diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c11bfe8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +#IDE +.idea/ +*.iml + +#Gradle +build/ diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..e018ef9 --- /dev/null +++ b/build.gradle @@ -0,0 +1,58 @@ +apply plugin: 'java' +apply plugin: 'eclipse' + +sourceCompatibility = '1.6' +targetCompatibility = '1.6' + +repositories +{ + maven + { + name 'forge' + url 'http://files.minecraftforge.net/maven' + } + mavenCentral() + maven + { + name 'sonatypeSnapshot' + url 'https://oss.sonatype.org/content/repositories/snapshots/' + } + maven + { + name 'minecraft' + url 'https://libraries.minecraft.net/' + } +} + +dependencies +{ + compile 'net.minecraft:launchwrapper:1.9' + compile 'org.ow2.asm:asm-debug-all:4.1' + compile 'org.scala-lang:scala-library:2.10.2' + compile 'org.scala-lang:scala-compiler:2.10.2' + compile 'net.sf.jopt-simple:jopt-simple:4.5' + compile 'java3d:vecmath:1.3.1' + compile 'net.sf.trove4j:trove4j:3.0.3' + compile 'com.ibm.icu:icu4j-core-mojang:51.2' + compile 'net.sf.jopt-simple:jopt-simple:4.5' + compile 'lzma:lzma:0.0.1' + compile 'com.paulscode:codecjorbis:20101023' + compile 'com.paulscode:codecwav:20101023' + compile 'com.paulscode:libraryjavasound:20101123' + compile 'com.paulscode:librarylwjglopenal:20100824' + compile 'com.paulscode:soundsystem:20120107' + compile 'io.netty:netty-all:4.0.10.Final' + compile 'com.google.guava:guava:15.0' + compile 'org.apache.commons:commons-lang3:3.1' + compile 'commons-io:commons-io:2.4' + compile 'net.java.jinput:jinput:2.0.5' + compile 'net.java.jutils:jutils:1.0.0' + compile 'com.google.code.gson:gson:2.2.4' + compile 'com.mojang:authlib:1.3' + compile 'org.apache.logging.log4j:log4j-api:2.0-beta9' + compile 'org.apache.logging.log4j:log4j-core:2.0-beta9' + compile 'org.lwjgl.lwjgl:lwjgl:2.9.0' + compile 'org.lwjgl.lwjgl:lwjgl_util:2.9.0' + + testCompile 'junit:junit:4.5' +} diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..3c7abdf --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.jar Binary files differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..244a668 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Wed Mar 26 13:33:58 CDT 2014 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=http\://services.gradle.org/distributions/gradle-1.11-bin.zip diff --git a/gradlew b/gradlew new file mode 100755 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/src/main/java/Start.java b/src/main/java/Start.java new file mode 100644 index 0000000..1505fad --- /dev/null +++ b/src/main/java/Start.java @@ -0,0 +1,114 @@ +import java.io.File; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.lang.reflect.Field; +import java.net.URL; +import java.net.URLConnection; +import java.net.URLEncoder; +import java.util.Arrays; + +import joptsimple.ArgumentAcceptingOptionSpec; +import joptsimple.OptionParser; +import joptsimple.OptionSet; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.main.Main; + +public class Start +{ + public static void main(String[] args) throws Exception + { + int userIndex = -1; + int passIndex = -1; + int sessIndex = -1; + int versIndex = -1; + + for( int x = 0; x < args.length; x++) + { + if (args[x].equals("--username")) userIndex = x + 1; + else if (args[x].equals("--password")) passIndex = x + 1; + else if (args[x].equals("--session")) sessIndex = x + 1; + else if (args[x].equals("--version")) versIndex = x + 1; + } + + if (userIndex != 0-1 && passIndex != -1 && sessIndex == -1) + { + String[] session = getSession(args[userIndex], args[passIndex]); + if (session != null) + { + args[userIndex] = session[0]; + args = concat(args, new String[]{"--session", session[1]}); + } + } + + //Kill the password if its there so it isn't printed to the console. + if (passIndex != -1) + { + args[passIndex-1] = "no_password_for_joo"; + args[passIndex] = "no_password_for_joo"; + } + + if (versIndex == -1) + { + args = concat(args, new String[]{ "--version", "fml_mcp" }); + } + + Main.main(args); + } + + private static String[] getSession(String username, String password) throws UnsupportedEncodingException + { + String parameters = "http://login.minecraft.net/?user=" + URLEncoder.encode(username, "UTF-8") + + "&password=" + URLEncoder.encode(password, "UTF-8") + + "&version=" + 13; + String result = openUrl(parameters); + + if (result == null) + { + System.out.println("Can't connect to minecraft.net"); + return null; + } + + if (!result.contains(":")) + { + System.out.println("Login Failed: " + result); + return null; + } + String[] values = result.split(":"); + return new String[]{ values[2].trim(), values[3].trim() }; + } + + private static String openUrl(String addr) + { + try + { + URL url = new URL(addr); + java.io.InputStream is; + is = url.openConnection().getInputStream(); + java.io.BufferedReader reader = new java.io.BufferedReader(new java.io.InputStreamReader(is)); + String buf = ""; + String line = null; + + while ((line = reader.readLine()) != null) + { + buf += "\n" + line; + } + + reader.close(); + return buf; + } + catch (IOException e) + { + e.printStackTrace(); + } + + return null; + } + + private static T[] concat(T[] first, T[] second) + { + T[] result = Arrays.copyOf(first, first.length + second.length); + System.arraycopy(second, 0, result, first.length, second.length); + return result; + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/client/CustomModLoadingErrorDisplayException.java b/src/main/java/cpw/mods/fml/client/CustomModLoadingErrorDisplayException.java new file mode 100644 index 0000000..0795ff1 --- /dev/null +++ b/src/main/java/cpw/mods/fml/client/CustomModLoadingErrorDisplayException.java @@ -0,0 +1,57 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.client; + +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.GuiErrorScreen; +import cpw.mods.fml.common.IFMLHandledException; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/** + * If a mod throws this exception during loading, it will be called back to render + * the error screen through the methods below. This error will not be cleared, and will + * not allow the game to carry on, but might be useful if your mod wishes to report + * a fatal configuration error in a pretty way. + * + * Throw this through a proxy. It won't work on the dedicated server environment. + * @author cpw + * + */ +@SideOnly(Side.CLIENT) +public abstract class CustomModLoadingErrorDisplayException extends RuntimeException implements IFMLHandledException +{ + private static final long serialVersionUID = 1L; + + /** + * Called after the GUI is inited by the parent code. You can do extra stuff here, maybe? + * + * @param errorScreen The error screen we're painting + * @param fontRenderer A font renderer for you + */ + public abstract void initGui(GuiErrorScreen errorScreen, FontRenderer fontRenderer); + + /** + * Draw your error to the screen. + * + *
Warning: Minecraft is in a deep error state. All it can do is stop. + * Do not try and do anything involving complex user interaction here. + * + * @param errorScreen The error screen to draw to + * @param fontRenderer A font renderer for you + * @param mouseRelX Mouse X + * @param mouseRelY Mouse Y + * @param tickTime tick time + */ + public abstract void drawScreen(GuiErrorScreen errorScreen, FontRenderer fontRenderer, int mouseRelX, int mouseRelY, float tickTime); +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/client/ExtendedServerListData.java b/src/main/java/cpw/mods/fml/client/ExtendedServerListData.java new file mode 100644 index 0000000..c397e7a --- /dev/null +++ b/src/main/java/cpw/mods/fml/client/ExtendedServerListData.java @@ -0,0 +1,18 @@ +package cpw.mods.fml.client; + +import java.util.Map; + +public class ExtendedServerListData { + public final String type; + public final boolean isCompatible; + public final Map modData; + public final boolean isBlocked; + + public ExtendedServerListData(String type, boolean isCompatible, Map modData, boolean isBlocked) + { + this.type = type; + this.isCompatible = isCompatible; + this.modData = modData; + this.isBlocked = isBlocked; + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/client/FMLClientHandler.java b/src/main/java/cpw/mods/fml/client/FMLClientHandler.java new file mode 100644 index 0000000..b0d03fa --- /dev/null +++ b/src/main/java/cpw/mods/fml/client/FMLClientHandler.java @@ -0,0 +1,850 @@ +/* + * The FML Forge Mod Loader suite. Copyright (C) 2012 cpw + * + * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation; either version 2.1 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +package cpw.mods.fml.client; + +import java.io.File; +import java.io.FileInputStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityClientPlayerMP; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.GuiIngameMenu; +import net.minecraft.client.gui.GuiMainMenu; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.GuiSelectWorld; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.gui.ServerListEntryNormal; +import net.minecraft.client.multiplayer.GuiConnecting; +import net.minecraft.client.multiplayer.ServerData; +import net.minecraft.client.multiplayer.WorldClient; +import net.minecraft.client.network.NetHandlerPlayClient; +import net.minecraft.client.network.OldServerPinger; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.resources.IReloadableResourceManager; +import net.minecraft.client.resources.IResourcePack; +import net.minecraft.crash.CrashReport; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.launchwrapper.Launch; +import net.minecraft.nbt.CompressedStreamTools; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.INetHandler; +import net.minecraft.network.NetHandlerPlayServer; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.ServerStatusResponse; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.WorldSettings; +import net.minecraft.world.storage.SaveFormatOld; + +import org.apache.logging.log4j.Level; +import org.lwjgl.input.Mouse; + +import com.google.common.base.Strings; +import com.google.common.base.Throwables; +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMap.Builder; +import com.google.common.collect.Maps; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; + +import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.common.DummyModContainer; +import cpw.mods.fml.common.DuplicateModsFoundException; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.IFMLSidedHandler; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.LoaderException; +import cpw.mods.fml.common.MetadataCollection; +import cpw.mods.fml.common.MissingModsException; +import cpw.mods.fml.common.ModContainer; +import cpw.mods.fml.common.ModMetadata; +import cpw.mods.fml.common.ObfuscationReflectionHelper; +import cpw.mods.fml.common.StartupQuery; +import cpw.mods.fml.common.WrongMinecraftVersionException; +import cpw.mods.fml.common.eventhandler.EventBus; +import cpw.mods.fml.common.network.FMLNetworkEvent; +import cpw.mods.fml.common.registry.GameData; +import cpw.mods.fml.common.registry.LanguageRegistry; +import cpw.mods.fml.common.toposort.ModSortingException; +import cpw.mods.fml.relauncher.Side; + + +/** + * Handles primary communication from hooked code into the system + * + * The FML entry point is {@link #beginMinecraftLoading(Minecraft, List)} called from + * {@link Minecraft} + * + * Obfuscated code should focus on this class and other members of the "server" + * (or "client") code + * + * The actual mod loading is handled at arms length by {@link Loader} + * + * It is expected that a similar class will exist for each target environment: + * Bukkit and Client side. + * + * It should not be directly modified. + * + * @author cpw + * + */ +public class FMLClientHandler implements IFMLSidedHandler +{ + /** + * The singleton + */ + private static final FMLClientHandler INSTANCE = new FMLClientHandler(); + + /** + * A reference to the server itself + */ + private Minecraft client; + + private DummyModContainer optifineContainer; + + @SuppressWarnings("unused") + private boolean guiLoaded; + + @SuppressWarnings("unused") + private boolean serverIsRunning; + + private MissingModsException modsMissing; + + private ModSortingException modSorting; + + private boolean loading = true; + + private WrongMinecraftVersionException wrongMC; + + private CustomModLoadingErrorDisplayException customError; + + private DuplicateModsFoundException dupesFound; + + private boolean serverShouldBeKilledQuietly; + + private List resourcePackList; + + @SuppressWarnings("unused") + private IReloadableResourceManager resourceManager; + + private Map resourcePackMap; + + private BiMap guiFactories; + + private Map extraServerListData; + private Map serverDataTag; + + private NetHandlerPlayClient currentPlayClient; + + /** + * Called to start the whole game off + * + * @param minecraft The minecraft instance being launched + * @param resourcePackList The resource pack list we will populate with mods + * @param resourceManager The resource manager + */ + @SuppressWarnings("unchecked") + public void beginMinecraftLoading(Minecraft minecraft, @SuppressWarnings("rawtypes") List resourcePackList, IReloadableResourceManager resourceManager) + { + client = minecraft; + this.resourcePackList = resourcePackList; + this.resourceManager = resourceManager; + this.resourcePackMap = Maps.newHashMap(); + if (minecraft.isDemo()) + { + FMLLog.severe("DEMO MODE DETECTED, FML will not work. Finishing now."); + haltGame("FML will not run in demo mode", new RuntimeException()); + return; + } + + FMLCommonHandler.instance().beginLoading(this); + try + { + Class optifineConfig = Class.forName("Config", false, Loader.instance().getModClassLoader()); + String optifineVersion = (String) optifineConfig.getField("VERSION").get(null); + Map dummyOptifineMeta = ImmutableMap.builder().put("name", "Optifine").put("version", optifineVersion).build(); + ModMetadata optifineMetadata = MetadataCollection.from(getClass().getResourceAsStream("optifinemod.info"),"optifine").getMetadataForId("optifine", dummyOptifineMeta); + optifineContainer = new DummyModContainer(optifineMetadata); + FMLLog.info("Forge Mod Loader has detected optifine %s, enabling compatibility features",optifineContainer.getVersion()); + } + catch (Exception e) + { + optifineContainer = null; + } + try + { + Loader.instance().loadMods(); + } + catch (WrongMinecraftVersionException wrong) + { + wrongMC = wrong; + } + catch (DuplicateModsFoundException dupes) + { + dupesFound = dupes; + } + catch (MissingModsException missing) + { + modsMissing = missing; + } + catch (ModSortingException sorting) + { + modSorting = sorting; + } + catch (CustomModLoadingErrorDisplayException custom) + { + FMLLog.log(Level.ERROR, custom, "A custom exception was thrown by a mod, the game will now halt"); + customError = custom; + } + catch (LoaderException le) + { + haltGame("There was a severe problem during mod loading that has caused the game to fail", le); + return; + } + + Map> sharedModList = (Map>) Launch.blackboard.get("modList"); + if (sharedModList == null) + { + sharedModList = Maps.newHashMap(); + Launch.blackboard.put("modList", sharedModList); + } + for (ModContainer mc : Loader.instance().getActiveModList()) + { + Map sharedModDescriptor = mc.getSharedModDescriptor(); + if (sharedModDescriptor != null) + { + String sharedModId = "fml:"+mc.getModId(); + sharedModList.put(sharedModId, sharedModDescriptor); + } + } + } + + @Override + public void haltGame(String message, Throwable t) + { + client.displayCrashReport(new CrashReport(message, t)); + throw Throwables.propagate(t); + } + /** + * Called a bit later on during initialization to finish loading mods + * Also initializes key bindings + * + */ + @SuppressWarnings({ "deprecation", "unchecked" }) + public void finishMinecraftLoading() + { + if (modsMissing != null || wrongMC != null || customError!=null || dupesFound!=null || modSorting!=null) + { + return; + } + try + { + Loader.instance().initializeMods(); + } + catch (CustomModLoadingErrorDisplayException custom) + { + FMLLog.log(Level.ERROR, custom, "A custom exception was thrown by a mod, the game will now halt"); + customError = custom; + return; + } + catch (LoaderException le) + { + haltGame("There was a severe problem during mod loading that has caused the game to fail", le); + return; + } + + // Reload resources + client.refreshResources(); + RenderingRegistry.instance().loadEntityRenderers((Map, Render>)RenderManager.instance.entityRenderMap); + guiFactories = HashBiMap.create(); + for (ModContainer mc : Loader.instance().getActiveModList()) + { + String className = mc.getGuiClassName(); + if (Strings.isNullOrEmpty(className)) + { + continue; + } + try + { + Class clazz = Class.forName(className, true, Loader.instance().getModClassLoader()); + Class guiClassFactory = clazz.asSubclass(IModGuiFactory.class); + IModGuiFactory guiFactory = guiClassFactory.newInstance(); + guiFactory.initialize(client); + guiFactories.put(mc, guiFactory); + } catch (Exception e) + { + FMLLog.log(Level.ERROR, e, "A critical error occurred instantiating the gui factory for mod %s", mc.getModId()); + } + } + loading = false; + client.gameSettings.loadOptions(); //Reload options to load any mod added keybindings. + } + + @SuppressWarnings("unused") + public void extendModList() + { + @SuppressWarnings("unchecked") + Map> modList = (Map>) Launch.blackboard.get("modList"); + if (modList != null) + { + for (Entry> modEntry : modList.entrySet()) + { + String sharedModId = modEntry.getKey(); + String system = sharedModId.split(":")[0]; + if ("fml".equals(system)) + { + continue; + } + Map mod = modEntry.getValue(); + String modSystem = mod.get("modsystem"); // the modsystem (FML uses FML or ModLoader) + String modId = mod.get("id"); // unique ID + String modVersion = mod.get("version"); // version + String modName = mod.get("name"); // a human readable name + String modURL = mod.get("url"); // a URL for the mod (can be empty string) + String modAuthors = mod.get("authors"); // a csv of authors (can be empty string) + String modDescription = mod.get("description"); // a (potentially) multiline description (can be empty string) + } + } + + } + public void onInitializationComplete() + { + if (wrongMC != null) + { + showGuiScreen(new GuiWrongMinecraft(wrongMC)); + } + else if (modsMissing != null) + { + showGuiScreen(new GuiModsMissing(modsMissing)); + } + else if (dupesFound != null) + { + showGuiScreen(new GuiDupesFound(dupesFound)); + } + else if (modSorting != null) + { + showGuiScreen(new GuiSortingProblem(modSorting)); + } + else if (customError != null) + { + showGuiScreen(new GuiCustomModLoadingErrorScreen(customError)); + } + else + { + } + } + /** + * Get the server instance + */ + public Minecraft getClient() + { + return client; + } + + /** + * @return the instance + */ + public static FMLClientHandler instance() + { + return INSTANCE; + } + + /** + * @param player + * @param gui + */ + public void displayGuiScreen(EntityPlayer player, GuiScreen gui) + { + if (client.thePlayer==player && gui != null) { + client.displayGuiScreen(gui); + } + } + + /** + * @param mods + */ + public void addSpecialModEntries(ArrayList mods) + { + if (optifineContainer!=null) { + mods.add(optifineContainer); + } + } + + @Override + public List getAdditionalBrandingInformation() + { + if (optifineContainer!=null) + { + return Arrays.asList(String.format("Optifine %s",optifineContainer.getVersion())); + } else { + return ImmutableList.of(); + } + } + + @Override + public Side getSide() + { + return Side.CLIENT; + } + + public boolean hasOptifine() + { + return optifineContainer!=null; + } + + @Override + public void showGuiScreen(Object clientGuiElement) + { + GuiScreen gui = (GuiScreen) clientGuiElement; + client.displayGuiScreen(gui); + } + + @Override + public void queryUser(StartupQuery query) throws InterruptedException + { + if (query.getResult() == null) + { + client.displayGuiScreen(new GuiNotification(query)); + } + else + { + client.displayGuiScreen(new GuiConfirmation(query)); + } + + if (query.isSynchronous()) + { + while (client.currentScreen instanceof GuiNotification) + { + if (Thread.interrupted()) throw new InterruptedException(); + + client.loadingScreen.resetProgresAndWorkingMessage(""); + + Thread.sleep(50); + } + + client.loadingScreen.resetProgresAndWorkingMessage(""); // make sure the blank screen is being drawn at the end + } + } + + public boolean handleLoadingScreen(ScaledResolution scaledResolution) + { + if (client.currentScreen instanceof GuiNotification) + { + int width = scaledResolution.getScaledWidth(); + int height = scaledResolution.getScaledHeight(); + int mouseX = Mouse.getX() * width / client.displayWidth; + int mouseZ = height - Mouse.getY() * height / client.displayHeight - 1; + + client.currentScreen.drawScreen(mouseX, mouseZ, 0); + client.currentScreen.handleInput(); + + return true; + } + else + { + return false; + } + } + + public WorldClient getWorldClient() + { + return client.theWorld; + } + + public EntityClientPlayerMP getClientPlayerEntity() + { + return client.thePlayer; + } + + @Override + public void beginServerLoading(MinecraftServer server) + { + serverShouldBeKilledQuietly = false; + // NOOP + } + + @Override + public void finishServerLoading() + { + // NOOP + } + + @Override + public File getSavesDirectory() + { + return ((SaveFormatOld) client.getSaveLoader()).savesDirectory; + } + + @Override + public MinecraftServer getServer() + { + return client.getIntegratedServer(); + } + + public void displayMissingMods(Object modMissingPacket) + { +// showGuiScreen(new GuiModsMissingForServer(modMissingPacket)); + } + + /** + * If the client is in the midst of loading, we disable saving so that custom settings aren't wiped out + */ + public boolean isLoading() + { + return loading; + } + + @Override + public boolean shouldServerShouldBeKilledQuietly() + { + return serverShouldBeKilledQuietly; + } + + /** + * Is this GUI type open? + * + * @param gui The type of GUI to test for + * @return if a GUI of this type is open + */ + public boolean isGUIOpen(Class gui) + { + return client.currentScreen != null && client.currentScreen.getClass().equals(gui); + } + + + @Override + public void addModAsResource(ModContainer container) + { + LanguageRegistry.instance().loadLanguagesFor(container, Side.CLIENT); + Class resourcePackType = container.getCustomResourcePackClass(); + if (resourcePackType != null) + { + try + { + IResourcePack pack = (IResourcePack) resourcePackType.getConstructor(ModContainer.class).newInstance(container); + resourcePackList.add(pack); + resourcePackMap.put(container.getModId(), pack); + } + catch (NoSuchMethodException e) + { + FMLLog.log(Level.ERROR, "The container %s (type %s) returned an invalid class for it's resource pack.", container.getName(), container.getClass().getName()); + return; + } + catch (Exception e) + { + FMLLog.log(Level.ERROR, e, "An unexpected exception occurred constructing the custom resource pack for %s", container.getName()); + throw Throwables.propagate(e); + } + } + } + + @Override + public void updateResourcePackList() + { + client.refreshResources(); + } + + public IResourcePack getResourcePackFor(String modId) + { + return resourcePackMap.get(modId); + } + + @Override + public String getCurrentLanguage() + { + return client.getLanguageManager().getCurrentLanguage().getLanguageCode(); + } + + @Override + public void serverStopped() + { + // If the server crashes during startup, it might hang the client- reset the client so it can abend properly. + MinecraftServer server = getServer(); + + if (server != null && !server.serverIsInRunLoop()) + { + ObfuscationReflectionHelper.setPrivateValue(MinecraftServer.class, server, true, "field_71296"+"_Q","serverIs"+"Running"); + } + } + + @Override + public INetHandler getClientPlayHandler() + { + return this.currentPlayClient; + } + @Override + public NetworkManager getClientToServerNetworkManager() + { + return this.client.getNetHandler()!=null ? this.client.getNetHandler().getNetworkManager() : null; + } + + public void handleClientWorldClosing(WorldClient world) + { + NetworkManager client = getClientToServerNetworkManager(); + // ONLY revert a non-local connection + if (client != null && !client.isLocalChannel()) + { + GameData.revertToFrozen(); + } + } + + public void startIntegratedServer(String id, String name, WorldSettings settings) + { + playClientBlock = new CountDownLatch(1); + } + + public File getSavesDir() + { + return new File(client.mcDataDir, "saves"); + } + public void tryLoadExistingWorld(GuiSelectWorld selectWorldGUI, String dirName, String saveName) + { + File dir = new File(getSavesDir(), dirName); + NBTTagCompound leveldat; + try + { + leveldat = CompressedStreamTools.readCompressed(new FileInputStream(new File(dir, "level.dat"))); + } + catch (Exception e) + { + try + { + leveldat = CompressedStreamTools.readCompressed(new FileInputStream(new File(dir, "level.dat_old"))); + } + catch (Exception e1) + { + FMLLog.warning("There appears to be a problem loading the save %s, both level files are unreadable.", dirName); + return; + } + } + NBTTagCompound fmlData = leveldat.getCompoundTag("FML"); + if (fmlData.hasKey("ModItemData")) + { + showGuiScreen(new GuiOldSaveLoadConfirm(dirName, saveName, selectWorldGUI)); + } + else + { + try + { + client.launchIntegratedServer(dirName, saveName, (WorldSettings)null); + } + catch (StartupQuery.AbortedException e) + { + // ignore + } + } + } + + public void showInGameModOptions(GuiIngameMenu guiIngameMenu) + { + showGuiScreen(new GuiIngameModOptions(guiIngameMenu)); + } + + public IModGuiFactory getGuiFactoryFor(ModContainer selectedMod) + { + return guiFactories.get(selectedMod); + } + + + public void setupServerList() + { + extraServerListData = Collections.synchronizedMap(Maps.newHashMap()); + serverDataTag = Collections.synchronizedMap(Maps.newHashMap()); + } + + public void captureAdditionalData(ServerStatusResponse serverstatusresponse, JsonObject jsonobject) + { + if (jsonobject.has("modinfo")) + { + JsonObject fmlData = jsonobject.get("modinfo").getAsJsonObject(); + extraServerListData.put(serverstatusresponse, fmlData); + } + } + public void bindServerListData(ServerData data, ServerStatusResponse originalResponse) + { + if (extraServerListData.containsKey(originalResponse)) + { + JsonObject jsonData = extraServerListData.get(originalResponse); + String type = jsonData.get("type").getAsString(); + JsonArray modDataArray = jsonData.get("modList").getAsJsonArray(); + boolean moddedClientAllowed = jsonData.has("clientModsAllowed") ? jsonData.get("clientModsAllowed").getAsBoolean() : true; + Builder modListBldr = ImmutableMap.builder(); + for (JsonElement obj : modDataArray) + { + JsonObject modObj = obj.getAsJsonObject(); + modListBldr.put(modObj.get("modid").getAsString(), modObj.get("version").getAsString()); + } + + serverDataTag.put(data, new ExtendedServerListData(type, true, modListBldr.build(), !moddedClientAllowed)); + } + else + { + String serverDescription = data.serverMOTD; + boolean moddedClientAllowed = true; + if (!Strings.isNullOrEmpty(serverDescription)) + { + moddedClientAllowed = !serverDescription.endsWith(":NOFML§r"); + } + serverDataTag.put(data, new ExtendedServerListData("VANILLA", false, ImmutableMap.of(), !moddedClientAllowed)); + } + startupConnectionData.countDown(); + } + + private static final ResourceLocation iconSheet = new ResourceLocation("fml:textures/gui/icons.png"); + private static final CountDownLatch startupConnectionData = new CountDownLatch(1); + + public String enhanceServerListEntry(ServerListEntryNormal serverListEntry, ServerData serverEntry, int x, int width, int y, int relativeMouseX, int relativeMouseY) + { + String tooltip; + int idx; + boolean blocked = false; + if (serverDataTag.containsKey(serverEntry)) + { + ExtendedServerListData extendedData = serverDataTag.get(serverEntry); + if ("FML".equals(extendedData.type) && extendedData.isCompatible) + { + idx = 0; + tooltip = String.format("Compatible FML modded server\n%d mods present", extendedData.modData.size()); + } + else if ("FML".equals(extendedData.type) && !extendedData.isCompatible) + { + idx = 16; + tooltip = String.format("Incompatible FML modded server\n%d mods present", extendedData.modData.size()); + } + else if ("BUKKIT".equals(extendedData.type)) + { + idx = 32; + tooltip = String.format("Bukkit modded server"); + } + else if ("VANILLA".equals(extendedData.type)) + { + idx = 48; + tooltip = String.format("Vanilla server"); + } + else + { + idx = 64; + tooltip = String.format("Unknown server data"); + } + blocked = extendedData.isBlocked; + } + else + { + return null; + } + this.client.getTextureManager().bindTexture(iconSheet); + Gui.func_146110_a(x + width - 18, y + 10, 0, (float)idx, 16, 16, 256.0f, 256.0f); + if (blocked) + { + Gui.func_146110_a(x + width - 18, y + 10, 0, 80, 16, 16, 256.0f, 256.0f); + } + + return relativeMouseX > width - 15 && relativeMouseX < width && relativeMouseY > 10 && relativeMouseY < 26 ? tooltip : null; + } + + public String fixDescription(String description) + { + return description.endsWith(":NOFML§r") ? description.substring(0, description.length() - 8)+"§r" : description; + } + + public void connectToServerAtStartup(String host, int port) + { + setupServerList(); + OldServerPinger osp = new OldServerPinger(); + ServerData serverData = new ServerData("Command Line", host+":"+port); + try + { + osp.func_147224_a(serverData); + startupConnectionData.await(30, TimeUnit.SECONDS); + } + catch (Exception e) + { + showGuiScreen(new GuiConnecting(new GuiMainMenu(), client, host, port)); + return; + } + connectToServer(new GuiMainMenu(), serverData); + } + + public void connectToServer(GuiScreen guiMultiplayer, ServerData serverEntry) + { + ExtendedServerListData extendedData = serverDataTag.get(serverEntry); + if (extendedData != null && extendedData.isBlocked) + { + showGuiScreen(new GuiAccessDenied(guiMultiplayer, serverEntry)); + } + else + { + showGuiScreen(new GuiConnecting(guiMultiplayer, client, serverEntry)); + } + playClientBlock = new CountDownLatch(1); + } + + private CountDownLatch playClientBlock; + + public void setPlayClient(NetHandlerPlayClient netHandlerPlayClient) + { + playClientBlock.countDown(); + this.currentPlayClient = netHandlerPlayClient; + } + + @Override + public void waitForPlayClient() + { + boolean gotIt = false; + try + { + gotIt = playClientBlock.await(1,TimeUnit.SECONDS); + } catch (InterruptedException e) + { + } + if (!gotIt) + { + throw new RuntimeException("Timeout waiting for client thread to catch up!"); + } + } + + @Override + public void fireNetRegistrationEvent(EventBus bus, NetworkManager manager, Set channelSet, String channel, Side side) + { + if (side == Side.CLIENT) + { + bus.post(new FMLNetworkEvent.CustomPacketRegistrationEvent(manager, channelSet, channel, side, NetHandlerPlayClient.class)); + } + else + { + bus.post(new FMLNetworkEvent.CustomPacketRegistrationEvent(manager, channelSet, channel, side, NetHandlerPlayServer.class)); + } + } + + @Override + public boolean shouldAllowPlayerLogins() + { + return true; //Always true as the server has to be started before clicking 'Open to lan' + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/client/FMLConfigGuiFactory.java b/src/main/java/cpw/mods/fml/client/FMLConfigGuiFactory.java new file mode 100644 index 0000000..83697c8 --- /dev/null +++ b/src/main/java/cpw/mods/fml/client/FMLConfigGuiFactory.java @@ -0,0 +1,100 @@ +package cpw.mods.fml.client; + +import java.util.List; +import java.util.Set; +import com.google.common.collect.ImmutableSet; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.resources.I18n; + +public class FMLConfigGuiFactory implements IModGuiFactory { + public static class FMLConfigGuiScreen extends GuiScreen { + private GuiScreen parent; + + public FMLConfigGuiScreen(GuiScreen parent) + { + this.parent = parent; + } + + @SuppressWarnings("unchecked") + @Override + public void initGui() + { + this.buttonList.add(new GuiButton(1, this.width / 2 - 75, this.height - 38, I18n.format("gui.done"))); + } + + @Override + protected void actionPerformed(GuiButton par1GuiButton) + { + if (par1GuiButton.enabled && par1GuiButton.id == 1) + { + FMLClientHandler.instance().showGuiScreen(parent); + } + } + + @Override + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + this.drawCenteredString(this.fontRendererObj, "Forge Mod Loader test config screen", this.width / 2, 40, 0xFFFFFF); + super.drawScreen(par1, par2, par3); + } + + } + + @SuppressWarnings("unused") + private Minecraft minecraft; + @Override + public void initialize(Minecraft minecraftInstance) + { + this.minecraft = minecraftInstance; + } + + @Override + public Class mainConfigGuiClass() + { + return FMLConfigGuiScreen.class; + } + + private static final Set fmlCategories = ImmutableSet.of(new RuntimeOptionCategoryElement("HELP", "FML")); + + @Override + public Set runtimeGuiCategories() + { + return fmlCategories; + } + + @Override + public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) + { + return new RuntimeOptionGuiHandler() { + @Override + public void paint(int x, int y, int w, int h) + { + // TODO Auto-generated method stub + + } + + @Override + public void close() + { + } + + @Override + public void addWidgets(List widgets, int x, int y, int w, int h) + { + widgets.add(new GuiButton(100, x+10, y+10, "HELLO")); + } + + @Override + public void actionCallback(int actionId) + { + // TODO Auto-generated method stub + + } + }; + } + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/client/FMLFileResourcePack.java b/src/main/java/cpw/mods/fml/client/FMLFileResourcePack.java new file mode 100644 index 0000000..9948f4a --- /dev/null +++ b/src/main/java/cpw/mods/fml/client/FMLFileResourcePack.java @@ -0,0 +1,61 @@ +package cpw.mods.fml.client; + +import java.awt.image.BufferedImage; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import org.apache.logging.log4j.Level; + +import javax.imageio.ImageIO; + +import net.minecraft.client.resources.FileResourcePack; + +import com.google.common.base.Charsets; + +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.ModContainer; + +public class FMLFileResourcePack extends FileResourcePack { + + private ModContainer container; + + public FMLFileResourcePack(ModContainer container) + { + super(container.getSource()); + this.container = container; + } + + @Override + public String getPackName() + { + return "FMLFileResourcePack:"+container.getName(); + } + @Override + protected InputStream getInputStreamByName(String resourceName) throws IOException + { + try + { + return super.getInputStreamByName(resourceName); + } + catch (IOException ioe) + { + if ("pack.mcmeta".equals(resourceName)) + { + FMLLog.log(container.getName(), Level.DEBUG, "Mod %s is missing a pack.mcmeta file, substituting a dummy one", container.getName()); + return new ByteArrayInputStream(("{\n" + + " \"pack\": {\n"+ + " \"description\": \"dummy FML pack for "+container.getName()+"\",\n"+ + " \"pack_format\": 1\n"+ + "}\n" + + "}").getBytes(Charsets.UTF_8)); + } + else throw ioe; + } + } + + @Override + public BufferedImage getPackImage() throws IOException + { + return ImageIO.read(getInputStreamByName(container.getMetadata().logoFile)); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/client/FMLFolderResourcePack.java b/src/main/java/cpw/mods/fml/client/FMLFolderResourcePack.java new file mode 100644 index 0000000..7361157 --- /dev/null +++ b/src/main/java/cpw/mods/fml/client/FMLFolderResourcePack.java @@ -0,0 +1,67 @@ +package cpw.mods.fml.client; + +import java.awt.image.BufferedImage; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import org.apache.logging.log4j.Level; + +import javax.imageio.ImageIO; + +import net.minecraft.client.resources.FolderResourcePack; + +import com.google.common.base.Charsets; + +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.ModContainer; + +public class FMLFolderResourcePack extends FolderResourcePack { + + private ModContainer container; + + public FMLFolderResourcePack(ModContainer container) + { + super(container.getSource()); + this.container = container; + } + + @Override + protected boolean hasResourceName(String par1Str) + { + return super.hasResourceName(par1Str); + } + @Override + public String getPackName() + { + return "FMLFileResourcePack:"+container.getName(); + } + @Override + protected InputStream getInputStreamByName(String resourceName) throws IOException + { + try + { + return super.getInputStreamByName(resourceName); + } + catch (IOException ioe) + { + if ("pack.mcmeta".equals(resourceName)) + { + FMLLog.log(container.getName(), Level.DEBUG, "Mod %s is missing a pack.mcmeta file, substituting a dummy one", container.getName()); + return new ByteArrayInputStream(("{\n" + + " \"pack\": {\n"+ + " \"description\": \"dummy FML pack for "+container.getName()+"\",\n"+ + " \"pack_format\": 1\n"+ + "}\n" + + "}").getBytes(Charsets.UTF_8)); + } + else throw ioe; + } + } + + @Override + public BufferedImage getPackImage() throws IOException + { + return ImageIO.read(getInputStreamByName(container.getMetadata().logoFile)); + } + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/client/GuiAccessDenied.java b/src/main/java/cpw/mods/fml/client/GuiAccessDenied.java new file mode 100644 index 0000000..a47fe85 --- /dev/null +++ b/src/main/java/cpw/mods/fml/client/GuiAccessDenied.java @@ -0,0 +1,55 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.client; + +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.multiplayer.ServerData; +import net.minecraft.client.resources.I18n; + +public class GuiAccessDenied extends GuiScreen +{ + private GuiScreen parent; + private ServerData data; + public GuiAccessDenied(GuiScreen parent, ServerData data) + { + this.parent = parent; + this.data = data; + } + + @SuppressWarnings("unchecked") + @Override + public void initGui() + { + this.buttonList.add(new GuiButton(1, this.width / 2 - 75, this.height - 38, I18n.format("gui.done"))); + } + + @Override + protected void actionPerformed(GuiButton par1GuiButton) + { + if (par1GuiButton.enabled && par1GuiButton.id == 1) + { + FMLClientHandler.instance().showGuiScreen(parent); + } + } + @Override + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + int offset = Math.max(85 - 2 * 10, 10); + this.drawCenteredString(this.fontRendererObj, "Forge Mod Loader could not connect to this server", this.width / 2, offset, 0xFFFFFF); + offset += 10; + this.drawCenteredString(this.fontRendererObj, String.format("The server %s has forbidden modded access", data.serverName), this.width / 2, offset, 0xFFFFFF); + super.drawScreen(par1, par2, par3); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/client/GuiBackupFailed.java b/src/main/java/cpw/mods/fml/client/GuiBackupFailed.java new file mode 100644 index 0000000..df9af95 --- /dev/null +++ b/src/main/java/cpw/mods/fml/client/GuiBackupFailed.java @@ -0,0 +1,55 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.client; + +import java.io.File; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.resources.I18n; + +public class GuiBackupFailed extends GuiScreen +{ + private GuiScreen parent; + private File zipName; + public GuiBackupFailed(GuiScreen parent, File zipName) + { + this.parent = parent; + this.zipName = zipName; + } + + @SuppressWarnings("unchecked") + @Override + public void initGui() + { + this.buttonList.add(new GuiButton(1, this.width / 2 - 75, this.height - 38, I18n.format("gui.done"))); + } + + @Override + protected void actionPerformed(GuiButton par1GuiButton) + { + if (par1GuiButton.enabled && par1GuiButton.id == 1) + { + FMLClientHandler.instance().showGuiScreen(parent); + } + } + @Override + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + int offset = Math.max(85 - 2 * 10, 10); + this.drawCenteredString(this.fontRendererObj, String.format("There was an error saving the archive %s", zipName.getName()), this.width / 2, offset, 0xFFFFFF); + offset += 10; + this.drawCenteredString(this.fontRendererObj, String.format("Please fix the problem and try again"), this.width / 2, offset, 0xFFFFFF); + super.drawScreen(par1, par2, par3); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/client/GuiConfirmation.java b/src/main/java/cpw/mods/fml/client/GuiConfirmation.java new file mode 100644 index 0000000..1b69033 --- /dev/null +++ b/src/main/java/cpw/mods/fml/client/GuiConfirmation.java @@ -0,0 +1,33 @@ +package cpw.mods.fml.client; + +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiOptionButton; +import net.minecraft.client.resources.I18n; +import cpw.mods.fml.common.StartupQuery; + +public class GuiConfirmation extends GuiNotification +{ + public GuiConfirmation(StartupQuery query) + { + super(query); + } + + @SuppressWarnings("unchecked") + @Override + public void initGui() + { + this.buttonList.add(new GuiOptionButton(0, this.width / 2 - 155, this.height - 38, I18n.format("gui.yes"))); + this.buttonList.add(new GuiOptionButton(1, this.width / 2 - 155 + 160, this.height - 38, I18n.format("gui.no"))); + } + + @Override + protected void actionPerformed(GuiButton button) + { + if (button.enabled && (button.id == 0 || button.id == 1)) + { + FMLClientHandler.instance().showGuiScreen(null); + query.setResult(button.id == 0); + query.finish(); + } + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/client/GuiCustomModLoadingErrorScreen.java b/src/main/java/cpw/mods/fml/client/GuiCustomModLoadingErrorScreen.java new file mode 100644 index 0000000..1686543 --- /dev/null +++ b/src/main/java/cpw/mods/fml/client/GuiCustomModLoadingErrorScreen.java @@ -0,0 +1,37 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.client; + +import net.minecraft.client.gui.GuiErrorScreen; + +public class GuiCustomModLoadingErrorScreen extends GuiErrorScreen +{ + private CustomModLoadingErrorDisplayException customException; + public GuiCustomModLoadingErrorScreen(CustomModLoadingErrorDisplayException customException) + { + super(null,null); + this.customException = customException; + } + @Override + public void initGui() + { + super.initGui(); + this.customException.initGui(this, fontRendererObj); + } + @Override + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + this.customException.drawScreen(this, fontRendererObj, par1, par2, par3); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/client/GuiDupesFound.java b/src/main/java/cpw/mods/fml/client/GuiDupesFound.java new file mode 100644 index 0000000..28d7ddd --- /dev/null +++ b/src/main/java/cpw/mods/fml/client/GuiDupesFound.java @@ -0,0 +1,55 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.client; + +import java.io.File; +import java.util.Map.Entry; + +import net.minecraft.client.gui.GuiErrorScreen; +import cpw.mods.fml.common.DuplicateModsFoundException; +import cpw.mods.fml.common.ModContainer; + +public class GuiDupesFound extends GuiErrorScreen +{ + + private DuplicateModsFoundException dupes; + + public GuiDupesFound(DuplicateModsFoundException dupes) + { + super(null,null); + this.dupes = dupes; + } + + @Override + public void initGui() + { + super.initGui(); + } + @Override + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + int offset = Math.max(85 - dupes.dupes.size() * 10, 10); + this.drawCenteredString(this.fontRendererObj, "Forge Mod Loader has found a problem with your minecraft installation", this.width / 2, offset, 0xFFFFFF); + offset+=10; + this.drawCenteredString(this.fontRendererObj, "You have mod sources that are duplicate within your system", this.width / 2, offset, 0xFFFFFF); + offset+=10; + this.drawCenteredString(this.fontRendererObj, "Mod Id : File name", this.width / 2, offset, 0xFFFFFF); + offset+=5; + for (Entry mc : dupes.dupes.entries()) + { + offset+=10; + this.drawCenteredString(this.fontRendererObj, String.format("%s : %s", mc.getKey().getModId(), mc.getValue().getName()), this.width / 2, offset, 0xEEEEEE); + } + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/client/GuiIngameModOptions.java b/src/main/java/cpw/mods/fml/client/GuiIngameModOptions.java new file mode 100644 index 0000000..1091254 --- /dev/null +++ b/src/main/java/cpw/mods/fml/client/GuiIngameModOptions.java @@ -0,0 +1,55 @@ +package cpw.mods.fml.client; + +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.resources.I18n; + +public class GuiIngameModOptions extends GuiScreen +{ + private final GuiScreen parentScreen; + protected String title = "Mod Options"; + private GuiModOptionList optionList; + + public GuiIngameModOptions(GuiScreen parentScreen) + { + this.parentScreen = parentScreen; + } + + @SuppressWarnings("unchecked") + @Override + public void initGui() + { + this.optionList=new GuiModOptionList(this); + this.optionList.registerScrollButtons(this.buttonList, 7, 8); + this.buttonList.add(new GuiButton(200, this.width / 2 - 100, this.height / 6 + 168, I18n.format("gui.done", new Object[0]))); + } + + @Override + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.enabled) + { + if (p_146284_1_.id == 200) + { + this.mc.gameSettings.saveOptions(); + this.mc.displayGuiScreen(this.parentScreen); + } + } + } + + @Override + public void drawScreen(int par1, int par2, float par3) + { + // force a non-transparent background + this.drawDefaultBackground(); + this.optionList.drawScreen(par1, par2, par3); + this.drawCenteredString(this.fontRendererObj, this.title, this.width / 2, 15, 0xFFFFFF); + super.drawScreen(par1, par2, par3); + } + + FontRenderer getFontRenderer() { + return fontRendererObj; + } + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/client/GuiModList.java b/src/main/java/cpw/mods/fml/client/GuiModList.java new file mode 100644 index 0000000..c327701 --- /dev/null +++ b/src/main/java/cpw/mods/fml/client/GuiModList.java @@ -0,0 +1,304 @@ +/* + * The FML Forge Mod Loader suite. + * Copyright (C) 2012 cpw + * + * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation; either version 2.1 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package cpw.mods.fml.client; + +import java.awt.Dimension; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; + +import javax.imageio.ImageIO; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.DynamicTexture; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.client.resources.I18n; +import net.minecraft.client.resources.IResourcePack; +import net.minecraft.util.ResourceLocation; + +import org.apache.logging.log4j.Level; +import org.lwjgl.opengl.GL11; + +import com.google.common.base.Strings; + +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.ModContainer; +import cpw.mods.fml.common.ModContainer.Disableable; + +/** + * @author cpw + * + */ +public class GuiModList extends GuiScreen +{ + private GuiScreen mainMenu; + private GuiSlotModList modList; + private int selected = -1; + private ModContainer selectedMod; + private int listWidth; + private ArrayList mods; + private GuiButton configModButton; + private GuiButton disableModButton; + private ResourceLocation cachedLogo; + private Dimension cachedLogoDimensions; + + /** + * @param mainMenu + */ + public GuiModList(GuiScreen mainMenu) + { + this.mainMenu=mainMenu; + this.mods=new ArrayList(); + FMLClientHandler.instance().addSpecialModEntries(mods); + for (ModContainer mod : Loader.instance().getModList()) { + if (mod.getMetadata()!=null && mod.getMetadata().parentMod==null && !Strings.isNullOrEmpty(mod.getMetadata().parent)) { + String parentMod = mod.getMetadata().parent; + ModContainer parentContainer = Loader.instance().getIndexedModList().get(parentMod); + if (parentContainer != null) + { + mod.getMetadata().parentMod = parentContainer; + parentContainer.getMetadata().childMods.add(mod); + continue; + } + } + else if (mod.getMetadata()!=null && mod.getMetadata().parentMod!=null) + { + continue; + } + mods.add(mod); + } + } + + @SuppressWarnings("unchecked") + @Override + public void initGui() + { + for (ModContainer mod : mods) { + listWidth=Math.max(listWidth,getFontRenderer().getStringWidth(mod.getName()) + 10); + listWidth=Math.max(listWidth,getFontRenderer().getStringWidth(mod.getVersion()) + 10); + } + listWidth=Math.min(listWidth, 150); + this.buttonList.add(new GuiButton(6, this.width / 2 - 75, this.height - 38, I18n.format("gui.done"))); + configModButton = new GuiButton(20, 10, this.height - 60, this.listWidth, 20, "Config"); + disableModButton = new GuiButton(21, 10, this.height - 38, this.listWidth, 20, "Disable"); + this.buttonList.add(configModButton); + this.buttonList.add(disableModButton); + this.modList=new GuiSlotModList(this, mods, listWidth); + this.modList.registerScrollButtons(this.buttonList, 7, 8); + } + + @Override + protected void actionPerformed(GuiButton button) { + if (button.enabled) + { + switch (button.id) + { + case 6: + this.mc.displayGuiScreen(this.mainMenu); + return; + case 20: + try + { + IModGuiFactory guiFactory = FMLClientHandler.instance().getGuiFactoryFor(selectedMod); + GuiScreen newScreen = guiFactory.mainConfigGuiClass().getConstructor(GuiScreen.class).newInstance(this); + this.mc.displayGuiScreen(newScreen); + } + catch (Exception e) + { + FMLLog.log(Level.ERROR, e, "There was a critical issue trying to build the config GUI for %s", selectedMod.getModId()); + } + return; + } + } + super.actionPerformed(button); + } + + public int drawLine(String line, int offset, int shifty) + { + this.fontRendererObj.drawString(line, offset, shifty, 0xd7edea); + return shifty + 10; + } + + @Override + public void drawScreen(int p_571_1_, int p_571_2_, float p_571_3_) + { + this.modList.drawScreen(p_571_1_, p_571_2_, p_571_3_); + this.drawCenteredString(this.fontRendererObj, "Mod List", this.width / 2, 16, 0xFFFFFF); + int offset = this.listWidth + 20; + if (selectedMod != null) { + GL11.glEnable(GL11.GL_BLEND); + if (!selectedMod.getMetadata().autogenerated) { + configModButton.visible = true; + disableModButton.visible = true; + disableModButton.packedFGColour = 0xFF3377; + configModButton.enabled = false; + int shifty = 35; + String logoFile = selectedMod.getMetadata().logoFile; + if (!logoFile.isEmpty()) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + TextureManager tm = mc.getTextureManager(); + IResourcePack pack = FMLClientHandler.instance().getResourcePackFor(selectedMod.getModId()); + try + { + if (cachedLogo == null) + { + BufferedImage logo = null; + if (pack!=null) + { + logo = pack.getPackImage(); + } + else + { + InputStream logoResource = getClass().getResourceAsStream(logoFile); + if (logoResource != null) + { + logo = ImageIO.read(logoResource); + } + } + if (logo != null) + { + cachedLogo = tm.getDynamicTextureLocation("modlogo", new DynamicTexture(logo)); + cachedLogoDimensions = new Dimension(logo.getWidth(), logo.getHeight()); + } + } + if (cachedLogo != null) + { + this.mc.renderEngine.bindTexture(cachedLogo); + double scaleX = cachedLogoDimensions.width / 200.0; + double scaleY = cachedLogoDimensions.height / 65.0; + double scale = 1.0; + if (scaleX > 1 || scaleY > 1) + { + scale = 1.0 / Math.max(scaleX, scaleY); + } + cachedLogoDimensions.width *= scale; + cachedLogoDimensions.height *= scale; + int top = 32; + Tessellator tess = Tessellator.instance; + tess.startDrawingQuads(); + tess.addVertexWithUV(offset, top + cachedLogoDimensions.height, zLevel, 0, 1); + tess.addVertexWithUV(offset + cachedLogoDimensions.width, top + cachedLogoDimensions.height, zLevel, 1, 1); + tess.addVertexWithUV(offset + cachedLogoDimensions.width, top, zLevel, 1, 0); + tess.addVertexWithUV(offset, top, zLevel, 0, 0); + tess.draw(); + + shifty += 65; + } + } + catch (IOException e) + { + ; + } + } + this.fontRendererObj.drawStringWithShadow(selectedMod.getMetadata().name, offset, shifty, 0xFFFFFF); + shifty += 12; + + shifty = drawLine(String.format("Version: %s (%s)", selectedMod.getDisplayVersion(), selectedMod.getVersion()), offset, shifty); + shifty = drawLine(String.format("Mod ID: '%s' Mod State: %s", selectedMod.getModId(), Loader.instance().getModState(selectedMod)), offset, shifty); + if (!selectedMod.getMetadata().credits.isEmpty()) { + shifty = drawLine(String.format("Credits: %s", selectedMod.getMetadata().credits), offset, shifty); + } + shifty = drawLine(String.format("Authors: %s", selectedMod.getMetadata().getAuthorList()), offset, shifty); + shifty = drawLine(String.format("URL: %s", selectedMod.getMetadata().url), offset, shifty); + shifty = drawLine(selectedMod.getMetadata().childMods.isEmpty() ? "No child mods for this mod" : String.format("Child mods: %s", selectedMod.getMetadata().getChildModList()), offset, shifty); + int rightSide = this.width - offset - 20; + if (rightSide > 20) + { + this.getFontRenderer().drawSplitString(selectedMod.getMetadata().description, offset, shifty + 10, rightSide, 0xDDDDDD); + } + Disableable disableable = selectedMod.canBeDisabled(); + if (disableable == Disableable.RESTART) + { + disableModButton.enabled = true; + disableModButton.visible = true; + disableModButton.packedFGColour = 0xFF3377; + } + else if (disableable == Disableable.YES) + { + disableModButton.enabled = true; + disableModButton.visible = true; + disableModButton.packedFGColour = 0; + } + else + { + disableModButton.packedFGColour = 0; + disableModButton.visible = true; + disableModButton.enabled = false; + } + IModGuiFactory guiFactory = FMLClientHandler.instance().getGuiFactoryFor(selectedMod); + if (guiFactory == null || guiFactory.mainConfigGuiClass() == null) + { + configModButton.visible = true; + configModButton.enabled = false; + } + else + { + configModButton.visible = true; + configModButton.enabled = true; + } + } else { + offset = ( this.listWidth + this.width ) / 2; + this.drawCenteredString(this.fontRendererObj, selectedMod.getName(), offset, 35, 0xFFFFFF); + this.drawCenteredString(this.fontRendererObj, String.format("Version: %s",selectedMod.getVersion()), offset, 45, 0xFFFFFF); + this.drawCenteredString(this.fontRendererObj, String.format("Mod State: %s",Loader.instance().getModState(selectedMod)), offset, 55, 0xFFFFFF); + this.drawCenteredString(this.fontRendererObj, "No mod information found", offset, 65, 0xDDDDDD); + this.drawCenteredString(this.fontRendererObj, "Ask your mod author to provide a mod mcmod.info file", offset, 75, 0xDDDDDD); + configModButton.visible = false; + disableModButton.visible = false; + } + GL11.glDisable(GL11.GL_BLEND); + } + else + { + configModButton.visible = false; + disableModButton.visible = false; + } + super.drawScreen(p_571_1_, p_571_2_, p_571_3_); + } + + Minecraft getMinecraftInstance() { + return mc; + } + + FontRenderer getFontRenderer() { + return fontRendererObj; + } + + /** + * @param var1 + */ + public void selectModIndex(int var1) + { + this.selected=var1; + if (var1>=0 && var1<=mods.size()) { + this.selectedMod=mods.get(selected); + } else { + this.selectedMod=null; + } + cachedLogo = null; + } + + public boolean modIndexSelected(int var1) + { + return var1==selected; + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/client/GuiModOptionList.java b/src/main/java/cpw/mods/fml/client/GuiModOptionList.java new file mode 100644 index 0000000..839e0cb --- /dev/null +++ b/src/main/java/cpw/mods/fml/client/GuiModOptionList.java @@ -0,0 +1,47 @@ +package cpw.mods.fml.client; + +import net.minecraft.client.renderer.Tessellator; + +public class GuiModOptionList extends GuiScrollingList { + + private GuiIngameModOptions parent; + + public GuiModOptionList(GuiIngameModOptions parent) + { + super(parent.mc, 150, parent.height, 32, parent.height - 65 + 4, 10, 35); + this.parent = parent; + } + + @Override + protected int getSize() + { + return 1; + } + + @Override + protected void elementClicked(int index, boolean doubleClick) + { + // TODO Auto-generated method stub + + } + + @Override + protected boolean isSelected(int index) + { + return false; + } + + @Override + protected void drawBackground() + { + } + + @Override + protected void drawSlot(int var1, int var2, int var3, int var4, Tessellator var5) + { + this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth("Test 1", listWidth - 10), this.left + 3 , var3 + 2, 0xFF2222); + this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth("TEST 2", listWidth - 10), this.left + 3 , var3 + 12, 0xFF2222); + this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth("DISABLED", listWidth - 10), this.left + 3 , var3 + 22, 0xFF2222); + } + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/client/GuiModsMissing.java b/src/main/java/cpw/mods/fml/client/GuiModsMissing.java new file mode 100644 index 0000000..50567b0 --- /dev/null +++ b/src/main/java/cpw/mods/fml/client/GuiModsMissing.java @@ -0,0 +1,62 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.client; + +import net.minecraft.client.gui.GuiErrorScreen; +import cpw.mods.fml.common.MissingModsException; +import cpw.mods.fml.common.versioning.ArtifactVersion; +import cpw.mods.fml.common.versioning.DefaultArtifactVersion; + +public class GuiModsMissing extends GuiErrorScreen +{ + + private MissingModsException modsMissing; + + public GuiModsMissing(MissingModsException modsMissing) + { + super(null,null); + this.modsMissing = modsMissing; + } + + @Override + public void initGui() + { + super.initGui(); + } + @Override + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + int offset = Math.max(85 - modsMissing.missingMods.size() * 10, 10); + this.drawCenteredString(this.fontRendererObj, "Forge Mod Loader has found a problem with your minecraft installation", this.width / 2, offset, 0xFFFFFF); + offset+=10; + this.drawCenteredString(this.fontRendererObj, "The mods and versions listed below could not be found", this.width / 2, offset, 0xFFFFFF); + offset+=5; + for (ArtifactVersion v : modsMissing.missingMods) + { + offset+=10; + if (v instanceof DefaultArtifactVersion) + { + DefaultArtifactVersion dav = (DefaultArtifactVersion)v; + if (dav.getRange() != null && dav.getRange().isUnboundedAbove()) + { + this.drawCenteredString(this.fontRendererObj, String.format("%s : minimum version required is %s", v.getLabel(), dav.getRange().getLowerBoundString()), this.width / 2, offset, 0xEEEEEE); + continue; + } + } + this.drawCenteredString(this.fontRendererObj, String.format("%s : %s", v.getLabel(), v.getRangeString()), this.width / 2, offset, 0xEEEEEE); + } + offset+=20; + this.drawCenteredString(this.fontRendererObj, "The file 'ForgeModLoader-client-0.log' contains more information", this.width / 2, offset, 0xFFFFFF); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/client/GuiModsMissingForServer.java b/src/main/java/cpw/mods/fml/client/GuiModsMissingForServer.java new file mode 100644 index 0000000..bf34378 --- /dev/null +++ b/src/main/java/cpw/mods/fml/client/GuiModsMissingForServer.java @@ -0,0 +1,63 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.client; + +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.resources.I18n; +import cpw.mods.fml.common.MissingModsException; +import cpw.mods.fml.common.versioning.ArtifactVersion; + +public class GuiModsMissingForServer extends GuiScreen +{ + private MissingModsException modsMissing; + + public GuiModsMissingForServer(MissingModsException modsMissing) + { + this.modsMissing = modsMissing; + } + + @SuppressWarnings("unchecked") + @Override + public void initGui() + { + this.buttonList.add(new GuiButton(1, this.width / 2 - 75, this.height - 38, I18n.format("gui.done"))); + } + + @Override + protected void actionPerformed(GuiButton par1GuiButton) + { + if (par1GuiButton.enabled && par1GuiButton.id == 1) + { + FMLClientHandler.instance().showGuiScreen(null); + } + } + @Override + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + int offset = Math.max(85 - modsMissing.missingMods.size() * 10, 10); + this.drawCenteredString(this.fontRendererObj, "Forge Mod Loader could not connect to this server", this.width / 2, offset, 0xFFFFFF); + offset += 10; + this.drawCenteredString(this.fontRendererObj, "The mods and versions listed below could not be found", this.width / 2, offset, 0xFFFFFF); + offset += 10; + this.drawCenteredString(this.fontRendererObj, "They are required to play on this server", this.width / 2, offset, 0xFFFFFF); + offset += 5; + for (ArtifactVersion v : modsMissing.missingMods) + { + offset += 10; + this.drawCenteredString(this.fontRendererObj, String.format("%s : %s", v.getLabel(), v.getRangeString()), this.width / 2, offset, 0xEEEEEE); + } + super.drawScreen(par1, par2, par3); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/client/GuiNotification.java b/src/main/java/cpw/mods/fml/client/GuiNotification.java new file mode 100644 index 0000000..cdaefd1 --- /dev/null +++ b/src/main/java/cpw/mods/fml/client/GuiNotification.java @@ -0,0 +1,62 @@ +package cpw.mods.fml.client; + +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.resources.I18n; +import cpw.mods.fml.common.StartupQuery; + +public class GuiNotification extends GuiScreen +{ + public GuiNotification(StartupQuery query) + { + this.query = query; + } + + @SuppressWarnings("unchecked") + @Override + public void initGui() + { + this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height - 38, I18n.format("gui.done"))); + } + + @Override + protected void actionPerformed(GuiButton button) + { + if (button.enabled && button.id == 0) + { + FMLClientHandler.instance().showGuiScreen(null); + query.finish(); + } + } + + @Override + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + + String[] lines = query.getText().split("\n"); + + int spaceAvailable = this.height - 38 - 20; + int spaceRequired = Math.min(spaceAvailable, 10 + 10 * lines.length); + + int offset = 10 + (spaceAvailable - spaceRequired) / 2; // vertically centered + + for (String line : lines) + { + if (offset >= spaceAvailable) + { + this.drawCenteredString(this.fontRendererObj, "...", this.width / 2, offset, 0xFFFFFF); + break; + } + else + { + if (!line.isEmpty()) this.drawCenteredString(this.fontRendererObj, line, this.width / 2, offset, 0xFFFFFF); + offset += 10; + } + } + + super.drawScreen(par1, par2, par3); + } + + protected final StartupQuery query; +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/client/GuiOldSaveLoadConfirm.java b/src/main/java/cpw/mods/fml/client/GuiOldSaveLoadConfirm.java new file mode 100644 index 0000000..b99f81a --- /dev/null +++ b/src/main/java/cpw/mods/fml/client/GuiOldSaveLoadConfirm.java @@ -0,0 +1,84 @@ +package cpw.mods.fml.client; + +import java.io.File; +import java.io.IOException; + +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiLabel; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.GuiSelectWorld; +import net.minecraft.client.gui.GuiYesNo; +import net.minecraft.world.WorldSettings; + +import org.apache.logging.log4j.Level; + +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.ObfuscationReflectionHelper; +import cpw.mods.fml.common.StartupQuery; +import cpw.mods.fml.common.ZipperUtil; + +public class GuiOldSaveLoadConfirm extends GuiYesNo { + + private String dirName; + private String saveName; + private File zip; + public GuiOldSaveLoadConfirm(String dirName, String saveName, GuiScreen parent) + { + super(parent, "", "", 0); + this.dirName = dirName; + this.saveName = saveName; + this.zip = new File(FMLClientHandler.instance().getClient().mcDataDir,String.format("%s-%2$td%2$tm%2$ty%2$tH%2$tM%2$tS.zip", saveName, System.currentTimeMillis())); + } + @Override + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + this.drawCenteredString(this.fontRendererObj, String.format("The world %s contains pre-update modding data", saveName), this.width / 2, 50, 16777215); + this.drawCenteredString(this.fontRendererObj, String.format("There may be problems updating it to this version"), this.width / 2, 70, 16777215); + this.drawCenteredString(this.fontRendererObj, String.format("FML will save a zip to %s", zip.getName()), this.width / 2, 90, 16777215); + this.drawCenteredString(this.fontRendererObj, String.format("Do you wish to continue loading?"), this.width / 2, 110, 16777215); + int k; + + for (k = 0; k < this.buttonList.size(); ++k) + { + ((GuiButton)this.buttonList.get(k)).drawButton(this.mc, par1, par2); + } + + for (k = 0; k < this.labelList.size(); ++k) + { + ((GuiLabel)this.labelList.get(k)).func_146159_a(this.mc, par1, par2); + } + } + @Override + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.id == 1) + { + ObfuscationReflectionHelper.setPrivateValue(GuiSelectWorld.class, (GuiSelectWorld)parentScreen, false, "field_"+"146634_i"); + FMLClientHandler.instance().showGuiScreen(parentScreen); + } + else + { + FMLLog.info("Capturing current state of world %s into file %s", saveName, zip.getAbsolutePath()); + try + { + ZipperUtil.zip(new File(FMLClientHandler.instance().getSavesDir(), dirName), zip); + } catch (IOException e) + { + FMLLog.log(Level.WARN, e, "There was a problem saving the backup %s. Please fix and try again", zip.getName()); + FMLClientHandler.instance().showGuiScreen(new GuiBackupFailed(parentScreen, zip)); + return; + } + FMLClientHandler.instance().showGuiScreen(null); + + try + { + mc.launchIntegratedServer(dirName, saveName, (WorldSettings)null); + } + catch (StartupQuery.AbortedException e) + { + // ignore + } + } + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/client/GuiScrollingList.java b/src/main/java/cpw/mods/fml/client/GuiScrollingList.java new file mode 100644 index 0000000..a31da14 --- /dev/null +++ b/src/main/java/cpw/mods/fml/client/GuiScrollingList.java @@ -0,0 +1,454 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.client; + +import java.util.List; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.Tessellator; + +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.GL11; + +public abstract class GuiScrollingList +{ + private final Minecraft client; + protected final int listWidth; + protected final int listHeight; + protected final int top; + protected final int bottom; + private final int right; + protected final int left; + protected final int slotHeight; + private int scrollUpActionId; + private int scrollDownActionId; + protected int mouseX; + protected int mouseY; + private float initialMouseClickY = -2.0F; + private float scrollFactor; + private float scrollDistance; + private int selectedIndex = -1; + private long lastClickTime = 0L; + private boolean field_25123_p = true; + private boolean field_27262_q; + private int field_27261_r; + + public GuiScrollingList(Minecraft client, int width, int height, int top, int bottom, int left, int entryHeight) + { + this.client = client; + this.listWidth = width; + this.listHeight = height; + this.top = top; + this.bottom = bottom; + this.slotHeight = entryHeight; + this.left = left; + this.right = width + this.left; + } + + public void func_27258_a(boolean p_27258_1_) + { + this.field_25123_p = p_27258_1_; + } + + protected void func_27259_a(boolean p_27259_1_, int p_27259_2_) + { + this.field_27262_q = p_27259_1_; + this.field_27261_r = p_27259_2_; + + if (!p_27259_1_) + { + this.field_27261_r = 0; + } + } + + protected abstract int getSize(); + + protected abstract void elementClicked(int index, boolean doubleClick); + + protected abstract boolean isSelected(int index); + + protected int getContentHeight() + { + return this.getSize() * this.slotHeight + this.field_27261_r; + } + + protected abstract void drawBackground(); + + protected abstract void drawSlot(int var1, int var2, int var3, int var4, Tessellator var5); + + protected void func_27260_a(int p_27260_1_, int p_27260_2_, Tessellator p_27260_3_) {} + + protected void func_27255_a(int p_27255_1_, int p_27255_2_) {} + + protected void func_27257_b(int p_27257_1_, int p_27257_2_) {} + + public int func_27256_c(int p_27256_1_, int p_27256_2_) + + { + int var3 = this.left + 1; + int var4 = this.left + this.listWidth - 7; + int var5 = p_27256_2_ - this.top - this.field_27261_r + (int)this.scrollDistance - 4; + int var6 = var5 / this.slotHeight; + return p_27256_1_ >= var3 && p_27256_1_ <= var4 && var6 >= 0 && var5 >= 0 && var6 < this.getSize() ? var6 : -1; + } + + public void registerScrollButtons(@SuppressWarnings("rawtypes") List p_22240_1_, int p_22240_2_, int p_22240_3_) + { + this.scrollUpActionId = p_22240_2_; + this.scrollDownActionId = p_22240_3_; + } + + private void applyScrollLimits() + { + int var1 = this.getContentHeight() - (this.bottom - this.top - 4); + + if (var1 < 0) + { + var1 /= 2; + } + + if (this.scrollDistance < 0.0F) + { + this.scrollDistance = 0.0F; + } + + if (this.scrollDistance > (float)var1) + { + this.scrollDistance = (float)var1; + } + } + + public void actionPerformed(GuiButton button) + { + if (button.enabled) + { + if (button.id == this.scrollUpActionId) + { + this.scrollDistance -= (float)(this.slotHeight * 2 / 3); + this.initialMouseClickY = -2.0F; + this.applyScrollLimits(); + } + else if (button.id == this.scrollDownActionId) + { + this.scrollDistance += (float)(this.slotHeight * 2 / 3); + this.initialMouseClickY = -2.0F; + this.applyScrollLimits(); + } + } + } + + public void drawScreen(int mouseX, int mouseY, float p_22243_3_) + { + this.mouseX = mouseX; + this.mouseY = mouseY; + this.drawBackground(); + int listLength = this.getSize(); + int scrollBarXStart = this.left + this.listWidth - 6; + int scrollBarXEnd = scrollBarXStart + 6; + int boxLeft = this.left; + int boxRight = scrollBarXStart-1; + int var10; + int var11; + int var13; + int var19; + + if (Mouse.isButtonDown(0)) + { + if (this.initialMouseClickY == -1.0F) + { + boolean var7 = true; + + if (mouseY >= this.top && mouseY <= this.bottom) + { + var10 = mouseY - this.top - this.field_27261_r + (int)this.scrollDistance - 4; + var11 = var10 / this.slotHeight; + + if (mouseX >= boxLeft && mouseX <= boxRight && var11 >= 0 && var10 >= 0 && var11 < listLength) + { + boolean var12 = var11 == this.selectedIndex && System.currentTimeMillis() - this.lastClickTime < 250L; + this.elementClicked(var11, var12); + this.selectedIndex = var11; + this.lastClickTime = System.currentTimeMillis(); + } + else if (mouseX >= boxLeft && mouseX <= boxRight && var10 < 0) + { + this.func_27255_a(mouseX - boxLeft, mouseY - this.top + (int)this.scrollDistance - 4); + var7 = false; + } + + if (mouseX >= scrollBarXStart && mouseX <= scrollBarXEnd) + { + this.scrollFactor = -1.0F; + var19 = this.getContentHeight() - (this.bottom - this.top - 4); + + if (var19 < 1) + { + var19 = 1; + } + + var13 = (int)((float)((this.bottom - this.top) * (this.bottom - this.top)) / (float)this.getContentHeight()); + + if (var13 < 32) + { + var13 = 32; + } + + if (var13 > this.bottom - this.top - 8) + { + var13 = this.bottom - this.top - 8; + } + + this.scrollFactor /= (float)(this.bottom - this.top - var13) / (float)var19; + } + else + { + this.scrollFactor = 1.0F; + } + + if (var7) + { + this.initialMouseClickY = (float)mouseY; + } + else + { + this.initialMouseClickY = -2.0F; + } + } + else + { + this.initialMouseClickY = -2.0F; + } + } + else if (this.initialMouseClickY >= 0.0F) + { + this.scrollDistance -= ((float)mouseY - this.initialMouseClickY) * this.scrollFactor; + this.initialMouseClickY = (float)mouseY; + } + } + else + { + while (Mouse.next()) + { + int var16 = Mouse.getEventDWheel(); + + if (var16 != 0) + { + if (var16 > 0) + { + var16 = -1; + } + else if (var16 < 0) + { + var16 = 1; + } + + this.scrollDistance += (float)(var16 * this.slotHeight / 2); + } + } + + this.initialMouseClickY = -1.0F; + } + + this.applyScrollLimits(); + Tessellator var18 = Tessellator.instance; + if (this.client.theWorld != null) + { + this.drawGradientRect(this.left, this.top, this.right, this.bottom, -1072689136, -804253680); + } + else + { + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_FOG); + this.client.renderEngine.bindTexture(Gui.optionsBackground); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + float var17 = 32.0F; + var18.startDrawingQuads(); + var18.setColorOpaque_I(2105376); + var18.addVertexWithUV((double)this.left, (double)this.bottom, 0.0D, (double)((float)this.left / var17), (double)((float)(this.bottom + (int)this.scrollDistance) / var17)); + var18.addVertexWithUV((double)this.right, (double)this.bottom, 0.0D, (double)((float)this.right / var17), (double)((float)(this.bottom + (int)this.scrollDistance) / var17)); + var18.addVertexWithUV((double)this.right, (double)this.top, 0.0D, (double)((float)this.right / var17), (double)((float)(this.top + (int)this.scrollDistance) / var17)); + var18.addVertexWithUV((double)this.left, (double)this.top, 0.0D, (double)((float)this.left / var17), (double)((float)(this.top + (int)this.scrollDistance) / var17)); + var18.draw(); + } + // boxRight = this.listWidth / 2 - 92 - 16; + var10 = this.top + 4 - (int)this.scrollDistance; + + if (this.field_27262_q) + { + this.func_27260_a(boxRight, var10, var18); + } + + int var14; + + for (var11 = 0; var11 < listLength; ++var11) + { + var19 = var10 + var11 * this.slotHeight + this.field_27261_r; + var13 = this.slotHeight - 4; + + if (var19 <= this.bottom && var19 + var13 >= this.top) + { + if (this.field_25123_p && this.isSelected(var11)) + { + var14 = boxLeft; + int var15 = boxRight; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_TEXTURE_2D); + var18.startDrawingQuads(); + var18.setColorOpaque_I(8421504); + var18.addVertexWithUV((double)var14, (double)(var19 + var13 + 2), 0.0D, 0.0D, 1.0D); + var18.addVertexWithUV((double)var15, (double)(var19 + var13 + 2), 0.0D, 1.0D, 1.0D); + var18.addVertexWithUV((double)var15, (double)(var19 - 2), 0.0D, 1.0D, 0.0D); + var18.addVertexWithUV((double)var14, (double)(var19 - 2), 0.0D, 0.0D, 0.0D); + var18.setColorOpaque_I(0); + var18.addVertexWithUV((double)(var14 + 1), (double)(var19 + var13 + 1), 0.0D, 0.0D, 1.0D); + var18.addVertexWithUV((double)(var15 - 1), (double)(var19 + var13 + 1), 0.0D, 1.0D, 1.0D); + var18.addVertexWithUV((double)(var15 - 1), (double)(var19 - 1), 0.0D, 1.0D, 0.0D); + var18.addVertexWithUV((double)(var14 + 1), (double)(var19 - 1), 0.0D, 0.0D, 0.0D); + var18.draw(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + + this.drawSlot(var11, boxRight, var19, var13, var18); + } + } + + GL11.glDisable(GL11.GL_DEPTH_TEST); + byte var20 = 4; + if (this.client.theWorld == null) + { + this.overlayBackground(0, this.top, 255, 255); + this.overlayBackground(this.bottom, this.listHeight, 255, 255); + } + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glShadeModel(GL11.GL_SMOOTH); + GL11.glDisable(GL11.GL_TEXTURE_2D); + var18.startDrawingQuads(); + var18.setColorRGBA_I(0, 0); + var18.addVertexWithUV((double)this.left, (double)(this.top + var20), 0.0D, 0.0D, 1.0D); + var18.addVertexWithUV((double)this.right, (double)(this.top + var20), 0.0D, 1.0D, 1.0D); + var18.setColorRGBA_I(0, 255); + var18.addVertexWithUV((double)this.right, (double)this.top, 0.0D, 1.0D, 0.0D); + var18.addVertexWithUV((double)this.left, (double)this.top, 0.0D, 0.0D, 0.0D); + var18.draw(); + var18.startDrawingQuads(); + var18.setColorRGBA_I(0, 255); + var18.addVertexWithUV((double)this.left, (double)this.bottom, 0.0D, 0.0D, 1.0D); + var18.addVertexWithUV((double)this.right, (double)this.bottom, 0.0D, 1.0D, 1.0D); + var18.setColorRGBA_I(0, 0); + var18.addVertexWithUV((double)this.right, (double)(this.bottom - var20), 0.0D, 1.0D, 0.0D); + var18.addVertexWithUV((double)this.left, (double)(this.bottom - var20), 0.0D, 0.0D, 0.0D); + var18.draw(); + var19 = this.getContentHeight() - (this.bottom - this.top - 4); + + if (var19 > 0) + { + var13 = (this.bottom - this.top) * (this.bottom - this.top) / this.getContentHeight(); + + if (var13 < 32) + { + var13 = 32; + } + + if (var13 > this.bottom - this.top - 8) + { + var13 = this.bottom - this.top - 8; + } + + var14 = (int)this.scrollDistance * (this.bottom - this.top - var13) / var19 + this.top; + + if (var14 < this.top) + { + var14 = this.top; + } + + var18.startDrawingQuads(); + var18.setColorRGBA_I(0, 255); + var18.addVertexWithUV((double)scrollBarXStart, (double)this.bottom, 0.0D, 0.0D, 1.0D); + var18.addVertexWithUV((double)scrollBarXEnd, (double)this.bottom, 0.0D, 1.0D, 1.0D); + var18.addVertexWithUV((double)scrollBarXEnd, (double)this.top, 0.0D, 1.0D, 0.0D); + var18.addVertexWithUV((double)scrollBarXStart, (double)this.top, 0.0D, 0.0D, 0.0D); + var18.draw(); + var18.startDrawingQuads(); + var18.setColorRGBA_I(8421504, 255); + var18.addVertexWithUV((double)scrollBarXStart, (double)(var14 + var13), 0.0D, 0.0D, 1.0D); + var18.addVertexWithUV((double)scrollBarXEnd, (double)(var14 + var13), 0.0D, 1.0D, 1.0D); + var18.addVertexWithUV((double)scrollBarXEnd, (double)var14, 0.0D, 1.0D, 0.0D); + var18.addVertexWithUV((double)scrollBarXStart, (double)var14, 0.0D, 0.0D, 0.0D); + var18.draw(); + var18.startDrawingQuads(); + var18.setColorRGBA_I(12632256, 255); + var18.addVertexWithUV((double)scrollBarXStart, (double)(var14 + var13 - 1), 0.0D, 0.0D, 1.0D); + var18.addVertexWithUV((double)(scrollBarXEnd - 1), (double)(var14 + var13 - 1), 0.0D, 1.0D, 1.0D); + var18.addVertexWithUV((double)(scrollBarXEnd - 1), (double)var14, 0.0D, 1.0D, 0.0D); + var18.addVertexWithUV((double)scrollBarXStart, (double)var14, 0.0D, 0.0D, 0.0D); + var18.draw(); + } + + this.func_27257_b(mouseX, mouseY); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glShadeModel(GL11.GL_FLAT); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glDisable(GL11.GL_BLEND); + } + + private void overlayBackground(int p_22239_1_, int p_22239_2_, int p_22239_3_, int p_22239_4_) + { + Tessellator var5 = Tessellator.instance; + this.client.renderEngine.bindTexture(Gui.optionsBackground); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + float var6 = 32.0F; + var5.startDrawingQuads(); + var5.setColorRGBA_I(4210752, p_22239_4_); + var5.addVertexWithUV(0.0D, (double)p_22239_2_, 0.0D, 0.0D, (double)((float)p_22239_2_ / var6)); + var5.addVertexWithUV((double)this.listWidth + 30, (double)p_22239_2_, 0.0D, (double)((float)(this.listWidth + 30) / var6), (double)((float)p_22239_2_ / var6)); + var5.setColorRGBA_I(4210752, p_22239_3_); + var5.addVertexWithUV((double)this.listWidth + 30, (double)p_22239_1_, 0.0D, (double)((float)(this.listWidth + 30) / var6), (double)((float)p_22239_1_ / var6)); + var5.addVertexWithUV(0.0D, (double)p_22239_1_, 0.0D, 0.0D, (double)((float)p_22239_1_ / var6)); + var5.draw(); + } + + protected void drawGradientRect(int par1, int par2, int par3, int par4, int par5, int par6) + { + float f = (float)(par5 >> 24 & 255) / 255.0F; + float f1 = (float)(par5 >> 16 & 255) / 255.0F; + float f2 = (float)(par5 >> 8 & 255) / 255.0F; + float f3 = (float)(par5 & 255) / 255.0F; + float f4 = (float)(par6 >> 24 & 255) / 255.0F; + float f5 = (float)(par6 >> 16 & 255) / 255.0F; + float f6 = (float)(par6 >> 8 & 255) / 255.0F; + float f7 = (float)(par6 & 255) / 255.0F; + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_ALPHA_TEST); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glShadeModel(GL11.GL_SMOOTH); + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_F(f1, f2, f3, f); + tessellator.addVertex((double)par3, (double)par2, 0.0D); + tessellator.addVertex((double)par1, (double)par2, 0.0D); + tessellator.setColorRGBA_F(f5, f6, f7, f4); + tessellator.addVertex((double)par1, (double)par4, 0.0D); + tessellator.addVertex((double)par3, (double)par4, 0.0D); + tessellator.draw(); + GL11.glShadeModel(GL11.GL_FLAT); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/client/GuiSlotModList.java b/src/main/java/cpw/mods/fml/client/GuiSlotModList.java new file mode 100644 index 0000000..cc5f543 --- /dev/null +++ b/src/main/java/cpw/mods/fml/client/GuiSlotModList.java @@ -0,0 +1,87 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.client; + +import java.util.ArrayList; + +import net.minecraft.client.renderer.Tessellator; + +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.LoaderState.ModState; +import cpw.mods.fml.common.ModContainer; + +/** + * @author cpw + * + */ +public class GuiSlotModList extends GuiScrollingList +{ + private GuiModList parent; + private ArrayList mods; + + public GuiSlotModList(GuiModList parent, ArrayList mods, int listWidth) + { + super(parent.getMinecraftInstance(), listWidth, parent.height, 32, parent.height - 66 + 4, 10, 35); + this.parent=parent; + this.mods=mods; + } + + @Override + protected int getSize() + { + return mods.size(); + } + + @Override + protected void elementClicked(int var1, boolean var2) + { + this.parent.selectModIndex(var1); + } + + @Override + protected boolean isSelected(int var1) + { + return this.parent.modIndexSelected(var1); + } + + @Override + protected void drawBackground() + { + this.parent.drawDefaultBackground(); + } + + @Override + protected int getContentHeight() + { + return (this.getSize()) * 35 + 1; + } + + @Override + protected void drawSlot(int listIndex, int var2, int var3, int var4, Tessellator var5) + { + ModContainer mc=mods.get(listIndex); + if (Loader.instance().getModState(mc)==ModState.DISABLED) + { + this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth(mc.getName(), listWidth - 10), this.left + 3 , var3 + 2, 0xFF2222); + this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth(mc.getDisplayVersion(), listWidth - 10), this.left + 3 , var3 + 12, 0xFF2222); + this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth("DISABLED", listWidth - 10), this.left + 3 , var3 + 22, 0xFF2222); + } + else + { + this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth(mc.getName(), listWidth - 10), this.left + 3 , var3 + 2, 0xFFFFFF); + this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth(mc.getDisplayVersion(), listWidth - 10), this.left + 3 , var3 + 12, 0xCCCCCC); + this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth(mc.getMetadata() !=null ? mc.getMetadata().getChildModCountString() : "Metadata not found", listWidth - 10), this.left + 3 , var3 + 22, 0xCCCCCC); + } + } + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/client/GuiSortingProblem.java b/src/main/java/cpw/mods/fml/client/GuiSortingProblem.java new file mode 100644 index 0000000..40d48b9 --- /dev/null +++ b/src/main/java/cpw/mods/fml/client/GuiSortingProblem.java @@ -0,0 +1,44 @@ +package cpw.mods.fml.client; + +import net.minecraft.client.gui.GuiScreen; +import cpw.mods.fml.common.ModContainer; +import cpw.mods.fml.common.toposort.ModSortingException; +import cpw.mods.fml.common.toposort.ModSortingException.SortingExceptionData; + +public class GuiSortingProblem extends GuiScreen { + private SortingExceptionData failedList; + + public GuiSortingProblem(ModSortingException modSorting) + { + this.failedList = modSorting.getExceptionData(); + } + + @Override + public void initGui() + { + super.initGui(); + } + + @Override + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + int offset = Math.max(85 - (failedList.getVisitedNodes().size() + 3) * 10, 10); + this.drawCenteredString(this.fontRendererObj, "Forge Mod Loader has found a problem with your minecraft installation", this.width / 2, offset, 0xFFFFFF); + offset+=10; + this.drawCenteredString(this.fontRendererObj, "A mod sorting cycle was detected and loading cannot continue", this.width / 2, offset, 0xFFFFFF); + offset+=10; + this.drawCenteredString(this.fontRendererObj, String.format("The first mod in the cycle is %s", failedList.getFirstBadNode()), this.width / 2, offset, 0xFFFFFF); + offset+=10; + this.drawCenteredString(this.fontRendererObj, "The remainder of the cycle involves these mods", this.width / 2, offset, 0xFFFFFF); + offset+=5; + for (ModContainer mc : failedList.getVisitedNodes()) + { + offset+=10; + this.drawCenteredString(this.fontRendererObj, String.format("%s : before: %s, after: %s", mc.toString(), mc.getDependants(), mc.getDependencies()), this.width / 2, offset, 0xEEEEEE); + } + offset+=20; + this.drawCenteredString(this.fontRendererObj, "The file 'ForgeModLoader-client-0.log' contains more information", this.width / 2, offset, 0xFFFFFF); + } + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/client/GuiWrongMinecraft.java b/src/main/java/cpw/mods/fml/client/GuiWrongMinecraft.java new file mode 100644 index 0000000..6746f20 --- /dev/null +++ b/src/main/java/cpw/mods/fml/client/GuiWrongMinecraft.java @@ -0,0 +1,46 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.client; + +import net.minecraft.client.gui.GuiErrorScreen; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.WrongMinecraftVersionException; + +public class GuiWrongMinecraft extends GuiErrorScreen +{ + private WrongMinecraftVersionException wrongMC; + public GuiWrongMinecraft(WrongMinecraftVersionException wrongMC) + { + super(null,null); + this.wrongMC = wrongMC; + } + @Override + public void initGui() + { + super.initGui(); + } + @Override + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + int offset = 75; + this.drawCenteredString(this.fontRendererObj, "Forge Mod Loader has found a problem with your minecraft installation", this.width / 2, offset, 0xFFFFFF); + offset+=10; + this.drawCenteredString(this.fontRendererObj, String.format("The mod listed below does not want to run in Minecraft version %s", Loader.instance().getMinecraftModContainer().getVersion()), this.width / 2, offset, 0xFFFFFF); + offset+=5; + offset+=10; + this.drawCenteredString(this.fontRendererObj, String.format("%s (%s) wants Minecraft %s", wrongMC.mod.getName(), wrongMC.mod.getModId(), wrongMC.mod.acceptableMinecraftVersionRange()), this.width / 2, offset, 0xEEEEEE); + offset+=20; + this.drawCenteredString(this.fontRendererObj, "The file 'ForgeModLoader-client-0.log' contains more information", this.width / 2, offset, 0xFFFFFF); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/client/IModGuiFactory.java b/src/main/java/cpw/mods/fml/client/IModGuiFactory.java new file mode 100644 index 0000000..5be73c5 --- /dev/null +++ b/src/main/java/cpw/mods/fml/client/IModGuiFactory.java @@ -0,0 +1,129 @@ +package cpw.mods.fml.client; + +import java.util.List; +import java.util.Set; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.GuiScreen; + +public interface IModGuiFactory { + /** + * Called when instantiated to initialize with the active minecraft instance. + * + * @param minecraftInstance the instance + */ + public void initialize(Minecraft minecraftInstance); + /** + * Return the name of a class extending {@link GuiScreen}. This class will + * be instantiated when the "config" button is pressed in the mod list. It will + * have a single argument constructor - the "parent" screen, the same as all + * Minecraft GUIs. The expected behaviour is that this screen will replace the + * "mod list" screen completely, and will return to the mod list screen through + * the parent link, once the appropriate action is taken from the config screen. + * + * A null from this method indicates that the mod does not provide a "config" + * button GUI screen, and the config button will be hidden/disabled. + * + * This config GUI is anticipated to provide configuration to the mod in a friendly + * visual way. It should not be abused to set internals such as IDs (they're gonna + * keep disappearing anyway), but rather, interesting behaviours. This config GUI + * is never run when a server game is running, and should be used to configure + * desired behaviours that affect server state. Costs, mod game modes, stuff like that + * can be changed here. + * + * @return A class that will be instantiated on clicks on the config button + * or null if no GUI is desired. + */ + public Class mainConfigGuiClass(); + + + /** + * Return a list of the "runtime" categories this mod wishes to populate with + * GUI elements. + * + * Runtime categories are created on demand and organized in a 'lite' tree format. + * The parent represents the parent node in the tree. There is one special parent + * 'Help' that will always list first, and is generally meant to provide Help type + * content for mods. The remaining parents will sort alphabetically, though + * this may change if there is a lot of alphabetic abuse. "AAA" is probably never a valid + * category parent. + * + * Runtime configuration itself falls into two flavours: in-game help, which is + * generally non interactive except for the text it wishes to show, and client-only + * affecting behaviours. This would include things like toggling minimaps, or cheat modes + * or anything NOT affecting the behaviour of the server. Please don't abuse this to + * change the state of the server in any way, this is intended to behave identically + * when the server is local or remote. + * + * @return the set of options this mod wishes to have available, or empty if none + */ + public Set runtimeGuiCategories(); + + /** + * Return an instance of a {@link RuntimeOptionGuiHandler} that handles painting the + * right hand side option screen for the specified {@link RuntimeOptionCategoryElement}. + * + * @param element The element we wish to paint for + * @return The Handler for painting it + */ + public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element); + + /** + * Represents an option category and entry in the runtime gui options list. + * + * @author cpw + * + */ + public static class RuntimeOptionCategoryElement { + public final String parent; + public final String child; + + public RuntimeOptionCategoryElement(String parent, String child) + { + this.parent = parent; + this.child = child; + } + } + + /** + * Responsible for painting the mod specific section of runtime options GUI for a particular category + * + * @author cpw + * + */ + public interface RuntimeOptionGuiHandler { + /** + * Called to add widgets to the screen, such as buttons. + * GUI identifier numbers should start at 100 and increase. + * The callback will be through {@link #actionCallback(int)} + * + * @param x X + * @param y Y + * @param w width + * @param h height + */ + public void addWidgets(List widgetList, int x, int y, int w, int h); + + /** + * Called to paint the rectangle specified. + * @param x X + * @param y Y + * @param w width + * @param h height + */ + public void paint(int x, int y, int w, int h); + + /** + * Called if a widget with id >= 100 is fired. + * + * @param actionId the actionId of the firing widget + */ + public void actionCallback(int actionId); + + /** + * Called when this handler is about to go away (probably replaced by another one, or closing the + * option screen) + */ + public void close(); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/client/registry/ClientRegistry.java b/src/main/java/cpw/mods/fml/client/registry/ClientRegistry.java new file mode 100644 index 0000000..2f20c31 --- /dev/null +++ b/src/main/java/cpw/mods/fml/client/registry/ClientRegistry.java @@ -0,0 +1,51 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.client.registry; + +import org.apache.commons.lang3.ArrayUtils; + +import cpw.mods.fml.common.registry.GameRegistry; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.client.settings.KeyBinding; +import net.minecraft.tileentity.TileEntity; + +public class ClientRegistry +{ + /** + * + * Utility method for registering a tile entity and it's renderer at once - generally you should register them separately + * + * @param tileEntityClass + * @param id + * @param specialRenderer + */ + public static void registerTileEntity(Class tileEntityClass, String id, TileEntitySpecialRenderer specialRenderer) + { + GameRegistry.registerTileEntity(tileEntityClass, id); + bindTileEntitySpecialRenderer(tileEntityClass, specialRenderer); + } + + @SuppressWarnings("unchecked") + public static void bindTileEntitySpecialRenderer(Class tileEntityClass, TileEntitySpecialRenderer specialRenderer) + { + TileEntityRendererDispatcher.instance.mapSpecialRenderers.put(tileEntityClass, specialRenderer); + specialRenderer.func_147497_a(TileEntityRendererDispatcher.instance); + } + + public static void registerKeyBinding(KeyBinding key) + { + Minecraft.getMinecraft().gameSettings.keyBindings = ArrayUtils.add(Minecraft.getMinecraft().gameSettings.keyBindings, key); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/client/registry/ISimpleBlockRenderingHandler.java b/src/main/java/cpw/mods/fml/client/registry/ISimpleBlockRenderingHandler.java new file mode 100644 index 0000000..c6a4a87 --- /dev/null +++ b/src/main/java/cpw/mods/fml/client/registry/ISimpleBlockRenderingHandler.java @@ -0,0 +1,28 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.client.registry; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.world.IBlockAccess; + +public interface ISimpleBlockRenderingHandler +{ + public abstract void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer); + + public abstract boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer); + + public abstract boolean shouldRender3DInInventory(int modelId); + + public abstract int getRenderId(); +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/client/registry/RenderingRegistry.java b/src/main/java/cpw/mods/fml/client/registry/RenderingRegistry.java new file mode 100644 index 0000000..ca25363 --- /dev/null +++ b/src/main/java/cpw/mods/fml/client/registry/RenderingRegistry.java @@ -0,0 +1,142 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.client.registry; + +import java.util.List; +import java.util.Map; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.client.renderer.entity.RenderBiped; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.entity.Entity; +import net.minecraft.world.IBlockAccess; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.ObjectArrays; + +/** + * @author cpw + * + */ +public class RenderingRegistry +{ + private static final RenderingRegistry INSTANCE = new RenderingRegistry(); + + private int nextRenderId = 42; + + private Map blockRenderers = Maps.newHashMap(); + + private List entityRenderers = Lists.newArrayList(); + + /** + * Add a new armour prefix to the RenderPlayer + * + * @param armor + */ + public static int addNewArmourRendererPrefix(String armor) + { + RenderBiped.bipedArmorFilenamePrefix = ObjectArrays.concat(RenderBiped.bipedArmorFilenamePrefix, armor); + return RenderBiped.bipedArmorFilenamePrefix.length - 1; + } + + /** + * Register an entity rendering handler. This will, after mod initialization, be inserted into the main + * render map for entities + * + * @param entityClass + * @param renderer + */ + public static void registerEntityRenderingHandler(Class entityClass, Render renderer) + { + instance().entityRenderers.add(new EntityRendererInfo(entityClass, renderer)); + } + + /** + * Register a simple block rendering handler + * + * @param handler + */ + public static void registerBlockHandler(ISimpleBlockRenderingHandler handler) + { + instance().blockRenderers.put(handler.getRenderId(), handler); + } + + /** + * Register the simple block rendering handler + * This version will not call getRenderId on the passed in handler, instead using the supplied ID, so you + * can easily re-use the same rendering handler for multiple IDs + * + * @param renderId + * @param handler + */ + public static void registerBlockHandler(int renderId, ISimpleBlockRenderingHandler handler) + { + instance().blockRenderers.put(renderId, handler); + } + /** + * Get the next available renderId from the block render ID list + */ + public static int getNextAvailableRenderId() + { + return instance().nextRenderId++; + } + + + @Deprecated public static RenderingRegistry instance() + { + return INSTANCE; + } + + private static class EntityRendererInfo + { + public EntityRendererInfo(Class target, Render renderer) + { + this.target = target; + this.renderer = renderer; + } + private Class target; + private Render renderer; + } + + public boolean renderWorldBlock(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, Block block, int modelId) + { + if (!blockRenderers.containsKey(modelId)) { return false; } + ISimpleBlockRenderingHandler bri = blockRenderers.get(modelId); + return bri.renderWorldBlock(world, x, y, z, block, modelId, renderer); + } + + public void renderInventoryBlock(RenderBlocks renderer, Block block, int metadata, int modelID) + { + if (!blockRenderers.containsKey(modelID)) { return; } + ISimpleBlockRenderingHandler bri = blockRenderers.get(modelID); + bri.renderInventoryBlock(block, metadata, modelID, renderer); + } + + public boolean renderItemAsFull3DBlock(int modelId) + { + ISimpleBlockRenderingHandler bri = blockRenderers.get(modelId); + return bri != null && bri.shouldRender3DInInventory(modelId); + } + + public void loadEntityRenderers(Map, Render> rendererMap) + { + for (EntityRendererInfo info : entityRenderers) + { + rendererMap.put(info.target, info.renderer); + info.renderer.setRenderManager(RenderManager.instance); + } + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/API.java b/src/main/java/cpw/mods/fml/common/API.java new file mode 100644 index 0000000..c50b923 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/API.java @@ -0,0 +1,14 @@ +package cpw.mods.fml.common; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.PACKAGE) +public @interface API { + String owner(); + String provides(); + String apiVersion(); +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/BukkitPluginRef.java b/src/main/java/cpw/mods/fml/common/BukkitPluginRef.java new file mode 100644 index 0000000..06c0bfd --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/BukkitPluginRef.java @@ -0,0 +1,41 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Declare a variable to be populated by a Bukkit Plugin proxy instance if the bukkit coremod + * is available. It can only be applied to field typed as {@link BukkitProxy} + * Generally it should be used in conjunction with {@link Mod#bukkitPlugin()} specifying the + * plugin to load. + * + * @author cpw + * + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.FIELD) +public @interface BukkitPluginRef +{ + /** + * A reference (possibly version specific) to a Bukkit Plugin by name, using the name@versionbound + * specification. If this is a bukkit enabled environment the field annotated by this + * will be populated with a {@link BukkitProxy} instance if possible. This proxy will be gotten by + * reflectively calling the "getModProxy" method on the bukkit plugin instance. + * @return The name of the plugin which we will inject into this field + */ + String value(); +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/BukkitProxy.java b/src/main/java/cpw/mods/fml/common/BukkitProxy.java new file mode 100644 index 0000000..4f1fb41 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/BukkitProxy.java @@ -0,0 +1,24 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common; + +/** + * A marker interface for retrieving a proxy to a bukkit plugin. + * Fields associated with {@link BukkitPluginRef} annotations should + * declare this type and cast down if the target is available (not null) + * @author cpw + * + */ +public interface BukkitProxy +{ +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/CertificateHelper.java b/src/main/java/cpw/mods/fml/common/CertificateHelper.java new file mode 100644 index 0000000..e65e488 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/CertificateHelper.java @@ -0,0 +1,68 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common; + +import java.nio.ByteBuffer; +import java.security.MessageDigest; +import java.security.cert.Certificate; + +public class CertificateHelper { + + private static final String HEXES = "0123456789abcdef"; + + public static String getFingerprint(Certificate certificate) + { + if (certificate == null) + { + return "NO VALID CERTIFICATE FOUND"; + } + try + { + MessageDigest md = MessageDigest.getInstance("SHA-1"); + byte[] der = certificate.getEncoded(); + md.update(der); + byte[] digest = md.digest(); + return hexify(digest); + } + catch (Exception e) + { + return null; + } + } + + public static String getFingerprint(ByteBuffer buffer) + { + try + { + MessageDigest digest = MessageDigest.getInstance("SHA-1"); + digest.update(buffer); + byte[] chksum = digest.digest(); + return hexify(chksum); + } + catch (Exception e) + { + return null; + } + } + + private static String hexify(byte[] chksum) + { + final StringBuilder hex = new StringBuilder( 2 * chksum.length ); + for ( final byte b : chksum ) { + hex.append(HEXES.charAt((b & 0xF0) >> 4)) + .append(HEXES.charAt((b & 0x0F))); + } + return hex.toString(); + } + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/DummyModContainer.java b/src/main/java/cpw/mods/fml/common/DummyModContainer.java new file mode 100644 index 0000000..5fa49e8 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/DummyModContainer.java @@ -0,0 +1,203 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common; + +import java.io.File; +import java.security.cert.Certificate; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.google.common.collect.ImmutableList; +import com.google.common.eventbus.EventBus; + +import cpw.mods.fml.common.versioning.ArtifactVersion; +import cpw.mods.fml.common.versioning.DefaultArtifactVersion; +import cpw.mods.fml.common.versioning.VersionRange; + +public class DummyModContainer implements ModContainer +{ + private ModMetadata md; + private ArtifactVersion processedVersion; + private String label; + + public DummyModContainer(ModMetadata md) + { + this.md = md; + } + + public DummyModContainer(String label) + { + this.label = label; + } + public DummyModContainer() + { + } + + @Override + public void bindMetadata(MetadataCollection mc) + { + } + + @Override + public List getDependants() + { + return Collections.emptyList(); + } + + @Override + public List getDependencies() + { + return Collections.emptyList(); + } + + @Override + public Set getRequirements() + { + return Collections.emptySet(); + } + + @Override + public ModMetadata getMetadata() + { + return md; + } + + @Override + public Object getMod() + { + return null; + } + + @Override + public String getModId() + { + return md.modId; + } + + @Override + public String getName() + { + return md.name; + } + + @Override + public String getSortingRules() + { + return ""; + } + + @Override + public File getSource() + { + return null; + } + + @Override + public String getVersion() + { + return md.version; + } + + @Override + public boolean matches(Object mod) + { + return false; + } + + @Override + public void setEnabledState(boolean enabled) + { + } + + @Override + public boolean registerBus(EventBus bus, LoadController controller) + { + return false; + } + + @Override + public ArtifactVersion getProcessedVersion() + { + if (processedVersion == null) + { + processedVersion = new DefaultArtifactVersion(getModId(), getVersion()); + } + return processedVersion; + } + + @Override + public boolean isImmutable() + { + return false; + } + + @Override + public String getDisplayVersion() + { + return md.version; + } + @Override + public VersionRange acceptableMinecraftVersionRange() + { + return Loader.instance().getMinecraftModContainer().getStaticVersionRange(); + } + + @Override + public Certificate getSigningCertificate() + { + return null; + } + + @Override + public String toString() + { + return md != null ? getModId() : "Dummy Container ("+label+") @" + System.identityHashCode(this); + } + + @Override + public Map getCustomModProperties() + { + return EMPTY_PROPERTIES; + } + @Override + public Class getCustomResourcePackClass() + { + return null; + } + + @Override + public Map getSharedModDescriptor() + { + return null; + } + + @Override + public Disableable canBeDisabled() + { + return Disableable.NEVER; + } + + @Override + public String getGuiClassName() + { + return null; + } + + @Override + public List getOwnedPackages() + { + return ImmutableList.of(); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/DuplicateModsFoundException.java b/src/main/java/cpw/mods/fml/common/DuplicateModsFoundException.java new file mode 100644 index 0000000..7971809 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/DuplicateModsFoundException.java @@ -0,0 +1,27 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common; + +import java.io.File; + +import com.google.common.collect.SetMultimap; + +public class DuplicateModsFoundException extends LoaderException { + private static final long serialVersionUID = 1L; + public SetMultimap dupes; + + public DuplicateModsFoundException(SetMultimap dupes) { + this.dupes = dupes; + } + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/FMLCommonHandler.java b/src/main/java/cpw/mods/fml/common/FMLCommonHandler.java new file mode 100644 index 0000000..4922e1e --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/FMLCommonHandler.java @@ -0,0 +1,545 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common; + +import java.io.File; +import java.lang.ref.WeakReference; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import net.minecraft.crash.CrashReport; +import net.minecraft.crash.CrashReportCategory; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.INetHandler; +import net.minecraft.network.NetworkManager; +import net.minecraft.server.MinecraftServer; +import net.minecraft.world.World; +import net.minecraft.world.storage.SaveHandler; +import net.minecraft.world.storage.WorldInfo; + +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.Logger; + +import com.google.common.base.Joiner; +import com.google.common.base.Strings; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableList.Builder; +import com.google.common.collect.Lists; +import com.google.common.collect.MapMaker; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; + +import cpw.mods.fml.common.eventhandler.EventBus; +import cpw.mods.fml.common.gameevent.InputEvent; +import cpw.mods.fml.common.gameevent.PlayerEvent; +import cpw.mods.fml.common.gameevent.TickEvent; +import cpw.mods.fml.common.gameevent.TickEvent.Phase; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.server.FMLServerHandler; + + +/** + * The main class for non-obfuscated hook handling code + * + * Anything that doesn't require obfuscated or client/server specific code should + * go in this handler + * + * It also contains a reference to the sided handler instance that is valid + * allowing for common code to access specific properties from the obfuscated world + * without a direct dependency + * + * @author cpw + * + */ +public class FMLCommonHandler +{ + /** + * The singleton + */ + private static final FMLCommonHandler INSTANCE = new FMLCommonHandler(); + /** + * The delegate for side specific data and functions + */ + private IFMLSidedHandler sidedDelegate; + + private Class forge; + private boolean noForge; + private List brandings; + private List brandingsNoMC; + private List crashCallables = Lists.newArrayList(Loader.instance().getCallableCrashInformation()); + private Set handlerSet = Sets.newSetFromMap(new MapMaker().weakKeys().makeMap()); + private WeakReference handlerToCheck; + private EventBus eventBus = new EventBus(); + /** + * The FML event bus. Subscribe here for FML related events + * + * @return the event bus + */ + public EventBus bus() + { + return eventBus; + } + + public void beginLoading(IFMLSidedHandler handler) + { + sidedDelegate = handler; + FMLLog.log("MinecraftForge", Level.INFO, "Attempting early MinecraftForge initialization"); + callForgeMethod("initialize"); + callForgeMethod("registerCrashCallable"); + FMLLog.log("MinecraftForge", Level.INFO, "Completed early MinecraftForge initialization"); + } + + /** + * @return the instance + */ + public static FMLCommonHandler instance() + { + return INSTANCE; + } + /** + * Find the container that associates with the supplied mod object + * @param mod + */ + public ModContainer findContainerFor(Object mod) + { + if (mod instanceof String) + { + return Loader.instance().getIndexedModList().get(mod); + } + else + { + return Loader.instance().getReversedModObjectList().get(mod); + } + } + /** + * Get the forge mod loader logging instance (goes to the forgemodloader log file) + * @return The log instance for the FML log file + */ + public Logger getFMLLogger() + { + return FMLLog.getLogger(); + } + + public Side getSide() + { + return sidedDelegate.getSide(); + } + + /** + * Return the effective side for the context in the game. This is dependent + * on thread analysis to try and determine whether the code is running in the + * server or not. Use at your own risk + */ + public Side getEffectiveSide() + { + Thread thr = Thread.currentThread(); + if ((thr.getName().equals("Server thread"))) + { + return Side.SERVER; + } + + return Side.CLIENT; + } + /** + * Raise an exception + */ + public void raiseException(Throwable exception, String message, boolean stopGame) + { + FMLLog.log(Level.ERROR, exception, "Something raised an exception. The message was '%s'. 'stopGame' is %b", message, stopGame); + if (stopGame) + { + getSidedDelegate().haltGame(message,exception); + } + } + + + private Class findMinecraftForge() + { + if (forge==null && !noForge) + { + try { + forge = Class.forName("net.minecraftforge.common.MinecraftForge"); + } catch (Exception ex) { + noForge = true; + } + } + return forge; + } + + private Object callForgeMethod(String method) + { + if (noForge) + return null; + try + { + return findMinecraftForge().getMethod(method).invoke(null); + } + catch (Exception e) + { + // No Forge installation + return null; + } + } + + public void computeBranding() + { + if (brandings == null) + { + Builder brd = ImmutableList.builder(); + brd.add(Loader.instance().getMCVersionString()); + brd.add(Loader.instance().getMCPVersionString()); + brd.add("FML v"+Loader.instance().getFMLVersionString()); + String forgeBranding = (String) callForgeMethod("getBrandingVersion"); + if (!Strings.isNullOrEmpty(forgeBranding)) + { + brd.add(forgeBranding); + } + if (sidedDelegate!=null) + { + brd.addAll(sidedDelegate.getAdditionalBrandingInformation()); + } + if (Loader.instance().getFMLBrandingProperties().containsKey("fmlbranding")) + { + brd.add(Loader.instance().getFMLBrandingProperties().get("fmlbranding")); + } + int tModCount = Loader.instance().getModList().size(); + int aModCount = Loader.instance().getActiveModList().size(); + brd.add(String.format("%d mod%s loaded, %d mod%s active", tModCount, tModCount!=1 ? "s" :"", aModCount, aModCount!=1 ? "s" :"" )); + brandings = brd.build(); + brandingsNoMC = brandings.subList(1, brandings.size()); + } + } + public List getBrandings(boolean includeMC) + { + if (brandings == null) + { + computeBranding(); + } + return includeMC ? ImmutableList.copyOf(brandings) : ImmutableList.copyOf(brandingsNoMC); + } + + public IFMLSidedHandler getSidedDelegate() + { + return sidedDelegate; + } + + public void onPostServerTick() + { + bus().post(new TickEvent.ServerTickEvent(Phase.END)); + } + + /** + * Every tick just after world and other ticks occur + */ + public void onPostWorldTick(World world) + { + bus().post(new TickEvent.WorldTickEvent(Side.SERVER, Phase.END, world)); + } + + public void onPreServerTick() + { + bus().post(new TickEvent.ServerTickEvent(Phase.START)); + } + + /** + * Every tick just before world and other ticks occur + */ + public void onPreWorldTick(World world) + { + bus().post(new TickEvent.WorldTickEvent(Side.SERVER, Phase.START, world)); + } + + public boolean handleServerAboutToStart(MinecraftServer server) + { + return Loader.instance().serverAboutToStart(server); + } + + public boolean handleServerStarting(MinecraftServer server) + { + return Loader.instance().serverStarting(server); + } + + public void handleServerStarted() + { + Loader.instance().serverStarted(); + } + + public void handleServerStopping() + { + Loader.instance().serverStopping(); + } + + public File getSavesDirectory() { + return sidedDelegate.getSavesDirectory(); + } + + public MinecraftServer getMinecraftServerInstance() + { + return sidedDelegate.getServer(); + } + + public void showGuiScreen(Object clientGuiElement) + { + sidedDelegate.showGuiScreen(clientGuiElement); + } + + public void queryUser(StartupQuery query) throws InterruptedException + { + sidedDelegate.queryUser(query); + } + + public void onServerStart(MinecraftServer dedicatedServer) + { + FMLServerHandler.instance(); + sidedDelegate.beginServerLoading(dedicatedServer); + } + + public void onServerStarted() + { + sidedDelegate.finishServerLoading(); + } + + + public void onPreClientTick() + { + bus().post(new TickEvent.ClientTickEvent(Phase.START)); + } + + public void onPostClientTick() + { + bus().post(new TickEvent.ClientTickEvent(Phase.END)); + } + + public void onRenderTickStart(float timer) + { + bus().post(new TickEvent.RenderTickEvent(Phase.START, timer)); + } + + public void onRenderTickEnd(float timer) + { + bus().post(new TickEvent.RenderTickEvent(Phase.END, timer)); + } + + public void onPlayerPreTick(EntityPlayer player) + { + bus().post(new TickEvent.PlayerTickEvent(Phase.START, player)); + } + + public void onPlayerPostTick(EntityPlayer player) + { + bus().post(new TickEvent.PlayerTickEvent(Phase.END, player)); + } + + public void registerCrashCallable(ICrashCallable callable) + { + crashCallables.add(callable); + } + + public void enhanceCrashReport(CrashReport crashReport, CrashReportCategory category) + { + for (ICrashCallable call: crashCallables) + { + category.addCrashSectionCallable(call.getLabel(), call); + } + } + + public void handleWorldDataSave(SaveHandler handler, WorldInfo worldInfo, NBTTagCompound tagCompound) + { + for (ModContainer mc : Loader.instance().getModList()) + { + if (mc instanceof InjectedModContainer) + { + WorldAccessContainer wac = ((InjectedModContainer)mc).getWrappedWorldAccessContainer(); + if (wac != null) + { + NBTTagCompound dataForWriting = wac.getDataForWriting(handler, worldInfo); + tagCompound.setTag(mc.getModId(), dataForWriting); + } + } + } + } + + public void handleWorldDataLoad(SaveHandler handler, WorldInfo worldInfo, NBTTagCompound tagCompound) + { + if (getEffectiveSide()!=Side.SERVER) + { + return; + } + if (handlerSet.contains(handler)) + { + return; + } + handlerSet.add(handler); + handlerToCheck = new WeakReference(handler); // for confirmBackupLevelDatUse + Map additionalProperties = Maps.newHashMap(); + worldInfo.setAdditionalProperties(additionalProperties); + for (ModContainer mc : Loader.instance().getModList()) + { + if (mc instanceof InjectedModContainer) + { + WorldAccessContainer wac = ((InjectedModContainer)mc).getWrappedWorldAccessContainer(); + if (wac != null) + { + wac.readData(handler, worldInfo, additionalProperties, tagCompound.getCompoundTag(mc.getModId())); + } + } + } + } + + public void confirmBackupLevelDatUse(SaveHandler handler) + { + if (handlerToCheck == null || handlerToCheck.get() != handler) { + // only run if the save has been initially loaded + handlerToCheck = null; + return; + } + + String text = "Forge Mod Loader detected that the backup level.dat is being used.\n\n" + + "This may happen due to a bug or corruption, continuing can damage\n" + + "your world beyond repair or lose data / progress.\n\n" + + "It's recommended to create a world backup before continuing."; + + boolean confirmed = StartupQuery.confirm(text); + if (!confirmed) StartupQuery.abort(); + } + + public boolean shouldServerBeKilledQuietly() + { + if (sidedDelegate == null) + { + return false; + } + return sidedDelegate.shouldServerShouldBeKilledQuietly(); + } + + public void handleServerStopped() + { + sidedDelegate.serverStopped(); + MinecraftServer server = getMinecraftServerInstance(); + Loader.instance().serverStopped(); + // FORCE the internal server to stop: hello optifine workaround! + if (server!=null) ObfuscationReflectionHelper.setPrivateValue(MinecraftServer.class, server, false, "field_71316"+"_v", "u", "serverStopped"); + } + + public String getModName() + { + List modNames = Lists.newArrayListWithExpectedSize(3); + modNames.add("fml"); + if (!noForge) + { + modNames.add("forge"); + } + + if (Loader.instance().getFMLBrandingProperties().containsKey("snooperbranding")) + { + modNames.add(Loader.instance().getFMLBrandingProperties().get("snooperbranding")); + } + return Joiner.on(',').join(modNames); + } + + public void addModToResourcePack(ModContainer container) + { + sidedDelegate.addModAsResource(container); + } + + public void updateResourcePackList() + { + sidedDelegate.updateResourcePackList(); + } + + public String getCurrentLanguage() + { + + return sidedDelegate.getCurrentLanguage(); + } + + public void bootstrap() + { + } + + public NetworkManager getClientToServerNetworkManager() + { + return sidedDelegate.getClientToServerNetworkManager(); + } + + public void fireMouseInput() + { + bus().post(new InputEvent.MouseInputEvent()); + } + + public void fireKeyInput() + { + bus().post(new InputEvent.KeyInputEvent()); + } + + public void firePlayerChangedDimensionEvent(EntityPlayer player, int fromDim, int toDim) + { + bus().post(new PlayerEvent.PlayerChangedDimensionEvent(player, fromDim, toDim)); + } + + public void firePlayerLoggedIn(EntityPlayer player) + { + bus().post(new PlayerEvent.PlayerLoggedInEvent(player)); + } + + public void firePlayerLoggedOut(EntityPlayer player) + { + bus().post(new PlayerEvent.PlayerLoggedOutEvent(player)); + } + + public void firePlayerRespawnEvent(EntityPlayer player) + { + bus().post(new PlayerEvent.PlayerRespawnEvent(player)); + } + + public void firePlayerItemPickupEvent(EntityPlayer player, EntityItem item) + { + bus().post(new PlayerEvent.ItemPickupEvent(player, item)); + } + + public void firePlayerCraftingEvent(EntityPlayer player, ItemStack crafted, IInventory craftMatrix) + { + bus().post(new PlayerEvent.ItemCraftedEvent(player, crafted, craftMatrix)); + } + + public void firePlayerSmeltedEvent(EntityPlayer player, ItemStack smelted) + { + bus().post(new PlayerEvent.ItemSmeltedEvent(player, smelted)); + } + + public INetHandler getClientPlayHandler() + { + return sidedDelegate.getClientPlayHandler(); + } + + public void waitForPlayClient() + { + sidedDelegate.waitForPlayClient(); + } + + public void fireNetRegistrationEvent(NetworkManager manager, Set channelSet, String channel, Side side) + { + sidedDelegate.fireNetRegistrationEvent(bus(), manager, channelSet, channel, side); + } + + public boolean shouldAllowPlayerLogins() + { + return sidedDelegate.shouldAllowPlayerLogins(); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/FMLContainer.java b/src/main/java/cpw/mods/fml/common/FMLContainer.java new file mode 100644 index 0000000..78bfe0d --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/FMLContainer.java @@ -0,0 +1,301 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common; + +import java.io.File; +import java.security.cert.Certificate; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import net.minecraft.item.Item; +import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.world.storage.SaveHandler; +import net.minecraft.world.storage.WorldInfo; + +import org.apache.logging.log4j.Level; + +import com.google.common.collect.Maps; +import com.google.common.eventbus.EventBus; +import com.google.common.eventbus.Subscribe; + +import cpw.mods.fml.client.FMLFileResourcePack; +import cpw.mods.fml.client.FMLFolderResourcePack; +import cpw.mods.fml.common.asm.FMLSanityChecker; +import cpw.mods.fml.common.event.FMLConstructionEvent; +import cpw.mods.fml.common.network.NetworkCheckHandler; +import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.network.internal.FMLNetworkHandler; +import cpw.mods.fml.common.registry.GameData; +import cpw.mods.fml.relauncher.Side; + +/** + * @author cpw + * + */ +public class FMLContainer extends DummyModContainer implements WorldAccessContainer +{ + public FMLContainer() + { + super(new ModMetadata()); + ModMetadata meta = getMetadata(); + meta.modId="FML"; + meta.name="Forge Mod Loader"; + meta.version=Loader.instance().getFMLVersionString(); + meta.credits="Made possible with help from many people"; + meta.authorList=Arrays.asList("cpw", "LexManos"); + meta.description="The Forge Mod Loader provides the ability for systems to load mods " + + "from the file system. It also provides key capabilities for mods to be able " + + "to cooperate and provide a good modding environment. "; + meta.url="https://github.com/MinecraftForge/FML/wiki"; + meta.updateUrl="https://github.com/MinecraftForge/FML/wiki"; + meta.screenshots=new String[0]; + meta.logoFile=""; + } + + @Override + public boolean registerBus(EventBus bus, LoadController controller) + { + bus.register(this); + return true; + } + + @Subscribe + public void modConstruction(FMLConstructionEvent evt) + { + NetworkRegistry.INSTANCE.register(this, this.getClass(), null, evt.getASMHarvestedData()); + FMLNetworkHandler.registerChannel(this, evt.getSide()); + } + + @NetworkCheckHandler + public boolean checkModLists(Map modList, Side side) + { + return Loader.instance().checkRemoteModList(modList,side); + } + @Override + public NBTTagCompound getDataForWriting(SaveHandler handler, WorldInfo info) + { + NBTTagCompound fmlData = new NBTTagCompound(); + NBTTagList list = new NBTTagList(); + for (ModContainer mc : Loader.instance().getActiveModList()) + { + NBTTagCompound mod = new NBTTagCompound(); + mod.setString("ModId", mc.getModId()); + mod.setString("ModVersion", mc.getVersion()); + list.appendTag(mod); + } + fmlData.setTag("ModList", list); + // name <-> id mappings + NBTTagList dataList = new NBTTagList(); + FMLLog.fine("Gathering id map for writing to world save %s", info.getWorldName()); + Map itemList = GameData.buildItemDataList(); + for (Entry item : itemList.entrySet()) + { + NBTTagCompound tag = new NBTTagCompound(); + tag.setString("K",item.getKey()); + tag.setInteger("V",item.getValue()); + dataList.appendTag(tag); + } + fmlData.setTag("ItemData", dataList); + // blocked ids + fmlData.setIntArray("BlockedItemIds", GameData.getBlockedIds()); + // block aliases + NBTTagList blockAliasList = new NBTTagList(); + for (Entry entry : GameData.getBlockRegistry().getAliases().entrySet()) + { + NBTTagCompound tag = new NBTTagCompound(); + tag.setString("K", entry.getKey()); + tag.setString("V", entry.getValue()); + blockAliasList.appendTag(tag); + } + fmlData.setTag("BlockAliases", blockAliasList); + // item aliases + NBTTagList itemAliasList = new NBTTagList(); + for (Entry entry : GameData.getItemRegistry().getAliases().entrySet()) + { + NBTTagCompound tag = new NBTTagCompound(); + tag.setString("K", entry.getKey()); + tag.setString("V", entry.getValue()); + itemAliasList.appendTag(tag); + } + fmlData.setTag("ItemAliases", itemAliasList); + + return fmlData; + } + + @Override + public void readData(SaveHandler handler, WorldInfo info, Map propertyMap, NBTTagCompound tag) + { + if (tag.hasKey("ModList")) + { + NBTTagList modList = tag.getTagList("ModList", (byte)10); + for (int i = 0; i < modList.tagCount(); i++) + { + NBTTagCompound mod = modList.getCompoundTagAt(i); + String modId = mod.getString("ModId"); + String modVersion = mod.getString("ModVersion"); + ModContainer container = Loader.instance().getIndexedModList().get(modId); + if (container == null) + { + FMLLog.log("fml.ModTracker", Level.ERROR, "This world was saved with mod %s which appears to be missing, things may not work well", modId); + continue; + } + if (!modVersion.equals(container.getVersion())) + { + FMLLog.log("fml.ModTracker", Level.INFO, "This world was saved with mod %s version %s and it is now at version %s, things may not work well", modId, modVersion, container.getVersion()); + } + } + } + + List failedElements = null; + + if (tag.hasKey("ModItemData")) + { + FMLLog.info("Attempting to convert old world data to new system. This may be trouble!"); + NBTTagList modList = tag.getTagList("ModItemData", (byte)10); + Map dataList = Maps.newLinkedHashMap(); + for (int i = 0; i < modList.tagCount(); i++) + { + NBTTagCompound itemTag = modList.getCompoundTagAt(i); + String modId = itemTag.getString("ModId"); + String itemType = itemTag.getString("ItemType"); + int itemId = itemTag.getInteger("ItemId"); + int ordinal = itemTag.getInteger("ordinal"); + String forcedModId = itemTag.hasKey("ForcedModId") ? itemTag.getString("ForcedModId") : null; + String forcedName = itemTag.hasKey("ForcedName") ? itemTag.getString("ForcedName") : null; + if (forcedName == null) + { + FMLLog.warning("Found unlabelled item in world save, this may cause problems. The item type %s:%d will not be present", itemType, ordinal); + } + else + { + boolean isItem; + try { + Class clazz = Class.forName(itemType); + clazz.asSubclass(Item.class); + isItem = true; + } + catch (ClassNotFoundException cnfs) + { + FMLLog.warning("The old item %s is not present in this game, it's type cannot be inferred - it will be skipped", itemType); + // MISSING, skip + continue; + } + catch (ClassCastException ccs) + { + isItem = false; + } + String itemLabel = String.format("%c%s:%s", isItem ? '\u0002' : '\u0001', forcedModId != null ? forcedModId : modId, forcedName); + dataList.put(itemLabel, itemId); + } + } + failedElements = GameData.injectWorldIDMap(dataList, true, true); + + } + else if (tag.hasKey("ItemData")) + { + // name <-> id mappings + NBTTagList list = tag.getTagList("ItemData", 10); + Map dataList = Maps.newLinkedHashMap(); + for (int i = 0; i < list.tagCount(); i++) + { + NBTTagCompound dataTag = list.getCompoundTagAt(i); + dataList.put(dataTag.getString("K"), dataTag.getInteger("V")); + } + + Set blockedIds = new HashSet(); + + if (!tag.hasKey("BlockedItemIds")) // no blocked id info -> old 1.7 save + { + // old early 1.7 save potentially affected by the registry mapping bug + // fix the ids the best we can... + GameData.fixBrokenIds(dataList, blockedIds); + } + + // blocked ids + for (int id : tag.getIntArray("BlockedItemIds")) + { + blockedIds.add(id); + } + // block aliases + Map blockAliases = new HashMap(); + list = tag.getTagList("BlockAliases", 10); + for (int i = 0; i < list.tagCount(); i++) + { + NBTTagCompound dataTag = list.getCompoundTagAt(i); + blockAliases.put(dataTag.getString("K"), dataTag.getString("V")); + } + // item aliases + Map itemAliases = new HashMap(); + list = tag.getTagList("ItemAliases", 10); + for (int i = 0; i < list.tagCount(); i++) + { + NBTTagCompound dataTag = list.getCompoundTagAt(i); + itemAliases.put(dataTag.getString("K"), dataTag.getString("V")); + } + + failedElements = GameData.injectWorldIDMap(dataList, blockedIds, blockAliases, itemAliases, true, true); + } + + if (failedElements != null && !failedElements.isEmpty()) + { + String text = "Forge Mod Loader could not load this save.\n\n" + + "There are "+failedElements.size()+" unassigned blocks and items in this save.\n" + + "You will not be able to load until they are present again.\n\n" + + "Missing Blocks/Items:\n"; + + for (String s : failedElements) text += s + "\n"; + + StartupQuery.notify(text); + StartupQuery.abort(); + } + } + + + @Override + public Certificate getSigningCertificate() + { + Certificate[] certificates = getClass().getProtectionDomain().getCodeSource().getCertificates(); + return certificates != null ? certificates[0] : null; + } + + @Override + public File getSource() + { + return FMLSanityChecker.fmlLocation; + } + + @Override + public Class getCustomResourcePackClass() + { + return getSource().isDirectory() ? FMLFolderResourcePack.class : FMLFileResourcePack.class; + } + + @Override + public String getGuiClassName() + { + return "cpw.mods.fml.client.FMLConfigGuiFactory"; + } + + @Override + public Object getMod() + { + return this; + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/FMLLog.java b/src/main/java/cpw/mods/fml/common/FMLLog.java new file mode 100644 index 0000000..df72bd1 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/FMLLog.java @@ -0,0 +1,79 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common; + +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.Logger; + +@SuppressWarnings("static-access") +public class FMLLog +{ + private static cpw.mods.fml.relauncher.FMLRelaunchLog coreLog = cpw.mods.fml.relauncher.FMLRelaunchLog.log; + + public static void log(String targetLog, Level level, String format, Object... data) + { + coreLog.log(targetLog, level, format, data); + } + + public static void log(Level level, String format, Object... data) + { + coreLog.log(level, format, data); + } + + public static void log(String targetLog, Level level, Throwable ex, String format, Object... data) + { + coreLog.log(targetLog, level, ex, format, data); + } + + public static void log(Level level, Throwable ex, String format, Object... data) + { + coreLog.log(level, ex, format, data); + } + + public static void severe(String format, Object... data) + { + log(Level.ERROR, format, data); + } + + public static void bigWarning(String format, Object... data) + { + log(Level.WARN, "****************************************"); + log(Level.WARN, "* "+format, data); + log(Level.WARN, "****************************************"); + } + + public static void warning(String format, Object... data) + { + log(Level.WARN, format, data); + } + + public static void info(String format, Object... data) + { + log(Level.INFO, format, data); + } + + public static void fine(String format, Object... data) + { + log(Level.DEBUG, format, data); + } + + public static void finer(String format, Object... data) + { + log(Level.TRACE, format, data); + } + + public static Logger getLogger() + { + return coreLog.getLogger(); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/FMLModContainer.java b/src/main/java/cpw/mods/fml/common/FMLModContainer.java new file mode 100644 index 0000000..4aa37d9 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/FMLModContainer.java @@ -0,0 +1,610 @@ +/* + * The FML Forge Mod Loader suite. Copyright (C) 2012 cpw + * + * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation; either version 2.1 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +package cpw.mods.fml.common; + +import java.io.File; +import java.io.FileInputStream; +import java.lang.annotation.Annotation; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.security.cert.Certificate; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; +import org.apache.logging.log4j.Level; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +import com.google.common.base.Function; +import com.google.common.base.Strings; +import com.google.common.base.Throwables; +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableList.Builder; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ListMultimap; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.SetMultimap; +import com.google.common.collect.Sets; +import com.google.common.eventbus.EventBus; +import com.google.common.eventbus.Subscribe; + +import cpw.mods.fml.common.Mod.Instance; +import cpw.mods.fml.common.Mod.Metadata; +import cpw.mods.fml.common.discovery.ASMDataTable; +import cpw.mods.fml.common.discovery.ASMDataTable.ASMData; +import cpw.mods.fml.common.discovery.ModCandidate; +import cpw.mods.fml.common.event.FMLConstructionEvent; +import cpw.mods.fml.common.event.FMLEvent; +import cpw.mods.fml.common.event.FMLFingerprintViolationEvent; +import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.versioning.ArtifactVersion; +import cpw.mods.fml.common.versioning.DefaultArtifactVersion; +import cpw.mods.fml.common.versioning.VersionParser; +import cpw.mods.fml.common.versioning.VersionRange; + +public class FMLModContainer implements ModContainer +{ + private Object modInstance; + private File source; + private ModMetadata modMetadata; + private String className; + private Map descriptor; + private boolean enabled = true; + private String internalVersion; + private boolean overridesMetadata; + private EventBus eventBus; + private LoadController controller; + private DefaultArtifactVersion processedVersion; + + private String annotationDependencies; + private VersionRange minecraftAccepted; + private boolean fingerprintNotPresent; + private Set sourceFingerprints; + private Certificate certificate; + private String modLanguage; + private ILanguageAdapter languageAdapter; + private Disableable disableability; + private ListMultimap,Method> eventMethods; + private Map customModProperties; + private ModCandidate candidate; + + public FMLModContainer(String className, ModCandidate container, Map modDescriptor) + { + this.className = className; + this.source = container.getModContainer(); + this.candidate = container; + this.descriptor = modDescriptor; + this.modLanguage = (String) modDescriptor.get("modLanguage"); + this.languageAdapter = "scala".equals(modLanguage) ? new ILanguageAdapter.ScalaAdapter() : new ILanguageAdapter.JavaAdapter(); + this.eventMethods = ArrayListMultimap.create(); + } + + private ILanguageAdapter getLanguageAdapter() + { + return languageAdapter; + } + @Override + public String getModId() + { + return (String) descriptor.get("modid"); + } + + @Override + public String getName() + { + return modMetadata.name; + } + + @Override + public String getVersion() + { + return internalVersion; + } + + @Override + public File getSource() + { + return source; + } + + @Override + public ModMetadata getMetadata() + { + return modMetadata; + } + + @Override + public void bindMetadata(MetadataCollection mc) + { + modMetadata = mc.getMetadataForId(getModId(), descriptor); + + if (descriptor.containsKey("useMetadata")) + { + overridesMetadata = !((Boolean)descriptor.get("useMetadata")).booleanValue(); + } + + if (overridesMetadata || !modMetadata.useDependencyInformation) + { + Set requirements = Sets.newHashSet(); + List dependencies = Lists.newArrayList(); + List dependants = Lists.newArrayList(); + annotationDependencies = (String) descriptor.get("dependencies"); + Loader.instance().computeDependencies(annotationDependencies, requirements, dependencies, dependants); + modMetadata.requiredMods = requirements; + modMetadata.dependencies = dependencies; + modMetadata.dependants = dependants; + FMLLog.log(getModId(), Level.TRACE, "Parsed dependency info : %s %s %s", requirements, dependencies, dependants); + } + else + { + FMLLog.log(getModId(), Level.TRACE, "Using mcmod dependency info : %s %s %s", modMetadata.requiredMods, modMetadata.dependencies, modMetadata.dependants); + } + if (Strings.isNullOrEmpty(modMetadata.name)) + { + FMLLog.log(getModId(), Level.INFO,"Mod %s is missing the required element 'name'. Substituting %s", getModId(), getModId()); + modMetadata.name = getModId(); + } + internalVersion = (String) descriptor.get("version"); + if (Strings.isNullOrEmpty(internalVersion)) + { + Properties versionProps = searchForVersionProperties(); + if (versionProps != null) + { + internalVersion = versionProps.getProperty(getModId()+".version"); + FMLLog.log(getModId(), Level.DEBUG, "Found version %s for mod %s in version.properties, using", internalVersion, getModId()); + } + + } + if (Strings.isNullOrEmpty(internalVersion) && !Strings.isNullOrEmpty(modMetadata.version)) + { + FMLLog.log(getModId(), Level.WARN, "Mod %s is missing the required element 'version' and a version.properties file could not be found. Falling back to metadata version %s", getModId(), modMetadata.version); + internalVersion = modMetadata.version; + } + if (Strings.isNullOrEmpty(internalVersion)) + { + FMLLog.log(getModId(), Level.WARN, "Mod %s is missing the required element 'version' and no fallback can be found. Substituting '1.0'.", getModId()); + modMetadata.version = internalVersion = "1.0"; + } + + String mcVersionString = (String) descriptor.get("acceptedMinecraftVersions"); + if (!Strings.isNullOrEmpty(mcVersionString)) + { + minecraftAccepted = VersionParser.parseRange(mcVersionString); + } + else + { + minecraftAccepted = Loader.instance().getMinecraftModContainer().getStaticVersionRange(); + } + } + + public Properties searchForVersionProperties() + { + try + { + FMLLog.log(getModId(), Level.DEBUG,"Attempting to load the file version.properties from %s to locate a version number for %s", getSource().getName(), getModId()); + Properties version = null; + if (getSource().isFile()) + { + ZipFile source = new ZipFile(getSource()); + ZipEntry versionFile = source.getEntry("version.properties"); + if (versionFile!=null) + { + version = new Properties(); + version.load(source.getInputStream(versionFile)); + } + source.close(); + } + else if (getSource().isDirectory()) + { + File propsFile = new File(getSource(),"version.properties"); + if (propsFile.exists() && propsFile.isFile()) + { + version = new Properties(); + FileInputStream fis = new FileInputStream(propsFile); + version.load(fis); + fis.close(); + } + } + return version; + } + catch (Exception e) + { + Throwables.propagateIfPossible(e); + FMLLog.log(getModId(), Level.TRACE, "Failed to find a usable version.properties file"); + return null; + } + } + + @Override + public void setEnabledState(boolean enabled) + { + this.enabled = enabled; + } + + @Override + public Set getRequirements() + { + return modMetadata.requiredMods; + } + + @Override + public List getDependencies() + { + return modMetadata.dependencies; + } + + @Override + public List getDependants() + { + return modMetadata.dependants; + } + + @Override + public String getSortingRules() + { + return ((overridesMetadata || !modMetadata.useDependencyInformation) ? Strings.nullToEmpty(annotationDependencies) : modMetadata.printableSortingRules()); + } + + @Override + public boolean matches(Object mod) + { + return mod == modInstance; + } + + @Override + public Object getMod() + { + return modInstance; + } + + @Override + public boolean registerBus(EventBus bus, LoadController controller) + { + if (this.enabled) + { + FMLLog.log(getModId(), Level.DEBUG, "Enabling mod %s", getModId()); + this.eventBus = bus; + this.controller = controller; + eventBus.register(this); + return true; + } + else + { + return false; + } + } + + @SuppressWarnings("unchecked") + private Method gatherAnnotations(Class clazz) throws Exception + { + Method factoryMethod = null; + for (Method m : clazz.getDeclaredMethods()) + { + for (Annotation a : m.getAnnotations()) + { + if (a.annotationType().equals(Mod.EventHandler.class)) + { + if (m.getParameterTypes().length == 1 && FMLEvent.class.isAssignableFrom(m.getParameterTypes()[0])) + { + m.setAccessible(true); + eventMethods.put((Class) m.getParameterTypes()[0],m); + } + else + { + FMLLog.log(getModId(), Level.ERROR,"The mod %s appears to have an invalid event annotation %s. This annotation can only apply to methods with recognized event arguments - it will not be called", getModId(), a.annotationType().getSimpleName()); + } + } + else if (a.annotationType().equals(Mod.InstanceFactory.class)) + { + if (Modifier.isStatic(m.getModifiers()) && m.getParameterTypes().length == 0 && factoryMethod == null) + { + m.setAccessible(true); + factoryMethod = m; + } + else if (!(Modifier.isStatic(m.getModifiers()) && m.getParameterTypes().length == 0)) + { + FMLLog.log(getModId(), Level.ERROR, "The InstanceFactory annotation can only apply to a static method, taking zero arguments - it will be ignored on %s(%s)", m.getName(), Arrays.asList(m.getParameterTypes())); + } + else if (factoryMethod != null) + { + FMLLog.log(getModId(), Level.ERROR, "The InstanceFactory annotation can only be used once, the application to %s(%s) will be ignored", m.getName(), Arrays.asList(m.getParameterTypes())); + } + } + } + } + return factoryMethod; + } + + private void processFieldAnnotations(ASMDataTable asmDataTable) throws Exception + { + SetMultimap annotations = asmDataTable.getAnnotationsFor(this); + + parseSimpleFieldAnnotation(annotations, Instance.class.getName(), new Function() + { + @Override + public Object apply(ModContainer mc) + { + return mc.getMod(); + } + }); + parseSimpleFieldAnnotation(annotations, Metadata.class.getName(), new Function() + { + @Override + public Object apply(ModContainer mc) + { + return mc.getMetadata(); + } + }); + } + + private void parseSimpleFieldAnnotation(SetMultimap annotations, String annotationClassName, Function retreiver) throws IllegalAccessException + { + String[] annName = annotationClassName.split("\\."); + String annotationName = annName[annName.length - 1]; + for (ASMData targets : annotations.get(annotationClassName)) + { + String targetMod = (String) targets.getAnnotationInfo().get("value"); + Field f = null; + Object injectedMod = null; + ModContainer mc = this; + boolean isStatic = false; + Class clz = modInstance.getClass(); + if (!Strings.isNullOrEmpty(targetMod)) + { + if (Loader.isModLoaded(targetMod)) + { + mc = Loader.instance().getIndexedModList().get(targetMod); + } + else + { + mc = null; + } + } + if (mc != null) + { + try + { + clz = Class.forName(targets.getClassName(), true, Loader.instance().getModClassLoader()); + f = clz.getDeclaredField(targets.getObjectName()); + f.setAccessible(true); + isStatic = Modifier.isStatic(f.getModifiers()); + injectedMod = retreiver.apply(mc); + } + catch (Exception e) + { + Throwables.propagateIfPossible(e); + FMLLog.log(getModId(), Level.WARN, e, "Attempting to load @%s in class %s for %s and failing", annotationName, targets.getClassName(), mc.getModId()); + } + } + if (f != null) + { + Object target = null; + if (!isStatic) + { + target = modInstance; + if (!modInstance.getClass().equals(clz)) + { + FMLLog.log(getModId(), Level.WARN, "Unable to inject @%s in non-static field %s.%s for %s as it is NOT the primary mod instance", annotationName, targets.getClassName(), targets.getObjectName(), mc.getModId()); + continue; + } + } + f.set(target, injectedMod); + } + } + } + + @Subscribe + public void constructMod(FMLConstructionEvent event) + { + try + { + ModClassLoader modClassLoader = event.getModClassLoader(); + modClassLoader.addFile(source); + modClassLoader.clearNegativeCacheFor(candidate.getClassList()); + Class clazz = Class.forName(className, true, modClassLoader); + + Certificate[] certificates = clazz.getProtectionDomain().getCodeSource().getCertificates(); + int len = 0; + if (certificates != null) + { + len = certificates.length; + } + Builder certBuilder = ImmutableList.builder(); + for (int i = 0; i < len; i++) + { + certBuilder.add(CertificateHelper.getFingerprint(certificates[i])); + } + + ImmutableList certList = certBuilder.build(); + sourceFingerprints = ImmutableSet.copyOf(certList); + + String expectedFingerprint = (String) descriptor.get("certificateFingerprint"); + + fingerprintNotPresent = true; + + if (expectedFingerprint != null && !expectedFingerprint.isEmpty()) + { + if (!sourceFingerprints.contains(expectedFingerprint)) + { + Level warnLevel = Level.ERROR; + if (source.isDirectory()) + { + warnLevel = Level.TRACE; + } + FMLLog.log(getModId(), warnLevel, "The mod %s is expecting signature %s for source %s, however there is no signature matching that description", getModId(), expectedFingerprint, source.getName()); + } + else + { + certificate = certificates[certList.indexOf(expectedFingerprint)]; + fingerprintNotPresent = false; + } + } + + @SuppressWarnings("unchecked") + List> props = (List>) descriptor.get("customProperties"); + if (props != null) + { + com.google.common.collect.ImmutableMap.Builder builder = ImmutableMap.builder(); + for (Map p : props) + { + builder.put((String)p.get("k"),(String)p.get("v")); + } + customModProperties = builder.build(); + } + else + { + customModProperties = EMPTY_PROPERTIES; + } + + Boolean hasDisableableFlag = (Boolean) descriptor.get("canBeDeactivated"); + boolean hasReverseDepends = !event.getReverseDependencies().get(getModId()).isEmpty(); + if (hasDisableableFlag != null && hasDisableableFlag) + { + disableability = hasReverseDepends ? Disableable.DEPENDENCIES : Disableable.YES; + } + else + { + disableability = hasReverseDepends ? Disableable.DEPENDENCIES : Disableable.RESTART; + } + Method factoryMethod = gatherAnnotations(clazz); + modInstance = getLanguageAdapter().getNewInstance(this,clazz, modClassLoader, factoryMethod); + NetworkRegistry.INSTANCE.register(this, clazz, (String)(descriptor.containsKey("acceptableRemoteVersions") ? descriptor.get("acceptableRemoteVersions") : null), event.getASMHarvestedData()); + if (fingerprintNotPresent) + { + eventBus.post(new FMLFingerprintViolationEvent(source.isDirectory(), source, ImmutableSet.copyOf(this.sourceFingerprints), expectedFingerprint)); + } + ProxyInjector.inject(this, event.getASMHarvestedData(), FMLCommonHandler.instance().getSide(), getLanguageAdapter()); + processFieldAnnotations(event.getASMHarvestedData()); + } + catch (Throwable e) + { + controller.errorOccurred(this, e); + Throwables.propagateIfPossible(e); + } + } + + @Subscribe + public void handleModStateEvent(FMLEvent event) + { + if (!eventMethods.containsKey(event.getClass())) + { + return; + } + try + { + for (Method m : eventMethods.get(event.getClass())) + { + m.invoke(modInstance, event); + } + } + catch (Throwable t) + { + controller.errorOccurred(this, t); + } + } + + @Override + public ArtifactVersion getProcessedVersion() + { + if (processedVersion == null) + { + processedVersion = new DefaultArtifactVersion(getModId(), getVersion()); + } + return processedVersion; + } + @Override + public boolean isImmutable() + { + return false; + } + + @Override + public String getDisplayVersion() + { + return modMetadata.version; + } + + @Override + public VersionRange acceptableMinecraftVersionRange() + { + return minecraftAccepted; + } + + @Override + public Certificate getSigningCertificate() + { + return certificate; + } + + @Override + public String toString() + { + return "FMLMod:"+getModId()+"{"+getVersion()+"}"; + } + + @Override + public Map getCustomModProperties() + { + return customModProperties; + } + + @Override + public Class getCustomResourcePackClass() + { + try + { + return getSource().isDirectory() ? Class.forName("cpw.mods.fml.client.FMLFolderResourcePack", true, getClass().getClassLoader()) : Class.forName("cpw.mods.fml.client.FMLFileResourcePack",true, getClass().getClassLoader()); + } + catch (ClassNotFoundException e) + { + return null; + } + } + @Override + public Map getSharedModDescriptor() + { + Map descriptor = Maps.newHashMap(); + descriptor.put("modsystem", "FML"); + descriptor.put("id", getModId()); + descriptor.put("version",getDisplayVersion()); + descriptor.put("name", getName()); + descriptor.put("url", modMetadata.url); + descriptor.put("authors", modMetadata.getAuthorList()); + descriptor.put("description", modMetadata.description); + return descriptor; + } + + @Override + public Disableable canBeDisabled() + { + return disableability; + } + + @Override + public String getGuiClassName() + { + return (String) descriptor.get("guiFactory"); + } + + @Override + public List getOwnedPackages() + { + return candidate.getContainedPackages(); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/IASMHook.java b/src/main/java/cpw/mods/fml/common/IASMHook.java new file mode 100644 index 0000000..5208db2 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/IASMHook.java @@ -0,0 +1,34 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common; + +import org.objectweb.asm.tree.ClassNode; + +public interface IASMHook { + /** + * Inject the {@link Mod} class node into this instance. This allows retrieval from custom + * attributes or other artifacts in your mod class + * + * @param modClassNode The mod class + * @return optionally some code generated classes that will be injected into the classloader + */ + ClassNode[] inject(ClassNode modClassNode); + /** + * Allow mods to manipulate classes loaded from this {@link Mod}'s jar file. The {@link Mod} + * class is always guaranteed to be called first. + * The node state should be changed in place. + * + * @param node The class being loaded + */ + void modifyClass(String className, ClassNode node); +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/ICrashCallable.java b/src/main/java/cpw/mods/fml/common/ICrashCallable.java new file mode 100644 index 0000000..441ac36 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/ICrashCallable.java @@ -0,0 +1,20 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common; + +import java.util.concurrent.Callable; + +public interface ICrashCallable extends Callable +{ + String getLabel(); +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/IFMLHandledException.java b/src/main/java/cpw/mods/fml/common/IFMLHandledException.java new file mode 100644 index 0000000..0ca2f01 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/IFMLHandledException.java @@ -0,0 +1,18 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common; + +public interface IFMLHandledException +{ + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/IFMLSidedHandler.java b/src/main/java/cpw/mods/fml/common/IFMLSidedHandler.java new file mode 100644 index 0000000..5fb6120 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/IFMLSidedHandler.java @@ -0,0 +1,64 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common; + +import java.io.File; +import java.util.List; +import java.util.Set; + +import net.minecraft.network.INetHandler; +import net.minecraft.network.NetworkManager; +import net.minecraft.server.MinecraftServer; +import cpw.mods.fml.common.eventhandler.EventBus; +import cpw.mods.fml.relauncher.Side; + +public interface IFMLSidedHandler +{ + List getAdditionalBrandingInformation(); + + Side getSide(); + + void haltGame(String message, Throwable exception); + + void showGuiScreen(Object clientGuiElement); + + void queryUser(StartupQuery query) throws InterruptedException; + + void beginServerLoading(MinecraftServer server); + + void finishServerLoading(); + + File getSavesDirectory(); + + MinecraftServer getServer(); + + boolean shouldServerShouldBeKilledQuietly(); + + void addModAsResource(ModContainer container); + + void updateResourcePackList(); + + String getCurrentLanguage(); + + void serverStopped(); + + NetworkManager getClientToServerNetworkManager(); + + INetHandler getClientPlayHandler(); + + void waitForPlayClient(); + + void fireNetRegistrationEvent(EventBus bus, NetworkManager manager, Set channelSet, String channel, Side side); + + boolean shouldAllowPlayerLogins(); +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/IFuelHandler.java b/src/main/java/cpw/mods/fml/common/IFuelHandler.java new file mode 100644 index 0000000..0794185 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/IFuelHandler.java @@ -0,0 +1,20 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common; + +import net.minecraft.item.ItemStack; + +public interface IFuelHandler +{ + int getBurnTime(ItemStack fuel); +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/ILanguageAdapter.java b/src/main/java/cpw/mods/fml/common/ILanguageAdapter.java new file mode 100644 index 0000000..60c794c --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/ILanguageAdapter.java @@ -0,0 +1,196 @@ +package cpw.mods.fml.common; + +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import org.apache.logging.log4j.Level; + +import cpw.mods.fml.relauncher.Side; + +public interface ILanguageAdapter { + public Object getNewInstance(FMLModContainer container, Class objectClass, ClassLoader classLoader, Method factoryMarkedAnnotation) throws Exception; + public boolean supportsStatics(); + public void setProxy(Field target, Class proxyTarget, Object proxy) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException; + public void setInternalProxies(ModContainer mod, Side side, ClassLoader loader); + + public static class ScalaAdapter implements ILanguageAdapter { + @Override + public Object getNewInstance(FMLModContainer container, Class scalaObjectClass, ClassLoader classLoader, Method factoryMarkedAnnotation) throws Exception + { + Class sObjectClass = Class.forName(scalaObjectClass.getName()+"$",true,classLoader); + return sObjectClass.getField("MODULE$").get(null); + } + + @Override + public boolean supportsStatics() + { + return false; + } + + @Override + public void setProxy(Field target, Class proxyTarget, Object proxy) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException + { + try + { + // Get the actual singleton class. The two variants are from + // whether the @SidedProxy is declared in a the class block + // of the object directly, or in the object block, i.e. + // whether it's: + // class ModName { + // @SidedProxy ... + // } + // object ModName extends ModName {} + // which leads to us getting the outer class, or + // object ModName { + // @SidedProxy ... + // } + // which leads to us getting the inner class. + if (!proxyTarget.getName().endsWith("$")) + { + // Get internal class generated by Scala. + proxyTarget = Class.forName(proxyTarget.getName() + "$", true, proxyTarget.getClassLoader()); + } + } + catch (ClassNotFoundException e) + { + // Not a singleton, look for @Instance field as a fallback. + FMLLog.log(Level.INFO, e, "An error occured trying to load a proxy into %s.%s. Did you declare your mod as 'class' instead of 'object'?", proxyTarget.getSimpleName(), target.getName()); + return; + } + + // Get the instance via the MODULE$ field which is + // automatically generated by the Scala compiler for + // singletons. + Object targetInstance = proxyTarget.getField("MODULE$").get(null); + + try + { + // Find setter function. We do it this way because we can't + // necessarily use proxyTarget.getMethod(proxy.getClass()), as + // it might be a subclass and not the exact parameter type. + // All fields are private in Scala, wrapped by a getter and + // setter named and _$eq. To those + // familiar with scala.reflect.BeanProperty: these will always + // be there, set and get will always + // only be generated *additionally*. + final String setterName = target.getName() + "_$eq"; + for (Method setter : proxyTarget.getMethods()) + { + Class[] setterParameters = setter.getParameterTypes(); + if (setterName.equals(setter.getName()) && + // Some more validation. + setterParameters.length == 1 && + setterParameters[0].isAssignableFrom(proxy.getClass())) + { + // Here goes nothing... + setter.invoke(targetInstance, proxy); + return; + } + } + } + catch (InvocationTargetException e) + { + FMLLog.log(Level.ERROR, e, "An error occured trying to load a proxy into %s.%s", proxyTarget.getSimpleName(), target.getName()); + throw new LoaderException(e); + } + + // If we come here we could not find a setter for this proxy. + FMLLog.severe("Failed loading proxy into %s.%s, could not find setter function. Did you declare the field with 'val' instead of 'var'?", proxyTarget.getSimpleName(), target.getName()); + throw new LoaderException(); + } + + @Override + public void setInternalProxies(ModContainer mod, Side side, ClassLoader loader) + { + // For Scala mods, we want to enable authors to write them like so: + // object ModName { + // @SidedProxy(...) + // var proxy: ModProxy = null + // } + // For this to work, we have to search inside the inner class Scala + // generates for singletons, which is in called ModName$. These are + // not automatically handled, because the mod discovery code ignores + // internal classes. + // Note that it is alternatively possible to write this like so: + // class ModName { + // @SidedProxy(...) + // var proxy: ModProxy = null + // } + // object ModName extends ModName { ... } + // which will fall back to the normal injection code which calls + // setProxy in turn. + + // Get the actual mod implementation, which will be the inner class + // if we have a singleton. + Class proxyTarget = mod.getMod().getClass(); + if (proxyTarget.getName().endsWith("$")) + { + // So we have a singleton class, check if there are targets. + for (Field target : proxyTarget.getDeclaredFields()) + { + // This will not turn up anything if the alternative + // approach was taken (manually declaring the class). + // So we don't initialize the field twice. + if (target.getAnnotation(SidedProxy.class) != null) + { + String targetType = side.isClient() ? target.getAnnotation(SidedProxy.class).clientSide() : target.getAnnotation(SidedProxy.class).serverSide(); + try + { + Object proxy = Class.forName(targetType, true, loader).newInstance(); + + if (!target.getType().isAssignableFrom(proxy.getClass())) + { + FMLLog.severe("Attempted to load a proxy type %s into %s.%s, but the types don't match", targetType, proxyTarget.getSimpleName(), target.getName()); + throw new LoaderException(); + } + + setProxy(target, proxyTarget, proxy); + } + catch (Exception e) { + FMLLog.log(Level.ERROR, e, "An error occured trying to load a proxy into %s.%s", proxyTarget.getSimpleName(), target.getName()); + throw new LoaderException(e); + } + } + } + } + else + { + FMLLog.finer("Mod does not appear to be a singleton."); + } + } + } + + public static class JavaAdapter implements ILanguageAdapter { + @Override + public Object getNewInstance(FMLModContainer container, Class objectClass, ClassLoader classLoader, Method factoryMarkedMethod) throws Exception + { + if (factoryMarkedMethod != null) + { + return factoryMarkedMethod.invoke(null); + } + else + { + return objectClass.newInstance(); + } + } + + @Override + public boolean supportsStatics() + { + return true; + } + + @Override + public void setProxy(Field target, Class proxyTarget, Object proxy) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, + SecurityException + { + target.set(null, proxy); + } + + @Override + public void setInternalProxies(ModContainer mod, Side side, ClassLoader loader) + { + // Nothing to do here. + } + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/IWorldGenerator.java b/src/main/java/cpw/mods/fml/common/IWorldGenerator.java new file mode 100644 index 0000000..d03a04f --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/IWorldGenerator.java @@ -0,0 +1,41 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common; + +import java.util.Random; + +import net.minecraft.world.World; +import net.minecraft.world.chunk.IChunkProvider; + + +/** + * This is called back during world generation. + * + * @author cpw + * + */ +public interface IWorldGenerator +{ + /** + * Generate some world + * + * @param random the chunk specific {@link Random}. + * @param chunkX the chunk X coordinate of this chunk. + * @param chunkZ the chunk Z coordinate of this chunk. + * @param world : additionalData[0] The minecraft {@link World} we're generating for. + * @param chunkGenerator : additionalData[1] The {@link IChunkProvider} that is generating. + * @param chunkProvider : additionalData[2] {@link IChunkProvider} that is requesting the world generation. + * + */ + public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider); +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/InjectedModContainer.java b/src/main/java/cpw/mods/fml/common/InjectedModContainer.java new file mode 100644 index 0000000..ce82214 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/InjectedModContainer.java @@ -0,0 +1,204 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common; + +import java.io.File; +import java.security.cert.Certificate; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.google.common.eventbus.EventBus; + +import cpw.mods.fml.common.versioning.ArtifactVersion; +import cpw.mods.fml.common.versioning.VersionRange; + +public class InjectedModContainer implements ModContainer +{ + private File source; + public final ModContainer wrappedContainer; + + public InjectedModContainer(ModContainer mc, File source) + { + this.source = source != null ? source : new File("minecraft.jar"); + this.wrappedContainer = mc; + } + + @Override + public String getModId() + { + return wrappedContainer.getModId(); + } + + @Override + public String getName() + { + return wrappedContainer.getName(); + } + + @Override + public String getVersion() + { + return wrappedContainer.getVersion(); + } + + @Override + public File getSource() + { + return source; + } + + @Override + public ModMetadata getMetadata() + { + return wrappedContainer.getMetadata(); + } + + @Override + public void bindMetadata(MetadataCollection mc) + { + wrappedContainer.bindMetadata(mc); + } + + @Override + public void setEnabledState(boolean enabled) + { + wrappedContainer.setEnabledState(enabled); + } + + @Override + public Set getRequirements() + { + return wrappedContainer.getRequirements(); + } + + @Override + public List getDependencies() + { + return wrappedContainer.getDependencies(); + } + + @Override + public List getDependants() + { + return wrappedContainer.getDependants(); + } + + @Override + public String getSortingRules() + { + return wrappedContainer.getSortingRules(); + } + + @Override + public boolean registerBus(EventBus bus, LoadController controller) + { + return wrappedContainer.registerBus(bus, controller); + } + + @Override + public boolean matches(Object mod) + { + return wrappedContainer.matches(mod); + } + + @Override + public Object getMod() + { + return wrappedContainer.getMod(); + } + + @Override + public ArtifactVersion getProcessedVersion() + { + return wrappedContainer.getProcessedVersion(); + } + + @Override + public boolean isImmutable() + { + return true; + } + + @Override + public String getDisplayVersion() + { + return wrappedContainer.getDisplayVersion(); + } + + @Override + public VersionRange acceptableMinecraftVersionRange() + { + return wrappedContainer.acceptableMinecraftVersionRange(); + } + + public WorldAccessContainer getWrappedWorldAccessContainer() + { + if (wrappedContainer instanceof WorldAccessContainer) + { + return (WorldAccessContainer) wrappedContainer; + } + else + { + return null; + } + } + + @Override + public Certificate getSigningCertificate() + { + return wrappedContainer.getSigningCertificate(); + } + + @Override + public String toString() + { + return "Wrapped{"+wrappedContainer.toString()+"}"; + } + + @Override + public Map getCustomModProperties() + { + return wrappedContainer.getCustomModProperties(); + } + + @Override + public Class getCustomResourcePackClass() + { + return wrappedContainer.getCustomResourcePackClass(); + } + + @Override + public Map getSharedModDescriptor() + { + return wrappedContainer.getSharedModDescriptor(); + } + + @Override + public Disableable canBeDisabled() + { + return wrappedContainer.canBeDisabled(); + } + + @Override + public String getGuiClassName() + { + return wrappedContainer.getGuiClassName(); + } + + @Override + public List getOwnedPackages() + { + return wrappedContainer.getOwnedPackages(); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/LoadController.java b/src/main/java/cpw/mods/fml/common/LoadController.java new file mode 100644 index 0000000..03ddddb --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/LoadController.java @@ -0,0 +1,352 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common; + +import java.lang.reflect.InvocationTargetException; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map.Entry; + +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.ThreadContext; + +import com.google.common.base.Joiner; +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.BiMap; +import com.google.common.collect.Collections2; +import com.google.common.collect.ImmutableBiMap; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMap.Builder; +import com.google.common.collect.Iterables; +import com.google.common.collect.ListMultimap; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Multimap; +import com.google.common.eventbus.EventBus; +import com.google.common.eventbus.Subscribe; + +import cpw.mods.fml.common.LoaderState.ModState; +import cpw.mods.fml.common.event.FMLEvent; +import cpw.mods.fml.common.event.FMLLoadEvent; +import cpw.mods.fml.common.event.FMLModDisabledEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.event.FMLStateEvent; +import cpw.mods.fml.common.functions.ArtifactVersionNameFunction; +import cpw.mods.fml.common.versioning.ArtifactVersion; + +public class LoadController +{ + private Loader loader; + private EventBus masterChannel; + private ImmutableMap eventChannels; + private LoaderState state; + private Multimap modStates = ArrayListMultimap.create(); + private Multimap errors = ArrayListMultimap.create(); + private List activeModList = Lists.newArrayList(); + private ModContainer activeContainer; + private BiMap modObjectList; + private ListMultimap packageOwners; + + public LoadController(Loader loader) + { + this.loader = loader; + this.masterChannel = new EventBus("FMLMainChannel"); + this.masterChannel.register(this); + + state = LoaderState.NOINIT; + packageOwners = ArrayListMultimap.create(); + + } + + void disableMod(ModContainer mod) + { + HashMap temporary = Maps.newHashMap(eventChannels); + String modId = mod.getModId(); + EventBus bus = temporary.remove(modId); + bus.post(new FMLModDisabledEvent()); + if (errors.get(modId).isEmpty()) + { + eventChannels = ImmutableMap.copyOf(temporary); + modStates.put(modId, ModState.DISABLED); + modObjectList.remove(mod); + activeModList.remove(mod); + } + } + @Subscribe + public void buildModList(FMLLoadEvent event) + { + Builder eventBus = ImmutableMap.builder(); + + for (ModContainer mod : loader.getModList()) + { + //Create mod logger, and make the EventBus logger a child of it. + EventBus bus = new EventBus(mod.getModId()); + boolean isActive = mod.registerBus(bus, this); + if (isActive) + { + activeModList.add(mod); + modStates.put(mod.getModId(), ModState.UNLOADED); + eventBus.put(mod.getModId(), bus); + FMLCommonHandler.instance().addModToResourcePack(mod); + } + else + { + FMLLog.log(mod.getModId(), Level.WARN, "Mod %s has been disabled through configuration", mod.getModId()); + modStates.put(mod.getModId(), ModState.UNLOADED); + modStates.put(mod.getModId(), ModState.DISABLED); + } + } + + eventChannels = eventBus.build(); + FMLCommonHandler.instance().updateResourcePackList(); + } + + public void distributeStateMessage(LoaderState state, Object... eventData) + { + if (state.hasEvent()) + { + masterChannel.post(state.getEvent(eventData)); + } + } + + public void transition(LoaderState desiredState, boolean forceState) + { + LoaderState oldState = state; + state = state.transition(!errors.isEmpty()); + if (state != desiredState && !forceState) + { + Throwable toThrow = null; + FMLLog.severe("Fatal errors were detected during the transition from %s to %s. Loading cannot continue", oldState, desiredState); + StringBuilder sb = new StringBuilder(); + printModStates(sb); + FMLLog.severe("%s", sb.toString()); + if (errors.size()>0) + { + FMLLog.severe("The following problems were captured during this phase"); + for (Entry error : errors.entries()) + { + FMLLog.log(Level.ERROR, error.getValue(), "Caught exception from %s", error.getKey()); + if (error.getValue() instanceof IFMLHandledException) + { + toThrow = error.getValue(); + } + else if (toThrow == null) + { + toThrow = error.getValue(); + } + } + } + else + { + FMLLog.severe("The ForgeModLoader state engine has become corrupted. Probably, a state was missed by and invalid modification to a base class" + + "ForgeModLoader depends on. This is a critical error and not recoverable. Investigate any modifications to base classes outside of" + + "ForgeModLoader, especially Optifine, to see if there are fixes available."); + throw new RuntimeException("The ForgeModLoader state engine is invalid"); + } + if (toThrow != null && toThrow instanceof RuntimeException) + { + throw (RuntimeException)toThrow; + } + else + { + throw new LoaderException(toThrow); + } + } + else if (state != desiredState && forceState) + { + FMLLog.info("The state engine was in incorrect state %s and forced into state %s. Errors may have been discarded.", state, desiredState); + forceState(desiredState); + } + + } + + public ModContainer activeContainer() + { + return activeContainer != null ? activeContainer : findActiveContainerFromStack(); + } + + @Subscribe + public void propogateStateMessage(FMLEvent stateEvent) + { + if (stateEvent instanceof FMLPreInitializationEvent) + { + modObjectList = buildModObjectList(); + } + for (ModContainer mc : activeModList) + { + sendEventToModContainer(stateEvent, mc); + } + } + + private void sendEventToModContainer(FMLEvent stateEvent, ModContainer mc) + { + String modId = mc.getModId(); + Collection requirements = Collections2.transform(mc.getRequirements(),new ArtifactVersionNameFunction()); + for (ArtifactVersion av : mc.getDependencies()) + { + if (av.getLabel()!= null && requirements.contains(av.getLabel()) && modStates.containsEntry(av.getLabel(),ModState.ERRORED)) + { + FMLLog.log(modId, Level.ERROR, "Skipping event %s and marking errored mod %s since required dependency %s has errored", stateEvent.getEventType(), modId, av.getLabel()); + modStates.put(modId, ModState.ERRORED); + return; + } + } + activeContainer = mc; + stateEvent.applyModContainer(activeContainer()); + ThreadContext.put("mod", modId); + FMLLog.log(modId, Level.TRACE, "Sending event %s to mod %s", stateEvent.getEventType(), modId); + eventChannels.get(modId).post(stateEvent); + FMLLog.log(modId, Level.TRACE, "Sent event %s to mod %s", stateEvent.getEventType(), modId); + ThreadContext.remove("mod"); + activeContainer = null; + if (stateEvent instanceof FMLStateEvent) + { + if (!errors.containsKey(modId)) + { + modStates.put(modId, ((FMLStateEvent)stateEvent).getModState()); + } + else + { + modStates.put(modId, ModState.ERRORED); + } + } + } + + public ImmutableBiMap buildModObjectList() + { + ImmutableBiMap.Builder builder = ImmutableBiMap.builder(); + for (ModContainer mc : activeModList) + { + if (!mc.isImmutable() && mc.getMod()!=null) + { + builder.put(mc, mc.getMod()); + List packages = mc.getOwnedPackages(); + for (String pkg : packages) + { + packageOwners.put(pkg, mc); + } + } + if (mc.getMod()==null && !mc.isImmutable() && state!=LoaderState.CONSTRUCTING) + { + FMLLog.severe("There is a severe problem with %s - it appears not to have constructed correctly", mc.getModId()); + if (state != LoaderState.CONSTRUCTING) + { + this.errorOccurred(mc, new RuntimeException()); + } + } + } + return builder.build(); + } + + public void errorOccurred(ModContainer modContainer, Throwable exception) + { + if (exception instanceof InvocationTargetException) + { + errors.put(modContainer.getModId(), ((InvocationTargetException)exception).getCause()); + } + else + { + errors.put(modContainer.getModId(), exception); + } + } + + public void printModStates(StringBuilder ret) + { + for (ModContainer mc : loader.getModList()) + { + ret.append("\n\t").append(mc.getModId()).append("{").append(mc.getVersion()).append("} [").append(mc.getName()).append("] (").append(mc.getSource().getName()).append(") "); + Joiner.on("->"). appendTo(ret, modStates.get(mc.getModId())); + } + } + + public List getActiveModList() + { + return activeModList; + } + + public ModState getModState(ModContainer selectedMod) + { + return Iterables.getLast(modStates.get(selectedMod.getModId()), ModState.AVAILABLE); + } + + public void distributeStateMessage(Class customEvent) + { + try + { + masterChannel.post(customEvent.newInstance()); + } + catch (Exception e) + { + FMLLog.log(Level.ERROR, e, "An unexpected exception"); + throw new LoaderException(e); + } + } + + public BiMap getModObjectList() + { + if (modObjectList == null) + { + FMLLog.severe("Detected an attempt by a mod %s to perform game activity during mod construction. This is a serious programming error.", activeContainer); + return buildModObjectList(); + } + return ImmutableBiMap.copyOf(modObjectList); + } + + public boolean isInState(LoaderState state) + { + return this.state == state; + } + + boolean hasReachedState(LoaderState state) { + return this.state.ordinal()>=state.ordinal() && this.state!=LoaderState.ERRORED; + } + + void forceState(LoaderState newState) + { + this.state = newState; + } + + private ModContainer findActiveContainerFromStack() + { + for (Class c : getCallingStack()) + { + int idx = c.getName().lastIndexOf('.'); + if (idx == -1) + { + continue; + } + String pkg = c.getName().substring(0,idx); + if (packageOwners.containsKey(pkg)) + { + return packageOwners.get(pkg).get(0); + } + } + + return null; + } + private FMLSecurityManager accessibleManager = new FMLSecurityManager(); + + class FMLSecurityManager extends SecurityManager + { + Class[] getStackClasses() + { + return getClassContext(); + } + } + + Class[] getCallingStack() + { + return accessibleManager.getStackClasses(); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/Loader.java b/src/main/java/cpw/mods/fml/common/Loader.java new file mode 100644 index 0000000..592ca31 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/Loader.java @@ -0,0 +1,965 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common; + +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.net.MalformedURLException; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; + +import org.apache.logging.log4j.Level; + +import com.google.common.base.CharMatcher; +import com.google.common.base.Function; +import com.google.common.base.Joiner; +import com.google.common.base.Splitter; +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMultiset; +import com.google.common.collect.LinkedHashMultimap; +import com.google.common.collect.ListMultimap; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Multimaps; +import com.google.common.collect.Multiset.Entry; +import com.google.common.collect.Multisets; +import com.google.common.collect.Ordering; +import com.google.common.collect.SetMultimap; +import com.google.common.collect.Sets; +import com.google.common.collect.TreeMultimap; + +import cpw.mods.fml.common.LoaderState.ModState; +import cpw.mods.fml.common.ModContainer.Disableable; +import cpw.mods.fml.common.discovery.ModDiscoverer; +import cpw.mods.fml.common.event.FMLInterModComms; +import cpw.mods.fml.common.event.FMLLoadEvent; +import cpw.mods.fml.common.event.FMLMissingMappingsEvent; +import cpw.mods.fml.common.event.FMLMissingMappingsEvent.MissingMapping; +import cpw.mods.fml.common.event.FMLModIdMappingEvent; +import cpw.mods.fml.common.functions.ArtifactVersionNameFunction; +import cpw.mods.fml.common.functions.ModIdFunction; +import cpw.mods.fml.common.registry.GameData; +import cpw.mods.fml.common.registry.GameRegistry.Type; +import cpw.mods.fml.common.toposort.ModSorter; +import cpw.mods.fml.common.toposort.ModSortingException; +import cpw.mods.fml.common.toposort.ModSortingException.SortingExceptionData; +import cpw.mods.fml.common.toposort.TopologicalSort; +import cpw.mods.fml.common.versioning.ArtifactVersion; +import cpw.mods.fml.common.versioning.VersionParser; +import cpw.mods.fml.relauncher.Side; + +/** + * The loader class performs the actual loading of the mod code from disk. + * + *

+ * There are several {@link LoaderState}s to mod loading, triggered in two + * different stages from the FML handler code's hooks into the minecraft code. + *

+ * + *
    + *
  1. LOADING. Scanning the filesystem for mod containers to load (zips, jars, + * directories), adding them to the {@link #modClassLoader} Scanning, the loaded + * containers for mod classes to load and registering them appropriately.
  2. + *
  3. PREINIT. The mod classes are configured, they are sorted into a load + * order, and instances of the mods are constructed.
  4. + *
  5. INIT. The mod instances are initialized. For BaseMod mods, this involves + * calling the load method.
  6. + *
  7. POSTINIT. The mod instances are post initialized. For BaseMod mods this + * involves calling the modsLoaded method.
  8. + *
  9. UP. The Loader is complete
  10. + *
  11. ERRORED. The loader encountered an error during the LOADING phase and + * dropped to this state instead. It will not complete loading from this state, + * but it attempts to continue loading before abandoning and giving a fatal + * error.
  12. + *
+ * + * Phase 1 code triggers the LOADING and PREINIT states. Phase 2 code triggers + * the INIT and POSTINIT states. + * + * @author cpw + * + */ +public class Loader +{ + private static final Splitter DEPENDENCYPARTSPLITTER = Splitter.on(":").omitEmptyStrings().trimResults(); + private static final Splitter DEPENDENCYSPLITTER = Splitter.on(";").omitEmptyStrings().trimResults(); + /** + * The singleton instance + */ + private static Loader instance; + /** + * Build information for tracking purposes. + */ + private static String major; + private static String minor; + private static String rev; + private static String build; + private static String mccversion; + private static String mcpversion; + + /** + * The class loader we load the mods into. + */ + private ModClassLoader modClassLoader; + /** + * The sorted list of mods. + */ + private List mods; + /** + * A named list of mods + */ + private Map namedMods; + /** + * A reverse dependency graph for mods + */ + private ListMultimap reverseDependencies; + /** + * The canonical configuration directory + */ + private File canonicalConfigDir; + private File canonicalModsDir; + private LoadController modController; + private MinecraftDummyContainer minecraft; + private MCPDummyContainer mcp; + + private static File minecraftDir; + private static List injectedContainers; + private ImmutableMap fmlBrandingProperties; + private File forcedModFile; + + public static Loader instance() + { + if (instance == null) + { + instance = new Loader(); + } + + return instance; + } + + @SuppressWarnings("unchecked") + public static void injectData(Object... data) + { + major = (String) data[0]; + minor = (String) data[1]; + rev = (String) data[2]; + build = (String) data[3]; + mccversion = (String) data[4]; + mcpversion = (String) data[5]; + minecraftDir = (File) data[6]; + injectedContainers = (List)data[7]; + } + + private Loader() + { + modClassLoader = new ModClassLoader(getClass().getClassLoader()); + String actualMCVersion = "1.7.2"; + if (!mccversion.equals(actualMCVersion)) + { + FMLLog.severe("This version of FML is built for Minecraft %s, we have detected Minecraft %s in your minecraft jar file", mccversion, actualMCVersion); + throw new LoaderException(); + } + + minecraft = new MinecraftDummyContainer(actualMCVersion); + mcp = new MCPDummyContainer(MetadataCollection.from(getClass().getResourceAsStream("/mcpmod.info"), "MCP").getMetadataForId("mcp", null)); + } + + /** + * Sort the mods into a sorted list, using dependency information from the + * containers. The sorting is performed using a {@link TopologicalSort} + * based on the pre- and post- dependency information provided by the mods. + */ + private void sortModList() + { + FMLLog.finer("Verifying mod requirements are satisfied"); + try + { + BiMap modVersions = HashBiMap.create(); + for (ModContainer mod : getActiveModList()) + { + modVersions.put(mod.getModId(), mod.getProcessedVersion()); + } + + ArrayListMultimap reqList = ArrayListMultimap.create(); + for (ModContainer mod : getActiveModList()) + { + if (!mod.acceptableMinecraftVersionRange().containsVersion(minecraft.getProcessedVersion())) + { + FMLLog.severe("The mod %s does not wish to run in Minecraft version %s. You will have to remove it to play.", mod.getModId(), getMCVersionString()); + throw new WrongMinecraftVersionException(mod); + } + Map names = Maps.uniqueIndex(mod.getRequirements(), new ArtifactVersionNameFunction()); + Set versionMissingMods = Sets.newHashSet(); + + Set missingMods = Sets.difference(names.keySet(), modVersions.keySet()); + if (!missingMods.isEmpty()) + { + FMLLog.severe("The mod %s (%s) requires mods %s to be available", mod.getModId(), mod.getName(), missingMods); + for (String modid : missingMods) + { + versionMissingMods.add(names.get(modid)); + } + throw new MissingModsException(versionMissingMods); + } + reqList.putAll(mod.getModId(), names.keySet()); + ImmutableList allDeps = ImmutableList.builder().addAll(mod.getDependants()).addAll(mod.getDependencies()).build(); + for (ArtifactVersion v : allDeps) + { + if (modVersions.containsKey(v.getLabel())) + { + if (!v.containsVersion(modVersions.get(v.getLabel()))) + { + versionMissingMods.add(v); + } + } + } + if (!versionMissingMods.isEmpty()) + { + FMLLog.severe("The mod %s (%s) requires mod versions %s to be available", mod.getModId(), mod.getName(), versionMissingMods); + throw new MissingModsException(versionMissingMods); + } + } + + FMLLog.finer("All mod requirements are satisfied"); + + reverseDependencies = Multimaps.invertFrom(reqList, ArrayListMultimap.create()); + ModSorter sorter = new ModSorter(getActiveModList(), namedMods); + + try + { + FMLLog.finer("Sorting mods into an ordered list"); + List sortedMods = sorter.sort(); + // Reset active list to the sorted list + modController.getActiveModList().clear(); + modController.getActiveModList().addAll(sortedMods); + // And inject the sorted list into the overall list + mods.removeAll(sortedMods); + sortedMods.addAll(mods); + mods = sortedMods; + FMLLog.finer("Mod sorting completed successfully"); + } + catch (ModSortingException sortException) + { + FMLLog.severe("A dependency cycle was detected in the input mod set so an ordering cannot be determined"); + SortingExceptionData exceptionData = sortException.getExceptionData(); + FMLLog.severe("The first mod in the cycle is %s", exceptionData.getFirstBadNode()); + FMLLog.severe("The mod cycle involves"); + for (ModContainer mc : exceptionData.getVisitedNodes()) + { + FMLLog.severe("%s : before: %s, after: %s", mc.toString(), mc.getDependants(), mc.getDependencies()); + } + FMLLog.log(Level.ERROR, sortException, "The full error"); + throw sortException; + } + } + finally + { + FMLLog.fine("Mod sorting data"); + int unprintedMods = mods.size(); + for (ModContainer mod : getActiveModList()) + { + if (!mod.isImmutable()) + { + FMLLog.fine("\t%s(%s:%s): %s (%s)", mod.getModId(), mod.getName(), mod.getVersion(), mod.getSource().getName(), mod.getSortingRules()); + unprintedMods--; + } + } + if (unprintedMods == mods.size()) + { + FMLLog.fine("No user mods found to sort"); + } + } + + } + + /** + * The primary loading code + * + * + * The found resources are first loaded into the {@link #modClassLoader} + * (always) then scanned for class resources matching the specification + * above. + * + * If they provide the {@link Mod} annotation, they will be loaded as + * "FML mods" + * + * Finally, if they are successfully loaded as classes, they are then added + * to the available mod list. + */ + private ModDiscoverer identifyMods() + { + FMLLog.fine("Building injected Mod Containers %s", injectedContainers); + // Add in the MCP mod container + mods.add(new InjectedModContainer(mcp,new File("minecraft.jar"))); + for (String cont : injectedContainers) + { + ModContainer mc; + try + { + mc = (ModContainer) Class.forName(cont,true,modClassLoader).newInstance(); + } + catch (Exception e) + { + FMLLog.log(Level.ERROR, e, "A problem occured instantiating the injected mod container %s", cont); + throw new LoaderException(e); + } + mods.add(new InjectedModContainer(mc,mc.getSource())); + } + ModDiscoverer discoverer = new ModDiscoverer(); + FMLLog.fine("Attempting to load mods contained in the minecraft jar file and associated classes"); + discoverer.findClasspathMods(modClassLoader); + FMLLog.fine("Minecraft jar mods loaded successfully"); + + FMLLog.info("Searching %s for mods", canonicalModsDir.getAbsolutePath()); + discoverer.findModDirMods(canonicalModsDir); + File versionSpecificModsDir = new File(canonicalModsDir,mccversion); + if (versionSpecificModsDir.isDirectory()) + { + FMLLog.info("Also searching %s for mods", versionSpecificModsDir); + discoverer.findModDirMods(versionSpecificModsDir); + } + + mods.addAll(discoverer.identifyMods()); + identifyDuplicates(mods); + namedMods = Maps.uniqueIndex(mods, new ModIdFunction()); + FMLLog.info("Forge Mod Loader has identified %d mod%s to load", mods.size(), mods.size() != 1 ? "s" : ""); + return discoverer; + } + + private class ModIdComparator implements Comparator + { + @Override + public int compare(ModContainer o1, ModContainer o2) + { + return o1.getModId().compareTo(o2.getModId()); + } + } + + private void identifyDuplicates(List mods) + { + TreeMultimap dupsearch = TreeMultimap.create(new ModIdComparator(), Ordering.arbitrary()); + for (ModContainer mc : mods) + { + if (mc.getSource() != null) + { + dupsearch.put(mc, mc.getSource()); + } + } + + ImmutableMultiset duplist = Multisets.copyHighestCountFirst(dupsearch.keys()); + SetMultimap dupes = LinkedHashMultimap.create(); + for (Entry e : duplist.entrySet()) + { + if (e.getCount() > 1) + { + FMLLog.severe("Found a duplicate mod %s at %s", e.getElement().getModId(), dupsearch.get(e.getElement())); + dupes.putAll(e.getElement(),dupsearch.get(e.getElement())); + } + } + if (!dupes.isEmpty()) + { + throw new DuplicateModsFoundException(dupes); + } + } + + /** + * + */ + private void initializeLoader() + { + File modsDir = new File(minecraftDir, "mods"); + File configDir = new File(minecraftDir, "config"); + String canonicalModsPath; + String canonicalConfigPath; + + try + { + canonicalModsPath = modsDir.getCanonicalPath(); + canonicalConfigPath = configDir.getCanonicalPath(); + canonicalConfigDir = configDir.getCanonicalFile(); + canonicalModsDir = modsDir.getCanonicalFile(); + } + catch (IOException ioe) + { + FMLLog.log(Level.ERROR, ioe, "Failed to resolve loader directories: mods : %s ; config %s", canonicalModsDir.getAbsolutePath(), + configDir.getAbsolutePath()); + throw new LoaderException(ioe); + } + + if (!canonicalModsDir.exists()) + { + FMLLog.info("No mod directory found, creating one: %s", canonicalModsPath); + boolean dirMade = canonicalModsDir.mkdir(); + if (!dirMade) + { + FMLLog.severe("Unable to create the mod directory %s", canonicalModsPath); + throw new LoaderException(); + } + FMLLog.info("Mod directory created successfully"); + } + + if (!canonicalConfigDir.exists()) + { + FMLLog.fine("No config directory found, creating one: %s", canonicalConfigPath); + boolean dirMade = canonicalConfigDir.mkdir(); + if (!dirMade) + { + FMLLog.severe("Unable to create the config directory %s", canonicalConfigPath); + throw new LoaderException(); + } + FMLLog.info("Config directory created successfully"); + } + + if (!canonicalModsDir.isDirectory()) + { + FMLLog.severe("Attempting to load mods from %s, which is not a directory", canonicalModsPath); + throw new LoaderException(); + } + + if (!configDir.isDirectory()) + { + FMLLog.severe("Attempting to load configuration from %s, which is not a directory", canonicalConfigPath); + throw new LoaderException(); + } + } + + public List getModList() + { + return instance().mods != null ? ImmutableList.copyOf(instance().mods) : ImmutableList.of(); + } + + /** + * Called from the hook to start mod loading. We trigger the + * {@link #identifyMods()} and Constructing, Preinitalization, and Initalization phases here. Finally, + * the mod list is frozen completely and is consider immutable from then on. + */ + public void loadMods() + { + initializeLoader(); + mods = Lists.newArrayList(); + namedMods = Maps.newHashMap(); + modController = new LoadController(this); + modController.transition(LoaderState.LOADING, false); + ModDiscoverer disc = identifyMods(); + ModAPIManager.INSTANCE.manageAPI(modClassLoader, disc); + disableRequestedMods(); + modController.distributeStateMessage(FMLLoadEvent.class); + sortModList(); + ModAPIManager.INSTANCE.cleanupAPIContainers(modController.getActiveModList()); + ModAPIManager.INSTANCE.cleanupAPIContainers(mods); + mods = ImmutableList.copyOf(mods); + for (File nonMod : disc.getNonModLibs()) + { + if (nonMod.isFile()) + { + FMLLog.info("FML has found a non-mod file %s in your mods directory. It will now be injected into your classpath. This could severe stability issues, it should be removed if possible.", nonMod.getName()); + try + { + modClassLoader.addFile(nonMod); + } + catch (MalformedURLException e) + { + FMLLog.log(Level.ERROR, e, "Encountered a weird problem with non-mod file injection : %s", nonMod.getName()); + } + } + } + modController.transition(LoaderState.CONSTRUCTING, false); + modController.distributeStateMessage(LoaderState.CONSTRUCTING, modClassLoader, disc.getASMTable(), reverseDependencies); + FMLLog.fine("Mod signature data"); + for (ModContainer mod : getActiveModList()) + { + FMLLog.fine("\t%s(%s:%s): %s (%s)", mod.getModId(), mod.getName(), mod.getVersion(), mod.getSource().getName(), CertificateHelper.getFingerprint(mod.getSigningCertificate())); + } + if (getActiveModList().isEmpty()) + { + FMLLog.fine("No user mod signature data found"); + } + modController.transition(LoaderState.PREINITIALIZATION, false); + modController.distributeStateMessage(LoaderState.PREINITIALIZATION, disc.getASMTable(), canonicalConfigDir); + modController.transition(LoaderState.INITIALIZATION, false); + } + + private void disableRequestedMods() + { + String forcedModList = System.getProperty("fml.modStates", ""); + FMLLog.finer("Received a system property request \'%s\'",forcedModList); + Map sysPropertyStateList = Splitter.on(CharMatcher.anyOf(";:")) + .omitEmptyStrings().trimResults().withKeyValueSeparator("=") + .split(forcedModList); + FMLLog.finer("System property request managing the state of %d mods", sysPropertyStateList.size()); + Map modStates = Maps.newHashMap(); + + forcedModFile = new File(canonicalConfigDir, "fmlModState.properties"); + Properties forcedModListProperties = new Properties(); + if (forcedModFile.exists() && forcedModFile.isFile()) + { + FMLLog.finer("Found a mod state file %s", forcedModFile.getName()); + try + { + forcedModListProperties.load(new FileReader(forcedModFile)); + FMLLog.finer("Loaded states for %d mods from file", forcedModListProperties.size()); + } + catch (Exception e) + { + FMLLog.log(Level.INFO, e, "An error occurred reading the fmlModState.properties file"); + } + } + modStates.putAll(Maps.fromProperties(forcedModListProperties)); + modStates.putAll(sysPropertyStateList); + FMLLog.fine("After merging, found state information for %d mods", modStates.size()); + + Map isEnabled = Maps.transformValues(modStates, new Function() + { + @Override + public Boolean apply(String input) + { + return Boolean.parseBoolean(input); + } + }); + + for (Map.Entry entry : isEnabled.entrySet()) + { + if (namedMods.containsKey(entry.getKey())) + { + FMLLog.info("Setting mod %s to enabled state %b", entry.getKey(), entry.getValue()); + namedMods.get(entry.getKey()).setEnabledState(entry.getValue()); + } + } + } + + /** + * Query if we know of a mod named modname + * + * @param modname + * @return If the mod is loaded + */ + public static boolean isModLoaded(String modname) + { + return instance().namedMods.containsKey(modname) && instance().modController.getModState(instance.namedMods.get(modname))!=ModState.DISABLED; + } + + public File getConfigDir() + { + return canonicalConfigDir; + } + + public String getCrashInformation() + { + // Handle being called before we've begun setup + if (modController == null) + { + return ""; + } + StringBuilder ret = new StringBuilder(); + List branding = FMLCommonHandler.instance().getBrandings(false); + + Joiner.on(' ').skipNulls().appendTo(ret, branding); + if (modController != null) + { + modController.printModStates(ret); + } + return ret.toString(); + } + + public String getFMLVersionString() + { + return String.format("%s.%s.%s.%s", major, minor, rev, build); + } + + public ClassLoader getModClassLoader() + { + return modClassLoader; + } + + public void computeDependencies(String dependencyString, Set requirements, List dependencies, List dependants) + { + if (dependencyString == null || dependencyString.length() == 0) + { + return; + } + + boolean parseFailure = false; + + for (String dep : DEPENDENCYSPLITTER.split(dependencyString)) + { + List depparts = Lists.newArrayList(DEPENDENCYPARTSPLITTER.split(dep)); + // Need two parts to the string + if (depparts.size() != 2) + { + parseFailure = true; + continue; + } + String instruction = depparts.get(0); + String target = depparts.get(1); + boolean targetIsAll = target.startsWith("*"); + + // Cannot have an "all" relationship with anything except pure * + if (targetIsAll && target.length() > 1) + { + parseFailure = true; + continue; + } + + // If this is a required element, add it to the required list + if ("required-before".equals(instruction) || "required-after".equals(instruction)) + { + // You can't require everything + if (!targetIsAll) + { + requirements.add(VersionParser.parseVersionReference(target)); + } + else + { + parseFailure = true; + continue; + } + } + + // You cannot have a versioned dependency on everything + if (targetIsAll && target.indexOf('@') > -1) + { + parseFailure = true; + continue; + } + // before elements are things we are loaded before (so they are our dependants) + if ("required-before".equals(instruction) || "before".equals(instruction)) + { + dependants.add(VersionParser.parseVersionReference(target)); + } + // after elements are things that load before we do (so they are out dependencies) + else if ("required-after".equals(instruction) || "after".equals(instruction)) + { + dependencies.add(VersionParser.parseVersionReference(target)); + } + else + { + parseFailure = true; + } + } + + if (parseFailure) + { + FMLLog.log(Level.WARN, "Unable to parse dependency string %s", dependencyString); + throw new LoaderException(); + } + } + + public Map getIndexedModList() + { + return ImmutableMap.copyOf(namedMods); + } + + public void initializeMods() + { + // Mod controller should be in the initialization state here + modController.distributeStateMessage(LoaderState.INITIALIZATION); + modController.transition(LoaderState.POSTINITIALIZATION, false); + modController.distributeStateMessage(FMLInterModComms.IMCEvent.class); + modController.distributeStateMessage(LoaderState.POSTINITIALIZATION); + modController.transition(LoaderState.AVAILABLE, false); + modController.distributeStateMessage(LoaderState.AVAILABLE); + GameData.freezeData(); + // Dump the custom registry data map, if necessary + GameData.dumpRegistry(minecraftDir); + FMLLog.info("Forge Mod Loader has successfully loaded %d mod%s", mods.size(), mods.size() == 1 ? "" : "s"); + } + + public ICrashCallable getCallableCrashInformation() + { + return new ICrashCallable() { + @Override + public String call() throws Exception + { + return getCrashInformation(); + } + + @Override + public String getLabel() + { + return "FML"; + } + }; + } + + public List getActiveModList() + { + return modController != null ? modController.getActiveModList() : ImmutableList.of(); + } + + public ModState getModState(ModContainer selectedMod) + { + return modController.getModState(selectedMod); + } + + public String getMCVersionString() + { + return "Minecraft " + mccversion; + } + + public boolean serverStarting(Object server) + { + try + { + modController.distributeStateMessage(LoaderState.SERVER_STARTING, server); + modController.transition(LoaderState.SERVER_STARTING, false); + } + catch (Throwable t) + { + FMLLog.log(Level.ERROR, t, "A fatal exception occurred during the server starting event"); + return false; + } + return true; + } + + public void serverStarted() + { + modController.distributeStateMessage(LoaderState.SERVER_STARTED); + modController.transition(LoaderState.SERVER_STARTED, false); + } + + public void serverStopping() + { + modController.distributeStateMessage(LoaderState.SERVER_STOPPING); + modController.transition(LoaderState.SERVER_STOPPING, false); + } + + public BiMap getModObjectList() + { + return modController.getModObjectList(); + } + + public BiMap getReversedModObjectList() + { + return getModObjectList().inverse(); + } + + public ModContainer activeModContainer() + { + return modController != null ? modController.activeContainer() : null; + } + + public boolean isInState(LoaderState state) + { + return modController.isInState(state); + } + + public MinecraftDummyContainer getMinecraftModContainer() + { + return minecraft; + } + + public boolean hasReachedState(LoaderState state) + { + return modController != null ? modController.hasReachedState(state) : false; + } + + public String getMCPVersionString() + { + return String.format("MCP v%s", mcpversion); + } + + public void serverStopped() + { + GameData.revertToFrozen(); + modController.distributeStateMessage(LoaderState.SERVER_STOPPED); + modController.transition(LoaderState.SERVER_STOPPED, true); + modController.transition(LoaderState.AVAILABLE, true); + } + + public boolean serverAboutToStart(Object server) + { + try + { + modController.distributeStateMessage(LoaderState.SERVER_ABOUT_TO_START, server); + modController.transition(LoaderState.SERVER_ABOUT_TO_START, false); + } + catch (Throwable t) + { + FMLLog.log(Level.ERROR, t, "A fatal exception occurred during the server about to start event"); + return false; + } + return true; + } + + public Map getFMLBrandingProperties() + { + if (fmlBrandingProperties == null) + { + Properties loaded = new Properties(); + try + { + loaded.load(getClass().getClassLoader().getResourceAsStream("fmlbranding.properties")); + } + catch (Exception e) + { + // File not found - ignore + } + fmlBrandingProperties = Maps.fromProperties(loaded); + } + return fmlBrandingProperties; + } + + + public Map getCustomModProperties(String modId) + { + return getIndexedModList().get(modId).getCustomModProperties(); + } + + boolean checkRemoteModList(Map modList, Side side) + { + Set remoteModIds = modList.keySet(); + Set localModIds = namedMods.keySet(); + + Set difference = Sets.newLinkedHashSet(Sets.difference(localModIds, remoteModIds)); + for (Iterator iterator = difference.iterator(); iterator.hasNext();) + { + String missingRemotely = iterator.next(); + ModState modState = modController.getModState(namedMods.get(missingRemotely)); + if (modState == ModState.DISABLED) + { + iterator.remove(); + } + } + + FMLLog.info("Attempting connection with missing mods %s at %s", difference, side); + return true; + } + + /** + * Fire a FMLMissingMappingsEvent to let mods determine how blocks/items defined in the world + * save, but missing from the runtime, are to be handled. + * + * @param missing Map containing missing names with their associated id, blocks need to come before items for remapping. + * @param isLocalWorld Whether this is executing for a world load (local/server) or a client. + * @param gameData GameData instance where the new map's config is to be loaded into. + * @return List with the mapping results. + */ + public List fireMissingMappingEvent(LinkedHashMap missing, boolean isLocalWorld, GameData gameData, Map remaps) + { + if (missing.isEmpty()) // nothing to do + { + return ImmutableList.of(); + } + + FMLLog.fine("There are %d mappings missing - attempting a mod remap", missing.size()); + ArrayListMultimap missingMappings = ArrayListMultimap.create(); + + for (Map.Entry mapping : missing.entrySet()) + { + int id = mapping.getValue(); + MissingMapping m = new MissingMapping(mapping.getKey(), id); + missingMappings.put(m.name.substring(0, m.name.indexOf(':')), m); + } + + FMLMissingMappingsEvent missingEvent = new FMLMissingMappingsEvent(missingMappings); + modController.propogateStateMessage(missingEvent); + + if (isLocalWorld) // local world, warn about entries still being set to the default action + { + boolean didWarn = false; + + for (MissingMapping mapping : missingMappings.values()) + { + if (mapping.getAction() == FMLMissingMappingsEvent.Action.DEFAULT) + { + if (!didWarn) + { + FMLLog.severe("There are unidentified mappings in this world - we are going to attempt to process anyway"); + didWarn = true; + } + + FMLLog.severe("Unidentified %s: %s, id %d", mapping.type == Type.BLOCK ? "block" : "item", mapping.name, mapping.id); + } + } + } + else // remote world, fail on entries with the default action + { + List missedMapping = new ArrayList(); + + for (MissingMapping mapping : missingMappings.values()) + { + if (mapping.getAction() == FMLMissingMappingsEvent.Action.DEFAULT) + { + missedMapping.add(mapping.name); + } + } + + if (!missedMapping.isEmpty()) + { + return ImmutableList.copyOf(missedMapping); + } + } + + return GameData.processIdRematches(missingMappings.values(), isLocalWorld, gameData, remaps); + } + + public void fireRemapEvent(Map remaps) + { + if (remaps.isEmpty()) + { + FMLLog.finer("Skipping remap event - no remaps occured"); + } + else + { + modController.propogateStateMessage(new FMLModIdMappingEvent(remaps)); + } + } + + public void runtimeDisableMod(String modId) + { + ModContainer mc = namedMods.get(modId); + Disableable disableable = mc.canBeDisabled(); + if (disableable == Disableable.NEVER) + { + FMLLog.info("Cannot disable mod %s - it is never allowed to be disabled", modId); + return; + } + if (disableable == Disableable.DEPENDENCIES) + { + FMLLog.info("Cannot disable mod %s - there are dependent mods that require its presence", modId); + return; + } + if (disableable == Disableable.YES) + { + FMLLog.info("Runtime disabling mod %s", modId); + modController.disableMod(mc); + List localmods = Lists.newArrayList(mods); + localmods.remove(mc); + mods = ImmutableList.copyOf(localmods); + } + + try + { + Properties props = new Properties(); + props.load(new FileReader(forcedModFile)); + props.put(modId, "false"); + props.store(new FileWriter(forcedModFile), null); + } + catch (Exception e) + { + FMLLog.log(Level.INFO, e, "An error occurred writing the fml mod states file, your disabled change won't persist"); + } + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/LoaderException.java b/src/main/java/cpw/mods/fml/common/LoaderException.java new file mode 100644 index 0000000..cfe8de1 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/LoaderException.java @@ -0,0 +1,30 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common; + +public class LoaderException extends RuntimeException +{ + /** + * + */ + private static final long serialVersionUID = -5675297950958861378L; + + public LoaderException(Throwable wrapped) + { + super(wrapped); + } + + public LoaderException() + { + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/LoaderState.java b/src/main/java/cpw/mods/fml/common/LoaderState.java new file mode 100644 index 0000000..180d1ec --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/LoaderState.java @@ -0,0 +1,121 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common; + +import com.google.common.base.Throwables; + +import cpw.mods.fml.common.event.FMLConstructionEvent; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLLoadCompleteEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.event.FMLServerAboutToStartEvent; +import cpw.mods.fml.common.event.FMLServerStartedEvent; +import cpw.mods.fml.common.event.FMLServerStartingEvent; +import cpw.mods.fml.common.event.FMLServerStoppedEvent; +import cpw.mods.fml.common.event.FMLServerStoppingEvent; +import cpw.mods.fml.common.event.FMLStateEvent; + +/** + * The state enum used to help track state progression for the loader + * @author cpw + * + */ +public enum LoaderState +{ + NOINIT("Uninitialized",null), + LOADING("Loading",null), + CONSTRUCTING("Constructing mods",FMLConstructionEvent.class), + PREINITIALIZATION("Pre-initializing mods", FMLPreInitializationEvent.class), + INITIALIZATION("Initializing mods", FMLInitializationEvent.class), + POSTINITIALIZATION("Post-initializing mods", FMLPostInitializationEvent.class), + AVAILABLE("Mod loading complete", FMLLoadCompleteEvent.class), + SERVER_ABOUT_TO_START("Server about to start", FMLServerAboutToStartEvent.class), + SERVER_STARTING("Server starting", FMLServerStartingEvent.class), + SERVER_STARTED("Server started", FMLServerStartedEvent.class), + SERVER_STOPPING("Server stopping", FMLServerStoppingEvent.class), + SERVER_STOPPED("Server stopped", FMLServerStoppedEvent.class), + ERRORED("Mod Loading errored",null); + + + private Class eventClass; + @SuppressWarnings("unused") + private String name; + + private LoaderState(String name, Class event) + { + this.name = name; + this.eventClass = event; + } + + public LoaderState transition(boolean errored) + { + if (errored) + { + return ERRORED; + } + // stopping -> available + if (this == SERVER_STOPPED) + { + return AVAILABLE; + } + return values()[ordinal() < values().length ? ordinal()+1 : ordinal()]; + } + + public boolean hasEvent() + { + return eventClass != null; + } + + public FMLStateEvent getEvent(Object... eventData) + { + try + { + return eventClass.getConstructor(Object[].class).newInstance((Object)eventData); + } + catch (Exception e) + { + throw Throwables.propagate(e); + } + } + public LoaderState requiredState() + { + if (this == NOINIT) return NOINIT; + return LoaderState.values()[this.ordinal()-1]; + } + public enum ModState + { + UNLOADED("Unloaded"), + LOADED("Loaded"), + CONSTRUCTED("Constructed"), + PREINITIALIZED("Pre-initialized"), + INITIALIZED("Initialized"), + POSTINITIALIZED("Post-initialized"), + AVAILABLE("Available"), + DISABLED("Disabled"), + ERRORED("Errored"); + + private String label; + + private ModState(String label) + { + this.label = label; + } + + @Override + public String toString() + { + return this.label; + } + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/MCPDummyContainer.java b/src/main/java/cpw/mods/fml/common/MCPDummyContainer.java new file mode 100644 index 0000000..81373f0 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/MCPDummyContainer.java @@ -0,0 +1,32 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common; + +import com.google.common.eventbus.EventBus; + +public class MCPDummyContainer extends DummyModContainer { + public MCPDummyContainer(ModMetadata metadata) { + super(metadata); + } + + @Override + public boolean registerBus(EventBus bus, LoadController controller) { + return true; + } + + @Override + public Disableable canBeDisabled() + { + return Disableable.YES; + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/MetadataCollection.java b/src/main/java/cpw/mods/fml/common/MetadataCollection.java new file mode 100644 index 0000000..9572573 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/MetadataCollection.java @@ -0,0 +1,124 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.Map; +import org.apache.logging.log4j.Level; + +import com.google.common.base.Throwables; +import com.google.common.collect.Maps; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonParseException; +import com.google.gson.JsonParser; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import cpw.mods.fml.common.versioning.ArtifactVersion; +import cpw.mods.fml.common.versioning.VersionParser; + +public class MetadataCollection +{ + @SuppressWarnings("unused") + private String modListVersion; + private ModMetadata[] modList; + private Map metadatas = Maps.newHashMap(); + + public static MetadataCollection from(InputStream inputStream, String sourceName) + { + if (inputStream == null) + { + return new MetadataCollection(); + } + + InputStreamReader reader = new InputStreamReader(inputStream); + try + { + MetadataCollection collection; + Gson gson = new GsonBuilder().registerTypeAdapter(ArtifactVersion.class, new ArtifactVersionAdapter()).create(); + JsonParser parser = new JsonParser(); + JsonElement rootElement = parser.parse(reader); + if (rootElement.isJsonArray()) + { + collection = new MetadataCollection(); + JsonArray jsonList = rootElement.getAsJsonArray(); + collection.modList = new ModMetadata[jsonList.size()]; + int i = 0; + for (JsonElement mod : jsonList) + { + collection.modList[i++]=gson.fromJson(mod, ModMetadata.class); + } + } + else + { + collection = gson.fromJson(rootElement, MetadataCollection.class); + } + collection.parseModMetadataList(); + return collection; + } + catch (JsonParseException e) + { + FMLLog.log(Level.ERROR, e, "The mcmod.info file in %s cannot be parsed as valid JSON. It will be ignored", sourceName); + return new MetadataCollection(); + } + catch (Exception e) + { + throw Throwables.propagate(e); + } + } + + + private void parseModMetadataList() + { + for (ModMetadata modMetadata : modList) + { + metadatas.put(modMetadata.modId, modMetadata); + } + } + + public ModMetadata getMetadataForId(String modId, Map extraData) + { + if (!metadatas.containsKey(modId)) + { + ModMetadata dummy = new ModMetadata(); + dummy.modId = modId; + dummy.name = (String) extraData.get("name"); + dummy.version = (String) extraData.get("version"); + dummy.autogenerated = true; + metadatas.put(modId, dummy); + } + return metadatas.get(modId); + } + + public static class ArtifactVersionAdapter extends TypeAdapter + { + + @Override + public void write(JsonWriter out, ArtifactVersion value) throws IOException + { + // no op - we never write these out + } + + @Override + public ArtifactVersion read(JsonReader in) throws IOException + { + return VersionParser.parseVersionReference(in.nextString()); + } + + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/MinecraftDummyContainer.java b/src/main/java/cpw/mods/fml/common/MinecraftDummyContainer.java new file mode 100644 index 0000000..fd9d9f8 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/MinecraftDummyContainer.java @@ -0,0 +1,36 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common; + +import cpw.mods.fml.common.versioning.VersionParser; +import cpw.mods.fml.common.versioning.VersionRange; + +public class MinecraftDummyContainer extends DummyModContainer +{ + + private VersionRange staticRange; + public MinecraftDummyContainer(String actualMCVersion) + { + super(new ModMetadata()); + getMetadata().modId = "Minecraft"; + getMetadata().name = "Minecraft"; + getMetadata().version = actualMCVersion; + staticRange = VersionParser.parseRange("["+actualMCVersion+"]"); + } + + + public VersionRange getStaticVersionRange() + { + return staticRange; + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/MissingModsException.java b/src/main/java/cpw/mods/fml/common/MissingModsException.java new file mode 100644 index 0000000..3ef8720 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/MissingModsException.java @@ -0,0 +1,28 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common; + +import java.util.Set; + +import cpw.mods.fml.common.versioning.ArtifactVersion; + +public class MissingModsException extends RuntimeException +{ + private static final long serialVersionUID = 1L; + public final Set missingMods; + + public MissingModsException(Set missingMods) + { + this.missingMods = missingMods; + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/Mod.java b/src/main/java/cpw/mods/fml/common/Mod.java new file mode 100644 index 0000000..8a7357b --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/Mod.java @@ -0,0 +1,283 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import cpw.mods.fml.client.IModGuiFactory; +import cpw.mods.fml.common.event.FMLEvent; +import cpw.mods.fml.common.event.FMLFingerprintViolationEvent; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLInterModComms; +import cpw.mods.fml.common.event.FMLInterModComms.IMCEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.event.FMLServerAboutToStartEvent; +import cpw.mods.fml.common.event.FMLServerStartedEvent; +import cpw.mods.fml.common.event.FMLServerStartingEvent; +import cpw.mods.fml.common.event.FMLServerStoppedEvent; +import cpw.mods.fml.common.event.FMLServerStoppingEvent; +import cpw.mods.fml.common.network.NetworkCheckHandler; +import cpw.mods.fml.common.registry.GameRegistry; + +/** + * This defines a Mod to FML. + * Any class found with this annotation applied will be loaded as a Mod. The instance that is loaded will + * represent the mod to other Mods in the system. It will be sent various subclasses of {@link FMLEvent} + * at pre-defined times during the loading of the game, based on where you have applied the {@link EventHandler} + * annotation. + * + *

This is a simple example of a Mod. It has the modId of "MyModId", the name of "My example mod", it is + * version 1.0, and depends on FML being loaded. + *

{@code
+ * package mymod;
+ * // Declare that this is a mod with modId "MyModId", name "My example mod", version "1.0" and dependency on FML.
+ * {@literal @}Mod(modId="MyModId",name="My example mod",version="1.0",dependencies="required-after:FML")
+ * public class MyMod {
+ *		// Populate this field with the instance of the mod created by FML
+ *		{@literal @}Instance("MyModId")
+ *		public MyMod instance;
+ *
+ *		// Mark this method for receiving an {@link FMLEvent} (in this case, it's the {@link FMLPreInitializationEvent})
+ *		{@literal @}EventHandler public void preInit(FMLPreInitializationEvent event)
+ *		{
+ *			// Do stuff in pre-init phase (read config, create blocks and items, register them)
+ *		}
+ * }
+ * }
+ * 
+ * + * @author cpw + * + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +public @interface Mod +{ + /** + * The unique mod identifier for this mod + */ + String modid(); + /** + * A user friendly name for the mod + */ + String name() default ""; + /** + * A version string for this mod + */ + String version() default ""; + /** + * A simple dependency string for this mod (see modloader's "priorities" string specification) + */ + String dependencies() default ""; + /** + * Whether to use the mcmod.info metadata by default for this mod. + * If true, settings in the mcmod.info file will override settings in these annotations. + */ + boolean useMetadata() default false; + + /** + * The acceptable range of minecraft versions that this mod will load and run in + * The default ("empty string") indicates that only the current minecraft version is acceptable. + * FML will refuse to run with an error if the minecraft version is not in this range across all mods. + * @return A version range as specified by the maven version range specification or the empty string + */ + String acceptedMinecraftVersions() default ""; + /** + * A replacement for the no-longer-existing "versionRange" of NetworkMod. Specify a remote version range + * that this mod will accept as valid. Defaults to nothing, which is interpreted as "only this version". + * Another special value is '*' which means accept all versions. + * + * This is ignored if there is a {@link NetworkCheckHandler} annotation on a method in this class. + * + * @return A version range as specified by the maven version range specification or the empty string + */ + String acceptableRemoteVersions() default ""; + + /** + * A version range specifying compatible save version information. If your mod follows good version numbering + * practice Like this (http://semver.org/) then this should be sufficient. + * + * Advanced users can specify a {@link SaveInspectionHandler} instead. + * @return A version range as specified by the maven version range specification or the empty string + */ + String acceptableSaveVersions() default ""; + /** + * An optional bukkit plugin that will be injected into the bukkit plugin framework if + * this mod is loaded into the FML framework and the bukkit coremod is present. + * Instances of the bukkit plugin can be obtained via the {@link BukkitPluginRef} annotation on fields. + * + * This may be implemented by a bukkit integration. It is not provided with vanilla FML or MinecraftForge. + * + * @return The name of the plugin to load for this mod + */ + String bukkitPlugin() default ""; + /** + * Specifying this field allows for a mod to expect a signed jar with a fingerprint matching this value. + * The fingerprint should be SHA-1 encoded, lowercase with ':' removed. An empty value indicates that + * the mod is not expecting to be signed. + * + * Any incorrectness of the fingerprint, be it missing or wrong, will result in the {@link FMLFingerprintViolationEvent} + * event firing prior to any other event on the mod. + * + * @return A certificate fingerprint that is expected for this mod. + */ + String certificateFingerprint() default ""; + + /** + * The language the mod is authored in. This will be used to control certain compatibility behaviours for this mod. + * Valid values are currently "java", "scala" + * + * @return The language the mod is authored in + */ + String modLanguage() default "java"; + /** + * NOT YET IMPLEMENTED.
+ * An optional ASM hook class, that can be used to apply ASM to classes loaded from this mod. It is also given + * the ASM tree of the class declaring {@link Mod} to do with what it will. + * + * @return The name of a class to be loaded and executed. Must implement {@link IASMHook}. + */ + @Deprecated + String asmHookClass() default ""; + + /** + * If your mod doesn't have a runtime persistent effect on the state of the game, and can be disabled without side effects + * (minimap mods, graphical tweak mods) then you can set true here and receive the FMLDeactivationEvent to perform deactivation + * tasks. + * This does not affect administrative disabling through the system property fml.modStates or the config file fmlModState.properties. + * The mod will only be deactivated outside of a running game world - FML will never allow mod deactivation whilst a game server + * is running. + * + * @return if this mod can be deactivated whilst the game is open. + */ + boolean canBeDeactivated() default false; + + /** + * An optional GUI factory for this mod. This is the name of a class implementing {@link IModGuiFactory} that will be instantiated + * on the client side, and will have certain configuration/options guis requested from it. + * + * @return The name of a class implementing {@link IModGuiFactory} + */ + String guiFactory() default ""; + /** + * A list of custom properties for this mod. Completely up to the mod author if/when they + * want to put anything in here. + * @return an optional list of custom properties + */ + CustomProperty[] customProperties() default {}; + + /** + * A custom key => value property pair for use with {@link Mod#customProperties()} + * @author cpw + * + */ + @Retention(RetentionPolicy.RUNTIME) + @Target({}) + public @interface CustomProperty + { + /** + * A key. Should be unique. + * @return A key + */ + String k(); + /** + * A value. Can be anything. + * @return A value + */ + String v(); + } + /** + * Marks the associated method as handling an FML lifecycle event. + * The method must have a single parameter, one of the following types. This annotation + * replaces the multiple different annotations that previously were used. + * + * Current event classes. This first section is standard lifecycle events. They are dispatched + * at various phases as the game starts. Each event should have information useful to that + * phase of the lifecycle. They are fired in this order. + * + * These suggestions are mostly just suggestions on what to do in each event. + *
    + *
  • {@link FMLPreInitializationEvent} : Run before anything else. Read your config, create blocks, + * items, etc, and register them with the {@link GameRegistry}.
  • + *
  • {@link FMLInitializationEvent} : Do your mod setup. Build whatever data structures you care about. Register recipes, + * send {@link FMLInterModComms} messages to other mods.
  • + *
  • {@link FMLPostInitializationEvent} : Handle interaction with other mods, complete your setup based on this.
  • + *
+ *

These are the server lifecycle events. They are fired whenever a server is running, or about to run. Each time a server + * starts they will be fired in this sequence. + *

    + *
  • {@link FMLServerAboutToStartEvent} : Use if you need to handle something before the server has even been created.
  • + *
  • {@link FMLServerStartingEvent} : Do stuff you need to do to set up the server. register commands, tweak the server.
  • + *
  • {@link FMLServerStartedEvent} : Do what you need to with the running server.
  • + *
  • {@link FMLServerStoppingEvent} : Do what you need to before the server has started it's shutdown sequence.
  • + *
  • {@link FMLServerStoppedEvent} : Do whatever cleanup you need once the server has shutdown. Generally only useful + * on the integrated server.
  • + *
+ * The second set of events are more specialized, for receiving notification of specific + * information. + *
    + *
  • {@link FMLFingerprintViolationEvent} : Sent just before {@link FMLPreInitializationEvent} + * if something is wrong with your mod signature
  • + *
  • {@link IMCEvent} : Sent just after {@link FMLInitializationEvent} if you have IMC messages waiting + * from other mods
  • + *
+ * + * @author cpw + * + */ + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.METHOD) + public @interface EventHandler{} + + /** + * Populate the annotated field with the mod instance based on the specified ModId. This can be used + * to retrieve instances of other mods. + * @author cpw + * + */ + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.FIELD) + public @interface Instance { + /** + * The mod object to inject into this field + */ + String value() default ""; + } + /** + * Populate the annotated field with the mod's metadata. + * @author cpw + * + */ + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.FIELD) + public @interface Metadata { + /** + * The mod id specifying the metadata to load here + */ + String value() default ""; + } + + /** + * Mod instance factory method. Should return an instance of the mod. Applies only to static methods on the same class as {@link Mod}. + * @author cpw + * + */ + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.METHOD) + public @interface InstanceFactory { + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/ModAPIManager.java b/src/main/java/cpw/mods/fml/common/ModAPIManager.java new file mode 100644 index 0000000..045d3f0 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/ModAPIManager.java @@ -0,0 +1,216 @@ +package cpw.mods.fml.common; + +import java.io.File; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; + +import cpw.mods.fml.common.asm.transformers.ModAPITransformer; +import cpw.mods.fml.common.discovery.ASMDataTable; +import cpw.mods.fml.common.discovery.ASMDataTable.ASMData; +import cpw.mods.fml.common.discovery.ModCandidate; +import cpw.mods.fml.common.discovery.ModDiscoverer; +import cpw.mods.fml.common.functions.ModIdFunction; +import cpw.mods.fml.common.versioning.ArtifactVersion; +import cpw.mods.fml.common.versioning.DefaultArtifactVersion; +import cpw.mods.fml.common.versioning.VersionParser; + +public class ModAPIManager { + public static final ModAPIManager INSTANCE = new ModAPIManager(); + @SuppressWarnings("unused") + private ModAPITransformer transformer; + private ASMDataTable dataTable; + private Map apiContainers; + + private static class APIContainer extends DummyModContainer { + private List referredMods; + private ArtifactVersion ownerMod; + private ArtifactVersion ourVersion; + private String providedAPI; + private File source; + private String version; + private Set currentReferents; + private Set packages; + + public APIContainer(String providedAPI, String apiVersion, File source, ArtifactVersion ownerMod) + { + this.providedAPI = providedAPI; + this.version = apiVersion; + this.ownerMod = ownerMod; + this.ourVersion = new DefaultArtifactVersion(providedAPI, apiVersion); + this.referredMods = Lists.newArrayList(); + this.source = source; + this.currentReferents = Sets.newHashSet(); + this.packages = Sets.newHashSet(); + } + + @Override + public File getSource() + { + return source; + } + @Override + public String getVersion() + { + return version; + } + @Override + public String getName() + { + return "API: "+providedAPI; + } + @Override + public String getModId() + { + return "API:"+providedAPI; + } + @Override + public List getDependants() + { + return referredMods; + } + + @Override + public List getDependencies() + { + return ImmutableList.of(ownerMod); + } + + @Override + public ArtifactVersion getProcessedVersion() + { + return ourVersion; + } + + public void validate(String providedAPI, String apiOwner, String apiVersion) + { + // TODO Compare this annotation data to the one we first found. Maybe barf if there is inconsistency? + } + + @Override + public String toString() + { + return "APIContainer{"+providedAPI+":"+version+"}"; + } + + public void addAPIReference(String embedded) + { + if (currentReferents.add(embedded)) + { + referredMods.add(VersionParser.parseVersionReference(embedded)); + } + } + + public void addOwnedPackage(String apiPackage) + { + packages.add(apiPackage); + } + + public void addAPIReferences(List candidateIds) + { + for (String modId : candidateIds) + { + addAPIReference(modId); + } + } + } + public void registerDataTableAndParseAPI(ASMDataTable dataTable) + { + this.dataTable = dataTable; + + Set apiList = dataTable.getAll("cpw.mods.fml.common.API"); + + apiContainers = Maps.newHashMap(); + + for (ASMData data : apiList) + { + Map annotationInfo = data.getAnnotationInfo(); + String apiPackage = data.getClassName().substring(0,data.getClassName().indexOf(".package-info")); + String providedAPI = (String) annotationInfo.get("provides"); + String apiOwner = (String) annotationInfo.get("owner"); + String apiVersion = (String) annotationInfo.get("apiVersion"); + APIContainer container = apiContainers.get(providedAPI); + if (container == null) + { + container = new APIContainer(providedAPI, apiVersion, data.getCandidate().getModContainer(), VersionParser.parseVersionReference(apiOwner)); + apiContainers.put(providedAPI, container); + } + else + { + container.validate(providedAPI, apiOwner, apiVersion); + } + container.addOwnedPackage(apiPackage); + for (ModContainer mc : data.getCandidate().getContainedMods()) + { + String embeddedIn = mc.getModId(); + if (container.currentReferents.contains(embeddedIn)) + { + continue; + } + FMLLog.fine("Found API %s (owned by %s providing %s) embedded in %s",apiPackage, apiOwner, providedAPI, embeddedIn); + if (!embeddedIn.equals(apiOwner)) + { + container.addAPIReference(embeddedIn); + } + } + } + + for (APIContainer container : apiContainers.values()) + { + for (String pkg : container.packages) + { + Set candidates = dataTable.getCandidatesFor(pkg); + for (ModCandidate candidate : candidates) + { + List candidateIds = Lists.transform(candidate.getContainedMods(), new ModIdFunction()); + if (!candidateIds.contains(container.ownerMod.getLabel()) && !container.currentReferents.containsAll(candidateIds)) + { + FMLLog.info("Found mod(s) %s containing declared API package %s (owned by %s) without associated API reference",candidateIds, pkg, container.ownerMod); + container.addAPIReferences(candidateIds); + } + } + } + if (apiContainers.containsKey(container.ownerMod.getLabel())) + { + ArtifactVersion owner = container.ownerMod; + do + { + APIContainer parent = apiContainers.get(owner.getLabel()); + FMLLog.finer("Removing upstream parent %s from %s", parent.ownerMod.getLabel(), container); + container.currentReferents.remove(parent.ownerMod.getLabel()); + container.referredMods.remove(parent.ownerMod); + owner = parent.ownerMod; + } + while (apiContainers.containsKey(owner.getLabel())); + } + FMLLog.fine("Creating API container dummy for API %s: owner: %s, dependents: %s", container.providedAPI, container.ownerMod, container.referredMods); + } + } + + public void manageAPI(ModClassLoader modClassLoader, ModDiscoverer discoverer) + { + registerDataTableAndParseAPI(discoverer.getASMTable()); + transformer = modClassLoader.addModAPITransformer(dataTable); + } + + public void injectAPIModContainers(List mods, Map nameLookup) + { + mods.addAll(apiContainers.values()); + nameLookup.putAll(apiContainers); + } + + public void cleanupAPIContainers(List mods) + { + mods.removeAll(apiContainers.values()); + } + + public boolean hasAPI(String modId) + { + return apiContainers.containsKey(modId); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/ModClassLoader.java b/src/main/java/cpw/mods/fml/common/ModClassLoader.java new file mode 100644 index 0000000..504bc0d --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/ModClassLoader.java @@ -0,0 +1,97 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common; + +import java.io.File; +import java.net.MalformedURLException; +import java.net.URISyntaxException; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.List; +import java.util.Set; +import org.apache.logging.log4j.Level; + +import net.minecraft.launchwrapper.IClassTransformer; +import net.minecraft.launchwrapper.LaunchClassLoader; + +import com.google.common.collect.ImmutableList; + +import cpw.mods.fml.common.asm.transformers.ModAPITransformer; +import cpw.mods.fml.common.discovery.ASMDataTable; + +/** + * A simple delegating class loader used to load mods into the system + * + * + * @author cpw + * + */ +public class ModClassLoader extends URLClassLoader +{ + private static final List STANDARD_LIBRARIES = ImmutableList.of("jinput.jar", "lwjgl.jar", "lwjgl_util.jar"); + private LaunchClassLoader mainClassLoader; + + public ModClassLoader(ClassLoader parent) { + super(new URL[0], null); + this.mainClassLoader = (LaunchClassLoader)parent; + } + + public void addFile(File modFile) throws MalformedURLException + { + URL url = modFile.toURI().toURL(); + mainClassLoader.addURL(url); + } + + @Override + public Class loadClass(String name) throws ClassNotFoundException + { + return mainClassLoader.loadClass(name); + } + + public File[] getParentSources() { + List urls=mainClassLoader.getSources(); + File[] sources=new File[urls.size()]; + try + { + for (int i = 0; i getDefaultLibraries() + { + return STANDARD_LIBRARIES; + } + + public void clearNegativeCacheFor(Set classList) + { + mainClassLoader.clearNegativeEntries(classList); + } + + public ModAPITransformer addModAPITransformer(ASMDataTable dataTable) + { + mainClassLoader.registerTransformer("cpw.mods.fml.common.asm.transformers.ModAPITransformer"); + List transformers = mainClassLoader.getTransformers(); + ModAPITransformer modAPI = (ModAPITransformer) transformers.get(transformers.size()-1); + modAPI.initTable(dataTable); + return modAPI; + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/ModContainer.java b/src/main/java/cpw/mods/fml/common/ModContainer.java new file mode 100644 index 0000000..b4076f2 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/ModContainer.java @@ -0,0 +1,150 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common; + +import java.io.File; +import java.security.cert.Certificate; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.google.common.collect.ImmutableMap; +import com.google.common.eventbus.EventBus; + +import cpw.mods.fml.common.versioning.ArtifactVersion; +import cpw.mods.fml.common.versioning.VersionRange; + +/** + * The container that wraps around mods in the system. + *

+ * The philosophy is that individual mod implementation technologies should not + * impact the actual loading and management of mod code. This interface provides + * a mechanism by which we can wrap actual mod code so that the loader and other + * facilities can treat mods at arms length. + *

+ * + * @author cpw + * + */ + +public interface ModContainer +{ + public static enum Disableable { + YES, RESTART, NEVER, DEPENDENCIES; + } + /** + * The globally unique modid for this mod + */ + String getModId(); + + /** + * A human readable name + */ + + String getName(); + + /** + * A human readable version identifier + */ + String getVersion(); + + /** + * The location on the file system which this mod came from + */ + File getSource(); + + /** + * The metadata for this mod + */ + ModMetadata getMetadata(); + + /** + * Attach this mod to it's metadata from the supplied metadata collection + */ + void bindMetadata(MetadataCollection mc); + + /** + * Set the enabled/disabled state of this mod + */ + void setEnabledState(boolean enabled); + + /** + * A list of the modids that this mod requires loaded prior to loading + */ + Set getRequirements(); + + /** + * A list of modids that should be loaded prior to this one. The special + * value * indicates to load after any other mod. + */ + List getDependencies(); + + /** + * A list of modids that should be loaded after this one. The + * special value * indicates to load before any + * other mod. + */ + List getDependants(); + + /** + * A representative string encapsulating the sorting preferences for this + * mod + */ + String getSortingRules(); + + /** + * Register the event bus for the mod and the controller for error handling + * Returns if this bus was successfully registered - disabled mods and other + * mods that don't need real events should return false and avoid further + * processing + * + * @param bus + * @param controller + */ + boolean registerBus(EventBus bus, LoadController controller); + + /** + * Does this mod match the supplied mod + * + * @param mod + */ + boolean matches(Object mod); + + /** + * Get the actual mod object + */ + Object getMod(); + + ArtifactVersion getProcessedVersion(); + + boolean isImmutable(); + + String getDisplayVersion(); + + VersionRange acceptableMinecraftVersionRange(); + + Certificate getSigningCertificate(); + + public static final Map EMPTY_PROPERTIES = ImmutableMap.of(); + Map getCustomModProperties(); + + public Class getCustomResourcePackClass(); + + Map getSharedModDescriptor(); + + Disableable canBeDisabled(); + + String getGuiClassName(); + + List getOwnedPackages(); +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/ModContainerFactory.java b/src/main/java/cpw/mods/fml/common/ModContainerFactory.java new file mode 100644 index 0000000..0d724e0 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/ModContainerFactory.java @@ -0,0 +1,69 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common; + +import java.io.File; +import java.util.regex.Pattern; + +import org.objectweb.asm.Type; + +import cpw.mods.fml.common.discovery.ModCandidate; +import cpw.mods.fml.common.discovery.asm.ASMModParser; +import cpw.mods.fml.common.discovery.asm.ModAnnotation; + +public class ModContainerFactory +{ + private static Pattern modClass = Pattern.compile(".*(\\.|)(mod\\_[^\\s$]+)$"); + private static ModContainerFactory INSTANCE = new ModContainerFactory(); + public static ModContainerFactory instance() { + return INSTANCE; + } + public ModContainer build(ASMModParser modParser, File modSource, ModCandidate container) + { + String className = modParser.getASMType().getClassName(); + if (modParser.isBaseMod(container.getRememberedBaseMods()) && modClass.matcher(className).find()) + { + FMLLog.severe("Found a BaseMod type mod %s", className); + FMLLog.severe("This will not be loaded and will be ignored. ModLoader mechanisms are no longer available."); + } + else if (modClass.matcher(className).find()) + { + FMLLog.fine("Identified a class %s following modloader naming convention but not directly a BaseMod or currently seen subclass", className); + container.rememberModCandidateType(modParser); + } + else if (modParser.isBaseMod(container.getRememberedBaseMods())) + { + FMLLog.fine("Found a basemod %s of non-standard naming format", className); + container.rememberBaseModType(className); + } + + // We warn if it's not a basemod instance -- compatibility requires it to be in net.minecraft.src *sigh* + if (className.startsWith("net.minecraft.src.") && container.isClasspath() && !container.isMinecraftJar()) + { + FMLLog.severe("FML has detected a mod that is using a package name based on 'net.minecraft.src' : %s. This is generally a severe programming error. " + + " There should be no mod code in the minecraft namespace. MOVE YOUR MOD! If you're in eclipse, select your source code and 'refactor' it into " + + "a new package. Go on. DO IT NOW!",className); + } + + for (ModAnnotation ann : modParser.getAnnotations()) + { + if (ann.getASMType().equals(Type.getType(Mod.class))) + { + FMLLog.fine("Identified an FMLMod type mod %s", className); + return new FMLModContainer(className, container, ann.getValues()); + } + } + + return null; + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/ModMetadata.java b/src/main/java/cpw/mods/fml/common/ModMetadata.java new file mode 100644 index 0000000..d40d652 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/ModMetadata.java @@ -0,0 +1,81 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common; + +import java.util.List; +import java.util.Set; + +import com.google.common.base.Joiner; +import com.google.common.collect.Lists; +import com.google.gson.annotations.SerializedName; + +import cpw.mods.fml.common.functions.ModNameFunction; +import cpw.mods.fml.common.versioning.ArtifactVersion; + +/** + * @author cpw + * + */ +public class ModMetadata +{ + @SerializedName("modid") + public String modId; + public String name; + public String description = ""; + + public String url = ""; + public String updateUrl = ""; + + public String logoFile = ""; + public String version = ""; + public List authorList = Lists.newArrayList(); + public String credits = ""; + public String parent = ""; + public String[] screenshots; + + // this field is not for use in the json + public transient ModContainer parentMod; + // this field is not for use in the json + public transient List childMods = Lists.newArrayList(); + + public boolean useDependencyInformation; + public Set requiredMods; + public List dependencies; + public List dependants; + // this field is not for use in the json + public transient boolean autogenerated; + + public ModMetadata() + { + } + + public String getChildModCountString() + { + return String.format("%d child mod%s", childMods.size(), childMods.size() != 1 ? "s" : ""); + } + + public String getAuthorList() + { + return Joiner.on(", ").join(authorList); + } + + public String getChildModList() + { + return Joiner.on(", ").join(Lists.transform(childMods, new ModNameFunction())); + } + + public String printableSortingRules() + { + return ""; + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/ObfuscationReflectionHelper.java b/src/main/java/cpw/mods/fml/common/ObfuscationReflectionHelper.java new file mode 100644 index 0000000..e29b3b8 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/ObfuscationReflectionHelper.java @@ -0,0 +1,104 @@ +/* + * The FML Forge Mod Loader suite. Copyright (C) 2012 cpw + * + * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation; either version 2.1 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +package cpw.mods.fml.common; + +import java.util.Arrays; +import org.apache.logging.log4j.Level; + +import cpw.mods.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper; +import cpw.mods.fml.relauncher.ReflectionHelper; +import cpw.mods.fml.relauncher.ReflectionHelper.UnableToAccessFieldException; +import cpw.mods.fml.relauncher.ReflectionHelper.UnableToFindFieldException; + +/** + * Some reflection helper code. + * + * @author cpw + * + */ +public class ObfuscationReflectionHelper +{ + public static T getPrivateValue(Class classToAccess, E instance, int fieldIndex) + { + try + { + return ReflectionHelper.getPrivateValue(classToAccess, instance, fieldIndex); + } + catch (UnableToAccessFieldException e) + { + FMLLog.log(Level.ERROR, e, "There was a problem getting field index %d from %s", fieldIndex, classToAccess.getName()); + throw e; + } + } + + public static String[] remapFieldNames(String className, String... fieldNames) + { + String internalClassName = FMLDeobfuscatingRemapper.INSTANCE.unmap(className.replace('.', '/')); + String[] mappedNames = new String[fieldNames.length]; + int i = 0; + for (String fName : fieldNames) + { + mappedNames[i++] = FMLDeobfuscatingRemapper.INSTANCE.mapFieldName(internalClassName, fName, null); + } + return mappedNames; + } + + public static T getPrivateValue(Class classToAccess, E instance, String... fieldNames) + { + try + { + return ReflectionHelper.getPrivateValue(classToAccess, instance, remapFieldNames(classToAccess.getName(),fieldNames)); + } + catch (UnableToFindFieldException e) + { + FMLLog.log(Level.ERROR,e,"Unable to locate any field %s on type %s", Arrays.toString(fieldNames), classToAccess.getName()); + throw e; + } + catch (UnableToAccessFieldException e) + { + FMLLog.log(Level.ERROR, e, "Unable to access any field %s on type %s", Arrays.toString(fieldNames), classToAccess.getName()); + throw e; + } + } + + public static void setPrivateValue(Class classToAccess, T instance, E value, int fieldIndex) + { + try + { + ReflectionHelper.setPrivateValue(classToAccess, instance, value, fieldIndex); + } + catch (UnableToAccessFieldException e) + { + FMLLog.log(Level.ERROR, e, "There was a problem setting field index %d on type %s", fieldIndex, classToAccess.getName()); + throw e; + } + } + + public static void setPrivateValue(Class classToAccess, T instance, E value, String... fieldNames) + { + try + { + ReflectionHelper.setPrivateValue(classToAccess, instance, value, remapFieldNames(classToAccess.getName(), fieldNames)); + } + catch (UnableToFindFieldException e) + { + FMLLog.log(Level.ERROR, e, "Unable to locate any field %s on type %s", Arrays.toString(fieldNames), classToAccess.getName()); + throw e; + } + catch (UnableToAccessFieldException e) + { + FMLLog.log(Level.ERROR, e, "Unable to set any field %s on type %s", Arrays.toString(fieldNames), classToAccess.getName()); + throw e; + } + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/Optional.java b/src/main/java/cpw/mods/fml/common/Optional.java new file mode 100644 index 0000000..e657125 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/Optional.java @@ -0,0 +1,76 @@ +package cpw.mods.fml.common; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Classes annotated with this will have the named interface or method removed from the runtime definition of the class + * if the modid specified is missing. + * + * @author cpw + * + */ +public final class Optional { + /** + * Not constructable + */ + private Optional() {} + + /** + * Mark a list of interfaces as removable + * @author cpw + * + */ + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + public @interface InterfaceList { + /** + * Mark a list of interfaces for optional removal. + * @return + */ + public Interface[] value(); + } + /** + * Used to remove optional interfaces + * @author cpw + * + */ + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + public @interface Interface { + /** + * The fully qualified name of the interface to be stripped + * @return the interface name + */ + public String iface(); + + /** + * The modid that is required to be present for stripping NOT to occur + * @return the modid + */ + public String modid(); + + /** + * Strip references to this interface in method declarations? (Useful to kill synthetic methods from scala f.e.) + * + * @return if references should be stripped + */ + public boolean striprefs() default false; + } + /** + * Used to remove optional methods + * @author cpw + * + */ + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.METHOD) + public @interface Method { + /** + * The modid that is required to be present for stripping NOT to occur + * @return the modid + */ + public String modid(); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/ProxyInjector.java b/src/main/java/cpw/mods/fml/common/ProxyInjector.java new file mode 100644 index 0000000..8a8a861 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/ProxyInjector.java @@ -0,0 +1,83 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common; + +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.util.Set; +import org.apache.logging.log4j.Level; + +import com.google.common.base.Strings; + +import cpw.mods.fml.common.discovery.ASMDataTable; +import cpw.mods.fml.common.discovery.ASMDataTable.ASMData; +import cpw.mods.fml.relauncher.Side; + +/** + * @author cpw + * + */ +public class ProxyInjector +{ + public static void inject(ModContainer mod, ASMDataTable data, Side side, ILanguageAdapter languageAdapter) + { + FMLLog.fine("Attempting to inject @SidedProxy classes into %s", mod.getModId()); + Set targets = data.getAnnotationsFor(mod).get(SidedProxy.class.getName()); + ClassLoader mcl = Loader.instance().getModClassLoader(); + + for (ASMData targ : targets) + { + try + { + Class proxyTarget = Class.forName(targ.getClassName(), true, mcl); + Field target = proxyTarget.getDeclaredField(targ.getObjectName()); + if (target == null) + { + // Impossible? + FMLLog.severe("Attempted to load a proxy type into %s.%s but the field was not found", targ.getClassName(), targ.getObjectName()); + throw new LoaderException(); + } + target.setAccessible(true); + + SidedProxy annotation = target.getAnnotation(SidedProxy.class); + if (!Strings.isNullOrEmpty(annotation.modId()) && !annotation.modId().equals(mod.getModId())) + { + FMLLog.fine("Skipping proxy injection for %s.%s since it is not for mod %s", targ.getClassName(), targ.getObjectName(), mod.getModId()); + continue; + } + String targetType = side.isClient() ? annotation.clientSide() : annotation.serverSide(); + Object proxy=Class.forName(targetType, true, mcl).newInstance(); + + if (languageAdapter.supportsStatics() && (target.getModifiers() & Modifier.STATIC) == 0 ) + { + FMLLog.severe("Attempted to load a proxy type %s into %s.%s, but the field is not static", targetType, targ.getClassName(), targ.getObjectName()); + throw new LoaderException(); + } + if (!target.getType().isAssignableFrom(proxy.getClass())) + { + FMLLog.severe("Attempted to load a proxy type %s into %s.%s, but the types don't match", targetType, targ.getClassName(), targ.getObjectName()); + throw new LoaderException(); + } + languageAdapter.setProxy(target, proxyTarget, proxy); + } + catch (Exception e) + { + FMLLog.log(Level.ERROR, e, "An error occured trying to load a proxy into %s.%s", targ.getAnnotationInfo(), targ.getClassName(), targ.getObjectName()); + throw new LoaderException(e); + } + } + + // Allow language specific proxy injection. + languageAdapter.setInternalProxies(mod, side, mcl); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/SaveInspectionHandler.java b/src/main/java/cpw/mods/fml/common/SaveInspectionHandler.java new file mode 100644 index 0000000..44ec0b0 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/SaveInspectionHandler.java @@ -0,0 +1,20 @@ +package cpw.mods.fml.common; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * A method annotated with this on the {@link Mod} will be called whenever a local save is listed in + * the save games list. + * + * @author cpw + * + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface SaveInspectionHandler +{ + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/SidedProxy.java b/src/main/java/cpw/mods/fml/common/SidedProxy.java new file mode 100644 index 0000000..c59fabc --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/SidedProxy.java @@ -0,0 +1,68 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Sided proxies are loaded based on the specific environment they find themselves loaded into. + * They are used to ensure that client-specific code (such as GUIs) is only loaded into the game + * on the client side. + * It is applied to static fields of a class, anywhere in your mod code. FML will scan + * and load any classes with this annotation at mod construction time. + * + *

+ * This example will load a CommonProxy on the server side, and a ClientProxy on the client side. + * + *

{@code
+ *	public class MySidedProxyHolder {
+ *		{@literal @}SidedProxy(modId="MyModId",clientSide="mymod.ClientProxy", serverSide="mymod.CommonProxy")
+ *		public static CommonProxy proxy;
+ *	}
+ *
+ *	public class CommonProxy {
+ *		// Common or server stuff here that needs to be overridden on the client
+ *	}
+ *
+ *	public class ClientProxy extends CommonProxy {
+ *		// Override common stuff with client specific stuff here
+ *	}
+ * }
+ * 
+ * @author cpw + * + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.FIELD) +public @interface SidedProxy +{ + /** + * The name of the client side class to load and populate + */ + String clientSide() default ""; + + /** + * The name of the server side class to load and populate + */ + String serverSide() default ""; + + /** + * The (optional) name of a mod to load this proxy for. This will help ensure correct behaviour when loading a combined + * scala/java mod package. It is almost never going to be required, unless you ship both Scala and Java {@link Mod} content + * in a single jar. + */ + String modId() default ""; +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/StartupQuery.java b/src/main/java/cpw/mods/fml/common/StartupQuery.java new file mode 100644 index 0000000..0814640 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/StartupQuery.java @@ -0,0 +1,160 @@ +package cpw.mods.fml.common; + +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.atomic.AtomicBoolean; + +import net.minecraft.server.MinecraftServer; + +public class StartupQuery { + // internal class/functionality, do not use + + public static boolean confirm(String text) + { + StartupQuery query = new StartupQuery(text, new AtomicBoolean()); + query.execute(); + return query.getResult(); + } + + public static void notify(String text) + { + StartupQuery query = new StartupQuery(text, null); + query.execute(); + } + + public static void abort() + { + MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance(); + if (server != null) server.initiateShutdown(); + + aborted = true; // to abort loading and go back to the main menu + throw new AbortedException(); // to halt the server + } + + + public static void reset() + { + pending = null; + aborted = false; + } + + public static boolean check() + { + if (pending != null) + { + try + { + FMLCommonHandler.instance().queryUser(pending); + } + catch (InterruptedException e) + { + FMLLog.warning("query interrupted"); + abort(); + } + + pending = null; + } + + return !aborted; + } + + private static volatile StartupQuery pending; + private static volatile boolean aborted = false; + + + private StartupQuery(String text, AtomicBoolean result) + { + this.text = text; + this.result = result; + } + + public Boolean getResult() + { + return result == null ? null : result.get(); + } + + public void setResult(boolean result) + { + this.result.set(result); + } + + public String getText() + { + return text; + } + + public boolean isSynchronous() + { + return synchronous; + } + + public void finish() + { + signal.countDown(); + } + + private void execute() + { + String prop = System.getProperty("fml.queryResult"); + + if (result != null && prop != null) + { + FMLLog.info("Using fml.queryResult %s to answer the following query:\n%s", prop, text); + + if (prop.equalsIgnoreCase("confirm")) + { + setResult(true); + return; + } + else if (prop.equalsIgnoreCase("cancel")) + { + setResult(false); + return; + } + + FMLLog.warning("Invalid value for fml.queryResult: %s, expected confirm or cancel", prop); + } + + synchronous = false; + pending = this; // let the other thread start the query + + // from the integrated server thread: the client will eventually check pending and execute the query + // from the client thread: synchronous execution + // dedicated server: command handling in mc is synchronous, execute the server-side query directly + if (FMLCommonHandler.instance().getSide().isServer() || + FMLCommonHandler.instance().getEffectiveSide().isClient()) + { + synchronous = true; + check(); + } + + try + { + signal.await(); + reset(); + } + catch (InterruptedException e) + { + FMLLog.warning("query interrupted"); + abort(); + } + } + + private String text; + private AtomicBoolean result; + private CountDownLatch signal = new CountDownLatch(1); + private volatile boolean synchronous; + + + /** + * Exception not being caught by the crash report generation logic. + */ + public static class AbortedException extends RuntimeException + { + private static final long serialVersionUID = -5933665223696833921L; + + private AbortedException() + { + super(); + } + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/WorldAccessContainer.java b/src/main/java/cpw/mods/fml/common/WorldAccessContainer.java new file mode 100644 index 0000000..aac2362 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/WorldAccessContainer.java @@ -0,0 +1,25 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common; + +import java.util.Map; + +import net.minecraft.nbt.*; +import net.minecraft.world.storage.*; + + +public interface WorldAccessContainer +{ + public NBTTagCompound getDataForWriting(SaveHandler handler, WorldInfo info); + public void readData(SaveHandler handler, WorldInfo info, Map propertyMap, NBTTagCompound tag); +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/WrongMinecraftVersionException.java b/src/main/java/cpw/mods/fml/common/WrongMinecraftVersionException.java new file mode 100644 index 0000000..4df6fe0 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/WrongMinecraftVersionException.java @@ -0,0 +1,25 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common; + +public class WrongMinecraftVersionException extends RuntimeException +{ + private static final long serialVersionUID = 1L; + public ModContainer mod; + + public WrongMinecraftVersionException(ModContainer mod) + { + this.mod = mod; + } + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/ZipperUtil.java b/src/main/java/cpw/mods/fml/common/ZipperUtil.java new file mode 100644 index 0000000..ce513ac --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/ZipperUtil.java @@ -0,0 +1,98 @@ +package cpw.mods.fml.common; + +import java.io.Closeable; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.net.URI; +import java.util.Deque; +import java.util.LinkedList; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; + +import org.apache.logging.log4j.Level; + +import com.google.common.io.Files; + +import cpw.mods.fml.client.FMLClientHandler; + +/** + * Copied from http://stackoverflow.com/questions/1399126/java-util-zip-recreating-directory-structure + * because the code looked very tidy and neat. Thanks, McDowell! + * + * @author McDowell + * + */ +public class ZipperUtil { + public static void zip(File directory, File zipfile) throws IOException + { + URI base = directory.toURI(); + Deque queue = new LinkedList(); + queue.push(directory); + OutputStream out = new FileOutputStream(zipfile); + Closeable res = null; + try + { + ZipOutputStream zout = new ZipOutputStream(out); + res = zout; + while (!queue.isEmpty()) + { + directory = queue.pop(); + for (File kid : directory.listFiles()) + { + String name = base.relativize(kid.toURI()).getPath(); + if (kid.isDirectory()) + { + queue.push(kid); + name = name.endsWith("/") ? name : name + "/"; + zout.putNextEntry(new ZipEntry(name)); + } else + { + zout.putNextEntry(new ZipEntry(name)); + Files.copy(kid, zout); + zout.closeEntry(); + } + } + } + } finally + { + res.close(); + } + } + + public static void backupWorld() throws IOException + { + String dirName = FMLCommonHandler.instance().getMinecraftServerInstance().getFolderName(); + String saveName; + + if (FMLCommonHandler.instance().getSide().isClient()) + { + saveName = FMLCommonHandler.instance().getMinecraftServerInstance().getWorldName(); + } + else + { + saveName = dirName; + } + + backupWorld(dirName, saveName); + } + + public static void backupWorld(String dirName, String saveName) throws IOException + { + File dstFolder = FMLCommonHandler.instance().getSavesDirectory(); + File zip = new File(dstFolder, String.format("%s-%2$tY%2$tm%2$td-%2$tH%2$tM%2$tS.zip", saveName, System.currentTimeMillis())); + + try + { + ZipperUtil.zip(new File(dstFolder, dirName), zip); + } + catch (IOException e) + { + FMLLog.log(Level.WARN, e, "World backup failed."); + throw e; + } + + FMLLog.info("World backup created at %s.", zip.getCanonicalPath()); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/asm/FMLSanityChecker.java b/src/main/java/cpw/mods/fml/common/asm/FMLSanityChecker.java new file mode 100644 index 0000000..ecf1e64 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/asm/FMLSanityChecker.java @@ -0,0 +1,182 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.asm; + +import java.io.File; +import java.io.IOException; +import java.net.URLDecoder; +import java.security.CodeSource; +import java.security.cert.Certificate; +import java.util.Map; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import org.apache.logging.log4j.Level; + +import net.minecraft.launchwrapper.LaunchClassLoader; + +import com.google.common.base.Charsets; +import com.google.common.io.ByteStreams; + +import cpw.mods.fml.common.CertificateHelper; +import cpw.mods.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper; +import cpw.mods.fml.common.patcher.ClassPatchManager; +import cpw.mods.fml.relauncher.FMLLaunchHandler; +import cpw.mods.fml.relauncher.FMLRelaunchLog; +import cpw.mods.fml.relauncher.IFMLCallHook; +import cpw.mods.fml.relauncher.Side; + +public class FMLSanityChecker implements IFMLCallHook +{ + private static final String FMLFINGERPRINT = "51:0A:FB:4C:AF:A4:A0:F2:F5:CF:C5:0E:B4:CC:3C:30:24:4A:E3:8E".toLowerCase().replace(":", ""); + private static final String FORGEFINGERPRINT = "E3:C3:D5:0C:7C:98:6D:F7:4C:64:5C:0A:C5:46:39:74:1C:90:A5:57".toLowerCase().replace(":", ""); + private static final String MCFINGERPRINT = "CD:99:95:96:56:F7:53:DC:28:D8:63:B4:67:69:F7:F8:FB:AE:FC:FC".toLowerCase().replace(":", ""); + private LaunchClassLoader cl; + public static File fmlLocation; + + @Override + public Void call() throws Exception + { + CodeSource codeSource = getClass().getProtectionDomain().getCodeSource(); + boolean goodFML = false; + boolean fmlIsJar = false; + if (codeSource.getLocation().getProtocol().equals("jar")) + { + fmlIsJar = true; + Certificate[] certificates = codeSource.getCertificates(); + if (certificates!=null) + { + + for (Certificate cert : certificates) + { + String fingerprint = CertificateHelper.getFingerprint(cert); + if (fingerprint.equals(FMLFINGERPRINT)) + { + FMLRelaunchLog.info("Found valid fingerprint for FML. Certificate fingerprint %s", fingerprint); + goodFML = true; + } + else if (fingerprint.equals(FORGEFINGERPRINT)) + { + FMLRelaunchLog.info("Found valid fingerprint for Minecraft Forge. Certificate fingerprint %s", fingerprint); + goodFML = true; + } + else + { + FMLRelaunchLog.severe("Found invalid fingerprint for FML: %s", fingerprint); + } + } + } + } + else + { + goodFML = true; + } + + boolean goodMC = FMLLaunchHandler.side() == Side.SERVER; //Server is not signed, so assume it's good. + int certCount = 0; + try + { + Class cbr = Class.forName("net.minecraft.client.ClientBrandRetriever",false, cl); + codeSource = cbr.getProtectionDomain().getCodeSource(); + } + catch (Exception e) + { + // Probably a development environment, or the server (the server is not signed) + goodMC = true; + } + JarFile mcJarFile = null; + if (fmlIsJar && !goodMC && codeSource.getLocation().getProtocol().equals("jar")) + { + try + { + String mcPath = codeSource.getLocation().getPath().substring(5); + mcPath = mcPath.substring(0, mcPath.lastIndexOf('!')); + mcPath = URLDecoder.decode(mcPath, Charsets.UTF_8.name()); + mcJarFile = new JarFile(mcPath,true); + mcJarFile.getManifest(); + JarEntry cbrEntry = mcJarFile.getJarEntry("net/minecraft/client/ClientBrandRetriever.class"); + ByteStreams.toByteArray(mcJarFile.getInputStream(cbrEntry)); + Certificate[] certificates = cbrEntry.getCertificates(); + certCount = certificates != null ? certificates.length : 0; + if (certificates!=null) + { + + for (Certificate cert : certificates) + { + String fingerprint = CertificateHelper.getFingerprint(cert); + if (fingerprint.equals(MCFINGERPRINT)) + { + FMLRelaunchLog.info("Found valid fingerprint for Minecraft. Certificate fingerprint %s", fingerprint); + goodMC = true; + } + } + } + } + catch (Throwable e) + { + FMLRelaunchLog.log(Level.ERROR, e, "A critical error occurred trying to read the minecraft jar file"); + } + finally + { + if (mcJarFile != null) + { + try + { + mcJarFile.close(); + } + catch (IOException ioe) + { + // Noise + } + } + } + } + else + { + goodMC = true; + } + if (!goodMC) + { + FMLRelaunchLog.severe("The minecraft jar %s appears to be corrupt! There has been CRITICAL TAMPERING WITH MINECRAFT, it is highly unlikely minecraft will work! STOP NOW, get a clean copy and try again!",codeSource.getLocation().getFile()); + if (!Boolean.parseBoolean(System.getProperty("fml.ignoreInvalidMinecraftCertificates","false"))) + { + FMLRelaunchLog.severe("For your safety, FML will not launch minecraft. You will need to fetch a clean version of the minecraft jar file"); + FMLRelaunchLog.severe("Technical information: The class net.minecraft.client.ClientBrandRetriever should have been associated with the minecraft jar file, " + + "and should have returned us a valid, intact minecraft jar location. This did not work. Either you have modified the minecraft jar file (if so " + + "run the forge installer again), or you are using a base editing jar that is changing this class (and likely others too). If you REALLY " + + "want to run minecraft in this configuration, add the flag -Dfml.ignoreInvalidMinecraftCertificates=true to the 'JVM settings' in your launcher profile."); + System.exit(1); + } + else + { + FMLRelaunchLog.severe("FML has been ordered to ignore the invalid or missing minecraft certificate. This is very likely to cause a problem!"); + FMLRelaunchLog.severe("Technical information: ClientBrandRetriever was at %s, there were %d certificates for it", codeSource.getLocation(), certCount); + } + } + if (!goodFML) + { + FMLRelaunchLog.severe("FML appears to be missing any signature data. This is not a good thing"); + } + return null; + } + + @Override + public void injectData(Map data) + { + cl = (LaunchClassLoader) data.get("classLoader"); + File mcDir = (File)data.get("mcLocation"); + fmlLocation = (File)data.get("coremodLocation"); + ClassPatchManager.INSTANCE.setup(FMLLaunchHandler.side()); + FMLDeobfuscatingRemapper.INSTANCE.setup(mcDir, cl, (String) data.get("deobfuscationFileName")); + } + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/asm/ReobfuscationMarker.java b/src/main/java/cpw/mods/fml/common/asm/ReobfuscationMarker.java new file mode 100644 index 0000000..a6be499 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/asm/ReobfuscationMarker.java @@ -0,0 +1,29 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.asm; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Used to force certain classes to reobfuscate + * @author cpw + * + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE}) +public @interface ReobfuscationMarker { + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/asm/transformers/AccessTransformer.java b/src/main/java/cpw/mods/fml/common/asm/transformers/AccessTransformer.java new file mode 100644 index 0000000..286bdab --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/asm/transformers/AccessTransformer.java @@ -0,0 +1,433 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.asm.transformers; + +import static org.objectweb.asm.Opcodes.ACC_FINAL; +import static org.objectweb.asm.Opcodes.ACC_PRIVATE; +import static org.objectweb.asm.Opcodes.ACC_PROTECTED; +import static org.objectweb.asm.Opcodes.ACC_PUBLIC; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.net.URL; +import java.util.Collection; +import java.util.List; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; +import java.util.zip.ZipOutputStream; + +import net.minecraft.launchwrapper.IClassTransformer; + +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.tree.ClassNode; +import org.objectweb.asm.tree.FieldNode; +import org.objectweb.asm.tree.MethodNode; + +import com.google.common.base.Charsets; +import com.google.common.base.Splitter; +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; +import com.google.common.collect.Multimap; +import com.google.common.io.LineProcessor; +import com.google.common.io.Resources; + +import cpw.mods.fml.relauncher.FMLRelaunchLog; + +public class AccessTransformer implements IClassTransformer +{ + private static final boolean DEBUG = Boolean.parseBoolean(System.getProperty("fml.debugAccessTransformer", "false")); + private class Modifier + { + public String name = ""; + public String desc = ""; + public int oldAccess = 0; + public int newAccess = 0; + public int targetAccess = 0; + public boolean changeFinal = false; + public boolean markFinal = false; + protected boolean modifyClassVisibility; + + private void setTargetAccess(String name) + { + if (name.startsWith("public")) targetAccess = ACC_PUBLIC; + else if (name.startsWith("private")) targetAccess = ACC_PRIVATE; + else if (name.startsWith("protected")) targetAccess = ACC_PROTECTED; + + if (name.endsWith("-f")) + { + changeFinal = true; + markFinal = false; + } + else if (name.endsWith("+f")) + { + changeFinal = true; + markFinal = true; + } + } + } + + private Multimap modifiers = ArrayListMultimap.create(); + + public AccessTransformer() throws IOException + { + this("fml_at.cfg"); + } + protected AccessTransformer(String rulesFile) throws IOException + { + readMapFile(rulesFile); + } + + private void readMapFile(String rulesFile) throws IOException + { + File file = new File(rulesFile); + URL rulesResource; + if (file.exists()) + { + rulesResource = file.toURI().toURL(); + } + else + { + rulesResource = Resources.getResource(rulesFile); + } + Resources.readLines(rulesResource, Charsets.UTF_8, new LineProcessor() + { + @Override + public Void getResult() + { + return null; + } + + @Override + public boolean processLine(String input) throws IOException + { + String line = Iterables.getFirst(Splitter.on('#').limit(2).split(input), "").trim(); + if (line.length()==0) + { + return true; + } + List parts = Lists.newArrayList(Splitter.on(" ").trimResults().split(line)); + if (parts.size()>3) + { + throw new RuntimeException("Invalid config file line "+ input); + } + Modifier m = new Modifier(); + m.setTargetAccess(parts.get(0)); + + if (parts.size() == 2) + { + m.modifyClassVisibility = true; + } + else + { + String nameReference = parts.get(2); + int parenIdx = nameReference.indexOf('('); + if (parenIdx>0) + { + m.desc = nameReference.substring(parenIdx); + m.name = nameReference.substring(0,parenIdx); + } + else + { + m.name = nameReference; + } + } + String className = parts.get(1).replace('/', '.'); + modifiers.put(className, m); + if (DEBUG) System.out.printf("AT RULE: %s %s %s (type %s)\n", toBinary(m.targetAccess), m.name, m.desc, className); + return true; + } + }); + FMLRelaunchLog.fine("Loaded %d rules from AccessTransformer config file %s\n", modifiers.size(), rulesFile); + } + + @Override + public byte[] transform(String name, String transformedName, byte[] bytes) + { + if (bytes == null) { return null; } + + if (DEBUG) + { + FMLRelaunchLog.fine("Considering all methods and fields on %s (%s)\n", transformedName, name); + } + if (!modifiers.containsKey(transformedName)) { return bytes; } + + ClassNode classNode = new ClassNode(); + ClassReader classReader = new ClassReader(bytes); + classReader.accept(classNode, 0); + + Collection mods = modifiers.get(transformedName); + for (Modifier m : mods) + { + if (m.modifyClassVisibility) + { + classNode.access = getFixedAccess(classNode.access, m); + if (DEBUG) + { + System.out.println(String.format("Class: %s %s -> %s", name, toBinary(m.oldAccess), toBinary(m.newAccess))); + } + continue; + } + if (m.desc.isEmpty()) + { + for (FieldNode n : classNode.fields) + { + if (n.name.equals(m.name) || m.name.equals("*")) + { + n.access = getFixedAccess(n.access, m); + if (DEBUG) + { + System.out.println(String.format("Field: %s.%s %s -> %s", name, n.name, toBinary(m.oldAccess), toBinary(m.newAccess))); + } + + if (!m.name.equals("*")) + { + break; + } + } + } + } + else + { + for (MethodNode n : classNode.methods) + { + if ((n.name.equals(m.name) && n.desc.equals(m.desc)) || m.name.equals("*")) + { + n.access = getFixedAccess(n.access, m); + if (DEBUG) + { + System.out.println(String.format("Method: %s.%s%s %s -> %s", name, n.name, n.desc, toBinary(m.oldAccess), toBinary(m.newAccess))); + } + + if (!m.name.equals("*")) + { + break; + } + } + } + } + } + + ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS); + classNode.accept(writer); + return writer.toByteArray(); + } + + private String toBinary(int num) + { + return String.format("%16s", Integer.toBinaryString(num)).replace(' ', '0'); + } + + private int getFixedAccess(int access, Modifier target) + { + target.oldAccess = access; + int t = target.targetAccess; + int ret = (access & ~7); + + switch (access & 7) + { + case ACC_PRIVATE: + ret |= t; + break; + case 0: // default + ret |= (t != ACC_PRIVATE ? t : 0 /* default */); + break; + case ACC_PROTECTED: + ret |= (t != ACC_PRIVATE && t != 0 /* default */? t : ACC_PROTECTED); + break; + case ACC_PUBLIC: + ret |= (t != ACC_PRIVATE && t != 0 /* default */&& t != ACC_PROTECTED ? t : ACC_PUBLIC); + break; + default: + throw new RuntimeException("The fuck?"); + } + + // Clear the "final" marker on fields only if specified in control field + if (target.changeFinal) + { + if (target.markFinal) + { + ret |= ACC_FINAL; + } + else + { + ret &= ~ACC_FINAL; + } + } + target.newAccess = ret; + return ret; + } + + public static void main(String[] args) + { + if (args.length < 2) + { + System.out.println("Usage: AccessTransformer [MapFile2]... "); + System.exit(1); + } + + boolean hasTransformer = false; + AccessTransformer[] trans = new AccessTransformer[args.length - 1]; + for (int x = 1; x < args.length; x++) + { + try + { + trans[x - 1] = new AccessTransformer(args[x]); + hasTransformer = true; + } + catch (IOException e) + { + System.out.println("Could not read Transformer Map: " + args[x]); + e.printStackTrace(); + } + } + + if (!hasTransformer) + { + System.out.println("Culd not find a valid transformer to perform"); + System.exit(1); + } + + File orig = new File(args[0]); + File temp = new File(args[0] + ".ATBack"); + if (!orig.exists() && !temp.exists()) + { + System.out.println("Could not find target jar: " + orig); + System.exit(1); + } + + if (!orig.renameTo(temp)) + { + System.out.println("Could not rename file: " + orig + " -> " + temp); + System.exit(1); + } + + try + { + processJar(temp, orig, trans); + } + catch (IOException e) + { + e.printStackTrace(); + System.exit(1); + } + + if (!temp.delete()) + { + System.out.println("Could not delete temp file: " + temp); + } + } + + private static void processJar(File inFile, File outFile, AccessTransformer[] transformers) throws IOException + { + ZipInputStream inJar = null; + ZipOutputStream outJar = null; + + try + { + try + { + inJar = new ZipInputStream(new BufferedInputStream(new FileInputStream(inFile))); + } + catch (FileNotFoundException e) + { + throw new FileNotFoundException("Could not open input file: " + e.getMessage()); + } + + try + { + outJar = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(outFile))); + } + catch (FileNotFoundException e) + { + throw new FileNotFoundException("Could not open output file: " + e.getMessage()); + } + + ZipEntry entry; + while ((entry = inJar.getNextEntry()) != null) + { + if (entry.isDirectory()) + { + outJar.putNextEntry(entry); + continue; + } + + byte[] data = new byte[4096]; + ByteArrayOutputStream entryBuffer = new ByteArrayOutputStream(); + + int len; + do + { + len = inJar.read(data); + if (len > 0) + { + entryBuffer.write(data, 0, len); + } + } + while (len != -1); + + byte[] entryData = entryBuffer.toByteArray(); + + String entryName = entry.getName(); + + if (entryName.endsWith(".class") && !entryName.startsWith(".")) + { + ClassNode cls = new ClassNode(); + ClassReader rdr = new ClassReader(entryData); + rdr.accept(cls, 0); + String name = cls.name.replace('/', '.').replace('\\', '.'); + + for (AccessTransformer trans : transformers) + { + entryData = trans.transform(name, name, entryData); + } + } + + ZipEntry newEntry = new ZipEntry(entryName); + outJar.putNextEntry(newEntry); + outJar.write(entryData); + } + } + finally + { + if (outJar != null) + { + try + { + outJar.close(); + } + catch (IOException e) + { + } + } + + if (inJar != null) + { + try + { + inJar.close(); + } + catch (IOException e) + { + } + } + } + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/asm/transformers/DeobfuscationTransformer.java b/src/main/java/cpw/mods/fml/common/asm/transformers/DeobfuscationTransformer.java new file mode 100644 index 0000000..804edba --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/asm/transformers/DeobfuscationTransformer.java @@ -0,0 +1,53 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.asm.transformers; + +import net.minecraft.launchwrapper.IClassNameTransformer; +import net.minecraft.launchwrapper.IClassTransformer; + +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.commons.RemappingClassAdapter; + +import cpw.mods.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper; +import cpw.mods.fml.common.asm.transformers.deobf.FMLRemappingAdapter; + +public class DeobfuscationTransformer implements IClassTransformer, IClassNameTransformer { + + @Override + public byte[] transform(String name, String transformedName, byte[] bytes) + { + if (bytes == null) + { + return null; + } + ClassReader classReader = new ClassReader(bytes); + ClassWriter classWriter = new ClassWriter(ClassWriter.COMPUTE_MAXS); + RemappingClassAdapter remapAdapter = new FMLRemappingAdapter(classWriter); + classReader.accept(remapAdapter, ClassReader.EXPAND_FRAMES); + return classWriter.toByteArray(); + } + + @Override + public String remapClassName(String name) + { + return FMLDeobfuscatingRemapper.INSTANCE.map(name.replace('.','/')).replace('/', '.'); + } + + @Override + public String unmapClassName(String name) + { + return FMLDeobfuscatingRemapper.INSTANCE.unmap(name.replace('.', '/')).replace('/','.'); + } + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/asm/transformers/EventSubscriptionTransformer.java b/src/main/java/cpw/mods/fml/common/asm/transformers/EventSubscriptionTransformer.java new file mode 100644 index 0000000..106f81a --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/asm/transformers/EventSubscriptionTransformer.java @@ -0,0 +1,192 @@ +package cpw.mods.fml.common.asm.transformers; + +import static org.objectweb.asm.ClassWriter.COMPUTE_FRAMES; +import static org.objectweb.asm.ClassWriter.COMPUTE_MAXS; +import static org.objectweb.asm.Opcodes.ACC_PRIVATE; +import static org.objectweb.asm.Opcodes.ACC_PROTECTED; +import static org.objectweb.asm.Opcodes.ACC_PUBLIC; +import static org.objectweb.asm.Opcodes.ACC_STATIC; +import static org.objectweb.asm.Opcodes.ALOAD; +import static org.objectweb.asm.Opcodes.ARETURN; +import static org.objectweb.asm.Opcodes.ASM4; +import static org.objectweb.asm.Opcodes.DUP; +import static org.objectweb.asm.Opcodes.F_SAME; +import static org.objectweb.asm.Opcodes.GETSTATIC; +import static org.objectweb.asm.Opcodes.IFNULL; +import static org.objectweb.asm.Opcodes.INVOKESPECIAL; +import static org.objectweb.asm.Opcodes.NEW; +import static org.objectweb.asm.Opcodes.PUTSTATIC; +import static org.objectweb.asm.Opcodes.RETURN; +import static org.objectweb.asm.Type.VOID_TYPE; +import static org.objectweb.asm.Type.getMethodDescriptor; + +import java.util.List; + +import net.minecraft.launchwrapper.IClassTransformer; + +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.Type; +import org.objectweb.asm.tree.ClassNode; +import org.objectweb.asm.tree.FieldInsnNode; +import org.objectweb.asm.tree.FieldNode; +import org.objectweb.asm.tree.FrameNode; +import org.objectweb.asm.tree.InsnNode; +import org.objectweb.asm.tree.JumpInsnNode; +import org.objectweb.asm.tree.LabelNode; +import org.objectweb.asm.tree.MethodInsnNode; +import org.objectweb.asm.tree.MethodNode; +import org.objectweb.asm.tree.TypeInsnNode; +import org.objectweb.asm.tree.VarInsnNode; + +import cpw.mods.fml.common.eventhandler.Event; + +public class EventSubscriptionTransformer implements IClassTransformer +{ + public EventSubscriptionTransformer() + { + } + + @Override + public byte[] transform(String name, String transformedName, byte[] bytes) + { + if (bytes == null || name.equals("cpw.mods.fml.common.eventhandler.Event") || name.startsWith("net.minecraft.") || name.indexOf('.') == -1) + { + return bytes; + } + ClassReader cr = new ClassReader(bytes); + ClassNode classNode = new ClassNode(); + cr.accept(classNode, 0); + + try + { + if (buildEvents(classNode)) + { + ClassWriter cw = new ClassWriter(COMPUTE_MAXS | COMPUTE_FRAMES); + classNode.accept(cw); + return cw.toByteArray(); + } + return bytes; + } + catch (ClassNotFoundException ex) + { + // Discard silently- it's just noise + } + catch (Exception e) + { + e.printStackTrace(); + } + + return bytes; + } + + private boolean buildEvents(ClassNode classNode) throws Exception + { + Class parent = this.getClass().getClassLoader().loadClass(classNode.superName.replace('/', '.')); + if (!Event.class.isAssignableFrom(parent)) + { + return false; + } + + boolean hasSetup = false; + boolean hasGetListenerList = false; + boolean hasDefaultCtr = false; + + Class listenerListClazz = Class.forName("cpw.mods.fml.common.eventhandler.ListenerList", false, getClass().getClassLoader()); + Type tList = Type.getType(listenerListClazz); + + for (MethodNode method : (List)classNode.methods) + { + if (method.name.equals("setup") && + method.desc.equals(Type.getMethodDescriptor(VOID_TYPE)) && + (method.access & ACC_PROTECTED) == ACC_PROTECTED) + { + hasSetup = true; + } + if (method.name.equals("getListenerList") && + method.desc.equals(Type.getMethodDescriptor(tList)) && + (method.access & ACC_PUBLIC) == ACC_PUBLIC) + { + hasGetListenerList = true; + } + if (method.name.equals("") && + method.desc.equals(Type.getMethodDescriptor(VOID_TYPE))) + { + hasDefaultCtr = true; + } + } + + if (hasSetup) + { + if (!hasGetListenerList) + { + throw new RuntimeException("Event class defines setup() but does not define getListenerList! " + classNode.name); + } + else + { + return false; + } + } + + Type tSuper = Type.getType(classNode.superName); + + //Add private static ListenerList LISTENER_LIST + classNode.fields.add(new FieldNode(ACC_PRIVATE | ACC_STATIC, "LISTENER_LIST", tList.getDescriptor(), null, null)); + + /*Add: + * public () + * { + * super(); + * } + */ + MethodNode method = new MethodNode(ASM4, ACC_PUBLIC, "", getMethodDescriptor(VOID_TYPE), null, null); + method.instructions.add(new VarInsnNode(ALOAD, 0)); + method.instructions.add(new MethodInsnNode(INVOKESPECIAL, tSuper.getInternalName(), "", getMethodDescriptor(VOID_TYPE))); + method.instructions.add(new InsnNode(RETURN)); + if (!hasDefaultCtr) + { + classNode.methods.add(method); + } + + /*Add: + * protected void setup() + * { + * super.setup(); + * if (LISTENER_LIST != NULL) + * { + * return; + * } + * LISTENER_LIST = new ListenerList(super.getListenerList()); + * } + */ + method = new MethodNode(ASM4, ACC_PROTECTED, "setup", getMethodDescriptor(VOID_TYPE), null, null); + method.instructions.add(new VarInsnNode(ALOAD, 0)); + method.instructions.add(new MethodInsnNode(INVOKESPECIAL, tSuper.getInternalName(), "setup", getMethodDescriptor(VOID_TYPE))); + method.instructions.add(new FieldInsnNode(GETSTATIC, classNode.name, "LISTENER_LIST", tList.getDescriptor())); + LabelNode initLisitener = new LabelNode(); + method.instructions.add(new JumpInsnNode(IFNULL, initLisitener)); + method.instructions.add(new InsnNode(RETURN)); + method.instructions.add(initLisitener); + method.instructions.add(new FrameNode(F_SAME, 0, null, 0, null)); + method.instructions.add(new TypeInsnNode(NEW, tList.getInternalName())); + method.instructions.add(new InsnNode(DUP)); + method.instructions.add(new VarInsnNode(ALOAD, 0)); + method.instructions.add(new MethodInsnNode(INVOKESPECIAL, tSuper.getInternalName(), "getListenerList", getMethodDescriptor(tList))); + method.instructions.add(new MethodInsnNode(INVOKESPECIAL, tList.getInternalName(), "", getMethodDescriptor(VOID_TYPE, tList))); + method.instructions.add(new FieldInsnNode(PUTSTATIC, classNode.name, "LISTENER_LIST", tList.getDescriptor())); + method.instructions.add(new InsnNode(RETURN)); + classNode.methods.add(method); + + /*Add: + * public ListenerList getListenerList() + * { + * return this.LISTENER_LIST; + * } + */ + method = new MethodNode(ASM4, ACC_PUBLIC, "getListenerList", getMethodDescriptor(tList), null, null); + method.instructions.add(new FieldInsnNode(GETSTATIC, classNode.name, "LISTENER_LIST", tList.getDescriptor())); + method.instructions.add(new InsnNode(ARETURN)); + classNode.methods.add(method); + return true; + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/asm/transformers/MarkerTransformer.java b/src/main/java/cpw/mods/fml/common/asm/transformers/MarkerTransformer.java new file mode 100644 index 0000000..6dc72cc --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/asm/transformers/MarkerTransformer.java @@ -0,0 +1,288 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.asm.transformers; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.net.URL; +import java.util.List; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; +import java.util.zip.ZipOutputStream; + +import net.minecraft.launchwrapper.IClassTransformer; + +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.tree.ClassNode; + +import com.google.common.base.Charsets; +import com.google.common.base.Splitter; +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.Iterables; +import com.google.common.collect.ListMultimap; +import com.google.common.collect.Lists; +import com.google.common.io.LineProcessor; +import com.google.common.io.Resources; + +public class MarkerTransformer implements IClassTransformer +{ + private ListMultimap markers = ArrayListMultimap.create(); + + public MarkerTransformer() throws IOException + { + this("fml_marker.cfg"); + } + protected MarkerTransformer(String rulesFile) throws IOException + { + readMapFile(rulesFile); + } + + private void readMapFile(String rulesFile) throws IOException + { + File file = new File(rulesFile); + URL rulesResource; + if (file.exists()) + { + rulesResource = file.toURI().toURL(); + } + else + { + rulesResource = Resources.getResource(rulesFile); + } + Resources.readLines(rulesResource, Charsets.UTF_8, new LineProcessor() + { + @Override + public Void getResult() + { + return null; + } + + @Override + public boolean processLine(String input) throws IOException + { + String line = Iterables.getFirst(Splitter.on('#').limit(2).split(input), "").trim(); + if (line.length()==0) + { + return true; + } + List parts = Lists.newArrayList(Splitter.on(" ").trimResults().split(line)); + if (parts.size()!=2) + { + throw new RuntimeException("Invalid config file line "+ input); + } + List markerInterfaces = Lists.newArrayList(Splitter.on(",").trimResults().split(parts.get(1))); + for (String marker : markerInterfaces) + { + markers.put(parts.get(0), marker); + } + return true; + } + }); + } + + @Override + public byte[] transform(String name, String transformedName, byte[] bytes) + { + if (bytes == null) { return null; } + if (!markers.containsKey(name)) { return bytes; } + + ClassNode classNode = new ClassNode(); + ClassReader classReader = new ClassReader(bytes); + classReader.accept(classNode, 0); + + for (String marker : markers.get(name)) + { + classNode.interfaces.add(marker); + } + + ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS); + classNode.accept(writer); + return writer.toByteArray(); + } + + public static void main(String[] args) + { + if (args.length < 2) + { + System.out.println("Usage: MarkerTransformer [MapFile2]... "); + return; + } + + boolean hasTransformer = false; + MarkerTransformer[] trans = new MarkerTransformer[args.length - 1]; + for (int x = 1; x < args.length; x++) + { + try + { + trans[x - 1] = new MarkerTransformer(args[x]); + hasTransformer = true; + } + catch (IOException e) + { + System.out.println("Could not read Transformer Map: " + args[x]); + e.printStackTrace(); + } + } + + if (!hasTransformer) + { + System.out.println("Culd not find a valid transformer to perform"); + return; + } + + File orig = new File(args[0]); + File temp = new File(args[0] + ".ATBack"); + if (!orig.exists() && !temp.exists()) + { + System.out.println("Could not find target jar: " + orig); + return; + } +/* + if (temp.exists()) + { + if (orig.exists() && !orig.renameTo(new File(args[0] + (new SimpleDateFormat(".yyyy.MM.dd.HHmmss")).format(new Date())))) + { + System.out.println("Could not backup existing file: " + orig); + return; + } + if (!temp.renameTo(orig)) + { + System.out.println("Could not restore backup from previous run: " + temp); + return; + } + } +*/ + if (!orig.renameTo(temp)) + { + System.out.println("Could not rename file: " + orig + " -> " + temp); + return; + } + + try + { + processJar(temp, orig, trans); + } + catch (IOException e) + { + e.printStackTrace(); + } + + if (!temp.delete()) + { + System.out.println("Could not delete temp file: " + temp); + } + } + + private static void processJar(File inFile, File outFile, MarkerTransformer[] transformers) throws IOException + { + ZipInputStream inJar = null; + ZipOutputStream outJar = null; + + try + { + try + { + inJar = new ZipInputStream(new BufferedInputStream(new FileInputStream(inFile))); + } + catch (FileNotFoundException e) + { + throw new FileNotFoundException("Could not open input file: " + e.getMessage()); + } + + try + { + outJar = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(outFile))); + } + catch (FileNotFoundException e) + { + throw new FileNotFoundException("Could not open output file: " + e.getMessage()); + } + + ZipEntry entry; + while ((entry = inJar.getNextEntry()) != null) + { + if (entry.isDirectory()) + { + outJar.putNextEntry(entry); + continue; + } + + byte[] data = new byte[4096]; + ByteArrayOutputStream entryBuffer = new ByteArrayOutputStream(); + + int len; + do + { + len = inJar.read(data); + if (len > 0) + { + entryBuffer.write(data, 0, len); + } + } + while (len != -1); + + byte[] entryData = entryBuffer.toByteArray(); + + String entryName = entry.getName(); + + if (entryName.endsWith(".class") && !entryName.startsWith(".")) + { + ClassNode cls = new ClassNode(); + ClassReader rdr = new ClassReader(entryData); + rdr.accept(cls, 0); + String name = cls.name.replace('/', '.').replace('\\', '.'); + + for (MarkerTransformer trans : transformers) + { + entryData = trans.transform(name, name, entryData); + } + } + + ZipEntry newEntry = new ZipEntry(entryName); + outJar.putNextEntry(newEntry); + outJar.write(entryData); + } + } + finally + { + if (outJar != null) + { + try + { + outJar.close(); + } + catch (IOException e) + { + } + } + + if (inJar != null) + { + try + { + inJar.close(); + } + catch (IOException e) + { + } + } + } + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/asm/transformers/ModAPITransformer.java b/src/main/java/cpw/mods/fml/common/asm/transformers/ModAPITransformer.java new file mode 100644 index 0000000..0e5abdb --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/asm/transformers/ModAPITransformer.java @@ -0,0 +1,161 @@ +package cpw.mods.fml.common.asm.transformers; + +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; +import java.util.Set; + +import net.minecraft.launchwrapper.IClassTransformer; + +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.tree.ClassNode; +import org.objectweb.asm.tree.MethodNode; + +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.ListMultimap; +import com.google.common.collect.Sets; + +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.ModAPIManager; +import cpw.mods.fml.common.discovery.ASMDataTable; +import cpw.mods.fml.common.discovery.ASMDataTable.ASMData; +import cpw.mods.fml.relauncher.FMLRelaunchLog; + +public class ModAPITransformer implements IClassTransformer { + + private static final boolean logDebugInfo = Boolean.valueOf(System.getProperty("fml.debugAPITransformer", "true")); + private ListMultimap optionals; + + @Override + public byte[] transform(String name, String transformedName, byte[] basicClass) + { + String lookupName = name; + if(name.endsWith("$class")) + { + lookupName = name.substring(0, name.length() - 6); + } + if (optionals == null || !optionals.containsKey(lookupName)) + { + return basicClass; + } + ClassNode classNode = new ClassNode(); + ClassReader classReader = new ClassReader(basicClass); + classReader.accept(classNode, 0); + + if (logDebugInfo) FMLRelaunchLog.finer("Optional removal - found optionals for class %s - processing", name); + for (ASMData optional : optionals.get(lookupName)) + { + String modId = (String) optional.getAnnotationInfo().get("modid"); + + if (Loader.isModLoaded(modId) || ModAPIManager.INSTANCE.hasAPI(modId)) + { + if (logDebugInfo) FMLRelaunchLog.finer("Optional removal skipped - mod present %s", modId); + continue; + } + if (logDebugInfo) FMLRelaunchLog.finer("Optional on %s triggered - mod missing %s", name, modId); + + if (optional.getAnnotationInfo().containsKey("iface")) + { + Boolean stripRefs = (Boolean)optional.getAnnotationInfo().get("striprefs"); + if (stripRefs == null) stripRefs = Boolean.FALSE; + stripInterface(classNode,(String)optional.getAnnotationInfo().get("iface"), stripRefs); + } + else + { + stripMethod(classNode, (String)optional.getObjectName()); + } + + } + if (logDebugInfo) FMLRelaunchLog.finer("Optional removal - class %s processed", name); + + ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS); + classNode.accept(writer); + return writer.toByteArray(); + } + + private void stripMethod(ClassNode classNode, String methodDescriptor) + { + if(classNode.name.endsWith("$class")) + { + String subName = classNode.name.substring(0, classNode.name.length() - 6); + int pos = methodDescriptor.indexOf('(') + 1; + methodDescriptor = methodDescriptor.substring(0, pos) + 'L' + subName + ';' + methodDescriptor.substring(pos); + } + for (ListIterator iterator = classNode.methods.listIterator(); iterator.hasNext();) + { + MethodNode method = iterator.next(); + if (methodDescriptor.equals(method.name+method.desc)) + { + iterator.remove(); + if (logDebugInfo) FMLRelaunchLog.finer("Optional removal - method %s removed", methodDescriptor); + return; + } + } + if (logDebugInfo) FMLRelaunchLog.finer("Optional removal - method %s NOT removed - not found", methodDescriptor); + } + + private void stripInterface(ClassNode classNode, String interfaceName, boolean stripRefs) + { + String ifaceName = interfaceName.replace('.', '/'); + boolean found = classNode.interfaces.remove(ifaceName); + if (found && logDebugInfo) FMLRelaunchLog.finer("Optional removal - interface %s removed", interfaceName); + if (!found && logDebugInfo) FMLRelaunchLog.finer("Optional removal - interface %s NOT removed - not found", interfaceName); + + if (found && stripRefs) + { + if (logDebugInfo) FMLRelaunchLog.finer("Optional removal - interface %s - stripping method signature references", interfaceName); + for (Iterator iterator = classNode.methods.iterator(); iterator.hasNext();) + { + MethodNode node = iterator.next(); + if (node.desc.contains(ifaceName)) + { + if (logDebugInfo) FMLRelaunchLog.finer("Optional removal - interface %s - stripping method containing reference %s", interfaceName, node.name); + iterator.remove(); + } + } + if (logDebugInfo) FMLRelaunchLog.finer("Optional removal - interface %s - all method signature references stripped", interfaceName); + } + else if (found) + { + if (logDebugInfo) FMLRelaunchLog.finer("Optional removal - interface %s - NOT stripping method signature references", interfaceName); + } + } + + public void initTable(ASMDataTable dataTable) + { + optionals = ArrayListMultimap.create(); + Set interfaceLists = dataTable.getAll("cpw.mods.fml.common.Optional$InterfaceList"); + addData(unpackInterfaces(interfaceLists)); + Set interfaces = dataTable.getAll("cpw.mods.fml.common.Optional$Interface"); + addData(interfaces); + Set methods = dataTable.getAll("cpw.mods.fml.common.Optional$Method"); + addData(methods); + } + + private Set unpackInterfaces(Set packedInterfaces) + { + Set result = Sets.newHashSet(); + for (ASMData data : packedInterfaces) + { + @SuppressWarnings("unchecked") + List> packedList = (List>) data.getAnnotationInfo().get("value"); + for (Map packed : packedList) + { + ASMData newData = data.copy(packed); + result.add(newData); + } + } + + return result; + } + private void addData(Set interfaces) + { + for (ASMData data : interfaces) + { + optionals.put(data.getClassName(),data); + } + } + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/asm/transformers/PatchingTransformer.java b/src/main/java/cpw/mods/fml/common/asm/transformers/PatchingTransformer.java new file mode 100644 index 0000000..aad384d --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/asm/transformers/PatchingTransformer.java @@ -0,0 +1,13 @@ +package cpw.mods.fml.common.asm.transformers; + +import net.minecraft.launchwrapper.IClassTransformer; +import cpw.mods.fml.common.patcher.ClassPatchManager; + +public class PatchingTransformer implements IClassTransformer { + @Override + public byte[] transform(String name, String transformedName, byte[] bytes) + { + return ClassPatchManager.INSTANCE.applyPatch(name, transformedName, bytes); + } + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/asm/transformers/SideTransformer.java b/src/main/java/cpw/mods/fml/common/asm/transformers/SideTransformer.java new file mode 100644 index 0000000..4c7775d --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/asm/transformers/SideTransformer.java @@ -0,0 +1,117 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.asm.transformers; + +import java.util.Iterator; +import java.util.List; + +import net.minecraft.launchwrapper.IClassTransformer; + +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.Type; +import org.objectweb.asm.tree.AnnotationNode; +import org.objectweb.asm.tree.ClassNode; +import org.objectweb.asm.tree.FieldNode; +import org.objectweb.asm.tree.MethodNode; + +import cpw.mods.fml.relauncher.FMLLaunchHandler; +import cpw.mods.fml.relauncher.SideOnly; + +public class SideTransformer implements IClassTransformer +{ + private static String SIDE = FMLLaunchHandler.side().name(); + private static final boolean DEBUG = false; + @Override + public byte[] transform(String name, String transformedName, byte[] bytes) + { + if (bytes == null) { return null; } + + ClassNode classNode = new ClassNode(); + ClassReader classReader = new ClassReader(bytes); + classReader.accept(classNode, 0); + + if (remove((List)classNode.visibleAnnotations, SIDE)) + { + if (DEBUG) + { + System.out.println(String.format("Attempted to load class %s for invalid side %s", classNode.name, SIDE)); + } + throw new RuntimeException(String.format("Attempted to load class %s for invalid side %s", classNode.name, SIDE)); + } + + Iterator fields = classNode.fields.iterator(); + while(fields.hasNext()) + { + FieldNode field = fields.next(); + if (remove((List)field.visibleAnnotations, SIDE)) + { + if (DEBUG) + { + System.out.println(String.format("Removing Field: %s.%s", classNode.name, field.name)); + } + fields.remove(); + } + } + Iterator methods = classNode.methods.iterator(); + while(methods.hasNext()) + { + MethodNode method = methods.next(); + if (remove((List)method.visibleAnnotations, SIDE)) + { + if (DEBUG) + { + System.out.println(String.format("Removing Method: %s.%s%s", classNode.name, method.name, method.desc)); + } + methods.remove(); + } + } + + ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS); + classNode.accept(writer); + return writer.toByteArray(); + } + + private boolean remove(List anns, String side) + { + if (anns == null) + { + return false; + } + for (AnnotationNode ann : anns) + { + if (ann.desc.equals(Type.getDescriptor(SideOnly.class))) + { + if (ann.values != null) + { + for (int x = 0; x < ann.values.size() - 1; x += 2) + { + Object key = ann.values.get(x); + Object value = ann.values.get(x+1); + if (key instanceof String && key.equals("value")) + { + if (value instanceof String[] ) + { + if (!((String[])value)[1].equals(side)) + { + return true; + } + } + } + } + } + } + } + return false; + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/asm/transformers/deobf/FMLDeobfuscatingRemapper.java b/src/main/java/cpw/mods/fml/common/asm/transformers/deobf/FMLDeobfuscatingRemapper.java new file mode 100644 index 0000000..84eee25 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/asm/transformers/deobf/FMLDeobfuscatingRemapper.java @@ -0,0 +1,434 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.asm.transformers.deobf; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import net.minecraft.launchwrapper.LaunchClassLoader; + +import org.apache.logging.log4j.Level; +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.commons.Remapper; +import org.objectweb.asm.tree.ClassNode; +import org.objectweb.asm.tree.FieldNode; + +import com.google.common.base.CharMatcher; +import com.google.common.base.Charsets; +import com.google.common.base.Splitter; +import com.google.common.base.Strings; +import com.google.common.collect.BiMap; +import com.google.common.collect.ImmutableBiMap; +import com.google.common.collect.ImmutableBiMap.Builder; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; +import com.google.common.io.CharStreams; +import com.google.common.io.InputSupplier; + +import cpw.mods.fml.common.patcher.ClassPatchManager; +import cpw.mods.fml.relauncher.FMLRelaunchLog; + +public class FMLDeobfuscatingRemapper extends Remapper { + public static final FMLDeobfuscatingRemapper INSTANCE = new FMLDeobfuscatingRemapper(); + + private BiMap classNameBiMap; + private BiMap mcpNameBiMap; + + private Map> rawFieldMaps; + private Map> rawMethodMaps; + + private Map> fieldNameMaps; + private Map> methodNameMaps; + + private LaunchClassLoader classLoader; + + + private static final boolean DEBUG_REMAPPING = Boolean.parseBoolean(System.getProperty("fml.remappingDebug", "false")); + private static final boolean DUMP_FIELD_MAPS = Boolean.parseBoolean(System.getProperty("fml.remappingDebug.dumpFieldMaps", "false")) && DEBUG_REMAPPING; + private static final boolean DUMP_METHOD_MAPS = Boolean.parseBoolean(System.getProperty("fml.remappingDebug.dumpMethodMaps", "false")) && DEBUG_REMAPPING; + + private FMLDeobfuscatingRemapper() + { + classNameBiMap=ImmutableBiMap.of(); + mcpNameBiMap=ImmutableBiMap.of(); + } + + public void setupLoadOnly(String deobfFileName, boolean loadAll) + { + try + { + File mapData = new File(deobfFileName); + LZMAInputSupplier zis = new LZMAInputSupplier(new FileInputStream(mapData)); + InputSupplier srgSupplier = CharStreams.newReaderSupplier(zis,Charsets.UTF_8); + List srgList = CharStreams.readLines(srgSupplier); + rawMethodMaps = Maps.newHashMap(); + rawFieldMaps = Maps.newHashMap(); + Builder builder = ImmutableBiMap.builder(); + Builder mcpBuilder = ImmutableBiMap.builder(); + Splitter splitter = Splitter.on(CharMatcher.anyOf(": ")).omitEmptyStrings().trimResults(); + for (String line : srgList) + { + String[] parts = Iterables.toArray(splitter.split(line),String.class); + String typ = parts[0]; + if ("CL".equals(typ)) + { + parseClass(builder, parts); + parseMCPClass(mcpBuilder,parts); + } + else if ("MD".equals(typ) && loadAll) + { + parseMethod(parts); + } + else if ("FD".equals(typ) && loadAll) + { + parseField(parts); + } + } + classNameBiMap = builder.build(); + mcpNameBiMap = mcpBuilder.build(); + } + catch (IOException ioe) + { + FMLRelaunchLog.log(Level.ERROR, "An error occurred loading the deobfuscation map data", ioe); + } + methodNameMaps = Maps.newHashMapWithExpectedSize(rawMethodMaps.size()); + fieldNameMaps = Maps.newHashMapWithExpectedSize(rawFieldMaps.size()); + + } + public void setup(File mcDir, LaunchClassLoader classLoader, String deobfFileName) + { + this.classLoader = classLoader; + try + { + InputStream classData = getClass().getResourceAsStream(deobfFileName); + LZMAInputSupplier zis = new LZMAInputSupplier(classData); + InputSupplier srgSupplier = CharStreams.newReaderSupplier(zis,Charsets.UTF_8); + List srgList = CharStreams.readLines(srgSupplier); + rawMethodMaps = Maps.newHashMap(); + rawFieldMaps = Maps.newHashMap(); + Builder builder = ImmutableBiMap.builder(); + Builder mcpBuilder = ImmutableBiMap.builder(); + Splitter splitter = Splitter.on(CharMatcher.anyOf(": ")).omitEmptyStrings().trimResults(); + for (String line : srgList) + { + String[] parts = Iterables.toArray(splitter.split(line),String.class); + String typ = parts[0]; + if ("CL".equals(typ)) + { + parseClass(builder, parts); + parseMCPClass(mcpBuilder,parts); + } + else if ("MD".equals(typ)) + { + parseMethod(parts); + } + else if ("FD".equals(typ)) + { + parseField(parts); + } + } + classNameBiMap = builder.build(); + // Special case some mappings for modloader mods + mcpBuilder.put("BaseMod","net/minecraft/src/BaseMod"); + mcpBuilder.put("ModLoader","net/minecraft/src/ModLoader"); + mcpBuilder.put("EntityRendererProxy","net/minecraft/src/EntityRendererProxy"); + mcpBuilder.put("MLProp","net/minecraft/src/MLProp"); + mcpBuilder.put("TradeEntry","net/minecraft/src/TradeEntry"); + mcpNameBiMap = mcpBuilder.build(); + } + catch (IOException ioe) + { + FMLRelaunchLog.log(Level.ERROR, ioe, "An error occurred loading the deobfuscation map data"); + } + methodNameMaps = Maps.newHashMapWithExpectedSize(rawMethodMaps.size()); + fieldNameMaps = Maps.newHashMapWithExpectedSize(rawFieldMaps.size()); + } + + public boolean isRemappedClass(String className) + { + className = className.replace('.', '/'); + return classNameBiMap.containsKey(className) || mcpNameBiMap.containsKey(className) || (!classNameBiMap.isEmpty() && className.indexOf('/') == -1); + } + + private void parseField(String[] parts) + { + String oldSrg = parts[1]; + int lastOld = oldSrg.lastIndexOf('/'); + String cl = oldSrg.substring(0,lastOld); + String oldName = oldSrg.substring(lastOld+1); + String newSrg = parts[2]; + int lastNew = newSrg.lastIndexOf('/'); + String newName = newSrg.substring(lastNew+1); + if (!rawFieldMaps.containsKey(cl)) + { + rawFieldMaps.put(cl, Maps.newHashMap()); + } + rawFieldMaps.get(cl).put(oldName + ":" + getFieldType(cl, oldName), newName); + rawFieldMaps.get(cl).put(oldName + ":null", newName); + } + + /* + * Cache the field descriptions for classes so we don't repeatedly reload the same data again and again + */ + private Map> fieldDescriptions = Maps.newHashMap(); + + // Cache null values so we don't waste time trying to recompute classes with no field or method maps + private Set negativeCacheMethods = Sets.newHashSet(); + private Set negativeCacheFields = Sets.newHashSet(); + + private String getFieldType(String owner, String name) + { + if (fieldDescriptions.containsKey(owner)) + { + return fieldDescriptions.get(owner).get(name); + } + synchronized (fieldDescriptions) + { + try + { + byte[] classBytes = ClassPatchManager.INSTANCE.getPatchedResource(owner, map(owner).replace('/', '.'), classLoader); + if (classBytes == null) + { + return null; + } + ClassReader cr = new ClassReader(classBytes); + ClassNode classNode = new ClassNode(); + cr.accept(classNode, ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES); + Map resMap = Maps.newHashMap(); + for (FieldNode fieldNode : (List) classNode.fields) { + resMap.put(fieldNode.name, fieldNode.desc); + } + fieldDescriptions.put(owner, resMap); + return resMap.get(name); + } + catch (IOException e) + { + FMLRelaunchLog.log(Level.ERROR,e, "A critical exception occured reading a class file %s", owner); + } + return null; + } + } + + private void parseClass(Builder builder, String[] parts) + { + builder.put(parts[1],parts[2]); + } + + private void parseMCPClass(Builder builder, String[] parts) + { + int clIdx = parts[2].lastIndexOf('/'); + builder.put("net/minecraft/src/"+parts[2].substring(clIdx+1),parts[2]); + } + + private void parseMethod(String[] parts) + { + String oldSrg = parts[1]; + int lastOld = oldSrg.lastIndexOf('/'); + String cl = oldSrg.substring(0,lastOld); + String oldName = oldSrg.substring(lastOld+1); + String sig = parts[2]; + String newSrg = parts[3]; + int lastNew = newSrg.lastIndexOf('/'); + String newName = newSrg.substring(lastNew+1); + if (!rawMethodMaps.containsKey(cl)) + { + rawMethodMaps.put(cl, Maps.newHashMap()); + } + rawMethodMaps.get(cl).put(oldName+sig, newName); + } + + @Override + public String mapFieldName(String owner, String name, String desc) + { + if (classNameBiMap == null || classNameBiMap.isEmpty()) + { + return name; + } + Map fieldMap = getFieldMap(owner); + return fieldMap!=null && fieldMap.containsKey(name+":"+desc) ? fieldMap.get(name+":"+desc) : name; + } + + @Override + public String map(String typeName) + { + if (classNameBiMap == null || classNameBiMap.isEmpty()) + { + return typeName; + } + if (classNameBiMap.containsKey(typeName)) + { + return classNameBiMap.get(typeName); + } + int dollarIdx = typeName.indexOf('$'); + String realType = dollarIdx > -1 ? typeName.substring(0, dollarIdx) : typeName; + String subType = dollarIdx > -1 ? typeName.substring(dollarIdx+1) : ""; + + String result = classNameBiMap.containsKey(realType) ? classNameBiMap.get(realType) : mcpNameBiMap.containsKey(realType) ? mcpNameBiMap.get(realType) : realType; + result = dollarIdx > -1 ? result+"$"+subType : result; + return result; + } + + public String unmap(String typeName) + { + if (classNameBiMap == null || classNameBiMap.isEmpty()) + { + return typeName; + } + + if (classNameBiMap.containsValue(typeName)) + { + return classNameBiMap.inverse().get(typeName); + } + int dollarIdx = typeName.indexOf('$'); + String realType = dollarIdx > -1 ? typeName.substring(0, dollarIdx) : typeName; + String subType = dollarIdx > -1 ? typeName.substring(dollarIdx+1) : ""; + + + String result = classNameBiMap.containsValue(realType) ? classNameBiMap.inverse().get(realType) : mcpNameBiMap.containsValue(realType) ? mcpNameBiMap.inverse().get(realType) : realType; + result = dollarIdx > -1 ? result+"$"+subType : result; + return result; + } + + + @Override + public String mapMethodName(String owner, String name, String desc) + { + if (classNameBiMap==null || classNameBiMap.isEmpty()) + { + return name; + } + Map methodMap = getMethodMap(owner); + String methodDescriptor = name+desc; + return methodMap!=null && methodMap.containsKey(methodDescriptor) ? methodMap.get(methodDescriptor) : name; + } + + private Map getFieldMap(String className) + { + if (!fieldNameMaps.containsKey(className) && !negativeCacheFields.contains(className)) + { + findAndMergeSuperMaps(className); + if (!fieldNameMaps.containsKey(className)) + { + negativeCacheFields.add(className); + } + + if (DUMP_FIELD_MAPS) + { + FMLRelaunchLog.finer("Field map for %s : %s", className, fieldNameMaps.get(className)); + } + } + return fieldNameMaps.get(className); + } + + private Map getMethodMap(String className) + { + if (!methodNameMaps.containsKey(className) && !negativeCacheMethods.contains(className)) + { + findAndMergeSuperMaps(className); + if (!methodNameMaps.containsKey(className)) + { + negativeCacheMethods.add(className); + } + if (DUMP_METHOD_MAPS) + { + FMLRelaunchLog.finer("Method map for %s : %s", className, methodNameMaps.get(className)); + } + + } + return methodNameMaps.get(className); + } + + private void findAndMergeSuperMaps(String name) + { + try + { + String superName = null; + String[] interfaces = new String[0]; + byte[] classBytes = ClassPatchManager.INSTANCE.getPatchedResource(name, map(name), classLoader); + if (classBytes != null) + { + ClassReader cr = new ClassReader(classBytes); + superName = cr.getSuperName(); + interfaces = cr.getInterfaces(); + } + mergeSuperMaps(name, superName, interfaces); + } + catch (IOException e) + { + e.printStackTrace(); + } + } + public void mergeSuperMaps(String name, String superName, String[] interfaces) + { +// System.out.printf("Computing super maps for %s: %s %s\n", name, superName, Arrays.asList(interfaces)); + if (classNameBiMap == null || classNameBiMap.isEmpty()) + { + return; + } + // Skip Object + if (Strings.isNullOrEmpty(superName)) + { + return; + } + + List allParents = ImmutableList.builder().add(superName).addAll(Arrays.asList(interfaces)).build(); + // generate maps for all parent objects + for (String parentThing : allParents) + { + if (!methodNameMaps.containsKey(parentThing)) + { + findAndMergeSuperMaps(parentThing); + } + } + Map methodMap = Maps.newHashMap(); + Map fieldMap = Maps.newHashMap(); + for (String parentThing : allParents) + { + if (methodNameMaps.containsKey(parentThing)) + { + methodMap.putAll(methodNameMaps.get(parentThing)); + } + if (fieldNameMaps.containsKey(parentThing)) + { + fieldMap.putAll(fieldNameMaps.get(parentThing)); + } + } + if (rawMethodMaps.containsKey(name)) + { + methodMap.putAll(rawMethodMaps.get(name)); + } + if (rawFieldMaps.containsKey(name)) + { + fieldMap.putAll(rawFieldMaps.get(name)); + } + methodNameMaps.put(name, ImmutableMap.copyOf(methodMap)); + fieldNameMaps.put(name, ImmutableMap.copyOf(fieldMap)); +// System.out.printf("Maps: %s %s\n", name, methodMap); + } + + public Set getObfedClasses() + { + return ImmutableSet.copyOf(classNameBiMap.keySet()); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/asm/transformers/deobf/FMLRemappingAdapter.java b/src/main/java/cpw/mods/fml/common/asm/transformers/deobf/FMLRemappingAdapter.java new file mode 100644 index 0000000..3eb1132 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/asm/transformers/deobf/FMLRemappingAdapter.java @@ -0,0 +1,34 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.asm.transformers.deobf; + +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.commons.RemappingClassAdapter; + +public class FMLRemappingAdapter extends RemappingClassAdapter { + public FMLRemappingAdapter(ClassVisitor cv) + { + super(cv, FMLDeobfuscatingRemapper.INSTANCE); + } + + @Override + public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) + { + if (interfaces == null) + { + interfaces = new String[0]; + } + FMLDeobfuscatingRemapper.INSTANCE.mergeSuperMaps(name, superName, interfaces); + super.visit(version, access, name, signature, superName, interfaces); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/asm/transformers/deobf/LZMAInputSupplier.java b/src/main/java/cpw/mods/fml/common/asm/transformers/deobf/LZMAInputSupplier.java new file mode 100644 index 0000000..86f041f --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/asm/transformers/deobf/LZMAInputSupplier.java @@ -0,0 +1,36 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.asm.transformers.deobf; + +import java.io.IOException; +import java.io.InputStream; + +import LZMA.LzmaInputStream; + +import com.google.common.io.InputSupplier; + +public class LZMAInputSupplier implements InputSupplier { + private InputStream compressedData; + + public LZMAInputSupplier(InputStream compressedData) + { + this.compressedData = compressedData; + } + + @Override + public InputStream getInput() throws IOException + { + return new LzmaInputStream(this.compressedData); + } + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/discovery/ASMDataTable.java b/src/main/java/cpw/mods/fml/common/discovery/ASMDataTable.java new file mode 100644 index 0000000..aed9f1d --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/discovery/ASMDataTable.java @@ -0,0 +1,141 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.discovery; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.google.common.base.Predicate; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSetMultimap; +import com.google.common.collect.Lists; +import com.google.common.collect.Multimap; +import com.google.common.collect.Multimaps; +import com.google.common.collect.SetMultimap; + +import cpw.mods.fml.common.ModContainer; + +public class ASMDataTable +{ + public final static class ASMData implements Cloneable + { + private ModCandidate candidate; + private String annotationName; + private String className; + private String objectName; + private Map annotationInfo; + public ASMData(ModCandidate candidate, String annotationName, String className, String objectName, Map info) + { + this.candidate = candidate; + this.annotationName = annotationName; + this.className = className; + this.objectName = objectName; + this.annotationInfo = info; + } + public ModCandidate getCandidate() + { + return candidate; + } + public String getAnnotationName() + { + return annotationName; + } + public String getClassName() + { + return className; + } + public String getObjectName() + { + return objectName; + } + public Map getAnnotationInfo() + { + return annotationInfo; + } + + public ASMData copy(Map newAnnotationInfo) + { + try + { + ASMData clone = (ASMData) this.clone(); + clone.annotationInfo = newAnnotationInfo; + return clone; + } + catch (CloneNotSupportedException e) + { + throw new RuntimeException("Unpossible", e); + } + } + } + + private static class ModContainerPredicate implements Predicate + { + private ModContainer container; + public ModContainerPredicate(ModContainer container) + { + this.container = container; + } + @Override + public boolean apply(ASMData data) + { + return container.getSource().equals(data.candidate.getModContainer()); + } + } + private SetMultimap globalAnnotationData = HashMultimap.create(); + private Map> containerAnnotationData; + + private List containers = Lists.newArrayList(); + private SetMultimap packageMap = HashMultimap.create(); + + public SetMultimap getAnnotationsFor(ModContainer container) + { + if (containerAnnotationData == null) + { + ImmutableMap.Builder> mapBuilder = ImmutableMap.>builder(); + for (ModContainer cont : containers) + { + Multimap values = Multimaps.filterValues(globalAnnotationData, new ModContainerPredicate(cont)); + mapBuilder.put(cont, ImmutableSetMultimap.copyOf(values)); + } + containerAnnotationData = mapBuilder.build(); + } + return containerAnnotationData.get(container); + } + + public Set getAll(String annotation) + { + return globalAnnotationData.get(annotation); + } + + public void addASMData(ModCandidate candidate, String annotation, String className, String objectName, Map annotationInfo) + { + globalAnnotationData.put(annotation, new ASMData(candidate, annotation, className, objectName, annotationInfo)); + } + + public void addContainer(ModContainer container) + { + this.containers.add(container); + } + + public void registerPackage(ModCandidate modCandidate, String pkg) + { + this.packageMap.put(pkg,modCandidate); + } + + public Set getCandidatesFor(String pkg) + { + return this.packageMap.get(pkg); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/discovery/ContainerType.java b/src/main/java/cpw/mods/fml/common/discovery/ContainerType.java new file mode 100644 index 0000000..d1f9b83 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/discovery/ContainerType.java @@ -0,0 +1,44 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.discovery; + +import java.util.List; + +import com.google.common.base.Throwables; + +import cpw.mods.fml.common.ModContainer; + +public enum ContainerType +{ + JAR(JarDiscoverer.class), + DIR(DirectoryDiscoverer.class); + + private ITypeDiscoverer discoverer; + + private ContainerType(Class discovererClass) + { + try + { + this.discoverer = discovererClass.newInstance(); + } + catch (Exception e) + { + throw Throwables.propagate(e); + } + } + + public List findMods(ModCandidate candidate, ASMDataTable table) + { + return discoverer.discover(candidate, table); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/discovery/DirectoryDiscoverer.java b/src/main/java/cpw/mods/fml/common/discovery/DirectoryDiscoverer.java new file mode 100644 index 0000000..1f0196f --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/discovery/DirectoryDiscoverer.java @@ -0,0 +1,128 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.discovery; + +import java.io.File; +import java.io.FileFilter; +import java.io.FileInputStream; +import java.util.Arrays; +import java.util.List; +import java.util.regex.Matcher; + +import org.apache.logging.log4j.Level; + +import com.google.common.base.Throwables; +import com.google.common.collect.Lists; + +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.LoaderException; +import cpw.mods.fml.common.MetadataCollection; +import cpw.mods.fml.common.ModContainer; +import cpw.mods.fml.common.ModContainerFactory; +import cpw.mods.fml.common.discovery.asm.ASMModParser; + +public class DirectoryDiscoverer implements ITypeDiscoverer +{ + private class ClassFilter implements FileFilter + { + @Override + public boolean accept(File file) + { + return (file.isFile() && classFile.matcher(file.getName()).find()) || file.isDirectory(); + } + } + + private ASMDataTable table; + + @Override + public List discover(ModCandidate candidate, ASMDataTable table) + { + this.table = table; + List found = Lists.newArrayList(); + FMLLog.fine("Examining directory %s for potential mods", candidate.getModContainer().getName()); + exploreFileSystem("", candidate.getModContainer(), found, candidate, null); + for (ModContainer mc : found) + { + table.addContainer(mc); + } + return found; + } + + public void exploreFileSystem(String path, File modDir, List harvestedMods, ModCandidate candidate, MetadataCollection mc) + { + if (path.length() == 0) + { + File metadata = new File(modDir, "mcmod.info"); + try + { + FileInputStream fis = new FileInputStream(metadata); + mc = MetadataCollection.from(fis,modDir.getName()); + fis.close(); + FMLLog.fine("Found an mcmod.info file in directory %s", modDir.getName()); + } + catch (Exception e) + { + mc = MetadataCollection.from(null,""); + FMLLog.fine("No mcmod.info file found in directory %s", modDir.getName()); + } + } + + File[] content = modDir.listFiles(new ClassFilter()); + + // Always sort our content + Arrays.sort(content); + for (File file : content) + { + if (file.isDirectory()) + { + FMLLog.finer("Recursing into package %s", path + file.getName()); + exploreFileSystem(path + file.getName() + ".", file, harvestedMods, candidate, mc); + continue; + } + Matcher match = classFile.matcher(file.getName()); + + if (match.matches()) + { + ASMModParser modParser = null; + try + { + FileInputStream fis = new FileInputStream(file); + modParser = new ASMModParser(fis); + fis.close(); + candidate.addClassEntry(path+file.getName()); + } + catch (LoaderException e) + { + FMLLog.log(Level.ERROR, e, "There was a problem reading the file %s - probably this is a corrupt file", file.getPath()); + throw e; + } + catch (Exception e) + { + Throwables.propagate(e); + } + + modParser.validate(); + modParser.sendToTable(table, candidate); + ModContainer container = ModContainerFactory.instance().build(modParser, candidate.getModContainer(), candidate); + if (container!=null) + { + harvestedMods.add(container); + container.bindMetadata(mc); + } + } + + + } + } + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/discovery/ITypeDiscoverer.java b/src/main/java/cpw/mods/fml/common/discovery/ITypeDiscoverer.java new file mode 100644 index 0000000..3a2acf8 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/discovery/ITypeDiscoverer.java @@ -0,0 +1,25 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.discovery; + +import java.util.List; +import java.util.regex.Pattern; + +import cpw.mods.fml.common.ModContainer; + +public interface ITypeDiscoverer +{ + public static Pattern classFile = Pattern.compile("([^\\s$]+).class$"); + + public List discover(ModCandidate candidate, ASMDataTable table); +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/discovery/JarDiscoverer.java b/src/main/java/cpw/mods/fml/common/discovery/JarDiscoverer.java new file mode 100644 index 0000000..c3862bb --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/discovery/JarDiscoverer.java @@ -0,0 +1,113 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.discovery; + +import java.util.Collections; +import java.util.List; +import java.util.jar.JarFile; +import org.apache.logging.log4j.Level; +import java.util.regex.Matcher; +import java.util.zip.ZipEntry; + +import com.google.common.collect.Lists; + +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.LoaderException; +import cpw.mods.fml.common.MetadataCollection; +import cpw.mods.fml.common.ModContainer; +import cpw.mods.fml.common.ModContainerFactory; +import cpw.mods.fml.common.discovery.asm.ASMModParser; + +public class JarDiscoverer implements ITypeDiscoverer +{ + @Override + public List discover(ModCandidate candidate, ASMDataTable table) + { + List foundMods = Lists.newArrayList(); + FMLLog.fine("Examining file %s for potential mods", candidate.getModContainer().getName()); + JarFile jar = null; + try + { + jar = new JarFile(candidate.getModContainer()); + + if (jar.getManifest()!=null && (jar.getManifest().getMainAttributes().get("FMLCorePlugin") != null || jar.getManifest().getMainAttributes().get("TweakClass") != null)) + { + FMLLog.finer("Ignoring coremod or tweak system %s", candidate.getModContainer()); + return foundMods; + } + ZipEntry modInfo = jar.getEntry("mcmod.info"); + MetadataCollection mc = null; + if (modInfo != null) + { + FMLLog.finer("Located mcmod.info file in file %s", candidate.getModContainer().getName()); + mc = MetadataCollection.from(jar.getInputStream(modInfo), candidate.getModContainer().getName()); + } + else + { + FMLLog.fine("The mod container %s appears to be missing an mcmod.info file", candidate.getModContainer().getName()); + mc = MetadataCollection.from(null, ""); + } + for (ZipEntry ze : Collections.list(jar.entries())) + { + if (ze.getName()!=null && ze.getName().startsWith("__MACOSX")) + { + continue; + } + Matcher match = classFile.matcher(ze.getName()); + if (match.matches()) + { + ASMModParser modParser; + try + { + modParser = new ASMModParser(jar.getInputStream(ze)); + candidate.addClassEntry(ze.getName()); + } + catch (LoaderException e) + { + FMLLog.log(Level.ERROR, e, "There was a problem reading the entry %s in the jar %s - probably a corrupt zip", ze.getName(), candidate.getModContainer().getPath()); + jar.close(); + throw e; + } + modParser.validate(); + modParser.sendToTable(table, candidate); + ModContainer container = ModContainerFactory.instance().build(modParser, candidate.getModContainer(), candidate); + if (container!=null) + { + table.addContainer(container); + foundMods.add(container); + container.bindMetadata(mc); + } + } + } + } + catch (Exception e) + { + FMLLog.log(Level.WARN, e, "Zip file %s failed to read properly, it will be ignored", candidate.getModContainer().getName()); + } + finally + { + if (jar != null) + { + try + { + jar.close(); + } + catch (Exception e) + { + } + } + } + return foundMods; + } + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/discovery/ModCandidate.java b/src/main/java/cpw/mods/fml/common/discovery/ModCandidate.java new file mode 100644 index 0000000..89774d8 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/discovery/ModCandidate.java @@ -0,0 +1,126 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.discovery; + +import java.io.File; +import java.util.List; +import java.util.Set; + +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; + +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.ModContainer; +import cpw.mods.fml.common.discovery.asm.ASMModParser; + + +public class ModCandidate +{ + private File classPathRoot; + private File modContainer; + private ContainerType sourceType; + private boolean classpath; + private List baseModTypes = Lists.newArrayList(); + private boolean isMinecraft; + private List baseModCandidateTypes = Lists.newArrayListWithCapacity(1); + private Set foundClasses = Sets.newHashSet(); + private List mods; + private List packages = Lists.newArrayList(); + private ASMDataTable table; + + public ModCandidate(File classPathRoot, File modContainer, ContainerType sourceType) + { + this(classPathRoot, modContainer, sourceType, false, false); + } + public ModCandidate(File classPathRoot, File modContainer, ContainerType sourceType, boolean isMinecraft, boolean classpath) + { + this.classPathRoot = classPathRoot; + this.modContainer = modContainer; + this.sourceType = sourceType; + this.isMinecraft = isMinecraft; + this.classpath = classpath; + } + + public File getClassPathRoot() + { + return classPathRoot; + } + + public File getModContainer() + { + return modContainer; + } + + public ContainerType getSourceType() + { + return sourceType; + } + public List explore(ASMDataTable table) + { + this.table = table; + this.mods = sourceType.findMods(this, table); + if (!baseModCandidateTypes.isEmpty()) + { + FMLLog.info("Attempting to reparse the mod container %s", getModContainer().getName()); + this.mods = sourceType.findMods(this, table); + } + return this.mods; + } + + public void addClassEntry(String name) + { + String className = name.substring(0, name.lastIndexOf('.')); // strip the .class + foundClasses.add(className.replace('.', '/')); + className = className.replace('/','.'); + int pkgIdx = className.lastIndexOf('.'); + if (pkgIdx > -1) + { + String pkg = className.substring(0,pkgIdx); + packages.add(pkg); + this.table.registerPackage(this,pkg); + } + } + + public boolean isClasspath() + { + return classpath; + } + public void rememberBaseModType(String className) + { + baseModTypes.add(className); + } + public List getRememberedBaseMods() + { + return baseModTypes; + } + public boolean isMinecraftJar() + { + return isMinecraft; + } + public void rememberModCandidateType(ASMModParser modParser) + { + baseModCandidateTypes.add(modParser); + } + public Set getClassList() + { + return foundClasses; + } + public List getContainedMods() + { + return mods; + } + public List getContainedPackages() + { + return packages; + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/discovery/ModDiscoverer.java b/src/main/java/cpw/mods/fml/common/discovery/ModDiscoverer.java new file mode 100644 index 0000000..50e4bc3 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/discovery/ModDiscoverer.java @@ -0,0 +1,155 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.discovery; + +import java.io.File; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import org.apache.logging.log4j.Level; +import com.google.common.base.Throwables; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.LoaderException; +import cpw.mods.fml.common.ModClassLoader; +import cpw.mods.fml.common.ModContainer; +import cpw.mods.fml.relauncher.CoreModManager; +import cpw.mods.fml.relauncher.FileListHelper; + +public class ModDiscoverer +{ + private static Pattern zipJar = Pattern.compile("(.+).(zip|jar)$"); + + private List candidates = Lists.newArrayList(); + + private ASMDataTable dataTable = new ASMDataTable(); + + private List nonModLibs = Lists.newArrayList(); + + public void findClasspathMods(ModClassLoader modClassLoader) + { + List knownLibraries = ImmutableList.builder() + // skip default libs + .addAll(modClassLoader.getDefaultLibraries()) + // skip loaded coremods + .addAll(CoreModManager.getLoadedCoremods()) + // skip reparse coremods here + .addAll(CoreModManager.getReparseableCoremods()) + .build(); + File[] minecraftSources = modClassLoader.getParentSources(); + if (minecraftSources.length == 1 && minecraftSources[0].isFile()) + { + FMLLog.fine("Minecraft is a file at %s, loading", minecraftSources[0].getAbsolutePath()); + candidates.add(new ModCandidate(minecraftSources[0], minecraftSources[0], ContainerType.JAR, true, true)); + } + else + { + for (int i = 0; i < minecraftSources.length; i++) + { + if (minecraftSources[i].isFile()) + { + if (knownLibraries.contains(minecraftSources[i].getName())) + { + FMLLog.finer("Skipping known library file %s", minecraftSources[i].getAbsolutePath()); + } + else + { + FMLLog.fine("Found a minecraft related file at %s, examining for mod candidates", minecraftSources[i].getAbsolutePath()); + candidates.add(new ModCandidate(minecraftSources[i], minecraftSources[i], ContainerType.JAR, i==0, true)); + } + } + else if (minecraftSources[i].isDirectory()) + { + FMLLog.fine("Found a minecraft related directory at %s, examining for mod candidates", minecraftSources[i].getAbsolutePath()); + candidates.add(new ModCandidate(minecraftSources[i], minecraftSources[i], ContainerType.DIR, i==0, true)); + } + } + } + + } + + public void findModDirMods(File modsDir) + { + File[] modList = FileListHelper.sortFileList(modsDir, null); + + for (File modFile : modList) + { + // skip loaded coremods + if (CoreModManager.getLoadedCoremods().contains(modFile.getName())) + { + FMLLog.finer("Skipping already parsed coremod or tweaker %s", modFile.getName()); + } + else if (modFile.isDirectory()) + { + FMLLog.fine("Found a candidate mod directory %s", modFile.getName()); + candidates.add(new ModCandidate(modFile, modFile, ContainerType.DIR)); + } + else + { + Matcher matcher = zipJar.matcher(modFile.getName()); + + if (matcher.matches()) + { + FMLLog.fine("Found a candidate zip or jar file %s", matcher.group(0)); + candidates.add(new ModCandidate(modFile, modFile, ContainerType.JAR)); + } + else + { + FMLLog.fine("Ignoring unknown file %s in mods directory", modFile.getName()); + } + } + } + } + + public List identifyMods() + { + List modList = Lists.newArrayList(); + + for (ModCandidate candidate : candidates) + { + try + { + List mods = candidate.explore(dataTable); + if (mods.isEmpty() && !candidate.isClasspath()) + { + nonModLibs.add(candidate.getModContainer()); + } + else + { + modList.addAll(mods); + } + } + catch (LoaderException le) + { + FMLLog.log(Level.WARN, le, "Identified a problem with the mod candidate %s, ignoring this source", candidate.getModContainer()); + } + catch (Throwable t) + { + Throwables.propagate(t); + } + } + + return modList; + } + + public ASMDataTable getASMTable() + { + return dataTable; + } + + public List getNonModLibs() + { + return nonModLibs; + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/discovery/asm/ASMModParser.java b/src/main/java/cpw/mods/fml/common/discovery/asm/ASMModParser.java new file mode 100644 index 0000000..2b50864 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/discovery/asm/ASMModParser.java @@ -0,0 +1,186 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.discovery.asm; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; + +import org.apache.logging.log4j.Level; +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.Type; + +import com.google.common.base.Objects; +import com.google.common.base.Strings; +import com.google.common.collect.Lists; + +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.LoaderException; +import cpw.mods.fml.common.discovery.ASMDataTable; +import cpw.mods.fml.common.discovery.ModCandidate; + +public class ASMModParser +{ + + private Type asmType; + private int classVersion; + private Type asmSuperType; + private LinkedList annotations = Lists.newLinkedList(); + private String baseModProperties; + + static enum AnnotationType + { + CLASS, FIELD, METHOD, SUBTYPE; + } + + public ASMModParser(InputStream stream) throws IOException + { + try + { + ClassReader reader = new ClassReader(stream); + reader.accept(new ModClassVisitor(this), 0); + } + catch (Exception ex) + { + FMLLog.log(Level.ERROR, ex, "Unable to read a class file correctly"); + throw new LoaderException(ex); + } + } + + public void beginNewTypeName(String typeQName, int classVersion, String superClassQName) + { + this.asmType = Type.getObjectType(typeQName); + this.classVersion = classVersion; + this.asmSuperType = !Strings.isNullOrEmpty(superClassQName) ? Type.getObjectType(superClassQName) : null; + } + + public void startClassAnnotation(String annotationName) + { + ModAnnotation ann = new ModAnnotation(AnnotationType.CLASS, Type.getType(annotationName), this.asmType.getClassName()); + annotations.addFirst(ann); + } + + public void addAnnotationProperty(String key, Object value) + { + annotations.getFirst().addProperty(key, value); + } + + public void startFieldAnnotation(String fieldName, String annotationName) + { + ModAnnotation ann = new ModAnnotation(AnnotationType.FIELD, Type.getType(annotationName), fieldName); + annotations.addFirst(ann); + } + + @Override + public String toString() + { + return Objects.toStringHelper("ASMAnnotationDiscoverer") + .add("className", asmType.getClassName()) + .add("classVersion", classVersion) + .add("superName", asmSuperType.getClassName()) + .add("annotations", annotations) + .add("isBaseMod", isBaseMod(Collections.emptyList())) + .add("baseModProperties", baseModProperties) + .toString(); + } + + public Type getASMType() + { + return asmType; + } + + public int getClassVersion() + { + return classVersion; + } + + public Type getASMSuperType() + { + return asmSuperType; + } + + public LinkedList getAnnotations() + { + return annotations; + } + + public void validate() + { +// if (classVersion > 50.0) +// { +// +// throw new LoaderException(new RuntimeException("Mod compiled for Java 7 detected")); +// } + } + + public boolean isBaseMod(List rememberedTypes) + { + return getASMSuperType().equals(Type.getType("LBaseMod;")) || getASMSuperType().equals(Type.getType("Lnet/minecraft/src/BaseMod;"))|| rememberedTypes.contains(getASMSuperType().getClassName()); + } + + public void setBaseModProperties(String foundProperties) + { + this.baseModProperties = foundProperties; + } + + public String getBaseModProperties() + { + return this.baseModProperties; + } + + public void sendToTable(ASMDataTable table, ModCandidate candidate) + { + for (ModAnnotation ma : annotations) + { + table.addASMData(candidate, ma.asmType.getClassName(), this.asmType.getClassName(), ma.member, ma.values); + } + } + + public void addAnnotationArray(String name) + { + annotations.getFirst().addArray(name); + } + + public void addAnnotationEnumProperty(String name, String desc, String value) + { + annotations.getFirst().addEnumProperty(name, desc, value); + + } + + public void endArray() + { + annotations.getFirst().endArray(); + + } + + public void addSubAnnotation(String name, String desc) + { + ModAnnotation ma = annotations.getFirst(); + annotations.addFirst(ma.addChildAnnotation(name, desc)); + } + + public void endSubAnnotation() + { + // take the child and stick it at the end + ModAnnotation child = annotations.removeFirst(); + annotations.addLast(child); + } + + public void startMethodAnnotation(String methodName, String methodDescriptor, String annotationName) + { + ModAnnotation ann = new ModAnnotation(AnnotationType.METHOD, Type.getType(annotationName), methodName+methodDescriptor); + annotations.addFirst(ann); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/discovery/asm/ModAnnotation.java b/src/main/java/cpw/mods/fml/common/discovery/asm/ModAnnotation.java new file mode 100644 index 0000000..1b258bd --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/discovery/asm/ModAnnotation.java @@ -0,0 +1,122 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.discovery.asm; + +import java.util.ArrayList; +import java.util.Map; + +import org.objectweb.asm.Type; + +import com.google.common.base.Objects; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; + +import cpw.mods.fml.common.discovery.asm.ASMModParser.AnnotationType; + +public class ModAnnotation +{ + public class EnumHolder + { + @SuppressWarnings("unused") + private String desc; + @SuppressWarnings("unused") + private String value; + + public EnumHolder(String desc, String value) + { + this.desc = desc; + this.value = value; + } + + } + AnnotationType type; + Type asmType; + String member; + Map values = Maps.newHashMap(); + private ArrayList arrayList; + private String arrayName; + public ModAnnotation(AnnotationType type, Type asmType, String member) + { + this.type = type; + this.asmType = asmType; + this.member = member; + } + + public ModAnnotation(AnnotationType type, Type asmType, ModAnnotation parent) + { + this.type = type; + this.asmType = asmType; + } + @Override + public String toString() + { + return Objects.toStringHelper("Annotation") + .add("type",type) + .add("name",asmType.getClassName()) + .add("member",member) + .add("values", values) + .toString(); + } + public AnnotationType getType() + { + return type; + } + public Type getASMType() + { + return asmType; + } + public String getMember() + { + return member; + } + public Map getValues() + { + return values; + } + public void addArray(String name) + { + this.arrayList = Lists.newArrayList(); + this.arrayName = name; + } + public void addProperty(String key, Object value) + { + if (this.arrayList != null) + { + arrayList.add(value); + } + else + { + values.put(key, value); + } + } + + public void addEnumProperty(String key, String enumName, String value) + { + values.put(key, new EnumHolder(enumName, value)); + } + + public void endArray() + { + values.put(arrayName, arrayList); + arrayList = null; + } + public ModAnnotation addChildAnnotation(String name, String desc) + { + ModAnnotation child = new ModAnnotation(AnnotationType.SUBTYPE, Type.getType(desc), this); + if (arrayList != null) + { + arrayList.add(child.getValues()); + } + return child; + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/discovery/asm/ModAnnotationVisitor.java b/src/main/java/cpw/mods/fml/common/discovery/asm/ModAnnotationVisitor.java new file mode 100644 index 0000000..46cdd45 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/discovery/asm/ModAnnotationVisitor.java @@ -0,0 +1,82 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.discovery.asm; + +import org.objectweb.asm.AnnotationVisitor; +import org.objectweb.asm.Opcodes; + +public class ModAnnotationVisitor extends AnnotationVisitor +{ + private ASMModParser discoverer; + private boolean array; + @SuppressWarnings("unused") + private String name; + private boolean isSubAnnotation; + + public ModAnnotationVisitor(ASMModParser discoverer) + { + super(Opcodes.ASM4); + this.discoverer = discoverer; + } + + public ModAnnotationVisitor(ASMModParser discoverer, String name) + { + this(discoverer); + this.array = true; + this.name = name; + discoverer.addAnnotationArray(name); + } + + public ModAnnotationVisitor(ASMModParser discoverer, boolean isSubAnnotation) + { + this(discoverer); + this.isSubAnnotation = true; + } + + @Override + public void visit(String key, Object value) + { + discoverer.addAnnotationProperty(key, value); + } + + @Override + public void visitEnum(String name, String desc, String value) + { + discoverer.addAnnotationEnumProperty(name, desc, value); + } + + @Override + public AnnotationVisitor visitArray(String name) + { + return new ModAnnotationVisitor(discoverer, name); + } + @Override + public AnnotationVisitor visitAnnotation(String name, String desc) + { + discoverer.addSubAnnotation(name, desc); + return new ModAnnotationVisitor(discoverer, true); + } + @Override + public void visitEnd() + { + if (array) + { + discoverer.endArray(); + } + + if (isSubAnnotation) + { + discoverer.endSubAnnotation(); + } + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/discovery/asm/ModClassVisitor.java b/src/main/java/cpw/mods/fml/common/discovery/asm/ModClassVisitor.java new file mode 100644 index 0000000..7044350 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/discovery/asm/ModClassVisitor.java @@ -0,0 +1,57 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.discovery.asm; + +import org.objectweb.asm.AnnotationVisitor; +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.FieldVisitor; +import org.objectweb.asm.MethodVisitor; +import org.objectweb.asm.Opcodes; + +public class ModClassVisitor extends ClassVisitor +{ + private ASMModParser discoverer; + + public ModClassVisitor(ASMModParser discoverer) + { + super(Opcodes.ASM4); + this.discoverer = discoverer; + } + + + @Override + public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) + { + discoverer.beginNewTypeName(name, version, superName); + } + + @Override + public AnnotationVisitor visitAnnotation(String annotationName, boolean runtimeVisible) + { + discoverer.startClassAnnotation(annotationName); + return new ModAnnotationVisitor(discoverer); + } + + + @Override + public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) + { + return new ModFieldVisitor(name, discoverer); + } + + @Override + public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) + { + return new ModMethodVisitor(name, desc, discoverer); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/discovery/asm/ModFieldVisitor.java b/src/main/java/cpw/mods/fml/common/discovery/asm/ModFieldVisitor.java new file mode 100644 index 0000000..c09b1b9 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/discovery/asm/ModFieldVisitor.java @@ -0,0 +1,38 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.discovery.asm; + +import org.objectweb.asm.AnnotationVisitor; +import org.objectweb.asm.FieldVisitor; +import org.objectweb.asm.Opcodes; + +public class ModFieldVisitor extends FieldVisitor +{ + + private String fieldName; + private ASMModParser discoverer; + + public ModFieldVisitor(String name, ASMModParser discoverer) + { + super(Opcodes.ASM4); + this.fieldName = name; + this.discoverer = discoverer; + } + + @Override + public AnnotationVisitor visitAnnotation(String annotationName, boolean runtimeVisible) + { + discoverer.startFieldAnnotation(fieldName, annotationName); + return new ModAnnotationVisitor(discoverer); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/discovery/asm/ModMethodVisitor.java b/src/main/java/cpw/mods/fml/common/discovery/asm/ModMethodVisitor.java new file mode 100644 index 0000000..06488b6 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/discovery/asm/ModMethodVisitor.java @@ -0,0 +1,28 @@ +package cpw.mods.fml.common.discovery.asm; + +import org.objectweb.asm.AnnotationVisitor; +import org.objectweb.asm.MethodVisitor; +import org.objectweb.asm.Opcodes; + +public class ModMethodVisitor extends MethodVisitor { + + private String methodName; + private String methodDescriptor; + private ASMModParser discoverer; + + public ModMethodVisitor(String name, String desc, ASMModParser discoverer) + { + super(Opcodes.ASM4); + this.methodName = name; + this.methodDescriptor = desc; + this.discoverer = discoverer; + } + + @Override + public AnnotationVisitor visitAnnotation(String annotationName, boolean runtimeVisible) + { + discoverer.startMethodAnnotation(methodName, methodDescriptor, annotationName); + return new ModAnnotationVisitor(discoverer); + } + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/event/FMLConstructionEvent.java b/src/main/java/cpw/mods/fml/common/event/FMLConstructionEvent.java new file mode 100644 index 0000000..cea1f68 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/event/FMLConstructionEvent.java @@ -0,0 +1,55 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.event; + +import com.google.common.collect.ListMultimap; + +import cpw.mods.fml.common.LoaderState.ModState; +import cpw.mods.fml.common.ModClassLoader; +import cpw.mods.fml.common.discovery.ASMDataTable; + +public class FMLConstructionEvent extends FMLStateEvent +{ + private ModClassLoader modClassLoader; + private ASMDataTable asmData; + private ListMultimap reverseDependencies; + + @SuppressWarnings("unchecked") + public FMLConstructionEvent(Object... eventData) + { + this.modClassLoader = (ModClassLoader)eventData[0]; + this.asmData = (ASMDataTable) eventData[1]; + this.reverseDependencies = (ListMultimap) eventData[2]; + } + + public ModClassLoader getModClassLoader() + { + return modClassLoader; + } + + @Override + public ModState getModState() + { + return ModState.CONSTRUCTED; + } + + public ASMDataTable getASMHarvestedData() + { + return asmData; + } + + public ListMultimap getReverseDependencies() + { + return reverseDependencies; + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/event/FMLEvent.java b/src/main/java/cpw/mods/fml/common/event/FMLEvent.java new file mode 100644 index 0000000..d441530 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/event/FMLEvent.java @@ -0,0 +1,27 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.event; + +import cpw.mods.fml.common.ModContainer; + +public class FMLEvent +{ + public final String getEventType() + { + return getClass().getSimpleName(); + } + + public void applyModContainer(ModContainer activeContainer) { + // NO OP + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/event/FMLFingerprintViolationEvent.java b/src/main/java/cpw/mods/fml/common/event/FMLFingerprintViolationEvent.java new file mode 100644 index 0000000..4c556ff --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/event/FMLFingerprintViolationEvent.java @@ -0,0 +1,36 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.event; + +import java.io.File; +import java.util.Set; + +import com.google.common.collect.ImmutableSet; + + +public class FMLFingerprintViolationEvent extends FMLEvent { + + public final boolean isDirectory; + public final Set fingerprints; + public final File source; + public final String expectedFingerprint; + + public FMLFingerprintViolationEvent(boolean isDirectory, File source, ImmutableSet fingerprints, String expectedFingerprint) + { + super(); + this.isDirectory = isDirectory; + this.source = source; + this.fingerprints = fingerprints; + this.expectedFingerprint = expectedFingerprint; + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/event/FMLInitializationEvent.java b/src/main/java/cpw/mods/fml/common/event/FMLInitializationEvent.java new file mode 100644 index 0000000..fc355cf --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/event/FMLInitializationEvent.java @@ -0,0 +1,31 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.event; + +import cpw.mods.fml.common.LoaderState.ModState; + +public class FMLInitializationEvent extends FMLStateEvent +{ + + public FMLInitializationEvent(Object... data) + { + super(data); + } + + @Override + public ModState getModState() + { + return ModState.INITIALIZED; + } + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/event/FMLInterModComms.java b/src/main/java/cpw/mods/fml/common/event/FMLInterModComms.java new file mode 100644 index 0000000..00b26d0 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/event/FMLInterModComms.java @@ -0,0 +1,219 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.event; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.ImmutableList; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.LoaderState; +import cpw.mods.fml.common.Mod.Instance; +import cpw.mods.fml.common.ModContainer; + +/** + * Simple intermod communications to receive simple messages directed at you + * from other mods + * + * @author cpw + * + */ +public class FMLInterModComms { + private static final ImmutableList emptyIMCList = ImmutableList.of(); + private static ArrayListMultimap modMessages = ArrayListMultimap.create(); + + /** + * Subscribe to this event to receive your messages (they are sent between + * {@link Init} and {@link PostInit}) + * + * @author cpw + * + */ + public static class IMCEvent extends FMLEvent { + private ModContainer activeContainer; + + @Override + public void applyModContainer(ModContainer activeContainer) + { + this.activeContainer = activeContainer; + this.currentList = null; + FMLLog.finer("Attempting to deliver %d IMC messages to mod %s", modMessages.get(activeContainer.getModId()).size(), activeContainer.getModId()); + } + + private ImmutableList currentList; + + public ImmutableList getMessages() + { + if (currentList == null) + { + currentList = ImmutableList.copyOf(modMessages.removeAll(activeContainer.getModId())); + } + return currentList; + } + } + + /** + * You will receive an instance of this for each message sent + * + * @author cpw + * + */ + public static final class IMCMessage { + /** + * This is the modid of the mod that sent you the message + */ + private String sender; + /** + * This field, and {@link #value} are both at the mod's discretion + */ + public final String key; + /** + * This field, and {@link #key} are both at the mod's discretion + */ + private Object value; + + private IMCMessage(String key, Object value) + { + this.key = key; + this.value = value; + } + + @Override + public String toString() + { + return sender; + } + + public String getSender() + { + return this.sender; + } + + void setSender(ModContainer activeModContainer) + { + this.sender = activeModContainer.getModId(); + } + + public String getStringValue() + { + return (String) value; + } + + public NBTTagCompound getNBTValue() + { + return (NBTTagCompound) value; + } + + public ItemStack getItemStackValue() + { + return (ItemStack) value; + } + + public Class getMessageType() + { + return value.getClass(); + } + + public boolean isStringMessage() + { + return String.class.isAssignableFrom(getMessageType()); + } + + public boolean isItemStackMessage() + { + return ItemStack.class.isAssignableFrom(getMessageType()); + } + + public boolean isNBTMessage() + { + return NBTTagCompound.class.isAssignableFrom(getMessageType()); + } + } + + public static boolean sendMessage(String modId, String key, NBTTagCompound value) + { + return enqueueStartupMessage(modId, new IMCMessage(key, value)); + } + public static boolean sendMessage(String modId, String key, ItemStack value) + { + return enqueueStartupMessage(modId, new IMCMessage(key, value)); + } + public static boolean sendMessage(String modId, String key, String value) + { + return enqueueStartupMessage(modId, new IMCMessage(key, value)); + } + + public static void sendRuntimeMessage(Object sourceMod, String modId, String key, NBTTagCompound value) + { + enqueueMessage(sourceMod, modId, new IMCMessage(key, value)); + } + + public static void sendRuntimeMessage(Object sourceMod, String modId, String key, ItemStack value) + { + enqueueMessage(sourceMod, modId, new IMCMessage(key, value)); + } + + public static void sendRuntimeMessage(Object sourceMod, String modId, String key, String value) + { + enqueueMessage(sourceMod, modId, new IMCMessage(key, value)); + } + + private static boolean enqueueStartupMessage(String modTarget, IMCMessage message) + { + if (Loader.instance().activeModContainer() == null) + { + return false; + } + enqueueMessage(Loader.instance().activeModContainer(), modTarget, message); + return Loader.isModLoaded(modTarget) && !Loader.instance().hasReachedState(LoaderState.POSTINITIALIZATION); + + } + private static void enqueueMessage(Object sourceMod, String modTarget, IMCMessage message) + { + ModContainer mc; + if (sourceMod instanceof ModContainer) { + mc = (ModContainer) sourceMod; + } + else + { + mc = FMLCommonHandler.instance().findContainerFor(sourceMod); + } + if (mc != null && Loader.isModLoaded(modTarget)) + { + message.setSender(mc); + modMessages.put(modTarget, message); + } + } + + /** + * Retrieve any pending runtime messages for the mod + * @param forMod The {@link Instance} of the Mod to fetch messages for + * @return any messages - the collection will never be null + */ + public static ImmutableList fetchRuntimeMessages(Object forMod) + { + ModContainer mc = FMLCommonHandler.instance().findContainerFor(forMod); + if (mc != null) + { + return ImmutableList.copyOf(modMessages.removeAll(mc.getModId())); + } + else + { + return emptyIMCList; + } + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/event/FMLLoadCompleteEvent.java b/src/main/java/cpw/mods/fml/common/event/FMLLoadCompleteEvent.java new file mode 100644 index 0000000..d6fc0be --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/event/FMLLoadCompleteEvent.java @@ -0,0 +1,31 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.event; + +import cpw.mods.fml.common.LoaderState.ModState; + +public class FMLLoadCompleteEvent extends FMLStateEvent +{ + + public FMLLoadCompleteEvent(Object... data) + { + super(data); + } + + @Override + public ModState getModState() + { + return ModState.AVAILABLE; + } + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/event/FMLLoadEvent.java b/src/main/java/cpw/mods/fml/common/event/FMLLoadEvent.java new file mode 100644 index 0000000..ad74768 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/event/FMLLoadEvent.java @@ -0,0 +1,18 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.event; + +public class FMLLoadEvent +{ + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/event/FMLMissingMappingsEvent.java b/src/main/java/cpw/mods/fml/common/event/FMLMissingMappingsEvent.java new file mode 100644 index 0000000..a279cf7 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/event/FMLMissingMappingsEvent.java @@ -0,0 +1,174 @@ +package cpw.mods.fml.common.event; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ListMultimap; + +import cpw.mods.fml.common.ModContainer; +import cpw.mods.fml.common.registry.GameData; +import cpw.mods.fml.common.registry.GameRegistry; + +/** + * This event is fired if a world is loaded that has block and item mappings referring the mod that are not + * in existence. + * These can be remapped to other existing objects, or simply discarded. + * Use get() and getAll() to process this event. + * + * @author cpw, Player + * + */ +public class FMLMissingMappingsEvent extends FMLEvent { + /** + * Actions you can take with this missing mapping. + *
    + *
  • {@link #IGNORE} means this missing mapping will be ignored. + *
  • {@link #WARN} means this missing mapping will generate a warning. + *
  • {@link #FAIL} means this missing mapping will prevent the world from loading. + *
+ * @author cpw + * + */ + public static enum Action { DEFAULT, IGNORE, WARN, FAIL, REMAP } + public static class MissingMapping { + public final GameRegistry.Type type; + public final String name; + public final int id; + private Action action = Action.DEFAULT; + private Object target; + + public MissingMapping(String name, int id) + { + this.type = name.charAt(0) == '\u0001' ? GameRegistry.Type.BLOCK : GameRegistry.Type.ITEM; + this.name = name.substring(1); + this.id = id; + } + /** + * @deprecated use ignore(), warn(), fail() or remap() instead + */ + @Deprecated + public void setAction(Action target) + { + if (target == Action.DEFAULT || target == Action.REMAP) throw new IllegalArgumentException(); + + this.action = target; + } + + /** + * Ignore the missing item. + */ + public void ignore() + { + action = Action.IGNORE; + } + + /** + * Warn the user about the missing item. + */ + public void warn() + { + action = Action.WARN; + } + + /** + * Prevent the world from loading due to the missing item. + */ + public void fail() + { + action = Action.FAIL; + } + + /** + * Remap the missing item to the specified Block. + * + * Use this if you have renamed a Block, don't forget to handle the ItemBlock. + * Existing references using the old name will point to the new one. + * + * @param target Block to remap to. + */ + public void remap(Block target) + { + if (type != GameRegistry.Type.BLOCK) throw new IllegalArgumentException("Can't remap an item to a block."); + if (target == null) throw new NullPointerException("remap target is null"); + if (GameData.getBlockRegistry().getId(target) < 0) throw new IllegalArgumentException(String.format("The specified block %s hasn't been registered at startup.", target)); + + action = Action.REMAP; + this.target = target; + } + + /** + * Remap the missing item to the specified Item. + * + * Use this if you have renamed an Item. + * Existing references using the old name will point to the new one. + * + * @param target Item to remap to. + */ + public void remap(Item target) + { + if (type != GameRegistry.Type.ITEM) throw new IllegalArgumentException("Can't remap a block to an item."); + if (target == null) throw new NullPointerException("remap target is null"); + if (GameData.getItemRegistry().getId(target) < 0) throw new IllegalArgumentException(String.format("The specified item %s hasn't been registered at startup.", target)); + + action = Action.REMAP; + this.target = target; + } + + // internal + + public Action getAction() + { + return this.action; + } + + public Object getTarget() + { + return target; + } + } + private ListMultimap missing; + private ModContainer activeContainer; + + public FMLMissingMappingsEvent(ListMultimap missingMappings) + { + this.missing = missingMappings; + } + + @Override + public void applyModContainer(ModContainer activeContainer) + { + super.applyModContainer(activeContainer); + this.activeContainer = activeContainer; + } + + /** + * Get the list of missing mappings for the active mod. + * + * Process the list entries by calling ignore(), warn(), fail() or remap() on each entry. + * + * @return list of missing mappings + */ + public List get() + { + return ImmutableList.copyOf(missing.get(activeContainer.getModId())); + } + + /** + * Get the list of missing mappings for all mods. + * + * Only use this if you need to handle mod id changes, e.g. if you renamed your mod or + * split/merge into/from multiple mods. + * + * Process the list entries by calling ignore(), warn(), fail() or remap() on each entry you + * want to handle. + * + * @return list of missing mappings + */ + public List getAll() + { + return ImmutableList.copyOf(missing.values()); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/event/FMLModDisabledEvent.java b/src/main/java/cpw/mods/fml/common/event/FMLModDisabledEvent.java new file mode 100644 index 0000000..54315d4 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/event/FMLModDisabledEvent.java @@ -0,0 +1,4 @@ +package cpw.mods.fml.common.event; + +public class FMLModDisabledEvent extends FMLEvent { +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/event/FMLModIdMappingEvent.java b/src/main/java/cpw/mods/fml/common/event/FMLModIdMappingEvent.java new file mode 100644 index 0000000..44afdf5 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/event/FMLModIdMappingEvent.java @@ -0,0 +1,48 @@ +package cpw.mods.fml.common.event; + +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; + +public class FMLModIdMappingEvent extends FMLEvent { + public static enum RemapTarget { BLOCK, ITEM } + public class ModRemapping + { + public final int oldId; + public final int newId; + public final String tag; + public final RemapTarget remapTarget; + public ModRemapping(int oldId, int newId, String tag) + { + this.oldId = oldId; + this.newId = newId; + this.tag = tag.substring(1); + this.remapTarget = tag.charAt(0) == '\u0001' ? RemapTarget.BLOCK : RemapTarget.ITEM; + } + + } + public final ImmutableList remappedIds; + + public FMLModIdMappingEvent(Map mappings) + { + List remappings = Lists.newArrayList(); + for (Entry mapping : mappings.entrySet()) + { + remappings.add(new ModRemapping(mapping.getValue()[0], mapping.getValue()[1], mapping.getKey())); + } + + Collections.sort(remappings, new Comparator() { + @Override + public int compare(ModRemapping o1, ModRemapping o2) + { + return (o1.newId < o2.newId) ? -1 : ((o1.newId == o2.newId) ? 0 : 1); + } + }); + remappedIds = ImmutableList.copyOf(remappings); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/event/FMLPostInitializationEvent.java b/src/main/java/cpw/mods/fml/common/event/FMLPostInitializationEvent.java new file mode 100644 index 0000000..0f58605 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/event/FMLPostInitializationEvent.java @@ -0,0 +1,50 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.event; + +import com.google.common.base.Throwables; + +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.LoaderState.ModState; + +public class FMLPostInitializationEvent extends FMLStateEvent +{ + public FMLPostInitializationEvent(Object... data) + { + super(data); + } + + @Override + public ModState getModState() + { + return ModState.POSTINITIALIZED; + } + + public Object buildSoftDependProxy(String modId, String className) + { + if (Loader.isModLoaded(modId)) + { + try + { + Class clz = Class.forName(className,true,Loader.instance().getModClassLoader()); + return clz.newInstance(); + } + catch (Exception e) + { + Throwables.propagateIfPossible(e); + return null; + } + } + return null; + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/event/FMLPreInitializationEvent.java b/src/main/java/cpw/mods/fml/common/event/FMLPreInitializationEvent.java new file mode 100644 index 0000000..00021d0 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/event/FMLPreInitializationEvent.java @@ -0,0 +1,132 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.event; + +import java.io.File; +import java.security.CodeSource; +import java.security.cert.Certificate; +import java.util.Properties; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import cpw.mods.fml.common.LoaderState.ModState; +import cpw.mods.fml.common.FMLModContainer; +import cpw.mods.fml.common.ModContainer; +import cpw.mods.fml.common.ModMetadata; +import cpw.mods.fml.common.discovery.ASMDataTable; + +public class FMLPreInitializationEvent extends FMLStateEvent +{ + private ModMetadata modMetadata; + private File sourceFile; + private File configurationDir; + private File suggestedConfigFile; + private ASMDataTable asmData; + private ModContainer modContainer; + + public FMLPreInitializationEvent(Object... data) + { + super(data); + this.asmData = (ASMDataTable)data[0]; + this.configurationDir = (File)data[1]; + } + + @Override + public ModState getModState() + { + return ModState.PREINITIALIZED; + } + + @Override + public void applyModContainer(ModContainer activeContainer) + { + this.modContainer = activeContainer; + this.modMetadata = activeContainer.getMetadata(); + this.sourceFile = activeContainer.getSource(); + this.suggestedConfigFile = new File(configurationDir, activeContainer.getModId()+".cfg"); + } + + public File getSourceFile() + { + return sourceFile; + } + + public ModMetadata getModMetadata() + { + return modMetadata; + } + + public File getModConfigurationDirectory() + { + return configurationDir; + } + + public File getSuggestedConfigurationFile() + { + return suggestedConfigFile; + } + + public ASMDataTable getAsmData() + { + return asmData; + } + + public Properties getVersionProperties() + { + if (this.modContainer instanceof FMLModContainer) + { + return ((FMLModContainer)this.modContainer).searchForVersionProperties(); + } + + return null; + } + + /** + * Get a logger instance configured to write to the FML Log as a parent, identified by modid. Handy for mod logging! + * Configurations can be applied through the config/logging.properties file, specifying logging levels + * for your ModID. Use this! + * + * @return A logger + */ + public Logger getModLog() + { + Logger log = LogManager.getLogger(modContainer.getModId()); + return log; + } + + + /** + * Retrieve the FML signing certificates, if any. Validate these against the + * published FML certificates in your mod, if you wish. + * + * Deprecated because mods should NOT trust this code. Rather + * they should copy this, or something like this, into their own mods. + * + * @return Certificates used to sign FML and Forge + */ + @Deprecated + public Certificate[] getFMLSigningCertificates() + { + CodeSource codeSource = getClass().getClassLoader().getParent().getClass().getProtectionDomain().getCodeSource(); + Certificate[] certs = codeSource.getCertificates(); + if (certs == null) + { + return new Certificate[0]; + } + else + { + return certs; + } + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/event/FMLServerAboutToStartEvent.java b/src/main/java/cpw/mods/fml/common/event/FMLServerAboutToStartEvent.java new file mode 100644 index 0000000..2f6edc7 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/event/FMLServerAboutToStartEvent.java @@ -0,0 +1,37 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.event; + +import net.minecraft.server.MinecraftServer; +import cpw.mods.fml.common.LoaderState.ModState; + +public class FMLServerAboutToStartEvent extends FMLStateEvent { + + private MinecraftServer server; + + public FMLServerAboutToStartEvent(Object... data) + { + super(data); + this.server = (MinecraftServer) data[0]; + } + @Override + public ModState getModState() + { + return ModState.AVAILABLE; + } + + public MinecraftServer getServer() + { + return server; + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/event/FMLServerStartedEvent.java b/src/main/java/cpw/mods/fml/common/event/FMLServerStartedEvent.java new file mode 100644 index 0000000..5884e03 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/event/FMLServerStartedEvent.java @@ -0,0 +1,31 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.event; + +import cpw.mods.fml.common.LoaderState.ModState; + +public class FMLServerStartedEvent extends FMLStateEvent +{ + + public FMLServerStartedEvent(Object... data) + { + super(data); + } + + @Override + public ModState getModState() + { + return ModState.AVAILABLE; + } + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/event/FMLServerStartingEvent.java b/src/main/java/cpw/mods/fml/common/event/FMLServerStartingEvent.java new file mode 100644 index 0000000..ad9a396 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/event/FMLServerStartingEvent.java @@ -0,0 +1,46 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.event; + +import net.minecraft.command.CommandHandler; +import net.minecraft.command.ICommand; +import net.minecraft.server.MinecraftServer; +import cpw.mods.fml.common.LoaderState.ModState; + +public class FMLServerStartingEvent extends FMLStateEvent +{ + + private MinecraftServer server; + + public FMLServerStartingEvent(Object... data) + { + super(data); + this.server = (MinecraftServer) data[0]; + } + @Override + public ModState getModState() + { + return ModState.AVAILABLE; + } + + public MinecraftServer getServer() + { + return server; + } + + public void registerServerCommand(ICommand command) + { + CommandHandler ch = (CommandHandler) getServer().getCommandManager(); + ch.registerCommand(command); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/event/FMLServerStoppedEvent.java b/src/main/java/cpw/mods/fml/common/event/FMLServerStoppedEvent.java new file mode 100644 index 0000000..8cdacb7 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/event/FMLServerStoppedEvent.java @@ -0,0 +1,29 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.event; + +import cpw.mods.fml.common.LoaderState.ModState; + +public class FMLServerStoppedEvent extends FMLStateEvent { + + public FMLServerStoppedEvent(Object... data) + { + super(data); + } + @Override + public ModState getModState() + { + return ModState.AVAILABLE; + } + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/event/FMLServerStoppingEvent.java b/src/main/java/cpw/mods/fml/common/event/FMLServerStoppingEvent.java new file mode 100644 index 0000000..c2568e6 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/event/FMLServerStoppingEvent.java @@ -0,0 +1,31 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.event; + +import cpw.mods.fml.common.LoaderState.ModState; + +public class FMLServerStoppingEvent extends FMLStateEvent +{ + + public FMLServerStoppingEvent(Object... data) + { + super(data); + } + + @Override + public ModState getModState() + { + return ModState.AVAILABLE; + } + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/event/FMLStateEvent.java b/src/main/java/cpw/mods/fml/common/event/FMLStateEvent.java new file mode 100644 index 0000000..b24a1ea --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/event/FMLStateEvent.java @@ -0,0 +1,32 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.event; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.LoaderState.ModState; +import cpw.mods.fml.relauncher.Side; + +public abstract class FMLStateEvent extends FMLEvent +{ + public FMLStateEvent(Object... data) + { + + } + + public abstract ModState getModState(); + + public Side getSide() + { + return FMLCommonHandler.instance().getSide(); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/eventhandler/ASMEventHandler.java b/src/main/java/cpw/mods/fml/common/eventhandler/ASMEventHandler.java new file mode 100644 index 0000000..ffa0f13 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/eventhandler/ASMEventHandler.java @@ -0,0 +1,143 @@ +package cpw.mods.fml.common.eventhandler; + +import static org.objectweb.asm.Opcodes.*; + +import java.lang.reflect.Method; +import java.util.HashMap; + + +import org.apache.logging.log4j.ThreadContext; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.MethodVisitor; +import org.objectweb.asm.Type; + +import com.google.common.collect.Maps; +import cpw.mods.fml.common.ModContainer; + + +public class ASMEventHandler implements IEventListener +{ + private static int IDs = 0; + private static final String HANDLER_DESC = Type.getInternalName(IEventListener.class); + private static final String HANDLER_FUNC_DESC = Type.getMethodDescriptor(IEventListener.class.getDeclaredMethods()[0]); + private static final ASMClassLoader LOADER = new ASMClassLoader(); + private static final HashMap> cache = Maps.newHashMap(); + + private final IEventListener handler; + private final SubscribeEvent subInfo; + private ModContainer owner; + public ASMEventHandler(Object target, Method method, ModContainer owner) throws Exception + { + this.owner = owner; + handler = (IEventListener)createWrapper(method).getConstructor(Object.class).newInstance(target); + subInfo = method.getAnnotation(SubscribeEvent.class); + } + + @Override + public void invoke(Event event) + { + if (owner != null) + { + ThreadContext.put("mod", owner.getName()); + } + else + { + ThreadContext.put("mod", ""); + } + if (handler != null) + { + if (!event.isCancelable() || !event.isCanceled() || subInfo.receiveCanceled()) + { + handler.invoke(event); + } + } + ThreadContext.remove("mod"); + } + + public EventPriority getPriority() + { + return subInfo.priority(); + } + + public Class createWrapper(Method callback) + { + if (cache.containsKey(callback)) + { + return cache.get(callback); + } + + ClassWriter cw = new ClassWriter(0); + MethodVisitor mv; + + String name = getUniqueName(callback); + String desc = name.replace('.', '/'); + String instType = Type.getInternalName(callback.getDeclaringClass()); + String eventType = Type.getInternalName(callback.getParameterTypes()[0]); + + /* + System.out.println("Name: " + name); + System.out.println("Desc: " + desc); + System.out.println("InstType: " + instType); + System.out.println("Callback: " + callback.getName() + Type.getMethodDescriptor(callback)); + System.out.println("Event: " + eventType); + */ + + cw.visit(V1_6, ACC_PUBLIC | ACC_SUPER, desc, null, "java/lang/Object", new String[]{ HANDLER_DESC }); + + cw.visitSource(".dynamic", null); + { + cw.visitField(ACC_PUBLIC, "instance", "Ljava/lang/Object;", null, null).visitEnd(); + } + { + mv = cw.visitMethod(ACC_PUBLIC, "", "(Ljava/lang/Object;)V", null, null); + mv.visitCode(); + mv.visitVarInsn(ALOAD, 0); + mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "", "()V"); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 1); + mv.visitFieldInsn(PUTFIELD, desc, "instance", "Ljava/lang/Object;"); + mv.visitInsn(RETURN); + mv.visitMaxs(2, 2); + mv.visitEnd(); + } + { + mv = cw.visitMethod(ACC_PUBLIC, "invoke", HANDLER_FUNC_DESC, null, null); + mv.visitCode(); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETFIELD, desc, "instance", "Ljava/lang/Object;"); + mv.visitTypeInsn(CHECKCAST, instType); + mv.visitVarInsn(ALOAD, 1); + mv.visitTypeInsn(CHECKCAST, eventType); + mv.visitMethodInsn(INVOKEVIRTUAL, instType, callback.getName(), Type.getMethodDescriptor(callback)); + mv.visitInsn(RETURN); + mv.visitMaxs(2, 2); + mv.visitEnd(); + } + cw.visitEnd(); + Class ret = LOADER.define(name, cw.toByteArray()); + cache.put(callback, ret); + return ret; + } + + private String getUniqueName(Method callback) + { + return String.format("%s_%d_%s_%s_%s", getClass().getName(), IDs++, + callback.getDeclaringClass().getSimpleName(), + callback.getName(), + callback.getParameterTypes()[0].getSimpleName()); + } + + private static class ASMClassLoader extends ClassLoader + { + private ASMClassLoader() + { + super(ASMClassLoader.class.getClassLoader()); + } + + public Class define(String name, byte[] data) + { + return defineClass(name, data, 0, data.length); + } + } + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/eventhandler/Cancelable.java b/src/main/java/cpw/mods/fml/common/eventhandler/Cancelable.java new file mode 100644 index 0000000..d3f926e --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/eventhandler/Cancelable.java @@ -0,0 +1,11 @@ +package cpw.mods.fml.common.eventhandler; + +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +@Retention(value = RUNTIME) +@Target(value = TYPE) +public @interface Cancelable{} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/eventhandler/Event.java b/src/main/java/cpw/mods/fml/common/eventhandler/Event.java new file mode 100644 index 0000000..ca7302f --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/eventhandler/Event.java @@ -0,0 +1,156 @@ +package cpw.mods.fml.common.eventhandler; + +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Annotation; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + + +/** + * Base Event class that all other events are derived from + */ +public class Event +{ + @Retention(value = RUNTIME) + @Target(value = TYPE) + public @interface HasResult{} + + public enum Result + { + DENY, + DEFAULT, + ALLOW + } + + private boolean isCanceled = false; + private final boolean isCancelable; + private Result result = Result.DEFAULT; + private final boolean hasResult; + private static ListenerList listeners = new ListenerList(); + + private static final Map, Map, Boolean>> annotationMap = new ConcurrentHashMap, Map, Boolean>>(); + + public Event() + { + setup(); + isCancelable = hasAnnotation(Cancelable.class); + hasResult = hasAnnotation(HasResult.class); + } + + private boolean hasAnnotation(Class annotation) + { + Class me = this.getClass(); + Map, Boolean> list = annotationMap.get(me); + if (list == null) + { + list = new ConcurrentHashMap, Boolean>(); + annotationMap.put(me, list); + } + + Boolean cached = list.get(annotation); + if (cached != null) + { + return cached; + } + + Class cls = me; + while (cls != Event.class) + { + if (cls.isAnnotationPresent(annotation)) + { + list.put(annotation, true); + return true; + } + cls = cls.getSuperclass(); + } + + list.put(annotation, false); + return false; + } + + /** + * Determine if this function is cancelable at all. + * @return If access to setCanceled should be allowed + */ + public boolean isCancelable() + { + return isCancelable; + } + + /** + * Determine if this event is canceled and should stop executing. + * @return The current canceled state + */ + public boolean isCanceled() + { + return isCanceled; + } + + /** + * Sets the state of this event, not all events are cancelable, and any attempt to + * cancel a event that can't be will result in a IllegalArgumentException. + * + * The functionality of setting the canceled state is defined on a per-event bases. + * + * @param cancel The new canceled value + */ + public void setCanceled(boolean cancel) + { + if (!isCancelable()) + { + throw new IllegalArgumentException("Attempted to cancel a uncancelable event"); + } + isCanceled = cancel; + } + + /** + * Determines if this event expects a significant result value. + */ + public boolean hasResult() + { + return hasResult; + } + + /** + * Returns the value set as the result of this event + */ + public Result getResult() + { + return result; + } + + /** + * Sets the result value for this event, not all events can have a result set, and any attempt to + * set a result for a event that isn't expecting it will result in a IllegalArgumentException. + * + * The functionality of setting the result is defined on a per-event bases. + * + * @param value The new result + */ + public void setResult(Result value) + { + result = value; + } + /** + * Called by the base constructor, this is used by ASM generated + * event classes to setup various functionality such as the listenerlist. + */ + protected void setup() + { + } + + /** + * Returns a ListenerList object that contains all listeners + * that are registered to this event. + * + * @return Listener List + */ + public ListenerList getListenerList() + { + return listeners; + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/eventhandler/EventBus.java b/src/main/java/cpw/mods/fml/common/eventhandler/EventBus.java new file mode 100644 index 0000000..c2cd809 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/eventhandler/EventBus.java @@ -0,0 +1,126 @@ +package cpw.mods.fml.common.eventhandler; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import org.apache.logging.log4j.Level; + + + +import com.google.common.collect.MapMaker; +import com.google.common.reflect.TypeToken; +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.ModContainer; + +public class EventBus +{ + private static int maxID = 0; + + private ConcurrentHashMap> listeners = new ConcurrentHashMap>(); + private Map listenerOwners = new MapMaker().weakKeys().weakValues().makeMap(); + private final int busID = maxID++; + + public EventBus() + { + ListenerList.resize(busID + 1); + } + + public void register(Object target) + { + if (listeners.containsKey(target)) + { + return; + } + + ModContainer activeModContainer = Loader.instance().activeModContainer(); + if (activeModContainer == null) + { + FMLLog.log(Level.ERROR, new Throwable(), "Unable to determine registrant mod for %s. This is a critical error and should be impossible", target); + activeModContainer = Loader.instance().getMinecraftModContainer(); + } + listenerOwners.put(target, activeModContainer); + Set> supers = TypeToken.of(target.getClass()).getTypes().rawTypes(); + for (Method method : target.getClass().getMethods()) + { + for (Class cls : supers) + { + try + { + Method real = cls.getDeclaredMethod(method.getName(), method.getParameterTypes()); + if (real.isAnnotationPresent(SubscribeEvent.class)) + { + Class[] parameterTypes = method.getParameterTypes(); + if (parameterTypes.length != 1) + { + throw new IllegalArgumentException( + "Method " + method + " has @SubscribeEvent annotation, but requires " + parameterTypes.length + + " arguments. Event handler methods must require a single argument." + ); + } + + Class eventType = parameterTypes[0]; + + if (!Event.class.isAssignableFrom(eventType)) + { + throw new IllegalArgumentException("Method " + method + " has @SubscribeEvent annotation, but takes a argument that is not an Event " + eventType); + } + + register(eventType, target, method, activeModContainer); + break; + } + } + catch (NoSuchMethodException e) + { + ; + } + } + } + } + + private void register(Class eventType, Object target, Method method, ModContainer owner) + { + try + { + Constructor ctr = eventType.getConstructor(); + ctr.setAccessible(true); + Event event = (Event)ctr.newInstance(); + ASMEventHandler listener = new ASMEventHandler(target, method, owner); + event.getListenerList().register(busID, listener.getPriority(), listener); + + ArrayList others = listeners.get(target); + if (others == null) + { + others = new ArrayList(); + listeners.put(target, others); + } + others.add(listener); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + public void unregister(Object object) + { + ArrayList list = listeners.remove(object); + for (IEventListener listener : list) + { + ListenerList.unregisterAll(busID, listener); + } + } + + public boolean post(Event event) + { + IEventListener[] listeners = event.getListenerList().getListeners(busID); + for (IEventListener listener : listeners) + { + listener.invoke(event); + } + return (event.isCancelable() ? event.isCanceled() : false); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/eventhandler/EventPriority.java b/src/main/java/cpw/mods/fml/common/eventhandler/EventPriority.java new file mode 100644 index 0000000..ee6ad07 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/eventhandler/EventPriority.java @@ -0,0 +1,16 @@ +package cpw.mods.fml.common.eventhandler; + +public enum EventPriority +{ + /*Priority of event listeners, listeners will be sorted with respect to this priority level. + * + * Note: + * Due to using a ArrayList in the ListenerList, + * these need to stay in a contiguous index starting at 0. {Default ordinal} + */ + HIGHEST, //First to execute + HIGH, + NORMAL, + LOW, + LOWEST //Last to execute +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/eventhandler/IEventListener.java b/src/main/java/cpw/mods/fml/common/eventhandler/IEventListener.java new file mode 100644 index 0000000..2b2fb75 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/eventhandler/IEventListener.java @@ -0,0 +1,8 @@ +package cpw.mods.fml.common.eventhandler; + + + +public interface IEventListener +{ + public void invoke(Event event); +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/eventhandler/ListenerList.java b/src/main/java/cpw/mods/fml/common/eventhandler/ListenerList.java new file mode 100644 index 0000000..50aeeb7 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/eventhandler/ListenerList.java @@ -0,0 +1,219 @@ +package cpw.mods.fml.common.eventhandler; + +import java.util.*; + + +public class ListenerList +{ + private static ArrayList allLists = new ArrayList(); + private static int maxSize = 0; + + private ListenerList parent; + private ListenerListInst[] lists = new ListenerListInst[0]; + + public ListenerList() + { + allLists.add(this); + resizeLists(maxSize); + } + + public ListenerList(ListenerList parent) + { + allLists.add(this); + this.parent = parent; + resizeLists(maxSize); + } + + public static void resize(int max) + { + if (max <= maxSize) + { + return; + } + for (ListenerList list : allLists) + { + list.resizeLists(max); + } + maxSize = max; + } + + public void resizeLists(int max) + { + if (parent != null) + { + parent.resizeLists(max); + } + + if (lists.length >= max) + { + return; + } + + ListenerListInst[] newList = new ListenerListInst[max]; + int x = 0; + for (; x < lists.length; x++) + { + newList[x] = lists[x]; + } + for(; x < max; x++) + { + if (parent != null) + { + newList[x] = new ListenerListInst(parent.getInstance(x)); + } + else + { + newList[x] = new ListenerListInst(); + } + } + lists = newList; + } + + public static void clearBusID(int id) + { + for (ListenerList list : allLists) + { + list.lists[id].dispose(); + } + } + + protected ListenerListInst getInstance(int id) + { + return lists[id]; + } + + public IEventListener[] getListeners(int id) + { + return lists[id].getListeners(); + } + + public void register(int id, EventPriority priority, IEventListener listener) + { + lists[id].register(priority, listener); + } + + public void unregister(int id, IEventListener listener) + { + lists[id].unregister(listener); + } + + public static void unregisterAll(int id, IEventListener listener) + { + for (ListenerList list : allLists) + { + list.unregister(id, listener); + } + } + + private class ListenerListInst + { + private boolean rebuild = true; + private IEventListener[] listeners; + private ArrayList> priorities; + private ListenerListInst parent; + + private ListenerListInst() + { + int count = EventPriority.values().length; + priorities = new ArrayList>(count); + + for (int x = 0; x < count; x++) + { + priorities.add(new ArrayList()); + } + } + + public void dispose() + { + for (ArrayList listeners : priorities) + { + listeners.clear(); + } + priorities.clear(); + parent = null; + listeners = null; + } + + private ListenerListInst(ListenerListInst parent) + { + this(); + this.parent = parent; + } + + /** + * Returns a ArrayList containing all listeners for this event, + * and all parent events for the specified priority. + * + * The list is returned with the listeners for the children events first. + * + * @param priority The Priority to get + * @return ArrayList containing listeners + */ + public ArrayList getListeners(EventPriority priority) + { + ArrayList ret = new ArrayList(priorities.get(priority.ordinal())); + if (parent != null) + { + ret.addAll(parent.getListeners(priority)); + } + return ret; + } + + /** + * Returns a full list of all listeners for all priority levels. + * Including all parent listeners. + * + * List is returned in proper priority order. + * + * Automatically rebuilds the internal Array cache if its information is out of date. + * + * @return Array containing listeners + */ + public IEventListener[] getListeners() + { + if (shouldRebuild()) buildCache(); + return listeners; + } + + protected boolean shouldRebuild() + { + return rebuild || (parent != null && parent.shouldRebuild()); + } + + /** + * Rebuild the local Array of listeners, returns early if there is no work to do. + */ + private void buildCache() + { + if(parent != null && parent.shouldRebuild()) + { + parent.buildCache(); + } + + ArrayList ret = new ArrayList(); + for (EventPriority value : EventPriority.values()) + { + ret.addAll(getListeners(value)); + } + listeners = ret.toArray(new IEventListener[ret.size()]); + rebuild = false; + } + + public void register(EventPriority priority, IEventListener listener) + { + priorities.get(priority.ordinal()).add(listener); + rebuild = true; + } + + public void unregister(IEventListener listener) + { + for(ArrayList list : priorities) + { + if (list.remove(listener)) + { + rebuild = true; + } + } + } + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/eventhandler/SubscribeEvent.java b/src/main/java/cpw/mods/fml/common/eventhandler/SubscribeEvent.java new file mode 100644 index 0000000..55531b2 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/eventhandler/SubscribeEvent.java @@ -0,0 +1,15 @@ +package cpw.mods.fml.common.eventhandler; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import static java.lang.annotation.RetentionPolicy.*; +import static java.lang.annotation.ElementType.*; + +@Retention(value = RUNTIME) +@Target(value = METHOD) +public @interface SubscribeEvent +{ + public EventPriority priority() default EventPriority.NORMAL; + public boolean receiveCanceled() default false; +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/functions/ArtifactVersionNameFunction.java b/src/main/java/cpw/mods/fml/common/functions/ArtifactVersionNameFunction.java new file mode 100644 index 0000000..9e18630 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/functions/ArtifactVersionNameFunction.java @@ -0,0 +1,13 @@ +package cpw.mods.fml.common.functions; + +import com.google.common.base.Function; + +import cpw.mods.fml.common.versioning.ArtifactVersion; + +public class ArtifactVersionNameFunction implements Function { + @Override + public String apply(ArtifactVersion v) + { + return v.getLabel(); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/functions/ModIdFunction.java b/src/main/java/cpw/mods/fml/common/functions/ModIdFunction.java new file mode 100644 index 0000000..cc81cd7 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/functions/ModIdFunction.java @@ -0,0 +1,26 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.functions; + +import com.google.common.base.Function; + +import cpw.mods.fml.common.ModContainer; + +public final class ModIdFunction implements Function +{ + @Override + public String apply(ModContainer container) + { + return container.getModId(); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/functions/ModNameFunction.java b/src/main/java/cpw/mods/fml/common/functions/ModNameFunction.java new file mode 100644 index 0000000..8eb6093 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/functions/ModNameFunction.java @@ -0,0 +1,27 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.functions; + +import com.google.common.base.Function; + +import cpw.mods.fml.common.ModContainer; + +public class ModNameFunction implements Function +{ + @Override + public String apply(ModContainer input) + { + return input.getName(); + } + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/gameevent/InputEvent.java b/src/main/java/cpw/mods/fml/common/gameevent/InputEvent.java new file mode 100644 index 0000000..5fb25ef --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/gameevent/InputEvent.java @@ -0,0 +1,8 @@ +package cpw.mods.fml.common.gameevent; + +import cpw.mods.fml.common.eventhandler.Event; + +public class InputEvent extends Event { + public static class MouseInputEvent extends InputEvent {} + public static class KeyInputEvent extends InputEvent {} +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/gameevent/PlayerEvent.java b/src/main/java/cpw/mods/fml/common/gameevent/PlayerEvent.java new file mode 100644 index 0000000..ef999d5 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/gameevent/PlayerEvent.java @@ -0,0 +1,75 @@ +package cpw.mods.fml.common.gameevent; + +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import cpw.mods.fml.common.eventhandler.Event; + +public class PlayerEvent extends Event { + public final EntityPlayer player; + private PlayerEvent(EntityPlayer player) + { + this.player = player; + } + + public static class ItemPickupEvent extends PlayerEvent { + public final EntityItem pickedUp; + public ItemPickupEvent(EntityPlayer player, EntityItem pickedUp) + { + super(player); + this.pickedUp = pickedUp; + } + } + + public static class ItemCraftedEvent extends PlayerEvent { + public final ItemStack crafting; + public final IInventory craftMatrix; + public ItemCraftedEvent(EntityPlayer player, ItemStack crafting, IInventory craftMatrix) + { + super(player); + this.crafting = crafting; + this.craftMatrix = craftMatrix; + } + } + public static class ItemSmeltedEvent extends PlayerEvent { + public final ItemStack smelting; + public ItemSmeltedEvent(EntityPlayer player, ItemStack crafting) + { + super(player); + this.smelting = crafting; + } + } + + public static class PlayerLoggedInEvent extends PlayerEvent { + public PlayerLoggedInEvent(EntityPlayer player) + { + super(player); + } + } + + public static class PlayerLoggedOutEvent extends PlayerEvent { + public PlayerLoggedOutEvent(EntityPlayer player) + { + super(player); + } + } + + public static class PlayerRespawnEvent extends PlayerEvent { + public PlayerRespawnEvent(EntityPlayer player) + { + super(player); + } + } + + public static class PlayerChangedDimensionEvent extends PlayerEvent { + public final int fromDim; + public final int toDim; + public PlayerChangedDimensionEvent(EntityPlayer player, int fromDim, int toDim) + { + super(player); + this.fromDim = fromDim; + this.toDim = toDim; + } + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/gameevent/TickEvent.java b/src/main/java/cpw/mods/fml/common/gameevent/TickEvent.java new file mode 100644 index 0000000..52ad9f7 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/gameevent/TickEvent.java @@ -0,0 +1,67 @@ +package cpw.mods.fml.common.gameevent; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.world.World; +import cpw.mods.fml.common.eventhandler.Event; +import cpw.mods.fml.relauncher.Side; + +public class TickEvent extends Event { + public enum Type { + WORLD, PLAYER, CLIENT, SERVER, RENDER; + } + + public enum Phase { + START, END; + } + public final Type type; + public final Side side; + public final Phase phase; + public TickEvent(Type type, Side side, Phase phase) + { + this.type = type; + this.side = side; + this.phase = phase; + } + + public static class ServerTickEvent extends TickEvent { + public ServerTickEvent(Phase phase) + { + super(Type.SERVER, Side.SERVER, phase); + } + } + + public static class ClientTickEvent extends TickEvent { + public ClientTickEvent(Phase phase) + { + super(Type.CLIENT, Side.CLIENT, phase); + } + } + + public static class WorldTickEvent extends TickEvent { + public final World world; + public WorldTickEvent(Side side, Phase phase, World world) + { + super(Type.WORLD, side, phase); + this.world = world; + } + } + public static class PlayerTickEvent extends TickEvent { + public final EntityPlayer player; + + public PlayerTickEvent(Phase phase, EntityPlayer player) + { + super(Type.PLAYER, player instanceof EntityPlayerMP ? Side.SERVER : Side.CLIENT, phase); + this.player = player; + } + } + + public static class RenderTickEvent extends TickEvent { + public final float renderTickTime; + public RenderTickEvent(Phase phase, float renderTickTime) + { + super(Type.RENDER, Side.CLIENT, phase); + this.renderTickTime = renderTickTime; + } + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/launcher/FMLDeobfTweaker.java b/src/main/java/cpw/mods/fml/common/launcher/FMLDeobfTweaker.java new file mode 100644 index 0000000..b7fbd3b --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/launcher/FMLDeobfTweaker.java @@ -0,0 +1,64 @@ +package cpw.mods.fml.common.launcher; + +import java.io.File; +import java.lang.reflect.Method; +import java.util.List; + +import cpw.mods.fml.relauncher.CoreModManager; +import cpw.mods.fml.relauncher.FMLInjectionData; +import cpw.mods.fml.relauncher.FMLRelaunchLog; + +import net.minecraft.launchwrapper.ITweaker; +import net.minecraft.launchwrapper.Launch; +import net.minecraft.launchwrapper.LaunchClassLoader; + +public class FMLDeobfTweaker implements ITweaker { + @Override + public void acceptOptions(List args, File gameDir, File assetsDir, String profile) + { + } + + @Override + public void injectIntoClassLoader(LaunchClassLoader classLoader) + { + // Deobfuscation transformer, always last, and the access transformer tweaker as well + if (!(Boolean)Launch.blackboard.get("fml.deobfuscatedEnvironment")) + { + classLoader.registerTransformer("cpw.mods.fml.common.asm.transformers.DeobfuscationTransformer"); + } + // Add all the access transformers now as well + for (String transformer : CoreModManager.getAccessTransformers()) + { + classLoader.registerTransformer(transformer); + } + try + { + FMLRelaunchLog.fine("Validating minecraft"); + Class loaderClazz = Class.forName("cpw.mods.fml.common.Loader", true, classLoader); + Method m = loaderClazz.getMethod("injectData", Object[].class); + m.invoke(null, (Object)FMLInjectionData.data()); + m = loaderClazz.getMethod("instance"); + m.invoke(null); + FMLRelaunchLog.fine("Minecraft validated, launching..."); + } + catch (Exception e) + { + // Load in the Loader, make sure he's ready to roll - this will initialize most of the rest of minecraft here + System.out.println("A CRITICAL PROBLEM OCCURED INITIALIZING MINECRAFT - LIKELY YOU HAVE AN INCORRECT VERSION FOR THIS FML"); + throw new RuntimeException(e); + } + } + + @Override + public String getLaunchTarget() + { + throw new RuntimeException("Invalid for use as a primary tweaker"); + } + + @Override + public String[] getLaunchArguments() + { + return new String[0]; + } + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/launcher/FMLInjectionAndSortingTweaker.java b/src/main/java/cpw/mods/fml/common/launcher/FMLInjectionAndSortingTweaker.java new file mode 100644 index 0000000..4ad84e2 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/launcher/FMLInjectionAndSortingTweaker.java @@ -0,0 +1,54 @@ +package cpw.mods.fml.common.launcher; + +import java.io.File; +import java.util.List; + +import cpw.mods.fml.relauncher.CoreModManager; + +import net.minecraft.launchwrapper.ITweaker; +import net.minecraft.launchwrapper.LaunchClassLoader; + +/** + * This class is to manage the injection of coremods as tweakers into the tweak framework. + * It has to inject the coremod tweaks during construction, because that is the only time + * the tweak list is writeable. + * @author cpw + * + */ +public class FMLInjectionAndSortingTweaker implements ITweaker { + private boolean run; + public FMLInjectionAndSortingTweaker() + { + CoreModManager.injectCoreModTweaks(this); + run = false; + } + + @Override + public void acceptOptions(List args, File gameDir, File assetsDir, String profile) + { + if (!run) + { + // We sort the tweak list here so that it obeys the tweakordering + CoreModManager.sortTweakList(); + } + run = true; + } + + @Override + public void injectIntoClassLoader(LaunchClassLoader classLoader) + { + } + + @Override + public String getLaunchTarget() + { + return ""; + } + + @Override + public String[] getLaunchArguments() + { + return new String[0]; + } + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/launcher/FMLServerTweaker.java b/src/main/java/cpw/mods/fml/common/launcher/FMLServerTweaker.java new file mode 100644 index 0000000..1b83a5b --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/launcher/FMLServerTweaker.java @@ -0,0 +1,24 @@ +package cpw.mods.fml.common.launcher; + +import cpw.mods.fml.relauncher.FMLLaunchHandler; +import net.minecraft.launchwrapper.LaunchClassLoader; + +public class FMLServerTweaker extends FMLTweaker { + @Override + public String getLaunchTarget() + { + return "net.minecraft.server.MinecraftServer"; + } + + @Override + public void injectIntoClassLoader(LaunchClassLoader classLoader) + { + classLoader.addClassLoaderExclusion("com.mojang.util."); + classLoader.addTransformerExclusion("cpw.mods.fml.repackage."); + classLoader.addTransformerExclusion("cpw.mods.fml.relauncher."); + classLoader.addTransformerExclusion("cpw.mods.fml.common.asm.transformers."); + classLoader.addClassLoaderExclusion("LZMA."); + FMLLaunchHandler.configureForServerLaunch(classLoader, this); + FMLLaunchHandler.appendCoreMods(); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/launcher/FMLTweaker.java b/src/main/java/cpw/mods/fml/common/launcher/FMLTweaker.java new file mode 100644 index 0000000..7148544 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/launcher/FMLTweaker.java @@ -0,0 +1,154 @@ +package cpw.mods.fml.common.launcher; + +import java.io.File; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import net.minecraft.launchwrapper.ITweaker; +import net.minecraft.launchwrapper.Launch; +import net.minecraft.launchwrapper.LaunchClassLoader; + +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.LogManager; + +import com.google.common.base.Throwables; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; + +import cpw.mods.fml.relauncher.FMLLaunchHandler; + +public class FMLTweaker implements ITweaker { + private File gameDir; + private Map launchArgs; + private List standaloneArgs; + private static URI jarLocation; + + @SuppressWarnings("unchecked") + @Override + public void acceptOptions(List args, File gameDir, File assetsDir, String profile) + { + this.gameDir = (gameDir == null ? new File(".") : gameDir); + + this.launchArgs = (Map)Launch.blackboard.get("launchArgs"); + + this.standaloneArgs = Lists.newArrayList(); + if (this.launchArgs == null) + { + this.launchArgs = Maps.newHashMap(); + Launch.blackboard.put("launchArgs", this.launchArgs); + } + + String classifier = null; + + for (String arg : args) + { + if (arg.startsWith("-")) + { + if (classifier != null) + { + classifier = launchArgs.put(classifier, ""); + } + else if (arg.contains("=")) + { + classifier = launchArgs.put(arg.substring(0, arg.indexOf('=')), arg.substring(arg.indexOf('=') + 1)); + } + else + { + classifier = arg; + } + } + else + { + if (classifier != null) + { + classifier = launchArgs.put(classifier, arg); + } + else + { + this.standaloneArgs.add(arg); + } + } + } + + if (!this.launchArgs.containsKey("--version")) + { + launchArgs.put("--version", profile != null ? profile : "UnknownFMLProfile"); + } + + if (!this.launchArgs.containsKey("--gameDir") && gameDir != null) + { + launchArgs.put("--gameDir", gameDir.getAbsolutePath()); + } + + if (!this.launchArgs.containsKey("--assetsDir") && assetsDir != null) + { + launchArgs.put("--assetsDir", assetsDir.getAbsolutePath()); + } + + Yggdrasil.login(launchArgs); + + try + { + jarLocation = getClass().getProtectionDomain().getCodeSource().getLocation().toURI(); + } + catch (URISyntaxException e) + { + LogManager.getLogger("FMLTWEAK").log(Level.ERROR, "Missing URI information for FML tweak"); + throw Throwables.propagate(e); + } + } + + @Override + public void injectIntoClassLoader(LaunchClassLoader classLoader) + { + classLoader.addClassLoaderExclusion("org.apache."); + classLoader.addTransformerExclusion("cpw.mods.fml.repackage."); + classLoader.addTransformerExclusion("cpw.mods.fml.relauncher."); + classLoader.addTransformerExclusion("cpw.mods.fml.common.asm.transformers."); + classLoader.addClassLoaderExclusion("LZMA."); + FMLLaunchHandler.configureForClientLaunch(classLoader, this); + FMLLaunchHandler.appendCoreMods(); + } + + @Override + public String getLaunchTarget() + { + return "net.minecraft.client.main.Main"; + } + + @Override + public String[] getLaunchArguments() + { + List args = Lists.newArrayList(); + args.addAll(standaloneArgs); + + for (Entry arg : launchArgs.entrySet()) + { + args.add(arg.getKey()); + args.add(arg.getValue()); + } + launchArgs.clear(); + + return args.toArray(new String[args.size()]); + } + + public File getGameDir() + { + return gameDir; + } + + public static URI getJarLocation() + { + return jarLocation; + } + + public void injectCascadingTweak(String tweakClassName) + { + @SuppressWarnings("unchecked") + List tweakClasses = (List) Launch.blackboard.get("TweakClasses"); + tweakClasses.add(tweakClassName); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/launcher/Yggdrasil.java b/src/main/java/cpw/mods/fml/common/launcher/Yggdrasil.java new file mode 100644 index 0000000..c176dd2 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/launcher/Yggdrasil.java @@ -0,0 +1,132 @@ +package cpw.mods.fml.common.launcher; + +import java.io.Closeable; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.List; +import java.util.Map; + +import org.apache.commons.io.IOUtils; + +import com.google.common.base.Charsets; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +/** + * Basic implementation of Mojang's 'Yggdrasil' login system, purely intended as a dev time bare bones login. + * Login errors are not handled. + */ +@SuppressWarnings("unused") +public class Yggdrasil { + private static class Request { + Agent agent = new Agent(); + String username; + String password; + String clientToken = null; + boolean requestUser = true; + + public Request(String username, String password){ + this.username = username; + this.password = password; + } + + private static class Agent { + String name = "Minecraft"; + int version = 1; + } + } + + private static class Response { + String error; + String errorMessage; + String cause; + String accessToken; + String clientToken; + Profile selectedProfile; + Profile[] availableProfiles; + User user; + + private static class Profile { + String id; + String name; + boolean legacy; + } + + private static class User { + String id; + List properties; + + private static class Property { + String name; + String value; + } + } + } + + private static void close(Closeable c) + { + if (c != null) { + try { + c.close(); + } catch (IOException e){} + } + } + + public static void login(Map args) + { + if (!args.containsKey("--username") || !args.containsKey("--password")) return; + + String username = args.get("--username"); + String password = args.remove("--password"); + + Gson GSON = new GsonBuilder().setPrettyPrinting().create(); + String request = GSON.toJson(new Request(username, password)); + + OutputStream out = null; + InputStream in = null; + + try + { + HttpURLConnection con = (HttpURLConnection)(new URL("https://authserver.mojang.com/authenticate")).openConnection(); + con.setConnectTimeout(15000); + con.setReadTimeout(15000); + con.setUseCaches(false); + + byte[] data = request.getBytes(Charsets.UTF_8); + + con.setRequestProperty("Content-Type", "application/json; charset=utf-8"); + con.setRequestProperty("Content-Length", Integer.toString(data.length)); + con.setDoOutput(true); + + out = con.getOutputStream(); + out.write(data); + + in = con.getInputStream(); + Response result = GSON.fromJson(IOUtils.toString(in, Charsets.UTF_8), Response.class); + + if (result.selectedProfile != null) + { + args.put("--username", result.selectedProfile.name); + args.put("--uuid", result.selectedProfile.id); + args.put("--accessToken", result.accessToken); + } + } + catch (MalformedURLException e) + { + e.printStackTrace(); + } + catch (IOException e) + { + e.printStackTrace(); + } + finally + { + close(out); + close(in); + } + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/network/ByteBufUtils.java b/src/main/java/cpw/mods/fml/common/network/ByteBufUtils.java new file mode 100644 index 0000000..c0c4156 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/network/ByteBufUtils.java @@ -0,0 +1,283 @@ +package cpw.mods.fml.common.network; + +import java.io.IOException; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.PacketBuffer; +import org.apache.commons.lang3.Validate; + +import com.google.common.base.Charsets; +import com.google.common.base.Throwables; + +import io.netty.buffer.ByteBuf; + +/** + * Utilities for interacting with {@link ByteBuf}. + * @author cpw + * + */ +public class ByteBufUtils { + /** + * The number of bytes to write the supplied int using the 7 bit varint encoding. + * + * @param toCount The number to analyse + * @return The number of bytes it will take to write it (maximum of 5) + */ + public static int varIntByteCount(int toCount) + { + return (toCount & 0xFFFFFF80) == 0 ? 1 : ((toCount & 0xFFFFC000) == 0 ? 2 : ((toCount & 0xFFE00000) == 0 ? 3 : ((toCount & 0xF0000000) == 0 ? 4 : 5))); + } + /** + * Read a varint from the supplied buffer. + * + * @param buf The buffer to read from + * @param maxSize The maximum length of bytes to read + * @return The integer + */ + public static int readVarInt(ByteBuf buf, int maxSize) + { + Validate.isTrue(maxSize < 6 && maxSize > 0, "Varint length is between 1 and 5, not %d", maxSize); + int i = 0; + int j = 0; + byte b0; + + do + { + b0 = buf.readByte(); + i |= (b0 & 127) << j++ * 7; + + if (j > maxSize) + { + throw new RuntimeException("VarInt too big"); + } + } + while ((b0 & 128) == 128); + + return i; + } + /** + * An extended length short. Used by custom payload packets to extend size. + * + * @param buf + * @return + */ + public static int readVarShort(ByteBuf buf) + { + int low = buf.readUnsignedShort(); + int high = 0; + if ((low & 0x8000) != 0) + { + low = low & 0x7FFF; + high = buf.readUnsignedByte(); + } + return ((high & 0xFF) << 15) | low; + } + + public static void writeVarShort(ByteBuf buf, int toWrite) + { + int low = toWrite & 0x7FFF; + int high = ( toWrite & 0x7F8000 ) >> 15; + if (high != 0) + { + low = low | 0x8000; + } + buf.writeShort(low); + if (high != 0) + { + buf.writeByte(high); + } + } + /** + * Write an integer to the buffer using variable length encoding. The maxSize constrains + * how many bytes (and therefore the maximum number) that will be written. + * + * @param to The buffer to write to + * @param toWrite The integer to write + * @param maxSize The maximum number of bytes to use + */ + public static void writeVarInt(ByteBuf to, int toWrite, int maxSize) + { + Validate.isTrue(varIntByteCount(toWrite) <= maxSize, "Integer is too big for %d bytes", maxSize); + while ((toWrite & -128) != 0) + { + to.writeByte(toWrite & 127 | 128); + toWrite >>>= 7; + } + + to.writeByte(toWrite); + } + /** + * Read a UTF8 string from the byte buffer. + * It is encoded as [] + * + * @param from The buffer to read from + * @return The string + */ + public static String readUTF8String(ByteBuf from) + { + int len = readVarInt(from,2); + String str = from.toString(from.readerIndex(), len, Charsets.UTF_8); + from.readerIndex(from.readerIndex() + len); + return str; + } + + /** + * Write a String with UTF8 byte encoding to the buffer. + * It is encoded as [] + * @param to the buffer to write to + * @param string The string to write + */ + public static void writeUTF8String(ByteBuf to, String string) + { + byte[] utf8Bytes = string.getBytes(Charsets.UTF_8); + Validate.isTrue(varIntByteCount(utf8Bytes.length) < 3, "The string is too long for this encoding."); + writeVarInt(to, utf8Bytes.length, 2); + to.writeBytes(utf8Bytes); + } + + /** + * Write an {@link ItemStack} using minecraft compatible encoding. + * + * @param to The buffer to write to + * @param stack The itemstack to write + */ + public static void writeItemStack(ByteBuf to, ItemStack stack) + { + PacketBuffer pb = new PacketBuffer(to); + try + { + pb.writeItemStackToBuffer(stack); + } catch (IOException e) + { + // Unpossible? + throw Throwables.propagate(e); + } + } + + /** + * Read an {@link ItemStack} from the byte buffer provided. It uses the minecraft encoding. + * + * @param from The buffer to read from + * @return The itemstack read + */ + public static ItemStack readItemStack(ByteBuf from) + { + PacketBuffer pb = new PacketBuffer(from); + try + { + return pb.readItemStackFromBuffer(); + } catch (IOException e) + { + // Unpossible? + throw Throwables.propagate(e); + } + } + + /** + * Write an {@link NBTTagCompound} to the byte buffer. It uses the minecraft encoding. + * + * @param to The buffer to write to + * @param tag The tag to write + */ + public static void writeTag(ByteBuf to, NBTTagCompound tag) + { + PacketBuffer pb = new PacketBuffer(to); + try + { + pb.writeNBTTagCompoundToBuffer(tag); + } catch (IOException e) + { + // Unpossible? + throw Throwables.propagate(e); + } + } + + /** + * Read an {@link NBTTagCompound} from the byte buffer. It uses the minecraft encoding. + * + * @param from The buffer to read from + * @return The read tag + */ + public static NBTTagCompound readTag(ByteBuf from) + { + PacketBuffer pb = new PacketBuffer(from); + try + { + return pb.readNBTTagCompoundFromBuffer(); + } catch (IOException e) + { + // Unpossible? + throw Throwables.propagate(e); + } + } + + public static String getContentDump(ByteBuf buffer) + { + int currentLength = buffer.readableBytes(); + StringBuffer returnString = new StringBuffer((currentLength * 3) + // The + // hex + (currentLength) + // The ascii + (currentLength / 4) + // The tabs/\n's + 30); // The text + + // returnString.append("Buffer contents:\n"); + int i, j; // Loop variables + for (i = 0; i < currentLength; i++) + { + if ((i != 0) && (i % 16 == 0)) + { + // If it's a multiple of 16 and i isn't null, show the ascii + returnString.append('\t'); + for (j = i - 16; j < i; j++) + { + if (buffer.getByte(j) < 0x20 || buffer.getByte(j) > 0x7F) + returnString.append('.'); + else + returnString.append((char) buffer.getByte(j)); + } + // Add a linefeed after the string + returnString.append("\n"); + } + + returnString.append(Integer.toString((buffer.getByte(i) & 0xF0) >> 4, 16) + Integer.toString((buffer.getByte(i) & 0x0F) >> 0, 16)); + returnString.append(' '); + } + + // Add padding spaces if it's not a multiple of 16 + if (i != 0 && i % 16 != 0) + { + for (j = 0; j < ((16 - (i % 16)) * 3); j++) + { + returnString.append(' '); + } + } + // Add the tab for alignment + returnString.append('\t'); + + // Add final chararacters at right, after padding + + // If it was at the end of a line, print out the full line + if (i > 0 && (i % 16) == 0) + { + j = i - 16; + } else + { + j = (i - (i % 16)); + } + + for (; i >= 0 && j < i; j++) + { + if (buffer.getByte(j) < 0x20 || buffer.getByte(j) > 0x7F) + returnString.append('.'); + else + returnString.append((char) buffer.getByte(j)); + } + + // Finally, tidy it all up with a newline + returnString.append('\n'); + returnString.append("Length: " + currentLength); + + return returnString.toString(); + + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/network/FMLEmbeddedChannel.java b/src/main/java/cpw/mods/fml/common/network/FMLEmbeddedChannel.java new file mode 100644 index 0000000..dd23ab8 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/network/FMLEmbeddedChannel.java @@ -0,0 +1,67 @@ +package cpw.mods.fml.common.network; + +import io.netty.channel.ChannelHandler; +import io.netty.channel.embedded.EmbeddedChannel; +import java.util.Map.Entry; +import net.minecraft.network.Packet; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.ModContainer; +import cpw.mods.fml.common.network.FMLOutboundHandler.OutboundTarget; +import cpw.mods.fml.common.network.internal.FMLProxyPacket; +import cpw.mods.fml.relauncher.Side; + +/** + * Utility wrapper around {@link EmbeddedChannel}. Provides some convenience methods + * associated with the specific needs of FML network handling. + * + * @author cpw + * + */ +public class FMLEmbeddedChannel extends EmbeddedChannel { + public FMLEmbeddedChannel(String channelName, Side source, ChannelHandler... handlers) + { + this(Loader.instance().activeModContainer(), channelName, source, handlers); + } + public FMLEmbeddedChannel(ModContainer container, String channelName, Side source, ChannelHandler... handlers) + { + super(handlers); + this.attr(NetworkRegistry.FML_CHANNEL).set(channelName); + this.attr(NetworkRegistry.CHANNEL_SOURCE).set(source); + this.attr(NetworkRegistry.MOD_CONTAINER).setIfAbsent(container); + this.pipeline().addFirst("fml:outbound",new FMLOutboundHandler()); + } + + + /** + * Utility method to generate a regular packet from a custom packet. Basically, it writes the packet through the + * outbound side which should have a message to message codec present (such as {@link FMLIndexedMessageToMessageCodec}, + * transforming from mod packets to standard {@link FMLProxyPacket}s. + * + * This is mostly useful in cases where vanilla expects a packet, such as the TileEntity getDescriptionPacket. + * + * @param object The inbound packet + * @return A Packet suitable for passing to vanilla network code. + */ + public Packet generatePacketFrom(Object object) + { + OutboundTarget outboundTarget = attr(FMLOutboundHandler.FML_MESSAGETARGET).getAndSet(OutboundTarget.NOWHERE); + writeOutbound(object); + Packet pkt = (Packet) outboundMessages().poll(); + attr(FMLOutboundHandler.FML_MESSAGETARGET).set(outboundTarget); + return pkt; + } + + public String findChannelHandlerNameForType(Class type) + { + String targetName = null; + for (Entry entry : pipeline()) + { + if (type.isInstance(entry.getValue())) + { + targetName = entry.getKey(); + break; + } + } + return targetName; + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/network/FMLEventChannel.java b/src/main/java/cpw/mods/fml/common/network/FMLEventChannel.java new file mode 100644 index 0000000..36fc6ac --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/network/FMLEventChannel.java @@ -0,0 +1,175 @@ +package cpw.mods.fml.common.network; + +import io.netty.channel.ChannelFutureListener; +import io.netty.channel.ChannelHandlerContext; +import java.util.EnumMap; +import net.minecraft.client.network.NetHandlerPlayClient; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.network.NetHandlerPlayServer; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.eventhandler.EventBus; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.network.internal.FMLProxyPacket; +import cpw.mods.fml.relauncher.Side; + +/** + * An event driven network channel, using {@link FMLNetworkEvent.CustomPacketEvent} and {@link FMLNetworkEvent.CustomNetworkEvent} + * to deliver messages to an event listener. There is one "bus" for each channel, due to the + * impossibility of filtering a bus for specific events. + * + * This event driven system completely wraps the netty code. Mod code deals with FMLProxyPackets directly. It is not + * possible to enhance the netty pipeline, and I would expect highly unexpected results if it were modified reflectively. + * Use a real ChannelHandler if you want to use netty. + * + * @author cpw + * + */ +public class FMLEventChannel { + private EnumMap channels; + private EventBus eventBus; + + /* + * This is done this way so that the CLIENT specific code in the factory only loads on the client + */ + private enum EventFactory + { + SERVER() + { + @Override + FMLNetworkEvent.CustomPacketEvent make(FMLProxyPacket msg) + { + FMLNetworkEvent.CustomPacketEvent event = null; + if (msg.handler() instanceof NetHandlerPlayServer) + { + NetHandlerPlayServer server = (NetHandlerPlayServer) msg.handler(); + event = new FMLNetworkEvent.ServerCustomPacketEvent(server.func_147362_b(), msg); + } + return event; + } + }, + CLIENT() + { + @Override + FMLNetworkEvent.CustomPacketEvent make(FMLProxyPacket msg) + { + FMLNetworkEvent.CustomPacketEvent event = null; + if (msg.handler() instanceof NetHandlerPlayClient) + { + NetHandlerPlayClient client = (NetHandlerPlayClient) msg.handler(); + event = new FMLNetworkEvent.ClientCustomPacketEvent(client.getNetworkManager(), msg); + } + else if (msg.handler() instanceof NetHandlerPlayServer) + { + NetHandlerPlayServer server = (NetHandlerPlayServer) msg.handler(); + event = new FMLNetworkEvent.ServerCustomPacketEvent(server.func_147362_b(), msg); + } + return event; + } + }; + abstract FMLNetworkEvent.CustomPacketEvent make(FMLProxyPacket msg); + } + + private static EventFactory factory = FMLCommonHandler.instance().getSide() == Side.CLIENT ? EventFactory.CLIENT : EventFactory.SERVER; + FMLEventChannel(String name) + { + this.channels = NetworkRegistry.INSTANCE.newChannel(name, new NetworkEventFiringHandler(this)); + this.eventBus = new EventBus(); + } + + /** + * Register an event listener with this channel and bus. See {@link SubscribeEvent} + * + * @param object + */ + public void register(Object object) + { + this.eventBus.register(object); + } + + /** + * Unregister an event listener from the bus. + * @param object + */ + public void unregister(Object object) + { + this.eventBus.unregister(object); + } + + void fireRead(FMLProxyPacket msg, ChannelHandlerContext ctx) + { + FMLNetworkEvent.CustomPacketEvent event = factory.make(msg); + if (event != null) + { + this.eventBus.post(event); + if (event.reply != null) + { + ctx.channel().attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.REPLY); + ctx.writeAndFlush(event.reply).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); + } + } + } + + public void fireUserEvent(Object evt, ChannelHandlerContext ctx) + { + FMLNetworkEvent.CustomNetworkEvent event = new FMLNetworkEvent.CustomNetworkEvent(evt); + this.eventBus.post(event); + } + + /** + * Send a packet to all on the server + * + * @param pkt + */ + public void sendToAll(FMLProxyPacket pkt) + { + channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALL); + channels.get(Side.SERVER).writeAndFlush(pkt).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); + } + + /** + * Send to a specific player + * + * @param pkt + * @param player + */ + public void sendTo(FMLProxyPacket pkt, EntityPlayerMP player) + { + channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.PLAYER); + channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(player); + channels.get(Side.SERVER).writeAndFlush(pkt).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); + } + + /** + * Send to all around a point + * @param pkt + * @param point + */ + public void sendToAllAround(FMLProxyPacket pkt, NetworkRegistry.TargetPoint point) + { + channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALLAROUNDPOINT); + channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(point); + channels.get(Side.SERVER).writeAndFlush(pkt).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); + } + + /** + * Send to all in a dimension + * @param pkt + * @param dimensionId + */ + public void sendToDimension(FMLProxyPacket pkt, int dimensionId) + { + channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.DIMENSION); + channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(dimensionId); + channels.get(Side.SERVER).writeAndFlush(pkt).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); + } + + /** + * Send to the server + * @param pkt + */ + public void sendToServer(FMLProxyPacket pkt) + { + channels.get(Side.CLIENT).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.TOSERVER); + channels.get(Side.CLIENT).writeAndFlush(pkt).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/network/FMLIndexedMessageToMessageCodec.java b/src/main/java/cpw/mods/fml/common/network/FMLIndexedMessageToMessageCodec.java new file mode 100644 index 0000000..81cf39c --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/network/FMLIndexedMessageToMessageCodec.java @@ -0,0 +1,94 @@ +package cpw.mods.fml.common.network; + +import gnu.trove.map.hash.TByteObjectHashMap; +import gnu.trove.map.hash.TObjectByteHashMap; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; +import io.netty.channel.ChannelHandler.Sharable; +import io.netty.channel.ChannelHandlerContext; +import io.netty.handler.codec.MessageToMessageCodec; +import io.netty.util.AttributeKey; +import java.util.List; +import org.apache.logging.log4j.Level; +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.network.internal.FMLProxyPacket; + +@Sharable +public abstract class FMLIndexedMessageToMessageCodec extends MessageToMessageCodec { + private TByteObjectHashMap> discriminators = new TByteObjectHashMap>(); + private TObjectByteHashMap> types = new TObjectByteHashMap>(); + + /** + * Make this accessible to subclasses + */ + + protected static final AttributeKey> INBOUNDPACKETTRACKER = new AttributeKey>("fml:inboundpacket"); + + @Override + public void handlerAdded(ChannelHandlerContext ctx) throws Exception + { + super.handlerAdded(ctx); + ctx.attr(INBOUNDPACKETTRACKER).set(new ThreadLocal()); + } + + public FMLIndexedMessageToMessageCodec addDiscriminator(int discriminator, Class type) + { + discriminators.put((byte)discriminator, type); + types.put(type, (byte)discriminator); + return this; + } + + public abstract void encodeInto(ChannelHandlerContext ctx, A msg, ByteBuf target) throws Exception; + @Override + protected final void encode(ChannelHandlerContext ctx, A msg, List out) throws Exception + { + ByteBuf buffer = Unpooled.buffer(); + @SuppressWarnings("unchecked") // Stupid unnecessary cast I can't seem to kill + Class clazz = (Class) msg.getClass(); + byte discriminator = types.get(clazz); + buffer.writeByte(discriminator); + encodeInto(ctx, msg, buffer); + FMLProxyPacket proxy = new FMLProxyPacket(buffer.copy(), ctx.channel().attr(NetworkRegistry.FML_CHANNEL).get()); + FMLProxyPacket old = ctx.attr(INBOUNDPACKETTRACKER).get().get(); + if (old != null) + { + proxy.setDispatcher(old.getDispatcher()); + } + out.add(proxy); + } + + public abstract void decodeInto(ChannelHandlerContext ctx, ByteBuf source, A msg); + + @Override + protected final void decode(ChannelHandlerContext ctx, FMLProxyPacket msg, List out) throws Exception + { + testMessageValidity(msg); + ByteBuf payload = msg.payload(); + byte discriminator = payload.readByte(); + Class clazz = discriminators.get(discriminator); + if(clazz == null) + { + throw new NullPointerException("Undefined message for discriminator " + discriminator + " in channel " + msg.channel()); + } + A newMsg = clazz.newInstance(); + ctx.attr(INBOUNDPACKETTRACKER).get().set(msg); + decodeInto(ctx, payload.slice(), newMsg); + out.add(newMsg); + } + + /** + * Called to verify the message received. This can be used to hard disconnect in case of an unexpected packet, + * say due to a weird protocol mismatch. Use with caution. + * @param msg + */ + protected void testMessageValidity(FMLProxyPacket msg) + { + } + + @Override + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception + { + FMLLog.log(Level.ERROR, cause, "FMLIndexedMessageCodec exception caught"); + super.exceptionCaught(ctx, cause); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/network/FMLNetworkEvent.java b/src/main/java/cpw/mods/fml/common/network/FMLNetworkEvent.java new file mode 100644 index 0000000..91ce6ab --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/network/FMLNetworkEvent.java @@ -0,0 +1,168 @@ +package cpw.mods.fml.common.network; + +import java.util.Set; +import com.google.common.collect.ImmutableSet; +import net.minecraft.network.INetHandler; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.play.INetHandlerPlayClient; +import net.minecraft.network.play.INetHandlerPlayServer; +import cpw.mods.fml.common.eventhandler.Event; +import cpw.mods.fml.common.network.internal.FMLProxyPacket; +import cpw.mods.fml.relauncher.Side; + +public class FMLNetworkEvent extends Event { + public final T handler; + public final NetworkManager manager; + @SuppressWarnings("unused") + private final Class type; + + FMLNetworkEvent(T thing, Class type, NetworkManager manager) + { + this.handler = thing; + this.type = type; + this.manager = manager; + } + /** + * Fired at the client when a client connects to a server + * @author cpw + * + */ + public static class ClientConnectedToServerEvent extends FMLNetworkEvent { + public final boolean isLocal; + public final String connectionType; + public ClientConnectedToServerEvent(NetworkManager manager, String connectionType) + { + super((INetHandlerPlayClient) manager.getNetHandler(), INetHandlerPlayClient.class, manager); + this.isLocal = manager.isLocalChannel(); + this.connectionType = connectionType; + } + } + + /** + * Fired at the server when a client connects to the server. + * + * @author cpw + * + */ + public static class ServerConnectionFromClientEvent extends FMLNetworkEvent { + public final boolean isLocal; + public ServerConnectionFromClientEvent(NetworkManager manager) + { + super((INetHandlerPlayServer) manager.getNetHandler(), INetHandlerPlayServer.class, manager); + this.isLocal = manager.isLocalChannel(); + } + } + /** + * Fired at the server when a client disconnects. + * + * @author cpw + * + */ + public static class ServerDisconnectionFromClientEvent extends FMLNetworkEvent { + public ServerDisconnectionFromClientEvent(NetworkManager manager) + { + super((INetHandlerPlayServer) manager.getNetHandler(), INetHandlerPlayServer.class, manager); + } + } + /** + * Fired at the client when the client is disconnected from the server. + * + * @author cpw + * + */ + public static class ClientDisconnectionFromServerEvent extends FMLNetworkEvent { + public ClientDisconnectionFromServerEvent(NetworkManager manager) + { + super((INetHandlerPlayClient) manager.getNetHandler(), INetHandlerPlayClient.class, manager); + } + } + + /** + * Fired when the REGISTER/UNREGISTER for custom channels is received. + * + * @author cpw + * + * @param The side + */ + public static class CustomPacketRegistrationEvent extends FMLNetworkEvent { + public final ImmutableSet registrations; + public final String operation; + public final Side side; + public CustomPacketRegistrationEvent(NetworkManager manager, Set registrations, String operation, Side side, Class type) + { + super(type.cast(manager.getNetHandler()), type, manager); + this.registrations = ImmutableSet.copyOf(registrations); + this.side = side; + this.operation = operation; + } + } + + public static abstract class CustomPacketEvent extends FMLNetworkEvent { + /** + * The packet that generated the event + */ + public final FMLProxyPacket packet; + + /** + * Set this packet to reply to the originator + */ + public FMLProxyPacket reply; + CustomPacketEvent(S thing, Class type, NetworkManager manager, FMLProxyPacket packet) + { + super(thing, type, manager); + this.packet = packet; + } + + public abstract Side side(); + } + + /** + * Fired when a custom packet is received on the client for the channel + * @author cpw + * + */ + public static class ClientCustomPacketEvent extends CustomPacketEvent { + public ClientCustomPacketEvent(NetworkManager manager, FMLProxyPacket packet) + { + super((INetHandlerPlayClient) manager.getNetHandler(), INetHandlerPlayClient.class, manager, packet); + } + + @Override + public Side side() + { + return Side.CLIENT; + } + } + + /** + * Fired when a custom packet is received at the server for the channel + * @author cpw + * + */ + public static class ServerCustomPacketEvent extends CustomPacketEvent { + public ServerCustomPacketEvent(NetworkManager manager, FMLProxyPacket packet) + { + super((INetHandlerPlayServer) manager.getNetHandler(), INetHandlerPlayServer.class, manager, packet); + } + + @Override + public Side side() + { + return Side.SERVER; + } + } + + /** + * Fired when a custom event, such as {@link NetworkHandshakeEstablished} is fired for the channel + * + * @author cpw + * + */ + public static class CustomNetworkEvent extends Event { + public final Object wrappedEvent; + public CustomNetworkEvent(Object wrappedEvent) + { + this.wrappedEvent = wrappedEvent; + } + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/network/FMLNetworkException.java b/src/main/java/cpw/mods/fml/common/network/FMLNetworkException.java new file mode 100644 index 0000000..194bdcb --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/network/FMLNetworkException.java @@ -0,0 +1,32 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.network; + +public class FMLNetworkException extends RuntimeException +{ + private static final long serialVersionUID = 1L; + + public FMLNetworkException(Exception e) + { + super(e); + } + + public FMLNetworkException() + { + } + + public FMLNetworkException(String string) + { + super(string); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/network/FMLOutboundHandler.java b/src/main/java/cpw/mods/fml/common/network/FMLOutboundHandler.java new file mode 100644 index 0000000..0f094f2 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/network/FMLOutboundHandler.java @@ -0,0 +1,286 @@ +package cpw.mods.fml.common.network; + +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelOutboundHandlerAdapter; +import io.netty.channel.ChannelPromise; +import io.netty.channel.embedded.EmbeddedChannel; +import io.netty.util.AttributeKey; +import java.util.List; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.network.NetworkManager; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; +import cpw.mods.fml.common.network.handshake.NetworkDispatcher; +import cpw.mods.fml.common.network.internal.FMLProxyPacket; +import cpw.mods.fml.relauncher.Side; + +public class FMLOutboundHandler extends ChannelOutboundHandlerAdapter { + public static final AttributeKey FML_MESSAGETARGET = new AttributeKey("fml:outboundTarget"); + public static final AttributeKey FML_MESSAGETARGETARGS = new AttributeKey("fml:outboundTargetArgs"); + public enum OutboundTarget { + /** + * The packet is sent nowhere. It will be on the {@link EmbeddedChannel#outboundMessages()} Queue. + * + * @author cpw + * + */ + NOWHERE(Sets.immutableEnumSet(Side.CLIENT, Side.SERVER)) + { + @Override + public void validateArgs(Object args) + { + // NOOP + } + + @Override + public List selectNetworks(Object args, ChannelHandlerContext context, FMLProxyPacket packet) + { + return null; + } + + }, + /** + * The packet is sent to the {@link NetworkDispatcher} supplied as an argument. + * + * @author cpw + * + */ + DISPATCHER(Sets.immutableEnumSet(Side.SERVER)) + { + @Override + public void validateArgs(Object args) + { + if (!(args instanceof NetworkDispatcher)) + { + throw new RuntimeException("DISPATCHER expects a NetworkDispatcher"); + } + } + + @Override + public List selectNetworks(Object args, ChannelHandlerContext context, FMLProxyPacket packet) + { + return ImmutableList.of((NetworkDispatcher)args); + } + }, + /** + * The packet is sent to the originator of the packet. This requires the inbound packet + * to have it's originator information set. + * + * @author cpw + * + */ + REPLY(Sets.immutableEnumSet(Side.SERVER)) + { + @Override + public void validateArgs(Object args) + { + // NOOP + } + + @Override + public List selectNetworks(Object args, ChannelHandlerContext context, FMLProxyPacket packet) + { + return ImmutableList.of(packet.getDispatcher()); + } + }, + /** + * The packet is sent to the {@link EntityPlayerMP} supplied as an argument. + * + * @author cpw + * + */ + PLAYER(Sets.immutableEnumSet(Side.SERVER)) + { + @Override + public void validateArgs(Object args) + { + if (!(args instanceof EntityPlayerMP)) + { + throw new RuntimeException("PLAYER target expects a Player arg"); + } + } + @Override + public List selectNetworks(Object args, ChannelHandlerContext context, FMLProxyPacket packet) + { + EntityPlayerMP player = (EntityPlayerMP) args; + NetworkDispatcher dispatcher = player.playerNetServerHandler.netManager.channel().attr(NetworkDispatcher.FML_DISPATCHER).get(); + return ImmutableList.of(dispatcher); + } + }, + /** + * The packet is dispatched to all players connected to the server. + * @author cpw + * + */ + ALL(Sets.immutableEnumSet(Side.SERVER)) + { + @Override + public void validateArgs(Object args) + { + } + @SuppressWarnings("unchecked") + @Override + public List selectNetworks(Object args, ChannelHandlerContext context, FMLProxyPacket packet) + { + ImmutableList.Builder builder = ImmutableList.builder(); + for (EntityPlayerMP player : (List)FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().playerEntityList) + { + NetworkDispatcher dispatcher = player.playerNetServerHandler.netManager.channel().attr(NetworkDispatcher.FML_DISPATCHER).get(); + builder.add(dispatcher); + } + return builder.build(); + } + }, + /** + * The packet is sent to all players in the dimension identified by the integer argument. + * @author cpw + * + */ + DIMENSION(Sets.immutableEnumSet(Side.SERVER)) + { + @Override + public void validateArgs(Object args) + { + if (!(args instanceof Integer)) + { + throw new RuntimeException("DIMENSION expects an integer argument"); + } + } + @SuppressWarnings("unchecked") + @Override + public List selectNetworks(Object args, ChannelHandlerContext context, FMLProxyPacket packet) + { + int dimension = (Integer)args; + ImmutableList.Builder builder = ImmutableList.builder(); + for (EntityPlayerMP player : (List)FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().playerEntityList) + { + if (dimension == player.dimension) + { + NetworkDispatcher dispatcher = player.playerNetServerHandler.netManager.channel().attr(NetworkDispatcher.FML_DISPATCHER).get(); + builder.add(dispatcher); + } + } + return builder.build(); + } + }, + /** + * The packet is sent to all players within range of the {@link TargetPoint} argument supplied. + * + * @author cpw + * + */ + ALLAROUNDPOINT(Sets.immutableEnumSet(Side.SERVER)) + { + @Override + public void validateArgs(Object args) + { + if (!(args instanceof TargetPoint)) + { + throw new RuntimeException("ALLAROUNDPOINT expects a TargetPoint argument"); + } + } + + @SuppressWarnings("unchecked") + @Override + public List selectNetworks(Object args, ChannelHandlerContext context, FMLProxyPacket packet) + { + TargetPoint tp = (TargetPoint)args; + ImmutableList.Builder builder = ImmutableList.builder(); + for (EntityPlayerMP player : (List)FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().playerEntityList) + { + if (player.dimension == tp.dimension) + { + double d4 = tp.x - player.posX; + double d5 = tp.y - player.posY; + double d6 = tp.z - player.posZ; + + if (d4 * d4 + d5 * d5 + d6 * d6 < tp.range * tp.range) + { + NetworkDispatcher dispatcher = player.playerNetServerHandler.netManager.channel().attr(NetworkDispatcher.FML_DISPATCHER).get(); + builder.add(dispatcher); + } + } + } + return builder.build(); + } + }, + /** + * The packet is sent to the server this client is currently conversing with. + * @author cpw + * + */ + TOSERVER(Sets.immutableEnumSet(Side.CLIENT)) + { + @Override + public void validateArgs(Object args) + { + } + @Override + public List selectNetworks(Object args, ChannelHandlerContext context, FMLProxyPacket packet) + { + NetworkManager clientConnection = FMLCommonHandler.instance().getClientToServerNetworkManager(); + return clientConnection == null ? ImmutableList.of() : ImmutableList.of(clientConnection.channel().attr(NetworkDispatcher.FML_DISPATCHER).get()); + } + }; + + private OutboundTarget(ImmutableSet sides) + { + this.allowed = sides; + } + public final ImmutableSet allowed; + public abstract void validateArgs(Object args); + public abstract List selectNetworks(Object args, ChannelHandlerContext context, FMLProxyPacket packet); + } + + @Override + public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception + { + if (!(msg instanceof FMLProxyPacket)) + { + return; + } + FMLProxyPacket pkt = (FMLProxyPacket) msg; + OutboundTarget outboundTarget; + Object args = null; + NetworkDispatcher dispatcher = ctx.channel().attr(NetworkDispatcher.FML_DISPATCHER).get(); + // INTERNAL message callback - let it pass out + if (dispatcher != null) + { + ctx.write(msg, promise); + return; + } + + outboundTarget = ctx.channel().attr(FML_MESSAGETARGET).get(); + Side channelSide = ctx.channel().attr(NetworkRegistry.CHANNEL_SOURCE).get(); + if (outboundTarget != null && outboundTarget.allowed.contains(channelSide)) + { + args = ctx.channel().attr(FML_MESSAGETARGETARGS).get(); + outboundTarget.validateArgs(args); + } + else if (channelSide == Side.CLIENT) + { + outboundTarget = OutboundTarget.TOSERVER; + } + else + { + throw new FMLNetworkException("Packet arrived at the outbound handler without a valid target!"); + } + + List dispatchers = outboundTarget.selectNetworks(args, ctx, pkt); + + // This will drop the messages into the output queue at the embedded channel + if (dispatchers == null) + { + ctx.write(msg, promise); + return; + } + for (NetworkDispatcher targetDispatcher : dispatchers) + { + targetDispatcher.sendProxy((FMLProxyPacket) msg); + } + } + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/network/IGuiHandler.java b/src/main/java/cpw/mods/fml/common/network/IGuiHandler.java new file mode 100644 index 0000000..ebb38ff --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/network/IGuiHandler.java @@ -0,0 +1,46 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.network; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; + +public interface IGuiHandler +{ + /** + * Returns a Server side Container to be displayed to the user. + * + * @param ID The Gui ID Number + * @param player The player viewing the Gui + * @param world The current world + * @param x X Position + * @param y Y Position + * @param z Z Position + * @return A GuiScreen/Container to be displayed to the user, null if none. + */ + public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z); + /** + * Returns a Container to be displayed to the user. On the client side, this + * needs to return a instance of GuiScreen On the server side, this needs to + * return a instance of Container + * + * @param ID The Gui ID Number + * @param player The player viewing the Gui + * @param world The current world + * @param x X Position + * @param y Y Position + * @param z Z Position + * @return A GuiScreen/Container to be displayed to the user, null if none. + */ + public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z); +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/network/NetworkCheckHandler.java b/src/main/java/cpw/mods/fml/common/network/NetworkCheckHandler.java new file mode 100644 index 0000000..a768871 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/network/NetworkCheckHandler.java @@ -0,0 +1,33 @@ +package cpw.mods.fml.common.network; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import cpw.mods.fml.relauncher.Side; + +/** + * A method annotated with this will be called when a remote network connection is offered. + * The method should have two parameters, of types {@link Map} and {@link Side}. It should return a boolean + * true indicating that the remote party is acceptable, or false if not. + * + *

+ * When the method is invoked, the map will contain String keys and values listing all mods and their versions present. + * The side represents the side of the remote party. So if you're on the server, it'll be CLIENT, and vice versa. + * + *

+ * This method will be invoked both when querying the status of the remote server, and when connecting to the remote server. + * + *

+ * NOTE: the server will not be setup at any point when this method is called. Do not try and interact with the server + * or the client in any way, except to accept or reject the list of mods. + * + * @author cpw + * + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface NetworkCheckHandler +{ + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/network/NetworkEventFiringHandler.java b/src/main/java/cpw/mods/fml/common/network/NetworkEventFiringHandler.java new file mode 100644 index 0000000..9fd0eea --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/network/NetworkEventFiringHandler.java @@ -0,0 +1,44 @@ +package cpw.mods.fml.common.network; + +import org.apache.logging.log4j.Level; +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.network.internal.FMLProxyPacket; +import io.netty.channel.ChannelHandler.Sharable; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.SimpleChannelInboundHandler; + +/** + * Use this handler as the only thing in your channel, to receive network events + * whenever your channel receives a message. + * Note: it will not forward on to other handlers. + * + * @author cpw + * + */ +@Sharable +public class NetworkEventFiringHandler extends SimpleChannelInboundHandler { + private FMLEventChannel eventChannel; + + NetworkEventFiringHandler(FMLEventChannel fmlEventChannel) + { + this.eventChannel = fmlEventChannel; + } + + @Override + protected void channelRead0(ChannelHandlerContext ctx, FMLProxyPacket msg) throws Exception + { + eventChannel.fireRead(msg,ctx); + } + + @Override + public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception + { + eventChannel.fireUserEvent(evt,ctx); + } + @Override + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception + { + FMLLog.log(Level.ERROR, cause, "NetworkEventFiringHandler exception"); + super.exceptionCaught(ctx, cause); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/network/NetworkHandshakeEstablished.java b/src/main/java/cpw/mods/fml/common/network/NetworkHandshakeEstablished.java new file mode 100644 index 0000000..999b37b --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/network/NetworkHandshakeEstablished.java @@ -0,0 +1,28 @@ +package cpw.mods.fml.common.network; + +import net.minecraft.network.INetHandler; +import cpw.mods.fml.common.network.handshake.NetworkDispatcher; +import cpw.mods.fml.relauncher.Side; + +/** + * This message is sent through all channels affected by a currently occurring handshake. It is guaranteed to + * be able to send a custom payload packet, however, interaction with minecraft and world state is NOT assured + * as it is likely this is fired on a netty handler thread, not a world processing thread. + * + * If you wish to send an outbound message through your channel, bind the {@link FMLOutboundHandler#FML_MESSAGETARGET} + * property of your channel to the supplied dispatcher. + * @author cpw + * + */ +public class NetworkHandshakeEstablished { + public final NetworkDispatcher dispatcher; + public final Side side; + public final INetHandler netHandler; + + public NetworkHandshakeEstablished(NetworkDispatcher dispatcher, INetHandler netHandler, Side origin) + { + this.netHandler = netHandler; + this.dispatcher = dispatcher; + this.side = origin; + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/network/NetworkRegistry.java b/src/main/java/cpw/mods/fml/common/network/NetworkRegistry.java new file mode 100644 index 0000000..38e08ef --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/network/NetworkRegistry.java @@ -0,0 +1,320 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.network; + +import io.netty.channel.ChannelHandler; +import io.netty.channel.ChannelHandlerContext; +import io.netty.handler.codec.MessageToMessageCodec; +import io.netty.util.AttributeKey; + +import java.util.EnumMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import org.apache.logging.log4j.Level; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.inventory.Container; +import net.minecraft.network.INetHandler; +import net.minecraft.world.World; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Maps; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.ModContainer; +import cpw.mods.fml.common.discovery.ASMDataTable; +import cpw.mods.fml.common.network.FMLOutboundHandler.OutboundTarget; +import cpw.mods.fml.common.network.handshake.NetworkDispatcher; +import cpw.mods.fml.common.network.internal.FMLProxyPacket; +import cpw.mods.fml.common.network.internal.NetworkModHolder; +import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper; +import cpw.mods.fml.relauncher.Side; + +/** + * @author cpw + * + */ +public enum NetworkRegistry +{ + INSTANCE; + private EnumMap> channels = Maps.newEnumMap(Side.class); + private Map registry = Maps.newHashMap(); + private Map serverGuiHandlers = Maps.newHashMap(); + private Map clientGuiHandlers = Maps.newHashMap(); + + /** + * Set in the {@link ChannelHandlerContext} + */ + public static final AttributeKey FML_CHANNEL = new AttributeKey("fml:channelName"); + public static final AttributeKey CHANNEL_SOURCE = new AttributeKey("fml:channelSource"); + public static final AttributeKey MOD_CONTAINER = new AttributeKey("fml:modContainer"); + public static final AttributeKey NET_HANDLER = new AttributeKey("fml:netHandler"); + + public static final byte FML_PROTOCOL = 1; + + private NetworkRegistry() + { + channels.put(Side.CLIENT, Maps.newConcurrentMap()); + channels.put(Side.SERVER, Maps.newConcurrentMap()); + } + + /** + * Represents a target point for the ALLROUNDPOINT target. + * + * @author cpw + * + */ + public static class TargetPoint { + /** + * A target point + * @param dimension The dimension to target + * @param x The X coordinate + * @param y The Y coordinate + * @param z The Z coordinate + * @param range The range + */ + public TargetPoint(int dimension, double x, double y, double z, double range) + { + this.x = x; + this.y = y; + this.z = z; + this.range = range; + this.dimension = dimension; + } + public final double x; + public final double y; + public final double z; + public final double range; + public final int dimension; + } + /** + * Create a new synchronous message channel pair based on netty. + * + * There are two preconstructed models available: + *

    + *
  • {@link #newSimpleChannel(String)} provides {@link SimpleNetworkWrapper}, a simple implementation of a netty handler, suitable for those who don't + * wish to dive too deeply into netty. + *
  • {@link #newEventChannel(String)} provides {@link FMLEventChannel} an event driven implementation, with lower level + * access to the network data stream, for those with advanced bitbanging needs that don't wish to poke netty too hard. + *
  • Alternatively, simply use the netty features provided here and implement the full power of the netty stack. + *
+ * + * There are two channels created : one for each logical side (considered as the source of an outbound message) + * The returned map will contain a value for each logical side, though both will only be working in the + * integrated server case. + * + * The channel expects to read and write using {@link FMLProxyPacket}. All operation is synchronous, as the + * asynchronous behaviour occurs at a lower level in netty. + * + * The first handler in the pipeline is special and should not be removed or moved from the head - it transforms + * packets from the outbound of this pipeline into custom packets, based on the current {@link AttributeKey} value + * {@link NetworkRegistry#FML_MESSAGETARGET} and {@link NetworkRegistry#FML_MESSAGETARGETARGS} set on the channel. + * For the client to server channel (source side : CLIENT) this is fixed as "TOSERVER". For SERVER to CLIENT packets, + * several possible values exist. + * + * Mod Messages should be transformed using a something akin to a {@link MessageToMessageCodec}. FML provides + * a utility codec, {@link FMLIndexedMessageToMessageCodec} that transforms from {@link FMLProxyPacket} to a mod + * message using a message discriminator byte. This is optional, but highly recommended for use. + * + * Note also that the handlers supplied need to be {@link ChannelHandler.Shareable} - they are injected into two + * channels. + * + * @param name + * @param handlers + * @return + */ + public EnumMap newChannel(String name, ChannelHandler... handlers) + { + if (channels.containsKey(name) || name.startsWith("MC|") || name.startsWith("\u0001") || name.startsWith("FML")) + { + throw new RuntimeException("That channel is already registered"); + } + EnumMap result = Maps.newEnumMap(Side.class); + + for (Side side : Side.values()) + { + FMLEmbeddedChannel channel = new FMLEmbeddedChannel(name, side, handlers); + channels.get(side).put(name,channel); + result.put(side, channel); + } + return result; + } + + /** + * Construct a new {@link SimpleNetworkWrapper} for the channel. + * + * @param name The name of the channel + * @return A {@link SimpleNetworkWrapper} for handling this channel + */ + public SimpleNetworkWrapper newSimpleChannel(String name) + { + return new SimpleNetworkWrapper(name); + } + /** + * Construct a new {@link FMLEventChannel} for the channel. + * + * @param name The name of the channel + * @return An {@link FMLEventChannel} for handling this channel + */ + public FMLEventChannel newEventDrivenChannel(String name) + { + return new FMLEventChannel(name); + } + /** + * INTERNAL Create a new channel pair with the specified name and channel handlers. + * This is used internally in forge and FML + * + * @param container The container to associate the channel with + * @param name The name for the channel + * @param handlers Some {@link ChannelHandler} for the channel + * @return an {@link EnumMap} of the pair of channels. keys are {@link Side}. There will always be two entries. + */ + public EnumMap newChannel(ModContainer container, String name, ChannelHandler... handlers) + { + if (channels.containsKey(name) || name.startsWith("MC|") || name.startsWith("\u0001") || (name.startsWith("FML") && !("FML".equals(container.getModId())))) + { + throw new RuntimeException("That channel is already registered"); + } + EnumMap result = Maps.newEnumMap(Side.class); + + for (Side side : Side.values()) + { + FMLEmbeddedChannel channel = new FMLEmbeddedChannel(container, name, side, handlers); + channels.get(side).put(name,channel); + result.put(side, channel); + } + return result; + } + + public FMLEmbeddedChannel getChannel(String name, Side source) + { + return channels.get(source).get(name); + } + /** + * Register an {@link IGuiHandler} for the supplied mod object. + * + * @param mod The mod to handle GUIs for + * @param handler A handler for creating GUI related objects + */ + public void registerGuiHandler(Object mod, IGuiHandler handler) + { + ModContainer mc = FMLCommonHandler.instance().findContainerFor(mod); + if (mc == null) + { + FMLLog.log(Level.ERROR, "Mod of type %s attempted to register a gui network handler during a construction phase", mod.getClass().getName()); + throw new RuntimeException("Invalid attempt to create a GUI during mod construction. Use an EventHandler instead"); + } + serverGuiHandlers.put(mc, handler); + clientGuiHandlers.put(mc, handler); + } + + /** + * INTERNAL method for accessing the Gui registry + * @param mc Mod Container + * @param player Player + * @param modGuiId guiId + * @param world World + * @param x X coord + * @param y Y coord + * @param z Z coord + * @return The server side GUI object (An instance of {@link Container}) + */ + public Container getRemoteGuiContainer(ModContainer mc, EntityPlayerMP player, int modGuiId, World world, int x, int y, int z) + { + IGuiHandler handler = serverGuiHandlers.get(mc); + + if (handler != null) + { + return (Container)handler.getServerGuiElement(modGuiId, player, world, x, y, z); + } + else + { + return null; + } + } + + /** + * INTERNAL method for accessing the Gui registry + * @param mc Mod Container + * @param player Player + * @param modGuiId guiId + * @param world World + * @param x X coord + * @param y Y coord + * @param z Z coord + * @return The client side GUI object (An instance of {@link GUI}) + */ + public Object getLocalGuiContainer(ModContainer mc, EntityPlayer player, int modGuiId, World world, int x, int y, int z) + { + IGuiHandler handler = clientGuiHandlers.get(mc); + return handler.getClientGuiElement(modGuiId, player, world, x, y, z); + } + + /** + * Is there a channel with this name on this side? + * @param channelName The name + * @param source the side + * @return if there's a channel + */ + public boolean hasChannel(String channelName, Side source) + { + return channels.get(source).containsKey(channelName); + } + + /** + * INTERNAL method for registering a mod as a network capable thing + * @param fmlModContainer The fml mod container + * @param clazz a class + * @param remoteVersionRange the acceptable remote range + * @param asmHarvestedData internal data + */ + public void register(ModContainer fmlModContainer, Class clazz, String remoteVersionRange, ASMDataTable asmHarvestedData) + { + NetworkModHolder networkModHolder = new NetworkModHolder(fmlModContainer, clazz, remoteVersionRange, asmHarvestedData); + registry.put(fmlModContainer, networkModHolder); + } + + public Map registry() + { + return ImmutableMap.copyOf(registry); + } + + /** + * All the valid channel names for a side + * @param side the side + * @return the set of channel names + */ + public Set channelNamesFor(Side side) + { + return channels.get(side).keySet(); + } + + /** + * INTERNAL fire a handshake to all channels + * @param networkDispatcher The dispatcher firing + * @param origin which side the dispatcher is on + */ + public void fireNetworkHandshake(NetworkDispatcher networkDispatcher, Side origin) + { + NetworkHandshakeEstablished handshake = new NetworkHandshakeEstablished(networkDispatcher, networkDispatcher.getNetHandler(), origin); + for (Entry channel : channels.get(origin).entrySet()) + { + channel.getValue().attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.DISPATCHER); + channel.getValue().attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(networkDispatcher); + channel.getValue().pipeline().fireUserEventTriggered(handshake); + } + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/network/handshake/ChannelRegistrationHandler.java b/src/main/java/cpw/mods/fml/common/network/handshake/ChannelRegistrationHandler.java new file mode 100644 index 0000000..6acd632 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/network/handshake/ChannelRegistrationHandler.java @@ -0,0 +1,42 @@ +package cpw.mods.fml.common.network.handshake; + +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.SimpleChannelInboundHandler; +import java.util.Set; +import net.minecraft.network.NetworkManager; +import org.apache.logging.log4j.Level; +import com.google.common.base.Charsets; +import com.google.common.collect.ImmutableSet; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.network.internal.FMLProxyPacket; +import cpw.mods.fml.relauncher.Side; + +public class ChannelRegistrationHandler extends SimpleChannelInboundHandler { + @Override + protected void channelRead0(ChannelHandlerContext ctx, FMLProxyPacket msg) throws Exception + { + Side side = msg.getTarget(); + NetworkManager manager = msg.getOrigin(); + if (msg.channel().equals("REGISTER") || msg.channel().equals("UNREGISTER")) + { + byte[] data = new byte[msg.payload().readableBytes()]; + msg.payload().readBytes(data); + String channels = new String(data,Charsets.UTF_8); + String[] split = channels.split("\0"); + Set channelSet = ImmutableSet.copyOf(split); + FMLCommonHandler.instance().fireNetRegistrationEvent(manager, channelSet, msg.channel(), side); + } + else + { + ctx.fireChannelRead(msg); + } + } + + @Override + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception + { + FMLLog.log(Level.ERROR, cause, "ChannelRegistrationHandler exception"); + super.exceptionCaught(ctx, cause); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/network/handshake/FMLHandshakeClientState.java b/src/main/java/cpw/mods/fml/common/network/handshake/FMLHandshakeClientState.java new file mode 100644 index 0000000..bbd9cd4 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/network/handshake/FMLHandshakeClientState.java @@ -0,0 +1,139 @@ +package cpw.mods.fml.common.network.handshake; + +import java.util.List; +import io.netty.channel.ChannelFutureListener; +import io.netty.channel.ChannelHandlerContext; +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.network.internal.FMLMessage; +import cpw.mods.fml.common.network.internal.FMLNetworkHandler; +import cpw.mods.fml.common.registry.GameData; +import cpw.mods.fml.relauncher.Side; + +/** + * Packet handshake sequence manager- client side (responding to remote server) + * + * Flow: + * 1. Wait for server hello. (START). Move to HELLO state. + * 2. Receive Server Hello. Send customchannel registration. Send Client Hello. Send our modlist. Move to WAITINGFORSERVERDATA state. + * 3. Receive server modlist. Send ack if acceptable, else send nack and exit error. Receive server IDs. Move to COMPLETE state. Send ack. + * + * @author cpw + * + */ +enum FMLHandshakeClientState implements IHandshakeState +{ + START + { + @Override + public FMLHandshakeClientState accept(ChannelHandlerContext ctx, FMLHandshakeMessage msg) + { + NetworkDispatcher dispatcher = ctx.channel().attr(NetworkDispatcher.FML_DISPATCHER).get(); + dispatcher.clientListenForServerHandshake(); + return HELLO; + } + }, + HELLO + { + @Override + public FMLHandshakeClientState accept(ChannelHandlerContext ctx, FMLHandshakeMessage msg) + { + // write our custom packet registration, always + ctx.writeAndFlush(FMLHandshakeMessage.makeCustomChannelRegistration(NetworkRegistry.INSTANCE.channelNamesFor(Side.CLIENT))); + if (msg == null) + { + NetworkDispatcher dispatcher = ctx.channel().attr(NetworkDispatcher.FML_DISPATCHER).get(); + dispatcher.abortClientHandshake("VANILLA"); + // VANILLA login + return DONE; + } + + FMLLog.info("Server protocol version %x", ((FMLHandshakeMessage.ServerHello)msg).protocolVersion()); + ctx.writeAndFlush(new FMLHandshakeMessage.ClientHello()).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); + ctx.writeAndFlush(new FMLHandshakeMessage.ModList(Loader.instance().getActiveModList())).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); + return WAITINGSERVERDATA; + } + }, + + WAITINGSERVERDATA + { + @Override + public FMLHandshakeClientState accept(ChannelHandlerContext ctx, FMLHandshakeMessage msg) + { + String result = FMLNetworkHandler.checkModList((FMLHandshakeMessage.ModList) msg, Side.SERVER); + if (result != null) + { + NetworkDispatcher dispatcher = ctx.channel().attr(NetworkDispatcher.FML_DISPATCHER).get(); + dispatcher.rejectHandshake(result); + return ERROR; + } + ctx.writeAndFlush(new FMLHandshakeMessage.HandshakeAck(ordinal())).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); + if (!ctx.channel().attr(NetworkDispatcher.IS_LOCAL).get()) + { + return WAITINGSERVERCOMPLETE; + } + else + { + return PENDINGCOMPLETE; + } + } + }, + WAITINGSERVERCOMPLETE + { + @Override + public FMLHandshakeClientState accept(ChannelHandlerContext ctx, FMLHandshakeMessage msg) + { + FMLHandshakeMessage.ModIdData modIds = (FMLHandshakeMessage.ModIdData)msg; + List locallyMissing = GameData.injectWorldIDMap(modIds.dataList(), false, false); + if (!locallyMissing.isEmpty()) + { + NetworkDispatcher dispatcher = ctx.channel().attr(NetworkDispatcher.FML_DISPATCHER).get(); + dispatcher.rejectHandshake("Fatally missing blocks and items"); + FMLLog.severe("Failed to connect to server: there are %d missing blocks and items", locallyMissing.size()); + FMLLog.fine("Missing list: %s", locallyMissing); + return ERROR; + } + ctx.writeAndFlush(new FMLHandshakeMessage.HandshakeAck(ordinal())).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); + return PENDINGCOMPLETE; + } + }, + PENDINGCOMPLETE + { + @Override + public FMLHandshakeClientState accept(ChannelHandlerContext ctx, FMLHandshakeMessage msg) + { + ctx.writeAndFlush(new FMLHandshakeMessage.HandshakeAck(ordinal())).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); + return COMPLETE; + } + }, + COMPLETE + { + @Override + public FMLHandshakeClientState accept(ChannelHandlerContext ctx, FMLHandshakeMessage msg) + { + NetworkDispatcher dispatcher = ctx.channel().attr(NetworkDispatcher.FML_DISPATCHER).get(); + dispatcher.completeClientHandshake(); + FMLMessage.CompleteHandshake complete = new FMLMessage.CompleteHandshake(Side.CLIENT); + ctx.fireChannelRead(complete); + ctx.writeAndFlush(new FMLHandshakeMessage.HandshakeAck(ordinal())).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); + return DONE; + } + }, + DONE + { + @Override + public FMLHandshakeClientState accept(ChannelHandlerContext ctx, FMLHandshakeMessage msg) + { + return this; + } + }, + ERROR + { + @Override + public FMLHandshakeClientState accept(ChannelHandlerContext ctx, FMLHandshakeMessage msg) + { + return this; + } + }; +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/network/handshake/FMLHandshakeCodec.java b/src/main/java/cpw/mods/fml/common/network/handshake/FMLHandshakeCodec.java new file mode 100644 index 0000000..f471452 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/network/handshake/FMLHandshakeCodec.java @@ -0,0 +1,27 @@ +package cpw.mods.fml.common.network.handshake; + +import cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec; +import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelHandlerContext; + +public class FMLHandshakeCodec extends FMLIndexedMessageToMessageCodec { + public FMLHandshakeCodec() + { + addDiscriminator((byte)0, FMLHandshakeMessage.ServerHello.class); + addDiscriminator((byte)1, FMLHandshakeMessage.ClientHello.class); + addDiscriminator((byte)2, FMLHandshakeMessage.ModList.class); + addDiscriminator((byte)3, FMLHandshakeMessage.ModIdData.class); + addDiscriminator((byte)-1, FMLHandshakeMessage.HandshakeAck.class); + } + @Override + public void encodeInto(ChannelHandlerContext ctx, FMLHandshakeMessage msg, ByteBuf target) throws Exception + { + msg.toBytes(target); + } + + @Override + public void decodeInto(ChannelHandlerContext ctx, ByteBuf source, FMLHandshakeMessage msg) + { + msg.fromBytes(source); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/network/handshake/FMLHandshakeMessage.java b/src/main/java/cpw/mods/fml/common/network/handshake/FMLHandshakeMessage.java new file mode 100644 index 0000000..d65f730 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/network/handshake/FMLHandshakeMessage.java @@ -0,0 +1,206 @@ +package cpw.mods.fml.common.network.handshake; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.google.common.base.Charsets; +import com.google.common.base.Joiner; +import com.google.common.collect.Iterables; +import com.google.common.collect.Maps; + +import cpw.mods.fml.common.ModContainer; +import cpw.mods.fml.common.network.ByteBufUtils; +import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.network.internal.FMLProxyPacket; + +public abstract class FMLHandshakeMessage { + public static FMLProxyPacket makeCustomChannelRegistration(Set channels) + { + String salutation = Joiner.on('\0').join(Iterables.concat(Arrays.asList("FML|HS","FML"),channels)); + FMLProxyPacket proxy = new FMLProxyPacket(Unpooled.wrappedBuffer(salutation.getBytes(Charsets.UTF_8)), "REGISTER"); + return proxy; + } + public static class ServerHello extends FMLHandshakeMessage { + private byte serverProtocolVersion; + @Override + public void toBytes(ByteBuf buffer) + { + buffer.writeByte(NetworkRegistry.FML_PROTOCOL); + } + + @Override + public void fromBytes(ByteBuf buffer) + { + serverProtocolVersion = buffer.readByte(); + } + + public byte protocolVersion() + { + return serverProtocolVersion; + } + } + public static class ClientHello extends FMLHandshakeMessage { + private byte serverProtocolVersion; + @Override + public void toBytes(ByteBuf buffer) + { + buffer.writeByte(NetworkRegistry.FML_PROTOCOL); + } + + @Override + public void fromBytes(ByteBuf buffer) + { + serverProtocolVersion = buffer.readByte(); + } + + public byte protocolVersion() + { + return serverProtocolVersion; + } + } + public static class ModList extends FMLHandshakeMessage { + public ModList() + { + + } + public ModList(List modList) + { + for (ModContainer mod : modList) + { + modTags.put(mod.getModId(), mod.getVersion()); + } + } + private Map modTags = Maps.newHashMap(); + + @Override + public void toBytes(ByteBuf buffer) + { + super.toBytes(buffer); + ByteBufUtils.writeVarInt(buffer, modTags.size(), 2); + for (Map.Entry modTag: modTags.entrySet()) + { + ByteBufUtils.writeUTF8String(buffer, modTag.getKey()); + ByteBufUtils.writeUTF8String(buffer, modTag.getValue()); + } + } + + @Override + public void fromBytes(ByteBuf buffer) + { + super.fromBytes(buffer); + int modCount = ByteBufUtils.readVarInt(buffer, 2); + for (int i = 0; i < modCount; i++) + { + modTags.put(ByteBufUtils.readUTF8String(buffer), ByteBufUtils.readUTF8String(buffer)); + } + } + + public String modListAsString() + { + return Joiner.on(',').withKeyValueSeparator("@").join(modTags); + } + + public int modListSize() + { + return modTags.size(); + } + public Map modList() + { + return modTags; + } + + @Override + public String toString(Class> side) + { + return super.toString(side)+":"+modTags.size()+" mods"; + } + } + + public static class ModIdData extends FMLHandshakeMessage { + public ModIdData() + { + + } + + public ModIdData(Map modIds) + { + this.modIds = modIds; + } + + private Map modIds; + @Override + public void fromBytes(ByteBuf buffer) + { + int length = ByteBufUtils.readVarInt(buffer, 3); + modIds = Maps.newHashMap(); + + for (int i = 0; i < length; i++) + { + modIds.put(ByteBufUtils.readUTF8String(buffer),ByteBufUtils.readVarInt(buffer, 3)); + } + } + + @Override + public void toBytes(ByteBuf buffer) + { + ByteBufUtils.writeVarInt(buffer, modIds.size(), 3); + for (Entry entry: modIds.entrySet()) + { + ByteBufUtils.writeUTF8String(buffer, entry.getKey()); + ByteBufUtils.writeVarInt(buffer, entry.getValue(), 3); + } + } + + public Map dataList() + { + return modIds; + } + @Override + public String toString(Class> side) + { + return super.toString(side) + ":"+modIds.size()+" mappings"; + } + } + public static class HandshakeAck extends FMLHandshakeMessage { + int phase; + public HandshakeAck() {} + HandshakeAck(int phase) + { + this.phase = phase; + } + @Override + public void fromBytes(ByteBuf buffer) + { + phase = buffer.readByte(); + } + + @Override + public void toBytes(ByteBuf buffer) + { + buffer.writeByte(phase); + } + @Override + public String toString(Class> side) + { + return super.toString(side) + ":{"+phase+"}"; + } + } + public void fromBytes(ByteBuf buffer) + { + } + + public void toBytes(ByteBuf buffer) + { + } + + public String toString(Class> side) + { + return getClass().getName().substring(getClass().getName().lastIndexOf('$')); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/network/handshake/FMLHandshakeServerState.java b/src/main/java/cpw/mods/fml/common/network/handshake/FMLHandshakeServerState.java new file mode 100644 index 0000000..28e607c --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/network/handshake/FMLHandshakeServerState.java @@ -0,0 +1,94 @@ +package cpw.mods.fml.common.network.handshake; + +import io.netty.channel.ChannelFutureListener; +import io.netty.channel.ChannelHandlerContext; +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.network.internal.FMLMessage; +import cpw.mods.fml.common.network.internal.FMLNetworkHandler; +import cpw.mods.fml.common.registry.GameData; +import cpw.mods.fml.relauncher.Side; + +enum FMLHandshakeServerState implements IHandshakeState +{ + START + { + @Override + public FMLHandshakeServerState accept(ChannelHandlerContext ctx, FMLHandshakeMessage msg) + { + NetworkDispatcher dispatcher = ctx.channel().attr(NetworkDispatcher.FML_DISPATCHER).get(); + dispatcher.serverInitiateHandshake(); + ctx.writeAndFlush(FMLHandshakeMessage.makeCustomChannelRegistration(NetworkRegistry.INSTANCE.channelNamesFor(Side.SERVER))).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); + ctx.writeAndFlush(new FMLHandshakeMessage.ServerHello()).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); + return HELLO; + } + }, + HELLO + { + @Override + public FMLHandshakeServerState accept(ChannelHandlerContext ctx, FMLHandshakeMessage msg) + { + // Hello packet first + if (msg instanceof FMLHandshakeMessage.ClientHello) + { + FMLLog.info("Client protocol version %x", ((FMLHandshakeMessage.ClientHello)msg).protocolVersion()); + return this; + } + + FMLHandshakeMessage.ModList client = (FMLHandshakeMessage.ModList)msg; + FMLLog.info("Client attempting to join with %d mods : %s", client.modListSize(), client.modListAsString()); + String result = FMLNetworkHandler.checkModList(client, Side.CLIENT); + if (result != null) + { + NetworkDispatcher dispatcher = ctx.channel().attr(NetworkDispatcher.FML_DISPATCHER).get(); + dispatcher.rejectHandshake(result); + return ERROR; + } + ctx.writeAndFlush(new FMLHandshakeMessage.ModList(Loader.instance().getActiveModList())); + return WAITINGCACK; + } + }, + WAITINGCACK + { + @Override + public FMLHandshakeServerState accept(ChannelHandlerContext ctx, FMLHandshakeMessage msg) + { + if (!ctx.channel().attr(NetworkDispatcher.IS_LOCAL).get()) + { + ctx.writeAndFlush(new FMLHandshakeMessage.ModIdData(GameData.buildItemDataList())).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); + } + ctx.writeAndFlush(new FMLHandshakeMessage.HandshakeAck(ordinal())).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); + NetworkRegistry.INSTANCE.fireNetworkHandshake(ctx.channel().attr(NetworkDispatcher.FML_DISPATCHER).get(), Side.SERVER); + return COMPLETE; + } + }, + COMPLETE + { + @Override + public FMLHandshakeServerState accept(ChannelHandlerContext ctx, FMLHandshakeMessage msg) + { + // Poke the client + ctx.writeAndFlush(new FMLHandshakeMessage.HandshakeAck(ordinal())).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); + FMLMessage.CompleteHandshake complete = new FMLMessage.CompleteHandshake(Side.SERVER); + ctx.fireChannelRead(complete); + return DONE; + } + }, + DONE + { + @Override + public FMLHandshakeServerState accept(ChannelHandlerContext ctx, FMLHandshakeMessage msg) + { + return this; + } + }, + ERROR + { + @Override + public FMLHandshakeServerState accept(ChannelHandlerContext ctx, FMLHandshakeMessage msg) + { + return this; + } + }; +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/network/handshake/HandshakeInjector.java b/src/main/java/cpw/mods/fml/common/network/handshake/HandshakeInjector.java new file mode 100644 index 0000000..d865084 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/network/handshake/HandshakeInjector.java @@ -0,0 +1,23 @@ +package cpw.mods.fml.common.network.handshake; + +import cpw.mods.fml.common.network.internal.FMLProxyPacket; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelOutboundHandlerAdapter; +import io.netty.channel.ChannelPromise; + +public class HandshakeInjector extends ChannelOutboundHandlerAdapter { + + private NetworkDispatcher dispatcher; + public HandshakeInjector(NetworkDispatcher networkDispatcher) + { + this.dispatcher = networkDispatcher; + } + @Override + public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception + { + if (msg instanceof FMLProxyPacket) + { + this.dispatcher.sendProxy((FMLProxyPacket) msg); + } + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/network/handshake/HandshakeMessageHandler.java b/src/main/java/cpw/mods/fml/common/network/handshake/HandshakeMessageHandler.java new file mode 100644 index 0000000..d7cf50b --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/network/handshake/HandshakeMessageHandler.java @@ -0,0 +1,50 @@ +package cpw.mods.fml.common.network.handshake; + +import org.apache.logging.log4j.Level; +import cpw.mods.fml.common.FMLLog; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.SimpleChannelInboundHandler; +import io.netty.util.AttributeKey; + +public class HandshakeMessageHandler & IHandshakeState> extends SimpleChannelInboundHandler { + private static final AttributeKey> STATE = new AttributeKey>("fml:handshake-state"); + private final AttributeKey fmlHandshakeState; + private S initialState; + private Class stateType; + + @SuppressWarnings("unchecked") + public HandshakeMessageHandler(Class stateType) + { + fmlHandshakeState = (AttributeKey) ((Object)STATE); + initialState = Enum.valueOf(stateType, "START"); + this.stateType = stateType; + } + @Override + protected void channelRead0(ChannelHandlerContext ctx, FMLHandshakeMessage msg) throws Exception + { + S state = ctx.attr(fmlHandshakeState).get(); + FMLLog.finer(msg.toString(stateType) + "->" + state.getClass().getName().substring(state.getClass().getName().lastIndexOf('.')+1)+":"+state); + S newState = state.accept(ctx, msg); + ctx.attr(fmlHandshakeState).set(newState); + } + + @Override + public void channelActive(ChannelHandlerContext ctx) throws Exception + { + ctx.attr(fmlHandshakeState).set(initialState); + } + @Override + public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception + { + S state = ctx.attr(fmlHandshakeState).get(); + S newState = state.accept(ctx, null); + ctx.attr(fmlHandshakeState).set(newState); + } + + @Override + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception + { + FMLLog.log(Level.ERROR, cause, "HandshakeMessageHandler exception"); + super.exceptionCaught(ctx, cause); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/network/handshake/IHandshakeState.java b/src/main/java/cpw/mods/fml/common/network/handshake/IHandshakeState.java new file mode 100644 index 0000000..3c58e73 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/network/handshake/IHandshakeState.java @@ -0,0 +1,7 @@ +package cpw.mods.fml.common.network.handshake; + +import io.netty.channel.ChannelHandlerContext; + +public interface IHandshakeState { + S accept(ChannelHandlerContext ctx, FMLHandshakeMessage msg); +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/network/handshake/NetworkDispatcher.java b/src/main/java/cpw/mods/fml/common/network/handshake/NetworkDispatcher.java new file mode 100644 index 0000000..eca3216 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/network/handshake/NetworkDispatcher.java @@ -0,0 +1,461 @@ +package cpw.mods.fml.common.network.handshake; + +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelOutboundHandler; +import io.netty.channel.ChannelPromise; +import io.netty.channel.SimpleChannelInboundHandler; +import io.netty.channel.embedded.EmbeddedChannel; +import io.netty.util.AttributeKey; +import io.netty.util.concurrent.Future; +import io.netty.util.concurrent.GenericFutureListener; +import io.netty.util.concurrent.ScheduledFuture; +import java.net.SocketAddress; +import java.nio.channels.ClosedChannelException; +import java.util.List; +import java.util.Locale; +import java.util.concurrent.Callable; +import java.util.concurrent.TimeUnit; +import org.apache.logging.log4j.Level; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.network.EnumConnectionState; +import net.minecraft.network.INetHandler; +import net.minecraft.network.NetHandlerPlayServer; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.client.C17PacketCustomPayload; +import net.minecraft.network.play.server.S01PacketJoinGame; +import net.minecraft.network.play.server.S3FPacketCustomPayload; +import net.minecraft.network.play.server.S40PacketDisconnect; +import net.minecraft.server.management.ServerConfigurationManager; +import net.minecraft.util.ChatComponentText; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.network.FMLNetworkEvent; +import cpw.mods.fml.common.network.FMLNetworkException; +import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.network.internal.FMLMessage; +import cpw.mods.fml.common.network.internal.FMLNetworkHandler; +import cpw.mods.fml.common.network.internal.FMLProxyPacket; +import cpw.mods.fml.relauncher.Side; + +public class NetworkDispatcher extends SimpleChannelInboundHandler implements ChannelOutboundHandler { + private static enum ConnectionState { + OPENING, AWAITING_HANDSHAKE, HANDSHAKING, HANDSHAKECOMPLETE, CONNECTED; + } + + private static enum ConnectionType { + MODDED, BUKKIT, VANILLA; + } + + public static NetworkDispatcher get(NetworkManager manager) + { + return manager.channel().attr(FML_DISPATCHER).get(); + } + + public static NetworkDispatcher allocAndSet(NetworkManager manager) + { + NetworkDispatcher net = new NetworkDispatcher(manager); + manager.channel().attr(FML_DISPATCHER).getAndSet(net); + return net; + } + + public static NetworkDispatcher allocAndSet(NetworkManager manager, ServerConfigurationManager scm) + { + NetworkDispatcher net = new NetworkDispatcher(manager, scm); + manager.channel().attr(FML_DISPATCHER).getAndSet(net); + return net; + } + + public static final AttributeKey FML_DISPATCHER = new AttributeKey("fml:dispatcher"); + public static final AttributeKey IS_LOCAL = new AttributeKey("fml:isLocal"); + public final NetworkManager manager; + private final ServerConfigurationManager scm; + private EntityPlayerMP player; + private ConnectionState state; + private ConnectionType connectionType; + private final Side side; + private final EmbeddedChannel handshakeChannel; + private NetHandlerPlayServer serverHandler; + private INetHandler netHandler; + + public NetworkDispatcher(NetworkManager manager) + { + super(Packet.class, false); + this.manager = manager; + this.scm = null; + this.side = Side.CLIENT; + this.handshakeChannel = new EmbeddedChannel(new HandshakeInjector(this), new ChannelRegistrationHandler(), new FMLHandshakeCodec(), new HandshakeMessageHandler(FMLHandshakeClientState.class)); + this.handshakeChannel.attr(FML_DISPATCHER).set(this); + this.handshakeChannel.attr(NetworkRegistry.CHANNEL_SOURCE).set(Side.SERVER); + this.handshakeChannel.attr(NetworkRegistry.FML_CHANNEL).set("FML|HS"); + this.handshakeChannel.attr(IS_LOCAL).set(manager.isLocalChannel()); + } + + public NetworkDispatcher(NetworkManager manager, ServerConfigurationManager scm) + { + super(Packet.class, false); + this.manager = manager; + this.scm = scm; + this.side = Side.SERVER; + this.handshakeChannel = new EmbeddedChannel(new HandshakeInjector(this), new ChannelRegistrationHandler(), new FMLHandshakeCodec(), new HandshakeMessageHandler(FMLHandshakeServerState.class)); + this.handshakeChannel.attr(FML_DISPATCHER).set(this); + this.handshakeChannel.attr(NetworkRegistry.CHANNEL_SOURCE).set(Side.CLIENT); + this.handshakeChannel.attr(NetworkRegistry.FML_CHANNEL).set("FML|HS"); + this.handshakeChannel.attr(IS_LOCAL).set(manager.isLocalChannel()); + } + + public void serverToClientHandshake(EntityPlayerMP player) + { + this.player = player; + insertIntoChannel(); + } + + private void insertIntoChannel() + { + this.manager.channel().config().setAutoRead(false); + // Insert ourselves into the pipeline + this.manager.channel().pipeline().addBefore("packet_handler", "fml:packet_handler", this); + } + + public void clientToServerHandshake() + { + insertIntoChannel(); + } + + @Override + public void handlerAdded(ChannelHandlerContext ctx) throws Exception + { + this.state = ConnectionState.OPENING; + // send ourselves as a user event, to kick the pipeline active + this.handshakeChannel.pipeline().fireUserEventTriggered(this); + this.manager.channel().config().setAutoRead(true); + } + + void serverInitiateHandshake() + { + // Send mod salutation to the client + // This will be ignored by vanilla clients + this.state = ConnectionState.AWAITING_HANDSHAKE; + this.manager.channel().pipeline().addFirst("fml:vanilla_detector", new VanillaTimeoutWaiter()); + // Need to start the handler here, so we can send custompayload packets + serverHandler = new NetHandlerPlayServer(scm.getServerInstance(), manager, player); + this.netHandler = serverHandler; + // NULL the play server here - we restore it further on. If not, there are packets sent before the login + player.playerNetServerHandler = null; + // manually for the manager into the PLAY state, so we can send packets later + this.manager.setConnectionState(EnumConnectionState.PLAY); + } + + void clientListenForServerHandshake() + { + manager.setConnectionState(EnumConnectionState.PLAY); + FMLCommonHandler.instance().waitForPlayClient(); + this.netHandler = FMLCommonHandler.instance().getClientPlayHandler(); + this.state = ConnectionState.AWAITING_HANDSHAKE; + } + + private void completeClientSideConnection(ConnectionType type) + { + this.connectionType = type; + FMLLog.info("[%s] Client side %s connection established", Thread.currentThread().getName(), this.connectionType.name().toLowerCase(Locale.ENGLISH)); + this.state = ConnectionState.CONNECTED; + FMLCommonHandler.instance().bus().post(new FMLNetworkEvent.ClientConnectedToServerEvent(manager, this.connectionType.name())); + } + + private void completeServerSideConnection(ConnectionType type) + { + this.connectionType = type; + FMLLog.info("[%s] Server side %s connection established", Thread.currentThread().getName(), this.connectionType.name().toLowerCase(Locale.ENGLISH)); + this.state = ConnectionState.CONNECTED; + FMLCommonHandler.instance().bus().post(new FMLNetworkEvent.ServerConnectionFromClientEvent(manager)); + scm.initializeConnectionToPlayer(manager, player, serverHandler); + } + @Override + protected void channelRead0(ChannelHandlerContext ctx, Packet msg) throws Exception + { + boolean handled = false; + if (msg instanceof C17PacketCustomPayload) + { + handled = handleServerSideCustomPacket((C17PacketCustomPayload) msg, ctx); + } + else if (msg instanceof S3FPacketCustomPayload) + { + handled = handleClientSideCustomPacket((S3FPacketCustomPayload)msg, ctx); + } + else if (state != ConnectionState.CONNECTED && state != ConnectionState.HANDSHAKECOMPLETE) + { + handled = handleVanilla(msg); + } + if (!handled) + { + ctx.fireChannelRead(msg); + } + } + + private boolean handleVanilla(Packet msg) + { + if (state == ConnectionState.AWAITING_HANDSHAKE && msg instanceof S01PacketJoinGame) + { + handshakeChannel.pipeline().fireUserEventTriggered(msg); + } + else + { + FMLLog.info("Unexpected packet during modded negotiation - assuming vanilla or keepalives : %s", msg.getClass().getName()); + } + return false; + } + + public INetHandler getNetHandler() + { + return netHandler; + } + + @Override + public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception + { + if (evt instanceof ConnectionType && side == Side.SERVER) + { + FMLLog.info("Timeout occurred, assuming a vanilla client"); + kickVanilla(); + } + } + + private void kickVanilla() + { + kickWithMessage("This is modded. No modded response received. Bye!"); + } + private void kickWithMessage(String message) + { + final ChatComponentText chatcomponenttext = new ChatComponentText(message); + manager.scheduleOutboundPacket(new S40PacketDisconnect(chatcomponenttext), new GenericFutureListener>() + { + @Override + public void operationComplete(Future result) + { + manager.closeChannel(chatcomponenttext); + } + }); + manager.channel().config().setAutoRead(false); + } + + private boolean handleClientSideCustomPacket(S3FPacketCustomPayload msg, ChannelHandlerContext context) + { + String channelName = msg.func_149169_c(); + if ("FML|HS".equals(channelName) || "REGISTER".equals(channelName) || "UNREGISTER".equals(channelName)) + { + FMLProxyPacket proxy = new FMLProxyPacket(msg); + proxy.setDispatcher(this); + handshakeChannel.writeInbound(proxy); + // forward any messages into the regular channel + for (Object push : handshakeChannel.inboundMessages()) + { + List messageResult = FMLNetworkHandler.forwardHandshake((FMLMessage.CompleteHandshake)push, this, Side.CLIENT); + for (FMLProxyPacket result: messageResult) + { + result.setTarget(Side.CLIENT); + result.payload().resetReaderIndex(); + context.fireChannelRead(result); + } + } + handshakeChannel.inboundMessages().clear(); + return true; + } + else if (NetworkRegistry.INSTANCE.hasChannel(channelName, Side.CLIENT)) + { + FMLProxyPacket proxy = new FMLProxyPacket(msg); + proxy.setDispatcher(this); + context.fireChannelRead(proxy); + return true; + } + return false; + } + + private boolean handleServerSideCustomPacket(C17PacketCustomPayload msg, ChannelHandlerContext context) + { + if (state == ConnectionState.AWAITING_HANDSHAKE) + { + this.manager.channel().pipeline().remove("fml:vanilla_detector"); + state = ConnectionState.HANDSHAKING; + } + String channelName = msg.func_149559_c(); + if ("FML|HS".equals(channelName) || "REGISTER".equals(channelName) || "UNREGISTER".equals(channelName)) + { + FMLProxyPacket proxy = new FMLProxyPacket(msg); + proxy.setDispatcher(this); + handshakeChannel.writeInbound(proxy); + for (Object push : handshakeChannel.inboundMessages()) + { + List messageResult = FMLNetworkHandler.forwardHandshake((FMLMessage.CompleteHandshake)push, this, Side.SERVER); + for (FMLProxyPacket result: messageResult) + { + result.setTarget(Side.SERVER); + result.payload().resetReaderIndex(); + context.fireChannelRead(result); + } + } + handshakeChannel.inboundMessages().clear(); + return true; + } + else if (NetworkRegistry.INSTANCE.hasChannel(channelName, Side.SERVER)) + { + FMLProxyPacket proxy = new FMLProxyPacket(msg); + proxy.setDispatcher(this); + context.fireChannelRead(proxy); + return true; + } + return false; + } + + private class VanillaTimeoutWaiter extends ChannelInboundHandlerAdapter + { + private ScheduledFuture future; + + @Override + public void handlerAdded(final ChannelHandlerContext ctx) throws Exception + { + future = ctx.executor().schedule(new Callable() { + @Override + public Void call() throws Exception + { + if (state != ConnectionState.CONNECTED) + { + FMLLog.info("Timeout occurred waiting for response, assuming vanilla connection"); + ctx.fireUserEventTriggered(ConnectionType.VANILLA); + } + return null; + } + }, 10, TimeUnit.HOURS); + } + + @Override + public void handlerRemoved(ChannelHandlerContext ctx) throws Exception + { + future.cancel(true); + } + } + + public void sendProxy(FMLProxyPacket msg) + { + manager.scheduleOutboundPacket(msg); + } + + public void rejectHandshake(String result) + { + kickWithMessage(result); + } + + @Override + public void bind(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise) throws Exception + { + ctx.bind(localAddress, promise); + } + + @Override + public void connect(ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) throws Exception + { + ctx.connect(remoteAddress, localAddress, promise); + } + + @Override + public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception + { + if (side == Side.CLIENT) + { + FMLCommonHandler.instance().bus().post(new FMLNetworkEvent.ClientDisconnectionFromServerEvent(manager)); + } + else + { + FMLCommonHandler.instance().bus().post(new FMLNetworkEvent.ServerDisconnectionFromClientEvent(manager)); + } + ctx.disconnect(promise); + } + + @Override + public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception + { + if (side == Side.CLIENT) + { + FMLCommonHandler.instance().bus().post(new FMLNetworkEvent.ClientDisconnectionFromServerEvent(manager)); + } + else + { + FMLCommonHandler.instance().bus().post(new FMLNetworkEvent.ServerDisconnectionFromClientEvent(manager)); + } + ctx.close(promise); + } + + @Override + @Deprecated + public void deregister(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception + { + ctx.deregister(promise); + } + + @Override + public void read(ChannelHandlerContext ctx) throws Exception + { + ctx.read(); + } + + @Override + public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception + { + if (msg instanceof FMLProxyPacket) + { + if (side == Side.CLIENT) + ctx.write(((FMLProxyPacket) msg).toC17Packet(), promise); + else + ctx.write(((FMLProxyPacket) msg).toS3FPacket(), promise); + } + else + { + ctx.write(msg, promise); + } + } + + @Override + public void flush(ChannelHandlerContext ctx) throws Exception + { + ctx.flush(); + } + + public void completeHandshake(Side target) + { + if (state == ConnectionState.CONNECTED) + { + FMLLog.severe("Attempt to double complete the network connection!"); + throw new FMLNetworkException("Attempt to double complete!"); + } + if (side == Side.CLIENT) + { + completeClientSideConnection(ConnectionType.MODDED); + } + else + { + completeServerSideConnection(ConnectionType.MODDED); + } + } + + public void completeClientHandshake() + { + state = ConnectionState.HANDSHAKECOMPLETE; + } + + public void abortClientHandshake(String type) + { + completeClientSideConnection(ConnectionType.valueOf(type)); + } + + @Override + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception + { + // Stop the epic channel closed spam at close + if (!(cause instanceof ClosedChannelException)) + { + FMLLog.log(Level.ERROR, cause, "NetworkDispatcher exception"); + } + super.exceptionCaught(ctx, cause); + } + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/network/internal/EntitySpawnHandler.java b/src/main/java/cpw/mods/fml/common/network/internal/EntitySpawnHandler.java new file mode 100644 index 0000000..72bf209 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/network/internal/EntitySpawnHandler.java @@ -0,0 +1,131 @@ +package cpw.mods.fml.common.network.internal; + +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.SimpleChannelInboundHandler; + +import java.util.List; +import org.apache.logging.log4j.Level; + +import net.minecraft.client.entity.EntityClientPlayerMP; +import net.minecraft.client.multiplayer.WorldClient; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.world.World; + +import com.google.common.base.Throwables; + +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.ModContainer; +import cpw.mods.fml.common.network.internal.FMLMessage.EntityAdjustMessage; +import cpw.mods.fml.common.network.internal.FMLMessage.EntityMessage; +import cpw.mods.fml.common.registry.EntityRegistry; +import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration; +import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData; +import cpw.mods.fml.common.registry.IThrowableEntity; + +public class EntitySpawnHandler extends SimpleChannelInboundHandler { + @Override + protected void channelRead0(ChannelHandlerContext ctx, EntityMessage msg) throws Exception + { + if (msg.getClass().equals(FMLMessage.EntitySpawnMessage.class)) + { + spawnEntity((FMLMessage.EntitySpawnMessage)msg); + } + else if (msg.getClass().equals(FMLMessage.EntityAdjustMessage.class)) + { + adjustEntity((FMLMessage.EntityAdjustMessage)msg); + } + } + + private void adjustEntity(EntityAdjustMessage msg) + { + Entity ent = FMLClientHandler.instance().getWorldClient().getEntityByID(msg.entityId); + if (ent != null) + { + ent.serverPosX = msg.serverX; + ent.serverPosY = msg.serverY; + ent.serverPosZ = msg.serverZ; + } + else + { + FMLLog.fine("Attempted to adjust the position of entity %d which is not present on the client", msg.entityId); + } + + } + + private void spawnEntity(FMLMessage.EntitySpawnMessage spawnMsg) + { + ModContainer mc = Loader.instance().getIndexedModList().get(spawnMsg.modId); + EntityRegistration er = EntityRegistry.instance().lookupModSpawn(mc, spawnMsg.modEntityTypeId); + WorldClient wc = FMLClientHandler.instance().getWorldClient(); + Class cls = er.getEntityClass(); + try + { + Entity entity; + if (er.hasCustomSpawning()) + { + entity = er.doCustomSpawning(spawnMsg); + } else + { + entity = (Entity) (cls.getConstructor(World.class).newInstance(wc)); + + int offset = spawnMsg.entityId - entity.getEntityId(); + entity.setEntityId(spawnMsg.entityId); + entity.setLocationAndAngles(spawnMsg.scaledX, spawnMsg.scaledY, spawnMsg.scaledZ, spawnMsg.scaledYaw, spawnMsg.scaledPitch); + if (entity instanceof EntityLiving) + { + ((EntityLiving) entity).rotationYawHead = spawnMsg.scaledHeadYaw; + } + + Entity parts[] = entity.getParts(); + if (parts != null) + { + for (int j = 0; j < parts.length; j++) + { + parts[j].setEntityId(parts[j].getEntityId() + offset); + } + } + } + + entity.serverPosX = spawnMsg.rawX; + entity.serverPosY = spawnMsg.rawY; + entity.serverPosZ = spawnMsg.rawZ; + + EntityClientPlayerMP clientPlayer = FMLClientHandler.instance().getClientPlayerEntity(); + if (entity instanceof IThrowableEntity) + { + Entity thrower = clientPlayer.getEntityId() == spawnMsg.throwerId ? clientPlayer : wc.getEntityByID(spawnMsg.throwerId); + ((IThrowableEntity) entity).setThrower(thrower); + } + + if (spawnMsg.dataWatcherList != null) + { + entity.getDataWatcher().updateWatchedObjectsFromList((List) spawnMsg.dataWatcherList); + } + + if (spawnMsg.throwerId > 0) + { + entity.setVelocity(spawnMsg.speedScaledX, spawnMsg.speedScaledY, spawnMsg.speedScaledZ); + } + + if (entity instanceof IEntityAdditionalSpawnData) + { + ((IEntityAdditionalSpawnData) entity).readSpawnData(spawnMsg.dataStream); + } + wc.addEntityToWorld(spawnMsg.entityId, entity); + } catch (Exception e) + { + FMLLog.log(Level.ERROR, e, "A severe problem occurred during the spawning of an entity"); + throw Throwables.propagate(e); + } + } + + @Override + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception + { + FMLLog.log(Level.ERROR, cause, "EntitySpawnHandler exception"); + super.exceptionCaught(ctx, cause); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/network/internal/FMLMessage.java b/src/main/java/cpw/mods/fml/common/network/internal/FMLMessage.java new file mode 100644 index 0000000..7e104d7 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/network/internal/FMLMessage.java @@ -0,0 +1,260 @@ +package cpw.mods.fml.common.network.internal; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; + +import java.io.IOException; +import java.util.List; + +import net.minecraft.entity.DataWatcher; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.network.PacketBuffer; +import net.minecraft.util.MathHelper; +import cpw.mods.fml.common.ModContainer; +import cpw.mods.fml.common.network.ByteBufUtils; +import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration; +import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData; +import cpw.mods.fml.common.registry.IThrowableEntity; +import cpw.mods.fml.relauncher.Side; + +public abstract class FMLMessage { + public static class CompleteHandshake extends FMLMessage { + Side target; + public CompleteHandshake() { + } + public CompleteHandshake(Side target) + { + this.target = target; + } + @Override + void fromBytes(ByteBuf buf) + { + target = Side.values()[buf.readByte()]; + } + @Override + void toBytes(ByteBuf buf) + { + buf.writeByte(target.ordinal()); + } + } + public static class OpenGui extends FMLMessage { + int windowId; + String modId; + int modGuiId; + int x; + int y; + int z; + + public OpenGui() {} + OpenGui(int windowId, String modId, int modGuiId, int x, int y, int z) + { + this.windowId = windowId; + this.modId = modId; + this.modGuiId = modGuiId; + this.x = x; + this.y = y; + this.z = z; + } + + @Override + void toBytes(ByteBuf buf) + { + buf.writeInt(windowId); + ByteBufUtils.writeUTF8String(buf, modId); + buf.writeInt(modGuiId); + buf.writeInt(x); + buf.writeInt(y); + buf.writeInt(z); + } + + @Override + void fromBytes(ByteBuf buf) + { + windowId = buf.readInt(); + modId = ByteBufUtils.readUTF8String(buf); + modGuiId = buf.readInt(); + x = buf.readInt(); + y = buf.readInt(); + z = buf.readInt(); + } + } + + public abstract static class EntityMessage extends FMLMessage { + Entity entity; + int entityId; + public EntityMessage() + { + + } + EntityMessage(Entity entity) + { + this.entity = entity; + } + @Override + void toBytes(ByteBuf buf) + { + buf.writeInt(entity.getEntityId()); + } + + @Override + void fromBytes(ByteBuf buf) + { + entityId = buf.readInt(); + } + } + + public static class EntityAdjustMessage extends EntityMessage { + int serverX; + int serverY; + int serverZ; + + public EntityAdjustMessage() {} + public EntityAdjustMessage(Entity entity, int serverX, int serverY, int serverZ) + { + super(entity); + this.serverX = serverX; + this.serverY = serverY; + this.serverZ = serverZ; + } + + @Override + void toBytes(ByteBuf buf) + { + super.toBytes(buf); + buf.writeInt(serverX); + buf.writeInt(serverY); + buf.writeInt(serverZ); + } + + @Override + void fromBytes(ByteBuf buf) + { + super.fromBytes(buf); + serverX = buf.readInt(); + serverY = buf.readInt(); + serverZ = buf.readInt(); + } + } + public static class EntitySpawnMessage extends EntityMessage { + String modId; + int modEntityTypeId; + int rawX; + int rawY; + int rawZ; + double scaledX; + double scaledY; + double scaledZ; + float scaledYaw; + float scaledPitch; + float scaledHeadYaw; + int throwerId; + double speedScaledX; + double speedScaledY; + double speedScaledZ; + @SuppressWarnings("rawtypes") + List dataWatcherList; + ByteBuf dataStream; + + public EntitySpawnMessage() {} + public EntitySpawnMessage(EntityRegistration er, Entity entity, ModContainer modContainer) + { + super(entity); + modId = modContainer.getModId(); + modEntityTypeId = er.getModEntityId(); + } + @Override + void toBytes(ByteBuf buf) + { + super.toBytes(buf); + ByteBufUtils.writeUTF8String(buf, modId); + buf.writeInt(modEntityTypeId); + // posX, posY, posZ + buf.writeInt(MathHelper.floor_double(entity.posX * 32D)); + buf.writeInt(MathHelper.floor_double(entity.posY * 32D)); + buf.writeInt(MathHelper.floor_double(entity.posZ * 32D)); + // yaw, pitch + buf.writeByte((byte)(entity.rotationYaw * 256.0F / 360.0F)); + buf.writeByte((byte) (entity.rotationPitch * 256.0F / 360.0F)); + // head yaw + if (entity instanceof EntityLivingBase) + { + buf.writeByte((byte) (((EntityLivingBase)entity).rotationYawHead * 256.0F / 360.0F)); + } + + ByteBuf tmpBuf = Unpooled.buffer(); + PacketBuffer pb = new PacketBuffer(tmpBuf); + try + { + entity.getDataWatcher().func_151509_a(pb); + } catch (IOException e) + { + // Sigh + } + buf.writeBytes(tmpBuf); + + if (entity instanceof IThrowableEntity) + { + Entity owner = ((IThrowableEntity)entity).getThrower(); + buf.writeInt(owner == null ? entity.getEntityId() : owner.getEntityId()); + double maxVel = 3.9D; + double mX = entity.motionX; + double mY = entity.motionY; + double mZ = entity.motionZ; + if (mX < -maxVel) mX = -maxVel; + if (mY < -maxVel) mY = -maxVel; + if (mZ < -maxVel) mZ = -maxVel; + if (mX > maxVel) mX = maxVel; + if (mY > maxVel) mY = maxVel; + if (mZ > maxVel) mZ = maxVel; + buf.writeInt((int)(mX * 8000D)); + buf.writeInt((int)(mY * 8000D)); + buf.writeInt((int)(mZ * 8000D)); + } + else + { + buf.writeInt(0); + } + if (entity instanceof IEntityAdditionalSpawnData) + { + tmpBuf = Unpooled.buffer(); + ((IEntityAdditionalSpawnData)entity).writeSpawnData(tmpBuf); + buf.writeBytes(tmpBuf); + } + } + @Override + void fromBytes(ByteBuf dat) + { + super.fromBytes(dat); + modId = ByteBufUtils.readUTF8String(dat); + modEntityTypeId = dat.readInt(); + rawX = dat.readInt(); + rawY = dat.readInt(); + rawZ = dat.readInt(); + scaledX = rawX / 32D; + scaledY = rawY / 32D; + scaledZ = rawZ / 32D; + scaledYaw = dat.readByte() * 360F / 256F; + scaledPitch = dat.readByte() * 360F / 256F; + scaledHeadYaw = dat.readByte() * 360F / 256F; + try + { + dataWatcherList = DataWatcher.readWatchedListFromPacketBuffer(new PacketBuffer(dat)); + } catch (IOException e) + { + // Sigh + } + + throwerId = dat.readInt(); + if (throwerId != 0) + { + speedScaledX = dat.readInt() / 8000D; + speedScaledY = dat.readInt() / 8000D; + speedScaledZ = dat.readInt() / 8000D; + } + this.dataStream = dat; + } + } + abstract void toBytes(ByteBuf buf); + abstract void fromBytes(ByteBuf buf); +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/network/internal/FMLNetworkHandler.java b/src/main/java/cpw/mods/fml/common/network/internal/FMLNetworkHandler.java new file mode 100644 index 0000000..d448735 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/network/internal/FMLNetworkHandler.java @@ -0,0 +1,199 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.network.internal; + +import io.netty.channel.ChannelPipeline; +import io.netty.channel.embedded.EmbeddedChannel; +import java.util.ArrayList; +import java.util.EnumMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.inventory.Container; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.server.management.ServerConfigurationManager; +import net.minecraft.world.World; +import org.apache.logging.log4j.core.helpers.Integers; +import com.google.common.collect.Lists; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.FMLContainer; +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.ModContainer; +import cpw.mods.fml.common.network.FMLEmbeddedChannel; +import cpw.mods.fml.common.network.FMLOutboundHandler; +import cpw.mods.fml.common.network.FMLOutboundHandler.OutboundTarget; +import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.network.handshake.FMLHandshakeMessage; +import cpw.mods.fml.common.network.handshake.NetworkDispatcher; +import cpw.mods.fml.common.network.internal.FMLMessage.CompleteHandshake; +import cpw.mods.fml.common.registry.EntityRegistry; +import cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class FMLNetworkHandler +{ + public static final int READ_TIMEOUT = Integers.parseInt(System.getProperty("fml.readTimeout","30"),30); + public static final int LOGIN_TIMEOUT = Integers.parseInt(System.getProperty("fml.loginTimeout","600"),600); + private static EnumMap channelPair; + + public static void fmlServerHandshake(ServerConfigurationManager scm, NetworkManager manager, EntityPlayerMP player) + { + NetworkDispatcher dispatcher = NetworkDispatcher.allocAndSet(manager, scm); + dispatcher.serverToClientHandshake(player); + } + + public static void fmlClientHandshake(NetworkManager field_147393_d) + { + NetworkDispatcher dispatcher = NetworkDispatcher.allocAndSet(field_147393_d); + dispatcher.clientToServerHandshake(); + } + + public static void openGui(EntityPlayer entityPlayer, Object mod, int modGuiId, World world, int x, int y, int z) + { + ModContainer mc = FMLCommonHandler.instance().findContainerFor(mod); + if (entityPlayer instanceof EntityPlayerMP) + { + EntityPlayerMP entityPlayerMP = (EntityPlayerMP) entityPlayer; + Container remoteGuiContainer = NetworkRegistry.INSTANCE.getRemoteGuiContainer(mc, entityPlayerMP, modGuiId, world, x, y, z); + if (remoteGuiContainer != null) + { + entityPlayerMP.getNextWindowId(); + entityPlayerMP.closeContainer(); + int windowId = entityPlayerMP.currentWindowId; + FMLMessage.OpenGui openGui = new FMLMessage.OpenGui(windowId, mc.getModId(), modGuiId, x, y, z); + EmbeddedChannel embeddedChannel = channelPair.get(Side.SERVER); + embeddedChannel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.PLAYER); + embeddedChannel.attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(entityPlayerMP); + embeddedChannel.writeOutbound(openGui); + entityPlayerMP.openContainer = remoteGuiContainer; + entityPlayerMP.openContainer.windowId = windowId; + entityPlayerMP.openContainer.addCraftingToCrafters(entityPlayerMP); + } + } + else if (FMLCommonHandler.instance().getSide().equals(Side.CLIENT)) + { + Object guiContainer = NetworkRegistry.INSTANCE.getLocalGuiContainer(mc, entityPlayer, modGuiId, world, x, y, z); + FMLCommonHandler.instance().showGuiScreen(guiContainer); + } + else + { + FMLLog.fine("Invalid attempt to open a local GUI on a dedicated server. This is likely a bug. GUIID: %s,%d", mc.getModId(), modGuiId); + } + + } + + public static void makeEntitySpawnAdjustment(Entity entity, EntityPlayerMP player, int serverX, int serverY, int serverZ) + { + EmbeddedChannel embeddedChannel = channelPair.get(Side.SERVER); + embeddedChannel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.PLAYER); + embeddedChannel.attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(player); + embeddedChannel.writeOutbound(new FMLMessage.EntityAdjustMessage(entity, serverX, serverY, serverZ)); + } + + public static Packet getEntitySpawningPacket(Entity entity) + { + EntityRegistration er = EntityRegistry.instance().lookupModSpawn(entity.getClass(), false); + if (er == null) + { + return null; + } + if (er.usesVanillaSpawning()) + { + return null; + } + + return channelPair.get(Side.SERVER).generatePacketFrom(new FMLMessage.EntitySpawnMessage(er, entity, er.getContainer())); + } + + public static String checkModList(FMLHandshakeMessage.ModList modListPacket, Side side) + { + Map modList = modListPacket.modList(); + List rejects = Lists.newArrayList(); + for (Entry networkMod : NetworkRegistry.INSTANCE.registry().entrySet()) + { + boolean result = networkMod.getValue().check(modList, side); + if (!result) + { + rejects.add(networkMod.getKey()); + } + } + if (rejects.isEmpty()) + { + return null; + } + else + { + FMLLog.info("Rejecting connection %s: %s", side, rejects); + return String.format("Mod rejections %s",rejects); + } + } + + @SideOnly(Side.CLIENT) + private static void addClientHandlers() + { + ChannelPipeline pipeline = channelPair.get(Side.CLIENT).pipeline(); + String targetName = channelPair.get(Side.CLIENT).findChannelHandlerNameForType(FMLRuntimeCodec.class); + pipeline.addAfter(targetName, "GuiHandler", new OpenGuiHandler()); + pipeline.addAfter(targetName, "EntitySpawnHandler", new EntitySpawnHandler()); + } + public static void registerChannel(FMLContainer container, Side side) + { + channelPair = NetworkRegistry.INSTANCE.newChannel(container, "FML", new FMLRuntimeCodec(), new HandshakeCompletionHandler()); + EmbeddedChannel embeddedChannel = channelPair.get(Side.SERVER); + embeddedChannel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.NOWHERE); + + if (side == Side.CLIENT) + { + addClientHandlers(); + } + } + + public static List forwardHandshake(CompleteHandshake push, NetworkDispatcher target, Side side) + { + channelPair.get(side).attr(NetworkDispatcher.FML_DISPATCHER).set(target); + channelPair.get(side).writeOutbound(push); + + ArrayList list = new ArrayList(); + for (Object o: channelPair.get(side).outboundMessages()) + { + list.add((FMLProxyPacket)o); + } + channelPair.get(side).outboundMessages().clear(); + return list; + } + + + public static void enhanceStatusQuery(JsonObject jsonobject) + { + JsonObject fmlData = new JsonObject(); + fmlData.addProperty("type", "FML"); + JsonArray modList = new JsonArray(); + for (ModContainer mc : Loader.instance().getActiveModList()) + { + JsonObject modData = new JsonObject(); + modData.addProperty("modid", mc.getModId()); + modData.addProperty("version", mc.getVersion()); + modList.add(modData); + } + fmlData.add("modList", modList); + jsonobject.add("modinfo", fmlData); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/network/internal/FMLProxyPacket.java b/src/main/java/cpw/mods/fml/common/network/internal/FMLProxyPacket.java new file mode 100644 index 0000000..6e8d6d7 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/network/internal/FMLProxyPacket.java @@ -0,0 +1,132 @@ +package cpw.mods.fml.common.network.internal; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; +import io.netty.channel.embedded.EmbeddedChannel; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.client.C17PacketCustomPayload; +import net.minecraft.network.play.server.S3FPacketCustomPayload; +import org.apache.logging.log4j.Level; +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.network.FMLNetworkException; +import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.network.handshake.NetworkDispatcher; +import cpw.mods.fml.relauncher.Side; + +public class FMLProxyPacket extends Packet { + final String channel; + private Side target; + private final ByteBuf payload; + private INetHandler netHandler; + private NetworkDispatcher dispatcher; + + private FMLProxyPacket(byte[] payload, String channel) + { + this(Unpooled.wrappedBuffer(payload), channel); + } + + public FMLProxyPacket(S3FPacketCustomPayload original) + { + this(original.func_149168_d(), original.func_149169_c()); + this.target = Side.CLIENT; + } + + public FMLProxyPacket(C17PacketCustomPayload original) + { + this(original.func_149558_e(), original.func_149559_c()); + this.target = Side.SERVER; + } + + public FMLProxyPacket(ByteBuf payload, String channel) + { + this.channel = channel; + this.payload = payload; + } + @Override + public void readPacketData(PacketBuffer packetbuffer) throws IOException + { + // NOOP - we are not built this way + } + + @Override + public void writePacketData(PacketBuffer packetbuffer) throws IOException + { + // NOOP - we are not built this way + } + + @Override + public void processPacket(INetHandler inethandler) + { + this.netHandler = inethandler; + EmbeddedChannel internalChannel = NetworkRegistry.INSTANCE.getChannel(this.channel, this.target); + if (internalChannel != null) + { + internalChannel.attr(NetworkRegistry.NET_HANDLER).set(this.netHandler); + try + { + internalChannel.writeInbound(this); + } + catch (FMLNetworkException ne) + { + FMLLog.log(Level.ERROR, ne, "There was a network exception handling a packet on channel %s", channel); + dispatcher.rejectHandshake(ne.getMessage()); + } + catch (Throwable t) + { + FMLLog.log(Level.ERROR, t, "There was a critical exception handling a packet on channel %s", channel); + dispatcher.rejectHandshake("A fatal error has occured, this connection is terminated"); + } + } + } + + public String channel() + { + return channel; + } + public ByteBuf payload() + { + return payload; + } + public INetHandler handler() + { + return netHandler; + } + public Packet toC17Packet() + { + return new C17PacketCustomPayload(channel, payload.array()); + } + + public Packet toS3FPacket() + { + return new S3FPacketCustomPayload(channel, payload.array()); + } + + public void setTarget(Side target) + { + this.target = target; + } + + public void setDispatcher(NetworkDispatcher networkDispatcher) + { + this.dispatcher = networkDispatcher; + } + + public NetworkManager getOrigin() + { + return this.dispatcher != null ? this.dispatcher.manager : null; + } + + public NetworkDispatcher getDispatcher() + { + return this.dispatcher; + } + + public Side getTarget() + { + return target; + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/network/internal/FMLRuntimeCodec.java b/src/main/java/cpw/mods/fml/common/network/internal/FMLRuntimeCodec.java new file mode 100644 index 0000000..2beb9b8 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/network/internal/FMLRuntimeCodec.java @@ -0,0 +1,44 @@ +package cpw.mods.fml.common.network.internal; + +import com.google.common.base.Splitter; +import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelHandlerContext; +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.network.ByteBufUtils; +import cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec; +import cpw.mods.fml.common.network.FMLNetworkException; + +public class FMLRuntimeCodec extends FMLIndexedMessageToMessageCodec { + public FMLRuntimeCodec() + { + addDiscriminator(0,FMLMessage.CompleteHandshake.class); + addDiscriminator(1,FMLMessage.OpenGui.class); + addDiscriminator(2,FMLMessage.EntitySpawnMessage.class); + addDiscriminator(3,FMLMessage.EntityAdjustMessage.class); + } + @Override + public void encodeInto(ChannelHandlerContext ctx, FMLMessage msg, ByteBuf target) throws Exception + { + msg.toBytes(target); + } + + @Override + public void decodeInto(ChannelHandlerContext ctx, ByteBuf source, FMLMessage msg) + { + msg.fromBytes(source); + } + + @Override + protected void testMessageValidity(FMLProxyPacket msg) + { + if (msg.payload().getByte(0) == 0 && msg.payload().readableBytes() > 2) + { + FMLLog.severe("The connection appears to have sent an invalid FML packet of type 0, this is likely because it think's it's talking to 1.6.4 FML"); + FMLLog.info("Bad data :"); + for (String l : Splitter.on('\n').split(ByteBufUtils.getContentDump(msg.payload()))) { + FMLLog.info("\t%s",l); + } + throw new FMLNetworkException("Invalid FML packet"); + } + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/network/internal/HandshakeCompletionHandler.java b/src/main/java/cpw/mods/fml/common/network/internal/HandshakeCompletionHandler.java new file mode 100644 index 0000000..900ff14 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/network/internal/HandshakeCompletionHandler.java @@ -0,0 +1,26 @@ +package cpw.mods.fml.common.network.internal; + +import org.apache.logging.log4j.Level; +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.network.handshake.NetworkDispatcher; +import cpw.mods.fml.common.network.internal.FMLMessage.CompleteHandshake; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.SimpleChannelInboundHandler; +import io.netty.channel.ChannelHandler.Sharable; + +@Sharable +public class HandshakeCompletionHandler extends SimpleChannelInboundHandler { + @Override + protected void channelRead0(ChannelHandlerContext ctx, CompleteHandshake msg) throws Exception + { + NetworkDispatcher dispatcher = ctx.channel().attr(NetworkDispatcher.FML_DISPATCHER).getAndRemove(); + dispatcher.completeHandshake(msg.target); + } + + @Override + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception + { + FMLLog.log(Level.ERROR, cause, "HandshakeCompletionHandler exception"); + super.exceptionCaught(ctx, cause); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/network/internal/NetworkModHolder.java b/src/main/java/cpw/mods/fml/common/network/internal/NetworkModHolder.java new file mode 100644 index 0000000..70e7326 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/network/internal/NetworkModHolder.java @@ -0,0 +1,208 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.network.internal; + +import java.lang.reflect.Method; +import java.util.Map; +import java.util.Set; +import org.apache.logging.log4j.Level; + +import com.google.common.base.Strings; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.SetMultimap; + +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.ModContainer; +import cpw.mods.fml.common.discovery.ASMDataTable; +import cpw.mods.fml.common.discovery.ASMDataTable.ASMData; +import cpw.mods.fml.common.network.NetworkCheckHandler; +import cpw.mods.fml.common.versioning.DefaultArtifactVersion; +import cpw.mods.fml.common.versioning.InvalidVersionSpecificationException; +import cpw.mods.fml.common.versioning.VersionRange; +import cpw.mods.fml.relauncher.Side; + +public class NetworkModHolder +{ + private abstract class NetworkChecker { + public abstract boolean check(Map remoteVersions, Side side); + } + + private class IgnoredChecker extends NetworkChecker { + @Override + public boolean check(Map remoteVersions, Side side) + { + return true; + } + } + private class DefaultNetworkChecker extends NetworkChecker { + @Override + public boolean check(Map remoteVersions, Side side) + { + return remoteVersions.containsKey(container.getModId()) ? acceptVersion(remoteVersions.get(container.getModId())) : false; + } + + } + private class MethodNetworkChecker extends NetworkChecker { + @Override + public boolean check(Map remoteVersions, Side side) + { + try + { + return (Boolean) checkHandler.invoke(container.getMod(), remoteVersions, side); + } + catch (Exception e) + { + FMLLog.log(Level.ERROR, e, "Error occurred invoking NetworkCheckHandler %s at %s", checkHandler.getName(), container); + return false; + } + } + } + private static int assignedIds = 1; + + private int localId; + private int networkId; + + private ModContainer container; + private Method checkHandler; + + private VersionRange acceptableRange; + + private NetworkChecker checker; + + public NetworkModHolder(ModContainer container) + { + this.container = container; + this.localId = assignedIds++; + this.networkId = this.localId; + } + public NetworkModHolder(ModContainer container, Class modClass, String acceptableVersionRange, ASMDataTable table) + { + this(container); + SetMultimap annotationTable = table.getAnnotationsFor(container); + Set versionCheckHandlers; + if (annotationTable != null) + { + versionCheckHandlers = annotationTable.get(NetworkCheckHandler.class.getName()); + } + else + { + versionCheckHandlers = ImmutableSet.of(); + } + String networkCheckHandlerMethod = null; + for (ASMData vch : versionCheckHandlers) + { + if (vch.getClassName().equals(modClass.getName())) + { + networkCheckHandlerMethod = vch.getObjectName(); + networkCheckHandlerMethod = networkCheckHandlerMethod.substring(0,networkCheckHandlerMethod.indexOf('(')); + break; + } + } + if (versionCheckHandlers.isEmpty()) + { + for (Method m : modClass.getMethods()) + { + if (m.isAnnotationPresent(NetworkCheckHandler.class)) + { + if (m.getParameterTypes().length == 2 && m.getParameterTypes()[0].equals(Map.class) && m.getParameterTypes()[1].equals(Side.class)) + { + this.checkHandler = m; + break; + } + else + { + FMLLog.severe("Found unexpected method signature for annotation NetworkCheckHandler"); + } + } + } + } + if (networkCheckHandlerMethod != null) + { + try + { + Method checkHandlerMethod = modClass.getDeclaredMethod(networkCheckHandlerMethod, Map.class, Side.class); + if (checkHandlerMethod.isAnnotationPresent(NetworkCheckHandler.class)) + { + this.checkHandler = checkHandlerMethod; + } + } + catch (Exception e) + { + FMLLog.log(Level.WARN, e, "The declared version check handler method %s on network mod id %s is not accessible", networkCheckHandlerMethod, container.getModId()); + } + } + if (this.checkHandler != null) + { + this.checker = new MethodNetworkChecker(); + } else if (!Strings.isNullOrEmpty(acceptableVersionRange) && !acceptableVersionRange.equals('*')) + { + try + { + this.acceptableRange = VersionRange.createFromVersionSpec(acceptableVersionRange); + } + catch (InvalidVersionSpecificationException e) + { + FMLLog.log(Level.WARN, e, "Invalid bounded range %s specified for network mod id %s", acceptableVersionRange, container.getModId()); + } + this.checker = new DefaultNetworkChecker(); + } else { + this.checker = new IgnoredChecker(); + } + FMLLog.finer("Testing mod %s to verify it accepts its own version in a remote connection", container.getModId()); + boolean acceptsSelf = acceptVersion(container.getVersion()); + if (!acceptsSelf) + { + FMLLog.severe("The mod %s appears to reject its own version number (%s) in its version handling. This is likely a severe bug in the mod!", container.getModId(), container.getVersion()); + } + else + { + FMLLog.finer("The mod %s accepts its own version (%s)", container.getModId(), container.getVersion()); + } + } + + public boolean acceptVersion(String version) + { + if (acceptableRange!=null) + { + return acceptableRange.containsVersion(new DefaultArtifactVersion(version)); + } + + return container.getVersion().equals(version); + } + + public boolean check(Map data, Side side) + { + return checker.check(data, side); + } + + public int getLocalId() + { + return localId; + } + + public int getNetworkId() + { + return networkId; + } + + public ModContainer getContainer() + { + return container; + } + + public void setNetworkId(int value) + { + this.networkId = value; + } + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/network/internal/OpenGuiHandler.java b/src/main/java/cpw/mods/fml/common/network/internal/OpenGuiHandler.java new file mode 100644 index 0000000..ac8ea20 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/network/internal/OpenGuiHandler.java @@ -0,0 +1,27 @@ +package cpw.mods.fml.common.network.internal; + +import org.apache.logging.log4j.Level; +import net.minecraft.entity.player.EntityPlayer; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.SimpleChannelInboundHandler; +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.network.internal.FMLMessage.OpenGui; + +public class OpenGuiHandler extends SimpleChannelInboundHandler { + @Override + protected void channelRead0(ChannelHandlerContext ctx, OpenGui msg) throws Exception + { + EntityPlayer player = FMLClientHandler.instance().getClient().thePlayer; + player.openGui(msg.modId, msg.modGuiId, player.worldObj, msg.x, msg.y, msg.z); + player.openContainer.windowId = msg.windowId; + } + + @Override + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception + { + FMLLog.log(Level.ERROR, cause, "OpenGuiHandler exception"); + super.exceptionCaught(ctx, cause); + } + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/network/simpleimpl/IMessage.java b/src/main/java/cpw/mods/fml/common/network/simpleimpl/IMessage.java new file mode 100644 index 0000000..b12fe4b --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/network/simpleimpl/IMessage.java @@ -0,0 +1,24 @@ +package cpw.mods.fml.common.network.simpleimpl; + +import io.netty.buffer.ByteBuf; + +/** + * Implement this interface for each message you wish to define. + * + * @author cpw + * + */ +public interface IMessage { + /** + * Convert from the supplied buffer into your specific message type + * + * @param buf + */ + public void fromBytes(ByteBuf buf); + + /** + * Deconstruct your message into the supplied byte buffer + * @param buf + */ + public void toBytes(ByteBuf buf); +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/network/simpleimpl/IMessageHandler.java b/src/main/java/cpw/mods/fml/common/network/simpleimpl/IMessageHandler.java new file mode 100644 index 0000000..2432bc5 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/network/simpleimpl/IMessageHandler.java @@ -0,0 +1,24 @@ +package cpw.mods.fml.common.network.simpleimpl; + + +/** + * A message handler based on {@link IMessage}. Implement and override {@link #onMessage(IMessage)} to + * process your packet. Supply the class to {@link SimpleNetworkWrapper#registerMessage(Class, Class, byte, cpw.mods.fml.relauncher.Side)} + * to register both the message type and it's associated handler. + * + * @author cpw + * + * @param This is the request type - it is the message you expect to receive from remote. + * @param This is the reply type - it is the message you expect to send in reply. You can use IMessage as the type here + * if you don't anticipate sending a reply. + */ +public interface IMessageHandler { + /** + * Called when a message is received of the appropriate type. You can optionally return a reply message, or null if no reply + * is needed. + * + * @param message The message + * @return an optional return message + */ + public REPLY onMessage(REQ message, MessageContext ctx); +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/network/simpleimpl/MessageContext.java b/src/main/java/cpw/mods/fml/common/network/simpleimpl/MessageContext.java new file mode 100644 index 0000000..2cb4007 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/network/simpleimpl/MessageContext.java @@ -0,0 +1,43 @@ +package cpw.mods.fml.common.network.simpleimpl; + +import cpw.mods.fml.relauncher.Side; +import net.minecraft.client.network.NetHandlerPlayClient; +import net.minecraft.network.INetHandler; +import net.minecraft.network.NetHandlerPlayServer; + +/** + * Context for the {@link IMessageHandler} + * + * @author cpw + * + */ +public class MessageContext { + /** + * The {@link INetHandler} for this message. It could be a client or server handler, depending + * on the {@link #side} recieved. + */ + public final INetHandler netHandler; + + /** + * The Side this message has been received on + */ + public final Side side; + /** + * @param netHandler + */ + MessageContext(INetHandler netHandler, Side side) + { + this.netHandler = netHandler; + this.side = side; + } + + public NetHandlerPlayServer getServerHandler() + { + return (NetHandlerPlayServer) netHandler; + } + + public NetHandlerPlayClient getClientHandler() + { + return (NetHandlerPlayClient) netHandler; + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/network/simpleimpl/SimpleChannelHandlerWrapper.java b/src/main/java/cpw/mods/fml/common/network/simpleimpl/SimpleChannelHandlerWrapper.java new file mode 100644 index 0000000..5441b43 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/network/simpleimpl/SimpleChannelHandlerWrapper.java @@ -0,0 +1,45 @@ +package cpw.mods.fml.common.network.simpleimpl; + +import org.apache.logging.log4j.Level; +import net.minecraft.network.INetHandler; +import com.google.common.base.Throwables; +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.relauncher.Side; +import io.netty.channel.ChannelFutureListener; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.SimpleChannelInboundHandler; + +public class SimpleChannelHandlerWrapper extends SimpleChannelInboundHandler { + private IMessageHandler messageHandler; + private Side side; + public SimpleChannelHandlerWrapper(Class> handler, Side side) + { + try + { + messageHandler = handler.newInstance(); + } catch (Exception e) + { + Throwables.propagate(e); + } + this.side = side; + } + @Override + protected void channelRead0(ChannelHandlerContext ctx, REQ msg) throws Exception + { + INetHandler iNetHandler = ctx.attr(NetworkRegistry.NET_HANDLER).get(); + MessageContext context = new MessageContext(iNetHandler, side); + REPLY result = messageHandler.onMessage(msg, context); + if (result != null) + { + ctx.writeAndFlush(result).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); + } + } + + @Override + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception + { + FMLLog.log(Level.ERROR, cause, "SimpleChannelHandlerWrapper exception"); + super.exceptionCaught(ctx, cause); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/network/simpleimpl/SimpleIndexedCodec.java b/src/main/java/cpw/mods/fml/common/network/simpleimpl/SimpleIndexedCodec.java new file mode 100644 index 0000000..b68b227 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/network/simpleimpl/SimpleIndexedCodec.java @@ -0,0 +1,20 @@ +package cpw.mods.fml.common.network.simpleimpl; + +import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelHandlerContext; +import cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec; + +public class SimpleIndexedCodec extends FMLIndexedMessageToMessageCodec { + @Override + public void encodeInto(ChannelHandlerContext ctx, IMessage msg, ByteBuf target) throws Exception + { + msg.toBytes(target); + } + + @Override + public void decodeInto(ChannelHandlerContext ctx, ByteBuf source, IMessage msg) + { + msg.fromBytes(source); + } + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/network/simpleimpl/SimpleNetworkWrapper.java b/src/main/java/cpw/mods/fml/common/network/simpleimpl/SimpleNetworkWrapper.java new file mode 100644 index 0000000..49a0b6a --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/network/simpleimpl/SimpleNetworkWrapper.java @@ -0,0 +1,165 @@ +package cpw.mods.fml.common.network.simpleimpl; + +import io.netty.channel.ChannelFutureListener; +import java.util.EnumMap; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.tileentity.TileEntity; +import cpw.mods.fml.common.network.FMLEmbeddedChannel; +import cpw.mods.fml.common.network.FMLOutboundHandler; +import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; +import cpw.mods.fml.relauncher.Side; + +/** + * This class is a simplified netty wrapper for those not wishing to deal with the full power of netty. + * It provides a simple message driven system, based on a discriminator byte over the custom packet channel. + * + * Usage is simple:
    + *
  • construct, and store, an instance of this class. It will automatically register and configure your underlying netty channel. + * + *
  • Then, call {@link #registerMessage(Class, Class, byte, Side)} for each message type you want to exchange + * providing an {@link IMessageHandler} implementation class as well as an {@link IMessage} implementation class. The side parameter + * to that method indicates which side (server or client) the message processing will occur on. The discriminator byte + * should be unique for this channelName - it is used to discriminate between different types of message that might + * occur on this channel (a simple form of message channel multiplexing, if you will). + *
  • To get a packet suitable for presenting to the rest of minecraft, you can call {@link #getPacketFrom(IMessage)}. The return result + * is suitable for returning from things like {@link TileEntity#getDescriptionPacket} for example. + *
  • Finally, use the sendXXX to send unsolicited messages to various classes of recipients. + *
+ * + * + * + * @author cpw + * + */ +public class SimpleNetworkWrapper { + private EnumMap channels; + private SimpleIndexedCodec packetCodec; + + public SimpleNetworkWrapper(String channelName) + { + packetCodec = new SimpleIndexedCodec(); + channels = NetworkRegistry.INSTANCE.newChannel(channelName, packetCodec); + } + + /** + * Register a message and it's associated handler. The message will have the supplied discriminator byte. The message handler will + * be registered on the supplied side (this is the side where you want the message to be processed and acted upon). + * + * @param messageHandler the message handler type + * @param message the message type + * @param discriminator a discriminator byte + * @param side the side for the handler + */ + public void registerMessage(Class> messageHandler, Class message, int discriminator, Side side) + { + packetCodec.addDiscriminator(discriminator, message); + FMLEmbeddedChannel channel = channels.get(side); + String type = channel.findChannelHandlerNameForType(SimpleIndexedCodec.class); + if (side == Side.SERVER) + { + addServerHandlerAfter(channel, type, messageHandler); + } + else + { + addClientHandlerAfter(channel, type, messageHandler); + } + } + + private void addServerHandlerAfter(FMLEmbeddedChannel channel, String type, Class> messageHandler) + { + SimpleChannelHandlerWrapper handler = getHandlerWrapper(messageHandler, Side.SERVER); + channel.pipeline().addAfter(type, messageHandler.getName(), handler); + } + + private void addClientHandlerAfter(FMLEmbeddedChannel channel, String type, Class> messageHandler) + { + SimpleChannelHandlerWrapper handler = getHandlerWrapper(messageHandler, Side.CLIENT); + channel.pipeline().addAfter(type, messageHandler.getName(), handler); + } + + private SimpleChannelHandlerWrapper getHandlerWrapper(Class> messageHandler, Side side) + { + return new SimpleChannelHandlerWrapper(messageHandler, side); + } + + /** + * Construct a minecraft packet from the supplied message. Can be used where minecraft packets are required, such as + * {@link TileEntity#getDescriptionPacket}. + * + * @param message The message to translate into packet form + * @return A minecraft {@link Packet} suitable for use in minecraft APIs + */ + public Packet getPacketFrom(IMessage message) + { + return channels.get(Side.SERVER).generatePacketFrom(message); + } + + /** + * Send this message to everyone. + * The {@link IMessageHandler} for this message type should be on the CLIENT side. + * + * @param message The message to send + */ + public void sendToAll(IMessage message) + { + channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALL); + channels.get(Side.SERVER).writeAndFlush(message).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); + } + + /** + * Send this message to the specified player. + * The {@link IMessageHandler} for this message type should be on the CLIENT side. + * + * @param message The message to send + * @param player The player to send it to + */ + public void sendTo(IMessage message, EntityPlayerMP player) + { + channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.PLAYER); + channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(player); + channels.get(Side.SERVER).writeAndFlush(message).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); + } + + /** + * Send this message to everyone within a certain range of a point. + * The {@link IMessageHandler} for this message type should be on the CLIENT side. + * + * @param message The message to send + * @param point The {@link TargetPoint} around which to send + */ + public void sendToAllAround(IMessage message, NetworkRegistry.TargetPoint point) + { + channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALLAROUNDPOINT); + channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(point); + channels.get(Side.SERVER).writeAndFlush(message).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); + } + + /** + * Send this message to everyone within the supplied dimension. + * The {@link IMessageHandler} for this message type should be on the CLIENT side. + * + * @param message The message to send + * @param dimensionId The dimension id to target + */ + public void sendToDimension(IMessage message, int dimensionId) + { + channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.DIMENSION); + channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(dimensionId); + channels.get(Side.SERVER).writeAndFlush(message).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); + } + + /** + * Send this message to the server. + * The {@link IMessageHandler} for this message type should be on the SERVER side. + * + * @param message The message to send + */ + public void sendToServer(IMessage message) + { + channels.get(Side.CLIENT).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.TOSERVER); + channels.get(Side.CLIENT).writeAndFlush(message).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/patcher/ClassPatch.java b/src/main/java/cpw/mods/fml/common/patcher/ClassPatch.java new file mode 100644 index 0000000..9b435e7 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/patcher/ClassPatch.java @@ -0,0 +1,25 @@ +package cpw.mods.fml.common.patcher; + +public class ClassPatch { + public final String name; + public final String sourceClassName; + public final String targetClassName; + public final boolean existsAtTarget; + public final byte[] patch; + public final int inputChecksum; + public ClassPatch(String name, String sourceClassName, String targetClassName, boolean existsAtTarget, int inputChecksum, byte[] patch) + { + this.name = name; + this.sourceClassName = sourceClassName; + this.targetClassName = targetClassName; + this.existsAtTarget = existsAtTarget; + this.inputChecksum = inputChecksum; + this.patch = patch; + } + + @Override + public String toString() + { + return String.format("%s : %s => %s (%b) size %d", name, sourceClassName, targetClassName, existsAtTarget, patch.length); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/patcher/ClassPatchManager.java b/src/main/java/cpw/mods/fml/common/patcher/ClassPatchManager.java new file mode 100644 index 0000000..a2e1082 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/patcher/ClassPatchManager.java @@ -0,0 +1,229 @@ +package cpw.mods.fml.common.patcher; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.jar.JarEntry; +import java.util.jar.JarInputStream; +import java.util.jar.JarOutputStream; +import java.util.jar.Pack200; +import java.util.regex.Pattern; + +import org.apache.logging.log4j.Level; + +import net.minecraft.launchwrapper.LaunchClassLoader; + +import LZMA.LzmaInputStream; + +import com.google.common.base.Joiner; +import com.google.common.base.Throwables; +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.ListMultimap; +import com.google.common.collect.Maps; +import com.google.common.hash.Hashing; +import com.google.common.io.ByteArrayDataInput; +import com.google.common.io.ByteStreams; +import com.google.common.io.Files; + +import cpw.mods.fml.relauncher.FMLRelaunchLog; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.repackage.com.nothome.delta.GDiffPatcher; + +public class ClassPatchManager { + public static final ClassPatchManager INSTANCE = new ClassPatchManager(); + + public static final boolean dumpPatched = Boolean.parseBoolean(System.getProperty("fml.dumpPatchedClasses", "false")); + + private GDiffPatcher patcher = new GDiffPatcher(); + private ListMultimap patches; + + private Map patchedClasses = Maps.newHashMap(); + private File tempDir; + private ClassPatchManager() + { + if (dumpPatched) + { + tempDir = Files.createTempDir(); + FMLRelaunchLog.info("Dumping patched classes to %s",tempDir.getAbsolutePath()); + } + } + + + public byte[] getPatchedResource(String name, String mappedName, LaunchClassLoader loader) throws IOException + { + byte[] rawClassBytes = loader.getClassBytes(name); + return applyPatch(name, mappedName, rawClassBytes); + } + public byte[] applyPatch(String name, String mappedName, byte[] inputData) + { + if (patches == null) + { + return inputData; + } + if (patchedClasses.containsKey(name)) + { + return patchedClasses.get(name); + } + List list = patches.get(name); + if (list.isEmpty()) + { + return inputData; + } + boolean ignoredError = false; + FMLRelaunchLog.fine("Runtime patching class %s (input size %d), found %d patch%s", mappedName, (inputData == null ? 0 : inputData.length), list.size(), list.size()!=1 ? "es" : ""); + for (ClassPatch patch: list) + { + if (!patch.targetClassName.equals(mappedName) && !patch.sourceClassName.equals(name)) + { + FMLRelaunchLog.warning("Binary patch found %s for wrong class %s", patch.targetClassName, mappedName); + } + if (!patch.existsAtTarget && (inputData == null || inputData.length == 0)) + { + inputData = new byte[0]; + } + else if (!patch.existsAtTarget) + { + FMLRelaunchLog.warning("Patcher expecting empty class data file for %s, but received non-empty", patch.targetClassName); + } + else + { + int inputChecksum = Hashing.adler32().hashBytes(inputData).asInt(); + if (patch.inputChecksum != inputChecksum) + { + FMLRelaunchLog.severe("There is a binary discrepency between the expected input class %s (%s) and the actual class. Checksum on disk is %x, in patch %x. Things are probably about to go very wrong. Did you put something into the jar file?", mappedName, name, inputChecksum, patch.inputChecksum); + if (!Boolean.parseBoolean(System.getProperty("fml.ignorePatchDiscrepancies","false"))) + { + FMLRelaunchLog.severe("The game is going to exit, because this is a critical error, and it is very improbable that the modded game will work, please obtain clean jar files."); + System.exit(1); + } + else + { + FMLRelaunchLog.severe("FML is going to ignore this error, note that the patch will not be applied, and there is likely to be a malfunctioning behaviour, including not running at all"); + ignoredError = true; + continue; + } + } + } + synchronized (patcher) + { + try + { + inputData = patcher.patch(inputData, patch.patch); + } + catch (IOException e) + { + FMLRelaunchLog.log(Level.ERROR, e, "Encountered problem runtime patching class %s", name); + continue; + } + } + } + if (!ignoredError) + { + FMLRelaunchLog.fine("Successfully applied runtime patches for %s (new size %d)", mappedName, inputData.length); + } + if (dumpPatched) + { + try + { + Files.write(inputData, new File(tempDir,mappedName)); + } + catch (IOException e) + { + FMLRelaunchLog.log(Level.ERROR, e, "Failed to write %s to %s", mappedName, tempDir.getAbsolutePath()); + } + } + patchedClasses.put(name,inputData); + return inputData; + } + + public void setup(Side side) + { + Pattern binpatchMatcher = Pattern.compile(String.format("binpatch/%s/.*.binpatch", side.toString().toLowerCase(Locale.ENGLISH))); + JarInputStream jis; + try + { + InputStream binpatchesCompressed = getClass().getResourceAsStream("/binpatches.pack.lzma"); + if (binpatchesCompressed==null) + { + FMLRelaunchLog.log(Level.ERROR, "The binary patch set is missing. Either you are in a development environment, or things are not going to work!"); + return; + } + LzmaInputStream binpatchesDecompressed = new LzmaInputStream(binpatchesCompressed); + ByteArrayOutputStream jarBytes = new ByteArrayOutputStream(); + JarOutputStream jos = new JarOutputStream(jarBytes); + Pack200.newUnpacker().unpack(binpatchesDecompressed, jos); + jis = new JarInputStream(new ByteArrayInputStream(jarBytes.toByteArray())); + } + catch (Exception e) + { + FMLRelaunchLog.log(Level.ERROR, e, "Error occurred reading binary patches. Expect severe problems!"); + throw Throwables.propagate(e); + } + + patches = ArrayListMultimap.create(); + + do + { + try + { + JarEntry entry = jis.getNextJarEntry(); + if (entry == null) + { + break; + } + if (binpatchMatcher.matcher(entry.getName()).matches()) + { + ClassPatch cp = readPatch(entry, jis); + if (cp != null) + { + patches.put(cp.sourceClassName, cp); + } + } + else + { + jis.closeEntry(); + } + } + catch (IOException e) + { + } + } while (true); + FMLRelaunchLog.fine("Read %d binary patches", patches.size()); + FMLRelaunchLog.fine("Patch list :\n\t%s", Joiner.on("\t\n").join(patches.asMap().entrySet())); + patchedClasses.clear(); + } + + private ClassPatch readPatch(JarEntry patchEntry, JarInputStream jis) + { + FMLRelaunchLog.finer("Reading patch data from %s", patchEntry.getName()); + ByteArrayDataInput input; + try + { + input = ByteStreams.newDataInput(ByteStreams.toByteArray(jis)); + } + catch (IOException e) + { + FMLRelaunchLog.log(Level.WARN, e, "Unable to read binpatch file %s - ignoring", patchEntry.getName()); + return null; + } + String name = input.readUTF(); + String sourceClassName = input.readUTF(); + String targetClassName = input.readUTF(); + boolean exists = input.readBoolean(); + int inputChecksum = 0; + if (exists) + { + inputChecksum = input.readInt(); + } + int patchLength = input.readInt(); + byte[] patchBytes = new byte[patchLength]; + input.readFully(patchBytes); + + return new ClassPatch(name, sourceClassName, targetClassName, exists, inputChecksum, patchBytes); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/patcher/GenDiffSet.java b/src/main/java/cpw/mods/fml/common/patcher/GenDiffSet.java new file mode 100644 index 0000000..714bea8 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/patcher/GenDiffSet.java @@ -0,0 +1,100 @@ +package cpw.mods.fml.common.patcher; + +import java.io.File; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import java.util.Locale; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.LogManager; + +import java.util.logging.Logger; + +import com.google.common.hash.Hashing; +import com.google.common.io.ByteArrayDataOutput; +import com.google.common.io.ByteStreams; +import com.google.common.io.Files; + +import cpw.mods.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper; +import cpw.mods.fml.repackage.com.nothome.delta.Delta; + +public class GenDiffSet { + + private static final List RESERVED_NAMES = Arrays.asList("CON", "PRN", "AUX", "NUL", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9", "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9"); + + public static void main(String[] args) throws IOException + { + String sourceJar = args[0]; //Clean Vanilla jar minecraft.jar or minecraft_server.jar + String targetDir = args[1]; //Directory containing obfed output classes, typically mcp/reobf/minecraft + String deobfData = args[2]; //Path to FML's deobfusication_data.lzma + String outputDir = args[3]; //Path to place generated .binpatch + String killTarget = args[4]; //"true" if we should destroy the target file if it generated a successful .binpatch + + LogManager.getLogger("GENDIFF").log(Level.INFO, String.format("Creating patches at %s for %s from %s", outputDir, sourceJar, targetDir)); + Delta delta = new Delta(); + FMLDeobfuscatingRemapper remapper = FMLDeobfuscatingRemapper.INSTANCE; + remapper.setupLoadOnly(deobfData, false); + JarFile sourceZip = new JarFile(sourceJar); + boolean kill = killTarget.equalsIgnoreCase("true"); + + File f = new File(outputDir); + f.mkdirs(); + + for (String name : remapper.getObfedClasses()) + { +// Logger.getLogger("GENDIFF").info(String.format("Evaluating path for data :%s",name)); + String fileName = name; + String jarName = name; + if (RESERVED_NAMES.contains(name.toUpperCase(Locale.ENGLISH))) + { + fileName = "_"+name; + } + File targetFile = new File(targetDir, fileName.replace('/', File.separatorChar) + ".class"); + jarName = jarName+".class"; + if (targetFile.exists()) + { + String sourceClassName = name.replace('/', '.'); + String targetClassName = remapper.map(name).replace('/', '.'); + JarEntry entry = sourceZip.getJarEntry(jarName); + + byte[] vanillaBytes = entry != null ? ByteStreams.toByteArray(sourceZip.getInputStream(entry)) : new byte[0]; + byte[] patchedBytes = Files.toByteArray(targetFile); + + byte[] diff = delta.compute(vanillaBytes, patchedBytes); + + + ByteArrayDataOutput diffOut = ByteStreams.newDataOutput(diff.length + 50); + // Original name + diffOut.writeUTF(name); + // Source name + diffOut.writeUTF(sourceClassName); + // Target name + diffOut.writeUTF(targetClassName); + // exists at original + diffOut.writeBoolean(entry != null); + if (entry != null) + { + diffOut.writeInt(Hashing.adler32().hashBytes(vanillaBytes).asInt()); + } + // length of patch + diffOut.writeInt(diff.length); + // patch + diffOut.write(diff); + + File target = new File(outputDir, targetClassName+".binpatch"); + target.getParentFile().mkdirs(); + Files.write(diffOut.toByteArray(), target); + Logger.getLogger("GENDIFF").info(String.format("Wrote patch for %s (%s) at %s",name, targetClassName, target.getAbsolutePath())); + if (kill) + { + targetFile.delete(); + Logger.getLogger("GENDIFF").info(String.format(" Deleted target: %s", targetFile.toString())); + } + } + } + sourceZip.close(); + } + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/registry/EntityRegistry.java b/src/main/java/cpw/mods/fml/common/registry/EntityRegistry.java new file mode 100644 index 0000000..69cfe70 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/registry/EntityRegistry.java @@ -0,0 +1,369 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.registry; + +import java.util.BitSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.apache.logging.log4j.Level; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityList; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityTracker; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.biome.BiomeGenBase.SpawnListEntry; + +import com.google.common.base.Function; +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; +import com.google.common.collect.ListMultimap; +import com.google.common.collect.Maps; +import com.google.common.primitives.UnsignedBytes; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.ModContainer; +import cpw.mods.fml.common.network.internal.FMLMessage.EntitySpawnMessage; + +public class EntityRegistry +{ + public class EntityRegistration + { + private Class entityClass; + private ModContainer container; + private String entityName; + private int modId; + private int trackingRange; + private int updateFrequency; + private boolean sendsVelocityUpdates; + private Function customSpawnCallback; + private boolean usesVanillaSpawning; + public EntityRegistration(ModContainer mc, Class entityClass, String entityName, int id, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates) + { + this.container = mc; + this.entityClass = entityClass; + this.entityName = entityName; + this.modId = id; + this.trackingRange = trackingRange; + this.updateFrequency = updateFrequency; + this.sendsVelocityUpdates = sendsVelocityUpdates; + } + public Class getEntityClass() + { + return entityClass; + } + public ModContainer getContainer() + { + return container; + } + public String getEntityName() + { + return entityName; + } + public int getModEntityId() + { + return modId; + } + public int getTrackingRange() + { + return trackingRange; + } + public int getUpdateFrequency() + { + return updateFrequency; + } + public boolean sendsVelocityUpdates() + { + return sendsVelocityUpdates; + } + + public boolean usesVanillaSpawning() + { + return usesVanillaSpawning; + } + public boolean hasCustomSpawning() + { + return customSpawnCallback != null; + } + public Entity doCustomSpawning(EntitySpawnMessage spawnMsg) throws Exception + { + return customSpawnCallback.apply(spawnMsg); + } + public void setCustomSpawning(Function callable, boolean usesVanillaSpawning) + { + this.customSpawnCallback = callable; + this.usesVanillaSpawning = usesVanillaSpawning; + } + } + + private static final EntityRegistry INSTANCE = new EntityRegistry(); + + private BitSet availableIndicies; + private ListMultimap entityRegistrations = ArrayListMultimap.create(); + private Map entityNames = Maps.newHashMap(); + private BiMap, EntityRegistration> entityClassRegistrations = HashBiMap.create(); + public static EntityRegistry instance() + { + return INSTANCE; + } + + private EntityRegistry() + { + availableIndicies = new BitSet(256); + availableIndicies.set(1,255); + for (Object id : EntityList.IDtoClassMapping.keySet()) + { + availableIndicies.clear((Integer)id); + } + } + + /** + * Register the mod entity type with FML + + * @param entityClass The entity class + * @param entityName A unique name for the entity + * @param id A mod specific ID for the entity + * @param mod The mod + * @param trackingRange The range at which MC will send tracking updates + * @param updateFrequency The frequency of tracking updates + * @param sendsVelocityUpdates Whether to send velocity information packets as well + */ + public static void registerModEntity(Class entityClass, String entityName, int id, Object mod, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates) + { + instance().doModEntityRegistration(entityClass, entityName, id, mod, trackingRange, updateFrequency, sendsVelocityUpdates); + } + + @SuppressWarnings("unchecked") + private void doModEntityRegistration(Class entityClass, String entityName, int id, Object mod, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates) + { + ModContainer mc = FMLCommonHandler.instance().findContainerFor(mod); + EntityRegistration er = new EntityRegistration(mc, entityClass, entityName, id, trackingRange, updateFrequency, sendsVelocityUpdates); + try + { + entityClassRegistrations.put(entityClass, er); + entityNames.put(entityName, mc); + if (!EntityList.classToStringMapping.containsKey(entityClass)) + { + String entityModName = String.format("%s.%s", mc.getModId(), entityName); + EntityList.classToStringMapping.put(entityClass, entityModName); + EntityList.stringToClassMapping.put(entityModName, entityClass); + FMLLog.finer("Automatically registered mod %s entity %s as %s", mc.getModId(), entityName, entityModName); + } + else + { + FMLLog.fine("Skipping automatic mod %s entity registration for already registered class %s", mc.getModId(), entityClass.getName()); + } + } + catch (IllegalArgumentException e) + { + FMLLog.log(Level.WARN, e, "The mod %s tried to register the entity (name,class) (%s,%s) one or both of which are already registered", mc.getModId(), entityName, entityClass.getName()); + return; + } + entityRegistrations.put(mc, er); + } + + public static void registerGlobalEntityID(Class entityClass, String entityName, int id) + { + if (EntityList.classToStringMapping.containsKey(entityClass)) + { + ModContainer activeModContainer = Loader.instance().activeModContainer(); + String modId = "unknown"; + if (activeModContainer != null) + { + modId = activeModContainer.getModId(); + } + else + { + FMLLog.severe("There is a rogue mod failing to register entities from outside the context of mod loading. This is incredibly dangerous and should be stopped."); + } + FMLLog.warning("The mod %s tried to register the entity class %s which was already registered - if you wish to override default naming for FML mod entities, register it here first", modId, entityClass); + return; + } + id = instance().validateAndClaimId(id); + EntityList.addMapping(entityClass, entityName, id); + } + + private int validateAndClaimId(int id) + { + // workaround for broken ML + int realId = id; + if (id < Byte.MIN_VALUE) + { + FMLLog.warning("Compensating for modloader out of range compensation by mod : entityId %d for mod %s is now %d", id, Loader.instance().activeModContainer().getModId(), realId); + realId += 3000; + } + + if (realId < 0) + { + realId += Byte.MAX_VALUE; + } + try + { + UnsignedBytes.checkedCast(realId); + } + catch (IllegalArgumentException e) + { + FMLLog.log(Level.ERROR, "The entity ID %d for mod %s is not an unsigned byte and may not work", id, Loader.instance().activeModContainer().getModId()); + } + + if (!availableIndicies.get(realId)) + { + FMLLog.severe("The mod %s has attempted to register an entity ID %d which is already reserved. This could cause severe problems", Loader.instance().activeModContainer().getModId(), id); + } + availableIndicies.clear(realId); + return realId; + } + + public static void registerGlobalEntityID(Class entityClass, String entityName, int id, int backgroundEggColour, int foregroundEggColour) + { + if (EntityList.classToStringMapping.containsKey(entityClass)) + { + ModContainer activeModContainer = Loader.instance().activeModContainer(); + String modId = "unknown"; + if (activeModContainer != null) + { + modId = activeModContainer.getModId(); + } + else + { + FMLLog.severe("There is a rogue mod failing to register entities from outside the context of mod loading. This is incredibly dangerous and should be stopped."); + } + FMLLog.warning("The mod %s tried to register the entity class %s which was already registered - if you wish to override default naming for FML mod entities, register it here first", modId, entityClass); + return; + } + instance().validateAndClaimId(id); + EntityList.addMapping(entityClass, entityName, id, backgroundEggColour, foregroundEggColour); + } + + public static void addSpawn(Class entityClass, int weightedProb, int min, int max, EnumCreatureType typeOfCreature, BiomeGenBase... biomes) + { + for (BiomeGenBase biome : biomes) + { + @SuppressWarnings("unchecked") + List spawns = biome.getSpawnableList(typeOfCreature); + + for (SpawnListEntry entry : spawns) + { + //Adjusting an existing spawn entry + if (entry.entityClass == entityClass) + { + entry.itemWeight = weightedProb; + entry.minGroupCount = min; + entry.maxGroupCount = max; + break; + } + } + + spawns.add(new SpawnListEntry(entityClass, weightedProb, min, max)); + } + } + + @SuppressWarnings("unchecked") + public static void addSpawn(String entityName, int weightedProb, int min, int max, EnumCreatureType spawnList, BiomeGenBase... biomes) + { + Class entityClazz = (Class) EntityList.stringToClassMapping.get(entityName); + + if (EntityLiving.class.isAssignableFrom(entityClazz)) + { + addSpawn((Class ) entityClazz, weightedProb, min, max, spawnList, biomes); + } + } + + public static void removeSpawn(Class entityClass, EnumCreatureType typeOfCreature, BiomeGenBase... biomes) + { + for (BiomeGenBase biome : biomes) + { + @SuppressWarnings("unchecked") + Iterator spawns = biome.getSpawnableList(typeOfCreature).iterator(); + + while (spawns.hasNext()) + { + SpawnListEntry entry = spawns.next(); + if (entry.entityClass == entityClass) + { + spawns.remove(); + } + } + } + } + + @SuppressWarnings("unchecked") + public static void removeSpawn(String entityName, EnumCreatureType spawnList, BiomeGenBase... biomes) + { + Class entityClazz = (Class) EntityList.stringToClassMapping.get(entityName); + + if (EntityLiving.class.isAssignableFrom(entityClazz)) + { + removeSpawn((Class ) entityClazz, spawnList, biomes); + } + } + + public static int findGlobalUniqueEntityId() + { + int res = instance().availableIndicies.nextSetBit(0); + if (res < 0) + { + throw new RuntimeException("No more entity indicies left"); + } + return res; + } + + public EntityRegistration lookupModSpawn(Class clazz, boolean keepLooking) + { + Class localClazz = clazz; + + do + { + EntityRegistration er = entityClassRegistrations.get(localClazz); + if (er != null) + { + return er; + } + localClazz = localClazz.getSuperclass(); + keepLooking = (!Object.class.equals(localClazz)); + } + while (keepLooking); + + return null; + } + + public EntityRegistration lookupModSpawn(ModContainer mc, int modEntityId) + { + for (EntityRegistration er : entityRegistrations.get(mc)) + { + if (er.getModEntityId() == modEntityId) + { + return er; + } + } + return null; + } + + public boolean tryTrackingEntity(EntityTracker entityTracker, Entity entity) + { + + EntityRegistration er = lookupModSpawn(entity.getClass(), true); + if (er != null) + { + entityTracker.addEntityToTracker(entity, er.getTrackingRange(), er.getUpdateFrequency(), er.sendsVelocityUpdates()); + return true; + } + return false; + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/registry/FMLControlledNamespacedRegistry.java b/src/main/java/cpw/mods/fml/common/registry/FMLControlledNamespacedRegistry.java new file mode 100644 index 0000000..00f7390 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/registry/FMLControlledNamespacedRegistry.java @@ -0,0 +1,378 @@ +package cpw.mods.fml.common.registry; + +import java.util.ArrayList; +import java.util.BitSet; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import net.minecraft.util.ObjectIntIdentityMap; +import net.minecraft.util.RegistryNamespaced; + +import com.google.common.collect.ImmutableMap; + +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.ModContainer; + +public class FMLControlledNamespacedRegistry extends RegistryNamespaced { + private final Class superType; + private String optionalDefaultName; + private I optionalDefaultObject; + private int maxId; + private int minId; + private char discriminator; + // aliases redirecting legacy names to the actual name, may need recursive application to find the final name. + // these need to be registry specific, it's possible to only have a loosely linked item for a block which may get renamed by itself. + private final Map aliases = new HashMap(); + + FMLControlledNamespacedRegistry(String optionalDefault, int maxIdValue, int minIdValue, Class type, char discriminator) + { + this.superType = type; + this.discriminator = discriminator; + this.optionalDefaultName = optionalDefault; + this.maxId = maxIdValue; + this.minId = minIdValue; + } + + @SuppressWarnings("unchecked") + void set(FMLControlledNamespacedRegistry registry) + { + if (this.superType != registry.superType) throw new IllegalArgumentException("incompatible registry"); + + this.discriminator = registry.discriminator; + this.optionalDefaultName = registry.optionalDefaultName; + this.maxId = registry.maxId; + this.minId = registry.minId; + this.aliases.clear(); + this.aliases.putAll(registry.aliases); + underlyingIntegerMap = new ObjectIntIdentityMap(); + registryObjects.clear(); + + for (I thing : (Iterable) registry) + { + addObjectRaw(registry.getId(thing), registry.getNameForObject(thing), thing); + } + } + + // public api + + /** + * Add an object to the registry, trying to use the specified id. + * + * @deprecated register through {@link GameRegistry} instead. + */ + @Override + @Deprecated + public void addObject(int id, String name, Object thing) + { + GameData.getMain().register(thing, name, id); + } + + /** + * DANGEROUS! EVIL! DO NOT USE! + * + * @deprecated register through {@link GameRegistry} instead. + */ + @Override + @Deprecated + public void putObject(Object objName, Object obj) + { + String name = (String) objName; + I thing = (I) obj; + + if (name == null) throw new NullPointerException("Can't use a null-name for the registry."); + if (name.isEmpty()) throw new IllegalArgumentException("Can't use an empty name for the registry."); + if (thing == null) throw new NullPointerException("Can't add null-object to the registry."); + + String existingName = getNameForObject(thing); + + if (existingName == null) + { + FMLLog.bigWarning("Ignoring putObject(%s, %s), not resolvable", name, thing); + } + else if (existingName.equals(name)) + { + FMLLog.bigWarning("Ignoring putObject(%s, %s), already added", name, thing); + } + else + { + FMLLog.bigWarning("Ignoring putObject(%s, %s), adding alias to %s instead", name, thing, existingName); + addAlias(name, existingName); + } + } + + /** + * Fetch the object identified by the specified name or the default object. + * + * For blocks the default object is the air block, for items it's null. + * + * @param name Unique name identifying the object. + * @return Registered object of the default object if it wasn't found- + */ + @Override + public I getObject(String name) + { + I object = getRaw(name); + return object == null ? this.optionalDefaultObject : object; + } + + /** + * Fetch the object identified by the specified id or the default object. + * + * For blocks the default object is the air block, for items it's null. + * + * @param id ID identifying the object. + * @return Registered object of the default object if it wasn't found- + */ + @Override + public I getObjectById(int id) + { + I object = getRaw(id); + return object == null ? this.optionalDefaultObject : object; + } + + /** + * @deprecated use getObjectById instead + */ + @Deprecated + public I get(int id) + { + return getObjectById(id); + } + + /** + * @deprecated use getObject instead + */ + @Deprecated + public I get(String name) + { + return getObject(name); + } + + /** + * Get the id for the specified object. + * + * Don't hold onto the id across the world, it's being dynamically re-mapped as needed. + * + * Usually the name should be used instead of the id, if using the Block/Item object itself is + * not suitable for the task. + * + * @param thing Block/Item object. + * @return Block/Item id or -1 if it wasn't found. + */ + public int getId(I thing) + { + return getIDForObject(thing); + } + + /** + * Get the object identified by the specified id. + * + * @param id Block/Item id. + * @return Block/Item object or null if it wasn't found. + */ + public I getRaw(int id) + { + return superType.cast(super.getObjectById(id)); + } + + /** + * Get the object identified by the specified name. + * + * @param name Block/Item name. + * @return Block/Item object or null if it wasn't found. + */ + public I getRaw(String name) + { + I ret = superType.cast(super.getObject(name)); + + if (ret == null) // no match, try aliases recursively + { + name = aliases.get(name); + + if (name != null) return getRaw(name); + } + + return ret; + } + + /** + * Determine if the registry has an entry for the specified name. + * + * Aliased names will be resolved as well. + * + * @param name Object name to check. + * @return true if a matching entry was found. + */ + @Override + public boolean containsKey(String name) + { + boolean ret = super.containsKey(name); + + if (!ret) // no match, try aliases recursively + { + name = aliases.get(name); + + if (name != null) return containsKey(name); + } + + return ret; + } + + /** + * Get the id for the specified object. + * + * Don't hold onto the id across the world, it's being dynamically re-mapped as needed. + * + * Usually the name should be used instead of the id, if using the Block/Item object itself is + * not suitable for the task. + * + * @param itemName Block/Item registry name. + * @return Block/Item id or -1 if it wasn't found. + */ + public int getId(String itemName) + { + I obj = getRaw(itemName); + if (obj == null) return -1; + + return getId(obj); + } + + /** + * @deprecated use containsKey instead + */ + @Deprecated + public boolean contains(String itemName) + { + return containsKey(itemName); + } + + // internal + + @SuppressWarnings("unchecked") + public void serializeInto(Map idMapping) // for saving + { + for (I thing : (Iterable) this) + { + idMapping.put(discriminator+getNameForObject(thing), getId(thing)); + } + } + + public Map getAliases() // for saving + { + return ImmutableMap.copyOf(aliases); + } + + /** + * Add the specified object to the registry. + * + * @param id ID to use if available, auto-assigned otherwise. + * @param name Name to use, prefixed by the mod id. + * @param thing Object to add. + * @param availabilityMap Map marking available IDs for auto assignment. + * @return ID eventually allocated. + */ + int add(int id, String name, I thing, BitSet availabilityMap) + { + if (name == null) throw new NullPointerException("Can't use a null-name for the registry."); + if (name.isEmpty()) throw new IllegalArgumentException("Can't use an empty name for the registry."); + if (thing == null) throw new NullPointerException("Can't add null-object to the registry."); + if (name.equals(optionalDefaultName)) + { + this.optionalDefaultObject = thing; + } + + int idToUse = id; + if (id == 0 || availabilityMap.get(id)) + { + idToUse = availabilityMap.nextClearBit(minId); + } + if (idToUse > maxId) + { + throw new RuntimeException(String.format("Invalid id %d - maximum id range exceeded.", id)); + } + + ModContainer mc = Loader.instance().activeModContainer(); + if (mc != null) + { + String prefix = mc.getModId(); + name = prefix + ":"+ name; + } + + if (getRaw(name) == thing) // already registered, return prev registration's id + { + FMLLog.bigWarning("The object %s has been registered twice for the same name %s.", thing, name); + return getId(thing); + } + if (getRaw(name) != null) // duplicate name, will crash later due to the BiMap + { + FMLLog.bigWarning("The name %s has been registered twice, for %s and %s.", name, getRaw(name), thing); + } + if (getId(thing) >= 0) // duplicate object, will crash later due to the BiMap + { + FMLLog.bigWarning("The object %s has been registered twice, using the names %s and %s.", thing, getNameForObject(thing), name); + } + if (GameData.isFrozen(this)) + { + FMLLog.bigWarning("The object %s (name %s) is being added too late.", thing, name); + } + + addObjectRaw(idToUse, name, thing); + + FMLLog.finer("Registry add: %s %d %s", name, idToUse, thing); + return idToUse; + } + + void addAlias(String from, String to) + { + aliases.put(from, to); + FMLLog.finer("Registry alias: %s -> %s", from, to); + } + + @SuppressWarnings("unchecked") + Map getEntriesNotIn(FMLControlledNamespacedRegistry registry) + { + Map ret = new HashMap(); + + for (I thing : (Iterable) this) + { + if (!registry.field_148758_b.containsKey(thing)) ret.put(getNameForObject(thing), getId(thing)); + } + + return ret; + } + + @SuppressWarnings("unchecked") + void dump() + { + List ids = new ArrayList(); + + for (I thing : (Iterable) this) + { + ids.add(getId(thing)); + } + + // sort by id + Collections.sort(ids); + + for (int id : ids) + { + I thing = getRaw(id); + FMLLog.finer("Registry: %s %d %s", getNameForObject(thing), id, thing); + } + } + + /** + * Version of addObject not using the API restricting overrides. + */ + private void addObjectRaw(int id, String name, I thing) + { + if (name == null) throw new NullPointerException(); + if (thing == null) throw new NullPointerException(); + + underlyingIntegerMap.func_148746_a(thing, id); // obj <-> id + super.putObject(ensureNamespaced(name), thing); // name <-> obj + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/registry/GameData.java b/src/main/java/cpw/mods/fml/common/registry/GameData.java new file mode 100644 index 0000000..f50f180 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/registry/GameData.java @@ -0,0 +1,921 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.registry; + +import java.io.File; +import java.io.IOException; +import java.util.Arrays; +import java.util.BitSet; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; + +import org.apache.logging.log4j.Level; + +import com.google.common.base.Charsets; +import com.google.common.base.Joiner; +import com.google.common.base.Joiner.MapJoiner; +import com.google.common.collect.HashBasedTable; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableListMultimap; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Table; +import com.google.common.io.Files; + +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.ModContainer; +import cpw.mods.fml.common.StartupQuery; +import cpw.mods.fml.common.ZipperUtil; +import cpw.mods.fml.common.event.FMLMissingMappingsEvent; +import cpw.mods.fml.common.event.FMLMissingMappingsEvent.MissingMapping; +import cpw.mods.fml.common.registry.GameRegistry.Type; +import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier; + +public class GameData { + private static final int MIN_BLOCK_ID = 0; + private static final int MAX_BLOCK_ID = 4095; + private static final int MIN_ITEM_ID = 4096; + private static final int MAX_ITEM_ID = 31999; + + private static final GameData mainData = new GameData(); + + /** + * @deprecated use {@link getBlockRegistry()} instead. + */ + @Deprecated + public static final FMLControlledNamespacedRegistry blockRegistry = getBlockRegistry(); + /** + * @deprecated use {@link getItemRegistry()} instead. + */ + @Deprecated + public static final FMLControlledNamespacedRegistry itemRegistry = getItemRegistry(); + + private static Table customItemStacks = HashBasedTable.create(); + private static Map customOwners = Maps.newHashMap(); + private static GameData frozen; + + // public api + + /** + * Get the currently active block registry. + * + * @return Block Registry. + */ + public static FMLControlledNamespacedRegistry getBlockRegistry() { + return getMain().iBlockRegistry; + } + + /** + * Get the currently active item registry. + * + * @return Item Registry. + */ + public static FMLControlledNamespacedRegistry getItemRegistry() { + return getMain().iItemRegistry; + } + + /** + * @deprecated no replacement planned + */ + @Deprecated + public static ModContainer findModOwner(String string) + { + UniqueIdentifier ui = new UniqueIdentifier(string); + if (customOwners.containsKey(ui)) + { + return customOwners.get(ui); + } + return Loader.instance().getIndexedModList().get(ui.modId); + } + + // internal from here + + public static Map buildItemDataList() + { + Map idMapping = Maps.newHashMap(); + getMain().iBlockRegistry.serializeInto(idMapping); + getMain().iItemRegistry.serializeInto(idMapping); + return idMapping; + } + + public static int[] getBlockedIds() + { + int[] ret = new int[getMain().blockedIds.size()]; + int index = 0; + + for (int id : getMain().blockedIds) + { + ret[index] = id; + index++; + } + + return ret; + } + + public static void dumpRegistry(File minecraftDir) + { + if (customItemStacks == null) + { + return; + } + if (Boolean.valueOf(System.getProperty("fml.dumpRegistry", "false")).booleanValue()) + { + ImmutableListMultimap.Builder builder = ImmutableListMultimap.builder(); + for (String modId : customItemStacks.rowKeySet()) + { + builder.putAll(modId, customItemStacks.row(modId).keySet()); + } + + File f = new File(minecraftDir, "itemStackRegistry.csv"); + MapJoiner mapJoiner = Joiner.on("\n").withKeyValueSeparator(","); + try + { + Files.write(mapJoiner.join(builder.build().entries()), f, Charsets.UTF_8); + FMLLog.log(Level.INFO, "Dumped item registry data to %s", f.getAbsolutePath()); + } + catch (IOException e) + { + FMLLog.log(Level.ERROR, e, "Failed to write registry data to %s", f.getAbsolutePath()); + } + } + } + + static Item findItem(String modId, String name) + { + return (Item) getMain().iItemRegistry.getObject(modId + ":" + name); + } + + static Block findBlock(String modId, String name) + { + String key = modId + ":" + name; + return getMain().iBlockRegistry.containsKey(key) ? getMain().iBlockRegistry.getObject(key) : null; + } + + static ItemStack findItemStack(String modId, String name) + { + ItemStack is = customItemStacks.get(modId, name); + if (is == null) + { + Item i = findItem(modId, name); + if (i != null) + { + is = new ItemStack(i, 0 ,0); + } + } + if (is == null) + { + Block b = findBlock(modId, name); + if (b != null) + { + is = new ItemStack(b, 0, Short.MAX_VALUE); + } + } + return is; + } + + static void registerCustomItemStack(String name, ItemStack itemStack) + { + customItemStacks.put(Loader.instance().activeModContainer().getModId(), name, itemStack); + } + + static UniqueIdentifier getUniqueName(Block block) + { + if (block == null) return null; + String name = getMain().iBlockRegistry.getNameForObject(block); + UniqueIdentifier ui = new UniqueIdentifier(name); + if (customItemStacks.contains(ui.modId, ui.name)) + { + return null; + } + + return ui; + } + + static UniqueIdentifier getUniqueName(Item item) + { + if (item == null) return null; + String name = getMain().iItemRegistry.getNameForObject(item); + UniqueIdentifier ui = new UniqueIdentifier(name); + if (customItemStacks.contains(ui.modId, ui.name)) + { + return null; + } + + return ui; + } + + /** + * Fix IDs improperly allocated by early versions of the registry, best-effort. + * + * Items sharing the same ID with a block, but not sharing the same registry name will be + * mapped to an unused id. Losing items instead of blocks should minimize the damage. + * + * @param dataList List containing the IDs to fix + */ + public static void fixBrokenIds(Map dataList, Set blockedIds) + { + BitSet availabilityMap = new BitSet(MAX_ITEM_ID + 1); + + // reserve all ids occupied by blocks + for (Entry entry : dataList.entrySet()) + { + String itemName = entry.getKey(); + String realName = itemName.substring(1); + + if (itemName.charAt(0) == '\u0001') // is a block + { + availabilityMap.set(entry.getValue()); + } + } + + Set newBlockedIds = new HashSet(); + Set itemsToRemove = new HashSet(); + Map itemsToRelocate = new HashMap(); + + // check all ids occupied by items + for (Entry entry : dataList.entrySet()) + { + String itemName = entry.getKey(); + + if (itemName.charAt(0) != '\u0001') // is an item + { + int oldId = entry.getValue(); + String realName = itemName.substring(1); + String blockName = '\u0001' + realName; + Item item = getMain().iItemRegistry.getRaw(realName); + boolean blockThisId = false; // block oldId unless it's used by a block + + if (item == null) // item no longer available + { + // can't fix items without reliably checking if they are ItemBlocks + FMLLog.warning("Item %s (old id %d) is no longer available and thus can't be fixed.", realName, oldId); + itemsToRemove.add(itemName); + blockThisId = true; + } + else if (item instanceof ItemBlock) + { + if (dataList.containsKey(blockName)) // the item was an ItemBlock before + { + int blockId = dataList.get(blockName); + + if (blockId != oldId) // mis-located ItemBlock + { + // relocate to the matching block + FMLLog.warning("ItemBlock %s (old id %d) doesn't have the same id as its block (%d).", realName, oldId, blockId); + itemsToRelocate.put(entry.getKey(), blockId); + blockThisId = true; + } + else // intact ItemBlock + { + availabilityMap.set(oldId); // occupy id + } + } + else // the item hasn't been an ItemBlock before, but it's now + { + // can't fix these, drop them + FMLLog.warning("Item %s (old id %d) has been migrated to an ItemBlock and can't be fixed.", realName, oldId); + itemsToRemove.add(itemName); + blockThisId = true; + } + } + else if (availabilityMap.get(oldId)) // normal item, id is already occupied + { + // remove the item mapping + FMLLog.warning("Item %s (old id %d) is conflicting with another block/item and can't be fixed.", realName, oldId); + itemsToRemove.add(itemName); + } + else // intact Item + { + availabilityMap.set(oldId); // occupy id + } + + // handle blocking the id from future use if possible (i.e. not used by a conflicting block) + // blockThisId requests don't modify availabilityMap, it could only be set by a block (or another item, which isn't being handled) + if (blockThisId && !availabilityMap.get(oldId)) + { + // there's no block occupying this id, thus block the id from future use + // as there may still be ItemStacks in the world referencing it + newBlockedIds.add(oldId); + availabilityMap.set(oldId); + } + } + } + + if (itemsToRemove.isEmpty() && itemsToRelocate.isEmpty()) return; // nothing to do + + // confirm + String text = "Forge Mod Loader detected that this save is damaged.\n\n" + + "It's likely that an automatic repair can successfully restore\n" + + "most of it, except some items which may get swapped with others.\n\n" + + "A world backup will be created as a zip file in your saves\n" + + "directory automatically.\n\n" + + itemsToRemove.size()+" items need to be removed.\n"+ + itemsToRelocate.size()+" items need to be relocated."; + + boolean confirmed = StartupQuery.confirm(text); + if (!confirmed) StartupQuery.abort(); + + // confirm missing mods causing item removal + Set modsMissing = new HashSet(); + + for (String itemName : itemsToRemove) + { + modsMissing.add(itemName.substring(1, itemName.indexOf(':'))); + } + + for (Iterator it = modsMissing.iterator(); it.hasNext(); ) + { + String mod = it.next(); + + if (mod.equals("minecraft") || Loader.instance().isModLoaded(mod)) it.remove(); + } + + if (!modsMissing.isEmpty()) + { + text = "Forge Mod Loader detected that "+modsMissing.size()+" mods are missing.\n\n" + + "If you continue items previously provided by those mods will be\n" + + "removed while repairing this world save.\n\n" + + "Missing mods:\n"; + + for (String mod : modsMissing) text += mod+"\n"; + + confirmed = StartupQuery.confirm(text); + if (!confirmed) StartupQuery.abort(); + } + + // backup + try + { + ZipperUtil.backupWorld(); + } + catch (IOException e) + { + StartupQuery.notify("The world backup couldn't be created.\n\n"+e); + StartupQuery.abort(); + } + + // apply fix + for (String itemName : itemsToRemove) + { + int id = dataList.remove(itemName); + + FMLLog.warning("Removed Item %s, old id %d.", itemName.substring(1), id); + } + + for (Map.Entry entry : itemsToRelocate.entrySet()) + { + String itemName = entry.getKey(); + int newId = entry.getValue(); + + int oldId = dataList.put(itemName, newId); + + FMLLog.warning("Remapped Item %s to id %d, old id %d.", itemName.substring(1), newId, oldId); + } + + blockedIds.addAll(newBlockedIds); + } + + public static List injectWorldIDMap(Map dataList, boolean injectFrozenData, boolean isLocalWorld) + { + return injectWorldIDMap(dataList, new HashSet(), new HashMap(), new HashMap(), injectFrozenData, isLocalWorld); + } + + public static List injectWorldIDMap(Map dataList, Set blockedIds, Map blockAliases, Map itemAliases, boolean injectFrozenData, boolean isLocalWorld) + { + FMLLog.info("Injecting existing block and item data into this %s instance", FMLCommonHandler.instance().getEffectiveSide().isServer() ? "server" : "client"); + Map remaps = Maps.newHashMap(); + LinkedHashMap missingMappings = new LinkedHashMap(); + getMain().testConsistency(); + getMain().iBlockRegistry.dump(); + getMain().iItemRegistry.dump(); + + GameData newData = new GameData(); + + for (int id : blockedIds) + { + newData.block(id); + } + + for (Map.Entry entry : blockAliases.entrySet()) + { + newData.iBlockRegistry.addAlias(entry.getKey(), entry.getValue()); + } + + for (Map.Entry entry : itemAliases.entrySet()) + { + newData.iItemRegistry.addAlias(entry.getKey(), entry.getValue()); + } + + // process blocks and items in the world, blocks in the first pass, items in the second + // blocks need to be added first for proper ItemBlock handling + for (int pass = 0; pass < 2; pass++) + { + boolean isBlock = (pass == 0); + + for (Entry entry : dataList.entrySet()) + { + String itemName = entry.getKey(); + int newId = entry.getValue(); + + // names starting with 0x1 are blocks, skip if the type isn't handled by this pass + if ((itemName.charAt(0) == '\u0001') != isBlock) continue; + + itemName = itemName.substring(1); + int currId = isBlock ? getMain().iBlockRegistry.getId(itemName) : getMain().iItemRegistry.getId(itemName); + + if (currId == -1) + { + FMLLog.info("Found a missing id from the world %s", itemName); + missingMappings.put(entry.getKey(), newId); + continue; // no block/item -> nothing to add + } + else if (currId != newId) + { + FMLLog.fine("Found %s id mismatch %s : %d (was %d)", isBlock ? "block" : "item", itemName, currId, newId); + remaps.put(itemName, new Integer[] { currId, newId }); + } + + // register + FMLControlledNamespacedRegistry srcRegistry = isBlock ? getMain().iBlockRegistry : getMain().iItemRegistry; + currId = newData.register(srcRegistry.getRaw(itemName), itemName, newId); + + if (currId != newId) + { + throw new IllegalStateException(String.format("Can't map %s %s to id %d, already occupied by %s, blocked %b, ItemBlock %b", + isBlock ? "block" : "item", + itemName, + newId, + isBlock ? newData.iBlockRegistry.getRaw(newId) : newData.iItemRegistry.getRaw(newId), + newData.blockedIds.contains(newId), + isBlock ? false : (getMain().iItemRegistry.getRaw(currId) instanceof ItemBlock))); + } + } + } + + List missedMappings = Loader.instance().fireMissingMappingEvent(missingMappings, isLocalWorld, newData, remaps); + if (!missedMappings.isEmpty()) return missedMappings; + + if (injectFrozenData) // add blocks + items missing from the map + { + Map missingBlocks = frozen.iBlockRegistry.getEntriesNotIn(newData.iBlockRegistry); + Map missingItems = frozen.iItemRegistry.getEntriesNotIn(newData.iItemRegistry); + + if (!missingBlocks.isEmpty() || !missingItems.isEmpty()) + { + FMLLog.info("Injecting new block and item data into this server instance"); + + for (int pass = 0; pass < 2; pass++) + { + boolean isBlock = pass == 0; + Map missing = (pass == 0) ? missingBlocks : missingItems; + + for (Entry entry : missing.entrySet()) + { + String itemName = entry.getKey(); + int currId = entry.getValue(); + int newId; + + if (isBlock) + { + newId = newData.registerBlock(frozen.iBlockRegistry.getRaw(itemName), itemName, null, currId); + } + else + { + newId = newData.registerItem(frozen.iItemRegistry.getRaw(itemName), itemName, null, currId); + } + + FMLLog.info("Injected new block/item %s : %d (was %d)", itemName, newId, currId); + + if (newId != currId) // a new id was assigned + { + remaps.put(itemName, new Integer[] { entry.getValue(), newId }); + } + } + } + } + } + + newData.testConsistency(); + getMain().set(newData); + + getMain().iBlockRegistry.dump(); + getMain().iItemRegistry.dump(); + Loader.instance().fireRemapEvent(remaps); + return ImmutableList.of(); + } + + public static List processIdRematches(Iterable missedMappings, boolean isLocalWorld, GameData gameData, Map remaps) + { + List failed = Lists.newArrayList(); + List ignored = Lists.newArrayList(); + List warned = Lists.newArrayList(); + List defaulted = Lists.newArrayList(); + + for (MissingMapping remap : missedMappings) + { + FMLMissingMappingsEvent.Action action = remap.getAction(); + + if (action == FMLMissingMappingsEvent.Action.REMAP) + { + // block/item re-mapped, finish the registration with the new name/object, but the old id + int currId, newId; + String newName; + + if (remap.type == Type.BLOCK) + { + currId = getMain().iBlockRegistry.getId((Block) remap.getTarget()); + newName = getMain().iBlockRegistry.getNameForObject(remap.getTarget()); + FMLLog.fine("The Block %s is being remapped to %s.", remap.name, newName); + + newId = gameData.registerBlock((Block) remap.getTarget(), newName, null, remap.id); + gameData.iBlockRegistry.addAlias(remap.name, newName); + } + else + { + currId = getMain().iItemRegistry.getId((Item) remap.getTarget()); + newName = getMain().iItemRegistry.getNameForObject(remap.getTarget()); + FMLLog.fine("The Item %s is being remapped to %s.", remap.name, newName); + + newId = gameData.registerItem((Item) remap.getTarget(), newName, null, remap.id); + gameData.iItemRegistry.addAlias(remap.name, newName); + } + + if (newId != remap.id) throw new IllegalStateException(); + + if (currId != newId) + { + FMLLog.info("Found %s id mismatch %s : %d (was %d)", remap.type == Type.BLOCK ? "block" : "item", newName, currId, newId); + remaps.put(newName, new Integer[] { currId, newId }); + } + } + else + { + // block item missing, warn as requested and block the id + if (action == FMLMissingMappingsEvent.Action.DEFAULT) + { + defaulted.add(remap.name); + } + else if (action == FMLMissingMappingsEvent.Action.IGNORE) + { + ignored.add(remap.name); + } + else if (action == FMLMissingMappingsEvent.Action.FAIL) + { + failed.add(remap.name); + } + else if (action == FMLMissingMappingsEvent.Action.WARN) + { + warned.add(remap.name); + } + + gameData.block(remap.id); // prevent the id from being reused later + } + } + + if (!defaulted.isEmpty()) + { + String text = "Forge Mod Loader detected missing blocks/items.\n\n" + + "There are "+defaulted.size()+" missing blocks and items in this save.\n" + + "If you continue the missing blocks/items will get removed.\n" + + "A world backup will be automatically created in your saves directory.\n\n" + + "Missing Blocks/Items:\n"; + + for (String s : defaulted) text += s + "\n"; + + boolean confirmed = StartupQuery.confirm(text); + if (!confirmed) StartupQuery.abort(); + + try + { + ZipperUtil.backupWorld(); + } + catch (IOException e) + { + StartupQuery.notify("The world backup couldn't be created.\n\n"+e); + StartupQuery.abort(); + } + + warned.addAll(defaulted); + } + if (!failed.isEmpty()) + { + FMLLog.severe("This world contains blocks and items that refuse to be remapped. The world will not be loaded"); + return failed; + } + if (!warned.isEmpty()) + { + FMLLog.severe("This world contains block and item mappings that may cause world breakage"); + return failed; + } + else if (!ignored.isEmpty()) + { + FMLLog.fine("There were %d missing mappings that have been ignored", ignored.size()); + } + return failed; + } + + public static void freezeData() + { + FMLLog.fine("Freezing block and item id maps"); + + frozen = new GameData(getMain()); + frozen.testConsistency(); + } + + public static void revertToFrozen() + { + if (frozen == null) + { + FMLLog.warning("Can't revert to frozen GameData state without freezing first."); + } + else + { + FMLLog.fine("Reverting to frozen data state."); + + getMain().set(frozen); + } + } + + protected static boolean isFrozen(FMLControlledNamespacedRegistry registry) + { + return frozen != null && (getMain().iBlockRegistry == registry || getMain().iItemRegistry == registry); + } + + protected static GameData getMain() + { + return mainData; + } + + // internal registry objects + private final FMLControlledNamespacedRegistry iBlockRegistry; + private final FMLControlledNamespacedRegistry iItemRegistry; + // bit set marking ids as occupied + private final BitSet availabilityMap; + // IDs previously allocated in a world, but now unmapped/dangling; prevents the IDs from being reused + private final Set blockedIds; + + private GameData() + { + iBlockRegistry = new FMLControlledNamespacedRegistry("air", MAX_BLOCK_ID, MIN_BLOCK_ID, Block.class,'\u0001'); + iItemRegistry = new FMLControlledNamespacedRegistry(null, MAX_ITEM_ID, MIN_ITEM_ID, Item.class,'\u0002'); + availabilityMap = new BitSet(MAX_ITEM_ID + 1); + blockedIds = new HashSet(); + } + + private GameData(GameData data) + { + this(); + set(data); + } + + private void set(GameData data) + { + iBlockRegistry.set(data.iBlockRegistry); + iItemRegistry.set(data.iItemRegistry); + availabilityMap.clear(); + availabilityMap.or(data.availabilityMap); + blockedIds.clear(); + blockedIds.addAll(data.blockedIds); + } + + int register(Object obj, String name, int idHint) + { + if (obj instanceof Block) + { + return registerBlock((Block) obj, name, null, idHint); + } + else if (obj instanceof Item) + { + return registerItem((Item) obj, name, null, idHint); + } + else + { + throw new IllegalArgumentException("An invalid registry object is to be added, only instances of Block or Item are allowed."); + } + } + + int registerItem(Item item, String name, String modId) + { + return registerItem(item, name, modId, 0); + } + + int registerItem(Item item, String name, String modId, int idHint) + { + if (modId != null) + { + ModContainer mc = Loader.instance().activeModContainer(); + customOwners.put(new UniqueIdentifier(modId, name), mc); + } + if (item instanceof ItemBlock) // ItemBlock, adjust id and clear the slot already occupied by the corresponding block + { + Block block = ((ItemBlock) item).field_150939_a; + idHint = iBlockRegistry.getId(block); + + if (idHint == -1) // ItemBlock before its Block + { + idHint = availabilityMap.nextClearBit(MIN_BLOCK_ID); // find suitable id here, iItemRegistry would search from MIN_ITEM_ID + if (idHint > MAX_BLOCK_ID) throw new RuntimeException(String.format("Invalid id %d - maximum id range exceeded.", idHint)); + } + else // ItemBlock after its Block + { + FMLLog.fine("Found matching Block %s for ItemBlock %s at id %d", block, item, idHint); + freeSlot(idHint, item); // temporarily free the slot occupied by the Block for the item registration + } + } + + int itemId = iItemRegistry.add(idHint, name, item, availabilityMap); + + if (item instanceof ItemBlock) // verify + { + if (itemId != idHint) throw new IllegalStateException("Block -> ItemBlock insertion failed."); + verifyItemBlockName((ItemBlock) item); + } + + // block the Block Registry slot with the same id + useSlot(itemId); + + return itemId; + } + + int registerBlock(Block block, String name, String modId) + { + return registerBlock(block, name, modId, 0); + } + + int registerBlock(Block block, String name, String modId, int idHint) + { + if (modId != null) + { + ModContainer mc = Loader.instance().activeModContainer(); + customOwners.put(new UniqueIdentifier(modId, name), mc); + } + + // handle ItemBlock-before-Block registrations + ItemBlock itemBlock = null; + + for (Item item : (Iterable) iItemRegistry) // find matching ItemBlock + { + if (item instanceof ItemBlock && ((ItemBlock) item).field_150939_a == block) + { + itemBlock = (ItemBlock) item; + break; + } + } + + if (itemBlock != null) // has ItemBlock, adjust id and clear the slot already occupied by the corresponding item + { + idHint = iItemRegistry.getId(itemBlock); + FMLLog.fine("Found matching ItemBlock %s for Block %s at id %d", itemBlock, block, idHint); + freeSlot(idHint, block); // temporarily free the slot occupied by the Item for the block registration + } + + // add + int blockId = iBlockRegistry.add(idHint, name, block, availabilityMap); + + if (itemBlock != null) // verify + { + if (blockId != idHint) throw new IllegalStateException("ItemBlock -> Block insertion failed."); + verifyItemBlockName(itemBlock); + } + + useSlot(blockId); + + return blockId; + } + + /** + * Block the specified id from being reused. + */ + private void block(int id) + { + blockedIds.add(id); + useSlot(id); + } + + private void useSlot(int id) + { + availabilityMap.set(id); + } + + /** + * Free the specified slot. + * + * The slot must not be occupied by something else than the specified object within the same type. + * The same object is permitted for handling duplicate registrations. + * + * @param id id to free + * @param obj object allowed besides different types (block vs item) + */ + private void freeSlot(int id, Object obj) + { + FMLControlledNamespacedRegistry registry = (obj instanceof Block) ? iBlockRegistry : iItemRegistry; + Object thing = registry.getRaw(id); + + if (thing != null && thing != obj) + { + throw new IllegalStateException(String.format("Can't free registry slot %d occupied by %s", id, thing)); + } + + availabilityMap.clear(id); + } + + private void verifyItemBlockName(ItemBlock item) + { + String blockName = iBlockRegistry.getNameForObject(item.field_150939_a); + String itemName = iItemRegistry.getNameForObject(item); + + if (blockName != null && !blockName.equals(itemName)) + { + FMLLog.bigWarning("Block <-> ItemBlock name mismatch, block name %s, item name %s", blockName, itemName); + } + } + + @SuppressWarnings("unchecked") + private void testConsistency() { + // test if there's an entry for every set bit in availabilityMap + for (int i = availabilityMap.nextSetBit(0); i >= 0; i = availabilityMap.nextSetBit(i+1)) + { + if (iBlockRegistry.getRaw(i) == null && iItemRegistry.getRaw(i) == null && !blockedIds.contains(i)) + { + throw new IllegalStateException(String.format("availabilityMap references empty entries for id %d.", i)); + } + } + + // test if there's a bit in availabilityMap set for every entry in the block registry, make sure it's not a blocked id + for (Block block : (Iterable) iBlockRegistry) + { + int id = iBlockRegistry.getId(block); + String name = iBlockRegistry.getNameForObject(block); + + if (id < 0) { + throw new IllegalStateException(String.format("Registry entry for block %s, name %s, doesn't yield an id", block, name)); + } + if (name == null) { + throw new IllegalStateException(String.format("Registry entry for block %s, id %d, doesn't yield a name", block, id)); + } + if (!availabilityMap.get(id)) { + throw new IllegalStateException(String.format("Registry entry for block %s, id %d, name %s, marked as empty.", block, id, name)); + } + if (blockedIds.contains(id)) { + throw new IllegalStateException(String.format("Registry entry for block %s, id %d, name %s, marked as dangling.", block, id, name)); + } + } + + // test if there's a bit in availabilityMap set for every entry in the item registry, make sure it's not a blocked id, + // check if ItemBlocks have blocks with matching ids in the block registry + for (Item item : (Iterable) iItemRegistry) + { + int id = iItemRegistry.getId(item); + String name = iItemRegistry.getNameForObject(item); + + if (id < 0) { + throw new IllegalStateException(String.format("Registry entry for item %s, name %s, doesn't yield an id", item, name)); + } + if (name == null) { + throw new IllegalStateException(String.format("Registry entry for item %s, id %d, doesn't yield a name", item, id)); + } + if (!availabilityMap.get(id)) { + throw new IllegalStateException(String.format("Registry entry for item %s, id %d, name %s, marked as empty.", item, id, name)); + } + if (blockedIds.contains(id)) { + throw new IllegalStateException(String.format("Registry entry for item %s, id %d, name %s, marked as dangling.", item, id, name)); + } + + if (item instanceof ItemBlock) + { + Block block = ((ItemBlock) item).field_150939_a; + + if (iBlockRegistry.getId(block) != id) + { + throw new IllegalStateException(String.format("Registry entry for ItemBlock %s, id %d, is missing or uses the non-matching id %d.", item, id, iBlockRegistry.getId(block))); + } + } + } + + FMLLog.fine("Registry consistency check successful"); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/registry/GameRegistry.java b/src/main/java/cpw/mods/fml/common/registry/GameRegistry.java new file mode 100644 index 0000000..ad59394 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/registry/GameRegistry.java @@ -0,0 +1,415 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.registry; + +import java.lang.reflect.Constructor; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.Set; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.item.crafting.FurnaceRecipes; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraft.world.chunk.IChunkProvider; + +import org.apache.logging.log4j.Level; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.ObjectArrays; +import com.google.common.collect.Sets; +import com.google.common.primitives.Ints; + +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.IFuelHandler; +import cpw.mods.fml.common.IWorldGenerator; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.LoaderException; +import cpw.mods.fml.common.LoaderState; +import cpw.mods.fml.common.ObfuscationReflectionHelper; + +public class GameRegistry +{ + private static Set worldGenerators = Sets.newHashSet(); + private static Map worldGeneratorIndex = Maps.newHashMap(); + private static List fuelHandlers = Lists.newArrayList(); + private static List sortedGeneratorList; + + /** + * Register a world generator - something that inserts new block types into the world + * + * @param generator the generator + * @param weight a weight to assign to this generator. Heavy weights tend to sink to the bottom of + * list of world generators (i.e. they run later) + */ + public static void registerWorldGenerator(IWorldGenerator generator, int modGenerationWeight) + { + worldGenerators.add(generator); + worldGeneratorIndex.put(generator, modGenerationWeight); + if (sortedGeneratorList != null) + { + sortedGeneratorList = null; + } + } + + /** + * Callback hook for world gen - if your mod wishes to add extra mod related generation to the world + * call this + * + * @param chunkX + * @param chunkZ + * @param world + * @param chunkGenerator + * @param chunkProvider + */ + public static void generateWorld(int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) + { + if (sortedGeneratorList == null) + { + computeSortedGeneratorList(); + } + long worldSeed = world.getSeed(); + Random fmlRandom = new Random(worldSeed); + long xSeed = fmlRandom.nextLong() >> 2 + 1L; + long zSeed = fmlRandom.nextLong() >> 2 + 1L; + long chunkSeed = (xSeed * chunkX + zSeed * chunkZ) ^ worldSeed; + + for (IWorldGenerator generator : sortedGeneratorList) + { + fmlRandom.setSeed(chunkSeed); + generator.generate(fmlRandom, chunkX, chunkZ, world, chunkGenerator, chunkProvider); + } + } + + private static void computeSortedGeneratorList() + { + ArrayList list = Lists.newArrayList(worldGenerators); + Collections.sort(list, new Comparator() { + @Override + public int compare(IWorldGenerator o1, IWorldGenerator o2) + { + return Ints.compare(worldGeneratorIndex.get(o1), worldGeneratorIndex.get(o2)); + } + }); + sortedGeneratorList = ImmutableList.copyOf(list); + } + + /** + * Register an item with the item registry with a custom name : this allows for easier server->client resolution + * + * @param item The item to register + * @param name The mod-unique name of the item + */ + public static void registerItem(net.minecraft.item.Item item, String name) + { + registerItem(item, name, null); + } + + /** + * Register the specified Item with a mod specific name : overrides the standard type based name + * @param item The item to register + * @param name The mod-unique name to register it as - null will remove a custom name + * @param modId An optional modId that will "own" this block - generally used by multi-mod systems + * where one mod should "own" all the blocks of all the mods, null defaults to the active mod + */ + public static Item registerItem(Item item, String name, String modId) + { + GameData.getMain().registerItem(item, name, modId); + return item; + } + + + public static void addAlias(String alias, String forName, GameRegistry.Type type) + { + + } + /** + * Register a block with the specified mod specific name + * @param block The block to register + * @param name The mod-unique name to register it as + */ + public static Block registerBlock(Block block, String name) + { + return registerBlock(block, ItemBlock.class, name); + } + /** + * Register a block with the world, with the specified item class and block name + * @param block The block to register + * @param itemclass The item type to register with it : null registers a block without associated item. + * @param name The mod-unique name to register it with + */ + public static Block registerBlock(Block block, Class itemclass, String name) + { + return registerBlock(block, itemclass, name, null); + } + /** + * Register a block with the world, with the specified item class, block name and owning modId + * @param block The block to register + * @param itemclass The item type to register with it : null registers a block without associated item. + * @param name The mod-unique name to register it with + * @param modId The modId that will own the block name. null defaults to the active modId + */ + public static Block registerBlock(Block block, Class itemclass, String name, String modId, Object... itemCtorArgs) + { + if (Loader.instance().isInState(LoaderState.CONSTRUCTING)) + { + FMLLog.warning("The mod %s is attempting to register a block whilst it it being constructed. This is bad modding practice - please use a proper mod lifecycle event.", Loader.instance().activeModContainer()); + } + try + { + assert block != null : "registerBlock: block cannot be null"; + ItemBlock i = null; + if (itemclass != null) + { + Class[] ctorArgClasses = new Class[itemCtorArgs.length + 1]; + ctorArgClasses[0] = Block.class; + for (int idx = 1; idx < ctorArgClasses.length; idx++) + { + ctorArgClasses[idx] = itemCtorArgs[idx-1].getClass(); + } + Constructor itemCtor = itemclass.getConstructor(ctorArgClasses); + i = itemCtor.newInstance(ObjectArrays.concat(block, itemCtorArgs)); + } + // block registration has to happen first + GameData.getMain().registerBlock(block, name, modId); + if (i != null) + { + GameData.getMain().registerItem(i, name, modId); + } + return block; + } + catch (Exception e) + { + FMLLog.log(Level.ERROR, e, "Caught an exception during block registration"); + throw new LoaderException(e); + } + } + + public static void addRecipe(ItemStack output, Object... params) + { + addShapedRecipe(output, params); + } + + public static IRecipe addShapedRecipe(ItemStack output, Object... params) + { + return CraftingManager.getInstance().addRecipe(output, params); + } + + public static void addShapelessRecipe(ItemStack output, Object... params) + { + CraftingManager.getInstance().addShapelessRecipe(output, params); + } + + @SuppressWarnings("unchecked") + public static void addRecipe(IRecipe recipe) + { + CraftingManager.getInstance().getRecipeList().add(recipe); + } + + public static void addSmelting(Block input, ItemStack output, float xp) + { + FurnaceRecipes.smelting().func_151393_a(input, output, xp); + } + + public static void addSmelting(Item input, ItemStack output, float xp) + { + FurnaceRecipes.smelting().func_151396_a(input, output, xp); + } + + public static void addSmelting(ItemStack input, ItemStack output, float xp) + { + FurnaceRecipes.smelting().func_151394_a(input, output, xp); + } + + public static void registerTileEntity(Class tileEntityClass, String id) + { + TileEntity.addMapping(tileEntityClass, id); + } + + /** + * Register a tile entity, with alternative TileEntity identifiers. Use with caution! + * This method allows for you to "rename" the 'id' of the tile entity. + * + * @param tileEntityClass The tileEntity class to register + * @param id The primary ID, this will be the ID that the tileentity saves as + * @param alternatives A list of alternative IDs that will also map to this class. These will never save, but they will load + */ + public static void registerTileEntityWithAlternatives(Class tileEntityClass, String id, String... alternatives) + { + TileEntity.addMapping(tileEntityClass, id); + Map> teMappings = ObfuscationReflectionHelper.getPrivateValue(TileEntity.class, null, "field_" + "145855_i", "nameToClassMap"); + for (String s: alternatives) + { + if (!teMappings.containsKey(s)) + { + teMappings.put(s, tileEntityClass); + } + } + } + + public static void registerFuelHandler(IFuelHandler handler) + { + fuelHandlers.add(handler); + } + public static int getFuelValue(ItemStack itemStack) + { + int fuelValue = 0; + for (IFuelHandler handler : fuelHandlers) + { + fuelValue = Math.max(fuelValue, handler.getBurnTime(itemStack)); + } + return fuelValue; + } + + /** + * Look up a mod block in the global "named item list" + * @param modId The modid owning the block + * @param name The name of the block itself + * @return The block or null if not found + */ + public static Block findBlock(String modId, String name) + { + return GameData.findBlock(modId, name); + } + + /** + * Look up a mod item in the global "named item list" + * @param modId The modid owning the item + * @param name The name of the item itself + * @return The item or null if not found + */ + public static Item findItem(String modId, String name) + { + return GameData.findItem(modId, name); + } + + /** + * Manually register a custom item stack with FML for later tracking. It is automatically scoped with the active modid + * + * @param name The name to register it under + * @param itemStack The itemstack to register + */ + public static void registerCustomItemStack(String name, ItemStack itemStack) + { + GameData.registerCustomItemStack(name, itemStack); + } + /** + * Lookup an itemstack based on mod and name. It will create "default" itemstacks from blocks and items if no + * explicit itemstack is found. + * + * If it is built from a block, the metadata is by default the "wildcard" value. + * + * Custom itemstacks can be dumped from minecraft by setting the system property fml.dumpRegistry to true + * (-Dfml.dumpRegistry=true on the command line will work) + * + * @param modId The modid of the stack owner + * @param name The name of the stack + * @param stackSize The size of the stack returned + * @return The custom itemstack or null if no such itemstack was found + */ + public static ItemStack findItemStack(String modId, String name, int stackSize) + { + ItemStack foundStack = GameData.findItemStack(modId, name); + if (foundStack != null) + { + ItemStack is = foundStack.copy(); + is.stackSize = Math.min(stackSize, is.getMaxStackSize()); + return is; + } + return null; + } + + public static final class UniqueIdentifier + { + public final String modId; + public final String name; + UniqueIdentifier(String modId, String name) + { + this.modId = modId; + this.name = name; + } + + public UniqueIdentifier(String string) + { + String[] parts = string.split(":"); + this.modId = parts[0]; + this.name = parts[1]; + } + + @Override + public boolean equals(Object obj) + { + if (obj == null) return false; + if (obj.getClass() != this.getClass()) return false; + final UniqueIdentifier other = (UniqueIdentifier) obj; + return Objects.equal(modId, other.modId) && Objects.equal(name, other.name); + } + + @Override + public int hashCode() + { + return Objects.hashCode(modId, name); + } + + @Override + public String toString() + { + return String.format("%s:%s", modId, name); + } + } + + public static enum Type { BLOCK, ITEM } + /** + * Look up the mod identifier data for a block. + * Returns null if there is no mod specified mod identifier data, or it is part of a + * custom itemstack definition {@link #registerCustomItemStack} + * + * Note: uniqueness and persistence is only guaranteed by mods using the game registry + * correctly. + * + * @param block to lookup + * @return a {@link UniqueIdentifier} for the block or null + */ + public static UniqueIdentifier findUniqueIdentifierFor(Block block) + { + return GameData.getUniqueName(block); + } + /** + * Look up the mod identifier data for an item. + * Returns null if there is no mod specified mod identifier data, or it is part of a + * custom itemstack definition {@link #registerCustomItemStack} + * + * Note: uniqueness and persistence is only guaranteed by mods using the game registry + * correctly. + * + * @param item to lookup + * @return a {@link UniqueIdentifier} for the item or null + */ + public static UniqueIdentifier findUniqueIdentifierFor(Item item) + { + return GameData.getUniqueName(item); + } + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/registry/IEntityAdditionalSpawnData.java b/src/main/java/cpw/mods/fml/common/registry/IEntityAdditionalSpawnData.java new file mode 100644 index 0000000..a24dfbd --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/registry/IEntityAdditionalSpawnData.java @@ -0,0 +1,38 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.registry; + +import io.netty.buffer.ByteBuf; + +/** + * A interface for Entities that need extra information to be communicated + * between the server and client when they are spawned. + */ +public interface IEntityAdditionalSpawnData +{ + /** + * Called by the server when constructing the spawn packet. + * Data should be added to the provided stream. + * + * @param buffer The packet data stream + */ + public void writeSpawnData(ByteBuf buffer); + + /** + * Called by the client when it receives a Entity spawn packet. + * Data should be read out of the stream in the same way as it was written. + * + * @param data The packet data stream + */ + public void readSpawnData(ByteBuf additionalData); +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/registry/IThrowableEntity.java b/src/main/java/cpw/mods/fml/common/registry/IThrowableEntity.java new file mode 100644 index 0000000..33333c2 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/registry/IThrowableEntity.java @@ -0,0 +1,34 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.registry; + +import net.minecraft.entity.Entity; + +/** + * This interface should be implemented by an Entity that can be 'thrown', like snowballs. + * This was created to mimic ModLoaderMP's 'owner' functionality. + */ +public interface IThrowableEntity +{ + /** + * Gets the entity that threw/created this entity. + * @return The owner instance, Null if none. + */ + public Entity getThrower(); + + /** + * Sets the entity that threw/created this entity. + * @param entity The new thrower/creator. + */ + public void setThrower(Entity entity); +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/registry/LanguageRegistry.java b/src/main/java/cpw/mods/fml/common/registry/LanguageRegistry.java new file mode 100644 index 0000000..1d2f4d5 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/registry/LanguageRegistry.java @@ -0,0 +1,306 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.registry; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; +import org.apache.logging.log4j.Level; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.StringTranslate; + +import com.google.common.base.Charsets; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.ModContainer; +import cpw.mods.fml.relauncher.Side; + +public class LanguageRegistry +{ + private static final LanguageRegistry INSTANCE = new LanguageRegistry(); + + private Map modLanguageData=new HashMap(); + + private static final Pattern assetENUSLang = Pattern.compile("assets/(.*)/lang/(.*).lang"); + + public static LanguageRegistry instance() + { + return INSTANCE; + } + + public String getStringLocalization(String key) + { + return getStringLocalization(key, FMLCommonHandler.instance().getCurrentLanguage()); + } + + public String getStringLocalization(String key, String lang) + { + String localizedString = ""; + Properties langPack = modLanguageData.get(lang); + + if (langPack != null) { + if (langPack.getProperty(key) != null) { + localizedString = langPack.getProperty(key); + } + } + + return localizedString; + } + + /** + * Deprecated for removal in 1.8. Use the assets lang system + */ + @Deprecated + public void addStringLocalization(String key, String value) + { + addStringLocalization(key, "en_US", value); + } + + /** + * Deprecated for removal in 1.8. Use the assets lang system + */ + @Deprecated + public void addStringLocalization(String key, String lang, String value) + { + Properties langPack=modLanguageData.get(lang); + if (langPack==null) { + langPack=new Properties(); + modLanguageData.put(lang, langPack); + } + langPack.put(key,value); + } + + /** + * Deprecated for removal in 1.8. Use the assets lang system + */ + @Deprecated + public void addStringLocalization(Properties langPackAdditions) { + addStringLocalization(langPackAdditions, "en_US"); + } + + /** + * Deprecated for removal in 1.8. Use the assets lang system + */ + @Deprecated + public void addStringLocalization(Properties langPackAdditions, String lang) { + Properties langPack = modLanguageData.get(lang); + if (langPack == null) { + langPack = new Properties(); + modLanguageData.put(lang, langPack); + } + if (langPackAdditions != null) { + langPack.putAll(langPackAdditions); + } + } + + /** + * Deprecated for removal in 1.8. Use the assets lang system + */ + @Deprecated + public void addNameForObject(Object objectToName, String lang, String name) + { + String objectName; + if (objectToName instanceof Item) { + objectName=((Item)objectToName).getUnlocalizedName(); + } else if (objectToName instanceof Block) { + objectName=((Block)objectToName).getUnlocalizedName(); + } else if (objectToName instanceof ItemStack) { + objectName=((ItemStack)objectToName).getItem().getUnlocalizedName((ItemStack)objectToName); + } else { + throw new IllegalArgumentException(String.format("Illegal object for naming %s",objectToName)); + } + objectName+=".name"; + addStringLocalization(objectName, lang, name); + } + + /** + * Deprecated for removal in 1.8. Use the assets lang system + */ + @Deprecated + public static void addName(Object objectToName, String name) + { + instance().addNameForObject(objectToName, "en_US", name); + } + + /** + * Deprecated for removal in 1.8. Use the assets lang system + */ + @SuppressWarnings("unchecked") + @Deprecated + public void loadLanguageTable(@SuppressWarnings("rawtypes") Map field_135032_a, String lang) + { + Properties usPack=modLanguageData.get("en_US"); + if (usPack!=null) { + field_135032_a.putAll(usPack); + } + Properties langPack=modLanguageData.get(lang); + if (langPack==null) { + return; + } + field_135032_a.putAll(langPack); + } + + /** + * Deprecated for removal in 1.8. Use the assets lang system + */ + @Deprecated + public void loadLocalization(String localizationFile, String lang, boolean isXML) + { + URL urlResource = this.getClass().getResource(localizationFile); + if (urlResource != null) + { + loadLocalization(urlResource, lang, isXML); + } + else + { + ModContainer activeModContainer = Loader.instance().activeModContainer(); + if (activeModContainer!=null) + { + FMLLog.log(activeModContainer.getModId(), Level.ERROR, "The language resource %s cannot be located on the classpath. This is a programming error.", localizationFile); + } + else + { + FMLLog.log(Level.ERROR, "The language resource %s cannot be located on the classpath. This is a programming error.", localizationFile); + } + } + } + + /** + * Deprecated for removal in 1.8. Use the assets lang system + */ + @Deprecated + public void loadLocalization(URL localizationFile, String lang, boolean isXML) + { + InputStream langStream = null; + Properties langPack = new Properties(); + + try { + langStream = localizationFile.openStream(); + + if (isXML) { + langPack.loadFromXML(langStream); + } + else { + langPack.load(new InputStreamReader(langStream,Charsets.UTF_8)); + } + + addStringLocalization(langPack, lang); + } + catch (IOException e) { + FMLLog.log(Level.ERROR, e, "Unable to load localization from file %s", localizationFile); + } + finally { + try { + if (langStream != null) { + langStream.close(); + } + } + catch (IOException ex) { + // HUSH + } + } + } + + public void injectLanguage(String language, HashMap parsedLangFile) + { + + Properties p = modLanguageData.get(language); + if (p == null) + { + p = new Properties(); + modLanguageData.put(language, p); + } + p.putAll(parsedLangFile); + } + + public void loadLanguagesFor(ModContainer container, Side side) + { + File source = container.getSource(); + try + { + if (source.isDirectory()) + { + searchDirForLanguages(source, "", side); + } + else + { + searchZipForLanguages(source, side); + } + } + catch (IOException ioe) + { + + } + } + + private void searchZipForLanguages(File source, Side side) throws IOException + { + ZipFile zf = new ZipFile(source); + for (ZipEntry ze : Collections.list(zf.entries())) + { + Matcher matcher = assetENUSLang.matcher(ze.getName()); + if (matcher.matches()) + { + String lang = matcher.group(2); + FMLLog.fine("Injecting found translation data for lang %s in zip file %s at %s into language system", lang, source.getName(), ze.getName()); + LanguageRegistry.instance().injectLanguage(lang, StringTranslate.parseLangFile(zf.getInputStream(ze))); + // Ensure en_US is available to StringTranslate on the server + if ("en_US".equals(lang) && side == Side.SERVER) + { + StringTranslate.inject(zf.getInputStream(ze)); + } + } + } + zf.close(); + } + + private void searchDirForLanguages(File source, String path, Side side) throws IOException + { + for (File file : source.listFiles()) + { + String currPath = path+file.getName(); + if (file.isDirectory()) + { + searchDirForLanguages(file, currPath+'/', side); + } + Matcher matcher = assetENUSLang.matcher(currPath); + if (matcher.matches()) + { + String lang = matcher.group(2); + FMLLog.fine("Injecting found translation assets for lang %s at %s into language system", lang, currPath); + LanguageRegistry.instance().injectLanguage(lang, StringTranslate.parseLangFile(new FileInputStream(file))); + // Ensure en_US is available to StringTranslate on the server + if ("en_US".equals(lang) && side == Side.SERVER) + { + StringTranslate.inject(new FileInputStream(file)); + } + } + } + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/registry/VillagerRegistry.java b/src/main/java/cpw/mods/fml/common/registry/VillagerRegistry.java new file mode 100644 index 0000000..aa7cb01 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/registry/VillagerRegistry.java @@ -0,0 +1,250 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.registry; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Random; + +import net.minecraft.entity.passive.EntityVillager; +import net.minecraft.item.Item; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Tuple; +import net.minecraft.village.MerchantRecipeList; +import net.minecraft.world.gen.structure.StructureVillagePieces; + +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Multimap; + +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/** + * Registry for villager trading control + * + * @author cpw + * + */ +public class VillagerRegistry +{ + private static final VillagerRegistry INSTANCE = new VillagerRegistry(); + + private Multimap tradeHandlers = ArrayListMultimap.create(); + private Map, IVillageCreationHandler> villageCreationHandlers = Maps.newHashMap(); + private List newVillagerIds = Lists.newArrayList(); + @SideOnly(Side.CLIENT) + private Map newVillagers; + + /** + * Allow access to the {@link net.minecraft.world.gen.structure.StructureVillagePieces} array controlling new village + * creation so you can insert your own new village pieces + * + * @author cpw + * + */ + public interface IVillageCreationHandler + { + /** + * Called when {@link net.minecraft.world.gen.structure.MapGenVillage} is creating a new village + * + * @param random + * @param i + */ + StructureVillagePieces.PieceWeight getVillagePieceWeight(Random random, int i); + + /** + * The class of the root structure component to add to the village + */ + Class getComponentClass(); + + + /** + * Build an instance of the village component {@link net.minecraft.world.gen.structure.StructureVillagePieces} + * @param villagePiece + * @param startPiece + * @param pieces + * @param random + * @param p1 + * @param p2 + * @param p3 + * @param p4 + * @param p5 + */ + Object buildComponent(StructureVillagePieces.PieceWeight villagePiece, StructureVillagePieces.Start startPiece, @SuppressWarnings("rawtypes") List pieces, Random random, int p1, + int p2, int p3, int p4, int p5); + } + + /** + * Allow access to the {@link MerchantRecipeList} for a villager type for manipulation + * + * @author cpw + * + */ + public interface IVillageTradeHandler + { + /** + * Called to allow changing the content of the {@link MerchantRecipeList} for the villager + * supplied during creation + * + * @param villager + * @param recipeList + */ + void manipulateTradesForVillager(EntityVillager villager, MerchantRecipeList recipeList, Random random); + } + + public static VillagerRegistry instance() + { + return INSTANCE; + } + + /** + * Register your villager id + * @param id + */ + public void registerVillagerId(int id) + { + if (newVillagerIds.contains(id)) + { + FMLLog.severe("Attempt to register duplicate villager id %d", id); + throw new RuntimeException(); + } + newVillagerIds.add(id); + } + /** + * Register a new skin for a villager type + * + * @param villagerId + * @param villagerSkin + */ + @SideOnly(Side.CLIENT) + public void registerVillagerSkin(int villagerId, ResourceLocation villagerSkin) + { + if (newVillagers == null) + { + newVillagers = Maps.newHashMap(); + } + newVillagers.put(villagerId, villagerSkin); + } + + /** + * Register a new village creation handler + * + * @param handler + */ + public void registerVillageCreationHandler(IVillageCreationHandler handler) + { + villageCreationHandlers.put(handler.getComponentClass(), handler); + } + + /** + * Register a new villager trading handler for the specified villager type + * + * @param villagerId + * @param handler + */ + public void registerVillageTradeHandler(int villagerId, IVillageTradeHandler handler) + { + tradeHandlers.put(villagerId, handler); + } + + /** + * Callback to setup new villager types + * + * @param villagerType + * @param defaultSkin + */ + @SideOnly(Side.CLIENT) + public static ResourceLocation getVillagerSkin(int villagerType, ResourceLocation defaultSkin) + { + if (instance().newVillagers != null && instance().newVillagers.containsKey(villagerType)) + { + return instance().newVillagers.get(villagerType); + } + return defaultSkin; + } + + /** + * Returns a list of all added villager types + * + * @return newVillagerIds + */ + public static Collection getRegisteredVillagers() + { + return Collections.unmodifiableCollection(instance().newVillagerIds); + } + /** + * Callback to handle trade setup for villagers + * + * @param recipeList + * @param villager + * @param villagerType + * @param random + */ + public static void manageVillagerTrades(MerchantRecipeList recipeList, EntityVillager villager, int villagerType, Random random) + { + for (IVillageTradeHandler handler : instance().tradeHandlers.get(villagerType)) + { + handler.manipulateTradesForVillager(villager, recipeList, random); + } + } + + public static void addExtraVillageComponents(@SuppressWarnings("rawtypes") ArrayList components, Random random, int i) + { + @SuppressWarnings("unchecked") + List parts = components; + for (IVillageCreationHandler handler : instance().villageCreationHandlers.values()) + { + parts.add(handler.getVillagePieceWeight(random, i)); + } + } + + public static Object getVillageComponent(StructureVillagePieces.PieceWeight villagePiece, StructureVillagePieces.Start startPiece, @SuppressWarnings("rawtypes") List pieces, Random random, + int p1, int p2, int p3, int p4, int p5) + { + return instance().villageCreationHandlers.get(villagePiece.villagePieceClass).buildComponent(villagePiece, startPiece, pieces, random, p1, p2, p3, p4, p5); + } + + + @SuppressWarnings("unchecked") + public static void addEmeraldBuyRecipe(EntityVillager villager, MerchantRecipeList list, Random random, Item item, float chance, int min, int max) + { + if (min > 0 && max > 0) + { + EntityVillager.villagersSellingList.put(item, new Tuple(min, max)); + } + EntityVillager.func_146091_a(list, item, random, chance); + } + + @SuppressWarnings("unchecked") + public static void addEmeraldSellRecipe(EntityVillager villager, MerchantRecipeList list, Random random, Item item, float chance, int min, int max) + { + if (min > 0 && max > 0) + { + EntityVillager.blacksmithSellingList.put(item, new Tuple(min, max)); + } + EntityVillager.func_146089_b(list, item, random, chance); + } + + public static void applyRandomTrade(EntityVillager villager, Random rand) + { + int extra = instance().newVillagerIds.size(); + int trade = rand.nextInt(5 + extra); + villager.setProfession(trade < 5 ? trade : instance().newVillagerIds.get(trade - 5)); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/toposort/ModSorter.java b/src/main/java/cpw/mods/fml/common/toposort/ModSorter.java new file mode 100644 index 0000000..5e1d84f --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/toposort/ModSorter.java @@ -0,0 +1,137 @@ +/* + * The FML Forge Mod Loader suite. Copyright (C) 2012 cpw + * + * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation; either version 2.1 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +package cpw.mods.fml.common.toposort; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.google.common.collect.Maps; + +import cpw.mods.fml.common.DummyModContainer; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.ModAPIManager; +import cpw.mods.fml.common.ModContainer; +import cpw.mods.fml.common.toposort.TopologicalSort.DirectedGraph; +import cpw.mods.fml.common.versioning.ArtifactVersion; + +/** + * @author cpw + * + */ +public class ModSorter +{ + private DirectedGraph modGraph; + + private ModContainer beforeAll = new DummyModContainer("BeforeAll"); + private ModContainer afterAll = new DummyModContainer("AfterAll"); + private ModContainer before = new DummyModContainer("Before"); + private ModContainer after = new DummyModContainer("After"); + + public ModSorter(List modList, Map nameLookup) + { + HashMap sortingNameLookup = Maps.newHashMap(nameLookup); + ModAPIManager.INSTANCE.injectAPIModContainers(modList, sortingNameLookup); + buildGraph(modList, sortingNameLookup); + } + + private void buildGraph(List modList, Map nameLookup) + { + modGraph = new DirectedGraph(); + modGraph.addNode(beforeAll); + modGraph.addNode(before); + modGraph.addNode(afterAll); + modGraph.addNode(after); + modGraph.addEdge(before, after); + modGraph.addEdge(beforeAll, before); + modGraph.addEdge(after, afterAll); + + for (ModContainer mod : modList) + { + modGraph.addNode(mod); + } + + for (ModContainer mod : modList) + { + if (mod.isImmutable()) + { + // Immutable mods are always before everything + modGraph.addEdge(beforeAll, mod); + modGraph.addEdge(mod, before); + continue; + } + boolean preDepAdded = false; + boolean postDepAdded = false; + + for (ArtifactVersion dep : mod.getDependencies()) + { + preDepAdded = true; + + String modid = dep.getLabel(); + if (modid.equals("*")) + { + // We are "after" everything + modGraph.addEdge(mod, afterAll); + modGraph.addEdge(after, mod); + postDepAdded = true; + } + else + { + modGraph.addEdge(before, mod); + if (nameLookup.containsKey(modid) || Loader.isModLoaded(modid)) { + modGraph.addEdge(nameLookup.get(modid), mod); + } + } + } + + for (ArtifactVersion dep : mod.getDependants()) + { + postDepAdded = true; + + String modid = dep.getLabel(); + if (modid.equals("*")) + { + // We are "before" everything + modGraph.addEdge(beforeAll, mod); + modGraph.addEdge(mod, before); + preDepAdded = true; + } + else + { + modGraph.addEdge(mod, after); + if (Loader.isModLoaded(modid)) { + modGraph.addEdge(mod, nameLookup.get(modid)); + } + } + } + + if (!preDepAdded) + { + modGraph.addEdge(before, mod); + } + + if (!postDepAdded) + { + modGraph.addEdge(mod, after); + } + } + } + + public List sort() + { + List sortedList = TopologicalSort.topologicalSort(modGraph); + sortedList.removeAll(Arrays.asList(new ModContainer[] {beforeAll, before, after, afterAll})); + return sortedList; + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/toposort/ModSortingException.java b/src/main/java/cpw/mods/fml/common/toposort/ModSortingException.java new file mode 100644 index 0000000..3a7116d --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/toposort/ModSortingException.java @@ -0,0 +1,56 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.toposort; + +import java.util.Set; + +public class ModSortingException extends RuntimeException +{ + private static final long serialVersionUID = 1L; + + public class SortingExceptionData + { + public SortingExceptionData(T node, Set visitedNodes) + { + this.firstBadNode = node; + this.visitedNodes = visitedNodes; + } + + private T firstBadNode; + private Set visitedNodes; + + public T getFirstBadNode() + { + return firstBadNode; + } + public Set getVisitedNodes() + { + return visitedNodes; + } + } + + private SortingExceptionData sortingExceptionData; + + public ModSortingException(String string, T node, Set visitedNodes) + { + super(string); + this.sortingExceptionData = new SortingExceptionData(node, visitedNodes); + } + + @SuppressWarnings("unchecked") + public SortingExceptionData getExceptionData() + { + return (SortingExceptionData) sortingExceptionData; + } + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/toposort/TopologicalSort.java b/src/main/java/cpw/mods/fml/common/toposort/TopologicalSort.java new file mode 100644 index 0000000..a2bee2c --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/toposort/TopologicalSort.java @@ -0,0 +1,207 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.toposort; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; + +import com.google.common.collect.Sets; +import com.google.common.collect.Sets.SetView; + +import cpw.mods.fml.common.FMLLog; + +/** + * Topological sort for mod loading + * + * Based on a variety of sources, including http://keithschwarz.com/interesting/code/?dir=topological-sort + * @author cpw + * + */ +public class TopologicalSort +{ + public static class DirectedGraph implements Iterable + { + private final Map> graph = new HashMap>(); + private List orderedNodes = new ArrayList(); + + public boolean addNode(T node) + { + // Ignore nodes already added + if (graph.containsKey(node)) + { + return false; + } + + orderedNodes.add(node); + graph.put(node, new TreeSet(new Comparator() + { + @Override + public int compare(T o1, T o2) { + return orderedNodes.indexOf(o1)-orderedNodes.indexOf(o2); + } + })); + return true; + } + + public void addEdge(T from, T to) + { + if (!(graph.containsKey(from) && graph.containsKey(to))) + { + throw new NoSuchElementException("Missing nodes from graph"); + } + + graph.get(from).add(to); + } + + public void removeEdge(T from, T to) + { + if (!(graph.containsKey(from) && graph.containsKey(to))) + { + throw new NoSuchElementException("Missing nodes from graph"); + } + + graph.get(from).remove(to); + } + + public boolean edgeExists(T from, T to) + { + if (!(graph.containsKey(from) && graph.containsKey(to))) + { + throw new NoSuchElementException("Missing nodes from graph"); + } + + return graph.get(from).contains(to); + } + + public Set edgesFrom(T from) + { + if (!graph.containsKey(from)) + { + throw new NoSuchElementException("Missing node from graph"); + } + + return Collections.unmodifiableSortedSet(graph.get(from)); + } + @Override + public Iterator iterator() + { + return orderedNodes.iterator(); + } + + public int size() + { + return graph.size(); + } + + public boolean isEmpty() + { + return graph.isEmpty(); + } + + @Override + public String toString() + { + return graph.toString(); + } + } + + /** + * Sort the input graph into a topologically sorted list + * + * Uses the reverse depth first search as outlined in ... + * @param graph + * @return The sorted mods list. + */ + public static List topologicalSort(DirectedGraph graph) + { + DirectedGraph rGraph = reverse(graph); + List sortedResult = new ArrayList(); + Set visitedNodes = new HashSet(); + // A list of "fully explored" nodes. Leftovers in here indicate cycles in the graph + Set expandedNodes = new HashSet(); + + for (T node : rGraph) + { + explore(node, rGraph, sortedResult, visitedNodes, expandedNodes); + } + + return sortedResult; + } + + public static DirectedGraph reverse(DirectedGraph graph) + { + DirectedGraph result = new DirectedGraph(); + + for (T node : graph) + { + result.addNode(node); + } + + for (T from : graph) + { + for (T to : graph.edgesFrom(from)) + { + result.addEdge(to, from); + } + } + + return result; + } + + public static void explore(T node, DirectedGraph graph, List sortedResult, Set visitedNodes, Set expandedNodes) + { + // Have we been here before? + if (visitedNodes.contains(node)) + { + // And have completed this node before + if (expandedNodes.contains(node)) + { + // Then we're fine + return; + } + + FMLLog.severe("Mod Sorting failed."); + FMLLog.severe("Visting node %s", node); + FMLLog.severe("Current sorted list : %s", sortedResult); + FMLLog.severe("Visited set for this node : %s", visitedNodes); + FMLLog.severe("Explored node set : %s", expandedNodes); + SetView cycleList = Sets.difference(visitedNodes, expandedNodes); + FMLLog.severe("Likely cycle is in : %s", cycleList); + throw new ModSortingException("There was a cycle detected in the input graph, sorting is not possible", node, cycleList); + } + + // Visit this node + visitedNodes.add(node); + + // Recursively explore inbound edges + for (T inbound : graph.edgesFrom(node)) + { + explore(inbound, graph, sortedResult, visitedNodes, expandedNodes); + } + + // Add ourselves now + sortedResult.add(node); + // And mark ourselves as explored + expandedNodes.add(node); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/versioning/ArtifactVersion.java b/src/main/java/cpw/mods/fml/common/versioning/ArtifactVersion.java new file mode 100644 index 0000000..13ba264 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/versioning/ArtifactVersion.java @@ -0,0 +1,50 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.versioning; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * Describes an artifact version in terms of its components, converts it to/from a string and + * compares two versions. + * + * @author Brett Porter + */ +public interface ArtifactVersion + extends Comparable +{ + String getLabel(); + + String getVersionString(); + + boolean containsVersion(ArtifactVersion source); + + String getRangeString(); +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/versioning/ComparableVersion.java b/src/main/java/cpw/mods/fml/common/versioning/ComparableVersion.java new file mode 100644 index 0000000..bfdb337 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/versioning/ComparableVersion.java @@ -0,0 +1,500 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.versioning; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.Locale; +import java.util.Properties; +import java.util.Stack; + +/** + * Generic implementation of version comparison. + * + *

Features: + *

    + *
  • mixing of '-' (dash) and '.' (dot) separators,
  • + *
  • transition between characters and digits also constitutes a separator: + * 1.0alpha1 => [1, 0, alpha, 1]
  • + *
  • unlimited number of version components,
  • + *
  • version components in the text can be digits or strings,
  • + *
  • strings are checked for well-known qualifiers and the qualifier ordering is used for version ordering. + * Well-known qualifiers (case insensitive) are:
      + *
    • snapshot
    • + *
    • alpha or a
    • + *
    • beta or b
    • + *
    • milestone or m
    • + *
    • rc or cr
    • + *
    • (the empty string) or ga or final
    • + *
    • sp
    • + *
    + * Unknown qualifiers are considered after known qualifiers, with lexical order (always case insensitive), + *
  • + *
  • a dash usually precedes a qualifier, and is always less important than something preceded with a dot.
  • + *

+ * + * @see "Versioning" on Maven Wiki + * @author Kenney Westerhof + * @author Hervé Boutemy + */ +public class ComparableVersion + implements Comparable +{ + private String value; + + private String canonical; + + private ListItem items; + + private interface Item + { + final int INTEGER_ITEM = 0; + final int STRING_ITEM = 1; + final int LIST_ITEM = 2; + + int compareTo( Item item ); + + int getType(); + + boolean isNull(); + } + + /** + * Represents a numeric item in the version item list. + */ + private static class IntegerItem + implements Item + { + private static final BigInteger BigInteger_ZERO = new BigInteger( "0" ); + + private final BigInteger value; + + public static final IntegerItem ZERO = new IntegerItem(); + + private IntegerItem() + { + this.value = BigInteger_ZERO; + } + + public IntegerItem( String str ) + { + this.value = new BigInteger( str ); + } + + @Override + public int getType() + { + return INTEGER_ITEM; + } + + @Override + public boolean isNull() + { + return BigInteger_ZERO.equals( value ); + } + + @Override + public int compareTo( Item item ) + { + if ( item == null ) + { + return BigInteger_ZERO.equals( value ) ? 0 : 1; // 1.0 == 1, 1.1 > 1 + } + + switch ( item.getType() ) + { + case INTEGER_ITEM: + return value.compareTo( ( (IntegerItem) item ).value ); + + case STRING_ITEM: + return 1; // 1.1 > 1-sp + + case LIST_ITEM: + return 1; // 1.1 > 1-1 + + default: + throw new RuntimeException( "invalid item: " + item.getClass() ); + } + } + + @Override + public String toString() + { + return value.toString(); + } + } + + /** + * Represents a string in the version item list, usually a qualifier. + */ + private static class StringItem + implements Item + { + private static final String[] QUALIFIERS = { "alpha", "beta", "milestone", "rc", "snapshot", "", "sp" }; + + private static final List _QUALIFIERS = Arrays.asList( QUALIFIERS ); + + private static final Properties ALIASES = new Properties(); + static + { + ALIASES.put( "ga", "" ); + ALIASES.put( "final", "" ); + ALIASES.put( "cr", "rc" ); + } + + /** + * A comparable value for the empty-string qualifier. This one is used to determine if a given qualifier makes + * the version older than one without a qualifier, or more recent. + */ + private static final String RELEASE_VERSION_INDEX = String.valueOf( _QUALIFIERS.indexOf( "" ) ); + + private String value; + + public StringItem( String value, boolean followedByDigit ) + { + if ( followedByDigit && value.length() == 1 ) + { + // a1 = alpha-1, b1 = beta-1, m1 = milestone-1 + switch ( value.charAt( 0 ) ) + { + case 'a': + value = "alpha"; + break; + case 'b': + value = "beta"; + break; + case 'm': + value = "milestone"; + break; + } + } + this.value = ALIASES.getProperty( value , value ); + } + + @Override + public int getType() + { + return STRING_ITEM; + } + + @Override + public boolean isNull() + { + return ( comparableQualifier( value ).compareTo( RELEASE_VERSION_INDEX ) == 0 ); + } + + /** + * Returns a comparable value for a qualifier. + * + * This method takes into account the ordering of known qualifiers then unknown qualifiers with lexical ordering. + * + * just returning an Integer with the index here is faster, but requires a lot of if/then/else to check for -1 + * or QUALIFIERS.size and then resort to lexical ordering. Most comparisons are decided by the first character, + * so this is still fast. If more characters are needed then it requires a lexical sort anyway. + * + * @param qualifier + * @return an equivalent value that can be used with lexical comparison + */ + public static String comparableQualifier( String qualifier ) + { + int i = _QUALIFIERS.indexOf( qualifier ); + + return i == -1 ? ( _QUALIFIERS.size() + "-" + qualifier ) : String.valueOf( i ); + } + + @Override + public int compareTo( Item item ) + { + if ( item == null ) + { + // 1-rc < 1, 1-ga > 1 + return comparableQualifier( value ).compareTo( RELEASE_VERSION_INDEX ); + } + switch ( item.getType() ) + { + case INTEGER_ITEM: + return -1; // 1.any < 1.1 ? + + case STRING_ITEM: + return comparableQualifier( value ).compareTo( comparableQualifier( ( (StringItem) item ).value ) ); + + case LIST_ITEM: + return -1; // 1.any < 1-1 + + default: + throw new RuntimeException( "invalid item: " + item.getClass() ); + } + } + + @Override + public String toString() + { + return value; + } + } + + /** + * Represents a version list item. This class is used both for the global item list and for sub-lists (which start + * with '-(number)' in the version specification). + */ + private static class ListItem + extends ArrayList + implements Item + { + /** + * + */ + private static final long serialVersionUID = 1L; + + @Override + public int getType() + { + return LIST_ITEM; + } + + @Override + public boolean isNull() + { + return ( size() == 0 ); + } + + void normalize() + { + for( ListIterator iterator = listIterator( size() ); iterator.hasPrevious(); ) + { + Item item = iterator.previous(); + if ( item.isNull() ) + { + iterator.remove(); // remove null trailing items: 0, "", empty list + } + else + { + break; + } + } + } + + @Override + public int compareTo( Item item ) + { + if ( item == null ) + { + if ( size() == 0 ) + { + return 0; // 1-0 = 1- (normalize) = 1 + } + Item first = get( 0 ); + return first.compareTo( null ); + } + switch ( item.getType() ) + { + case INTEGER_ITEM: + return -1; // 1-1 < 1.0.x + + case STRING_ITEM: + return 1; // 1-1 > 1-sp + + case LIST_ITEM: + Iterator left = iterator(); + Iterator right = ( (ListItem) item ).iterator(); + + while ( left.hasNext() || right.hasNext() ) + { + Item l = left.hasNext() ? left.next() : null; + Item r = right.hasNext() ? right.next() : null; + + // if this is shorter, then invert the compare and mul with -1 + int result = l == null ? -1 * r.compareTo( l ) : l.compareTo( r ); + + if ( result != 0 ) + { + return result; + } + } + + return 0; + + default: + throw new RuntimeException( "invalid item: " + item.getClass() ); + } + } + + @Override + public String toString() + { + StringBuilder buffer = new StringBuilder( "(" ); + for( Iterator iter = iterator(); iter.hasNext(); ) + { + buffer.append( iter.next() ); + if ( iter.hasNext() ) + { + buffer.append( ',' ); + } + } + buffer.append( ')' ); + return buffer.toString(); + } + } + + public ComparableVersion( String version ) + { + parseVersion( version ); + } + + public final void parseVersion( String version ) + { + this.value = version; + + items = new ListItem(); + + version = version.toLowerCase( Locale.ENGLISH ); + + ListItem list = items; + + Stack stack = new Stack(); + stack.push( list ); + + boolean isDigit = false; + + int startIndex = 0; + + for ( int i = 0; i < version.length(); i++ ) + { + char c = version.charAt( i ); + + if ( c == '.' ) + { + if ( i == startIndex ) + { + list.add( IntegerItem.ZERO ); + } + else + { + list.add( parseItem( isDigit, version.substring( startIndex, i ) ) ); + } + startIndex = i + 1; + } + else if ( c == '-' ) + { + if ( i == startIndex ) + { + list.add( IntegerItem.ZERO ); + } + else + { + list.add( parseItem( isDigit, version.substring( startIndex, i ) ) ); + } + startIndex = i + 1; + + if ( isDigit ) + { + list.normalize(); // 1.0-* = 1-* + + if ( ( i + 1 < version.length() ) && Character.isDigit( version.charAt( i + 1 ) ) ) + { + // new ListItem only if previous were digits and new char is a digit, + // ie need to differentiate only 1.1 from 1-1 + list.add( list = new ListItem() ); + + stack.push( list ); + } + } + } + else if ( Character.isDigit( c ) ) + { + if ( !isDigit && i > startIndex ) + { + list.add( new StringItem( version.substring( startIndex, i ), true ) ); + startIndex = i; + } + + isDigit = true; + } + else + { + if ( isDigit && i > startIndex ) + { + list.add( parseItem( true, version.substring( startIndex, i ) ) ); + startIndex = i; + } + + isDigit = false; + } + } + + if ( version.length() > startIndex ) + { + list.add( parseItem( isDigit, version.substring( startIndex ) ) ); + } + + while ( !stack.isEmpty() ) + { + list = (ListItem) stack.pop(); + list.normalize(); + } + + canonical = items.toString(); + } + + private static Item parseItem( boolean isDigit, String buf ) + { + return isDigit ? new IntegerItem( buf ) : new StringItem( buf, false ); + } + + @Override + public int compareTo( ComparableVersion o ) + { + return items.compareTo( o.items ); + } + + @Override + public String toString() + { + return value; + } + + @Override + public boolean equals( Object o ) + { + return ( o instanceof ComparableVersion ) && canonical.equals( ( (ComparableVersion) o ).canonical ); + } + + @Override + public int hashCode() + { + return canonical.hashCode(); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/versioning/DefaultArtifactVersion.java b/src/main/java/cpw/mods/fml/common/versioning/DefaultArtifactVersion.java new file mode 100644 index 0000000..a25e41a --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/versioning/DefaultArtifactVersion.java @@ -0,0 +1,106 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.versioning; + +public class DefaultArtifactVersion implements ArtifactVersion +{ + + private ComparableVersion comparableVersion; + private String label; + private boolean unbounded; + private VersionRange range; + + public DefaultArtifactVersion(String versionNumber) + { + comparableVersion = new ComparableVersion(versionNumber); + range = VersionRange.createFromVersion(versionNumber, this); + } + + public DefaultArtifactVersion(String label, VersionRange range) + { + this.label = label; + this.range = range; + } + public DefaultArtifactVersion(String label, String version) + { + this(version); + this.label = label; + } + + public DefaultArtifactVersion(String string, boolean unbounded) + { + this.label = string; + this.unbounded = true; + } + + @Override + public boolean equals(Object obj) + { + return ((DefaultArtifactVersion)obj).containsVersion(this); + } + + @Override + public int compareTo(ArtifactVersion o) + { + return unbounded ? 0 : this.comparableVersion.compareTo(((DefaultArtifactVersion)o).comparableVersion); + } + + @Override + public String getLabel() + { + return label; + } + + @Override + public boolean containsVersion(ArtifactVersion source) + { + if (!source.getLabel().equals(getLabel())) + { + return false; + } + if (unbounded) + { + return true; + } + if (range != null) + { + return range.containsVersion(source); + } + else + { + return false; + } + } + + @Override + public String getVersionString() + { + return comparableVersion == null ? "unknown" : comparableVersion.toString(); + } + + @Override + public String getRangeString() + { + return range == null ? "any" : range.toString(); + } + @Override + public String toString() + { + return label == null ? comparableVersion.toString() : label + ( unbounded ? "" : "@" + range); + } + + public VersionRange getRange() + { + return range; + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/versioning/InvalidVersionSpecificationException.java b/src/main/java/cpw/mods/fml/common/versioning/InvalidVersionSpecificationException.java new file mode 100644 index 0000000..0f4e0d9 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/versioning/InvalidVersionSpecificationException.java @@ -0,0 +1,47 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.versioning; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * Occurs when a version is invalid. + * + * @author Brett Porter + */ +public class InvalidVersionSpecificationException extends Exception +{ + private static final long serialVersionUID = 1L; + + public InvalidVersionSpecificationException( String message ) + { + super( message ); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/versioning/Restriction.java b/src/main/java/cpw/mods/fml/common/versioning/Restriction.java new file mode 100644 index 0000000..5c9dbac --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/versioning/Restriction.java @@ -0,0 +1,212 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.versioning; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * Describes a restriction in versioning. + * + * @author Brett Porter + */ +public class Restriction +{ + private final ArtifactVersion lowerBound; + + private final boolean lowerBoundInclusive; + + private final ArtifactVersion upperBound; + + private final boolean upperBoundInclusive; + + public static final Restriction EVERYTHING = new Restriction( null, false, null, false ); + + public Restriction( ArtifactVersion lowerBound, boolean lowerBoundInclusive, ArtifactVersion upperBound, + boolean upperBoundInclusive ) + { + this.lowerBound = lowerBound; + this.lowerBoundInclusive = lowerBoundInclusive; + this.upperBound = upperBound; + this.upperBoundInclusive = upperBoundInclusive; + } + + public ArtifactVersion getLowerBound() + { + return lowerBound; + } + + public boolean isLowerBoundInclusive() + { + return lowerBoundInclusive; + } + + public ArtifactVersion getUpperBound() + { + return upperBound; + } + + public boolean isUpperBoundInclusive() + { + return upperBoundInclusive; + } + + public boolean containsVersion( ArtifactVersion version ) + { + if ( lowerBound != null ) + { + int comparison = lowerBound.compareTo( version ); + + if ( ( comparison == 0 ) && !lowerBoundInclusive ) + { + return false; + } + if ( comparison > 0 ) + { + return false; + } + } + if ( upperBound != null ) + { + int comparison = upperBound.compareTo( version ); + + if ( ( comparison == 0 ) && !upperBoundInclusive ) + { + return false; + } + if ( comparison < 0 ) + { + return false; + } + } + + return true; + } + + @Override + public int hashCode() + { + int result = 13; + + if ( lowerBound == null ) + { + result += 1; + } + else + { + result += lowerBound.hashCode(); + } + + result *= lowerBoundInclusive ? 1 : 2; + + if ( upperBound == null ) + { + result -= 3; + } + else + { + result -= upperBound.hashCode(); + } + + result *= upperBoundInclusive ? 2 : 3; + + return result; + } + + @Override + public boolean equals( Object other ) + { + if ( this == other ) + { + return true; + } + + if ( !( other instanceof Restriction ) ) + { + return false; + } + + Restriction restriction = (Restriction) other; + if ( lowerBound != null ) + { + if ( !lowerBound.equals( restriction.lowerBound ) ) + { + return false; + } + } + else if ( restriction.lowerBound != null ) + { + return false; + } + + if ( lowerBoundInclusive != restriction.lowerBoundInclusive ) + { + return false; + } + + if ( upperBound != null ) + { + if ( !upperBound.equals( restriction.upperBound ) ) + { + return false; + } + } + else if ( restriction.upperBound != null ) + { + return false; + } + + if ( upperBoundInclusive != restriction.upperBoundInclusive ) + { + return false; + } + + return true; + } + + @Override + public String toString() + { + StringBuilder buf = new StringBuilder(); + + buf.append( isLowerBoundInclusive() ? "[" : "(" ); + if ( getLowerBound() != null ) + { + buf.append( getLowerBound().toString() ); + } + buf.append( "," ); + if ( getUpperBound() != null ) + { + buf.append( getUpperBound().toString() ); + } + buf.append( isUpperBoundInclusive() ? "]" : ")" ); + + return buf.toString(); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/versioning/VersionParser.java b/src/main/java/cpw/mods/fml/common/versioning/VersionParser.java new file mode 100644 index 0000000..537975e --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/versioning/VersionParser.java @@ -0,0 +1,75 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.versioning; + +import java.util.List; +import org.apache.logging.log4j.Level; + +import com.google.common.base.Splitter; +import com.google.common.base.Strings; +import com.google.common.collect.Lists; + +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.LoaderException; + +/** + * Parses version strings according to the specification here: + * http://docs.codehaus.org/display/MAVEN/Versioning + * and allows for comparison of versions based on that document. + * Bounded version specifications are defined as + * http://maven.apache.org/plugins/maven-enforcer-plugin/rules/versionRanges.html + * + * Borrows heavily from maven version range management code + * + * @author cpw + * + */ +public class VersionParser +{ + private static final Splitter SEPARATOR = Splitter.on('@').omitEmptyStrings().trimResults(); + public static ArtifactVersion parseVersionReference(String labelledRef) + { + if (Strings.isNullOrEmpty(labelledRef)) + { + throw new RuntimeException(String.format("Empty reference %s", labelledRef)); + } + List parts = Lists.newArrayList(SEPARATOR.split(labelledRef)); + if (parts.size()>2) + { + throw new RuntimeException(String.format("Invalid versioned reference %s", labelledRef)); + } + if (parts.size()==1) + { + return new DefaultArtifactVersion(parts.get(0), true); + } + return new DefaultArtifactVersion(parts.get(0),parseRange(parts.get(1))); + } + + public static boolean satisfies(ArtifactVersion target, ArtifactVersion source) + { + return target.containsVersion(source); + } + + public static VersionRange parseRange(String range) + { + try + { + return VersionRange.createFromVersionSpec(range); + } + catch (InvalidVersionSpecificationException e) + { + FMLLog.log(Level.ERROR, e, "Unable to parse a version range specification successfully %s", range); + throw new LoaderException(e); + } + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/versioning/VersionRange.java b/src/main/java/cpw/mods/fml/common/versioning/VersionRange.java new file mode 100644 index 0000000..3371f15 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/versioning/VersionRange.java @@ -0,0 +1,566 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.common.versioning; +/* + * Modifications by cpw under LGPL 2.1 or later + */ + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + +import com.google.common.base.Joiner; + +/** + * Construct a version range from a specification. + * + * @author Brett Porter + */ +public class VersionRange +{ + private final ArtifactVersion recommendedVersion; + + private final List restrictions; + + private VersionRange( ArtifactVersion recommendedVersion, + List restrictions ) + { + this.recommendedVersion = recommendedVersion; + this.restrictions = restrictions; + } + + public ArtifactVersion getRecommendedVersion() + { + return recommendedVersion; + } + + public List getRestrictions() + { + return restrictions; + } + + public VersionRange cloneOf() + { + List copiedRestrictions = null; + + if ( restrictions != null ) + { + copiedRestrictions = new ArrayList(); + + if ( !restrictions.isEmpty() ) + { + copiedRestrictions.addAll( restrictions ); + } + } + + return new VersionRange( recommendedVersion, copiedRestrictions ); + } + + /** + * Create a version range from a string representation + *

+ * Some spec examples are + *

    + *
  • 1.0 Version 1.0
  • + *
  • [1.0,2.0) Versions 1.0 (included) to 2.0 (not included)
  • + *
  • [1.0,2.0] Versions 1.0 to 2.0 (both included)
  • + *
  • [1.5,) Versions 1.5 and higher
  • + *
  • (,1.0],[1.2,) Versions up to 1.0 (included) and 1.2 or higher
  • + *
+ * + * @param spec string representation of a version or version range + * @return a new {@link VersionRange} object that represents the spec + * @throws InvalidVersionSpecificationException + * + */ + public static VersionRange createFromVersionSpec( String spec ) + throws InvalidVersionSpecificationException + { + if ( spec == null ) + { + return null; + } + + List restrictions = new ArrayList(); + String process = spec; + ArtifactVersion version = null; + ArtifactVersion upperBound = null; + ArtifactVersion lowerBound = null; + + while ( process.startsWith( "[" ) || process.startsWith( "(" ) ) + { + int index1 = process.indexOf( ")" ); + int index2 = process.indexOf( "]" ); + + int index = index2; + if ( index2 < 0 || index1 < index2 ) + { + if ( index1 >= 0 ) + { + index = index1; + } + } + + if ( index < 0 ) + { + throw new InvalidVersionSpecificationException( "Unbounded range: " + spec ); + } + + Restriction restriction = parseRestriction( process.substring( 0, index + 1 ) ); + if ( lowerBound == null ) + { + lowerBound = restriction.getLowerBound(); + } + if ( upperBound != null ) + { + if ( restriction.getLowerBound() == null || restriction.getLowerBound().compareTo( upperBound ) < 0 ) + { + throw new InvalidVersionSpecificationException( "Ranges overlap: " + spec ); + } + } + restrictions.add( restriction ); + upperBound = restriction.getUpperBound(); + + process = process.substring( index + 1 ).trim(); + + if ( process.length() > 0 && process.startsWith( "," ) ) + { + process = process.substring( 1 ).trim(); + } + } + + if ( process.length() > 0 ) + { + if ( restrictions.size() > 0 ) + { + throw new InvalidVersionSpecificationException( + "Only fully-qualified sets allowed in multiple set scenario: " + spec ); + } + else + { + version = new DefaultArtifactVersion( process ); + restrictions.add( Restriction.EVERYTHING ); + } + } + + return new VersionRange( version, restrictions ); + } + + private static Restriction parseRestriction( String spec ) + throws InvalidVersionSpecificationException + { + boolean lowerBoundInclusive = spec.startsWith( "[" ); + boolean upperBoundInclusive = spec.endsWith( "]" ); + + String process = spec.substring( 1, spec.length() - 1 ).trim(); + + Restriction restriction; + + int index = process.indexOf( "," ); + + if ( index < 0 ) + { + if ( !lowerBoundInclusive || !upperBoundInclusive ) + { + throw new InvalidVersionSpecificationException( "Single version must be surrounded by []: " + spec ); + } + + ArtifactVersion version = new DefaultArtifactVersion( process ); + + restriction = new Restriction( version, lowerBoundInclusive, version, upperBoundInclusive ); + } + else + { + String lowerBound = process.substring( 0, index ).trim(); + String upperBound = process.substring( index + 1 ).trim(); + if ( lowerBound.equals( upperBound ) ) + { + throw new InvalidVersionSpecificationException( "Range cannot have identical boundaries: " + spec ); + } + + ArtifactVersion lowerVersion = null; + if ( lowerBound.length() > 0 ) + { + lowerVersion = new DefaultArtifactVersion( lowerBound ); + } + ArtifactVersion upperVersion = null; + if ( upperBound.length() > 0 ) + { + upperVersion = new DefaultArtifactVersion( upperBound ); + } + + if ( upperVersion != null && lowerVersion != null && upperVersion.compareTo( lowerVersion ) < 0 ) + { + throw new InvalidVersionSpecificationException( "Range defies version ordering: " + spec ); + } + + restriction = new Restriction( lowerVersion, lowerBoundInclusive, upperVersion, upperBoundInclusive ); + } + + return restriction; + } + + public static VersionRange createFromVersion( String version , ArtifactVersion existing) + { + List restrictions = Collections.emptyList(); + if (existing == null) + { + existing = new DefaultArtifactVersion( version ); + } + return new VersionRange(existing , restrictions ); + } + + /** + * Creates and returns a new VersionRange that is a restriction of this + * version range and the specified version range. + *

+ * Note: Precedence is given to the recommended version from this version range over the + * recommended version from the specified version range. + *

+ * + * @param restriction the VersionRange that will be used to restrict this version + * range. + * @return the VersionRange that is a restriction of this version range and the + * specified version range. + *

+ * The restrictions of the returned version range will be an intersection of the restrictions + * of this version range and the specified version range if both version ranges have + * restrictions. Otherwise, the restrictions on the returned range will be empty. + *

+ *

+ * The recommended version of the returned version range will be the recommended version of + * this version range, provided that ranges falls within the intersected restrictions. If + * the restrictions are empty, this version range's recommended version is used if it is not + * null. If it is null, the specified version range's recommended + * version is used (provided it is non-null). If no recommended version can be + * obtained, the returned version range's recommended version is set to null. + *

+ * @throws NullPointerException if the specified VersionRange is + * null. + */ + public VersionRange restrict( VersionRange restriction ) + { + List r1 = this.restrictions; + List r2 = restriction.restrictions; + List restrictions; + + if ( r1.isEmpty() || r2.isEmpty() ) + { + restrictions = Collections.emptyList(); + } + else + { + restrictions = intersection( r1, r2 ); + } + + ArtifactVersion version = null; + if ( restrictions.size() > 0 ) + { + for ( Restriction r : restrictions ) + { + if ( recommendedVersion != null && r.containsVersion( recommendedVersion ) ) + { + // if we find the original, use that + version = recommendedVersion; + break; + } + else if ( version == null && restriction.getRecommendedVersion() != null + && r.containsVersion( restriction.getRecommendedVersion() ) ) + { + // use this if we can, but prefer the original if possible + version = restriction.getRecommendedVersion(); + } + } + } + // Either the original or the specified version ranges have no restrictions + else if ( recommendedVersion != null ) + { + // Use the original recommended version since it exists + version = recommendedVersion; + } + else if ( restriction.recommendedVersion != null ) + { + // Use the recommended version from the specified VersionRange since there is no + // original recommended version + version = restriction.recommendedVersion; + } +/* TODO: should throw this immediately, but need artifact + else + { + throw new OverConstrainedVersionException( "Restricting incompatible version ranges" ); + } +*/ + + return new VersionRange( version, restrictions ); + } + + private List intersection( List r1, List r2 ) + { + List restrictions = new ArrayList( r1.size() + r2.size() ); + Iterator i1 = r1.iterator(); + Iterator i2 = r2.iterator(); + Restriction res1 = i1.next(); + Restriction res2 = i2.next(); + + boolean done = false; + while ( !done ) + { + if ( res1.getLowerBound() == null || res2.getUpperBound() == null + || res1.getLowerBound().compareTo( res2.getUpperBound() ) <= 0 ) + { + if ( res1.getUpperBound() == null || res2.getLowerBound() == null + || res1.getUpperBound().compareTo( res2.getLowerBound() ) >= 0 ) + { + ArtifactVersion lower; + ArtifactVersion upper; + boolean lowerInclusive; + boolean upperInclusive; + + // overlaps + if ( res1.getLowerBound() == null ) + { + lower = res2.getLowerBound(); + lowerInclusive = res2.isLowerBoundInclusive(); + } + else if ( res2.getLowerBound() == null ) + { + lower = res1.getLowerBound(); + lowerInclusive = res1.isLowerBoundInclusive(); + } + else + { + int comparison = res1.getLowerBound().compareTo( res2.getLowerBound() ); + if ( comparison < 0 ) + { + lower = res2.getLowerBound(); + lowerInclusive = res2.isLowerBoundInclusive(); + } + else if ( comparison == 0 ) + { + lower = res1.getLowerBound(); + lowerInclusive = res1.isLowerBoundInclusive() && res2.isLowerBoundInclusive(); + } + else + { + lower = res1.getLowerBound(); + lowerInclusive = res1.isLowerBoundInclusive(); + } + } + + if ( res1.getUpperBound() == null ) + { + upper = res2.getUpperBound(); + upperInclusive = res2.isUpperBoundInclusive(); + } + else if ( res2.getUpperBound() == null ) + { + upper = res1.getUpperBound(); + upperInclusive = res1.isUpperBoundInclusive(); + } + else + { + int comparison = res1.getUpperBound().compareTo( res2.getUpperBound() ); + if ( comparison < 0 ) + { + upper = res1.getUpperBound(); + upperInclusive = res1.isUpperBoundInclusive(); + } + else if ( comparison == 0 ) + { + upper = res1.getUpperBound(); + upperInclusive = res1.isUpperBoundInclusive() && res2.isUpperBoundInclusive(); + } + else + { + upper = res2.getUpperBound(); + upperInclusive = res2.isUpperBoundInclusive(); + } + } + + // don't add if they are equal and one is not inclusive + if ( lower == null || upper == null || lower.compareTo( upper ) != 0 ) + { + restrictions.add( new Restriction( lower, lowerInclusive, upper, upperInclusive ) ); + } + else if ( lowerInclusive && upperInclusive ) + { + restrictions.add( new Restriction( lower, lowerInclusive, upper, upperInclusive ) ); + } + + //noinspection ObjectEquality + if ( upper == res2.getUpperBound() ) + { + // advance res2 + if ( i2.hasNext() ) + { + res2 = i2.next(); + } + else + { + done = true; + } + } + else + { + // advance res1 + if ( i1.hasNext() ) + { + res1 = i1.next(); + } + else + { + done = true; + } + } + } + else + { + // move on to next in r1 + if ( i1.hasNext() ) + { + res1 = i1.next(); + } + else + { + done = true; + } + } + } + else + { + // move on to next in r2 + if ( i2.hasNext() ) + { + res2 = i2.next(); + } + else + { + done = true; + } + } + } + + return restrictions; + } + + @Override + public String toString() + { + if ( recommendedVersion != null ) + { + return recommendedVersion.toString(); + } + else + { + return Joiner.on(',').join(restrictions); + } + } + + public ArtifactVersion matchVersion( List versions ) + { + // TODO: could be more efficient by sorting the list and then moving along the restrictions in order? + + ArtifactVersion matched = null; + for ( ArtifactVersion version : versions ) + { + if ( containsVersion( version ) ) + { + // valid - check if it is greater than the currently matched version + if ( matched == null || version.compareTo( matched ) > 0 ) + { + matched = version; + } + } + } + return matched; + } + + public boolean containsVersion( ArtifactVersion version ) + { + for ( Restriction restriction : restrictions ) + { + if ( restriction.containsVersion( version ) ) + { + return true; + } + } + return false; + } + + public boolean hasRestrictions() + { + return !restrictions.isEmpty() && recommendedVersion == null; + } + + @Override + public boolean equals( Object obj ) + { + if ( this == obj ) + { + return true; + } + if ( !( obj instanceof VersionRange ) ) + { + return false; + } + VersionRange other = (VersionRange) obj; + + boolean equals = + recommendedVersion == other.recommendedVersion + || ( ( recommendedVersion != null ) && recommendedVersion.equals( other.recommendedVersion ) ); + equals &= + restrictions == other.restrictions + || ( ( restrictions != null ) && restrictions.equals( other.restrictions ) ); + return equals; + } + + @Override + public int hashCode() + { + int hash = 7; + hash = 31 * hash + ( recommendedVersion == null ? 0 : recommendedVersion.hashCode() ); + hash = 31 * hash + ( restrictions == null ? 0 : restrictions.hashCode() ); + return hash; + } + + public boolean isUnboundedAbove() + { + return restrictions.size() == 1 && restrictions.get(0).getUpperBound() == null && !restrictions.get(0).isUpperBoundInclusive(); + } + + public String getLowerBoundString() + { + return restrictions.size() == 1 ? restrictions.get(0).getLowerBound().getVersionString() : ""; + } + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/relauncher/CoreModManager.java b/src/main/java/cpw/mods/fml/relauncher/CoreModManager.java new file mode 100644 index 0000000..53dfc2a --- /dev/null +++ b/src/main/java/cpw/mods/fml/relauncher/CoreModManager.java @@ -0,0 +1,568 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.relauncher; + +import java.io.File; +import java.io.FilenameFilter; +import java.io.IOException; +import java.lang.reflect.Method; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.jar.Attributes; +import java.util.jar.JarFile; + +import org.apache.logging.log4j.Level; + +import net.minecraft.launchwrapper.ITweaker; +import net.minecraft.launchwrapper.Launch; +import net.minecraft.launchwrapper.LaunchClassLoader; + +import com.google.common.base.Strings; +import com.google.common.base.Throwables; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.ObjectArrays; +import com.google.common.primitives.Ints; + +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker; +import cpw.mods.fml.common.launcher.FMLTweaker; +import cpw.mods.fml.common.toposort.TopologicalSort; +import cpw.mods.fml.relauncher.IFMLLoadingPlugin.DependsOn; +import cpw.mods.fml.relauncher.IFMLLoadingPlugin.MCVersion; +import cpw.mods.fml.relauncher.IFMLLoadingPlugin.Name; +import cpw.mods.fml.relauncher.IFMLLoadingPlugin.SortingIndex; +import cpw.mods.fml.relauncher.IFMLLoadingPlugin.TransformerExclusions; + +public class CoreModManager { + private static final Attributes.Name COREMODCONTAINSFMLMOD = new Attributes.Name("FMLCorePluginContainsFMLMod"); + private static String[] rootPlugins = { "cpw.mods.fml.relauncher.FMLCorePlugin", "net.minecraftforge.classloading.FMLForgePlugin" }; + private static List loadedCoremods = Lists.newArrayList(); + private static List loadPlugins; + private static boolean deobfuscatedEnvironment; + private static FMLTweaker tweaker; + private static File mcDir; + private static List reparsedCoremods = Lists.newArrayList(); + private static List accessTransformers = Lists.newArrayList(); + + private static class FMLPluginWrapper implements ITweaker { + public final String name; + public final IFMLLoadingPlugin coreModInstance; + public final List predepends; + public final File location; + public final int sortIndex; + + public FMLPluginWrapper(String name, IFMLLoadingPlugin coreModInstance, File location, int sortIndex, String... predepends) + { + super(); + this.name = name; + this.coreModInstance = coreModInstance; + this.location = location; + this.sortIndex = sortIndex; + this.predepends = Lists.newArrayList(predepends); + } + + @Override + public String toString() + { + return String.format("%s {%s}", this.name, this.predepends); + } + + @Override + public void acceptOptions(List args, File gameDir, File assetsDir, String profile) + { + // NO OP + } + + @Override + public void injectIntoClassLoader(LaunchClassLoader classLoader) + { + FMLRelaunchLog.fine("Injecting coremod %s {%s} class transformers", name, coreModInstance.getClass().getName()); + if (coreModInstance.getASMTransformerClass() != null) for (String transformer : coreModInstance.getASMTransformerClass()) + { + FMLRelaunchLog.finer("Registering transformer %s", transformer); + classLoader.registerTransformer(transformer); + } + FMLRelaunchLog.fine("Injection complete"); + + FMLRelaunchLog.fine("Running coremod plugin for %s {%s}", name, coreModInstance.getClass().getName()); + Map data = new HashMap(); + data.put("mcLocation", mcDir); + data.put("coremodList", loadPlugins); + data.put("runtimeDeobfuscationEnabled", !deobfuscatedEnvironment); + FMLRelaunchLog.fine("Running coremod plugin %s", name); + data.put("coremodLocation", location); + coreModInstance.injectData(data); + String setupClass = coreModInstance.getSetupClass(); + if (setupClass != null) + { + try + { + IFMLCallHook call = (IFMLCallHook) Class.forName(setupClass, true, classLoader).newInstance(); + Map callData = new HashMap(); + callData.put("mcLocation", mcDir); + callData.put("classLoader", classLoader); + callData.put("coremodLocation", location); + callData.put("deobfuscationFileName", FMLInjectionData.debfuscationDataName()); + call.injectData(callData); + call.call(); + } + catch (Exception e) + { + throw new RuntimeException(e); + } + } + FMLRelaunchLog.fine("Coremod plugin class %s run successfully", coreModInstance.getClass().getSimpleName()); + + String modContainer = coreModInstance.getModContainerClass(); + if (modContainer != null) + { + FMLInjectionData.containers.add(modContainer); + } + } + + @Override + public String getLaunchTarget() + { + return ""; + } + + @Override + public String[] getLaunchArguments() + { + return new String[0]; + } + + } + + public static void handleLaunch(File mcDir, LaunchClassLoader classLoader, FMLTweaker tweaker) + { + CoreModManager.mcDir = mcDir; + CoreModManager.tweaker = tweaker; + try + { + // Are we in a 'decompiled' environment? + byte[] bs = classLoader.getClassBytes("net.minecraft.world.World"); + if (bs != null) + { + FMLRelaunchLog.info("Managed to load a deobfuscated Minecraft name- we are in a deobfuscated environment. Skipping runtime deobfuscation"); + deobfuscatedEnvironment = true; + } + } + catch (IOException e1) + { + } + + if (!deobfuscatedEnvironment) + { + FMLRelaunchLog.fine("Enabling runtime deobfuscation"); + } + + tweaker.injectCascadingTweak("cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker"); + try + { + classLoader.registerTransformer("cpw.mods.fml.common.asm.transformers.PatchingTransformer"); + } + catch (Exception e) + { + FMLRelaunchLog.log(Level.ERROR, e, "The patch transformer failed to load! This is critical, loading cannot continue!"); + throw Throwables.propagate(e); + } + + loadPlugins = new ArrayList(); + for (String rootPluginName : rootPlugins) + { + loadCoreMod(classLoader, rootPluginName, new File(FMLTweaker.getJarLocation())); + } + + if (loadPlugins.isEmpty()) + { + throw new RuntimeException("A fatal error has occured - no valid fml load plugin was found - this is a completely corrupt FML installation."); + } + + FMLRelaunchLog.fine("All fundamental core mods are successfully located"); + // Now that we have the root plugins loaded - lets see what else might + // be around + String commandLineCoremods = System.getProperty("fml.coreMods.load", ""); + for (String coreModClassName : commandLineCoremods.split(",")) + { + if (coreModClassName.isEmpty()) + { + continue; + } + FMLRelaunchLog.info("Found a command line coremod : %s", coreModClassName); + loadCoreMod(classLoader, coreModClassName, null); + } + discoverCoreMods(mcDir, classLoader); + + } + + private static void discoverCoreMods(File mcDir, LaunchClassLoader classLoader) + { + FMLRelaunchLog.fine("Discovering coremods"); + File coreMods = setupCoreModDir(mcDir); + FilenameFilter ff = new FilenameFilter() { + @Override + public boolean accept(File dir, String name) + { + return name.endsWith(".jar"); + } + }; + File[] coreModList = coreMods.listFiles(ff); + File versionedModDir = new File(coreMods, FMLInjectionData.mccversion); + if (versionedModDir.isDirectory()) + { + File[] versionedCoreMods = versionedModDir.listFiles(ff); + coreModList = ObjectArrays.concat(coreModList, versionedCoreMods, File.class); + } + + coreModList = FileListHelper.sortFileList(coreModList); + + for (File coreMod : coreModList) + { + FMLRelaunchLog.fine("Examining for coremod candidacy %s", coreMod.getName()); + JarFile jar = null; + Attributes mfAttributes; + try + { + jar = new JarFile(coreMod); + if (jar.getManifest() == null) + { + // Not a coremod + continue; + } + mfAttributes = jar.getManifest().getMainAttributes(); + } + catch (IOException ioe) + { + FMLRelaunchLog.log(Level.ERROR, ioe, "Unable to read the jar file %s - ignoring", coreMod.getName()); + continue; + } + finally + { + if (jar != null) + { + try + { + jar.close(); + } + catch (IOException e) + { + // Noise + } + } + } + String cascadedTweaker = mfAttributes.getValue("TweakClass"); + if (cascadedTweaker != null) + { + FMLRelaunchLog.info("Loading tweaker %s from %s", cascadedTweaker, coreMod.getName()); + Integer sortOrder = Ints.tryParse(Strings.nullToEmpty(mfAttributes.getValue("TweakOrder"))); + sortOrder = (sortOrder == null ? Integer.valueOf(0) : sortOrder); + handleCascadingTweak(coreMod, jar, cascadedTweaker, classLoader, sortOrder); + loadedCoremods.add(coreMod.getName()); + continue; + } + + String fmlCorePlugin = mfAttributes.getValue("FMLCorePlugin"); + if (fmlCorePlugin == null) + { + // Not a coremod + FMLRelaunchLog.fine("Not found coremod data in %s", coreMod.getName()); + continue; + } + + try + { + classLoader.addURL(coreMod.toURI().toURL()); + if (!mfAttributes.containsKey(COREMODCONTAINSFMLMOD)) + { + FMLRelaunchLog.finer("Adding %s to the list of known coremods, it will not be examined again", coreMod.getName()); + loadedCoremods.add(coreMod.getName()); + } + else + { + FMLRelaunchLog.finer("Found FMLCorePluginContainsFMLMod marker in %s, it will be examined later for regular @Mod instances", + coreMod.getName()); + reparsedCoremods.add(coreMod.getName()); + } + } + catch (MalformedURLException e) + { + FMLRelaunchLog.log(Level.ERROR, e, "Unable to convert file into a URL. weird"); + continue; + } + loadCoreMod(classLoader, fmlCorePlugin, coreMod); + } + } + + private static Method ADDURL; + + private static void handleCascadingTweak(File coreMod, JarFile jar, String cascadedTweaker, LaunchClassLoader classLoader, Integer sortingOrder) + { + try + { + // Have to manually stuff the tweaker into the parent classloader + if (ADDURL == null) + { + ADDURL = URLClassLoader.class.getDeclaredMethod("addURL", URL.class); + ADDURL.setAccessible(true); + } + ADDURL.invoke(classLoader.getClass().getClassLoader(), coreMod.toURI().toURL()); + classLoader.addURL(coreMod.toURI().toURL()); + CoreModManager.tweaker.injectCascadingTweak(cascadedTweaker); + tweakSorting.put(cascadedTweaker,sortingOrder); + } + catch (Exception e) + { + FMLRelaunchLog.log(Level.INFO, e, "There was a problem trying to load the mod dir tweaker %s", coreMod.getAbsolutePath()); + } + } + + /** + * @param mcDir + * the minecraft home directory + * @return the coremod directory + */ + private static File setupCoreModDir(File mcDir) + { + File coreModDir = new File(mcDir, "mods"); + try + { + coreModDir = coreModDir.getCanonicalFile(); + } + catch (IOException e) + { + throw new RuntimeException(String.format("Unable to canonicalize the coremod dir at %s", mcDir.getName()), e); + } + if (!coreModDir.exists()) + { + coreModDir.mkdir(); + } + else if (coreModDir.exists() && !coreModDir.isDirectory()) + { + throw new RuntimeException(String.format("Found a coremod file in %s that's not a directory", mcDir.getName())); + } + return coreModDir; + } + + public static List getLoadedCoremods() + { + return loadedCoremods; + } + + public static List getReparseableCoremods() + { + return reparsedCoremods; + } + + private static FMLPluginWrapper loadCoreMod(LaunchClassLoader classLoader, String coreModClass, File location) + { + String coreModName = coreModClass.substring(coreModClass.lastIndexOf('.') + 1); + try + { + FMLRelaunchLog.fine("Instantiating coremod class %s", coreModName); + classLoader.addTransformerExclusion(coreModClass); + Class coreModClazz = Class.forName(coreModClass, true, classLoader); + Name coreModNameAnn = coreModClazz.getAnnotation(IFMLLoadingPlugin.Name.class); + if (coreModNameAnn != null && !Strings.isNullOrEmpty(coreModNameAnn.value())) + { + coreModName = coreModNameAnn.value(); + FMLRelaunchLog.finer("coremod named %s is loading", coreModName); + } + MCVersion requiredMCVersion = coreModClazz.getAnnotation(IFMLLoadingPlugin.MCVersion.class); + if (!Arrays.asList(rootPlugins).contains(coreModClass) && (requiredMCVersion == null || Strings.isNullOrEmpty(requiredMCVersion.value()))) + { + FMLRelaunchLog.log(Level.WARN, "The coremod %s does not have a MCVersion annotation, it may cause issues with this version of Minecraft", + coreModClass); + } + else if (requiredMCVersion != null && !FMLInjectionData.mccversion.equals(requiredMCVersion.value())) + { + FMLRelaunchLog.log(Level.ERROR, "The coremod %s is requesting minecraft version %s and minecraft is %s. It will be ignored.", coreModClass, + requiredMCVersion.value(), FMLInjectionData.mccversion); + return null; + } + else if (requiredMCVersion != null) + { + FMLRelaunchLog.log(Level.DEBUG, "The coremod %s requested minecraft version %s and minecraft is %s. It will be loaded.", coreModClass, + requiredMCVersion.value(), FMLInjectionData.mccversion); + } + TransformerExclusions trExclusions = coreModClazz.getAnnotation(IFMLLoadingPlugin.TransformerExclusions.class); + if (trExclusions != null) + { + for (String st : trExclusions.value()) + { + classLoader.addTransformerExclusion(st); + } + } + DependsOn deplist = coreModClazz.getAnnotation(IFMLLoadingPlugin.DependsOn.class); + String[] dependencies = new String[0]; + if (deplist != null) + { + dependencies = deplist.value(); + } + SortingIndex index = coreModClazz.getAnnotation(IFMLLoadingPlugin.SortingIndex.class); + int sortIndex = index != null ? index.value() : 0; + + IFMLLoadingPlugin plugin = (IFMLLoadingPlugin) coreModClazz.newInstance(); + String accessTransformerClass = plugin.getAccessTransformerClass(); + if (accessTransformerClass != null) + { + FMLRelaunchLog.log(Level.DEBUG, "Added access transformer class %s to enqueued access transformers", accessTransformerClass); + accessTransformers.add(accessTransformerClass); + } + FMLPluginWrapper wrap = new FMLPluginWrapper(coreModName, plugin, location, sortIndex, dependencies); + loadPlugins.add(wrap); + FMLRelaunchLog.fine("Enqueued coremod %s", coreModName); + return wrap; + } + catch (ClassNotFoundException cnfe) + { + if (!Lists.newArrayList(rootPlugins).contains(coreModClass)) + FMLRelaunchLog.log(Level.ERROR, cnfe, "Coremod %s: Unable to class load the plugin %s", coreModName, coreModClass); + else + FMLRelaunchLog.fine("Skipping root plugin %s", coreModClass); + } + catch (ClassCastException cce) + { + FMLRelaunchLog.log(Level.ERROR, cce, "Coremod %s: The plugin %s is not an implementor of IFMLLoadingPlugin", coreModName, coreModClass); + } + catch (InstantiationException ie) + { + FMLRelaunchLog.log(Level.ERROR, ie, "Coremod %s: The plugin class %s was not instantiable", coreModName, coreModClass); + } + catch (IllegalAccessException iae) + { + FMLRelaunchLog.log(Level.ERROR, iae, "Coremod %s: The plugin class %s was not accessible", coreModName, coreModClass); + } + return null; + } + + @SuppressWarnings("unused") + private static void sortCoreMods() + { + TopologicalSort.DirectedGraph sortGraph = new TopologicalSort.DirectedGraph(); + Map pluginMap = Maps.newHashMap(); + for (FMLPluginWrapper plug : loadPlugins) + { + sortGraph.addNode(plug); + pluginMap.put(plug.name, plug); + } + + for (FMLPluginWrapper plug : loadPlugins) + { + for (String dep : plug.predepends) + { + if (!pluginMap.containsKey(dep)) + { + FMLRelaunchLog.log(Level.ERROR, "Missing coremod dependency - the coremod %s depends on coremod %s which isn't present.", plug.name, dep); + throw new RuntimeException(); + } + sortGraph.addEdge(plug, pluginMap.get(dep)); + } + } + try + { + loadPlugins = TopologicalSort.topologicalSort(sortGraph); + FMLRelaunchLog.fine("Sorted coremod list %s", loadPlugins); + } + catch (Exception e) + { + FMLLog.log(Level.ERROR, e, "There was a problem performing the coremod sort"); + throw Throwables.propagate(e); + } + } + + public static void injectTransformers(LaunchClassLoader classLoader) + { + + Launch.blackboard.put("fml.deobfuscatedEnvironment", deobfuscatedEnvironment); + tweaker.injectCascadingTweak("cpw.mods.fml.common.launcher.FMLDeobfTweaker"); + tweakSorting.put("cpw.mods.fml.common.launcher.FMLDeobfTweaker", Integer.valueOf(1000)); + } + + public static void injectCoreModTweaks(FMLInjectionAndSortingTweaker fmlInjectionAndSortingTweaker) + { + @SuppressWarnings("unchecked") + List tweakers = (List) Launch.blackboard.get("Tweaks"); + // Add the sorting tweaker first- it'll appear twice in the list + tweakers.add(0, fmlInjectionAndSortingTweaker); + for (FMLPluginWrapper wrapper : loadPlugins) + { + tweakers.add(wrapper); + } + } + + private static Map tweakSorting = Maps.newHashMap(); + + public static void sortTweakList() + { + @SuppressWarnings("unchecked") + List tweakers = (List) Launch.blackboard.get("Tweaks"); + Collections.sort(tweakers, new Comparator() { + @Override + public int compare(ITweaker o1, ITweaker o2) + { + Integer first = null; + Integer second = null; + if (o1 instanceof FMLInjectionAndSortingTweaker) + { + first = Integer.MIN_VALUE; + } + if (o2 instanceof FMLInjectionAndSortingTweaker) + { + second = Integer.MIN_VALUE; + } + + if (o1 instanceof FMLPluginWrapper) + { + first = ((FMLPluginWrapper) o1).sortIndex; + } + else if (first == null) + { + first = tweakSorting.get(o1.getClass().getName()); + } + if (o2 instanceof FMLPluginWrapper) + { + second = ((FMLPluginWrapper) o2).sortIndex; + } + else if (second == null) + { + second = tweakSorting.get(o2.getClass().getName()); + } + if (first == null) + { + first = 0; + } + if (second == null) + { + second = 0; + } + + return Ints.saturatedCast((long)first - (long)second); + } + }); + } + + public static List getAccessTransformers() + { + return accessTransformers; + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/relauncher/FMLCorePlugin.java b/src/main/java/cpw/mods/fml/relauncher/FMLCorePlugin.java new file mode 100644 index 0000000..2961bfa --- /dev/null +++ b/src/main/java/cpw/mods/fml/relauncher/FMLCorePlugin.java @@ -0,0 +1,51 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.relauncher; + +import java.util.Map; + +public class FMLCorePlugin implements IFMLLoadingPlugin +{ + @Override + public String[] getASMTransformerClass() + { + return new String[] { + "cpw.mods.fml.common.asm.transformers.MarkerTransformer", + "cpw.mods.fml.common.asm.transformers.SideTransformer", + "cpw.mods.fml.common.asm.transformers.EventSubscriptionTransformer", + }; + } + + @Override + public String getAccessTransformerClass() + { + return "cpw.mods.fml.common.asm.transformers.AccessTransformer"; + } + @Override + public String getModContainerClass() + { + return "cpw.mods.fml.common.FMLContainer"; + } + + @Override + public String getSetupClass() + { + return "cpw.mods.fml.common.asm.FMLSanityChecker"; + } + + @Override + public void injectData(Map data) + { + // don't care about this data + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/relauncher/FMLInjectionData.java b/src/main/java/cpw/mods/fml/relauncher/FMLInjectionData.java new file mode 100644 index 0000000..dacaaca --- /dev/null +++ b/src/main/java/cpw/mods/fml/relauncher/FMLInjectionData.java @@ -0,0 +1,73 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.relauncher; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; +import org.apache.logging.log4j.Level; + +import net.minecraft.launchwrapper.LaunchClassLoader; + +public class FMLInjectionData +{ + static File minecraftHome; + static String major; + static String minor; + static String rev; + static String build; + static String mccversion; + static String mcpversion; + static String deobfuscationDataHash; + + public static List containers = new ArrayList(); + + static void build(File mcHome, LaunchClassLoader classLoader) + { + minecraftHome = mcHome; + InputStream stream = classLoader.getResourceAsStream("fmlversion.properties"); + Properties properties = new Properties(); + + if (stream != null) + { + try + { + properties.load(stream); + } + catch (IOException ex) + { + FMLRelaunchLog.log(Level.ERROR, ex, "Could not get FML version information - corrupted installation detected!"); + } + } + + major = properties.getProperty("fmlbuild.major.number", "missing"); + minor = properties.getProperty("fmlbuild.minor.number", "missing"); + rev = properties.getProperty("fmlbuild.revision.number", "missing"); + build = properties.getProperty("fmlbuild.build.number", "missing"); + mccversion = properties.getProperty("fmlbuild.mcversion", "missing"); + mcpversion = properties.getProperty("fmlbuild.mcpversion", "missing"); + deobfuscationDataHash = properties.getProperty("fmlbuild.deobfuscation.hash","deadbeef"); + } + + static String debfuscationDataName() + { + return "/deobfuscation_data-"+mccversion+".lzma"; + } + public static Object[] data() + { + return new Object[] { major, minor, rev, build, mccversion, mcpversion, minecraftHome, containers }; + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/relauncher/FMLLaunchHandler.java b/src/main/java/cpw/mods/fml/relauncher/FMLLaunchHandler.java new file mode 100644 index 0000000..8b3ac60 --- /dev/null +++ b/src/main/java/cpw/mods/fml/relauncher/FMLLaunchHandler.java @@ -0,0 +1,115 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.relauncher; + +import java.io.File; +import org.apache.logging.log4j.Level; + +import net.minecraft.launchwrapper.LaunchClassLoader; + +import com.google.common.base.Throwables; + +import cpw.mods.fml.common.launcher.FMLTweaker; + +public class FMLLaunchHandler +{ + private static FMLLaunchHandler INSTANCE; + static Side side; + private LaunchClassLoader classLoader; + private FMLTweaker tweaker; + private File minecraftHome; + + public static void configureForClientLaunch(LaunchClassLoader loader, FMLTweaker tweaker) + { + instance(loader, tweaker).setupClient(); + } + + public static void configureForServerLaunch(LaunchClassLoader loader, FMLTweaker tweaker) + { + instance(loader, tweaker).setupServer(); + } + + private static FMLLaunchHandler instance(LaunchClassLoader launchLoader, FMLTweaker tweaker) + { + if (INSTANCE == null) + { + INSTANCE = new FMLLaunchHandler(launchLoader, tweaker); + } + return INSTANCE; + + } + + private FMLLaunchHandler(LaunchClassLoader launchLoader, FMLTweaker tweaker) + { + this.classLoader = launchLoader; + this.tweaker = tweaker; + this.minecraftHome = tweaker.getGameDir(); + this.classLoader.addClassLoaderExclusion("cpw.mods.fml.relauncher."); + this.classLoader.addClassLoaderExclusion("net.minecraftforge.classloading."); + this.classLoader.addTransformerExclusion("cpw.mods.fml.common.asm.transformers.deobf."); + this.classLoader.addTransformerExclusion("cpw.mods.fml.common.patcher."); + } + + private void setupClient() + { + FMLRelaunchLog.side = Side.CLIENT; + side = Side.CLIENT; + setupHome(); + } + + private void setupServer() + { + FMLRelaunchLog.side = Side.SERVER; + side = Side.SERVER; + setupHome(); + + } + + private void setupHome() + { + FMLInjectionData.build(minecraftHome, classLoader); + FMLRelaunchLog.minecraftHome = minecraftHome; + FMLRelaunchLog.info("Forge Mod Loader version %s.%s.%s.%s for Minecraft %s loading", FMLInjectionData.major, FMLInjectionData.minor, + FMLInjectionData.rev, FMLInjectionData.build, FMLInjectionData.mccversion, FMLInjectionData.mcpversion); + FMLRelaunchLog.info("Java is %s, version %s, running on %s:%s:%s, installed at %s", System.getProperty("java.vm.name"), System.getProperty("java.version"), System.getProperty("os.name"), System.getProperty("os.arch"), System.getProperty("os.version"), System.getProperty("java.home")); + FMLRelaunchLog.fine("Java classpath at launch is %s", System.getProperty("java.class.path")); + FMLRelaunchLog.fine("Java library path at launch is %s", System.getProperty("java.library.path")); + + try + { + CoreModManager.handleLaunch(minecraftHome, classLoader, tweaker); + } + catch (Throwable t) + { + t.printStackTrace(); + FMLRelaunchLog.log(Level.ERROR, t, "An error occurred trying to configure the minecraft home at %s for Forge Mod Loader", minecraftHome.getAbsolutePath()); + throw Throwables.propagate(t); + } + } + + public static Side side() + { + return side; + } + + + private void injectPostfixTransformers() + { + CoreModManager.injectTransformers(classLoader); + } + + public static void appendCoreMods() + { + INSTANCE.injectPostfixTransformers(); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/relauncher/FMLRelaunchLog.java b/src/main/java/cpw/mods/fml/relauncher/FMLRelaunchLog.java new file mode 100644 index 0000000..baf1dc9 --- /dev/null +++ b/src/main/java/cpw/mods/fml/relauncher/FMLRelaunchLog.java @@ -0,0 +1,108 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.relauncher; + +import java.io.File; +import java.util.Locale; +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.ThreadContext; + +public class FMLRelaunchLog { + + /** + * Our special logger for logging issues to. We copy various assets from the + * Minecraft logger to achieve a similar appearance. + */ + public static FMLRelaunchLog log = new FMLRelaunchLog(); + + static File minecraftHome; + private static boolean configured; + + private Logger myLog; + + static Side side; + + private FMLRelaunchLog() + { + } + + /** + * Configure the FML logger + */ + private static void configureLogging() + { + log.myLog = LogManager.getLogger("FML"); + ThreadContext.put("side", side.name().toLowerCase(Locale.ENGLISH)); + configured = true; + } + + public static void log(String targetLog, Level level, String format, Object... data) + { + LogManager.getLogger(targetLog).log(level, String.format(format, data)); + } + + public static void log(Level level, String format, Object... data) + { + if (!configured) + { + configureLogging(); + } + log.myLog.log(level, String.format(format, data)); + } + + public static void log(String targetLog, Level level, Throwable ex, String format, Object... data) + { + LogManager.getLogger(targetLog).log(level, String.format(format, data), ex); + } + + public static void log(Level level, Throwable ex, String format, Object... data) + { + if (!configured) + { + configureLogging(); + } + log.myLog.log(level, String.format(format, data), ex); + } + + public static void severe(String format, Object... data) + { + log(Level.ERROR, format, data); + } + + public static void warning(String format, Object... data) + { + log(Level.WARN, format, data); + } + + public static void info(String format, Object... data) + { + log(Level.INFO, format, data); + } + + public static void fine(String format, Object... data) + { + log(Level.DEBUG, format, data); + } + + public static void finer(String format, Object... data) + { + log(Level.TRACE, format, data); + } + + public Logger getLogger() + { + return myLog; + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/relauncher/FileListHelper.java b/src/main/java/cpw/mods/fml/relauncher/FileListHelper.java new file mode 100644 index 0000000..3cccad4 --- /dev/null +++ b/src/main/java/cpw/mods/fml/relauncher/FileListHelper.java @@ -0,0 +1,29 @@ +package cpw.mods.fml.relauncher; + +import java.io.File; +import java.io.FilenameFilter; +import java.util.Arrays; +import java.util.Comparator; + +public final class FileListHelper { + private static enum CaseInsensitiveFileComparator implements Comparator + { + INSTANCE; + @Override + public int compare(File o1, File o2) + { + return o1 != null && o2 != null ? o1.getName().compareToIgnoreCase(o2.getName()) : o1 == null ? -1 : 1; + } + + } + public static File[] sortFileList(File[] files) + { + Arrays.sort(files, CaseInsensitiveFileComparator.INSTANCE); + return files; + } + public static File[] sortFileList(File dir, FilenameFilter filter) + { + File[] files = dir.listFiles(filter); + return sortFileList(files); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/relauncher/IFMLCallHook.java b/src/main/java/cpw/mods/fml/relauncher/IFMLCallHook.java new file mode 100644 index 0000000..20cc0c3 --- /dev/null +++ b/src/main/java/cpw/mods/fml/relauncher/IFMLCallHook.java @@ -0,0 +1,34 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.relauncher; + +import java.util.Map; +import java.util.concurrent.Callable; + +/** + * This call hook allows for code to execute at the very early stages of + * minecraft initialization. FML uses it to validate that there is a + * safe environment for further loading of FML. + * + * @author cpw + * + */ +public interface IFMLCallHook extends Callable +{ + /** + * Injected with data from the FML environment: + * "classLoader" : The FML Class Loader + * @param data + */ + void injectData(Map data); +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/relauncher/IFMLLoadingPlugin.java b/src/main/java/cpw/mods/fml/relauncher/IFMLLoadingPlugin.java new file mode 100644 index 0000000..d716900 --- /dev/null +++ b/src/main/java/cpw/mods/fml/relauncher/IFMLLoadingPlugin.java @@ -0,0 +1,136 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package cpw.mods.fml.relauncher; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.util.Map; + +/** + * The base plugin that provides class name meta information to FML to + * enhance the classloading lifecycle for mods in FML + * + * @author cpw + * + */ +public interface IFMLLoadingPlugin +{ + /** + * Return a list of classes that implements the IClassTransformer interface + * @return a list of classes that implements the IClassTransformer interface + */ + String[] getASMTransformerClass(); + + /** + * Return a class name that implements "ModContainer" for injection into the mod list + * The "getName" function should return a name that other mods can, if need be, + * depend on. + * Trivially, this modcontainer will be loaded before all regular mod containers, + * which means it will be forced to be "immutable" - not susceptible to normal + * sorting behaviour. + * All other mod behaviours are available however- this container can receive and handle + * normal loading events + */ + String getModContainerClass(); + + /** + * Return the class name of an implementor of "IFMLCallHook", that will be run, in the + * main thread, to perform any additional setup this coremod may require. It will be + * run prior to Minecraft starting, so it CANNOT operate on minecraft + * itself. The game will deliberately crash if this code is detected to trigger a + * minecraft class loading (TODO: implement crash ;) ) + */ + String getSetupClass(); + + /** + * Inject coremod data into this coremod + * This data includes: + * "mcLocation" : the location of the minecraft directory, + * "coremodList" : the list of coremods + * "coremodLocation" : the file this coremod loaded from, + */ + void injectData(Map data); + + /** + * Return an optional access transformer class for this coremod. It will be injected post-deobf + * so ensure your ATs conform to the new srgnames scheme. + * @return the name of an access transformer class or null if none is provided + */ + String getAccessTransformerClass(); + + /** + * Annotate your load plugin with a list of package prefixes that will *not* be + * processed by the ASM transformation stack. + * + * Your plugin, and any transformers should *definitely* be in this list, because + * otherwise you can face problems with the classloader trying to transform classes + * with your transformer, whilst it is *loading* your transformer. Not pretty. + * + * @author cpw + * + */ + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + public @interface TransformerExclusions + { + public String[] value() default ""; + } + + /** + * Use this to target a specific minecraft version for your coremod. It will refuse to load with an error if + * minecraft is not this exact version. + * + * @author cpw + * + */ + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + public @interface MCVersion + { + public String value() default ""; + } + + /** + * Name this coremod something other than the "short class name" + * @author cpw + * + */ + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + public @interface Name + { + public String value() default ""; + } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + public @interface DependsOn + { + public String[] value() default {}; + } + + /** + * A simple sorting index, interleaved with other tweakers from other sources, as well as FML + * @author cpw + * + */ + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.TYPE) + public @interface SortingIndex + { + public int value() default 0; + } + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/relauncher/ReflectionHelper.java b/src/main/java/cpw/mods/fml/relauncher/ReflectionHelper.java new file mode 100644 index 0000000..42b1e5e --- /dev/null +++ b/src/main/java/cpw/mods/fml/relauncher/ReflectionHelper.java @@ -0,0 +1,189 @@ +/* + * The FML Forge Mod Loader suite. Copyright (C) 2012 cpw + * + * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation; either version 2.1 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +package cpw.mods.fml.relauncher; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +/** + * Some reflection helper code. + * + * @author cpw + * + */ +public class ReflectionHelper +{ + public static class UnableToFindMethodException extends RuntimeException + { + private static final long serialVersionUID = 1L; + @SuppressWarnings("unused") + private String[] methodNames; + + public UnableToFindMethodException(String[] methodNames, Exception failed) + { + super(failed); + this.methodNames = methodNames; + } + + } + + public static class UnableToFindClassException extends RuntimeException + { + private static final long serialVersionUID = 1L; + @SuppressWarnings("unused") + private String[] classNames; + + public UnableToFindClassException(String[] classNames, Exception err) + { + super(err); + this.classNames = classNames; + } + + } + + public static class UnableToAccessFieldException extends RuntimeException + { + private static final long serialVersionUID = 1L; + @SuppressWarnings("unused") + private String[] fieldNameList; + + public UnableToAccessFieldException(String[] fieldNames, Exception e) + { + super(e); + this.fieldNameList = fieldNames; + } + } + + public static class UnableToFindFieldException extends RuntimeException + { + private static final long serialVersionUID = 1L; + @SuppressWarnings("unused") + private String[] fieldNameList; + public UnableToFindFieldException(String[] fieldNameList, Exception e) + { + super(e); + this.fieldNameList = fieldNameList; + } + } + + public static Field findField(Class clazz, String... fieldNames) + { + Exception failed = null; + for (String fieldName : fieldNames) + { + try + { + Field f = clazz.getDeclaredField(fieldName); + f.setAccessible(true); + return f; + } + catch (Exception e) + { + failed = e; + } + } + throw new UnableToFindFieldException(fieldNames, failed); + } + + @SuppressWarnings("unchecked") + public static T getPrivateValue(Class classToAccess, E instance, int fieldIndex) + { + try + { + Field f = classToAccess.getDeclaredFields()[fieldIndex]; + f.setAccessible(true); + return (T) f.get(instance); + } + catch (Exception e) + { + throw new UnableToAccessFieldException(new String[0], e); + } + } + + @SuppressWarnings("unchecked") + public static T getPrivateValue(Class classToAccess, E instance, String... fieldNames) + { + try + { + return (T) findField(classToAccess, fieldNames).get(instance); + } + catch (Exception e) + { + throw new UnableToAccessFieldException(fieldNames, e); + } + } + + public static void setPrivateValue(Class classToAccess, T instance, E value, int fieldIndex) + { + try + { + Field f = classToAccess.getDeclaredFields()[fieldIndex]; + f.setAccessible(true); + f.set(instance, value); + } + catch (Exception e) + { + throw new UnableToAccessFieldException(new String[0] , e); + } + } + + public static void setPrivateValue(Class classToAccess, T instance, E value, String... fieldNames) + { + try + { + findField(classToAccess, fieldNames).set(instance, value); + } + catch (Exception e) + { + throw new UnableToAccessFieldException(fieldNames, e); + } + } + + @SuppressWarnings("unchecked") + public static Class getClass(ClassLoader loader, String... classNames) + { + Exception err = null; + for (String className : classNames) + { + try + { + return (Class) Class.forName(className, false, loader); + } + catch (Exception e) + { + err = e; + } + } + + throw new UnableToFindClassException(classNames, err); + } + + + public static Method findMethod(Class clazz, E instance, String[] methodNames, Class... methodTypes) + { + Exception failed = null; + for (String methodName : methodNames) + { + try + { + Method m = clazz.getDeclaredMethod(methodName, methodTypes); + m.setAccessible(true); + return m; + } + catch (Exception e) + { + failed = e; + } + } + throw new UnableToFindMethodException(methodNames, failed); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/relauncher/ServerLaunchWrapper.java b/src/main/java/cpw/mods/fml/relauncher/ServerLaunchWrapper.java new file mode 100644 index 0000000..ab61c63 --- /dev/null +++ b/src/main/java/cpw/mods/fml/relauncher/ServerLaunchWrapper.java @@ -0,0 +1,53 @@ +package cpw.mods.fml.relauncher; + +import java.lang.reflect.Method; + +public class ServerLaunchWrapper { + + /** + * @param args + */ + public static void main(String[] args) + { + new ServerLaunchWrapper().run(args); + } + + private ServerLaunchWrapper() + { + + } + + private void run(String[] args) + { + Class launchwrapper = null; + try + { + launchwrapper = Class.forName("net.minecraft.launchwrapper.Launch",true,getClass().getClassLoader()); + Class.forName("org.objectweb.asm.Type",true,getClass().getClassLoader()); + } + catch (Exception e) + { + System.err.printf("We appear to be missing one or more essential library files.\n" + + "You will need to add them to your server before FML and Forge will run successfully."); + e.printStackTrace(System.err); + System.exit(1); + } + + try + { + Method main = launchwrapper.getMethod("main", String[].class); + String[] allArgs = new String[args.length + 2]; + allArgs[0] = "--tweakClass"; + allArgs[1] = "cpw.mods.fml.common.launcher.FMLServerTweaker"; + System.arraycopy(args, 0, allArgs, 2, args.length); + main.invoke(null,(Object)allArgs); + } + catch (Exception e) + { + System.err.printf("A problem occurred running the Server launcher."); + e.printStackTrace(System.err); + System.exit(1); + } + } + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/relauncher/Side.java b/src/main/java/cpw/mods/fml/relauncher/Side.java new file mode 100644 index 0000000..4b2b159 --- /dev/null +++ b/src/main/java/cpw/mods/fml/relauncher/Side.java @@ -0,0 +1,17 @@ +package cpw.mods.fml.relauncher; + +public enum Side +{ + CLIENT, + SERVER; + + public boolean isServer() + { + return !this.isClient(); + } + + public boolean isClient() + { + return this == CLIENT; + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/relauncher/SideOnly.java b/src/main/java/cpw/mods/fml/relauncher/SideOnly.java new file mode 100644 index 0000000..3e21461 --- /dev/null +++ b/src/main/java/cpw/mods/fml/relauncher/SideOnly.java @@ -0,0 +1,13 @@ +package cpw.mods.fml.relauncher; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target( {ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR}) +public @interface SideOnly +{ + Side value(); +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/repackage/com/nothome/delta/ByteBufferSeekableSource.java b/src/main/java/cpw/mods/fml/repackage/com/nothome/delta/ByteBufferSeekableSource.java new file mode 100644 index 0000000..92f6c7b --- /dev/null +++ b/src/main/java/cpw/mods/fml/repackage/com/nothome/delta/ByteBufferSeekableSource.java @@ -0,0 +1,100 @@ +/* + * ByteArraySeekableSource.java + * + * Created on May 17, 2006, 12:41 PM + * Copyright (c) 2006 Heiko Klein + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + */ + +package cpw.mods.fml.repackage.com.nothome.delta; + +import java.io.IOException; +import java.nio.ByteBuffer; + +/** + * Wraps a byte buffer as a source + */ +public class ByteBufferSeekableSource implements SeekableSource { + + private ByteBuffer bb; + private ByteBuffer cur; + + /** + * Constructs a new ByteArraySeekableSource. + */ + public ByteBufferSeekableSource(byte[] source) { + this(ByteBuffer.wrap(source)); + } + + /** + * Constructs a new ByteArraySeekableSource. + */ + public ByteBufferSeekableSource(ByteBuffer bb) { + if (bb == null) + throw new NullPointerException("bb"); + this.bb = bb; + bb.rewind(); + try { + seek(0); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + @Override + public void seek(long pos) throws IOException { + cur = bb.slice(); + if (pos > cur.limit()) + throw new IOException("pos " + pos + " cannot seek " + cur.limit()); + cur.position((int) pos); + } + + @Override + public int read(ByteBuffer dest) throws IOException { + if (!cur.hasRemaining()) + return -1; + int c = 0; + while (cur.hasRemaining() && dest.hasRemaining()) { + dest.put(cur.get()); + c++; + } + return c; + } + + @Override + public void close() throws IOException { + bb = null; + cur = null; + } + + /** + * Returns a debug String. + */ + @Override + public String toString() + { + return "BBSeekable" + + " bb=" + this.bb.position() + "-" + bb.limit() + + " cur=" + this.cur.position() + "-" + cur.limit() + + ""; + } + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/repackage/com/nothome/delta/Checksum.java b/src/main/java/cpw/mods/fml/repackage/com/nothome/delta/Checksum.java new file mode 100644 index 0000000..c9beb9e --- /dev/null +++ b/src/main/java/cpw/mods/fml/repackage/com/nothome/delta/Checksum.java @@ -0,0 +1,162 @@ +/* + * + * Copyright (c) 2001 Torgeir Veimo + * Copyright (c) 2002 Nicolas PERIDONT + * Copyright (c) 2006 Heiko Klein + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +package cpw.mods.fml.repackage.com.nothome.delta; + +import java.io.IOException; +import java.nio.ByteBuffer; +import java.util.Map; + +import com.google.common.collect.Maps; + +/** + * Checksum computation class. + */ +public class Checksum { + + static final boolean debug = false; + + private Map checksums = Maps.newHashMap(); + + private static final char single_hash[] = { + /* Random numbers generated using SLIB's pseudo-random number generator. */ + 0xbcd1, 0xbb65, 0x42c2, 0xdffe, 0x9666, 0x431b, 0x8504, 0xeb46, + 0x6379, 0xd460, 0xcf14, 0x53cf, 0xdb51, 0xdb08, 0x12c8, 0xf602, + 0xe766, 0x2394, 0x250d, 0xdcbb, 0xa678, 0x02af, 0xa5c6, 0x7ea6, + 0xb645, 0xcb4d, 0xc44b, 0xe5dc, 0x9fe6, 0x5b5c, 0x35f5, 0x701a, + 0x220f, 0x6c38, 0x1a56, 0x4ca3, 0xffc6, 0xb152, 0x8d61, 0x7a58, + 0x9025, 0x8b3d, 0xbf0f, 0x95a3, 0xe5f4, 0xc127, 0x3bed, 0x320b, + 0xb7f3, 0x6054, 0x333c, 0xd383, 0x8154, 0x5242, 0x4e0d, 0x0a94, + 0x7028, 0x8689, 0x3a22, 0x0980, 0x1847, 0xb0f1, 0x9b5c, 0x4176, + 0xb858, 0xd542, 0x1f6c, 0x2497, 0x6a5a, 0x9fa9, 0x8c5a, 0x7743, + 0xa8a9, 0x9a02, 0x4918, 0x438c, 0xc388, 0x9e2b, 0x4cad, 0x01b6, + 0xab19, 0xf777, 0x365f, 0x1eb2, 0x091e, 0x7bf8, 0x7a8e, 0x5227, + 0xeab1, 0x2074, 0x4523, 0xe781, 0x01a3, 0x163d, 0x3b2e, 0x287d, + 0x5e7f, 0xa063, 0xb134, 0x8fae, 0x5e8e, 0xb7b7, 0x4548, 0x1f5a, + 0xfa56, 0x7a24, 0x900f, 0x42dc, 0xcc69, 0x02a0, 0x0b22, 0xdb31, + 0x71fe, 0x0c7d, 0x1732, 0x1159, 0xcb09, 0xe1d2, 0x1351, 0x52e9, + 0xf536, 0x5a4f, 0xc316, 0x6bf9, 0x8994, 0xb774, 0x5f3e, 0xf6d6, + 0x3a61, 0xf82c, 0xcc22, 0x9d06, 0x299c, 0x09e5, 0x1eec, 0x514f, + 0x8d53, 0xa650, 0x5c6e, 0xc577, 0x7958, 0x71ac, 0x8916, 0x9b4f, + 0x2c09, 0x5211, 0xf6d8, 0xcaaa, 0xf7ef, 0x287f, 0x7a94, 0xab49, + 0xfa2c, 0x7222, 0xe457, 0xd71a, 0x00c3, 0x1a76, 0xe98c, 0xc037, + 0x8208, 0x5c2d, 0xdfda, 0xe5f5, 0x0b45, 0x15ce, 0x8a7e, 0xfcad, + 0xaa2d, 0x4b5c, 0xd42e, 0xb251, 0x907e, 0x9a47, 0xc9a6, 0xd93f, + 0x085e, 0x35ce, 0xa153, 0x7e7b, 0x9f0b, 0x25aa, 0x5d9f, 0xc04d, + 0x8a0e, 0x2875, 0x4a1c, 0x295f, 0x1393, 0xf760, 0x9178, 0x0f5b, + 0xfa7d, 0x83b4, 0x2082, 0x721d, 0x6462, 0x0368, 0x67e2, 0x8624, + 0x194d, 0x22f6, 0x78fb, 0x6791, 0xb238, 0xb332, 0x7276, 0xf272, + 0x47ec, 0x4504, 0xa961, 0x9fc8, 0x3fdc, 0xb413, 0x007a, 0x0806, + 0x7458, 0x95c6, 0xccaa, 0x18d6, 0xe2ae, 0x1b06, 0xf3f6, 0x5050, + 0xc8e8, 0xf4ac, 0xc04c, 0xf41c, 0x992f, 0xae44, 0x5f1b, 0x1113, + 0x1738, 0xd9a8, 0x19ea, 0x2d33, 0x9698, 0x2fe9, 0x323f, 0xcde2, + 0x6d71, 0xe37d, 0xb697, 0x2c4f, 0x4373, 0x9102, 0x075d, 0x8e25, + 0x1672, 0xec28, 0x6acb, 0x86cc, 0x186e, 0x9414, 0xd674, 0xd1a5 + }; + + /** + * Initialize checksums for source. The checksum for the chunkSize bytes at offset + * chunkSize * i is inserted into a hash map. + */ + public Checksum(SeekableSource source, int chunkSize) throws IOException { + ByteBuffer bb = ByteBuffer.allocate(chunkSize * 2); + int count = 0; + while (true) { + source.read(bb); + bb.flip(); + if (bb.remaining() < chunkSize) + break; + while (bb.remaining() >= chunkSize) { + long queryChecksum = queryChecksum0(bb, chunkSize); + checksums.put(queryChecksum, count++); + } + bb.compact(); + } + } + + /** + * Finds the checksum computed from the buffer. + * Marks, gets, then resets the buffer. + */ + public static long queryChecksum(ByteBuffer bb, int len) { + bb.mark(); + long sum = queryChecksum0(bb, len); + bb.reset(); + return sum; + } + + private static long queryChecksum0(ByteBuffer bb, int len) { + int high = 0; int low = 0; + for (int i = 0; i < len; i++) { + low += single_hash[bb.get()+128]; + high += low; + } + return ((high & 0xffff) << 16) | (low & 0xffff); + } + + /** + * Increments a checksum. + * @param checksum initial checksum + * @param out byte leaving view + * @param in byte entering view + * @param chunkSize size of chunks + * @return new checksum + */ + public static long incrementChecksum(long checksum, byte out, byte in, int chunkSize) { + char old_c = single_hash[out+128]; + char new_c = single_hash[in+128]; + int low = ((int)((checksum) & 0xffff) - old_c + new_c) & 0xffff; + int high = ((int)((checksum) >> 16) - (old_c * chunkSize) + low) & 0xffff; + return (high << 16) | (low & 0xffff); + } + + /** + * 256 random hash values. + */ + public static char[] getSingleHash() { + return single_hash; + } + + /** + * Finds the index of a checksum. + */ + public int findChecksumIndex(long hashf) { + if (!checksums.containsKey(hashf)) + return -1; + return checksums.get(hashf); + } + + /** + * Returns a debug String. + */ + @Override + public String toString() + { + return super.toString() + + " checksums=" + this.checksums; + } + + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/repackage/com/nothome/delta/DebugDiffWriter.java b/src/main/java/cpw/mods/fml/repackage/com/nothome/delta/DebugDiffWriter.java new file mode 100644 index 0000000..f22b949 --- /dev/null +++ b/src/main/java/cpw/mods/fml/repackage/com/nothome/delta/DebugDiffWriter.java @@ -0,0 +1,78 @@ +/* + * + * Copyright (c) 2001 Torgeir Veimo + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + */ + +package cpw.mods.fml.repackage.com.nothome.delta; + + +import java.io.ByteArrayOutputStream; +import java.io.IOException; + +/** + * For debugging patch generation. + */ +public class DebugDiffWriter implements DiffWriter { + + private ByteArrayOutputStream os = new ByteArrayOutputStream(); + + /** + * Constructs a new DebugDiffWriter. + */ + public DebugDiffWriter() {} + + @Override + public void addCopy(long offset, int length) throws IOException { + if (os.size() > 0) + writeBuf(); + System.err.println("COPY off: " + offset + ", len: " + length); + } + + @Override + public void addData(byte b) throws IOException { + os.write(b); + writeBuf(); + } + private void writeBuf() { + System.err.print("DATA: "); + byte[] ba = os.toByteArray(); + for (int ix = 0; ix < ba.length; ix++) { + if (ba[ix] == '\n') + System.err.print("\\n"); + else + System.err.print(String.valueOf((char)((char) ba[ix]))); + //System.err.print("0x" + Integer.toHexString(buf[ix]) + " "); // hex output + } + System.err.println(""); + os.reset(); + } + + @Override + public void flush() throws IOException { + System.err.println("FLUSH"); + } + @Override + public void close() throws IOException { + System.err.println("CLOSE"); + } + +} diff --git a/src/main/java/cpw/mods/fml/repackage/com/nothome/delta/Delta.java b/src/main/java/cpw/mods/fml/repackage/com/nothome/delta/Delta.java new file mode 100644 index 0000000..be43429 --- /dev/null +++ b/src/main/java/cpw/mods/fml/repackage/com/nothome/delta/Delta.java @@ -0,0 +1,447 @@ + /* + * + * Copyright (c) 2001 Torgeir Veimo + * Copyright (c) 2002 Nicolas PERIDONT + * Bug Fixes: Daniel Morrione dan@morrione.net + * Copyright (c) 2006 Heiko Klein + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + * Change Log: + * iiimmddyyn nnnnn Description + * ---------- ----- ------------------------------------------------------- + * gls100603a Fixes from Torgeir Veimo and Dan Morrione + * gls110603a Stream not being closed thus preventing a file from + * being subsequently deleted. + * gls031504a Error being written to stderr rather than throwing exception + */ + +package cpw.mods.fml.repackage.com.nothome.delta; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.RandomAccessFile; +import java.nio.ByteBuffer; +import java.nio.channels.Channels; +import java.nio.channels.ReadableByteChannel; + +/** + * Class for computing deltas against a source. + * The source file is read by blocks and a hash is computed per block. + * Then the target is scanned for matching blocks. + *

+ * This class is not thread safe. Use one instance per thread. + *

+ * This class should support files over 4GB in length, although you must + * use a larger checksum size, such as 1K, as all checksums use "int" indexing. + * Newer versions may eventually support paging in/out of checksums. + */ +public class Delta { + + /** + * Debug flag. + */ + final static boolean debug = false; + + /** + * Default size of 16. + * For "Lorem ipsum" text files (see the tests) the ideal size is about 14. + * Any smaller and the patch size becomes actually be larger. + *

+ * Use a size like 64 or 128 for large files. + */ + public static final int DEFAULT_CHUNK_SIZE = 1<<4; + + /** + * Chunk Size. + */ + private int S; + + private SourceState source; + private TargetState target; + private DiffWriter output; + + /** + * Constructs a new Delta. + * In the future, additional constructor arguments will set the algorithm details. + */ + public Delta() { + setChunkSize(DEFAULT_CHUNK_SIZE); + } + + /** + * Sets the chunk size used. + * Larger chunks are faster and use less memory, but create larger patches + * as well. + * + * @param size + */ + public void setChunkSize(int size) { + if (size <= 0) + throw new IllegalArgumentException("Invalid size"); + S = size; + } + + /** + * Compares the source bytes with target bytes, writing to output. + */ + public void compute(byte source[], byte target[], OutputStream output) + throws IOException { + compute(new ByteBufferSeekableSource(source), + new ByteArrayInputStream(target), + new GDiffWriter(output)); + } + + /** + * Compares the source bytes with target bytes, returning output. + */ + public byte[] compute(byte source[], byte target[]) + throws IOException { + ByteArrayOutputStream os = new ByteArrayOutputStream(); + compute(source, target, os); + return os.toByteArray(); + } + + /** + * Compares the source bytes with target input, writing to output. + */ + public void compute(byte[] sourceBytes, InputStream inputStream, + DiffWriter diffWriter) throws IOException + { + compute(new ByteBufferSeekableSource(sourceBytes), + inputStream, diffWriter); + } + + /** + * Compares the source file with a target file, writing to output. + * + * @param output will be closed + */ + public void compute(File sourceFile, File targetFile, DiffWriter output) + throws IOException { + RandomAccessFileSeekableSource source = new RandomAccessFileSeekableSource(new RandomAccessFile(sourceFile, "r")); + InputStream is = new BufferedInputStream(new FileInputStream(targetFile)); + try { + compute(source, is, output); + } finally { + source.close(); + is.close(); + } + } + + /** + * Compares the source with a target, writing to output. + * + * @param output will be closed + */ + public void compute(SeekableSource seekSource, InputStream targetIS, DiffWriter output) + throws IOException { + + if (debug) { + debug("using match length S = " + S); + } + + source = new SourceState(seekSource); + target = new TargetState(targetIS); + this.output = output; + if (debug) + debug("checksums " + source.checksum); + + while (!target.eof()) { + debug("!target.eof()"); + int index = target.find(source); + if (index != -1) { + if (debug) + debug("found hash " + index); + long offset = (long)index * S; + source.seek(offset); + int match = target.longestMatch(source); + if (match >= S) { + if (debug) + debug("output.addCopy("+offset+","+match+")"); + output.addCopy(offset, match); + } else { + // move the position back according to how much we can't copy + target.tbuf.position(target.tbuf.position() - match); + addData(); + } + } else { + addData(); + } + } + output.close(); + } + + private void addData() throws IOException { + int i = target.read(); + if (debug) + debug("addData " + Integer.toHexString(i)); + if (i == -1) + return; + output.addData((byte)i); + } + + class SourceState { + + private Checksum checksum; + private SeekableSource source; + + public SourceState(SeekableSource source) throws IOException { + checksum = new Checksum(source, S); + this.source = source; + source.seek(0); + } + + public void seek(long index) throws IOException { + source.seek(index); + } + + /** + * Returns a debug String. + */ + @Override + public String toString() + { + return "Source"+ + " checksum=" + this.checksum + + " source=" + this.source + + ""; + } + + } + + class TargetState { + + private ReadableByteChannel c; + private ByteBuffer tbuf = ByteBuffer.allocate(blocksize()); + private ByteBuffer sbuf = ByteBuffer.allocate(blocksize()); + private long hash; + private boolean hashReset = true; + private boolean eof; + + TargetState(InputStream targetIS) throws IOException { + c = Channels.newChannel(targetIS); + tbuf.limit(0); + } + + private int blocksize() { + return Math.min(1024 * 16, S * 4); + } + + /** + * Returns the index of the next N bytes of the stream. + */ + public int find(SourceState source) throws IOException { + if (eof) + return -1; + sbuf.clear(); + sbuf.limit(0); + if (hashReset) { + debug("hashReset"); + while (tbuf.remaining() < S) { + tbuf.compact(); + int read = c.read(tbuf); + tbuf.flip(); + if (read == -1) { + debug("target ending"); + return -1; + } + } + hash = Checksum.queryChecksum(tbuf, S); + hashReset = false; + } + if (debug) + debug("hash " + hash + " " + dump()); + return source.checksum.findChecksumIndex(hash); + } + + public boolean eof() { + return eof; + } + + /** + * Reads a byte. + * @throws IOException + */ + public int read() throws IOException { + if (tbuf.remaining() <= S) { + readMore(); + if (!tbuf.hasRemaining()) { + eof = true; + return -1; + } + } + byte b = tbuf.get(); + if (tbuf.remaining() >= S) { + byte nchar = tbuf.get( tbuf.position() + S -1 ); + hash = Checksum.incrementChecksum(hash, b, nchar, S); + } else { + debug("out of char"); + } + return b & 0xFF; + } + + /** + * Returns the longest match length at the source location. + */ + public int longestMatch(SourceState source) throws IOException { + debug("longestMatch"); + int match = 0; + hashReset = true; + while (true) { + if (!sbuf.hasRemaining()) { + sbuf.clear(); + int read = source.source.read(sbuf); + sbuf.flip(); + if (read == -1) + return match; + } + if (!tbuf.hasRemaining()) { + readMore(); + if (!tbuf.hasRemaining()) { + debug("target ending"); + eof = true; + return match; + } + } + if (sbuf.get() != tbuf.get()) { + tbuf.position(tbuf.position() - 1); + return match; + } + match++; + } + } + + private void readMore() throws IOException { + if (debug) + debug("readMore " + tbuf); + tbuf.compact(); + c.read(tbuf); + tbuf.flip(); + } + + void hash() { + hash = Checksum.queryChecksum(tbuf, S); + } + + /** + * Returns a debug String. + */ + @Override + public String toString() + { + return "Target[" + + " targetBuff=" + dump() + // this.tbuf + + " sourceBuff=" + this.sbuf + + " hashf=" + this.hash + + " eof=" + this.eof + + "]"; + } + + private String dump() { return dump(tbuf); } + + private String dump(ByteBuffer bb) { + return getTextDump(bb); + } + + private void append(StringBuffer sb, int value) { + char b1 = (char)((value >> 4) & 0x0F); + char b2 = (char)((value) & 0x0F); + sb.append( Character.forDigit(b1, 16) ); + sb.append( Character.forDigit(b2, 16) ); + } + + public String getTextDump(ByteBuffer bb) + { + StringBuffer sb = new StringBuffer(bb.remaining() * 2); + bb.mark(); + while (bb.hasRemaining()) { + int val = bb.get(); + if (val > 32 && val < 127) + sb.append(" ").append((char)val); + else + append(sb, val); + } + bb.reset(); + return sb.toString(); + } + + } + + /** + * Creates a patch using file names. + */ + public static void main(String argv[]) throws Exception { + if (argv.length != 3) { + System.err.println("usage Delta [-d] source target [output]"); + System.err.println("either -d or an output filename must be specified."); + System.err.println("aborting.."); + return; + } + DiffWriter output = null; + File sourceFile = null; + File targetFile = null; + if (argv[0].equals("-d")) { + sourceFile = new File(argv[1]); + targetFile = new File(argv[2]); + output = new DebugDiffWriter(); + } else { + sourceFile = new File(argv[0]); + targetFile = new File(argv[1]); + output = + new GDiffWriter( + new DataOutputStream( + new BufferedOutputStream( + new FileOutputStream(new File(argv[2]))))); + } + + if (sourceFile.length() > Integer.MAX_VALUE + || targetFile.length() > Integer.MAX_VALUE) { + System.err.println( + "source or target is too large, max length is " + + Integer.MAX_VALUE); + System.err.println("aborting.."); + output.close(); + return; + } + + Delta d = new Delta(); + d.compute(sourceFile, targetFile, output); + + output.flush(); + output.close(); + if (debug) //gls031504a + System.out.println("finished generating delta"); + } + + private void debug(String s) { + if (debug) + System.err.println(s); + } + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/repackage/com/nothome/delta/DiffWriter.java b/src/main/java/cpw/mods/fml/repackage/com/nothome/delta/DiffWriter.java new file mode 100644 index 0000000..c37889b --- /dev/null +++ b/src/main/java/cpw/mods/fml/repackage/com/nothome/delta/DiffWriter.java @@ -0,0 +1,57 @@ +/* + * + * Copyright (c) 2001 Torgeir Veimo + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + */ + +package cpw.mods.fml.repackage.com.nothome.delta; + +import java.io.Closeable; +import java.io.IOException; + +/** + * Interface for DIFF writers. + */ +public interface DiffWriter extends Closeable { + + /** + * Add a GDIFF copy instruction. + */ + public void addCopy(long offset, int length) throws IOException; + + /** + * Add a GDIFF data instruction. + * Implementors should buffer the data. + */ + public void addData(byte b) throws IOException; + + /** + * Flushes to output, e.g. any data added. + */ + public void flush() throws IOException; + + /** + * Closes this stream. + * Note that {@link DiffWriter} will invoke this method at the end. + */ + @Override + public void close() throws IOException; +} diff --git a/src/main/java/cpw/mods/fml/repackage/com/nothome/delta/GDiffPatcher.java b/src/main/java/cpw/mods/fml/repackage/com/nothome/delta/GDiffPatcher.java new file mode 100644 index 0000000..83cf60b --- /dev/null +++ b/src/main/java/cpw/mods/fml/repackage/com/nothome/delta/GDiffPatcher.java @@ -0,0 +1,245 @@ +/* + * + * Copyright (c) 2001 Torgeir Veimo + * Copyright (c) 2006 Heiko Klein + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + */ + +package cpw.mods.fml.repackage.com.nothome.delta; + +import static cpw.mods.fml.repackage.com.nothome.delta.GDiffWriter.COPY_INT_INT; +import static cpw.mods.fml.repackage.com.nothome.delta.GDiffWriter.COPY_INT_UBYTE; +import static cpw.mods.fml.repackage.com.nothome.delta.GDiffWriter.COPY_INT_USHORT; +import static cpw.mods.fml.repackage.com.nothome.delta.GDiffWriter.COPY_LONG_INT; +import static cpw.mods.fml.repackage.com.nothome.delta.GDiffWriter.COPY_USHORT_INT; +import static cpw.mods.fml.repackage.com.nothome.delta.GDiffWriter.COPY_USHORT_UBYTE; +import static cpw.mods.fml.repackage.com.nothome.delta.GDiffWriter.COPY_USHORT_USHORT; +import static cpw.mods.fml.repackage.com.nothome.delta.GDiffWriter.DATA_INT; +import static cpw.mods.fml.repackage.com.nothome.delta.GDiffWriter.DATA_MAX; +import static cpw.mods.fml.repackage.com.nothome.delta.GDiffWriter.DATA_USHORT; +import static cpw.mods.fml.repackage.com.nothome.delta.GDiffWriter.EOF; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.EOFException; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.RandomAccessFile; +import java.nio.ByteBuffer; + +/** + * This class patches an input file with a GDIFF patch file. + * + * The patch file follows the GDIFF file specification available at + * + * http://www.w3.org/TR/NOTE-gdiff-19970901.html. + */ +public class GDiffPatcher { + + private ByteBuffer buf = ByteBuffer.allocate(1024); + private byte buf2[] = buf.array(); + + /** + * Constructs a new GDiffPatcher. + */ + public GDiffPatcher() { + } + + /** + * Patches to an output file. + */ + public void patch(File sourceFile, File patchFile, File outputFile) + throws IOException + { + RandomAccessFileSeekableSource source =new RandomAccessFileSeekableSource(new RandomAccessFile(sourceFile, "r")); + InputStream patch = new FileInputStream(patchFile); + OutputStream output = new FileOutputStream(outputFile); + try { + patch(source, patch, output); + } catch (IOException e) { + throw e; + } finally { + source.close(); + patch.close(); + output.close(); + } + } + + /** + * Patches to an output stream. + */ + public void patch(byte[] source, InputStream patch, OutputStream output) throws IOException { + patch(new ByteBufferSeekableSource(source), patch, output); + } + + /** + * Patches in memory, returning the patch result. + */ + public byte[] patch(byte[] source, byte[] patch) throws IOException { + ByteArrayOutputStream os = new ByteArrayOutputStream(); + patch(source, new ByteArrayInputStream(patch), os); + return os.toByteArray(); + } + + /** + * Patches to an output stream. + */ + public void patch(SeekableSource source, InputStream patch, OutputStream out) throws IOException { + + DataOutputStream outOS = new DataOutputStream(out); + DataInputStream patchIS = new DataInputStream(patch); + + // the magic string is 'd1 ff d1 ff' + the version number + if (patchIS.readUnsignedByte() != 0xd1 || + patchIS.readUnsignedByte() != 0xff || + patchIS.readUnsignedByte() != 0xd1 || + patchIS.readUnsignedByte() != 0xff || + patchIS.readUnsignedByte() != 0x04) { + + throw new PatchException("magic string not found, aborting!"); + } + + while (true) { + int command = patchIS.readUnsignedByte(); + if (command == EOF) + break; + int length; + int offset; + + if (command <= DATA_MAX) { + append(command, patchIS, outOS); + continue; + } + + switch (command) { + case DATA_USHORT: // ushort, n bytes following; append + length = patchIS.readUnsignedShort(); + append(length, patchIS, outOS); + break; + case DATA_INT: // int, n bytes following; append + length = patchIS.readInt(); + append(length, patchIS, outOS); + break; + case COPY_USHORT_UBYTE: + offset = patchIS.readUnsignedShort(); + length = patchIS.readUnsignedByte(); + copy(offset, length, source, outOS); + break; + case COPY_USHORT_USHORT: + offset = patchIS.readUnsignedShort(); + length = patchIS.readUnsignedShort(); + copy(offset, length, source, outOS); + break; + case COPY_USHORT_INT: + offset = patchIS.readUnsignedShort(); + length = patchIS.readInt(); + copy(offset, length, source, outOS); + break; + case COPY_INT_UBYTE: + offset = patchIS.readInt(); + length = patchIS.readUnsignedByte(); + copy(offset, length, source, outOS); + break; + case COPY_INT_USHORT: + offset = patchIS.readInt(); + length = patchIS.readUnsignedShort(); + copy(offset, length, source, outOS); + break; + case COPY_INT_INT: + offset = patchIS.readInt(); + length = patchIS.readInt(); + copy(offset, length, source, outOS); + break; + case COPY_LONG_INT: + long loffset = patchIS.readLong(); + length = patchIS.readInt(); + copy(loffset, length, source, outOS); + break; + default: + throw new IllegalStateException("command " + command); + } + } + outOS.flush(); + } + + private void copy(long offset, int length, SeekableSource source, OutputStream output) + throws IOException + { + source.seek(offset); + while (length > 0) { + int len = Math.min(buf.capacity(), length); + buf.clear().limit(len); + int res = source.read(buf); + if (res == -1) + throw new EOFException("in copy " + offset + " " + length); + output.write(buf.array(), 0, res); + length -= res; + } + } + + private void append(int length, InputStream patch, OutputStream output) throws IOException { + while (length > 0) { + int len = Math.min(buf2.length, length); + int res = patch.read(buf2, 0, len); + if (res == -1) + throw new EOFException("cannot read " + length); + output.write(buf2, 0, res); + length -= res; + } + } + + /** + * Simple command line tool to patch a file. + */ + public static void main(String argv[]) { + + if (argv.length != 3) { + System.err.println("usage GDiffPatch source patch output"); + System.err.println("aborting.."); + return; + } + try { + File sourceFile = new File(argv[0]); + File patchFile = new File(argv[1]); + File outputFile = new File(argv[2]); + + if (sourceFile.length() > Integer.MAX_VALUE || + patchFile.length() > Integer.MAX_VALUE) { + System.err.println("source or patch is too large, max length is " + Integer.MAX_VALUE); + System.err.println("aborting.."); + return; + } + GDiffPatcher patcher = new GDiffPatcher(); + patcher.patch(sourceFile, patchFile, outputFile); + + System.out.println("finished patching file"); + + } catch (Exception ioe) { //gls031504a + System.err.println("error while patching: " + ioe); + } + } +} diff --git a/src/main/java/cpw/mods/fml/repackage/com/nothome/delta/GDiffWriter.java b/src/main/java/cpw/mods/fml/repackage/com/nothome/delta/GDiffWriter.java new file mode 100644 index 0000000..4bdad16 --- /dev/null +++ b/src/main/java/cpw/mods/fml/repackage/com/nothome/delta/GDiffWriter.java @@ -0,0 +1,177 @@ +/* + * + * Copyright (c) 2001 Torgeir Veimo + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + */ + +package cpw.mods.fml.repackage.com.nothome.delta; + +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +/** + * Outputs a diff following the GDIFF file specification available at + * http://www.w3.org/TR/NOTE-gdiff-19970901.html. + */ +public class GDiffWriter implements DiffWriter { + + /** + * Max length of a chunk. + */ + public static final int CHUNK_SIZE = Short.MAX_VALUE; + + public static final byte EOF = 0; + + /** + * Max length for single length data encode. + */ + public static final int DATA_MAX = 246; + + public static final int DATA_USHORT = 247; + public static final int DATA_INT = 248; + public static final int COPY_USHORT_UBYTE = 249; + public static final int COPY_USHORT_USHORT = 250; + public static final int COPY_USHORT_INT = 251; + public static final int COPY_INT_UBYTE = 252; + public static final int COPY_INT_USHORT = 253; + public static final int COPY_INT_INT = 254; + public static final int COPY_LONG_INT = 255; + + private ByteArrayOutputStream buf = new ByteArrayOutputStream(); + + private boolean debug = false; + + private DataOutputStream output = null; + + /** + * Constructs a new GDiffWriter. + */ + public GDiffWriter(DataOutputStream os) throws IOException { + this.output = os; + // write magic string "d1 ff d1 ff 04" + output.writeByte(0xd1); + output.writeByte(0xff); + output.writeByte(0xd1); + output.writeByte(0xff); + output.writeByte(0x04); + } + + /** + * Constructs a new GDiffWriter. + */ + public GDiffWriter(OutputStream output) throws IOException { + this(new DataOutputStream(output)); + } + + @Override + public void addCopy(long offset, int length) throws IOException { + writeBuf(); + + //output debug data + if (debug) + System.err.println("COPY off: " + offset + ", len: " + length); + + // output real data + if (offset > Integer.MAX_VALUE) { + // Actually, we don't support longer files than int.MAX_VALUE at the moment.. + output.writeByte(COPY_LONG_INT); + output.writeLong(offset); + output.writeInt(length); + } else if (offset < 65536) { + if (length < 256) { + output.writeByte(COPY_USHORT_UBYTE); + output.writeShort((int)offset); + output.writeByte(length); + } else if (length > 65535) { + output.writeByte(COPY_USHORT_INT); + output.writeShort((int)offset); + output.writeInt(length); + } else { + output.writeByte(COPY_USHORT_USHORT); + output.writeShort((int)offset); + output.writeShort(length); + } + } else { + if (length < 256) { + output.writeByte(COPY_INT_UBYTE); + output.writeInt((int)offset); + output.writeByte(length); + } else if (length > 65535) { + output.writeByte(COPY_INT_INT); + output.writeInt((int)offset); + output.writeInt(length); + } else { + output.writeByte(COPY_INT_USHORT); + output.writeInt((int)offset); + output.writeShort(length); + } + } + } + + /** + * Adds a data byte. + */ + @Override + public void addData(byte b) throws IOException { + buf.write(b); + if (buf.size() >= CHUNK_SIZE) + writeBuf(); + } + + private void writeBuf() throws IOException { + if (buf.size() > 0) { + if (buf.size() <= DATA_MAX) { + output.writeByte(buf.size()); + } else if (buf.size() <= 65535) { + output.writeByte(DATA_USHORT); + output.writeShort(buf.size()); + } else { + output.writeByte(DATA_INT); + output.writeInt(buf.size()); + } + buf.writeTo(output); + buf.reset(); + } + } + + /** + * Flushes accumulated data bytes, if any. + */ + @Override + public void flush() throws IOException + { + writeBuf(); + output.flush(); + } + + /** + * Writes the final EOF byte, closes the underlying stream. + */ + @Override + public void close() throws IOException { + this.flush(); + output.write((byte)EOF); + output.close(); + } + +} diff --git a/src/main/java/cpw/mods/fml/repackage/com/nothome/delta/PatchException.java b/src/main/java/cpw/mods/fml/repackage/com/nothome/delta/PatchException.java new file mode 100644 index 0000000..fe89b7f --- /dev/null +++ b/src/main/java/cpw/mods/fml/repackage/com/nothome/delta/PatchException.java @@ -0,0 +1,51 @@ +/* + * PatchException.java + * + * Created on June 6, 2006, 9:34 PM + * Copyright (c) 2006 Heiko Klein + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + */ + +package cpw.mods.fml.repackage.com.nothome.delta; + +import java.io.IOException; + +/** + * Thrown when a patch is invalid. + */ +public class PatchException extends IOException { + + private static final long serialVersionUID = 1; + + /** + * Creates a new instance of PatchException without detail message. + */ + public PatchException() { + } + + /** + * Constructs an instance of PatchException with the specified detail message. + * @param msg the detail message. + */ + public PatchException(String msg) { + super(msg); + } +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/repackage/com/nothome/delta/RandomAccessFileSeekableSource.java b/src/main/java/cpw/mods/fml/repackage/com/nothome/delta/RandomAccessFileSeekableSource.java new file mode 100644 index 0000000..9234b2b --- /dev/null +++ b/src/main/java/cpw/mods/fml/repackage/com/nothome/delta/RandomAccessFileSeekableSource.java @@ -0,0 +1,78 @@ +/* + * RandomAccessFileSeekableSource.java + * + * Created on May 17, 2006, 1:45 PM + * Copyright (c) 2006 Heiko Klein + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + * + */ + +package cpw.mods.fml.repackage.com.nothome.delta; + +import java.io.IOException; +import java.io.RandomAccessFile; +import java.nio.ByteBuffer; + +/** + * Wraps a random access file. + */ +public class RandomAccessFileSeekableSource implements SeekableSource { + + private RandomAccessFile raf; + + /** + * Constructs a new RandomAccessFileSeekableSource. + * @param raf + */ + public RandomAccessFileSeekableSource(RandomAccessFile raf) { + if (raf == null) + throw new NullPointerException("raf"); + this.raf = raf; + } + + @Override + public void seek(long pos) throws IOException { + raf.seek(pos); + } + + public int read(byte[] b, int off, int len) throws IOException { + return raf.read(b, off, len); + } + + public long length() throws IOException { + return raf.length(); + } + + @Override + public void close() throws IOException { + raf.close(); + } + + @Override + public int read(ByteBuffer bb) throws IOException { + int c = raf.read(bb.array(), bb.position(), bb.remaining()); + if (c == -1) + return -1; + bb.position(bb.position() + c); + return c; + } + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/repackage/com/nothome/delta/SeekableSource.java b/src/main/java/cpw/mods/fml/repackage/com/nothome/delta/SeekableSource.java new file mode 100644 index 0000000..48a3c20 --- /dev/null +++ b/src/main/java/cpw/mods/fml/repackage/com/nothome/delta/SeekableSource.java @@ -0,0 +1,51 @@ +/* + * SeekableSource.java + * + * Created on May 17, 2006, 12:33 PM + * Copyright (c) 2006 Heiko Klein + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + */ + +package cpw.mods.fml.repackage.com.nothome.delta; + +import java.io.Closeable; +import java.io.IOException; +import java.io.RandomAccessFile; +import java.nio.ByteBuffer; + +/** + * For sources of random-access data, such as {@link RandomAccessFile}. + */ +public interface SeekableSource extends Closeable { + + /** + * Sets the position for the next {@link #read(ByteBuffer)}. + */ + void seek(long pos) throws IOException ; + + /** + * Reads up to {@link ByteBuffer#remaining()} bytes from the source, + * returning the number of bytes read, or -1 if no bytes were read + * and EOF was reached. + */ + int read(ByteBuffer bb) throws IOException; + +} \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/server/FMLServerHandler.java b/src/main/java/cpw/mods/fml/server/FMLServerHandler.java new file mode 100644 index 0000000..f541c5a --- /dev/null +++ b/src/main/java/cpw/mods/fml/server/FMLServerHandler.java @@ -0,0 +1,265 @@ +/* + * The FML Forge Mod Loader suite. Copyright (C) 2012 cpw + * + * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation; either version 2.1 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +package cpw.mods.fml.server; + +import java.io.File; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import net.minecraft.command.ServerCommand; +import net.minecraft.network.INetHandler; +import net.minecraft.network.NetHandlerPlayServer; +import net.minecraft.network.NetworkManager; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.dedicated.DedicatedServer; +import net.minecraft.world.storage.SaveFormatOld; + +import com.google.common.collect.ImmutableList; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.IFMLSidedHandler; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.ModContainer; +import cpw.mods.fml.common.StartupQuery; +import cpw.mods.fml.common.eventhandler.EventBus; +import cpw.mods.fml.common.network.FMLNetworkEvent; +import cpw.mods.fml.common.registry.LanguageRegistry; +import cpw.mods.fml.relauncher.Side; + +/** + * Handles primary communication from hooked code into the system + * + * The FML entry point is {@link #beginServerLoading(MinecraftServer)} called from + * {@link net.minecraft.server.dedicated.DedicatedServer} + * + * Obfuscated code should focus on this class and other members of the "server" + * (or "client") code + * + * The actual mod loading is handled at arms length by {@link Loader} + * + * It is expected that a similar class will exist for each target environment: + * Bukkit and Client side. + * + * It should not be directly modified. + * + * @author cpw + * + */ +public class FMLServerHandler implements IFMLSidedHandler +{ + /** + * The singleton + */ + private static final FMLServerHandler INSTANCE = new FMLServerHandler(); + + /** + * A reference to the server itself + */ + private MinecraftServer server; + + private FMLServerHandler() + { + FMLCommonHandler.instance().beginLoading(this); + } + /** + * Called to start the whole game off from + * {@link MinecraftServer#startServer} + * + * @param minecraftServer + */ + @Override + public void beginServerLoading(MinecraftServer minecraftServer) + { + server = minecraftServer; + Loader.instance().loadMods(); + } + + /** + * Called a bit later on during server initialization to finish loading mods + */ + @Override + public void finishServerLoading() + { + Loader.instance().initializeMods(); + } + + @Override + public void haltGame(String message, Throwable exception) + { + throw new RuntimeException(message, exception); + } + + @Override + public File getSavesDirectory() + { + return ((SaveFormatOld) server.getActiveAnvilConverter()).savesDirectory; + } + + /** + * Get the server instance + */ + @Override + public MinecraftServer getServer() + { + return server; + } + + /** + * @return the instance + */ + public static FMLServerHandler instance() + { + return INSTANCE; + } + + /* (non-Javadoc) + * @see cpw.mods.fml.common.IFMLSidedHandler#getAdditionalBrandingInformation() + */ + @Override + public List getAdditionalBrandingInformation() + { + return ImmutableList.of(); + } + + /* (non-Javadoc) + * @see cpw.mods.fml.common.IFMLSidedHandler#getSide() + */ + @Override + public Side getSide() + { + return Side.SERVER; + } + + @Override + public void showGuiScreen(Object clientGuiElement) + { + + } + + @Override + public void queryUser(StartupQuery query) throws InterruptedException + { + if (query.getResult() == null) + { + FMLLog.warning("%s", query.getText()); + query.finish(); + } + else + { + String text = query.getText() + + "\n\nRun the command /fml confirm or or /fml cancel to proceed." + + "\nAlternatively start the server with -Dfml.queryResult=confirm or -Dfml.queryResult=cancel to preselect the answer."; + FMLLog.warning("%s", text); + + if (!query.isSynchronous()) return; // no-op until mc does commands in another thread (if ever) + + boolean done = false; + + while (!done && server.isServerRunning()) + { + if (Thread.interrupted()) throw new InterruptedException(); + + DedicatedServer dedServer = (DedicatedServer) server; + + // rudimentary command processing, check for fml confirm/cancel and stop commands + synchronized (dedServer.pendingCommandList) + { + for (Iterator it = dedServer.pendingCommandList.iterator(); it.hasNext(); ) + { + String cmd = it.next().command.trim().toLowerCase(); + + if (cmd.equals("/fml confirm")) + { + FMLLog.info("confirmed"); + query.setResult(true); + done = true; + it.remove(); + } + else if (cmd.equals("/fml cancel")) + { + FMLLog.info("cancelled"); + query.setResult(false); + done = true; + it.remove(); + } + else if (cmd.equals("/stop")) + { + StartupQuery.abort(); + } + } + } + + Thread.sleep(10L); + } + + query.finish(); + } + } + + @Override + public boolean shouldServerShouldBeKilledQuietly() + { + return false; + } + @Override + public void addModAsResource(ModContainer container) + { + LanguageRegistry.instance().loadLanguagesFor(container, Side.SERVER); + } + + @Override + public void updateResourcePackList() + { + + } + @Override + public String getCurrentLanguage() + { + return "en_US"; + } + + @Override + public void serverStopped() + { + // NOOP + } + @Override + public NetworkManager getClientToServerNetworkManager() + { + throw new RuntimeException("Missing"); + } + @Override + public INetHandler getClientPlayHandler() + { + return null; + } + @Override + public void waitForPlayClient() + { + // NOOP + } + + @Override + public void fireNetRegistrationEvent(EventBus bus, NetworkManager manager, Set channelSet, String channel, Side side) + { + bus.post(new FMLNetworkEvent.CustomPacketRegistrationEvent(manager, channelSet, channel, side, NetHandlerPlayServer.class)); + } + + @Override + public boolean shouldAllowPlayerLogins() + { + return DedicatedServer.allowPlayerLogins; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/Block.java b/src/main/java/net/minecraft/block/Block.java new file mode 100644 index 0000000..3fbfd8f --- /dev/null +++ b/src/main/java/net/minecraft/block/Block.java @@ -0,0 +1,2249 @@ +package net.minecraft.block; + +import cpw.mods.fml.common.registry.GameData; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Random; + +import net.minecraft.block.material.MapColor; +import net.minecraft.block.material.Material; +import net.minecraft.client.particle.EffectRenderer; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.boss.EntityDragon; +import net.minecraft.entity.boss.EntityWither; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.item.EntityXPOrb; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.stats.StatList; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntitySign; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.IIcon; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.RegistryNamespaced; +import net.minecraft.util.RegistryNamespacedDefaultedByKey; +import net.minecraft.util.StatCollector; +import net.minecraft.util.Vec3; +import net.minecraft.world.Explosion; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraft.world.WorldProviderEnd; +import net.minecraftforge.common.EnumPlantType; +import net.minecraftforge.common.ForgeHooks; +import net.minecraftforge.common.IPlantable; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.common.util.RotationHelper; +import net.minecraftforge.event.ForgeEventFactory; +import static net.minecraftforge.common.util.ForgeDirection.*; + +public class Block +{ + public static final RegistryNamespaced blockRegistry = GameData.getBlockRegistry(); + private CreativeTabs displayOnCreativeTab; + protected String textureName; + public static final Block.SoundType soundTypeStone = new Block.SoundType("stone", 1.0F, 1.0F); + public static final Block.SoundType soundTypeWood = new Block.SoundType("wood", 1.0F, 1.0F); + public static final Block.SoundType soundTypeGravel = new Block.SoundType("gravel", 1.0F, 1.0F); + public static final Block.SoundType soundTypeGrass = new Block.SoundType("grass", 1.0F, 1.0F); + public static final Block.SoundType soundTypePiston = new Block.SoundType("stone", 1.0F, 1.0F); + public static final Block.SoundType soundTypeMetal = new Block.SoundType("stone", 1.0F, 1.5F); + public static final Block.SoundType soundTypeGlass = new Block.SoundType("stone", 1.0F, 1.0F) + { + private static final String __OBFID = "CL_00000200"; + public String getBreakSound() + { + return "dig.glass"; + } + public String func_150496_b() + { + return "step.stone"; + } + }; + public static final Block.SoundType soundTypeCloth = new Block.SoundType("cloth", 1.0F, 1.0F); + public static final Block.SoundType soundTypeSand = new Block.SoundType("sand", 1.0F, 1.0F); + public static final Block.SoundType soundTypeSnow = new Block.SoundType("snow", 1.0F, 1.0F); + public static final Block.SoundType soundTypeLadder = new Block.SoundType("ladder", 1.0F, 1.0F) + { + private static final String __OBFID = "CL_00000201"; + public String getBreakSound() + { + return "dig.wood"; + } + }; + public static final Block.SoundType soundTypeAnvil = new Block.SoundType("anvil", 0.3F, 1.0F) + { + private static final String __OBFID = "CL_00000202"; + public String getBreakSound() + { + return "dig.stone"; + } + public String func_150496_b() + { + return "random.anvil_land"; + } + }; + protected boolean opaque; + protected int lightOpacity; + protected boolean canBlockGrass; + protected int lightValue; + protected boolean useNeighborBrightness; + protected float blockHardness; + protected float blockResistance; + protected boolean blockConstructorCalled = true; + protected boolean enableStats = true; + protected boolean needsRandomTick; + protected boolean isBlockContainer; + protected double minX; + protected double minY; + protected double minZ; + protected double maxX; + protected double maxY; + protected double maxZ; + public Block.SoundType stepSound; + public float blockParticleGravity; + protected final Material blockMaterial; + public float slipperiness; + private String unlocalizedName; + @SideOnly(Side.CLIENT) + protected IIcon blockIcon; + private static final String __OBFID = "CL_00000199"; + + public static int getIdFromBlock(Block p_149682_0_) + { + return blockRegistry.getIDForObject(p_149682_0_); + } + + public static Block getBlockById(int p_149729_0_) + { + Block ret = (Block)blockRegistry.getObjectById(p_149729_0_); + return ret == null ? Blocks.air : ret; + } + + public static Block getBlockFromItem(Item p_149634_0_) + { + return getBlockById(Item.getIdFromItem(p_149634_0_)); + } + + public static Block getBlockFromName(String p_149684_0_) + { + if (blockRegistry.containsKey(p_149684_0_)) + { + return (Block)blockRegistry.getObject(p_149684_0_); + } + else + { + try + { + return (Block)blockRegistry.getObjectById(Integer.parseInt(p_149684_0_)); + } + catch (NumberFormatException numberformatexception) + { + return null; + } + } + } + + public boolean func_149730_j() + { + return this.opaque; + } + + public int getLightOpacity() + { + return this.lightOpacity; + } + + @SideOnly(Side.CLIENT) + public boolean getCanBlockGrass() + { + return this.canBlockGrass; + } + + public int getLightValue() + { + return this.lightValue; + } + + public boolean getUseNeighborBrightness() + { + return this.useNeighborBrightness; + } + + public Material getMaterial() + { + return this.blockMaterial; + } + + public MapColor getMapColor(int p_149728_1_) + { + return this.getMaterial().getMaterialMapColor(); + } + + public static void registerBlocks() + { + blockRegistry.addObject(0, "air", (new BlockAir()).setBlockName("air")); + blockRegistry.addObject(1, "stone", (new BlockStone()).setHardness(1.5F).setResistance(10.0F).setStepSound(soundTypePiston).setBlockName("stone").setBlockTextureName("stone")); + blockRegistry.addObject(2, "grass", (new BlockGrass()).setHardness(0.6F).setStepSound(soundTypeGrass).setBlockName("grass").setBlockTextureName("grass")); + blockRegistry.addObject(3, "dirt", (new BlockDirt()).setHardness(0.5F).setStepSound(soundTypeGravel).setBlockName("dirt").setBlockTextureName("dirt")); + Block block = (new Block(Material.rock)).setHardness(2.0F).setResistance(10.0F).setStepSound(soundTypePiston).setBlockName("stonebrick").setCreativeTab(CreativeTabs.tabBlock).setBlockTextureName("cobblestone"); + blockRegistry.addObject(4, "cobblestone", block); + Block block1 = (new BlockWood()).setHardness(2.0F).setResistance(5.0F).setStepSound(soundTypeWood).setBlockName("wood").setBlockTextureName("planks"); + blockRegistry.addObject(5, "planks", block1); + blockRegistry.addObject(6, "sapling", (new BlockSapling()).setHardness(0.0F).setStepSound(soundTypeGrass).setBlockName("sapling").setBlockTextureName("sapling")); + blockRegistry.addObject(7, "bedrock", (new Block(Material.rock)).setBlockUnbreakable().setResistance(6000000.0F).setStepSound(soundTypePiston).setBlockName("bedrock").disableStats().setCreativeTab(CreativeTabs.tabBlock).setBlockTextureName("bedrock")); + blockRegistry.addObject(8, "flowing_water", (new BlockDynamicLiquid(Material.water)).setHardness(100.0F).setLightOpacity(3).setBlockName("water").disableStats().setBlockTextureName("water_flow")); + blockRegistry.addObject(9, "water", (new BlockStaticLiquid(Material.water)).setHardness(100.0F).setLightOpacity(3).setBlockName("water").disableStats().setBlockTextureName("water_still")); + blockRegistry.addObject(10, "flowing_lava", (new BlockDynamicLiquid(Material.lava)).setHardness(100.0F).setLightLevel(1.0F).setBlockName("lava").disableStats().setBlockTextureName("lava_flow")); + blockRegistry.addObject(11, "lava", (new BlockStaticLiquid(Material.lava)).setHardness(100.0F).setLightLevel(1.0F).setBlockName("lava").disableStats().setBlockTextureName("lava_still")); + blockRegistry.addObject(12, "sand", (new BlockSand()).setHardness(0.5F).setStepSound(soundTypeSand).setBlockName("sand").setBlockTextureName("sand")); + blockRegistry.addObject(13, "gravel", (new BlockGravel()).setHardness(0.6F).setStepSound(soundTypeGravel).setBlockName("gravel").setBlockTextureName("gravel")); + blockRegistry.addObject(14, "gold_ore", (new BlockOre()).setHardness(3.0F).setResistance(5.0F).setStepSound(soundTypePiston).setBlockName("oreGold").setBlockTextureName("gold_ore")); + blockRegistry.addObject(15, "iron_ore", (new BlockOre()).setHardness(3.0F).setResistance(5.0F).setStepSound(soundTypePiston).setBlockName("oreIron").setBlockTextureName("iron_ore")); + blockRegistry.addObject(16, "coal_ore", (new BlockOre()).setHardness(3.0F).setResistance(5.0F).setStepSound(soundTypePiston).setBlockName("oreCoal").setBlockTextureName("coal_ore")); + blockRegistry.addObject(17, "log", (new BlockOldLog()).setBlockName("log").setBlockTextureName("log")); + blockRegistry.addObject(18, "leaves", (new BlockOldLeaf()).setBlockName("leaves").setBlockTextureName("leaves")); + blockRegistry.addObject(19, "sponge", (new BlockSponge()).setHardness(0.6F).setStepSound(soundTypeGrass).setBlockName("sponge").setBlockTextureName("sponge")); + blockRegistry.addObject(20, "glass", (new BlockGlass(Material.glass, false)).setHardness(0.3F).setStepSound(soundTypeGlass).setBlockName("glass").setBlockTextureName("glass")); + blockRegistry.addObject(21, "lapis_ore", (new BlockOre()).setHardness(3.0F).setResistance(5.0F).setStepSound(soundTypePiston).setBlockName("oreLapis").setBlockTextureName("lapis_ore")); + blockRegistry.addObject(22, "lapis_block", (new BlockCompressed(MapColor.lapisColor)).setHardness(3.0F).setResistance(5.0F).setStepSound(soundTypePiston).setBlockName("blockLapis").setCreativeTab(CreativeTabs.tabBlock).setBlockTextureName("lapis_block")); + blockRegistry.addObject(23, "dispenser", (new BlockDispenser()).setHardness(3.5F).setStepSound(soundTypePiston).setBlockName("dispenser").setBlockTextureName("dispenser")); + Block block2 = (new BlockSandStone()).setStepSound(soundTypePiston).setHardness(0.8F).setBlockName("sandStone").setBlockTextureName("sandstone"); + blockRegistry.addObject(24, "sandstone", block2); + blockRegistry.addObject(25, "noteblock", (new BlockNote()).setHardness(0.8F).setBlockName("musicBlock").setBlockTextureName("noteblock")); + blockRegistry.addObject(26, "bed", (new BlockBed()).setHardness(0.2F).setBlockName("bed").disableStats().setBlockTextureName("bed")); + blockRegistry.addObject(27, "golden_rail", (new BlockRailPowered()).setHardness(0.7F).setStepSound(soundTypeMetal).setBlockName("goldenRail").setBlockTextureName("rail_golden")); + blockRegistry.addObject(28, "detector_rail", (new BlockRailDetector()).setHardness(0.7F).setStepSound(soundTypeMetal).setBlockName("detectorRail").setBlockTextureName("rail_detector")); + blockRegistry.addObject(29, "sticky_piston", (new BlockPistonBase(true)).setBlockName("pistonStickyBase")); + blockRegistry.addObject(30, "web", (new BlockWeb()).setLightOpacity(1).setHardness(4.0F).setBlockName("web").setBlockTextureName("web")); + blockRegistry.addObject(31, "tallgrass", (new BlockTallGrass()).setHardness(0.0F).setStepSound(soundTypeGrass).setBlockName("tallgrass")); + blockRegistry.addObject(32, "deadbush", (new BlockDeadBush()).setHardness(0.0F).setStepSound(soundTypeGrass).setBlockName("deadbush").setBlockTextureName("deadbush")); + blockRegistry.addObject(33, "piston", (new BlockPistonBase(false)).setBlockName("pistonBase")); + blockRegistry.addObject(34, "piston_head", new BlockPistonExtension()); + blockRegistry.addObject(35, "wool", (new BlockColored(Material.cloth)).setHardness(0.8F).setStepSound(soundTypeCloth).setBlockName("cloth").setBlockTextureName("wool_colored")); + blockRegistry.addObject(36, "piston_extension", new BlockPistonMoving()); + blockRegistry.addObject(37, "yellow_flower", (new BlockFlower(0)).setHardness(0.0F).setStepSound(soundTypeGrass).setBlockName("flower1").setBlockTextureName("flower_dandelion")); + blockRegistry.addObject(38, "red_flower", (new BlockFlower(1)).setHardness(0.0F).setStepSound(soundTypeGrass).setBlockName("flower2").setBlockTextureName("flower_rose")); + blockRegistry.addObject(39, "brown_mushroom", (new BlockMushroom()).setHardness(0.0F).setStepSound(soundTypeGrass).setLightLevel(0.125F).setBlockName("mushroom").setBlockTextureName("mushroom_brown")); + blockRegistry.addObject(40, "red_mushroom", (new BlockMushroom()).setHardness(0.0F).setStepSound(soundTypeGrass).setBlockName("mushroom").setBlockTextureName("mushroom_red")); + blockRegistry.addObject(41, "gold_block", (new BlockCompressed(MapColor.goldColor)).setHardness(3.0F).setResistance(10.0F).setStepSound(soundTypeMetal).setBlockName("blockGold").setBlockTextureName("gold_block")); + blockRegistry.addObject(42, "iron_block", (new BlockCompressed(MapColor.ironColor)).setHardness(5.0F).setResistance(10.0F).setStepSound(soundTypeMetal).setBlockName("blockIron").setBlockTextureName("iron_block")); + blockRegistry.addObject(43, "double_stone_slab", (new BlockStoneSlab(true)).setHardness(2.0F).setResistance(10.0F).setStepSound(soundTypePiston).setBlockName("stoneSlab")); + blockRegistry.addObject(44, "stone_slab", (new BlockStoneSlab(false)).setHardness(2.0F).setResistance(10.0F).setStepSound(soundTypePiston).setBlockName("stoneSlab")); + Block block3 = (new Block(Material.rock)).setHardness(2.0F).setResistance(10.0F).setStepSound(soundTypePiston).setBlockName("brick").setCreativeTab(CreativeTabs.tabBlock).setBlockTextureName("brick"); + blockRegistry.addObject(45, "brick_block", block3); + blockRegistry.addObject(46, "tnt", (new BlockTNT()).setHardness(0.0F).setStepSound(soundTypeGrass).setBlockName("tnt").setBlockTextureName("tnt")); + blockRegistry.addObject(47, "bookshelf", (new BlockBookshelf()).setHardness(1.5F).setStepSound(soundTypeWood).setBlockName("bookshelf").setBlockTextureName("bookshelf")); + blockRegistry.addObject(48, "mossy_cobblestone", (new Block(Material.rock)).setHardness(2.0F).setResistance(10.0F).setStepSound(soundTypePiston).setBlockName("stoneMoss").setCreativeTab(CreativeTabs.tabBlock).setBlockTextureName("cobblestone_mossy")); + blockRegistry.addObject(49, "obsidian", (new BlockObsidian()).setHardness(50.0F).setResistance(2000.0F).setStepSound(soundTypePiston).setBlockName("obsidian").setBlockTextureName("obsidian")); + blockRegistry.addObject(50, "torch", (new BlockTorch()).setHardness(0.0F).setLightLevel(0.9375F).setStepSound(soundTypeWood).setBlockName("torch").setBlockTextureName("torch_on")); + blockRegistry.addObject(51, "fire", (new BlockFire()).setHardness(0.0F).setLightLevel(1.0F).setStepSound(soundTypeWood).setBlockName("fire").disableStats().setBlockTextureName("fire")); + blockRegistry.addObject(52, "mob_spawner", (new BlockMobSpawner()).setHardness(5.0F).setStepSound(soundTypeMetal).setBlockName("mobSpawner").disableStats().setBlockTextureName("mob_spawner")); + blockRegistry.addObject(53, "oak_stairs", (new BlockStairs(block1, 0)).setBlockName("stairsWood")); + blockRegistry.addObject(54, "chest", (new BlockChest(0)).setHardness(2.5F).setStepSound(soundTypeWood).setBlockName("chest")); + blockRegistry.addObject(55, "redstone_wire", (new BlockRedstoneWire()).setHardness(0.0F).setStepSound(soundTypeStone).setBlockName("redstoneDust").disableStats().setBlockTextureName("redstone_dust")); + blockRegistry.addObject(56, "diamond_ore", (new BlockOre()).setHardness(3.0F).setResistance(5.0F).setStepSound(soundTypePiston).setBlockName("oreDiamond").setBlockTextureName("diamond_ore")); + blockRegistry.addObject(57, "diamond_block", (new BlockCompressed(MapColor.diamondColor)).setHardness(5.0F).setResistance(10.0F).setStepSound(soundTypeMetal).setBlockName("blockDiamond").setBlockTextureName("diamond_block")); + blockRegistry.addObject(58, "crafting_table", (new BlockWorkbench()).setHardness(2.5F).setStepSound(soundTypeWood).setBlockName("workbench").setBlockTextureName("crafting_table")); + blockRegistry.addObject(59, "wheat", (new BlockCrops()).setBlockName("crops").setBlockTextureName("wheat")); + Block block4 = (new BlockFarmland()).setHardness(0.6F).setStepSound(soundTypeGravel).setBlockName("farmland").setBlockTextureName("farmland"); + blockRegistry.addObject(60, "farmland", block4); + blockRegistry.addObject(61, "furnace", (new BlockFurnace(false)).setHardness(3.5F).setStepSound(soundTypePiston).setBlockName("furnace").setCreativeTab(CreativeTabs.tabDecorations)); + blockRegistry.addObject(62, "lit_furnace", (new BlockFurnace(true)).setHardness(3.5F).setStepSound(soundTypePiston).setLightLevel(0.875F).setBlockName("furnace")); + blockRegistry.addObject(63, "standing_sign", (new BlockSign(TileEntitySign.class, true)).setHardness(1.0F).setStepSound(soundTypeWood).setBlockName("sign").disableStats()); + blockRegistry.addObject(64, "wooden_door", (new BlockDoor(Material.wood)).setHardness(3.0F).setStepSound(soundTypeWood).setBlockName("doorWood").disableStats().setBlockTextureName("door_wood")); + blockRegistry.addObject(65, "ladder", (new BlockLadder()).setHardness(0.4F).setStepSound(soundTypeLadder).setBlockName("ladder").setBlockTextureName("ladder")); + blockRegistry.addObject(66, "rail", (new BlockRail()).setHardness(0.7F).setStepSound(soundTypeMetal).setBlockName("rail").setBlockTextureName("rail_normal")); + blockRegistry.addObject(67, "stone_stairs", (new BlockStairs(block, 0)).setBlockName("stairsStone")); + blockRegistry.addObject(68, "wall_sign", (new BlockSign(TileEntitySign.class, false)).setHardness(1.0F).setStepSound(soundTypeWood).setBlockName("sign").disableStats()); + blockRegistry.addObject(69, "lever", (new BlockLever()).setHardness(0.5F).setStepSound(soundTypeWood).setBlockName("lever").setBlockTextureName("lever")); + blockRegistry.addObject(70, "stone_pressure_plate", (new BlockPressurePlate("stone", Material.rock, BlockPressurePlate.Sensitivity.mobs)).setHardness(0.5F).setStepSound(soundTypePiston).setBlockName("pressurePlate")); + blockRegistry.addObject(71, "iron_door", (new BlockDoor(Material.iron)).setHardness(5.0F).setStepSound(soundTypeMetal).setBlockName("doorIron").disableStats().setBlockTextureName("door_iron")); + blockRegistry.addObject(72, "wooden_pressure_plate", (new BlockPressurePlate("planks_oak", Material.wood, BlockPressurePlate.Sensitivity.everything)).setHardness(0.5F).setStepSound(soundTypeWood).setBlockName("pressurePlate")); + blockRegistry.addObject(73, "redstone_ore", (new BlockRedstoneOre(false)).setHardness(3.0F).setResistance(5.0F).setStepSound(soundTypePiston).setBlockName("oreRedstone").setCreativeTab(CreativeTabs.tabBlock).setBlockTextureName("redstone_ore")); + blockRegistry.addObject(74, "lit_redstone_ore", (new BlockRedstoneOre(true)).setLightLevel(0.625F).setHardness(3.0F).setResistance(5.0F).setStepSound(soundTypePiston).setBlockName("oreRedstone").setBlockTextureName("redstone_ore")); + blockRegistry.addObject(75, "unlit_redstone_torch", (new BlockRedstoneTorch(false)).setHardness(0.0F).setStepSound(soundTypeWood).setBlockName("notGate").setBlockTextureName("redstone_torch_off")); + blockRegistry.addObject(76, "redstone_torch", (new BlockRedstoneTorch(true)).setHardness(0.0F).setLightLevel(0.5F).setStepSound(soundTypeWood).setBlockName("notGate").setCreativeTab(CreativeTabs.tabRedstone).setBlockTextureName("redstone_torch_on")); + blockRegistry.addObject(77, "stone_button", (new BlockButtonStone()).setHardness(0.5F).setStepSound(soundTypePiston).setBlockName("button")); + blockRegistry.addObject(78, "snow_layer", (new BlockSnow()).setHardness(0.1F).setStepSound(soundTypeSnow).setBlockName("snow").setLightOpacity(0).setBlockTextureName("snow")); + blockRegistry.addObject(79, "ice", (new BlockIce()).setHardness(0.5F).setLightOpacity(3).setStepSound(soundTypeGlass).setBlockName("ice").setBlockTextureName("ice")); + blockRegistry.addObject(80, "snow", (new BlockSnowBlock()).setHardness(0.2F).setStepSound(soundTypeSnow).setBlockName("snow").setBlockTextureName("snow")); + blockRegistry.addObject(81, "cactus", (new BlockCactus()).setHardness(0.4F).setStepSound(soundTypeCloth).setBlockName("cactus").setBlockTextureName("cactus")); + blockRegistry.addObject(82, "clay", (new BlockClay()).setHardness(0.6F).setStepSound(soundTypeGravel).setBlockName("clay").setBlockTextureName("clay")); + blockRegistry.addObject(83, "reeds", (new BlockReed()).setHardness(0.0F).setStepSound(soundTypeGrass).setBlockName("reeds").disableStats().setBlockTextureName("reeds")); + blockRegistry.addObject(84, "jukebox", (new BlockJukebox()).setHardness(2.0F).setResistance(10.0F).setStepSound(soundTypePiston).setBlockName("jukebox").setBlockTextureName("jukebox")); + blockRegistry.addObject(85, "fence", (new BlockFence("planks_oak", Material.wood)).setHardness(2.0F).setResistance(5.0F).setStepSound(soundTypeWood).setBlockName("fence")); + Block block5 = (new BlockPumpkin(false)).setHardness(1.0F).setStepSound(soundTypeWood).setBlockName("pumpkin").setBlockTextureName("pumpkin"); + blockRegistry.addObject(86, "pumpkin", block5); + blockRegistry.addObject(87, "netherrack", (new BlockNetherrack()).setHardness(0.4F).setStepSound(soundTypePiston).setBlockName("hellrock").setBlockTextureName("netherrack")); + blockRegistry.addObject(88, "soul_sand", (new BlockSoulSand()).setHardness(0.5F).setStepSound(soundTypeSand).setBlockName("hellsand").setBlockTextureName("soul_sand")); + blockRegistry.addObject(89, "glowstone", (new BlockGlowstone(Material.glass)).setHardness(0.3F).setStepSound(soundTypeGlass).setLightLevel(1.0F).setBlockName("lightgem").setBlockTextureName("glowstone")); + blockRegistry.addObject(90, "portal", (new BlockPortal()).setHardness(-1.0F).setStepSound(soundTypeGlass).setLightLevel(0.75F).setBlockName("portal").setBlockTextureName("portal")); + blockRegistry.addObject(91, "lit_pumpkin", (new BlockPumpkin(true)).setHardness(1.0F).setStepSound(soundTypeWood).setLightLevel(1.0F).setBlockName("litpumpkin").setBlockTextureName("pumpkin")); + blockRegistry.addObject(92, "cake", (new BlockCake()).setHardness(0.5F).setStepSound(soundTypeCloth).setBlockName("cake").disableStats().setBlockTextureName("cake")); + blockRegistry.addObject(93, "unpowered_repeater", (new BlockRedstoneRepeater(false)).setHardness(0.0F).setStepSound(soundTypeWood).setBlockName("diode").disableStats().setBlockTextureName("repeater_off")); + blockRegistry.addObject(94, "powered_repeater", (new BlockRedstoneRepeater(true)).setHardness(0.0F).setLightLevel(0.625F).setStepSound(soundTypeWood).setBlockName("diode").disableStats().setBlockTextureName("repeater_on")); + blockRegistry.addObject(95, "stained_glass", (new BlockStainedGlass(Material.glass)).setHardness(0.3F).setStepSound(soundTypeGlass).setBlockName("stainedGlass").setBlockTextureName("glass")); + blockRegistry.addObject(96, "trapdoor", (new BlockTrapDoor(Material.wood)).setHardness(3.0F).setStepSound(soundTypeWood).setBlockName("trapdoor").disableStats().setBlockTextureName("trapdoor")); + blockRegistry.addObject(97, "monster_egg", (new BlockSilverfish()).setHardness(0.75F).setBlockName("monsterStoneEgg")); + Block block6 = (new BlockStoneBrick()).setHardness(1.5F).setResistance(10.0F).setStepSound(soundTypePiston).setBlockName("stonebricksmooth").setBlockTextureName("stonebrick"); + blockRegistry.addObject(98, "stonebrick", block6); + blockRegistry.addObject(99, "brown_mushroom_block", (new BlockHugeMushroom(Material.wood, 0)).setHardness(0.2F).setStepSound(soundTypeWood).setBlockName("mushroom").setBlockTextureName("mushroom_block")); + blockRegistry.addObject(100, "red_mushroom_block", (new BlockHugeMushroom(Material.wood, 1)).setHardness(0.2F).setStepSound(soundTypeWood).setBlockName("mushroom").setBlockTextureName("mushroom_block")); + blockRegistry.addObject(101, "iron_bars", (new BlockPane("iron_bars", "iron_bars", Material.iron, true)).setHardness(5.0F).setResistance(10.0F).setStepSound(soundTypeMetal).setBlockName("fenceIron")); + blockRegistry.addObject(102, "glass_pane", (new BlockPane("glass", "glass_pane_top", Material.glass, false)).setHardness(0.3F).setStepSound(soundTypeGlass).setBlockName("thinGlass")); + Block block7 = (new BlockMelon()).setHardness(1.0F).setStepSound(soundTypeWood).setBlockName("melon").setBlockTextureName("melon"); + blockRegistry.addObject(103, "melon_block", block7); + blockRegistry.addObject(104, "pumpkin_stem", (new BlockStem(block5)).setHardness(0.0F).setStepSound(soundTypeWood).setBlockName("pumpkinStem").setBlockTextureName("pumpkin_stem")); + blockRegistry.addObject(105, "melon_stem", (new BlockStem(block7)).setHardness(0.0F).setStepSound(soundTypeWood).setBlockName("pumpkinStem").setBlockTextureName("melon_stem")); + blockRegistry.addObject(106, "vine", (new BlockVine()).setHardness(0.2F).setStepSound(soundTypeGrass).setBlockName("vine").setBlockTextureName("vine")); + blockRegistry.addObject(107, "fence_gate", (new BlockFenceGate()).setHardness(2.0F).setResistance(5.0F).setStepSound(soundTypeWood).setBlockName("fenceGate")); + blockRegistry.addObject(108, "brick_stairs", (new BlockStairs(block3, 0)).setBlockName("stairsBrick")); + blockRegistry.addObject(109, "stone_brick_stairs", (new BlockStairs(block6, 0)).setBlockName("stairsStoneBrickSmooth")); + blockRegistry.addObject(110, "mycelium", (new BlockMycelium()).setHardness(0.6F).setStepSound(soundTypeGrass).setBlockName("mycel").setBlockTextureName("mycelium")); + blockRegistry.addObject(111, "waterlily", (new BlockLilyPad()).setHardness(0.0F).setStepSound(soundTypeGrass).setBlockName("waterlily").setBlockTextureName("waterlily")); + Block block8 = (new Block(Material.rock)).setHardness(2.0F).setResistance(10.0F).setStepSound(soundTypePiston).setBlockName("netherBrick").setCreativeTab(CreativeTabs.tabBlock).setBlockTextureName("nether_brick"); + blockRegistry.addObject(112, "nether_brick", block8); + blockRegistry.addObject(113, "nether_brick_fence", (new BlockFence("nether_brick", Material.rock)).setHardness(2.0F).setResistance(10.0F).setStepSound(soundTypePiston).setBlockName("netherFence")); + blockRegistry.addObject(114, "nether_brick_stairs", (new BlockStairs(block8, 0)).setBlockName("stairsNetherBrick")); + blockRegistry.addObject(115, "nether_wart", (new BlockNetherWart()).setBlockName("netherStalk").setBlockTextureName("nether_wart")); + blockRegistry.addObject(116, "enchanting_table", (new BlockEnchantmentTable()).setHardness(5.0F).setResistance(2000.0F).setBlockName("enchantmentTable").setBlockTextureName("enchanting_table")); + blockRegistry.addObject(117, "brewing_stand", (new BlockBrewingStand()).setHardness(0.5F).setLightLevel(0.125F).setBlockName("brewingStand").setBlockTextureName("brewing_stand")); + blockRegistry.addObject(118, "cauldron", (new BlockCauldron()).setHardness(2.0F).setBlockName("cauldron").setBlockTextureName("cauldron")); + blockRegistry.addObject(119, "end_portal", (new BlockEndPortal(Material.portal)).setHardness(-1.0F).setResistance(6000000.0F)); + blockRegistry.addObject(120, "end_portal_frame", (new BlockEndPortalFrame()).setStepSound(soundTypeGlass).setLightLevel(0.125F).setHardness(-1.0F).setBlockName("endPortalFrame").setResistance(6000000.0F).setCreativeTab(CreativeTabs.tabDecorations).setBlockTextureName("endframe")); + blockRegistry.addObject(121, "end_stone", (new Block(Material.rock)).setHardness(3.0F).setResistance(15.0F).setStepSound(soundTypePiston).setBlockName("whiteStone").setCreativeTab(CreativeTabs.tabBlock).setBlockTextureName("end_stone")); + blockRegistry.addObject(122, "dragon_egg", (new BlockDragonEgg()).setHardness(3.0F).setResistance(15.0F).setStepSound(soundTypePiston).setLightLevel(0.125F).setBlockName("dragonEgg").setBlockTextureName("dragon_egg")); + blockRegistry.addObject(123, "redstone_lamp", (new BlockRedstoneLight(false)).setHardness(0.3F).setStepSound(soundTypeGlass).setBlockName("redstoneLight").setCreativeTab(CreativeTabs.tabRedstone).setBlockTextureName("redstone_lamp_off")); + blockRegistry.addObject(124, "lit_redstone_lamp", (new BlockRedstoneLight(true)).setHardness(0.3F).setStepSound(soundTypeGlass).setBlockName("redstoneLight").setBlockTextureName("redstone_lamp_on")); + blockRegistry.addObject(125, "double_wooden_slab", (new BlockWoodSlab(true)).setHardness(2.0F).setResistance(5.0F).setStepSound(soundTypeWood).setBlockName("woodSlab")); + blockRegistry.addObject(126, "wooden_slab", (new BlockWoodSlab(false)).setHardness(2.0F).setResistance(5.0F).setStepSound(soundTypeWood).setBlockName("woodSlab")); + blockRegistry.addObject(127, "cocoa", (new BlockCocoa()).setHardness(0.2F).setResistance(5.0F).setStepSound(soundTypeWood).setBlockName("cocoa").setBlockTextureName("cocoa")); + blockRegistry.addObject(128, "sandstone_stairs", (new BlockStairs(block2, 0)).setBlockName("stairsSandStone")); + blockRegistry.addObject(129, "emerald_ore", (new BlockOre()).setHardness(3.0F).setResistance(5.0F).setStepSound(soundTypePiston).setBlockName("oreEmerald").setBlockTextureName("emerald_ore")); + blockRegistry.addObject(130, "ender_chest", (new BlockEnderChest()).setHardness(22.5F).setResistance(1000.0F).setStepSound(soundTypePiston).setBlockName("enderChest").setLightLevel(0.5F)); + blockRegistry.addObject(131, "tripwire_hook", (new BlockTripWireHook()).setBlockName("tripWireSource").setBlockTextureName("trip_wire_source")); + blockRegistry.addObject(132, "tripwire", (new BlockTripWire()).setBlockName("tripWire").setBlockTextureName("trip_wire")); + blockRegistry.addObject(133, "emerald_block", (new BlockCompressed(MapColor.emeraldColor)).setHardness(5.0F).setResistance(10.0F).setStepSound(soundTypeMetal).setBlockName("blockEmerald").setBlockTextureName("emerald_block")); + blockRegistry.addObject(134, "spruce_stairs", (new BlockStairs(block1, 1)).setBlockName("stairsWoodSpruce")); + blockRegistry.addObject(135, "birch_stairs", (new BlockStairs(block1, 2)).setBlockName("stairsWoodBirch")); + blockRegistry.addObject(136, "jungle_stairs", (new BlockStairs(block1, 3)).setBlockName("stairsWoodJungle")); + blockRegistry.addObject(137, "command_block", (new BlockCommandBlock()).setBlockUnbreakable().setResistance(6000000.0F).setBlockName("commandBlock").setBlockTextureName("command_block")); + blockRegistry.addObject(138, "beacon", (new BlockBeacon()).setBlockName("beacon").setLightLevel(1.0F).setBlockTextureName("beacon")); + blockRegistry.addObject(139, "cobblestone_wall", (new BlockWall(block)).setBlockName("cobbleWall")); + blockRegistry.addObject(140, "flower_pot", (new BlockFlowerPot()).setHardness(0.0F).setStepSound(soundTypeStone).setBlockName("flowerPot").setBlockTextureName("flower_pot")); + blockRegistry.addObject(141, "carrots", (new BlockCarrot()).setBlockName("carrots").setBlockTextureName("carrots")); + blockRegistry.addObject(142, "potatoes", (new BlockPotato()).setBlockName("potatoes").setBlockTextureName("potatoes")); + blockRegistry.addObject(143, "wooden_button", (new BlockButtonWood()).setHardness(0.5F).setStepSound(soundTypeWood).setBlockName("button")); + blockRegistry.addObject(144, "skull", (new BlockSkull()).setHardness(1.0F).setStepSound(soundTypePiston).setBlockName("skull").setBlockTextureName("skull")); + blockRegistry.addObject(145, "anvil", (new BlockAnvil()).setHardness(5.0F).setStepSound(soundTypeAnvil).setResistance(2000.0F).setBlockName("anvil")); + blockRegistry.addObject(146, "trapped_chest", (new BlockChest(1)).setHardness(2.5F).setStepSound(soundTypeWood).setBlockName("chestTrap")); + blockRegistry.addObject(147, "light_weighted_pressure_plate", (new BlockPressurePlateWeighted("gold_block", Material.iron, 15)).setHardness(0.5F).setStepSound(soundTypeWood).setBlockName("weightedPlate_light")); + blockRegistry.addObject(148, "heavy_weighted_pressure_plate", (new BlockPressurePlateWeighted("iron_block", Material.iron, 150)).setHardness(0.5F).setStepSound(soundTypeWood).setBlockName("weightedPlate_heavy")); + blockRegistry.addObject(149, "unpowered_comparator", (new BlockRedstoneComparator(false)).setHardness(0.0F).setStepSound(soundTypeWood).setBlockName("comparator").disableStats().setBlockTextureName("comparator_off")); + blockRegistry.addObject(150, "powered_comparator", (new BlockRedstoneComparator(true)).setHardness(0.0F).setLightLevel(0.625F).setStepSound(soundTypeWood).setBlockName("comparator").disableStats().setBlockTextureName("comparator_on")); + blockRegistry.addObject(151, "daylight_detector", (new BlockDaylightDetector()).setHardness(0.2F).setStepSound(soundTypeWood).setBlockName("daylightDetector").setBlockTextureName("daylight_detector")); + blockRegistry.addObject(152, "redstone_block", (new BlockCompressedPowered(MapColor.tntColor)).setHardness(5.0F).setResistance(10.0F).setStepSound(soundTypeMetal).setBlockName("blockRedstone").setBlockTextureName("redstone_block")); + blockRegistry.addObject(153, "quartz_ore", (new BlockOre()).setHardness(3.0F).setResistance(5.0F).setStepSound(soundTypePiston).setBlockName("netherquartz").setBlockTextureName("quartz_ore")); + blockRegistry.addObject(154, "hopper", (new BlockHopper()).setHardness(3.0F).setResistance(8.0F).setStepSound(soundTypeWood).setBlockName("hopper").setBlockTextureName("hopper")); + Block block9 = (new BlockQuartz()).setStepSound(soundTypePiston).setHardness(0.8F).setBlockName("quartzBlock").setBlockTextureName("quartz_block"); + blockRegistry.addObject(155, "quartz_block", block9); + blockRegistry.addObject(156, "quartz_stairs", (new BlockStairs(block9, 0)).setBlockName("stairsQuartz")); + blockRegistry.addObject(157, "activator_rail", (new BlockRailPowered()).setHardness(0.7F).setStepSound(soundTypeMetal).setBlockName("activatorRail").setBlockTextureName("rail_activator")); + blockRegistry.addObject(158, "dropper", (new BlockDropper()).setHardness(3.5F).setStepSound(soundTypePiston).setBlockName("dropper").setBlockTextureName("dropper")); + blockRegistry.addObject(159, "stained_hardened_clay", (new BlockColored(Material.rock)).setHardness(1.25F).setResistance(7.0F).setStepSound(soundTypePiston).setBlockName("clayHardenedStained").setBlockTextureName("hardened_clay_stained")); + blockRegistry.addObject(160, "stained_glass_pane", (new BlockStainedGlassPane()).setHardness(0.3F).setStepSound(soundTypeGlass).setBlockName("thinStainedGlass").setBlockTextureName("glass")); + blockRegistry.addObject(161, "leaves2", (new BlockNewLeaf()).setBlockName("leaves").setBlockTextureName("leaves")); + blockRegistry.addObject(162, "log2", (new BlockNewLog()).setBlockName("log").setBlockTextureName("log")); + blockRegistry.addObject(163, "acacia_stairs", (new BlockStairs(block1, 4)).setBlockName("stairsWoodAcacia")); + blockRegistry.addObject(164, "dark_oak_stairs", (new BlockStairs(block1, 5)).setBlockName("stairsWoodDarkOak")); + blockRegistry.addObject(170, "hay_block", (new BlockHay()).setHardness(0.5F).setStepSound(soundTypeGrass).setBlockName("hayBlock").setCreativeTab(CreativeTabs.tabBlock).setBlockTextureName("hay_block")); + blockRegistry.addObject(171, "carpet", (new BlockCarpet()).setHardness(0.1F).setStepSound(soundTypeCloth).setBlockName("woolCarpet").setLightOpacity(0)); + blockRegistry.addObject(172, "hardened_clay", (new BlockHardenedClay()).setHardness(1.25F).setResistance(7.0F).setStepSound(soundTypePiston).setBlockName("clayHardened").setBlockTextureName("hardened_clay")); + blockRegistry.addObject(173, "coal_block", (new Block(Material.rock)).setHardness(5.0F).setResistance(10.0F).setStepSound(soundTypePiston).setBlockName("blockCoal").setCreativeTab(CreativeTabs.tabBlock).setBlockTextureName("coal_block")); + blockRegistry.addObject(174, "packed_ice", (new BlockPackedIce()).setHardness(0.5F).setStepSound(soundTypeGlass).setBlockName("icePacked").setBlockTextureName("ice_packed")); + blockRegistry.addObject(175, "double_plant", new BlockDoublePlant()); + Iterator iterator = blockRegistry.iterator(); + + while (iterator.hasNext()) + { + Block block10 = (Block)iterator.next(); + + if (block10.blockMaterial == Material.air) + { + block10.useNeighborBrightness = false; + } + else + { + boolean flag = false; + boolean flag1 = block10.getRenderType() == 10; + boolean flag2 = block10 instanceof BlockSlab; + boolean flag3 = block10 == block4; + boolean flag4 = block10.canBlockGrass; + boolean flag5 = block10.lightOpacity == 0; + + if (flag1 || flag2 || flag3 || flag4 || flag5) + { + flag = true; + } + + block10.useNeighborBrightness = flag; + } + } + } + + protected Block(Material p_i45394_1_) + { + this.stepSound = soundTypeStone; + this.blockParticleGravity = 1.0F; + this.slipperiness = 0.6F; + this.blockMaterial = p_i45394_1_; + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + this.opaque = this.isOpaqueCube(); + this.lightOpacity = this.isOpaqueCube() ? 255 : 0; + this.canBlockGrass = !p_i45394_1_.getCanBlockGrass(); + } + + public Block setStepSound(Block.SoundType p_149672_1_) + { + this.stepSound = p_149672_1_; + return this; + } + + public Block setLightOpacity(int p_149713_1_) + { + this.lightOpacity = p_149713_1_; + return this; + } + + public Block setLightLevel(float p_149715_1_) + { + this.lightValue = (int)(15.0F * p_149715_1_); + return this; + } + + public Block setResistance(float p_149752_1_) + { + this.blockResistance = p_149752_1_ * 3.0F; + return this; + } + + @SideOnly(Side.CLIENT) + public boolean isBlockNormalCube() + { + return this.blockMaterial.blocksMovement() && this.renderAsNormalBlock(); + } + + public boolean isNormalCube() + { + return this.blockMaterial.isOpaque() && this.renderAsNormalBlock() && !this.canProvidePower(); + } + + public boolean renderAsNormalBlock() + { + return true; + } + + public boolean getBlocksMovement(IBlockAccess p_149655_1_, int p_149655_2_, int p_149655_3_, int p_149655_4_) + { + return !this.blockMaterial.blocksMovement(); + } + + public int getRenderType() + { + return 0; + } + + public Block setHardness(float p_149711_1_) + { + this.blockHardness = p_149711_1_; + + if (this.blockResistance < p_149711_1_ * 5.0F) + { + this.blockResistance = p_149711_1_ * 5.0F; + } + + return this; + } + + public Block setBlockUnbreakable() + { + this.setHardness(-1.0F); + return this; + } + + public float getBlockHardness(World p_149712_1_, int p_149712_2_, int p_149712_3_, int p_149712_4_) + { + return this.blockHardness; + } + + public Block setTickRandomly(boolean p_149675_1_) + { + this.needsRandomTick = p_149675_1_; + return this; + } + + public boolean getTickRandomly() + { + return this.needsRandomTick; + } + + @Deprecated //Forge: New Metadata sensitive version. + public boolean hasTileEntity() + { + return hasTileEntity(0); + } + + public final void setBlockBounds(float p_149676_1_, float p_149676_2_, float p_149676_3_, float p_149676_4_, float p_149676_5_, float p_149676_6_) + { + this.minX = (double)p_149676_1_; + this.minY = (double)p_149676_2_; + this.minZ = (double)p_149676_3_; + this.maxX = (double)p_149676_4_; + this.maxY = (double)p_149676_5_; + this.maxZ = (double)p_149676_6_; + } + + @SideOnly(Side.CLIENT) + public int getMixedBrightnessForBlock(IBlockAccess p_149677_1_, int p_149677_2_, int p_149677_3_, int p_149677_4_) + { + Block block = p_149677_1_.getBlock(p_149677_2_, p_149677_3_, p_149677_4_); + int l = p_149677_1_.getLightBrightnessForSkyBlocks(p_149677_2_, p_149677_3_, p_149677_4_, block.getLightValue(p_149677_1_, p_149677_2_, p_149677_3_, p_149677_4_)); + + if (l == 0 && block instanceof BlockSlab) + { + --p_149677_3_; + block = p_149677_1_.getBlock(p_149677_2_, p_149677_3_, p_149677_4_); + return p_149677_1_.getLightBrightnessForSkyBlocks(p_149677_2_, p_149677_3_, p_149677_4_, block.getLightValue(p_149677_1_, p_149677_2_, p_149677_3_, p_149677_4_)); + } + else + { + return l; + } + } + + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) + { + return p_149646_5_ == 0 && this.minY > 0.0D ? true : (p_149646_5_ == 1 && this.maxY < 1.0D ? true : (p_149646_5_ == 2 && this.minZ > 0.0D ? true : (p_149646_5_ == 3 && this.maxZ < 1.0D ? true : (p_149646_5_ == 4 && this.minX > 0.0D ? true : (p_149646_5_ == 5 && this.maxX < 1.0D ? true : !p_149646_1_.getBlock(p_149646_2_, p_149646_3_, p_149646_4_).isOpaqueCube()))))); + } + + public boolean isBlockSolid(IBlockAccess p_149747_1_, int p_149747_2_, int p_149747_3_, int p_149747_4_, int p_149747_5_) + { + return p_149747_1_.getBlock(p_149747_2_, p_149747_3_, p_149747_4_).getMaterial().isSolid(); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess p_149673_1_, int p_149673_2_, int p_149673_3_, int p_149673_4_, int p_149673_5_) + { + return this.getIcon(p_149673_5_, p_149673_1_.getBlockMetadata(p_149673_2_, p_149673_3_, p_149673_4_)); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return this.blockIcon; + } + + public void addCollisionBoxesToList(World p_149743_1_, int p_149743_2_, int p_149743_3_, int p_149743_4_, AxisAlignedBB p_149743_5_, List p_149743_6_, Entity p_149743_7_) + { + AxisAlignedBB axisalignedbb1 = this.getCollisionBoundingBoxFromPool(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_); + + if (axisalignedbb1 != null && p_149743_5_.intersectsWith(axisalignedbb1)) + { + p_149743_6_.add(axisalignedbb1); + } + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) + { + return AxisAlignedBB.getAABBPool().getAABB((double)p_149668_2_ + this.minX, (double)p_149668_3_ + this.minY, (double)p_149668_4_ + this.minZ, (double)p_149668_2_ + this.maxX, (double)p_149668_3_ + this.maxY, (double)p_149668_4_ + this.maxZ); + } + + @SideOnly(Side.CLIENT) + public final IIcon getBlockTextureFromSide(int p_149733_1_) + { + return this.getIcon(p_149733_1_, 0); + } + + @SideOnly(Side.CLIENT) + public AxisAlignedBB getSelectedBoundingBoxFromPool(World p_149633_1_, int p_149633_2_, int p_149633_3_, int p_149633_4_) + { + return AxisAlignedBB.getAABBPool().getAABB((double)p_149633_2_ + this.minX, (double)p_149633_3_ + this.minY, (double)p_149633_4_ + this.minZ, (double)p_149633_2_ + this.maxX, (double)p_149633_3_ + this.maxY, (double)p_149633_4_ + this.maxZ); + } + + public boolean isOpaqueCube() + { + return true; + } + + public boolean canCollideCheck(int p_149678_1_, boolean p_149678_2_) + { + return this.isCollidable(); + } + + public boolean isCollidable() + { + return true; + } + + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) {} + + @SideOnly(Side.CLIENT) + public void randomDisplayTick(World p_149734_1_, int p_149734_2_, int p_149734_3_, int p_149734_4_, Random p_149734_5_) {} + + public void onBlockDestroyedByPlayer(World p_149664_1_, int p_149664_2_, int p_149664_3_, int p_149664_4_, int p_149664_5_) {} + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) {} + + public int tickRate(World p_149738_1_) + { + return 10; + } + + public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_) {} + + public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) + { + if (hasTileEntity(p_149749_6_) && !(this instanceof BlockContainer)) + { + p_149749_1_.removeTileEntity(p_149749_2_, p_149749_3_, p_149749_4_); + } + } + + public int quantityDropped(Random p_149745_1_) + { + return 1; + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return Item.getItemFromBlock(this); + } + + public float getPlayerRelativeBlockHardness(EntityPlayer p_149737_1_, World p_149737_2_, int p_149737_3_, int p_149737_4_, int p_149737_5_) + { + return ForgeHooks.blockStrength(this, p_149737_1_, p_149737_2_, p_149737_3_, p_149737_4_, p_149737_5_); + } + + public final void dropBlockAsItem(World p_149697_1_, int p_149697_2_, int p_149697_3_, int p_149697_4_, int p_149697_5_, int p_149697_6_) + { + this.dropBlockAsItemWithChance(p_149697_1_, p_149697_2_, p_149697_3_, p_149697_4_, p_149697_5_, 1.0F, p_149697_6_); + } + + public void dropBlockAsItemWithChance(World p_149690_1_, int p_149690_2_, int p_149690_3_, int p_149690_4_, int p_149690_5_, float p_149690_6_, int p_149690_7_) + { + if (!p_149690_1_.isRemote) + { + ArrayList items = getDrops(p_149690_1_, p_149690_2_, p_149690_3_, p_149690_4_, p_149690_5_, p_149690_7_); + p_149690_6_ = ForgeEventFactory.fireBlockHarvesting(items, p_149690_1_, this, p_149690_2_, p_149690_3_, p_149690_4_, p_149690_5_, p_149690_7_, p_149690_6_, false, harvesters.get()); + + for (ItemStack item : items) + { + if (p_149690_1_.rand.nextFloat() <= p_149690_6_) + { + this.dropBlockAsItem(p_149690_1_, p_149690_2_, p_149690_3_, p_149690_4_, item); + } + } + } + } + + protected void dropBlockAsItem(World p_149642_1_, int p_149642_2_, int p_149642_3_, int p_149642_4_, ItemStack p_149642_5_) + { + if (!p_149642_1_.isRemote && p_149642_1_.getGameRules().getGameRuleBooleanValue("doTileDrops")) + { + float f = 0.7F; + double d0 = (double)(p_149642_1_.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D; + double d1 = (double)(p_149642_1_.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D; + double d2 = (double)(p_149642_1_.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D; + EntityItem entityitem = new EntityItem(p_149642_1_, (double)p_149642_2_ + d0, (double)p_149642_3_ + d1, (double)p_149642_4_ + d2, p_149642_5_); + entityitem.delayBeforeCanPickup = 10; + p_149642_1_.spawnEntityInWorld(entityitem); + } + } + + public void dropXpOnBlockBreak(World p_149657_1_, int p_149657_2_, int p_149657_3_, int p_149657_4_, int p_149657_5_) + { + if (!p_149657_1_.isRemote) + { + while (p_149657_5_ > 0) + { + int i1 = EntityXPOrb.getXPSplit(p_149657_5_); + p_149657_5_ -= i1; + p_149657_1_.spawnEntityInWorld(new EntityXPOrb(p_149657_1_, (double)p_149657_2_ + 0.5D, (double)p_149657_3_ + 0.5D, (double)p_149657_4_ + 0.5D, i1)); + } + } + } + + public int damageDropped(int p_149692_1_) + { + return 0; + } + + public float getExplosionResistance(Entity p_149638_1_) + { + return this.blockResistance / 5.0F; + } + + public MovingObjectPosition collisionRayTrace(World p_149731_1_, int p_149731_2_, int p_149731_3_, int p_149731_4_, Vec3 p_149731_5_, Vec3 p_149731_6_) + { + this.setBlockBoundsBasedOnState(p_149731_1_, p_149731_2_, p_149731_3_, p_149731_4_); + p_149731_5_ = p_149731_5_.addVector((double)(-p_149731_2_), (double)(-p_149731_3_), (double)(-p_149731_4_)); + p_149731_6_ = p_149731_6_.addVector((double)(-p_149731_2_), (double)(-p_149731_3_), (double)(-p_149731_4_)); + Vec3 vec32 = p_149731_5_.getIntermediateWithXValue(p_149731_6_, this.minX); + Vec3 vec33 = p_149731_5_.getIntermediateWithXValue(p_149731_6_, this.maxX); + Vec3 vec34 = p_149731_5_.getIntermediateWithYValue(p_149731_6_, this.minY); + Vec3 vec35 = p_149731_5_.getIntermediateWithYValue(p_149731_6_, this.maxY); + Vec3 vec36 = p_149731_5_.getIntermediateWithZValue(p_149731_6_, this.minZ); + Vec3 vec37 = p_149731_5_.getIntermediateWithZValue(p_149731_6_, this.maxZ); + + if (!this.isVecInsideYZBounds(vec32)) + { + vec32 = null; + } + + if (!this.isVecInsideYZBounds(vec33)) + { + vec33 = null; + } + + if (!this.isVecInsideXZBounds(vec34)) + { + vec34 = null; + } + + if (!this.isVecInsideXZBounds(vec35)) + { + vec35 = null; + } + + if (!this.isVecInsideXYBounds(vec36)) + { + vec36 = null; + } + + if (!this.isVecInsideXYBounds(vec37)) + { + vec37 = null; + } + + Vec3 vec38 = null; + + if (vec32 != null && (vec38 == null || p_149731_5_.squareDistanceTo(vec32) < p_149731_5_.squareDistanceTo(vec38))) + { + vec38 = vec32; + } + + if (vec33 != null && (vec38 == null || p_149731_5_.squareDistanceTo(vec33) < p_149731_5_.squareDistanceTo(vec38))) + { + vec38 = vec33; + } + + if (vec34 != null && (vec38 == null || p_149731_5_.squareDistanceTo(vec34) < p_149731_5_.squareDistanceTo(vec38))) + { + vec38 = vec34; + } + + if (vec35 != null && (vec38 == null || p_149731_5_.squareDistanceTo(vec35) < p_149731_5_.squareDistanceTo(vec38))) + { + vec38 = vec35; + } + + if (vec36 != null && (vec38 == null || p_149731_5_.squareDistanceTo(vec36) < p_149731_5_.squareDistanceTo(vec38))) + { + vec38 = vec36; + } + + if (vec37 != null && (vec38 == null || p_149731_5_.squareDistanceTo(vec37) < p_149731_5_.squareDistanceTo(vec38))) + { + vec38 = vec37; + } + + if (vec38 == null) + { + return null; + } + else + { + byte b0 = -1; + + if (vec38 == vec32) + { + b0 = 4; + } + + if (vec38 == vec33) + { + b0 = 5; + } + + if (vec38 == vec34) + { + b0 = 0; + } + + if (vec38 == vec35) + { + b0 = 1; + } + + if (vec38 == vec36) + { + b0 = 2; + } + + if (vec38 == vec37) + { + b0 = 3; + } + + return new MovingObjectPosition(p_149731_2_, p_149731_3_, p_149731_4_, b0, vec38.addVector((double)p_149731_2_, (double)p_149731_3_, (double)p_149731_4_)); + } + } + + private boolean isVecInsideYZBounds(Vec3 p_149654_1_) + { + return p_149654_1_ == null ? false : p_149654_1_.yCoord >= this.minY && p_149654_1_.yCoord <= this.maxY && p_149654_1_.zCoord >= this.minZ && p_149654_1_.zCoord <= this.maxZ; + } + + private boolean isVecInsideXZBounds(Vec3 p_149687_1_) + { + return p_149687_1_ == null ? false : p_149687_1_.xCoord >= this.minX && p_149687_1_.xCoord <= this.maxX && p_149687_1_.zCoord >= this.minZ && p_149687_1_.zCoord <= this.maxZ; + } + + private boolean isVecInsideXYBounds(Vec3 p_149661_1_) + { + return p_149661_1_ == null ? false : p_149661_1_.xCoord >= this.minX && p_149661_1_.xCoord <= this.maxX && p_149661_1_.yCoord >= this.minY && p_149661_1_.yCoord <= this.maxY; + } + + public void onBlockDestroyedByExplosion(World p_149723_1_, int p_149723_2_, int p_149723_3_, int p_149723_4_, Explosion p_149723_5_) {} + + public boolean canReplace(World p_149705_1_, int p_149705_2_, int p_149705_3_, int p_149705_4_, int p_149705_5_, ItemStack p_149705_6_) + { + return this.canPlaceBlockOnSide(p_149705_1_, p_149705_2_, p_149705_3_, p_149705_4_, p_149705_5_); + } + + @SideOnly(Side.CLIENT) + public int getRenderBlockPass() + { + return 0; + } + + public boolean canPlaceBlockOnSide(World p_149707_1_, int p_149707_2_, int p_149707_3_, int p_149707_4_, int p_149707_5_) + { + return this.canPlaceBlockAt(p_149707_1_, p_149707_2_, p_149707_3_, p_149707_4_); + } + + public boolean canPlaceBlockAt(World p_149742_1_, int p_149742_2_, int p_149742_3_, int p_149742_4_) + { + return p_149742_1_.getBlock(p_149742_2_, p_149742_3_, p_149742_4_).isReplaceable(p_149742_1_, p_149742_2_, p_149742_3_, p_149742_4_); + } + + public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) + { + return false; + } + + public void onEntityWalking(World p_149724_1_, int p_149724_2_, int p_149724_3_, int p_149724_4_, Entity p_149724_5_) {} + + public int onBlockPlaced(World p_149660_1_, int p_149660_2_, int p_149660_3_, int p_149660_4_, int p_149660_5_, float p_149660_6_, float p_149660_7_, float p_149660_8_, int p_149660_9_) + { + return p_149660_9_; + } + + public void onBlockClicked(World p_149699_1_, int p_149699_2_, int p_149699_3_, int p_149699_4_, EntityPlayer p_149699_5_) {} + + public void velocityToAddToEntity(World p_149640_1_, int p_149640_2_, int p_149640_3_, int p_149640_4_, Entity p_149640_5_, Vec3 p_149640_6_) {} + + public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) {} + + public final double getBlockBoundsMinX() + { + return this.minX; + } + + public final double getBlockBoundsMaxX() + { + return this.maxX; + } + + public final double getBlockBoundsMinY() + { + return this.minY; + } + + public final double getBlockBoundsMaxY() + { + return this.maxY; + } + + public final double getBlockBoundsMinZ() + { + return this.minZ; + } + + public final double getBlockBoundsMaxZ() + { + return this.maxZ; + } + + @SideOnly(Side.CLIENT) + public int getBlockColor() + { + return 16777215; + } + + @SideOnly(Side.CLIENT) + public int getRenderColor(int p_149741_1_) + { + return 16777215; + } + + @SideOnly(Side.CLIENT) + public int colorMultiplier(IBlockAccess p_149720_1_, int p_149720_2_, int p_149720_3_, int p_149720_4_) + { + return 16777215; + } + + public int isProvidingWeakPower(IBlockAccess p_149709_1_, int p_149709_2_, int p_149709_3_, int p_149709_4_, int p_149709_5_) + { + return 0; + } + + public boolean canProvidePower() + { + return false; + } + + public void onEntityCollidedWithBlock(World p_149670_1_, int p_149670_2_, int p_149670_3_, int p_149670_4_, Entity p_149670_5_) {} + + public int isProvidingStrongPower(IBlockAccess p_149748_1_, int p_149748_2_, int p_149748_3_, int p_149748_4_, int p_149748_5_) + { + return 0; + } + + public void setBlockBoundsForItemRender() {} + + public void harvestBlock(World p_149636_1_, EntityPlayer p_149636_2_, int p_149636_3_, int p_149636_4_, int p_149636_5_, int p_149636_6_) + { + p_149636_2_.addStat(StatList.mineBlockStatArray[getIdFromBlock(this)], 1); + p_149636_2_.addExhaustion(0.025F); + + if (this.canSilkHarvest(p_149636_1_, p_149636_2_, p_149636_3_, p_149636_4_, p_149636_5_, p_149636_6_) && EnchantmentHelper.getSilkTouchModifier(p_149636_2_)) + { + ArrayList items = new ArrayList(); + ItemStack itemstack = this.createStackedBlock(p_149636_6_); + + if (itemstack != null) + { + items.add(itemstack); + } + + ForgeEventFactory.fireBlockHarvesting(items, p_149636_1_, this, p_149636_3_, p_149636_4_, p_149636_5_, p_149636_6_, 0, 1.0f, true, p_149636_2_); + for (ItemStack is : items) + { + this.dropBlockAsItem(p_149636_1_, p_149636_3_, p_149636_4_, p_149636_5_, is); + } + } + else + { + harvesters.set(p_149636_2_); + int i1 = EnchantmentHelper.getFortuneModifier(p_149636_2_); + this.dropBlockAsItem(p_149636_1_, p_149636_3_, p_149636_4_, p_149636_5_, p_149636_6_, i1); + harvesters.set(null); + } + } + + protected boolean canSilkHarvest() + { + Integer meta = silk_check_meta.get(); + return this.renderAsNormalBlock() && !this.hasTileEntity(meta == null ? 0 : meta); + } + + protected ItemStack createStackedBlock(int p_149644_1_) + { + int j = 0; + Item item = Item.getItemFromBlock(this); + + if (item != null && item.getHasSubtypes()) + { + j = p_149644_1_; + } + + return new ItemStack(item, 1, j); + } + + public int quantityDroppedWithBonus(int p_149679_1_, Random p_149679_2_) + { + return this.quantityDropped(p_149679_2_); + } + + public boolean canBlockStay(World p_149718_1_, int p_149718_2_, int p_149718_3_, int p_149718_4_) + { + return true; + } + + public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_) {} + + public void onPostBlockPlaced(World p_149714_1_, int p_149714_2_, int p_149714_3_, int p_149714_4_, int p_149714_5_) {} + + public Block setBlockName(String p_149663_1_) + { + this.unlocalizedName = p_149663_1_; + return this; + } + + public String getLocalizedName() + { + return StatCollector.translateToLocal(this.getUnlocalizedName() + ".name"); + } + + public String getUnlocalizedName() + { + return "tile." + this.unlocalizedName; + } + + public boolean onBlockEventReceived(World p_149696_1_, int p_149696_2_, int p_149696_3_, int p_149696_4_, int p_149696_5_, int p_149696_6_) + { + return false; + } + + public boolean getEnableStats() + { + return this.enableStats; + } + + protected Block disableStats() + { + this.enableStats = false; + return this; + } + + public int getMobilityFlag() + { + return this.blockMaterial.getMaterialMobility(); + } + + @SideOnly(Side.CLIENT) + public float getAmbientOcclusionLightValue() + { + return this.isBlockNormalCube() ? 0.2F : 1.0F; + } + + public void onFallenUpon(World p_149746_1_, int p_149746_2_, int p_149746_3_, int p_149746_4_, Entity p_149746_5_, float p_149746_6_) {} + + @SideOnly(Side.CLIENT) + public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) + { + return Item.getItemFromBlock(this); + } + + public int getDamageValue(World p_149643_1_, int p_149643_2_, int p_149643_3_, int p_149643_4_) + { + return this.damageDropped(p_149643_1_.getBlockMetadata(p_149643_2_, p_149643_3_, p_149643_4_)); + } + + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_) + { + p_149666_3_.add(new ItemStack(p_149666_1_, 1, 0)); + } + + public Block setCreativeTab(CreativeTabs p_149647_1_) + { + this.displayOnCreativeTab = p_149647_1_; + return this; + } + + public void onBlockHarvested(World p_149681_1_, int p_149681_2_, int p_149681_3_, int p_149681_4_, int p_149681_5_, EntityPlayer p_149681_6_) {} + + @SideOnly(Side.CLIENT) + public CreativeTabs getCreativeTabToDisplayOn() + { + return this.displayOnCreativeTab; + } + + public void onBlockPreDestroy(World p_149725_1_, int p_149725_2_, int p_149725_3_, int p_149725_4_, int p_149725_5_) {} + + public void fillWithRain(World p_149639_1_, int p_149639_2_, int p_149639_3_, int p_149639_4_) {} + + @SideOnly(Side.CLIENT) + public boolean isFlowerPot() + { + return false; + } + + public boolean func_149698_L() + { + return true; + } + + public boolean canDropFromExplosion(Explosion p_149659_1_) + { + return true; + } + + public boolean isAssociatedBlock(Block p_149667_1_) + { + return this == p_149667_1_; + } + + public static boolean isEqualTo(Block p_149680_0_, Block p_149680_1_) + { + return p_149680_0_ != null && p_149680_1_ != null ? (p_149680_0_ == p_149680_1_ ? true : p_149680_0_.isAssociatedBlock(p_149680_1_)) : false; + } + + public boolean hasComparatorInputOverride() + { + return false; + } + + public int getComparatorInputOverride(World p_149736_1_, int p_149736_2_, int p_149736_3_, int p_149736_4_, int p_149736_5_) + { + return 0; + } + + public Block setBlockTextureName(String p_149658_1_) + { + this.textureName = p_149658_1_; + return this; + } + + @SideOnly(Side.CLIENT) + protected String getTextureName() + { + return this.textureName == null ? "MISSING_ICON_BLOCK_" + getIdFromBlock(this) + "_" + this.unlocalizedName : this.textureName; + } + + @SideOnly(Side.CLIENT) + public IIcon func_149735_b(int p_149735_1_, int p_149735_2_) + { + return this.getIcon(p_149735_1_, p_149735_2_); + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.blockIcon = p_149651_1_.registerIcon(this.getTextureName()); + } + + @SideOnly(Side.CLIENT) + public String getItemIconName() + { + return null; + } + + /* ======================================== FORGE START =====================================*/ + private ThreadLocal harvesters = new ThreadLocal(); + private ThreadLocal silk_check_meta = new ThreadLocal(); + /** + * Get a light value for the block at the specified coordinates, normal ranges are between 0 and 15 + * + * @param world The current world + * @param x X Position + * @param y Y position + * @param z Z position + * @return The light value + */ + public int getLightValue(IBlockAccess world, int x, int y, int z) + { + Block block = world.getBlock(x, y, z); + if (block != this) + { + return block.getLightValue(world, x, y, z); + } + return getLightValue(); + } + + /** + * Checks if a player or entity can use this block to 'climb' like a ladder. + * + * @param world The current world + * @param x X Position + * @param y Y position + * @param z Z position + * @param entity The entity trying to use the ladder, CAN be null. + * @return True if the block should act like a ladder + */ + public boolean isLadder(IBlockAccess world, int x, int y, int z, EntityLivingBase entity) + { + return false; + } + + /** + * Return true if the block is a normal, solid cube. This + * determines indirect power state, entity ejection from blocks, and a few + * others. + * + * @param world The current world + * @param x X Position + * @param y Y position + * @param z Z position + * @return True if the block is a full cube + */ + public boolean isNormalCube(IBlockAccess world, int x, int y, int z) + { + return getMaterial().isOpaque() && renderAsNormalBlock() && !canProvidePower(); + } + + /** + * Checks if the block is a solid face on the given side, used by placement logic. + * + * @param world The current world + * @param x X Position + * @param y Y position + * @param z Z position + * @param side The side to check + * @return True if the block is solid on the specified side. + */ + public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) + { + int meta = world.getBlockMetadata(x, y, z); + + if (this instanceof BlockSlab) + { + return (((meta & 8) == 8 && (side == UP)) || func_149730_j()); + } + else if (this instanceof BlockFarmland) + { + return (side != DOWN && side != UP); + } + else if (this instanceof BlockStairs) + { + boolean flipped = ((meta & 4) != 0); + return ((meta & 3) + side.ordinal() == 5) || (side == UP && flipped); + } + else if (this instanceof BlockSnow) + { + return (meta & 7) == 7; + } + else if (this instanceof BlockHopper && side == UP) + { + return true; + } + else if (this instanceof BlockCompressedPowered) + { + return true; + } + return isNormalCube(world, x, y, z); + } + + /** + * Determines if a new block can be replace the space occupied by this one, + * Used in the player's placement code to make the block act like water, and lava. + * + * @param world The current world + * @param x X Position + * @param y Y position + * @param z Z position + * @return True if the block is replaceable by another block + */ + public boolean isReplaceable(IBlockAccess world, int x, int y, int z) + { + return blockMaterial.isReplaceable(); + } + + /** + * Determines if this block should set fire and deal fire damage + * to entities coming into contact with it. + * + * @param world The current world + * @param x X Position + * @param y Y position + * @param z Z position + * @return True if the block should deal damage + */ + public boolean isBurning(IBlockAccess world, int x, int y, int z) + { + return false; + } + + /** + * Determines this block should be treated as an air block + * by the rest of the code. This method is primarily + * useful for creating pure logic-blocks that will be invisible + * to the player and otherwise interact as air would. + * + * @param world The current world + * @param x X Position + * @param y Y position + * @param z Z position + * @return True if the block considered air + */ + public boolean isAir(IBlockAccess world, int x, int y, int z) + { + return getMaterial() == Material.air; + } + + /** + * Determines if the player can harvest this block, obtaining it's drops when the block is destroyed. + * + * @param player The player damaging the block, may be null + * @param meta The block's current metadata + * @return True to spawn the drops + */ + public boolean canHarvestBlock(EntityPlayer player, int meta) + { + return ForgeHooks.canHarvestBlock(this, player, meta); + } + + /** + * Called when a player removes a block. This is responsible for + * actually destroying the block, and the block is intact at time of call. + * This is called regardless of whether the player can harvest the block or + * not. + * + * Return true if the block is actually destroyed. + * + * Note: When used in multiplayer, this is called on both client and + * server sides! + * + * @param world The current world + * @param player The player damaging the block, may be null + * @param x X Position + * @param y Y position + * @param z Z position + * @return True if the block is actually destroyed. + */ + public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z) + { + return world.setBlockToAir(x, y, z); + } + + /** + * Chance that fire will spread and consume this block. + * 300 being a 100% chance, 0, being a 0% chance. + * + * @param world The current world + * @param x The blocks X position + * @param y The blocks Y position + * @param z The blocks Z position + * @param face The face that the fire is coming from + * @return A number ranging from 0 to 300 relating used to determine if the block will be consumed by fire + */ + public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face) + { + return Blocks.fire.getFlammability(this); + } + + /** + * Called when fire is updating, checks if a block face can catch fire. + * + * + * @param world The current world + * @param x The blocks X position + * @param y The blocks Y position + * @param z The blocks Z position + * @param face The face that the fire is coming from + * @return True if the face can be on fire, false otherwise. + */ + public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face) + { + return getFlammability(world, x, y, z, face) > 0; + } + + /** + * Called when fire is updating on a neighbor block. + * The higher the number returned, the faster fire will spread around this block. + * + * @param world The current world + * @param x The blocks X position + * @param y The blocks Y position + * @param z The blocks Z position + * @param face The face that the fire is coming from + * @return A number that is used to determine the speed of fire growth around the block + */ + public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face) + { + return Blocks.fire.getEncouragement(this); + } + + /** + * Currently only called by fire when it is on top of this block. + * Returning true will prevent the fire from naturally dying during updating. + * Also prevents firing from dying from rain. + * + * @param world The current world + * @param x The blocks X position + * @param y The blocks Y position + * @param z The blocks Z position + * @param metadata The blocks current metadata + * @param side The face that the fire is coming from + * @return True if this block sustains fire, meaning it will never go out. + */ + public boolean isFireSource(World world, int x, int y, int z, ForgeDirection side) + { + if (this == Blocks.netherrack && side == UP) + { + return true; + } + if ((world.provider instanceof WorldProviderEnd) && this == Blocks.bedrock && side == UP) + { + return true; + } + return false; + } + + private boolean isTileProvider = this instanceof ITileEntityProvider; + /** + * Called throughout the code as a replacement for block instanceof BlockContainer + * Moving this to the Block base class allows for mods that wish to extend vanilla + * blocks, and also want to have a tile entity on that block, may. + * + * Return true from this function to specify this block has a tile entity. + * + * @param metadata Metadata of the current block + * @return True if block has a tile entity, false otherwise + */ + public boolean hasTileEntity(int metadata) + { + return isTileProvider; + } + + /** + * Called throughout the code as a replacement for ITileEntityProvider.createNewTileEntity + * Return the same thing you would from that function. + * This will fall back to ITileEntityProvider.createNewTileEntity(World) if this block is a ITileEntityProvider + * + * @param metadata The Metadata of the current block + * @return A instance of a class extending TileEntity + */ + public TileEntity createTileEntity(World world, int metadata) + { + if (isTileProvider) + { + return ((ITileEntityProvider)this).createNewTileEntity(world, metadata); + } + return null; + } + + /** + * Metadata and fortune sensitive version, this replaces the old (int meta, Random rand) + * version in 1.1. + * + * @param meta Blocks Metadata + * @param fortune Current item fortune level + * @param random Random number generator + * @return The number of items to drop + */ + public int quantityDropped(int meta, int fortune, Random random) + { + return quantityDroppedWithBonus(fortune, random); + } + + /** + * This returns a complete list of items dropped from this block. + * + * @param world The current world + * @param x X Position + * @param y Y Position + * @param z Z Position + * @param metadata Current metadata + * @param fortune Breakers fortune level + * @return A ArrayList containing all items this block drops + */ + public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) + { + ArrayList ret = new ArrayList(); + + int count = quantityDropped(metadata, fortune, world.rand); + for(int i = 0; i < count; i++) + { + Item item = getItemDropped(metadata, world.rand, fortune); + if (item != null) + { + ret.add(new ItemStack(item, 1, damageDropped(metadata))); + } + } + return ret; + } + + /** + * Return true from this function if the player with silk touch can harvest this block directly, and not it's normal drops. + * + * @param world The world + * @param player The player doing the harvesting + * @param x X Position + * @param y Y Position + * @param z Z Position + * @param metadata The metadata + * @return True if the block can be directly harvested using silk touch + */ + public boolean canSilkHarvest(World world, EntityPlayer player, int x, int y, int z, int metadata) + { + silk_check_meta.set(metadata);; + boolean ret = this.canSilkHarvest(); + silk_check_meta.set(null); + return ret; + } + + /** + * Determines if a specified mob type can spawn on this block, returning false will + * prevent any mob from spawning on the block. + * + * @param type The Mob Category Type + * @param world The current world + * @param x The X Position + * @param y The Y Position + * @param z The Z Position + * @return True to allow a mob of the specified category to spawn, false to prevent it. + */ + public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) + { + int meta = world.getBlockMetadata(x, y, z); + if (this instanceof BlockSlab) + { + return (((meta & 8) == 8) || func_149730_j()); + } + else if (this instanceof BlockStairs) + { + return ((meta & 4) != 0); + } + return isSideSolid(world, x, y, z, UP); + } + + /** + * Determines if this block is classified as a Bed, Allowing + * players to sleep in it, though the block has to specifically + * perform the sleeping functionality in it's activated event. + * + * @param world The current world + * @param x X Position + * @param y Y Position + * @param z Z Position + * @param player The player or camera entity, null in some cases. + * @return True to treat this as a bed + */ + public boolean isBed(IBlockAccess world, int x, int y, int z, EntityLivingBase player) + { + return this == Blocks.bed; + } + + /** + * Returns the position that the player is moved to upon + * waking up, or respawning at the bed. + * + * @param world The current world + * @param x X Position + * @param y Y Position + * @param z Z Position + * @param player The player or camera entity, null in some cases. + * @return The spawn position + */ + public ChunkCoordinates getBedSpawnPosition(IBlockAccess world, int x, int y, int z, EntityPlayer player) + { + if (world instanceof World) + return BlockBed.func_149977_a((World)world, x, y, z, 0); + return null; + } + + /** + * Called when a user either starts or stops sleeping in the bed. + * + * @param world The current world + * @param x X Position + * @param y Y Position + * @param z Z Position + * @param player The player or camera entity, null in some cases. + * @param occupied True if we are occupying the bed, or false if they are stopping use of the bed + */ + public void setBedOccupied(IBlockAccess world, int x, int y, int z, EntityPlayer player, boolean occupied) + { + if (world instanceof World) + BlockBed.func_149979_a((World)world, x, y, z, occupied); + } + + /** + * Returns the direction of the block. Same values that + * are returned by BlockDirectional + * + * @param world The current world + * @param x X Position + * @param y Y Position + * @param z Z Position + * @return Bed direction + */ + public int getBedDirection(IBlockAccess world, int x, int y, int z) + { + return BlockBed.getDirection(world.getBlockMetadata(x, y, z)); + } + + /** + * Determines if the current block is the foot half of the bed. + * + * @param world The current world + * @param x X Position + * @param y Y Position + * @param z Z Position + * @return True if the current block is the foot side of a bed. + */ + public boolean isBedFoot(IBlockAccess world, int x, int y, int z) + { + return BlockBed.isBlockHeadOfBed(world.getBlockMetadata(x, y, z)); + } + + /** + * Called when a leaf should start its decay process. + * + * @param world The current world + * @param x X Position + * @param y Y Position + * @param z Z Position + */ + public void beginLeavesDecay(World world, int x, int y, int z){} + + /** + * Determines if this block can prevent leaves connected to it from decaying. + * + * @param world The current world + * @param x X Position + * @param y Y Position + * @param z Z Position + * @return true if the presence this block can prevent leaves from decaying. + */ + public boolean canSustainLeaves(IBlockAccess world, int x, int y, int z) + { + return false; + } + + /** + * Determines if this block is considered a leaf block, used to apply the leaf decay and generation system. + * + * @param world The current world + * @param x X Position + * @param y Y Position + * @param z Z Position + * @return true if this block is considered leaves. + */ + public boolean isLeaves(IBlockAccess world, int x, int y, int z) + { + return getMaterial() == Material.leaves; + } + + /** + * Used during tree growth to determine if newly generated leaves can replace this block. + * + * @param world The current world + * @param x X Position + * @param y Y Position + * @param z Z Position + * @return true if this block can be replaced by growing leaves. + */ + public boolean canBeReplacedByLeaves(IBlockAccess world, int x, int y, int z) + { + return !func_149730_j(); + } + + /** + * + * @param world The current world + * @param x X Position + * @param y Y Position + * @param z Z Position + * @return true if the block is wood (logs) + */ + public boolean isWood(IBlockAccess world, int x, int y, int z) + { + return false; + } + + /** + * Determines if the current block is replaceable by Ore veins during world generation. + * + * @param world The current world + * @param x X Position + * @param y Y Position + * @param z Z Position + * @param target The generic target block the gen is looking for, Standards define stone + * for overworld generation, and neatherack for the nether. + * @return True to allow this block to be replaced by a ore + */ + public boolean isReplaceableOreGen(World world, int x, int y, int z, Block target) + { + return this == target; + } + + /** + * Location sensitive version of getExplosionRestance + * + * @param par1Entity The entity that caused the explosion + * @param world The current world + * @param x X Position + * @param y Y Position + * @param z Z Position + * @param explosionX Explosion source X Position + * @param explosionY Explosion source X Position + * @param explosionZ Explosion source X Position + * @return The amount of the explosion absorbed. + */ + public float getExplosionResistance(Entity par1Entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ) + { + return getExplosionResistance(par1Entity); + } + + /** + * Called when the block is destroyed by an explosion. + * Useful for allowing the block to take into account tile entities, + * metadata, etc. when exploded, before it is removed. + * + * @param world The current world + * @param x X Position + * @param y Y Position + * @param z Z Position + * @param Explosion The explosion instance affecting the block + */ + public void onBlockExploded(World world, int x, int y, int z, Explosion explosion) + { + world.setBlockToAir(x, y, z); + onBlockDestroyedByExplosion(world, x, y, z, explosion); + } + + /** + * Determine if this block can make a redstone connection on the side provided, + * Useful to control which sides are inputs and outputs for redstone wires. + * + * Side: + * -1: UP + * 0: NORTH + * 1: EAST + * 2: SOUTH + * 3: WEST + * + * @param world The current world + * @param x X Position + * @param y Y Position + * @param z Z Position + * @param side The side that is trying to make the connection + * @return True to make the connection + */ + public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side) + { + return canProvidePower() && side != -1; + } + + /** + * Determines if a torch can be placed on the top surface of this block. + * Useful for creating your own block that torches can be on, such as fences. + * + * @param world The current world + * @param x X Position + * @param y Y Position + * @param z Z Position + * @return True to allow the torch to be placed + */ + public boolean canPlaceTorchOnTop(World world, int x, int y, int z) + { + if (isSideSolid(world, x, y, z, UP)) + { + return true; + } + else + { + return this == Blocks.fence || this == Blocks.nether_brick_fence || this == Blocks.glass || this == Blocks.cobblestone_wall; + } + } + + /** + * Determines if this block should render in this pass. + * + * @param pass The pass in question + * @return True to render + */ + public boolean canRenderInPass(int pass) + { + return pass == getRenderBlockPass(); + } + + /** + * Called when a user uses the creative pick block button on this block + * + * @param target The full target the player is looking at + * @return A ItemStack to add to the player's inventory, Null if nothing should be added. + */ + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) + { + Item item = getItem(world, x, y, z); + + if (item == null) + { + return null; + } + + Block block = item instanceof ItemBlock && !isFlowerPot() ? Block.getBlockFromItem(item) : this; + return new ItemStack(item, 1, block.getDamageValue(world, x, y, z)); + } + + /** + * Used by getTopSolidOrLiquidBlock while placing biome decorations, villages, etc + * Also used to determine if the player can spawn on this block. + * + * @return False to disallow spawning + */ + public boolean isFoliage(IBlockAccess world, int x, int y, int z) + { + return false; + } + + /** + * Spawn a digging particle effect in the world, this is a wrapper + * around EffectRenderer.addBlockHitEffects to allow the block more + * control over the particles. Useful when you have entirely different + * texture sheets for different sides/locations in the world. + * + * @param world The current world + * @param target The target the player is looking at {x/y/z/side/sub} + * @param effectRenderer A reference to the current effect renderer. + * @return True to prevent vanilla digging particles form spawning. + */ + @SideOnly(Side.CLIENT) + public boolean addHitEffects(World worldObj, MovingObjectPosition target, EffectRenderer effectRenderer) + { + return false; + } + + /** + * Spawn particles for when the block is destroyed. Due to the nature + * of how this is invoked, the x/y/z locations are not always guaranteed + * to host your block. So be sure to do proper sanity checks before assuming + * that the location is this block. + * + * @param world The current world + * @param x X position to spawn the particle + * @param y Y position to spawn the particle + * @param z Z position to spawn the particle + * @param meta The metadata for the block before it was destroyed. + * @param effectRenderer A reference to the current effect renderer. + * @return True to prevent vanilla break particles from spawning. + */ + @SideOnly(Side.CLIENT) + public boolean addDestroyEffects(World world, int x, int y, int z, int meta, EffectRenderer effectRenderer) + { + return false; + } + + /** + * Determines if this block can support the passed in plant, allowing it to be planted and grow. + * Some examples: + * Reeds check if its a reed, or if its sand/dirt/grass and adjacent to water + * Cacti checks if its a cacti, or if its sand + * Nether types check for soul sand + * Crops check for tilled soil + * Caves check if it's a solid surface + * Plains check if its grass or dirt + * Water check if its still water + * + * @param world The current world + * @param x X Position + * @param y Y Position + * @param z Z position + * @param direction The direction relative to the given position the plant wants to be, typically its UP + * @param plantable The plant that wants to check + * @return True to allow the plant to be planted/stay. + */ + public boolean canSustainPlant(IBlockAccess world, int x, int y, int z, ForgeDirection direction, IPlantable plantable) + { + Block plant = plantable.getPlant(world, x, y + 1, z); + EnumPlantType plantType = plantable.getPlantType(world, x, y + 1, z); + + if (plant == Blocks.cactus && this == Blocks.cactus) + { + return true; + } + + if (plant == Blocks.reeds && this == Blocks.reeds) + { + return true; + } + + if (plantable instanceof BlockBush && ((BlockBush)plantable).canPlaceBlockOn(this)) + { + return true; + } + + switch (plantType) + { + case Desert: return this == Blocks.sand; + case Nether: return this == Blocks.soul_sand; + case Crop: return this == Blocks.farmland; + case Cave: return isSideSolid(world, x, y, z, UP); + case Plains: return this == Blocks.grass || this == Blocks.dirt; + case Water: return world.getBlock(x, y, z).getMaterial() == Material.water && world.getBlockMetadata(x, y, z) == 0; + case Beach: + boolean isBeach = this == Blocks.grass || this == Blocks.dirt || this == Blocks.sand; + boolean hasWater = (world.getBlock(x - 1, y, z ).getMaterial() == Material.water || + world.getBlock(x + 1, y, z ).getMaterial() == Material.water || + world.getBlock(x, y, z - 1).getMaterial() == Material.water || + world.getBlock(x, y, z + 1).getMaterial() == Material.water); + return isBeach && hasWater; + } + + return false; + } + + /** + * Called when a plant grows on this block, only implemented for saplings using the WorldGen*Trees classes right now. + * Modder may implement this for custom plants. + * This does not use ForgeDirection, because large/huge trees can be located in non-representable direction, + * so the source location is specified. + * Currently this just changes the block to dirt if it was grass. + * + * Note: This happens DURING the generation, the generation may not be complete when this is called. + * + * @param world Current world + * @param x Soil X + * @param y Soil Y + * @param z Soil Z + * @param sourceX Plant growth location X + * @param sourceY Plant growth location Y + * @param sourceZ Plant growth location Z + */ + public void onPlantGrow(World world, int x, int y, int z, int sourceX, int sourceY, int sourceZ) + { + if (this == Blocks.grass || this == Blocks.farmland) + { + world.setBlock(x, y, z, Blocks.dirt, 0, 2); + } + } + + /** + * Checks if this soil is fertile, typically this means that growth rates + * of plants on this soil will be slightly sped up. + * Only vanilla case is tilledField when it is within range of water. + * + * @param world The current world + * @param x X Position + * @param y Y Position + * @param z Z position + * @return True if the soil should be considered fertile. + */ + public boolean isFertile(World world, int x, int y, int z) + { + if (this == Blocks.farmland) + { + return world.getBlockMetadata(x, y, z) > 0; + } + + return false; + } + + /** + * Location aware and overrideable version of the lightOpacity array, + * return the number to subtract from the light value when it passes through this block. + * + * This is not guaranteed to have the tile entity in place before this is called, so it is + * Recommended that you have your tile entity call relight after being placed if you + * rely on it for light info. + * + * @param world The current world + * @param x X Position + * @param y Y Position + * @param z Z position + * @return The amount of light to block, 0 for air, 255 for fully opaque. + */ + public int getLightOpacity(IBlockAccess world, int x, int y, int z) + { + return getLightOpacity(); + } + + /** + * Determines if this block is can be destroyed by the specified entities normal behavior. + * + * @param world The current world + * @param x X Position + * @param y Y Position + * @param z Z position + * @return True to allow the ender dragon to destroy this block + */ + public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) + { + if (entity instanceof EntityWither) + { + return this != Blocks.bedrock && this != Blocks.end_portal && this != Blocks.end_portal_frame && this != Blocks.command_block; + } + else if (entity instanceof EntityDragon) + { + return this != Blocks.obsidian && this != Blocks.end_stone && this != Blocks.bedrock; + } + + return true; + } + + /** + * Determines if this block can be used as the base of a beacon. + * + * @param world The current world + * @param x X Position + * @param y Y Position + * @param z Z position + * @param beaconX Beacons X Position + * @param beaconY Beacons Y Position + * @param beaconZ Beacons Z Position + * @return True, to support the beacon, and make it active with this block. + */ + public boolean isBeaconBase(IBlockAccess worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ) + { + return this == Blocks.emerald_block || this == Blocks.gold_block || this == Blocks.diamond_block || this == Blocks.iron_block; + } + + /** + * Rotate the block. For vanilla blocks this rotates around the axis passed in (generally, it should be the "face" that was hit). + * Note: for mod blocks, this is up to the block and modder to decide. It is not mandated that it be a rotation around the + * face, but could be a rotation to orient *to* that face, or a visiting of possible rotations. + * The method should return true if the rotation was successful though. + * + * @param worldObj The world + * @param x X position + * @param y Y position + * @param z Z position + * @param axis The axis to rotate around + * @return True if the rotation was successful, False if the rotation failed, or is not possible + */ + public boolean rotateBlock(World worldObj, int x, int y, int z, ForgeDirection axis) + { + return RotationHelper.rotateVanillaBlock(this, worldObj, x, y, z, axis); + } + + /** + * Get the rotations that can apply to the block at the specified coordinates. Null means no rotations are possible. + * Note, this is up to the block to decide. It may not be accurate or representative. + * @param worldObj The world + * @param x X position + * @param y Y position + * @param z Z position + * @return An array of valid axes to rotate around, or null for none or unknown + */ + public ForgeDirection[] getValidRotations(World worldObj, int x, int y, int z) + { + return RotationHelper.getValidVanillaBlockRotations(this); + } + + /** + * Determines the amount of enchanting power this block can provide to an enchanting table. + * @param world The World + * @param x X position + * @param y Y position + * @param z Z position + * @return The amount of enchanting power this block produces. + */ + public float getEnchantPowerBonus(World world, int x, int y, int z) + { + return this == Blocks.bookshelf ? 1 : 0; + } + + /** + * Common way to recolour a block with an external tool + * @param world The world + * @param x X + * @param y Y + * @param z Z + * @param side The side hit with the colouring tool + * @param colour The colour to change to + * @return If the recolouring was successful + */ + public boolean recolourBlock(World world, int x, int y, int z, ForgeDirection side, int colour) + { + if (this == Blocks.wool) + { + int meta = world.getBlockMetadata(x, y, z); + if (meta != colour) + { + world.setBlockMetadataWithNotify(x, y, z, colour, 3); + return true; + } + } + return false; + } + + /** + * Gathers how much experience this block drops when broken. + * + * @param world The world + * @param metadata + * @param fortune + * @return Amount of XP from breaking this block. + */ + public int getExpDrop(IBlockAccess world, int metadata, int fortune) + { + return 0; + } + + /** + * Called when a tile entity on a side of this block changes is created or is destroyed. + * @param world The world + * @param x The x position of this block instance + * @param y The y position of this block instance + * @param z The z position of this block instance + * @param tileX The x position of the tile that changed + * @param tileY The y position of the tile that changed + * @param tileZ The z position of the tile that changed + */ + public void onNeighborChange(IBlockAccess world, int x, int y, int z, int tileX, int tileY, int tileZ) + { + } + + /** + * Called to determine whether to allow the a block to handle its own indirect power rather than using the default rules. + * @param world The world + * @param x The x position of this block instance + * @param y The y position of this block instance + * @param z The z position of this block instance + * @param side The INPUT side of the block to be powered - ie the opposite of this block's output side + * @return Whether Block#isProvidingWeakPower should be called when determining indirect power + */ + public boolean shouldCheckWeakPower(IBlockAccess world, int x, int y, int z, int side) + { + return isNormalCube(); + } + + /** + * If this block should be notified of weak changes. + * Weak changes are changes 1 block away through a solid block. + * Similar to comparators. + * + * @param world The current world + * @param x X Position + * @param y Y position + * @param z Z position + * @param side The side to check + * @return true To be notified of changes + */ + public boolean getWeakChanges(IBlockAccess world, int x, int y, int z) + { + return false; + } + + private String[] harvestTool = new String[16]; + private int[] harvestLevel = new int[]{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}; + /** + * Sets or removes the tool and level required to harvest this block. + * + * @param toolClass Class + * @param level Harvest level: + * Wood: 0 + * Stone: 1 + * Iton: 2 + * Diamond: 3 + * Gold: 0 + */ + public void setHarvestLevel(String toolClass, int level) + { + for (int m = 0; m < 16; m++) + { + setHarvestLevel(toolClass, level, m); + } + } + + /** + * Sets or removes the tool and level required to harvest this block. + * + * @param toolClass Class + * @param level Harvest level: + * Wood: 0 + * Stone: 1 + * Iton: 2 + * Diamond: 3 + * Gold: 0 + * @param metadata The specific metadata to set + */ + public void setHarvestLevel(String toolClass, int level, int metadata) + { + this.harvestTool[metadata] = toolClass; + this.harvestLevel[metadata] = level; + } + + /** + * Queries the class of tool required to harvest this block, if null is returned + * we assume that anything can harvest this block. + * + * @param metadata + * @return + */ + public String getHarvestTool(int metadata) + { + return harvestTool[metadata]; + } + + /** + * Queries the harvest level of this item stack for the specifred tool class, + * Returns -1 if this tool is not of the specified type + * + * @param stack This item stack instance + * @return Harvest level, or -1 if not the specified tool type. + */ + public int getHarvestLevel(int metadata) + { + return harvestLevel[metadata]; + } + + /** + * Checks if the specified tool type is efficient on this block, + * meaning that it digs at full speed. + * + * @param type + * @param metadata + * @return + */ + public boolean isToolEffective(String type, int metadata) + { + if ("pickaxe".equals(type) && (this == Blocks.redstone_ore || this == Blocks.lit_redstone_ore || this == Blocks.obsidian)) + return false; + if (harvestTool[metadata] == null) return false; + return harvestTool[metadata].equals(type); + } + /* ========================================= FORGE END ======================================*/ + + public static class SoundType + { + public final String soundName; + public final float volume; + public final float frequency; + private static final String __OBFID = "CL_00000203"; + + public SoundType(String p_i45393_1_, float p_i45393_2_, float p_i45393_3_) + { + this.soundName = p_i45393_1_; + this.volume = p_i45393_2_; + this.frequency = p_i45393_3_; + } + + public float getVolume() + { + return this.volume; + } + + public float getPitch() + { + return this.frequency; + } + + public String getBreakSound() + { + return "dig." + this.soundName; + } + + public String getStepResourcePath() + { + return "step." + this.soundName; + } + + public String func_150496_b() + { + return this.getBreakSound(); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockAir.java b/src/main/java/net/minecraft/block/BlockAir.java new file mode 100644 index 0000000..144048f --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockAir.java @@ -0,0 +1,37 @@ +package net.minecraft.block; + +import net.minecraft.block.material.Material; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; + +public class BlockAir extends Block +{ + private static final String __OBFID = "CL_00000190"; + + protected BlockAir() + { + super(Material.air); + } + + public int getRenderType() + { + return -1; + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) + { + return null; + } + + public boolean isOpaqueCube() + { + return false; + } + + public boolean canCollideCheck(int p_149678_1_, boolean p_149678_2_) + { + return false; + } + + public void dropBlockAsItemWithChance(World p_149690_1_, int p_149690_2_, int p_149690_3_, int p_149690_4_, int p_149690_5_, float p_149690_6_, int p_149690_7_) {} +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockAnvil.java b/src/main/java/net/minecraft/block/BlockAnvil.java new file mode 100644 index 0000000..f433067 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockAnvil.java @@ -0,0 +1,160 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityFallingBlock; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockAnvil extends BlockFalling +{ + public static final String[] anvilDamageNames = new String[] {"intact", "slightlyDamaged", "veryDamaged"}; + private static final String[] anvilIconNames = new String[] {"anvil_top_damaged_0", "anvil_top_damaged_1", "anvil_top_damaged_2"}; + @SideOnly(Side.CLIENT) + public int anvilRenderSide; + @SideOnly(Side.CLIENT) + private IIcon[] anvilIcons; + private static final String __OBFID = "CL_00000192"; + + protected BlockAnvil() + { + super(Material.anvil); + this.setLightOpacity(0); + this.setCreativeTab(CreativeTabs.tabDecorations); + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public boolean isOpaqueCube() + { + return false; + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + if (this.anvilRenderSide == 3 && p_149691_1_ == 1) + { + int k = (p_149691_2_ >> 2) % this.anvilIcons.length; + return this.anvilIcons[k]; + } + else + { + return this.blockIcon; + } + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.blockIcon = p_149651_1_.registerIcon("anvil_base"); + this.anvilIcons = new IIcon[anvilIconNames.length]; + + for (int i = 0; i < this.anvilIcons.length; ++i) + { + this.anvilIcons[i] = p_149651_1_.registerIcon(anvilIconNames[i]); + } + } + + public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_) + { + int l = MathHelper.floor_double((double)(p_149689_5_.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + int i1 = p_149689_1_.getBlockMetadata(p_149689_2_, p_149689_3_, p_149689_4_) >> 2; + ++l; + l %= 4; + + if (l == 0) + { + p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, 2 | i1 << 2, 2); + } + + if (l == 1) + { + p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, 3 | i1 << 2, 2); + } + + if (l == 2) + { + p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, 0 | i1 << 2, 2); + } + + if (l == 3) + { + p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, 1 | i1 << 2, 2); + } + } + + public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) + { + if (p_149727_1_.isRemote) + { + return true; + } + else + { + p_149727_5_.displayGUIAnvil(p_149727_2_, p_149727_3_, p_149727_4_); + return true; + } + } + + public int getRenderType() + { + return 35; + } + + public int damageDropped(int p_149692_1_) + { + return p_149692_1_ >> 2; + } + + public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) + { + int l = p_149719_1_.getBlockMetadata(p_149719_2_, p_149719_3_, p_149719_4_) & 3; + + if (l != 3 && l != 1) + { + this.setBlockBounds(0.125F, 0.0F, 0.0F, 0.875F, 1.0F, 1.0F); + } + else + { + this.setBlockBounds(0.0F, 0.0F, 0.125F, 1.0F, 1.0F, 0.875F); + } + } + + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_) + { + p_149666_3_.add(new ItemStack(p_149666_1_, 1, 0)); + p_149666_3_.add(new ItemStack(p_149666_1_, 1, 1)); + p_149666_3_.add(new ItemStack(p_149666_1_, 1, 2)); + } + + protected void func_149829_a(EntityFallingBlock p_149829_1_) + { + p_149829_1_.func_145806_a(true); + } + + public void func_149828_a(World p_149828_1_, int p_149828_2_, int p_149828_3_, int p_149828_4_, int p_149828_5_) + { + p_149828_1_.playAuxSFX(1022, p_149828_2_, p_149828_3_, p_149828_4_, 0); + } + + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) + { + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockBasePressurePlate.java b/src/main/java/net/minecraft/block/BlockBasePressurePlate.java new file mode 100644 index 0000000..4a894e0 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockBasePressurePlate.java @@ -0,0 +1,209 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public abstract class BlockBasePressurePlate extends Block +{ + private String field_150067_a; + private static final String __OBFID = "CL_00000194"; + + protected BlockBasePressurePlate(String p_i45387_1_, Material p_i45387_2_) + { + super(p_i45387_2_); + this.field_150067_a = p_i45387_1_; + this.setCreativeTab(CreativeTabs.tabRedstone); + this.setTickRandomly(true); + this.func_150063_b(this.func_150066_d(15)); + } + + public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) + { + this.func_150063_b(p_149719_1_.getBlockMetadata(p_149719_2_, p_149719_3_, p_149719_4_)); + } + + protected void func_150063_b(int p_150063_1_) + { + boolean flag = this.func_150060_c(p_150063_1_) > 0; + float f = 0.0625F; + + if (flag) + { + this.setBlockBounds(f, 0.0F, f, 1.0F - f, 0.03125F, 1.0F - f); + } + else + { + this.setBlockBounds(f, 0.0F, f, 1.0F - f, 0.0625F, 1.0F - f); + } + } + + public int tickRate(World p_149738_1_) + { + return 20; + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) + { + return null; + } + + public boolean isOpaqueCube() + { + return false; + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public boolean getBlocksMovement(IBlockAccess p_149655_1_, int p_149655_2_, int p_149655_3_, int p_149655_4_) + { + return true; + } + + public boolean canPlaceBlockAt(World p_149742_1_, int p_149742_2_, int p_149742_3_, int p_149742_4_) + { + return World.doesBlockHaveSolidTopSurface(p_149742_1_, p_149742_2_, p_149742_3_ - 1, p_149742_4_) || BlockFence.func_149825_a(p_149742_1_.getBlock(p_149742_2_, p_149742_3_ - 1, p_149742_4_)); + } + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) + { + boolean flag = false; + + if (!World.doesBlockHaveSolidTopSurface(p_149695_1_, p_149695_2_, p_149695_3_ - 1, p_149695_4_) && !BlockFence.func_149825_a(p_149695_1_.getBlock(p_149695_2_, p_149695_3_ - 1, p_149695_4_))) + { + flag = true; + } + + if (flag) + { + this.dropBlockAsItem(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, p_149695_1_.getBlockMetadata(p_149695_2_, p_149695_3_, p_149695_4_), 0); + p_149695_1_.setBlockToAir(p_149695_2_, p_149695_3_, p_149695_4_); + } + } + + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) + { + if (!p_149674_1_.isRemote) + { + int l = this.func_150060_c(p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_)); + + if (l > 0) + { + this.func_150062_a(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, l); + } + } + } + + public void onEntityCollidedWithBlock(World p_149670_1_, int p_149670_2_, int p_149670_3_, int p_149670_4_, Entity p_149670_5_) + { + if (!p_149670_1_.isRemote) + { + int l = this.func_150060_c(p_149670_1_.getBlockMetadata(p_149670_2_, p_149670_3_, p_149670_4_)); + + if (l == 0) + { + this.func_150062_a(p_149670_1_, p_149670_2_, p_149670_3_, p_149670_4_, l); + } + } + } + + protected void func_150062_a(World p_150062_1_, int p_150062_2_, int p_150062_3_, int p_150062_4_, int p_150062_5_) + { + int i1 = this.func_150065_e(p_150062_1_, p_150062_2_, p_150062_3_, p_150062_4_); + boolean flag = p_150062_5_ > 0; + boolean flag1 = i1 > 0; + + if (p_150062_5_ != i1) + { + p_150062_1_.setBlockMetadataWithNotify(p_150062_2_, p_150062_3_, p_150062_4_, this.func_150066_d(i1), 2); + this.func_150064_a_(p_150062_1_, p_150062_2_, p_150062_3_, p_150062_4_); + p_150062_1_.markBlockRangeForRenderUpdate(p_150062_2_, p_150062_3_, p_150062_4_, p_150062_2_, p_150062_3_, p_150062_4_); + } + + if (!flag1 && flag) + { + p_150062_1_.playSoundEffect((double)p_150062_2_ + 0.5D, (double)p_150062_3_ + 0.1D, (double)p_150062_4_ + 0.5D, "random.click", 0.3F, 0.5F); + } + else if (flag1 && !flag) + { + p_150062_1_.playSoundEffect((double)p_150062_2_ + 0.5D, (double)p_150062_3_ + 0.1D, (double)p_150062_4_ + 0.5D, "random.click", 0.3F, 0.6F); + } + + if (flag1) + { + p_150062_1_.scheduleBlockUpdate(p_150062_2_, p_150062_3_, p_150062_4_, this, this.tickRate(p_150062_1_)); + } + } + + protected AxisAlignedBB func_150061_a(int p_150061_1_, int p_150061_2_, int p_150061_3_) + { + float f = 0.125F; + return AxisAlignedBB.getAABBPool().getAABB((double)((float)p_150061_1_ + f), (double)p_150061_2_, (double)((float)p_150061_3_ + f), (double)((float)(p_150061_1_ + 1) - f), (double)p_150061_2_ + 0.25D, (double)((float)(p_150061_3_ + 1) - f)); + } + + public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) + { + if (this.func_150060_c(p_149749_6_) > 0) + { + this.func_150064_a_(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_); + } + + super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_); + } + + protected void func_150064_a_(World p_150064_1_, int p_150064_2_, int p_150064_3_, int p_150064_4_) + { + p_150064_1_.notifyBlocksOfNeighborChange(p_150064_2_, p_150064_3_, p_150064_4_, this); + p_150064_1_.notifyBlocksOfNeighborChange(p_150064_2_, p_150064_3_ - 1, p_150064_4_, this); + } + + public int isProvidingWeakPower(IBlockAccess p_149709_1_, int p_149709_2_, int p_149709_3_, int p_149709_4_, int p_149709_5_) + { + return this.func_150060_c(p_149709_1_.getBlockMetadata(p_149709_2_, p_149709_3_, p_149709_4_)); + } + + public int isProvidingStrongPower(IBlockAccess p_149748_1_, int p_149748_2_, int p_149748_3_, int p_149748_4_, int p_149748_5_) + { + return p_149748_5_ == 1 ? this.func_150060_c(p_149748_1_.getBlockMetadata(p_149748_2_, p_149748_3_, p_149748_4_)) : 0; + } + + public boolean canProvidePower() + { + return true; + } + + public void setBlockBoundsForItemRender() + { + float f = 0.5F; + float f1 = 0.125F; + float f2 = 0.5F; + this.setBlockBounds(0.5F - f, 0.5F - f1, 0.5F - f2, 0.5F + f, 0.5F + f1, 0.5F + f2); + } + + public int getMobilityFlag() + { + return 1; + } + + protected abstract int func_150065_e(World var1, int var2, int var3, int var4); + + protected abstract int func_150060_c(int var1); + + protected abstract int func_150066_d(int var1); + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.blockIcon = p_149651_1_.registerIcon(this.field_150067_a); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockBeacon.java b/src/main/java/net/minecraft/block/BlockBeacon.java new file mode 100644 index 0000000..cc1b8df --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockBeacon.java @@ -0,0 +1,80 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityBeacon; +import net.minecraft.world.World; + +public class BlockBeacon extends BlockContainer +{ + private static final String __OBFID = "CL_00000197"; + + public BlockBeacon() + { + super(Material.glass); + this.setHardness(3.0F); + this.setCreativeTab(CreativeTabs.tabMisc); + } + + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) + { + return new TileEntityBeacon(); + } + + public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) + { + if (p_149727_1_.isRemote) + { + return true; + } + else + { + TileEntityBeacon tileentitybeacon = (TileEntityBeacon)p_149727_1_.getTileEntity(p_149727_2_, p_149727_3_, p_149727_4_); + + if (tileentitybeacon != null) + { + p_149727_5_.func_146104_a(tileentitybeacon); + } + + return true; + } + } + + public boolean isOpaqueCube() + { + return false; + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public int getRenderType() + { + return 34; + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + super.registerBlockIcons(p_149651_1_); + } + + public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_) + { + super.onBlockPlacedBy(p_149689_1_, p_149689_2_, p_149689_3_, p_149689_4_, p_149689_5_, p_149689_6_); + + if (p_149689_6_.hasDisplayName()) + { + ((TileEntityBeacon)p_149689_1_.getTileEntity(p_149689_2_, p_149689_3_, p_149689_4_)).func_145999_a(p_149689_6_.getDisplayName()); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockBed.java b/src/main/java/net/minecraft/block/BlockBed.java new file mode 100644 index 0000000..0def831 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockBed.java @@ -0,0 +1,307 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Iterator; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.Direction; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; + +public class BlockBed extends BlockDirectional +{ + public static final int[][] field_149981_a = new int[][] {{0, 1}, { -1, 0}, {0, -1}, {1, 0}}; + @SideOnly(Side.CLIENT) + private IIcon[] field_149980_b; + @SideOnly(Side.CLIENT) + private IIcon[] field_149982_M; + @SideOnly(Side.CLIENT) + private IIcon[] field_149983_N; + private static final String __OBFID = "CL_00000198"; + + public BlockBed() + { + super(Material.cloth); + this.func_149978_e(); + } + + public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) + { + if (p_149727_1_.isRemote) + { + return true; + } + else + { + int i1 = p_149727_1_.getBlockMetadata(p_149727_2_, p_149727_3_, p_149727_4_); + + if (!isBlockHeadOfBed(i1)) + { + int j1 = getDirection(i1); + p_149727_2_ += field_149981_a[j1][0]; + p_149727_4_ += field_149981_a[j1][1]; + + if (p_149727_1_.getBlock(p_149727_2_, p_149727_3_, p_149727_4_) != this) + { + return true; + } + + i1 = p_149727_1_.getBlockMetadata(p_149727_2_, p_149727_3_, p_149727_4_); + } + + if (p_149727_1_.provider.canRespawnHere() && p_149727_1_.getBiomeGenForCoords(p_149727_2_, p_149727_4_) != BiomeGenBase.hell) + { + if (func_149976_c(i1)) + { + EntityPlayer entityplayer1 = null; + Iterator iterator = p_149727_1_.playerEntities.iterator(); + + while (iterator.hasNext()) + { + EntityPlayer entityplayer2 = (EntityPlayer)iterator.next(); + + if (entityplayer2.isPlayerSleeping()) + { + ChunkCoordinates chunkcoordinates = entityplayer2.playerLocation; + + if (chunkcoordinates.posX == p_149727_2_ && chunkcoordinates.posY == p_149727_3_ && chunkcoordinates.posZ == p_149727_4_) + { + entityplayer1 = entityplayer2; + } + } + } + + if (entityplayer1 != null) + { + p_149727_5_.addChatComponentMessage(new ChatComponentTranslation("tile.bed.occupied", new Object[0])); + return true; + } + + func_149979_a(p_149727_1_, p_149727_2_, p_149727_3_, p_149727_4_, false); + } + + EntityPlayer.EnumStatus enumstatus = p_149727_5_.sleepInBedAt(p_149727_2_, p_149727_3_, p_149727_4_); + + if (enumstatus == EntityPlayer.EnumStatus.OK) + { + func_149979_a(p_149727_1_, p_149727_2_, p_149727_3_, p_149727_4_, true); + return true; + } + else + { + if (enumstatus == EntityPlayer.EnumStatus.NOT_POSSIBLE_NOW) + { + p_149727_5_.addChatComponentMessage(new ChatComponentTranslation("tile.bed.noSleep", new Object[0])); + } + else if (enumstatus == EntityPlayer.EnumStatus.NOT_SAFE) + { + p_149727_5_.addChatComponentMessage(new ChatComponentTranslation("tile.bed.notSafe", new Object[0])); + } + + return true; + } + } + else + { + double d2 = (double)p_149727_2_ + 0.5D; + double d0 = (double)p_149727_3_ + 0.5D; + double d1 = (double)p_149727_4_ + 0.5D; + p_149727_1_.setBlockToAir(p_149727_2_, p_149727_3_, p_149727_4_); + int k1 = getDirection(i1); + p_149727_2_ += field_149981_a[k1][0]; + p_149727_4_ += field_149981_a[k1][1]; + + if (p_149727_1_.getBlock(p_149727_2_, p_149727_3_, p_149727_4_) == this) + { + p_149727_1_.setBlockToAir(p_149727_2_, p_149727_3_, p_149727_4_); + d2 = (d2 + (double)p_149727_2_ + 0.5D) / 2.0D; + d0 = (d0 + (double)p_149727_3_ + 0.5D) / 2.0D; + d1 = (d1 + (double)p_149727_4_ + 0.5D) / 2.0D; + } + + p_149727_1_.newExplosion((Entity)null, (double)((float)p_149727_2_ + 0.5F), (double)((float)p_149727_3_ + 0.5F), (double)((float)p_149727_4_ + 0.5F), 5.0F, true, true); + return true; + } + } + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + if (p_149691_1_ == 0) + { + return Blocks.planks.getBlockTextureFromSide(p_149691_1_); + } + else + { + int k = getDirection(p_149691_2_); + int l = Direction.bedDirection[k][p_149691_1_]; + int i1 = isBlockHeadOfBed(p_149691_2_) ? 1 : 0; + return (i1 != 1 || l != 2) && (i1 != 0 || l != 3) ? (l != 5 && l != 4 ? this.field_149983_N[i1] : this.field_149982_M[i1]) : this.field_149980_b[i1]; + } + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.field_149983_N = new IIcon[] {p_149651_1_.registerIcon(this.getTextureName() + "_feet_top"), p_149651_1_.registerIcon(this.getTextureName() + "_head_top")}; + this.field_149980_b = new IIcon[] {p_149651_1_.registerIcon(this.getTextureName() + "_feet_end"), p_149651_1_.registerIcon(this.getTextureName() + "_head_end")}; + this.field_149982_M = new IIcon[] {p_149651_1_.registerIcon(this.getTextureName() + "_feet_side"), p_149651_1_.registerIcon(this.getTextureName() + "_head_side")}; + } + + public int getRenderType() + { + return 14; + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public boolean isOpaqueCube() + { + return false; + } + + public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) + { + this.func_149978_e(); + } + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) + { + int l = p_149695_1_.getBlockMetadata(p_149695_2_, p_149695_3_, p_149695_4_); + int i1 = getDirection(l); + + if (isBlockHeadOfBed(l)) + { + if (p_149695_1_.getBlock(p_149695_2_ - field_149981_a[i1][0], p_149695_3_, p_149695_4_ - field_149981_a[i1][1]) != this) + { + p_149695_1_.setBlockToAir(p_149695_2_, p_149695_3_, p_149695_4_); + } + } + else if (p_149695_1_.getBlock(p_149695_2_ + field_149981_a[i1][0], p_149695_3_, p_149695_4_ + field_149981_a[i1][1]) != this) + { + p_149695_1_.setBlockToAir(p_149695_2_, p_149695_3_, p_149695_4_); + + if (!p_149695_1_.isRemote) + { + this.dropBlockAsItem(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, l, 0); + } + } + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return isBlockHeadOfBed(p_149650_1_) ? Item.getItemById(0) : Items.bed; + } + + private void func_149978_e() + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5625F, 1.0F); + } + + public static boolean isBlockHeadOfBed(int p_149975_0_) + { + return (p_149975_0_ & 8) != 0; + } + + public static boolean func_149976_c(int p_149976_0_) + { + return (p_149976_0_ & 4) != 0; + } + + public static void func_149979_a(World p_149979_0_, int p_149979_1_, int p_149979_2_, int p_149979_3_, boolean p_149979_4_) + { + int l = p_149979_0_.getBlockMetadata(p_149979_1_, p_149979_2_, p_149979_3_); + + if (p_149979_4_) + { + l |= 4; + } + else + { + l &= -5; + } + + p_149979_0_.setBlockMetadataWithNotify(p_149979_1_, p_149979_2_, p_149979_3_, l, 4); + } + + public static ChunkCoordinates func_149977_a(World p_149977_0_, int p_149977_1_, int p_149977_2_, int p_149977_3_, int p_149977_4_) + { + int i1 = p_149977_0_.getBlockMetadata(p_149977_1_, p_149977_2_, p_149977_3_); + int j1 = BlockDirectional.getDirection(i1); + + for (int k1 = 0; k1 <= 1; ++k1) + { + int l1 = p_149977_1_ - field_149981_a[j1][0] * k1 - 1; + int i2 = p_149977_3_ - field_149981_a[j1][1] * k1 - 1; + int j2 = l1 + 2; + int k2 = i2 + 2; + + for (int l2 = l1; l2 <= j2; ++l2) + { + for (int i3 = i2; i3 <= k2; ++i3) + { + if (World.doesBlockHaveSolidTopSurface(p_149977_0_, l2, p_149977_2_ - 1, i3) && !p_149977_0_.getBlock(l2, p_149977_2_, i3).getMaterial().isOpaque() && !p_149977_0_.getBlock(l2, p_149977_2_ + 1, i3).getMaterial().isOpaque()) + { + if (p_149977_4_ <= 0) + { + return new ChunkCoordinates(l2, p_149977_2_, i3); + } + + --p_149977_4_; + } + } + } + } + + return null; + } + + public void dropBlockAsItemWithChance(World p_149690_1_, int p_149690_2_, int p_149690_3_, int p_149690_4_, int p_149690_5_, float p_149690_6_, int p_149690_7_) + { + if (!isBlockHeadOfBed(p_149690_5_)) + { + super.dropBlockAsItemWithChance(p_149690_1_, p_149690_2_, p_149690_3_, p_149690_4_, p_149690_5_, p_149690_6_, 0); + } + } + + public int getMobilityFlag() + { + return 1; + } + + @SideOnly(Side.CLIENT) + public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) + { + return Items.bed; + } + + public void onBlockHarvested(World p_149681_1_, int p_149681_2_, int p_149681_3_, int p_149681_4_, int p_149681_5_, EntityPlayer p_149681_6_) + { + if (p_149681_6_.capabilities.isCreativeMode && isBlockHeadOfBed(p_149681_5_)) + { + int i1 = getDirection(p_149681_5_); + p_149681_2_ -= field_149981_a[i1][0]; + p_149681_4_ -= field_149981_a[i1][1]; + + if (p_149681_1_.getBlock(p_149681_2_, p_149681_3_, p_149681_4_) == this) + { + p_149681_1_.setBlockToAir(p_149681_2_, p_149681_3_, p_149681_4_); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockBookshelf.java b/src/main/java/net/minecraft/block/BlockBookshelf.java new file mode 100644 index 0000000..e1ee865 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockBookshelf.java @@ -0,0 +1,38 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.util.IIcon; + +public class BlockBookshelf extends Block +{ + private static final String __OBFID = "CL_00000206"; + + public BlockBookshelf() + { + super(Material.wood); + this.setCreativeTab(CreativeTabs.tabBlock); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return p_149691_1_ != 1 && p_149691_1_ != 0 ? super.getIcon(p_149691_1_, p_149691_2_) : Blocks.planks.getBlockTextureFromSide(p_149691_1_); + } + + public int quantityDropped(Random p_149745_1_) + { + return 3; + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return Items.book; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockBreakable.java b/src/main/java/net/minecraft/block/BlockBreakable.java new file mode 100644 index 0000000..a3706ec --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockBreakable.java @@ -0,0 +1,55 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.init.Blocks; +import net.minecraft.util.Facing; +import net.minecraft.world.IBlockAccess; + +public class BlockBreakable extends Block +{ + private boolean field_149996_a; + private String field_149995_b; + private static final String __OBFID = "CL_00000254"; + + protected BlockBreakable(String p_i45411_1_, Material p_i45411_2_, boolean p_i45411_3_) + { + super(p_i45411_2_); + this.field_149996_a = p_i45411_3_; + this.field_149995_b = p_i45411_1_; + } + + public boolean isOpaqueCube() + { + return false; + } + + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) + { + Block block = p_149646_1_.getBlock(p_149646_2_, p_149646_3_, p_149646_4_); + + if (this == Blocks.glass || this == Blocks.stained_glass) + { + if (p_149646_1_.getBlockMetadata(p_149646_2_, p_149646_3_, p_149646_4_) != p_149646_1_.getBlockMetadata(p_149646_2_ - Facing.offsetsXForSide[p_149646_5_], p_149646_3_ - Facing.offsetsYForSide[p_149646_5_], p_149646_4_ - Facing.offsetsZForSide[p_149646_5_])) + { + return true; + } + + if (block == this) + { + return false; + } + } + + return !this.field_149996_a && block == this ? false : super.shouldSideBeRendered(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, p_149646_5_); + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.blockIcon = p_149651_1_.registerIcon(this.field_149995_b); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockBrewingStand.java b/src/main/java/net/minecraft/block/BlockBrewingStand.java new file mode 100644 index 0000000..cb3c54a --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockBrewingStand.java @@ -0,0 +1,180 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityBrewingStand; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +public class BlockBrewingStand extends BlockContainer +{ + private Random field_149961_a = new Random(); + @SideOnly(Side.CLIENT) + private IIcon iconBrewingStandBase; + private static final String __OBFID = "CL_00000207"; + + public BlockBrewingStand() + { + super(Material.iron); + } + + public boolean isOpaqueCube() + { + return false; + } + + public int getRenderType() + { + return 25; + } + + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) + { + return new TileEntityBrewingStand(); + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public void addCollisionBoxesToList(World p_149743_1_, int p_149743_2_, int p_149743_3_, int p_149743_4_, AxisAlignedBB p_149743_5_, List p_149743_6_, Entity p_149743_7_) + { + this.setBlockBounds(0.4375F, 0.0F, 0.4375F, 0.5625F, 0.875F, 0.5625F); + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + this.setBlockBoundsForItemRender(); + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + } + + public void setBlockBoundsForItemRender() + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F); + } + + public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) + { + if (p_149727_1_.isRemote) + { + return true; + } + else + { + TileEntityBrewingStand tileentitybrewingstand = (TileEntityBrewingStand)p_149727_1_.getTileEntity(p_149727_2_, p_149727_3_, p_149727_4_); + + if (tileentitybrewingstand != null) + { + p_149727_5_.func_146098_a(tileentitybrewingstand); + } + + return true; + } + } + + public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_) + { + if (p_149689_6_.hasDisplayName()) + { + ((TileEntityBrewingStand)p_149689_1_.getTileEntity(p_149689_2_, p_149689_3_, p_149689_4_)).func_145937_a(p_149689_6_.getDisplayName()); + } + } + + public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) + { + TileEntity tileentity = p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_); + + if (tileentity instanceof TileEntityBrewingStand) + { + TileEntityBrewingStand tileentitybrewingstand = (TileEntityBrewingStand)tileentity; + + for (int i1 = 0; i1 < tileentitybrewingstand.getSizeInventory(); ++i1) + { + ItemStack itemstack = tileentitybrewingstand.getStackInSlot(i1); + + if (itemstack != null) + { + float f = this.field_149961_a.nextFloat() * 0.8F + 0.1F; + float f1 = this.field_149961_a.nextFloat() * 0.8F + 0.1F; + float f2 = this.field_149961_a.nextFloat() * 0.8F + 0.1F; + + while (itemstack.stackSize > 0) + { + int j1 = this.field_149961_a.nextInt(21) + 10; + + if (j1 > itemstack.stackSize) + { + j1 = itemstack.stackSize; + } + + itemstack.stackSize -= j1; + EntityItem entityitem = new EntityItem(p_149749_1_, (double)((float)p_149749_2_ + f), (double)((float)p_149749_3_ + f1), (double)((float)p_149749_4_ + f2), new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage())); + float f3 = 0.05F; + entityitem.motionX = (double)((float)this.field_149961_a.nextGaussian() * f3); + entityitem.motionY = (double)((float)this.field_149961_a.nextGaussian() * f3 + 0.2F); + entityitem.motionZ = (double)((float)this.field_149961_a.nextGaussian() * f3); + p_149749_1_.spawnEntityInWorld(entityitem); + } + } + } + } + + super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_); + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return Items.brewing_stand; + } + + @SideOnly(Side.CLIENT) + public void randomDisplayTick(World p_149734_1_, int p_149734_2_, int p_149734_3_, int p_149734_4_, Random p_149734_5_) + { + double d0 = (double)((float)p_149734_2_ + 0.4F + p_149734_5_.nextFloat() * 0.2F); + double d1 = (double)((float)p_149734_3_ + 0.7F + p_149734_5_.nextFloat() * 0.3F); + double d2 = (double)((float)p_149734_4_ + 0.4F + p_149734_5_.nextFloat() * 0.2F); + p_149734_1_.spawnParticle("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D); + } + + @SideOnly(Side.CLIENT) + public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) + { + return Items.brewing_stand; + } + + public boolean hasComparatorInputOverride() + { + return true; + } + + public int getComparatorInputOverride(World p_149736_1_, int p_149736_2_, int p_149736_3_, int p_149736_4_, int p_149736_5_) + { + return Container.calcRedstoneFromInventory((IInventory)p_149736_1_.getTileEntity(p_149736_2_, p_149736_3_, p_149736_4_)); + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + super.registerBlockIcons(p_149651_1_); + this.iconBrewingStandBase = p_149651_1_.registerIcon(this.getTextureName() + "_base"); + } + + @SideOnly(Side.CLIENT) + public IIcon getIconBrewingStandBase() + { + return this.iconBrewingStandBase; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockBush.java b/src/main/java/net/minecraft/block/BlockBush.java new file mode 100644 index 0000000..c67cce7 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockBush.java @@ -0,0 +1,120 @@ +package net.minecraft.block; + +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Blocks; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; +import net.minecraft.world.IBlockAccess; +import net.minecraftforge.common.EnumPlantType; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.common.IPlantable; +import static net.minecraftforge.common.EnumPlantType.*; + +public class BlockBush extends Block implements IPlantable +{ + private static final String __OBFID = "CL_00000208"; + + protected BlockBush(Material p_i45395_1_) + { + super(p_i45395_1_); + this.setTickRandomly(true); + float f = 0.2F; + this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 3.0F, 0.5F + f); + this.setCreativeTab(CreativeTabs.tabDecorations); + } + + protected BlockBush() + { + this(Material.plants); + } + + public boolean canPlaceBlockAt(World p_149742_1_, int p_149742_2_, int p_149742_3_, int p_149742_4_) + { + return super.canPlaceBlockAt(p_149742_1_, p_149742_2_, p_149742_3_, p_149742_4_) && this.canBlockStay(p_149742_1_, p_149742_2_, p_149742_3_, p_149742_4_); + } + + protected boolean canPlaceBlockOn(Block p_149854_1_) + { + return p_149854_1_ == Blocks.grass || p_149854_1_ == Blocks.dirt || p_149854_1_ == Blocks.farmland; + } + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) + { + super.onNeighborBlockChange(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, p_149695_5_); + this.checkAndDropBlock(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_); + } + + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) + { + this.checkAndDropBlock(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_); + } + + protected void checkAndDropBlock(World p_149855_1_, int p_149855_2_, int p_149855_3_, int p_149855_4_) + { + if (!this.canBlockStay(p_149855_1_, p_149855_2_, p_149855_3_, p_149855_4_)) + { + this.dropBlockAsItem(p_149855_1_, p_149855_2_, p_149855_3_, p_149855_4_, p_149855_1_.getBlockMetadata(p_149855_2_, p_149855_3_, p_149855_4_), 0); + p_149855_1_.setBlock(p_149855_2_, p_149855_3_, p_149855_4_, getBlockById(0), 0, 2); + } + } + + public boolean canBlockStay(World p_149718_1_, int p_149718_2_, int p_149718_3_, int p_149718_4_) + { + return p_149718_1_.getBlock(p_149718_2_, p_149718_3_ - 1, p_149718_4_).canSustainPlant(p_149718_1_, p_149718_2_, p_149718_3_ - 1, p_149718_4_, ForgeDirection.UP, this); + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) + { + return null; + } + + public boolean isOpaqueCube() + { + return false; + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public int getRenderType() + { + return 1; + } + + @Override + public EnumPlantType getPlantType(IBlockAccess world, int x, int y, int z) + { + if (this == Blocks.wheat) return Crop; + if (this == Blocks.carrots) return Crop; + if (this == Blocks.potatoes) return Crop; + if (this == Blocks.melon_stem) return Crop; + if (this == Blocks.pumpkin_stem) return Crop; + if (this == Blocks.deadbush) return Desert; + if (this == Blocks.waterlily) return Water; + if (this == Blocks.red_mushroom) return Cave; + if (this == Blocks.brown_mushroom) return Cave; + if (this == Blocks.nether_wart) return Nether; + if (this == Blocks.sapling) return Plains; + if (this == Blocks.tallgrass) return Plains; + if (this == Blocks.double_plant) return Plains; + if (this == Blocks.red_flower) return Plains; + if (this == Blocks.yellow_flower) return Plains; + return Plains; + } + + @Override + public Block getPlant(IBlockAccess world, int x, int y, int z) + { + return this; + } + + @Override + public int getPlantMetadata(IBlockAccess world, int x, int y, int z) + { + return world.getBlockMetadata(x, y, z); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockButton.java b/src/main/java/net/minecraft/block/BlockButton.java new file mode 100644 index 0000000..24ea688 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockButton.java @@ -0,0 +1,362 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import net.minecraftforge.common.util.ForgeDirection; +import static net.minecraftforge.common.util.ForgeDirection.*; + +public abstract class BlockButton extends Block +{ + private final boolean field_150047_a; + private static final String __OBFID = "CL_00000209"; + + protected BlockButton(boolean p_i45396_1_) + { + super(Material.circuits); + this.setTickRandomly(true); + this.setCreativeTab(CreativeTabs.tabRedstone); + this.field_150047_a = p_i45396_1_; + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) + { + return null; + } + + public int tickRate(World p_149738_1_) + { + return this.field_150047_a ? 30 : 20; + } + + public boolean isOpaqueCube() + { + return false; + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public boolean canPlaceBlockOnSide(World p_149707_1_, int p_149707_2_, int p_149707_3_, int p_149707_4_, int p_149707_5_) + { + ForgeDirection dir = ForgeDirection.getOrientation(p_149707_5_); + return (dir == NORTH && p_149707_1_.isSideSolid(p_149707_2_, p_149707_3_, p_149707_4_ + 1, NORTH)) || + (dir == SOUTH && p_149707_1_.isSideSolid(p_149707_2_, p_149707_3_, p_149707_4_ - 1, SOUTH)) || + (dir == WEST && p_149707_1_.isSideSolid(p_149707_2_ + 1, p_149707_3_, p_149707_4_, WEST)) || + (dir == EAST && p_149707_1_.isSideSolid(p_149707_2_ - 1, p_149707_3_, p_149707_4_, EAST)); + } + + public boolean canPlaceBlockAt(World p_149742_1_, int p_149742_2_, int p_149742_3_, int p_149742_4_) + { + return (p_149742_1_.isSideSolid(p_149742_2_ - 1, p_149742_3_, p_149742_4_, EAST)) || + (p_149742_1_.isSideSolid(p_149742_2_ + 1, p_149742_3_, p_149742_4_, WEST)) || + (p_149742_1_.isSideSolid(p_149742_2_, p_149742_3_, p_149742_4_ - 1, SOUTH)) || + (p_149742_1_.isSideSolid(p_149742_2_, p_149742_3_, p_149742_4_ + 1, NORTH)); + } + + public int onBlockPlaced(World p_149660_1_, int p_149660_2_, int p_149660_3_, int p_149660_4_, int p_149660_5_, float p_149660_6_, float p_149660_7_, float p_149660_8_, int p_149660_9_) + { + int j1 = p_149660_1_.getBlockMetadata(p_149660_2_, p_149660_3_, p_149660_4_); + int k1 = j1 & 8; + j1 &= 7; + + ForgeDirection dir = ForgeDirection.getOrientation(p_149660_5_); + + if (dir == NORTH && p_149660_1_.isSideSolid(p_149660_2_, p_149660_3_, p_149660_4_ + 1, NORTH)) + { + j1 = 4; + } + else if (dir == SOUTH && p_149660_1_.isSideSolid(p_149660_2_, p_149660_3_, p_149660_4_ - 1, SOUTH)) + { + j1 = 3; + } + else if (dir == WEST && p_149660_1_.isSideSolid(p_149660_2_ + 1, p_149660_3_, p_149660_4_, WEST)) + { + j1 = 2; + } + else if (dir == EAST && p_149660_1_.isSideSolid(p_149660_2_ - 1, p_149660_3_, p_149660_4_, EAST)) + { + j1 = 1; + } + else + { + j1 = this.func_150045_e(p_149660_1_, p_149660_2_, p_149660_3_, p_149660_4_); + } + + return j1 + k1; + } + + private int func_150045_e(World p_150045_1_, int p_150045_2_, int p_150045_3_, int p_150045_4_) + { + if (p_150045_1_.isSideSolid(p_150045_2_ - 1, p_150045_3_, p_150045_4_, EAST)) return 1; + if (p_150045_1_.isSideSolid(p_150045_2_ + 1, p_150045_3_, p_150045_4_, WEST)) return 2; + if (p_150045_1_.isSideSolid(p_150045_2_, p_150045_3_, p_150045_4_ - 1, SOUTH)) return 3; + if (p_150045_1_.isSideSolid(p_150045_2_, p_150045_3_, p_150045_4_ + 1, NORTH)) return 4; + return 1; + } + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) + { + if (this.func_150044_m(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_)) + { + int l = p_149695_1_.getBlockMetadata(p_149695_2_, p_149695_3_, p_149695_4_) & 7; + boolean flag = false; + + if (!p_149695_1_.isSideSolid(p_149695_2_ - 1, p_149695_3_, p_149695_4_, EAST) && l == 1) + { + flag = true; + } + + if (!p_149695_1_.isSideSolid(p_149695_2_ + 1, p_149695_3_, p_149695_4_, WEST) && l == 2) + { + flag = true; + } + + if (!p_149695_1_.isSideSolid(p_149695_2_, p_149695_3_, p_149695_4_ - 1, SOUTH) && l == 3) + { + flag = true; + } + + if (!p_149695_1_.isSideSolid(p_149695_2_, p_149695_3_, p_149695_4_ + 1, NORTH) && l == 4) + { + flag = true; + } + + if (flag) + { + this.dropBlockAsItem(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, p_149695_1_.getBlockMetadata(p_149695_2_, p_149695_3_, p_149695_4_), 0); + p_149695_1_.setBlockToAir(p_149695_2_, p_149695_3_, p_149695_4_); + } + } + } + + private boolean func_150044_m(World p_150044_1_, int p_150044_2_, int p_150044_3_, int p_150044_4_) + { + if (!this.canPlaceBlockAt(p_150044_1_, p_150044_2_, p_150044_3_, p_150044_4_)) + { + this.dropBlockAsItem(p_150044_1_, p_150044_2_, p_150044_3_, p_150044_4_, p_150044_1_.getBlockMetadata(p_150044_2_, p_150044_3_, p_150044_4_), 0); + p_150044_1_.setBlockToAir(p_150044_2_, p_150044_3_, p_150044_4_); + return false; + } + else + { + return true; + } + } + + public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) + { + int l = p_149719_1_.getBlockMetadata(p_149719_2_, p_149719_3_, p_149719_4_); + this.func_150043_b(l); + } + + private void func_150043_b(int p_150043_1_) + { + int j = p_150043_1_ & 7; + boolean flag = (p_150043_1_ & 8) > 0; + float f = 0.375F; + float f1 = 0.625F; + float f2 = 0.1875F; + float f3 = 0.125F; + + if (flag) + { + f3 = 0.0625F; + } + + if (j == 1) + { + this.setBlockBounds(0.0F, f, 0.5F - f2, f3, f1, 0.5F + f2); + } + else if (j == 2) + { + this.setBlockBounds(1.0F - f3, f, 0.5F - f2, 1.0F, f1, 0.5F + f2); + } + else if (j == 3) + { + this.setBlockBounds(0.5F - f2, f, 0.0F, 0.5F + f2, f1, f3); + } + else if (j == 4) + { + this.setBlockBounds(0.5F - f2, f, 1.0F - f3, 0.5F + f2, f1, 1.0F); + } + } + + public void onBlockClicked(World p_149699_1_, int p_149699_2_, int p_149699_3_, int p_149699_4_, EntityPlayer p_149699_5_) {} + + public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) + { + int i1 = p_149727_1_.getBlockMetadata(p_149727_2_, p_149727_3_, p_149727_4_); + int j1 = i1 & 7; + int k1 = 8 - (i1 & 8); + + if (k1 == 0) + { + return true; + } + else + { + p_149727_1_.setBlockMetadataWithNotify(p_149727_2_, p_149727_3_, p_149727_4_, j1 + k1, 3); + p_149727_1_.markBlockRangeForRenderUpdate(p_149727_2_, p_149727_3_, p_149727_4_, p_149727_2_, p_149727_3_, p_149727_4_); + p_149727_1_.playSoundEffect((double)p_149727_2_ + 0.5D, (double)p_149727_3_ + 0.5D, (double)p_149727_4_ + 0.5D, "random.click", 0.3F, 0.6F); + this.func_150042_a(p_149727_1_, p_149727_2_, p_149727_3_, p_149727_4_, j1); + p_149727_1_.scheduleBlockUpdate(p_149727_2_, p_149727_3_, p_149727_4_, this, this.tickRate(p_149727_1_)); + return true; + } + } + + public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) + { + if ((p_149749_6_ & 8) > 0) + { + int i1 = p_149749_6_ & 7; + this.func_150042_a(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, i1); + } + + super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_); + } + + public int isProvidingWeakPower(IBlockAccess p_149709_1_, int p_149709_2_, int p_149709_3_, int p_149709_4_, int p_149709_5_) + { + return (p_149709_1_.getBlockMetadata(p_149709_2_, p_149709_3_, p_149709_4_) & 8) > 0 ? 15 : 0; + } + + public int isProvidingStrongPower(IBlockAccess p_149748_1_, int p_149748_2_, int p_149748_3_, int p_149748_4_, int p_149748_5_) + { + int i1 = p_149748_1_.getBlockMetadata(p_149748_2_, p_149748_3_, p_149748_4_); + + if ((i1 & 8) == 0) + { + return 0; + } + else + { + int j1 = i1 & 7; + return j1 == 5 && p_149748_5_ == 1 ? 15 : (j1 == 4 && p_149748_5_ == 2 ? 15 : (j1 == 3 && p_149748_5_ == 3 ? 15 : (j1 == 2 && p_149748_5_ == 4 ? 15 : (j1 == 1 && p_149748_5_ == 5 ? 15 : 0)))); + } + } + + public boolean canProvidePower() + { + return true; + } + + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) + { + if (!p_149674_1_.isRemote) + { + int l = p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_); + + if ((l & 8) != 0) + { + if (this.field_150047_a) + { + this.func_150046_n(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_); + } + else + { + p_149674_1_.setBlockMetadataWithNotify(p_149674_2_, p_149674_3_, p_149674_4_, l & 7, 3); + int i1 = l & 7; + this.func_150042_a(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, i1); + p_149674_1_.playSoundEffect((double)p_149674_2_ + 0.5D, (double)p_149674_3_ + 0.5D, (double)p_149674_4_ + 0.5D, "random.click", 0.3F, 0.5F); + p_149674_1_.markBlockRangeForRenderUpdate(p_149674_2_, p_149674_3_, p_149674_4_, p_149674_2_, p_149674_3_, p_149674_4_); + } + } + } + } + + public void setBlockBoundsForItemRender() + { + float f = 0.1875F; + float f1 = 0.125F; + float f2 = 0.125F; + this.setBlockBounds(0.5F - f, 0.5F - f1, 0.5F - f2, 0.5F + f, 0.5F + f1, 0.5F + f2); + } + + public void onEntityCollidedWithBlock(World p_149670_1_, int p_149670_2_, int p_149670_3_, int p_149670_4_, Entity p_149670_5_) + { + if (!p_149670_1_.isRemote) + { + if (this.field_150047_a) + { + if ((p_149670_1_.getBlockMetadata(p_149670_2_, p_149670_3_, p_149670_4_) & 8) == 0) + { + this.func_150046_n(p_149670_1_, p_149670_2_, p_149670_3_, p_149670_4_); + } + } + } + } + + private void func_150046_n(World p_150046_1_, int p_150046_2_, int p_150046_3_, int p_150046_4_) + { + int l = p_150046_1_.getBlockMetadata(p_150046_2_, p_150046_3_, p_150046_4_); + int i1 = l & 7; + boolean flag = (l & 8) != 0; + this.func_150043_b(l); + List list = p_150046_1_.getEntitiesWithinAABB(EntityArrow.class, AxisAlignedBB.getAABBPool().getAABB((double)p_150046_2_ + this.minX, (double)p_150046_3_ + this.minY, (double)p_150046_4_ + this.minZ, (double)p_150046_2_ + this.maxX, (double)p_150046_3_ + this.maxY, (double)p_150046_4_ + this.maxZ)); + boolean flag1 = !list.isEmpty(); + + if (flag1 && !flag) + { + p_150046_1_.setBlockMetadataWithNotify(p_150046_2_, p_150046_3_, p_150046_4_, i1 | 8, 3); + this.func_150042_a(p_150046_1_, p_150046_2_, p_150046_3_, p_150046_4_, i1); + p_150046_1_.markBlockRangeForRenderUpdate(p_150046_2_, p_150046_3_, p_150046_4_, p_150046_2_, p_150046_3_, p_150046_4_); + p_150046_1_.playSoundEffect((double)p_150046_2_ + 0.5D, (double)p_150046_3_ + 0.5D, (double)p_150046_4_ + 0.5D, "random.click", 0.3F, 0.6F); + } + + if (!flag1 && flag) + { + p_150046_1_.setBlockMetadataWithNotify(p_150046_2_, p_150046_3_, p_150046_4_, i1, 3); + this.func_150042_a(p_150046_1_, p_150046_2_, p_150046_3_, p_150046_4_, i1); + p_150046_1_.markBlockRangeForRenderUpdate(p_150046_2_, p_150046_3_, p_150046_4_, p_150046_2_, p_150046_3_, p_150046_4_); + p_150046_1_.playSoundEffect((double)p_150046_2_ + 0.5D, (double)p_150046_3_ + 0.5D, (double)p_150046_4_ + 0.5D, "random.click", 0.3F, 0.5F); + } + + if (flag1) + { + p_150046_1_.scheduleBlockUpdate(p_150046_2_, p_150046_3_, p_150046_4_, this, this.tickRate(p_150046_1_)); + } + } + + private void func_150042_a(World p_150042_1_, int p_150042_2_, int p_150042_3_, int p_150042_4_, int p_150042_5_) + { + p_150042_1_.notifyBlocksOfNeighborChange(p_150042_2_, p_150042_3_, p_150042_4_, this); + + if (p_150042_5_ == 1) + { + p_150042_1_.notifyBlocksOfNeighborChange(p_150042_2_ - 1, p_150042_3_, p_150042_4_, this); + } + else if (p_150042_5_ == 2) + { + p_150042_1_.notifyBlocksOfNeighborChange(p_150042_2_ + 1, p_150042_3_, p_150042_4_, this); + } + else if (p_150042_5_ == 3) + { + p_150042_1_.notifyBlocksOfNeighborChange(p_150042_2_, p_150042_3_, p_150042_4_ - 1, this); + } + else if (p_150042_5_ == 4) + { + p_150042_1_.notifyBlocksOfNeighborChange(p_150042_2_, p_150042_3_, p_150042_4_ + 1, this); + } + else + { + p_150042_1_.notifyBlocksOfNeighborChange(p_150042_2_, p_150042_3_ - 1, p_150042_4_, this); + } + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) {} +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockButtonStone.java b/src/main/java/net/minecraft/block/BlockButtonStone.java new file mode 100644 index 0000000..9aebcc6 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockButtonStone.java @@ -0,0 +1,22 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.init.Blocks; +import net.minecraft.util.IIcon; + +public class BlockButtonStone extends BlockButton +{ + private static final String __OBFID = "CL_00000319"; + + protected BlockButtonStone() + { + super(false); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return Blocks.stone.getBlockTextureFromSide(1); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockButtonWood.java b/src/main/java/net/minecraft/block/BlockButtonWood.java new file mode 100644 index 0000000..978ac3d --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockButtonWood.java @@ -0,0 +1,22 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.init.Blocks; +import net.minecraft.util.IIcon; + +public class BlockButtonWood extends BlockButton +{ + private static final String __OBFID = "CL_00000336"; + + protected BlockButtonWood() + { + super(true); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return Blocks.planks.getBlockTextureFromSide(1); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockCactus.java b/src/main/java/net/minecraft/block/BlockCactus.java new file mode 100644 index 0000000..4b1d671 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockCactus.java @@ -0,0 +1,166 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.init.Blocks; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.DamageSource; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.EnumPlantType; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.common.IPlantable; + +public class BlockCactus extends Block implements IPlantable +{ + @SideOnly(Side.CLIENT) + private IIcon field_150041_a; + @SideOnly(Side.CLIENT) + private IIcon field_150040_b; + private static final String __OBFID = "CL_00000210"; + + protected BlockCactus() + { + super(Material.cactus); + this.setTickRandomly(true); + this.setCreativeTab(CreativeTabs.tabDecorations); + } + + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) + { + if (p_149674_1_.isAirBlock(p_149674_2_, p_149674_3_ + 1, p_149674_4_)) + { + int l; + + for (l = 1; p_149674_1_.getBlock(p_149674_2_, p_149674_3_ - l, p_149674_4_) == this; ++l) + { + ; + } + + if (l < 3) + { + int i1 = p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_); + + if (i1 == 15) + { + p_149674_1_.setBlock(p_149674_2_, p_149674_3_ + 1, p_149674_4_, this); + p_149674_1_.setBlockMetadataWithNotify(p_149674_2_, p_149674_3_, p_149674_4_, 0, 4); + this.onNeighborBlockChange(p_149674_1_, p_149674_2_, p_149674_3_ + 1, p_149674_4_, this); + } + else + { + p_149674_1_.setBlockMetadataWithNotify(p_149674_2_, p_149674_3_, p_149674_4_, i1 + 1, 4); + } + } + } + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) + { + float f = 0.0625F; + return AxisAlignedBB.getAABBPool().getAABB((double)((float)p_149668_2_ + f), (double)p_149668_3_, (double)((float)p_149668_4_ + f), (double)((float)(p_149668_2_ + 1) - f), (double)((float)(p_149668_3_ + 1) - f), (double)((float)(p_149668_4_ + 1) - f)); + } + + @SideOnly(Side.CLIENT) + public AxisAlignedBB getSelectedBoundingBoxFromPool(World p_149633_1_, int p_149633_2_, int p_149633_3_, int p_149633_4_) + { + float f = 0.0625F; + return AxisAlignedBB.getAABBPool().getAABB((double)((float)p_149633_2_ + f), (double)p_149633_3_, (double)((float)p_149633_4_ + f), (double)((float)(p_149633_2_ + 1) - f), (double)(p_149633_3_ + 1), (double)((float)(p_149633_4_ + 1) - f)); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return p_149691_1_ == 1 ? this.field_150041_a : (p_149691_1_ == 0 ? this.field_150040_b : this.blockIcon); + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public boolean isOpaqueCube() + { + return false; + } + + public int getRenderType() + { + return 13; + } + + public boolean canPlaceBlockAt(World p_149742_1_, int p_149742_2_, int p_149742_3_, int p_149742_4_) + { + return !super.canPlaceBlockAt(p_149742_1_, p_149742_2_, p_149742_3_, p_149742_4_) ? false : this.canBlockStay(p_149742_1_, p_149742_2_, p_149742_3_, p_149742_4_); + } + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) + { + if (!this.canBlockStay(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_)) + { + p_149695_1_.func_147480_a(p_149695_2_, p_149695_3_, p_149695_4_, true); + } + } + + public boolean canBlockStay(World p_149718_1_, int p_149718_2_, int p_149718_3_, int p_149718_4_) + { + if (p_149718_1_.getBlock(p_149718_2_ - 1, p_149718_3_, p_149718_4_).getMaterial().isSolid()) + { + return false; + } + else if (p_149718_1_.getBlock(p_149718_2_ + 1, p_149718_3_, p_149718_4_).getMaterial().isSolid()) + { + return false; + } + else if (p_149718_1_.getBlock(p_149718_2_, p_149718_3_, p_149718_4_ - 1).getMaterial().isSolid()) + { + return false; + } + else if (p_149718_1_.getBlock(p_149718_2_, p_149718_3_, p_149718_4_ + 1).getMaterial().isSolid()) + { + return false; + } + else + { + Block block = p_149718_1_.getBlock(p_149718_2_, p_149718_3_ - 1, p_149718_4_); + return block.canSustainPlant(p_149718_1_, p_149718_2_, p_149718_3_ - 1, p_149718_4_, ForgeDirection.UP, this); + } + } + + public void onEntityCollidedWithBlock(World p_149670_1_, int p_149670_2_, int p_149670_3_, int p_149670_4_, Entity p_149670_5_) + { + p_149670_5_.attackEntityFrom(DamageSource.cactus, 1.0F); + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.blockIcon = p_149651_1_.registerIcon(this.getTextureName() + "_side"); + this.field_150041_a = p_149651_1_.registerIcon(this.getTextureName() + "_top"); + this.field_150040_b = p_149651_1_.registerIcon(this.getTextureName() + "_bottom"); + } + + @Override + public EnumPlantType getPlantType(IBlockAccess world, int x, int y, int z) + { + return EnumPlantType.Desert; + } + + @Override + public Block getPlant(IBlockAccess world, int x, int y, int z) + { + return this; + } + + @Override + public int getPlantMetadata(IBlockAccess world, int x, int y, int z) + { + return -1; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockCake.java b/src/main/java/net/minecraft/block/BlockCake.java new file mode 100644 index 0000000..68e66ee --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockCake.java @@ -0,0 +1,154 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockCake extends Block +{ + @SideOnly(Side.CLIENT) + private IIcon field_150038_a; + @SideOnly(Side.CLIENT) + private IIcon field_150037_b; + @SideOnly(Side.CLIENT) + private IIcon field_150039_M; + private static final String __OBFID = "CL_00000211"; + + protected BlockCake() + { + super(Material.cake); + this.setTickRandomly(true); + } + + public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) + { + int l = p_149719_1_.getBlockMetadata(p_149719_2_, p_149719_3_, p_149719_4_); + float f = 0.0625F; + float f1 = (float)(1 + l * 2) / 16.0F; + float f2 = 0.5F; + this.setBlockBounds(f1, 0.0F, f, 1.0F - f, f2, 1.0F - f); + } + + public void setBlockBoundsForItemRender() + { + float f = 0.0625F; + float f1 = 0.5F; + this.setBlockBounds(f, 0.0F, f, 1.0F - f, f1, 1.0F - f); + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) + { + int l = p_149668_1_.getBlockMetadata(p_149668_2_, p_149668_3_, p_149668_4_); + float f = 0.0625F; + float f1 = (float)(1 + l * 2) / 16.0F; + float f2 = 0.5F; + return AxisAlignedBB.getAABBPool().getAABB((double)((float)p_149668_2_ + f1), (double)p_149668_3_, (double)((float)p_149668_4_ + f), (double)((float)(p_149668_2_ + 1) - f), (double)((float)p_149668_3_ + f2 - f), (double)((float)(p_149668_4_ + 1) - f)); + } + + @SideOnly(Side.CLIENT) + public AxisAlignedBB getSelectedBoundingBoxFromPool(World p_149633_1_, int p_149633_2_, int p_149633_3_, int p_149633_4_) + { + int l = p_149633_1_.getBlockMetadata(p_149633_2_, p_149633_3_, p_149633_4_); + float f = 0.0625F; + float f1 = (float)(1 + l * 2) / 16.0F; + float f2 = 0.5F; + return AxisAlignedBB.getAABBPool().getAABB((double)((float)p_149633_2_ + f1), (double)p_149633_3_, (double)((float)p_149633_4_ + f), (double)((float)(p_149633_2_ + 1) - f), (double)((float)p_149633_3_ + f2), (double)((float)(p_149633_4_ + 1) - f)); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return p_149691_1_ == 1 ? this.field_150038_a : (p_149691_1_ == 0 ? this.field_150037_b : (p_149691_2_ > 0 && p_149691_1_ == 4 ? this.field_150039_M : this.blockIcon)); + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.blockIcon = p_149651_1_.registerIcon(this.getTextureName() + "_side"); + this.field_150039_M = p_149651_1_.registerIcon(this.getTextureName() + "_inner"); + this.field_150038_a = p_149651_1_.registerIcon(this.getTextureName() + "_top"); + this.field_150037_b = p_149651_1_.registerIcon(this.getTextureName() + "_bottom"); + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public boolean isOpaqueCube() + { + return false; + } + + public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) + { + this.func_150036_b(p_149727_1_, p_149727_2_, p_149727_3_, p_149727_4_, p_149727_5_); + return true; + } + + public void onBlockClicked(World p_149699_1_, int p_149699_2_, int p_149699_3_, int p_149699_4_, EntityPlayer p_149699_5_) + { + this.func_150036_b(p_149699_1_, p_149699_2_, p_149699_3_, p_149699_4_, p_149699_5_); + } + + private void func_150036_b(World p_150036_1_, int p_150036_2_, int p_150036_3_, int p_150036_4_, EntityPlayer p_150036_5_) + { + if (p_150036_5_.canEat(false)) + { + p_150036_5_.getFoodStats().addStats(2, 0.1F); + int l = p_150036_1_.getBlockMetadata(p_150036_2_, p_150036_3_, p_150036_4_) + 1; + + if (l >= 6) + { + p_150036_1_.setBlockToAir(p_150036_2_, p_150036_3_, p_150036_4_); + } + else + { + p_150036_1_.setBlockMetadataWithNotify(p_150036_2_, p_150036_3_, p_150036_4_, l, 2); + } + } + } + + public boolean canPlaceBlockAt(World p_149742_1_, int p_149742_2_, int p_149742_3_, int p_149742_4_) + { + return !super.canPlaceBlockAt(p_149742_1_, p_149742_2_, p_149742_3_, p_149742_4_) ? false : this.canBlockStay(p_149742_1_, p_149742_2_, p_149742_3_, p_149742_4_); + } + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) + { + if (!this.canBlockStay(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_)) + { + p_149695_1_.setBlockToAir(p_149695_2_, p_149695_3_, p_149695_4_); + } + } + + public boolean canBlockStay(World p_149718_1_, int p_149718_2_, int p_149718_3_, int p_149718_4_) + { + return p_149718_1_.getBlock(p_149718_2_, p_149718_3_ - 1, p_149718_4_).getMaterial().isSolid(); + } + + public int quantityDropped(Random p_149745_1_) + { + return 0; + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return null; + } + + @SideOnly(Side.CLIENT) + public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) + { + return Items.cake; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockCarpet.java b/src/main/java/net/minecraft/block/BlockCarpet.java new file mode 100644 index 0000000..45fe2ea --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockCarpet.java @@ -0,0 +1,121 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockCarpet extends Block +{ + private static final String __OBFID = "CL_00000338"; + + protected BlockCarpet() + { + super(Material.carpet); + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.0625F, 1.0F); + this.setTickRandomly(true); + this.setCreativeTab(CreativeTabs.tabDecorations); + this.func_150089_b(0); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return Blocks.wool.getIcon(p_149691_1_, p_149691_2_); + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) + { + byte b0 = 0; + float f = 0.0625F; + return AxisAlignedBB.getAABBPool().getAABB((double)p_149668_2_ + this.minX, (double)p_149668_3_ + this.minY, (double)p_149668_4_ + this.minZ, (double)p_149668_2_ + this.maxX, (double)((float)p_149668_3_ + (float)b0 * f), (double)p_149668_4_ + this.maxZ); + } + + public boolean isOpaqueCube() + { + return false; + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public void setBlockBoundsForItemRender() + { + this.func_150089_b(0); + } + + public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) + { + this.func_150089_b(p_149719_1_.getBlockMetadata(p_149719_2_, p_149719_3_, p_149719_4_)); + } + + protected void func_150089_b(int p_150089_1_) + { + byte b0 = 0; + float f = (float)(1 * (1 + b0)) / 16.0F; + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, f, 1.0F); + } + + public boolean canPlaceBlockAt(World p_149742_1_, int p_149742_2_, int p_149742_3_, int p_149742_4_) + { + return super.canPlaceBlockAt(p_149742_1_, p_149742_2_, p_149742_3_, p_149742_4_) && this.canBlockStay(p_149742_1_, p_149742_2_, p_149742_3_, p_149742_4_); + } + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) + { + this.func_150090_e(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_); + } + + private boolean func_150090_e(World p_150090_1_, int p_150090_2_, int p_150090_3_, int p_150090_4_) + { + if (!this.canBlockStay(p_150090_1_, p_150090_2_, p_150090_3_, p_150090_4_)) + { + this.dropBlockAsItem(p_150090_1_, p_150090_2_, p_150090_3_, p_150090_4_, p_150090_1_.getBlockMetadata(p_150090_2_, p_150090_3_, p_150090_4_), 0); + p_150090_1_.setBlockToAir(p_150090_2_, p_150090_3_, p_150090_4_); + return false; + } + else + { + return true; + } + } + + public boolean canBlockStay(World p_149718_1_, int p_149718_2_, int p_149718_3_, int p_149718_4_) + { + return !p_149718_1_.isAirBlock(p_149718_2_, p_149718_3_ - 1, p_149718_4_); + } + + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) + { + return p_149646_5_ == 1 ? true : super.shouldSideBeRendered(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, p_149646_5_); + } + + public int damageDropped(int p_149692_1_) + { + return p_149692_1_; + } + + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_) + { + for (int i = 0; i < 16; ++i) + { + p_149666_3_.add(new ItemStack(p_149666_1_, 1, i)); + } + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) {} +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockCarrot.java b/src/main/java/net/minecraft/block/BlockCarrot.java new file mode 100644 index 0000000..c97b9a1 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockCarrot.java @@ -0,0 +1,54 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.util.IIcon; + +public class BlockCarrot extends BlockCrops +{ + @SideOnly(Side.CLIENT) + private IIcon[] field_149868_a; + private static final String __OBFID = "CL_00000212"; + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + if (p_149691_2_ < 7) + { + if (p_149691_2_ == 6) + { + p_149691_2_ = 5; + } + + return this.field_149868_a[p_149691_2_ >> 1]; + } + else + { + return this.field_149868_a[3]; + } + } + + protected Item func_149866_i() + { + return Items.carrot; + } + + protected Item func_149865_P() + { + return Items.carrot; + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.field_149868_a = new IIcon[4]; + + for (int i = 0; i < this.field_149868_a.length; ++i) + { + this.field_149868_a[i] = p_149651_1_.registerIcon(this.getTextureName() + "_stage_" + i); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockCauldron.java b/src/main/java/net/minecraft/block/BlockCauldron.java new file mode 100644 index 0000000..59dbc24 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockCauldron.java @@ -0,0 +1,236 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemArmor; +import net.minecraft.item.ItemStack; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class BlockCauldron extends Block +{ + @SideOnly(Side.CLIENT) + private IIcon field_150029_a; + @SideOnly(Side.CLIENT) + private IIcon field_150028_b; + @SideOnly(Side.CLIENT) + private IIcon field_150030_M; + private static final String __OBFID = "CL_00000213"; + + public BlockCauldron() + { + super(Material.iron); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return p_149691_1_ == 1 ? this.field_150028_b : (p_149691_1_ == 0 ? this.field_150030_M : this.blockIcon); + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.field_150029_a = p_149651_1_.registerIcon(this.getTextureName() + "_" + "inner"); + this.field_150028_b = p_149651_1_.registerIcon(this.getTextureName() + "_top"); + this.field_150030_M = p_149651_1_.registerIcon(this.getTextureName() + "_" + "bottom"); + this.blockIcon = p_149651_1_.registerIcon(this.getTextureName() + "_side"); + } + + public void addCollisionBoxesToList(World p_149743_1_, int p_149743_2_, int p_149743_3_, int p_149743_4_, AxisAlignedBB p_149743_5_, List p_149743_6_, Entity p_149743_7_) + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.3125F, 1.0F); + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + float f = 0.125F; + this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F); + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f); + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F); + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + this.setBlockBoundsForItemRender(); + } + + @SideOnly(Side.CLIENT) + public static IIcon getCauldronIcon(String p_150026_0_) + { + return p_150026_0_.equals("inner") ? Blocks.cauldron.field_150029_a : (p_150026_0_.equals("bottom") ? Blocks.cauldron.field_150030_M : null); + } + + public void setBlockBoundsForItemRender() + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + + public boolean isOpaqueCube() + { + return false; + } + + public int getRenderType() + { + return 24; + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public void onEntityCollidedWithBlock(World p_149670_1_, int p_149670_2_, int p_149670_3_, int p_149670_4_, Entity p_149670_5_) + { + int l = func_150027_b(p_149670_1_.getBlockMetadata(p_149670_2_, p_149670_3_, p_149670_4_)); + float f = (float)p_149670_3_ + (6.0F + (float)(3 * l)) / 16.0F; + + if (!p_149670_1_.isRemote && p_149670_5_.isBurning() && l > 0 && p_149670_5_.boundingBox.minY <= (double)f) + { + p_149670_5_.extinguish(); + this.func_150024_a(p_149670_1_, p_149670_2_, p_149670_3_, p_149670_4_, l - 1); + } + } + + public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) + { + if (p_149727_1_.isRemote) + { + return true; + } + else + { + ItemStack itemstack = p_149727_5_.inventory.getCurrentItem(); + + if (itemstack == null) + { + return true; + } + else + { + int i1 = p_149727_1_.getBlockMetadata(p_149727_2_, p_149727_3_, p_149727_4_); + int j1 = func_150027_b(i1); + + if (itemstack.getItem() == Items.water_bucket) + { + if (j1 < 3) + { + if (!p_149727_5_.capabilities.isCreativeMode) + { + p_149727_5_.inventory.setInventorySlotContents(p_149727_5_.inventory.currentItem, new ItemStack(Items.bucket)); + } + + this.func_150024_a(p_149727_1_, p_149727_2_, p_149727_3_, p_149727_4_, 3); + } + + return true; + } + else + { + if (itemstack.getItem() == Items.glass_bottle) + { + if (j1 > 0) + { + if (!p_149727_5_.capabilities.isCreativeMode) + { + ItemStack itemstack1 = new ItemStack(Items.potionitem, 1, 0); + + if (!p_149727_5_.inventory.addItemStackToInventory(itemstack1)) + { + p_149727_1_.spawnEntityInWorld(new EntityItem(p_149727_1_, (double)p_149727_2_ + 0.5D, (double)p_149727_3_ + 1.5D, (double)p_149727_4_ + 0.5D, itemstack1)); + } + else if (p_149727_5_ instanceof EntityPlayerMP) + { + ((EntityPlayerMP)p_149727_5_).sendContainerToPlayer(p_149727_5_.inventoryContainer); + } + + --itemstack.stackSize; + + if (itemstack.stackSize <= 0) + { + p_149727_5_.inventory.setInventorySlotContents(p_149727_5_.inventory.currentItem, (ItemStack)null); + } + } + + this.func_150024_a(p_149727_1_, p_149727_2_, p_149727_3_, p_149727_4_, j1 - 1); + } + } + else if (j1 > 0 && itemstack.getItem() instanceof ItemArmor && ((ItemArmor)itemstack.getItem()).getArmorMaterial() == ItemArmor.ArmorMaterial.CLOTH) + { + ItemArmor itemarmor = (ItemArmor)itemstack.getItem(); + itemarmor.removeColor(itemstack); + this.func_150024_a(p_149727_1_, p_149727_2_, p_149727_3_, p_149727_4_, j1 - 1); + return true; + } + + return false; + } + } + } + } + + public void func_150024_a(World p_150024_1_, int p_150024_2_, int p_150024_3_, int p_150024_4_, int p_150024_5_) + { + p_150024_1_.setBlockMetadataWithNotify(p_150024_2_, p_150024_3_, p_150024_4_, MathHelper.clamp_int(p_150024_5_, 0, 3), 2); + p_150024_1_.func_147453_f(p_150024_2_, p_150024_3_, p_150024_4_, this); + } + + public void fillWithRain(World p_149639_1_, int p_149639_2_, int p_149639_3_, int p_149639_4_) + { + if (p_149639_1_.rand.nextInt(20) == 1) + { + int l = p_149639_1_.getBlockMetadata(p_149639_2_, p_149639_3_, p_149639_4_); + + if (l < 3) + { + p_149639_1_.setBlockMetadataWithNotify(p_149639_2_, p_149639_3_, p_149639_4_, l + 1, 2); + } + } + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return Items.cauldron; + } + + @SideOnly(Side.CLIENT) + public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) + { + return Items.cauldron; + } + + public boolean hasComparatorInputOverride() + { + return true; + } + + public int getComparatorInputOverride(World p_149736_1_, int p_149736_2_, int p_149736_3_, int p_149736_4_, int p_149736_5_) + { + int i1 = p_149736_1_.getBlockMetadata(p_149736_2_, p_149736_3_, p_149736_4_); + return func_150027_b(i1); + } + + public static int func_150027_b(int p_150027_0_) + { + return p_150027_0_; + } + + @SideOnly(Side.CLIENT) + public static float getRenderLiquidLevel(int p_150025_0_) + { + int j = MathHelper.clamp_int(p_150025_0_, 0, 3); + return (float)(6 + 3 * j) / 16.0F; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockChest.java b/src/main/java/net/minecraft/block/BlockChest.java new file mode 100644 index 0000000..0166688 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockChest.java @@ -0,0 +1,526 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Iterator; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.passive.EntityOcelot; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.InventoryLargeChest; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityChest; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.MathHelper; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import static net.minecraftforge.common.util.ForgeDirection.*; + +public class BlockChest extends BlockContainer +{ + private final Random field_149955_b = new Random(); + public final int field_149956_a; + private static final String __OBFID = "CL_00000214"; + + protected BlockChest(int p_i45397_1_) + { + super(Material.wood); + this.field_149956_a = p_i45397_1_; + this.setCreativeTab(CreativeTabs.tabDecorations); + this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F); + } + + public boolean isOpaqueCube() + { + return false; + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public int getRenderType() + { + return 22; + } + + public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) + { + if (p_149719_1_.getBlock(p_149719_2_, p_149719_3_, p_149719_4_ - 1) == this) + { + this.setBlockBounds(0.0625F, 0.0F, 0.0F, 0.9375F, 0.875F, 0.9375F); + } + else if (p_149719_1_.getBlock(p_149719_2_, p_149719_3_, p_149719_4_ + 1) == this) + { + this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 1.0F); + } + else if (p_149719_1_.getBlock(p_149719_2_ - 1, p_149719_3_, p_149719_4_) == this) + { + this.setBlockBounds(0.0F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F); + } + else if (p_149719_1_.getBlock(p_149719_2_ + 1, p_149719_3_, p_149719_4_) == this) + { + this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 1.0F, 0.875F, 0.9375F); + } + else + { + this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F); + } + } + + public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_) + { + super.onBlockAdded(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_); + this.func_149954_e(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_); + Block block = p_149726_1_.getBlock(p_149726_2_, p_149726_3_, p_149726_4_ - 1); + Block block1 = p_149726_1_.getBlock(p_149726_2_, p_149726_3_, p_149726_4_ + 1); + Block block2 = p_149726_1_.getBlock(p_149726_2_ - 1, p_149726_3_, p_149726_4_); + Block block3 = p_149726_1_.getBlock(p_149726_2_ + 1, p_149726_3_, p_149726_4_); + + if (block == this) + { + this.func_149954_e(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_ - 1); + } + + if (block1 == this) + { + this.func_149954_e(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_ + 1); + } + + if (block2 == this) + { + this.func_149954_e(p_149726_1_, p_149726_2_ - 1, p_149726_3_, p_149726_4_); + } + + if (block3 == this) + { + this.func_149954_e(p_149726_1_, p_149726_2_ + 1, p_149726_3_, p_149726_4_); + } + } + + public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_) + { + Block block = p_149689_1_.getBlock(p_149689_2_, p_149689_3_, p_149689_4_ - 1); + Block block1 = p_149689_1_.getBlock(p_149689_2_, p_149689_3_, p_149689_4_ + 1); + Block block2 = p_149689_1_.getBlock(p_149689_2_ - 1, p_149689_3_, p_149689_4_); + Block block3 = p_149689_1_.getBlock(p_149689_2_ + 1, p_149689_3_, p_149689_4_); + byte b0 = 0; + int l = MathHelper.floor_double((double)(p_149689_5_.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + + if (l == 0) + { + b0 = 2; + } + + if (l == 1) + { + b0 = 5; + } + + if (l == 2) + { + b0 = 3; + } + + if (l == 3) + { + b0 = 4; + } + + if (block != this && block1 != this && block2 != this && block3 != this) + { + p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, b0, 3); + } + else + { + if ((block == this || block1 == this) && (b0 == 4 || b0 == 5)) + { + if (block == this) + { + p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_ - 1, b0, 3); + } + else + { + p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_ + 1, b0, 3); + } + + p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, b0, 3); + } + + if ((block2 == this || block3 == this) && (b0 == 2 || b0 == 3)) + { + if (block2 == this) + { + p_149689_1_.setBlockMetadataWithNotify(p_149689_2_ - 1, p_149689_3_, p_149689_4_, b0, 3); + } + else + { + p_149689_1_.setBlockMetadataWithNotify(p_149689_2_ + 1, p_149689_3_, p_149689_4_, b0, 3); + } + + p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, b0, 3); + } + } + + if (p_149689_6_.hasDisplayName()) + { + ((TileEntityChest)p_149689_1_.getTileEntity(p_149689_2_, p_149689_3_, p_149689_4_)).func_145976_a(p_149689_6_.getDisplayName()); + } + } + + public void func_149954_e(World p_149954_1_, int p_149954_2_, int p_149954_3_, int p_149954_4_) + { + if (!p_149954_1_.isRemote) + { + Block block = p_149954_1_.getBlock(p_149954_2_, p_149954_3_, p_149954_4_ - 1); + Block block1 = p_149954_1_.getBlock(p_149954_2_, p_149954_3_, p_149954_4_ + 1); + Block block2 = p_149954_1_.getBlock(p_149954_2_ - 1, p_149954_3_, p_149954_4_); + Block block3 = p_149954_1_.getBlock(p_149954_2_ + 1, p_149954_3_, p_149954_4_); + boolean flag = true; + int l; + Block block4; + int i1; + Block block5; + boolean flag1; + byte b0; + int j1; + + if (block != this && block1 != this) + { + if (block2 != this && block3 != this) + { + b0 = 3; + + if (block.func_149730_j() && !block1.func_149730_j()) + { + b0 = 3; + } + + if (block1.func_149730_j() && !block.func_149730_j()) + { + b0 = 2; + } + + if (block2.func_149730_j() && !block3.func_149730_j()) + { + b0 = 5; + } + + if (block3.func_149730_j() && !block2.func_149730_j()) + { + b0 = 4; + } + } + else + { + l = block2 == this ? p_149954_2_ - 1 : p_149954_2_ + 1; + block4 = p_149954_1_.getBlock(l, p_149954_3_, p_149954_4_ - 1); + i1 = block2 == this ? p_149954_2_ - 1 : p_149954_2_ + 1; + block5 = p_149954_1_.getBlock(i1, p_149954_3_, p_149954_4_ + 1); + b0 = 3; + flag1 = true; + + if (block2 == this) + { + j1 = p_149954_1_.getBlockMetadata(p_149954_2_ - 1, p_149954_3_, p_149954_4_); + } + else + { + j1 = p_149954_1_.getBlockMetadata(p_149954_2_ + 1, p_149954_3_, p_149954_4_); + } + + if (j1 == 2) + { + b0 = 2; + } + + if ((block.func_149730_j() || block4.func_149730_j()) && !block1.func_149730_j() && !block5.func_149730_j()) + { + b0 = 3; + } + + if ((block1.func_149730_j() || block5.func_149730_j()) && !block.func_149730_j() && !block4.func_149730_j()) + { + b0 = 2; + } + } + } + else + { + l = block == this ? p_149954_4_ - 1 : p_149954_4_ + 1; + block4 = p_149954_1_.getBlock(p_149954_2_ - 1, p_149954_3_, l); + i1 = block == this ? p_149954_4_ - 1 : p_149954_4_ + 1; + block5 = p_149954_1_.getBlock(p_149954_2_ + 1, p_149954_3_, i1); + b0 = 5; + flag1 = true; + + if (block == this) + { + j1 = p_149954_1_.getBlockMetadata(p_149954_2_, p_149954_3_, p_149954_4_ - 1); + } + else + { + j1 = p_149954_1_.getBlockMetadata(p_149954_2_, p_149954_3_, p_149954_4_ + 1); + } + + if (j1 == 4) + { + b0 = 4; + } + + if ((block2.func_149730_j() || block4.func_149730_j()) && !block3.func_149730_j() && !block5.func_149730_j()) + { + b0 = 5; + } + + if ((block3.func_149730_j() || block5.func_149730_j()) && !block2.func_149730_j() && !block4.func_149730_j()) + { + b0 = 4; + } + } + + p_149954_1_.setBlockMetadataWithNotify(p_149954_2_, p_149954_3_, p_149954_4_, b0, 3); + } + } + + public boolean canPlaceBlockAt(World p_149742_1_, int p_149742_2_, int p_149742_3_, int p_149742_4_) + { + int l = 0; + + if (p_149742_1_.getBlock(p_149742_2_ - 1, p_149742_3_, p_149742_4_) == this) + { + ++l; + } + + if (p_149742_1_.getBlock(p_149742_2_ + 1, p_149742_3_, p_149742_4_) == this) + { + ++l; + } + + if (p_149742_1_.getBlock(p_149742_2_, p_149742_3_, p_149742_4_ - 1) == this) + { + ++l; + } + + if (p_149742_1_.getBlock(p_149742_2_, p_149742_3_, p_149742_4_ + 1) == this) + { + ++l; + } + + return l > 1 ? false : (this.func_149952_n(p_149742_1_, p_149742_2_ - 1, p_149742_3_, p_149742_4_) ? false : (this.func_149952_n(p_149742_1_, p_149742_2_ + 1, p_149742_3_, p_149742_4_) ? false : (this.func_149952_n(p_149742_1_, p_149742_2_, p_149742_3_, p_149742_4_ - 1) ? false : !this.func_149952_n(p_149742_1_, p_149742_2_, p_149742_3_, p_149742_4_ + 1)))); + } + + private boolean func_149952_n(World p_149952_1_, int p_149952_2_, int p_149952_3_, int p_149952_4_) + { + return p_149952_1_.getBlock(p_149952_2_, p_149952_3_, p_149952_4_) != this ? false : (p_149952_1_.getBlock(p_149952_2_ - 1, p_149952_3_, p_149952_4_) == this ? true : (p_149952_1_.getBlock(p_149952_2_ + 1, p_149952_3_, p_149952_4_) == this ? true : (p_149952_1_.getBlock(p_149952_2_, p_149952_3_, p_149952_4_ - 1) == this ? true : p_149952_1_.getBlock(p_149952_2_, p_149952_3_, p_149952_4_ + 1) == this))); + } + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) + { + super.onNeighborBlockChange(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, p_149695_5_); + TileEntityChest tileentitychest = (TileEntityChest)p_149695_1_.getTileEntity(p_149695_2_, p_149695_3_, p_149695_4_); + + if (tileentitychest != null) + { + tileentitychest.updateContainingBlockInfo(); + } + } + + public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) + { + TileEntityChest tileentitychest = (TileEntityChest)p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_); + + if (tileentitychest != null) + { + for (int i1 = 0; i1 < tileentitychest.getSizeInventory(); ++i1) + { + ItemStack itemstack = tileentitychest.getStackInSlot(i1); + + if (itemstack != null) + { + float f = this.field_149955_b.nextFloat() * 0.8F + 0.1F; + float f1 = this.field_149955_b.nextFloat() * 0.8F + 0.1F; + EntityItem entityitem; + + for (float f2 = this.field_149955_b.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; p_149749_1_.spawnEntityInWorld(entityitem)) + { + int j1 = this.field_149955_b.nextInt(21) + 10; + + if (j1 > itemstack.stackSize) + { + j1 = itemstack.stackSize; + } + + itemstack.stackSize -= j1; + entityitem = new EntityItem(p_149749_1_, (double)((float)p_149749_2_ + f), (double)((float)p_149749_3_ + f1), (double)((float)p_149749_4_ + f2), new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage())); + float f3 = 0.05F; + entityitem.motionX = (double)((float)this.field_149955_b.nextGaussian() * f3); + entityitem.motionY = (double)((float)this.field_149955_b.nextGaussian() * f3 + 0.2F); + entityitem.motionZ = (double)((float)this.field_149955_b.nextGaussian() * f3); + + if (itemstack.hasTagCompound()) + { + entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); + } + } + } + } + + p_149749_1_.func_147453_f(p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_); + } + + super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_); + } + + public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) + { + if (p_149727_1_.isRemote) + { + return true; + } + else + { + IInventory iinventory = this.func_149951_m(p_149727_1_, p_149727_2_, p_149727_3_, p_149727_4_); + + if (iinventory != null) + { + p_149727_5_.displayGUIChest(iinventory); + } + + return true; + } + } + + public IInventory func_149951_m(World p_149951_1_, int p_149951_2_, int p_149951_3_, int p_149951_4_) + { + Object object = (TileEntityChest)p_149951_1_.getTileEntity(p_149951_2_, p_149951_3_, p_149951_4_); + + if (object == null) + { + return null; + } + else if (p_149951_1_.isSideSolid(p_149951_2_, p_149951_3_ + 1, p_149951_4_, DOWN)) + { + return null; + } + else if (func_149953_o(p_149951_1_, p_149951_2_, p_149951_3_, p_149951_4_)) + { + return null; + } + else if (p_149951_1_.getBlock(p_149951_2_ - 1, p_149951_3_, p_149951_4_) == this && (p_149951_1_.isSideSolid(p_149951_2_ - 1, p_149951_3_ + 1, p_149951_4_, DOWN) || func_149953_o(p_149951_1_, p_149951_2_ - 1, p_149951_3_, p_149951_4_))) + { + return null; + } + else if (p_149951_1_.getBlock(p_149951_2_ + 1, p_149951_3_, p_149951_4_) == this && (p_149951_1_.isSideSolid(p_149951_2_ + 1, p_149951_3_ + 1, p_149951_4_, DOWN) || func_149953_o(p_149951_1_, p_149951_2_ + 1, p_149951_3_, p_149951_4_))) + { + return null; + } + else if (p_149951_1_.getBlock(p_149951_2_, p_149951_3_, p_149951_4_ - 1) == this && (p_149951_1_.isSideSolid(p_149951_2_, p_149951_3_ + 1, p_149951_4_ - 1, DOWN) || func_149953_o(p_149951_1_, p_149951_2_, p_149951_3_, p_149951_4_ - 1))) + { + return null; + } + else if (p_149951_1_.getBlock(p_149951_2_, p_149951_3_, p_149951_4_ + 1) == this && (p_149951_1_.isSideSolid(p_149951_2_, p_149951_3_ + 1, p_149951_4_ + 1, DOWN) || func_149953_o(p_149951_1_, p_149951_2_, p_149951_3_, p_149951_4_ + 1))) + { + return null; + } + else + { + if (p_149951_1_.getBlock(p_149951_2_ - 1, p_149951_3_, p_149951_4_) == this) + { + object = new InventoryLargeChest("container.chestDouble", (TileEntityChest)p_149951_1_.getTileEntity(p_149951_2_ - 1, p_149951_3_, p_149951_4_), (IInventory)object); + } + + if (p_149951_1_.getBlock(p_149951_2_ + 1, p_149951_3_, p_149951_4_) == this) + { + object = new InventoryLargeChest("container.chestDouble", (IInventory)object, (TileEntityChest)p_149951_1_.getTileEntity(p_149951_2_ + 1, p_149951_3_, p_149951_4_)); + } + + if (p_149951_1_.getBlock(p_149951_2_, p_149951_3_, p_149951_4_ - 1) == this) + { + object = new InventoryLargeChest("container.chestDouble", (TileEntityChest)p_149951_1_.getTileEntity(p_149951_2_, p_149951_3_, p_149951_4_ - 1), (IInventory)object); + } + + if (p_149951_1_.getBlock(p_149951_2_, p_149951_3_, p_149951_4_ + 1) == this) + { + object = new InventoryLargeChest("container.chestDouble", (IInventory)object, (TileEntityChest)p_149951_1_.getTileEntity(p_149951_2_, p_149951_3_, p_149951_4_ + 1)); + } + + return (IInventory)object; + } + } + + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) + { + TileEntityChest tileentitychest = new TileEntityChest(); + return tileentitychest; + } + + public boolean canProvidePower() + { + return this.field_149956_a == 1; + } + + public int isProvidingWeakPower(IBlockAccess p_149709_1_, int p_149709_2_, int p_149709_3_, int p_149709_4_, int p_149709_5_) + { + if (!this.canProvidePower()) + { + return 0; + } + else + { + int i1 = ((TileEntityChest)p_149709_1_.getTileEntity(p_149709_2_, p_149709_3_, p_149709_4_)).numPlayersUsing; + return MathHelper.clamp_int(i1, 0, 15); + } + } + + public int isProvidingStrongPower(IBlockAccess p_149748_1_, int p_149748_2_, int p_149748_3_, int p_149748_4_, int p_149748_5_) + { + return p_149748_5_ == 1 ? this.isProvidingWeakPower(p_149748_1_, p_149748_2_, p_149748_3_, p_149748_4_, p_149748_5_) : 0; + } + + private static boolean func_149953_o(World p_149953_0_, int p_149953_1_, int p_149953_2_, int p_149953_3_) + { + Iterator iterator = p_149953_0_.getEntitiesWithinAABB(EntityOcelot.class, AxisAlignedBB.getAABBPool().getAABB((double)p_149953_1_, (double)(p_149953_2_ + 1), (double)p_149953_3_, (double)(p_149953_1_ + 1), (double)(p_149953_2_ + 2), (double)(p_149953_3_ + 1))).iterator(); + EntityOcelot entityocelot1; + + do + { + if (!iterator.hasNext()) + { + return false; + } + + EntityOcelot entityocelot = (EntityOcelot)iterator.next(); + entityocelot1 = (EntityOcelot)entityocelot; + } + while (!entityocelot1.isSitting()); + + return true; + } + + public boolean hasComparatorInputOverride() + { + return true; + } + + public int getComparatorInputOverride(World p_149736_1_, int p_149736_2_, int p_149736_3_, int p_149736_4_, int p_149736_5_) + { + return Container.calcRedstoneFromInventory(this.func_149951_m(p_149736_1_, p_149736_2_, p_149736_3_, p_149736_4_)); + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.blockIcon = p_149651_1_.registerIcon("planks_oak"); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockClay.java b/src/main/java/net/minecraft/block/BlockClay.java new file mode 100644 index 0000000..2db650f --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockClay.java @@ -0,0 +1,28 @@ +package net.minecraft.block; + +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Items; +import net.minecraft.item.Item; + +public class BlockClay extends Block +{ + private static final String __OBFID = "CL_00000215"; + + public BlockClay() + { + super(Material.clay); + this.setCreativeTab(CreativeTabs.tabBlock); + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return Items.clay_ball; + } + + public int quantityDropped(Random p_149745_1_) + { + return 4; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockCocoa.java b/src/main/java/net/minecraft/block/BlockCocoa.java new file mode 100644 index 0000000..37f8cf4 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockCocoa.java @@ -0,0 +1,234 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.Direction; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockCocoa extends BlockDirectional implements IGrowable +{ + @SideOnly(Side.CLIENT) + private IIcon[] field_149989_a; + private static final String __OBFID = "CL_00000216"; + + public BlockCocoa() + { + super(Material.plants); + this.setTickRandomly(true); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return this.field_149989_a[2]; + } + + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) + { + if (!this.canBlockStay(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_)) + { + this.dropBlockAsItem(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_), 0); + p_149674_1_.setBlock(p_149674_2_, p_149674_3_, p_149674_4_, getBlockById(0), 0, 2); + } + else if (p_149674_1_.rand.nextInt(5) == 0) + { + int l = p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_); + int i1 = func_149987_c(l); + + if (i1 < 2) + { + ++i1; + p_149674_1_.setBlockMetadataWithNotify(p_149674_2_, p_149674_3_, p_149674_4_, i1 << 2 | getDirection(l), 2); + } + } + } + + @SideOnly(Side.CLIENT) + public IIcon getCocoaIcon(int p_149988_1_) + { + if (p_149988_1_ < 0 || p_149988_1_ >= this.field_149989_a.length) + { + p_149988_1_ = this.field_149989_a.length - 1; + } + + return this.field_149989_a[p_149988_1_]; + } + + public boolean canBlockStay(World p_149718_1_, int p_149718_2_, int p_149718_3_, int p_149718_4_) + { + int l = getDirection(p_149718_1_.getBlockMetadata(p_149718_2_, p_149718_3_, p_149718_4_)); + p_149718_2_ += Direction.offsetX[l]; + p_149718_4_ += Direction.offsetZ[l]; + Block block = p_149718_1_.getBlock(p_149718_2_, p_149718_3_, p_149718_4_); + return block == Blocks.log && BlockLog.func_150165_c(p_149718_1_.getBlockMetadata(p_149718_2_, p_149718_3_, p_149718_4_)) == 3; + } + + public int getRenderType() + { + return 28; + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public boolean isOpaqueCube() + { + return false; + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) + { + this.setBlockBoundsBasedOnState(p_149668_1_, p_149668_2_, p_149668_3_, p_149668_4_); + return super.getCollisionBoundingBoxFromPool(p_149668_1_, p_149668_2_, p_149668_3_, p_149668_4_); + } + + public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) + { + int l = p_149719_1_.getBlockMetadata(p_149719_2_, p_149719_3_, p_149719_4_); + int i1 = getDirection(l); + int j1 = func_149987_c(l); + int k1 = 4 + j1 * 2; + int l1 = 5 + j1 * 2; + float f = (float)k1 / 2.0F; + + switch (i1) + { + case 0: + this.setBlockBounds((8.0F - f) / 16.0F, (12.0F - (float)l1) / 16.0F, (15.0F - (float)k1) / 16.0F, (8.0F + f) / 16.0F, 0.75F, 0.9375F); + break; + case 1: + this.setBlockBounds(0.0625F, (12.0F - (float)l1) / 16.0F, (8.0F - f) / 16.0F, (1.0F + (float)k1) / 16.0F, 0.75F, (8.0F + f) / 16.0F); + break; + case 2: + this.setBlockBounds((8.0F - f) / 16.0F, (12.0F - (float)l1) / 16.0F, 0.0625F, (8.0F + f) / 16.0F, 0.75F, (1.0F + (float)k1) / 16.0F); + break; + case 3: + this.setBlockBounds((15.0F - (float)k1) / 16.0F, (12.0F - (float)l1) / 16.0F, (8.0F - f) / 16.0F, 0.9375F, 0.75F, (8.0F + f) / 16.0F); + } + } + + public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_) + { + int l = ((MathHelper.floor_double((double)(p_149689_5_.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3) + 0) % 4; + p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, l, 2); + } + + public int onBlockPlaced(World p_149660_1_, int p_149660_2_, int p_149660_3_, int p_149660_4_, int p_149660_5_, float p_149660_6_, float p_149660_7_, float p_149660_8_, int p_149660_9_) + { + if (p_149660_5_ == 1 || p_149660_5_ == 0) + { + p_149660_5_ = 2; + } + + return Direction.rotateOpposite[Direction.facingToDirection[p_149660_5_]]; + } + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) + { + if (!this.canBlockStay(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_)) + { + this.dropBlockAsItem(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, p_149695_1_.getBlockMetadata(p_149695_2_, p_149695_3_, p_149695_4_), 0); + p_149695_1_.setBlock(p_149695_2_, p_149695_3_, p_149695_4_, getBlockById(0), 0, 2); + } + } + + @SideOnly(Side.CLIENT) + public AxisAlignedBB getSelectedBoundingBoxFromPool(World p_149633_1_, int p_149633_2_, int p_149633_3_, int p_149633_4_) + { + this.setBlockBoundsBasedOnState(p_149633_1_, p_149633_2_, p_149633_3_, p_149633_4_); + return super.getSelectedBoundingBoxFromPool(p_149633_1_, p_149633_2_, p_149633_3_, p_149633_4_); + } + + public static int func_149987_c(int p_149987_0_) + { + return (p_149987_0_ & 12) >> 2; + } + + public void dropBlockAsItemWithChance(World p_149690_1_, int p_149690_2_, int p_149690_3_, int p_149690_4_, int p_149690_5_, float p_149690_6_, int p_149690_7_) + { + super.dropBlockAsItemWithChance(p_149690_1_, p_149690_2_, p_149690_3_, p_149690_4_, p_149690_5_, p_149690_6_, p_149690_7_); + } + + @Override + public ArrayList getDrops(World world, int x, int y, int z, int p_149690_5_, int fortune) + { + ArrayList dropped = super.getDrops(world, x, y, z, p_149690_5_, fortune); + int j1 = func_149987_c(p_149690_5_); + byte b0 = 1; + + if (j1 >= 2) + { + b0 = 3; + } + + for (int k1 = 0; k1 < b0; ++k1) + { + dropped.add(new ItemStack(Items.dye, 1, 3)); + } + return dropped; + } + + @SideOnly(Side.CLIENT) + public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) + { + return Items.dye; + } + + public int getDamageValue(World p_149643_1_, int p_149643_2_, int p_149643_3_, int p_149643_4_) + { + return 3; + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.field_149989_a = new IIcon[3]; + + for (int i = 0; i < this.field_149989_a.length; ++i) + { + this.field_149989_a[i] = p_149651_1_.registerIcon(this.getTextureName() + "_stage_" + i); + } + } + + public boolean func_149851_a(World p_149851_1_, int p_149851_2_, int p_149851_3_, int p_149851_4_, boolean p_149851_5_) + { + int l = p_149851_1_.getBlockMetadata(p_149851_2_, p_149851_3_, p_149851_4_); + int i1 = func_149987_c(l); + return i1 < 2; + } + + public boolean func_149852_a(World p_149852_1_, Random p_149852_2_, int p_149852_3_, int p_149852_4_, int p_149852_5_) + { + return true; + } + + public void func_149853_b(World p_149853_1_, Random p_149853_2_, int p_149853_3_, int p_149853_4_, int p_149853_5_) + { + int l = p_149853_1_.getBlockMetadata(p_149853_3_, p_149853_4_, p_149853_5_); + int i1 = BlockDirectional.getDirection(l); + int j1 = func_149987_c(l); + ++j1; + p_149853_1_.setBlockMetadataWithNotify(p_149853_3_, p_149853_4_, p_149853_5_, j1 << 2 | i1, 2); + } + + @Override + public Item getItemDropped(int par1, Random par2Random, int par3) + { + return null; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockColored.java b/src/main/java/net/minecraft/block/BlockColored.java new file mode 100644 index 0000000..b33b0da --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockColored.java @@ -0,0 +1,72 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.block.material.MapColor; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemDye; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +public class BlockColored extends Block +{ + @SideOnly(Side.CLIENT) + private IIcon[] field_150033_a; + private static final String __OBFID = "CL_00000217"; + + public BlockColored(Material p_i45398_1_) + { + super(p_i45398_1_); + this.setCreativeTab(CreativeTabs.tabBlock); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return this.field_150033_a[p_149691_2_ % this.field_150033_a.length]; + } + + public int damageDropped(int p_149692_1_) + { + return p_149692_1_; + } + + public static int func_150032_b(int p_150032_0_) + { + return func_150031_c(p_150032_0_); + } + + public static int func_150031_c(int p_150031_0_) + { + return ~p_150031_0_ & 15; + } + + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_) + { + for (int i = 0; i < 16; ++i) + { + p_149666_3_.add(new ItemStack(p_149666_1_, 1, i)); + } + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.field_150033_a = new IIcon[16]; + + for (int i = 0; i < this.field_150033_a.length; ++i) + { + this.field_150033_a[i] = p_149651_1_.registerIcon(this.getTextureName() + "_" + ItemDye.field_150921_b[func_150031_c(i)]); + } + } + + public MapColor getMapColor(int p_149728_1_) + { + return MapColor.getMapColorForBlockColored(p_149728_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockCommandBlock.java b/src/main/java/net/minecraft/block/BlockCommandBlock.java new file mode 100644 index 0000000..3beb9bf --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockCommandBlock.java @@ -0,0 +1,101 @@ +package net.minecraft.block; + +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.command.server.CommandBlockLogic; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityCommandBlock; +import net.minecraft.world.World; + +public class BlockCommandBlock extends BlockContainer +{ + private static final String __OBFID = "CL_00000219"; + + public BlockCommandBlock() + { + super(Material.iron); + } + + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) + { + return new TileEntityCommandBlock(); + } + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) + { + if (!p_149695_1_.isRemote) + { + boolean flag = p_149695_1_.isBlockIndirectlyGettingPowered(p_149695_2_, p_149695_3_, p_149695_4_); + int l = p_149695_1_.getBlockMetadata(p_149695_2_, p_149695_3_, p_149695_4_); + boolean flag1 = (l & 1) != 0; + + if (flag && !flag1) + { + p_149695_1_.setBlockMetadataWithNotify(p_149695_2_, p_149695_3_, p_149695_4_, l | 1, 4); + p_149695_1_.scheduleBlockUpdate(p_149695_2_, p_149695_3_, p_149695_4_, this, this.tickRate(p_149695_1_)); + } + else if (!flag && flag1) + { + p_149695_1_.setBlockMetadataWithNotify(p_149695_2_, p_149695_3_, p_149695_4_, l & -2, 4); + } + } + } + + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) + { + TileEntity tileentity = p_149674_1_.getTileEntity(p_149674_2_, p_149674_3_, p_149674_4_); + + if (tileentity != null && tileentity instanceof TileEntityCommandBlock) + { + CommandBlockLogic commandblocklogic = ((TileEntityCommandBlock)tileentity).func_145993_a(); + commandblocklogic.func_145755_a(p_149674_1_); + p_149674_1_.func_147453_f(p_149674_2_, p_149674_3_, p_149674_4_, this); + } + } + + public int tickRate(World p_149738_1_) + { + return 1; + } + + public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) + { + TileEntityCommandBlock tileentitycommandblock = (TileEntityCommandBlock)p_149727_1_.getTileEntity(p_149727_2_, p_149727_3_, p_149727_4_); + + if (tileentitycommandblock != null) + { + p_149727_5_.func_146100_a(tileentitycommandblock); + } + + return true; + } + + public boolean hasComparatorInputOverride() + { + return true; + } + + public int getComparatorInputOverride(World p_149736_1_, int p_149736_2_, int p_149736_3_, int p_149736_4_, int p_149736_5_) + { + TileEntity tileentity = p_149736_1_.getTileEntity(p_149736_2_, p_149736_3_, p_149736_4_); + return tileentity != null && tileentity instanceof TileEntityCommandBlock ? ((TileEntityCommandBlock)tileentity).func_145993_a().func_145760_g() : 0; + } + + public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_) + { + TileEntityCommandBlock tileentitycommandblock = (TileEntityCommandBlock)p_149689_1_.getTileEntity(p_149689_2_, p_149689_3_, p_149689_4_); + + if (p_149689_6_.hasDisplayName()) + { + tileentitycommandblock.func_145993_a().func_145754_b(p_149689_6_.getDisplayName()); + } + } + + public int quantityDropped(Random p_149745_1_) + { + return 0; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockCompressed.java b/src/main/java/net/minecraft/block/BlockCompressed.java new file mode 100644 index 0000000..4a6f5ed --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockCompressed.java @@ -0,0 +1,23 @@ +package net.minecraft.block; + +import net.minecraft.block.material.MapColor; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; + +public class BlockCompressed extends Block +{ + private final MapColor field_150202_a; + private static final String __OBFID = "CL_00000268"; + + public BlockCompressed(MapColor p_i45414_1_) + { + super(Material.iron); + this.field_150202_a = p_i45414_1_; + this.setCreativeTab(CreativeTabs.tabBlock); + } + + public MapColor getMapColor(int p_149728_1_) + { + return this.field_150202_a; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockCompressedPowered.java b/src/main/java/net/minecraft/block/BlockCompressedPowered.java new file mode 100644 index 0000000..af6242d --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockCompressedPowered.java @@ -0,0 +1,26 @@ +package net.minecraft.block; + +import net.minecraft.block.material.MapColor; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.world.IBlockAccess; + +public class BlockCompressedPowered extends BlockCompressed +{ + private static final String __OBFID = "CL_00000287"; + + public BlockCompressedPowered(MapColor p_i45416_1_) + { + super(p_i45416_1_); + this.setCreativeTab(CreativeTabs.tabRedstone); + } + + public boolean canProvidePower() + { + return true; + } + + public int isProvidingWeakPower(IBlockAccess p_149709_1_, int p_149709_2_, int p_149709_3_, int p_149709_4_, int p_149709_5_) + { + return 15; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockContainer.java b/src/main/java/net/minecraft/block/BlockContainer.java new file mode 100644 index 0000000..000cbf0 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockContainer.java @@ -0,0 +1,34 @@ +package net.minecraft.block; + +import net.minecraft.block.material.Material; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +public abstract class BlockContainer extends Block implements ITileEntityProvider +{ + private static final String __OBFID = "CL_00000193"; + + protected BlockContainer(Material p_i45386_1_) + { + super(p_i45386_1_); + this.isBlockContainer = true; + } + + public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_) + { + super.onBlockAdded(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_); + } + + public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) + { + super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_); + p_149749_1_.removeTileEntity(p_149749_2_, p_149749_3_, p_149749_4_); + } + + public boolean onBlockEventReceived(World p_149696_1_, int p_149696_2_, int p_149696_3_, int p_149696_4_, int p_149696_5_, int p_149696_6_) + { + super.onBlockEventReceived(p_149696_1_, p_149696_2_, p_149696_3_, p_149696_4_, p_149696_5_, p_149696_6_); + TileEntity tileentity = p_149696_1_.getTileEntity(p_149696_2_, p_149696_3_, p_149696_4_); + return tileentity != null ? tileentity.receiveClientEvent(p_149696_5_, p_149696_6_) : false; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockCrops.java b/src/main/java/net/minecraft/block/BlockCrops.java new file mode 100644 index 0000000..b1aa0dc --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockCrops.java @@ -0,0 +1,212 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.Random; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public class BlockCrops extends BlockBush implements IGrowable +{ + @SideOnly(Side.CLIENT) + private IIcon[] field_149867_a; + private static final String __OBFID = "CL_00000222"; + + protected BlockCrops() + { + this.setTickRandomly(true); + float f = 0.5F; + this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.25F, 0.5F + f); + this.setCreativeTab((CreativeTabs)null); + this.setHardness(0.0F); + this.setStepSound(soundTypeGrass); + this.disableStats(); + } + + protected boolean canPlaceBlockOn(Block p_149854_1_) + { + return p_149854_1_ == Blocks.farmland; + } + + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) + { + super.updateTick(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, p_149674_5_); + + if (p_149674_1_.getBlockLightValue(p_149674_2_, p_149674_3_ + 1, p_149674_4_) >= 9) + { + int l = p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_); + + if (l < 7) + { + float f = this.func_149864_n(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_); + + if (p_149674_5_.nextInt((int)(25.0F / f) + 1) == 0) + { + ++l; + p_149674_1_.setBlockMetadataWithNotify(p_149674_2_, p_149674_3_, p_149674_4_, l, 2); + } + } + } + } + + public void func_149863_m(World p_149863_1_, int p_149863_2_, int p_149863_3_, int p_149863_4_) + { + int l = p_149863_1_.getBlockMetadata(p_149863_2_, p_149863_3_, p_149863_4_) + MathHelper.getRandomIntegerInRange(p_149863_1_.rand, 2, 5); + + if (l > 7) + { + l = 7; + } + + p_149863_1_.setBlockMetadataWithNotify(p_149863_2_, p_149863_3_, p_149863_4_, l, 2); + } + + private float func_149864_n(World p_149864_1_, int p_149864_2_, int p_149864_3_, int p_149864_4_) + { + float f = 1.0F; + Block block = p_149864_1_.getBlock(p_149864_2_, p_149864_3_, p_149864_4_ - 1); + Block block1 = p_149864_1_.getBlock(p_149864_2_, p_149864_3_, p_149864_4_ + 1); + Block block2 = p_149864_1_.getBlock(p_149864_2_ - 1, p_149864_3_, p_149864_4_); + Block block3 = p_149864_1_.getBlock(p_149864_2_ + 1, p_149864_3_, p_149864_4_); + Block block4 = p_149864_1_.getBlock(p_149864_2_ - 1, p_149864_3_, p_149864_4_ - 1); + Block block5 = p_149864_1_.getBlock(p_149864_2_ + 1, p_149864_3_, p_149864_4_ - 1); + Block block6 = p_149864_1_.getBlock(p_149864_2_ + 1, p_149864_3_, p_149864_4_ + 1); + Block block7 = p_149864_1_.getBlock(p_149864_2_ - 1, p_149864_3_, p_149864_4_ + 1); + boolean flag = block2 == this || block3 == this; + boolean flag1 = block == this || block1 == this; + boolean flag2 = block4 == this || block5 == this || block6 == this || block7 == this; + + for (int l = p_149864_2_ - 1; l <= p_149864_2_ + 1; ++l) + { + for (int i1 = p_149864_4_ - 1; i1 <= p_149864_4_ + 1; ++i1) + { + float f1 = 0.0F; + + if (p_149864_1_.getBlock(l, p_149864_3_ - 1, i1).canSustainPlant(p_149864_1_, l, p_149864_3_ - 1, i1, ForgeDirection.UP, this)) + { + f1 = 1.0F; + + if (p_149864_1_.getBlock(l, p_149864_3_ - 1, i1).isFertile(p_149864_1_, l, p_149864_3_ - 1, i1)) + { + f1 = 3.0F; + } + } + + if (l != p_149864_2_ || i1 != p_149864_4_) + { + f1 /= 4.0F; + } + + f += f1; + } + } + + if (flag2 || flag && flag1) + { + f /= 2.0F; + } + + return f; + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + if (p_149691_2_ < 0 || p_149691_2_ > 7) + { + p_149691_2_ = 7; + } + + return this.field_149867_a[p_149691_2_]; + } + + public int getRenderType() + { + return 6; + } + + protected Item func_149866_i() + { + return Items.wheat_seeds; + } + + protected Item func_149865_P() + { + return Items.wheat; + } + + public void dropBlockAsItemWithChance(World p_149690_1_, int p_149690_2_, int p_149690_3_, int p_149690_4_, int p_149690_5_, float p_149690_6_, int p_149690_7_) + { + super.dropBlockAsItemWithChance(p_149690_1_, p_149690_2_, p_149690_3_, p_149690_4_, p_149690_5_, p_149690_6_, 0); + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return p_149650_1_ == 7 ? this.func_149865_P() : this.func_149866_i(); + } + + public int quantityDropped(Random p_149745_1_) + { + return 1; + } + + public boolean func_149851_a(World p_149851_1_, int p_149851_2_, int p_149851_3_, int p_149851_4_, boolean p_149851_5_) + { + return p_149851_1_.getBlockMetadata(p_149851_2_, p_149851_3_, p_149851_4_) != 7; + } + + public boolean func_149852_a(World p_149852_1_, Random p_149852_2_, int p_149852_3_, int p_149852_4_, int p_149852_5_) + { + return true; + } + + @SideOnly(Side.CLIENT) + public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) + { + return this.func_149866_i(); + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.field_149867_a = new IIcon[8]; + + for (int i = 0; i < this.field_149867_a.length; ++i) + { + this.field_149867_a[i] = p_149651_1_.registerIcon(this.getTextureName() + "_stage_" + i); + } + } + + public void func_149853_b(World p_149853_1_, Random p_149853_2_, int p_149853_3_, int p_149853_4_, int p_149853_5_) + { + this.func_149863_m(p_149853_1_, p_149853_3_, p_149853_4_, p_149853_5_); + } + + @Override + public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) + { + ArrayList ret = super.getDrops(world, x, y, z, metadata, fortune); + + if (metadata >= 7) + { + for (int i = 0; i < 3 + fortune; ++i) + { + if (world.rand.nextInt(15) <= metadata) + { + ret.add(new ItemStack(this.func_149866_i(), 1, 0)); + } + } + } + + return ret; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockDaylightDetector.java b/src/main/java/net/minecraft/block/BlockDaylightDetector.java new file mode 100644 index 0000000..e2db32d --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockDaylightDetector.java @@ -0,0 +1,113 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityDaylightDetector; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.EnumSkyBlock; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockDaylightDetector extends BlockContainer +{ + private IIcon[] field_149958_a = new IIcon[2]; + private static final String __OBFID = "CL_00000223"; + + public BlockDaylightDetector() + { + super(Material.wood); + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.375F, 1.0F); + this.setCreativeTab(CreativeTabs.tabRedstone); + } + + public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.375F, 1.0F); + } + + public int isProvidingWeakPower(IBlockAccess p_149709_1_, int p_149709_2_, int p_149709_3_, int p_149709_4_, int p_149709_5_) + { + return p_149709_1_.getBlockMetadata(p_149709_2_, p_149709_3_, p_149709_4_); + } + + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) {} + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) {} + + public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_) {} + + public void func_149957_e(World p_149957_1_, int p_149957_2_, int p_149957_3_, int p_149957_4_) + { + if (!p_149957_1_.provider.hasNoSky) + { + int l = p_149957_1_.getBlockMetadata(p_149957_2_, p_149957_3_, p_149957_4_); + int i1 = p_149957_1_.getSavedLightValue(EnumSkyBlock.Sky, p_149957_2_, p_149957_3_, p_149957_4_) - p_149957_1_.skylightSubtracted; + float f = p_149957_1_.getCelestialAngleRadians(1.0F); + + if (f < (float)Math.PI) + { + f += (0.0F - f) * 0.2F; + } + else + { + f += (((float)Math.PI * 2F) - f) * 0.2F; + } + + i1 = Math.round((float)i1 * MathHelper.cos(f)); + + if (i1 < 0) + { + i1 = 0; + } + + if (i1 > 15) + { + i1 = 15; + } + + if (l != i1) + { + p_149957_1_.setBlockMetadataWithNotify(p_149957_2_, p_149957_3_, p_149957_4_, i1, 3); + } + } + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public boolean isOpaqueCube() + { + return false; + } + + public boolean canProvidePower() + { + return true; + } + + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) + { + return new TileEntityDaylightDetector(); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return p_149691_1_ == 1 ? this.field_149958_a[0] : this.field_149958_a[1]; + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.field_149958_a[0] = p_149651_1_.registerIcon(this.getTextureName() + "_top"); + this.field_149958_a[1] = p_149651_1_.registerIcon(this.getTextureName() + "_side"); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockDeadBush.java b/src/main/java/net/minecraft/block/BlockDeadBush.java new file mode 100644 index 0000000..3cfb81f --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockDeadBush.java @@ -0,0 +1,46 @@ +package net.minecraft.block; + +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.stats.StatList; +import net.minecraft.world.World; + +public class BlockDeadBush extends BlockBush +{ + private static final String __OBFID = "CL_00000224"; + + protected BlockDeadBush() + { + super(Material.vine); + float f = 0.4F; + this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.8F, 0.5F + f); + } + + protected boolean canPlaceBlockOn(Block p_149854_1_) + { + return p_149854_1_ == Blocks.sand || p_149854_1_ == Blocks.hardened_clay || p_149854_1_ == Blocks.stained_hardened_clay || p_149854_1_ == Blocks.dirt; + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return null; + } + + public void harvestBlock(World p_149636_1_, EntityPlayer p_149636_2_, int p_149636_3_, int p_149636_4_, int p_149636_5_, int p_149636_6_) + { + if (!p_149636_1_.isRemote && p_149636_2_.getCurrentEquippedItem() != null && p_149636_2_.getCurrentEquippedItem().getItem() == Items.shears) + { + p_149636_2_.addStat(StatList.mineBlockStatArray[Block.getIdFromBlock(this)], 1); + this.dropBlockAsItem(p_149636_1_, p_149636_3_, p_149636_4_, p_149636_5_, new ItemStack(Blocks.deadbush, 1, p_149636_6_)); + } + else + { + super.harvestBlock(p_149636_1_, p_149636_2_, p_149636_3_, p_149636_4_, p_149636_5_, p_149636_6_); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockDirectional.java b/src/main/java/net/minecraft/block/BlockDirectional.java new file mode 100644 index 0000000..d42b619 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockDirectional.java @@ -0,0 +1,18 @@ +package net.minecraft.block; + +import net.minecraft.block.material.Material; + +public abstract class BlockDirectional extends Block +{ + private static final String __OBFID = "CL_00000227"; + + protected BlockDirectional(Material p_i45401_1_) + { + super(p_i45401_1_); + } + + public static int getDirection(int p_149895_0_) + { + return p_149895_0_ & 3; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockDirt.java b/src/main/java/net/minecraft/block/BlockDirt.java new file mode 100644 index 0000000..f1f9d14 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockDirt.java @@ -0,0 +1,124 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockDirt extends Block +{ + public static final String[] field_150009_a = new String[] {"default", "default", "podzol"}; + @SideOnly(Side.CLIENT) + private IIcon field_150008_b; + @SideOnly(Side.CLIENT) + private IIcon field_150010_M; + private static final String __OBFID = "CL_00000228"; + + protected BlockDirt() + { + super(Material.ground); + this.setCreativeTab(CreativeTabs.tabBlock); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + if (p_149691_2_ == 2) + { + if (p_149691_1_ == 1) + { + return this.field_150008_b; + } + + if (p_149691_1_ != 0) + { + return this.field_150010_M; + } + } + + return this.blockIcon; + } + + public int damageDropped(int p_149692_1_) + { + return 0; + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess p_149673_1_, int p_149673_2_, int p_149673_3_, int p_149673_4_, int p_149673_5_) + { + int i1 = p_149673_1_.getBlockMetadata(p_149673_2_, p_149673_3_, p_149673_4_); + + if (i1 == 2) + { + if (p_149673_5_ == 1) + { + return this.field_150008_b; + } + + if (p_149673_5_ != 0) + { + Material material = p_149673_1_.getBlock(p_149673_2_, p_149673_3_ + 1, p_149673_4_).getMaterial(); + + if (material == Material.snow || material == Material.craftedSnow) + { + return Blocks.grass.getIcon(p_149673_1_, p_149673_2_, p_149673_3_, p_149673_4_, p_149673_5_); + } + + Block block = p_149673_1_.getBlock(p_149673_2_, p_149673_3_ + 1, p_149673_4_); + + if (block != Blocks.dirt && block != Blocks.grass) + { + return this.field_150010_M; + } + } + } + + return this.blockIcon; + } + + protected ItemStack createStackedBlock(int p_149644_1_) + { + if (p_149644_1_ == 1) + { + p_149644_1_ = 0; + } + + return super.createStackedBlock(p_149644_1_); + } + + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_) + { + p_149666_3_.add(new ItemStack(this, 1, 0)); + p_149666_3_.add(new ItemStack(this, 1, 2)); + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + super.registerBlockIcons(p_149651_1_); + this.field_150008_b = p_149651_1_.registerIcon(this.getTextureName() + "_" + "podzol_top"); + this.field_150010_M = p_149651_1_.registerIcon(this.getTextureName() + "_" + "podzol_side"); + } + + public int getDamageValue(World p_149643_1_, int p_149643_2_, int p_149643_3_, int p_149643_4_) + { + int l = p_149643_1_.getBlockMetadata(p_149643_2_, p_149643_3_, p_149643_4_); + + if (l == 1) + { + l = 0; + } + + return l; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockDispenser.java b/src/main/java/net/minecraft/block/BlockDispenser.java new file mode 100644 index 0000000..eddc06a --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockDispenser.java @@ -0,0 +1,271 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.dispenser.BehaviorDefaultDispenseItem; +import net.minecraft.dispenser.IBehaviorDispenseItem; +import net.minecraft.dispenser.IBlockSource; +import net.minecraft.dispenser.IPosition; +import net.minecraft.dispenser.PositionImpl; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityDispenser; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.IIcon; +import net.minecraft.util.IRegistry; +import net.minecraft.util.RegistryDefaulted; +import net.minecraft.world.World; + +public class BlockDispenser extends BlockContainer +{ + public static final IRegistry dispenseBehaviorRegistry = new RegistryDefaulted(new BehaviorDefaultDispenseItem()); + protected Random field_149942_b = new Random(); + @SideOnly(Side.CLIENT) + protected IIcon field_149944_M; + @SideOnly(Side.CLIENT) + protected IIcon field_149945_N; + @SideOnly(Side.CLIENT) + protected IIcon field_149946_O; + private static final String __OBFID = "CL_00000229"; + + protected BlockDispenser() + { + super(Material.rock); + this.setCreativeTab(CreativeTabs.tabRedstone); + } + + public int tickRate(World p_149738_1_) + { + return 4; + } + + public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_) + { + super.onBlockAdded(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_); + this.func_149938_m(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_); + } + + private void func_149938_m(World p_149938_1_, int p_149938_2_, int p_149938_3_, int p_149938_4_) + { + if (!p_149938_1_.isRemote) + { + Block block = p_149938_1_.getBlock(p_149938_2_, p_149938_3_, p_149938_4_ - 1); + Block block1 = p_149938_1_.getBlock(p_149938_2_, p_149938_3_, p_149938_4_ + 1); + Block block2 = p_149938_1_.getBlock(p_149938_2_ - 1, p_149938_3_, p_149938_4_); + Block block3 = p_149938_1_.getBlock(p_149938_2_ + 1, p_149938_3_, p_149938_4_); + byte b0 = 3; + + if (block.func_149730_j() && !block1.func_149730_j()) + { + b0 = 3; + } + + if (block1.func_149730_j() && !block.func_149730_j()) + { + b0 = 2; + } + + if (block2.func_149730_j() && !block3.func_149730_j()) + { + b0 = 5; + } + + if (block3.func_149730_j() && !block2.func_149730_j()) + { + b0 = 4; + } + + p_149938_1_.setBlockMetadataWithNotify(p_149938_2_, p_149938_3_, p_149938_4_, b0, 2); + } + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + int k = p_149691_2_ & 7; + return p_149691_1_ == k ? (k != 1 && k != 0 ? this.field_149945_N : this.field_149946_O) : (k != 1 && k != 0 ? (p_149691_1_ != 1 && p_149691_1_ != 0 ? this.blockIcon : this.field_149944_M) : this.field_149944_M); + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.blockIcon = p_149651_1_.registerIcon("furnace_side"); + this.field_149944_M = p_149651_1_.registerIcon("furnace_top"); + this.field_149945_N = p_149651_1_.registerIcon(this.getTextureName() + "_front_horizontal"); + this.field_149946_O = p_149651_1_.registerIcon(this.getTextureName() + "_front_vertical"); + } + + public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) + { + if (p_149727_1_.isRemote) + { + return true; + } + else + { + TileEntityDispenser tileentitydispenser = (TileEntityDispenser)p_149727_1_.getTileEntity(p_149727_2_, p_149727_3_, p_149727_4_); + + if (tileentitydispenser != null) + { + p_149727_5_.func_146102_a(tileentitydispenser); + } + + return true; + } + } + + protected void func_149941_e(World p_149941_1_, int p_149941_2_, int p_149941_3_, int p_149941_4_) + { + BlockSourceImpl blocksourceimpl = new BlockSourceImpl(p_149941_1_, p_149941_2_, p_149941_3_, p_149941_4_); + TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity(); + + if (tileentitydispenser != null) + { + int l = tileentitydispenser.func_146017_i(); + + if (l < 0) + { + p_149941_1_.playAuxSFX(1001, p_149941_2_, p_149941_3_, p_149941_4_, 0); + } + else + { + ItemStack itemstack = tileentitydispenser.getStackInSlot(l); + IBehaviorDispenseItem ibehaviordispenseitem = this.func_149940_a(itemstack); + + if (ibehaviordispenseitem != IBehaviorDispenseItem.itemDispenseBehaviorProvider) + { + ItemStack itemstack1 = ibehaviordispenseitem.dispense(blocksourceimpl, itemstack); + tileentitydispenser.setInventorySlotContents(l, itemstack1.stackSize == 0 ? null : itemstack1); + } + } + } + } + + protected IBehaviorDispenseItem func_149940_a(ItemStack p_149940_1_) + { + return (IBehaviorDispenseItem)dispenseBehaviorRegistry.getObject(p_149940_1_.getItem()); + } + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) + { + boolean flag = p_149695_1_.isBlockIndirectlyGettingPowered(p_149695_2_, p_149695_3_, p_149695_4_) || p_149695_1_.isBlockIndirectlyGettingPowered(p_149695_2_, p_149695_3_ + 1, p_149695_4_); + int l = p_149695_1_.getBlockMetadata(p_149695_2_, p_149695_3_, p_149695_4_); + boolean flag1 = (l & 8) != 0; + + if (flag && !flag1) + { + p_149695_1_.scheduleBlockUpdate(p_149695_2_, p_149695_3_, p_149695_4_, this, this.tickRate(p_149695_1_)); + p_149695_1_.setBlockMetadataWithNotify(p_149695_2_, p_149695_3_, p_149695_4_, l | 8, 4); + } + else if (!flag && flag1) + { + p_149695_1_.setBlockMetadataWithNotify(p_149695_2_, p_149695_3_, p_149695_4_, l & -9, 4); + } + } + + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) + { + if (!p_149674_1_.isRemote) + { + this.func_149941_e(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_); + } + } + + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) + { + return new TileEntityDispenser(); + } + + public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_) + { + int l = BlockPistonBase.determineOrientation(p_149689_1_, p_149689_2_, p_149689_3_, p_149689_4_, p_149689_5_); + p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, l, 2); + + if (p_149689_6_.hasDisplayName()) + { + ((TileEntityDispenser)p_149689_1_.getTileEntity(p_149689_2_, p_149689_3_, p_149689_4_)).func_146018_a(p_149689_6_.getDisplayName()); + } + } + + public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) + { + TileEntityDispenser tileentitydispenser = (TileEntityDispenser)p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_); + + if (tileentitydispenser != null) + { + for (int i1 = 0; i1 < tileentitydispenser.getSizeInventory(); ++i1) + { + ItemStack itemstack = tileentitydispenser.getStackInSlot(i1); + + if (itemstack != null) + { + float f = this.field_149942_b.nextFloat() * 0.8F + 0.1F; + float f1 = this.field_149942_b.nextFloat() * 0.8F + 0.1F; + float f2 = this.field_149942_b.nextFloat() * 0.8F + 0.1F; + + while (itemstack.stackSize > 0) + { + int j1 = this.field_149942_b.nextInt(21) + 10; + + if (j1 > itemstack.stackSize) + { + j1 = itemstack.stackSize; + } + + itemstack.stackSize -= j1; + EntityItem entityitem = new EntityItem(p_149749_1_, (double)((float)p_149749_2_ + f), (double)((float)p_149749_3_ + f1), (double)((float)p_149749_4_ + f2), new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage())); + + if (itemstack.hasTagCompound()) + { + entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); + } + + float f3 = 0.05F; + entityitem.motionX = (double)((float)this.field_149942_b.nextGaussian() * f3); + entityitem.motionY = (double)((float)this.field_149942_b.nextGaussian() * f3 + 0.2F); + entityitem.motionZ = (double)((float)this.field_149942_b.nextGaussian() * f3); + p_149749_1_.spawnEntityInWorld(entityitem); + } + } + } + + p_149749_1_.func_147453_f(p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_); + } + + super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_); + } + + public static IPosition func_149939_a(IBlockSource p_149939_0_) + { + EnumFacing enumfacing = func_149937_b(p_149939_0_.getBlockMetadata()); + double d0 = p_149939_0_.getX() + 0.7D * (double)enumfacing.getFrontOffsetX(); + double d1 = p_149939_0_.getY() + 0.7D * (double)enumfacing.getFrontOffsetY(); + double d2 = p_149939_0_.getZ() + 0.7D * (double)enumfacing.getFrontOffsetZ(); + return new PositionImpl(d0, d1, d2); + } + + public static EnumFacing func_149937_b(int p_149937_0_) + { + return EnumFacing.getFront(p_149937_0_ & 7); + } + + public boolean hasComparatorInputOverride() + { + return true; + } + + public int getComparatorInputOverride(World p_149736_1_, int p_149736_2_, int p_149736_3_, int p_149736_4_, int p_149736_5_) + { + return Container.calcRedstoneFromInventory((IInventory)p_149736_1_.getTileEntity(p_149736_2_, p_149736_3_, p_149736_4_)); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockDoor.java b/src/main/java/net/minecraft/block/BlockDoor.java new file mode 100644 index 0000000..8689a70 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockDoor.java @@ -0,0 +1,413 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.IconFlipped; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.IIcon; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.Vec3; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockDoor extends Block +{ + @SideOnly(Side.CLIENT) + private IIcon[] field_150017_a; + @SideOnly(Side.CLIENT) + private IIcon[] field_150016_b; + private static final String __OBFID = "CL_00000230"; + + protected BlockDoor(Material p_i45402_1_) + { + super(p_i45402_1_); + float f = 0.5F; + float f1 = 1.0F; + this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f1, 0.5F + f); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return this.field_150016_b[0]; + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess p_149673_1_, int p_149673_2_, int p_149673_3_, int p_149673_4_, int p_149673_5_) + { + if (p_149673_5_ != 1 && p_149673_5_ != 0) + { + int i1 = this.func_150012_g(p_149673_1_, p_149673_2_, p_149673_3_, p_149673_4_); + int j1 = i1 & 3; + boolean flag = (i1 & 4) != 0; + boolean flag1 = false; + boolean flag2 = (i1 & 8) != 0; + + if (flag) + { + if (j1 == 0 && p_149673_5_ == 2) + { + flag1 = !flag1; + } + else if (j1 == 1 && p_149673_5_ == 5) + { + flag1 = !flag1; + } + else if (j1 == 2 && p_149673_5_ == 3) + { + flag1 = !flag1; + } + else if (j1 == 3 && p_149673_5_ == 4) + { + flag1 = !flag1; + } + } + else + { + if (j1 == 0 && p_149673_5_ == 5) + { + flag1 = !flag1; + } + else if (j1 == 1 && p_149673_5_ == 3) + { + flag1 = !flag1; + } + else if (j1 == 2 && p_149673_5_ == 4) + { + flag1 = !flag1; + } + else if (j1 == 3 && p_149673_5_ == 2) + { + flag1 = !flag1; + } + + if ((i1 & 16) != 0) + { + flag1 = !flag1; + } + } + + return flag2 ? this.field_150017_a[flag1?1:0] : this.field_150016_b[flag1?1:0]; + } + else + { + return this.field_150016_b[0]; + } + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.field_150017_a = new IIcon[2]; + this.field_150016_b = new IIcon[2]; + this.field_150017_a[0] = p_149651_1_.registerIcon(this.getTextureName() + "_upper"); + this.field_150016_b[0] = p_149651_1_.registerIcon(this.getTextureName() + "_lower"); + this.field_150017_a[1] = new IconFlipped(this.field_150017_a[0], true, false); + this.field_150016_b[1] = new IconFlipped(this.field_150016_b[0], true, false); + } + + public boolean isOpaqueCube() + { + return false; + } + + public boolean getBlocksMovement(IBlockAccess p_149655_1_, int p_149655_2_, int p_149655_3_, int p_149655_4_) + { + int l = this.func_150012_g(p_149655_1_, p_149655_2_, p_149655_3_, p_149655_4_); + return (l & 4) != 0; + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public int getRenderType() + { + return 7; + } + + @SideOnly(Side.CLIENT) + public AxisAlignedBB getSelectedBoundingBoxFromPool(World p_149633_1_, int p_149633_2_, int p_149633_3_, int p_149633_4_) + { + this.setBlockBoundsBasedOnState(p_149633_1_, p_149633_2_, p_149633_3_, p_149633_4_); + return super.getSelectedBoundingBoxFromPool(p_149633_1_, p_149633_2_, p_149633_3_, p_149633_4_); + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) + { + this.setBlockBoundsBasedOnState(p_149668_1_, p_149668_2_, p_149668_3_, p_149668_4_); + return super.getCollisionBoundingBoxFromPool(p_149668_1_, p_149668_2_, p_149668_3_, p_149668_4_); + } + + public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) + { + this.func_150011_b(this.func_150012_g(p_149719_1_, p_149719_2_, p_149719_3_, p_149719_4_)); + } + + public int func_150013_e(IBlockAccess p_150013_1_, int p_150013_2_, int p_150013_3_, int p_150013_4_) + { + return this.func_150012_g(p_150013_1_, p_150013_2_, p_150013_3_, p_150013_4_) & 3; + } + + public boolean func_150015_f(IBlockAccess p_150015_1_, int p_150015_2_, int p_150015_3_, int p_150015_4_) + { + return (this.func_150012_g(p_150015_1_, p_150015_2_, p_150015_3_, p_150015_4_) & 4) != 0; + } + + private void func_150011_b(int p_150011_1_) + { + float f = 0.1875F; + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 2.0F, 1.0F); + int j = p_150011_1_ & 3; + boolean flag = (p_150011_1_ & 4) != 0; + boolean flag1 = (p_150011_1_ & 16) != 0; + + if (j == 0) + { + if (flag) + { + if (!flag1) + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f); + } + else + { + this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F); + } + } + else + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F); + } + } + else if (j == 1) + { + if (flag) + { + if (!flag1) + { + this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + else + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F); + } + } + else + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f); + } + } + else if (j == 2) + { + if (flag) + { + if (!flag1) + { + this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F); + } + else + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f); + } + } + else + { + this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + } + else if (j == 3) + { + if (flag) + { + if (!flag1) + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F); + } + else + { + this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + } + else + { + this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F); + } + } + } + + public void onBlockClicked(World p_149699_1_, int p_149699_2_, int p_149699_3_, int p_149699_4_, EntityPlayer p_149699_5_) {} + + public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) + { + if (this.blockMaterial == Material.iron) + { + return false; //Allow items to interact with the door + } + else + { + int i1 = this.func_150012_g(p_149727_1_, p_149727_2_, p_149727_3_, p_149727_4_); + int j1 = i1 & 7; + j1 ^= 4; + + if ((i1 & 8) == 0) + { + p_149727_1_.setBlockMetadataWithNotify(p_149727_2_, p_149727_3_, p_149727_4_, j1, 2); + p_149727_1_.markBlockRangeForRenderUpdate(p_149727_2_, p_149727_3_, p_149727_4_, p_149727_2_, p_149727_3_, p_149727_4_); + } + else + { + p_149727_1_.setBlockMetadataWithNotify(p_149727_2_, p_149727_3_ - 1, p_149727_4_, j1, 2); + p_149727_1_.markBlockRangeForRenderUpdate(p_149727_2_, p_149727_3_ - 1, p_149727_4_, p_149727_2_, p_149727_3_, p_149727_4_); + } + + p_149727_1_.playAuxSFXAtEntity(p_149727_5_, 1003, p_149727_2_, p_149727_3_, p_149727_4_, 0); + return true; + } + } + + public void func_150014_a(World p_150014_1_, int p_150014_2_, int p_150014_3_, int p_150014_4_, boolean p_150014_5_) + { + int l = this.func_150012_g(p_150014_1_, p_150014_2_, p_150014_3_, p_150014_4_); + boolean flag1 = (l & 4) != 0; + + if (flag1 != p_150014_5_) + { + int i1 = l & 7; + i1 ^= 4; + + if ((l & 8) == 0) + { + p_150014_1_.setBlockMetadataWithNotify(p_150014_2_, p_150014_3_, p_150014_4_, i1, 2); + p_150014_1_.markBlockRangeForRenderUpdate(p_150014_2_, p_150014_3_, p_150014_4_, p_150014_2_, p_150014_3_, p_150014_4_); + } + else + { + p_150014_1_.setBlockMetadataWithNotify(p_150014_2_, p_150014_3_ - 1, p_150014_4_, i1, 2); + p_150014_1_.markBlockRangeForRenderUpdate(p_150014_2_, p_150014_3_ - 1, p_150014_4_, p_150014_2_, p_150014_3_, p_150014_4_); + } + + p_150014_1_.playAuxSFXAtEntity((EntityPlayer)null, 1003, p_150014_2_, p_150014_3_, p_150014_4_, 0); + } + } + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) + { + int l = p_149695_1_.getBlockMetadata(p_149695_2_, p_149695_3_, p_149695_4_); + + if ((l & 8) == 0) + { + boolean flag = false; + + if (p_149695_1_.getBlock(p_149695_2_, p_149695_3_ + 1, p_149695_4_) != this) + { + p_149695_1_.setBlockToAir(p_149695_2_, p_149695_3_, p_149695_4_); + flag = true; + } + + if (!World.doesBlockHaveSolidTopSurface(p_149695_1_, p_149695_2_, p_149695_3_ - 1, p_149695_4_)) + { + p_149695_1_.setBlockToAir(p_149695_2_, p_149695_3_, p_149695_4_); + flag = true; + + if (p_149695_1_.getBlock(p_149695_2_, p_149695_3_ + 1, p_149695_4_) == this) + { + p_149695_1_.setBlockToAir(p_149695_2_, p_149695_3_ + 1, p_149695_4_); + } + } + + if (flag) + { + if (!p_149695_1_.isRemote) + { + this.dropBlockAsItem(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, l, 0); + } + } + else + { + boolean flag1 = p_149695_1_.isBlockIndirectlyGettingPowered(p_149695_2_, p_149695_3_, p_149695_4_) || p_149695_1_.isBlockIndirectlyGettingPowered(p_149695_2_, p_149695_3_ + 1, p_149695_4_); + + if ((flag1 || p_149695_5_.canProvidePower()) && p_149695_5_ != this) + { + this.func_150014_a(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, flag1); + } + } + } + else + { + if (p_149695_1_.getBlock(p_149695_2_, p_149695_3_ - 1, p_149695_4_) != this) + { + p_149695_1_.setBlockToAir(p_149695_2_, p_149695_3_, p_149695_4_); + } + + if (p_149695_5_ != this) + { + this.onNeighborBlockChange(p_149695_1_, p_149695_2_, p_149695_3_ - 1, p_149695_4_, p_149695_5_); + } + } + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return (p_149650_1_ & 8) != 0 ? null : (this.blockMaterial == Material.iron ? Items.iron_door : Items.wooden_door); + } + + public MovingObjectPosition collisionRayTrace(World p_149731_1_, int p_149731_2_, int p_149731_3_, int p_149731_4_, Vec3 p_149731_5_, Vec3 p_149731_6_) + { + this.setBlockBoundsBasedOnState(p_149731_1_, p_149731_2_, p_149731_3_, p_149731_4_); + return super.collisionRayTrace(p_149731_1_, p_149731_2_, p_149731_3_, p_149731_4_, p_149731_5_, p_149731_6_); + } + + public boolean canPlaceBlockAt(World p_149742_1_, int p_149742_2_, int p_149742_3_, int p_149742_4_) + { + return p_149742_3_ >= p_149742_1_.getHeight() - 1 ? false : World.doesBlockHaveSolidTopSurface(p_149742_1_, p_149742_2_, p_149742_3_ - 1, p_149742_4_) && super.canPlaceBlockAt(p_149742_1_, p_149742_2_, p_149742_3_, p_149742_4_) && super.canPlaceBlockAt(p_149742_1_, p_149742_2_, p_149742_3_ + 1, p_149742_4_); + } + + public int getMobilityFlag() + { + return 1; + } + + public int func_150012_g(IBlockAccess p_150012_1_, int p_150012_2_, int p_150012_3_, int p_150012_4_) + { + int l = p_150012_1_.getBlockMetadata(p_150012_2_, p_150012_3_, p_150012_4_); + boolean flag = (l & 8) != 0; + int i1; + int j1; + + if (flag) + { + i1 = p_150012_1_.getBlockMetadata(p_150012_2_, p_150012_3_ - 1, p_150012_4_); + j1 = l; + } + else + { + i1 = l; + j1 = p_150012_1_.getBlockMetadata(p_150012_2_, p_150012_3_ + 1, p_150012_4_); + } + + boolean flag1 = (j1 & 1) != 0; + return i1 & 7 | (flag ? 8 : 0) | (flag1 ? 16 : 0); + } + + @SideOnly(Side.CLIENT) + public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) + { + return this.blockMaterial == Material.iron ? Items.iron_door : Items.wooden_door; + } + + public void onBlockHarvested(World p_149681_1_, int p_149681_2_, int p_149681_3_, int p_149681_4_, int p_149681_5_, EntityPlayer p_149681_6_) + { + if (p_149681_6_.capabilities.isCreativeMode && (p_149681_5_ & 8) != 0 && p_149681_1_.getBlock(p_149681_2_, p_149681_3_ - 1, p_149681_4_) == this) + { + p_149681_1_.setBlockToAir(p_149681_2_, p_149681_3_ - 1, p_149681_4_); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockDoublePlant.java b/src/main/java/net/minecraft/block/BlockDoublePlant.java new file mode 100644 index 0000000..27876b8 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockDoublePlant.java @@ -0,0 +1,266 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.stats.StatList; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockDoublePlant extends BlockBush implements IGrowable +{ + public static final String[] field_149892_a = new String[] {"sunflower", "syringa", "grass", "fern", "rose", "paeonia"}; + @SideOnly(Side.CLIENT) + private IIcon[] doublePlantBottomIcons; + @SideOnly(Side.CLIENT) + private IIcon[] doublePlantTopIcons; + @SideOnly(Side.CLIENT) + public IIcon[] sunflowerIcons; + private static final String __OBFID = "CL_00000231"; + + public BlockDoublePlant() + { + super(Material.plants); + this.setHardness(0.0F); + this.setStepSound(soundTypeGrass); + this.setBlockName("doublePlant"); + } + + public int getRenderType() + { + return 40; + } + + public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + + public int func_149885_e(IBlockAccess p_149885_1_, int p_149885_2_, int p_149885_3_, int p_149885_4_) + { + int l = p_149885_1_.getBlockMetadata(p_149885_2_, p_149885_3_, p_149885_4_); + return !func_149887_c(l) ? l & 7 : p_149885_1_.getBlockMetadata(p_149885_2_, p_149885_3_ - 1, p_149885_4_) & 7; + } + + public boolean canPlaceBlockAt(World p_149742_1_, int p_149742_2_, int p_149742_3_, int p_149742_4_) + { + return super.canPlaceBlockAt(p_149742_1_, p_149742_2_, p_149742_3_, p_149742_4_) && p_149742_1_.isAirBlock(p_149742_2_, p_149742_3_ + 1, p_149742_4_); + } + + protected void checkAndDropBlock(World p_149855_1_, int p_149855_2_, int p_149855_3_, int p_149855_4_) + { + if (!this.canBlockStay(p_149855_1_, p_149855_2_, p_149855_3_, p_149855_4_)) + { + int l = p_149855_1_.getBlockMetadata(p_149855_2_, p_149855_3_, p_149855_4_); + + if (!func_149887_c(l)) + { + this.dropBlockAsItem(p_149855_1_, p_149855_2_, p_149855_3_, p_149855_4_, l, 0); + + if (p_149855_1_.getBlock(p_149855_2_, p_149855_3_ + 1, p_149855_4_) == this) + { + p_149855_1_.setBlock(p_149855_2_, p_149855_3_ + 1, p_149855_4_, Blocks.air, 0, 2); + } + } + + p_149855_1_.setBlock(p_149855_2_, p_149855_3_, p_149855_4_, Blocks.air, 0, 2); + } + } + + public boolean canBlockStay(World p_149718_1_, int p_149718_2_, int p_149718_3_, int p_149718_4_) + { + if (p_149718_1_.getBlock(p_149718_2_, p_149718_3_, p_149718_4_) != this) return super.canBlockStay(p_149718_1_, p_149718_2_, p_149718_3_, p_149718_4_); //Forge: This function is called during world gen and placement, before this block is set, so if we are not 'here' then assume it's the pre-check. + int l = p_149718_1_.getBlockMetadata(p_149718_2_, p_149718_3_, p_149718_4_); + return func_149887_c(l) ? p_149718_1_.getBlock(p_149718_2_, p_149718_3_ - 1, p_149718_4_) == this : p_149718_1_.getBlock(p_149718_2_, p_149718_3_ + 1, p_149718_4_) == this && super.canBlockStay(p_149718_1_, p_149718_2_, p_149718_3_, p_149718_4_); + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + if (func_149887_c(p_149650_1_)) + { + return null; + } + else + { + int k = func_149890_d(p_149650_1_); + return k != 3 && k != 2 ? Item.getItemFromBlock(this) : null; + } + } + + public int damageDropped(int p_149692_1_) + { + return func_149887_c(p_149692_1_) ? 0 : p_149692_1_ & 7; + } + + public static boolean func_149887_c(int p_149887_0_) + { + return (p_149887_0_ & 8) != 0; + } + + public static int func_149890_d(int p_149890_0_) + { + return p_149890_0_ & 7; + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return func_149887_c(p_149691_2_) ? this.doublePlantBottomIcons[0] : this.doublePlantBottomIcons[p_149691_2_ & 7]; + } + + @SideOnly(Side.CLIENT) + public IIcon func_149888_a(boolean p_149888_1_, int p_149888_2_) + { + return p_149888_1_ ? this.doublePlantTopIcons[p_149888_2_] : this.doublePlantBottomIcons[p_149888_2_]; + } + + @SideOnly(Side.CLIENT) + public int colorMultiplier(IBlockAccess p_149720_1_, int p_149720_2_, int p_149720_3_, int p_149720_4_) + { + int l = this.func_149885_e(p_149720_1_, p_149720_2_, p_149720_3_, p_149720_4_); + return l != 2 && l != 3 ? 16777215 : p_149720_1_.getBiomeGenForCoords(p_149720_2_, p_149720_4_).getBiomeGrassColor(p_149720_2_, p_149720_3_, p_149720_4_); + } + + public void func_149889_c(World p_149889_1_, int p_149889_2_, int p_149889_3_, int p_149889_4_, int p_149889_5_, int p_149889_6_) + { + p_149889_1_.setBlock(p_149889_2_, p_149889_3_, p_149889_4_, this, p_149889_5_, p_149889_6_); + p_149889_1_.setBlock(p_149889_2_, p_149889_3_ + 1, p_149889_4_, this, 8, p_149889_6_); + } + + public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_) + { + int l = ((MathHelper.floor_double((double)(p_149689_5_.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3) + 2) % 4; + p_149689_1_.setBlock(p_149689_2_, p_149689_3_ + 1, p_149689_4_, this, 8 | l, 2); + } + + public void harvestBlock(World p_149636_1_, EntityPlayer p_149636_2_, int p_149636_3_, int p_149636_4_, int p_149636_5_, int p_149636_6_) + { + if (p_149636_1_.isRemote || p_149636_2_.getCurrentEquippedItem() == null || p_149636_2_.getCurrentEquippedItem().getItem() != Items.shears || func_149887_c(p_149636_6_) || !this.func_149886_b(p_149636_1_, p_149636_3_, p_149636_4_, p_149636_5_, p_149636_6_, p_149636_2_)) + { + super.harvestBlock(p_149636_1_, p_149636_2_, p_149636_3_, p_149636_4_, p_149636_5_, p_149636_6_); + } + } + + public void onBlockHarvested(World p_149681_1_, int p_149681_2_, int p_149681_3_, int p_149681_4_, int p_149681_5_, EntityPlayer p_149681_6_) + { + if (func_149887_c(p_149681_5_)) + { + if (p_149681_1_.getBlock(p_149681_2_, p_149681_3_ - 1, p_149681_4_) == this) + { + if (!p_149681_6_.capabilities.isCreativeMode) + { + int i1 = p_149681_1_.getBlockMetadata(p_149681_2_, p_149681_3_ - 1, p_149681_4_); + int j1 = func_149890_d(i1); + + if (j1 != 3 && j1 != 2) + { + p_149681_1_.func_147480_a(p_149681_2_, p_149681_3_ - 1, p_149681_4_, true); + } + else + { + if (!p_149681_1_.isRemote && p_149681_6_.getCurrentEquippedItem() != null && p_149681_6_.getCurrentEquippedItem().getItem() == Items.shears) + { + this.func_149886_b(p_149681_1_, p_149681_2_, p_149681_3_, p_149681_4_, i1, p_149681_6_); + } + + p_149681_1_.setBlockToAir(p_149681_2_, p_149681_3_ - 1, p_149681_4_); + } + } + else + { + p_149681_1_.setBlockToAir(p_149681_2_, p_149681_3_ - 1, p_149681_4_); + } + } + } + else if (p_149681_6_.capabilities.isCreativeMode && p_149681_1_.getBlock(p_149681_2_, p_149681_3_ + 1, p_149681_4_) == this) + { + p_149681_1_.setBlock(p_149681_2_, p_149681_3_ + 1, p_149681_4_, Blocks.air, 0, 2); + } + + super.onBlockHarvested(p_149681_1_, p_149681_2_, p_149681_3_, p_149681_4_, p_149681_5_, p_149681_6_); + } + + private boolean func_149886_b(World p_149886_1_, int p_149886_2_, int p_149886_3_, int p_149886_4_, int p_149886_5_, EntityPlayer p_149886_6_) + { + int i1 = func_149890_d(p_149886_5_); + + if (i1 != 3 && i1 != 2) + { + return false; + } + else + { + p_149886_6_.addStat(StatList.mineBlockStatArray[Block.getIdFromBlock(this)], 1); + byte b0 = 1; + + if (i1 == 3) + { + b0 = 2; + } + + this.dropBlockAsItem(p_149886_1_, p_149886_2_, p_149886_3_, p_149886_4_, new ItemStack(Blocks.tallgrass, 2, b0)); + return true; + } + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.doublePlantBottomIcons = new IIcon[field_149892_a.length]; + this.doublePlantTopIcons = new IIcon[field_149892_a.length]; + + for (int i = 0; i < this.doublePlantBottomIcons.length; ++i) + { + this.doublePlantBottomIcons[i] = p_149651_1_.registerIcon("double_plant_" + field_149892_a[i] + "_bottom"); + this.doublePlantTopIcons[i] = p_149651_1_.registerIcon("double_plant_" + field_149892_a[i] + "_top"); + } + + this.sunflowerIcons = new IIcon[2]; + this.sunflowerIcons[0] = p_149651_1_.registerIcon("double_plant_sunflower_front"); + this.sunflowerIcons[1] = p_149651_1_.registerIcon("double_plant_sunflower_back"); + } + + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_) + { + for (int i = 0; i < this.doublePlantBottomIcons.length; ++i) + { + p_149666_3_.add(new ItemStack(p_149666_1_, 1, i)); + } + } + + public int getDamageValue(World p_149643_1_, int p_149643_2_, int p_149643_3_, int p_149643_4_) + { + int l = p_149643_1_.getBlockMetadata(p_149643_2_, p_149643_3_, p_149643_4_); + return func_149887_c(l) ? func_149890_d(p_149643_1_.getBlockMetadata(p_149643_2_, p_149643_3_ - 1, p_149643_4_)) : func_149890_d(l); + } + + public boolean func_149851_a(World p_149851_1_, int p_149851_2_, int p_149851_3_, int p_149851_4_, boolean p_149851_5_) + { + int l = this.func_149885_e(p_149851_1_, p_149851_2_, p_149851_3_, p_149851_4_); + return l != 2 && l != 3; + } + + public boolean func_149852_a(World p_149852_1_, Random p_149852_2_, int p_149852_3_, int p_149852_4_, int p_149852_5_) + { + return true; + } + + public void func_149853_b(World p_149853_1_, Random p_149853_2_, int p_149853_3_, int p_149853_4_, int p_149853_5_) + { + int l = this.func_149885_e(p_149853_1_, p_149853_3_, p_149853_4_, p_149853_5_); + this.dropBlockAsItem(p_149853_1_, p_149853_3_, p_149853_4_, p_149853_5_, new ItemStack(this, 1, l)); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockDragonEgg.java b/src/main/java/net/minecraft/block/BlockDragonEgg.java new file mode 100644 index 0000000..cb9a8e5 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockDragonEgg.java @@ -0,0 +1,148 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.entity.item.EntityFallingBlock; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockDragonEgg extends Block +{ + private static final String __OBFID = "CL_00000232"; + + public BlockDragonEgg() + { + super(Material.dragonEgg); + this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 1.0F, 0.9375F); + } + + public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_) + { + p_149726_1_.scheduleBlockUpdate(p_149726_2_, p_149726_3_, p_149726_4_, this, this.tickRate(p_149726_1_)); + } + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) + { + p_149695_1_.scheduleBlockUpdate(p_149695_2_, p_149695_3_, p_149695_4_, this, this.tickRate(p_149695_1_)); + } + + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) + { + this.func_150018_e(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_); + } + + private void func_150018_e(World p_150018_1_, int p_150018_2_, int p_150018_3_, int p_150018_4_) + { + if (BlockFalling.func_149831_e(p_150018_1_, p_150018_2_, p_150018_3_ - 1, p_150018_4_) && p_150018_3_ >= 0) + { + byte b0 = 32; + + if (!BlockFalling.fallInstantly && p_150018_1_.checkChunksExist(p_150018_2_ - b0, p_150018_3_ - b0, p_150018_4_ - b0, p_150018_2_ + b0, p_150018_3_ + b0, p_150018_4_ + b0)) + { + EntityFallingBlock entityfallingblock = new EntityFallingBlock(p_150018_1_, (double)((float)p_150018_2_ + 0.5F), (double)((float)p_150018_3_ + 0.5F), (double)((float)p_150018_4_ + 0.5F), this); + p_150018_1_.spawnEntityInWorld(entityfallingblock); + } + else + { + p_150018_1_.setBlockToAir(p_150018_2_, p_150018_3_, p_150018_4_); + + while (BlockFalling.func_149831_e(p_150018_1_, p_150018_2_, p_150018_3_ - 1, p_150018_4_) && p_150018_3_ > 0) + { + --p_150018_3_; + } + + if (p_150018_3_ > 0) + { + p_150018_1_.setBlock(p_150018_2_, p_150018_3_, p_150018_4_, this, 0, 2); + } + } + } + } + + public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) + { + this.func_150019_m(p_149727_1_, p_149727_2_, p_149727_3_, p_149727_4_); + return true; + } + + public void onBlockClicked(World p_149699_1_, int p_149699_2_, int p_149699_3_, int p_149699_4_, EntityPlayer p_149699_5_) + { + this.func_150019_m(p_149699_1_, p_149699_2_, p_149699_3_, p_149699_4_); + } + + private void func_150019_m(World p_150019_1_, int p_150019_2_, int p_150019_3_, int p_150019_4_) + { + if (p_150019_1_.getBlock(p_150019_2_, p_150019_3_, p_150019_4_) == this) + { + for (int l = 0; l < 1000; ++l) + { + int i1 = p_150019_2_ + p_150019_1_.rand.nextInt(16) - p_150019_1_.rand.nextInt(16); + int j1 = p_150019_3_ + p_150019_1_.rand.nextInt(8) - p_150019_1_.rand.nextInt(8); + int k1 = p_150019_4_ + p_150019_1_.rand.nextInt(16) - p_150019_1_.rand.nextInt(16); + + if (p_150019_1_.getBlock(i1, j1, k1).blockMaterial == Material.air) + { + if (!p_150019_1_.isRemote) + { + p_150019_1_.setBlock(i1, j1, k1, this, p_150019_1_.getBlockMetadata(p_150019_2_, p_150019_3_, p_150019_4_), 2); + p_150019_1_.setBlockToAir(p_150019_2_, p_150019_3_, p_150019_4_); + } + else + { + short short1 = 128; + + for (int l1 = 0; l1 < short1; ++l1) + { + double d0 = p_150019_1_.rand.nextDouble(); + float f = (p_150019_1_.rand.nextFloat() - 0.5F) * 0.2F; + float f1 = (p_150019_1_.rand.nextFloat() - 0.5F) * 0.2F; + float f2 = (p_150019_1_.rand.nextFloat() - 0.5F) * 0.2F; + double d1 = (double)i1 + (double)(p_150019_2_ - i1) * d0 + (p_150019_1_.rand.nextDouble() - 0.5D) * 1.0D + 0.5D; + double d2 = (double)j1 + (double)(p_150019_3_ - j1) * d0 + p_150019_1_.rand.nextDouble() * 1.0D - 0.5D; + double d3 = (double)k1 + (double)(p_150019_4_ - k1) * d0 + (p_150019_1_.rand.nextDouble() - 0.5D) * 1.0D + 0.5D; + p_150019_1_.spawnParticle("portal", d1, d2, d3, (double)f, (double)f1, (double)f2); + } + } + + return; + } + } + } + } + + public int tickRate(World p_149738_1_) + { + return 5; + } + + public boolean isOpaqueCube() + { + return false; + } + + public boolean renderAsNormalBlock() + { + return false; + } + + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) + { + return true; + } + + public int getRenderType() + { + return 27; + } + + @SideOnly(Side.CLIENT) + public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) + { + return Item.getItemById(0); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockDropper.java b/src/main/java/net/minecraft/block/BlockDropper.java new file mode 100644 index 0000000..76919dd --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockDropper.java @@ -0,0 +1,93 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.dispenser.BehaviorDefaultDispenseItem; +import net.minecraft.dispenser.IBehaviorDispenseItem; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityDispenser; +import net.minecraft.tileentity.TileEntityDropper; +import net.minecraft.tileentity.TileEntityHopper; +import net.minecraft.util.Facing; +import net.minecraft.world.World; + +public class BlockDropper extends BlockDispenser +{ + private final IBehaviorDispenseItem field_149947_P = new BehaviorDefaultDispenseItem(); + private static final String __OBFID = "CL_00000233"; + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.blockIcon = p_149651_1_.registerIcon("furnace_side"); + this.field_149944_M = p_149651_1_.registerIcon("furnace_top"); + this.field_149945_N = p_149651_1_.registerIcon(this.getTextureName() + "_front_horizontal"); + this.field_149946_O = p_149651_1_.registerIcon(this.getTextureName() + "_front_vertical"); + } + + protected IBehaviorDispenseItem func_149940_a(ItemStack p_149940_1_) + { + return this.field_149947_P; + } + + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) + { + return new TileEntityDropper(); + } + + protected void func_149941_e(World p_149941_1_, int p_149941_2_, int p_149941_3_, int p_149941_4_) + { + BlockSourceImpl blocksourceimpl = new BlockSourceImpl(p_149941_1_, p_149941_2_, p_149941_3_, p_149941_4_); + TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity(); + + if (tileentitydispenser != null) + { + int l = tileentitydispenser.func_146017_i(); + + if (l < 0) + { + p_149941_1_.playAuxSFX(1001, p_149941_2_, p_149941_3_, p_149941_4_, 0); + } + else + { + ItemStack itemstack = tileentitydispenser.getStackInSlot(l); + int i1 = p_149941_1_.getBlockMetadata(p_149941_2_, p_149941_3_, p_149941_4_) & 7; + IInventory iinventory = TileEntityHopper.func_145893_b(p_149941_1_, (double)(p_149941_2_ + Facing.offsetsXForSide[i1]), (double)(p_149941_3_ + Facing.offsetsYForSide[i1]), (double)(p_149941_4_ + Facing.offsetsZForSide[i1])); + ItemStack itemstack1; + + if (iinventory != null) + { + itemstack1 = TileEntityHopper.func_145889_a(iinventory, itemstack.copy().splitStack(1), Facing.oppositeSide[i1]); + + if (itemstack1 == null) + { + itemstack1 = itemstack.copy(); + + if (--itemstack1.stackSize == 0) + { + itemstack1 = null; + } + } + else + { + itemstack1 = itemstack.copy(); + } + } + else + { + itemstack1 = this.field_149947_P.dispense(blocksourceimpl, itemstack); + + if (itemstack1 != null && itemstack1.stackSize == 0) + { + itemstack1 = null; + } + } + + tileentitydispenser.setInventorySlotContents(l, itemstack1); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockDynamicLiquid.java b/src/main/java/net/minecraft/block/BlockDynamicLiquid.java new file mode 100644 index 0000000..7f796e0 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockDynamicLiquid.java @@ -0,0 +1,354 @@ +package net.minecraft.block; + +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; + +public class BlockDynamicLiquid extends BlockLiquid +{ + int field_149815_a; + boolean[] field_149814_b = new boolean[4]; + int[] field_149816_M = new int[4]; + private static final String __OBFID = "CL_00000234"; + + protected BlockDynamicLiquid(Material p_i45403_1_) + { + super(p_i45403_1_); + } + + private void func_149811_n(World p_149811_1_, int p_149811_2_, int p_149811_3_, int p_149811_4_) + { + int l = p_149811_1_.getBlockMetadata(p_149811_2_, p_149811_3_, p_149811_4_); + p_149811_1_.setBlock(p_149811_2_, p_149811_3_, p_149811_4_, Block.getBlockById(Block.getIdFromBlock(this) + 1), l, 2); + } + + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) + { + int l = this.func_149804_e(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_); + byte b0 = 1; + + if (this.blockMaterial == Material.lava && !p_149674_1_.provider.isHellWorld) + { + b0 = 2; + } + + boolean flag = true; + int i1 = this.tickRate(p_149674_1_); + int j1; + + if (l > 0) + { + byte b1 = -100; + this.field_149815_a = 0; + int l1 = this.func_149810_a(p_149674_1_, p_149674_2_ - 1, p_149674_3_, p_149674_4_, b1); + l1 = this.func_149810_a(p_149674_1_, p_149674_2_ + 1, p_149674_3_, p_149674_4_, l1); + l1 = this.func_149810_a(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_ - 1, l1); + l1 = this.func_149810_a(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_ + 1, l1); + j1 = l1 + b0; + + if (j1 >= 8 || l1 < 0) + { + j1 = -1; + } + + if (this.func_149804_e(p_149674_1_, p_149674_2_, p_149674_3_ + 1, p_149674_4_) >= 0) + { + int k1 = this.func_149804_e(p_149674_1_, p_149674_2_, p_149674_3_ + 1, p_149674_4_); + + if (k1 >= 8) + { + j1 = k1; + } + else + { + j1 = k1 + 8; + } + } + + if (this.field_149815_a >= 2 && this.blockMaterial == Material.water) + { + if (p_149674_1_.getBlock(p_149674_2_, p_149674_3_ - 1, p_149674_4_).getMaterial().isSolid()) + { + j1 = 0; + } + else if (p_149674_1_.getBlock(p_149674_2_, p_149674_3_ - 1, p_149674_4_).getMaterial() == this.blockMaterial && p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_ - 1, p_149674_4_) == 0) + { + j1 = 0; + } + } + + if (this.blockMaterial == Material.lava && l < 8 && j1 < 8 && j1 > l && p_149674_5_.nextInt(4) != 0) + { + i1 *= 4; + } + + if (j1 == l) + { + if (flag) + { + this.func_149811_n(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_); + } + } + else + { + l = j1; + + if (j1 < 0) + { + p_149674_1_.setBlockToAir(p_149674_2_, p_149674_3_, p_149674_4_); + } + else + { + p_149674_1_.setBlockMetadataWithNotify(p_149674_2_, p_149674_3_, p_149674_4_, j1, 2); + p_149674_1_.scheduleBlockUpdate(p_149674_2_, p_149674_3_, p_149674_4_, this, i1); + p_149674_1_.notifyBlocksOfNeighborChange(p_149674_2_, p_149674_3_, p_149674_4_, this); + } + } + } + else + { + this.func_149811_n(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_); + } + + if (this.func_149809_q(p_149674_1_, p_149674_2_, p_149674_3_ - 1, p_149674_4_)) + { + if (this.blockMaterial == Material.lava && p_149674_1_.getBlock(p_149674_2_, p_149674_3_ - 1, p_149674_4_).getMaterial() == Material.water) + { + p_149674_1_.setBlock(p_149674_2_, p_149674_3_ - 1, p_149674_4_, Blocks.stone); + this.func_149799_m(p_149674_1_, p_149674_2_, p_149674_3_ - 1, p_149674_4_); + return; + } + + if (l >= 8) + { + this.func_149813_h(p_149674_1_, p_149674_2_, p_149674_3_ - 1, p_149674_4_, l); + } + else + { + this.func_149813_h(p_149674_1_, p_149674_2_, p_149674_3_ - 1, p_149674_4_, l + 8); + } + } + else if (l >= 0 && (l == 0 || this.func_149807_p(p_149674_1_, p_149674_2_, p_149674_3_ - 1, p_149674_4_))) + { + boolean[] aboolean = this.func_149808_o(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_); + j1 = l + b0; + + if (l >= 8) + { + j1 = 1; + } + + if (j1 >= 8) + { + return; + } + + if (aboolean[0]) + { + this.func_149813_h(p_149674_1_, p_149674_2_ - 1, p_149674_3_, p_149674_4_, j1); + } + + if (aboolean[1]) + { + this.func_149813_h(p_149674_1_, p_149674_2_ + 1, p_149674_3_, p_149674_4_, j1); + } + + if (aboolean[2]) + { + this.func_149813_h(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_ - 1, j1); + } + + if (aboolean[3]) + { + this.func_149813_h(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_ + 1, j1); + } + } + } + + private void func_149813_h(World p_149813_1_, int p_149813_2_, int p_149813_3_, int p_149813_4_, int p_149813_5_) + { + if (this.func_149809_q(p_149813_1_, p_149813_2_, p_149813_3_, p_149813_4_)) + { + Block block = p_149813_1_.getBlock(p_149813_2_, p_149813_3_, p_149813_4_); + + if (this.blockMaterial == Material.lava) + { + this.func_149799_m(p_149813_1_, p_149813_2_, p_149813_3_, p_149813_4_); + } + else + { + block.dropBlockAsItem(p_149813_1_, p_149813_2_, p_149813_3_, p_149813_4_, p_149813_1_.getBlockMetadata(p_149813_2_, p_149813_3_, p_149813_4_), 0); + } + + p_149813_1_.setBlock(p_149813_2_, p_149813_3_, p_149813_4_, this, p_149813_5_, 3); + } + } + + private int func_149812_c(World p_149812_1_, int p_149812_2_, int p_149812_3_, int p_149812_4_, int p_149812_5_, int p_149812_6_) + { + int j1 = 1000; + + for (int k1 = 0; k1 < 4; ++k1) + { + if ((k1 != 0 || p_149812_6_ != 1) && (k1 != 1 || p_149812_6_ != 0) && (k1 != 2 || p_149812_6_ != 3) && (k1 != 3 || p_149812_6_ != 2)) + { + int l1 = p_149812_2_; + int i2 = p_149812_4_; + + if (k1 == 0) + { + l1 = p_149812_2_ - 1; + } + + if (k1 == 1) + { + ++l1; + } + + if (k1 == 2) + { + i2 = p_149812_4_ - 1; + } + + if (k1 == 3) + { + ++i2; + } + + if (!this.func_149807_p(p_149812_1_, l1, p_149812_3_, i2) && (p_149812_1_.getBlock(l1, p_149812_3_, i2).getMaterial() != this.blockMaterial || p_149812_1_.getBlockMetadata(l1, p_149812_3_, i2) != 0)) + { + if (!this.func_149807_p(p_149812_1_, l1, p_149812_3_ - 1, i2)) + { + return p_149812_5_; + } + + if (p_149812_5_ < 4) + { + int j2 = this.func_149812_c(p_149812_1_, l1, p_149812_3_, i2, p_149812_5_ + 1, k1); + + if (j2 < j1) + { + j1 = j2; + } + } + } + } + } + + return j1; + } + + private boolean[] func_149808_o(World p_149808_1_, int p_149808_2_, int p_149808_3_, int p_149808_4_) + { + int l; + int i1; + + for (l = 0; l < 4; ++l) + { + this.field_149816_M[l] = 1000; + i1 = p_149808_2_; + int j1 = p_149808_4_; + + if (l == 0) + { + i1 = p_149808_2_ - 1; + } + + if (l == 1) + { + ++i1; + } + + if (l == 2) + { + j1 = p_149808_4_ - 1; + } + + if (l == 3) + { + ++j1; + } + + if (!this.func_149807_p(p_149808_1_, i1, p_149808_3_, j1) && (p_149808_1_.getBlock(i1, p_149808_3_, j1).getMaterial() != this.blockMaterial || p_149808_1_.getBlockMetadata(i1, p_149808_3_, j1) != 0)) + { + if (this.func_149807_p(p_149808_1_, i1, p_149808_3_ - 1, j1)) + { + this.field_149816_M[l] = this.func_149812_c(p_149808_1_, i1, p_149808_3_, j1, 1, l); + } + else + { + this.field_149816_M[l] = 0; + } + } + } + + l = this.field_149816_M[0]; + + for (i1 = 1; i1 < 4; ++i1) + { + if (this.field_149816_M[i1] < l) + { + l = this.field_149816_M[i1]; + } + } + + for (i1 = 0; i1 < 4; ++i1) + { + this.field_149814_b[i1] = this.field_149816_M[i1] == l; + } + + return this.field_149814_b; + } + + private boolean func_149807_p(World p_149807_1_, int p_149807_2_, int p_149807_3_, int p_149807_4_) + { + Block block = p_149807_1_.getBlock(p_149807_2_, p_149807_3_, p_149807_4_); + return block != Blocks.wooden_door && block != Blocks.iron_door && block != Blocks.standing_sign && block != Blocks.ladder && block != Blocks.reeds ? (block.blockMaterial == Material.portal ? true : block.blockMaterial.blocksMovement()) : true; + } + + protected int func_149810_a(World p_149810_1_, int p_149810_2_, int p_149810_3_, int p_149810_4_, int p_149810_5_) + { + int i1 = this.func_149804_e(p_149810_1_, p_149810_2_, p_149810_3_, p_149810_4_); + + if (i1 < 0) + { + return p_149810_5_; + } + else + { + if (i1 == 0) + { + ++this.field_149815_a; + } + + if (i1 >= 8) + { + i1 = 0; + } + + return p_149810_5_ >= 0 && i1 >= p_149810_5_ ? p_149810_5_ : i1; + } + } + + private boolean func_149809_q(World p_149809_1_, int p_149809_2_, int p_149809_3_, int p_149809_4_) + { + Material material = p_149809_1_.getBlock(p_149809_2_, p_149809_3_, p_149809_4_).getMaterial(); + return material == this.blockMaterial ? false : (material == Material.lava ? false : !this.func_149807_p(p_149809_1_, p_149809_2_, p_149809_3_, p_149809_4_)); + } + + public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_) + { + super.onBlockAdded(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_); + + if (p_149726_1_.getBlock(p_149726_2_, p_149726_3_, p_149726_4_) == this) + { + p_149726_1_.scheduleBlockUpdate(p_149726_2_, p_149726_3_, p_149726_4_, this, this.tickRate(p_149726_1_)); + } + } + + public boolean func_149698_L() + { + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockEnchantmentTable.java b/src/main/java/net/minecraft/block/BlockEnchantmentTable.java new file mode 100644 index 0000000..f12c68e --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockEnchantmentTable.java @@ -0,0 +1,119 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityEnchantmentTable; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +public class BlockEnchantmentTable extends BlockContainer +{ + @SideOnly(Side.CLIENT) + private IIcon field_149950_a; + @SideOnly(Side.CLIENT) + private IIcon field_149949_b; + private static final String __OBFID = "CL_00000235"; + + protected BlockEnchantmentTable() + { + super(Material.rock); + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.75F, 1.0F); + this.setLightOpacity(0); + this.setCreativeTab(CreativeTabs.tabDecorations); + } + + public boolean renderAsNormalBlock() + { + return false; + } + + @SideOnly(Side.CLIENT) + public void randomDisplayTick(World p_149734_1_, int p_149734_2_, int p_149734_3_, int p_149734_4_, Random p_149734_5_) + { + super.randomDisplayTick(p_149734_1_, p_149734_2_, p_149734_3_, p_149734_4_, p_149734_5_); + + for (int l = p_149734_2_ - 2; l <= p_149734_2_ + 2; ++l) + { + for (int i1 = p_149734_4_ - 2; i1 <= p_149734_4_ + 2; ++i1) + { + if (l > p_149734_2_ - 2 && l < p_149734_2_ + 2 && i1 == p_149734_4_ - 1) + { + i1 = p_149734_4_ + 2; + } + + if (p_149734_5_.nextInt(16) == 0) + { + for (int j1 = p_149734_3_; j1 <= p_149734_3_ + 1; ++j1) + { + if (p_149734_1_.getBlock(l, j1, i1) == Blocks.bookshelf) + { + if (!p_149734_1_.isAirBlock((l - p_149734_2_) / 2 + p_149734_2_, j1, (i1 - p_149734_4_) / 2 + p_149734_4_)) + { + break; + } + + p_149734_1_.spawnParticle("enchantmenttable", (double)p_149734_2_ + 0.5D, (double)p_149734_3_ + 2.0D, (double)p_149734_4_ + 0.5D, (double)((float)(l - p_149734_2_) + p_149734_5_.nextFloat()) - 0.5D, (double)((float)(j1 - p_149734_3_) - p_149734_5_.nextFloat() - 1.0F), (double)((float)(i1 - p_149734_4_) + p_149734_5_.nextFloat()) - 0.5D); + } + } + } + } + } + } + + public boolean isOpaqueCube() + { + return false; + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return p_149691_1_ == 0 ? this.field_149949_b : (p_149691_1_ == 1 ? this.field_149950_a : this.blockIcon); + } + + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) + { + return new TileEntityEnchantmentTable(); + } + + public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) + { + if (p_149727_1_.isRemote) + { + return true; + } + else + { + TileEntityEnchantmentTable tileentityenchantmenttable = (TileEntityEnchantmentTable)p_149727_1_.getTileEntity(p_149727_2_, p_149727_3_, p_149727_4_); + p_149727_5_.displayGUIEnchantment(p_149727_2_, p_149727_3_, p_149727_4_, tileentityenchantmenttable.func_145921_b() ? tileentityenchantmenttable.func_145919_a() : null); + return true; + } + } + + public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_) + { + super.onBlockPlacedBy(p_149689_1_, p_149689_2_, p_149689_3_, p_149689_4_, p_149689_5_, p_149689_6_); + + if (p_149689_6_.hasDisplayName()) + { + ((TileEntityEnchantmentTable)p_149689_1_.getTileEntity(p_149689_2_, p_149689_3_, p_149689_4_)).func_145920_a(p_149689_6_.getDisplayName()); + } + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.blockIcon = p_149651_1_.registerIcon(this.getTextureName() + "_" + "side"); + this.field_149950_a = p_149651_1_.registerIcon(this.getTextureName() + "_" + "top"); + this.field_149949_b = p_149651_1_.registerIcon(this.getTextureName() + "_" + "bottom"); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockEndPortal.java b/src/main/java/net/minecraft/block/BlockEndPortal.java new file mode 100644 index 0000000..01efbc2 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockEndPortal.java @@ -0,0 +1,115 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import java.util.Random; +import net.minecraft.block.material.MapColor; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.item.Item; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityEndPortal; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockEndPortal extends BlockContainer +{ + public static boolean field_149948_a; + private static final String __OBFID = "CL_00000236"; + + protected BlockEndPortal(Material p_i45404_1_) + { + super(p_i45404_1_); + this.setLightLevel(1.0F); + } + + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) + { + return new TileEntityEndPortal(); + } + + public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) + { + float f = 0.0625F; + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, f, 1.0F); + } + + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) + { + return p_149646_5_ != 0 ? false : super.shouldSideBeRendered(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, p_149646_5_); + } + + public void addCollisionBoxesToList(World p_149743_1_, int p_149743_2_, int p_149743_3_, int p_149743_4_, AxisAlignedBB p_149743_5_, List p_149743_6_, Entity p_149743_7_) {} + + public boolean isOpaqueCube() + { + return false; + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public int quantityDropped(Random p_149745_1_) + { + return 0; + } + + public void onEntityCollidedWithBlock(World p_149670_1_, int p_149670_2_, int p_149670_3_, int p_149670_4_, Entity p_149670_5_) + { + if (p_149670_5_.ridingEntity == null && p_149670_5_.riddenByEntity == null && !p_149670_1_.isRemote) + { + p_149670_5_.travelToDimension(1); + } + } + + @SideOnly(Side.CLIENT) + public void randomDisplayTick(World p_149734_1_, int p_149734_2_, int p_149734_3_, int p_149734_4_, Random p_149734_5_) + { + double d0 = (double)((float)p_149734_2_ + p_149734_5_.nextFloat()); + double d1 = (double)((float)p_149734_3_ + 0.8F); + double d2 = (double)((float)p_149734_4_ + p_149734_5_.nextFloat()); + double d3 = 0.0D; + double d4 = 0.0D; + double d5 = 0.0D; + p_149734_1_.spawnParticle("smoke", d0, d1, d2, d3, d4, d5); + } + + public int getRenderType() + { + return -1; + } + + public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_) + { + if (!field_149948_a) + { + if (p_149726_1_.provider.dimensionId != 0) + { + p_149726_1_.setBlockToAir(p_149726_2_, p_149726_3_, p_149726_4_); + } + } + } + + @SideOnly(Side.CLIENT) + public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) + { + return Item.getItemById(0); + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.blockIcon = p_149651_1_.registerIcon("portal"); + } + + public MapColor getMapColor(int p_149728_1_) + { + return MapColor.obsidianColor; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockEndPortalFrame.java b/src/main/java/net/minecraft/block/BlockEndPortalFrame.java new file mode 100644 index 0000000..34dba6f --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockEndPortalFrame.java @@ -0,0 +1,108 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class BlockEndPortalFrame extends Block +{ + @SideOnly(Side.CLIENT) + private IIcon iconEndPortalFrameTop; + @SideOnly(Side.CLIENT) + private IIcon iconEndPortalFrameEye; + private static final String __OBFID = "CL_00000237"; + + public BlockEndPortalFrame() + { + super(Material.rock); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return p_149691_1_ == 1 ? this.iconEndPortalFrameTop : (p_149691_1_ == 0 ? Blocks.end_stone.getBlockTextureFromSide(p_149691_1_) : this.blockIcon); + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.blockIcon = p_149651_1_.registerIcon(this.getTextureName() + "_side"); + this.iconEndPortalFrameTop = p_149651_1_.registerIcon(this.getTextureName() + "_top"); + this.iconEndPortalFrameEye = p_149651_1_.registerIcon(this.getTextureName() + "_eye"); + } + + @SideOnly(Side.CLIENT) + public IIcon getIconEndPortalFrameEye() + { + return this.iconEndPortalFrameEye; + } + + public boolean isOpaqueCube() + { + return false; + } + + public int getRenderType() + { + return 26; + } + + public void setBlockBoundsForItemRender() + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.8125F, 1.0F); + } + + public void addCollisionBoxesToList(World p_149743_1_, int p_149743_2_, int p_149743_3_, int p_149743_4_, AxisAlignedBB p_149743_5_, List p_149743_6_, Entity p_149743_7_) + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.8125F, 1.0F); + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + int l = p_149743_1_.getBlockMetadata(p_149743_2_, p_149743_3_, p_149743_4_); + + if (isEnderEyeInserted(l)) + { + this.setBlockBounds(0.3125F, 0.8125F, 0.3125F, 0.6875F, 1.0F, 0.6875F); + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + } + + this.setBlockBoundsForItemRender(); + } + + public static boolean isEnderEyeInserted(int p_150020_0_) + { + return (p_150020_0_ & 4) != 0; + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return null; + } + + public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_) + { + int l = ((MathHelper.floor_double((double)(p_149689_5_.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3) + 2) % 4; + p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, l, 2); + } + + public boolean hasComparatorInputOverride() + { + return true; + } + + public int getComparatorInputOverride(World p_149736_1_, int p_149736_2_, int p_149736_3_, int p_149736_4_, int p_149736_5_) + { + int i1 = p_149736_1_.getBlockMetadata(p_149736_2_, p_149736_3_, p_149736_4_); + return isEnderEyeInserted(i1) ? 15 : 0; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockEnderChest.java b/src/main/java/net/minecraft/block/BlockEnderChest.java new file mode 100644 index 0000000..c42d8b1 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockEnderChest.java @@ -0,0 +1,151 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.inventory.InventoryEnderChest; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityEnderChest; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class BlockEnderChest extends BlockContainer +{ + private static final String __OBFID = "CL_00000238"; + + protected BlockEnderChest() + { + super(Material.rock); + this.setCreativeTab(CreativeTabs.tabDecorations); + this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F); + } + + public boolean isOpaqueCube() + { + return false; + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public int getRenderType() + { + return 22; + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return Item.getItemFromBlock(Blocks.obsidian); + } + + public int quantityDropped(Random p_149745_1_) + { + return 8; + } + + protected boolean canSilkHarvest() + { + return true; + } + + public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_) + { + byte b0 = 0; + int l = MathHelper.floor_double((double)(p_149689_5_.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + + if (l == 0) + { + b0 = 2; + } + + if (l == 1) + { + b0 = 5; + } + + if (l == 2) + { + b0 = 3; + } + + if (l == 3) + { + b0 = 4; + } + + p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, b0, 2); + } + + public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) + { + InventoryEnderChest inventoryenderchest = p_149727_5_.getInventoryEnderChest(); + TileEntityEnderChest tileentityenderchest = (TileEntityEnderChest)p_149727_1_.getTileEntity(p_149727_2_, p_149727_3_, p_149727_4_); + + if (inventoryenderchest != null && tileentityenderchest != null) + { + if (p_149727_1_.getBlock(p_149727_2_, p_149727_3_ + 1, p_149727_4_).isNormalCube()) + { + return true; + } + else if (p_149727_1_.isRemote) + { + return true; + } + else + { + inventoryenderchest.func_146031_a(tileentityenderchest); + p_149727_5_.displayGUIChest(inventoryenderchest); + return true; + } + } + else + { + return true; + } + } + + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) + { + return new TileEntityEnderChest(); + } + + @SideOnly(Side.CLIENT) + public void randomDisplayTick(World p_149734_1_, int p_149734_2_, int p_149734_3_, int p_149734_4_, Random p_149734_5_) + { + for (int l = 0; l < 3; ++l) + { + double d6 = (double)((float)p_149734_2_ + p_149734_5_.nextFloat()); + double d1 = (double)((float)p_149734_3_ + p_149734_5_.nextFloat()); + d6 = (double)((float)p_149734_4_ + p_149734_5_.nextFloat()); + double d3 = 0.0D; + double d4 = 0.0D; + double d5 = 0.0D; + int i1 = p_149734_5_.nextInt(2) * 2 - 1; + int j1 = p_149734_5_.nextInt(2) * 2 - 1; + d3 = ((double)p_149734_5_.nextFloat() - 0.5D) * 0.125D; + d4 = ((double)p_149734_5_.nextFloat() - 0.5D) * 0.125D; + d5 = ((double)p_149734_5_.nextFloat() - 0.5D) * 0.125D; + double d2 = (double)p_149734_4_ + 0.5D + 0.25D * (double)j1; + d5 = (double)(p_149734_5_.nextFloat() * 1.0F * (float)j1); + double d0 = (double)p_149734_2_ + 0.5D + 0.25D * (double)i1; + d3 = (double)(p_149734_5_.nextFloat() * 1.0F * (float)i1); + p_149734_1_.spawnParticle("portal", d0, d1, d2, d3, d4, d5); + } + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.blockIcon = p_149651_1_.registerIcon("obsidian"); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockEventData.java b/src/main/java/net/minecraft/block/BlockEventData.java new file mode 100644 index 0000000..7692fa8 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockEventData.java @@ -0,0 +1,70 @@ +package net.minecraft.block; + +public class BlockEventData +{ + private int coordX; + private int coordY; + private int coordZ; + private Block field_151344_d; + private int eventID; + private int eventParameter; + private static final String __OBFID = "CL_00000131"; + + public BlockEventData(int p_i45362_1_, int p_i45362_2_, int p_i45362_3_, Block p_i45362_4_, int p_i45362_5_, int p_i45362_6_) + { + this.coordX = p_i45362_1_; + this.coordY = p_i45362_2_; + this.coordZ = p_i45362_3_; + this.eventID = p_i45362_5_; + this.eventParameter = p_i45362_6_; + this.field_151344_d = p_i45362_4_; + } + + public int func_151340_a() + { + return this.coordX; + } + + public int func_151342_b() + { + return this.coordY; + } + + public int func_151341_c() + { + return this.coordZ; + } + + public int getEventID() + { + return this.eventID; + } + + public int getEventParameter() + { + return this.eventParameter; + } + + public Block getBlock() + { + return this.field_151344_d; + } + + public boolean equals(Object par1Obj) + { + if (!(par1Obj instanceof BlockEventData)) + { + return false; + } + else + { + BlockEventData blockeventdata = (BlockEventData)par1Obj; + return this.coordX == blockeventdata.coordX && this.coordY == blockeventdata.coordY && this.coordZ == blockeventdata.coordZ && this.eventID == blockeventdata.eventID && this.eventParameter == blockeventdata.eventParameter && this.field_151344_d == blockeventdata.field_151344_d; + } + } + + public String toString() + { + return "TE(" + this.coordX + "," + this.coordY + "," + this.coordZ + ")," + this.eventID + "," + this.eventParameter + "," + this.field_151344_d; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockFalling.java b/src/main/java/net/minecraft/block/BlockFalling.java new file mode 100644 index 0000000..312485a --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockFalling.java @@ -0,0 +1,104 @@ +package net.minecraft.block; + +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.item.EntityFallingBlock; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; + +public class BlockFalling extends Block +{ + public static boolean fallInstantly; + private static final String __OBFID = "CL_00000240"; + + public BlockFalling() + { + super(Material.sand); + this.setCreativeTab(CreativeTabs.tabBlock); + } + + public BlockFalling(Material p_i45405_1_) + { + super(p_i45405_1_); + } + + public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_) + { + p_149726_1_.scheduleBlockUpdate(p_149726_2_, p_149726_3_, p_149726_4_, this, this.tickRate(p_149726_1_)); + } + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) + { + p_149695_1_.scheduleBlockUpdate(p_149695_2_, p_149695_3_, p_149695_4_, this, this.tickRate(p_149695_1_)); + } + + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) + { + if (!p_149674_1_.isRemote) + { + this.func_149830_m(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_); + } + } + + private void func_149830_m(World p_149830_1_, int p_149830_2_, int p_149830_3_, int p_149830_4_) + { + if (func_149831_e(p_149830_1_, p_149830_2_, p_149830_3_ - 1, p_149830_4_) && p_149830_3_ >= 0) + { + byte b0 = 32; + + if (!fallInstantly && p_149830_1_.checkChunksExist(p_149830_2_ - b0, p_149830_3_ - b0, p_149830_4_ - b0, p_149830_2_ + b0, p_149830_3_ + b0, p_149830_4_ + b0)) + { + if (!p_149830_1_.isRemote) + { + EntityFallingBlock entityfallingblock = new EntityFallingBlock(p_149830_1_, (double)((float)p_149830_2_ + 0.5F), (double)((float)p_149830_3_ + 0.5F), (double)((float)p_149830_4_ + 0.5F), this, p_149830_1_.getBlockMetadata(p_149830_2_, p_149830_3_, p_149830_4_)); + this.func_149829_a(entityfallingblock); + p_149830_1_.spawnEntityInWorld(entityfallingblock); + } + } + else + { + p_149830_1_.setBlockToAir(p_149830_2_, p_149830_3_, p_149830_4_); + + while (func_149831_e(p_149830_1_, p_149830_2_, p_149830_3_ - 1, p_149830_4_) && p_149830_3_ > 0) + { + --p_149830_3_; + } + + if (p_149830_3_ > 0) + { + p_149830_1_.setBlock(p_149830_2_, p_149830_3_, p_149830_4_, this); + } + } + } + } + + protected void func_149829_a(EntityFallingBlock p_149829_1_) {} + + public int tickRate(World p_149738_1_) + { + return 2; + } + + public static boolean func_149831_e(World p_149831_0_, int p_149831_1_, int p_149831_2_, int p_149831_3_) + { + Block block = p_149831_0_.getBlock(p_149831_1_, p_149831_2_, p_149831_3_); + + if (block.isAir(p_149831_0_, p_149831_1_, p_149831_2_, p_149831_3_)) + { + return true; + } + else if (block == Blocks.fire) + { + return true; + } + else + { + //TODO: King, take a look here when doing liquids! + Material material = block.blockMaterial; + return material == Material.water ? true : material == Material.lava; + } + } + + public void func_149828_a(World p_149828_1_, int p_149828_2_, int p_149828_3_, int p_149828_4_, int p_149828_5_) {} +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockFarmland.java b/src/main/java/net/minecraft/block/BlockFarmland.java new file mode 100644 index 0000000..7f930c8 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockFarmland.java @@ -0,0 +1,156 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; +import net.minecraftforge.common.IPlantable; +import net.minecraftforge.common.util.ForgeDirection; + +public class BlockFarmland extends Block +{ + @SideOnly(Side.CLIENT) + private IIcon field_149824_a; + @SideOnly(Side.CLIENT) + private IIcon field_149823_b; + private static final String __OBFID = "CL_00000241"; + + protected BlockFarmland() + { + super(Material.ground); + this.setTickRandomly(true); + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.9375F, 1.0F); + this.setLightOpacity(255); + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) + { + return AxisAlignedBB.getAABBPool().getAABB((double)(p_149668_2_ + 0), (double)(p_149668_3_ + 0), (double)(p_149668_4_ + 0), (double)(p_149668_2_ + 1), (double)(p_149668_3_ + 1), (double)(p_149668_4_ + 1)); + } + + public boolean isOpaqueCube() + { + return false; + } + + public boolean renderAsNormalBlock() + { + return false; + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return p_149691_1_ == 1 ? (p_149691_2_ > 0 ? this.field_149824_a : this.field_149823_b) : Blocks.dirt.getBlockTextureFromSide(p_149691_1_); + } + + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) + { + if (!this.func_149821_m(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_) && !p_149674_1_.canLightningStrikeAt(p_149674_2_, p_149674_3_ + 1, p_149674_4_)) + { + int l = p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_); + + if (l > 0) + { + p_149674_1_.setBlockMetadataWithNotify(p_149674_2_, p_149674_3_, p_149674_4_, l - 1, 2); + } + else if (!this.func_149822_e(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_)) + { + p_149674_1_.setBlock(p_149674_2_, p_149674_3_, p_149674_4_, Blocks.dirt); + } + } + else + { + p_149674_1_.setBlockMetadataWithNotify(p_149674_2_, p_149674_3_, p_149674_4_, 7, 2); + } + } + + public void onFallenUpon(World p_149746_1_, int p_149746_2_, int p_149746_3_, int p_149746_4_, Entity p_149746_5_, float p_149746_6_) + { + if (!p_149746_1_.isRemote && p_149746_1_.rand.nextFloat() < p_149746_6_ - 0.5F) + { + if (!(p_149746_5_ instanceof EntityPlayer) && !p_149746_1_.getGameRules().getGameRuleBooleanValue("mobGriefing")) + { + return; + } + + p_149746_1_.setBlock(p_149746_2_, p_149746_3_, p_149746_4_, Blocks.dirt); + } + } + + private boolean func_149822_e(World p_149822_1_, int p_149822_2_, int p_149822_3_, int p_149822_4_) + { + byte b0 = 0; + + for (int l = p_149822_2_ - b0; l <= p_149822_2_ + b0; ++l) + { + for (int i1 = p_149822_4_ - b0; i1 <= p_149822_4_ + b0; ++i1) + { + Block block = p_149822_1_.getBlock(l, p_149822_3_ + 1, i1); + + if (block instanceof IPlantable && canSustainPlant(p_149822_1_, p_149822_2_, p_149822_3_, p_149822_4_, ForgeDirection.UP, (IPlantable)block)) + { + return true; + } + } + } + + return false; + } + + private boolean func_149821_m(World p_149821_1_, int p_149821_2_, int p_149821_3_, int p_149821_4_) + { + for (int l = p_149821_2_ - 4; l <= p_149821_2_ + 4; ++l) + { + for (int i1 = p_149821_3_; i1 <= p_149821_3_ + 1; ++i1) + { + for (int j1 = p_149821_4_ - 4; j1 <= p_149821_4_ + 4; ++j1) + { + if (p_149821_1_.getBlock(l, i1, j1).getMaterial() == Material.water) + { + return true; + } + } + } + } + + return false; + } + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) + { + super.onNeighborBlockChange(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, p_149695_5_); + Material material = p_149695_1_.getBlock(p_149695_2_, p_149695_3_ + 1, p_149695_4_).getMaterial(); + + if (material.isSolid()) + { + p_149695_1_.setBlock(p_149695_2_, p_149695_3_, p_149695_4_, Blocks.dirt); + } + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return Blocks.dirt.getItemDropped(0, p_149650_2_, p_149650_3_); + } + + @SideOnly(Side.CLIENT) + public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) + { + return Item.getItemFromBlock(Blocks.dirt); + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.field_149824_a = p_149651_1_.registerIcon(this.getTextureName() + "_wet"); + this.field_149823_b = p_149651_1_.registerIcon(this.getTextureName() + "_dry"); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockFence.java b/src/main/java/net/minecraft/block/BlockFence.java new file mode 100644 index 0000000..d88ab19 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockFence.java @@ -0,0 +1,169 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemLead; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockFence extends Block +{ + private final String field_149827_a; + private static final String __OBFID = "CL_00000242"; + + public BlockFence(String p_i45406_1_, Material p_i45406_2_) + { + super(p_i45406_2_); + this.field_149827_a = p_i45406_1_; + this.setCreativeTab(CreativeTabs.tabDecorations); + } + + public void addCollisionBoxesToList(World p_149743_1_, int p_149743_2_, int p_149743_3_, int p_149743_4_, AxisAlignedBB p_149743_5_, List p_149743_6_, Entity p_149743_7_) + { + boolean flag = this.canConnectFenceTo(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_ - 1); + boolean flag1 = this.canConnectFenceTo(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_ + 1); + boolean flag2 = this.canConnectFenceTo(p_149743_1_, p_149743_2_ - 1, p_149743_3_, p_149743_4_); + boolean flag3 = this.canConnectFenceTo(p_149743_1_, p_149743_2_ + 1, p_149743_3_, p_149743_4_); + float f = 0.375F; + float f1 = 0.625F; + float f2 = 0.375F; + float f3 = 0.625F; + + if (flag) + { + f2 = 0.0F; + } + + if (flag1) + { + f3 = 1.0F; + } + + if (flag || flag1) + { + this.setBlockBounds(f, 0.0F, f2, f1, 1.5F, f3); + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + } + + f2 = 0.375F; + f3 = 0.625F; + + if (flag2) + { + f = 0.0F; + } + + if (flag3) + { + f1 = 1.0F; + } + + if (flag2 || flag3 || !flag && !flag1) + { + this.setBlockBounds(f, 0.0F, f2, f1, 1.5F, f3); + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + } + + if (flag) + { + f2 = 0.0F; + } + + if (flag1) + { + f3 = 1.0F; + } + + this.setBlockBounds(f, 0.0F, f2, f1, 1.0F, f3); + } + + public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) + { + boolean flag = this.canConnectFenceTo(p_149719_1_, p_149719_2_, p_149719_3_, p_149719_4_ - 1); + boolean flag1 = this.canConnectFenceTo(p_149719_1_, p_149719_2_, p_149719_3_, p_149719_4_ + 1); + boolean flag2 = this.canConnectFenceTo(p_149719_1_, p_149719_2_ - 1, p_149719_3_, p_149719_4_); + boolean flag3 = this.canConnectFenceTo(p_149719_1_, p_149719_2_ + 1, p_149719_3_, p_149719_4_); + float f = 0.375F; + float f1 = 0.625F; + float f2 = 0.375F; + float f3 = 0.625F; + + if (flag) + { + f2 = 0.0F; + } + + if (flag1) + { + f3 = 1.0F; + } + + if (flag2) + { + f = 0.0F; + } + + if (flag3) + { + f1 = 1.0F; + } + + this.setBlockBounds(f, 0.0F, f2, f1, 1.0F, f3); + } + + public boolean isOpaqueCube() + { + return false; + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public boolean getBlocksMovement(IBlockAccess p_149655_1_, int p_149655_2_, int p_149655_3_, int p_149655_4_) + { + return false; + } + + public int getRenderType() + { + return 11; + } + + public boolean canConnectFenceTo(IBlockAccess p_149826_1_, int p_149826_2_, int p_149826_3_, int p_149826_4_) + { + Block block = p_149826_1_.getBlock(p_149826_2_, p_149826_3_, p_149826_4_); + return block != this && block != Blocks.fence_gate ? (block.blockMaterial.isOpaque() && block.renderAsNormalBlock() ? block.blockMaterial != Material.gourd : false) : true; + } + + public static boolean func_149825_a(Block p_149825_0_) + { + return p_149825_0_ == Blocks.fence || p_149825_0_ == Blocks.nether_brick_fence; + } + + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) + { + return true; + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.blockIcon = p_149651_1_.registerIcon(this.field_149827_a); + } + + public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) + { + return p_149727_1_.isRemote ? true : ItemLead.func_150909_a(p_149727_5_, p_149727_1_, p_149727_2_, p_149727_3_, p_149727_4_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockFenceGate.java b/src/main/java/net/minecraft/block/BlockFenceGate.java new file mode 100644 index 0000000..46aa664 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockFenceGate.java @@ -0,0 +1,146 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockFenceGate extends BlockDirectional +{ + private static final String __OBFID = "CL_00000243"; + + public BlockFenceGate() + { + super(Material.wood); + this.setCreativeTab(CreativeTabs.tabRedstone); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return Blocks.planks.getBlockTextureFromSide(p_149691_1_); + } + + public boolean canPlaceBlockAt(World p_149742_1_, int p_149742_2_, int p_149742_3_, int p_149742_4_) + { + return !p_149742_1_.getBlock(p_149742_2_, p_149742_3_ - 1, p_149742_4_).getMaterial().isSolid() ? false : super.canPlaceBlockAt(p_149742_1_, p_149742_2_, p_149742_3_, p_149742_4_); + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) + { + int l = p_149668_1_.getBlockMetadata(p_149668_2_, p_149668_3_, p_149668_4_); + return isFenceGateOpen(l) ? null : (l != 2 && l != 0 ? AxisAlignedBB.getAABBPool().getAABB((double)((float)p_149668_2_ + 0.375F), (double)p_149668_3_, (double)p_149668_4_, (double)((float)p_149668_2_ + 0.625F), (double)((float)p_149668_3_ + 1.5F), (double)(p_149668_4_ + 1)) : AxisAlignedBB.getAABBPool().getAABB((double)p_149668_2_, (double)p_149668_3_, (double)((float)p_149668_4_ + 0.375F), (double)(p_149668_2_ + 1), (double)((float)p_149668_3_ + 1.5F), (double)((float)p_149668_4_ + 0.625F))); + } + + public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) + { + int l = getDirection(p_149719_1_.getBlockMetadata(p_149719_2_, p_149719_3_, p_149719_4_)); + + if (l != 2 && l != 0) + { + this.setBlockBounds(0.375F, 0.0F, 0.0F, 0.625F, 1.0F, 1.0F); + } + else + { + this.setBlockBounds(0.0F, 0.0F, 0.375F, 1.0F, 1.0F, 0.625F); + } + } + + public boolean isOpaqueCube() + { + return false; + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public boolean getBlocksMovement(IBlockAccess p_149655_1_, int p_149655_2_, int p_149655_3_, int p_149655_4_) + { + return isFenceGateOpen(p_149655_1_.getBlockMetadata(p_149655_2_, p_149655_3_, p_149655_4_)); + } + + public int getRenderType() + { + return 21; + } + + public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_) + { + int l = (MathHelper.floor_double((double)(p_149689_5_.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3) % 4; + p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, l, 2); + } + + public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) + { + int i1 = p_149727_1_.getBlockMetadata(p_149727_2_, p_149727_3_, p_149727_4_); + + if (isFenceGateOpen(i1)) + { + p_149727_1_.setBlockMetadataWithNotify(p_149727_2_, p_149727_3_, p_149727_4_, i1 & -5, 2); + } + else + { + int j1 = (MathHelper.floor_double((double)(p_149727_5_.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3) % 4; + int k1 = getDirection(i1); + + if (k1 == (j1 + 2) % 4) + { + i1 = j1; + } + + p_149727_1_.setBlockMetadataWithNotify(p_149727_2_, p_149727_3_, p_149727_4_, i1 | 4, 2); + } + + p_149727_1_.playAuxSFXAtEntity(p_149727_5_, 1003, p_149727_2_, p_149727_3_, p_149727_4_, 0); + return true; + } + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) + { + if (!p_149695_1_.isRemote) + { + int l = p_149695_1_.getBlockMetadata(p_149695_2_, p_149695_3_, p_149695_4_); + boolean flag = p_149695_1_.isBlockIndirectlyGettingPowered(p_149695_2_, p_149695_3_, p_149695_4_); + + if (flag || p_149695_5_.canProvidePower()) + { + if (flag && !isFenceGateOpen(l)) + { + p_149695_1_.setBlockMetadataWithNotify(p_149695_2_, p_149695_3_, p_149695_4_, l | 4, 2); + p_149695_1_.playAuxSFXAtEntity((EntityPlayer)null, 1003, p_149695_2_, p_149695_3_, p_149695_4_, 0); + } + else if (!flag && isFenceGateOpen(l)) + { + p_149695_1_.setBlockMetadataWithNotify(p_149695_2_, p_149695_3_, p_149695_4_, l & -5, 2); + p_149695_1_.playAuxSFXAtEntity((EntityPlayer)null, 1003, p_149695_2_, p_149695_3_, p_149695_4_, 0); + } + } + } + } + + public static boolean isFenceGateOpen(int p_149896_0_) + { + return (p_149896_0_ & 4) != 0; + } + + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) + { + return true; + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) {} +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockFire.java b/src/main/java/net/minecraft/block/BlockFire.java new file mode 100644 index 0000000..7b6ed96 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockFire.java @@ -0,0 +1,520 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.IdentityHashMap; +import java.util.Map.Entry; +import java.util.Random; +import com.google.common.collect.Maps; +import net.minecraft.block.material.MapColor; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.init.Blocks; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraft.world.WorldProviderEnd; +import net.minecraftforge.common.util.ForgeDirection; +import static net.minecraftforge.common.util.ForgeDirection.*; + +public class BlockFire extends Block +{ + @Deprecated + private int[] field_149849_a = new int[4096]; + @Deprecated + private int[] field_149848_b = new int[4096]; + @SideOnly(Side.CLIENT) + private IIcon[] field_149850_M; + private static final String __OBFID = "CL_00000245"; + + protected BlockFire() + { + super(Material.fire); + this.setTickRandomly(true); + } + + public static void func_149843_e() + { + Blocks.fire.func_149842_a(getIdFromBlock(Blocks.planks), 5, 20); + Blocks.fire.func_149842_a(getIdFromBlock(Blocks.double_wooden_slab), 5, 20); + Blocks.fire.func_149842_a(getIdFromBlock(Blocks.wooden_slab), 5, 20); + Blocks.fire.func_149842_a(getIdFromBlock(Blocks.fence), 5, 20); + Blocks.fire.func_149842_a(getIdFromBlock(Blocks.oak_stairs), 5, 20); + Blocks.fire.func_149842_a(getIdFromBlock(Blocks.birch_stairs), 5, 20); + Blocks.fire.func_149842_a(getIdFromBlock(Blocks.spruce_stairs), 5, 20); + Blocks.fire.func_149842_a(getIdFromBlock(Blocks.jungle_stairs), 5, 20); + Blocks.fire.func_149842_a(getIdFromBlock(Blocks.log), 5, 5); + Blocks.fire.func_149842_a(getIdFromBlock(Blocks.log2), 5, 5); + Blocks.fire.func_149842_a(getIdFromBlock(Blocks.leaves), 30, 60); + Blocks.fire.func_149842_a(getIdFromBlock(Blocks.leaves2), 30, 60); + Blocks.fire.func_149842_a(getIdFromBlock(Blocks.bookshelf), 30, 20); + Blocks.fire.func_149842_a(getIdFromBlock(Blocks.tnt), 15, 100); + Blocks.fire.func_149842_a(getIdFromBlock(Blocks.tallgrass), 60, 100); + Blocks.fire.func_149842_a(getIdFromBlock(Blocks.double_plant), 60, 100); + Blocks.fire.func_149842_a(getIdFromBlock(Blocks.yellow_flower), 60, 100); + Blocks.fire.func_149842_a(getIdFromBlock(Blocks.red_flower), 60, 100); + Blocks.fire.func_149842_a(getIdFromBlock(Blocks.wool), 30, 60); + Blocks.fire.func_149842_a(getIdFromBlock(Blocks.vine), 15, 100); + Blocks.fire.func_149842_a(getIdFromBlock(Blocks.coal_block), 5, 5); + Blocks.fire.func_149842_a(getIdFromBlock(Blocks.hay_block), 60, 20); + Blocks.fire.func_149842_a(getIdFromBlock(Blocks.carpet), 60, 20); + } + + @Deprecated // Use setFireInfo + public void func_149842_a(int p_149842_1_, int p_149842_2_, int p_149842_3_) + { + this.setFireInfo((Block)Block.blockRegistry.getObjectById(p_149842_1_), p_149842_2_, p_149842_3_); + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) + { + return null; + } + + public boolean isOpaqueCube() + { + return false; + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public int getRenderType() + { + return 3; + } + + public int quantityDropped(Random p_149745_1_) + { + return 0; + } + + public int tickRate(World p_149738_1_) + { + return 30; + } + + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) + { + if (p_149674_1_.getGameRules().getGameRuleBooleanValue("doFireTick")) + { + boolean flag = p_149674_1_.getBlock(p_149674_2_, p_149674_3_ - 1, p_149674_4_).isFireSource(p_149674_1_, p_149674_2_, p_149674_3_ - 1, p_149674_4_, UP); + + if (!this.canPlaceBlockAt(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_)) + { + p_149674_1_.setBlockToAir(p_149674_2_, p_149674_3_, p_149674_4_); + } + + if (!flag && p_149674_1_.isRaining() && (p_149674_1_.canLightningStrikeAt(p_149674_2_, p_149674_3_, p_149674_4_) || p_149674_1_.canLightningStrikeAt(p_149674_2_ - 1, p_149674_3_, p_149674_4_) || p_149674_1_.canLightningStrikeAt(p_149674_2_ + 1, p_149674_3_, p_149674_4_) || p_149674_1_.canLightningStrikeAt(p_149674_2_, p_149674_3_, p_149674_4_ - 1) || p_149674_1_.canLightningStrikeAt(p_149674_2_, p_149674_3_, p_149674_4_ + 1))) + { + p_149674_1_.setBlockToAir(p_149674_2_, p_149674_3_, p_149674_4_); + } + else + { + int l = p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_); + + if (l < 15) + { + p_149674_1_.setBlockMetadataWithNotify(p_149674_2_, p_149674_3_, p_149674_4_, l + p_149674_5_.nextInt(3) / 2, 4); + } + + p_149674_1_.scheduleBlockUpdate(p_149674_2_, p_149674_3_, p_149674_4_, this, this.tickRate(p_149674_1_) + p_149674_5_.nextInt(10)); + + if (!flag && !this.canNeighborBurn(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_)) + { + if (!World.doesBlockHaveSolidTopSurface(p_149674_1_, p_149674_2_, p_149674_3_ - 1, p_149674_4_) || l > 3) + { + p_149674_1_.setBlockToAir(p_149674_2_, p_149674_3_, p_149674_4_); + } + } + else if (!flag && !this.canCatchFire(p_149674_1_, p_149674_2_, p_149674_3_ - 1, p_149674_4_, UP) && l == 15 && p_149674_5_.nextInt(4) == 0) + { + p_149674_1_.setBlockToAir(p_149674_2_, p_149674_3_, p_149674_4_); + } + else + { + boolean flag1 = p_149674_1_.isBlockHighHumidity(p_149674_2_, p_149674_3_, p_149674_4_); + byte b0 = 0; + + if (flag1) + { + b0 = -50; + } + + this.tryCatchFire(p_149674_1_, p_149674_2_ + 1, p_149674_3_, p_149674_4_, 300 + b0, p_149674_5_, l, WEST ); + this.tryCatchFire(p_149674_1_, p_149674_2_ - 1, p_149674_3_, p_149674_4_, 300 + b0, p_149674_5_, l, EAST ); + this.tryCatchFire(p_149674_1_, p_149674_2_, p_149674_3_ - 1, p_149674_4_, 250 + b0, p_149674_5_, l, UP ); + this.tryCatchFire(p_149674_1_, p_149674_2_, p_149674_3_ + 1, p_149674_4_, 250 + b0, p_149674_5_, l, DOWN ); + this.tryCatchFire(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_ - 1, 300 + b0, p_149674_5_, l, SOUTH); + this.tryCatchFire(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_ + 1, 300 + b0, p_149674_5_, l, NORTH); + + for (int i1 = p_149674_2_ - 1; i1 <= p_149674_2_ + 1; ++i1) + { + for (int j1 = p_149674_4_ - 1; j1 <= p_149674_4_ + 1; ++j1) + { + for (int k1 = p_149674_3_ - 1; k1 <= p_149674_3_ + 4; ++k1) + { + if (i1 != p_149674_2_ || k1 != p_149674_3_ || j1 != p_149674_4_) + { + int l1 = 100; + + if (k1 > p_149674_3_ + 1) + { + l1 += (k1 - (p_149674_3_ + 1)) * 100; + } + + int i2 = this.getChanceOfNeighborsEncouragingFire(p_149674_1_, i1, k1, j1); + + if (i2 > 0) + { + int j2 = (i2 + 40 + p_149674_1_.difficultySetting.getDifficultyId() * 7) / (l + 30); + + if (flag1) + { + j2 /= 2; + } + + if (j2 > 0 && p_149674_5_.nextInt(l1) <= j2 && (!p_149674_1_.isRaining() || !p_149674_1_.canLightningStrikeAt(i1, k1, j1)) && !p_149674_1_.canLightningStrikeAt(i1 - 1, k1, p_149674_4_) && !p_149674_1_.canLightningStrikeAt(i1 + 1, k1, j1) && !p_149674_1_.canLightningStrikeAt(i1, k1, j1 - 1) && !p_149674_1_.canLightningStrikeAt(i1, k1, j1 + 1)) + { + int k2 = l + p_149674_5_.nextInt(5) / 4; + + if (k2 > 15) + { + k2 = 15; + } + + p_149674_1_.setBlock(i1, k1, j1, this, k2, 3); + } + } + } + } + } + } + } + } + } + } + + public boolean func_149698_L() + { + return false; + } + + @Deprecated + private void tryCatchFire(World p_149841_1_, int p_149841_2_, int p_149841_3_, int p_149841_4_, int p_149841_5_, Random p_149841_6_, int p_149841_7_) + { + this.tryCatchFire(p_149841_1_, p_149841_2_, p_149841_3_, p_149841_4_, p_149841_5_, p_149841_6_, p_149841_7_, UP); + } + + private void tryCatchFire(World p_149841_1_, int p_149841_2_, int p_149841_3_, int p_149841_4_, int p_149841_5_, Random p_149841_6_, int p_149841_7_, ForgeDirection face) + { + int j1 = p_149841_1_.getBlock(p_149841_2_, p_149841_3_, p_149841_4_).getFlammability(p_149841_1_, p_149841_2_, p_149841_3_, p_149841_4_, face); + + if (p_149841_6_.nextInt(p_149841_5_) < j1) + { + boolean flag = p_149841_1_.getBlock(p_149841_2_, p_149841_3_, p_149841_4_) == Blocks.tnt; + + if (p_149841_6_.nextInt(p_149841_7_ + 10) < 5 && !p_149841_1_.canLightningStrikeAt(p_149841_2_, p_149841_3_, p_149841_4_)) + { + int k1 = p_149841_7_ + p_149841_6_.nextInt(5) / 4; + + if (k1 > 15) + { + k1 = 15; + } + + p_149841_1_.setBlock(p_149841_2_, p_149841_3_, p_149841_4_, this, k1, 3); + } + else + { + p_149841_1_.setBlockToAir(p_149841_2_, p_149841_3_, p_149841_4_); + } + + if (flag) + { + Blocks.tnt.onBlockDestroyedByPlayer(p_149841_1_, p_149841_2_, p_149841_3_, p_149841_4_, 1); + } + } + } + + private boolean canNeighborBurn(World p_149847_1_, int p_149847_2_, int p_149847_3_, int p_149847_4_) + { + return this.canCatchFire(p_149847_1_, p_149847_2_ + 1, p_149847_3_, p_149847_4_, WEST ) || + this.canCatchFire(p_149847_1_, p_149847_2_ - 1, p_149847_3_, p_149847_4_, EAST ) || + this.canCatchFire(p_149847_1_, p_149847_2_, p_149847_3_ - 1, p_149847_4_, UP ) || + this.canCatchFire(p_149847_1_, p_149847_2_, p_149847_3_ + 1, p_149847_4_, DOWN ) || + this.canCatchFire(p_149847_1_, p_149847_2_, p_149847_3_, p_149847_4_ - 1, SOUTH) || + this.canCatchFire(p_149847_1_, p_149847_2_, p_149847_3_, p_149847_4_ + 1, NORTH); + } + + private int getChanceOfNeighborsEncouragingFire(World p_149845_1_, int p_149845_2_, int p_149845_3_, int p_149845_4_) + { + byte b0 = 0; + + if (!p_149845_1_.isAirBlock(p_149845_2_, p_149845_3_, p_149845_4_)) + { + return 0; + } + else + { + int l = b0; + l = this.getChanceToEncourageFire(p_149845_1_, p_149845_2_ + 1, p_149845_3_, p_149845_4_, l, WEST ); + l = this.getChanceToEncourageFire(p_149845_1_, p_149845_2_ - 1, p_149845_3_, p_149845_4_, l, EAST ); + l = this.getChanceToEncourageFire(p_149845_1_, p_149845_2_, p_149845_3_ - 1, p_149845_4_, l, UP ); + l = this.getChanceToEncourageFire(p_149845_1_, p_149845_2_, p_149845_3_ + 1, p_149845_4_, l, DOWN ); + l = this.getChanceToEncourageFire(p_149845_1_, p_149845_2_, p_149845_3_, p_149845_4_ - 1, l, SOUTH); + l = this.getChanceToEncourageFire(p_149845_1_, p_149845_2_, p_149845_3_, p_149845_4_ + 1, l, NORTH); + return l; + } + } + + public boolean isCollidable() + { + return false; + } + + @Deprecated + public boolean canBlockCatchFire(IBlockAccess p_149844_1_, int p_149844_2_, int p_149844_3_, int p_149844_4_) + { + return canCatchFire(p_149844_1_, p_149844_2_, p_149844_3_, p_149844_4_, UP); + } + + @Deprecated + public int func_149846_a(World p_149846_1_, int p_149846_2_, int p_149846_3_, int p_149846_4_, int p_149846_5_) + { + return getChanceToEncourageFire(p_149846_1_, p_149846_2_, p_149846_3_, p_149846_4_, p_149846_5_, UP); + } + + public boolean canPlaceBlockAt(World p_149742_1_, int p_149742_2_, int p_149742_3_, int p_149742_4_) + { + return World.doesBlockHaveSolidTopSurface(p_149742_1_, p_149742_2_, p_149742_3_ - 1, p_149742_4_) || this.canNeighborBurn(p_149742_1_, p_149742_2_, p_149742_3_, p_149742_4_); + } + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) + { + if (!World.doesBlockHaveSolidTopSurface(p_149695_1_, p_149695_2_, p_149695_3_ - 1, p_149695_4_) && !this.canNeighborBurn(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_)) + { + p_149695_1_.setBlockToAir(p_149695_2_, p_149695_3_, p_149695_4_); + } + } + + public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_) + { + if (p_149726_1_.provider.dimensionId > 0 || !Blocks.portal.func_150000_e(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_)) + { + if (!World.doesBlockHaveSolidTopSurface(p_149726_1_, p_149726_2_, p_149726_3_ - 1, p_149726_4_) && !this.canNeighborBurn(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_)) + { + p_149726_1_.setBlockToAir(p_149726_2_, p_149726_3_, p_149726_4_); + } + else + { + p_149726_1_.scheduleBlockUpdate(p_149726_2_, p_149726_3_, p_149726_4_, this, this.tickRate(p_149726_1_) + p_149726_1_.rand.nextInt(10)); + } + } + } + + @SideOnly(Side.CLIENT) + public void randomDisplayTick(World p_149734_1_, int p_149734_2_, int p_149734_3_, int p_149734_4_, Random p_149734_5_) + { + if (p_149734_5_.nextInt(24) == 0) + { + p_149734_1_.playSound((double)((float)p_149734_2_ + 0.5F), (double)((float)p_149734_3_ + 0.5F), (double)((float)p_149734_4_ + 0.5F), "fire.fire", 1.0F + p_149734_5_.nextFloat(), p_149734_5_.nextFloat() * 0.7F + 0.3F, false); + } + + int l; + float f; + float f1; + float f2; + + if (!World.doesBlockHaveSolidTopSurface(p_149734_1_, p_149734_2_, p_149734_3_ - 1, p_149734_4_) && !Blocks.fire.canCatchFire(p_149734_1_, p_149734_2_, p_149734_3_ - 1, p_149734_4_, UP)) + { + if (Blocks.fire.canCatchFire(p_149734_1_, p_149734_2_ - 1, p_149734_3_, p_149734_4_, EAST)) + { + for (l = 0; l < 2; ++l) + { + f = (float)p_149734_2_ + p_149734_5_.nextFloat() * 0.1F; + f1 = (float)p_149734_3_ + p_149734_5_.nextFloat(); + f2 = (float)p_149734_4_ + p_149734_5_.nextFloat(); + p_149734_1_.spawnParticle("largesmoke", (double)f, (double)f1, (double)f2, 0.0D, 0.0D, 0.0D); + } + } + + if (Blocks.fire.canCatchFire(p_149734_1_, p_149734_2_ + 1, p_149734_3_, p_149734_4_, WEST)) + { + for (l = 0; l < 2; ++l) + { + f = (float)(p_149734_2_ + 1) - p_149734_5_.nextFloat() * 0.1F; + f1 = (float)p_149734_3_ + p_149734_5_.nextFloat(); + f2 = (float)p_149734_4_ + p_149734_5_.nextFloat(); + p_149734_1_.spawnParticle("largesmoke", (double)f, (double)f1, (double)f2, 0.0D, 0.0D, 0.0D); + } + } + + if (Blocks.fire.canCatchFire(p_149734_1_, p_149734_2_, p_149734_3_, p_149734_4_ - 1, SOUTH)) + { + for (l = 0; l < 2; ++l) + { + f = (float)p_149734_2_ + p_149734_5_.nextFloat(); + f1 = (float)p_149734_3_ + p_149734_5_.nextFloat(); + f2 = (float)p_149734_4_ + p_149734_5_.nextFloat() * 0.1F; + p_149734_1_.spawnParticle("largesmoke", (double)f, (double)f1, (double)f2, 0.0D, 0.0D, 0.0D); + } + } + + if (Blocks.fire.canCatchFire(p_149734_1_, p_149734_2_, p_149734_3_, p_149734_4_ + 1, NORTH)) + { + for (l = 0; l < 2; ++l) + { + f = (float)p_149734_2_ + p_149734_5_.nextFloat(); + f1 = (float)p_149734_3_ + p_149734_5_.nextFloat(); + f2 = (float)(p_149734_4_ + 1) - p_149734_5_.nextFloat() * 0.1F; + p_149734_1_.spawnParticle("largesmoke", (double)f, (double)f1, (double)f2, 0.0D, 0.0D, 0.0D); + } + } + + if (Blocks.fire.canCatchFire(p_149734_1_, p_149734_2_, p_149734_3_ + 1, p_149734_4_, DOWN)) + { + for (l = 0; l < 2; ++l) + { + f = (float)p_149734_2_ + p_149734_5_.nextFloat(); + f1 = (float)(p_149734_3_ + 1) - p_149734_5_.nextFloat() * 0.1F; + f2 = (float)p_149734_4_ + p_149734_5_.nextFloat(); + p_149734_1_.spawnParticle("largesmoke", (double)f, (double)f1, (double)f2, 0.0D, 0.0D, 0.0D); + } + } + } + else + { + for (l = 0; l < 3; ++l) + { + f = (float)p_149734_2_ + p_149734_5_.nextFloat(); + f1 = (float)p_149734_3_ + p_149734_5_.nextFloat() * 0.5F + 0.5F; + f2 = (float)p_149734_4_ + p_149734_5_.nextFloat(); + p_149734_1_.spawnParticle("largesmoke", (double)f, (double)f1, (double)f2, 0.0D, 0.0D, 0.0D); + } + } + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.field_149850_M = new IIcon[] {p_149651_1_.registerIcon(this.getTextureName() + "_layer_0"), p_149651_1_.registerIcon(this.getTextureName() + "_layer_1")}; + } + + @SideOnly(Side.CLIENT) + public IIcon getFireIcon(int p_149840_1_) + { + return this.field_149850_M[p_149840_1_]; + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return this.field_149850_M[0]; + } + + public MapColor getMapColor(int p_149728_1_) + { + return MapColor.tntColor; + } + + /*================================= Forge Start ======================================*/ + private static class FireInfo + { + private int encouragement = 0; + private int flammibility = 0; + } + private IdentityHashMap blockInfo = Maps.newIdentityHashMap(); + + public void setFireInfo(Block block, int encouragement, int flammibility) + { + if (block == Blocks.air) throw new IllegalArgumentException("Tried to set air on fire... This is bad."); + int id = Block.getIdFromBlock(block); + this.field_149849_a[id] = encouragement; + this.field_149848_b[id] = flammibility; + + FireInfo info = getInfo(block, true); + info.encouragement = encouragement; + info.flammibility = flammibility; + } + + private FireInfo getInfo(Block block, boolean garentee) + { + FireInfo ret = blockInfo.get(block); + if (ret == null && garentee) + { + ret = new FireInfo(); + blockInfo.put(block, ret); + } + return ret; + } + + public void rebuildFireInfo() + { + for (int x = 0; x < 4096; x++) + { + //If we care.. we could detect changes in here and make sure we keep them, however + //it's my thinking that anyone who hacks into the private variables should DIAF and we don't care about them. + field_149849_a[x] = 0; + field_149848_b[x] = 0; + } + + for (Entry e : blockInfo.entrySet()) + { + int id = Block.getIdFromBlock(e.getKey()); + if (id >= 0 && id < 4096) + { + field_149849_a[id] = e.getValue().encouragement; + field_149848_b[id] = e.getValue().flammibility; + } + } + } + + public int getFlammability(Block block) + { + int id = Block.getIdFromBlock(block); + return id >= 0 && id < 4096 ? field_149848_b[id] : 0; + } + + public int getEncouragement(Block block) + { + int id = Block.getIdFromBlock(block); + return id >= 0 && id < 4096 ? field_149849_a[id] : 0; + } + + /** + * Side sensitive version that calls the block function. + * + * @param world The current world + * @param x X Position + * @param y Y Position + * @param z Z Position + * @param face The side the fire is coming from + * @return True if the face can catch fire. + */ + public boolean canCatchFire(IBlockAccess world, int x, int y, int z, ForgeDirection face) + { + return world.getBlock(x, y, z).isFlammable(world, x, y, z, face); + } + + /** + * Side sensitive version that calls the block function. + * + * @param world The current world + * @param x X Position + * @param y Y Position + * @param z Z Position + * @param oldChance The previous maximum chance. + * @param face The side the fire is coming from + * @return The chance of the block catching fire, or oldChance if it is higher + */ + public int getChanceToEncourageFire(IBlockAccess world, int x, int y, int z, int oldChance, ForgeDirection face) + { + int newChance = world.getBlock(x, y, z).getFireSpreadSpeed(world, x, y, z, face); + return (newChance > oldChance ? newChance : oldChance); + } + /*================================= Forge Start ======================================*/ +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockFlower.java b/src/main/java/net/minecraft/block/BlockFlower.java new file mode 100644 index 0000000..f8a83b2 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockFlower.java @@ -0,0 +1,121 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +public class BlockFlower extends BlockBush +{ + private static final String[][] field_149860_M = new String[][] {{"flower_dandelion"}, {"flower_rose", "flower_blue_orchid", "flower_allium", "flower_houstonia", "flower_tulip_red", "flower_tulip_orange", "flower_tulip_white", "flower_tulip_pink", "flower_oxeye_daisy"}}; + public static final String[] field_149859_a = new String[] {"poppy", "blueOrchid", "allium", "houstonia", "tulipRed", "tulipOrange", "tulipWhite", "tulipPink", "oxeyeDaisy"}; + public static final String[] field_149858_b = new String[] {"dandelion"}; + @SideOnly(Side.CLIENT) + private IIcon[] field_149861_N; + private int field_149862_O; + private static final String __OBFID = "CL_00000246"; + + protected BlockFlower(int par1) + { + super(Material.plants); + this.field_149862_O = par1; + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + if (p_149691_2_ >= this.field_149861_N.length) + { + p_149691_2_ = 0; + } + + return this.field_149861_N[p_149691_2_]; + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.field_149861_N = new IIcon[field_149860_M[this.field_149862_O].length]; + + for (int i = 0; i < this.field_149861_N.length; ++i) + { + this.field_149861_N[i] = p_149651_1_.registerIcon(field_149860_M[this.field_149862_O][i]); + } + } + + public int damageDropped(int p_149692_1_) + { + return p_149692_1_; + } + + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_) + { + for (int i = 0; i < this.field_149861_N.length; ++i) + { + p_149666_3_.add(new ItemStack(p_149666_1_, 1, i)); + } + } + + public static BlockFlower func_149857_e(String p_149857_0_) + { + String[] astring = field_149858_b; + int i = astring.length; + int j; + String s1; + + for (j = 0; j < i; ++j) + { + s1 = astring[j]; + + if (s1.equals(p_149857_0_)) + { + return Blocks.yellow_flower; + } + } + + astring = field_149859_a; + i = astring.length; + + for (j = 0; j < i; ++j) + { + s1 = astring[j]; + + if (s1.equals(p_149857_0_)) + { + return Blocks.red_flower; + } + } + + return null; + } + + public static int func_149856_f(String p_149856_0_) + { + int i; + + for (i = 0; i < field_149858_b.length; ++i) + { + if (field_149858_b[i].equals(p_149856_0_)) + { + return i; + } + } + + for (i = 0; i < field_149859_a.length; ++i) + { + if (field_149859_a[i].equals(p_149856_0_)) + { + return i; + } + } + + return 0; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockFlowerPot.java b/src/main/java/net/minecraft/block/BlockFlowerPot.java new file mode 100644 index 0000000..c2b666c --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockFlowerPot.java @@ -0,0 +1,245 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityFlowerPot; +import net.minecraft.world.World; + +public class BlockFlowerPot extends BlockContainer +{ + private static final String __OBFID = "CL_00000247"; + + public BlockFlowerPot() + { + super(Material.circuits); + this.setBlockBoundsForItemRender(); + } + + public void setBlockBoundsForItemRender() + { + float f = 0.375F; + float f1 = f / 2.0F; + this.setBlockBounds(0.5F - f1, 0.0F, 0.5F - f1, 0.5F + f1, f, 0.5F + f1); + } + + public boolean isOpaqueCube() + { + return false; + } + + public int getRenderType() + { + return 33; + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) + { + ItemStack itemstack = p_149727_5_.inventory.getCurrentItem(); + + if (itemstack != null && itemstack.getItem() instanceof ItemBlock) + { + if (p_149727_1_.getBlockMetadata(p_149727_2_, p_149727_3_, p_149727_4_) != 0) + { + return false; + } + else + { + TileEntityFlowerPot tileentityflowerpot = this.func_149929_e(p_149727_1_, p_149727_2_, p_149727_3_, p_149727_4_); + + if (tileentityflowerpot != null) + { + Block block = Block.getBlockFromItem(itemstack.getItem()); + + if (!this.func_149928_a(block, itemstack.getItemDamage())) + { + return false; + } + else + { + tileentityflowerpot.func_145964_a(itemstack.getItem(), itemstack.getItemDamage()); + tileentityflowerpot.markDirty(); + + if (!p_149727_1_.setBlockMetadataWithNotify(p_149727_2_, p_149727_3_, p_149727_4_, itemstack.getItemDamage(), 2)) + { + p_149727_1_.markBlockForUpdate(p_149727_2_, p_149727_3_, p_149727_4_); + } + + if (!p_149727_5_.capabilities.isCreativeMode && --itemstack.stackSize <= 0) + { + p_149727_5_.inventory.setInventorySlotContents(p_149727_5_.inventory.currentItem, (ItemStack)null); + } + + return true; + } + } + else + { + return false; + } + } + } + else + { + return false; + } + } + + private boolean func_149928_a(Block p_149928_1_, int p_149928_2_) + { + return p_149928_1_ != Blocks.yellow_flower && p_149928_1_ != Blocks.red_flower && p_149928_1_ != Blocks.cactus && p_149928_1_ != Blocks.brown_mushroom && p_149928_1_ != Blocks.red_mushroom && p_149928_1_ != Blocks.sapling && p_149928_1_ != Blocks.deadbush ? p_149928_1_ == Blocks.tallgrass && p_149928_2_ == 2 : true; + } + + @SideOnly(Side.CLIENT) + public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) + { + TileEntityFlowerPot tileentityflowerpot = this.func_149929_e(p_149694_1_, p_149694_2_, p_149694_3_, p_149694_4_); + return tileentityflowerpot != null && tileentityflowerpot.getFlowerPotItem() != null ? tileentityflowerpot.getFlowerPotItem() : Items.flower_pot; + } + + public int getDamageValue(World p_149643_1_, int p_149643_2_, int p_149643_3_, int p_149643_4_) + { + TileEntityFlowerPot tileentityflowerpot = this.func_149929_e(p_149643_1_, p_149643_2_, p_149643_3_, p_149643_4_); + return tileentityflowerpot != null && tileentityflowerpot.getFlowerPotItem() != null ? tileentityflowerpot.getFlowerPotData() : 0; + } + + @SideOnly(Side.CLIENT) + public boolean isFlowerPot() + { + return true; + } + + public boolean canPlaceBlockAt(World p_149742_1_, int p_149742_2_, int p_149742_3_, int p_149742_4_) + { + return super.canPlaceBlockAt(p_149742_1_, p_149742_2_, p_149742_3_, p_149742_4_) && World.doesBlockHaveSolidTopSurface(p_149742_1_, p_149742_2_, p_149742_3_ - 1, p_149742_4_); + } + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) + { + if (!World.doesBlockHaveSolidTopSurface(p_149695_1_, p_149695_2_, p_149695_3_ - 1, p_149695_4_)) + { + this.dropBlockAsItem(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, p_149695_1_.getBlockMetadata(p_149695_2_, p_149695_3_, p_149695_4_), 0); + p_149695_1_.setBlockToAir(p_149695_2_, p_149695_3_, p_149695_4_); + } + } + + public void dropBlockAsItemWithChance(World p_149690_1_, int p_149690_2_, int p_149690_3_, int p_149690_4_, int p_149690_5_, float p_149690_6_, int p_149690_7_) + { + super.dropBlockAsItemWithChance(p_149690_1_, p_149690_2_, p_149690_3_, p_149690_4_, p_149690_5_, p_149690_6_, p_149690_7_); + TileEntityFlowerPot tileentityflowerpot = this.func_149929_e(p_149690_1_, p_149690_2_, p_149690_3_, p_149690_4_); + + if (tileentityflowerpot != null && tileentityflowerpot.getFlowerPotItem() != null) + { + this.dropBlockAsItem(p_149690_1_, p_149690_2_, p_149690_3_, p_149690_4_, new ItemStack(tileentityflowerpot.getFlowerPotItem(), 1, tileentityflowerpot.getFlowerPotData())); + } + } + + public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) + { + TileEntityFlowerPot tileentityflowerpot = this.func_149929_e(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_); + + if (tileentityflowerpot != null && tileentityflowerpot.getFlowerPotItem() != null) + { + this.dropBlockAsItem(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, new ItemStack(tileentityflowerpot.getFlowerPotItem(), 1, tileentityflowerpot.getFlowerPotData())); + } + + super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_); + } + + public void onBlockHarvested(World p_149681_1_, int p_149681_2_, int p_149681_3_, int p_149681_4_, int p_149681_5_, EntityPlayer p_149681_6_) + { + super.onBlockHarvested(p_149681_1_, p_149681_2_, p_149681_3_, p_149681_4_, p_149681_5_, p_149681_6_); + + if (p_149681_6_.capabilities.isCreativeMode) + { + TileEntityFlowerPot tileentityflowerpot = this.func_149929_e(p_149681_1_, p_149681_2_, p_149681_3_, p_149681_4_); + + if (tileentityflowerpot != null) + { + tileentityflowerpot.func_145964_a(Item.getItemById(0), 0); + } + } + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return Items.flower_pot; + } + + private TileEntityFlowerPot func_149929_e(World p_149929_1_, int p_149929_2_, int p_149929_3_, int p_149929_4_) + { + TileEntity tileentity = p_149929_1_.getTileEntity(p_149929_2_, p_149929_3_, p_149929_4_); + return tileentity != null && tileentity instanceof TileEntityFlowerPot ? (TileEntityFlowerPot)tileentity : null; + } + + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) + { + Object object = null; + byte b0 = 0; + + switch (p_149915_2_) + { + case 1: + object = Blocks.red_flower; + b0 = 0; + break; + case 2: + object = Blocks.yellow_flower; + break; + case 3: + object = Blocks.sapling; + b0 = 0; + break; + case 4: + object = Blocks.sapling; + b0 = 1; + break; + case 5: + object = Blocks.sapling; + b0 = 2; + break; + case 6: + object = Blocks.sapling; + b0 = 3; + break; + case 7: + object = Blocks.red_mushroom; + break; + case 8: + object = Blocks.brown_mushroom; + break; + case 9: + object = Blocks.cactus; + break; + case 10: + object = Blocks.deadbush; + break; + case 11: + object = Blocks.tallgrass; + b0 = 2; + break; + case 12: + object = Blocks.sapling; + b0 = 4; + break; + case 13: + object = Blocks.sapling; + b0 = 5; + } + + return new TileEntityFlowerPot(Item.getItemFromBlock((Block)object), b0); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockFurnace.java b/src/main/java/net/minecraft/block/BlockFurnace.java new file mode 100644 index 0000000..0f203d3 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockFurnace.java @@ -0,0 +1,279 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityFurnace; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class BlockFurnace extends BlockContainer +{ + private final Random field_149933_a = new Random(); + private final boolean field_149932_b; + private static boolean field_149934_M; + @SideOnly(Side.CLIENT) + private IIcon field_149935_N; + @SideOnly(Side.CLIENT) + private IIcon field_149936_O; + private static final String __OBFID = "CL_00000248"; + + protected BlockFurnace(boolean p_i45407_1_) + { + super(Material.rock); + this.field_149932_b = p_i45407_1_; + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return Item.getItemFromBlock(Blocks.furnace); + } + + public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_) + { + super.onBlockAdded(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_); + this.func_149930_e(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_); + } + + private void func_149930_e(World p_149930_1_, int p_149930_2_, int p_149930_3_, int p_149930_4_) + { + if (!p_149930_1_.isRemote) + { + Block block = p_149930_1_.getBlock(p_149930_2_, p_149930_3_, p_149930_4_ - 1); + Block block1 = p_149930_1_.getBlock(p_149930_2_, p_149930_3_, p_149930_4_ + 1); + Block block2 = p_149930_1_.getBlock(p_149930_2_ - 1, p_149930_3_, p_149930_4_); + Block block3 = p_149930_1_.getBlock(p_149930_2_ + 1, p_149930_3_, p_149930_4_); + byte b0 = 3; + + if (block.func_149730_j() && !block1.func_149730_j()) + { + b0 = 3; + } + + if (block1.func_149730_j() && !block.func_149730_j()) + { + b0 = 2; + } + + if (block2.func_149730_j() && !block3.func_149730_j()) + { + b0 = 5; + } + + if (block3.func_149730_j() && !block2.func_149730_j()) + { + b0 = 4; + } + + p_149930_1_.setBlockMetadataWithNotify(p_149930_2_, p_149930_3_, p_149930_4_, b0, 2); + } + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return p_149691_1_ == 1 ? this.field_149935_N : (p_149691_1_ == 0 ? this.field_149935_N : (p_149691_1_ != p_149691_2_ ? this.blockIcon : this.field_149936_O)); + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.blockIcon = p_149651_1_.registerIcon("furnace_side"); + this.field_149936_O = p_149651_1_.registerIcon(this.field_149932_b ? "furnace_front_on" : "furnace_front_off"); + this.field_149935_N = p_149651_1_.registerIcon("furnace_top"); + } + + public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) + { + if (p_149727_1_.isRemote) + { + return true; + } + else + { + TileEntityFurnace tileentityfurnace = (TileEntityFurnace)p_149727_1_.getTileEntity(p_149727_2_, p_149727_3_, p_149727_4_); + + if (tileentityfurnace != null) + { + p_149727_5_.func_146101_a(tileentityfurnace); + } + + return true; + } + } + + public static void updateFurnaceBlockState(boolean p_149931_0_, World p_149931_1_, int p_149931_2_, int p_149931_3_, int p_149931_4_) + { + int l = p_149931_1_.getBlockMetadata(p_149931_2_, p_149931_3_, p_149931_4_); + TileEntity tileentity = p_149931_1_.getTileEntity(p_149931_2_, p_149931_3_, p_149931_4_); + field_149934_M = true; + + if (p_149931_0_) + { + p_149931_1_.setBlock(p_149931_2_, p_149931_3_, p_149931_4_, Blocks.lit_furnace); + } + else + { + p_149931_1_.setBlock(p_149931_2_, p_149931_3_, p_149931_4_, Blocks.furnace); + } + + field_149934_M = false; + p_149931_1_.setBlockMetadataWithNotify(p_149931_2_, p_149931_3_, p_149931_4_, l, 2); + + if (tileentity != null) + { + tileentity.validate(); + p_149931_1_.setTileEntity(p_149931_2_, p_149931_3_, p_149931_4_, tileentity); + } + } + + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) + { + return new TileEntityFurnace(); + } + + public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_) + { + int l = MathHelper.floor_double((double)(p_149689_5_.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + + if (l == 0) + { + p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, 2, 2); + } + + if (l == 1) + { + p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, 5, 2); + } + + if (l == 2) + { + p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, 3, 2); + } + + if (l == 3) + { + p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, 4, 2); + } + + if (p_149689_6_.hasDisplayName()) + { + ((TileEntityFurnace)p_149689_1_.getTileEntity(p_149689_2_, p_149689_3_, p_149689_4_)).func_145951_a(p_149689_6_.getDisplayName()); + } + } + + public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) + { + if (!field_149934_M) + { + TileEntityFurnace tileentityfurnace = (TileEntityFurnace)p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_); + + if (tileentityfurnace != null) + { + for (int i1 = 0; i1 < tileentityfurnace.getSizeInventory(); ++i1) + { + ItemStack itemstack = tileentityfurnace.getStackInSlot(i1); + + if (itemstack != null) + { + float f = this.field_149933_a.nextFloat() * 0.8F + 0.1F; + float f1 = this.field_149933_a.nextFloat() * 0.8F + 0.1F; + float f2 = this.field_149933_a.nextFloat() * 0.8F + 0.1F; + + while (itemstack.stackSize > 0) + { + int j1 = this.field_149933_a.nextInt(21) + 10; + + if (j1 > itemstack.stackSize) + { + j1 = itemstack.stackSize; + } + + itemstack.stackSize -= j1; + EntityItem entityitem = new EntityItem(p_149749_1_, (double)((float)p_149749_2_ + f), (double)((float)p_149749_3_ + f1), (double)((float)p_149749_4_ + f2), new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage())); + + if (itemstack.hasTagCompound()) + { + entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); + } + + float f3 = 0.05F; + entityitem.motionX = (double)((float)this.field_149933_a.nextGaussian() * f3); + entityitem.motionY = (double)((float)this.field_149933_a.nextGaussian() * f3 + 0.2F); + entityitem.motionZ = (double)((float)this.field_149933_a.nextGaussian() * f3); + p_149749_1_.spawnEntityInWorld(entityitem); + } + } + } + + p_149749_1_.func_147453_f(p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_); + } + } + + super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_); + } + + @SideOnly(Side.CLIENT) + public void randomDisplayTick(World p_149734_1_, int p_149734_2_, int p_149734_3_, int p_149734_4_, Random p_149734_5_) + { + if (this.field_149932_b) + { + int l = p_149734_1_.getBlockMetadata(p_149734_2_, p_149734_3_, p_149734_4_); + float f = (float)p_149734_2_ + 0.5F; + float f1 = (float)p_149734_3_ + 0.0F + p_149734_5_.nextFloat() * 6.0F / 16.0F; + float f2 = (float)p_149734_4_ + 0.5F; + float f3 = 0.52F; + float f4 = p_149734_5_.nextFloat() * 0.6F - 0.3F; + + if (l == 4) + { + p_149734_1_.spawnParticle("smoke", (double)(f - f3), (double)f1, (double)(f2 + f4), 0.0D, 0.0D, 0.0D); + p_149734_1_.spawnParticle("flame", (double)(f - f3), (double)f1, (double)(f2 + f4), 0.0D, 0.0D, 0.0D); + } + else if (l == 5) + { + p_149734_1_.spawnParticle("smoke", (double)(f + f3), (double)f1, (double)(f2 + f4), 0.0D, 0.0D, 0.0D); + p_149734_1_.spawnParticle("flame", (double)(f + f3), (double)f1, (double)(f2 + f4), 0.0D, 0.0D, 0.0D); + } + else if (l == 2) + { + p_149734_1_.spawnParticle("smoke", (double)(f + f4), (double)f1, (double)(f2 - f3), 0.0D, 0.0D, 0.0D); + p_149734_1_.spawnParticle("flame", (double)(f + f4), (double)f1, (double)(f2 - f3), 0.0D, 0.0D, 0.0D); + } + else if (l == 3) + { + p_149734_1_.spawnParticle("smoke", (double)(f + f4), (double)f1, (double)(f2 + f3), 0.0D, 0.0D, 0.0D); + p_149734_1_.spawnParticle("flame", (double)(f + f4), (double)f1, (double)(f2 + f3), 0.0D, 0.0D, 0.0D); + } + } + } + + public boolean hasComparatorInputOverride() + { + return true; + } + + public int getComparatorInputOverride(World p_149736_1_, int p_149736_2_, int p_149736_3_, int p_149736_4_, int p_149736_5_) + { + return Container.calcRedstoneFromInventory((IInventory)p_149736_1_.getTileEntity(p_149736_2_, p_149736_3_, p_149736_4_)); + } + + @SideOnly(Side.CLIENT) + public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) + { + return Item.getItemFromBlock(Blocks.furnace); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockGlass.java b/src/main/java/net/minecraft/block/BlockGlass.java new file mode 100644 index 0000000..6b09bb9 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockGlass.java @@ -0,0 +1,39 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; + +public class BlockGlass extends BlockBreakable +{ + private static final String __OBFID = "CL_00000249"; + + public BlockGlass(Material p_i45408_1_, boolean p_i45408_2_) + { + super("glass", p_i45408_1_, p_i45408_2_); + this.setCreativeTab(CreativeTabs.tabBlock); + } + + public int quantityDropped(Random p_149745_1_) + { + return 0; + } + + @SideOnly(Side.CLIENT) + public int getRenderBlockPass() + { + return 0; + } + + public boolean renderAsNormalBlock() + { + return false; + } + + protected boolean canSilkHarvest() + { + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockGlowstone.java b/src/main/java/net/minecraft/block/BlockGlowstone.java new file mode 100644 index 0000000..38a8bf1 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockGlowstone.java @@ -0,0 +1,40 @@ +package net.minecraft.block; + +import java.util.Random; +import net.minecraft.block.material.MapColor; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.util.MathHelper; + +public class BlockGlowstone extends Block +{ + private static final String __OBFID = "CL_00000250"; + + public BlockGlowstone(Material p_i45409_1_) + { + super(p_i45409_1_); + this.setCreativeTab(CreativeTabs.tabBlock); + } + + public int quantityDroppedWithBonus(int p_149679_1_, Random p_149679_2_) + { + return MathHelper.clamp_int(this.quantityDropped(p_149679_2_) + p_149679_2_.nextInt(p_149679_1_ + 1), 1, 4); + } + + public int quantityDropped(Random p_149745_1_) + { + return 2 + p_149745_1_.nextInt(3); + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return Items.glowstone_dust; + } + + public MapColor getMapColor(int p_149728_1_) + { + return MapColor.sandColor; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockGrass.java b/src/main/java/net/minecraft/block/BlockGrass.java new file mode 100644 index 0000000..9cbfb1c --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockGrass.java @@ -0,0 +1,196 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.util.IIcon; +import net.minecraft.world.ColorizerGrass; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class BlockGrass extends Block implements IGrowable +{ + private static final Logger logger = LogManager.getLogger(); + @SideOnly(Side.CLIENT) + private IIcon field_149991_b; + @SideOnly(Side.CLIENT) + private IIcon field_149993_M; + @SideOnly(Side.CLIENT) + private IIcon field_149994_N; + private static final String __OBFID = "CL_00000251"; + + protected BlockGrass() + { + super(Material.grass); + this.setTickRandomly(true); + this.setCreativeTab(CreativeTabs.tabBlock); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return p_149691_1_ == 1 ? this.field_149991_b : (p_149691_1_ == 0 ? Blocks.dirt.getBlockTextureFromSide(p_149691_1_) : this.blockIcon); + } + + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) + { + if (!p_149674_1_.isRemote) + { + if (p_149674_1_.getBlockLightValue(p_149674_2_, p_149674_3_ + 1, p_149674_4_) < 4 && p_149674_1_.getBlockLightOpacity(p_149674_2_, p_149674_3_ + 1, p_149674_4_) > 2) + { + p_149674_1_.setBlock(p_149674_2_, p_149674_3_, p_149674_4_, Blocks.dirt); + } + else if (p_149674_1_.getBlockLightValue(p_149674_2_, p_149674_3_ + 1, p_149674_4_) >= 9) + { + for (int l = 0; l < 4; ++l) + { + int i1 = p_149674_2_ + p_149674_5_.nextInt(3) - 1; + int j1 = p_149674_3_ + p_149674_5_.nextInt(5) - 3; + int k1 = p_149674_4_ + p_149674_5_.nextInt(3) - 1; + Block block = p_149674_1_.getBlock(i1, j1 + 1, k1); + + if (p_149674_1_.getBlock(i1, j1, k1) == Blocks.dirt && p_149674_1_.getBlockMetadata(i1, j1, k1) == 0 && p_149674_1_.getBlockLightValue(i1, j1 + 1, k1) >= 4 && p_149674_1_.getBlockLightOpacity(i1, j1 + 1, k1) <= 2) + { + p_149674_1_.setBlock(i1, j1, k1, Blocks.grass); + } + } + } + } + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return Blocks.dirt.getItemDropped(0, p_149650_2_, p_149650_3_); + } + + public boolean func_149851_a(World p_149851_1_, int p_149851_2_, int p_149851_3_, int p_149851_4_, boolean p_149851_5_) + { + return true; + } + + public boolean func_149852_a(World p_149852_1_, Random p_149852_2_, int p_149852_3_, int p_149852_4_, int p_149852_5_) + { + return true; + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess p_149673_1_, int p_149673_2_, int p_149673_3_, int p_149673_4_, int p_149673_5_) + { + if (p_149673_5_ == 1) + { + return this.field_149991_b; + } + else if (p_149673_5_ == 0) + { + return Blocks.dirt.getBlockTextureFromSide(p_149673_5_); + } + else + { + Material material = p_149673_1_.getBlock(p_149673_2_, p_149673_3_ + 1, p_149673_4_).getMaterial(); + return material != Material.snow && material != Material.craftedSnow ? this.blockIcon : this.field_149993_M; + } + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.blockIcon = p_149651_1_.registerIcon(this.getTextureName() + "_side"); + this.field_149991_b = p_149651_1_.registerIcon(this.getTextureName() + "_top"); + this.field_149993_M = p_149651_1_.registerIcon(this.getTextureName() + "_side_snowed"); + this.field_149994_N = p_149651_1_.registerIcon(this.getTextureName() + "_side_overlay"); + } + + @SideOnly(Side.CLIENT) + public int getBlockColor() + { + double d0 = 0.5D; + double d1 = 1.0D; + return ColorizerGrass.getGrassColor(d0, d1); + } + + @SideOnly(Side.CLIENT) + public int getRenderColor(int p_149741_1_) + { + return this.getBlockColor(); + } + + @SideOnly(Side.CLIENT) + public int colorMultiplier(IBlockAccess p_149720_1_, int p_149720_2_, int p_149720_3_, int p_149720_4_) + { + int l = 0; + int i1 = 0; + int j1 = 0; + + for (int k1 = -1; k1 <= 1; ++k1) + { + for (int l1 = -1; l1 <= 1; ++l1) + { + int i2 = p_149720_1_.getBiomeGenForCoords(p_149720_2_ + l1, p_149720_4_ + k1).getBiomeGrassColor(p_149720_2_ + l1, p_149720_3_, p_149720_4_ + k1); + l += (i2 & 16711680) >> 16; + i1 += (i2 & 65280) >> 8; + j1 += i2 & 255; + } + } + + return (l / 9 & 255) << 16 | (i1 / 9 & 255) << 8 | j1 / 9 & 255; + } + + @SideOnly(Side.CLIENT) + public static IIcon getIconSideOverlay() + { + return Blocks.grass.field_149994_N; + } + + public void func_149853_b(World p_149853_1_, Random p_149853_2_, int p_149853_3_, int p_149853_4_, int p_149853_5_) + { + int l = 0; + + while (l < 128) + { + int i1 = p_149853_3_; + int j1 = p_149853_4_ + 1; + int k1 = p_149853_5_; + int l1 = 0; + + while (true) + { + if (l1 < l / 16) + { + i1 += p_149853_2_.nextInt(3) - 1; + j1 += (p_149853_2_.nextInt(3) - 1) * p_149853_2_.nextInt(3) / 2; + k1 += p_149853_2_.nextInt(3) - 1; + + if (p_149853_1_.getBlock(i1, j1 - 1, k1) == Blocks.grass && !p_149853_1_.getBlock(i1, j1, k1).isNormalCube()) + { + ++l1; + continue; + } + } + else if (p_149853_1_.getBlock(i1, j1, k1).blockMaterial == Material.air) + { + if (p_149853_2_.nextInt(8) != 0) + { + if (Blocks.tallgrass.canBlockStay(p_149853_1_, i1, j1, k1)) + { + p_149853_1_.setBlock(i1, j1, k1, Blocks.tallgrass, 1, 3); + } + } + else + { + p_149853_1_.getBiomeGenForCoords(i1, k1).plantFlower(p_149853_1_, p_149853_2_, i1, j1, k1); + } + } + + ++l; + break; + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockGravel.java b/src/main/java/net/minecraft/block/BlockGravel.java new file mode 100644 index 0000000..2f6e97b --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockGravel.java @@ -0,0 +1,20 @@ +package net.minecraft.block; + +import java.util.Random; +import net.minecraft.init.Items; +import net.minecraft.item.Item; + +public class BlockGravel extends BlockFalling +{ + private static final String __OBFID = "CL_00000252"; + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + if (p_149650_3_ > 3) + { + p_149650_3_ = 3; + } + + return p_149650_2_.nextInt(10 - p_149650_3_ * 3) == 0 ? Items.flint : Item.getItemFromBlock(this); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockHardenedClay.java b/src/main/java/net/minecraft/block/BlockHardenedClay.java new file mode 100644 index 0000000..6883a54 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockHardenedClay.java @@ -0,0 +1,21 @@ +package net.minecraft.block; + +import net.minecraft.block.material.MapColor; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; + +public class BlockHardenedClay extends Block +{ + private static final String __OBFID = "CL_00000255"; + + public BlockHardenedClay() + { + super(Material.rock); + this.setCreativeTab(CreativeTabs.tabBlock); + } + + public MapColor getMapColor(int p_149728_1_) + { + return MapColor.adobeColor; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockHay.java b/src/main/java/net/minecraft/block/BlockHay.java new file mode 100644 index 0000000..eed465a --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockHay.java @@ -0,0 +1,32 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.util.IIcon; + +public class BlockHay extends BlockRotatedPillar +{ + private static final String __OBFID = "CL_00000256"; + + public BlockHay() + { + super(Material.grass); + this.setCreativeTab(CreativeTabs.tabBlock); + } + + @SideOnly(Side.CLIENT) + protected IIcon getSideIcon(int p_150163_1_) + { + return this.blockIcon; + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.field_150164_N = p_149651_1_.registerIcon(this.getTextureName() + "_top"); + this.blockIcon = p_149651_1_.registerIcon(this.getTextureName() + "_side"); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockHopper.java b/src/main/java/net/minecraft/block/BlockHopper.java new file mode 100644 index 0000000..0f73504 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockHopper.java @@ -0,0 +1,255 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.inventory.Container; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityHopper; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.Facing; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockHopper extends BlockContainer +{ + private final Random field_149922_a = new Random(); + @SideOnly(Side.CLIENT) + private IIcon field_149921_b; + @SideOnly(Side.CLIENT) + private IIcon field_149923_M; + @SideOnly(Side.CLIENT) + private IIcon field_149924_N; + private static final String __OBFID = "CL_00000257"; + + public BlockHopper() + { + super(Material.iron); + this.setCreativeTab(CreativeTabs.tabRedstone); + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + + public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + + public void addCollisionBoxesToList(World p_149743_1_, int p_149743_2_, int p_149743_3_, int p_149743_4_, AxisAlignedBB p_149743_5_, List p_149743_6_, Entity p_149743_7_) + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.625F, 1.0F); + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + float f = 0.125F; + this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F); + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f); + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F); + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + + public int onBlockPlaced(World p_149660_1_, int p_149660_2_, int p_149660_3_, int p_149660_4_, int p_149660_5_, float p_149660_6_, float p_149660_7_, float p_149660_8_, int p_149660_9_) + { + int j1 = Facing.oppositeSide[p_149660_5_]; + + if (j1 == 1) + { + j1 = 0; + } + + return j1; + } + + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) + { + return new TileEntityHopper(); + } + + public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_) + { + super.onBlockPlacedBy(p_149689_1_, p_149689_2_, p_149689_3_, p_149689_4_, p_149689_5_, p_149689_6_); + + if (p_149689_6_.hasDisplayName()) + { + TileEntityHopper tileentityhopper = func_149920_e(p_149689_1_, p_149689_2_, p_149689_3_, p_149689_4_); + tileentityhopper.func_145886_a(p_149689_6_.getDisplayName()); + } + } + + public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_) + { + super.onBlockAdded(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_); + this.func_149919_e(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_); + } + + public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) + { + if (p_149727_1_.isRemote) + { + return true; + } + else + { + TileEntityHopper tileentityhopper = func_149920_e(p_149727_1_, p_149727_2_, p_149727_3_, p_149727_4_); + + if (tileentityhopper != null) + { + p_149727_5_.func_146093_a(tileentityhopper); + } + + return true; + } + } + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) + { + this.func_149919_e(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_); + } + + private void func_149919_e(World p_149919_1_, int p_149919_2_, int p_149919_3_, int p_149919_4_) + { + int l = p_149919_1_.getBlockMetadata(p_149919_2_, p_149919_3_, p_149919_4_); + int i1 = getDirectionFromMetadata(l); + boolean flag = !p_149919_1_.isBlockIndirectlyGettingPowered(p_149919_2_, p_149919_3_, p_149919_4_); + boolean flag1 = func_149917_c(l); + + if (flag != flag1) + { + p_149919_1_.setBlockMetadataWithNotify(p_149919_2_, p_149919_3_, p_149919_4_, i1 | (flag ? 0 : 8), 4); + } + } + + public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) + { + TileEntityHopper tileentityhopper = (TileEntityHopper)p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_); + + if (tileentityhopper != null) + { + for (int i1 = 0; i1 < tileentityhopper.getSizeInventory(); ++i1) + { + ItemStack itemstack = tileentityhopper.getStackInSlot(i1); + + if (itemstack != null) + { + float f = this.field_149922_a.nextFloat() * 0.8F + 0.1F; + float f1 = this.field_149922_a.nextFloat() * 0.8F + 0.1F; + float f2 = this.field_149922_a.nextFloat() * 0.8F + 0.1F; + + while (itemstack.stackSize > 0) + { + int j1 = this.field_149922_a.nextInt(21) + 10; + + if (j1 > itemstack.stackSize) + { + j1 = itemstack.stackSize; + } + + itemstack.stackSize -= j1; + EntityItem entityitem = new EntityItem(p_149749_1_, (double)((float)p_149749_2_ + f), (double)((float)p_149749_3_ + f1), (double)((float)p_149749_4_ + f2), new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage())); + + if (itemstack.hasTagCompound()) + { + entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); + } + + float f3 = 0.05F; + entityitem.motionX = (double)((float)this.field_149922_a.nextGaussian() * f3); + entityitem.motionY = (double)((float)this.field_149922_a.nextGaussian() * f3 + 0.2F); + entityitem.motionZ = (double)((float)this.field_149922_a.nextGaussian() * f3); + p_149749_1_.spawnEntityInWorld(entityitem); + } + } + } + + p_149749_1_.func_147453_f(p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_); + } + + super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_); + } + + public int getRenderType() + { + return 38; + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public boolean isOpaqueCube() + { + return false; + } + + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) + { + return true; + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return p_149691_1_ == 1 ? this.field_149923_M : this.field_149921_b; + } + + public static int getDirectionFromMetadata(int p_149918_0_) + { + return p_149918_0_ & 7; + } + + public static boolean func_149917_c(int p_149917_0_) + { + return (p_149917_0_ & 8) != 8; + } + + public boolean hasComparatorInputOverride() + { + return true; + } + + public int getComparatorInputOverride(World p_149736_1_, int p_149736_2_, int p_149736_3_, int p_149736_4_, int p_149736_5_) + { + return Container.calcRedstoneFromInventory(func_149920_e(p_149736_1_, p_149736_2_, p_149736_3_, p_149736_4_)); + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.field_149921_b = p_149651_1_.registerIcon("hopper_outside"); + this.field_149923_M = p_149651_1_.registerIcon("hopper_top"); + this.field_149924_N = p_149651_1_.registerIcon("hopper_inside"); + } + + @SideOnly(Side.CLIENT) + public static IIcon getHopperIcon(String p_149916_0_) + { + return p_149916_0_.equals("hopper_outside") ? Blocks.hopper.field_149921_b : (p_149916_0_.equals("hopper_inside") ? Blocks.hopper.field_149924_N : null); + } + + public static TileEntityHopper func_149920_e(IBlockAccess p_149920_0_, int p_149920_1_, int p_149920_2_, int p_149920_3_) + { + return (TileEntityHopper)p_149920_0_.getTileEntity(p_149920_1_, p_149920_2_, p_149920_3_); + } + + @SideOnly(Side.CLIENT) + public String getItemIconName() + { + return "hopper"; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockHugeMushroom.java b/src/main/java/net/minecraft/block/BlockHugeMushroom.java new file mode 100644 index 0000000..29ac38f --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockHugeMushroom.java @@ -0,0 +1,73 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +public class BlockHugeMushroom extends Block +{ + private static final String[] field_149793_a = new String[] {"skin_brown", "skin_red"}; + private final int field_149792_b; + @SideOnly(Side.CLIENT) + private IIcon[] field_149794_M; + @SideOnly(Side.CLIENT) + private IIcon field_149795_N; + @SideOnly(Side.CLIENT) + private IIcon field_149796_O; + private static final String __OBFID = "CL_00000258"; + + public BlockHugeMushroom(Material p_i45412_1_, int p_i45412_2_) + { + super(p_i45412_1_); + this.field_149792_b = p_i45412_2_; + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return p_149691_2_ == 10 && p_149691_1_ > 1 ? this.field_149795_N : (p_149691_2_ >= 1 && p_149691_2_ <= 9 && p_149691_1_ == 1 ? this.field_149794_M[this.field_149792_b] : (p_149691_2_ >= 1 && p_149691_2_ <= 3 && p_149691_1_ == 2 ? this.field_149794_M[this.field_149792_b] : (p_149691_2_ >= 7 && p_149691_2_ <= 9 && p_149691_1_ == 3 ? this.field_149794_M[this.field_149792_b] : ((p_149691_2_ == 1 || p_149691_2_ == 4 || p_149691_2_ == 7) && p_149691_1_ == 4 ? this.field_149794_M[this.field_149792_b] : ((p_149691_2_ == 3 || p_149691_2_ == 6 || p_149691_2_ == 9) && p_149691_1_ == 5 ? this.field_149794_M[this.field_149792_b] : (p_149691_2_ == 14 ? this.field_149794_M[this.field_149792_b] : (p_149691_2_ == 15 ? this.field_149795_N : this.field_149796_O))))))); + } + + public int quantityDropped(Random p_149745_1_) + { + int i = p_149745_1_.nextInt(10) - 7; + + if (i < 0) + { + i = 0; + } + + return i; + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return Item.getItemById(Block.getIdFromBlock(Blocks.brown_mushroom) + this.field_149792_b); + } + + @SideOnly(Side.CLIENT) + public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) + { + return Item.getItemById(Block.getIdFromBlock(Blocks.brown_mushroom) + this.field_149792_b); + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.field_149794_M = new IIcon[field_149793_a.length]; + + for (int i = 0; i < this.field_149794_M.length; ++i) + { + this.field_149794_M[i] = p_149651_1_.registerIcon(this.getTextureName() + "_" + field_149793_a[i]); + } + + this.field_149796_O = p_149651_1_.registerIcon(this.getTextureName() + "_" + "inside"); + this.field_149795_N = p_149651_1_.registerIcon(this.getTextureName() + "_" + "skin_stem"); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockIce.java b/src/main/java/net/minecraft/block/BlockIce.java new file mode 100644 index 0000000..0f40507 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockIce.java @@ -0,0 +1,98 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.stats.StatList; +import net.minecraft.world.EnumSkyBlock; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockIce extends BlockBreakable +{ + private static final String __OBFID = "CL_00000259"; + + public BlockIce() + { + super("ice", Material.ice, false); + this.slipperiness = 0.98F; + this.setTickRandomly(true); + this.setCreativeTab(CreativeTabs.tabBlock); + } + + @SideOnly(Side.CLIENT) + public int getRenderBlockPass() + { + return 1; + } + + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) + { + return super.shouldSideBeRendered(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, 1 - p_149646_5_); + } + + public void harvestBlock(World p_149636_1_, EntityPlayer p_149636_2_, int p_149636_3_, int p_149636_4_, int p_149636_5_, int p_149636_6_) + { + p_149636_2_.addStat(StatList.mineBlockStatArray[Block.getIdFromBlock(this)], 1); + p_149636_2_.addExhaustion(0.025F); + + if (this.canSilkHarvest(p_149636_1_, p_149636_2_, p_149636_3_, p_149636_4_, p_149636_5_, p_149636_6_) && EnchantmentHelper.getSilkTouchModifier(p_149636_2_)) + { + ItemStack itemstack = this.createStackedBlock(p_149636_6_); + + if (itemstack != null) + { + this.dropBlockAsItem(p_149636_1_, p_149636_3_, p_149636_4_, p_149636_5_, itemstack); + } + } + else + { + if (p_149636_1_.provider.isHellWorld) + { + p_149636_1_.setBlockToAir(p_149636_3_, p_149636_4_, p_149636_5_); + return; + } + + int i1 = EnchantmentHelper.getFortuneModifier(p_149636_2_); + this.dropBlockAsItem(p_149636_1_, p_149636_3_, p_149636_4_, p_149636_5_, p_149636_6_, i1); + Material material = p_149636_1_.getBlock(p_149636_3_, p_149636_4_ - 1, p_149636_5_).getMaterial(); + + if (material.blocksMovement() || material.isLiquid()) + { + p_149636_1_.setBlock(p_149636_3_, p_149636_4_, p_149636_5_, Blocks.flowing_water); + } + } + } + + public int quantityDropped(Random p_149745_1_) + { + return 0; + } + + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) + { + if (p_149674_1_.getSavedLightValue(EnumSkyBlock.Block, p_149674_2_, p_149674_3_, p_149674_4_) > 11 - this.getLightOpacity()) + { + if (p_149674_1_.provider.isHellWorld) + { + p_149674_1_.setBlockToAir(p_149674_2_, p_149674_3_, p_149674_4_); + return; + } + + this.dropBlockAsItem(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_), 0); + p_149674_1_.setBlock(p_149674_2_, p_149674_3_, p_149674_4_, Blocks.water); + } + } + + public int getMobilityFlag() + { + return 0; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockJukebox.java b/src/main/java/net/minecraft/block/BlockJukebox.java new file mode 100644 index 0000000..5eafc7a --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockJukebox.java @@ -0,0 +1,170 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +public class BlockJukebox extends BlockContainer +{ + @SideOnly(Side.CLIENT) + private IIcon field_149927_a; + private static final String __OBFID = "CL_00000260"; + + protected BlockJukebox() + { + super(Material.wood); + this.setCreativeTab(CreativeTabs.tabDecorations); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return p_149691_1_ == 1 ? this.field_149927_a : this.blockIcon; + } + + public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) + { + if (p_149727_1_.getBlockMetadata(p_149727_2_, p_149727_3_, p_149727_4_) == 0) + { + return false; + } + else + { + this.func_149925_e(p_149727_1_, p_149727_2_, p_149727_3_, p_149727_4_); + return true; + } + } + + public void func_149926_b(World p_149926_1_, int p_149926_2_, int p_149926_3_, int p_149926_4_, ItemStack p_149926_5_) + { + if (!p_149926_1_.isRemote) + { + BlockJukebox.TileEntityJukebox tileentityjukebox = (BlockJukebox.TileEntityJukebox)p_149926_1_.getTileEntity(p_149926_2_, p_149926_3_, p_149926_4_); + + if (tileentityjukebox != null) + { + tileentityjukebox.func_145857_a(p_149926_5_.copy()); + p_149926_1_.setBlockMetadataWithNotify(p_149926_2_, p_149926_3_, p_149926_4_, 1, 2); + } + } + } + + public void func_149925_e(World p_149925_1_, int p_149925_2_, int p_149925_3_, int p_149925_4_) + { + if (!p_149925_1_.isRemote) + { + BlockJukebox.TileEntityJukebox tileentityjukebox = (BlockJukebox.TileEntityJukebox)p_149925_1_.getTileEntity(p_149925_2_, p_149925_3_, p_149925_4_); + + if (tileentityjukebox != null) + { + ItemStack itemstack = tileentityjukebox.func_145856_a(); + + if (itemstack != null) + { + p_149925_1_.playAuxSFX(1005, p_149925_2_, p_149925_3_, p_149925_4_, 0); + p_149925_1_.playRecord((String)null, p_149925_2_, p_149925_3_, p_149925_4_); + tileentityjukebox.func_145857_a((ItemStack)null); + p_149925_1_.setBlockMetadataWithNotify(p_149925_2_, p_149925_3_, p_149925_4_, 0, 2); + float f = 0.7F; + double d0 = (double)(p_149925_1_.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D; + double d1 = (double)(p_149925_1_.rand.nextFloat() * f) + (double)(1.0F - f) * 0.2D + 0.6D; + double d2 = (double)(p_149925_1_.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D; + ItemStack itemstack1 = itemstack.copy(); + EntityItem entityitem = new EntityItem(p_149925_1_, (double)p_149925_2_ + d0, (double)p_149925_3_ + d1, (double)p_149925_4_ + d2, itemstack1); + entityitem.delayBeforeCanPickup = 10; + p_149925_1_.spawnEntityInWorld(entityitem); + } + } + } + } + + public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) + { + this.func_149925_e(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_); + super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_); + } + + public void dropBlockAsItemWithChance(World p_149690_1_, int p_149690_2_, int p_149690_3_, int p_149690_4_, int p_149690_5_, float p_149690_6_, int p_149690_7_) + { + if (!p_149690_1_.isRemote) + { + super.dropBlockAsItemWithChance(p_149690_1_, p_149690_2_, p_149690_3_, p_149690_4_, p_149690_5_, p_149690_6_, 0); + } + } + + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) + { + return new BlockJukebox.TileEntityJukebox(); + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.blockIcon = p_149651_1_.registerIcon(this.getTextureName() + "_side"); + this.field_149927_a = p_149651_1_.registerIcon(this.getTextureName() + "_top"); + } + + public boolean hasComparatorInputOverride() + { + return true; + } + + public int getComparatorInputOverride(World p_149736_1_, int p_149736_2_, int p_149736_3_, int p_149736_4_, int p_149736_5_) + { + ItemStack itemstack = ((BlockJukebox.TileEntityJukebox)p_149736_1_.getTileEntity(p_149736_2_, p_149736_3_, p_149736_4_)).func_145856_a(); + return itemstack == null ? 0 : Item.getIdFromItem(itemstack.getItem()) + 1 - Item.getIdFromItem(Items.record_13); + } + + public static class TileEntityJukebox extends TileEntity + { + private ItemStack field_145858_a; + private static final String __OBFID = "CL_00000261"; + + public void readFromNBT(NBTTagCompound p_145839_1_) + { + super.readFromNBT(p_145839_1_); + + if (p_145839_1_.hasKey("RecordItem", 10)) + { + this.func_145857_a(ItemStack.loadItemStackFromNBT(p_145839_1_.getCompoundTag("RecordItem"))); + } + else if (p_145839_1_.getInteger("Record") > 0) + { + this.func_145857_a(new ItemStack(Item.getItemById(p_145839_1_.getInteger("Record")), 1, 0)); + } + } + + public void writeToNBT(NBTTagCompound p_145841_1_) + { + super.writeToNBT(p_145841_1_); + + if (this.func_145856_a() != null) + { + p_145841_1_.setTag("RecordItem", this.func_145856_a().writeToNBT(new NBTTagCompound())); + p_145841_1_.setInteger("Record", Item.getIdFromItem(this.func_145856_a().getItem())); + } + } + + public ItemStack func_145856_a() + { + return this.field_145858_a; + } + + public void func_145857_a(ItemStack p_145857_1_) + { + this.field_145858_a = p_145857_1_; + this.markDirty(); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockLadder.java b/src/main/java/net/minecraft/block/BlockLadder.java new file mode 100644 index 0000000..1c30098 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockLadder.java @@ -0,0 +1,163 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import net.minecraftforge.common.util.ForgeDirection; +import static net.minecraftforge.common.util.ForgeDirection.*; + +public class BlockLadder extends Block +{ + private static final String __OBFID = "CL_00000262"; + + protected BlockLadder() + { + super(Material.circuits); + this.setCreativeTab(CreativeTabs.tabDecorations); + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) + { + this.setBlockBoundsBasedOnState(p_149668_1_, p_149668_2_, p_149668_3_, p_149668_4_); + return super.getCollisionBoundingBoxFromPool(p_149668_1_, p_149668_2_, p_149668_3_, p_149668_4_); + } + + public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) + { + this.func_149797_b(p_149719_1_.getBlockMetadata(p_149719_2_, p_149719_3_, p_149719_4_)); + } + + @SideOnly(Side.CLIENT) + public AxisAlignedBB getSelectedBoundingBoxFromPool(World p_149633_1_, int p_149633_2_, int p_149633_3_, int p_149633_4_) + { + this.setBlockBoundsBasedOnState(p_149633_1_, p_149633_2_, p_149633_3_, p_149633_4_); + return super.getSelectedBoundingBoxFromPool(p_149633_1_, p_149633_2_, p_149633_3_, p_149633_4_); + } + + public void func_149797_b(int p_149797_1_) + { + float f = 0.125F; + + if (p_149797_1_ == 2) + { + this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F); + } + + if (p_149797_1_ == 3) + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f); + } + + if (p_149797_1_ == 4) + { + this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + + if (p_149797_1_ == 5) + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F); + } + } + + public boolean isOpaqueCube() + { + return false; + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public int getRenderType() + { + return 8; + } + + public boolean canPlaceBlockAt(World p_149742_1_, int p_149742_2_, int p_149742_3_, int p_149742_4_) + { + return p_149742_1_.isSideSolid(p_149742_2_ - 1, p_149742_3_, p_149742_4_, EAST ) || + p_149742_1_.isSideSolid(p_149742_2_ + 1, p_149742_3_, p_149742_4_, WEST ) || + p_149742_1_.isSideSolid(p_149742_2_, p_149742_3_, p_149742_4_ - 1, SOUTH) || + p_149742_1_.isSideSolid(p_149742_2_, p_149742_3_, p_149742_4_ + 1, NORTH); + } + + public int onBlockPlaced(World p_149660_1_, int p_149660_2_, int p_149660_3_, int p_149660_4_, int p_149660_5_, float p_149660_6_, float p_149660_7_, float p_149660_8_, int p_149660_9_) + { + int j1 = p_149660_9_; + + if ((p_149660_9_ == 0 || p_149660_5_ == 2) && p_149660_1_.isSideSolid(p_149660_2_, p_149660_3_, p_149660_4_ + 1, NORTH)) + { + j1 = 2; + } + + if ((j1 == 0 || p_149660_5_ == 3) && p_149660_1_.isSideSolid(p_149660_2_, p_149660_3_, p_149660_4_ - 1, SOUTH)) + { + j1 = 3; + } + + if ((j1 == 0 || p_149660_5_ == 4) && p_149660_1_.isSideSolid(p_149660_2_ + 1, p_149660_3_, p_149660_4_, WEST)) + { + j1 = 4; + } + + if ((j1 == 0 || p_149660_5_ == 5) && p_149660_1_.isSideSolid(p_149660_2_ - 1, p_149660_3_, p_149660_4_, EAST)) + { + j1 = 5; + } + + return j1; + } + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) + { + int l = p_149695_1_.getBlockMetadata(p_149695_2_, p_149695_3_, p_149695_4_); + boolean flag = false; + + if (l == 2 && p_149695_1_.isSideSolid(p_149695_2_, p_149695_3_, p_149695_4_ + 1, NORTH)) + { + flag = true; + } + + if (l == 3 && p_149695_1_.isSideSolid(p_149695_2_, p_149695_3_, p_149695_4_ - 1, SOUTH)) + { + flag = true; + } + + if (l == 4 && p_149695_1_.isSideSolid(p_149695_2_ + 1, p_149695_3_, p_149695_4_, WEST)) + { + flag = true; + } + + if (l == 5 && p_149695_1_.isSideSolid(p_149695_2_ - 1, p_149695_3_, p_149695_4_, EAST)) + { + flag = true; + } + + if (!flag) + { + this.dropBlockAsItem(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, l, 0); + p_149695_1_.setBlockToAir(p_149695_2_, p_149695_3_, p_149695_4_); + } + + super.onNeighborBlockChange(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, p_149695_5_); + } + + public int quantityDropped(Random p_149745_1_) + { + return 1; + } + + @Override + public boolean isLadder(IBlockAccess world, int x, int y, int z, EntityLivingBase entity) + { + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockLeaves.java b/src/main/java/net/minecraft/block/BlockLeaves.java new file mode 100644 index 0000000..fdf36a1 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockLeaves.java @@ -0,0 +1,351 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.stats.StatList; +import net.minecraft.util.IIcon; +import net.minecraft.world.ColorizerFoliage; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.IShearable; + +public abstract class BlockLeaves extends BlockLeavesBase implements IShearable +{ + int[] field_150128_a; + @SideOnly(Side.CLIENT) + protected int field_150127_b; + protected IIcon[][] field_150129_M = new IIcon[2][]; + private static final String __OBFID = "CL_00000263"; + + public BlockLeaves() + { + super(Material.leaves, false); + this.setTickRandomly(true); + this.setCreativeTab(CreativeTabs.tabDecorations); + this.setHardness(0.2F); + this.setLightOpacity(1); + this.setStepSound(soundTypeGrass); + } + + @SideOnly(Side.CLIENT) + public int getBlockColor() + { + double d0 = 0.5D; + double d1 = 1.0D; + return ColorizerFoliage.getFoliageColor(d0, d1); + } + + @SideOnly(Side.CLIENT) + public int getRenderColor(int p_149741_1_) + { + return ColorizerFoliage.getFoliageColorBasic(); + } + + @SideOnly(Side.CLIENT) + public int colorMultiplier(IBlockAccess p_149720_1_, int p_149720_2_, int p_149720_3_, int p_149720_4_) + { + int l = 0; + int i1 = 0; + int j1 = 0; + + for (int k1 = -1; k1 <= 1; ++k1) + { + for (int l1 = -1; l1 <= 1; ++l1) + { + int i2 = p_149720_1_.getBiomeGenForCoords(p_149720_2_ + l1, p_149720_4_ + k1).getBiomeFoliageColor(p_149720_2_ + l1, p_149720_3_, p_149720_4_ + k1); + l += (i2 & 16711680) >> 16; + i1 += (i2 & 65280) >> 8; + j1 += i2 & 255; + } + } + + return (l / 9 & 255) << 16 | (i1 / 9 & 255) << 8 | j1 / 9 & 255; + } + + public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) + { + byte b0 = 1; + int i1 = b0 + 1; + + if (p_149749_1_.checkChunksExist(p_149749_2_ - i1, p_149749_3_ - i1, p_149749_4_ - i1, p_149749_2_ + i1, p_149749_3_ + i1, p_149749_4_ + i1)) + { + for (int j1 = -b0; j1 <= b0; ++j1) + { + for (int k1 = -b0; k1 <= b0; ++k1) + { + for (int l1 = -b0; l1 <= b0; ++l1) + { + Block block = p_149749_1_.getBlock(p_149749_2_ + j1, p_149749_3_ + k1, p_149749_4_ + l1); + if (block.isLeaves(p_149749_1_, p_149749_2_ + j1, p_149749_3_ + k1, p_149749_4_ + l1)) + { + block.beginLeavesDecay(p_149749_1_, p_149749_2_ + j1, p_149749_3_ + k1, p_149749_4_ + l1); + } + } + } + } + } + } + + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) + { + if (!p_149674_1_.isRemote) + { + int l = p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_); + + if ((l & 8) != 0 && (l & 4) == 0) + { + byte b0 = 4; + int i1 = b0 + 1; + byte b1 = 32; + int j1 = b1 * b1; + int k1 = b1 / 2; + + if (this.field_150128_a == null) + { + this.field_150128_a = new int[b1 * b1 * b1]; + } + + int l1; + + if (p_149674_1_.checkChunksExist(p_149674_2_ - i1, p_149674_3_ - i1, p_149674_4_ - i1, p_149674_2_ + i1, p_149674_3_ + i1, p_149674_4_ + i1)) + { + int i2; + int j2; + + for (l1 = -b0; l1 <= b0; ++l1) + { + for (i2 = -b0; i2 <= b0; ++i2) + { + for (j2 = -b0; j2 <= b0; ++j2) + { + Block block = p_149674_1_.getBlock(p_149674_2_ + l1, p_149674_3_ + i2, p_149674_4_ + j2); + + if (!block.canSustainLeaves(p_149674_1_, p_149674_2_ + l1, p_149674_3_ + i2, p_149674_4_ + j2)) + { + if (block.isLeaves(p_149674_1_, p_149674_2_ + l1, p_149674_3_ + i2, p_149674_4_ + j2)) + { + this.field_150128_a[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = -2; + } + else + { + this.field_150128_a[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = -1; + } + } + else + { + this.field_150128_a[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = 0; + } + } + } + } + + for (l1 = 1; l1 <= 4; ++l1) + { + for (i2 = -b0; i2 <= b0; ++i2) + { + for (j2 = -b0; j2 <= b0; ++j2) + { + for (int k2 = -b0; k2 <= b0; ++k2) + { + if (this.field_150128_a[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1] == l1 - 1) + { + if (this.field_150128_a[(i2 + k1 - 1) * j1 + (j2 + k1) * b1 + k2 + k1] == -2) + { + this.field_150128_a[(i2 + k1 - 1) * j1 + (j2 + k1) * b1 + k2 + k1] = l1; + } + + if (this.field_150128_a[(i2 + k1 + 1) * j1 + (j2 + k1) * b1 + k2 + k1] == -2) + { + this.field_150128_a[(i2 + k1 + 1) * j1 + (j2 + k1) * b1 + k2 + k1] = l1; + } + + if (this.field_150128_a[(i2 + k1) * j1 + (j2 + k1 - 1) * b1 + k2 + k1] == -2) + { + this.field_150128_a[(i2 + k1) * j1 + (j2 + k1 - 1) * b1 + k2 + k1] = l1; + } + + if (this.field_150128_a[(i2 + k1) * j1 + (j2 + k1 + 1) * b1 + k2 + k1] == -2) + { + this.field_150128_a[(i2 + k1) * j1 + (j2 + k1 + 1) * b1 + k2 + k1] = l1; + } + + if (this.field_150128_a[(i2 + k1) * j1 + (j2 + k1) * b1 + (k2 + k1 - 1)] == -2) + { + this.field_150128_a[(i2 + k1) * j1 + (j2 + k1) * b1 + (k2 + k1 - 1)] = l1; + } + + if (this.field_150128_a[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1 + 1] == -2) + { + this.field_150128_a[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1 + 1] = l1; + } + } + } + } + } + } + } + + l1 = this.field_150128_a[k1 * j1 + k1 * b1 + k1]; + + if (l1 >= 0) + { + p_149674_1_.setBlockMetadataWithNotify(p_149674_2_, p_149674_3_, p_149674_4_, l & -9, 4); + } + else + { + this.removeLeaves(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_); + } + } + } + } + + @SideOnly(Side.CLIENT) + public void randomDisplayTick(World p_149734_1_, int p_149734_2_, int p_149734_3_, int p_149734_4_, Random p_149734_5_) + { + if (p_149734_1_.canLightningStrikeAt(p_149734_2_, p_149734_3_ + 1, p_149734_4_) && !World.doesBlockHaveSolidTopSurface(p_149734_1_, p_149734_2_, p_149734_3_ - 1, p_149734_4_) && p_149734_5_.nextInt(15) == 1) + { + double d0 = (double)((float)p_149734_2_ + p_149734_5_.nextFloat()); + double d1 = (double)p_149734_3_ - 0.05D; + double d2 = (double)((float)p_149734_4_ + p_149734_5_.nextFloat()); + p_149734_1_.spawnParticle("dripWater", d0, d1, d2, 0.0D, 0.0D, 0.0D); + } + } + + private void removeLeaves(World p_150126_1_, int p_150126_2_, int p_150126_3_, int p_150126_4_) + { + this.dropBlockAsItem(p_150126_1_, p_150126_2_, p_150126_3_, p_150126_4_, p_150126_1_.getBlockMetadata(p_150126_2_, p_150126_3_, p_150126_4_), 0); + p_150126_1_.setBlockToAir(p_150126_2_, p_150126_3_, p_150126_4_); + } + + public int quantityDropped(Random p_149745_1_) + { + return p_149745_1_.nextInt(20) == 0 ? 1 : 0; + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return Item.getItemFromBlock(Blocks.sapling); + } + + public void dropBlockAsItemWithChance(World p_149690_1_, int p_149690_2_, int p_149690_3_, int p_149690_4_, int p_149690_5_, float p_149690_6_, int p_149690_7_) + { + if (!p_149690_1_.isRemote) + { + int j1 = this.func_150123_b(p_149690_5_); + + if (p_149690_7_ > 0) + { + j1 -= 2 << p_149690_7_; + + if (j1 < 10) + { + j1 = 10; + } + } + + if (p_149690_1_.rand.nextInt(j1) == 0) + { + Item item = this.getItemDropped(p_149690_5_, p_149690_1_.rand, p_149690_7_); + this.dropBlockAsItem(p_149690_1_, p_149690_2_, p_149690_3_, p_149690_4_, new ItemStack(item, 1, this.damageDropped(p_149690_5_))); + } + + j1 = 200; + + if (p_149690_7_ > 0) + { + j1 -= 10 << p_149690_7_; + + if (j1 < 40) + { + j1 = 40; + } + } + + this.func_150124_c(p_149690_1_, p_149690_2_, p_149690_3_, p_149690_4_, p_149690_5_, j1); + } + } + + protected void func_150124_c(World p_150124_1_, int p_150124_2_, int p_150124_3_, int p_150124_4_, int p_150124_5_, int p_150124_6_) {} + + protected int func_150123_b(int p_150123_1_) + { + return 20; + } + + public void harvestBlock(World p_149636_1_, EntityPlayer p_149636_2_, int p_149636_3_, int p_149636_4_, int p_149636_5_, int p_149636_6_) + { + { + super.harvestBlock(p_149636_1_, p_149636_2_, p_149636_3_, p_149636_4_, p_149636_5_, p_149636_6_); + } + } + + public int damageDropped(int p_149692_1_) + { + return p_149692_1_ & 3; + } + + public boolean isOpaqueCube() + { + return !this.field_150121_P; + } + + @SideOnly(Side.CLIENT) + public abstract IIcon getIcon(int var1, int var2); + + @SideOnly(Side.CLIENT) + public void setGraphicsLevel(boolean p_150122_1_) + { + this.field_150121_P = p_150122_1_; + this.field_150127_b = p_150122_1_ ? 0 : 1; + } + + protected ItemStack createStackedBlock(int p_149644_1_) + { + return new ItemStack(Item.getItemFromBlock(this), 1, p_149644_1_ & 3); + } + + public abstract String[] func_150125_e(); + + + @Override + public boolean isShearable(ItemStack item, IBlockAccess world, int x, int y, int z) + { + return true; + } + + @Override + public ArrayList onSheared(ItemStack item, IBlockAccess world, int x, int y, int z, int fortune) + { + ArrayList ret = new ArrayList(); + ret.add(new ItemStack(this, 1, world.getBlockMetadata(x, y, z) & 3)); + return ret; + } + + @Override + public void beginLeavesDecay(World world, int x, int y, int z) + { + + int i2 = world.getBlockMetadata(x, y, z); + + if ((i2 & 8) == 0) + { + world.setBlockMetadataWithNotify(x, y, z, i2 | 8, 4); + } + world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) | 8, 4); + } + + @Override + public boolean isLeaves(IBlockAccess world, int x, int y, int z) + { + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockLeavesBase.java b/src/main/java/net/minecraft/block/BlockLeavesBase.java new file mode 100644 index 0000000..512082e --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockLeavesBase.java @@ -0,0 +1,30 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.material.Material; +import net.minecraft.world.IBlockAccess; + +public class BlockLeavesBase extends Block +{ + protected boolean field_150121_P; + private static final String __OBFID = "CL_00000326"; + + protected BlockLeavesBase(Material p_i45433_1_, boolean p_i45433_2_) + { + super(p_i45433_1_); + this.field_150121_P = p_i45433_2_; + } + + public boolean isOpaqueCube() + { + return false; + } + + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) + { + Block block = p_149646_1_.getBlock(p_149646_2_, p_149646_3_, p_149646_4_); + return !this.field_150121_P && block == this ? false : super.shouldSideBeRendered(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, p_149646_5_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockLever.java b/src/main/java/net/minecraft/block/BlockLever.java new file mode 100644 index 0000000..39dc6c9 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockLever.java @@ -0,0 +1,372 @@ +package net.minecraft.block; + +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.MathHelper; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import net.minecraftforge.common.util.ForgeDirection; +import static net.minecraftforge.common.util.ForgeDirection.*; + +public class BlockLever extends Block +{ + private static final String __OBFID = "CL_00000264"; + + protected BlockLever() + { + super(Material.circuits); + this.setCreativeTab(CreativeTabs.tabRedstone); + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) + { + return null; + } + + public boolean isOpaqueCube() + { + return false; + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public int getRenderType() + { + return 12; + } + + public boolean canPlaceBlockOnSide(World p_149707_1_, int p_149707_2_, int p_149707_3_, int p_149707_4_, int p_149707_5_) + { + ForgeDirection dir = ForgeDirection.getOrientation(p_149707_5_); + return (dir == DOWN && p_149707_1_.isSideSolid(p_149707_2_, p_149707_3_ + 1, p_149707_4_, DOWN )) || + (dir == UP && p_149707_1_.isSideSolid(p_149707_2_, p_149707_3_ - 1, p_149707_4_, UP )) || + (dir == NORTH && p_149707_1_.isSideSolid(p_149707_2_, p_149707_3_, p_149707_4_ + 1, NORTH)) || + (dir == SOUTH && p_149707_1_.isSideSolid(p_149707_2_, p_149707_3_, p_149707_4_ - 1, SOUTH)) || + (dir == WEST && p_149707_1_.isSideSolid(p_149707_2_ + 1, p_149707_3_, p_149707_4_, WEST )) || + (dir == EAST && p_149707_1_.isSideSolid(p_149707_2_ - 1, p_149707_3_, p_149707_4_, EAST )); + } + + public boolean canPlaceBlockAt(World p_149742_1_, int p_149742_2_, int p_149742_3_, int p_149742_4_) + { + return p_149742_1_.isSideSolid(p_149742_2_ - 1, p_149742_3_, p_149742_4_, EAST ) || + p_149742_1_.isSideSolid(p_149742_2_ + 1, p_149742_3_, p_149742_4_, WEST ) || + p_149742_1_.isSideSolid(p_149742_2_, p_149742_3_, p_149742_4_ - 1, SOUTH) || + p_149742_1_.isSideSolid(p_149742_2_, p_149742_3_, p_149742_4_ + 1, NORTH) || + p_149742_1_.isSideSolid(p_149742_2_, p_149742_3_ - 1, p_149742_4_, UP ) || + p_149742_1_.isSideSolid(p_149742_2_, p_149742_3_ + 1, p_149742_4_, DOWN ); + } + + public int onBlockPlaced(World p_149660_1_, int p_149660_2_, int p_149660_3_, int p_149660_4_, int p_149660_5_, float p_149660_6_, float p_149660_7_, float p_149660_8_, int p_149660_9_) + { + int k1 = p_149660_9_ & 8; + int j1 = p_149660_9_ & 7; + byte b0 = -1; + + if (p_149660_5_ == 0 && p_149660_1_.isSideSolid(p_149660_2_, p_149660_3_ + 1, p_149660_4_, DOWN)) + { + b0 = 0; + } + + if (p_149660_5_ == 1 && p_149660_1_.isSideSolid(p_149660_2_, p_149660_3_ - 1, p_149660_4_, UP)) + { + b0 = 5; + } + + if (p_149660_5_ == 2 && p_149660_1_.isSideSolid(p_149660_2_, p_149660_3_, p_149660_4_ + 1, NORTH)) + { + b0 = 4; + } + + if (p_149660_5_ == 3 && p_149660_1_.isSideSolid(p_149660_2_, p_149660_3_, p_149660_4_ - 1, SOUTH)) + { + b0 = 3; + } + + if (p_149660_5_ == 4 && p_149660_1_.isSideSolid(p_149660_2_ + 1, p_149660_3_, p_149660_4_, WEST)) + { + b0 = 2; + } + + if (p_149660_5_ == 5 && p_149660_1_.isSideSolid(p_149660_2_ - 1, p_149660_3_, p_149660_4_, EAST)) + { + b0 = 1; + } + + return b0 + k1; + } + + public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_) + { + int l = p_149689_1_.getBlockMetadata(p_149689_2_, p_149689_3_, p_149689_4_); + int i1 = l & 7; + int j1 = l & 8; + + if (i1 == invertMetadata(1)) + { + if ((MathHelper.floor_double((double)(p_149689_5_.rotationYaw * 4.0F / 360.0F) + 0.5D) & 1) == 0) + { + p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, 5 | j1, 2); + } + else + { + p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, 6 | j1, 2); + } + } + else if (i1 == invertMetadata(0)) + { + if ((MathHelper.floor_double((double)(p_149689_5_.rotationYaw * 4.0F / 360.0F) + 0.5D) & 1) == 0) + { + p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, 7 | j1, 2); + } + else + { + p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, 0 | j1, 2); + } + } + } + + public static int invertMetadata(int p_149819_0_) + { + switch (p_149819_0_) + { + case 0: + return 0; + case 1: + return 5; + case 2: + return 4; + case 3: + return 3; + case 4: + return 2; + case 5: + return 1; + default: + return -1; + } + } + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) + { + if (this.func_149820_e(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_)) + { + int l = p_149695_1_.getBlockMetadata(p_149695_2_, p_149695_3_, p_149695_4_) & 7; + boolean flag = false; + + if (!p_149695_1_.isSideSolid(p_149695_2_ - 1, p_149695_3_, p_149695_4_, EAST) && l == 1) + { + flag = true; + } + + if (!p_149695_1_.isSideSolid(p_149695_2_ + 1, p_149695_3_, p_149695_4_, WEST) && l == 2) + { + flag = true; + } + + if (!p_149695_1_.isSideSolid(p_149695_2_, p_149695_3_, p_149695_4_ - 1, SOUTH) && l == 3) + { + flag = true; + } + + if (!p_149695_1_.isSideSolid(p_149695_2_, p_149695_3_, p_149695_4_ + 1, NORTH) && l == 4) + { + flag = true; + } + + if (!p_149695_1_.isSideSolid(p_149695_2_, p_149695_3_ - 1, p_149695_4_, UP) && l == 5) + { + flag = true; + } + + if (!p_149695_1_.isSideSolid(p_149695_2_, p_149695_3_ - 1, p_149695_4_, UP) && l == 6) + { + flag = true; + } + + if (!p_149695_1_.isSideSolid(p_149695_2_, p_149695_3_ + 1, p_149695_4_, DOWN) && l == 0) + { + flag = true; + } + + if (!p_149695_1_.isSideSolid(p_149695_2_, p_149695_3_ + 1, p_149695_4_, DOWN) && l == 7) + { + flag = true; + } + + if (flag) + { + this.dropBlockAsItem(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, p_149695_1_.getBlockMetadata(p_149695_2_, p_149695_3_, p_149695_4_), 0); + p_149695_1_.setBlockToAir(p_149695_2_, p_149695_3_, p_149695_4_); + } + } + } + + private boolean func_149820_e(World p_149820_1_, int p_149820_2_, int p_149820_3_, int p_149820_4_) + { + if (!this.canPlaceBlockAt(p_149820_1_, p_149820_2_, p_149820_3_, p_149820_4_)) + { + this.dropBlockAsItem(p_149820_1_, p_149820_2_, p_149820_3_, p_149820_4_, p_149820_1_.getBlockMetadata(p_149820_2_, p_149820_3_, p_149820_4_), 0); + p_149820_1_.setBlockToAir(p_149820_2_, p_149820_3_, p_149820_4_); + return false; + } + else + { + return true; + } + } + + public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) + { + int l = p_149719_1_.getBlockMetadata(p_149719_2_, p_149719_3_, p_149719_4_) & 7; + float f = 0.1875F; + + if (l == 1) + { + this.setBlockBounds(0.0F, 0.2F, 0.5F - f, f * 2.0F, 0.8F, 0.5F + f); + } + else if (l == 2) + { + this.setBlockBounds(1.0F - f * 2.0F, 0.2F, 0.5F - f, 1.0F, 0.8F, 0.5F + f); + } + else if (l == 3) + { + this.setBlockBounds(0.5F - f, 0.2F, 0.0F, 0.5F + f, 0.8F, f * 2.0F); + } + else if (l == 4) + { + this.setBlockBounds(0.5F - f, 0.2F, 1.0F - f * 2.0F, 0.5F + f, 0.8F, 1.0F); + } + else if (l != 5 && l != 6) + { + if (l == 0 || l == 7) + { + f = 0.25F; + this.setBlockBounds(0.5F - f, 0.4F, 0.5F - f, 0.5F + f, 1.0F, 0.5F + f); + } + } + else + { + f = 0.25F; + this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.6F, 0.5F + f); + } + } + + public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) + { + if (p_149727_1_.isRemote) + { + return true; + } + else + { + int i1 = p_149727_1_.getBlockMetadata(p_149727_2_, p_149727_3_, p_149727_4_); + int j1 = i1 & 7; + int k1 = 8 - (i1 & 8); + p_149727_1_.setBlockMetadataWithNotify(p_149727_2_, p_149727_3_, p_149727_4_, j1 + k1, 3); + p_149727_1_.playSoundEffect((double)p_149727_2_ + 0.5D, (double)p_149727_3_ + 0.5D, (double)p_149727_4_ + 0.5D, "random.click", 0.3F, k1 > 0 ? 0.6F : 0.5F); + p_149727_1_.notifyBlocksOfNeighborChange(p_149727_2_, p_149727_3_, p_149727_4_, this); + + if (j1 == 1) + { + p_149727_1_.notifyBlocksOfNeighborChange(p_149727_2_ - 1, p_149727_3_, p_149727_4_, this); + } + else if (j1 == 2) + { + p_149727_1_.notifyBlocksOfNeighborChange(p_149727_2_ + 1, p_149727_3_, p_149727_4_, this); + } + else if (j1 == 3) + { + p_149727_1_.notifyBlocksOfNeighborChange(p_149727_2_, p_149727_3_, p_149727_4_ - 1, this); + } + else if (j1 == 4) + { + p_149727_1_.notifyBlocksOfNeighborChange(p_149727_2_, p_149727_3_, p_149727_4_ + 1, this); + } + else if (j1 != 5 && j1 != 6) + { + if (j1 == 0 || j1 == 7) + { + p_149727_1_.notifyBlocksOfNeighborChange(p_149727_2_, p_149727_3_ + 1, p_149727_4_, this); + } + } + else + { + p_149727_1_.notifyBlocksOfNeighborChange(p_149727_2_, p_149727_3_ - 1, p_149727_4_, this); + } + + return true; + } + } + + public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) + { + if ((p_149749_6_ & 8) > 0) + { + p_149749_1_.notifyBlocksOfNeighborChange(p_149749_2_, p_149749_3_, p_149749_4_, this); + int i1 = p_149749_6_ & 7; + + if (i1 == 1) + { + p_149749_1_.notifyBlocksOfNeighborChange(p_149749_2_ - 1, p_149749_3_, p_149749_4_, this); + } + else if (i1 == 2) + { + p_149749_1_.notifyBlocksOfNeighborChange(p_149749_2_ + 1, p_149749_3_, p_149749_4_, this); + } + else if (i1 == 3) + { + p_149749_1_.notifyBlocksOfNeighborChange(p_149749_2_, p_149749_3_, p_149749_4_ - 1, this); + } + else if (i1 == 4) + { + p_149749_1_.notifyBlocksOfNeighborChange(p_149749_2_, p_149749_3_, p_149749_4_ + 1, this); + } + else if (i1 != 5 && i1 != 6) + { + if (i1 == 0 || i1 == 7) + { + p_149749_1_.notifyBlocksOfNeighborChange(p_149749_2_, p_149749_3_ + 1, p_149749_4_, this); + } + } + else + { + p_149749_1_.notifyBlocksOfNeighborChange(p_149749_2_, p_149749_3_ - 1, p_149749_4_, this); + } + } + + super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_); + } + + public int isProvidingWeakPower(IBlockAccess p_149709_1_, int p_149709_2_, int p_149709_3_, int p_149709_4_, int p_149709_5_) + { + return (p_149709_1_.getBlockMetadata(p_149709_2_, p_149709_3_, p_149709_4_) & 8) > 0 ? 15 : 0; + } + + public int isProvidingStrongPower(IBlockAccess p_149748_1_, int p_149748_2_, int p_149748_3_, int p_149748_4_, int p_149748_5_) + { + int i1 = p_149748_1_.getBlockMetadata(p_149748_2_, p_149748_3_, p_149748_4_); + + if ((i1 & 8) == 0) + { + return 0; + } + else + { + int j1 = i1 & 7; + return j1 == 0 && p_149748_5_ == 0 ? 15 : (j1 == 7 && p_149748_5_ == 0 ? 15 : (j1 == 6 && p_149748_5_ == 1 ? 15 : (j1 == 5 && p_149748_5_ == 1 ? 15 : (j1 == 4 && p_149748_5_ == 2 ? 15 : (j1 == 3 && p_149748_5_ == 3 ? 15 : (j1 == 2 && p_149748_5_ == 4 ? 15 : (j1 == 1 && p_149748_5_ == 5 ? 15 : 0))))))); + } + } + + public boolean canProvidePower() + { + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockLilyPad.java b/src/main/java/net/minecraft/block/BlockLilyPad.java new file mode 100644 index 0000000..110d28d --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockLilyPad.java @@ -0,0 +1,72 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityBoat; +import net.minecraft.init.Blocks; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockLilyPad extends BlockBush +{ + private static final String __OBFID = "CL_00000332"; + + protected BlockLilyPad() + { + float f = 0.5F; + float f1 = 0.015625F; + this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f1, 0.5F + f); + this.setCreativeTab(CreativeTabs.tabDecorations); + } + + public int getRenderType() + { + return 23; + } + + public void addCollisionBoxesToList(World p_149743_1_, int p_149743_2_, int p_149743_3_, int p_149743_4_, AxisAlignedBB p_149743_5_, List p_149743_6_, Entity p_149743_7_) + { + if (p_149743_7_ == null || !(p_149743_7_ instanceof EntityBoat)) + { + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + } + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) + { + return AxisAlignedBB.getAABBPool().getAABB((double)p_149668_2_ + this.minX, (double)p_149668_3_ + this.minY, (double)p_149668_4_ + this.minZ, (double)p_149668_2_ + this.maxX, (double)p_149668_3_ + this.maxY, (double)p_149668_4_ + this.maxZ); + } + + protected boolean canPlaceBlockOn(Block p_149854_1_) + { + return p_149854_1_ == Blocks.water; + } + + @SideOnly(Side.CLIENT) + public int getBlockColor() + { + return 2129968; + } + + @SideOnly(Side.CLIENT) + public int getRenderColor(int p_149741_1_) + { + return 2129968; + } + + @SideOnly(Side.CLIENT) + public int colorMultiplier(IBlockAccess p_149720_1_, int p_149720_2_, int p_149720_3_, int p_149720_4_) + { + return 2129968; + } + + public boolean canBlockStay(World p_149718_1_, int p_149718_2_, int p_149718_3_, int p_149718_4_) + { + return p_149718_3_ >= 0 && p_149718_3_ < 256 ? p_149718_1_.getBlock(p_149718_2_, p_149718_3_ - 1, p_149718_4_).getMaterial() == Material.water && p_149718_1_.getBlockMetadata(p_149718_2_, p_149718_3_ - 1, p_149718_4_) == 0 : false; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockLiquid.java b/src/main/java/net/minecraft/block/BlockLiquid.java new file mode 100644 index 0000000..4c1e880 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockLiquid.java @@ -0,0 +1,551 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.IIcon; +import net.minecraft.util.Vec3; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public abstract class BlockLiquid extends Block +{ + @SideOnly(Side.CLIENT) + private IIcon[] field_149806_a; + private static final String __OBFID = "CL_00000265"; + + protected BlockLiquid(Material p_i45413_1_) + { + super(p_i45413_1_); + float f = 0.0F; + float f1 = 0.0F; + this.setBlockBounds(0.0F + f1, 0.0F + f, 0.0F + f1, 1.0F + f1, 1.0F + f, 1.0F + f1); + this.setTickRandomly(true); + } + + public boolean getBlocksMovement(IBlockAccess p_149655_1_, int p_149655_2_, int p_149655_3_, int p_149655_4_) + { + return this.blockMaterial != Material.lava; + } + + public static float getLiquidHeightPercent(int p_149801_0_) + { + if (p_149801_0_ >= 8) + { + p_149801_0_ = 0; + } + + return (float)(p_149801_0_ + 1) / 9.0F; + } + + @SideOnly(Side.CLIENT) + public int getBlockColor() + { + return 16777215; + } + + @SideOnly(Side.CLIENT) + public int colorMultiplier(IBlockAccess p_149720_1_, int p_149720_2_, int p_149720_3_, int p_149720_4_) + { + if (this.blockMaterial != Material.water) + { + return 16777215; + } + else + { + int l = 0; + int i1 = 0; + int j1 = 0; + + for (int k1 = -1; k1 <= 1; ++k1) + { + for (int l1 = -1; l1 <= 1; ++l1) + { + int i2 = p_149720_1_.getBiomeGenForCoords(p_149720_2_ + l1, p_149720_4_ + k1).getWaterColorMultiplier(); + l += (i2 & 16711680) >> 16; + i1 += (i2 & 65280) >> 8; + j1 += i2 & 255; + } + } + + return (l / 9 & 255) << 16 | (i1 / 9 & 255) << 8 | j1 / 9 & 255; + } + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return p_149691_1_ != 0 && p_149691_1_ != 1 ? this.field_149806_a[1] : this.field_149806_a[0]; + } + + protected int func_149804_e(World p_149804_1_, int p_149804_2_, int p_149804_3_, int p_149804_4_) + { + return p_149804_1_.getBlock(p_149804_2_, p_149804_3_, p_149804_4_).getMaterial() == this.blockMaterial ? p_149804_1_.getBlockMetadata(p_149804_2_, p_149804_3_, p_149804_4_) : -1; + } + + protected int getEffectiveFlowDecay(IBlockAccess p_149798_1_, int p_149798_2_, int p_149798_3_, int p_149798_4_) + { + if (p_149798_1_.getBlock(p_149798_2_, p_149798_3_, p_149798_4_).getMaterial() != this.blockMaterial) + { + return -1; + } + else + { + int l = p_149798_1_.getBlockMetadata(p_149798_2_, p_149798_3_, p_149798_4_); + + if (l >= 8) + { + l = 0; + } + + return l; + } + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public boolean isOpaqueCube() + { + return false; + } + + public boolean canCollideCheck(int p_149678_1_, boolean p_149678_2_) + { + return p_149678_2_ && p_149678_1_ == 0; + } + + public boolean isBlockSolid(IBlockAccess p_149747_1_, int p_149747_2_, int p_149747_3_, int p_149747_4_, int p_149747_5_) + { + Material material = p_149747_1_.getBlock(p_149747_2_, p_149747_3_, p_149747_4_).getMaterial(); + return material == this.blockMaterial ? false : (p_149747_5_ == 1 ? true : (material == Material.ice ? false : super.isBlockSolid(p_149747_1_, p_149747_2_, p_149747_3_, p_149747_4_, p_149747_5_))); + } + + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) + { + Material material = p_149646_1_.getBlock(p_149646_2_, p_149646_3_, p_149646_4_).getMaterial(); + return material == this.blockMaterial ? false : (p_149646_5_ == 1 ? true : super.shouldSideBeRendered(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, p_149646_5_)); + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) + { + return null; + } + + public int getRenderType() + { + return 4; + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return null; + } + + public int quantityDropped(Random p_149745_1_) + { + return 0; + } + + private Vec3 getFlowVector(IBlockAccess p_149800_1_, int p_149800_2_, int p_149800_3_, int p_149800_4_) + { + Vec3 vec3 = p_149800_1_.getWorldVec3Pool().getVecFromPool(0.0D, 0.0D, 0.0D); + int l = this.getEffectiveFlowDecay(p_149800_1_, p_149800_2_, p_149800_3_, p_149800_4_); + + for (int i1 = 0; i1 < 4; ++i1) + { + int j1 = p_149800_2_; + int k1 = p_149800_4_; + + if (i1 == 0) + { + j1 = p_149800_2_ - 1; + } + + if (i1 == 1) + { + k1 = p_149800_4_ - 1; + } + + if (i1 == 2) + { + ++j1; + } + + if (i1 == 3) + { + ++k1; + } + + int l1 = this.getEffectiveFlowDecay(p_149800_1_, j1, p_149800_3_, k1); + int i2; + + if (l1 < 0) + { + if (!p_149800_1_.getBlock(j1, p_149800_3_, k1).getMaterial().blocksMovement()) + { + l1 = this.getEffectiveFlowDecay(p_149800_1_, j1, p_149800_3_ - 1, k1); + + if (l1 >= 0) + { + i2 = l1 - (l - 8); + vec3 = vec3.addVector((double)((j1 - p_149800_2_) * i2), (double)((p_149800_3_ - p_149800_3_) * i2), (double)((k1 - p_149800_4_) * i2)); + } + } + } + else if (l1 >= 0) + { + i2 = l1 - l; + vec3 = vec3.addVector((double)((j1 - p_149800_2_) * i2), (double)((p_149800_3_ - p_149800_3_) * i2), (double)((k1 - p_149800_4_) * i2)); + } + } + + if (p_149800_1_.getBlockMetadata(p_149800_2_, p_149800_3_, p_149800_4_) >= 8) + { + boolean flag = false; + + if (flag || this.isBlockSolid(p_149800_1_, p_149800_2_, p_149800_3_, p_149800_4_ - 1, 2)) + { + flag = true; + } + + if (flag || this.isBlockSolid(p_149800_1_, p_149800_2_, p_149800_3_, p_149800_4_ + 1, 3)) + { + flag = true; + } + + if (flag || this.isBlockSolid(p_149800_1_, p_149800_2_ - 1, p_149800_3_, p_149800_4_, 4)) + { + flag = true; + } + + if (flag || this.isBlockSolid(p_149800_1_, p_149800_2_ + 1, p_149800_3_, p_149800_4_, 5)) + { + flag = true; + } + + if (flag || this.isBlockSolid(p_149800_1_, p_149800_2_, p_149800_3_ + 1, p_149800_4_ - 1, 2)) + { + flag = true; + } + + if (flag || this.isBlockSolid(p_149800_1_, p_149800_2_, p_149800_3_ + 1, p_149800_4_ + 1, 3)) + { + flag = true; + } + + if (flag || this.isBlockSolid(p_149800_1_, p_149800_2_ - 1, p_149800_3_ + 1, p_149800_4_, 4)) + { + flag = true; + } + + if (flag || this.isBlockSolid(p_149800_1_, p_149800_2_ + 1, p_149800_3_ + 1, p_149800_4_, 5)) + { + flag = true; + } + + if (flag) + { + vec3 = vec3.normalize().addVector(0.0D, -6.0D, 0.0D); + } + } + + vec3 = vec3.normalize(); + return vec3; + } + + public void velocityToAddToEntity(World p_149640_1_, int p_149640_2_, int p_149640_3_, int p_149640_4_, Entity p_149640_5_, Vec3 p_149640_6_) + { + Vec3 vec31 = this.getFlowVector(p_149640_1_, p_149640_2_, p_149640_3_, p_149640_4_); + p_149640_6_.xCoord += vec31.xCoord; + p_149640_6_.yCoord += vec31.yCoord; + p_149640_6_.zCoord += vec31.zCoord; + } + + public int tickRate(World p_149738_1_) + { + return this.blockMaterial == Material.water ? 5 : (this.blockMaterial == Material.lava ? (p_149738_1_.provider.hasNoSky ? 10 : 30) : 0); + } + + @SideOnly(Side.CLIENT) + public int getMixedBrightnessForBlock(IBlockAccess p_149677_1_, int p_149677_2_, int p_149677_3_, int p_149677_4_) + { + int l = p_149677_1_.getLightBrightnessForSkyBlocks(p_149677_2_, p_149677_3_, p_149677_4_, 0); + int i1 = p_149677_1_.getLightBrightnessForSkyBlocks(p_149677_2_, p_149677_3_ + 1, p_149677_4_, 0); + int j1 = l & 255; + int k1 = i1 & 255; + int l1 = l >> 16 & 255; + int i2 = i1 >> 16 & 255; + return (j1 > k1 ? j1 : k1) | (l1 > i2 ? l1 : i2) << 16; + } + + @SideOnly(Side.CLIENT) + public int getRenderBlockPass() + { + return this.blockMaterial == Material.water ? 1 : 0; + } + + @SideOnly(Side.CLIENT) + public void randomDisplayTick(World p_149734_1_, int p_149734_2_, int p_149734_3_, int p_149734_4_, Random p_149734_5_) + { + int l; + + if (this.blockMaterial == Material.water) + { + if (p_149734_5_.nextInt(10) == 0) + { + l = p_149734_1_.getBlockMetadata(p_149734_2_, p_149734_3_, p_149734_4_); + + if (l <= 0 || l >= 8) + { + p_149734_1_.spawnParticle("suspended", (double)((float)p_149734_2_ + p_149734_5_.nextFloat()), (double)((float)p_149734_3_ + p_149734_5_.nextFloat()), (double)((float)p_149734_4_ + p_149734_5_.nextFloat()), 0.0D, 0.0D, 0.0D); + } + } + + for (l = 0; l < 0; ++l) + { + int i1 = p_149734_5_.nextInt(4); + int j1 = p_149734_2_; + int k1 = p_149734_4_; + + if (i1 == 0) + { + j1 = p_149734_2_ - 1; + } + + if (i1 == 1) + { + ++j1; + } + + if (i1 == 2) + { + k1 = p_149734_4_ - 1; + } + + if (i1 == 3) + { + ++k1; + } + + if (p_149734_1_.getBlock(j1, p_149734_3_, k1).getMaterial() == Material.air && (p_149734_1_.getBlock(j1, p_149734_3_ - 1, k1).getMaterial().blocksMovement() || p_149734_1_.getBlock(j1, p_149734_3_ - 1, k1).getMaterial().isLiquid())) + { + float f = 0.0625F; + double d0 = (double)((float)p_149734_2_ + p_149734_5_.nextFloat()); + double d1 = (double)((float)p_149734_3_ + p_149734_5_.nextFloat()); + double d2 = (double)((float)p_149734_4_ + p_149734_5_.nextFloat()); + + if (i1 == 0) + { + d0 = (double)((float)p_149734_2_ - f); + } + + if (i1 == 1) + { + d0 = (double)((float)(p_149734_2_ + 1) + f); + } + + if (i1 == 2) + { + d2 = (double)((float)p_149734_4_ - f); + } + + if (i1 == 3) + { + d2 = (double)((float)(p_149734_4_ + 1) + f); + } + + double d3 = 0.0D; + double d4 = 0.0D; + + if (i1 == 0) + { + d3 = (double)(-f); + } + + if (i1 == 1) + { + d3 = (double)f; + } + + if (i1 == 2) + { + d4 = (double)(-f); + } + + if (i1 == 3) + { + d4 = (double)f; + } + + p_149734_1_.spawnParticle("splash", d0, d1, d2, d3, 0.0D, d4); + } + } + } + + if (this.blockMaterial == Material.water && p_149734_5_.nextInt(64) == 0) + { + l = p_149734_1_.getBlockMetadata(p_149734_2_, p_149734_3_, p_149734_4_); + + if (l > 0 && l < 8) + { + p_149734_1_.playSound((double)((float)p_149734_2_ + 0.5F), (double)((float)p_149734_3_ + 0.5F), (double)((float)p_149734_4_ + 0.5F), "liquid.water", p_149734_5_.nextFloat() * 0.25F + 0.75F, p_149734_5_.nextFloat() * 1.0F + 0.5F, false); + } + } + + double d5; + double d6; + double d7; + + if (this.blockMaterial == Material.lava && p_149734_1_.getBlock(p_149734_2_, p_149734_3_ + 1, p_149734_4_).getMaterial() == Material.air && !p_149734_1_.getBlock(p_149734_2_, p_149734_3_ + 1, p_149734_4_).isOpaqueCube()) + { + if (p_149734_5_.nextInt(100) == 0) + { + d5 = (double)((float)p_149734_2_ + p_149734_5_.nextFloat()); + d6 = (double)p_149734_3_ + this.maxY; + d7 = (double)((float)p_149734_4_ + p_149734_5_.nextFloat()); + p_149734_1_.spawnParticle("lava", d5, d6, d7, 0.0D, 0.0D, 0.0D); + p_149734_1_.playSound(d5, d6, d7, "liquid.lavapop", 0.2F + p_149734_5_.nextFloat() * 0.2F, 0.9F + p_149734_5_.nextFloat() * 0.15F, false); + } + + if (p_149734_5_.nextInt(200) == 0) + { + p_149734_1_.playSound((double)p_149734_2_, (double)p_149734_3_, (double)p_149734_4_, "liquid.lava", 0.2F + p_149734_5_.nextFloat() * 0.2F, 0.9F + p_149734_5_.nextFloat() * 0.15F, false); + } + } + + if (p_149734_5_.nextInt(10) == 0 && World.doesBlockHaveSolidTopSurface(p_149734_1_, p_149734_2_, p_149734_3_ - 1, p_149734_4_) && !p_149734_1_.getBlock(p_149734_2_, p_149734_3_ - 2, p_149734_4_).getMaterial().blocksMovement()) + { + d5 = (double)((float)p_149734_2_ + p_149734_5_.nextFloat()); + d6 = (double)p_149734_3_ - 1.05D; + d7 = (double)((float)p_149734_4_ + p_149734_5_.nextFloat()); + + if (this.blockMaterial == Material.water) + { + p_149734_1_.spawnParticle("dripWater", d5, d6, d7, 0.0D, 0.0D, 0.0D); + } + else + { + p_149734_1_.spawnParticle("dripLava", d5, d6, d7, 0.0D, 0.0D, 0.0D); + } + } + } + + public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_) + { + this.func_149805_n(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_); + } + + @SideOnly(Side.CLIENT) + public static double getFlowDirection(IBlockAccess p_149802_0_, int p_149802_1_, int p_149802_2_, int p_149802_3_, Material p_149802_4_) + { + Vec3 vec3 = null; + + if (p_149802_4_ == Material.water) + { + vec3 = Blocks.flowing_water.getFlowVector(p_149802_0_, p_149802_1_, p_149802_2_, p_149802_3_); + } + + if (p_149802_4_ == Material.lava) + { + vec3 = Blocks.flowing_lava.getFlowVector(p_149802_0_, p_149802_1_, p_149802_2_, p_149802_3_); + } + + return vec3.xCoord == 0.0D && vec3.zCoord == 0.0D ? -1000.0D : Math.atan2(vec3.zCoord, vec3.xCoord) - (Math.PI / 2D); + } + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) + { + this.func_149805_n(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_); + } + + private void func_149805_n(World p_149805_1_, int p_149805_2_, int p_149805_3_, int p_149805_4_) + { + if (p_149805_1_.getBlock(p_149805_2_, p_149805_3_, p_149805_4_) == this) + { + if (this.blockMaterial == Material.lava) + { + boolean flag = false; + + if (flag || p_149805_1_.getBlock(p_149805_2_, p_149805_3_, p_149805_4_ - 1).getMaterial() == Material.water) + { + flag = true; + } + + if (flag || p_149805_1_.getBlock(p_149805_2_, p_149805_3_, p_149805_4_ + 1).getMaterial() == Material.water) + { + flag = true; + } + + if (flag || p_149805_1_.getBlock(p_149805_2_ - 1, p_149805_3_, p_149805_4_).getMaterial() == Material.water) + { + flag = true; + } + + if (flag || p_149805_1_.getBlock(p_149805_2_ + 1, p_149805_3_, p_149805_4_).getMaterial() == Material.water) + { + flag = true; + } + + if (flag || p_149805_1_.getBlock(p_149805_2_, p_149805_3_ + 1, p_149805_4_).getMaterial() == Material.water) + { + flag = true; + } + + if (flag) + { + int l = p_149805_1_.getBlockMetadata(p_149805_2_, p_149805_3_, p_149805_4_); + + if (l == 0) + { + p_149805_1_.setBlock(p_149805_2_, p_149805_3_, p_149805_4_, Blocks.obsidian); + } + else if (l <= 4) + { + p_149805_1_.setBlock(p_149805_2_, p_149805_3_, p_149805_4_, Blocks.cobblestone); + } + + this.func_149799_m(p_149805_1_, p_149805_2_, p_149805_3_, p_149805_4_); + } + } + } + } + + protected void func_149799_m(World p_149799_1_, int p_149799_2_, int p_149799_3_, int p_149799_4_) + { + p_149799_1_.playSoundEffect((double)((float)p_149799_2_ + 0.5F), (double)((float)p_149799_3_ + 0.5F), (double)((float)p_149799_4_ + 0.5F), "random.fizz", 0.5F, 2.6F + (p_149799_1_.rand.nextFloat() - p_149799_1_.rand.nextFloat()) * 0.8F); + + for (int l = 0; l < 8; ++l) + { + p_149799_1_.spawnParticle("largesmoke", (double)p_149799_2_ + Math.random(), (double)p_149799_3_ + 1.2D, (double)p_149799_4_ + Math.random(), 0.0D, 0.0D, 0.0D); + } + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + if (this.blockMaterial == Material.lava) + { + this.field_149806_a = new IIcon[] {p_149651_1_.registerIcon("lava_still"), p_149651_1_.registerIcon("lava_flow")}; + } + else + { + this.field_149806_a = new IIcon[] {p_149651_1_.registerIcon("water_still"), p_149651_1_.registerIcon("water_flow")}; + } + } + + @SideOnly(Side.CLIENT) + public static IIcon getLiquidIcon(String p_149803_0_) + { + return p_149803_0_ == "water_still" ? Blocks.flowing_water.field_149806_a[0] : (p_149803_0_ == "water_flow" ? Blocks.flowing_water.field_149806_a[1] : (p_149803_0_ == "lava_still" ? Blocks.flowing_lava.field_149806_a[0] : (p_149803_0_ == "lava_flow" ? Blocks.flowing_lava.field_149806_a[1] : null))); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockLog.java b/src/main/java/net/minecraft/block/BlockLog.java new file mode 100644 index 0000000..ceb450e --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockLog.java @@ -0,0 +1,91 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public abstract class BlockLog extends BlockRotatedPillar +{ + @SideOnly(Side.CLIENT) + protected IIcon[] field_150167_a; + @SideOnly(Side.CLIENT) + protected IIcon[] field_150166_b; + private static final String __OBFID = "CL_00000266"; + + public BlockLog() + { + super(Material.wood); + this.setCreativeTab(CreativeTabs.tabBlock); + this.setHardness(2.0F); + this.setStepSound(soundTypeWood); + } + + public static int func_150165_c(int p_150165_0_) + { + return p_150165_0_ & 3; + } + + public int quantityDropped(Random p_149745_1_) + { + return 1; + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return Item.getItemFromBlock(this); + } + + public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) + { + byte b0 = 4; + int i1 = b0 + 1; + + if (p_149749_1_.checkChunksExist(p_149749_2_ - i1, p_149749_3_ - i1, p_149749_4_ - i1, p_149749_2_ + i1, p_149749_3_ + i1, p_149749_4_ + i1)) + { + for (int j1 = -b0; j1 <= b0; ++j1) + { + for (int k1 = -b0; k1 <= b0; ++k1) + { + for (int l1 = -b0; l1 <= b0; ++l1) + { + Block block = p_149749_1_.getBlock(p_149749_2_ + j1, p_149749_3_ + k1, p_149749_4_ + l1); + if (block.isLeaves(p_149749_1_, p_149749_2_ + j1, p_149749_3_ + k1, p_149749_4_ + l1)) + { + block.beginLeavesDecay(p_149749_1_, p_149749_2_ + j1, p_149749_3_ + k1, p_149749_4_ + l1); + } + } + } + } + } + } + + @SideOnly(Side.CLIENT) + protected IIcon getSideIcon(int p_150163_1_) + { + return this.field_150167_a[p_150163_1_ % this.field_150167_a.length]; + } + + @SideOnly(Side.CLIENT) + protected IIcon getTopIcon(int p_150161_1_) + { + return this.field_150166_b[p_150161_1_ % this.field_150166_b.length]; + } + + @Override + public boolean canSustainLeaves(IBlockAccess world, int x, int y, int z) + { + return true; + } + + @Override + public boolean isWood(IBlockAccess world, int x, int y, int z) + { + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockMelon.java b/src/main/java/net/minecraft/block/BlockMelon.java new file mode 100644 index 0000000..2b94a1f --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockMelon.java @@ -0,0 +1,59 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.util.IIcon; + +public class BlockMelon extends Block +{ + @SideOnly(Side.CLIENT) + private IIcon field_150201_a; + private static final String __OBFID = "CL_00000267"; + + protected BlockMelon() + { + super(Material.gourd); + this.setCreativeTab(CreativeTabs.tabBlock); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return p_149691_1_ != 1 && p_149691_1_ != 0 ? this.blockIcon : this.field_150201_a; + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return Items.melon; + } + + public int quantityDropped(Random p_149745_1_) + { + return 3 + p_149745_1_.nextInt(5); + } + + public int quantityDroppedWithBonus(int p_149679_1_, Random p_149679_2_) + { + int j = this.quantityDropped(p_149679_2_) + p_149679_2_.nextInt(1 + p_149679_1_); + + if (j > 9) + { + j = 9; + } + + return j; + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.blockIcon = p_149651_1_.registerIcon(this.getTextureName() + "_side"); + this.field_150201_a = p_149651_1_.registerIcon(this.getTextureName() + "_top"); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockMobSpawner.java b/src/main/java/net/minecraft/block/BlockMobSpawner.java new file mode 100644 index 0000000..66ecf1c --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockMobSpawner.java @@ -0,0 +1,59 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.item.Item; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityMobSpawner; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockMobSpawner extends BlockContainer +{ + private static final String __OBFID = "CL_00000269"; + + protected BlockMobSpawner() + { + super(Material.rock); + } + + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) + { + return new TileEntityMobSpawner(); + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return null; + } + + public int quantityDropped(Random p_149745_1_) + { + return 0; + } + + public void dropBlockAsItemWithChance(World p_149690_1_, int p_149690_2_, int p_149690_3_, int p_149690_4_, int p_149690_5_, float p_149690_6_, int p_149690_7_) + { + super.dropBlockAsItemWithChance(p_149690_1_, p_149690_2_, p_149690_3_, p_149690_4_, p_149690_5_, p_149690_6_, p_149690_7_); + } + + private Random rand = new Random(); + @Override + public int getExpDrop(IBlockAccess world, int metadata, int fortune) + { + return 15 + rand.nextInt(15) + rand.nextInt(15); + } + + public boolean isOpaqueCube() + { + return false; + } + + @SideOnly(Side.CLIENT) + public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) + { + return Item.getItemById(0); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockMushroom.java b/src/main/java/net/minecraft/block/BlockMushroom.java new file mode 100644 index 0000000..0108112 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockMushroom.java @@ -0,0 +1,137 @@ +package net.minecraft.block; + +import java.util.Random; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenBigMushroom; +import net.minecraftforge.common.util.ForgeDirection; + +public class BlockMushroom extends BlockBush implements IGrowable +{ + private static final String __OBFID = "CL_00000272"; + + protected BlockMushroom() + { + float f = 0.2F; + this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 2.0F, 0.5F + f); + this.setTickRandomly(true); + } + + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) + { + if (p_149674_5_.nextInt(25) == 0) + { + byte b0 = 4; + int l = 5; + int i1; + int j1; + int k1; + + for (i1 = p_149674_2_ - b0; i1 <= p_149674_2_ + b0; ++i1) + { + for (j1 = p_149674_4_ - b0; j1 <= p_149674_4_ + b0; ++j1) + { + for (k1 = p_149674_3_ - 1; k1 <= p_149674_3_ + 1; ++k1) + { + if (p_149674_1_.getBlock(i1, k1, j1) == this) + { + --l; + + if (l <= 0) + { + return; + } + } + } + } + } + + i1 = p_149674_2_ + p_149674_5_.nextInt(3) - 1; + j1 = p_149674_3_ + p_149674_5_.nextInt(2) - p_149674_5_.nextInt(2); + k1 = p_149674_4_ + p_149674_5_.nextInt(3) - 1; + + for (int l1 = 0; l1 < 4; ++l1) + { + if (p_149674_1_.isAirBlock(i1, j1, k1) && this.canBlockStay(p_149674_1_, i1, j1, k1)) + { + p_149674_2_ = i1; + p_149674_3_ = j1; + p_149674_4_ = k1; + } + + i1 = p_149674_2_ + p_149674_5_.nextInt(3) - 1; + j1 = p_149674_3_ + p_149674_5_.nextInt(2) - p_149674_5_.nextInt(2); + k1 = p_149674_4_ + p_149674_5_.nextInt(3) - 1; + } + + if (p_149674_1_.isAirBlock(i1, j1, k1) && this.canBlockStay(p_149674_1_, i1, j1, k1)) + { + p_149674_1_.setBlock(i1, j1, k1, this, 0, 2); + } + } + } + + public boolean canPlaceBlockAt(World p_149742_1_, int p_149742_2_, int p_149742_3_, int p_149742_4_) + { + return super.canPlaceBlockAt(p_149742_1_, p_149742_2_, p_149742_3_, p_149742_4_) && this.canBlockStay(p_149742_1_, p_149742_2_, p_149742_3_, p_149742_4_); + } + + protected boolean canPlaceBlockOn(Block p_149854_1_) + { + return p_149854_1_.func_149730_j(); + } + + public boolean canBlockStay(World p_149718_1_, int p_149718_2_, int p_149718_3_, int p_149718_4_) + { + if (p_149718_3_ >= 0 && p_149718_3_ < 256) + { + Block block = p_149718_1_.getBlock(p_149718_2_, p_149718_3_ - 1, p_149718_4_); + return block == Blocks.mycelium || block == Blocks.dirt && p_149718_1_.getBlockMetadata(p_149718_2_, p_149718_3_ - 1, p_149718_4_) == 2 || p_149718_1_.getFullBlockLightValue(p_149718_2_, p_149718_3_, p_149718_4_) < 13 && block.canSustainPlant(p_149718_1_, p_149718_2_, p_149718_3_ - 1, p_149718_4_, ForgeDirection.UP, this); + } + else + { + return false; + } + } + + public boolean func_149884_c(World p_149884_1_, int p_149884_2_, int p_149884_3_, int p_149884_4_, Random p_149884_5_) + { + int l = p_149884_1_.getBlockMetadata(p_149884_2_, p_149884_3_, p_149884_4_); + p_149884_1_.setBlockToAir(p_149884_2_, p_149884_3_, p_149884_4_); + WorldGenBigMushroom worldgenbigmushroom = null; + + if (this == Blocks.brown_mushroom) + { + worldgenbigmushroom = new WorldGenBigMushroom(0); + } + else if (this == Blocks.red_mushroom) + { + worldgenbigmushroom = new WorldGenBigMushroom(1); + } + + if (worldgenbigmushroom != null && worldgenbigmushroom.generate(p_149884_1_, p_149884_5_, p_149884_2_, p_149884_3_, p_149884_4_)) + { + return true; + } + else + { + p_149884_1_.setBlock(p_149884_2_, p_149884_3_, p_149884_4_, this, l, 3); + return false; + } + } + + public boolean func_149851_a(World p_149851_1_, int p_149851_2_, int p_149851_3_, int p_149851_4_, boolean p_149851_5_) + { + return true; + } + + public boolean func_149852_a(World p_149852_1_, Random p_149852_2_, int p_149852_3_, int p_149852_4_, int p_149852_5_) + { + return (double)p_149852_2_.nextFloat() < 0.4D; + } + + public void func_149853_b(World p_149853_1_, Random p_149853_2_, int p_149853_3_, int p_149853_4_, int p_149853_5_) + { + this.func_149884_c(p_149853_1_, p_149853_3_, p_149853_4_, p_149853_5_, p_149853_2_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockMycelium.java b/src/main/java/net/minecraft/block/BlockMycelium.java new file mode 100644 index 0000000..2230974 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockMycelium.java @@ -0,0 +1,103 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockMycelium extends Block +{ + @SideOnly(Side.CLIENT) + private IIcon field_150200_a; + @SideOnly(Side.CLIENT) + private IIcon field_150199_b; + private static final String __OBFID = "CL_00000273"; + + protected BlockMycelium() + { + super(Material.grass); + this.setTickRandomly(true); + this.setCreativeTab(CreativeTabs.tabBlock); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return p_149691_1_ == 1 ? this.field_150200_a : (p_149691_1_ == 0 ? Blocks.dirt.getBlockTextureFromSide(p_149691_1_) : this.blockIcon); + } + + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) + { + if (!p_149674_1_.isRemote) + { + if (p_149674_1_.getBlockLightValue(p_149674_2_, p_149674_3_ + 1, p_149674_4_) < 4 && p_149674_1_.getBlockLightOpacity(p_149674_2_, p_149674_3_ + 1, p_149674_4_) > 2) + { + p_149674_1_.setBlock(p_149674_2_, p_149674_3_, p_149674_4_, Blocks.dirt); + } + else if (p_149674_1_.getBlockLightValue(p_149674_2_, p_149674_3_ + 1, p_149674_4_) >= 9) + { + for (int l = 0; l < 4; ++l) + { + int i1 = p_149674_2_ + p_149674_5_.nextInt(3) - 1; + int j1 = p_149674_3_ + p_149674_5_.nextInt(5) - 3; + int k1 = p_149674_4_ + p_149674_5_.nextInt(3) - 1; + Block block = p_149674_1_.getBlock(i1, j1 + 1, k1); + + if (p_149674_1_.getBlock(i1, j1, k1) == Blocks.dirt && p_149674_1_.getBlockMetadata(i1, j1, k1) == 0 && p_149674_1_.getBlockLightValue(i1, j1 + 1, k1) >= 4 && p_149674_1_.getBlockLightOpacity(i1, j1 + 1, k1) <= 2) + { + p_149674_1_.setBlock(i1, j1, k1, this); + } + } + } + } + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return Blocks.dirt.getItemDropped(0, p_149650_2_, p_149650_3_); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess p_149673_1_, int p_149673_2_, int p_149673_3_, int p_149673_4_, int p_149673_5_) + { + if (p_149673_5_ == 1) + { + return this.field_150200_a; + } + else if (p_149673_5_ == 0) + { + return Blocks.dirt.getBlockTextureFromSide(p_149673_5_); + } + else + { + Material material = p_149673_1_.getBlock(p_149673_2_, p_149673_3_ + 1, p_149673_4_).getMaterial(); + return material != Material.snow && material != Material.craftedSnow ? this.blockIcon : this.field_150199_b; + } + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.blockIcon = p_149651_1_.registerIcon(this.getTextureName() + "_side"); + this.field_150200_a = p_149651_1_.registerIcon(this.getTextureName() + "_top"); + this.field_150199_b = p_149651_1_.registerIcon("grass_side_snowed"); + } + + @SideOnly(Side.CLIENT) + public void randomDisplayTick(World p_149734_1_, int p_149734_2_, int p_149734_3_, int p_149734_4_, Random p_149734_5_) + { + super.randomDisplayTick(p_149734_1_, p_149734_2_, p_149734_3_, p_149734_4_, p_149734_5_); + + if (p_149734_5_.nextInt(10) == 0) + { + p_149734_1_.spawnParticle("townaura", (double)((float)p_149734_2_ + p_149734_5_.nextFloat()), (double)((float)p_149734_3_ + 1.1F), (double)((float)p_149734_4_ + p_149734_5_.nextFloat()), 0.0D, 0.0D, 0.0D); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockNetherWart.java b/src/main/java/net/minecraft/block/BlockNetherWart.java new file mode 100644 index 0000000..ba0c9d5 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockNetherWart.java @@ -0,0 +1,135 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.Random; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public class BlockNetherWart extends BlockBush +{ + @SideOnly(Side.CLIENT) + private IIcon[] field_149883_a; + private static final String __OBFID = "CL_00000274"; + + protected BlockNetherWart() + { + this.setTickRandomly(true); + float f = 0.5F; + this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.25F, 0.5F + f); + this.setCreativeTab((CreativeTabs)null); + } + + protected boolean canPlaceBlockOn(Block p_149854_1_) + { + return p_149854_1_ == Blocks.soul_sand; + } + + public boolean canBlockStay(World p_149718_1_, int p_149718_2_, int p_149718_3_, int p_149718_4_) + { + return super.canBlockStay(p_149718_1_, p_149718_2_, p_149718_3_, p_149718_4_); + } + + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) + { + int l = p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_); + + if (l < 3 && p_149674_5_.nextInt(10) == 0) + { + ++l; + p_149674_1_.setBlockMetadataWithNotify(p_149674_2_, p_149674_3_, p_149674_4_, l, 2); + } + + super.updateTick(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, p_149674_5_); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return p_149691_2_ >= 3 ? this.field_149883_a[2] : (p_149691_2_ > 0 ? this.field_149883_a[1] : this.field_149883_a[0]); + } + + public int getRenderType() + { + return 6; + } + + public void dropBlockAsItemWithChance(World p_149690_1_, int p_149690_2_, int p_149690_3_, int p_149690_4_, int p_149690_5_, float p_149690_6_, int p_149690_7_) + { + super.dropBlockAsItemWithChance(p_149690_1_, p_149690_2_, p_149690_3_, p_149690_4_, p_149690_5_, p_149690_6_, p_149690_7_); + + if (false && !p_149690_1_.isRemote) + { + int j1 = 1; + + if (p_149690_5_ >= 3) + { + j1 = 2 + p_149690_1_.rand.nextInt(3); + + if (p_149690_7_ > 0) + { + j1 += p_149690_1_.rand.nextInt(p_149690_7_ + 1); + } + } + + for (int k1 = 0; k1 < j1; ++k1) + { + this.dropBlockAsItem(p_149690_1_, p_149690_2_, p_149690_3_, p_149690_4_, new ItemStack(Items.nether_wart)); + } + } + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return null; + } + + public int quantityDropped(Random p_149745_1_) + { + return 0; + } + + @SideOnly(Side.CLIENT) + public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) + { + return Items.nether_wart; + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.field_149883_a = new IIcon[3]; + + for (int i = 0; i < this.field_149883_a.length; ++i) + { + this.field_149883_a[i] = p_149651_1_.registerIcon(this.getTextureName() + "_stage_" + i); + } + } + + @Override + public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) + { + ArrayList ret = new ArrayList(); + int count = 1; + + if (metadata >= 3) + { + count = 2 + world.rand.nextInt(3) + (fortune > 0 ? world.rand.nextInt(fortune + 1) : 0); + } + + for (int i = 0; i < count; i++) + { + ret.add(new ItemStack(Items.nether_wart)); + } + + return ret; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockNetherrack.java b/src/main/java/net/minecraft/block/BlockNetherrack.java new file mode 100644 index 0000000..99468de --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockNetherrack.java @@ -0,0 +1,21 @@ +package net.minecraft.block; + +import net.minecraft.block.material.MapColor; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; + +public class BlockNetherrack extends Block +{ + private static final String __OBFID = "CL_00000275"; + + public BlockNetherrack() + { + super(Material.rock); + this.setCreativeTab(CreativeTabs.tabBlock); + } + + public MapColor getMapColor(int p_149728_1_) + { + return MapColor.netherrackColor; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockNewLeaf.java b/src/main/java/net/minecraft/block/BlockNewLeaf.java new file mode 100644 index 0000000..08f4156 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockNewLeaf.java @@ -0,0 +1,69 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +public class BlockNewLeaf extends BlockLeaves +{ + public static final String[][] field_150132_N = new String[][] {{"leaves_acacia", "leaves_big_oak"}, {"leaves_acacia_opaque", "leaves_big_oak_opaque"}}; + public static final String[] field_150133_O = new String[] {"acacia", "big_oak"}; + private static final String __OBFID = "CL_00000276"; + + protected void func_150124_c(World p_150124_1_, int p_150124_2_, int p_150124_3_, int p_150124_4_, int p_150124_5_, int p_150124_6_) + { + if ((p_150124_5_ & 3) == 1 && p_150124_1_.rand.nextInt(p_150124_6_) == 0) + { + this.dropBlockAsItem(p_150124_1_, p_150124_2_, p_150124_3_, p_150124_4_, new ItemStack(Items.apple, 1, 0)); + } + } + + public int damageDropped(int p_149692_1_) + { + return super.damageDropped(p_149692_1_) + 4; + } + + public int getDamageValue(World p_149643_1_, int p_149643_2_, int p_149643_3_, int p_149643_4_) + { + return p_149643_1_.getBlockMetadata(p_149643_2_, p_149643_3_, p_149643_4_) & 3; + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return (p_149691_2_ & 3) == 1 ? this.field_150129_M[this.field_150127_b][1] : this.field_150129_M[this.field_150127_b][0]; + } + + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_) + { + p_149666_3_.add(new ItemStack(p_149666_1_, 1, 0)); + p_149666_3_.add(new ItemStack(p_149666_1_, 1, 1)); + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + for (int i = 0; i < field_150132_N.length; ++i) + { + this.field_150129_M[i] = new IIcon[field_150132_N[i].length]; + + for (int j = 0; j < field_150132_N[i].length; ++j) + { + this.field_150129_M[i][j] = p_149651_1_.registerIcon(field_150132_N[i][j]); + } + } + } + + public String[] func_150125_e() + { + return field_150133_O; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockNewLog.java b/src/main/java/net/minecraft/block/BlockNewLog.java new file mode 100644 index 0000000..96b8433 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockNewLog.java @@ -0,0 +1,36 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +public class BlockNewLog extends BlockLog +{ + public static final String[] field_150169_M = new String[] {"acacia", "big_oak"}; + private static final String __OBFID = "CL_00000277"; + + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_) + { + p_149666_3_.add(new ItemStack(p_149666_1_, 1, 0)); + p_149666_3_.add(new ItemStack(p_149666_1_, 1, 1)); + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.field_150167_a = new IIcon[field_150169_M.length]; + this.field_150166_b = new IIcon[field_150169_M.length]; + + for (int i = 0; i < this.field_150167_a.length; ++i) + { + this.field_150167_a[i] = p_149651_1_.registerIcon(this.getTextureName() + "_" + field_150169_M[i]); + this.field_150166_b[i] = p_149651_1_.registerIcon(this.getTextureName() + "_" + field_150169_M[i] + "_top"); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockNote.java b/src/main/java/net/minecraft/block/BlockNote.java new file mode 100644 index 0000000..2154c6e --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockNote.java @@ -0,0 +1,103 @@ +package net.minecraft.block; + +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityNote; +import net.minecraft.world.World; + +public class BlockNote extends BlockContainer +{ + private static final String __OBFID = "CL_00000278"; + + public BlockNote() + { + super(Material.wood); + this.setCreativeTab(CreativeTabs.tabRedstone); + } + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) + { + boolean flag = p_149695_1_.isBlockIndirectlyGettingPowered(p_149695_2_, p_149695_3_, p_149695_4_); + TileEntityNote tileentitynote = (TileEntityNote)p_149695_1_.getTileEntity(p_149695_2_, p_149695_3_, p_149695_4_); + + if (tileentitynote != null && tileentitynote.previousRedstoneState != flag) + { + if (flag) + { + tileentitynote.triggerNote(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_); + } + + tileentitynote.previousRedstoneState = flag; + } + } + + public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) + { + if (p_149727_1_.isRemote) + { + return true; + } + else + { + TileEntityNote tileentitynote = (TileEntityNote)p_149727_1_.getTileEntity(p_149727_2_, p_149727_3_, p_149727_4_); + + if (tileentitynote != null) + { + tileentitynote.changePitch(); + tileentitynote.triggerNote(p_149727_1_, p_149727_2_, p_149727_3_, p_149727_4_); + } + + return true; + } + } + + public void onBlockClicked(World p_149699_1_, int p_149699_2_, int p_149699_3_, int p_149699_4_, EntityPlayer p_149699_5_) + { + if (!p_149699_1_.isRemote) + { + TileEntityNote tileentitynote = (TileEntityNote)p_149699_1_.getTileEntity(p_149699_2_, p_149699_3_, p_149699_4_); + + if (tileentitynote != null) + { + tileentitynote.triggerNote(p_149699_1_, p_149699_2_, p_149699_3_, p_149699_4_); + } + } + } + + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) + { + return new TileEntityNote(); + } + + public boolean onBlockEventReceived(World p_149696_1_, int p_149696_2_, int p_149696_3_, int p_149696_4_, int p_149696_5_, int p_149696_6_) + { + float f = (float)Math.pow(2.0D, (double)(p_149696_6_ - 12) / 12.0D); + String s = "harp"; + + if (p_149696_5_ == 1) + { + s = "bd"; + } + + if (p_149696_5_ == 2) + { + s = "snare"; + } + + if (p_149696_5_ == 3) + { + s = "hat"; + } + + if (p_149696_5_ == 4) + { + s = "bassattack"; + } + + p_149696_1_.playSoundEffect((double)p_149696_2_ + 0.5D, (double)p_149696_3_ + 0.5D, (double)p_149696_4_ + 0.5D, "note." + s, 3.0F, f); + p_149696_1_.spawnParticle("note", (double)p_149696_2_ + 0.5D, (double)p_149696_3_ + 1.2D, (double)p_149696_4_ + 0.5D, (double)p_149696_6_ / 24.0D, 0.0D, 0.0D); + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockObsidian.java b/src/main/java/net/minecraft/block/BlockObsidian.java new file mode 100644 index 0000000..a17894d --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockObsidian.java @@ -0,0 +1,26 @@ +package net.minecraft.block; + +import java.util.Random; +import net.minecraft.block.material.MapColor; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; + +public class BlockObsidian extends BlockStone +{ + private static final String __OBFID = "CL_00000279"; + + public int quantityDropped(Random p_149745_1_) + { + return 1; + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return Item.getItemFromBlock(Blocks.obsidian); + } + + public MapColor getMapColor(int p_149728_1_) + { + return MapColor.obsidianColor; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockOldLeaf.java b/src/main/java/net/minecraft/block/BlockOldLeaf.java new file mode 100644 index 0000000..84eaeb0 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockOldLeaf.java @@ -0,0 +1,88 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.ColorizerFoliage; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockOldLeaf extends BlockLeaves +{ + public static final String[][] field_150130_N = new String[][] {{"leaves_oak", "leaves_spruce", "leaves_birch", "leaves_jungle"}, {"leaves_oak_opaque", "leaves_spruce_opaque", "leaves_birch_opaque", "leaves_jungle_opaque"}}; + public static final String[] field_150131_O = new String[] {"oak", "spruce", "birch", "jungle"}; + private static final String __OBFID = "CL_00000280"; + + @SideOnly(Side.CLIENT) + public int getRenderColor(int p_149741_1_) + { + return (p_149741_1_ & 3) == 1 ? ColorizerFoliage.getFoliageColorPine() : ((p_149741_1_ & 3) == 2 ? ColorizerFoliage.getFoliageColorBirch() : super.getRenderColor(p_149741_1_)); + } + + @SideOnly(Side.CLIENT) + public int colorMultiplier(IBlockAccess p_149720_1_, int p_149720_2_, int p_149720_3_, int p_149720_4_) + { + int l = p_149720_1_.getBlockMetadata(p_149720_2_, p_149720_3_, p_149720_4_); + return (l & 3) == 1 ? ColorizerFoliage.getFoliageColorPine() : ((l & 3) == 2 ? ColorizerFoliage.getFoliageColorBirch() : super.colorMultiplier(p_149720_1_, p_149720_2_, p_149720_3_, p_149720_4_)); + } + + protected void func_150124_c(World p_150124_1_, int p_150124_2_, int p_150124_3_, int p_150124_4_, int p_150124_5_, int p_150124_6_) + { + if ((p_150124_5_ & 3) == 0 && p_150124_1_.rand.nextInt(p_150124_6_) == 0) + { + this.dropBlockAsItem(p_150124_1_, p_150124_2_, p_150124_3_, p_150124_4_, new ItemStack(Items.apple, 1, 0)); + } + } + + protected int func_150123_b(int p_150123_1_) + { + int j = super.func_150123_b(p_150123_1_); + + if ((p_150123_1_ & 3) == 3) + { + j = 40; + } + + return j; + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return (p_149691_2_ & 3) == 1 ? this.field_150129_M[this.field_150127_b][1] : ((p_149691_2_ & 3) == 3 ? this.field_150129_M[this.field_150127_b][3] : ((p_149691_2_ & 3) == 2 ? this.field_150129_M[this.field_150127_b][2] : this.field_150129_M[this.field_150127_b][0])); + } + + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_) + { + p_149666_3_.add(new ItemStack(p_149666_1_, 1, 0)); + p_149666_3_.add(new ItemStack(p_149666_1_, 1, 1)); + p_149666_3_.add(new ItemStack(p_149666_1_, 1, 2)); + p_149666_3_.add(new ItemStack(p_149666_1_, 1, 3)); + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + for (int i = 0; i < field_150130_N.length; ++i) + { + this.field_150129_M[i] = new IIcon[field_150130_N[i].length]; + + for (int j = 0; j < field_150130_N[i].length; ++j) + { + this.field_150129_M[i][j] = p_149651_1_.registerIcon(field_150130_N[i][j]); + } + } + } + + public String[] func_150125_e() + { + return field_150131_O; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockOldLog.java b/src/main/java/net/minecraft/block/BlockOldLog.java new file mode 100644 index 0000000..b8353fd --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockOldLog.java @@ -0,0 +1,38 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +public class BlockOldLog extends BlockLog +{ + public static final String[] field_150168_M = new String[] {"oak", "spruce", "birch", "jungle"}; + private static final String __OBFID = "CL_00000281"; + + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_) + { + p_149666_3_.add(new ItemStack(p_149666_1_, 1, 0)); + p_149666_3_.add(new ItemStack(p_149666_1_, 1, 1)); + p_149666_3_.add(new ItemStack(p_149666_1_, 1, 2)); + p_149666_3_.add(new ItemStack(p_149666_1_, 1, 3)); + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.field_150167_a = new IIcon[field_150168_M.length]; + this.field_150166_b = new IIcon[field_150168_M.length]; + + for (int i = 0; i < this.field_150167_a.length; ++i) + { + this.field_150167_a[i] = p_149651_1_.registerIcon(this.getTextureName() + "_" + field_150168_M[i]); + this.field_150166_b[i] = p_149651_1_.registerIcon(this.getTextureName() + "_" + field_150168_M[i] + "_top"); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockOre.java b/src/main/java/net/minecraft/block/BlockOre.java new file mode 100644 index 0000000..8437880 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockOre.java @@ -0,0 +1,95 @@ +package net.minecraft.block; + +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.util.MathHelper; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockOre extends Block +{ + private static final String __OBFID = "CL_00000282"; + + public BlockOre() + { + super(Material.rock); + this.setCreativeTab(CreativeTabs.tabBlock); + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return this == Blocks.coal_ore ? Items.coal : (this == Blocks.diamond_ore ? Items.diamond : (this == Blocks.lapis_ore ? Items.dye : (this == Blocks.emerald_ore ? Items.emerald : (this == Blocks.quartz_ore ? Items.quartz : Item.getItemFromBlock(this))))); + } + + public int quantityDropped(Random p_149745_1_) + { + return this == Blocks.lapis_ore ? 4 + p_149745_1_.nextInt(5) : 1; + } + + public int quantityDroppedWithBonus(int p_149679_1_, Random p_149679_2_) + { + if (p_149679_1_ > 0 && Item.getItemFromBlock(this) != this.getItemDropped(0, p_149679_2_, p_149679_1_)) + { + int j = p_149679_2_.nextInt(p_149679_1_ + 2) - 1; + + if (j < 0) + { + j = 0; + } + + return this.quantityDropped(p_149679_2_) * (j + 1); + } + else + { + return this.quantityDropped(p_149679_2_); + } + } + + public void dropBlockAsItemWithChance(World p_149690_1_, int p_149690_2_, int p_149690_3_, int p_149690_4_, int p_149690_5_, float p_149690_6_, int p_149690_7_) + { + super.dropBlockAsItemWithChance(p_149690_1_, p_149690_2_, p_149690_3_, p_149690_4_, p_149690_5_, p_149690_6_, p_149690_7_); + } + + private Random rand = new Random(); + @Override + public int getExpDrop(IBlockAccess p_149690_1_, int p_149690_5_, int p_149690_7_) + { + if (this.getItemDropped(p_149690_5_, rand, p_149690_7_) != Item.getItemFromBlock(this)) + { + int j1 = 0; + + if (this == Blocks.coal_ore) + { + j1 = MathHelper.getRandomIntegerInRange(rand, 0, 2); + } + else if (this == Blocks.diamond_ore) + { + j1 = MathHelper.getRandomIntegerInRange(rand, 3, 7); + } + else if (this == Blocks.emerald_ore) + { + j1 = MathHelper.getRandomIntegerInRange(rand, 3, 7); + } + else if (this == Blocks.lapis_ore) + { + j1 = MathHelper.getRandomIntegerInRange(rand, 2, 5); + } + else if (this == Blocks.quartz_ore) + { + j1 = MathHelper.getRandomIntegerInRange(rand, 2, 5); + } + + return j1; + } + return 0; + } + + public int damageDropped(int p_149692_1_) + { + return this == Blocks.lapis_ore ? 4 : 0; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockPackedIce.java b/src/main/java/net/minecraft/block/BlockPackedIce.java new file mode 100644 index 0000000..2d43cb0 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockPackedIce.java @@ -0,0 +1,22 @@ +package net.minecraft.block; + +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; + +public class BlockPackedIce extends Block +{ + private static final String __OBFID = "CL_00000283"; + + public BlockPackedIce() + { + super(Material.packedIce); + this.slipperiness = 0.98F; + this.setCreativeTab(CreativeTabs.tabBlock); + } + + public int quantityDropped(Random p_149745_1_) + { + return 0; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockPane.java b/src/main/java/net/minecraft/block/BlockPane.java new file mode 100644 index 0000000..ac2e8f1 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockPane.java @@ -0,0 +1,197 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; +import static net.minecraftforge.common.util.ForgeDirection.*; + +public class BlockPane extends Block +{ + private final String field_150100_a; + private final boolean field_150099_b; + private final String field_150101_M; + @SideOnly(Side.CLIENT) + private IIcon field_150102_N; + private static final String __OBFID = "CL_00000322"; + + protected BlockPane(String p_i45432_1_, String p_i45432_2_, Material p_i45432_3_, boolean p_i45432_4_) + { + super(p_i45432_3_); + this.field_150100_a = p_i45432_2_; + this.field_150099_b = p_i45432_4_; + this.field_150101_M = p_i45432_1_; + this.setCreativeTab(CreativeTabs.tabDecorations); + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return !this.field_150099_b ? null : super.getItemDropped(p_149650_1_, p_149650_2_, p_149650_3_); + } + + public boolean isOpaqueCube() + { + return false; + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public int getRenderType() + { + return this.blockMaterial == Material.glass ? 41 : 18; + } + + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) + { + return p_149646_1_.getBlock(p_149646_2_, p_149646_3_, p_149646_4_) == this ? false : super.shouldSideBeRendered(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, p_149646_5_); + } + + public void addCollisionBoxesToList(World p_149743_1_, int p_149743_2_, int p_149743_3_, int p_149743_4_, AxisAlignedBB p_149743_5_, List p_149743_6_, Entity p_149743_7_) + { + boolean flag = this.canPaneConnectTo(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_ - 1, NORTH); + boolean flag1 = this.canPaneConnectTo(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_ + 1, SOUTH); + boolean flag2 = this.canPaneConnectTo(p_149743_1_, p_149743_2_ - 1, p_149743_3_, p_149743_4_, WEST ); + boolean flag3 = this.canPaneConnectTo(p_149743_1_, p_149743_2_ + 1, p_149743_3_, p_149743_4_, EAST ); + + if ((!flag2 || !flag3) && (flag2 || flag3 || flag || flag1)) + { + if (flag2 && !flag3) + { + this.setBlockBounds(0.0F, 0.0F, 0.4375F, 0.5F, 1.0F, 0.5625F); + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + } + else if (!flag2 && flag3) + { + this.setBlockBounds(0.5F, 0.0F, 0.4375F, 1.0F, 1.0F, 0.5625F); + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + } + } + else + { + this.setBlockBounds(0.0F, 0.0F, 0.4375F, 1.0F, 1.0F, 0.5625F); + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + } + + if ((!flag || !flag1) && (flag2 || flag3 || flag || flag1)) + { + if (flag && !flag1) + { + this.setBlockBounds(0.4375F, 0.0F, 0.0F, 0.5625F, 1.0F, 0.5F); + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + } + else if (!flag && flag1) + { + this.setBlockBounds(0.4375F, 0.0F, 0.5F, 0.5625F, 1.0F, 1.0F); + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + } + } + else + { + this.setBlockBounds(0.4375F, 0.0F, 0.0F, 0.5625F, 1.0F, 1.0F); + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + } + } + + public void setBlockBoundsForItemRender() + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + + public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) + { + float f = 0.4375F; + float f1 = 0.5625F; + float f2 = 0.4375F; + float f3 = 0.5625F; + boolean flag = this.canPaneConnectTo(p_149719_1_, p_149719_2_, p_149719_3_, p_149719_4_ - 1, NORTH); + boolean flag1 = this.canPaneConnectTo(p_149719_1_, p_149719_2_, p_149719_3_, p_149719_4_ + 1, SOUTH); + boolean flag2 = this.canPaneConnectTo(p_149719_1_, p_149719_2_ - 1, p_149719_3_, p_149719_4_, WEST ); + boolean flag3 = this.canPaneConnectTo(p_149719_1_, p_149719_2_ + 1, p_149719_3_, p_149719_4_, EAST ); + + if ((!flag2 || !flag3) && (flag2 || flag3 || flag || flag1)) + { + if (flag2 && !flag3) + { + f = 0.0F; + } + else if (!flag2 && flag3) + { + f1 = 1.0F; + } + } + else + { + f = 0.0F; + f1 = 1.0F; + } + + if ((!flag || !flag1) && (flag2 || flag3 || flag || flag1)) + { + if (flag && !flag1) + { + f2 = 0.0F; + } + else if (!flag && flag1) + { + f3 = 1.0F; + } + } + else + { + f2 = 0.0F; + f3 = 1.0F; + } + + this.setBlockBounds(f, 0.0F, f2, f1, 1.0F, f3); + } + + public final boolean canPaneConnectToBlock(Block p_150098_1_) + { + return p_150098_1_.func_149730_j() || p_150098_1_ == this || p_150098_1_ == Blocks.glass || p_150098_1_ == Blocks.stained_glass || p_150098_1_ == Blocks.stained_glass_pane || p_150098_1_ instanceof BlockPane; + } + + @SideOnly(Side.CLIENT) + public IIcon func_150097_e() + { + return this.field_150102_N; + } + + protected boolean canSilkHarvest() + { + return true; + } + + protected ItemStack createStackedBlock(int p_149644_1_) + { + return new ItemStack(Item.getItemFromBlock(this), 1, p_149644_1_); + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.blockIcon = p_149651_1_.registerIcon(this.field_150101_M); + this.field_150102_N = p_149651_1_.registerIcon(this.field_150100_a); + } + + public boolean canPaneConnectTo(IBlockAccess world, int x, int y, int z, ForgeDirection dir) + { + return canPaneConnectToBlock(world.getBlock(x, y, z)) || + world.isSideSolid(x, y, z, dir.getOpposite(), false); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockPistonBase.java b/src/main/java/net/minecraft/block/BlockPistonBase.java new file mode 100644 index 0000000..6e07fcb --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockPistonBase.java @@ -0,0 +1,510 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.server.management.PlayerManager; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityPiston; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.Facing; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockPistonBase extends Block +{ + private final boolean isSticky; + @SideOnly(Side.CLIENT) + private IIcon innerTopIcon; + @SideOnly(Side.CLIENT) + private IIcon bottomIcon; + @SideOnly(Side.CLIENT) + private IIcon topIcon; + private static final String __OBFID = "CL_00000366"; + + public BlockPistonBase(boolean p_i45443_1_) + { + super(Material.piston); + this.isSticky = p_i45443_1_; + this.setStepSound(soundTypePiston); + this.setHardness(0.5F); + this.setCreativeTab(CreativeTabs.tabRedstone); + } + + @SideOnly(Side.CLIENT) + public IIcon getPistonExtensionTexture() + { + return this.topIcon; + } + + @SideOnly(Side.CLIENT) + public void func_150070_b(float p_150070_1_, float p_150070_2_, float p_150070_3_, float p_150070_4_, float p_150070_5_, float p_150070_6_) + { + this.setBlockBounds(p_150070_1_, p_150070_2_, p_150070_3_, p_150070_4_, p_150070_5_, p_150070_6_); + } + + public int getRenderType() + { + return 16; + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + int k = getPistonOrientation(p_149691_2_); + return k > 5 ? this.topIcon : (p_149691_1_ == k ? (!isExtended(p_149691_2_) && this.minX <= 0.0D && this.minY <= 0.0D && this.minZ <= 0.0D && this.maxX >= 1.0D && this.maxY >= 1.0D && this.maxZ >= 1.0D ? this.topIcon : this.innerTopIcon) : (p_149691_1_ == Facing.oppositeSide[k] ? this.bottomIcon : this.blockIcon)); + } + + @SideOnly(Side.CLIENT) + public static IIcon getPistonBaseIcon(String p_150074_0_) + { + return p_150074_0_ == "piston_side" ? Blocks.piston.blockIcon : (p_150074_0_ == "piston_top_normal" ? Blocks.piston.topIcon : (p_150074_0_ == "piston_top_sticky" ? Blocks.sticky_piston.topIcon : (p_150074_0_ == "piston_inner" ? Blocks.piston.innerTopIcon : null))); + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.blockIcon = p_149651_1_.registerIcon("piston_side"); + this.topIcon = p_149651_1_.registerIcon(this.isSticky ? "piston_top_sticky" : "piston_top_normal"); + this.innerTopIcon = p_149651_1_.registerIcon("piston_inner"); + this.bottomIcon = p_149651_1_.registerIcon("piston_bottom"); + } + + public boolean isOpaqueCube() + { + return false; + } + + public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) + { + return false; + } + + public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_) + { + int l = determineOrientation(p_149689_1_, p_149689_2_, p_149689_3_, p_149689_4_, p_149689_5_); + p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, l, 2); + + if (!p_149689_1_.isRemote) + { + this.updatePistonState(p_149689_1_, p_149689_2_, p_149689_3_, p_149689_4_); + } + } + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) + { + if (!p_149695_1_.isRemote) + { + this.updatePistonState(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_); + } + } + + public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_) + { + if (!p_149726_1_.isRemote && p_149726_1_.getTileEntity(p_149726_2_, p_149726_3_, p_149726_4_) == null) + { + this.updatePistonState(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_); + } + } + + private void updatePistonState(World p_150078_1_, int p_150078_2_, int p_150078_3_, int p_150078_4_) + { + int l = p_150078_1_.getBlockMetadata(p_150078_2_, p_150078_3_, p_150078_4_); + int i1 = getPistonOrientation(l); + + if (i1 != 7) + { + boolean flag = this.isIndirectlyPowered(p_150078_1_, p_150078_2_, p_150078_3_, p_150078_4_, i1); + + if (flag && !isExtended(l)) + { + if (canExtend(p_150078_1_, p_150078_2_, p_150078_3_, p_150078_4_, i1)) + { + p_150078_1_.addBlockEvent(p_150078_2_, p_150078_3_, p_150078_4_, this, 0, i1); + } + } + else if (!flag && isExtended(l)) + { + p_150078_1_.setBlockMetadataWithNotify(p_150078_2_, p_150078_3_, p_150078_4_, i1, 2); + p_150078_1_.addBlockEvent(p_150078_2_, p_150078_3_, p_150078_4_, this, 1, i1); + } + } + } + + private boolean isIndirectlyPowered(World p_150072_1_, int p_150072_2_, int p_150072_3_, int p_150072_4_, int p_150072_5_) + { + return p_150072_5_ != 0 && p_150072_1_.getIndirectPowerOutput(p_150072_2_, p_150072_3_ - 1, p_150072_4_, 0) ? true : (p_150072_5_ != 1 && p_150072_1_.getIndirectPowerOutput(p_150072_2_, p_150072_3_ + 1, p_150072_4_, 1) ? true : (p_150072_5_ != 2 && p_150072_1_.getIndirectPowerOutput(p_150072_2_, p_150072_3_, p_150072_4_ - 1, 2) ? true : (p_150072_5_ != 3 && p_150072_1_.getIndirectPowerOutput(p_150072_2_, p_150072_3_, p_150072_4_ + 1, 3) ? true : (p_150072_5_ != 5 && p_150072_1_.getIndirectPowerOutput(p_150072_2_ + 1, p_150072_3_, p_150072_4_, 5) ? true : (p_150072_5_ != 4 && p_150072_1_.getIndirectPowerOutput(p_150072_2_ - 1, p_150072_3_, p_150072_4_, 4) ? true : (p_150072_1_.getIndirectPowerOutput(p_150072_2_, p_150072_3_, p_150072_4_, 0) ? true : (p_150072_1_.getIndirectPowerOutput(p_150072_2_, p_150072_3_ + 2, p_150072_4_, 1) ? true : (p_150072_1_.getIndirectPowerOutput(p_150072_2_, p_150072_3_ + 1, p_150072_4_ - 1, 2) ? true : (p_150072_1_.getIndirectPowerOutput(p_150072_2_, p_150072_3_ + 1, p_150072_4_ + 1, 3) ? true : (p_150072_1_.getIndirectPowerOutput(p_150072_2_ - 1, p_150072_3_ + 1, p_150072_4_, 4) ? true : p_150072_1_.getIndirectPowerOutput(p_150072_2_ + 1, p_150072_3_ + 1, p_150072_4_, 5))))))))))); + } + + public boolean onBlockEventReceived(World p_149696_1_, int p_149696_2_, int p_149696_3_, int p_149696_4_, int p_149696_5_, int p_149696_6_) + { + if (!p_149696_1_.isRemote) + { + boolean flag = this.isIndirectlyPowered(p_149696_1_, p_149696_2_, p_149696_3_, p_149696_4_, p_149696_6_); + + if (flag && p_149696_5_ == 1) + { + p_149696_1_.setBlockMetadataWithNotify(p_149696_2_, p_149696_3_, p_149696_4_, p_149696_6_ | 8, 2); + return false; + } + + if (!flag && p_149696_5_ == 0) + { + return false; + } + } + + if (p_149696_5_ == 0) + { + if (!this.tryExtend(p_149696_1_, p_149696_2_, p_149696_3_, p_149696_4_, p_149696_6_)) + { + return false; + } + + p_149696_1_.setBlockMetadataWithNotify(p_149696_2_, p_149696_3_, p_149696_4_, p_149696_6_ | 8, 2); + p_149696_1_.playSoundEffect((double)p_149696_2_ + 0.5D, (double)p_149696_3_ + 0.5D, (double)p_149696_4_ + 0.5D, "tile.piston.out", 0.5F, p_149696_1_.rand.nextFloat() * 0.25F + 0.6F); + } + else if (p_149696_5_ == 1) + { + TileEntity tileentity1 = p_149696_1_.getTileEntity(p_149696_2_ + Facing.offsetsXForSide[p_149696_6_], p_149696_3_ + Facing.offsetsYForSide[p_149696_6_], p_149696_4_ + Facing.offsetsZForSide[p_149696_6_]); + + if (tileentity1 instanceof TileEntityPiston) + { + ((TileEntityPiston)tileentity1).clearPistonTileEntity(); + } + + p_149696_1_.setBlock(p_149696_2_, p_149696_3_, p_149696_4_, Blocks.piston_extension, p_149696_6_, 3); + p_149696_1_.setTileEntity(p_149696_2_, p_149696_3_, p_149696_4_, BlockPistonMoving.getTileEntity(this, p_149696_6_, p_149696_6_, false, true)); + + if (this.isSticky) + { + int j1 = p_149696_2_ + Facing.offsetsXForSide[p_149696_6_] * 2; + int k1 = p_149696_3_ + Facing.offsetsYForSide[p_149696_6_] * 2; + int l1 = p_149696_4_ + Facing.offsetsZForSide[p_149696_6_] * 2; + Block block = p_149696_1_.getBlock(j1, k1, l1); + int i2 = p_149696_1_.getBlockMetadata(j1, k1, l1); + boolean flag1 = false; + + if (block == Blocks.piston_extension) + { + TileEntity tileentity = p_149696_1_.getTileEntity(j1, k1, l1); + + if (tileentity instanceof TileEntityPiston) + { + TileEntityPiston tileentitypiston = (TileEntityPiston)tileentity; + + if (tileentitypiston.getPistonOrientation() == p_149696_6_ && tileentitypiston.isExtending()) + { + tileentitypiston.clearPistonTileEntity(); + block = tileentitypiston.getStoredBlockID(); + i2 = tileentitypiston.getBlockMetadata(); + flag1 = true; + } + } + } + + if (!flag1 && block.getMaterial() != Material.air && canPushBlock(block, p_149696_1_, j1, k1, l1, false) && (block.getMobilityFlag() == 0 || block == Blocks.piston || block == Blocks.sticky_piston)) + { + p_149696_2_ += Facing.offsetsXForSide[p_149696_6_]; + p_149696_3_ += Facing.offsetsYForSide[p_149696_6_]; + p_149696_4_ += Facing.offsetsZForSide[p_149696_6_]; + p_149696_1_.setBlock(p_149696_2_, p_149696_3_, p_149696_4_, Blocks.piston_extension, i2, 3); + p_149696_1_.setTileEntity(p_149696_2_, p_149696_3_, p_149696_4_, BlockPistonMoving.getTileEntity(block, i2, p_149696_6_, false, false)); + p_149696_1_.setBlockToAir(j1, k1, l1); + } + else if (!flag1) + { + p_149696_1_.setBlockToAir(p_149696_2_ + Facing.offsetsXForSide[p_149696_6_], p_149696_3_ + Facing.offsetsYForSide[p_149696_6_], p_149696_4_ + Facing.offsetsZForSide[p_149696_6_]); + } + } + else + { + p_149696_1_.setBlockToAir(p_149696_2_ + Facing.offsetsXForSide[p_149696_6_], p_149696_3_ + Facing.offsetsYForSide[p_149696_6_], p_149696_4_ + Facing.offsetsZForSide[p_149696_6_]); + } + + p_149696_1_.playSoundEffect((double)p_149696_2_ + 0.5D, (double)p_149696_3_ + 0.5D, (double)p_149696_4_ + 0.5D, "tile.piston.in", 0.5F, p_149696_1_.rand.nextFloat() * 0.15F + 0.6F); + } + + return true; + } + + public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) + { + int l = p_149719_1_.getBlockMetadata(p_149719_2_, p_149719_3_, p_149719_4_); + + if (isExtended(l)) + { + float f = 0.25F; + + switch (getPistonOrientation(l)) + { + case 0: + this.setBlockBounds(0.0F, 0.25F, 0.0F, 1.0F, 1.0F, 1.0F); + break; + case 1: + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.75F, 1.0F); + break; + case 2: + this.setBlockBounds(0.0F, 0.0F, 0.25F, 1.0F, 1.0F, 1.0F); + break; + case 3: + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.75F); + break; + case 4: + this.setBlockBounds(0.25F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + break; + case 5: + this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.75F, 1.0F, 1.0F); + } + } + else + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + } + + public void setBlockBoundsForItemRender() + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + + public void addCollisionBoxesToList(World p_149743_1_, int p_149743_2_, int p_149743_3_, int p_149743_4_, AxisAlignedBB p_149743_5_, List p_149743_6_, Entity p_149743_7_) + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) + { + this.setBlockBoundsBasedOnState(p_149668_1_, p_149668_2_, p_149668_3_, p_149668_4_); + return super.getCollisionBoundingBoxFromPool(p_149668_1_, p_149668_2_, p_149668_3_, p_149668_4_); + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public static int getPistonOrientation(int p_150076_0_) + { + return p_150076_0_ & 7; + } + + public static boolean isExtended(int p_150075_0_) + { + return (p_150075_0_ & 8) != 0; + } + + public static int determineOrientation(World p_150071_0_, int p_150071_1_, int p_150071_2_, int p_150071_3_, EntityLivingBase p_150071_4_) + { + if (MathHelper.abs((float)p_150071_4_.posX - (float)p_150071_1_) < 2.0F && MathHelper.abs((float)p_150071_4_.posZ - (float)p_150071_3_) < 2.0F) + { + double d0 = p_150071_4_.posY + 1.82D - (double)p_150071_4_.yOffset; + + if (d0 - (double)p_150071_2_ > 2.0D) + { + return 1; + } + + if ((double)p_150071_2_ - d0 > 0.0D) + { + return 0; + } + } + + int l = MathHelper.floor_double((double)(p_150071_4_.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + return l == 0 ? 2 : (l == 1 ? 5 : (l == 2 ? 3 : (l == 3 ? 4 : 0))); + } + + private static boolean canPushBlock(Block p_150080_0_, World p_150080_1_, int p_150080_2_, int p_150080_3_, int p_150080_4_, boolean p_150080_5_) + { + if (p_150080_0_ == Blocks.obsidian) + { + return false; + } + else + { + if (p_150080_0_ != Blocks.piston && p_150080_0_ != Blocks.sticky_piston) + { + if (p_150080_0_.getBlockHardness(p_150080_1_, p_150080_2_, p_150080_3_, p_150080_4_) == -1.0F) + { + return false; + } + + if (p_150080_0_.getMobilityFlag() == 2) + { + return false; + } + + if (p_150080_0_.getMobilityFlag() == 1) + { + if (!p_150080_5_) + { + return false; + } + + return true; + } + } + else if (isExtended(p_150080_1_.getBlockMetadata(p_150080_2_, p_150080_3_, p_150080_4_))) + { + return false; + } + + return !(p_150080_1_.getBlock(p_150080_2_, p_150080_3_, p_150080_4_).hasTileEntity(p_150080_1_.getBlockMetadata(p_150080_2_, p_150080_3_, p_150080_4_))); + + } + } + + private static boolean canExtend(World p_150077_0_, int p_150077_1_, int p_150077_2_, int p_150077_3_, int p_150077_4_) + { + int i1 = p_150077_1_ + Facing.offsetsXForSide[p_150077_4_]; + int j1 = p_150077_2_ + Facing.offsetsYForSide[p_150077_4_]; + int k1 = p_150077_3_ + Facing.offsetsZForSide[p_150077_4_]; + int l1 = 0; + + while (true) + { + if (l1 < 13) + { + if (j1 <= 0 || j1 >= p_150077_0_.getHeight()) + { + return false; + } + + Block block = p_150077_0_.getBlock(i1, j1, k1); + + if (!block.isAir(p_150077_0_, i1, j1, k1)) + { + if (!canPushBlock(block, p_150077_0_, i1, j1, k1, true)) + { + return false; + } + + if (block.getMobilityFlag() != 1) + { + if (l1 == 12) + { + return false; + } + + i1 += Facing.offsetsXForSide[p_150077_4_]; + j1 += Facing.offsetsYForSide[p_150077_4_]; + k1 += Facing.offsetsZForSide[p_150077_4_]; + ++l1; + continue; + } + } + } + + return true; + } + } + + private boolean tryExtend(World p_150079_1_, int p_150079_2_, int p_150079_3_, int p_150079_4_, int p_150079_5_) + { + int i1 = p_150079_2_ + Facing.offsetsXForSide[p_150079_5_]; + int j1 = p_150079_3_ + Facing.offsetsYForSide[p_150079_5_]; + int k1 = p_150079_4_ + Facing.offsetsZForSide[p_150079_5_]; + int l1 = 0; + + while (true) + { + if (l1 < 13) + { + if (j1 <= 0 || j1 >= p_150079_1_.getHeight()) + { + return false; + } + + Block block = p_150079_1_.getBlock(i1, j1, k1); + + if (!block.isAir(p_150079_1_, i1, j1, k1)) + { + if (!canPushBlock(block, p_150079_1_, i1, j1, k1, true)) + { + return false; + } + + if (block.getMobilityFlag() != 1) + { + if (l1 == 12) + { + return false; + } + + i1 += Facing.offsetsXForSide[p_150079_5_]; + j1 += Facing.offsetsYForSide[p_150079_5_]; + k1 += Facing.offsetsZForSide[p_150079_5_]; + ++l1; + continue; + } + + //With our change to how snowballs are dropped this needs to disallow to mimic vanilla behavior. + float chance = block instanceof BlockSnow ? -1.0f : 1.0f; + block.dropBlockAsItemWithChance(p_150079_1_, i1, j1, k1, p_150079_1_.getBlockMetadata(i1, j1, k1), chance, 0); + p_150079_1_.setBlockToAir(i1, j1, k1); + } + } + + l1 = i1; + int k3 = j1; + int i2 = k1; + int j2 = 0; + Block[] ablock; + int k2; + int l2; + int i3; + + for (ablock = new Block[13]; i1 != p_150079_2_ || j1 != p_150079_3_ || k1 != p_150079_4_; k1 = i3) + { + k2 = i1 - Facing.offsetsXForSide[p_150079_5_]; + l2 = j1 - Facing.offsetsYForSide[p_150079_5_]; + i3 = k1 - Facing.offsetsZForSide[p_150079_5_]; + Block block1 = p_150079_1_.getBlock(k2, l2, i3); + int j3 = p_150079_1_.getBlockMetadata(k2, l2, i3); + + if (block1 == this && k2 == p_150079_2_ && l2 == p_150079_3_ && i3 == p_150079_4_) + { + p_150079_1_.setBlock(i1, j1, k1, Blocks.piston_extension, p_150079_5_ | (this.isSticky ? 8 : 0), 4); + p_150079_1_.setTileEntity(i1, j1, k1, BlockPistonMoving.getTileEntity(Blocks.piston_head, p_150079_5_ | (this.isSticky ? 8 : 0), p_150079_5_, true, false)); + } + else + { + p_150079_1_.setBlock(i1, j1, k1, Blocks.piston_extension, j3, 4); + p_150079_1_.setTileEntity(i1, j1, k1, BlockPistonMoving.getTileEntity(block1, j3, p_150079_5_, true, false)); + } + + ablock[j2++] = block1; + i1 = k2; + j1 = l2; + } + + i1 = l1; + j1 = k3; + k1 = i2; + + for (j2 = 0; i1 != p_150079_2_ || j1 != p_150079_3_ || k1 != p_150079_4_; k1 = i3) + { + k2 = i1 - Facing.offsetsXForSide[p_150079_5_]; + l2 = j1 - Facing.offsetsYForSide[p_150079_5_]; + i3 = k1 - Facing.offsetsZForSide[p_150079_5_]; + p_150079_1_.notifyBlocksOfNeighborChange(k2, l2, i3, ablock[j2++]); + i1 = k2; + j1 = l2; + } + + return true; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockPistonExtension.java b/src/main/java/net/minecraft/block/BlockPistonExtension.java new file mode 100644 index 0000000..d004181 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockPistonExtension.java @@ -0,0 +1,225 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.Facing; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockPistonExtension extends Block +{ + @SideOnly(Side.CLIENT) + private IIcon field_150088_a; + private static final String __OBFID = "CL_00000367"; + + public BlockPistonExtension() + { + super(Material.piston); + this.setStepSound(soundTypePiston); + this.setHardness(0.5F); + } + + @SideOnly(Side.CLIENT) + public void func_150086_a(IIcon p_150086_1_) + { + this.field_150088_a = p_150086_1_; + } + + public void onBlockHarvested(World p_149681_1_, int p_149681_2_, int p_149681_3_, int p_149681_4_, int p_149681_5_, EntityPlayer p_149681_6_) + { + if (p_149681_6_.capabilities.isCreativeMode) + { + int i1 = getDirectionMeta(p_149681_5_); + Block block = p_149681_1_.getBlock(p_149681_2_ - Facing.offsetsXForSide[i1], p_149681_3_ - Facing.offsetsYForSide[i1], p_149681_4_ - Facing.offsetsZForSide[i1]); + + if (block == Blocks.piston || block == Blocks.sticky_piston) + { + p_149681_1_.setBlockToAir(p_149681_2_ - Facing.offsetsXForSide[i1], p_149681_3_ - Facing.offsetsYForSide[i1], p_149681_4_ - Facing.offsetsZForSide[i1]); + } + } + + super.onBlockHarvested(p_149681_1_, p_149681_2_, p_149681_3_, p_149681_4_, p_149681_5_, p_149681_6_); + } + + public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) + { + super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_); + int i1 = Facing.oppositeSide[getDirectionMeta(p_149749_6_)]; + p_149749_2_ += Facing.offsetsXForSide[i1]; + p_149749_3_ += Facing.offsetsYForSide[i1]; + p_149749_4_ += Facing.offsetsZForSide[i1]; + Block block1 = p_149749_1_.getBlock(p_149749_2_, p_149749_3_, p_149749_4_); + + if (block1 == Blocks.piston || block1 == Blocks.sticky_piston) + { + p_149749_6_ = p_149749_1_.getBlockMetadata(p_149749_2_, p_149749_3_, p_149749_4_); + + if (BlockPistonBase.isExtended(p_149749_6_)) + { + block1.dropBlockAsItem(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_6_, 0); + p_149749_1_.setBlockToAir(p_149749_2_, p_149749_3_, p_149749_4_); + } + } + } + + @SideOnly(Side.CLIENT) + public void func_150087_e() + { + this.field_150088_a = null; + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + int k = getDirectionMeta(p_149691_2_); + return p_149691_1_ == k ? (this.field_150088_a != null ? this.field_150088_a : ((p_149691_2_ & 8) != 0 ? BlockPistonBase.getPistonBaseIcon("piston_top_sticky") : BlockPistonBase.getPistonBaseIcon("piston_top_normal"))) : (k < 6 && p_149691_1_ == Facing.oppositeSide[k] ? BlockPistonBase.getPistonBaseIcon("piston_top_normal") : BlockPistonBase.getPistonBaseIcon("piston_side")); + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) {} + + public int getRenderType() + { + return 17; + } + + public boolean isOpaqueCube() + { + return false; + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public boolean canPlaceBlockAt(World p_149742_1_, int p_149742_2_, int p_149742_3_, int p_149742_4_) + { + return false; + } + + public boolean canPlaceBlockOnSide(World p_149707_1_, int p_149707_2_, int p_149707_3_, int p_149707_4_, int p_149707_5_) + { + return false; + } + + public int quantityDropped(Random p_149745_1_) + { + return 0; + } + + public void addCollisionBoxesToList(World p_149743_1_, int p_149743_2_, int p_149743_3_, int p_149743_4_, AxisAlignedBB p_149743_5_, List p_149743_6_, Entity p_149743_7_) + { + int l = p_149743_1_.getBlockMetadata(p_149743_2_, p_149743_3_, p_149743_4_); + float f = 0.25F; + float f1 = 0.375F; + float f2 = 0.625F; + float f3 = 0.25F; + float f4 = 0.75F; + + switch (getDirectionMeta(l)) + { + case 0: + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.25F, 1.0F); + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + this.setBlockBounds(0.375F, 0.25F, 0.375F, 0.625F, 1.0F, 0.625F); + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + break; + case 1: + this.setBlockBounds(0.0F, 0.75F, 0.0F, 1.0F, 1.0F, 1.0F); + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + this.setBlockBounds(0.375F, 0.0F, 0.375F, 0.625F, 0.75F, 0.625F); + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + break; + case 2: + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.25F); + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + this.setBlockBounds(0.25F, 0.375F, 0.25F, 0.75F, 0.625F, 1.0F); + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + break; + case 3: + this.setBlockBounds(0.0F, 0.0F, 0.75F, 1.0F, 1.0F, 1.0F); + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + this.setBlockBounds(0.25F, 0.375F, 0.0F, 0.75F, 0.625F, 0.75F); + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + break; + case 4: + this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.25F, 1.0F, 1.0F); + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + this.setBlockBounds(0.375F, 0.25F, 0.25F, 0.625F, 0.75F, 1.0F); + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + break; + case 5: + this.setBlockBounds(0.75F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + this.setBlockBounds(0.0F, 0.375F, 0.25F, 0.75F, 0.625F, 0.75F); + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + } + + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + + public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) + { + int l = p_149719_1_.getBlockMetadata(p_149719_2_, p_149719_3_, p_149719_4_); + float f = 0.25F; + + switch (getDirectionMeta(l)) + { + case 0: + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.25F, 1.0F); + break; + case 1: + this.setBlockBounds(0.0F, 0.75F, 0.0F, 1.0F, 1.0F, 1.0F); + break; + case 2: + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.25F); + break; + case 3: + this.setBlockBounds(0.0F, 0.0F, 0.75F, 1.0F, 1.0F, 1.0F); + break; + case 4: + this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.25F, 1.0F, 1.0F); + break; + case 5: + this.setBlockBounds(0.75F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + } + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) + { + int l = getDirectionMeta(p_149695_1_.getBlockMetadata(p_149695_2_, p_149695_3_, p_149695_4_)); + Block block1 = p_149695_1_.getBlock(p_149695_2_ - Facing.offsetsXForSide[l], p_149695_3_ - Facing.offsetsYForSide[l], p_149695_4_ - Facing.offsetsZForSide[l]); + + if (block1 != Blocks.piston && block1 != Blocks.sticky_piston) + { + p_149695_1_.setBlockToAir(p_149695_2_, p_149695_3_, p_149695_4_); + } + else + { + block1.onNeighborBlockChange(p_149695_1_, p_149695_2_ - Facing.offsetsXForSide[l], p_149695_3_ - Facing.offsetsYForSide[l], p_149695_4_ - Facing.offsetsZForSide[l], p_149695_5_); + } + } + + public static int getDirectionMeta(int p_150085_0_) + { + return p_150085_0_ & 7; + } + + @SideOnly(Side.CLIENT) + public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) + { + int l = p_149694_1_.getBlockMetadata(p_149694_2_, p_149694_3_, p_149694_4_); + return (l & 8) != 0 ? Item.getItemFromBlock(Blocks.sticky_piston) : Item.getItemFromBlock(Blocks.piston); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockPistonMoving.java b/src/main/java/net/minecraft/block/BlockPistonMoving.java new file mode 100644 index 0000000..d1152f4 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockPistonMoving.java @@ -0,0 +1,234 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityPiston; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.Facing; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockPistonMoving extends BlockContainer +{ + private static final String __OBFID = "CL_00000368"; + + public BlockPistonMoving() + { + super(Material.piston); + this.setHardness(-1.0F); + } + + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) + { + return null; + } + + public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_) {} + + public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) + { + TileEntity tileentity = p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_); + + if (tileentity instanceof TileEntityPiston) + { + ((TileEntityPiston)tileentity).clearPistonTileEntity(); + } + else + { + super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_); + } + } + + public boolean canPlaceBlockAt(World p_149742_1_, int p_149742_2_, int p_149742_3_, int p_149742_4_) + { + return false; + } + + public boolean canPlaceBlockOnSide(World p_149707_1_, int p_149707_2_, int p_149707_3_, int p_149707_4_, int p_149707_5_) + { + return false; + } + + public int getRenderType() + { + return -1; + } + + public boolean isOpaqueCube() + { + return false; + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) + { + if (!p_149727_1_.isRemote && p_149727_1_.getTileEntity(p_149727_2_, p_149727_3_, p_149727_4_) == null) + { + p_149727_1_.setBlockToAir(p_149727_2_, p_149727_3_, p_149727_4_); + return true; + } + else + { + return false; + } + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return null; + } + + public void dropBlockAsItemWithChance(World p_149690_1_, int p_149690_2_, int p_149690_3_, int p_149690_4_, int p_149690_5_, float p_149690_6_, int p_149690_7_) + { + if (!p_149690_1_.isRemote) + { + TileEntityPiston tileentitypiston = this.func_149963_e(p_149690_1_, p_149690_2_, p_149690_3_, p_149690_4_); + + if (tileentitypiston != null) + { + tileentitypiston.getStoredBlockID().dropBlockAsItem(p_149690_1_, p_149690_2_, p_149690_3_, p_149690_4_, tileentitypiston.getBlockMetadata(), 0); + } + } + } + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) + { + if (!p_149695_1_.isRemote) + { + p_149695_1_.getTileEntity(p_149695_2_, p_149695_3_, p_149695_4_); + } + } + + public static TileEntity getTileEntity(Block p_149962_0_, int p_149962_1_, int p_149962_2_, boolean p_149962_3_, boolean p_149962_4_) + { + return new TileEntityPiston(p_149962_0_, p_149962_1_, p_149962_2_, p_149962_3_, p_149962_4_); + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) + { + TileEntityPiston tileentitypiston = this.func_149963_e(p_149668_1_, p_149668_2_, p_149668_3_, p_149668_4_); + + if (tileentitypiston == null) + { + return null; + } + else + { + float f = tileentitypiston.func_145860_a(0.0F); + + if (tileentitypiston.isExtending()) + { + f = 1.0F - f; + } + + return this.func_149964_a(p_149668_1_, p_149668_2_, p_149668_3_, p_149668_4_, tileentitypiston.getStoredBlockID(), f, tileentitypiston.getPistonOrientation()); + } + } + + public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) + { + TileEntityPiston tileentitypiston = this.func_149963_e(p_149719_1_, p_149719_2_, p_149719_3_, p_149719_4_); + + if (tileentitypiston != null) + { + Block block = tileentitypiston.getStoredBlockID(); + + if (block == this || block.getMaterial() == Material.air) + { + return; + } + + block.setBlockBoundsBasedOnState(p_149719_1_, p_149719_2_, p_149719_3_, p_149719_4_); + float f = tileentitypiston.func_145860_a(0.0F); + + if (tileentitypiston.isExtending()) + { + f = 1.0F - f; + } + + int l = tileentitypiston.getPistonOrientation(); + this.minX = block.getBlockBoundsMinX() - (double)((float)Facing.offsetsXForSide[l] * f); + this.minY = block.getBlockBoundsMinY() - (double)((float)Facing.offsetsYForSide[l] * f); + this.minZ = block.getBlockBoundsMinZ() - (double)((float)Facing.offsetsZForSide[l] * f); + this.maxX = block.getBlockBoundsMaxX() - (double)((float)Facing.offsetsXForSide[l] * f); + this.maxY = block.getBlockBoundsMaxY() - (double)((float)Facing.offsetsYForSide[l] * f); + this.maxZ = block.getBlockBoundsMaxZ() - (double)((float)Facing.offsetsZForSide[l] * f); + } + } + + public AxisAlignedBB func_149964_a(World p_149964_1_, int p_149964_2_, int p_149964_3_, int p_149964_4_, Block p_149964_5_, float p_149964_6_, int p_149964_7_) + { + if (p_149964_5_ != this && p_149964_5_.getMaterial() != Material.air) + { + AxisAlignedBB axisalignedbb = p_149964_5_.getCollisionBoundingBoxFromPool(p_149964_1_, p_149964_2_, p_149964_3_, p_149964_4_); + + if (axisalignedbb == null) + { + return null; + } + else + { + if (Facing.offsetsXForSide[p_149964_7_] < 0) + { + axisalignedbb.minX -= (double)((float)Facing.offsetsXForSide[p_149964_7_] * p_149964_6_); + } + else + { + axisalignedbb.maxX -= (double)((float)Facing.offsetsXForSide[p_149964_7_] * p_149964_6_); + } + + if (Facing.offsetsYForSide[p_149964_7_] < 0) + { + axisalignedbb.minY -= (double)((float)Facing.offsetsYForSide[p_149964_7_] * p_149964_6_); + } + else + { + axisalignedbb.maxY -= (double)((float)Facing.offsetsYForSide[p_149964_7_] * p_149964_6_); + } + + if (Facing.offsetsZForSide[p_149964_7_] < 0) + { + axisalignedbb.minZ -= (double)((float)Facing.offsetsZForSide[p_149964_7_] * p_149964_6_); + } + else + { + axisalignedbb.maxZ -= (double)((float)Facing.offsetsZForSide[p_149964_7_] * p_149964_6_); + } + + return axisalignedbb; + } + } + else + { + return null; + } + } + + private TileEntityPiston func_149963_e(IBlockAccess p_149963_1_, int p_149963_2_, int p_149963_3_, int p_149963_4_) + { + TileEntity tileentity = p_149963_1_.getTileEntity(p_149963_2_, p_149963_3_, p_149963_4_); + return tileentity instanceof TileEntityPiston ? (TileEntityPiston)tileentity : null; + } + + @SideOnly(Side.CLIENT) + public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) + { + return Item.getItemById(0); + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.blockIcon = p_149651_1_.registerIcon("piston_top_normal"); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockPortal.java b/src/main/java/net/minecraft/block/BlockPortal.java new file mode 100644 index 0000000..2436b0f --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockPortal.java @@ -0,0 +1,413 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemMonsterPlacer; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.Direction; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockPortal extends BlockBreakable +{ + public static final int[][] field_150001_a = new int[][] {new int[0], {3, 1}, {2, 0}}; + private static final String __OBFID = "CL_00000284"; + + public BlockPortal() + { + super("portal", Material.portal, false); + this.setTickRandomly(true); + } + + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) + { + super.updateTick(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, p_149674_5_); + + if (p_149674_1_.provider.isSurfaceWorld() && p_149674_1_.getGameRules().getGameRuleBooleanValue("doMobSpawning") && p_149674_5_.nextInt(2000) < p_149674_1_.difficultySetting.getDifficultyId()) + { + int l; + + for (l = p_149674_3_; !World.doesBlockHaveSolidTopSurface(p_149674_1_, p_149674_2_, l, p_149674_4_) && l > 0; --l) + { + ; + } + + if (l > 0 && !p_149674_1_.getBlock(p_149674_2_, l + 1, p_149674_4_).isNormalCube()) + { + Entity entity = ItemMonsterPlacer.spawnCreature(p_149674_1_, 57, (double)p_149674_2_ + 0.5D, (double)l + 1.1D, (double)p_149674_4_ + 0.5D); + + if (entity != null) + { + entity.timeUntilPortal = entity.getPortalCooldown(); + } + } + } + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) + { + return null; + } + + public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) + { + int l = func_149999_b(p_149719_1_.getBlockMetadata(p_149719_2_, p_149719_3_, p_149719_4_)); + + if (l == 0) + { + if (p_149719_1_.getBlock(p_149719_2_ - 1, p_149719_3_, p_149719_4_) != this && p_149719_1_.getBlock(p_149719_2_ + 1, p_149719_3_, p_149719_4_) != this) + { + l = 2; + } + else + { + l = 1; + } + + if (p_149719_1_ instanceof World && !((World)p_149719_1_).isRemote) + { + ((World)p_149719_1_).setBlockMetadataWithNotify(p_149719_2_, p_149719_3_, p_149719_4_, l, 2); + } + } + + float f = 0.125F; + float f1 = 0.125F; + + if (l == 1) + { + f = 0.5F; + } + + if (l == 2) + { + f1 = 0.5F; + } + + this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f1, 0.5F + f, 1.0F, 0.5F + f1); + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public boolean func_150000_e(World p_150000_1_, int p_150000_2_, int p_150000_3_, int p_150000_4_) + { + BlockPortal.Size size = new BlockPortal.Size(p_150000_1_, p_150000_2_, p_150000_3_, p_150000_4_, 1); + BlockPortal.Size size1 = new BlockPortal.Size(p_150000_1_, p_150000_2_, p_150000_3_, p_150000_4_, 2); + + if (size.func_150860_b() && size.field_150864_e == 0) + { + size.func_150859_c(); + return true; + } + else if (size1.func_150860_b() && size1.field_150864_e == 0) + { + size1.func_150859_c(); + return true; + } + else + { + return false; + } + } + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) + { + int l = func_149999_b(p_149695_1_.getBlockMetadata(p_149695_2_, p_149695_3_, p_149695_4_)); + BlockPortal.Size size = new BlockPortal.Size(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, 1); + BlockPortal.Size size1 = new BlockPortal.Size(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, 2); + + if (l == 1 && (!size.func_150860_b() || size.field_150864_e < size.field_150868_h * size.field_150862_g)) + { + p_149695_1_.setBlock(p_149695_2_, p_149695_3_, p_149695_4_, Blocks.air); + } + else if (l == 2 && (!size1.func_150860_b() || size1.field_150864_e < size1.field_150868_h * size1.field_150862_g)) + { + p_149695_1_.setBlock(p_149695_2_, p_149695_3_, p_149695_4_, Blocks.air); + } + else if (l == 0 && !size.func_150860_b() && !size1.func_150860_b()) + { + p_149695_1_.setBlock(p_149695_2_, p_149695_3_, p_149695_4_, Blocks.air); + } + } + + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) + { + int i1 = 0; + + if (p_149646_1_.getBlock(p_149646_2_, p_149646_3_, p_149646_4_) == this) + { + i1 = func_149999_b(p_149646_1_.getBlockMetadata(p_149646_2_, p_149646_3_, p_149646_4_)); + + if (i1 == 0) + { + return false; + } + + if (i1 == 2 && p_149646_5_ != 5 && p_149646_5_ != 4) + { + return false; + } + + if (i1 == 1 && p_149646_5_ != 3 && p_149646_5_ != 2) + { + return false; + } + } + + boolean flag = p_149646_1_.getBlock(p_149646_2_ - 1, p_149646_3_, p_149646_4_) == this && p_149646_1_.getBlock(p_149646_2_ - 2, p_149646_3_, p_149646_4_) != this; + boolean flag1 = p_149646_1_.getBlock(p_149646_2_ + 1, p_149646_3_, p_149646_4_) == this && p_149646_1_.getBlock(p_149646_2_ + 2, p_149646_3_, p_149646_4_) != this; + boolean flag2 = p_149646_1_.getBlock(p_149646_2_, p_149646_3_, p_149646_4_ - 1) == this && p_149646_1_.getBlock(p_149646_2_, p_149646_3_, p_149646_4_ - 2) != this; + boolean flag3 = p_149646_1_.getBlock(p_149646_2_, p_149646_3_, p_149646_4_ + 1) == this && p_149646_1_.getBlock(p_149646_2_, p_149646_3_, p_149646_4_ + 2) != this; + boolean flag4 = flag || flag1 || i1 == 1; + boolean flag5 = flag2 || flag3 || i1 == 2; + return flag4 && p_149646_5_ == 4 ? true : (flag4 && p_149646_5_ == 5 ? true : (flag5 && p_149646_5_ == 2 ? true : flag5 && p_149646_5_ == 3)); + } + + public int quantityDropped(Random p_149745_1_) + { + return 0; + } + + public void onEntityCollidedWithBlock(World p_149670_1_, int p_149670_2_, int p_149670_3_, int p_149670_4_, Entity p_149670_5_) + { + if (p_149670_5_.ridingEntity == null && p_149670_5_.riddenByEntity == null) + { + p_149670_5_.setInPortal(); + } + } + + @SideOnly(Side.CLIENT) + public int getRenderBlockPass() + { + return 1; + } + + @SideOnly(Side.CLIENT) + public void randomDisplayTick(World p_149734_1_, int p_149734_2_, int p_149734_3_, int p_149734_4_, Random p_149734_5_) + { + if (p_149734_5_.nextInt(100) == 0) + { + p_149734_1_.playSound((double)p_149734_2_ + 0.5D, (double)p_149734_3_ + 0.5D, (double)p_149734_4_ + 0.5D, "portal.portal", 0.5F, p_149734_5_.nextFloat() * 0.4F + 0.8F, false); + } + + for (int l = 0; l < 4; ++l) + { + double d0 = (double)((float)p_149734_2_ + p_149734_5_.nextFloat()); + double d1 = (double)((float)p_149734_3_ + p_149734_5_.nextFloat()); + double d2 = (double)((float)p_149734_4_ + p_149734_5_.nextFloat()); + double d3 = 0.0D; + double d4 = 0.0D; + double d5 = 0.0D; + int i1 = p_149734_5_.nextInt(2) * 2 - 1; + d3 = ((double)p_149734_5_.nextFloat() - 0.5D) * 0.5D; + d4 = ((double)p_149734_5_.nextFloat() - 0.5D) * 0.5D; + d5 = ((double)p_149734_5_.nextFloat() - 0.5D) * 0.5D; + + if (p_149734_1_.getBlock(p_149734_2_ - 1, p_149734_3_, p_149734_4_) != this && p_149734_1_.getBlock(p_149734_2_ + 1, p_149734_3_, p_149734_4_) != this) + { + d0 = (double)p_149734_2_ + 0.5D + 0.25D * (double)i1; + d3 = (double)(p_149734_5_.nextFloat() * 2.0F * (float)i1); + } + else + { + d2 = (double)p_149734_4_ + 0.5D + 0.25D * (double)i1; + d5 = (double)(p_149734_5_.nextFloat() * 2.0F * (float)i1); + } + + p_149734_1_.spawnParticle("portal", d0, d1, d2, d3, d4, d5); + } + } + + public static int func_149999_b(int p_149999_0_) + { + return p_149999_0_ & 3; + } + + @SideOnly(Side.CLIENT) + public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) + { + return Item.getItemById(0); + } + + public static class Size + { + private final World field_150867_a; + private final int field_150865_b; + private final int field_150866_c; + private final int field_150863_d; + private int field_150864_e = 0; + private ChunkCoordinates field_150861_f; + private int field_150862_g; + private int field_150868_h; + private static final String __OBFID = "CL_00000285"; + + public Size(World p_i45415_1_, int p_i45415_2_, int p_i45415_3_, int p_i45415_4_, int p_i45415_5_) + { + this.field_150867_a = p_i45415_1_; + this.field_150865_b = p_i45415_5_; + this.field_150863_d = BlockPortal.field_150001_a[p_i45415_5_][0]; + this.field_150866_c = BlockPortal.field_150001_a[p_i45415_5_][1]; + + for (int i1 = p_i45415_3_; p_i45415_3_ > i1 - 21 && p_i45415_3_ > 0 && this.func_150857_a(p_i45415_1_.getBlock(p_i45415_2_, p_i45415_3_ - 1, p_i45415_4_)); --p_i45415_3_) + { + ; + } + + int j1 = this.func_150853_a(p_i45415_2_, p_i45415_3_, p_i45415_4_, this.field_150863_d) - 1; + + if (j1 >= 0) + { + this.field_150861_f = new ChunkCoordinates(p_i45415_2_ + j1 * Direction.offsetX[this.field_150863_d], p_i45415_3_, p_i45415_4_ + j1 * Direction.offsetZ[this.field_150863_d]); + this.field_150868_h = this.func_150853_a(this.field_150861_f.posX, this.field_150861_f.posY, this.field_150861_f.posZ, this.field_150866_c); + + if (this.field_150868_h < 2 || this.field_150868_h > 21) + { + this.field_150861_f = null; + this.field_150868_h = 0; + } + } + + if (this.field_150861_f != null) + { + this.field_150862_g = this.func_150858_a(); + } + } + + protected int func_150853_a(int p_150853_1_, int p_150853_2_, int p_150853_3_, int p_150853_4_) + { + int j1 = Direction.offsetX[p_150853_4_]; + int k1 = Direction.offsetZ[p_150853_4_]; + int i1; + Block block; + + for (i1 = 0; i1 < 22; ++i1) + { + block = this.field_150867_a.getBlock(p_150853_1_ + j1 * i1, p_150853_2_, p_150853_3_ + k1 * i1); + + if (!this.func_150857_a(block)) + { + break; + } + + Block block1 = this.field_150867_a.getBlock(p_150853_1_ + j1 * i1, p_150853_2_ - 1, p_150853_3_ + k1 * i1); + + if (block1 != Blocks.obsidian) + { + break; + } + } + + block = this.field_150867_a.getBlock(p_150853_1_ + j1 * i1, p_150853_2_, p_150853_3_ + k1 * i1); + return block == Blocks.obsidian ? i1 : 0; + } + + protected int func_150858_a() + { + int i; + int j; + int k; + int l; + label56: + + for (this.field_150862_g = 0; this.field_150862_g < 21; ++this.field_150862_g) + { + i = this.field_150861_f.posY + this.field_150862_g; + + for (j = 0; j < this.field_150868_h; ++j) + { + k = this.field_150861_f.posX + j * Direction.offsetX[BlockPortal.field_150001_a[this.field_150865_b][1]]; + l = this.field_150861_f.posZ + j * Direction.offsetZ[BlockPortal.field_150001_a[this.field_150865_b][1]]; + Block block = this.field_150867_a.getBlock(k, i, l); + + if (!this.func_150857_a(block)) + { + break label56; + } + + if (block == Blocks.portal) + { + ++this.field_150864_e; + } + + if (j == 0) + { + block = this.field_150867_a.getBlock(k + Direction.offsetX[BlockPortal.field_150001_a[this.field_150865_b][0]], i, l + Direction.offsetZ[BlockPortal.field_150001_a[this.field_150865_b][0]]); + + if (block != Blocks.obsidian) + { + break label56; + } + } + else if (j == this.field_150868_h - 1) + { + block = this.field_150867_a.getBlock(k + Direction.offsetX[BlockPortal.field_150001_a[this.field_150865_b][1]], i, l + Direction.offsetZ[BlockPortal.field_150001_a[this.field_150865_b][1]]); + + if (block != Blocks.obsidian) + { + break label56; + } + } + } + } + + for (i = 0; i < this.field_150868_h; ++i) + { + j = this.field_150861_f.posX + i * Direction.offsetX[BlockPortal.field_150001_a[this.field_150865_b][1]]; + k = this.field_150861_f.posY + this.field_150862_g; + l = this.field_150861_f.posZ + i * Direction.offsetZ[BlockPortal.field_150001_a[this.field_150865_b][1]]; + + if (this.field_150867_a.getBlock(j, k, l) != Blocks.obsidian) + { + this.field_150862_g = 0; + break; + } + } + + if (this.field_150862_g <= 21 && this.field_150862_g >= 3) + { + return this.field_150862_g; + } + else + { + this.field_150861_f = null; + this.field_150868_h = 0; + this.field_150862_g = 0; + return 0; + } + } + + protected boolean func_150857_a(Block p_150857_1_) + { + return p_150857_1_.blockMaterial == Material.air || p_150857_1_ == Blocks.fire || p_150857_1_ == Blocks.portal; + } + + public boolean func_150860_b() + { + return this.field_150861_f != null && this.field_150868_h >= 2 && this.field_150868_h <= 21 && this.field_150862_g >= 3 && this.field_150862_g <= 21; + } + + public void func_150859_c() + { + for (int i = 0; i < this.field_150868_h; ++i) + { + int j = this.field_150861_f.posX + Direction.offsetX[this.field_150866_c] * i; + int k = this.field_150861_f.posZ + Direction.offsetZ[this.field_150866_c] * i; + + for (int l = 0; l < this.field_150862_g; ++l) + { + int i1 = this.field_150861_f.posY + l; + this.field_150867_a.setBlock(j, i1, k, Blocks.portal, this.field_150865_b, 2); + } + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockPotato.java b/src/main/java/net/minecraft/block/BlockPotato.java new file mode 100644 index 0000000..9f9a680 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockPotato.java @@ -0,0 +1,69 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +public class BlockPotato extends BlockCrops +{ + @SideOnly(Side.CLIENT) + private IIcon[] field_149869_a; + private static final String __OBFID = "CL_00000286"; + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + if (p_149691_2_ < 7) + { + if (p_149691_2_ == 6) + { + p_149691_2_ = 5; + } + + return this.field_149869_a[p_149691_2_ >> 1]; + } + else + { + return this.field_149869_a[3]; + } + } + + protected Item func_149866_i() + { + return Items.potato; + } + + protected Item func_149865_P() + { + return Items.potato; + } + + public void dropBlockAsItemWithChance(World p_149690_1_, int p_149690_2_, int p_149690_3_, int p_149690_4_, int p_149690_5_, float p_149690_6_, int p_149690_7_) + { + super.dropBlockAsItemWithChance(p_149690_1_, p_149690_2_, p_149690_3_, p_149690_4_, p_149690_5_, p_149690_6_, p_149690_7_); + + if (!p_149690_1_.isRemote) + { + if (p_149690_5_ >= 7 && p_149690_1_.rand.nextInt(50) == 0) + { + this.dropBlockAsItem(p_149690_1_, p_149690_2_, p_149690_3_, p_149690_4_, new ItemStack(Items.poisonous_potato)); + } + } + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.field_149869_a = new IIcon[4]; + + for (int i = 0; i < this.field_149869_a.length; ++i) + { + this.field_149869_a[i] = p_149651_1_.registerIcon(this.getTextureName() + "_stage_" + i); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockPressurePlate.java b/src/main/java/net/minecraft/block/BlockPressurePlate.java new file mode 100644 index 0000000..74c8078 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockPressurePlate.java @@ -0,0 +1,77 @@ +package net.minecraft.block; + +import java.util.Iterator; +import java.util.List; +import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; + +public class BlockPressurePlate extends BlockBasePressurePlate +{ + private BlockPressurePlate.Sensitivity field_150069_a; + private static final String __OBFID = "CL_00000289"; + + protected BlockPressurePlate(String p_i45418_1_, Material p_i45418_2_, BlockPressurePlate.Sensitivity p_i45418_3_) + { + super(p_i45418_1_, p_i45418_2_); + this.field_150069_a = p_i45418_3_; + } + + protected int func_150066_d(int p_150066_1_) + { + return p_150066_1_ > 0 ? 1 : 0; + } + + protected int func_150060_c(int p_150060_1_) + { + return p_150060_1_ == 1 ? 15 : 0; + } + + protected int func_150065_e(World p_150065_1_, int p_150065_2_, int p_150065_3_, int p_150065_4_) + { + List list = null; + + if (this.field_150069_a == BlockPressurePlate.Sensitivity.everything) + { + list = p_150065_1_.getEntitiesWithinAABBExcludingEntity((Entity)null, this.func_150061_a(p_150065_2_, p_150065_3_, p_150065_4_)); + } + + if (this.field_150069_a == BlockPressurePlate.Sensitivity.mobs) + { + list = p_150065_1_.getEntitiesWithinAABB(EntityLivingBase.class, this.func_150061_a(p_150065_2_, p_150065_3_, p_150065_4_)); + } + + if (this.field_150069_a == BlockPressurePlate.Sensitivity.players) + { + list = p_150065_1_.getEntitiesWithinAABB(EntityPlayer.class, this.func_150061_a(p_150065_2_, p_150065_3_, p_150065_4_)); + } + + if (list != null && !list.isEmpty()) + { + Iterator iterator = list.iterator(); + + while (iterator.hasNext()) + { + Entity entity = (Entity)iterator.next(); + + if (!entity.doesEntityNotTriggerPressurePlate()) + { + return 15; + } + } + } + + return 0; + } + + public static enum Sensitivity + { + everything, + mobs, + players; + + private static final String __OBFID = "CL_00000290"; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockPressurePlateWeighted.java b/src/main/java/net/minecraft/block/BlockPressurePlateWeighted.java new file mode 100644 index 0000000..176676a --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockPressurePlateWeighted.java @@ -0,0 +1,48 @@ +package net.minecraft.block; + +import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class BlockPressurePlateWeighted extends BlockBasePressurePlate +{ + private final int field_150068_a; + private static final String __OBFID = "CL_00000334"; + + protected BlockPressurePlateWeighted(String p_i45436_1_, Material p_i45436_2_, int p_i45436_3_) + { + super(p_i45436_1_, p_i45436_2_); + this.field_150068_a = p_i45436_3_; + } + + protected int func_150065_e(World p_150065_1_, int p_150065_2_, int p_150065_3_, int p_150065_4_) + { + int l = Math.min(p_150065_1_.getEntitiesWithinAABB(Entity.class, this.func_150061_a(p_150065_2_, p_150065_3_, p_150065_4_)).size(), this.field_150068_a); + + if (l <= 0) + { + return 0; + } + else + { + float f = (float)Math.min(this.field_150068_a, l) / (float)this.field_150068_a; + return MathHelper.ceiling_float_int(f * 15.0F); + } + } + + protected int func_150060_c(int p_150060_1_) + { + return p_150060_1_; + } + + protected int func_150066_d(int p_150066_1_) + { + return p_150066_1_; + } + + public int tickRate(World p_149738_1_) + { + return 10; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockPumpkin.java b/src/main/java/net/minecraft/block/BlockPumpkin.java new file mode 100644 index 0000000..2e13cfc --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockPumpkin.java @@ -0,0 +1,132 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.monster.EntityIronGolem; +import net.minecraft.entity.monster.EntitySnowman; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class BlockPumpkin extends BlockDirectional +{ + private boolean field_149985_a; + @SideOnly(Side.CLIENT) + private IIcon field_149984_b; + @SideOnly(Side.CLIENT) + private IIcon field_149986_M; + private static final String __OBFID = "CL_00000291"; + + protected BlockPumpkin(boolean p_i45419_1_) + { + super(Material.gourd); + this.setTickRandomly(true); + this.field_149985_a = p_i45419_1_; + this.setCreativeTab(CreativeTabs.tabBlock); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return p_149691_1_ == 1 ? this.field_149984_b : (p_149691_1_ == 0 ? this.field_149984_b : (p_149691_2_ == 2 && p_149691_1_ == 2 ? this.field_149986_M : (p_149691_2_ == 3 && p_149691_1_ == 5 ? this.field_149986_M : (p_149691_2_ == 0 && p_149691_1_ == 3 ? this.field_149986_M : (p_149691_2_ == 1 && p_149691_1_ == 4 ? this.field_149986_M : this.blockIcon))))); + } + + public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_) + { + super.onBlockAdded(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_); + + if (p_149726_1_.getBlock(p_149726_2_, p_149726_3_ - 1, p_149726_4_) == Blocks.snow && p_149726_1_.getBlock(p_149726_2_, p_149726_3_ - 2, p_149726_4_) == Blocks.snow) + { + if (!p_149726_1_.isRemote) + { + p_149726_1_.setBlock(p_149726_2_, p_149726_3_, p_149726_4_, getBlockById(0), 0, 2); + p_149726_1_.setBlock(p_149726_2_, p_149726_3_ - 1, p_149726_4_, getBlockById(0), 0, 2); + p_149726_1_.setBlock(p_149726_2_, p_149726_3_ - 2, p_149726_4_, getBlockById(0), 0, 2); + EntitySnowman entitysnowman = new EntitySnowman(p_149726_1_); + entitysnowman.setLocationAndAngles((double)p_149726_2_ + 0.5D, (double)p_149726_3_ - 1.95D, (double)p_149726_4_ + 0.5D, 0.0F, 0.0F); + p_149726_1_.spawnEntityInWorld(entitysnowman); + p_149726_1_.notifyBlockChange(p_149726_2_, p_149726_3_, p_149726_4_, getBlockById(0)); + p_149726_1_.notifyBlockChange(p_149726_2_, p_149726_3_ - 1, p_149726_4_, getBlockById(0)); + p_149726_1_.notifyBlockChange(p_149726_2_, p_149726_3_ - 2, p_149726_4_, getBlockById(0)); + } + + for (int i1 = 0; i1 < 120; ++i1) + { + p_149726_1_.spawnParticle("snowshovel", (double)p_149726_2_ + p_149726_1_.rand.nextDouble(), (double)(p_149726_3_ - 2) + p_149726_1_.rand.nextDouble() * 2.5D, (double)p_149726_4_ + p_149726_1_.rand.nextDouble(), 0.0D, 0.0D, 0.0D); + } + } + else if (p_149726_1_.getBlock(p_149726_2_, p_149726_3_ - 1, p_149726_4_) == Blocks.iron_block && p_149726_1_.getBlock(p_149726_2_, p_149726_3_ - 2, p_149726_4_) == Blocks.iron_block) + { + boolean flag = p_149726_1_.getBlock(p_149726_2_ - 1, p_149726_3_ - 1, p_149726_4_) == Blocks.iron_block && p_149726_1_.getBlock(p_149726_2_ + 1, p_149726_3_ - 1, p_149726_4_) == Blocks.iron_block; + boolean flag1 = p_149726_1_.getBlock(p_149726_2_, p_149726_3_ - 1, p_149726_4_ - 1) == Blocks.iron_block && p_149726_1_.getBlock(p_149726_2_, p_149726_3_ - 1, p_149726_4_ + 1) == Blocks.iron_block; + + if (flag || flag1) + { + p_149726_1_.setBlock(p_149726_2_, p_149726_3_, p_149726_4_, getBlockById(0), 0, 2); + p_149726_1_.setBlock(p_149726_2_, p_149726_3_ - 1, p_149726_4_, getBlockById(0), 0, 2); + p_149726_1_.setBlock(p_149726_2_, p_149726_3_ - 2, p_149726_4_, getBlockById(0), 0, 2); + + if (flag) + { + p_149726_1_.setBlock(p_149726_2_ - 1, p_149726_3_ - 1, p_149726_4_, getBlockById(0), 0, 2); + p_149726_1_.setBlock(p_149726_2_ + 1, p_149726_3_ - 1, p_149726_4_, getBlockById(0), 0, 2); + } + else + { + p_149726_1_.setBlock(p_149726_2_, p_149726_3_ - 1, p_149726_4_ - 1, getBlockById(0), 0, 2); + p_149726_1_.setBlock(p_149726_2_, p_149726_3_ - 1, p_149726_4_ + 1, getBlockById(0), 0, 2); + } + + EntityIronGolem entityirongolem = new EntityIronGolem(p_149726_1_); + entityirongolem.setPlayerCreated(true); + entityirongolem.setLocationAndAngles((double)p_149726_2_ + 0.5D, (double)p_149726_3_ - 1.95D, (double)p_149726_4_ + 0.5D, 0.0F, 0.0F); + p_149726_1_.spawnEntityInWorld(entityirongolem); + + for (int l = 0; l < 120; ++l) + { + p_149726_1_.spawnParticle("snowballpoof", (double)p_149726_2_ + p_149726_1_.rand.nextDouble(), (double)(p_149726_3_ - 2) + p_149726_1_.rand.nextDouble() * 3.9D, (double)p_149726_4_ + p_149726_1_.rand.nextDouble(), 0.0D, 0.0D, 0.0D); + } + + p_149726_1_.notifyBlockChange(p_149726_2_, p_149726_3_, p_149726_4_, getBlockById(0)); + p_149726_1_.notifyBlockChange(p_149726_2_, p_149726_3_ - 1, p_149726_4_, getBlockById(0)); + p_149726_1_.notifyBlockChange(p_149726_2_, p_149726_3_ - 2, p_149726_4_, getBlockById(0)); + + if (flag) + { + p_149726_1_.notifyBlockChange(p_149726_2_ - 1, p_149726_3_ - 1, p_149726_4_, getBlockById(0)); + p_149726_1_.notifyBlockChange(p_149726_2_ + 1, p_149726_3_ - 1, p_149726_4_, getBlockById(0)); + } + else + { + p_149726_1_.notifyBlockChange(p_149726_2_, p_149726_3_ - 1, p_149726_4_ - 1, getBlockById(0)); + p_149726_1_.notifyBlockChange(p_149726_2_, p_149726_3_ - 1, p_149726_4_ + 1, getBlockById(0)); + } + } + } + } + + public boolean canPlaceBlockAt(World p_149742_1_, int p_149742_2_, int p_149742_3_, int p_149742_4_) + { + return p_149742_1_.getBlock(p_149742_2_, p_149742_3_, p_149742_4_).isReplaceable(p_149742_1_, p_149742_2_, p_149742_3_, p_149742_4_) && World.doesBlockHaveSolidTopSurface(p_149742_1_, p_149742_2_, p_149742_3_ - 1, p_149742_4_); + } + + public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_) + { + int l = MathHelper.floor_double((double)(p_149689_5_.rotationYaw * 4.0F / 360.0F) + 2.5D) & 3; + p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, l, 2); + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.field_149986_M = p_149651_1_.registerIcon(this.getTextureName() + "_face_" + (this.field_149985_a ? "on" : "off")); + this.field_149984_b = p_149651_1_.registerIcon(this.getTextureName() + "_top"); + this.blockIcon = p_149651_1_.registerIcon(this.getTextureName() + "_side"); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockQuartz.java b/src/main/java/net/minecraft/block/BlockQuartz.java new file mode 100644 index 0000000..17113f1 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockQuartz.java @@ -0,0 +1,142 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.block.material.MapColor; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +public class BlockQuartz extends Block +{ + public static final String[] field_150191_a = new String[] {"default", "chiseled", "lines"}; + private static final String[] field_150189_b = new String[] {"side", "chiseled", "lines", null, null}; + @SideOnly(Side.CLIENT) + private IIcon[] field_150192_M; + @SideOnly(Side.CLIENT) + private IIcon field_150193_N; + @SideOnly(Side.CLIENT) + private IIcon field_150194_O; + @SideOnly(Side.CLIENT) + private IIcon field_150190_P; + @SideOnly(Side.CLIENT) + private IIcon field_150188_Q; + private static final String __OBFID = "CL_00000292"; + + public BlockQuartz() + { + super(Material.rock); + this.setCreativeTab(CreativeTabs.tabBlock); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + if (p_149691_2_ != 2 && p_149691_2_ != 3 && p_149691_2_ != 4) + { + if (p_149691_1_ != 1 && (p_149691_1_ != 0 || p_149691_2_ != 1)) + { + if (p_149691_1_ == 0) + { + return this.field_150188_Q; + } + else + { + if (p_149691_2_ < 0 || p_149691_2_ >= this.field_150192_M.length) + { + p_149691_2_ = 0; + } + + return this.field_150192_M[p_149691_2_]; + } + } + else + { + return p_149691_2_ == 1 ? this.field_150193_N : this.field_150190_P; + } + } + else + { + return p_149691_2_ == 2 && (p_149691_1_ == 1 || p_149691_1_ == 0) ? this.field_150194_O : (p_149691_2_ == 3 && (p_149691_1_ == 5 || p_149691_1_ == 4) ? this.field_150194_O : (p_149691_2_ == 4 && (p_149691_1_ == 2 || p_149691_1_ == 3) ? this.field_150194_O : this.field_150192_M[p_149691_2_])); + } + } + + public int onBlockPlaced(World p_149660_1_, int p_149660_2_, int p_149660_3_, int p_149660_4_, int p_149660_5_, float p_149660_6_, float p_149660_7_, float p_149660_8_, int p_149660_9_) + { + if (p_149660_9_ == 2) + { + switch (p_149660_5_) + { + case 0: + case 1: + p_149660_9_ = 2; + break; + case 2: + case 3: + p_149660_9_ = 4; + break; + case 4: + case 5: + p_149660_9_ = 3; + } + } + + return p_149660_9_; + } + + public int damageDropped(int p_149692_1_) + { + return p_149692_1_ != 3 && p_149692_1_ != 4 ? p_149692_1_ : 2; + } + + protected ItemStack createStackedBlock(int p_149644_1_) + { + return p_149644_1_ != 3 && p_149644_1_ != 4 ? super.createStackedBlock(p_149644_1_) : new ItemStack(Item.getItemFromBlock(this), 1, 2); + } + + public int getRenderType() + { + return 39; + } + + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_) + { + p_149666_3_.add(new ItemStack(p_149666_1_, 1, 0)); + p_149666_3_.add(new ItemStack(p_149666_1_, 1, 1)); + p_149666_3_.add(new ItemStack(p_149666_1_, 1, 2)); + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.field_150192_M = new IIcon[field_150189_b.length]; + + for (int i = 0; i < this.field_150192_M.length; ++i) + { + if (field_150189_b[i] == null) + { + this.field_150192_M[i] = this.field_150192_M[i - 1]; + } + else + { + this.field_150192_M[i] = p_149651_1_.registerIcon(this.getTextureName() + "_" + field_150189_b[i]); + } + } + + this.field_150190_P = p_149651_1_.registerIcon(this.getTextureName() + "_" + "top"); + this.field_150193_N = p_149651_1_.registerIcon(this.getTextureName() + "_" + "chiseled_top"); + this.field_150194_O = p_149651_1_.registerIcon(this.getTextureName() + "_" + "lines_top"); + this.field_150188_Q = p_149651_1_.registerIcon(this.getTextureName() + "_" + "bottom"); + } + + public MapColor getMapColor(int p_149728_1_) + { + return MapColor.quartzColor; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockRail.java b/src/main/java/net/minecraft/block/BlockRail.java new file mode 100644 index 0000000..3219cab --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockRail.java @@ -0,0 +1,40 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +public class BlockRail extends BlockRailBase +{ + @SideOnly(Side.CLIENT) + private IIcon field_150056_b; + private static final String __OBFID = "CL_00000293"; + + protected BlockRail() + { + super(false); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return p_149691_2_ >= 6 ? this.field_150056_b : this.blockIcon; + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + super.registerBlockIcons(p_149651_1_); + this.field_150056_b = p_149651_1_.registerIcon(this.getTextureName() + "_turned"); + } + + protected void func_150048_a(World p_150048_1_, int p_150048_2_, int p_150048_3_, int p_150048_4_, int p_150048_5_, int p_150048_6_, Block p_150048_7_) + { + if (p_150048_7_.canProvidePower() && (new BlockRailBase.Rail(p_150048_1_, p_150048_2_, p_150048_3_, p_150048_4_)).func_150650_a() == 3) + { + this.func_150052_a(p_150048_1_, p_150048_2_, p_150048_3_, p_150048_4_, false); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockRailBase.java b/src/main/java/net/minecraft/block/BlockRailBase.java new file mode 100644 index 0000000..60812f3 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockRailBase.java @@ -0,0 +1,731 @@ +package net.minecraft.block; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.item.EntityMinecart; +import net.minecraft.init.Blocks; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.Vec3; +import net.minecraft.world.ChunkPosition; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public abstract class BlockRailBase extends Block +{ + protected final boolean field_150053_a; + private static final String __OBFID = "CL_00000195"; + + public static final boolean func_150049_b_(World p_150049_0_, int p_150049_1_, int p_150049_2_, int p_150049_3_) + { + return func_150051_a(p_150049_0_.getBlock(p_150049_1_, p_150049_2_, p_150049_3_)); + } + + public static final boolean func_150051_a(Block p_150051_0_) + { + return p_150051_0_ instanceof BlockRailBase; + } + + protected BlockRailBase(boolean p_i45389_1_) + { + super(Material.circuits); + this.field_150053_a = p_i45389_1_; + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F); + this.setCreativeTab(CreativeTabs.tabTransport); + } + + public boolean isPowered() + { + return this.field_150053_a; + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) + { + return null; + } + + public boolean isOpaqueCube() + { + return false; + } + + public MovingObjectPosition collisionRayTrace(World p_149731_1_, int p_149731_2_, int p_149731_3_, int p_149731_4_, Vec3 p_149731_5_, Vec3 p_149731_6_) + { + this.setBlockBoundsBasedOnState(p_149731_1_, p_149731_2_, p_149731_3_, p_149731_4_); + return super.collisionRayTrace(p_149731_1_, p_149731_2_, p_149731_3_, p_149731_4_, p_149731_5_, p_149731_6_); + } + + public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) + { + int l = p_149719_1_.getBlockMetadata(p_149719_2_, p_149719_3_, p_149719_4_); + + if (l >= 2 && l <= 5) + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.625F, 1.0F); + } + else + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F); + } + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public int getRenderType() + { + return renderType; + } + + public int quantityDropped(Random p_149745_1_) + { + return 1; + } + + public boolean canPlaceBlockAt(World p_149742_1_, int p_149742_2_, int p_149742_3_, int p_149742_4_) + { + return World.doesBlockHaveSolidTopSurface(p_149742_1_, p_149742_2_, p_149742_3_ - 1, p_149742_4_); + } + + public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_) + { + if (!p_149726_1_.isRemote) + { + this.func_150052_a(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_, true); + + if (this.field_150053_a) + { + this.onNeighborBlockChange(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_, this); + } + } + } + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) + { + if (!p_149695_1_.isRemote) + { + int l = p_149695_1_.getBlockMetadata(p_149695_2_, p_149695_3_, p_149695_4_); + int i1 = l; + + if (this.field_150053_a) + { + i1 = l & 7; + } + + boolean flag = false; + + if (!World.doesBlockHaveSolidTopSurface(p_149695_1_, p_149695_2_, p_149695_3_ - 1, p_149695_4_)) + { + flag = true; + } + + if (i1 == 2 && !World.doesBlockHaveSolidTopSurface(p_149695_1_, p_149695_2_ + 1, p_149695_3_, p_149695_4_)) + { + flag = true; + } + + if (i1 == 3 && !World.doesBlockHaveSolidTopSurface(p_149695_1_, p_149695_2_ - 1, p_149695_3_, p_149695_4_)) + { + flag = true; + } + + if (i1 == 4 && !World.doesBlockHaveSolidTopSurface(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_ - 1)) + { + flag = true; + } + + if (i1 == 5 && !World.doesBlockHaveSolidTopSurface(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_ + 1)) + { + flag = true; + } + + if (flag) + { + this.dropBlockAsItem(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, p_149695_1_.getBlockMetadata(p_149695_2_, p_149695_3_, p_149695_4_), 0); + p_149695_1_.setBlockToAir(p_149695_2_, p_149695_3_, p_149695_4_); + } + else + { + this.func_150048_a(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, l, i1, p_149695_5_); + } + } + } + + protected void func_150048_a(World p_150048_1_, int p_150048_2_, int p_150048_3_, int p_150048_4_, int p_150048_5_, int p_150048_6_, Block p_150048_7_) {} + + protected void func_150052_a(World p_150052_1_, int p_150052_2_, int p_150052_3_, int p_150052_4_, boolean p_150052_5_) + { + if (!p_150052_1_.isRemote) + { + (new BlockRailBase.Rail(p_150052_1_, p_150052_2_, p_150052_3_, p_150052_4_)).func_150655_a(p_150052_1_.isBlockIndirectlyGettingPowered(p_150052_2_, p_150052_3_, p_150052_4_), p_150052_5_); + } + } + + public int getMobilityFlag() + { + return 0; + } + + public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) + { + int i1 = p_149749_6_; + + if (this.field_150053_a) + { + i1 = p_149749_6_ & 7; + } + + super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_); + + if (i1 == 2 || i1 == 3 || i1 == 4 || i1 == 5) + { + p_149749_1_.notifyBlocksOfNeighborChange(p_149749_2_, p_149749_3_ + 1, p_149749_4_, p_149749_5_); + } + + if (this.field_150053_a) + { + p_149749_1_.notifyBlocksOfNeighborChange(p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_); + p_149749_1_.notifyBlocksOfNeighborChange(p_149749_2_, p_149749_3_ - 1, p_149749_4_, p_149749_5_); + } + } + + /* ======================================== FORGE START =====================================*/ + /** + * Return true if the rail can make corners. + * Used by placement logic. + * @param world The world. + * @param x The rail X coordinate. + * @param y The rail Y coordinate. + * @param z The rail Z coordinate. + * @return True if the rail can make corners. + */ + public boolean isFlexibleRail(IBlockAccess world, int y, int x, int z) + { + return isPowered(); + } + + /** + * Returns true if the rail can make up and down slopes. + * Used by placement logic. + * @param world The world. + * @param x The rail X coordinate. + * @param y The rail Y coordinate. + * @param z The rail Z coordinate. + * @return True if the rail can make slopes. + */ + public boolean canMakeSlopes(IBlockAccess world, int x, int y, int z) + { + return true; + } + + /** + * Return the rail's metadata (without the power bit if the rail uses one). + * Can be used to make the cart think the rail something other than it is, + * for example when making diamond junctions or switches. + * The cart parameter will often be null unless it it called from EntityMinecart. + * + * Valid rail metadata is defined as follows: + * 0x0: flat track going North-South + * 0x1: flat track going West-East + * 0x2: track ascending to the East + * 0x3: track ascending to the West + * 0x4: track ascending to the North + * 0x5: track ascending to the South + * 0x6: WestNorth corner (connecting East and South) + * 0x7: EastNorth corner (connecting West and South) + * 0x8: EastSouth corner (connecting West and North) + * 0x9: WestSouth corner (connecting East and North) + * + * @param world The world. + * @param cart The cart asking for the metadata, null if it is not called by EntityMinecart. + * @param y The rail X coordinate. + * @param x The rail Y coordinate. + * @param z The rail Z coordinate. + * @return The metadata. + */ + public int getBasicRailMetadata(IBlockAccess world, EntityMinecart cart, int x, int y, int z) + { + int meta = world.getBlockMetadata(x, y, z); + if(isPowered()) + { + meta = meta & 7; + } + return meta; + } + + /** + * Returns the max speed of the rail at the specified position. + * @param world The world. + * @param cart The cart on the rail, may be null. + * @param x The rail X coordinate. + * @param y The rail Y coordinate. + * @param z The rail Z coordinate. + * @return The max speed of the current rail. + */ + public float getRailMaxSpeed(World world, EntityMinecart cart, int y, int x, int z) + { + return 0.4f; + } + + /** + * This function is called by any minecart that passes over this rail. + * It is called once per update tick that the minecart is on the rail. + * @param world The world. + * @param cart The cart on the rail. + * @param y The rail X coordinate. + * @param x The rail Y coordinate. + * @param z The rail Z coordinate. + */ + public void onMinecartPass(World world, EntityMinecart cart, int y, int x, int z) + { + } + + /** + * Forge: Moved render type to a field and a setter. + * This allows for a mod to change the render type + * for vanilla rails, and any mod rails that extend + * this class. + */ + private int renderType = 9; + + public void setRenderType(int value) + { + renderType = value; + } + /* ======================================== FORGE END =====================================*/ + + public class Rail + { + private World field_150660_b; + private int field_150661_c; + private int field_150658_d; + private int field_150659_e; + private final boolean field_150656_f; + private List field_150657_g = new ArrayList(); + private static final String __OBFID = "CL_00000196"; + private final boolean canMakeSlopes; + + public Rail(World p_i45388_2_, int p_i45388_3_, int p_i45388_4_, int p_i45388_5_) + { + this.field_150660_b = p_i45388_2_; + this.field_150661_c = p_i45388_3_; + this.field_150658_d = p_i45388_4_; + this.field_150659_e = p_i45388_5_; + BlockRailBase block = (BlockRailBase)p_i45388_2_.getBlock(p_i45388_3_, p_i45388_4_, p_i45388_5_); + int l = block.getBasicRailMetadata(p_i45388_2_, null, p_i45388_3_, p_i45388_4_, p_i45388_5_); + this.field_150656_f = block.isFlexibleRail(p_i45388_2_, p_i45388_3_, p_i45388_4_, p_i45388_5_); + canMakeSlopes = block.canMakeSlopes(p_i45388_2_, p_i45388_3_, p_i45388_4_, p_i45388_5_); + this.func_150648_a(l); + } + + private void func_150648_a(int p_150648_1_) + { + this.field_150657_g.clear(); + + if (p_150648_1_ == 0) + { + this.field_150657_g.add(new ChunkPosition(this.field_150661_c, this.field_150658_d, this.field_150659_e - 1)); + this.field_150657_g.add(new ChunkPosition(this.field_150661_c, this.field_150658_d, this.field_150659_e + 1)); + } + else if (p_150648_1_ == 1) + { + this.field_150657_g.add(new ChunkPosition(this.field_150661_c - 1, this.field_150658_d, this.field_150659_e)); + this.field_150657_g.add(new ChunkPosition(this.field_150661_c + 1, this.field_150658_d, this.field_150659_e)); + } + else if (p_150648_1_ == 2) + { + this.field_150657_g.add(new ChunkPosition(this.field_150661_c - 1, this.field_150658_d, this.field_150659_e)); + this.field_150657_g.add(new ChunkPosition(this.field_150661_c + 1, this.field_150658_d + 1, this.field_150659_e)); + } + else if (p_150648_1_ == 3) + { + this.field_150657_g.add(new ChunkPosition(this.field_150661_c - 1, this.field_150658_d + 1, this.field_150659_e)); + this.field_150657_g.add(new ChunkPosition(this.field_150661_c + 1, this.field_150658_d, this.field_150659_e)); + } + else if (p_150648_1_ == 4) + { + this.field_150657_g.add(new ChunkPosition(this.field_150661_c, this.field_150658_d + 1, this.field_150659_e - 1)); + this.field_150657_g.add(new ChunkPosition(this.field_150661_c, this.field_150658_d, this.field_150659_e + 1)); + } + else if (p_150648_1_ == 5) + { + this.field_150657_g.add(new ChunkPosition(this.field_150661_c, this.field_150658_d, this.field_150659_e - 1)); + this.field_150657_g.add(new ChunkPosition(this.field_150661_c, this.field_150658_d + 1, this.field_150659_e + 1)); + } + else if (p_150648_1_ == 6) + { + this.field_150657_g.add(new ChunkPosition(this.field_150661_c + 1, this.field_150658_d, this.field_150659_e)); + this.field_150657_g.add(new ChunkPosition(this.field_150661_c, this.field_150658_d, this.field_150659_e + 1)); + } + else if (p_150648_1_ == 7) + { + this.field_150657_g.add(new ChunkPosition(this.field_150661_c - 1, this.field_150658_d, this.field_150659_e)); + this.field_150657_g.add(new ChunkPosition(this.field_150661_c, this.field_150658_d, this.field_150659_e + 1)); + } + else if (p_150648_1_ == 8) + { + this.field_150657_g.add(new ChunkPosition(this.field_150661_c - 1, this.field_150658_d, this.field_150659_e)); + this.field_150657_g.add(new ChunkPosition(this.field_150661_c, this.field_150658_d, this.field_150659_e - 1)); + } + else if (p_150648_1_ == 9) + { + this.field_150657_g.add(new ChunkPosition(this.field_150661_c + 1, this.field_150658_d, this.field_150659_e)); + this.field_150657_g.add(new ChunkPosition(this.field_150661_c, this.field_150658_d, this.field_150659_e - 1)); + } + } + + private void func_150651_b() + { + for (int i = 0; i < this.field_150657_g.size(); ++i) + { + BlockRailBase.Rail rail = this.func_150654_a((ChunkPosition)this.field_150657_g.get(i)); + + if (rail != null && rail.func_150653_a(this)) + { + this.field_150657_g.set(i, new ChunkPosition(rail.field_150661_c, rail.field_150658_d, rail.field_150659_e)); + } + else + { + this.field_150657_g.remove(i--); + } + } + } + + private boolean func_150646_a(int p_150646_1_, int p_150646_2_, int p_150646_3_) + { + return BlockRailBase.func_150049_b_(this.field_150660_b, p_150646_1_, p_150646_2_, p_150646_3_) ? true : (BlockRailBase.func_150049_b_(this.field_150660_b, p_150646_1_, p_150646_2_ + 1, p_150646_3_) ? true : BlockRailBase.func_150049_b_(this.field_150660_b, p_150646_1_, p_150646_2_ - 1, p_150646_3_)); + } + + private BlockRailBase.Rail func_150654_a(ChunkPosition p_150654_1_) + { + return BlockRailBase.func_150049_b_(this.field_150660_b, p_150654_1_.chunkPosX, p_150654_1_.chunkPosY, p_150654_1_.chunkPosZ) ? BlockRailBase.this.new Rail(this.field_150660_b, p_150654_1_.chunkPosX, p_150654_1_.chunkPosY, p_150654_1_.chunkPosZ) : (BlockRailBase.func_150049_b_(this.field_150660_b, p_150654_1_.chunkPosX, p_150654_1_.chunkPosY + 1, p_150654_1_.chunkPosZ) ? BlockRailBase.this.new Rail(this.field_150660_b, p_150654_1_.chunkPosX, p_150654_1_.chunkPosY + 1, p_150654_1_.chunkPosZ) : (BlockRailBase.func_150049_b_(this.field_150660_b, p_150654_1_.chunkPosX, p_150654_1_.chunkPosY - 1, p_150654_1_.chunkPosZ) ? BlockRailBase.this.new Rail(this.field_150660_b, p_150654_1_.chunkPosX, p_150654_1_.chunkPosY - 1, p_150654_1_.chunkPosZ) : null)); + } + + private boolean func_150653_a(BlockRailBase.Rail p_150653_1_) + { + for (int i = 0; i < this.field_150657_g.size(); ++i) + { + ChunkPosition chunkposition = (ChunkPosition)this.field_150657_g.get(i); + + if (chunkposition.chunkPosX == p_150653_1_.field_150661_c && chunkposition.chunkPosZ == p_150653_1_.field_150659_e) + { + return true; + } + } + + return false; + } + + private boolean func_150652_b(int p_150652_1_, int p_150652_2_, int p_150652_3_) + { + for (int l = 0; l < this.field_150657_g.size(); ++l) + { + ChunkPosition chunkposition = (ChunkPosition)this.field_150657_g.get(l); + + if (chunkposition.chunkPosX == p_150652_1_ && chunkposition.chunkPosZ == p_150652_3_) + { + return true; + } + } + + return false; + } + + protected int func_150650_a() + { + int i = 0; + + if (this.func_150646_a(this.field_150661_c, this.field_150658_d, this.field_150659_e - 1)) + { + ++i; + } + + if (this.func_150646_a(this.field_150661_c, this.field_150658_d, this.field_150659_e + 1)) + { + ++i; + } + + if (this.func_150646_a(this.field_150661_c - 1, this.field_150658_d, this.field_150659_e)) + { + ++i; + } + + if (this.func_150646_a(this.field_150661_c + 1, this.field_150658_d, this.field_150659_e)) + { + ++i; + } + + return i; + } + + private boolean func_150649_b(BlockRailBase.Rail p_150649_1_) + { + return this.func_150653_a(p_150649_1_) ? true : (this.field_150657_g.size() == 2 ? false : (this.field_150657_g.isEmpty() ? true : true)); + } + + private void func_150645_c(BlockRailBase.Rail p_150645_1_) + { + this.field_150657_g.add(new ChunkPosition(p_150645_1_.field_150661_c, p_150645_1_.field_150658_d, p_150645_1_.field_150659_e)); + boolean flag = this.func_150652_b(this.field_150661_c, this.field_150658_d, this.field_150659_e - 1); + boolean flag1 = this.func_150652_b(this.field_150661_c, this.field_150658_d, this.field_150659_e + 1); + boolean flag2 = this.func_150652_b(this.field_150661_c - 1, this.field_150658_d, this.field_150659_e); + boolean flag3 = this.func_150652_b(this.field_150661_c + 1, this.field_150658_d, this.field_150659_e); + byte b0 = -1; + + if (flag || flag1) + { + b0 = 0; + } + + if (flag2 || flag3) + { + b0 = 1; + } + + if (!this.field_150656_f) + { + if (flag1 && flag3 && !flag && !flag2) + { + b0 = 6; + } + + if (flag1 && flag2 && !flag && !flag3) + { + b0 = 7; + } + + if (flag && flag2 && !flag1 && !flag3) + { + b0 = 8; + } + + if (flag && flag3 && !flag1 && !flag2) + { + b0 = 9; + } + } + + if (b0 == 0 && canMakeSlopes) + { + if (BlockRailBase.func_150049_b_(this.field_150660_b, this.field_150661_c, this.field_150658_d + 1, this.field_150659_e - 1)) + { + b0 = 4; + } + + if (BlockRailBase.func_150049_b_(this.field_150660_b, this.field_150661_c, this.field_150658_d + 1, this.field_150659_e + 1)) + { + b0 = 5; + } + } + + if (b0 == 1 && canMakeSlopes) + { + if (BlockRailBase.func_150049_b_(this.field_150660_b, this.field_150661_c + 1, this.field_150658_d + 1, this.field_150659_e)) + { + b0 = 2; + } + + if (BlockRailBase.func_150049_b_(this.field_150660_b, this.field_150661_c - 1, this.field_150658_d + 1, this.field_150659_e)) + { + b0 = 3; + } + } + + if (b0 < 0) + { + b0 = 0; + } + + int i = b0; + + if (this.field_150656_f) + { + i = this.field_150660_b.getBlockMetadata(this.field_150661_c, this.field_150658_d, this.field_150659_e) & 8 | b0; + } + + this.field_150660_b.setBlockMetadataWithNotify(this.field_150661_c, this.field_150658_d, this.field_150659_e, i, 3); + } + + private boolean func_150647_c(int p_150647_1_, int p_150647_2_, int p_150647_3_) + { + BlockRailBase.Rail rail = this.func_150654_a(new ChunkPosition(p_150647_1_, p_150647_2_, p_150647_3_)); + + if (rail == null) + { + return false; + } + else + { + rail.func_150651_b(); + return rail.func_150649_b(this); + } + } + + public void func_150655_a(boolean p_150655_1_, boolean p_150655_2_) + { + boolean flag2 = this.func_150647_c(this.field_150661_c, this.field_150658_d, this.field_150659_e - 1); + boolean flag3 = this.func_150647_c(this.field_150661_c, this.field_150658_d, this.field_150659_e + 1); + boolean flag4 = this.func_150647_c(this.field_150661_c - 1, this.field_150658_d, this.field_150659_e); + boolean flag5 = this.func_150647_c(this.field_150661_c + 1, this.field_150658_d, this.field_150659_e); + byte b0 = -1; + + if ((flag2 || flag3) && !flag4 && !flag5) + { + b0 = 0; + } + + if ((flag4 || flag5) && !flag2 && !flag3) + { + b0 = 1; + } + + if (!this.field_150656_f) + { + if (flag3 && flag5 && !flag2 && !flag4) + { + b0 = 6; + } + + if (flag3 && flag4 && !flag2 && !flag5) + { + b0 = 7; + } + + if (flag2 && flag4 && !flag3 && !flag5) + { + b0 = 8; + } + + if (flag2 && flag5 && !flag3 && !flag4) + { + b0 = 9; + } + } + + if (b0 == -1) + { + if (flag2 || flag3) + { + b0 = 0; + } + + if (flag4 || flag5) + { + b0 = 1; + } + + if (!this.field_150656_f) + { + if (p_150655_1_) + { + if (flag3 && flag5) + { + b0 = 6; + } + + if (flag4 && flag3) + { + b0 = 7; + } + + if (flag5 && flag2) + { + b0 = 9; + } + + if (flag2 && flag4) + { + b0 = 8; + } + } + else + { + if (flag2 && flag4) + { + b0 = 8; + } + + if (flag5 && flag2) + { + b0 = 9; + } + + if (flag4 && flag3) + { + b0 = 7; + } + + if (flag3 && flag5) + { + b0 = 6; + } + } + } + } + + if (b0 == 0 && canMakeSlopes) + { + if (BlockRailBase.func_150049_b_(this.field_150660_b, this.field_150661_c, this.field_150658_d + 1, this.field_150659_e - 1)) + { + b0 = 4; + } + + if (BlockRailBase.func_150049_b_(this.field_150660_b, this.field_150661_c, this.field_150658_d + 1, this.field_150659_e + 1)) + { + b0 = 5; + } + } + + if (b0 == 1 && canMakeSlopes) + { + if (BlockRailBase.func_150049_b_(this.field_150660_b, this.field_150661_c + 1, this.field_150658_d + 1, this.field_150659_e)) + { + b0 = 2; + } + + if (BlockRailBase.func_150049_b_(this.field_150660_b, this.field_150661_c - 1, this.field_150658_d + 1, this.field_150659_e)) + { + b0 = 3; + } + } + + if (b0 < 0) + { + b0 = 0; + } + + this.func_150648_a(b0); + int i = b0; + + if (this.field_150656_f) + { + i = this.field_150660_b.getBlockMetadata(this.field_150661_c, this.field_150658_d, this.field_150659_e) & 8 | b0; + } + + if (p_150655_2_ || this.field_150660_b.getBlockMetadata(this.field_150661_c, this.field_150658_d, this.field_150659_e) != i) + { + this.field_150660_b.setBlockMetadataWithNotify(this.field_150661_c, this.field_150658_d, this.field_150659_e, i, 3); + + for (int j = 0; j < this.field_150657_g.size(); ++j) + { + BlockRailBase.Rail rail = this.func_150654_a((ChunkPosition)this.field_150657_g.get(j)); + + if (rail != null) + { + rail.func_150651_b(); + + if (rail.func_150649_b(this)) + { + rail.func_150645_c(this); + } + } + } + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockRailDetector.java b/src/main/java/net/minecraft/block/BlockRailDetector.java new file mode 100644 index 0000000..3600ac2 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockRailDetector.java @@ -0,0 +1,160 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import java.util.Random; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.command.IEntitySelector; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityMinecartCommandBlock; +import net.minecraft.entity.item.EntityMinecart; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.IInventory; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockRailDetector extends BlockRailBase +{ + @SideOnly(Side.CLIENT) + private IIcon[] field_150055_b; + private static final String __OBFID = "CL_00000225"; + + public BlockRailDetector() + { + super(true); + this.setTickRandomly(true); + } + + public int tickRate(World p_149738_1_) + { + return 20; + } + + public boolean canProvidePower() + { + return true; + } + + public void onEntityCollidedWithBlock(World p_149670_1_, int p_149670_2_, int p_149670_3_, int p_149670_4_, Entity p_149670_5_) + { + if (!p_149670_1_.isRemote) + { + int l = p_149670_1_.getBlockMetadata(p_149670_2_, p_149670_3_, p_149670_4_); + + if ((l & 8) == 0) + { + this.func_150054_a(p_149670_1_, p_149670_2_, p_149670_3_, p_149670_4_, l); + } + } + } + + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) + { + if (!p_149674_1_.isRemote) + { + int l = p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_); + + if ((l & 8) != 0) + { + this.func_150054_a(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, l); + } + } + } + + public int isProvidingWeakPower(IBlockAccess p_149709_1_, int p_149709_2_, int p_149709_3_, int p_149709_4_, int p_149709_5_) + { + return (p_149709_1_.getBlockMetadata(p_149709_2_, p_149709_3_, p_149709_4_) & 8) != 0 ? 15 : 0; + } + + public int isProvidingStrongPower(IBlockAccess p_149748_1_, int p_149748_2_, int p_149748_3_, int p_149748_4_, int p_149748_5_) + { + return (p_149748_1_.getBlockMetadata(p_149748_2_, p_149748_3_, p_149748_4_) & 8) == 0 ? 0 : (p_149748_5_ == 1 ? 15 : 0); + } + + private void func_150054_a(World p_150054_1_, int p_150054_2_, int p_150054_3_, int p_150054_4_, int p_150054_5_) + { + boolean flag = (p_150054_5_ & 8) != 0; + boolean flag1 = false; + float f = 0.125F; + List list = p_150054_1_.getEntitiesWithinAABB(EntityMinecart.class, AxisAlignedBB.getAABBPool().getAABB((double)((float)p_150054_2_ + f), (double)p_150054_3_, (double)((float)p_150054_4_ + f), (double)((float)(p_150054_2_ + 1) - f), (double)((float)(p_150054_3_ + 1) - f), (double)((float)(p_150054_4_ + 1) - f))); + + if (!list.isEmpty()) + { + flag1 = true; + } + + if (flag1 && !flag) + { + p_150054_1_.setBlockMetadataWithNotify(p_150054_2_, p_150054_3_, p_150054_4_, p_150054_5_ | 8, 3); + p_150054_1_.notifyBlocksOfNeighborChange(p_150054_2_, p_150054_3_, p_150054_4_, this); + p_150054_1_.notifyBlocksOfNeighborChange(p_150054_2_, p_150054_3_ - 1, p_150054_4_, this); + p_150054_1_.markBlockRangeForRenderUpdate(p_150054_2_, p_150054_3_, p_150054_4_, p_150054_2_, p_150054_3_, p_150054_4_); + } + + if (!flag1 && flag) + { + p_150054_1_.setBlockMetadataWithNotify(p_150054_2_, p_150054_3_, p_150054_4_, p_150054_5_ & 7, 3); + p_150054_1_.notifyBlocksOfNeighborChange(p_150054_2_, p_150054_3_, p_150054_4_, this); + p_150054_1_.notifyBlocksOfNeighborChange(p_150054_2_, p_150054_3_ - 1, p_150054_4_, this); + p_150054_1_.markBlockRangeForRenderUpdate(p_150054_2_, p_150054_3_, p_150054_4_, p_150054_2_, p_150054_3_, p_150054_4_); + } + + if (flag1) + { + p_150054_1_.scheduleBlockUpdate(p_150054_2_, p_150054_3_, p_150054_4_, this, this.tickRate(p_150054_1_)); + } + + p_150054_1_.func_147453_f(p_150054_2_, p_150054_3_, p_150054_4_, this); + } + + public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_) + { + super.onBlockAdded(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_); + this.func_150054_a(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_, p_149726_1_.getBlockMetadata(p_149726_2_, p_149726_3_, p_149726_4_)); + } + + public boolean hasComparatorInputOverride() + { + return true; + } + + public int getComparatorInputOverride(World p_149736_1_, int p_149736_2_, int p_149736_3_, int p_149736_4_, int p_149736_5_) + { + if ((p_149736_1_.getBlockMetadata(p_149736_2_, p_149736_3_, p_149736_4_) & 8) > 0) + { + float f = 0.125F; + List list = p_149736_1_.getEntitiesWithinAABB(EntityMinecartCommandBlock.class, AxisAlignedBB.getAABBPool().getAABB((double)((float)p_149736_2_ + f), (double)p_149736_3_, (double)((float)p_149736_4_ + f), (double)((float)(p_149736_2_ + 1) - f), (double)((float)(p_149736_3_ + 1) - f), (double)((float)(p_149736_4_ + 1) - f))); + + if (list.size() > 0) + { + return ((EntityMinecartCommandBlock)list.get(0)).func_145822_e().func_145760_g(); + } + + List list1 = p_149736_1_.selectEntitiesWithinAABB(EntityMinecart.class, AxisAlignedBB.getAABBPool().getAABB((double)((float)p_149736_2_ + f), (double)p_149736_3_, (double)((float)p_149736_4_ + f), (double)((float)(p_149736_2_ + 1) - f), (double)((float)(p_149736_3_ + 1) - f), (double)((float)(p_149736_4_ + 1) - f)), IEntitySelector.selectInventories); + + if (list1.size() > 0) + { + return Container.calcRedstoneFromInventory((IInventory)list1.get(0)); + } + } + + return 0; + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.field_150055_b = new IIcon[2]; + this.field_150055_b[0] = p_149651_1_.registerIcon(this.getTextureName()); + this.field_150055_b[1] = p_149651_1_.registerIcon(this.getTextureName() + "_powered"); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return (p_149691_2_ & 8) != 0 ? this.field_150055_b[1] : this.field_150055_b[0]; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockRailPowered.java b/src/main/java/net/minecraft/block/BlockRailPowered.java new file mode 100644 index 0000000..3fce824 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockRailPowered.java @@ -0,0 +1,189 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +public class BlockRailPowered extends BlockRailBase +{ + @SideOnly(Side.CLIENT) + protected IIcon field_150059_b; + private static final String __OBFID = "CL_00000288"; + + protected BlockRailPowered() + { + super(true); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return (p_149691_2_ & 8) == 0 ? this.blockIcon : this.field_150059_b; + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + super.registerBlockIcons(p_149651_1_); + this.field_150059_b = p_149651_1_.registerIcon(this.getTextureName() + "_powered"); + } + + protected boolean func_150058_a(World p_150058_1_, int p_150058_2_, int p_150058_3_, int p_150058_4_, int p_150058_5_, boolean p_150058_6_, int p_150058_7_) + { + if (p_150058_7_ >= 8) + { + return false; + } + else + { + int j1 = p_150058_5_ & 7; + boolean flag1 = true; + + switch (j1) + { + case 0: + if (p_150058_6_) + { + ++p_150058_4_; + } + else + { + --p_150058_4_; + } + + break; + case 1: + if (p_150058_6_) + { + --p_150058_2_; + } + else + { + ++p_150058_2_; + } + + break; + case 2: + if (p_150058_6_) + { + --p_150058_2_; + } + else + { + ++p_150058_2_; + ++p_150058_3_; + flag1 = false; + } + + j1 = 1; + break; + case 3: + if (p_150058_6_) + { + --p_150058_2_; + ++p_150058_3_; + flag1 = false; + } + else + { + ++p_150058_2_; + } + + j1 = 1; + break; + case 4: + if (p_150058_6_) + { + ++p_150058_4_; + } + else + { + --p_150058_4_; + ++p_150058_3_; + flag1 = false; + } + + j1 = 0; + break; + case 5: + if (p_150058_6_) + { + ++p_150058_4_; + ++p_150058_3_; + flag1 = false; + } + else + { + --p_150058_4_; + } + + j1 = 0; + } + + return this.func_150057_a(p_150058_1_, p_150058_2_, p_150058_3_, p_150058_4_, p_150058_6_, p_150058_7_, j1) ? true : flag1 && this.func_150057_a(p_150058_1_, p_150058_2_, p_150058_3_ - 1, p_150058_4_, p_150058_6_, p_150058_7_, j1); + } + } + + protected boolean func_150057_a(World p_150057_1_, int p_150057_2_, int p_150057_3_, int p_150057_4_, boolean p_150057_5_, int p_150057_6_, int p_150057_7_) + { + Block block = p_150057_1_.getBlock(p_150057_2_, p_150057_3_, p_150057_4_); + + if (block == this) + { + int j1 = p_150057_1_.getBlockMetadata(p_150057_2_, p_150057_3_, p_150057_4_); + int k1 = j1 & 7; + + if (p_150057_7_ == 1 && (k1 == 0 || k1 == 4 || k1 == 5)) + { + return false; + } + + if (p_150057_7_ == 0 && (k1 == 1 || k1 == 2 || k1 == 3)) + { + return false; + } + + if ((j1 & 8) != 0) + { + if (p_150057_1_.isBlockIndirectlyGettingPowered(p_150057_2_, p_150057_3_, p_150057_4_)) + { + return true; + } + + return this.func_150058_a(p_150057_1_, p_150057_2_, p_150057_3_, p_150057_4_, j1, p_150057_5_, p_150057_6_ + 1); + } + } + + return false; + } + + protected void func_150048_a(World p_150048_1_, int p_150048_2_, int p_150048_3_, int p_150048_4_, int p_150048_5_, int p_150048_6_, Block p_150048_7_) + { + boolean flag = p_150048_1_.isBlockIndirectlyGettingPowered(p_150048_2_, p_150048_3_, p_150048_4_); + flag = flag || this.func_150058_a(p_150048_1_, p_150048_2_, p_150048_3_, p_150048_4_, p_150048_5_, true, 0) || this.func_150058_a(p_150048_1_, p_150048_2_, p_150048_3_, p_150048_4_, p_150048_5_, false, 0); + boolean flag1 = false; + + if (flag && (p_150048_5_ & 8) == 0) + { + p_150048_1_.setBlockMetadataWithNotify(p_150048_2_, p_150048_3_, p_150048_4_, p_150048_6_ | 8, 3); + flag1 = true; + } + else if (!flag && (p_150048_5_ & 8) != 0) + { + p_150048_1_.setBlockMetadataWithNotify(p_150048_2_, p_150048_3_, p_150048_4_, p_150048_6_, 3); + flag1 = true; + } + + if (flag1) + { + p_150048_1_.notifyBlocksOfNeighborChange(p_150048_2_, p_150048_3_ - 1, p_150048_4_, this); + + if (p_150048_6_ == 2 || p_150048_6_ == 3 || p_150048_6_ == 4 || p_150048_6_ == 5) + { + p_150048_1_.notifyBlocksOfNeighborChange(p_150048_2_, p_150048_3_ + 1, p_150048_4_, this); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockRedstoneComparator.java b/src/main/java/net/minecraft/block/BlockRedstoneComparator.java new file mode 100644 index 0000000..71fb187 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockRedstoneComparator.java @@ -0,0 +1,246 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityComparator; +import net.minecraft.util.Direction; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockRedstoneComparator extends BlockRedstoneDiode implements ITileEntityProvider +{ + private static final String __OBFID = "CL_00000220"; + + public BlockRedstoneComparator(boolean p_i45399_1_) + { + super(p_i45399_1_); + this.isBlockContainer = true; + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return Items.comparator; + } + + @SideOnly(Side.CLIENT) + public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) + { + return Items.comparator; + } + + protected int func_149901_b(int p_149901_1_) + { + return 2; + } + + protected BlockRedstoneDiode getBlockPowered() + { + return Blocks.powered_comparator; + } + + protected BlockRedstoneDiode getBlockUnpowered() + { + return Blocks.unpowered_comparator; + } + + public int getRenderType() + { + return 37; + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + boolean flag = this.isRepeaterPowered || (p_149691_2_ & 8) != 0; + return p_149691_1_ == 0 ? (flag ? Blocks.redstone_torch.getBlockTextureFromSide(p_149691_1_) : Blocks.unlit_redstone_torch.getBlockTextureFromSide(p_149691_1_)) : (p_149691_1_ == 1 ? (flag ? Blocks.powered_comparator.blockIcon : this.blockIcon) : Blocks.double_stone_slab.getBlockTextureFromSide(1)); + } + + protected boolean func_149905_c(int p_149905_1_) + { + return this.isRepeaterPowered || (p_149905_1_ & 8) != 0; + } + + protected int func_149904_f(IBlockAccess p_149904_1_, int p_149904_2_, int p_149904_3_, int p_149904_4_, int p_149904_5_) + { + return this.getTileEntityComparator(p_149904_1_, p_149904_2_, p_149904_3_, p_149904_4_).getOutputSignal(); + } + + private int getOutputStrength(World p_149970_1_, int p_149970_2_, int p_149970_3_, int p_149970_4_, int p_149970_5_) + { + return !this.func_149969_d(p_149970_5_) ? this.getInputStrength(p_149970_1_, p_149970_2_, p_149970_3_, p_149970_4_, p_149970_5_) : Math.max(this.getInputStrength(p_149970_1_, p_149970_2_, p_149970_3_, p_149970_4_, p_149970_5_) - this.func_149902_h(p_149970_1_, p_149970_2_, p_149970_3_, p_149970_4_, p_149970_5_), 0); + } + + public boolean func_149969_d(int p_149969_1_) + { + return (p_149969_1_ & 4) == 4; + } + + protected boolean isGettingInput(World p_149900_1_, int p_149900_2_, int p_149900_3_, int p_149900_4_, int p_149900_5_) + { + int i1 = this.getInputStrength(p_149900_1_, p_149900_2_, p_149900_3_, p_149900_4_, p_149900_5_); + + if (i1 >= 15) + { + return true; + } + else if (i1 == 0) + { + return false; + } + else + { + int j1 = this.func_149902_h(p_149900_1_, p_149900_2_, p_149900_3_, p_149900_4_, p_149900_5_); + return j1 == 0 ? true : i1 >= j1; + } + } + + protected int getInputStrength(World p_149903_1_, int p_149903_2_, int p_149903_3_, int p_149903_4_, int p_149903_5_) + { + int i1 = super.getInputStrength(p_149903_1_, p_149903_2_, p_149903_3_, p_149903_4_, p_149903_5_); + int j1 = getDirection(p_149903_5_); + int k1 = p_149903_2_ + Direction.offsetX[j1]; + int l1 = p_149903_4_ + Direction.offsetZ[j1]; + Block block = p_149903_1_.getBlock(k1, p_149903_3_, l1); + + if (block.hasComparatorInputOverride()) + { + i1 = block.getComparatorInputOverride(p_149903_1_, k1, p_149903_3_, l1, Direction.rotateOpposite[j1]); + } + else if (i1 < 15 && block.isNormalCube()) + { + k1 += Direction.offsetX[j1]; + l1 += Direction.offsetZ[j1]; + block = p_149903_1_.getBlock(k1, p_149903_3_, l1); + + if (block.hasComparatorInputOverride()) + { + i1 = block.getComparatorInputOverride(p_149903_1_, k1, p_149903_3_, l1, Direction.rotateOpposite[j1]); + } + } + + return i1; + } + + public TileEntityComparator getTileEntityComparator(IBlockAccess p_149971_1_, int p_149971_2_, int p_149971_3_, int p_149971_4_) + { + return (TileEntityComparator)p_149971_1_.getTileEntity(p_149971_2_, p_149971_3_, p_149971_4_); + } + + public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) + { + int i1 = p_149727_1_.getBlockMetadata(p_149727_2_, p_149727_3_, p_149727_4_); + boolean flag = this.isRepeaterPowered | (i1 & 8) != 0; + boolean flag1 = !this.func_149969_d(i1); + int j1 = flag1 ? 4 : 0; + j1 |= flag ? 8 : 0; + p_149727_1_.playSoundEffect((double)p_149727_2_ + 0.5D, (double)p_149727_3_ + 0.5D, (double)p_149727_4_ + 0.5D, "random.click", 0.3F, flag1 ? 0.55F : 0.5F); + p_149727_1_.setBlockMetadataWithNotify(p_149727_2_, p_149727_3_, p_149727_4_, j1 | i1 & 3, 2); + this.func_149972_c(p_149727_1_, p_149727_2_, p_149727_3_, p_149727_4_, p_149727_1_.rand); + return true; + } + + protected void func_149897_b(World p_149897_1_, int p_149897_2_, int p_149897_3_, int p_149897_4_, Block p_149897_5_) + { + if (!p_149897_1_.isBlockTickScheduledThisTick(p_149897_2_, p_149897_3_, p_149897_4_, this)) + { + int l = p_149897_1_.getBlockMetadata(p_149897_2_, p_149897_3_, p_149897_4_); + int i1 = this.getOutputStrength(p_149897_1_, p_149897_2_, p_149897_3_, p_149897_4_, l); + int j1 = this.getTileEntityComparator(p_149897_1_, p_149897_2_, p_149897_3_, p_149897_4_).getOutputSignal(); + + if (i1 != j1 || this.func_149905_c(l) != this.isGettingInput(p_149897_1_, p_149897_2_, p_149897_3_, p_149897_4_, l)) + { + if (this.func_149912_i(p_149897_1_, p_149897_2_, p_149897_3_, p_149897_4_, l)) + { + p_149897_1_.scheduleBlockUpdateWithPriority(p_149897_2_, p_149897_3_, p_149897_4_, this, this.func_149901_b(0), -1); + } + else + { + p_149897_1_.scheduleBlockUpdateWithPriority(p_149897_2_, p_149897_3_, p_149897_4_, this, this.func_149901_b(0), 0); + } + } + } + } + + private void func_149972_c(World p_149972_1_, int p_149972_2_, int p_149972_3_, int p_149972_4_, Random p_149972_5_) + { + int l = p_149972_1_.getBlockMetadata(p_149972_2_, p_149972_3_, p_149972_4_); + int i1 = this.getOutputStrength(p_149972_1_, p_149972_2_, p_149972_3_, p_149972_4_, l); + int j1 = this.getTileEntityComparator(p_149972_1_, p_149972_2_, p_149972_3_, p_149972_4_).getOutputSignal(); + this.getTileEntityComparator(p_149972_1_, p_149972_2_, p_149972_3_, p_149972_4_).setOutputSignal(i1); + + if (j1 != i1 || !this.func_149969_d(l)) + { + boolean flag = this.isGettingInput(p_149972_1_, p_149972_2_, p_149972_3_, p_149972_4_, l); + boolean flag1 = this.isRepeaterPowered || (l & 8) != 0; + + if (flag1 && !flag) + { + p_149972_1_.setBlockMetadataWithNotify(p_149972_2_, p_149972_3_, p_149972_4_, l & -9, 2); + } + else if (!flag1 && flag) + { + p_149972_1_.setBlockMetadataWithNotify(p_149972_2_, p_149972_3_, p_149972_4_, l | 8, 2); + } + + this.func_149911_e(p_149972_1_, p_149972_2_, p_149972_3_, p_149972_4_); + } + } + + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) + { + if (this.isRepeaterPowered) + { + int l = p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_); + p_149674_1_.setBlock(p_149674_2_, p_149674_3_, p_149674_4_, this.getBlockUnpowered(), l | 8, 4); + } + + this.func_149972_c(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, p_149674_5_); + } + + public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_) + { + super.onBlockAdded(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_); + p_149726_1_.setTileEntity(p_149726_2_, p_149726_3_, p_149726_4_, this.createNewTileEntity(p_149726_1_, 0)); + } + + public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) + { + super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_); + p_149749_1_.removeTileEntity(p_149749_2_, p_149749_3_, p_149749_4_); + this.func_149911_e(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_); + } + + public boolean onBlockEventReceived(World p_149696_1_, int p_149696_2_, int p_149696_3_, int p_149696_4_, int p_149696_5_, int p_149696_6_) + { + super.onBlockEventReceived(p_149696_1_, p_149696_2_, p_149696_3_, p_149696_4_, p_149696_5_, p_149696_6_); + TileEntity tileentity = p_149696_1_.getTileEntity(p_149696_2_, p_149696_3_, p_149696_4_); + return tileentity != null ? tileentity.receiveClientEvent(p_149696_5_, p_149696_6_) : false; + } + + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) + { + return new TileEntityComparator(); + } + + @Override + public void onNeighborChange(IBlockAccess world, int x, int y, int z, int tileX, int tileY, int tileZ) + { + if (y == tileY && world instanceof World) + { + onNeighborBlockChange((World)world, x, y, z, world.getBlock(tileX, tileY, tileZ)); + } + } + + @Override + public boolean getWeakChanges(IBlockAccess world, int x, int y, int z) + { + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockRedstoneDiode.java b/src/main/java/net/minecraft/block/BlockRedstoneDiode.java new file mode 100644 index 0000000..9d430f8 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockRedstoneDiode.java @@ -0,0 +1,318 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Direction; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public abstract class BlockRedstoneDiode extends BlockDirectional +{ + protected final boolean isRepeaterPowered; + private static final String __OBFID = "CL_00000226"; + + protected BlockRedstoneDiode(boolean p_i45400_1_) + { + super(Material.circuits); + this.isRepeaterPowered = p_i45400_1_; + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F); + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public boolean canPlaceBlockAt(World p_149742_1_, int p_149742_2_, int p_149742_3_, int p_149742_4_) + { + return !World.doesBlockHaveSolidTopSurface(p_149742_1_, p_149742_2_, p_149742_3_ - 1, p_149742_4_) ? false : super.canPlaceBlockAt(p_149742_1_, p_149742_2_, p_149742_3_, p_149742_4_); + } + + public boolean canBlockStay(World p_149718_1_, int p_149718_2_, int p_149718_3_, int p_149718_4_) + { + return !World.doesBlockHaveSolidTopSurface(p_149718_1_, p_149718_2_, p_149718_3_ - 1, p_149718_4_) ? false : super.canBlockStay(p_149718_1_, p_149718_2_, p_149718_3_, p_149718_4_); + } + + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) + { + int l = p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_); + + if (!this.func_149910_g(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, l)) + { + boolean flag = this.isGettingInput(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, l); + + if (this.isRepeaterPowered && !flag) + { + p_149674_1_.setBlock(p_149674_2_, p_149674_3_, p_149674_4_, this.getBlockUnpowered(), l, 2); + } + else if (!this.isRepeaterPowered) + { + p_149674_1_.setBlock(p_149674_2_, p_149674_3_, p_149674_4_, this.getBlockPowered(), l, 2); + + if (!flag) + { + p_149674_1_.scheduleBlockUpdateWithPriority(p_149674_2_, p_149674_3_, p_149674_4_, this.getBlockPowered(), this.func_149899_k(l), -1); + } + } + } + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return p_149691_1_ == 0 ? (this.isRepeaterPowered ? Blocks.redstone_torch.getBlockTextureFromSide(p_149691_1_) : Blocks.unlit_redstone_torch.getBlockTextureFromSide(p_149691_1_)) : (p_149691_1_ == 1 ? this.blockIcon : Blocks.double_stone_slab.getBlockTextureFromSide(1)); + } + + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) + { + return p_149646_5_ != 0 && p_149646_5_ != 1; + } + + public int getRenderType() + { + return 36; + } + + protected boolean func_149905_c(int p_149905_1_) + { + return this.isRepeaterPowered; + } + + public int isProvidingStrongPower(IBlockAccess p_149748_1_, int p_149748_2_, int p_149748_3_, int p_149748_4_, int p_149748_5_) + { + return this.isProvidingWeakPower(p_149748_1_, p_149748_2_, p_149748_3_, p_149748_4_, p_149748_5_); + } + + public int isProvidingWeakPower(IBlockAccess p_149709_1_, int p_149709_2_, int p_149709_3_, int p_149709_4_, int p_149709_5_) + { + int i1 = p_149709_1_.getBlockMetadata(p_149709_2_, p_149709_3_, p_149709_4_); + + if (!this.func_149905_c(i1)) + { + return 0; + } + else + { + int j1 = getDirection(i1); + return j1 == 0 && p_149709_5_ == 3 ? this.func_149904_f(p_149709_1_, p_149709_2_, p_149709_3_, p_149709_4_, i1) : (j1 == 1 && p_149709_5_ == 4 ? this.func_149904_f(p_149709_1_, p_149709_2_, p_149709_3_, p_149709_4_, i1) : (j1 == 2 && p_149709_5_ == 2 ? this.func_149904_f(p_149709_1_, p_149709_2_, p_149709_3_, p_149709_4_, i1) : (j1 == 3 && p_149709_5_ == 5 ? this.func_149904_f(p_149709_1_, p_149709_2_, p_149709_3_, p_149709_4_, i1) : 0))); + } + } + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) + { + if (!this.canBlockStay(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_)) + { + this.dropBlockAsItem(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, p_149695_1_.getBlockMetadata(p_149695_2_, p_149695_3_, p_149695_4_), 0); + p_149695_1_.setBlockToAir(p_149695_2_, p_149695_3_, p_149695_4_); + p_149695_1_.notifyBlocksOfNeighborChange(p_149695_2_ + 1, p_149695_3_, p_149695_4_, this); + p_149695_1_.notifyBlocksOfNeighborChange(p_149695_2_ - 1, p_149695_3_, p_149695_4_, this); + p_149695_1_.notifyBlocksOfNeighborChange(p_149695_2_, p_149695_3_, p_149695_4_ + 1, this); + p_149695_1_.notifyBlocksOfNeighborChange(p_149695_2_, p_149695_3_, p_149695_4_ - 1, this); + p_149695_1_.notifyBlocksOfNeighborChange(p_149695_2_, p_149695_3_ - 1, p_149695_4_, this); + p_149695_1_.notifyBlocksOfNeighborChange(p_149695_2_, p_149695_3_ + 1, p_149695_4_, this); + } + else + { + this.func_149897_b(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, p_149695_5_); + } + } + + protected void func_149897_b(World p_149897_1_, int p_149897_2_, int p_149897_3_, int p_149897_4_, Block p_149897_5_) + { + int l = p_149897_1_.getBlockMetadata(p_149897_2_, p_149897_3_, p_149897_4_); + + if (!this.func_149910_g(p_149897_1_, p_149897_2_, p_149897_3_, p_149897_4_, l)) + { + boolean flag = this.isGettingInput(p_149897_1_, p_149897_2_, p_149897_3_, p_149897_4_, l); + + if ((this.isRepeaterPowered && !flag || !this.isRepeaterPowered && flag) && !p_149897_1_.isBlockTickScheduledThisTick(p_149897_2_, p_149897_3_, p_149897_4_, this)) + { + byte b0 = -1; + + if (this.func_149912_i(p_149897_1_, p_149897_2_, p_149897_3_, p_149897_4_, l)) + { + b0 = -3; + } + else if (this.isRepeaterPowered) + { + b0 = -2; + } + + p_149897_1_.scheduleBlockUpdateWithPriority(p_149897_2_, p_149897_3_, p_149897_4_, this, this.func_149901_b(l), b0); + } + } + } + + public boolean func_149910_g(IBlockAccess p_149910_1_, int p_149910_2_, int p_149910_3_, int p_149910_4_, int p_149910_5_) + { + return false; + } + + protected boolean isGettingInput(World p_149900_1_, int p_149900_2_, int p_149900_3_, int p_149900_4_, int p_149900_5_) + { + return this.getInputStrength(p_149900_1_, p_149900_2_, p_149900_3_, p_149900_4_, p_149900_5_) > 0; + } + + protected int getInputStrength(World p_149903_1_, int p_149903_2_, int p_149903_3_, int p_149903_4_, int p_149903_5_) + { + int i1 = getDirection(p_149903_5_); + int j1 = p_149903_2_ + Direction.offsetX[i1]; + int k1 = p_149903_4_ + Direction.offsetZ[i1]; + int l1 = p_149903_1_.getIndirectPowerLevelTo(j1, p_149903_3_, k1, Direction.directionToFacing[i1]); + return l1 >= 15 ? l1 : Math.max(l1, p_149903_1_.getBlock(j1, p_149903_3_, k1) == Blocks.redstone_wire ? p_149903_1_.getBlockMetadata(j1, p_149903_3_, k1) : 0); + } + + protected int func_149902_h(IBlockAccess p_149902_1_, int p_149902_2_, int p_149902_3_, int p_149902_4_, int p_149902_5_) + { + int i1 = getDirection(p_149902_5_); + + switch (i1) + { + case 0: + case 2: + return Math.max(this.func_149913_i(p_149902_1_, p_149902_2_ - 1, p_149902_3_, p_149902_4_, 4), this.func_149913_i(p_149902_1_, p_149902_2_ + 1, p_149902_3_, p_149902_4_, 5)); + case 1: + case 3: + return Math.max(this.func_149913_i(p_149902_1_, p_149902_2_, p_149902_3_, p_149902_4_ + 1, 3), this.func_149913_i(p_149902_1_, p_149902_2_, p_149902_3_, p_149902_4_ - 1, 2)); + default: + return 0; + } + } + + protected int func_149913_i(IBlockAccess p_149913_1_, int p_149913_2_, int p_149913_3_, int p_149913_4_, int p_149913_5_) + { + Block block = p_149913_1_.getBlock(p_149913_2_, p_149913_3_, p_149913_4_); + return this.func_149908_a(block) ? (block == Blocks.redstone_wire ? p_149913_1_.getBlockMetadata(p_149913_2_, p_149913_3_, p_149913_4_) : p_149913_1_.isBlockProvidingPowerTo(p_149913_2_, p_149913_3_, p_149913_4_, p_149913_5_)) : 0; + } + + public boolean canProvidePower() + { + return true; + } + + public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_) + { + int l = ((MathHelper.floor_double((double)(p_149689_5_.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3) + 2) % 4; + p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, l, 3); + boolean flag = this.isGettingInput(p_149689_1_, p_149689_2_, p_149689_3_, p_149689_4_, l); + + if (flag) + { + p_149689_1_.scheduleBlockUpdate(p_149689_2_, p_149689_3_, p_149689_4_, this, 1); + } + } + + public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_) + { + this.func_149911_e(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_); + } + + protected void func_149911_e(World p_149911_1_, int p_149911_2_, int p_149911_3_, int p_149911_4_) + { + int l = getDirection(p_149911_1_.getBlockMetadata(p_149911_2_, p_149911_3_, p_149911_4_)); + + if (l == 1) + { + p_149911_1_.notifyBlockOfNeighborChange(p_149911_2_ + 1, p_149911_3_, p_149911_4_, this); + p_149911_1_.notifyBlocksOfNeighborChange(p_149911_2_ + 1, p_149911_3_, p_149911_4_, this, 4); + } + + if (l == 3) + { + p_149911_1_.notifyBlockOfNeighborChange(p_149911_2_ - 1, p_149911_3_, p_149911_4_, this); + p_149911_1_.notifyBlocksOfNeighborChange(p_149911_2_ - 1, p_149911_3_, p_149911_4_, this, 5); + } + + if (l == 2) + { + p_149911_1_.notifyBlockOfNeighborChange(p_149911_2_, p_149911_3_, p_149911_4_ + 1, this); + p_149911_1_.notifyBlocksOfNeighborChange(p_149911_2_, p_149911_3_, p_149911_4_ + 1, this, 2); + } + + if (l == 0) + { + p_149911_1_.notifyBlockOfNeighborChange(p_149911_2_, p_149911_3_, p_149911_4_ - 1, this); + p_149911_1_.notifyBlocksOfNeighborChange(p_149911_2_, p_149911_3_, p_149911_4_ - 1, this, 3); + } + } + + public void onBlockDestroyedByPlayer(World p_149664_1_, int p_149664_2_, int p_149664_3_, int p_149664_4_, int p_149664_5_) + { + if (this.isRepeaterPowered) + { + p_149664_1_.notifyBlocksOfNeighborChange(p_149664_2_ + 1, p_149664_3_, p_149664_4_, this); + p_149664_1_.notifyBlocksOfNeighborChange(p_149664_2_ - 1, p_149664_3_, p_149664_4_, this); + p_149664_1_.notifyBlocksOfNeighborChange(p_149664_2_, p_149664_3_, p_149664_4_ + 1, this); + p_149664_1_.notifyBlocksOfNeighborChange(p_149664_2_, p_149664_3_, p_149664_4_ - 1, this); + p_149664_1_.notifyBlocksOfNeighborChange(p_149664_2_, p_149664_3_ - 1, p_149664_4_, this); + p_149664_1_.notifyBlocksOfNeighborChange(p_149664_2_, p_149664_3_ + 1, p_149664_4_, this); + } + + super.onBlockDestroyedByPlayer(p_149664_1_, p_149664_2_, p_149664_3_, p_149664_4_, p_149664_5_); + } + + public boolean isOpaqueCube() + { + return false; + } + + protected boolean func_149908_a(Block p_149908_1_) + { + return p_149908_1_.canProvidePower(); + } + + protected int func_149904_f(IBlockAccess p_149904_1_, int p_149904_2_, int p_149904_3_, int p_149904_4_, int p_149904_5_) + { + return 15; + } + + public static boolean isRedstoneRepeaterBlockID(Block p_149909_0_) + { + return Blocks.unpowered_repeater.func_149907_e(p_149909_0_) || Blocks.unpowered_comparator.func_149907_e(p_149909_0_); + } + + public boolean func_149907_e(Block p_149907_1_) + { + return p_149907_1_ == this.getBlockPowered() || p_149907_1_ == this.getBlockUnpowered(); + } + + public boolean func_149912_i(World p_149912_1_, int p_149912_2_, int p_149912_3_, int p_149912_4_, int p_149912_5_) + { + int i1 = getDirection(p_149912_5_); + + if (isRedstoneRepeaterBlockID(p_149912_1_.getBlock(p_149912_2_ - Direction.offsetX[i1], p_149912_3_, p_149912_4_ - Direction.offsetZ[i1]))) + { + int j1 = p_149912_1_.getBlockMetadata(p_149912_2_ - Direction.offsetX[i1], p_149912_3_, p_149912_4_ - Direction.offsetZ[i1]); + int k1 = getDirection(j1); + return k1 != i1; + } + else + { + return false; + } + } + + protected int func_149899_k(int p_149899_1_) + { + return this.func_149901_b(p_149899_1_); + } + + protected abstract int func_149901_b(int var1); + + protected abstract BlockRedstoneDiode getBlockPowered(); + + protected abstract BlockRedstoneDiode getBlockUnpowered(); + + public boolean isAssociatedBlock(Block p_149667_1_) + { + return this.func_149907_e(p_149667_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockRedstoneLight.java b/src/main/java/net/minecraft/block/BlockRedstoneLight.java new file mode 100644 index 0000000..8659ff9 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockRedstoneLight.java @@ -0,0 +1,81 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class BlockRedstoneLight extends Block +{ + private final boolean field_150171_a; + private static final String __OBFID = "CL_00000297"; + + public BlockRedstoneLight(boolean p_i45421_1_) + { + super(Material.redstoneLight); + this.field_150171_a = p_i45421_1_; + + if (p_i45421_1_) + { + this.setLightLevel(1.0F); + } + } + + public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_) + { + if (!p_149726_1_.isRemote) + { + if (this.field_150171_a && !p_149726_1_.isBlockIndirectlyGettingPowered(p_149726_2_, p_149726_3_, p_149726_4_)) + { + p_149726_1_.scheduleBlockUpdate(p_149726_2_, p_149726_3_, p_149726_4_, this, 4); + } + else if (!this.field_150171_a && p_149726_1_.isBlockIndirectlyGettingPowered(p_149726_2_, p_149726_3_, p_149726_4_)) + { + p_149726_1_.setBlock(p_149726_2_, p_149726_3_, p_149726_4_, Blocks.lit_redstone_lamp, 0, 2); + } + } + } + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) + { + if (!p_149695_1_.isRemote) + { + if (this.field_150171_a && !p_149695_1_.isBlockIndirectlyGettingPowered(p_149695_2_, p_149695_3_, p_149695_4_)) + { + p_149695_1_.scheduleBlockUpdate(p_149695_2_, p_149695_3_, p_149695_4_, this, 4); + } + else if (!this.field_150171_a && p_149695_1_.isBlockIndirectlyGettingPowered(p_149695_2_, p_149695_3_, p_149695_4_)) + { + p_149695_1_.setBlock(p_149695_2_, p_149695_3_, p_149695_4_, Blocks.lit_redstone_lamp, 0, 2); + } + } + } + + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) + { + if (!p_149674_1_.isRemote && this.field_150171_a && !p_149674_1_.isBlockIndirectlyGettingPowered(p_149674_2_, p_149674_3_, p_149674_4_)) + { + p_149674_1_.setBlock(p_149674_2_, p_149674_3_, p_149674_4_, Blocks.redstone_lamp, 0, 2); + } + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return Item.getItemFromBlock(Blocks.redstone_lamp); + } + + @SideOnly(Side.CLIENT) + public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) + { + return Item.getItemFromBlock(Blocks.redstone_lamp); + } + + protected ItemStack createStackedBlock(int p_149644_1_) + { + return new ItemStack(Blocks.redstone_lamp); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockRedstoneOre.java b/src/main/java/net/minecraft/block/BlockRedstoneOre.java new file mode 100644 index 0000000..6b1766c --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockRedstoneOre.java @@ -0,0 +1,166 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockRedstoneOre extends Block +{ + private boolean field_150187_a; + private static final String __OBFID = "CL_00000294"; + + public BlockRedstoneOre(boolean p_i45420_1_) + { + super(Material.rock); + + if (p_i45420_1_) + { + this.setTickRandomly(true); + } + + this.field_150187_a = p_i45420_1_; + } + + public int tickRate(World p_149738_1_) + { + return 30; + } + + public void onBlockClicked(World p_149699_1_, int p_149699_2_, int p_149699_3_, int p_149699_4_, EntityPlayer p_149699_5_) + { + this.func_150185_e(p_149699_1_, p_149699_2_, p_149699_3_, p_149699_4_); + super.onBlockClicked(p_149699_1_, p_149699_2_, p_149699_3_, p_149699_4_, p_149699_5_); + } + + public void onEntityWalking(World p_149724_1_, int p_149724_2_, int p_149724_3_, int p_149724_4_, Entity p_149724_5_) + { + this.func_150185_e(p_149724_1_, p_149724_2_, p_149724_3_, p_149724_4_); + super.onEntityWalking(p_149724_1_, p_149724_2_, p_149724_3_, p_149724_4_, p_149724_5_); + } + + public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) + { + this.func_150185_e(p_149727_1_, p_149727_2_, p_149727_3_, p_149727_4_); + return super.onBlockActivated(p_149727_1_, p_149727_2_, p_149727_3_, p_149727_4_, p_149727_5_, p_149727_6_, p_149727_7_, p_149727_8_, p_149727_9_); + } + + private void func_150185_e(World p_150185_1_, int p_150185_2_, int p_150185_3_, int p_150185_4_) + { + this.func_150186_m(p_150185_1_, p_150185_2_, p_150185_3_, p_150185_4_); + + if (this == Blocks.redstone_ore) + { + p_150185_1_.setBlock(p_150185_2_, p_150185_3_, p_150185_4_, Blocks.lit_redstone_ore); + } + } + + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) + { + if (this == Blocks.lit_redstone_ore) + { + p_149674_1_.setBlock(p_149674_2_, p_149674_3_, p_149674_4_, Blocks.redstone_ore); + } + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return Items.redstone; + } + + public int quantityDroppedWithBonus(int p_149679_1_, Random p_149679_2_) + { + return this.quantityDropped(p_149679_2_) + p_149679_2_.nextInt(p_149679_1_ + 1); + } + + public int quantityDropped(Random p_149745_1_) + { + return 4 + p_149745_1_.nextInt(2); + } + + public void dropBlockAsItemWithChance(World p_149690_1_, int p_149690_2_, int p_149690_3_, int p_149690_4_, int p_149690_5_, float p_149690_6_, int p_149690_7_) + { + super.dropBlockAsItemWithChance(p_149690_1_, p_149690_2_, p_149690_3_, p_149690_4_, p_149690_5_, p_149690_6_, p_149690_7_); + } + + private Random rand = new Random(); + @Override // World, meta, fortune + public int getExpDrop(IBlockAccess p_149690_1_, int p_149690_5_, int p_149690_7_) + { + if (this.getItemDropped(p_149690_5_, rand, p_149690_7_) != Item.getItemFromBlock(this)) + { + return 1 + rand.nextInt(5); + } + return 0; + } + + @SideOnly(Side.CLIENT) + public void randomDisplayTick(World p_149734_1_, int p_149734_2_, int p_149734_3_, int p_149734_4_, Random p_149734_5_) + { + if (this.field_150187_a) + { + this.func_150186_m(p_149734_1_, p_149734_2_, p_149734_3_, p_149734_4_); + } + } + + private void func_150186_m(World p_150186_1_, int p_150186_2_, int p_150186_3_, int p_150186_4_) + { + Random random = p_150186_1_.rand; + double d0 = 0.0625D; + + for (int l = 0; l < 6; ++l) + { + double d1 = (double)((float)p_150186_2_ + random.nextFloat()); + double d2 = (double)((float)p_150186_3_ + random.nextFloat()); + double d3 = (double)((float)p_150186_4_ + random.nextFloat()); + + if (l == 0 && !p_150186_1_.getBlock(p_150186_2_, p_150186_3_ + 1, p_150186_4_).isOpaqueCube()) + { + d2 = (double)(p_150186_3_ + 1) + d0; + } + + if (l == 1 && !p_150186_1_.getBlock(p_150186_2_, p_150186_3_ - 1, p_150186_4_).isOpaqueCube()) + { + d2 = (double)(p_150186_3_ + 0) - d0; + } + + if (l == 2 && !p_150186_1_.getBlock(p_150186_2_, p_150186_3_, p_150186_4_ + 1).isOpaqueCube()) + { + d3 = (double)(p_150186_4_ + 1) + d0; + } + + if (l == 3 && !p_150186_1_.getBlock(p_150186_2_, p_150186_3_, p_150186_4_ - 1).isOpaqueCube()) + { + d3 = (double)(p_150186_4_ + 0) - d0; + } + + if (l == 4 && !p_150186_1_.getBlock(p_150186_2_ + 1, p_150186_3_, p_150186_4_).isOpaqueCube()) + { + d1 = (double)(p_150186_2_ + 1) + d0; + } + + if (l == 5 && !p_150186_1_.getBlock(p_150186_2_ - 1, p_150186_3_, p_150186_4_).isOpaqueCube()) + { + d1 = (double)(p_150186_2_ + 0) - d0; + } + + if (d1 < (double)p_150186_2_ || d1 > (double)(p_150186_2_ + 1) || d2 < 0.0D || d2 > (double)(p_150186_3_ + 1) || d3 < (double)p_150186_4_ || d3 > (double)(p_150186_4_ + 1)) + { + p_150186_1_.spawnParticle("reddust", d1, d2, d3, 0.0D, 0.0D, 0.0D); + } + } + } + + protected ItemStack createStackedBlock(int p_149644_1_) + { + return new ItemStack(Blocks.redstone_ore); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockRedstoneRepeater.java b/src/main/java/net/minecraft/block/BlockRedstoneRepeater.java new file mode 100644 index 0000000..e20fa4a --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockRedstoneRepeater.java @@ -0,0 +1,133 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockRedstoneRepeater extends BlockRedstoneDiode +{ + public static final double[] repeaterTorchOffset = new double[] { -0.0625D, 0.0625D, 0.1875D, 0.3125D}; + private static final int[] repeaterState = new int[] {1, 2, 3, 4}; + private static final String __OBFID = "CL_00000301"; + + protected BlockRedstoneRepeater(boolean p_i45424_1_) + { + super(p_i45424_1_); + } + + public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) + { + int i1 = p_149727_1_.getBlockMetadata(p_149727_2_, p_149727_3_, p_149727_4_); + int j1 = (i1 & 12) >> 2; + j1 = j1 + 1 << 2 & 12; + p_149727_1_.setBlockMetadataWithNotify(p_149727_2_, p_149727_3_, p_149727_4_, j1 | i1 & 3, 3); + return true; + } + + protected int func_149901_b(int p_149901_1_) + { + return repeaterState[(p_149901_1_ & 12) >> 2] * 2; + } + + protected BlockRedstoneDiode getBlockPowered() + { + return Blocks.powered_repeater; + } + + protected BlockRedstoneDiode getBlockUnpowered() + { + return Blocks.unpowered_repeater; + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return Items.repeater; + } + + @SideOnly(Side.CLIENT) + public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) + { + return Items.repeater; + } + + public int getRenderType() + { + return 15; + } + + public boolean func_149910_g(IBlockAccess p_149910_1_, int p_149910_2_, int p_149910_3_, int p_149910_4_, int p_149910_5_) + { + return this.func_149902_h(p_149910_1_, p_149910_2_, p_149910_3_, p_149910_4_, p_149910_5_) > 0; + } + + protected boolean func_149908_a(Block p_149908_1_) + { + return isRedstoneRepeaterBlockID(p_149908_1_); + } + + public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) + { + super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_); + this.func_149911_e(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_); + } + + @SideOnly(Side.CLIENT) + public void randomDisplayTick(World p_149734_1_, int p_149734_2_, int p_149734_3_, int p_149734_4_, Random p_149734_5_) + { + if (this.isRepeaterPowered) + { + int l = p_149734_1_.getBlockMetadata(p_149734_2_, p_149734_3_, p_149734_4_); + int i1 = getDirection(l); + double d0 = (double)((float)p_149734_2_ + 0.5F) + (double)(p_149734_5_.nextFloat() - 0.5F) * 0.2D; + double d1 = (double)((float)p_149734_3_ + 0.4F) + (double)(p_149734_5_.nextFloat() - 0.5F) * 0.2D; + double d2 = (double)((float)p_149734_4_ + 0.5F) + (double)(p_149734_5_.nextFloat() - 0.5F) * 0.2D; + double d3 = 0.0D; + double d4 = 0.0D; + + if (p_149734_5_.nextInt(2) == 0) + { + switch (i1) + { + case 0: + d4 = -0.3125D; + break; + case 1: + d3 = 0.3125D; + break; + case 2: + d4 = 0.3125D; + break; + case 3: + d3 = -0.3125D; + } + } + else + { + int j1 = (l & 12) >> 2; + + switch (i1) + { + case 0: + d4 = repeaterTorchOffset[j1]; + break; + case 1: + d3 = -repeaterTorchOffset[j1]; + break; + case 2: + d4 = -repeaterTorchOffset[j1]; + break; + case 3: + d3 = repeaterTorchOffset[j1]; + } + } + + p_149734_1_.spawnParticle("reddust", d0 + d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockRedstoneTorch.java b/src/main/java/net/minecraft/block/BlockRedstoneTorch.java new file mode 100644 index 0000000..9ccd67d --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockRedstoneTorch.java @@ -0,0 +1,244 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Random; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockRedstoneTorch extends BlockTorch +{ + private boolean field_150113_a; + private static Map field_150112_b = new HashMap(); + private static final String __OBFID = "CL_00000298"; + + private boolean func_150111_a(World p_150111_1_, int p_150111_2_, int p_150111_3_, int p_150111_4_, boolean p_150111_5_) + { + if (!field_150112_b.containsKey(p_150111_1_)) + { + field_150112_b.put(p_150111_1_, new ArrayList()); + } + + List list = (List)field_150112_b.get(p_150111_1_); + + if (p_150111_5_) + { + list.add(new BlockRedstoneTorch.Toggle(p_150111_2_, p_150111_3_, p_150111_4_, p_150111_1_.getTotalWorldTime())); + } + + int l = 0; + + for (int i1 = 0; i1 < list.size(); ++i1) + { + BlockRedstoneTorch.Toggle toggle = (BlockRedstoneTorch.Toggle)list.get(i1); + + if (toggle.field_150847_a == p_150111_2_ && toggle.field_150845_b == p_150111_3_ && toggle.field_150846_c == p_150111_4_) + { + ++l; + + if (l >= 8) + { + return true; + } + } + } + + return false; + } + + protected BlockRedstoneTorch(boolean p_i45423_1_) + { + this.field_150113_a = p_i45423_1_; + this.setTickRandomly(true); + this.setCreativeTab((CreativeTabs)null); + } + + public int tickRate(World p_149738_1_) + { + return 2; + } + + public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_) + { + if (p_149726_1_.getBlockMetadata(p_149726_2_, p_149726_3_, p_149726_4_) == 0) + { + super.onBlockAdded(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_); + } + + if (this.field_150113_a) + { + p_149726_1_.notifyBlocksOfNeighborChange(p_149726_2_, p_149726_3_ - 1, p_149726_4_, this); + p_149726_1_.notifyBlocksOfNeighborChange(p_149726_2_, p_149726_3_ + 1, p_149726_4_, this); + p_149726_1_.notifyBlocksOfNeighborChange(p_149726_2_ - 1, p_149726_3_, p_149726_4_, this); + p_149726_1_.notifyBlocksOfNeighborChange(p_149726_2_ + 1, p_149726_3_, p_149726_4_, this); + p_149726_1_.notifyBlocksOfNeighborChange(p_149726_2_, p_149726_3_, p_149726_4_ - 1, this); + p_149726_1_.notifyBlocksOfNeighborChange(p_149726_2_, p_149726_3_, p_149726_4_ + 1, this); + } + } + + public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) + { + if (this.field_150113_a) + { + p_149749_1_.notifyBlocksOfNeighborChange(p_149749_2_, p_149749_3_ - 1, p_149749_4_, this); + p_149749_1_.notifyBlocksOfNeighborChange(p_149749_2_, p_149749_3_ + 1, p_149749_4_, this); + p_149749_1_.notifyBlocksOfNeighborChange(p_149749_2_ - 1, p_149749_3_, p_149749_4_, this); + p_149749_1_.notifyBlocksOfNeighborChange(p_149749_2_ + 1, p_149749_3_, p_149749_4_, this); + p_149749_1_.notifyBlocksOfNeighborChange(p_149749_2_, p_149749_3_, p_149749_4_ - 1, this); + p_149749_1_.notifyBlocksOfNeighborChange(p_149749_2_, p_149749_3_, p_149749_4_ + 1, this); + } + } + + public int isProvidingWeakPower(IBlockAccess p_149709_1_, int p_149709_2_, int p_149709_3_, int p_149709_4_, int p_149709_5_) + { + if (!this.field_150113_a) + { + return 0; + } + else + { + int i1 = p_149709_1_.getBlockMetadata(p_149709_2_, p_149709_3_, p_149709_4_); + return i1 == 5 && p_149709_5_ == 1 ? 0 : (i1 == 3 && p_149709_5_ == 3 ? 0 : (i1 == 4 && p_149709_5_ == 2 ? 0 : (i1 == 1 && p_149709_5_ == 5 ? 0 : (i1 == 2 && p_149709_5_ == 4 ? 0 : 15)))); + } + } + + private boolean func_150110_m(World p_150110_1_, int p_150110_2_, int p_150110_3_, int p_150110_4_) + { + int l = p_150110_1_.getBlockMetadata(p_150110_2_, p_150110_3_, p_150110_4_); + return l == 5 && p_150110_1_.getIndirectPowerOutput(p_150110_2_, p_150110_3_ - 1, p_150110_4_, 0) ? true : (l == 3 && p_150110_1_.getIndirectPowerOutput(p_150110_2_, p_150110_3_, p_150110_4_ - 1, 2) ? true : (l == 4 && p_150110_1_.getIndirectPowerOutput(p_150110_2_, p_150110_3_, p_150110_4_ + 1, 3) ? true : (l == 1 && p_150110_1_.getIndirectPowerOutput(p_150110_2_ - 1, p_150110_3_, p_150110_4_, 4) ? true : l == 2 && p_150110_1_.getIndirectPowerOutput(p_150110_2_ + 1, p_150110_3_, p_150110_4_, 5)))); + } + + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) + { + boolean flag = this.func_150110_m(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_); + List list = (List)field_150112_b.get(p_149674_1_); + + while (list != null && !list.isEmpty() && p_149674_1_.getTotalWorldTime() - ((BlockRedstoneTorch.Toggle)list.get(0)).field_150844_d > 60L) + { + list.remove(0); + } + + if (this.field_150113_a) + { + if (flag) + { + p_149674_1_.setBlock(p_149674_2_, p_149674_3_, p_149674_4_, Blocks.unlit_redstone_torch, p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_), 3); + + if (this.func_150111_a(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, true)) + { + p_149674_1_.playSoundEffect((double)((float)p_149674_2_ + 0.5F), (double)((float)p_149674_3_ + 0.5F), (double)((float)p_149674_4_ + 0.5F), "random.fizz", 0.5F, 2.6F + (p_149674_1_.rand.nextFloat() - p_149674_1_.rand.nextFloat()) * 0.8F); + + for (int l = 0; l < 5; ++l) + { + double d0 = (double)p_149674_2_ + p_149674_5_.nextDouble() * 0.6D + 0.2D; + double d1 = (double)p_149674_3_ + p_149674_5_.nextDouble() * 0.6D + 0.2D; + double d2 = (double)p_149674_4_ + p_149674_5_.nextDouble() * 0.6D + 0.2D; + p_149674_1_.spawnParticle("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D); + } + } + } + } + else if (!flag && !this.func_150111_a(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, false)) + { + p_149674_1_.setBlock(p_149674_2_, p_149674_3_, p_149674_4_, Blocks.redstone_torch, p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_), 3); + } + } + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) + { + if (!this.func_150108_b(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, p_149695_5_)) + { + boolean flag = this.func_150110_m(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_); + + if (this.field_150113_a && flag || !this.field_150113_a && !flag) + { + p_149695_1_.scheduleBlockUpdate(p_149695_2_, p_149695_3_, p_149695_4_, this, this.tickRate(p_149695_1_)); + } + } + } + + public int isProvidingStrongPower(IBlockAccess p_149748_1_, int p_149748_2_, int p_149748_3_, int p_149748_4_, int p_149748_5_) + { + return p_149748_5_ == 0 ? this.isProvidingWeakPower(p_149748_1_, p_149748_2_, p_149748_3_, p_149748_4_, p_149748_5_) : 0; + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return Item.getItemFromBlock(Blocks.redstone_torch); + } + + public boolean canProvidePower() + { + return true; + } + + @SideOnly(Side.CLIENT) + public void randomDisplayTick(World p_149734_1_, int p_149734_2_, int p_149734_3_, int p_149734_4_, Random p_149734_5_) + { + if (this.field_150113_a) + { + int l = p_149734_1_.getBlockMetadata(p_149734_2_, p_149734_3_, p_149734_4_); + double d0 = (double)((float)p_149734_2_ + 0.5F) + (double)(p_149734_5_.nextFloat() - 0.5F) * 0.2D; + double d1 = (double)((float)p_149734_3_ + 0.7F) + (double)(p_149734_5_.nextFloat() - 0.5F) * 0.2D; + double d2 = (double)((float)p_149734_4_ + 0.5F) + (double)(p_149734_5_.nextFloat() - 0.5F) * 0.2D; + double d3 = 0.2199999988079071D; + double d4 = 0.27000001072883606D; + + if (l == 1) + { + p_149734_1_.spawnParticle("reddust", d0 - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D); + } + else if (l == 2) + { + p_149734_1_.spawnParticle("reddust", d0 + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D); + } + else if (l == 3) + { + p_149734_1_.spawnParticle("reddust", d0, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D); + } + else if (l == 4) + { + p_149734_1_.spawnParticle("reddust", d0, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D); + } + else + { + p_149734_1_.spawnParticle("reddust", d0, d1, d2, 0.0D, 0.0D, 0.0D); + } + } + } + + @SideOnly(Side.CLIENT) + public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) + { + return Item.getItemFromBlock(Blocks.redstone_torch); + } + + public boolean isAssociatedBlock(Block p_149667_1_) + { + return p_149667_1_ == Blocks.unlit_redstone_torch || p_149667_1_ == Blocks.redstone_torch; + } + + static class Toggle + { + int field_150847_a; + int field_150845_b; + int field_150846_c; + long field_150844_d; + private static final String __OBFID = "CL_00000299"; + + public Toggle(int p_i45422_1_, int p_i45422_2_, int p_i45422_3_, long p_i45422_4_) + { + this.field_150847_a = p_i45422_1_; + this.field_150845_b = p_i45422_2_; + this.field_150846_c = p_i45422_3_; + this.field_150844_d = p_i45422_4_; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockRedstoneWire.java b/src/main/java/net/minecraft/block/BlockRedstoneWire.java new file mode 100644 index 0000000..963232f --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockRedstoneWire.java @@ -0,0 +1,490 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Random; +import java.util.Set; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.Direction; +import net.minecraft.util.IIcon; +import net.minecraft.world.ChunkPosition; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockRedstoneWire extends Block +{ + private boolean field_150181_a = true; + private Set field_150179_b = new HashSet(); + @SideOnly(Side.CLIENT) + private IIcon field_150182_M; + @SideOnly(Side.CLIENT) + private IIcon field_150183_N; + @SideOnly(Side.CLIENT) + private IIcon field_150184_O; + @SideOnly(Side.CLIENT) + private IIcon field_150180_P; + private static final String __OBFID = "CL_00000295"; + + public BlockRedstoneWire() + { + super(Material.circuits); + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.0625F, 1.0F); + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) + { + return null; + } + + public boolean isOpaqueCube() + { + return false; + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public int getRenderType() + { + return 5; + } + + @SideOnly(Side.CLIENT) + public int colorMultiplier(IBlockAccess p_149720_1_, int p_149720_2_, int p_149720_3_, int p_149720_4_) + { + return 8388608; + } + + public boolean canPlaceBlockAt(World p_149742_1_, int p_149742_2_, int p_149742_3_, int p_149742_4_) + { + return World.doesBlockHaveSolidTopSurface(p_149742_1_, p_149742_2_, p_149742_3_ - 1, p_149742_4_) || p_149742_1_.getBlock(p_149742_2_, p_149742_3_ - 1, p_149742_4_) == Blocks.glowstone; + } + + private void func_150177_e(World p_150177_1_, int p_150177_2_, int p_150177_3_, int p_150177_4_) + { + this.func_150175_a(p_150177_1_, p_150177_2_, p_150177_3_, p_150177_4_, p_150177_2_, p_150177_3_, p_150177_4_); + ArrayList arraylist = new ArrayList(this.field_150179_b); + this.field_150179_b.clear(); + + for (int l = 0; l < arraylist.size(); ++l) + { + ChunkPosition chunkposition = (ChunkPosition)arraylist.get(l); + p_150177_1_.notifyBlocksOfNeighborChange(chunkposition.chunkPosX, chunkposition.chunkPosY, chunkposition.chunkPosZ, this); + } + } + + private void func_150175_a(World p_150175_1_, int p_150175_2_, int p_150175_3_, int p_150175_4_, int p_150175_5_, int p_150175_6_, int p_150175_7_) + { + int k1 = p_150175_1_.getBlockMetadata(p_150175_2_, p_150175_3_, p_150175_4_); + byte b0 = 0; + int i3 = this.func_150178_a(p_150175_1_, p_150175_5_, p_150175_6_, p_150175_7_, b0); + this.field_150181_a = false; + int l1 = p_150175_1_.getStrongestIndirectPower(p_150175_2_, p_150175_3_, p_150175_4_); + this.field_150181_a = true; + + if (l1 > 0 && l1 > i3 - 1) + { + i3 = l1; + } + + int i2 = 0; + + for (int j2 = 0; j2 < 4; ++j2) + { + int k2 = p_150175_2_; + int l2 = p_150175_4_; + + if (j2 == 0) + { + k2 = p_150175_2_ - 1; + } + + if (j2 == 1) + { + ++k2; + } + + if (j2 == 2) + { + l2 = p_150175_4_ - 1; + } + + if (j2 == 3) + { + ++l2; + } + + if (k2 != p_150175_5_ || l2 != p_150175_7_) + { + i2 = this.func_150178_a(p_150175_1_, k2, p_150175_3_, l2, i2); + } + + if (p_150175_1_.getBlock(k2, p_150175_3_, l2).isNormalCube() && !p_150175_1_.getBlock(p_150175_2_, p_150175_3_ + 1, p_150175_4_).isNormalCube()) + { + if ((k2 != p_150175_5_ || l2 != p_150175_7_) && p_150175_3_ >= p_150175_6_) + { + i2 = this.func_150178_a(p_150175_1_, k2, p_150175_3_ + 1, l2, i2); + } + } + else if (!p_150175_1_.getBlock(k2, p_150175_3_, l2).isNormalCube() && (k2 != p_150175_5_ || l2 != p_150175_7_) && p_150175_3_ <= p_150175_6_) + { + i2 = this.func_150178_a(p_150175_1_, k2, p_150175_3_ - 1, l2, i2); + } + } + + if (i2 > i3) + { + i3 = i2 - 1; + } + else if (i3 > 0) + { + --i3; + } + else + { + i3 = 0; + } + + if (l1 > i3 - 1) + { + i3 = l1; + } + + if (k1 != i3) + { + p_150175_1_.setBlockMetadataWithNotify(p_150175_2_, p_150175_3_, p_150175_4_, i3, 2); + this.field_150179_b.add(new ChunkPosition(p_150175_2_, p_150175_3_, p_150175_4_)); + this.field_150179_b.add(new ChunkPosition(p_150175_2_ - 1, p_150175_3_, p_150175_4_)); + this.field_150179_b.add(new ChunkPosition(p_150175_2_ + 1, p_150175_3_, p_150175_4_)); + this.field_150179_b.add(new ChunkPosition(p_150175_2_, p_150175_3_ - 1, p_150175_4_)); + this.field_150179_b.add(new ChunkPosition(p_150175_2_, p_150175_3_ + 1, p_150175_4_)); + this.field_150179_b.add(new ChunkPosition(p_150175_2_, p_150175_3_, p_150175_4_ - 1)); + this.field_150179_b.add(new ChunkPosition(p_150175_2_, p_150175_3_, p_150175_4_ + 1)); + } + } + + private void func_150172_m(World p_150172_1_, int p_150172_2_, int p_150172_3_, int p_150172_4_) + { + if (p_150172_1_.getBlock(p_150172_2_, p_150172_3_, p_150172_4_) == this) + { + p_150172_1_.notifyBlocksOfNeighborChange(p_150172_2_, p_150172_3_, p_150172_4_, this); + p_150172_1_.notifyBlocksOfNeighborChange(p_150172_2_ - 1, p_150172_3_, p_150172_4_, this); + p_150172_1_.notifyBlocksOfNeighborChange(p_150172_2_ + 1, p_150172_3_, p_150172_4_, this); + p_150172_1_.notifyBlocksOfNeighborChange(p_150172_2_, p_150172_3_, p_150172_4_ - 1, this); + p_150172_1_.notifyBlocksOfNeighborChange(p_150172_2_, p_150172_3_, p_150172_4_ + 1, this); + p_150172_1_.notifyBlocksOfNeighborChange(p_150172_2_, p_150172_3_ - 1, p_150172_4_, this); + p_150172_1_.notifyBlocksOfNeighborChange(p_150172_2_, p_150172_3_ + 1, p_150172_4_, this); + } + } + + public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_) + { + super.onBlockAdded(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_); + + if (!p_149726_1_.isRemote) + { + this.func_150177_e(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_); + p_149726_1_.notifyBlocksOfNeighborChange(p_149726_2_, p_149726_3_ + 1, p_149726_4_, this); + p_149726_1_.notifyBlocksOfNeighborChange(p_149726_2_, p_149726_3_ - 1, p_149726_4_, this); + this.func_150172_m(p_149726_1_, p_149726_2_ - 1, p_149726_3_, p_149726_4_); + this.func_150172_m(p_149726_1_, p_149726_2_ + 1, p_149726_3_, p_149726_4_); + this.func_150172_m(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_ - 1); + this.func_150172_m(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_ + 1); + + if (p_149726_1_.getBlock(p_149726_2_ - 1, p_149726_3_, p_149726_4_).isNormalCube()) + { + this.func_150172_m(p_149726_1_, p_149726_2_ - 1, p_149726_3_ + 1, p_149726_4_); + } + else + { + this.func_150172_m(p_149726_1_, p_149726_2_ - 1, p_149726_3_ - 1, p_149726_4_); + } + + if (p_149726_1_.getBlock(p_149726_2_ + 1, p_149726_3_, p_149726_4_).isNormalCube()) + { + this.func_150172_m(p_149726_1_, p_149726_2_ + 1, p_149726_3_ + 1, p_149726_4_); + } + else + { + this.func_150172_m(p_149726_1_, p_149726_2_ + 1, p_149726_3_ - 1, p_149726_4_); + } + + if (p_149726_1_.getBlock(p_149726_2_, p_149726_3_, p_149726_4_ - 1).isNormalCube()) + { + this.func_150172_m(p_149726_1_, p_149726_2_, p_149726_3_ + 1, p_149726_4_ - 1); + } + else + { + this.func_150172_m(p_149726_1_, p_149726_2_, p_149726_3_ - 1, p_149726_4_ - 1); + } + + if (p_149726_1_.getBlock(p_149726_2_, p_149726_3_, p_149726_4_ + 1).isNormalCube()) + { + this.func_150172_m(p_149726_1_, p_149726_2_, p_149726_3_ + 1, p_149726_4_ + 1); + } + else + { + this.func_150172_m(p_149726_1_, p_149726_2_, p_149726_3_ - 1, p_149726_4_ + 1); + } + } + } + + public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) + { + super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_); + + if (!p_149749_1_.isRemote) + { + p_149749_1_.notifyBlocksOfNeighborChange(p_149749_2_, p_149749_3_ + 1, p_149749_4_, this); + p_149749_1_.notifyBlocksOfNeighborChange(p_149749_2_, p_149749_3_ - 1, p_149749_4_, this); + p_149749_1_.notifyBlocksOfNeighborChange(p_149749_2_ + 1, p_149749_3_, p_149749_4_, this); + p_149749_1_.notifyBlocksOfNeighborChange(p_149749_2_ - 1, p_149749_3_, p_149749_4_, this); + p_149749_1_.notifyBlocksOfNeighborChange(p_149749_2_, p_149749_3_, p_149749_4_ + 1, this); + p_149749_1_.notifyBlocksOfNeighborChange(p_149749_2_, p_149749_3_, p_149749_4_ - 1, this); + this.func_150177_e(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_); + this.func_150172_m(p_149749_1_, p_149749_2_ - 1, p_149749_3_, p_149749_4_); + this.func_150172_m(p_149749_1_, p_149749_2_ + 1, p_149749_3_, p_149749_4_); + this.func_150172_m(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_ - 1); + this.func_150172_m(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_ + 1); + + if (p_149749_1_.getBlock(p_149749_2_ - 1, p_149749_3_, p_149749_4_).isNormalCube()) + { + this.func_150172_m(p_149749_1_, p_149749_2_ - 1, p_149749_3_ + 1, p_149749_4_); + } + else + { + this.func_150172_m(p_149749_1_, p_149749_2_ - 1, p_149749_3_ - 1, p_149749_4_); + } + + if (p_149749_1_.getBlock(p_149749_2_ + 1, p_149749_3_, p_149749_4_).isNormalCube()) + { + this.func_150172_m(p_149749_1_, p_149749_2_ + 1, p_149749_3_ + 1, p_149749_4_); + } + else + { + this.func_150172_m(p_149749_1_, p_149749_2_ + 1, p_149749_3_ - 1, p_149749_4_); + } + + if (p_149749_1_.getBlock(p_149749_2_, p_149749_3_, p_149749_4_ - 1).isNormalCube()) + { + this.func_150172_m(p_149749_1_, p_149749_2_, p_149749_3_ + 1, p_149749_4_ - 1); + } + else + { + this.func_150172_m(p_149749_1_, p_149749_2_, p_149749_3_ - 1, p_149749_4_ - 1); + } + + if (p_149749_1_.getBlock(p_149749_2_, p_149749_3_, p_149749_4_ + 1).isNormalCube()) + { + this.func_150172_m(p_149749_1_, p_149749_2_, p_149749_3_ + 1, p_149749_4_ + 1); + } + else + { + this.func_150172_m(p_149749_1_, p_149749_2_, p_149749_3_ - 1, p_149749_4_ + 1); + } + } + } + + private int func_150178_a(World p_150178_1_, int p_150178_2_, int p_150178_3_, int p_150178_4_, int p_150178_5_) + { + if (p_150178_1_.getBlock(p_150178_2_, p_150178_3_, p_150178_4_) != this) + { + return p_150178_5_; + } + else + { + int i1 = p_150178_1_.getBlockMetadata(p_150178_2_, p_150178_3_, p_150178_4_); + return i1 > p_150178_5_ ? i1 : p_150178_5_; + } + } + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) + { + if (!p_149695_1_.isRemote) + { + boolean flag = this.canPlaceBlockAt(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_); + + if (flag) + { + this.func_150177_e(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_); + } + else + { + this.dropBlockAsItem(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, 0, 0); + p_149695_1_.setBlockToAir(p_149695_2_, p_149695_3_, p_149695_4_); + } + + super.onNeighborBlockChange(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, p_149695_5_); + } + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return Items.redstone; + } + + public int isProvidingStrongPower(IBlockAccess p_149748_1_, int p_149748_2_, int p_149748_3_, int p_149748_4_, int p_149748_5_) + { + return !this.field_150181_a ? 0 : this.isProvidingWeakPower(p_149748_1_, p_149748_2_, p_149748_3_, p_149748_4_, p_149748_5_); + } + + public int isProvidingWeakPower(IBlockAccess p_149709_1_, int p_149709_2_, int p_149709_3_, int p_149709_4_, int p_149709_5_) + { + if (!this.field_150181_a) + { + return 0; + } + else + { + int i1 = p_149709_1_.getBlockMetadata(p_149709_2_, p_149709_3_, p_149709_4_); + + if (i1 == 0) + { + return 0; + } + else if (p_149709_5_ == 1) + { + return i1; + } + else + { + boolean flag = func_150176_g(p_149709_1_, p_149709_2_ - 1, p_149709_3_, p_149709_4_, 1) || !p_149709_1_.getBlock(p_149709_2_ - 1, p_149709_3_, p_149709_4_).isNormalCube() && func_150176_g(p_149709_1_, p_149709_2_ - 1, p_149709_3_ - 1, p_149709_4_, -1); + boolean flag1 = func_150176_g(p_149709_1_, p_149709_2_ + 1, p_149709_3_, p_149709_4_, 3) || !p_149709_1_.getBlock(p_149709_2_ + 1, p_149709_3_, p_149709_4_).isNormalCube() && func_150176_g(p_149709_1_, p_149709_2_ + 1, p_149709_3_ - 1, p_149709_4_, -1); + boolean flag2 = func_150176_g(p_149709_1_, p_149709_2_, p_149709_3_, p_149709_4_ - 1, 2) || !p_149709_1_.getBlock(p_149709_2_, p_149709_3_, p_149709_4_ - 1).isNormalCube() && func_150176_g(p_149709_1_, p_149709_2_, p_149709_3_ - 1, p_149709_4_ - 1, -1); + boolean flag3 = func_150176_g(p_149709_1_, p_149709_2_, p_149709_3_, p_149709_4_ + 1, 0) || !p_149709_1_.getBlock(p_149709_2_, p_149709_3_, p_149709_4_ + 1).isNormalCube() && func_150176_g(p_149709_1_, p_149709_2_, p_149709_3_ - 1, p_149709_4_ + 1, -1); + + if (!p_149709_1_.getBlock(p_149709_2_, p_149709_3_ + 1, p_149709_4_).isNormalCube()) + { + if (p_149709_1_.getBlock(p_149709_2_ - 1, p_149709_3_, p_149709_4_).isNormalCube() && func_150176_g(p_149709_1_, p_149709_2_ - 1, p_149709_3_ + 1, p_149709_4_, -1)) + { + flag = true; + } + + if (p_149709_1_.getBlock(p_149709_2_ + 1, p_149709_3_, p_149709_4_).isNormalCube() && func_150176_g(p_149709_1_, p_149709_2_ + 1, p_149709_3_ + 1, p_149709_4_, -1)) + { + flag1 = true; + } + + if (p_149709_1_.getBlock(p_149709_2_, p_149709_3_, p_149709_4_ - 1).isNormalCube() && func_150176_g(p_149709_1_, p_149709_2_, p_149709_3_ + 1, p_149709_4_ - 1, -1)) + { + flag2 = true; + } + + if (p_149709_1_.getBlock(p_149709_2_, p_149709_3_, p_149709_4_ + 1).isNormalCube() && func_150176_g(p_149709_1_, p_149709_2_, p_149709_3_ + 1, p_149709_4_ + 1, -1)) + { + flag3 = true; + } + } + + return !flag2 && !flag1 && !flag && !flag3 && p_149709_5_ >= 2 && p_149709_5_ <= 5 ? i1 : (p_149709_5_ == 2 && flag2 && !flag && !flag1 ? i1 : (p_149709_5_ == 3 && flag3 && !flag && !flag1 ? i1 : (p_149709_5_ == 4 && flag && !flag2 && !flag3 ? i1 : (p_149709_5_ == 5 && flag1 && !flag2 && !flag3 ? i1 : 0)))); + } + } + } + + public boolean canProvidePower() + { + return this.field_150181_a; + } + + public static boolean isPowerProviderOrWire(IBlockAccess p_150174_0_, int p_150174_1_, int p_150174_2_, int p_150174_3_, int p_150174_4_) + { + Block block = p_150174_0_.getBlock(p_150174_1_, p_150174_2_, p_150174_3_); + + if (block == Blocks.redstone_wire) + { + return true; + } + else if (!Blocks.unpowered_repeater.func_149907_e(block)) + { + return block.canConnectRedstone(p_150174_0_, p_150174_1_, p_150174_2_, p_150174_3_, p_150174_4_); + } + else + { + int i1 = p_150174_0_.getBlockMetadata(p_150174_1_, p_150174_2_, p_150174_3_); + return p_150174_4_ == (i1 & 3) || p_150174_4_ == Direction.rotateOpposite[i1 & 3]; + } + } + + @SideOnly(Side.CLIENT) + public void randomDisplayTick(World p_149734_1_, int p_149734_2_, int p_149734_3_, int p_149734_4_, Random p_149734_5_) + { + int l = p_149734_1_.getBlockMetadata(p_149734_2_, p_149734_3_, p_149734_4_); + + if (l > 0) + { + double d0 = (double)p_149734_2_ + 0.5D + ((double)p_149734_5_.nextFloat() - 0.5D) * 0.2D; + double d1 = (double)((float)p_149734_3_ + 0.0625F); + double d2 = (double)p_149734_4_ + 0.5D + ((double)p_149734_5_.nextFloat() - 0.5D) * 0.2D; + float f = (float)l / 15.0F; + float f1 = f * 0.6F + 0.4F; + + if (l == 0) + { + f1 = 0.0F; + } + + float f2 = f * f * 0.7F - 0.5F; + float f3 = f * f * 0.6F - 0.7F; + + if (f2 < 0.0F) + { + f2 = 0.0F; + } + + if (f3 < 0.0F) + { + f3 = 0.0F; + } + + p_149734_1_.spawnParticle("reddust", d0, d1, d2, (double)f1, (double)f2, (double)f3); + } + } + + public static boolean func_150176_g(IBlockAccess p_150176_0_, int p_150176_1_, int p_150176_2_, int p_150176_3_, int p_150176_4_) + { + if (isPowerProviderOrWire(p_150176_0_, p_150176_1_, p_150176_2_, p_150176_3_, p_150176_4_)) + { + return true; + } + else if (p_150176_0_.getBlock(p_150176_1_, p_150176_2_, p_150176_3_) == Blocks.powered_repeater) + { + int i1 = p_150176_0_.getBlockMetadata(p_150176_1_, p_150176_2_, p_150176_3_); + return p_150176_4_ == (i1 & 3); + } + else + { + return false; + } + } + + @SideOnly(Side.CLIENT) + public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) + { + return Items.redstone; + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.field_150182_M = p_149651_1_.registerIcon(this.getTextureName() + "_" + "cross"); + this.field_150183_N = p_149651_1_.registerIcon(this.getTextureName() + "_" + "line"); + this.field_150184_O = p_149651_1_.registerIcon(this.getTextureName() + "_" + "cross_overlay"); + this.field_150180_P = p_149651_1_.registerIcon(this.getTextureName() + "_" + "line_overlay"); + this.blockIcon = this.field_150182_M; + } + + @SideOnly(Side.CLIENT) + public static IIcon getRedstoneWireIcon(String p_150173_0_) + { + return p_150173_0_.equals("cross") ? Blocks.redstone_wire.field_150182_M : (p_150173_0_.equals("line") ? Blocks.redstone_wire.field_150183_N : (p_150173_0_.equals("cross_overlay") ? Blocks.redstone_wire.field_150184_O : (p_150173_0_.equals("line_overlay") ? Blocks.redstone_wire.field_150180_P : null))); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockReed.java b/src/main/java/net/minecraft/block/BlockReed.java new file mode 100644 index 0000000..a503ec9 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockReed.java @@ -0,0 +1,145 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import net.minecraftforge.common.EnumPlantType; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.common.IPlantable; + +public class BlockReed extends Block implements IPlantable +{ + private static final String __OBFID = "CL_00000300"; + + protected BlockReed() + { + super(Material.plants); + float f = 0.375F; + this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 1.0F, 0.5F + f); + this.setTickRandomly(true); + } + + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) + { + if (p_149674_1_.getBlock(p_149674_2_, p_149674_3_ - 1, p_149674_4_) == Blocks.reeds || this.func_150170_e(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_)) + { + if (p_149674_1_.isAirBlock(p_149674_2_, p_149674_3_ + 1, p_149674_4_)) + { + int l; + + for (l = 1; p_149674_1_.getBlock(p_149674_2_, p_149674_3_ - l, p_149674_4_) == this; ++l) + { + ; + } + + if (l < 3) + { + int i1 = p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_); + + if (i1 == 15) + { + p_149674_1_.setBlock(p_149674_2_, p_149674_3_ + 1, p_149674_4_, this); + p_149674_1_.setBlockMetadataWithNotify(p_149674_2_, p_149674_3_, p_149674_4_, 0, 4); + } + else + { + p_149674_1_.setBlockMetadataWithNotify(p_149674_2_, p_149674_3_, p_149674_4_, i1 + 1, 4); + } + } + } + } + } + + public boolean canPlaceBlockAt(World p_149742_1_, int p_149742_2_, int p_149742_3_, int p_149742_4_) + { + Block block = p_149742_1_.getBlock(p_149742_2_, p_149742_3_ - 1, p_149742_4_); + return block.canSustainPlant(p_149742_1_, p_149742_2_, p_149742_3_ - 1, p_149742_4_, ForgeDirection.UP, this); + } + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) + { + this.func_150170_e(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_); + } + + protected final boolean func_150170_e(World p_150170_1_, int p_150170_2_, int p_150170_3_, int p_150170_4_) + { + if (!this.canBlockStay(p_150170_1_, p_150170_2_, p_150170_3_, p_150170_4_)) + { + this.dropBlockAsItem(p_150170_1_, p_150170_2_, p_150170_3_, p_150170_4_, p_150170_1_.getBlockMetadata(p_150170_2_, p_150170_3_, p_150170_4_), 0); + p_150170_1_.setBlockToAir(p_150170_2_, p_150170_3_, p_150170_4_); + return false; + } + else + { + return true; + } + } + + public boolean canBlockStay(World p_149718_1_, int p_149718_2_, int p_149718_3_, int p_149718_4_) + { + return this.canPlaceBlockAt(p_149718_1_, p_149718_2_, p_149718_3_, p_149718_4_); + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) + { + return null; + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return Items.reeds; + } + + public boolean isOpaqueCube() + { + return false; + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public int getRenderType() + { + return 1; + } + + @SideOnly(Side.CLIENT) + public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) + { + return Items.reeds; + } + + @SideOnly(Side.CLIENT) + public int colorMultiplier(IBlockAccess p_149720_1_, int p_149720_2_, int p_149720_3_, int p_149720_4_) + { + return p_149720_1_.getBiomeGenForCoords(p_149720_2_, p_149720_4_).getBiomeGrassColor(p_149720_2_, p_149720_3_, p_149720_4_); + } + + @Override + public EnumPlantType getPlantType(IBlockAccess world, int x, int y, int z) + { + return EnumPlantType.Beach; + } + + @Override + public Block getPlant(IBlockAccess world, int x, int y, int z) + { + return this; + } + + @Override + public int getPlantMetadata(IBlockAccess world, int x, int y, int z) + { + return world.getBlockMetadata(x, y, z); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockRotatedPillar.java b/src/main/java/net/minecraft/block/BlockRotatedPillar.java new file mode 100644 index 0000000..22c9290 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockRotatedPillar.java @@ -0,0 +1,81 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.material.Material; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +public abstract class BlockRotatedPillar extends Block +{ + @SideOnly(Side.CLIENT) + protected IIcon field_150164_N; + private static final String __OBFID = "CL_00000302"; + + protected BlockRotatedPillar(Material p_i45425_1_) + { + super(p_i45425_1_); + } + + public int getRenderType() + { + return 31; + } + + public int onBlockPlaced(World p_149660_1_, int p_149660_2_, int p_149660_3_, int p_149660_4_, int p_149660_5_, float p_149660_6_, float p_149660_7_, float p_149660_8_, int p_149660_9_) + { + int j1 = p_149660_9_ & 3; + byte b0 = 0; + + switch (p_149660_5_) + { + case 0: + case 1: + b0 = 0; + break; + case 2: + case 3: + b0 = 8; + break; + case 4: + case 5: + b0 = 4; + } + + return j1 | b0; + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + int k = p_149691_2_ & 12; + int l = p_149691_2_ & 3; + return k == 0 && (p_149691_1_ == 1 || p_149691_1_ == 0) ? this.getTopIcon(l) : (k == 4 && (p_149691_1_ == 5 || p_149691_1_ == 4) ? this.getTopIcon(l) : (k == 8 && (p_149691_1_ == 2 || p_149691_1_ == 3) ? this.getTopIcon(l) : this.getSideIcon(l))); + } + + public int damageDropped(int p_149692_1_) + { + return p_149692_1_ & 3; + } + + @SideOnly(Side.CLIENT) + protected abstract IIcon getSideIcon(int var1); + + @SideOnly(Side.CLIENT) + protected IIcon getTopIcon(int p_150161_1_) + { + return this.field_150164_N; + } + + public int func_150162_k(int p_150162_1_) + { + return p_150162_1_ & 3; + } + + protected ItemStack createStackedBlock(int p_149644_1_) + { + return new ItemStack(Item.getItemFromBlock(this), 1, this.func_150162_k(p_149644_1_)); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockSand.java b/src/main/java/net/minecraft/block/BlockSand.java new file mode 100644 index 0000000..fa711e4 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockSand.java @@ -0,0 +1,51 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.block.material.MapColor; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +public class BlockSand extends BlockFalling +{ + public static final String[] field_149838_a = new String[] {"default", "red"}; + @SideOnly(Side.CLIENT) + private static IIcon field_149837_b; + @SideOnly(Side.CLIENT) + private static IIcon field_149839_N; + private static final String __OBFID = "CL_00000303"; + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return p_149691_2_ == 1 ? field_149839_N : field_149837_b; + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + field_149837_b = p_149651_1_.registerIcon("sand"); + field_149839_N = p_149651_1_.registerIcon("red_sand"); + } + + public int damageDropped(int p_149692_1_) + { + return p_149692_1_; + } + + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_) + { + p_149666_3_.add(new ItemStack(p_149666_1_, 1, 0)); + p_149666_3_.add(new ItemStack(p_149666_1_, 1, 1)); + } + + public MapColor getMapColor(int p_149728_1_) + { + return p_149728_1_ == 1 ? MapColor.dirtColor : MapColor.sandColor; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockSandStone.java b/src/main/java/net/minecraft/block/BlockSandStone.java new file mode 100644 index 0000000..0880748 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockSandStone.java @@ -0,0 +1,82 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +public class BlockSandStone extends Block +{ + public static final String[] field_150157_a = new String[] {"default", "chiseled", "smooth"}; + private static final String[] field_150156_b = new String[] {"normal", "carved", "smooth"}; + @SideOnly(Side.CLIENT) + private IIcon[] field_150158_M; + @SideOnly(Side.CLIENT) + private IIcon field_150159_N; + @SideOnly(Side.CLIENT) + private IIcon field_150160_O; + private static final String __OBFID = "CL_00000304"; + + public BlockSandStone() + { + super(Material.rock); + this.setCreativeTab(CreativeTabs.tabBlock); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + if (p_149691_1_ != 1 && (p_149691_1_ != 0 || p_149691_2_ != 1 && p_149691_2_ != 2)) + { + if (p_149691_1_ == 0) + { + return this.field_150160_O; + } + else + { + if (p_149691_2_ < 0 || p_149691_2_ >= this.field_150158_M.length) + { + p_149691_2_ = 0; + } + + return this.field_150158_M[p_149691_2_]; + } + } + else + { + return this.field_150159_N; + } + } + + public int damageDropped(int p_149692_1_) + { + return p_149692_1_; + } + + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_) + { + p_149666_3_.add(new ItemStack(p_149666_1_, 1, 0)); + p_149666_3_.add(new ItemStack(p_149666_1_, 1, 1)); + p_149666_3_.add(new ItemStack(p_149666_1_, 1, 2)); + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.field_150158_M = new IIcon[field_150156_b.length]; + + for (int i = 0; i < this.field_150158_M.length; ++i) + { + this.field_150158_M[i] = p_149651_1_.registerIcon(this.getTextureName() + "_" + field_150156_b[i]); + } + + this.field_150159_N = p_149651_1_.registerIcon(this.getTextureName() + "_top"); + this.field_150160_O = p_149651_1_.registerIcon(this.getTextureName() + "_bottom"); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockSapling.java b/src/main/java/net/minecraft/block/BlockSapling.java new file mode 100644 index 0000000..8de3ebc --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockSapling.java @@ -0,0 +1,236 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import java.util.Random; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenBigTree; +import net.minecraft.world.gen.feature.WorldGenCanopyTree; +import net.minecraft.world.gen.feature.WorldGenForest; +import net.minecraft.world.gen.feature.WorldGenMegaJungle; +import net.minecraft.world.gen.feature.WorldGenMegaPineTree; +import net.minecraft.world.gen.feature.WorldGenSavannaTree; +import net.minecraft.world.gen.feature.WorldGenTaiga2; +import net.minecraft.world.gen.feature.WorldGenTrees; +import net.minecraft.world.gen.feature.WorldGenerator; + +public class BlockSapling extends BlockBush implements IGrowable +{ + public static final String[] field_149882_a = new String[] {"oak", "spruce", "birch", "jungle", "acacia", "roofed_oak"}; + private static final IIcon[] field_149881_b = new IIcon[field_149882_a.length]; + private static final String __OBFID = "CL_00000305"; + + protected BlockSapling() + { + float f = 0.4F; + this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 2.0F, 0.5F + f); + this.setCreativeTab(CreativeTabs.tabDecorations); + } + + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) + { + if (!p_149674_1_.isRemote) + { + super.updateTick(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, p_149674_5_); + + if (p_149674_1_.getBlockLightValue(p_149674_2_, p_149674_3_ + 1, p_149674_4_) >= 9 && p_149674_5_.nextInt(7) == 0) + { + this.func_149879_c(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, p_149674_5_); + } + } + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + p_149691_2_ &= 7; + return field_149881_b[MathHelper.clamp_int(p_149691_2_, 0, 5)]; + } + + public void func_149879_c(World p_149879_1_, int p_149879_2_, int p_149879_3_, int p_149879_4_, Random p_149879_5_) + { + int l = p_149879_1_.getBlockMetadata(p_149879_2_, p_149879_3_, p_149879_4_); + + if ((l & 8) == 0) + { + p_149879_1_.setBlockMetadataWithNotify(p_149879_2_, p_149879_3_, p_149879_4_, l | 8, 4); + } + else + { + this.func_149878_d(p_149879_1_, p_149879_2_, p_149879_3_, p_149879_4_, p_149879_5_); + } + } + + public void func_149878_d(World p_149878_1_, int p_149878_2_, int p_149878_3_, int p_149878_4_, Random p_149878_5_) + { + if (!net.minecraftforge.event.terraingen.TerrainGen.saplingGrowTree(p_149878_1_, p_149878_5_, p_149878_2_, p_149878_3_, p_149878_4_)) return; + int l = p_149878_1_.getBlockMetadata(p_149878_2_, p_149878_3_, p_149878_4_) & 7; + Object object = p_149878_5_.nextInt(10) == 0 ? new WorldGenBigTree(true) : new WorldGenTrees(true); + int i1 = 0; + int j1 = 0; + boolean flag = false; + + switch (l) + { + case 0: + default: + break; + case 1: + label78: + + for (i1 = 0; i1 >= -1; --i1) + { + for (j1 = 0; j1 >= -1; --j1) + { + if (this.func_149880_a(p_149878_1_, p_149878_2_ + i1, p_149878_3_, p_149878_4_ + j1, 1) && this.func_149880_a(p_149878_1_, p_149878_2_ + i1 + 1, p_149878_3_, p_149878_4_ + j1, 1) && this.func_149880_a(p_149878_1_, p_149878_2_ + i1, p_149878_3_, p_149878_4_ + j1 + 1, 1) && this.func_149880_a(p_149878_1_, p_149878_2_ + i1 + 1, p_149878_3_, p_149878_4_ + j1 + 1, 1)) + { + object = new WorldGenMegaPineTree(false, p_149878_5_.nextBoolean()); + flag = true; + break label78; + } + } + } + + if (!flag) + { + j1 = 0; + i1 = 0; + object = new WorldGenTaiga2(true); + } + + break; + case 2: + object = new WorldGenForest(true, false); + break; + case 3: + label93: + + for (i1 = 0; i1 >= -1; --i1) + { + for (j1 = 0; j1 >= -1; --j1) + { + if (this.func_149880_a(p_149878_1_, p_149878_2_ + i1, p_149878_3_, p_149878_4_ + j1, 3) && this.func_149880_a(p_149878_1_, p_149878_2_ + i1 + 1, p_149878_3_, p_149878_4_ + j1, 3) && this.func_149880_a(p_149878_1_, p_149878_2_ + i1, p_149878_3_, p_149878_4_ + j1 + 1, 3) && this.func_149880_a(p_149878_1_, p_149878_2_ + i1 + 1, p_149878_3_, p_149878_4_ + j1 + 1, 3)) + { + object = new WorldGenMegaJungle(true, 10, 20, 3, 3); + flag = true; + break label93; + } + } + } + + if (!flag) + { + j1 = 0; + i1 = 0; + object = new WorldGenTrees(true, 4 + p_149878_5_.nextInt(7), 3, 3, false); + } + + break; + case 4: + object = new WorldGenSavannaTree(true); + break; + case 5: + label108: + + for (i1 = 0; i1 >= -1; --i1) + { + for (j1 = 0; j1 >= -1; --j1) + { + if (this.func_149880_a(p_149878_1_, p_149878_2_ + i1, p_149878_3_, p_149878_4_ + j1, 5) && this.func_149880_a(p_149878_1_, p_149878_2_ + i1 + 1, p_149878_3_, p_149878_4_ + j1, 5) && this.func_149880_a(p_149878_1_, p_149878_2_ + i1, p_149878_3_, p_149878_4_ + j1 + 1, 5) && this.func_149880_a(p_149878_1_, p_149878_2_ + i1 + 1, p_149878_3_, p_149878_4_ + j1 + 1, 5)) + { + object = new WorldGenCanopyTree(true); + flag = true; + break label108; + } + } + } + + if (!flag) + { + return; + } + } + + Block block = Blocks.air; + + if (flag) + { + p_149878_1_.setBlock(p_149878_2_ + i1, p_149878_3_, p_149878_4_ + j1, block, 0, 4); + p_149878_1_.setBlock(p_149878_2_ + i1 + 1, p_149878_3_, p_149878_4_ + j1, block, 0, 4); + p_149878_1_.setBlock(p_149878_2_ + i1, p_149878_3_, p_149878_4_ + j1 + 1, block, 0, 4); + p_149878_1_.setBlock(p_149878_2_ + i1 + 1, p_149878_3_, p_149878_4_ + j1 + 1, block, 0, 4); + } + else + { + p_149878_1_.setBlock(p_149878_2_, p_149878_3_, p_149878_4_, block, 0, 4); + } + + if (!((WorldGenerator)object).generate(p_149878_1_, p_149878_5_, p_149878_2_ + i1, p_149878_3_, p_149878_4_ + j1)) + { + if (flag) + { + p_149878_1_.setBlock(p_149878_2_ + i1, p_149878_3_, p_149878_4_ + j1, this, l, 4); + p_149878_1_.setBlock(p_149878_2_ + i1 + 1, p_149878_3_, p_149878_4_ + j1, this, l, 4); + p_149878_1_.setBlock(p_149878_2_ + i1, p_149878_3_, p_149878_4_ + j1 + 1, this, l, 4); + p_149878_1_.setBlock(p_149878_2_ + i1 + 1, p_149878_3_, p_149878_4_ + j1 + 1, this, l, 4); + } + else + { + p_149878_1_.setBlock(p_149878_2_, p_149878_3_, p_149878_4_, this, l, 4); + } + } + } + + public boolean func_149880_a(World p_149880_1_, int p_149880_2_, int p_149880_3_, int p_149880_4_, int p_149880_5_) + { + return p_149880_1_.getBlock(p_149880_2_, p_149880_3_, p_149880_4_) == this && (p_149880_1_.getBlockMetadata(p_149880_2_, p_149880_3_, p_149880_4_) & 7) == p_149880_5_; + } + + public int damageDropped(int p_149692_1_) + { + return MathHelper.clamp_int(p_149692_1_ & 7, 0, 5); + } + + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_) + { + p_149666_3_.add(new ItemStack(p_149666_1_, 1, 0)); + p_149666_3_.add(new ItemStack(p_149666_1_, 1, 1)); + p_149666_3_.add(new ItemStack(p_149666_1_, 1, 2)); + p_149666_3_.add(new ItemStack(p_149666_1_, 1, 3)); + p_149666_3_.add(new ItemStack(p_149666_1_, 1, 4)); + p_149666_3_.add(new ItemStack(p_149666_1_, 1, 5)); + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + for (int i = 0; i < field_149881_b.length; ++i) + { + field_149881_b[i] = p_149651_1_.registerIcon(this.getTextureName() + "_" + field_149882_a[i]); + } + } + + public boolean func_149851_a(World p_149851_1_, int p_149851_2_, int p_149851_3_, int p_149851_4_, boolean p_149851_5_) + { + return true; + } + + public boolean func_149852_a(World p_149852_1_, Random p_149852_2_, int p_149852_3_, int p_149852_4_, int p_149852_5_) + { + return (double)p_149852_1_.rand.nextFloat() < 0.45D; + } + + public void func_149853_b(World p_149853_1_, Random p_149853_2_, int p_149853_3_, int p_149853_4_, int p_149853_5_) + { + this.func_149879_c(p_149853_1_, p_149853_3_, p_149853_4_, p_149853_5_, p_149853_2_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockSign.java b/src/main/java/net/minecraft/block/BlockSign.java new file mode 100644 index 0000000..f65fdce --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockSign.java @@ -0,0 +1,176 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockSign extends BlockContainer +{ + private Class field_149968_a; + private boolean field_149967_b; + private static final String __OBFID = "CL_00000306"; + + protected BlockSign(Class p_i45426_1_, boolean p_i45426_2_) + { + super(Material.wood); + this.field_149967_b = p_i45426_2_; + this.field_149968_a = p_i45426_1_; + float f = 0.25F; + float f1 = 1.0F; + this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f1, 0.5F + f); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return Blocks.planks.getBlockTextureFromSide(p_149691_1_); + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) + { + return null; + } + + public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) + { + if (!this.field_149967_b) + { + int l = p_149719_1_.getBlockMetadata(p_149719_2_, p_149719_3_, p_149719_4_); + float f = 0.28125F; + float f1 = 0.78125F; + float f2 = 0.0F; + float f3 = 1.0F; + float f4 = 0.125F; + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + + if (l == 2) + { + this.setBlockBounds(f2, f, 1.0F - f4, f3, f1, 1.0F); + } + + if (l == 3) + { + this.setBlockBounds(f2, f, 0.0F, f3, f1, f4); + } + + if (l == 4) + { + this.setBlockBounds(1.0F - f4, f, f2, 1.0F, f1, f3); + } + + if (l == 5) + { + this.setBlockBounds(0.0F, f, f2, f4, f1, f3); + } + } + } + + @SideOnly(Side.CLIENT) + public AxisAlignedBB getSelectedBoundingBoxFromPool(World p_149633_1_, int p_149633_2_, int p_149633_3_, int p_149633_4_) + { + this.setBlockBoundsBasedOnState(p_149633_1_, p_149633_2_, p_149633_3_, p_149633_4_); + return super.getSelectedBoundingBoxFromPool(p_149633_1_, p_149633_2_, p_149633_3_, p_149633_4_); + } + + public int getRenderType() + { + return -1; + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public boolean getBlocksMovement(IBlockAccess p_149655_1_, int p_149655_2_, int p_149655_3_, int p_149655_4_) + { + return true; + } + + public boolean isOpaqueCube() + { + return false; + } + + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) + { + try + { + return (TileEntity)this.field_149968_a.newInstance(); + } + catch (Exception exception) + { + throw new RuntimeException(exception); + } + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return Items.sign; + } + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) + { + boolean flag = false; + + if (this.field_149967_b) + { + if (!p_149695_1_.getBlock(p_149695_2_, p_149695_3_ - 1, p_149695_4_).getMaterial().isSolid()) + { + flag = true; + } + } + else + { + int l = p_149695_1_.getBlockMetadata(p_149695_2_, p_149695_3_, p_149695_4_); + flag = true; + + if (l == 2 && p_149695_1_.getBlock(p_149695_2_, p_149695_3_, p_149695_4_ + 1).getMaterial().isSolid()) + { + flag = false; + } + + if (l == 3 && p_149695_1_.getBlock(p_149695_2_, p_149695_3_, p_149695_4_ - 1).getMaterial().isSolid()) + { + flag = false; + } + + if (l == 4 && p_149695_1_.getBlock(p_149695_2_ + 1, p_149695_3_, p_149695_4_).getMaterial().isSolid()) + { + flag = false; + } + + if (l == 5 && p_149695_1_.getBlock(p_149695_2_ - 1, p_149695_3_, p_149695_4_).getMaterial().isSolid()) + { + flag = false; + } + } + + if (flag) + { + this.dropBlockAsItem(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, p_149695_1_.getBlockMetadata(p_149695_2_, p_149695_3_, p_149695_4_), 0); + p_149695_1_.setBlockToAir(p_149695_2_, p_149695_3_, p_149695_4_); + } + + super.onNeighborBlockChange(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, p_149695_5_); + } + + @SideOnly(Side.CLIENT) + public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) + { + return Items.sign; + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) {} +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockSilverfish.java b/src/main/java/net/minecraft/block/BlockSilverfish.java new file mode 100644 index 0000000..e7f19bf --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockSilverfish.java @@ -0,0 +1,168 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.monster.EntitySilverfish; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; +import org.apache.commons.lang3.tuple.ImmutablePair; + +public class BlockSilverfish extends Block +{ + public static final String[] field_150198_a = new String[] {"stone", "cobble", "brick", "mossybrick", "crackedbrick", "chiseledbrick"}; + private static final String __OBFID = "CL_00000271"; + + public BlockSilverfish() + { + super(Material.clay); + this.setHardness(0.0F); + this.setCreativeTab(CreativeTabs.tabDecorations); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + switch (p_149691_2_) + { + case 1: + return Blocks.cobblestone.getBlockTextureFromSide(p_149691_1_); + case 2: + return Blocks.stonebrick.getBlockTextureFromSide(p_149691_1_); + case 3: + return Blocks.stonebrick.getIcon(p_149691_1_, 1); + case 4: + return Blocks.stonebrick.getIcon(p_149691_1_, 2); + case 5: + return Blocks.stonebrick.getIcon(p_149691_1_, 3); + default: + return Blocks.stone.getBlockTextureFromSide(p_149691_1_); + } + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) {} + + public void onBlockDestroyedByPlayer(World p_149664_1_, int p_149664_2_, int p_149664_3_, int p_149664_4_, int p_149664_5_) + { + if (!p_149664_1_.isRemote) + { + EntitySilverfish entitysilverfish = new EntitySilverfish(p_149664_1_); + entitysilverfish.setLocationAndAngles((double)p_149664_2_ + 0.5D, (double)p_149664_3_, (double)p_149664_4_ + 0.5D, 0.0F, 0.0F); + p_149664_1_.spawnEntityInWorld(entitysilverfish); + entitysilverfish.spawnExplosionParticle(); + } + + super.onBlockDestroyedByPlayer(p_149664_1_, p_149664_2_, p_149664_3_, p_149664_4_, p_149664_5_); + } + + public int quantityDropped(Random p_149745_1_) + { + return 0; + } + + public static boolean func_150196_a(Block p_150196_0_) + { + return p_150196_0_ == Blocks.stone || p_150196_0_ == Blocks.cobblestone || p_150196_0_ == Blocks.stonebrick; + } + + public static int func_150195_a(Block p_150195_0_, int p_150195_1_) + { + if (p_150195_1_ == 0) + { + if (p_150195_0_ == Blocks.cobblestone) + { + return 1; + } + + if (p_150195_0_ == Blocks.stonebrick) + { + return 2; + } + } + else if (p_150195_0_ == Blocks.stonebrick) + { + switch (p_150195_1_) + { + case 1: + return 3; + case 2: + return 4; + case 3: + return 5; + } + } + + return 0; + } + + public static ImmutablePair func_150197_b(int p_150197_0_) + { + switch (p_150197_0_) + { + case 1: + return new ImmutablePair(Blocks.cobblestone, Integer.valueOf(0)); + case 2: + return new ImmutablePair(Blocks.stonebrick, Integer.valueOf(0)); + case 3: + return new ImmutablePair(Blocks.stonebrick, Integer.valueOf(1)); + case 4: + return new ImmutablePair(Blocks.stonebrick, Integer.valueOf(2)); + case 5: + return new ImmutablePair(Blocks.stonebrick, Integer.valueOf(3)); + default: + return new ImmutablePair(Blocks.stone, Integer.valueOf(0)); + } + } + + protected ItemStack createStackedBlock(int p_149644_1_) + { + switch (p_149644_1_) + { + case 1: + return new ItemStack(Blocks.cobblestone); + case 2: + return new ItemStack(Blocks.stonebrick); + case 3: + return new ItemStack(Blocks.stonebrick, 1, 1); + case 4: + return new ItemStack(Blocks.stonebrick, 1, 2); + case 5: + return new ItemStack(Blocks.stonebrick, 1, 3); + default: + return new ItemStack(Blocks.stone); + } + } + + public void dropBlockAsItemWithChance(World p_149690_1_, int p_149690_2_, int p_149690_3_, int p_149690_4_, int p_149690_5_, float p_149690_6_, int p_149690_7_) + { + if (!p_149690_1_.isRemote) + { + EntitySilverfish entitysilverfish = new EntitySilverfish(p_149690_1_); + entitysilverfish.setLocationAndAngles((double)p_149690_2_ + 0.5D, (double)p_149690_3_, (double)p_149690_4_ + 0.5D, 0.0F, 0.0F); + p_149690_1_.spawnEntityInWorld(entitysilverfish); + entitysilverfish.spawnExplosionParticle(); + } + } + + public int getDamageValue(World p_149643_1_, int p_149643_2_, int p_149643_3_, int p_149643_4_) + { + return p_149643_1_.getBlockMetadata(p_149643_2_, p_149643_3_, p_149643_4_); + } + + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_) + { + for (int i = 0; i < field_150198_a.length; ++i) + { + p_149666_3_.add(new ItemStack(p_149666_1_, 1, i)); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockSkull.java b/src/main/java/net/minecraft/block/BlockSkull.java new file mode 100644 index 0000000..0f1b703 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockSkull.java @@ -0,0 +1,301 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.boss.EntityWither; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemSkull; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.stats.AchievementList; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntitySkull; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.EnumDifficulty; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockSkull extends BlockContainer +{ + private static final String __OBFID = "CL_00000307"; + + protected BlockSkull() + { + super(Material.circuits); + this.setBlockBounds(0.25F, 0.0F, 0.25F, 0.75F, 0.5F, 0.75F); + } + + public int getRenderType() + { + return -1; + } + + public boolean isOpaqueCube() + { + return false; + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) + { + int l = p_149719_1_.getBlockMetadata(p_149719_2_, p_149719_3_, p_149719_4_) & 7; + + switch (l) + { + case 1: + default: + this.setBlockBounds(0.25F, 0.0F, 0.25F, 0.75F, 0.5F, 0.75F); + break; + case 2: + this.setBlockBounds(0.25F, 0.25F, 0.5F, 0.75F, 0.75F, 1.0F); + break; + case 3: + this.setBlockBounds(0.25F, 0.25F, 0.0F, 0.75F, 0.75F, 0.5F); + break; + case 4: + this.setBlockBounds(0.5F, 0.25F, 0.25F, 1.0F, 0.75F, 0.75F); + break; + case 5: + this.setBlockBounds(0.0F, 0.25F, 0.25F, 0.5F, 0.75F, 0.75F); + } + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) + { + this.setBlockBoundsBasedOnState(p_149668_1_, p_149668_2_, p_149668_3_, p_149668_4_); + return super.getCollisionBoundingBoxFromPool(p_149668_1_, p_149668_2_, p_149668_3_, p_149668_4_); + } + + public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_) + { + int l = MathHelper.floor_double((double)(p_149689_5_.rotationYaw * 4.0F / 360.0F) + 2.5D) & 3; + p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, l, 2); + } + + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) + { + return new TileEntitySkull(); + } + + @SideOnly(Side.CLIENT) + public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) + { + return Items.skull; + } + + public int getDamageValue(World p_149643_1_, int p_149643_2_, int p_149643_3_, int p_149643_4_) + { + TileEntity tileentity = p_149643_1_.getTileEntity(p_149643_2_, p_149643_3_, p_149643_4_); + return tileentity != null && tileentity instanceof TileEntitySkull ? ((TileEntitySkull)tileentity).func_145904_a() : super.getDamageValue(p_149643_1_, p_149643_2_, p_149643_3_, p_149643_4_); + } + + public int damageDropped(int p_149692_1_) + { + return p_149692_1_; + } + + public void onBlockHarvested(World p_149681_1_, int p_149681_2_, int p_149681_3_, int p_149681_4_, int p_149681_5_, EntityPlayer p_149681_6_) + { + if (p_149681_6_.capabilities.isCreativeMode) + { + p_149681_5_ |= 8; + p_149681_1_.setBlockMetadataWithNotify(p_149681_2_, p_149681_3_, p_149681_4_, p_149681_5_, 4); + } + + this.dropBlockAsItem(p_149681_1_, p_149681_2_, p_149681_3_, p_149681_4_, p_149681_5_, 0); + + super.onBlockHarvested(p_149681_1_, p_149681_2_, p_149681_3_, p_149681_4_, p_149681_5_, p_149681_6_); + } + + public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) + { + super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_); + } + + @Override + public ArrayList getDrops(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, int p_149749_6_, int fortune) + { + ArrayList ret = new ArrayList(); + { + if ((p_149749_6_ & 8) == 0) + { + ItemStack itemstack = new ItemStack(Items.skull, 1, this.getDamageValue(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_)); + TileEntitySkull tileentityskull = (TileEntitySkull)p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_); + + if (tileentityskull == null) return ret; + + if (tileentityskull.func_145904_a() == 3 && tileentityskull.func_145907_c() != null && tileentityskull.func_145907_c().length() > 0) + { + itemstack.setTagCompound(new NBTTagCompound()); + itemstack.getTagCompound().setString("SkullOwner", tileentityskull.func_145907_c()); + } + + ret.add(itemstack); + } + } + return ret; + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return Items.skull; + } + + public void func_149965_a(World p_149965_1_, int p_149965_2_, int p_149965_3_, int p_149965_4_, TileEntitySkull p_149965_5_) + { + if (p_149965_5_.func_145904_a() == 1 && p_149965_3_ >= 2 && p_149965_1_.difficultySetting != EnumDifficulty.PEACEFUL && !p_149965_1_.isRemote) + { + int l; + EntityWither entitywither; + Iterator iterator; + EntityPlayer entityplayer; + int i1; + + for (l = -2; l <= 0; ++l) + { + if (p_149965_1_.getBlock(p_149965_2_, p_149965_3_ - 1, p_149965_4_ + l) == Blocks.soul_sand && p_149965_1_.getBlock(p_149965_2_, p_149965_3_ - 1, p_149965_4_ + l + 1) == Blocks.soul_sand && p_149965_1_.getBlock(p_149965_2_, p_149965_3_ - 2, p_149965_4_ + l + 1) == Blocks.soul_sand && p_149965_1_.getBlock(p_149965_2_, p_149965_3_ - 1, p_149965_4_ + l + 2) == Blocks.soul_sand && this.func_149966_a(p_149965_1_, p_149965_2_, p_149965_3_, p_149965_4_ + l, 1) && this.func_149966_a(p_149965_1_, p_149965_2_, p_149965_3_, p_149965_4_ + l + 1, 1) && this.func_149966_a(p_149965_1_, p_149965_2_, p_149965_3_, p_149965_4_ + l + 2, 1)) + { + p_149965_1_.setBlockMetadataWithNotify(p_149965_2_, p_149965_3_, p_149965_4_ + l, 8, 2); + p_149965_1_.setBlockMetadataWithNotify(p_149965_2_, p_149965_3_, p_149965_4_ + l + 1, 8, 2); + p_149965_1_.setBlockMetadataWithNotify(p_149965_2_, p_149965_3_, p_149965_4_ + l + 2, 8, 2); + p_149965_1_.setBlock(p_149965_2_, p_149965_3_, p_149965_4_ + l, getBlockById(0), 0, 2); + p_149965_1_.setBlock(p_149965_2_, p_149965_3_, p_149965_4_ + l + 1, getBlockById(0), 0, 2); + p_149965_1_.setBlock(p_149965_2_, p_149965_3_, p_149965_4_ + l + 2, getBlockById(0), 0, 2); + p_149965_1_.setBlock(p_149965_2_, p_149965_3_ - 1, p_149965_4_ + l, getBlockById(0), 0, 2); + p_149965_1_.setBlock(p_149965_2_, p_149965_3_ - 1, p_149965_4_ + l + 1, getBlockById(0), 0, 2); + p_149965_1_.setBlock(p_149965_2_, p_149965_3_ - 1, p_149965_4_ + l + 2, getBlockById(0), 0, 2); + p_149965_1_.setBlock(p_149965_2_, p_149965_3_ - 2, p_149965_4_ + l + 1, getBlockById(0), 0, 2); + + if (!p_149965_1_.isRemote) + { + entitywither = new EntityWither(p_149965_1_); + entitywither.setLocationAndAngles((double)p_149965_2_ + 0.5D, (double)p_149965_3_ - 1.45D, (double)(p_149965_4_ + l) + 1.5D, 90.0F, 0.0F); + entitywither.renderYawOffset = 90.0F; + entitywither.func_82206_m(); + + if (!p_149965_1_.isRemote) + { + iterator = p_149965_1_.getEntitiesWithinAABB(EntityPlayer.class, entitywither.boundingBox.expand(50.0D, 50.0D, 50.0D)).iterator(); + + while (iterator.hasNext()) + { + entityplayer = (EntityPlayer)iterator.next(); + entityplayer.triggerAchievement(AchievementList.field_150963_I); + } + } + + p_149965_1_.spawnEntityInWorld(entitywither); + } + + for (i1 = 0; i1 < 120; ++i1) + { + p_149965_1_.spawnParticle("snowballpoof", (double)p_149965_2_ + p_149965_1_.rand.nextDouble(), (double)(p_149965_3_ - 2) + p_149965_1_.rand.nextDouble() * 3.9D, (double)(p_149965_4_ + l + 1) + p_149965_1_.rand.nextDouble(), 0.0D, 0.0D, 0.0D); + } + + p_149965_1_.notifyBlockChange(p_149965_2_, p_149965_3_, p_149965_4_ + l, getBlockById(0)); + p_149965_1_.notifyBlockChange(p_149965_2_, p_149965_3_, p_149965_4_ + l + 1, getBlockById(0)); + p_149965_1_.notifyBlockChange(p_149965_2_, p_149965_3_, p_149965_4_ + l + 2, getBlockById(0)); + p_149965_1_.notifyBlockChange(p_149965_2_, p_149965_3_ - 1, p_149965_4_ + l, getBlockById(0)); + p_149965_1_.notifyBlockChange(p_149965_2_, p_149965_3_ - 1, p_149965_4_ + l + 1, getBlockById(0)); + p_149965_1_.notifyBlockChange(p_149965_2_, p_149965_3_ - 1, p_149965_4_ + l + 2, getBlockById(0)); + p_149965_1_.notifyBlockChange(p_149965_2_, p_149965_3_ - 2, p_149965_4_ + l + 1, getBlockById(0)); + return; + } + } + + for (l = -2; l <= 0; ++l) + { + if (p_149965_1_.getBlock(p_149965_2_ + l, p_149965_3_ - 1, p_149965_4_) == Blocks.soul_sand && p_149965_1_.getBlock(p_149965_2_ + l + 1, p_149965_3_ - 1, p_149965_4_) == Blocks.soul_sand && p_149965_1_.getBlock(p_149965_2_ + l + 1, p_149965_3_ - 2, p_149965_4_) == Blocks.soul_sand && p_149965_1_.getBlock(p_149965_2_ + l + 2, p_149965_3_ - 1, p_149965_4_) == Blocks.soul_sand && this.func_149966_a(p_149965_1_, p_149965_2_ + l, p_149965_3_, p_149965_4_, 1) && this.func_149966_a(p_149965_1_, p_149965_2_ + l + 1, p_149965_3_, p_149965_4_, 1) && this.func_149966_a(p_149965_1_, p_149965_2_ + l + 2, p_149965_3_, p_149965_4_, 1)) + { + p_149965_1_.setBlockMetadataWithNotify(p_149965_2_ + l, p_149965_3_, p_149965_4_, 8, 2); + p_149965_1_.setBlockMetadataWithNotify(p_149965_2_ + l + 1, p_149965_3_, p_149965_4_, 8, 2); + p_149965_1_.setBlockMetadataWithNotify(p_149965_2_ + l + 2, p_149965_3_, p_149965_4_, 8, 2); + p_149965_1_.setBlock(p_149965_2_ + l, p_149965_3_, p_149965_4_, getBlockById(0), 0, 2); + p_149965_1_.setBlock(p_149965_2_ + l + 1, p_149965_3_, p_149965_4_, getBlockById(0), 0, 2); + p_149965_1_.setBlock(p_149965_2_ + l + 2, p_149965_3_, p_149965_4_, getBlockById(0), 0, 2); + p_149965_1_.setBlock(p_149965_2_ + l, p_149965_3_ - 1, p_149965_4_, getBlockById(0), 0, 2); + p_149965_1_.setBlock(p_149965_2_ + l + 1, p_149965_3_ - 1, p_149965_4_, getBlockById(0), 0, 2); + p_149965_1_.setBlock(p_149965_2_ + l + 2, p_149965_3_ - 1, p_149965_4_, getBlockById(0), 0, 2); + p_149965_1_.setBlock(p_149965_2_ + l + 1, p_149965_3_ - 2, p_149965_4_, getBlockById(0), 0, 2); + + if (!p_149965_1_.isRemote) + { + entitywither = new EntityWither(p_149965_1_); + entitywither.setLocationAndAngles((double)(p_149965_2_ + l) + 1.5D, (double)p_149965_3_ - 1.45D, (double)p_149965_4_ + 0.5D, 0.0F, 0.0F); + entitywither.func_82206_m(); + + if (!p_149965_1_.isRemote) + { + iterator = p_149965_1_.getEntitiesWithinAABB(EntityPlayer.class, entitywither.boundingBox.expand(50.0D, 50.0D, 50.0D)).iterator(); + + while (iterator.hasNext()) + { + entityplayer = (EntityPlayer)iterator.next(); + entityplayer.triggerAchievement(AchievementList.field_150963_I); + } + } + + p_149965_1_.spawnEntityInWorld(entitywither); + } + + for (i1 = 0; i1 < 120; ++i1) + { + p_149965_1_.spawnParticle("snowballpoof", (double)(p_149965_2_ + l + 1) + p_149965_1_.rand.nextDouble(), (double)(p_149965_3_ - 2) + p_149965_1_.rand.nextDouble() * 3.9D, (double)p_149965_4_ + p_149965_1_.rand.nextDouble(), 0.0D, 0.0D, 0.0D); + } + + p_149965_1_.notifyBlockChange(p_149965_2_ + l, p_149965_3_, p_149965_4_, getBlockById(0)); + p_149965_1_.notifyBlockChange(p_149965_2_ + l + 1, p_149965_3_, p_149965_4_, getBlockById(0)); + p_149965_1_.notifyBlockChange(p_149965_2_ + l + 2, p_149965_3_, p_149965_4_, getBlockById(0)); + p_149965_1_.notifyBlockChange(p_149965_2_ + l, p_149965_3_ - 1, p_149965_4_, getBlockById(0)); + p_149965_1_.notifyBlockChange(p_149965_2_ + l + 1, p_149965_3_ - 1, p_149965_4_, getBlockById(0)); + p_149965_1_.notifyBlockChange(p_149965_2_ + l + 2, p_149965_3_ - 1, p_149965_4_, getBlockById(0)); + p_149965_1_.notifyBlockChange(p_149965_2_ + l + 1, p_149965_3_ - 2, p_149965_4_, getBlockById(0)); + return; + } + } + } + } + + private boolean func_149966_a(World p_149966_1_, int p_149966_2_, int p_149966_3_, int p_149966_4_, int p_149966_5_) + { + if (p_149966_1_.getBlock(p_149966_2_, p_149966_3_, p_149966_4_) != this) + { + return false; + } + else + { + TileEntity tileentity = p_149966_1_.getTileEntity(p_149966_2_, p_149966_3_, p_149966_4_); + return tileentity != null && tileentity instanceof TileEntitySkull ? ((TileEntitySkull)tileentity).func_145904_a() == p_149966_5_ : false; + } + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) {} + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return Blocks.soul_sand.getBlockTextureFromSide(p_149691_1_); + } + + @SideOnly(Side.CLIENT) + public String getItemIconName() + { + return this.getTextureName() + "_" + ItemSkull.field_94587_a[0]; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockSlab.java b/src/main/java/net/minecraft/block/BlockSlab.java new file mode 100644 index 0000000..d9abd85 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockSlab.java @@ -0,0 +1,141 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.Facing; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public abstract class BlockSlab extends Block +{ + protected final boolean field_150004_a; + private static final String __OBFID = "CL_00000253"; + + public BlockSlab(boolean p_i45410_1_, Material p_i45410_2_) + { + super(p_i45410_2_); + this.field_150004_a = p_i45410_1_; + + if (p_i45410_1_) + { + this.opaque = true; + } + else + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); + } + + this.setLightOpacity(255); + } + + public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) + { + if (this.field_150004_a) + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + else + { + boolean flag = (p_149719_1_.getBlockMetadata(p_149719_2_, p_149719_3_, p_149719_4_) & 8) != 0; + + if (flag) + { + this.setBlockBounds(0.0F, 0.5F, 0.0F, 1.0F, 1.0F, 1.0F); + } + else + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); + } + } + } + + public void setBlockBoundsForItemRender() + { + if (this.field_150004_a) + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + else + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); + } + } + + public void addCollisionBoxesToList(World p_149743_1_, int p_149743_2_, int p_149743_3_, int p_149743_4_, AxisAlignedBB p_149743_5_, List p_149743_6_, Entity p_149743_7_) + { + this.setBlockBoundsBasedOnState(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_); + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + } + + public boolean isOpaqueCube() + { + return this.field_150004_a; + } + + public int onBlockPlaced(World p_149660_1_, int p_149660_2_, int p_149660_3_, int p_149660_4_, int p_149660_5_, float p_149660_6_, float p_149660_7_, float p_149660_8_, int p_149660_9_) + { + return this.field_150004_a ? p_149660_9_ : (p_149660_5_ != 0 && (p_149660_5_ == 1 || (double)p_149660_7_ <= 0.5D) ? p_149660_9_ : p_149660_9_ | 8); + } + + public int quantityDropped(Random p_149745_1_) + { + return this.field_150004_a ? 2 : 1; + } + + public int damageDropped(int p_149692_1_) + { + return p_149692_1_ & 7; + } + + public boolean renderAsNormalBlock() + { + return this.field_150004_a; + } + + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) + { + if (this.field_150004_a) + { + return super.shouldSideBeRendered(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, p_149646_5_); + } + else if (p_149646_5_ != 1 && p_149646_5_ != 0 && !super.shouldSideBeRendered(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, p_149646_5_)) + { + return false; + } + else + { + int i1 = p_149646_2_ + Facing.offsetsXForSide[Facing.oppositeSide[p_149646_5_]]; + int j1 = p_149646_3_ + Facing.offsetsYForSide[Facing.oppositeSide[p_149646_5_]]; + int k1 = p_149646_4_ + Facing.offsetsZForSide[Facing.oppositeSide[p_149646_5_]]; + boolean flag = (p_149646_1_.getBlockMetadata(i1, j1, k1) & 8) != 0; + return flag ? (p_149646_5_ == 0 ? true : (p_149646_5_ == 1 && super.shouldSideBeRendered(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, p_149646_5_) ? true : !func_150003_a(p_149646_1_.getBlock(p_149646_2_, p_149646_3_, p_149646_4_)) || (p_149646_1_.getBlockMetadata(p_149646_2_, p_149646_3_, p_149646_4_) & 8) == 0)) : (p_149646_5_ == 1 ? true : (p_149646_5_ == 0 && super.shouldSideBeRendered(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, p_149646_5_) ? true : !func_150003_a(p_149646_1_.getBlock(p_149646_2_, p_149646_3_, p_149646_4_)) || (p_149646_1_.getBlockMetadata(p_149646_2_, p_149646_3_, p_149646_4_) & 8) != 0)); + } + } + + @SideOnly(Side.CLIENT) + private static boolean func_150003_a(Block p_150003_0_) + { + return p_150003_0_ == Blocks.stone_slab || p_150003_0_ == Blocks.wooden_slab; + } + + public abstract String func_150002_b(int var1); + + public int getDamageValue(World p_149643_1_, int p_149643_2_, int p_149643_3_, int p_149643_4_) + { + return super.getDamageValue(p_149643_1_, p_149643_2_, p_149643_3_, p_149643_4_) & 7; + } + + @SideOnly(Side.CLIENT) + public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) + { + return func_150003_a(this) ? Item.getItemFromBlock(this) : (this == Blocks.double_stone_slab ? Item.getItemFromBlock(Blocks.stone_slab) : (this == Blocks.double_wooden_slab ? Item.getItemFromBlock(Blocks.wooden_slab) : Item.getItemFromBlock(Blocks.stone_slab))); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockSnow.java b/src/main/java/net/minecraft/block/BlockSnow.java new file mode 100644 index 0000000..a125838 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockSnow.java @@ -0,0 +1,156 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.stats.StatList; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.EnumSkyBlock; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockSnow extends Block +{ + private static final String __OBFID = "CL_00000309"; + + protected BlockSnow() + { + super(Material.snow); + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F); + this.setTickRandomly(true); + this.setCreativeTab(CreativeTabs.tabDecorations); + this.func_150154_b(0); + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.blockIcon = p_149651_1_.registerIcon("snow"); + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) + { + int l = p_149668_1_.getBlockMetadata(p_149668_2_, p_149668_3_, p_149668_4_) & 7; + float f = 0.125F; + return AxisAlignedBB.getAABBPool().getAABB((double)p_149668_2_ + this.minX, (double)p_149668_3_ + this.minY, (double)p_149668_4_ + this.minZ, (double)p_149668_2_ + this.maxX, (double)((float)p_149668_3_ + (float)l * f), (double)p_149668_4_ + this.maxZ); + } + + public boolean isOpaqueCube() + { + return false; + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public void setBlockBoundsForItemRender() + { + this.func_150154_b(0); + } + + public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) + { + this.func_150154_b(p_149719_1_.getBlockMetadata(p_149719_2_, p_149719_3_, p_149719_4_)); + } + + protected void func_150154_b(int p_150154_1_) + { + int j = p_150154_1_ & 7; + float f = (float)(2 * (1 + j)) / 16.0F; + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, f, 1.0F); + } + + public boolean canPlaceBlockAt(World p_149742_1_, int p_149742_2_, int p_149742_3_, int p_149742_4_) + { + Block block = p_149742_1_.getBlock(p_149742_2_, p_149742_3_ - 1, p_149742_4_); + return block != Blocks.ice && block != Blocks.packed_ice ? (block.isLeaves(p_149742_1_, p_149742_2_, p_149742_3_ - 1, p_149742_4_) ? true : (block == this && (p_149742_1_.getBlockMetadata(p_149742_2_, p_149742_3_ - 1, p_149742_4_) & 7) == 7 ? true : block.isOpaqueCube() && block.blockMaterial.blocksMovement())) : false; + } + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) + { + this.func_150155_m(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_); + } + + private boolean func_150155_m(World p_150155_1_, int p_150155_2_, int p_150155_3_, int p_150155_4_) + { + if (!this.canPlaceBlockAt(p_150155_1_, p_150155_2_, p_150155_3_, p_150155_4_)) + { + p_150155_1_.setBlockToAir(p_150155_2_, p_150155_3_, p_150155_4_); + return false; + } + else + { + return true; + } + } + + public void harvestBlock(World p_149636_1_, EntityPlayer p_149636_2_, int p_149636_3_, int p_149636_4_, int p_149636_5_, int p_149636_6_) + { + super.harvestBlock(p_149636_1_, p_149636_2_, p_149636_3_, p_149636_4_, p_149636_5_, p_149636_6_); + p_149636_1_.setBlockToAir(p_149636_3_, p_149636_4_, p_149636_5_); + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return Items.snowball; + } + + public int quantityDropped(Random p_149745_1_) + { + return 1; + } + + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) + { + if (p_149674_1_.getSavedLightValue(EnumSkyBlock.Block, p_149674_2_, p_149674_3_, p_149674_4_) > 11) + { + p_149674_1_.setBlockToAir(p_149674_2_, p_149674_3_, p_149674_4_); + } + } + + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) + { + return p_149646_5_ == 1 ? true : super.shouldSideBeRendered(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, p_149646_5_); + } + + /** + * Metadata and fortune sensitive version, this replaces the old (int meta, Random rand) + * version in 1.1. + * + * @param meta Blocks Metadata + * @param fortune Current item fortune level + * @param random Random number generator + * @return The number of items to drop + */ + public int quantityDropped(int meta, int fortune, Random random) + { + return (meta & 7) + 1; + } + + /** + * Determines if a new block can be replace the space occupied by this one, + * Used in the player's placement code to make the block act like water, and lava. + * + * @param world The current world + * @param x X Position + * @param y Y position + * @param z Z position + * @return True if the block is replaceable by another block + */ + public boolean isReplaceable(IBlockAccess world, int x, int y, int z) + { + int meta = world.getBlockMetadata(x, y, z); + return meta >= 7 ? false : blockMaterial.isReplaceable(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockSnowBlock.java b/src/main/java/net/minecraft/block/BlockSnowBlock.java new file mode 100644 index 0000000..4021b1f --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockSnowBlock.java @@ -0,0 +1,40 @@ +package net.minecraft.block; + +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.world.EnumSkyBlock; +import net.minecraft.world.World; + +public class BlockSnowBlock extends Block +{ + private static final String __OBFID = "CL_00000308"; + + protected BlockSnowBlock() + { + super(Material.craftedSnow); + this.setTickRandomly(true); + this.setCreativeTab(CreativeTabs.tabBlock); + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return Items.snowball; + } + + public int quantityDropped(Random p_149745_1_) + { + return 4; + } + + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) + { + if (p_149674_1_.getSavedLightValue(EnumSkyBlock.Block, p_149674_2_, p_149674_3_, p_149674_4_) > 11) + { + this.dropBlockAsItem(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_), 0); + p_149674_1_.setBlockToAir(p_149674_2_, p_149674_3_, p_149674_4_); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockSoulSand.java b/src/main/java/net/minecraft/block/BlockSoulSand.java new file mode 100644 index 0000000..b84e919 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockSoulSand.java @@ -0,0 +1,30 @@ +package net.minecraft.block; + +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; + +public class BlockSoulSand extends Block +{ + private static final String __OBFID = "CL_00000310"; + + public BlockSoulSand() + { + super(Material.sand); + this.setCreativeTab(CreativeTabs.tabBlock); + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) + { + float f = 0.125F; + return AxisAlignedBB.getAABBPool().getAABB((double)p_149668_2_, (double)p_149668_3_, (double)p_149668_4_, (double)(p_149668_2_ + 1), (double)((float)(p_149668_3_ + 1) - f), (double)(p_149668_4_ + 1)); + } + + public void onEntityCollidedWithBlock(World p_149670_1_, int p_149670_2_, int p_149670_3_, int p_149670_4_, Entity p_149670_5_) + { + p_149670_5_.motionX *= 0.4D; + p_149670_5_.motionZ *= 0.4D; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockSourceImpl.java b/src/main/java/net/minecraft/block/BlockSourceImpl.java new file mode 100644 index 0000000..a987b2f --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockSourceImpl.java @@ -0,0 +1,67 @@ +package net.minecraft.block; + +import net.minecraft.dispenser.IBlockSource; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +public class BlockSourceImpl implements IBlockSource +{ + private final World worldObj; + private final int xPos; + private final int yPos; + private final int zPos; + private static final String __OBFID = "CL_00001194"; + + public BlockSourceImpl(World par1World, int par2, int par3, int par4) + { + this.worldObj = par1World; + this.xPos = par2; + this.yPos = par3; + this.zPos = par4; + } + + public World getWorld() + { + return this.worldObj; + } + + public double getX() + { + return (double)this.xPos + 0.5D; + } + + public double getY() + { + return (double)this.yPos + 0.5D; + } + + public double getZ() + { + return (double)this.zPos + 0.5D; + } + + public int getXInt() + { + return this.xPos; + } + + public int getYInt() + { + return this.yPos; + } + + public int getZInt() + { + return this.zPos; + } + + public int getBlockMetadata() + { + return this.worldObj.getBlockMetadata(this.xPos, this.yPos, this.zPos); + } + + public TileEntity getBlockTileEntity() + { + return this.worldObj.getTileEntity(this.xPos, this.yPos, this.zPos); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockSponge.java b/src/main/java/net/minecraft/block/BlockSponge.java new file mode 100644 index 0000000..0576bf0 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockSponge.java @@ -0,0 +1,15 @@ +package net.minecraft.block; + +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; + +public class BlockSponge extends Block +{ + private static final String __OBFID = "CL_00000311"; + + protected BlockSponge() + { + super(Material.sponge); + this.setCreativeTab(CreativeTabs.tabBlock); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockStainedGlass.java b/src/main/java/net/minecraft/block/BlockStainedGlass.java new file mode 100644 index 0000000..2ac90c8 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockStainedGlass.java @@ -0,0 +1,81 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemDye; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +public class BlockStainedGlass extends BlockBreakable +{ + private static final IIcon[] field_149998_a = new IIcon[16]; + private static final String __OBFID = "CL_00000312"; + + public BlockStainedGlass(Material p_i45427_1_) + { + super("glass", p_i45427_1_, false); + this.setCreativeTab(CreativeTabs.tabBlock); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return field_149998_a[p_149691_2_ % field_149998_a.length]; + } + + public int damageDropped(int p_149692_1_) + { + return p_149692_1_; + } + + public int quantityDropped(Random p_149745_1_) + { + return 0; + } + + @SideOnly(Side.CLIENT) + public static int func_149997_b(int p_149997_0_) + { + return ~p_149997_0_ & 15; + } + + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_) + { + for (int i = 0; i < field_149998_a.length; ++i) + { + p_149666_3_.add(new ItemStack(p_149666_1_, 1, i)); + } + } + + @SideOnly(Side.CLIENT) + public int getRenderBlockPass() + { + return 1; + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + for (int i = 0; i < field_149998_a.length; ++i) + { + field_149998_a[i] = p_149651_1_.registerIcon(this.getTextureName() + "_" + ItemDye.field_150921_b[func_149997_b(i)]); + } + } + + protected boolean canSilkHarvest() + { + return true; + } + + public boolean renderAsNormalBlock() + { + return false; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockStainedGlassPane.java b/src/main/java/net/minecraft/block/BlockStainedGlassPane.java new file mode 100644 index 0000000..81a9f7b --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockStainedGlassPane.java @@ -0,0 +1,81 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemDye; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +public class BlockStainedGlassPane extends BlockPane +{ + private static final IIcon[] field_150106_a = new IIcon[16]; + private static final IIcon[] field_150105_b = new IIcon[16]; + private static final String __OBFID = "CL_00000313"; + + public BlockStainedGlassPane() + { + super("glass", "glass_pane_top", Material.glass, false); + this.setCreativeTab(CreativeTabs.tabDecorations); + } + + @SideOnly(Side.CLIENT) + public IIcon func_149735_b(int p_149735_1_, int p_149735_2_) + { + return field_150106_a[p_149735_2_ % field_150106_a.length]; + } + + @SideOnly(Side.CLIENT) + public IIcon func_150104_b(int p_150104_1_) + { + return field_150105_b[~p_150104_1_ & 15]; + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return this.func_149735_b(p_149691_1_, ~p_149691_2_ & 15); + } + + public int damageDropped(int p_149692_1_) + { + return p_149692_1_; + } + + @SideOnly(Side.CLIENT) + public static int func_150103_c(int p_150103_0_) + { + return p_150103_0_ & 15; + } + + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_) + { + for (int i = 0; i < field_150106_a.length; ++i) + { + p_149666_3_.add(new ItemStack(p_149666_1_, 1, i)); + } + } + + @SideOnly(Side.CLIENT) + public int getRenderBlockPass() + { + return 1; + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + super.registerBlockIcons(p_149651_1_); + + for (int i = 0; i < field_150106_a.length; ++i) + { + field_150106_a[i] = p_149651_1_.registerIcon(this.getTextureName() + "_" + ItemDye.field_150921_b[func_150103_c(i)]); + field_150105_b[i] = p_149651_1_.registerIcon(this.getTextureName() + "_pane_top_" + ItemDye.field_150921_b[func_150103_c(i)]); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockStairs.java b/src/main/java/net/minecraft/block/BlockStairs.java new file mode 100644 index 0000000..01add1c --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockStairs.java @@ -0,0 +1,555 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import java.util.Random; +import net.minecraft.block.material.MapColor; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.Vec3; +import net.minecraft.world.Explosion; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockStairs extends Block +{ + private static final int[][] field_150150_a = new int[][] {{2, 6}, {3, 7}, {2, 3}, {6, 7}, {0, 4}, {1, 5}, {0, 1}, {4, 5}}; + private final Block field_150149_b; + private final int field_150151_M; + private boolean field_150152_N; + private int field_150153_O; + private static final String __OBFID = "CL_00000314"; + + protected BlockStairs(Block p_i45428_1_, int p_i45428_2_) + { + super(p_i45428_1_.blockMaterial); + this.field_150149_b = p_i45428_1_; + this.field_150151_M = p_i45428_2_; + this.setHardness(p_i45428_1_.blockHardness); + this.setResistance(p_i45428_1_.blockResistance / 3.0F); + this.setStepSound(p_i45428_1_.stepSound); + this.setLightOpacity(255); + this.setCreativeTab(CreativeTabs.tabBlock); + } + + public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) + { + if (this.field_150152_N) + { + this.setBlockBounds(0.5F * (float)(this.field_150153_O % 2), 0.5F * (float)(this.field_150153_O / 2 % 2), 0.5F * (float)(this.field_150153_O / 4 % 2), 0.5F + 0.5F * (float)(this.field_150153_O % 2), 0.5F + 0.5F * (float)(this.field_150153_O / 2 % 2), 0.5F + 0.5F * (float)(this.field_150153_O / 4 % 2)); + } + else + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + } + + public boolean isOpaqueCube() + { + return false; + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public int getRenderType() + { + return 10; + } + + public void func_150147_e(IBlockAccess p_150147_1_, int p_150147_2_, int p_150147_3_, int p_150147_4_) + { + int l = p_150147_1_.getBlockMetadata(p_150147_2_, p_150147_3_, p_150147_4_); + + if ((l & 4) != 0) + { + this.setBlockBounds(0.0F, 0.5F, 0.0F, 1.0F, 1.0F, 1.0F); + } + else + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); + } + } + + public static boolean func_150148_a(Block p_150148_0_) + { + return p_150148_0_ instanceof BlockStairs; + } + + private boolean func_150146_f(IBlockAccess p_150146_1_, int p_150146_2_, int p_150146_3_, int p_150146_4_, int p_150146_5_) + { + Block block = p_150146_1_.getBlock(p_150146_2_, p_150146_3_, p_150146_4_); + return func_150148_a(block) && p_150146_1_.getBlockMetadata(p_150146_2_, p_150146_3_, p_150146_4_) == p_150146_5_; + } + + public boolean func_150145_f(IBlockAccess p_150145_1_, int p_150145_2_, int p_150145_3_, int p_150145_4_) + { + int l = p_150145_1_.getBlockMetadata(p_150145_2_, p_150145_3_, p_150145_4_); + int i1 = l & 3; + float f = 0.5F; + float f1 = 1.0F; + + if ((l & 4) != 0) + { + f = 0.0F; + f1 = 0.5F; + } + + float f2 = 0.0F; + float f3 = 1.0F; + float f4 = 0.0F; + float f5 = 0.5F; + boolean flag = true; + Block block; + int j1; + int k1; + + if (i1 == 0) + { + f2 = 0.5F; + f5 = 1.0F; + block = p_150145_1_.getBlock(p_150145_2_ + 1, p_150145_3_, p_150145_4_); + j1 = p_150145_1_.getBlockMetadata(p_150145_2_ + 1, p_150145_3_, p_150145_4_); + + if (func_150148_a(block) && (l & 4) == (j1 & 4)) + { + k1 = j1 & 3; + + if (k1 == 3 && !this.func_150146_f(p_150145_1_, p_150145_2_, p_150145_3_, p_150145_4_ + 1, l)) + { + f5 = 0.5F; + flag = false; + } + else if (k1 == 2 && !this.func_150146_f(p_150145_1_, p_150145_2_, p_150145_3_, p_150145_4_ - 1, l)) + { + f4 = 0.5F; + flag = false; + } + } + } + else if (i1 == 1) + { + f3 = 0.5F; + f5 = 1.0F; + block = p_150145_1_.getBlock(p_150145_2_ - 1, p_150145_3_, p_150145_4_); + j1 = p_150145_1_.getBlockMetadata(p_150145_2_ - 1, p_150145_3_, p_150145_4_); + + if (func_150148_a(block) && (l & 4) == (j1 & 4)) + { + k1 = j1 & 3; + + if (k1 == 3 && !this.func_150146_f(p_150145_1_, p_150145_2_, p_150145_3_, p_150145_4_ + 1, l)) + { + f5 = 0.5F; + flag = false; + } + else if (k1 == 2 && !this.func_150146_f(p_150145_1_, p_150145_2_, p_150145_3_, p_150145_4_ - 1, l)) + { + f4 = 0.5F; + flag = false; + } + } + } + else if (i1 == 2) + { + f4 = 0.5F; + f5 = 1.0F; + block = p_150145_1_.getBlock(p_150145_2_, p_150145_3_, p_150145_4_ + 1); + j1 = p_150145_1_.getBlockMetadata(p_150145_2_, p_150145_3_, p_150145_4_ + 1); + + if (func_150148_a(block) && (l & 4) == (j1 & 4)) + { + k1 = j1 & 3; + + if (k1 == 1 && !this.func_150146_f(p_150145_1_, p_150145_2_ + 1, p_150145_3_, p_150145_4_, l)) + { + f3 = 0.5F; + flag = false; + } + else if (k1 == 0 && !this.func_150146_f(p_150145_1_, p_150145_2_ - 1, p_150145_3_, p_150145_4_, l)) + { + f2 = 0.5F; + flag = false; + } + } + } + else if (i1 == 3) + { + block = p_150145_1_.getBlock(p_150145_2_, p_150145_3_, p_150145_4_ - 1); + j1 = p_150145_1_.getBlockMetadata(p_150145_2_, p_150145_3_, p_150145_4_ - 1); + + if (func_150148_a(block) && (l & 4) == (j1 & 4)) + { + k1 = j1 & 3; + + if (k1 == 1 && !this.func_150146_f(p_150145_1_, p_150145_2_ + 1, p_150145_3_, p_150145_4_, l)) + { + f3 = 0.5F; + flag = false; + } + else if (k1 == 0 && !this.func_150146_f(p_150145_1_, p_150145_2_ - 1, p_150145_3_, p_150145_4_, l)) + { + f2 = 0.5F; + flag = false; + } + } + } + + this.setBlockBounds(f2, f, f4, f3, f1, f5); + return flag; + } + + public boolean func_150144_g(IBlockAccess p_150144_1_, int p_150144_2_, int p_150144_3_, int p_150144_4_) + { + int l = p_150144_1_.getBlockMetadata(p_150144_2_, p_150144_3_, p_150144_4_); + int i1 = l & 3; + float f = 0.5F; + float f1 = 1.0F; + + if ((l & 4) != 0) + { + f = 0.0F; + f1 = 0.5F; + } + + float f2 = 0.0F; + float f3 = 0.5F; + float f4 = 0.5F; + float f5 = 1.0F; + boolean flag = false; + Block block; + int j1; + int k1; + + if (i1 == 0) + { + block = p_150144_1_.getBlock(p_150144_2_ - 1, p_150144_3_, p_150144_4_); + j1 = p_150144_1_.getBlockMetadata(p_150144_2_ - 1, p_150144_3_, p_150144_4_); + + if (func_150148_a(block) && (l & 4) == (j1 & 4)) + { + k1 = j1 & 3; + + if (k1 == 3 && !this.func_150146_f(p_150144_1_, p_150144_2_, p_150144_3_, p_150144_4_ - 1, l)) + { + f4 = 0.0F; + f5 = 0.5F; + flag = true; + } + else if (k1 == 2 && !this.func_150146_f(p_150144_1_, p_150144_2_, p_150144_3_, p_150144_4_ + 1, l)) + { + f4 = 0.5F; + f5 = 1.0F; + flag = true; + } + } + } + else if (i1 == 1) + { + block = p_150144_1_.getBlock(p_150144_2_ + 1, p_150144_3_, p_150144_4_); + j1 = p_150144_1_.getBlockMetadata(p_150144_2_ + 1, p_150144_3_, p_150144_4_); + + if (func_150148_a(block) && (l & 4) == (j1 & 4)) + { + f2 = 0.5F; + f3 = 1.0F; + k1 = j1 & 3; + + if (k1 == 3 && !this.func_150146_f(p_150144_1_, p_150144_2_, p_150144_3_, p_150144_4_ - 1, l)) + { + f4 = 0.0F; + f5 = 0.5F; + flag = true; + } + else if (k1 == 2 && !this.func_150146_f(p_150144_1_, p_150144_2_, p_150144_3_, p_150144_4_ + 1, l)) + { + f4 = 0.5F; + f5 = 1.0F; + flag = true; + } + } + } + else if (i1 == 2) + { + block = p_150144_1_.getBlock(p_150144_2_, p_150144_3_, p_150144_4_ - 1); + j1 = p_150144_1_.getBlockMetadata(p_150144_2_, p_150144_3_, p_150144_4_ - 1); + + if (func_150148_a(block) && (l & 4) == (j1 & 4)) + { + f4 = 0.0F; + f5 = 0.5F; + k1 = j1 & 3; + + if (k1 == 1 && !this.func_150146_f(p_150144_1_, p_150144_2_ - 1, p_150144_3_, p_150144_4_, l)) + { + flag = true; + } + else if (k1 == 0 && !this.func_150146_f(p_150144_1_, p_150144_2_ + 1, p_150144_3_, p_150144_4_, l)) + { + f2 = 0.5F; + f3 = 1.0F; + flag = true; + } + } + } + else if (i1 == 3) + { + block = p_150144_1_.getBlock(p_150144_2_, p_150144_3_, p_150144_4_ + 1); + j1 = p_150144_1_.getBlockMetadata(p_150144_2_, p_150144_3_, p_150144_4_ + 1); + + if (func_150148_a(block) && (l & 4) == (j1 & 4)) + { + k1 = j1 & 3; + + if (k1 == 1 && !this.func_150146_f(p_150144_1_, p_150144_2_ - 1, p_150144_3_, p_150144_4_, l)) + { + flag = true; + } + else if (k1 == 0 && !this.func_150146_f(p_150144_1_, p_150144_2_ + 1, p_150144_3_, p_150144_4_, l)) + { + f2 = 0.5F; + f3 = 1.0F; + flag = true; + } + } + } + + if (flag) + { + this.setBlockBounds(f2, f, f4, f3, f1, f5); + } + + return flag; + } + + public void addCollisionBoxesToList(World p_149743_1_, int p_149743_2_, int p_149743_3_, int p_149743_4_, AxisAlignedBB p_149743_5_, List p_149743_6_, Entity p_149743_7_) + { + this.func_150147_e(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_); + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + boolean flag = this.func_150145_f(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_); + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + + if (flag && this.func_150144_g(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_)) + { + super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_); + } + + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + + public void onBlockClicked(World p_149699_1_, int p_149699_2_, int p_149699_3_, int p_149699_4_, EntityPlayer p_149699_5_) + { + this.field_150149_b.onBlockClicked(p_149699_1_, p_149699_2_, p_149699_3_, p_149699_4_, p_149699_5_); + } + + @SideOnly(Side.CLIENT) + public void randomDisplayTick(World p_149734_1_, int p_149734_2_, int p_149734_3_, int p_149734_4_, Random p_149734_5_) + { + this.field_150149_b.randomDisplayTick(p_149734_1_, p_149734_2_, p_149734_3_, p_149734_4_, p_149734_5_); + } + + public void onBlockDestroyedByPlayer(World p_149664_1_, int p_149664_2_, int p_149664_3_, int p_149664_4_, int p_149664_5_) + { + this.field_150149_b.onBlockDestroyedByPlayer(p_149664_1_, p_149664_2_, p_149664_3_, p_149664_4_, p_149664_5_); + } + + public float getExplosionResistance(Entity p_149638_1_) + { + return this.field_150149_b.getExplosionResistance(p_149638_1_); + } + + public int tickRate(World p_149738_1_) + { + return this.field_150149_b.tickRate(p_149738_1_); + } + + public void velocityToAddToEntity(World p_149640_1_, int p_149640_2_, int p_149640_3_, int p_149640_4_, Entity p_149640_5_, Vec3 p_149640_6_) + { + this.field_150149_b.velocityToAddToEntity(p_149640_1_, p_149640_2_, p_149640_3_, p_149640_4_, p_149640_5_, p_149640_6_); + } + + @SideOnly(Side.CLIENT) + public int getMixedBrightnessForBlock(IBlockAccess p_149677_1_, int p_149677_2_, int p_149677_3_, int p_149677_4_) + { + return this.field_150149_b.getMixedBrightnessForBlock(p_149677_1_, p_149677_2_, p_149677_3_, p_149677_4_); + } + + @SideOnly(Side.CLIENT) + public int getRenderBlockPass() + { + return this.field_150149_b.getRenderBlockPass(); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return this.field_150149_b.getIcon(p_149691_1_, this.field_150151_M); + } + + @SideOnly(Side.CLIENT) + public AxisAlignedBB getSelectedBoundingBoxFromPool(World p_149633_1_, int p_149633_2_, int p_149633_3_, int p_149633_4_) + { + return this.field_150149_b.getSelectedBoundingBoxFromPool(p_149633_1_, p_149633_2_, p_149633_3_, p_149633_4_); + } + + public boolean isCollidable() + { + return this.field_150149_b.isCollidable(); + } + + public boolean canCollideCheck(int p_149678_1_, boolean p_149678_2_) + { + return this.field_150149_b.canCollideCheck(p_149678_1_, p_149678_2_); + } + + public boolean canPlaceBlockAt(World p_149742_1_, int p_149742_2_, int p_149742_3_, int p_149742_4_) + { + return this.field_150149_b.canPlaceBlockAt(p_149742_1_, p_149742_2_, p_149742_3_, p_149742_4_); + } + + public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_) + { + this.onNeighborBlockChange(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_, Blocks.air); + this.field_150149_b.onBlockAdded(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_); + } + + public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) + { + this.field_150149_b.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_); + } + + public void onEntityWalking(World p_149724_1_, int p_149724_2_, int p_149724_3_, int p_149724_4_, Entity p_149724_5_) + { + this.field_150149_b.onEntityWalking(p_149724_1_, p_149724_2_, p_149724_3_, p_149724_4_, p_149724_5_); + } + + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) + { + this.field_150149_b.updateTick(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, p_149674_5_); + } + + public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) + { + return this.field_150149_b.onBlockActivated(p_149727_1_, p_149727_2_, p_149727_3_, p_149727_4_, p_149727_5_, 0, 0.0F, 0.0F, 0.0F); + } + + public void onBlockDestroyedByExplosion(World p_149723_1_, int p_149723_2_, int p_149723_3_, int p_149723_4_, Explosion p_149723_5_) + { + this.field_150149_b.onBlockDestroyedByExplosion(p_149723_1_, p_149723_2_, p_149723_3_, p_149723_4_, p_149723_5_); + } + + public MapColor getMapColor(int p_149728_1_) + { + return this.field_150149_b.getMapColor(this.field_150151_M); + } + + public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_) + { + int l = MathHelper.floor_double((double)(p_149689_5_.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + int i1 = p_149689_1_.getBlockMetadata(p_149689_2_, p_149689_3_, p_149689_4_) & 4; + + if (l == 0) + { + p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, 2 | i1, 2); + } + + if (l == 1) + { + p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, 1 | i1, 2); + } + + if (l == 2) + { + p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, 3 | i1, 2); + } + + if (l == 3) + { + p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, 0 | i1, 2); + } + } + + public int onBlockPlaced(World p_149660_1_, int p_149660_2_, int p_149660_3_, int p_149660_4_, int p_149660_5_, float p_149660_6_, float p_149660_7_, float p_149660_8_, int p_149660_9_) + { + return p_149660_5_ != 0 && (p_149660_5_ == 1 || (double)p_149660_7_ <= 0.5D) ? p_149660_9_ : p_149660_9_ | 4; + } + + public MovingObjectPosition collisionRayTrace(World p_149731_1_, int p_149731_2_, int p_149731_3_, int p_149731_4_, Vec3 p_149731_5_, Vec3 p_149731_6_) + { + MovingObjectPosition[] amovingobjectposition = new MovingObjectPosition[8]; + int l = p_149731_1_.getBlockMetadata(p_149731_2_, p_149731_3_, p_149731_4_); + int i1 = l & 3; + boolean flag = (l & 4) == 4; + int[] aint = field_150150_a[i1 + (flag?4:0)]; + this.field_150152_N = true; + int k1; + int l1; + int i2; + + for (int j1 = 0; j1 < 8; ++j1) + { + this.field_150153_O = j1; + int[] aint1 = aint; + k1 = aint.length; + + for (l1 = 0; l1 < k1; ++l1) + { + i2 = aint1[l1]; + + if (i2 == j1) + { + ; + } + } + + amovingobjectposition[j1] = super.collisionRayTrace(p_149731_1_, p_149731_2_, p_149731_3_, p_149731_4_, p_149731_5_, p_149731_6_); + } + + int[] aint2 = aint; + int k2 = aint.length; + + for (k1 = 0; k1 < k2; ++k1) + { + l1 = aint2[k1]; + amovingobjectposition[l1] = null; + } + + MovingObjectPosition movingobjectposition1 = null; + double d1 = 0.0D; + MovingObjectPosition[] amovingobjectposition1 = amovingobjectposition; + i2 = amovingobjectposition.length; + + for (int j2 = 0; j2 < i2; ++j2) + { + MovingObjectPosition movingobjectposition = amovingobjectposition1[j2]; + + if (movingobjectposition != null) + { + double d0 = movingobjectposition.hitVec.squareDistanceTo(p_149731_6_); + + if (d0 > d1) + { + movingobjectposition1 = movingobjectposition; + d1 = d0; + } + } + } + + return movingobjectposition1; + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) {} +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockStaticLiquid.java b/src/main/java/net/minecraft/block/BlockStaticLiquid.java new file mode 100644 index 0000000..936f182 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockStaticLiquid.java @@ -0,0 +1,91 @@ +package net.minecraft.block; + +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; + +public class BlockStaticLiquid extends BlockLiquid +{ + private static final String __OBFID = "CL_00000315"; + + protected BlockStaticLiquid(Material p_i45429_1_) + { + super(p_i45429_1_); + this.setTickRandomly(false); + + if (p_i45429_1_ == Material.lava) + { + this.setTickRandomly(true); + } + } + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) + { + super.onNeighborBlockChange(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, p_149695_5_); + + if (p_149695_1_.getBlock(p_149695_2_, p_149695_3_, p_149695_4_) == this) + { + this.setNotStationary(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_); + } + } + + private void setNotStationary(World p_149818_1_, int p_149818_2_, int p_149818_3_, int p_149818_4_) + { + int l = p_149818_1_.getBlockMetadata(p_149818_2_, p_149818_3_, p_149818_4_); + p_149818_1_.setBlock(p_149818_2_, p_149818_3_, p_149818_4_, Block.getBlockById(Block.getIdFromBlock(this) - 1), l, 2); + p_149818_1_.scheduleBlockUpdate(p_149818_2_, p_149818_3_, p_149818_4_, Block.getBlockById(Block.getIdFromBlock(this) - 1), this.tickRate(p_149818_1_)); + } + + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) + { + if (this.blockMaterial == Material.lava) + { + int l = p_149674_5_.nextInt(3); + int i1; + + for (i1 = 0; i1 < l; ++i1) + { + p_149674_2_ += p_149674_5_.nextInt(3) - 1; + ++p_149674_3_; + p_149674_4_ += p_149674_5_.nextInt(3) - 1; + Block block = p_149674_1_.getBlock(p_149674_2_, p_149674_3_, p_149674_4_); + + if (block.blockMaterial == Material.air) + { + if (this.isFlammable(p_149674_1_, p_149674_2_ - 1, p_149674_3_, p_149674_4_) || this.isFlammable(p_149674_1_, p_149674_2_ + 1, p_149674_3_, p_149674_4_) || this.isFlammable(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_ - 1) || this.isFlammable(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_ + 1) || this.isFlammable(p_149674_1_, p_149674_2_, p_149674_3_ - 1, p_149674_4_) || this.isFlammable(p_149674_1_, p_149674_2_, p_149674_3_ + 1, p_149674_4_)) + { + p_149674_1_.setBlock(p_149674_2_, p_149674_3_, p_149674_4_, Blocks.fire); + return; + } + } + else if (block.blockMaterial.blocksMovement()) + { + return; + } + } + + if (l == 0) + { + i1 = p_149674_2_; + int k1 = p_149674_4_; + + for (int j1 = 0; j1 < 3; ++j1) + { + p_149674_2_ = i1 + p_149674_5_.nextInt(3) - 1; + p_149674_4_ = k1 + p_149674_5_.nextInt(3) - 1; + + if (p_149674_1_.isAirBlock(p_149674_2_, p_149674_3_ + 1, p_149674_4_) && this.isFlammable(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_)) + { + p_149674_1_.setBlock(p_149674_2_, p_149674_3_ + 1, p_149674_4_, Blocks.fire); + } + } + } + } + } + + private boolean isFlammable(World p_149817_1_, int p_149817_2_, int p_149817_3_, int p_149817_4_) + { + return p_149817_1_.getBlock(p_149817_2_, p_149817_3_, p_149817_4_).getMaterial().getCanBurn(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockStem.java b/src/main/java/net/minecraft/block/BlockStem.java new file mode 100644 index 0000000..980aa69 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockStem.java @@ -0,0 +1,305 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import static net.minecraftforge.common.util.ForgeDirection.*; + +public class BlockStem extends BlockBush implements IGrowable +{ + private final Block field_149877_a; + @SideOnly(Side.CLIENT) + private IIcon field_149876_b; + private static final String __OBFID = "CL_00000316"; + + protected BlockStem(Block p_i45430_1_) + { + this.field_149877_a = p_i45430_1_; + this.setTickRandomly(true); + float f = 0.125F; + this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.25F, 0.5F + f); + this.setCreativeTab((CreativeTabs)null); + } + + protected boolean canPlaceBlockOn(Block p_149854_1_) + { + return p_149854_1_ == Blocks.farmland; + } + + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) + { + super.updateTick(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, p_149674_5_); + + if (p_149674_1_.getBlockLightValue(p_149674_2_, p_149674_3_ + 1, p_149674_4_) >= 9) + { + float f = this.func_149875_n(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_); + + if (p_149674_5_.nextInt((int)(25.0F / f) + 1) == 0) + { + int l = p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_); + + if (l < 7) + { + ++l; + p_149674_1_.setBlockMetadataWithNotify(p_149674_2_, p_149674_3_, p_149674_4_, l, 2); + } + else + { + if (p_149674_1_.getBlock(p_149674_2_ - 1, p_149674_3_, p_149674_4_) == this.field_149877_a) + { + return; + } + + if (p_149674_1_.getBlock(p_149674_2_ + 1, p_149674_3_, p_149674_4_) == this.field_149877_a) + { + return; + } + + if (p_149674_1_.getBlock(p_149674_2_, p_149674_3_, p_149674_4_ - 1) == this.field_149877_a) + { + return; + } + + if (p_149674_1_.getBlock(p_149674_2_, p_149674_3_, p_149674_4_ + 1) == this.field_149877_a) + { + return; + } + + int i1 = p_149674_5_.nextInt(4); + int j1 = p_149674_2_; + int k1 = p_149674_4_; + + if (i1 == 0) + { + j1 = p_149674_2_ - 1; + } + + if (i1 == 1) + { + ++j1; + } + + if (i1 == 2) + { + k1 = p_149674_4_ - 1; + } + + if (i1 == 3) + { + ++k1; + } + + Block block = p_149674_1_.getBlock(j1, p_149674_3_ - 1, k1); + + if (p_149674_1_.isAirBlock(j1, p_149674_3_, k1) && (block.canSustainPlant(p_149674_1_, j1, p_149674_3_ - 1, k1, UP, this) || block == Blocks.dirt || block == Blocks.grass)) + { + p_149674_1_.setBlock(j1, p_149674_3_, k1, this.field_149877_a); + } + } + } + } + } + + public void func_149874_m(World p_149874_1_, int p_149874_2_, int p_149874_3_, int p_149874_4_) + { + int l = p_149874_1_.getBlockMetadata(p_149874_2_, p_149874_3_, p_149874_4_) + MathHelper.getRandomIntegerInRange(p_149874_1_.rand, 2, 5); + + if (l > 7) + { + l = 7; + } + + p_149874_1_.setBlockMetadataWithNotify(p_149874_2_, p_149874_3_, p_149874_4_, l, 2); + } + + private float func_149875_n(World p_149875_1_, int p_149875_2_, int p_149875_3_, int p_149875_4_) + { + float f = 1.0F; + Block block = p_149875_1_.getBlock(p_149875_2_, p_149875_3_, p_149875_4_ - 1); + Block block1 = p_149875_1_.getBlock(p_149875_2_, p_149875_3_, p_149875_4_ + 1); + Block block2 = p_149875_1_.getBlock(p_149875_2_ - 1, p_149875_3_, p_149875_4_); + Block block3 = p_149875_1_.getBlock(p_149875_2_ + 1, p_149875_3_, p_149875_4_); + Block block4 = p_149875_1_.getBlock(p_149875_2_ - 1, p_149875_3_, p_149875_4_ - 1); + Block block5 = p_149875_1_.getBlock(p_149875_2_ + 1, p_149875_3_, p_149875_4_ - 1); + Block block6 = p_149875_1_.getBlock(p_149875_2_ + 1, p_149875_3_, p_149875_4_ + 1); + Block block7 = p_149875_1_.getBlock(p_149875_2_ - 1, p_149875_3_, p_149875_4_ + 1); + boolean flag = block2 == this || block3 == this; + boolean flag1 = block == this || block1 == this; + boolean flag2 = block4 == this || block5 == this || block6 == this || block7 == this; + + for (int l = p_149875_2_ - 1; l <= p_149875_2_ + 1; ++l) + { + for (int i1 = p_149875_4_ - 1; i1 <= p_149875_4_ + 1; ++i1) + { + Block block8 = p_149875_1_.getBlock(l, p_149875_3_ - 1, i1); + float f1 = 0.0F; + + if (block8.canSustainPlant(p_149875_1_, l, p_149875_3_ - 1, i1, UP, this)) + { + f1 = 1.0F; + + if (block8.isFertile(p_149875_1_, l, p_149875_3_ - 1, i1)) + { + f1 = 3.0F; + } + } + + if (l != p_149875_2_ || i1 != p_149875_4_) + { + f1 /= 4.0F; + } + + f += f1; + } + } + + if (flag2 || flag && flag1) + { + f /= 2.0F; + } + + return f; + } + + @SideOnly(Side.CLIENT) + public int getRenderColor(int p_149741_1_) + { + int j = p_149741_1_ * 32; + int k = 255 - p_149741_1_ * 8; + int l = p_149741_1_ * 4; + return j << 16 | k << 8 | l; + } + + @SideOnly(Side.CLIENT) + public int colorMultiplier(IBlockAccess p_149720_1_, int p_149720_2_, int p_149720_3_, int p_149720_4_) + { + return this.getRenderColor(p_149720_1_.getBlockMetadata(p_149720_2_, p_149720_3_, p_149720_4_)); + } + + public void setBlockBoundsForItemRender() + { + float f = 0.125F; + this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.25F, 0.5F + f); + } + + public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) + { + this.maxY = (double)((float)(p_149719_1_.getBlockMetadata(p_149719_2_, p_149719_3_, p_149719_4_) * 2 + 2) / 16.0F); + float f = 0.125F; + this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, (float)this.maxY, 0.5F + f); + } + + public int getRenderType() + { + return 19; + } + + @SideOnly(Side.CLIENT) + public int getState(IBlockAccess p_149873_1_, int p_149873_2_, int p_149873_3_, int p_149873_4_) + { + int l = p_149873_1_.getBlockMetadata(p_149873_2_, p_149873_3_, p_149873_4_); + return l < 7 ? -1 : (p_149873_1_.getBlock(p_149873_2_ - 1, p_149873_3_, p_149873_4_) == this.field_149877_a ? 0 : (p_149873_1_.getBlock(p_149873_2_ + 1, p_149873_3_, p_149873_4_) == this.field_149877_a ? 1 : (p_149873_1_.getBlock(p_149873_2_, p_149873_3_, p_149873_4_ - 1) == this.field_149877_a ? 2 : (p_149873_1_.getBlock(p_149873_2_, p_149873_3_, p_149873_4_ + 1) == this.field_149877_a ? 3 : -1)))); + } + + public void dropBlockAsItemWithChance(World p_149690_1_, int p_149690_2_, int p_149690_3_, int p_149690_4_, int p_149690_5_, float p_149690_6_, int p_149690_7_) + { + super.dropBlockAsItemWithChance(p_149690_1_, p_149690_2_, p_149690_3_, p_149690_4_, p_149690_5_, p_149690_6_, p_149690_7_); + + if (false && !p_149690_1_.isRemote) + { + Item item = null; + + if (this.field_149877_a == Blocks.pumpkin) + { + item = Items.pumpkin_seeds; + } + + if (this.field_149877_a == Blocks.melon_block) + { + item = Items.melon_seeds; + } + + for (int j1 = 0; j1 < 3; ++j1) + { + if (p_149690_1_.rand.nextInt(15) <= p_149690_5_) + { + this.dropBlockAsItem(p_149690_1_, p_149690_2_, p_149690_3_, p_149690_4_, new ItemStack(item)); + } + } + } + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return null; + } + + public int quantityDropped(Random p_149745_1_) + { + return 1; + } + + public boolean func_149851_a(World p_149851_1_, int p_149851_2_, int p_149851_3_, int p_149851_4_, boolean p_149851_5_) + { + return p_149851_1_.getBlockMetadata(p_149851_2_, p_149851_3_, p_149851_4_) != 7; + } + + public boolean func_149852_a(World p_149852_1_, Random p_149852_2_, int p_149852_3_, int p_149852_4_, int p_149852_5_) + { + return true; + } + + @SideOnly(Side.CLIENT) + public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) + { + return this.field_149877_a == Blocks.pumpkin ? Items.pumpkin_seeds : (this.field_149877_a == Blocks.melon_block ? Items.melon_seeds : Item.getItemById(0)); + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.blockIcon = p_149651_1_.registerIcon(this.getTextureName() + "_disconnected"); + this.field_149876_b = p_149651_1_.registerIcon(this.getTextureName() + "_connected"); + } + + @SideOnly(Side.CLIENT) + public IIcon getStemIcon() + { + return this.field_149876_b; + } + + public void func_149853_b(World p_149853_1_, Random p_149853_2_, int p_149853_3_, int p_149853_4_, int p_149853_5_) + { + this.func_149874_m(p_149853_1_, p_149853_3_, p_149853_4_, p_149853_5_); + } + + + @Override + public ArrayList getDrops(World world, int x, int y, int z, int meta, int fortune) + { + ArrayList ret = new ArrayList(); + + Item item = null; + item = field_149877_a == Blocks.pumpkin ? Items.pumpkin_seeds : item; + item = field_149877_a == Blocks.melon_block ? Items.melon_seeds : item; + + for (int i = 0; item != null && i < 3; i++) + { + ret.add(new ItemStack(item)); + } + + return ret; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockStone.java b/src/main/java/net/minecraft/block/BlockStone.java new file mode 100644 index 0000000..63e02a0 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockStone.java @@ -0,0 +1,23 @@ +package net.minecraft.block; + +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; + +public class BlockStone extends Block +{ + private static final String __OBFID = "CL_00000317"; + + public BlockStone() + { + super(Material.rock); + this.setCreativeTab(CreativeTabs.tabBlock); + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return Item.getItemFromBlock(Blocks.cobblestone); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockStoneBrick.java b/src/main/java/net/minecraft/block/BlockStoneBrick.java new file mode 100644 index 0000000..2d7634e --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockStoneBrick.java @@ -0,0 +1,69 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +public class BlockStoneBrick extends Block +{ + public static final String[] field_150142_a = new String[] {"default", "mossy", "cracked", "chiseled"}; + public static final String[] field_150141_b = new String[] {null, "mossy", "cracked", "carved"}; + @SideOnly(Side.CLIENT) + private IIcon[] field_150143_M; + private static final String __OBFID = "CL_00000318"; + + public BlockStoneBrick() + { + super(Material.rock); + this.setCreativeTab(CreativeTabs.tabBlock); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + if (p_149691_2_ < 0 || p_149691_2_ >= field_150141_b.length) + { + p_149691_2_ = 0; + } + + return this.field_150143_M[p_149691_2_]; + } + + public int damageDropped(int p_149692_1_) + { + return p_149692_1_; + } + + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_) + { + for (int i = 0; i < 4; ++i) + { + p_149666_3_.add(new ItemStack(p_149666_1_, 1, i)); + } + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.field_150143_M = new IIcon[field_150141_b.length]; + + for (int i = 0; i < this.field_150143_M.length; ++i) + { + String s = this.getTextureName(); + + if (field_150141_b[i] != null) + { + s = s + "_" + field_150141_b[i]; + } + + this.field_150143_M[i] = p_149651_1_.registerIcon(s); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockStoneSlab.java b/src/main/java/net/minecraft/block/BlockStoneSlab.java new file mode 100644 index 0000000..d2e35a1 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockStoneSlab.java @@ -0,0 +1,82 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +public class BlockStoneSlab extends BlockSlab +{ + public static final String[] field_150006_b = new String[] {"stone", "sand", "wood", "cobble", "brick", "smoothStoneBrick", "netherBrick", "quartz"}; + @SideOnly(Side.CLIENT) + private IIcon field_150007_M; + private static final String __OBFID = "CL_00000320"; + + public BlockStoneSlab(boolean p_i45431_1_) + { + super(p_i45431_1_, Material.rock); + this.setCreativeTab(CreativeTabs.tabBlock); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + int k = p_149691_2_ & 7; + + if (this.field_150004_a && (p_149691_2_ & 8) != 0) + { + p_149691_1_ = 1; + } + + return k == 0 ? (p_149691_1_ != 1 && p_149691_1_ != 0 ? this.field_150007_M : this.blockIcon) : (k == 1 ? Blocks.sandstone.getBlockTextureFromSide(p_149691_1_) : (k == 2 ? Blocks.planks.getBlockTextureFromSide(p_149691_1_) : (k == 3 ? Blocks.cobblestone.getBlockTextureFromSide(p_149691_1_) : (k == 4 ? Blocks.brick_block.getBlockTextureFromSide(p_149691_1_) : (k == 5 ? Blocks.stonebrick.getIcon(p_149691_1_, 0) : (k == 6 ? Blocks.nether_brick.getBlockTextureFromSide(1) : (k == 7 ? Blocks.quartz_block.getBlockTextureFromSide(p_149691_1_) : this.blockIcon))))))); + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.blockIcon = p_149651_1_.registerIcon("stone_slab_top"); + this.field_150007_M = p_149651_1_.registerIcon("stone_slab_side"); + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return Item.getItemFromBlock(Blocks.stone_slab); + } + + protected ItemStack createStackedBlock(int p_149644_1_) + { + return new ItemStack(Item.getItemFromBlock(Blocks.stone_slab), 2, p_149644_1_ & 7); + } + + public String func_150002_b(int p_150002_1_) + { + if (p_150002_1_ < 0 || p_150002_1_ >= field_150006_b.length) + { + p_150002_1_ = 0; + } + + return super.getUnlocalizedName() + "." + field_150006_b[p_150002_1_]; + } + + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_) + { + if (p_149666_1_ != Item.getItemFromBlock(Blocks.double_stone_slab)) + { + for (int i = 0; i <= 7; ++i) + { + if (i != 2) + { + p_149666_3_.add(new ItemStack(p_149666_1_, 1, i)); + } + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockTNT.java b/src/main/java/net/minecraft/block/BlockTNT.java new file mode 100644 index 0000000..5e86c45 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockTNT.java @@ -0,0 +1,133 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityTNTPrimed; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.init.Items; +import net.minecraft.util.IIcon; +import net.minecraft.world.Explosion; +import net.minecraft.world.World; + +public class BlockTNT extends Block +{ + @SideOnly(Side.CLIENT) + private IIcon field_150116_a; + @SideOnly(Side.CLIENT) + private IIcon field_150115_b; + private static final String __OBFID = "CL_00000324"; + + public BlockTNT() + { + super(Material.tnt); + this.setCreativeTab(CreativeTabs.tabRedstone); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return p_149691_1_ == 0 ? this.field_150115_b : (p_149691_1_ == 1 ? this.field_150116_a : this.blockIcon); + } + + public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_) + { + super.onBlockAdded(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_); + + if (p_149726_1_.isBlockIndirectlyGettingPowered(p_149726_2_, p_149726_3_, p_149726_4_)) + { + this.onBlockDestroyedByPlayer(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_, 1); + p_149726_1_.setBlockToAir(p_149726_2_, p_149726_3_, p_149726_4_); + } + } + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) + { + if (p_149695_1_.isBlockIndirectlyGettingPowered(p_149695_2_, p_149695_3_, p_149695_4_)) + { + this.onBlockDestroyedByPlayer(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, 1); + p_149695_1_.setBlockToAir(p_149695_2_, p_149695_3_, p_149695_4_); + } + } + + public int quantityDropped(Random p_149745_1_) + { + return 1; + } + + public void onBlockDestroyedByExplosion(World p_149723_1_, int p_149723_2_, int p_149723_3_, int p_149723_4_, Explosion p_149723_5_) + { + if (!p_149723_1_.isRemote) + { + EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(p_149723_1_, (double)((float)p_149723_2_ + 0.5F), (double)((float)p_149723_3_ + 0.5F), (double)((float)p_149723_4_ + 0.5F), p_149723_5_.getExplosivePlacedBy()); + entitytntprimed.fuse = p_149723_1_.rand.nextInt(entitytntprimed.fuse / 4) + entitytntprimed.fuse / 8; + p_149723_1_.spawnEntityInWorld(entitytntprimed); + } + } + + public void onBlockDestroyedByPlayer(World p_149664_1_, int p_149664_2_, int p_149664_3_, int p_149664_4_, int p_149664_5_) + { + this.func_150114_a(p_149664_1_, p_149664_2_, p_149664_3_, p_149664_4_, p_149664_5_, (EntityLivingBase)null); + } + + public void func_150114_a(World p_150114_1_, int p_150114_2_, int p_150114_3_, int p_150114_4_, int p_150114_5_, EntityLivingBase p_150114_6_) + { + if (!p_150114_1_.isRemote) + { + if ((p_150114_5_ & 1) == 1) + { + EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(p_150114_1_, (double)((float)p_150114_2_ + 0.5F), (double)((float)p_150114_3_ + 0.5F), (double)((float)p_150114_4_ + 0.5F), p_150114_6_); + p_150114_1_.spawnEntityInWorld(entitytntprimed); + p_150114_1_.playSoundAtEntity(entitytntprimed, "game.tnt.primed", 1.0F, 1.0F); + } + } + } + + public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) + { + if (p_149727_5_.getCurrentEquippedItem() != null && p_149727_5_.getCurrentEquippedItem().getItem() == Items.flint_and_steel) + { + this.func_150114_a(p_149727_1_, p_149727_2_, p_149727_3_, p_149727_4_, 1, p_149727_5_); + p_149727_1_.setBlockToAir(p_149727_2_, p_149727_3_, p_149727_4_); + p_149727_5_.getCurrentEquippedItem().damageItem(1, p_149727_5_); + return true; + } + else + { + return super.onBlockActivated(p_149727_1_, p_149727_2_, p_149727_3_, p_149727_4_, p_149727_5_, p_149727_6_, p_149727_7_, p_149727_8_, p_149727_9_); + } + } + + public void onEntityCollidedWithBlock(World p_149670_1_, int p_149670_2_, int p_149670_3_, int p_149670_4_, Entity p_149670_5_) + { + if (p_149670_5_ instanceof EntityArrow && !p_149670_1_.isRemote) + { + EntityArrow entityarrow = (EntityArrow)p_149670_5_; + + if (entityarrow.isBurning()) + { + this.func_150114_a(p_149670_1_, p_149670_2_, p_149670_3_, p_149670_4_, 1, entityarrow.shootingEntity instanceof EntityLivingBase ? (EntityLivingBase)entityarrow.shootingEntity : null); + p_149670_1_.setBlockToAir(p_149670_2_, p_149670_3_, p_149670_4_); + } + } + } + + public boolean canDropFromExplosion(Explosion p_149659_1_) + { + return false; + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.blockIcon = p_149651_1_.registerIcon(this.getTextureName() + "_side"); + this.field_150116_a = p_149651_1_.registerIcon(this.getTextureName() + "_top"); + this.field_150115_b = p_149651_1_.registerIcon(this.getTextureName() + "_bottom"); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockTallGrass.java b/src/main/java/net/minecraft/block/BlockTallGrass.java new file mode 100644 index 0000000..351d197 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockTallGrass.java @@ -0,0 +1,167 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.stats.StatList; +import net.minecraft.util.IIcon; +import net.minecraft.world.ColorizerGrass; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.ForgeHooks; +import net.minecraftforge.common.IShearable; + +public class BlockTallGrass extends BlockBush implements IGrowable, IShearable +{ + private static final String[] field_149871_a = new String[] {"deadbush", "tallgrass", "fern"}; + @SideOnly(Side.CLIENT) + private IIcon[] field_149870_b; + private static final String __OBFID = "CL_00000321"; + + protected BlockTallGrass() + { + super(Material.vine); + float f = 0.4F; + this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.8F, 0.5F + f); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + if (p_149691_2_ >= this.field_149870_b.length) + { + p_149691_2_ = 0; + } + + return this.field_149870_b[p_149691_2_]; + } + + @SideOnly(Side.CLIENT) + public int getBlockColor() + { + double d0 = 0.5D; + double d1 = 1.0D; + return ColorizerGrass.getGrassColor(d0, d1); + } + + public boolean canBlockStay(World p_149718_1_, int p_149718_2_, int p_149718_3_, int p_149718_4_) + { + return this.canPlaceBlockOn(p_149718_1_.getBlock(p_149718_2_, p_149718_3_ - 1, p_149718_4_)); + } + + @SideOnly(Side.CLIENT) + public int getRenderColor(int p_149741_1_) + { + return p_149741_1_ == 0 ? 16777215 : ColorizerGrass.getGrassColor(0.5D, 1.0D); + } + + @SideOnly(Side.CLIENT) + public int colorMultiplier(IBlockAccess p_149720_1_, int p_149720_2_, int p_149720_3_, int p_149720_4_) + { + int l = p_149720_1_.getBlockMetadata(p_149720_2_, p_149720_3_, p_149720_4_); + return l == 0 ? 16777215 : p_149720_1_.getBiomeGenForCoords(p_149720_2_, p_149720_4_).getBiomeGrassColor(p_149720_2_, p_149720_3_, p_149720_4_); + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return null; + } + + public int quantityDroppedWithBonus(int p_149679_1_, Random p_149679_2_) + { + return 1 + p_149679_2_.nextInt(p_149679_1_ * 2 + 1); + } + + public void harvestBlock(World p_149636_1_, EntityPlayer p_149636_2_, int p_149636_3_, int p_149636_4_, int p_149636_5_, int p_149636_6_) + { + { + super.harvestBlock(p_149636_1_, p_149636_2_, p_149636_3_, p_149636_4_, p_149636_5_, p_149636_6_); + } + } + + public int getDamageValue(World p_149643_1_, int p_149643_2_, int p_149643_3_, int p_149643_4_) + { + return p_149643_1_.getBlockMetadata(p_149643_2_, p_149643_3_, p_149643_4_); + } + + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_) + { + for (int i = 1; i < 3; ++i) + { + p_149666_3_.add(new ItemStack(p_149666_1_, 1, i)); + } + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.field_149870_b = new IIcon[field_149871_a.length]; + + for (int i = 0; i < this.field_149870_b.length; ++i) + { + this.field_149870_b[i] = p_149651_1_.registerIcon(field_149871_a[i]); + } + } + + public boolean func_149851_a(World p_149851_1_, int p_149851_2_, int p_149851_3_, int p_149851_4_, boolean p_149851_5_) + { + int l = p_149851_1_.getBlockMetadata(p_149851_2_, p_149851_3_, p_149851_4_); + return l != 0; + } + + public boolean func_149852_a(World p_149852_1_, Random p_149852_2_, int p_149852_3_, int p_149852_4_, int p_149852_5_) + { + return true; + } + + public void func_149853_b(World p_149853_1_, Random p_149853_2_, int p_149853_3_, int p_149853_4_, int p_149853_5_) + { + int l = p_149853_1_.getBlockMetadata(p_149853_3_, p_149853_4_, p_149853_5_); + byte b0 = 2; + + if (l == 2) + { + b0 = 3; + } + + if (Blocks.double_plant.canPlaceBlockAt(p_149853_1_, p_149853_3_, p_149853_4_, p_149853_5_)) + { + Blocks.double_plant.func_149889_c(p_149853_1_, p_149853_3_, p_149853_4_, p_149853_5_, b0, 2); + } + } + + @Override + public ArrayList getDrops(World world, int x, int y, int z, int meta, int fortune) + { + ArrayList ret = new ArrayList(); + if (world.rand.nextInt(8) != 0) return ret; + ItemStack seed = ForgeHooks.getGrassSeed(world); + if (seed != null) ret.add(seed); + return ret; + } + + @Override + public boolean isShearable(ItemStack item, IBlockAccess world, int x, int y, int z) + { + return true; + } + + @Override + public ArrayList onSheared(ItemStack item, IBlockAccess world, int x, int y, int z, int fortune) + { + ArrayList ret = new ArrayList(); + ret.add(new ItemStack(this, 1, world.getBlockMetadata(x, y, z))); + return ret; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockTorch.java b/src/main/java/net/minecraft/block/BlockTorch.java new file mode 100644 index 0000000..d1d76d1 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockTorch.java @@ -0,0 +1,277 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Blocks; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; +import static net.minecraftforge.common.util.ForgeDirection.*; + +public class BlockTorch extends Block +{ + private static final String __OBFID = "CL_00000325"; + + protected BlockTorch() + { + super(Material.circuits); + this.setTickRandomly(true); + this.setCreativeTab(CreativeTabs.tabDecorations); + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) + { + return null; + } + + public boolean isOpaqueCube() + { + return false; + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public int getRenderType() + { + return 2; + } + + private boolean func_150107_m(World p_150107_1_, int p_150107_2_, int p_150107_3_, int p_150107_4_) + { + if (World.doesBlockHaveSolidTopSurface(p_150107_1_, p_150107_2_, p_150107_3_, p_150107_4_)) + { + return true; + } + else + { + Block block = p_150107_1_.getBlock(p_150107_2_, p_150107_3_, p_150107_4_); + return block.canPlaceTorchOnTop(p_150107_1_, p_150107_2_, p_150107_3_, p_150107_4_); + } + } + + public boolean canPlaceBlockAt(World p_149742_1_, int p_149742_2_, int p_149742_3_, int p_149742_4_) + { + return p_149742_1_.isSideSolid(p_149742_2_ - 1, p_149742_3_, p_149742_4_, EAST, true) || + p_149742_1_.isSideSolid(p_149742_2_ + 1, p_149742_3_, p_149742_4_, WEST, true) || + p_149742_1_.isSideSolid(p_149742_2_, p_149742_3_, p_149742_4_ - 1, SOUTH, true) || + p_149742_1_.isSideSolid(p_149742_2_, p_149742_3_, p_149742_4_ + 1, NORTH, true) || + func_150107_m(p_149742_1_, p_149742_2_, p_149742_3_ - 1, p_149742_4_); + } + + public int onBlockPlaced(World p_149660_1_, int p_149660_2_, int p_149660_3_, int p_149660_4_, int p_149660_5_, float p_149660_6_, float p_149660_7_, float p_149660_8_, int p_149660_9_) + { + int j1 = p_149660_9_; + + if (p_149660_5_ == 1 && this.func_150107_m(p_149660_1_, p_149660_2_, p_149660_3_ - 1, p_149660_4_)) + { + j1 = 5; + } + + if (p_149660_5_ == 2 && p_149660_1_.isSideSolid(p_149660_2_, p_149660_3_, p_149660_4_ + 1, NORTH, true)) + { + j1 = 4; + } + + if (p_149660_5_ == 3 && p_149660_1_.isSideSolid(p_149660_2_, p_149660_3_, p_149660_4_ - 1, SOUTH, true)) + { + j1 = 3; + } + + if (p_149660_5_ == 4 && p_149660_1_.isSideSolid(p_149660_2_ + 1, p_149660_3_, p_149660_4_, WEST, true)) + { + j1 = 2; + } + + if (p_149660_5_ == 5 && p_149660_1_.isSideSolid(p_149660_2_ - 1, p_149660_3_, p_149660_4_, EAST, true)) + { + j1 = 1; + } + + return j1; + } + + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) + { + super.updateTick(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, p_149674_5_); + + if (p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_) == 0) + { + this.onBlockAdded(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_); + } + } + + public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_) + { + if (p_149726_1_.getBlockMetadata(p_149726_2_, p_149726_3_, p_149726_4_) == 0) + { + if (p_149726_1_.isSideSolid(p_149726_2_ - 1, p_149726_3_, p_149726_4_, EAST, true)) + { + p_149726_1_.setBlockMetadataWithNotify(p_149726_2_, p_149726_3_, p_149726_4_, 1, 2); + } + else if (p_149726_1_.isSideSolid(p_149726_2_ + 1, p_149726_3_, p_149726_4_, WEST, true)) + { + p_149726_1_.setBlockMetadataWithNotify(p_149726_2_, p_149726_3_, p_149726_4_, 2, 2); + } + else if (p_149726_1_.isSideSolid(p_149726_2_, p_149726_3_, p_149726_4_ - 1, SOUTH, true)) + { + p_149726_1_.setBlockMetadataWithNotify(p_149726_2_, p_149726_3_, p_149726_4_, 3, 2); + } + else if (p_149726_1_.isSideSolid(p_149726_2_, p_149726_3_, p_149726_4_ + 1, NORTH, true)) + { + p_149726_1_.setBlockMetadataWithNotify(p_149726_2_, p_149726_3_, p_149726_4_, 4, 2); + } + else if (this.func_150107_m(p_149726_1_, p_149726_2_, p_149726_3_ - 1, p_149726_4_)) + { + p_149726_1_.setBlockMetadataWithNotify(p_149726_2_, p_149726_3_, p_149726_4_, 5, 2); + } + } + + this.func_150109_e(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_); + } + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) + { + this.func_150108_b(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, p_149695_5_); + } + + protected boolean func_150108_b(World p_150108_1_, int p_150108_2_, int p_150108_3_, int p_150108_4_, Block p_150108_5_) + { + if (this.func_150109_e(p_150108_1_, p_150108_2_, p_150108_3_, p_150108_4_)) + { + int l = p_150108_1_.getBlockMetadata(p_150108_2_, p_150108_3_, p_150108_4_); + boolean flag = false; + + if (!p_150108_1_.isSideSolid(p_150108_2_ - 1, p_150108_3_, p_150108_4_, EAST, true) && l == 1) + { + flag = true; + } + + if (!p_150108_1_.isSideSolid(p_150108_2_ + 1, p_150108_3_, p_150108_4_, WEST, true) && l == 2) + { + flag = true; + } + + if (!p_150108_1_.isSideSolid(p_150108_2_, p_150108_3_, p_150108_4_ - 1, SOUTH, true) && l == 3) + { + flag = true; + } + + if (!p_150108_1_.isSideSolid(p_150108_2_, p_150108_3_, p_150108_4_ + 1, NORTH, true) && l == 4) + { + flag = true; + } + + if (!this.func_150107_m(p_150108_1_, p_150108_2_, p_150108_3_ - 1, p_150108_4_) && l == 5) + { + flag = true; + } + + if (flag) + { + this.dropBlockAsItem(p_150108_1_, p_150108_2_, p_150108_3_, p_150108_4_, p_150108_1_.getBlockMetadata(p_150108_2_, p_150108_3_, p_150108_4_), 0); + p_150108_1_.setBlockToAir(p_150108_2_, p_150108_3_, p_150108_4_); + return true; + } + else + { + return false; + } + } + else + { + return true; + } + } + + protected boolean func_150109_e(World p_150109_1_, int p_150109_2_, int p_150109_3_, int p_150109_4_) + { + if (!this.canPlaceBlockAt(p_150109_1_, p_150109_2_, p_150109_3_, p_150109_4_)) + { + if (p_150109_1_.getBlock(p_150109_2_, p_150109_3_, p_150109_4_) == this) + { + this.dropBlockAsItem(p_150109_1_, p_150109_2_, p_150109_3_, p_150109_4_, p_150109_1_.getBlockMetadata(p_150109_2_, p_150109_3_, p_150109_4_), 0); + p_150109_1_.setBlockToAir(p_150109_2_, p_150109_3_, p_150109_4_); + } + + return false; + } + else + { + return true; + } + } + + public MovingObjectPosition collisionRayTrace(World p_149731_1_, int p_149731_2_, int p_149731_3_, int p_149731_4_, Vec3 p_149731_5_, Vec3 p_149731_6_) + { + int l = p_149731_1_.getBlockMetadata(p_149731_2_, p_149731_3_, p_149731_4_) & 7; + float f = 0.15F; + + if (l == 1) + { + this.setBlockBounds(0.0F, 0.2F, 0.5F - f, f * 2.0F, 0.8F, 0.5F + f); + } + else if (l == 2) + { + this.setBlockBounds(1.0F - f * 2.0F, 0.2F, 0.5F - f, 1.0F, 0.8F, 0.5F + f); + } + else if (l == 3) + { + this.setBlockBounds(0.5F - f, 0.2F, 0.0F, 0.5F + f, 0.8F, f * 2.0F); + } + else if (l == 4) + { + this.setBlockBounds(0.5F - f, 0.2F, 1.0F - f * 2.0F, 0.5F + f, 0.8F, 1.0F); + } + else + { + f = 0.1F; + this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.6F, 0.5F + f); + } + + return super.collisionRayTrace(p_149731_1_, p_149731_2_, p_149731_3_, p_149731_4_, p_149731_5_, p_149731_6_); + } + + @SideOnly(Side.CLIENT) + public void randomDisplayTick(World p_149734_1_, int p_149734_2_, int p_149734_3_, int p_149734_4_, Random p_149734_5_) + { + int l = p_149734_1_.getBlockMetadata(p_149734_2_, p_149734_3_, p_149734_4_); + double d0 = (double)((float)p_149734_2_ + 0.5F); + double d1 = (double)((float)p_149734_3_ + 0.7F); + double d2 = (double)((float)p_149734_4_ + 0.5F); + double d3 = 0.2199999988079071D; + double d4 = 0.27000001072883606D; + + if (l == 1) + { + p_149734_1_.spawnParticle("smoke", d0 - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D); + p_149734_1_.spawnParticle("flame", d0 - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D); + } + else if (l == 2) + { + p_149734_1_.spawnParticle("smoke", d0 + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D); + p_149734_1_.spawnParticle("flame", d0 + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D); + } + else if (l == 3) + { + p_149734_1_.spawnParticle("smoke", d0, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D); + p_149734_1_.spawnParticle("flame", d0, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D); + } + else if (l == 4) + { + p_149734_1_.spawnParticle("smoke", d0, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D); + p_149734_1_.spawnParticle("flame", d0, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D); + } + else + { + p_149734_1_.spawnParticle("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D); + p_149734_1_.spawnParticle("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockTrapDoor.java b/src/main/java/net/minecraft/block/BlockTrapDoor.java new file mode 100644 index 0000000..fe190d5 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockTrapDoor.java @@ -0,0 +1,269 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.Vec3; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public class BlockTrapDoor extends Block +{ + /** Set this to allow trapdoors to remain free-floating */ + public static boolean disableValidation = false; + private static final String __OBFID = "CL_00000327"; + + protected BlockTrapDoor(Material p_i45434_1_) + { + super(p_i45434_1_); + float f = 0.5F; + float f1 = 1.0F; + this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f1, 0.5F + f); + this.setCreativeTab(CreativeTabs.tabRedstone); + } + + public boolean isOpaqueCube() + { + return false; + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public boolean getBlocksMovement(IBlockAccess p_149655_1_, int p_149655_2_, int p_149655_3_, int p_149655_4_) + { + return !func_150118_d(p_149655_1_.getBlockMetadata(p_149655_2_, p_149655_3_, p_149655_4_)); + } + + public int getRenderType() + { + return 0; + } + + @SideOnly(Side.CLIENT) + public AxisAlignedBB getSelectedBoundingBoxFromPool(World p_149633_1_, int p_149633_2_, int p_149633_3_, int p_149633_4_) + { + this.setBlockBoundsBasedOnState(p_149633_1_, p_149633_2_, p_149633_3_, p_149633_4_); + return super.getSelectedBoundingBoxFromPool(p_149633_1_, p_149633_2_, p_149633_3_, p_149633_4_); + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) + { + this.setBlockBoundsBasedOnState(p_149668_1_, p_149668_2_, p_149668_3_, p_149668_4_); + return super.getCollisionBoundingBoxFromPool(p_149668_1_, p_149668_2_, p_149668_3_, p_149668_4_); + } + + public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) + { + this.func_150117_b(p_149719_1_.getBlockMetadata(p_149719_2_, p_149719_3_, p_149719_4_)); + } + + public void setBlockBoundsForItemRender() + { + float f = 0.1875F; + this.setBlockBounds(0.0F, 0.5F - f / 2.0F, 0.0F, 1.0F, 0.5F + f / 2.0F, 1.0F); + } + + public void func_150117_b(int p_150117_1_) + { + float f = 0.1875F; + + if ((p_150117_1_ & 8) != 0) + { + this.setBlockBounds(0.0F, 1.0F - f, 0.0F, 1.0F, 1.0F, 1.0F); + } + else + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, f, 1.0F); + } + + if (func_150118_d(p_150117_1_)) + { + if ((p_150117_1_ & 3) == 0) + { + this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F); + } + + if ((p_150117_1_ & 3) == 1) + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f); + } + + if ((p_150117_1_ & 3) == 2) + { + this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + + if ((p_150117_1_ & 3) == 3) + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F); + } + } + } + + public void onBlockClicked(World p_149699_1_, int p_149699_2_, int p_149699_3_, int p_149699_4_, EntityPlayer p_149699_5_) {} + + public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) + { + if (this.blockMaterial == Material.iron) + { + return true; + } + else + { + int i1 = p_149727_1_.getBlockMetadata(p_149727_2_, p_149727_3_, p_149727_4_); + p_149727_1_.setBlockMetadataWithNotify(p_149727_2_, p_149727_3_, p_149727_4_, i1 ^ 4, 2); + p_149727_1_.playAuxSFXAtEntity(p_149727_5_, 1003, p_149727_2_, p_149727_3_, p_149727_4_, 0); + return true; + } + } + + public void func_150120_a(World p_150120_1_, int p_150120_2_, int p_150120_3_, int p_150120_4_, boolean p_150120_5_) + { + int l = p_150120_1_.getBlockMetadata(p_150120_2_, p_150120_3_, p_150120_4_); + boolean flag1 = (l & 4) > 0; + + if (flag1 != p_150120_5_) + { + p_150120_1_.setBlockMetadataWithNotify(p_150120_2_, p_150120_3_, p_150120_4_, l ^ 4, 2); + p_150120_1_.playAuxSFXAtEntity((EntityPlayer)null, 1003, p_150120_2_, p_150120_3_, p_150120_4_, 0); + } + } + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) + { + if (!p_149695_1_.isRemote) + { + int l = p_149695_1_.getBlockMetadata(p_149695_2_, p_149695_3_, p_149695_4_); + int i1 = p_149695_2_; + int j1 = p_149695_4_; + + if ((l & 3) == 0) + { + j1 = p_149695_4_ + 1; + } + + if ((l & 3) == 1) + { + --j1; + } + + if ((l & 3) == 2) + { + i1 = p_149695_2_ + 1; + } + + if ((l & 3) == 3) + { + --i1; + } + + if (!(func_150119_a(p_149695_1_.getBlock(i1, p_149695_3_, j1)) || p_149695_1_.isSideSolid(i1, p_149695_3_, j1, ForgeDirection.getOrientation((l & 3) + 2)))) + { + p_149695_1_.setBlockToAir(p_149695_2_, p_149695_3_, p_149695_4_); + this.dropBlockAsItem(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, l, 0); + } + + boolean flag = p_149695_1_.isBlockIndirectlyGettingPowered(p_149695_2_, p_149695_3_, p_149695_4_); + + if (flag || p_149695_5_.canProvidePower()) + { + this.func_150120_a(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, flag); + } + } + } + + public MovingObjectPosition collisionRayTrace(World p_149731_1_, int p_149731_2_, int p_149731_3_, int p_149731_4_, Vec3 p_149731_5_, Vec3 p_149731_6_) + { + this.setBlockBoundsBasedOnState(p_149731_1_, p_149731_2_, p_149731_3_, p_149731_4_); + return super.collisionRayTrace(p_149731_1_, p_149731_2_, p_149731_3_, p_149731_4_, p_149731_5_, p_149731_6_); + } + + public int onBlockPlaced(World p_149660_1_, int p_149660_2_, int p_149660_3_, int p_149660_4_, int p_149660_5_, float p_149660_6_, float p_149660_7_, float p_149660_8_, int p_149660_9_) + { + int j1 = 0; + + if (p_149660_5_ == 2) + { + j1 = 0; + } + + if (p_149660_5_ == 3) + { + j1 = 1; + } + + if (p_149660_5_ == 4) + { + j1 = 2; + } + + if (p_149660_5_ == 5) + { + j1 = 3; + } + + if (p_149660_5_ != 1 && p_149660_5_ != 0 && p_149660_7_ > 0.5F) + { + j1 |= 8; + } + + return j1; + } + + public boolean canPlaceBlockOnSide(World p_149707_1_, int p_149707_2_, int p_149707_3_, int p_149707_4_, int p_149707_5_) + { + if (disableValidation) return true; + if (p_149707_5_ == 0) + { + return false; + } + else if (p_149707_5_ == 1) + { + return false; + } + else + { + if (p_149707_5_ == 2) + { + ++p_149707_4_; + } + + if (p_149707_5_ == 3) + { + --p_149707_4_; + } + + if (p_149707_5_ == 4) + { + ++p_149707_2_; + } + + if (p_149707_5_ == 5) + { + --p_149707_2_; + } + + return func_150119_a(p_149707_1_.getBlock(p_149707_2_, p_149707_3_, p_149707_4_)) || p_149707_1_.isSideSolid(p_149707_2_, p_149707_3_, p_149707_4_, ForgeDirection.UP); + } + } + + public static boolean func_150118_d(int p_150118_0_) + { + return (p_150118_0_ & 4) != 0; + } + + private static boolean func_150119_a(Block p_150119_0_) + { + if (disableValidation) return true; + return p_150119_0_.blockMaterial.isOpaque() && p_150119_0_.renderAsNormalBlock() || p_150119_0_ == Blocks.glowstone || p_150119_0_ instanceof BlockSlab || p_150119_0_ instanceof BlockStairs; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockTripWire.java b/src/main/java/net/minecraft/block/BlockTripWire.java new file mode 100644 index 0000000..0b1d8a5 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockTripWire.java @@ -0,0 +1,259 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.Direction; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockTripWire extends Block +{ + private static final String __OBFID = "CL_00000328"; + + public BlockTripWire() + { + super(Material.circuits); + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.15625F, 1.0F); + this.setTickRandomly(true); + } + + public int tickRate(World p_149738_1_) + { + return 10; + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) + { + return null; + } + + public boolean isOpaqueCube() + { + return false; + } + + public boolean renderAsNormalBlock() + { + return false; + } + + @SideOnly(Side.CLIENT) + public int getRenderBlockPass() + { + return 1; + } + + public int getRenderType() + { + return 30; + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return Items.string; + } + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) + { + int l = p_149695_1_.getBlockMetadata(p_149695_2_, p_149695_3_, p_149695_4_); + boolean flag = (l & 2) == 2; + boolean flag1 = !World.doesBlockHaveSolidTopSurface(p_149695_1_, p_149695_2_, p_149695_3_ - 1, p_149695_4_); + + if (flag != flag1) + { + this.dropBlockAsItem(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, l, 0); + p_149695_1_.setBlockToAir(p_149695_2_, p_149695_3_, p_149695_4_); + } + } + + public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) + { + int l = p_149719_1_.getBlockMetadata(p_149719_2_, p_149719_3_, p_149719_4_); + boolean flag = (l & 4) == 4; + boolean flag1 = (l & 2) == 2; + + if (!flag1) + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.09375F, 1.0F); + } + else if (!flag) + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); + } + else + { + this.setBlockBounds(0.0F, 0.0625F, 0.0F, 1.0F, 0.15625F, 1.0F); + } + } + + @SideOnly(Side.CLIENT) + public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) + { + return Items.string; + } + + public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_) + { + int l = World.doesBlockHaveSolidTopSurface(p_149726_1_, p_149726_2_, p_149726_3_ - 1, p_149726_4_) ? 0 : 2; + p_149726_1_.setBlockMetadataWithNotify(p_149726_2_, p_149726_3_, p_149726_4_, l, 3); + this.func_150138_a(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_, l); + } + + public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) + { + this.func_150138_a(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_6_ | 1); + } + + public void onBlockHarvested(World p_149681_1_, int p_149681_2_, int p_149681_3_, int p_149681_4_, int p_149681_5_, EntityPlayer p_149681_6_) + { + if (!p_149681_1_.isRemote) + { + if (p_149681_6_.getCurrentEquippedItem() != null && p_149681_6_.getCurrentEquippedItem().getItem() == Items.shears) + { + p_149681_1_.setBlockMetadataWithNotify(p_149681_2_, p_149681_3_, p_149681_4_, p_149681_5_ | 8, 4); + } + } + } + + private void func_150138_a(World p_150138_1_, int p_150138_2_, int p_150138_3_, int p_150138_4_, int p_150138_5_) + { + int i1 = 0; + + while (i1 < 2) + { + int j1 = 1; + + while (true) + { + if (j1 < 42) + { + int k1 = p_150138_2_ + Direction.offsetX[i1] * j1; + int l1 = p_150138_4_ + Direction.offsetZ[i1] * j1; + Block block = p_150138_1_.getBlock(k1, p_150138_3_, l1); + + if (block == Blocks.tripwire_hook) + { + int i2 = p_150138_1_.getBlockMetadata(k1, p_150138_3_, l1) & 3; + + if (i2 == Direction.rotateOpposite[i1]) + { + Blocks.tripwire_hook.func_150136_a(p_150138_1_, k1, p_150138_3_, l1, false, p_150138_1_.getBlockMetadata(k1, p_150138_3_, l1), true, j1, p_150138_5_); + } + } + else if (block == Blocks.tripwire) + { + ++j1; + continue; + } + } + + ++i1; + break; + } + } + } + + public void onEntityCollidedWithBlock(World p_149670_1_, int p_149670_2_, int p_149670_3_, int p_149670_4_, Entity p_149670_5_) + { + if (!p_149670_1_.isRemote) + { + if ((p_149670_1_.getBlockMetadata(p_149670_2_, p_149670_3_, p_149670_4_) & 1) != 1) + { + this.func_150140_e(p_149670_1_, p_149670_2_, p_149670_3_, p_149670_4_); + } + } + } + + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) + { + if (!p_149674_1_.isRemote) + { + if ((p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_) & 1) == 1) + { + this.func_150140_e(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_); + } + } + } + + private void func_150140_e(World p_150140_1_, int p_150140_2_, int p_150140_3_, int p_150140_4_) + { + int l = p_150140_1_.getBlockMetadata(p_150140_2_, p_150140_3_, p_150140_4_); + boolean flag = (l & 1) == 1; + boolean flag1 = false; + List list = p_150140_1_.getEntitiesWithinAABBExcludingEntity((Entity)null, AxisAlignedBB.getAABBPool().getAABB((double)p_150140_2_ + this.minX, (double)p_150140_3_ + this.minY, (double)p_150140_4_ + this.minZ, (double)p_150140_2_ + this.maxX, (double)p_150140_3_ + this.maxY, (double)p_150140_4_ + this.maxZ)); + + if (!list.isEmpty()) + { + Iterator iterator = list.iterator(); + + while (iterator.hasNext()) + { + Entity entity = (Entity)iterator.next(); + + if (!entity.doesEntityNotTriggerPressurePlate()) + { + flag1 = true; + break; + } + } + } + + if (flag1 && !flag) + { + l |= 1; + } + + if (!flag1 && flag) + { + l &= -2; + } + + if (flag1 != flag) + { + p_150140_1_.setBlockMetadataWithNotify(p_150140_2_, p_150140_3_, p_150140_4_, l, 3); + this.func_150138_a(p_150140_1_, p_150140_2_, p_150140_3_, p_150140_4_, l); + } + + if (flag1) + { + p_150140_1_.scheduleBlockUpdate(p_150140_2_, p_150140_3_, p_150140_4_, this, this.tickRate(p_150140_1_)); + } + } + + @SideOnly(Side.CLIENT) + public static boolean func_150139_a(IBlockAccess p_150139_0_, int p_150139_1_, int p_150139_2_, int p_150139_3_, int p_150139_4_, int p_150139_5_) + { + int j1 = p_150139_1_ + Direction.offsetX[p_150139_5_]; + int k1 = p_150139_3_ + Direction.offsetZ[p_150139_5_]; + Block block = p_150139_0_.getBlock(j1, p_150139_2_, k1); + boolean flag = (p_150139_4_ & 2) == 2; + int l1; + + if (block == Blocks.tripwire_hook) + { + l1 = p_150139_0_.getBlockMetadata(j1, p_150139_2_, k1); + int i2 = l1 & 3; + return i2 == Direction.rotateOpposite[p_150139_5_]; + } + else if (block == Blocks.tripwire) + { + l1 = p_150139_0_.getBlockMetadata(j1, p_150139_2_, k1); + boolean flag1 = (l1 & 2) == 2; + return flag == flag1; + } + else + { + return false; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockTripWireHook.java b/src/main/java/net/minecraft/block/BlockTripWireHook.java new file mode 100644 index 0000000..e3e3285 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockTripWireHook.java @@ -0,0 +1,394 @@ +package net.minecraft.block; + +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Blocks; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.Direction; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import net.minecraftforge.common.util.ForgeDirection; +import static net.minecraftforge.common.util.ForgeDirection.*; + +public class BlockTripWireHook extends Block +{ + private static final String __OBFID = "CL_00000329"; + + public BlockTripWireHook() + { + super(Material.circuits); + this.setCreativeTab(CreativeTabs.tabRedstone); + this.setTickRandomly(true); + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) + { + return null; + } + + public boolean isOpaqueCube() + { + return false; + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public int getRenderType() + { + return 29; + } + + public int tickRate(World p_149738_1_) + { + return 10; + } + + public boolean canPlaceBlockOnSide(World p_149707_1_, int p_149707_2_, int p_149707_3_, int p_149707_4_, int p_149707_5_) + { + ForgeDirection dir = ForgeDirection.getOrientation(p_149707_5_); + return (dir == NORTH && p_149707_1_.isSideSolid(p_149707_2_, p_149707_3_, p_149707_4_ + 1, NORTH)) || + (dir == SOUTH && p_149707_1_.isSideSolid(p_149707_2_, p_149707_3_, p_149707_4_ - 1, SOUTH)) || + (dir == WEST && p_149707_1_.isSideSolid(p_149707_2_ + 1, p_149707_3_, p_149707_4_, WEST )) || + (dir == EAST && p_149707_1_.isSideSolid(p_149707_2_ - 1, p_149707_3_, p_149707_4_, EAST )); + } + + public boolean canPlaceBlockAt(World p_149742_1_, int p_149742_2_, int p_149742_3_, int p_149742_4_) + { + return p_149742_1_.isSideSolid(p_149742_2_ - 1, p_149742_3_, p_149742_4_, EAST ) || + p_149742_1_.isSideSolid(p_149742_2_ + 1, p_149742_3_, p_149742_4_, WEST ) || + p_149742_1_.isSideSolid(p_149742_2_, p_149742_3_, p_149742_4_ - 1, SOUTH) || + p_149742_1_.isSideSolid(p_149742_2_, p_149742_3_, p_149742_4_ + 1, NORTH); + } + + public int onBlockPlaced(World p_149660_1_, int p_149660_2_, int p_149660_3_, int p_149660_4_, int p_149660_5_, float p_149660_6_, float p_149660_7_, float p_149660_8_, int p_149660_9_) + { + byte b0 = 0; + + if (p_149660_5_ == 2 && p_149660_1_.isSideSolid(p_149660_2_, p_149660_3_, p_149660_4_ + 1, NORTH, true)) + { + b0 = 2; + } + + if (p_149660_5_ == 3 && p_149660_1_.isSideSolid(p_149660_2_, p_149660_3_, p_149660_4_ - 1, SOUTH, true)) + { + b0 = 0; + } + + if (p_149660_5_ == 4 && p_149660_1_.isSideSolid(p_149660_2_ + 1, p_149660_3_, p_149660_4_, WEST, true)) + { + b0 = 1; + } + + if (p_149660_5_ == 5 && p_149660_1_.isSideSolid(p_149660_2_ - 1, p_149660_3_, p_149660_4_, EAST, true)) + { + b0 = 3; + } + + return b0; + } + + public void onPostBlockPlaced(World p_149714_1_, int p_149714_2_, int p_149714_3_, int p_149714_4_, int p_149714_5_) + { + this.func_150136_a(p_149714_1_, p_149714_2_, p_149714_3_, p_149714_4_, false, p_149714_5_, false, -1, 0); + } + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) + { + if (p_149695_5_ != this) + { + if (this.func_150137_e(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_)) + { + int l = p_149695_1_.getBlockMetadata(p_149695_2_, p_149695_3_, p_149695_4_); + int i1 = l & 3; + boolean flag = false; + + if (!p_149695_1_.isSideSolid(p_149695_2_ - 1, p_149695_3_, p_149695_4_, EAST) && i1 == 3) + { + flag = true; + } + + if (!p_149695_1_.isSideSolid(p_149695_2_ + 1, p_149695_3_, p_149695_4_, WEST) && i1 == 1) + { + flag = true; + } + + if (!p_149695_1_.isSideSolid(p_149695_2_, p_149695_3_, p_149695_4_ - 1, SOUTH) && i1 == 0) + { + flag = true; + } + + if (!p_149695_1_.isSideSolid(p_149695_2_, p_149695_3_, p_149695_4_ + 1, NORTH) && i1 == 2) + { + flag = true; + } + + if (flag) + { + this.dropBlockAsItem(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, l, 0); + p_149695_1_.setBlockToAir(p_149695_2_, p_149695_3_, p_149695_4_); + } + } + } + } + + public void func_150136_a(World p_150136_1_, int p_150136_2_, int p_150136_3_, int p_150136_4_, boolean p_150136_5_, int p_150136_6_, boolean p_150136_7_, int p_150136_8_, int p_150136_9_) + { + int k1 = p_150136_6_ & 3; + boolean flag2 = (p_150136_6_ & 4) == 4; + boolean flag3 = (p_150136_6_ & 8) == 8; + boolean flag4 = !p_150136_5_; + boolean flag5 = false; + boolean flag6 = !p_150136_1_.isSideSolid(p_150136_2_, p_150136_3_ - 1, p_150136_4_, UP); + int l1 = Direction.offsetX[k1]; + int i2 = Direction.offsetZ[k1]; + int j2 = 0; + int[] aint = new int[42]; + int k2; + int l2; + int i3; + int j3; + + for (k2 = 1; k2 < 42; ++k2) + { + l2 = p_150136_2_ + l1 * k2; + i3 = p_150136_4_ + i2 * k2; + Block block = p_150136_1_.getBlock(l2, p_150136_3_, i3); + + if (block == Blocks.tripwire_hook) + { + j3 = p_150136_1_.getBlockMetadata(l2, p_150136_3_, i3); + + if ((j3 & 3) == Direction.rotateOpposite[k1]) + { + j2 = k2; + } + + break; + } + + if (block != Blocks.tripwire && k2 != p_150136_8_) + { + aint[k2] = -1; + flag4 = false; + } + else + { + j3 = k2 == p_150136_8_ ? p_150136_9_ : p_150136_1_.getBlockMetadata(l2, p_150136_3_, i3); + boolean flag7 = (j3 & 8) != 8; + boolean flag8 = (j3 & 1) == 1; + boolean flag9 = (j3 & 2) == 2; + flag4 &= flag9 == flag6; + flag5 |= flag7 && flag8; + aint[k2] = j3; + + if (k2 == p_150136_8_) + { + p_150136_1_.scheduleBlockUpdate(p_150136_2_, p_150136_3_, p_150136_4_, this, this.tickRate(p_150136_1_)); + flag4 &= flag7; + } + } + } + + flag4 &= j2 > 1; + flag5 &= flag4; + k2 = (flag4 ? 4 : 0) | (flag5 ? 8 : 0); + p_150136_6_ = k1 | k2; + int k3; + + if (j2 > 0) + { + l2 = p_150136_2_ + l1 * j2; + i3 = p_150136_4_ + i2 * j2; + k3 = Direction.rotateOpposite[k1]; + p_150136_1_.setBlockMetadataWithNotify(l2, p_150136_3_, i3, k3 | k2, 3); + this.func_150134_a(p_150136_1_, l2, p_150136_3_, i3, k3); + this.func_150135_a(p_150136_1_, l2, p_150136_3_, i3, flag4, flag5, flag2, flag3); + } + + this.func_150135_a(p_150136_1_, p_150136_2_, p_150136_3_, p_150136_4_, flag4, flag5, flag2, flag3); + + if (!p_150136_5_) + { + p_150136_1_.setBlockMetadataWithNotify(p_150136_2_, p_150136_3_, p_150136_4_, p_150136_6_, 3); + + if (p_150136_7_) + { + this.func_150134_a(p_150136_1_, p_150136_2_, p_150136_3_, p_150136_4_, k1); + } + } + + if (flag2 != flag4) + { + for (l2 = 1; l2 < j2; ++l2) + { + i3 = p_150136_2_ + l1 * l2; + k3 = p_150136_4_ + i2 * l2; + j3 = aint[l2]; + + if (j3 >= 0) + { + if (flag4) + { + j3 |= 4; + } + else + { + j3 &= -5; + } + + p_150136_1_.setBlockMetadataWithNotify(i3, p_150136_3_, k3, j3, 3); + } + } + } + } + + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) + { + this.func_150136_a(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, false, p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_), true, -1, 0); + } + + private void func_150135_a(World p_150135_1_, int p_150135_2_, int p_150135_3_, int p_150135_4_, boolean p_150135_5_, boolean p_150135_6_, boolean p_150135_7_, boolean p_150135_8_) + { + if (p_150135_6_ && !p_150135_8_) + { + p_150135_1_.playSoundEffect((double)p_150135_2_ + 0.5D, (double)p_150135_3_ + 0.1D, (double)p_150135_4_ + 0.5D, "random.click", 0.4F, 0.6F); + } + else if (!p_150135_6_ && p_150135_8_) + { + p_150135_1_.playSoundEffect((double)p_150135_2_ + 0.5D, (double)p_150135_3_ + 0.1D, (double)p_150135_4_ + 0.5D, "random.click", 0.4F, 0.5F); + } + else if (p_150135_5_ && !p_150135_7_) + { + p_150135_1_.playSoundEffect((double)p_150135_2_ + 0.5D, (double)p_150135_3_ + 0.1D, (double)p_150135_4_ + 0.5D, "random.click", 0.4F, 0.7F); + } + else if (!p_150135_5_ && p_150135_7_) + { + p_150135_1_.playSoundEffect((double)p_150135_2_ + 0.5D, (double)p_150135_3_ + 0.1D, (double)p_150135_4_ + 0.5D, "random.bowhit", 0.4F, 1.2F / (p_150135_1_.rand.nextFloat() * 0.2F + 0.9F)); + } + } + + private void func_150134_a(World p_150134_1_, int p_150134_2_, int p_150134_3_, int p_150134_4_, int p_150134_5_) + { + p_150134_1_.notifyBlocksOfNeighborChange(p_150134_2_, p_150134_3_, p_150134_4_, this); + + if (p_150134_5_ == 3) + { + p_150134_1_.notifyBlocksOfNeighborChange(p_150134_2_ - 1, p_150134_3_, p_150134_4_, this); + } + else if (p_150134_5_ == 1) + { + p_150134_1_.notifyBlocksOfNeighborChange(p_150134_2_ + 1, p_150134_3_, p_150134_4_, this); + } + else if (p_150134_5_ == 0) + { + p_150134_1_.notifyBlocksOfNeighborChange(p_150134_2_, p_150134_3_, p_150134_4_ - 1, this); + } + else if (p_150134_5_ == 2) + { + p_150134_1_.notifyBlocksOfNeighborChange(p_150134_2_, p_150134_3_, p_150134_4_ + 1, this); + } + } + + private boolean func_150137_e(World p_150137_1_, int p_150137_2_, int p_150137_3_, int p_150137_4_) + { + if (!this.canPlaceBlockAt(p_150137_1_, p_150137_2_, p_150137_3_, p_150137_4_)) + { + this.dropBlockAsItem(p_150137_1_, p_150137_2_, p_150137_3_, p_150137_4_, p_150137_1_.getBlockMetadata(p_150137_2_, p_150137_3_, p_150137_4_), 0); + p_150137_1_.setBlockToAir(p_150137_2_, p_150137_3_, p_150137_4_); + return false; + } + else + { + return true; + } + } + + public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) + { + int l = p_149719_1_.getBlockMetadata(p_149719_2_, p_149719_3_, p_149719_4_) & 3; + float f = 0.1875F; + + if (l == 3) + { + this.setBlockBounds(0.0F, 0.2F, 0.5F - f, f * 2.0F, 0.8F, 0.5F + f); + } + else if (l == 1) + { + this.setBlockBounds(1.0F - f * 2.0F, 0.2F, 0.5F - f, 1.0F, 0.8F, 0.5F + f); + } + else if (l == 0) + { + this.setBlockBounds(0.5F - f, 0.2F, 0.0F, 0.5F + f, 0.8F, f * 2.0F); + } + else if (l == 2) + { + this.setBlockBounds(0.5F - f, 0.2F, 1.0F - f * 2.0F, 0.5F + f, 0.8F, 1.0F); + } + } + + public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) + { + boolean flag = (p_149749_6_ & 4) == 4; + boolean flag1 = (p_149749_6_ & 8) == 8; + + if (flag || flag1) + { + this.func_150136_a(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, true, p_149749_6_, false, -1, 0); + } + + if (flag1) + { + p_149749_1_.notifyBlocksOfNeighborChange(p_149749_2_, p_149749_3_, p_149749_4_, this); + int i1 = p_149749_6_ & 3; + + if (i1 == 3) + { + p_149749_1_.notifyBlocksOfNeighborChange(p_149749_2_ - 1, p_149749_3_, p_149749_4_, this); + } + else if (i1 == 1) + { + p_149749_1_.notifyBlocksOfNeighborChange(p_149749_2_ + 1, p_149749_3_, p_149749_4_, this); + } + else if (i1 == 0) + { + p_149749_1_.notifyBlocksOfNeighborChange(p_149749_2_, p_149749_3_, p_149749_4_ - 1, this); + } + else if (i1 == 2) + { + p_149749_1_.notifyBlocksOfNeighborChange(p_149749_2_, p_149749_3_, p_149749_4_ + 1, this); + } + } + + super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_); + } + + public int isProvidingWeakPower(IBlockAccess p_149709_1_, int p_149709_2_, int p_149709_3_, int p_149709_4_, int p_149709_5_) + { + return (p_149709_1_.getBlockMetadata(p_149709_2_, p_149709_3_, p_149709_4_) & 8) == 8 ? 15 : 0; + } + + public int isProvidingStrongPower(IBlockAccess p_149748_1_, int p_149748_2_, int p_149748_3_, int p_149748_4_, int p_149748_5_) + { + int i1 = p_149748_1_.getBlockMetadata(p_149748_2_, p_149748_3_, p_149748_4_); + + if ((i1 & 8) != 8) + { + return 0; + } + else + { + int j1 = i1 & 3; + return j1 == 2 && p_149748_5_ == 2 ? 15 : (j1 == 0 && p_149748_5_ == 3 ? 15 : (j1 == 1 && p_149748_5_ == 4 ? 15 : (j1 == 3 && p_149748_5_ == 5 ? 15 : 0))); + } + } + + public boolean canProvidePower() + { + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockVine.java b/src/main/java/net/minecraft/block/BlockVine.java new file mode 100644 index 0000000..60d20a8 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockVine.java @@ -0,0 +1,406 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.stats.StatList; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.Direction; +import net.minecraft.world.ColorizerFoliage; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.ForgeHooks; +import net.minecraftforge.common.IShearable; + +public class BlockVine extends Block implements IShearable +{ + private static final String __OBFID = "CL_00000330"; + + public BlockVine() + { + super(Material.vine); + this.setTickRandomly(true); + this.setCreativeTab(CreativeTabs.tabDecorations); + } + + public void setBlockBoundsForItemRender() + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + + public int getRenderType() + { + return 20; + } + + public boolean isOpaqueCube() + { + return false; + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) + { + float f = 0.0625F; + int l = p_149719_1_.getBlockMetadata(p_149719_2_, p_149719_3_, p_149719_4_); + float f1 = 1.0F; + float f2 = 1.0F; + float f3 = 1.0F; + float f4 = 0.0F; + float f5 = 0.0F; + float f6 = 0.0F; + boolean flag = l > 0; + + if ((l & 2) != 0) + { + f4 = Math.max(f4, 0.0625F); + f1 = 0.0F; + f2 = 0.0F; + f5 = 1.0F; + f3 = 0.0F; + f6 = 1.0F; + flag = true; + } + + if ((l & 8) != 0) + { + f1 = Math.min(f1, 0.9375F); + f4 = 1.0F; + f2 = 0.0F; + f5 = 1.0F; + f3 = 0.0F; + f6 = 1.0F; + flag = true; + } + + if ((l & 4) != 0) + { + f6 = Math.max(f6, 0.0625F); + f3 = 0.0F; + f1 = 0.0F; + f4 = 1.0F; + f2 = 0.0F; + f5 = 1.0F; + flag = true; + } + + if ((l & 1) != 0) + { + f3 = Math.min(f3, 0.9375F); + f6 = 1.0F; + f1 = 0.0F; + f4 = 1.0F; + f2 = 0.0F; + f5 = 1.0F; + flag = true; + } + + if (!flag && this.func_150093_a(p_149719_1_.getBlock(p_149719_2_, p_149719_3_ + 1, p_149719_4_))) + { + f2 = Math.min(f2, 0.9375F); + f5 = 1.0F; + f1 = 0.0F; + f4 = 1.0F; + f3 = 0.0F; + f6 = 1.0F; + } + + this.setBlockBounds(f1, f2, f3, f4, f5, f6); + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) + { + return null; + } + + public boolean canPlaceBlockOnSide(World p_149707_1_, int p_149707_2_, int p_149707_3_, int p_149707_4_, int p_149707_5_) + { + switch (p_149707_5_) + { + case 1: + return this.func_150093_a(p_149707_1_.getBlock(p_149707_2_, p_149707_3_ + 1, p_149707_4_)); + case 2: + return this.func_150093_a(p_149707_1_.getBlock(p_149707_2_, p_149707_3_, p_149707_4_ + 1)); + case 3: + return this.func_150093_a(p_149707_1_.getBlock(p_149707_2_, p_149707_3_, p_149707_4_ - 1)); + case 4: + return this.func_150093_a(p_149707_1_.getBlock(p_149707_2_ + 1, p_149707_3_, p_149707_4_)); + case 5: + return this.func_150093_a(p_149707_1_.getBlock(p_149707_2_ - 1, p_149707_3_, p_149707_4_)); + default: + return false; + } + } + + private boolean func_150093_a(Block p_150093_1_) + { + return p_150093_1_.renderAsNormalBlock() && p_150093_1_.blockMaterial.blocksMovement(); + } + + private boolean func_150094_e(World p_150094_1_, int p_150094_2_, int p_150094_3_, int p_150094_4_) + { + int l = p_150094_1_.getBlockMetadata(p_150094_2_, p_150094_3_, p_150094_4_); + int i1 = l; + + if (l > 0) + { + for (int j1 = 0; j1 <= 3; ++j1) + { + int k1 = 1 << j1; + + if ((l & k1) != 0 && !this.func_150093_a(p_150094_1_.getBlock(p_150094_2_ + Direction.offsetX[j1], p_150094_3_, p_150094_4_ + Direction.offsetZ[j1])) && (p_150094_1_.getBlock(p_150094_2_, p_150094_3_ + 1, p_150094_4_) != this || (p_150094_1_.getBlockMetadata(p_150094_2_, p_150094_3_ + 1, p_150094_4_) & k1) == 0)) + { + i1 &= ~k1; + } + } + } + + if (i1 == 0 && !this.func_150093_a(p_150094_1_.getBlock(p_150094_2_, p_150094_3_ + 1, p_150094_4_))) + { + return false; + } + else + { + if (i1 != l) + { + p_150094_1_.setBlockMetadataWithNotify(p_150094_2_, p_150094_3_, p_150094_4_, i1, 2); + } + + return true; + } + } + + @SideOnly(Side.CLIENT) + public int getBlockColor() + { + return ColorizerFoliage.getFoliageColorBasic(); + } + + @SideOnly(Side.CLIENT) + public int getRenderColor(int p_149741_1_) + { + return ColorizerFoliage.getFoliageColorBasic(); + } + + @SideOnly(Side.CLIENT) + public int colorMultiplier(IBlockAccess p_149720_1_, int p_149720_2_, int p_149720_3_, int p_149720_4_) + { + return p_149720_1_.getBiomeGenForCoords(p_149720_2_, p_149720_4_).getBiomeFoliageColor(p_149720_2_, p_149720_3_, p_149720_4_); + } + + public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) + { + if (!p_149695_1_.isRemote && !this.func_150094_e(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_)) + { + this.dropBlockAsItem(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, p_149695_1_.getBlockMetadata(p_149695_2_, p_149695_3_, p_149695_4_), 0); + p_149695_1_.setBlockToAir(p_149695_2_, p_149695_3_, p_149695_4_); + } + } + + public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) + { + if (!p_149674_1_.isRemote && p_149674_1_.rand.nextInt(4) == 0) + { + byte b0 = 4; + int l = 5; + boolean flag = false; + int i1; + int j1; + int k1; + label134: + + for (i1 = p_149674_2_ - b0; i1 <= p_149674_2_ + b0; ++i1) + { + for (j1 = p_149674_4_ - b0; j1 <= p_149674_4_ + b0; ++j1) + { + for (k1 = p_149674_3_ - 1; k1 <= p_149674_3_ + 1; ++k1) + { + if (p_149674_1_.getBlock(i1, k1, j1) == this) + { + --l; + + if (l <= 0) + { + flag = true; + break label134; + } + } + } + } + } + + i1 = p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_); + j1 = p_149674_1_.rand.nextInt(6); + k1 = Direction.facingToDirection[j1]; + int l1; + + if (j1 == 1 && p_149674_3_ < 255 && p_149674_1_.isAirBlock(p_149674_2_, p_149674_3_ + 1, p_149674_4_)) + { + if (flag) + { + return; + } + + int j2 = p_149674_1_.rand.nextInt(16) & i1; + + if (j2 > 0) + { + for (l1 = 0; l1 <= 3; ++l1) + { + if (!this.func_150093_a(p_149674_1_.getBlock(p_149674_2_ + Direction.offsetX[l1], p_149674_3_ + 1, p_149674_4_ + Direction.offsetZ[l1]))) + { + j2 &= ~(1 << l1); + } + } + + if (j2 > 0) + { + p_149674_1_.setBlock(p_149674_2_, p_149674_3_ + 1, p_149674_4_, this, j2, 2); + } + } + } + else + { + Block block; + int i2; + + if (j1 >= 2 && j1 <= 5 && (i1 & 1 << k1) == 0) + { + if (flag) + { + return; + } + + block = p_149674_1_.getBlock(p_149674_2_ + Direction.offsetX[k1], p_149674_3_, p_149674_4_ + Direction.offsetZ[k1]); + + if (block.blockMaterial == Material.air) + { + l1 = k1 + 1 & 3; + i2 = k1 + 3 & 3; + + if ((i1 & 1 << l1) != 0 && this.func_150093_a(p_149674_1_.getBlock(p_149674_2_ + Direction.offsetX[k1] + Direction.offsetX[l1], p_149674_3_, p_149674_4_ + Direction.offsetZ[k1] + Direction.offsetZ[l1]))) + { + p_149674_1_.setBlock(p_149674_2_ + Direction.offsetX[k1], p_149674_3_, p_149674_4_ + Direction.offsetZ[k1], this, 1 << l1, 2); + } + else if ((i1 & 1 << i2) != 0 && this.func_150093_a(p_149674_1_.getBlock(p_149674_2_ + Direction.offsetX[k1] + Direction.offsetX[i2], p_149674_3_, p_149674_4_ + Direction.offsetZ[k1] + Direction.offsetZ[i2]))) + { + p_149674_1_.setBlock(p_149674_2_ + Direction.offsetX[k1], p_149674_3_, p_149674_4_ + Direction.offsetZ[k1], this, 1 << i2, 2); + } + else if ((i1 & 1 << l1) != 0 && p_149674_1_.isAirBlock(p_149674_2_ + Direction.offsetX[k1] + Direction.offsetX[l1], p_149674_3_, p_149674_4_ + Direction.offsetZ[k1] + Direction.offsetZ[l1]) && this.func_150093_a(p_149674_1_.getBlock(p_149674_2_ + Direction.offsetX[l1], p_149674_3_, p_149674_4_ + Direction.offsetZ[l1]))) + { + p_149674_1_.setBlock(p_149674_2_ + Direction.offsetX[k1] + Direction.offsetX[l1], p_149674_3_, p_149674_4_ + Direction.offsetZ[k1] + Direction.offsetZ[l1], this, 1 << (k1 + 2 & 3), 2); + } + else if ((i1 & 1 << i2) != 0 && p_149674_1_.isAirBlock(p_149674_2_ + Direction.offsetX[k1] + Direction.offsetX[i2], p_149674_3_, p_149674_4_ + Direction.offsetZ[k1] + Direction.offsetZ[i2]) && this.func_150093_a(p_149674_1_.getBlock(p_149674_2_ + Direction.offsetX[i2], p_149674_3_, p_149674_4_ + Direction.offsetZ[i2]))) + { + p_149674_1_.setBlock(p_149674_2_ + Direction.offsetX[k1] + Direction.offsetX[i2], p_149674_3_, p_149674_4_ + Direction.offsetZ[k1] + Direction.offsetZ[i2], this, 1 << (k1 + 2 & 3), 2); + } + else if (this.func_150093_a(p_149674_1_.getBlock(p_149674_2_ + Direction.offsetX[k1], p_149674_3_ + 1, p_149674_4_ + Direction.offsetZ[k1]))) + { + p_149674_1_.setBlock(p_149674_2_ + Direction.offsetX[k1], p_149674_3_, p_149674_4_ + Direction.offsetZ[k1], this, 0, 2); + } + } + else if (block.blockMaterial.isOpaque() && block.renderAsNormalBlock()) + { + p_149674_1_.setBlockMetadataWithNotify(p_149674_2_, p_149674_3_, p_149674_4_, i1 | 1 << k1, 2); + } + } + else if (p_149674_3_ > 1) + { + block = p_149674_1_.getBlock(p_149674_2_, p_149674_3_ - 1, p_149674_4_); + + if (block.blockMaterial == Material.air) + { + l1 = p_149674_1_.rand.nextInt(16) & i1; + + if (l1 > 0) + { + p_149674_1_.setBlock(p_149674_2_, p_149674_3_ - 1, p_149674_4_, this, l1, 2); + } + } + else if (block == this) + { + l1 = p_149674_1_.rand.nextInt(16) & i1; + i2 = p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_ - 1, p_149674_4_); + + if (i2 != (i2 | l1)) + { + p_149674_1_.setBlockMetadataWithNotify(p_149674_2_, p_149674_3_ - 1, p_149674_4_, i2 | l1, 2); + } + } + } + } + } + } + + public int onBlockPlaced(World p_149660_1_, int p_149660_2_, int p_149660_3_, int p_149660_4_, int p_149660_5_, float p_149660_6_, float p_149660_7_, float p_149660_8_, int p_149660_9_) + { + byte b0 = 0; + + switch (p_149660_5_) + { + case 2: + b0 = 1; + break; + case 3: + b0 = 4; + break; + case 4: + b0 = 8; + break; + case 5: + b0 = 2; + } + + return b0 != 0 ? b0 : p_149660_9_; + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return null; + } + + public int quantityDropped(Random p_149745_1_) + { + return 0; + } + + public void harvestBlock(World p_149636_1_, EntityPlayer p_149636_2_, int p_149636_3_, int p_149636_4_, int p_149636_5_, int p_149636_6_) + { + { + super.harvestBlock(p_149636_1_, p_149636_2_, p_149636_3_, p_149636_4_, p_149636_5_, p_149636_6_); + } + } + + @Override + public boolean isShearable(ItemStack item, IBlockAccess world, int x, int y, int z) + { + return true; + } + + @Override + public ArrayList onSheared(ItemStack item, IBlockAccess world, int x, int y, int z, int fortune) + { + ArrayList ret = new ArrayList(); + ret.add(new ItemStack(this, 1)); + return ret; + } + + @Override + public boolean isLadder(IBlockAccess world, int x, int y, int z, EntityLivingBase entity) + { + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockWall.java b/src/main/java/net/minecraft/block/BlockWall.java new file mode 100644 index 0000000..d9570b4 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockWall.java @@ -0,0 +1,138 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockWall extends Block +{ + public static final String[] field_150092_a = new String[] {"normal", "mossy"}; + private static final String __OBFID = "CL_00000331"; + + public BlockWall(Block p_i45435_1_) + { + super(p_i45435_1_.blockMaterial); + this.setHardness(p_i45435_1_.blockHardness); + this.setResistance(p_i45435_1_.blockResistance / 3.0F); + this.setStepSound(p_i45435_1_.stepSound); + this.setCreativeTab(CreativeTabs.tabBlock); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return p_149691_2_ == 1 ? Blocks.mossy_cobblestone.getBlockTextureFromSide(p_149691_1_) : Blocks.cobblestone.getBlockTextureFromSide(p_149691_1_); + } + + public int getRenderType() + { + return 32; + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public boolean getBlocksMovement(IBlockAccess p_149655_1_, int p_149655_2_, int p_149655_3_, int p_149655_4_) + { + return false; + } + + public boolean isOpaqueCube() + { + return false; + } + + public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) + { + boolean flag = this.canConnectWallTo(p_149719_1_, p_149719_2_, p_149719_3_, p_149719_4_ - 1); + boolean flag1 = this.canConnectWallTo(p_149719_1_, p_149719_2_, p_149719_3_, p_149719_4_ + 1); + boolean flag2 = this.canConnectWallTo(p_149719_1_, p_149719_2_ - 1, p_149719_3_, p_149719_4_); + boolean flag3 = this.canConnectWallTo(p_149719_1_, p_149719_2_ + 1, p_149719_3_, p_149719_4_); + float f = 0.25F; + float f1 = 0.75F; + float f2 = 0.25F; + float f3 = 0.75F; + float f4 = 1.0F; + + if (flag) + { + f2 = 0.0F; + } + + if (flag1) + { + f3 = 1.0F; + } + + if (flag2) + { + f = 0.0F; + } + + if (flag3) + { + f1 = 1.0F; + } + + if (flag && flag1 && !flag2 && !flag3) + { + f4 = 0.8125F; + f = 0.3125F; + f1 = 0.6875F; + } + else if (!flag && !flag1 && flag2 && flag3) + { + f4 = 0.8125F; + f2 = 0.3125F; + f3 = 0.6875F; + } + + this.setBlockBounds(f, 0.0F, f2, f1, f4, f3); + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) + { + this.setBlockBoundsBasedOnState(p_149668_1_, p_149668_2_, p_149668_3_, p_149668_4_); + this.maxY = 1.5D; + return super.getCollisionBoundingBoxFromPool(p_149668_1_, p_149668_2_, p_149668_3_, p_149668_4_); + } + + public boolean canConnectWallTo(IBlockAccess p_150091_1_, int p_150091_2_, int p_150091_3_, int p_150091_4_) + { + Block block = p_150091_1_.getBlock(p_150091_2_, p_150091_3_, p_150091_4_); + return block != this && block != Blocks.fence_gate ? (block.blockMaterial.isOpaque() && block.renderAsNormalBlock() ? block.blockMaterial != Material.gourd : false) : true; + } + + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_) + { + p_149666_3_.add(new ItemStack(p_149666_1_, 1, 0)); + p_149666_3_.add(new ItemStack(p_149666_1_, 1, 1)); + } + + public int damageDropped(int p_149692_1_) + { + return p_149692_1_; + } + + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) + { + return p_149646_5_ == 0 ? super.shouldSideBeRendered(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, p_149646_5_) : true; + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) {} +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockWeb.java b/src/main/java/net/minecraft/block/BlockWeb.java new file mode 100644 index 0000000..214886f --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockWeb.java @@ -0,0 +1,56 @@ +package net.minecraft.block; + +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; + +public class BlockWeb extends Block +{ + private static final String __OBFID = "CL_00000333"; + + public BlockWeb() + { + super(Material.web); + this.setCreativeTab(CreativeTabs.tabDecorations); + } + + public void onEntityCollidedWithBlock(World p_149670_1_, int p_149670_2_, int p_149670_3_, int p_149670_4_, Entity p_149670_5_) + { + p_149670_5_.setInWeb(); + } + + public boolean isOpaqueCube() + { + return false; + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) + { + return null; + } + + public int getRenderType() + { + return 1; + } + + public boolean renderAsNormalBlock() + { + return false; + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return Items.string; + } + + protected boolean canSilkHarvest() + { + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockWood.java b/src/main/java/net/minecraft/block/BlockWood.java new file mode 100644 index 0000000..016c201 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockWood.java @@ -0,0 +1,63 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +public class BlockWood extends Block +{ + public static final String[] field_150096_a = new String[] {"oak", "spruce", "birch", "jungle", "acacia", "big_oak"}; + @SideOnly(Side.CLIENT) + private IIcon[] field_150095_b; + private static final String __OBFID = "CL_00000335"; + + public BlockWood() + { + super(Material.wood); + this.setCreativeTab(CreativeTabs.tabBlock); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + if (p_149691_2_ < 0 || p_149691_2_ >= this.field_150095_b.length) + { + p_149691_2_ = 0; + } + + return this.field_150095_b[p_149691_2_]; + } + + public int damageDropped(int p_149692_1_) + { + return p_149692_1_; + } + + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_) + { + p_149666_3_.add(new ItemStack(p_149666_1_, 1, 0)); + p_149666_3_.add(new ItemStack(p_149666_1_, 1, 1)); + p_149666_3_.add(new ItemStack(p_149666_1_, 1, 2)); + p_149666_3_.add(new ItemStack(p_149666_1_, 1, 3)); + p_149666_3_.add(new ItemStack(p_149666_1_, 1, 4)); + p_149666_3_.add(new ItemStack(p_149666_1_, 1, 5)); + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.field_150095_b = new IIcon[field_150096_a.length]; + + for (int i = 0; i < this.field_150095_b.length; ++i) + { + this.field_150095_b[i] = p_149651_1_.registerIcon(this.getTextureName() + "_" + field_150096_a[i]); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockWoodSlab.java b/src/main/java/net/minecraft/block/BlockWoodSlab.java new file mode 100644 index 0000000..7c6f07f --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockWoodSlab.java @@ -0,0 +1,66 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +public class BlockWoodSlab extends BlockSlab +{ + public static final String[] field_150005_b = new String[] {"oak", "spruce", "birch", "jungle", "acacia", "big_oak"}; + private static final String __OBFID = "CL_00000337"; + + public BlockWoodSlab(boolean p_i45437_1_) + { + super(p_i45437_1_, Material.wood); + this.setCreativeTab(CreativeTabs.tabBlock); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return Blocks.planks.getIcon(p_149691_1_, p_149691_2_ & 7); + } + + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return Item.getItemFromBlock(Blocks.wooden_slab); + } + + protected ItemStack createStackedBlock(int p_149644_1_) + { + return new ItemStack(Item.getItemFromBlock(Blocks.wooden_slab), 2, p_149644_1_ & 7); + } + + public String func_150002_b(int p_150002_1_) + { + if (p_150002_1_ < 0 || p_150002_1_ >= field_150005_b.length) + { + p_150002_1_ = 0; + } + + return super.getUnlocalizedName() + "." + field_150005_b[p_150002_1_]; + } + + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_) + { + if (p_149666_1_ != Item.getItemFromBlock(Blocks.double_wooden_slab)) + { + for (int i = 0; i < field_150005_b.length; ++i) + { + p_149666_3_.add(new ItemStack(p_149666_1_, 1, i)); + } + } + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) {} +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/BlockWorkbench.java b/src/main/java/net/minecraft/block/BlockWorkbench.java new file mode 100644 index 0000000..390b384 --- /dev/null +++ b/src/main/java/net/minecraft/block/BlockWorkbench.java @@ -0,0 +1,53 @@ +package net.minecraft.block; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +public class BlockWorkbench extends Block +{ + @SideOnly(Side.CLIENT) + private IIcon field_150035_a; + @SideOnly(Side.CLIENT) + private IIcon field_150034_b; + private static final String __OBFID = "CL_00000221"; + + protected BlockWorkbench() + { + super(Material.wood); + this.setCreativeTab(CreativeTabs.tabDecorations); + } + + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) + { + return p_149691_1_ == 1 ? this.field_150035_a : (p_149691_1_ == 0 ? Blocks.planks.getBlockTextureFromSide(p_149691_1_) : (p_149691_1_ != 2 && p_149691_1_ != 4 ? this.blockIcon : this.field_150034_b)); + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) + { + this.blockIcon = p_149651_1_.registerIcon(this.getTextureName() + "_side"); + this.field_150035_a = p_149651_1_.registerIcon(this.getTextureName() + "_top"); + this.field_150034_b = p_149651_1_.registerIcon(this.getTextureName() + "_front"); + } + + public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) + { + if (p_149727_1_.isRemote) + { + return true; + } + else + { + p_149727_5_.displayGUIWorkbench(p_149727_2_, p_149727_3_, p_149727_4_); + return true; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/IGrowable.java b/src/main/java/net/minecraft/block/IGrowable.java new file mode 100644 index 0000000..8c8079e --- /dev/null +++ b/src/main/java/net/minecraft/block/IGrowable.java @@ -0,0 +1,13 @@ +package net.minecraft.block; + +import java.util.Random; +import net.minecraft.world.World; + +public interface IGrowable +{ + boolean func_149851_a(World var1, int var2, int var3, int var4, boolean var5); + + boolean func_149852_a(World var1, Random var2, int var3, int var4, int var5); + + void func_149853_b(World var1, Random var2, int var3, int var4, int var5); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/ITileEntityProvider.java b/src/main/java/net/minecraft/block/ITileEntityProvider.java new file mode 100644 index 0000000..72b5709 --- /dev/null +++ b/src/main/java/net/minecraft/block/ITileEntityProvider.java @@ -0,0 +1,9 @@ +package net.minecraft.block; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +public interface ITileEntityProvider +{ + TileEntity createNewTileEntity(World var1, int var2); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/material/MapColor.java b/src/main/java/net/minecraft/block/material/MapColor.java new file mode 100644 index 0000000..4e07467 --- /dev/null +++ b/src/main/java/net/minecraft/block/material/MapColor.java @@ -0,0 +1,135 @@ +package net.minecraft.block.material; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.BlockColored; + +public class MapColor +{ + public static final MapColor[] mapColorArray = new MapColor[64]; + public static final MapColor airColor = new MapColor(0, 0); + public static final MapColor grassColor = new MapColor(1, 8368696); + public static final MapColor sandColor = new MapColor(2, 16247203); + public static final MapColor clothColor = new MapColor(3, 10987431); + public static final MapColor tntColor = new MapColor(4, 16711680); + public static final MapColor iceColor = new MapColor(5, 10526975); + public static final MapColor ironColor = new MapColor(6, 10987431); + public static final MapColor foliageColor = new MapColor(7, 31744); + public static final MapColor snowColor = new MapColor(8, 16777215); + public static final MapColor clayColor = new MapColor(9, 10791096); + public static final MapColor dirtColor = new MapColor(10, 12020271); + public static final MapColor stoneColor = new MapColor(11, 7368816); + public static final MapColor waterColor = new MapColor(12, 4210943); + public static final MapColor woodColor = new MapColor(13, 6837042); + public static final MapColor quartzColor = new MapColor(14, 16776437); + public static final MapColor adobeColor = new MapColor(15, 14188339); + public static final MapColor magentaColor = new MapColor(16, 11685080); + public static final MapColor lightBlueColor = new MapColor(17, 6724056); + public static final MapColor yellowColor = new MapColor(18, 15066419); + public static final MapColor limeColor = new MapColor(19, 8375321); + public static final MapColor pinkColor = new MapColor(20, 15892389); + public static final MapColor grayColor = new MapColor(21, 5000268); + public static final MapColor silverColor = new MapColor(22, 10066329); + public static final MapColor cyanColor = new MapColor(23, 5013401); + public static final MapColor purpleColor = new MapColor(24, 8339378); + public static final MapColor blueColor = new MapColor(25, 3361970); + public static final MapColor brownColor = new MapColor(26, 6704179); + public static final MapColor greenColor = new MapColor(27, 6717235); + public static final MapColor redColor = new MapColor(28, 10040115); + public static final MapColor blackColor = new MapColor(29, 1644825); + public static final MapColor goldColor = new MapColor(30, 16445005); + public static final MapColor diamondColor = new MapColor(31, 6085589); + public static final MapColor lapisColor = new MapColor(32, 4882687); + public static final MapColor emeraldColor = new MapColor(33, 55610); + public static final MapColor obsidianColor = new MapColor(34, 1381407); + public static final MapColor netherrackColor = new MapColor(35, 7340544); + public final int colorValue; + public final int colorIndex; + private static final String __OBFID = "CL_00000544"; + + private MapColor(int par1, int par2) + { + if (par1 >= 0 && par1 <= 63) + { + this.colorIndex = par1; + this.colorValue = par2; + mapColorArray[par1] = this; + } + else + { + throw new IndexOutOfBoundsException("Map colour ID must be between 0 and 63 (inclusive)"); + } + } + + public static MapColor getMapColorForBlockColored(int p_151644_0_) + { + switch (BlockColored.func_150031_c(p_151644_0_)) + { + case 0: + return blackColor; + case 1: + return redColor; + case 2: + return greenColor; + case 3: + return brownColor; + case 4: + return blueColor; + case 5: + return purpleColor; + case 6: + return cyanColor; + case 7: + return silverColor; + case 8: + return grayColor; + case 9: + return pinkColor; + case 10: + return limeColor; + case 11: + return yellowColor; + case 12: + return lightBlueColor; + case 13: + return magentaColor; + case 14: + return adobeColor; + case 15: + return snowColor; + default: + return airColor; + } + } + + @SideOnly(Side.CLIENT) + public int func_151643_b(int p_151643_1_) + { + short short1 = 220; + + if (p_151643_1_ == 3) + { + short1 = 135; + } + + if (p_151643_1_ == 2) + { + short1 = 255; + } + + if (p_151643_1_ == 1) + { + short1 = 220; + } + + if (p_151643_1_ == 0) + { + short1 = 180; + } + + int j = (this.colorValue >> 16 & 255) * short1 / 255; + int k = (this.colorValue >> 8 & 255) * short1 / 255; + int l = (this.colorValue & 255) * short1 / 255; + return -16777216 | j << 16 | k << 8 | l; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/material/Material.java b/src/main/java/net/minecraft/block/material/Material.java new file mode 100644 index 0000000..8c4fbee --- /dev/null +++ b/src/main/java/net/minecraft/block/material/Material.java @@ -0,0 +1,156 @@ +package net.minecraft.block.material; + +public class Material +{ + public static final Material air = new MaterialTransparent(MapColor.airColor); + public static final Material grass = new Material(MapColor.grassColor); + public static final Material ground = new Material(MapColor.dirtColor); + public static final Material wood = (new Material(MapColor.woodColor)).setBurning(); + public static final Material rock = (new Material(MapColor.stoneColor)).setRequiresTool(); + public static final Material iron = (new Material(MapColor.ironColor)).setRequiresTool(); + public static final Material anvil = (new Material(MapColor.ironColor)).setRequiresTool().setImmovableMobility(); + public static final Material water = (new MaterialLiquid(MapColor.waterColor)).setNoPushMobility(); + public static final Material lava = (new MaterialLiquid(MapColor.tntColor)).setNoPushMobility(); + public static final Material leaves = (new Material(MapColor.foliageColor)).setBurning().setTranslucent().setNoPushMobility(); + public static final Material plants = (new MaterialLogic(MapColor.foliageColor)).setNoPushMobility(); + public static final Material vine = (new MaterialLogic(MapColor.foliageColor)).setBurning().setNoPushMobility().setReplaceable(); + public static final Material sponge = new Material(MapColor.clothColor); + public static final Material cloth = (new Material(MapColor.clothColor)).setBurning(); + public static final Material fire = (new MaterialTransparent(MapColor.airColor)).setNoPushMobility(); + public static final Material sand = new Material(MapColor.sandColor); + public static final Material circuits = (new MaterialLogic(MapColor.airColor)).setNoPushMobility(); + public static final Material carpet = (new MaterialLogic(MapColor.clothColor)).setBurning(); + public static final Material glass = (new Material(MapColor.airColor)).setTranslucent().setAdventureModeExempt(); + public static final Material redstoneLight = (new Material(MapColor.airColor)).setAdventureModeExempt(); + public static final Material tnt = (new Material(MapColor.tntColor)).setBurning().setTranslucent(); + public static final Material coral = (new Material(MapColor.foliageColor)).setNoPushMobility(); + public static final Material ice = (new Material(MapColor.iceColor)).setTranslucent().setAdventureModeExempt(); + public static final Material packedIce = (new Material(MapColor.iceColor)).setAdventureModeExempt(); + public static final Material snow = (new MaterialLogic(MapColor.snowColor)).setReplaceable().setTranslucent().setRequiresTool().setNoPushMobility(); + public static final Material craftedSnow = (new Material(MapColor.snowColor)).setRequiresTool(); + public static final Material cactus = (new Material(MapColor.foliageColor)).setTranslucent().setNoPushMobility(); + public static final Material clay = new Material(MapColor.clayColor); + public static final Material gourd = (new Material(MapColor.foliageColor)).setNoPushMobility(); + public static final Material dragonEgg = (new Material(MapColor.foliageColor)).setNoPushMobility(); + public static final Material portal = (new MaterialPortal(MapColor.airColor)).setImmovableMobility(); + public static final Material cake = (new Material(MapColor.airColor)).setNoPushMobility(); + public static final Material web = (new Material(MapColor.clothColor) + { + private static final String __OBFID = "CL_00000543"; + public boolean blocksMovement() + { + return false; + } + }).setRequiresTool().setNoPushMobility(); + public static final Material piston = (new Material(MapColor.stoneColor)).setImmovableMobility(); + private boolean canBurn; + private boolean replaceable; + private boolean isTranslucent; + private final MapColor materialMapColor; + private boolean requiresNoTool = true; + private int mobilityFlag; + private boolean isAdventureModeExempt; + private static final String __OBFID = "CL_00000542"; + + public Material(MapColor par1MapColor) + { + this.materialMapColor = par1MapColor; + } + + public boolean isLiquid() + { + return false; + } + + public boolean isSolid() + { + return true; + } + + public boolean getCanBlockGrass() + { + return true; + } + + public boolean blocksMovement() + { + return true; + } + + private Material setTranslucent() + { + this.isTranslucent = true; + return this; + } + + protected Material setRequiresTool() + { + this.requiresNoTool = false; + return this; + } + + protected Material setBurning() + { + this.canBurn = true; + return this; + } + + public boolean getCanBurn() + { + return this.canBurn; + } + + public Material setReplaceable() + { + this.replaceable = true; + return this; + } + + public boolean isReplaceable() + { + return this.replaceable; + } + + public boolean isOpaque() + { + return this.isTranslucent ? false : this.blocksMovement(); + } + + public boolean isToolNotRequired() + { + return this.requiresNoTool; + } + + public int getMaterialMobility() + { + return this.mobilityFlag; + } + + protected Material setNoPushMobility() + { + this.mobilityFlag = 1; + return this; + } + + protected Material setImmovableMobility() + { + this.mobilityFlag = 2; + return this; + } + + protected Material setAdventureModeExempt() + { + this.isAdventureModeExempt = true; + return this; + } + + public boolean isAdventureModeExempt() + { + return this.isAdventureModeExempt; + } + + public MapColor getMaterialMapColor() + { + return this.materialMapColor; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/material/MaterialLiquid.java b/src/main/java/net/minecraft/block/material/MaterialLiquid.java new file mode 100644 index 0000000..810b5e1 --- /dev/null +++ b/src/main/java/net/minecraft/block/material/MaterialLiquid.java @@ -0,0 +1,28 @@ +package net.minecraft.block.material; + +public class MaterialLiquid extends Material +{ + private static final String __OBFID = "CL_00000541"; + + public MaterialLiquid(MapColor par1MapColor) + { + super(par1MapColor); + this.setReplaceable(); + this.setNoPushMobility(); + } + + public boolean isLiquid() + { + return true; + } + + public boolean blocksMovement() + { + return false; + } + + public boolean isSolid() + { + return false; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/material/MaterialLogic.java b/src/main/java/net/minecraft/block/material/MaterialLogic.java new file mode 100644 index 0000000..6544a82 --- /dev/null +++ b/src/main/java/net/minecraft/block/material/MaterialLogic.java @@ -0,0 +1,27 @@ +package net.minecraft.block.material; + +public class MaterialLogic extends Material +{ + private static final String __OBFID = "CL_00000539"; + + public MaterialLogic(MapColor par1MapColor) + { + super(par1MapColor); + this.setAdventureModeExempt(); + } + + public boolean isSolid() + { + return false; + } + + public boolean getCanBlockGrass() + { + return false; + } + + public boolean blocksMovement() + { + return false; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/material/MaterialPortal.java b/src/main/java/net/minecraft/block/material/MaterialPortal.java new file mode 100644 index 0000000..60e9ab3 --- /dev/null +++ b/src/main/java/net/minecraft/block/material/MaterialPortal.java @@ -0,0 +1,26 @@ +package net.minecraft.block.material; + +public class MaterialPortal extends Material +{ + private static final String __OBFID = "CL_00000545"; + + public MaterialPortal(MapColor par1MapColor) + { + super(par1MapColor); + } + + public boolean isSolid() + { + return false; + } + + public boolean getCanBlockGrass() + { + return false; + } + + public boolean blocksMovement() + { + return false; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/block/material/MaterialTransparent.java b/src/main/java/net/minecraft/block/material/MaterialTransparent.java new file mode 100644 index 0000000..a13cc63 --- /dev/null +++ b/src/main/java/net/minecraft/block/material/MaterialTransparent.java @@ -0,0 +1,27 @@ +package net.minecraft.block.material; + +public class MaterialTransparent extends Material +{ + private static final String __OBFID = "CL_00000540"; + + public MaterialTransparent(MapColor par1MapColor) + { + super(par1MapColor); + this.setReplaceable(); + } + + public boolean isSolid() + { + return false; + } + + public boolean getCanBlockGrass() + { + return false; + } + + public boolean blocksMovement() + { + return false; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/AnvilConverterException.java b/src/main/java/net/minecraft/client/AnvilConverterException.java new file mode 100644 index 0000000..d46a689 --- /dev/null +++ b/src/main/java/net/minecraft/client/AnvilConverterException.java @@ -0,0 +1,15 @@ +package net.minecraft.client; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class AnvilConverterException extends Exception +{ + private static final String __OBFID = "CL_00000599"; + + public AnvilConverterException(String par1Str) + { + super(par1Str); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/ClientBrandRetriever.java b/src/main/java/net/minecraft/client/ClientBrandRetriever.java new file mode 100644 index 0000000..974cdc6 --- /dev/null +++ b/src/main/java/net/minecraft/client/ClientBrandRetriever.java @@ -0,0 +1,16 @@ +package net.minecraft.client; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class ClientBrandRetriever +{ + private static final String __OBFID = "CL_00001460"; + + public static String getClientModName() + { + return FMLCommonHandler.instance().getModName(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/LoadingScreenRenderer.java b/src/main/java/net/minecraft/client/LoadingScreenRenderer.java new file mode 100644 index 0000000..1d2f623 --- /dev/null +++ b/src/main/java/net/minecraft/client/LoadingScreenRenderer.java @@ -0,0 +1,213 @@ +package net.minecraft.client; + +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.shader.Framebuffer; +import net.minecraft.util.IProgressUpdate; +import net.minecraft.util.MinecraftError; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class LoadingScreenRenderer implements IProgressUpdate +{ + private String field_73727_a = ""; + private Minecraft mc; + private String currentlyDisplayedText = ""; + private long field_73723_d = Minecraft.getSystemTime(); + private boolean field_73724_e; + private ScaledResolution field_146587_f; + private Framebuffer field_146588_g; + private static final String __OBFID = "CL_00000655"; + + public LoadingScreenRenderer(Minecraft par1Minecraft) + { + this.mc = par1Minecraft; + this.field_146587_f = new ScaledResolution(par1Minecraft.gameSettings, par1Minecraft.displayWidth, par1Minecraft.displayHeight); + this.field_146588_g = new Framebuffer(this.field_146587_f.getScaledWidth(), this.field_146587_f.getScaledHeight(), false); + this.field_146588_g.setFramebufferFilter(9728); + } + + public void resetProgressAndMessage(String par1Str) + { + this.field_73724_e = false; + this.func_73722_d(par1Str); + } + + public void displayProgressMessage(String par1Str) + { + this.field_73724_e = true; + this.func_73722_d(par1Str); + } + + public void func_73722_d(String par1Str) + { + this.currentlyDisplayedText = par1Str; + + if (!this.mc.running) + { + if (!this.field_73724_e) + { + throw new MinecraftError(); + } + } + else + { + GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + + if (OpenGlHelper.isFramebufferEnabled()) + { + int i = this.field_146587_f.getScaleFactor(); + GL11.glOrtho(0.0D, (double)(this.field_146587_f.getScaledWidth() * i), (double)(this.field_146587_f.getScaledHeight() * i), 0.0D, 100.0D, 300.0D); + } + else + { + ScaledResolution scaledresolution = new ScaledResolution(this.mc.gameSettings, this.mc.displayWidth, this.mc.displayHeight); + GL11.glOrtho(0.0D, scaledresolution.getScaledWidth_double(), scaledresolution.getScaledHeight_double(), 0.0D, 100.0D, 300.0D); + } + + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + GL11.glTranslatef(0.0F, 0.0F, -200.0F); + } + } + + public void resetProgresAndWorkingMessage(String par1Str) + { + if (!this.mc.running) + { + if (!this.field_73724_e) + { + throw new MinecraftError(); + } + } + else + { + this.field_73723_d = 0L; + this.field_73727_a = par1Str; + this.setLoadingProgress(-1); + this.field_73723_d = 0L; + } + } + + public void setLoadingProgress(int par1) + { + if (!this.mc.running) + { + if (!this.field_73724_e) + { + throw new MinecraftError(); + } + } + else + { + long j = Minecraft.getSystemTime(); + + if (j - this.field_73723_d >= 100L) + { + this.field_73723_d = j; + ScaledResolution scaledresolution = new ScaledResolution(this.mc.gameSettings, this.mc.displayWidth, this.mc.displayHeight); + int k = scaledresolution.getScaleFactor(); + int l = scaledresolution.getScaledWidth(); + int i1 = scaledresolution.getScaledHeight(); + + if (OpenGlHelper.isFramebufferEnabled()) + { + this.field_146588_g.framebufferClear(); + } + else + { + GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); + } + + this.field_146588_g.bindFramebuffer(true); + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + + if (OpenGlHelper.isFramebufferEnabled()) + { + GL11.glOrtho(0.0D, (double)l, (double)i1, 0.0D, 100.0D, 300.0D); + } + else + { + GL11.glOrtho(0.0D, scaledresolution.getScaledWidth_double(), scaledresolution.getScaledHeight_double(), 0.0D, 100.0D, 300.0D); + } + + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + GL11.glTranslatef(0.0F, 0.0F, -200.0F); + + if (!OpenGlHelper.isFramebufferEnabled()) + { + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); + } + + if (!FMLClientHandler.instance().handleLoadingScreen(scaledresolution)) + { + Tessellator tessellator = Tessellator.instance; + this.mc.getTextureManager().bindTexture(Gui.optionsBackground); + float f = 32.0F; + tessellator.startDrawingQuads(); + tessellator.setColorOpaque_I(4210752); + tessellator.addVertexWithUV(0.0D, (double)i1, 0.0D, 0.0D, (double)((float)i1 / f)); + tessellator.addVertexWithUV((double)l, (double)i1, 0.0D, (double)((float)l / f), (double)((float)i1 / f)); + tessellator.addVertexWithUV((double)l, 0.0D, 0.0D, (double)((float)l / f), 0.0D); + tessellator.addVertexWithUV(0.0D, 0.0D, 0.0D, 0.0D, 0.0D); + tessellator.draw(); + + if (par1 >= 0) + { + byte b0 = 100; + byte b1 = 2; + int j1 = l / 2 - b0 / 2; + int k1 = i1 / 2 + 16; + GL11.glDisable(GL11.GL_TEXTURE_2D); + tessellator.startDrawingQuads(); + tessellator.setColorOpaque_I(8421504); + tessellator.addVertex((double)j1, (double)k1, 0.0D); + tessellator.addVertex((double)j1, (double)(k1 + b1), 0.0D); + tessellator.addVertex((double)(j1 + b0), (double)(k1 + b1), 0.0D); + tessellator.addVertex((double)(j1 + b0), (double)k1, 0.0D); + tessellator.setColorOpaque_I(8454016); + tessellator.addVertex((double)j1, (double)k1, 0.0D); + tessellator.addVertex((double)j1, (double)(k1 + b1), 0.0D); + tessellator.addVertex((double)(j1 + par1), (double)(k1 + b1), 0.0D); + tessellator.addVertex((double)(j1 + par1), (double)k1, 0.0D); + tessellator.draw(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + this.mc.fontRenderer.drawStringWithShadow(this.currentlyDisplayedText, (l - this.mc.fontRenderer.getStringWidth(this.currentlyDisplayedText)) / 2, i1 / 2 - 4 - 16, 16777215); + this.mc.fontRenderer.drawStringWithShadow(this.field_73727_a, (l - this.mc.fontRenderer.getStringWidth(this.field_73727_a)) / 2, i1 / 2 - 4 + 8, 16777215); + } + this.field_146588_g.unbindFramebuffer(); + + if (OpenGlHelper.isFramebufferEnabled()) + { + this.field_146588_g.framebufferRender(l * k, i1 * k); + } + + this.mc.func_147120_f(); + + try + { + Thread.yield(); + } + catch (Exception exception) + { + ; + } + } + } + } + + public void func_146586_a() {} +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/Minecraft.java b/src/main/java/net/minecraft/client/Minecraft.java new file mode 100644 index 0000000..03e3cfb --- /dev/null +++ b/src/main/java/net/minecraft/client/Minecraft.java @@ -0,0 +1,2612 @@ +package net.minecraft.client; + +import com.google.common.collect.Lists; + +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.StartupQuery; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.util.concurrent.GenericFutureListener; +import java.awt.Toolkit; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Field; +import java.net.Proxy; +import java.net.SocketAddress; +import java.nio.ByteBuffer; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.concurrent.Callable; +import javax.imageio.ImageIO; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.audio.MusicTicker; +import net.minecraft.client.audio.SoundHandler; +import net.minecraft.client.entity.EntityClientPlayerMP; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.GuiChat; +import net.minecraft.client.gui.GuiGameOver; +import net.minecraft.client.gui.GuiIngame; +import net.minecraft.client.gui.GuiIngameMenu; +import net.minecraft.client.gui.GuiMainMenu; +import net.minecraft.client.gui.GuiMemoryErrorScreen; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.GuiSleepMP; +import net.minecraft.client.gui.GuiWinGame; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.gui.achievement.GuiAchievement; +import net.minecraft.client.gui.inventory.GuiInventory; +import net.minecraft.client.multiplayer.GuiConnecting; +import net.minecraft.client.multiplayer.PlayerControllerMP; +import net.minecraft.client.multiplayer.ServerData; +import net.minecraft.client.multiplayer.WorldClient; +import net.minecraft.client.network.NetHandlerLoginClient; +import net.minecraft.client.network.NetHandlerPlayClient; +import net.minecraft.client.particle.EffectRenderer; +import net.minecraft.client.renderer.EntityRenderer; +import net.minecraft.client.renderer.GLAllocation; +import net.minecraft.client.renderer.ItemRenderer; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.RenderGlobal; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.client.resources.DefaultResourcePack; +import net.minecraft.client.resources.FoliageColorReloadListener; +import net.minecraft.client.resources.GrassColorReloadListener; +import net.minecraft.client.resources.I18n; +import net.minecraft.client.resources.IReloadableResourceManager; +import net.minecraft.client.resources.IResourceManager; +import net.minecraft.client.resources.LanguageManager; +import net.minecraft.client.resources.ResourcePackRepository; +import net.minecraft.client.resources.SimpleReloadableResourceManager; +import net.minecraft.client.resources.data.AnimationMetadataSection; +import net.minecraft.client.resources.data.AnimationMetadataSectionSerializer; +import net.minecraft.client.resources.data.FontMetadataSection; +import net.minecraft.client.resources.data.FontMetadataSectionSerializer; +import net.minecraft.client.resources.data.IMetadataSerializer; +import net.minecraft.client.resources.data.LanguageMetadataSection; +import net.minecraft.client.resources.data.LanguageMetadataSectionSerializer; +import net.minecraft.client.resources.data.PackMetadataSection; +import net.minecraft.client.resources.data.PackMetadataSectionSerializer; +import net.minecraft.client.resources.data.TextureMetadataSection; +import net.minecraft.client.resources.data.TextureMetadataSectionSerializer; +import net.minecraft.client.settings.GameSettings; +import net.minecraft.client.settings.KeyBinding; +import net.minecraft.client.shader.Framebuffer; +import net.minecraft.crash.CrashReport; +import net.minecraft.crash.CrashReportCategory; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLeashKnot; +import net.minecraft.entity.EntityList; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.boss.BossStatus; +import net.minecraft.entity.item.EntityBoat; +import net.minecraft.entity.item.EntityItemFrame; +import net.minecraft.entity.item.EntityMinecart; +import net.minecraft.entity.item.EntityPainting; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Bootstrap; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.network.EnumConnectionState; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.handshake.client.C00Handshake; +import net.minecraft.network.login.client.C00PacketLoginStart; +import net.minecraft.network.play.client.C16PacketClientStatus; +import net.minecraft.profiler.IPlayerUsage; +import net.minecraft.profiler.PlayerUsageSnooper; +import net.minecraft.profiler.Profiler; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.integrated.IntegratedServer; +import net.minecraft.stats.AchievementList; +import net.minecraft.stats.IStatStringFormat; +import net.minecraft.stats.StatFileWriter; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MinecraftError; +import net.minecraft.util.MouseHelper; +import net.minecraft.util.MovementInputFromOptions; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.ReportedException; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.ScreenShotHelper; +import net.minecraft.util.Session; +import net.minecraft.util.Timer; +import net.minecraft.util.Util; +import net.minecraft.world.EnumDifficulty; +import net.minecraft.world.WorldProviderEnd; +import net.minecraft.world.WorldProviderHell; +import net.minecraft.world.WorldSettings; +import net.minecraft.world.chunk.storage.AnvilSaveConverter; +import net.minecraft.world.storage.ISaveFormat; +import net.minecraft.world.storage.ISaveHandler; +import net.minecraft.world.storage.WorldInfo; +import net.minecraftforge.client.ForgeHooksClient; +import net.minecraftforge.client.GuiIngameForge; +import net.minecraftforge.client.event.GuiOpenEvent; +import net.minecraftforge.common.ForgeHooks; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.ForgeEventFactory; +import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action; +import net.minecraftforge.event.world.WorldEvent; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.lwjgl.LWJGLException; +import org.lwjgl.Sys; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.ContextCapabilities; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.DisplayMode; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL20; +import org.lwjgl.opengl.GLContext; +import org.lwjgl.opengl.PixelFormat; +import org.lwjgl.util.glu.GLU; + +import com.google.common.collect.MapDifference; + +@SideOnly(Side.CLIENT) +public class Minecraft implements IPlayerUsage +{ + private static final Logger logger = LogManager.getLogger(); + private static final ResourceLocation locationMojangPng = new ResourceLocation("textures/gui/title/mojang.png"); + public static final boolean isRunningOnMac = Util.getOSType() == Util.EnumOS.MACOS; + public static byte[] memoryReserve = new byte[10485760]; + private static final List macDisplayModes = Lists.newArrayList(new DisplayMode[] {new DisplayMode(2560, 1600), new DisplayMode(2880, 1800)}); + private final File fileResourcepacks; + private ServerData currentServerData; + public TextureManager renderEngine; + private static Minecraft theMinecraft; + public PlayerControllerMP playerController; + private boolean fullscreen; + private boolean hasCrashed; + private CrashReport crashReporter; + public int displayWidth; + public int displayHeight; + private Timer timer = new Timer(20.0F); + private PlayerUsageSnooper usageSnooper = new PlayerUsageSnooper("client", this, MinecraftServer.getSystemTimeMillis()); + public WorldClient theWorld; + public RenderGlobal renderGlobal; + public EntityClientPlayerMP thePlayer; + public EntityLivingBase renderViewEntity; + public Entity pointedEntity; + public EffectRenderer effectRenderer; + private final Session session; + private boolean isGamePaused; + public FontRenderer fontRenderer; + public FontRenderer standardGalacticFontRenderer; + public GuiScreen currentScreen; + public LoadingScreenRenderer loadingScreen; + public EntityRenderer entityRenderer; + private int leftClickCounter; + private int tempDisplayWidth; + private int tempDisplayHeight; + private IntegratedServer theIntegratedServer; + public GuiAchievement guiAchievement; + public GuiIngame ingameGUI; + public boolean skipRenderWorld; + public MovingObjectPosition objectMouseOver; + public GameSettings gameSettings; + public MouseHelper mouseHelper; + public final File mcDataDir; + private final File fileAssets; + private final String launchedVersion; + private final Proxy proxy; + private ISaveFormat saveLoader; + private static int debugFPS; + private int rightClickDelayTimer; + private boolean refreshTexturePacksScheduled; + private String serverName; + private int serverPort; + boolean isTakingScreenshot; + public boolean inGameHasFocus; + long systemTime = getSystemTime(); + private int joinPlayerCounter; + private final boolean jvm64bit; + private final boolean isDemo; + private NetworkManager myNetworkManager; + private boolean integratedServerIsRunning; + public final Profiler mcProfiler = new Profiler(); + private long field_83002_am = -1L; + private IReloadableResourceManager mcResourceManager; + private final IMetadataSerializer metadataSerializer_ = new IMetadataSerializer(); + private List defaultResourcePacks = Lists.newArrayList(); + private DefaultResourcePack mcDefaultResourcePack; + private ResourcePackRepository mcResourcePackRepository; + private LanguageManager mcLanguageManager; + private Framebuffer framebufferMc; + private TextureMap textureMapBlocks; + private SoundHandler mcSoundHandler; + private MusicTicker mcMusicTicker; + volatile boolean running = true; + public String debug = ""; + long debugUpdateTime = getSystemTime(); + int fpsCounter; + long prevFrameTime = -1L; + private String debugProfilerName = "root"; + private static final String __OBFID = "CL_00000631"; + + public Minecraft(Session par1Session, int par2, int par3, boolean par4, boolean par5, File par6File, File par7File, File par8File, Proxy par9Proxy, String par10Str) + { + theMinecraft = this; + this.mcDataDir = par6File; + this.fileAssets = par7File; + this.fileResourcepacks = par8File; + this.launchedVersion = par10Str; + this.mcDefaultResourcePack = new DefaultResourcePack(this.fileAssets); + this.addDefaultResourcePack(); + this.proxy = par9Proxy == null ? Proxy.NO_PROXY : par9Proxy; + this.startTimerHackThread(); + this.session = par1Session; + logger.info("Setting user: " + par1Session.getUsername()); + //logger.info("(Session ID is " + par1Session.getSessionID() + ")"); //don't print the session to the console.. that's stupid... + this.isDemo = par5; + this.displayWidth = par2; + this.displayHeight = par3; + this.tempDisplayWidth = par2; + this.tempDisplayHeight = par3; + this.fullscreen = par4; + this.jvm64bit = isJvm64bit(); + ImageIO.setUseCache(false); + Bootstrap.func_151354_b(); + } + + private static boolean isJvm64bit() + { + String[] astring = new String[] {"sun.arch.data.model", "com.ibm.vm.bitmode", "os.arch"}; + String[] astring1 = astring; + int i = astring.length; + + for (int j = 0; j < i; ++j) + { + String s = astring1[j]; + String s1 = System.getProperty(s); + + if (s1 != null && s1.contains("64")) + { + return true; + } + } + + return false; + } + + public static void func_147105_a(String p_147105_0_) + { + try + { + Toolkit toolkit = Toolkit.getDefaultToolkit(); + Class oclass = toolkit.getClass(); + + if (oclass.getName().equals("sun.awt.X11.XToolkit")) + { + Field field = oclass.getDeclaredField("awtAppClassName"); + field.setAccessible(true); + field.set(toolkit, p_147105_0_); + } + } + catch (Exception exception) + { + ; + } + } + + public Framebuffer getFramebuffer() + { + return this.framebufferMc; + } + + private void startTimerHackThread() + { + Thread thread = new Thread("Timer hack thread") + { + private static final String __OBFID = "CL_00000632"; + public void run() + { + while (Minecraft.this.running) + { + try + { + Thread.sleep(2147483647L); + } + catch (InterruptedException interruptedexception) + { + ; + } + } + } + }; + thread.setDaemon(true); + thread.start(); + } + + public void crashed(CrashReport par1CrashReport) + { + this.hasCrashed = true; + this.crashReporter = par1CrashReport; + } + + public void displayCrashReport(CrashReport par1CrashReport) + { + File file1 = new File(getMinecraft().mcDataDir, "crash-reports"); + File file2 = new File(file1, "crash-" + (new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss")).format(new Date()) + "-client.txt"); + System.out.println(par1CrashReport.getCompleteReport()); + + if (par1CrashReport.getFile() != null) + { + System.out.println("#@!@# Game crashed! Crash report saved to: #@!@# " + par1CrashReport.getFile()); + System.exit(-1); + } + else if (par1CrashReport.saveToFile(file2)) + { + System.out.println("#@!@# Game crashed! Crash report saved to: #@!@# " + file2.getAbsolutePath()); + System.exit(-1); + } + else + { + System.out.println("#@?@# Game crashed! Crash report could not be saved. #@?@#"); + System.exit(-2); + } + } + + public void setServer(String par1Str, int par2) + { + this.serverName = par1Str; + this.serverPort = par2; + } + + private void startGame() throws LWJGLException + { + this.gameSettings = new GameSettings(this, this.mcDataDir); + + if (this.gameSettings.overrideHeight > 0 && this.gameSettings.overrideWidth > 0) + { + this.displayWidth = this.gameSettings.overrideWidth; + this.displayHeight = this.gameSettings.overrideHeight; + } + + if (this.fullscreen) + { + Display.setFullscreen(true); + this.displayWidth = Display.getDisplayMode().getWidth(); + this.displayHeight = Display.getDisplayMode().getHeight(); + + if (this.displayWidth <= 0) + { + this.displayWidth = 1; + } + + if (this.displayHeight <= 0) + { + this.displayHeight = 1; + } + } + else + { + Display.setDisplayMode(new DisplayMode(this.displayWidth, this.displayHeight)); + } + + Display.setResizable(true); + Display.setTitle("Minecraft 1.7.2"); + logger.info("LWJGL Version: " + Sys.getVersion()); + Util.EnumOS enumos = Util.getOSType(); + + if (enumos != Util.EnumOS.MACOS) + { + try + { + Display.setIcon(new ByteBuffer[] {this.readImage(new File(this.fileAssets, "/icons/icon_16x16.png")), this.readImage(new File(this.fileAssets, "/icons/icon_32x32.png"))}); + } + catch (IOException ioexception) + { + logger.error("Couldn\'t set icon", ioexception); + } + + if (enumos != Util.EnumOS.WINDOWS) + { + func_147105_a("Minecraft"); + } + } + + try + { + ForgeHooksClient.createDisplay(); + } + catch (LWJGLException lwjglexception) + { + logger.error("Couldn\'t set pixel format", lwjglexception); + + try + { + Thread.sleep(1000L); + } + catch (InterruptedException interruptedexception) + { + ; + } + + if (this.fullscreen) + { + this.updateDisplayMode(); + } + + Display.create(); + } + + OpenGlHelper.initializeTextures(); + this.framebufferMc = new Framebuffer(this.displayWidth, this.displayHeight, true); + this.framebufferMc.setFramebufferColor(0.0F, 0.0F, 0.0F, 0.0F); + this.guiAchievement = new GuiAchievement(this); + this.metadataSerializer_.registerMetadataSectionType(new TextureMetadataSectionSerializer(), TextureMetadataSection.class); + this.metadataSerializer_.registerMetadataSectionType(new FontMetadataSectionSerializer(), FontMetadataSection.class); + this.metadataSerializer_.registerMetadataSectionType(new AnimationMetadataSectionSerializer(), AnimationMetadataSection.class); + this.metadataSerializer_.registerMetadataSectionType(new PackMetadataSectionSerializer(), PackMetadataSection.class); + this.metadataSerializer_.registerMetadataSectionType(new LanguageMetadataSectionSerializer(), LanguageMetadataSection.class); + this.saveLoader = new AnvilSaveConverter(new File(this.mcDataDir, "saves")); + this.mcResourcePackRepository = new ResourcePackRepository(this.fileResourcepacks, new File(this.mcDataDir, "server-resource-packs"), this.mcDefaultResourcePack, this.metadataSerializer_, this.gameSettings); + this.mcResourceManager = new SimpleReloadableResourceManager(this.metadataSerializer_); + this.mcLanguageManager = new LanguageManager(this.metadataSerializer_, this.gameSettings.language); + this.mcResourceManager.registerReloadListener(this.mcLanguageManager); + FMLClientHandler.instance().beginMinecraftLoading(this, this.defaultResourcePacks, this.mcResourceManager); + this.renderEngine = new TextureManager(this.mcResourceManager); + this.mcResourceManager.registerReloadListener(this.renderEngine); + this.mcSoundHandler = new SoundHandler(this.mcResourceManager, this.gameSettings); + this.mcMusicTicker = new MusicTicker(this); + this.mcResourceManager.registerReloadListener(this.mcSoundHandler); + this.loadScreen(); + this.fontRenderer = new FontRenderer(this.gameSettings, new ResourceLocation("textures/font/ascii.png"), this.renderEngine, false); + + if (this.gameSettings.language != null) + { + this.fontRenderer.setUnicodeFlag(this.mcLanguageManager.isCurrentLocaleUnicode() || this.gameSettings.forceUnicodeFont); + this.fontRenderer.setBidiFlag(this.mcLanguageManager.isCurrentLanguageBidirectional()); + } + + this.standardGalacticFontRenderer = new FontRenderer(this.gameSettings, new ResourceLocation("textures/font/ascii_sga.png"), this.renderEngine, false); + this.mcResourceManager.registerReloadListener(this.fontRenderer); + this.mcResourceManager.registerReloadListener(this.standardGalacticFontRenderer); + this.mcResourceManager.registerReloadListener(new GrassColorReloadListener()); + this.mcResourceManager.registerReloadListener(new FoliageColorReloadListener()); + RenderManager.instance.itemRenderer = new ItemRenderer(this); + this.entityRenderer = new EntityRenderer(this, this.mcResourceManager); + this.mcResourceManager.registerReloadListener(this.entityRenderer); + AchievementList.openInventory.setStatStringFormatter(new IStatStringFormat() + { + private static final String __OBFID = "CL_00000639"; + public String formatString(String par1Str) + { + try + { + return String.format(par1Str, new Object[] {GameSettings.getKeyDisplayString(Minecraft.this.gameSettings.keyBindInventory.getKeyCode())}); + } + catch (Exception exception) + { + return "Error: " + exception.getLocalizedMessage(); + } + } + }); + this.mouseHelper = new MouseHelper(); + this.checkGLError("Pre startup"); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glShadeModel(GL11.GL_SMOOTH); + GL11.glClearDepth(1.0D); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glDepthFunc(GL11.GL_LEQUAL); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); + GL11.glCullFace(GL11.GL_BACK); + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + this.checkGLError("Startup"); + this.renderGlobal = new RenderGlobal(this); + this.textureMapBlocks = new TextureMap(0, "textures/blocks"); + this.textureMapBlocks.setAnisotropicFiltering(this.gameSettings.anisotropicFiltering); + this.textureMapBlocks.setMipmapLevels(this.gameSettings.mipmapLevels); + this.renderEngine.loadTextureMap(TextureMap.locationBlocksTexture, this.textureMapBlocks); + this.renderEngine.loadTextureMap(TextureMap.locationItemsTexture, new TextureMap(1, "textures/items")); + GL11.glViewport(0, 0, this.displayWidth, this.displayHeight); + this.effectRenderer = new EffectRenderer(this.theWorld, this.renderEngine); + FMLClientHandler.instance().finishMinecraftLoading(); + this.checkGLError("Post startup"); + this.ingameGUI = new GuiIngameForge(this); + + if (this.serverName != null) + { + FMLClientHandler.instance().connectToServerAtStartup(this.serverName, this.serverPort); + } + else + { + this.displayGuiScreen(new GuiMainMenu()); + } + + this.loadingScreen = new LoadingScreenRenderer(this); + + if (this.gameSettings.fullScreen && !this.fullscreen) + { + this.toggleFullscreen(); + } + + FMLClientHandler.instance().onInitializationComplete(); + Display.setVSyncEnabled(this.gameSettings.enableVsync); + } + + public void refreshResources() + { + ArrayList arraylist = Lists.newArrayList(this.defaultResourcePacks); + Iterator iterator = this.mcResourcePackRepository.getRepositoryEntries().iterator(); + + while (iterator.hasNext()) + { + ResourcePackRepository.Entry entry = (ResourcePackRepository.Entry)iterator.next(); + arraylist.add(entry.getResourcePack()); + } + + if (this.mcResourcePackRepository.func_148530_e() != null) + { + arraylist.add(this.mcResourcePackRepository.func_148530_e()); + } + + this.mcLanguageManager.parseLanguageMetadata(arraylist); + this.mcResourceManager.reloadResources(arraylist); + + if (this.renderGlobal != null) + { + this.renderGlobal.loadRenderers(); + } + } + + private void addDefaultResourcePack() + { + this.defaultResourcePacks.add(this.mcDefaultResourcePack); + } + + private ByteBuffer readImage(File par1File) throws IOException + { + BufferedImage bufferedimage = ImageIO.read(par1File); + int[] aint = bufferedimage.getRGB(0, 0, bufferedimage.getWidth(), bufferedimage.getHeight(), (int[])null, 0, bufferedimage.getWidth()); + ByteBuffer bytebuffer = ByteBuffer.allocate(4 * aint.length); + int[] aint1 = aint; + int i = aint.length; + + for (int j = 0; j < i; ++j) + { + int k = aint1[j]; + bytebuffer.putInt(k << 8 | k >> 24 & 255); + } + + bytebuffer.flip(); + return bytebuffer; + } + + private void updateDisplayMode() throws LWJGLException + { + HashSet hashset = new HashSet(); + Collections.addAll(hashset, Display.getAvailableDisplayModes()); + DisplayMode displaymode = Display.getDesktopDisplayMode(); + + if (!hashset.contains(displaymode) && Util.getOSType() == Util.EnumOS.MACOS) + { + Iterator iterator = macDisplayModes.iterator(); + + while (iterator.hasNext()) + { + DisplayMode displaymode1 = (DisplayMode)iterator.next(); + boolean flag = true; + Iterator iterator1 = hashset.iterator(); + DisplayMode displaymode2; + + while (iterator1.hasNext()) + { + displaymode2 = (DisplayMode)iterator1.next(); + + if (displaymode2.getBitsPerPixel() == 32 && displaymode2.getWidth() == displaymode1.getWidth() && displaymode2.getHeight() == displaymode1.getHeight()) + { + flag = false; + break; + } + } + + if (!flag) + { + iterator1 = hashset.iterator(); + + while (iterator1.hasNext()) + { + displaymode2 = (DisplayMode)iterator1.next(); + + if (displaymode2.getBitsPerPixel() == 32 && displaymode2.getWidth() == displaymode1.getWidth() / 2 && displaymode2.getHeight() == displaymode1.getHeight() / 2) + { + displaymode = displaymode2; + break; + } + } + } + } + } + + Display.setDisplayMode(displaymode); + this.displayWidth = displaymode.getWidth(); + this.displayHeight = displaymode.getHeight(); + } + + private void loadScreen() throws LWJGLException + { + GL11.glEnable(GL11.GL_TEXTURE_2D); + this.renderEngine.bindTexture(locationMojangPng); + ScaledResolution scaledresolution = new ScaledResolution(this.gameSettings, this.displayWidth, this.displayHeight); + int i = scaledresolution.getScaleFactor(); + Framebuffer framebuffer = new Framebuffer(scaledresolution.getScaledWidth() * i, scaledresolution.getScaledHeight() * i, true); + framebuffer.bindFramebuffer(false); + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + GL11.glOrtho(0.0D, (double)scaledresolution.getScaledWidth(), (double)scaledresolution.getScaledHeight(), 0.0D, 1000.0D, 3000.0D); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + GL11.glTranslatef(0.0F, 0.0F, -2000.0F); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_FOG); + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glEnable(GL11.GL_TEXTURE_2D); + this.renderEngine.bindTexture(locationMojangPng); + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.setColorOpaque_I(16777215); + tessellator.addVertexWithUV(0.0D, (double)this.displayHeight, 0.0D, 0.0D, 0.0D); + tessellator.addVertexWithUV((double)this.displayWidth, (double)this.displayHeight, 0.0D, 0.0D, 0.0D); + tessellator.addVertexWithUV((double)this.displayWidth, 0.0D, 0.0D, 0.0D, 0.0D); + tessellator.addVertexWithUV(0.0D, 0.0D, 0.0D, 0.0D, 0.0D); + tessellator.draw(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + tessellator.setColorOpaque_I(16777215); + short short1 = 256; + short short2 = 256; + this.scaledTessellator((scaledresolution.getScaledWidth() - short1) / 2, (scaledresolution.getScaledHeight() - short2) / 2, 0, 0, short1, short2); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_FOG); + framebuffer.unbindFramebuffer(); + framebuffer.framebufferRender(scaledresolution.getScaledWidth() * i, scaledresolution.getScaledHeight() * i); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); + GL11.glFlush(); + this.func_147120_f(); + } + + public void scaledTessellator(int par1, int par2, int par3, int par4, int par5, int par6) + { + float f = 0.00390625F; + float f1 = 0.00390625F; + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV((double)(par1 + 0), (double)(par2 + par6), 0.0D, (double)((float)(par3 + 0) * f), (double)((float)(par4 + par6) * f1)); + tessellator.addVertexWithUV((double)(par1 + par5), (double)(par2 + par6), 0.0D, (double)((float)(par3 + par5) * f), (double)((float)(par4 + par6) * f1)); + tessellator.addVertexWithUV((double)(par1 + par5), (double)(par2 + 0), 0.0D, (double)((float)(par3 + par5) * f), (double)((float)(par4 + 0) * f1)); + tessellator.addVertexWithUV((double)(par1 + 0), (double)(par2 + 0), 0.0D, (double)((float)(par3 + 0) * f), (double)((float)(par4 + 0) * f1)); + tessellator.draw(); + } + + public ISaveFormat getSaveLoader() + { + return this.saveLoader; + } + + public void displayGuiScreen(GuiScreen p_147108_1_) + { + if (p_147108_1_ == null && this.theWorld == null) + { + p_147108_1_ = new GuiMainMenu(); + } + else if (p_147108_1_ == null && this.thePlayer.getHealth() <= 0.0F) + { + p_147108_1_ = new GuiGameOver(); + } + + GuiScreen old = this.currentScreen; + GuiOpenEvent event = new GuiOpenEvent(p_147108_1_); + + if (MinecraftForge.EVENT_BUS.post(event)) return; + + p_147108_1_ = event.gui; + if (old != null && p_147108_1_ != old) + { + old.onGuiClosed(); + } + + if (p_147108_1_ instanceof GuiMainMenu) + { + this.gameSettings.showDebugInfo = false; + this.ingameGUI.getChatGUI().clearChatMessages(); + } + + this.currentScreen = (GuiScreen)p_147108_1_; + + if (p_147108_1_ != null) + { + this.setIngameNotInFocus(); + ScaledResolution scaledresolution = new ScaledResolution(this.gameSettings, this.displayWidth, this.displayHeight); + int i = scaledresolution.getScaledWidth(); + int j = scaledresolution.getScaledHeight(); + ((GuiScreen)p_147108_1_).setWorldAndResolution(this, i, j); + this.skipRenderWorld = false; + } + else + { + this.mcSoundHandler.resumeSounds(); + this.setIngameFocus(); + } + } + + private void checkGLError(String par1Str) + { + int i = GL11.glGetError(); + + if (i != 0) + { + String s1 = GLU.gluErrorString(i); + logger.error("########## GL ERROR ##########"); + logger.error("@ " + par1Str); + logger.error(i + ": " + s1); + } + } + + public void shutdownMinecraftApplet() + { + try + { + logger.info("Stopping!"); + + try + { + this.loadWorld((WorldClient)null); + } + catch (Throwable throwable1) + { + ; + } + + try + { + GLAllocation.deleteTexturesAndDisplayLists(); + } + catch (Throwable throwable) + { + ; + } + + this.mcSoundHandler.unloadSounds(); + } + finally + { + Display.destroy(); + + if (!this.hasCrashed) + { + System.exit(0); + } + } + + System.gc(); + } + + public void run() + { + this.running = true; + CrashReport crashreport; + + try + { + this.startGame(); + } + catch (Throwable throwable) + { + crashreport = CrashReport.makeCrashReport(throwable, "Initializing game"); + crashreport.makeCategory("Initialization"); + this.displayCrashReport(this.addGraphicsAndWorldToCrashReport(crashreport)); + return; + } + + while (true) + { + try + { + while (this.running) + { + if (!this.hasCrashed || this.crashReporter == null) + { + try + { + this.runGameLoop(); + } + catch (OutOfMemoryError outofmemoryerror) + { + this.freeMemory(); + this.displayGuiScreen(new GuiMemoryErrorScreen()); + System.gc(); + } + + continue; + } + + this.displayCrashReport(this.crashReporter); + } + } + catch (MinecraftError minecrafterror) + { + break; + } + catch (ReportedException reportedexception) + { + this.addGraphicsAndWorldToCrashReport(reportedexception.getCrashReport()); + this.freeMemory(); + logger.fatal("Reported exception thrown!", reportedexception); + this.displayCrashReport(reportedexception.getCrashReport()); + break; + } + catch (Throwable throwable1) + { + crashreport = this.addGraphicsAndWorldToCrashReport(new CrashReport("Unexpected error", throwable1)); + this.freeMemory(); + logger.fatal("Unreported exception thrown!", throwable1); + this.displayCrashReport(crashreport); + break; + } + finally + { + this.shutdownMinecraftApplet(); + } + + return; + } + } + + private void runGameLoop() + { + AxisAlignedBB.getAABBPool().cleanPool(); + + if (this.theWorld != null) + { + this.theWorld.getWorldVec3Pool().clear(); + } + + this.mcProfiler.startSection("root"); + + if (Display.isCreated() && Display.isCloseRequested()) + { + this.shutdown(); + } + + if (this.isGamePaused && this.theWorld != null) + { + float f = this.timer.renderPartialTicks; + this.timer.updateTimer(); + this.timer.renderPartialTicks = f; + } + else + { + this.timer.updateTimer(); + } + + if ((this.theWorld == null || this.currentScreen == null) && this.refreshTexturePacksScheduled) + { + this.refreshTexturePacksScheduled = false; + this.refreshResources(); + } + + long j = System.nanoTime(); + this.mcProfiler.startSection("tick"); + + for (int i = 0; i < this.timer.elapsedTicks; ++i) + { + this.runTick(); + } + + this.mcProfiler.endStartSection("preRenderErrors"); + long k = System.nanoTime() - j; + this.checkGLError("Pre render"); + RenderBlocks.fancyGrass = this.gameSettings.fancyGraphics; + this.mcProfiler.endStartSection("sound"); + this.mcSoundHandler.setListener(this.thePlayer, this.timer.renderPartialTicks); + this.mcProfiler.endSection(); + this.mcProfiler.startSection("render"); + GL11.glPushMatrix(); + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); + this.framebufferMc.bindFramebuffer(true); + this.mcProfiler.startSection("display"); + GL11.glEnable(GL11.GL_TEXTURE_2D); + + if (this.thePlayer != null && this.thePlayer.isEntityInsideOpaqueBlock()) + { + this.gameSettings.thirdPersonView = 0; + } + + this.mcProfiler.endSection(); + + if (!this.skipRenderWorld) + { + FMLCommonHandler.instance().onRenderTickStart(this.timer.renderPartialTicks); + this.mcProfiler.endStartSection("gameRenderer"); + this.entityRenderer.updateCameraAndRender(this.timer.renderPartialTicks); + this.mcProfiler.endSection(); + FMLCommonHandler.instance().onRenderTickEnd(this.timer.renderPartialTicks); + } + + GL11.glFlush(); + this.mcProfiler.endSection(); + + if (!Display.isActive() && this.fullscreen) + { + this.toggleFullscreen(); + } + + if (this.gameSettings.showDebugInfo && this.gameSettings.showDebugProfilerChart) + { + if (!this.mcProfiler.profilingEnabled) + { + this.mcProfiler.clearProfiling(); + } + + this.mcProfiler.profilingEnabled = true; + this.displayDebugInfo(k); + } + else + { + this.mcProfiler.profilingEnabled = false; + this.prevFrameTime = System.nanoTime(); + } + + this.guiAchievement.func_146254_a(); + this.framebufferMc.unbindFramebuffer(); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + this.framebufferMc.framebufferRender(this.displayWidth, this.displayHeight); + GL11.glPopMatrix(); + this.mcProfiler.startSection("root"); + this.func_147120_f(); + Thread.yield(); + this.screenshotListener(); + this.checkGLError("Post render"); + ++this.fpsCounter; + this.isGamePaused = this.isSingleplayer() && this.currentScreen != null && this.currentScreen.doesGuiPauseGame() && !this.theIntegratedServer.getPublic(); + + while (getSystemTime() >= this.debugUpdateTime + 1000L) + { + debugFPS = this.fpsCounter; + this.debug = debugFPS + " fps, " + WorldRenderer.chunksUpdated + " chunk updates"; + WorldRenderer.chunksUpdated = 0; + this.debugUpdateTime += 1000L; + this.fpsCounter = 0; + this.usageSnooper.addMemoryStatsToSnooper(); + + if (!this.usageSnooper.isSnooperRunning()) + { + this.usageSnooper.startSnooper(); + } + } + + this.mcProfiler.endSection(); + + if (this.isFramerateLimitBelowMax()) + { + Display.sync(this.getLimitFramerate()); + } + } + + public void func_147120_f() + { + Display.update(); + + if (!this.fullscreen && Display.wasResized()) + { + int i = this.displayWidth; + int j = this.displayHeight; + this.displayWidth = Display.getWidth(); + this.displayHeight = Display.getHeight(); + + if (this.displayWidth != i || this.displayHeight != j) + { + if (this.displayWidth <= 0) + { + this.displayWidth = 1; + } + + if (this.displayHeight <= 0) + { + this.displayHeight = 1; + } + + this.resize(this.displayWidth, this.displayHeight); + } + } + } + + public int getLimitFramerate() + { + return this.theWorld == null && this.currentScreen != null ? 30 : this.gameSettings.limitFramerate; + } + + public boolean isFramerateLimitBelowMax() + { + return (float)this.getLimitFramerate() < GameSettings.Options.FRAMERATE_LIMIT.getValueMax(); + } + + public void freeMemory() + { + try + { + memoryReserve = new byte[0]; + this.renderGlobal.deleteAllDisplayLists(); + } + catch (Throwable throwable2) + { + ; + } + + try + { + System.gc(); + AxisAlignedBB.getAABBPool().clearPool(); + this.theWorld.getWorldVec3Pool().clearAndFreeCache(); + } + catch (Throwable throwable1) + { + ; + } + + try + { + System.gc(); + this.loadWorld((WorldClient)null); + } + catch (Throwable throwable) + { + ; + } + + System.gc(); + } + + private void screenshotListener() + { + if (this.gameSettings.keyBindScreenshot.isPressed()) + { + if (!this.isTakingScreenshot) + { + this.isTakingScreenshot = true; + this.ingameGUI.getChatGUI().printChatMessage(ScreenShotHelper.saveScreenshot(this.mcDataDir, this.displayWidth, this.displayHeight, this.framebufferMc)); + } + } + else + { + this.isTakingScreenshot = false; + } + } + + private void updateDebugProfilerName(int par1) + { + List list = this.mcProfiler.getProfilingData(this.debugProfilerName); + + if (list != null && !list.isEmpty()) + { + Profiler.Result result = (Profiler.Result)list.remove(0); + + if (par1 == 0) + { + if (result.field_76331_c.length() > 0) + { + int j = this.debugProfilerName.lastIndexOf("."); + + if (j >= 0) + { + this.debugProfilerName = this.debugProfilerName.substring(0, j); + } + } + } + else + { + --par1; + + if (par1 < list.size() && !((Profiler.Result)list.get(par1)).field_76331_c.equals("unspecified")) + { + if (this.debugProfilerName.length() > 0) + { + this.debugProfilerName = this.debugProfilerName + "."; + } + + this.debugProfilerName = this.debugProfilerName + ((Profiler.Result)list.get(par1)).field_76331_c; + } + } + } + } + + private void displayDebugInfo(long par1) + { + if (this.mcProfiler.profilingEnabled) + { + List list = this.mcProfiler.getProfilingData(this.debugProfilerName); + Profiler.Result result = (Profiler.Result)list.remove(0); + GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glEnable(GL11.GL_COLOR_MATERIAL); + GL11.glLoadIdentity(); + GL11.glOrtho(0.0D, (double)this.displayWidth, (double)this.displayHeight, 0.0D, 1000.0D, 3000.0D); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + GL11.glTranslatef(0.0F, 0.0F, -2000.0F); + GL11.glLineWidth(1.0F); + GL11.glDisable(GL11.GL_TEXTURE_2D); + Tessellator tessellator = Tessellator.instance; + short short1 = 160; + int j = this.displayWidth - short1 - 10; + int k = this.displayHeight - short1 * 2; + GL11.glEnable(GL11.GL_BLEND); + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_I(0, 200); + tessellator.addVertex((double)((float)j - (float)short1 * 1.1F), (double)((float)k - (float)short1 * 0.6F - 16.0F), 0.0D); + tessellator.addVertex((double)((float)j - (float)short1 * 1.1F), (double)(k + short1 * 2), 0.0D); + tessellator.addVertex((double)((float)j + (float)short1 * 1.1F), (double)(k + short1 * 2), 0.0D); + tessellator.addVertex((double)((float)j + (float)short1 * 1.1F), (double)((float)k - (float)short1 * 0.6F - 16.0F), 0.0D); + tessellator.draw(); + GL11.glDisable(GL11.GL_BLEND); + double d0 = 0.0D; + int i1; + + for (int l = 0; l < list.size(); ++l) + { + Profiler.Result result1 = (Profiler.Result)list.get(l); + i1 = MathHelper.floor_double(result1.field_76332_a / 4.0D) + 1; + tessellator.startDrawing(6); + tessellator.setColorOpaque_I(result1.func_76329_a()); + tessellator.addVertex((double)j, (double)k, 0.0D); + int j1; + float f; + float f1; + float f2; + + for (j1 = i1; j1 >= 0; --j1) + { + f = (float)((d0 + result1.field_76332_a * (double)j1 / (double)i1) * Math.PI * 2.0D / 100.0D); + f1 = MathHelper.sin(f) * (float)short1; + f2 = MathHelper.cos(f) * (float)short1 * 0.5F; + tessellator.addVertex((double)((float)j + f1), (double)((float)k - f2), 0.0D); + } + + tessellator.draw(); + tessellator.startDrawing(5); + tessellator.setColorOpaque_I((result1.func_76329_a() & 16711422) >> 1); + + for (j1 = i1; j1 >= 0; --j1) + { + f = (float)((d0 + result1.field_76332_a * (double)j1 / (double)i1) * Math.PI * 2.0D / 100.0D); + f1 = MathHelper.sin(f) * (float)short1; + f2 = MathHelper.cos(f) * (float)short1 * 0.5F; + tessellator.addVertex((double)((float)j + f1), (double)((float)k - f2), 0.0D); + tessellator.addVertex((double)((float)j + f1), (double)((float)k - f2 + 10.0F), 0.0D); + } + + tessellator.draw(); + d0 += result1.field_76332_a; + } + + DecimalFormat decimalformat = new DecimalFormat("##0.00"); + GL11.glEnable(GL11.GL_TEXTURE_2D); + String s = ""; + + if (!result.field_76331_c.equals("unspecified")) + { + s = s + "[0] "; + } + + if (result.field_76331_c.length() == 0) + { + s = s + "ROOT "; + } + else + { + s = s + result.field_76331_c + " "; + } + + i1 = 16777215; + this.fontRenderer.drawStringWithShadow(s, j - short1, k - short1 / 2 - 16, i1); + this.fontRenderer.drawStringWithShadow(s = decimalformat.format(result.field_76330_b) + "%", j + short1 - this.fontRenderer.getStringWidth(s), k - short1 / 2 - 16, i1); + + for (int k1 = 0; k1 < list.size(); ++k1) + { + Profiler.Result result2 = (Profiler.Result)list.get(k1); + String s1 = ""; + + if (result2.field_76331_c.equals("unspecified")) + { + s1 = s1 + "[?] "; + } + else + { + s1 = s1 + "[" + (k1 + 1) + "] "; + } + + s1 = s1 + result2.field_76331_c; + this.fontRenderer.drawStringWithShadow(s1, j - short1, k + short1 / 2 + k1 * 8 + 20, result2.func_76329_a()); + this.fontRenderer.drawStringWithShadow(s1 = decimalformat.format(result2.field_76332_a) + "%", j + short1 - 50 - this.fontRenderer.getStringWidth(s1), k + short1 / 2 + k1 * 8 + 20, result2.func_76329_a()); + this.fontRenderer.drawStringWithShadow(s1 = decimalformat.format(result2.field_76330_b) + "%", j + short1 - this.fontRenderer.getStringWidth(s1), k + short1 / 2 + k1 * 8 + 20, result2.func_76329_a()); + } + } + } + + public void shutdown() + { + this.running = false; + } + + public void setIngameFocus() + { + if (Display.isActive()) + { + if (!this.inGameHasFocus) + { + this.inGameHasFocus = true; + this.mouseHelper.grabMouseCursor(); + this.displayGuiScreen((GuiScreen)null); + this.leftClickCounter = 10000; + } + } + } + + public void setIngameNotInFocus() + { + if (this.inGameHasFocus) + { + KeyBinding.unPressAllKeys(); + this.inGameHasFocus = false; + this.mouseHelper.ungrabMouseCursor(); + } + } + + public void displayInGameMenu() + { + if (this.currentScreen == null) + { + this.displayGuiScreen(new GuiIngameMenu()); + + if (this.isSingleplayer() && !this.theIntegratedServer.getPublic()) + { + this.mcSoundHandler.pauseSounds(); + } + } + } + + private void func_147115_a(boolean p_147115_1_) + { + if (!p_147115_1_) + { + this.leftClickCounter = 0; + } + + if (this.leftClickCounter <= 0) + { + if (p_147115_1_ && this.objectMouseOver != null && this.objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) + { + int i = this.objectMouseOver.blockX; + int j = this.objectMouseOver.blockY; + int k = this.objectMouseOver.blockZ; + + if (this.theWorld.getBlock(i, j, k).getMaterial() != Material.air) + { + this.playerController.onPlayerDamageBlock(i, j, k, this.objectMouseOver.sideHit); + + if (this.thePlayer.isCurrentToolAdventureModeExempt(i, j, k)) + { + this.effectRenderer.addBlockHitEffects(i, j, k, this.objectMouseOver); + this.thePlayer.swingItem(); + } + } + } + else + { + this.playerController.resetBlockRemoving(); + } + } + } + + private void func_147116_af() + { + if (this.leftClickCounter <= 0) + { + this.thePlayer.swingItem(); + + if (this.objectMouseOver == null) + { + logger.error("Null returned as \'hitResult\', this shouldn\'t happen!"); + + if (this.playerController.isNotCreative()) + { + this.leftClickCounter = 10; + } + } + else + { + switch (Minecraft.SwitchMovingObjectType.field_151437_a[this.objectMouseOver.typeOfHit.ordinal()]) + { + case 1: + this.playerController.attackEntity(this.thePlayer, this.objectMouseOver.entityHit); + break; + case 2: + int i = this.objectMouseOver.blockX; + int j = this.objectMouseOver.blockY; + int k = this.objectMouseOver.blockZ; + + if (this.theWorld.getBlock(i, j, k).getMaterial() == Material.air) + { + if (this.playerController.isNotCreative()) + { + this.leftClickCounter = 10; + } + } + else + { + this.playerController.clickBlock(i, j, k, this.objectMouseOver.sideHit); + } + } + } + } + } + + private void func_147121_ag() + { + this.rightClickDelayTimer = 4; + boolean flag = true; + ItemStack itemstack = this.thePlayer.inventory.getCurrentItem(); + + if (this.objectMouseOver == null) + { + logger.warn("Null returned as \'hitResult\', this shouldn\'t happen!"); + } + else + { + switch (Minecraft.SwitchMovingObjectType.field_151437_a[this.objectMouseOver.typeOfHit.ordinal()]) + { + case 1: + if (this.playerController.interactWithEntitySendPacket(this.thePlayer, this.objectMouseOver.entityHit)) + { + flag = false; + } + + break; + case 2: + int i = this.objectMouseOver.blockX; + int j = this.objectMouseOver.blockY; + int k = this.objectMouseOver.blockZ; + + if (!this.theWorld.getBlock(i, j, k).isAir(theWorld, i, j, k)) + { + int l = itemstack != null ? itemstack.stackSize : 0; + + boolean result = !ForgeEventFactory.onPlayerInteract(thePlayer, Action.RIGHT_CLICK_BLOCK, i, j, k, this.objectMouseOver.sideHit).isCanceled(); + if (result && this.playerController.onPlayerRightClick(this.thePlayer, this.theWorld, itemstack, i, j, k, this.objectMouseOver.sideHit, this.objectMouseOver.hitVec)) + { + flag = false; + this.thePlayer.swingItem(); + } + + if (itemstack == null) + { + return; + } + + if (itemstack.stackSize == 0) + { + this.thePlayer.inventory.mainInventory[this.thePlayer.inventory.currentItem] = null; + } + else if (itemstack.stackSize != l || this.playerController.isInCreativeMode()) + { + this.entityRenderer.itemRenderer.resetEquippedProgress(); + } + } + } + } + + if (flag) + { + ItemStack itemstack1 = this.thePlayer.inventory.getCurrentItem(); + + boolean result = !ForgeEventFactory.onPlayerInteract(thePlayer, Action.RIGHT_CLICK_AIR, 0, 0, 0, -1).isCanceled(); + if (result && itemstack1 != null && this.playerController.sendUseItem(this.thePlayer, this.theWorld, itemstack1)) + { + this.entityRenderer.itemRenderer.resetEquippedProgress2(); + } + } + } + + public void toggleFullscreen() + { + try + { + this.fullscreen = !this.fullscreen; + + if (this.fullscreen) + { + this.updateDisplayMode(); + this.displayWidth = Display.getDisplayMode().getWidth(); + this.displayHeight = Display.getDisplayMode().getHeight(); + + if (this.displayWidth <= 0) + { + this.displayWidth = 1; + } + + if (this.displayHeight <= 0) + { + this.displayHeight = 1; + } + } + else + { + Display.setDisplayMode(new DisplayMode(this.tempDisplayWidth, this.tempDisplayHeight)); + this.displayWidth = this.tempDisplayWidth; + this.displayHeight = this.tempDisplayHeight; + + if (this.displayWidth <= 0) + { + this.displayWidth = 1; + } + + if (this.displayHeight <= 0) + { + this.displayHeight = 1; + } + } + + if (this.currentScreen != null) + { + this.resize(this.displayWidth, this.displayHeight); + } + else + { + this.updateFramebufferSize(); + } + + Display.setFullscreen(this.fullscreen); + Display.setVSyncEnabled(this.gameSettings.enableVsync); + this.func_147120_f(); + } + catch (Exception exception) + { + logger.error("Couldn\'t toggle fullscreen", exception); + } + } + + private void resize(int par1, int par2) + { + this.displayWidth = par1 <= 0 ? 1 : par1; + this.displayHeight = par2 <= 0 ? 1 : par2; + + if (this.currentScreen != null) + { + ScaledResolution scaledresolution = new ScaledResolution(this.gameSettings, par1, par2); + int k = scaledresolution.getScaledWidth(); + int l = scaledresolution.getScaledHeight(); + this.currentScreen.setWorldAndResolution(this, k, l); + } + + this.loadingScreen = new LoadingScreenRenderer(this); + this.updateFramebufferSize(); + } + + private void updateFramebufferSize() + { + this.framebufferMc.createBindFramebuffer(this.displayWidth, this.displayHeight); + + if (this.entityRenderer != null) + { + this.entityRenderer.updateShaderGroupSize(this.displayWidth, this.displayHeight); + } + } + + public void runTick() + { + if (this.rightClickDelayTimer > 0) + { + --this.rightClickDelayTimer; + } + + FMLCommonHandler.instance().onPreClientTick(); + + this.mcProfiler.startSection("gui"); + + if (!this.isGamePaused) + { + this.ingameGUI.updateTick(); + } + + this.mcProfiler.endStartSection("pick"); + this.entityRenderer.getMouseOver(1.0F); + this.mcProfiler.endStartSection("gameMode"); + + if (!this.isGamePaused && this.theWorld != null) + { + this.playerController.updateController(); + } + + this.mcProfiler.endStartSection("textures"); + + if (!this.isGamePaused) + { + this.renderEngine.tick(); + } + + if (this.currentScreen == null && this.thePlayer != null) + { + if (this.thePlayer.getHealth() <= 0.0F) + { + this.displayGuiScreen((GuiScreen)null); + } + else if (this.thePlayer.isPlayerSleeping() && this.theWorld != null) + { + this.displayGuiScreen(new GuiSleepMP()); + } + } + else if (this.currentScreen != null && this.currentScreen instanceof GuiSleepMP && !this.thePlayer.isPlayerSleeping()) + { + this.displayGuiScreen((GuiScreen)null); + } + + if (this.currentScreen != null) + { + this.leftClickCounter = 10000; + } + + CrashReport crashreport; + CrashReportCategory crashreportcategory; + + if (this.currentScreen != null) + { + try + { + this.currentScreen.handleInput(); + } + catch (Throwable throwable1) + { + crashreport = CrashReport.makeCrashReport(throwable1, "Updating screen events"); + crashreportcategory = crashreport.makeCategory("Affected screen"); + crashreportcategory.addCrashSectionCallable("Screen name", new Callable() + { + private static final String __OBFID = "CL_00000640"; + public String call() + { + return Minecraft.this.currentScreen.getClass().getCanonicalName(); + } + }); + throw new ReportedException(crashreport); + } + + if (this.currentScreen != null) + { + try + { + this.currentScreen.updateScreen(); + } + catch (Throwable throwable) + { + crashreport = CrashReport.makeCrashReport(throwable, "Ticking screen"); + crashreportcategory = crashreport.makeCategory("Affected screen"); + crashreportcategory.addCrashSectionCallable("Screen name", new Callable() + { + private static final String __OBFID = "CL_00000642"; + public String call() + { + return Minecraft.this.currentScreen.getClass().getCanonicalName(); + } + }); + throw new ReportedException(crashreport); + } + } + } + + if (this.currentScreen == null || this.currentScreen.allowUserInput) + { + this.mcProfiler.endStartSection("mouse"); + int i; + + while (Mouse.next()) + { + if (ForgeHooksClient.postMouseEvent()) continue; + + i = Mouse.getEventButton(); + + if (isRunningOnMac && i == 0 && (Keyboard.isKeyDown(29) || Keyboard.isKeyDown(157))) + { + i = 1; + } + + KeyBinding.setKeyBindState(i - 100, Mouse.getEventButtonState()); + + if (Mouse.getEventButtonState()) + { + KeyBinding.onTick(i - 100); + } + + long k = getSystemTime() - this.systemTime; + + if (k <= 200L) + { + int j = Mouse.getEventDWheel(); + + if (j != 0) + { + this.thePlayer.inventory.changeCurrentItem(j); + + if (this.gameSettings.noclip) + { + if (j > 0) + { + j = 1; + } + + if (j < 0) + { + j = -1; + } + + this.gameSettings.noclipRate += (float)j * 0.25F; + } + } + + if (this.currentScreen == null) + { + if (!this.inGameHasFocus && Mouse.getEventButtonState()) + { + this.setIngameFocus(); + } + } + else if (this.currentScreen != null) + { + this.currentScreen.handleMouseInput(); + } + } + FMLCommonHandler.instance().fireMouseInput(); + } + + if (this.leftClickCounter > 0) + { + --this.leftClickCounter; + } + + this.mcProfiler.endStartSection("keyboard"); + boolean flag; + + while (Keyboard.next()) + { + KeyBinding.setKeyBindState(Keyboard.getEventKey(), Keyboard.getEventKeyState()); + + if (Keyboard.getEventKeyState()) + { + KeyBinding.onTick(Keyboard.getEventKey()); + } + + if (this.field_83002_am > 0L) + { + if (getSystemTime() - this.field_83002_am >= 6000L) + { + throw new ReportedException(new CrashReport("Manually triggered debug crash", new Throwable())); + } + + if (!Keyboard.isKeyDown(46) || !Keyboard.isKeyDown(61)) + { + this.field_83002_am = -1L; + } + } + else if (Keyboard.isKeyDown(46) && Keyboard.isKeyDown(61)) + { + this.field_83002_am = getSystemTime(); + } + + if (Keyboard.getEventKeyState()) + { + if (Keyboard.getEventKey() == 62 && this.entityRenderer != null) + { + this.entityRenderer.deactivateShader(); + } + + if (Keyboard.getEventKey() == 87) + { + this.toggleFullscreen(); + } + else + { + if (this.currentScreen != null) + { + this.currentScreen.handleKeyboardInput(); + } + else + { + if (Keyboard.getEventKey() == 1) + { + this.displayInGameMenu(); + } + + if (Keyboard.getEventKey() == 31 && Keyboard.isKeyDown(61)) + { + this.refreshResources(); + } + + if (Keyboard.getEventKey() == 20 && Keyboard.isKeyDown(61)) + { + this.refreshResources(); + } + + if (Keyboard.getEventKey() == 33 && Keyboard.isKeyDown(61)) + { + flag = Keyboard.isKeyDown(42) | Keyboard.isKeyDown(54); + this.gameSettings.setOptionValue(GameSettings.Options.RENDER_DISTANCE, flag ? -1 : 1); + } + + if (Keyboard.getEventKey() == 30 && Keyboard.isKeyDown(61)) + { + this.renderGlobal.loadRenderers(); + } + + if (Keyboard.getEventKey() == 35 && Keyboard.isKeyDown(61)) + { + this.gameSettings.advancedItemTooltips = !this.gameSettings.advancedItemTooltips; + this.gameSettings.saveOptions(); + } + + if (Keyboard.getEventKey() == 48 && Keyboard.isKeyDown(61)) + { + RenderManager.debugBoundingBox = !RenderManager.debugBoundingBox; + } + + if (Keyboard.getEventKey() == 25 && Keyboard.isKeyDown(61)) + { + this.gameSettings.pauseOnLostFocus = !this.gameSettings.pauseOnLostFocus; + this.gameSettings.saveOptions(); + } + + if (Keyboard.getEventKey() == 59) + { + this.gameSettings.hideGUI = !this.gameSettings.hideGUI; + } + + if (Keyboard.getEventKey() == 61) + { + this.gameSettings.showDebugInfo = !this.gameSettings.showDebugInfo; + this.gameSettings.showDebugProfilerChart = GuiScreen.isShiftKeyDown(); + } + + if (this.gameSettings.keyBindTogglePerspective.isPressed()) + { + ++this.gameSettings.thirdPersonView; + + if (this.gameSettings.thirdPersonView > 2) + { + this.gameSettings.thirdPersonView = 0; + } + } + + if (this.gameSettings.keyBindSmoothCamera.isPressed()) + { + this.gameSettings.smoothCamera = !this.gameSettings.smoothCamera; + } + } + + if (this.gameSettings.showDebugInfo && this.gameSettings.showDebugProfilerChart) + { + if (Keyboard.getEventKey() == 11) + { + this.updateDebugProfilerName(0); + } + + for (i = 0; i < 9; ++i) + { + if (Keyboard.getEventKey() == 2 + i) + { + this.updateDebugProfilerName(i + 1); + } + } + } + } + FMLCommonHandler.instance().fireKeyInput(); + } + } + + for (i = 0; i < 9; ++i) + { + if (this.gameSettings.keyBindsHotbar[i].isPressed()) + { + this.thePlayer.inventory.currentItem = i; + } + } + + flag = this.gameSettings.chatVisibility != EntityPlayer.EnumChatVisibility.HIDDEN; + + while (this.gameSettings.keyBindInventory.isPressed()) + { + if (this.playerController.func_110738_j()) + { + this.thePlayer.func_110322_i(); + } + else + { + this.getNetHandler().addToSendQueue(new C16PacketClientStatus(C16PacketClientStatus.EnumState.OPEN_INVENTORY_ACHIEVEMENT)); + this.displayGuiScreen(new GuiInventory(this.thePlayer)); + } + } + + while (this.gameSettings.keyBindDrop.isPressed()) + { + this.thePlayer.dropOneItem(GuiScreen.isCtrlKeyDown()); + } + + while (this.gameSettings.keyBindChat.isPressed() && flag) + { + this.displayGuiScreen(new GuiChat()); + } + + if (this.currentScreen == null && this.gameSettings.keyBindCommand.isPressed() && flag) + { + this.displayGuiScreen(new GuiChat("/")); + } + + if (this.thePlayer.isUsingItem()) + { + if (!this.gameSettings.keyBindUseItem.getIsKeyPressed()) + { + this.playerController.onStoppedUsingItem(this.thePlayer); + } + + label391: + + while (true) + { + if (!this.gameSettings.keyBindAttack.isPressed()) + { + while (this.gameSettings.keyBindUseItem.isPressed()) + { + ; + } + + while (true) + { + if (this.gameSettings.keyBindPickBlock.isPressed()) + { + continue; + } + + break label391; + } + } + } + } + else + { + while (this.gameSettings.keyBindAttack.isPressed()) + { + this.func_147116_af(); + } + + while (this.gameSettings.keyBindUseItem.isPressed()) + { + this.func_147121_ag(); + } + + while (this.gameSettings.keyBindPickBlock.isPressed()) + { + this.func_147112_ai(); + } + } + + if (this.gameSettings.keyBindUseItem.getIsKeyPressed() && this.rightClickDelayTimer == 0 && !this.thePlayer.isUsingItem()) + { + this.func_147121_ag(); + } + + this.func_147115_a(this.currentScreen == null && this.gameSettings.keyBindAttack.getIsKeyPressed() && this.inGameHasFocus); + } + + if (this.theWorld != null) + { + if (this.thePlayer != null) + { + ++this.joinPlayerCounter; + + if (this.joinPlayerCounter == 30) + { + this.joinPlayerCounter = 0; + this.theWorld.joinEntityInSurroundings(this.thePlayer); + } + } + + this.mcProfiler.endStartSection("gameRenderer"); + + if (!this.isGamePaused) + { + this.entityRenderer.updateRenderer(); + } + + this.mcProfiler.endStartSection("levelRenderer"); + + if (!this.isGamePaused) + { + this.renderGlobal.updateClouds(); + } + + this.mcProfiler.endStartSection("level"); + + if (!this.isGamePaused) + { + if (this.theWorld.lastLightningBolt > 0) + { + --this.theWorld.lastLightningBolt; + } + + this.theWorld.updateEntities(); + } + } + + if (!this.isGamePaused) + { + this.mcMusicTicker.update(); + this.mcSoundHandler.update(); + } + + if (this.theWorld != null) + { + if (!this.isGamePaused) + { + this.theWorld.setAllowedSpawnTypes(this.theWorld.difficultySetting != EnumDifficulty.PEACEFUL, true); + + try + { + this.theWorld.tick(); + } + catch (Throwable throwable2) + { + crashreport = CrashReport.makeCrashReport(throwable2, "Exception in world tick"); + + if (this.theWorld == null) + { + crashreportcategory = crashreport.makeCategory("Affected level"); + crashreportcategory.addCrashSection("Problem", "Level is null!"); + } + else + { + this.theWorld.addWorldInfoToCrashReport(crashreport); + } + + throw new ReportedException(crashreport); + } + } + + this.mcProfiler.endStartSection("animateTick"); + + if (!this.isGamePaused && this.theWorld != null) + { + this.theWorld.doVoidFogParticles(MathHelper.floor_double(this.thePlayer.posX), MathHelper.floor_double(this.thePlayer.posY), MathHelper.floor_double(this.thePlayer.posZ)); + } + + this.mcProfiler.endStartSection("particles"); + + if (!this.isGamePaused) + { + this.effectRenderer.updateEffects(); + } + } + else if (this.myNetworkManager != null) + { + this.mcProfiler.endStartSection("pendingConnection"); + this.myNetworkManager.processReceivedPackets(); + } + + FMLCommonHandler.instance().onPostClientTick(); + + this.mcProfiler.endSection(); + this.systemTime = getSystemTime(); + } + + public void launchIntegratedServer(String par1Str, String par2Str, WorldSettings par3WorldSettings) + { + FMLClientHandler.instance().startIntegratedServer(par1Str, par2Str, par3WorldSettings); + this.loadWorld((WorldClient)null); + System.gc(); + ISaveHandler isavehandler = this.saveLoader.getSaveLoader(par1Str, false); + WorldInfo worldinfo = isavehandler.loadWorldInfo(); + + if (worldinfo == null && par3WorldSettings != null) + { + worldinfo = new WorldInfo(par3WorldSettings, par1Str); + isavehandler.saveWorldInfo(worldinfo); + } + + if (par3WorldSettings == null) + { + par3WorldSettings = new WorldSettings(worldinfo); + } + + try + { + this.theIntegratedServer = new IntegratedServer(this, par1Str, par2Str, par3WorldSettings); + this.theIntegratedServer.startServerThread(); + this.integratedServerIsRunning = true; + } + catch (Throwable throwable) + { + CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Starting integrated server"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("Starting integrated server"); + crashreportcategory.addCrashSection("Level ID", par1Str); + crashreportcategory.addCrashSection("Level Name", par2Str); + throw new ReportedException(crashreport); + } + + this.loadingScreen.displayProgressMessage(I18n.format("menu.loadingLevel", new Object[0])); + + while (!this.theIntegratedServer.serverIsInRunLoop()) + { + if (!StartupQuery.check()) + { + loadWorld(null); + displayGuiScreen(null); + return; + } + String s2 = this.theIntegratedServer.getUserMessage(); + + if (s2 != null) + { + this.loadingScreen.resetProgresAndWorkingMessage(I18n.format(s2, new Object[0])); + } + else + { + this.loadingScreen.resetProgresAndWorkingMessage(""); + } + + try + { + Thread.sleep(200L); + } + catch (InterruptedException interruptedexception) + { + ; + } + } + + this.displayGuiScreen((GuiScreen)null); + SocketAddress socketaddress = this.theIntegratedServer.func_147137_ag().addLocalEndpoint(); + NetworkManager networkmanager = NetworkManager.provideLocalClient(socketaddress); + networkmanager.setNetHandler(new NetHandlerLoginClient(networkmanager, this, (GuiScreen)null)); + networkmanager.scheduleOutboundPacket(new C00Handshake(4, socketaddress.toString(), 0, EnumConnectionState.LOGIN), new GenericFutureListener[0]); + networkmanager.scheduleOutboundPacket(new C00PacketLoginStart(this.getSession().func_148256_e()), new GenericFutureListener[0]); + this.myNetworkManager = networkmanager; + } + + public void loadWorld(WorldClient par1WorldClient) + { + this.loadWorld(par1WorldClient, ""); + } + + public void loadWorld(WorldClient par1WorldClient, String par2Str) + { + if (theWorld != null) + { + MinecraftForge.EVENT_BUS.post(new WorldEvent.Unload(theWorld)); + } + + if (par1WorldClient == null) + { + NetHandlerPlayClient nethandlerplayclient = this.getNetHandler(); + + if (nethandlerplayclient != null) + { + nethandlerplayclient.cleanup(); + } + + if (this.theIntegratedServer != null) + { + this.theIntegratedServer.initiateShutdown(); + if (loadingScreen != null) + { + this.loadingScreen.resetProgresAndWorkingMessage("Shutting down internal server..."); + } + while (!theIntegratedServer.isServerStopped()) + { + try + { + Thread.sleep(10); + } + catch (InterruptedException ie) {} + } + } + + this.theIntegratedServer = null; + this.guiAchievement.func_146257_b(); + this.entityRenderer.getMapItemRenderer().func_148249_a(); + } + + this.renderViewEntity = null; + this.myNetworkManager = null; + + if (this.loadingScreen != null) + { + this.loadingScreen.resetProgressAndMessage(par2Str); + this.loadingScreen.resetProgresAndWorkingMessage(""); + } + + if (par1WorldClient == null && this.theWorld != null) + { + if (this.mcResourcePackRepository.func_148530_e() != null) + { + this.scheduleResourcesRefresh(); + } + + this.mcResourcePackRepository.func_148529_f(); + this.setServerData((ServerData)null); + this.integratedServerIsRunning = false; + FMLClientHandler.instance().handleClientWorldClosing(this.theWorld); + } + + this.mcSoundHandler.stopSounds(); + this.theWorld = par1WorldClient; + + if (par1WorldClient != null) + { + if (this.renderGlobal != null) + { + this.renderGlobal.setWorldAndLoadRenderers(par1WorldClient); + } + + if (this.effectRenderer != null) + { + this.effectRenderer.clearEffects(par1WorldClient); + } + + if (this.thePlayer == null) + { + this.thePlayer = this.playerController.func_147493_a(par1WorldClient, new StatFileWriter()); + this.playerController.flipPlayer(this.thePlayer); + } + + this.thePlayer.preparePlayerToSpawn(); + par1WorldClient.spawnEntityInWorld(this.thePlayer); + this.thePlayer.movementInput = new MovementInputFromOptions(this.gameSettings); + this.playerController.setPlayerCapabilities(this.thePlayer); + this.renderViewEntity = this.thePlayer; + } + else + { + this.saveLoader.flushCache(); + this.thePlayer = null; + } + + System.gc(); + this.systemTime = 0L; + } + + public String debugInfoRenders() + { + return this.renderGlobal.getDebugInfoRenders(); + } + + public String getEntityDebug() + { + return this.renderGlobal.getDebugInfoEntities(); + } + + public String getWorldProviderName() + { + return this.theWorld.getProviderName(); + } + + public String debugInfoEntities() + { + return "P: " + this.effectRenderer.getStatistics() + ". T: " + this.theWorld.getDebugLoadedEntities(); + } + + public void setDimensionAndSpawnPlayer(int par1) + { + this.theWorld.setSpawnLocation(); + this.theWorld.removeAllEntities(); + int j = 0; + String s = null; + + if (this.thePlayer != null) + { + j = this.thePlayer.getEntityId(); + this.theWorld.removeEntity(this.thePlayer); + s = this.thePlayer.func_142021_k(); + } + + this.renderViewEntity = null; + this.thePlayer = this.playerController.func_147493_a(this.theWorld, this.thePlayer == null ? new StatFileWriter() : this.thePlayer.getStatFileWriter()); + this.thePlayer.dimension = par1; + this.renderViewEntity = this.thePlayer; + this.thePlayer.preparePlayerToSpawn(); + this.thePlayer.func_142020_c(s); + this.theWorld.spawnEntityInWorld(this.thePlayer); + this.playerController.flipPlayer(this.thePlayer); + this.thePlayer.movementInput = new MovementInputFromOptions(this.gameSettings); + this.thePlayer.setEntityId(j); + this.playerController.setPlayerCapabilities(this.thePlayer); + + if (this.currentScreen instanceof GuiGameOver) + { + this.displayGuiScreen((GuiScreen)null); + } + } + + public final boolean isDemo() + { + return this.isDemo; + } + + public NetHandlerPlayClient getNetHandler() + { + return this.thePlayer != null ? this.thePlayer.sendQueue : null; + } + + public static boolean isGuiEnabled() + { + return theMinecraft == null || !theMinecraft.gameSettings.hideGUI; + } + + public static boolean isFancyGraphicsEnabled() + { + return theMinecraft != null && theMinecraft.gameSettings.fancyGraphics; + } + + public static boolean isAmbientOcclusionEnabled() + { + return theMinecraft != null && theMinecraft.gameSettings.ambientOcclusion != 0; + } + + private void func_147112_ai() + { + if (this.objectMouseOver != null) + { + boolean flag = this.thePlayer.capabilities.isCreativeMode; + int j; + + if (!ForgeHooks.onPickBlock(this.objectMouseOver, this.thePlayer, this.theWorld)) return; + // We delete this code wholly instead of commenting it out, to make sure we detect changes in it between MC versions + if (flag) + { + j = this.thePlayer.inventoryContainer.inventorySlots.size() - 9 + this.thePlayer.inventory.currentItem; + this.playerController.sendSlotPacket(this.thePlayer.inventory.getStackInSlot(this.thePlayer.inventory.currentItem), j); + } + } + } + + public CrashReport addGraphicsAndWorldToCrashReport(CrashReport par1CrashReport) + { + par1CrashReport.getCategory().addCrashSectionCallable("Launched Version", new Callable() + { + private static final String __OBFID = "CL_00000643"; + public String call() + { + return Minecraft.this.launchedVersion; + } + }); + par1CrashReport.getCategory().addCrashSectionCallable("LWJGL", new Callable() + { + private static final String __OBFID = "CL_00000644"; + public String call() + { + return Sys.getVersion(); + } + }); + par1CrashReport.getCategory().addCrashSectionCallable("OpenGL", new Callable() + { + private static final String __OBFID = "CL_00000645"; + public String call() + { + return GL11.glGetString(GL11.GL_RENDERER) + " GL version " + GL11.glGetString(GL11.GL_VERSION) + ", " + GL11.glGetString(GL11.GL_VENDOR); + } + }); + par1CrashReport.getCategory().addCrashSectionCallable("Is Modded", new Callable() + { + private static final String __OBFID = "CL_00000646"; + public String call() + { + String s = ClientBrandRetriever.getClientModName(); + return !s.equals("vanilla") ? "Definitely; Client brand changed to \'" + s + "\'" : (Minecraft.class.getSigners() == null ? "Very likely; Jar signature invalidated" : "Probably not. Jar signature remains and client brand is untouched."); + } + }); + par1CrashReport.getCategory().addCrashSectionCallable("Type", new Callable() + { + private static final String __OBFID = "CL_00000647"; + public String call() + { + return "Client (map_client.txt)"; + } + }); + par1CrashReport.getCategory().addCrashSectionCallable("Resource Packs", new Callable() + { + private static final String __OBFID = "CL_00000633"; + public String call() + { + return Minecraft.this.gameSettings.resourcePacks.toString(); + } + }); + par1CrashReport.getCategory().addCrashSectionCallable("Current Language", new Callable() + { + private static final String __OBFID = "CL_00000634"; + public String call() + { + return Minecraft.this.mcLanguageManager.getCurrentLanguage().toString(); + } + }); + par1CrashReport.getCategory().addCrashSectionCallable("Profiler Position", new Callable() + { + private static final String __OBFID = "CL_00000635"; + public String call() + { + return Minecraft.this.mcProfiler.profilingEnabled ? Minecraft.this.mcProfiler.getNameOfLastSection() : "N/A (disabled)"; + } + }); + par1CrashReport.getCategory().addCrashSectionCallable("Vec3 Pool Size", new Callable() + { + private static final String __OBFID = "CL_00000636"; + public String call() + { + int i = Minecraft.this.theWorld.getWorldVec3Pool().getPoolSize(); + int j = 56 * i; + int k = j / 1024 / 1024; + int l = Minecraft.this.theWorld.getWorldVec3Pool().getNextFreeSpace(); + int i1 = 56 * l; + int j1 = i1 / 1024 / 1024; + return i + " (" + j + " bytes; " + k + " MB) allocated, " + l + " (" + i1 + " bytes; " + j1 + " MB) used"; + } + }); + par1CrashReport.getCategory().addCrashSectionCallable("Anisotropic Filtering", new Callable() + { + private static final String __OBFID = "CL_00000637"; + public String call() + { + return Minecraft.this.gameSettings.anisotropicFiltering == 1 ? "Off (1)" : "On (" + Minecraft.this.gameSettings.anisotropicFiltering + ")"; + } + }); + + if (this.theWorld != null) + { + this.theWorld.addWorldInfoToCrashReport(par1CrashReport); + } + + return par1CrashReport; + } + + public static Minecraft getMinecraft() + { + return theMinecraft; + } + + public void scheduleResourcesRefresh() + { + this.refreshTexturePacksScheduled = true; + } + + public void addServerStatsToSnooper(PlayerUsageSnooper par1PlayerUsageSnooper) + { + par1PlayerUsageSnooper.addData("fps", Integer.valueOf(debugFPS)); + par1PlayerUsageSnooper.addData("vsync_enabled", Boolean.valueOf(this.gameSettings.enableVsync)); + par1PlayerUsageSnooper.addData("display_frequency", Integer.valueOf(Display.getDisplayMode().getFrequency())); + par1PlayerUsageSnooper.addData("display_type", this.fullscreen ? "fullscreen" : "windowed"); + par1PlayerUsageSnooper.addData("run_time", Long.valueOf((MinecraftServer.getSystemTimeMillis() - par1PlayerUsageSnooper.getMinecraftStartTimeMillis()) / 60L * 1000L)); + par1PlayerUsageSnooper.addData("resource_packs", Integer.valueOf(this.mcResourcePackRepository.getRepositoryEntries().size())); + int i = 0; + Iterator iterator = this.mcResourcePackRepository.getRepositoryEntries().iterator(); + + while (iterator.hasNext()) + { + ResourcePackRepository.Entry entry = (ResourcePackRepository.Entry)iterator.next(); + par1PlayerUsageSnooper.addData("resource_pack[" + i++ + "]", entry.getResourcePackName()); + } + + if (this.theIntegratedServer != null && this.theIntegratedServer.getPlayerUsageSnooper() != null) + { + par1PlayerUsageSnooper.addData("snooper_partner", this.theIntegratedServer.getPlayerUsageSnooper().getUniqueID()); + } + } + + public void addServerTypeToSnooper(PlayerUsageSnooper par1PlayerUsageSnooper) + { + par1PlayerUsageSnooper.addData("opengl_version", GL11.glGetString(GL11.GL_VERSION)); + par1PlayerUsageSnooper.addData("opengl_vendor", GL11.glGetString(GL11.GL_VENDOR)); + par1PlayerUsageSnooper.addData("client_brand", ClientBrandRetriever.getClientModName()); + par1PlayerUsageSnooper.addData("launched_version", this.launchedVersion); + ContextCapabilities contextcapabilities = GLContext.getCapabilities(); + par1PlayerUsageSnooper.addData("gl_caps[ARB_multitexture]", Boolean.valueOf(contextcapabilities.GL_ARB_multitexture)); + par1PlayerUsageSnooper.addData("gl_caps[ARB_multisample]", Boolean.valueOf(contextcapabilities.GL_ARB_multisample)); + par1PlayerUsageSnooper.addData("gl_caps[ARB_texture_cube_map]", Boolean.valueOf(contextcapabilities.GL_ARB_texture_cube_map)); + par1PlayerUsageSnooper.addData("gl_caps[ARB_vertex_blend]", Boolean.valueOf(contextcapabilities.GL_ARB_vertex_blend)); + par1PlayerUsageSnooper.addData("gl_caps[ARB_matrix_palette]", Boolean.valueOf(contextcapabilities.GL_ARB_matrix_palette)); + par1PlayerUsageSnooper.addData("gl_caps[ARB_vertex_program]", Boolean.valueOf(contextcapabilities.GL_ARB_vertex_program)); + par1PlayerUsageSnooper.addData("gl_caps[ARB_vertex_shader]", Boolean.valueOf(contextcapabilities.GL_ARB_vertex_shader)); + par1PlayerUsageSnooper.addData("gl_caps[ARB_fragment_program]", Boolean.valueOf(contextcapabilities.GL_ARB_fragment_program)); + par1PlayerUsageSnooper.addData("gl_caps[ARB_fragment_shader]", Boolean.valueOf(contextcapabilities.GL_ARB_fragment_shader)); + par1PlayerUsageSnooper.addData("gl_caps[ARB_shader_objects]", Boolean.valueOf(contextcapabilities.GL_ARB_shader_objects)); + par1PlayerUsageSnooper.addData("gl_caps[ARB_vertex_buffer_object]", Boolean.valueOf(contextcapabilities.GL_ARB_vertex_buffer_object)); + par1PlayerUsageSnooper.addData("gl_caps[ARB_framebuffer_object]", Boolean.valueOf(contextcapabilities.GL_ARB_framebuffer_object)); + par1PlayerUsageSnooper.addData("gl_caps[ARB_pixel_buffer_object]", Boolean.valueOf(contextcapabilities.GL_ARB_pixel_buffer_object)); + par1PlayerUsageSnooper.addData("gl_caps[ARB_uniform_buffer_object]", Boolean.valueOf(contextcapabilities.GL_ARB_uniform_buffer_object)); + par1PlayerUsageSnooper.addData("gl_caps[ARB_texture_non_power_of_two]", Boolean.valueOf(contextcapabilities.GL_ARB_texture_non_power_of_two)); + par1PlayerUsageSnooper.addData("gl_caps[gl_max_vertex_uniforms]", Integer.valueOf(GL11.glGetInteger(GL20.GL_MAX_VERTEX_UNIFORM_COMPONENTS))); + par1PlayerUsageSnooper.addData("gl_caps[gl_max_fragment_uniforms]", Integer.valueOf(GL11.glGetInteger(GL20.GL_MAX_FRAGMENT_UNIFORM_COMPONENTS))); + par1PlayerUsageSnooper.addData("gl_max_texture_size", Integer.valueOf(getGLMaximumTextureSize())); + } + + //Forge: Adds a optimization to the getGLMaximumTextureSize, only calculate it once. + private static int max_texture_size = -1; + public static int getGLMaximumTextureSize() + { + if (max_texture_size != -1) + { + return max_texture_size; + } + + for (int i = 16384; i > 0; i >>= 1) + { + GL11.glTexImage2D(GL11.GL_PROXY_TEXTURE_2D, 0, GL11.GL_RGBA, i, i, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer)null); + int j = GL11.glGetTexLevelParameteri(GL11.GL_PROXY_TEXTURE_2D, 0, GL11.GL_TEXTURE_WIDTH); + + if (j != 0) + { + max_texture_size = i; + return i; + } + } + + return -1; + } + + public boolean isSnooperEnabled() + { + return this.gameSettings.snooperEnabled; + } + + public void setServerData(ServerData par1ServerData) + { + this.currentServerData = par1ServerData; + } + + public ServerData func_147104_D() + { + return this.currentServerData; + } + + public boolean isIntegratedServerRunning() + { + return this.integratedServerIsRunning; + } + + public boolean isSingleplayer() + { + return this.integratedServerIsRunning && this.theIntegratedServer != null; + } + + public IntegratedServer getIntegratedServer() + { + return this.theIntegratedServer; + } + + public static void stopIntegratedServer() + { + if (theMinecraft != null) + { + IntegratedServer integratedserver = theMinecraft.getIntegratedServer(); + + if (integratedserver != null) + { + integratedserver.stopServer(); + } + } + } + + public PlayerUsageSnooper getPlayerUsageSnooper() + { + return this.usageSnooper; + } + + public static long getSystemTime() + { + return Sys.getTime() * 1000L / Sys.getTimerResolution(); + } + + public boolean isFullScreen() + { + return this.fullscreen; + } + + public Session getSession() + { + return this.session; + } + + public Proxy getProxy() + { + return this.proxy; + } + + public TextureManager getTextureManager() + { + return this.renderEngine; + } + + public IResourceManager getResourceManager() + { + return this.mcResourceManager; + } + + public ResourcePackRepository getResourcePackRepository() + { + return this.mcResourcePackRepository; + } + + public LanguageManager getLanguageManager() + { + return this.mcLanguageManager; + } + + public TextureMap getTextureMapBlocks() + { + return this.textureMapBlocks; + } + + public boolean isJava64bit() + { + return this.jvm64bit; + } + + public boolean isGamePaused() + { + return this.isGamePaused; + } + + public SoundHandler getSoundHandler() + { + return this.mcSoundHandler; + } + + public MusicTicker.MusicType func_147109_W() + { + return this.currentScreen instanceof GuiWinGame ? MusicTicker.MusicType.CREDITS : (this.thePlayer != null ? (this.thePlayer.worldObj.provider instanceof WorldProviderHell ? MusicTicker.MusicType.NETHER : (this.thePlayer.worldObj.provider instanceof WorldProviderEnd ? (BossStatus.bossName != null && BossStatus.statusBarTime > 0 ? MusicTicker.MusicType.END_BOSS : MusicTicker.MusicType.END) : (this.thePlayer.capabilities.isCreativeMode && this.thePlayer.capabilities.allowFlying ? MusicTicker.MusicType.CREATIVE : MusicTicker.MusicType.GAME))) : MusicTicker.MusicType.MENU); + } + + @SideOnly(Side.CLIENT) + + static final class SwitchMovingObjectType + { + static final int[] field_151437_a = new int[MovingObjectPosition.MovingObjectType.values().length]; + private static final String __OBFID = "CL_00000638"; + + static + { + try + { + field_151437_a[MovingObjectPosition.MovingObjectType.ENTITY.ordinal()] = 1; + } + catch (NoSuchFieldError var2) + { + ; + } + + try + { + field_151437_a[MovingObjectPosition.MovingObjectType.BLOCK.ordinal()] = 2; + } + catch (NoSuchFieldError var1) + { + ; + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/audio/ISound.java b/src/main/java/net/minecraft/client/audio/ISound.java new file mode 100644 index 0000000..62b7055 --- /dev/null +++ b/src/main/java/net/minecraft/client/audio/ISound.java @@ -0,0 +1,47 @@ +package net.minecraft.client.audio; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.util.ResourceLocation; + +@SideOnly(Side.CLIENT) +public interface ISound +{ + ResourceLocation getPositionedSoundLocation(); + + boolean canRepeat(); + + int getRepeatDelay(); + + float getVolume(); + + float getPitch(); + + float getXPosF(); + + float getYPosF(); + + float getZPosF(); + + ISound.AttenuationType getAttenuationType(); + + @SideOnly(Side.CLIENT) + public static enum AttenuationType + { + NONE(0), + LINEAR(2); + private final int field_148589_c; + + private static final String __OBFID = "CL_00001126"; + + private AttenuationType(int p_i45110_3_) + { + this.field_148589_c = p_i45110_3_; + } + + public int getTypeInt() + { + return this.field_148589_c; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/audio/ISoundEventAccessor.java b/src/main/java/net/minecraft/client/audio/ISoundEventAccessor.java new file mode 100644 index 0000000..f55c525 --- /dev/null +++ b/src/main/java/net/minecraft/client/audio/ISoundEventAccessor.java @@ -0,0 +1,12 @@ +package net.minecraft.client.audio; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public interface ISoundEventAccessor +{ + int func_148721_a(); + + Object func_148720_g(); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/audio/ITickableSound.java b/src/main/java/net/minecraft/client/audio/ITickableSound.java new file mode 100644 index 0000000..47211c7 --- /dev/null +++ b/src/main/java/net/minecraft/client/audio/ITickableSound.java @@ -0,0 +1,11 @@ +package net.minecraft.client.audio; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.server.gui.IUpdatePlayerListBox; + +@SideOnly(Side.CLIENT) +public interface ITickableSound extends ISound, IUpdatePlayerListBox +{ + boolean isDonePlaying(); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/audio/MovingSound.java b/src/main/java/net/minecraft/client/audio/MovingSound.java new file mode 100644 index 0000000..726ec1e --- /dev/null +++ b/src/main/java/net/minecraft/client/audio/MovingSound.java @@ -0,0 +1,22 @@ +package net.minecraft.client.audio; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.util.ResourceLocation; + +@SideOnly(Side.CLIENT) +public abstract class MovingSound extends PositionedSound implements ITickableSound +{ + protected boolean donePlaying = false; + private static final String __OBFID = "CL_00001117"; + + protected MovingSound(ResourceLocation p_i45104_1_) + { + super(p_i45104_1_); + } + + public boolean isDonePlaying() + { + return this.donePlaying; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/audio/MovingSoundMinecart.java b/src/main/java/net/minecraft/client/audio/MovingSoundMinecart.java new file mode 100644 index 0000000..a6c359f --- /dev/null +++ b/src/main/java/net/minecraft/client/audio/MovingSoundMinecart.java @@ -0,0 +1,49 @@ +package net.minecraft.client.audio; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.item.EntityMinecart; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; + +@SideOnly(Side.CLIENT) +public class MovingSoundMinecart extends MovingSound +{ + private final EntityMinecart field_147670_k; + private float field_147669_l = 0.0F; + private static final String __OBFID = "CL_00001118"; + + public MovingSoundMinecart(EntityMinecart p_i45105_1_) + { + super(new ResourceLocation("minecraft:minecart.base")); + this.field_147670_k = p_i45105_1_; + this.repeat = true; + this.field_147665_h = 0; + } + + public void update() + { + if (this.field_147670_k.isDead) + { + this.donePlaying = true; + } + else + { + this.xPosF = (float)this.field_147670_k.posX; + this.yPosF = (float)this.field_147670_k.posY; + this.zPosF = (float)this.field_147670_k.posZ; + float f = MathHelper.sqrt_double(this.field_147670_k.motionX * this.field_147670_k.motionX + this.field_147670_k.motionZ * this.field_147670_k.motionZ); + + if ((double)f >= 0.01D) + { + this.field_147669_l = MathHelper.clamp_float(this.field_147669_l + 0.0025F, 0.0F, 1.0F); + this.volume = 0.0F + MathHelper.clamp_float(f, 0.0F, 0.5F) * 0.7F; + } + else + { + this.field_147669_l = 0.0F; + this.volume = 0.0F; + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/audio/MovingSoundMinecartRiding.java b/src/main/java/net/minecraft/client/audio/MovingSoundMinecartRiding.java new file mode 100644 index 0000000..e13020a --- /dev/null +++ b/src/main/java/net/minecraft/client/audio/MovingSoundMinecartRiding.java @@ -0,0 +1,47 @@ +package net.minecraft.client.audio; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.item.EntityMinecart; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; + +@SideOnly(Side.CLIENT) +public class MovingSoundMinecartRiding extends MovingSound +{ + private final EntityPlayer field_147672_k; + private final EntityMinecart field_147671_l; + private static final String __OBFID = "CL_00001119"; + + public MovingSoundMinecartRiding(EntityPlayer p_i45106_1_, EntityMinecart p_i45106_2_) + { + super(new ResourceLocation("minecraft:minecart.inside")); + this.field_147672_k = p_i45106_1_; + this.field_147671_l = p_i45106_2_; + this.field_147666_i = ISound.AttenuationType.NONE; + this.repeat = true; + this.field_147665_h = 0; + } + + public void update() + { + if (!this.field_147671_l.isDead && this.field_147672_k.isRiding() && this.field_147672_k.ridingEntity == this.field_147671_l) + { + float f = MathHelper.sqrt_double(this.field_147671_l.motionX * this.field_147671_l.motionX + this.field_147671_l.motionZ * this.field_147671_l.motionZ); + + if ((double)f >= 0.01D) + { + this.volume = 0.0F + MathHelper.clamp_float(f, 0.0F, 1.0F) * 0.75F; + } + else + { + this.volume = 0.0F; + } + } + else + { + this.donePlaying = true; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/audio/MusicTicker.java b/src/main/java/net/minecraft/client/audio/MusicTicker.java new file mode 100644 index 0000000..937ee3d --- /dev/null +++ b/src/main/java/net/minecraft/client/audio/MusicTicker.java @@ -0,0 +1,90 @@ +package net.minecraft.client.audio; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.client.Minecraft; +import net.minecraft.server.gui.IUpdatePlayerListBox; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; + +@SideOnly(Side.CLIENT) +public class MusicTicker implements IUpdatePlayerListBox +{ + private final Random field_147679_a = new Random(); + private final Minecraft field_147677_b; + private ISound field_147678_c; + private int field_147676_d = 100; + private static final String __OBFID = "CL_00001138"; + + public MusicTicker(Minecraft p_i45112_1_) + { + this.field_147677_b = p_i45112_1_; + } + + public void update() + { + MusicTicker.MusicType musictype = this.field_147677_b.func_147109_W(); + + if (this.field_147678_c != null) + { + if (!musictype.getMusicTickerLocation().equals(this.field_147678_c.getPositionedSoundLocation())) + { + this.field_147677_b.getSoundHandler().stopSound(this.field_147678_c); + this.field_147676_d = MathHelper.getRandomIntegerInRange(this.field_147679_a, 0, musictype.func_148634_b() / 2); + } + + if (!this.field_147677_b.getSoundHandler().isSoundPlaying(this.field_147678_c)) + { + this.field_147678_c = null; + this.field_147676_d = Math.min(MathHelper.getRandomIntegerInRange(this.field_147679_a, musictype.func_148634_b(), musictype.func_148633_c()), this.field_147676_d); + } + } + + if (this.field_147678_c == null && this.field_147676_d-- <= 0) + { + this.field_147678_c = PositionedSoundRecord.func_147673_a(musictype.getMusicTickerLocation()); + this.field_147677_b.getSoundHandler().playSound(this.field_147678_c); + this.field_147676_d = Integer.MAX_VALUE; + } + } + + @SideOnly(Side.CLIENT) + public static enum MusicType + { + MENU(new ResourceLocation("minecraft:music.menu"), 20, 600), + GAME(new ResourceLocation("minecraft:music.game"), 12000, 24000), + CREATIVE(new ResourceLocation("minecraft:music.game.creative"), 1200, 3600), + CREDITS(new ResourceLocation("minecraft:music.game.end.credits"), Integer.MAX_VALUE, Integer.MAX_VALUE), + NETHER(new ResourceLocation("minecraft:music.game.nether"), 1200, 3600), + END_BOSS(new ResourceLocation("minecraft:music.game.end.dragon"), 0, 0), + END(new ResourceLocation("minecraft:music.game.end"), 6000, 24000); + private final ResourceLocation field_148645_h; + private final int field_148646_i; + private final int field_148643_j; + + private static final String __OBFID = "CL_00001139"; + + private MusicType(ResourceLocation p_i45111_3_, int p_i45111_4_, int p_i45111_5_) + { + this.field_148645_h = p_i45111_3_; + this.field_148646_i = p_i45111_4_; + this.field_148643_j = p_i45111_5_; + } + + public ResourceLocation getMusicTickerLocation() + { + return this.field_148645_h; + } + + public int func_148634_b() + { + return this.field_148646_i; + } + + public int func_148633_c() + { + return this.field_148643_j; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/audio/PositionedSound.java b/src/main/java/net/minecraft/client/audio/PositionedSound.java new file mode 100644 index 0000000..f5d2bbd --- /dev/null +++ b/src/main/java/net/minecraft/client/audio/PositionedSound.java @@ -0,0 +1,71 @@ +package net.minecraft.client.audio; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.util.ResourceLocation; + +@SideOnly(Side.CLIENT) +public abstract class PositionedSound implements ISound +{ + protected final ResourceLocation field_147664_a; + protected float volume = 1.0F; + protected float field_147663_c = 1.0F; + protected float xPosF; + protected float yPosF; + protected float zPosF; + protected boolean repeat = false; + protected int field_147665_h = 0; + protected ISound.AttenuationType field_147666_i; + private static final String __OBFID = "CL_00001116"; + + protected PositionedSound(ResourceLocation p_i45103_1_) + { + this.field_147666_i = ISound.AttenuationType.LINEAR; + this.field_147664_a = p_i45103_1_; + } + + public ResourceLocation getPositionedSoundLocation() + { + return this.field_147664_a; + } + + public boolean canRepeat() + { + return this.repeat; + } + + public int getRepeatDelay() + { + return this.field_147665_h; + } + + public float getVolume() + { + return this.volume; + } + + public float getPitch() + { + return this.field_147663_c; + } + + public float getXPosF() + { + return this.xPosF; + } + + public float getYPosF() + { + return this.yPosF; + } + + public float getZPosF() + { + return this.zPosF; + } + + public ISound.AttenuationType getAttenuationType() + { + return this.field_147666_i; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/audio/PositionedSoundRecord.java b/src/main/java/net/minecraft/client/audio/PositionedSoundRecord.java new file mode 100644 index 0000000..694ba01 --- /dev/null +++ b/src/main/java/net/minecraft/client/audio/PositionedSoundRecord.java @@ -0,0 +1,44 @@ +package net.minecraft.client.audio; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.util.ResourceLocation; + +@SideOnly(Side.CLIENT) +public class PositionedSoundRecord extends PositionedSound +{ + private static final String __OBFID = "CL_00001120"; + + public static PositionedSoundRecord func_147674_a(ResourceLocation p_147674_0_, float p_147674_1_) + { + return new PositionedSoundRecord(p_147674_0_, 0.25F, p_147674_1_, false, 0, ISound.AttenuationType.NONE, 0.0F, 0.0F, 0.0F); + } + + public static PositionedSoundRecord func_147673_a(ResourceLocation p_147673_0_) + { + return new PositionedSoundRecord(p_147673_0_, 1.0F, 1.0F, false, 0, ISound.AttenuationType.NONE, 0.0F, 0.0F, 0.0F); + } + + public static PositionedSoundRecord func_147675_a(ResourceLocation p_147675_0_, float p_147675_1_, float p_147675_2_, float p_147675_3_) + { + return new PositionedSoundRecord(p_147675_0_, 4.0F, 1.0F, false, 0, ISound.AttenuationType.LINEAR, p_147675_1_, p_147675_2_, p_147675_3_); + } + + public PositionedSoundRecord(ResourceLocation p_i45107_1_, float p_i45107_2_, float p_i45107_3_, float p_i45107_4_, float p_i45107_5_, float p_i45107_6_) + { + this(p_i45107_1_, p_i45107_2_, p_i45107_3_, false, 0, ISound.AttenuationType.LINEAR, p_i45107_4_, p_i45107_5_, p_i45107_6_); + } + + private PositionedSoundRecord(ResourceLocation p_i45108_1_, float p_i45108_2_, float p_i45108_3_, boolean p_i45108_4_, int p_i45108_5_, ISound.AttenuationType p_i45108_6_, float p_i45108_7_, float p_i45108_8_, float p_i45108_9_) + { + super(p_i45108_1_); + this.volume = p_i45108_2_; + this.field_147663_c = p_i45108_3_; + this.xPosF = p_i45108_7_; + this.yPosF = p_i45108_8_; + this.zPosF = p_i45108_9_; + this.repeat = p_i45108_4_; + this.field_147665_h = p_i45108_5_; + this.field_147666_i = p_i45108_6_; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/audio/SoundCategory.java b/src/main/java/net/minecraft/client/audio/SoundCategory.java new file mode 100644 index 0000000..01540db --- /dev/null +++ b/src/main/java/net/minecraft/client/audio/SoundCategory.java @@ -0,0 +1,66 @@ +package net.minecraft.client.audio; + +import com.google.common.collect.Maps; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Map; + +@SideOnly(Side.CLIENT) +public enum SoundCategory +{ + MASTER("master", 0), + MUSIC("music", 1), + RECORDS("record", 2), + WEATHER("weather", 3), + BLOCKS("block", 4), + MOBS("hostile", 5), + ANIMALS("neutral", 6), + PLAYERS("player", 7), + AMBIENT("ambient", 8); + private static final Map field_147168_j = Maps.newHashMap(); + private static final Map field_147169_k = Maps.newHashMap(); + private final String categoryName; + private final int categoryId; + + private static final String __OBFID = "CL_00001686"; + + private SoundCategory(String p_i45126_3_, int p_i45126_4_) + { + this.categoryName = p_i45126_3_; + this.categoryId = p_i45126_4_; + } + + public String getCategoryName() + { + return this.categoryName; + } + + public int getCategoryId() + { + return this.categoryId; + } + + public static SoundCategory func_147154_a(String p_147154_0_) + { + return (SoundCategory)field_147168_j.get(p_147154_0_); + } + + static + { + SoundCategory[] var0 = values(); + int var1 = var0.length; + + for (int var2 = 0; var2 < var1; ++var2) + { + SoundCategory var3 = var0[var2]; + + if (field_147168_j.containsKey(var3.getCategoryName()) || field_147169_k.containsKey(Integer.valueOf(var3.getCategoryId()))) + { + throw new Error("Clash in Sound Category ID & Name pools! Cannot insert " + var3); + } + + field_147168_j.put(var3.getCategoryName(), var3); + field_147169_k.put(Integer.valueOf(var3.getCategoryId()), var3); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/audio/SoundEventAccessor.java b/src/main/java/net/minecraft/client/audio/SoundEventAccessor.java new file mode 100644 index 0000000..59bffcf --- /dev/null +++ b/src/main/java/net/minecraft/client/audio/SoundEventAccessor.java @@ -0,0 +1,28 @@ +package net.minecraft.client.audio; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class SoundEventAccessor implements ISoundEventAccessor +{ + private final SoundPoolEntry field_148739_a; + private final int field_148738_b; + private static final String __OBFID = "CL_00001153"; + + SoundEventAccessor(SoundPoolEntry p_i45123_1_, int p_i45123_2_) + { + this.field_148739_a = p_i45123_1_; + this.field_148738_b = p_i45123_2_; + } + + public int func_148721_a() + { + return this.field_148738_b; + } + + public SoundPoolEntry func_148720_g() + { + return new SoundPoolEntry(this.field_148739_a); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/audio/SoundEventAccessorComposite.java b/src/main/java/net/minecraft/client/audio/SoundEventAccessorComposite.java new file mode 100644 index 0000000..cbfdbd9 --- /dev/null +++ b/src/main/java/net/minecraft/client/audio/SoundEventAccessorComposite.java @@ -0,0 +1,90 @@ +package net.minecraft.client.audio; + +import com.google.common.collect.Lists; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import net.minecraft.util.ResourceLocation; + +@SideOnly(Side.CLIENT) +public class SoundEventAccessorComposite implements ISoundEventAccessor +{ + private final List soundPool = Lists.newArrayList(); + private final Random rnd = new Random(); + private final ResourceLocation field_148735_c; + private final SoundCategory field_148732_d; + private double eventPitch; + private double eventVolume; + private static final String __OBFID = "CL_00001146"; + + public SoundEventAccessorComposite(ResourceLocation p_i45120_1_, double p_i45120_2_, double p_i45120_4_, SoundCategory p_i45120_6_) + { + this.field_148735_c = p_i45120_1_; + this.eventVolume = p_i45120_4_; + this.eventPitch = p_i45120_2_; + this.field_148732_d = p_i45120_6_; + } + + public int func_148721_a() + { + int i = 0; + ISoundEventAccessor isoundeventaccessor; + + for (Iterator iterator = this.soundPool.iterator(); iterator.hasNext(); i += isoundeventaccessor.func_148721_a()) + { + isoundeventaccessor = (ISoundEventAccessor)iterator.next(); + } + + return i; + } + + public SoundPoolEntry func_148720_g() + { + int i = this.func_148721_a(); + + if (!this.soundPool.isEmpty() && i != 0) + { + int j = this.rnd.nextInt(i); + Iterator iterator = this.soundPool.iterator(); + ISoundEventAccessor isoundeventaccessor; + + do + { + if (!iterator.hasNext()) + { + return SoundHandler.missing_sound; + } + + isoundeventaccessor = (ISoundEventAccessor)iterator.next(); + j -= isoundeventaccessor.func_148721_a(); + } + while (j >= 0); + + SoundPoolEntry soundpoolentry = (SoundPoolEntry)isoundeventaccessor.func_148720_g(); + soundpoolentry.setPitch(soundpoolentry.getPitch() * this.eventPitch); + soundpoolentry.setVolume(soundpoolentry.getVolume() * this.eventVolume); + return soundpoolentry; + } + else + { + return SoundHandler.missing_sound; + } + } + + public void addSoundToEventPool(ISoundEventAccessor p_148727_1_) + { + this.soundPool.add(p_148727_1_); + } + + public ResourceLocation getSoundEventLocation() + { + return this.field_148735_c; + } + + public SoundCategory getSoundCategory() + { + return this.field_148732_d; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/audio/SoundHandler.java b/src/main/java/net/minecraft/client/audio/SoundHandler.java new file mode 100644 index 0000000..5c6786c --- /dev/null +++ b/src/main/java/net/minecraft/client/audio/SoundHandler.java @@ -0,0 +1,295 @@ +package net.minecraft.client.audio; + +import com.google.common.collect.Lists; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStreamReader; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.Map.Entry; +import net.minecraft.client.resources.IResource; +import net.minecraft.client.resources.IResourceManager; +import net.minecraft.client.resources.IResourceManagerReloadListener; +import net.minecraft.client.settings.GameSettings; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.server.gui.IUpdatePlayerListBox; +import net.minecraft.util.ResourceLocation; +import org.apache.commons.lang3.ArrayUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +@SideOnly(Side.CLIENT) +public class SoundHandler implements IResourceManagerReloadListener, IUpdatePlayerListBox +{ + private static final Logger logger = LogManager.getLogger(); + private static final Gson field_147699_c = (new GsonBuilder()).registerTypeAdapter(SoundList.class, new SoundListSerializer()).create(); + private static final ParameterizedType field_147696_d = new ParameterizedType() + { + private static final String __OBFID = "CL_00001148"; + public Type[] getActualTypeArguments() + { + return new Type[] {String.class, SoundList.class}; + } + public Type getRawType() + { + return Map.class; + } + public Type getOwnerType() + { + return null; + } + }; + public static final SoundPoolEntry missing_sound = new SoundPoolEntry(new ResourceLocation("meta:missing_sound"), 0.0D, 0.0D, false); + private final SoundRegistry sndRegistry = new SoundRegistry(); + private final SoundManager sndManager; + private final IResourceManager mcResourceManager; + private static final String __OBFID = "CL_00001147"; + + public SoundHandler(IResourceManager p_i45122_1_, GameSettings p_i45122_2_) + { + this.mcResourceManager = p_i45122_1_; + this.sndManager = new SoundManager(this, p_i45122_2_); + } + + public void onResourceManagerReload(IResourceManager par1ResourceManager) + { + this.sndManager.reloadSoundSystem(); + this.sndRegistry.func_148763_c(); + Iterator iterator = par1ResourceManager.getResourceDomains().iterator(); + + while (iterator.hasNext()) + { + String s = (String)iterator.next(); + + try + { + List list = par1ResourceManager.getAllResources(new ResourceLocation(s, "sounds.json")); + + for (int i = list.size() - 1; i >= 0; --i) + { + IResource iresource = (IResource)list.get(i); + + try + { + Map map = (Map)field_147699_c.fromJson(new InputStreamReader(iresource.getInputStream()), field_147696_d); + Iterator iterator1 = map.entrySet().iterator(); + + while (iterator1.hasNext()) + { + Entry entry = (Entry)iterator1.next(); + this.loadSoundResource(new ResourceLocation(s, (String)entry.getKey()), (SoundList)entry.getValue()); + } + } + catch (RuntimeException runtimeexception) + { + logger.warn("Invalid sounds.json", runtimeexception); + } + } + } + catch (IOException ioexception) + { + ; + } + } + } + + private void loadSoundResource(ResourceLocation p_147693_1_, SoundList p_147693_2_) + { + SoundEventAccessorComposite soundeventaccessorcomposite; + + if (this.sndRegistry.containsKey(p_147693_1_) && !p_147693_2_.canReplaceExisting()) + { + soundeventaccessorcomposite = (SoundEventAccessorComposite)this.sndRegistry.getObject(p_147693_1_); + } + else + { + soundeventaccessorcomposite = new SoundEventAccessorComposite(p_147693_1_, 1.0D, 1.0D, p_147693_2_.getSoundCategory()); + this.sndRegistry.registerSound(soundeventaccessorcomposite); + } + + Iterator iterator = p_147693_2_.getSoundList().iterator(); + + while (iterator.hasNext()) + { + final SoundList.SoundEntry soundentry = (SoundList.SoundEntry)iterator.next(); + String s = soundentry.getSoundEntryName(); + ResourceLocation resourcelocation1 = new ResourceLocation(s); + final String s1 = s.contains(":") ? resourcelocation1.getResourceDomain() : p_147693_1_.getResourceDomain(); + Object object; + + switch (SoundHandler.SwitchType.field_148765_a[soundentry.getSoundEntryType().ordinal()]) + { + case 1: + ResourceLocation resourcelocation2 = new ResourceLocation(s1, "sounds/" + resourcelocation1.getResourcePath() + ".ogg"); + + try + { + this.mcResourceManager.getResource(resourcelocation2); + } + catch (FileNotFoundException filenotfoundexception) + { + logger.warn("File {} does not exist, cannot add it to event {}", new Object[] {resourcelocation2, p_147693_1_}); + continue; + } + catch (IOException ioexception) + { + logger.warn("Could not load sound file " + resourcelocation2 + ", cannot add it to event " + p_147693_1_, ioexception); + continue; + } + + object = new SoundEventAccessor(new SoundPoolEntry(resourcelocation2, (double)soundentry.getSoundEntryPitch(), (double)soundentry.getSoundEntryVolume(), soundentry.isStreaming()), soundentry.getSoundEntryWeight()); + break; + case 2: + object = new ISoundEventAccessor() + { + final ResourceLocation field_148726_a = new ResourceLocation(s1, soundentry.getSoundEntryName()); + private static final String __OBFID = "CL_00001149"; + public int func_148721_a() + { + SoundEventAccessorComposite soundeventaccessorcomposite1 = (SoundEventAccessorComposite)SoundHandler.this.sndRegistry.getObject(this.field_148726_a); + return soundeventaccessorcomposite1 == null ? 0 : soundeventaccessorcomposite1.func_148721_a(); + } + public SoundPoolEntry func_148720_g() + { + SoundEventAccessorComposite soundeventaccessorcomposite1 = (SoundEventAccessorComposite)SoundHandler.this.sndRegistry.getObject(this.field_148726_a); + return soundeventaccessorcomposite1 == null ? SoundHandler.missing_sound : soundeventaccessorcomposite1.func_148720_g(); + } + }; + break; + default: + throw new IllegalStateException("IN YOU FACE"); + } + + soundeventaccessorcomposite.addSoundToEventPool((ISoundEventAccessor)object); + } + } + + public SoundEventAccessorComposite getSound(ResourceLocation p_147680_1_) + { + return (SoundEventAccessorComposite)this.sndRegistry.getObject(p_147680_1_); + } + + public void playSound(ISound p_147682_1_) + { + this.sndManager.playSound(p_147682_1_); + } + + public void playDelayedSound(ISound p_147681_1_, int p_147681_2_) + { + this.sndManager.addDelayedSound(p_147681_1_, p_147681_2_); + } + + public void setListener(EntityPlayer p_147691_1_, float p_147691_2_) + { + this.sndManager.setListener(p_147691_1_, p_147691_2_); + } + + public void pauseSounds() + { + this.sndManager.pauseAllSounds(); + } + + public void stopSounds() + { + this.sndManager.stopAllSounds(); + } + + public void unloadSounds() + { + this.sndManager.unloadSoundSystem(); + } + + public void update() + { + this.sndManager.updateAllSounds(); + } + + public void resumeSounds() + { + this.sndManager.resumeAllSounds(); + } + + public void setSoundLevel(SoundCategory p_147684_1_, float p_147684_2_) + { + if (p_147684_1_ == SoundCategory.MASTER && p_147684_2_ <= 0.0F) + { + this.stopSounds(); + } + + this.sndManager.setSoundCategoryVolume(p_147684_1_, p_147684_2_); + } + + public void stopSound(ISound p_147683_1_) + { + this.sndManager.stopSound(p_147683_1_); + } + + public SoundEventAccessorComposite getRandomSoundFromCategories(SoundCategory ... p_147686_1_) + { + ArrayList arraylist = Lists.newArrayList(); + Iterator iterator = this.sndRegistry.getKeys().iterator(); + + while (iterator.hasNext()) + { + ResourceLocation resourcelocation = (ResourceLocation)iterator.next(); + SoundEventAccessorComposite soundeventaccessorcomposite = (SoundEventAccessorComposite)this.sndRegistry.getObject(resourcelocation); + + if (ArrayUtils.contains(p_147686_1_, soundeventaccessorcomposite.getSoundCategory())) + { + arraylist.add(soundeventaccessorcomposite); + } + } + + if (arraylist.isEmpty()) + { + return null; + } + else + { + return (SoundEventAccessorComposite)arraylist.get((new Random()).nextInt(arraylist.size())); + } + } + + public boolean isSoundPlaying(ISound p_147692_1_) + { + return this.sndManager.isSoundPlaying(p_147692_1_); + } + + @SideOnly(Side.CLIENT) + + static final class SwitchType + { + static final int[] field_148765_a = new int[SoundList.SoundEntry.Type.values().length]; + private static final String __OBFID = "CL_00001150"; + + static + { + try + { + field_148765_a[SoundList.SoundEntry.Type.FILE.ordinal()] = 1; + } + catch (NoSuchFieldError var2) + { + ; + } + + try + { + field_148765_a[SoundList.SoundEntry.Type.SOUND_EVENT.ordinal()] = 2; + } + catch (NoSuchFieldError var1) + { + ; + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/audio/SoundList.java b/src/main/java/net/minecraft/client/audio/SoundList.java new file mode 100644 index 0000000..08ecbaf --- /dev/null +++ b/src/main/java/net/minecraft/client/audio/SoundList.java @@ -0,0 +1,151 @@ +package net.minecraft.client.audio; + +import com.google.common.collect.Lists; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; + +@SideOnly(Side.CLIENT) +public class SoundList +{ + private final List field_148577_a = Lists.newArrayList(); + private boolean replaceExisting; + private SoundCategory field_148576_c; + private static final String __OBFID = "CL_00001121"; + + public List getSoundList() + { + return this.field_148577_a; + } + + public boolean canReplaceExisting() + { + return this.replaceExisting; + } + + public void setReplaceExisting(boolean p_148572_1_) + { + this.replaceExisting = p_148572_1_; + } + + public SoundCategory getSoundCategory() + { + return this.field_148576_c; + } + + public void setSoundCategory(SoundCategory p_148571_1_) + { + this.field_148576_c = p_148571_1_; + } + + @SideOnly(Side.CLIENT) + public static class SoundEntry + { + private String field_148569_a; + private float field_148567_b = 1.0F; + private float field_148568_c = 1.0F; + private int field_148565_d = 1; + private SoundList.SoundEntry.Type field_148566_e; + private boolean field_148564_f; + private static final String __OBFID = "CL_00001122"; + + public SoundEntry() + { + this.field_148566_e = SoundList.SoundEntry.Type.FILE; + this.field_148564_f = false; + } + + public String getSoundEntryName() + { + return this.field_148569_a; + } + + public void setSoundEntryName(String p_148561_1_) + { + this.field_148569_a = p_148561_1_; + } + + public float getSoundEntryVolume() + { + return this.field_148567_b; + } + + public void setSoundEntryVolume(float p_148553_1_) + { + this.field_148567_b = p_148553_1_; + } + + public float getSoundEntryPitch() + { + return this.field_148568_c; + } + + public void setSoundEntryPitch(float p_148559_1_) + { + this.field_148568_c = p_148559_1_; + } + + public int getSoundEntryWeight() + { + return this.field_148565_d; + } + + public void setSoundEntryWeight(int p_148554_1_) + { + this.field_148565_d = p_148554_1_; + } + + public SoundList.SoundEntry.Type getSoundEntryType() + { + return this.field_148566_e; + } + + public void setSoundEntryType(SoundList.SoundEntry.Type p_148562_1_) + { + this.field_148566_e = p_148562_1_; + } + + public boolean isStreaming() + { + return this.field_148564_f; + } + + public void setStreaming(boolean p_148557_1_) + { + this.field_148564_f = p_148557_1_; + } + + @SideOnly(Side.CLIENT) + public static enum Type + { + FILE("file"), + SOUND_EVENT("event"); + private final String field_148583_c; + + private static final String __OBFID = "CL_00001123"; + + private Type(String p_i45109_3_) + { + this.field_148583_c = p_i45109_3_; + } + + public static SoundList.SoundEntry.Type getType(String p_148580_0_) + { + SoundList.SoundEntry.Type[] atype = values(); + int i = atype.length; + + for (int j = 0; j < i; ++j) + { + SoundList.SoundEntry.Type type = atype[j]; + + if (type.field_148583_c.equals(p_148580_0_)) + { + return type; + } + } + + return null; + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/audio/SoundListSerializer.java b/src/main/java/net/minecraft/client/audio/SoundListSerializer.java new file mode 100644 index 0000000..7cb0d59 --- /dev/null +++ b/src/main/java/net/minecraft/client/audio/SoundListSerializer.java @@ -0,0 +1,88 @@ +package net.minecraft.client.audio; + +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.lang.reflect.Type; +import net.minecraft.util.JsonUtils; +import org.apache.commons.lang3.Validate; + +@SideOnly(Side.CLIENT) +public class SoundListSerializer implements JsonDeserializer +{ + private static final String __OBFID = "CL_00001124"; + + public SoundList deserialize(JsonElement p_148578_1_, Type p_148578_2_, JsonDeserializationContext p_148578_3_) + { + JsonObject jsonobject = JsonUtils.getJsonElementAsJsonObject(p_148578_1_, "entry"); + SoundList soundlist = new SoundList(); + soundlist.setReplaceExisting(JsonUtils.getJsonObjectBooleanFieldValueOrDefault(jsonobject, "replace", false)); + SoundCategory soundcategory = SoundCategory.func_147154_a(JsonUtils.getJsonObjectStringFieldValueOrDefault(jsonobject, "category", SoundCategory.MASTER.getCategoryName())); + soundlist.setSoundCategory(soundcategory); + Validate.notNull(soundcategory, "Invalid category", new Object[0]); + + if (jsonobject.has("sounds")) + { + JsonArray jsonarray = JsonUtils.getJsonObjectJsonArrayField(jsonobject, "sounds"); + + for (int i = 0; i < jsonarray.size(); ++i) + { + JsonElement jsonelement1 = jsonarray.get(i); + SoundList.SoundEntry soundentry = new SoundList.SoundEntry(); + + if (JsonUtils.jsonElementTypeIsString(jsonelement1)) + { + soundentry.setSoundEntryName(JsonUtils.getJsonElementStringValue(jsonelement1, "sound")); + } + else + { + JsonObject jsonobject1 = JsonUtils.getJsonElementAsJsonObject(jsonelement1, "sound"); + soundentry.setSoundEntryName(JsonUtils.getJsonObjectStringFieldValue(jsonobject1, "name")); + + if (jsonobject1.has("type")) + { + SoundList.SoundEntry.Type type1 = SoundList.SoundEntry.Type.getType(JsonUtils.getJsonObjectStringFieldValue(jsonobject1, "type")); + Validate.notNull(type1, "Invalid type", new Object[0]); + soundentry.setSoundEntryType(type1); + } + + float f; + + if (jsonobject1.has("volume")) + { + f = JsonUtils.getJsonObjectFloatFieldValue(jsonobject1, "volume"); + Validate.isTrue(f > 0.0F, "Invalid volume", new Object[0]); + soundentry.setSoundEntryVolume(f); + } + + if (jsonobject1.has("pitch")) + { + f = JsonUtils.getJsonObjectFloatFieldValue(jsonobject1, "pitch"); + Validate.isTrue(f > 0.0F, "Invalid pitch", new Object[0]); + soundentry.setSoundEntryPitch(f); + } + + if (jsonobject1.has("weight")) + { + int j = JsonUtils.getJsonObjectIntegerFieldValue(jsonobject1, "weight"); + Validate.isTrue(j > 0, "Invalid weight", new Object[0]); + soundentry.setSoundEntryWeight(j); + } + + if (jsonobject1.has("stream")) + { + soundentry.setStreaming(JsonUtils.getJsonObjectBooleanFieldValue(jsonobject1, "stream")); + } + } + + soundlist.getSoundList().add(soundentry); + } + } + + return soundlist; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/audio/SoundManager.java b/src/main/java/net/minecraft/client/audio/SoundManager.java new file mode 100644 index 0000000..05e9778 --- /dev/null +++ b/src/main/java/net/minecraft/client/audio/SoundManager.java @@ -0,0 +1,510 @@ +package net.minecraft.client.audio; + +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Multimap; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLConnection; +import java.net.URLStreamHandler; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.Map.Entry; +import net.minecraft.client.Minecraft; +import net.minecraft.client.settings.GameSettings; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.Marker; +import org.apache.logging.log4j.MarkerManager; +import paulscode.sound.SoundSystem; +import paulscode.sound.SoundSystemConfig; +import paulscode.sound.SoundSystemException; +import paulscode.sound.Source; +import paulscode.sound.codecs.CodecJOrbis; +import paulscode.sound.libraries.LibraryLWJGLOpenAL; + +import net.minecraftforge.client.*; +import net.minecraftforge.client.event.sound.*; +import net.minecraftforge.common.MinecraftForge; + +@SideOnly(Side.CLIENT) +public class SoundManager +{ + private static final Marker field_148623_a = MarkerManager.getMarker("SOUNDS"); + private static final Logger logger = LogManager.getLogger(); + public final SoundHandler sndHandler; + private final GameSettings options; + private SoundManager.SoundSystemStarterThread sndSystem; + private boolean loaded; + private int playTime = 0; + private final Map playingSounds = HashBiMap.create(); + private final Map invPlayingSounds; + private Map playingSoundPoolEntries; + private final Multimap categorySounds; + private final List tickableSounds; + private final Map delayedSounds; + private final Map playingSoundsStopTime; + private static final String __OBFID = "CL_00001141"; + + public SoundManager(SoundHandler p_i45119_1_, GameSettings p_i45119_2_) + { + this.invPlayingSounds = ((BiMap)this.playingSounds).inverse(); + this.playingSoundPoolEntries = Maps.newHashMap(); + this.categorySounds = HashMultimap.create(); + this.tickableSounds = Lists.newArrayList(); + this.delayedSounds = Maps.newHashMap(); + this.playingSoundsStopTime = Maps.newHashMap(); + this.sndHandler = p_i45119_1_; + this.options = p_i45119_2_; + + try + { + SoundSystemConfig.addLibrary(LibraryLWJGLOpenAL.class); + SoundSystemConfig.setCodec("ogg", CodecJOrbis.class); + MinecraftForge.EVENT_BUS.post(new SoundSetupEvent(this)); + } + catch (SoundSystemException soundsystemexception) + { + logger.error(field_148623_a, "Error linking with the LibraryJavaSound plug-in", soundsystemexception); + } + } + + public void reloadSoundSystem() + { + this.unloadSoundSystem(); + this.loadSoundSystem(); + MinecraftForge.EVENT_BUS.post(new SoundLoadEvent(this)); + } + + private synchronized void loadSoundSystem() + { + if (!this.loaded) + { + try + { + (new Thread(new Runnable() + { + private static final String __OBFID = "CL_00001142"; + public void run() + { + SoundManager.this.sndSystem = SoundManager.this.new SoundSystemStarterThread(null); + SoundManager.this.loaded = true; + SoundManager.this.sndSystem.setMasterVolume(SoundManager.this.options.getSoundLevel(SoundCategory.MASTER)); + SoundManager.logger.info(SoundManager.field_148623_a, "Sound engine started"); + } + }, "Sound Library Loader")).start(); + } + catch (RuntimeException runtimeexception) + { + logger.error(field_148623_a, "Error starting SoundSystem. Turning off sounds & music", runtimeexception); + this.options.setSoundLevel(SoundCategory.MASTER, 0.0F); + this.options.saveOptions(); + } + } + } + + private float getSoundCategoryVolume(SoundCategory p_148595_1_) + { + return p_148595_1_ != null && p_148595_1_ != SoundCategory.MASTER ? this.options.getSoundLevel(p_148595_1_) : 1.0F; + } + + public void setSoundCategoryVolume(SoundCategory p_148601_1_, float p_148601_2_) + { + if (this.loaded) + { + if (p_148601_1_ == SoundCategory.MASTER) + { + this.sndSystem.setMasterVolume(p_148601_2_); + } + else + { + Iterator iterator = this.categorySounds.get(p_148601_1_).iterator(); + + while (iterator.hasNext()) + { + String s = (String)iterator.next(); + ISound isound = (ISound)this.playingSounds.get(s); + float f1 = this.getNormalizedVolume(isound, (SoundPoolEntry)this.playingSoundPoolEntries.get(isound), p_148601_1_); + + if (f1 <= 0.0F) + { + this.stopSound(isound); + } + else + { + this.sndSystem.setVolume(s, f1); + } + } + } + } + } + + public void unloadSoundSystem() + { + if (this.loaded) + { + this.stopAllSounds(); + this.sndSystem.cleanup(); + this.loaded = false; + } + } + + public void stopAllSounds() + { + if (this.loaded) + { + Iterator iterator = this.playingSounds.keySet().iterator(); + + while (iterator.hasNext()) + { + String s = (String)iterator.next(); + this.sndSystem.stop(s); + } + + this.playingSounds.clear(); + this.delayedSounds.clear(); + this.tickableSounds.clear(); + this.categorySounds.clear(); + this.playingSoundPoolEntries.clear(); + this.playingSoundsStopTime.clear(); + } + } + + public void updateAllSounds() + { + ++this.playTime; + Iterator iterator = this.tickableSounds.iterator(); + String s; + + while (iterator.hasNext()) + { + ITickableSound itickablesound = (ITickableSound)iterator.next(); + itickablesound.update(); + + if (itickablesound.isDonePlaying()) + { + this.stopSound(itickablesound); + } + else + { + s = (String)this.invPlayingSounds.get(itickablesound); + this.sndSystem.setVolume(s, this.getNormalizedVolume(itickablesound, (SoundPoolEntry)this.playingSoundPoolEntries.get(itickablesound), this.sndHandler.getSound(itickablesound.getPositionedSoundLocation()).getSoundCategory())); + this.sndSystem.setPitch(s, this.getNormalizedPitch(itickablesound, (SoundPoolEntry)this.playingSoundPoolEntries.get(itickablesound))); + this.sndSystem.setPosition(s, itickablesound.getXPosF(), itickablesound.getYPosF(), itickablesound.getZPosF()); + } + } + + iterator = this.playingSounds.entrySet().iterator(); + ISound isound; + + while (iterator.hasNext()) + { + Entry entry = (Entry)iterator.next(); + s = (String)entry.getKey(); + isound = (ISound)entry.getValue(); + + if (!this.sndSystem.playing(s)) + { + int i = ((Integer)this.playingSoundsStopTime.get(s)).intValue(); + + if (i <= this.playTime) + { + int j = isound.getRepeatDelay(); + + if (isound.canRepeat() && j > 0) + { + this.delayedSounds.put(isound, Integer.valueOf(this.playTime + j)); + } + + iterator.remove(); + logger.debug(field_148623_a, "Removed channel {} because it\'s not playing anymore", new Object[] {s}); + this.sndSystem.removeSource(s); + this.playingSoundsStopTime.remove(s); + this.playingSoundPoolEntries.remove(isound); + + try + { + this.categorySounds.remove(this.sndHandler.getSound(isound.getPositionedSoundLocation()).getSoundCategory(), s); + } + catch (RuntimeException runtimeexception) + { + ; + } + + if (isound instanceof ITickableSound) + { + this.tickableSounds.remove(isound); + } + } + } + } + + Iterator iterator1 = this.delayedSounds.entrySet().iterator(); + + while (iterator1.hasNext()) + { + Entry entry1 = (Entry)iterator1.next(); + + if (this.playTime >= ((Integer)entry1.getValue()).intValue()) + { + isound = (ISound)entry1.getKey(); + + if (isound instanceof ITickableSound) + { + ((ITickableSound)isound).update(); + } + + this.playSound(isound); + iterator1.remove(); + } + } + } + + public boolean isSoundPlaying(ISound p_148597_1_) + { + if (!this.loaded) + { + return false; + } + else + { + String s = (String)this.invPlayingSounds.get(p_148597_1_); + return s == null ? false : this.sndSystem.playing(s) || this.playingSoundsStopTime.containsKey(s) && ((Integer)this.playingSoundsStopTime.get(s)).intValue() <= this.playTime; + } + } + + public void stopSound(ISound p_148602_1_) + { + if (this.loaded) + { + String s = (String)this.invPlayingSounds.get(p_148602_1_); + + if (s != null) + { + this.sndSystem.stop(s); + } + } + } + + public void playSound(ISound p_148611_1_) + { + if (this.loaded) + { + if (this.sndSystem.getMasterVolume() <= 0.0F) + { + logger.debug(field_148623_a, "Skipped playing soundEvent: {}, master volume was zero", new Object[] {p_148611_1_.getPositionedSoundLocation()}); + } + else + { + p_148611_1_ = ForgeHooksClient.playSound(this, p_148611_1_); + if (p_148611_1_ == null) return; + + SoundEventAccessorComposite soundeventaccessorcomposite = this.sndHandler.getSound(p_148611_1_.getPositionedSoundLocation()); + + if (soundeventaccessorcomposite == null) + { + logger.warn(field_148623_a, "Unable to play unknown soundEvent: {}", new Object[] {p_148611_1_.getPositionedSoundLocation()}); + } + else + { + SoundPoolEntry soundpoolentry = soundeventaccessorcomposite.func_148720_g(); + + if (soundpoolentry == SoundHandler.missing_sound) + { + logger.warn(field_148623_a, "Unable to play empty soundEvent: {}", new Object[] {soundeventaccessorcomposite.getSoundEventLocation()}); + } + else + { + float f = p_148611_1_.getVolume(); + float f1 = 16.0F; + + if (f > 1.0F) + { + f1 *= f; + } + + SoundCategory soundcategory = soundeventaccessorcomposite.getSoundCategory(); + float f2 = this.getNormalizedVolume(p_148611_1_, soundpoolentry, soundcategory); + double d0 = (double)this.getNormalizedPitch(p_148611_1_, soundpoolentry); + ResourceLocation resourcelocation = soundpoolentry.getSoundPoolEntryLocation(); + + if (f2 == 0.0F) + { + logger.debug(field_148623_a, "Skipped playing sound {}, volume was zero.", new Object[] {resourcelocation}); + } + else + { + boolean flag = p_148611_1_.canRepeat() && p_148611_1_.getRepeatDelay() == 0; + String s = UUID.randomUUID().toString(); + + if (soundpoolentry.func_148648_d()) + { + this.sndSystem.newStreamingSource(false, s, getURLForSoundResource(resourcelocation), resourcelocation.toString(), flag, p_148611_1_.getXPosF(), p_148611_1_.getYPosF(), p_148611_1_.getZPosF(), p_148611_1_.getAttenuationType().getTypeInt(), f1); + MinecraftForge.EVENT_BUS.post(new PlayStreamingSourceEvent(this, p_148611_1_, s)); + } + else + { + this.sndSystem.newSource(false, s, getURLForSoundResource(resourcelocation), resourcelocation.toString(), flag, p_148611_1_.getXPosF(), p_148611_1_.getYPosF(), p_148611_1_.getZPosF(), p_148611_1_.getAttenuationType().getTypeInt(), f1); + MinecraftForge.EVENT_BUS.post(new PlaySoundSourceEvent(this, p_148611_1_, s)); + } + + logger.debug(field_148623_a, "Playing sound {} for event {} as channel {}", new Object[] {soundpoolentry.getSoundPoolEntryLocation(), soundeventaccessorcomposite.getSoundEventLocation(), s}); + this.sndSystem.setPitch(s, (float)d0); + this.sndSystem.setVolume(s, f2); + this.sndSystem.play(s); + this.playingSoundsStopTime.put(s, Integer.valueOf(this.playTime + 20)); + this.playingSounds.put(s, p_148611_1_); + this.playingSoundPoolEntries.put(p_148611_1_, soundpoolentry); + + if (soundcategory != SoundCategory.MASTER) + { + this.categorySounds.put(soundcategory, s); + } + + if (p_148611_1_ instanceof ITickableSound) + { + this.tickableSounds.add((ITickableSound)p_148611_1_); + } + } + } + } + } + } + } + + private float getNormalizedPitch(ISound p_148606_1_, SoundPoolEntry p_148606_2_) + { + return (float)MathHelper.clamp_double((double)p_148606_1_.getPitch() * p_148606_2_.getPitch(), 0.5D, 2.0D); + } + + private float getNormalizedVolume(ISound p_148594_1_, SoundPoolEntry p_148594_2_, SoundCategory p_148594_3_) + { + return (float)MathHelper.clamp_double((double)p_148594_1_.getVolume() * p_148594_2_.getVolume() * (double)this.getSoundCategoryVolume(p_148594_3_), 0.0D, 1.0D); + } + + public void pauseAllSounds() + { + Iterator iterator = this.playingSounds.keySet().iterator(); + + while (iterator.hasNext()) + { + String s = (String)iterator.next(); + logger.debug(field_148623_a, "Pausing channel {}", new Object[] {s}); + this.sndSystem.pause(s); + } + } + + public void resumeAllSounds() + { + Iterator iterator = this.playingSounds.keySet().iterator(); + + while (iterator.hasNext()) + { + String s = (String)iterator.next(); + logger.debug(field_148623_a, "Resuming channel {}", new Object[] {s}); + this.sndSystem.play(s); + } + } + + public void addDelayedSound(ISound p_148599_1_, int p_148599_2_) + { + this.delayedSounds.put(p_148599_1_, Integer.valueOf(this.playTime + p_148599_2_)); + } + + private static URL getURLForSoundResource(final ResourceLocation p_148612_0_) + { + String s = String.format("%s:%s:%s", new Object[] {"mcsounddomain", p_148612_0_.getResourceDomain(), p_148612_0_.getResourcePath()}); + URLStreamHandler urlstreamhandler = new URLStreamHandler() + { + private static final String __OBFID = "CL_00001143"; + protected URLConnection openConnection(final URL par1URL) + { + return new URLConnection(par1URL) + { + private static final String __OBFID = "CL_00001144"; + public void connect() {} + public InputStream getInputStream() throws IOException + { + return Minecraft.getMinecraft().getResourceManager().getResource(p_148612_0_).getInputStream(); + } + }; + } + }; + + try + { + return new URL((URL)null, s, urlstreamhandler); + } + catch (MalformedURLException malformedurlexception) + { + throw new Error("TODO: Sanely handle url exception! :D"); + } + } + + public void setListener(EntityPlayer p_148615_1_, float p_148615_2_) + { + if (this.loaded && p_148615_1_ != null) + { + float f1 = p_148615_1_.prevRotationPitch + (p_148615_1_.rotationPitch - p_148615_1_.prevRotationPitch) * p_148615_2_; + float f2 = p_148615_1_.prevRotationYaw + (p_148615_1_.rotationYaw - p_148615_1_.prevRotationYaw) * p_148615_2_; + double d0 = p_148615_1_.prevPosX + (p_148615_1_.posX - p_148615_1_.prevPosX) * (double)p_148615_2_; + double d1 = p_148615_1_.prevPosY + (p_148615_1_.posY - p_148615_1_.prevPosY) * (double)p_148615_2_; + double d2 = p_148615_1_.prevPosZ + (p_148615_1_.posZ - p_148615_1_.prevPosZ) * (double)p_148615_2_; + float f3 = MathHelper.cos((f2 + 90.0F) * 0.017453292F); + float f4 = MathHelper.sin((f2 + 90.0F) * 0.017453292F); + float f5 = MathHelper.cos(-f1 * 0.017453292F); + float f6 = MathHelper.sin(-f1 * 0.017453292F); + float f7 = MathHelper.cos((-f1 + 90.0F) * 0.017453292F); + float f8 = MathHelper.sin((-f1 + 90.0F) * 0.017453292F); + float f9 = f3 * f5; + float f10 = f4 * f5; + float f11 = f3 * f7; + float f12 = f4 * f7; + this.sndSystem.setListenerPosition((float)d0, (float)d1, (float)d2); + this.sndSystem.setListenerOrientation(f9, f6, f10, f11, f8, f12); + } + } + + @SideOnly(Side.CLIENT) + class SoundSystemStarterThread extends SoundSystem + { + private static final String __OBFID = "CL_00001145"; + + private SoundSystemStarterThread() {} + + public boolean playing(String p_playing_1_) + { + Object object = SoundSystemConfig.THREAD_SYNC; + + synchronized (SoundSystemConfig.THREAD_SYNC) + { + if (this.soundLibrary == null) + { + return false; + } + else + { + Source source = (Source)this.soundLibrary.getSources().get(p_playing_1_); + return source == null ? false : source.playing() || source.paused(); + } + } + } + + SoundSystemStarterThread(Object p_i45118_2_) + { + this(); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/audio/SoundPoolEntry.java b/src/main/java/net/minecraft/client/audio/SoundPoolEntry.java new file mode 100644 index 0000000..99cc94a --- /dev/null +++ b/src/main/java/net/minecraft/client/audio/SoundPoolEntry.java @@ -0,0 +1,61 @@ +package net.minecraft.client.audio; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.util.ResourceLocation; + +@SideOnly(Side.CLIENT) +public class SoundPoolEntry +{ + private final ResourceLocation field_148656_a; + private final boolean field_148654_b; + private double field_148655_c; + private double field_148653_d; + private static final String __OBFID = "CL_00001140"; + + public SoundPoolEntry(ResourceLocation p_i45113_1_, double p_i45113_2_, double p_i45113_4_, boolean p_i45113_6_) + { + this.field_148656_a = p_i45113_1_; + this.field_148655_c = p_i45113_2_; + this.field_148653_d = p_i45113_4_; + this.field_148654_b = p_i45113_6_; + } + + public SoundPoolEntry(SoundPoolEntry p_i45114_1_) + { + this.field_148656_a = p_i45114_1_.field_148656_a; + this.field_148655_c = p_i45114_1_.field_148655_c; + this.field_148653_d = p_i45114_1_.field_148653_d; + this.field_148654_b = p_i45114_1_.field_148654_b; + } + + public ResourceLocation getSoundPoolEntryLocation() + { + return this.field_148656_a; + } + + public double getPitch() + { + return this.field_148655_c; + } + + public void setPitch(double p_148651_1_) + { + this.field_148655_c = p_148651_1_; + } + + public double getVolume() + { + return this.field_148653_d; + } + + public void setVolume(double p_148647_1_) + { + this.field_148653_d = p_148647_1_; + } + + public boolean func_148648_d() + { + return this.field_148654_b; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/audio/SoundRegistry.java b/src/main/java/net/minecraft/client/audio/SoundRegistry.java new file mode 100644 index 0000000..5e806bf --- /dev/null +++ b/src/main/java/net/minecraft/client/audio/SoundRegistry.java @@ -0,0 +1,30 @@ +package net.minecraft.client.audio; + +import com.google.common.collect.Maps; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Map; +import net.minecraft.util.RegistrySimple; + +@SideOnly(Side.CLIENT) +public class SoundRegistry extends RegistrySimple +{ + private Map field_148764_a; + private static final String __OBFID = "CL_00001151"; + + protected Map createUnderlyingMap() + { + this.field_148764_a = Maps.newHashMap(); + return this.field_148764_a; + } + + public void registerSound(SoundEventAccessorComposite p_148762_1_) + { + this.putObject(p_148762_1_.getSoundEventLocation(), p_148762_1_); + } + + public void func_148763_c() + { + this.field_148764_a.clear(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/entity/AbstractClientPlayer.java b/src/main/java/net/minecraft/client/entity/AbstractClientPlayer.java new file mode 100644 index 0000000..ed984db --- /dev/null +++ b/src/main/java/net/minecraft/client/entity/AbstractClientPlayer.java @@ -0,0 +1,114 @@ +package net.minecraft.client.entity; + +import com.mojang.authlib.GameProfile; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.IImageBuffer; +import net.minecraft.client.renderer.ImageBufferDownload; +import net.minecraft.client.renderer.ThreadDownloadImageData; +import net.minecraft.client.renderer.texture.ITextureObject; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StringUtils; +import net.minecraft.world.World; + +@SideOnly(Side.CLIENT) +public abstract class AbstractClientPlayer extends EntityPlayer +{ + public static final ResourceLocation locationStevePng = new ResourceLocation("textures/entity/steve.png"); + private ThreadDownloadImageData downloadImageSkin; + private ThreadDownloadImageData downloadImageCape; + private ResourceLocation locationSkin; + private ResourceLocation locationCape; + private static final String __OBFID = "CL_00000935"; + + public AbstractClientPlayer(World p_i45074_1_, GameProfile p_i45074_2_) + { + super(p_i45074_1_, p_i45074_2_); + this.setupCustomSkin(); + } + + protected void setupCustomSkin() + { + String s = this.getCommandSenderName(); + + if (!s.isEmpty()) + { + this.locationSkin = getLocationSkin(s); + this.locationCape = getLocationCape(s); + this.downloadImageSkin = getDownloadImageSkin(this.locationSkin, s); + this.downloadImageCape = getDownloadImageCape(this.locationCape, s); + } + } + + public ThreadDownloadImageData getTextureSkin() + { + return this.downloadImageSkin; + } + + public ThreadDownloadImageData getTextureCape() + { + return this.downloadImageCape; + } + + public ResourceLocation getLocationSkin() + { + return this.locationSkin; + } + + public ResourceLocation getLocationCape() + { + return this.locationCape; + } + + public static ThreadDownloadImageData getDownloadImageSkin(ResourceLocation par0ResourceLocation, String par1Str) + { + return getDownloadImage(par0ResourceLocation, getSkinUrl(par1Str), locationStevePng, new ImageBufferDownload()); + } + + public static ThreadDownloadImageData getDownloadImageCape(ResourceLocation par0ResourceLocation, String par1Str) + { + return getDownloadImage(par0ResourceLocation, getCapeUrl(par1Str), (ResourceLocation)null, (IImageBuffer)null); + } + + private static ThreadDownloadImageData getDownloadImage(ResourceLocation par0ResourceLocation, String par1Str, ResourceLocation par2ResourceLocation, IImageBuffer par3IImageBuffer) + { + TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); + Object object = texturemanager.getTexture(par0ResourceLocation); + + if (object == null) + { + object = new ThreadDownloadImageData(par1Str, par2ResourceLocation, par3IImageBuffer); + texturemanager.loadTexture(par0ResourceLocation, (ITextureObject)object); + } + + return (ThreadDownloadImageData)object; + } + + public static String getSkinUrl(String par0Str) + { + return String.format("http://skins.minecraft.net/MinecraftSkins/%s.png", new Object[] {StringUtils.stripControlCodes(par0Str)}); + } + + public static String getCapeUrl(String par0Str) + { + return String.format("http://skins.minecraft.net/MinecraftCloaks/%s.png", new Object[] {StringUtils.stripControlCodes(par0Str)}); + } + + public static ResourceLocation getLocationSkin(String par0Str) + { + return new ResourceLocation("skins/" + StringUtils.stripControlCodes(par0Str)); + } + + public static ResourceLocation getLocationCape(String par0Str) + { + return new ResourceLocation("cloaks/" + StringUtils.stripControlCodes(par0Str)); + } + + public static ResourceLocation getLocationSkull(String par0Str) + { + return new ResourceLocation("skull/" + StringUtils.stripControlCodes(par0Str)); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/entity/EntityClientPlayerMP.java b/src/main/java/net/minecraft/client/entity/EntityClientPlayerMP.java new file mode 100644 index 0000000..e65026b --- /dev/null +++ b/src/main/java/net/minecraft/client/entity/EntityClientPlayerMP.java @@ -0,0 +1,270 @@ +package net.minecraft.client.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.Minecraft; +import net.minecraft.client.audio.MovingSoundMinecartRiding; +import net.minecraft.client.network.NetHandlerPlayClient; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.item.EntityMinecart; +import net.minecraft.item.ItemStack; +import net.minecraft.network.play.client.C01PacketChatMessage; +import net.minecraft.network.play.client.C03PacketPlayer; +import net.minecraft.network.play.client.C07PacketPlayerDigging; +import net.minecraft.network.play.client.C0APacketAnimation; +import net.minecraft.network.play.client.C0BPacketEntityAction; +import net.minecraft.network.play.client.C0CPacketInput; +import net.minecraft.network.play.client.C0DPacketCloseWindow; +import net.minecraft.network.play.client.C13PacketPlayerAbilities; +import net.minecraft.network.play.client.C16PacketClientStatus; +import net.minecraft.stats.StatBase; +import net.minecraft.stats.StatFileWriter; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.util.Session; +import net.minecraft.world.World; + +@SideOnly(Side.CLIENT) +public class EntityClientPlayerMP extends EntityPlayerSP +{ + public final NetHandlerPlayClient sendQueue; + private final StatFileWriter field_146108_bO; + private double oldPosX; + private double oldMinY; + private double oldPosY; + private double oldPosZ; + private float oldRotationYaw; + private float oldRotationPitch; + private boolean wasOnGround; + private boolean wasSneaking; + private boolean wasSprinting; + private int ticksSinceMovePacket; + private boolean hasSetHealth; + private String field_142022_ce; + private static final String __OBFID = "CL_00000887"; + + public EntityClientPlayerMP(Minecraft p_i45064_1_, World p_i45064_2_, Session p_i45064_3_, NetHandlerPlayClient p_i45064_4_, StatFileWriter p_i45064_5_) + { + super(p_i45064_1_, p_i45064_2_, p_i45064_3_, 0); + this.sendQueue = p_i45064_4_; + this.field_146108_bO = p_i45064_5_; + } + + public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) + { + return false; + } + + public void heal(float par1) {} + + public void mountEntity(Entity par1Entity) + { + super.mountEntity(par1Entity); + + if (par1Entity instanceof EntityMinecart) + { + this.mc.getSoundHandler().playSound(new MovingSoundMinecartRiding(this, (EntityMinecart)par1Entity)); + } + } + + public void onUpdate() + { + if (this.worldObj.blockExists(MathHelper.floor_double(this.posX), 0, MathHelper.floor_double(this.posZ))) + { + super.onUpdate(); + + if (this.isRiding()) + { + this.sendQueue.addToSendQueue(new C03PacketPlayer.C05PacketPlayerLook(this.rotationYaw, this.rotationPitch, this.onGround)); + this.sendQueue.addToSendQueue(new C0CPacketInput(this.moveStrafing, this.moveForward, this.movementInput.jump, this.movementInput.sneak)); + } + else + { + this.sendMotionUpdates(); + } + } + } + + public void sendMotionUpdates() + { + boolean flag = this.isSprinting(); + + if (flag != this.wasSprinting) + { + if (flag) + { + this.sendQueue.addToSendQueue(new C0BPacketEntityAction(this, 4)); + } + else + { + this.sendQueue.addToSendQueue(new C0BPacketEntityAction(this, 5)); + } + + this.wasSprinting = flag; + } + + boolean flag1 = this.isSneaking(); + + if (flag1 != this.wasSneaking) + { + if (flag1) + { + this.sendQueue.addToSendQueue(new C0BPacketEntityAction(this, 1)); + } + else + { + this.sendQueue.addToSendQueue(new C0BPacketEntityAction(this, 2)); + } + + this.wasSneaking = flag1; + } + + double d0 = this.posX - this.oldPosX; + double d1 = this.boundingBox.minY - this.oldMinY; + double d2 = this.posZ - this.oldPosZ; + double d3 = (double)(this.rotationYaw - this.oldRotationYaw); + double d4 = (double)(this.rotationPitch - this.oldRotationPitch); + boolean flag2 = d0 * d0 + d1 * d1 + d2 * d2 > 9.0E-4D || this.ticksSinceMovePacket >= 20; + boolean flag3 = d3 != 0.0D || d4 != 0.0D; + + if (this.ridingEntity != null) + { + this.sendQueue.addToSendQueue(new C03PacketPlayer.C06PacketPlayerPosLook(this.motionX, -999.0D, -999.0D, this.motionZ, this.rotationYaw, this.rotationPitch, this.onGround)); + flag2 = false; + } + else if (flag2 && flag3) + { + this.sendQueue.addToSendQueue(new C03PacketPlayer.C06PacketPlayerPosLook(this.posX, this.boundingBox.minY, this.posY, this.posZ, this.rotationYaw, this.rotationPitch, this.onGround)); + } + else if (flag2) + { + this.sendQueue.addToSendQueue(new C03PacketPlayer.C04PacketPlayerPosition(this.posX, this.boundingBox.minY, this.posY, this.posZ, this.onGround)); + } + else if (flag3) + { + this.sendQueue.addToSendQueue(new C03PacketPlayer.C05PacketPlayerLook(this.rotationYaw, this.rotationPitch, this.onGround)); + } + else + { + this.sendQueue.addToSendQueue(new C03PacketPlayer(this.onGround)); + } + + ++this.ticksSinceMovePacket; + this.wasOnGround = this.onGround; + + if (flag2) + { + this.oldPosX = this.posX; + this.oldMinY = this.boundingBox.minY; + this.oldPosY = this.posY; + this.oldPosZ = this.posZ; + this.ticksSinceMovePacket = 0; + } + + if (flag3) + { + this.oldRotationYaw = this.rotationYaw; + this.oldRotationPitch = this.rotationPitch; + } + } + + public EntityItem dropOneItem(boolean par1) + { + int i = par1 ? 3 : 4; + this.sendQueue.addToSendQueue(new C07PacketPlayerDigging(i, 0, 0, 0, 0)); + return null; + } + + public void joinEntityItemWithWorld(EntityItem par1EntityItem) {} + + public void sendChatMessage(String par1Str) + { + this.sendQueue.addToSendQueue(new C01PacketChatMessage(par1Str)); + } + + public void swingItem() + { + super.swingItem(); + this.sendQueue.addToSendQueue(new C0APacketAnimation(this, 1)); + } + + public void respawnPlayer() + { + this.sendQueue.addToSendQueue(new C16PacketClientStatus(C16PacketClientStatus.EnumState.PERFORM_RESPAWN)); + } + + protected void damageEntity(DamageSource par1DamageSource, float par2) + { + if (!this.isEntityInvulnerable()) + { + this.setHealth(this.getHealth() - par2); + } + } + + public void closeScreen() + { + this.sendQueue.addToSendQueue(new C0DPacketCloseWindow(this.openContainer.windowId)); + this.closeScreenNoPacket(); + } + + public void closeScreenNoPacket() + { + this.inventory.setItemStack((ItemStack)null); + super.closeScreen(); + } + + public void setPlayerSPHealth(float par1) + { + if (this.hasSetHealth) + { + super.setPlayerSPHealth(par1); + } + else + { + this.setHealth(par1); + this.hasSetHealth = true; + } + } + + public void addStat(StatBase par1StatBase, int par2) + { + if (par1StatBase != null) + { + if (par1StatBase.isIndependent) + { + super.addStat(par1StatBase, par2); + } + } + } + + public void sendPlayerAbilities() + { + this.sendQueue.addToSendQueue(new C13PacketPlayerAbilities(this.capabilities)); + } + + protected void func_110318_g() + { + this.sendQueue.addToSendQueue(new C0BPacketEntityAction(this, 6, (int)(this.getHorseJumpPower() * 100.0F))); + } + + public void func_110322_i() + { + this.sendQueue.addToSendQueue(new C0BPacketEntityAction(this, 7)); + } + + public void func_142020_c(String par1Str) + { + this.field_142022_ce = par1Str; + } + + public String func_142021_k() + { + return this.field_142022_ce; + } + + public StatFileWriter getStatFileWriter() + { + return this.field_146108_bO; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/entity/EntityOtherPlayerMP.java b/src/main/java/net/minecraft/client/entity/EntityOtherPlayerMP.java new file mode 100644 index 0000000..2b7c6d2 --- /dev/null +++ b/src/main/java/net/minecraft/client/entity/EntityOtherPlayerMP.java @@ -0,0 +1,174 @@ +package net.minecraft.client.entity; + +import com.mojang.authlib.GameProfile; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.Minecraft; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.DamageSource; +import net.minecraft.util.IChatComponent; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +@SideOnly(Side.CLIENT) +public class EntityOtherPlayerMP extends AbstractClientPlayer +{ + private boolean isItemInUse; + private int otherPlayerMPPosRotationIncrements; + private double otherPlayerMPX; + private double otherPlayerMPY; + private double otherPlayerMPZ; + private double otherPlayerMPYaw; + private double otherPlayerMPPitch; + private static final String __OBFID = "CL_00000939"; + + public EntityOtherPlayerMP(World p_i45075_1_, GameProfile p_i45075_2_) + { + super(p_i45075_1_, p_i45075_2_); + this.yOffset = 0.0F; + this.stepHeight = 0.0F; + this.noClip = true; + this.field_71082_cx = 0.25F; + this.renderDistanceWeight = 10.0D; + } + + protected void resetHeight() + { + this.yOffset = 0.0F; + } + + public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) + { + return true; + } + + public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9) + { + this.otherPlayerMPX = par1; + this.otherPlayerMPY = par3; + this.otherPlayerMPZ = par5; + this.otherPlayerMPYaw = (double)par7; + this.otherPlayerMPPitch = (double)par8; + this.otherPlayerMPPosRotationIncrements = par9; + } + + public void onUpdate() + { + this.field_71082_cx = 0.0F; + super.onUpdate(); + this.prevLimbSwingAmount = this.limbSwingAmount; + double d0 = this.posX - this.prevPosX; + double d1 = this.posZ - this.prevPosZ; + float f = MathHelper.sqrt_double(d0 * d0 + d1 * d1) * 4.0F; + + if (f > 1.0F) + { + f = 1.0F; + } + + this.limbSwingAmount += (f - this.limbSwingAmount) * 0.4F; + this.limbSwing += this.limbSwingAmount; + + if (!this.isItemInUse && this.isEating() && this.inventory.mainInventory[this.inventory.currentItem] != null) + { + ItemStack itemstack = this.inventory.mainInventory[this.inventory.currentItem]; + this.setItemInUse(this.inventory.mainInventory[this.inventory.currentItem], itemstack.getItem().getMaxItemUseDuration(itemstack)); + this.isItemInUse = true; + } + else if (this.isItemInUse && !this.isEating()) + { + this.clearItemInUse(); + this.isItemInUse = false; + } + } + + public float getShadowSize() + { + return 0.0F; + } + + public void onLivingUpdate() + { + super.updateEntityActionState(); + + if (this.otherPlayerMPPosRotationIncrements > 0) + { + double d0 = this.posX + (this.otherPlayerMPX - this.posX) / (double)this.otherPlayerMPPosRotationIncrements; + double d1 = this.posY + (this.otherPlayerMPY - this.posY) / (double)this.otherPlayerMPPosRotationIncrements; + double d2 = this.posZ + (this.otherPlayerMPZ - this.posZ) / (double)this.otherPlayerMPPosRotationIncrements; + double d3; + + for (d3 = this.otherPlayerMPYaw - (double)this.rotationYaw; d3 < -180.0D; d3 += 360.0D) + { + ; + } + + while (d3 >= 180.0D) + { + d3 -= 360.0D; + } + + this.rotationYaw = (float)((double)this.rotationYaw + d3 / (double)this.otherPlayerMPPosRotationIncrements); + this.rotationPitch = (float)((double)this.rotationPitch + (this.otherPlayerMPPitch - (double)this.rotationPitch) / (double)this.otherPlayerMPPosRotationIncrements); + --this.otherPlayerMPPosRotationIncrements; + this.setPosition(d0, d1, d2); + this.setRotation(this.rotationYaw, this.rotationPitch); + } + + this.prevCameraYaw = this.cameraYaw; + float f1 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); + float f = (float)Math.atan(-this.motionY * 0.20000000298023224D) * 15.0F; + + if (f1 > 0.1F) + { + f1 = 0.1F; + } + + if (!this.onGround || this.getHealth() <= 0.0F) + { + f1 = 0.0F; + } + + if (this.onGround || this.getHealth() <= 0.0F) + { + f = 0.0F; + } + + this.cameraYaw += (f1 - this.cameraYaw) * 0.4F; + this.cameraPitch += (f - this.cameraPitch) * 0.8F; + } + + public void setCurrentItemOrArmor(int par1, ItemStack par2ItemStack) + { + if (par1 == 0) + { + this.inventory.mainInventory[this.inventory.currentItem] = par2ItemStack; + } + else + { + this.inventory.armorInventory[par1 - 1] = par2ItemStack; + } + } + + @Override + public float getDefaultEyeHeight() + { + return 1.82F; + } + + public void addChatMessage(IChatComponent p_145747_1_) + { + Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(p_145747_1_); + } + + public boolean canCommandSenderUseCommand(int par1, String par2Str) + { + return false; + } + + public ChunkCoordinates getPlayerCoordinates() + { + return new ChunkCoordinates(MathHelper.floor_double(this.posX + 0.5D), MathHelper.floor_double(this.posY + 0.5D), MathHelper.floor_double(this.posZ + 0.5D)); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/entity/EntityPlayerSP.java b/src/main/java/net/minecraft/client/entity/EntityPlayerSP.java new file mode 100644 index 0000000..a44f113 --- /dev/null +++ b/src/main/java/net/minecraft/client/entity/EntityPlayerSP.java @@ -0,0 +1,632 @@ +package net.minecraft.client.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.Minecraft; +import net.minecraft.client.audio.PositionedSoundRecord; +import net.minecraft.client.gui.GuiCommandBlock; +import net.minecraft.client.gui.GuiEnchantment; +import net.minecraft.client.gui.GuiHopper; +import net.minecraft.client.gui.GuiMerchant; +import net.minecraft.client.gui.GuiRepair; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.GuiScreenBook; +import net.minecraft.client.gui.inventory.GuiBeacon; +import net.minecraft.client.gui.inventory.GuiBrewingStand; +import net.minecraft.client.gui.inventory.GuiChest; +import net.minecraft.client.gui.inventory.GuiCrafting; +import net.minecraft.client.gui.inventory.GuiDispenser; +import net.minecraft.client.gui.inventory.GuiEditSign; +import net.minecraft.client.gui.inventory.GuiFurnace; +import net.minecraft.client.gui.inventory.GuiScreenHorseInventory; +import net.minecraft.client.particle.EntityCrit2FX; +import net.minecraft.client.particle.EntityPickupFX; +import net.minecraft.command.server.CommandBlockLogic; +import net.minecraft.entity.Entity; +import net.minecraft.entity.IMerchant; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.attributes.IAttributeInstance; +import net.minecraft.entity.item.EntityMinecartHopper; +import net.minecraft.entity.passive.EntityHorse; +import net.minecraft.init.Items; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.Potion; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityBeacon; +import net.minecraft.tileentity.TileEntityBrewingStand; +import net.minecraft.tileentity.TileEntityCommandBlock; +import net.minecraft.tileentity.TileEntityDispenser; +import net.minecraft.tileentity.TileEntityFurnace; +import net.minecraft.tileentity.TileEntityHopper; +import net.minecraft.tileentity.TileEntitySign; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.DamageSource; +import net.minecraft.util.IChatComponent; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MouseFilter; +import net.minecraft.util.MovementInput; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Session; +import net.minecraft.world.World; +import net.minecraftforge.client.ForgeHooksClient; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.PlaySoundAtEntityEvent; + +@SideOnly(Side.CLIENT) +public class EntityPlayerSP extends AbstractClientPlayer +{ + public MovementInput movementInput; + protected Minecraft mc; + protected int sprintToggleTimer; + public int sprintingTicksLeft; + public float renderArmYaw; + public float renderArmPitch; + public float prevRenderArmYaw; + public float prevRenderArmPitch; + private int horseJumpPowerCounter; + private float horseJumpPower; + private MouseFilter field_71162_ch = new MouseFilter(); + private MouseFilter field_71160_ci = new MouseFilter(); + private MouseFilter field_71161_cj = new MouseFilter(); + public float timeInPortal; + public float prevTimeInPortal; + private static final String __OBFID = "CL_00000938"; + + public EntityPlayerSP(Minecraft par1Minecraft, World par2World, Session par3Session, int par4) + { + super(par2World, par3Session.func_148256_e()); + this.mc = par1Minecraft; + this.dimension = par4; + } + + public void updateEntityActionState() + { + super.updateEntityActionState(); + this.moveStrafing = this.movementInput.moveStrafe; + this.moveForward = this.movementInput.moveForward; + this.isJumping = this.movementInput.jump; + this.prevRenderArmYaw = this.renderArmYaw; + this.prevRenderArmPitch = this.renderArmPitch; + this.renderArmPitch = (float)((double)this.renderArmPitch + (double)(this.rotationPitch - this.renderArmPitch) * 0.5D); + this.renderArmYaw = (float)((double)this.renderArmYaw + (double)(this.rotationYaw - this.renderArmYaw) * 0.5D); + } + + public void onLivingUpdate() + { + if (this.sprintingTicksLeft > 0) + { + --this.sprintingTicksLeft; + + if (this.sprintingTicksLeft == 0) + { + this.setSprinting(false); + } + } + + if (this.sprintToggleTimer > 0) + { + --this.sprintToggleTimer; + } + + if (this.mc.playerController.enableEverythingIsScrewedUpMode()) + { + this.posX = this.posZ = 0.5D; + this.posX = 0.0D; + this.posZ = 0.0D; + this.rotationYaw = (float)this.ticksExisted / 12.0F; + this.rotationPitch = 10.0F; + this.posY = 68.5D; + } + else + { + this.prevTimeInPortal = this.timeInPortal; + + if (this.inPortal) + { + if (this.mc.currentScreen != null) + { + this.mc.displayGuiScreen((GuiScreen)null); + } + + if (this.timeInPortal == 0.0F) + { + this.mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("portal.trigger"), this.rand.nextFloat() * 0.4F + 0.8F)); + } + + this.timeInPortal += 0.0125F; + + if (this.timeInPortal >= 1.0F) + { + this.timeInPortal = 1.0F; + } + + this.inPortal = false; + } + else if (this.isPotionActive(Potion.confusion) && this.getActivePotionEffect(Potion.confusion).getDuration() > 60) + { + this.timeInPortal += 0.006666667F; + + if (this.timeInPortal > 1.0F) + { + this.timeInPortal = 1.0F; + } + } + else + { + if (this.timeInPortal > 0.0F) + { + this.timeInPortal -= 0.05F; + } + + if (this.timeInPortal < 0.0F) + { + this.timeInPortal = 0.0F; + } + } + + if (this.timeUntilPortal > 0) + { + --this.timeUntilPortal; + } + + boolean flag = this.movementInput.jump; + float f = 0.8F; + boolean flag1 = this.movementInput.moveForward >= f; + this.movementInput.updatePlayerMoveState(); + + if (this.isUsingItem() && !this.isRiding()) + { + this.movementInput.moveStrafe *= 0.2F; + this.movementInput.moveForward *= 0.2F; + this.sprintToggleTimer = 0; + } + + if (this.movementInput.sneak && this.ySize < 0.2F) + { + this.ySize = 0.2F; + } + + this.func_145771_j(this.posX - (double)this.width * 0.35D, this.boundingBox.minY + 0.5D, this.posZ + (double)this.width * 0.35D); + this.func_145771_j(this.posX - (double)this.width * 0.35D, this.boundingBox.minY + 0.5D, this.posZ - (double)this.width * 0.35D); + this.func_145771_j(this.posX + (double)this.width * 0.35D, this.boundingBox.minY + 0.5D, this.posZ - (double)this.width * 0.35D); + this.func_145771_j(this.posX + (double)this.width * 0.35D, this.boundingBox.minY + 0.5D, this.posZ + (double)this.width * 0.35D); + boolean flag2 = (float)this.getFoodStats().getFoodLevel() > 6.0F || this.capabilities.allowFlying; + + if (this.onGround && !flag1 && this.movementInput.moveForward >= f && !this.isSprinting() && flag2 && !this.isUsingItem() && !this.isPotionActive(Potion.blindness)) + { + if (this.sprintToggleTimer <= 0 && !this.mc.gameSettings.keyBindSprint.getIsKeyPressed()) + { + this.sprintToggleTimer = 7; + } + else + { + this.setSprinting(true); + } + } + + if (!this.isSprinting() && this.movementInput.moveForward >= f && flag2 && !this.isUsingItem() && !this.isPotionActive(Potion.blindness) && this.mc.gameSettings.keyBindSprint.getIsKeyPressed()) + { + this.setSprinting(true); + } + + if (this.isSprinting() && (this.movementInput.moveForward < f || this.isCollidedHorizontally || !flag2)) + { + this.setSprinting(false); + } + + if (this.capabilities.allowFlying && !flag && this.movementInput.jump) + { + if (this.flyToggleTimer == 0) + { + this.flyToggleTimer = 7; + } + else + { + this.capabilities.isFlying = !this.capabilities.isFlying; + this.sendPlayerAbilities(); + this.flyToggleTimer = 0; + } + } + + if (this.capabilities.isFlying) + { + if (this.movementInput.sneak) + { + this.motionY -= 0.15D; + } + + if (this.movementInput.jump) + { + this.motionY += 0.15D; + } + } + + if (this.isRidingHorse()) + { + if (this.horseJumpPowerCounter < 0) + { + ++this.horseJumpPowerCounter; + + if (this.horseJumpPowerCounter == 0) + { + this.horseJumpPower = 0.0F; + } + } + + if (flag && !this.movementInput.jump) + { + this.horseJumpPowerCounter = -10; + this.func_110318_g(); + } + else if (!flag && this.movementInput.jump) + { + this.horseJumpPowerCounter = 0; + this.horseJumpPower = 0.0F; + } + else if (flag) + { + ++this.horseJumpPowerCounter; + + if (this.horseJumpPowerCounter < 10) + { + this.horseJumpPower = (float)this.horseJumpPowerCounter * 0.1F; + } + else + { + this.horseJumpPower = 0.8F + 2.0F / (float)(this.horseJumpPowerCounter - 9) * 0.1F; + } + } + } + else + { + this.horseJumpPower = 0.0F; + } + + super.onLivingUpdate(); + + if (this.onGround && this.capabilities.isFlying) + { + this.capabilities.isFlying = false; + this.sendPlayerAbilities(); + } + } + } + + public float getFOVMultiplier() + { + float f = 1.0F; + + if (this.capabilities.isFlying) + { + f *= 1.1F; + } + + IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed); + f = (float)((double)f * ((iattributeinstance.getAttributeValue() / (double)this.capabilities.getWalkSpeed() + 1.0D) / 2.0D)); + + if (this.capabilities.getWalkSpeed() == 0.0F || Float.isNaN(f) || Float.isInfinite(f)) + { + f = 1.0F; + } + + if (this.isUsingItem() && this.getItemInUse().getItem() == Items.bow) + { + int i = this.getItemInUseDuration(); + float f1 = (float)i / 20.0F; + + if (f1 > 1.0F) + { + f1 = 1.0F; + } + else + { + f1 *= f1; + } + + f *= 1.0F - f1 * 0.15F; + } + + return ForgeHooksClient.getOffsetFOV(this, f); + } + + public void closeScreen() + { + super.closeScreen(); + this.mc.displayGuiScreen((GuiScreen)null); + } + + public void func_146100_a(TileEntity p_146100_1_) + { + if (p_146100_1_ instanceof TileEntitySign) + { + this.mc.displayGuiScreen(new GuiEditSign((TileEntitySign)p_146100_1_)); + } + else if (p_146100_1_ instanceof TileEntityCommandBlock) + { + this.mc.displayGuiScreen(new GuiCommandBlock(((TileEntityCommandBlock)p_146100_1_).func_145993_a())); + } + } + + public void func_146095_a(CommandBlockLogic p_146095_1_) + { + this.mc.displayGuiScreen(new GuiCommandBlock(p_146095_1_)); + } + + public void displayGUIBook(ItemStack par1ItemStack) + { + Item item = par1ItemStack.getItem(); + + if (item == Items.written_book) + { + this.mc.displayGuiScreen(new GuiScreenBook(this, par1ItemStack, false)); + } + else if (item == Items.writable_book) + { + this.mc.displayGuiScreen(new GuiScreenBook(this, par1ItemStack, true)); + } + } + + public void displayGUIChest(IInventory par1IInventory) + { + this.mc.displayGuiScreen(new GuiChest(this.inventory, par1IInventory)); + } + + public void func_146093_a(TileEntityHopper p_146093_1_) + { + this.mc.displayGuiScreen(new GuiHopper(this.inventory, p_146093_1_)); + } + + public void displayGUIHopperMinecart(EntityMinecartHopper par1EntityMinecartHopper) + { + this.mc.displayGuiScreen(new GuiHopper(this.inventory, par1EntityMinecartHopper)); + } + + public void displayGUIHorse(EntityHorse par1EntityHorse, IInventory par2IInventory) + { + this.mc.displayGuiScreen(new GuiScreenHorseInventory(this.inventory, par2IInventory, par1EntityHorse)); + } + + public void displayGUIWorkbench(int par1, int par2, int par3) + { + this.mc.displayGuiScreen(new GuiCrafting(this.inventory, this.worldObj, par1, par2, par3)); + } + + public void displayGUIEnchantment(int par1, int par2, int par3, String par4Str) + { + this.mc.displayGuiScreen(new GuiEnchantment(this.inventory, this.worldObj, par1, par2, par3, par4Str)); + } + + public void displayGUIAnvil(int par1, int par2, int par3) + { + this.mc.displayGuiScreen(new GuiRepair(this.inventory, this.worldObj, par1, par2, par3)); + } + + public void func_146101_a(TileEntityFurnace p_146101_1_) + { + this.mc.displayGuiScreen(new GuiFurnace(this.inventory, p_146101_1_)); + } + + public void func_146098_a(TileEntityBrewingStand p_146098_1_) + { + this.mc.displayGuiScreen(new GuiBrewingStand(this.inventory, p_146098_1_)); + } + + public void func_146104_a(TileEntityBeacon p_146104_1_) + { + this.mc.displayGuiScreen(new GuiBeacon(this.inventory, p_146104_1_)); + } + + public void func_146102_a(TileEntityDispenser p_146102_1_) + { + this.mc.displayGuiScreen(new GuiDispenser(this.inventory, p_146102_1_)); + } + + public void displayGUIMerchant(IMerchant par1IMerchant, String par2Str) + { + this.mc.displayGuiScreen(new GuiMerchant(this.inventory, par1IMerchant, this.worldObj, par2Str)); + } + + public void onCriticalHit(Entity par1Entity) + { + this.mc.effectRenderer.addEffect(new EntityCrit2FX(this.mc.theWorld, par1Entity)); + } + + public void onEnchantmentCritical(Entity par1Entity) + { + EntityCrit2FX entitycrit2fx = new EntityCrit2FX(this.mc.theWorld, par1Entity, "magicCrit"); + this.mc.effectRenderer.addEffect(entitycrit2fx); + } + + public void onItemPickup(Entity par1Entity, int par2) + { + this.mc.effectRenderer.addEffect(new EntityPickupFX(this.mc.theWorld, par1Entity, this, -0.5F)); + } + + public boolean isSneaking() + { + return this.movementInput.sneak && !this.sleeping; + } + + public void setPlayerSPHealth(float par1) + { + float f1 = this.getHealth() - par1; + + if (f1 <= 0.0F) + { + this.setHealth(par1); + + if (f1 < 0.0F) + { + this.hurtResistantTime = this.maxHurtResistantTime / 2; + } + } + else + { + this.lastDamage = f1; + this.setHealth(this.getHealth()); + this.hurtResistantTime = this.maxHurtResistantTime; + this.damageEntity(DamageSource.generic, f1); + this.hurtTime = this.maxHurtTime = 10; + } + } + + public void addChatComponentMessage(IChatComponent p_146105_1_) + { + this.mc.ingameGUI.getChatGUI().printChatMessage(p_146105_1_); + } + + private boolean isBlockTranslucent(int par1, int par2, int par3) + { + return this.worldObj.getBlock(par1, par2, par3).isNormalCube(); + } + + private boolean isHeadspaceFree(int x, int y, int z, int height) + { + for (int i1 = 0; i1 < height; i1++) + { + if (isBlockTranslucent(x, y + i1, z + 1)) return false; + } + return true; + } + + protected boolean func_145771_j(double p_145771_1_, double p_145771_3_, double p_145771_5_) + { + if (this.noClip) + { + return false; + } + int i = MathHelper.floor_double(p_145771_1_); + int j = MathHelper.floor_double(p_145771_3_); + int k = MathHelper.floor_double(p_145771_5_); + double d3 = p_145771_1_ - (double)i; + double d4 = p_145771_5_ - (double)k; + + int entHeight = Math.max(Math.round(this.height), 1); + + boolean inTranslucentBlock = true; + + for (int i1 = 0; i1 < entHeight; i1++) + { + if (!this.isBlockTranslucent(i, j + i1, k)) + { + inTranslucentBlock = false; + } + } + + if (inTranslucentBlock) + { + boolean flag = !isHeadspaceFree(i - 1, j, k, entHeight); + boolean flag1 = !isHeadspaceFree(i + 1, j, k, entHeight); + boolean flag2 = !isHeadspaceFree(i, j, k - 1, entHeight); + boolean flag3 = !isHeadspaceFree(i, j, k + 1, entHeight); + byte b0 = -1; + double d5 = 9999.0D; + + if (flag && d3 < d5) + { + d5 = d3; + b0 = 0; + } + + if (flag1 && 1.0D - d3 < d5) + { + d5 = 1.0D - d3; + b0 = 1; + } + + if (flag2 && d4 < d5) + { + d5 = d4; + b0 = 4; + } + + if (flag3 && 1.0D - d4 < d5) + { + d5 = 1.0D - d4; + b0 = 5; + } + + float f = 0.1F; + + if (b0 == 0) + { + this.motionX = (double)(-f); + } + + if (b0 == 1) + { + this.motionX = (double)f; + } + + if (b0 == 4) + { + this.motionZ = (double)(-f); + } + + if (b0 == 5) + { + this.motionZ = (double)f; + } + } + + return false; + } + + public void setSprinting(boolean par1) + { + super.setSprinting(par1); + this.sprintingTicksLeft = par1 ? 600 : 0; + } + + public void setXPStats(float par1, int par2, int par3) + { + this.experience = par1; + this.experienceTotal = par2; + this.experienceLevel = par3; + } + + public void addChatMessage(IChatComponent p_145747_1_) + { + this.mc.ingameGUI.getChatGUI().printChatMessage(p_145747_1_); + } + + public boolean canCommandSenderUseCommand(int par1, String par2Str) + { + return par1 <= 0; + } + + public ChunkCoordinates getPlayerCoordinates() + { + return new ChunkCoordinates(MathHelper.floor_double(this.posX + 0.5D), MathHelper.floor_double(this.posY + 0.5D), MathHelper.floor_double(this.posZ + 0.5D)); + } + + public void playSound(String par1Str, float par2, float par3) + { + PlaySoundAtEntityEvent event = new PlaySoundAtEntityEvent(this, par1Str, par2, par3); + if (MinecraftForge.EVENT_BUS.post(event)) + { + return; + } + par1Str = event.name; + this.worldObj.playSound(this.posX, this.posY - (double)this.yOffset, this.posZ, par1Str, par2, par3, false); + } + + public boolean isClientWorld() + { + return true; + } + + public boolean isRidingHorse() + { + return this.ridingEntity != null && this.ridingEntity instanceof EntityHorse; + } + + public float getHorseJumpPower() + { + return this.horseJumpPower; + } + + protected void func_110318_g() {} +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/ChatLine.java b/src/main/java/net/minecraft/client/gui/ChatLine.java new file mode 100644 index 0000000..aa4bcba --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/ChatLine.java @@ -0,0 +1,36 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.util.IChatComponent; + +@SideOnly(Side.CLIENT) +public class ChatLine +{ + private final int updateCounterCreated; + private final IChatComponent lineString; + private final int chatLineID; + private static final String __OBFID = "CL_00000627"; + + public ChatLine(int p_i45000_1_, IChatComponent p_i45000_2_, int p_i45000_3_) + { + this.lineString = p_i45000_2_; + this.updateCounterCreated = p_i45000_1_; + this.chatLineID = p_i45000_3_; + } + + public IChatComponent func_151461_a() + { + return this.lineString; + } + + public int getUpdatedCounter() + { + return this.updateCounterCreated; + } + + public int getChatLineID() + { + return this.chatLineID; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/FontRenderer.java b/src/main/java/net/minecraft/client/gui/FontRenderer.java new file mode 100644 index 0000000..df73f41 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/FontRenderer.java @@ -0,0 +1,832 @@ +package net.minecraft.client.gui; + +import com.ibm.icu.text.ArabicShaping; +import com.ibm.icu.text.ArabicShapingException; +import com.ibm.icu.text.Bidi; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.io.InputStream; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import javax.imageio.ImageIO; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.client.resources.IResourceManager; +import net.minecraft.client.resources.IResourceManagerReloadListener; +import net.minecraft.client.settings.GameSettings; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class FontRenderer implements IResourceManagerReloadListener +{ + private static final ResourceLocation[] unicodePageLocations = new ResourceLocation[256]; + private int[] charWidth = new int[256]; + public int FONT_HEIGHT = 9; + public Random fontRandom = new Random(); + private byte[] glyphWidth = new byte[65536]; + private int[] colorCode = new int[32]; + private final ResourceLocation locationFontTexture; + private final TextureManager renderEngine; + private float posX; + private float posY; + private boolean unicodeFlag; + private boolean bidiFlag; + private float red; + private float blue; + private float green; + private float alpha; + private int textColor; + private boolean randomStyle; + private boolean boldStyle; + private boolean italicStyle; + private boolean underlineStyle; + private boolean strikethroughStyle; + private static final String __OBFID = "CL_00000660"; + + public FontRenderer(GameSettings par1GameSettings, ResourceLocation par2ResourceLocation, TextureManager par3TextureManager, boolean par4) + { + this.locationFontTexture = par2ResourceLocation; + this.renderEngine = par3TextureManager; + this.unicodeFlag = par4; + par3TextureManager.bindTexture(this.locationFontTexture); + + for (int i = 0; i < 32; ++i) + { + int j = (i >> 3 & 1) * 85; + int k = (i >> 2 & 1) * 170 + j; + int l = (i >> 1 & 1) * 170 + j; + int i1 = (i >> 0 & 1) * 170 + j; + + if (i == 6) + { + k += 85; + } + + if (par1GameSettings.anaglyph) + { + int j1 = (k * 30 + l * 59 + i1 * 11) / 100; + int k1 = (k * 30 + l * 70) / 100; + int l1 = (k * 30 + i1 * 70) / 100; + k = j1; + l = k1; + i1 = l1; + } + + if (i >= 16) + { + k /= 4; + l /= 4; + i1 /= 4; + } + + this.colorCode[i] = (k & 255) << 16 | (l & 255) << 8 | i1 & 255; + } + + this.readGlyphSizes(); + } + + public void onResourceManagerReload(IResourceManager par1ResourceManager) + { + this.readFontTexture(); + } + + private void readFontTexture() + { + BufferedImage bufferedimage; + + try + { + bufferedimage = ImageIO.read(Minecraft.getMinecraft().getResourceManager().getResource(this.locationFontTexture).getInputStream()); + } + catch (IOException ioexception) + { + throw new RuntimeException(ioexception); + } + + int i = bufferedimage.getWidth(); + int j = bufferedimage.getHeight(); + int[] aint = new int[i * j]; + bufferedimage.getRGB(0, 0, i, j, aint, 0, i); + int k = j / 16; + int l = i / 16; + byte b0 = 1; + float f = 8.0F / (float)l; + int i1 = 0; + + while (i1 < 256) + { + int j1 = i1 % 16; + int k1 = i1 / 16; + + if (i1 == 32) + { + this.charWidth[i1] = 3 + b0; + } + + int l1 = l - 1; + + while (true) + { + if (l1 >= 0) + { + int i2 = j1 * l + l1; + boolean flag = true; + + for (int j2 = 0; j2 < k && flag; ++j2) + { + int k2 = (k1 * l + j2) * i; + + if ((aint[i2 + k2] >> 24 & 255) != 0) + { + flag = false; + } + } + + if (flag) + { + --l1; + continue; + } + } + + ++l1; + this.charWidth[i1] = (int)(0.5D + (double)((float)l1 * f)) + b0; + ++i1; + break; + } + } + } + + private void readGlyphSizes() + { + try + { + InputStream inputstream = Minecraft.getMinecraft().getResourceManager().getResource(new ResourceLocation("font/glyph_sizes.bin")).getInputStream(); + inputstream.read(this.glyphWidth); + } + catch (IOException ioexception) + { + throw new RuntimeException(ioexception); + } + } + + private float renderCharAtPos(int par1, char par2, boolean par3) + { + return par2 == 32 ? 4.0F : ("\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".indexOf(par2) != -1 && !this.unicodeFlag ? this.renderDefaultChar(par1, par3) : this.renderUnicodeChar(par2, par3)); + } + + private float renderDefaultChar(int par1, boolean par2) + { + float f = (float)(par1 % 16 * 8); + float f1 = (float)(par1 / 16 * 8); + float f2 = par2 ? 1.0F : 0.0F; + this.renderEngine.bindTexture(this.locationFontTexture); + float f3 = (float)this.charWidth[par1] - 0.01F; + GL11.glBegin(GL11.GL_TRIANGLE_STRIP); + GL11.glTexCoord2f(f / 128.0F, f1 / 128.0F); + GL11.glVertex3f(this.posX + f2, this.posY, 0.0F); + GL11.glTexCoord2f(f / 128.0F, (f1 + 7.99F) / 128.0F); + GL11.glVertex3f(this.posX - f2, this.posY + 7.99F, 0.0F); + GL11.glTexCoord2f((f + f3 - 1.0F) / 128.0F, f1 / 128.0F); + GL11.glVertex3f(this.posX + f3 - 1.0F + f2, this.posY, 0.0F); + GL11.glTexCoord2f((f + f3 - 1.0F) / 128.0F, (f1 + 7.99F) / 128.0F); + GL11.glVertex3f(this.posX + f3 - 1.0F - f2, this.posY + 7.99F, 0.0F); + GL11.glEnd(); + return (float)this.charWidth[par1]; + } + + private ResourceLocation getUnicodePageLocation(int par1) + { + if (unicodePageLocations[par1] == null) + { + unicodePageLocations[par1] = new ResourceLocation(String.format("textures/font/unicode_page_%02x.png", new Object[] {Integer.valueOf(par1)})); + } + + return unicodePageLocations[par1]; + } + + private void loadGlyphTexture(int par1) + { + this.renderEngine.bindTexture(this.getUnicodePageLocation(par1)); + } + + private float renderUnicodeChar(char par1, boolean par2) + { + if (this.glyphWidth[par1] == 0) + { + return 0.0F; + } + else + { + int i = par1 / 256; + this.loadGlyphTexture(i); + int j = this.glyphWidth[par1] >>> 4; + int k = this.glyphWidth[par1] & 15; + float f = (float)j; + float f1 = (float)(k + 1); + float f2 = (float)(par1 % 16 * 16) + f; + float f3 = (float)((par1 & 255) / 16 * 16); + float f4 = f1 - f - 0.02F; + float f5 = par2 ? 1.0F : 0.0F; + GL11.glBegin(GL11.GL_TRIANGLE_STRIP); + GL11.glTexCoord2f(f2 / 256.0F, f3 / 256.0F); + GL11.glVertex3f(this.posX + f5, this.posY, 0.0F); + GL11.glTexCoord2f(f2 / 256.0F, (f3 + 15.98F) / 256.0F); + GL11.glVertex3f(this.posX - f5, this.posY + 7.99F, 0.0F); + GL11.glTexCoord2f((f2 + f4) / 256.0F, f3 / 256.0F); + GL11.glVertex3f(this.posX + f4 / 2.0F + f5, this.posY, 0.0F); + GL11.glTexCoord2f((f2 + f4) / 256.0F, (f3 + 15.98F) / 256.0F); + GL11.glVertex3f(this.posX + f4 / 2.0F - f5, this.posY + 7.99F, 0.0F); + GL11.glEnd(); + return (f1 - f) / 2.0F + 1.0F; + } + } + + public int drawStringWithShadow(String par1Str, int par2, int par3, int par4) + { + return this.drawString(par1Str, par2, par3, par4, true); + } + + public int drawString(String par1Str, int par2, int par3, int par4) + { + return this.drawString(par1Str, par2, par3, par4, false); + } + + public int drawString(String par1Str, int par2, int par3, int par4, boolean par5) + { + GL11.glEnable(GL11.GL_ALPHA_TEST); + this.resetStyles(); + int l; + + if (par5) + { + l = this.renderString(par1Str, par2 + 1, par3 + 1, par4, true); + l = Math.max(l, this.renderString(par1Str, par2, par3, par4, false)); + } + else + { + l = this.renderString(par1Str, par2, par3, par4, false); + } + + return l; + } + + private String bidiReorder(String p_147647_1_) + { + try + { + Bidi bidi = new Bidi((new ArabicShaping(8)).shape(p_147647_1_), 127); + bidi.setReorderingMode(0); + return bidi.writeReordered(2); + } + catch (ArabicShapingException arabicshapingexception) + { + return p_147647_1_; + } + } + + private void resetStyles() + { + this.randomStyle = false; + this.boldStyle = false; + this.italicStyle = false; + this.underlineStyle = false; + this.strikethroughStyle = false; + } + + private void renderStringAtPos(String par1Str, boolean par2) + { + for (int i = 0; i < par1Str.length(); ++i) + { + char c0 = par1Str.charAt(i); + int j; + int k; + + if (c0 == 167 && i + 1 < par1Str.length()) + { + j = "0123456789abcdefklmnor".indexOf(par1Str.toLowerCase().charAt(i + 1)); + + if (j < 16) + { + this.randomStyle = false; + this.boldStyle = false; + this.strikethroughStyle = false; + this.underlineStyle = false; + this.italicStyle = false; + + if (j < 0 || j > 15) + { + j = 15; + } + + if (par2) + { + j += 16; + } + + k = this.colorCode[j]; + this.textColor = k; + GL11.glColor4f((float)(k >> 16) / 255.0F, (float)(k >> 8 & 255) / 255.0F, (float)(k & 255) / 255.0F, this.alpha); + } + else if (j == 16) + { + this.randomStyle = true; + } + else if (j == 17) + { + this.boldStyle = true; + } + else if (j == 18) + { + this.strikethroughStyle = true; + } + else if (j == 19) + { + this.underlineStyle = true; + } + else if (j == 20) + { + this.italicStyle = true; + } + else if (j == 21) + { + this.randomStyle = false; + this.boldStyle = false; + this.strikethroughStyle = false; + this.underlineStyle = false; + this.italicStyle = false; + GL11.glColor4f(this.red, this.blue, this.green, this.alpha); + } + + ++i; + } + else + { + j = "\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".indexOf(c0); + + if (this.randomStyle && j != -1) + { + do + { + k = this.fontRandom.nextInt(this.charWidth.length); + } + while (this.charWidth[j] != this.charWidth[k]); + + j = k; + } + + float f1 = this.unicodeFlag ? 0.5F : 1.0F; + boolean flag1 = (c0 == 0 || j == -1 || this.unicodeFlag) && par2; + + if (flag1) + { + this.posX -= f1; + this.posY -= f1; + } + + float f = this.renderCharAtPos(j, c0, this.italicStyle); + + if (flag1) + { + this.posX += f1; + this.posY += f1; + } + + if (this.boldStyle) + { + this.posX += f1; + + if (flag1) + { + this.posX -= f1; + this.posY -= f1; + } + + this.renderCharAtPos(j, c0, this.italicStyle); + this.posX -= f1; + + if (flag1) + { + this.posX += f1; + this.posY += f1; + } + + ++f; + } + + Tessellator tessellator; + + if (this.strikethroughStyle) + { + tessellator = Tessellator.instance; + GL11.glDisable(GL11.GL_TEXTURE_2D); + tessellator.startDrawingQuads(); + tessellator.addVertex((double)this.posX, (double)(this.posY + (float)(this.FONT_HEIGHT / 2)), 0.0D); + tessellator.addVertex((double)(this.posX + f), (double)(this.posY + (float)(this.FONT_HEIGHT / 2)), 0.0D); + tessellator.addVertex((double)(this.posX + f), (double)(this.posY + (float)(this.FONT_HEIGHT / 2) - 1.0F), 0.0D); + tessellator.addVertex((double)this.posX, (double)(this.posY + (float)(this.FONT_HEIGHT / 2) - 1.0F), 0.0D); + tessellator.draw(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + + if (this.underlineStyle) + { + tessellator = Tessellator.instance; + GL11.glDisable(GL11.GL_TEXTURE_2D); + tessellator.startDrawingQuads(); + int l = this.underlineStyle ? -1 : 0; + tessellator.addVertex((double)(this.posX + (float)l), (double)(this.posY + (float)this.FONT_HEIGHT), 0.0D); + tessellator.addVertex((double)(this.posX + f), (double)(this.posY + (float)this.FONT_HEIGHT), 0.0D); + tessellator.addVertex((double)(this.posX + f), (double)(this.posY + (float)this.FONT_HEIGHT - 1.0F), 0.0D); + tessellator.addVertex((double)(this.posX + (float)l), (double)(this.posY + (float)this.FONT_HEIGHT - 1.0F), 0.0D); + tessellator.draw(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + + this.posX += (float)((int)f); + } + } + } + + private int renderStringAligned(String par1Str, int par2, int par3, int par4, int par5, boolean par6) + { + if (this.bidiFlag) + { + int i1 = this.getStringWidth(this.bidiReorder(par1Str)); + par2 = par2 + par4 - i1; + } + + return this.renderString(par1Str, par2, par3, par5, par6); + } + + private int renderString(String par1Str, int par2, int par3, int par4, boolean par5) + { + if (par1Str == null) + { + return 0; + } + else + { + if (this.bidiFlag) + { + par1Str = this.bidiReorder(par1Str); + } + + if ((par4 & -67108864) == 0) + { + par4 |= -16777216; + } + + if (par5) + { + par4 = (par4 & 16579836) >> 2 | par4 & -16777216; + } + + this.red = (float)(par4 >> 16 & 255) / 255.0F; + this.blue = (float)(par4 >> 8 & 255) / 255.0F; + this.green = (float)(par4 & 255) / 255.0F; + this.alpha = (float)(par4 >> 24 & 255) / 255.0F; + GL11.glColor4f(this.red, this.blue, this.green, this.alpha); + this.posX = (float)par2; + this.posY = (float)par3; + this.renderStringAtPos(par1Str, par5); + return (int)this.posX; + } + } + + public int getStringWidth(String par1Str) + { + if (par1Str == null) + { + return 0; + } + else + { + int i = 0; + boolean flag = false; + + for (int j = 0; j < par1Str.length(); ++j) + { + char c0 = par1Str.charAt(j); + int k = this.getCharWidth(c0); + + if (k < 0 && j < par1Str.length() - 1) + { + ++j; + c0 = par1Str.charAt(j); + + if (c0 != 108 && c0 != 76) + { + if (c0 == 114 || c0 == 82) + { + flag = false; + } + } + else + { + flag = true; + } + + k = 0; + } + + i += k; + + if (flag) + { + ++i; + } + } + + return i; + } + } + + public int getCharWidth(char par1) + { + if (par1 == 167) + { + return -1; + } + else if (par1 == 32) + { + return 4; + } + else + { + int i = "\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000".indexOf(par1); + + if (par1 > 0 && i != -1 && !this.unicodeFlag) + { + return this.charWidth[i]; + } + else if (this.glyphWidth[par1] != 0) + { + int j = this.glyphWidth[par1] >>> 4; + int k = this.glyphWidth[par1] & 15; + + if (k > 7) + { + k = 15; + j = 0; + } + + ++k; + return (k - j) / 2 + 1; + } + else + { + return 0; + } + } + } + + public String trimStringToWidth(String par1Str, int par2) + { + return this.trimStringToWidth(par1Str, par2, false); + } + + public String trimStringToWidth(String par1Str, int par2, boolean par3) + { + StringBuilder stringbuilder = new StringBuilder(); + int j = 0; + int k = par3 ? par1Str.length() - 1 : 0; + int l = par3 ? -1 : 1; + boolean flag1 = false; + boolean flag2 = false; + + for (int i1 = k; i1 >= 0 && i1 < par1Str.length() && j < par2; i1 += l) + { + char c0 = par1Str.charAt(i1); + int j1 = this.getCharWidth(c0); + + if (flag1) + { + flag1 = false; + + if (c0 != 108 && c0 != 76) + { + if (c0 == 114 || c0 == 82) + { + flag2 = false; + } + } + else + { + flag2 = true; + } + } + else if (j1 < 0) + { + flag1 = true; + } + else + { + j += j1; + + if (flag2) + { + ++j; + } + } + + if (j > par2) + { + break; + } + + if (par3) + { + stringbuilder.insert(0, c0); + } + else + { + stringbuilder.append(c0); + } + } + + return stringbuilder.toString(); + } + + private String trimStringNewline(String par1Str) + { + while (par1Str != null && par1Str.endsWith("\n")) + { + par1Str = par1Str.substring(0, par1Str.length() - 1); + } + + return par1Str; + } + + public void drawSplitString(String par1Str, int par2, int par3, int par4, int par5) + { + this.resetStyles(); + this.textColor = par5; + par1Str = this.trimStringNewline(par1Str); + this.renderSplitString(par1Str, par2, par3, par4, false); + } + + private void renderSplitString(String par1Str, int par2, int par3, int par4, boolean par5) + { + List list = this.listFormattedStringToWidth(par1Str, par4); + + for (Iterator iterator = list.iterator(); iterator.hasNext(); par3 += this.FONT_HEIGHT) + { + String s1 = (String)iterator.next(); + this.renderStringAligned(s1, par2, par3, par4, this.textColor, par5); + } + } + + public int splitStringWidth(String par1Str, int par2) + { + return this.FONT_HEIGHT * this.listFormattedStringToWidth(par1Str, par2).size(); + } + + public void setUnicodeFlag(boolean par1) + { + this.unicodeFlag = par1; + } + + public boolean getUnicodeFlag() + { + return this.unicodeFlag; + } + + public void setBidiFlag(boolean par1) + { + this.bidiFlag = par1; + } + + public List listFormattedStringToWidth(String par1Str, int par2) + { + return Arrays.asList(this.wrapFormattedStringToWidth(par1Str, par2).split("\n")); + } + + String wrapFormattedStringToWidth(String par1Str, int par2) + { + int j = this.sizeStringToWidth(par1Str, par2); + + if (par1Str.length() <= j) + { + return par1Str; + } + else + { + String s1 = par1Str.substring(0, j); + char c0 = par1Str.charAt(j); + boolean flag = c0 == 32 || c0 == 10; + String s2 = getFormatFromString(s1) + par1Str.substring(j + (flag ? 1 : 0)); + return s1 + "\n" + this.wrapFormattedStringToWidth(s2, par2); + } + } + + private int sizeStringToWidth(String par1Str, int par2) + { + int j = par1Str.length(); + int k = 0; + int l = 0; + int i1 = -1; + + for (boolean flag = false; l < j; ++l) + { + char c0 = par1Str.charAt(l); + + switch (c0) + { + case 10: + --l; + break; + case 167: + if (l < j - 1) + { + ++l; + char c1 = par1Str.charAt(l); + + if (c1 != 108 && c1 != 76) + { + if (c1 == 114 || c1 == 82 || isFormatColor(c1)) + { + flag = false; + } + } + else + { + flag = true; + } + } + + break; + case 32: + i1 = l; + default: + k += this.getCharWidth(c0); + + if (flag) + { + ++k; + } + } + + if (c0 == 10) + { + ++l; + i1 = l; + break; + } + + if (k > par2) + { + break; + } + } + + return l != j && i1 != -1 && i1 < l ? i1 : l; + } + + private static boolean isFormatColor(char par0) + { + return par0 >= 48 && par0 <= 57 || par0 >= 97 && par0 <= 102 || par0 >= 65 && par0 <= 70; + } + + private static boolean isFormatSpecial(char par0) + { + return par0 >= 107 && par0 <= 111 || par0 >= 75 && par0 <= 79 || par0 == 114 || par0 == 82; + } + + private static String getFormatFromString(String par0Str) + { + String s1 = ""; + int i = -1; + int j = par0Str.length(); + + while ((i = par0Str.indexOf(167, i + 1)) != -1) + { + if (i < j - 1) + { + char c0 = par0Str.charAt(i + 1); + + if (isFormatColor(c0)) + { + s1 = "\u00a7" + c0; + } + else if (isFormatSpecial(c0)) + { + s1 = s1 + "\u00a7" + c0; + } + } + } + + return s1; + } + + public boolean getBidiFlag() + { + return this.bidiFlag; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/Gui.java b/src/main/java/net/minecraft/client/gui/Gui.java new file mode 100644 index 0000000..690d836 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/Gui.java @@ -0,0 +1,157 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class Gui +{ + public static final ResourceLocation optionsBackground = new ResourceLocation("textures/gui/options_background.png"); + public static final ResourceLocation statIcons = new ResourceLocation("textures/gui/container/stats_icons.png"); + public static final ResourceLocation icons = new ResourceLocation("textures/gui/icons.png"); + protected float zLevel; + private static final String __OBFID = "CL_00000662"; + + protected void drawHorizontalLine(int par1, int par2, int par3, int par4) + { + if (par2 < par1) + { + int i1 = par1; + par1 = par2; + par2 = i1; + } + + drawRect(par1, par3, par2 + 1, par3 + 1, par4); + } + + protected void drawVerticalLine(int par1, int par2, int par3, int par4) + { + if (par3 < par2) + { + int i1 = par2; + par2 = par3; + par3 = i1; + } + + drawRect(par1, par2 + 1, par1 + 1, par3, par4); + } + + public static void drawRect(int par0, int par1, int par2, int par3, int par4) + { + int j1; + + if (par0 < par2) + { + j1 = par0; + par0 = par2; + par2 = j1; + } + + if (par1 < par3) + { + j1 = par1; + par1 = par3; + par3 = j1; + } + + float f3 = (float)(par4 >> 24 & 255) / 255.0F; + float f = (float)(par4 >> 16 & 255) / 255.0F; + float f1 = (float)(par4 >> 8 & 255) / 255.0F; + float f2 = (float)(par4 & 255) / 255.0F; + Tessellator tessellator = Tessellator.instance; + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_TEXTURE_2D); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glColor4f(f, f1, f2, f3); + tessellator.startDrawingQuads(); + tessellator.addVertex((double)par0, (double)par3, 0.0D); + tessellator.addVertex((double)par2, (double)par3, 0.0D); + tessellator.addVertex((double)par2, (double)par1, 0.0D); + tessellator.addVertex((double)par0, (double)par1, 0.0D); + tessellator.draw(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_BLEND); + } + + protected void drawGradientRect(int par1, int par2, int par3, int par4, int par5, int par6) + { + float f = (float)(par5 >> 24 & 255) / 255.0F; + float f1 = (float)(par5 >> 16 & 255) / 255.0F; + float f2 = (float)(par5 >> 8 & 255) / 255.0F; + float f3 = (float)(par5 & 255) / 255.0F; + float f4 = (float)(par6 >> 24 & 255) / 255.0F; + float f5 = (float)(par6 >> 16 & 255) / 255.0F; + float f6 = (float)(par6 >> 8 & 255) / 255.0F; + float f7 = (float)(par6 & 255) / 255.0F; + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_ALPHA_TEST); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glShadeModel(GL11.GL_SMOOTH); + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_F(f1, f2, f3, f); + tessellator.addVertex((double)par3, (double)par2, (double)this.zLevel); + tessellator.addVertex((double)par1, (double)par2, (double)this.zLevel); + tessellator.setColorRGBA_F(f5, f6, f7, f4); + tessellator.addVertex((double)par1, (double)par4, (double)this.zLevel); + tessellator.addVertex((double)par3, (double)par4, (double)this.zLevel); + tessellator.draw(); + GL11.glShadeModel(GL11.GL_FLAT); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + + public void drawCenteredString(FontRenderer par1FontRenderer, String par2Str, int par3, int par4, int par5) + { + par1FontRenderer.drawStringWithShadow(par2Str, par3 - par1FontRenderer.getStringWidth(par2Str) / 2, par4, par5); + } + + public void drawString(FontRenderer par1FontRenderer, String par2Str, int par3, int par4, int par5) + { + par1FontRenderer.drawStringWithShadow(par2Str, par3, par4, par5); + } + + public void drawTexturedModalRect(int par1, int par2, int par3, int par4, int par5, int par6) + { + float f = 0.00390625F; + float f1 = 0.00390625F; + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV((double)(par1 + 0), (double)(par2 + par6), (double)this.zLevel, (double)((float)(par3 + 0) * f), (double)((float)(par4 + par6) * f1)); + tessellator.addVertexWithUV((double)(par1 + par5), (double)(par2 + par6), (double)this.zLevel, (double)((float)(par3 + par5) * f), (double)((float)(par4 + par6) * f1)); + tessellator.addVertexWithUV((double)(par1 + par5), (double)(par2 + 0), (double)this.zLevel, (double)((float)(par3 + par5) * f), (double)((float)(par4 + 0) * f1)); + tessellator.addVertexWithUV((double)(par1 + 0), (double)(par2 + 0), (double)this.zLevel, (double)((float)(par3 + 0) * f), (double)((float)(par4 + 0) * f1)); + tessellator.draw(); + } + + public void drawTexturedModelRectFromIcon(int par1, int par2, IIcon par3Icon, int par4, int par5) + { + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV((double)(par1 + 0), (double)(par2 + par5), (double)this.zLevel, (double)par3Icon.getMinU(), (double)par3Icon.getMaxV()); + tessellator.addVertexWithUV((double)(par1 + par4), (double)(par2 + par5), (double)this.zLevel, (double)par3Icon.getMaxU(), (double)par3Icon.getMaxV()); + tessellator.addVertexWithUV((double)(par1 + par4), (double)(par2 + 0), (double)this.zLevel, (double)par3Icon.getMaxU(), (double)par3Icon.getMinV()); + tessellator.addVertexWithUV((double)(par1 + 0), (double)(par2 + 0), (double)this.zLevel, (double)par3Icon.getMinU(), (double)par3Icon.getMinV()); + tessellator.draw(); + } + + public static void func_146110_a(int p_146110_0_, int p_146110_1_, float p_146110_2_, float p_146110_3_, int p_146110_4_, int p_146110_5_, float p_146110_6_, float p_146110_7_) + { + float f4 = 1.0F / p_146110_6_; + float f5 = 1.0F / p_146110_7_; + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV((double)p_146110_0_, (double)(p_146110_1_ + p_146110_5_), 0.0D, (double)(p_146110_2_ * f4), (double)((p_146110_3_ + (float)p_146110_5_) * f5)); + tessellator.addVertexWithUV((double)(p_146110_0_ + p_146110_4_), (double)(p_146110_1_ + p_146110_5_), 0.0D, (double)((p_146110_2_ + (float)p_146110_4_) * f4), (double)((p_146110_3_ + (float)p_146110_5_) * f5)); + tessellator.addVertexWithUV((double)(p_146110_0_ + p_146110_4_), (double)p_146110_1_, 0.0D, (double)((p_146110_2_ + (float)p_146110_4_) * f4), (double)(p_146110_3_ * f5)); + tessellator.addVertexWithUV((double)p_146110_0_, (double)p_146110_1_, 0.0D, (double)(p_146110_2_ * f4), (double)(p_146110_3_ * f5)); + tessellator.draw(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiButton.java b/src/main/java/net/minecraft/client/gui/GuiButton.java new file mode 100644 index 0000000..e0c749a --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiButton.java @@ -0,0 +1,122 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.Minecraft; +import net.minecraft.client.audio.PositionedSoundRecord; +import net.minecraft.client.audio.SoundHandler; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class GuiButton extends Gui +{ + protected static final ResourceLocation buttonTextures = new ResourceLocation("textures/gui/widgets.png"); + protected int width; + protected int height; + public int xPosition; + public int yPosition; + public String displayString; + public int id; + public boolean enabled; + public boolean visible; + protected boolean field_146123_n; + private static final String __OBFID = "CL_00000668"; + public int packedFGColour; + + public GuiButton(int par1, int par2, int par3, String par4Str) + { + this(par1, par2, par3, 200, 20, par4Str); + } + + public GuiButton(int par1, int par2, int par3, int par4, int par5, String par6Str) + { + this.width = 200; + this.height = 20; + this.enabled = true; + this.visible = true; + this.id = par1; + this.xPosition = par2; + this.yPosition = par3; + this.width = par4; + this.height = par5; + this.displayString = par6Str; + } + + protected int getHoverState(boolean p_146114_1_) + { + byte b0 = 1; + + if (!this.enabled) + { + b0 = 0; + } + else if (p_146114_1_) + { + b0 = 2; + } + + return b0; + } + + public void drawButton(Minecraft p_146112_1_, int p_146112_2_, int p_146112_3_) + { + if (this.visible) + { + FontRenderer fontrenderer = p_146112_1_.fontRenderer; + p_146112_1_.getTextureManager().bindTexture(buttonTextures); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.field_146123_n = p_146112_2_ >= this.xPosition && p_146112_3_ >= this.yPosition && p_146112_2_ < this.xPosition + this.width && p_146112_3_ < this.yPosition + this.height; + int k = this.getHoverState(this.field_146123_n); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 46 + k * 20, this.width / 2, this.height); + this.drawTexturedModalRect(this.xPosition + this.width / 2, this.yPosition, 200 - this.width / 2, 46 + k * 20, this.width / 2, this.height); + this.mouseDragged(p_146112_1_, p_146112_2_, p_146112_3_); + int l = 14737632; + + if (packedFGColour != 0) + { + l = packedFGColour; + } + else if (!this.enabled) + { + l = 10526880; + } + else if (this.field_146123_n) + { + l = 16777120; + } + + this.drawCenteredString(fontrenderer, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, l); + } + } + + protected void mouseDragged(Minecraft p_146119_1_, int p_146119_2_, int p_146119_3_) {} + + public void mouseReleased(int p_146118_1_, int p_146118_2_) {} + + public boolean mousePressed(Minecraft p_146116_1_, int p_146116_2_, int p_146116_3_) + { + return this.enabled && this.visible && p_146116_2_ >= this.xPosition && p_146116_3_ >= this.yPosition && p_146116_2_ < this.xPosition + this.width && p_146116_3_ < this.yPosition + this.height; + } + + public boolean func_146115_a() + { + return this.field_146123_n; + } + + public void func_146111_b(int p_146111_1_, int p_146111_2_) {} + + public void func_146113_a(SoundHandler p_146113_1_) + { + p_146113_1_.playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); + } + + public int getButtonWidth() + { + return this.width; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiButtonLanguage.java b/src/main/java/net/minecraft/client/gui/GuiButtonLanguage.java new file mode 100644 index 0000000..e220713 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiButtonLanguage.java @@ -0,0 +1,35 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.Minecraft; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class GuiButtonLanguage extends GuiButton +{ + private static final String __OBFID = "CL_00000672"; + + public GuiButtonLanguage(int par1, int par2, int par3) + { + super(par1, par2, par3, 20, 20, ""); + } + + public void drawButton(Minecraft p_146112_1_, int p_146112_2_, int p_146112_3_) + { + if (this.visible) + { + p_146112_1_.getTextureManager().bindTexture(GuiButton.buttonTextures); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + boolean flag = p_146112_2_ >= this.xPosition && p_146112_3_ >= this.yPosition && p_146112_2_ < this.xPosition + this.width && p_146112_3_ < this.yPosition + this.height; + int k = 106; + + if (flag) + { + k += this.height; + } + + this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, k, this.width, this.height); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiButtonLink.java b/src/main/java/net/minecraft/client/gui/GuiButtonLink.java new file mode 100644 index 0000000..4a5311f --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiButtonLink.java @@ -0,0 +1,34 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.net.URI; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +@SideOnly(Side.CLIENT) +public class GuiButtonLink extends GuiButton +{ + private static final Logger logger = LogManager.getLogger(); + private static final String __OBFID = "CL_00000673"; + + public GuiButtonLink(int par1, int par2, int par3, int par4, int par5, String par6Str) + { + super(par1, par2, par3, par4, par5, par6Str); + } + + public void openURI(String p_146138_1_) + { + try + { + URI uri = new URI(p_146138_1_); + Class oclass = Class.forName("java.awt.Desktop"); + Object object = oclass.getMethod("getDesktop", new Class[0]).invoke((Object)null, new Object[0]); + oclass.getMethod("browse", new Class[] {URI.class}).invoke(object, new Object[] {uri}); + } + catch (Throwable throwable) + { + logger.error("Couldn\'t open link", throwable); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiChat.java b/src/main/java/net/minecraft/client/gui/GuiChat.java new file mode 100644 index 0000000..bc0f2c9 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiChat.java @@ -0,0 +1,469 @@ +package net.minecraft.client.gui; + +import com.google.common.collect.Lists; +import com.google.common.collect.ObjectArrays; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.File; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import net.minecraft.event.ClickEvent; +import net.minecraft.event.HoverEvent; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.JsonToNBT; +import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.NBTException; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.play.client.C14PacketTabComplete; +import net.minecraft.stats.Achievement; +import net.minecraft.stats.StatBase; +import net.minecraft.stats.StatList; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IChatComponent; +import net.minecraftforge.client.ClientCommandHandler; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class GuiChat extends GuiScreen +{ + private static final Logger logger = LogManager.getLogger(); + private String field_146410_g = ""; + private int sentHistoryCursor = -1; + private boolean field_146417_i; + private boolean field_146414_r; + private int field_146413_s; + private List field_146412_t = new ArrayList(); + private URI clickedURI; + protected GuiTextField inputField; + private String defaultInputFieldText = ""; + private static final String __OBFID = "CL_00000682"; + + public GuiChat() {} + + public GuiChat(String par1Str) + { + this.defaultInputFieldText = par1Str; + } + + public void initGui() + { + Keyboard.enableRepeatEvents(true); + this.sentHistoryCursor = this.mc.ingameGUI.getChatGUI().getSentMessages().size(); + this.inputField = new GuiTextField(this.fontRendererObj, 4, this.height - 12, this.width - 4, 12); + this.inputField.setMaxStringLength(100); + this.inputField.setEnableBackgroundDrawing(false); + this.inputField.setFocused(true); + this.inputField.setText(this.defaultInputFieldText); + this.inputField.setCanLoseFocus(false); + } + + public void onGuiClosed() + { + Keyboard.enableRepeatEvents(false); + this.mc.ingameGUI.getChatGUI().resetScroll(); + } + + public void updateScreen() + { + this.inputField.updateCursorCounter(); + } + + protected void keyTyped(char par1, int par2) + { + this.field_146414_r = false; + + if (par2 == 15) + { + this.func_146404_p_(); + } + else + { + this.field_146417_i = false; + } + + if (par2 == 1) + { + this.mc.displayGuiScreen((GuiScreen)null); + } + else if (par2 != 28 && par2 != 156) + { + if (par2 == 200) + { + this.getSentHistory(-1); + } + else if (par2 == 208) + { + this.getSentHistory(1); + } + else if (par2 == 201) + { + this.mc.ingameGUI.getChatGUI().scroll(this.mc.ingameGUI.getChatGUI().func_146232_i() - 1); + } + else if (par2 == 209) + { + this.mc.ingameGUI.getChatGUI().scroll(-this.mc.ingameGUI.getChatGUI().func_146232_i() + 1); + } + else + { + this.inputField.textboxKeyTyped(par1, par2); + } + } + else + { + String s = this.inputField.getText().trim(); + + if (s.length() > 0) + { + this.func_146403_a(s); + } + + this.mc.displayGuiScreen((GuiScreen)null); + } + } + + public void func_146403_a(String p_146403_1_) + { + this.mc.ingameGUI.getChatGUI().addToSentMessages(p_146403_1_); + if (ClientCommandHandler.instance.executeCommand(mc.thePlayer, p_146403_1_) == 1) return; + this.mc.thePlayer.sendChatMessage(p_146403_1_); + } + + public void handleMouseInput() + { + super.handleMouseInput(); + int i = Mouse.getEventDWheel(); + + if (i != 0) + { + if (i > 1) + { + i = 1; + } + + if (i < -1) + { + i = -1; + } + + if (!isShiftKeyDown()) + { + i *= 7; + } + + this.mc.ingameGUI.getChatGUI().scroll(i); + } + } + + protected void mouseClicked(int par1, int par2, int par3) + { + if (par3 == 0 && this.mc.gameSettings.chatLinks) + { + IChatComponent ichatcomponent = this.mc.ingameGUI.getChatGUI().func_146236_a(Mouse.getX(), Mouse.getY()); + + if (ichatcomponent != null) + { + ClickEvent clickevent = ichatcomponent.getChatStyle().getChatClickEvent(); + + if (clickevent != null) + { + if (isShiftKeyDown()) + { + this.inputField.writeText(ichatcomponent.getUnformattedTextForChat()); + } + else + { + URI uri; + + if (clickevent.getAction() == ClickEvent.Action.OPEN_URL) + { + try + { + uri = new URI(clickevent.getValue()); + + if (this.mc.gameSettings.chatLinksPrompt) + { + this.clickedURI = uri; + this.mc.displayGuiScreen(new GuiConfirmOpenLink(this, clickevent.getValue(), 0, false)); + } + else + { + this.func_146407_a(uri); + } + } + catch (URISyntaxException urisyntaxexception) + { + logger.error("Can\'t open url for " + clickevent, urisyntaxexception); + } + } + else if (clickevent.getAction() == ClickEvent.Action.OPEN_FILE) + { + uri = (new File(clickevent.getValue())).toURI(); + this.func_146407_a(uri); + } + else if (clickevent.getAction() == ClickEvent.Action.SUGGEST_COMMAND) + { + this.inputField.setText(clickevent.getValue()); + } + else if (clickevent.getAction() == ClickEvent.Action.RUN_COMMAND) + { + this.func_146403_a(clickevent.getValue()); + } + else + { + logger.error("Don\'t know how to handle " + clickevent); + } + } + + return; + } + } + } + + this.inputField.mouseClicked(par1, par2, par3); + super.mouseClicked(par1, par2, par3); + } + + public void confirmClicked(boolean par1, int par2) + { + if (par2 == 0) + { + if (par1) + { + this.func_146407_a(this.clickedURI); + } + + this.clickedURI = null; + this.mc.displayGuiScreen(this); + } + } + + private void func_146407_a(URI p_146407_1_) + { + try + { + Class oclass = Class.forName("java.awt.Desktop"); + Object object = oclass.getMethod("getDesktop", new Class[0]).invoke((Object)null, new Object[0]); + oclass.getMethod("browse", new Class[] {URI.class}).invoke(object, new Object[] {p_146407_1_}); + } + catch (Throwable throwable) + { + logger.error("Couldn\'t open link", throwable); + } + } + + public void func_146404_p_() + { + String s1; + + if (this.field_146417_i) + { + this.inputField.deleteFromCursor(this.inputField.func_146197_a(-1, this.inputField.getCursorPosition(), false) - this.inputField.getCursorPosition()); + + if (this.field_146413_s >= this.field_146412_t.size()) + { + this.field_146413_s = 0; + } + } + else + { + int i = this.inputField.func_146197_a(-1, this.inputField.getCursorPosition(), false); + this.field_146412_t.clear(); + this.field_146413_s = 0; + String s = this.inputField.getText().substring(i).toLowerCase(); + s1 = this.inputField.getText().substring(0, this.inputField.getCursorPosition()); + this.func_146405_a(s1, s); + + if (this.field_146412_t.isEmpty()) + { + return; + } + + this.field_146417_i = true; + this.inputField.deleteFromCursor(i - this.inputField.getCursorPosition()); + } + + if (this.field_146412_t.size() > 1) + { + StringBuilder stringbuilder = new StringBuilder(); + + for (Iterator iterator = this.field_146412_t.iterator(); iterator.hasNext(); stringbuilder.append(s1)) + { + s1 = (String)iterator.next(); + + if (stringbuilder.length() > 0) + { + stringbuilder.append(", "); + } + } + + this.mc.ingameGUI.getChatGUI().printChatMessageWithOptionalDeletion(new ChatComponentText(stringbuilder.toString()), 1); + } + + this.inputField.writeText(EnumChatFormatting.getTextWithoutFormattingCodes((String)this.field_146412_t.get(this.field_146413_s++))); + } + + private void func_146405_a(String p_146405_1_, String p_146405_2_) + { + if (p_146405_1_.length() >= 1) + { + ClientCommandHandler.instance.autoComplete(p_146405_1_, p_146405_2_); + this.mc.thePlayer.sendQueue.addToSendQueue(new C14PacketTabComplete(p_146405_1_)); + this.field_146414_r = true; + } + } + + public void getSentHistory(int p_146402_1_) + { + int j = this.sentHistoryCursor + p_146402_1_; + int k = this.mc.ingameGUI.getChatGUI().getSentMessages().size(); + + if (j < 0) + { + j = 0; + } + + if (j > k) + { + j = k; + } + + if (j != this.sentHistoryCursor) + { + if (j == k) + { + this.sentHistoryCursor = k; + this.inputField.setText(this.field_146410_g); + } + else + { + if (this.sentHistoryCursor == k) + { + this.field_146410_g = this.inputField.getText(); + } + + this.inputField.setText((String)this.mc.ingameGUI.getChatGUI().getSentMessages().get(j)); + this.sentHistoryCursor = j; + } + } + } + + public void drawScreen(int par1, int par2, float par3) + { + drawRect(2, this.height - 14, this.width - 2, this.height - 2, Integer.MIN_VALUE); + this.inputField.drawTextBox(); + IChatComponent ichatcomponent = this.mc.ingameGUI.getChatGUI().func_146236_a(Mouse.getX(), Mouse.getY()); + + if (ichatcomponent != null && ichatcomponent.getChatStyle().getChatHoverEvent() != null) + { + HoverEvent hoverevent = ichatcomponent.getChatStyle().getChatHoverEvent(); + + if (hoverevent.getAction() == HoverEvent.Action.SHOW_ITEM) + { + ItemStack itemstack = null; + + try + { + NBTBase nbtbase = JsonToNBT.func_150315_a(hoverevent.getValue().getUnformattedText()); + + if (nbtbase != null && nbtbase instanceof NBTTagCompound) + { + itemstack = ItemStack.loadItemStackFromNBT((NBTTagCompound)nbtbase); + } + } + catch (NBTException nbtexception) + { + ; + } + + if (itemstack != null) + { + this.renderToolTip(itemstack, par1, par2); + } + else + { + this.drawCreativeTabHoveringText(EnumChatFormatting.RED + "Invalid Item!", par1, par2); + } + } + else if (hoverevent.getAction() == HoverEvent.Action.SHOW_TEXT) + { + this.drawCreativeTabHoveringText(hoverevent.getValue().getFormattedText(), par1, par2); + } + else if (hoverevent.getAction() == HoverEvent.Action.SHOW_ACHIEVEMENT) + { + StatBase statbase = StatList.func_151177_a(hoverevent.getValue().getUnformattedText()); + + if (statbase != null) + { + IChatComponent ichatcomponent1 = statbase.func_150951_e(); + ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("stats.tooltip.type." + (statbase.isAchievement() ? "achievement" : "statistic"), new Object[0]); + chatcomponenttranslation.getChatStyle().setItalic(Boolean.valueOf(true)); + String s = statbase instanceof Achievement ? ((Achievement)statbase).getDescription() : null; + ArrayList arraylist = Lists.newArrayList(new String[] {ichatcomponent1.getFormattedText(), chatcomponenttranslation.getFormattedText()}); + + if (s != null) + { + arraylist.addAll(this.fontRendererObj.listFormattedStringToWidth(s, 150)); + } + + this.func_146283_a(arraylist, par1, par2); + } + else + { + this.drawCreativeTabHoveringText(EnumChatFormatting.RED + "Invalid statistic/achievement!", par1, par2); + } + } + + GL11.glDisable(GL11.GL_LIGHTING); + } + + super.drawScreen(par1, par2, par3); + } + + public void func_146406_a(String[] p_146406_1_) + { + if (this.field_146414_r) + { + this.field_146417_i = false; + this.field_146412_t.clear(); + String[] astring1 = p_146406_1_; + int i = p_146406_1_.length; + + String[] complete = ClientCommandHandler.instance.latestAutoComplete; + if (complete != null) + { + astring1 = ObjectArrays.concat(complete, astring1, String.class); + i = astring1.length; + } + + for (int j = 0; j < i; ++j) + { + String s = astring1[j]; + + if (s.length() > 0) + { + this.field_146412_t.add(s); + } + } + + if (this.field_146412_t.size() > 0) + { + this.field_146417_i = true; + this.func_146404_p_(); + } + } + } + + public boolean doesGuiPauseGame() + { + return false; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiCommandBlock.java b/src/main/java/net/minecraft/client/gui/GuiCommandBlock.java new file mode 100644 index 0000000..d821b84 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiCommandBlock.java @@ -0,0 +1,147 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.Unpooled; +import net.minecraft.client.resources.I18n; +import net.minecraft.command.server.CommandBlockLogic; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.client.C17PacketCustomPayload; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.lwjgl.input.Keyboard; + +@SideOnly(Side.CLIENT) +public class GuiCommandBlock extends GuiScreen +{ + private static final Logger field_146488_a = LogManager.getLogger(); + private GuiTextField commandTextField; + private GuiTextField field_146486_g; + private final CommandBlockLogic localCommandBlock; + private GuiButton doneBtn; + private GuiButton cancelBtn; + private static final String __OBFID = "CL_00000748"; + + public GuiCommandBlock(CommandBlockLogic p_i45032_1_) + { + this.localCommandBlock = p_i45032_1_; + } + + public void updateScreen() + { + this.commandTextField.updateCursorCounter(); + } + + public void initGui() + { + Keyboard.enableRepeatEvents(true); + this.buttonList.clear(); + this.buttonList.add(this.doneBtn = new GuiButton(0, this.width / 2 - 4 - 150, this.height / 4 + 120 + 12, 150, 20, I18n.format("gui.done", new Object[0]))); + this.buttonList.add(this.cancelBtn = new GuiButton(1, this.width / 2 + 4, this.height / 4 + 120 + 12, 150, 20, I18n.format("gui.cancel", new Object[0]))); + this.commandTextField = new GuiTextField(this.fontRendererObj, this.width / 2 - 150, 50, 300, 20); + this.commandTextField.setMaxStringLength(32767); + this.commandTextField.setFocused(true); + this.commandTextField.setText(this.localCommandBlock.func_145753_i()); + this.field_146486_g = new GuiTextField(this.fontRendererObj, this.width / 2 - 150, 135, 300, 20); + this.field_146486_g.setMaxStringLength(32767); + this.field_146486_g.setEnabled(false); + this.field_146486_g.setText(this.localCommandBlock.func_145753_i()); + + if (this.localCommandBlock.func_145749_h() != null) + { + this.field_146486_g.setText(this.localCommandBlock.func_145749_h().getUnformattedText()); + } + + this.doneBtn.enabled = this.commandTextField.getText().trim().length() > 0; + } + + public void onGuiClosed() + { + Keyboard.enableRepeatEvents(false); + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.enabled) + { + if (p_146284_1_.id == 1) + { + this.mc.displayGuiScreen((GuiScreen)null); + } + else if (p_146284_1_.id == 0) + { + PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer()); + + try + { + packetbuffer.writeByte(this.localCommandBlock.func_145751_f()); + this.localCommandBlock.func_145757_a(packetbuffer); + packetbuffer.writeStringToBuffer(this.commandTextField.getText()); + this.mc.getNetHandler().addToSendQueue(new C17PacketCustomPayload("MC|AdvCdm", packetbuffer)); + } + catch (Exception exception) + { + field_146488_a.error("Couldn\'t send command block info", exception); + } + finally + { + packetbuffer.release(); + } + + this.mc.displayGuiScreen((GuiScreen)null); + } + } + } + + protected void keyTyped(char par1, int par2) + { + this.commandTextField.textboxKeyTyped(par1, par2); + this.field_146486_g.textboxKeyTyped(par1, par2); + this.doneBtn.enabled = this.commandTextField.getText().trim().length() > 0; + + if (par2 != 28 && par2 != 156) + { + if (par2 == 1) + { + this.actionPerformed(this.cancelBtn); + } + } + else + { + this.actionPerformed(this.doneBtn); + } + } + + protected void mouseClicked(int par1, int par2, int par3) + { + super.mouseClicked(par1, par2, par3); + this.commandTextField.mouseClicked(par1, par2, par3); + this.field_146486_g.mouseClicked(par1, par2, par3); + } + + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + this.drawCenteredString(this.fontRendererObj, I18n.format("advMode.setCommand", new Object[0]), this.width / 2, 20, 16777215); + this.drawString(this.fontRendererObj, I18n.format("advMode.command", new Object[0]), this.width / 2 - 150, 37, 10526880); + this.commandTextField.drawTextBox(); + byte b0 = 75; + byte b1 = 0; + FontRenderer fontrenderer = this.fontRendererObj; + String s = I18n.format("advMode.nearestPlayer", new Object[0]); + int i1 = this.width / 2 - 150; + int l = b1 + 1; + this.drawString(fontrenderer, s, i1, b0 + b1 * this.fontRendererObj.FONT_HEIGHT, 10526880); + this.drawString(this.fontRendererObj, I18n.format("advMode.randomPlayer", new Object[0]), this.width / 2 - 150, b0 + l++ * this.fontRendererObj.FONT_HEIGHT, 10526880); + this.drawString(this.fontRendererObj, I18n.format("advMode.allPlayers", new Object[0]), this.width / 2 - 150, b0 + l++ * this.fontRendererObj.FONT_HEIGHT, 10526880); + + if (this.field_146486_g.getText().length() > 0) + { + int k = b0 + l * this.fontRendererObj.FONT_HEIGHT + 20; + this.drawString(this.fontRendererObj, I18n.format("advMode.previousOutput", new Object[0]), this.width / 2 - 150, k, 10526880); + this.field_146486_g.drawTextBox(); + } + + super.drawScreen(par1, par2, par3); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiConfirmOpenLink.java b/src/main/java/net/minecraft/client/gui/GuiConfirmOpenLink.java new file mode 100644 index 0000000..243327b --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiConfirmOpenLink.java @@ -0,0 +1,62 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.resources.I18n; + +@SideOnly(Side.CLIENT) +public class GuiConfirmOpenLink extends GuiYesNo +{ + private String openLinkWarning; + private String copyLinkButtonText; + private String field_146361_t; + private boolean field_146360_u = true; + private static final String __OBFID = "CL_00000683"; + + public GuiConfirmOpenLink(GuiScreen par1GuiScreen, String par2Str, int par3, boolean par4) + { + super(par1GuiScreen, I18n.format(par4 ? "chat.link.confirmTrusted" : "chat.link.confirm", new Object[0]), par2Str, par3); + this.confirmButtonText = I18n.format(par4 ? "chat.link.open" : "gui.yes", new Object[0]); + this.cancelButtonText = I18n.format(par4 ? "gui.cancel" : "gui.no", new Object[0]); + this.copyLinkButtonText = I18n.format("chat.copy", new Object[0]); + this.openLinkWarning = I18n.format("chat.link.warning", new Object[0]); + this.field_146361_t = par2Str; + } + + public void initGui() + { + this.buttonList.add(new GuiButton(0, this.width / 3 - 83 + 0, this.height / 6 + 96, 100, 20, this.confirmButtonText)); + this.buttonList.add(new GuiButton(2, this.width / 3 - 83 + 105, this.height / 6 + 96, 100, 20, this.copyLinkButtonText)); + this.buttonList.add(new GuiButton(1, this.width / 3 - 83 + 210, this.height / 6 + 96, 100, 20, this.cancelButtonText)); + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.id == 2) + { + this.copyLinkToClipboard(); + } + + this.parentScreen.confirmClicked(p_146284_1_.id == 0, this.field_146357_i); + } + + public void copyLinkToClipboard() + { + setClipboardString(this.field_146361_t); + } + + public void drawScreen(int par1, int par2, float par3) + { + super.drawScreen(par1, par2, par3); + + if (this.field_146360_u) + { + this.drawCenteredString(this.fontRendererObj, this.openLinkWarning, this.width / 2, 110, 16764108); + } + } + + public void func_146358_g() + { + this.field_146360_u = false; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiControls.java b/src/main/java/net/minecraft/client/gui/GuiControls.java new file mode 100644 index 0000000..a9762d8 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiControls.java @@ -0,0 +1,147 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.resources.I18n; +import net.minecraft.client.settings.GameSettings; +import net.minecraft.client.settings.KeyBinding; + +@SideOnly(Side.CLIENT) +public class GuiControls extends GuiScreen +{ + private static final GameSettings.Options[] field_146492_g = new GameSettings.Options[] {GameSettings.Options.INVERT_MOUSE, GameSettings.Options.SENSITIVITY, GameSettings.Options.TOUCHSCREEN}; + private GuiScreen parentScreen; + protected String field_146495_a = "Controls"; + private GameSettings options; + public KeyBinding buttonId = null; + private GuiKeyBindingList keyBindingList; + private GuiButton field_146493_s; + private static final String __OBFID = "CL_00000736"; + + public GuiControls(GuiScreen par1GuiScreen, GameSettings par2GameSettings) + { + this.parentScreen = par1GuiScreen; + this.options = par2GameSettings; + } + + public void initGui() + { + this.keyBindingList = new GuiKeyBindingList(this, this.mc); + this.buttonList.add(new GuiButton(200, this.width / 2 - 155, this.height - 29, 150, 20, I18n.format("gui.done", new Object[0]))); + this.buttonList.add(this.field_146493_s = new GuiButton(201, this.width / 2 - 155 + 160, this.height - 29, 150, 20, I18n.format("controls.resetAll", new Object[0]))); + this.field_146495_a = I18n.format("controls.title", new Object[0]); + int i = 0; + GameSettings.Options[] aoptions = field_146492_g; + int j = aoptions.length; + + for (int k = 0; k < j; ++k) + { + GameSettings.Options options = aoptions[k]; + + if (options.getEnumFloat()) + { + this.buttonList.add(new GuiOptionSlider(options.returnEnumOrdinal(), this.width / 2 - 155 + i % 2 * 160, 18 + 24 * (i >> 1), options)); + } + else + { + this.buttonList.add(new GuiOptionButton(options.returnEnumOrdinal(), this.width / 2 - 155 + i % 2 * 160, 18 + 24 * (i >> 1), options, this.options.getKeyBinding(options))); + } + + ++i; + } + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.id == 200) + { + this.mc.displayGuiScreen(this.parentScreen); + } + else if (p_146284_1_.id == 201) + { + KeyBinding[] akeybinding = this.mc.gameSettings.keyBindings; + int i = akeybinding.length; + + for (int j = 0; j < i; ++j) + { + KeyBinding keybinding = akeybinding[j]; + keybinding.setKeyCode(keybinding.getKeyCodeDefault()); + } + + KeyBinding.resetKeyBindingArrayAndHash(); + } + else if (p_146284_1_.id < 100 && p_146284_1_ instanceof GuiOptionButton) + { + this.options.setOptionValue(((GuiOptionButton)p_146284_1_).returnEnumOptions(), 1); + p_146284_1_.displayString = this.options.getKeyBinding(GameSettings.Options.getEnumOptions(p_146284_1_.id)); + } + } + + protected void mouseClicked(int par1, int par2, int par3) + { + if (this.buttonId != null) + { + this.options.setOptionKeyBinding(this.buttonId, -100 + par3); + this.buttonId = null; + KeyBinding.resetKeyBindingArrayAndHash(); + } + else if (par3 != 0 || !this.keyBindingList.func_148179_a(par1, par2, par3)) + { + super.mouseClicked(par1, par2, par3); + } + } + + protected void mouseMovedOrUp(int p_146286_1_, int p_146286_2_, int p_146286_3_) + { + if (p_146286_3_ != 0 || !this.keyBindingList.func_148181_b(p_146286_1_, p_146286_2_, p_146286_3_)) + { + super.mouseMovedOrUp(p_146286_1_, p_146286_2_, p_146286_3_); + } + } + + protected void keyTyped(char par1, int par2) + { + if (this.buttonId != null) + { + if (par2 == 1) + { + this.options.setOptionKeyBinding(this.buttonId, 0); + } + else + { + this.options.setOptionKeyBinding(this.buttonId, par2); + } + + this.buttonId = null; + KeyBinding.resetKeyBindingArrayAndHash(); + } + else + { + super.keyTyped(par1, par2); + } + } + + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + this.keyBindingList.drawScreen(par1, par2, par3); + this.drawCenteredString(this.fontRendererObj, this.field_146495_a, this.width / 2, 8, 16777215); + boolean flag = true; + KeyBinding[] akeybinding = this.options.keyBindings; + int k = akeybinding.length; + + for (int l = 0; l < k; ++l) + { + KeyBinding keybinding = akeybinding[l]; + + if (keybinding.getKeyCode() != keybinding.getKeyCodeDefault()) + { + flag = false; + break; + } + } + + this.field_146493_s.enabled = !flag; + super.drawScreen(par1, par2, par3); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiCreateFlatWorld.java b/src/main/java/net/minecraft/client/gui/GuiCreateFlatWorld.java new file mode 100644 index 0000000..f2ba840 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiCreateFlatWorld.java @@ -0,0 +1,215 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.resources.I18n; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.gen.FlatGeneratorInfo; +import net.minecraft.world.gen.FlatLayerInfo; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +@SideOnly(Side.CLIENT) +public class GuiCreateFlatWorld extends GuiScreen +{ + private static RenderItem field_146392_a = new RenderItem(); + private final GuiCreateWorld createWorldGui; + private FlatGeneratorInfo theFlatGeneratorInfo = FlatGeneratorInfo.getDefaultFlatGenerator(); + private String field_146393_h; + private String field_146394_i; + private String field_146391_r; + private GuiCreateFlatWorld.Details createFlatWorldListSlotGui; + private GuiButton field_146389_t; + private GuiButton field_146388_u; + private GuiButton field_146386_v; + private static final String __OBFID = "CL_00000687"; + + public GuiCreateFlatWorld(GuiCreateWorld par1GuiCreateWorld, String par2Str) + { + this.createWorldGui = par1GuiCreateWorld; + this.func_146383_a(par2Str); + } + + public String func_146384_e() + { + return this.theFlatGeneratorInfo.toString(); + } + + public void func_146383_a(String p_146383_1_) + { + this.theFlatGeneratorInfo = FlatGeneratorInfo.createFlatGeneratorFromString(p_146383_1_); + } + + public void initGui() + { + this.buttonList.clear(); + this.field_146393_h = I18n.format("createWorld.customize.flat.title", new Object[0]); + this.field_146394_i = I18n.format("createWorld.customize.flat.tile", new Object[0]); + this.field_146391_r = I18n.format("createWorld.customize.flat.height", new Object[0]); + this.createFlatWorldListSlotGui = new GuiCreateFlatWorld.Details(); + this.buttonList.add(this.field_146389_t = new GuiButton(2, this.width / 2 - 154, this.height - 52, 100, 20, I18n.format("createWorld.customize.flat.addLayer", new Object[0]) + " (NYI)")); + this.buttonList.add(this.field_146388_u = new GuiButton(3, this.width / 2 - 50, this.height - 52, 100, 20, I18n.format("createWorld.customize.flat.editLayer", new Object[0]) + " (NYI)")); + this.buttonList.add(this.field_146386_v = new GuiButton(4, this.width / 2 - 155, this.height - 52, 150, 20, I18n.format("createWorld.customize.flat.removeLayer", new Object[0]))); + this.buttonList.add(new GuiButton(0, this.width / 2 - 155, this.height - 28, 150, 20, I18n.format("gui.done", new Object[0]))); + this.buttonList.add(new GuiButton(5, this.width / 2 + 5, this.height - 52, 150, 20, I18n.format("createWorld.customize.presets", new Object[0]))); + this.buttonList.add(new GuiButton(1, this.width / 2 + 5, this.height - 28, 150, 20, I18n.format("gui.cancel", new Object[0]))); + this.field_146389_t.visible = this.field_146388_u.visible = false; + this.theFlatGeneratorInfo.func_82645_d(); + this.func_146375_g(); + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + int i = this.theFlatGeneratorInfo.getFlatLayers().size() - this.createFlatWorldListSlotGui.field_148228_k - 1; + + if (p_146284_1_.id == 1) + { + this.mc.displayGuiScreen(this.createWorldGui); + } + else if (p_146284_1_.id == 0) + { + this.createWorldGui.field_146334_a = this.func_146384_e(); + this.mc.displayGuiScreen(this.createWorldGui); + } + else if (p_146284_1_.id == 5) + { + this.mc.displayGuiScreen(new GuiFlatPresets(this)); + } + else if (p_146284_1_.id == 4 && this.func_146382_i()) + { + this.theFlatGeneratorInfo.getFlatLayers().remove(i); + this.createFlatWorldListSlotGui.field_148228_k = Math.min(this.createFlatWorldListSlotGui.field_148228_k, this.theFlatGeneratorInfo.getFlatLayers().size() - 1); + } + + this.theFlatGeneratorInfo.func_82645_d(); + this.func_146375_g(); + } + + public void func_146375_g() + { + boolean flag = this.func_146382_i(); + this.field_146386_v.enabled = flag; + this.field_146388_u.enabled = flag; + this.field_146388_u.enabled = false; + this.field_146389_t.enabled = false; + } + + private boolean func_146382_i() + { + return this.createFlatWorldListSlotGui.field_148228_k > -1 && this.createFlatWorldListSlotGui.field_148228_k < this.theFlatGeneratorInfo.getFlatLayers().size(); + } + + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + this.createFlatWorldListSlotGui.drawScreen(par1, par2, par3); + this.drawCenteredString(this.fontRendererObj, this.field_146393_h, this.width / 2, 8, 16777215); + int k = this.width / 2 - 92 - 16; + this.drawString(this.fontRendererObj, this.field_146394_i, k, 32, 16777215); + this.drawString(this.fontRendererObj, this.field_146391_r, k + 2 + 213 - this.fontRendererObj.getStringWidth(this.field_146391_r), 32, 16777215); + super.drawScreen(par1, par2, par3); + } + + @SideOnly(Side.CLIENT) + class Details extends GuiSlot + { + public int field_148228_k = -1; + private static final String __OBFID = "CL_00000688"; + + public Details() + { + super(GuiCreateFlatWorld.this.mc, GuiCreateFlatWorld.this.width, GuiCreateFlatWorld.this.height, 43, GuiCreateFlatWorld.this.height - 60, 24); + } + + private void func_148225_a(int p_148225_1_, int p_148225_2_, ItemStack p_148225_3_) + { + this.func_148226_e(p_148225_1_ + 1, p_148225_2_ + 1); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + + if (p_148225_3_ != null) + { + RenderHelper.enableGUIStandardItemLighting(); + GuiCreateFlatWorld.field_146392_a.renderItemIntoGUI(GuiCreateFlatWorld.this.fontRendererObj, GuiCreateFlatWorld.this.mc.getTextureManager(), p_148225_3_, p_148225_1_ + 2, p_148225_2_ + 2); + RenderHelper.disableStandardItemLighting(); + } + + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + } + + private void func_148226_e(int p_148226_1_, int p_148226_2_) + { + this.func_148224_c(p_148226_1_, p_148226_2_, 0, 0); + } + + private void func_148224_c(int p_148224_1_, int p_148224_2_, int p_148224_3_, int p_148224_4_) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GuiCreateFlatWorld.this.mc.getTextureManager().bindTexture(Gui.statIcons); + float f = 0.0078125F; + float f1 = 0.0078125F; + boolean flag = true; + boolean flag1 = true; + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV((double)(p_148224_1_ + 0), (double)(p_148224_2_ + 18), (double)GuiCreateFlatWorld.this.zLevel, (double)((float)(p_148224_3_ + 0) * 0.0078125F), (double)((float)(p_148224_4_ + 18) * 0.0078125F)); + tessellator.addVertexWithUV((double)(p_148224_1_ + 18), (double)(p_148224_2_ + 18), (double)GuiCreateFlatWorld.this.zLevel, (double)((float)(p_148224_3_ + 18) * 0.0078125F), (double)((float)(p_148224_4_ + 18) * 0.0078125F)); + tessellator.addVertexWithUV((double)(p_148224_1_ + 18), (double)(p_148224_2_ + 0), (double)GuiCreateFlatWorld.this.zLevel, (double)((float)(p_148224_3_ + 18) * 0.0078125F), (double)((float)(p_148224_4_ + 0) * 0.0078125F)); + tessellator.addVertexWithUV((double)(p_148224_1_ + 0), (double)(p_148224_2_ + 0), (double)GuiCreateFlatWorld.this.zLevel, (double)((float)(p_148224_3_ + 0) * 0.0078125F), (double)((float)(p_148224_4_ + 0) * 0.0078125F)); + tessellator.draw(); + } + + protected int getSize() + { + return GuiCreateFlatWorld.this.theFlatGeneratorInfo.getFlatLayers().size(); + } + + protected void elementClicked(int p_148144_1_, boolean p_148144_2_, int p_148144_3_, int p_148144_4_) + { + this.field_148228_k = p_148144_1_; + GuiCreateFlatWorld.this.func_146375_g(); + } + + protected boolean isSelected(int p_148131_1_) + { + return p_148131_1_ == this.field_148228_k; + } + + protected void drawBackground() {} + + protected void drawSlot(int p_148126_1_, int p_148126_2_, int p_148126_3_, int p_148126_4_, Tessellator p_148126_5_, int p_148126_6_, int p_148126_7_) + { + FlatLayerInfo flatlayerinfo = (FlatLayerInfo)GuiCreateFlatWorld.this.theFlatGeneratorInfo.getFlatLayers().get(GuiCreateFlatWorld.this.theFlatGeneratorInfo.getFlatLayers().size() - p_148126_1_ - 1); + Item item = Item.getItemFromBlock(flatlayerinfo.func_151536_b()); + ItemStack itemstack = flatlayerinfo.func_151536_b() == Blocks.air ? null : new ItemStack(item, 1, flatlayerinfo.getFillBlockMeta()); + String s = itemstack != null && item != null ? item.getItemStackDisplayName(itemstack) : "Air"; + this.func_148225_a(p_148126_2_, p_148126_3_, itemstack); + GuiCreateFlatWorld.this.fontRendererObj.drawString(s, p_148126_2_ + 18 + 5, p_148126_3_ + 3, 16777215); + String s1; + + if (p_148126_1_ == 0) + { + s1 = I18n.format("createWorld.customize.flat.layer.top", new Object[] {Integer.valueOf(flatlayerinfo.getLayerCount())}); + } + else if (p_148126_1_ == GuiCreateFlatWorld.this.theFlatGeneratorInfo.getFlatLayers().size() - 1) + { + s1 = I18n.format("createWorld.customize.flat.layer.bottom", new Object[] {Integer.valueOf(flatlayerinfo.getLayerCount())}); + } + else + { + s1 = I18n.format("createWorld.customize.flat.layer", new Object[] {Integer.valueOf(flatlayerinfo.getLayerCount())}); + } + + GuiCreateFlatWorld.this.fontRendererObj.drawString(s1, p_148126_2_ + 2 + 213 - GuiCreateFlatWorld.this.fontRendererObj.getStringWidth(s1), p_148126_3_ + 3, 16777215); + } + + protected int getScrollBarX() + { + return this.width - 70; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiCreateWorld.java b/src/main/java/net/minecraft/client/gui/GuiCreateWorld.java new file mode 100644 index 0000000..2a3ac03 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiCreateWorld.java @@ -0,0 +1,441 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.client.resources.I18n; +import net.minecraft.util.ChatAllowedCharacters; +import net.minecraft.util.MathHelper; +import net.minecraft.world.WorldSettings; +import net.minecraft.world.WorldType; +import net.minecraft.world.storage.ISaveFormat; +import net.minecraft.world.storage.WorldInfo; +import org.lwjgl.input.Keyboard; + +@SideOnly(Side.CLIENT) +public class GuiCreateWorld extends GuiScreen +{ + private GuiScreen field_146332_f; + private GuiTextField field_146333_g; + private GuiTextField field_146335_h; + private String field_146336_i; + private String field_146342_r = "survival"; + private boolean field_146341_s = true; + private boolean field_146340_t; + private boolean field_146339_u; + private boolean field_146338_v; + private boolean field_146337_w; + private boolean field_146345_x; + private boolean field_146344_y; + private GuiButton field_146343_z; + private GuiButton field_146324_A; + private GuiButton field_146325_B; + private GuiButton field_146326_C; + private GuiButton field_146320_D; + private GuiButton field_146321_E; + private GuiButton field_146322_F; + private String field_146323_G; + private String field_146328_H; + private String field_146329_I; + private String field_146330_J; + private int field_146331_K; + public String field_146334_a = ""; + private static final String[] field_146327_L = new String[] {"CON", "COM", "PRN", "AUX", "CLOCK$", "NUL", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9", "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9"}; + private static final String __OBFID = "CL_00000689"; + + public GuiCreateWorld(GuiScreen par1GuiScreen) + { + this.field_146332_f = par1GuiScreen; + this.field_146329_I = ""; + this.field_146330_J = I18n.format("selectWorld.newWorld", new Object[0]); + } + + public void updateScreen() + { + this.field_146333_g.updateCursorCounter(); + this.field_146335_h.updateCursorCounter(); + } + + public void initGui() + { + Keyboard.enableRepeatEvents(true); + this.buttonList.clear(); + this.buttonList.add(new GuiButton(0, this.width / 2 - 155, this.height - 28, 150, 20, I18n.format("selectWorld.create", new Object[0]))); + this.buttonList.add(new GuiButton(1, this.width / 2 + 5, this.height - 28, 150, 20, I18n.format("gui.cancel", new Object[0]))); + this.buttonList.add(this.field_146343_z = new GuiButton(2, this.width / 2 - 75, 115, 150, 20, I18n.format("selectWorld.gameMode", new Object[0]))); + this.buttonList.add(this.field_146324_A = new GuiButton(3, this.width / 2 - 75, 187, 150, 20, I18n.format("selectWorld.moreWorldOptions", new Object[0]))); + this.buttonList.add(this.field_146325_B = new GuiButton(4, this.width / 2 - 155, 100, 150, 20, I18n.format("selectWorld.mapFeatures", new Object[0]))); + this.field_146325_B.visible = false; + this.buttonList.add(this.field_146326_C = new GuiButton(7, this.width / 2 + 5, 151, 150, 20, I18n.format("selectWorld.bonusItems", new Object[0]))); + this.field_146326_C.visible = false; + this.buttonList.add(this.field_146320_D = new GuiButton(5, this.width / 2 + 5, 100, 150, 20, I18n.format("selectWorld.mapType", new Object[0]))); + this.field_146320_D.visible = false; + this.buttonList.add(this.field_146321_E = new GuiButton(6, this.width / 2 - 155, 151, 150, 20, I18n.format("selectWorld.allowCommands", new Object[0]))); + this.field_146321_E.visible = false; + this.buttonList.add(this.field_146322_F = new GuiButton(8, this.width / 2 + 5, 120, 150, 20, I18n.format("selectWorld.customizeType", new Object[0]))); + this.field_146322_F.visible = false; + this.field_146333_g = new GuiTextField(this.fontRendererObj, this.width / 2 - 100, 60, 200, 20); + this.field_146333_g.setFocused(true); + this.field_146333_g.setText(this.field_146330_J); + this.field_146335_h = new GuiTextField(this.fontRendererObj, this.width / 2 - 100, 60, 200, 20); + this.field_146335_h.setText(this.field_146329_I); + this.func_146316_a(this.field_146344_y); + this.func_146314_g(); + this.func_146319_h(); + } + + private void func_146314_g() + { + this.field_146336_i = this.field_146333_g.getText().trim(); + char[] achar = ChatAllowedCharacters.allowedCharacters; + int i = achar.length; + + for (int j = 0; j < i; ++j) + { + char c0 = achar[j]; + this.field_146336_i = this.field_146336_i.replace(c0, '_'); + } + + if (MathHelper.stringNullOrLengthZero(this.field_146336_i)) + { + this.field_146336_i = "World"; + } + + this.field_146336_i = func_146317_a(this.mc.getSaveLoader(), this.field_146336_i); + } + + private void func_146319_h() + { + this.field_146343_z.displayString = I18n.format("selectWorld.gameMode", new Object[0]) + " " + I18n.format("selectWorld.gameMode." + this.field_146342_r, new Object[0]); + this.field_146323_G = I18n.format("selectWorld.gameMode." + this.field_146342_r + ".line1", new Object[0]); + this.field_146328_H = I18n.format("selectWorld.gameMode." + this.field_146342_r + ".line2", new Object[0]); + this.field_146325_B.displayString = I18n.format("selectWorld.mapFeatures", new Object[0]) + " "; + + if (this.field_146341_s) + { + this.field_146325_B.displayString = this.field_146325_B.displayString + I18n.format("options.on", new Object[0]); + } + else + { + this.field_146325_B.displayString = this.field_146325_B.displayString + I18n.format("options.off", new Object[0]); + } + + this.field_146326_C.displayString = I18n.format("selectWorld.bonusItems", new Object[0]) + " "; + + if (this.field_146338_v && !this.field_146337_w) + { + this.field_146326_C.displayString = this.field_146326_C.displayString + I18n.format("options.on", new Object[0]); + } + else + { + this.field_146326_C.displayString = this.field_146326_C.displayString + I18n.format("options.off", new Object[0]); + } + + this.field_146320_D.displayString = I18n.format("selectWorld.mapType", new Object[0]) + " " + I18n.format(WorldType.worldTypes[this.field_146331_K].getTranslateName(), new Object[0]); + this.field_146321_E.displayString = I18n.format("selectWorld.allowCommands", new Object[0]) + " "; + + if (this.field_146340_t && !this.field_146337_w) + { + this.field_146321_E.displayString = this.field_146321_E.displayString + I18n.format("options.on", new Object[0]); + } + else + { + this.field_146321_E.displayString = this.field_146321_E.displayString + I18n.format("options.off", new Object[0]); + } + } + + public static String func_146317_a(ISaveFormat p_146317_0_, String p_146317_1_) + { + p_146317_1_ = p_146317_1_.replaceAll("[\\./\"]", "_"); + String[] astring = field_146327_L; + int i = astring.length; + + for (int j = 0; j < i; ++j) + { + String s1 = astring[j]; + + if (p_146317_1_.equalsIgnoreCase(s1)) + { + p_146317_1_ = "_" + p_146317_1_ + "_"; + } + } + + while (p_146317_0_.getWorldInfo(p_146317_1_) != null) + { + p_146317_1_ = p_146317_1_ + "-"; + } + + return p_146317_1_; + } + + public void onGuiClosed() + { + Keyboard.enableRepeatEvents(false); + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.enabled) + { + if (p_146284_1_.id == 1) + { + this.mc.displayGuiScreen(this.field_146332_f); + } + else if (p_146284_1_.id == 0) + { + this.mc.displayGuiScreen((GuiScreen)null); + + if (this.field_146345_x) + { + return; + } + + this.field_146345_x = true; + long i = (new Random()).nextLong(); + String s = this.field_146335_h.getText(); + + if (!MathHelper.stringNullOrLengthZero(s)) + { + try + { + long j = Long.parseLong(s); + + if (j != 0L) + { + i = j; + } + } + catch (NumberFormatException numberformatexception) + { + i = (long)s.hashCode(); + } + } + + WorldType.worldTypes[this.field_146331_K].onGUICreateWorldPress(); + + WorldSettings.GameType gametype = WorldSettings.GameType.getByName(this.field_146342_r); + WorldSettings worldsettings = new WorldSettings(i, gametype, this.field_146341_s, this.field_146337_w, WorldType.worldTypes[this.field_146331_K]); + worldsettings.func_82750_a(this.field_146334_a); + + if (this.field_146338_v && !this.field_146337_w) + { + worldsettings.enableBonusChest(); + } + + if (this.field_146340_t && !this.field_146337_w) + { + worldsettings.enableCommands(); + } + + this.mc.launchIntegratedServer(this.field_146336_i, this.field_146333_g.getText().trim(), worldsettings); + } + else if (p_146284_1_.id == 3) + { + this.func_146315_i(); + } + else if (p_146284_1_.id == 2) + { + if (this.field_146342_r.equals("survival")) + { + if (!this.field_146339_u) + { + this.field_146340_t = false; + } + + this.field_146337_w = false; + this.field_146342_r = "hardcore"; + this.field_146337_w = true; + this.field_146321_E.enabled = false; + this.field_146326_C.enabled = false; + this.func_146319_h(); + } + else if (this.field_146342_r.equals("hardcore")) + { + if (!this.field_146339_u) + { + this.field_146340_t = true; + } + + this.field_146337_w = false; + this.field_146342_r = "creative"; + this.func_146319_h(); + this.field_146337_w = false; + this.field_146321_E.enabled = true; + this.field_146326_C.enabled = true; + } + else + { + if (!this.field_146339_u) + { + this.field_146340_t = false; + } + + this.field_146342_r = "survival"; + this.func_146319_h(); + this.field_146321_E.enabled = true; + this.field_146326_C.enabled = true; + this.field_146337_w = false; + } + + this.func_146319_h(); + } + else if (p_146284_1_.id == 4) + { + this.field_146341_s = !this.field_146341_s; + this.func_146319_h(); + } + else if (p_146284_1_.id == 7) + { + this.field_146338_v = !this.field_146338_v; + this.func_146319_h(); + } + else if (p_146284_1_.id == 5) + { + ++this.field_146331_K; + + if (this.field_146331_K >= WorldType.worldTypes.length) + { + this.field_146331_K = 0; + } + + while (WorldType.worldTypes[this.field_146331_K] == null || !WorldType.worldTypes[this.field_146331_K].getCanBeCreated()) + { + ++this.field_146331_K; + + if (this.field_146331_K >= WorldType.worldTypes.length) + { + this.field_146331_K = 0; + } + } + + this.field_146334_a = ""; + this.func_146319_h(); + this.func_146316_a(this.field_146344_y); + } + else if (p_146284_1_.id == 6) + { + this.field_146339_u = true; + this.field_146340_t = !this.field_146340_t; + this.func_146319_h(); + } + else if (p_146284_1_.id == 8) + { + WorldType.worldTypes[field_146331_K].onCustomizeButton(mc, this); + } + } + } + + private void func_146315_i() + { + this.func_146316_a(!this.field_146344_y); + } + + private void func_146316_a(boolean p_146316_1_) + { + this.field_146344_y = p_146316_1_; + this.field_146343_z.visible = !this.field_146344_y; + this.field_146325_B.visible = this.field_146344_y; + this.field_146326_C.visible = this.field_146344_y; + this.field_146320_D.visible = this.field_146344_y; + this.field_146321_E.visible = this.field_146344_y; + this.field_146322_F.visible = this.field_146344_y && WorldType.worldTypes[this.field_146331_K].isCustomizable(); + + if (this.field_146344_y) + { + this.field_146324_A.displayString = I18n.format("gui.done", new Object[0]); + } + else + { + this.field_146324_A.displayString = I18n.format("selectWorld.moreWorldOptions", new Object[0]); + } + } + + protected void keyTyped(char par1, int par2) + { + if (this.field_146333_g.isFocused() && !this.field_146344_y) + { + this.field_146333_g.textboxKeyTyped(par1, par2); + this.field_146330_J = this.field_146333_g.getText(); + } + else if (this.field_146335_h.isFocused() && this.field_146344_y) + { + this.field_146335_h.textboxKeyTyped(par1, par2); + this.field_146329_I = this.field_146335_h.getText(); + } + + if (par2 == 28 || par2 == 156) + { + this.actionPerformed((GuiButton)this.buttonList.get(0)); + } + + ((GuiButton)this.buttonList.get(0)).enabled = this.field_146333_g.getText().length() > 0; + this.func_146314_g(); + } + + protected void mouseClicked(int par1, int par2, int par3) + { + super.mouseClicked(par1, par2, par3); + + if (this.field_146344_y) + { + this.field_146335_h.mouseClicked(par1, par2, par3); + } + else + { + this.field_146333_g.mouseClicked(par1, par2, par3); + } + } + + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + this.drawCenteredString(this.fontRendererObj, I18n.format("selectWorld.create", new Object[0]), this.width / 2, 20, -1); + + if (this.field_146344_y) + { + this.drawString(this.fontRendererObj, I18n.format("selectWorld.enterSeed", new Object[0]), this.width / 2 - 100, 47, -6250336); + this.drawString(this.fontRendererObj, I18n.format("selectWorld.seedInfo", new Object[0]), this.width / 2 - 100, 85, -6250336); + this.drawString(this.fontRendererObj, I18n.format("selectWorld.mapFeatures.info", new Object[0]), this.width / 2 - 150, 122, -6250336); + this.drawString(this.fontRendererObj, I18n.format("selectWorld.allowCommands.info", new Object[0]), this.width / 2 - 150, 172, -6250336); + this.field_146335_h.drawTextBox(); + + if (WorldType.worldTypes[this.field_146331_K].showWorldInfoNotice()) + { + this.fontRendererObj.drawSplitString(I18n.format(WorldType.worldTypes[this.field_146331_K].func_151359_c(), new Object[0]), this.field_146320_D.xPosition + 2, this.field_146320_D.yPosition + 22, this.field_146320_D.getButtonWidth(), 10526880); + } + } + else + { + this.drawString(this.fontRendererObj, I18n.format("selectWorld.enterName", new Object[0]), this.width / 2 - 100, 47, -6250336); + this.drawString(this.fontRendererObj, I18n.format("selectWorld.resultFolder", new Object[0]) + " " + this.field_146336_i, this.width / 2 - 100, 85, -6250336); + this.field_146333_g.drawTextBox(); + this.drawString(this.fontRendererObj, this.field_146323_G, this.width / 2 - 100, 137, -6250336); + this.drawString(this.fontRendererObj, this.field_146328_H, this.width / 2 - 100, 149, -6250336); + } + + super.drawScreen(par1, par2, par3); + } + + public void func_146318_a(WorldInfo p_146318_1_) + { + this.field_146330_J = I18n.format("selectWorld.newWorld.copyOf", new Object[] {p_146318_1_.getWorldName()}); + this.field_146329_I = p_146318_1_.getSeed() + ""; + this.field_146331_K = p_146318_1_.getTerrainType().getWorldTypeID(); + this.field_146334_a = p_146318_1_.getGeneratorOptions(); + this.field_146341_s = p_146318_1_.isMapFeaturesEnabled(); + this.field_146340_t = p_146318_1_.areCommandsAllowed(); + + if (p_146318_1_.isHardcoreModeEnabled()) + { + this.field_146342_r = "hardcore"; + } + else if (p_146318_1_.getGameType().isSurvivalOrAdventure()) + { + this.field_146342_r = "survival"; + } + else if (p_146318_1_.getGameType().isCreative()) + { + this.field_146342_r = "creative"; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiDisconnected.java b/src/main/java/net/minecraft/client/gui/GuiDisconnected.java new file mode 100644 index 0000000..511ffa2 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiDisconnected.java @@ -0,0 +1,60 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Iterator; +import java.util.List; +import net.minecraft.client.resources.I18n; +import net.minecraft.util.IChatComponent; + +@SideOnly(Side.CLIENT) +public class GuiDisconnected extends GuiScreen +{ + private String field_146306_a; + private IChatComponent field_146304_f; + private List field_146305_g; + private final GuiScreen field_146307_h; + private static final String __OBFID = "CL_00000693"; + + public GuiDisconnected(GuiScreen p_i45020_1_, String p_i45020_2_, IChatComponent p_i45020_3_) + { + this.field_146307_h = p_i45020_1_; + this.field_146306_a = I18n.format(p_i45020_2_, new Object[0]); + this.field_146304_f = p_i45020_3_; + } + + protected void keyTyped(char par1, int par2) {} + + public void initGui() + { + this.buttonList.clear(); + this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 120 + 12, I18n.format("gui.toMenu", new Object[0]))); + this.field_146305_g = this.fontRendererObj.listFormattedStringToWidth(this.field_146304_f.getFormattedText(), this.width - 50); + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.id == 0) + { + this.mc.displayGuiScreen(this.field_146307_h); + } + } + + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + this.drawCenteredString(this.fontRendererObj, this.field_146306_a, this.width / 2, this.height / 2 - 50, 11184810); + int k = this.height / 2 - 30; + + if (this.field_146305_g != null) + { + for (Iterator iterator = this.field_146305_g.iterator(); iterator.hasNext(); k += this.fontRendererObj.FONT_HEIGHT) + { + String s = (String)iterator.next(); + this.drawCenteredString(this.fontRendererObj, s, this.width / 2, k, 16777215); + } + } + + super.drawScreen(par1, par2, par3); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiDownloadTerrain.java b/src/main/java/net/minecraft/client/gui/GuiDownloadTerrain.java new file mode 100644 index 0000000..0dc368e --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiDownloadTerrain.java @@ -0,0 +1,54 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.network.NetHandlerPlayClient; +import net.minecraft.client.resources.I18n; +import net.minecraft.network.play.client.C00PacketKeepAlive; + +@SideOnly(Side.CLIENT) +public class GuiDownloadTerrain extends GuiScreen +{ + private NetHandlerPlayClient field_146594_a; + private int field_146593_f; + private static final String __OBFID = "CL_00000708"; + + public GuiDownloadTerrain(NetHandlerPlayClient p_i45023_1_) + { + this.field_146594_a = p_i45023_1_; + } + + protected void keyTyped(char par1, int par2) {} + + public void initGui() + { + this.buttonList.clear(); + } + + public void updateScreen() + { + ++this.field_146593_f; + + if (this.field_146593_f % 20 == 0) + { + this.field_146594_a.addToSendQueue(new C00PacketKeepAlive()); + } + + if (this.field_146594_a != null) + { + this.field_146594_a.onNetworkTick(); + } + } + + public void drawScreen(int par1, int par2, float par3) + { + this.drawBackground(0); + this.drawCenteredString(this.fontRendererObj, I18n.format("multiplayer.downloadingTerrain", new Object[0]), this.width / 2, this.height / 2 - 50, 16777215); + super.drawScreen(par1, par2, par3); + } + + public boolean doesGuiPauseGame() + { + return false; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiEnchantment.java b/src/main/java/net/minecraft/client/gui/GuiEnchantment.java new file mode 100644 index 0000000..6970546 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiEnchantment.java @@ -0,0 +1,259 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.model.ModelBook; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ContainerEnchantment; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnchantmentNameParts; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; +import org.lwjgl.util.glu.Project; + +@SideOnly(Side.CLIENT) +public class GuiEnchantment extends GuiContainer +{ + private static final ResourceLocation field_147078_C = new ResourceLocation("textures/gui/container/enchanting_table.png"); + private static final ResourceLocation field_147070_D = new ResourceLocation("textures/entity/enchanting_table_book.png"); + private static final ModelBook field_147072_E = new ModelBook(); + private Random field_147074_F = new Random(); + private ContainerEnchantment field_147075_G; + public int field_147073_u; + public float field_147071_v; + public float field_147069_w; + public float field_147082_x; + public float field_147081_y; + public float field_147080_z; + public float field_147076_A; + ItemStack field_147077_B; + private String field_147079_H; + private static final String __OBFID = "CL_00000757"; + + public GuiEnchantment(InventoryPlayer par1InventoryPlayer, World par2World, int par3, int par4, int par5, String par6Str) + { + super(new ContainerEnchantment(par1InventoryPlayer, par2World, par3, par4, par5)); + this.field_147075_G = (ContainerEnchantment)this.inventorySlots; + this.field_147079_H = par6Str; + } + + protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) + { + this.fontRendererObj.drawString(this.field_147079_H == null ? I18n.format("container.enchant", new Object[0]) : this.field_147079_H, 12, 5, 4210752); + this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752); + } + + public void updateScreen() + { + super.updateScreen(); + this.func_147068_g(); + } + + protected void mouseClicked(int par1, int par2, int par3) + { + super.mouseClicked(par1, par2, par3); + int l = (this.width - this.xSize) / 2; + int i1 = (this.height - this.ySize) / 2; + + for (int j1 = 0; j1 < 3; ++j1) + { + int k1 = par1 - (l + 60); + int l1 = par2 - (i1 + 14 + 19 * j1); + + if (k1 >= 0 && l1 >= 0 && k1 < 108 && l1 < 19 && this.field_147075_G.enchantItem(this.mc.thePlayer, j1)) + { + this.mc.playerController.sendEnchantPacket(this.field_147075_G.windowId, j1); + } + } + } + + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(field_147078_C); + int k = (this.width - this.xSize) / 2; + int l = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + GL11.glPushMatrix(); + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glPushMatrix(); + GL11.glLoadIdentity(); + ScaledResolution scaledresolution = new ScaledResolution(this.mc.gameSettings, this.mc.displayWidth, this.mc.displayHeight); + GL11.glViewport((scaledresolution.getScaledWidth() - 320) / 2 * scaledresolution.getScaleFactor(), (scaledresolution.getScaledHeight() - 240) / 2 * scaledresolution.getScaleFactor(), 320 * scaledresolution.getScaleFactor(), 240 * scaledresolution.getScaleFactor()); + GL11.glTranslatef(-0.34F, 0.23F, 0.0F); + Project.gluPerspective(90.0F, 1.3333334F, 9.0F, 80.0F); + float f1 = 1.0F; + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + RenderHelper.enableStandardItemLighting(); + GL11.glTranslatef(0.0F, 3.3F, -16.0F); + GL11.glScalef(f1, f1, f1); + float f2 = 5.0F; + GL11.glScalef(f2, f2, f2); + GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); + this.mc.getTextureManager().bindTexture(field_147070_D); + GL11.glRotatef(20.0F, 1.0F, 0.0F, 0.0F); + float f3 = this.field_147076_A + (this.field_147080_z - this.field_147076_A) * p_146976_1_; + GL11.glTranslatef((1.0F - f3) * 0.2F, (1.0F - f3) * 0.1F, (1.0F - f3) * 0.25F); + GL11.glRotatef(-(1.0F - f3) * 90.0F - 90.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F); + float f4 = this.field_147069_w + (this.field_147071_v - this.field_147069_w) * p_146976_1_ + 0.25F; + float f5 = this.field_147069_w + (this.field_147071_v - this.field_147069_w) * p_146976_1_ + 0.75F; + f4 = (f4 - (float)MathHelper.truncateDoubleToInt((double)f4)) * 1.6F - 0.3F; + f5 = (f5 - (float)MathHelper.truncateDoubleToInt((double)f5)) * 1.6F - 0.3F; + + if (f4 < 0.0F) + { + f4 = 0.0F; + } + + if (f5 < 0.0F) + { + f5 = 0.0F; + } + + if (f4 > 1.0F) + { + f4 = 1.0F; + } + + if (f5 > 1.0F) + { + f5 = 1.0F; + } + + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + field_147072_E.render((Entity)null, 0.0F, f4, f5, f3, 0.0F, 0.0625F); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + RenderHelper.disableStandardItemLighting(); + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glViewport(0, 0, this.mc.displayWidth, this.mc.displayHeight); + GL11.glPopMatrix(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glPopMatrix(); + RenderHelper.disableStandardItemLighting(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + EnchantmentNameParts.instance.reseedRandomGenerator(this.field_147075_G.nameSeed); + + for (int i1 = 0; i1 < 3; ++i1) + { + String s = EnchantmentNameParts.instance.generateNewRandomName(); + this.zLevel = 0.0F; + this.mc.getTextureManager().bindTexture(field_147078_C); + int j1 = this.field_147075_G.enchantLevels[i1]; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + + if (j1 == 0) + { + this.drawTexturedModalRect(k + 60, l + 14 + 19 * i1, 0, 185, 108, 19); + } + else + { + String s1 = "" + j1; + FontRenderer fontrenderer = this.mc.standardGalacticFontRenderer; + int k1 = 6839882; + + if (this.mc.thePlayer.experienceLevel < j1 && !this.mc.thePlayer.capabilities.isCreativeMode) + { + this.drawTexturedModalRect(k + 60, l + 14 + 19 * i1, 0, 185, 108, 19); + fontrenderer.drawSplitString(s, k + 62, l + 16 + 19 * i1, 104, (k1 & 16711422) >> 1); + fontrenderer = this.mc.fontRenderer; + k1 = 4226832; + fontrenderer.drawStringWithShadow(s1, k + 62 + 104 - fontrenderer.getStringWidth(s1), l + 16 + 19 * i1 + 7, k1); + } + else + { + int l1 = p_146976_2_ - (k + 60); + int i2 = p_146976_3_ - (l + 14 + 19 * i1); + + if (l1 >= 0 && i2 >= 0 && l1 < 108 && i2 < 19) + { + this.drawTexturedModalRect(k + 60, l + 14 + 19 * i1, 0, 204, 108, 19); + k1 = 16777088; + } + else + { + this.drawTexturedModalRect(k + 60, l + 14 + 19 * i1, 0, 166, 108, 19); + } + + fontrenderer.drawSplitString(s, k + 62, l + 16 + 19 * i1, 104, k1); + fontrenderer = this.mc.fontRenderer; + k1 = 8453920; + fontrenderer.drawStringWithShadow(s1, k + 62 + 104 - fontrenderer.getStringWidth(s1), l + 16 + 19 * i1 + 7, k1); + } + } + } + } + + public void func_147068_g() + { + ItemStack itemstack = this.inventorySlots.getSlot(0).getStack(); + + if (!ItemStack.areItemStacksEqual(itemstack, this.field_147077_B)) + { + this.field_147077_B = itemstack; + + do + { + this.field_147082_x += (float)(this.field_147074_F.nextInt(4) - this.field_147074_F.nextInt(4)); + } + while (this.field_147071_v <= this.field_147082_x + 1.0F && this.field_147071_v >= this.field_147082_x - 1.0F); + } + + ++this.field_147073_u; + this.field_147069_w = this.field_147071_v; + this.field_147076_A = this.field_147080_z; + boolean flag = false; + + for (int i = 0; i < 3; ++i) + { + if (this.field_147075_G.enchantLevels[i] != 0) + { + flag = true; + } + } + + if (flag) + { + this.field_147080_z += 0.2F; + } + else + { + this.field_147080_z -= 0.2F; + } + + if (this.field_147080_z < 0.0F) + { + this.field_147080_z = 0.0F; + } + + if (this.field_147080_z > 1.0F) + { + this.field_147080_z = 1.0F; + } + + float f1 = (this.field_147082_x - this.field_147071_v) * 0.4F; + float f = 0.2F; + + if (f1 < -f) + { + f1 = -f; + } + + if (f1 > f) + { + f1 = f; + } + + this.field_147081_y += (f1 - this.field_147081_y) * 0.9F; + this.field_147071_v += this.field_147081_y; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiErrorScreen.java b/src/main/java/net/minecraft/client/gui/GuiErrorScreen.java new file mode 100644 index 0000000..96e3901 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiErrorScreen.java @@ -0,0 +1,40 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.resources.I18n; + +@SideOnly(Side.CLIENT) +public class GuiErrorScreen extends GuiScreen +{ + private String field_146313_a; + private String field_146312_f; + private static final String __OBFID = "CL_00000696"; + + public GuiErrorScreen(String par1Str, String par2Str) + { + this.field_146313_a = par1Str; + this.field_146312_f = par2Str; + } + + public void initGui() + { + super.initGui(); + this.buttonList.add(new GuiButton(0, this.width / 2 - 100, 140, I18n.format("gui.cancel", new Object[0]))); + } + + public void drawScreen(int par1, int par2, float par3) + { + this.drawGradientRect(0, 0, this.width, this.height, -12574688, -11530224); + this.drawCenteredString(this.fontRendererObj, this.field_146313_a, this.width / 2, 90, 16777215); + this.drawCenteredString(this.fontRendererObj, this.field_146312_f, this.width / 2, 110, 16777215); + super.drawScreen(par1, par2, par3); + } + + protected void keyTyped(char par1, int par2) {} + + protected void actionPerformed(GuiButton p_146284_1_) + { + this.mc.displayGuiScreen((GuiScreen)null); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiFlatPresets.java b/src/main/java/net/minecraft/client/gui/GuiFlatPresets.java new file mode 100644 index 0000000..d1db72e --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiFlatPresets.java @@ -0,0 +1,248 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.resources.I18n; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.gen.FlatGeneratorInfo; +import net.minecraft.world.gen.FlatLayerInfo; +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +@SideOnly(Side.CLIENT) +public class GuiFlatPresets extends GuiScreen +{ + private static RenderItem field_146437_a = new RenderItem(); + private static final List field_146431_f = new ArrayList(); + private final GuiCreateFlatWorld field_146432_g; + private String field_146438_h; + private String field_146439_i; + private String field_146436_r; + private GuiFlatPresets.ListSlot field_146435_s; + private GuiButton field_146434_t; + private GuiTextField field_146433_u; + private static final String __OBFID = "CL_00000704"; + + public GuiFlatPresets(GuiCreateFlatWorld par1GuiCreateFlatWorld) + { + this.field_146432_g = par1GuiCreateFlatWorld; + } + + public void initGui() + { + this.buttonList.clear(); + Keyboard.enableRepeatEvents(true); + this.field_146438_h = I18n.format("createWorld.customize.presets.title", new Object[0]); + this.field_146439_i = I18n.format("createWorld.customize.presets.share", new Object[0]); + this.field_146436_r = I18n.format("createWorld.customize.presets.list", new Object[0]); + this.field_146433_u = new GuiTextField(this.fontRendererObj, 50, 40, this.width - 100, 20); + this.field_146435_s = new GuiFlatPresets.ListSlot(); + this.field_146433_u.setMaxStringLength(1230); + this.field_146433_u.setText(this.field_146432_g.func_146384_e()); + this.buttonList.add(this.field_146434_t = new GuiButton(0, this.width / 2 - 155, this.height - 28, 150, 20, I18n.format("createWorld.customize.presets.select", new Object[0]))); + this.buttonList.add(new GuiButton(1, this.width / 2 + 5, this.height - 28, 150, 20, I18n.format("gui.cancel", new Object[0]))); + this.func_146426_g(); + } + + public void onGuiClosed() + { + Keyboard.enableRepeatEvents(false); + } + + protected void mouseClicked(int par1, int par2, int par3) + { + this.field_146433_u.mouseClicked(par1, par2, par3); + super.mouseClicked(par1, par2, par3); + } + + protected void keyTyped(char par1, int par2) + { + if (!this.field_146433_u.textboxKeyTyped(par1, par2)) + { + super.keyTyped(par1, par2); + } + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.id == 0 && this.func_146430_p()) + { + this.field_146432_g.func_146383_a(this.field_146433_u.getText()); + this.mc.displayGuiScreen(this.field_146432_g); + } + else if (p_146284_1_.id == 1) + { + this.mc.displayGuiScreen(this.field_146432_g); + } + } + + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + this.field_146435_s.drawScreen(par1, par2, par3); + this.drawCenteredString(this.fontRendererObj, this.field_146438_h, this.width / 2, 8, 16777215); + this.drawString(this.fontRendererObj, this.field_146439_i, 50, 30, 10526880); + this.drawString(this.fontRendererObj, this.field_146436_r, 50, 70, 10526880); + this.field_146433_u.drawTextBox(); + super.drawScreen(par1, par2, par3); + } + + public void updateScreen() + { + this.field_146433_u.updateCursorCounter(); + super.updateScreen(); + } + + public void func_146426_g() + { + boolean flag = this.func_146430_p(); + this.field_146434_t.enabled = flag; + } + + private boolean func_146430_p() + { + return this.field_146435_s.field_148175_k > -1 && this.field_146435_s.field_148175_k < field_146431_f.size() || this.field_146433_u.getText().length() > 1; + } + + private static void func_146425_a(String p_146425_0_, Item p_146425_1_, BiomeGenBase p_146425_2_, FlatLayerInfo ... p_146425_3_) + { + func_146421_a(p_146425_0_, p_146425_1_, p_146425_2_, (List)null, p_146425_3_); + } + + private static void func_146421_a(String p_146421_0_, Item p_146421_1_, BiomeGenBase p_146421_2_, List p_146421_3_, FlatLayerInfo ... p_146421_4_) + { + FlatGeneratorInfo flatgeneratorinfo = new FlatGeneratorInfo(); + + for (int i = p_146421_4_.length - 1; i >= 0; --i) + { + flatgeneratorinfo.getFlatLayers().add(p_146421_4_[i]); + } + + flatgeneratorinfo.setBiome(p_146421_2_.biomeID); + flatgeneratorinfo.func_82645_d(); + + if (p_146421_3_ != null) + { + Iterator iterator = p_146421_3_.iterator(); + + while (iterator.hasNext()) + { + String s1 = (String)iterator.next(); + flatgeneratorinfo.getWorldFeatures().put(s1, new HashMap()); + } + } + + field_146431_f.add(new GuiFlatPresets.LayerItem(p_146421_1_, p_146421_0_, flatgeneratorinfo.toString())); + } + + static + { + func_146421_a("Classic Flat", Item.getItemFromBlock(Blocks.grass), BiomeGenBase.plains, Arrays.asList(new String[] {"village"}), new FlatLayerInfo[] {new FlatLayerInfo(1, Blocks.grass), new FlatLayerInfo(2, Blocks.dirt), new FlatLayerInfo(1, Blocks.bedrock)}); + func_146421_a("Tunnelers\' Dream", Item.getItemFromBlock(Blocks.stone), BiomeGenBase.extremeHills, Arrays.asList(new String[] {"biome_1", "dungeon", "decoration", "stronghold", "mineshaft"}), new FlatLayerInfo[] {new FlatLayerInfo(1, Blocks.grass), new FlatLayerInfo(5, Blocks.dirt), new FlatLayerInfo(230, Blocks.stone), new FlatLayerInfo(1, Blocks.bedrock)}); + func_146421_a("Water World", Item.getItemFromBlock(Blocks.flowing_water), BiomeGenBase.plains, Arrays.asList(new String[] {"village", "biome_1"}), new FlatLayerInfo[] {new FlatLayerInfo(90, Blocks.water), new FlatLayerInfo(5, Blocks.sand), new FlatLayerInfo(5, Blocks.dirt), new FlatLayerInfo(5, Blocks.stone), new FlatLayerInfo(1, Blocks.bedrock)}); + func_146421_a("Overworld", Item.getItemFromBlock(Blocks.tallgrass), BiomeGenBase.plains, Arrays.asList(new String[] {"village", "biome_1", "decoration", "stronghold", "mineshaft", "dungeon", "lake", "lava_lake"}), new FlatLayerInfo[] {new FlatLayerInfo(1, Blocks.grass), new FlatLayerInfo(3, Blocks.dirt), new FlatLayerInfo(59, Blocks.stone), new FlatLayerInfo(1, Blocks.bedrock)}); + func_146421_a("Snowy Kingdom", Item.getItemFromBlock(Blocks.snow_layer), BiomeGenBase.icePlains, Arrays.asList(new String[] {"village", "biome_1"}), new FlatLayerInfo[] {new FlatLayerInfo(1, Blocks.snow_layer), new FlatLayerInfo(1, Blocks.grass), new FlatLayerInfo(3, Blocks.dirt), new FlatLayerInfo(59, Blocks.stone), new FlatLayerInfo(1, Blocks.bedrock)}); + func_146421_a("Bottomless Pit", Items.feather, BiomeGenBase.plains, Arrays.asList(new String[] {"village", "biome_1"}), new FlatLayerInfo[] {new FlatLayerInfo(1, Blocks.grass), new FlatLayerInfo(3, Blocks.dirt), new FlatLayerInfo(2, Blocks.cobblestone)}); + func_146421_a("Desert", Item.getItemFromBlock(Blocks.sand), BiomeGenBase.desert, Arrays.asList(new String[] {"village", "biome_1", "decoration", "stronghold", "mineshaft", "dungeon"}), new FlatLayerInfo[] {new FlatLayerInfo(8, Blocks.sand), new FlatLayerInfo(52, Blocks.sandstone), new FlatLayerInfo(3, Blocks.stone), new FlatLayerInfo(1, Blocks.bedrock)}); + func_146425_a("Redstone Ready", Items.redstone, BiomeGenBase.desert, new FlatLayerInfo[] {new FlatLayerInfo(52, Blocks.sandstone), new FlatLayerInfo(3, Blocks.stone), new FlatLayerInfo(1, Blocks.bedrock)}); + } + + @SideOnly(Side.CLIENT) + static class LayerItem + { + public Item field_148234_a; + public String field_148232_b; + public String field_148233_c; + private static final String __OBFID = "CL_00000705"; + + public LayerItem(Item p_i45022_1_, String p_i45022_2_, String p_i45022_3_) + { + this.field_148234_a = p_i45022_1_; + this.field_148232_b = p_i45022_2_; + this.field_148233_c = p_i45022_3_; + } + } + + @SideOnly(Side.CLIENT) + class ListSlot extends GuiSlot + { + public int field_148175_k = -1; + private static final String __OBFID = "CL_00000706"; + + public ListSlot() + { + super(GuiFlatPresets.this.mc, GuiFlatPresets.this.width, GuiFlatPresets.this.height, 80, GuiFlatPresets.this.height - 37, 24); + } + + private void func_148172_a(int p_148172_1_, int p_148172_2_, Item p_148172_3_) + { + this.func_148173_e(p_148172_1_ + 1, p_148172_2_ + 1); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + RenderHelper.enableGUIStandardItemLighting(); + GuiFlatPresets.field_146437_a.renderItemIntoGUI(GuiFlatPresets.this.fontRendererObj, GuiFlatPresets.this.mc.getTextureManager(), new ItemStack(p_148172_3_, 1, 0), p_148172_1_ + 2, p_148172_2_ + 2); + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + } + + private void func_148173_e(int p_148173_1_, int p_148173_2_) + { + this.func_148171_c(p_148173_1_, p_148173_2_, 0, 0); + } + + private void func_148171_c(int p_148171_1_, int p_148171_2_, int p_148171_3_, int p_148171_4_) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GuiFlatPresets.this.mc.getTextureManager().bindTexture(Gui.statIcons); + float f = 0.0078125F; + float f1 = 0.0078125F; + boolean flag = true; + boolean flag1 = true; + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV((double)(p_148171_1_ + 0), (double)(p_148171_2_ + 18), (double)GuiFlatPresets.this.zLevel, (double)((float)(p_148171_3_ + 0) * 0.0078125F), (double)((float)(p_148171_4_ + 18) * 0.0078125F)); + tessellator.addVertexWithUV((double)(p_148171_1_ + 18), (double)(p_148171_2_ + 18), (double)GuiFlatPresets.this.zLevel, (double)((float)(p_148171_3_ + 18) * 0.0078125F), (double)((float)(p_148171_4_ + 18) * 0.0078125F)); + tessellator.addVertexWithUV((double)(p_148171_1_ + 18), (double)(p_148171_2_ + 0), (double)GuiFlatPresets.this.zLevel, (double)((float)(p_148171_3_ + 18) * 0.0078125F), (double)((float)(p_148171_4_ + 0) * 0.0078125F)); + tessellator.addVertexWithUV((double)(p_148171_1_ + 0), (double)(p_148171_2_ + 0), (double)GuiFlatPresets.this.zLevel, (double)((float)(p_148171_3_ + 0) * 0.0078125F), (double)((float)(p_148171_4_ + 0) * 0.0078125F)); + tessellator.draw(); + } + + protected int getSize() + { + return GuiFlatPresets.field_146431_f.size(); + } + + protected void elementClicked(int p_148144_1_, boolean p_148144_2_, int p_148144_3_, int p_148144_4_) + { + this.field_148175_k = p_148144_1_; + GuiFlatPresets.this.func_146426_g(); + GuiFlatPresets.this.field_146433_u.setText(((GuiFlatPresets.LayerItem)GuiFlatPresets.field_146431_f.get(GuiFlatPresets.this.field_146435_s.field_148175_k)).field_148233_c); + } + + protected boolean isSelected(int p_148131_1_) + { + return p_148131_1_ == this.field_148175_k; + } + + protected void drawBackground() {} + + protected void drawSlot(int p_148126_1_, int p_148126_2_, int p_148126_3_, int p_148126_4_, Tessellator p_148126_5_, int p_148126_6_, int p_148126_7_) + { + GuiFlatPresets.LayerItem layeritem = (GuiFlatPresets.LayerItem)GuiFlatPresets.field_146431_f.get(p_148126_1_); + this.func_148172_a(p_148126_2_, p_148126_3_, layeritem.field_148234_a); + GuiFlatPresets.this.fontRendererObj.drawString(layeritem.field_148232_b, p_148126_2_ + 18 + 5, p_148126_3_ + 6, 16777215); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiGameOver.java b/src/main/java/net/minecraft/client/gui/GuiGameOver.java new file mode 100644 index 0000000..19f527b --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiGameOver.java @@ -0,0 +1,122 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Iterator; +import net.minecraft.client.multiplayer.WorldClient; +import net.minecraft.client.resources.I18n; +import net.minecraft.util.EnumChatFormatting; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class GuiGameOver extends GuiScreen +{ + private int field_146347_a; + private boolean field_146346_f = false; + private static final String __OBFID = "CL_00000690"; + + public void initGui() + { + this.buttonList.clear(); + + if (this.mc.theWorld.getWorldInfo().isHardcoreModeEnabled()) + { + if (this.mc.isIntegratedServerRunning()) + { + this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 96, I18n.format("deathScreen.deleteWorld", new Object[0]))); + } + else + { + this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 96, I18n.format("deathScreen.leaveServer", new Object[0]))); + } + } + else + { + this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 72, I18n.format("deathScreen.respawn", new Object[0]))); + this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 96, I18n.format("deathScreen.titleScreen", new Object[0]))); + + if (this.mc.getSession() == null) + { + ((GuiButton)this.buttonList.get(1)).enabled = false; + } + } + + GuiButton guibutton; + + for (Iterator iterator = this.buttonList.iterator(); iterator.hasNext(); guibutton.enabled = false) + { + guibutton = (GuiButton)iterator.next(); + } + } + + protected void keyTyped(char par1, int par2) {} + + protected void actionPerformed(GuiButton p_146284_1_) + { + switch (p_146284_1_.id) + { + case 0: + this.mc.thePlayer.respawnPlayer(); + this.mc.displayGuiScreen((GuiScreen)null); + break; + case 1: + GuiYesNo guiyesno = new GuiYesNo(this, I18n.format("deathScreen.quit.confirm", new Object[0]), "", I18n.format("deathScreen.titleScreen", new Object[0]), I18n.format("deathScreen.respawn", new Object[0]), 0); + this.mc.displayGuiScreen(guiyesno); + guiyesno.func_146350_a(20); + } + } + + public void confirmClicked(boolean par1, int par2) + { + if (par1) + { + this.mc.theWorld.sendQuittingDisconnectingPacket(); + this.mc.loadWorld((WorldClient)null); + this.mc.displayGuiScreen(new GuiMainMenu()); + } + else + { + this.mc.thePlayer.respawnPlayer(); + this.mc.displayGuiScreen((GuiScreen)null); + } + } + + public void drawScreen(int par1, int par2, float par3) + { + this.drawGradientRect(0, 0, this.width, this.height, 1615855616, -1602211792); + GL11.glPushMatrix(); + GL11.glScalef(2.0F, 2.0F, 2.0F); + boolean flag = this.mc.theWorld.getWorldInfo().isHardcoreModeEnabled(); + String s = flag ? I18n.format("deathScreen.title.hardcore", new Object[0]) : I18n.format("deathScreen.title", new Object[0]); + this.drawCenteredString(this.fontRendererObj, s, this.width / 2 / 2, 30, 16777215); + GL11.glPopMatrix(); + + if (flag) + { + this.drawCenteredString(this.fontRendererObj, I18n.format("deathScreen.hardcoreInfo", new Object[0]), this.width / 2, 144, 16777215); + } + + this.drawCenteredString(this.fontRendererObj, I18n.format("deathScreen.score", new Object[0]) + ": " + EnumChatFormatting.YELLOW + this.mc.thePlayer.getScore(), this.width / 2, 100, 16777215); + super.drawScreen(par1, par2, par3); + } + + public boolean doesGuiPauseGame() + { + return false; + } + + public void updateScreen() + { + super.updateScreen(); + ++this.field_146347_a; + GuiButton guibutton; + + if (this.field_146347_a == 20) + { + for (Iterator iterator = this.buttonList.iterator(); iterator.hasNext(); guibutton.enabled = true) + { + guibutton = (GuiButton)iterator.next(); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiHopper.java b/src/main/java/net/minecraft/client/gui/GuiHopper.java new file mode 100644 index 0000000..8a3e0e2 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiHopper.java @@ -0,0 +1,44 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ContainerHopper; +import net.minecraft.inventory.IInventory; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class GuiHopper extends GuiContainer +{ + private static final ResourceLocation field_147085_u = new ResourceLocation("textures/gui/container/hopper.png"); + private IInventory field_147084_v; + private IInventory field_147083_w; + private static final String __OBFID = "CL_00000759"; + + public GuiHopper(InventoryPlayer par1InventoryPlayer, IInventory par2IInventory) + { + super(new ContainerHopper(par1InventoryPlayer, par2IInventory)); + this.field_147084_v = par1InventoryPlayer; + this.field_147083_w = par2IInventory; + this.allowUserInput = false; + this.ySize = 133; + } + + protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) + { + this.fontRendererObj.drawString(this.field_147083_w.hasCustomInventoryName() ? this.field_147083_w.getInventoryName() : I18n.format(this.field_147083_w.getInventoryName(), new Object[0]), 8, 6, 4210752); + this.fontRendererObj.drawString(this.field_147084_v.hasCustomInventoryName() ? this.field_147084_v.getInventoryName() : I18n.format(this.field_147084_v.getInventoryName(), new Object[0]), 8, this.ySize - 96 + 2, 4210752); + } + + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(field_147085_u); + int k = (this.width - this.xSize) / 2; + int l = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiIngame.java b/src/main/java/net/minecraft/client/gui/GuiIngame.java new file mode 100644 index 0000000..7320ef2 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiIngame.java @@ -0,0 +1,1013 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.awt.Color; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.client.Minecraft; +import net.minecraft.client.network.NetHandlerPlayClient; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.attributes.IAttributeInstance; +import net.minecraft.entity.boss.BossStatus; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.Potion; +import net.minecraft.scoreboard.Score; +import net.minecraft.scoreboard.ScoreObjective; +import net.minecraft.scoreboard.ScorePlayerTeam; +import net.minecraft.scoreboard.Scoreboard; +import net.minecraft.util.Direction; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.FoodStats; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StringUtils; +import net.minecraft.world.EnumSkyBlock; +import net.minecraft.world.chunk.Chunk; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +@SideOnly(Side.CLIENT) +public class GuiIngame extends Gui +{ + protected static final ResourceLocation vignetteTexPath = new ResourceLocation("textures/misc/vignette.png"); + protected static final ResourceLocation widgetsTexPath = new ResourceLocation("textures/gui/widgets.png"); + protected static final ResourceLocation pumpkinBlurTexPath = new ResourceLocation("textures/misc/pumpkinblur.png"); + protected static final RenderItem itemRenderer = new RenderItem(); + protected final Random rand = new Random(); + protected final Minecraft mc; + protected final GuiNewChat persistantChatGUI; + protected int updateCounter; + protected String recordPlaying = ""; + protected int recordPlayingUpFor; + protected boolean recordIsPlaying; + public float prevVignetteBrightness = 1.0F; + protected int remainingHighlightTicks; + protected ItemStack highlightingItemStack; + private static final String __OBFID = "CL_00000661"; + + public GuiIngame(Minecraft par1Minecraft) + { + this.mc = par1Minecraft; + this.persistantChatGUI = new GuiNewChat(par1Minecraft); + } + + public void renderGameOverlay(float par1, boolean par2, int par3, int par4) + { + ScaledResolution scaledresolution = new ScaledResolution(this.mc.gameSettings, this.mc.displayWidth, this.mc.displayHeight); + int k = scaledresolution.getScaledWidth(); + int l = scaledresolution.getScaledHeight(); + FontRenderer fontrenderer = this.mc.fontRenderer; + this.mc.entityRenderer.setupOverlayRendering(); + GL11.glEnable(GL11.GL_BLEND); + + if (Minecraft.isFancyGraphicsEnabled()) + { + this.renderVignette(this.mc.thePlayer.getBrightness(par1), k, l); + } + else + { + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + } + + ItemStack itemstack = this.mc.thePlayer.inventory.armorItemInSlot(3); + + if (this.mc.gameSettings.thirdPersonView == 0 && itemstack != null && itemstack.getItem() == Item.getItemFromBlock(Blocks.pumpkin)) + { + this.renderPumpkinBlur(k, l); + } + + if (!this.mc.thePlayer.isPotionActive(Potion.confusion)) + { + float f1 = this.mc.thePlayer.prevTimeInPortal + (this.mc.thePlayer.timeInPortal - this.mc.thePlayer.prevTimeInPortal) * par1; + + if (f1 > 0.0F) + { + this.func_130015_b(f1, k, l); + } + } + + int i1; + int j1; + int k1; + + if (!this.mc.playerController.enableEverythingIsScrewedUpMode()) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(widgetsTexPath); + InventoryPlayer inventoryplayer = this.mc.thePlayer.inventory; + this.zLevel = -90.0F; + this.drawTexturedModalRect(k / 2 - 91, l - 22, 0, 0, 182, 22); + this.drawTexturedModalRect(k / 2 - 91 - 1 + inventoryplayer.currentItem * 20, l - 22 - 1, 0, 22, 24, 22); + this.mc.getTextureManager().bindTexture(icons); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(775, 769, 1, 0); + this.drawTexturedModalRect(k / 2 - 7, l / 2 - 7, 0, 0, 16, 16); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + this.mc.mcProfiler.startSection("bossHealth"); + this.renderBossHealth(); + this.mc.mcProfiler.endSection(); + + if (this.mc.playerController.shouldDrawHUD()) + { + this.func_110327_a(k, l); + } + + this.mc.mcProfiler.startSection("actionBar"); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + RenderHelper.enableGUIStandardItemLighting(); + + for (i1 = 0; i1 < 9; ++i1) + { + j1 = k / 2 - 90 + i1 * 20 + 2; + k1 = l - 16 - 3; + this.renderInventorySlot(i1, j1, k1, par1); + } + + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + this.mc.mcProfiler.endSection(); + GL11.glDisable(GL11.GL_BLEND); + } + + int l4; + + if (this.mc.thePlayer.getSleepTimer() > 0) + { + this.mc.mcProfiler.startSection("sleep"); + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glDisable(GL11.GL_ALPHA_TEST); + l4 = this.mc.thePlayer.getSleepTimer(); + float f2 = (float)l4 / 100.0F; + + if (f2 > 1.0F) + { + f2 = 1.0F - (float)(l4 - 100) / 10.0F; + } + + j1 = (int)(220.0F * f2) << 24 | 1052704; + drawRect(0, 0, k, l, j1); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_DEPTH_TEST); + this.mc.mcProfiler.endSection(); + } + + l4 = 16777215; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + i1 = k / 2 - 91; + int l1; + int i2; + int j2; + int k2; + float f3; + short short1; + + if (this.mc.thePlayer.isRidingHorse()) + { + this.mc.mcProfiler.startSection("jumpBar"); + this.mc.getTextureManager().bindTexture(Gui.icons); + f3 = this.mc.thePlayer.getHorseJumpPower(); + short1 = 182; + l1 = (int)(f3 * (float)(short1 + 1)); + i2 = l - 32 + 3; + this.drawTexturedModalRect(i1, i2, 0, 84, short1, 5); + + if (l1 > 0) + { + this.drawTexturedModalRect(i1, i2, 0, 89, l1, 5); + } + + this.mc.mcProfiler.endSection(); + } + else if (this.mc.playerController.gameIsSurvivalOrAdventure()) + { + this.mc.mcProfiler.startSection("expBar"); + this.mc.getTextureManager().bindTexture(Gui.icons); + j1 = this.mc.thePlayer.xpBarCap(); + + if (j1 > 0) + { + short1 = 182; + l1 = (int)(this.mc.thePlayer.experience * (float)(short1 + 1)); + i2 = l - 32 + 3; + this.drawTexturedModalRect(i1, i2, 0, 64, short1, 5); + + if (l1 > 0) + { + this.drawTexturedModalRect(i1, i2, 0, 69, l1, 5); + } + } + + this.mc.mcProfiler.endSection(); + + if (this.mc.thePlayer.experienceLevel > 0) + { + this.mc.mcProfiler.startSection("expLevel"); + boolean flag2 = false; + l1 = flag2 ? 16777215 : 8453920; + String s3 = "" + this.mc.thePlayer.experienceLevel; + j2 = (k - fontrenderer.getStringWidth(s3)) / 2; + k2 = l - 31 - 4; + boolean flag1 = false; + fontrenderer.drawString(s3, j2 + 1, k2, 0); + fontrenderer.drawString(s3, j2 - 1, k2, 0); + fontrenderer.drawString(s3, j2, k2 + 1, 0); + fontrenderer.drawString(s3, j2, k2 - 1, 0); + fontrenderer.drawString(s3, j2, k2, l1); + this.mc.mcProfiler.endSection(); + } + } + + String s2; + + if (this.mc.gameSettings.heldItemTooltips) + { + this.mc.mcProfiler.startSection("toolHighlight"); + + if (this.remainingHighlightTicks > 0 && this.highlightingItemStack != null) + { + s2 = this.highlightingItemStack.getDisplayName(); + k1 = (k - fontrenderer.getStringWidth(s2)) / 2; + l1 = l - 59; + + if (!this.mc.playerController.shouldDrawHUD()) + { + l1 += 14; + } + + i2 = (int)((float)this.remainingHighlightTicks * 256.0F / 10.0F); + + if (i2 > 255) + { + i2 = 255; + } + + if (i2 > 0) + { + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + fontrenderer.drawStringWithShadow(s2, k1, l1, 16777215 + (i2 << 24)); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); + } + } + + this.mc.mcProfiler.endSection(); + } + + if (this.mc.isDemo()) + { + this.mc.mcProfiler.startSection("demo"); + s2 = ""; + + if (this.mc.theWorld.getTotalWorldTime() >= 120500L) + { + s2 = I18n.format("demo.demoExpired", new Object[0]); + } + else + { + s2 = I18n.format("demo.remainingTime", new Object[] {StringUtils.ticksToElapsedTime((int)(120500L - this.mc.theWorld.getTotalWorldTime()))}); + } + + k1 = fontrenderer.getStringWidth(s2); + fontrenderer.drawStringWithShadow(s2, k - k1 - 10, 5, 16777215); + this.mc.mcProfiler.endSection(); + } + + int i3; + int j3; + int k3; + + if (this.mc.gameSettings.showDebugInfo) + { + this.mc.mcProfiler.startSection("debug"); + GL11.glPushMatrix(); + fontrenderer.drawStringWithShadow("Minecraft 1.7.2 (" + this.mc.debug + ")", 2, 2, 16777215); + fontrenderer.drawStringWithShadow(this.mc.debugInfoRenders(), 2, 12, 16777215); + fontrenderer.drawStringWithShadow(this.mc.getEntityDebug(), 2, 22, 16777215); + fontrenderer.drawStringWithShadow(this.mc.debugInfoEntities(), 2, 32, 16777215); + fontrenderer.drawStringWithShadow(this.mc.getWorldProviderName(), 2, 42, 16777215); + long i5 = Runtime.getRuntime().maxMemory(); + long j5 = Runtime.getRuntime().totalMemory(); + long k5 = Runtime.getRuntime().freeMemory(); + long l5 = j5 - k5; + String s = "Used memory: " + l5 * 100L / i5 + "% (" + l5 / 1024L / 1024L + "MB) of " + i5 / 1024L / 1024L + "MB"; + i3 = 14737632; + this.drawString(fontrenderer, s, k - fontrenderer.getStringWidth(s) - 2, 2, 14737632); + s = "Allocated memory: " + j5 * 100L / i5 + "% (" + j5 / 1024L / 1024L + "MB)"; + this.drawString(fontrenderer, s, k - fontrenderer.getStringWidth(s) - 2, 12, 14737632); + int offset = 22; + for (String brd : FMLCommonHandler.instance().getBrandings(false)) + { + this.drawString(fontrenderer, brd, k - fontrenderer.getStringWidth(brd) - 2, offset+=10, 14737632); + } + j3 = MathHelper.floor_double(this.mc.thePlayer.posX); + k3 = MathHelper.floor_double(this.mc.thePlayer.posY); + int l3 = MathHelper.floor_double(this.mc.thePlayer.posZ); + this.drawString(fontrenderer, String.format("x: %.5f (%d) // c: %d (%d)", new Object[] {Double.valueOf(this.mc.thePlayer.posX), Integer.valueOf(j3), Integer.valueOf(j3 >> 4), Integer.valueOf(j3 & 15)}), 2, 64, 14737632); + this.drawString(fontrenderer, String.format("y: %.3f (feet pos, %.3f eyes pos)", new Object[] {Double.valueOf(this.mc.thePlayer.boundingBox.minY), Double.valueOf(this.mc.thePlayer.posY)}), 2, 72, 14737632); + this.drawString(fontrenderer, String.format("z: %.5f (%d) // c: %d (%d)", new Object[] {Double.valueOf(this.mc.thePlayer.posZ), Integer.valueOf(l3), Integer.valueOf(l3 >> 4), Integer.valueOf(l3 & 15)}), 2, 80, 14737632); + int i4 = MathHelper.floor_double((double)(this.mc.thePlayer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + this.drawString(fontrenderer, "f: " + i4 + " (" + Direction.directions[i4] + ") / " + MathHelper.wrapAngleTo180_float(this.mc.thePlayer.rotationYaw), 2, 88, 14737632); + + if (this.mc.theWorld != null && this.mc.theWorld.blockExists(j3, k3, l3)) + { + Chunk chunk = this.mc.theWorld.getChunkFromBlockCoords(j3, l3); + this.drawString(fontrenderer, "lc: " + (chunk.getTopFilledSegment() + 15) + " b: " + chunk.getBiomeGenForWorldCoords(j3 & 15, l3 & 15, this.mc.theWorld.getWorldChunkManager()).biomeName + " bl: " + chunk.getSavedLightValue(EnumSkyBlock.Block, j3 & 15, k3, l3 & 15) + " sl: " + chunk.getSavedLightValue(EnumSkyBlock.Sky, j3 & 15, k3, l3 & 15) + " rl: " + chunk.getBlockLightValue(j3 & 15, k3, l3 & 15, 0), 2, 96, 14737632); + } + + this.drawString(fontrenderer, String.format("ws: %.3f, fs: %.3f, g: %b, fl: %d", new Object[] {Float.valueOf(this.mc.thePlayer.capabilities.getWalkSpeed()), Float.valueOf(this.mc.thePlayer.capabilities.getFlySpeed()), Boolean.valueOf(this.mc.thePlayer.onGround), Integer.valueOf(this.mc.theWorld.getHeightValue(j3, l3))}), 2, 104, 14737632); + + if (this.mc.entityRenderer != null && this.mc.entityRenderer.isShaderActive()) + { + this.drawString(fontrenderer, String.format("shader: %s", new Object[] {this.mc.entityRenderer.getShaderGroup().getShaderGroupName()}), 2, 112, 14737632); + } + + GL11.glPopMatrix(); + this.mc.mcProfiler.endSection(); + } + + if (this.recordPlayingUpFor > 0) + { + this.mc.mcProfiler.startSection("overlayMessage"); + f3 = (float)this.recordPlayingUpFor - par1; + k1 = (int)(f3 * 255.0F / 20.0F); + + if (k1 > 255) + { + k1 = 255; + } + + if (k1 > 8) + { + GL11.glPushMatrix(); + GL11.glTranslatef((float)(k / 2), (float)(l - 68), 0.0F); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + l1 = 16777215; + + if (this.recordIsPlaying) + { + l1 = Color.HSBtoRGB(f3 / 50.0F, 0.7F, 0.6F) & 16777215; + } + + fontrenderer.drawString(this.recordPlaying, -fontrenderer.getStringWidth(this.recordPlaying) / 2, -4, l1 + (k1 << 24 & -16777216)); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); + } + + this.mc.mcProfiler.endSection(); + } + + ScoreObjective scoreobjective = this.mc.theWorld.getScoreboard().func_96539_a(1); + + if (scoreobjective != null) + { + this.func_96136_a(scoreobjective, l, k, fontrenderer); + } + + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glPushMatrix(); + GL11.glTranslatef(0.0F, (float)(l - 48), 0.0F); + this.mc.mcProfiler.startSection("chat"); + this.persistantChatGUI.drawChat(this.updateCounter); + this.mc.mcProfiler.endSection(); + GL11.glPopMatrix(); + scoreobjective = this.mc.theWorld.getScoreboard().func_96539_a(0); + + if (this.mc.gameSettings.keyBindPlayerList.getIsKeyPressed() && (!this.mc.isIntegratedServerRunning() || this.mc.thePlayer.sendQueue.playerInfoList.size() > 1 || scoreobjective != null)) + { + this.mc.mcProfiler.startSection("playerList"); + NetHandlerPlayClient nethandlerplayclient = this.mc.thePlayer.sendQueue; + List list = nethandlerplayclient.playerInfoList; + i2 = nethandlerplayclient.currentServerMaxPlayers; + j2 = i2; + + for (k2 = 1; j2 > 20; j2 = (i2 + k2 - 1) / k2) + { + ++k2; + } + + int i6 = 300 / k2; + + if (i6 > 150) + { + i6 = 150; + } + + int l2 = (k - k2 * i6) / 2; + byte b0 = 10; + drawRect(l2 - 1, b0 - 1, l2 + i6 * k2, b0 + 9 * j2, Integer.MIN_VALUE); + + for (i3 = 0; i3 < i2; ++i3) + { + j3 = l2 + i3 % k2 * i6; + k3 = b0 + i3 / k2 * 9; + drawRect(j3, k3, j3 + i6 - 1, k3 + 8, 553648127); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glEnable(GL11.GL_ALPHA_TEST); + + if (i3 < list.size()) + { + GuiPlayerInfo guiplayerinfo = (GuiPlayerInfo)list.get(i3); + ScorePlayerTeam scoreplayerteam = this.mc.theWorld.getScoreboard().getPlayersTeam(guiplayerinfo.name); + String s4 = ScorePlayerTeam.formatPlayerName(scoreplayerteam, guiplayerinfo.name); + fontrenderer.drawStringWithShadow(s4, j3, k3, 16777215); + + if (scoreobjective != null) + { + int j4 = j3 + fontrenderer.getStringWidth(s4) + 5; + int k4 = j3 + i6 - 12 - 5; + + if (k4 - j4 > 5) + { + Score score = scoreobjective.getScoreboard().func_96529_a(guiplayerinfo.name, scoreobjective); + String s1 = EnumChatFormatting.YELLOW + "" + score.getScorePoints(); + fontrenderer.drawStringWithShadow(s1, k4 - fontrenderer.getStringWidth(s1), k3, 16777215); + } + } + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(icons); + byte b1 = 0; + boolean flag3 = false; + byte b2; + + if (guiplayerinfo.responseTime < 0) + { + b2 = 5; + } + else if (guiplayerinfo.responseTime < 150) + { + b2 = 0; + } + else if (guiplayerinfo.responseTime < 300) + { + b2 = 1; + } + else if (guiplayerinfo.responseTime < 600) + { + b2 = 2; + } + else if (guiplayerinfo.responseTime < 1000) + { + b2 = 3; + } + else + { + b2 = 4; + } + + this.zLevel += 100.0F; + this.drawTexturedModalRect(j3 + i6 - 12, k3, 0 + b1 * 10, 176 + b2 * 8, 10, 8); + this.zLevel -= 100.0F; + } + } + } + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_ALPHA_TEST); + } + + protected void func_96136_a(ScoreObjective par1ScoreObjective, int par2, int par3, FontRenderer par4FontRenderer) + { + Scoreboard scoreboard = par1ScoreObjective.getScoreboard(); + Collection collection = scoreboard.func_96534_i(par1ScoreObjective); + + if (collection.size() <= 15) + { + int k = par4FontRenderer.getStringWidth(par1ScoreObjective.getDisplayName()); + String s; + + for (Iterator iterator = collection.iterator(); iterator.hasNext(); k = Math.max(k, par4FontRenderer.getStringWidth(s))) + { + Score score = (Score)iterator.next(); + ScorePlayerTeam scoreplayerteam = scoreboard.getPlayersTeam(score.getPlayerName()); + s = ScorePlayerTeam.formatPlayerName(scoreplayerteam, score.getPlayerName()) + ": " + EnumChatFormatting.RED + score.getScorePoints(); + } + + int k1 = collection.size() * par4FontRenderer.FONT_HEIGHT; + int l1 = par2 / 2 + k1 / 3; + byte b0 = 3; + int i2 = par3 - k - b0; + int l = 0; + Iterator iterator1 = collection.iterator(); + + while (iterator1.hasNext()) + { + Score score1 = (Score)iterator1.next(); + ++l; + ScorePlayerTeam scoreplayerteam1 = scoreboard.getPlayersTeam(score1.getPlayerName()); + String s1 = ScorePlayerTeam.formatPlayerName(scoreplayerteam1, score1.getPlayerName()); + String s2 = EnumChatFormatting.RED + "" + score1.getScorePoints(); + int i1 = l1 - l * par4FontRenderer.FONT_HEIGHT; + int j1 = par3 - b0 + 2; + drawRect(i2 - 2, i1, j1, i1 + par4FontRenderer.FONT_HEIGHT, 1342177280); + par4FontRenderer.drawString(s1, i2, i1, 553648127); + par4FontRenderer.drawString(s2, j1 - par4FontRenderer.getStringWidth(s2), i1, 553648127); + + if (l == collection.size()) + { + String s3 = par1ScoreObjective.getDisplayName(); + drawRect(i2 - 2, i1 - par4FontRenderer.FONT_HEIGHT - 1, j1, i1 - 1, 1610612736); + drawRect(i2 - 2, i1 - 1, j1, i1, 1342177280); + par4FontRenderer.drawString(s3, i2 + k / 2 - par4FontRenderer.getStringWidth(s3) / 2, i1 - par4FontRenderer.FONT_HEIGHT, 553648127); + } + } + } + } + + protected void func_110327_a(int par1, int par2) + { + boolean flag = this.mc.thePlayer.hurtResistantTime / 3 % 2 == 1; + + if (this.mc.thePlayer.hurtResistantTime < 10) + { + flag = false; + } + + int k = MathHelper.ceiling_float_int(this.mc.thePlayer.getHealth()); + int l = MathHelper.ceiling_float_int(this.mc.thePlayer.prevHealth); + this.rand.setSeed((long)(this.updateCounter * 312871)); + boolean flag1 = false; + FoodStats foodstats = this.mc.thePlayer.getFoodStats(); + int i1 = foodstats.getFoodLevel(); + int j1 = foodstats.getPrevFoodLevel(); + IAttributeInstance iattributeinstance = this.mc.thePlayer.getEntityAttribute(SharedMonsterAttributes.maxHealth); + int k1 = par1 / 2 - 91; + int l1 = par1 / 2 + 91; + int i2 = par2 - 39; + float f = (float)iattributeinstance.getAttributeValue(); + float f1 = this.mc.thePlayer.getAbsorptionAmount(); + int j2 = MathHelper.ceiling_float_int((f + f1) / 2.0F / 10.0F); + int k2 = Math.max(10 - (j2 - 2), 3); + int l2 = i2 - (j2 - 1) * k2 - 10; + float f2 = f1; + int i3 = this.mc.thePlayer.getTotalArmorValue(); + int j3 = -1; + + if (this.mc.thePlayer.isPotionActive(Potion.regeneration)) + { + j3 = this.updateCounter % MathHelper.ceiling_float_int(f + 5.0F); + } + + this.mc.mcProfiler.startSection("armor"); + int k3; + int l3; + + for (k3 = 0; k3 < 10; ++k3) + { + if (i3 > 0) + { + l3 = k1 + k3 * 8; + + if (k3 * 2 + 1 < i3) + { + this.drawTexturedModalRect(l3, l2, 34, 9, 9, 9); + } + + if (k3 * 2 + 1 == i3) + { + this.drawTexturedModalRect(l3, l2, 25, 9, 9, 9); + } + + if (k3 * 2 + 1 > i3) + { + this.drawTexturedModalRect(l3, l2, 16, 9, 9, 9); + } + } + } + + this.mc.mcProfiler.endStartSection("health"); + int i4; + int j4; + int k4; + + for (k3 = MathHelper.ceiling_float_int((f + f1) / 2.0F) - 1; k3 >= 0; --k3) + { + l3 = 16; + + if (this.mc.thePlayer.isPotionActive(Potion.poison)) + { + l3 += 36; + } + else if (this.mc.thePlayer.isPotionActive(Potion.wither)) + { + l3 += 72; + } + + byte b0 = 0; + + if (flag) + { + b0 = 1; + } + + i4 = MathHelper.ceiling_float_int((float)(k3 + 1) / 10.0F) - 1; + j4 = k1 + k3 % 10 * 8; + k4 = i2 - i4 * k2; + + if (k <= 4) + { + k4 += this.rand.nextInt(2); + } + + if (k3 == j3) + { + k4 -= 2; + } + + byte b1 = 0; + + if (this.mc.theWorld.getWorldInfo().isHardcoreModeEnabled()) + { + b1 = 5; + } + + this.drawTexturedModalRect(j4, k4, 16 + b0 * 9, 9 * b1, 9, 9); + + if (flag) + { + if (k3 * 2 + 1 < l) + { + this.drawTexturedModalRect(j4, k4, l3 + 54, 9 * b1, 9, 9); + } + + if (k3 * 2 + 1 == l) + { + this.drawTexturedModalRect(j4, k4, l3 + 63, 9 * b1, 9, 9); + } + } + + if (f2 > 0.0F) + { + if (f2 == f1 && f1 % 2.0F == 1.0F) + { + this.drawTexturedModalRect(j4, k4, l3 + 153, 9 * b1, 9, 9); + } + else + { + this.drawTexturedModalRect(j4, k4, l3 + 144, 9 * b1, 9, 9); + } + + f2 -= 2.0F; + } + else + { + if (k3 * 2 + 1 < k) + { + this.drawTexturedModalRect(j4, k4, l3 + 36, 9 * b1, 9, 9); + } + + if (k3 * 2 + 1 == k) + { + this.drawTexturedModalRect(j4, k4, l3 + 45, 9 * b1, 9, 9); + } + } + } + + Entity entity = this.mc.thePlayer.ridingEntity; + int k5; + + if (entity == null) + { + this.mc.mcProfiler.endStartSection("food"); + + for (l3 = 0; l3 < 10; ++l3) + { + k5 = i2; + i4 = 16; + byte b4 = 0; + + if (this.mc.thePlayer.isPotionActive(Potion.hunger)) + { + i4 += 36; + b4 = 13; + } + + if (this.mc.thePlayer.getFoodStats().getSaturationLevel() <= 0.0F && this.updateCounter % (i1 * 3 + 1) == 0) + { + k5 = i2 + (this.rand.nextInt(3) - 1); + } + + if (flag1) + { + b4 = 1; + } + + k4 = l1 - l3 * 8 - 9; + this.drawTexturedModalRect(k4, k5, 16 + b4 * 9, 27, 9, 9); + + if (flag1) + { + if (l3 * 2 + 1 < j1) + { + this.drawTexturedModalRect(k4, k5, i4 + 54, 27, 9, 9); + } + + if (l3 * 2 + 1 == j1) + { + this.drawTexturedModalRect(k4, k5, i4 + 63, 27, 9, 9); + } + } + + if (l3 * 2 + 1 < i1) + { + this.drawTexturedModalRect(k4, k5, i4 + 36, 27, 9, 9); + } + + if (l3 * 2 + 1 == i1) + { + this.drawTexturedModalRect(k4, k5, i4 + 45, 27, 9, 9); + } + } + } + else if (entity instanceof EntityLivingBase) + { + this.mc.mcProfiler.endStartSection("mountHealth"); + EntityLivingBase entitylivingbase = (EntityLivingBase)entity; + k5 = (int)Math.ceil((double)entitylivingbase.getHealth()); + float f3 = entitylivingbase.getMaxHealth(); + j4 = (int)(f3 + 0.5F) / 2; + + if (j4 > 30) + { + j4 = 30; + } + + k4 = i2; + + for (int l5 = 0; j4 > 0; l5 += 20) + { + int l4 = Math.min(j4, 10); + j4 -= l4; + + for (int i5 = 0; i5 < l4; ++i5) + { + byte b2 = 52; + byte b3 = 0; + + if (flag1) + { + b3 = 1; + } + + int j5 = l1 - i5 * 8 - 9; + this.drawTexturedModalRect(j5, k4, b2 + b3 * 9, 9, 9, 9); + + if (i5 * 2 + 1 + l5 < k5) + { + this.drawTexturedModalRect(j5, k4, b2 + 36, 9, 9, 9); + } + + if (i5 * 2 + 1 + l5 == k5) + { + this.drawTexturedModalRect(j5, k4, b2 + 45, 9, 9, 9); + } + } + + k4 -= 10; + } + } + + this.mc.mcProfiler.endStartSection("air"); + + if (this.mc.thePlayer.isInsideOfMaterial(Material.water)) + { + l3 = this.mc.thePlayer.getAir(); + k5 = MathHelper.ceiling_double_int((double)(l3 - 2) * 10.0D / 300.0D); + i4 = MathHelper.ceiling_double_int((double)l3 * 10.0D / 300.0D) - k5; + + for (j4 = 0; j4 < k5 + i4; ++j4) + { + if (j4 < k5) + { + this.drawTexturedModalRect(l1 - j4 * 8 - 9, l2, 16, 18, 9, 9); + } + else + { + this.drawTexturedModalRect(l1 - j4 * 8 - 9, l2, 25, 18, 9, 9); + } + } + } + + this.mc.mcProfiler.endSection(); + } + + protected void renderBossHealth() + { + if (BossStatus.bossName != null && BossStatus.statusBarTime > 0) + { + --BossStatus.statusBarTime; + FontRenderer fontrenderer = this.mc.fontRenderer; + ScaledResolution scaledresolution = new ScaledResolution(this.mc.gameSettings, this.mc.displayWidth, this.mc.displayHeight); + int i = scaledresolution.getScaledWidth(); + short short1 = 182; + int j = i / 2 - short1 / 2; + int k = (int)(BossStatus.healthScale * (float)(short1 + 1)); + byte b0 = 12; + this.drawTexturedModalRect(j, b0, 0, 74, short1, 5); + this.drawTexturedModalRect(j, b0, 0, 74, short1, 5); + + if (k > 0) + { + this.drawTexturedModalRect(j, b0, 0, 79, k, 5); + } + + String s = BossStatus.bossName; + fontrenderer.drawStringWithShadow(s, i / 2 - fontrenderer.getStringWidth(s) / 2, b0 - 10, 16777215); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(icons); + } + } + + protected void renderPumpkinBlur(int par1, int par2) + { + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glDepthMask(false); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_ALPHA_TEST); + this.mc.getTextureManager().bindTexture(pumpkinBlurTexPath); + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV(0.0D, (double)par2, -90.0D, 0.0D, 1.0D); + tessellator.addVertexWithUV((double)par1, (double)par2, -90.0D, 1.0D, 1.0D); + tessellator.addVertexWithUV((double)par1, 0.0D, -90.0D, 1.0D, 0.0D); + tessellator.addVertexWithUV(0.0D, 0.0D, -90.0D, 0.0D, 0.0D); + tessellator.draw(); + GL11.glDepthMask(true); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + } + + protected void renderVignette(float par1, int par2, int par3) + { + par1 = 1.0F - par1; + + if (par1 < 0.0F) + { + par1 = 0.0F; + } + + if (par1 > 1.0F) + { + par1 = 1.0F; + } + + this.prevVignetteBrightness = (float)((double)this.prevVignetteBrightness + (double)(par1 - this.prevVignetteBrightness) * 0.01D); + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glDepthMask(false); + OpenGlHelper.glBlendFunc(0, 769, 1, 0); + GL11.glColor4f(this.prevVignetteBrightness, this.prevVignetteBrightness, this.prevVignetteBrightness, 1.0F); + this.mc.getTextureManager().bindTexture(vignetteTexPath); + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV(0.0D, (double)par3, -90.0D, 0.0D, 1.0D); + tessellator.addVertexWithUV((double)par2, (double)par3, -90.0D, 1.0D, 1.0D); + tessellator.addVertexWithUV((double)par2, 0.0D, -90.0D, 1.0D, 0.0D); + tessellator.addVertexWithUV(0.0D, 0.0D, -90.0D, 0.0D, 0.0D); + tessellator.draw(); + GL11.glDepthMask(true); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + } + + protected void func_130015_b(float par1, int par2, int par3) + { + if (par1 < 1.0F) + { + par1 *= par1; + par1 *= par1; + par1 = par1 * 0.8F + 0.2F; + } + + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glDepthMask(false); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glColor4f(1.0F, 1.0F, 1.0F, par1); + IIcon iicon = Blocks.portal.getBlockTextureFromSide(1); + this.mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture); + float f1 = iicon.getMinU(); + float f2 = iicon.getMinV(); + float f3 = iicon.getMaxU(); + float f4 = iicon.getMaxV(); + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV(0.0D, (double)par3, -90.0D, (double)f1, (double)f4); + tessellator.addVertexWithUV((double)par2, (double)par3, -90.0D, (double)f3, (double)f4); + tessellator.addVertexWithUV((double)par2, 0.0D, -90.0D, (double)f3, (double)f2); + tessellator.addVertexWithUV(0.0D, 0.0D, -90.0D, (double)f1, (double)f2); + tessellator.draw(); + GL11.glDepthMask(true); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + } + + protected void renderInventorySlot(int par1, int par2, int par3, float par4) + { + ItemStack itemstack = this.mc.thePlayer.inventory.mainInventory[par1]; + + if (itemstack != null) + { + float f1 = (float)itemstack.animationsToGo - par4; + + if (f1 > 0.0F) + { + GL11.glPushMatrix(); + float f2 = 1.0F + f1 / 5.0F; + GL11.glTranslatef((float)(par2 + 8), (float)(par3 + 12), 0.0F); + GL11.glScalef(1.0F / f2, (f2 + 1.0F) / 2.0F, 1.0F); + GL11.glTranslatef((float)(-(par2 + 8)), (float)(-(par3 + 12)), 0.0F); + } + + itemRenderer.renderItemAndEffectIntoGUI(this.mc.fontRenderer, this.mc.getTextureManager(), itemstack, par2, par3); + + if (f1 > 0.0F) + { + GL11.glPopMatrix(); + } + + itemRenderer.renderItemOverlayIntoGUI(this.mc.fontRenderer, this.mc.getTextureManager(), itemstack, par2, par3); + } + } + + public void updateTick() + { + if (this.recordPlayingUpFor > 0) + { + --this.recordPlayingUpFor; + } + + ++this.updateCounter; + + if (this.mc.thePlayer != null) + { + ItemStack itemstack = this.mc.thePlayer.inventory.getCurrentItem(); + + if (itemstack == null) + { + this.remainingHighlightTicks = 0; + } + else if (this.highlightingItemStack != null && itemstack.getItem() == this.highlightingItemStack.getItem() && ItemStack.areItemStackTagsEqual(itemstack, this.highlightingItemStack) && (itemstack.isItemStackDamageable() || itemstack.getItemDamage() == this.highlightingItemStack.getItemDamage())) + { + if (this.remainingHighlightTicks > 0) + { + --this.remainingHighlightTicks; + } + } + else + { + this.remainingHighlightTicks = 40; + } + + this.highlightingItemStack = itemstack; + } + } + + public void setRecordPlayingMessage(String par1Str) + { + this.func_110326_a("Now playing: " + par1Str, true); + } + + public void func_110326_a(String par1Str, boolean par2) + { + this.recordPlaying = par1Str; + this.recordPlayingUpFor = 60; + this.recordIsPlaying = par2; + } + + public GuiNewChat getChatGUI() + { + return this.persistantChatGUI; + } + + public int getUpdateCounter() + { + return this.updateCounter; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiIngameMenu.java b/src/main/java/net/minecraft/client/gui/GuiIngameMenu.java new file mode 100644 index 0000000..d3c3960 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiIngameMenu.java @@ -0,0 +1,90 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.gui.achievement.GuiAchievements; +import net.minecraft.client.gui.achievement.GuiStats; +import net.minecraft.client.multiplayer.WorldClient; +import net.minecraft.client.resources.I18n; + +@SideOnly(Side.CLIENT) +public class GuiIngameMenu extends GuiScreen +{ + private int field_146445_a; + private int field_146444_f; + private static final String __OBFID = "CL_00000703"; + + public void initGui() + { + this.field_146445_a = 0; + this.buttonList.clear(); + byte b0 = -16; + boolean flag = true; + this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 120 + b0, I18n.format("menu.returnToMenu", new Object[0]))); + + if (!this.mc.isIntegratedServerRunning()) + { + ((GuiButton)this.buttonList.get(0)).displayString = I18n.format("menu.disconnect", new Object[0]); + } + + this.buttonList.add(new GuiButton(4, this.width / 2 - 100, this.height / 4 + 24 + b0, I18n.format("menu.returnToGame", new Object[0]))); + this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 96 + b0, 98, 20, I18n.format("menu.options", new Object[0]))); + this.buttonList.add(new GuiButton(12, this.width / 2 + 2, this.height / 4 + 96 + b0, 98, 20, "Mod Options...")); + GuiButton guibutton; + this.buttonList.add(guibutton = new GuiButton(7, this.width / 2 - 100, this.height / 4 + 72 + b0, 200, 20, I18n.format("menu.shareToLan", new Object[0]))); + this.buttonList.add(new GuiButton(5, this.width / 2 - 100, this.height / 4 + 48 + b0, 98, 20, I18n.format("gui.achievements", new Object[0]))); + this.buttonList.add(new GuiButton(6, this.width / 2 + 2, this.height / 4 + 48 + b0, 98, 20, I18n.format("gui.stats", new Object[0]))); + guibutton.enabled = this.mc.isSingleplayer() && !this.mc.getIntegratedServer().getPublic(); + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + switch (p_146284_1_.id) + { + case 0: + this.mc.displayGuiScreen(new GuiOptions(this, this.mc.gameSettings)); + break; + case 1: + p_146284_1_.enabled = false; + this.mc.theWorld.sendQuittingDisconnectingPacket(); + this.mc.loadWorld((WorldClient)null); + this.mc.displayGuiScreen(new GuiMainMenu()); + case 2: + case 3: + default: + break; + case 4: + this.mc.displayGuiScreen((GuiScreen)null); + this.mc.setIngameFocus(); + break; + case 5: + if (this.mc.thePlayer != null) + this.mc.displayGuiScreen(new GuiAchievements(this, this.mc.thePlayer.getStatFileWriter())); + break; + case 6: + if (this.mc.thePlayer != null) + this.mc.displayGuiScreen(new GuiStats(this, this.mc.thePlayer.getStatFileWriter())); + break; + case 7: + this.mc.displayGuiScreen(new GuiShareToLan(this)); + break; + case 12: + FMLClientHandler.instance().showInGameModOptions(this); + break; + } + } + + public void updateScreen() + { + super.updateScreen(); + ++this.field_146444_f; + } + + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + this.drawCenteredString(this.fontRendererObj, "Game menu", this.width / 2, 40, 16777215); + super.drawScreen(par1, par2, par3); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiKeyBindingList.java b/src/main/java/net/minecraft/client/gui/GuiKeyBindingList.java new file mode 100644 index 0000000..ed4c18c --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiKeyBindingList.java @@ -0,0 +1,193 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Arrays; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.resources.I18n; +import net.minecraft.client.settings.GameSettings; +import net.minecraft.client.settings.KeyBinding; +import net.minecraft.util.EnumChatFormatting; +import org.apache.commons.lang3.ArrayUtils; + +@SideOnly(Side.CLIENT) +public class GuiKeyBindingList extends GuiListExtended +{ + private final GuiControls field_148191_k; + private final Minecraft mc; + private final GuiListExtended.IGuiListEntry[] field_148190_m; + private int field_148188_n = 0; + private static final String __OBFID = "CL_00000732"; + + public GuiKeyBindingList(GuiControls p_i45031_1_, Minecraft p_i45031_2_) + { + super(p_i45031_2_, p_i45031_1_.width, p_i45031_1_.height, 63, p_i45031_1_.height - 32, 20); + this.field_148191_k = p_i45031_1_; + this.mc = p_i45031_2_; + KeyBinding[] akeybinding = (KeyBinding[])ArrayUtils.clone(p_i45031_2_.gameSettings.keyBindings); + this.field_148190_m = new GuiListExtended.IGuiListEntry[akeybinding.length + KeyBinding.getKeybinds().size()]; + Arrays.sort(akeybinding); + int i = 0; + String s = null; + KeyBinding[] akeybinding1 = akeybinding; + int j = akeybinding.length; + + for (int k = 0; k < j; ++k) + { + KeyBinding keybinding = akeybinding1[k]; + String s1 = keybinding.getKeyCategory(); + + if (!s1.equals(s)) + { + s = s1; + this.field_148190_m[i++] = new GuiKeyBindingList.CategoryEntry(s1); + } + + int l = p_i45031_2_.fontRenderer.getStringWidth(I18n.format(keybinding.getKeyDescription(), new Object[0])); + + if (l > this.field_148188_n) + { + this.field_148188_n = l; + } + + this.field_148190_m[i++] = new GuiKeyBindingList.KeyEntry(keybinding, null); + } + } + + protected int getSize() + { + return this.field_148190_m.length; + } + + public GuiListExtended.IGuiListEntry getListEntry(int p_148180_1_) + { + return this.field_148190_m[p_148180_1_]; + } + + protected int getScrollBarX() + { + return super.getScrollBarX() + 15; + } + + public int getListWidth() + { + return super.getListWidth() + 32; + } + + @SideOnly(Side.CLIENT) + public class CategoryEntry implements GuiListExtended.IGuiListEntry + { + private final String field_148285_b; + private final int field_148286_c; + private static final String __OBFID = "CL_00000734"; + + public CategoryEntry(String p_i45028_2_) + { + this.field_148285_b = I18n.format(p_i45028_2_, new Object[0]); + this.field_148286_c = GuiKeyBindingList.this.mc.fontRenderer.getStringWidth(this.field_148285_b); + } + + public void drawEntry(int p_148279_1_, int p_148279_2_, int p_148279_3_, int p_148279_4_, int p_148279_5_, Tessellator p_148279_6_, int p_148279_7_, int p_148279_8_, boolean p_148279_9_) + { + GuiKeyBindingList.this.mc.fontRenderer.drawString(this.field_148285_b, GuiKeyBindingList.this.mc.currentScreen.width / 2 - this.field_148286_c / 2, p_148279_3_ + p_148279_5_ - GuiKeyBindingList.this.mc.fontRenderer.FONT_HEIGHT - 1, 16777215); + } + + public boolean mousePressed(int p_148278_1_, int p_148278_2_, int p_148278_3_, int p_148278_4_, int p_148278_5_, int p_148278_6_) + { + return false; + } + + public void mouseReleased(int p_148277_1_, int p_148277_2_, int p_148277_3_, int p_148277_4_, int p_148277_5_, int p_148277_6_) {} + } + + @SideOnly(Side.CLIENT) + public class KeyEntry implements GuiListExtended.IGuiListEntry + { + private final KeyBinding field_148282_b; + private final String field_148283_c; + private final GuiButton btnChangeKeyBinding; + private final GuiButton btnReset; + private static final String __OBFID = "CL_00000735"; + + private KeyEntry(KeyBinding p_i45029_2_) + { + this.field_148282_b = p_i45029_2_; + this.field_148283_c = I18n.format(p_i45029_2_.getKeyDescription(), new Object[0]); + this.btnChangeKeyBinding = new GuiButton(0, 0, 0, 75, 18, I18n.format(p_i45029_2_.getKeyDescription(), new Object[0])); + this.btnReset = new GuiButton(0, 0, 0, 50, 18, I18n.format("controls.reset", new Object[0])); + } + + public void drawEntry(int p_148279_1_, int p_148279_2_, int p_148279_3_, int p_148279_4_, int p_148279_5_, Tessellator p_148279_6_, int p_148279_7_, int p_148279_8_, boolean p_148279_9_) + { + boolean flag1 = GuiKeyBindingList.this.field_148191_k.buttonId == this.field_148282_b; + GuiKeyBindingList.this.mc.fontRenderer.drawString(this.field_148283_c, p_148279_2_ + 90 - GuiKeyBindingList.this.field_148188_n, p_148279_3_ + p_148279_5_ / 2 - GuiKeyBindingList.this.mc.fontRenderer.FONT_HEIGHT / 2, 16777215); + this.btnReset.xPosition = p_148279_2_ + 190; + this.btnReset.yPosition = p_148279_3_; + this.btnReset.enabled = this.field_148282_b.getKeyCode() != this.field_148282_b.getKeyCodeDefault(); + this.btnReset.drawButton(GuiKeyBindingList.this.mc, p_148279_7_, p_148279_8_); + this.btnChangeKeyBinding.xPosition = p_148279_2_ + 105; + this.btnChangeKeyBinding.yPosition = p_148279_3_; + this.btnChangeKeyBinding.displayString = GameSettings.getKeyDisplayString(this.field_148282_b.getKeyCode()); + boolean flag2 = false; + + if (this.field_148282_b.getKeyCode() != 0) + { + KeyBinding[] akeybinding = GuiKeyBindingList.this.mc.gameSettings.keyBindings; + int l1 = akeybinding.length; + + for (int i2 = 0; i2 < l1; ++i2) + { + KeyBinding keybinding = akeybinding[i2]; + + if (keybinding != this.field_148282_b && keybinding.getKeyCode() == this.field_148282_b.getKeyCode()) + { + flag2 = true; + break; + } + } + } + + if (flag1) + { + this.btnChangeKeyBinding.displayString = EnumChatFormatting.WHITE + "> " + EnumChatFormatting.YELLOW + this.btnChangeKeyBinding.displayString + EnumChatFormatting.WHITE + " <"; + } + else if (flag2) + { + this.btnChangeKeyBinding.displayString = EnumChatFormatting.RED + this.btnChangeKeyBinding.displayString; + } + + this.btnChangeKeyBinding.drawButton(GuiKeyBindingList.this.mc, p_148279_7_, p_148279_8_); + } + + public boolean mousePressed(int p_148278_1_, int p_148278_2_, int p_148278_3_, int p_148278_4_, int p_148278_5_, int p_148278_6_) + { + if (this.btnChangeKeyBinding.mousePressed(GuiKeyBindingList.this.mc, p_148278_2_, p_148278_3_)) + { + GuiKeyBindingList.this.field_148191_k.buttonId = this.field_148282_b; + return true; + } + else if (this.btnReset.mousePressed(GuiKeyBindingList.this.mc, p_148278_2_, p_148278_3_)) + { + GuiKeyBindingList.this.mc.gameSettings.setOptionKeyBinding(this.field_148282_b, this.field_148282_b.getKeyCodeDefault()); + KeyBinding.resetKeyBindingArrayAndHash(); + return true; + } + else + { + return false; + } + } + + public void mouseReleased(int p_148277_1_, int p_148277_2_, int p_148277_3_, int p_148277_4_, int p_148277_5_, int p_148277_6_) + { + this.btnChangeKeyBinding.mouseReleased(p_148277_2_, p_148277_3_); + this.btnReset.mouseReleased(p_148277_2_, p_148277_3_); + } + + KeyEntry(KeyBinding p_i45030_2_, Object p_i45030_3_) + { + this(p_i45030_2_); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiLabel.java b/src/main/java/net/minecraft/client/gui/GuiLabel.java new file mode 100644 index 0000000..42c49fc --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiLabel.java @@ -0,0 +1,69 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.OpenGlHelper; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class GuiLabel extends Gui +{ + protected int field_146167_a; + protected int field_146161_f; + public int field_146162_g; + public int field_146174_h; + private ArrayList field_146173_k; + private boolean field_146170_l; + public boolean field_146172_j; + private boolean field_146171_m; + private int field_146168_n; + private int field_146169_o; + private int field_146166_p; + private int field_146165_q; + private FontRenderer field_146164_r; + private int field_146163_s; + private static final String __OBFID = "CL_00000671"; + + public void func_146159_a(Minecraft p_146159_1_, int p_146159_2_, int p_146159_3_) + { + if (this.field_146172_j) + { + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + this.func_146160_b(p_146159_1_, p_146159_2_, p_146159_3_); + int k = this.field_146174_h + this.field_146161_f / 2 + this.field_146163_s / 2; + int l = k - this.field_146173_k.size() * 10 / 2; + + for (int i1 = 0; i1 < this.field_146173_k.size(); ++i1) + { + if (this.field_146170_l) + { + this.drawCenteredString(this.field_146164_r, (String)this.field_146173_k.get(i1), this.field_146162_g + this.field_146167_a / 2, l + i1 * 10, this.field_146168_n); + } + else + { + this.drawString(this.field_146164_r, (String)this.field_146173_k.get(i1), this.field_146162_g, l + i1 * 10, this.field_146168_n); + } + } + } + } + + protected void func_146160_b(Minecraft p_146160_1_, int p_146160_2_, int p_146160_3_) + { + if (this.field_146171_m) + { + int k = this.field_146167_a + this.field_146163_s * 2; + int l = this.field_146161_f + this.field_146163_s * 2; + int i1 = this.field_146162_g - this.field_146163_s; + int j1 = this.field_146174_h - this.field_146163_s; + drawRect(i1, j1, i1 + k, j1 + l, this.field_146169_o); + this.drawHorizontalLine(i1, i1 + k, j1, this.field_146166_p); + this.drawHorizontalLine(i1, i1 + k, j1 + l, this.field_146165_q); + this.drawVerticalLine(i1, j1, j1 + l, this.field_146166_p); + this.drawVerticalLine(i1 + k, j1, j1 + l, this.field_146165_q); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiLanguage.java b/src/main/java/net/minecraft/client/gui/GuiLanguage.java new file mode 100644 index 0000000..478c1cb --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiLanguage.java @@ -0,0 +1,134 @@ +package net.minecraft.client.gui; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Iterator; +import java.util.Map; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.resources.I18n; +import net.minecraft.client.resources.Language; +import net.minecraft.client.resources.LanguageManager; +import net.minecraft.client.settings.GameSettings; + +@SideOnly(Side.CLIENT) +public class GuiLanguage extends GuiScreen +{ + protected GuiScreen field_146453_a; + private GuiLanguage.List field_146450_f; + private final GameSettings field_146451_g; + private final LanguageManager field_146454_h; + private GuiOptionButton field_146455_i; + private GuiOptionButton field_146452_r; + private static final String __OBFID = "CL_00000698"; + + public GuiLanguage(GuiScreen par1GuiScreen, GameSettings par2GameSettings, LanguageManager par3LanguageManager) + { + this.field_146453_a = par1GuiScreen; + this.field_146451_g = par2GameSettings; + this.field_146454_h = par3LanguageManager; + } + + public void initGui() + { + this.buttonList.add(this.field_146455_i = new GuiOptionButton(100, this.width / 2 - 155, this.height - 38, GameSettings.Options.FORCE_UNICODE_FONT, this.field_146451_g.getKeyBinding(GameSettings.Options.FORCE_UNICODE_FONT))); + this.buttonList.add(this.field_146452_r = new GuiOptionButton(6, this.width / 2 - 155 + 160, this.height - 38, I18n.format("gui.done", new Object[0]))); + this.field_146450_f = new GuiLanguage.List(); + this.field_146450_f.registerScrollButtons(7, 8); + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.enabled) + { + switch (p_146284_1_.id) + { + case 5: + break; + case 6: + this.mc.displayGuiScreen(this.field_146453_a); + break; + case 100: + if (p_146284_1_ instanceof GuiOptionButton) + { + this.field_146451_g.setOptionValue(((GuiOptionButton)p_146284_1_).returnEnumOptions(), 1); + p_146284_1_.displayString = this.field_146451_g.getKeyBinding(GameSettings.Options.FORCE_UNICODE_FONT); + } + + break; + default: + this.field_146450_f.actionPerformed(p_146284_1_); + } + } + } + + public void drawScreen(int par1, int par2, float par3) + { + this.field_146450_f.drawScreen(par1, par2, par3); + this.drawCenteredString(this.fontRendererObj, I18n.format("options.language", new Object[0]), this.width / 2, 16, 16777215); + this.drawCenteredString(this.fontRendererObj, "(" + I18n.format("options.languageWarning", new Object[0]) + ")", this.width / 2, this.height - 56, 8421504); + super.drawScreen(par1, par2, par3); + } + + @SideOnly(Side.CLIENT) + class List extends GuiSlot + { + private final java.util.List field_148176_l = Lists.newArrayList(); + private final Map field_148177_m = Maps.newHashMap(); + private static final String __OBFID = "CL_00000699"; + + public List() + { + super(GuiLanguage.this.mc, GuiLanguage.this.width, GuiLanguage.this.height, 32, GuiLanguage.this.height - 65 + 4, 18); + Iterator iterator = GuiLanguage.this.field_146454_h.getLanguages().iterator(); + + while (iterator.hasNext()) + { + Language language = (Language)iterator.next(); + this.field_148177_m.put(language.getLanguageCode(), language); + this.field_148176_l.add(language.getLanguageCode()); + } + } + + protected int getSize() + { + return this.field_148176_l.size(); + } + + protected void elementClicked(int p_148144_1_, boolean p_148144_2_, int p_148144_3_, int p_148144_4_) + { + Language language = (Language)this.field_148177_m.get(this.field_148176_l.get(p_148144_1_)); + GuiLanguage.this.field_146454_h.setCurrentLanguage(language); + GuiLanguage.this.field_146451_g.language = language.getLanguageCode(); + GuiLanguage.this.mc.refreshResources(); + GuiLanguage.this.fontRendererObj.setUnicodeFlag(GuiLanguage.this.field_146454_h.isCurrentLocaleUnicode() || GuiLanguage.this.field_146451_g.forceUnicodeFont); + GuiLanguage.this.fontRendererObj.setBidiFlag(GuiLanguage.this.field_146454_h.isCurrentLanguageBidirectional()); + GuiLanguage.this.field_146452_r.displayString = I18n.format("gui.done", new Object[0]); + GuiLanguage.this.field_146455_i.displayString = GuiLanguage.this.field_146451_g.getKeyBinding(GameSettings.Options.FORCE_UNICODE_FONT); + GuiLanguage.this.field_146451_g.saveOptions(); + } + + protected boolean isSelected(int p_148131_1_) + { + return ((String)this.field_148176_l.get(p_148131_1_)).equals(GuiLanguage.this.field_146454_h.getCurrentLanguage().getLanguageCode()); + } + + protected int getContentHeight() + { + return this.getSize() * 18; + } + + protected void drawBackground() + { + GuiLanguage.this.drawDefaultBackground(); + } + + protected void drawSlot(int p_148126_1_, int p_148126_2_, int p_148126_3_, int p_148126_4_, Tessellator p_148126_5_, int p_148126_6_, int p_148126_7_) + { + GuiLanguage.this.fontRendererObj.setBidiFlag(true); + GuiLanguage.this.drawCenteredString(GuiLanguage.this.fontRendererObj, ((Language)this.field_148177_m.get(this.field_148176_l.get(p_148126_1_))).toString(), this.width / 2, p_148126_3_ + 1, 16777215); + GuiLanguage.this.fontRendererObj.setBidiFlag(GuiLanguage.this.field_146454_h.getCurrentLanguage().isBidirectional()); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiListExtended.java b/src/main/java/net/minecraft/client/gui/GuiListExtended.java new file mode 100644 index 0000000..e1693eb --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiListExtended.java @@ -0,0 +1,82 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.Tessellator; + +@SideOnly(Side.CLIENT) +public abstract class GuiListExtended extends GuiSlot +{ + private static final String __OBFID = "CL_00000674"; + + public GuiListExtended(Minecraft p_i45010_1_, int p_i45010_2_, int p_i45010_3_, int p_i45010_4_, int p_i45010_5_, int p_i45010_6_) + { + super(p_i45010_1_, p_i45010_2_, p_i45010_3_, p_i45010_4_, p_i45010_5_, p_i45010_6_); + } + + protected void elementClicked(int p_148144_1_, boolean p_148144_2_, int p_148144_3_, int p_148144_4_) {} + + protected boolean isSelected(int p_148131_1_) + { + return false; + } + + protected void drawBackground() {} + + protected void drawSlot(int p_148126_1_, int p_148126_2_, int p_148126_3_, int p_148126_4_, Tessellator p_148126_5_, int p_148126_6_, int p_148126_7_) + { + this.getListEntry(p_148126_1_).drawEntry(p_148126_1_, p_148126_2_, p_148126_3_, this.getListWidth(), p_148126_4_, p_148126_5_, p_148126_6_, p_148126_7_, this.func_148124_c(p_148126_6_, p_148126_7_) == p_148126_1_); + } + + public boolean func_148179_a(int p_148179_1_, int p_148179_2_, int p_148179_3_) + { + if (this.func_148141_e(p_148179_2_)) + { + int l = this.func_148124_c(p_148179_1_, p_148179_2_); + + if (l >= 0) + { + int i1 = this.left + this.width / 2 - this.getListWidth() / 2 + 2; + int j1 = this.top + 4 - this.getAmountScrolled() + l * this.slotHeight + this.headerPadding; + int k1 = p_148179_1_ - i1; + int l1 = p_148179_2_ - j1; + + if (this.getListEntry(l).mousePressed(l, p_148179_1_, p_148179_2_, p_148179_3_, k1, l1)) + { + this.func_148143_b(false); + return true; + } + } + } + + return false; + } + + public boolean func_148181_b(int p_148181_1_, int p_148181_2_, int p_148181_3_) + { + for (int l = 0; l < this.getSize(); ++l) + { + int i1 = this.left + this.width / 2 - this.getListWidth() / 2 + 2; + int j1 = this.top + 4 - this.getAmountScrolled() + l * this.slotHeight + this.headerPadding; + int k1 = p_148181_1_ - i1; + int l1 = p_148181_2_ - j1; + this.getListEntry(l).mouseReleased(l, p_148181_1_, p_148181_2_, p_148181_3_, k1, l1); + } + + this.func_148143_b(true); + return false; + } + + public abstract GuiListExtended.IGuiListEntry getListEntry(int var1); + + @SideOnly(Side.CLIENT) + public interface IGuiListEntry + { + void drawEntry(int var1, int var2, int var3, int var4, int var5, Tessellator var6, int var7, int var8, boolean var9); + + boolean mousePressed(int var1, int var2, int var3, int var4, int var5, int var6); + + void mouseReleased(int var1, int var2, int var3, int var4, int var5, int var6); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiMainMenu.java b/src/main/java/net/minecraft/client/gui/GuiMainMenu.java new file mode 100644 index 0000000..f484e2e --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiMainMenu.java @@ -0,0 +1,647 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.client.GuiModList; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.URI; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; +import java.util.Random; +import java.util.concurrent.atomic.AtomicInteger; +import net.minecraft.client.Minecraft; +import net.minecraft.client.mco.ExceptionMcoService; +import net.minecraft.client.mco.ExceptionRetryCall; +import net.minecraft.client.mco.GuiScreenClientOutdated; +import net.minecraft.client.mco.McoClient; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.DynamicTexture; +import net.minecraft.client.resources.I18n; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Session; +import net.minecraft.world.demo.DemoWorldServer; +import net.minecraft.world.storage.ISaveFormat; +import net.minecraft.world.storage.WorldInfo; +import net.minecraftforge.client.ForgeHooksClient; +import org.apache.commons.io.Charsets; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.lwjgl.opengl.GL11; +import org.lwjgl.util.glu.Project; + +import com.google.common.base.Strings; +import com.google.common.collect.Lists; + +@SideOnly(Side.CLIENT) +public class GuiMainMenu extends GuiScreen +{ + private static final AtomicInteger field_146973_f = new AtomicInteger(0); + private static final Logger logger = LogManager.getLogger(); + private static final Random rand = new Random(); + private float updateCounter; + private String splashText; + private GuiButton buttonResetDemo; + private int panoramaTimer; + private DynamicTexture viewportTexture; + private boolean field_96141_q = true; + private static boolean field_96140_r; + private static boolean field_96139_s; + private final Object field_104025_t = new Object(); + private String field_92025_p; + private String field_146972_A; + private String field_104024_v; + private static final ResourceLocation splashTexts = new ResourceLocation("texts/splashes.txt"); + private static final ResourceLocation minecraftTitleTextures = new ResourceLocation("textures/gui/title/minecraft.png"); + private static final ResourceLocation[] titlePanoramaPaths = new ResourceLocation[] {new ResourceLocation("textures/gui/title/background/panorama_0.png"), new ResourceLocation("textures/gui/title/background/panorama_1.png"), new ResourceLocation("textures/gui/title/background/panorama_2.png"), new ResourceLocation("textures/gui/title/background/panorama_3.png"), new ResourceLocation("textures/gui/title/background/panorama_4.png"), new ResourceLocation("textures/gui/title/background/panorama_5.png")}; + public static final String field_96138_a = "Please click " + EnumChatFormatting.UNDERLINE + "here" + EnumChatFormatting.RESET + " for more information."; + private int field_92024_r; + private int field_92023_s; + private int field_92022_t; + private int field_92021_u; + private int field_92020_v; + private int field_92019_w; + private ResourceLocation field_110351_G; + private GuiButton minecraftRealmsButton; + private static final String __OBFID = "CL_00001154"; + + private GuiButton fmlModButton = null; + + public GuiMainMenu() + { + this.field_146972_A = field_96138_a; + this.splashText = "missingno"; + BufferedReader bufferedreader = null; + + try + { + ArrayList arraylist = new ArrayList(); + bufferedreader = new BufferedReader(new InputStreamReader(Minecraft.getMinecraft().getResourceManager().getResource(splashTexts).getInputStream(), Charsets.UTF_8)); + String s; + + while ((s = bufferedreader.readLine()) != null) + { + s = s.trim(); + + if (!s.isEmpty()) + { + arraylist.add(s); + } + } + + if (!arraylist.isEmpty()) + { + do + { + this.splashText = (String)arraylist.get(rand.nextInt(arraylist.size())); + } + while (this.splashText.hashCode() == 125780783); + } + } + catch (IOException ioexception1) + { + ; + } + finally + { + if (bufferedreader != null) + { + try + { + bufferedreader.close(); + } + catch (IOException ioexception) + { + ; + } + } + } + + this.updateCounter = rand.nextFloat(); + this.field_92025_p = ""; + + if (!OpenGlHelper.openGL21) + { + this.field_92025_p = "Old graphics card detected; this may prevent you from"; + this.field_146972_A = "playing in the far future as OpenGL 2.1 will be required."; + this.field_104024_v = "https://help.mojang.com/customer/portal/articles/325948?ref=game"; + } + } + + public void updateScreen() + { + ++this.panoramaTimer; + } + + public boolean doesGuiPauseGame() + { + return false; + } + + protected void keyTyped(char par1, int par2) {} + + public void initGui() + { + this.viewportTexture = new DynamicTexture(256, 256); + this.field_110351_G = this.mc.getTextureManager().getDynamicTextureLocation("background", this.viewportTexture); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(new Date()); + + if (calendar.get(2) + 1 == 11 && calendar.get(5) == 9) + { + this.splashText = "Happy birthday, ez!"; + } + else if (calendar.get(2) + 1 == 6 && calendar.get(5) == 1) + { + this.splashText = "Happy birthday, Notch!"; + } + else if (calendar.get(2) + 1 == 12 && calendar.get(5) == 24) + { + this.splashText = "Merry X-mas!"; + } + else if (calendar.get(2) + 1 == 1 && calendar.get(5) == 1) + { + this.splashText = "Happy new year!"; + } + else if (calendar.get(2) + 1 == 10 && calendar.get(5) == 31) + { + this.splashText = "OOoooOOOoooo! Spooky!"; + } + + boolean flag = true; + int i = this.height / 4 + 48; + + if (this.mc.isDemo()) + { + this.addDemoButtons(i, 24); + } + else + { + this.addSingleplayerMultiplayerButtons(i, 24); + } + + this.func_130020_g(); + this.buttonList.add(new GuiButton(0, this.width / 2 - 100, i + 72 + 12, 98, 20, I18n.format("menu.options", new Object[0]))); + this.buttonList.add(new GuiButton(4, this.width / 2 + 2, i + 72 + 12, 98, 20, I18n.format("menu.quit", new Object[0]))); + this.buttonList.add(new GuiButtonLanguage(5, this.width / 2 - 124, i + 72 + 12)); + Object object = this.field_104025_t; + + synchronized (this.field_104025_t) + { + this.field_92023_s = this.fontRendererObj.getStringWidth(this.field_92025_p); + this.field_92024_r = this.fontRendererObj.getStringWidth(this.field_146972_A); + int j = Math.max(this.field_92023_s, this.field_92024_r); + this.field_92022_t = (this.width - j) / 2; + this.field_92021_u = ((GuiButton)this.buttonList.get(0)).yPosition - 24; + this.field_92020_v = this.field_92022_t + j; + this.field_92019_w = this.field_92021_u + 24; + } + } + + private void func_130020_g() + { + if (this.field_96141_q) + { + if (!field_96140_r) + { + field_96140_r = true; + (new Thread("MCO Availability Checker #" + field_146973_f.incrementAndGet()) + { + private static final String __OBFID = "CL_00001155"; + public void run() + { + Session session = GuiMainMenu.this.mc.getSession(); + McoClient mcoclient = new McoClient(session.getSessionID(), session.getUsername(), "1.7.2", Minecraft.getMinecraft().getProxy()); + boolean flag = false; + + for (int i = 0; i < 3; ++i) + { + try + { + Boolean obool = mcoclient.func_148687_b(); + + if (obool.booleanValue()) + { + GuiMainMenu.this.func_130022_h(); + } + + GuiMainMenu.field_96139_s = obool.booleanValue(); + } + catch (ExceptionRetryCall exceptionretrycall) + { + flag = true; + } + catch (ExceptionMcoService exceptionmcoservice) + { + GuiMainMenu.logger.error("Couldn\'t connect to Realms"); + } + catch (IOException ioexception) + { + GuiMainMenu.logger.error("Couldn\'t parse response connecting to Realms"); + } + + if (!flag) + { + break; + } + + try + { + Thread.sleep(10000L); + } + catch (InterruptedException interruptedexception) + { + Thread.currentThread().interrupt(); + } + } + } + }).start(); + } + else if (field_96139_s) + { + this.func_130022_h(); + } + } + } + + private void func_130022_h() + { + this.minecraftRealmsButton.visible = true; + fmlModButton.width = 98; + fmlModButton.xPosition = this.width / 2 + 2; + } + + private void addSingleplayerMultiplayerButtons(int par1, int par2) + { + this.buttonList.add(new GuiButton(1, this.width / 2 - 100, par1, I18n.format("menu.singleplayer", new Object[0]))); + this.buttonList.add(new GuiButton(2, this.width / 2 - 100, par1 + par2 * 1, I18n.format("menu.multiplayer", new Object[0]))); + //If Minecraft Realms is enabled, halve the size of both buttons and set them next to eachother. + fmlModButton = new GuiButton(6, this.width / 2 - 100, par1 + par2 * 2, "Mods"); + this.buttonList.add(fmlModButton); + + minecraftRealmsButton = new GuiButton(14, this.width / 2 - 100, par1 + par2 * 2, I18n.format("menu.online")); + minecraftRealmsButton.width = 98; + minecraftRealmsButton.xPosition = this.width / 2 - 100; + this.buttonList.add(minecraftRealmsButton); + this.minecraftRealmsButton.visible = false; + } + + private void addDemoButtons(int par1, int par2) + { + this.buttonList.add(new GuiButton(11, this.width / 2 - 100, par1, I18n.format("menu.playdemo", new Object[0]))); + this.buttonList.add(this.buttonResetDemo = new GuiButton(12, this.width / 2 - 100, par1 + par2 * 1, I18n.format("menu.resetdemo", new Object[0]))); + ISaveFormat isaveformat = this.mc.getSaveLoader(); + WorldInfo worldinfo = isaveformat.getWorldInfo("Demo_World"); + + if (worldinfo == null) + { + this.buttonResetDemo.enabled = false; + } + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.id == 0) + { + this.mc.displayGuiScreen(new GuiOptions(this, this.mc.gameSettings)); + } + + if (p_146284_1_.id == 5) + { + this.mc.displayGuiScreen(new GuiLanguage(this, this.mc.gameSettings, this.mc.getLanguageManager())); + } + + if (p_146284_1_.id == 1) + { + this.mc.displayGuiScreen(new GuiSelectWorld(this)); + } + + if (p_146284_1_.id == 2) + { + this.mc.displayGuiScreen(new GuiMultiplayer(this)); + } + + if (p_146284_1_.id == 14 && this.minecraftRealmsButton.visible) + { + this.func_140005_i(); + } + + if (p_146284_1_.id == 4) + { + this.mc.shutdown(); + } + + if (p_146284_1_.id == 6) + { + this.mc.displayGuiScreen(new GuiModList(this)); + } + + if (p_146284_1_.id == 11) + { + this.mc.launchIntegratedServer("Demo_World", "Demo_World", DemoWorldServer.demoWorldSettings); + } + + if (p_146284_1_.id == 12) + { + ISaveFormat isaveformat = this.mc.getSaveLoader(); + WorldInfo worldinfo = isaveformat.getWorldInfo("Demo_World"); + + if (worldinfo != null) + { + GuiYesNo guiyesno = GuiSelectWorld.func_146623_a(this, worldinfo.getWorldName(), 12); + this.mc.displayGuiScreen(guiyesno); + } + } + } + + private void func_140005_i() + { + Session session = this.mc.getSession(); + McoClient mcoclient = new McoClient(session.getSessionID(), session.getUsername(), "1.7.2", Minecraft.getMinecraft().getProxy()); + + try + { + if (mcoclient.func_148695_c().booleanValue()) + { + this.mc.displayGuiScreen(new GuiScreenClientOutdated(this)); + } + else + { + this.mc.displayGuiScreen(new GuiScreenOnlineServers(this)); + } + } + catch (ExceptionMcoService exceptionmcoservice) + { + logger.error("Couldn\'t connect to realms"); + } + catch (IOException ioexception) + { + logger.error("Couldn\'t connect to realms"); + } + } + + public void confirmClicked(boolean par1, int par2) + { + if (par1 && par2 == 12) + { + ISaveFormat isaveformat = this.mc.getSaveLoader(); + isaveformat.flushCache(); + isaveformat.deleteWorldDirectory("Demo_World"); + this.mc.displayGuiScreen(this); + } + else if (par2 == 13) + { + if (par1) + { + try + { + Class oclass = Class.forName("java.awt.Desktop"); + Object object = oclass.getMethod("getDesktop", new Class[0]).invoke((Object)null, new Object[0]); + oclass.getMethod("browse", new Class[] {URI.class}).invoke(object, new Object[] {new URI(this.field_104024_v)}); + } + catch (Throwable throwable) + { + logger.error("Couldn\'t open link", throwable); + } + } + + this.mc.displayGuiScreen(this); + } + } + + private void drawPanorama(int par1, int par2, float par3) + { + Tessellator tessellator = Tessellator.instance; + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glPushMatrix(); + GL11.glLoadIdentity(); + Project.gluPerspective(120.0F, 1.0F, 0.05F, 10.0F); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glPushMatrix(); + GL11.glLoadIdentity(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(90.0F, 0.0F, 0.0F, 1.0F); + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glDepthMask(false); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + byte b0 = 8; + + for (int k = 0; k < b0 * b0; ++k) + { + GL11.glPushMatrix(); + float f1 = ((float)(k % b0) / (float)b0 - 0.5F) / 64.0F; + float f2 = ((float)(k / b0) / (float)b0 - 0.5F) / 64.0F; + float f3 = 0.0F; + GL11.glTranslatef(f1, f2, f3); + GL11.glRotatef(MathHelper.sin(((float)this.panoramaTimer + par3) / 400.0F) * 25.0F + 20.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(-((float)this.panoramaTimer + par3) * 0.1F, 0.0F, 1.0F, 0.0F); + + for (int l = 0; l < 6; ++l) + { + GL11.glPushMatrix(); + + if (l == 1) + { + GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + } + + if (l == 2) + { + GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); + } + + if (l == 3) + { + GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); + } + + if (l == 4) + { + GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); + } + + if (l == 5) + { + GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F); + } + + this.mc.getTextureManager().bindTexture(titlePanoramaPaths[l]); + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_I(16777215, 255 / (k + 1)); + float f4 = 0.0F; + tessellator.addVertexWithUV(-1.0D, -1.0D, 1.0D, (double)(0.0F + f4), (double)(0.0F + f4)); + tessellator.addVertexWithUV(1.0D, -1.0D, 1.0D, (double)(1.0F - f4), (double)(0.0F + f4)); + tessellator.addVertexWithUV(1.0D, 1.0D, 1.0D, (double)(1.0F - f4), (double)(1.0F - f4)); + tessellator.addVertexWithUV(-1.0D, 1.0D, 1.0D, (double)(0.0F + f4), (double)(1.0F - f4)); + tessellator.draw(); + GL11.glPopMatrix(); + } + + GL11.glPopMatrix(); + GL11.glColorMask(true, true, true, false); + } + + tessellator.setTranslation(0.0D, 0.0D, 0.0D); + GL11.glColorMask(true, true, true, true); + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glPopMatrix(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glPopMatrix(); + GL11.glDepthMask(true); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glEnable(GL11.GL_DEPTH_TEST); + } + + private void rotateAndBlurSkybox(float par1) + { + this.mc.getTextureManager().bindTexture(this.field_110351_G); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); + GL11.glCopyTexSubImage2D(GL11.GL_TEXTURE_2D, 0, 0, 0, 0, 0, 256, 256); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glColorMask(true, true, true, false); + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + GL11.glDisable(GL11.GL_ALPHA_TEST); + byte b0 = 3; + + for (int i = 0; i < b0; ++i) + { + tessellator.setColorRGBA_F(1.0F, 1.0F, 1.0F, 1.0F / (float)(i + 1)); + int j = this.width; + int k = this.height; + float f1 = (float)(i - b0 / 2) / 256.0F; + tessellator.addVertexWithUV((double)j, (double)k, (double)this.zLevel, (double)(0.0F + f1), 1.0D); + tessellator.addVertexWithUV((double)j, 0.0D, (double)this.zLevel, (double)(1.0F + f1), 1.0D); + tessellator.addVertexWithUV(0.0D, 0.0D, (double)this.zLevel, (double)(1.0F + f1), 0.0D); + tessellator.addVertexWithUV(0.0D, (double)k, (double)this.zLevel, (double)(0.0F + f1), 0.0D); + } + + tessellator.draw(); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glColorMask(true, true, true, true); + } + + private void renderSkybox(int par1, int par2, float par3) + { + this.mc.getFramebuffer().unbindFramebuffer(); + GL11.glViewport(0, 0, 256, 256); + this.drawPanorama(par1, par2, par3); + this.rotateAndBlurSkybox(par3); + this.rotateAndBlurSkybox(par3); + this.rotateAndBlurSkybox(par3); + this.rotateAndBlurSkybox(par3); + this.rotateAndBlurSkybox(par3); + this.rotateAndBlurSkybox(par3); + this.rotateAndBlurSkybox(par3); + this.mc.getFramebuffer().bindFramebuffer(true); + GL11.glViewport(0, 0, this.mc.displayWidth, this.mc.displayHeight); + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + float f1 = this.width > this.height ? 120.0F / (float)this.width : 120.0F / (float)this.height; + float f2 = (float)this.height * f1 / 256.0F; + float f3 = (float)this.width * f1 / 256.0F; + tessellator.setColorRGBA_F(1.0F, 1.0F, 1.0F, 1.0F); + int k = this.width; + int l = this.height; + tessellator.addVertexWithUV(0.0D, (double)l, (double)this.zLevel, (double)(0.5F - f2), (double)(0.5F + f3)); + tessellator.addVertexWithUV((double)k, (double)l, (double)this.zLevel, (double)(0.5F - f2), (double)(0.5F - f3)); + tessellator.addVertexWithUV((double)k, 0.0D, (double)this.zLevel, (double)(0.5F + f2), (double)(0.5F - f3)); + tessellator.addVertexWithUV(0.0D, 0.0D, (double)this.zLevel, (double)(0.5F + f2), (double)(0.5F + f3)); + tessellator.draw(); + } + + public void drawScreen(int par1, int par2, float par3) + { + GL11.glDisable(GL11.GL_ALPHA_TEST); + this.renderSkybox(par1, par2, par3); + GL11.glEnable(GL11.GL_ALPHA_TEST); + Tessellator tessellator = Tessellator.instance; + short short1 = 274; + int k = this.width / 2 - short1 / 2; + byte b0 = 30; + this.drawGradientRect(0, 0, this.width, this.height, -2130706433, 16777215); + this.drawGradientRect(0, 0, this.width, this.height, 0, Integer.MIN_VALUE); + this.mc.getTextureManager().bindTexture(minecraftTitleTextures); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + + if ((double)this.updateCounter < 1.0E-4D) + { + this.drawTexturedModalRect(k + 0, b0 + 0, 0, 0, 99, 44); + this.drawTexturedModalRect(k + 99, b0 + 0, 129, 0, 27, 44); + this.drawTexturedModalRect(k + 99 + 26, b0 + 0, 126, 0, 3, 44); + this.drawTexturedModalRect(k + 99 + 26 + 3, b0 + 0, 99, 0, 26, 44); + this.drawTexturedModalRect(k + 155, b0 + 0, 0, 45, 155, 44); + } + else + { + this.drawTexturedModalRect(k + 0, b0 + 0, 0, 0, 155, 44); + this.drawTexturedModalRect(k + 155, b0 + 0, 0, 45, 155, 44); + } + + tessellator.setColorOpaque_I(-1); + GL11.glPushMatrix(); + GL11.glTranslatef((float)(this.width / 2 + 90), 70.0F, 0.0F); + GL11.glRotatef(-20.0F, 0.0F, 0.0F, 1.0F); + float f1 = 1.8F - MathHelper.abs(MathHelper.sin((float)(Minecraft.getSystemTime() % 1000L) / 1000.0F * (float)Math.PI * 2.0F) * 0.1F); + f1 = f1 * 100.0F / (float)(this.fontRendererObj.getStringWidth(this.splashText) + 32); + GL11.glScalef(f1, f1, f1); + this.drawCenteredString(this.fontRendererObj, this.splashText, 0, -8, -256); + GL11.glPopMatrix(); + String s = "Minecraft 1.7.2"; + + if (this.mc.isDemo()) + { + s = s + " Demo"; + } + + List brandings = Lists.reverse(FMLCommonHandler.instance().getBrandings(true)); + for (int i = 0; i < brandings.size(); i++) + { + String brd = brandings.get(i); + if (!Strings.isNullOrEmpty(brd)) + { + this.drawString(this.fontRendererObj, brd, 2, this.height - ( 10 + i * (this.fontRendererObj.FONT_HEIGHT + 1)), 16777215); + } + } + ForgeHooksClient.renderMainMenu(this, fontRendererObj, width, height); + String s1 = "Copyright Mojang AB. Do not distribute!"; + this.drawString(this.fontRendererObj, s1, this.width - this.fontRendererObj.getStringWidth(s1) - 2, this.height - 10, -1); + + if (this.field_92025_p != null && this.field_92025_p.length() > 0) + { + drawRect(this.field_92022_t - 2, this.field_92021_u - 2, this.field_92020_v + 2, this.field_92019_w - 1, 1428160512); + this.drawString(this.fontRendererObj, this.field_92025_p, this.field_92022_t, this.field_92021_u, -1); + this.drawString(this.fontRendererObj, this.field_146972_A, (this.width - this.field_92024_r) / 2, ((GuiButton)this.buttonList.get(0)).yPosition - 12, -1); + } + + super.drawScreen(par1, par2, par3); + } + + protected void mouseClicked(int par1, int par2, int par3) + { + super.mouseClicked(par1, par2, par3); + Object object = this.field_104025_t; + + synchronized (this.field_104025_t) + { + if (this.field_92025_p.length() > 0 && par1 >= this.field_92022_t && par1 <= this.field_92020_v && par2 >= this.field_92021_u && par2 <= this.field_92019_w) + { + GuiConfirmOpenLink guiconfirmopenlink = new GuiConfirmOpenLink(this, this.field_104024_v, 13, true); + guiconfirmopenlink.func_146358_g(); + this.mc.displayGuiScreen(guiconfirmopenlink); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiMemoryErrorScreen.java b/src/main/java/net/minecraft/client/gui/GuiMemoryErrorScreen.java new file mode 100644 index 0000000..6259f7f --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiMemoryErrorScreen.java @@ -0,0 +1,47 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.resources.I18n; + +@SideOnly(Side.CLIENT) +public class GuiMemoryErrorScreen extends GuiScreen +{ + private static final String __OBFID = "CL_00000702"; + + public void initGui() + { + this.buttonList.clear(); + this.buttonList.add(new GuiOptionButton(0, this.width / 2 - 155, this.height / 4 + 120 + 12, I18n.format("gui.toMenu", new Object[0]))); + this.buttonList.add(new GuiOptionButton(1, this.width / 2 - 155 + 160, this.height / 4 + 120 + 12, I18n.format("menu.quit", new Object[0]))); + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.id == 0) + { + this.mc.displayGuiScreen(new GuiMainMenu()); + } + else if (p_146284_1_.id == 1) + { + this.mc.shutdown(); + } + } + + protected void keyTyped(char par1, int par2) {} + + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + this.drawCenteredString(this.fontRendererObj, "Out of memory!", this.width / 2, this.height / 4 - 60 + 20, 16777215); + this.drawString(this.fontRendererObj, "Minecraft has run out of memory.", this.width / 2 - 140, this.height / 4 - 60 + 60 + 0, 10526880); + this.drawString(this.fontRendererObj, "This could be caused by a bug in the game or by the", this.width / 2 - 140, this.height / 4 - 60 + 60 + 18, 10526880); + this.drawString(this.fontRendererObj, "Java Virtual Machine not being allocated enough", this.width / 2 - 140, this.height / 4 - 60 + 60 + 27, 10526880); + this.drawString(this.fontRendererObj, "memory.", this.width / 2 - 140, this.height / 4 - 60 + 60 + 36, 10526880); + this.drawString(this.fontRendererObj, "To prevent level corruption, the current game has quit.", this.width / 2 - 140, this.height / 4 - 60 + 60 + 54, 10526880); + this.drawString(this.fontRendererObj, "We\'ve tried to free up enough memory to let you go back to", this.width / 2 - 140, this.height / 4 - 60 + 60 + 63, 10526880); + this.drawString(this.fontRendererObj, "the main menu and back to playing, but this may not have worked.", this.width / 2 - 140, this.height / 4 - 60 + 60 + 72, 10526880); + this.drawString(this.fontRendererObj, "Please restart the game if you see this message again.", this.width / 2 - 140, this.height / 4 - 60 + 60 + 81, 10526880); + super.drawScreen(par1, par2, par3); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiMerchant.java b/src/main/java/net/minecraft/client/gui/GuiMerchant.java new file mode 100644 index 0000000..ed3fc0f --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiMerchant.java @@ -0,0 +1,234 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.IMerchant; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ContainerMerchant; +import net.minecraft.item.ItemStack; +import net.minecraft.network.play.client.C17PacketCustomPayload; +import net.minecraft.util.ResourceLocation; +import net.minecraft.village.MerchantRecipe; +import net.minecraft.village.MerchantRecipeList; +import net.minecraft.world.World; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +@SideOnly(Side.CLIENT) +public class GuiMerchant extends GuiContainer +{ + private static final Logger logger = LogManager.getLogger(); + private static final ResourceLocation field_147038_v = new ResourceLocation("textures/gui/container/villager.png"); + private IMerchant field_147037_w; + private GuiMerchant.MerchantButton field_147043_x; + private GuiMerchant.MerchantButton field_147042_y; + private int field_147041_z; + private String field_147040_A; + private static final String __OBFID = "CL_00000762"; + + public GuiMerchant(InventoryPlayer par1InventoryPlayer, IMerchant par2IMerchant, World par3World, String par4Str) + { + super(new ContainerMerchant(par1InventoryPlayer, par2IMerchant, par3World)); + this.field_147037_w = par2IMerchant; + this.field_147040_A = par4Str != null && par4Str.length() >= 1 ? par4Str : I18n.format("entity.Villager.name", new Object[0]); + } + + public void initGui() + { + super.initGui(); + int i = (this.width - this.xSize) / 2; + int j = (this.height - this.ySize) / 2; + this.buttonList.add(this.field_147043_x = new GuiMerchant.MerchantButton(1, i + 120 + 27, j + 24 - 1, true)); + this.buttonList.add(this.field_147042_y = new GuiMerchant.MerchantButton(2, i + 36 - 19, j + 24 - 1, false)); + this.field_147043_x.enabled = false; + this.field_147042_y.enabled = false; + } + + protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) + { + this.fontRendererObj.drawString(this.field_147040_A, this.xSize / 2 - this.fontRendererObj.getStringWidth(this.field_147040_A) / 2, 6, 4210752); + this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752); + } + + public void updateScreen() + { + super.updateScreen(); + MerchantRecipeList merchantrecipelist = this.field_147037_w.getRecipes(this.mc.thePlayer); + + if (merchantrecipelist != null) + { + this.field_147043_x.enabled = this.field_147041_z < merchantrecipelist.size() - 1; + this.field_147042_y.enabled = this.field_147041_z > 0; + } + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + boolean flag = false; + + if (p_146284_1_ == this.field_147043_x) + { + ++this.field_147041_z; + flag = true; + } + else if (p_146284_1_ == this.field_147042_y) + { + --this.field_147041_z; + flag = true; + } + + if (flag) + { + ((ContainerMerchant)this.inventorySlots).setCurrentRecipeIndex(this.field_147041_z); + ByteBuf bytebuf = Unpooled.buffer(); + + try + { + bytebuf.writeInt(this.field_147041_z); + this.mc.getNetHandler().addToSendQueue(new C17PacketCustomPayload("MC|TrSel", bytebuf)); + } + catch (Exception exception) + { + logger.error("Couldn\'t send trade info", exception); + } + finally + { + bytebuf.release(); + } + } + } + + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(field_147038_v); + int k = (this.width - this.xSize) / 2; + int l = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + MerchantRecipeList merchantrecipelist = this.field_147037_w.getRecipes(this.mc.thePlayer); + + if (merchantrecipelist != null && !merchantrecipelist.isEmpty()) + { + int i1 = this.field_147041_z; + MerchantRecipe merchantrecipe = (MerchantRecipe)merchantrecipelist.get(i1); + + if (merchantrecipe.isRecipeDisabled()) + { + this.mc.getTextureManager().bindTexture(field_147038_v); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_LIGHTING); + this.drawTexturedModalRect(this.guiLeft + 83, this.guiTop + 21, 212, 0, 28, 21); + this.drawTexturedModalRect(this.guiLeft + 83, this.guiTop + 51, 212, 0, 28, 21); + } + } + } + + public void drawScreen(int par1, int par2, float par3) + { + super.drawScreen(par1, par2, par3); + MerchantRecipeList merchantrecipelist = this.field_147037_w.getRecipes(this.mc.thePlayer); + + if (merchantrecipelist != null && !merchantrecipelist.isEmpty()) + { + int k = (this.width - this.xSize) / 2; + int l = (this.height - this.ySize) / 2; + int i1 = this.field_147041_z; + MerchantRecipe merchantrecipe = (MerchantRecipe)merchantrecipelist.get(i1); + GL11.glPushMatrix(); + ItemStack itemstack = merchantrecipe.getItemToBuy(); + ItemStack itemstack1 = merchantrecipe.getSecondItemToBuy(); + ItemStack itemstack2 = merchantrecipe.getItemToSell(); + RenderHelper.enableGUIStandardItemLighting(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glEnable(GL11.GL_COLOR_MATERIAL); + GL11.glEnable(GL11.GL_LIGHTING); + itemRender.zLevel = 100.0F; + itemRender.renderItemAndEffectIntoGUI(this.fontRendererObj, this.mc.getTextureManager(), itemstack, k + 36, l + 24); + itemRender.renderItemOverlayIntoGUI(this.fontRendererObj, this.mc.getTextureManager(), itemstack, k + 36, l + 24); + + if (itemstack1 != null) + { + itemRender.renderItemAndEffectIntoGUI(this.fontRendererObj, this.mc.getTextureManager(), itemstack1, k + 62, l + 24); + itemRender.renderItemOverlayIntoGUI(this.fontRendererObj, this.mc.getTextureManager(), itemstack1, k + 62, l + 24); + } + + itemRender.renderItemAndEffectIntoGUI(this.fontRendererObj, this.mc.getTextureManager(), itemstack2, k + 120, l + 24); + itemRender.renderItemOverlayIntoGUI(this.fontRendererObj, this.mc.getTextureManager(), itemstack2, k + 120, l + 24); + itemRender.zLevel = 0.0F; + GL11.glDisable(GL11.GL_LIGHTING); + + if (this.func_146978_c(36, 24, 16, 16, par1, par2)) + { + this.renderToolTip(itemstack, par1, par2); + } + else if (itemstack1 != null && this.func_146978_c(62, 24, 16, 16, par1, par2)) + { + this.renderToolTip(itemstack1, par1, par2); + } + else if (this.func_146978_c(120, 24, 16, 16, par1, par2)) + { + this.renderToolTip(itemstack2, par1, par2); + } + + GL11.glPopMatrix(); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + RenderHelper.enableStandardItemLighting(); + } + } + + public IMerchant func_147035_g() + { + return this.field_147037_w; + } + + @SideOnly(Side.CLIENT) + static class MerchantButton extends GuiButton + { + private final boolean field_146157_o; + private static final String __OBFID = "CL_00000763"; + + public MerchantButton(int par1, int par2, int par3, boolean par4) + { + super(par1, par2, par3, 12, 19, ""); + this.field_146157_o = par4; + } + + public void drawButton(Minecraft p_146112_1_, int p_146112_2_, int p_146112_3_) + { + if (this.visible) + { + p_146112_1_.getTextureManager().bindTexture(GuiMerchant.field_147038_v); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + boolean flag = p_146112_2_ >= this.xPosition && p_146112_3_ >= this.yPosition && p_146112_2_ < this.xPosition + this.width && p_146112_3_ < this.yPosition + this.height; + int k = 0; + int l = 176; + + if (!this.enabled) + { + l += this.width * 2; + } + else if (flag) + { + l += this.width; + } + + if (!this.field_146157_o) + { + k += this.height; + } + + this.drawTexturedModalRect(this.xPosition, this.yPosition, l, k, this.width, this.height); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiMultiplayer.java b/src/main/java/net/minecraft/client/gui/GuiMultiplayer.java new file mode 100644 index 0000000..2f3f74d --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiMultiplayer.java @@ -0,0 +1,420 @@ +package net.minecraft.client.gui; + +import com.google.common.base.Splitter; +import com.google.common.collect.Lists; +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.client.multiplayer.GuiConnecting; +import net.minecraft.client.multiplayer.ServerData; +import net.minecraft.client.multiplayer.ServerList; +import net.minecraft.client.network.LanServerDetector; +import net.minecraft.client.network.OldServerPinger; +import net.minecraft.client.resources.I18n; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.lwjgl.input.Keyboard; + +@SideOnly(Side.CLIENT) +public class GuiMultiplayer extends GuiScreen +{ + private static final Logger logger = LogManager.getLogger(); + private final OldServerPinger field_146797_f = new OldServerPinger(); + private GuiScreen field_146798_g; + private ServerSelectionList field_146803_h; + private ServerList field_146804_i; + private GuiButton field_146810_r; + private GuiButton field_146809_s; + private GuiButton field_146808_t; + private boolean field_146807_u; + private boolean field_146806_v; + private boolean field_146805_w; + private boolean field_146813_x; + private String field_146812_y; + private ServerData field_146811_z; + private LanServerDetector.LanServerList field_146799_A; + private LanServerDetector.ThreadLanServerFind field_146800_B; + private boolean field_146801_C; + private static final String __OBFID = "CL_00000814"; + + public GuiMultiplayer(GuiScreen par1GuiScreen) + { + this.field_146798_g = par1GuiScreen; + FMLClientHandler.instance().setupServerList(); + } + + public void initGui() + { + Keyboard.enableRepeatEvents(true); + this.buttonList.clear(); + + if (!this.field_146801_C) + { + this.field_146801_C = true; + this.field_146804_i = new ServerList(this.mc); + this.field_146804_i.loadServerList(); + this.field_146799_A = new LanServerDetector.LanServerList(); + + try + { + this.field_146800_B = new LanServerDetector.ThreadLanServerFind(this.field_146799_A); + this.field_146800_B.start(); + } + catch (Exception exception) + { + logger.warn("Unable to start LAN server detection: " + exception.getMessage()); + } + + this.field_146803_h = new ServerSelectionList(this, this.mc, this.width, this.height, 32, this.height - 64, 36); + this.field_146803_h.func_148195_a(this.field_146804_i); + } + else + { + this.field_146803_h.func_148122_a(this.width, this.height, 32, this.height - 64); + } + + this.func_146794_g(); + } + + public void func_146794_g() + { + this.buttonList.add(this.field_146810_r = new GuiButton(7, this.width / 2 - 154, this.height - 28, 70, 20, I18n.format("selectServer.edit", new Object[0]))); + this.buttonList.add(this.field_146808_t = new GuiButton(2, this.width / 2 - 74, this.height - 28, 70, 20, I18n.format("selectServer.delete", new Object[0]))); + this.buttonList.add(this.field_146809_s = new GuiButton(1, this.width / 2 - 154, this.height - 52, 100, 20, I18n.format("selectServer.select", new Object[0]))); + this.buttonList.add(new GuiButton(4, this.width / 2 - 50, this.height - 52, 100, 20, I18n.format("selectServer.direct", new Object[0]))); + this.buttonList.add(new GuiButton(3, this.width / 2 + 4 + 50, this.height - 52, 100, 20, I18n.format("selectServer.add", new Object[0]))); + this.buttonList.add(new GuiButton(8, this.width / 2 + 4, this.height - 28, 70, 20, I18n.format("selectServer.refresh", new Object[0]))); + this.buttonList.add(new GuiButton(0, this.width / 2 + 4 + 76, this.height - 28, 75, 20, I18n.format("gui.cancel", new Object[0]))); + this.func_146790_a(this.field_146803_h.func_148193_k()); + } + + public void updateScreen() + { + super.updateScreen(); + + if (this.field_146799_A.getWasUpdated()) + { + List list = this.field_146799_A.getLanServers(); + this.field_146799_A.setWasNotUpdated(); + this.field_146803_h.func_148194_a(list); + } + + this.field_146797_f.func_147223_a(); + } + + public void onGuiClosed() + { + Keyboard.enableRepeatEvents(false); + + if (this.field_146800_B != null) + { + this.field_146800_B.interrupt(); + this.field_146800_B = null; + } + + this.field_146797_f.func_147226_b(); + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.enabled) + { + GuiListExtended.IGuiListEntry iguilistentry = this.field_146803_h.func_148193_k() < 0 ? null : this.field_146803_h.getListEntry(this.field_146803_h.func_148193_k()); + + if (p_146284_1_.id == 2 && iguilistentry instanceof ServerListEntryNormal) + { + String s4 = ((ServerListEntryNormal)iguilistentry).func_148296_a().serverName; + + if (s4 != null) + { + this.field_146807_u = true; + String s = I18n.format("selectServer.deleteQuestion", new Object[0]); + String s1 = "\'" + s4 + "\' " + I18n.format("selectServer.deleteWarning", new Object[0]); + String s2 = I18n.format("selectServer.deleteButton", new Object[0]); + String s3 = I18n.format("gui.cancel", new Object[0]); + GuiYesNo guiyesno = new GuiYesNo(this, s, s1, s2, s3, this.field_146803_h.func_148193_k()); + this.mc.displayGuiScreen(guiyesno); + } + } + else if (p_146284_1_.id == 1) + { + this.func_146796_h(); + } + else if (p_146284_1_.id == 4) + { + this.field_146813_x = true; + this.mc.displayGuiScreen(new GuiScreenServerList(this, this.field_146811_z = new ServerData(I18n.format("selectServer.defaultName", new Object[0]), ""))); + } + else if (p_146284_1_.id == 3) + { + this.field_146806_v = true; + this.mc.displayGuiScreen(new GuiScreenAddServer(this, this.field_146811_z = new ServerData(I18n.format("selectServer.defaultName", new Object[0]), ""))); + } + else if (p_146284_1_.id == 7 && iguilistentry instanceof ServerListEntryNormal) + { + this.field_146805_w = true; + ServerData serverdata = ((ServerListEntryNormal)iguilistentry).func_148296_a(); + this.field_146811_z = new ServerData(serverdata.serverName, serverdata.serverIP); + this.field_146811_z.setHideAddress(serverdata.isHidingAddress()); + this.mc.displayGuiScreen(new GuiScreenAddServer(this, this.field_146811_z)); + } + else if (p_146284_1_.id == 0) + { + this.mc.displayGuiScreen(this.field_146798_g); + } + else if (p_146284_1_.id == 8) + { + this.func_146792_q(); + } + } + } + + private void func_146792_q() + { + this.mc.displayGuiScreen(new GuiMultiplayer(this.field_146798_g)); + } + + public void confirmClicked(boolean par1, int par2) + { + GuiListExtended.IGuiListEntry iguilistentry = this.field_146803_h.func_148193_k() < 0 ? null : this.field_146803_h.getListEntry(this.field_146803_h.func_148193_k()); + + if (this.field_146807_u) + { + this.field_146807_u = false; + + if (par1 && iguilistentry instanceof ServerListEntryNormal) + { + this.field_146804_i.removeServerData(this.field_146803_h.func_148193_k()); + this.field_146804_i.saveServerList(); + this.field_146803_h.func_148192_c(-1); + this.field_146803_h.func_148195_a(this.field_146804_i); + } + + this.mc.displayGuiScreen(this); + } + else if (this.field_146813_x) + { + this.field_146813_x = false; + + if (par1) + { + this.func_146791_a(this.field_146811_z); + } + else + { + this.mc.displayGuiScreen(this); + } + } + else if (this.field_146806_v) + { + this.field_146806_v = false; + + if (par1) + { + this.field_146804_i.addServerData(this.field_146811_z); + this.field_146804_i.saveServerList(); + this.field_146803_h.func_148192_c(-1); + this.field_146803_h.func_148195_a(this.field_146804_i); + } + + this.mc.displayGuiScreen(this); + } + else if (this.field_146805_w) + { + this.field_146805_w = false; + + if (par1 && iguilistentry instanceof ServerListEntryNormal) + { + ServerData serverdata = ((ServerListEntryNormal)iguilistentry).func_148296_a(); + serverdata.serverName = this.field_146811_z.serverName; + serverdata.serverIP = this.field_146811_z.serverIP; + serverdata.setHideAddress(this.field_146811_z.isHidingAddress()); + this.field_146804_i.saveServerList(); + this.field_146803_h.func_148195_a(this.field_146804_i); + } + + this.mc.displayGuiScreen(this); + } + } + + protected void keyTyped(char par1, int par2) + { + int j = this.field_146803_h.func_148193_k(); + GuiListExtended.IGuiListEntry iguilistentry = j < 0 ? null : this.field_146803_h.getListEntry(j); + + if (par2 == 63) + { + this.func_146792_q(); + } + else + { + if (j >= 0) + { + if (par2 == 200) + { + if (isShiftKeyDown()) + { + if (j > 0 && iguilistentry instanceof ServerListEntryNormal) + { + this.field_146804_i.swapServers(j, j - 1); + this.func_146790_a(this.field_146803_h.func_148193_k() - 1); + this.field_146803_h.scrollBy(-this.field_146803_h.getSlotHeight()); + this.field_146803_h.func_148195_a(this.field_146804_i); + } + } + else if (j > 0) + { + this.func_146790_a(this.field_146803_h.func_148193_k() - 1); + this.field_146803_h.scrollBy(-this.field_146803_h.getSlotHeight()); + + if (this.field_146803_h.getListEntry(this.field_146803_h.func_148193_k()) instanceof ServerListEntryLanScan) + { + if (this.field_146803_h.func_148193_k() > 0) + { + this.func_146790_a(this.field_146803_h.getSize() - 1); + this.field_146803_h.scrollBy(-this.field_146803_h.getSlotHeight()); + } + else + { + this.func_146790_a(-1); + } + } + } + else + { + this.func_146790_a(-1); + } + } + else if (par2 == 208) + { + if (isShiftKeyDown()) + { + if (j < this.field_146804_i.countServers() - 1) + { + this.field_146804_i.swapServers(j, j + 1); + this.func_146790_a(j + 1); + this.field_146803_h.scrollBy(this.field_146803_h.getSlotHeight()); + this.field_146803_h.func_148195_a(this.field_146804_i); + } + } + else if (j < this.field_146803_h.getSize()) + { + this.func_146790_a(this.field_146803_h.func_148193_k() + 1); + this.field_146803_h.scrollBy(this.field_146803_h.getSlotHeight()); + + if (this.field_146803_h.getListEntry(this.field_146803_h.func_148193_k()) instanceof ServerListEntryLanScan) + { + if (this.field_146803_h.func_148193_k() < this.field_146803_h.getSize() - 1) + { + this.func_146790_a(this.field_146803_h.getSize() + 1); + this.field_146803_h.scrollBy(this.field_146803_h.getSlotHeight()); + } + else + { + this.func_146790_a(-1); + } + } + } + else + { + this.func_146790_a(-1); + } + } + else if (par2 != 28 && par2 != 156) + { + super.keyTyped(par1, par2); + } + else + { + this.actionPerformed((GuiButton)this.buttonList.get(2)); + } + } + else + { + super.keyTyped(par1, par2); + } + } + } + + public void drawScreen(int par1, int par2, float par3) + { + this.field_146812_y = null; + this.drawDefaultBackground(); + this.field_146803_h.drawScreen(par1, par2, par3); + this.drawCenteredString(this.fontRendererObj, I18n.format("multiplayer.title", new Object[0]), this.width / 2, 20, 16777215); + super.drawScreen(par1, par2, par3); + + if (this.field_146812_y != null) + { + this.func_146283_a(Lists.newArrayList(Splitter.on("\n").split(this.field_146812_y)), par1, par2); + } + } + + public void func_146796_h() + { + GuiListExtended.IGuiListEntry iguilistentry = this.field_146803_h.func_148193_k() < 0 ? null : this.field_146803_h.getListEntry(this.field_146803_h.func_148193_k()); + + if (iguilistentry instanceof ServerListEntryNormal) + { + this.func_146791_a(((ServerListEntryNormal)iguilistentry).func_148296_a()); + } + else if (iguilistentry instanceof ServerListEntryLanDetected) + { + LanServerDetector.LanServer lanserver = ((ServerListEntryLanDetected)iguilistentry).func_148289_a(); + this.func_146791_a(new ServerData(lanserver.getServerMotd(), lanserver.getServerIpPort())); + } + } + + private void func_146791_a(ServerData p_146791_1_) + { + FMLClientHandler.instance().connectToServer(this, p_146791_1_); + } + + public void func_146790_a(int p_146790_1_) + { + this.field_146803_h.func_148192_c(p_146790_1_); + GuiListExtended.IGuiListEntry iguilistentry = p_146790_1_ < 0 ? null : this.field_146803_h.getListEntry(p_146790_1_); + this.field_146809_s.enabled = false; + this.field_146810_r.enabled = false; + this.field_146808_t.enabled = false; + + if (iguilistentry != null && !(iguilistentry instanceof ServerListEntryLanScan)) + { + this.field_146809_s.enabled = true; + + if (iguilistentry instanceof ServerListEntryNormal) + { + this.field_146810_r.enabled = true; + this.field_146808_t.enabled = true; + } + } + } + + public OldServerPinger func_146789_i() + { + return this.field_146797_f; + } + + public void func_146793_a(String p_146793_1_) + { + this.field_146812_y = p_146793_1_; + } + + protected void mouseClicked(int par1, int par2, int par3) + { + super.mouseClicked(par1, par2, par3); + this.field_146803_h.func_148179_a(par1, par2, par3); + } + + protected void mouseMovedOrUp(int p_146286_1_, int p_146286_2_, int p_146286_3_) + { + super.mouseMovedOrUp(p_146286_1_, p_146286_2_, p_146286_3_); + this.field_146803_h.func_148181_b(p_146286_1_, p_146286_2_, p_146286_3_); + } + + public ServerList func_146795_p() + { + return this.field_146804_i; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiNewChat.java b/src/main/java/net/minecraft/client/gui/GuiNewChat.java new file mode 100644 index 0000000..631634f --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiNewChat.java @@ -0,0 +1,432 @@ +package net.minecraft.client.gui; + +import com.google.common.collect.Lists; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IChatComponent; +import net.minecraft.util.MathHelper; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class GuiNewChat extends Gui +{ + private static final Logger logger = LogManager.getLogger(); + private final Minecraft mc; + private final List sentMessages = new ArrayList(); + private final List chatLines = new ArrayList(); + private final List field_146253_i = new ArrayList(); + private int field_146250_j; + private boolean field_146251_k; + private static final String __OBFID = "CL_00000669"; + + public GuiNewChat(Minecraft par1Minecraft) + { + this.mc = par1Minecraft; + } + + public void drawChat(int p_146230_1_) + { + if (this.mc.gameSettings.chatVisibility != EntityPlayer.EnumChatVisibility.HIDDEN) + { + int j = this.func_146232_i(); + boolean flag = false; + int k = 0; + int l = this.field_146253_i.size(); + float f = this.mc.gameSettings.chatOpacity * 0.9F + 0.1F; + + if (l > 0) + { + if (this.getChatOpen()) + { + flag = true; + } + + float f1 = this.func_146244_h(); + int i1 = MathHelper.ceiling_float_int((float)this.func_146228_f() / f1); + GL11.glPushMatrix(); + GL11.glTranslatef(2.0F, 20.0F, 0.0F); + GL11.glScalef(f1, f1, 1.0F); + int j1; + int k1; + int i2; + + for (j1 = 0; j1 + this.field_146250_j < this.field_146253_i.size() && j1 < j; ++j1) + { + ChatLine chatline = (ChatLine)this.field_146253_i.get(j1 + this.field_146250_j); + + if (chatline != null) + { + k1 = p_146230_1_ - chatline.getUpdatedCounter(); + + if (k1 < 200 || flag) + { + double d0 = (double)k1 / 200.0D; + d0 = 1.0D - d0; + d0 *= 10.0D; + + if (d0 < 0.0D) + { + d0 = 0.0D; + } + + if (d0 > 1.0D) + { + d0 = 1.0D; + } + + d0 *= d0; + i2 = (int)(255.0D * d0); + + if (flag) + { + i2 = 255; + } + + i2 = (int)((float)i2 * f); + ++k; + + if (i2 > 3) + { + byte b0 = 0; + int j2 = -j1 * 9; + drawRect(b0, j2 - 9, b0 + i1 + 4, j2, i2 / 2 << 24); + String s = chatline.func_151461_a().getFormattedText(); + this.mc.fontRenderer.drawStringWithShadow(s, b0, j2 - 8, 16777215 + (i2 << 24)); + GL11.glDisable(GL11.GL_ALPHA_TEST); + } + } + } + } + + if (flag) + { + j1 = this.mc.fontRenderer.FONT_HEIGHT; + GL11.glTranslatef(-3.0F, 0.0F, 0.0F); + int k2 = l * j1 + l; + k1 = k * j1 + k; + int l2 = this.field_146250_j * k1 / l; + int l1 = k1 * k1 / k2; + + if (k2 != k1) + { + i2 = l2 > 0 ? 170 : 96; + int i3 = this.field_146251_k ? 13382451 : 3355562; + drawRect(0, -l2, 2, -l2 - l1, i3 + (i2 << 24)); + drawRect(2, -l2, 1, -l2 - l1, 13421772 + (i2 << 24)); + } + } + + GL11.glPopMatrix(); + } + } + } + + public void clearChatMessages() + { + this.field_146253_i.clear(); + this.chatLines.clear(); + this.sentMessages.clear(); + } + + public void printChatMessage(IChatComponent p_146227_1_) + { + this.printChatMessageWithOptionalDeletion(p_146227_1_, 0); + } + + public void printChatMessageWithOptionalDeletion(IChatComponent p_146234_1_, int p_146234_2_) + { + this.func_146237_a(p_146234_1_, p_146234_2_, this.mc.ingameGUI.getUpdateCounter(), false); + logger.info("[CHAT] " + p_146234_1_.getUnformattedText()); + } + + private String func_146235_b(String p_146235_1_) + { + return Minecraft.getMinecraft().gameSettings.chatColours ? p_146235_1_ : EnumChatFormatting.getTextWithoutFormattingCodes(p_146235_1_); + } + + private void func_146237_a(IChatComponent p_146237_1_, int p_146237_2_, int p_146237_3_, boolean p_146237_4_) + { + if (p_146237_2_ != 0) + { + this.deleteChatLine(p_146237_2_); + } + + int k = MathHelper.floor_float((float)this.func_146228_f() / this.func_146244_h()); + int l = 0; + ChatComponentText chatcomponenttext = new ChatComponentText(""); + ArrayList arraylist = Lists.newArrayList(); + ArrayList arraylist1 = Lists.newArrayList(p_146237_1_); + + for (int i1 = 0; i1 < arraylist1.size(); ++i1) + { + IChatComponent ichatcomponent1 = (IChatComponent)arraylist1.get(i1); + String s = this.func_146235_b(ichatcomponent1.getChatStyle().getFormattingCode() + ichatcomponent1.getUnformattedTextForChat()); + int j1 = this.mc.fontRenderer.getStringWidth(s); + ChatComponentText chatcomponenttext1 = new ChatComponentText(s); + chatcomponenttext1.setChatStyle(ichatcomponent1.getChatStyle().createShallowCopy()); + boolean flag1 = false; + + if (l + j1 > k) + { + String s1 = this.mc.fontRenderer.trimStringToWidth(s, k - l, false); + String s2 = s1.length() < s.length() ? s.substring(s1.length()) : null; + + if (s2 != null && s2.length() > 0) + { + int k1 = s1.lastIndexOf(" "); + + if (k1 >= 0 && this.mc.fontRenderer.getStringWidth(s.substring(0, k1)) > 0) + { + s1 = s.substring(0, k1); + s2 = s.substring(k1); + } + + ChatComponentText chatcomponenttext2 = new ChatComponentText(s2); + chatcomponenttext2.setChatStyle(ichatcomponent1.getChatStyle().createShallowCopy()); + arraylist1.add(i1 + 1, chatcomponenttext2); + } + + j1 = this.mc.fontRenderer.getStringWidth(s1); + chatcomponenttext1 = new ChatComponentText(s1); + chatcomponenttext1.setChatStyle(ichatcomponent1.getChatStyle().createShallowCopy()); + flag1 = true; + } + + if (l + j1 <= k) + { + l += j1; + chatcomponenttext.appendSibling(chatcomponenttext1); + } + else + { + flag1 = true; + } + + if (flag1) + { + arraylist.add(chatcomponenttext); + l = 0; + chatcomponenttext = new ChatComponentText(""); + } + } + + arraylist.add(chatcomponenttext); + boolean flag2 = this.getChatOpen(); + IChatComponent ichatcomponent2; + + for (Iterator iterator = arraylist.iterator(); iterator.hasNext(); this.field_146253_i.add(0, new ChatLine(p_146237_3_, ichatcomponent2, p_146237_2_))) + { + ichatcomponent2 = (IChatComponent)iterator.next(); + + if (flag2 && this.field_146250_j > 0) + { + this.field_146251_k = true; + this.scroll(1); + } + } + + while (this.field_146253_i.size() > 100) + { + this.field_146253_i.remove(this.field_146253_i.size() - 1); + } + + if (!p_146237_4_) + { + this.chatLines.add(0, new ChatLine(p_146237_3_, p_146237_1_, p_146237_2_)); + + while (this.chatLines.size() > 100) + { + this.chatLines.remove(this.chatLines.size() - 1); + } + } + } + + public void refreshChat() + { + this.field_146253_i.clear(); + this.resetScroll(); + + for (int i = this.chatLines.size() - 1; i >= 0; --i) + { + ChatLine chatline = (ChatLine)this.chatLines.get(i); + this.func_146237_a(chatline.func_151461_a(), chatline.getChatLineID(), chatline.getUpdatedCounter(), true); + } + } + + public List getSentMessages() + { + return this.sentMessages; + } + + public void addToSentMessages(String p_146239_1_) + { + if (this.sentMessages.isEmpty() || !((String)this.sentMessages.get(this.sentMessages.size() - 1)).equals(p_146239_1_)) + { + this.sentMessages.add(p_146239_1_); + } + } + + public void resetScroll() + { + this.field_146250_j = 0; + this.field_146251_k = false; + } + + public void scroll(int p_146229_1_) + { + this.field_146250_j += p_146229_1_; + int j = this.field_146253_i.size(); + + if (this.field_146250_j > j - this.func_146232_i()) + { + this.field_146250_j = j - this.func_146232_i(); + } + + if (this.field_146250_j <= 0) + { + this.field_146250_j = 0; + this.field_146251_k = false; + } + } + + public IChatComponent func_146236_a(int p_146236_1_, int p_146236_2_) + { + if (!this.getChatOpen()) + { + return null; + } + else + { + ScaledResolution scaledresolution = new ScaledResolution(this.mc.gameSettings, this.mc.displayWidth, this.mc.displayHeight); + int k = scaledresolution.getScaleFactor(); + float f = this.func_146244_h(); + int l = p_146236_1_ / k - 3; + int i1 = p_146236_2_ / k - 27; + l = MathHelper.floor_float((float)l / f); + i1 = MathHelper.floor_float((float)i1 / f); + + if (l >= 0 && i1 >= 0) + { + int j1 = Math.min(this.func_146232_i(), this.field_146253_i.size()); + + if (l <= MathHelper.floor_float((float)this.func_146228_f() / this.func_146244_h()) && i1 < this.mc.fontRenderer.FONT_HEIGHT * j1 + j1) + { + int k1 = i1 / this.mc.fontRenderer.FONT_HEIGHT + this.field_146250_j; + + if (k1 >= 0 && k1 < this.field_146253_i.size()) + { + ChatLine chatline = (ChatLine)this.field_146253_i.get(k1); + int l1 = 0; + Iterator iterator = chatline.func_151461_a().iterator(); + + while (iterator.hasNext()) + { + IChatComponent ichatcomponent = (IChatComponent)iterator.next(); + + if (ichatcomponent instanceof ChatComponentText) + { + l1 += this.mc.fontRenderer.getStringWidth(this.func_146235_b(((ChatComponentText)ichatcomponent).getChatComponentText_TextValue())); + + if (l1 > l) + { + return ichatcomponent; + } + } + } + } + + return null; + } + else + { + return null; + } + } + else + { + return null; + } + } + } + + public boolean getChatOpen() + { + return this.mc.currentScreen instanceof GuiChat; + } + + public void deleteChatLine(int p_146242_1_) + { + Iterator iterator = this.field_146253_i.iterator(); + ChatLine chatline; + + do + { + if (!iterator.hasNext()) + { + iterator = this.chatLines.iterator(); + + do + { + if (!iterator.hasNext()) + { + return; + } + + chatline = (ChatLine)iterator.next(); + } + while (chatline.getChatLineID() != p_146242_1_); + + iterator.remove(); + return; + } + + chatline = (ChatLine)iterator.next(); + } + while (chatline.getChatLineID() != p_146242_1_); + + iterator.remove(); + } + + public int func_146228_f() + { + return func_146233_a(this.mc.gameSettings.chatWidth); + } + + public int func_146246_g() + { + return func_146243_b(this.getChatOpen() ? this.mc.gameSettings.chatHeightFocused : this.mc.gameSettings.chatHeightUnfocused); + } + + public float func_146244_h() + { + return this.mc.gameSettings.chatScale; + } + + public static int func_146233_a(float p_146233_0_) + { + short short1 = 320; + byte b0 = 40; + return MathHelper.floor_float(p_146233_0_ * (float)(short1 - b0) + (float)b0); + } + + public static int func_146243_b(float p_146243_0_) + { + short short1 = 180; + byte b0 = 20; + return MathHelper.floor_float(p_146243_0_ * (float)(short1 - b0) + (float)b0); + } + + public int func_146232_i() + { + return this.func_146246_g() / 9; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiOptionButton.java b/src/main/java/net/minecraft/client/gui/GuiOptionButton.java new file mode 100644 index 0000000..059b39a --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiOptionButton.java @@ -0,0 +1,34 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.settings.GameSettings; + +@SideOnly(Side.CLIENT) +public class GuiOptionButton extends GuiButton +{ + private final GameSettings.Options enumOptions; + private static final String __OBFID = "CL_00000676"; + + public GuiOptionButton(int p_i45011_1_, int p_i45011_2_, int p_i45011_3_, String p_i45011_4_) + { + this(p_i45011_1_, p_i45011_2_, p_i45011_3_, (GameSettings.Options)null, p_i45011_4_); + } + + public GuiOptionButton(int p_i45012_1_, int p_i45012_2_, int p_i45012_3_, int p_i45012_4_, int p_i45012_5_, String p_i45012_6_) + { + super(p_i45012_1_, p_i45012_2_, p_i45012_3_, p_i45012_4_, p_i45012_5_, p_i45012_6_); + this.enumOptions = null; + } + + public GuiOptionButton(int p_i45013_1_, int p_i45013_2_, int p_i45013_3_, GameSettings.Options p_i45013_4_, String p_i45013_5_) + { + super(p_i45013_1_, p_i45013_2_, p_i45013_3_, 150, 20, p_i45013_5_); + this.enumOptions = p_i45013_4_; + } + + public GameSettings.Options returnEnumOptions() + { + return this.enumOptions; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiOptionSlider.java b/src/main/java/net/minecraft/client/gui/GuiOptionSlider.java new file mode 100644 index 0000000..2c4140c --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiOptionSlider.java @@ -0,0 +1,102 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.Minecraft; +import net.minecraft.client.settings.GameSettings; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class GuiOptionSlider extends GuiButton +{ + private float field_146134_p; + public boolean field_146135_o; + private GameSettings.Options field_146133_q; + private final float field_146132_r; + private final float field_146131_s; + private static final String __OBFID = "CL_00000680"; + + public GuiOptionSlider(int p_i45016_1_, int p_i45016_2_, int p_i45016_3_, GameSettings.Options p_i45016_4_) + { + this(p_i45016_1_, p_i45016_2_, p_i45016_3_, p_i45016_4_, 0.0F, 1.0F); + } + + public GuiOptionSlider(int p_i45017_1_, int p_i45017_2_, int p_i45017_3_, GameSettings.Options p_i45017_4_, float p_i45017_5_, float p_i45017_6_) + { + super(p_i45017_1_, p_i45017_2_, p_i45017_3_, 150, 20, ""); + this.field_146134_p = 1.0F; + this.field_146133_q = p_i45017_4_; + this.field_146132_r = p_i45017_5_; + this.field_146131_s = p_i45017_6_; + Minecraft minecraft = Minecraft.getMinecraft(); + this.field_146134_p = p_i45017_4_.normalizeValue(minecraft.gameSettings.getOptionFloatValue(p_i45017_4_)); + this.displayString = minecraft.gameSettings.getKeyBinding(p_i45017_4_); + } + + protected int getHoverState(boolean p_146114_1_) + { + return 0; + } + + protected void mouseDragged(Minecraft p_146119_1_, int p_146119_2_, int p_146119_3_) + { + if (this.visible) + { + if (this.field_146135_o) + { + this.field_146134_p = (float)(p_146119_2_ - (this.xPosition + 4)) / (float)(this.width - 8); + + if (this.field_146134_p < 0.0F) + { + this.field_146134_p = 0.0F; + } + + if (this.field_146134_p > 1.0F) + { + this.field_146134_p = 1.0F; + } + + float f = this.field_146133_q.denormalizeValue(this.field_146134_p); + p_146119_1_.gameSettings.setOptionFloatValue(this.field_146133_q, f); + this.field_146134_p = this.field_146133_q.normalizeValue(f); + this.displayString = p_146119_1_.gameSettings.getKeyBinding(this.field_146133_q); + } + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.drawTexturedModalRect(this.xPosition + (int)(this.field_146134_p * (float)(this.width - 8)), this.yPosition, 0, 66, 4, 20); + this.drawTexturedModalRect(this.xPosition + (int)(this.field_146134_p * (float)(this.width - 8)) + 4, this.yPosition, 196, 66, 4, 20); + } + } + + public boolean mousePressed(Minecraft p_146116_1_, int p_146116_2_, int p_146116_3_) + { + if (super.mousePressed(p_146116_1_, p_146116_2_, p_146116_3_)) + { + this.field_146134_p = (float)(p_146116_2_ - (this.xPosition + 4)) / (float)(this.width - 8); + + if (this.field_146134_p < 0.0F) + { + this.field_146134_p = 0.0F; + } + + if (this.field_146134_p > 1.0F) + { + this.field_146134_p = 1.0F; + } + + p_146116_1_.gameSettings.setOptionFloatValue(this.field_146133_q, this.field_146133_q.denormalizeValue(this.field_146134_p)); + this.displayString = p_146116_1_.gameSettings.getKeyBinding(this.field_146133_q); + this.field_146135_o = true; + return true; + } + else + { + return false; + } + } + + public void mouseReleased(int p_146118_1_, int p_146118_2_) + { + this.field_146135_o = false; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiOptions.java b/src/main/java/net/minecraft/client/gui/GuiOptions.java new file mode 100644 index 0000000..16307a7 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiOptions.java @@ -0,0 +1,152 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.audio.PositionedSoundRecord; +import net.minecraft.client.audio.SoundCategory; +import net.minecraft.client.audio.SoundEventAccessorComposite; +import net.minecraft.client.audio.SoundHandler; +import net.minecraft.client.resources.I18n; +import net.minecraft.client.settings.GameSettings; + +@SideOnly(Side.CLIENT) +public class GuiOptions extends GuiScreen +{ + private static final GameSettings.Options[] field_146440_f = new GameSettings.Options[] {GameSettings.Options.FOV, GameSettings.Options.DIFFICULTY}; + private final GuiScreen field_146441_g; + private final GameSettings field_146443_h; + protected String field_146442_a = "Options"; + private static final String __OBFID = "CL_00000700"; + + public GuiOptions(GuiScreen par1GuiScreen, GameSettings par2GameSettings) + { + this.field_146441_g = par1GuiScreen; + this.field_146443_h = par2GameSettings; + } + + public void initGui() + { + int i = 0; + this.field_146442_a = I18n.format("options.title", new Object[0]); + GameSettings.Options[] aoptions = field_146440_f; + int j = aoptions.length; + + for (int k = 0; k < j; ++k) + { + GameSettings.Options options = aoptions[k]; + + if (options.getEnumFloat()) + { + this.buttonList.add(new GuiOptionSlider(options.returnEnumOrdinal(), this.width / 2 - 155 + i % 2 * 160, this.height / 6 - 12 + 24 * (i >> 1), options)); + } + else + { + GuiOptionButton guioptionbutton = new GuiOptionButton(options.returnEnumOrdinal(), this.width / 2 - 155 + i % 2 * 160, this.height / 6 - 12 + 24 * (i >> 1), options, this.field_146443_h.getKeyBinding(options)); + + if (options == GameSettings.Options.DIFFICULTY && this.mc.theWorld != null && this.mc.theWorld.getWorldInfo().isHardcoreModeEnabled()) + { + guioptionbutton.enabled = false; + guioptionbutton.displayString = I18n.format("options.difficulty", new Object[0]) + ": " + I18n.format("options.difficulty.hardcore", new Object[0]); + } + + this.buttonList.add(guioptionbutton); + } + + ++i; + } + + this.buttonList.add(new GuiButton(106, this.width / 2 - 152, this.height / 6 + 72 - 6, 150, 20, I18n.format("options.sounds", new Object[0]))); + this.buttonList.add(new GuiButton(8675309, this.width / 2 + 2, this.height / 6 + 72 - 6, 150, 20, "Super Secret Settings...") + { + private static final String __OBFID = "CL_00000701"; + public void func_146113_a(SoundHandler p_146113_1_) + { + SoundEventAccessorComposite soundeventaccessorcomposite = p_146113_1_.getRandomSoundFromCategories(new SoundCategory[] {SoundCategory.ANIMALS, SoundCategory.BLOCKS, SoundCategory.MOBS, SoundCategory.PLAYERS, SoundCategory.WEATHER}); + + if (soundeventaccessorcomposite != null) + { + p_146113_1_.playSound(PositionedSoundRecord.func_147674_a(soundeventaccessorcomposite.getSoundEventLocation(), 0.5F)); + } + } + }); + this.buttonList.add(new GuiButton(101, this.width / 2 - 152, this.height / 6 + 96 - 6, 150, 20, I18n.format("options.video", new Object[0]))); + this.buttonList.add(new GuiButton(100, this.width / 2 + 2, this.height / 6 + 96 - 6, 150, 20, I18n.format("options.controls", new Object[0]))); + this.buttonList.add(new GuiButton(102, this.width / 2 - 152, this.height / 6 + 120 - 6, 150, 20, I18n.format("options.language", new Object[0]))); + this.buttonList.add(new GuiButton(103, this.width / 2 + 2, this.height / 6 + 120 - 6, 150, 20, I18n.format("options.multiplayer.title", new Object[0]))); + this.buttonList.add(new GuiButton(105, this.width / 2 - 152, this.height / 6 + 144 - 6, 150, 20, I18n.format("options.resourcepack", new Object[0]))); + this.buttonList.add(new GuiButton(104, this.width / 2 + 2, this.height / 6 + 144 - 6, 150, 20, I18n.format("options.snooper.view", new Object[0]))); + this.buttonList.add(new GuiButton(200, this.width / 2 - 100, this.height / 6 + 168, I18n.format("gui.done", new Object[0]))); + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.enabled) + { + if (p_146284_1_.id < 100 && p_146284_1_ instanceof GuiOptionButton) + { + this.field_146443_h.setOptionValue(((GuiOptionButton)p_146284_1_).returnEnumOptions(), 1); + p_146284_1_.displayString = this.field_146443_h.getKeyBinding(GameSettings.Options.getEnumOptions(p_146284_1_.id)); + } + + if (p_146284_1_.id == 8675309) + { + this.mc.entityRenderer.activateNextShader(); + } + + if (p_146284_1_.id == 101) + { + this.mc.gameSettings.saveOptions(); + this.mc.displayGuiScreen(new GuiVideoSettings(this, this.field_146443_h)); + } + + if (p_146284_1_.id == 100) + { + this.mc.gameSettings.saveOptions(); + this.mc.displayGuiScreen(new GuiControls(this, this.field_146443_h)); + } + + if (p_146284_1_.id == 102) + { + this.mc.gameSettings.saveOptions(); + this.mc.displayGuiScreen(new GuiLanguage(this, this.field_146443_h, this.mc.getLanguageManager())); + } + + if (p_146284_1_.id == 103) + { + this.mc.gameSettings.saveOptions(); + this.mc.displayGuiScreen(new ScreenChatOptions(this, this.field_146443_h)); + } + + if (p_146284_1_.id == 104) + { + this.mc.gameSettings.saveOptions(); + this.mc.displayGuiScreen(new GuiSnooper(this, this.field_146443_h)); + } + + if (p_146284_1_.id == 200) + { + this.mc.gameSettings.saveOptions(); + this.mc.displayGuiScreen(this.field_146441_g); + } + + if (p_146284_1_.id == 105) + { + this.mc.gameSettings.saveOptions(); + this.mc.displayGuiScreen(new GuiScreenResourcePacks(this)); + } + + if (p_146284_1_.id == 106) + { + this.mc.gameSettings.saveOptions(); + this.mc.displayGuiScreen(new GuiScreenOptionsSounds(this, this.field_146443_h)); + } + } + } + + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + this.drawCenteredString(this.fontRendererObj, this.field_146442_a, this.width / 2, 15, 16777215); + super.drawScreen(par1, par2, par3); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiOptionsRowList.java b/src/main/java/net/minecraft/client/gui/GuiOptionsRowList.java new file mode 100644 index 0000000..b56231e --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiOptionsRowList.java @@ -0,0 +1,135 @@ +package net.minecraft.client.gui; + +import com.google.common.collect.Lists; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.settings.GameSettings; + +@SideOnly(Side.CLIENT) +public class GuiOptionsRowList extends GuiListExtended +{ + private final List field_148184_k = Lists.newArrayList(); + private static final String __OBFID = "CL_00000677"; + + public GuiOptionsRowList(Minecraft p_i45015_1_, int p_i45015_2_, int p_i45015_3_, int p_i45015_4_, int p_i45015_5_, int p_i45015_6_, GameSettings.Options ... p_i45015_7_) + { + super(p_i45015_1_, p_i45015_2_, p_i45015_3_, p_i45015_4_, p_i45015_5_, p_i45015_6_); + this.field_148163_i = false; + + for (int j1 = 0; j1 < p_i45015_7_.length; j1 += 2) + { + GameSettings.Options options = p_i45015_7_[j1]; + GameSettings.Options options1 = j1 < p_i45015_7_.length - 1 ? p_i45015_7_[j1 + 1] : null; + GuiButton guibutton = this.func_148182_a(p_i45015_1_, p_i45015_2_ / 2 - 155, 0, options); + GuiButton guibutton1 = this.func_148182_a(p_i45015_1_, p_i45015_2_ / 2 - 155 + 160, 0, options1); + this.field_148184_k.add(new GuiOptionsRowList.Row(guibutton, guibutton1)); + } + } + + private GuiButton func_148182_a(Minecraft p_148182_1_, int p_148182_2_, int p_148182_3_, GameSettings.Options p_148182_4_) + { + if (p_148182_4_ == null) + { + return null; + } + else + { + int k = p_148182_4_.returnEnumOrdinal(); + return (GuiButton)(p_148182_4_.getEnumFloat() ? new GuiOptionSlider(k, p_148182_2_, p_148182_3_, p_148182_4_) : new GuiOptionButton(k, p_148182_2_, p_148182_3_, p_148182_4_, p_148182_1_.gameSettings.getKeyBinding(p_148182_4_))); + } + } + + public GuiOptionsRowList.Row getListEntry(int p_148183_1_) + { + return (GuiOptionsRowList.Row)this.field_148184_k.get(p_148183_1_); + } + + protected int getSize() + { + return this.field_148184_k.size(); + } + + public int getListWidth() + { + return 400; + } + + protected int getScrollBarX() + { + return super.getScrollBarX() + 32; + } + + @SideOnly(Side.CLIENT) + public static class Row implements GuiListExtended.IGuiListEntry + { + private final Minecraft field_148325_a = Minecraft.getMinecraft(); + private final GuiButton field_148323_b; + private final GuiButton field_148324_c; + private static final String __OBFID = "CL_00000678"; + + public Row(GuiButton p_i45014_1_, GuiButton p_i45014_2_) + { + this.field_148323_b = p_i45014_1_; + this.field_148324_c = p_i45014_2_; + } + + public void drawEntry(int p_148279_1_, int p_148279_2_, int p_148279_3_, int p_148279_4_, int p_148279_5_, Tessellator p_148279_6_, int p_148279_7_, int p_148279_8_, boolean p_148279_9_) + { + if (this.field_148323_b != null) + { + this.field_148323_b.yPosition = p_148279_3_; + this.field_148323_b.drawButton(this.field_148325_a, p_148279_7_, p_148279_8_); + } + + if (this.field_148324_c != null) + { + this.field_148324_c.yPosition = p_148279_3_; + this.field_148324_c.drawButton(this.field_148325_a, p_148279_7_, p_148279_8_); + } + } + + public boolean mousePressed(int p_148278_1_, int p_148278_2_, int p_148278_3_, int p_148278_4_, int p_148278_5_, int p_148278_6_) + { + if (this.field_148323_b.mousePressed(this.field_148325_a, p_148278_2_, p_148278_3_)) + { + if (this.field_148323_b instanceof GuiOptionButton) + { + this.field_148325_a.gameSettings.setOptionValue(((GuiOptionButton)this.field_148323_b).returnEnumOptions(), 1); + this.field_148323_b.displayString = this.field_148325_a.gameSettings.getKeyBinding(GameSettings.Options.getEnumOptions(this.field_148323_b.id)); + } + + return true; + } + else if (this.field_148324_c != null && this.field_148324_c.mousePressed(this.field_148325_a, p_148278_2_, p_148278_3_)) + { + if (this.field_148324_c instanceof GuiOptionButton) + { + this.field_148325_a.gameSettings.setOptionValue(((GuiOptionButton)this.field_148324_c).returnEnumOptions(), 1); + this.field_148324_c.displayString = this.field_148325_a.gameSettings.getKeyBinding(GameSettings.Options.getEnumOptions(this.field_148324_c.id)); + } + + return true; + } + else + { + return false; + } + } + + public void mouseReleased(int p_148277_1_, int p_148277_2_, int p_148277_3_, int p_148277_4_, int p_148277_5_, int p_148277_6_) + { + if (this.field_148323_b != null) + { + this.field_148323_b.mouseReleased(p_148277_2_, p_148277_3_); + } + + if (this.field_148324_c != null) + { + this.field_148324_c.mouseReleased(p_148277_2_, p_148277_3_); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiPlayerInfo.java b/src/main/java/net/minecraft/client/gui/GuiPlayerInfo.java new file mode 100644 index 0000000..337f71e --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiPlayerInfo.java @@ -0,0 +1,19 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class GuiPlayerInfo +{ + public final String name; + private final String nameinLowerCase; + public int responseTime; + private static final String __OBFID = "CL_00000888"; + + public GuiPlayerInfo(String par1Str) + { + this.name = par1Str; + this.nameinLowerCase = par1Str.toLowerCase(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiRenameWorld.java b/src/main/java/net/minecraft/client/gui/GuiRenameWorld.java new file mode 100644 index 0000000..df6c659 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiRenameWorld.java @@ -0,0 +1,90 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.resources.I18n; +import net.minecraft.world.storage.ISaveFormat; +import net.minecraft.world.storage.WorldInfo; +import org.lwjgl.input.Keyboard; + +@SideOnly(Side.CLIENT) +public class GuiRenameWorld extends GuiScreen +{ + private GuiScreen field_146585_a; + private GuiTextField field_146583_f; + private final String field_146584_g; + private static final String __OBFID = "CL_00000709"; + + public GuiRenameWorld(GuiScreen par1GuiScreen, String par2Str) + { + this.field_146585_a = par1GuiScreen; + this.field_146584_g = par2Str; + } + + public void updateScreen() + { + this.field_146583_f.updateCursorCounter(); + } + + public void initGui() + { + Keyboard.enableRepeatEvents(true); + this.buttonList.clear(); + this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 96 + 12, I18n.format("selectWorld.renameButton", new Object[0]))); + this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 120 + 12, I18n.format("gui.cancel", new Object[0]))); + ISaveFormat isaveformat = this.mc.getSaveLoader(); + WorldInfo worldinfo = isaveformat.getWorldInfo(this.field_146584_g); + String s = worldinfo.getWorldName(); + this.field_146583_f = new GuiTextField(this.fontRendererObj, this.width / 2 - 100, 60, 200, 20); + this.field_146583_f.setFocused(true); + this.field_146583_f.setText(s); + } + + public void onGuiClosed() + { + Keyboard.enableRepeatEvents(false); + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.enabled) + { + if (p_146284_1_.id == 1) + { + this.mc.displayGuiScreen(this.field_146585_a); + } + else if (p_146284_1_.id == 0) + { + ISaveFormat isaveformat = this.mc.getSaveLoader(); + isaveformat.renameWorld(this.field_146584_g, this.field_146583_f.getText().trim()); + this.mc.displayGuiScreen(this.field_146585_a); + } + } + } + + protected void keyTyped(char par1, int par2) + { + this.field_146583_f.textboxKeyTyped(par1, par2); + ((GuiButton)this.buttonList.get(0)).enabled = this.field_146583_f.getText().trim().length() > 0; + + if (par2 == 28 || par2 == 156) + { + this.actionPerformed((GuiButton)this.buttonList.get(0)); + } + } + + protected void mouseClicked(int par1, int par2, int par3) + { + super.mouseClicked(par1, par2, par3); + this.field_146583_f.mouseClicked(par1, par2, par3); + } + + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + this.drawCenteredString(this.fontRendererObj, I18n.format("selectWorld.renameTitle", new Object[0]), this.width / 2, 20, 16777215); + this.drawString(this.fontRendererObj, I18n.format("selectWorld.enterName", new Object[0]), this.width / 2 - 100, 47, 10526880); + this.field_146583_f.drawTextBox(); + super.drawScreen(par1, par2, par3); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiRepair.java b/src/main/java/net/minecraft/client/gui/GuiRepair.java new file mode 100644 index 0000000..924d50e --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiRepair.java @@ -0,0 +1,186 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ContainerRepair; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.network.play.client.C17PacketCustomPayload; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; +import org.apache.commons.io.Charsets; +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class GuiRepair extends GuiContainer implements ICrafting +{ + private static final ResourceLocation field_147093_u = new ResourceLocation("textures/gui/container/anvil.png"); + private ContainerRepair field_147092_v; + private GuiTextField field_147091_w; + private InventoryPlayer field_147094_x; + private static final String __OBFID = "CL_00000738"; + + public GuiRepair(InventoryPlayer par1InventoryPlayer, World par2World, int par3, int par4, int par5) + { + super(new ContainerRepair(par1InventoryPlayer, par2World, par3, par4, par5, Minecraft.getMinecraft().thePlayer)); + this.field_147094_x = par1InventoryPlayer; + this.field_147092_v = (ContainerRepair)this.inventorySlots; + } + + public void initGui() + { + super.initGui(); + Keyboard.enableRepeatEvents(true); + int i = (this.width - this.xSize) / 2; + int j = (this.height - this.ySize) / 2; + this.field_147091_w = new GuiTextField(this.fontRendererObj, i + 62, j + 24, 103, 12); + this.field_147091_w.setTextColor(-1); + this.field_147091_w.setDisabledTextColour(-1); + this.field_147091_w.setEnableBackgroundDrawing(false); + this.field_147091_w.setMaxStringLength(40); + this.inventorySlots.removeCraftingFromCrafters(this); + this.inventorySlots.addCraftingToCrafters(this); + } + + public void onGuiClosed() + { + super.onGuiClosed(); + Keyboard.enableRepeatEvents(false); + this.inventorySlots.removeCraftingFromCrafters(this); + } + + protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) + { + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_BLEND); + this.fontRendererObj.drawString(I18n.format("container.repair", new Object[0]), 60, 6, 4210752); + + if (this.field_147092_v.maximumCost > 0) + { + int k = 8453920; + boolean flag = true; + String s = I18n.format("container.repair.cost", new Object[] {Integer.valueOf(this.field_147092_v.maximumCost)}); + + if (this.field_147092_v.maximumCost >= 40 && !this.mc.thePlayer.capabilities.isCreativeMode) + { + s = I18n.format("container.repair.expensive", new Object[0]); + k = 16736352; + } + else if (!this.field_147092_v.getSlot(2).getHasStack()) + { + flag = false; + } + else if (!this.field_147092_v.getSlot(2).canTakeStack(this.field_147094_x.player)) + { + k = 16736352; + } + + if (flag) + { + int l = -16777216 | (k & 16579836) >> 2 | k & -16777216; + int i1 = this.xSize - 8 - this.fontRendererObj.getStringWidth(s); + byte b0 = 67; + + if (this.fontRendererObj.getUnicodeFlag()) + { + drawRect(i1 - 3, b0 - 2, this.xSize - 7, b0 + 10, -16777216); + drawRect(i1 - 2, b0 - 1, this.xSize - 8, b0 + 9, -12895429); + } + else + { + this.fontRendererObj.drawString(s, i1, b0 + 1, l); + this.fontRendererObj.drawString(s, i1 + 1, b0, l); + this.fontRendererObj.drawString(s, i1 + 1, b0 + 1, l); + } + + this.fontRendererObj.drawString(s, i1, b0, k); + } + } + + GL11.glEnable(GL11.GL_LIGHTING); + } + + protected void keyTyped(char par1, int par2) + { + if (this.field_147091_w.textboxKeyTyped(par1, par2)) + { + this.func_147090_g(); + } + else + { + super.keyTyped(par1, par2); + } + } + + private void func_147090_g() + { + String s = this.field_147091_w.getText(); + Slot slot = this.field_147092_v.getSlot(0); + + if (slot != null && slot.getHasStack() && !slot.getStack().hasDisplayName() && s.equals(slot.getStack().getDisplayName())) + { + s = ""; + } + + this.field_147092_v.updateItemName(s); + this.mc.thePlayer.sendQueue.addToSendQueue(new C17PacketCustomPayload("MC|ItemName", s.getBytes(Charsets.UTF_8))); + } + + protected void mouseClicked(int par1, int par2, int par3) + { + super.mouseClicked(par1, par2, par3); + this.field_147091_w.mouseClicked(par1, par2, par3); + } + + public void drawScreen(int par1, int par2, float par3) + { + super.drawScreen(par1, par2, par3); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_BLEND); + this.field_147091_w.drawTextBox(); + } + + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(field_147093_u); + int k = (this.width - this.xSize) / 2; + int l = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + this.drawTexturedModalRect(k + 59, l + 20, 0, this.ySize + (this.field_147092_v.getSlot(0).getHasStack() ? 0 : 16), 110, 16); + + if ((this.field_147092_v.getSlot(0).getHasStack() || this.field_147092_v.getSlot(1).getHasStack()) && !this.field_147092_v.getSlot(2).getHasStack()) + { + this.drawTexturedModalRect(k + 99, l + 45, this.xSize, 0, 28, 21); + } + } + + public void sendContainerAndContentsToPlayer(Container par1Container, List par2List) + { + this.sendSlotContents(par1Container, 0, par1Container.getSlot(0).getStack()); + } + + public void sendSlotContents(Container par1Container, int par2, ItemStack par3ItemStack) + { + if (par2 == 0) + { + this.field_147091_w.setText(par3ItemStack == null ? "" : par3ItemStack.getDisplayName()); + this.field_147091_w.setEnabled(par3ItemStack != null); + + if (par3ItemStack != null) + { + this.func_147090_g(); + } + } + } + + public void sendProgressBarUpdate(Container par1Container, int par2, int par3) {} +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiResourcePackAvailable.java b/src/main/java/net/minecraft/client/gui/GuiResourcePackAvailable.java new file mode 100644 index 0000000..540c187 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiResourcePackAvailable.java @@ -0,0 +1,23 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.client.Minecraft; +import net.minecraft.client.resources.I18n; + +@SideOnly(Side.CLIENT) +public class GuiResourcePackAvailable extends GuiResourcePackList +{ + private static final String __OBFID = "CL_00000824"; + + public GuiResourcePackAvailable(Minecraft p_i45054_1_, int p_i45054_2_, int p_i45054_3_, List p_i45054_4_) + { + super(p_i45054_1_, p_i45054_2_, p_i45054_3_, p_i45054_4_); + } + + protected String func_148202_k() + { + return I18n.format("resourcePack.available.title", new Object[0]); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiResourcePackList.java b/src/main/java/net/minecraft/client/gui/GuiResourcePackList.java new file mode 100644 index 0000000..bc392af --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiResourcePackList.java @@ -0,0 +1,59 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.resources.ResourcePackListEntry; +import net.minecraft.util.EnumChatFormatting; + +@SideOnly(Side.CLIENT) +public abstract class GuiResourcePackList extends GuiListExtended +{ + protected final Minecraft field_148205_k; + protected final List field_148204_l; + private static final String __OBFID = "CL_00000825"; + + public GuiResourcePackList(Minecraft p_i45055_1_, int p_i45055_2_, int p_i45055_3_, List p_i45055_4_) + { + super(p_i45055_1_, p_i45055_2_, p_i45055_3_, 32, p_i45055_3_ - 55 + 4, 36); + this.field_148205_k = p_i45055_1_; + this.field_148204_l = p_i45055_4_; + this.field_148163_i = false; + this.setHasListHeader(true, (int)((float)p_i45055_1_.fontRenderer.FONT_HEIGHT * 1.5F)); + } + + protected void drawListHeader(int p_148129_1_, int p_148129_2_, Tessellator p_148129_3_) + { + String s = EnumChatFormatting.UNDERLINE + "" + EnumChatFormatting.BOLD + this.func_148202_k(); + this.field_148205_k.fontRenderer.drawString(s, p_148129_1_ + this.width / 2 - this.field_148205_k.fontRenderer.getStringWidth(s) / 2, Math.min(this.top + 3, p_148129_2_), 16777215); + } + + protected abstract String func_148202_k(); + + public List func_148201_l() + { + return this.field_148204_l; + } + + protected int getSize() + { + return this.func_148201_l().size(); + } + + public ResourcePackListEntry getListEntry(int p_148203_1_) + { + return (ResourcePackListEntry)this.func_148201_l().get(p_148203_1_); + } + + public int getListWidth() + { + return this.width; + } + + protected int getScrollBarX() + { + return this.right - 6; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiResourcePackSelected.java b/src/main/java/net/minecraft/client/gui/GuiResourcePackSelected.java new file mode 100644 index 0000000..8bcff59 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiResourcePackSelected.java @@ -0,0 +1,23 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.client.Minecraft; +import net.minecraft.client.resources.I18n; + +@SideOnly(Side.CLIENT) +public class GuiResourcePackSelected extends GuiResourcePackList +{ + private static final String __OBFID = "CL_00000827"; + + public GuiResourcePackSelected(Minecraft p_i45056_1_, int p_i45056_2_, int p_i45056_3_, List p_i45056_4_) + { + super(p_i45056_1_, p_i45056_2_, p_i45056_3_, p_i45056_4_); + } + + protected String func_148202_k() + { + return I18n.format("resourcePack.selected.title", new Object[0]); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiScreen.java b/src/main/java/net/minecraft/client/gui/GuiScreen.java new file mode 100644 index 0000000..8c25b36 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiScreen.java @@ -0,0 +1,379 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.awt.Toolkit; +import java.awt.datatransfer.ClipboardOwner; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.StringSelection; +import java.awt.datatransfer.Transferable; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +@SideOnly(Side.CLIENT) +public class GuiScreen extends Gui +{ + protected static RenderItem itemRender = new RenderItem(); + public Minecraft mc; + public int width; + public int height; + protected List buttonList = new ArrayList(); + protected List labelList = new ArrayList(); + public boolean allowUserInput; + protected FontRenderer fontRendererObj; + private GuiButton selectedButton; + private int eventButton; + private long lastMouseEvent; + private int field_146298_h; + private static final String __OBFID = "CL_00000710"; + + public void drawScreen(int par1, int par2, float par3) + { + int k; + + for (k = 0; k < this.buttonList.size(); ++k) + { + ((GuiButton)this.buttonList.get(k)).drawButton(this.mc, par1, par2); + } + + for (k = 0; k < this.labelList.size(); ++k) + { + ((GuiLabel)this.labelList.get(k)).func_146159_a(this.mc, par1, par2); + } + } + + protected void keyTyped(char par1, int par2) + { + if (par2 == 1) + { + this.mc.displayGuiScreen((GuiScreen)null); + this.mc.setIngameFocus(); + } + } + + public static String getClipboardString() + { + try + { + Transferable transferable = Toolkit.getDefaultToolkit().getSystemClipboard().getContents((Object)null); + + if (transferable != null && transferable.isDataFlavorSupported(DataFlavor.stringFlavor)) + { + return (String)transferable.getTransferData(DataFlavor.stringFlavor); + } + } + catch (Exception exception) + { + ; + } + + return ""; + } + + public static void setClipboardString(String p_146275_0_) + { + try + { + StringSelection stringselection = new StringSelection(p_146275_0_); + Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringselection, (ClipboardOwner)null); + } + catch (Exception exception) + { + ; + } + } + + protected void renderToolTip(ItemStack p_146285_1_, int p_146285_2_, int p_146285_3_) + { + List list = p_146285_1_.getTooltip(this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips); + + for (int k = 0; k < list.size(); ++k) + { + if (k == 0) + { + list.set(k, p_146285_1_.getRarity().rarityColor + (String)list.get(k)); + } + else + { + list.set(k, EnumChatFormatting.GRAY + (String)list.get(k)); + } + } + + FontRenderer font = p_146285_1_.getItem().getFontRenderer(p_146285_1_); + this.func_146283_a(list, p_146285_2_, p_146285_3_); + drawHoveringText(list, p_146285_2_, p_146285_3_, (font == null ? fontRendererObj : font)); + } + + protected void drawCreativeTabHoveringText(String p_146279_1_, int p_146279_2_, int p_146279_3_) + { + this.func_146283_a(Arrays.asList(new String[] {p_146279_1_}), p_146279_2_, p_146279_3_); + } + + protected void func_146283_a(List p_146283_1_, int p_146283_2_, int p_146283_3_) + { + drawHoveringText(p_146283_1_, p_146283_2_, p_146283_3_, fontRendererObj); + } + + protected void drawHoveringText(List p_146283_1_, int p_146283_2_, int p_146283_3_, FontRenderer font) + { + if (!p_146283_1_.isEmpty()) + { + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + int k = 0; + Iterator iterator = p_146283_1_.iterator(); + + while (iterator.hasNext()) + { + String s = (String)iterator.next(); + int l = font.getStringWidth(s); + + if (l > k) + { + k = l; + } + } + + int j2 = p_146283_2_ + 12; + int k2 = p_146283_3_ - 12; + int i1 = 8; + + if (p_146283_1_.size() > 1) + { + i1 += 2 + (p_146283_1_.size() - 1) * 10; + } + + if (j2 + k > this.width) + { + j2 -= 28 + k; + } + + if (k2 + i1 + 6 > this.height) + { + k2 = this.height - i1 - 6; + } + + this.zLevel = 300.0F; + itemRender.zLevel = 300.0F; + int j1 = -267386864; + this.drawGradientRect(j2 - 3, k2 - 4, j2 + k + 3, k2 - 3, j1, j1); + this.drawGradientRect(j2 - 3, k2 + i1 + 3, j2 + k + 3, k2 + i1 + 4, j1, j1); + this.drawGradientRect(j2 - 3, k2 - 3, j2 + k + 3, k2 + i1 + 3, j1, j1); + this.drawGradientRect(j2 - 4, k2 - 3, j2 - 3, k2 + i1 + 3, j1, j1); + this.drawGradientRect(j2 + k + 3, k2 - 3, j2 + k + 4, k2 + i1 + 3, j1, j1); + int k1 = 1347420415; + int l1 = (k1 & 16711422) >> 1 | k1 & -16777216; + this.drawGradientRect(j2 - 3, k2 - 3 + 1, j2 - 3 + 1, k2 + i1 + 3 - 1, k1, l1); + this.drawGradientRect(j2 + k + 2, k2 - 3 + 1, j2 + k + 3, k2 + i1 + 3 - 1, k1, l1); + this.drawGradientRect(j2 - 3, k2 - 3, j2 + k + 3, k2 - 3 + 1, k1, k1); + this.drawGradientRect(j2 - 3, k2 + i1 + 2, j2 + k + 3, k2 + i1 + 3, l1, l1); + + for (int i2 = 0; i2 < p_146283_1_.size(); ++i2) + { + String s1 = (String)p_146283_1_.get(i2); + font.drawStringWithShadow(s1, j2, k2, -1); + + if (i2 == 0) + { + k2 += 2; + } + + k2 += 10; + } + + this.zLevel = 0.0F; + itemRender.zLevel = 0.0F; + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + RenderHelper.enableStandardItemLighting(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + } + } + + protected void mouseClicked(int par1, int par2, int par3) + { + if (par3 == 0) + { + for (int l = 0; l < this.buttonList.size(); ++l) + { + GuiButton guibutton = (GuiButton)this.buttonList.get(l); + + if (guibutton.mousePressed(this.mc, par1, par2)) + { + this.selectedButton = guibutton; + guibutton.func_146113_a(this.mc.getSoundHandler()); + this.actionPerformed(guibutton); + } + } + } + } + + protected void mouseMovedOrUp(int p_146286_1_, int p_146286_2_, int p_146286_3_) + { + if (this.selectedButton != null && p_146286_3_ == 0) + { + this.selectedButton.mouseReleased(p_146286_1_, p_146286_2_); + this.selectedButton = null; + } + } + + protected void mouseClickMove(int p_146273_1_, int p_146273_2_, int p_146273_3_, long p_146273_4_) {} + + protected void actionPerformed(GuiButton p_146284_1_) {} + + public void setWorldAndResolution(Minecraft p_146280_1_, int p_146280_2_, int p_146280_3_) + { + this.mc = p_146280_1_; + this.fontRendererObj = p_146280_1_.fontRenderer; + this.width = p_146280_2_; + this.height = p_146280_3_; + this.buttonList.clear(); + this.initGui(); + } + + public void initGui() {} + + public void handleInput() + { + if (Mouse.isCreated()) + { + while (Mouse.next()) + { + this.handleMouseInput(); + } + } + + if (Keyboard.isCreated()) + { + while (Keyboard.next()) + { + this.handleKeyboardInput(); + } + } + } + + public void handleMouseInput() + { + int i = Mouse.getEventX() * this.width / this.mc.displayWidth; + int j = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1; + int k = Mouse.getEventButton(); + + if (Minecraft.isRunningOnMac && k == 0 && (Keyboard.isKeyDown(29) || Keyboard.isKeyDown(157))) + { + k = 1; + } + + if (Mouse.getEventButtonState()) + { + if (this.mc.gameSettings.touchscreen && this.field_146298_h++ > 0) + { + return; + } + + this.eventButton = k; + this.lastMouseEvent = Minecraft.getSystemTime(); + this.mouseClicked(i, j, this.eventButton); + } + else if (k != -1) + { + if (this.mc.gameSettings.touchscreen && --this.field_146298_h > 0) + { + return; + } + + this.eventButton = -1; + this.mouseMovedOrUp(i, j, k); + } + else if (this.eventButton != -1 && this.lastMouseEvent > 0L) + { + long l = Minecraft.getSystemTime() - this.lastMouseEvent; + this.mouseClickMove(i, j, this.eventButton, l); + } + } + + public void handleKeyboardInput() + { + if (Keyboard.getEventKeyState()) + { + int i = Keyboard.getEventKey(); + char c0 = Keyboard.getEventCharacter(); + + if (i == 87) + { + this.mc.toggleFullscreen(); + return; + } + + this.keyTyped(c0, i); + } + } + + public void updateScreen() {} + + public void onGuiClosed() {} + + public void drawDefaultBackground() + { + this.drawWorldBackground(0); + } + + public void drawWorldBackground(int p_146270_1_) + { + if (this.mc.theWorld != null) + { + this.drawGradientRect(0, 0, this.width, this.height, -1072689136, -804253680); + } + else + { + this.drawBackground(p_146270_1_); + } + } + + public void drawBackground(int p_146278_1_) + { + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_FOG); + Tessellator tessellator = Tessellator.instance; + this.mc.getTextureManager().bindTexture(optionsBackground); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + float f = 32.0F; + tessellator.startDrawingQuads(); + tessellator.setColorOpaque_I(4210752); + tessellator.addVertexWithUV(0.0D, (double)this.height, 0.0D, 0.0D, (double)((float)this.height / f + (float)p_146278_1_)); + tessellator.addVertexWithUV((double)this.width, (double)this.height, 0.0D, (double)((float)this.width / f), (double)((float)this.height / f + (float)p_146278_1_)); + tessellator.addVertexWithUV((double)this.width, 0.0D, 0.0D, (double)((float)this.width / f), (double)p_146278_1_); + tessellator.addVertexWithUV(0.0D, 0.0D, 0.0D, 0.0D, (double)p_146278_1_); + tessellator.draw(); + } + + public boolean doesGuiPauseGame() + { + return true; + } + + public void confirmClicked(boolean par1, int par2) {} + + public static boolean isCtrlKeyDown() + { + return Minecraft.isRunningOnMac ? Keyboard.isKeyDown(219) || Keyboard.isKeyDown(220) : Keyboard.isKeyDown(29) || Keyboard.isKeyDown(157); + } + + public static boolean isShiftKeyDown() + { + return Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiScreenAddServer.java b/src/main/java/net/minecraft/client/gui/GuiScreenAddServer.java new file mode 100644 index 0000000..e5d9be5 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiScreenAddServer.java @@ -0,0 +1,103 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.multiplayer.ServerData; +import net.minecraft.client.resources.I18n; +import org.lwjgl.input.Keyboard; + +@SideOnly(Side.CLIENT) +public class GuiScreenAddServer extends GuiScreen +{ + private GuiScreen field_146310_a; + private GuiTextField field_146308_f; + private GuiTextField field_146309_g; + private ServerData field_146311_h; + private static final String __OBFID = "CL_00000695"; + + public GuiScreenAddServer(GuiScreen par1GuiScreen, ServerData par2ServerData) + { + this.field_146310_a = par1GuiScreen; + this.field_146311_h = par2ServerData; + } + + public void updateScreen() + { + this.field_146309_g.updateCursorCounter(); + this.field_146308_f.updateCursorCounter(); + } + + public void initGui() + { + Keyboard.enableRepeatEvents(true); + this.buttonList.clear(); + this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 96 + 12, I18n.format("addServer.add", new Object[0]))); + this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 120 + 12, I18n.format("gui.cancel", new Object[0]))); + this.field_146309_g = new GuiTextField(this.fontRendererObj, this.width / 2 - 100, 66, 200, 20); + this.field_146309_g.setFocused(true); + this.field_146309_g.setText(this.field_146311_h.serverName); + this.field_146308_f = new GuiTextField(this.fontRendererObj, this.width / 2 - 100, 106, 200, 20); + this.field_146308_f.setMaxStringLength(128); + this.field_146308_f.setText(this.field_146311_h.serverIP); + ((GuiButton)this.buttonList.get(0)).enabled = this.field_146308_f.getText().length() > 0 && this.field_146308_f.getText().split(":").length > 0 && this.field_146309_g.getText().length() > 0; + } + + public void onGuiClosed() + { + Keyboard.enableRepeatEvents(false); + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.enabled) + { + if (p_146284_1_.id == 1) + { + this.field_146310_a.confirmClicked(false, 0); + } + else if (p_146284_1_.id == 0) + { + this.field_146311_h.serverName = this.field_146309_g.getText(); + this.field_146311_h.serverIP = this.field_146308_f.getText(); + this.field_146310_a.confirmClicked(true, 0); + } + } + } + + protected void keyTyped(char par1, int par2) + { + this.field_146309_g.textboxKeyTyped(par1, par2); + this.field_146308_f.textboxKeyTyped(par1, par2); + + if (par2 == 15) + { + this.field_146309_g.setFocused(!this.field_146309_g.isFocused()); + this.field_146308_f.setFocused(!this.field_146308_f.isFocused()); + } + + if (par2 == 28 || par2 == 156) + { + this.actionPerformed((GuiButton)this.buttonList.get(0)); + } + + ((GuiButton)this.buttonList.get(0)).enabled = this.field_146308_f.getText().length() > 0 && this.field_146308_f.getText().split(":").length > 0 && this.field_146309_g.getText().length() > 0; + } + + protected void mouseClicked(int par1, int par2, int par3) + { + super.mouseClicked(par1, par2, par3); + this.field_146308_f.mouseClicked(par1, par2, par3); + this.field_146309_g.mouseClicked(par1, par2, par3); + } + + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + this.drawCenteredString(this.fontRendererObj, I18n.format("addServer.title", new Object[0]), this.width / 2, 17, 16777215); + this.drawString(this.fontRendererObj, I18n.format("addServer.enterName", new Object[0]), this.width / 2 - 100, 53, 10526880); + this.drawString(this.fontRendererObj, I18n.format("addServer.enterIp", new Object[0]), this.width / 2 - 100, 94, 10526880); + this.field_146309_g.drawTextBox(); + this.field_146308_f.drawTextBox(); + super.drawScreen(par1, par2, par3); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiScreenBook.java b/src/main/java/net/minecraft/client/gui/GuiScreenBook.java new file mode 100644 index 0000000..68b4c63 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiScreenBook.java @@ -0,0 +1,464 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; +import net.minecraft.client.Minecraft; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.nbt.NBTTagString; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.client.C17PacketCustomPayload; +import net.minecraft.util.ChatAllowedCharacters; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class GuiScreenBook extends GuiScreen +{ + private static final Logger logger = LogManager.getLogger(); + private static final ResourceLocation bookGuiTextures = new ResourceLocation("textures/gui/book.png"); + private final EntityPlayer editingPlayer; + private final ItemStack bookObj; + private final boolean bookIsUnsigned; + private boolean field_146481_r; + private boolean field_146480_s; + private int updateCount; + private int bookImageWidth = 192; + private int bookImageHeight = 192; + private int bookTotalPages = 1; + private int currPage; + private NBTTagList bookPages; + private String bookTitle = ""; + private GuiScreenBook.NextPageButton buttonNextPage; + private GuiScreenBook.NextPageButton buttonPreviousPage; + private GuiButton buttonDone; + private GuiButton buttonSign; + private GuiButton buttonFinalize; + private GuiButton buttonCancel; + private static final String __OBFID = "CL_00000744"; + + public GuiScreenBook(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack, boolean par3) + { + this.editingPlayer = par1EntityPlayer; + this.bookObj = par2ItemStack; + this.bookIsUnsigned = par3; + + if (par2ItemStack.hasTagCompound()) + { + NBTTagCompound nbttagcompound = par2ItemStack.getTagCompound(); + this.bookPages = nbttagcompound.getTagList("pages", 8); + + if (this.bookPages != null) + { + this.bookPages = (NBTTagList)this.bookPages.copy(); + this.bookTotalPages = this.bookPages.tagCount(); + + if (this.bookTotalPages < 1) + { + this.bookTotalPages = 1; + } + } + } + + if (this.bookPages == null && par3) + { + this.bookPages = new NBTTagList(); + this.bookPages.appendTag(new NBTTagString("")); + this.bookTotalPages = 1; + } + } + + public void updateScreen() + { + super.updateScreen(); + ++this.updateCount; + } + + public void initGui() + { + this.buttonList.clear(); + Keyboard.enableRepeatEvents(true); + + if (this.bookIsUnsigned) + { + this.buttonList.add(this.buttonSign = new GuiButton(3, this.width / 2 - 100, 4 + this.bookImageHeight, 98, 20, I18n.format("book.signButton", new Object[0]))); + this.buttonList.add(this.buttonDone = new GuiButton(0, this.width / 2 + 2, 4 + this.bookImageHeight, 98, 20, I18n.format("gui.done", new Object[0]))); + this.buttonList.add(this.buttonFinalize = new GuiButton(5, this.width / 2 - 100, 4 + this.bookImageHeight, 98, 20, I18n.format("book.finalizeButton", new Object[0]))); + this.buttonList.add(this.buttonCancel = new GuiButton(4, this.width / 2 + 2, 4 + this.bookImageHeight, 98, 20, I18n.format("gui.cancel", new Object[0]))); + } + else + { + this.buttonList.add(this.buttonDone = new GuiButton(0, this.width / 2 - 100, 4 + this.bookImageHeight, 200, 20, I18n.format("gui.done", new Object[0]))); + } + + int i = (this.width - this.bookImageWidth) / 2; + byte b0 = 2; + this.buttonList.add(this.buttonNextPage = new GuiScreenBook.NextPageButton(1, i + 120, b0 + 154, true)); + this.buttonList.add(this.buttonPreviousPage = new GuiScreenBook.NextPageButton(2, i + 38, b0 + 154, false)); + this.updateButtons(); + } + + public void onGuiClosed() + { + Keyboard.enableRepeatEvents(false); + } + + private void updateButtons() + { + this.buttonNextPage.visible = !this.field_146480_s && (this.currPage < this.bookTotalPages - 1 || this.bookIsUnsigned); + this.buttonPreviousPage.visible = !this.field_146480_s && this.currPage > 0; + this.buttonDone.visible = !this.bookIsUnsigned || !this.field_146480_s; + + if (this.bookIsUnsigned) + { + this.buttonSign.visible = !this.field_146480_s; + this.buttonCancel.visible = this.field_146480_s; + this.buttonFinalize.visible = this.field_146480_s; + this.buttonFinalize.enabled = this.bookTitle.trim().length() > 0; + } + } + + private void sendBookToServer(boolean p_146462_1_) + { + if (this.bookIsUnsigned && this.field_146481_r) + { + if (this.bookPages != null) + { + String s; + + while (this.bookPages.tagCount() > 1) + { + s = this.bookPages.getStringTagAt(this.bookPages.tagCount() - 1); + + if (s.length() != 0) + { + break; + } + + this.bookPages.removeTag(this.bookPages.tagCount() - 1); + } + + if (this.bookObj.hasTagCompound()) + { + NBTTagCompound nbttagcompound = this.bookObj.getTagCompound(); + nbttagcompound.setTag("pages", this.bookPages); + } + else + { + this.bookObj.setTagInfo("pages", this.bookPages); + } + + s = "MC|BEdit"; + + if (p_146462_1_) + { + s = "MC|BSign"; + this.bookObj.setTagInfo("author", new NBTTagString(this.editingPlayer.getCommandSenderName())); + this.bookObj.setTagInfo("title", new NBTTagString(this.bookTitle.trim())); + this.bookObj.func_150996_a(Items.written_book); + } + + ByteBuf bytebuf = Unpooled.buffer(); + + try + { + (new PacketBuffer(bytebuf)).writeItemStackToBuffer(this.bookObj); + this.mc.getNetHandler().addToSendQueue(new C17PacketCustomPayload(s, bytebuf)); + } + catch (Exception exception) + { + logger.error("Couldn\'t send book info", exception); + } + finally + { + bytebuf.release(); + } + } + } + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.enabled) + { + if (p_146284_1_.id == 0) + { + this.mc.displayGuiScreen((GuiScreen)null); + this.sendBookToServer(false); + } + else if (p_146284_1_.id == 3 && this.bookIsUnsigned) + { + this.field_146480_s = true; + } + else if (p_146284_1_.id == 1) + { + if (this.currPage < this.bookTotalPages - 1) + { + ++this.currPage; + } + else if (this.bookIsUnsigned) + { + this.addNewPage(); + + if (this.currPage < this.bookTotalPages - 1) + { + ++this.currPage; + } + } + } + else if (p_146284_1_.id == 2) + { + if (this.currPage > 0) + { + --this.currPage; + } + } + else if (p_146284_1_.id == 5 && this.field_146480_s) + { + this.sendBookToServer(true); + this.mc.displayGuiScreen((GuiScreen)null); + } + else if (p_146284_1_.id == 4 && this.field_146480_s) + { + this.field_146480_s = false; + } + + this.updateButtons(); + } + } + + private void addNewPage() + { + if (this.bookPages != null && this.bookPages.tagCount() < 50) + { + this.bookPages.appendTag(new NBTTagString("")); + ++this.bookTotalPages; + this.field_146481_r = true; + } + } + + protected void keyTyped(char par1, int par2) + { + super.keyTyped(par1, par2); + + if (this.bookIsUnsigned) + { + if (this.field_146480_s) + { + this.func_146460_c(par1, par2); + } + else + { + this.keyTypedInBook(par1, par2); + } + } + } + + private void keyTypedInBook(char p_146463_1_, int p_146463_2_) + { + switch (p_146463_1_) + { + case 22: + this.func_146459_b(GuiScreen.getClipboardString()); + return; + default: + switch (p_146463_2_) + { + case 14: + String s = this.func_146456_p(); + + if (s.length() > 0) + { + this.func_146457_a(s.substring(0, s.length() - 1)); + } + + return; + case 28: + case 156: + this.func_146459_b("\n"); + return; + default: + if (ChatAllowedCharacters.isAllowedCharacter(p_146463_1_)) + { + this.func_146459_b(Character.toString(p_146463_1_)); + } + } + } + } + + private void func_146460_c(char p_146460_1_, int p_146460_2_) + { + switch (p_146460_2_) + { + case 14: + if (!this.bookTitle.isEmpty()) + { + this.bookTitle = this.bookTitle.substring(0, this.bookTitle.length() - 1); + this.updateButtons(); + } + + return; + case 28: + case 156: + if (!this.bookTitle.isEmpty()) + { + this.sendBookToServer(true); + this.mc.displayGuiScreen((GuiScreen)null); + } + + return; + default: + if (this.bookTitle.length() < 16 && ChatAllowedCharacters.isAllowedCharacter(p_146460_1_)) + { + this.bookTitle = this.bookTitle + Character.toString(p_146460_1_); + this.updateButtons(); + this.field_146481_r = true; + } + } + } + + private String func_146456_p() + { + return this.bookPages != null && this.currPage >= 0 && this.currPage < this.bookPages.tagCount() ? this.bookPages.getStringTagAt(this.currPage) : ""; + } + + private void func_146457_a(String p_146457_1_) + { + if (this.bookPages != null && this.currPage >= 0 && this.currPage < this.bookPages.tagCount()) + { + this.bookPages.func_150304_a(this.currPage, new NBTTagString(p_146457_1_)); + this.field_146481_r = true; + } + } + + private void func_146459_b(String p_146459_1_) + { + String s1 = this.func_146456_p(); + String s2 = s1 + p_146459_1_; + int i = this.fontRendererObj.splitStringWidth(s2 + "" + EnumChatFormatting.BLACK + "_", 118); + + if (i <= 118 && s2.length() < 256) + { + this.func_146457_a(s2); + } + } + + public void drawScreen(int par1, int par2, float par3) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(bookGuiTextures); + int k = (this.width - this.bookImageWidth) / 2; + byte b0 = 2; + this.drawTexturedModalRect(k, b0, 0, 0, this.bookImageWidth, this.bookImageHeight); + String s; + String s1; + int l; + + if (this.field_146480_s) + { + s = this.bookTitle; + + if (this.bookIsUnsigned) + { + if (this.updateCount / 6 % 2 == 0) + { + s = s + "" + EnumChatFormatting.BLACK + "_"; + } + else + { + s = s + "" + EnumChatFormatting.GRAY + "_"; + } + } + + s1 = I18n.format("book.editTitle", new Object[0]); + l = this.fontRendererObj.getStringWidth(s1); + this.fontRendererObj.drawString(s1, k + 36 + (116 - l) / 2, b0 + 16 + 16, 0); + int i1 = this.fontRendererObj.getStringWidth(s); + this.fontRendererObj.drawString(s, k + 36 + (116 - i1) / 2, b0 + 48, 0); + String s2 = I18n.format("book.byAuthor", new Object[] {this.editingPlayer.getCommandSenderName()}); + int j1 = this.fontRendererObj.getStringWidth(s2); + this.fontRendererObj.drawString(EnumChatFormatting.DARK_GRAY + s2, k + 36 + (116 - j1) / 2, b0 + 48 + 10, 0); + String s3 = I18n.format("book.finalizeWarning", new Object[0]); + this.fontRendererObj.drawSplitString(s3, k + 36, b0 + 80, 116, 0); + } + else + { + s = I18n.format("book.pageIndicator", new Object[] {Integer.valueOf(this.currPage + 1), Integer.valueOf(this.bookTotalPages)}); + s1 = ""; + + if (this.bookPages != null && this.currPage >= 0 && this.currPage < this.bookPages.tagCount()) + { + s1 = this.bookPages.getStringTagAt(this.currPage); + } + + if (this.bookIsUnsigned) + { + if (this.fontRendererObj.getBidiFlag()) + { + s1 = s1 + "_"; + } + else if (this.updateCount / 6 % 2 == 0) + { + s1 = s1 + "" + EnumChatFormatting.BLACK + "_"; + } + else + { + s1 = s1 + "" + EnumChatFormatting.GRAY + "_"; + } + } + + l = this.fontRendererObj.getStringWidth(s); + this.fontRendererObj.drawString(s, k - l + this.bookImageWidth - 44, b0 + 16, 0); + this.fontRendererObj.drawSplitString(s1, k + 36, b0 + 16 + 16, 116, 0); + } + + super.drawScreen(par1, par2, par3); + } + + @SideOnly(Side.CLIENT) + static class NextPageButton extends GuiButton + { + private final boolean field_146151_o; + private static final String __OBFID = "CL_00000745"; + + public NextPageButton(int par1, int par2, int par3, boolean par4) + { + super(par1, par2, par3, 23, 13, ""); + this.field_146151_o = par4; + } + + public void drawButton(Minecraft p_146112_1_, int p_146112_2_, int p_146112_3_) + { + if (this.visible) + { + boolean flag = p_146112_2_ >= this.xPosition && p_146112_3_ >= this.yPosition && p_146112_2_ < this.xPosition + this.width && p_146112_3_ < this.yPosition + this.height; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + p_146112_1_.getTextureManager().bindTexture(GuiScreenBook.bookGuiTextures); + int k = 0; + int l = 192; + + if (flag) + { + k += 23; + } + + if (!this.field_146151_o) + { + l += 13; + } + + this.drawTexturedModalRect(this.xPosition, this.yPosition, k, l, 23, 13); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiScreenBuyRealms.java b/src/main/java/net/minecraft/client/gui/GuiScreenBuyRealms.java new file mode 100644 index 0000000..6cc5820 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiScreenBuyRealms.java @@ -0,0 +1,101 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.Minecraft; +import net.minecraft.client.mco.ExceptionMcoService; +import net.minecraft.client.mco.McoClient; +import net.minecraft.client.resources.I18n; +import net.minecraft.util.Session; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.lwjgl.input.Keyboard; + +@SideOnly(Side.CLIENT) +public class GuiScreenBuyRealms extends GuiScreen +{ + private static final Logger logger = LogManager.getLogger(); + private GuiScreen field_146817_f; + private static int field_146818_g = 111; + private volatile String field_146820_h = ""; + private static final String __OBFID = "CL_00000770"; + + public GuiScreenBuyRealms(GuiScreen p_i45035_1_) + { + this.field_146817_f = p_i45035_1_; + } + + public void updateScreen() {} + + public void initGui() + { + Keyboard.enableRepeatEvents(true); + this.buttonList.clear(); + short short1 = 212; + this.buttonList.add(new GuiButton(field_146818_g, this.width / 2 - short1 / 2, 180, short1, 20, I18n.format("gui.back", new Object[0]))); + this.func_146816_h(); + } + + private void func_146816_h() + { + Session session = this.mc.getSession(); + final McoClient mcoclient = new McoClient(session.getSessionID(), session.getUsername(), "1.7.2", Minecraft.getMinecraft().getProxy()); + (new Thread() + { + private static final String __OBFID = "CL_00000771"; + public void run() + { + try + { + GuiScreenBuyRealms.this.field_146820_h = mcoclient.func_148690_i(); + } + catch (ExceptionMcoService exceptionmcoservice) + { + GuiScreenBuyRealms.logger.error("Could not get stat"); + } + } + }).start(); + } + + public void onGuiClosed() + { + Keyboard.enableRepeatEvents(false); + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.enabled) + { + if (p_146284_1_.id == field_146818_g) + { + this.mc.displayGuiScreen(this.field_146817_f); + } + } + } + + protected void keyTyped(char par1, int par2) {} + + protected void mouseClicked(int par1, int par2, int par3) + { + super.mouseClicked(par1, par2, par3); + } + + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + this.drawCenteredString(this.fontRendererObj, I18n.format("mco.buy.realms.title", new Object[0]), this.width / 2, 11, 16777215); + String[] astring = this.field_146820_h.split("\n"); + int k = 52; + String[] astring1 = astring; + int l = astring.length; + + for (int i1 = 0; i1 < l; ++i1) + { + String s = astring1[i1]; + this.drawCenteredString(this.fontRendererObj, s, this.width / 2, k, 10526880); + k += 18; + } + + super.drawScreen(par1, par2, par3); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiScreenConfigureWorld.java b/src/main/java/net/minecraft/client/gui/GuiScreenConfigureWorld.java new file mode 100644 index 0000000..19fae09 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiScreenConfigureWorld.java @@ -0,0 +1,330 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.mco.GuiScreenBackup; +import net.minecraft.client.gui.mco.GuiScreenResetWorld; +import net.minecraft.client.mco.ExceptionMcoService; +import net.minecraft.client.mco.McoClient; +import net.minecraft.client.mco.McoServer; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.resources.I18n; +import net.minecraft.util.Session; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.lwjgl.input.Keyboard; + +@SideOnly(Side.CLIENT) +public class GuiScreenConfigureWorld extends GuiScreen +{ + private static final Logger logger = LogManager.getLogger(); + private final GuiScreen field_146884_f; + private McoServer field_146885_g; + private GuiScreenConfigureWorld.SelectionListInvited field_146890_h; + private int field_146891_i; + private int field_146897_r; + private int field_146896_s; + private int field_146895_t = -1; + private String field_146894_u; + private GuiButton field_146893_v; + private GuiButton field_146892_w; + private GuiButton field_146900_x; + private GuiButton field_146899_y; + private GuiButton field_146898_z; + private GuiButton field_146886_A; + private GuiButton field_146887_B; + private GuiButton field_146888_C; + private boolean field_146883_D; + private static final String __OBFID = "CL_00000773"; + + public GuiScreenConfigureWorld(GuiScreen par1GuiScreen, McoServer par2McoServer) + { + this.field_146884_f = par1GuiScreen; + this.field_146885_g = par2McoServer; + } + + public void updateScreen() {} + + public void initGui() + { + this.field_146891_i = this.width / 2 - 200; + this.field_146897_r = 180; + this.field_146896_s = this.width / 2; + Keyboard.enableRepeatEvents(true); + this.buttonList.clear(); + + if (this.field_146885_g.field_148808_d.equals("CLOSED")) + { + this.buttonList.add(this.field_146893_v = new GuiButton(0, this.field_146891_i, this.func_146873_a(12), this.field_146897_r / 2 - 2, 20, I18n.format("mco.configure.world.buttons.open", new Object[0]))); + this.field_146893_v.enabled = !this.field_146885_g.field_148819_h; + } + else + { + this.buttonList.add(this.field_146892_w = new GuiButton(1, this.field_146891_i, this.func_146873_a(12), this.field_146897_r / 2 - 2, 20, I18n.format("mco.configure.world.buttons.close", new Object[0]))); + this.field_146892_w.enabled = !this.field_146885_g.field_148819_h; + } + + this.buttonList.add(this.field_146887_B = new GuiButton(7, this.field_146891_i + this.field_146897_r / 2 + 2, this.func_146873_a(12), this.field_146897_r / 2 - 2, 20, I18n.format("mco.configure.world.buttons.subscription", new Object[0]))); + this.buttonList.add(this.field_146900_x = new GuiButton(5, this.field_146891_i, this.func_146873_a(10), this.field_146897_r / 2 - 2, 20, I18n.format("mco.configure.world.buttons.edit", new Object[0]))); + this.buttonList.add(this.field_146899_y = new GuiButton(6, this.field_146891_i + this.field_146897_r / 2 + 2, this.func_146873_a(10), this.field_146897_r / 2 - 2, 20, I18n.format("mco.configure.world.buttons.reset", new Object[0]))); + this.buttonList.add(this.field_146898_z = new GuiButton(4, this.field_146896_s, this.func_146873_a(10), this.field_146897_r / 2 - 2, 20, I18n.format("mco.configure.world.buttons.invite", new Object[0]))); + this.buttonList.add(this.field_146886_A = new GuiButton(3, this.field_146896_s + this.field_146897_r / 2 + 2, this.func_146873_a(10), this.field_146897_r / 2 - 2, 20, I18n.format("mco.configure.world.buttons.uninvite", new Object[0]))); + this.buttonList.add(this.field_146888_C = new GuiButton(8, this.field_146896_s, this.func_146873_a(12), this.field_146897_r / 2 - 2, 20, I18n.format("mco.configure.world.buttons.backup", new Object[0]))); + this.buttonList.add(new GuiButton(10, this.field_146896_s + this.field_146897_r / 2 + 2, this.func_146873_a(12), this.field_146897_r / 2 - 2, 20, I18n.format("gui.back", new Object[0]))); + this.field_146890_h = new GuiScreenConfigureWorld.SelectionListInvited(); + this.field_146900_x.enabled = !this.field_146885_g.field_148819_h; + this.field_146899_y.enabled = !this.field_146885_g.field_148819_h; + this.field_146898_z.enabled = !this.field_146885_g.field_148819_h; + this.field_146886_A.enabled = !this.field_146885_g.field_148819_h; + this.field_146888_C.enabled = !this.field_146885_g.field_148819_h; + } + + private int func_146873_a(int p_146873_1_) + { + return 40 + p_146873_1_ * 13; + } + + public void onGuiClosed() + { + Keyboard.enableRepeatEvents(false); + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.enabled) + { + if (p_146284_1_.id == 10) + { + if (this.field_146883_D) + { + ((GuiScreenOnlineServers)this.field_146884_f).func_146670_h(); + } + + this.mc.displayGuiScreen(this.field_146884_f); + } + else if (p_146284_1_.id == 5) + { + this.mc.displayGuiScreen(new GuiScreenEditOnlineWorld(this, this.field_146884_f, this.field_146885_g)); + } + else if (p_146284_1_.id == 1) + { + String s = I18n.format("mco.configure.world.close.question.line1", new Object[0]); + String s1 = I18n.format("mco.configure.world.close.question.line2", new Object[0]); + this.mc.displayGuiScreen(new GuiScreenConfirmation(this, GuiScreenConfirmation.ConfirmationType.Info, s, s1, 1)); + } + else if (p_146284_1_.id == 0) + { + this.func_146876_g(); + } + else if (p_146284_1_.id == 4) + { + this.mc.displayGuiScreen(new GuiScreenInvite(this.field_146884_f, this, this.field_146885_g)); + } + else if (p_146284_1_.id == 3) + { + this.func_146877_i(); + } + else if (p_146284_1_.id == 6) + { + this.mc.displayGuiScreen(new GuiScreenResetWorld(this, this.field_146885_g)); + } + else if (p_146284_1_.id == 7) + { + this.mc.displayGuiScreen(new GuiScreenSubscription(this, this.field_146885_g)); + } + else if (p_146284_1_.id == 8) + { + this.mc.displayGuiScreen(new GuiScreenBackup(this, this.field_146885_g.field_148812_a)); + } + } + } + + private void func_146876_g() + { + Session session = this.mc.getSession(); + McoClient mcoclient = new McoClient(session.getSessionID(), session.getUsername(), "1.7.2", Minecraft.getMinecraft().getProxy()); + + try + { + Boolean obool = mcoclient.func_148692_e(this.field_146885_g.field_148812_a); + + if (obool.booleanValue()) + { + this.field_146883_D = true; + this.field_146885_g.field_148808_d = "OPEN"; + this.initGui(); + } + } + catch (ExceptionMcoService exceptionmcoservice) + { + logger.error("Couldn\'t open world"); + } + catch (IOException ioexception) + { + logger.error("Could not parse response opening world"); + } + } + + private void func_146882_h() + { + Session session = this.mc.getSession(); + McoClient mcoclient = new McoClient(session.getSessionID(), session.getUsername(), "1.7.2", Minecraft.getMinecraft().getProxy()); + + try + { + boolean flag = mcoclient.func_148700_f(this.field_146885_g.field_148812_a).booleanValue(); + + if (flag) + { + this.field_146883_D = true; + this.field_146885_g.field_148808_d = "CLOSED"; + this.initGui(); + } + } + catch (ExceptionMcoService exceptionmcoservice) + { + logger.error("Couldn\'t close world"); + } + catch (IOException ioexception) + { + logger.error("Could not parse response closing world"); + } + } + + private void func_146877_i() + { + if (this.field_146895_t >= 0 && this.field_146895_t < this.field_146885_g.field_148806_f.size()) + { + this.field_146894_u = (String)this.field_146885_g.field_148806_f.get(this.field_146895_t); + GuiYesNo guiyesno = new GuiYesNo(this, "Question", I18n.format("mco.configure.world.uninvite.question", new Object[0]) + " \'" + this.field_146894_u + "\'", 3); + this.mc.displayGuiScreen(guiyesno); + } + } + + public void confirmClicked(boolean par1, int par2) + { + if (par2 == 3) + { + if (par1) + { + Session session = this.mc.getSession(); + McoClient mcoclient = new McoClient(session.getSessionID(), session.getUsername(), "1.7.2", Minecraft.getMinecraft().getProxy()); + + try + { + mcoclient.func_148694_a(this.field_146885_g.field_148812_a, this.field_146894_u); + } + catch (ExceptionMcoService exceptionmcoservice) + { + logger.error("Couldn\'t uninvite user"); + } + + this.func_146875_d(this.field_146895_t); + } + + this.mc.displayGuiScreen(new GuiScreenConfigureWorld(this.field_146884_f, this.field_146885_g)); + } + + if (par2 == 1) + { + if (par1) + { + this.func_146882_h(); + } + + this.mc.displayGuiScreen(this); + } + } + + private void func_146875_d(int p_146875_1_) + { + this.field_146885_g.field_148806_f.remove(p_146875_1_); + } + + protected void keyTyped(char par1, int par2) {} + + protected void mouseClicked(int par1, int par2, int par3) + { + super.mouseClicked(par1, par2, par3); + } + + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + this.field_146890_h.func_148446_a(par1, par2, par3); + this.drawCenteredString(this.fontRendererObj, I18n.format("mco.configure.world.title", new Object[0]), this.width / 2, 17, 16777215); + this.drawString(this.fontRendererObj, I18n.format("mco.configure.world.name", new Object[0]), this.field_146891_i, this.func_146873_a(1), 10526880); + this.drawString(this.fontRendererObj, this.field_146885_g.func_148801_b(), this.field_146891_i, this.func_146873_a(2), 16777215); + this.drawString(this.fontRendererObj, I18n.format("mco.configure.world.description", new Object[0]), this.field_146891_i, this.func_146873_a(4), 10526880); + this.drawString(this.fontRendererObj, this.field_146885_g.func_148800_a(), this.field_146891_i, this.func_146873_a(5), 16777215); + this.drawString(this.fontRendererObj, I18n.format("mco.configure.world.status", new Object[0]), this.field_146891_i, this.func_146873_a(7), 10526880); + this.drawString(this.fontRendererObj, this.func_146870_p(), this.field_146891_i, this.func_146873_a(8), 16777215); + this.drawString(this.fontRendererObj, I18n.format("mco.configure.world.invited", new Object[0]), this.field_146896_s, this.func_146873_a(1), 10526880); + super.drawScreen(par1, par2, par3); + } + + private String func_146870_p() + { + if (this.field_146885_g.field_148819_h) + { + return "Expired"; + } + else + { + String s = this.field_146885_g.field_148808_d.toLowerCase(); + return Character.toUpperCase(s.charAt(0)) + s.substring(1); + } + } + + @SideOnly(Side.CLIENT) + class SelectionListInvited extends SelectionListBase + { + private static final String __OBFID = "CL_00000775"; + + public SelectionListInvited() + { + super(GuiScreenConfigureWorld.this.mc, GuiScreenConfigureWorld.this.field_146896_s, GuiScreenConfigureWorld.this.func_146873_a(2), GuiScreenConfigureWorld.this.field_146897_r, GuiScreenConfigureWorld.this.func_146873_a(9) - GuiScreenConfigureWorld.this.func_146873_a(2), 12); + } + + protected int func_148443_a() + { + return GuiScreenConfigureWorld.this.field_146885_g.field_148806_f.size() + 1; + } + + protected void func_148449_a(int p_148449_1_, boolean p_148449_2_) + { + if (p_148449_1_ < GuiScreenConfigureWorld.this.field_146885_g.field_148806_f.size()) + { + GuiScreenConfigureWorld.this.field_146895_t = p_148449_1_; + } + } + + protected boolean func_148444_a(int p_148444_1_) + { + return p_148444_1_ == GuiScreenConfigureWorld.this.field_146895_t; + } + + protected int func_148447_b() + { + return this.func_148443_a() * 12; + } + + protected void func_148445_c() {} + + protected void func_148442_a(int p_148442_1_, int p_148442_2_, int p_148442_3_, int p_148442_4_, Tessellator p_148442_5_) + { + if (p_148442_1_ < GuiScreenConfigureWorld.this.field_146885_g.field_148806_f.size()) + { + this.func_148463_b(p_148442_1_, p_148442_2_, p_148442_3_, p_148442_4_, p_148442_5_); + } + } + + private void func_148463_b(int p_148463_1_, int p_148463_2_, int p_148463_3_, int p_148463_4_, Tessellator p_148463_5_) + { + String s = (String)GuiScreenConfigureWorld.this.field_146885_g.field_148806_f.get(p_148463_1_); + GuiScreenConfigureWorld.this.drawString(GuiScreenConfigureWorld.this.fontRendererObj, s, p_148463_2_ + 2, p_148463_3_ + 1, 16777215); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiScreenConfirmation.java b/src/main/java/net/minecraft/client/gui/GuiScreenConfirmation.java new file mode 100644 index 0000000..382d211 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiScreenConfirmation.java @@ -0,0 +1,66 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.resources.I18n; + +@SideOnly(Side.CLIENT) +public class GuiScreenConfirmation extends GuiScreen +{ + private final GuiScreenConfirmation.ConfirmationType field_146937_i; + private final String field_146934_r; + private final String field_146933_s; + protected final GuiScreen field_146935_a; + protected final String field_146931_f; + protected final String field_146932_g; + protected final int field_146936_h; + private static final String __OBFID = "CL_00000781"; + + public GuiScreenConfirmation(GuiScreen par1GuiScreen, GuiScreenConfirmation.ConfirmationType par2GuiScreenConfirmationType, String par3Str, String par4Str, int par5) + { + this.field_146935_a = par1GuiScreen; + this.field_146936_h = par5; + this.field_146937_i = par2GuiScreenConfirmationType; + this.field_146934_r = par3Str; + this.field_146933_s = par4Str; + this.field_146931_f = I18n.format("gui.yes", new Object[0]); + this.field_146932_g = I18n.format("gui.no", new Object[0]); + } + + public void initGui() + { + this.buttonList.add(new GuiOptionButton(0, this.width / 2 - 155, this.height / 6 + 112, this.field_146931_f)); + this.buttonList.add(new GuiOptionButton(1, this.width / 2 - 155 + 160, this.height / 6 + 112, this.field_146932_g)); + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + this.field_146935_a.confirmClicked(p_146284_1_.id == 0, this.field_146936_h); + } + + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + this.drawCenteredString(this.fontRendererObj, this.field_146937_i.field_148515_d, this.width / 2, 70, this.field_146937_i.field_148518_c); + this.drawCenteredString(this.fontRendererObj, this.field_146934_r, this.width / 2, 90, 16777215); + this.drawCenteredString(this.fontRendererObj, this.field_146933_s, this.width / 2, 110, 16777215); + super.drawScreen(par1, par2, par3); + } + + @SideOnly(Side.CLIENT) + public static enum ConfirmationType + { + Warning("Warning!", 16711680), + Info("Info!", 8226750); + public final int field_148518_c; + public final String field_148515_d; + + private static final String __OBFID = "CL_00000782"; + + private ConfirmationType(String par3Str, int par4) + { + this.field_148515_d = par3Str; + this.field_148518_c = par4; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiScreenDemo.java b/src/main/java/net/minecraft/client/gui/GuiScreenDemo.java new file mode 100644 index 0000000..3ae5105 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiScreenDemo.java @@ -0,0 +1,83 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.net.URI; +import net.minecraft.client.resources.I18n; +import net.minecraft.client.settings.GameSettings; +import net.minecraft.util.ResourceLocation; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class GuiScreenDemo extends GuiScreen +{ + private static final Logger logger = LogManager.getLogger(); + private static final ResourceLocation field_146348_f = new ResourceLocation("textures/gui/demo_background.png"); + private static final String __OBFID = "CL_00000691"; + + public void initGui() + { + this.buttonList.clear(); + byte b0 = -16; + this.buttonList.add(new GuiButton(1, this.width / 2 - 116, this.height / 2 + 62 + b0, 114, 20, I18n.format("demo.help.buy", new Object[0]))); + this.buttonList.add(new GuiButton(2, this.width / 2 + 2, this.height / 2 + 62 + b0, 114, 20, I18n.format("demo.help.later", new Object[0]))); + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + switch (p_146284_1_.id) + { + case 1: + p_146284_1_.enabled = false; + + try + { + Class oclass = Class.forName("java.awt.Desktop"); + Object object = oclass.getMethod("getDesktop", new Class[0]).invoke((Object)null, new Object[0]); + oclass.getMethod("browse", new Class[] {URI.class}).invoke(object, new Object[] {new URI("http://www.minecraft.net/store?source=demo")}); + } + catch (Throwable throwable) + { + logger.error("Couldn\'t open link", throwable); + } + + break; + case 2: + this.mc.displayGuiScreen((GuiScreen)null); + this.mc.setIngameFocus(); + } + } + + public void updateScreen() + { + super.updateScreen(); + } + + public void drawDefaultBackground() + { + super.drawDefaultBackground(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(field_146348_f); + int i = (this.width - 248) / 2; + int j = (this.height - 166) / 2; + this.drawTexturedModalRect(i, j, 0, 0, 248, 166); + } + + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + int k = (this.width - 248) / 2 + 10; + int l = (this.height - 166) / 2 + 8; + this.fontRendererObj.drawString(I18n.format("demo.help.title", new Object[0]), k, l, 2039583); + l += 12; + GameSettings gamesettings = this.mc.gameSettings; + this.fontRendererObj.drawString(I18n.format("demo.help.movementShort", new Object[] {GameSettings.getKeyDisplayString(gamesettings.keyBindForward.getKeyCode()), GameSettings.getKeyDisplayString(gamesettings.keyBindLeft.getKeyCode()), GameSettings.getKeyDisplayString(gamesettings.keyBindBack.getKeyCode()), GameSettings.getKeyDisplayString(gamesettings.keyBindRight.getKeyCode())}), k, l, 5197647); + this.fontRendererObj.drawString(I18n.format("demo.help.movementMouse", new Object[0]), k, l + 12, 5197647); + this.fontRendererObj.drawString(I18n.format("demo.help.jump", new Object[] {GameSettings.getKeyDisplayString(gamesettings.keyBindJump.getKeyCode())}), k, l + 24, 5197647); + this.fontRendererObj.drawString(I18n.format("demo.help.inventory", new Object[] {GameSettings.getKeyDisplayString(gamesettings.keyBindInventory.getKeyCode())}), k, l + 36, 5197647); + this.fontRendererObj.drawSplitString(I18n.format("demo.help.fullWrapped", new Object[0]), k, l + 68, 218, 2039583); + super.drawScreen(par1, par2, par3); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiScreenDisconnectedOnline.java b/src/main/java/net/minecraft/client/gui/GuiScreenDisconnectedOnline.java new file mode 100644 index 0000000..e6077fb --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiScreenDisconnectedOnline.java @@ -0,0 +1,60 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Iterator; +import java.util.List; +import net.minecraft.client.resources.I18n; +import net.minecraft.util.IChatComponent; + +@SideOnly(Side.CLIENT) +public class GuiScreenDisconnectedOnline extends GuiScreen +{ + private String field_146867_a; + private IChatComponent field_146865_f; + private List field_146866_g; + private final GuiScreen field_146868_h; + private static final String __OBFID = "CL_00000778"; + + public GuiScreenDisconnectedOnline(GuiScreen p_i45037_1_, String p_i45037_2_, IChatComponent p_i45037_3_) + { + this.field_146868_h = p_i45037_1_; + this.field_146867_a = I18n.format(p_i45037_2_, new Object[0]); + this.field_146865_f = p_i45037_3_; + } + + protected void keyTyped(char par1, int par2) {} + + public void initGui() + { + this.buttonList.clear(); + this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 120 + 12, I18n.format("gui.back", new Object[0]))); + this.field_146866_g = this.fontRendererObj.listFormattedStringToWidth(this.field_146865_f.getFormattedText(), this.width - 50); + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.id == 0) + { + this.mc.displayGuiScreen(this.field_146868_h); + } + } + + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + this.drawCenteredString(this.fontRendererObj, this.field_146867_a, this.width / 2, this.height / 2 - 50, 11184810); + int k = this.height / 2 - 30; + + if (this.field_146866_g != null) + { + for (Iterator iterator = this.field_146866_g.iterator(); iterator.hasNext(); k += this.fontRendererObj.FONT_HEIGHT) + { + String s = (String)iterator.next(); + this.drawCenteredString(this.fontRendererObj, s, this.width / 2, k, 16777215); + } + } + + super.drawScreen(par1, par2, par3); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiScreenEditOnlineWorld.java b/src/main/java/net/minecraft/client/gui/GuiScreenEditOnlineWorld.java new file mode 100644 index 0000000..2e942d0 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiScreenEditOnlineWorld.java @@ -0,0 +1,156 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.UnsupportedEncodingException; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.mco.GuiScreenResetWorld; +import net.minecraft.client.mco.ExceptionMcoService; +import net.minecraft.client.mco.McoClient; +import net.minecraft.client.mco.McoServer; +import net.minecraft.client.resources.I18n; +import net.minecraft.util.Session; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.lwjgl.input.Keyboard; + +@SideOnly(Side.CLIENT) +public class GuiScreenEditOnlineWorld extends GuiScreen +{ + private static final Logger logger = LogManager.getLogger(); + private GuiScreen field_146855_f; + private GuiScreen field_146857_g; + private GuiTextField field_146863_h; + private GuiTextField field_146864_i; + private McoServer field_146861_r; + private GuiButton field_146860_s; + private int field_146859_t; + private int field_146858_u; + private int field_146856_v; + private GuiScreenOnlineServersSubscreen field_146854_w; + private static final String __OBFID = "CL_00000779"; + + public GuiScreenEditOnlineWorld(GuiScreen par1GuiScreen, GuiScreen par2GuiScreen, McoServer par3McoServer) + { + this.field_146855_f = par1GuiScreen; + this.field_146857_g = par2GuiScreen; + this.field_146861_r = par3McoServer; + } + + public void updateScreen() + { + this.field_146864_i.updateCursorCounter(); + this.field_146863_h.updateCursorCounter(); + } + + public void initGui() + { + this.field_146859_t = this.width / 4; + this.field_146858_u = this.width / 4 - 2; + this.field_146856_v = this.width / 2 + 4; + Keyboard.enableRepeatEvents(true); + this.buttonList.clear(); + this.buttonList.add(this.field_146860_s = new GuiButton(0, this.field_146859_t, this.height / 4 + 120 + 22, this.field_146858_u, 20, I18n.format("mco.configure.world.buttons.done", new Object[0]))); + this.buttonList.add(new GuiButton(1, this.field_146856_v, this.height / 4 + 120 + 22, this.field_146858_u, 20, I18n.format("gui.cancel", new Object[0]))); + this.field_146864_i = new GuiTextField(this.fontRendererObj, this.field_146859_t, 56, 212, 20); + this.field_146864_i.setFocused(true); + this.field_146864_i.setMaxStringLength(32); + this.field_146864_i.setText(this.field_146861_r.func_148801_b()); + this.field_146863_h = new GuiTextField(this.fontRendererObj, this.field_146859_t, 96, 212, 20); + this.field_146863_h.setMaxStringLength(32); + this.field_146863_h.setText(this.field_146861_r.func_148800_a()); + this.field_146854_w = new GuiScreenOnlineServersSubscreen(this.width, this.height, this.field_146859_t, 122, this.field_146861_r.field_148820_i, this.field_146861_r.field_148817_j); + this.buttonList.addAll(this.field_146854_w.field_148405_a); + } + + public void onGuiClosed() + { + Keyboard.enableRepeatEvents(false); + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.enabled) + { + if (p_146284_1_.id == 1) + { + this.mc.displayGuiScreen(this.field_146855_f); + } + else if (p_146284_1_.id == 0) + { + this.func_146853_g(); + } + else if (p_146284_1_.id == 2) + { + this.mc.displayGuiScreen(new GuiScreenResetWorld(this, this.field_146861_r)); + } + else + { + this.field_146854_w.func_148397_a(p_146284_1_); + } + } + } + + private void func_146853_g() + { + Session session = this.mc.getSession(); + McoClient mcoclient = new McoClient(session.getSessionID(), session.getUsername(), "1.7.2", Minecraft.getMinecraft().getProxy()); + + try + { + String s = this.field_146863_h.getText() != null && !this.field_146863_h.getText().trim().equals("") ? this.field_146863_h.getText() : null; + mcoclient.func_148689_a(this.field_146861_r.field_148812_a, this.field_146864_i.getText(), s, this.field_146854_w.field_148402_e, this.field_146854_w.field_148399_f); + this.field_146861_r.func_148803_a(this.field_146864_i.getText()); + this.field_146861_r.func_148804_b(this.field_146863_h.getText()); + this.field_146861_r.field_148820_i = this.field_146854_w.field_148402_e; + this.field_146861_r.field_148817_j = this.field_146854_w.field_148399_f; + this.mc.displayGuiScreen(new GuiScreenConfigureWorld(this.field_146857_g, this.field_146861_r)); + } + catch (ExceptionMcoService exceptionmcoservice) + { + logger.error("Couldn\'t edit world"); + } + catch (UnsupportedEncodingException unsupportedencodingexception) + { + logger.error("Couldn\'t edit world"); + } + } + + protected void keyTyped(char par1, int par2) + { + this.field_146864_i.textboxKeyTyped(par1, par2); + this.field_146863_h.textboxKeyTyped(par1, par2); + + if (par2 == 15) + { + this.field_146864_i.setFocused(!this.field_146864_i.isFocused()); + this.field_146863_h.setFocused(!this.field_146863_h.isFocused()); + } + + if (par2 == 28 || par2 == 156) + { + this.func_146853_g(); + } + + this.field_146860_s.enabled = this.field_146864_i.getText() != null && !this.field_146864_i.getText().trim().equals(""); + } + + protected void mouseClicked(int par1, int par2, int par3) + { + super.mouseClicked(par1, par2, par3); + this.field_146863_h.mouseClicked(par1, par2, par3); + this.field_146864_i.mouseClicked(par1, par2, par3); + } + + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + this.drawCenteredString(this.fontRendererObj, I18n.format("mco.configure.world.edit.title", new Object[0]), this.width / 2, 17, 16777215); + this.drawString(this.fontRendererObj, I18n.format("mco.configure.world.name", new Object[0]), this.field_146859_t, 43, 10526880); + this.drawString(this.fontRendererObj, I18n.format("mco.configure.world.description", new Object[0]), this.field_146859_t, 84, 10526880); + this.field_146864_i.drawTextBox(); + this.field_146863_h.drawTextBox(); + this.field_146854_w.func_148394_a(this, this.fontRendererObj); + super.drawScreen(par1, par2, par3); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiScreenInvite.java b/src/main/java/net/minecraft/client/gui/GuiScreenInvite.java new file mode 100644 index 0000000..9a5bc01 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiScreenInvite.java @@ -0,0 +1,151 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.client.Minecraft; +import net.minecraft.client.mco.ExceptionMcoService; +import net.minecraft.client.mco.McoClient; +import net.minecraft.client.mco.McoServer; +import net.minecraft.client.resources.I18n; +import net.minecraft.util.Session; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.lwjgl.input.Keyboard; + +@SideOnly(Side.CLIENT) +public class GuiScreenInvite extends GuiScreen +{ + private static final Logger logger = LogManager.getLogger(); + private GuiTextField field_146921_f; + private McoServer field_146923_g; + private final GuiScreen field_146929_h; + private final GuiScreenConfigureWorld field_146930_i; + private final int field_146927_r = 0; + private final int field_146926_s = 1; + private String field_146925_t = "Could not invite the provided name"; + private String field_146924_u; + private boolean field_146922_v; + private static final String __OBFID = "CL_00000780"; + + public GuiScreenInvite(GuiScreen par1GuiScreen, GuiScreenConfigureWorld par2GuiScreenConfigureWorld, McoServer par3McoServer) + { + this.field_146929_h = par1GuiScreen; + this.field_146930_i = par2GuiScreenConfigureWorld; + this.field_146923_g = par3McoServer; + } + + public void updateScreen() + { + this.field_146921_f.updateCursorCounter(); + } + + public void initGui() + { + Keyboard.enableRepeatEvents(true); + this.buttonList.clear(); + this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 96 + 12, I18n.format("mco.configure.world.buttons.invite", new Object[0]))); + this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 120 + 12, I18n.format("gui.cancel", new Object[0]))); + this.field_146921_f = new GuiTextField(this.fontRendererObj, this.width / 2 - 100, 66, 200, 20); + this.field_146921_f.setFocused(true); + } + + public void onGuiClosed() + { + Keyboard.enableRepeatEvents(false); + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.enabled) + { + if (p_146284_1_.id == 1) + { + this.mc.displayGuiScreen(this.field_146930_i); + } + else if (p_146284_1_.id == 0) + { + Session session = this.mc.getSession(); + McoClient mcoclient = new McoClient(session.getSessionID(), session.getUsername(), "1.7.2", Minecraft.getMinecraft().getProxy()); + + if (this.field_146921_f.getText() == null || this.field_146921_f.getText().isEmpty()) + { + return; + } + + try + { + McoServer mcoserver = mcoclient.func_148697_b(this.field_146923_g.field_148812_a, this.field_146921_f.getText()); + + if (mcoserver != null) + { + this.field_146923_g.field_148806_f = mcoserver.field_148806_f; + this.mc.displayGuiScreen(new GuiScreenConfigureWorld(this.field_146929_h, this.field_146923_g)); + } + else + { + this.func_146920_a(this.field_146925_t); + } + } + catch (ExceptionMcoService exceptionmcoservice) + { + logger.error("Couldn\'t invite user"); + this.func_146920_a(exceptionmcoservice.field_148829_b); + } + catch (IOException ioexception) + { + logger.error("Couldn\'t parse response inviting user", ioexception); + this.func_146920_a(this.field_146925_t); + } + } + } + } + + private void func_146920_a(String p_146920_1_) + { + this.field_146922_v = true; + this.field_146924_u = p_146920_1_; + } + + protected void keyTyped(char par1, int par2) + { + this.field_146921_f.textboxKeyTyped(par1, par2); + + if (par2 == 15) + { + if (this.field_146921_f.isFocused()) + { + this.field_146921_f.setFocused(false); + } + else + { + this.field_146921_f.setFocused(true); + } + } + + if (par2 == 28 || par2 == 156) + { + this.actionPerformed((GuiButton)this.buttonList.get(0)); + } + } + + protected void mouseClicked(int par1, int par2, int par3) + { + super.mouseClicked(par1, par2, par3); + this.field_146921_f.mouseClicked(par1, par2, par3); + } + + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + this.drawString(this.fontRendererObj, I18n.format("mco.configure.world.invite.profile.name", new Object[0]), this.width / 2 - 100, 53, 10526880); + + if (this.field_146922_v) + { + this.drawCenteredString(this.fontRendererObj, this.field_146924_u, this.width / 2, 100, 16711680); + } + + this.field_146921_f.drawTextBox(); + super.drawScreen(par1, par2, par3); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiScreenLongRunningTask.java b/src/main/java/net/minecraft/client/gui/GuiScreenLongRunningTask.java new file mode 100644 index 0000000..21a7499 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiScreenLongRunningTask.java @@ -0,0 +1,111 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.Collections; +import java.util.concurrent.atomic.AtomicInteger; +import net.minecraft.client.Minecraft; +import net.minecraft.client.resources.I18n; + +@SideOnly(Side.CLIENT) +public class GuiScreenLongRunningTask extends GuiScreen +{ + private static final AtomicInteger field_146908_f = new AtomicInteger(0); + private final int field_146910_g = 666; + private final int field_146917_h = 667; + private final GuiScreen field_146919_i; + private final Thread field_146914_r; + private volatile String field_146913_s = ""; + private volatile boolean field_146912_t; + private volatile String field_146911_u; + private volatile boolean field_146909_v; + private int field_146907_w; + private TaskLongRunning field_146918_x; + private int field_146916_y = 212; + public static final String[] field_146915_a = new String[] {"\u2583 \u2584 \u2585 \u2586 \u2587 \u2588 \u2587 \u2586 \u2585 \u2584 \u2583", "_ \u2583 \u2584 \u2585 \u2586 \u2587 \u2588 \u2587 \u2586 \u2585 \u2584", "_ _ \u2583 \u2584 \u2585 \u2586 \u2587 \u2588 \u2587 \u2586 \u2585", "_ _ _ \u2583 \u2584 \u2585 \u2586 \u2587 \u2588 \u2587 \u2586", "_ _ _ _ \u2583 \u2584 \u2585 \u2586 \u2587 \u2588 \u2587", "_ _ _ _ _ \u2583 \u2584 \u2585 \u2586 \u2587 \u2588", "_ _ _ _ \u2583 \u2584 \u2585 \u2586 \u2587 \u2588 \u2587", "_ _ _ \u2583 \u2584 \u2585 \u2586 \u2587 \u2588 \u2587 \u2586", "_ _ \u2583 \u2584 \u2585 \u2586 \u2587 \u2588 \u2587 \u2586 \u2585", "_ \u2583 \u2584 \u2585 \u2586 \u2587 \u2588 \u2587 \u2586 \u2585 \u2584", "\u2583 \u2584 \u2585 \u2586 \u2587 \u2588 \u2587 \u2586 \u2585 \u2584 \u2583", "\u2584 \u2585 \u2586 \u2587 \u2588 \u2587 \u2586 \u2585 \u2584 \u2583 _", "\u2585 \u2586 \u2587 \u2588 \u2587 \u2586 \u2585 \u2584 \u2583 _ _", "\u2586 \u2587 \u2588 \u2587 \u2586 \u2585 \u2584 \u2583 _ _ _", "\u2587 \u2588 \u2587 \u2586 \u2585 \u2584 \u2583 _ _ _ _", "\u2588 \u2587 \u2586 \u2585 \u2584 \u2583 _ _ _ _ _", "\u2587 \u2588 \u2587 \u2586 \u2585 \u2584 \u2583 _ _ _ _", "\u2586 \u2587 \u2588 \u2587 \u2586 \u2585 \u2584 \u2583 _ _ _", "\u2585 \u2586 \u2587 \u2588 \u2587 \u2586 \u2585 \u2584 \u2583 _ _", "\u2584 \u2585 \u2586 \u2587 \u2588 \u2587 \u2586 \u2585 \u2584 \u2583 _"}; + private static final String __OBFID = "CL_00000783"; + + public GuiScreenLongRunningTask(Minecraft par1Minecraft, GuiScreen par2GuiScreen, TaskLongRunning par3TaskLongRunning) + { + super.buttonList = Collections.synchronizedList(new ArrayList()); + this.mc = par1Minecraft; + this.field_146919_i = par2GuiScreen; + this.field_146918_x = par3TaskLongRunning; + par3TaskLongRunning.func_148412_a(this); + this.field_146914_r = new Thread(par3TaskLongRunning, "MCO Task #" + field_146908_f.incrementAndGet()); + } + + public void func_146902_g() + { + this.field_146914_r.start(); + } + + public void updateScreen() + { + super.updateScreen(); + ++this.field_146907_w; + this.field_146918_x.func_148414_a(); + } + + protected void keyTyped(char par1, int par2) {} + + public void initGui() + { + this.field_146918_x.func_148411_d(); + this.buttonList.add(new GuiButton(666, this.width / 2 - this.field_146916_y / 2, 170, this.field_146916_y, 20, I18n.format("gui.cancel", new Object[0]))); + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.id == 666 || p_146284_1_.id == 667) + { + this.field_146909_v = true; + this.mc.displayGuiScreen(this.field_146919_i); + } + + this.field_146918_x.func_148415_a(p_146284_1_); + } + + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + this.drawCenteredString(this.fontRendererObj, this.field_146913_s, this.width / 2, this.height / 2 - 50, 16777215); + this.drawCenteredString(this.fontRendererObj, "", this.width / 2, this.height / 2 - 10, 16777215); + + if (!this.field_146912_t) + { + this.drawCenteredString(this.fontRendererObj, field_146915_a[this.field_146907_w % field_146915_a.length], this.width / 2, this.height / 2 + 15, 8421504); + } + + if (this.field_146912_t) + { + this.drawCenteredString(this.fontRendererObj, this.field_146911_u, this.width / 2, this.height / 2 + 15, 16711680); + } + + super.drawScreen(par1, par2, par3); + } + + public void func_146905_a(String p_146905_1_) + { + this.field_146912_t = true; + this.field_146911_u = p_146905_1_; + this.buttonList.clear(); + this.buttonList.add(new GuiButton(667, this.width / 2 - this.field_146916_y / 2, this.height / 4 + 120 + 12, I18n.format("gui.back", new Object[0]))); + } + + public Minecraft func_146903_h() + { + return this.mc; + } + + public void func_146906_b(String p_146906_1_) + { + this.field_146913_s = p_146906_1_; + } + + public boolean func_146904_i() + { + return this.field_146909_v; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiScreenOnlineServers.java b/src/main/java/net/minecraft/client/gui/GuiScreenOnlineServers.java new file mode 100644 index 0000000..98e2fee --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiScreenOnlineServers.java @@ -0,0 +1,697 @@ +package net.minecraft.client.gui; + +import com.google.common.collect.Lists; +import com.google.common.util.concurrent.ThreadFactoryBuilder; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import java.net.UnknownHostException; +import java.util.Iterator; +import java.util.List; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.atomic.AtomicInteger; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.mco.GuiScreenCreateOnlineWorld; +import net.minecraft.client.gui.mco.GuiScreenPendingInvitation; +import net.minecraft.client.mco.ExceptionMcoService; +import net.minecraft.client.mco.McoClient; +import net.minecraft.client.mco.McoServer; +import net.minecraft.client.mco.McoServerList; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.resources.I18n; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Session; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class GuiScreenOnlineServers extends GuiScreen +{ + private static final AtomicInteger field_146701_a = new AtomicInteger(0); + private static final Logger logger = LogManager.getLogger(); + private static final ResourceLocation field_146697_g = new ResourceLocation("textures/gui/widgets.png"); + private static final ResourceLocation field_146702_h = new ResourceLocation("textures/gui/title/minecraft.png"); + private static McoServerList field_146703_i = new McoServerList(); + private static GuiScreenRealmsPinger field_146709_r = new GuiScreenRealmsPinger(); + private static final ThreadPoolExecutor field_146708_s = new ScheduledThreadPoolExecutor(5, (new ThreadFactoryBuilder()).setNameFormat("Server Pinger #%d").setDaemon(true).build()); + private GuiScreen field_146707_t; + private GuiScreenOnlineServers.OnlineServerList field_146706_u; + private long field_146705_v = -1L; + private GuiButton field_146704_w; + private GuiButton field_146712_x; + private GuiButtonLink field_146711_y; + private GuiButton field_146710_z; + private String field_146698_A; + private boolean field_146699_B; + private List field_146700_C = Lists.newArrayList(); + private volatile int field_146694_D = 0; + private int field_146696_E; + private static final String __OBFID = "CL_00000792"; + + public GuiScreenOnlineServers(GuiScreen par1GuiScreen) + { + this.field_146707_t = par1GuiScreen; + } + + public void initGui() + { + Keyboard.enableRepeatEvents(true); + this.buttonList.clear(); + field_146703_i.func_148475_a(this.mc.getSession()); + + if (!this.field_146699_B) + { + this.field_146699_B = true; + this.field_146706_u = new GuiScreenOnlineServers.OnlineServerList(); + } + else + { + this.field_146706_u.func_148346_a(this.width, this.height, 32, this.height - 64); + } + + this.func_146688_g(); + } + + public void func_146688_g() + { + this.buttonList.add(this.field_146710_z = new GuiButton(1, this.width / 2 - 154, this.height - 52, 100, 20, I18n.format("mco.selectServer.play", new Object[0]))); + String s = this.field_146694_D > 0 ? I18n.format("mco.selectServer.create", new Object[0]) : I18n.format("mco.selectServer.buy", new Object[0]); + this.buttonList.add(this.field_146712_x = new GuiButton(2, this.width / 2 - 48, this.height - 52, 100, 20, s)); + this.buttonList.add(this.field_146704_w = new GuiButton(3, this.width / 2 + 58, this.height - 52, 100, 20, I18n.format("mco.selectServer.configure", new Object[0]))); + this.buttonList.add(this.field_146711_y = new GuiButtonLink(4, this.width / 2 - 154, this.height - 28, 154, 20, I18n.format("mco.selectServer.moreinfo", new Object[0]))); + this.buttonList.add(new GuiButton(0, this.width / 2 + 6, this.height - 28, 153, 20, I18n.format("gui.cancel", new Object[0]))); + McoServer mcoserver = this.func_146691_a(this.field_146705_v); + this.field_146710_z.enabled = mcoserver != null && mcoserver.field_148808_d.equals(McoServer.State.OPEN.name()) && !mcoserver.field_148819_h; + this.field_146704_w.enabled = mcoserver != null && !mcoserver.field_148808_d.equals(McoServer.State.ADMIN_LOCK.name()); + + if (mcoserver != null && !mcoserver.field_148809_e.equals(this.mc.getSession().getUsername())) + { + this.field_146704_w.displayString = I18n.format("mco.selectServer.leave", new Object[0]); + } + } + + public void updateScreen() + { + super.updateScreen(); + ++this.field_146696_E; + + if (field_146703_i.func_148472_a()) + { + List list = field_146703_i.func_148473_c(); + Iterator iterator = list.iterator(); + + while (iterator.hasNext()) + { + McoServer mcoserver = (McoServer)iterator.next(); + Iterator iterator1 = this.field_146700_C.iterator(); + + while (iterator1.hasNext()) + { + McoServer mcoserver1 = (McoServer)iterator1.next(); + + if (mcoserver.field_148812_a == mcoserver1.field_148812_a) + { + mcoserver.func_148799_a(mcoserver1); + break; + } + } + } + + this.field_146694_D = field_146703_i.func_148469_e(); + this.field_146700_C = list; + field_146703_i.func_148479_b(); + } + + this.field_146712_x.displayString = this.field_146694_D > 0 ? I18n.format("mco.selectServer.create", new Object[0]) : I18n.format("mco.selectServer.buy", new Object[0]); + } + + public void onGuiClosed() + { + Keyboard.enableRepeatEvents(false); + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.enabled) + { + if (p_146284_1_.id == 1) + { + this.func_146656_d(this.field_146705_v); + } + else if (p_146284_1_.id == 3) + { + this.func_146667_u(); + } + else if (p_146284_1_.id == 0) + { + this.func_146669_s(); + this.mc.displayGuiScreen(this.field_146707_t); + } + else if (p_146284_1_.id == 2) + { + this.func_146669_s(); + this.mc.displayGuiScreen((GuiScreen)(this.field_146694_D > 0 ? new GuiScreenCreateOnlineWorld(this) : new GuiScreenBuyRealms(this))); + } + else if (p_146284_1_.id == 4) + { + this.func_146660_t(); + } + else + { + this.field_146706_u.func_148357_a(p_146284_1_); + } + } + } + + private void func_146669_s() + { + field_146703_i.func_148476_f(); + field_146709_r.func_148507_b(); + } + + private void func_146660_t() + { + String s = I18n.format("mco.more.info.question.line1", new Object[0]); + String s1 = I18n.format("mco.more.info.question.line2", new Object[0]); + this.mc.displayGuiScreen(new GuiScreenConfirmation(this, GuiScreenConfirmation.ConfirmationType.Info, s, s1, 4)); + } + + private void func_146667_u() + { + McoServer mcoserver = this.func_146691_a(this.field_146705_v); + + if (mcoserver != null) + { + if (this.mc.getSession().getUsername().equals(mcoserver.field_148809_e)) + { + McoServer mcoserver1 = this.func_146677_c(mcoserver.field_148812_a); + + if (mcoserver1 != null) + { + this.func_146669_s(); + this.mc.displayGuiScreen(new GuiScreenConfigureWorld(this, mcoserver1)); + } + } + else + { + String s1 = I18n.format("mco.configure.world.leave.question.line1", new Object[0]); + String s = I18n.format("mco.configure.world.leave.question.line2", new Object[0]); + this.mc.displayGuiScreen(new GuiScreenConfirmation(this, GuiScreenConfirmation.ConfirmationType.Info, s1, s, 3)); + } + } + } + + private McoServer func_146691_a(long p_146691_1_) + { + Iterator iterator = this.field_146700_C.iterator(); + McoServer mcoserver; + + do + { + if (!iterator.hasNext()) + { + return null; + } + + mcoserver = (McoServer)iterator.next(); + } + while (mcoserver.field_148812_a != p_146691_1_); + + return mcoserver; + } + + private int func_146672_b(long p_146672_1_) + { + for (int j = 0; j < this.field_146700_C.size(); ++j) + { + if (((McoServer)this.field_146700_C.get(j)).field_148812_a == p_146672_1_) + { + return j; + } + } + + return -1; + } + + public void confirmClicked(boolean par1, int par2) + { + if (par2 == 3 && par1) + { + (new Thread("MCO Configure Requester #" + field_146701_a.incrementAndGet()) + { + private static final String __OBFID = "CL_00000793"; + public void run() + { + try + { + McoServer mcoserver = GuiScreenOnlineServers.this.func_146691_a(GuiScreenOnlineServers.this.field_146705_v); + + if (mcoserver != null) + { + Session session = GuiScreenOnlineServers.this.mc.getSession(); + McoClient mcoclient = new McoClient(session.getSessionID(), session.getUsername(), "1.7.2", Minecraft.getMinecraft().getProxy()); + GuiScreenOnlineServers.field_146703_i.func_148470_a(mcoserver); + GuiScreenOnlineServers.this.field_146700_C.remove(mcoserver); + mcoclient.func_148698_c(mcoserver.field_148812_a); + GuiScreenOnlineServers.field_146703_i.func_148470_a(mcoserver); + GuiScreenOnlineServers.this.field_146700_C.remove(mcoserver); + GuiScreenOnlineServers.this.func_146685_v(); + } + } + catch (ExceptionMcoService exceptionmcoservice) + { + GuiScreenOnlineServers.logger.error("Couldn\'t configure world"); + } + } + }).start(); + } + else if (par2 == 4 && par1) + { + this.field_146711_y.openURI("http://realms.minecraft.net/"); + } + + this.mc.displayGuiScreen(this); + } + + private void func_146685_v() + { + int i = this.func_146672_b(this.field_146705_v); + + if (this.field_146700_C.size() - 1 == i) + { + --i; + } + + if (this.field_146700_C.size() == 0) + { + i = -1; + } + + if (i >= 0 && i < this.field_146700_C.size()) + { + this.field_146705_v = ((McoServer)this.field_146700_C.get(i)).field_148812_a; + } + } + + public void func_146670_h() + { + this.field_146705_v = -1L; + } + + private McoServer func_146677_c(long p_146677_1_) + { + Session session = this.mc.getSession(); + McoClient mcoclient = new McoClient(session.getSessionID(), session.getUsername(), "1.7.2", Minecraft.getMinecraft().getProxy()); + + try + { + return mcoclient.func_148709_a(p_146677_1_); + } + catch (ExceptionMcoService exceptionmcoservice) + { + logger.error("Couldn\'t get own world"); + } + catch (IOException ioexception) + { + logger.error("Couldn\'t parse response getting own world"); + } + + return null; + } + + protected void keyTyped(char par1, int par2) + { + if (par2 == 59) + { + this.mc.gameSettings.hideServerAddress = !this.mc.gameSettings.hideServerAddress; + this.mc.gameSettings.saveOptions(); + } + else + { + if (par2 != 28 && par2 != 156) + { + super.keyTyped(par1, par2); + } + else + { + this.actionPerformed((GuiButton)this.buttonList.get(0)); + } + } + } + + public void drawScreen(int par1, int par2, float par3) + { + this.field_146698_A = null; + this.drawDefaultBackground(); + this.field_146706_u.func_148350_a(par1, par2, par3); + this.func_146665_b(this.width / 2 - 50, 7); + super.drawScreen(par1, par2, par3); + + if (this.field_146698_A != null) + { + this.func_146658_b(this.field_146698_A, par1, par2); + } + + this.func_146659_c(par1, par2); + } + + private void func_146665_b(int p_146665_1_, int p_146665_2_) + { + this.mc.getTextureManager().bindTexture(field_146702_h); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glPushMatrix(); + GL11.glScalef(0.5F, 0.5F, 0.5F); + this.drawTexturedModalRect(p_146665_1_ * 2, p_146665_2_ * 2, 0, 97, 200, 50); + GL11.glPopMatrix(); + } + + protected void mouseClicked(int par1, int par2, int par3) + { + super.mouseClicked(par1, par2, par3); + + if (this.func_146662_d(par1, par2) && field_146703_i.func_148468_d() != 0) + { + this.func_146669_s(); + GuiScreenPendingInvitation guiscreenpendinginvitation = new GuiScreenPendingInvitation(this.field_146707_t); + this.mc.displayGuiScreen(guiscreenpendinginvitation); + } + } + + private void func_146659_c(int p_146659_1_, int p_146659_2_) + { + int k = field_146703_i.func_148468_d(); + boolean flag = this.func_146662_d(p_146659_1_, p_146659_2_); + this.mc.getTextureManager().bindTexture(field_146697_g); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glPushMatrix(); + this.drawTexturedModalRect(this.width / 2 + 58, 12, flag ? 166 : 182, 22, 16, 16); + GL11.glPopMatrix(); + int l; + int i1; + + if (k != 0) + { + l = 198 + (Math.min(k, 6) - 1) * 8; + i1 = (int)(Math.max(0.0F, Math.max(MathHelper.sin((float)(10 + this.field_146696_E) * 0.57F), MathHelper.cos((float)this.field_146696_E * 0.35F))) * -6.0F); + this.mc.getTextureManager().bindTexture(field_146697_g); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glPushMatrix(); + this.drawTexturedModalRect(this.width / 2 + 58 + 4, 16 + i1, l, 22, 8, 8); + GL11.glPopMatrix(); + } + + if (flag) + { + l = p_146659_1_ + 12; + i1 = p_146659_2_ - 12; + String s = ""; + + if (k != 0) + { + s = I18n.format("mco.invites.pending", new Object[0]); + } + else + { + s = I18n.format("mco.invites.nopending", new Object[0]); + } + + int j1 = this.fontRendererObj.getStringWidth(s); + this.drawGradientRect(l - 3, i1 - 3, l + j1 + 3, i1 + 8 + 3, -1073741824, -1073741824); + this.fontRendererObj.drawStringWithShadow(s, l, i1, -1); + } + } + + private boolean func_146662_d(int p_146662_1_, int p_146662_2_) + { + int k = this.width / 2 + 56; + int l = this.width / 2 + 78; + byte b0 = 13; + byte b1 = 27; + return k <= p_146662_1_ && p_146662_1_ <= l && b0 <= p_146662_2_ && p_146662_2_ <= b1; + } + + private void func_146656_d(long p_146656_1_) + { + McoServer mcoserver = this.func_146691_a(p_146656_1_); + + if (mcoserver != null) + { + this.func_146669_s(); + GuiScreenLongRunningTask guiscreenlongrunningtask = new GuiScreenLongRunningTask(this.mc, this, new TaskOnlineConnect(this, mcoserver)); + guiscreenlongrunningtask.func_146902_g(); + this.mc.displayGuiScreen(guiscreenlongrunningtask); + } + } + + private void func_146661_c(int p_146661_1_, int p_146661_2_, int p_146661_3_, int p_146661_4_) + { + this.mc.getTextureManager().bindTexture(field_146697_g); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glPushMatrix(); + GL11.glScalef(0.5F, 0.5F, 0.5F); + this.drawTexturedModalRect(p_146661_1_ * 2, p_146661_2_ * 2, 191, 0, 16, 15); + GL11.glPopMatrix(); + + if (p_146661_3_ >= p_146661_1_ && p_146661_3_ <= p_146661_1_ + 9 && p_146661_4_ >= p_146661_2_ && p_146661_4_ <= p_146661_2_ + 9) + { + this.field_146698_A = I18n.format("mco.selectServer.expired", new Object[0]); + } + } + + private void func_146687_b(int p_146687_1_, int p_146687_2_, int p_146687_3_, int p_146687_4_, int p_146687_5_) + { + if (this.field_146696_E % 20 < 10) + { + this.mc.getTextureManager().bindTexture(field_146697_g); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glPushMatrix(); + GL11.glScalef(0.5F, 0.5F, 0.5F); + this.drawTexturedModalRect(p_146687_1_ * 2, p_146687_2_ * 2, 207, 0, 16, 15); + GL11.glPopMatrix(); + } + + if (p_146687_3_ >= p_146687_1_ && p_146687_3_ <= p_146687_1_ + 9 && p_146687_4_ >= p_146687_2_ && p_146687_4_ <= p_146687_2_ + 9) + { + if (p_146687_5_ == 0) + { + this.field_146698_A = I18n.format("mco.selectServer.expires.soon", new Object[0]); + } + else if (p_146687_5_ == 1) + { + this.field_146698_A = I18n.format("mco.selectServer.expires.day", new Object[0]); + } + else + { + this.field_146698_A = I18n.format("mco.selectServer.expires.days", new Object[] {Integer.valueOf(p_146687_5_)}); + } + } + } + + private void func_146683_d(int p_146683_1_, int p_146683_2_, int p_146683_3_, int p_146683_4_) + { + this.mc.getTextureManager().bindTexture(field_146697_g); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glPushMatrix(); + GL11.glScalef(0.5F, 0.5F, 0.5F); + this.drawTexturedModalRect(p_146683_1_ * 2, p_146683_2_ * 2, 207, 0, 16, 15); + GL11.glPopMatrix(); + + if (p_146683_3_ >= p_146683_1_ && p_146683_3_ <= p_146683_1_ + 9 && p_146683_4_ >= p_146683_2_ && p_146683_4_ <= p_146683_2_ + 9) + { + this.field_146698_A = I18n.format("mco.selectServer.open", new Object[0]); + } + } + + private void func_146671_e(int p_146671_1_, int p_146671_2_, int p_146671_3_, int p_146671_4_) + { + this.mc.getTextureManager().bindTexture(field_146697_g); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glPushMatrix(); + GL11.glScalef(0.5F, 0.5F, 0.5F); + this.drawTexturedModalRect(p_146671_1_ * 2, p_146671_2_ * 2, 223, 0, 16, 15); + GL11.glPopMatrix(); + + if (p_146671_3_ >= p_146671_1_ && p_146671_3_ <= p_146671_1_ + 9 && p_146671_4_ >= p_146671_2_ && p_146671_4_ <= p_146671_2_ + 9) + { + this.field_146698_A = I18n.format("mco.selectServer.closed", new Object[0]); + } + } + + private void func_146666_f(int p_146666_1_, int p_146666_2_, int p_146666_3_, int p_146666_4_) + { + this.mc.getTextureManager().bindTexture(field_146697_g); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glPushMatrix(); + GL11.glScalef(0.5F, 0.5F, 0.5F); + this.drawTexturedModalRect(p_146666_1_ * 2, p_146666_2_ * 2, 223, 0, 16, 15); + GL11.glPopMatrix(); + + if (p_146666_3_ >= p_146666_1_ && p_146666_3_ <= p_146666_1_ + 9 && p_146666_4_ >= p_146666_2_ && p_146666_4_ <= p_146666_2_ + 9) + { + this.field_146698_A = I18n.format("mco.selectServer.locked", new Object[0]); + } + } + + protected void func_146658_b(String p_146658_1_, int p_146658_2_, int p_146658_3_) + { + if (p_146658_1_ != null) + { + int k = p_146658_2_ + 12; + int l = p_146658_3_ - 12; + int i1 = this.fontRendererObj.getStringWidth(p_146658_1_); + this.drawGradientRect(k - 3, l - 3, k + i1 + 3, l + 8 + 3, -1073741824, -1073741824); + this.fontRendererObj.drawStringWithShadow(p_146658_1_, k, l, -1); + } + } + + @SideOnly(Side.CLIENT) + class OnlineServerList extends GuiScreenSelectLocation + { + private static final String __OBFID = "CL_00000794"; + + public OnlineServerList() + { + super(GuiScreenOnlineServers.this.mc, GuiScreenOnlineServers.this.width, GuiScreenOnlineServers.this.height, 32, GuiScreenOnlineServers.this.height - 64, 36); + } + + protected int func_148355_a() + { + return GuiScreenOnlineServers.this.field_146700_C.size() + 1; + } + + protected void func_148352_a(int p_148352_1_, boolean p_148352_2_) + { + if (p_148352_1_ < GuiScreenOnlineServers.this.field_146700_C.size()) + { + McoServer mcoserver = (McoServer)GuiScreenOnlineServers.this.field_146700_C.get(p_148352_1_); + GuiScreenOnlineServers.this.field_146705_v = mcoserver.field_148812_a; + + if (!GuiScreenOnlineServers.this.mc.getSession().getUsername().equals(mcoserver.field_148809_e)) + { + GuiScreenOnlineServers.this.field_146704_w.displayString = I18n.format("mco.selectServer.leave", new Object[0]); + } + else + { + GuiScreenOnlineServers.this.field_146704_w.displayString = I18n.format("mco.selectServer.configure", new Object[0]); + } + + GuiScreenOnlineServers.this.field_146704_w.enabled = !mcoserver.field_148808_d.equals(McoServer.State.ADMIN_LOCK.name()); + GuiScreenOnlineServers.this.field_146710_z.enabled = mcoserver.field_148808_d.equals(McoServer.State.OPEN.name()) && !mcoserver.field_148819_h; + + if (p_148352_2_ && GuiScreenOnlineServers.this.field_146710_z.enabled) + { + GuiScreenOnlineServers.this.func_146656_d(GuiScreenOnlineServers.this.field_146705_v); + } + } + } + + protected boolean func_148356_a(int p_148356_1_) + { + return p_148356_1_ == GuiScreenOnlineServers.this.func_146672_b(GuiScreenOnlineServers.this.field_146705_v); + } + + protected boolean func_148349_b(int p_148349_1_) + { + try + { + return p_148349_1_ >= 0 && p_148349_1_ < GuiScreenOnlineServers.this.field_146700_C.size() && ((McoServer)GuiScreenOnlineServers.this.field_146700_C.get(p_148349_1_)).field_148809_e.toLowerCase().equals(GuiScreenOnlineServers.this.mc.getSession().getUsername()); + } + catch (Exception exception) + { + return false; + } + } + + protected int func_148351_b() + { + return this.func_148355_a() * 36; + } + + protected void func_148358_c() + { + GuiScreenOnlineServers.this.drawDefaultBackground(); + } + + protected void func_148348_a(int p_148348_1_, int p_148348_2_, int p_148348_3_, int p_148348_4_, Tessellator p_148348_5_) + { + if (p_148348_1_ < GuiScreenOnlineServers.this.field_146700_C.size()) + { + this.func_148390_b(p_148348_1_, p_148348_2_, p_148348_3_, p_148348_4_, p_148348_5_); + } + } + + private void func_148390_b(int p_148390_1_, int p_148390_2_, int p_148390_3_, int p_148390_4_, Tessellator p_148390_5_) + { + final McoServer mcoserver = (McoServer)GuiScreenOnlineServers.this.field_146700_C.get(p_148390_1_); + + if (!mcoserver.field_148814_o) + { + mcoserver.field_148814_o = true; + GuiScreenOnlineServers.field_146708_s.submit(new Runnable() + { + private static final String __OBFID = "CL_00000795"; + public void run() + { + try + { + GuiScreenOnlineServers.field_146709_r.func_148506_a(mcoserver); + } + catch (UnknownHostException unknownhostexception) + { + GuiScreenOnlineServers.logger.error("Pinger: Could not resolve host"); + } + } + }); + } + + GuiScreenOnlineServers.this.drawString(GuiScreenOnlineServers.this.fontRendererObj, mcoserver.func_148801_b(), p_148390_2_ + 2, p_148390_3_ + 1, 16777215); + short short1 = 207; + byte b0 = 1; + + if (mcoserver.field_148819_h) + { + GuiScreenOnlineServers.this.func_146661_c(p_148390_2_ + short1, p_148390_3_ + b0, this.field_148365_e, this.field_148362_f); + } + else if (mcoserver.field_148808_d.equals(McoServer.State.CLOSED.name())) + { + GuiScreenOnlineServers.this.func_146671_e(p_148390_2_ + short1, p_148390_3_ + b0, this.field_148365_e, this.field_148362_f); + } + else if (mcoserver.field_148809_e.equals(GuiScreenOnlineServers.this.mc.getSession().getUsername()) && mcoserver.field_148818_k < 7) + { + this.func_148389_a(p_148390_1_, p_148390_2_ - 14, p_148390_3_, mcoserver); + GuiScreenOnlineServers.this.func_146687_b(p_148390_2_ + short1, p_148390_3_ + b0, this.field_148365_e, this.field_148362_f, mcoserver.field_148818_k); + } + else if (mcoserver.field_148808_d.equals(McoServer.State.OPEN.name())) + { + GuiScreenOnlineServers.this.func_146683_d(p_148390_2_ + short1, p_148390_3_ + b0, this.field_148365_e, this.field_148362_f); + this.func_148389_a(p_148390_1_, p_148390_2_ - 14, p_148390_3_, mcoserver); + } + else if (mcoserver.field_148808_d.equals(McoServer.State.ADMIN_LOCK.name())) + { + GuiScreenOnlineServers.this.func_146666_f(p_148390_2_ + short1, p_148390_3_ + b0, this.field_148365_e, this.field_148362_f); + } + + GuiScreenOnlineServers.this.drawString(GuiScreenOnlineServers.this.fontRendererObj, mcoserver.field_148813_n, p_148390_2_ + 200 - GuiScreenOnlineServers.this.fontRendererObj.getStringWidth(mcoserver.field_148813_n), p_148390_3_ + 1, 8421504); + GuiScreenOnlineServers.this.drawString(GuiScreenOnlineServers.this.fontRendererObj, mcoserver.func_148800_a(), p_148390_2_ + 2, p_148390_3_ + 12, 7105644); + GuiScreenOnlineServers.this.drawString(GuiScreenOnlineServers.this.fontRendererObj, mcoserver.field_148809_e, p_148390_2_ + 2, p_148390_3_ + 12 + 11, 5000268); + } + + private void func_148389_a(int p_148389_1_, int p_148389_2_, int p_148389_3_, McoServer p_148389_4_) + { + if (p_148389_4_.field_148807_g != null) + { + if (p_148389_4_.field_148816_m != null) + { + GuiScreenOnlineServers.this.drawString(GuiScreenOnlineServers.this.fontRendererObj, p_148389_4_.field_148816_m, p_148389_2_ + 215 - GuiScreenOnlineServers.this.fontRendererObj.getStringWidth(p_148389_4_.field_148816_m), p_148389_3_ + 1, 8421504); + } + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GuiScreenOnlineServers.this.mc.getTextureManager().bindTexture(Gui.icons); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiScreenOnlineServersSubscreen.java b/src/main/java/net/minecraft/client/gui/GuiScreenOnlineServersSubscreen.java new file mode 100644 index 0000000..f67579d --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiScreenOnlineServersSubscreen.java @@ -0,0 +1,83 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.List; +import net.minecraft.client.resources.I18n; + +@SideOnly(Side.CLIENT) +public class GuiScreenOnlineServersSubscreen +{ + private final int field_148400_g; + private final int field_148407_h; + private final int field_148408_i; + private final int field_148406_j; + List field_148405_a = new ArrayList(); + String[] field_148403_b; + String[] field_148404_c; + String[][] field_148401_d; + int field_148402_e; + int field_148399_f; + private static final String __OBFID = "CL_00000796"; + + public GuiScreenOnlineServersSubscreen(int par1, int par2, int par3, int par4, int par5, int par6) + { + this.field_148400_g = par1; + this.field_148407_h = par2; + this.field_148408_i = par3; + this.field_148406_j = par4; + this.field_148402_e = par5; + this.field_148399_f = par6; + this.func_148395_a(); + } + + private void func_148395_a() + { + this.func_148396_b(); + this.field_148405_a.add(new GuiButton(5005, this.field_148408_i, this.field_148406_j + 1, 212, 20, this.func_148398_c())); + this.field_148405_a.add(new GuiButton(5006, this.field_148408_i, this.field_148406_j + 25, 212, 20, this.func_148393_d())); + } + + private void func_148396_b() + { + this.field_148403_b = new String[] {I18n.format("options.difficulty.peaceful", new Object[0]), I18n.format("options.difficulty.easy", new Object[0]), I18n.format("options.difficulty.normal", new Object[0]), I18n.format("options.difficulty.hard", new Object[0])}; + this.field_148404_c = new String[] {I18n.format("selectWorld.gameMode.survival", new Object[0]), I18n.format("selectWorld.gameMode.creative", new Object[0]), I18n.format("selectWorld.gameMode.adventure", new Object[0])}; + this.field_148401_d = new String[][] {{I18n.format("selectWorld.gameMode.survival.line1", new Object[0]), I18n.format("selectWorld.gameMode.survival.line2", new Object[0])}, {I18n.format("selectWorld.gameMode.creative.line1", new Object[0]), I18n.format("selectWorld.gameMode.creative.line2", new Object[0])}, {I18n.format("selectWorld.gameMode.adventure.line1", new Object[0]), I18n.format("selectWorld.gameMode.adventure.line2", new Object[0])}}; + } + + private String func_148398_c() + { + String s = I18n.format("options.difficulty", new Object[0]); + return s + ": " + this.field_148403_b[this.field_148402_e]; + } + + private String func_148393_d() + { + String s = I18n.format("selectWorld.gameMode", new Object[0]); + return s + ": " + this.field_148404_c[this.field_148399_f]; + } + + void func_148397_a(GuiButton p_148397_1_) + { + if (p_148397_1_.enabled) + { + if (p_148397_1_.id == 5005) + { + this.field_148402_e = (this.field_148402_e + 1) % this.field_148403_b.length; + p_148397_1_.displayString = this.func_148398_c(); + } + else if (p_148397_1_.id == 5006) + { + this.field_148399_f = (this.field_148399_f + 1) % this.field_148404_c.length; + p_148397_1_.displayString = this.func_148393_d(); + } + } + } + + public void func_148394_a(GuiScreen p_148394_1_, FontRenderer p_148394_2_) + { + p_148394_1_.drawString(p_148394_2_, this.field_148401_d[this.field_148399_f][0], this.field_148408_i, this.field_148406_j + 50, 10526880); + p_148394_1_.drawString(p_148394_2_, this.field_148401_d[this.field_148399_f][1], this.field_148408_i, this.field_148406_j + 60, 10526880); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiScreenOptionsSounds.java b/src/main/java/net/minecraft/client/gui/GuiScreenOptionsSounds.java new file mode 100644 index 0000000..72b099b --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiScreenOptionsSounds.java @@ -0,0 +1,179 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.Minecraft; +import net.minecraft.client.audio.PositionedSoundRecord; +import net.minecraft.client.audio.SoundCategory; +import net.minecraft.client.audio.SoundHandler; +import net.minecraft.client.resources.I18n; +import net.minecraft.client.settings.GameSettings; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class GuiScreenOptionsSounds extends GuiScreen +{ + private final GuiScreen field_146505_f; + private final GameSettings field_146506_g; + protected String field_146507_a = "Options"; + private String field_146508_h; + private static final String __OBFID = "CL_00000716"; + + public GuiScreenOptionsSounds(GuiScreen p_i45025_1_, GameSettings p_i45025_2_) + { + this.field_146505_f = p_i45025_1_; + this.field_146506_g = p_i45025_2_; + } + + public void initGui() + { + byte b0 = 0; + this.field_146507_a = I18n.format("options.sounds.title", new Object[0]); + this.field_146508_h = I18n.format("options.off", new Object[0]); + this.buttonList.add(new GuiScreenOptionsSounds.Button(SoundCategory.MASTER.getCategoryId(), this.width / 2 - 155 + b0 % 2 * 160, this.height / 6 - 12 + 24 * (b0 >> 1), SoundCategory.MASTER, true)); + int k = b0 + 2; + SoundCategory[] asoundcategory = SoundCategory.values(); + int i = asoundcategory.length; + + for (int j = 0; j < i; ++j) + { + SoundCategory soundcategory = asoundcategory[j]; + + if (soundcategory != SoundCategory.MASTER) + { + this.buttonList.add(new GuiScreenOptionsSounds.Button(soundcategory.getCategoryId(), this.width / 2 - 155 + k % 2 * 160, this.height / 6 - 12 + 24 * (k >> 1), soundcategory, false)); + ++k; + } + } + + this.buttonList.add(new GuiButton(200, this.width / 2 - 100, this.height / 6 + 168, I18n.format("gui.done", new Object[0]))); + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.enabled) + { + if (p_146284_1_.id == 200) + { + this.mc.gameSettings.saveOptions(); + this.mc.displayGuiScreen(this.field_146505_f); + } + } + } + + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + this.drawCenteredString(this.fontRendererObj, this.field_146507_a, this.width / 2, 15, 16777215); + super.drawScreen(par1, par2, par3); + } + + protected String func_146504_a(SoundCategory p_146504_1_) + { + float f = this.field_146506_g.getSoundLevel(p_146504_1_); + return f == 0.0F ? this.field_146508_h : (int)(f * 100.0F) + "%"; + } + + @SideOnly(Side.CLIENT) + class Button extends GuiButton + { + private final SoundCategory field_146153_r; + private final String field_146152_s; + public float field_146156_o = 1.0F; + public boolean field_146155_p; + private static final String __OBFID = "CL_00000717"; + + public Button(int p_i45024_2_, int p_i45024_3_, int p_i45024_4_, SoundCategory p_i45024_5_, boolean p_i45024_6_) + { + super(p_i45024_2_, p_i45024_3_, p_i45024_4_, p_i45024_6_ ? 310 : 150, 20, ""); + this.field_146153_r = p_i45024_5_; + this.field_146152_s = I18n.format("soundCategory." + p_i45024_5_.getCategoryName(), new Object[0]); + this.displayString = this.field_146152_s + ": " + GuiScreenOptionsSounds.this.func_146504_a(p_i45024_5_); + this.field_146156_o = GuiScreenOptionsSounds.this.field_146506_g.getSoundLevel(p_i45024_5_); + } + + protected int getHoverState(boolean p_146114_1_) + { + return 0; + } + + protected void mouseDragged(Minecraft p_146119_1_, int p_146119_2_, int p_146119_3_) + { + if (this.visible) + { + if (this.field_146155_p) + { + this.field_146156_o = (float)(p_146119_2_ - (this.xPosition + 4)) / (float)(this.width - 8); + + if (this.field_146156_o < 0.0F) + { + this.field_146156_o = 0.0F; + } + + if (this.field_146156_o > 1.0F) + { + this.field_146156_o = 1.0F; + } + + p_146119_1_.gameSettings.setSoundLevel(this.field_146153_r, this.field_146156_o); + p_146119_1_.gameSettings.saveOptions(); + this.displayString = this.field_146152_s + ": " + GuiScreenOptionsSounds.this.func_146504_a(this.field_146153_r); + } + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.drawTexturedModalRect(this.xPosition + (int)(this.field_146156_o * (float)(this.width - 8)), this.yPosition, 0, 66, 4, 20); + this.drawTexturedModalRect(this.xPosition + (int)(this.field_146156_o * (float)(this.width - 8)) + 4, this.yPosition, 196, 66, 4, 20); + } + } + + public boolean mousePressed(Minecraft p_146116_1_, int p_146116_2_, int p_146116_3_) + { + if (super.mousePressed(p_146116_1_, p_146116_2_, p_146116_3_)) + { + this.field_146156_o = (float)(p_146116_2_ - (this.xPosition + 4)) / (float)(this.width - 8); + + if (this.field_146156_o < 0.0F) + { + this.field_146156_o = 0.0F; + } + + if (this.field_146156_o > 1.0F) + { + this.field_146156_o = 1.0F; + } + + p_146116_1_.gameSettings.setSoundLevel(this.field_146153_r, this.field_146156_o); + p_146116_1_.gameSettings.saveOptions(); + this.displayString = this.field_146152_s + ": " + GuiScreenOptionsSounds.this.func_146504_a(this.field_146153_r); + this.field_146155_p = true; + return true; + } + else + { + return false; + } + } + + public void func_146113_a(SoundHandler p_146113_1_) {} + + public void mouseReleased(int p_146118_1_, int p_146118_2_) + { + if (this.field_146155_p) + { + if (this.field_146153_r == SoundCategory.MASTER) + { + float f = 1.0F; + } + else + { + GuiScreenOptionsSounds.this.field_146506_g.getSoundLevel(this.field_146153_r); + } + + GuiScreenOptionsSounds.this.mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); + } + + this.field_146155_p = false; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiScreenRealmsPinger.java b/src/main/java/net/minecraft/client/gui/GuiScreenRealmsPinger.java new file mode 100644 index 0000000..48098d7 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiScreenRealmsPinger.java @@ -0,0 +1,113 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.util.concurrent.GenericFutureListener; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import net.minecraft.client.Minecraft; +import net.minecraft.client.mco.McoServer; +import net.minecraft.client.multiplayer.ServerAddress; +import net.minecraft.network.EnumConnectionState; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.ServerStatusResponse; +import net.minecraft.network.handshake.client.C00Handshake; +import net.minecraft.network.status.INetHandlerStatusClient; +import net.minecraft.network.status.client.C00PacketServerQuery; +import net.minecraft.network.status.client.C01PacketPing; +import net.minecraft.network.status.server.S00PacketServerInfo; +import net.minecraft.network.status.server.S01PacketPong; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IChatComponent; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +@SideOnly(Side.CLIENT) +public class GuiScreenRealmsPinger +{ + private static final Logger logger = LogManager.getLogger(); + private final List field_148509_b = Collections.synchronizedList(new ArrayList()); + private static final String __OBFID = "CL_00000807"; + + public void func_148506_a(final McoServer p_148506_1_) throws UnknownHostException + { + if (p_148506_1_.field_148807_g != null) + { + ServerAddress serveraddress = ServerAddress.func_78860_a(p_148506_1_.field_148807_g); + final NetworkManager networkmanager = NetworkManager.provideLanClient(InetAddress.getByName(serveraddress.getIP()), serveraddress.getPort()); + this.field_148509_b.add(networkmanager); + networkmanager.setNetHandler(new INetHandlerStatusClient() + { + private boolean field_147399_d = false; + private static final String __OBFID = "CL_00000808"; + public void handleServerInfo(S00PacketServerInfo p_147397_1_) + { + ServerStatusResponse serverstatusresponse = p_147397_1_.func_149294_c(); + + if (serverstatusresponse.func_151318_b() != null) + { + p_148506_1_.field_148813_n = EnumChatFormatting.GRAY + "" + serverstatusresponse.func_151318_b().func_151333_b(); + } + + networkmanager.scheduleOutboundPacket(new C01PacketPing(Minecraft.getSystemTime()), new GenericFutureListener[0]); + this.field_147399_d = true; + } + public void handlePong(S01PacketPong p_147398_1_) + { + networkmanager.closeChannel(new ChatComponentText("Finished")); + } + public void onDisconnect(IChatComponent p_147231_1_) + { + if (!this.field_147399_d) + { + GuiScreenRealmsPinger.logger.error("Can\'t ping " + p_148506_1_.field_148807_g + ": " + p_147231_1_.getUnformattedText()); + } + } + public void onConnectionStateTransition(EnumConnectionState p_147232_1_, EnumConnectionState p_147232_2_) + { + if (p_147232_2_ != EnumConnectionState.STATUS) + { + throw new UnsupportedOperationException("Unexpected change in protocol to " + p_147232_2_); + } + } + public void onNetworkTick() {} + }); + + try + { + networkmanager.scheduleOutboundPacket(new C00Handshake(4, serveraddress.getIP(), serveraddress.getPort(), EnumConnectionState.STATUS), new GenericFutureListener[0]); + networkmanager.scheduleOutboundPacket(new C00PacketServerQuery(), new GenericFutureListener[0]); + } + catch (Throwable throwable) + { + logger.error(throwable); + } + } + } + + public void func_148507_b() + { + List list = this.field_148509_b; + + synchronized (this.field_148509_b) + { + Iterator iterator = this.field_148509_b.iterator(); + + while (iterator.hasNext()) + { + NetworkManager networkmanager = (NetworkManager)iterator.next(); + + if (networkmanager.isChannelOpen()) + { + iterator.remove(); + networkmanager.closeChannel(new ChatComponentText("Cancelled")); + } + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiScreenReamlsTOS.java b/src/main/java/net/minecraft/client/gui/GuiScreenReamlsTOS.java new file mode 100644 index 0000000..57707e4 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiScreenReamlsTOS.java @@ -0,0 +1,141 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.ClipboardOwner; +import java.awt.datatransfer.StringSelection; +import java.net.URI; +import net.minecraft.client.Minecraft; +import net.minecraft.client.mco.ExceptionMcoService; +import net.minecraft.client.mco.McoClient; +import net.minecraft.client.mco.McoServer; +import net.minecraft.client.resources.I18n; +import net.minecraft.util.Session; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.lwjgl.input.Keyboard; + +@SideOnly(Side.CLIENT) +public class GuiScreenReamlsTOS extends GuiScreen +{ + private static final Logger logger = LogManager.getLogger(); + private final GuiScreen field_146770_f; + private final McoServer field_146771_g; + private GuiButton field_146774_h; + private boolean field_146775_i = false; + private String field_146772_r = "https://minecraft.net/realms/terms"; + private static final String __OBFID = "CL_00000809"; + + public GuiScreenReamlsTOS(GuiScreen p_i45045_1_, McoServer p_i45045_2_) + { + this.field_146770_f = p_i45045_1_; + this.field_146771_g = p_i45045_2_; + } + + public void updateScreen() {} + + public void initGui() + { + Keyboard.enableRepeatEvents(true); + this.buttonList.clear(); + int i = this.width / 4; + int j = this.width / 4 - 2; + int k = this.width / 2 + 4; + this.buttonList.add(this.field_146774_h = new GuiButton(1, i, this.height / 5 + 96 + 22, j, 20, I18n.format("mco.terms.buttons.agree", new Object[0]))); + this.buttonList.add(new GuiButton(2, k, this.height / 5 + 96 + 22, j, 20, I18n.format("mco.terms.buttons.disagree", new Object[0]))); + } + + public void onGuiClosed() + { + Keyboard.enableRepeatEvents(false); + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.enabled) + { + if (p_146284_1_.id == 2) + { + this.mc.displayGuiScreen(this.field_146770_f); + } + else if (p_146284_1_.id == 1) + { + this.func_146768_g(); + } + } + } + + private void func_146768_g() + { + Session session = this.mc.getSession(); + McoClient mcoclient = new McoClient(session.getSessionID(), session.getUsername(), "1.7.2", Minecraft.getMinecraft().getProxy()); + + try + { + mcoclient.func_148714_h(); + GuiScreenLongRunningTask guiscreenlongrunningtask = new GuiScreenLongRunningTask(this.mc, this, new TaskOnlineConnect(this, this.field_146771_g)); + guiscreenlongrunningtask.func_146902_g(); + this.mc.displayGuiScreen(guiscreenlongrunningtask); + } + catch (ExceptionMcoService exceptionmcoservice) + { + logger.error("Couldn\'t agree to TOS"); + } + } + + protected void mouseClicked(int par1, int par2, int par3) + { + super.mouseClicked(par1, par2, par3); + + if (this.field_146775_i) + { + Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + clipboard.setContents(new StringSelection(this.field_146772_r), (ClipboardOwner)null); + this.func_146769_a(this.field_146772_r); + } + } + + private void func_146769_a(String p_146769_1_) + { + try + { + URI uri = new URI(p_146769_1_); + Class oclass = Class.forName("java.awt.Desktop"); + Object object = oclass.getMethod("getDesktop", new Class[0]).invoke((Object)null, new Object[0]); + oclass.getMethod("browse", new Class[] {URI.class}).invoke(object, new Object[] {uri}); + } + catch (Throwable throwable) + { + logger.error("Couldn\'t open link"); + } + } + + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + this.drawCenteredString(this.fontRendererObj, I18n.format("mco.terms.title", new Object[0]), this.width / 2, 17, 16777215); + this.drawString(this.fontRendererObj, I18n.format("mco.terms.sentence.1", new Object[0]), this.width / 2 - 120, 87, 16777215); + int k = this.fontRendererObj.getStringWidth(I18n.format("mco.terms.sentence.1", new Object[0])); + int l = 3368635; + int i1 = 7107012; + int j1 = this.width / 2 - 121 + k; + byte b0 = 86; + int k1 = j1 + this.fontRendererObj.getStringWidth("mco.terms.sentence.2") + 1; + int l1 = 87 + this.fontRendererObj.FONT_HEIGHT; + + if (j1 <= par1 && par1 <= k1 && b0 <= par2 && par2 <= l1) + { + this.field_146775_i = true; + this.drawString(this.fontRendererObj, " " + I18n.format("mco.terms.sentence.2", new Object[0]), this.width / 2 - 120 + k, 87, i1); + } + else + { + this.field_146775_i = false; + this.drawString(this.fontRendererObj, " " + I18n.format("mco.terms.sentence.2", new Object[0]), this.width / 2 - 120 + k, 87, l); + } + + super.drawScreen(par1, par2, par3); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiScreenResourcePacks.java b/src/main/java/net/minecraft/client/gui/GuiScreenResourcePacks.java new file mode 100644 index 0000000..9176b3b --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiScreenResourcePacks.java @@ -0,0 +1,206 @@ +package net.minecraft.client.gui; + +import com.google.common.collect.Lists; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.File; +import java.io.IOException; +import java.net.URI; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import net.minecraft.client.resources.I18n; +import net.minecraft.client.resources.ResourcePackListEntry; +import net.minecraft.client.resources.ResourcePackListEntryDefault; +import net.minecraft.client.resources.ResourcePackListEntryFound; +import net.minecraft.client.resources.ResourcePackRepository; +import net.minecraft.util.Util; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.lwjgl.Sys; + +@SideOnly(Side.CLIENT) +public class GuiScreenResourcePacks extends GuiScreen +{ + private static final Logger logger = LogManager.getLogger(); + private GuiScreen field_146965_f; + private List field_146966_g; + private List field_146969_h; + private GuiResourcePackAvailable field_146970_i; + private GuiResourcePackSelected field_146967_r; + private static final String __OBFID = "CL_00000820"; + + public GuiScreenResourcePacks(GuiScreen p_i45050_1_) + { + this.field_146965_f = p_i45050_1_; + } + + public void initGui() + { + this.buttonList.add(new GuiOptionButton(2, this.width / 2 - 154, this.height - 48, I18n.format("resourcePack.openFolder", new Object[0]))); + this.buttonList.add(new GuiOptionButton(1, this.width / 2 + 4, this.height - 48, I18n.format("gui.done", new Object[0]))); + this.field_146966_g = new ArrayList(); + this.field_146969_h = new ArrayList(); + ResourcePackRepository resourcepackrepository = this.mc.getResourcePackRepository(); + resourcepackrepository.updateRepositoryEntriesAll(); + ArrayList arraylist = Lists.newArrayList(resourcepackrepository.getRepositoryEntriesAll()); + arraylist.removeAll(resourcepackrepository.getRepositoryEntries()); + Iterator iterator = arraylist.iterator(); + ResourcePackRepository.Entry entry; + + while (iterator.hasNext()) + { + entry = (ResourcePackRepository.Entry)iterator.next(); + this.field_146966_g.add(new ResourcePackListEntryFound(this, entry)); + } + + iterator = Lists.reverse(resourcepackrepository.getRepositoryEntries()).iterator(); + + while (iterator.hasNext()) + { + entry = (ResourcePackRepository.Entry)iterator.next(); + this.field_146969_h.add(new ResourcePackListEntryFound(this, entry)); + } + + this.field_146969_h.add(new ResourcePackListEntryDefault(this)); + this.field_146970_i = new GuiResourcePackAvailable(this.mc, 200, this.height, this.field_146966_g); + this.field_146970_i.setSlotXBoundsFromLeft(this.width / 2 - 4 - 200); + this.field_146970_i.registerScrollButtons(7, 8); + this.field_146967_r = new GuiResourcePackSelected(this.mc, 200, this.height, this.field_146969_h); + this.field_146967_r.setSlotXBoundsFromLeft(this.width / 2 + 4); + this.field_146967_r.registerScrollButtons(7, 8); + } + + public boolean func_146961_a(ResourcePackListEntry p_146961_1_) + { + return this.field_146969_h.contains(p_146961_1_); + } + + public List func_146962_b(ResourcePackListEntry p_146962_1_) + { + return this.func_146961_a(p_146962_1_) ? this.field_146969_h : this.field_146966_g; + } + + public List func_146964_g() + { + return this.field_146966_g; + } + + public List func_146963_h() + { + return this.field_146969_h; + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.enabled) + { + if (p_146284_1_.id == 2) + { + File file1 = this.mc.getResourcePackRepository().getDirResourcepacks(); + String s = file1.getAbsolutePath(); + + if (Util.getOSType() == Util.EnumOS.MACOS) + { + try + { + logger.info(s); + Runtime.getRuntime().exec(new String[] {"/usr/bin/open", s}); + return; + } + catch (IOException ioexception1) + { + logger.error("Couldn\'t open file", ioexception1); + } + } + else if (Util.getOSType() == Util.EnumOS.WINDOWS) + { + String s1 = String.format("cmd.exe /C start \"Open file\" \"%s\"", new Object[] {s}); + + try + { + Runtime.getRuntime().exec(s1); + return; + } + catch (IOException ioexception) + { + logger.error("Couldn\'t open file", ioexception); + } + } + + boolean flag = false; + + try + { + Class oclass = Class.forName("java.awt.Desktop"); + Object object = oclass.getMethod("getDesktop", new Class[0]).invoke((Object)null, new Object[0]); + oclass.getMethod("browse", new Class[] {URI.class}).invoke(object, new Object[] {file1.toURI()}); + } + catch (Throwable throwable) + { + logger.error("Couldn\'t open link", throwable); + flag = true; + } + + if (flag) + { + logger.info("Opening via system class!"); + Sys.openURL("file://" + s); + } + } + else if (p_146284_1_.id == 1) + { + ArrayList arraylist = Lists.newArrayList(); + Iterator iterator = this.field_146969_h.iterator(); + + while (iterator.hasNext()) + { + ResourcePackListEntry resourcepacklistentry = (ResourcePackListEntry)iterator.next(); + + if (resourcepacklistentry instanceof ResourcePackListEntryFound) + { + arraylist.add(((ResourcePackListEntryFound)resourcepacklistentry).func_148318_i()); + } + } + + Collections.reverse(arraylist); + this.mc.getResourcePackRepository().func_148527_a(arraylist); + this.mc.gameSettings.resourcePacks.clear(); + iterator = arraylist.iterator(); + + while (iterator.hasNext()) + { + ResourcePackRepository.Entry entry = (ResourcePackRepository.Entry)iterator.next(); + this.mc.gameSettings.resourcePacks.add(entry.getResourcePackName()); + } + + this.mc.gameSettings.saveOptions(); + this.mc.refreshResources(); + this.mc.displayGuiScreen(this.field_146965_f); + } + } + } + + protected void mouseClicked(int par1, int par2, int par3) + { + super.mouseClicked(par1, par2, par3); + this.field_146970_i.func_148179_a(par1, par2, par3); + this.field_146967_r.func_148179_a(par1, par2, par3); + } + + protected void mouseMovedOrUp(int p_146286_1_, int p_146286_2_, int p_146286_3_) + { + super.mouseMovedOrUp(p_146286_1_, p_146286_2_, p_146286_3_); + } + + public void drawScreen(int par1, int par2, float par3) + { + this.drawBackground(0); + this.field_146970_i.drawScreen(par1, par2, par3); + this.field_146967_r.drawScreen(par1, par2, par3); + this.drawCenteredString(this.fontRendererObj, I18n.format("resourcePack.title", new Object[0]), this.width / 2, 16, 16777215); + this.drawCenteredString(this.fontRendererObj, I18n.format("resourcePack.folderInfo", new Object[0]), this.width / 2 - 77, this.height - 26, 8421504); + super.drawScreen(par1, par2, par3); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiScreenSelectLocation.java b/src/main/java/net/minecraft/client/gui/GuiScreenSelectLocation.java new file mode 100644 index 0000000..5f2b087 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiScreenSelectLocation.java @@ -0,0 +1,409 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.Tessellator; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public abstract class GuiScreenSelectLocation +{ + private final Minecraft field_148368_a; + private int field_148363_g; + private int field_148375_h; + protected int field_148366_b; + protected int field_148367_c; + private int field_148376_i; + private int field_148373_j; + protected final int field_148364_d; + private int field_148374_k; + private int field_148371_l; + protected int field_148365_e; + protected int field_148362_f; + private float field_148372_m = -2.0F; + private float field_148369_n; + private float field_148370_o; + private int field_148381_p = -1; + private long field_148380_q; + private boolean field_148379_r = true; + private boolean field_148378_s; + private int field_148377_t; + private static final String __OBFID = "CL_00000785"; + + public GuiScreenSelectLocation(Minecraft par1Minecraft, int par2, int par3, int par4, int par5, int par6) + { + this.field_148368_a = par1Minecraft; + this.field_148363_g = par2; + this.field_148375_h = par3; + this.field_148366_b = par4; + this.field_148367_c = par5; + this.field_148364_d = par6; + this.field_148373_j = 0; + this.field_148376_i = par2; + } + + public void func_148346_a(int p_148346_1_, int p_148346_2_, int p_148346_3_, int p_148346_4_) + { + this.field_148363_g = p_148346_1_; + this.field_148375_h = p_148346_2_; + this.field_148366_b = p_148346_3_; + this.field_148367_c = p_148346_4_; + this.field_148373_j = 0; + this.field_148376_i = p_148346_1_; + } + + protected abstract int func_148355_a(); + + protected abstract void func_148352_a(int var1, boolean var2); + + protected abstract boolean func_148356_a(int var1); + + protected abstract boolean func_148349_b(int var1); + + protected int func_148351_b() + { + return this.func_148355_a() * this.field_148364_d + this.field_148377_t; + } + + protected abstract void func_148358_c(); + + protected abstract void func_148348_a(int var1, int var2, int var3, int var4, Tessellator var5); + + protected void func_148354_a(int p_148354_1_, int p_148354_2_, Tessellator p_148354_3_) {} + + protected void func_148359_a(int p_148359_1_, int p_148359_2_) {} + + protected void func_148353_b(int p_148353_1_, int p_148353_2_) {} + + private void func_148361_h() + { + int i = this.func_148347_d(); + + if (i < 0) + { + i /= 2; + } + + if (this.field_148370_o < 0.0F) + { + this.field_148370_o = 0.0F; + } + + if (this.field_148370_o > (float)i) + { + this.field_148370_o = (float)i; + } + } + + public int func_148347_d() + { + return this.func_148351_b() - (this.field_148367_c - this.field_148366_b - 4); + } + + public void func_148357_a(GuiButton p_148357_1_) + { + if (p_148357_1_.enabled) + { + if (p_148357_1_.id == this.field_148374_k) + { + this.field_148370_o -= (float)(this.field_148364_d * 2 / 3); + this.field_148372_m = -2.0F; + this.func_148361_h(); + } + else if (p_148357_1_.id == this.field_148371_l) + { + this.field_148370_o += (float)(this.field_148364_d * 2 / 3); + this.field_148372_m = -2.0F; + this.func_148361_h(); + } + } + } + + public void func_148350_a(int p_148350_1_, int p_148350_2_, float p_148350_3_) + { + this.field_148365_e = p_148350_1_; + this.field_148362_f = p_148350_2_; + this.func_148358_c(); + int k = this.func_148355_a(); + int l = this.func_148360_g(); + int i1 = l + 6; + int k1; + int l1; + int i2; + int j2; + int j3; + + if (Mouse.isButtonDown(0)) + { + if (this.field_148372_m == -1.0F) + { + boolean flag = true; + + if (p_148350_2_ >= this.field_148366_b && p_148350_2_ <= this.field_148367_c) + { + int j1 = this.field_148363_g / 2 - 110; + k1 = this.field_148363_g / 2 + 110; + l1 = p_148350_2_ - this.field_148366_b - this.field_148377_t + (int)this.field_148370_o - 4; + i2 = l1 / this.field_148364_d; + + if (p_148350_1_ >= j1 && p_148350_1_ <= k1 && i2 >= 0 && l1 >= 0 && i2 < k) + { + boolean flag1 = i2 == this.field_148381_p && Minecraft.getSystemTime() - this.field_148380_q < 250L; + this.func_148352_a(i2, flag1); + this.field_148381_p = i2; + this.field_148380_q = Minecraft.getSystemTime(); + } + else if (p_148350_1_ >= j1 && p_148350_1_ <= k1 && l1 < 0) + { + this.func_148359_a(p_148350_1_ - j1, p_148350_2_ - this.field_148366_b + (int)this.field_148370_o - 4); + flag = false; + } + + if (p_148350_1_ >= l && p_148350_1_ <= i1) + { + this.field_148369_n = -1.0F; + j3 = this.func_148347_d(); + + if (j3 < 1) + { + j3 = 1; + } + + j2 = (int)((float)((this.field_148367_c - this.field_148366_b) * (this.field_148367_c - this.field_148366_b)) / (float)this.func_148351_b()); + + if (j2 < 32) + { + j2 = 32; + } + + if (j2 > this.field_148367_c - this.field_148366_b - 8) + { + j2 = this.field_148367_c - this.field_148366_b - 8; + } + + this.field_148369_n /= (float)(this.field_148367_c - this.field_148366_b - j2) / (float)j3; + } + else + { + this.field_148369_n = 1.0F; + } + + if (flag) + { + this.field_148372_m = (float)p_148350_2_; + } + else + { + this.field_148372_m = -2.0F; + } + } + else + { + this.field_148372_m = -2.0F; + } + } + else if (this.field_148372_m >= 0.0F) + { + this.field_148370_o -= ((float)p_148350_2_ - this.field_148372_m) * this.field_148369_n; + this.field_148372_m = (float)p_148350_2_; + } + } + else + { + while (!this.field_148368_a.gameSettings.touchscreen && Mouse.next()) + { + int i3 = Mouse.getEventDWheel(); + + if (i3 != 0) + { + if (i3 > 0) + { + i3 = -1; + } + else if (i3 < 0) + { + i3 = 1; + } + + this.field_148370_o += (float)(i3 * this.field_148364_d / 2); + } + } + + this.field_148372_m = -1.0F; + } + + this.func_148361_h(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_FOG); + Tessellator tessellator = Tessellator.instance; + this.field_148368_a.getTextureManager().bindTexture(Gui.optionsBackground); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + float f1 = 32.0F; + tessellator.startDrawingQuads(); + tessellator.setColorOpaque_I(2105376); + tessellator.addVertexWithUV((double)this.field_148373_j, (double)this.field_148367_c, 0.0D, (double)((float)this.field_148373_j / f1), (double)((float)(this.field_148367_c + (int)this.field_148370_o) / f1)); + tessellator.addVertexWithUV((double)this.field_148376_i, (double)this.field_148367_c, 0.0D, (double)((float)this.field_148376_i / f1), (double)((float)(this.field_148367_c + (int)this.field_148370_o) / f1)); + tessellator.addVertexWithUV((double)this.field_148376_i, (double)this.field_148366_b, 0.0D, (double)((float)this.field_148376_i / f1), (double)((float)(this.field_148366_b + (int)this.field_148370_o) / f1)); + tessellator.addVertexWithUV((double)this.field_148373_j, (double)this.field_148366_b, 0.0D, (double)((float)this.field_148373_j / f1), (double)((float)(this.field_148366_b + (int)this.field_148370_o) / f1)); + tessellator.draw(); + k1 = this.field_148363_g / 2 - 92 - 16; + l1 = this.field_148366_b + 4 - (int)this.field_148370_o; + + if (this.field_148378_s) + { + this.func_148354_a(k1, l1, tessellator); + } + + int k2; + + for (i2 = 0; i2 < k; ++i2) + { + j3 = l1 + i2 * this.field_148364_d + this.field_148377_t; + j2 = this.field_148364_d - 4; + + if (j3 <= this.field_148367_c && j3 + j2 >= this.field_148366_b) + { + int l2; + + if (this.field_148379_r && this.func_148349_b(i2)) + { + k2 = this.field_148363_g / 2 - 110; + l2 = this.field_148363_g / 2 + 110; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_TEXTURE_2D); + tessellator.startDrawingQuads(); + tessellator.setColorOpaque_I(0); + tessellator.addVertexWithUV((double)k2, (double)(j3 + j2 + 2), 0.0D, 0.0D, 1.0D); + tessellator.addVertexWithUV((double)l2, (double)(j3 + j2 + 2), 0.0D, 1.0D, 1.0D); + tessellator.addVertexWithUV((double)l2, (double)(j3 - 2), 0.0D, 1.0D, 0.0D); + tessellator.addVertexWithUV((double)k2, (double)(j3 - 2), 0.0D, 0.0D, 0.0D); + tessellator.draw(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + + if (this.field_148379_r && this.func_148356_a(i2)) + { + k2 = this.field_148363_g / 2 - 110; + l2 = this.field_148363_g / 2 + 110; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_TEXTURE_2D); + tessellator.startDrawingQuads(); + tessellator.setColorOpaque_I(8421504); + tessellator.addVertexWithUV((double)k2, (double)(j3 + j2 + 2), 0.0D, 0.0D, 1.0D); + tessellator.addVertexWithUV((double)l2, (double)(j3 + j2 + 2), 0.0D, 1.0D, 1.0D); + tessellator.addVertexWithUV((double)l2, (double)(j3 - 2), 0.0D, 1.0D, 0.0D); + tessellator.addVertexWithUV((double)k2, (double)(j3 - 2), 0.0D, 0.0D, 0.0D); + tessellator.setColorOpaque_I(0); + tessellator.addVertexWithUV((double)(k2 + 1), (double)(j3 + j2 + 1), 0.0D, 0.0D, 1.0D); + tessellator.addVertexWithUV((double)(l2 - 1), (double)(j3 + j2 + 1), 0.0D, 1.0D, 1.0D); + tessellator.addVertexWithUV((double)(l2 - 1), (double)(j3 - 1), 0.0D, 1.0D, 0.0D); + tessellator.addVertexWithUV((double)(k2 + 1), (double)(j3 - 1), 0.0D, 0.0D, 0.0D); + tessellator.draw(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + + this.func_148348_a(i2, k1, j3, j2, tessellator); + } + } + + GL11.glDisable(GL11.GL_DEPTH_TEST); + byte b0 = 4; + this.func_148345_b(0, this.field_148366_b, 255, 255); + this.func_148345_b(this.field_148367_c, this.field_148375_h, 255, 255); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glShadeModel(GL11.GL_SMOOTH); + GL11.glDisable(GL11.GL_TEXTURE_2D); + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_I(0, 0); + tessellator.addVertexWithUV((double)this.field_148373_j, (double)(this.field_148366_b + b0), 0.0D, 0.0D, 1.0D); + tessellator.addVertexWithUV((double)this.field_148376_i, (double)(this.field_148366_b + b0), 0.0D, 1.0D, 1.0D); + tessellator.setColorRGBA_I(0, 255); + tessellator.addVertexWithUV((double)this.field_148376_i, (double)this.field_148366_b, 0.0D, 1.0D, 0.0D); + tessellator.addVertexWithUV((double)this.field_148373_j, (double)this.field_148366_b, 0.0D, 0.0D, 0.0D); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_I(0, 255); + tessellator.addVertexWithUV((double)this.field_148373_j, (double)this.field_148367_c, 0.0D, 0.0D, 1.0D); + tessellator.addVertexWithUV((double)this.field_148376_i, (double)this.field_148367_c, 0.0D, 1.0D, 1.0D); + tessellator.setColorRGBA_I(0, 0); + tessellator.addVertexWithUV((double)this.field_148376_i, (double)(this.field_148367_c - b0), 0.0D, 1.0D, 0.0D); + tessellator.addVertexWithUV((double)this.field_148373_j, (double)(this.field_148367_c - b0), 0.0D, 0.0D, 0.0D); + tessellator.draw(); + j3 = this.func_148347_d(); + + if (j3 > 0) + { + j2 = (this.field_148367_c - this.field_148366_b) * (this.field_148367_c - this.field_148366_b) / this.func_148351_b(); + + if (j2 < 32) + { + j2 = 32; + } + + if (j2 > this.field_148367_c - this.field_148366_b - 8) + { + j2 = this.field_148367_c - this.field_148366_b - 8; + } + + k2 = (int)this.field_148370_o * (this.field_148367_c - this.field_148366_b - j2) / j3 + this.field_148366_b; + + if (k2 < this.field_148366_b) + { + k2 = this.field_148366_b; + } + + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_I(0, 255); + tessellator.addVertexWithUV((double)l, (double)this.field_148367_c, 0.0D, 0.0D, 1.0D); + tessellator.addVertexWithUV((double)i1, (double)this.field_148367_c, 0.0D, 1.0D, 1.0D); + tessellator.addVertexWithUV((double)i1, (double)this.field_148366_b, 0.0D, 1.0D, 0.0D); + tessellator.addVertexWithUV((double)l, (double)this.field_148366_b, 0.0D, 0.0D, 0.0D); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_I(8421504, 255); + tessellator.addVertexWithUV((double)l, (double)(k2 + j2), 0.0D, 0.0D, 1.0D); + tessellator.addVertexWithUV((double)i1, (double)(k2 + j2), 0.0D, 1.0D, 1.0D); + tessellator.addVertexWithUV((double)i1, (double)k2, 0.0D, 1.0D, 0.0D); + tessellator.addVertexWithUV((double)l, (double)k2, 0.0D, 0.0D, 0.0D); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_I(12632256, 255); + tessellator.addVertexWithUV((double)l, (double)(k2 + j2 - 1), 0.0D, 0.0D, 1.0D); + tessellator.addVertexWithUV((double)(i1 - 1), (double)(k2 + j2 - 1), 0.0D, 1.0D, 1.0D); + tessellator.addVertexWithUV((double)(i1 - 1), (double)k2, 0.0D, 1.0D, 0.0D); + tessellator.addVertexWithUV((double)l, (double)k2, 0.0D, 0.0D, 0.0D); + tessellator.draw(); + } + + this.func_148353_b(p_148350_1_, p_148350_2_); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glShadeModel(GL11.GL_FLAT); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glDisable(GL11.GL_BLEND); + } + + protected int func_148360_g() + { + return this.field_148363_g / 2 + 124; + } + + private void func_148345_b(int p_148345_1_, int p_148345_2_, int p_148345_3_, int p_148345_4_) + { + Tessellator tessellator = Tessellator.instance; + this.field_148368_a.getTextureManager().bindTexture(Gui.optionsBackground); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + float f = 32.0F; + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_I(4210752, p_148345_4_); + tessellator.addVertexWithUV(0.0D, (double)p_148345_2_, 0.0D, 0.0D, (double)((float)p_148345_2_ / f)); + tessellator.addVertexWithUV((double)this.field_148363_g, (double)p_148345_2_, 0.0D, (double)((float)this.field_148363_g / f), (double)((float)p_148345_2_ / f)); + tessellator.setColorRGBA_I(4210752, p_148345_3_); + tessellator.addVertexWithUV((double)this.field_148363_g, (double)p_148345_1_, 0.0D, (double)((float)this.field_148363_g / f), (double)((float)p_148345_1_ / f)); + tessellator.addVertexWithUV(0.0D, (double)p_148345_1_, 0.0D, 0.0D, (double)((float)p_148345_1_ / f)); + tessellator.draw(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiScreenServerList.java b/src/main/java/net/minecraft/client/gui/GuiScreenServerList.java new file mode 100644 index 0000000..5fed465 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiScreenServerList.java @@ -0,0 +1,90 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.multiplayer.ServerData; +import net.minecraft.client.resources.I18n; +import org.lwjgl.input.Keyboard; + +@SideOnly(Side.CLIENT) +public class GuiScreenServerList extends GuiScreen +{ + private final GuiScreen field_146303_a; + private final ServerData field_146301_f; + private GuiTextField field_146302_g; + private static final String __OBFID = "CL_00000692"; + + public GuiScreenServerList(GuiScreen par1GuiScreen, ServerData par2ServerData) + { + this.field_146303_a = par1GuiScreen; + this.field_146301_f = par2ServerData; + } + + public void updateScreen() + { + this.field_146302_g.updateCursorCounter(); + } + + public void initGui() + { + Keyboard.enableRepeatEvents(true); + this.buttonList.clear(); + this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 96 + 12, I18n.format("selectServer.select", new Object[0]))); + this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 120 + 12, I18n.format("gui.cancel", new Object[0]))); + this.field_146302_g = new GuiTextField(this.fontRendererObj, this.width / 2 - 100, 116, 200, 20); + this.field_146302_g.setMaxStringLength(128); + this.field_146302_g.setFocused(true); + this.field_146302_g.setText(this.mc.gameSettings.lastServer); + ((GuiButton)this.buttonList.get(0)).enabled = this.field_146302_g.getText().length() > 0 && this.field_146302_g.getText().split(":").length > 0; + } + + public void onGuiClosed() + { + Keyboard.enableRepeatEvents(false); + this.mc.gameSettings.lastServer = this.field_146302_g.getText(); + this.mc.gameSettings.saveOptions(); + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.enabled) + { + if (p_146284_1_.id == 1) + { + this.field_146303_a.confirmClicked(false, 0); + } + else if (p_146284_1_.id == 0) + { + this.field_146301_f.serverIP = this.field_146302_g.getText(); + this.field_146303_a.confirmClicked(true, 0); + } + } + } + + protected void keyTyped(char par1, int par2) + { + if (this.field_146302_g.textboxKeyTyped(par1, par2)) + { + ((GuiButton)this.buttonList.get(0)).enabled = this.field_146302_g.getText().length() > 0 && this.field_146302_g.getText().split(":").length > 0; + } + else if (par2 == 28 || par2 == 156) + { + this.actionPerformed((GuiButton)this.buttonList.get(0)); + } + } + + protected void mouseClicked(int par1, int par2, int par3) + { + super.mouseClicked(par1, par2, par3); + this.field_146302_g.mouseClicked(par1, par2, par3); + } + + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + this.drawCenteredString(this.fontRendererObj, I18n.format("selectServer.direct", new Object[0]), this.width / 2, 20, 16777215); + this.drawString(this.fontRendererObj, I18n.format("addServer.enterIp", new Object[0]), this.width / 2 - 100, 100, 10526880); + this.field_146302_g.drawTextBox(); + super.drawScreen(par1, par2, par3); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiScreenSubscription.java b/src/main/java/net/minecraft/client/gui/GuiScreenSubscription.java new file mode 100644 index 0000000..465e3c2 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiScreenSubscription.java @@ -0,0 +1,145 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.ClipboardOwner; +import java.awt.datatransfer.StringSelection; +import java.io.IOException; +import java.net.URI; +import java.text.SimpleDateFormat; +import java.util.GregorianCalendar; +import java.util.TimeZone; +import net.minecraft.client.Minecraft; +import net.minecraft.client.mco.ExceptionMcoService; +import net.minecraft.client.mco.McoClient; +import net.minecraft.client.mco.McoServer; +import net.minecraft.client.mco.ValueObjectSubscription; +import net.minecraft.client.resources.I18n; +import net.minecraft.util.Session; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.lwjgl.input.Keyboard; + +@SideOnly(Side.CLIENT) +public class GuiScreenSubscription extends GuiScreen +{ + private static final Logger logger = LogManager.getLogger(); + private final GuiScreen field_146780_f; + private final McoServer field_146781_g; + private final int field_146787_h = 0; + private final int field_146788_i = 1; + private int field_146785_r; + private String field_146784_s; + private final String field_146783_t = "https://account.mojang.com"; + private final String field_146782_u = "/buy/realms"; + private static final String __OBFID = "CL_00000813"; + + public GuiScreenSubscription(GuiScreen par1GuiScreen, McoServer par2McoServer) + { + this.field_146780_f = par1GuiScreen; + this.field_146781_g = par2McoServer; + } + + public void updateScreen() {} + + public void initGui() + { + this.func_146778_a(this.field_146781_g.field_148812_a); + Keyboard.enableRepeatEvents(true); + this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 96 + 12, I18n.format("mco.configure.world.subscription.extend", new Object[0]))); + this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 120 + 12, I18n.format("gui.cancel", new Object[0]))); + } + + private void func_146778_a(long p_146778_1_) + { + Session session = this.mc.getSession(); + McoClient mcoclient = new McoClient(session.getSessionID(), session.getUsername(), "1.7.2", Minecraft.getMinecraft().getProxy()); + + try + { + ValueObjectSubscription valueobjectsubscription = mcoclient.func_148705_g(p_146778_1_); + this.field_146785_r = valueobjectsubscription.field_148789_b; + this.field_146784_s = this.func_146776_b(valueobjectsubscription.field_148790_a); + } + catch (ExceptionMcoService exceptionmcoservice) + { + logger.error("Couldn\'t get subscription"); + } + catch (IOException ioexception) + { + logger.error("Couldn\'t parse response subscribing"); + } + } + + private String func_146776_b(long p_146776_1_) + { + GregorianCalendar gregoriancalendar = new GregorianCalendar(TimeZone.getDefault()); + gregoriancalendar.setTimeInMillis(p_146776_1_); + return SimpleDateFormat.getDateTimeInstance().format(gregoriancalendar.getTime()); + } + + public void onGuiClosed() + { + Keyboard.enableRepeatEvents(false); + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.enabled) + { + if (p_146284_1_.id == 0) + { + this.mc.displayGuiScreen(this.field_146780_f); + } + else if (p_146284_1_.id == 1) + { + String s = "https://account.mojang.com/buy/realms?wid=" + this.field_146781_g.field_148812_a + "?pid=" + this.func_146777_g(); + Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + clipboard.setContents(new StringSelection(s), (ClipboardOwner)null); + this.func_146779_a(s); + } + } + } + + private String func_146777_g() + { + String s = this.mc.getSession().getSessionID(); + String[] astring = s.split(":"); + return astring.length == 3 ? astring[2] : ""; + } + + private void func_146779_a(String p_146779_1_) + { + try + { + URI uri = new URI(p_146779_1_); + Class oclass = Class.forName("java.awt.Desktop"); + Object object = oclass.getMethod("getDesktop", new Class[0]).invoke((Object)null, new Object[0]); + oclass.getMethod("browse", new Class[] {URI.class}).invoke(object, new Object[] {uri}); + } + catch (Throwable throwable) + { + logger.error("Couldn\'t open link"); + } + } + + protected void keyTyped(char par1, int par2) {} + + protected void mouseClicked(int par1, int par2, int par3) + { + super.mouseClicked(par1, par2, par3); + } + + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + this.drawCenteredString(this.fontRendererObj, I18n.format("mco.configure.world.subscription.title", new Object[0]), this.width / 2, 17, 16777215); + this.drawString(this.fontRendererObj, I18n.format("mco.configure.world.subscription.start", new Object[0]), this.width / 2 - 100, 53, 10526880); + this.drawString(this.fontRendererObj, this.field_146784_s, this.width / 2 - 100, 66, 16777215); + this.drawString(this.fontRendererObj, I18n.format("mco.configure.world.subscription.daysleft", new Object[0]), this.width / 2 - 100, 85, 10526880); + this.drawString(this.fontRendererObj, String.valueOf(this.field_146785_r), this.width / 2 - 100, 98, 16777215); + super.drawScreen(par1, par2, par3); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiScreenWorking.java b/src/main/java/net/minecraft/client/gui/GuiScreenWorking.java new file mode 100644 index 0000000..ed2dd0d --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiScreenWorking.java @@ -0,0 +1,57 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.util.IProgressUpdate; + +@SideOnly(Side.CLIENT) +public class GuiScreenWorking extends GuiScreen implements IProgressUpdate +{ + private String field_146591_a = ""; + private String field_146589_f = ""; + private int field_146590_g; + private boolean field_146592_h; + private static final String __OBFID = "CL_00000707"; + + public void displayProgressMessage(String par1Str) + { + this.resetProgressAndMessage(par1Str); + } + + public void resetProgressAndMessage(String par1Str) + { + this.field_146591_a = par1Str; + this.resetProgresAndWorkingMessage("Working..."); + } + + public void resetProgresAndWorkingMessage(String par1Str) + { + this.field_146589_f = par1Str; + this.setLoadingProgress(0); + } + + public void setLoadingProgress(int par1) + { + this.field_146590_g = par1; + } + + public void func_146586_a() + { + this.field_146592_h = true; + } + + public void drawScreen(int par1, int par2, float par3) + { + if (this.field_146592_h) + { + this.mc.displayGuiScreen((GuiScreen)null); + } + else + { + this.drawDefaultBackground(); + this.drawCenteredString(this.fontRendererObj, this.field_146591_a, this.width / 2, 70, 16777215); + this.drawCenteredString(this.fontRendererObj, this.field_146589_f + " " + this.field_146590_g + "%", this.width / 2, 90, 16777215); + super.drawScreen(par1, par2, par3); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiSelectWorld.java b/src/main/java/net/minecraft/client/gui/GuiSelectWorld.java new file mode 100644 index 0000000..b2f12f3 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiSelectWorld.java @@ -0,0 +1,315 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Collections; +import java.util.Date; +import net.minecraft.client.AnvilConverterException; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.resources.I18n; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.MathHelper; +import net.minecraft.world.WorldSettings; +import net.minecraft.world.storage.ISaveFormat; +import net.minecraft.world.storage.ISaveHandler; +import net.minecraft.world.storage.SaveFormatComparator; +import net.minecraft.world.storage.WorldInfo; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +@SideOnly(Side.CLIENT) +public class GuiSelectWorld extends GuiScreen +{ + private static final Logger logger = LogManager.getLogger(); + private final DateFormat field_146633_h = new SimpleDateFormat(); + protected GuiScreen field_146632_a; + protected String field_146628_f = "Select world"; + private boolean field_146634_i; + private int field_146640_r; + private java.util.List field_146639_s; + private GuiSelectWorld.List field_146638_t; + private String field_146637_u; + private String field_146636_v; + private String[] field_146635_w = new String[3]; + private boolean field_146643_x; + private GuiButton field_146642_y; + private GuiButton field_146641_z; + private GuiButton field_146630_A; + private GuiButton field_146631_B; + private static final String __OBFID = "CL_00000711"; + + public GuiSelectWorld(GuiScreen par1GuiScreen) + { + this.field_146632_a = par1GuiScreen; + } + + public void initGui() + { + this.field_146628_f = I18n.format("selectWorld.title", new Object[0]); + + try + { + this.func_146627_h(); + } + catch (AnvilConverterException anvilconverterexception) + { + logger.error("Couldn\'t load level list", anvilconverterexception); + this.mc.displayGuiScreen(new GuiErrorScreen("Unable to load worlds", anvilconverterexception.getMessage())); + return; + } + + this.field_146637_u = I18n.format("selectWorld.world", new Object[0]); + this.field_146636_v = I18n.format("selectWorld.conversion", new Object[0]); + this.field_146635_w[WorldSettings.GameType.SURVIVAL.getID()] = I18n.format("gameMode.survival", new Object[0]); + this.field_146635_w[WorldSettings.GameType.CREATIVE.getID()] = I18n.format("gameMode.creative", new Object[0]); + this.field_146635_w[WorldSettings.GameType.ADVENTURE.getID()] = I18n.format("gameMode.adventure", new Object[0]); + this.field_146638_t = new GuiSelectWorld.List(); + this.field_146638_t.registerScrollButtons(4, 5); + this.func_146618_g(); + } + + private void func_146627_h() throws AnvilConverterException + { + ISaveFormat isaveformat = this.mc.getSaveLoader(); + this.field_146639_s = isaveformat.getSaveList(); + Collections.sort(this.field_146639_s); + this.field_146640_r = -1; + } + + protected String func_146621_a(int p_146621_1_) + { + return ((SaveFormatComparator)this.field_146639_s.get(p_146621_1_)).getFileName(); + } + + protected String func_146614_d(int p_146614_1_) + { + String s = ((SaveFormatComparator)this.field_146639_s.get(p_146614_1_)).getDisplayName(); + + if (s == null || MathHelper.stringNullOrLengthZero(s)) + { + s = I18n.format("selectWorld.world", new Object[0]) + " " + (p_146614_1_ + 1); + } + + return s; + } + + public void func_146618_g() + { + this.buttonList.add(this.field_146641_z = new GuiButton(1, this.width / 2 - 154, this.height - 52, 150, 20, I18n.format("selectWorld.select", new Object[0]))); + this.buttonList.add(new GuiButton(3, this.width / 2 + 4, this.height - 52, 150, 20, I18n.format("selectWorld.create", new Object[0]))); + this.buttonList.add(this.field_146630_A = new GuiButton(6, this.width / 2 - 154, this.height - 28, 72, 20, I18n.format("selectWorld.rename", new Object[0]))); + this.buttonList.add(this.field_146642_y = new GuiButton(2, this.width / 2 - 76, this.height - 28, 72, 20, I18n.format("selectWorld.delete", new Object[0]))); + this.buttonList.add(this.field_146631_B = new GuiButton(7, this.width / 2 + 4, this.height - 28, 72, 20, I18n.format("selectWorld.recreate", new Object[0]))); + this.buttonList.add(new GuiButton(0, this.width / 2 + 82, this.height - 28, 72, 20, I18n.format("gui.cancel", new Object[0]))); + this.field_146641_z.enabled = false; + this.field_146642_y.enabled = false; + this.field_146630_A.enabled = false; + this.field_146631_B.enabled = false; + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.enabled) + { + if (p_146284_1_.id == 2) + { + String s = this.func_146614_d(this.field_146640_r); + + if (s != null) + { + this.field_146643_x = true; + GuiYesNo guiyesno = func_146623_a(this, s, this.field_146640_r); + this.mc.displayGuiScreen(guiyesno); + } + } + else if (p_146284_1_.id == 1) + { + this.func_146615_e(this.field_146640_r); + } + else if (p_146284_1_.id == 3) + { + this.mc.displayGuiScreen(new GuiCreateWorld(this)); + } + else if (p_146284_1_.id == 6) + { + this.mc.displayGuiScreen(new GuiRenameWorld(this, this.func_146621_a(this.field_146640_r))); + } + else if (p_146284_1_.id == 0) + { + this.mc.displayGuiScreen(this.field_146632_a); + } + else if (p_146284_1_.id == 7) + { + GuiCreateWorld guicreateworld = new GuiCreateWorld(this); + ISaveHandler isavehandler = this.mc.getSaveLoader().getSaveLoader(this.func_146621_a(this.field_146640_r), false); + WorldInfo worldinfo = isavehandler.loadWorldInfo(); + isavehandler.flush(); + guicreateworld.func_146318_a(worldinfo); + this.mc.displayGuiScreen(guicreateworld); + } + else + { + this.field_146638_t.actionPerformed(p_146284_1_); + } + } + } + + public void func_146615_e(int p_146615_1_) + { + this.mc.displayGuiScreen((GuiScreen)null); + + if (!this.field_146634_i) + { + this.field_146634_i = true; + String s = this.func_146621_a(p_146615_1_); + + if (s == null) + { + s = "World" + p_146615_1_; + } + + String s1 = this.func_146614_d(p_146615_1_); + + if (s1 == null) + { + s1 = "World" + p_146615_1_; + } + + if (this.mc.getSaveLoader().canLoadWorld(s)) + { + FMLClientHandler.instance().tryLoadExistingWorld(this, s, s1); + } + } + } + + public void confirmClicked(boolean par1, int par2) + { + if (this.field_146643_x) + { + this.field_146643_x = false; + + if (par1) + { + ISaveFormat isaveformat = this.mc.getSaveLoader(); + isaveformat.flushCache(); + isaveformat.deleteWorldDirectory(this.func_146621_a(par2)); + + try + { + this.func_146627_h(); + } + catch (AnvilConverterException anvilconverterexception) + { + logger.error("Couldn\'t load level list", anvilconverterexception); + } + } + + this.mc.displayGuiScreen(this); + } + } + + public void drawScreen(int par1, int par2, float par3) + { + this.field_146638_t.drawScreen(par1, par2, par3); + this.drawCenteredString(this.fontRendererObj, this.field_146628_f, this.width / 2, 20, 16777215); + super.drawScreen(par1, par2, par3); + } + + public static GuiYesNo func_146623_a(GuiScreen p_146623_0_, String p_146623_1_, int p_146623_2_) + { + String s1 = I18n.format("selectWorld.deleteQuestion", new Object[0]); + String s2 = "\'" + p_146623_1_ + "\' " + I18n.format("selectWorld.deleteWarning", new Object[0]); + String s3 = I18n.format("selectWorld.deleteButton", new Object[0]); + String s4 = I18n.format("gui.cancel", new Object[0]); + GuiYesNo guiyesno = new GuiYesNo(p_146623_0_, s1, s2, s3, s4, p_146623_2_); + return guiyesno; + } + + @SideOnly(Side.CLIENT) + class List extends GuiSlot + { + private static final String __OBFID = "CL_00000712"; + + public List() + { + super(GuiSelectWorld.this.mc, GuiSelectWorld.this.width, GuiSelectWorld.this.height, 32, GuiSelectWorld.this.height - 64, 36); + } + + protected int getSize() + { + return GuiSelectWorld.this.field_146639_s.size(); + } + + protected void elementClicked(int p_148144_1_, boolean p_148144_2_, int p_148144_3_, int p_148144_4_) + { + GuiSelectWorld.this.field_146640_r = p_148144_1_; + boolean flag1 = GuiSelectWorld.this.field_146640_r >= 0 && GuiSelectWorld.this.field_146640_r < this.getSize(); + GuiSelectWorld.this.field_146641_z.enabled = flag1; + GuiSelectWorld.this.field_146642_y.enabled = flag1; + GuiSelectWorld.this.field_146630_A.enabled = flag1; + GuiSelectWorld.this.field_146631_B.enabled = flag1; + + if (p_148144_2_ && flag1) + { + GuiSelectWorld.this.func_146615_e(p_148144_1_); + } + } + + protected boolean isSelected(int p_148131_1_) + { + return p_148131_1_ == GuiSelectWorld.this.field_146640_r; + } + + protected int getContentHeight() + { + return GuiSelectWorld.this.field_146639_s.size() * 36; + } + + protected void drawBackground() + { + GuiSelectWorld.this.drawDefaultBackground(); + } + + protected void drawSlot(int p_148126_1_, int p_148126_2_, int p_148126_3_, int p_148126_4_, Tessellator p_148126_5_, int p_148126_6_, int p_148126_7_) + { + SaveFormatComparator saveformatcomparator = (SaveFormatComparator)GuiSelectWorld.this.field_146639_s.get(p_148126_1_); + String s = saveformatcomparator.getDisplayName(); + + if (s == null || MathHelper.stringNullOrLengthZero(s)) + { + s = GuiSelectWorld.this.field_146637_u + " " + (p_148126_1_ + 1); + } + + String s1 = saveformatcomparator.getFileName(); + s1 = s1 + " (" + GuiSelectWorld.this.field_146633_h.format(new Date(saveformatcomparator.getLastTimePlayed())); + s1 = s1 + ")"; + String s2 = ""; + + if (saveformatcomparator.requiresConversion()) + { + s2 = GuiSelectWorld.this.field_146636_v + " " + s2; + } + else + { + s2 = GuiSelectWorld.this.field_146635_w[saveformatcomparator.getEnumGameType().getID()]; + + if (saveformatcomparator.isHardcoreModeEnabled()) + { + s2 = EnumChatFormatting.DARK_RED + I18n.format("gameMode.hardcore", new Object[0]) + EnumChatFormatting.RESET; + } + + if (saveformatcomparator.getCheatsEnabled()) + { + s2 = s2 + ", " + I18n.format("selectWorld.cheats", new Object[0]); + } + } + + GuiSelectWorld.this.drawString(GuiSelectWorld.this.fontRendererObj, s, p_148126_2_ + 2, p_148126_3_ + 1, 16777215); + GuiSelectWorld.this.drawString(GuiSelectWorld.this.fontRendererObj, s1, p_148126_2_ + 2, p_148126_3_ + 12, 8421504); + GuiSelectWorld.this.drawString(GuiSelectWorld.this.fontRendererObj, s2, p_148126_2_ + 2, p_148126_3_ + 12 + 10, 8421504); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiShareToLan.java b/src/main/java/net/minecraft/client/gui/GuiShareToLan.java new file mode 100644 index 0000000..1767b7c --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiShareToLan.java @@ -0,0 +1,105 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.resources.I18n; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.IChatComponent; +import net.minecraft.world.WorldSettings; + +@SideOnly(Side.CLIENT) +public class GuiShareToLan extends GuiScreen +{ + private final GuiScreen field_146598_a; + private GuiButton field_146596_f; + private GuiButton field_146597_g; + private String field_146599_h = "survival"; + private boolean field_146600_i; + private static final String __OBFID = "CL_00000713"; + + public GuiShareToLan(GuiScreen par1GuiScreen) + { + this.field_146598_a = par1GuiScreen; + } + + public void initGui() + { + this.buttonList.clear(); + this.buttonList.add(new GuiButton(101, this.width / 2 - 155, this.height - 28, 150, 20, I18n.format("lanServer.start", new Object[0]))); + this.buttonList.add(new GuiButton(102, this.width / 2 + 5, this.height - 28, 150, 20, I18n.format("gui.cancel", new Object[0]))); + this.buttonList.add(this.field_146597_g = new GuiButton(104, this.width / 2 - 155, 100, 150, 20, I18n.format("selectWorld.gameMode", new Object[0]))); + this.buttonList.add(this.field_146596_f = new GuiButton(103, this.width / 2 + 5, 100, 150, 20, I18n.format("selectWorld.allowCommands", new Object[0]))); + this.func_146595_g(); + } + + private void func_146595_g() + { + this.field_146597_g.displayString = I18n.format("selectWorld.gameMode", new Object[0]) + " " + I18n.format("selectWorld.gameMode." + this.field_146599_h, new Object[0]); + this.field_146596_f.displayString = I18n.format("selectWorld.allowCommands", new Object[0]) + " "; + + if (this.field_146600_i) + { + this.field_146596_f.displayString = this.field_146596_f.displayString + I18n.format("options.on", new Object[0]); + } + else + { + this.field_146596_f.displayString = this.field_146596_f.displayString + I18n.format("options.off", new Object[0]); + } + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.id == 102) + { + this.mc.displayGuiScreen(this.field_146598_a); + } + else if (p_146284_1_.id == 104) + { + if (this.field_146599_h.equals("survival")) + { + this.field_146599_h = "creative"; + } + else if (this.field_146599_h.equals("creative")) + { + this.field_146599_h = "adventure"; + } + else + { + this.field_146599_h = "survival"; + } + + this.func_146595_g(); + } + else if (p_146284_1_.id == 103) + { + this.field_146600_i = !this.field_146600_i; + this.func_146595_g(); + } + else if (p_146284_1_.id == 101) + { + this.mc.displayGuiScreen((GuiScreen)null); + String s = this.mc.getIntegratedServer().shareToLAN(WorldSettings.GameType.getByName(this.field_146599_h), this.field_146600_i); + Object object; + + if (s != null) + { + object = new ChatComponentTranslation("commands.publish.started", new Object[] {s}); + } + else + { + object = new ChatComponentText("commands.publish.failed"); + } + + this.mc.ingameGUI.getChatGUI().printChatMessage((IChatComponent)object); + } + } + + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + this.drawCenteredString(this.fontRendererObj, I18n.format("lanServer.title", new Object[0]), this.width / 2, 50, 16777215); + this.drawCenteredString(this.fontRendererObj, I18n.format("lanServer.otherPlayers", new Object[0]), this.width / 2, 82, 16777215); + super.drawScreen(par1, par2, par3); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiSleepMP.java b/src/main/java/net/minecraft/client/gui/GuiSleepMP.java new file mode 100644 index 0000000..a882121 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiSleepMP.java @@ -0,0 +1,61 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.network.NetHandlerPlayClient; +import net.minecraft.client.resources.I18n; +import net.minecraft.network.play.client.C0BPacketEntityAction; + +@SideOnly(Side.CLIENT) +public class GuiSleepMP extends GuiChat +{ + private static final String __OBFID = "CL_00000697"; + + public void initGui() + { + super.initGui(); + this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height - 40, I18n.format("multiplayer.stopSleeping", new Object[0]))); + } + + protected void keyTyped(char par1, int par2) + { + if (par2 == 1) + { + this.func_146418_g(); + } + else if (par2 != 28 && par2 != 156) + { + super.keyTyped(par1, par2); + } + else + { + String s = this.inputField.getText().trim(); + + if (!s.isEmpty()) + { + this.mc.thePlayer.sendChatMessage(s); + } + + this.inputField.setText(""); + this.mc.ingameGUI.getChatGUI().resetScroll(); + } + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.id == 1) + { + this.func_146418_g(); + } + else + { + super.actionPerformed(p_146284_1_); + } + } + + private void func_146418_g() + { + NetHandlerPlayClient nethandlerplayclient = this.mc.thePlayer.sendQueue; + nethandlerplayclient.addToSendQueue(new C0BPacketEntityAction(this.mc.thePlayer, 3)); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiSlot.java b/src/main/java/net/minecraft/client/gui/GuiSlot.java new file mode 100644 index 0000000..4ab124e --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiSlot.java @@ -0,0 +1,483 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.Tessellator; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public abstract class GuiSlot +{ + private final Minecraft mc; + protected int width; + private int height; + protected int top; + protected int bottom; + protected int right; + protected int left; + protected final int slotHeight; + private int scrollUpButtonID; + private int scrollDownButtonID; + protected int mouseX; + protected int mouseY; + protected boolean field_148163_i = true; + private float initialClickY = -2.0F; + private float scrollMultiplier; + private float amountScrolled; + private int selectedElement = -1; + private long lastClicked; + private boolean showSelectionBox = true; + private boolean hasListHeader; + protected int headerPadding; + private boolean field_148164_v = true; + private static final String __OBFID = "CL_00000679"; + + public GuiSlot(Minecraft par1Minecraft, int par2, int par3, int par4, int par5, int par6) + { + this.mc = par1Minecraft; + this.width = par2; + this.height = par3; + this.top = par4; + this.bottom = par5; + this.slotHeight = par6; + this.left = 0; + this.right = par2; + } + + public void func_148122_a(int p_148122_1_, int p_148122_2_, int p_148122_3_, int p_148122_4_) + { + this.width = p_148122_1_; + this.height = p_148122_2_; + this.top = p_148122_3_; + this.bottom = p_148122_4_; + this.left = 0; + this.right = p_148122_1_; + } + + public void setShowSelectionBox(boolean p_148130_1_) + { + this.showSelectionBox = p_148130_1_; + } + + protected void setHasListHeader(boolean p_148133_1_, int p_148133_2_) + { + this.hasListHeader = p_148133_1_; + this.headerPadding = p_148133_2_; + + if (!p_148133_1_) + { + this.headerPadding = 0; + } + } + + protected abstract int getSize(); + + protected abstract void elementClicked(int var1, boolean var2, int var3, int var4); + + protected abstract boolean isSelected(int var1); + + protected int getContentHeight() + { + return this.getSize() * this.slotHeight + this.headerPadding; + } + + protected abstract void drawBackground(); + + protected abstract void drawSlot(int var1, int var2, int var3, int var4, Tessellator var5, int var6, int var7); + + protected void drawListHeader(int p_148129_1_, int p_148129_2_, Tessellator p_148129_3_) {} + + protected void func_148132_a(int p_148132_1_, int p_148132_2_) {} + + protected void func_148142_b(int p_148142_1_, int p_148142_2_) {} + + public int func_148124_c(int p_148124_1_, int p_148124_2_) + { + int k = this.left + this.width / 2 - this.getListWidth() / 2; + int l = this.left + this.width / 2 + this.getListWidth() / 2; + int i1 = p_148124_2_ - this.top - this.headerPadding + (int)this.amountScrolled - 4; + int j1 = i1 / this.slotHeight; + return p_148124_1_ < this.getScrollBarX() && p_148124_1_ >= k && p_148124_1_ <= l && j1 >= 0 && i1 >= 0 && j1 < this.getSize() ? j1 : -1; + } + + public void registerScrollButtons(int p_148134_1_, int p_148134_2_) + { + this.scrollUpButtonID = p_148134_1_; + this.scrollDownButtonID = p_148134_2_; + } + + private void bindAmountScrolled() + { + int i = this.func_148135_f(); + + if (i < 0) + { + i /= 2; + } + + if (!this.field_148163_i && i < 0) + { + i = 0; + } + + if (this.amountScrolled < 0.0F) + { + this.amountScrolled = 0.0F; + } + + if (this.amountScrolled > (float)i) + { + this.amountScrolled = (float)i; + } + } + + public int func_148135_f() + { + return this.getContentHeight() - (this.bottom - this.top - 4); + } + + public int getAmountScrolled() + { + return (int)this.amountScrolled; + } + + public boolean func_148141_e(int p_148141_1_) + { + return p_148141_1_ >= this.top && p_148141_1_ <= this.bottom; + } + + public void scrollBy(int p_148145_1_) + { + this.amountScrolled += (float)p_148145_1_; + this.bindAmountScrolled(); + this.initialClickY = -2.0F; + } + + public void actionPerformed(GuiButton p_148147_1_) + { + if (p_148147_1_.enabled) + { + if (p_148147_1_.id == this.scrollUpButtonID) + { + this.amountScrolled -= (float)(this.slotHeight * 2 / 3); + this.initialClickY = -2.0F; + this.bindAmountScrolled(); + } + else if (p_148147_1_.id == this.scrollDownButtonID) + { + this.amountScrolled += (float)(this.slotHeight * 2 / 3); + this.initialClickY = -2.0F; + this.bindAmountScrolled(); + } + } + } + + public void drawScreen(int p_148128_1_, int p_148128_2_, float p_148128_3_) + { + this.mouseX = p_148128_1_; + this.mouseY = p_148128_2_; + this.drawBackground(); + int k = this.getSize(); + int l = this.getScrollBarX(); + int i1 = l + 6; + int l1; + int i2; + int k2; + int i3; + + if (p_148128_1_ > this.left && p_148128_1_ < this.right && p_148128_2_ > this.top && p_148128_2_ < this.bottom) + { + if (Mouse.isButtonDown(0) && this.func_148125_i()) + { + if (this.initialClickY == -1.0F) + { + boolean flag1 = true; + + if (p_148128_2_ >= this.top && p_148128_2_ <= this.bottom) + { + int k1 = this.width / 2 - this.getListWidth() / 2; + l1 = this.width / 2 + this.getListWidth() / 2; + i2 = p_148128_2_ - this.top - this.headerPadding + (int)this.amountScrolled - 4; + int j2 = i2 / this.slotHeight; + + if (p_148128_1_ >= k1 && p_148128_1_ <= l1 && j2 >= 0 && i2 >= 0 && j2 < k) + { + boolean flag = j2 == this.selectedElement && Minecraft.getSystemTime() - this.lastClicked < 250L; + this.elementClicked(j2, flag, p_148128_1_, p_148128_2_); + this.selectedElement = j2; + this.lastClicked = Minecraft.getSystemTime(); + } + else if (p_148128_1_ >= k1 && p_148128_1_ <= l1 && i2 < 0) + { + this.func_148132_a(p_148128_1_ - k1, p_148128_2_ - this.top + (int)this.amountScrolled - 4); + flag1 = false; + } + + if (p_148128_1_ >= l && p_148128_1_ <= i1) + { + this.scrollMultiplier = -1.0F; + i3 = this.func_148135_f(); + + if (i3 < 1) + { + i3 = 1; + } + + k2 = (int)((float)((this.bottom - this.top) * (this.bottom - this.top)) / (float)this.getContentHeight()); + + if (k2 < 32) + { + k2 = 32; + } + + if (k2 > this.bottom - this.top - 8) + { + k2 = this.bottom - this.top - 8; + } + + this.scrollMultiplier /= (float)(this.bottom - this.top - k2) / (float)i3; + } + else + { + this.scrollMultiplier = 1.0F; + } + + if (flag1) + { + this.initialClickY = (float)p_148128_2_; + } + else + { + this.initialClickY = -2.0F; + } + } + else + { + this.initialClickY = -2.0F; + } + } + else if (this.initialClickY >= 0.0F) + { + this.amountScrolled -= ((float)p_148128_2_ - this.initialClickY) * this.scrollMultiplier; + this.initialClickY = (float)p_148128_2_; + } + } + else + { + for (; !this.mc.gameSettings.touchscreen && Mouse.next(); this.mc.currentScreen.handleMouseInput()) + { + int j1 = Mouse.getEventDWheel(); + + if (j1 != 0) + { + if (j1 > 0) + { + j1 = -1; + } + else if (j1 < 0) + { + j1 = 1; + } + + this.amountScrolled += (float)(j1 * this.slotHeight / 2); + } + } + + this.initialClickY = -1.0F; + } + } + + this.bindAmountScrolled(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_FOG); + Tessellator tessellator = Tessellator.instance; + drawContainerBackground(tessellator); + l1 = this.left + this.width / 2 - this.getListWidth() / 2 + 2; + i2 = this.top + 4 - (int)this.amountScrolled; + + if (this.hasListHeader) + { + this.drawListHeader(l1, i2, tessellator); + } + + this.drawSelectionBox(l1, i2, p_148128_1_, p_148128_2_); + GL11.glDisable(GL11.GL_DEPTH_TEST); + byte b0 = 4; + this.overlayBackground(0, this.top, 255, 255); + this.overlayBackground(this.bottom, this.height, 255, 255); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 0, 1); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glShadeModel(GL11.GL_SMOOTH); + GL11.glDisable(GL11.GL_TEXTURE_2D); + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_I(0, 0); + tessellator.addVertexWithUV((double)this.left, (double)(this.top + b0), 0.0D, 0.0D, 1.0D); + tessellator.addVertexWithUV((double)this.right, (double)(this.top + b0), 0.0D, 1.0D, 1.0D); + tessellator.setColorRGBA_I(0, 255); + tessellator.addVertexWithUV((double)this.right, (double)this.top, 0.0D, 1.0D, 0.0D); + tessellator.addVertexWithUV((double)this.left, (double)this.top, 0.0D, 0.0D, 0.0D); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_I(0, 255); + tessellator.addVertexWithUV((double)this.left, (double)this.bottom, 0.0D, 0.0D, 1.0D); + tessellator.addVertexWithUV((double)this.right, (double)this.bottom, 0.0D, 1.0D, 1.0D); + tessellator.setColorRGBA_I(0, 0); + tessellator.addVertexWithUV((double)this.right, (double)(this.bottom - b0), 0.0D, 1.0D, 0.0D); + tessellator.addVertexWithUV((double)this.left, (double)(this.bottom - b0), 0.0D, 0.0D, 0.0D); + tessellator.draw(); + i3 = this.func_148135_f(); + + if (i3 > 0) + { + k2 = (this.bottom - this.top) * (this.bottom - this.top) / this.getContentHeight(); + + if (k2 < 32) + { + k2 = 32; + } + + if (k2 > this.bottom - this.top - 8) + { + k2 = this.bottom - this.top - 8; + } + + int l2 = (int)this.amountScrolled * (this.bottom - this.top - k2) / i3 + this.top; + + if (l2 < this.top) + { + l2 = this.top; + } + + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_I(0, 255); + tessellator.addVertexWithUV((double)l, (double)this.bottom, 0.0D, 0.0D, 1.0D); + tessellator.addVertexWithUV((double)i1, (double)this.bottom, 0.0D, 1.0D, 1.0D); + tessellator.addVertexWithUV((double)i1, (double)this.top, 0.0D, 1.0D, 0.0D); + tessellator.addVertexWithUV((double)l, (double)this.top, 0.0D, 0.0D, 0.0D); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_I(8421504, 255); + tessellator.addVertexWithUV((double)l, (double)(l2 + k2), 0.0D, 0.0D, 1.0D); + tessellator.addVertexWithUV((double)i1, (double)(l2 + k2), 0.0D, 1.0D, 1.0D); + tessellator.addVertexWithUV((double)i1, (double)l2, 0.0D, 1.0D, 0.0D); + tessellator.addVertexWithUV((double)l, (double)l2, 0.0D, 0.0D, 0.0D); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_I(12632256, 255); + tessellator.addVertexWithUV((double)l, (double)(l2 + k2 - 1), 0.0D, 0.0D, 1.0D); + tessellator.addVertexWithUV((double)(i1 - 1), (double)(l2 + k2 - 1), 0.0D, 1.0D, 1.0D); + tessellator.addVertexWithUV((double)(i1 - 1), (double)l2, 0.0D, 1.0D, 0.0D); + tessellator.addVertexWithUV((double)l, (double)l2, 0.0D, 0.0D, 0.0D); + tessellator.draw(); + } + + this.func_148142_b(p_148128_1_, p_148128_2_); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glShadeModel(GL11.GL_FLAT); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glDisable(GL11.GL_BLEND); + } + + public void func_148143_b(boolean p_148143_1_) + { + this.field_148164_v = p_148143_1_; + } + + public boolean func_148125_i() + { + return this.field_148164_v; + } + + public int getListWidth() + { + return 220; + } + + protected void drawSelectionBox(int p_148120_1_, int p_148120_2_, int p_148120_3_, int p_148120_4_) + { + int i1 = this.getSize(); + Tessellator tessellator = Tessellator.instance; + + for (int j1 = 0; j1 < i1; ++j1) + { + int k1 = p_148120_2_ + j1 * this.slotHeight + this.headerPadding; + int l1 = this.slotHeight - 4; + + if (k1 <= this.bottom && k1 + l1 >= this.top) + { + if (this.showSelectionBox && this.isSelected(j1)) + { + int i2 = this.left + (this.width / 2 - this.getListWidth() / 2); + int j2 = this.left + this.width / 2 + this.getListWidth() / 2; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_TEXTURE_2D); + tessellator.startDrawingQuads(); + tessellator.setColorOpaque_I(8421504); + tessellator.addVertexWithUV((double)i2, (double)(k1 + l1 + 2), 0.0D, 0.0D, 1.0D); + tessellator.addVertexWithUV((double)j2, (double)(k1 + l1 + 2), 0.0D, 1.0D, 1.0D); + tessellator.addVertexWithUV((double)j2, (double)(k1 - 2), 0.0D, 1.0D, 0.0D); + tessellator.addVertexWithUV((double)i2, (double)(k1 - 2), 0.0D, 0.0D, 0.0D); + tessellator.setColorOpaque_I(0); + tessellator.addVertexWithUV((double)(i2 + 1), (double)(k1 + l1 + 1), 0.0D, 0.0D, 1.0D); + tessellator.addVertexWithUV((double)(j2 - 1), (double)(k1 + l1 + 1), 0.0D, 1.0D, 1.0D); + tessellator.addVertexWithUV((double)(j2 - 1), (double)(k1 - 1), 0.0D, 1.0D, 0.0D); + tessellator.addVertexWithUV((double)(i2 + 1), (double)(k1 - 1), 0.0D, 0.0D, 0.0D); + tessellator.draw(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + + this.drawSlot(j1, p_148120_1_, k1, l1, tessellator, p_148120_3_, p_148120_4_); + } + } + } + + protected int getScrollBarX() + { + return this.width / 2 + 124; + } + + private void overlayBackground(int p_148136_1_, int p_148136_2_, int p_148136_3_, int p_148136_4_) + { + Tessellator tessellator = Tessellator.instance; + this.mc.getTextureManager().bindTexture(Gui.optionsBackground); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + float f = 32.0F; + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_I(4210752, p_148136_4_); + tessellator.addVertexWithUV((double)this.left, (double)p_148136_2_, 0.0D, 0.0D, (double)((float)p_148136_2_ / f)); + tessellator.addVertexWithUV((double)(this.left + this.width), (double)p_148136_2_, 0.0D, (double)((float)this.width / f), (double)((float)p_148136_2_ / f)); + tessellator.setColorRGBA_I(4210752, p_148136_3_); + tessellator.addVertexWithUV((double)(this.left + this.width), (double)p_148136_1_, 0.0D, (double)((float)this.width / f), (double)((float)p_148136_1_ / f)); + tessellator.addVertexWithUV((double)this.left, (double)p_148136_1_, 0.0D, 0.0D, (double)((float)p_148136_1_ / f)); + tessellator.draw(); + } + + public void setSlotXBoundsFromLeft(int p_148140_1_) + { + this.left = p_148140_1_; + this.right = p_148140_1_ + this.width; + } + + public int getSlotHeight() + { + return this.slotHeight; + } + + protected void drawContainerBackground(Tessellator tessellator) + { + this.mc.getTextureManager().bindTexture(Gui.optionsBackground); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + float f1 = 32.0F; + tessellator.startDrawingQuads(); + tessellator.setColorOpaque_I(2105376); + tessellator.addVertexWithUV((double)this.left, (double)this.bottom, 0.0D, (double)((float)this.left / f1), (double)((float)(this.bottom + (int)this.amountScrolled) / f1)); + tessellator.addVertexWithUV((double)this.right, (double)this.bottom, 0.0D, (double)((float)this.right / f1), (double)((float)(this.bottom + (int)this.amountScrolled) / f1)); + tessellator.addVertexWithUV((double)this.right, (double)this.top, 0.0D, (double)((float)this.right / f1), (double)((float)(this.top + (int)this.amountScrolled) / f1)); + tessellator.addVertexWithUV((double)this.left, (double)this.top, 0.0D, (double)((float)this.left / f1), (double)((float)(this.top + (int)this.amountScrolled) / f1)); + tessellator.draw(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiSnooper.java b/src/main/java/net/minecraft/client/gui/GuiSnooper.java new file mode 100644 index 0000000..462eef4 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiSnooper.java @@ -0,0 +1,149 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.TreeMap; +import java.util.Map.Entry; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.resources.I18n; +import net.minecraft.client.settings.GameSettings; + +@SideOnly(Side.CLIENT) +public class GuiSnooper extends GuiScreen +{ + private final GuiScreen field_146608_a; + private final GameSettings field_146603_f; + private final java.util.List field_146604_g = new ArrayList(); + private final java.util.List field_146609_h = new ArrayList(); + private String field_146610_i; + private String[] field_146607_r; + private GuiSnooper.List field_146606_s; + private GuiButton field_146605_t; + private static final String __OBFID = "CL_00000714"; + + public GuiSnooper(GuiScreen par1GuiScreen, GameSettings par2GameSettings) + { + this.field_146608_a = par1GuiScreen; + this.field_146603_f = par2GameSettings; + } + + public void initGui() + { + this.field_146610_i = I18n.format("options.snooper.title", new Object[0]); + String s = I18n.format("options.snooper.desc", new Object[0]); + ArrayList arraylist = new ArrayList(); + Iterator iterator = this.fontRendererObj.listFormattedStringToWidth(s, this.width - 30).iterator(); + + while (iterator.hasNext()) + { + String s1 = (String)iterator.next(); + arraylist.add(s1); + } + + this.field_146607_r = (String[])arraylist.toArray(new String[0]); + this.field_146604_g.clear(); + this.field_146609_h.clear(); + this.buttonList.add(this.field_146605_t = new GuiButton(1, this.width / 2 - 152, this.height - 30, 150, 20, this.field_146603_f.getKeyBinding(GameSettings.Options.SNOOPER_ENABLED))); + this.buttonList.add(new GuiButton(2, this.width / 2 + 2, this.height - 30, 150, 20, I18n.format("gui.done", new Object[0]))); + boolean flag = this.mc.getIntegratedServer() != null && this.mc.getIntegratedServer().getPlayerUsageSnooper() != null; + Iterator iterator1 = (new TreeMap(this.mc.getPlayerUsageSnooper().getCurrentStats())).entrySet().iterator(); + Entry entry; + + while (iterator1.hasNext()) + { + entry = (Entry)iterator1.next(); + this.field_146604_g.add((flag ? "C " : "") + (String)entry.getKey()); + this.field_146609_h.add(this.fontRendererObj.trimStringToWidth((String)entry.getValue(), this.width - 220)); + } + + if (flag) + { + iterator1 = (new TreeMap(this.mc.getIntegratedServer().getPlayerUsageSnooper().getCurrentStats())).entrySet().iterator(); + + while (iterator1.hasNext()) + { + entry = (Entry)iterator1.next(); + this.field_146604_g.add("S " + (String)entry.getKey()); + this.field_146609_h.add(this.fontRendererObj.trimStringToWidth((String)entry.getValue(), this.width - 220)); + } + } + + this.field_146606_s = new GuiSnooper.List(); + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.enabled) + { + if (p_146284_1_.id == 2) + { + this.field_146603_f.saveOptions(); + this.field_146603_f.saveOptions(); + this.mc.displayGuiScreen(this.field_146608_a); + } + + if (p_146284_1_.id == 1) + { + this.field_146603_f.setOptionValue(GameSettings.Options.SNOOPER_ENABLED, 1); + this.field_146605_t.displayString = this.field_146603_f.getKeyBinding(GameSettings.Options.SNOOPER_ENABLED); + } + } + } + + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + this.field_146606_s.drawScreen(par1, par2, par3); + this.drawCenteredString(this.fontRendererObj, this.field_146610_i, this.width / 2, 8, 16777215); + int k = 22; + String[] astring = this.field_146607_r; + int l = astring.length; + + for (int i1 = 0; i1 < l; ++i1) + { + String s = astring[i1]; + this.drawCenteredString(this.fontRendererObj, s, this.width / 2, k, 8421504); + k += this.fontRendererObj.FONT_HEIGHT; + } + + super.drawScreen(par1, par2, par3); + } + + @SideOnly(Side.CLIENT) + class List extends GuiSlot + { + private static final String __OBFID = "CL_00000715"; + + public List() + { + super(GuiSnooper.this.mc, GuiSnooper.this.width, GuiSnooper.this.height, 80, GuiSnooper.this.height - 40, GuiSnooper.this.fontRendererObj.FONT_HEIGHT + 1); + } + + protected int getSize() + { + return GuiSnooper.this.field_146604_g.size(); + } + + protected void elementClicked(int p_148144_1_, boolean p_148144_2_, int p_148144_3_, int p_148144_4_) {} + + protected boolean isSelected(int p_148131_1_) + { + return false; + } + + protected void drawBackground() {} + + protected void drawSlot(int p_148126_1_, int p_148126_2_, int p_148126_3_, int p_148126_4_, Tessellator p_148126_5_, int p_148126_6_, int p_148126_7_) + { + GuiSnooper.this.fontRendererObj.drawString((String)GuiSnooper.this.field_146604_g.get(p_148126_1_), 10, p_148126_3_, 16777215); + GuiSnooper.this.fontRendererObj.drawString((String)GuiSnooper.this.field_146609_h.get(p_148126_1_), 230, p_148126_3_, 16777215); + } + + protected int getScrollBarX() + { + return this.width - 10; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiTextField.java b/src/main/java/net/minecraft/client/gui/GuiTextField.java new file mode 100644 index 0000000..231b8ef --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiTextField.java @@ -0,0 +1,664 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.ChatAllowedCharacters; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class GuiTextField extends Gui +{ + private final FontRenderer field_146211_a; + private final int xPosition; + private final int yPosition; + private final int width; + private final int height; + private String text = ""; + private int maxStringLength = 32; + private int cursorCounter; + private boolean enableBackgroundDrawing = true; + private boolean canLoseFocus = true; + private boolean isFocused; + private boolean isEnabled = true; + private int lineScrollOffset; + private int cursorPosition; + private int selectionEnd; + private int enabledColor = 14737632; + private int disabledColor = 7368816; + private boolean visible = true; + private static final String __OBFID = "CL_00000670"; + + public GuiTextField(FontRenderer par1FontRenderer, int par2, int par3, int par4, int par5) + { + this.field_146211_a = par1FontRenderer; + this.xPosition = par2; + this.yPosition = par3; + this.width = par4; + this.height = par5; + } + + public void updateCursorCounter() + { + ++this.cursorCounter; + } + + public void setText(String p_146180_1_) + { + if (p_146180_1_.length() > this.maxStringLength) + { + this.text = p_146180_1_.substring(0, this.maxStringLength); + } + else + { + this.text = p_146180_1_; + } + + this.setCursorPositionEnd(); + } + + public String getText() + { + return this.text; + } + + public String getSelectedText() + { + int i = this.cursorPosition < this.selectionEnd ? this.cursorPosition : this.selectionEnd; + int j = this.cursorPosition < this.selectionEnd ? this.selectionEnd : this.cursorPosition; + return this.text.substring(i, j); + } + + public void writeText(String p_146191_1_) + { + String s1 = ""; + String s2 = ChatAllowedCharacters.filerAllowedCharacters(p_146191_1_); + int i = this.cursorPosition < this.selectionEnd ? this.cursorPosition : this.selectionEnd; + int j = this.cursorPosition < this.selectionEnd ? this.selectionEnd : this.cursorPosition; + int k = this.maxStringLength - this.text.length() - (i - this.selectionEnd); + boolean flag = false; + + if (this.text.length() > 0) + { + s1 = s1 + this.text.substring(0, i); + } + + int l; + + if (k < s2.length()) + { + s1 = s1 + s2.substring(0, k); + l = k; + } + else + { + s1 = s1 + s2; + l = s2.length(); + } + + if (this.text.length() > 0 && j < this.text.length()) + { + s1 = s1 + this.text.substring(j); + } + + this.text = s1; + this.moveCursorBy(i - this.selectionEnd + l); + } + + public void deleteWords(int p_146177_1_) + { + if (this.text.length() != 0) + { + if (this.selectionEnd != this.cursorPosition) + { + this.writeText(""); + } + else + { + this.deleteFromCursor(this.getNthWordFromCursor(p_146177_1_) - this.cursorPosition); + } + } + } + + public void deleteFromCursor(int p_146175_1_) + { + if (this.text.length() != 0) + { + if (this.selectionEnd != this.cursorPosition) + { + this.writeText(""); + } + else + { + boolean flag = p_146175_1_ < 0; + int j = flag ? this.cursorPosition + p_146175_1_ : this.cursorPosition; + int k = flag ? this.cursorPosition : this.cursorPosition + p_146175_1_; + String s = ""; + + if (j >= 0) + { + s = this.text.substring(0, j); + } + + if (k < this.text.length()) + { + s = s + this.text.substring(k); + } + + this.text = s; + + if (flag) + { + this.moveCursorBy(p_146175_1_); + } + } + } + } + + public int getNthWordFromCursor(int p_146187_1_) + { + return this.getNthWordFromPos(p_146187_1_, this.getCursorPosition()); + } + + public int getNthWordFromPos(int p_146183_1_, int p_146183_2_) + { + return this.func_146197_a(p_146183_1_, this.getCursorPosition(), true); + } + + public int func_146197_a(int p_146197_1_, int p_146197_2_, boolean p_146197_3_) + { + int k = p_146197_2_; + boolean flag1 = p_146197_1_ < 0; + int l = Math.abs(p_146197_1_); + + for (int i1 = 0; i1 < l; ++i1) + { + if (flag1) + { + while (p_146197_3_ && k > 0 && this.text.charAt(k - 1) == 32) + { + --k; + } + + while (k > 0 && this.text.charAt(k - 1) != 32) + { + --k; + } + } + else + { + int j1 = this.text.length(); + k = this.text.indexOf(32, k); + + if (k == -1) + { + k = j1; + } + else + { + while (p_146197_3_ && k < j1 && this.text.charAt(k) == 32) + { + ++k; + } + } + } + } + + return k; + } + + public void moveCursorBy(int p_146182_1_) + { + this.setCursorPosition(this.selectionEnd + p_146182_1_); + } + + public void setCursorPosition(int p_146190_1_) + { + this.cursorPosition = p_146190_1_; + int j = this.text.length(); + + if (this.cursorPosition < 0) + { + this.cursorPosition = 0; + } + + if (this.cursorPosition > j) + { + this.cursorPosition = j; + } + + this.setSelectionPos(this.cursorPosition); + } + + public void setCursorPositionZero() + { + this.setCursorPosition(0); + } + + public void setCursorPositionEnd() + { + this.setCursorPosition(this.text.length()); + } + + public boolean textboxKeyTyped(char p_146201_1_, int p_146201_2_) + { + if (!this.isFocused) + { + return false; + } + else + { + switch (p_146201_1_) + { + case 1: + this.setCursorPositionEnd(); + this.setSelectionPos(0); + return true; + case 3: + GuiScreen.setClipboardString(this.getSelectedText()); + return true; + case 22: + if (this.isEnabled) + { + this.writeText(GuiScreen.getClipboardString()); + } + + return true; + case 24: + GuiScreen.setClipboardString(this.getSelectedText()); + + if (this.isEnabled) + { + this.writeText(""); + } + + return true; + default: + switch (p_146201_2_) + { + case 14: + if (GuiScreen.isCtrlKeyDown()) + { + if (this.isEnabled) + { + this.deleteWords(-1); + } + } + else if (this.isEnabled) + { + this.deleteFromCursor(-1); + } + + return true; + case 199: + if (GuiScreen.isShiftKeyDown()) + { + this.setSelectionPos(0); + } + else + { + this.setCursorPositionZero(); + } + + return true; + case 203: + if (GuiScreen.isShiftKeyDown()) + { + if (GuiScreen.isCtrlKeyDown()) + { + this.setSelectionPos(this.getNthWordFromPos(-1, this.getSelectionEnd())); + } + else + { + this.setSelectionPos(this.getSelectionEnd() - 1); + } + } + else if (GuiScreen.isCtrlKeyDown()) + { + this.setCursorPosition(this.getNthWordFromCursor(-1)); + } + else + { + this.moveCursorBy(-1); + } + + return true; + case 205: + if (GuiScreen.isShiftKeyDown()) + { + if (GuiScreen.isCtrlKeyDown()) + { + this.setSelectionPos(this.getNthWordFromPos(1, this.getSelectionEnd())); + } + else + { + this.setSelectionPos(this.getSelectionEnd() + 1); + } + } + else if (GuiScreen.isCtrlKeyDown()) + { + this.setCursorPosition(this.getNthWordFromCursor(1)); + } + else + { + this.moveCursorBy(1); + } + + return true; + case 207: + if (GuiScreen.isShiftKeyDown()) + { + this.setSelectionPos(this.text.length()); + } + else + { + this.setCursorPositionEnd(); + } + + return true; + case 211: + if (GuiScreen.isCtrlKeyDown()) + { + if (this.isEnabled) + { + this.deleteWords(1); + } + } + else if (this.isEnabled) + { + this.deleteFromCursor(1); + } + + return true; + default: + if (ChatAllowedCharacters.isAllowedCharacter(p_146201_1_)) + { + if (this.isEnabled) + { + this.writeText(Character.toString(p_146201_1_)); + } + + return true; + } + else + { + return false; + } + } + } + } + } + + public void mouseClicked(int p_146192_1_, int p_146192_2_, int p_146192_3_) + { + boolean flag = p_146192_1_ >= this.xPosition && p_146192_1_ < this.xPosition + this.width && p_146192_2_ >= this.yPosition && p_146192_2_ < this.yPosition + this.height; + + if (this.canLoseFocus) + { + this.setFocused(flag); + } + + if (this.isFocused && p_146192_3_ == 0) + { + int l = p_146192_1_ - this.xPosition; + + if (this.enableBackgroundDrawing) + { + l -= 4; + } + + String s = this.field_146211_a.trimStringToWidth(this.text.substring(this.lineScrollOffset), this.getWidth()); + this.setCursorPosition(this.field_146211_a.trimStringToWidth(s, l).length() + this.lineScrollOffset); + } + } + + public void drawTextBox() + { + if (this.getVisible()) + { + if (this.getEnableBackgroundDrawing()) + { + drawRect(this.xPosition - 1, this.yPosition - 1, this.xPosition + this.width + 1, this.yPosition + this.height + 1, -6250336); + drawRect(this.xPosition, this.yPosition, this.xPosition + this.width, this.yPosition + this.height, -16777216); + } + + int i = this.isEnabled ? this.enabledColor : this.disabledColor; + int j = this.cursorPosition - this.lineScrollOffset; + int k = this.selectionEnd - this.lineScrollOffset; + String s = this.field_146211_a.trimStringToWidth(this.text.substring(this.lineScrollOffset), this.getWidth()); + boolean flag = j >= 0 && j <= s.length(); + boolean flag1 = this.isFocused && this.cursorCounter / 6 % 2 == 0 && flag; + int l = this.enableBackgroundDrawing ? this.xPosition + 4 : this.xPosition; + int i1 = this.enableBackgroundDrawing ? this.yPosition + (this.height - 8) / 2 : this.yPosition; + int j1 = l; + + if (k > s.length()) + { + k = s.length(); + } + + if (s.length() > 0) + { + String s1 = flag ? s.substring(0, j) : s; + j1 = this.field_146211_a.drawStringWithShadow(s1, l, i1, i); + } + + boolean flag2 = this.cursorPosition < this.text.length() || this.text.length() >= this.getMaxStringLength(); + int k1 = j1; + + if (!flag) + { + k1 = j > 0 ? l + this.width : l; + } + else if (flag2) + { + k1 = j1 - 1; + --j1; + } + + if (s.length() > 0 && flag && j < s.length()) + { + this.field_146211_a.drawStringWithShadow(s.substring(j), j1, i1, i); + } + + if (flag1) + { + if (flag2) + { + Gui.drawRect(k1, i1 - 1, k1 + 1, i1 + 1 + this.field_146211_a.FONT_HEIGHT, -3092272); + } + else + { + this.field_146211_a.drawStringWithShadow("_", k1, i1, i); + } + } + + if (k != j) + { + int l1 = l + this.field_146211_a.getStringWidth(s.substring(0, k)); + this.drawCursorVertical(k1, i1 - 1, l1 - 1, i1 + 1 + this.field_146211_a.FONT_HEIGHT); + } + } + } + + private void drawCursorVertical(int p_146188_1_, int p_146188_2_, int p_146188_3_, int p_146188_4_) + { + int i1; + + if (p_146188_1_ < p_146188_3_) + { + i1 = p_146188_1_; + p_146188_1_ = p_146188_3_; + p_146188_3_ = i1; + } + + if (p_146188_2_ < p_146188_4_) + { + i1 = p_146188_2_; + p_146188_2_ = p_146188_4_; + p_146188_4_ = i1; + } + + if (p_146188_3_ > this.xPosition + this.width) + { + p_146188_3_ = this.xPosition + this.width; + } + + if (p_146188_1_ > this.xPosition + this.width) + { + p_146188_1_ = this.xPosition + this.width; + } + + Tessellator tessellator = Tessellator.instance; + GL11.glColor4f(0.0F, 0.0F, 255.0F, 255.0F); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_COLOR_LOGIC_OP); + GL11.glLogicOp(GL11.GL_OR_REVERSE); + tessellator.startDrawingQuads(); + tessellator.addVertex((double)p_146188_1_, (double)p_146188_4_, 0.0D); + tessellator.addVertex((double)p_146188_3_, (double)p_146188_4_, 0.0D); + tessellator.addVertex((double)p_146188_3_, (double)p_146188_2_, 0.0D); + tessellator.addVertex((double)p_146188_1_, (double)p_146188_2_, 0.0D); + tessellator.draw(); + GL11.glDisable(GL11.GL_COLOR_LOGIC_OP); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + + public void setMaxStringLength(int p_146203_1_) + { + this.maxStringLength = p_146203_1_; + + if (this.text.length() > p_146203_1_) + { + this.text = this.text.substring(0, p_146203_1_); + } + } + + public int getMaxStringLength() + { + return this.maxStringLength; + } + + public int getCursorPosition() + { + return this.cursorPosition; + } + + public boolean getEnableBackgroundDrawing() + { + return this.enableBackgroundDrawing; + } + + public void setEnableBackgroundDrawing(boolean p_146185_1_) + { + this.enableBackgroundDrawing = p_146185_1_; + } + + public void setTextColor(int p_146193_1_) + { + this.enabledColor = p_146193_1_; + } + + public void setDisabledTextColour(int p_146204_1_) + { + this.disabledColor = p_146204_1_; + } + + public void setFocused(boolean p_146195_1_) + { + if (p_146195_1_ && !this.isFocused) + { + this.cursorCounter = 0; + } + + this.isFocused = p_146195_1_; + } + + public boolean isFocused() + { + return this.isFocused; + } + + public void setEnabled(boolean p_146184_1_) + { + this.isEnabled = p_146184_1_; + } + + public int getSelectionEnd() + { + return this.selectionEnd; + } + + public int getWidth() + { + return this.getEnableBackgroundDrawing() ? this.width - 8 : this.width; + } + + public void setSelectionPos(int p_146199_1_) + { + int j = this.text.length(); + + if (p_146199_1_ > j) + { + p_146199_1_ = j; + } + + if (p_146199_1_ < 0) + { + p_146199_1_ = 0; + } + + this.selectionEnd = p_146199_1_; + + if (this.field_146211_a != null) + { + if (this.lineScrollOffset > j) + { + this.lineScrollOffset = j; + } + + int k = this.getWidth(); + String s = this.field_146211_a.trimStringToWidth(this.text.substring(this.lineScrollOffset), k); + int l = s.length() + this.lineScrollOffset; + + if (p_146199_1_ == this.lineScrollOffset) + { + this.lineScrollOffset -= this.field_146211_a.trimStringToWidth(this.text, k, true).length(); + } + + if (p_146199_1_ > l) + { + this.lineScrollOffset += p_146199_1_ - l; + } + else if (p_146199_1_ <= this.lineScrollOffset) + { + this.lineScrollOffset -= this.lineScrollOffset - p_146199_1_; + } + + if (this.lineScrollOffset < 0) + { + this.lineScrollOffset = 0; + } + + if (this.lineScrollOffset > j) + { + this.lineScrollOffset = j; + } + } + } + + public void setCanLoseFocus(boolean p_146205_1_) + { + this.canLoseFocus = p_146205_1_; + } + + public boolean getVisible() + { + return this.visible; + } + + public void setVisible(boolean p_146189_1_) + { + this.visible = p_146189_1_; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiVideoSettings.java b/src/main/java/net/minecraft/client/gui/GuiVideoSettings.java new file mode 100644 index 0000000..bdd36c5 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiVideoSettings.java @@ -0,0 +1,81 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.resources.I18n; +import net.minecraft.client.settings.GameSettings; + +@SideOnly(Side.CLIENT) +public class GuiVideoSettings extends GuiScreen +{ + private GuiScreen parentGuiScreen; + protected String screenTitle = "Video Settings"; + private GameSettings guiGameSettings; + private GuiListExtended optionsRowList; + private static final GameSettings.Options[] videoOptions = new GameSettings.Options[] {GameSettings.Options.GRAPHICS, GameSettings.Options.RENDER_DISTANCE, GameSettings.Options.AMBIENT_OCCLUSION, GameSettings.Options.FRAMERATE_LIMIT, GameSettings.Options.ANAGLYPH, GameSettings.Options.VIEW_BOBBING, GameSettings.Options.GUI_SCALE, GameSettings.Options.ADVANCED_OPENGL, GameSettings.Options.GAMMA, GameSettings.Options.RENDER_CLOUDS, GameSettings.Options.PARTICLES, GameSettings.Options.USE_SERVER_TEXTURES, GameSettings.Options.USE_FULLSCREEN, GameSettings.Options.ENABLE_VSYNC, GameSettings.Options.MIPMAP_LEVELS, GameSettings.Options.ANISOTROPIC_FILTERING}; + private static final String __OBFID = "CL_00000718"; + + public GuiVideoSettings(GuiScreen par1GuiScreen, GameSettings par2GameSettings) + { + this.parentGuiScreen = par1GuiScreen; + this.guiGameSettings = par2GameSettings; + } + + public void initGui() + { + this.screenTitle = I18n.format("options.videoTitle", new Object[0]); + this.buttonList.clear(); + this.buttonList.add(new GuiButton(200, this.width / 2 - 100, this.height - 27, I18n.format("gui.done", new Object[0]))); + this.optionsRowList = new GuiOptionsRowList(this.mc, this.width, this.height, 32, this.height - 32, 25, videoOptions); + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.enabled) + { + if (p_146284_1_.id == 200) + { + this.mc.gameSettings.saveOptions(); + this.mc.displayGuiScreen(this.parentGuiScreen); + } + } + } + + protected void mouseClicked(int par1, int par2, int par3) + { + int l = this.guiGameSettings.guiScale; + super.mouseClicked(par1, par2, par3); + this.optionsRowList.func_148179_a(par1, par2, par3); + + if (this.guiGameSettings.guiScale != l) + { + ScaledResolution scaledresolution = new ScaledResolution(this.mc.gameSettings, this.mc.displayWidth, this.mc.displayHeight); + int i1 = scaledresolution.getScaledWidth(); + int j1 = scaledresolution.getScaledHeight(); + this.setWorldAndResolution(this.mc, i1, j1); + } + } + + protected void mouseMovedOrUp(int p_146286_1_, int p_146286_2_, int p_146286_3_) + { + int l = this.guiGameSettings.guiScale; + super.mouseMovedOrUp(p_146286_1_, p_146286_2_, p_146286_3_); + this.optionsRowList.func_148181_b(p_146286_1_, p_146286_2_, p_146286_3_); + + if (this.guiGameSettings.guiScale != l) + { + ScaledResolution scaledresolution = new ScaledResolution(this.mc.gameSettings, this.mc.displayWidth, this.mc.displayHeight); + int i1 = scaledresolution.getScaledWidth(); + int j1 = scaledresolution.getScaledHeight(); + this.setWorldAndResolution(this.mc, i1, j1); + } + } + + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + this.optionsRowList.drawScreen(par1, par2, par3); + this.drawCenteredString(this.fontRendererObj, this.screenTitle, this.width / 2, 5, 16777215); + super.drawScreen(par1, par2, par3); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiWinGame.java b/src/main/java/net/minecraft/client/gui/GuiWinGame.java new file mode 100644 index 0000000..da4d9e2 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiWinGame.java @@ -0,0 +1,214 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.network.play.client.C16PacketClientStatus; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; +import org.apache.commons.io.Charsets; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class GuiWinGame extends GuiScreen +{ + private static final Logger logger = LogManager.getLogger(); + private static final ResourceLocation field_146576_f = new ResourceLocation("textures/gui/title/minecraft.png"); + private static final ResourceLocation field_146577_g = new ResourceLocation("textures/misc/vignette.png"); + private int field_146581_h; + private List field_146582_i; + private int field_146579_r; + private float field_146578_s = 0.5F; + private static final String __OBFID = "CL_00000719"; + + public void updateScreen() + { + ++this.field_146581_h; + float f = (float)(this.field_146579_r + this.height + this.height + 24) / this.field_146578_s; + + if ((float)this.field_146581_h > f) + { + this.func_146574_g(); + } + } + + protected void keyTyped(char par1, int par2) + { + if (par2 == 1) + { + this.func_146574_g(); + } + } + + private void func_146574_g() + { + this.mc.thePlayer.sendQueue.addToSendQueue(new C16PacketClientStatus(C16PacketClientStatus.EnumState.PERFORM_RESPAWN)); + this.mc.displayGuiScreen((GuiScreen)null); + } + + public boolean doesGuiPauseGame() + { + return true; + } + + public void initGui() + { + if (this.field_146582_i == null) + { + this.field_146582_i = new ArrayList(); + + try + { + String s = ""; + String s1 = "" + EnumChatFormatting.WHITE + EnumChatFormatting.OBFUSCATED + EnumChatFormatting.GREEN + EnumChatFormatting.AQUA; + short short1 = 274; + BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(this.mc.getResourceManager().getResource(new ResourceLocation("texts/end.txt")).getInputStream(), Charsets.UTF_8)); + Random random = new Random(8124371L); + int i; + + while ((s = bufferedreader.readLine()) != null) + { + String s2; + String s3; + + for (s = s.replaceAll("PLAYERNAME", this.mc.getSession().getUsername()); s.contains(s1); s = s2 + EnumChatFormatting.WHITE + EnumChatFormatting.OBFUSCATED + "XXXXXXXX".substring(0, random.nextInt(4) + 3) + s3) + { + i = s.indexOf(s1); + s2 = s.substring(0, i); + s3 = s.substring(i + s1.length()); + } + + this.field_146582_i.addAll(this.mc.fontRenderer.listFormattedStringToWidth(s, short1)); + this.field_146582_i.add(""); + } + + for (i = 0; i < 8; ++i) + { + this.field_146582_i.add(""); + } + + bufferedreader = new BufferedReader(new InputStreamReader(this.mc.getResourceManager().getResource(new ResourceLocation("texts/credits.txt")).getInputStream(), Charsets.UTF_8)); + + while ((s = bufferedreader.readLine()) != null) + { + s = s.replaceAll("PLAYERNAME", this.mc.getSession().getUsername()); + s = s.replaceAll("\t", " "); + this.field_146582_i.addAll(this.mc.fontRenderer.listFormattedStringToWidth(s, short1)); + this.field_146582_i.add(""); + } + + this.field_146579_r = this.field_146582_i.size() * 12; + } + catch (Exception exception) + { + logger.error("Couldn\'t load credits", exception); + } + } + } + + private void func_146575_b(int p_146575_1_, int p_146575_2_, float p_146575_3_) + { + Tessellator tessellator = Tessellator.instance; + this.mc.getTextureManager().bindTexture(Gui.optionsBackground); + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_F(1.0F, 1.0F, 1.0F, 1.0F); + int k = this.width; + float f1 = 0.0F - ((float)this.field_146581_h + p_146575_3_) * 0.5F * this.field_146578_s; + float f2 = (float)this.height - ((float)this.field_146581_h + p_146575_3_) * 0.5F * this.field_146578_s; + float f3 = 0.015625F; + float f4 = ((float)this.field_146581_h + p_146575_3_ - 0.0F) * 0.02F; + float f5 = (float)(this.field_146579_r + this.height + this.height + 24) / this.field_146578_s; + float f6 = (f5 - 20.0F - ((float)this.field_146581_h + p_146575_3_)) * 0.005F; + + if (f6 < f4) + { + f4 = f6; + } + + if (f4 > 1.0F) + { + f4 = 1.0F; + } + + f4 *= f4; + f4 = f4 * 96.0F / 255.0F; + tessellator.setColorOpaque_F(f4, f4, f4); + tessellator.addVertexWithUV(0.0D, (double)this.height, (double)this.zLevel, 0.0D, (double)(f1 * f3)); + tessellator.addVertexWithUV((double)k, (double)this.height, (double)this.zLevel, (double)((float)k * f3), (double)(f1 * f3)); + tessellator.addVertexWithUV((double)k, 0.0D, (double)this.zLevel, (double)((float)k * f3), (double)(f2 * f3)); + tessellator.addVertexWithUV(0.0D, 0.0D, (double)this.zLevel, 0.0D, (double)(f2 * f3)); + tessellator.draw(); + } + + public void drawScreen(int par1, int par2, float par3) + { + this.func_146575_b(par1, par2, par3); + Tessellator tessellator = Tessellator.instance; + short short1 = 274; + int k = this.width / 2 - short1 / 2; + int l = this.height + 50; + float f1 = -((float)this.field_146581_h + par3) * this.field_146578_s; + GL11.glPushMatrix(); + GL11.glTranslatef(0.0F, f1, 0.0F); + this.mc.getTextureManager().bindTexture(field_146576_f); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.drawTexturedModalRect(k, l, 0, 0, 155, 44); + this.drawTexturedModalRect(k + 155, l, 0, 45, 155, 44); + tessellator.setColorOpaque_I(16777215); + int i1 = l + 200; + int j1; + + for (j1 = 0; j1 < this.field_146582_i.size(); ++j1) + { + if (j1 == this.field_146582_i.size() - 1) + { + float f2 = (float)i1 + f1 - (float)(this.height / 2 - 6); + + if (f2 < 0.0F) + { + GL11.glTranslatef(0.0F, -f2, 0.0F); + } + } + + if ((float)i1 + f1 + 12.0F + 8.0F > 0.0F && (float)i1 + f1 < (float)this.height) + { + String s = (String)this.field_146582_i.get(j1); + + if (s.startsWith("[C]")) + { + this.fontRendererObj.drawStringWithShadow(s.substring(3), k + (short1 - this.fontRendererObj.getStringWidth(s.substring(3))) / 2, i1, 16777215); + } + else + { + this.fontRendererObj.fontRandom.setSeed((long)j1 * 4238972211L + (long)(this.field_146581_h / 4)); + this.fontRendererObj.drawStringWithShadow(s, k, i1, 16777215); + } + } + + i1 += 12; + } + + GL11.glPopMatrix(); + this.mc.getTextureManager().bindTexture(field_146577_g); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_ZERO, GL11.GL_ONE_MINUS_SRC_COLOR); + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_F(1.0F, 1.0F, 1.0F, 1.0F); + j1 = this.width; + int k1 = this.height; + tessellator.addVertexWithUV(0.0D, (double)k1, (double)this.zLevel, 0.0D, 1.0D); + tessellator.addVertexWithUV((double)j1, (double)k1, (double)this.zLevel, 1.0D, 1.0D); + tessellator.addVertexWithUV((double)j1, 0.0D, (double)this.zLevel, 1.0D, 0.0D); + tessellator.addVertexWithUV(0.0D, 0.0D, (double)this.zLevel, 0.0D, 0.0D); + tessellator.draw(); + GL11.glDisable(GL11.GL_BLEND); + super.drawScreen(par1, par2, par3); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/GuiYesNo.java b/src/main/java/net/minecraft/client/gui/GuiYesNo.java new file mode 100644 index 0000000..2be9737 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/GuiYesNo.java @@ -0,0 +1,83 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Iterator; +import net.minecraft.client.resources.I18n; + +@SideOnly(Side.CLIENT) +public class GuiYesNo extends GuiScreen +{ + protected GuiScreen parentScreen; + protected String field_146351_f; + private String field_146354_r; + protected String confirmButtonText; + protected String cancelButtonText; + protected int field_146357_i; + private int field_146353_s; + private static final String __OBFID = "CL_00000684"; + + public GuiYesNo(GuiScreen par1GuiScreen, String par2Str, String par3Str, int par4) + { + this.parentScreen = par1GuiScreen; + this.field_146351_f = par2Str; + this.field_146354_r = par3Str; + this.field_146357_i = par4; + this.confirmButtonText = I18n.format("gui.yes", new Object[0]); + this.cancelButtonText = I18n.format("gui.no", new Object[0]); + } + + public GuiYesNo(GuiScreen par1GuiScreen, String par2Str, String par3Str, String par4Str, String par5Str, int par6) + { + this.parentScreen = par1GuiScreen; + this.field_146351_f = par2Str; + this.field_146354_r = par3Str; + this.confirmButtonText = par4Str; + this.cancelButtonText = par5Str; + this.field_146357_i = par6; + } + + public void initGui() + { + this.buttonList.add(new GuiOptionButton(0, this.width / 2 - 155, this.height / 6 + 96, this.confirmButtonText)); + this.buttonList.add(new GuiOptionButton(1, this.width / 2 - 155 + 160, this.height / 6 + 96, this.cancelButtonText)); + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + this.parentScreen.confirmClicked(p_146284_1_.id == 0, this.field_146357_i); + } + + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + this.drawCenteredString(this.fontRendererObj, this.field_146351_f, this.width / 2, 70, 16777215); + this.drawCenteredString(this.fontRendererObj, this.field_146354_r, this.width / 2, 90, 16777215); + super.drawScreen(par1, par2, par3); + } + + public void func_146350_a(int p_146350_1_) + { + this.field_146353_s = p_146350_1_; + GuiButton guibutton; + + for (Iterator iterator = this.buttonList.iterator(); iterator.hasNext(); guibutton.enabled = false) + { + guibutton = (GuiButton)iterator.next(); + } + } + + public void updateScreen() + { + super.updateScreen(); + GuiButton guibutton; + + if (--this.field_146353_s == 0) + { + for (Iterator iterator = this.buttonList.iterator(); iterator.hasNext(); guibutton.enabled = true) + { + guibutton = (GuiButton)iterator.next(); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/IProgressMeter.java b/src/main/java/net/minecraft/client/gui/IProgressMeter.java new file mode 100644 index 0000000..ad29fff --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/IProgressMeter.java @@ -0,0 +1,12 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public interface IProgressMeter +{ + String[] field_146510_b_ = new String[] {"oooooo", "Oooooo", "oOoooo", "ooOooo", "oooOoo", "ooooOo", "oooooO"}; + + void func_146509_g(); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/MapItemRenderer.java b/src/main/java/net/minecraft/client/gui/MapItemRenderer.java new file mode 100644 index 0000000..6ac136c --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/MapItemRenderer.java @@ -0,0 +1,166 @@ +package net.minecraft.client.gui; + +import com.google.common.collect.Maps; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Iterator; +import java.util.Map; +import net.minecraft.block.material.MapColor; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.DynamicTexture; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.storage.MapData; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class MapItemRenderer +{ + private static final ResourceLocation field_148253_a = new ResourceLocation("textures/map/map_icons.png"); + private final TextureManager field_148251_b; + private final Map field_148252_c = Maps.newHashMap(); + private static final String __OBFID = "CL_00000663"; + + public MapItemRenderer(TextureManager p_i45009_1_) + { + this.field_148251_b = p_i45009_1_; + } + + public void func_148246_a(MapData p_148246_1_) + { + this.func_148248_b(p_148246_1_).func_148236_a(); + } + + public void func_148250_a(MapData p_148250_1_, boolean p_148250_2_) + { + this.func_148248_b(p_148250_1_).func_148237_a(p_148250_2_); + } + + private MapItemRenderer.Instance func_148248_b(MapData p_148248_1_) + { + MapItemRenderer.Instance instance = (MapItemRenderer.Instance)this.field_148252_c.get(p_148248_1_.mapName); + + if (instance == null) + { + instance = new MapItemRenderer.Instance(p_148248_1_, null); + this.field_148252_c.put(p_148248_1_.mapName, instance); + } + + return instance; + } + + public void func_148249_a() + { + Iterator iterator = this.field_148252_c.values().iterator(); + + while (iterator.hasNext()) + { + MapItemRenderer.Instance instance = (MapItemRenderer.Instance)iterator.next(); + this.field_148251_b.deleteTexture(instance.field_148240_d); + } + + this.field_148252_c.clear(); + } + + @SideOnly(Side.CLIENT) + class Instance + { + private final MapData field_148242_b; + private final DynamicTexture field_148243_c; + private final ResourceLocation field_148240_d; + private final int[] field_148241_e; + private static final String __OBFID = "CL_00000665"; + + private Instance(MapData p_i45007_2_) + { + this.field_148242_b = p_i45007_2_; + this.field_148243_c = new DynamicTexture(128, 128); + this.field_148241_e = this.field_148243_c.getTextureData(); + this.field_148240_d = MapItemRenderer.this.field_148251_b.getDynamicTextureLocation("map/" + p_i45007_2_.mapName, this.field_148243_c); + + for (int i = 0; i < this.field_148241_e.length; ++i) + { + this.field_148241_e[i] = 0; + } + } + + private void func_148236_a() + { + for (int i = 0; i < 16384; ++i) + { + int j = this.field_148242_b.colors[i] & 255; + + if (j / 4 == 0) + { + this.field_148241_e[i] = (i + i / 128 & 1) * 8 + 16 << 24; + } + else + { + this.field_148241_e[i] = MapColor.mapColorArray[j / 4].func_151643_b(j & 3); + } + } + + this.field_148243_c.updateDynamicTexture(); + } + + private void func_148237_a(boolean p_148237_1_) + { + byte b0 = 0; + byte b1 = 0; + Tessellator tessellator = Tessellator.instance; + float f = 0.0F; + MapItemRenderer.this.field_148251_b.bindTexture(this.field_148240_d); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(1, 771, 0, 1); + GL11.glDisable(GL11.GL_ALPHA_TEST); + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV((double)((float)(b0 + 0) + f), (double)((float)(b1 + 128) - f), -0.009999999776482582D, 0.0D, 1.0D); + tessellator.addVertexWithUV((double)((float)(b0 + 128) - f), (double)((float)(b1 + 128) - f), -0.009999999776482582D, 1.0D, 1.0D); + tessellator.addVertexWithUV((double)((float)(b0 + 128) - f), (double)((float)(b1 + 0) + f), -0.009999999776482582D, 1.0D, 0.0D); + tessellator.addVertexWithUV((double)((float)(b0 + 0) + f), (double)((float)(b1 + 0) + f), -0.009999999776482582D, 0.0D, 0.0D); + tessellator.draw(); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glDisable(GL11.GL_BLEND); + MapItemRenderer.this.field_148251_b.bindTexture(MapItemRenderer.field_148253_a); + int i = 0; + Iterator iterator = this.field_148242_b.playersVisibleOnMap.values().iterator(); + + while (iterator.hasNext()) + { + MapData.MapCoord mapcoord = (MapData.MapCoord)iterator.next(); + + if (!p_148237_1_ || mapcoord.iconSize == 1) + { + GL11.glPushMatrix(); + GL11.glTranslatef((float)b0 + (float)mapcoord.centerX / 2.0F + 64.0F, (float)b1 + (float)mapcoord.centerZ / 2.0F + 64.0F, -0.02F); + GL11.glRotatef((float)(mapcoord.iconRotation * 360) / 16.0F, 0.0F, 0.0F, 1.0F); + GL11.glScalef(4.0F, 4.0F, 3.0F); + GL11.glTranslatef(-0.125F, 0.125F, 0.0F); + float f1 = (float)(mapcoord.iconSize % 4 + 0) / 4.0F; + float f2 = (float)(mapcoord.iconSize / 4 + 0) / 4.0F; + float f3 = (float)(mapcoord.iconSize % 4 + 1) / 4.0F; + float f4 = (float)(mapcoord.iconSize / 4 + 1) / 4.0F; + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV(-1.0D, 1.0D, (double)((float)i * 0.001F), (double)f1, (double)f2); + tessellator.addVertexWithUV(1.0D, 1.0D, (double)((float)i * 0.001F), (double)f3, (double)f2); + tessellator.addVertexWithUV(1.0D, -1.0D, (double)((float)i * 0.001F), (double)f3, (double)f4); + tessellator.addVertexWithUV(-1.0D, -1.0D, (double)((float)i * 0.001F), (double)f1, (double)f4); + tessellator.draw(); + GL11.glPopMatrix(); + ++i; + } + } + + GL11.glPushMatrix(); + GL11.glTranslatef(0.0F, 0.0F, -0.04F); + GL11.glScalef(1.0F, 1.0F, 1.0F); + GL11.glPopMatrix(); + } + + Instance(MapData p_i45008_2_, Object p_i45008_3_) + { + this(p_i45008_2_); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/ScaledResolution.java b/src/main/java/net/minecraft/client/gui/ScaledResolution.java new file mode 100644 index 0000000..08f667b --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/ScaledResolution.java @@ -0,0 +1,65 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.settings.GameSettings; +import net.minecraft.util.MathHelper; + +@SideOnly(Side.CLIENT) +public class ScaledResolution +{ + private int scaledWidth; + private int scaledHeight; + private double scaledWidthD; + private double scaledHeightD; + private int scaleFactor; + private static final String __OBFID = "CL_00000666"; + + public ScaledResolution(GameSettings par1GameSettings, int par2, int par3) + { + this.scaledWidth = par2; + this.scaledHeight = par3; + this.scaleFactor = 1; + int k = par1GameSettings.guiScale; + + if (k == 0) + { + k = 1000; + } + + while (this.scaleFactor < k && this.scaledWidth / (this.scaleFactor + 1) >= 320 && this.scaledHeight / (this.scaleFactor + 1) >= 240) + { + ++this.scaleFactor; + } + + this.scaledWidthD = (double)this.scaledWidth / (double)this.scaleFactor; + this.scaledHeightD = (double)this.scaledHeight / (double)this.scaleFactor; + this.scaledWidth = MathHelper.ceiling_double_int(this.scaledWidthD); + this.scaledHeight = MathHelper.ceiling_double_int(this.scaledHeightD); + } + + public int getScaledWidth() + { + return this.scaledWidth; + } + + public int getScaledHeight() + { + return this.scaledHeight; + } + + public double getScaledWidth_double() + { + return this.scaledWidthD; + } + + public double getScaledHeight_double() + { + return this.scaledHeightD; + } + + public int getScaleFactor() + { + return this.scaleFactor; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/ScreenChatOptions.java b/src/main/java/net/minecraft/client/gui/ScreenChatOptions.java new file mode 100644 index 0000000..520d201 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/ScreenChatOptions.java @@ -0,0 +1,106 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.resources.I18n; +import net.minecraft.client.settings.GameSettings; + +@SideOnly(Side.CLIENT) +public class ScreenChatOptions extends GuiScreen +{ + private static final GameSettings.Options[] field_146399_a = new GameSettings.Options[] {GameSettings.Options.CHAT_VISIBILITY, GameSettings.Options.CHAT_COLOR, GameSettings.Options.CHAT_LINKS, GameSettings.Options.CHAT_OPACITY, GameSettings.Options.CHAT_LINKS_PROMPT, GameSettings.Options.CHAT_SCALE, GameSettings.Options.CHAT_HEIGHT_FOCUSED, GameSettings.Options.CHAT_HEIGHT_UNFOCUSED, GameSettings.Options.CHAT_WIDTH}; + private static final GameSettings.Options[] field_146395_f = new GameSettings.Options[] {GameSettings.Options.SHOW_CAPE}; + private final GuiScreen field_146396_g; + private final GameSettings field_146400_h; + private String field_146401_i; + private String field_146398_r; + private int field_146397_s; + private static final String __OBFID = "CL_00000681"; + + public ScreenChatOptions(GuiScreen par1GuiScreen, GameSettings par2GameSettings) + { + this.field_146396_g = par1GuiScreen; + this.field_146400_h = par2GameSettings; + } + + public void initGui() + { + int i = 0; + this.field_146401_i = I18n.format("options.chat.title", new Object[0]); + this.field_146398_r = I18n.format("options.multiplayer.title", new Object[0]); + GameSettings.Options[] aoptions = field_146399_a; + int j = aoptions.length; + int k; + GameSettings.Options options; + + for (k = 0; k < j; ++k) + { + options = aoptions[k]; + + if (options.getEnumFloat()) + { + this.buttonList.add(new GuiOptionSlider(options.returnEnumOrdinal(), this.width / 2 - 155 + i % 2 * 160, this.height / 6 + 24 * (i >> 1), options)); + } + else + { + this.buttonList.add(new GuiOptionButton(options.returnEnumOrdinal(), this.width / 2 - 155 + i % 2 * 160, this.height / 6 + 24 * (i >> 1), options, this.field_146400_h.getKeyBinding(options))); + } + + ++i; + } + + if (i % 2 == 1) + { + ++i; + } + + this.field_146397_s = this.height / 6 + 24 * (i >> 1); + i += 2; + aoptions = field_146395_f; + j = aoptions.length; + + for (k = 0; k < j; ++k) + { + options = aoptions[k]; + + if (options.getEnumFloat()) + { + this.buttonList.add(new GuiOptionSlider(options.returnEnumOrdinal(), this.width / 2 - 155 + i % 2 * 160, this.height / 6 + 24 * (i >> 1), options)); + } + else + { + this.buttonList.add(new GuiOptionButton(options.returnEnumOrdinal(), this.width / 2 - 155 + i % 2 * 160, this.height / 6 + 24 * (i >> 1), options, this.field_146400_h.getKeyBinding(options))); + } + + ++i; + } + + this.buttonList.add(new GuiButton(200, this.width / 2 - 100, this.height / 6 + 168, I18n.format("gui.done", new Object[0]))); + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.enabled) + { + if (p_146284_1_.id < 100 && p_146284_1_ instanceof GuiOptionButton) + { + this.field_146400_h.setOptionValue(((GuiOptionButton)p_146284_1_).returnEnumOptions(), 1); + p_146284_1_.displayString = this.field_146400_h.getKeyBinding(GameSettings.Options.getEnumOptions(p_146284_1_.id)); + } + + if (p_146284_1_.id == 200) + { + this.mc.gameSettings.saveOptions(); + this.mc.displayGuiScreen(this.field_146396_g); + } + } + } + + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + this.drawCenteredString(this.fontRendererObj, this.field_146401_i, this.width / 2, 20, 16777215); + this.drawCenteredString(this.fontRendererObj, this.field_146398_r, this.width / 2, this.field_146397_s + 7, 16777215); + super.drawScreen(par1, par2, par3); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/SelectionListBase.java b/src/main/java/net/minecraft/client/gui/SelectionListBase.java new file mode 100644 index 0000000..dd45158 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/SelectionListBase.java @@ -0,0 +1,319 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.Tessellator; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public abstract class SelectionListBase +{ + private final Minecraft field_148456_a; + private final int field_148453_e; + private final int field_148450_f; + private final int field_148451_g; + private final int field_148461_h; + protected final int field_148454_b; + protected int field_148455_c; + protected int field_148452_d; + private float field_148462_i = -2.0F; + private float field_148459_j; + private float field_148460_k; + private int field_148457_l = -1; + private long field_148458_m; + private static final String __OBFID = "CL_00000789"; + + public SelectionListBase(Minecraft par1Minecraft, int par2, int par3, int par4, int par5, int par6) + { + this.field_148456_a = par1Minecraft; + this.field_148450_f = par3; + this.field_148461_h = par3 + par5; + this.field_148454_b = par6; + this.field_148453_e = par2; + this.field_148451_g = par2 + par4; + } + + protected abstract int func_148443_a(); + + protected abstract void func_148449_a(int var1, boolean var2); + + protected abstract boolean func_148444_a(int var1); + + protected int func_148447_b() + { + return this.func_148443_a() * this.field_148454_b; + } + + protected abstract void func_148445_c(); + + protected abstract void func_148442_a(int var1, int var2, int var3, int var4, Tessellator var5); + + private void func_148448_f() + { + int i = this.func_148441_d(); + + if (i < 0) + { + i = 0; + } + + if (this.field_148460_k < 0.0F) + { + this.field_148460_k = 0.0F; + } + + if (this.field_148460_k > (float)i) + { + this.field_148460_k = (float)i; + } + } + + public int func_148441_d() + { + return this.func_148447_b() - (this.field_148461_h - this.field_148450_f - 4); + } + + public void func_148446_a(int p_148446_1_, int p_148446_2_, float p_148446_3_) + { + this.field_148455_c = p_148446_1_; + this.field_148452_d = p_148446_2_; + this.func_148445_c(); + int k = this.func_148443_a(); + int l = this.func_148440_e(); + int i1 = l + 6; + int k1; + int l1; + int i2; + int j2; + int j3; + + if (Mouse.isButtonDown(0)) + { + if (this.field_148462_i == -1.0F) + { + boolean flag = true; + + if (p_148446_2_ >= this.field_148450_f && p_148446_2_ <= this.field_148461_h) + { + int j1 = this.field_148453_e + 2; + k1 = this.field_148451_g - 2; + l1 = p_148446_2_ - this.field_148450_f + (int)this.field_148460_k - 4; + i2 = l1 / this.field_148454_b; + + if (p_148446_1_ >= j1 && p_148446_1_ <= k1 && i2 >= 0 && l1 >= 0 && i2 < k) + { + boolean flag1 = i2 == this.field_148457_l && Minecraft.getSystemTime() - this.field_148458_m < 250L; + this.func_148449_a(i2, flag1); + this.field_148457_l = i2; + this.field_148458_m = Minecraft.getSystemTime(); + } + else if (p_148446_1_ >= j1 && p_148446_1_ <= k1 && l1 < 0) + { + flag = false; + } + + if (p_148446_1_ >= l && p_148446_1_ <= i1) + { + this.field_148459_j = -1.0F; + j3 = this.func_148441_d(); + + if (j3 < 1) + { + j3 = 1; + } + + j2 = (int)((float)((this.field_148461_h - this.field_148450_f) * (this.field_148461_h - this.field_148450_f)) / (float)this.func_148447_b()); + + if (j2 < 32) + { + j2 = 32; + } + + if (j2 > this.field_148461_h - this.field_148450_f - 8) + { + j2 = this.field_148461_h - this.field_148450_f - 8; + } + + this.field_148459_j /= (float)(this.field_148461_h - this.field_148450_f - j2) / (float)j3; + } + else + { + this.field_148459_j = 1.0F; + } + + if (flag) + { + this.field_148462_i = (float)p_148446_2_; + } + else + { + this.field_148462_i = -2.0F; + } + } + else + { + this.field_148462_i = -2.0F; + } + } + else if (this.field_148462_i >= 0.0F) + { + this.field_148460_k -= ((float)p_148446_2_ - this.field_148462_i) * this.field_148459_j; + this.field_148462_i = (float)p_148446_2_; + } + } + else + { + while (!this.field_148456_a.gameSettings.touchscreen && Mouse.next()) + { + int i3 = Mouse.getEventDWheel(); + + if (i3 != 0) + { + if (i3 > 0) + { + i3 = -1; + } + else if (i3 < 0) + { + i3 = 1; + } + + this.field_148460_k += (float)(i3 * this.field_148454_b / 2); + } + } + + this.field_148462_i = -1.0F; + } + + this.func_148448_f(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_FOG); + Tessellator tessellator = Tessellator.instance; + this.field_148456_a.getTextureManager().bindTexture(Gui.optionsBackground); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + float f1 = 32.0F; + tessellator.startDrawingQuads(); + tessellator.setColorOpaque_I(2105376); + tessellator.addVertexWithUV((double)this.field_148453_e, (double)this.field_148461_h, 0.0D, (double)((float)this.field_148453_e / f1), (double)((float)(this.field_148461_h + (int)this.field_148460_k) / f1)); + tessellator.addVertexWithUV((double)this.field_148451_g, (double)this.field_148461_h, 0.0D, (double)((float)this.field_148451_g / f1), (double)((float)(this.field_148461_h + (int)this.field_148460_k) / f1)); + tessellator.addVertexWithUV((double)this.field_148451_g, (double)this.field_148450_f, 0.0D, (double)((float)this.field_148451_g / f1), (double)((float)(this.field_148450_f + (int)this.field_148460_k) / f1)); + tessellator.addVertexWithUV((double)this.field_148453_e, (double)this.field_148450_f, 0.0D, (double)((float)this.field_148453_e / f1), (double)((float)(this.field_148450_f + (int)this.field_148460_k) / f1)); + tessellator.draw(); + k1 = this.field_148453_e + 2; + l1 = this.field_148450_f + 4 - (int)this.field_148460_k; + int k2; + + for (i2 = 0; i2 < k; ++i2) + { + j3 = l1 + i2 * this.field_148454_b; + j2 = this.field_148454_b - 4; + + if (j3 + this.field_148454_b <= this.field_148461_h && j3 - 4 >= this.field_148450_f) + { + if (this.func_148444_a(i2)) + { + k2 = this.field_148453_e + 2; + int l2 = this.field_148451_g - 2; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_TEXTURE_2D); + tessellator.startDrawingQuads(); + tessellator.setColorOpaque_I(8421504); + tessellator.addVertexWithUV((double)k2, (double)(j3 + j2 + 2), 0.0D, 0.0D, 1.0D); + tessellator.addVertexWithUV((double)l2, (double)(j3 + j2 + 2), 0.0D, 1.0D, 1.0D); + tessellator.addVertexWithUV((double)l2, (double)(j3 - 2), 0.0D, 1.0D, 0.0D); + tessellator.addVertexWithUV((double)k2, (double)(j3 - 2), 0.0D, 0.0D, 0.0D); + tessellator.setColorOpaque_I(0); + tessellator.addVertexWithUV((double)(k2 + 1), (double)(j3 + j2 + 1), 0.0D, 0.0D, 1.0D); + tessellator.addVertexWithUV((double)(l2 - 1), (double)(j3 + j2 + 1), 0.0D, 1.0D, 1.0D); + tessellator.addVertexWithUV((double)(l2 - 1), (double)(j3 - 1), 0.0D, 1.0D, 0.0D); + tessellator.addVertexWithUV((double)(k2 + 1), (double)(j3 - 1), 0.0D, 0.0D, 0.0D); + tessellator.draw(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + + this.func_148442_a(i2, k1, j3, j2, tessellator); + } + } + + GL11.glDisable(GL11.GL_DEPTH_TEST); + byte b0 = 4; + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glShadeModel(GL11.GL_SMOOTH); + GL11.glDisable(GL11.GL_TEXTURE_2D); + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_I(0, 0); + tessellator.addVertexWithUV((double)this.field_148453_e, (double)(this.field_148450_f + b0), 0.0D, 0.0D, 1.0D); + tessellator.addVertexWithUV((double)this.field_148451_g, (double)(this.field_148450_f + b0), 0.0D, 1.0D, 1.0D); + tessellator.setColorRGBA_I(0, 255); + tessellator.addVertexWithUV((double)this.field_148451_g, (double)this.field_148450_f, 0.0D, 1.0D, 0.0D); + tessellator.addVertexWithUV((double)this.field_148453_e, (double)this.field_148450_f, 0.0D, 0.0D, 0.0D); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_I(0, 255); + tessellator.addVertexWithUV((double)this.field_148453_e, (double)this.field_148461_h, 0.0D, 0.0D, 1.0D); + tessellator.addVertexWithUV((double)this.field_148451_g, (double)this.field_148461_h, 0.0D, 1.0D, 1.0D); + tessellator.setColorRGBA_I(0, 0); + tessellator.addVertexWithUV((double)this.field_148451_g, (double)(this.field_148461_h - b0), 0.0D, 1.0D, 0.0D); + tessellator.addVertexWithUV((double)this.field_148453_e, (double)(this.field_148461_h - b0), 0.0D, 0.0D, 0.0D); + tessellator.draw(); + j3 = this.func_148441_d(); + + if (j3 > 0) + { + j2 = (this.field_148461_h - this.field_148450_f) * (this.field_148461_h - this.field_148450_f) / this.func_148447_b(); + + if (j2 < 32) + { + j2 = 32; + } + + if (j2 > this.field_148461_h - this.field_148450_f - 8) + { + j2 = this.field_148461_h - this.field_148450_f - 8; + } + + k2 = (int)this.field_148460_k * (this.field_148461_h - this.field_148450_f - j2) / j3 + this.field_148450_f; + + if (k2 < this.field_148450_f) + { + k2 = this.field_148450_f; + } + + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_I(0, 255); + tessellator.addVertexWithUV((double)l, (double)this.field_148461_h, 0.0D, 0.0D, 1.0D); + tessellator.addVertexWithUV((double)i1, (double)this.field_148461_h, 0.0D, 1.0D, 1.0D); + tessellator.addVertexWithUV((double)i1, (double)this.field_148450_f, 0.0D, 1.0D, 0.0D); + tessellator.addVertexWithUV((double)l, (double)this.field_148450_f, 0.0D, 0.0D, 0.0D); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_I(8421504, 255); + tessellator.addVertexWithUV((double)l, (double)(k2 + j2), 0.0D, 0.0D, 1.0D); + tessellator.addVertexWithUV((double)i1, (double)(k2 + j2), 0.0D, 1.0D, 1.0D); + tessellator.addVertexWithUV((double)i1, (double)k2, 0.0D, 1.0D, 0.0D); + tessellator.addVertexWithUV((double)l, (double)k2, 0.0D, 0.0D, 0.0D); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_I(12632256, 255); + tessellator.addVertexWithUV((double)l, (double)(k2 + j2 - 1), 0.0D, 0.0D, 1.0D); + tessellator.addVertexWithUV((double)(i1 - 1), (double)(k2 + j2 - 1), 0.0D, 1.0D, 1.0D); + tessellator.addVertexWithUV((double)(i1 - 1), (double)k2, 0.0D, 1.0D, 0.0D); + tessellator.addVertexWithUV((double)l, (double)k2, 0.0D, 0.0D, 0.0D); + tessellator.draw(); + } + + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glShadeModel(GL11.GL_FLAT); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glDisable(GL11.GL_BLEND); + } + + protected int func_148440_e() + { + return this.field_148451_g - 8; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/ServerListEntryLanDetected.java b/src/main/java/net/minecraft/client/gui/ServerListEntryLanDetected.java new file mode 100644 index 0000000..5d1ddce --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/ServerListEntryLanDetected.java @@ -0,0 +1,60 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.Minecraft; +import net.minecraft.client.network.LanServerDetector; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.resources.I18n; + +@SideOnly(Side.CLIENT) +public class ServerListEntryLanDetected implements GuiListExtended.IGuiListEntry +{ + private final GuiMultiplayer field_148292_c; + protected final Minecraft field_148293_a; + protected final LanServerDetector.LanServer field_148291_b; + private long field_148290_d = 0L; + private static final String __OBFID = "CL_00000816"; + + protected ServerListEntryLanDetected(GuiMultiplayer p_i45046_1_, LanServerDetector.LanServer p_i45046_2_) + { + this.field_148292_c = p_i45046_1_; + this.field_148291_b = p_i45046_2_; + this.field_148293_a = Minecraft.getMinecraft(); + } + + public void drawEntry(int p_148279_1_, int p_148279_2_, int p_148279_3_, int p_148279_4_, int p_148279_5_, Tessellator p_148279_6_, int p_148279_7_, int p_148279_8_, boolean p_148279_9_) + { + this.field_148293_a.fontRenderer.drawString(I18n.format("lanServer.title", new Object[0]), p_148279_2_ + 32 + 3, p_148279_3_ + 1, 16777215); + this.field_148293_a.fontRenderer.drawString(this.field_148291_b.getServerMotd(), p_148279_2_ + 32 + 3, p_148279_3_ + 12, 8421504); + + if (this.field_148293_a.gameSettings.hideServerAddress) + { + this.field_148293_a.fontRenderer.drawString(I18n.format("selectServer.hiddenAddress", new Object[0]), p_148279_2_ + 32 + 3, p_148279_3_ + 12 + 11, 3158064); + } + else + { + this.field_148293_a.fontRenderer.drawString(this.field_148291_b.getServerIpPort(), p_148279_2_ + 32 + 3, p_148279_3_ + 12 + 11, 3158064); + } + } + + public boolean mousePressed(int p_148278_1_, int p_148278_2_, int p_148278_3_, int p_148278_4_, int p_148278_5_, int p_148278_6_) + { + this.field_148292_c.func_146790_a(p_148278_1_); + + if (Minecraft.getSystemTime() - this.field_148290_d < 250L) + { + this.field_148292_c.func_146796_h(); + } + + this.field_148290_d = Minecraft.getSystemTime(); + return false; + } + + public void mouseReleased(int p_148277_1_, int p_148277_2_, int p_148277_3_, int p_148277_4_, int p_148277_5_, int p_148277_6_) {} + + public LanServerDetector.LanServer func_148289_a() + { + return this.field_148291_b; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/ServerListEntryLanScan.java b/src/main/java/net/minecraft/client/gui/ServerListEntryLanScan.java new file mode 100644 index 0000000..05fcb9a --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/ServerListEntryLanScan.java @@ -0,0 +1,44 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.resources.I18n; + +@SideOnly(Side.CLIENT) +public class ServerListEntryLanScan implements GuiListExtended.IGuiListEntry +{ + private final Minecraft field_148288_a = Minecraft.getMinecraft(); + private static final String __OBFID = "CL_00000815"; + + public void drawEntry(int p_148279_1_, int p_148279_2_, int p_148279_3_, int p_148279_4_, int p_148279_5_, Tessellator p_148279_6_, int p_148279_7_, int p_148279_8_, boolean p_148279_9_) + { + int l1 = p_148279_3_ + p_148279_5_ / 2 - this.field_148288_a.fontRenderer.FONT_HEIGHT / 2; + this.field_148288_a.fontRenderer.drawString(I18n.format("lanServer.scanning", new Object[0]), this.field_148288_a.currentScreen.width / 2 - this.field_148288_a.fontRenderer.getStringWidth(I18n.format("lanServer.scanning", new Object[0])) / 2, l1, 16777215); + String s; + + switch ((int)(Minecraft.getSystemTime() / 300L % 4L)) + { + case 0: + default: + s = "O o o"; + break; + case 1: + case 3: + s = "o O o"; + break; + case 2: + s = "o o O"; + } + + this.field_148288_a.fontRenderer.drawString(s, this.field_148288_a.currentScreen.width / 2 - this.field_148288_a.fontRenderer.getStringWidth(s) / 2, l1 + this.field_148288_a.fontRenderer.FONT_HEIGHT, 8421504); + } + + public boolean mousePressed(int p_148278_1_, int p_148278_2_, int p_148278_3_, int p_148278_4_, int p_148278_5_, int p_148278_6_) + { + return false; + } + + public void mouseReleased(int p_148277_1_, int p_148277_2_, int p_148277_3_, int p_148277_4_, int p_148277_5_, int p_148277_6_) {} +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/ServerListEntryNormal.java b/src/main/java/net/minecraft/client/gui/ServerListEntryNormal.java new file mode 100644 index 0000000..b1defa8 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/ServerListEntryNormal.java @@ -0,0 +1,258 @@ +package net.minecraft.client.gui; + +import com.google.common.base.Charsets; +import com.google.common.util.concurrent.ThreadFactoryBuilder; +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.ByteBufInputStream; +import io.netty.buffer.Unpooled; +import io.netty.handler.codec.base64.Base64; +import java.awt.image.BufferedImage; +import java.net.UnknownHostException; +import java.util.List; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.ThreadPoolExecutor; +import javax.imageio.ImageIO; +import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.ServerData; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.DynamicTexture; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; +import org.apache.commons.lang3.Validate; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class ServerListEntryNormal implements GuiListExtended.IGuiListEntry +{ + private static final Logger logger = LogManager.getLogger(); + private static final ThreadPoolExecutor field_148302_b = new ScheduledThreadPoolExecutor(5, (new ThreadFactoryBuilder()).setNameFormat("Server Pinger #%d").setDaemon(true).build()); + private final GuiMultiplayer field_148303_c; + private final Minecraft field_148300_d; + private final ServerData field_148301_e; + private long field_148298_f; + private String field_148299_g; + private DynamicTexture field_148305_h; + private ResourceLocation field_148306_i; + private static final String __OBFID = "CL_00000817"; + + protected ServerListEntryNormal(GuiMultiplayer p_i45048_1_, ServerData p_i45048_2_) + { + this.field_148303_c = p_i45048_1_; + this.field_148301_e = p_i45048_2_; + this.field_148300_d = Minecraft.getMinecraft(); + this.field_148306_i = new ResourceLocation("servers/" + p_i45048_2_.serverIP + "/icon"); + this.field_148305_h = (DynamicTexture)this.field_148300_d.getTextureManager().getTexture(this.field_148306_i); + } + + public void drawEntry(int p_148279_1_, int p_148279_2_, int p_148279_3_, int p_148279_4_, int p_148279_5_, Tessellator p_148279_6_, int p_148279_7_, int p_148279_8_, boolean p_148279_9_) + { + if (!this.field_148301_e.field_78841_f) + { + this.field_148301_e.field_78841_f = true; + this.field_148301_e.pingToServer = -2L; + this.field_148301_e.serverMOTD = ""; + this.field_148301_e.populationInfo = ""; + field_148302_b.submit(new Runnable() + { + private static final String __OBFID = "CL_00000818"; + public void run() + { + try + { + ServerListEntryNormal.this.field_148303_c.func_146789_i().func_147224_a(ServerListEntryNormal.this.field_148301_e); + } + catch (UnknownHostException unknownhostexception) + { + ServerListEntryNormal.this.field_148301_e.pingToServer = -1L; + ServerListEntryNormal.this.field_148301_e.serverMOTD = EnumChatFormatting.DARK_RED + "Can\'t resolve hostname"; + } + catch (Exception exception) + { + ServerListEntryNormal.this.field_148301_e.pingToServer = -1L; + ServerListEntryNormal.this.field_148301_e.serverMOTD = EnumChatFormatting.DARK_RED + "Can\'t connect to server."; + } + } + }); + } + + boolean flag1 = this.field_148301_e.field_82821_f > 4; + boolean flag2 = this.field_148301_e.field_82821_f < 4; + boolean flag3 = flag1 || flag2; + this.field_148300_d.fontRenderer.drawString(this.field_148301_e.serverName, p_148279_2_ + 32 + 3, p_148279_3_ + 1, 16777215); + List list = this.field_148300_d.fontRenderer.listFormattedStringToWidth(FMLClientHandler.instance().fixDescription(this.field_148301_e.serverMOTD), p_148279_4_ - 32 - 2); + + for (int l1 = 0; l1 < Math.min(list.size(), 2); ++l1) + { + this.field_148300_d.fontRenderer.drawString((String)list.get(l1), p_148279_2_ + 32 + 3, p_148279_3_ + 12 + this.field_148300_d.fontRenderer.FONT_HEIGHT * l1, 8421504); + } + + String s2 = flag3 ? EnumChatFormatting.DARK_RED + this.field_148301_e.gameVersion : this.field_148301_e.populationInfo; + int i2 = this.field_148300_d.fontRenderer.getStringWidth(s2); + this.field_148300_d.fontRenderer.drawString(s2, p_148279_2_ + p_148279_4_ - i2 - 15 - 2, p_148279_3_ + 1, 8421504); + byte b0 = 0; + String s = null; + int j2; + String s1; + + if (flag3) + { + j2 = 5; + s1 = flag1 ? "Client out of date!" : "Server out of date!"; + s = this.field_148301_e.field_147412_i; + } + else if (this.field_148301_e.field_78841_f && this.field_148301_e.pingToServer != -2L) + { + if (this.field_148301_e.pingToServer < 0L) + { + j2 = 5; + } + else if (this.field_148301_e.pingToServer < 150L) + { + j2 = 0; + } + else if (this.field_148301_e.pingToServer < 300L) + { + j2 = 1; + } + else if (this.field_148301_e.pingToServer < 600L) + { + j2 = 2; + } + else if (this.field_148301_e.pingToServer < 1000L) + { + j2 = 3; + } + else + { + j2 = 4; + } + + if (this.field_148301_e.pingToServer < 0L) + { + s1 = "(no connection)"; + } + else + { + s1 = this.field_148301_e.pingToServer + "ms"; + s = this.field_148301_e.field_147412_i; + } + } + else + { + b0 = 1; + j2 = (int)(Minecraft.getSystemTime() / 100L + (long)(p_148279_1_ * 2) & 7L); + + if (j2 > 4) + { + j2 = 8 - j2; + } + + s1 = "Pinging..."; + } + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.field_148300_d.getTextureManager().bindTexture(Gui.icons); + Gui.func_146110_a(p_148279_2_ + p_148279_4_ - 15, p_148279_3_, (float)(b0 * 10), (float)(176 + j2 * 8), 10, 8, 256.0F, 256.0F); + + if (this.field_148301_e.getBase64EncodedIconData() != null && !this.field_148301_e.getBase64EncodedIconData().equals(this.field_148299_g)) + { + this.field_148299_g = this.field_148301_e.getBase64EncodedIconData(); + this.func_148297_b(); + this.field_148303_c.func_146795_p().saveServerList(); + } + + if (this.field_148305_h != null) + { + this.field_148300_d.getTextureManager().bindTexture(this.field_148306_i); + Gui.func_146110_a(p_148279_2_, p_148279_3_, 0.0F, 0.0F, 32, 32, 32.0F, 32.0F); + } + + int k2 = p_148279_7_ - p_148279_2_; + int l2 = p_148279_8_ - p_148279_3_; + + String tooltip = FMLClientHandler.instance().enhanceServerListEntry(this, this.field_148301_e, p_148279_2_, p_148279_4_, p_148279_3_, k2, l2); + if (tooltip != null) + { + this.field_148303_c.func_146793_a(tooltip); + } else + if (k2 >= p_148279_4_ - 15 && k2 <= p_148279_4_ - 5 && l2 >= 0 && l2 <= 8) + { + this.field_148303_c.func_146793_a(s1); + } + else if (k2 >= p_148279_4_ - i2 - 15 - 2 && k2 <= p_148279_4_ - 15 - 2 && l2 >= 0 && l2 <= 8) + { + this.field_148303_c.func_146793_a(s); + } + } + + private void func_148297_b() + { + if (this.field_148301_e.getBase64EncodedIconData() == null) + { + this.field_148300_d.getTextureManager().deleteTexture(this.field_148306_i); + this.field_148305_h = null; + } + else + { + ByteBuf bytebuf = Unpooled.copiedBuffer(this.field_148301_e.getBase64EncodedIconData(), Charsets.UTF_8); + ByteBuf bytebuf1 = Base64.decode(bytebuf); + BufferedImage bufferedimage; + label74: + { + try + { + bufferedimage = ImageIO.read(new ByteBufInputStream(bytebuf1)); + Validate.validState(bufferedimage.getWidth() == 64, "Must be 64 pixels wide", new Object[0]); + Validate.validState(bufferedimage.getHeight() == 64, "Must be 64 pixels high", new Object[0]); + break label74; + } + catch (Exception exception) + { + logger.error("Invalid icon for server " + this.field_148301_e.serverName + " (" + this.field_148301_e.serverIP + ")", exception); + this.field_148301_e.func_147407_a((String)null); + } + finally + { + bytebuf.release(); + bytebuf1.release(); + } + + return; + } + + if (this.field_148305_h == null) + { + this.field_148305_h = new DynamicTexture(bufferedimage.getWidth(), bufferedimage.getHeight()); + this.field_148300_d.getTextureManager().loadTexture(this.field_148306_i, this.field_148305_h); + } + + bufferedimage.getRGB(0, 0, bufferedimage.getWidth(), bufferedimage.getHeight(), this.field_148305_h.getTextureData(), 0, bufferedimage.getWidth()); + this.field_148305_h.updateDynamicTexture(); + } + } + + public boolean mousePressed(int p_148278_1_, int p_148278_2_, int p_148278_3_, int p_148278_4_, int p_148278_5_, int p_148278_6_) + { + this.field_148303_c.func_146790_a(p_148278_1_); + + if (Minecraft.getSystemTime() - this.field_148298_f < 250L) + { + this.field_148303_c.func_146796_h(); + } + + this.field_148298_f = Minecraft.getSystemTime(); + return false; + } + + public void mouseReleased(int p_148277_1_, int p_148277_2_, int p_148277_3_, int p_148277_4_, int p_148277_5_, int p_148277_6_) {} + + public ServerData func_148296_a() + { + return this.field_148301_e; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/ServerSelectionList.java b/src/main/java/net/minecraft/client/gui/ServerSelectionList.java new file mode 100644 index 0000000..4ea4339 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/ServerSelectionList.java @@ -0,0 +1,101 @@ +package net.minecraft.client.gui; + +import com.google.common.collect.Lists; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Iterator; +import java.util.List; +import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.ServerList; +import net.minecraft.client.network.LanServerDetector; + +@SideOnly(Side.CLIENT) +public class ServerSelectionList extends GuiListExtended +{ + private final GuiMultiplayer field_148200_k; + private final List field_148198_l = Lists.newArrayList(); + private final List field_148199_m = Lists.newArrayList(); + private final GuiListExtended.IGuiListEntry field_148196_n = new ServerListEntryLanScan(); + private int field_148197_o = -1; + private static final String __OBFID = "CL_00000819"; + + public ServerSelectionList(GuiMultiplayer p_i45049_1_, Minecraft p_i45049_2_, int p_i45049_3_, int p_i45049_4_, int p_i45049_5_, int p_i45049_6_, int p_i45049_7_) + { + super(p_i45049_2_, p_i45049_3_, p_i45049_4_, p_i45049_5_, p_i45049_6_, p_i45049_7_); + this.field_148200_k = p_i45049_1_; + } + + public GuiListExtended.IGuiListEntry getListEntry(int p_148180_1_) + { + if (p_148180_1_ < this.field_148198_l.size()) + { + return (GuiListExtended.IGuiListEntry)this.field_148198_l.get(p_148180_1_); + } + else + { + p_148180_1_ -= this.field_148198_l.size(); + + if (p_148180_1_ == 0) + { + return this.field_148196_n; + } + else + { + --p_148180_1_; + return (GuiListExtended.IGuiListEntry)this.field_148199_m.get(p_148180_1_); + } + } + } + + protected int getSize() + { + return this.field_148198_l.size() + 1 + this.field_148199_m.size(); + } + + public void func_148192_c(int p_148192_1_) + { + this.field_148197_o = p_148192_1_; + } + + protected boolean isSelected(int p_148131_1_) + { + return p_148131_1_ == this.field_148197_o; + } + + public int func_148193_k() + { + return this.field_148197_o; + } + + public void func_148195_a(ServerList p_148195_1_) + { + this.field_148198_l.clear(); + + for (int i = 0; i < p_148195_1_.countServers(); ++i) + { + this.field_148198_l.add(new ServerListEntryNormal(this.field_148200_k, p_148195_1_.getServerData(i))); + } + } + + public void func_148194_a(List p_148194_1_) + { + this.field_148199_m.clear(); + Iterator iterator = p_148194_1_.iterator(); + + while (iterator.hasNext()) + { + LanServerDetector.LanServer lanserver = (LanServerDetector.LanServer)iterator.next(); + this.field_148199_m.add(new ServerListEntryLanDetected(this.field_148200_k, lanserver)); + } + } + + protected int getScrollBarX() + { + return super.getScrollBarX() + 30; + } + + public int getListWidth() + { + return super.getListWidth() + 85; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/TaskLongRunning.java b/src/main/java/net/minecraft/client/gui/TaskLongRunning.java new file mode 100644 index 0000000..496ef82 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/TaskLongRunning.java @@ -0,0 +1,43 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.Minecraft; + +@SideOnly(Side.CLIENT) +public abstract class TaskLongRunning implements Runnable +{ + protected GuiScreenLongRunningTask field_148419_b; + private static final String __OBFID = "CL_00000784"; + + public void func_148412_a(GuiScreenLongRunningTask p_148412_1_) + { + this.field_148419_b = p_148412_1_; + } + + public void func_148416_a(String p_148416_1_) + { + this.field_148419_b.func_146905_a(p_148416_1_); + } + + public void func_148417_b(String p_148417_1_) + { + this.field_148419_b.func_146906_b(p_148417_1_); + } + + public Minecraft func_148413_b() + { + return this.field_148419_b.func_146903_h(); + } + + public boolean func_148418_c() + { + return this.field_148419_b.func_146904_i(); + } + + public void func_148414_a() {} + + public void func_148415_a(GuiButton p_148415_1_) {} + + public void func_148411_d() {} +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/TaskOnlineConnect.java b/src/main/java/net/minecraft/client/gui/TaskOnlineConnect.java new file mode 100644 index 0000000..20ae950 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/TaskOnlineConnect.java @@ -0,0 +1,199 @@ +package net.minecraft.client.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.util.concurrent.GenericFutureListener; +import java.io.IOException; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.concurrent.atomic.AtomicInteger; +import net.minecraft.client.Minecraft; +import net.minecraft.client.mco.ExceptionMcoService; +import net.minecraft.client.mco.ExceptionRetryCall; +import net.minecraft.client.mco.McoClient; +import net.minecraft.client.mco.McoServer; +import net.minecraft.client.mco.McoServerAddress; +import net.minecraft.client.multiplayer.ServerAddress; +import net.minecraft.client.network.NetHandlerLoginClient; +import net.minecraft.client.resources.I18n; +import net.minecraft.network.EnumConnectionState; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.handshake.client.C00Handshake; +import net.minecraft.network.login.client.C00PacketLoginStart; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.Session; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +@SideOnly(Side.CLIENT) +public class TaskOnlineConnect extends TaskLongRunning +{ + private static final AtomicInteger field_148439_a = new AtomicInteger(0); + private static final Logger logger = LogManager.getLogger(); + private NetworkManager field_148436_d; + private final McoServer field_148437_e; + private final GuiScreen field_148435_f; + private static final String __OBFID = "CL_00000790"; + + public TaskOnlineConnect(GuiScreen par1GuiScreen, McoServer par2McoServer) + { + this.field_148435_f = par1GuiScreen; + this.field_148437_e = par2McoServer; + } + + public void run() + { + this.func_148417_b(I18n.format("mco.connect.connecting", new Object[0])); + Session session = this.func_148413_b().getSession(); + McoClient mcoclient = new McoClient(session.getSessionID(), session.getUsername(), "1.7.2", Minecraft.getMinecraft().getProxy()); + boolean flag = false; + boolean flag1 = false; + int i = 5; + McoServerAddress mcoserveraddress = null; + boolean flag2 = false; + + for (int j = 0; j < 10 && !this.func_148418_c(); ++j) + { + try + { + mcoserveraddress = mcoclient.func_148688_b(this.field_148437_e.field_148812_a); + flag = true; + } + catch (ExceptionRetryCall exceptionretrycall) + { + i = exceptionretrycall.field_148832_d; + } + catch (ExceptionMcoService exceptionmcoservice) + { + if (exceptionmcoservice.field_148830_c == 6002) + { + flag2 = true; + } + else + { + flag1 = true; + this.func_148416_a(exceptionmcoservice.toString()); + logger.error("Couldn\'t connect to world", exceptionmcoservice); + } + + break; + } + catch (IOException ioexception) + { + logger.error("Couldn\'t parse response connecting to world", ioexception); + } + catch (Exception exception) + { + flag1 = true; + logger.error("Couldn\'t connect to world", exception); + this.func_148416_a(exception.getLocalizedMessage()); + } + + if (flag) + { + break; + } + + this.func_148429_a(i); + } + + if (flag2) + { + this.func_148413_b().displayGuiScreen(new GuiScreenReamlsTOS(this.field_148435_f, this.field_148437_e)); + } + else if (!this.func_148418_c() && !flag1) + { + if (flag) + { + ServerAddress serveraddress = ServerAddress.func_78860_a(mcoserveraddress.field_148770_a); + this.func_148432_a(serveraddress.getIP(), serveraddress.getPort()); + } + else + { + this.func_148413_b().displayGuiScreen(this.field_148435_f); + } + } + } + + private void func_148429_a(int p_148429_1_) + { + try + { + Thread.sleep((long)(p_148429_1_ * 1000)); + } + catch (InterruptedException interruptedexception) + { + logger.warn(interruptedexception.getLocalizedMessage()); + } + } + + private void func_148432_a(final String p_148432_1_, final int p_148432_2_) + { + (new Thread("MCO Connector #" + field_148439_a.incrementAndGet()) + { + private static final String __OBFID = "CL_00000791"; + public void run() + { + try + { + if (TaskOnlineConnect.this.func_148418_c()) + { + return; + } + + TaskOnlineConnect.this.field_148436_d = NetworkManager.provideLanClient(InetAddress.getByName(p_148432_1_), p_148432_2_); + + if (TaskOnlineConnect.this.func_148418_c()) + { + return; + } + + TaskOnlineConnect.this.field_148436_d.setNetHandler(new NetHandlerLoginClient(TaskOnlineConnect.this.field_148436_d, TaskOnlineConnect.this.func_148413_b(), TaskOnlineConnect.this.field_148435_f)); + + if (TaskOnlineConnect.this.func_148418_c()) + { + return; + } + + TaskOnlineConnect.this.field_148436_d.scheduleOutboundPacket(new C00Handshake(4, p_148432_1_, p_148432_2_, EnumConnectionState.LOGIN), new GenericFutureListener[0]); + + if (TaskOnlineConnect.this.func_148418_c()) + { + return; + } + + TaskOnlineConnect.this.field_148436_d.scheduleOutboundPacket(new C00PacketLoginStart(TaskOnlineConnect.this.func_148413_b().getSession().func_148256_e()), new GenericFutureListener[0]); + TaskOnlineConnect.this.func_148417_b(I18n.format("mco.connect.authorizing", new Object[0])); + } + catch (UnknownHostException unknownhostexception) + { + if (TaskOnlineConnect.this.func_148418_c()) + { + return; + } + + TaskOnlineConnect.logger.error("Couldn\'t connect to world", unknownhostexception); + TaskOnlineConnect.this.func_148413_b().displayGuiScreen(new GuiScreenDisconnectedOnline(TaskOnlineConnect.this.field_148435_f, "connect.failed", new ChatComponentTranslation("disconnect.genericReason", new Object[] {"Unknown host \'" + p_148432_1_ + "\'"}))); + } + catch (Exception exception) + { + if (TaskOnlineConnect.this.func_148418_c()) + { + return; + } + + TaskOnlineConnect.logger.error("Couldn\'t connect to world", exception); + TaskOnlineConnect.this.func_148413_b().displayGuiScreen(new GuiScreenDisconnectedOnline(TaskOnlineConnect.this.field_148435_f, "connect.failed", new ChatComponentTranslation("disconnect.genericReason", new Object[] {exception.toString()}))); + } + } + }).start(); + } + + public void func_148414_a() + { + if (this.field_148436_d != null) + { + this.field_148436_d.processReceivedPackets(); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/achievement/GuiAchievement.java b/src/main/java/net/minecraft/client/gui/achievement/GuiAchievement.java new file mode 100644 index 0000000..33d21b6 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/achievement/GuiAchievement.java @@ -0,0 +1,150 @@ +package net.minecraft.client.gui.achievement; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.resources.I18n; +import net.minecraft.stats.Achievement; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +@SideOnly(Side.CLIENT) +public class GuiAchievement extends Gui +{ + private static final ResourceLocation field_146261_a = new ResourceLocation("textures/gui/achievement/achievement_background.png"); + private Minecraft field_146259_f; + private int field_146260_g; + private int field_146267_h; + private String field_146268_i; + private String field_146265_j; + private Achievement field_146266_k; + private long field_146263_l; + private RenderItem field_146264_m; + private boolean field_146262_n; + private static final String __OBFID = "CL_00000721"; + + public GuiAchievement(Minecraft par1Minecraft) + { + this.field_146259_f = par1Minecraft; + this.field_146264_m = new RenderItem(); + } + + public void func_146256_a(Achievement p_146256_1_) + { + this.field_146268_i = I18n.format("achievement.get", new Object[0]); + this.field_146265_j = p_146256_1_.func_150951_e().getUnformattedText(); + this.field_146263_l = Minecraft.getSystemTime(); + this.field_146266_k = p_146256_1_; + this.field_146262_n = false; + } + + public void func_146255_b(Achievement p_146255_1_) + { + this.field_146268_i = p_146255_1_.func_150951_e().getUnformattedText(); + this.field_146265_j = p_146255_1_.getDescription(); + this.field_146263_l = Minecraft.getSystemTime() + 2500L; + this.field_146266_k = p_146255_1_; + this.field_146262_n = true; + } + + private void func_146258_c() + { + GL11.glViewport(0, 0, this.field_146259_f.displayWidth, this.field_146259_f.displayHeight); + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + this.field_146260_g = this.field_146259_f.displayWidth; + this.field_146267_h = this.field_146259_f.displayHeight; + ScaledResolution scaledresolution = new ScaledResolution(this.field_146259_f.gameSettings, this.field_146259_f.displayWidth, this.field_146259_f.displayHeight); + this.field_146260_g = scaledresolution.getScaledWidth(); + this.field_146267_h = scaledresolution.getScaledHeight(); + GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + GL11.glOrtho(0.0D, (double)this.field_146260_g, (double)this.field_146267_h, 0.0D, 1000.0D, 3000.0D); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + GL11.glTranslatef(0.0F, 0.0F, -2000.0F); + } + + public void func_146254_a() + { + if (this.field_146266_k != null && this.field_146263_l != 0L && Minecraft.getMinecraft().thePlayer != null) + { + double d0 = (double)(Minecraft.getSystemTime() - this.field_146263_l) / 3000.0D; + + if (!this.field_146262_n) + { + if (d0 < 0.0D || d0 > 1.0D) + { + this.field_146263_l = 0L; + return; + } + } + else if (d0 > 0.5D) + { + d0 = 0.5D; + } + + this.func_146258_c(); + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glDepthMask(false); + double d1 = d0 * 2.0D; + + if (d1 > 1.0D) + { + d1 = 2.0D - d1; + } + + d1 *= 4.0D; + d1 = 1.0D - d1; + + if (d1 < 0.0D) + { + d1 = 0.0D; + } + + d1 *= d1; + d1 *= d1; + int i = this.field_146260_g - 160; + int j = 0 - (int)(d1 * 36.0D); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glEnable(GL11.GL_TEXTURE_2D); + this.field_146259_f.getTextureManager().bindTexture(field_146261_a); + GL11.glDisable(GL11.GL_LIGHTING); + this.drawTexturedModalRect(i, j, 96, 202, 160, 32); + + if (this.field_146262_n) + { + this.field_146259_f.fontRenderer.drawSplitString(this.field_146265_j, i + 30, j + 7, 120, -1); + } + else + { + this.field_146259_f.fontRenderer.drawString(this.field_146268_i, i + 30, j + 7, -256); + this.field_146259_f.fontRenderer.drawString(this.field_146265_j, i + 30, j + 18, -1); + } + + RenderHelper.enableGUIStandardItemLighting(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glEnable(GL11.GL_COLOR_MATERIAL); + GL11.glEnable(GL11.GL_LIGHTING); + this.field_146264_m.renderItemAndEffectIntoGUI(this.field_146259_f.fontRenderer, this.field_146259_f.getTextureManager(), this.field_146266_k.theItemStack, i + 8, j + 8); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDepthMask(true); + GL11.glEnable(GL11.GL_DEPTH_TEST); + } + } + + public void func_146257_b() + { + this.field_146266_k = null; + this.field_146263_l = 0L; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/achievement/GuiAchievements.java b/src/main/java/net/minecraft/client/gui/achievement/GuiAchievements.java new file mode 100644 index 0000000..559f87e --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/achievement/GuiAchievements.java @@ -0,0 +1,591 @@ +package net.minecraft.client.gui.achievement; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiOptionButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.IProgressMeter; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.client.resources.I18n; +import net.minecraft.init.Blocks; +import net.minecraft.network.play.client.C16PacketClientStatus; +import net.minecraft.stats.Achievement; +import net.minecraft.stats.AchievementList; +import net.minecraft.stats.StatFileWriter; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; +import java.util.LinkedList; +import java.util.List; +import net.minecraftforge.common.AchievementPage; + +@SideOnly(Side.CLIENT) +public class GuiAchievements extends GuiScreen implements IProgressMeter +{ + private static final int field_146572_y = AchievementList.minDisplayColumn * 24 - 112; + private static final int field_146571_z = AchievementList.minDisplayRow * 24 - 112; + private static final int field_146559_A = AchievementList.maxDisplayColumn * 24 - 77; + private static final int field_146560_B = AchievementList.maxDisplayRow * 24 - 77; + private static final ResourceLocation field_146561_C = new ResourceLocation("textures/gui/achievement/achievement_background.png"); + protected GuiScreen field_146562_a; + protected int field_146555_f = 256; + protected int field_146557_g = 202; + protected int field_146563_h; + protected int field_146564_i; + protected float field_146570_r = 1.0F; + protected double field_146569_s; + protected double field_146568_t; + protected double field_146567_u; + protected double field_146566_v; + protected double field_146565_w; + protected double field_146573_x; + private int field_146554_D; + private StatFileWriter field_146556_E; + private boolean field_146558_F = true; + private static final String __OBFID = "CL_00000722"; + + private int currentPage = -1; + private GuiButton button; + private LinkedList minecraftAchievements = new LinkedList(); + + public GuiAchievements(GuiScreen p_i45026_1_, StatFileWriter p_i45026_2_) + { + this.field_146562_a = p_i45026_1_; + this.field_146556_E = p_i45026_2_; + short short1 = 141; + short short2 = 141; + this.field_146569_s = this.field_146567_u = this.field_146565_w = (double)(AchievementList.openInventory.displayColumn * 24 - short1 / 2 - 12); + this.field_146568_t = this.field_146566_v = this.field_146573_x = (double)(AchievementList.openInventory.displayRow * 24 - short2 / 2); + minecraftAchievements.clear(); + for (Object achievement : AchievementList.achievementList) + { + if (!AchievementPage.isAchievementInPages((Achievement)achievement)) + { + minecraftAchievements.add((Achievement)achievement); + } + } + } + + public void initGui() + { + this.mc.getNetHandler().addToSendQueue(new C16PacketClientStatus(C16PacketClientStatus.EnumState.REQUEST_STATS)); + this.buttonList.clear(); + this.buttonList.add(new GuiOptionButton(1, this.width / 2 + 24, this.height / 2 + 74, 80, 20, I18n.format("gui.done", new Object[0]))); + this.buttonList.add(button = new GuiButton(2, (width - field_146555_f) / 2 + 24, height / 2 + 74, 125, 20, AchievementPage.getTitle(currentPage))); + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (!this.field_146558_F) + { + if (p_146284_1_.id == 1) + { + this.mc.displayGuiScreen(this.field_146562_a); + } + + if (p_146284_1_.id == 2) + { + currentPage++; + if (currentPage >= AchievementPage.getAchievementPages().size()) + { + currentPage = -1; + } + button.displayString = AchievementPage.getTitle(currentPage); + } + } + } + + protected void keyTyped(char par1, int par2) + { + if (par2 == this.mc.gameSettings.keyBindInventory.getKeyCode()) + { + this.mc.displayGuiScreen((GuiScreen)null); + this.mc.setIngameFocus(); + } + else + { + super.keyTyped(par1, par2); + } + } + + public void drawScreen(int par1, int par2, float par3) + { + if (this.field_146558_F) + { + this.drawDefaultBackground(); + this.drawCenteredString(this.fontRendererObj, I18n.format("multiplayer.downloadingStats", new Object[0]), this.width / 2, this.height / 2, 16777215); + this.drawCenteredString(this.fontRendererObj, field_146510_b_[(int)(Minecraft.getSystemTime() / 150L % (long)field_146510_b_.length)], this.width / 2, this.height / 2 + this.fontRendererObj.FONT_HEIGHT * 2, 16777215); + } + else + { + int k; + + if (Mouse.isButtonDown(0)) + { + k = (this.width - this.field_146555_f) / 2; + int l = (this.height - this.field_146557_g) / 2; + int i1 = k + 8; + int j1 = l + 17; + + if ((this.field_146554_D == 0 || this.field_146554_D == 1) && par1 >= i1 && par1 < i1 + 224 && par2 >= j1 && par2 < j1 + 155) + { + if (this.field_146554_D == 0) + { + this.field_146554_D = 1; + } + else + { + this.field_146567_u -= (double)((float)(par1 - this.field_146563_h) * this.field_146570_r); + this.field_146566_v -= (double)((float)(par2 - this.field_146564_i) * this.field_146570_r); + this.field_146565_w = this.field_146569_s = this.field_146567_u; + this.field_146573_x = this.field_146568_t = this.field_146566_v; + } + + this.field_146563_h = par1; + this.field_146564_i = par2; + } + } + else + { + this.field_146554_D = 0; + } + + k = Mouse.getDWheel(); + float f4 = this.field_146570_r; + + if (k < 0) + { + this.field_146570_r += 0.25F; + } + else if (k > 0) + { + this.field_146570_r -= 0.25F; + } + + this.field_146570_r = MathHelper.clamp_float(this.field_146570_r, 1.0F, 2.0F); + + if (this.field_146570_r != f4) + { + float f6 = f4 - this.field_146570_r; + float f5 = f4 * (float)this.field_146555_f; + float f1 = f4 * (float)this.field_146557_g; + float f2 = this.field_146570_r * (float)this.field_146555_f; + float f3 = this.field_146570_r * (float)this.field_146557_g; + this.field_146567_u -= (double)((f2 - f5) * 0.5F); + this.field_146566_v -= (double)((f3 - f1) * 0.5F); + this.field_146565_w = this.field_146569_s = this.field_146567_u; + this.field_146573_x = this.field_146568_t = this.field_146566_v; + } + + if (this.field_146565_w < (double)field_146572_y) + { + this.field_146565_w = (double)field_146572_y; + } + + if (this.field_146573_x < (double)field_146571_z) + { + this.field_146573_x = (double)field_146571_z; + } + + if (this.field_146565_w >= (double)field_146559_A) + { + this.field_146565_w = (double)(field_146559_A - 1); + } + + if (this.field_146573_x >= (double)field_146560_B) + { + this.field_146573_x = (double)(field_146560_B - 1); + } + + this.drawDefaultBackground(); + this.func_146552_b(par1, par2, par3); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + this.func_146553_h(); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + } + } + + public void func_146509_g() + { + if (this.field_146558_F) + { + this.field_146558_F = false; + } + } + + public void updateScreen() + { + if (!this.field_146558_F) + { + this.field_146569_s = this.field_146567_u; + this.field_146568_t = this.field_146566_v; + double d0 = this.field_146565_w - this.field_146567_u; + double d1 = this.field_146573_x - this.field_146566_v; + + if (d0 * d0 + d1 * d1 < 4.0D) + { + this.field_146567_u += d0; + this.field_146566_v += d1; + } + else + { + this.field_146567_u += d0 * 0.85D; + this.field_146566_v += d1 * 0.85D; + } + } + } + + protected void func_146553_h() + { + int i = (this.width - this.field_146555_f) / 2; + int j = (this.height - this.field_146557_g) / 2; + this.fontRendererObj.drawString("Achievements", i + 15, j + 5, 4210752); + } + + protected void func_146552_b(int p_146552_1_, int p_146552_2_, float p_146552_3_) + { + int k = MathHelper.floor_double(this.field_146569_s + (this.field_146567_u - this.field_146569_s) * (double)p_146552_3_); + int l = MathHelper.floor_double(this.field_146568_t + (this.field_146566_v - this.field_146568_t) * (double)p_146552_3_); + + if (k < field_146572_y) + { + k = field_146572_y; + } + + if (l < field_146571_z) + { + l = field_146571_z; + } + + if (k >= field_146559_A) + { + k = field_146559_A - 1; + } + + if (l >= field_146560_B) + { + l = field_146560_B - 1; + } + + int i1 = (this.width - this.field_146555_f) / 2; + int j1 = (this.height - this.field_146557_g) / 2; + int k1 = i1 + 16; + int l1 = j1 + 17; + this.zLevel = 0.0F; + GL11.glDepthFunc(GL11.GL_GEQUAL); + GL11.glPushMatrix(); + GL11.glTranslatef((float)k1, (float)l1, -200.0F); + GL11.glScalef(1.0F / this.field_146570_r, 1.0F / this.field_146570_r, 0.0F); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glEnable(GL11.GL_COLOR_MATERIAL); + int i2 = k + 288 >> 4; + int j2 = l + 288 >> 4; + int k2 = (k + 288) % 16; + int l2 = (l + 288) % 16; + boolean flag = true; + boolean flag1 = true; + boolean flag2 = true; + boolean flag3 = true; + boolean flag4 = true; + Random random = new Random(); + float f1 = 16.0F / this.field_146570_r; + float f2 = 16.0F / this.field_146570_r; + int i3; + int j3; + int k3; + + for (i3 = 0; (float)i3 * f1 - (float)l2 < 155.0F; ++i3) + { + float f3 = 0.6F - (float)(j2 + i3) / 25.0F * 0.3F; + GL11.glColor4f(f3, f3, f3, 1.0F); + + for (j3 = 0; (float)j3 * f2 - (float)k2 < 224.0F; ++j3) + { + random.setSeed((long)(this.mc.getSession().getPlayerID().hashCode() + i2 + j3 + (j2 + i3) * 16)); + k3 = random.nextInt(1 + j2 + i3) + (j2 + i3) / 2; + IIcon iicon = Blocks.sand.getIcon(0, 0); + + if (k3 <= 37 && j2 + i3 != 35) + { + if (k3 == 22) + { + if (random.nextInt(2) == 0) + { + iicon = Blocks.diamond_ore.getIcon(0, 0); + } + else + { + iicon = Blocks.redstone_ore.getIcon(0, 0); + } + } + else if (k3 == 10) + { + iicon = Blocks.iron_ore.getIcon(0, 0); + } + else if (k3 == 8) + { + iicon = Blocks.coal_ore.getIcon(0, 0); + } + else if (k3 > 4) + { + iicon = Blocks.stone.getIcon(0, 0); + } + else if (k3 > 0) + { + iicon = Blocks.dirt.getIcon(0, 0); + } + } + else + { + iicon = Blocks.bedrock.getIcon(0, 0); + } + + this.mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture); + this.drawTexturedModelRectFromIcon(j3 * 16 - k2, i3 * 16 - l2, iicon, 16, 16); + } + } + + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glDepthFunc(GL11.GL_LEQUAL); + this.mc.getTextureManager().bindTexture(field_146561_C); + int i4; + int j4; + int l4; + + List achievementList = (currentPage == -1 ? minecraftAchievements : AchievementPage.getAchievementPage(currentPage).getAchievements()); + for (i3 = 0; i3 < achievementList.size(); ++i3) + { + Achievement achievement1 = achievementList.get(i3); + + if (achievement1.parentAchievement != null && achievementList.contains(achievement1.parentAchievement)) + { + j3 = achievement1.displayColumn * 24 - k + 11; + k3 = achievement1.displayRow * 24 - l + 11; + l4 = achievement1.parentAchievement.displayColumn * 24 - k + 11; + int l3 = achievement1.parentAchievement.displayRow * 24 - l + 11; + boolean flag5 = this.field_146556_E.hasAchievementUnlocked(achievement1); + boolean flag6 = this.field_146556_E.canUnlockAchievement(achievement1); + i4 = this.field_146556_E.func_150874_c(achievement1); + + if (i4 <= 4) + { + j4 = -16777216; + + if (flag5) + { + j4 = -6250336; + } + else if (flag6) + { + j4 = -16711936; + } + + this.drawHorizontalLine(j3, l4, k3, j4); + this.drawVerticalLine(l4, k3, l3, j4); + + if (j3 > l4) + { + this.drawTexturedModalRect(j3 - 11 - 7, k3 - 5, 114, 234, 7, 11); + } + else if (j3 < l4) + { + this.drawTexturedModalRect(j3 + 11, k3 - 5, 107, 234, 7, 11); + } + else if (k3 > l3) + { + this.drawTexturedModalRect(j3 - 5, k3 - 11 - 7, 96, 234, 11, 7); + } + else if (k3 < l3) + { + this.drawTexturedModalRect(j3 - 5, k3 + 11, 96, 241, 11, 7); + } + } + } + } + + Achievement achievement = null; + RenderItem renderitem = new RenderItem(); + float f4 = (float)(p_146552_1_ - k1) * this.field_146570_r; + float f5 = (float)(p_146552_2_ - l1) * this.field_146570_r; + RenderHelper.enableGUIStandardItemLighting(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glEnable(GL11.GL_COLOR_MATERIAL); + int i5; + int j5; + + for (l4 = 0; l4 < achievementList.size(); ++l4) + { + Achievement achievement2 = (Achievement)achievementList.get(l4); + i5 = achievement2.displayColumn * 24 - k; + j5 = achievement2.displayRow * 24 - l; + + if (i5 >= -24 && j5 >= -24 && (float)i5 <= 224.0F * this.field_146570_r && (float)j5 <= 155.0F * this.field_146570_r) + { + i4 = this.field_146556_E.func_150874_c(achievement2); + float f6; + + if (this.field_146556_E.hasAchievementUnlocked(achievement2)) + { + f6 = 0.75F; + GL11.glColor4f(f6, f6, f6, 1.0F); + } + else if (this.field_146556_E.canUnlockAchievement(achievement2)) + { + f6 = 1.0F; + GL11.glColor4f(f6, f6, f6, 1.0F); + } + else if (i4 < 3) + { + f6 = 0.3F; + GL11.glColor4f(f6, f6, f6, 1.0F); + } + else if (i4 == 3) + { + f6 = 0.2F; + GL11.glColor4f(f6, f6, f6, 1.0F); + } + else + { + if (i4 != 4) + { + continue; + } + + f6 = 0.1F; + GL11.glColor4f(f6, f6, f6, 1.0F); + } + + this.mc.getTextureManager().bindTexture(field_146561_C); + + if (achievement2.getSpecial()) + { + this.drawTexturedModalRect(i5 - 2, j5 - 2, 26, 202, 26, 26); + } + else + { + this.drawTexturedModalRect(i5 - 2, j5 - 2, 0, 202, 26, 26); + } + + if (!this.field_146556_E.canUnlockAchievement(achievement2)) + { + f6 = 0.1F; + GL11.glColor4f(f6, f6, f6, 1.0F); + renderitem.renderWithColor = false; + } + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_CULL_FACE); + renderitem.renderItemAndEffectIntoGUI(this.mc.fontRenderer, this.mc.getTextureManager(), achievement2.theItemStack, i5 + 3, j5 + 3); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glDisable(GL11.GL_LIGHTING); + + if (!this.field_146556_E.canUnlockAchievement(achievement2)) + { + renderitem.renderWithColor = true; + } + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + + if (f4 >= (float)i5 && f4 <= (float)(i5 + 22) && f5 >= (float)j5 && f5 <= (float)(j5 + 22)) + { + achievement = achievement2; + } + } + } + + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glEnable(GL11.GL_BLEND); + GL11.glPopMatrix(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(field_146561_C); + this.drawTexturedModalRect(i1, j1, 0, 0, this.field_146555_f, this.field_146557_g); + this.zLevel = 0.0F; + GL11.glDepthFunc(GL11.GL_LEQUAL); + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glEnable(GL11.GL_TEXTURE_2D); + super.drawScreen(p_146552_1_, p_146552_2_, p_146552_3_); + + if (achievement != null) + { + String s1 = achievement.func_150951_e().getUnformattedText(); + String s2 = achievement.getDescription(); + i5 = p_146552_1_ + 12; + j5 = p_146552_2_ - 4; + i4 = this.field_146556_E.func_150874_c(achievement); + + if (!this.field_146556_E.canUnlockAchievement(achievement)) + { + String s; + int k4; + + if (i4 == 3) + { + s1 = I18n.format("achievement.unknown", new Object[0]); + j4 = Math.max(this.fontRendererObj.getStringWidth(s1), 120); + s = (new ChatComponentTranslation("achievement.requires", new Object[] {achievement.parentAchievement.func_150951_e()})).getUnformattedText(); + k4 = this.fontRendererObj.splitStringWidth(s, j4); + this.drawGradientRect(i5 - 3, j5 - 3, i5 + j4 + 3, j5 + k4 + 12 + 3, -1073741824, -1073741824); + this.fontRendererObj.drawSplitString(s, i5, j5 + 12, j4, -9416624); + } + else if (i4 < 3) + { + j4 = Math.max(this.fontRendererObj.getStringWidth(s1), 120); + s = (new ChatComponentTranslation("achievement.requires", new Object[] {achievement.parentAchievement.func_150951_e()})).getUnformattedText(); + k4 = this.fontRendererObj.splitStringWidth(s, j4); + this.drawGradientRect(i5 - 3, j5 - 3, i5 + j4 + 3, j5 + k4 + 12 + 3, -1073741824, -1073741824); + this.fontRendererObj.drawSplitString(s, i5, j5 + 12, j4, -9416624); + } + else + { + s1 = null; + } + } + else + { + j4 = Math.max(this.fontRendererObj.getStringWidth(s1), 120); + int k5 = this.fontRendererObj.splitStringWidth(s2, j4); + + if (this.field_146556_E.hasAchievementUnlocked(achievement)) + { + k5 += 12; + } + + this.drawGradientRect(i5 - 3, j5 - 3, i5 + j4 + 3, j5 + k5 + 3 + 12, -1073741824, -1073741824); + this.fontRendererObj.drawSplitString(s2, i5, j5 + 12, j4, -6250336); + + if (this.field_146556_E.hasAchievementUnlocked(achievement)) + { + this.fontRendererObj.drawStringWithShadow(I18n.format("achievement.taken", new Object[0]), i5, j5 + k5 + 4, -7302913); + } + } + + if (s1 != null) + { + this.fontRendererObj.drawStringWithShadow(s1, i5, j5, this.field_146556_E.canUnlockAchievement(achievement) ? (achievement.getSpecial() ? -128 : -1) : (achievement.getSpecial() ? -8355776 : -8355712)); + } + } + + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glEnable(GL11.GL_LIGHTING); + RenderHelper.disableStandardItemLighting(); + } + + public boolean doesGuiPauseGame() + { + return !this.field_146558_F; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/achievement/GuiStats.java b/src/main/java/net/minecraft/client/gui/achievement/GuiStats.java new file mode 100644 index 0000000..cdf5433 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/achievement/GuiStats.java @@ -0,0 +1,810 @@ +package net.minecraft.client.gui.achievement; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.Iterator; +import java.util.List; +import net.minecraft.client.Minecraft; +import net.minecraft.client.audio.PositionedSoundRecord; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.GuiSlot; +import net.minecraft.client.gui.IProgressMeter; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.EntityList; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.network.play.client.C16PacketClientStatus; +import net.minecraft.stats.StatBase; +import net.minecraft.stats.StatCrafting; +import net.minecraft.stats.StatFileWriter; +import net.minecraft.stats.StatList; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +@SideOnly(Side.CLIENT) +public class GuiStats extends GuiScreen implements IProgressMeter +{ + private static RenderItem field_146544_g = new RenderItem(); + protected GuiScreen field_146549_a; + protected String field_146542_f = "Select world"; + private GuiStats.StatsGeneral field_146550_h; + private GuiStats.StatsItem field_146551_i; + private GuiStats.StatsBlock field_146548_r; + private GuiStats.StatsMobsList field_146547_s; + private StatFileWriter field_146546_t; + private GuiSlot field_146545_u; + private boolean doesGuiPauseGame = true; + private static final String __OBFID = "CL_00000723"; + + public GuiStats(GuiScreen par1GuiScreen, StatFileWriter par2StatFileWriter) + { + this.field_146549_a = par1GuiScreen; + this.field_146546_t = par2StatFileWriter; + } + + public void initGui() + { + this.field_146542_f = I18n.format("gui.stats", new Object[0]); + this.mc.getNetHandler().addToSendQueue(new C16PacketClientStatus(C16PacketClientStatus.EnumState.REQUEST_STATS)); + } + + public void func_146541_h() + { + this.buttonList.add(new GuiButton(0, this.width / 2 + 4, this.height - 28, 150, 20, I18n.format("gui.done", new Object[0]))); + this.buttonList.add(new GuiButton(1, this.width / 2 - 160, this.height - 52, 80, 20, I18n.format("stat.generalButton", new Object[0]))); + GuiButton guibutton; + GuiButton guibutton1; + GuiButton guibutton2; + this.buttonList.add(guibutton = new GuiButton(2, this.width / 2 - 80, this.height - 52, 80, 20, I18n.format("stat.blocksButton", new Object[0]))); + this.buttonList.add(guibutton1 = new GuiButton(3, this.width / 2, this.height - 52, 80, 20, I18n.format("stat.itemsButton", new Object[0]))); + this.buttonList.add(guibutton2 = new GuiButton(4, this.width / 2 + 80, this.height - 52, 80, 20, I18n.format("stat.mobsButton", new Object[0]))); + + if (this.field_146548_r.getSize() == 0) + { + guibutton.enabled = false; + } + + if (this.field_146551_i.getSize() == 0) + { + guibutton1.enabled = false; + } + + if (this.field_146547_s.getSize() == 0) + { + guibutton2.enabled = false; + } + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.enabled) + { + if (p_146284_1_.id == 0) + { + this.mc.displayGuiScreen(this.field_146549_a); + } + else if (p_146284_1_.id == 1) + { + this.field_146545_u = this.field_146550_h; + } + else if (p_146284_1_.id == 3) + { + this.field_146545_u = this.field_146551_i; + } + else if (p_146284_1_.id == 2) + { + this.field_146545_u = this.field_146548_r; + } + else if (p_146284_1_.id == 4) + { + this.field_146545_u = this.field_146547_s; + } + else + { + this.field_146545_u.actionPerformed(p_146284_1_); + } + } + } + + public void drawScreen(int par1, int par2, float par3) + { + if (this.doesGuiPauseGame) + { + this.drawDefaultBackground(); + this.drawCenteredString(this.fontRendererObj, I18n.format("multiplayer.downloadingStats", new Object[0]), this.width / 2, this.height / 2, 16777215); + this.drawCenteredString(this.fontRendererObj, field_146510_b_[(int)(Minecraft.getSystemTime() / 150L % (long)field_146510_b_.length)], this.width / 2, this.height / 2 + this.fontRendererObj.FONT_HEIGHT * 2, 16777215); + } + else + { + this.field_146545_u.drawScreen(par1, par2, par3); + this.drawCenteredString(this.fontRendererObj, this.field_146542_f, this.width / 2, 20, 16777215); + super.drawScreen(par1, par2, par3); + } + } + + public void func_146509_g() + { + if (this.doesGuiPauseGame) + { + this.field_146550_h = new GuiStats.StatsGeneral(); + this.field_146550_h.registerScrollButtons(1, 1); + this.field_146551_i = new GuiStats.StatsItem(); + this.field_146551_i.registerScrollButtons(1, 1); + this.field_146548_r = new GuiStats.StatsBlock(); + this.field_146548_r.registerScrollButtons(1, 1); + this.field_146547_s = new GuiStats.StatsMobsList(); + this.field_146547_s.registerScrollButtons(1, 1); + this.field_146545_u = this.field_146550_h; + this.func_146541_h(); + this.doesGuiPauseGame = false; + } + } + + public boolean doesGuiPauseGame() + { + return !this.doesGuiPauseGame; + } + + private void func_146521_a(int p_146521_1_, int p_146521_2_, Item p_146521_3_) + { + this.drawButtonBackground(p_146521_1_ + 1, p_146521_2_ + 1); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + RenderHelper.enableGUIStandardItemLighting(); + field_146544_g.renderItemIntoGUI(this.fontRendererObj, this.mc.getTextureManager(), new ItemStack(p_146521_3_, 1, 0), p_146521_1_ + 2, p_146521_2_ + 2); + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + } + + private void drawButtonBackground(int p_146531_1_, int p_146531_2_) + { + this.drawSprite(p_146531_1_, p_146531_2_, 0, 0); + } + + private void drawSprite(int p_146527_1_, int p_146527_2_, int p_146527_3_, int p_146527_4_) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(statIcons); + float f = 0.0078125F; + float f1 = 0.0078125F; + boolean flag = true; + boolean flag1 = true; + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV((double)(p_146527_1_ + 0), (double)(p_146527_2_ + 18), (double)this.zLevel, (double)((float)(p_146527_3_ + 0) * 0.0078125F), (double)((float)(p_146527_4_ + 18) * 0.0078125F)); + tessellator.addVertexWithUV((double)(p_146527_1_ + 18), (double)(p_146527_2_ + 18), (double)this.zLevel, (double)((float)(p_146527_3_ + 18) * 0.0078125F), (double)((float)(p_146527_4_ + 18) * 0.0078125F)); + tessellator.addVertexWithUV((double)(p_146527_1_ + 18), (double)(p_146527_2_ + 0), (double)this.zLevel, (double)((float)(p_146527_3_ + 18) * 0.0078125F), (double)((float)(p_146527_4_ + 0) * 0.0078125F)); + tessellator.addVertexWithUV((double)(p_146527_1_ + 0), (double)(p_146527_2_ + 0), (double)this.zLevel, (double)((float)(p_146527_3_ + 0) * 0.0078125F), (double)((float)(p_146527_4_ + 0) * 0.0078125F)); + tessellator.draw(); + } + + @SideOnly(Side.CLIENT) + abstract class Stats extends GuiSlot + { + protected int field_148218_l = -1; + protected List field_148219_m; + protected Comparator field_148216_n; + protected int field_148217_o = -1; + protected int field_148215_p; + private static final String __OBFID = "CL_00000730"; + + protected Stats() + { + super(GuiStats.this.mc, GuiStats.this.width, GuiStats.this.height, 32, GuiStats.this.height - 64, 20); + this.setShowSelectionBox(false); + this.setHasListHeader(true, 20); + } + + protected void elementClicked(int p_148144_1_, boolean p_148144_2_, int p_148144_3_, int p_148144_4_) {} + + protected boolean isSelected(int p_148131_1_) + { + return false; + } + + protected void drawBackground() + { + GuiStats.this.drawDefaultBackground(); + } + + protected void drawListHeader(int p_148129_1_, int p_148129_2_, Tessellator p_148129_3_) + { + if (!Mouse.isButtonDown(0)) + { + this.field_148218_l = -1; + } + + if (this.field_148218_l == 0) + { + GuiStats.this.drawSprite(p_148129_1_ + 115 - 18, p_148129_2_ + 1, 0, 0); + } + else + { + GuiStats.this.drawSprite(p_148129_1_ + 115 - 18, p_148129_2_ + 1, 0, 18); + } + + if (this.field_148218_l == 1) + { + GuiStats.this.drawSprite(p_148129_1_ + 165 - 18, p_148129_2_ + 1, 0, 0); + } + else + { + GuiStats.this.drawSprite(p_148129_1_ + 165 - 18, p_148129_2_ + 1, 0, 18); + } + + if (this.field_148218_l == 2) + { + GuiStats.this.drawSprite(p_148129_1_ + 215 - 18, p_148129_2_ + 1, 0, 0); + } + else + { + GuiStats.this.drawSprite(p_148129_1_ + 215 - 18, p_148129_2_ + 1, 0, 18); + } + + if (this.field_148217_o != -1) + { + short short1 = 79; + byte b0 = 18; + + if (this.field_148217_o == 1) + { + short1 = 129; + } + else if (this.field_148217_o == 2) + { + short1 = 179; + } + + if (this.field_148215_p == 1) + { + b0 = 36; + } + + GuiStats.this.drawSprite(p_148129_1_ + short1, p_148129_2_ + 1, b0, 0); + } + } + + protected void func_148132_a(int p_148132_1_, int p_148132_2_) + { + this.field_148218_l = -1; + + if (p_148132_1_ >= 79 && p_148132_1_ < 115) + { + this.field_148218_l = 0; + } + else if (p_148132_1_ >= 129 && p_148132_1_ < 165) + { + this.field_148218_l = 1; + } + else if (p_148132_1_ >= 179 && p_148132_1_ < 215) + { + this.field_148218_l = 2; + } + + if (this.field_148218_l >= 0) + { + this.func_148212_h(this.field_148218_l); + GuiStats.this.mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); + } + } + + protected final int getSize() + { + return this.field_148219_m.size(); + } + + protected final StatCrafting func_148211_c(int p_148211_1_) + { + return (StatCrafting)this.field_148219_m.get(p_148211_1_); + } + + protected abstract String func_148210_b(int var1); + + protected void func_148209_a(StatBase p_148209_1_, int p_148209_2_, int p_148209_3_, boolean p_148209_4_) + { + String s; + + if (p_148209_1_ != null) + { + s = p_148209_1_.func_75968_a(GuiStats.this.field_146546_t.writeStat(p_148209_1_)); + GuiStats.this.drawString(GuiStats.this.fontRendererObj, s, p_148209_2_ - GuiStats.this.fontRendererObj.getStringWidth(s), p_148209_3_ + 5, p_148209_4_ ? 16777215 : 9474192); + } + else + { + s = "-"; + GuiStats.this.drawString(GuiStats.this.fontRendererObj, s, p_148209_2_ - GuiStats.this.fontRendererObj.getStringWidth(s), p_148209_3_ + 5, p_148209_4_ ? 16777215 : 9474192); + } + } + + protected void func_148142_b(int p_148142_1_, int p_148142_2_) + { + if (p_148142_2_ >= this.top && p_148142_2_ <= this.bottom) + { + int k = this.func_148124_c(p_148142_1_, p_148142_2_); + int l = this.width / 2 - 92 - 16; + + if (k >= 0) + { + if (p_148142_1_ < l + 40 || p_148142_1_ > l + 40 + 20) + { + return; + } + + StatCrafting statcrafting = this.func_148211_c(k); + this.func_148213_a(statcrafting, p_148142_1_, p_148142_2_); + } + else + { + String s = ""; + + if (p_148142_1_ >= l + 115 - 18 && p_148142_1_ <= l + 115) + { + s = this.func_148210_b(0); + } + else if (p_148142_1_ >= l + 165 - 18 && p_148142_1_ <= l + 165) + { + s = this.func_148210_b(1); + } + else + { + if (p_148142_1_ < l + 215 - 18 || p_148142_1_ > l + 215) + { + return; + } + + s = this.func_148210_b(2); + } + + s = ("" + I18n.format(s, new Object[0])).trim(); + + if (s.length() > 0) + { + int i1 = p_148142_1_ + 12; + int j1 = p_148142_2_ - 12; + int k1 = GuiStats.this.fontRendererObj.getStringWidth(s); + GuiStats.this.drawGradientRect(i1 - 3, j1 - 3, i1 + k1 + 3, j1 + 8 + 3, -1073741824, -1073741824); + GuiStats.this.fontRendererObj.drawStringWithShadow(s, i1, j1, -1); + } + } + } + } + + protected void func_148213_a(StatCrafting p_148213_1_, int p_148213_2_, int p_148213_3_) + { + if (p_148213_1_ != null) + { + Item item = p_148213_1_.func_150959_a(); + String s = ("" + I18n.format(item.getUnlocalizedName() + ".name", new Object[0])).trim(); + + if (s.length() > 0) + { + int k = p_148213_2_ + 12; + int l = p_148213_3_ - 12; + int i1 = GuiStats.this.fontRendererObj.getStringWidth(s); + GuiStats.this.drawGradientRect(k - 3, l - 3, k + i1 + 3, l + 8 + 3, -1073741824, -1073741824); + GuiStats.this.fontRendererObj.drawStringWithShadow(s, k, l, -1); + } + } + } + + protected void func_148212_h(int p_148212_1_) + { + if (p_148212_1_ != this.field_148217_o) + { + this.field_148217_o = p_148212_1_; + this.field_148215_p = -1; + } + else if (this.field_148215_p == -1) + { + this.field_148215_p = 1; + } + else + { + this.field_148217_o = -1; + this.field_148215_p = 0; + } + + Collections.sort(this.field_148219_m, this.field_148216_n); + } + } + + @SideOnly(Side.CLIENT) + class StatsBlock extends GuiStats.Stats + { + private static final String __OBFID = "CL_00000724"; + + public StatsBlock() + { + this.field_148219_m = new ArrayList(); + Iterator iterator = StatList.objectMineStats.iterator(); + + while (iterator.hasNext()) + { + StatCrafting statcrafting = (StatCrafting)iterator.next(); + boolean flag = false; + int i = Item.getIdFromItem(statcrafting.func_150959_a()); + + if (GuiStats.this.field_146546_t.writeStat(statcrafting) > 0) + { + flag = true; + } + else if (StatList.objectUseStats[i] != null && GuiStats.this.field_146546_t.writeStat(StatList.objectUseStats[i]) > 0) + { + flag = true; + } + else if (StatList.objectCraftStats[i] != null && GuiStats.this.field_146546_t.writeStat(StatList.objectCraftStats[i]) > 0) + { + flag = true; + } + + if (flag) + { + this.field_148219_m.add(statcrafting); + } + } + + this.field_148216_n = new Comparator() + { + private static final String __OBFID = "CL_00000725"; + public int compare(StatCrafting p_148339_1_, StatCrafting p_148339_2_) + { + int j = Item.getIdFromItem(p_148339_1_.func_150959_a()); + int k = Item.getIdFromItem(p_148339_2_.func_150959_a()); + StatBase statbase = null; + StatBase statbase1 = null; + + if (StatsBlock.this.field_148217_o == 2) + { + statbase = StatList.mineBlockStatArray[j]; + statbase1 = StatList.mineBlockStatArray[k]; + } + else if (StatsBlock.this.field_148217_o == 0) + { + statbase = StatList.objectCraftStats[j]; + statbase1 = StatList.objectCraftStats[k]; + } + else if (StatsBlock.this.field_148217_o == 1) + { + statbase = StatList.objectUseStats[j]; + statbase1 = StatList.objectUseStats[k]; + } + + if (statbase != null || statbase1 != null) + { + if (statbase == null) + { + return 1; + } + + if (statbase1 == null) + { + return -1; + } + + int l = GuiStats.this.field_146546_t.writeStat(statbase); + int i1 = GuiStats.this.field_146546_t.writeStat(statbase1); + + if (l != i1) + { + return (l - i1) * StatsBlock.this.field_148215_p; + } + } + + return j - k; + } + public int compare(Object par1Obj, Object par2Obj) + { + return this.compare((StatCrafting)par1Obj, (StatCrafting)par2Obj); + } + }; + } + + protected void drawListHeader(int p_148129_1_, int p_148129_2_, Tessellator p_148129_3_) + { + super.drawListHeader(p_148129_1_, p_148129_2_, p_148129_3_); + + if (this.field_148218_l == 0) + { + GuiStats.this.drawSprite(p_148129_1_ + 115 - 18 + 1, p_148129_2_ + 1 + 1, 18, 18); + } + else + { + GuiStats.this.drawSprite(p_148129_1_ + 115 - 18, p_148129_2_ + 1, 18, 18); + } + + if (this.field_148218_l == 1) + { + GuiStats.this.drawSprite(p_148129_1_ + 165 - 18 + 1, p_148129_2_ + 1 + 1, 36, 18); + } + else + { + GuiStats.this.drawSprite(p_148129_1_ + 165 - 18, p_148129_2_ + 1, 36, 18); + } + + if (this.field_148218_l == 2) + { + GuiStats.this.drawSprite(p_148129_1_ + 215 - 18 + 1, p_148129_2_ + 1 + 1, 54, 18); + } + else + { + GuiStats.this.drawSprite(p_148129_1_ + 215 - 18, p_148129_2_ + 1, 54, 18); + } + } + + protected void drawSlot(int p_148126_1_, int p_148126_2_, int p_148126_3_, int p_148126_4_, Tessellator p_148126_5_, int p_148126_6_, int p_148126_7_) + { + StatCrafting statcrafting = this.func_148211_c(p_148126_1_); + Item item = statcrafting.func_150959_a(); + GuiStats.this.func_146521_a(p_148126_2_ + 40, p_148126_3_, item); + int k1 = Item.getIdFromItem(item); + this.func_148209_a(StatList.objectCraftStats[k1], p_148126_2_ + 115, p_148126_3_, p_148126_1_ % 2 == 0); + this.func_148209_a(StatList.objectUseStats[k1], p_148126_2_ + 165, p_148126_3_, p_148126_1_ % 2 == 0); + this.func_148209_a(statcrafting, p_148126_2_ + 215, p_148126_3_, p_148126_1_ % 2 == 0); + } + + protected String func_148210_b(int p_148210_1_) + { + return p_148210_1_ == 0 ? "stat.crafted" : (p_148210_1_ == 1 ? "stat.used" : "stat.mined"); + } + } + + @SideOnly(Side.CLIENT) + class StatsGeneral extends GuiSlot + { + private static final String __OBFID = "CL_00000726"; + + public StatsGeneral() + { + super(GuiStats.this.mc, GuiStats.this.width, GuiStats.this.height, 32, GuiStats.this.height - 64, 10); + this.setShowSelectionBox(false); + } + + protected int getSize() + { + return StatList.generalStats.size(); + } + + protected void elementClicked(int p_148144_1_, boolean p_148144_2_, int p_148144_3_, int p_148144_4_) {} + + protected boolean isSelected(int p_148131_1_) + { + return false; + } + + protected int getContentHeight() + { + return this.getSize() * 10; + } + + protected void drawBackground() + { + GuiStats.this.drawDefaultBackground(); + } + + protected void drawSlot(int p_148126_1_, int p_148126_2_, int p_148126_3_, int p_148126_4_, Tessellator p_148126_5_, int p_148126_6_, int p_148126_7_) + { + StatBase statbase = (StatBase)StatList.generalStats.get(p_148126_1_); + GuiStats.this.drawString(GuiStats.this.fontRendererObj, statbase.func_150951_e().getUnformattedText(), p_148126_2_ + 2, p_148126_3_ + 1, p_148126_1_ % 2 == 0 ? 16777215 : 9474192); + String s = statbase.func_75968_a(GuiStats.this.field_146546_t.writeStat(statbase)); + GuiStats.this.drawString(GuiStats.this.fontRendererObj, s, p_148126_2_ + 2 + 213 - GuiStats.this.fontRendererObj.getStringWidth(s), p_148126_3_ + 1, p_148126_1_ % 2 == 0 ? 16777215 : 9474192); + } + } + + @SideOnly(Side.CLIENT) + class StatsItem extends GuiStats.Stats + { + private static final String __OBFID = "CL_00000727"; + + public StatsItem() + { + this.field_148219_m = new ArrayList(); + Iterator iterator = StatList.itemStats.iterator(); + + while (iterator.hasNext()) + { + StatCrafting statcrafting = (StatCrafting)iterator.next(); + boolean flag = false; + int i = Item.getIdFromItem(statcrafting.func_150959_a()); + + if (GuiStats.this.field_146546_t.writeStat(statcrafting) > 0) + { + flag = true; + } + else if (StatList.objectBreakStats[i] != null && GuiStats.this.field_146546_t.writeStat(StatList.objectBreakStats[i]) > 0) + { + flag = true; + } + else if (StatList.objectCraftStats[i] != null && GuiStats.this.field_146546_t.writeStat(StatList.objectCraftStats[i]) > 0) + { + flag = true; + } + + if (flag) + { + this.field_148219_m.add(statcrafting); + } + } + + this.field_148216_n = new Comparator() + { + private static final String __OBFID = "CL_00000728"; + public int compare(StatCrafting p_148342_1_, StatCrafting p_148342_2_) + { + int j = Item.getIdFromItem(p_148342_1_.func_150959_a()); + int k = Item.getIdFromItem(p_148342_2_.func_150959_a()); + StatBase statbase = null; + StatBase statbase1 = null; + + if (StatsItem.this.field_148217_o == 0) + { + statbase = StatList.objectBreakStats[j]; + statbase1 = StatList.objectBreakStats[k]; + } + else if (StatsItem.this.field_148217_o == 1) + { + statbase = StatList.objectCraftStats[j]; + statbase1 = StatList.objectCraftStats[k]; + } + else if (StatsItem.this.field_148217_o == 2) + { + statbase = StatList.objectUseStats[j]; + statbase1 = StatList.objectUseStats[k]; + } + + if (statbase != null || statbase1 != null) + { + if (statbase == null) + { + return 1; + } + + if (statbase1 == null) + { + return -1; + } + + int l = GuiStats.this.field_146546_t.writeStat(statbase); + int i1 = GuiStats.this.field_146546_t.writeStat(statbase1); + + if (l != i1) + { + return (l - i1) * StatsItem.this.field_148215_p; + } + } + + return j - k; + } + public int compare(Object par1Obj, Object par2Obj) + { + return this.compare((StatCrafting)par1Obj, (StatCrafting)par2Obj); + } + }; + } + + protected void drawListHeader(int p_148129_1_, int p_148129_2_, Tessellator p_148129_3_) + { + super.drawListHeader(p_148129_1_, p_148129_2_, p_148129_3_); + + if (this.field_148218_l == 0) + { + GuiStats.this.drawSprite(p_148129_1_ + 115 - 18 + 1, p_148129_2_ + 1 + 1, 72, 18); + } + else + { + GuiStats.this.drawSprite(p_148129_1_ + 115 - 18, p_148129_2_ + 1, 72, 18); + } + + if (this.field_148218_l == 1) + { + GuiStats.this.drawSprite(p_148129_1_ + 165 - 18 + 1, p_148129_2_ + 1 + 1, 18, 18); + } + else + { + GuiStats.this.drawSprite(p_148129_1_ + 165 - 18, p_148129_2_ + 1, 18, 18); + } + + if (this.field_148218_l == 2) + { + GuiStats.this.drawSprite(p_148129_1_ + 215 - 18 + 1, p_148129_2_ + 1 + 1, 36, 18); + } + else + { + GuiStats.this.drawSprite(p_148129_1_ + 215 - 18, p_148129_2_ + 1, 36, 18); + } + } + + protected void drawSlot(int p_148126_1_, int p_148126_2_, int p_148126_3_, int p_148126_4_, Tessellator p_148126_5_, int p_148126_6_, int p_148126_7_) + { + StatCrafting statcrafting = this.func_148211_c(p_148126_1_); + Item item = statcrafting.func_150959_a(); + GuiStats.this.func_146521_a(p_148126_2_ + 40, p_148126_3_, item); + int k1 = Item.getIdFromItem(item); + this.func_148209_a(StatList.objectBreakStats[k1], p_148126_2_ + 115, p_148126_3_, p_148126_1_ % 2 == 0); + this.func_148209_a(StatList.objectCraftStats[k1], p_148126_2_ + 165, p_148126_3_, p_148126_1_ % 2 == 0); + this.func_148209_a(statcrafting, p_148126_2_ + 215, p_148126_3_, p_148126_1_ % 2 == 0); + } + + protected String func_148210_b(int p_148210_1_) + { + return p_148210_1_ == 1 ? "stat.crafted" : (p_148210_1_ == 2 ? "stat.used" : "stat.depleted"); + } + } + + @SideOnly(Side.CLIENT) + class StatsMobsList extends GuiSlot + { + private final List field_148222_l = new ArrayList(); + private static final String __OBFID = "CL_00000729"; + + public StatsMobsList() + { + super(GuiStats.this.mc, GuiStats.this.width, GuiStats.this.height, 32, GuiStats.this.height - 64, GuiStats.this.fontRendererObj.FONT_HEIGHT * 4); + this.setShowSelectionBox(false); + Iterator iterator = EntityList.entityEggs.values().iterator(); + + while (iterator.hasNext()) + { + EntityList.EntityEggInfo entityegginfo = (EntityList.EntityEggInfo)iterator.next(); + + if (GuiStats.this.field_146546_t.writeStat(entityegginfo.field_151512_d) > 0 || GuiStats.this.field_146546_t.writeStat(entityegginfo.field_151513_e) > 0) + { + this.field_148222_l.add(entityegginfo); + } + } + } + + protected int getSize() + { + return this.field_148222_l.size(); + } + + protected void elementClicked(int p_148144_1_, boolean p_148144_2_, int p_148144_3_, int p_148144_4_) {} + + protected boolean isSelected(int p_148131_1_) + { + return false; + } + + protected int getContentHeight() + { + return this.getSize() * GuiStats.this.fontRendererObj.FONT_HEIGHT * 4; + } + + protected void drawBackground() + { + GuiStats.this.drawDefaultBackground(); + } + + protected void drawSlot(int p_148126_1_, int p_148126_2_, int p_148126_3_, int p_148126_4_, Tessellator p_148126_5_, int p_148126_6_, int p_148126_7_) + { + EntityList.EntityEggInfo entityegginfo = (EntityList.EntityEggInfo)this.field_148222_l.get(p_148126_1_); + String s = I18n.format("entity." + EntityList.getStringFromID(entityegginfo.spawnedID) + ".name", new Object[0]); + int k1 = GuiStats.this.field_146546_t.writeStat(entityegginfo.field_151512_d); + int l1 = GuiStats.this.field_146546_t.writeStat(entityegginfo.field_151513_e); + String s1 = I18n.format("stat.entityKills", new Object[] {Integer.valueOf(k1), s}); + String s2 = I18n.format("stat.entityKilledBy", new Object[] {s, Integer.valueOf(l1)}); + + if (k1 == 0) + { + s1 = I18n.format("stat.entityKills.none", new Object[] {s}); + } + + if (l1 == 0) + { + s2 = I18n.format("stat.entityKilledBy.none", new Object[] {s}); + } + + GuiStats.this.drawString(GuiStats.this.fontRendererObj, s, p_148126_2_ + 2 - 10, p_148126_3_ + 1, 16777215); + GuiStats.this.drawString(GuiStats.this.fontRendererObj, s1, p_148126_2_ + 2, p_148126_3_ + 1 + GuiStats.this.fontRendererObj.FONT_HEIGHT, k1 == 0 ? 6316128 : 9474192); + GuiStats.this.drawString(GuiStats.this.fontRendererObj, s2, p_148126_2_ + 2, p_148126_3_ + 1 + GuiStats.this.fontRendererObj.FONT_HEIGHT * 2, l1 == 0 ? 6316128 : 9474192); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/inventory/CreativeCrafting.java b/src/main/java/net/minecraft/client/gui/inventory/CreativeCrafting.java new file mode 100644 index 0000000..37c9606 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/inventory/CreativeCrafting.java @@ -0,0 +1,30 @@ +package net.minecraft.client.gui.inventory; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.client.Minecraft; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.item.ItemStack; + +@SideOnly(Side.CLIENT) +public class CreativeCrafting implements ICrafting +{ + private final Minecraft field_146109_a; + private static final String __OBFID = "CL_00000751"; + + public CreativeCrafting(Minecraft par1Minecraft) + { + this.field_146109_a = par1Minecraft; + } + + public void sendContainerAndContentsToPlayer(Container par1Container, List par2List) {} + + public void sendSlotContents(Container par1Container, int par2, ItemStack par3ItemStack) + { + this.field_146109_a.playerController.sendSlotPacket(par3ItemStack, par2); + } + + public void sendProgressBarUpdate(Container par1Container, int par2, int par3) {} +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/inventory/GuiBeacon.java b/src/main/java/net/minecraft/client/gui/inventory/GuiBeacon.java new file mode 100644 index 0000000..e1b18c0 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/inventory/GuiBeacon.java @@ -0,0 +1,336 @@ +package net.minecraft.client.gui.inventory; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; +import java.util.Iterator; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.init.Items; +import net.minecraft.inventory.ContainerBeacon; +import net.minecraft.item.ItemStack; +import net.minecraft.network.play.client.C17PacketCustomPayload; +import net.minecraft.potion.Potion; +import net.minecraft.tileentity.TileEntityBeacon; +import net.minecraft.util.ResourceLocation; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class GuiBeacon extends GuiContainer +{ + private static final Logger logger = LogManager.getLogger(); + private static final ResourceLocation beaconGuiTextures = new ResourceLocation("textures/gui/container/beacon.png"); + private TileEntityBeacon tileBeacon; + private GuiBeacon.ConfirmButton beaconConfirmButton; + private boolean buttonsNotDrawn; + private static final String __OBFID = "CL_00000739"; + + public GuiBeacon(InventoryPlayer par1InventoryPlayer, TileEntityBeacon par2TileEntityBeacon) + { + super(new ContainerBeacon(par1InventoryPlayer, par2TileEntityBeacon)); + this.tileBeacon = par2TileEntityBeacon; + this.xSize = 230; + this.ySize = 219; + } + + public void initGui() + { + super.initGui(); + this.buttonList.add(this.beaconConfirmButton = new GuiBeacon.ConfirmButton(-1, this.guiLeft + 164, this.guiTop + 107)); + this.buttonList.add(new GuiBeacon.CancelButton(-2, this.guiLeft + 190, this.guiTop + 107)); + this.buttonsNotDrawn = true; + this.beaconConfirmButton.enabled = false; + } + + public void updateScreen() + { + super.updateScreen(); + + if (this.buttonsNotDrawn && this.tileBeacon.getLevels() >= 0) + { + this.buttonsNotDrawn = false; + int j; + int k; + int l; + int i1; + GuiBeacon.PowerButton powerbutton; + + for (int i = 0; i <= 2; ++i) + { + j = TileEntityBeacon.effectsList[i].length; + k = j * 22 + (j - 1) * 2; + + for (l = 0; l < j; ++l) + { + i1 = TileEntityBeacon.effectsList[i][l].id; + powerbutton = new GuiBeacon.PowerButton(i << 8 | i1, this.guiLeft + 76 + l * 24 - k / 2, this.guiTop + 22 + i * 25, i1, i); + this.buttonList.add(powerbutton); + + if (i >= this.tileBeacon.getLevels()) + { + powerbutton.enabled = false; + } + else if (i1 == this.tileBeacon.getPrimaryEffect()) + { + powerbutton.func_146140_b(true); + } + } + } + + byte b0 = 3; + j = TileEntityBeacon.effectsList[b0].length + 1; + k = j * 22 + (j - 1) * 2; + + for (l = 0; l < j - 1; ++l) + { + i1 = TileEntityBeacon.effectsList[b0][l].id; + powerbutton = new GuiBeacon.PowerButton(b0 << 8 | i1, this.guiLeft + 167 + l * 24 - k / 2, this.guiTop + 47, i1, b0); + this.buttonList.add(powerbutton); + + if (b0 >= this.tileBeacon.getLevels()) + { + powerbutton.enabled = false; + } + else if (i1 == this.tileBeacon.getSecondaryEffect()) + { + powerbutton.func_146140_b(true); + } + } + + if (this.tileBeacon.getPrimaryEffect() > 0) + { + GuiBeacon.PowerButton powerbutton1 = new GuiBeacon.PowerButton(b0 << 8 | this.tileBeacon.getPrimaryEffect(), this.guiLeft + 167 + (j - 1) * 24 - k / 2, this.guiTop + 47, this.tileBeacon.getPrimaryEffect(), b0); + this.buttonList.add(powerbutton1); + + if (b0 >= this.tileBeacon.getLevels()) + { + powerbutton1.enabled = false; + } + else if (this.tileBeacon.getPrimaryEffect() == this.tileBeacon.getSecondaryEffect()) + { + powerbutton1.func_146140_b(true); + } + } + } + + this.beaconConfirmButton.enabled = this.tileBeacon.getStackInSlot(0) != null && this.tileBeacon.getPrimaryEffect() > 0; + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.id == -2) + { + this.mc.displayGuiScreen((GuiScreen)null); + } + else if (p_146284_1_.id == -1) + { + String s = "MC|Beacon"; + ByteBuf bytebuf = Unpooled.buffer(); + + try + { + bytebuf.writeInt(this.tileBeacon.getPrimaryEffect()); + bytebuf.writeInt(this.tileBeacon.getSecondaryEffect()); + this.mc.getNetHandler().addToSendQueue(new C17PacketCustomPayload(s, bytebuf)); + } + catch (Exception exception) + { + logger.error("Couldn\'t send beacon info", exception); + } + finally + { + bytebuf.release(); + } + + this.mc.displayGuiScreen((GuiScreen)null); + } + else if (p_146284_1_ instanceof GuiBeacon.PowerButton) + { + if (((GuiBeacon.PowerButton)p_146284_1_).func_146141_c()) + { + return; + } + + int j = p_146284_1_.id; + int k = j & 255; + int i = j >> 8; + + if (i < 3) + { + this.tileBeacon.setPrimaryEffect(k); + } + else + { + this.tileBeacon.setSecondaryEffect(k); + } + + this.buttonList.clear(); + this.initGui(); + this.updateScreen(); + } + } + + protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) + { + RenderHelper.disableStandardItemLighting(); + this.drawCenteredString(this.fontRendererObj, I18n.format("tile.beacon.primary", new Object[0]), 62, 10, 14737632); + this.drawCenteredString(this.fontRendererObj, I18n.format("tile.beacon.secondary", new Object[0]), 169, 10, 14737632); + Iterator iterator = this.buttonList.iterator(); + + while (iterator.hasNext()) + { + GuiButton guibutton = (GuiButton)iterator.next(); + + if (guibutton.func_146115_a()) + { + guibutton.func_146111_b(p_146979_1_ - this.guiLeft, p_146979_2_ - this.guiTop); + break; + } + } + + RenderHelper.enableGUIStandardItemLighting(); + } + + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(beaconGuiTextures); + int k = (this.width - this.xSize) / 2; + int l = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + itemRender.zLevel = 100.0F; + itemRender.renderItemAndEffectIntoGUI(this.fontRendererObj, this.mc.getTextureManager(), new ItemStack(Items.emerald), k + 42, l + 109); + itemRender.renderItemAndEffectIntoGUI(this.fontRendererObj, this.mc.getTextureManager(), new ItemStack(Items.diamond), k + 42 + 22, l + 109); + itemRender.renderItemAndEffectIntoGUI(this.fontRendererObj, this.mc.getTextureManager(), new ItemStack(Items.gold_ingot), k + 42 + 44, l + 109); + itemRender.renderItemAndEffectIntoGUI(this.fontRendererObj, this.mc.getTextureManager(), new ItemStack(Items.iron_ingot), k + 42 + 66, l + 109); + itemRender.zLevel = 0.0F; + } + + @SideOnly(Side.CLIENT) + static class Button extends GuiButton + { + private final ResourceLocation field_146145_o; + private final int field_146144_p; + private final int field_146143_q; + private boolean field_146142_r; + private static final String __OBFID = "CL_00000743"; + + protected Button(int par1, int par2, int par3, ResourceLocation par4ResourceLocation, int par5, int par6) + { + super(par1, par2, par3, 22, 22, ""); + this.field_146145_o = par4ResourceLocation; + this.field_146144_p = par5; + this.field_146143_q = par6; + } + + public void drawButton(Minecraft p_146112_1_, int p_146112_2_, int p_146112_3_) + { + if (this.visible) + { + p_146112_1_.getTextureManager().bindTexture(GuiBeacon.beaconGuiTextures); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.field_146123_n = p_146112_2_ >= this.xPosition && p_146112_3_ >= this.yPosition && p_146112_2_ < this.xPosition + this.width && p_146112_3_ < this.yPosition + this.height; + short short1 = 219; + int k = 0; + + if (!this.enabled) + { + k += this.width * 2; + } + else if (this.field_146142_r) + { + k += this.width * 1; + } + else if (this.field_146123_n) + { + k += this.width * 3; + } + + this.drawTexturedModalRect(this.xPosition, this.yPosition, k, short1, this.width, this.height); + + if (!GuiBeacon.beaconGuiTextures.equals(this.field_146145_o)) + { + p_146112_1_.getTextureManager().bindTexture(this.field_146145_o); + } + + this.drawTexturedModalRect(this.xPosition + 2, this.yPosition + 2, this.field_146144_p, this.field_146143_q, 18, 18); + } + } + + public boolean func_146141_c() + { + return this.field_146142_r; + } + + public void func_146140_b(boolean p_146140_1_) + { + this.field_146142_r = p_146140_1_; + } + } + + @SideOnly(Side.CLIENT) + class CancelButton extends GuiBeacon.Button + { + private static final String __OBFID = "CL_00000740"; + + public CancelButton(int par2, int par3, int par4) + { + super(par2, par3, par4, GuiBeacon.beaconGuiTextures, 112, 220); + } + + public void func_146111_b(int p_146111_1_, int p_146111_2_) + { + GuiBeacon.this.drawCreativeTabHoveringText(I18n.format("gui.cancel", new Object[0]), p_146111_1_, p_146111_2_); + } + } + + @SideOnly(Side.CLIENT) + class ConfirmButton extends GuiBeacon.Button + { + private static final String __OBFID = "CL_00000741"; + + public ConfirmButton(int par2, int par3, int par4) + { + super(par2, par3, par4, GuiBeacon.beaconGuiTextures, 90, 220); + } + + public void func_146111_b(int p_146111_1_, int p_146111_2_) + { + GuiBeacon.this.drawCreativeTabHoveringText(I18n.format("gui.done", new Object[0]), p_146111_1_, p_146111_2_); + } + } + + @SideOnly(Side.CLIENT) + class PowerButton extends GuiBeacon.Button + { + private final int field_146149_p; + private final int field_146148_q; + private static final String __OBFID = "CL_00000742"; + + public PowerButton(int par2, int par3, int par4, int par5, int par6) + { + super(par2, par3, par4, GuiContainer.field_147001_a, 0 + Potion.potionTypes[par5].getStatusIconIndex() % 8 * 18, 198 + Potion.potionTypes[par5].getStatusIconIndex() / 8 * 18); + this.field_146149_p = par5; + this.field_146148_q = par6; + } + + public void func_146111_b(int p_146111_1_, int p_146111_2_) + { + String s = I18n.format(Potion.potionTypes[this.field_146149_p].getName(), new Object[0]); + + if (this.field_146148_q >= 3 && this.field_146149_p != Potion.regeneration.id) + { + s = s + " II"; + } + + GuiBeacon.this.drawCreativeTabHoveringText(s, p_146111_1_, p_146111_2_); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/inventory/GuiBrewingStand.java b/src/main/java/net/minecraft/client/gui/inventory/GuiBrewingStand.java new file mode 100644 index 0000000..558a5f0 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/inventory/GuiBrewingStand.java @@ -0,0 +1,82 @@ +package net.minecraft.client.gui.inventory; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ContainerBrewingStand; +import net.minecraft.tileentity.TileEntityBrewingStand; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class GuiBrewingStand extends GuiContainer +{ + private static final ResourceLocation brewingStandGuiTextures = new ResourceLocation("textures/gui/container/brewing_stand.png"); + private TileEntityBrewingStand tileBrewingStand; + private static final String __OBFID = "CL_00000746"; + + public GuiBrewingStand(InventoryPlayer par1InventoryPlayer, TileEntityBrewingStand par2TileEntityBrewingStand) + { + super(new ContainerBrewingStand(par1InventoryPlayer, par2TileEntityBrewingStand)); + this.tileBrewingStand = par2TileEntityBrewingStand; + } + + protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) + { + String s = this.tileBrewingStand.hasCustomInventoryName() ? this.tileBrewingStand.getInventoryName() : I18n.format(this.tileBrewingStand.getInventoryName(), new Object[0]); + this.fontRendererObj.drawString(s, this.xSize / 2 - this.fontRendererObj.getStringWidth(s) / 2, 6, 4210752); + this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752); + } + + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(brewingStandGuiTextures); + int k = (this.width - this.xSize) / 2; + int l = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + int i1 = this.tileBrewingStand.getBrewTime(); + + if (i1 > 0) + { + int j1 = (int)(28.0F * (1.0F - (float)i1 / 400.0F)); + + if (j1 > 0) + { + this.drawTexturedModalRect(k + 97, l + 16, 176, 0, 9, j1); + } + + int k1 = i1 / 2 % 7; + + switch (k1) + { + case 0: + j1 = 29; + break; + case 1: + j1 = 24; + break; + case 2: + j1 = 20; + break; + case 3: + j1 = 16; + break; + case 4: + j1 = 11; + break; + case 5: + j1 = 6; + break; + case 6: + j1 = 0; + } + + if (j1 > 0) + { + this.drawTexturedModalRect(k + 65, l + 14 + 29 - j1, 185, 29 - j1, 12, j1); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/inventory/GuiChest.java b/src/main/java/net/minecraft/client/gui/inventory/GuiChest.java new file mode 100644 index 0000000..36cacc1 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/inventory/GuiChest.java @@ -0,0 +1,47 @@ +package net.minecraft.client.gui.inventory; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.resources.I18n; +import net.minecraft.inventory.ContainerChest; +import net.minecraft.inventory.IInventory; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class GuiChest extends GuiContainer +{ + private static final ResourceLocation field_147017_u = new ResourceLocation("textures/gui/container/generic_54.png"); + private IInventory upperChestInventory; + private IInventory lowerChestInventory; + private int inventoryRows; + private static final String __OBFID = "CL_00000749"; + + public GuiChest(IInventory par1IInventory, IInventory par2IInventory) + { + super(new ContainerChest(par1IInventory, par2IInventory)); + this.upperChestInventory = par1IInventory; + this.lowerChestInventory = par2IInventory; + this.allowUserInput = false; + short short1 = 222; + int i = short1 - 108; + this.inventoryRows = par2IInventory.getSizeInventory() / 9; + this.ySize = i + this.inventoryRows * 18; + } + + protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) + { + this.fontRendererObj.drawString(this.lowerChestInventory.hasCustomInventoryName() ? this.lowerChestInventory.getInventoryName() : I18n.format(this.lowerChestInventory.getInventoryName(), new Object[0]), 8, 6, 4210752); + this.fontRendererObj.drawString(this.upperChestInventory.hasCustomInventoryName() ? this.upperChestInventory.getInventoryName() : I18n.format(this.upperChestInventory.getInventoryName(), new Object[0]), 8, this.ySize - 96 + 2, 4210752); + } + + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(field_147017_u); + int k = (this.width - this.xSize) / 2; + int l = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.inventoryRows * 18 + 17); + this.drawTexturedModalRect(k, l + this.inventoryRows * 18 + 17, 0, 126, this.xSize, 96); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/inventory/GuiContainer.java b/src/main/java/net/minecraft/client/gui/inventory/GuiContainer.java new file mode 100644 index 0000000..3519702 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/inventory/GuiContainer.java @@ -0,0 +1,702 @@ +package net.minecraft.client.gui.inventory; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +@SideOnly(Side.CLIENT) +public abstract class GuiContainer extends GuiScreen +{ + protected static final ResourceLocation field_147001_a = new ResourceLocation("textures/gui/container/inventory.png"); + protected int xSize = 176; + protected int ySize = 166; + public Container inventorySlots; + protected int guiLeft; + protected int guiTop; + private Slot theSlot; + private Slot clickedSlot; + private boolean isRightMouseClick; + private ItemStack draggedStack; + private int field_147011_y; + private int field_147010_z; + private Slot returningStackDestSlot; + private long returningStackTime; + private ItemStack returningStack; + private Slot field_146985_D; + private long field_146986_E; + protected final Set field_147008_s = new HashSet(); + protected boolean field_147007_t; + private int field_146987_F; + private int field_146988_G; + private boolean field_146995_H; + private int field_146996_I; + private long field_146997_J; + private Slot field_146998_K; + private int field_146992_L; + private boolean field_146993_M; + private ItemStack field_146994_N; + private static final String __OBFID = "CL_00000737"; + + public GuiContainer(Container par1Container) + { + this.inventorySlots = par1Container; + this.field_146995_H = true; + } + + public void initGui() + { + super.initGui(); + this.mc.thePlayer.openContainer = this.inventorySlots; + this.guiLeft = (this.width - this.xSize) / 2; + this.guiTop = (this.height - this.ySize) / 2; + } + + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + int k = this.guiLeft; + int l = this.guiTop; + this.drawGuiContainerBackgroundLayer(par3, par1, par2); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + super.drawScreen(par1, par2, par3); + RenderHelper.enableGUIStandardItemLighting(); + GL11.glPushMatrix(); + GL11.glTranslatef((float)k, (float)l, 0.0F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + this.theSlot = null; + short short1 = 240; + short short2 = 240; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)short1 / 1.0F, (float)short2 / 1.0F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int k1; + + for (int i1 = 0; i1 < this.inventorySlots.inventorySlots.size(); ++i1) + { + Slot slot = (Slot)this.inventorySlots.inventorySlots.get(i1); + this.func_146977_a(slot); + + if (this.isMouseOverSlot(slot, par1, par2) && slot.func_111238_b()) + { + this.theSlot = slot; + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + int j1 = slot.xDisplayPosition; + k1 = slot.yDisplayPosition; + GL11.glColorMask(true, true, true, false); + this.drawGradientRect(j1, k1, j1 + 16, k1 + 16, -2130706433, -2130706433); + GL11.glColorMask(true, true, true, true); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + } + } + + //Forge: Force lighting to be disabled as there are some issue where lighting would + //incorrectly be applied based on items that are in the inventory. + GL11.glDisable(GL11.GL_LIGHTING); + this.drawGuiContainerForegroundLayer(par1, par2); + GL11.glEnable(GL11.GL_LIGHTING); + InventoryPlayer inventoryplayer = this.mc.thePlayer.inventory; + ItemStack itemstack = this.draggedStack == null ? inventoryplayer.getItemStack() : this.draggedStack; + + if (itemstack != null) + { + byte b0 = 8; + k1 = this.draggedStack == null ? 8 : 16; + String s = null; + + if (this.draggedStack != null && this.isRightMouseClick) + { + itemstack = itemstack.copy(); + itemstack.stackSize = MathHelper.ceiling_float_int((float)itemstack.stackSize / 2.0F); + } + else if (this.field_147007_t && this.field_147008_s.size() > 1) + { + itemstack = itemstack.copy(); + itemstack.stackSize = this.field_146996_I; + + if (itemstack.stackSize == 0) + { + s = "" + EnumChatFormatting.YELLOW + "0"; + } + } + + this.drawItemStack(itemstack, par1 - k - b0, par2 - l - k1, s); + } + + if (this.returningStack != null) + { + float f1 = (float)(Minecraft.getSystemTime() - this.returningStackTime) / 100.0F; + + if (f1 >= 1.0F) + { + f1 = 1.0F; + this.returningStack = null; + } + + k1 = this.returningStackDestSlot.xDisplayPosition - this.field_147011_y; + int j2 = this.returningStackDestSlot.yDisplayPosition - this.field_147010_z; + int l1 = this.field_147011_y + (int)((float)k1 * f1); + int i2 = this.field_147010_z + (int)((float)j2 * f1); + this.drawItemStack(this.returningStack, l1, i2, (String)null); + } + + GL11.glPopMatrix(); + + if (inventoryplayer.getItemStack() == null && this.theSlot != null && this.theSlot.getHasStack()) + { + ItemStack itemstack1 = this.theSlot.getStack(); + this.renderToolTip(itemstack1, par1, par2); + } + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + RenderHelper.enableStandardItemLighting(); + } + + private void drawItemStack(ItemStack p_146982_1_, int p_146982_2_, int p_146982_3_, String p_146982_4_) + { + GL11.glTranslatef(0.0F, 0.0F, 32.0F); + this.zLevel = 200.0F; + itemRender.zLevel = 200.0F; + FontRenderer font = null; + if (p_146982_1_ != null) font = p_146982_1_.getItem().getFontRenderer(p_146982_1_); + if (font == null) font = fontRendererObj; + itemRender.renderItemAndEffectIntoGUI(font, this.mc.getTextureManager(), p_146982_1_, p_146982_2_, p_146982_3_); + itemRender.renderItemOverlayIntoGUI(font, this.mc.getTextureManager(), p_146982_1_, p_146982_2_, p_146982_3_ - (this.draggedStack == null ? 0 : 8), p_146982_4_); + this.zLevel = 0.0F; + itemRender.zLevel = 0.0F; + } + + protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {} + + protected abstract void drawGuiContainerBackgroundLayer(float var1, int var2, int var3); + + private void func_146977_a(Slot p_146977_1_) + { + int i = p_146977_1_.xDisplayPosition; + int j = p_146977_1_.yDisplayPosition; + ItemStack itemstack = p_146977_1_.getStack(); + boolean flag = false; + boolean flag1 = p_146977_1_ == this.clickedSlot && this.draggedStack != null && !this.isRightMouseClick; + ItemStack itemstack1 = this.mc.thePlayer.inventory.getItemStack(); + String s = null; + + if (p_146977_1_ == this.clickedSlot && this.draggedStack != null && this.isRightMouseClick && itemstack != null) + { + itemstack = itemstack.copy(); + itemstack.stackSize /= 2; + } + else if (this.field_147007_t && this.field_147008_s.contains(p_146977_1_) && itemstack1 != null) + { + if (this.field_147008_s.size() == 1) + { + return; + } + + if (Container.func_94527_a(p_146977_1_, itemstack1, true) && this.inventorySlots.canDragIntoSlot(p_146977_1_)) + { + itemstack = itemstack1.copy(); + flag = true; + Container.func_94525_a(this.field_147008_s, this.field_146987_F, itemstack, p_146977_1_.getStack() == null ? 0 : p_146977_1_.getStack().stackSize); + + if (itemstack.stackSize > itemstack.getMaxStackSize()) + { + s = EnumChatFormatting.YELLOW + "" + itemstack.getMaxStackSize(); + itemstack.stackSize = itemstack.getMaxStackSize(); + } + + if (itemstack.stackSize > p_146977_1_.getSlotStackLimit()) + { + s = EnumChatFormatting.YELLOW + "" + p_146977_1_.getSlotStackLimit(); + itemstack.stackSize = p_146977_1_.getSlotStackLimit(); + } + } + else + { + this.field_147008_s.remove(p_146977_1_); + this.func_146980_g(); + } + } + + this.zLevel = 100.0F; + itemRender.zLevel = 100.0F; + + if (itemstack == null) + { + IIcon iicon = p_146977_1_.getBackgroundIconIndex(); + + if (iicon != null) + { + GL11.glDisable(GL11.GL_LIGHTING); + this.mc.getTextureManager().bindTexture(TextureMap.locationItemsTexture); + this.drawTexturedModelRectFromIcon(i, j, iicon, 16, 16); + GL11.glEnable(GL11.GL_LIGHTING); + flag1 = true; + } + } + + if (!flag1) + { + if (flag) + { + drawRect(i, j, i + 16, j + 16, -2130706433); + } + + GL11.glEnable(GL11.GL_DEPTH_TEST); + itemRender.renderItemAndEffectIntoGUI(this.fontRendererObj, this.mc.getTextureManager(), itemstack, i, j); + itemRender.renderItemOverlayIntoGUI(this.fontRendererObj, this.mc.getTextureManager(), itemstack, i, j, s); + } + + itemRender.zLevel = 0.0F; + this.zLevel = 0.0F; + } + + private void func_146980_g() + { + ItemStack itemstack = this.mc.thePlayer.inventory.getItemStack(); + + if (itemstack != null && this.field_147007_t) + { + this.field_146996_I = itemstack.stackSize; + ItemStack itemstack1; + int i; + + for (Iterator iterator = this.field_147008_s.iterator(); iterator.hasNext(); this.field_146996_I -= itemstack1.stackSize - i) + { + Slot slot = (Slot)iterator.next(); + itemstack1 = itemstack.copy(); + i = slot.getStack() == null ? 0 : slot.getStack().stackSize; + Container.func_94525_a(this.field_147008_s, this.field_146987_F, itemstack1, i); + + if (itemstack1.stackSize > itemstack1.getMaxStackSize()) + { + itemstack1.stackSize = itemstack1.getMaxStackSize(); + } + + if (itemstack1.stackSize > slot.getSlotStackLimit()) + { + itemstack1.stackSize = slot.getSlotStackLimit(); + } + } + } + } + + private Slot getSlotAtPosition(int p_146975_1_, int p_146975_2_) + { + for (int k = 0; k < this.inventorySlots.inventorySlots.size(); ++k) + { + Slot slot = (Slot)this.inventorySlots.inventorySlots.get(k); + + if (this.isMouseOverSlot(slot, p_146975_1_, p_146975_2_)) + { + return slot; + } + } + + return null; + } + + protected void mouseClicked(int par1, int par2, int par3) + { + super.mouseClicked(par1, par2, par3); + boolean flag = par3 == this.mc.gameSettings.keyBindPickBlock.getKeyCode() + 100; + Slot slot = this.getSlotAtPosition(par1, par2); + long l = Minecraft.getSystemTime(); + this.field_146993_M = this.field_146998_K == slot && l - this.field_146997_J < 250L && this.field_146992_L == par3; + this.field_146995_H = false; + + if (par3 == 0 || par3 == 1 || flag) + { + int i1 = this.guiLeft; + int j1 = this.guiTop; + boolean flag1 = par1 < i1 || par2 < j1 || par1 >= i1 + this.xSize || par2 >= j1 + this.ySize; + int k1 = -1; + + if (slot != null) + { + k1 = slot.slotNumber; + } + + if (flag1) + { + k1 = -999; + } + + if (this.mc.gameSettings.touchscreen && flag1 && this.mc.thePlayer.inventory.getItemStack() == null) + { + this.mc.displayGuiScreen((GuiScreen)null); + return; + } + + if (k1 != -1) + { + if (this.mc.gameSettings.touchscreen) + { + if (slot != null && slot.getHasStack()) + { + this.clickedSlot = slot; + this.draggedStack = null; + this.isRightMouseClick = par3 == 1; + } + else + { + this.clickedSlot = null; + } + } + else if (!this.field_147007_t) + { + if (this.mc.thePlayer.inventory.getItemStack() == null) + { + if (par3 == this.mc.gameSettings.keyBindPickBlock.getKeyCode() + 100) + { + this.handleMouseClick(slot, k1, par3, 3); + } + else + { + boolean flag2 = k1 != -999 && (Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54)); + byte b0 = 0; + + if (flag2) + { + this.field_146994_N = slot != null && slot.getHasStack() ? slot.getStack() : null; + b0 = 1; + } + else if (k1 == -999) + { + b0 = 4; + } + + this.handleMouseClick(slot, k1, par3, b0); + } + + this.field_146995_H = true; + } + else + { + this.field_147007_t = true; + this.field_146988_G = par3; + this.field_147008_s.clear(); + + if (par3 == 0) + { + this.field_146987_F = 0; + } + else if (par3 == 1) + { + this.field_146987_F = 1; + } + } + } + } + } + + this.field_146998_K = slot; + this.field_146997_J = l; + this.field_146992_L = par3; + } + + protected void mouseClickMove(int p_146273_1_, int p_146273_2_, int p_146273_3_, long p_146273_4_) + { + Slot slot = this.getSlotAtPosition(p_146273_1_, p_146273_2_); + ItemStack itemstack = this.mc.thePlayer.inventory.getItemStack(); + + if (this.clickedSlot != null && this.mc.gameSettings.touchscreen) + { + if (p_146273_3_ == 0 || p_146273_3_ == 1) + { + if (this.draggedStack == null) + { + if (slot != this.clickedSlot) + { + this.draggedStack = this.clickedSlot.getStack().copy(); + } + } + else if (this.draggedStack.stackSize > 1 && slot != null && Container.func_94527_a(slot, this.draggedStack, false)) + { + long i1 = Minecraft.getSystemTime(); + + if (this.field_146985_D == slot) + { + if (i1 - this.field_146986_E > 500L) + { + this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, 0, 0); + this.handleMouseClick(slot, slot.slotNumber, 1, 0); + this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, 0, 0); + this.field_146986_E = i1 + 750L; + --this.draggedStack.stackSize; + } + } + else + { + this.field_146985_D = slot; + this.field_146986_E = i1; + } + } + } + } + else if (this.field_147007_t && slot != null && itemstack != null && itemstack.stackSize > this.field_147008_s.size() && Container.func_94527_a(slot, itemstack, true) && slot.isItemValid(itemstack) && this.inventorySlots.canDragIntoSlot(slot)) + { + this.field_147008_s.add(slot); + this.func_146980_g(); + } + } + + protected void mouseMovedOrUp(int p_146286_1_, int p_146286_2_, int p_146286_3_) + { + Slot slot = this.getSlotAtPosition(p_146286_1_, p_146286_2_); + int l = this.guiLeft; + int i1 = this.guiTop; + boolean flag = p_146286_1_ < l || p_146286_2_ < i1 || p_146286_1_ >= l + this.xSize || p_146286_2_ >= i1 + this.ySize; + int j1 = -1; + + if (slot != null) + { + j1 = slot.slotNumber; + } + + if (flag) + { + j1 = -999; + } + + Slot slot1; + Iterator iterator; + + if (this.field_146993_M && slot != null && p_146286_3_ == 0 && this.inventorySlots.func_94530_a((ItemStack)null, slot)) + { + if (isShiftKeyDown()) + { + if (slot != null && slot.inventory != null && this.field_146994_N != null) + { + iterator = this.inventorySlots.inventorySlots.iterator(); + + while (iterator.hasNext()) + { + slot1 = (Slot)iterator.next(); + + if (slot1 != null && slot1.canTakeStack(this.mc.thePlayer) && slot1.getHasStack() && slot1.inventory == slot.inventory && Container.func_94527_a(slot1, this.field_146994_N, true)) + { + this.handleMouseClick(slot1, slot1.slotNumber, p_146286_3_, 1); + } + } + } + } + else + { + this.handleMouseClick(slot, j1, p_146286_3_, 6); + } + + this.field_146993_M = false; + this.field_146997_J = 0L; + } + else + { + if (this.field_147007_t && this.field_146988_G != p_146286_3_) + { + this.field_147007_t = false; + this.field_147008_s.clear(); + this.field_146995_H = true; + return; + } + + if (this.field_146995_H) + { + this.field_146995_H = false; + return; + } + + boolean flag1; + + if (this.clickedSlot != null && this.mc.gameSettings.touchscreen) + { + if (p_146286_3_ == 0 || p_146286_3_ == 1) + { + if (this.draggedStack == null && slot != this.clickedSlot) + { + this.draggedStack = this.clickedSlot.getStack(); + } + + flag1 = Container.func_94527_a(slot, this.draggedStack, false); + + if (j1 != -1 && this.draggedStack != null && flag1) + { + this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, p_146286_3_, 0); + this.handleMouseClick(slot, j1, 0, 0); + + if (this.mc.thePlayer.inventory.getItemStack() != null) + { + this.handleMouseClick(this.clickedSlot, this.clickedSlot.slotNumber, p_146286_3_, 0); + this.field_147011_y = p_146286_1_ - l; + this.field_147010_z = p_146286_2_ - i1; + this.returningStackDestSlot = this.clickedSlot; + this.returningStack = this.draggedStack; + this.returningStackTime = Minecraft.getSystemTime(); + } + else + { + this.returningStack = null; + } + } + else if (this.draggedStack != null) + { + this.field_147011_y = p_146286_1_ - l; + this.field_147010_z = p_146286_2_ - i1; + this.returningStackDestSlot = this.clickedSlot; + this.returningStack = this.draggedStack; + this.returningStackTime = Minecraft.getSystemTime(); + } + + this.draggedStack = null; + this.clickedSlot = null; + } + } + else if (this.field_147007_t && !this.field_147008_s.isEmpty()) + { + this.handleMouseClick((Slot)null, -999, Container.func_94534_d(0, this.field_146987_F), 5); + iterator = this.field_147008_s.iterator(); + + while (iterator.hasNext()) + { + slot1 = (Slot)iterator.next(); + this.handleMouseClick(slot1, slot1.slotNumber, Container.func_94534_d(1, this.field_146987_F), 5); + } + + this.handleMouseClick((Slot)null, -999, Container.func_94534_d(2, this.field_146987_F), 5); + } + else if (this.mc.thePlayer.inventory.getItemStack() != null) + { + if (p_146286_3_ == this.mc.gameSettings.keyBindPickBlock.getKeyCode() + 100) + { + this.handleMouseClick(slot, j1, p_146286_3_, 3); + } + else + { + flag1 = j1 != -999 && (Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54)); + + if (flag1) + { + this.field_146994_N = slot != null && slot.getHasStack() ? slot.getStack() : null; + } + + this.handleMouseClick(slot, j1, p_146286_3_, flag1 ? 1 : 0); + } + } + } + + if (this.mc.thePlayer.inventory.getItemStack() == null) + { + this.field_146997_J = 0L; + } + + this.field_147007_t = false; + } + + private boolean isMouseOverSlot(Slot p_146981_1_, int p_146981_2_, int p_146981_3_) + { + return this.func_146978_c(p_146981_1_.xDisplayPosition, p_146981_1_.yDisplayPosition, 16, 16, p_146981_2_, p_146981_3_); + } + + protected boolean func_146978_c(int p_146978_1_, int p_146978_2_, int p_146978_3_, int p_146978_4_, int p_146978_5_, int p_146978_6_) + { + int k1 = this.guiLeft; + int l1 = this.guiTop; + p_146978_5_ -= k1; + p_146978_6_ -= l1; + return p_146978_5_ >= p_146978_1_ - 1 && p_146978_5_ < p_146978_1_ + p_146978_3_ + 1 && p_146978_6_ >= p_146978_2_ - 1 && p_146978_6_ < p_146978_2_ + p_146978_4_ + 1; + } + + protected void handleMouseClick(Slot p_146984_1_, int p_146984_2_, int p_146984_3_, int p_146984_4_) + { + if (p_146984_1_ != null) + { + p_146984_2_ = p_146984_1_.slotNumber; + } + + this.mc.playerController.windowClick(this.inventorySlots.windowId, p_146984_2_, p_146984_3_, p_146984_4_, this.mc.thePlayer); + } + + protected void keyTyped(char par1, int par2) + { + if (par2 == 1 || par2 == this.mc.gameSettings.keyBindInventory.getKeyCode()) + { + this.mc.thePlayer.closeScreen(); + } + + this.checkHotbarKeys(par2); + + if (this.theSlot != null && this.theSlot.getHasStack()) + { + if (par2 == this.mc.gameSettings.keyBindPickBlock.getKeyCode()) + { + this.handleMouseClick(this.theSlot, this.theSlot.slotNumber, 0, 3); + } + else if (par2 == this.mc.gameSettings.keyBindDrop.getKeyCode()) + { + this.handleMouseClick(this.theSlot, this.theSlot.slotNumber, isCtrlKeyDown() ? 1 : 0, 4); + } + } + } + + protected boolean checkHotbarKeys(int p_146983_1_) + { + if (this.mc.thePlayer.inventory.getItemStack() == null && this.theSlot != null) + { + for (int j = 0; j < 9; ++j) + { + if (p_146983_1_ == this.mc.gameSettings.keyBindsHotbar[j].getKeyCode()) + { + this.handleMouseClick(this.theSlot, this.theSlot.slotNumber, j, 2); + return true; + } + } + } + + return false; + } + + public void onGuiClosed() + { + if (this.mc.thePlayer != null) + { + this.inventorySlots.onContainerClosed(this.mc.thePlayer); + } + } + + public boolean doesGuiPauseGame() + { + return false; + } + + public void updateScreen() + { + super.updateScreen(); + + if (!this.mc.thePlayer.isEntityAlive() || this.mc.thePlayer.isDead) + { + this.mc.thePlayer.closeScreen(); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/inventory/GuiContainerCreative.java b/src/main/java/net/minecraft/client/gui/inventory/GuiContainerCreative.java new file mode 100644 index 0000000..3c0355c --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/inventory/GuiContainerCreative.java @@ -0,0 +1,1114 @@ +package net.minecraft.client.gui.inventory; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiTextField; +import net.minecraft.client.gui.achievement.GuiAchievements; +import net.minecraft.client.gui.achievement.GuiStats; +import net.minecraft.client.renderer.InventoryEffectRenderer; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.resources.I18n; +import net.minecraft.client.settings.GameSettings; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.init.Items; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.InventoryBasic; +import net.minecraft.inventory.Slot; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +@SideOnly(Side.CLIENT) +public class GuiContainerCreative extends InventoryEffectRenderer +{ + private static final ResourceLocation field_147061_u = new ResourceLocation("textures/gui/container/creative_inventory/tabs.png"); + private static InventoryBasic field_147060_v = new InventoryBasic("tmp", true, 45); + private static int selectedTabIndex = CreativeTabs.tabBlock.getTabIndex(); + private float currentScroll; + private boolean isScrolling; + private boolean wasClicking; + private GuiTextField searchField; + private List field_147063_B; + private Slot field_147064_C; + private boolean field_147057_D; + private CreativeCrafting field_147059_E; + private static final String __OBFID = "CL_00000752"; + private static int tabPage = 0; + private int maxPages = 0; + + public GuiContainerCreative(EntityPlayer par1EntityPlayer) + { + super(new GuiContainerCreative.ContainerCreative(par1EntityPlayer)); + par1EntityPlayer.openContainer = this.inventorySlots; + this.allowUserInput = true; + this.ySize = 136; + this.xSize = 195; + } + + public void updateScreen() + { + if (!this.mc.playerController.isInCreativeMode()) + { + this.mc.displayGuiScreen(new GuiInventory(this.mc.thePlayer)); + } + } + + protected void handleMouseClick(Slot p_146984_1_, int p_146984_2_, int p_146984_3_, int p_146984_4_) + { + this.field_147057_D = true; + boolean flag = p_146984_4_ == 1; + p_146984_4_ = p_146984_2_ == -999 && p_146984_4_ == 0 ? 4 : p_146984_4_; + ItemStack itemstack1; + InventoryPlayer inventoryplayer; + + if (p_146984_1_ == null && selectedTabIndex != CreativeTabs.tabInventory.getTabIndex() && p_146984_4_ != 5) + { + inventoryplayer = this.mc.thePlayer.inventory; + + if (inventoryplayer.getItemStack() != null) + { + if (p_146984_3_ == 0) + { + this.mc.thePlayer.dropPlayerItemWithRandomChoice(inventoryplayer.getItemStack(), true); + this.mc.playerController.sendPacketDropItem(inventoryplayer.getItemStack()); + inventoryplayer.setItemStack((ItemStack)null); + } + + if (p_146984_3_ == 1) + { + itemstack1 = inventoryplayer.getItemStack().splitStack(1); + this.mc.thePlayer.dropPlayerItemWithRandomChoice(itemstack1, true); + this.mc.playerController.sendPacketDropItem(itemstack1); + + if (inventoryplayer.getItemStack().stackSize == 0) + { + inventoryplayer.setItemStack((ItemStack)null); + } + } + } + } + else + { + int l; + + if (p_146984_1_ == this.field_147064_C && flag) + { + for (l = 0; l < this.mc.thePlayer.inventoryContainer.getInventory().size(); ++l) + { + this.mc.playerController.sendSlotPacket((ItemStack)null, l); + } + } + else + { + ItemStack itemstack; + + if (selectedTabIndex == CreativeTabs.tabInventory.getTabIndex()) + { + if (p_146984_1_ == this.field_147064_C) + { + this.mc.thePlayer.inventory.setItemStack((ItemStack)null); + } + else if (p_146984_4_ == 4 && p_146984_1_ != null && p_146984_1_.getHasStack()) + { + itemstack = p_146984_1_.decrStackSize(p_146984_3_ == 0 ? 1 : p_146984_1_.getStack().getMaxStackSize()); + this.mc.thePlayer.dropPlayerItemWithRandomChoice(itemstack, true); + this.mc.playerController.sendPacketDropItem(itemstack); + } + else if (p_146984_4_ == 4 && this.mc.thePlayer.inventory.getItemStack() != null) + { + this.mc.thePlayer.dropPlayerItemWithRandomChoice(this.mc.thePlayer.inventory.getItemStack(), true); + this.mc.playerController.sendPacketDropItem(this.mc.thePlayer.inventory.getItemStack()); + this.mc.thePlayer.inventory.setItemStack((ItemStack)null); + } + else + { + this.mc.thePlayer.inventoryContainer.slotClick(p_146984_1_ == null ? p_146984_2_ : ((GuiContainerCreative.CreativeSlot)p_146984_1_).field_148332_b.slotNumber, p_146984_3_, p_146984_4_, this.mc.thePlayer); + this.mc.thePlayer.inventoryContainer.detectAndSendChanges(); + } + } + else if (p_146984_4_ != 5 && p_146984_1_.inventory == field_147060_v) + { + inventoryplayer = this.mc.thePlayer.inventory; + itemstack1 = inventoryplayer.getItemStack(); + ItemStack itemstack2 = p_146984_1_.getStack(); + ItemStack itemstack3; + + if (p_146984_4_ == 2) + { + if (itemstack2 != null && p_146984_3_ >= 0 && p_146984_3_ < 9) + { + itemstack3 = itemstack2.copy(); + itemstack3.stackSize = itemstack3.getMaxStackSize(); + this.mc.thePlayer.inventory.setInventorySlotContents(p_146984_3_, itemstack3); + this.mc.thePlayer.inventoryContainer.detectAndSendChanges(); + } + + return; + } + + if (p_146984_4_ == 3) + { + if (inventoryplayer.getItemStack() == null && p_146984_1_.getHasStack()) + { + itemstack3 = p_146984_1_.getStack().copy(); + itemstack3.stackSize = itemstack3.getMaxStackSize(); + inventoryplayer.setItemStack(itemstack3); + } + + return; + } + + if (p_146984_4_ == 4) + { + if (itemstack2 != null) + { + itemstack3 = itemstack2.copy(); + itemstack3.stackSize = p_146984_3_ == 0 ? 1 : itemstack3.getMaxStackSize(); + this.mc.thePlayer.dropPlayerItemWithRandomChoice(itemstack3, true); + this.mc.playerController.sendPacketDropItem(itemstack3); + } + + return; + } + + if (itemstack1 != null && itemstack2 != null && itemstack1.isItemEqual(itemstack2) && ItemStack.areItemStackTagsEqual(itemstack1, itemstack2)) //Forge: Bugfix, Compare NBT data, allow for deletion of enchanted books, MC-12770 + { + if (p_146984_3_ == 0) + { + if (flag) + { + itemstack1.stackSize = itemstack1.getMaxStackSize(); + } + else if (itemstack1.stackSize < itemstack1.getMaxStackSize()) + { + ++itemstack1.stackSize; + } + } + else if (itemstack1.stackSize <= 1) + { + inventoryplayer.setItemStack((ItemStack)null); + } + else + { + --itemstack1.stackSize; + } + } + else if (itemstack2 != null && itemstack1 == null) + { + inventoryplayer.setItemStack(ItemStack.copyItemStack(itemstack2)); + itemstack1 = inventoryplayer.getItemStack(); + + if (flag) + { + itemstack1.stackSize = itemstack1.getMaxStackSize(); + } + } + else + { + inventoryplayer.setItemStack((ItemStack)null); + } + } + else + { + this.inventorySlots.slotClick(p_146984_1_ == null ? p_146984_2_ : p_146984_1_.slotNumber, p_146984_3_, p_146984_4_, this.mc.thePlayer); + + if (Container.func_94532_c(p_146984_3_) == 2) + { + for (l = 0; l < 9; ++l) + { + this.mc.playerController.sendSlotPacket(this.inventorySlots.getSlot(45 + l).getStack(), 36 + l); + } + } + else if (p_146984_1_ != null) + { + itemstack = this.inventorySlots.getSlot(p_146984_1_.slotNumber).getStack(); + this.mc.playerController.sendSlotPacket(itemstack, p_146984_1_.slotNumber - this.inventorySlots.inventorySlots.size() + 9 + 36); + } + } + } + } + } + + public void initGui() + { + if (this.mc.playerController.isInCreativeMode()) + { + super.initGui(); + this.buttonList.clear(); + Keyboard.enableRepeatEvents(true); + this.searchField = new GuiTextField(this.fontRendererObj, this.guiLeft + 82, this.guiTop + 6, 89, this.fontRendererObj.FONT_HEIGHT); + this.searchField.setMaxStringLength(15); + this.searchField.setEnableBackgroundDrawing(false); + this.searchField.setVisible(false); + this.searchField.setTextColor(16777215); + int i = selectedTabIndex; + selectedTabIndex = -1; + this.setCurrentCreativeTab(CreativeTabs.creativeTabArray[i]); + this.field_147059_E = new CreativeCrafting(this.mc); + this.mc.thePlayer.inventoryContainer.addCraftingToCrafters(this.field_147059_E); + int tabCount = CreativeTabs.creativeTabArray.length; + if (tabCount > 12) + { + buttonList.add(new GuiButton(101, guiLeft, guiTop - 50, 20, 20, "<")); + buttonList.add(new GuiButton(102, guiLeft + xSize - 20, guiTop - 50, 20, 20, ">")); + maxPages = ((tabCount - 12) / 10) + 1; + } + } + else + { + this.mc.displayGuiScreen(new GuiInventory(this.mc.thePlayer)); + } + } + + public void onGuiClosed() + { + super.onGuiClosed(); + + if (this.mc.thePlayer != null && this.mc.thePlayer.inventory != null) + { + this.mc.thePlayer.inventoryContainer.removeCraftingFromCrafters(this.field_147059_E); + } + + Keyboard.enableRepeatEvents(false); + } + + protected void keyTyped(char par1, int par2) + { + if (!CreativeTabs.creativeTabArray[selectedTabIndex].hasSearchBar()) + { + if (GameSettings.isKeyDown(this.mc.gameSettings.keyBindChat)) + { + this.setCurrentCreativeTab(CreativeTabs.tabAllSearch); + } + else + { + super.keyTyped(par1, par2); + } + } + else + { + if (this.field_147057_D) + { + this.field_147057_D = false; + this.searchField.setText(""); + } + + if (!this.checkHotbarKeys(par2)) + { + if (this.searchField.textboxKeyTyped(par1, par2)) + { + this.updateCreativeSearch(); + } + else + { + super.keyTyped(par1, par2); + } + } + } + } + + private void updateCreativeSearch() + { + GuiContainerCreative.ContainerCreative containercreative = (GuiContainerCreative.ContainerCreative)this.inventorySlots; + containercreative.itemList.clear(); + + CreativeTabs tab = CreativeTabs.creativeTabArray[selectedTabIndex]; + if (tab.hasSearchBar() && tab != CreativeTabs.tabAllSearch) + { + tab.displayAllReleventItems(containercreative.itemList); + updateFilteredItems(containercreative); + return; + } + + Iterator iterator = Item.itemRegistry.iterator(); + + while (iterator.hasNext()) + { + Item item = (Item)iterator.next(); + + if (item != null && item.getCreativeTab() != null) + { + item.getSubItems(item, (CreativeTabs)null, containercreative.itemList); + } + } + updateFilteredItems(containercreative); + } + + //split from above for custom search tabs + private void updateFilteredItems(GuiContainerCreative.ContainerCreative containercreative) + { + Iterator iterator; + Enchantment[] aenchantment = Enchantment.enchantmentsList; + int j = aenchantment.length; + + for (int i = 0; i < j; ++i) + { + Enchantment enchantment = aenchantment[i]; + + if (enchantment != null && enchantment.type != null) + { + Items.enchanted_book.func_92113_a(enchantment, containercreative.itemList); + } + } + + iterator = containercreative.itemList.iterator(); + String s1 = this.searchField.getText().toLowerCase(); + + while (iterator.hasNext()) + { + ItemStack itemstack = (ItemStack)iterator.next(); + boolean flag = false; + Iterator iterator1 = itemstack.getTooltip(this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips).iterator(); + + while (true) + { + if (iterator1.hasNext()) + { + String s = (String)iterator1.next(); + + if (!s.toLowerCase().contains(s1)) + { + continue; + } + + flag = true; + } + + if (!flag) + { + iterator.remove(); + } + + break; + } + } + + this.currentScroll = 0.0F; + containercreative.scrollTo(0.0F); + } + + protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) + { + CreativeTabs creativetabs = CreativeTabs.creativeTabArray[selectedTabIndex]; + + if (creativetabs != null && creativetabs.drawInForegroundOfTab()) + { + GL11.glDisable(GL11.GL_BLEND); + this.fontRendererObj.drawString(I18n.format(creativetabs.getTranslatedTabLabel(), new Object[0]), 8, 6, 4210752); + } + } + + protected void mouseClicked(int par1, int par2, int par3) + { + if (par3 == 0) + { + int l = par1 - this.guiLeft; + int i1 = par2 - this.guiTop; + CreativeTabs[] acreativetabs = CreativeTabs.creativeTabArray; + int j1 = acreativetabs.length; + + for (int k1 = 0; k1 < j1; ++k1) + { + CreativeTabs creativetabs = acreativetabs[k1]; + + if (creativetabs != null && this.func_147049_a(creativetabs, l, i1)) + { + return; + } + } + } + + super.mouseClicked(par1, par2, par3); + } + + protected void mouseMovedOrUp(int p_146286_1_, int p_146286_2_, int p_146286_3_) + { + if (p_146286_3_ == 0) + { + int l = p_146286_1_ - this.guiLeft; + int i1 = p_146286_2_ - this.guiTop; + CreativeTabs[] acreativetabs = CreativeTabs.creativeTabArray; + int j1 = acreativetabs.length; + + for (int k1 = 0; k1 < j1; ++k1) + { + CreativeTabs creativetabs = acreativetabs[k1]; + + if (creativetabs != null && this.func_147049_a(creativetabs, l, i1)) + { + this.setCurrentCreativeTab(creativetabs); + return; + } + } + } + + super.mouseMovedOrUp(p_146286_1_, p_146286_2_, p_146286_3_); + } + + private boolean needsScrollBars() + { + if (CreativeTabs.creativeTabArray[selectedTabIndex] == null) return false; + return selectedTabIndex != CreativeTabs.tabInventory.getTabIndex() && CreativeTabs.creativeTabArray[selectedTabIndex].shouldHidePlayerInventory() && ((GuiContainerCreative.ContainerCreative)this.inventorySlots).func_148328_e(); + } + + private void setCurrentCreativeTab(CreativeTabs p_147050_1_) + { + if (p_147050_1_ == null) return; + int i = selectedTabIndex; + selectedTabIndex = p_147050_1_.getTabIndex(); + GuiContainerCreative.ContainerCreative containercreative = (GuiContainerCreative.ContainerCreative)this.inventorySlots; + this.field_147008_s.clear(); + containercreative.itemList.clear(); + p_147050_1_.displayAllReleventItems(containercreative.itemList); + + if (p_147050_1_ == CreativeTabs.tabInventory) + { + Container container = this.mc.thePlayer.inventoryContainer; + + if (this.field_147063_B == null) + { + this.field_147063_B = containercreative.inventorySlots; + } + + containercreative.inventorySlots = new ArrayList(); + + for (int j = 0; j < container.inventorySlots.size(); ++j) + { + GuiContainerCreative.CreativeSlot creativeslot = new GuiContainerCreative.CreativeSlot((Slot)container.inventorySlots.get(j), j); + containercreative.inventorySlots.add(creativeslot); + int k; + int l; + int i1; + + if (j >= 5 && j < 9) + { + k = j - 5; + l = k / 2; + i1 = k % 2; + creativeslot.xDisplayPosition = 9 + l * 54; + creativeslot.yDisplayPosition = 6 + i1 * 27; + } + else if (j >= 0 && j < 5) + { + creativeslot.yDisplayPosition = -2000; + creativeslot.xDisplayPosition = -2000; + } + else if (j < container.inventorySlots.size()) + { + k = j - 9; + l = k % 9; + i1 = k / 9; + creativeslot.xDisplayPosition = 9 + l * 18; + + if (j >= 36) + { + creativeslot.yDisplayPosition = 112; + } + else + { + creativeslot.yDisplayPosition = 54 + i1 * 18; + } + } + } + + this.field_147064_C = new Slot(field_147060_v, 0, 173, 112); + containercreative.inventorySlots.add(this.field_147064_C); + } + else if (i == CreativeTabs.tabInventory.getTabIndex()) + { + containercreative.inventorySlots = this.field_147063_B; + this.field_147063_B = null; + } + + if (this.searchField != null) + { + if (p_147050_1_.hasSearchBar()) + { + this.searchField.setVisible(true); + this.searchField.setCanLoseFocus(false); + this.searchField.setFocused(true); + this.searchField.setText(""); + this.updateCreativeSearch(); + } + else + { + this.searchField.setVisible(false); + this.searchField.setCanLoseFocus(true); + this.searchField.setFocused(false); + } + } + + this.currentScroll = 0.0F; + containercreative.scrollTo(0.0F); + } + + public void handleMouseInput() + { + super.handleMouseInput(); + int i = Mouse.getEventDWheel(); + + if (i != 0 && this.needsScrollBars()) + { + int j = ((GuiContainerCreative.ContainerCreative)this.inventorySlots).itemList.size() / 9 - 5 + 1; + + if (i > 0) + { + i = 1; + } + + if (i < 0) + { + i = -1; + } + + this.currentScroll = (float)((double)this.currentScroll - (double)i / (double)j); + + if (this.currentScroll < 0.0F) + { + this.currentScroll = 0.0F; + } + + if (this.currentScroll > 1.0F) + { + this.currentScroll = 1.0F; + } + + ((GuiContainerCreative.ContainerCreative)this.inventorySlots).scrollTo(this.currentScroll); + } + } + + public void drawScreen(int par1, int par2, float par3) + { + boolean flag = Mouse.isButtonDown(0); + int k = this.guiLeft; + int l = this.guiTop; + int i1 = k + 175; + int j1 = l + 18; + int k1 = i1 + 14; + int l1 = j1 + 112; + + if (!this.wasClicking && flag && par1 >= i1 && par2 >= j1 && par1 < k1 && par2 < l1) + { + this.isScrolling = this.needsScrollBars(); + } + + if (!flag) + { + this.isScrolling = false; + } + + this.wasClicking = flag; + + if (this.isScrolling) + { + this.currentScroll = ((float)(par2 - j1) - 7.5F) / ((float)(l1 - j1) - 15.0F); + + if (this.currentScroll < 0.0F) + { + this.currentScroll = 0.0F; + } + + if (this.currentScroll > 1.0F) + { + this.currentScroll = 1.0F; + } + + ((GuiContainerCreative.ContainerCreative)this.inventorySlots).scrollTo(this.currentScroll); + } + + super.drawScreen(par1, par2, par3); + CreativeTabs[] acreativetabs = CreativeTabs.creativeTabArray; + int start = tabPage * 10; + int i2 = Math.min(acreativetabs.length, ((tabPage + 1) * 10) + 2); + if (tabPage != 0) start += 2; + boolean rendered = false; + + for (int j2 = start; j2 < i2; ++j2) + { + CreativeTabs creativetabs = acreativetabs[j2]; + + if (creativetabs == null) continue; + if (this.renderCreativeInventoryHoveringText(creativetabs, par1, par2)) + { + rendered = true; + break; + } + } + + if (!rendered && renderCreativeInventoryHoveringText(CreativeTabs.tabAllSearch, par1, par2)) + { + renderCreativeInventoryHoveringText(CreativeTabs.tabInventory, par1, par2); + } + + if (this.field_147064_C != null && selectedTabIndex == CreativeTabs.tabInventory.getTabIndex() && this.func_146978_c(this.field_147064_C.xDisplayPosition, this.field_147064_C.yDisplayPosition, 16, 16, par1, par2)) + { + this.drawCreativeTabHoveringText(I18n.format("inventory.binSlot", new Object[0]), par1, par2); + } + + if (maxPages != 0) + { + String page = String.format("%d / %d", tabPage + 1, maxPages + 1); + int width = fontRendererObj.getStringWidth(page); + GL11.glDisable(GL11.GL_LIGHTING); + this.zLevel = 300.0F; + itemRender.zLevel = 300.0F; + fontRendererObj.drawString(page, guiLeft + (xSize / 2) - (width / 2), guiTop - 44, -1); + this.zLevel = 0.0F; + itemRender.zLevel = 0.0F; + } + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_LIGHTING); + } + + protected void renderToolTip(ItemStack p_146285_1_, int p_146285_2_, int p_146285_3_) + { + if (selectedTabIndex == CreativeTabs.tabAllSearch.getTabIndex()) + { + List list = p_146285_1_.getTooltip(this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips); + CreativeTabs creativetabs = p_146285_1_.getItem().getCreativeTab(); + + if (creativetabs == null && p_146285_1_.getItem() == Items.enchanted_book) + { + Map map = EnchantmentHelper.getEnchantments(p_146285_1_); + + if (map.size() == 1) + { + Enchantment enchantment = Enchantment.enchantmentsList[((Integer)map.keySet().iterator().next()).intValue()]; + CreativeTabs[] acreativetabs = CreativeTabs.creativeTabArray; + int k = acreativetabs.length; + + for (int l = 0; l < k; ++l) + { + CreativeTabs creativetabs1 = acreativetabs[l]; + + if (creativetabs1.func_111226_a(enchantment.type)) + { + creativetabs = creativetabs1; + break; + } + } + } + } + + if (creativetabs != null) + { + list.add(1, "" + EnumChatFormatting.BOLD + EnumChatFormatting.BLUE + I18n.format(creativetabs.getTranslatedTabLabel(), new Object[0])); + } + + for (int i1 = 0; i1 < list.size(); ++i1) + { + if (i1 == 0) + { + list.set(i1, p_146285_1_.getRarity().rarityColor + (String)list.get(i1)); + } + else + { + list.set(i1, EnumChatFormatting.GRAY + (String)list.get(i1)); + } + } + + this.func_146283_a(list, p_146285_2_, p_146285_3_); + } + else + { + super.renderToolTip(p_146285_1_, p_146285_2_, p_146285_3_); + } + } + + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + RenderHelper.enableGUIStandardItemLighting(); + CreativeTabs creativetabs = CreativeTabs.creativeTabArray[selectedTabIndex]; + CreativeTabs[] acreativetabs = CreativeTabs.creativeTabArray; + int k = acreativetabs.length; + int l; + + int start = tabPage * 10; + k = Math.min(acreativetabs.length, ((tabPage + 1) * 10 + 2)); + if (tabPage != 0) start += 2; + + for (l = start; l < k; ++l) + { + CreativeTabs creativetabs1 = acreativetabs[l]; + this.mc.getTextureManager().bindTexture(field_147061_u); + + if (creativetabs1 == null) continue; + + if (creativetabs1.getTabIndex() != selectedTabIndex) + { + this.func_147051_a(creativetabs1); + } + } + + if (tabPage != 0) + { + if (creativetabs != CreativeTabs.tabAllSearch) + { + this.mc.getTextureManager().bindTexture(field_147061_u); + func_147051_a(CreativeTabs.tabAllSearch); + } + if (creativetabs != CreativeTabs.tabInventory) + { + this.mc.getTextureManager().bindTexture(field_147061_u); + func_147051_a(CreativeTabs.tabInventory); + } + } + + this.mc.getTextureManager().bindTexture(new ResourceLocation("textures/gui/container/creative_inventory/tab_" + creativetabs.getBackgroundImageName())); + this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize); + this.searchField.drawTextBox(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int i1 = this.guiLeft + 175; + k = this.guiTop + 18; + l = k + 112; + this.mc.getTextureManager().bindTexture(field_147061_u); + + if (creativetabs.shouldHidePlayerInventory()) + { + this.drawTexturedModalRect(i1, k + (int)((float)(l - k - 17) * this.currentScroll), 232 + (this.needsScrollBars() ? 0 : 12), 0, 12, 15); + } + + if (creativetabs == null || creativetabs.getTabPage() != tabPage) + { + if (creativetabs != CreativeTabs.tabAllSearch && creativetabs != CreativeTabs.tabInventory) + { + return; + } + } + + this.func_147051_a(creativetabs); + + if (creativetabs == CreativeTabs.tabInventory) + { + GuiInventory.func_147046_a(this.guiLeft + 43, this.guiTop + 45, 20, (float)(this.guiLeft + 43 - p_146976_2_), (float)(this.guiTop + 45 - 30 - p_146976_3_), this.mc.thePlayer); + } + } + + protected boolean func_147049_a(CreativeTabs p_147049_1_, int p_147049_2_, int p_147049_3_) + { + if (p_147049_1_.getTabPage() != tabPage) + { + if (p_147049_1_ != CreativeTabs.tabAllSearch && + p_147049_1_ != CreativeTabs.tabInventory) + { + return false; + } + } + + int k = p_147049_1_.getTabColumn(); + int l = 28 * k; + byte b0 = 0; + + if (k == 5) + { + l = this.xSize - 28 + 2; + } + else if (k > 0) + { + l += k; + } + + int i1; + + if (p_147049_1_.isTabInFirstRow()) + { + i1 = b0 - 32; + } + else + { + i1 = b0 + this.ySize; + } + + return p_147049_2_ >= l && p_147049_2_ <= l + 28 && p_147049_3_ >= i1 && p_147049_3_ <= i1 + 32; + } + + protected boolean renderCreativeInventoryHoveringText(CreativeTabs p_147052_1_, int p_147052_2_, int p_147052_3_) + { + int k = p_147052_1_.getTabColumn(); + int l = 28 * k; + byte b0 = 0; + + if (k == 5) + { + l = this.xSize - 28 + 2; + } + else if (k > 0) + { + l += k; + } + + int i1; + + if (p_147052_1_.isTabInFirstRow()) + { + i1 = b0 - 32; + } + else + { + i1 = b0 + this.ySize; + } + + if (this.func_146978_c(l + 3, i1 + 3, 23, 27, p_147052_2_, p_147052_3_)) + { + this.drawCreativeTabHoveringText(I18n.format(p_147052_1_.getTranslatedTabLabel(), new Object[0]), p_147052_2_, p_147052_3_); + return true; + } + else + { + return false; + } + } + + protected void func_147051_a(CreativeTabs p_147051_1_) + { + boolean flag = p_147051_1_.getTabIndex() == selectedTabIndex; + boolean flag1 = p_147051_1_.isTabInFirstRow(); + int i = p_147051_1_.getTabColumn(); + int j = i * 28; + int k = 0; + int l = this.guiLeft + 28 * i; + int i1 = this.guiTop; + byte b0 = 32; + + if (flag) + { + k += 32; + } + + if (i == 5) + { + l = this.guiLeft + this.xSize - 28; + } + else if (i > 0) + { + l += i; + } + + if (flag1) + { + i1 -= 28; + } + else + { + k += 64; + i1 += this.ySize - 4; + } + + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glColor3f(1F, 1F, 1F); //Forge: Reset color in case Items change it. + this.drawTexturedModalRect(l, i1, j, k, 28, b0); + this.zLevel = 100.0F; + itemRender.zLevel = 100.0F; + l += 6; + i1 += 8 + (flag1 ? 1 : -1); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + ItemStack itemstack = p_147051_1_.getIconItemStack(); + itemRender.renderItemAndEffectIntoGUI(this.fontRendererObj, this.mc.getTextureManager(), itemstack, l, i1); + itemRender.renderItemOverlayIntoGUI(this.fontRendererObj, this.mc.getTextureManager(), itemstack, l, i1); + GL11.glDisable(GL11.GL_LIGHTING); + itemRender.zLevel = 0.0F; + this.zLevel = 0.0F; + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.id == 0) + { + this.mc.displayGuiScreen(new GuiAchievements(this, this.mc.thePlayer.getStatFileWriter())); + } + + if (p_146284_1_.id == 1) + { + this.mc.displayGuiScreen(new GuiStats(this, this.mc.thePlayer.getStatFileWriter())); + } + + if (p_146284_1_.id == 101) + { + tabPage = Math.max(tabPage - 1, 0); + } + else if (p_146284_1_.id == 102) + { + tabPage = Math.min(tabPage + 1, maxPages); + } + } + + public int func_147056_g() + { + return selectedTabIndex; + } + + @SideOnly(Side.CLIENT) + static class ContainerCreative extends Container + { + public List itemList = new ArrayList(); + private static final String __OBFID = "CL_00000753"; + + public ContainerCreative(EntityPlayer par1EntityPlayer) + { + InventoryPlayer inventoryplayer = par1EntityPlayer.inventory; + int i; + + for (i = 0; i < 5; ++i) + { + for (int j = 0; j < 9; ++j) + { + this.addSlotToContainer(new Slot(GuiContainerCreative.field_147060_v, i * 9 + j, 9 + j * 18, 18 + i * 18)); + } + } + + for (i = 0; i < 9; ++i) + { + this.addSlotToContainer(new Slot(inventoryplayer, i, 9 + i * 18, 112)); + } + + this.scrollTo(0.0F); + } + + public boolean canInteractWith(EntityPlayer par1EntityPlayer) + { + return true; + } + + public void scrollTo(float p_148329_1_) + { + int i = this.itemList.size() / 9 - 5 + 1; + int j = (int)((double)(p_148329_1_ * (float)i) + 0.5D); + + if (j < 0) + { + j = 0; + } + + for (int k = 0; k < 5; ++k) + { + for (int l = 0; l < 9; ++l) + { + int i1 = l + (k + j) * 9; + + if (i1 >= 0 && i1 < this.itemList.size()) + { + GuiContainerCreative.field_147060_v.setInventorySlotContents(l + k * 9, (ItemStack)this.itemList.get(i1)); + } + else + { + GuiContainerCreative.field_147060_v.setInventorySlotContents(l + k * 9, (ItemStack)null); + } + } + } + } + + public boolean func_148328_e() + { + return this.itemList.size() > 45; + } + + protected void retrySlotClick(int par1, int par2, boolean par3, EntityPlayer par4EntityPlayer) {} + + public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) + { + if (par2 >= this.inventorySlots.size() - 9 && par2 < this.inventorySlots.size()) + { + Slot slot = (Slot)this.inventorySlots.get(par2); + + if (slot != null && slot.getHasStack()) + { + slot.putStack((ItemStack)null); + } + } + + return null; + } + + public boolean func_94530_a(ItemStack par1ItemStack, Slot par2Slot) + { + return par2Slot.yDisplayPosition > 90; + } + + public boolean canDragIntoSlot(Slot par1Slot) + { + return par1Slot.inventory instanceof InventoryPlayer || par1Slot.yDisplayPosition > 90 && par1Slot.xDisplayPosition <= 162; + } + } + + @SideOnly(Side.CLIENT) + class CreativeSlot extends Slot + { + private final Slot field_148332_b; + private static final String __OBFID = "CL_00000754"; + + public CreativeSlot(Slot par2Slot, int par3) + { + super(par2Slot.inventory, par3, 0, 0); + this.field_148332_b = par2Slot; + } + + public void onPickupFromSlot(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack) + { + this.field_148332_b.onPickupFromSlot(par1EntityPlayer, par2ItemStack); + } + + public boolean isItemValid(ItemStack par1ItemStack) + { + return this.field_148332_b.isItemValid(par1ItemStack); + } + + public ItemStack getStack() + { + return this.field_148332_b.getStack(); + } + + public boolean getHasStack() + { + return this.field_148332_b.getHasStack(); + } + + public void putStack(ItemStack par1ItemStack) + { + this.field_148332_b.putStack(par1ItemStack); + } + + public void onSlotChanged() + { + this.field_148332_b.onSlotChanged(); + } + + public int getSlotStackLimit() + { + return this.field_148332_b.getSlotStackLimit(); + } + + public IIcon getBackgroundIconIndex() + { + return this.field_148332_b.getBackgroundIconIndex(); + } + + public ItemStack decrStackSize(int par1) + { + return this.field_148332_b.decrStackSize(par1); + } + + public boolean isSlotInInventory(IInventory par1IInventory, int par2) + { + return this.field_148332_b.isSlotInInventory(par1IInventory, par2); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/inventory/GuiCrafting.java b/src/main/java/net/minecraft/client/gui/inventory/GuiCrafting.java new file mode 100644 index 0000000..524115b --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/inventory/GuiCrafting.java @@ -0,0 +1,37 @@ +package net.minecraft.client.gui.inventory; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ContainerWorkbench; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class GuiCrafting extends GuiContainer +{ + private static final ResourceLocation craftingTableGuiTextures = new ResourceLocation("textures/gui/container/crafting_table.png"); + private static final String __OBFID = "CL_00000750"; + + public GuiCrafting(InventoryPlayer par1InventoryPlayer, World par2World, int par3, int par4, int par5) + { + super(new ContainerWorkbench(par1InventoryPlayer, par2World, par3, par4, par5)); + } + + protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) + { + this.fontRendererObj.drawString(I18n.format("container.crafting", new Object[0]), 28, 6, 4210752); + this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752); + } + + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(craftingTableGuiTextures); + int k = (this.width - this.xSize) / 2; + int l = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/inventory/GuiDispenser.java b/src/main/java/net/minecraft/client/gui/inventory/GuiDispenser.java new file mode 100644 index 0000000..c7cd352 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/inventory/GuiDispenser.java @@ -0,0 +1,40 @@ +package net.minecraft.client.gui.inventory; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ContainerDispenser; +import net.minecraft.tileentity.TileEntityDispenser; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class GuiDispenser extends GuiContainer +{ + private static final ResourceLocation dispenserGuiTextures = new ResourceLocation("textures/gui/container/dispenser.png"); + public TileEntityDispenser tileDispenser; + private static final String __OBFID = "CL_00000765"; + + public GuiDispenser(InventoryPlayer par1InventoryPlayer, TileEntityDispenser par2TileEntityDispenser) + { + super(new ContainerDispenser(par1InventoryPlayer, par2TileEntityDispenser)); + this.tileDispenser = par2TileEntityDispenser; + } + + protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) + { + String s = this.tileDispenser.hasCustomInventoryName() ? this.tileDispenser.getInventoryName() : I18n.format(this.tileDispenser.getInventoryName(), new Object[0]); + this.fontRendererObj.drawString(s, this.xSize / 2 - this.fontRendererObj.getStringWidth(s) / 2, 6, 4210752); + this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752); + } + + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(dispenserGuiTextures); + int k = (this.width - this.xSize) / 2; + int l = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/inventory/GuiEditSign.java b/src/main/java/net/minecraft/client/gui/inventory/GuiEditSign.java new file mode 100644 index 0000000..bed9ee3 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/inventory/GuiEditSign.java @@ -0,0 +1,149 @@ +package net.minecraft.client.gui.inventory; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.network.NetHandlerPlayClient; +import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; +import net.minecraft.init.Blocks; +import net.minecraft.network.play.client.C12PacketUpdateSign; +import net.minecraft.tileentity.TileEntitySign; +import net.minecraft.util.ChatAllowedCharacters; +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class GuiEditSign extends GuiScreen +{ + protected String screenTitle = "Edit sign message:"; + private TileEntitySign tileSign; + private int updateCounter; + private int editLine; + private GuiButton doneBtn; + private static final String __OBFID = "CL_00000764"; + + public GuiEditSign(TileEntitySign par1TileEntitySign) + { + this.tileSign = par1TileEntitySign; + } + + public void initGui() + { + this.buttonList.clear(); + Keyboard.enableRepeatEvents(true); + this.buttonList.add(this.doneBtn = new GuiButton(0, this.width / 2 - 100, this.height / 4 + 120, "Done")); + this.tileSign.setEditable(false); + } + + public void onGuiClosed() + { + Keyboard.enableRepeatEvents(false); + NetHandlerPlayClient nethandlerplayclient = this.mc.getNetHandler(); + + if (nethandlerplayclient != null) + { + nethandlerplayclient.addToSendQueue(new C12PacketUpdateSign(this.tileSign.xCoord, this.tileSign.yCoord, this.tileSign.zCoord, this.tileSign.signText)); + } + + this.tileSign.setEditable(true); + } + + public void updateScreen() + { + ++this.updateCounter; + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.enabled) + { + if (p_146284_1_.id == 0) + { + this.tileSign.markDirty(); + this.mc.displayGuiScreen((GuiScreen)null); + } + } + } + + protected void keyTyped(char par1, int par2) + { + if (par2 == 200) + { + this.editLine = this.editLine - 1 & 3; + } + + if (par2 == 208 || par2 == 28 || par2 == 156) + { + this.editLine = this.editLine + 1 & 3; + } + + if (par2 == 14 && this.tileSign.signText[this.editLine].length() > 0) + { + this.tileSign.signText[this.editLine] = this.tileSign.signText[this.editLine].substring(0, this.tileSign.signText[this.editLine].length() - 1); + } + + if (ChatAllowedCharacters.isAllowedCharacter(par1) && this.tileSign.signText[this.editLine].length() < 15) + { + this.tileSign.signText[this.editLine] = this.tileSign.signText[this.editLine] + par1; + } + + if (par2 == 1) + { + this.actionPerformed(this.doneBtn); + } + } + + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + this.drawCenteredString(this.fontRendererObj, this.screenTitle, this.width / 2, 40, 16777215); + GL11.glPushMatrix(); + GL11.glTranslatef((float)(this.width / 2), 0.0F, 50.0F); + float f1 = 93.75F; + GL11.glScalef(-f1, -f1, -f1); + GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); + Block block = this.tileSign.getBlockType(); + + if (block == Blocks.standing_sign) + { + float f2 = (float)(this.tileSign.getBlockMetadata() * 360) / 16.0F; + GL11.glRotatef(f2, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(0.0F, -1.0625F, 0.0F); + } + else + { + int k = this.tileSign.getBlockMetadata(); + float f3 = 0.0F; + + if (k == 2) + { + f3 = 180.0F; + } + + if (k == 4) + { + f3 = 90.0F; + } + + if (k == 5) + { + f3 = -90.0F; + } + + GL11.glRotatef(f3, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(0.0F, -1.0625F, 0.0F); + } + + if (this.updateCounter / 6 % 2 == 0) + { + this.tileSign.lineBeingEdited = this.editLine; + } + + TileEntityRendererDispatcher.instance.renderTileEntityAt(this.tileSign, -0.5D, -0.75D, -0.5D, 0.0F); + this.tileSign.lineBeingEdited = -1; + GL11.glPopMatrix(); + super.drawScreen(par1, par2, par3); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/inventory/GuiFurnace.java b/src/main/java/net/minecraft/client/gui/inventory/GuiFurnace.java new file mode 100644 index 0000000..6a95443 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/inventory/GuiFurnace.java @@ -0,0 +1,50 @@ +package net.minecraft.client.gui.inventory; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ContainerFurnace; +import net.minecraft.tileentity.TileEntityFurnace; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class GuiFurnace extends GuiContainer +{ + private static final ResourceLocation furnaceGuiTextures = new ResourceLocation("textures/gui/container/furnace.png"); + private TileEntityFurnace tileFurnace; + private static final String __OBFID = "CL_00000758"; + + public GuiFurnace(InventoryPlayer par1InventoryPlayer, TileEntityFurnace par2TileEntityFurnace) + { + super(new ContainerFurnace(par1InventoryPlayer, par2TileEntityFurnace)); + this.tileFurnace = par2TileEntityFurnace; + } + + protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) + { + String s = this.tileFurnace.hasCustomInventoryName() ? this.tileFurnace.getInventoryName() : I18n.format(this.tileFurnace.getInventoryName(), new Object[0]); + this.fontRendererObj.drawString(s, this.xSize / 2 - this.fontRendererObj.getStringWidth(s) / 2, 6, 4210752); + this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752); + } + + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(furnaceGuiTextures); + int k = (this.width - this.xSize) / 2; + int l = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + int i1; + + if (this.tileFurnace.isBurning()) + { + i1 = this.tileFurnace.getBurnTimeRemainingScaled(12); + this.drawTexturedModalRect(k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 2); + } + + i1 = this.tileFurnace.getCookProgressScaled(24); + this.drawTexturedModalRect(k + 79, l + 34, 176, 14, i1 + 1, 16); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/inventory/GuiInventory.java b/src/main/java/net/minecraft/client/gui/inventory/GuiInventory.java new file mode 100644 index 0000000..341804a --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/inventory/GuiInventory.java @@ -0,0 +1,124 @@ +package net.minecraft.client.gui.inventory; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.achievement.GuiAchievements; +import net.minecraft.client.gui.achievement.GuiStats; +import net.minecraft.client.renderer.InventoryEffectRenderer; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +@SideOnly(Side.CLIENT) +public class GuiInventory extends InventoryEffectRenderer +{ + private float xSizeFloat; + private float ySizeFloat; + private static final String __OBFID = "CL_00000761"; + + public GuiInventory(EntityPlayer par1EntityPlayer) + { + super(par1EntityPlayer.inventoryContainer); + this.allowUserInput = true; + } + + public void updateScreen() + { + if (this.mc.playerController.isInCreativeMode()) + { + this.mc.displayGuiScreen(new GuiContainerCreative(this.mc.thePlayer)); + } + } + + public void initGui() + { + this.buttonList.clear(); + + if (this.mc.playerController.isInCreativeMode()) + { + this.mc.displayGuiScreen(new GuiContainerCreative(this.mc.thePlayer)); + } + else + { + super.initGui(); + } + } + + protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) + { + this.fontRendererObj.drawString(I18n.format("container.crafting", new Object[0]), 86, 16, 4210752); + } + + public void drawScreen(int par1, int par2, float par3) + { + super.drawScreen(par1, par2, par3); + this.xSizeFloat = (float)par1; + this.ySizeFloat = (float)par2; + } + + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(field_147001_a); + int k = this.guiLeft; + int l = this.guiTop; + this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + func_147046_a(k + 51, l + 75, 30, (float)(k + 51) - this.xSizeFloat, (float)(l + 75 - 50) - this.ySizeFloat, this.mc.thePlayer); + } + + public static void func_147046_a(int p_147046_0_, int p_147046_1_, int p_147046_2_, float p_147046_3_, float p_147046_4_, EntityLivingBase p_147046_5_) + { + GL11.glEnable(GL11.GL_COLOR_MATERIAL); + GL11.glPushMatrix(); + GL11.glTranslatef((float)p_147046_0_, (float)p_147046_1_, 50.0F); + GL11.glScalef((float)(-p_147046_2_), (float)p_147046_2_, (float)p_147046_2_); + GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); + float f2 = p_147046_5_.renderYawOffset; + float f3 = p_147046_5_.rotationYaw; + float f4 = p_147046_5_.rotationPitch; + float f5 = p_147046_5_.prevRotationYawHead; + float f6 = p_147046_5_.rotationYawHead; + GL11.glRotatef(135.0F, 0.0F, 1.0F, 0.0F); + RenderHelper.enableStandardItemLighting(); + GL11.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-((float)Math.atan((double)(p_147046_4_ / 40.0F))) * 20.0F, 1.0F, 0.0F, 0.0F); + p_147046_5_.renderYawOffset = (float)Math.atan((double)(p_147046_3_ / 40.0F)) * 20.0F; + p_147046_5_.rotationYaw = (float)Math.atan((double)(p_147046_3_ / 40.0F)) * 40.0F; + p_147046_5_.rotationPitch = -((float)Math.atan((double)(p_147046_4_ / 40.0F))) * 20.0F; + p_147046_5_.rotationYawHead = p_147046_5_.rotationYaw; + p_147046_5_.prevRotationYawHead = p_147046_5_.rotationYaw; + GL11.glTranslatef(0.0F, p_147046_5_.yOffset, 0.0F); + RenderManager.instance.playerViewY = 180.0F; + RenderManager.instance.renderEntityWithPosYaw(p_147046_5_, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F); + p_147046_5_.renderYawOffset = f2; + p_147046_5_.rotationYaw = f3; + p_147046_5_.rotationPitch = f4; + p_147046_5_.prevRotationYawHead = f5; + p_147046_5_.rotationYawHead = f6; + GL11.glPopMatrix(); + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); + GL11.glDisable(GL11.GL_TEXTURE_2D); + OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.id == 0) + { + this.mc.displayGuiScreen(new GuiAchievements(this, this.mc.thePlayer.getStatFileWriter())); + } + + if (p_146284_1_.id == 1) + { + this.mc.displayGuiScreen(new GuiStats(this, this.mc.thePlayer.getStatFileWriter())); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/inventory/GuiScreenHorseInventory.java b/src/main/java/net/minecraft/client/gui/inventory/GuiScreenHorseInventory.java new file mode 100644 index 0000000..821d7a4 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/inventory/GuiScreenHorseInventory.java @@ -0,0 +1,65 @@ +package net.minecraft.client.gui.inventory; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.passive.EntityHorse; +import net.minecraft.inventory.ContainerHorseInventory; +import net.minecraft.inventory.IInventory; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class GuiScreenHorseInventory extends GuiContainer +{ + private static final ResourceLocation horseGuiTextures = new ResourceLocation("textures/gui/container/horse.png"); + private IInventory field_147030_v; + private IInventory field_147029_w; + private EntityHorse field_147034_x; + private float field_147033_y; + private float field_147032_z; + private static final String __OBFID = "CL_00000760"; + + public GuiScreenHorseInventory(IInventory par1IInventory, IInventory par2IInventory, EntityHorse par3EntityHorse) + { + super(new ContainerHorseInventory(par1IInventory, par2IInventory, par3EntityHorse)); + this.field_147030_v = par1IInventory; + this.field_147029_w = par2IInventory; + this.field_147034_x = par3EntityHorse; + this.allowUserInput = false; + } + + protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) + { + this.fontRendererObj.drawString(this.field_147029_w.hasCustomInventoryName() ? this.field_147029_w.getInventoryName() : I18n.format(this.field_147029_w.getInventoryName(), new Object[0]), 8, 6, 4210752); + this.fontRendererObj.drawString(this.field_147030_v.hasCustomInventoryName() ? this.field_147030_v.getInventoryName() : I18n.format(this.field_147030_v.getInventoryName(), new Object[0]), 8, this.ySize - 96 + 2, 4210752); + } + + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(horseGuiTextures); + int k = (this.width - this.xSize) / 2; + int l = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + + if (this.field_147034_x.isChested()) + { + this.drawTexturedModalRect(k + 79, l + 17, 0, this.ySize, 90, 54); + } + + if (this.field_147034_x.func_110259_cr()) + { + this.drawTexturedModalRect(k + 7, l + 35, 0, this.ySize + 54, 18, 18); + } + + GuiInventory.func_147046_a(k + 51, l + 60, 17, (float)(k + 51) - this.field_147033_y, (float)(l + 75 - 50) - this.field_147032_z, this.field_147034_x); + } + + public void drawScreen(int par1, int par2, float par3) + { + this.field_147033_y = (float)par1; + this.field_147032_z = (float)par2; + super.drawScreen(par1, par2, par3); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/mco/GuiScreenBackup.java b/src/main/java/net/minecraft/client/gui/mco/GuiScreenBackup.java new file mode 100644 index 0000000..8f83321 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/mco/GuiScreenBackup.java @@ -0,0 +1,369 @@ +package net.minecraft.client.gui.mco; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.ClipboardOwner; +import java.awt.datatransfer.StringSelection; +import java.net.URI; +import java.text.DateFormat; +import java.util.Collections; +import java.util.Date; +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.GuiScreenConfigureWorld; +import net.minecraft.client.gui.GuiScreenConfirmation; +import net.minecraft.client.gui.GuiScreenLongRunningTask; +import net.minecraft.client.gui.GuiScreenSelectLocation; +import net.minecraft.client.gui.TaskLongRunning; +import net.minecraft.client.mco.Backup; +import net.minecraft.client.mco.ExceptionMcoService; +import net.minecraft.client.mco.McoClient; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.resources.I18n; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.Session; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.lwjgl.input.Keyboard; + +@SideOnly(Side.CLIENT) +public class GuiScreenBackup extends GuiScreen +{ + private static final AtomicInteger field_146845_a = new AtomicInteger(0); + private static final Logger logger = LogManager.getLogger(); + private final GuiScreenConfigureWorld field_146842_g; + private final long field_146846_h; + private List field_146847_i = Collections.emptyList(); + private GuiScreenBackup.SelectionList field_146844_r; + private int field_146843_s = -1; + private static final String __OBFID = "CL_00000766"; + + public GuiScreenBackup(GuiScreenConfigureWorld par1GuiScreenConfigureWorld, long par2) + { + this.field_146842_g = par1GuiScreenConfigureWorld; + this.field_146846_h = par2; + } + + public void initGui() + { + Keyboard.enableRepeatEvents(true); + this.buttonList.clear(); + this.field_146844_r = new GuiScreenBackup.SelectionList(); + (new Thread("MCO Backup Requester #" + field_146845_a.incrementAndGet()) + { + private static final String __OBFID = "CL_00000767"; + public void run() + { + Session session = GuiScreenBackup.this.mc.getSession(); + McoClient mcoclient = new McoClient(session.getSessionID(), session.getUsername(), "1.7.2", Minecraft.getMinecraft().getProxy()); + + try + { + GuiScreenBackup.this.field_146847_i = mcoclient.func_148704_d(GuiScreenBackup.this.field_146846_h).theBackupList; + } + catch (ExceptionMcoService exceptionmcoservice) + { + GuiScreenBackup.logger.error("Couldn\'t request backups", exceptionmcoservice); + } + } + }).start(); + this.func_146840_h(); + } + + private void func_146840_h() + { + this.buttonList.add(new GuiButton(2, this.width / 2 + 6, this.height - 52, 153, 20, I18n.format("mco.backup.button.download", new Object[0]))); + this.buttonList.add(new GuiButton(1, this.width / 2 - 154, this.height - 52, 153, 20, I18n.format("mco.backup.button.restore", new Object[0]))); + this.buttonList.add(new GuiButton(0, this.width / 2 - 74, this.height - 52 + 25, 153, 20, I18n.format("gui.back", new Object[0]))); + } + + public void updateScreen() + { + super.updateScreen(); + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.enabled) + { + if (p_146284_1_.id == 1) + { + this.func_146827_i(); + } + else if (p_146284_1_.id == 0) + { + this.mc.displayGuiScreen(this.field_146842_g); + } + else if (p_146284_1_.id == 2) + { + this.func_146826_p(); + } + else + { + this.field_146844_r.func_148357_a(p_146284_1_); + } + } + } + + private void func_146827_i() + { + if (this.field_146843_s >= 0 && this.field_146843_s < this.field_146847_i.size()) + { + Date date = ((Backup)this.field_146847_i.get(this.field_146843_s)).field_148778_b; + String s = DateFormat.getDateTimeInstance(3, 3).format(date); + String s1 = this.func_146829_a(Long.valueOf(System.currentTimeMillis() - date.getTime())); + String s2 = I18n.format("mco.configure.world.restore.question.line1", new Object[0]) + " \'" + s + "\' (" + s1 + ")"; + String s3 = I18n.format("mco.configure.world.restore.question.line2", new Object[0]); + this.mc.displayGuiScreen(new GuiScreenConfirmation(this, GuiScreenConfirmation.ConfirmationType.Warning, s2, s3, 1)); + } + } + + private void func_146826_p() + { + String s = I18n.format("mco.configure.world.restore.download.question.line1", new Object[0]); + String s1 = I18n.format("mco.configure.world.restore.download.question.line2", new Object[0]); + this.mc.displayGuiScreen(new GuiScreenConfirmation(this, GuiScreenConfirmation.ConfirmationType.Info, s, s1, 2)); + } + + private void func_146821_q() + { + Session session = this.mc.getSession(); + McoClient mcoclient = new McoClient(session.getSessionID(), session.getUsername(), "1.7.2", Minecraft.getMinecraft().getProxy()); + + try + { + String s = mcoclient.func_148708_h(this.field_146846_h); + Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + clipboard.setContents(new StringSelection(s), (ClipboardOwner)null); + this.func_146823_a(s); + } + catch (ExceptionMcoService exceptionmcoservice) + { + logger.error("Couldn\'t download world data"); + } + } + + private void func_146823_a(String p_146823_1_) + { + try + { + URI uri = new URI(p_146823_1_); + Class oclass = Class.forName("java.awt.Desktop"); + Object object = oclass.getMethod("getDesktop", new Class[0]).invoke((Object)null, new Object[0]); + oclass.getMethod("browse", new Class[] {URI.class}).invoke(object, new Object[] {uri}); + } + catch (Throwable throwable) + { + logger.error("Couldn\'t open link"); + } + } + + public void confirmClicked(boolean par1, int par2) + { + if (par1 && par2 == 1) + { + this.func_146839_r(); + } + else if (par1 && par2 == 2) + { + this.func_146821_q(); + } + else + { + this.mc.displayGuiScreen(this); + } + } + + private void func_146839_r() + { + Backup backup = (Backup)this.field_146847_i.get(this.field_146843_s); + GuiScreenBackup.RestoreTask restoretask = new GuiScreenBackup.RestoreTask(backup, null); + GuiScreenLongRunningTask guiscreenlongrunningtask = new GuiScreenLongRunningTask(this.mc, this.field_146842_g, restoretask); + guiscreenlongrunningtask.func_146902_g(); + this.mc.displayGuiScreen(guiscreenlongrunningtask); + } + + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + this.field_146844_r.func_148350_a(par1, par2, par3); + this.drawCenteredString(this.fontRendererObj, I18n.format("mco.backup.title", new Object[0]), this.width / 2, 20, 16777215); + super.drawScreen(par1, par2, par3); + } + + private String func_146829_a(Long p_146829_1_) + { + if (p_146829_1_.longValue() < 0L) + { + return "right now"; + } + else + { + long i = p_146829_1_.longValue() / 1000L; + + if (i < 60L) + { + return (i == 1L ? "1 second" : i + " seconds") + " ago"; + } + else + { + long j; + + if (i < 3600L) + { + j = i / 60L; + return (j == 1L ? "1 minute" : j + " minutes") + " ago"; + } + else if (i < 86400L) + { + j = i / 3600L; + return (j == 1L ? "1 hour" : j + " hours") + " ago"; + } + else + { + j = i / 86400L; + return (j == 1L ? "1 day" : j + " days") + " ago"; + } + } + } + } + + @SideOnly(Side.CLIENT) + class RestoreTask extends TaskLongRunning + { + private final Backup field_148424_c; + private static final String __OBFID = "CL_00000769"; + + private RestoreTask(Backup par2Backup) + { + this.field_148424_c = par2Backup; + } + + public void run() + { + this.func_148417_b(I18n.format("mco.backup.restoring", new Object[0])); + + try + { + if (this.func_148418_c()) + { + return; + } + + Session session = GuiScreenBackup.this.mc.getSession(); + McoClient mcoclient = new McoClient(session.getSessionID(), session.getUsername(), "1.7.2", Minecraft.getMinecraft().getProxy()); + mcoclient.func_148712_c(GuiScreenBackup.this.field_146846_h, this.field_148424_c.field_148780_a); + + try + { + Thread.sleep(1000L); + } + catch (InterruptedException interruptedexception) + { + Thread.currentThread().interrupt(); + } + + if (this.func_148418_c()) + { + return; + } + + this.func_148413_b().displayGuiScreen(GuiScreenBackup.this.field_146842_g); + } + catch (ExceptionMcoService exceptionmcoservice) + { + if (this.func_148418_c()) + { + return; + } + + GuiScreenBackup.logger.error("Couldn\'t restore backup"); + this.func_148416_a(exceptionmcoservice.toString()); + } + catch (Exception exception) + { + if (this.func_148418_c()) + { + return; + } + + GuiScreenBackup.logger.error("Couldn\'t restore backup"); + this.func_148416_a(exception.getLocalizedMessage()); + } + } + + RestoreTask(Backup par2Backup, Object par3GuiScreenBackupDownloadThread) + { + this(par2Backup); + } + } + + @SideOnly(Side.CLIENT) + class SelectionList extends GuiScreenSelectLocation + { + private static final String __OBFID = "CL_00000768"; + + public SelectionList() + { + super(GuiScreenBackup.this.mc, GuiScreenBackup.this.width, GuiScreenBackup.this.height, 32, GuiScreenBackup.this.height - 64, 36); + } + + protected int func_148355_a() + { + return GuiScreenBackup.this.field_146847_i.size() + 1; + } + + protected void func_148352_a(int p_148352_1_, boolean p_148352_2_) + { + if (p_148352_1_ < GuiScreenBackup.this.field_146847_i.size()) + { + GuiScreenBackup.this.field_146843_s = p_148352_1_; + } + } + + protected boolean func_148356_a(int p_148356_1_) + { + return p_148356_1_ == GuiScreenBackup.this.field_146843_s; + } + + protected boolean func_148349_b(int p_148349_1_) + { + return false; + } + + protected int func_148351_b() + { + return this.func_148355_a() * 36; + } + + protected void func_148358_c() + { + GuiScreenBackup.this.drawDefaultBackground(); + } + + protected void func_148348_a(int p_148348_1_, int p_148348_2_, int p_148348_3_, int p_148348_4_, Tessellator p_148348_5_) + { + if (p_148348_1_ < GuiScreenBackup.this.field_146847_i.size()) + { + this.func_148385_b(p_148348_1_, p_148348_2_, p_148348_3_, p_148348_4_, p_148348_5_); + } + } + + private void func_148385_b(int p_148385_1_, int p_148385_2_, int p_148385_3_, int p_148385_4_, Tessellator p_148385_5_) + { + Backup backup = (Backup)GuiScreenBackup.this.field_146847_i.get(p_148385_1_); + GuiScreenBackup.this.drawString(GuiScreenBackup.this.fontRendererObj, "Backup (" + GuiScreenBackup.this.func_146829_a(Long.valueOf(MinecraftServer.getSystemTimeMillis() - backup.field_148778_b.getTime())) + ")", p_148385_2_ + 2, p_148385_3_ + 1, 16777215); + GuiScreenBackup.this.drawString(GuiScreenBackup.this.fontRendererObj, this.func_148384_a(backup.field_148778_b), p_148385_2_ + 2, p_148385_3_ + 12, 7105644); + } + + private String func_148384_a(Date p_148384_1_) + { + return DateFormat.getDateTimeInstance(3, 3).format(p_148384_1_); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/mco/GuiScreenCreateOnlineWorld.java b/src/main/java/net/minecraft/client/gui/mco/GuiScreenCreateOnlineWorld.java new file mode 100644 index 0000000..179955d --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/mco/GuiScreenCreateOnlineWorld.java @@ -0,0 +1,217 @@ +package net.minecraft.client.gui.mco; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.util.ArrayList; +import java.util.Collections; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.GuiScreenLongRunningTask; +import net.minecraft.client.gui.GuiTextField; +import net.minecraft.client.gui.TaskLongRunning; +import net.minecraft.client.mco.ExceptionMcoService; +import net.minecraft.client.mco.McoClient; +import net.minecraft.client.mco.WorldTemplate; +import net.minecraft.client.resources.I18n; +import net.minecraft.util.Session; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.lwjgl.input.Keyboard; + +@SideOnly(Side.CLIENT) +public class GuiScreenCreateOnlineWorld extends ScreenWithCallback +{ + private static final Logger logger = LogManager.getLogger(); + private GuiScreen field_146758_f; + private GuiTextField field_146760_g; + private String field_146766_h; + private static int field_146767_i = 0; + private static int field_146764_r = 1; + private static int field_146763_s = 2; + private boolean field_146762_t; + private String field_146761_u = "You must enter a name!"; + private WorldTemplate field_146759_v; + private static final String __OBFID = "CL_00000776"; + + public GuiScreenCreateOnlineWorld(GuiScreen par1GuiScreen) + { + super.buttonList = Collections.synchronizedList(new ArrayList()); + this.field_146758_f = par1GuiScreen; + } + + public void updateScreen() + { + this.field_146760_g.updateCursorCounter(); + this.field_146766_h = this.field_146760_g.getText(); + } + + public void initGui() + { + Keyboard.enableRepeatEvents(true); + this.buttonList.clear(); + this.buttonList.add(new GuiButton(field_146767_i, this.width / 2 - 100, this.height / 4 + 120 + 17, 97, 20, I18n.format("mco.create.world", new Object[0]))); + this.buttonList.add(new GuiButton(field_146764_r, this.width / 2 + 5, this.height / 4 + 120 + 17, 95, 20, I18n.format("gui.cancel", new Object[0]))); + this.field_146760_g = new GuiTextField(this.fontRendererObj, this.width / 2 - 100, 65, 200, 20); + this.field_146760_g.setFocused(true); + + if (this.field_146766_h != null) + { + this.field_146760_g.setText(this.field_146766_h); + } + + if (this.field_146759_v == null) + { + this.buttonList.add(new GuiButton(field_146763_s, this.width / 2 - 100, 107, 200, 20, I18n.format("mco.template.default.name", new Object[0]))); + } + else + { + this.buttonList.add(new GuiButton(field_146763_s, this.width / 2 - 100, 107, 200, 20, I18n.format("mco.template.name", new Object[0]) + ": " + this.field_146759_v.field_148785_b)); + } + } + + public void onGuiClosed() + { + Keyboard.enableRepeatEvents(false); + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.enabled) + { + if (p_146284_1_.id == field_146764_r) + { + this.mc.displayGuiScreen(this.field_146758_f); + } + else if (p_146284_1_.id == field_146767_i) + { + this.func_146757_h(); + } + else if (p_146284_1_.id == field_146763_s) + { + this.mc.displayGuiScreen(new GuiScreenMcoWorldTemplate(this, this.field_146759_v)); + } + } + } + + private void func_146757_h() + { + if (this.func_146753_i()) + { + GuiScreenCreateOnlineWorld.TaskWorldCreation taskworldcreation = new GuiScreenCreateOnlineWorld.TaskWorldCreation(this.field_146760_g.getText(), this.field_146759_v); + GuiScreenLongRunningTask guiscreenlongrunningtask = new GuiScreenLongRunningTask(this.mc, this.field_146758_f, taskworldcreation); + guiscreenlongrunningtask.func_146902_g(); + this.mc.displayGuiScreen(guiscreenlongrunningtask); + } + } + + private boolean func_146753_i() + { + this.field_146762_t = this.field_146760_g.getText() == null || this.field_146760_g.getText().trim().equals(""); + return !this.field_146762_t; + } + + protected void keyTyped(char par1, int par2) + { + this.field_146760_g.textboxKeyTyped(par1, par2); + + if (par2 == 15) + { + this.field_146760_g.setFocused(!this.field_146760_g.isFocused()); + } + + if (par2 == 28 || par2 == 156) + { + this.actionPerformed((GuiButton)this.buttonList.get(0)); + } + } + + protected void mouseClicked(int par1, int par2, int par3) + { + super.mouseClicked(par1, par2, par3); + this.field_146760_g.mouseClicked(par1, par2, par3); + } + + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + this.drawCenteredString(this.fontRendererObj, I18n.format("mco.selectServer.create", new Object[0]), this.width / 2, 11, 16777215); + this.drawString(this.fontRendererObj, I18n.format("mco.configure.world.name", new Object[0]), this.width / 2 - 100, 52, 10526880); + + if (this.field_146762_t) + { + this.drawCenteredString(this.fontRendererObj, this.field_146761_u, this.width / 2, 167, 16711680); + } + + this.field_146760_g.drawTextBox(); + super.drawScreen(par1, par2, par3); + } + + public void func_146735_a(WorldTemplate p_146756_1_) + { + this.field_146759_v = p_146756_1_; + } + + public void func_146735_a(Object p_146735_1_) + { + this.func_146735_a((WorldTemplate)p_146735_1_); + } + + @SideOnly(Side.CLIENT) + class TaskWorldCreation extends TaskLongRunning + { + private final String field_148427_c; + private final WorldTemplate field_148426_d; + private static final String __OBFID = "CL_00000777"; + + public TaskWorldCreation(String p_i45036_2_, WorldTemplate p_i45036_3_) + { + this.field_148427_c = p_i45036_2_; + this.field_148426_d = p_i45036_3_; + } + + public void run() + { + String s = I18n.format("mco.create.world.wait", new Object[0]); + this.func_148417_b(s); + Session session = GuiScreenCreateOnlineWorld.this.mc.getSession(); + McoClient mcoclient = new McoClient(session.getSessionID(), session.getUsername(), "1.7.2", Minecraft.getMinecraft().getProxy()); + + try + { + if (this.field_148426_d != null) + { + mcoclient.func_148707_a(this.field_148427_c, this.field_148426_d.field_148787_a); + } + else + { + mcoclient.func_148707_a(this.field_148427_c, "-1"); + } + + GuiScreenCreateOnlineWorld.this.mc.displayGuiScreen(GuiScreenCreateOnlineWorld.this.field_146758_f); + } + catch (ExceptionMcoService exceptionmcoservice) + { + GuiScreenCreateOnlineWorld.logger.error("Couldn\'t create world"); + this.func_148416_a(exceptionmcoservice.toString()); + } + catch (UnsupportedEncodingException unsupportedencodingexception) + { + GuiScreenCreateOnlineWorld.logger.error("Couldn\'t create world"); + this.func_148416_a(unsupportedencodingexception.getLocalizedMessage()); + } + catch (@SuppressWarnings("hiding") IOException ioexception) + { + GuiScreenCreateOnlineWorld.logger.error("Could not parse response creating world"); + this.func_148416_a(ioexception.getLocalizedMessage()); + } + catch (Exception exception) + { + GuiScreenCreateOnlineWorld.logger.error("Could not create world"); + this.func_148416_a(exception.getLocalizedMessage()); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/mco/GuiScreenMcoWorldTemplate.java b/src/main/java/net/minecraft/client/gui/mco/GuiScreenMcoWorldTemplate.java new file mode 100644 index 0000000..a7894e8 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/mco/GuiScreenMcoWorldTemplate.java @@ -0,0 +1,175 @@ +package net.minecraft.client.gui.mco; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.GuiScreenSelectLocation; +import net.minecraft.client.mco.ExceptionMcoService; +import net.minecraft.client.mco.McoClient; +import net.minecraft.client.mco.WorldTemplate; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.resources.I18n; +import net.minecraft.util.Session; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.lwjgl.input.Keyboard; + +@SideOnly(Side.CLIENT) +public class GuiScreenMcoWorldTemplate extends GuiScreen +{ + private static final AtomicInteger field_146958_a = new AtomicInteger(0); + private static final Logger logger = LogManager.getLogger(); + private final ScreenWithCallback field_146954_g; + private WorldTemplate field_146959_h; + private List field_146960_i = Collections.emptyList(); + private GuiScreenMcoWorldTemplate.SelectionList field_146957_r; + private int field_146956_s = -1; + private GuiButton field_146955_t; + private static final String __OBFID = "CL_00000786"; + + public GuiScreenMcoWorldTemplate(ScreenWithCallback par1ScreenWithCallback, WorldTemplate par2WorldTemplate) + { + this.field_146954_g = par1ScreenWithCallback; + this.field_146959_h = par2WorldTemplate; + } + + public void initGui() + { + Keyboard.enableRepeatEvents(true); + this.buttonList.clear(); + this.field_146957_r = new GuiScreenMcoWorldTemplate.SelectionList(); + (new Thread("MCO World Creator #" + field_146958_a.incrementAndGet()) + { + private static final String __OBFID = "CL_00000787"; + public void run() + { + Session session = GuiScreenMcoWorldTemplate.this.mc.getSession(); + McoClient mcoclient = new McoClient(session.getSessionID(), session.getUsername(), "1.7.2", Minecraft.getMinecraft().getProxy()); + + try + { + GuiScreenMcoWorldTemplate.this.field_146960_i = mcoclient.func_148693_e().field_148782_a; + } + catch (ExceptionMcoService exceptionmcoservice) + { + GuiScreenMcoWorldTemplate.logger.error("Couldn\'t fetch templates"); + } + } + }).start(); + this.func_146952_h(); + } + + private void func_146952_h() + { + this.buttonList.add(new GuiButton(0, this.width / 2 + 6, this.height - 52, 153, 20, I18n.format("gui.cancel", new Object[0]))); + this.buttonList.add(this.field_146955_t = new GuiButton(1, this.width / 2 - 154, this.height - 52, 153, 20, I18n.format("mco.template.button.select", new Object[0]))); + } + + public void updateScreen() + { + super.updateScreen(); + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.enabled) + { + if (p_146284_1_.id == 1) + { + this.func_146947_i(); + } + else if (p_146284_1_.id == 0) + { + this.field_146954_g.func_146735_a((Object)null); + this.mc.displayGuiScreen(this.field_146954_g); + } + else + { + this.field_146957_r.func_148357_a(p_146284_1_); + } + } + } + + private void func_146947_i() + { + if (this.field_146956_s >= 0 && this.field_146956_s < this.field_146960_i.size()) + { + this.field_146954_g.func_146735_a(this.field_146960_i.get(this.field_146956_s)); + this.mc.displayGuiScreen(this.field_146954_g); + } + } + + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + this.field_146957_r.func_148350_a(par1, par2, par3); + this.drawCenteredString(this.fontRendererObj, I18n.format("mco.template.title", new Object[0]), this.width / 2, 20, 16777215); + super.drawScreen(par1, par2, par3); + } + + @SideOnly(Side.CLIENT) + class SelectionList extends GuiScreenSelectLocation + { + private static final String __OBFID = "CL_00000788"; + + public SelectionList() + { + super(GuiScreenMcoWorldTemplate.this.mc, GuiScreenMcoWorldTemplate.this.width, GuiScreenMcoWorldTemplate.this.height, 32, GuiScreenMcoWorldTemplate.this.height - 64, 36); + } + + protected int func_148355_a() + { + return GuiScreenMcoWorldTemplate.this.field_146960_i.size() + 1; + } + + protected void func_148352_a(int p_148352_1_, boolean p_148352_2_) + { + if (p_148352_1_ < GuiScreenMcoWorldTemplate.this.field_146960_i.size()) + { + GuiScreenMcoWorldTemplate.this.field_146956_s = p_148352_1_; + GuiScreenMcoWorldTemplate.this.field_146959_h = null; + } + } + + protected boolean func_148356_a(int p_148356_1_) + { + return GuiScreenMcoWorldTemplate.this.field_146960_i.size() == 0 ? false : (p_148356_1_ >= GuiScreenMcoWorldTemplate.this.field_146960_i.size() ? false : (GuiScreenMcoWorldTemplate.this.field_146959_h != null ? GuiScreenMcoWorldTemplate.this.field_146959_h.field_148785_b.equals(((WorldTemplate)GuiScreenMcoWorldTemplate.this.field_146960_i.get(p_148356_1_)).field_148785_b) : p_148356_1_ == GuiScreenMcoWorldTemplate.this.field_146956_s)); + } + + protected boolean func_148349_b(int p_148349_1_) + { + return false; + } + + protected int func_148351_b() + { + return this.func_148355_a() * 36; + } + + protected void func_148358_c() + { + GuiScreenMcoWorldTemplate.this.drawDefaultBackground(); + } + + protected void func_148348_a(int p_148348_1_, int p_148348_2_, int p_148348_3_, int p_148348_4_, Tessellator p_148348_5_) + { + if (p_148348_1_ < GuiScreenMcoWorldTemplate.this.field_146960_i.size()) + { + this.func_148387_b(p_148348_1_, p_148348_2_, p_148348_3_, p_148348_4_, p_148348_5_); + } + } + + private void func_148387_b(int p_148387_1_, int p_148387_2_, int p_148387_3_, int p_148387_4_, Tessellator p_148387_5_) + { + WorldTemplate worldtemplate = (WorldTemplate)GuiScreenMcoWorldTemplate.this.field_146960_i.get(p_148387_1_); + GuiScreenMcoWorldTemplate.this.drawString(GuiScreenMcoWorldTemplate.this.fontRendererObj, worldtemplate.field_148785_b, p_148387_2_ + 2, p_148387_3_ + 1, 16777215); + GuiScreenMcoWorldTemplate.this.drawString(GuiScreenMcoWorldTemplate.this.fontRendererObj, worldtemplate.field_148784_d, p_148387_2_ + 2, p_148387_3_ + 12, 7105644); + GuiScreenMcoWorldTemplate.this.drawString(GuiScreenMcoWorldTemplate.this.fontRendererObj, worldtemplate.field_148786_c, p_148387_2_ + 2 + 207 - GuiScreenMcoWorldTemplate.this.fontRendererObj.getStringWidth(worldtemplate.field_148786_c), p_148387_3_ + 1, 5000268); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/mco/GuiScreenPendingInvitation.java b/src/main/java/net/minecraft/client/gui/mco/GuiScreenPendingInvitation.java new file mode 100644 index 0000000..5957ac1 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/mco/GuiScreenPendingInvitation.java @@ -0,0 +1,232 @@ +package net.minecraft.client.gui.mco; + +import com.google.common.collect.Lists; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.concurrent.atomic.AtomicInteger; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.GuiScreenOnlineServers; +import net.minecraft.client.gui.GuiScreenSelectLocation; +import net.minecraft.client.mco.ExceptionMcoService; +import net.minecraft.client.mco.McoClient; +import net.minecraft.client.mco.PendingInvite; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.resources.I18n; +import net.minecraft.util.Session; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.lwjgl.input.Keyboard; + +@SideOnly(Side.CLIENT) +public class GuiScreenPendingInvitation extends GuiScreen +{ + private static final AtomicInteger field_146732_a = new AtomicInteger(0); + private static final Logger logger = LogManager.getLogger(); + private final GuiScreen field_146730_g; + private GuiScreenPendingInvitation.List field_146733_h; + private java.util.List field_146734_i = Lists.newArrayList(); + private int field_146731_r = -1; + private static final String __OBFID = "CL_00000797"; + + public GuiScreenPendingInvitation(GuiScreen par1GuiScreen) + { + this.field_146730_g = par1GuiScreen; + } + + public void initGui() + { + Keyboard.enableRepeatEvents(true); + this.buttonList.clear(); + this.field_146733_h = new GuiScreenPendingInvitation.List(); + (new Thread("MCO List Invites #" + field_146732_a.incrementAndGet()) + { + private static final String __OBFID = "CL_00000798"; + public void run() + { + Session session = GuiScreenPendingInvitation.this.mc.getSession(); + McoClient mcoclient = new McoClient(session.getSessionID(), session.getUsername(), "1.7.2", Minecraft.getMinecraft().getProxy()); + + try + { + GuiScreenPendingInvitation.this.field_146734_i = mcoclient.func_148710_g().field_148768_a; + } + catch (ExceptionMcoService exceptionmcoservice) + { + GuiScreenPendingInvitation.logger.error("Couldn\'t list invites"); + } + } + }).start(); + this.func_146728_h(); + } + + private void func_146728_h() + { + this.buttonList.add(new GuiButton(1, this.width / 2 - 154, this.height - 52, 153, 20, I18n.format("mco.invites.button.accept", new Object[0]))); + this.buttonList.add(new GuiButton(2, this.width / 2 + 6, this.height - 52, 153, 20, I18n.format("mco.invites.button.reject", new Object[0]))); + this.buttonList.add(new GuiButton(0, this.width / 2 - 75, this.height - 28, 153, 20, I18n.format("gui.back", new Object[0]))); + } + + public void updateScreen() + { + super.updateScreen(); + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.enabled) + { + if (p_146284_1_.id == 1) + { + this.func_146723_p(); + } + else if (p_146284_1_.id == 0) + { + this.mc.displayGuiScreen(new GuiScreenOnlineServers(this.field_146730_g)); + } + else if (p_146284_1_.id == 2) + { + this.func_146724_i(); + } + else + { + this.field_146733_h.func_148357_a(p_146284_1_); + } + } + } + + private void func_146724_i() + { + if (this.field_146731_r >= 0 && this.field_146731_r < this.field_146734_i.size()) + { + (new Thread("MCO Reject Invite #" + field_146732_a.incrementAndGet()) + { + private static final String __OBFID = "CL_00000800"; + public void run() + { + try + { + Session session = GuiScreenPendingInvitation.this.mc.getSession(); + McoClient mcoclient = new McoClient(session.getSessionID(), session.getUsername(), "1.7.2", Minecraft.getMinecraft().getProxy()); + mcoclient.func_148706_b(((PendingInvite)GuiScreenPendingInvitation.this.field_146734_i.get(GuiScreenPendingInvitation.this.field_146731_r)).field_148776_a); + GuiScreenPendingInvitation.this.func_146718_q(); + } + catch (ExceptionMcoService exceptionmcoservice) + { + GuiScreenPendingInvitation.logger.error("Couldn\'t reject invite"); + } + } + }).start(); + } + } + + private void func_146723_p() + { + if (this.field_146731_r >= 0 && this.field_146731_r < this.field_146734_i.size()) + { + (new Thread("MCO Accept Invite #" + field_146732_a.incrementAndGet()) + { + private static final String __OBFID = "CL_00000801"; + public void run() + { + try + { + Session session = GuiScreenPendingInvitation.this.mc.getSession(); + McoClient mcoclient = new McoClient(session.getSessionID(), session.getUsername(), "1.7.2", Minecraft.getMinecraft().getProxy()); + mcoclient.func_148691_a(((PendingInvite)GuiScreenPendingInvitation.this.field_146734_i.get(GuiScreenPendingInvitation.this.field_146731_r)).field_148776_a); + GuiScreenPendingInvitation.this.func_146718_q(); + } + catch (ExceptionMcoService exceptionmcoservice) + { + GuiScreenPendingInvitation.logger.error("Couldn\'t accept invite"); + } + } + }).start(); + } + } + + private void func_146718_q() + { + int i = this.field_146731_r; + + if (this.field_146734_i.size() - 1 == this.field_146731_r) + { + --this.field_146731_r; + } + + this.field_146734_i.remove(i); + + if (this.field_146734_i.size() == 0) + { + this.field_146731_r = -1; + } + } + + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + this.field_146733_h.func_148350_a(par1, par2, par3); + this.drawCenteredString(this.fontRendererObj, I18n.format("mco.invites.title", new Object[0]), this.width / 2, 20, 16777215); + super.drawScreen(par1, par2, par3); + } + + @SideOnly(Side.CLIENT) + class List extends GuiScreenSelectLocation + { + private static final String __OBFID = "CL_00000802"; + + public List() + { + super(GuiScreenPendingInvitation.this.mc, GuiScreenPendingInvitation.this.width, GuiScreenPendingInvitation.this.height, 32, GuiScreenPendingInvitation.this.height - 64, 36); + } + + protected int func_148355_a() + { + return GuiScreenPendingInvitation.this.field_146734_i.size() + 1; + } + + protected void func_148352_a(int p_148352_1_, boolean p_148352_2_) + { + if (p_148352_1_ < GuiScreenPendingInvitation.this.field_146734_i.size()) + { + GuiScreenPendingInvitation.this.field_146731_r = p_148352_1_; + } + } + + protected boolean func_148356_a(int p_148356_1_) + { + return p_148356_1_ == GuiScreenPendingInvitation.this.field_146731_r; + } + + protected boolean func_148349_b(int p_148349_1_) + { + return false; + } + + protected int func_148351_b() + { + return this.func_148355_a() * 36; + } + + protected void func_148358_c() + { + GuiScreenPendingInvitation.this.drawDefaultBackground(); + } + + protected void func_148348_a(int p_148348_1_, int p_148348_2_, int p_148348_3_, int p_148348_4_, Tessellator p_148348_5_) + { + if (p_148348_1_ < GuiScreenPendingInvitation.this.field_146734_i.size()) + { + this.func_148382_b(p_148348_1_, p_148348_2_, p_148348_3_, p_148348_4_, p_148348_5_); + } + } + + private void func_148382_b(int p_148382_1_, int p_148382_2_, int p_148382_3_, int p_148382_4_, Tessellator p_148382_5_) + { + PendingInvite pendinginvite = (PendingInvite)GuiScreenPendingInvitation.this.field_146734_i.get(p_148382_1_); + GuiScreenPendingInvitation.this.drawString(GuiScreenPendingInvitation.this.fontRendererObj, pendinginvite.field_148774_b, p_148382_2_ + 2, p_148382_3_ + 1, 16777215); + GuiScreenPendingInvitation.this.drawString(GuiScreenPendingInvitation.this.fontRendererObj, pendinginvite.field_148775_c, p_148382_2_ + 2, p_148382_3_ + 12, 7105644); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/mco/GuiScreenResetWorld.java b/src/main/java/net/minecraft/client/gui/mco/GuiScreenResetWorld.java new file mode 100644 index 0000000..767b543 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/mco/GuiScreenResetWorld.java @@ -0,0 +1,220 @@ +package net.minecraft.client.gui.mco; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.GuiScreenConfirmation; +import net.minecraft.client.gui.GuiScreenLongRunningTask; +import net.minecraft.client.gui.GuiTextField; +import net.minecraft.client.gui.TaskLongRunning; +import net.minecraft.client.mco.ExceptionMcoService; +import net.minecraft.client.mco.McoClient; +import net.minecraft.client.mco.McoServer; +import net.minecraft.client.mco.WorldTemplate; +import net.minecraft.client.resources.I18n; +import net.minecraft.util.Session; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.lwjgl.input.Keyboard; + +@SideOnly(Side.CLIENT) +public class GuiScreenResetWorld extends ScreenWithCallback +{ + private static final Logger logger = LogManager.getLogger(); + private GuiScreen field_146742_f; + private McoServer field_146743_g; + private GuiTextField field_146749_h; + private final int field_146750_i = 1; + private final int field_146747_r = 2; + private static int field_146746_s = 3; + private WorldTemplate field_146745_t; + private GuiButton field_146744_u; + private static final String __OBFID = "CL_00000810"; + + public GuiScreenResetWorld(GuiScreen par1GuiScreen, McoServer par2McoServer) + { + this.field_146742_f = par1GuiScreen; + this.field_146743_g = par2McoServer; + } + + public void updateScreen() + { + this.field_146749_h.updateCursorCounter(); + } + + public void initGui() + { + Keyboard.enableRepeatEvents(true); + this.buttonList.clear(); + this.buttonList.add(this.field_146744_u = new GuiButton(1, this.width / 2 - 100, this.height / 4 + 120 + 12, 97, 20, I18n.format("mco.configure.world.buttons.reset", new Object[0]))); + this.buttonList.add(new GuiButton(2, this.width / 2 + 5, this.height / 4 + 120 + 12, 97, 20, I18n.format("gui.cancel", new Object[0]))); + this.field_146749_h = new GuiTextField(this.fontRendererObj, this.width / 2 - 100, 99, 200, 20); + this.field_146749_h.setFocused(true); + this.field_146749_h.setMaxStringLength(32); + this.field_146749_h.setText(""); + + if (this.field_146745_t == null) + { + this.buttonList.add(new GuiButton(field_146746_s, this.width / 2 - 100, 125, 200, 20, I18n.format("mco.template.default.name", new Object[0]))); + } + else + { + this.field_146749_h.setText(""); + this.field_146749_h.setEnabled(false); + this.field_146749_h.setFocused(false); + this.buttonList.add(new GuiButton(field_146746_s, this.width / 2 - 100, 125, 200, 20, I18n.format("mco.template.name", new Object[0]) + ": " + this.field_146745_t.field_148785_b)); + } + } + + public void onGuiClosed() + { + Keyboard.enableRepeatEvents(false); + } + + protected void keyTyped(char par1, int par2) + { + this.field_146749_h.textboxKeyTyped(par1, par2); + + if (par2 == 28 || par2 == 156) + { + this.actionPerformed(this.field_146744_u); + } + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.enabled) + { + if (p_146284_1_.id == 2) + { + this.mc.displayGuiScreen(this.field_146742_f); + } + else if (p_146284_1_.id == 1) + { + String s = I18n.format("mco.configure.world.reset.question.line1", new Object[0]); + String s1 = I18n.format("mco.configure.world.reset.question.line2", new Object[0]); + this.mc.displayGuiScreen(new GuiScreenConfirmation(this, GuiScreenConfirmation.ConfirmationType.Warning, s, s1, 1)); + } + else if (p_146284_1_.id == field_146746_s) + { + this.mc.displayGuiScreen(new GuiScreenMcoWorldTemplate(this, this.field_146745_t)); + } + } + } + + public void confirmClicked(boolean par1, int par2) + { + if (par1 && par2 == 1) + { + this.func_146741_h(); + } + else + { + this.mc.displayGuiScreen(this); + } + } + + private void func_146741_h() + { + GuiScreenResetWorld.ResetWorldTask resetworldtask = new GuiScreenResetWorld.ResetWorldTask(this.field_146743_g.field_148812_a, this.field_146749_h.getText(), this.field_146745_t); + GuiScreenLongRunningTask guiscreenlongrunningtask = new GuiScreenLongRunningTask(this.mc, this.field_146742_f, resetworldtask); + guiscreenlongrunningtask.func_146902_g(); + this.mc.displayGuiScreen(guiscreenlongrunningtask); + } + + protected void mouseClicked(int par1, int par2, int par3) + { + super.mouseClicked(par1, par2, par3); + this.field_146749_h.mouseClicked(par1, par2, par3); + } + + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + this.drawCenteredString(this.fontRendererObj, I18n.format("mco.reset.world.title", new Object[0]), this.width / 2, 17, 16777215); + this.drawCenteredString(this.fontRendererObj, I18n.format("mco.reset.world.warning", new Object[0]), this.width / 2, 56, 16711680); + this.drawString(this.fontRendererObj, I18n.format("mco.reset.world.seed", new Object[0]), this.width / 2 - 100, 86, 10526880); + this.field_146749_h.drawTextBox(); + super.drawScreen(par1, par2, par3); + } + + void func_146740_a(WorldTemplate p_146740_1_) + { + this.field_146745_t = p_146740_1_; + } + + void func_146735_a(Object p_146735_1_) + { + this.func_146740_a((WorldTemplate)p_146735_1_); + } + + @SideOnly(Side.CLIENT) + class ResetWorldTask extends TaskLongRunning + { + private final long field_148422_c; + private final String field_148420_d; + private final WorldTemplate field_148421_e; + private static final String __OBFID = "CL_00000811"; + + public ResetWorldTask(long par2, String par4Str, WorldTemplate par5WorldTemplate) + { + this.field_148422_c = par2; + this.field_148420_d = par4Str; + this.field_148421_e = par5WorldTemplate; + } + + public void run() + { + Session session = GuiScreenResetWorld.this.mc.getSession(); + McoClient mcoclient = new McoClient(session.getSessionID(), session.getUsername(), "1.7.2", Minecraft.getMinecraft().getProxy()); + String s = I18n.format("mco.reset.world.resetting.screen.title", new Object[0]); + this.func_148417_b(s); + + try + { + if (this.func_148418_c()) + { + return; + } + + if (this.field_148421_e != null) + { + mcoclient.func_148696_e(this.field_148422_c, this.field_148421_e.field_148787_a); + } + else + { + mcoclient.func_148699_d(this.field_148422_c, this.field_148420_d); + } + + if (this.func_148418_c()) + { + return; + } + + GuiScreenResetWorld.this.mc.displayGuiScreen(GuiScreenResetWorld.this.field_146742_f); + } + catch (ExceptionMcoService exceptionmcoservice) + { + if (this.func_148418_c()) + { + return; + } + + GuiScreenResetWorld.logger.error("Couldn\'t reset world"); + this.func_148416_a(exceptionmcoservice.toString()); + } + catch (Exception exception) + { + if (this.func_148418_c()) + { + return; + } + + GuiScreenResetWorld.logger.error("Couldn\'t reset world"); + this.func_148416_a(exception.toString()); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/gui/mco/ScreenWithCallback.java b/src/main/java/net/minecraft/client/gui/mco/ScreenWithCallback.java new file mode 100644 index 0000000..9f5f405 --- /dev/null +++ b/src/main/java/net/minecraft/client/gui/mco/ScreenWithCallback.java @@ -0,0 +1,13 @@ +package net.minecraft.client.gui.mco; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.gui.GuiScreen; + +@SideOnly(Side.CLIENT) +public abstract class ScreenWithCallback extends GuiScreen +{ + private static final String __OBFID = "CL_00000812"; + + abstract void func_146735_a(Object var1); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/main/Main.java b/src/main/java/net/minecraft/client/main/Main.java new file mode 100644 index 0000000..8084669 --- /dev/null +++ b/src/main/java/net/minecraft/client/main/Main.java @@ -0,0 +1,119 @@ +package net.minecraft.client.main; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.File; +import java.net.Authenticator; +import java.net.InetSocketAddress; +import java.net.PasswordAuthentication; +import java.net.Proxy; +import java.net.Proxy.Type; +import java.util.List; +import joptsimple.ArgumentAcceptingOptionSpec; +import joptsimple.NonOptionArgumentSpec; +import joptsimple.OptionParser; +import joptsimple.OptionSet; +import net.minecraft.client.Minecraft; +import net.minecraft.util.Session; + +@SideOnly(Side.CLIENT) +public class Main +{ + private static final String __OBFID = "CL_00001461"; + + public static void main(String[] par0ArrayOfStr) + { + System.setProperty("java.net.preferIPv4Stack", "true"); + OptionParser optionparser = new OptionParser(); + optionparser.allowsUnrecognizedOptions(); + optionparser.accepts("demo"); + optionparser.accepts("fullscreen"); + ArgumentAcceptingOptionSpec argumentacceptingoptionspec = optionparser.accepts("server").withRequiredArg(); + ArgumentAcceptingOptionSpec argumentacceptingoptionspec1 = optionparser.accepts("port").withRequiredArg().ofType(Integer.class).defaultsTo(Integer.valueOf(25565), new Integer[0]); + ArgumentAcceptingOptionSpec argumentacceptingoptionspec2 = optionparser.accepts("gameDir").withRequiredArg().ofType(File.class).defaultsTo(new File("."), new File[0]); + ArgumentAcceptingOptionSpec argumentacceptingoptionspec3 = optionparser.accepts("assetsDir").withRequiredArg().ofType(File.class); + ArgumentAcceptingOptionSpec argumentacceptingoptionspec4 = optionparser.accepts("resourcePackDir").withRequiredArg().ofType(File.class); + ArgumentAcceptingOptionSpec argumentacceptingoptionspec5 = optionparser.accepts("proxyHost").withRequiredArg(); + ArgumentAcceptingOptionSpec argumentacceptingoptionspec6 = optionparser.accepts("proxyPort").withRequiredArg().defaultsTo("8080", new String[0]).ofType(Integer.class); + ArgumentAcceptingOptionSpec argumentacceptingoptionspec7 = optionparser.accepts("proxyUser").withRequiredArg(); + ArgumentAcceptingOptionSpec argumentacceptingoptionspec8 = optionparser.accepts("proxyPass").withRequiredArg(); + ArgumentAcceptingOptionSpec argumentacceptingoptionspec9 = optionparser.accepts("username").withRequiredArg().defaultsTo("Player" + Minecraft.getSystemTime() % 1000L, new String[0]); + ArgumentAcceptingOptionSpec argumentacceptingoptionspec10 = optionparser.accepts("uuid").withRequiredArg(); + ArgumentAcceptingOptionSpec argumentacceptingoptionspec11 = optionparser.accepts("accessToken").withRequiredArg().required(); + ArgumentAcceptingOptionSpec argumentacceptingoptionspec12 = optionparser.accepts("version").withRequiredArg().required(); + ArgumentAcceptingOptionSpec argumentacceptingoptionspec13 = optionparser.accepts("width").withRequiredArg().ofType(Integer.class).defaultsTo(Integer.valueOf(854), new Integer[0]); + ArgumentAcceptingOptionSpec argumentacceptingoptionspec14 = optionparser.accepts("height").withRequiredArg().ofType(Integer.class).defaultsTo(Integer.valueOf(480), new Integer[0]); + NonOptionArgumentSpec nonoptionargumentspec = optionparser.nonOptions(); + OptionSet optionset = optionparser.parse(par0ArrayOfStr); + List list = optionset.valuesOf(nonoptionargumentspec); + String s = (String)optionset.valueOf(argumentacceptingoptionspec5); + Proxy proxy = Proxy.NO_PROXY; + + if (s != null) + { + try + { + proxy = new Proxy(Type.SOCKS, new InetSocketAddress(s, ((Integer)optionset.valueOf(argumentacceptingoptionspec6)).intValue())); + } + catch (Exception exception) + { + ; + } + } + + final String s1 = (String)optionset.valueOf(argumentacceptingoptionspec7); + final String s2 = (String)optionset.valueOf(argumentacceptingoptionspec8); + + if (!proxy.equals(Proxy.NO_PROXY) && func_110121_a(s1) && func_110121_a(s2)) + { + Authenticator.setDefault(new Authenticator() + { + private static final String __OBFID = "CL_00000828"; + protected PasswordAuthentication getPasswordAuthentication() + { + return new PasswordAuthentication(s1, s2.toCharArray()); + } + }); + } + + int i = ((Integer)optionset.valueOf(argumentacceptingoptionspec13)).intValue(); + int j = ((Integer)optionset.valueOf(argumentacceptingoptionspec14)).intValue(); + boolean flag = optionset.has("fullscreen"); + boolean flag1 = optionset.has("demo"); + String s3 = (String)optionset.valueOf(argumentacceptingoptionspec12); + File file1 = (File)optionset.valueOf(argumentacceptingoptionspec2); + File file2 = optionset.has(argumentacceptingoptionspec3) ? (File)optionset.valueOf(argumentacceptingoptionspec3) : new File(file1, "assets/"); + File file3 = optionset.has(argumentacceptingoptionspec4) ? (File)optionset.valueOf(argumentacceptingoptionspec4) : new File(file1, "resourcepacks/"); + String s4 = optionset.has(argumentacceptingoptionspec10) ? (String)argumentacceptingoptionspec10.value(optionset) : (String)argumentacceptingoptionspec9.value(optionset); + Session session = new Session((String)argumentacceptingoptionspec9.value(optionset), s4, (String)argumentacceptingoptionspec11.value(optionset)); + Minecraft minecraft = new Minecraft(session, i, j, flag, flag1, file1, file2, file3, proxy, s3); + String s5 = (String)optionset.valueOf(argumentacceptingoptionspec); + + if (s5 != null) + { + minecraft.setServer(s5, ((Integer)optionset.valueOf(argumentacceptingoptionspec1)).intValue()); + } + + Runtime.getRuntime().addShutdownHook(new Thread("Client Shutdown Thread") + { + private static final String __OBFID = "CL_00000829"; + public void run() + { + Minecraft.stopIntegratedServer(); + } + }); + + if (!list.isEmpty()) + { + System.out.println("Completely ignored arguments: " + list); + } + + Thread.currentThread().setName("Client thread"); + minecraft.run(); + } + + private static boolean func_110121_a(String par0Str) + { + return par0Str != null && !par0Str.isEmpty(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/mco/Backup.java b/src/main/java/net/minecraft/client/mco/Backup.java new file mode 100644 index 0000000..adf28b4 --- /dev/null +++ b/src/main/java/net/minecraft/client/mco/Backup.java @@ -0,0 +1,36 @@ +package net.minecraft.client.mco; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Date; +import net.minecraft.util.ValueObject; + +@SideOnly(Side.CLIENT) +public class Backup extends ValueObject +{ + public String field_148780_a; + public Date field_148778_b; + public long field_148779_c; + private static final String __OBFID = "CL_00001164"; + + public static Backup func_148777_a(JsonElement p_148777_0_) + { + JsonObject jsonobject = p_148777_0_.getAsJsonObject(); + Backup backup = new Backup(); + + try + { + backup.field_148780_a = jsonobject.get("backupId").getAsString(); + backup.field_148778_b = new Date(Long.parseLong(jsonobject.get("lastModifiedDate").getAsString())); + backup.field_148779_c = Long.parseLong(jsonobject.get("size").getAsString()); + } + catch (IllegalArgumentException illegalargumentexception) + { + ; + } + + return backup; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/mco/BackupList.java b/src/main/java/net/minecraft/client/mco/BackupList.java new file mode 100644 index 0000000..7b6c320 --- /dev/null +++ b/src/main/java/net/minecraft/client/mco/BackupList.java @@ -0,0 +1,50 @@ +package net.minecraft.client.mco; + +import com.google.gson.JsonElement; +import com.google.gson.JsonIOException; +import com.google.gson.JsonParser; +import com.google.gson.JsonSyntaxException; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +@SideOnly(Side.CLIENT) +public class BackupList +{ + public List theBackupList; + private static final String __OBFID = "CL_00001165"; + + public static BackupList func_148796_a(String p_148796_0_) + { + JsonParser jsonparser = new JsonParser(); + BackupList backuplist = new BackupList(); + backuplist.theBackupList = new ArrayList(); + + try + { + JsonElement jsonelement = jsonparser.parse(p_148796_0_).getAsJsonObject().get("backups"); + + if (jsonelement.isJsonArray()) + { + Iterator iterator = jsonelement.getAsJsonArray().iterator(); + + while (iterator.hasNext()) + { + backuplist.theBackupList.add(Backup.func_148777_a((JsonElement)iterator.next())); + } + } + } + catch (JsonIOException jsonioexception) + { + ; + } + catch (JsonSyntaxException jsonsyntaxexception) + { + ; + } + + return backuplist; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/mco/ExceptionMcoHttp.java b/src/main/java/net/minecraft/client/mco/ExceptionMcoHttp.java new file mode 100644 index 0000000..7059ee2 --- /dev/null +++ b/src/main/java/net/minecraft/client/mco/ExceptionMcoHttp.java @@ -0,0 +1,15 @@ +package net.minecraft.client.mco; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class ExceptionMcoHttp extends RuntimeException +{ + private static final String __OBFID = "CL_00001176"; + + public ExceptionMcoHttp(String par1Str, Exception par2Exception) + { + super(par1Str, par2Exception); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/mco/ExceptionMcoService.java b/src/main/java/net/minecraft/client/mco/ExceptionMcoService.java new file mode 100644 index 0000000..f909775 --- /dev/null +++ b/src/main/java/net/minecraft/client/mco/ExceptionMcoService.java @@ -0,0 +1,26 @@ +package net.minecraft.client.mco; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class ExceptionMcoService extends Exception +{ + public final int field_148831_a; + public final String field_148829_b; + public final int field_148830_c; + private static final String __OBFID = "CL_00001177"; + + public ExceptionMcoService(int par1, String par2Str, int par3) + { + super(par2Str); + this.field_148831_a = par1; + this.field_148829_b = par2Str; + this.field_148830_c = par3; + } + + public String toString() + { + return this.field_148830_c != -1 ? "Realms ( ErrorCode: " + this.field_148830_c + " )" : "Realms: " + this.field_148829_b; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/mco/ExceptionRetryCall.java b/src/main/java/net/minecraft/client/mco/ExceptionRetryCall.java new file mode 100644 index 0000000..8f30862 --- /dev/null +++ b/src/main/java/net/minecraft/client/mco/ExceptionRetryCall.java @@ -0,0 +1,17 @@ +package net.minecraft.client.mco; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class ExceptionRetryCall extends ExceptionMcoService +{ + public final int field_148832_d; + private static final String __OBFID = "CL_00001178"; + + public ExceptionRetryCall(int par1) + { + super(503, "Retry operation", -1); + this.field_148832_d = par1; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/mco/GuiScreenClientOutdated.java b/src/main/java/net/minecraft/client/mco/GuiScreenClientOutdated.java new file mode 100644 index 0000000..a7d9ff4 --- /dev/null +++ b/src/main/java/net/minecraft/client/mco/GuiScreenClientOutdated.java @@ -0,0 +1,51 @@ +package net.minecraft.client.mco; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.resources.I18n; + +@SideOnly(Side.CLIENT) +public class GuiScreenClientOutdated extends GuiScreen +{ + private final GuiScreen field_146901_a; + private static final String __OBFID = "CL_00000772"; + + public GuiScreenClientOutdated(GuiScreen par1GuiScreen) + { + this.field_146901_a = par1GuiScreen; + } + + public void initGui() + { + this.buttonList.clear(); + this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 120 + 12, "Back")); + } + + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + String s = I18n.format("mco.client.outdated.title", new Object[0]); + String s1 = I18n.format("mco.client.outdated.msg", new Object[0]); + this.drawCenteredString(this.fontRendererObj, s, this.width / 2, this.height / 2 - 50, 16711680); + this.drawCenteredString(this.fontRendererObj, s1, this.width / 2, this.height / 2 - 30, 16777215); + super.drawScreen(par1, par2, par3); + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.id == 0) + { + this.mc.displayGuiScreen(this.field_146901_a); + } + } + + protected void keyTyped(char par1, int par2) + { + if (par2 == 28 || par2 == 156) + { + this.mc.displayGuiScreen(this.field_146901_a); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/mco/McoClient.java b/src/main/java/net/minecraft/client/mco/McoClient.java new file mode 100644 index 0000000..6d1bc36 --- /dev/null +++ b/src/main/java/net/minecraft/client/mco/McoClient.java @@ -0,0 +1,255 @@ +package net.minecraft.client.mco; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.Proxy; +import java.net.URLEncoder; + +@SideOnly(Side.CLIENT) +public class McoClient +{ + private final String field_148719_a; + private final String field_148717_b; + private final String field_148718_c; + private final Proxy field_148715_d; + private static String field_148716_e = "https://mcoapi.minecraft.net/"; + private static final String __OBFID = "CL_00001156"; + + public McoClient(String p_i45484_1_, String p_i45484_2_, String p_i45484_3_, Proxy p_i45484_4_) + { + this.field_148719_a = p_i45484_1_; + this.field_148717_b = p_i45484_2_; + this.field_148718_c = p_i45484_3_; + this.field_148715_d = p_i45484_4_; + } + + public ValueObjectList func_148703_a() throws ExceptionMcoService, IOException + { + String s = this.func_148713_a(Request.func_148666_a(field_148716_e + "worlds")); + return ValueObjectList.func_148771_a(s); + } + + public McoServer func_148709_a(long p_148709_1_) throws ExceptionMcoService, IOException + { + String s = this.func_148713_a(Request.func_148666_a(field_148716_e + "worlds" + "/$ID".replace("$ID", String.valueOf(p_148709_1_)))); + return McoServer.func_148805_c(s); + } + + public McoServerAddress func_148688_b(long p_148688_1_) throws Exception + { + String s = field_148716_e + "worlds" + "/$ID/join".replace("$ID", "" + p_148688_1_); + String s1 = this.func_148713_a(Request.func_148670_a(s, 5000, 30000)); + return McoServerAddress.func_148769_a(s1); + } + + public void func_148707_a(String p_148707_1_, String p_148707_2_) throws ExceptionMcoService, UnsupportedEncodingException + { + StringBuilder stringbuilder = new StringBuilder(); + stringbuilder.append(field_148716_e).append("worlds"); + stringbuilder.append("?name=").append(this.func_148711_c(p_148707_1_)); + stringbuilder.append("&template=").append(p_148707_2_); + this.func_148713_a(Request.func_148661_a(stringbuilder.toString(), "", 5000, 30000)); + } + + public Boolean func_148687_b() throws ExceptionMcoService, IOException + { + String s = field_148716_e + "mco" + "/available"; + String s1 = this.func_148713_a(Request.func_148666_a(s)); + return Boolean.valueOf(s1); + } + + public Boolean func_148695_c() throws ExceptionMcoService, IOException + { + String s = field_148716_e + "mco" + "/client/outdated"; + String s1 = this.func_148713_a(Request.func_148666_a(s)); + return Boolean.valueOf(s1); + } + + public int func_148702_d() throws ExceptionMcoService + { + String s = field_148716_e + "payments" + "/unused"; + String s1 = this.func_148713_a(Request.func_148666_a(s)); + return Integer.valueOf(s1).intValue(); + } + + public void func_148694_a(long p_148694_1_, String p_148694_3_) throws ExceptionMcoService + { + String s1 = field_148716_e + "invites" + "/$WORLD_ID/invite/$USER_NAME".replace("$WORLD_ID", String.valueOf(p_148694_1_)).replace("$USER_NAME", p_148694_3_); + this.func_148713_a(Request.func_148663_b(s1)); + } + + public void func_148698_c(long p_148698_1_) throws ExceptionMcoService + { + String s = field_148716_e + "invites" + "/$WORLD_ID".replace("$WORLD_ID", String.valueOf(p_148698_1_)); + this.func_148713_a(Request.func_148663_b(s)); + } + + public McoServer func_148697_b(long p_148697_1_, String p_148697_3_) throws ExceptionMcoService, IOException + { + String s1 = field_148716_e + "invites" + "/$WORLD_ID/invite/$USER_NAME".replace("$WORLD_ID", String.valueOf(p_148697_1_)).replace("$USER_NAME", p_148697_3_); + String s2 = this.func_148713_a(Request.func_148672_c(s1, "")); + return McoServer.func_148805_c(s2); + } + + public BackupList func_148704_d(long p_148704_1_) throws ExceptionMcoService + { + String s = field_148716_e + "worlds" + "/$WORLD_ID/backups".replace("$WORLD_ID", String.valueOf(p_148704_1_)); + String s1 = this.func_148713_a(Request.func_148666_a(s)); + return BackupList.func_148796_a(s1); + } + + public void func_148689_a(long p_148689_1_, String p_148689_3_, String p_148689_4_, int p_148689_5_, int p_148689_6_) throws ExceptionMcoService, UnsupportedEncodingException + { + StringBuilder stringbuilder = new StringBuilder(); + stringbuilder.append(field_148716_e).append("worlds").append("/$WORLD_ID".replace("$WORLD_ID", String.valueOf(p_148689_1_))); + stringbuilder.append("?name=").append(this.func_148711_c(p_148689_3_)); + + if (p_148689_4_ != null && !p_148689_4_.trim().equals("")) + { + stringbuilder.append("&motd=").append(this.func_148711_c(p_148689_4_)); + } + else + { + stringbuilder.append("&motd="); + } + + stringbuilder.append("&difficulty=").append(p_148689_5_).append("&gameMode=").append(p_148689_6_); + this.func_148713_a(Request.func_148668_d(stringbuilder.toString(), "")); + } + + public void func_148712_c(long p_148712_1_, String p_148712_3_) throws ExceptionMcoService + { + String s1 = field_148716_e + "worlds" + "/$WORLD_ID/backups".replace("$WORLD_ID", String.valueOf(p_148712_1_)) + "?backupId=" + p_148712_3_; + this.func_148713_a(Request.func_148669_b(s1, "", 40000, 40000)); + } + + public WorldTemplateList func_148693_e() throws ExceptionMcoService + { + String s = field_148716_e + "worlds" + "/templates"; + String s1 = this.func_148713_a(Request.func_148666_a(s)); + return WorldTemplateList.func_148781_a(s1); + } + + public Boolean func_148692_e(long p_148692_1_) throws ExceptionMcoService, IOException + { + String s = field_148716_e + "worlds" + "/$WORLD_ID/open".replace("$WORLD_ID", String.valueOf(p_148692_1_)); + String s1 = this.func_148713_a(Request.func_148668_d(s, "")); + return Boolean.valueOf(s1); + } + + public Boolean func_148700_f(long p_148700_1_) throws ExceptionMcoService, IOException + { + String s = field_148716_e + "worlds" + "/$WORLD_ID/close".replace("$WORLD_ID", String.valueOf(p_148700_1_)); + String s1 = this.func_148713_a(Request.func_148668_d(s, "")); + return Boolean.valueOf(s1); + } + + public Boolean func_148699_d(long p_148699_1_, String p_148699_3_) throws ExceptionMcoService, UnsupportedEncodingException + { + StringBuilder stringbuilder = new StringBuilder(); + stringbuilder.append(field_148716_e).append("worlds").append("/$WORLD_ID/reset".replace("$WORLD_ID", String.valueOf(p_148699_1_))); + + if (p_148699_3_ != null && p_148699_3_.length() > 0) + { + stringbuilder.append("?seed=").append(this.func_148711_c(p_148699_3_)); + } + + String s1 = this.func_148713_a(Request.func_148669_b(stringbuilder.toString(), "", 30000, 80000)); + return Boolean.valueOf(s1); + } + + public Boolean func_148696_e(long p_148696_1_, String p_148696_3_) throws ExceptionMcoService + { + StringBuilder stringbuilder = new StringBuilder(); + stringbuilder.append(field_148716_e).append("worlds").append("/$WORLD_ID/reset".replace("$WORLD_ID", String.valueOf(p_148696_1_))); + + if (p_148696_3_ != null) + { + stringbuilder.append("?template=").append(p_148696_3_); + } + + String s1 = this.func_148713_a(Request.func_148669_b(stringbuilder.toString(), "", 30000, 80000)); + return Boolean.valueOf(s1); + } + + public ValueObjectSubscription func_148705_g(long p_148705_1_) throws ExceptionMcoService, IOException + { + String s = this.func_148713_a(Request.func_148666_a(field_148716_e + "subscriptions" + "/$WORLD_ID".replace("$WORLD_ID", String.valueOf(p_148705_1_)))); + return ValueObjectSubscription.func_148788_a(s); + } + + public int func_148701_f() throws ExceptionMcoService + { + String s = this.func_148713_a(Request.func_148666_a(field_148716_e + "invites" + "/count/pending")); + return Integer.parseInt(s); + } + + public PendingInvitesList func_148710_g() throws ExceptionMcoService + { + String s = this.func_148713_a(Request.func_148666_a(field_148716_e + "invites" + "/pending")); + return PendingInvitesList.func_148767_a(s); + } + + public void func_148691_a(String p_148691_1_) throws ExceptionMcoService + { + this.func_148713_a(Request.func_148668_d(field_148716_e + "invites" + "/accept/$INVITATION_ID".replace("$INVITATION_ID", p_148691_1_), "")); + } + + public String func_148708_h(long p_148708_1_) throws ExceptionMcoService + { + return this.func_148713_a(Request.func_148666_a(field_148716_e + "worlds" + "/$WORLD_ID/backups/download".replace("$WORLD_ID", String.valueOf(p_148708_1_)))); + } + + public void func_148706_b(String p_148706_1_) throws ExceptionMcoService + { + this.func_148713_a(Request.func_148668_d(field_148716_e + "invites" + "/reject/$INVITATION_ID".replace("$INVITATION_ID", p_148706_1_), "")); + } + + public void func_148714_h() throws ExceptionMcoService + { + this.func_148713_a(Request.func_148672_c(field_148716_e + "mco" + "/tos/agreed", "")); + } + + public String func_148690_i() throws ExceptionMcoService + { + return this.func_148713_a(Request.func_148666_a(field_148716_e + "mco" + "/stat")); + } + + private String func_148711_c(String p_148711_1_) throws UnsupportedEncodingException + { + return URLEncoder.encode(p_148711_1_, "UTF-8"); + } + + private String func_148713_a(Request p_148713_1_) throws ExceptionMcoService + { + McoClientConfig.func_148684_a(this.field_148715_d); + p_148713_1_.func_148665_a("sid", this.field_148719_a); + p_148713_1_.func_148665_a("user", this.field_148717_b); + p_148713_1_.func_148665_a("version", this.field_148718_c); + + try + { + int i = p_148713_1_.func_148671_a(); + + if (i == 503) + { + int j = p_148713_1_.func_148664_b(); + throw new ExceptionRetryCall(j); + } + else if (i >= 200 && i < 300) + { + return p_148713_1_.func_148659_d(); + } + else + { + throw new ExceptionMcoService(p_148713_1_.func_148671_a(), p_148713_1_.func_148659_d(), p_148713_1_.func_148673_g()); + } + } + catch (ExceptionMcoHttp exceptionmcohttp) + { + throw new ExceptionMcoService(500, "Server not available!", -1); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/mco/McoClientConfig.java b/src/main/java/net/minecraft/client/mco/McoClientConfig.java new file mode 100644 index 0000000..51a629d --- /dev/null +++ b/src/main/java/net/minecraft/client/mco/McoClientConfig.java @@ -0,0 +1,25 @@ +package net.minecraft.client.mco; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.net.Proxy; + +@SideOnly(Side.CLIENT) +public class McoClientConfig +{ + private static Proxy field_148686_a; + private static final String __OBFID = "CL_00001157"; + + public static Proxy func_148685_a() + { + return field_148686_a; + } + + public static void func_148684_a(Proxy p_148684_0_) + { + if (field_148686_a == null) + { + field_148686_a = p_148684_0_; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/mco/McoServer.java b/src/main/java/net/minecraft/client/mco/McoServer.java new file mode 100644 index 0000000..541c9b2 --- /dev/null +++ b/src/main/java/net/minecraft/client/mco/McoServer.java @@ -0,0 +1,168 @@ +package net.minecraft.client.mco; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonIOException; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.google.gson.JsonSyntaxException; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; + +@SideOnly(Side.CLIENT) +public class McoServer +{ + public long field_148812_a; + public String field_148810_b; + public String field_148811_c; + public String field_148808_d; + public String field_148809_e; + public List field_148806_f; + public String field_148807_g; + public boolean field_148819_h; + public int field_148820_i; + public int field_148817_j; + public int field_148818_k; + public int field_148815_l; + public String field_148816_m = ""; + public String field_148813_n = "\u00a770"; + public boolean field_148814_o = false; + private static final String __OBFID = "CL_00001166"; + + public String func_148800_a() + { + return this.field_148811_c; + } + + public String func_148801_b() + { + return this.field_148810_b; + } + + public void func_148803_a(String p_148803_1_) + { + this.field_148810_b = p_148803_1_; + } + + public void func_148804_b(String p_148804_1_) + { + this.field_148811_c = p_148804_1_; + } + + public void func_148799_a(McoServer p_148799_1_) + { + this.field_148816_m = p_148799_1_.field_148816_m; + this.field_148815_l = p_148799_1_.field_148815_l; + } + + public static McoServer func_148802_a(JsonObject p_148802_0_) + { + McoServer mcoserver = new McoServer(); + + try + { + mcoserver.field_148812_a = !p_148802_0_.get("id").isJsonNull() ? p_148802_0_.get("id").getAsLong() : -1L; + mcoserver.field_148810_b = !p_148802_0_.get("name").isJsonNull() ? p_148802_0_.get("name").getAsString() : null; + mcoserver.field_148811_c = !p_148802_0_.get("motd").isJsonNull() ? p_148802_0_.get("motd").getAsString() : null; + mcoserver.field_148808_d = !p_148802_0_.get("state").isJsonNull() ? p_148802_0_.get("state").getAsString() : McoServer.State.CLOSED.name(); + mcoserver.field_148809_e = !p_148802_0_.get("owner").isJsonNull() ? p_148802_0_.get("owner").getAsString() : null; + + if (p_148802_0_.get("invited").isJsonArray()) + { + mcoserver.field_148806_f = func_148798_a(p_148802_0_.get("invited").getAsJsonArray()); + } + else + { + mcoserver.field_148806_f = new ArrayList(); + } + + mcoserver.field_148818_k = !p_148802_0_.get("daysLeft").isJsonNull() ? p_148802_0_.get("daysLeft").getAsInt() : 0; + mcoserver.field_148807_g = !p_148802_0_.get("ip").isJsonNull() ? p_148802_0_.get("ip").getAsString() : null; + mcoserver.field_148819_h = !p_148802_0_.get("expired").isJsonNull() && p_148802_0_.get("expired").getAsBoolean(); + mcoserver.field_148820_i = !p_148802_0_.get("difficulty").isJsonNull() ? p_148802_0_.get("difficulty").getAsInt() : 0; + mcoserver.field_148817_j = !p_148802_0_.get("gameMode").isJsonNull() ? p_148802_0_.get("gameMode").getAsInt() : 0; + } + catch (IllegalArgumentException illegalargumentexception) + { + ; + } + + return mcoserver; + } + + private static List func_148798_a(JsonArray p_148798_0_) + { + ArrayList arraylist = new ArrayList(); + Iterator iterator = p_148798_0_.iterator(); + + while (iterator.hasNext()) + { + arraylist.add(((JsonElement)iterator.next()).getAsString()); + } + + return arraylist; + } + + public static McoServer func_148805_c(String p_148805_0_) + { + McoServer mcoserver = new McoServer(); + + try + { + JsonParser jsonparser = new JsonParser(); + JsonObject jsonobject = jsonparser.parse(p_148805_0_).getAsJsonObject(); + mcoserver = func_148802_a(jsonobject); + } + catch (JsonIOException jsonioexception) + { + ; + } + catch (JsonSyntaxException jsonsyntaxexception) + { + ; + } + + return mcoserver; + } + + public int hashCode() + { + return (new HashCodeBuilder(17, 37)).append(this.field_148812_a).append(this.field_148810_b).append(this.field_148811_c).append(this.field_148808_d).append(this.field_148809_e).append(this.field_148819_h).toHashCode(); + } + + public boolean equals(Object par1Obj) + { + if (par1Obj == null) + { + return false; + } + else if (par1Obj == this) + { + return true; + } + else if (par1Obj.getClass() != this.getClass()) + { + return false; + } + else + { + McoServer mcoserver = (McoServer)par1Obj; + return (new EqualsBuilder()).append(this.field_148812_a, mcoserver.field_148812_a).append(this.field_148810_b, mcoserver.field_148810_b).append(this.field_148811_c, mcoserver.field_148811_c).append(this.field_148808_d, mcoserver.field_148808_d).append(this.field_148809_e, mcoserver.field_148809_e).append(this.field_148819_h, mcoserver.field_148819_h).isEquals(); + } + } + + @SideOnly(Side.CLIENT) + public static enum State + { + CLOSED, + OPEN, + ADMIN_LOCK; + + private static final String __OBFID = "CL_00001167"; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/mco/McoServerAddress.java b/src/main/java/net/minecraft/client/mco/McoServerAddress.java new file mode 100644 index 0000000..a03a2b0 --- /dev/null +++ b/src/main/java/net/minecraft/client/mco/McoServerAddress.java @@ -0,0 +1,38 @@ +package net.minecraft.client.mco; + +import com.google.gson.JsonIOException; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.google.gson.JsonSyntaxException; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.util.ValueObject; + +@SideOnly(Side.CLIENT) +public class McoServerAddress extends ValueObject +{ + public String field_148770_a; + private static final String __OBFID = "CL_00001168"; + + public static McoServerAddress func_148769_a(String p_148769_0_) + { + JsonParser jsonparser = new JsonParser(); + McoServerAddress mcoserveraddress = new McoServerAddress(); + + try + { + JsonObject jsonobject = jsonparser.parse(p_148769_0_).getAsJsonObject(); + mcoserveraddress.field_148770_a = jsonobject.get("address").getAsString(); + } + catch (JsonIOException jsonioexception) + { + ; + } + catch (JsonSyntaxException jsonsyntaxexception) + { + ; + } + + return mcoserveraddress; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/mco/McoServerList.java b/src/main/java/net/minecraft/client/mco/McoServerList.java new file mode 100644 index 0000000..59f82e4 --- /dev/null +++ b/src/main/java/net/minecraft/client/mco/McoServerList.java @@ -0,0 +1,262 @@ +package net.minecraft.client.mco; + +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Set; +import java.util.Timer; +import java.util.TimerTask; +import net.minecraft.client.Minecraft; +import net.minecraft.util.Session; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +@SideOnly(Side.CLIENT) +public class McoServerList +{ + private static final Logger logger = LogManager.getLogger(); + private volatile boolean field_148488_b; + private McoServerList.UpdateTask field_148489_c = new McoServerList.UpdateTask(null); + private Timer field_148486_d = new Timer(); + private Set field_148487_e = Sets.newHashSet(); + private List field_148484_f = Lists.newArrayList(); + private int field_148485_g; + private boolean field_148492_h; + private Session field_148493_i; + private int field_148491_j; + private static final String __OBFID = "CL_00000803"; + + public McoServerList() + { + this.field_148486_d.schedule(this.field_148489_c, 0L, 10000L); + this.field_148493_i = Minecraft.getMinecraft().getSession(); + } + + public synchronized void func_148475_a(Session p_148475_1_) + { + this.field_148493_i = p_148475_1_; + + if (this.field_148488_b) + { + this.field_148488_b = false; + this.field_148489_c = new McoServerList.UpdateTask(null); + this.field_148486_d = new Timer(); + this.field_148486_d.schedule(this.field_148489_c, 0L, 10000L); + } + } + + public synchronized boolean func_148472_a() + { + return this.field_148492_h; + } + + public synchronized void func_148479_b() + { + this.field_148492_h = false; + } + + public synchronized List func_148473_c() + { + return Lists.newArrayList(this.field_148484_f); + } + + public int func_148468_d() + { + return this.field_148485_g; + } + + public int func_148469_e() + { + return this.field_148491_j; + } + + public synchronized void func_148476_f() + { + this.field_148488_b = true; + this.field_148489_c.cancel(); + this.field_148486_d.cancel(); + } + + private synchronized void func_148474_a(List p_148474_1_) + { + int i = 0; + Iterator iterator = this.field_148487_e.iterator(); + + while (iterator.hasNext()) + { + McoServer mcoserver = (McoServer)iterator.next(); + + if (p_148474_1_.remove(mcoserver)) + { + ++i; + } + } + + if (i == 0) + { + this.field_148487_e.clear(); + } + + this.field_148484_f = p_148474_1_; + this.field_148492_h = true; + } + + public synchronized void func_148470_a(McoServer p_148470_1_) + { + this.field_148484_f.remove(p_148470_1_); + this.field_148487_e.add(p_148470_1_); + } + + private void func_148471_a(int p_148471_1_) + { + this.field_148485_g = p_148471_1_; + } + + @SideOnly(Side.CLIENT) + class UpdateTask extends TimerTask + { + private McoClient field_148498_b; + private static final String __OBFID = "CL_00000805"; + + private UpdateTask() {} + + public void run() + { + if (!McoServerList.this.field_148488_b) + { + this.func_148496_c(); + this.func_148494_a(); + this.func_148495_b(); + } + } + + private void func_148494_a() + { + try + { + if (McoServerList.this.field_148493_i != null) + { + this.field_148498_b = new McoClient(McoServerList.this.field_148493_i.getSessionID(), McoServerList.this.field_148493_i.getUsername(), "1.7.2", Minecraft.getMinecraft().getProxy()); + List list = this.field_148498_b.func_148703_a().field_148772_a; + + if (list != null) + { + this.func_148497_a(list); + McoServerList.this.func_148474_a(list); + } + } + } + catch (ExceptionMcoService exceptionmcoservice) + { + McoServerList.logger.error("Couldn\'t get server list", exceptionmcoservice); + } + catch (IOException ioexception) + { + McoServerList.logger.error("Couldn\'t parse response from server getting list"); + } + } + + private void func_148495_b() + { + try + { + if (McoServerList.this.field_148493_i != null) + { + int i = this.field_148498_b.func_148701_f(); + McoServerList.this.func_148471_a(i); + } + } + catch (ExceptionMcoService exceptionmcoservice) + { + McoServerList.logger.error("Couldn\'t get pending invite count", exceptionmcoservice); + } + } + + private void func_148496_c() + { + try + { + if (McoServerList.this.field_148493_i != null) + { + McoClient mcoclient = new McoClient(McoServerList.this.field_148493_i.getSessionID(), McoServerList.this.field_148493_i.getUsername(), "1.7.2", Minecraft.getMinecraft().getProxy()); + McoServerList.this.field_148491_j = mcoclient.func_148702_d(); + } + } + catch (ExceptionMcoService exceptionmcoservice) + { + McoServerList.logger.error("Couldn\'t get token count", exceptionmcoservice); + McoServerList.this.field_148491_j = 0; + } + } + + private void func_148497_a(List p_148497_1_) + { + Collections.sort(p_148497_1_, new McoServerList.UpdateTask.Comparator(McoServerList.this.field_148493_i.getUsername(), null)); + } + + UpdateTask(Object par2McoServerListEmptyAnon) + { + this(); + } + + @SideOnly(Side.CLIENT) + class Comparator implements java.util.Comparator + { + private final String field_148504_b; + private static final String __OBFID = "CL_00000806"; + + private Comparator(String par2Str) + { + this.field_148504_b = par2Str; + } + + public int compare(McoServer p_148503_1_, McoServer p_148503_2_) + { + if (p_148503_1_.field_148809_e.equals(p_148503_2_.field_148809_e)) + { + return p_148503_1_.field_148812_a < p_148503_2_.field_148812_a ? 1 : (p_148503_1_.field_148812_a > p_148503_2_.field_148812_a ? -1 : 0); + } + else if (p_148503_1_.field_148809_e.equals(this.field_148504_b)) + { + return -1; + } + else if (p_148503_2_.field_148809_e.equals(this.field_148504_b)) + { + return 1; + } + else + { + if (p_148503_1_.field_148808_d.equals("CLOSED") || p_148503_2_.field_148808_d.equals("CLOSED")) + { + if (p_148503_1_.field_148808_d.equals("CLOSED")) + { + return 1; + } + + if (p_148503_2_.field_148808_d.equals("CLOSED")) + { + return 0; + } + } + + return p_148503_1_.field_148812_a < p_148503_2_.field_148812_a ? 1 : (p_148503_1_.field_148812_a > p_148503_2_.field_148812_a ? -1 : 0); + } + } + + public int compare(Object par1Obj, Object par2Obj) + { + return this.compare((McoServer)par1Obj, (McoServer)par2Obj); + } + + Comparator(String par2Str, Object par3McoServerListEmptyAnon) + { + this(par2Str); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/mco/PendingInvite.java b/src/main/java/net/minecraft/client/mco/PendingInvite.java new file mode 100644 index 0000000..1e62372 --- /dev/null +++ b/src/main/java/net/minecraft/client/mco/PendingInvite.java @@ -0,0 +1,33 @@ +package net.minecraft.client.mco; + +import com.google.gson.JsonObject; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.util.ValueObject; + +@SideOnly(Side.CLIENT) +public class PendingInvite extends ValueObject +{ + public String field_148776_a; + public String field_148774_b; + public String field_148775_c; + private static final String __OBFID = "CL_00001170"; + + public static PendingInvite func_148773_a(JsonObject p_148773_0_) + { + PendingInvite pendinginvite = new PendingInvite(); + + try + { + pendinginvite.field_148776_a = p_148773_0_.get("invitationId").getAsString(); + pendinginvite.field_148774_b = p_148773_0_.get("worldName").getAsString(); + pendinginvite.field_148775_c = p_148773_0_.get("worldOwnerName").getAsString(); + } + catch (Exception exception) + { + ; + } + + return pendinginvite; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/mco/PendingInvitesList.java b/src/main/java/net/minecraft/client/mco/PendingInvitesList.java new file mode 100644 index 0000000..4af23d7 --- /dev/null +++ b/src/main/java/net/minecraft/client/mco/PendingInvitesList.java @@ -0,0 +1,51 @@ +package net.minecraft.client.mco; + +import com.google.common.collect.Lists; +import com.google.gson.JsonElement; +import com.google.gson.JsonIOException; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.google.gson.JsonSyntaxException; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Iterator; +import java.util.List; +import net.minecraft.util.ValueObject; + +@SideOnly(Side.CLIENT) +public class PendingInvitesList extends ValueObject +{ + public List field_148768_a = Lists.newArrayList(); + private static final String __OBFID = "CL_00001171"; + + public static PendingInvitesList func_148767_a(String p_148767_0_) + { + PendingInvitesList pendinginviteslist = new PendingInvitesList(); + + try + { + JsonParser jsonparser = new JsonParser(); + JsonObject jsonobject = jsonparser.parse(p_148767_0_).getAsJsonObject(); + + if (jsonobject.get("invites").isJsonArray()) + { + Iterator iterator = jsonobject.get("invites").getAsJsonArray().iterator(); + + while (iterator.hasNext()) + { + pendinginviteslist.field_148768_a.add(PendingInvite.func_148773_a(((JsonElement)iterator.next()).getAsJsonObject())); + } + } + } + catch (JsonIOException jsonioexception) + { + ; + } + catch (JsonSyntaxException jsonsyntaxexception) + { + ; + } + + return pendinginviteslist; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/mco/Request.java b/src/main/java/net/minecraft/client/mco/Request.java new file mode 100644 index 0000000..e6cafe7 --- /dev/null +++ b/src/main/java/net/minecraft/client/mco/Request.java @@ -0,0 +1,347 @@ +package net.minecraft.client.mco; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.Proxy; +import java.net.URL; + +@SideOnly(Side.CLIENT) +public abstract class Request +{ + protected HttpURLConnection field_148677_a; + private boolean field_148676_c; + protected String field_148675_b; + private static final String __OBFID = "CL_00001159"; + + public Request(String par1Str, int par2, int par3) + { + try + { + this.field_148675_b = par1Str; + Proxy proxy = McoClientConfig.func_148685_a(); + + if (proxy != null) + { + this.field_148677_a = (HttpURLConnection)(new URL(par1Str)).openConnection(proxy); + } + else + { + this.field_148677_a = (HttpURLConnection)(new URL(par1Str)).openConnection(); + } + + this.field_148677_a.setConnectTimeout(par2); + this.field_148677_a.setReadTimeout(par3); + } + catch (Exception exception) + { + throw new ExceptionMcoHttp("Failed URL: " + par1Str, exception); + } + } + + public void func_148665_a(String p_148665_1_, String p_148665_2_) + { + String s2 = this.field_148677_a.getRequestProperty("Cookie"); + + if (s2 == null) + { + this.field_148677_a.setRequestProperty("Cookie", p_148665_1_ + "=" + p_148665_2_); + } + else + { + this.field_148677_a.setRequestProperty("Cookie", s2 + ";" + p_148665_1_ + "=" + p_148665_2_); + } + } + + public int func_148671_a() + { + try + { + this.func_148667_e(); + return this.field_148677_a.getResponseCode(); + } + catch (Exception exception) + { + throw new ExceptionMcoHttp("Failed URL: " + this.field_148675_b, exception); + } + } + + public int func_148664_b() + { + String s = this.field_148677_a.getHeaderField("Retry-After"); + + try + { + return Integer.valueOf(s).intValue(); + } + catch (Exception exception) + { + return 5; + } + } + + public String func_148659_d() + { + try + { + this.func_148667_e(); + String s = this.func_148671_a() >= 400 ? this.func_148660_a(this.field_148677_a.getErrorStream()) : this.func_148660_a(this.field_148677_a.getInputStream()); + this.func_148674_h(); + return s; + } + catch (IOException ioexception) + { + throw new ExceptionMcoHttp("Failed URL: " + this.field_148675_b, ioexception); + } + } + + private String func_148660_a(InputStream p_148660_1_) throws IOException + { + if (p_148660_1_ == null) + { + return ""; + } + else + { + StringBuilder stringbuilder = new StringBuilder(); + + for (int i = p_148660_1_.read(); i != -1; i = p_148660_1_.read()) + { + stringbuilder.append((char)i); + } + + return stringbuilder.toString(); + } + } + + private void func_148674_h() + { + byte[] abyte = new byte[1024]; + InputStream inputstream; + + try + { + boolean flag = false; + inputstream = this.field_148677_a.getInputStream(); + + while (true) + { + if (inputstream.read(abyte) <= 0) + { + inputstream.close(); + break; + } + } + } + catch (Exception exception) + { + try + { + inputstream = this.field_148677_a.getErrorStream(); + boolean flag1 = false; + + if (inputstream == null) + { + return; + } + + while (true) + { + if (inputstream.read(abyte) <= 0) + { + inputstream.close(); + break; + } + } + } + catch (IOException ioexception) + { + ; + } + } + } + + protected Request func_148667_e() + { + if (!this.field_148676_c) + { + Request request = this.func_148662_f(); + this.field_148676_c = true; + return request; + } + else + { + return this; + } + } + + protected abstract Request func_148662_f(); + + public static Request func_148666_a(String p_148666_0_) + { + return new Request.Get(p_148666_0_, 5000, 10000); + } + + public static Request func_148670_a(String p_148670_0_, int p_148670_1_, int p_148670_2_) + { + return new Request.Get(p_148670_0_, p_148670_1_, p_148670_2_); + } + + public static Request func_148672_c(String p_148672_0_, String p_148672_1_) + { + return new Request.Post(p_148672_0_, p_148672_1_.getBytes(), 5000, 10000); + } + + public static Request func_148661_a(String p_148661_0_, String p_148661_1_, int p_148661_2_, int p_148661_3_) + { + return new Request.Post(p_148661_0_, p_148661_1_.getBytes(), p_148661_2_, p_148661_3_); + } + + public static Request func_148663_b(String p_148663_0_) + { + return new Request.Delete(p_148663_0_, 5000, 10000); + } + + public static Request func_148668_d(String p_148668_0_, String p_148668_1_) + { + return new Request.Put(p_148668_0_, p_148668_1_.getBytes(), 5000, 10000); + } + + public static Request func_148669_b(String p_148669_0_, String p_148669_1_, int p_148669_2_, int p_148669_3_) + { + return new Request.Put(p_148669_0_, p_148669_1_.getBytes(), p_148669_2_, p_148669_3_); + } + + public int func_148673_g() + { + String s = this.field_148677_a.getHeaderField("Error-Code"); + + try + { + return Integer.valueOf(s).intValue(); + } + catch (Exception exception) + { + return -1; + } + } + + @SideOnly(Side.CLIENT) + public static class Delete extends Request + { + private static final String __OBFID = "CL_00001160"; + + public Delete(String par1Str, int par2, int par3) + { + super(par1Str, par2, par3); + } + + public Request.Delete func_148662_f() + { + try + { + this.field_148677_a.setDoOutput(true); + this.field_148677_a.setRequestMethod("DELETE"); + this.field_148677_a.connect(); + return this; + } + catch (Exception exception) + { + throw new ExceptionMcoHttp("Failed URL: " + this.field_148675_b, exception); + } + } + } + + @SideOnly(Side.CLIENT) + public static class Get extends Request + { + private static final String __OBFID = "CL_00001161"; + + public Get(String par1Str, int par2, int par3) + { + super(par1Str, par2, par3); + } + + public Request.Get func_148662_f() + { + try + { + this.field_148677_a.setDoInput(true); + this.field_148677_a.setDoOutput(true); + this.field_148677_a.setUseCaches(false); + this.field_148677_a.setRequestMethod("GET"); + return this; + } + catch (Exception exception) + { + throw new ExceptionMcoHttp("Failed URL: " + this.field_148675_b, exception); + } + } + } + + @SideOnly(Side.CLIENT) + public static class Post extends Request + { + private byte[] field_148683_c; + private static final String __OBFID = "CL_00001162"; + + public Post(String par1Str, byte[] par2ArrayOfByte, int par3, int par4) + { + super(par1Str, par3, par4); + this.field_148683_c = par2ArrayOfByte; + } + + public Request.Post func_148662_f() + { + try + { + this.field_148677_a.setDoInput(true); + this.field_148677_a.setDoOutput(true); + this.field_148677_a.setUseCaches(false); + this.field_148677_a.setRequestMethod("POST"); + OutputStream outputstream = this.field_148677_a.getOutputStream(); + outputstream.write(this.field_148683_c); + outputstream.flush(); + return this; + } + catch (Exception exception) + { + throw new ExceptionMcoHttp("Failed URL: " + this.field_148675_b, exception); + } + } + } + + @SideOnly(Side.CLIENT) + public static class Put extends Request + { + private byte[] field_148681_c; + private static final String __OBFID = "CL_00001163"; + + public Put(String par1Str, byte[] par2ArrayOfByte, int par3, int par4) + { + super(par1Str, par3, par4); + this.field_148681_c = par2ArrayOfByte; + } + + public Request.Put func_148662_f() + { + try + { + this.field_148677_a.setDoOutput(true); + this.field_148677_a.setDoInput(true); + this.field_148677_a.setRequestMethod("PUT"); + OutputStream outputstream = this.field_148677_a.getOutputStream(); + outputstream.write(this.field_148681_c); + outputstream.flush(); + return this; + } + catch (Exception exception) + { + throw new ExceptionMcoHttp("Failed URL: " + this.field_148675_b, exception); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/mco/ValueObjectList.java b/src/main/java/net/minecraft/client/mco/ValueObjectList.java new file mode 100644 index 0000000..d22a1fa --- /dev/null +++ b/src/main/java/net/minecraft/client/mco/ValueObjectList.java @@ -0,0 +1,54 @@ +package net.minecraft.client.mco; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonIOException; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.google.gson.JsonSyntaxException; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import net.minecraft.util.ValueObject; + +@SideOnly(Side.CLIENT) +public class ValueObjectList extends ValueObject +{ + public List field_148772_a; + private static final String __OBFID = "CL_00001169"; + + public static ValueObjectList func_148771_a(String p_148771_0_) + { + ValueObjectList valueobjectlist = new ValueObjectList(); + valueobjectlist.field_148772_a = new ArrayList(); + + try + { + JsonParser jsonparser = new JsonParser(); + JsonObject jsonobject = jsonparser.parse(p_148771_0_).getAsJsonObject(); + + if (jsonobject.get("servers").isJsonArray()) + { + JsonArray jsonarray = jsonobject.get("servers").getAsJsonArray(); + Iterator iterator = jsonarray.iterator(); + + while (iterator.hasNext()) + { + valueobjectlist.field_148772_a.add(McoServer.func_148802_a(((JsonElement)iterator.next()).getAsJsonObject())); + } + } + } + catch (JsonIOException jsonioexception) + { + ; + } + catch (JsonSyntaxException jsonsyntaxexception) + { + ; + } + + return valueobjectlist; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/mco/ValueObjectSubscription.java b/src/main/java/net/minecraft/client/mco/ValueObjectSubscription.java new file mode 100644 index 0000000..1185407 --- /dev/null +++ b/src/main/java/net/minecraft/client/mco/ValueObjectSubscription.java @@ -0,0 +1,40 @@ +package net.minecraft.client.mco; + +import com.google.gson.JsonIOException; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.google.gson.JsonSyntaxException; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.util.ValueObject; + +@SideOnly(Side.CLIENT) +public class ValueObjectSubscription extends ValueObject +{ + public long field_148790_a; + public int field_148789_b; + private static final String __OBFID = "CL_00001172"; + + public static ValueObjectSubscription func_148788_a(String p_148788_0_) + { + ValueObjectSubscription valueobjectsubscription = new ValueObjectSubscription(); + + try + { + JsonParser jsonparser = new JsonParser(); + JsonObject jsonobject = jsonparser.parse(p_148788_0_).getAsJsonObject(); + valueobjectsubscription.field_148790_a = jsonobject.get("startDate").getAsLong(); + valueobjectsubscription.field_148789_b = jsonobject.get("daysLeft").getAsInt(); + } + catch (JsonIOException jsonioexception) + { + ; + } + catch (JsonSyntaxException jsonsyntaxexception) + { + ; + } + + return valueobjectsubscription; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/mco/WorldTemplate.java b/src/main/java/net/minecraft/client/mco/WorldTemplate.java new file mode 100644 index 0000000..37d2511 --- /dev/null +++ b/src/main/java/net/minecraft/client/mco/WorldTemplate.java @@ -0,0 +1,35 @@ +package net.minecraft.client.mco; + +import com.google.gson.JsonObject; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.util.ValueObject; + +@SideOnly(Side.CLIENT) +public class WorldTemplate extends ValueObject +{ + public String field_148787_a; + public String field_148785_b; + public String field_148786_c; + public String field_148784_d; + private static final String __OBFID = "CL_00001174"; + + public static WorldTemplate func_148783_a(JsonObject p_148783_0_) + { + WorldTemplate worldtemplate = new WorldTemplate(); + + try + { + worldtemplate.field_148787_a = p_148783_0_.get("id").getAsString(); + worldtemplate.field_148785_b = p_148783_0_.get("name").getAsString(); + worldtemplate.field_148786_c = p_148783_0_.get("version").getAsString(); + worldtemplate.field_148784_d = p_148783_0_.get("author").getAsString(); + } + catch (IllegalArgumentException illegalargumentexception) + { + ; + } + + return worldtemplate; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/mco/WorldTemplateList.java b/src/main/java/net/minecraft/client/mco/WorldTemplateList.java new file mode 100644 index 0000000..548af87 --- /dev/null +++ b/src/main/java/net/minecraft/client/mco/WorldTemplateList.java @@ -0,0 +1,52 @@ +package net.minecraft.client.mco; + +import com.google.gson.JsonElement; +import com.google.gson.JsonIOException; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.google.gson.JsonSyntaxException; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import net.minecraft.util.ValueObject; + +@SideOnly(Side.CLIENT) +public class WorldTemplateList extends ValueObject +{ + public List field_148782_a; + private static final String __OBFID = "CL_00001175"; + + public static WorldTemplateList func_148781_a(String p_148781_0_) + { + WorldTemplateList worldtemplatelist = new WorldTemplateList(); + worldtemplatelist.field_148782_a = new ArrayList(); + + try + { + JsonParser jsonparser = new JsonParser(); + JsonObject jsonobject = jsonparser.parse(p_148781_0_).getAsJsonObject(); + + if (jsonobject.get("templates").isJsonArray()) + { + Iterator iterator = jsonobject.get("templates").getAsJsonArray().iterator(); + + while (iterator.hasNext()) + { + worldtemplatelist.field_148782_a.add(WorldTemplate.func_148783_a(((JsonElement)iterator.next()).getAsJsonObject())); + } + } + } + catch (JsonIOException jsonioexception) + { + ; + } + catch (JsonSyntaxException jsonsyntaxexception) + { + ; + } + + return worldtemplatelist; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/ModelBase.java b/src/main/java/net/minecraft/client/model/ModelBase.java new file mode 100644 index 0000000..95ca0d7 --- /dev/null +++ b/src/main/java/net/minecraft/client/model/ModelBase.java @@ -0,0 +1,44 @@ +package net.minecraft.client.model; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Random; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; + +public abstract class ModelBase +{ + public float onGround; + public boolean isRiding; + public List boxList = new ArrayList(); + public boolean isChild = true; + private Map modelTextureMap = new HashMap(); + public int textureWidth = 64; + public int textureHeight = 32; + private static final String __OBFID = "CL_00000845"; + + public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) {} + + public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) {} + + public void setLivingAnimations(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4) {} + + public ModelRenderer getRandomModelBox(Random par1Random) + { + return (ModelRenderer)this.boxList.get(par1Random.nextInt(this.boxList.size())); + } + + protected void setTextureOffset(String par1Str, int par2, int par3) + { + this.modelTextureMap.put(par1Str, new TextureOffset(par2, par3)); + } + + public TextureOffset getTextureOffset(String par1Str) + { + return (TextureOffset)this.modelTextureMap.get(par1Str); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/ModelBat.java b/src/main/java/net/minecraft/client/model/ModelBat.java new file mode 100644 index 0000000..2f70bfe --- /dev/null +++ b/src/main/java/net/minecraft/client/model/ModelBat.java @@ -0,0 +1,101 @@ +package net.minecraft.client.model; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; +import net.minecraft.entity.passive.EntityBat; +import net.minecraft.util.MathHelper; + +@SideOnly(Side.CLIENT) +public class ModelBat extends ModelBase +{ + private ModelRenderer batHead; + private ModelRenderer batBody; + private ModelRenderer batRightWing; + private ModelRenderer batLeftWing; + private ModelRenderer batOuterRightWing; + private ModelRenderer batOuterLeftWing; + private static final String __OBFID = "CL_00000830"; + + public ModelBat() + { + this.textureWidth = 64; + this.textureHeight = 64; + this.batHead = new ModelRenderer(this, 0, 0); + this.batHead.addBox(-3.0F, -3.0F, -3.0F, 6, 6, 6); + ModelRenderer modelrenderer = new ModelRenderer(this, 24, 0); + modelrenderer.addBox(-4.0F, -6.0F, -2.0F, 3, 4, 1); + this.batHead.addChild(modelrenderer); + ModelRenderer modelrenderer1 = new ModelRenderer(this, 24, 0); + modelrenderer1.mirror = true; + modelrenderer1.addBox(1.0F, -6.0F, -2.0F, 3, 4, 1); + this.batHead.addChild(modelrenderer1); + this.batBody = new ModelRenderer(this, 0, 16); + this.batBody.addBox(-3.0F, 4.0F, -3.0F, 6, 12, 6); + this.batBody.setTextureOffset(0, 34).addBox(-5.0F, 16.0F, 0.0F, 10, 6, 1); + this.batRightWing = new ModelRenderer(this, 42, 0); + this.batRightWing.addBox(-12.0F, 1.0F, 1.5F, 10, 16, 1); + this.batOuterRightWing = new ModelRenderer(this, 24, 16); + this.batOuterRightWing.setRotationPoint(-12.0F, 1.0F, 1.5F); + this.batOuterRightWing.addBox(-8.0F, 1.0F, 0.0F, 8, 12, 1); + this.batLeftWing = new ModelRenderer(this, 42, 0); + this.batLeftWing.mirror = true; + this.batLeftWing.addBox(2.0F, 1.0F, 1.5F, 10, 16, 1); + this.batOuterLeftWing = new ModelRenderer(this, 24, 16); + this.batOuterLeftWing.mirror = true; + this.batOuterLeftWing.setRotationPoint(12.0F, 1.0F, 1.5F); + this.batOuterLeftWing.addBox(0.0F, 1.0F, 0.0F, 8, 12, 1); + this.batBody.addChild(this.batRightWing); + this.batBody.addChild(this.batLeftWing); + this.batRightWing.addChild(this.batOuterRightWing); + this.batLeftWing.addChild(this.batOuterLeftWing); + } + + public int getBatSize() + { + return 36; + } + + public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) + { + EntityBat entitybat = (EntityBat)par1Entity; + float f6; + + if (entitybat.getIsBatHanging()) + { + f6 = (180F / (float)Math.PI); + this.batHead.rotateAngleX = par6 / (180F / (float)Math.PI); + this.batHead.rotateAngleY = (float)Math.PI - par5 / (180F / (float)Math.PI); + this.batHead.rotateAngleZ = (float)Math.PI; + this.batHead.setRotationPoint(0.0F, -2.0F, 0.0F); + this.batRightWing.setRotationPoint(-3.0F, 0.0F, 3.0F); + this.batLeftWing.setRotationPoint(3.0F, 0.0F, 3.0F); + this.batBody.rotateAngleX = (float)Math.PI; + this.batRightWing.rotateAngleX = -0.15707964F; + this.batRightWing.rotateAngleY = -((float)Math.PI * 2F / 5F); + this.batOuterRightWing.rotateAngleY = -1.7278761F; + this.batLeftWing.rotateAngleX = this.batRightWing.rotateAngleX; + this.batLeftWing.rotateAngleY = -this.batRightWing.rotateAngleY; + this.batOuterLeftWing.rotateAngleY = -this.batOuterRightWing.rotateAngleY; + } + else + { + f6 = (180F / (float)Math.PI); + this.batHead.rotateAngleX = par6 / (180F / (float)Math.PI); + this.batHead.rotateAngleY = par5 / (180F / (float)Math.PI); + this.batHead.rotateAngleZ = 0.0F; + this.batHead.setRotationPoint(0.0F, 0.0F, 0.0F); + this.batRightWing.setRotationPoint(0.0F, 0.0F, 0.0F); + this.batLeftWing.setRotationPoint(0.0F, 0.0F, 0.0F); + this.batBody.rotateAngleX = ((float)Math.PI / 4F) + MathHelper.cos(par4 * 0.1F) * 0.15F; + this.batBody.rotateAngleY = 0.0F; + this.batRightWing.rotateAngleY = MathHelper.cos(par4 * 1.3F) * (float)Math.PI * 0.25F; + this.batLeftWing.rotateAngleY = -this.batRightWing.rotateAngleY; + this.batOuterRightWing.rotateAngleY = this.batRightWing.rotateAngleY * 0.5F; + this.batOuterLeftWing.rotateAngleY = -this.batRightWing.rotateAngleY * 0.5F; + } + + this.batHead.render(par7); + this.batBody.render(par7); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/ModelBiped.java b/src/main/java/net/minecraft/client/model/ModelBiped.java new file mode 100644 index 0000000..979cd25 --- /dev/null +++ b/src/main/java/net/minecraft/client/model/ModelBiped.java @@ -0,0 +1,227 @@ +package net.minecraft.client.model; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; +import net.minecraft.util.MathHelper; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class ModelBiped extends ModelBase +{ + public ModelRenderer bipedHead; + public ModelRenderer bipedHeadwear; + public ModelRenderer bipedBody; + public ModelRenderer bipedRightArm; + public ModelRenderer bipedLeftArm; + public ModelRenderer bipedRightLeg; + public ModelRenderer bipedLeftLeg; + public ModelRenderer bipedEars; + public ModelRenderer bipedCloak; + public int heldItemLeft; + public int heldItemRight; + public boolean isSneak; + public boolean aimedBow; + private static final String __OBFID = "CL_00000840"; + + public ModelBiped() + { + this(0.0F); + } + + public ModelBiped(float par1) + { + this(par1, 0.0F, 64, 32); + } + + public ModelBiped(float par1, float par2, int par3, int par4) + { + this.textureWidth = par3; + this.textureHeight = par4; + this.bipedCloak = new ModelRenderer(this, 0, 0); + this.bipedCloak.addBox(-5.0F, 0.0F, -1.0F, 10, 16, 1, par1); + this.bipedEars = new ModelRenderer(this, 24, 0); + this.bipedEars.addBox(-3.0F, -6.0F, -1.0F, 6, 6, 1, par1); + this.bipedHead = new ModelRenderer(this, 0, 0); + this.bipedHead.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, par1); + this.bipedHead.setRotationPoint(0.0F, 0.0F + par2, 0.0F); + this.bipedHeadwear = new ModelRenderer(this, 32, 0); + this.bipedHeadwear.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, par1 + 0.5F); + this.bipedHeadwear.setRotationPoint(0.0F, 0.0F + par2, 0.0F); + this.bipedBody = new ModelRenderer(this, 16, 16); + this.bipedBody.addBox(-4.0F, 0.0F, -2.0F, 8, 12, 4, par1); + this.bipedBody.setRotationPoint(0.0F, 0.0F + par2, 0.0F); + this.bipedRightArm = new ModelRenderer(this, 40, 16); + this.bipedRightArm.addBox(-3.0F, -2.0F, -2.0F, 4, 12, 4, par1); + this.bipedRightArm.setRotationPoint(-5.0F, 2.0F + par2, 0.0F); + this.bipedLeftArm = new ModelRenderer(this, 40, 16); + this.bipedLeftArm.mirror = true; + this.bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, par1); + this.bipedLeftArm.setRotationPoint(5.0F, 2.0F + par2, 0.0F); + this.bipedRightLeg = new ModelRenderer(this, 0, 16); + this.bipedRightLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, par1); + this.bipedRightLeg.setRotationPoint(-1.9F, 12.0F + par2, 0.0F); + this.bipedLeftLeg = new ModelRenderer(this, 0, 16); + this.bipedLeftLeg.mirror = true; + this.bipedLeftLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, par1); + this.bipedLeftLeg.setRotationPoint(1.9F, 12.0F + par2, 0.0F); + } + + public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) + { + this.setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity); + + if (this.isChild) + { + float f6 = 2.0F; + GL11.glPushMatrix(); + GL11.glScalef(1.5F / f6, 1.5F / f6, 1.5F / f6); + GL11.glTranslatef(0.0F, 16.0F * par7, 0.0F); + this.bipedHead.render(par7); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glScalef(1.0F / f6, 1.0F / f6, 1.0F / f6); + GL11.glTranslatef(0.0F, 24.0F * par7, 0.0F); + this.bipedBody.render(par7); + this.bipedRightArm.render(par7); + this.bipedLeftArm.render(par7); + this.bipedRightLeg.render(par7); + this.bipedLeftLeg.render(par7); + this.bipedHeadwear.render(par7); + GL11.glPopMatrix(); + } + else + { + this.bipedHead.render(par7); + this.bipedBody.render(par7); + this.bipedRightArm.render(par7); + this.bipedLeftArm.render(par7); + this.bipedRightLeg.render(par7); + this.bipedLeftLeg.render(par7); + this.bipedHeadwear.render(par7); + } + } + + public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) + { + this.bipedHead.rotateAngleY = par4 / (180F / (float)Math.PI); + this.bipedHead.rotateAngleX = par5 / (180F / (float)Math.PI); + this.bipedHeadwear.rotateAngleY = this.bipedHead.rotateAngleY; + this.bipedHeadwear.rotateAngleX = this.bipedHead.rotateAngleX; + this.bipedRightArm.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float)Math.PI) * 2.0F * par2 * 0.5F; + this.bipedLeftArm.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 2.0F * par2 * 0.5F; + this.bipedRightArm.rotateAngleZ = 0.0F; + this.bipedLeftArm.rotateAngleZ = 0.0F; + this.bipedRightLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 1.4F * par2; + this.bipedLeftLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float)Math.PI) * 1.4F * par2; + this.bipedRightLeg.rotateAngleY = 0.0F; + this.bipedLeftLeg.rotateAngleY = 0.0F; + + if (this.isRiding) + { + this.bipedRightArm.rotateAngleX += -((float)Math.PI / 5F); + this.bipedLeftArm.rotateAngleX += -((float)Math.PI / 5F); + this.bipedRightLeg.rotateAngleX = -((float)Math.PI * 2F / 5F); + this.bipedLeftLeg.rotateAngleX = -((float)Math.PI * 2F / 5F); + this.bipedRightLeg.rotateAngleY = ((float)Math.PI / 10F); + this.bipedLeftLeg.rotateAngleY = -((float)Math.PI / 10F); + } + + if (this.heldItemLeft != 0) + { + this.bipedLeftArm.rotateAngleX = this.bipedLeftArm.rotateAngleX * 0.5F - ((float)Math.PI / 10F) * (float)this.heldItemLeft; + } + + if (this.heldItemRight != 0) + { + this.bipedRightArm.rotateAngleX = this.bipedRightArm.rotateAngleX * 0.5F - ((float)Math.PI / 10F) * (float)this.heldItemRight; + } + + this.bipedRightArm.rotateAngleY = 0.0F; + this.bipedLeftArm.rotateAngleY = 0.0F; + float f6; + float f7; + + if (this.onGround > -9990.0F) + { + f6 = this.onGround; + this.bipedBody.rotateAngleY = MathHelper.sin(MathHelper.sqrt_float(f6) * (float)Math.PI * 2.0F) * 0.2F; + this.bipedRightArm.rotationPointZ = MathHelper.sin(this.bipedBody.rotateAngleY) * 5.0F; + this.bipedRightArm.rotationPointX = -MathHelper.cos(this.bipedBody.rotateAngleY) * 5.0F; + this.bipedLeftArm.rotationPointZ = -MathHelper.sin(this.bipedBody.rotateAngleY) * 5.0F; + this.bipedLeftArm.rotationPointX = MathHelper.cos(this.bipedBody.rotateAngleY) * 5.0F; + this.bipedRightArm.rotateAngleY += this.bipedBody.rotateAngleY; + this.bipedLeftArm.rotateAngleY += this.bipedBody.rotateAngleY; + this.bipedLeftArm.rotateAngleX += this.bipedBody.rotateAngleY; + f6 = 1.0F - this.onGround; + f6 *= f6; + f6 *= f6; + f6 = 1.0F - f6; + f7 = MathHelper.sin(f6 * (float)Math.PI); + float f8 = MathHelper.sin(this.onGround * (float)Math.PI) * -(this.bipedHead.rotateAngleX - 0.7F) * 0.75F; + this.bipedRightArm.rotateAngleX = (float)((double)this.bipedRightArm.rotateAngleX - ((double)f7 * 1.2D + (double)f8)); + this.bipedRightArm.rotateAngleY += this.bipedBody.rotateAngleY * 2.0F; + this.bipedRightArm.rotateAngleZ = MathHelper.sin(this.onGround * (float)Math.PI) * -0.4F; + } + + if (this.isSneak) + { + this.bipedBody.rotateAngleX = 0.5F; + this.bipedRightArm.rotateAngleX += 0.4F; + this.bipedLeftArm.rotateAngleX += 0.4F; + this.bipedRightLeg.rotationPointZ = 4.0F; + this.bipedLeftLeg.rotationPointZ = 4.0F; + this.bipedRightLeg.rotationPointY = 9.0F; + this.bipedLeftLeg.rotationPointY = 9.0F; + this.bipedHead.rotationPointY = 1.0F; + this.bipedHeadwear.rotationPointY = 1.0F; + } + else + { + this.bipedBody.rotateAngleX = 0.0F; + this.bipedRightLeg.rotationPointZ = 0.1F; + this.bipedLeftLeg.rotationPointZ = 0.1F; + this.bipedRightLeg.rotationPointY = 12.0F; + this.bipedLeftLeg.rotationPointY = 12.0F; + this.bipedHead.rotationPointY = 0.0F; + this.bipedHeadwear.rotationPointY = 0.0F; + } + + this.bipedRightArm.rotateAngleZ += MathHelper.cos(par3 * 0.09F) * 0.05F + 0.05F; + this.bipedLeftArm.rotateAngleZ -= MathHelper.cos(par3 * 0.09F) * 0.05F + 0.05F; + this.bipedRightArm.rotateAngleX += MathHelper.sin(par3 * 0.067F) * 0.05F; + this.bipedLeftArm.rotateAngleX -= MathHelper.sin(par3 * 0.067F) * 0.05F; + + if (this.aimedBow) + { + f6 = 0.0F; + f7 = 0.0F; + this.bipedRightArm.rotateAngleZ = 0.0F; + this.bipedLeftArm.rotateAngleZ = 0.0F; + this.bipedRightArm.rotateAngleY = -(0.1F - f6 * 0.6F) + this.bipedHead.rotateAngleY; + this.bipedLeftArm.rotateAngleY = 0.1F - f6 * 0.6F + this.bipedHead.rotateAngleY + 0.4F; + this.bipedRightArm.rotateAngleX = -((float)Math.PI / 2F) + this.bipedHead.rotateAngleX; + this.bipedLeftArm.rotateAngleX = -((float)Math.PI / 2F) + this.bipedHead.rotateAngleX; + this.bipedRightArm.rotateAngleX -= f6 * 1.2F - f7 * 0.4F; + this.bipedLeftArm.rotateAngleX -= f6 * 1.2F - f7 * 0.4F; + this.bipedRightArm.rotateAngleZ += MathHelper.cos(par3 * 0.09F) * 0.05F + 0.05F; + this.bipedLeftArm.rotateAngleZ -= MathHelper.cos(par3 * 0.09F) * 0.05F + 0.05F; + this.bipedRightArm.rotateAngleX += MathHelper.sin(par3 * 0.067F) * 0.05F; + this.bipedLeftArm.rotateAngleX -= MathHelper.sin(par3 * 0.067F) * 0.05F; + } + } + + public void renderEars(float par1) + { + this.bipedEars.rotateAngleY = this.bipedHead.rotateAngleY; + this.bipedEars.rotateAngleX = this.bipedHead.rotateAngleX; + this.bipedEars.rotationPointX = 0.0F; + this.bipedEars.rotationPointY = 0.0F; + this.bipedEars.render(par1); + } + + public void renderCloak(float par1) + { + this.bipedCloak.render(par1); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/ModelBlaze.java b/src/main/java/net/minecraft/client/model/ModelBlaze.java new file mode 100644 index 0000000..eb62414 --- /dev/null +++ b/src/main/java/net/minecraft/client/model/ModelBlaze.java @@ -0,0 +1,79 @@ +package net.minecraft.client.model; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; +import net.minecraft.util.MathHelper; + +@SideOnly(Side.CLIENT) +public class ModelBlaze extends ModelBase +{ + private ModelRenderer[] blazeSticks = new ModelRenderer[12]; + private ModelRenderer blazeHead; + private static final String __OBFID = "CL_00000831"; + + public ModelBlaze() + { + for (int i = 0; i < this.blazeSticks.length; ++i) + { + this.blazeSticks[i] = new ModelRenderer(this, 0, 16); + this.blazeSticks[i].addBox(0.0F, 0.0F, 0.0F, 2, 8, 2); + } + + this.blazeHead = new ModelRenderer(this, 0, 0); + this.blazeHead.addBox(-4.0F, -4.0F, -4.0F, 8, 8, 8); + } + + public int func_78104_a() + { + return 8; + } + + public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) + { + this.setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity); + this.blazeHead.render(par7); + + for (int i = 0; i < this.blazeSticks.length; ++i) + { + this.blazeSticks[i].render(par7); + } + } + + public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) + { + float f6 = par3 * (float)Math.PI * -0.1F; + int i; + + for (i = 0; i < 4; ++i) + { + this.blazeSticks[i].rotationPointY = -2.0F + MathHelper.cos(((float)(i * 2) + par3) * 0.25F); + this.blazeSticks[i].rotationPointX = MathHelper.cos(f6) * 9.0F; + this.blazeSticks[i].rotationPointZ = MathHelper.sin(f6) * 9.0F; + ++f6; + } + + f6 = ((float)Math.PI / 4F) + par3 * (float)Math.PI * 0.03F; + + for (i = 4; i < 8; ++i) + { + this.blazeSticks[i].rotationPointY = 2.0F + MathHelper.cos(((float)(i * 2) + par3) * 0.25F); + this.blazeSticks[i].rotationPointX = MathHelper.cos(f6) * 7.0F; + this.blazeSticks[i].rotationPointZ = MathHelper.sin(f6) * 7.0F; + ++f6; + } + + f6 = 0.47123894F + par3 * (float)Math.PI * -0.05F; + + for (i = 8; i < 12; ++i) + { + this.blazeSticks[i].rotationPointY = 11.0F + MathHelper.cos(((float)i * 1.5F + par3) * 0.5F); + this.blazeSticks[i].rotationPointX = MathHelper.cos(f6) * 5.0F; + this.blazeSticks[i].rotationPointZ = MathHelper.sin(f6) * 5.0F; + ++f6; + } + + this.blazeHead.rotateAngleY = par4 / (180F / (float)Math.PI); + this.blazeHead.rotateAngleX = par5 / (180F / (float)Math.PI); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/ModelBoat.java b/src/main/java/net/minecraft/client/model/ModelBoat.java new file mode 100644 index 0000000..b2838e9 --- /dev/null +++ b/src/main/java/net/minecraft/client/model/ModelBoat.java @@ -0,0 +1,47 @@ +package net.minecraft.client.model; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; + +@SideOnly(Side.CLIENT) +public class ModelBoat extends ModelBase +{ + public ModelRenderer[] boatSides = new ModelRenderer[5]; + private static final String __OBFID = "CL_00000832"; + + public ModelBoat() + { + this.boatSides[0] = new ModelRenderer(this, 0, 8); + this.boatSides[1] = new ModelRenderer(this, 0, 0); + this.boatSides[2] = new ModelRenderer(this, 0, 0); + this.boatSides[3] = new ModelRenderer(this, 0, 0); + this.boatSides[4] = new ModelRenderer(this, 0, 0); + byte b0 = 24; + byte b1 = 6; + byte b2 = 20; + byte b3 = 4; + this.boatSides[0].addBox((float)(-b0 / 2), (float)(-b2 / 2 + 2), -3.0F, b0, b2 - 4, 4, 0.0F); + this.boatSides[0].setRotationPoint(0.0F, (float)b3, 0.0F); + this.boatSides[1].addBox((float)(-b0 / 2 + 2), (float)(-b1 - 1), -1.0F, b0 - 4, b1, 2, 0.0F); + this.boatSides[1].setRotationPoint((float)(-b0 / 2 + 1), (float)b3, 0.0F); + this.boatSides[2].addBox((float)(-b0 / 2 + 2), (float)(-b1 - 1), -1.0F, b0 - 4, b1, 2, 0.0F); + this.boatSides[2].setRotationPoint((float)(b0 / 2 - 1), (float)b3, 0.0F); + this.boatSides[3].addBox((float)(-b0 / 2 + 2), (float)(-b1 - 1), -1.0F, b0 - 4, b1, 2, 0.0F); + this.boatSides[3].setRotationPoint(0.0F, (float)b3, (float)(-b2 / 2 + 1)); + this.boatSides[4].addBox((float)(-b0 / 2 + 2), (float)(-b1 - 1), -1.0F, b0 - 4, b1, 2, 0.0F); + this.boatSides[4].setRotationPoint(0.0F, (float)b3, (float)(b2 / 2 - 1)); + this.boatSides[0].rotateAngleX = ((float)Math.PI / 2F); + this.boatSides[1].rotateAngleY = ((float)Math.PI * 3F / 2F); + this.boatSides[2].rotateAngleY = ((float)Math.PI / 2F); + this.boatSides[3].rotateAngleY = (float)Math.PI; + } + + public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) + { + for (int i = 0; i < 5; ++i) + { + this.boatSides[i].render(par7); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/ModelBook.java b/src/main/java/net/minecraft/client/model/ModelBook.java new file mode 100644 index 0000000..43b0c53 --- /dev/null +++ b/src/main/java/net/minecraft/client/model/ModelBook.java @@ -0,0 +1,53 @@ +package net.minecraft.client.model; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; +import net.minecraft.util.MathHelper; + +@SideOnly(Side.CLIENT) +public class ModelBook extends ModelBase +{ + public ModelRenderer coverRight = (new ModelRenderer(this)).setTextureOffset(0, 0).addBox(-6.0F, -5.0F, 0.0F, 6, 10, 0); + public ModelRenderer coverLeft = (new ModelRenderer(this)).setTextureOffset(16, 0).addBox(0.0F, -5.0F, 0.0F, 6, 10, 0); + public ModelRenderer pagesRight = (new ModelRenderer(this)).setTextureOffset(0, 10).addBox(0.0F, -4.0F, -0.99F, 5, 8, 1); + public ModelRenderer pagesLeft = (new ModelRenderer(this)).setTextureOffset(12, 10).addBox(0.0F, -4.0F, -0.01F, 5, 8, 1); + public ModelRenderer flippingPageRight = (new ModelRenderer(this)).setTextureOffset(24, 10).addBox(0.0F, -4.0F, 0.0F, 5, 8, 0); + public ModelRenderer flippingPageLeft = (new ModelRenderer(this)).setTextureOffset(24, 10).addBox(0.0F, -4.0F, 0.0F, 5, 8, 0); + public ModelRenderer bookSpine = (new ModelRenderer(this)).setTextureOffset(12, 0).addBox(-1.0F, -5.0F, 0.0F, 2, 10, 0); + private static final String __OBFID = "CL_00000833"; + + public ModelBook() + { + this.coverRight.setRotationPoint(0.0F, 0.0F, -1.0F); + this.coverLeft.setRotationPoint(0.0F, 0.0F, 1.0F); + this.bookSpine.rotateAngleY = ((float)Math.PI / 2F); + } + + public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) + { + this.setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity); + this.coverRight.render(par7); + this.coverLeft.render(par7); + this.bookSpine.render(par7); + this.pagesRight.render(par7); + this.pagesLeft.render(par7); + this.flippingPageRight.render(par7); + this.flippingPageLeft.render(par7); + } + + public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) + { + float f6 = (MathHelper.sin(par1 * 0.02F) * 0.1F + 1.25F) * par4; + this.coverRight.rotateAngleY = (float)Math.PI + f6; + this.coverLeft.rotateAngleY = -f6; + this.pagesRight.rotateAngleY = f6; + this.pagesLeft.rotateAngleY = -f6; + this.flippingPageRight.rotateAngleY = f6 - f6 * 2.0F * par2; + this.flippingPageLeft.rotateAngleY = f6 - f6 * 2.0F * par3; + this.pagesRight.rotationPointX = MathHelper.sin(f6); + this.pagesLeft.rotationPointX = MathHelper.sin(f6); + this.flippingPageRight.rotationPointX = MathHelper.sin(f6); + this.flippingPageLeft.rotationPointX = MathHelper.sin(f6); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/ModelBox.java b/src/main/java/net/minecraft/client/model/ModelBox.java new file mode 100644 index 0000000..b27f287 --- /dev/null +++ b/src/main/java/net/minecraft/client/model/ModelBox.java @@ -0,0 +1,93 @@ +package net.minecraft.client.model; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.Tessellator; + +public class ModelBox +{ + private PositionTextureVertex[] vertexPositions; + private TexturedQuad[] quadList; + public final float posX1; + public final float posY1; + public final float posZ1; + public final float posX2; + public final float posY2; + public final float posZ2; + public String field_78247_g; + private static final String __OBFID = "CL_00000872"; + + public ModelBox(ModelRenderer par1ModelRenderer, int par2, int par3, float par4, float par5, float par6, int par7, int par8, int par9, float par10) + { + this.posX1 = par4; + this.posY1 = par5; + this.posZ1 = par6; + this.posX2 = par4 + (float)par7; + this.posY2 = par5 + (float)par8; + this.posZ2 = par6 + (float)par9; + this.vertexPositions = new PositionTextureVertex[8]; + this.quadList = new TexturedQuad[6]; + float f4 = par4 + (float)par7; + float f5 = par5 + (float)par8; + float f6 = par6 + (float)par9; + par4 -= par10; + par5 -= par10; + par6 -= par10; + f4 += par10; + f5 += par10; + f6 += par10; + + if (par1ModelRenderer.mirror) + { + float f7 = f4; + f4 = par4; + par4 = f7; + } + + PositionTextureVertex positiontexturevertex7 = new PositionTextureVertex(par4, par5, par6, 0.0F, 0.0F); + PositionTextureVertex positiontexturevertex = new PositionTextureVertex(f4, par5, par6, 0.0F, 8.0F); + PositionTextureVertex positiontexturevertex1 = new PositionTextureVertex(f4, f5, par6, 8.0F, 8.0F); + PositionTextureVertex positiontexturevertex2 = new PositionTextureVertex(par4, f5, par6, 8.0F, 0.0F); + PositionTextureVertex positiontexturevertex3 = new PositionTextureVertex(par4, par5, f6, 0.0F, 0.0F); + PositionTextureVertex positiontexturevertex4 = new PositionTextureVertex(f4, par5, f6, 0.0F, 8.0F); + PositionTextureVertex positiontexturevertex5 = new PositionTextureVertex(f4, f5, f6, 8.0F, 8.0F); + PositionTextureVertex positiontexturevertex6 = new PositionTextureVertex(par4, f5, f6, 8.0F, 0.0F); + this.vertexPositions[0] = positiontexturevertex7; + this.vertexPositions[1] = positiontexturevertex; + this.vertexPositions[2] = positiontexturevertex1; + this.vertexPositions[3] = positiontexturevertex2; + this.vertexPositions[4] = positiontexturevertex3; + this.vertexPositions[5] = positiontexturevertex4; + this.vertexPositions[6] = positiontexturevertex5; + this.vertexPositions[7] = positiontexturevertex6; + this.quadList[0] = new TexturedQuad(new PositionTextureVertex[] {positiontexturevertex4, positiontexturevertex, positiontexturevertex1, positiontexturevertex5}, par2 + par9 + par7, par3 + par9, par2 + par9 + par7 + par9, par3 + par9 + par8, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + this.quadList[1] = new TexturedQuad(new PositionTextureVertex[] {positiontexturevertex7, positiontexturevertex3, positiontexturevertex6, positiontexturevertex2}, par2, par3 + par9, par2 + par9, par3 + par9 + par8, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + this.quadList[2] = new TexturedQuad(new PositionTextureVertex[] {positiontexturevertex4, positiontexturevertex3, positiontexturevertex7, positiontexturevertex}, par2 + par9, par3, par2 + par9 + par7, par3 + par9, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + this.quadList[3] = new TexturedQuad(new PositionTextureVertex[] {positiontexturevertex1, positiontexturevertex2, positiontexturevertex6, positiontexturevertex5}, par2 + par9 + par7, par3 + par9, par2 + par9 + par7 + par7, par3, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + this.quadList[4] = new TexturedQuad(new PositionTextureVertex[] {positiontexturevertex, positiontexturevertex7, positiontexturevertex2, positiontexturevertex1}, par2 + par9, par3 + par9, par2 + par9 + par7, par3 + par9 + par8, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + this.quadList[5] = new TexturedQuad(new PositionTextureVertex[] {positiontexturevertex3, positiontexturevertex4, positiontexturevertex5, positiontexturevertex6}, par2 + par9 + par7 + par9, par3 + par9, par2 + par9 + par7 + par9 + par7, par3 + par9 + par8, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight); + + if (par1ModelRenderer.mirror) + { + for (int j1 = 0; j1 < this.quadList.length; ++j1) + { + this.quadList[j1].flipFace(); + } + } + } + + @SideOnly(Side.CLIENT) + public void render(Tessellator par1Tessellator, float par2) + { + for (int i = 0; i < this.quadList.length; ++i) + { + this.quadList[i].draw(par1Tessellator, par2); + } + } + + public ModelBox func_78244_a(String par1Str) + { + this.field_78247_g = par1Str; + return this; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/ModelChest.java b/src/main/java/net/minecraft/client/model/ModelChest.java new file mode 100644 index 0000000..0c33f9e --- /dev/null +++ b/src/main/java/net/minecraft/client/model/ModelChest.java @@ -0,0 +1,39 @@ +package net.minecraft.client.model; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class ModelChest extends ModelBase +{ + public ModelRenderer chestLid = (new ModelRenderer(this, 0, 0)).setTextureSize(64, 64); + public ModelRenderer chestBelow; + public ModelRenderer chestKnob; + private static final String __OBFID = "CL_00000834"; + + public ModelChest() + { + this.chestLid.addBox(0.0F, -5.0F, -14.0F, 14, 5, 14, 0.0F); + this.chestLid.rotationPointX = 1.0F; + this.chestLid.rotationPointY = 7.0F; + this.chestLid.rotationPointZ = 15.0F; + this.chestKnob = (new ModelRenderer(this, 0, 0)).setTextureSize(64, 64); + this.chestKnob.addBox(-1.0F, -2.0F, -15.0F, 2, 4, 1, 0.0F); + this.chestKnob.rotationPointX = 8.0F; + this.chestKnob.rotationPointY = 7.0F; + this.chestKnob.rotationPointZ = 15.0F; + this.chestBelow = (new ModelRenderer(this, 0, 19)).setTextureSize(64, 64); + this.chestBelow.addBox(0.0F, 0.0F, 0.0F, 14, 10, 14, 0.0F); + this.chestBelow.rotationPointX = 1.0F; + this.chestBelow.rotationPointY = 6.0F; + this.chestBelow.rotationPointZ = 1.0F; + } + + public void renderAll() + { + this.chestKnob.rotateAngleX = this.chestLid.rotateAngleX; + this.chestLid.render(0.0625F); + this.chestKnob.render(0.0625F); + this.chestBelow.render(0.0625F); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/ModelChicken.java b/src/main/java/net/minecraft/client/model/ModelChicken.java new file mode 100644 index 0000000..e4df9a0 --- /dev/null +++ b/src/main/java/net/minecraft/client/model/ModelChicken.java @@ -0,0 +1,101 @@ +package net.minecraft.client.model; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; +import net.minecraft.util.MathHelper; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class ModelChicken extends ModelBase +{ + public ModelRenderer head; + public ModelRenderer body; + public ModelRenderer rightLeg; + public ModelRenderer leftLeg; + public ModelRenderer rightWing; + public ModelRenderer leftWing; + public ModelRenderer bill; + public ModelRenderer chin; + private static final String __OBFID = "CL_00000835"; + + public ModelChicken() + { + byte b0 = 16; + this.head = new ModelRenderer(this, 0, 0); + this.head.addBox(-2.0F, -6.0F, -2.0F, 4, 6, 3, 0.0F); + this.head.setRotationPoint(0.0F, (float)(-1 + b0), -4.0F); + this.bill = new ModelRenderer(this, 14, 0); + this.bill.addBox(-2.0F, -4.0F, -4.0F, 4, 2, 2, 0.0F); + this.bill.setRotationPoint(0.0F, (float)(-1 + b0), -4.0F); + this.chin = new ModelRenderer(this, 14, 4); + this.chin.addBox(-1.0F, -2.0F, -3.0F, 2, 2, 2, 0.0F); + this.chin.setRotationPoint(0.0F, (float)(-1 + b0), -4.0F); + this.body = new ModelRenderer(this, 0, 9); + this.body.addBox(-3.0F, -4.0F, -3.0F, 6, 8, 6, 0.0F); + this.body.setRotationPoint(0.0F, (float)b0, 0.0F); + this.rightLeg = new ModelRenderer(this, 26, 0); + this.rightLeg.addBox(-1.0F, 0.0F, -3.0F, 3, 5, 3); + this.rightLeg.setRotationPoint(-2.0F, (float)(3 + b0), 1.0F); + this.leftLeg = new ModelRenderer(this, 26, 0); + this.leftLeg.addBox(-1.0F, 0.0F, -3.0F, 3, 5, 3); + this.leftLeg.setRotationPoint(1.0F, (float)(3 + b0), 1.0F); + this.rightWing = new ModelRenderer(this, 24, 13); + this.rightWing.addBox(0.0F, 0.0F, -3.0F, 1, 4, 6); + this.rightWing.setRotationPoint(-4.0F, (float)(-3 + b0), 0.0F); + this.leftWing = new ModelRenderer(this, 24, 13); + this.leftWing.addBox(-1.0F, 0.0F, -3.0F, 1, 4, 6); + this.leftWing.setRotationPoint(4.0F, (float)(-3 + b0), 0.0F); + } + + public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) + { + this.setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity); + + if (this.isChild) + { + float f6 = 2.0F; + GL11.glPushMatrix(); + GL11.glTranslatef(0.0F, 5.0F * par7, 2.0F * par7); + this.head.render(par7); + this.bill.render(par7); + this.chin.render(par7); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glScalef(1.0F / f6, 1.0F / f6, 1.0F / f6); + GL11.glTranslatef(0.0F, 24.0F * par7, 0.0F); + this.body.render(par7); + this.rightLeg.render(par7); + this.leftLeg.render(par7); + this.rightWing.render(par7); + this.leftWing.render(par7); + GL11.glPopMatrix(); + } + else + { + this.head.render(par7); + this.bill.render(par7); + this.chin.render(par7); + this.body.render(par7); + this.rightLeg.render(par7); + this.leftLeg.render(par7); + this.rightWing.render(par7); + this.leftWing.render(par7); + } + } + + public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) + { + this.head.rotateAngleX = par5 / (180F / (float)Math.PI); + this.head.rotateAngleY = par4 / (180F / (float)Math.PI); + this.bill.rotateAngleX = this.head.rotateAngleX; + this.bill.rotateAngleY = this.head.rotateAngleY; + this.chin.rotateAngleX = this.head.rotateAngleX; + this.chin.rotateAngleY = this.head.rotateAngleY; + this.body.rotateAngleX = ((float)Math.PI / 2F); + this.rightLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 1.4F * par2; + this.leftLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float)Math.PI) * 1.4F * par2; + this.rightWing.rotateAngleZ = par3; + this.leftWing.rotateAngleZ = -par3; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/ModelCow.java b/src/main/java/net/minecraft/client/model/ModelCow.java new file mode 100644 index 0000000..1de5766 --- /dev/null +++ b/src/main/java/net/minecraft/client/model/ModelCow.java @@ -0,0 +1,33 @@ +package net.minecraft.client.model; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class ModelCow extends ModelQuadruped +{ + private static final String __OBFID = "CL_00000836"; + + public ModelCow() + { + super(12, 0.0F); + this.head = new ModelRenderer(this, 0, 0); + this.head.addBox(-4.0F, -4.0F, -6.0F, 8, 8, 6, 0.0F); + this.head.setRotationPoint(0.0F, 4.0F, -8.0F); + this.head.setTextureOffset(22, 0).addBox(-5.0F, -5.0F, -4.0F, 1, 3, 1, 0.0F); + this.head.setTextureOffset(22, 0).addBox(4.0F, -5.0F, -4.0F, 1, 3, 1, 0.0F); + this.body = new ModelRenderer(this, 18, 4); + this.body.addBox(-6.0F, -10.0F, -7.0F, 12, 18, 10, 0.0F); + this.body.setRotationPoint(0.0F, 5.0F, 2.0F); + this.body.setTextureOffset(52, 0).addBox(-2.0F, 2.0F, -8.0F, 4, 6, 1); + --this.leg1.rotationPointX; + ++this.leg2.rotationPointX; + this.leg1.rotationPointZ += 0.0F; + this.leg2.rotationPointZ += 0.0F; + --this.leg3.rotationPointX; + ++this.leg4.rotationPointX; + --this.leg3.rotationPointZ; + --this.leg4.rotationPointZ; + this.field_78151_h += 2.0F; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/ModelCreeper.java b/src/main/java/net/minecraft/client/model/ModelCreeper.java new file mode 100644 index 0000000..90b0d4d --- /dev/null +++ b/src/main/java/net/minecraft/client/model/ModelCreeper.java @@ -0,0 +1,71 @@ +package net.minecraft.client.model; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; +import net.minecraft.util.MathHelper; + +@SideOnly(Side.CLIENT) +public class ModelCreeper extends ModelBase +{ + public ModelRenderer head; + public ModelRenderer field_78133_b; + public ModelRenderer body; + public ModelRenderer leg1; + public ModelRenderer leg2; + public ModelRenderer leg3; + public ModelRenderer leg4; + private static final String __OBFID = "CL_00000837"; + + public ModelCreeper() + { + this(0.0F); + } + + public ModelCreeper(float par1) + { + byte b0 = 4; + this.head = new ModelRenderer(this, 0, 0); + this.head.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, par1); + this.head.setRotationPoint(0.0F, (float)b0, 0.0F); + this.field_78133_b = new ModelRenderer(this, 32, 0); + this.field_78133_b.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, par1 + 0.5F); + this.field_78133_b.setRotationPoint(0.0F, (float)b0, 0.0F); + this.body = new ModelRenderer(this, 16, 16); + this.body.addBox(-4.0F, 0.0F, -2.0F, 8, 12, 4, par1); + this.body.setRotationPoint(0.0F, (float)b0, 0.0F); + this.leg1 = new ModelRenderer(this, 0, 16); + this.leg1.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, par1); + this.leg1.setRotationPoint(-2.0F, (float)(12 + b0), 4.0F); + this.leg2 = new ModelRenderer(this, 0, 16); + this.leg2.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, par1); + this.leg2.setRotationPoint(2.0F, (float)(12 + b0), 4.0F); + this.leg3 = new ModelRenderer(this, 0, 16); + this.leg3.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, par1); + this.leg3.setRotationPoint(-2.0F, (float)(12 + b0), -4.0F); + this.leg4 = new ModelRenderer(this, 0, 16); + this.leg4.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, par1); + this.leg4.setRotationPoint(2.0F, (float)(12 + b0), -4.0F); + } + + public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) + { + this.setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity); + this.head.render(par7); + this.body.render(par7); + this.leg1.render(par7); + this.leg2.render(par7); + this.leg3.render(par7); + this.leg4.render(par7); + } + + public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) + { + this.head.rotateAngleY = par4 / (180F / (float)Math.PI); + this.head.rotateAngleX = par5 / (180F / (float)Math.PI); + this.leg1.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 1.4F * par2; + this.leg2.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float)Math.PI) * 1.4F * par2; + this.leg3.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float)Math.PI) * 1.4F * par2; + this.leg4.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 1.4F * par2; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/ModelDragon.java b/src/main/java/net/minecraft/client/model/ModelDragon.java new file mode 100644 index 0000000..e77ca58 --- /dev/null +++ b/src/main/java/net/minecraft/client/model/ModelDragon.java @@ -0,0 +1,232 @@ +package net.minecraft.client.model; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.boss.EntityDragon; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class ModelDragon extends ModelBase +{ + private ModelRenderer head; + private ModelRenderer spine; + private ModelRenderer jaw; + private ModelRenderer body; + private ModelRenderer rearLeg; + private ModelRenderer frontLeg; + private ModelRenderer rearLegTip; + private ModelRenderer frontLegTip; + private ModelRenderer rearFoot; + private ModelRenderer frontFoot; + private ModelRenderer wing; + private ModelRenderer wingTip; + private float partialTicks; + private static final String __OBFID = "CL_00000870"; + + public ModelDragon(float par1) + { + this.textureWidth = 256; + this.textureHeight = 256; + this.setTextureOffset("body.body", 0, 0); + this.setTextureOffset("wing.skin", -56, 88); + this.setTextureOffset("wingtip.skin", -56, 144); + this.setTextureOffset("rearleg.main", 0, 0); + this.setTextureOffset("rearfoot.main", 112, 0); + this.setTextureOffset("rearlegtip.main", 196, 0); + this.setTextureOffset("head.upperhead", 112, 30); + this.setTextureOffset("wing.bone", 112, 88); + this.setTextureOffset("head.upperlip", 176, 44); + this.setTextureOffset("jaw.jaw", 176, 65); + this.setTextureOffset("frontleg.main", 112, 104); + this.setTextureOffset("wingtip.bone", 112, 136); + this.setTextureOffset("frontfoot.main", 144, 104); + this.setTextureOffset("neck.box", 192, 104); + this.setTextureOffset("frontlegtip.main", 226, 138); + this.setTextureOffset("body.scale", 220, 53); + this.setTextureOffset("head.scale", 0, 0); + this.setTextureOffset("neck.scale", 48, 0); + this.setTextureOffset("head.nostril", 112, 0); + float f1 = -16.0F; + this.head = new ModelRenderer(this, "head"); + this.head.addBox("upperlip", -6.0F, -1.0F, -8.0F + f1, 12, 5, 16); + this.head.addBox("upperhead", -8.0F, -8.0F, 6.0F + f1, 16, 16, 16); + this.head.mirror = true; + this.head.addBox("scale", -5.0F, -12.0F, 12.0F + f1, 2, 4, 6); + this.head.addBox("nostril", -5.0F, -3.0F, -6.0F + f1, 2, 2, 4); + this.head.mirror = false; + this.head.addBox("scale", 3.0F, -12.0F, 12.0F + f1, 2, 4, 6); + this.head.addBox("nostril", 3.0F, -3.0F, -6.0F + f1, 2, 2, 4); + this.jaw = new ModelRenderer(this, "jaw"); + this.jaw.setRotationPoint(0.0F, 4.0F, 8.0F + f1); + this.jaw.addBox("jaw", -6.0F, 0.0F, -16.0F, 12, 4, 16); + this.head.addChild(this.jaw); + this.spine = new ModelRenderer(this, "neck"); + this.spine.addBox("box", -5.0F, -5.0F, -5.0F, 10, 10, 10); + this.spine.addBox("scale", -1.0F, -9.0F, -3.0F, 2, 4, 6); + this.body = new ModelRenderer(this, "body"); + this.body.setRotationPoint(0.0F, 4.0F, 8.0F); + this.body.addBox("body", -12.0F, 0.0F, -16.0F, 24, 24, 64); + this.body.addBox("scale", -1.0F, -6.0F, -10.0F, 2, 6, 12); + this.body.addBox("scale", -1.0F, -6.0F, 10.0F, 2, 6, 12); + this.body.addBox("scale", -1.0F, -6.0F, 30.0F, 2, 6, 12); + this.wing = new ModelRenderer(this, "wing"); + this.wing.setRotationPoint(-12.0F, 5.0F, 2.0F); + this.wing.addBox("bone", -56.0F, -4.0F, -4.0F, 56, 8, 8); + this.wing.addBox("skin", -56.0F, 0.0F, 2.0F, 56, 0, 56); + this.wingTip = new ModelRenderer(this, "wingtip"); + this.wingTip.setRotationPoint(-56.0F, 0.0F, 0.0F); + this.wingTip.addBox("bone", -56.0F, -2.0F, -2.0F, 56, 4, 4); + this.wingTip.addBox("skin", -56.0F, 0.0F, 2.0F, 56, 0, 56); + this.wing.addChild(this.wingTip); + this.frontLeg = new ModelRenderer(this, "frontleg"); + this.frontLeg.setRotationPoint(-12.0F, 20.0F, 2.0F); + this.frontLeg.addBox("main", -4.0F, -4.0F, -4.0F, 8, 24, 8); + this.frontLegTip = new ModelRenderer(this, "frontlegtip"); + this.frontLegTip.setRotationPoint(0.0F, 20.0F, -1.0F); + this.frontLegTip.addBox("main", -3.0F, -1.0F, -3.0F, 6, 24, 6); + this.frontLeg.addChild(this.frontLegTip); + this.frontFoot = new ModelRenderer(this, "frontfoot"); + this.frontFoot.setRotationPoint(0.0F, 23.0F, 0.0F); + this.frontFoot.addBox("main", -4.0F, 0.0F, -12.0F, 8, 4, 16); + this.frontLegTip.addChild(this.frontFoot); + this.rearLeg = new ModelRenderer(this, "rearleg"); + this.rearLeg.setRotationPoint(-16.0F, 16.0F, 42.0F); + this.rearLeg.addBox("main", -8.0F, -4.0F, -8.0F, 16, 32, 16); + this.rearLegTip = new ModelRenderer(this, "rearlegtip"); + this.rearLegTip.setRotationPoint(0.0F, 32.0F, -4.0F); + this.rearLegTip.addBox("main", -6.0F, -2.0F, 0.0F, 12, 32, 12); + this.rearLeg.addChild(this.rearLegTip); + this.rearFoot = new ModelRenderer(this, "rearfoot"); + this.rearFoot.setRotationPoint(0.0F, 31.0F, 4.0F); + this.rearFoot.addBox("main", -9.0F, 0.0F, -20.0F, 18, 6, 24); + this.rearLegTip.addChild(this.rearFoot); + } + + public void setLivingAnimations(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4) + { + this.partialTicks = par4; + } + + public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) + { + GL11.glPushMatrix(); + EntityDragon entitydragon = (EntityDragon)par1Entity; + float f6 = entitydragon.prevAnimTime + (entitydragon.animTime - entitydragon.prevAnimTime) * this.partialTicks; + this.jaw.rotateAngleX = (float)(Math.sin((double)(f6 * (float)Math.PI * 2.0F)) + 1.0D) * 0.2F; + float f7 = (float)(Math.sin((double)(f6 * (float)Math.PI * 2.0F - 1.0F)) + 1.0D); + f7 = (f7 * f7 * 1.0F + f7 * 2.0F) * 0.05F; + GL11.glTranslatef(0.0F, f7 - 2.0F, -3.0F); + GL11.glRotatef(f7 * 2.0F, 1.0F, 0.0F, 0.0F); + float f8 = -30.0F; + float f10 = 0.0F; + float f11 = 1.5F; + double[] adouble = entitydragon.getMovementOffsets(6, this.partialTicks); + float f12 = this.updateRotations(entitydragon.getMovementOffsets(5, this.partialTicks)[0] - entitydragon.getMovementOffsets(10, this.partialTicks)[0]); + float f13 = this.updateRotations(entitydragon.getMovementOffsets(5, this.partialTicks)[0] + (double)(f12 / 2.0F)); + f8 += 2.0F; + float f14 = f6 * (float)Math.PI * 2.0F; + f8 = 20.0F; + float f9 = -12.0F; + float f15; + + for (int i = 0; i < 5; ++i) + { + double[] adouble1 = entitydragon.getMovementOffsets(5 - i, this.partialTicks); + f15 = (float)Math.cos((double)((float)i * 0.45F + f14)) * 0.15F; + this.spine.rotateAngleY = this.updateRotations(adouble1[0] - adouble[0]) * (float)Math.PI / 180.0F * f11; + this.spine.rotateAngleX = f15 + (float)(adouble1[1] - adouble[1]) * (float)Math.PI / 180.0F * f11 * 5.0F; + this.spine.rotateAngleZ = -this.updateRotations(adouble1[0] - (double)f13) * (float)Math.PI / 180.0F * f11; + this.spine.rotationPointY = f8; + this.spine.rotationPointZ = f9; + this.spine.rotationPointX = f10; + f8 = (float)((double)f8 + Math.sin((double)this.spine.rotateAngleX) * 10.0D); + f9 = (float)((double)f9 - Math.cos((double)this.spine.rotateAngleY) * Math.cos((double)this.spine.rotateAngleX) * 10.0D); + f10 = (float)((double)f10 - Math.sin((double)this.spine.rotateAngleY) * Math.cos((double)this.spine.rotateAngleX) * 10.0D); + this.spine.render(par7); + } + + this.head.rotationPointY = f8; + this.head.rotationPointZ = f9; + this.head.rotationPointX = f10; + double[] adouble2 = entitydragon.getMovementOffsets(0, this.partialTicks); + this.head.rotateAngleY = this.updateRotations(adouble2[0] - adouble[0]) * (float)Math.PI / 180.0F * 1.0F; + this.head.rotateAngleZ = -this.updateRotations(adouble2[0] - (double)f13) * (float)Math.PI / 180.0F * 1.0F; + this.head.render(par7); + GL11.glPushMatrix(); + GL11.glTranslatef(0.0F, 1.0F, 0.0F); + GL11.glRotatef(-f12 * f11 * 1.0F, 0.0F, 0.0F, 1.0F); + GL11.glTranslatef(0.0F, -1.0F, 0.0F); + this.body.rotateAngleZ = 0.0F; + this.body.render(par7); + + for (int j = 0; j < 2; ++j) + { + GL11.glEnable(GL11.GL_CULL_FACE); + f15 = f6 * (float)Math.PI * 2.0F; + this.wing.rotateAngleX = 0.125F - (float)Math.cos((double)f15) * 0.2F; + this.wing.rotateAngleY = 0.25F; + this.wing.rotateAngleZ = (float)(Math.sin((double)f15) + 0.125D) * 0.8F; + this.wingTip.rotateAngleZ = -((float)(Math.sin((double)(f15 + 2.0F)) + 0.5D)) * 0.75F; + this.rearLeg.rotateAngleX = 1.0F + f7 * 0.1F; + this.rearLegTip.rotateAngleX = 0.5F + f7 * 0.1F; + this.rearFoot.rotateAngleX = 0.75F + f7 * 0.1F; + this.frontLeg.rotateAngleX = 1.3F + f7 * 0.1F; + this.frontLegTip.rotateAngleX = -0.5F - f7 * 0.1F; + this.frontFoot.rotateAngleX = 0.75F + f7 * 0.1F; + this.wing.render(par7); + this.frontLeg.render(par7); + this.rearLeg.render(par7); + GL11.glScalef(-1.0F, 1.0F, 1.0F); + + if (j == 0) + { + GL11.glCullFace(GL11.GL_FRONT); + } + } + + GL11.glPopMatrix(); + GL11.glCullFace(GL11.GL_BACK); + GL11.glDisable(GL11.GL_CULL_FACE); + float f16 = -((float)Math.sin((double)(f6 * (float)Math.PI * 2.0F))) * 0.0F; + f14 = f6 * (float)Math.PI * 2.0F; + f8 = 10.0F; + f9 = 60.0F; + f10 = 0.0F; + adouble = entitydragon.getMovementOffsets(11, this.partialTicks); + + for (int k = 0; k < 12; ++k) + { + adouble2 = entitydragon.getMovementOffsets(12 + k, this.partialTicks); + f16 = (float)((double)f16 + Math.sin((double)((float)k * 0.45F + f14)) * 0.05000000074505806D); + this.spine.rotateAngleY = (this.updateRotations(adouble2[0] - adouble[0]) * f11 + 180.0F) * (float)Math.PI / 180.0F; + this.spine.rotateAngleX = f16 + (float)(adouble2[1] - adouble[1]) * (float)Math.PI / 180.0F * f11 * 5.0F; + this.spine.rotateAngleZ = this.updateRotations(adouble2[0] - (double)f13) * (float)Math.PI / 180.0F * f11; + this.spine.rotationPointY = f8; + this.spine.rotationPointZ = f9; + this.spine.rotationPointX = f10; + f8 = (float)((double)f8 + Math.sin((double)this.spine.rotateAngleX) * 10.0D); + f9 = (float)((double)f9 - Math.cos((double)this.spine.rotateAngleY) * Math.cos((double)this.spine.rotateAngleX) * 10.0D); + f10 = (float)((double)f10 - Math.sin((double)this.spine.rotateAngleY) * Math.cos((double)this.spine.rotateAngleX) * 10.0D); + this.spine.render(par7); + } + + GL11.glPopMatrix(); + } + + private float updateRotations(double par1) + { + while (par1 >= 180.0D) + { + par1 -= 360.0D; + } + + while (par1 < -180.0D) + { + par1 += 360.0D; + } + + return (float)par1; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/ModelEnderCrystal.java b/src/main/java/net/minecraft/client/model/ModelEnderCrystal.java new file mode 100644 index 0000000..40ebe30 --- /dev/null +++ b/src/main/java/net/minecraft/client/model/ModelEnderCrystal.java @@ -0,0 +1,55 @@ +package net.minecraft.client.model; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class ModelEnderCrystal extends ModelBase +{ + private ModelRenderer cube; + private ModelRenderer glass = new ModelRenderer(this, "glass"); + private ModelRenderer base; + private static final String __OBFID = "CL_00000871"; + + public ModelEnderCrystal(float par1, boolean par2) + { + this.glass.setTextureOffset(0, 0).addBox(-4.0F, -4.0F, -4.0F, 8, 8, 8); + this.cube = new ModelRenderer(this, "cube"); + this.cube.setTextureOffset(32, 0).addBox(-4.0F, -4.0F, -4.0F, 8, 8, 8); + + if (par2) + { + this.base = new ModelRenderer(this, "base"); + this.base.setTextureOffset(0, 16).addBox(-6.0F, 0.0F, -6.0F, 12, 4, 12); + } + } + + public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) + { + GL11.glPushMatrix(); + GL11.glScalef(2.0F, 2.0F, 2.0F); + GL11.glTranslatef(0.0F, -0.5F, 0.0F); + + if (this.base != null) + { + this.base.render(par7); + } + + GL11.glRotatef(par3, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(0.0F, 0.8F + par4, 0.0F); + GL11.glRotatef(60.0F, 0.7071F, 0.0F, 0.7071F); + this.glass.render(par7); + float f6 = 0.875F; + GL11.glScalef(f6, f6, f6); + GL11.glRotatef(60.0F, 0.7071F, 0.0F, 0.7071F); + GL11.glRotatef(par3, 0.0F, 1.0F, 0.0F); + this.glass.render(par7); + GL11.glScalef(f6, f6, f6); + GL11.glRotatef(60.0F, 0.7071F, 0.0F, 0.7071F); + GL11.glRotatef(par3, 0.0F, 1.0F, 0.0F); + this.cube.render(par7); + GL11.glPopMatrix(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/ModelEnderman.java b/src/main/java/net/minecraft/client/model/ModelEnderman.java new file mode 100644 index 0000000..2bf009d --- /dev/null +++ b/src/main/java/net/minecraft/client/model/ModelEnderman.java @@ -0,0 +1,126 @@ +package net.minecraft.client.model; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; + +@SideOnly(Side.CLIENT) +public class ModelEnderman extends ModelBiped +{ + public boolean isCarrying; + public boolean isAttacking; + private static final String __OBFID = "CL_00000838"; + + public ModelEnderman() + { + super(0.0F, -14.0F, 64, 32); + float f = -14.0F; + float f1 = 0.0F; + this.bipedHeadwear = new ModelRenderer(this, 0, 16); + this.bipedHeadwear.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, f1 - 0.5F); + this.bipedHeadwear.setRotationPoint(0.0F, 0.0F + f, 0.0F); + this.bipedBody = new ModelRenderer(this, 32, 16); + this.bipedBody.addBox(-4.0F, 0.0F, -2.0F, 8, 12, 4, f1); + this.bipedBody.setRotationPoint(0.0F, 0.0F + f, 0.0F); + this.bipedRightArm = new ModelRenderer(this, 56, 0); + this.bipedRightArm.addBox(-1.0F, -2.0F, -1.0F, 2, 30, 2, f1); + this.bipedRightArm.setRotationPoint(-3.0F, 2.0F + f, 0.0F); + this.bipedLeftArm = new ModelRenderer(this, 56, 0); + this.bipedLeftArm.mirror = true; + this.bipedLeftArm.addBox(-1.0F, -2.0F, -1.0F, 2, 30, 2, f1); + this.bipedLeftArm.setRotationPoint(5.0F, 2.0F + f, 0.0F); + this.bipedRightLeg = new ModelRenderer(this, 56, 0); + this.bipedRightLeg.addBox(-1.0F, 0.0F, -1.0F, 2, 30, 2, f1); + this.bipedRightLeg.setRotationPoint(-2.0F, 12.0F + f, 0.0F); + this.bipedLeftLeg = new ModelRenderer(this, 56, 0); + this.bipedLeftLeg.mirror = true; + this.bipedLeftLeg.addBox(-1.0F, 0.0F, -1.0F, 2, 30, 2, f1); + this.bipedLeftLeg.setRotationPoint(2.0F, 12.0F + f, 0.0F); + } + + public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) + { + super.setRotationAngles(par1, par2, par3, par4, par5, par6, par7Entity); + this.bipedHead.showModel = true; + float f6 = -14.0F; + this.bipedBody.rotateAngleX = 0.0F; + this.bipedBody.rotationPointY = f6; + this.bipedBody.rotationPointZ = -0.0F; + this.bipedRightLeg.rotateAngleX -= 0.0F; + this.bipedLeftLeg.rotateAngleX -= 0.0F; + this.bipedRightArm.rotateAngleX = (float)((double)this.bipedRightArm.rotateAngleX * 0.5D); + this.bipedLeftArm.rotateAngleX = (float)((double)this.bipedLeftArm.rotateAngleX * 0.5D); + this.bipedRightLeg.rotateAngleX = (float)((double)this.bipedRightLeg.rotateAngleX * 0.5D); + this.bipedLeftLeg.rotateAngleX = (float)((double)this.bipedLeftLeg.rotateAngleX * 0.5D); + float f7 = 0.4F; + + if (this.bipedRightArm.rotateAngleX > f7) + { + this.bipedRightArm.rotateAngleX = f7; + } + + if (this.bipedLeftArm.rotateAngleX > f7) + { + this.bipedLeftArm.rotateAngleX = f7; + } + + if (this.bipedRightArm.rotateAngleX < -f7) + { + this.bipedRightArm.rotateAngleX = -f7; + } + + if (this.bipedLeftArm.rotateAngleX < -f7) + { + this.bipedLeftArm.rotateAngleX = -f7; + } + + if (this.bipedRightLeg.rotateAngleX > f7) + { + this.bipedRightLeg.rotateAngleX = f7; + } + + if (this.bipedLeftLeg.rotateAngleX > f7) + { + this.bipedLeftLeg.rotateAngleX = f7; + } + + if (this.bipedRightLeg.rotateAngleX < -f7) + { + this.bipedRightLeg.rotateAngleX = -f7; + } + + if (this.bipedLeftLeg.rotateAngleX < -f7) + { + this.bipedLeftLeg.rotateAngleX = -f7; + } + + if (this.isCarrying) + { + this.bipedRightArm.rotateAngleX = -0.5F; + this.bipedLeftArm.rotateAngleX = -0.5F; + this.bipedRightArm.rotateAngleZ = 0.05F; + this.bipedLeftArm.rotateAngleZ = -0.05F; + } + + this.bipedRightArm.rotationPointZ = 0.0F; + this.bipedLeftArm.rotationPointZ = 0.0F; + this.bipedRightLeg.rotationPointZ = 0.0F; + this.bipedLeftLeg.rotationPointZ = 0.0F; + this.bipedRightLeg.rotationPointY = 9.0F + f6; + this.bipedLeftLeg.rotationPointY = 9.0F + f6; + this.bipedHead.rotationPointZ = -0.0F; + this.bipedHead.rotationPointY = f6 + 1.0F; + this.bipedHeadwear.rotationPointX = this.bipedHead.rotationPointX; + this.bipedHeadwear.rotationPointY = this.bipedHead.rotationPointY; + this.bipedHeadwear.rotationPointZ = this.bipedHead.rotationPointZ; + this.bipedHeadwear.rotateAngleX = this.bipedHead.rotateAngleX; + this.bipedHeadwear.rotateAngleY = this.bipedHead.rotateAngleY; + this.bipedHeadwear.rotateAngleZ = this.bipedHead.rotateAngleZ; + + if (this.isAttacking) + { + float f8 = 1.0F; + this.bipedHead.rotationPointY -= f8 * 5.0F; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/ModelGhast.java b/src/main/java/net/minecraft/client/model/ModelGhast.java new file mode 100644 index 0000000..875d52e --- /dev/null +++ b/src/main/java/net/minecraft/client/model/ModelGhast.java @@ -0,0 +1,63 @@ +package net.minecraft.client.model; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.entity.Entity; +import net.minecraft.util.MathHelper; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class ModelGhast extends ModelBase +{ + ModelRenderer body; + ModelRenderer[] tentacles = new ModelRenderer[9]; + private static final String __OBFID = "CL_00000839"; + + public ModelGhast() + { + byte b0 = -16; + this.body = new ModelRenderer(this, 0, 0); + this.body.addBox(-8.0F, -8.0F, -8.0F, 16, 16, 16); + this.body.rotationPointY += (float)(24 + b0); + Random random = new Random(1660L); + + for (int i = 0; i < this.tentacles.length; ++i) + { + this.tentacles[i] = new ModelRenderer(this, 0, 0); + float f = (((float)(i % 3) - (float)(i / 3 % 2) * 0.5F + 0.25F) / 2.0F * 2.0F - 1.0F) * 5.0F; + float f1 = ((float)(i / 3) / 2.0F * 2.0F - 1.0F) * 5.0F; + int j = random.nextInt(7) + 8; + this.tentacles[i].addBox(-1.0F, 0.0F, -1.0F, 2, j, 2); + this.tentacles[i].rotationPointX = f; + this.tentacles[i].rotationPointZ = f1; + this.tentacles[i].rotationPointY = (float)(31 + b0); + } + } + + public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) + { + for (int i = 0; i < this.tentacles.length; ++i) + { + this.tentacles[i].rotateAngleX = 0.2F * MathHelper.sin(par3 * 0.3F + (float)i) + 0.4F; + } + } + + public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) + { + this.setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity); + GL11.glPushMatrix(); + GL11.glTranslatef(0.0F, 0.6F, 0.0F); + this.body.render(par7); + ModelRenderer[] amodelrenderer = this.tentacles; + int i = amodelrenderer.length; + + for (int j = 0; j < i; ++j) + { + ModelRenderer modelrenderer = amodelrenderer[j]; + modelrenderer.render(par7); + } + + GL11.glPopMatrix(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/ModelHorse.java b/src/main/java/net/minecraft/client/model/ModelHorse.java new file mode 100644 index 0000000..b61f5d8 --- /dev/null +++ b/src/main/java/net/minecraft/client/model/ModelHorse.java @@ -0,0 +1,550 @@ +package net.minecraft.client.model; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.passive.EntityHorse; +import net.minecraft.util.MathHelper; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class ModelHorse extends ModelBase +{ + private ModelRenderer head; + private ModelRenderer mouthTop; + private ModelRenderer mouthBottom; + private ModelRenderer horseLeftEar; + private ModelRenderer horseRightEar; + private ModelRenderer muleLeftEar; + private ModelRenderer muleRightEar; + private ModelRenderer neck; + private ModelRenderer horseFaceRopes; + private ModelRenderer mane; + private ModelRenderer body; + private ModelRenderer tailBase; + private ModelRenderer tailMiddle; + private ModelRenderer tailTip; + private ModelRenderer backLeftLeg; + private ModelRenderer backLeftShin; + private ModelRenderer backLeftHoof; + private ModelRenderer backRightLeg; + private ModelRenderer backRightShin; + private ModelRenderer backRightHoof; + private ModelRenderer frontLeftLeg; + private ModelRenderer frontLeftShin; + private ModelRenderer frontLeftHoof; + private ModelRenderer frontRightLeg; + private ModelRenderer frontRightShin; + private ModelRenderer frontRightHoof; + private ModelRenderer muleLeftChest; + private ModelRenderer muleRightChest; + private ModelRenderer horseSaddleBottom; + private ModelRenderer horseSaddleFront; + private ModelRenderer horseSaddleBack; + private ModelRenderer horseLeftSaddleRope; + private ModelRenderer horseLeftSaddleMetal; + private ModelRenderer horseRightSaddleRope; + private ModelRenderer horseRightSaddleMetal; + private ModelRenderer horseLeftFaceMetal; + private ModelRenderer horseRightFaceMetal; + private ModelRenderer horseLeftRein; + private ModelRenderer horseRightRein; + private static final String __OBFID = "CL_00000846"; + + public ModelHorse() + { + this.textureWidth = 128; + this.textureHeight = 128; + this.body = new ModelRenderer(this, 0, 34); + this.body.addBox(-5.0F, -8.0F, -19.0F, 10, 10, 24); + this.body.setRotationPoint(0.0F, 11.0F, 9.0F); + this.tailBase = new ModelRenderer(this, 44, 0); + this.tailBase.addBox(-1.0F, -1.0F, 0.0F, 2, 2, 3); + this.tailBase.setRotationPoint(0.0F, 3.0F, 14.0F); + this.setBoxRotation(this.tailBase, -1.134464F, 0.0F, 0.0F); + this.tailMiddle = new ModelRenderer(this, 38, 7); + this.tailMiddle.addBox(-1.5F, -2.0F, 3.0F, 3, 4, 7); + this.tailMiddle.setRotationPoint(0.0F, 3.0F, 14.0F); + this.setBoxRotation(this.tailMiddle, -1.134464F, 0.0F, 0.0F); + this.tailTip = new ModelRenderer(this, 24, 3); + this.tailTip.addBox(-1.5F, -4.5F, 9.0F, 3, 4, 7); + this.tailTip.setRotationPoint(0.0F, 3.0F, 14.0F); + this.setBoxRotation(this.tailTip, -1.40215F, 0.0F, 0.0F); + this.backLeftLeg = new ModelRenderer(this, 78, 29); + this.backLeftLeg.addBox(-2.5F, -2.0F, -2.5F, 4, 9, 5); + this.backLeftLeg.setRotationPoint(4.0F, 9.0F, 11.0F); + this.backLeftShin = new ModelRenderer(this, 78, 43); + this.backLeftShin.addBox(-2.0F, 0.0F, -1.5F, 3, 5, 3); + this.backLeftShin.setRotationPoint(4.0F, 16.0F, 11.0F); + this.backLeftHoof = new ModelRenderer(this, 78, 51); + this.backLeftHoof.addBox(-2.5F, 5.1F, -2.0F, 4, 3, 4); + this.backLeftHoof.setRotationPoint(4.0F, 16.0F, 11.0F); + this.backRightLeg = new ModelRenderer(this, 96, 29); + this.backRightLeg.addBox(-1.5F, -2.0F, -2.5F, 4, 9, 5); + this.backRightLeg.setRotationPoint(-4.0F, 9.0F, 11.0F); + this.backRightShin = new ModelRenderer(this, 96, 43); + this.backRightShin.addBox(-1.0F, 0.0F, -1.5F, 3, 5, 3); + this.backRightShin.setRotationPoint(-4.0F, 16.0F, 11.0F); + this.backRightHoof = new ModelRenderer(this, 96, 51); + this.backRightHoof.addBox(-1.5F, 5.1F, -2.0F, 4, 3, 4); + this.backRightHoof.setRotationPoint(-4.0F, 16.0F, 11.0F); + this.frontLeftLeg = new ModelRenderer(this, 44, 29); + this.frontLeftLeg.addBox(-1.9F, -1.0F, -2.1F, 3, 8, 4); + this.frontLeftLeg.setRotationPoint(4.0F, 9.0F, -8.0F); + this.frontLeftShin = new ModelRenderer(this, 44, 41); + this.frontLeftShin.addBox(-1.9F, 0.0F, -1.6F, 3, 5, 3); + this.frontLeftShin.setRotationPoint(4.0F, 16.0F, -8.0F); + this.frontLeftHoof = new ModelRenderer(this, 44, 51); + this.frontLeftHoof.addBox(-2.4F, 5.1F, -2.1F, 4, 3, 4); + this.frontLeftHoof.setRotationPoint(4.0F, 16.0F, -8.0F); + this.frontRightLeg = new ModelRenderer(this, 60, 29); + this.frontRightLeg.addBox(-1.1F, -1.0F, -2.1F, 3, 8, 4); + this.frontRightLeg.setRotationPoint(-4.0F, 9.0F, -8.0F); + this.frontRightShin = new ModelRenderer(this, 60, 41); + this.frontRightShin.addBox(-1.1F, 0.0F, -1.6F, 3, 5, 3); + this.frontRightShin.setRotationPoint(-4.0F, 16.0F, -8.0F); + this.frontRightHoof = new ModelRenderer(this, 60, 51); + this.frontRightHoof.addBox(-1.6F, 5.1F, -2.1F, 4, 3, 4); + this.frontRightHoof.setRotationPoint(-4.0F, 16.0F, -8.0F); + this.head = new ModelRenderer(this, 0, 0); + this.head.addBox(-2.5F, -10.0F, -1.5F, 5, 5, 7); + this.head.setRotationPoint(0.0F, 4.0F, -10.0F); + this.setBoxRotation(this.head, 0.5235988F, 0.0F, 0.0F); + this.mouthTop = new ModelRenderer(this, 24, 18); + this.mouthTop.addBox(-2.0F, -10.0F, -7.0F, 4, 3, 6); + this.mouthTop.setRotationPoint(0.0F, 3.95F, -10.0F); + this.setBoxRotation(this.mouthTop, 0.5235988F, 0.0F, 0.0F); + this.mouthBottom = new ModelRenderer(this, 24, 27); + this.mouthBottom.addBox(-2.0F, -7.0F, -6.5F, 4, 2, 5); + this.mouthBottom.setRotationPoint(0.0F, 4.0F, -10.0F); + this.setBoxRotation(this.mouthBottom, 0.5235988F, 0.0F, 0.0F); + this.head.addChild(this.mouthTop); + this.head.addChild(this.mouthBottom); + this.horseLeftEar = new ModelRenderer(this, 0, 0); + this.horseLeftEar.addBox(0.45F, -12.0F, 4.0F, 2, 3, 1); + this.horseLeftEar.setRotationPoint(0.0F, 4.0F, -10.0F); + this.setBoxRotation(this.horseLeftEar, 0.5235988F, 0.0F, 0.0F); + this.horseRightEar = new ModelRenderer(this, 0, 0); + this.horseRightEar.addBox(-2.45F, -12.0F, 4.0F, 2, 3, 1); + this.horseRightEar.setRotationPoint(0.0F, 4.0F, -10.0F); + this.setBoxRotation(this.horseRightEar, 0.5235988F, 0.0F, 0.0F); + this.muleLeftEar = new ModelRenderer(this, 0, 12); + this.muleLeftEar.addBox(-2.0F, -16.0F, 4.0F, 2, 7, 1); + this.muleLeftEar.setRotationPoint(0.0F, 4.0F, -10.0F); + this.setBoxRotation(this.muleLeftEar, 0.5235988F, 0.0F, 0.2617994F); + this.muleRightEar = new ModelRenderer(this, 0, 12); + this.muleRightEar.addBox(0.0F, -16.0F, 4.0F, 2, 7, 1); + this.muleRightEar.setRotationPoint(0.0F, 4.0F, -10.0F); + this.setBoxRotation(this.muleRightEar, 0.5235988F, 0.0F, -0.2617994F); + this.neck = new ModelRenderer(this, 0, 12); + this.neck.addBox(-2.05F, -9.8F, -2.0F, 4, 14, 8); + this.neck.setRotationPoint(0.0F, 4.0F, -10.0F); + this.setBoxRotation(this.neck, 0.5235988F, 0.0F, 0.0F); + this.muleLeftChest = new ModelRenderer(this, 0, 34); + this.muleLeftChest.addBox(-3.0F, 0.0F, 0.0F, 8, 8, 3); + this.muleLeftChest.setRotationPoint(-7.5F, 3.0F, 10.0F); + this.setBoxRotation(this.muleLeftChest, 0.0F, ((float)Math.PI / 2F), 0.0F); + this.muleRightChest = new ModelRenderer(this, 0, 47); + this.muleRightChest.addBox(-3.0F, 0.0F, 0.0F, 8, 8, 3); + this.muleRightChest.setRotationPoint(4.5F, 3.0F, 10.0F); + this.setBoxRotation(this.muleRightChest, 0.0F, ((float)Math.PI / 2F), 0.0F); + this.horseSaddleBottom = new ModelRenderer(this, 80, 0); + this.horseSaddleBottom.addBox(-5.0F, 0.0F, -3.0F, 10, 1, 8); + this.horseSaddleBottom.setRotationPoint(0.0F, 2.0F, 2.0F); + this.horseSaddleFront = new ModelRenderer(this, 106, 9); + this.horseSaddleFront.addBox(-1.5F, -1.0F, -3.0F, 3, 1, 2); + this.horseSaddleFront.setRotationPoint(0.0F, 2.0F, 2.0F); + this.horseSaddleBack = new ModelRenderer(this, 80, 9); + this.horseSaddleBack.addBox(-4.0F, -1.0F, 3.0F, 8, 1, 2); + this.horseSaddleBack.setRotationPoint(0.0F, 2.0F, 2.0F); + this.horseLeftSaddleMetal = new ModelRenderer(this, 74, 0); + this.horseLeftSaddleMetal.addBox(-0.5F, 6.0F, -1.0F, 1, 2, 2); + this.horseLeftSaddleMetal.setRotationPoint(5.0F, 3.0F, 2.0F); + this.horseLeftSaddleRope = new ModelRenderer(this, 70, 0); + this.horseLeftSaddleRope.addBox(-0.5F, 0.0F, -0.5F, 1, 6, 1); + this.horseLeftSaddleRope.setRotationPoint(5.0F, 3.0F, 2.0F); + this.horseRightSaddleMetal = new ModelRenderer(this, 74, 4); + this.horseRightSaddleMetal.addBox(-0.5F, 6.0F, -1.0F, 1, 2, 2); + this.horseRightSaddleMetal.setRotationPoint(-5.0F, 3.0F, 2.0F); + this.horseRightSaddleRope = new ModelRenderer(this, 80, 0); + this.horseRightSaddleRope.addBox(-0.5F, 0.0F, -0.5F, 1, 6, 1); + this.horseRightSaddleRope.setRotationPoint(-5.0F, 3.0F, 2.0F); + this.horseLeftFaceMetal = new ModelRenderer(this, 74, 13); + this.horseLeftFaceMetal.addBox(1.5F, -8.0F, -4.0F, 1, 2, 2); + this.horseLeftFaceMetal.setRotationPoint(0.0F, 4.0F, -10.0F); + this.setBoxRotation(this.horseLeftFaceMetal, 0.5235988F, 0.0F, 0.0F); + this.horseRightFaceMetal = new ModelRenderer(this, 74, 13); + this.horseRightFaceMetal.addBox(-2.5F, -8.0F, -4.0F, 1, 2, 2); + this.horseRightFaceMetal.setRotationPoint(0.0F, 4.0F, -10.0F); + this.setBoxRotation(this.horseRightFaceMetal, 0.5235988F, 0.0F, 0.0F); + this.horseLeftRein = new ModelRenderer(this, 44, 10); + this.horseLeftRein.addBox(2.6F, -6.0F, -6.0F, 0, 3, 16); + this.horseLeftRein.setRotationPoint(0.0F, 4.0F, -10.0F); + this.horseRightRein = new ModelRenderer(this, 44, 5); + this.horseRightRein.addBox(-2.6F, -6.0F, -6.0F, 0, 3, 16); + this.horseRightRein.setRotationPoint(0.0F, 4.0F, -10.0F); + this.mane = new ModelRenderer(this, 58, 0); + this.mane.addBox(-1.0F, -11.5F, 5.0F, 2, 16, 4); + this.mane.setRotationPoint(0.0F, 4.0F, -10.0F); + this.setBoxRotation(this.mane, 0.5235988F, 0.0F, 0.0F); + this.horseFaceRopes = new ModelRenderer(this, 80, 12); + this.horseFaceRopes.addBox(-2.5F, -10.1F, -7.0F, 5, 5, 12, 0.2F); + this.horseFaceRopes.setRotationPoint(0.0F, 4.0F, -10.0F); + this.setBoxRotation(this.horseFaceRopes, 0.5235988F, 0.0F, 0.0F); + } + + public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) + { + EntityHorse entityhorse = (EntityHorse)par1Entity; + int i = entityhorse.getHorseType(); + float f6 = entityhorse.getGrassEatingAmount(0.0F); + boolean flag = entityhorse.isAdultHorse(); + boolean flag1 = flag && entityhorse.isHorseSaddled(); + boolean flag2 = flag && entityhorse.isChested(); + boolean flag3 = i == 1 || i == 2; + float f7 = entityhorse.getHorseSize(); + boolean flag4 = entityhorse.riddenByEntity != null; + + if (flag1) + { + this.horseFaceRopes.render(par7); + this.horseSaddleBottom.render(par7); + this.horseSaddleFront.render(par7); + this.horseSaddleBack.render(par7); + this.horseLeftSaddleRope.render(par7); + this.horseLeftSaddleMetal.render(par7); + this.horseRightSaddleRope.render(par7); + this.horseRightSaddleMetal.render(par7); + this.horseLeftFaceMetal.render(par7); + this.horseRightFaceMetal.render(par7); + + if (flag4) + { + this.horseLeftRein.render(par7); + this.horseRightRein.render(par7); + } + } + + if (!flag) + { + GL11.glPushMatrix(); + GL11.glScalef(f7, 0.5F + f7 * 0.5F, f7); + GL11.glTranslatef(0.0F, 0.95F * (1.0F - f7), 0.0F); + } + + this.backLeftLeg.render(par7); + this.backLeftShin.render(par7); + this.backLeftHoof.render(par7); + this.backRightLeg.render(par7); + this.backRightShin.render(par7); + this.backRightHoof.render(par7); + this.frontLeftLeg.render(par7); + this.frontLeftShin.render(par7); + this.frontLeftHoof.render(par7); + this.frontRightLeg.render(par7); + this.frontRightShin.render(par7); + this.frontRightHoof.render(par7); + + if (!flag) + { + GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glScalef(f7, f7, f7); + GL11.glTranslatef(0.0F, 1.35F * (1.0F - f7), 0.0F); + } + + this.body.render(par7); + this.tailBase.render(par7); + this.tailMiddle.render(par7); + this.tailTip.render(par7); + this.neck.render(par7); + this.mane.render(par7); + + if (!flag) + { + GL11.glPopMatrix(); + GL11.glPushMatrix(); + float f8 = 0.5F + f7 * f7 * 0.5F; + GL11.glScalef(f8, f8, f8); + + if (f6 <= 0.0F) + { + GL11.glTranslatef(0.0F, 1.35F * (1.0F - f7), 0.0F); + } + else + { + GL11.glTranslatef(0.0F, 0.9F * (1.0F - f7) * f6 + 1.35F * (1.0F - f7) * (1.0F - f6), 0.15F * (1.0F - f7) * f6); + } + } + + if (flag3) + { + this.muleLeftEar.render(par7); + this.muleRightEar.render(par7); + } + else + { + this.horseLeftEar.render(par7); + this.horseRightEar.render(par7); + } + + this.head.render(par7); + + if (!flag) + { + GL11.glPopMatrix(); + } + + if (flag2) + { + this.muleLeftChest.render(par7); + this.muleRightChest.render(par7); + } + } + + private void setBoxRotation(ModelRenderer par1ModelRenderer, float par2, float par3, float par4) + { + par1ModelRenderer.rotateAngleX = par2; + par1ModelRenderer.rotateAngleY = par3; + par1ModelRenderer.rotateAngleZ = par4; + } + + private float updateHorseRotation(float par1, float par2, float par3) + { + float f3; + + for (f3 = par2 - par1; f3 < -180.0F; f3 += 360.0F) + { + ; + } + + while (f3 >= 180.0F) + { + f3 -= 360.0F; + } + + return par1 + par3 * f3; + } + + public void setLivingAnimations(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4) + { + super.setLivingAnimations(par1EntityLivingBase, par2, par3, par4); + float f3 = this.updateHorseRotation(par1EntityLivingBase.prevRenderYawOffset, par1EntityLivingBase.renderYawOffset, par4); + float f4 = this.updateHorseRotation(par1EntityLivingBase.prevRotationYawHead, par1EntityLivingBase.rotationYawHead, par4); + float f5 = par1EntityLivingBase.prevRotationPitch + (par1EntityLivingBase.rotationPitch - par1EntityLivingBase.prevRotationPitch) * par4; + float f6 = f4 - f3; + float f7 = f5 / (180F / (float)Math.PI); + + if (f6 > 20.0F) + { + f6 = 20.0F; + } + + if (f6 < -20.0F) + { + f6 = -20.0F; + } + + if (par3 > 0.2F) + { + f7 += MathHelper.cos(par2 * 0.4F) * 0.15F * par3; + } + + EntityHorse entityhorse = (EntityHorse)par1EntityLivingBase; + float f8 = entityhorse.getGrassEatingAmount(par4); + float f9 = entityhorse.getRearingAmount(par4); + float f10 = 1.0F - f9; + float f11 = entityhorse.func_110201_q(par4); + boolean flag = entityhorse.field_110278_bp != 0; + boolean flag1 = entityhorse.isHorseSaddled(); + boolean flag2 = entityhorse.riddenByEntity != null; + float f12 = (float)par1EntityLivingBase.ticksExisted + par4; + float f13 = MathHelper.cos(par2 * 0.6662F + (float)Math.PI); + float f14 = f13 * 0.8F * par3; + this.head.rotationPointY = 4.0F; + this.head.rotationPointZ = -10.0F; + this.tailBase.rotationPointY = 3.0F; + this.tailMiddle.rotationPointZ = 14.0F; + this.muleRightChest.rotationPointY = 3.0F; + this.muleRightChest.rotationPointZ = 10.0F; + this.body.rotateAngleX = 0.0F; + this.head.rotateAngleX = 0.5235988F + f7; + this.head.rotateAngleY = f6 / (180F / (float)Math.PI); + this.head.rotateAngleX = f9 * (0.2617994F + f7) + f8 * 2.18166F + (1.0F - Math.max(f9, f8)) * this.head.rotateAngleX; + this.head.rotateAngleY = f9 * (f6 / (180F / (float)Math.PI)) + (1.0F - Math.max(f9, f8)) * this.head.rotateAngleY; + this.head.rotationPointY = f9 * -6.0F + f8 * 11.0F + (1.0F - Math.max(f9, f8)) * this.head.rotationPointY; + this.head.rotationPointZ = f9 * -1.0F + f8 * -10.0F + (1.0F - Math.max(f9, f8)) * this.head.rotationPointZ; + this.tailBase.rotationPointY = f9 * 9.0F + f10 * this.tailBase.rotationPointY; + this.tailMiddle.rotationPointZ = f9 * 18.0F + f10 * this.tailMiddle.rotationPointZ; + this.muleRightChest.rotationPointY = f9 * 5.5F + f10 * this.muleRightChest.rotationPointY; + this.muleRightChest.rotationPointZ = f9 * 15.0F + f10 * this.muleRightChest.rotationPointZ; + this.body.rotateAngleX = f9 * -((float)Math.PI / 4F) + f10 * this.body.rotateAngleX; + this.horseLeftEar.rotationPointY = this.head.rotationPointY; + this.horseRightEar.rotationPointY = this.head.rotationPointY; + this.muleLeftEar.rotationPointY = this.head.rotationPointY; + this.muleRightEar.rotationPointY = this.head.rotationPointY; + this.neck.rotationPointY = this.head.rotationPointY; + this.mouthTop.rotationPointY = 0.02F; + this.mouthBottom.rotationPointY = 0.0F; + this.mane.rotationPointY = this.head.rotationPointY; + this.horseLeftEar.rotationPointZ = this.head.rotationPointZ; + this.horseRightEar.rotationPointZ = this.head.rotationPointZ; + this.muleLeftEar.rotationPointZ = this.head.rotationPointZ; + this.muleRightEar.rotationPointZ = this.head.rotationPointZ; + this.neck.rotationPointZ = this.head.rotationPointZ; + this.mouthTop.rotationPointZ = 0.02F - f11 * 1.0F; + this.mouthBottom.rotationPointZ = 0.0F + f11 * 1.0F; + this.mane.rotationPointZ = this.head.rotationPointZ; + this.horseLeftEar.rotateAngleX = this.head.rotateAngleX; + this.horseRightEar.rotateAngleX = this.head.rotateAngleX; + this.muleLeftEar.rotateAngleX = this.head.rotateAngleX; + this.muleRightEar.rotateAngleX = this.head.rotateAngleX; + this.neck.rotateAngleX = this.head.rotateAngleX; + this.mouthTop.rotateAngleX = 0.0F - 0.09424778F * f11; + this.mouthBottom.rotateAngleX = 0.0F + 0.15707964F * f11; + this.mane.rotateAngleX = this.head.rotateAngleX; + this.horseLeftEar.rotateAngleY = this.head.rotateAngleY; + this.horseRightEar.rotateAngleY = this.head.rotateAngleY; + this.muleLeftEar.rotateAngleY = this.head.rotateAngleY; + this.muleRightEar.rotateAngleY = this.head.rotateAngleY; + this.neck.rotateAngleY = this.head.rotateAngleY; + this.mouthTop.rotateAngleY = 0.0F; + this.mouthBottom.rotateAngleY = 0.0F; + this.mane.rotateAngleY = this.head.rotateAngleY; + this.muleLeftChest.rotateAngleX = f14 / 5.0F; + this.muleRightChest.rotateAngleX = -f14 / 5.0F; + float f15 = ((float)Math.PI / 2F); + float f16 = ((float)Math.PI * 3F / 2F); + float f17 = -1.0471976F; + float f18 = 0.2617994F * f9; + float f19 = MathHelper.cos(f12 * 0.6F + (float)Math.PI); + this.frontLeftLeg.rotationPointY = -2.0F * f9 + 9.0F * f10; + this.frontLeftLeg.rotationPointZ = -2.0F * f9 + -8.0F * f10; + this.frontRightLeg.rotationPointY = this.frontLeftLeg.rotationPointY; + this.frontRightLeg.rotationPointZ = this.frontLeftLeg.rotationPointZ; + this.backLeftShin.rotationPointY = this.backLeftLeg.rotationPointY + MathHelper.sin(((float)Math.PI / 2F) + f18 + f10 * -f13 * 0.5F * par3) * 7.0F; + this.backLeftShin.rotationPointZ = this.backLeftLeg.rotationPointZ + MathHelper.cos(((float)Math.PI * 3F / 2F) + f18 + f10 * -f13 * 0.5F * par3) * 7.0F; + this.backRightShin.rotationPointY = this.backRightLeg.rotationPointY + MathHelper.sin(((float)Math.PI / 2F) + f18 + f10 * f13 * 0.5F * par3) * 7.0F; + this.backRightShin.rotationPointZ = this.backRightLeg.rotationPointZ + MathHelper.cos(((float)Math.PI * 3F / 2F) + f18 + f10 * f13 * 0.5F * par3) * 7.0F; + float f20 = (-1.0471976F + f19) * f9 + f14 * f10; + float f21 = (-1.0471976F + -f19) * f9 + -f14 * f10; + this.frontLeftShin.rotationPointY = this.frontLeftLeg.rotationPointY + MathHelper.sin(((float)Math.PI / 2F) + f20) * 7.0F; + this.frontLeftShin.rotationPointZ = this.frontLeftLeg.rotationPointZ + MathHelper.cos(((float)Math.PI * 3F / 2F) + f20) * 7.0F; + this.frontRightShin.rotationPointY = this.frontRightLeg.rotationPointY + MathHelper.sin(((float)Math.PI / 2F) + f21) * 7.0F; + this.frontRightShin.rotationPointZ = this.frontRightLeg.rotationPointZ + MathHelper.cos(((float)Math.PI * 3F / 2F) + f21) * 7.0F; + this.backLeftLeg.rotateAngleX = f18 + -f13 * 0.5F * par3 * f10; + this.backLeftShin.rotateAngleX = -0.08726646F * f9 + (-f13 * 0.5F * par3 - Math.max(0.0F, f13 * 0.5F * par3)) * f10; + this.backLeftHoof.rotateAngleX = this.backLeftShin.rotateAngleX; + this.backRightLeg.rotateAngleX = f18 + f13 * 0.5F * par3 * f10; + this.backRightShin.rotateAngleX = -0.08726646F * f9 + (f13 * 0.5F * par3 - Math.max(0.0F, -f13 * 0.5F * par3)) * f10; + this.backRightHoof.rotateAngleX = this.backRightShin.rotateAngleX; + this.frontLeftLeg.rotateAngleX = f20; + this.frontLeftShin.rotateAngleX = (this.frontLeftLeg.rotateAngleX + (float)Math.PI * Math.max(0.0F, 0.2F + f19 * 0.2F)) * f9 + (f14 + Math.max(0.0F, f13 * 0.5F * par3)) * f10; + this.frontLeftHoof.rotateAngleX = this.frontLeftShin.rotateAngleX; + this.frontRightLeg.rotateAngleX = f21; + this.frontRightShin.rotateAngleX = (this.frontRightLeg.rotateAngleX + (float)Math.PI * Math.max(0.0F, 0.2F - f19 * 0.2F)) * f9 + (-f14 + Math.max(0.0F, -f13 * 0.5F * par3)) * f10; + this.frontRightHoof.rotateAngleX = this.frontRightShin.rotateAngleX; + this.backLeftHoof.rotationPointY = this.backLeftShin.rotationPointY; + this.backLeftHoof.rotationPointZ = this.backLeftShin.rotationPointZ; + this.backRightHoof.rotationPointY = this.backRightShin.rotationPointY; + this.backRightHoof.rotationPointZ = this.backRightShin.rotationPointZ; + this.frontLeftHoof.rotationPointY = this.frontLeftShin.rotationPointY; + this.frontLeftHoof.rotationPointZ = this.frontLeftShin.rotationPointZ; + this.frontRightHoof.rotationPointY = this.frontRightShin.rotationPointY; + this.frontRightHoof.rotationPointZ = this.frontRightShin.rotationPointZ; + + if (flag1) + { + this.horseSaddleBottom.rotationPointY = f9 * 0.5F + f10 * 2.0F; + this.horseSaddleBottom.rotationPointZ = f9 * 11.0F + f10 * 2.0F; + this.horseSaddleFront.rotationPointY = this.horseSaddleBottom.rotationPointY; + this.horseSaddleBack.rotationPointY = this.horseSaddleBottom.rotationPointY; + this.horseLeftSaddleRope.rotationPointY = this.horseSaddleBottom.rotationPointY; + this.horseRightSaddleRope.rotationPointY = this.horseSaddleBottom.rotationPointY; + this.horseLeftSaddleMetal.rotationPointY = this.horseSaddleBottom.rotationPointY; + this.horseRightSaddleMetal.rotationPointY = this.horseSaddleBottom.rotationPointY; + this.muleLeftChest.rotationPointY = this.muleRightChest.rotationPointY; + this.horseSaddleFront.rotationPointZ = this.horseSaddleBottom.rotationPointZ; + this.horseSaddleBack.rotationPointZ = this.horseSaddleBottom.rotationPointZ; + this.horseLeftSaddleRope.rotationPointZ = this.horseSaddleBottom.rotationPointZ; + this.horseRightSaddleRope.rotationPointZ = this.horseSaddleBottom.rotationPointZ; + this.horseLeftSaddleMetal.rotationPointZ = this.horseSaddleBottom.rotationPointZ; + this.horseRightSaddleMetal.rotationPointZ = this.horseSaddleBottom.rotationPointZ; + this.muleLeftChest.rotationPointZ = this.muleRightChest.rotationPointZ; + this.horseSaddleBottom.rotateAngleX = this.body.rotateAngleX; + this.horseSaddleFront.rotateAngleX = this.body.rotateAngleX; + this.horseSaddleBack.rotateAngleX = this.body.rotateAngleX; + this.horseLeftRein.rotationPointY = this.head.rotationPointY; + this.horseRightRein.rotationPointY = this.head.rotationPointY; + this.horseFaceRopes.rotationPointY = this.head.rotationPointY; + this.horseLeftFaceMetal.rotationPointY = this.head.rotationPointY; + this.horseRightFaceMetal.rotationPointY = this.head.rotationPointY; + this.horseLeftRein.rotationPointZ = this.head.rotationPointZ; + this.horseRightRein.rotationPointZ = this.head.rotationPointZ; + this.horseFaceRopes.rotationPointZ = this.head.rotationPointZ; + this.horseLeftFaceMetal.rotationPointZ = this.head.rotationPointZ; + this.horseRightFaceMetal.rotationPointZ = this.head.rotationPointZ; + this.horseLeftRein.rotateAngleX = f7; + this.horseRightRein.rotateAngleX = f7; + this.horseFaceRopes.rotateAngleX = this.head.rotateAngleX; + this.horseLeftFaceMetal.rotateAngleX = this.head.rotateAngleX; + this.horseRightFaceMetal.rotateAngleX = this.head.rotateAngleX; + this.horseFaceRopes.rotateAngleY = this.head.rotateAngleY; + this.horseLeftFaceMetal.rotateAngleY = this.head.rotateAngleY; + this.horseLeftRein.rotateAngleY = this.head.rotateAngleY; + this.horseRightFaceMetal.rotateAngleY = this.head.rotateAngleY; + this.horseRightRein.rotateAngleY = this.head.rotateAngleY; + + if (flag2) + { + this.horseLeftSaddleRope.rotateAngleX = -1.0471976F; + this.horseLeftSaddleMetal.rotateAngleX = -1.0471976F; + this.horseRightSaddleRope.rotateAngleX = -1.0471976F; + this.horseRightSaddleMetal.rotateAngleX = -1.0471976F; + this.horseLeftSaddleRope.rotateAngleZ = 0.0F; + this.horseLeftSaddleMetal.rotateAngleZ = 0.0F; + this.horseRightSaddleRope.rotateAngleZ = 0.0F; + this.horseRightSaddleMetal.rotateAngleZ = 0.0F; + } + else + { + this.horseLeftSaddleRope.rotateAngleX = f14 / 3.0F; + this.horseLeftSaddleMetal.rotateAngleX = f14 / 3.0F; + this.horseRightSaddleRope.rotateAngleX = f14 / 3.0F; + this.horseRightSaddleMetal.rotateAngleX = f14 / 3.0F; + this.horseLeftSaddleRope.rotateAngleZ = f14 / 5.0F; + this.horseLeftSaddleMetal.rotateAngleZ = f14 / 5.0F; + this.horseRightSaddleRope.rotateAngleZ = -f14 / 5.0F; + this.horseRightSaddleMetal.rotateAngleZ = -f14 / 5.0F; + } + } + + f15 = -1.3089F + par3 * 1.5F; + + if (f15 > 0.0F) + { + f15 = 0.0F; + } + + if (flag) + { + this.tailBase.rotateAngleY = MathHelper.cos(f12 * 0.7F); + f15 = 0.0F; + } + else + { + this.tailBase.rotateAngleY = 0.0F; + } + + this.tailMiddle.rotateAngleY = this.tailBase.rotateAngleY; + this.tailTip.rotateAngleY = this.tailBase.rotateAngleY; + this.tailMiddle.rotationPointY = this.tailBase.rotationPointY; + this.tailTip.rotationPointY = this.tailBase.rotationPointY; + this.tailMiddle.rotationPointZ = this.tailBase.rotationPointZ; + this.tailTip.rotationPointZ = this.tailBase.rotationPointZ; + this.tailBase.rotateAngleX = f15; + this.tailMiddle.rotateAngleX = f15; + this.tailTip.rotateAngleX = -0.2618F + f15; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/ModelIronGolem.java b/src/main/java/net/minecraft/client/model/ModelIronGolem.java new file mode 100644 index 0000000..6026de0 --- /dev/null +++ b/src/main/java/net/minecraft/client/model/ModelIronGolem.java @@ -0,0 +1,109 @@ +package net.minecraft.client.model; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.monster.EntityIronGolem; + +@SideOnly(Side.CLIENT) +public class ModelIronGolem extends ModelBase +{ + public ModelRenderer ironGolemHead; + public ModelRenderer ironGolemBody; + public ModelRenderer ironGolemRightArm; + public ModelRenderer ironGolemLeftArm; + public ModelRenderer ironGolemLeftLeg; + public ModelRenderer ironGolemRightLeg; + private static final String __OBFID = "CL_00000863"; + + public ModelIronGolem() + { + this(0.0F); + } + + public ModelIronGolem(float par1) + { + this(par1, -7.0F); + } + + public ModelIronGolem(float par1, float par2) + { + short short1 = 128; + short short2 = 128; + this.ironGolemHead = (new ModelRenderer(this)).setTextureSize(short1, short2); + this.ironGolemHead.setRotationPoint(0.0F, 0.0F + par2, -2.0F); + this.ironGolemHead.setTextureOffset(0, 0).addBox(-4.0F, -12.0F, -5.5F, 8, 10, 8, par1); + this.ironGolemHead.setTextureOffset(24, 0).addBox(-1.0F, -5.0F, -7.5F, 2, 4, 2, par1); + this.ironGolemBody = (new ModelRenderer(this)).setTextureSize(short1, short2); + this.ironGolemBody.setRotationPoint(0.0F, 0.0F + par2, 0.0F); + this.ironGolemBody.setTextureOffset(0, 40).addBox(-9.0F, -2.0F, -6.0F, 18, 12, 11, par1); + this.ironGolemBody.setTextureOffset(0, 70).addBox(-4.5F, 10.0F, -3.0F, 9, 5, 6, par1 + 0.5F); + this.ironGolemRightArm = (new ModelRenderer(this)).setTextureSize(short1, short2); + this.ironGolemRightArm.setRotationPoint(0.0F, -7.0F, 0.0F); + this.ironGolemRightArm.setTextureOffset(60, 21).addBox(-13.0F, -2.5F, -3.0F, 4, 30, 6, par1); + this.ironGolemLeftArm = (new ModelRenderer(this)).setTextureSize(short1, short2); + this.ironGolemLeftArm.setRotationPoint(0.0F, -7.0F, 0.0F); + this.ironGolemLeftArm.setTextureOffset(60, 58).addBox(9.0F, -2.5F, -3.0F, 4, 30, 6, par1); + this.ironGolemLeftLeg = (new ModelRenderer(this, 0, 22)).setTextureSize(short1, short2); + this.ironGolemLeftLeg.setRotationPoint(-4.0F, 18.0F + par2, 0.0F); + this.ironGolemLeftLeg.setTextureOffset(37, 0).addBox(-3.5F, -3.0F, -3.0F, 6, 16, 5, par1); + this.ironGolemRightLeg = (new ModelRenderer(this, 0, 22)).setTextureSize(short1, short2); + this.ironGolemRightLeg.mirror = true; + this.ironGolemRightLeg.setTextureOffset(60, 0).setRotationPoint(5.0F, 18.0F + par2, 0.0F); + this.ironGolemRightLeg.addBox(-3.5F, -3.0F, -3.0F, 6, 16, 5, par1); + } + + public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) + { + this.setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity); + this.ironGolemHead.render(par7); + this.ironGolemBody.render(par7); + this.ironGolemLeftLeg.render(par7); + this.ironGolemRightLeg.render(par7); + this.ironGolemRightArm.render(par7); + this.ironGolemLeftArm.render(par7); + } + + public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) + { + this.ironGolemHead.rotateAngleY = par4 / (180F / (float)Math.PI); + this.ironGolemHead.rotateAngleX = par5 / (180F / (float)Math.PI); + this.ironGolemLeftLeg.rotateAngleX = -1.5F * this.func_78172_a(par1, 13.0F) * par2; + this.ironGolemRightLeg.rotateAngleX = 1.5F * this.func_78172_a(par1, 13.0F) * par2; + this.ironGolemLeftLeg.rotateAngleY = 0.0F; + this.ironGolemRightLeg.rotateAngleY = 0.0F; + } + + public void setLivingAnimations(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4) + { + EntityIronGolem entityirongolem = (EntityIronGolem)par1EntityLivingBase; + int i = entityirongolem.getAttackTimer(); + + if (i > 0) + { + this.ironGolemRightArm.rotateAngleX = -2.0F + 1.5F * this.func_78172_a((float)i - par4, 10.0F); + this.ironGolemLeftArm.rotateAngleX = -2.0F + 1.5F * this.func_78172_a((float)i - par4, 10.0F); + } + else + { + int j = entityirongolem.getHoldRoseTick(); + + if (j > 0) + { + this.ironGolemRightArm.rotateAngleX = -0.8F + 0.025F * this.func_78172_a((float)j, 70.0F); + this.ironGolemLeftArm.rotateAngleX = 0.0F; + } + else + { + this.ironGolemRightArm.rotateAngleX = (-0.2F + 1.5F * this.func_78172_a(par2, 13.0F)) * par3; + this.ironGolemLeftArm.rotateAngleX = (-0.2F - 1.5F * this.func_78172_a(par2, 13.0F)) * par3; + } + } + } + + private float func_78172_a(float par1, float par2) + { + return (Math.abs(par1 % par2 - par2 * 0.5F) - par2 * 0.25F) / (par2 * 0.25F); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/ModelLargeChest.java b/src/main/java/net/minecraft/client/model/ModelLargeChest.java new file mode 100644 index 0000000..6010e07 --- /dev/null +++ b/src/main/java/net/minecraft/client/model/ModelLargeChest.java @@ -0,0 +1,29 @@ +package net.minecraft.client.model; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class ModelLargeChest extends ModelChest +{ + private static final String __OBFID = "CL_00000841"; + + public ModelLargeChest() + { + this.chestLid = (new ModelRenderer(this, 0, 0)).setTextureSize(128, 64); + this.chestLid.addBox(0.0F, -5.0F, -14.0F, 30, 5, 14, 0.0F); + this.chestLid.rotationPointX = 1.0F; + this.chestLid.rotationPointY = 7.0F; + this.chestLid.rotationPointZ = 15.0F; + this.chestKnob = (new ModelRenderer(this, 0, 0)).setTextureSize(128, 64); + this.chestKnob.addBox(-1.0F, -2.0F, -15.0F, 2, 4, 1, 0.0F); + this.chestKnob.rotationPointX = 16.0F; + this.chestKnob.rotationPointY = 7.0F; + this.chestKnob.rotationPointZ = 15.0F; + this.chestBelow = (new ModelRenderer(this, 0, 19)).setTextureSize(128, 64); + this.chestBelow.addBox(0.0F, 0.0F, 0.0F, 30, 10, 14, 0.0F); + this.chestBelow.rotationPointX = 1.0F; + this.chestBelow.rotationPointY = 6.0F; + this.chestBelow.rotationPointZ = 1.0F; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/ModelLeashKnot.java b/src/main/java/net/minecraft/client/model/ModelLeashKnot.java new file mode 100644 index 0000000..14acab4 --- /dev/null +++ b/src/main/java/net/minecraft/client/model/ModelLeashKnot.java @@ -0,0 +1,39 @@ +package net.minecraft.client.model; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; + +@SideOnly(Side.CLIENT) +public class ModelLeashKnot extends ModelBase +{ + public ModelRenderer field_110723_a; + private static final String __OBFID = "CL_00000843"; + + public ModelLeashKnot() + { + this(0, 0, 32, 32); + } + + public ModelLeashKnot(int par1, int par2, int par3, int par4) + { + this.textureWidth = par3; + this.textureHeight = par4; + this.field_110723_a = new ModelRenderer(this, par1, par2); + this.field_110723_a.addBox(-3.0F, -6.0F, -3.0F, 6, 8, 6, 0.0F); + this.field_110723_a.setRotationPoint(0.0F, 0.0F, 0.0F); + } + + public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) + { + this.setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity); + this.field_110723_a.render(par7); + } + + public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) + { + super.setRotationAngles(par1, par2, par3, par4, par5, par6, par7Entity); + this.field_110723_a.rotateAngleY = par4 / (180F / (float)Math.PI); + this.field_110723_a.rotateAngleX = par5 / (180F / (float)Math.PI); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/ModelMagmaCube.java b/src/main/java/net/minecraft/client/model/ModelMagmaCube.java new file mode 100644 index 0000000..c99fc41 --- /dev/null +++ b/src/main/java/net/minecraft/client/model/ModelMagmaCube.java @@ -0,0 +1,68 @@ +package net.minecraft.client.model; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.monster.EntityMagmaCube; + +@SideOnly(Side.CLIENT) +public class ModelMagmaCube extends ModelBase +{ + ModelRenderer[] field_78109_a = new ModelRenderer[8]; + ModelRenderer field_78108_b; + private static final String __OBFID = "CL_00000842"; + + public ModelMagmaCube() + { + for (int i = 0; i < this.field_78109_a.length; ++i) + { + byte b0 = 0; + int j = i; + + if (i == 2) + { + b0 = 24; + j = 10; + } + else if (i == 3) + { + b0 = 24; + j = 19; + } + + this.field_78109_a[i] = new ModelRenderer(this, b0, j); + this.field_78109_a[i].addBox(-4.0F, (float)(16 + i), -4.0F, 8, 1, 8); + } + + this.field_78108_b = new ModelRenderer(this, 0, 16); + this.field_78108_b.addBox(-2.0F, 18.0F, -2.0F, 4, 4, 4); + } + + public void setLivingAnimations(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4) + { + EntityMagmaCube entitymagmacube = (EntityMagmaCube)par1EntityLivingBase; + float f3 = entitymagmacube.prevSquishFactor + (entitymagmacube.squishFactor - entitymagmacube.prevSquishFactor) * par4; + + if (f3 < 0.0F) + { + f3 = 0.0F; + } + + for (int i = 0; i < this.field_78109_a.length; ++i) + { + this.field_78109_a[i].rotationPointY = (float)(-(4 - i)) * f3 * 1.7F; + } + } + + public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) + { + this.setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity); + this.field_78108_b.render(par7); + + for (int i = 0; i < this.field_78109_a.length; ++i) + { + this.field_78109_a[i].render(par7); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/ModelMinecart.java b/src/main/java/net/minecraft/client/model/ModelMinecart.java new file mode 100644 index 0000000..1caadc5 --- /dev/null +++ b/src/main/java/net/minecraft/client/model/ModelMinecart.java @@ -0,0 +1,53 @@ +package net.minecraft.client.model; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; + +@SideOnly(Side.CLIENT) +public class ModelMinecart extends ModelBase +{ + public ModelRenderer[] sideModels = new ModelRenderer[7]; + private static final String __OBFID = "CL_00000844"; + + public ModelMinecart() + { + this.sideModels[0] = new ModelRenderer(this, 0, 10); + this.sideModels[1] = new ModelRenderer(this, 0, 0); + this.sideModels[2] = new ModelRenderer(this, 0, 0); + this.sideModels[3] = new ModelRenderer(this, 0, 0); + this.sideModels[4] = new ModelRenderer(this, 0, 0); + this.sideModels[5] = new ModelRenderer(this, 44, 10); + byte b0 = 20; + byte b1 = 8; + byte b2 = 16; + byte b3 = 4; + this.sideModels[0].addBox((float)(-b0 / 2), (float)(-b2 / 2), -1.0F, b0, b2, 2, 0.0F); + this.sideModels[0].setRotationPoint(0.0F, (float)b3, 0.0F); + this.sideModels[5].addBox((float)(-b0 / 2 + 1), (float)(-b2 / 2 + 1), -1.0F, b0 - 2, b2 - 2, 1, 0.0F); + this.sideModels[5].setRotationPoint(0.0F, (float)b3, 0.0F); + this.sideModels[1].addBox((float)(-b0 / 2 + 2), (float)(-b1 - 1), -1.0F, b0 - 4, b1, 2, 0.0F); + this.sideModels[1].setRotationPoint((float)(-b0 / 2 + 1), (float)b3, 0.0F); + this.sideModels[2].addBox((float)(-b0 / 2 + 2), (float)(-b1 - 1), -1.0F, b0 - 4, b1, 2, 0.0F); + this.sideModels[2].setRotationPoint((float)(b0 / 2 - 1), (float)b3, 0.0F); + this.sideModels[3].addBox((float)(-b0 / 2 + 2), (float)(-b1 - 1), -1.0F, b0 - 4, b1, 2, 0.0F); + this.sideModels[3].setRotationPoint(0.0F, (float)b3, (float)(-b2 / 2 + 1)); + this.sideModels[4].addBox((float)(-b0 / 2 + 2), (float)(-b1 - 1), -1.0F, b0 - 4, b1, 2, 0.0F); + this.sideModels[4].setRotationPoint(0.0F, (float)b3, (float)(b2 / 2 - 1)); + this.sideModels[0].rotateAngleX = ((float)Math.PI / 2F); + this.sideModels[1].rotateAngleY = ((float)Math.PI * 3F / 2F); + this.sideModels[2].rotateAngleY = ((float)Math.PI / 2F); + this.sideModels[3].rotateAngleY = (float)Math.PI; + this.sideModels[5].rotateAngleX = -((float)Math.PI / 2F); + } + + public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) + { + this.sideModels[5].rotationPointY = 4.0F - par4; + + for (int i = 0; i < 6; ++i) + { + this.sideModels[i].render(par7); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/ModelOcelot.java b/src/main/java/net/minecraft/client/model/ModelOcelot.java new file mode 100644 index 0000000..e0930e6 --- /dev/null +++ b/src/main/java/net/minecraft/client/model/ModelOcelot.java @@ -0,0 +1,196 @@ +package net.minecraft.client.model; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.passive.EntityOcelot; +import net.minecraft.util.MathHelper; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class ModelOcelot extends ModelBase +{ + ModelRenderer ocelotBackLeftLeg; + ModelRenderer ocelotBackRightLeg; + ModelRenderer ocelotFrontLeftLeg; + ModelRenderer ocelotFrontRightLeg; + ModelRenderer ocelotTail; + ModelRenderer ocelotTail2; + ModelRenderer ocelotHead; + ModelRenderer ocelotBody; + int field_78163_i = 1; + private static final String __OBFID = "CL_00000848"; + + public ModelOcelot() + { + this.setTextureOffset("head.main", 0, 0); + this.setTextureOffset("head.nose", 0, 24); + this.setTextureOffset("head.ear1", 0, 10); + this.setTextureOffset("head.ear2", 6, 10); + this.ocelotHead = new ModelRenderer(this, "head"); + this.ocelotHead.addBox("main", -2.5F, -2.0F, -3.0F, 5, 4, 5); + this.ocelotHead.addBox("nose", -1.5F, 0.0F, -4.0F, 3, 2, 2); + this.ocelotHead.addBox("ear1", -2.0F, -3.0F, 0.0F, 1, 1, 2); + this.ocelotHead.addBox("ear2", 1.0F, -3.0F, 0.0F, 1, 1, 2); + this.ocelotHead.setRotationPoint(0.0F, 15.0F, -9.0F); + this.ocelotBody = new ModelRenderer(this, 20, 0); + this.ocelotBody.addBox(-2.0F, 3.0F, -8.0F, 4, 16, 6, 0.0F); + this.ocelotBody.setRotationPoint(0.0F, 12.0F, -10.0F); + this.ocelotTail = new ModelRenderer(this, 0, 15); + this.ocelotTail.addBox(-0.5F, 0.0F, 0.0F, 1, 8, 1); + this.ocelotTail.rotateAngleX = 0.9F; + this.ocelotTail.setRotationPoint(0.0F, 15.0F, 8.0F); + this.ocelotTail2 = new ModelRenderer(this, 4, 15); + this.ocelotTail2.addBox(-0.5F, 0.0F, 0.0F, 1, 8, 1); + this.ocelotTail2.setRotationPoint(0.0F, 20.0F, 14.0F); + this.ocelotBackLeftLeg = new ModelRenderer(this, 8, 13); + this.ocelotBackLeftLeg.addBox(-1.0F, 0.0F, 1.0F, 2, 6, 2); + this.ocelotBackLeftLeg.setRotationPoint(1.1F, 18.0F, 5.0F); + this.ocelotBackRightLeg = new ModelRenderer(this, 8, 13); + this.ocelotBackRightLeg.addBox(-1.0F, 0.0F, 1.0F, 2, 6, 2); + this.ocelotBackRightLeg.setRotationPoint(-1.1F, 18.0F, 5.0F); + this.ocelotFrontLeftLeg = new ModelRenderer(this, 40, 0); + this.ocelotFrontLeftLeg.addBox(-1.0F, 0.0F, 0.0F, 2, 10, 2); + this.ocelotFrontLeftLeg.setRotationPoint(1.2F, 13.8F, -5.0F); + this.ocelotFrontRightLeg = new ModelRenderer(this, 40, 0); + this.ocelotFrontRightLeg.addBox(-1.0F, 0.0F, 0.0F, 2, 10, 2); + this.ocelotFrontRightLeg.setRotationPoint(-1.2F, 13.8F, -5.0F); + } + + public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) + { + this.setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity); + + if (this.isChild) + { + float f6 = 2.0F; + GL11.glPushMatrix(); + GL11.glScalef(1.5F / f6, 1.5F / f6, 1.5F / f6); + GL11.glTranslatef(0.0F, 10.0F * par7, 4.0F * par7); + this.ocelotHead.render(par7); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glScalef(1.0F / f6, 1.0F / f6, 1.0F / f6); + GL11.glTranslatef(0.0F, 24.0F * par7, 0.0F); + this.ocelotBody.render(par7); + this.ocelotBackLeftLeg.render(par7); + this.ocelotBackRightLeg.render(par7); + this.ocelotFrontLeftLeg.render(par7); + this.ocelotFrontRightLeg.render(par7); + this.ocelotTail.render(par7); + this.ocelotTail2.render(par7); + GL11.glPopMatrix(); + } + else + { + this.ocelotHead.render(par7); + this.ocelotBody.render(par7); + this.ocelotTail.render(par7); + this.ocelotTail2.render(par7); + this.ocelotBackLeftLeg.render(par7); + this.ocelotBackRightLeg.render(par7); + this.ocelotFrontLeftLeg.render(par7); + this.ocelotFrontRightLeg.render(par7); + } + } + + public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) + { + this.ocelotHead.rotateAngleX = par5 / (180F / (float)Math.PI); + this.ocelotHead.rotateAngleY = par4 / (180F / (float)Math.PI); + + if (this.field_78163_i != 3) + { + this.ocelotBody.rotateAngleX = ((float)Math.PI / 2F); + + if (this.field_78163_i == 2) + { + this.ocelotBackLeftLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 1.0F * par2; + this.ocelotBackRightLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F + 0.3F) * 1.0F * par2; + this.ocelotFrontLeftLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float)Math.PI + 0.3F) * 1.0F * par2; + this.ocelotFrontRightLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float)Math.PI) * 1.0F * par2; + this.ocelotTail2.rotateAngleX = 1.7278761F + ((float)Math.PI / 10F) * MathHelper.cos(par1) * par2; + } + else + { + this.ocelotBackLeftLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 1.0F * par2; + this.ocelotBackRightLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float)Math.PI) * 1.0F * par2; + this.ocelotFrontLeftLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float)Math.PI) * 1.0F * par2; + this.ocelotFrontRightLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 1.0F * par2; + + if (this.field_78163_i == 1) + { + this.ocelotTail2.rotateAngleX = 1.7278761F + ((float)Math.PI / 4F) * MathHelper.cos(par1) * par2; + } + else + { + this.ocelotTail2.rotateAngleX = 1.7278761F + 0.47123894F * MathHelper.cos(par1) * par2; + } + } + } + } + + public void setLivingAnimations(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4) + { + EntityOcelot entityocelot = (EntityOcelot)par1EntityLivingBase; + this.ocelotBody.rotationPointY = 12.0F; + this.ocelotBody.rotationPointZ = -10.0F; + this.ocelotHead.rotationPointY = 15.0F; + this.ocelotHead.rotationPointZ = -9.0F; + this.ocelotTail.rotationPointY = 15.0F; + this.ocelotTail.rotationPointZ = 8.0F; + this.ocelotTail2.rotationPointY = 20.0F; + this.ocelotTail2.rotationPointZ = 14.0F; + this.ocelotFrontLeftLeg.rotationPointY = this.ocelotFrontRightLeg.rotationPointY = 13.8F; + this.ocelotFrontLeftLeg.rotationPointZ = this.ocelotFrontRightLeg.rotationPointZ = -5.0F; + this.ocelotBackLeftLeg.rotationPointY = this.ocelotBackRightLeg.rotationPointY = 18.0F; + this.ocelotBackLeftLeg.rotationPointZ = this.ocelotBackRightLeg.rotationPointZ = 5.0F; + this.ocelotTail.rotateAngleX = 0.9F; + + if (entityocelot.isSneaking()) + { + ++this.ocelotBody.rotationPointY; + this.ocelotHead.rotationPointY += 2.0F; + ++this.ocelotTail.rotationPointY; + this.ocelotTail2.rotationPointY += -4.0F; + this.ocelotTail2.rotationPointZ += 2.0F; + this.ocelotTail.rotateAngleX = ((float)Math.PI / 2F); + this.ocelotTail2.rotateAngleX = ((float)Math.PI / 2F); + this.field_78163_i = 0; + } + else if (entityocelot.isSprinting()) + { + this.ocelotTail2.rotationPointY = this.ocelotTail.rotationPointY; + this.ocelotTail2.rotationPointZ += 2.0F; + this.ocelotTail.rotateAngleX = ((float)Math.PI / 2F); + this.ocelotTail2.rotateAngleX = ((float)Math.PI / 2F); + this.field_78163_i = 2; + } + else if (entityocelot.isSitting()) + { + this.ocelotBody.rotateAngleX = ((float)Math.PI / 4F); + this.ocelotBody.rotationPointY += -4.0F; + this.ocelotBody.rotationPointZ += 5.0F; + this.ocelotHead.rotationPointY += -3.3F; + ++this.ocelotHead.rotationPointZ; + this.ocelotTail.rotationPointY += 8.0F; + this.ocelotTail.rotationPointZ += -2.0F; + this.ocelotTail2.rotationPointY += 2.0F; + this.ocelotTail2.rotationPointZ += -0.8F; + this.ocelotTail.rotateAngleX = 1.7278761F; + this.ocelotTail2.rotateAngleX = 2.670354F; + this.ocelotFrontLeftLeg.rotateAngleX = this.ocelotFrontRightLeg.rotateAngleX = -0.15707964F; + this.ocelotFrontLeftLeg.rotationPointY = this.ocelotFrontRightLeg.rotationPointY = 15.8F; + this.ocelotFrontLeftLeg.rotationPointZ = this.ocelotFrontRightLeg.rotationPointZ = -7.0F; + this.ocelotBackLeftLeg.rotateAngleX = this.ocelotBackRightLeg.rotateAngleX = -((float)Math.PI / 2F); + this.ocelotBackLeftLeg.rotationPointY = this.ocelotBackRightLeg.rotationPointY = 21.0F; + this.ocelotBackLeftLeg.rotationPointZ = this.ocelotBackRightLeg.rotationPointZ = 1.0F; + this.field_78163_i = 3; + } + else + { + this.field_78163_i = 1; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/ModelPig.java b/src/main/java/net/minecraft/client/model/ModelPig.java new file mode 100644 index 0000000..11b36d5 --- /dev/null +++ b/src/main/java/net/minecraft/client/model/ModelPig.java @@ -0,0 +1,22 @@ +package net.minecraft.client.model; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class ModelPig extends ModelQuadruped +{ + private static final String __OBFID = "CL_00000849"; + + public ModelPig() + { + this(0.0F); + } + + public ModelPig(float par1) + { + super(6, par1); + this.head.setTextureOffset(16, 16).addBox(-2.0F, 0.0F, -9.0F, 4, 3, 1, par1); + this.field_78145_g = 4.0F; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/ModelQuadruped.java b/src/main/java/net/minecraft/client/model/ModelQuadruped.java new file mode 100644 index 0000000..7613ee3 --- /dev/null +++ b/src/main/java/net/minecraft/client/model/ModelQuadruped.java @@ -0,0 +1,86 @@ +package net.minecraft.client.model; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; +import net.minecraft.util.MathHelper; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class ModelQuadruped extends ModelBase +{ + public ModelRenderer head = new ModelRenderer(this, 0, 0); + public ModelRenderer body; + public ModelRenderer leg1; + public ModelRenderer leg2; + public ModelRenderer leg3; + public ModelRenderer leg4; + protected float field_78145_g = 8.0F; + protected float field_78151_h = 4.0F; + private static final String __OBFID = "CL_00000851"; + + public ModelQuadruped(int par1, float par2) + { + this.head.addBox(-4.0F, -4.0F, -8.0F, 8, 8, 8, par2); + this.head.setRotationPoint(0.0F, (float)(18 - par1), -6.0F); + this.body = new ModelRenderer(this, 28, 8); + this.body.addBox(-5.0F, -10.0F, -7.0F, 10, 16, 8, par2); + this.body.setRotationPoint(0.0F, (float)(17 - par1), 2.0F); + this.leg1 = new ModelRenderer(this, 0, 16); + this.leg1.addBox(-2.0F, 0.0F, -2.0F, 4, par1, 4, par2); + this.leg1.setRotationPoint(-3.0F, (float)(24 - par1), 7.0F); + this.leg2 = new ModelRenderer(this, 0, 16); + this.leg2.addBox(-2.0F, 0.0F, -2.0F, 4, par1, 4, par2); + this.leg2.setRotationPoint(3.0F, (float)(24 - par1), 7.0F); + this.leg3 = new ModelRenderer(this, 0, 16); + this.leg3.addBox(-2.0F, 0.0F, -2.0F, 4, par1, 4, par2); + this.leg3.setRotationPoint(-3.0F, (float)(24 - par1), -5.0F); + this.leg4 = new ModelRenderer(this, 0, 16); + this.leg4.addBox(-2.0F, 0.0F, -2.0F, 4, par1, 4, par2); + this.leg4.setRotationPoint(3.0F, (float)(24 - par1), -5.0F); + } + + public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) + { + this.setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity); + + if (this.isChild) + { + float f6 = 2.0F; + GL11.glPushMatrix(); + GL11.glTranslatef(0.0F, this.field_78145_g * par7, this.field_78151_h * par7); + this.head.render(par7); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glScalef(1.0F / f6, 1.0F / f6, 1.0F / f6); + GL11.glTranslatef(0.0F, 24.0F * par7, 0.0F); + this.body.render(par7); + this.leg1.render(par7); + this.leg2.render(par7); + this.leg3.render(par7); + this.leg4.render(par7); + GL11.glPopMatrix(); + } + else + { + this.head.render(par7); + this.body.render(par7); + this.leg1.render(par7); + this.leg2.render(par7); + this.leg3.render(par7); + this.leg4.render(par7); + } + } + + public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) + { + float f6 = (180F / (float)Math.PI); + this.head.rotateAngleX = par5 / (180F / (float)Math.PI); + this.head.rotateAngleY = par4 / (180F / (float)Math.PI); + this.body.rotateAngleX = ((float)Math.PI / 2F); + this.leg1.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 1.4F * par2; + this.leg2.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float)Math.PI) * 1.4F * par2; + this.leg3.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float)Math.PI) * 1.4F * par2; + this.leg4.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 1.4F * par2; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/ModelRenderer.java b/src/main/java/net/minecraft/client/model/ModelRenderer.java new file mode 100644 index 0000000..76e8aad --- /dev/null +++ b/src/main/java/net/minecraft/client/model/ModelRenderer.java @@ -0,0 +1,287 @@ +package net.minecraft.client.model; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.List; +import net.minecraft.client.renderer.GLAllocation; +import net.minecraft.client.renderer.Tessellator; +import org.lwjgl.opengl.GL11; + +public class ModelRenderer +{ + public float textureWidth; + public float textureHeight; + private int textureOffsetX; + private int textureOffsetY; + public float rotationPointX; + public float rotationPointY; + public float rotationPointZ; + public float rotateAngleX; + public float rotateAngleY; + public float rotateAngleZ; + private boolean compiled; + private int displayList; + public boolean mirror; + public boolean showModel; + public boolean isHidden; + public List cubeList; + public List childModels; + public final String boxName; + private ModelBase baseModel; + public float offsetX; + public float offsetY; + public float offsetZ; + private static final String __OBFID = "CL_00000874"; + + public ModelRenderer(ModelBase par1ModelBase, String par2Str) + { + this.textureWidth = 64.0F; + this.textureHeight = 32.0F; + this.showModel = true; + this.cubeList = new ArrayList(); + this.baseModel = par1ModelBase; + par1ModelBase.boxList.add(this); + this.boxName = par2Str; + this.setTextureSize(par1ModelBase.textureWidth, par1ModelBase.textureHeight); + } + + public ModelRenderer(ModelBase par1ModelBase) + { + this(par1ModelBase, (String)null); + } + + public ModelRenderer(ModelBase par1ModelBase, int par2, int par3) + { + this(par1ModelBase); + this.setTextureOffset(par2, par3); + } + + public void addChild(ModelRenderer par1ModelRenderer) + { + if (this.childModels == null) + { + this.childModels = new ArrayList(); + } + + this.childModels.add(par1ModelRenderer); + } + + public ModelRenderer setTextureOffset(int par1, int par2) + { + this.textureOffsetX = par1; + this.textureOffsetY = par2; + return this; + } + + public ModelRenderer addBox(String par1Str, float par2, float par3, float par4, int par5, int par6, int par7) + { + par1Str = this.boxName + "." + par1Str; + TextureOffset textureoffset = this.baseModel.getTextureOffset(par1Str); + this.setTextureOffset(textureoffset.textureOffsetX, textureoffset.textureOffsetY); + this.cubeList.add((new ModelBox(this, this.textureOffsetX, this.textureOffsetY, par2, par3, par4, par5, par6, par7, 0.0F)).func_78244_a(par1Str)); + return this; + } + + public ModelRenderer addBox(float par1, float par2, float par3, int par4, int par5, int par6) + { + this.cubeList.add(new ModelBox(this, this.textureOffsetX, this.textureOffsetY, par1, par2, par3, par4, par5, par6, 0.0F)); + return this; + } + + public void addBox(float par1, float par2, float par3, int par4, int par5, int par6, float par7) + { + this.cubeList.add(new ModelBox(this, this.textureOffsetX, this.textureOffsetY, par1, par2, par3, par4, par5, par6, par7)); + } + + public void setRotationPoint(float par1, float par2, float par3) + { + this.rotationPointX = par1; + this.rotationPointY = par2; + this.rotationPointZ = par3; + } + + @SideOnly(Side.CLIENT) + public void render(float par1) + { + if (!this.isHidden) + { + if (this.showModel) + { + if (!this.compiled) + { + this.compileDisplayList(par1); + } + + GL11.glTranslatef(this.offsetX, this.offsetY, this.offsetZ); + int i; + + if (this.rotateAngleX == 0.0F && this.rotateAngleY == 0.0F && this.rotateAngleZ == 0.0F) + { + if (this.rotationPointX == 0.0F && this.rotationPointY == 0.0F && this.rotationPointZ == 0.0F) + { + GL11.glCallList(this.displayList); + + if (this.childModels != null) + { + for (i = 0; i < this.childModels.size(); ++i) + { + ((ModelRenderer)this.childModels.get(i)).render(par1); + } + } + } + else + { + GL11.glTranslatef(this.rotationPointX * par1, this.rotationPointY * par1, this.rotationPointZ * par1); + GL11.glCallList(this.displayList); + + if (this.childModels != null) + { + for (i = 0; i < this.childModels.size(); ++i) + { + ((ModelRenderer)this.childModels.get(i)).render(par1); + } + } + + GL11.glTranslatef(-this.rotationPointX * par1, -this.rotationPointY * par1, -this.rotationPointZ * par1); + } + } + else + { + GL11.glPushMatrix(); + GL11.glTranslatef(this.rotationPointX * par1, this.rotationPointY * par1, this.rotationPointZ * par1); + + if (this.rotateAngleZ != 0.0F) + { + GL11.glRotatef(this.rotateAngleZ * (180F / (float)Math.PI), 0.0F, 0.0F, 1.0F); + } + + if (this.rotateAngleY != 0.0F) + { + GL11.glRotatef(this.rotateAngleY * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F); + } + + if (this.rotateAngleX != 0.0F) + { + GL11.glRotatef(this.rotateAngleX * (180F / (float)Math.PI), 1.0F, 0.0F, 0.0F); + } + + GL11.glCallList(this.displayList); + + if (this.childModels != null) + { + for (i = 0; i < this.childModels.size(); ++i) + { + ((ModelRenderer)this.childModels.get(i)).render(par1); + } + } + + GL11.glPopMatrix(); + } + + GL11.glTranslatef(-this.offsetX, -this.offsetY, -this.offsetZ); + } + } + } + + @SideOnly(Side.CLIENT) + public void renderWithRotation(float par1) + { + if (!this.isHidden) + { + if (this.showModel) + { + if (!this.compiled) + { + this.compileDisplayList(par1); + } + + GL11.glPushMatrix(); + GL11.glTranslatef(this.rotationPointX * par1, this.rotationPointY * par1, this.rotationPointZ * par1); + + if (this.rotateAngleY != 0.0F) + { + GL11.glRotatef(this.rotateAngleY * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F); + } + + if (this.rotateAngleX != 0.0F) + { + GL11.glRotatef(this.rotateAngleX * (180F / (float)Math.PI), 1.0F, 0.0F, 0.0F); + } + + if (this.rotateAngleZ != 0.0F) + { + GL11.glRotatef(this.rotateAngleZ * (180F / (float)Math.PI), 0.0F, 0.0F, 1.0F); + } + + GL11.glCallList(this.displayList); + GL11.glPopMatrix(); + } + } + } + + @SideOnly(Side.CLIENT) + public void postRender(float par1) + { + if (!this.isHidden) + { + if (this.showModel) + { + if (!this.compiled) + { + this.compileDisplayList(par1); + } + + if (this.rotateAngleX == 0.0F && this.rotateAngleY == 0.0F && this.rotateAngleZ == 0.0F) + { + if (this.rotationPointX != 0.0F || this.rotationPointY != 0.0F || this.rotationPointZ != 0.0F) + { + GL11.glTranslatef(this.rotationPointX * par1, this.rotationPointY * par1, this.rotationPointZ * par1); + } + } + else + { + GL11.glTranslatef(this.rotationPointX * par1, this.rotationPointY * par1, this.rotationPointZ * par1); + + if (this.rotateAngleZ != 0.0F) + { + GL11.glRotatef(this.rotateAngleZ * (180F / (float)Math.PI), 0.0F, 0.0F, 1.0F); + } + + if (this.rotateAngleY != 0.0F) + { + GL11.glRotatef(this.rotateAngleY * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F); + } + + if (this.rotateAngleX != 0.0F) + { + GL11.glRotatef(this.rotateAngleX * (180F / (float)Math.PI), 1.0F, 0.0F, 0.0F); + } + } + } + } + } + + @SideOnly(Side.CLIENT) + private void compileDisplayList(float par1) + { + this.displayList = GLAllocation.generateDisplayLists(1); + GL11.glNewList(this.displayList, GL11.GL_COMPILE); + Tessellator tessellator = Tessellator.instance; + + for (int i = 0; i < this.cubeList.size(); ++i) + { + ((ModelBox)this.cubeList.get(i)).render(tessellator, par1); + } + + GL11.glEndList(); + this.compiled = true; + } + + public ModelRenderer setTextureSize(int par1, int par2) + { + this.textureWidth = (float)par1; + this.textureHeight = (float)par2; + return this; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/ModelSheep1.java b/src/main/java/net/minecraft/client/model/ModelSheep1.java new file mode 100644 index 0000000..4c2a800 --- /dev/null +++ b/src/main/java/net/minecraft/client/model/ModelSheep1.java @@ -0,0 +1,51 @@ +package net.minecraft.client.model; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.passive.EntitySheep; + +@SideOnly(Side.CLIENT) +public class ModelSheep1 extends ModelQuadruped +{ + private float field_78152_i; + private static final String __OBFID = "CL_00000852"; + + public ModelSheep1() + { + super(12, 0.0F); + this.head = new ModelRenderer(this, 0, 0); + this.head.addBox(-3.0F, -4.0F, -4.0F, 6, 6, 6, 0.6F); + this.head.setRotationPoint(0.0F, 6.0F, -8.0F); + this.body = new ModelRenderer(this, 28, 8); + this.body.addBox(-4.0F, -10.0F, -7.0F, 8, 16, 6, 1.75F); + this.body.setRotationPoint(0.0F, 5.0F, 2.0F); + float f = 0.5F; + this.leg1 = new ModelRenderer(this, 0, 16); + this.leg1.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, f); + this.leg1.setRotationPoint(-3.0F, 12.0F, 7.0F); + this.leg2 = new ModelRenderer(this, 0, 16); + this.leg2.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, f); + this.leg2.setRotationPoint(3.0F, 12.0F, 7.0F); + this.leg3 = new ModelRenderer(this, 0, 16); + this.leg3.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, f); + this.leg3.setRotationPoint(-3.0F, 12.0F, -5.0F); + this.leg4 = new ModelRenderer(this, 0, 16); + this.leg4.addBox(-2.0F, 0.0F, -2.0F, 4, 6, 4, f); + this.leg4.setRotationPoint(3.0F, 12.0F, -5.0F); + } + + public void setLivingAnimations(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4) + { + super.setLivingAnimations(par1EntityLivingBase, par2, par3, par4); + this.head.rotationPointY = 6.0F + ((EntitySheep)par1EntityLivingBase).func_70894_j(par4) * 9.0F; + this.field_78152_i = ((EntitySheep)par1EntityLivingBase).func_70890_k(par4); + } + + public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) + { + super.setRotationAngles(par1, par2, par3, par4, par5, par6, par7Entity); + this.head.rotateAngleX = this.field_78152_i; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/ModelSheep2.java b/src/main/java/net/minecraft/client/model/ModelSheep2.java new file mode 100644 index 0000000..fed9ff1 --- /dev/null +++ b/src/main/java/net/minecraft/client/model/ModelSheep2.java @@ -0,0 +1,38 @@ +package net.minecraft.client.model; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.passive.EntitySheep; + +@SideOnly(Side.CLIENT) +public class ModelSheep2 extends ModelQuadruped +{ + private float field_78153_i; + private static final String __OBFID = "CL_00000853"; + + public ModelSheep2() + { + super(12, 0.0F); + this.head = new ModelRenderer(this, 0, 0); + this.head.addBox(-3.0F, -4.0F, -6.0F, 6, 6, 8, 0.0F); + this.head.setRotationPoint(0.0F, 6.0F, -8.0F); + this.body = new ModelRenderer(this, 28, 8); + this.body.addBox(-4.0F, -10.0F, -7.0F, 8, 16, 6, 0.0F); + this.body.setRotationPoint(0.0F, 5.0F, 2.0F); + } + + public void setLivingAnimations(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4) + { + super.setLivingAnimations(par1EntityLivingBase, par2, par3, par4); + this.head.rotationPointY = 6.0F + ((EntitySheep)par1EntityLivingBase).func_70894_j(par4) * 9.0F; + this.field_78153_i = ((EntitySheep)par1EntityLivingBase).func_70890_k(par4); + } + + public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) + { + super.setRotationAngles(par1, par2, par3, par4, par5, par6, par7Entity); + this.head.rotateAngleX = this.field_78153_i; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/ModelSign.java b/src/main/java/net/minecraft/client/model/ModelSign.java new file mode 100644 index 0000000..8408350 --- /dev/null +++ b/src/main/java/net/minecraft/client/model/ModelSign.java @@ -0,0 +1,25 @@ +package net.minecraft.client.model; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class ModelSign extends ModelBase +{ + public ModelRenderer signBoard = new ModelRenderer(this, 0, 0); + public ModelRenderer signStick; + private static final String __OBFID = "CL_00000854"; + + public ModelSign() + { + this.signBoard.addBox(-12.0F, -14.0F, -1.0F, 24, 12, 2, 0.0F); + this.signStick = new ModelRenderer(this, 0, 14); + this.signStick.addBox(-1.0F, -2.0F, -1.0F, 2, 14, 2, 0.0F); + } + + public void renderSign() + { + this.signBoard.render(0.0625F); + this.signStick.render(0.0625F); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/ModelSilverfish.java b/src/main/java/net/minecraft/client/model/ModelSilverfish.java new file mode 100644 index 0000000..c9e4cbd --- /dev/null +++ b/src/main/java/net/minecraft/client/model/ModelSilverfish.java @@ -0,0 +1,77 @@ +package net.minecraft.client.model; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; +import net.minecraft.util.MathHelper; + +@SideOnly(Side.CLIENT) +public class ModelSilverfish extends ModelBase +{ + private ModelRenderer[] silverfishBodyParts = new ModelRenderer[7]; + private ModelRenderer[] silverfishWings; + private float[] field_78170_c = new float[7]; + private static final int[][] silverfishBoxLength = new int[][] {{3, 2, 2}, {4, 3, 2}, {6, 4, 3}, {3, 3, 3}, {2, 2, 3}, {2, 1, 2}, {1, 1, 2}}; + private static final int[][] silverfishTexturePositions = new int[][] {{0, 0}, {0, 4}, {0, 9}, {0, 16}, {0, 22}, {11, 0}, {13, 4}}; + private static final String __OBFID = "CL_00000855"; + + public ModelSilverfish() + { + float f = -3.5F; + + for (int i = 0; i < this.silverfishBodyParts.length; ++i) + { + this.silverfishBodyParts[i] = new ModelRenderer(this, silverfishTexturePositions[i][0], silverfishTexturePositions[i][1]); + this.silverfishBodyParts[i].addBox((float)silverfishBoxLength[i][0] * -0.5F, 0.0F, (float)silverfishBoxLength[i][2] * -0.5F, silverfishBoxLength[i][0], silverfishBoxLength[i][1], silverfishBoxLength[i][2]); + this.silverfishBodyParts[i].setRotationPoint(0.0F, (float)(24 - silverfishBoxLength[i][1]), f); + this.field_78170_c[i] = f; + + if (i < this.silverfishBodyParts.length - 1) + { + f += (float)(silverfishBoxLength[i][2] + silverfishBoxLength[i + 1][2]) * 0.5F; + } + } + + this.silverfishWings = new ModelRenderer[3]; + this.silverfishWings[0] = new ModelRenderer(this, 20, 0); + this.silverfishWings[0].addBox(-5.0F, 0.0F, (float)silverfishBoxLength[2][2] * -0.5F, 10, 8, silverfishBoxLength[2][2]); + this.silverfishWings[0].setRotationPoint(0.0F, 16.0F, this.field_78170_c[2]); + this.silverfishWings[1] = new ModelRenderer(this, 20, 11); + this.silverfishWings[1].addBox(-3.0F, 0.0F, (float)silverfishBoxLength[4][2] * -0.5F, 6, 4, silverfishBoxLength[4][2]); + this.silverfishWings[1].setRotationPoint(0.0F, 20.0F, this.field_78170_c[4]); + this.silverfishWings[2] = new ModelRenderer(this, 20, 18); + this.silverfishWings[2].addBox(-3.0F, 0.0F, (float)silverfishBoxLength[4][2] * -0.5F, 6, 5, silverfishBoxLength[1][2]); + this.silverfishWings[2].setRotationPoint(0.0F, 19.0F, this.field_78170_c[1]); + } + + public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) + { + this.setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity); + int i; + + for (i = 0; i < this.silverfishBodyParts.length; ++i) + { + this.silverfishBodyParts[i].render(par7); + } + + for (i = 0; i < this.silverfishWings.length; ++i) + { + this.silverfishWings[i].render(par7); + } + } + + public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) + { + for (int i = 0; i < this.silverfishBodyParts.length; ++i) + { + this.silverfishBodyParts[i].rotateAngleY = MathHelper.cos(par3 * 0.9F + (float)i * 0.15F * (float)Math.PI) * (float)Math.PI * 0.05F * (float)(1 + Math.abs(i - 2)); + this.silverfishBodyParts[i].rotationPointX = MathHelper.sin(par3 * 0.9F + (float)i * 0.15F * (float)Math.PI) * (float)Math.PI * 0.2F * (float)Math.abs(i - 2); + } + + this.silverfishWings[0].rotateAngleY = this.silverfishBodyParts[2].rotateAngleY; + this.silverfishWings[1].rotateAngleY = this.silverfishBodyParts[4].rotateAngleY; + this.silverfishWings[1].rotationPointX = this.silverfishBodyParts[4].rotationPointX; + this.silverfishWings[2].rotateAngleY = this.silverfishBodyParts[1].rotateAngleY; + this.silverfishWings[2].rotationPointX = this.silverfishBodyParts[1].rotationPointX; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/ModelSkeleton.java b/src/main/java/net/minecraft/client/model/ModelSkeleton.java new file mode 100644 index 0000000..e3296a8 --- /dev/null +++ b/src/main/java/net/minecraft/client/model/ModelSkeleton.java @@ -0,0 +1,48 @@ +package net.minecraft.client.model; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.monster.EntitySkeleton; + +@SideOnly(Side.CLIENT) +public class ModelSkeleton extends ModelZombie +{ + private static final String __OBFID = "CL_00000857"; + + public ModelSkeleton() + { + this(0.0F); + } + + public ModelSkeleton(float par1) + { + super(par1, 0.0F, 64, 32); + this.bipedRightArm = new ModelRenderer(this, 40, 16); + this.bipedRightArm.addBox(-1.0F, -2.0F, -1.0F, 2, 12, 2, par1); + this.bipedRightArm.setRotationPoint(-5.0F, 2.0F, 0.0F); + this.bipedLeftArm = new ModelRenderer(this, 40, 16); + this.bipedLeftArm.mirror = true; + this.bipedLeftArm.addBox(-1.0F, -2.0F, -1.0F, 2, 12, 2, par1); + this.bipedLeftArm.setRotationPoint(5.0F, 2.0F, 0.0F); + this.bipedRightLeg = new ModelRenderer(this, 0, 16); + this.bipedRightLeg.addBox(-1.0F, 0.0F, -1.0F, 2, 12, 2, par1); + this.bipedRightLeg.setRotationPoint(-2.0F, 12.0F, 0.0F); + this.bipedLeftLeg = new ModelRenderer(this, 0, 16); + this.bipedLeftLeg.mirror = true; + this.bipedLeftLeg.addBox(-1.0F, 0.0F, -1.0F, 2, 12, 2, par1); + this.bipedLeftLeg.setRotationPoint(2.0F, 12.0F, 0.0F); + } + + public void setLivingAnimations(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4) + { + this.aimedBow = ((EntitySkeleton)par1EntityLivingBase).getSkeletonType() == 1; + super.setLivingAnimations(par1EntityLivingBase, par2, par3, par4); + } + + public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) + { + super.setRotationAngles(par1, par2, par3, par4, par5, par6, par7Entity); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/ModelSkeletonHead.java b/src/main/java/net/minecraft/client/model/ModelSkeletonHead.java new file mode 100644 index 0000000..4a6414c --- /dev/null +++ b/src/main/java/net/minecraft/client/model/ModelSkeletonHead.java @@ -0,0 +1,39 @@ +package net.minecraft.client.model; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; + +@SideOnly(Side.CLIENT) +public class ModelSkeletonHead extends ModelBase +{ + public ModelRenderer skeletonHead; + private static final String __OBFID = "CL_00000856"; + + public ModelSkeletonHead() + { + this(0, 35, 64, 64); + } + + public ModelSkeletonHead(int par1, int par2, int par3, int par4) + { + this.textureWidth = par3; + this.textureHeight = par4; + this.skeletonHead = new ModelRenderer(this, par1, par2); + this.skeletonHead.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, 0.0F); + this.skeletonHead.setRotationPoint(0.0F, 0.0F, 0.0F); + } + + public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) + { + this.setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity); + this.skeletonHead.render(par7); + } + + public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) + { + super.setRotationAngles(par1, par2, par3, par4, par5, par6, par7Entity); + this.skeletonHead.rotateAngleY = par4 / (180F / (float)Math.PI); + this.skeletonHead.rotateAngleX = par5 / (180F / (float)Math.PI); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/ModelSlime.java b/src/main/java/net/minecraft/client/model/ModelSlime.java new file mode 100644 index 0000000..8df0706 --- /dev/null +++ b/src/main/java/net/minecraft/client/model/ModelSlime.java @@ -0,0 +1,46 @@ +package net.minecraft.client.model; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; + +@SideOnly(Side.CLIENT) +public class ModelSlime extends ModelBase +{ + ModelRenderer slimeBodies; + ModelRenderer slimeRightEye; + ModelRenderer slimeLeftEye; + ModelRenderer slimeMouth; + private static final String __OBFID = "CL_00000858"; + + public ModelSlime(int par1) + { + this.slimeBodies = new ModelRenderer(this, 0, par1); + this.slimeBodies.addBox(-4.0F, 16.0F, -4.0F, 8, 8, 8); + + if (par1 > 0) + { + this.slimeBodies = new ModelRenderer(this, 0, par1); + this.slimeBodies.addBox(-3.0F, 17.0F, -3.0F, 6, 6, 6); + this.slimeRightEye = new ModelRenderer(this, 32, 0); + this.slimeRightEye.addBox(-3.25F, 18.0F, -3.5F, 2, 2, 2); + this.slimeLeftEye = new ModelRenderer(this, 32, 4); + this.slimeLeftEye.addBox(1.25F, 18.0F, -3.5F, 2, 2, 2); + this.slimeMouth = new ModelRenderer(this, 32, 8); + this.slimeMouth.addBox(0.0F, 21.0F, -3.5F, 1, 1, 1); + } + } + + public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) + { + this.setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity); + this.slimeBodies.render(par7); + + if (this.slimeRightEye != null) + { + this.slimeRightEye.render(par7); + this.slimeLeftEye.render(par7); + this.slimeMouth.render(par7); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/ModelSnowMan.java b/src/main/java/net/minecraft/client/model/ModelSnowMan.java new file mode 100644 index 0000000..cbc5591 --- /dev/null +++ b/src/main/java/net/minecraft/client/model/ModelSnowMan.java @@ -0,0 +1,66 @@ +package net.minecraft.client.model; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; +import net.minecraft.util.MathHelper; + +@SideOnly(Side.CLIENT) +public class ModelSnowMan extends ModelBase +{ + public ModelRenderer body; + public ModelRenderer bottomBody; + public ModelRenderer head; + public ModelRenderer rightHand; + public ModelRenderer leftHand; + private static final String __OBFID = "CL_00000859"; + + public ModelSnowMan() + { + float f = 4.0F; + float f1 = 0.0F; + this.head = (new ModelRenderer(this, 0, 0)).setTextureSize(64, 64); + this.head.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, f1 - 0.5F); + this.head.setRotationPoint(0.0F, 0.0F + f, 0.0F); + this.rightHand = (new ModelRenderer(this, 32, 0)).setTextureSize(64, 64); + this.rightHand.addBox(-1.0F, 0.0F, -1.0F, 12, 2, 2, f1 - 0.5F); + this.rightHand.setRotationPoint(0.0F, 0.0F + f + 9.0F - 7.0F, 0.0F); + this.leftHand = (new ModelRenderer(this, 32, 0)).setTextureSize(64, 64); + this.leftHand.addBox(-1.0F, 0.0F, -1.0F, 12, 2, 2, f1 - 0.5F); + this.leftHand.setRotationPoint(0.0F, 0.0F + f + 9.0F - 7.0F, 0.0F); + this.body = (new ModelRenderer(this, 0, 16)).setTextureSize(64, 64); + this.body.addBox(-5.0F, -10.0F, -5.0F, 10, 10, 10, f1 - 0.5F); + this.body.setRotationPoint(0.0F, 0.0F + f + 9.0F, 0.0F); + this.bottomBody = (new ModelRenderer(this, 0, 36)).setTextureSize(64, 64); + this.bottomBody.addBox(-6.0F, -12.0F, -6.0F, 12, 12, 12, f1 - 0.5F); + this.bottomBody.setRotationPoint(0.0F, 0.0F + f + 20.0F, 0.0F); + } + + public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) + { + super.setRotationAngles(par1, par2, par3, par4, par5, par6, par7Entity); + this.head.rotateAngleY = par4 / (180F / (float)Math.PI); + this.head.rotateAngleX = par5 / (180F / (float)Math.PI); + this.body.rotateAngleY = par4 / (180F / (float)Math.PI) * 0.25F; + float f6 = MathHelper.sin(this.body.rotateAngleY); + float f7 = MathHelper.cos(this.body.rotateAngleY); + this.rightHand.rotateAngleZ = 1.0F; + this.leftHand.rotateAngleZ = -1.0F; + this.rightHand.rotateAngleY = 0.0F + this.body.rotateAngleY; + this.leftHand.rotateAngleY = (float)Math.PI + this.body.rotateAngleY; + this.rightHand.rotationPointX = f7 * 5.0F; + this.rightHand.rotationPointZ = -f6 * 5.0F; + this.leftHand.rotationPointX = -f7 * 5.0F; + this.leftHand.rotationPointZ = f6 * 5.0F; + } + + public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) + { + this.setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity); + this.body.render(par7); + this.bottomBody.render(par7); + this.head.render(par7); + this.rightHand.render(par7); + this.leftHand.render(par7); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/ModelSpider.java b/src/main/java/net/minecraft/client/model/ModelSpider.java new file mode 100644 index 0000000..10bab05 --- /dev/null +++ b/src/main/java/net/minecraft/client/model/ModelSpider.java @@ -0,0 +1,127 @@ +package net.minecraft.client.model; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; +import net.minecraft.util.MathHelper; + +@SideOnly(Side.CLIENT) +public class ModelSpider extends ModelBase +{ + public ModelRenderer spiderHead; + public ModelRenderer spiderNeck; + public ModelRenderer spiderBody; + public ModelRenderer spiderLeg1; + public ModelRenderer spiderLeg2; + public ModelRenderer spiderLeg3; + public ModelRenderer spiderLeg4; + public ModelRenderer spiderLeg5; + public ModelRenderer spiderLeg6; + public ModelRenderer spiderLeg7; + public ModelRenderer spiderLeg8; + private static final String __OBFID = "CL_00000860"; + + public ModelSpider() + { + float f = 0.0F; + byte b0 = 15; + this.spiderHead = new ModelRenderer(this, 32, 4); + this.spiderHead.addBox(-4.0F, -4.0F, -8.0F, 8, 8, 8, f); + this.spiderHead.setRotationPoint(0.0F, (float)b0, -3.0F); + this.spiderNeck = new ModelRenderer(this, 0, 0); + this.spiderNeck.addBox(-3.0F, -3.0F, -3.0F, 6, 6, 6, f); + this.spiderNeck.setRotationPoint(0.0F, (float)b0, 0.0F); + this.spiderBody = new ModelRenderer(this, 0, 12); + this.spiderBody.addBox(-5.0F, -4.0F, -6.0F, 10, 8, 12, f); + this.spiderBody.setRotationPoint(0.0F, (float)b0, 9.0F); + this.spiderLeg1 = new ModelRenderer(this, 18, 0); + this.spiderLeg1.addBox(-15.0F, -1.0F, -1.0F, 16, 2, 2, f); + this.spiderLeg1.setRotationPoint(-4.0F, (float)b0, 2.0F); + this.spiderLeg2 = new ModelRenderer(this, 18, 0); + this.spiderLeg2.addBox(-1.0F, -1.0F, -1.0F, 16, 2, 2, f); + this.spiderLeg2.setRotationPoint(4.0F, (float)b0, 2.0F); + this.spiderLeg3 = new ModelRenderer(this, 18, 0); + this.spiderLeg3.addBox(-15.0F, -1.0F, -1.0F, 16, 2, 2, f); + this.spiderLeg3.setRotationPoint(-4.0F, (float)b0, 1.0F); + this.spiderLeg4 = new ModelRenderer(this, 18, 0); + this.spiderLeg4.addBox(-1.0F, -1.0F, -1.0F, 16, 2, 2, f); + this.spiderLeg4.setRotationPoint(4.0F, (float)b0, 1.0F); + this.spiderLeg5 = new ModelRenderer(this, 18, 0); + this.spiderLeg5.addBox(-15.0F, -1.0F, -1.0F, 16, 2, 2, f); + this.spiderLeg5.setRotationPoint(-4.0F, (float)b0, 0.0F); + this.spiderLeg6 = new ModelRenderer(this, 18, 0); + this.spiderLeg6.addBox(-1.0F, -1.0F, -1.0F, 16, 2, 2, f); + this.spiderLeg6.setRotationPoint(4.0F, (float)b0, 0.0F); + this.spiderLeg7 = new ModelRenderer(this, 18, 0); + this.spiderLeg7.addBox(-15.0F, -1.0F, -1.0F, 16, 2, 2, f); + this.spiderLeg7.setRotationPoint(-4.0F, (float)b0, -1.0F); + this.spiderLeg8 = new ModelRenderer(this, 18, 0); + this.spiderLeg8.addBox(-1.0F, -1.0F, -1.0F, 16, 2, 2, f); + this.spiderLeg8.setRotationPoint(4.0F, (float)b0, -1.0F); + } + + public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) + { + this.setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity); + this.spiderHead.render(par7); + this.spiderNeck.render(par7); + this.spiderBody.render(par7); + this.spiderLeg1.render(par7); + this.spiderLeg2.render(par7); + this.spiderLeg3.render(par7); + this.spiderLeg4.render(par7); + this.spiderLeg5.render(par7); + this.spiderLeg6.render(par7); + this.spiderLeg7.render(par7); + this.spiderLeg8.render(par7); + } + + public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) + { + this.spiderHead.rotateAngleY = par4 / (180F / (float)Math.PI); + this.spiderHead.rotateAngleX = par5 / (180F / (float)Math.PI); + float f6 = ((float)Math.PI / 4F); + this.spiderLeg1.rotateAngleZ = -f6; + this.spiderLeg2.rotateAngleZ = f6; + this.spiderLeg3.rotateAngleZ = -f6 * 0.74F; + this.spiderLeg4.rotateAngleZ = f6 * 0.74F; + this.spiderLeg5.rotateAngleZ = -f6 * 0.74F; + this.spiderLeg6.rotateAngleZ = f6 * 0.74F; + this.spiderLeg7.rotateAngleZ = -f6; + this.spiderLeg8.rotateAngleZ = f6; + float f7 = -0.0F; + float f8 = 0.3926991F; + this.spiderLeg1.rotateAngleY = f8 * 2.0F + f7; + this.spiderLeg2.rotateAngleY = -f8 * 2.0F - f7; + this.spiderLeg3.rotateAngleY = f8 * 1.0F + f7; + this.spiderLeg4.rotateAngleY = -f8 * 1.0F - f7; + this.spiderLeg5.rotateAngleY = -f8 * 1.0F + f7; + this.spiderLeg6.rotateAngleY = f8 * 1.0F - f7; + this.spiderLeg7.rotateAngleY = -f8 * 2.0F + f7; + this.spiderLeg8.rotateAngleY = f8 * 2.0F - f7; + float f9 = -(MathHelper.cos(par1 * 0.6662F * 2.0F + 0.0F) * 0.4F) * par2; + float f10 = -(MathHelper.cos(par1 * 0.6662F * 2.0F + (float)Math.PI) * 0.4F) * par2; + float f11 = -(MathHelper.cos(par1 * 0.6662F * 2.0F + ((float)Math.PI / 2F)) * 0.4F) * par2; + float f12 = -(MathHelper.cos(par1 * 0.6662F * 2.0F + ((float)Math.PI * 3F / 2F)) * 0.4F) * par2; + float f13 = Math.abs(MathHelper.sin(par1 * 0.6662F + 0.0F) * 0.4F) * par2; + float f14 = Math.abs(MathHelper.sin(par1 * 0.6662F + (float)Math.PI) * 0.4F) * par2; + float f15 = Math.abs(MathHelper.sin(par1 * 0.6662F + ((float)Math.PI / 2F)) * 0.4F) * par2; + float f16 = Math.abs(MathHelper.sin(par1 * 0.6662F + ((float)Math.PI * 3F / 2F)) * 0.4F) * par2; + this.spiderLeg1.rotateAngleY += f9; + this.spiderLeg2.rotateAngleY += -f9; + this.spiderLeg3.rotateAngleY += f10; + this.spiderLeg4.rotateAngleY += -f10; + this.spiderLeg5.rotateAngleY += f11; + this.spiderLeg6.rotateAngleY += -f11; + this.spiderLeg7.rotateAngleY += f12; + this.spiderLeg8.rotateAngleY += -f12; + this.spiderLeg1.rotateAngleZ += f13; + this.spiderLeg2.rotateAngleZ += -f13; + this.spiderLeg3.rotateAngleZ += f14; + this.spiderLeg4.rotateAngleZ += -f14; + this.spiderLeg5.rotateAngleZ += f15; + this.spiderLeg6.rotateAngleZ += -f15; + this.spiderLeg7.rotateAngleZ += f16; + this.spiderLeg8.rotateAngleZ += -f16; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/ModelSquid.java b/src/main/java/net/minecraft/client/model/ModelSquid.java new file mode 100644 index 0000000..3e6b75a --- /dev/null +++ b/src/main/java/net/minecraft/client/model/ModelSquid.java @@ -0,0 +1,58 @@ +package net.minecraft.client.model; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; + +@SideOnly(Side.CLIENT) +public class ModelSquid extends ModelBase +{ + ModelRenderer squidBody; + ModelRenderer[] squidTentacles = new ModelRenderer[8]; + private static final String __OBFID = "CL_00000861"; + + public ModelSquid() + { + byte b0 = -16; + this.squidBody = new ModelRenderer(this, 0, 0); + this.squidBody.addBox(-6.0F, -8.0F, -6.0F, 12, 16, 12); + this.squidBody.rotationPointY += (float)(24 + b0); + + for (int i = 0; i < this.squidTentacles.length; ++i) + { + this.squidTentacles[i] = new ModelRenderer(this, 48, 0); + double d0 = (double)i * Math.PI * 2.0D / (double)this.squidTentacles.length; + float f = (float)Math.cos(d0) * 5.0F; + float f1 = (float)Math.sin(d0) * 5.0F; + this.squidTentacles[i].addBox(-1.0F, 0.0F, -1.0F, 2, 18, 2); + this.squidTentacles[i].rotationPointX = f; + this.squidTentacles[i].rotationPointZ = f1; + this.squidTentacles[i].rotationPointY = (float)(31 + b0); + d0 = (double)i * Math.PI * -2.0D / (double)this.squidTentacles.length + (Math.PI / 2D); + this.squidTentacles[i].rotateAngleY = (float)d0; + } + } + + public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) + { + ModelRenderer[] amodelrenderer = this.squidTentacles; + int i = amodelrenderer.length; + + for (int j = 0; j < i; ++j) + { + ModelRenderer modelrenderer = amodelrenderer[j]; + modelrenderer.rotateAngleX = par3; + } + } + + public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) + { + this.setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity); + this.squidBody.render(par7); + + for (int i = 0; i < this.squidTentacles.length; ++i) + { + this.squidTentacles[i].render(par7); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/ModelVillager.java b/src/main/java/net/minecraft/client/model/ModelVillager.java new file mode 100644 index 0000000..e996a87 --- /dev/null +++ b/src/main/java/net/minecraft/client/model/ModelVillager.java @@ -0,0 +1,73 @@ +package net.minecraft.client.model; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; +import net.minecraft.util.MathHelper; + +@SideOnly(Side.CLIENT) +public class ModelVillager extends ModelBase +{ + public ModelRenderer villagerHead; + public ModelRenderer villagerBody; + public ModelRenderer villagerArms; + public ModelRenderer rightVillagerLeg; + public ModelRenderer leftVillagerLeg; + public ModelRenderer villagerNose; + private static final String __OBFID = "CL_00000864"; + + public ModelVillager(float par1) + { + this(par1, 0.0F, 64, 64); + } + + public ModelVillager(float par1, float par2, int par3, int par4) + { + this.villagerHead = (new ModelRenderer(this)).setTextureSize(par3, par4); + this.villagerHead.setRotationPoint(0.0F, 0.0F + par2, 0.0F); + this.villagerHead.setTextureOffset(0, 0).addBox(-4.0F, -10.0F, -4.0F, 8, 10, 8, par1); + this.villagerNose = (new ModelRenderer(this)).setTextureSize(par3, par4); + this.villagerNose.setRotationPoint(0.0F, par2 - 2.0F, 0.0F); + this.villagerNose.setTextureOffset(24, 0).addBox(-1.0F, -1.0F, -6.0F, 2, 4, 2, par1); + this.villagerHead.addChild(this.villagerNose); + this.villagerBody = (new ModelRenderer(this)).setTextureSize(par3, par4); + this.villagerBody.setRotationPoint(0.0F, 0.0F + par2, 0.0F); + this.villagerBody.setTextureOffset(16, 20).addBox(-4.0F, 0.0F, -3.0F, 8, 12, 6, par1); + this.villagerBody.setTextureOffset(0, 38).addBox(-4.0F, 0.0F, -3.0F, 8, 18, 6, par1 + 0.5F); + this.villagerArms = (new ModelRenderer(this)).setTextureSize(par3, par4); + this.villagerArms.setRotationPoint(0.0F, 0.0F + par2 + 2.0F, 0.0F); + this.villagerArms.setTextureOffset(44, 22).addBox(-8.0F, -2.0F, -2.0F, 4, 8, 4, par1); + this.villagerArms.setTextureOffset(44, 22).addBox(4.0F, -2.0F, -2.0F, 4, 8, 4, par1); + this.villagerArms.setTextureOffset(40, 38).addBox(-4.0F, 2.0F, -2.0F, 8, 4, 4, par1); + this.rightVillagerLeg = (new ModelRenderer(this, 0, 22)).setTextureSize(par3, par4); + this.rightVillagerLeg.setRotationPoint(-2.0F, 12.0F + par2, 0.0F); + this.rightVillagerLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, par1); + this.leftVillagerLeg = (new ModelRenderer(this, 0, 22)).setTextureSize(par3, par4); + this.leftVillagerLeg.mirror = true; + this.leftVillagerLeg.setRotationPoint(2.0F, 12.0F + par2, 0.0F); + this.leftVillagerLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, par1); + } + + public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) + { + this.setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity); + this.villagerHead.render(par7); + this.villagerBody.render(par7); + this.rightVillagerLeg.render(par7); + this.leftVillagerLeg.render(par7); + this.villagerArms.render(par7); + } + + public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) + { + this.villagerHead.rotateAngleY = par4 / (180F / (float)Math.PI); + this.villagerHead.rotateAngleX = par5 / (180F / (float)Math.PI); + this.villagerArms.rotationPointY = 3.0F; + this.villagerArms.rotationPointZ = -1.0F; + this.villagerArms.rotateAngleX = -0.75F; + this.rightVillagerLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F) * 1.4F * par2 * 0.5F; + this.leftVillagerLeg.rotateAngleX = MathHelper.cos(par1 * 0.6662F + (float)Math.PI) * 1.4F * par2 * 0.5F; + this.rightVillagerLeg.rotateAngleY = 0.0F; + this.leftVillagerLeg.rotateAngleY = 0.0F; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/ModelWitch.java b/src/main/java/net/minecraft/client/model/ModelWitch.java new file mode 100644 index 0000000..b106d1e --- /dev/null +++ b/src/main/java/net/minecraft/client/model/ModelWitch.java @@ -0,0 +1,62 @@ +package net.minecraft.client.model; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; +import net.minecraft.util.MathHelper; + +@SideOnly(Side.CLIENT) +public class ModelWitch extends ModelVillager +{ + public boolean field_82900_g; + private ModelRenderer field_82901_h = (new ModelRenderer(this)).setTextureSize(64, 128); + private ModelRenderer witchHat; + private static final String __OBFID = "CL_00000866"; + + public ModelWitch(float par1) + { + super(par1, 0.0F, 64, 128); + this.field_82901_h.setRotationPoint(0.0F, -2.0F, 0.0F); + this.field_82901_h.setTextureOffset(0, 0).addBox(0.0F, 3.0F, -6.75F, 1, 1, 1, -0.25F); + this.villagerNose.addChild(this.field_82901_h); + this.witchHat = (new ModelRenderer(this)).setTextureSize(64, 128); + this.witchHat.setRotationPoint(-5.0F, -10.03125F, -5.0F); + this.witchHat.setTextureOffset(0, 64).addBox(0.0F, 0.0F, 0.0F, 10, 2, 10); + this.villagerHead.addChild(this.witchHat); + ModelRenderer modelrenderer = (new ModelRenderer(this)).setTextureSize(64, 128); + modelrenderer.setRotationPoint(1.75F, -4.0F, 2.0F); + modelrenderer.setTextureOffset(0, 76).addBox(0.0F, 0.0F, 0.0F, 7, 4, 7); + modelrenderer.rotateAngleX = -0.05235988F; + modelrenderer.rotateAngleZ = 0.02617994F; + this.witchHat.addChild(modelrenderer); + ModelRenderer modelrenderer1 = (new ModelRenderer(this)).setTextureSize(64, 128); + modelrenderer1.setRotationPoint(1.75F, -4.0F, 2.0F); + modelrenderer1.setTextureOffset(0, 87).addBox(0.0F, 0.0F, 0.0F, 4, 4, 4); + modelrenderer1.rotateAngleX = -0.10471976F; + modelrenderer1.rotateAngleZ = 0.05235988F; + modelrenderer.addChild(modelrenderer1); + ModelRenderer modelrenderer2 = (new ModelRenderer(this)).setTextureSize(64, 128); + modelrenderer2.setRotationPoint(1.75F, -2.0F, 2.0F); + modelrenderer2.setTextureOffset(0, 95).addBox(0.0F, 0.0F, 0.0F, 1, 2, 1, 0.25F); + modelrenderer2.rotateAngleX = -0.20943952F; + modelrenderer2.rotateAngleZ = 0.10471976F; + modelrenderer1.addChild(modelrenderer2); + } + + public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) + { + super.setRotationAngles(par1, par2, par3, par4, par5, par6, par7Entity); + this.villagerNose.offsetX = this.villagerNose.offsetY = this.villagerNose.offsetZ = 0.0F; + float f6 = 0.01F * (float)(par7Entity.getEntityId() % 10); + this.villagerNose.rotateAngleX = MathHelper.sin((float)par7Entity.ticksExisted * f6) * 4.5F * (float)Math.PI / 180.0F; + this.villagerNose.rotateAngleY = 0.0F; + this.villagerNose.rotateAngleZ = MathHelper.cos((float)par7Entity.ticksExisted * f6) * 2.5F * (float)Math.PI / 180.0F; + + if (this.field_82900_g) + { + this.villagerNose.rotateAngleX = -0.9F; + this.villagerNose.offsetZ = -0.09375F; + this.villagerNose.offsetY = 0.1875F; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/ModelWither.java b/src/main/java/net/minecraft/client/model/ModelWither.java new file mode 100644 index 0000000..16e35f8 --- /dev/null +++ b/src/main/java/net/minecraft/client/model/ModelWither.java @@ -0,0 +1,94 @@ +package net.minecraft.client.model; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.boss.EntityWither; +import net.minecraft.util.MathHelper; + +@SideOnly(Side.CLIENT) +public class ModelWither extends ModelBase +{ + private ModelRenderer[] field_82905_a; + private ModelRenderer[] field_82904_b; + private static final String __OBFID = "CL_00000867"; + + public ModelWither() + { + this.textureWidth = 64; + this.textureHeight = 64; + this.field_82905_a = new ModelRenderer[3]; + this.field_82905_a[0] = new ModelRenderer(this, 0, 16); + this.field_82905_a[0].addBox(-10.0F, 3.9F, -0.5F, 20, 3, 3); + this.field_82905_a[1] = (new ModelRenderer(this)).setTextureSize(this.textureWidth, this.textureHeight); + this.field_82905_a[1].setRotationPoint(-2.0F, 6.9F, -0.5F); + this.field_82905_a[1].setTextureOffset(0, 22).addBox(0.0F, 0.0F, 0.0F, 3, 10, 3); + this.field_82905_a[1].setTextureOffset(24, 22).addBox(-4.0F, 1.5F, 0.5F, 11, 2, 2); + this.field_82905_a[1].setTextureOffset(24, 22).addBox(-4.0F, 4.0F, 0.5F, 11, 2, 2); + this.field_82905_a[1].setTextureOffset(24, 22).addBox(-4.0F, 6.5F, 0.5F, 11, 2, 2); + this.field_82905_a[2] = new ModelRenderer(this, 12, 22); + this.field_82905_a[2].addBox(0.0F, 0.0F, 0.0F, 3, 6, 3); + this.field_82904_b = new ModelRenderer[3]; + this.field_82904_b[0] = new ModelRenderer(this, 0, 0); + this.field_82904_b[0].addBox(-4.0F, -4.0F, -4.0F, 8, 8, 8); + this.field_82904_b[1] = new ModelRenderer(this, 32, 0); + this.field_82904_b[1].addBox(-4.0F, -4.0F, -4.0F, 6, 6, 6); + this.field_82904_b[1].rotationPointX = -8.0F; + this.field_82904_b[1].rotationPointY = 4.0F; + this.field_82904_b[2] = new ModelRenderer(this, 32, 0); + this.field_82904_b[2].addBox(-4.0F, -4.0F, -4.0F, 6, 6, 6); + this.field_82904_b[2].rotationPointX = 10.0F; + this.field_82904_b[2].rotationPointY = 4.0F; + } + + public int func_82903_a() + { + return 32; + } + + public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) + { + this.setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity); + ModelRenderer[] amodelrenderer = this.field_82904_b; + int i = amodelrenderer.length; + int j; + ModelRenderer modelrenderer; + + for (j = 0; j < i; ++j) + { + modelrenderer = amodelrenderer[j]; + modelrenderer.render(par7); + } + + amodelrenderer = this.field_82905_a; + i = amodelrenderer.length; + + for (j = 0; j < i; ++j) + { + modelrenderer = amodelrenderer[j]; + modelrenderer.render(par7); + } + } + + public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) + { + float f6 = MathHelper.cos(par3 * 0.1F); + this.field_82905_a[1].rotateAngleX = (0.065F + 0.05F * f6) * (float)Math.PI; + this.field_82905_a[2].setRotationPoint(-2.0F, 6.9F + MathHelper.cos(this.field_82905_a[1].rotateAngleX) * 10.0F, -0.5F + MathHelper.sin(this.field_82905_a[1].rotateAngleX) * 10.0F); + this.field_82905_a[2].rotateAngleX = (0.265F + 0.1F * f6) * (float)Math.PI; + this.field_82904_b[0].rotateAngleY = par4 / (180F / (float)Math.PI); + this.field_82904_b[0].rotateAngleX = par5 / (180F / (float)Math.PI); + } + + public void setLivingAnimations(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4) + { + EntityWither entitywither = (EntityWither)par1EntityLivingBase; + + for (int i = 1; i < 3; ++i) + { + this.field_82904_b[i].rotateAngleY = (entitywither.func_82207_a(i - 1) - par1EntityLivingBase.renderYawOffset) / (180F / (float)Math.PI); + this.field_82904_b[i].rotateAngleX = entitywither.func_82210_r(i - 1) / (180F / (float)Math.PI); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/ModelWolf.java b/src/main/java/net/minecraft/client/model/ModelWolf.java new file mode 100644 index 0000000..801ba2a --- /dev/null +++ b/src/main/java/net/minecraft/client/model/ModelWolf.java @@ -0,0 +1,154 @@ +package net.minecraft.client.model; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.passive.EntityWolf; +import net.minecraft.util.MathHelper; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class ModelWolf extends ModelBase +{ + public ModelRenderer wolfHeadMain; + public ModelRenderer wolfBody; + public ModelRenderer wolfLeg1; + public ModelRenderer wolfLeg2; + public ModelRenderer wolfLeg3; + public ModelRenderer wolfLeg4; + ModelRenderer wolfTail; + ModelRenderer wolfMane; + private static final String __OBFID = "CL_00000868"; + + public ModelWolf() + { + float f = 0.0F; + float f1 = 13.5F; + this.wolfHeadMain = new ModelRenderer(this, 0, 0); + this.wolfHeadMain.addBox(-3.0F, -3.0F, -2.0F, 6, 6, 4, f); + this.wolfHeadMain.setRotationPoint(-1.0F, f1, -7.0F); + this.wolfBody = new ModelRenderer(this, 18, 14); + this.wolfBody.addBox(-4.0F, -2.0F, -3.0F, 6, 9, 6, f); + this.wolfBody.setRotationPoint(0.0F, 14.0F, 2.0F); + this.wolfMane = new ModelRenderer(this, 21, 0); + this.wolfMane.addBox(-4.0F, -3.0F, -3.0F, 8, 6, 7, f); + this.wolfMane.setRotationPoint(-1.0F, 14.0F, 2.0F); + this.wolfLeg1 = new ModelRenderer(this, 0, 18); + this.wolfLeg1.addBox(-1.0F, 0.0F, -1.0F, 2, 8, 2, f); + this.wolfLeg1.setRotationPoint(-2.5F, 16.0F, 7.0F); + this.wolfLeg2 = new ModelRenderer(this, 0, 18); + this.wolfLeg2.addBox(-1.0F, 0.0F, -1.0F, 2, 8, 2, f); + this.wolfLeg2.setRotationPoint(0.5F, 16.0F, 7.0F); + this.wolfLeg3 = new ModelRenderer(this, 0, 18); + this.wolfLeg3.addBox(-1.0F, 0.0F, -1.0F, 2, 8, 2, f); + this.wolfLeg3.setRotationPoint(-2.5F, 16.0F, -4.0F); + this.wolfLeg4 = new ModelRenderer(this, 0, 18); + this.wolfLeg4.addBox(-1.0F, 0.0F, -1.0F, 2, 8, 2, f); + this.wolfLeg4.setRotationPoint(0.5F, 16.0F, -4.0F); + this.wolfTail = new ModelRenderer(this, 9, 18); + this.wolfTail.addBox(-1.0F, 0.0F, -1.0F, 2, 8, 2, f); + this.wolfTail.setRotationPoint(-1.0F, 12.0F, 8.0F); + this.wolfHeadMain.setTextureOffset(16, 14).addBox(-3.0F, -5.0F, 0.0F, 2, 2, 1, f); + this.wolfHeadMain.setTextureOffset(16, 14).addBox(1.0F, -5.0F, 0.0F, 2, 2, 1, f); + this.wolfHeadMain.setTextureOffset(0, 10).addBox(-1.5F, 0.0F, -5.0F, 3, 3, 4, f); + } + + public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) + { + super.render(par1Entity, par2, par3, par4, par5, par6, par7); + this.setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity); + + if (this.isChild) + { + float f6 = 2.0F; + GL11.glPushMatrix(); + GL11.glTranslatef(0.0F, 5.0F * par7, 2.0F * par7); + this.wolfHeadMain.renderWithRotation(par7); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glScalef(1.0F / f6, 1.0F / f6, 1.0F / f6); + GL11.glTranslatef(0.0F, 24.0F * par7, 0.0F); + this.wolfBody.render(par7); + this.wolfLeg1.render(par7); + this.wolfLeg2.render(par7); + this.wolfLeg3.render(par7); + this.wolfLeg4.render(par7); + this.wolfTail.renderWithRotation(par7); + this.wolfMane.render(par7); + GL11.glPopMatrix(); + } + else + { + this.wolfHeadMain.renderWithRotation(par7); + this.wolfBody.render(par7); + this.wolfLeg1.render(par7); + this.wolfLeg2.render(par7); + this.wolfLeg3.render(par7); + this.wolfLeg4.render(par7); + this.wolfTail.renderWithRotation(par7); + this.wolfMane.render(par7); + } + } + + public void setLivingAnimations(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4) + { + EntityWolf entitywolf = (EntityWolf)par1EntityLivingBase; + + if (entitywolf.isAngry()) + { + this.wolfTail.rotateAngleY = 0.0F; + } + else + { + this.wolfTail.rotateAngleY = MathHelper.cos(par2 * 0.6662F) * 1.4F * par3; + } + + if (entitywolf.isSitting()) + { + this.wolfMane.setRotationPoint(-1.0F, 16.0F, -3.0F); + this.wolfMane.rotateAngleX = ((float)Math.PI * 2F / 5F); + this.wolfMane.rotateAngleY = 0.0F; + this.wolfBody.setRotationPoint(0.0F, 18.0F, 0.0F); + this.wolfBody.rotateAngleX = ((float)Math.PI / 4F); + this.wolfTail.setRotationPoint(-1.0F, 21.0F, 6.0F); + this.wolfLeg1.setRotationPoint(-2.5F, 22.0F, 2.0F); + this.wolfLeg1.rotateAngleX = ((float)Math.PI * 3F / 2F); + this.wolfLeg2.setRotationPoint(0.5F, 22.0F, 2.0F); + this.wolfLeg2.rotateAngleX = ((float)Math.PI * 3F / 2F); + this.wolfLeg3.rotateAngleX = 5.811947F; + this.wolfLeg3.setRotationPoint(-2.49F, 17.0F, -4.0F); + this.wolfLeg4.rotateAngleX = 5.811947F; + this.wolfLeg4.setRotationPoint(0.51F, 17.0F, -4.0F); + } + else + { + this.wolfBody.setRotationPoint(0.0F, 14.0F, 2.0F); + this.wolfBody.rotateAngleX = ((float)Math.PI / 2F); + this.wolfMane.setRotationPoint(-1.0F, 14.0F, -3.0F); + this.wolfMane.rotateAngleX = this.wolfBody.rotateAngleX; + this.wolfTail.setRotationPoint(-1.0F, 12.0F, 8.0F); + this.wolfLeg1.setRotationPoint(-2.5F, 16.0F, 7.0F); + this.wolfLeg2.setRotationPoint(0.5F, 16.0F, 7.0F); + this.wolfLeg3.setRotationPoint(-2.5F, 16.0F, -4.0F); + this.wolfLeg4.setRotationPoint(0.5F, 16.0F, -4.0F); + this.wolfLeg1.rotateAngleX = MathHelper.cos(par2 * 0.6662F) * 1.4F * par3; + this.wolfLeg2.rotateAngleX = MathHelper.cos(par2 * 0.6662F + (float)Math.PI) * 1.4F * par3; + this.wolfLeg3.rotateAngleX = MathHelper.cos(par2 * 0.6662F + (float)Math.PI) * 1.4F * par3; + this.wolfLeg4.rotateAngleX = MathHelper.cos(par2 * 0.6662F) * 1.4F * par3; + } + + this.wolfHeadMain.rotateAngleZ = entitywolf.getInterestedAngle(par4) + entitywolf.getShakeAngle(par4, 0.0F); + this.wolfMane.rotateAngleZ = entitywolf.getShakeAngle(par4, -0.08F); + this.wolfBody.rotateAngleZ = entitywolf.getShakeAngle(par4, -0.16F); + this.wolfTail.rotateAngleZ = entitywolf.getShakeAngle(par4, -0.2F); + } + + public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) + { + super.setRotationAngles(par1, par2, par3, par4, par5, par6, par7Entity); + this.wolfHeadMain.rotateAngleX = par5 / (180F / (float)Math.PI); + this.wolfHeadMain.rotateAngleY = par4 / (180F / (float)Math.PI); + this.wolfTail.rotateAngleX = par3; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/ModelZombie.java b/src/main/java/net/minecraft/client/model/ModelZombie.java new file mode 100644 index 0000000..f8f357e --- /dev/null +++ b/src/main/java/net/minecraft/client/model/ModelZombie.java @@ -0,0 +1,46 @@ +package net.minecraft.client.model; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; +import net.minecraft.util.MathHelper; + +@SideOnly(Side.CLIENT) +public class ModelZombie extends ModelBiped +{ + private static final String __OBFID = "CL_00000869"; + + public ModelZombie() + { + this(0.0F, false); + } + + protected ModelZombie(float par1, float par2, int par3, int par4) + { + super(par1, par2, par3, par4); + } + + public ModelZombie(float par1, boolean par2) + { + super(par1, 0.0F, 64, par2 ? 32 : 64); + } + + public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) + { + super.setRotationAngles(par1, par2, par3, par4, par5, par6, par7Entity); + float f6 = MathHelper.sin(this.onGround * (float)Math.PI); + float f7 = MathHelper.sin((1.0F - (1.0F - this.onGround) * (1.0F - this.onGround)) * (float)Math.PI); + this.bipedRightArm.rotateAngleZ = 0.0F; + this.bipedLeftArm.rotateAngleZ = 0.0F; + this.bipedRightArm.rotateAngleY = -(0.1F - f6 * 0.6F); + this.bipedLeftArm.rotateAngleY = 0.1F - f6 * 0.6F; + this.bipedRightArm.rotateAngleX = -((float)Math.PI / 2F); + this.bipedLeftArm.rotateAngleX = -((float)Math.PI / 2F); + this.bipedRightArm.rotateAngleX -= f6 * 1.2F - f7 * 0.4F; + this.bipedLeftArm.rotateAngleX -= f6 * 1.2F - f7 * 0.4F; + this.bipedRightArm.rotateAngleZ += MathHelper.cos(par3 * 0.09F) * 0.05F + 0.05F; + this.bipedLeftArm.rotateAngleZ -= MathHelper.cos(par3 * 0.09F) * 0.05F + 0.05F; + this.bipedRightArm.rotateAngleX += MathHelper.sin(par3 * 0.067F) * 0.05F; + this.bipedLeftArm.rotateAngleX -= MathHelper.sin(par3 * 0.067F) * 0.05F; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/ModelZombieVillager.java b/src/main/java/net/minecraft/client/model/ModelZombieVillager.java new file mode 100644 index 0000000..b16772e --- /dev/null +++ b/src/main/java/net/minecraft/client/model/ModelZombieVillager.java @@ -0,0 +1,60 @@ +package net.minecraft.client.model; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; +import net.minecraft.util.MathHelper; + +@SideOnly(Side.CLIENT) +public class ModelZombieVillager extends ModelBiped +{ + private static final String __OBFID = "CL_00000865"; + + public ModelZombieVillager() + { + this(0.0F, 0.0F, false); + } + + public ModelZombieVillager(float par1, float par2, boolean par3) + { + super(par1, 0.0F, 64, par3 ? 32 : 64); + + if (par3) + { + this.bipedHead = new ModelRenderer(this, 0, 0); + this.bipedHead.addBox(-4.0F, -10.0F, -4.0F, 8, 6, 8, par1); + this.bipedHead.setRotationPoint(0.0F, 0.0F + par2, 0.0F); + } + else + { + this.bipedHead = new ModelRenderer(this); + this.bipedHead.setRotationPoint(0.0F, 0.0F + par2, 0.0F); + this.bipedHead.setTextureOffset(0, 32).addBox(-4.0F, -10.0F, -4.0F, 8, 10, 8, par1); + this.bipedHead.setTextureOffset(24, 32).addBox(-1.0F, -3.0F, -6.0F, 2, 4, 2, par1); + } + } + + public int func_82897_a() + { + return 10; + } + + public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) + { + super.setRotationAngles(par1, par2, par3, par4, par5, par6, par7Entity); + float f6 = MathHelper.sin(this.onGround * (float)Math.PI); + float f7 = MathHelper.sin((1.0F - (1.0F - this.onGround) * (1.0F - this.onGround)) * (float)Math.PI); + this.bipedRightArm.rotateAngleZ = 0.0F; + this.bipedLeftArm.rotateAngleZ = 0.0F; + this.bipedRightArm.rotateAngleY = -(0.1F - f6 * 0.6F); + this.bipedLeftArm.rotateAngleY = 0.1F - f6 * 0.6F; + this.bipedRightArm.rotateAngleX = -((float)Math.PI / 2F); + this.bipedLeftArm.rotateAngleX = -((float)Math.PI / 2F); + this.bipedRightArm.rotateAngleX -= f6 * 1.2F - f7 * 0.4F; + this.bipedLeftArm.rotateAngleX -= f6 * 1.2F - f7 * 0.4F; + this.bipedRightArm.rotateAngleZ += MathHelper.cos(par3 * 0.09F) * 0.05F + 0.05F; + this.bipedLeftArm.rotateAngleZ -= MathHelper.cos(par3 * 0.09F) * 0.05F + 0.05F; + this.bipedRightArm.rotateAngleX += MathHelper.sin(par3 * 0.067F) * 0.05F; + this.bipedLeftArm.rotateAngleX -= MathHelper.sin(par3 * 0.067F) * 0.05F; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/PositionTextureVertex.java b/src/main/java/net/minecraft/client/model/PositionTextureVertex.java new file mode 100644 index 0000000..5bcc0e3 --- /dev/null +++ b/src/main/java/net/minecraft/client/model/PositionTextureVertex.java @@ -0,0 +1,35 @@ +package net.minecraft.client.model; + +import net.minecraft.util.Vec3; + +public class PositionTextureVertex +{ + public Vec3 vector3D; + public float texturePositionX; + public float texturePositionY; + private static final String __OBFID = "CL_00000862"; + + public PositionTextureVertex(float par1, float par2, float par3, float par4, float par5) + { + this(Vec3.createVectorHelper((double)par1, (double)par2, (double)par3), par4, par5); + } + + public PositionTextureVertex setTexturePosition(float par1, float par2) + { + return new PositionTextureVertex(this, par1, par2); + } + + public PositionTextureVertex(PositionTextureVertex par1PositionTextureVertex, float par2, float par3) + { + this.vector3D = par1PositionTextureVertex.vector3D; + this.texturePositionX = par2; + this.texturePositionY = par3; + } + + public PositionTextureVertex(Vec3 par1Vec3, float par2, float par3) + { + this.vector3D = par1Vec3; + this.texturePositionX = par2; + this.texturePositionY = par3; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/TextureOffset.java b/src/main/java/net/minecraft/client/model/TextureOffset.java new file mode 100644 index 0000000..03f2420 --- /dev/null +++ b/src/main/java/net/minecraft/client/model/TextureOffset.java @@ -0,0 +1,18 @@ +package net.minecraft.client.model; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class TextureOffset +{ + public final int textureOffsetX; + public final int textureOffsetY; + private static final String __OBFID = "CL_00000875"; + + public TextureOffset(int par1, int par2) + { + this.textureOffsetX = par1; + this.textureOffsetY = par2; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/model/TexturedQuad.java b/src/main/java/net/minecraft/client/model/TexturedQuad.java new file mode 100644 index 0000000..2054190 --- /dev/null +++ b/src/main/java/net/minecraft/client/model/TexturedQuad.java @@ -0,0 +1,66 @@ +package net.minecraft.client.model; + +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.Vec3; + +public class TexturedQuad +{ + public PositionTextureVertex[] vertexPositions; + public int nVertices; + private boolean invertNormal; + private static final String __OBFID = "CL_00000850"; + + public TexturedQuad(PositionTextureVertex[] par1ArrayOfPositionTextureVertex) + { + this.vertexPositions = par1ArrayOfPositionTextureVertex; + this.nVertices = par1ArrayOfPositionTextureVertex.length; + } + + public TexturedQuad(PositionTextureVertex[] par1ArrayOfPositionTextureVertex, int par2, int par3, int par4, int par5, float par6, float par7) + { + this(par1ArrayOfPositionTextureVertex); + float f2 = 0.0F / par6; + float f3 = 0.0F / par7; + par1ArrayOfPositionTextureVertex[0] = par1ArrayOfPositionTextureVertex[0].setTexturePosition((float)par4 / par6 - f2, (float)par3 / par7 + f3); + par1ArrayOfPositionTextureVertex[1] = par1ArrayOfPositionTextureVertex[1].setTexturePosition((float)par2 / par6 + f2, (float)par3 / par7 + f3); + par1ArrayOfPositionTextureVertex[2] = par1ArrayOfPositionTextureVertex[2].setTexturePosition((float)par2 / par6 + f2, (float)par5 / par7 - f3); + par1ArrayOfPositionTextureVertex[3] = par1ArrayOfPositionTextureVertex[3].setTexturePosition((float)par4 / par6 - f2, (float)par5 / par7 - f3); + } + + public void flipFace() + { + PositionTextureVertex[] apositiontexturevertex = new PositionTextureVertex[this.vertexPositions.length]; + + for (int i = 0; i < this.vertexPositions.length; ++i) + { + apositiontexturevertex[i] = this.vertexPositions[this.vertexPositions.length - i - 1]; + } + + this.vertexPositions = apositiontexturevertex; + } + + public void draw(Tessellator par1Tessellator, float par2) + { + Vec3 vec3 = this.vertexPositions[1].vector3D.subtract(this.vertexPositions[0].vector3D); + Vec3 vec31 = this.vertexPositions[1].vector3D.subtract(this.vertexPositions[2].vector3D); + Vec3 vec32 = vec31.crossProduct(vec3).normalize(); + par1Tessellator.startDrawingQuads(); + + if (this.invertNormal) + { + par1Tessellator.setNormal(-((float)vec32.xCoord), -((float)vec32.yCoord), -((float)vec32.zCoord)); + } + else + { + par1Tessellator.setNormal((float)vec32.xCoord, (float)vec32.yCoord, (float)vec32.zCoord); + } + + for (int i = 0; i < 4; ++i) + { + PositionTextureVertex positiontexturevertex = this.vertexPositions[i]; + par1Tessellator.addVertexWithUV((double)((float)positiontexturevertex.vector3D.xCoord * par2), (double)((float)positiontexturevertex.vector3D.yCoord * par2), (double)((float)positiontexturevertex.vector3D.zCoord * par2), (double)positiontexturevertex.texturePositionX, (double)positiontexturevertex.texturePositionY); + } + + par1Tessellator.draw(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/multiplayer/ChunkProviderClient.java b/src/main/java/net/minecraft/client/multiplayer/ChunkProviderClient.java new file mode 100644 index 0000000..a80b2fe --- /dev/null +++ b/src/main/java/net/minecraft/client/multiplayer/ChunkProviderClient.java @@ -0,0 +1,124 @@ +package net.minecraft.client.multiplayer; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.util.IProgressUpdate; +import net.minecraft.util.LongHashMap; +import net.minecraft.world.ChunkCoordIntPair; +import net.minecraft.world.ChunkPosition; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.EmptyChunk; +import net.minecraft.world.chunk.IChunkProvider; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +@SideOnly(Side.CLIENT) +public class ChunkProviderClient implements IChunkProvider +{ + private static final Logger logger = LogManager.getLogger(); + private Chunk blankChunk; + private LongHashMap chunkMapping = new LongHashMap(); + private List chunkListing = new ArrayList(); + private World worldObj; + private static final String __OBFID = "CL_00000880"; + + public ChunkProviderClient(World par1World) + { + this.blankChunk = new EmptyChunk(par1World, 0, 0); + this.worldObj = par1World; + } + + public boolean chunkExists(int par1, int par2) + { + return true; + } + + public void unloadChunk(int par1, int par2) + { + Chunk chunk = this.provideChunk(par1, par2); + + if (!chunk.isEmpty()) + { + chunk.onChunkUnload(); + } + + this.chunkMapping.remove(ChunkCoordIntPair.chunkXZ2Int(par1, par2)); + this.chunkListing.remove(chunk); + } + + public Chunk loadChunk(int par1, int par2) + { + Chunk chunk = new Chunk(this.worldObj, par1, par2); + this.chunkMapping.add(ChunkCoordIntPair.chunkXZ2Int(par1, par2), chunk); + this.chunkListing.add(chunk); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.ChunkEvent.Load(chunk)); + chunk.isChunkLoaded = true; + return chunk; + } + + public Chunk provideChunk(int par1, int par2) + { + Chunk chunk = (Chunk)this.chunkMapping.getValueByKey(ChunkCoordIntPair.chunkXZ2Int(par1, par2)); + return chunk == null ? this.blankChunk : chunk; + } + + public boolean saveChunks(boolean par1, IProgressUpdate par2IProgressUpdate) + { + return true; + } + + public void saveExtraData() {} + + public boolean unloadQueuedChunks() + { + long i = System.currentTimeMillis(); + Iterator iterator = this.chunkListing.iterator(); + + while (iterator.hasNext()) + { + Chunk chunk = (Chunk)iterator.next(); + chunk.func_150804_b(System.currentTimeMillis() - i > 5L); + } + + if (System.currentTimeMillis() - i > 100L) + { + logger.info("Warning: Clientside chunk ticking took {} ms", new Object[] {Long.valueOf(System.currentTimeMillis() - i)}); + } + + return false; + } + + public boolean canSave() + { + return false; + } + + public void populate(IChunkProvider par1IChunkProvider, int par2, int par3) {} + + public String makeString() + { + return "MultiplayerChunkCache: " + this.chunkMapping.getNumHashElements() + ", " + this.chunkListing.size(); + } + + public List getPossibleCreatures(EnumCreatureType par1EnumCreatureType, int par2, int par3, int par4) + { + return null; + } + + public ChunkPosition func_147416_a(World p_147416_1_, String p_147416_2_, int p_147416_3_, int p_147416_4_, int p_147416_5_) + { + return null; + } + + public int getLoadedChunkCount() + { + return this.chunkListing.size(); + } + + public void recreateStructures(int par1, int par2) {} +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/multiplayer/GuiConnecting.java b/src/main/java/net/minecraft/client/multiplayer/GuiConnecting.java new file mode 100644 index 0000000..a186d8b --- /dev/null +++ b/src/main/java/net/minecraft/client/multiplayer/GuiConnecting.java @@ -0,0 +1,149 @@ +package net.minecraft.client.multiplayer; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.util.concurrent.GenericFutureListener; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.concurrent.atomic.AtomicInteger; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiDisconnected; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.network.NetHandlerLoginClient; +import net.minecraft.client.resources.I18n; +import net.minecraft.network.EnumConnectionState; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.handshake.client.C00Handshake; +import net.minecraft.network.login.client.C00PacketLoginStart; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.ChatComponentTranslation; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +@SideOnly(Side.CLIENT) +public class GuiConnecting extends GuiScreen +{ + private static final AtomicInteger field_146372_a = new AtomicInteger(0); + private static final Logger logger = LogManager.getLogger(); + private NetworkManager field_146371_g; + private boolean field_146373_h; + private final GuiScreen field_146374_i; + private static final String __OBFID = "CL_00000685"; + + public GuiConnecting(GuiScreen par1GuiScreen, Minecraft par2Minecraft, ServerData par3ServerData) + { + this.mc = par2Minecraft; + this.field_146374_i = par1GuiScreen; + ServerAddress serveraddress = ServerAddress.func_78860_a(par3ServerData.serverIP); + par2Minecraft.loadWorld((WorldClient)null); + par2Minecraft.setServerData(par3ServerData); + this.func_146367_a(serveraddress.getIP(), serveraddress.getPort()); + } + + public GuiConnecting(GuiScreen par1GuiScreen, Minecraft par2Minecraft, String par3Str, int par4) + { + this.mc = par2Minecraft; + this.field_146374_i = par1GuiScreen; + par2Minecraft.loadWorld((WorldClient)null); + this.func_146367_a(par3Str, par4); + } + + private void func_146367_a(final String p_146367_1_, final int p_146367_2_) + { + logger.info("Connecting to " + p_146367_1_ + ", " + p_146367_2_); + (new Thread("Server Connector #" + field_146372_a.incrementAndGet()) + { + private static final String __OBFID = "CL_00000686"; + public void run() + { + try + { + if (GuiConnecting.this.field_146373_h) + { + return; + } + + GuiConnecting.this.field_146371_g = NetworkManager.provideLanClient(InetAddress.getByName(p_146367_1_), p_146367_2_); + GuiConnecting.this.field_146371_g.setNetHandler(new NetHandlerLoginClient(GuiConnecting.this.field_146371_g, GuiConnecting.this.mc, GuiConnecting.this.field_146374_i)); + GuiConnecting.this.field_146371_g.scheduleOutboundPacket(new C00Handshake(4, p_146367_1_, p_146367_2_, EnumConnectionState.LOGIN), new GenericFutureListener[0]); + GuiConnecting.this.field_146371_g.scheduleOutboundPacket(new C00PacketLoginStart(GuiConnecting.this.mc.getSession().func_148256_e()), new GenericFutureListener[0]); + } + catch (UnknownHostException unknownhostexception) + { + if (GuiConnecting.this.field_146373_h) + { + return; + } + + GuiConnecting.logger.error("Couldn\'t connect to server", unknownhostexception); + GuiConnecting.this.mc.displayGuiScreen(new GuiDisconnected(GuiConnecting.this.field_146374_i, "connect.failed", new ChatComponentTranslation("disconnect.genericReason", new Object[] {"Unknown host \'" + p_146367_1_ + "\'"}))); + } + catch (Exception exception) + { + if (GuiConnecting.this.field_146373_h) + { + return; + } + + GuiConnecting.logger.error("Couldn\'t connect to server", exception); + GuiConnecting.this.mc.displayGuiScreen(new GuiDisconnected(GuiConnecting.this.field_146374_i, "connect.failed", new ChatComponentTranslation("disconnect.genericReason", new Object[] {exception.toString()}))); + } + } + }).start(); + } + + public void updateScreen() + { + if (this.field_146371_g != null) + { + if (this.field_146371_g.isChannelOpen()) + { + this.field_146371_g.processReceivedPackets(); + } + else if (this.field_146371_g.getExitMessage() != null) + { + this.field_146371_g.getNetHandler().onDisconnect(this.field_146371_g.getExitMessage()); + } + } + } + + protected void keyTyped(char par1, int par2) {} + + public void initGui() + { + this.buttonList.clear(); + this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 120 + 12, I18n.format("gui.cancel", new Object[0]))); + } + + protected void actionPerformed(GuiButton p_146284_1_) + { + if (p_146284_1_.id == 0) + { + this.field_146373_h = true; + + if (this.field_146371_g != null) + { + this.field_146371_g.closeChannel(new ChatComponentText("Aborted")); + } + + this.mc.displayGuiScreen(this.field_146374_i); + } + } + + public void drawScreen(int par1, int par2, float par3) + { + this.drawDefaultBackground(); + + if (this.field_146371_g == null) + { + this.drawCenteredString(this.fontRendererObj, I18n.format("connect.connecting", new Object[0]), this.width / 2, this.height / 2 - 50, 16777215); + } + else + { + this.drawCenteredString(this.fontRendererObj, I18n.format("connect.authorizing", new Object[0]), this.width / 2, this.height / 2 - 50, 16777215); + } + + super.drawScreen(par1, par2, par3); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/multiplayer/PlayerControllerMP.java b/src/main/java/net/minecraft/client/multiplayer/PlayerControllerMP.java new file mode 100644 index 0000000..a03a973 --- /dev/null +++ b/src/main/java/net/minecraft/client/multiplayer/PlayerControllerMP.java @@ -0,0 +1,476 @@ +package net.minecraft.client.multiplayer; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.Minecraft; +import net.minecraft.client.audio.PositionedSoundRecord; +import net.minecraft.client.entity.EntityClientPlayerMP; +import net.minecraft.client.network.NetHandlerPlayClient; +import net.minecraft.entity.Entity; +import net.minecraft.entity.passive.EntityHorse; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemSword; +import net.minecraft.network.play.client.C02PacketUseEntity; +import net.minecraft.network.play.client.C07PacketPlayerDigging; +import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement; +import net.minecraft.network.play.client.C09PacketHeldItemChange; +import net.minecraft.network.play.client.C0EPacketClickWindow; +import net.minecraft.network.play.client.C10PacketCreativeInventoryAction; +import net.minecraft.network.play.client.C11PacketEnchantItem; +import net.minecraft.stats.StatFileWriter; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; +import net.minecraft.world.WorldSettings; + +import net.minecraftforge.common.ForgeHooks; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent; + +@SideOnly(Side.CLIENT) +public class PlayerControllerMP +{ + private final Minecraft mc; + private final NetHandlerPlayClient netClientHandler; + private int currentBlockX = -1; + private int currentBlockY = -1; + private int currentblockZ = -1; + private ItemStack currentItemHittingBlock; + private float curBlockDamageMP; + private float stepSoundTickCounter; + private int blockHitDelay; + private boolean isHittingBlock; + private WorldSettings.GameType currentGameType; + private int currentPlayerItem; + private static final String __OBFID = "CL_00000881"; + + public PlayerControllerMP(Minecraft p_i45062_1_, NetHandlerPlayClient p_i45062_2_) + { + this.currentGameType = WorldSettings.GameType.SURVIVAL; + this.mc = p_i45062_1_; + this.netClientHandler = p_i45062_2_; + } + + public static void clickBlockCreative(Minecraft par0Minecraft, PlayerControllerMP par1PlayerControllerMP, int par2, int par3, int par4, int par5) + { + if (!par0Minecraft.theWorld.extinguishFire(par0Minecraft.thePlayer, par2, par3, par4, par5)) + { + par1PlayerControllerMP.onPlayerDestroyBlock(par2, par3, par4, par5); + } + } + + public void setPlayerCapabilities(EntityPlayer par1EntityPlayer) + { + this.currentGameType.configurePlayerCapabilities(par1EntityPlayer.capabilities); + } + + public boolean enableEverythingIsScrewedUpMode() + { + return false; + } + + public void setGameType(WorldSettings.GameType par1EnumGameType) + { + this.currentGameType = par1EnumGameType; + this.currentGameType.configurePlayerCapabilities(this.mc.thePlayer.capabilities); + } + + public void flipPlayer(EntityPlayer par1EntityPlayer) + { + par1EntityPlayer.rotationYaw = -180.0F; + } + + public boolean shouldDrawHUD() + { + return this.currentGameType.isSurvivalOrAdventure(); + } + + public boolean onPlayerDestroyBlock(int par1, int par2, int par3, int par4) + { + ItemStack stack = mc.thePlayer.getCurrentEquippedItem(); + if (stack != null && stack.getItem() != null && stack.getItem().onBlockStartBreak(stack, par1, par2, par3, mc.thePlayer)) + { + return false; + } + + if (this.currentGameType.isAdventure() && !this.mc.thePlayer.isCurrentToolAdventureModeExempt(par1, par2, par3)) + { + return false; + } + else if (this.currentGameType.isCreative() && this.mc.thePlayer.getHeldItem() != null && this.mc.thePlayer.getHeldItem().getItem() instanceof ItemSword) + { + return false; + } + else + { + WorldClient worldclient = this.mc.theWorld; + Block block = worldclient.getBlock(par1, par2, par3); + + if (block.getMaterial() == Material.air) + { + return false; + } + else + { + worldclient.playAuxSFX(2001, par1, par2, par3, Block.getIdFromBlock(block) + (worldclient.getBlockMetadata(par1, par2, par3) << 12)); + int i1 = worldclient.getBlockMetadata(par1, par2, par3); + boolean flag = block.removedByPlayer(worldclient, mc.thePlayer, par1, par2, par3); + + if (flag) + { + block.onBlockDestroyedByPlayer(worldclient, par1, par2, par3, i1); + } + + this.currentBlockY = -1; + + if (!this.currentGameType.isCreative()) + { + ItemStack itemstack = this.mc.thePlayer.getCurrentEquippedItem(); + + if (itemstack != null) + { + itemstack.func_150999_a(worldclient, block, par1, par2, par3, this.mc.thePlayer); + + if (itemstack.stackSize == 0) + { + this.mc.thePlayer.destroyCurrentEquippedItem(); + } + } + } + + return flag; + } + } + } + + public void clickBlock(int par1, int par2, int par3, int par4) + { + if (!this.currentGameType.isAdventure() || this.mc.thePlayer.isCurrentToolAdventureModeExempt(par1, par2, par3)) + { + if (this.currentGameType.isCreative()) + { + this.netClientHandler.addToSendQueue(new C07PacketPlayerDigging(0, par1, par2, par3, par4)); + clickBlockCreative(this.mc, this, par1, par2, par3, par4); + this.blockHitDelay = 5; + } + else if (!this.isHittingBlock || !this.sameToolAndBlock(par1, par2, par3)) + { + if (this.isHittingBlock) + { + this.netClientHandler.addToSendQueue(new C07PacketPlayerDigging(1, this.currentBlockX, this.currentBlockY, this.currentblockZ, par4)); + } + + this.netClientHandler.addToSendQueue(new C07PacketPlayerDigging(0, par1, par2, par3, par4)); + Block block = this.mc.theWorld.getBlock(par1, par2, par3); + boolean flag = block.getMaterial() != Material.air; + + if (flag && this.curBlockDamageMP == 0.0F) + { + block.onBlockClicked(this.mc.theWorld, par1, par2, par3, this.mc.thePlayer); + } + + if (flag && block.getPlayerRelativeBlockHardness(this.mc.thePlayer, this.mc.thePlayer.worldObj, par1, par2, par3) >= 1.0F) + { + this.onPlayerDestroyBlock(par1, par2, par3, par4); + } + else + { + this.isHittingBlock = true; + this.currentBlockX = par1; + this.currentBlockY = par2; + this.currentblockZ = par3; + this.currentItemHittingBlock = this.mc.thePlayer.getHeldItem(); + this.curBlockDamageMP = 0.0F; + this.stepSoundTickCounter = 0.0F; + this.mc.theWorld.destroyBlockInWorldPartially(this.mc.thePlayer.getEntityId(), this.currentBlockX, this.currentBlockY, this.currentblockZ, (int)(this.curBlockDamageMP * 10.0F) - 1); + } + } + } + } + + public void resetBlockRemoving() + { + if (this.isHittingBlock) + { + this.netClientHandler.addToSendQueue(new C07PacketPlayerDigging(1, this.currentBlockX, this.currentBlockY, this.currentblockZ, -1)); + } + + this.isHittingBlock = false; + this.curBlockDamageMP = 0.0F; + this.mc.theWorld.destroyBlockInWorldPartially(this.mc.thePlayer.getEntityId(), this.currentBlockX, this.currentBlockY, this.currentblockZ, -1); + } + + public void onPlayerDamageBlock(int par1, int par2, int par3, int par4) + { + this.syncCurrentPlayItem(); + + if (this.blockHitDelay > 0) + { + --this.blockHitDelay; + } + else if (this.currentGameType.isCreative()) + { + this.blockHitDelay = 5; + this.netClientHandler.addToSendQueue(new C07PacketPlayerDigging(0, par1, par2, par3, par4)); + clickBlockCreative(this.mc, this, par1, par2, par3, par4); + } + else + { + if (this.sameToolAndBlock(par1, par2, par3)) + { + Block block = this.mc.theWorld.getBlock(par1, par2, par3); + + if (block.getMaterial() == Material.air) + { + this.isHittingBlock = false; + return; + } + + this.curBlockDamageMP += block.getPlayerRelativeBlockHardness(this.mc.thePlayer, this.mc.thePlayer.worldObj, par1, par2, par3); + + if (this.stepSoundTickCounter % 4.0F == 0.0F) + { + this.mc.getSoundHandler().playSound(new PositionedSoundRecord(new ResourceLocation(block.stepSound.getStepResourcePath()), (block.stepSound.getVolume() + 1.0F) / 8.0F, block.stepSound.getPitch() * 0.5F, (float)par1 + 0.5F, (float)par2 + 0.5F, (float)par3 + 0.5F)); + } + + ++this.stepSoundTickCounter; + + if (this.curBlockDamageMP >= 1.0F) + { + this.isHittingBlock = false; + this.netClientHandler.addToSendQueue(new C07PacketPlayerDigging(2, par1, par2, par3, par4)); + this.onPlayerDestroyBlock(par1, par2, par3, par4); + this.curBlockDamageMP = 0.0F; + this.stepSoundTickCounter = 0.0F; + this.blockHitDelay = 5; + } + + this.mc.theWorld.destroyBlockInWorldPartially(this.mc.thePlayer.getEntityId(), this.currentBlockX, this.currentBlockY, this.currentblockZ, (int)(this.curBlockDamageMP * 10.0F) - 1); + } + else + { + this.clickBlock(par1, par2, par3, par4); + } + } + } + + public float getBlockReachDistance() + { + return this.currentGameType.isCreative() ? 5.0F : 4.5F; + } + + public void updateController() + { + this.syncCurrentPlayItem(); + + if (this.netClientHandler.getNetworkManager().isChannelOpen()) + { + this.netClientHandler.getNetworkManager().processReceivedPackets(); + } + else if (this.netClientHandler.getNetworkManager().getExitMessage() != null) + { + this.netClientHandler.getNetworkManager().getNetHandler().onDisconnect(this.netClientHandler.getNetworkManager().getExitMessage()); + } + else + { + this.netClientHandler.getNetworkManager().getNetHandler().onDisconnect(new ChatComponentText("Disconnected from server")); + } + } + + private boolean sameToolAndBlock(int par1, int par2, int par3) + { + ItemStack itemstack = this.mc.thePlayer.getHeldItem(); + boolean flag = this.currentItemHittingBlock == null && itemstack == null; + + if (this.currentItemHittingBlock != null && itemstack != null) + { + flag = itemstack.getItem() == this.currentItemHittingBlock.getItem() && ItemStack.areItemStackTagsEqual(itemstack, this.currentItemHittingBlock) && (itemstack.isItemStackDamageable() || itemstack.getItemDamage() == this.currentItemHittingBlock.getItemDamage()); + } + + return par1 == this.currentBlockX && par2 == this.currentBlockY && par3 == this.currentblockZ && flag; + } + + private void syncCurrentPlayItem() + { + int i = this.mc.thePlayer.inventory.currentItem; + + if (i != this.currentPlayerItem) + { + this.currentPlayerItem = i; + this.netClientHandler.addToSendQueue(new C09PacketHeldItemChange(this.currentPlayerItem)); + } + } + + public boolean onPlayerRightClick(EntityPlayer par1EntityPlayer, World par2World, ItemStack par3ItemStack, int par4, int par5, int par6, int par7, Vec3 par8Vec3) + { + this.syncCurrentPlayItem(); + float f = (float)par8Vec3.xCoord - (float)par4; + float f1 = (float)par8Vec3.yCoord - (float)par5; + float f2 = (float)par8Vec3.zCoord - (float)par6; + boolean flag = false; + + if (par3ItemStack != null && + par3ItemStack.getItem() != null && + par3ItemStack.getItem().onItemUseFirst(par3ItemStack, par1EntityPlayer, par2World, par4, par5, par6, par7, f, f1, f2)) + { + return true; + } + + if (!par1EntityPlayer.isSneaking() || par1EntityPlayer.getHeldItem() == null || par1EntityPlayer.getHeldItem().getItem().doesSneakBypassUse(par2World, par4, par5, par6, par1EntityPlayer)) + { + flag = par2World.getBlock(par4, par5, par6).onBlockActivated(par2World, par4, par5, par6, par1EntityPlayer, par7, f, f1, f2); + } + + if (!flag && par3ItemStack != null && par3ItemStack.getItem() instanceof ItemBlock) + { + ItemBlock itemblock = (ItemBlock)par3ItemStack.getItem(); + + if (!itemblock.func_150936_a(par2World, par4, par5, par6, par7, par1EntityPlayer, par3ItemStack)) + { + return false; + } + } + + this.netClientHandler.addToSendQueue(new C08PacketPlayerBlockPlacement(par4, par5, par6, par7, par1EntityPlayer.inventory.getCurrentItem(), f, f1, f2)); + + if (flag) + { + return true; + } + else if (par3ItemStack == null) + { + return false; + } + else if (this.currentGameType.isCreative()) + { + int j1 = par3ItemStack.getItemDamage(); + int i1 = par3ItemStack.stackSize; + boolean flag1 = par3ItemStack.tryPlaceItemIntoWorld(par1EntityPlayer, par2World, par4, par5, par6, par7, f, f1, f2); + par3ItemStack.setItemDamage(j1); + par3ItemStack.stackSize = i1; + return flag1; + } + else + { + if (!par3ItemStack.tryPlaceItemIntoWorld(par1EntityPlayer, par2World, par4, par5, par6, par7, f, f1, f2)) + { + return false; + } + if (par3ItemStack.stackSize <= 0) + { + MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(par1EntityPlayer, par3ItemStack)); + } + return true; + } + } + + public boolean sendUseItem(EntityPlayer par1EntityPlayer, World par2World, ItemStack par3ItemStack) + { + this.syncCurrentPlayItem(); + this.netClientHandler.addToSendQueue(new C08PacketPlayerBlockPlacement(-1, -1, -1, 255, par1EntityPlayer.inventory.getCurrentItem(), 0.0F, 0.0F, 0.0F)); + int i = par3ItemStack.stackSize; + ItemStack itemstack1 = par3ItemStack.useItemRightClick(par2World, par1EntityPlayer); + + if (itemstack1 == par3ItemStack && (itemstack1 == null || itemstack1.stackSize == i)) + { + return false; + } + else + { + par1EntityPlayer.inventory.mainInventory[par1EntityPlayer.inventory.currentItem] = itemstack1; + + if (itemstack1.stackSize <= 0) + { + par1EntityPlayer.inventory.mainInventory[par1EntityPlayer.inventory.currentItem] = null; + MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(par1EntityPlayer, itemstack1)); + } + + return true; + } + } + + public EntityClientPlayerMP func_147493_a(World p_147493_1_, StatFileWriter p_147493_2_) + { + return new EntityClientPlayerMP(this.mc, p_147493_1_, this.mc.getSession(), this.netClientHandler, p_147493_2_); + } + + public void attackEntity(EntityPlayer par1EntityPlayer, Entity par2Entity) + { + this.syncCurrentPlayItem(); + this.netClientHandler.addToSendQueue(new C02PacketUseEntity(par2Entity, C02PacketUseEntity.Action.ATTACK)); + par1EntityPlayer.attackTargetEntityWithCurrentItem(par2Entity); + } + + public boolean interactWithEntitySendPacket(EntityPlayer par1EntityPlayer, Entity par2Entity) + { + this.syncCurrentPlayItem(); + this.netClientHandler.addToSendQueue(new C02PacketUseEntity(par2Entity, C02PacketUseEntity.Action.INTERACT)); + return par1EntityPlayer.interactWith(par2Entity); + } + + public ItemStack windowClick(int par1, int par2, int par3, int par4, EntityPlayer par5EntityPlayer) + { + short short1 = par5EntityPlayer.openContainer.getNextTransactionID(par5EntityPlayer.inventory); + ItemStack itemstack = par5EntityPlayer.openContainer.slotClick(par2, par3, par4, par5EntityPlayer); + this.netClientHandler.addToSendQueue(new C0EPacketClickWindow(par1, par2, par3, par4, itemstack, short1)); + return itemstack; + } + + public void sendEnchantPacket(int par1, int par2) + { + this.netClientHandler.addToSendQueue(new C11PacketEnchantItem(par1, par2)); + } + + public void sendSlotPacket(ItemStack par1ItemStack, int par2) + { + if (this.currentGameType.isCreative()) + { + this.netClientHandler.addToSendQueue(new C10PacketCreativeInventoryAction(par2, par1ItemStack)); + } + } + + public void sendPacketDropItem(ItemStack par1ItemStack) + { + if (this.currentGameType.isCreative() && par1ItemStack != null) + { + this.netClientHandler.addToSendQueue(new C10PacketCreativeInventoryAction(-1, par1ItemStack)); + } + } + + public void onStoppedUsingItem(EntityPlayer par1EntityPlayer) + { + this.syncCurrentPlayItem(); + this.netClientHandler.addToSendQueue(new C07PacketPlayerDigging(5, 0, 0, 0, 255)); + par1EntityPlayer.stopUsingItem(); + } + + public boolean gameIsSurvivalOrAdventure() + { + return this.currentGameType.isSurvivalOrAdventure(); + } + + public boolean isNotCreative() + { + return !this.currentGameType.isCreative(); + } + + public boolean isInCreativeMode() + { + return this.currentGameType.isCreative(); + } + + public boolean extendedReach() + { + return this.currentGameType.isCreative(); + } + + public boolean func_110738_j() + { + return this.mc.thePlayer.isRiding() && this.mc.thePlayer.ridingEntity instanceof EntityHorse; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/multiplayer/ServerAddress.java b/src/main/java/net/minecraft/client/multiplayer/ServerAddress.java new file mode 100644 index 0000000..6e20531 --- /dev/null +++ b/src/main/java/net/minecraft/client/multiplayer/ServerAddress.java @@ -0,0 +1,114 @@ +package net.minecraft.client.multiplayer; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Hashtable; +import javax.naming.directory.Attributes; +import javax.naming.directory.InitialDirContext; + +@SideOnly(Side.CLIENT) +public class ServerAddress +{ + private final String ipAddress; + private final int serverPort; + private static final String __OBFID = "CL_00000889"; + + private ServerAddress(String par1Str, int par2) + { + this.ipAddress = par1Str; + this.serverPort = par2; + } + + public String getIP() + { + return this.ipAddress; + } + + public int getPort() + { + return this.serverPort; + } + + public static ServerAddress func_78860_a(String par0Str) + { + if (par0Str == null) + { + return null; + } + else + { + String[] astring = par0Str.split(":"); + + if (par0Str.startsWith("[")) + { + int i = par0Str.indexOf("]"); + + if (i > 0) + { + String s1 = par0Str.substring(1, i); + String s2 = par0Str.substring(i + 1).trim(); + + if (s2.startsWith(":") && s2.length() > 0) + { + s2 = s2.substring(1); + astring = new String[] {s1, s2}; + } + else + { + astring = new String[] {s1}; + } + } + } + + if (astring.length > 2) + { + astring = new String[] {par0Str}; + } + + String s3 = astring[0]; + int j = astring.length > 1 ? parseIntWithDefault(astring[1], 25565) : 25565; + + if (j == 25565) + { + String[] astring1 = getServerAddress(s3); + s3 = astring1[0]; + j = parseIntWithDefault(astring1[1], 25565); + } + + return new ServerAddress(s3, j); + } + } + + private static String[] getServerAddress(String par0Str) + { + try + { + String s1 = "com.sun.jndi.dns.DnsContextFactory"; + Class.forName("com.sun.jndi.dns.DnsContextFactory"); + Hashtable hashtable = new Hashtable(); + hashtable.put("java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory"); + hashtable.put("java.naming.provider.url", "dns:"); + hashtable.put("com.sun.jndi.dns.timeout.retries", "1"); + InitialDirContext initialdircontext = new InitialDirContext(hashtable); + Attributes attributes = initialdircontext.getAttributes("_minecraft._tcp." + par0Str, new String[] {"SRV"}); + String[] astring = attributes.get("srv").get().toString().split(" ", 4); + return new String[] {astring[3], astring[2]}; + } + catch (Throwable throwable) + { + return new String[] {par0Str, Integer.toString(25565)}; + } + } + + private static int parseIntWithDefault(String par0Str, int par1) + { + try + { + return Integer.parseInt(par0Str.trim()); + } + catch (Exception exception) + { + return par1; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/multiplayer/ServerData.java b/src/main/java/net/minecraft/client/multiplayer/ServerData.java new file mode 100644 index 0000000..32c9c3c --- /dev/null +++ b/src/main/java/net/minecraft/client/multiplayer/ServerData.java @@ -0,0 +1,104 @@ +package net.minecraft.client.multiplayer; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.nbt.NBTTagCompound; + +@SideOnly(Side.CLIENT) +public class ServerData +{ + public String serverName; + public String serverIP; + public String populationInfo; + public String serverMOTD; + public long pingToServer; + public int field_82821_f = 4; + public String gameVersion = "1.7.2"; + public boolean field_78841_f; + public String field_147412_i; + private boolean field_78842_g = true; + private boolean acceptsTextures; + private boolean hideAddress; + private String field_147411_m; + private static final String __OBFID = "CL_00000890"; + + public ServerData(String par1Str, String par2Str) + { + this.serverName = par1Str; + this.serverIP = par2Str; + } + + public NBTTagCompound getNBTCompound() + { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + nbttagcompound.setString("name", this.serverName); + nbttagcompound.setString("ip", this.serverIP); + nbttagcompound.setBoolean("hideAddress", this.hideAddress); + + if (this.field_147411_m != null) + { + nbttagcompound.setString("icon", this.field_147411_m); + } + + if (!this.field_78842_g) + { + nbttagcompound.setBoolean("acceptTextures", this.acceptsTextures); + } + + return nbttagcompound; + } + + public boolean func_147408_b() + { + return this.acceptsTextures; + } + + public boolean func_147410_c() + { + return this.field_78842_g; + } + + public void setAcceptsTextures(boolean par1) + { + this.acceptsTextures = par1; + this.field_78842_g = false; + } + + public boolean isHidingAddress() + { + return this.hideAddress; + } + + public void setHideAddress(boolean par1) + { + this.hideAddress = par1; + } + + public static ServerData getServerDataFromNBTCompound(NBTTagCompound par0NBTTagCompound) + { + ServerData serverdata = new ServerData(par0NBTTagCompound.getString("name"), par0NBTTagCompound.getString("ip")); + serverdata.hideAddress = par0NBTTagCompound.getBoolean("hideAddress"); + + if (par0NBTTagCompound.hasKey("icon", 8)) + { + serverdata.func_147407_a(par0NBTTagCompound.getString("icon")); + } + + if (par0NBTTagCompound.hasKey("acceptTextures", 99)) + { + serverdata.setAcceptsTextures(par0NBTTagCompound.getBoolean("acceptTextures")); + } + + return serverdata; + } + + public String getBase64EncodedIconData() + { + return this.field_147411_m; + } + + public void func_147407_a(String p_147407_1_) + { + this.field_147411_m = p_147407_1_; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/multiplayer/ServerList.java b/src/main/java/net/minecraft/client/multiplayer/ServerList.java new file mode 100644 index 0000000..fc29044 --- /dev/null +++ b/src/main/java/net/minecraft/client/multiplayer/ServerList.java @@ -0,0 +1,129 @@ +package net.minecraft.client.multiplayer; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.File; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import net.minecraft.client.Minecraft; +import net.minecraft.nbt.CompressedStreamTools; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +@SideOnly(Side.CLIENT) +public class ServerList +{ + private static final Logger logger = LogManager.getLogger(); + private final Minecraft mc; + private final List servers = new ArrayList(); + private static final String __OBFID = "CL_00000891"; + + public ServerList(Minecraft par1Minecraft) + { + this.mc = par1Minecraft; + this.loadServerList(); + } + + public void loadServerList() + { + try + { + this.servers.clear(); + NBTTagCompound nbttagcompound = CompressedStreamTools.read(new File(this.mc.mcDataDir, "servers.dat")); + + if (nbttagcompound == null) + { + return; + } + + NBTTagList nbttaglist = nbttagcompound.getTagList("servers", 10); + + for (int i = 0; i < nbttaglist.tagCount(); ++i) + { + this.servers.add(ServerData.getServerDataFromNBTCompound(nbttaglist.getCompoundTagAt(i))); + } + } + catch (Exception exception) + { + logger.error("Couldn\'t load server list", exception); + } + } + + public void saveServerList() + { + try + { + NBTTagList nbttaglist = new NBTTagList(); + Iterator iterator = this.servers.iterator(); + + while (iterator.hasNext()) + { + ServerData serverdata = (ServerData)iterator.next(); + nbttaglist.appendTag(serverdata.getNBTCompound()); + } + + NBTTagCompound nbttagcompound = new NBTTagCompound(); + nbttagcompound.setTag("servers", nbttaglist); + CompressedStreamTools.safeWrite(nbttagcompound, new File(this.mc.mcDataDir, "servers.dat")); + } + catch (Exception exception) + { + logger.error("Couldn\'t save server list", exception); + } + } + + public ServerData getServerData(int par1) + { + return (ServerData)this.servers.get(par1); + } + + public void removeServerData(int par1) + { + this.servers.remove(par1); + } + + public void addServerData(ServerData par1ServerData) + { + this.servers.add(par1ServerData); + } + + public int countServers() + { + return this.servers.size(); + } + + public void swapServers(int par1, int par2) + { + ServerData serverdata = this.getServerData(par1); + this.servers.set(par1, this.getServerData(par2)); + this.servers.set(par2, serverdata); + this.saveServerList(); + } + + public void func_147413_a(int p_147413_1_, ServerData p_147413_2_) + { + this.servers.set(p_147413_1_, p_147413_2_); + } + + public static void func_147414_b(ServerData p_147414_0_) + { + ServerList serverlist = new ServerList(Minecraft.getMinecraft()); + serverlist.loadServerList(); + + for (int i = 0; i < serverlist.countServers(); ++i) + { + ServerData serverdata1 = serverlist.getServerData(i); + + if (serverdata1.serverName.equals(p_147414_0_.serverName) && serverdata1.serverIP.equals(p_147414_0_.serverIP)) + { + serverlist.func_147413_a(i, p_147414_0_); + break; + } + } + + serverlist.saveServerList(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/multiplayer/ThreadLanServerPing.java b/src/main/java/net/minecraft/client/multiplayer/ThreadLanServerPing.java new file mode 100644 index 0000000..98abd82 --- /dev/null +++ b/src/main/java/net/minecraft/client/multiplayer/ThreadLanServerPing.java @@ -0,0 +1,121 @@ +package net.minecraft.client.multiplayer; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; +import java.util.concurrent.atomic.AtomicInteger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +@SideOnly(Side.CLIENT) +public class ThreadLanServerPing extends Thread +{ + private static final AtomicInteger field_148658_a = new AtomicInteger(0); + private static final Logger logger = LogManager.getLogger(); + private final String motd; + private final DatagramSocket socket; + private boolean isStopping = true; + private final String address; + private static final String __OBFID = "CL_00001137"; + + public ThreadLanServerPing(String par1Str, String par2Str) throws IOException + { + super("LanServerPinger #" + field_148658_a.incrementAndGet()); + this.motd = par1Str; + this.address = par2Str; + this.setDaemon(true); + this.socket = new DatagramSocket(); + } + + public void run() + { + String s = getPingResponse(this.motd, this.address); + byte[] abyte = s.getBytes(); + + while (!this.isInterrupted() && this.isStopping) + { + try + { + InetAddress inetaddress = InetAddress.getByName("224.0.2.60"); + DatagramPacket datagrampacket = new DatagramPacket(abyte, abyte.length, inetaddress, 4445); + this.socket.send(datagrampacket); + } + catch (IOException ioexception) + { + logger.warn("LanServerPinger: " + ioexception.getMessage()); + break; + } + + try + { + sleep(1500L); + } + catch (InterruptedException interruptedexception) + { + ; + } + } + } + + public void interrupt() + { + super.interrupt(); + this.isStopping = false; + } + + public static String getPingResponse(String par0Str, String par1Str) + { + return "[MOTD]" + par0Str + "[/MOTD][AD]" + par1Str + "[/AD]"; + } + + public static String getMotdFromPingResponse(String par0Str) + { + int i = par0Str.indexOf("[MOTD]"); + + if (i < 0) + { + return "missing no"; + } + else + { + int j = par0Str.indexOf("[/MOTD]", i + "[MOTD]".length()); + return j < i ? "missing no" : par0Str.substring(i + "[MOTD]".length(), j); + } + } + + public static String getAdFromPingResponse(String par0Str) + { + int i = par0Str.indexOf("[/MOTD]"); + + if (i < 0) + { + return null; + } + else + { + int j = par0Str.indexOf("[/MOTD]", i + "[/MOTD]".length()); + + if (j >= 0) + { + return null; + } + else + { + int k = par0Str.indexOf("[AD]", i + "[/MOTD]".length()); + + if (k < 0) + { + return null; + } + else + { + int l = par0Str.indexOf("[/AD]", k + "[AD]".length()); + return l < k ? null : par0Str.substring(k + "[AD]".length(), l); + } + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/multiplayer/WorldClient.java b/src/main/java/net/minecraft/client/multiplayer/WorldClient.java new file mode 100644 index 0000000..9b8dd95 --- /dev/null +++ b/src/main/java/net/minecraft/client/multiplayer/WorldClient.java @@ -0,0 +1,444 @@ +package net.minecraft.client.multiplayer; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Random; +import java.util.Set; +import java.util.concurrent.Callable; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.Minecraft; +import net.minecraft.client.audio.MovingSoundMinecart; +import net.minecraft.client.audio.PositionedSoundRecord; +import net.minecraft.client.network.NetHandlerPlayClient; +import net.minecraft.client.particle.EntityFireworkStarterFX; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.crash.CrashReport; +import net.minecraft.crash.CrashReportCategory; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityMinecart; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.profiler.Profiler; +import net.minecraft.scoreboard.Scoreboard; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.IntHashMap; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.ChunkCoordIntPair; +import net.minecraft.world.EnumDifficulty; +import net.minecraft.world.World; +import net.minecraft.world.WorldProvider; +import net.minecraft.world.WorldSettings; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.IChunkProvider; +import net.minecraft.world.storage.SaveHandlerMP; + +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.world.WorldEvent; + +@SideOnly(Side.CLIENT) +public class WorldClient extends World +{ + private NetHandlerPlayClient sendQueue; + private ChunkProviderClient clientChunkProvider; + private IntHashMap entityHashSet = new IntHashMap(); + private Set entityList = new HashSet(); + private Set entitySpawnQueue = new HashSet(); + private final Minecraft mc = Minecraft.getMinecraft(); + private final Set previousActiveChunkSet = new HashSet(); + private static final String __OBFID = "CL_00000882"; + + public WorldClient(NetHandlerPlayClient p_i45063_1_, WorldSettings p_i45063_2_, int p_i45063_3_, EnumDifficulty p_i45063_4_, Profiler p_i45063_5_) + { + super(new SaveHandlerMP(), "MpServer", WorldProvider.getProviderForDimension(p_i45063_3_), p_i45063_2_, p_i45063_5_); + this.sendQueue = p_i45063_1_; + this.difficultySetting = p_i45063_4_; + this.mapStorage = p_i45063_1_.mapStorageOrigin; + this.isRemote = true; + this.finishSetup(); + this.setSpawnLocation(8, 64, 8); + MinecraftForge.EVENT_BUS.post(new WorldEvent.Load(this)); + } + + public void tick() + { + super.tick(); + this.func_82738_a(this.getTotalWorldTime() + 1L); + + if (this.getGameRules().getGameRuleBooleanValue("doDaylightCycle")) + { + this.setWorldTime(this.getWorldTime() + 1L); + } + + this.theProfiler.startSection("reEntryProcessing"); + + for (int i = 0; i < 10 && !this.entitySpawnQueue.isEmpty(); ++i) + { + Entity entity = (Entity)this.entitySpawnQueue.iterator().next(); + this.entitySpawnQueue.remove(entity); + + if (!this.loadedEntityList.contains(entity)) + { + this.spawnEntityInWorld(entity); + } + } + + this.theProfiler.endStartSection("connection"); + this.sendQueue.onNetworkTick(); + this.theProfiler.endStartSection("chunkCache"); + this.clientChunkProvider.unloadQueuedChunks(); + this.theProfiler.endStartSection("blocks"); + this.func_147456_g(); + this.theProfiler.endSection(); + } + + public void invalidateBlockReceiveRegion(int par1, int par2, int par3, int par4, int par5, int par6) {} + + protected IChunkProvider createChunkProvider() + { + this.clientChunkProvider = new ChunkProviderClient(this); + return this.clientChunkProvider; + } + + protected void func_147456_g() + { + super.func_147456_g(); + this.previousActiveChunkSet.retainAll(this.activeChunkSet); + + if (this.previousActiveChunkSet.size() == this.activeChunkSet.size()) + { + this.previousActiveChunkSet.clear(); + } + + int i = 0; + Iterator iterator = this.activeChunkSet.iterator(); + + while (iterator.hasNext()) + { + ChunkCoordIntPair chunkcoordintpair = (ChunkCoordIntPair)iterator.next(); + + if (!this.previousActiveChunkSet.contains(chunkcoordintpair)) + { + int j = chunkcoordintpair.chunkXPos * 16; + int k = chunkcoordintpair.chunkZPos * 16; + this.theProfiler.startSection("getChunk"); + Chunk chunk = this.getChunkFromChunkCoords(chunkcoordintpair.chunkXPos, chunkcoordintpair.chunkZPos); + this.func_147467_a(j, k, chunk); + this.theProfiler.endSection(); + this.previousActiveChunkSet.add(chunkcoordintpair); + ++i; + + if (i >= 10) + { + return; + } + } + } + } + + public void doPreChunk(int par1, int par2, boolean par3) + { + if (par3) + { + this.clientChunkProvider.loadChunk(par1, par2); + } + else + { + this.clientChunkProvider.unloadChunk(par1, par2); + } + + if (!par3) + { + this.markBlockRangeForRenderUpdate(par1 * 16, 0, par2 * 16, par1 * 16 + 15, 256, par2 * 16 + 15); + } + } + + public boolean spawnEntityInWorld(Entity par1Entity) + { + boolean flag = super.spawnEntityInWorld(par1Entity); + this.entityList.add(par1Entity); + + if (!flag) + { + this.entitySpawnQueue.add(par1Entity); + } + else if (par1Entity instanceof EntityMinecart) + { + this.mc.getSoundHandler().playSound(new MovingSoundMinecart((EntityMinecart)par1Entity)); + } + + return flag; + } + + public void removeEntity(Entity par1Entity) + { + super.removeEntity(par1Entity); + this.entityList.remove(par1Entity); + } + + public void onEntityAdded(Entity par1Entity) + { + super.onEntityAdded(par1Entity); + + if (this.entitySpawnQueue.contains(par1Entity)) + { + this.entitySpawnQueue.remove(par1Entity); + } + } + + public void onEntityRemoved(Entity par1Entity) + { + super.onEntityRemoved(par1Entity); + boolean flag = false; + + if (this.entityList.contains(par1Entity)) + { + if (par1Entity.isEntityAlive()) + { + this.entitySpawnQueue.add(par1Entity); + flag = true; + } + else + { + this.entityList.remove(par1Entity); + } + } + + if (RenderManager.instance.getEntityRenderObject(par1Entity).isStaticEntity() && !flag) + { + this.mc.renderGlobal.onStaticEntitiesChanged(); + } + } + + public void addEntityToWorld(int par1, Entity par2Entity) + { + Entity entity1 = this.getEntityByID(par1); + + if (entity1 != null) + { + this.removeEntity(entity1); + } + + this.entityList.add(par2Entity); + par2Entity.setEntityId(par1); + + if (!this.spawnEntityInWorld(par2Entity)) + { + this.entitySpawnQueue.add(par2Entity); + } + + this.entityHashSet.addKey(par1, par2Entity); + + if (RenderManager.instance.getEntityRenderObject(par2Entity).isStaticEntity()) + { + this.mc.renderGlobal.onStaticEntitiesChanged(); + } + } + + public Entity getEntityByID(int par1) + { + return (Entity)(par1 == this.mc.thePlayer.getEntityId() ? this.mc.thePlayer : (Entity)this.entityHashSet.lookup(par1)); + } + + public Entity removeEntityFromWorld(int par1) + { + Entity entity = (Entity)this.entityHashSet.removeObject(par1); + + if (entity != null) + { + this.entityList.remove(entity); + this.removeEntity(entity); + } + + return entity; + } + + public boolean func_147492_c(int p_147492_1_, int p_147492_2_, int p_147492_3_, Block p_147492_4_, int p_147492_5_) + { + this.invalidateBlockReceiveRegion(p_147492_1_, p_147492_2_, p_147492_3_, p_147492_1_, p_147492_2_, p_147492_3_); + return super.setBlock(p_147492_1_, p_147492_2_, p_147492_3_, p_147492_4_, p_147492_5_, 3); + } + + public void sendQuittingDisconnectingPacket() + { + this.sendQueue.getNetworkManager().closeChannel(new ChatComponentText("Quitting")); + } + + protected void updateWeather() + { + super.updateWeather(); + } + + @Override + public void updateWeatherBody() + { + if (!this.provider.hasNoSky) + { + ; + } + } + + public void doVoidFogParticles(int par1, int par2, int par3) + { + byte b0 = 16; + Random random = new Random(); + + for (int l = 0; l < 1000; ++l) + { + int i1 = par1 + this.rand.nextInt(b0) - this.rand.nextInt(b0); + int j1 = par2 + this.rand.nextInt(b0) - this.rand.nextInt(b0); + int k1 = par3 + this.rand.nextInt(b0) - this.rand.nextInt(b0); + Block block = this.getBlock(i1, j1, k1); + + if (block.getMaterial() == Material.air) + { + if (this.rand.nextInt(8) > j1 && this.provider.getWorldHasVoidParticles()) + { + this.spawnParticle("depthsuspend", (double)((float)i1 + this.rand.nextFloat()), (double)((float)j1 + this.rand.nextFloat()), (double)((float)k1 + this.rand.nextFloat()), 0.0D, 0.0D, 0.0D); + } + } + else + { + block.randomDisplayTick(this, i1, j1, k1, random); + } + } + } + + public void removeAllEntities() + { + this.loadedEntityList.removeAll(this.unloadedEntityList); + int i; + Entity entity; + int j; + int k; + + for (i = 0; i < this.unloadedEntityList.size(); ++i) + { + entity = (Entity)this.unloadedEntityList.get(i); + j = entity.chunkCoordX; + k = entity.chunkCoordZ; + + if (entity.addedToChunk && this.chunkExists(j, k)) + { + this.getChunkFromChunkCoords(j, k).removeEntity(entity); + } + } + + for (i = 0; i < this.unloadedEntityList.size(); ++i) + { + this.onEntityRemoved((Entity)this.unloadedEntityList.get(i)); + } + + this.unloadedEntityList.clear(); + + for (i = 0; i < this.loadedEntityList.size(); ++i) + { + entity = (Entity)this.loadedEntityList.get(i); + + if (entity.ridingEntity != null) + { + if (!entity.ridingEntity.isDead && entity.ridingEntity.riddenByEntity == entity) + { + continue; + } + + entity.ridingEntity.riddenByEntity = null; + entity.ridingEntity = null; + } + + if (entity.isDead) + { + j = entity.chunkCoordX; + k = entity.chunkCoordZ; + + if (entity.addedToChunk && this.chunkExists(j, k)) + { + this.getChunkFromChunkCoords(j, k).removeEntity(entity); + } + + this.loadedEntityList.remove(i--); + this.onEntityRemoved(entity); + } + } + } + + public CrashReportCategory addWorldInfoToCrashReport(CrashReport par1CrashReport) + { + CrashReportCategory crashreportcategory = super.addWorldInfoToCrashReport(par1CrashReport); + crashreportcategory.addCrashSectionCallable("Forced entities", new Callable() + { + private static final String __OBFID = "CL_00000883"; + public String call() + { + return WorldClient.this.entityList.size() + " total; " + WorldClient.this.entityList.toString(); + } + }); + crashreportcategory.addCrashSectionCallable("Retry entities", new Callable() + { + private static final String __OBFID = "CL_00000884"; + public String call() + { + return WorldClient.this.entitySpawnQueue.size() + " total; " + WorldClient.this.entitySpawnQueue.toString(); + } + }); + crashreportcategory.addCrashSectionCallable("Server brand", new Callable() + { + private static final String __OBFID = "CL_00000885"; + public String call() + { + return WorldClient.this.mc.thePlayer.func_142021_k(); + } + }); + crashreportcategory.addCrashSectionCallable("Server type", new Callable() + { + private static final String __OBFID = "CL_00000886"; + public String call() + { + return WorldClient.this.mc.getIntegratedServer() == null ? "Non-integrated multiplayer server" : "Integrated singleplayer server"; + } + }); + return crashreportcategory; + } + + public void playSound(double par1, double par3, double par5, String par7Str, float par8, float par9, boolean par10) + { + double d3 = this.mc.renderViewEntity.getDistanceSq(par1, par3, par5); + PositionedSoundRecord positionedsoundrecord = new PositionedSoundRecord(new ResourceLocation(par7Str), par8, par9, (float)par1, (float)par3, (float)par5); + + if (par10 && d3 > 100.0D) + { + double d4 = Math.sqrt(d3) / 40.0D; + this.mc.getSoundHandler().playDelayedSound(positionedsoundrecord, (int)(d4 * 20.0D)); + } + else + { + this.mc.getSoundHandler().playSound(positionedsoundrecord); + } + } + + public void makeFireworks(double par1, double par3, double par5, double par7, double par9, double par11, NBTTagCompound par13NBTTagCompound) + { + this.mc.effectRenderer.addEffect(new EntityFireworkStarterFX(this, par1, par3, par5, par7, par9, par11, this.mc.effectRenderer, par13NBTTagCompound)); + } + + public void setWorldScoreboard(Scoreboard par1Scoreboard) + { + this.worldScoreboard = par1Scoreboard; + } + + public void setWorldTime(long par1) + { + if (par1 < 0L) + { + par1 = -par1; + this.getGameRules().setOrCreateGameRule("doDaylightCycle", "false"); + } + else + { + this.getGameRules().setOrCreateGameRule("doDaylightCycle", "true"); + } + + super.setWorldTime(par1); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/network/LanServerDetector.java b/src/main/java/net/minecraft/client/network/LanServerDetector.java new file mode 100644 index 0000000..1593c14 --- /dev/null +++ b/src/main/java/net/minecraft/client/network/LanServerDetector.java @@ -0,0 +1,170 @@ +package net.minecraft.client.network; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import java.net.DatagramPacket; +import java.net.InetAddress; +import java.net.MulticastSocket; +import java.net.SocketTimeoutException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; +import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.ThreadLanServerPing; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +@SideOnly(Side.CLIENT) +public class LanServerDetector +{ + private static final AtomicInteger field_148551_a = new AtomicInteger(0); + private static final Logger logger = LogManager.getLogger(); + private static final String __OBFID = "CL_00001133"; + + @SideOnly(Side.CLIENT) + public static class LanServer + { + private String lanServerMotd; + private String lanServerIpPort; + private long timeLastSeen; + private static final String __OBFID = "CL_00001134"; + + public LanServer(String par1Str, String par2Str) + { + this.lanServerMotd = par1Str; + this.lanServerIpPort = par2Str; + this.timeLastSeen = Minecraft.getSystemTime(); + } + + public String getServerMotd() + { + return this.lanServerMotd; + } + + public String getServerIpPort() + { + return this.lanServerIpPort; + } + + public void updateLastSeen() + { + this.timeLastSeen = Minecraft.getSystemTime(); + } + } + + @SideOnly(Side.CLIENT) + public static class LanServerList + { + private ArrayList listOfLanServers = new ArrayList(); + boolean wasUpdated; + private static final String __OBFID = "CL_00001136"; + + public synchronized boolean getWasUpdated() + { + return this.wasUpdated; + } + + public synchronized void setWasNotUpdated() + { + this.wasUpdated = false; + } + + public synchronized List getLanServers() + { + return Collections.unmodifiableList(this.listOfLanServers); + } + + public synchronized void func_77551_a(String par1Str, InetAddress par2InetAddress) + { + String s1 = ThreadLanServerPing.getMotdFromPingResponse(par1Str); + String s2 = ThreadLanServerPing.getAdFromPingResponse(par1Str); + + if (s2 != null) + { + s2 = par2InetAddress.getHostAddress() + ":" + s2; + boolean flag = false; + Iterator iterator = this.listOfLanServers.iterator(); + + while (iterator.hasNext()) + { + LanServerDetector.LanServer lanserver = (LanServerDetector.LanServer)iterator.next(); + + if (lanserver.getServerIpPort().equals(s2)) + { + lanserver.updateLastSeen(); + flag = true; + break; + } + } + + if (!flag) + { + this.listOfLanServers.add(new LanServerDetector.LanServer(s1, s2)); + this.wasUpdated = true; + } + } + } + } + + @SideOnly(Side.CLIENT) + public static class ThreadLanServerFind extends Thread + { + private final LanServerDetector.LanServerList localServerList; + private final InetAddress broadcastAddress; + private final MulticastSocket socket; + private static final String __OBFID = "CL_00001135"; + + public ThreadLanServerFind(LanServerDetector.LanServerList par1LanServerList) throws IOException + { + super("LanServerDetector #" + LanServerDetector.field_148551_a.incrementAndGet()); + this.localServerList = par1LanServerList; + this.setDaemon(true); + this.socket = new MulticastSocket(4445); + this.broadcastAddress = InetAddress.getByName("224.0.2.60"); + this.socket.setSoTimeout(5000); + this.socket.joinGroup(this.broadcastAddress); + } + + public void run() + { + byte[] abyte = new byte[1024]; + + while (!this.isInterrupted()) + { + DatagramPacket datagrampacket = new DatagramPacket(abyte, abyte.length); + + try + { + this.socket.receive(datagrampacket); + } + catch (SocketTimeoutException sockettimeoutexception) + { + continue; + } + catch (IOException ioexception1) + { + LanServerDetector.logger.error("Couldn\'t ping server", ioexception1); + break; + } + + String s = new String(datagrampacket.getData(), datagrampacket.getOffset(), datagrampacket.getLength()); + LanServerDetector.logger.debug(datagrampacket.getAddress() + ": " + s); + this.localServerList.func_77551_a(s, datagrampacket.getAddress()); + } + + try + { + this.socket.leaveGroup(this.broadcastAddress); + } + catch (IOException ioexception) + { + ; + } + + this.socket.close(); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/network/NetHandlerHandshakeMemory.java b/src/main/java/net/minecraft/client/network/NetHandlerHandshakeMemory.java new file mode 100644 index 0000000..0f256e1 --- /dev/null +++ b/src/main/java/net/minecraft/client/network/NetHandlerHandshakeMemory.java @@ -0,0 +1,79 @@ +package net.minecraft.client.network; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.network.EnumConnectionState; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.handshake.INetHandlerHandshakeServer; +import net.minecraft.network.handshake.client.C00Handshake; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.network.NetHandlerLoginServer; +import net.minecraft.util.IChatComponent; +import org.apache.commons.lang3.Validate; + +@SideOnly(Side.CLIENT) +public class NetHandlerHandshakeMemory implements INetHandlerHandshakeServer +{ + private final MinecraftServer field_147385_a; + private final NetworkManager field_147384_b; + private static final String __OBFID = "CL_00001445"; + + public NetHandlerHandshakeMemory(MinecraftServer p_i45287_1_, NetworkManager p_i45287_2_) + { + this.field_147385_a = p_i45287_1_; + this.field_147384_b = p_i45287_2_; + } + + public void processHandshake(C00Handshake p_147383_1_) + { + this.field_147384_b.setConnectionState(p_147383_1_.func_149594_c()); + } + + public void onDisconnect(IChatComponent p_147231_1_) {} + + public void onConnectionStateTransition(EnumConnectionState p_147232_1_, EnumConnectionState p_147232_2_) + { + Validate.validState(p_147232_2_ == EnumConnectionState.LOGIN || p_147232_2_ == EnumConnectionState.STATUS, "Unexpected protocol " + p_147232_2_, new Object[0]); + + switch (NetHandlerHandshakeMemory.SwitchEnumConnectionState.field_151263_a[p_147232_2_.ordinal()]) + { + case 1: + this.field_147384_b.setNetHandler(new NetHandlerLoginServer(this.field_147385_a, this.field_147384_b)); + break; + case 2: + throw new UnsupportedOperationException("NYI"); + default: + } + } + + public void onNetworkTick() {} + + @SideOnly(Side.CLIENT) + + static final class SwitchEnumConnectionState + { + static final int[] field_151263_a = new int[EnumConnectionState.values().length]; + private static final String __OBFID = "CL_00001446"; + + static + { + try + { + field_151263_a[EnumConnectionState.LOGIN.ordinal()] = 1; + } + catch (NoSuchFieldError var2) + { + ; + } + + try + { + field_151263_a[EnumConnectionState.STATUS.ordinal()] = 2; + } + catch (NoSuchFieldError var1) + { + ; + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/network/NetHandlerLoginClient.java b/src/main/java/net/minecraft/client/network/NetHandlerLoginClient.java new file mode 100644 index 0000000..c30a8c4 --- /dev/null +++ b/src/main/java/net/minecraft/client/network/NetHandlerLoginClient.java @@ -0,0 +1,120 @@ +package net.minecraft.client.network; + +import com.mojang.authlib.exceptions.AuthenticationException; +import com.mojang.authlib.exceptions.AuthenticationUnavailableException; +import com.mojang.authlib.exceptions.InvalidCredentialsException; +import com.mojang.authlib.minecraft.MinecraftSessionService; +import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; + +import cpw.mods.fml.common.network.internal.FMLNetworkHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.util.concurrent.Future; +import io.netty.util.concurrent.GenericFutureListener; +import java.math.BigInteger; +import java.security.PublicKey; +import java.util.UUID; +import javax.crypto.SecretKey; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiDisconnected; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.network.EnumConnectionState; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.login.INetHandlerLoginClient; +import net.minecraft.network.login.client.C01PacketEncryptionResponse; +import net.minecraft.network.login.server.S00PacketDisconnect; +import net.minecraft.network.login.server.S01PacketEncryptionRequest; +import net.minecraft.network.login.server.S02PacketLoginSuccess; +import net.minecraft.network.play.client.C17PacketCustomPayload; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.CryptManager; +import net.minecraft.util.IChatComponent; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +@SideOnly(Side.CLIENT) +public class NetHandlerLoginClient implements INetHandlerLoginClient +{ + private static final Logger logger = LogManager.getLogger(); + private final Minecraft field_147394_b; + private final GuiScreen field_147395_c; + private final NetworkManager field_147393_d; + private static final String __OBFID = "CL_00000876"; + + public NetHandlerLoginClient(NetworkManager p_i45059_1_, Minecraft p_i45059_2_, GuiScreen p_i45059_3_) + { + this.field_147393_d = p_i45059_1_; + this.field_147394_b = p_i45059_2_; + this.field_147395_c = p_i45059_3_; + } + + public void handleEncryptionRequest(S01PacketEncryptionRequest p_147389_1_) + { + final SecretKey secretkey = CryptManager.createNewSharedKey(); + String s = p_147389_1_.func_149609_c(); + PublicKey publickey = p_147389_1_.func_149608_d(); + String s1 = (new BigInteger(CryptManager.getServerIdHash(s, publickey, secretkey))).toString(16); + + try + { + this.func_147391_c().joinServer(this.field_147394_b.getSession().func_148256_e(), this.field_147394_b.getSession().getToken(), s1); + } + catch (AuthenticationUnavailableException authenticationunavailableexception) + { + this.field_147393_d.closeChannel(new ChatComponentTranslation("disconnect.loginFailedInfo", new Object[] {new ChatComponentTranslation("disconnect.loginFailedInfo.serversUnavailable", new Object[0])})); + return; + } + catch (InvalidCredentialsException invalidcredentialsexception) + { + this.field_147393_d.closeChannel(new ChatComponentTranslation("disconnect.loginFailedInfo", new Object[] {new ChatComponentTranslation("disconnect.loginFailedInfo.invalidSession", new Object[0])})); + return; + } + catch (AuthenticationException authenticationexception) + { + this.field_147393_d.closeChannel(new ChatComponentTranslation("disconnect.loginFailedInfo", new Object[] {authenticationexception.getMessage()})); + return; + } + + this.field_147393_d.scheduleOutboundPacket(new C01PacketEncryptionResponse(secretkey, publickey, p_147389_1_.func_149607_e()), new GenericFutureListener[] {new GenericFutureListener() + { + private static final String __OBFID = "CL_00000877"; + public void operationComplete(Future p_operationComplete_1_) + { + NetHandlerLoginClient.this.field_147393_d.enableEncryption(secretkey); + } + } + }); + } + + private MinecraftSessionService func_147391_c() + { + return (new YggdrasilAuthenticationService(this.field_147394_b.getProxy(), UUID.randomUUID().toString())).createMinecraftSessionService(); + } + + public void handleLoginSuccess(S02PacketLoginSuccess p_147390_1_) + { + FMLNetworkHandler.fmlClientHandshake(this.field_147393_d); + } + + public void onDisconnect(IChatComponent p_147231_1_) + { + this.field_147394_b.displayGuiScreen(new GuiDisconnected(this.field_147395_c, "connect.failed", p_147231_1_)); + } + + public void onConnectionStateTransition(EnumConnectionState p_147232_1_, EnumConnectionState p_147232_2_) + { + logger.debug("Switching protocol from " + p_147232_1_ + " to " + p_147232_2_); + + if (p_147232_2_ == EnumConnectionState.PLAY) + { + this.field_147393_d.setNetHandler(new NetHandlerPlayClient(this.field_147394_b, this.field_147395_c, this.field_147393_d)); + } + } + + public void onNetworkTick() {} + + public void handleDisconnect(S00PacketDisconnect p_147388_1_) + { + this.field_147393_d.closeChannel(p_147388_1_.func_149603_c()); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/network/NetHandlerPlayClient.java b/src/main/java/net/minecraft/client/network/NetHandlerPlayClient.java new file mode 100644 index 0000000..36036ee --- /dev/null +++ b/src/main/java/net/minecraft/client/network/NetHandlerPlayClient.java @@ -0,0 +1,1635 @@ +package net.minecraft.client.network; + +import com.google.common.base.Charsets; +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; +import io.netty.util.concurrent.GenericFutureListener; +import java.io.ByteArrayInputStream; +import java.io.DataInputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.Map.Entry; +import net.minecraft.block.Block; +import net.minecraft.client.ClientBrandRetriever; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityClientPlayerMP; +import net.minecraft.client.entity.EntityOtherPlayerMP; +import net.minecraft.client.gui.GuiChat; +import net.minecraft.client.gui.GuiDisconnected; +import net.minecraft.client.gui.GuiDownloadTerrain; +import net.minecraft.client.gui.GuiMainMenu; +import net.minecraft.client.gui.GuiMerchant; +import net.minecraft.client.gui.GuiMultiplayer; +import net.minecraft.client.gui.GuiPlayerInfo; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.GuiScreenDemo; +import net.minecraft.client.gui.GuiScreenDisconnectedOnline; +import net.minecraft.client.gui.GuiWinGame; +import net.minecraft.client.gui.GuiYesNo; +import net.minecraft.client.gui.IProgressMeter; +import net.minecraft.client.gui.inventory.GuiContainerCreative; +import net.minecraft.client.multiplayer.PlayerControllerMP; +import net.minecraft.client.multiplayer.ServerList; +import net.minecraft.client.multiplayer.WorldClient; +import net.minecraft.client.particle.EntityCrit2FX; +import net.minecraft.client.particle.EntityPickupFX; +import net.minecraft.client.resources.I18n; +import net.minecraft.client.settings.GameSettings; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLeashKnot; +import net.minecraft.entity.EntityList; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IMerchant; +import net.minecraft.entity.NpcMerchant; +import net.minecraft.entity.ai.attributes.AttributeModifier; +import net.minecraft.entity.ai.attributes.BaseAttributeMap; +import net.minecraft.entity.ai.attributes.IAttributeInstance; +import net.minecraft.entity.ai.attributes.RangedAttribute; +import net.minecraft.entity.effect.EntityLightningBolt; +import net.minecraft.entity.item.EntityBoat; +import net.minecraft.entity.item.EntityEnderCrystal; +import net.minecraft.entity.item.EntityEnderEye; +import net.minecraft.entity.item.EntityEnderPearl; +import net.minecraft.entity.item.EntityExpBottle; +import net.minecraft.entity.item.EntityFallingBlock; +import net.minecraft.entity.item.EntityFireworkRocket; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.item.EntityItemFrame; +import net.minecraft.entity.item.EntityMinecart; +import net.minecraft.entity.item.EntityPainting; +import net.minecraft.entity.item.EntityTNTPrimed; +import net.minecraft.entity.item.EntityXPOrb; +import net.minecraft.entity.passive.EntityHorse; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.entity.projectile.EntityEgg; +import net.minecraft.entity.projectile.EntityFishHook; +import net.minecraft.entity.projectile.EntityLargeFireball; +import net.minecraft.entity.projectile.EntityPotion; +import net.minecraft.entity.projectile.EntitySmallFireball; +import net.minecraft.entity.projectile.EntitySnowball; +import net.minecraft.entity.projectile.EntityWitherSkull; +import net.minecraft.inventory.AnimalChest; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.InventoryBasic; +import net.minecraft.item.Item; +import net.minecraft.item.ItemMap; +import net.minecraft.item.ItemStack; +import net.minecraft.network.EnumConnectionState; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; +import net.minecraft.network.play.client.C00PacketKeepAlive; +import net.minecraft.network.play.client.C03PacketPlayer; +import net.minecraft.network.play.client.C0FPacketConfirmTransaction; +import net.minecraft.network.play.client.C17PacketCustomPayload; +import net.minecraft.network.play.server.S00PacketKeepAlive; +import net.minecraft.network.play.server.S01PacketJoinGame; +import net.minecraft.network.play.server.S02PacketChat; +import net.minecraft.network.play.server.S03PacketTimeUpdate; +import net.minecraft.network.play.server.S04PacketEntityEquipment; +import net.minecraft.network.play.server.S05PacketSpawnPosition; +import net.minecraft.network.play.server.S06PacketUpdateHealth; +import net.minecraft.network.play.server.S07PacketRespawn; +import net.minecraft.network.play.server.S08PacketPlayerPosLook; +import net.minecraft.network.play.server.S09PacketHeldItemChange; +import net.minecraft.network.play.server.S0APacketUseBed; +import net.minecraft.network.play.server.S0BPacketAnimation; +import net.minecraft.network.play.server.S0CPacketSpawnPlayer; +import net.minecraft.network.play.server.S0DPacketCollectItem; +import net.minecraft.network.play.server.S0EPacketSpawnObject; +import net.minecraft.network.play.server.S0FPacketSpawnMob; +import net.minecraft.network.play.server.S10PacketSpawnPainting; +import net.minecraft.network.play.server.S11PacketSpawnExperienceOrb; +import net.minecraft.network.play.server.S12PacketEntityVelocity; +import net.minecraft.network.play.server.S13PacketDestroyEntities; +import net.minecraft.network.play.server.S14PacketEntity; +import net.minecraft.network.play.server.S18PacketEntityTeleport; +import net.minecraft.network.play.server.S19PacketEntityHeadLook; +import net.minecraft.network.play.server.S19PacketEntityStatus; +import net.minecraft.network.play.server.S1BPacketEntityAttach; +import net.minecraft.network.play.server.S1CPacketEntityMetadata; +import net.minecraft.network.play.server.S1DPacketEntityEffect; +import net.minecraft.network.play.server.S1EPacketRemoveEntityEffect; +import net.minecraft.network.play.server.S1FPacketSetExperience; +import net.minecraft.network.play.server.S20PacketEntityProperties; +import net.minecraft.network.play.server.S21PacketChunkData; +import net.minecraft.network.play.server.S22PacketMultiBlockChange; +import net.minecraft.network.play.server.S23PacketBlockChange; +import net.minecraft.network.play.server.S24PacketBlockAction; +import net.minecraft.network.play.server.S25PacketBlockBreakAnim; +import net.minecraft.network.play.server.S26PacketMapChunkBulk; +import net.minecraft.network.play.server.S27PacketExplosion; +import net.minecraft.network.play.server.S28PacketEffect; +import net.minecraft.network.play.server.S29PacketSoundEffect; +import net.minecraft.network.play.server.S2APacketParticles; +import net.minecraft.network.play.server.S2BPacketChangeGameState; +import net.minecraft.network.play.server.S2CPacketSpawnGlobalEntity; +import net.minecraft.network.play.server.S2DPacketOpenWindow; +import net.minecraft.network.play.server.S2EPacketCloseWindow; +import net.minecraft.network.play.server.S2FPacketSetSlot; +import net.minecraft.network.play.server.S30PacketWindowItems; +import net.minecraft.network.play.server.S31PacketWindowProperty; +import net.minecraft.network.play.server.S32PacketConfirmTransaction; +import net.minecraft.network.play.server.S33PacketUpdateSign; +import net.minecraft.network.play.server.S34PacketMaps; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.network.play.server.S36PacketSignEditorOpen; +import net.minecraft.network.play.server.S37PacketStatistics; +import net.minecraft.network.play.server.S38PacketPlayerListItem; +import net.minecraft.network.play.server.S39PacketPlayerAbilities; +import net.minecraft.network.play.server.S3APacketTabComplete; +import net.minecraft.network.play.server.S3BPacketScoreboardObjective; +import net.minecraft.network.play.server.S3CPacketUpdateScore; +import net.minecraft.network.play.server.S3DPacketDisplayScoreboard; +import net.minecraft.network.play.server.S3EPacketTeams; +import net.minecraft.network.play.server.S3FPacketCustomPayload; +import net.minecraft.network.play.server.S40PacketDisconnect; +import net.minecraft.potion.PotionEffect; +import net.minecraft.scoreboard.IScoreObjectiveCriteria; +import net.minecraft.scoreboard.Score; +import net.minecraft.scoreboard.ScoreObjective; +import net.minecraft.scoreboard.ScorePlayerTeam; +import net.minecraft.scoreboard.Scoreboard; +import net.minecraft.stats.Achievement; +import net.minecraft.stats.AchievementList; +import net.minecraft.stats.StatBase; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityBeacon; +import net.minecraft.tileentity.TileEntityBrewingStand; +import net.minecraft.tileentity.TileEntityCommandBlock; +import net.minecraft.tileentity.TileEntityDispenser; +import net.minecraft.tileentity.TileEntityDropper; +import net.minecraft.tileentity.TileEntityFlowerPot; +import net.minecraft.tileentity.TileEntityFurnace; +import net.minecraft.tileentity.TileEntityHopper; +import net.minecraft.tileentity.TileEntityMobSpawner; +import net.minecraft.tileentity.TileEntitySign; +import net.minecraft.tileentity.TileEntitySkull; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.IChatComponent; +import net.minecraft.util.MathHelper; +import net.minecraft.village.MerchantRecipeList; +import net.minecraft.world.Explosion; +import net.minecraft.world.WorldProviderSurface; +import net.minecraft.world.WorldSettings; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.storage.ISaveHandler; +import net.minecraft.world.storage.MapData; +import net.minecraft.world.storage.MapStorage; +import net.minecraftforge.client.event.ClientChatReceivedEvent; +import net.minecraftforge.common.MinecraftForge; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +@SideOnly(Side.CLIENT) +public class NetHandlerPlayClient implements INetHandlerPlayClient +{ + private static final Logger logger = LogManager.getLogger(); + private final NetworkManager netManager; + private Minecraft gameController; + private WorldClient clientWorldController; + private boolean doneLoadingTerrain; + public MapStorage mapStorageOrigin = new MapStorage((ISaveHandler)null); + private Map playerInfoMap = new HashMap(); + public List playerInfoList = new ArrayList(); + public int currentServerMaxPlayers = 20; + private GuiScreen guiScreenServer; + private boolean field_147308_k = false; + private Random avRandomizer = new Random(); + private static final String __OBFID = "CL_00000878"; + + public NetHandlerPlayClient(Minecraft p_i45061_1_, GuiScreen p_i45061_2_, NetworkManager p_i45061_3_) + { + this.gameController = p_i45061_1_; + this.guiScreenServer = p_i45061_2_; + this.netManager = p_i45061_3_; + FMLClientHandler.instance().setPlayClient(this); + } + + public void cleanup() + { + this.clientWorldController = null; + } + + public void onNetworkTick() {} + + public void handleJoinGame(S01PacketJoinGame p_147282_1_) + { + this.gameController.playerController = new PlayerControllerMP(this.gameController, this); + this.clientWorldController = new WorldClient(this, new WorldSettings(0L, p_147282_1_.func_149198_e(), false, p_147282_1_.func_149195_d(), p_147282_1_.func_149196_i()), p_147282_1_.func_149194_f(), p_147282_1_.func_149192_g(), this.gameController.mcProfiler); + this.clientWorldController.isRemote = true; + this.gameController.loadWorld(this.clientWorldController); + this.gameController.thePlayer.dimension = p_147282_1_.func_149194_f(); + this.gameController.displayGuiScreen(new GuiDownloadTerrain(this)); + this.gameController.thePlayer.setEntityId(p_147282_1_.func_149197_c()); + this.currentServerMaxPlayers = p_147282_1_.func_149193_h(); + this.gameController.playerController.setGameType(p_147282_1_.func_149198_e()); + this.gameController.gameSettings.sendSettingsToServer(); + this.netManager.scheduleOutboundPacket(new C17PacketCustomPayload("MC|Brand", ClientBrandRetriever.getClientModName().getBytes(Charsets.UTF_8)), new GenericFutureListener[0]); + } + + public void handleSpawnObject(S0EPacketSpawnObject p_147235_1_) + { + double d0 = (double)p_147235_1_.func_148997_d() / 32.0D; + double d1 = (double)p_147235_1_.func_148998_e() / 32.0D; + double d2 = (double)p_147235_1_.func_148994_f() / 32.0D; + Object object = null; + + if (p_147235_1_.func_148993_l() == 10) + { + object = EntityMinecart.createMinecart(this.clientWorldController, d0, d1, d2, p_147235_1_.func_149009_m()); + } + else if (p_147235_1_.func_148993_l() == 90) + { + Entity entity = this.clientWorldController.getEntityByID(p_147235_1_.func_149009_m()); + + if (entity instanceof EntityPlayer) + { + object = new EntityFishHook(this.clientWorldController, d0, d1, d2, (EntityPlayer)entity); + } + + p_147235_1_.func_149002_g(0); + } + else if (p_147235_1_.func_148993_l() == 60) + { + object = new EntityArrow(this.clientWorldController, d0, d1, d2); + } + else if (p_147235_1_.func_148993_l() == 61) + { + object = new EntitySnowball(this.clientWorldController, d0, d1, d2); + } + else if (p_147235_1_.func_148993_l() == 71) + { + object = new EntityItemFrame(this.clientWorldController, (int)d0, (int)d1, (int)d2, p_147235_1_.func_149009_m()); + p_147235_1_.func_149002_g(0); + } + else if (p_147235_1_.func_148993_l() == 77) + { + object = new EntityLeashKnot(this.clientWorldController, (int)d0, (int)d1, (int)d2); + p_147235_1_.func_149002_g(0); + } + else if (p_147235_1_.func_148993_l() == 65) + { + object = new EntityEnderPearl(this.clientWorldController, d0, d1, d2); + } + else if (p_147235_1_.func_148993_l() == 72) + { + object = new EntityEnderEye(this.clientWorldController, d0, d1, d2); + } + else if (p_147235_1_.func_148993_l() == 76) + { + object = new EntityFireworkRocket(this.clientWorldController, d0, d1, d2, (ItemStack)null); + } + else if (p_147235_1_.func_148993_l() == 63) + { + object = new EntityLargeFireball(this.clientWorldController, d0, d1, d2, (double)p_147235_1_.func_149010_g() / 8000.0D, (double)p_147235_1_.func_149004_h() / 8000.0D, (double)p_147235_1_.func_148999_i() / 8000.0D); + p_147235_1_.func_149002_g(0); + } + else if (p_147235_1_.func_148993_l() == 64) + { + object = new EntitySmallFireball(this.clientWorldController, d0, d1, d2, (double)p_147235_1_.func_149010_g() / 8000.0D, (double)p_147235_1_.func_149004_h() / 8000.0D, (double)p_147235_1_.func_148999_i() / 8000.0D); + p_147235_1_.func_149002_g(0); + } + else if (p_147235_1_.func_148993_l() == 66) + { + object = new EntityWitherSkull(this.clientWorldController, d0, d1, d2, (double)p_147235_1_.func_149010_g() / 8000.0D, (double)p_147235_1_.func_149004_h() / 8000.0D, (double)p_147235_1_.func_148999_i() / 8000.0D); + p_147235_1_.func_149002_g(0); + } + else if (p_147235_1_.func_148993_l() == 62) + { + object = new EntityEgg(this.clientWorldController, d0, d1, d2); + } + else if (p_147235_1_.func_148993_l() == 73) + { + object = new EntityPotion(this.clientWorldController, d0, d1, d2, p_147235_1_.func_149009_m()); + p_147235_1_.func_149002_g(0); + } + else if (p_147235_1_.func_148993_l() == 75) + { + object = new EntityExpBottle(this.clientWorldController, d0, d1, d2); + p_147235_1_.func_149002_g(0); + } + else if (p_147235_1_.func_148993_l() == 1) + { + object = new EntityBoat(this.clientWorldController, d0, d1, d2); + } + else if (p_147235_1_.func_148993_l() == 50) + { + object = new EntityTNTPrimed(this.clientWorldController, d0, d1, d2, (EntityLivingBase)null); + } + else if (p_147235_1_.func_148993_l() == 51) + { + object = new EntityEnderCrystal(this.clientWorldController, d0, d1, d2); + } + else if (p_147235_1_.func_148993_l() == 2) + { + object = new EntityItem(this.clientWorldController, d0, d1, d2); + } + else if (p_147235_1_.func_148993_l() == 70) + { + object = new EntityFallingBlock(this.clientWorldController, d0, d1, d2, Block.getBlockById(p_147235_1_.func_149009_m() & 65535), p_147235_1_.func_149009_m() >> 16); + p_147235_1_.func_149002_g(0); + } + + if (object != null) + { + ((Entity)object).serverPosX = p_147235_1_.func_148997_d(); + ((Entity)object).serverPosY = p_147235_1_.func_148998_e(); + ((Entity)object).serverPosZ = p_147235_1_.func_148994_f(); + ((Entity)object).rotationPitch = (float)(p_147235_1_.func_149008_j() * 360) / 256.0F; + ((Entity)object).rotationYaw = (float)(p_147235_1_.func_149006_k() * 360) / 256.0F; + Entity[] aentity = ((Entity)object).getParts(); + + if (aentity != null) + { + int i = p_147235_1_.func_149001_c() - ((Entity)object).getEntityId(); + + for (int j = 0; j < aentity.length; ++j) + { + aentity[j].setEntityId(aentity[j].getEntityId() + i); + } + } + + ((Entity)object).setEntityId(p_147235_1_.func_149001_c()); + this.clientWorldController.addEntityToWorld(p_147235_1_.func_149001_c(), (Entity)object); + + if (p_147235_1_.func_149009_m() > 0) + { + if (p_147235_1_.func_148993_l() == 60) + { + Entity entity1 = this.clientWorldController.getEntityByID(p_147235_1_.func_149009_m()); + + if (entity1 instanceof EntityLivingBase) + { + EntityArrow entityarrow = (EntityArrow)object; + entityarrow.shootingEntity = entity1; + } + } + + ((Entity)object).setVelocity((double)p_147235_1_.func_149010_g() / 8000.0D, (double)p_147235_1_.func_149004_h() / 8000.0D, (double)p_147235_1_.func_148999_i() / 8000.0D); + } + } + } + + public void handleSpawnExperienceOrb(S11PacketSpawnExperienceOrb p_147286_1_) + { + EntityXPOrb entityxporb = new EntityXPOrb(this.clientWorldController, (double)p_147286_1_.func_148984_d(), (double)p_147286_1_.func_148983_e(), (double)p_147286_1_.func_148982_f(), p_147286_1_.func_148986_g()); + entityxporb.serverPosX = p_147286_1_.func_148984_d(); + entityxporb.serverPosY = p_147286_1_.func_148983_e(); + entityxporb.serverPosZ = p_147286_1_.func_148982_f(); + entityxporb.rotationYaw = 0.0F; + entityxporb.rotationPitch = 0.0F; + entityxporb.setEntityId(p_147286_1_.func_148985_c()); + this.clientWorldController.addEntityToWorld(p_147286_1_.func_148985_c(), entityxporb); + } + + public void handleSpawnGlobalEntity(S2CPacketSpawnGlobalEntity p_147292_1_) + { + double d0 = (double)p_147292_1_.func_149051_d() / 32.0D; + double d1 = (double)p_147292_1_.func_149050_e() / 32.0D; + double d2 = (double)p_147292_1_.func_149049_f() / 32.0D; + EntityLightningBolt entitylightningbolt = null; + + if (p_147292_1_.func_149053_g() == 1) + { + entitylightningbolt = new EntityLightningBolt(this.clientWorldController, d0, d1, d2); + } + + if (entitylightningbolt != null) + { + entitylightningbolt.serverPosX = p_147292_1_.func_149051_d(); + entitylightningbolt.serverPosY = p_147292_1_.func_149050_e(); + entitylightningbolt.serverPosZ = p_147292_1_.func_149049_f(); + entitylightningbolt.rotationYaw = 0.0F; + entitylightningbolt.rotationPitch = 0.0F; + entitylightningbolt.setEntityId(p_147292_1_.func_149052_c()); + this.clientWorldController.addWeatherEffect(entitylightningbolt); + } + } + + public void handleSpawnPainting(S10PacketSpawnPainting p_147288_1_) + { + EntityPainting entitypainting = new EntityPainting(this.clientWorldController, p_147288_1_.func_148964_d(), p_147288_1_.func_148963_e(), p_147288_1_.func_148962_f(), p_147288_1_.func_148966_g(), p_147288_1_.func_148961_h()); + this.clientWorldController.addEntityToWorld(p_147288_1_.func_148965_c(), entitypainting); + } + + public void handleEntityVelocity(S12PacketEntityVelocity p_147244_1_) + { + Entity entity = this.clientWorldController.getEntityByID(p_147244_1_.func_149412_c()); + + if (entity != null) + { + entity.setVelocity((double)p_147244_1_.func_149411_d() / 8000.0D, (double)p_147244_1_.func_149410_e() / 8000.0D, (double)p_147244_1_.func_149409_f() / 8000.0D); + } + } + + public void handleEntityMetadata(S1CPacketEntityMetadata p_147284_1_) + { + Entity entity = this.clientWorldController.getEntityByID(p_147284_1_.func_149375_d()); + + if (entity != null && p_147284_1_.func_149376_c() != null) + { + entity.getDataWatcher().updateWatchedObjectsFromList(p_147284_1_.func_149376_c()); + } + } + + public void handleSpawnPlayer(S0CPacketSpawnPlayer p_147237_1_) + { + double d0 = (double)p_147237_1_.func_148942_f() / 32.0D; + double d1 = (double)p_147237_1_.func_148949_g() / 32.0D; + double d2 = (double)p_147237_1_.func_148946_h() / 32.0D; + float f = (float)(p_147237_1_.func_148941_i() * 360) / 256.0F; + float f1 = (float)(p_147237_1_.func_148945_j() * 360) / 256.0F; + EntityOtherPlayerMP entityotherplayermp = new EntityOtherPlayerMP(this.gameController.theWorld, p_147237_1_.func_148948_e()); + entityotherplayermp.prevPosX = entityotherplayermp.lastTickPosX = (double)(entityotherplayermp.serverPosX = p_147237_1_.func_148942_f()); + entityotherplayermp.prevPosY = entityotherplayermp.lastTickPosY = (double)(entityotherplayermp.serverPosY = p_147237_1_.func_148949_g()); + entityotherplayermp.prevPosZ = entityotherplayermp.lastTickPosZ = (double)(entityotherplayermp.serverPosZ = p_147237_1_.func_148946_h()); + int i = p_147237_1_.func_148947_k(); + + if (i == 0) + { + entityotherplayermp.inventory.mainInventory[entityotherplayermp.inventory.currentItem] = null; + } + else + { + entityotherplayermp.inventory.mainInventory[entityotherplayermp.inventory.currentItem] = new ItemStack(Item.getItemById(i), 1, 0); + } + + entityotherplayermp.setPositionAndRotation(d0, d1, d2, f, f1); + this.clientWorldController.addEntityToWorld(p_147237_1_.func_148943_d(), entityotherplayermp); + List list = p_147237_1_.func_148944_c(); + + if (list != null) + { + entityotherplayermp.getDataWatcher().updateWatchedObjectsFromList(list); + } + } + + public void handleEntityTeleport(S18PacketEntityTeleport p_147275_1_) + { + Entity entity = this.clientWorldController.getEntityByID(p_147275_1_.func_149451_c()); + + if (entity != null) + { + entity.serverPosX = p_147275_1_.func_149449_d(); + entity.serverPosY = p_147275_1_.func_149448_e(); + entity.serverPosZ = p_147275_1_.func_149446_f(); + double d0 = (double)entity.serverPosX / 32.0D; + double d1 = (double)entity.serverPosY / 32.0D + 0.015625D; + double d2 = (double)entity.serverPosZ / 32.0D; + float f = (float)(p_147275_1_.func_149450_g() * 360) / 256.0F; + float f1 = (float)(p_147275_1_.func_149447_h() * 360) / 256.0F; + entity.setPositionAndRotation2(d0, d1, d2, f, f1, 3); + } + } + + public void handleHeldItemChange(S09PacketHeldItemChange p_147257_1_) + { + if (p_147257_1_.func_149385_c() >= 0 && p_147257_1_.func_149385_c() < InventoryPlayer.getHotbarSize()) + { + this.gameController.thePlayer.inventory.currentItem = p_147257_1_.func_149385_c(); + } + } + + public void handleEntityMovement(S14PacketEntity p_147259_1_) + { + Entity entity = p_147259_1_.func_149065_a(this.clientWorldController); + + if (entity != null) + { + entity.serverPosX += p_147259_1_.func_149062_c(); + entity.serverPosY += p_147259_1_.func_149061_d(); + entity.serverPosZ += p_147259_1_.func_149064_e(); + double d0 = (double)entity.serverPosX / 32.0D; + double d1 = (double)entity.serverPosY / 32.0D; + double d2 = (double)entity.serverPosZ / 32.0D; + float f = p_147259_1_.func_149060_h() ? (float)(p_147259_1_.func_149066_f() * 360) / 256.0F : entity.rotationYaw; + float f1 = p_147259_1_.func_149060_h() ? (float)(p_147259_1_.func_149063_g() * 360) / 256.0F : entity.rotationPitch; + entity.setPositionAndRotation2(d0, d1, d2, f, f1, 3); + } + } + + public void handleEntityHeadLook(S19PacketEntityHeadLook p_147267_1_) + { + Entity entity = p_147267_1_.func_149381_a(this.clientWorldController); + + if (entity != null) + { + float f = (float)(p_147267_1_.func_149380_c() * 360) / 256.0F; + entity.setRotationYawHead(f); + } + } + + public void handleDestroyEntities(S13PacketDestroyEntities p_147238_1_) + { + for (int i = 0; i < p_147238_1_.func_149098_c().length; ++i) + { + this.clientWorldController.removeEntityFromWorld(p_147238_1_.func_149098_c()[i]); + } + } + + public void handlePlayerPosLook(S08PacketPlayerPosLook p_147258_1_) + { + EntityClientPlayerMP entityclientplayermp = this.gameController.thePlayer; + double d0 = p_147258_1_.func_148932_c(); + double d1 = p_147258_1_.func_148928_d(); + double d2 = p_147258_1_.func_148933_e(); + float f = p_147258_1_.func_148931_f(); + float f1 = p_147258_1_.func_148930_g(); + entityclientplayermp.ySize = 0.0F; + entityclientplayermp.motionX = entityclientplayermp.motionY = entityclientplayermp.motionZ = 0.0D; + entityclientplayermp.setPositionAndRotation(d0, d1, d2, f, f1); + this.netManager.scheduleOutboundPacket(new C03PacketPlayer.C06PacketPlayerPosLook(entityclientplayermp.posX, entityclientplayermp.boundingBox.minY, entityclientplayermp.posY, entityclientplayermp.posZ, p_147258_1_.func_148931_f(), p_147258_1_.func_148930_g(), p_147258_1_.func_148929_h()), new GenericFutureListener[0]); + + if (!this.doneLoadingTerrain) + { + this.gameController.thePlayer.prevPosX = this.gameController.thePlayer.posX; + this.gameController.thePlayer.prevPosY = this.gameController.thePlayer.posY; + this.gameController.thePlayer.prevPosZ = this.gameController.thePlayer.posZ; + this.doneLoadingTerrain = true; + this.gameController.displayGuiScreen((GuiScreen)null); + } + } + + public void handleMultiBlockChange(S22PacketMultiBlockChange p_147287_1_) + { + int i = p_147287_1_.func_148920_c().chunkXPos * 16; + int j = p_147287_1_.func_148920_c().chunkZPos * 16; + + if (p_147287_1_.func_148921_d() != null) + { + DataInputStream datainputstream = new DataInputStream(new ByteArrayInputStream(p_147287_1_.func_148921_d())); + + try + { + for (int k = 0; k < p_147287_1_.func_148922_e(); ++k) + { + short short1 = datainputstream.readShort(); + short short2 = datainputstream.readShort(); + int l = short2 >> 4 & 4095; + int i1 = short2 & 15; + int j1 = short1 >> 12 & 15; + int k1 = short1 >> 8 & 15; + int l1 = short1 & 255; + this.clientWorldController.func_147492_c(j1 + i, l1, k1 + j, Block.getBlockById(l), i1); + } + } + catch (IOException ioexception) + { + ; + } + } + } + + public void handleChunkData(S21PacketChunkData p_147263_1_) + { + if (p_147263_1_.func_149274_i()) + { + if (p_147263_1_.func_149276_g() == 0) + { + this.clientWorldController.doPreChunk(p_147263_1_.func_149273_e(), p_147263_1_.func_149271_f(), false); + return; + } + + this.clientWorldController.doPreChunk(p_147263_1_.func_149273_e(), p_147263_1_.func_149271_f(), true); + } + + this.clientWorldController.invalidateBlockReceiveRegion(p_147263_1_.func_149273_e() << 4, 0, p_147263_1_.func_149271_f() << 4, (p_147263_1_.func_149273_e() << 4) + 15, 256, (p_147263_1_.func_149271_f() << 4) + 15); + Chunk chunk = this.clientWorldController.getChunkFromChunkCoords(p_147263_1_.func_149273_e(), p_147263_1_.func_149271_f()); + chunk.fillChunk(p_147263_1_.func_149272_d(), p_147263_1_.func_149276_g(), p_147263_1_.func_149270_h(), p_147263_1_.func_149274_i()); + this.clientWorldController.markBlockRangeForRenderUpdate(p_147263_1_.func_149273_e() << 4, 0, p_147263_1_.func_149271_f() << 4, (p_147263_1_.func_149273_e() << 4) + 15, 256, (p_147263_1_.func_149271_f() << 4) + 15); + + if (!p_147263_1_.func_149274_i() || !(this.clientWorldController.provider instanceof WorldProviderSurface)) + { + chunk.resetRelightChecks(); + } + } + + public void handleBlockChange(S23PacketBlockChange p_147234_1_) + { + this.clientWorldController.func_147492_c(p_147234_1_.func_148879_d(), p_147234_1_.func_148878_e(), p_147234_1_.func_148877_f(), p_147234_1_.func_148880_c(), p_147234_1_.func_148881_g()); + } + + public void handleDisconnect(S40PacketDisconnect p_147253_1_) + { + this.netManager.closeChannel(p_147253_1_.func_149165_c()); + } + + public void onDisconnect(IChatComponent p_147231_1_) + { + this.gameController.loadWorld((WorldClient)null); + + if (this.guiScreenServer != null) + { + this.gameController.displayGuiScreen(new GuiScreenDisconnectedOnline(this.guiScreenServer, "disconnect.lost", p_147231_1_)); + } + else + { + this.gameController.displayGuiScreen(new GuiDisconnected(new GuiMultiplayer(new GuiMainMenu()), "disconnect.lost", p_147231_1_)); + } + } + + public void addToSendQueue(Packet p_147297_1_) + { + this.netManager.scheduleOutboundPacket(p_147297_1_, new GenericFutureListener[0]); + } + + public void handleCollectItem(S0DPacketCollectItem p_147246_1_) + { + Entity entity = this.clientWorldController.getEntityByID(p_147246_1_.func_149354_c()); + Object object = (EntityLivingBase)this.clientWorldController.getEntityByID(p_147246_1_.func_149353_d()); + + if (object == null) + { + object = this.gameController.thePlayer; + } + + if (entity != null) + { + if (entity instanceof EntityXPOrb) + { + this.clientWorldController.playSoundAtEntity(entity, "random.orb", 0.2F, ((this.avRandomizer.nextFloat() - this.avRandomizer.nextFloat()) * 0.7F + 1.0F) * 2.0F); + } + else + { + this.clientWorldController.playSoundAtEntity(entity, "random.pop", 0.2F, ((this.avRandomizer.nextFloat() - this.avRandomizer.nextFloat()) * 0.7F + 1.0F) * 2.0F); + } + + this.gameController.effectRenderer.addEffect(new EntityPickupFX(this.gameController.theWorld, entity, (Entity)object, -0.5F)); + this.clientWorldController.removeEntityFromWorld(p_147246_1_.func_149354_c()); + } + } + + public void handleChat(S02PacketChat p_147251_1_) + { + ClientChatReceivedEvent event = new ClientChatReceivedEvent(p_147251_1_.func_148915_c()); + if (!MinecraftForge.EVENT_BUS.post(event) && event.message != null) + { + this.gameController.ingameGUI.getChatGUI().printChatMessage(event.message); + } + } + + public void handleAnimation(S0BPacketAnimation p_147279_1_) + { + Entity entity = this.clientWorldController.getEntityByID(p_147279_1_.func_148978_c()); + + if (entity != null) + { + if (p_147279_1_.func_148977_d() == 0) + { + EntityLivingBase entitylivingbase = (EntityLivingBase)entity; + entitylivingbase.swingItem(); + } + else if (p_147279_1_.func_148977_d() == 1) + { + entity.performHurtAnimation(); + } + else if (p_147279_1_.func_148977_d() == 2) + { + EntityPlayer entityplayer = (EntityPlayer)entity; + entityplayer.wakeUpPlayer(false, false, false); + } + else if (p_147279_1_.func_148977_d() == 4) + { + this.gameController.effectRenderer.addEffect(new EntityCrit2FX(this.gameController.theWorld, entity)); + } + else if (p_147279_1_.func_148977_d() == 5) + { + EntityCrit2FX entitycrit2fx = new EntityCrit2FX(this.gameController.theWorld, entity, "magicCrit"); + this.gameController.effectRenderer.addEffect(entitycrit2fx); + } + } + } + + public void handleUseBed(S0APacketUseBed p_147278_1_) + { + p_147278_1_.func_149091_a(this.clientWorldController).sleepInBedAt(p_147278_1_.func_149092_c(), p_147278_1_.func_149090_d(), p_147278_1_.func_149089_e()); + } + + public void handleSpawnMob(S0FPacketSpawnMob p_147281_1_) + { + double d0 = (double)p_147281_1_.func_149023_f() / 32.0D; + double d1 = (double)p_147281_1_.func_149034_g() / 32.0D; + double d2 = (double)p_147281_1_.func_149029_h() / 32.0D; + float f = (float)(p_147281_1_.func_149028_l() * 360) / 256.0F; + float f1 = (float)(p_147281_1_.func_149030_m() * 360) / 256.0F; + EntityLivingBase entitylivingbase = (EntityLivingBase)EntityList.createEntityByID(p_147281_1_.func_149025_e(), this.gameController.theWorld); + entitylivingbase.serverPosX = p_147281_1_.func_149023_f(); + entitylivingbase.serverPosY = p_147281_1_.func_149034_g(); + entitylivingbase.serverPosZ = p_147281_1_.func_149029_h(); + entitylivingbase.rotationYawHead = (float)(p_147281_1_.func_149032_n() * 360) / 256.0F; + Entity[] aentity = entitylivingbase.getParts(); + + if (aentity != null) + { + int i = p_147281_1_.func_149024_d() - entitylivingbase.getEntityId(); + + for (int j = 0; j < aentity.length; ++j) + { + aentity[j].setEntityId(aentity[j].getEntityId() + i); + } + } + + entitylivingbase.setEntityId(p_147281_1_.func_149024_d()); + entitylivingbase.setPositionAndRotation(d0, d1, d2, f, f1); + entitylivingbase.motionX = (double)((float)p_147281_1_.func_149026_i() / 8000.0F); + entitylivingbase.motionY = (double)((float)p_147281_1_.func_149033_j() / 8000.0F); + entitylivingbase.motionZ = (double)((float)p_147281_1_.func_149031_k() / 8000.0F); + this.clientWorldController.addEntityToWorld(p_147281_1_.func_149024_d(), entitylivingbase); + List list = p_147281_1_.func_149027_c(); + + if (list != null) + { + entitylivingbase.getDataWatcher().updateWatchedObjectsFromList(list); + } + } + + public void handleTimeUpdate(S03PacketTimeUpdate p_147285_1_) + { + this.gameController.theWorld.func_82738_a(p_147285_1_.func_149366_c()); + this.gameController.theWorld.setWorldTime(p_147285_1_.func_149365_d()); + } + + public void handleSpawnPosition(S05PacketSpawnPosition p_147271_1_) + { + this.gameController.thePlayer.setSpawnChunk(new ChunkCoordinates(p_147271_1_.func_149360_c(), p_147271_1_.func_149359_d(), p_147271_1_.func_149358_e()), true); + this.gameController.theWorld.getWorldInfo().setSpawnPosition(p_147271_1_.func_149360_c(), p_147271_1_.func_149359_d(), p_147271_1_.func_149358_e()); + } + + public void handleEntityAttach(S1BPacketEntityAttach p_147243_1_) + { + Object object = this.clientWorldController.getEntityByID(p_147243_1_.func_149403_d()); + Entity entity = this.clientWorldController.getEntityByID(p_147243_1_.func_149402_e()); + + if (p_147243_1_.func_149404_c() == 0) + { + boolean flag = false; + + if (p_147243_1_.func_149403_d() == this.gameController.thePlayer.getEntityId()) + { + object = this.gameController.thePlayer; + + if (entity instanceof EntityBoat) + { + ((EntityBoat)entity).setIsBoatEmpty(false); + } + + flag = ((Entity)object).ridingEntity == null && entity != null; + } + else if (entity instanceof EntityBoat) + { + ((EntityBoat)entity).setIsBoatEmpty(true); + } + + if (object == null) + { + return; + } + + ((Entity)object).mountEntity(entity); + + if (flag) + { + GameSettings gamesettings = this.gameController.gameSettings; + this.gameController.ingameGUI.func_110326_a(I18n.format("mount.onboard", new Object[] {GameSettings.getKeyDisplayString(gamesettings.keyBindSneak.getKeyCode())}), false); + } + } + else if (p_147243_1_.func_149404_c() == 1 && object != null && object instanceof EntityLiving) + { + if (entity != null) + { + ((EntityLiving)object).setLeashedToEntity(entity, false); + } + else + { + ((EntityLiving)object).clearLeashed(false, false); + } + } + } + + public void handleEntityStatus(S19PacketEntityStatus p_147236_1_) + { + Entity entity = p_147236_1_.func_149161_a(this.clientWorldController); + + if (entity != null) + { + entity.handleHealthUpdate(p_147236_1_.func_149160_c()); + } + } + + public void handleUpdateHealth(S06PacketUpdateHealth p_147249_1_) + { + this.gameController.thePlayer.setPlayerSPHealth(p_147249_1_.func_149332_c()); + this.gameController.thePlayer.getFoodStats().setFoodLevel(p_147249_1_.func_149330_d()); + this.gameController.thePlayer.getFoodStats().setFoodSaturationLevel(p_147249_1_.func_149331_e()); + } + + public void handleSetExperience(S1FPacketSetExperience p_147295_1_) + { + this.gameController.thePlayer.setXPStats(p_147295_1_.func_149397_c(), p_147295_1_.func_149396_d(), p_147295_1_.func_149395_e()); + } + + public void handleRespawn(S07PacketRespawn p_147280_1_) + { + if (p_147280_1_.func_149082_c() != this.gameController.thePlayer.dimension) + { + this.doneLoadingTerrain = false; + Scoreboard scoreboard = this.clientWorldController.getScoreboard(); + this.clientWorldController = new WorldClient(this, new WorldSettings(0L, p_147280_1_.func_149083_e(), false, this.gameController.theWorld.getWorldInfo().isHardcoreModeEnabled(), p_147280_1_.func_149080_f()), p_147280_1_.func_149082_c(), p_147280_1_.func_149081_d(), this.gameController.mcProfiler); + this.clientWorldController.setWorldScoreboard(scoreboard); + this.clientWorldController.isRemote = true; + this.gameController.loadWorld(this.clientWorldController); + this.gameController.thePlayer.dimension = p_147280_1_.func_149082_c(); + this.gameController.displayGuiScreen(new GuiDownloadTerrain(this)); + } + + this.gameController.setDimensionAndSpawnPlayer(p_147280_1_.func_149082_c()); + this.gameController.playerController.setGameType(p_147280_1_.func_149083_e()); + } + + public void handleExplosion(S27PacketExplosion p_147283_1_) + { + Explosion explosion = new Explosion(this.gameController.theWorld, (Entity)null, p_147283_1_.func_149148_f(), p_147283_1_.func_149143_g(), p_147283_1_.func_149145_h(), p_147283_1_.func_149146_i()); + explosion.affectedBlockPositions = p_147283_1_.func_149150_j(); + explosion.doExplosionB(true); + this.gameController.thePlayer.motionX += (double)p_147283_1_.func_149149_c(); + this.gameController.thePlayer.motionY += (double)p_147283_1_.func_149144_d(); + this.gameController.thePlayer.motionZ += (double)p_147283_1_.func_149147_e(); + } + + public void handleOpenWindow(S2DPacketOpenWindow p_147265_1_) + { + EntityClientPlayerMP entityclientplayermp = this.gameController.thePlayer; + + switch (p_147265_1_.func_148899_d()) + { + case 0: + entityclientplayermp.displayGUIChest(new InventoryBasic(p_147265_1_.func_148902_e(), p_147265_1_.func_148900_g(), p_147265_1_.func_148898_f())); + entityclientplayermp.openContainer.windowId = p_147265_1_.func_148901_c(); + break; + case 1: + entityclientplayermp.displayGUIWorkbench(MathHelper.floor_double(entityclientplayermp.posX), MathHelper.floor_double(entityclientplayermp.posY), MathHelper.floor_double(entityclientplayermp.posZ)); + entityclientplayermp.openContainer.windowId = p_147265_1_.func_148901_c(); + break; + case 2: + TileEntityFurnace tileentityfurnace = new TileEntityFurnace(); + + if (p_147265_1_.func_148900_g()) + { + tileentityfurnace.func_145951_a(p_147265_1_.func_148902_e()); + } + + entityclientplayermp.func_146101_a(tileentityfurnace); + entityclientplayermp.openContainer.windowId = p_147265_1_.func_148901_c(); + break; + case 3: + TileEntityDispenser tileentitydispenser = new TileEntityDispenser(); + + if (p_147265_1_.func_148900_g()) + { + tileentitydispenser.func_146018_a(p_147265_1_.func_148902_e()); + } + + entityclientplayermp.func_146102_a(tileentitydispenser); + entityclientplayermp.openContainer.windowId = p_147265_1_.func_148901_c(); + break; + case 4: + entityclientplayermp.displayGUIEnchantment(MathHelper.floor_double(entityclientplayermp.posX), MathHelper.floor_double(entityclientplayermp.posY), MathHelper.floor_double(entityclientplayermp.posZ), p_147265_1_.func_148900_g() ? p_147265_1_.func_148902_e() : null); + entityclientplayermp.openContainer.windowId = p_147265_1_.func_148901_c(); + break; + case 5: + TileEntityBrewingStand tileentitybrewingstand = new TileEntityBrewingStand(); + + if (p_147265_1_.func_148900_g()) + { + tileentitybrewingstand.func_145937_a(p_147265_1_.func_148902_e()); + } + + entityclientplayermp.func_146098_a(tileentitybrewingstand); + entityclientplayermp.openContainer.windowId = p_147265_1_.func_148901_c(); + break; + case 6: + entityclientplayermp.displayGUIMerchant(new NpcMerchant(entityclientplayermp), p_147265_1_.func_148900_g() ? p_147265_1_.func_148902_e() : null); + entityclientplayermp.openContainer.windowId = p_147265_1_.func_148901_c(); + break; + case 7: + TileEntityBeacon tileentitybeacon = new TileEntityBeacon(); + entityclientplayermp.func_146104_a(tileentitybeacon); + + if (p_147265_1_.func_148900_g()) + { + tileentitybeacon.func_145999_a(p_147265_1_.func_148902_e()); + } + + entityclientplayermp.openContainer.windowId = p_147265_1_.func_148901_c(); + break; + case 8: + entityclientplayermp.displayGUIAnvil(MathHelper.floor_double(entityclientplayermp.posX), MathHelper.floor_double(entityclientplayermp.posY), MathHelper.floor_double(entityclientplayermp.posZ)); + entityclientplayermp.openContainer.windowId = p_147265_1_.func_148901_c(); + break; + case 9: + TileEntityHopper tileentityhopper = new TileEntityHopper(); + + if (p_147265_1_.func_148900_g()) + { + tileentityhopper.func_145886_a(p_147265_1_.func_148902_e()); + } + + entityclientplayermp.func_146093_a(tileentityhopper); + entityclientplayermp.openContainer.windowId = p_147265_1_.func_148901_c(); + break; + case 10: + TileEntityDropper tileentitydropper = new TileEntityDropper(); + + if (p_147265_1_.func_148900_g()) + { + tileentitydropper.func_146018_a(p_147265_1_.func_148902_e()); + } + + entityclientplayermp.func_146102_a(tileentitydropper); + entityclientplayermp.openContainer.windowId = p_147265_1_.func_148901_c(); + break; + case 11: + Entity entity = this.clientWorldController.getEntityByID(p_147265_1_.func_148897_h()); + + if (entity != null && entity instanceof EntityHorse) + { + entityclientplayermp.displayGUIHorse((EntityHorse)entity, new AnimalChest(p_147265_1_.func_148902_e(), p_147265_1_.func_148900_g(), p_147265_1_.func_148898_f())); + entityclientplayermp.openContainer.windowId = p_147265_1_.func_148901_c(); + } + } + } + + public void handleSetSlot(S2FPacketSetSlot p_147266_1_) + { + EntityClientPlayerMP entityclientplayermp = this.gameController.thePlayer; + + if (p_147266_1_.func_149175_c() == -1) + { + entityclientplayermp.inventory.setItemStack(p_147266_1_.func_149174_e()); + } + else + { + boolean flag = false; + + if (this.gameController.currentScreen instanceof GuiContainerCreative) + { + GuiContainerCreative guicontainercreative = (GuiContainerCreative)this.gameController.currentScreen; + flag = guicontainercreative.func_147056_g() != CreativeTabs.tabInventory.getTabIndex(); + } + + if (p_147266_1_.func_149175_c() == 0 && p_147266_1_.func_149173_d() >= 36 && p_147266_1_.func_149173_d() < 45) + { + ItemStack itemstack = entityclientplayermp.inventoryContainer.getSlot(p_147266_1_.func_149173_d()).getStack(); + + if (p_147266_1_.func_149174_e() != null && (itemstack == null || itemstack.stackSize < p_147266_1_.func_149174_e().stackSize)) + { + p_147266_1_.func_149174_e().animationsToGo = 5; + } + + entityclientplayermp.inventoryContainer.putStackInSlot(p_147266_1_.func_149173_d(), p_147266_1_.func_149174_e()); + } + else if (p_147266_1_.func_149175_c() == entityclientplayermp.openContainer.windowId && (p_147266_1_.func_149175_c() != 0 || !flag)) + { + entityclientplayermp.openContainer.putStackInSlot(p_147266_1_.func_149173_d(), p_147266_1_.func_149174_e()); + } + } + } + + public void handleConfirmTransaction(S32PacketConfirmTransaction p_147239_1_) + { + Container container = null; + EntityClientPlayerMP entityclientplayermp = this.gameController.thePlayer; + + if (p_147239_1_.func_148889_c() == 0) + { + container = entityclientplayermp.inventoryContainer; + } + else if (p_147239_1_.func_148889_c() == entityclientplayermp.openContainer.windowId) + { + container = entityclientplayermp.openContainer; + } + + if (container != null && !p_147239_1_.func_148888_e()) + { + this.addToSendQueue(new C0FPacketConfirmTransaction(p_147239_1_.func_148889_c(), p_147239_1_.func_148890_d(), true)); + } + } + + public void handleWindowItems(S30PacketWindowItems p_147241_1_) + { + EntityClientPlayerMP entityclientplayermp = this.gameController.thePlayer; + + if (p_147241_1_.func_148911_c() == 0) + { + entityclientplayermp.inventoryContainer.putStacksInSlots(p_147241_1_.func_148910_d()); + } + else if (p_147241_1_.func_148911_c() == entityclientplayermp.openContainer.windowId) + { + entityclientplayermp.openContainer.putStacksInSlots(p_147241_1_.func_148910_d()); + } + } + + public void handleSignEditorOpen(S36PacketSignEditorOpen p_147268_1_) + { + Object object = this.clientWorldController.getTileEntity(p_147268_1_.func_149129_c(), p_147268_1_.func_149128_d(), p_147268_1_.func_149127_e()); + + if (object == null) + { + object = new TileEntitySign(); + ((TileEntity)object).setWorldObj(this.clientWorldController); + ((TileEntity)object).xCoord = p_147268_1_.func_149129_c(); + ((TileEntity)object).yCoord = p_147268_1_.func_149128_d(); + ((TileEntity)object).zCoord = p_147268_1_.func_149127_e(); + } + + this.gameController.thePlayer.func_146100_a((TileEntity)object); + } + + public void handleUpdateSign(S33PacketUpdateSign p_147248_1_) + { + boolean flag = false; + + if (this.gameController.theWorld.blockExists(p_147248_1_.func_149346_c(), p_147248_1_.func_149345_d(), p_147248_1_.func_149344_e())) + { + TileEntity tileentity = this.gameController.theWorld.getTileEntity(p_147248_1_.func_149346_c(), p_147248_1_.func_149345_d(), p_147248_1_.func_149344_e()); + + if (tileentity instanceof TileEntitySign) + { + TileEntitySign tileentitysign = (TileEntitySign)tileentity; + + if (tileentitysign.func_145914_a()) + { + for (int i = 0; i < 4; ++i) + { + tileentitysign.signText[i] = p_147248_1_.func_149347_f()[i]; + } + + tileentitysign.markDirty(); + } + + flag = true; + } + } + + if (!flag && this.gameController.thePlayer != null) + { + this.gameController.thePlayer.addChatMessage(new ChatComponentText("Unable to locate sign at " + p_147248_1_.func_149346_c() + ", " + p_147248_1_.func_149345_d() + ", " + p_147248_1_.func_149344_e())); + } + } + + public void handleUpdateTileEntity(S35PacketUpdateTileEntity p_147273_1_) + { + if (this.gameController.theWorld.blockExists(p_147273_1_.func_148856_c(), p_147273_1_.func_148855_d(), p_147273_1_.func_148854_e())) + { + TileEntity tileentity = this.gameController.theWorld.getTileEntity(p_147273_1_.func_148856_c(), p_147273_1_.func_148855_d(), p_147273_1_.func_148854_e()); + + if (tileentity != null) + { + if (p_147273_1_.func_148853_f() == 1 && tileentity instanceof TileEntityMobSpawner) + { + tileentity.readFromNBT(p_147273_1_.func_148857_g()); + } + else if (p_147273_1_.func_148853_f() == 2 && tileentity instanceof TileEntityCommandBlock) + { + tileentity.readFromNBT(p_147273_1_.func_148857_g()); + } + else if (p_147273_1_.func_148853_f() == 3 && tileentity instanceof TileEntityBeacon) + { + tileentity.readFromNBT(p_147273_1_.func_148857_g()); + } + else if (p_147273_1_.func_148853_f() == 4 && tileentity instanceof TileEntitySkull) + { + tileentity.readFromNBT(p_147273_1_.func_148857_g()); + } + else if (p_147273_1_.func_148853_f() == 5 && tileentity instanceof TileEntityFlowerPot) + { + tileentity.readFromNBT(p_147273_1_.func_148857_g()); + } + else + { + tileentity.onDataPacket(netManager, p_147273_1_); + } + } + } + } + + public void handleWindowProperty(S31PacketWindowProperty p_147245_1_) + { + EntityClientPlayerMP entityclientplayermp = this.gameController.thePlayer; + + if (entityclientplayermp.openContainer != null && entityclientplayermp.openContainer.windowId == p_147245_1_.func_149182_c()) + { + entityclientplayermp.openContainer.updateProgressBar(p_147245_1_.func_149181_d(), p_147245_1_.func_149180_e()); + } + } + + public void handleEntityEquipment(S04PacketEntityEquipment p_147242_1_) + { + Entity entity = this.clientWorldController.getEntityByID(p_147242_1_.func_149389_d()); + + if (entity != null) + { + entity.setCurrentItemOrArmor(p_147242_1_.func_149388_e(), p_147242_1_.func_149390_c()); + } + } + + public void handleCloseWindow(S2EPacketCloseWindow p_147276_1_) + { + this.gameController.thePlayer.closeScreenNoPacket(); + } + + public void handleBlockAction(S24PacketBlockAction p_147261_1_) + { + this.gameController.theWorld.addBlockEvent(p_147261_1_.func_148867_d(), p_147261_1_.func_148866_e(), p_147261_1_.func_148865_f(), p_147261_1_.func_148868_c(), p_147261_1_.func_148869_g(), p_147261_1_.func_148864_h()); + } + + public void handleBlockBreakAnim(S25PacketBlockBreakAnim p_147294_1_) + { + this.gameController.theWorld.destroyBlockInWorldPartially(p_147294_1_.func_148845_c(), p_147294_1_.func_148844_d(), p_147294_1_.func_148843_e(), p_147294_1_.func_148842_f(), p_147294_1_.func_148846_g()); + } + + public void handleMapChunkBulk(S26PacketMapChunkBulk p_147269_1_) + { + for (int i = 0; i < p_147269_1_.func_149254_d(); ++i) + { + int j = p_147269_1_.func_149255_a(i); + int k = p_147269_1_.func_149253_b(i); + this.clientWorldController.doPreChunk(j, k, true); + this.clientWorldController.invalidateBlockReceiveRegion(j << 4, 0, k << 4, (j << 4) + 15, 256, (k << 4) + 15); + Chunk chunk = this.clientWorldController.getChunkFromChunkCoords(j, k); + chunk.fillChunk(p_147269_1_.func_149256_c(i), p_147269_1_.func_149252_e()[i], p_147269_1_.func_149257_f()[i], true); + this.clientWorldController.markBlockRangeForRenderUpdate(j << 4, 0, k << 4, (j << 4) + 15, 256, (k << 4) + 15); + + if (!(this.clientWorldController.provider instanceof WorldProviderSurface)) + { + chunk.resetRelightChecks(); + } + } + } + + public void handleChangeGameState(S2BPacketChangeGameState p_147252_1_) + { + EntityClientPlayerMP entityclientplayermp = this.gameController.thePlayer; + int i = p_147252_1_.func_149138_c(); + float f = p_147252_1_.func_149137_d(); + int j = MathHelper.floor_float(f + 0.5F); + + if (i >= 0 && i < S2BPacketChangeGameState.field_149142_a.length && S2BPacketChangeGameState.field_149142_a[i] != null) + { + entityclientplayermp.addChatComponentMessage(new ChatComponentTranslation(S2BPacketChangeGameState.field_149142_a[i], new Object[0])); + } + + if (i == 1) + { + this.clientWorldController.getWorldInfo().setRaining(true); + this.clientWorldController.setRainStrength(0.0F); + } + else if (i == 2) + { + this.clientWorldController.getWorldInfo().setRaining(false); + this.clientWorldController.setRainStrength(1.0F); + } + else if (i == 3) + { + this.gameController.playerController.setGameType(WorldSettings.GameType.getByID(j)); + } + else if (i == 4) + { + this.gameController.displayGuiScreen(new GuiWinGame()); + } + else if (i == 5) + { + GameSettings gamesettings = this.gameController.gameSettings; + + if (f == 0.0F) + { + this.gameController.displayGuiScreen(new GuiScreenDemo()); + } + else if (f == 101.0F) + { + this.gameController.ingameGUI.getChatGUI().printChatMessage(new ChatComponentTranslation("demo.help.movement", new Object[] {GameSettings.getKeyDisplayString(gamesettings.keyBindForward.getKeyCode()), GameSettings.getKeyDisplayString(gamesettings.keyBindLeft.getKeyCode()), GameSettings.getKeyDisplayString(gamesettings.keyBindBack.getKeyCode()), GameSettings.getKeyDisplayString(gamesettings.keyBindRight.getKeyCode())})); + } + else if (f == 102.0F) + { + this.gameController.ingameGUI.getChatGUI().printChatMessage(new ChatComponentTranslation("demo.help.jump", new Object[] {GameSettings.getKeyDisplayString(gamesettings.keyBindJump.getKeyCode())})); + } + else if (f == 103.0F) + { + this.gameController.ingameGUI.getChatGUI().printChatMessage(new ChatComponentTranslation("demo.help.inventory", new Object[] {GameSettings.getKeyDisplayString(gamesettings.keyBindInventory.getKeyCode())})); + } + } + else if (i == 6) + { + this.clientWorldController.playSound(entityclientplayermp.posX, entityclientplayermp.posY + (double)entityclientplayermp.getEyeHeight(), entityclientplayermp.posZ, "random.successful_hit", 0.18F, 0.45F, false); + } + else if (i == 7) + { + this.clientWorldController.setRainStrength(f); + } + else if (i == 8) + { + this.clientWorldController.setThunderStrength(f); + } + } + + public void handleMaps(S34PacketMaps p_147264_1_) + { + MapData mapdata = ItemMap.func_150912_a(p_147264_1_.func_149188_c(), this.gameController.theWorld); + mapdata.updateMPMapData(p_147264_1_.func_149187_d()); + this.gameController.entityRenderer.getMapItemRenderer().func_148246_a(mapdata); + } + + public void handleEffect(S28PacketEffect p_147277_1_) + { + if (p_147277_1_.func_149244_c()) + { + this.gameController.theWorld.playBroadcastSound(p_147277_1_.func_149242_d(), p_147277_1_.func_149240_f(), p_147277_1_.func_149243_g(), p_147277_1_.func_149239_h(), p_147277_1_.func_149241_e()); + } + else + { + this.gameController.theWorld.playAuxSFX(p_147277_1_.func_149242_d(), p_147277_1_.func_149240_f(), p_147277_1_.func_149243_g(), p_147277_1_.func_149239_h(), p_147277_1_.func_149241_e()); + } + } + + public void handleStatistics(S37PacketStatistics p_147293_1_) + { + boolean flag = false; + StatBase statbase; + int i; + + for (Iterator iterator = p_147293_1_.func_148974_c().entrySet().iterator(); iterator.hasNext(); this.gameController.thePlayer.getStatFileWriter().func_150873_a(this.gameController.thePlayer, statbase, i)) + { + Entry entry = (Entry)iterator.next(); + statbase = (StatBase)entry.getKey(); + i = ((Integer)entry.getValue()).intValue(); + + if (statbase.isAchievement() && i > 0) + { + if (this.field_147308_k && this.gameController.thePlayer.getStatFileWriter().writeStat(statbase) == 0) + { + this.gameController.guiAchievement.func_146256_a((Achievement)statbase); + + if (statbase == AchievementList.openInventory) + { + this.gameController.gameSettings.showInventoryAchievementHint = false; + this.gameController.gameSettings.saveOptions(); + } + } + + flag = true; + } + } + + if (!this.field_147308_k && !flag && this.gameController.gameSettings.showInventoryAchievementHint) + { + this.gameController.guiAchievement.func_146255_b(AchievementList.openInventory); + } + + this.field_147308_k = true; + + if (this.gameController.currentScreen instanceof IProgressMeter) + { + ((IProgressMeter)this.gameController.currentScreen).func_146509_g(); + } + } + + public void handleEntityEffect(S1DPacketEntityEffect p_147260_1_) + { + Entity entity = this.clientWorldController.getEntityByID(p_147260_1_.func_149426_d()); + + if (entity instanceof EntityLivingBase) + { + PotionEffect potioneffect = new PotionEffect(p_147260_1_.func_149427_e(), p_147260_1_.func_149425_g(), p_147260_1_.func_149428_f()); + potioneffect.setPotionDurationMax(p_147260_1_.func_149429_c()); + ((EntityLivingBase)entity).addPotionEffect(potioneffect); + } + } + + public void handleRemoveEntityEffect(S1EPacketRemoveEntityEffect p_147262_1_) + { + Entity entity = this.clientWorldController.getEntityByID(p_147262_1_.func_149076_c()); + + if (entity instanceof EntityLivingBase) + { + ((EntityLivingBase)entity).removePotionEffectClient(p_147262_1_.func_149075_d()); + } + } + + public void handlePlayerListItem(S38PacketPlayerListItem p_147256_1_) + { + GuiPlayerInfo guiplayerinfo = (GuiPlayerInfo)this.playerInfoMap.get(p_147256_1_.func_149122_c()); + + if (guiplayerinfo == null && p_147256_1_.func_149121_d()) + { + guiplayerinfo = new GuiPlayerInfo(p_147256_1_.func_149122_c()); + this.playerInfoMap.put(p_147256_1_.func_149122_c(), guiplayerinfo); + this.playerInfoList.add(guiplayerinfo); + } + + if (guiplayerinfo != null && !p_147256_1_.func_149121_d()) + { + this.playerInfoMap.remove(p_147256_1_.func_149122_c()); + this.playerInfoList.remove(guiplayerinfo); + } + + if (guiplayerinfo != null && p_147256_1_.func_149121_d()) + { + guiplayerinfo.responseTime = p_147256_1_.func_149120_e(); + } + } + + public void handleKeepAlive(S00PacketKeepAlive p_147272_1_) + { + this.addToSendQueue(new C00PacketKeepAlive(p_147272_1_.func_149134_c())); + } + + public void onConnectionStateTransition(EnumConnectionState p_147232_1_, EnumConnectionState p_147232_2_) + { + throw new IllegalStateException("Unexpected protocol change!"); + } + + public void handlePlayerAbilities(S39PacketPlayerAbilities p_147270_1_) + { + EntityClientPlayerMP entityclientplayermp = this.gameController.thePlayer; + entityclientplayermp.capabilities.isFlying = p_147270_1_.func_149106_d(); + entityclientplayermp.capabilities.isCreativeMode = p_147270_1_.func_149103_f(); + entityclientplayermp.capabilities.disableDamage = p_147270_1_.func_149112_c(); + entityclientplayermp.capabilities.allowFlying = p_147270_1_.func_149105_e(); + entityclientplayermp.capabilities.setFlySpeed(p_147270_1_.func_149101_g()); + entityclientplayermp.capabilities.setPlayerWalkSpeed(p_147270_1_.func_149107_h()); + } + + public void handleTabComplete(S3APacketTabComplete p_147274_1_) + { + String[] astring = p_147274_1_.func_149630_c(); + + if (this.gameController.currentScreen instanceof GuiChat) + { + GuiChat guichat = (GuiChat)this.gameController.currentScreen; + guichat.func_146406_a(astring); + } + } + + public void handleSoundEffect(S29PacketSoundEffect p_147255_1_) + { + this.gameController.theWorld.playSound(p_147255_1_.func_149207_d(), p_147255_1_.func_149211_e(), p_147255_1_.func_149210_f(), p_147255_1_.func_149212_c(), p_147255_1_.func_149208_g(), p_147255_1_.func_149209_h(), false); + } + + public void handleCustomPayload(S3FPacketCustomPayload p_147240_1_) + { + if ("MC|TrList".equals(p_147240_1_.func_149169_c())) + { + ByteBuf bytebuf = Unpooled.wrappedBuffer(p_147240_1_.func_149168_d()); + + try + { + int i = bytebuf.readInt(); + GuiScreen guiscreen = this.gameController.currentScreen; + + if (guiscreen != null && guiscreen instanceof GuiMerchant && i == this.gameController.thePlayer.openContainer.windowId) + { + IMerchant imerchant = ((GuiMerchant)guiscreen).func_147035_g(); + MerchantRecipeList merchantrecipelist = MerchantRecipeList.func_151390_b(new PacketBuffer(bytebuf)); + imerchant.setRecipes(merchantrecipelist); + } + } + catch (IOException ioexception) + { + logger.error("Couldn\'t load trade info", ioexception); + } + } + else if ("MC|Brand".equals(p_147240_1_.func_149169_c())) + { + this.gameController.thePlayer.func_142020_c(new String(p_147240_1_.func_149168_d(), Charsets.UTF_8)); + } + else if ("MC|RPack".equals(p_147240_1_.func_149169_c())) + { + final String s = new String(p_147240_1_.func_149168_d(), Charsets.UTF_8); + + if (this.gameController.gameSettings.serverTextures) + { + if (this.gameController.func_147104_D() != null && this.gameController.func_147104_D().func_147408_b()) + { + this.gameController.getResourcePackRepository().func_148526_a(s); + } + else if (this.gameController.func_147104_D() == null || this.gameController.func_147104_D().func_147410_c()) + { + this.gameController.displayGuiScreen(new GuiYesNo(new GuiScreen() + { + private static final String __OBFID = "CL_00000879"; + public void confirmClicked(boolean par1, int par2) + { + this.mc = Minecraft.getMinecraft(); + + if (this.mc.func_147104_D() != null) + { + this.mc.func_147104_D().setAcceptsTextures(par1); + ServerList.func_147414_b(this.mc.func_147104_D()); + } + + if (par1) + { + this.mc.getResourcePackRepository().func_148526_a(s); + } + + this.mc.displayGuiScreen((GuiScreen)null); + } + }, I18n.format("multiplayer.texturePrompt.line1", new Object[0]), I18n.format("multiplayer.texturePrompt.line2", new Object[0]), 0)); + } + } + } + } + + public void handleScoreboardObjective(S3BPacketScoreboardObjective p_147291_1_) + { + Scoreboard scoreboard = this.clientWorldController.getScoreboard(); + ScoreObjective scoreobjective; + + if (p_147291_1_.func_149338_e() == 0) + { + scoreobjective = scoreboard.addScoreObjective(p_147291_1_.func_149339_c(), IScoreObjectiveCriteria.field_96641_b); + scoreobjective.setDisplayName(p_147291_1_.func_149337_d()); + } + else + { + scoreobjective = scoreboard.getObjective(p_147291_1_.func_149339_c()); + + if (p_147291_1_.func_149338_e() == 1) + { + scoreboard.func_96519_k(scoreobjective); + } + else if (p_147291_1_.func_149338_e() == 2) + { + scoreobjective.setDisplayName(p_147291_1_.func_149337_d()); + } + } + } + + public void handleUpdateScore(S3CPacketUpdateScore p_147250_1_) + { + Scoreboard scoreboard = this.clientWorldController.getScoreboard(); + ScoreObjective scoreobjective = scoreboard.getObjective(p_147250_1_.func_149321_d()); + + if (p_147250_1_.func_149322_f() == 0) + { + Score score = scoreboard.func_96529_a(p_147250_1_.func_149324_c(), scoreobjective); + score.setScorePoints(p_147250_1_.func_149323_e()); + } + else if (p_147250_1_.func_149322_f() == 1) + { + scoreboard.func_96515_c(p_147250_1_.func_149324_c()); + } + } + + public void handleDisplayScoreboard(S3DPacketDisplayScoreboard p_147254_1_) + { + Scoreboard scoreboard = this.clientWorldController.getScoreboard(); + + if (p_147254_1_.func_149370_d().length() == 0) + { + scoreboard.func_96530_a(p_147254_1_.func_149371_c(), (ScoreObjective)null); + } + else + { + ScoreObjective scoreobjective = scoreboard.getObjective(p_147254_1_.func_149370_d()); + scoreboard.func_96530_a(p_147254_1_.func_149371_c(), scoreobjective); + } + } + + public void handleTeams(S3EPacketTeams p_147247_1_) + { + Scoreboard scoreboard = this.clientWorldController.getScoreboard(); + ScorePlayerTeam scoreplayerteam; + + if (p_147247_1_.func_149307_h() == 0) + { + scoreplayerteam = scoreboard.createTeam(p_147247_1_.func_149312_c()); + } + else + { + scoreplayerteam = scoreboard.getTeam(p_147247_1_.func_149312_c()); + } + + if (p_147247_1_.func_149307_h() == 0 || p_147247_1_.func_149307_h() == 2) + { + scoreplayerteam.setTeamName(p_147247_1_.func_149306_d()); + scoreplayerteam.setNamePrefix(p_147247_1_.func_149311_e()); + scoreplayerteam.setNameSuffix(p_147247_1_.func_149309_f()); + scoreplayerteam.func_98298_a(p_147247_1_.func_149308_i()); + } + + Iterator iterator; + String s; + + if (p_147247_1_.func_149307_h() == 0 || p_147247_1_.func_149307_h() == 3) + { + iterator = p_147247_1_.func_149310_g().iterator(); + + while (iterator.hasNext()) + { + s = (String)iterator.next(); + scoreboard.func_151392_a(s, p_147247_1_.func_149312_c()); + } + } + + if (p_147247_1_.func_149307_h() == 4) + { + iterator = p_147247_1_.func_149310_g().iterator(); + + while (iterator.hasNext()) + { + s = (String)iterator.next(); + scoreboard.removePlayerFromTeam(s, scoreplayerteam); + } + } + + if (p_147247_1_.func_149307_h() == 1) + { + scoreboard.removeTeam(scoreplayerteam); + } + } + + public void handleParticles(S2APacketParticles p_147289_1_) + { + if (p_147289_1_.func_149222_k() == 0) + { + double d0 = (double)(p_147289_1_.func_149227_j() * p_147289_1_.func_149221_g()); + double d2 = (double)(p_147289_1_.func_149227_j() * p_147289_1_.func_149224_h()); + double d4 = (double)(p_147289_1_.func_149227_j() * p_147289_1_.func_149223_i()); + this.clientWorldController.spawnParticle(p_147289_1_.func_149228_c(), p_147289_1_.func_149220_d(), p_147289_1_.func_149226_e(), p_147289_1_.func_149225_f(), d0, d2, d4); + } + else + { + for (int i = 0; i < p_147289_1_.func_149222_k(); ++i) + { + double d1 = this.avRandomizer.nextGaussian() * (double)p_147289_1_.func_149221_g(); + double d3 = this.avRandomizer.nextGaussian() * (double)p_147289_1_.func_149224_h(); + double d5 = this.avRandomizer.nextGaussian() * (double)p_147289_1_.func_149223_i(); + double d6 = this.avRandomizer.nextGaussian() * (double)p_147289_1_.func_149227_j(); + double d7 = this.avRandomizer.nextGaussian() * (double)p_147289_1_.func_149227_j(); + double d8 = this.avRandomizer.nextGaussian() * (double)p_147289_1_.func_149227_j(); + this.clientWorldController.spawnParticle(p_147289_1_.func_149228_c(), p_147289_1_.func_149220_d() + d1, p_147289_1_.func_149226_e() + d3, p_147289_1_.func_149225_f() + d5, d6, d7, d8); + } + } + } + + public void handleEntityProperties(S20PacketEntityProperties p_147290_1_) + { + Entity entity = this.clientWorldController.getEntityByID(p_147290_1_.func_149442_c()); + + if (entity != null) + { + if (!(entity instanceof EntityLivingBase)) + { + throw new IllegalStateException("Server tried to update attributes of a non-living entity (actually: " + entity + ")"); + } + else + { + BaseAttributeMap baseattributemap = ((EntityLivingBase)entity).getAttributeMap(); + Iterator iterator = p_147290_1_.func_149441_d().iterator(); + + while (iterator.hasNext()) + { + S20PacketEntityProperties.Snapshot snapshot = (S20PacketEntityProperties.Snapshot)iterator.next(); + IAttributeInstance iattributeinstance = baseattributemap.getAttributeInstanceByName(snapshot.func_151409_a()); + + if (iattributeinstance == null) + { + iattributeinstance = baseattributemap.registerAttribute(new RangedAttribute(snapshot.func_151409_a(), 0.0D, 2.2250738585072014E-308D, Double.MAX_VALUE)); + } + + iattributeinstance.setBaseValue(snapshot.func_151410_b()); + iattributeinstance.removeAllModifiers(); + Iterator iterator1 = snapshot.func_151408_c().iterator(); + + while (iterator1.hasNext()) + { + AttributeModifier attributemodifier = (AttributeModifier)iterator1.next(); + iattributeinstance.applyModifier(attributemodifier); + } + } + } + } + } + + public NetworkManager getNetworkManager() + { + return this.netManager; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/network/OldServerPinger.java b/src/main/java/net/minecraft/client/network/OldServerPinger.java new file mode 100644 index 0000000..9c880d2 --- /dev/null +++ b/src/main/java/net/minecraft/client/network/OldServerPinger.java @@ -0,0 +1,346 @@ +package net.minecraft.client.network; + +import com.google.common.base.Charsets; +import com.google.common.base.Splitter; +import com.google.common.collect.Iterables; +import com.mojang.authlib.GameProfile; +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.bootstrap.Bootstrap; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; +import io.netty.channel.Channel; +import io.netty.channel.ChannelException; +import io.netty.channel.ChannelFutureListener; +import io.netty.channel.ChannelHandler; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelInitializer; +import io.netty.channel.ChannelOption; +import io.netty.channel.SimpleChannelInboundHandler; +import io.netty.channel.socket.nio.NioSocketChannel; +import io.netty.util.concurrent.GenericFutureListener; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.ServerAddress; +import net.minecraft.client.multiplayer.ServerData; +import net.minecraft.network.EnumConnectionState; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.ServerStatusResponse; +import net.minecraft.network.handshake.client.C00Handshake; +import net.minecraft.network.status.INetHandlerStatusClient; +import net.minecraft.network.status.client.C00PacketServerQuery; +import net.minecraft.network.status.client.C01PacketPing; +import net.minecraft.network.status.server.S00PacketServerInfo; +import net.minecraft.network.status.server.S01PacketPong; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IChatComponent; +import net.minecraft.util.MathHelper; +import org.apache.commons.lang3.ArrayUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +@SideOnly(Side.CLIENT) +public class OldServerPinger +{ + private static final Splitter field_147230_a = Splitter.on('\u0000').limit(6); + private static final Logger logger = LogManager.getLogger(); + private final List field_147229_c = Collections.synchronizedList(new ArrayList()); + private static final String __OBFID = "CL_00000892"; + + public void func_147224_a(final ServerData p_147224_1_) throws UnknownHostException + { + ServerAddress serveraddress = ServerAddress.func_78860_a(p_147224_1_.serverIP); + final NetworkManager networkmanager = NetworkManager.provideLanClient(InetAddress.getByName(serveraddress.getIP()), serveraddress.getPort()); + this.field_147229_c.add(networkmanager); + p_147224_1_.serverMOTD = "Pinging..."; + p_147224_1_.pingToServer = -1L; + p_147224_1_.field_147412_i = null; + networkmanager.setNetHandler(new INetHandlerStatusClient() + { + private boolean field_147403_d = false; + private static final String __OBFID = "CL_00000893"; + public void handleServerInfo(S00PacketServerInfo p_147397_1_) + { + ServerStatusResponse serverstatusresponse = p_147397_1_.func_149294_c(); + + if (serverstatusresponse.func_151317_a() != null) + { + p_147224_1_.serverMOTD = serverstatusresponse.func_151317_a().getFormattedText(); + } + else + { + p_147224_1_.serverMOTD = ""; + } + + if (serverstatusresponse.func_151322_c() != null) + { + p_147224_1_.gameVersion = serverstatusresponse.func_151322_c().func_151303_a(); + p_147224_1_.field_82821_f = serverstatusresponse.func_151322_c().func_151304_b(); + } + else + { + p_147224_1_.gameVersion = "Old"; + p_147224_1_.field_82821_f = 0; + } + + if (serverstatusresponse.func_151318_b() != null) + { + p_147224_1_.populationInfo = EnumChatFormatting.GRAY + "" + serverstatusresponse.func_151318_b().func_151333_b() + "" + EnumChatFormatting.DARK_GRAY + "/" + EnumChatFormatting.GRAY + serverstatusresponse.func_151318_b().func_151332_a(); + + if (ArrayUtils.isNotEmpty(serverstatusresponse.func_151318_b().func_151331_c())) + { + StringBuilder stringbuilder = new StringBuilder(); + GameProfile[] agameprofile = serverstatusresponse.func_151318_b().func_151331_c(); + int i = agameprofile.length; + + for (int j = 0; j < i; ++j) + { + GameProfile gameprofile = agameprofile[j]; + + if (stringbuilder.length() > 0) + { + stringbuilder.append("\n"); + } + + stringbuilder.append(gameprofile.getName()); + } + + if (serverstatusresponse.func_151318_b().func_151331_c().length < serverstatusresponse.func_151318_b().func_151333_b()) + { + if (stringbuilder.length() > 0) + { + stringbuilder.append("\n"); + } + + stringbuilder.append("... and ").append(serverstatusresponse.func_151318_b().func_151333_b() - serverstatusresponse.func_151318_b().func_151331_c().length).append(" more ..."); + } + + p_147224_1_.field_147412_i = stringbuilder.toString(); + } + } + else + { + p_147224_1_.populationInfo = EnumChatFormatting.DARK_GRAY + "???"; + } + + if (serverstatusresponse.func_151316_d() != null) + { + String s = serverstatusresponse.func_151316_d(); + + if (s.startsWith("data:image/png;base64,")) + { + p_147224_1_.func_147407_a(s.substring("data:image/png;base64,".length())); + } + else + { + OldServerPinger.logger.error("Invalid server icon (unknown format)"); + } + } + else + { + p_147224_1_.func_147407_a((String)null); + } + + FMLClientHandler.instance().bindServerListData(p_147224_1_, serverstatusresponse); + networkmanager.scheduleOutboundPacket(new C01PacketPing(Minecraft.getSystemTime()), new GenericFutureListener[0]); + this.field_147403_d = true; + } + public void handlePong(S01PacketPong p_147398_1_) + { + long i = p_147398_1_.func_149292_c(); + long j = Minecraft.getSystemTime(); + p_147224_1_.pingToServer = j - i; + networkmanager.closeChannel(new ChatComponentText("Finished")); + } + public void onDisconnect(IChatComponent p_147231_1_) + { + if (!this.field_147403_d) + { + OldServerPinger.logger.error("Can\'t ping " + p_147224_1_.serverIP + ": " + p_147231_1_.getUnformattedText()); + p_147224_1_.serverMOTD = EnumChatFormatting.DARK_RED + "Can\'t connect to server."; + p_147224_1_.populationInfo = ""; + OldServerPinger.this.func_147225_b(p_147224_1_); + } + } + public void onConnectionStateTransition(EnumConnectionState p_147232_1_, EnumConnectionState p_147232_2_) + { + if (p_147232_2_ != EnumConnectionState.STATUS) + { + throw new UnsupportedOperationException("Unexpected change in protocol to " + p_147232_2_); + } + } + public void onNetworkTick() {} + }); + + try + { + networkmanager.scheduleOutboundPacket(new C00Handshake(4, serveraddress.getIP(), serveraddress.getPort(), EnumConnectionState.STATUS), new GenericFutureListener[0]); + networkmanager.scheduleOutboundPacket(new C00PacketServerQuery(), new GenericFutureListener[0]); + } + catch (Throwable throwable) + { + logger.error(throwable); + } + } + + private void func_147225_b(final ServerData p_147225_1_) + { + final ServerAddress serveraddress = ServerAddress.func_78860_a(p_147225_1_.serverIP); + ((Bootstrap)((Bootstrap)((Bootstrap)(new Bootstrap()).group(NetworkManager.eventLoops)).handler(new ChannelInitializer() + { + private static final String __OBFID = "CL_00000894"; + protected void initChannel(Channel p_initChannel_1_) + { + try + { + p_initChannel_1_.config().setOption(ChannelOption.IP_TOS, Integer.valueOf(24)); + } + catch (ChannelException channelexception1) + { + ; + } + + try + { + p_initChannel_1_.config().setOption(ChannelOption.TCP_NODELAY, Boolean.valueOf(false)); + } + catch (ChannelException channelexception) + { + ; + } + + p_initChannel_1_.pipeline().addLast(new ChannelHandler[] {new SimpleChannelInboundHandler() + { + private static final String __OBFID = "CL_00000895"; + public void channelActive(ChannelHandlerContext p_channelActive_1_) throws Exception + { + super.channelActive(p_channelActive_1_); + ByteBuf bytebuf = Unpooled.buffer(); + bytebuf.writeByte(254); + bytebuf.writeByte(1); + bytebuf.writeByte(250); + char[] achar = "MC|PingHost".toCharArray(); + bytebuf.writeShort(achar.length); + char[] achar1 = achar; + int i = achar.length; + int j; + char c0; + + for (j = 0; j < i; ++j) + { + c0 = achar1[j]; + bytebuf.writeChar(c0); + } + + bytebuf.writeShort(7 + 2 * serveraddress.getIP().length()); + bytebuf.writeByte(127); + achar = serveraddress.getIP().toCharArray(); + bytebuf.writeShort(achar.length); + achar1 = achar; + i = achar.length; + + for (j = 0; j < i; ++j) + { + c0 = achar1[j]; + bytebuf.writeChar(c0); + } + + bytebuf.writeInt(serveraddress.getPort()); + p_channelActive_1_.channel().writeAndFlush(bytebuf).addListener(ChannelFutureListener.CLOSE_ON_FAILURE); + } + protected void channelRead0(ChannelHandlerContext p_147219_1_, ByteBuf p_147219_2_) + { + short short1 = p_147219_2_.readUnsignedByte(); + + if (short1 == 255) + { + String s = new String(p_147219_2_.readBytes(p_147219_2_.readShort() * 2).array(), Charsets.UTF_16BE); + String[] astring = (String[])Iterables.toArray(OldServerPinger.field_147230_a.split(s), String.class); + + if ("\u00a71".equals(astring[0])) + { + int i = MathHelper.parseIntWithDefault(astring[1], 0); + String s1 = astring[2]; + String s2 = astring[3]; + int j = MathHelper.parseIntWithDefault(astring[4], -1); + int k = MathHelper.parseIntWithDefault(astring[5], -1); + p_147225_1_.field_82821_f = -1; + p_147225_1_.gameVersion = s1; + p_147225_1_.serverMOTD = s2; + p_147225_1_.populationInfo = EnumChatFormatting.GRAY + "" + j + "" + EnumChatFormatting.DARK_GRAY + "/" + EnumChatFormatting.GRAY + k; + } + } + + p_147219_1_.close(); + } + public void exceptionCaught(ChannelHandlerContext p_exceptionCaught_1_, Throwable p_exceptionCaught_2_) + { + p_exceptionCaught_1_.close(); + } + protected void channelRead0(ChannelHandlerContext p_channelRead0_1_, Object p_channelRead0_2_) + { + this.channelRead0(p_channelRead0_1_, (ByteBuf)p_channelRead0_2_); + } + } + }); + } + })).channel(NioSocketChannel.class)).connect(serveraddress.getIP(), serveraddress.getPort()); + } + + public void func_147223_a() + { + List list = this.field_147229_c; + + synchronized (this.field_147229_c) + { + Iterator iterator = this.field_147229_c.iterator(); + + while (iterator.hasNext()) + { + NetworkManager networkmanager = (NetworkManager)iterator.next(); + + if (networkmanager.isChannelOpen()) + { + networkmanager.processReceivedPackets(); + } + else + { + iterator.remove(); + + if (networkmanager.getExitMessage() != null) + { + networkmanager.getNetHandler().onDisconnect(networkmanager.getExitMessage()); + } + } + } + } + } + + public void func_147226_b() + { + List list = this.field_147229_c; + + synchronized (this.field_147229_c) + { + Iterator iterator = this.field_147229_c.iterator(); + + while (iterator.hasNext()) + { + NetworkManager networkmanager = (NetworkManager)iterator.next(); + + if (networkmanager.isChannelOpen()) + { + iterator.remove(); + networkmanager.closeChannel(new ChatComponentText("Cancelled")); + } + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/particle/EffectRenderer.java b/src/main/java/net/minecraft/client/particle/EffectRenderer.java new file mode 100644 index 0000000..892743c --- /dev/null +++ b/src/main/java/net/minecraft/client/particle/EffectRenderer.java @@ -0,0 +1,306 @@ +package net.minecraft.client.particle; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import java.util.concurrent.Callable; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.ActiveRenderInfo; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.crash.CrashReport; +import net.minecraft.crash.CrashReportCategory; +import net.minecraft.entity.Entity; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.ReportedException; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; + +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class EffectRenderer +{ + private static final ResourceLocation particleTextures = new ResourceLocation("textures/particle/particles.png"); + protected World worldObj; + private List[] fxLayers = new List[4]; + private TextureManager renderer; + private Random rand = new Random(); + private static final String __OBFID = "CL_00000915"; + + public EffectRenderer(World par1World, TextureManager par2TextureManager) + { + if (par1World != null) + { + this.worldObj = par1World; + } + + this.renderer = par2TextureManager; + + for (int i = 0; i < 4; ++i) + { + this.fxLayers[i] = new ArrayList(); + } + } + + public void addEffect(EntityFX par1EntityFX) + { + int i = par1EntityFX.getFXLayer(); + + if (this.fxLayers[i].size() >= 4000) + { + this.fxLayers[i].remove(0); + } + + this.fxLayers[i].add(par1EntityFX); + } + + public void updateEffects() + { + for (int k = 0; k < 4; ++k) + { + final int i = k; + + for (int j = 0; j < this.fxLayers[i].size(); ++j) + { + final EntityFX entityfx = (EntityFX)this.fxLayers[i].get(j); + + try + { + if (entityfx != null) + { + entityfx.onUpdate(); + } + } + catch (Throwable throwable) + { + CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Ticking Particle"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("Particle being ticked"); + crashreportcategory.addCrashSectionCallable("Particle", new Callable() + { + private static final String __OBFID = "CL_00000916"; + public String call() + { + return entityfx.toString(); + } + }); + crashreportcategory.addCrashSectionCallable("Particle Type", new Callable() + { + private static final String __OBFID = "CL_00000917"; + public String call() + { + return i == 0 ? "MISC_TEXTURE" : (i == 1 ? "TERRAIN_TEXTURE" : (i == 2 ? "ITEM_TEXTURE" : (i == 3 ? "ENTITY_PARTICLE_TEXTURE" : "Unknown - " + i))); + } + }); + throw new ReportedException(crashreport); + } + + if (entityfx == null || entityfx.isDead) + { + this.fxLayers[i].remove(j--); + } + } + } + } + + public void renderParticles(Entity par1Entity, float par2) + { + float f1 = ActiveRenderInfo.rotationX; + float f2 = ActiveRenderInfo.rotationZ; + float f3 = ActiveRenderInfo.rotationYZ; + float f4 = ActiveRenderInfo.rotationXY; + float f5 = ActiveRenderInfo.rotationXZ; + EntityFX.interpPosX = par1Entity.lastTickPosX + (par1Entity.posX - par1Entity.lastTickPosX) * (double)par2; + EntityFX.interpPosY = par1Entity.lastTickPosY + (par1Entity.posY - par1Entity.lastTickPosY) * (double)par2; + EntityFX.interpPosZ = par1Entity.lastTickPosZ + (par1Entity.posZ - par1Entity.lastTickPosZ) * (double)par2; + + for (int k = 0; k < 3; ++k) + { + final int i = k; + + if (!this.fxLayers[i].isEmpty()) + { + switch (i) + { + case 0: + default: + this.renderer.bindTexture(particleTextures); + break; + case 1: + this.renderer.bindTexture(TextureMap.locationBlocksTexture); + break; + case 2: + this.renderer.bindTexture(TextureMap.locationItemsTexture); + } + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDepthMask(false); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F); + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + + for (int j = 0; j < this.fxLayers[i].size(); ++j) + { + final EntityFX entityfx = (EntityFX)this.fxLayers[i].get(j); + if (entityfx == null) continue; + tessellator.setBrightness(entityfx.getBrightnessForRender(par2)); + + try + { + entityfx.renderParticle(tessellator, par2, f1, f5, f2, f3, f4); + } + catch (Throwable throwable) + { + CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Rendering Particle"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("Particle being rendered"); + crashreportcategory.addCrashSectionCallable("Particle", new Callable() + { + private static final String __OBFID = "CL_00000918"; + public String call() + { + return entityfx.toString(); + } + }); + crashreportcategory.addCrashSectionCallable("Particle Type", new Callable() + { + private static final String __OBFID = "CL_00000919"; + public String call() + { + return i == 0 ? "MISC_TEXTURE" : (i == 1 ? "TERRAIN_TEXTURE" : (i == 2 ? "ITEM_TEXTURE" : (i == 3 ? "ENTITY_PARTICLE_TEXTURE" : "Unknown - " + i))); + } + }); + throw new ReportedException(crashreport); + } + } + + tessellator.draw(); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthMask(true); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); + } + } + } + + public void renderLitParticles(Entity par1Entity, float par2) + { + float f1 = 0.017453292F; + float f2 = MathHelper.cos(par1Entity.rotationYaw * 0.017453292F); + float f3 = MathHelper.sin(par1Entity.rotationYaw * 0.017453292F); + float f4 = -f3 * MathHelper.sin(par1Entity.rotationPitch * 0.017453292F); + float f5 = f2 * MathHelper.sin(par1Entity.rotationPitch * 0.017453292F); + float f6 = MathHelper.cos(par1Entity.rotationPitch * 0.017453292F); + byte b0 = 3; + List list = this.fxLayers[b0]; + + if (!list.isEmpty()) + { + Tessellator tessellator = Tessellator.instance; + + for (int i = 0; i < list.size(); ++i) + { + EntityFX entityfx = (EntityFX)list.get(i); + if (entityfx == null) continue; + tessellator.setBrightness(entityfx.getBrightnessForRender(par2)); + entityfx.renderParticle(tessellator, par2, f2, f6, f3, f4, f5); + } + } + } + + public void clearEffects(World par1World) + { + this.worldObj = par1World; + + for (int i = 0; i < 4; ++i) + { + this.fxLayers[i].clear(); + } + } + + public void addBlockDestroyEffects(int p_147215_1_, int p_147215_2_, int p_147215_3_, Block p_147215_4_, int p_147215_5_) + { + if (!p_147215_4_.isAir(worldObj, p_147215_1_, p_147215_2_, p_147215_3_) && !p_147215_4_.addDestroyEffects(worldObj, p_147215_1_, p_147215_2_, p_147215_3_, p_147215_5_, this)) + { + byte b0 = 4; + + for (int i1 = 0; i1 < b0; ++i1) + { + for (int j1 = 0; j1 < b0; ++j1) + { + for (int k1 = 0; k1 < b0; ++k1) + { + double d0 = (double)p_147215_1_ + ((double)i1 + 0.5D) / (double)b0; + double d1 = (double)p_147215_2_ + ((double)j1 + 0.5D) / (double)b0; + double d2 = (double)p_147215_3_ + ((double)k1 + 0.5D) / (double)b0; + this.addEffect((new EntityDiggingFX(this.worldObj, d0, d1, d2, d0 - (double)p_147215_1_ - 0.5D, d1 - (double)p_147215_2_ - 0.5D, d2 - (double)p_147215_3_ - 0.5D, p_147215_4_, p_147215_5_)).applyColourMultiplier(p_147215_1_, p_147215_2_, p_147215_3_)); + } + } + } + } + } + + public void addBlockHitEffects(int par1, int par2, int par3, int par4) + { + Block block = this.worldObj.getBlock(par1, par2, par3); + + if (block.getMaterial() != Material.air) + { + float f = 0.1F; + double d0 = (double)par1 + this.rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - (double)(f * 2.0F)) + (double)f + block.getBlockBoundsMinX(); + double d1 = (double)par2 + this.rand.nextDouble() * (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY() - (double)(f * 2.0F)) + (double)f + block.getBlockBoundsMinY(); + double d2 = (double)par3 + this.rand.nextDouble() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - (double)(f * 2.0F)) + (double)f + block.getBlockBoundsMinZ(); + + if (par4 == 0) + { + d1 = (double)par2 + block.getBlockBoundsMinY() - (double)f; + } + + if (par4 == 1) + { + d1 = (double)par2 + block.getBlockBoundsMaxY() + (double)f; + } + + if (par4 == 2) + { + d2 = (double)par3 + block.getBlockBoundsMinZ() - (double)f; + } + + if (par4 == 3) + { + d2 = (double)par3 + block.getBlockBoundsMaxZ() + (double)f; + } + + if (par4 == 4) + { + d0 = (double)par1 + block.getBlockBoundsMinX() - (double)f; + } + + if (par4 == 5) + { + d0 = (double)par1 + block.getBlockBoundsMaxX() + (double)f; + } + + this.addEffect((new EntityDiggingFX(this.worldObj, d0, d1, d2, 0.0D, 0.0D, 0.0D, block, this.worldObj.getBlockMetadata(par1, par2, par3))).applyColourMultiplier(par1, par2, par3).multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F)); + } + } + + public String getStatistics() + { + return "" + (this.fxLayers[0].size() + this.fxLayers[1].size() + this.fxLayers[2].size()); + } + + public void addBlockHitEffects(int x, int y, int z, MovingObjectPosition target) + { + Block block = worldObj.getBlock(x, y, z); + if (block != null && !block.addHitEffects(worldObj, target, this)) + { + addBlockHitEffects(x, y, z, target.sideHit); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/particle/EntityAuraFX.java b/src/main/java/net/minecraft/client/particle/EntityAuraFX.java new file mode 100644 index 0000000..3b199f0 --- /dev/null +++ b/src/main/java/net/minecraft/client/particle/EntityAuraFX.java @@ -0,0 +1,44 @@ +package net.minecraft.client.particle; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.world.World; + +@SideOnly(Side.CLIENT) +public class EntityAuraFX extends EntityFX +{ + private static final String __OBFID = "CL_00000929"; + + public EntityAuraFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12) + { + super(par1World, par2, par4, par6, par8, par10, par12); + float f = this.rand.nextFloat() * 0.1F + 0.2F; + this.particleRed = f; + this.particleGreen = f; + this.particleBlue = f; + this.setParticleTextureIndex(0); + this.setSize(0.02F, 0.02F); + this.particleScale *= this.rand.nextFloat() * 0.6F + 0.5F; + this.motionX *= 0.019999999552965164D; + this.motionY *= 0.019999999552965164D; + this.motionZ *= 0.019999999552965164D; + this.particleMaxAge = (int)(20.0D / (Math.random() * 0.8D + 0.2D)); + this.noClip = true; + } + + public void onUpdate() + { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.99D; + this.motionY *= 0.99D; + this.motionZ *= 0.99D; + + if (this.particleMaxAge-- <= 0) + { + this.setDead(); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/particle/EntityBlockDustFX.java b/src/main/java/net/minecraft/client/particle/EntityBlockDustFX.java new file mode 100644 index 0000000..5316c68 --- /dev/null +++ b/src/main/java/net/minecraft/client/particle/EntityBlockDustFX.java @@ -0,0 +1,20 @@ +package net.minecraft.client.particle; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.world.World; + +@SideOnly(Side.CLIENT) +public class EntityBlockDustFX extends EntityDiggingFX +{ + private static final String __OBFID = "CL_00000931"; + + public EntityBlockDustFX(World p_i45072_1_, double p_i45072_2_, double p_i45072_4_, double p_i45072_6_, double p_i45072_8_, double p_i45072_10_, double p_i45072_12_, Block p_i45072_14_, int p_i45072_15_) + { + super(p_i45072_1_, p_i45072_2_, p_i45072_4_, p_i45072_6_, p_i45072_8_, p_i45072_10_, p_i45072_12_, p_i45072_14_, p_i45072_15_); + this.motionX = p_i45072_8_; + this.motionY = p_i45072_10_; + this.motionZ = p_i45072_12_; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/particle/EntityBreakingFX.java b/src/main/java/net/minecraft/client/particle/EntityBreakingFX.java new file mode 100644 index 0000000..50807dd --- /dev/null +++ b/src/main/java/net/minecraft/client/particle/EntityBreakingFX.java @@ -0,0 +1,70 @@ +package net.minecraft.client.particle; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.world.World; + +@SideOnly(Side.CLIENT) +public class EntityBreakingFX extends EntityFX +{ + private static final String __OBFID = "CL_00000897"; + + public EntityBreakingFX(World par1World, double par2, double par4, double par6, Item par8Item) + { + this(par1World, par2, par4, par6, par8Item, 0); + } + + public EntityBreakingFX(World par1World, double par2, double par4, double par6, Item par8Item, int par9) + { + super(par1World, par2, par4, par6, 0.0D, 0.0D, 0.0D); + this.setParticleIcon(par8Item.getIconFromDamage(par9)); + this.particleRed = this.particleGreen = this.particleBlue = 1.0F; + this.particleGravity = Blocks.snow.blockParticleGravity; + this.particleScale /= 2.0F; + } + + public EntityBreakingFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12, Item par14Item, int par15) + { + this(par1World, par2, par4, par6, par14Item, par15); + this.motionX *= 0.10000000149011612D; + this.motionY *= 0.10000000149011612D; + this.motionZ *= 0.10000000149011612D; + this.motionX += par8; + this.motionY += par10; + this.motionZ += par12; + } + + public int getFXLayer() + { + return 2; + } + + public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) + { + float f6 = ((float)this.particleTextureIndexX + this.particleTextureJitterX / 4.0F) / 16.0F; + float f7 = f6 + 0.015609375F; + float f8 = ((float)this.particleTextureIndexY + this.particleTextureJitterY / 4.0F) / 16.0F; + float f9 = f8 + 0.015609375F; + float f10 = 0.1F * this.particleScale; + + if (this.particleIcon != null) + { + f6 = this.particleIcon.getInterpolatedU((double)(this.particleTextureJitterX / 4.0F * 16.0F)); + f7 = this.particleIcon.getInterpolatedU((double)((this.particleTextureJitterX + 1.0F) / 4.0F * 16.0F)); + f8 = this.particleIcon.getInterpolatedV((double)(this.particleTextureJitterY / 4.0F * 16.0F)); + f9 = this.particleIcon.getInterpolatedV((double)((this.particleTextureJitterY + 1.0F) / 4.0F * 16.0F)); + } + + float f11 = (float)(this.prevPosX + (this.posX - this.prevPosX) * (double)par2 - interpPosX); + float f12 = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)par2 - interpPosY); + float f13 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)par2 - interpPosZ); + par1Tessellator.setColorOpaque_F(this.particleRed, this.particleGreen, this.particleBlue); + par1Tessellator.addVertexWithUV((double)(f11 - par3 * f10 - par6 * f10), (double)(f12 - par4 * f10), (double)(f13 - par5 * f10 - par7 * f10), (double)f6, (double)f9); + par1Tessellator.addVertexWithUV((double)(f11 - par3 * f10 + par6 * f10), (double)(f12 + par4 * f10), (double)(f13 - par5 * f10 + par7 * f10), (double)f6, (double)f8); + par1Tessellator.addVertexWithUV((double)(f11 + par3 * f10 + par6 * f10), (double)(f12 + par4 * f10), (double)(f13 + par5 * f10 + par7 * f10), (double)f7, (double)f8); + par1Tessellator.addVertexWithUV((double)(f11 + par3 * f10 - par6 * f10), (double)(f12 - par4 * f10), (double)(f13 + par5 * f10 - par7 * f10), (double)f7, (double)f9); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/particle/EntityBubbleFX.java b/src/main/java/net/minecraft/client/particle/EntityBubbleFX.java new file mode 100644 index 0000000..78bd461 --- /dev/null +++ b/src/main/java/net/minecraft/client/particle/EntityBubbleFX.java @@ -0,0 +1,50 @@ +package net.minecraft.client.particle; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.material.Material; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +@SideOnly(Side.CLIENT) +public class EntityBubbleFX extends EntityFX +{ + private static final String __OBFID = "CL_00000898"; + + public EntityBubbleFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12) + { + super(par1World, par2, par4, par6, par8, par10, par12); + this.particleRed = 1.0F; + this.particleGreen = 1.0F; + this.particleBlue = 1.0F; + this.setParticleTextureIndex(32); + this.setSize(0.02F, 0.02F); + this.particleScale *= this.rand.nextFloat() * 0.6F + 0.2F; + this.motionX = par8 * 0.20000000298023224D + (double)((float)(Math.random() * 2.0D - 1.0D) * 0.02F); + this.motionY = par10 * 0.20000000298023224D + (double)((float)(Math.random() * 2.0D - 1.0D) * 0.02F); + this.motionZ = par12 * 0.20000000298023224D + (double)((float)(Math.random() * 2.0D - 1.0D) * 0.02F); + this.particleMaxAge = (int)(8.0D / (Math.random() * 0.8D + 0.2D)); + } + + public void onUpdate() + { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + this.motionY += 0.002D; + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.8500000238418579D; + this.motionY *= 0.8500000238418579D; + this.motionZ *= 0.8500000238418579D; + + if (this.worldObj.getBlock(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)).getMaterial() != Material.water) + { + this.setDead(); + } + + if (this.particleMaxAge-- <= 0) + { + this.setDead(); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/particle/EntityCloudFX.java b/src/main/java/net/minecraft/client/particle/EntityCloudFX.java new file mode 100644 index 0000000..6da386c --- /dev/null +++ b/src/main/java/net/minecraft/client/particle/EntityCloudFX.java @@ -0,0 +1,83 @@ +package net.minecraft.client.particle; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; + +@SideOnly(Side.CLIENT) +public class EntityCloudFX extends EntityFX +{ + float field_70569_a; + private static final String __OBFID = "CL_00000920"; + + public EntityCloudFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12) + { + super(par1World, par2, par4, par6, 0.0D, 0.0D, 0.0D); + float f = 2.5F; + this.motionX *= 0.10000000149011612D; + this.motionY *= 0.10000000149011612D; + this.motionZ *= 0.10000000149011612D; + this.motionX += par8; + this.motionY += par10; + this.motionZ += par12; + this.particleRed = this.particleGreen = this.particleBlue = 1.0F - (float)(Math.random() * 0.30000001192092896D); + this.particleScale *= 0.75F; + this.particleScale *= f; + this.field_70569_a = this.particleScale; + this.particleMaxAge = (int)(8.0D / (Math.random() * 0.8D + 0.3D)); + this.particleMaxAge = (int)((float)this.particleMaxAge * f); + this.noClip = false; + } + + public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) + { + float f6 = ((float)this.particleAge + par2) / (float)this.particleMaxAge * 32.0F; + + if (f6 < 0.0F) + { + f6 = 0.0F; + } + + if (f6 > 1.0F) + { + f6 = 1.0F; + } + + this.particleScale = this.field_70569_a * f6; + super.renderParticle(par1Tessellator, par2, par3, par4, par5, par6, par7); + } + + public void onUpdate() + { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + + if (this.particleAge++ >= this.particleMaxAge) + { + this.setDead(); + } + + this.setParticleTextureIndex(7 - this.particleAge * 8 / this.particleMaxAge); + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.9599999785423279D; + this.motionY *= 0.9599999785423279D; + this.motionZ *= 0.9599999785423279D; + EntityPlayer entityplayer = this.worldObj.getClosestPlayerToEntity(this, 2.0D); + + if (entityplayer != null && this.posY > entityplayer.boundingBox.minY) + { + this.posY += (entityplayer.boundingBox.minY - this.posY) * 0.2D; + this.motionY += (entityplayer.motionY - this.motionY) * 0.2D; + this.setPosition(this.posX, this.posY, this.posZ); + } + + if (this.onGround) + { + this.motionX *= 0.699999988079071D; + this.motionZ *= 0.699999988079071D; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/particle/EntityCrit2FX.java b/src/main/java/net/minecraft/client/particle/EntityCrit2FX.java new file mode 100644 index 0000000..f382aa7 --- /dev/null +++ b/src/main/java/net/minecraft/client/particle/EntityCrit2FX.java @@ -0,0 +1,63 @@ +package net.minecraft.client.particle; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.entity.Entity; +import net.minecraft.world.World; + +@SideOnly(Side.CLIENT) +public class EntityCrit2FX extends EntityFX +{ + private Entity theEntity; + private int currentLife; + private int maximumLife; + private String particleName; + private static final String __OBFID = "CL_00000899"; + + public EntityCrit2FX(World par1World, Entity par2Entity) + { + this(par1World, par2Entity, "crit"); + } + + public EntityCrit2FX(World par1World, Entity par2Entity, String par3Str) + { + super(par1World, par2Entity.posX, par2Entity.boundingBox.minY + (double)(par2Entity.height / 2.0F), par2Entity.posZ, par2Entity.motionX, par2Entity.motionY, par2Entity.motionZ); + this.theEntity = par2Entity; + this.maximumLife = 3; + this.particleName = par3Str; + this.onUpdate(); + } + + public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) {} + + public void onUpdate() + { + for (int i = 0; i < 16; ++i) + { + double d0 = (double)(this.rand.nextFloat() * 2.0F - 1.0F); + double d1 = (double)(this.rand.nextFloat() * 2.0F - 1.0F); + double d2 = (double)(this.rand.nextFloat() * 2.0F - 1.0F); + + if (d0 * d0 + d1 * d1 + d2 * d2 <= 1.0D) + { + double d3 = this.theEntity.posX + d0 * (double)this.theEntity.width / 4.0D; + double d4 = this.theEntity.boundingBox.minY + (double)(this.theEntity.height / 2.0F) + d1 * (double)this.theEntity.height / 4.0D; + double d5 = this.theEntity.posZ + d2 * (double)this.theEntity.width / 4.0D; + this.worldObj.spawnParticle(this.particleName, d3, d4, d5, d0, d1 + 0.2D, d2); + } + } + + ++this.currentLife; + + if (this.currentLife >= this.maximumLife) + { + this.setDead(); + } + } + + public int getFXLayer() + { + return 3; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/particle/EntityCritFX.java b/src/main/java/net/minecraft/client/particle/EntityCritFX.java new file mode 100644 index 0000000..a83fce0 --- /dev/null +++ b/src/main/java/net/minecraft/client/particle/EntityCritFX.java @@ -0,0 +1,82 @@ +package net.minecraft.client.particle; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.world.World; + +@SideOnly(Side.CLIENT) +public class EntityCritFX extends EntityFX +{ + float initialParticleScale; + private static final String __OBFID = "CL_00000900"; + + public EntityCritFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12) + { + this(par1World, par2, par4, par6, par8, par10, par12, 1.0F); + } + + public EntityCritFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12, float par14) + { + super(par1World, par2, par4, par6, 0.0D, 0.0D, 0.0D); + this.motionX *= 0.10000000149011612D; + this.motionY *= 0.10000000149011612D; + this.motionZ *= 0.10000000149011612D; + this.motionX += par8 * 0.4D; + this.motionY += par10 * 0.4D; + this.motionZ += par12 * 0.4D; + this.particleRed = this.particleGreen = this.particleBlue = (float)(Math.random() * 0.30000001192092896D + 0.6000000238418579D); + this.particleScale *= 0.75F; + this.particleScale *= par14; + this.initialParticleScale = this.particleScale; + this.particleMaxAge = (int)(6.0D / (Math.random() * 0.8D + 0.6D)); + this.particleMaxAge = (int)((float)this.particleMaxAge * par14); + this.noClip = false; + this.setParticleTextureIndex(65); + this.onUpdate(); + } + + public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) + { + float f6 = ((float)this.particleAge + par2) / (float)this.particleMaxAge * 32.0F; + + if (f6 < 0.0F) + { + f6 = 0.0F; + } + + if (f6 > 1.0F) + { + f6 = 1.0F; + } + + this.particleScale = this.initialParticleScale * f6; + super.renderParticle(par1Tessellator, par2, par3, par4, par5, par6, par7); + } + + public void onUpdate() + { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + + if (this.particleAge++ >= this.particleMaxAge) + { + this.setDead(); + } + + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.particleGreen = (float)((double)this.particleGreen * 0.96D); + this.particleBlue = (float)((double)this.particleBlue * 0.9D); + this.motionX *= 0.699999988079071D; + this.motionY *= 0.699999988079071D; + this.motionZ *= 0.699999988079071D; + this.motionY -= 0.019999999552965164D; + + if (this.onGround) + { + this.motionX *= 0.699999988079071D; + this.motionZ *= 0.699999988079071D; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/particle/EntityDiggingFX.java b/src/main/java/net/minecraft/client/particle/EntityDiggingFX.java new file mode 100644 index 0000000..0522a0c --- /dev/null +++ b/src/main/java/net/minecraft/client/particle/EntityDiggingFX.java @@ -0,0 +1,95 @@ +package net.minecraft.client.particle; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; + +@SideOnly(Side.CLIENT) +public class EntityDiggingFX extends EntityFX +{ + private Block field_145784_a; + private static final String __OBFID = "CL_00000932"; + private int side; + + public EntityDiggingFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12, Block par14Block, int par15) + { + this(par1World, par2, par4, par6, par8, par10, par12, par14Block, par15, par1World.rand.nextInt(6)); + } + + public EntityDiggingFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12, Block par14Block, int par15, int side) + { + super(par1World, par2, par4, par6, par8, par10, par12); + this.field_145784_a = par14Block; + this.setParticleIcon(par14Block.getIcon(side, par15)); + this.particleGravity = par14Block.blockParticleGravity; + this.particleRed = this.particleGreen = this.particleBlue = 0.6F; + this.particleScale /= 2.0F; + this.side = side; + } + + public EntityDiggingFX applyColourMultiplier(int par1, int par2, int par3) + { + if (this.field_145784_a == Blocks.grass && this.side != 1) + { + return this; + } + else + { + int l = this.field_145784_a.colorMultiplier(this.worldObj, par1, par2, par3); + this.particleRed *= (float)(l >> 16 & 255) / 255.0F; + this.particleGreen *= (float)(l >> 8 & 255) / 255.0F; + this.particleBlue *= (float)(l & 255) / 255.0F; + return this; + } + } + + public EntityDiggingFX applyRenderColor(int par1) + { + if (this.field_145784_a == Blocks.grass) + { + return this; + } + else + { + int j = this.field_145784_a.getRenderColor(par1); + this.particleRed *= (float)(j >> 16 & 255) / 255.0F; + this.particleGreen *= (float)(j >> 8 & 255) / 255.0F; + this.particleBlue *= (float)(j & 255) / 255.0F; + return this; + } + } + + public int getFXLayer() + { + return 1; + } + + public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) + { + float f6 = ((float)this.particleTextureIndexX + this.particleTextureJitterX / 4.0F) / 16.0F; + float f7 = f6 + 0.015609375F; + float f8 = ((float)this.particleTextureIndexY + this.particleTextureJitterY / 4.0F) / 16.0F; + float f9 = f8 + 0.015609375F; + float f10 = 0.1F * this.particleScale; + + if (this.particleIcon != null) + { + f6 = this.particleIcon.getInterpolatedU((double)(this.particleTextureJitterX / 4.0F * 16.0F)); + f7 = this.particleIcon.getInterpolatedU((double)((this.particleTextureJitterX + 1.0F) / 4.0F * 16.0F)); + f8 = this.particleIcon.getInterpolatedV((double)(this.particleTextureJitterY / 4.0F * 16.0F)); + f9 = this.particleIcon.getInterpolatedV((double)((this.particleTextureJitterY + 1.0F) / 4.0F * 16.0F)); + } + + float f11 = (float)(this.prevPosX + (this.posX - this.prevPosX) * (double)par2 - interpPosX); + float f12 = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)par2 - interpPosY); + float f13 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)par2 - interpPosZ); + par1Tessellator.setColorOpaque_F(this.particleRed, this.particleGreen, this.particleBlue); + par1Tessellator.addVertexWithUV((double)(f11 - par3 * f10 - par6 * f10), (double)(f12 - par4 * f10), (double)(f13 - par5 * f10 - par7 * f10), (double)f6, (double)f9); + par1Tessellator.addVertexWithUV((double)(f11 - par3 * f10 + par6 * f10), (double)(f12 + par4 * f10), (double)(f13 - par5 * f10 + par7 * f10), (double)f6, (double)f8); + par1Tessellator.addVertexWithUV((double)(f11 + par3 * f10 + par6 * f10), (double)(f12 + par4 * f10), (double)(f13 + par5 * f10 + par7 * f10), (double)f7, (double)f8); + par1Tessellator.addVertexWithUV((double)(f11 + par3 * f10 - par6 * f10), (double)(f12 - par4 * f10), (double)(f13 + par5 * f10 - par7 * f10), (double)f7, (double)f9); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/particle/EntityDropParticleFX.java b/src/main/java/net/minecraft/client/particle/EntityDropParticleFX.java new file mode 100644 index 0000000..ed4ea46 --- /dev/null +++ b/src/main/java/net/minecraft/client/particle/EntityDropParticleFX.java @@ -0,0 +1,125 @@ +package net.minecraft.client.particle; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.BlockLiquid; +import net.minecraft.block.material.Material; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +@SideOnly(Side.CLIENT) +public class EntityDropParticleFX extends EntityFX +{ + private Material materialType; + private int bobTimer; + private static final String __OBFID = "CL_00000901"; + + public EntityDropParticleFX(World par1World, double par2, double par4, double par6, Material par8Material) + { + super(par1World, par2, par4, par6, 0.0D, 0.0D, 0.0D); + this.motionX = this.motionY = this.motionZ = 0.0D; + + if (par8Material == Material.water) + { + this.particleRed = 0.0F; + this.particleGreen = 0.0F; + this.particleBlue = 1.0F; + } + else + { + this.particleRed = 1.0F; + this.particleGreen = 0.0F; + this.particleBlue = 0.0F; + } + + this.setParticleTextureIndex(113); + this.setSize(0.01F, 0.01F); + this.particleGravity = 0.06F; + this.materialType = par8Material; + this.bobTimer = 40; + this.particleMaxAge = (int)(64.0D / (Math.random() * 0.8D + 0.2D)); + this.motionX = this.motionY = this.motionZ = 0.0D; + } + + public int getBrightnessForRender(float par1) + { + return this.materialType == Material.water ? super.getBrightnessForRender(par1) : 257; + } + + public float getBrightness(float par1) + { + return this.materialType == Material.water ? super.getBrightness(par1) : 1.0F; + } + + public void onUpdate() + { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + + if (this.materialType == Material.water) + { + this.particleRed = 0.2F; + this.particleGreen = 0.3F; + this.particleBlue = 1.0F; + } + else + { + this.particleRed = 1.0F; + this.particleGreen = 16.0F / (float)(40 - this.bobTimer + 16); + this.particleBlue = 4.0F / (float)(40 - this.bobTimer + 8); + } + + this.motionY -= (double)this.particleGravity; + + if (this.bobTimer-- > 0) + { + this.motionX *= 0.02D; + this.motionY *= 0.02D; + this.motionZ *= 0.02D; + this.setParticleTextureIndex(113); + } + else + { + this.setParticleTextureIndex(112); + } + + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.9800000190734863D; + this.motionY *= 0.9800000190734863D; + this.motionZ *= 0.9800000190734863D; + + if (this.particleMaxAge-- <= 0) + { + this.setDead(); + } + + if (this.onGround) + { + if (this.materialType == Material.water) + { + this.setDead(); + this.worldObj.spawnParticle("splash", this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D); + } + else + { + this.setParticleTextureIndex(114); + } + + this.motionX *= 0.699999988079071D; + this.motionZ *= 0.699999988079071D; + } + + Material material = this.worldObj.getBlock(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)).getMaterial(); + + if (material.isLiquid() || material.isSolid()) + { + double d0 = (double)((float)(MathHelper.floor_double(this.posY) + 1) - BlockLiquid.getLiquidHeightPercent(this.worldObj.getBlockMetadata(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)))); + + if (this.posY < d0) + { + this.setDead(); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/particle/EntityEnchantmentTableParticleFX.java b/src/main/java/net/minecraft/client/particle/EntityEnchantmentTableParticleFX.java new file mode 100644 index 0000000..1a7428d --- /dev/null +++ b/src/main/java/net/minecraft/client/particle/EntityEnchantmentTableParticleFX.java @@ -0,0 +1,81 @@ +package net.minecraft.client.particle; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.world.World; + +@SideOnly(Side.CLIENT) +public class EntityEnchantmentTableParticleFX extends EntityFX +{ + private float field_70565_a; + private double field_70568_aq; + private double field_70567_ar; + private double field_70566_as; + private static final String __OBFID = "CL_00000902"; + + public EntityEnchantmentTableParticleFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12) + { + super(par1World, par2, par4, par6, par8, par10, par12); + this.motionX = par8; + this.motionY = par10; + this.motionZ = par12; + this.field_70568_aq = this.posX = par2; + this.field_70567_ar = this.posY = par4; + this.field_70566_as = this.posZ = par6; + float f = this.rand.nextFloat() * 0.6F + 0.4F; + this.field_70565_a = this.particleScale = this.rand.nextFloat() * 0.5F + 0.2F; + this.particleRed = this.particleGreen = this.particleBlue = 1.0F * f; + this.particleGreen *= 0.9F; + this.particleRed *= 0.9F; + this.particleMaxAge = (int)(Math.random() * 10.0D) + 30; + this.noClip = true; + this.setParticleTextureIndex((int)(Math.random() * 26.0D + 1.0D + 224.0D)); + } + + public int getBrightnessForRender(float par1) + { + int i = super.getBrightnessForRender(par1); + float f1 = (float)this.particleAge / (float)this.particleMaxAge; + f1 *= f1; + f1 *= f1; + int j = i & 255; + int k = i >> 16 & 255; + k += (int)(f1 * 15.0F * 16.0F); + + if (k > 240) + { + k = 240; + } + + return j | k << 16; + } + + public float getBrightness(float par1) + { + float f1 = super.getBrightness(par1); + float f2 = (float)this.particleAge / (float)this.particleMaxAge; + f2 *= f2; + f2 *= f2; + return f1 * (1.0F - f2) + f2; + } + + public void onUpdate() + { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + float f = (float)this.particleAge / (float)this.particleMaxAge; + f = 1.0F - f; + float f1 = 1.0F - f; + f1 *= f1; + f1 *= f1; + this.posX = this.field_70568_aq + this.motionX * (double)f; + this.posY = this.field_70567_ar + this.motionY * (double)f - (double)(f1 * 1.2F); + this.posZ = this.field_70566_as + this.motionZ * (double)f; + + if (this.particleAge++ >= this.particleMaxAge) + { + this.setDead(); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/particle/EntityExplodeFX.java b/src/main/java/net/minecraft/client/particle/EntityExplodeFX.java new file mode 100644 index 0000000..73d6bbf --- /dev/null +++ b/src/main/java/net/minecraft/client/particle/EntityExplodeFX.java @@ -0,0 +1,47 @@ +package net.minecraft.client.particle; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.world.World; + +@SideOnly(Side.CLIENT) +public class EntityExplodeFX extends EntityFX +{ + private static final String __OBFID = "CL_00000903"; + + public EntityExplodeFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12) + { + super(par1World, par2, par4, par6, par8, par10, par12); + this.motionX = par8 + (double)((float)(Math.random() * 2.0D - 1.0D) * 0.05F); + this.motionY = par10 + (double)((float)(Math.random() * 2.0D - 1.0D) * 0.05F); + this.motionZ = par12 + (double)((float)(Math.random() * 2.0D - 1.0D) * 0.05F); + this.particleRed = this.particleGreen = this.particleBlue = this.rand.nextFloat() * 0.3F + 0.7F; + this.particleScale = this.rand.nextFloat() * this.rand.nextFloat() * 6.0F + 1.0F; + this.particleMaxAge = (int)(16.0D / ((double)this.rand.nextFloat() * 0.8D + 0.2D)) + 2; + } + + public void onUpdate() + { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + + if (this.particleAge++ >= this.particleMaxAge) + { + this.setDead(); + } + + this.setParticleTextureIndex(7 - this.particleAge * 8 / this.particleMaxAge); + this.motionY += 0.004D; + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.8999999761581421D; + this.motionY *= 0.8999999761581421D; + this.motionZ *= 0.8999999761581421D; + + if (this.onGround) + { + this.motionX *= 0.699999988079071D; + this.motionZ *= 0.699999988079071D; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/particle/EntityFX.java b/src/main/java/net/minecraft/client/particle/EntityFX.java new file mode 100644 index 0000000..f0b5d0f --- /dev/null +++ b/src/main/java/net/minecraft/client/particle/EntityFX.java @@ -0,0 +1,216 @@ +package net.minecraft.client.particle; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.entity.Entity; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +@SideOnly(Side.CLIENT) +public class EntityFX extends Entity +{ + protected int particleTextureIndexX; + protected int particleTextureIndexY; + protected float particleTextureJitterX; + protected float particleTextureJitterY; + protected int particleAge; + protected int particleMaxAge; + protected float particleScale; + protected float particleGravity; + protected float particleRed; + protected float particleGreen; + protected float particleBlue; + protected float particleAlpha; + protected IIcon particleIcon; + public static double interpPosX; + public static double interpPosY; + public static double interpPosZ; + private static final String __OBFID = "CL_00000914"; + + protected EntityFX(World par1World, double par2, double par4, double par6) + { + super(par1World); + this.particleAlpha = 1.0F; + this.setSize(0.2F, 0.2F); + this.yOffset = this.height / 2.0F; + this.setPosition(par2, par4, par6); + this.lastTickPosX = par2; + this.lastTickPosY = par4; + this.lastTickPosZ = par6; + this.particleRed = this.particleGreen = this.particleBlue = 1.0F; + this.particleTextureJitterX = this.rand.nextFloat() * 3.0F; + this.particleTextureJitterY = this.rand.nextFloat() * 3.0F; + this.particleScale = (this.rand.nextFloat() * 0.5F + 0.5F) * 2.0F; + this.particleMaxAge = (int)(4.0F / (this.rand.nextFloat() * 0.9F + 0.1F)); + this.particleAge = 0; + } + + public EntityFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12) + { + this(par1World, par2, par4, par6); + this.motionX = par8 + (double)((float)(Math.random() * 2.0D - 1.0D) * 0.4F); + this.motionY = par10 + (double)((float)(Math.random() * 2.0D - 1.0D) * 0.4F); + this.motionZ = par12 + (double)((float)(Math.random() * 2.0D - 1.0D) * 0.4F); + float f = (float)(Math.random() + Math.random() + 1.0D) * 0.15F; + float f1 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); + this.motionX = this.motionX / (double)f1 * (double)f * 0.4000000059604645D; + this.motionY = this.motionY / (double)f1 * (double)f * 0.4000000059604645D + 0.10000000149011612D; + this.motionZ = this.motionZ / (double)f1 * (double)f * 0.4000000059604645D; + } + + public EntityFX multiplyVelocity(float par1) + { + this.motionX *= (double)par1; + this.motionY = (this.motionY - 0.10000000149011612D) * (double)par1 + 0.10000000149011612D; + this.motionZ *= (double)par1; + return this; + } + + public EntityFX multipleParticleScaleBy(float par1) + { + this.setSize(0.2F * par1, 0.2F * par1); + this.particleScale *= par1; + return this; + } + + public void setRBGColorF(float par1, float par2, float par3) + { + this.particleRed = par1; + this.particleGreen = par2; + this.particleBlue = par3; + } + + public void setAlphaF(float par1) + { + this.particleAlpha = par1; + } + + public float getRedColorF() + { + return this.particleRed; + } + + public float getGreenColorF() + { + return this.particleGreen; + } + + public float getBlueColorF() + { + return this.particleBlue; + } + + protected boolean canTriggerWalking() + { + return false; + } + + protected void entityInit() {} + + public void onUpdate() + { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + + if (this.particleAge++ >= this.particleMaxAge) + { + this.setDead(); + } + + this.motionY -= 0.04D * (double)this.particleGravity; + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.9800000190734863D; + this.motionY *= 0.9800000190734863D; + this.motionZ *= 0.9800000190734863D; + + if (this.onGround) + { + this.motionX *= 0.699999988079071D; + this.motionZ *= 0.699999988079071D; + } + } + + public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) + { + float f6 = (float)this.particleTextureIndexX / 16.0F; + float f7 = f6 + 0.0624375F; + float f8 = (float)this.particleTextureIndexY / 16.0F; + float f9 = f8 + 0.0624375F; + float f10 = 0.1F * this.particleScale; + + if (this.particleIcon != null) + { + f6 = this.particleIcon.getMinU(); + f7 = this.particleIcon.getMaxU(); + f8 = this.particleIcon.getMinV(); + f9 = this.particleIcon.getMaxV(); + } + + float f11 = (float)(this.prevPosX + (this.posX - this.prevPosX) * (double)par2 - interpPosX); + float f12 = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)par2 - interpPosY); + float f13 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)par2 - interpPosZ); + par1Tessellator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha); + par1Tessellator.addVertexWithUV((double)(f11 - par3 * f10 - par6 * f10), (double)(f12 - par4 * f10), (double)(f13 - par5 * f10 - par7 * f10), (double)f7, (double)f9); + par1Tessellator.addVertexWithUV((double)(f11 - par3 * f10 + par6 * f10), (double)(f12 + par4 * f10), (double)(f13 - par5 * f10 + par7 * f10), (double)f7, (double)f8); + par1Tessellator.addVertexWithUV((double)(f11 + par3 * f10 + par6 * f10), (double)(f12 + par4 * f10), (double)(f13 + par5 * f10 + par7 * f10), (double)f6, (double)f8); + par1Tessellator.addVertexWithUV((double)(f11 + par3 * f10 - par6 * f10), (double)(f12 - par4 * f10), (double)(f13 + par5 * f10 - par7 * f10), (double)f6, (double)f9); + } + + public int getFXLayer() + { + return 0; + } + + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) {} + + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {} + + public void setParticleIcon(IIcon par1Icon) + { + if (this.getFXLayer() == 1) + { + this.particleIcon = par1Icon; + } + else + { + if (this.getFXLayer() != 2) + { + throw new RuntimeException("Invalid call to Particle.setTex, use coordinate methods"); + } + + this.particleIcon = par1Icon; + } + } + + public void setParticleTextureIndex(int par1) + { + if (this.getFXLayer() != 0) + { + throw new RuntimeException("Invalid call to Particle.setMiscTex"); + } + else + { + this.particleTextureIndexX = par1 % 16; + this.particleTextureIndexY = par1 / 16; + } + } + + public void nextTextureIndexX() + { + ++this.particleTextureIndexX; + } + + public boolean canAttackWithItem() + { + return false; + } + + public String toString() + { + return this.getClass().getSimpleName() + ", Pos (" + this.posX + "," + this.posY + "," + this.posZ + "), RGBA (" + this.particleRed + "," + this.particleGreen + "," + this.particleBlue + "," + this.particleAlpha + "), Age " + this.particleAge; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/particle/EntityFireworkOverlayFX.java b/src/main/java/net/minecraft/client/particle/EntityFireworkOverlayFX.java new file mode 100644 index 0000000..df0c3ee --- /dev/null +++ b/src/main/java/net/minecraft/client/particle/EntityFireworkOverlayFX.java @@ -0,0 +1,37 @@ +package net.minecraft.client.particle; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +@SideOnly(Side.CLIENT) +public class EntityFireworkOverlayFX extends EntityFX +{ + private static final String __OBFID = "CL_00000904"; + + protected EntityFireworkOverlayFX(World par1World, double par2, double par4, double par6) + { + super(par1World, par2, par4, par6); + this.particleMaxAge = 4; + } + + public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) + { + float f6 = 0.25F; + float f7 = f6 + 0.25F; + float f8 = 0.125F; + float f9 = f8 + 0.25F; + float f10 = 7.1F * MathHelper.sin(((float)this.particleAge + par2 - 1.0F) * 0.25F * (float)Math.PI); + this.particleAlpha = 0.6F - ((float)this.particleAge + par2 - 1.0F) * 0.25F * 0.5F; + float f11 = (float)(this.prevPosX + (this.posX - this.prevPosX) * (double)par2 - interpPosX); + float f12 = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)par2 - interpPosY); + float f13 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)par2 - interpPosZ); + par1Tessellator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha); + par1Tessellator.addVertexWithUV((double)(f11 - par3 * f10 - par6 * f10), (double)(f12 - par4 * f10), (double)(f13 - par5 * f10 - par7 * f10), (double)f7, (double)f9); + par1Tessellator.addVertexWithUV((double)(f11 - par3 * f10 + par6 * f10), (double)(f12 + par4 * f10), (double)(f13 - par5 * f10 + par7 * f10), (double)f7, (double)f8); + par1Tessellator.addVertexWithUV((double)(f11 + par3 * f10 + par6 * f10), (double)(f12 + par4 * f10), (double)(f13 + par5 * f10 + par7 * f10), (double)f6, (double)f8); + par1Tessellator.addVertexWithUV((double)(f11 + par3 * f10 - par6 * f10), (double)(f12 - par4 * f10), (double)(f13 + par5 * f10 - par7 * f10), (double)f6, (double)f9); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/particle/EntityFireworkSparkFX.java b/src/main/java/net/minecraft/client/particle/EntityFireworkSparkFX.java new file mode 100644 index 0000000..c2be039 --- /dev/null +++ b/src/main/java/net/minecraft/client/particle/EntityFireworkSparkFX.java @@ -0,0 +1,143 @@ +package net.minecraft.client.particle; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; + +@SideOnly(Side.CLIENT) +public class EntityFireworkSparkFX extends EntityFX +{ + private int baseTextureIndex = 160; + private boolean field_92054_ax; + private boolean field_92048_ay; + private final EffectRenderer field_92047_az; + private float fadeColourRed; + private float fadeColourGreen; + private float fadeColourBlue; + private boolean hasFadeColour; + private static final String __OBFID = "CL_00000905"; + + public EntityFireworkSparkFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12, EffectRenderer par14EffectRenderer) + { + super(par1World, par2, par4, par6); + this.motionX = par8; + this.motionY = par10; + this.motionZ = par12; + this.field_92047_az = par14EffectRenderer; + this.particleScale *= 0.75F; + this.particleMaxAge = 48 + this.rand.nextInt(12); + this.noClip = false; + } + + public void setTrail(boolean par1) + { + this.field_92054_ax = par1; + } + + public void setTwinkle(boolean par1) + { + this.field_92048_ay = par1; + } + + public void setColour(int par1) + { + float f = (float)((par1 & 16711680) >> 16) / 255.0F; + float f1 = (float)((par1 & 65280) >> 8) / 255.0F; + float f2 = (float)((par1 & 255) >> 0) / 255.0F; + float f3 = 1.0F; + this.setRBGColorF(f * f3, f1 * f3, f2 * f3); + } + + public void setFadeColour(int par1) + { + this.fadeColourRed = (float)((par1 & 16711680) >> 16) / 255.0F; + this.fadeColourGreen = (float)((par1 & 65280) >> 8) / 255.0F; + this.fadeColourBlue = (float)((par1 & 255) >> 0) / 255.0F; + this.hasFadeColour = true; + } + + public AxisAlignedBB getBoundingBox() + { + return null; + } + + public boolean canBePushed() + { + return false; + } + + public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) + { + if (!this.field_92048_ay || this.particleAge < this.particleMaxAge / 3 || (this.particleAge + this.particleMaxAge) / 3 % 2 == 0) + { + super.renderParticle(par1Tessellator, par2, par3, par4, par5, par6, par7); + } + } + + public void onUpdate() + { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + + if (this.particleAge++ >= this.particleMaxAge) + { + this.setDead(); + } + + if (this.particleAge > this.particleMaxAge / 2) + { + this.setAlphaF(1.0F - ((float)this.particleAge - (float)(this.particleMaxAge / 2)) / (float)this.particleMaxAge); + + if (this.hasFadeColour) + { + this.particleRed += (this.fadeColourRed - this.particleRed) * 0.2F; + this.particleGreen += (this.fadeColourGreen - this.particleGreen) * 0.2F; + this.particleBlue += (this.fadeColourBlue - this.particleBlue) * 0.2F; + } + } + + this.setParticleTextureIndex(this.baseTextureIndex + (7 - this.particleAge * 8 / this.particleMaxAge)); + this.motionY -= 0.004D; + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.9100000262260437D; + this.motionY *= 0.9100000262260437D; + this.motionZ *= 0.9100000262260437D; + + if (this.onGround) + { + this.motionX *= 0.699999988079071D; + this.motionZ *= 0.699999988079071D; + } + + if (this.field_92054_ax && this.particleAge < this.particleMaxAge / 2 && (this.particleAge + this.particleMaxAge) % 2 == 0) + { + EntityFireworkSparkFX entityfireworksparkfx = new EntityFireworkSparkFX(this.worldObj, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D, this.field_92047_az); + entityfireworksparkfx.setRBGColorF(this.particleRed, this.particleGreen, this.particleBlue); + entityfireworksparkfx.particleAge = entityfireworksparkfx.particleMaxAge / 2; + + if (this.hasFadeColour) + { + entityfireworksparkfx.hasFadeColour = true; + entityfireworksparkfx.fadeColourRed = this.fadeColourRed; + entityfireworksparkfx.fadeColourGreen = this.fadeColourGreen; + entityfireworksparkfx.fadeColourBlue = this.fadeColourBlue; + } + + entityfireworksparkfx.field_92048_ay = this.field_92048_ay; + this.field_92047_az.addEffect(entityfireworksparkfx); + } + } + + public int getBrightnessForRender(float par1) + { + return 15728880; + } + + public float getBrightness(float par1) + { + return 1.0F; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/particle/EntityFireworkStarterFX.java b/src/main/java/net/minecraft/client/particle/EntityFireworkStarterFX.java new file mode 100644 index 0000000..accb239 --- /dev/null +++ b/src/main/java/net/minecraft/client/particle/EntityFireworkStarterFX.java @@ -0,0 +1,250 @@ +package net.minecraft.client.particle; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +@SideOnly(Side.CLIENT) +public class EntityFireworkStarterFX extends EntityFX +{ + private int fireworkAge; + private final EffectRenderer theEffectRenderer; + private NBTTagList fireworkExplosions; + boolean twinkle; + private static final String __OBFID = "CL_00000906"; + + public EntityFireworkStarterFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12, EffectRenderer par14EffectRenderer, NBTTagCompound par15NBTTagCompound) + { + super(par1World, par2, par4, par6, 0.0D, 0.0D, 0.0D); + this.motionX = par8; + this.motionY = par10; + this.motionZ = par12; + this.theEffectRenderer = par14EffectRenderer; + this.particleMaxAge = 8; + + if (par15NBTTagCompound != null) + { + this.fireworkExplosions = par15NBTTagCompound.getTagList("Explosions", 10); + + if (this.fireworkExplosions.tagCount() == 0) + { + this.fireworkExplosions = null; + } + else + { + this.particleMaxAge = this.fireworkExplosions.tagCount() * 2 - 1; + + for (int i = 0; i < this.fireworkExplosions.tagCount(); ++i) + { + NBTTagCompound nbttagcompound1 = this.fireworkExplosions.getCompoundTagAt(i); + + if (nbttagcompound1.getBoolean("Flicker")) + { + this.twinkle = true; + this.particleMaxAge += 15; + break; + } + } + } + } + } + + public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) {} + + public void onUpdate() + { + boolean flag; + + if (this.fireworkAge == 0 && this.fireworkExplosions != null) + { + flag = this.func_92037_i(); + boolean flag1 = false; + + if (this.fireworkExplosions.tagCount() >= 3) + { + flag1 = true; + } + else + { + for (int i = 0; i < this.fireworkExplosions.tagCount(); ++i) + { + NBTTagCompound nbttagcompound = this.fireworkExplosions.getCompoundTagAt(i); + + if (nbttagcompound.getByte("Type") == 1) + { + flag1 = true; + break; + } + } + } + + String s1 = "fireworks." + (flag1 ? "largeBlast" : "blast") + (flag ? "_far" : ""); + this.worldObj.playSound(this.posX, this.posY, this.posZ, s1, 20.0F, 0.95F + this.rand.nextFloat() * 0.1F, true); + } + + if (this.fireworkAge % 2 == 0 && this.fireworkExplosions != null && this.fireworkAge / 2 < this.fireworkExplosions.tagCount()) + { + int k = this.fireworkAge / 2; + NBTTagCompound nbttagcompound1 = this.fireworkExplosions.getCompoundTagAt(k); + byte b0 = nbttagcompound1.getByte("Type"); + boolean flag3 = nbttagcompound1.getBoolean("Trail"); + boolean flag2 = nbttagcompound1.getBoolean("Flicker"); + int[] aint = nbttagcompound1.getIntArray("Colors"); + int[] aint1 = nbttagcompound1.getIntArray("FadeColors"); + + if (b0 == 1) + { + this.createBall(0.5D, 4, aint, aint1, flag3, flag2); + } + else if (b0 == 2) + { + this.createShaped(0.5D, new double[][] {{0.0D, 1.0D}, {0.3455D, 0.309D}, {0.9511D, 0.309D}, {0.3795918367346939D, -0.12653061224489795D}, {0.6122448979591837D, -0.8040816326530612D}, {0.0D, -0.35918367346938773D}}, aint, aint1, flag3, flag2, false); + } + else if (b0 == 3) + { + this.createShaped(0.5D, new double[][] {{0.0D, 0.2D}, {0.2D, 0.2D}, {0.2D, 0.6D}, {0.6D, 0.6D}, {0.6D, 0.2D}, {0.2D, 0.2D}, {0.2D, 0.0D}, {0.4D, 0.0D}, {0.4D, -0.6D}, {0.2D, -0.6D}, {0.2D, -0.4D}, {0.0D, -0.4D}}, aint, aint1, flag3, flag2, true); + } + else if (b0 == 4) + { + this.createBurst(aint, aint1, flag3, flag2); + } + else + { + this.createBall(0.25D, 2, aint, aint1, flag3, flag2); + } + + int j = aint[0]; + float f = (float)((j & 16711680) >> 16) / 255.0F; + float f1 = (float)((j & 65280) >> 8) / 255.0F; + float f2 = (float)((j & 255) >> 0) / 255.0F; + EntityFireworkOverlayFX entityfireworkoverlayfx = new EntityFireworkOverlayFX(this.worldObj, this.posX, this.posY, this.posZ); + entityfireworkoverlayfx.setRBGColorF(f, f1, f2); + this.theEffectRenderer.addEffect(entityfireworkoverlayfx); + } + + ++this.fireworkAge; + + if (this.fireworkAge > this.particleMaxAge) + { + if (this.twinkle) + { + flag = this.func_92037_i(); + String s = "fireworks." + (flag ? "twinkle_far" : "twinkle"); + this.worldObj.playSound(this.posX, this.posY, this.posZ, s, 20.0F, 0.9F + this.rand.nextFloat() * 0.15F, true); + } + + this.setDead(); + } + } + + private boolean func_92037_i() + { + Minecraft minecraft = Minecraft.getMinecraft(); + return minecraft == null || minecraft.renderViewEntity == null || minecraft.renderViewEntity.getDistanceSq(this.posX, this.posY, this.posZ) >= 256.0D; + } + + private void createParticle(double par1, double par3, double par5, double par7, double par9, double par11, int[] par13ArrayOfInteger, int[] par14ArrayOfInteger, boolean par15, boolean par16) + { + EntityFireworkSparkFX entityfireworksparkfx = new EntityFireworkSparkFX(this.worldObj, par1, par3, par5, par7, par9, par11, this.theEffectRenderer); + entityfireworksparkfx.setTrail(par15); + entityfireworksparkfx.setTwinkle(par16); + int i = this.rand.nextInt(par13ArrayOfInteger.length); + entityfireworksparkfx.setColour(par13ArrayOfInteger[i]); + + if (par14ArrayOfInteger != null && par14ArrayOfInteger.length > 0) + { + entityfireworksparkfx.setFadeColour(par14ArrayOfInteger[this.rand.nextInt(par14ArrayOfInteger.length)]); + } + + this.theEffectRenderer.addEffect(entityfireworksparkfx); + } + + private void createBall(double par1, int par3, int[] par4ArrayOfInteger, int[] par5ArrayOfInteger, boolean par6, boolean par7) + { + double d1 = this.posX; + double d2 = this.posY; + double d3 = this.posZ; + + for (int j = -par3; j <= par3; ++j) + { + for (int k = -par3; k <= par3; ++k) + { + for (int l = -par3; l <= par3; ++l) + { + double d4 = (double)k + (this.rand.nextDouble() - this.rand.nextDouble()) * 0.5D; + double d5 = (double)j + (this.rand.nextDouble() - this.rand.nextDouble()) * 0.5D; + double d6 = (double)l + (this.rand.nextDouble() - this.rand.nextDouble()) * 0.5D; + double d7 = (double)MathHelper.sqrt_double(d4 * d4 + d5 * d5 + d6 * d6) / par1 + this.rand.nextGaussian() * 0.05D; + this.createParticle(d1, d2, d3, d4 / d7, d5 / d7, d6 / d7, par4ArrayOfInteger, par5ArrayOfInteger, par6, par7); + + if (j != -par3 && j != par3 && k != -par3 && k != par3) + { + l += par3 * 2 - 1; + } + } + } + } + } + + private void createShaped(double par1, double[][] par3ArrayOfDouble, int[] par4ArrayOfInteger, int[] par5ArrayOfInteger, boolean par6, boolean par7, boolean par8) + { + double d1 = par3ArrayOfDouble[0][0]; + double d2 = par3ArrayOfDouble[0][1]; + this.createParticle(this.posX, this.posY, this.posZ, d1 * par1, d2 * par1, 0.0D, par4ArrayOfInteger, par5ArrayOfInteger, par6, par7); + float f = this.rand.nextFloat() * (float)Math.PI; + double d3 = par8 ? 0.034D : 0.34D; + + for (int i = 0; i < 3; ++i) + { + double d4 = (double)f + (double)((float)i * (float)Math.PI) * d3; + double d5 = d1; + double d6 = d2; + + for (int j = 1; j < par3ArrayOfDouble.length; ++j) + { + double d7 = par3ArrayOfDouble[j][0]; + double d8 = par3ArrayOfDouble[j][1]; + + for (double d9 = 0.25D; d9 <= 1.0D; d9 += 0.25D) + { + double d10 = (d5 + (d7 - d5) * d9) * par1; + double d11 = (d6 + (d8 - d6) * d9) * par1; + double d12 = d10 * Math.sin(d4); + d10 *= Math.cos(d4); + + for (double d13 = -1.0D; d13 <= 1.0D; d13 += 2.0D) + { + this.createParticle(this.posX, this.posY, this.posZ, d10 * d13, d11, d12 * d13, par4ArrayOfInteger, par5ArrayOfInteger, par6, par7); + } + } + + d5 = d7; + d6 = d8; + } + } + } + + private void createBurst(int[] par1ArrayOfInteger, int[] par2ArrayOfInteger, boolean par3, boolean par4) + { + double d0 = this.rand.nextGaussian() * 0.05D; + double d1 = this.rand.nextGaussian() * 0.05D; + + for (int i = 0; i < 70; ++i) + { + double d2 = this.motionX * 0.5D + this.rand.nextGaussian() * 0.15D + d0; + double d3 = this.motionZ * 0.5D + this.rand.nextGaussian() * 0.15D + d1; + double d4 = this.motionY * 0.5D + this.rand.nextDouble() * 0.5D; + this.createParticle(this.posX, this.posY, this.posZ, d2, d4, d3, par1ArrayOfInteger, par2ArrayOfInteger, par3, par4); + } + } + + public int getFXLayer() + { + return 0; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/particle/EntityFishWakeFX.java b/src/main/java/net/minecraft/client/particle/EntityFishWakeFX.java new file mode 100644 index 0000000..73b1882 --- /dev/null +++ b/src/main/java/net/minecraft/client/particle/EntityFishWakeFX.java @@ -0,0 +1,50 @@ +package net.minecraft.client.particle; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.world.World; + +@SideOnly(Side.CLIENT) +public class EntityFishWakeFX extends EntityFX +{ + private static final String __OBFID = "CL_00000933"; + + public EntityFishWakeFX(World p_i45073_1_, double p_i45073_2_, double p_i45073_4_, double p_i45073_6_, double p_i45073_8_, double p_i45073_10_, double p_i45073_12_) + { + super(p_i45073_1_, p_i45073_2_, p_i45073_4_, p_i45073_6_, 0.0D, 0.0D, 0.0D); + this.motionX *= 0.30000001192092896D; + this.motionY = (double)((float)Math.random() * 0.2F + 0.1F); + this.motionZ *= 0.30000001192092896D; + this.particleRed = 1.0F; + this.particleGreen = 1.0F; + this.particleBlue = 1.0F; + this.setParticleTextureIndex(19); + this.setSize(0.01F, 0.01F); + this.particleMaxAge = (int)(8.0D / (Math.random() * 0.8D + 0.2D)); + this.particleGravity = 0.0F; + this.motionX = p_i45073_8_; + this.motionY = p_i45073_10_; + this.motionZ = p_i45073_12_; + } + + public void onUpdate() + { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + this.motionY -= (double)this.particleGravity; + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.9800000190734863D; + this.motionY *= 0.9800000190734863D; + this.motionZ *= 0.9800000190734863D; + int i = 60 - this.particleMaxAge; + float f = (float)i * 0.001F; + this.setSize(f, f); + this.setParticleTextureIndex(19 + i % 4); + + if (this.particleMaxAge-- <= 0) + { + this.setDead(); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/particle/EntityFlameFX.java b/src/main/java/net/minecraft/client/particle/EntityFlameFX.java new file mode 100644 index 0000000..8c3995f --- /dev/null +++ b/src/main/java/net/minecraft/client/particle/EntityFlameFX.java @@ -0,0 +1,104 @@ +package net.minecraft.client.particle; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.world.World; + +@SideOnly(Side.CLIENT) +public class EntityFlameFX extends EntityFX +{ + private float flameScale; + private static final String __OBFID = "CL_00000907"; + + public EntityFlameFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12) + { + super(par1World, par2, par4, par6, par8, par10, par12); + this.motionX = this.motionX * 0.009999999776482582D + par8; + this.motionY = this.motionY * 0.009999999776482582D + par10; + this.motionZ = this.motionZ * 0.009999999776482582D + par12; + double d6 = par2 + (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.05F); + d6 = par4 + (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.05F); + d6 = par6 + (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.05F); + this.flameScale = this.particleScale; + this.particleRed = this.particleGreen = this.particleBlue = 1.0F; + this.particleMaxAge = (int)(8.0D / (Math.random() * 0.8D + 0.2D)) + 4; + this.noClip = true; + this.setParticleTextureIndex(48); + } + + public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) + { + float f6 = ((float)this.particleAge + par2) / (float)this.particleMaxAge; + this.particleScale = this.flameScale * (1.0F - f6 * f6 * 0.5F); + super.renderParticle(par1Tessellator, par2, par3, par4, par5, par6, par7); + } + + public int getBrightnessForRender(float par1) + { + float f1 = ((float)this.particleAge + par1) / (float)this.particleMaxAge; + + if (f1 < 0.0F) + { + f1 = 0.0F; + } + + if (f1 > 1.0F) + { + f1 = 1.0F; + } + + int i = super.getBrightnessForRender(par1); + int j = i & 255; + int k = i >> 16 & 255; + j += (int)(f1 * 15.0F * 16.0F); + + if (j > 240) + { + j = 240; + } + + return j | k << 16; + } + + public float getBrightness(float par1) + { + float f1 = ((float)this.particleAge + par1) / (float)this.particleMaxAge; + + if (f1 < 0.0F) + { + f1 = 0.0F; + } + + if (f1 > 1.0F) + { + f1 = 1.0F; + } + + float f2 = super.getBrightness(par1); + return f2 * f1 + (1.0F - f1); + } + + public void onUpdate() + { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + + if (this.particleAge++ >= this.particleMaxAge) + { + this.setDead(); + } + + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.9599999785423279D; + this.motionY *= 0.9599999785423279D; + this.motionZ *= 0.9599999785423279D; + + if (this.onGround) + { + this.motionX *= 0.699999988079071D; + this.motionZ *= 0.699999988079071D; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/particle/EntityFootStepFX.java b/src/main/java/net/minecraft/client/particle/EntityFootStepFX.java new file mode 100644 index 0000000..4b880cc --- /dev/null +++ b/src/main/java/net/minecraft/client/particle/EntityFootStepFX.java @@ -0,0 +1,75 @@ +package net.minecraft.client.particle; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class EntityFootStepFX extends EntityFX +{ + private static final ResourceLocation field_110126_a = new ResourceLocation("textures/particle/footprint.png"); + private int footstepAge; + private int footstepMaxAge; + private TextureManager currentFootSteps; + private static final String __OBFID = "CL_00000908"; + + public EntityFootStepFX(TextureManager par1TextureManager, World par2World, double par3, double par5, double par7) + { + super(par2World, par3, par5, par7, 0.0D, 0.0D, 0.0D); + this.currentFootSteps = par1TextureManager; + this.motionX = this.motionY = this.motionZ = 0.0D; + this.footstepMaxAge = 200; + } + + public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) + { + float f6 = ((float)this.footstepAge + par2) / (float)this.footstepMaxAge; + f6 *= f6; + float f7 = 2.0F - f6 * 2.0F; + + if (f7 > 1.0F) + { + f7 = 1.0F; + } + + f7 *= 0.2F; + GL11.glDisable(GL11.GL_LIGHTING); + float f8 = 0.125F; + float f9 = (float)(this.posX - interpPosX); + float f10 = (float)(this.posY - interpPosY); + float f11 = (float)(this.posZ - interpPosZ); + float f12 = this.worldObj.getLightBrightness(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)); + this.currentFootSteps.bindTexture(field_110126_a); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + par1Tessellator.startDrawingQuads(); + par1Tessellator.setColorRGBA_F(f12, f12, f12, f7); + par1Tessellator.addVertexWithUV((double)(f9 - f8), (double)f10, (double)(f11 + f8), 0.0D, 1.0D); + par1Tessellator.addVertexWithUV((double)(f9 + f8), (double)f10, (double)(f11 + f8), 1.0D, 1.0D); + par1Tessellator.addVertexWithUV((double)(f9 + f8), (double)f10, (double)(f11 - f8), 1.0D, 0.0D); + par1Tessellator.addVertexWithUV((double)(f9 - f8), (double)f10, (double)(f11 - f8), 0.0D, 0.0D); + par1Tessellator.draw(); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + } + + public void onUpdate() + { + ++this.footstepAge; + + if (this.footstepAge == this.footstepMaxAge) + { + this.setDead(); + } + } + + public int getFXLayer() + { + return 3; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/particle/EntityHeartFX.java b/src/main/java/net/minecraft/client/particle/EntityHeartFX.java new file mode 100644 index 0000000..a91d737 --- /dev/null +++ b/src/main/java/net/minecraft/client/particle/EntityHeartFX.java @@ -0,0 +1,81 @@ +package net.minecraft.client.particle; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.world.World; + +@SideOnly(Side.CLIENT) +public class EntityHeartFX extends EntityFX +{ + float particleScaleOverTime; + private static final String __OBFID = "CL_00000909"; + + public EntityHeartFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12) + { + this(par1World, par2, par4, par6, par8, par10, par12, 2.0F); + } + + public EntityHeartFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12, float par14) + { + super(par1World, par2, par4, par6, 0.0D, 0.0D, 0.0D); + this.motionX *= 0.009999999776482582D; + this.motionY *= 0.009999999776482582D; + this.motionZ *= 0.009999999776482582D; + this.motionY += 0.1D; + this.particleScale *= 0.75F; + this.particleScale *= par14; + this.particleScaleOverTime = this.particleScale; + this.particleMaxAge = 16; + this.noClip = false; + this.setParticleTextureIndex(80); + } + + public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) + { + float f6 = ((float)this.particleAge + par2) / (float)this.particleMaxAge * 32.0F; + + if (f6 < 0.0F) + { + f6 = 0.0F; + } + + if (f6 > 1.0F) + { + f6 = 1.0F; + } + + this.particleScale = this.particleScaleOverTime * f6; + super.renderParticle(par1Tessellator, par2, par3, par4, par5, par6, par7); + } + + public void onUpdate() + { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + + if (this.particleAge++ >= this.particleMaxAge) + { + this.setDead(); + } + + this.moveEntity(this.motionX, this.motionY, this.motionZ); + + if (this.posY == this.prevPosY) + { + this.motionX *= 1.1D; + this.motionZ *= 1.1D; + } + + this.motionX *= 0.8600000143051147D; + this.motionY *= 0.8600000143051147D; + this.motionZ *= 0.8600000143051147D; + + if (this.onGround) + { + this.motionX *= 0.699999988079071D; + this.motionZ *= 0.699999988079071D; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/particle/EntityHugeExplodeFX.java b/src/main/java/net/minecraft/client/particle/EntityHugeExplodeFX.java new file mode 100644 index 0000000..27aaff5 --- /dev/null +++ b/src/main/java/net/minecraft/client/particle/EntityHugeExplodeFX.java @@ -0,0 +1,44 @@ +package net.minecraft.client.particle; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.world.World; + +@SideOnly(Side.CLIENT) +public class EntityHugeExplodeFX extends EntityFX +{ + private int timeSinceStart; + private int maximumTime = 8; + private static final String __OBFID = "CL_00000911"; + + public EntityHugeExplodeFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12) + { + super(par1World, par2, par4, par6, 0.0D, 0.0D, 0.0D); + } + + public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) {} + + public void onUpdate() + { + for (int i = 0; i < 6; ++i) + { + double d0 = this.posX + (this.rand.nextDouble() - this.rand.nextDouble()) * 4.0D; + double d1 = this.posY + (this.rand.nextDouble() - this.rand.nextDouble()) * 4.0D; + double d2 = this.posZ + (this.rand.nextDouble() - this.rand.nextDouble()) * 4.0D; + this.worldObj.spawnParticle("largeexplode", d0, d1, d2, (double)((float)this.timeSinceStart / (float)this.maximumTime), 0.0D, 0.0D); + } + + ++this.timeSinceStart; + + if (this.timeSinceStart == this.maximumTime) + { + this.setDead(); + } + } + + public int getFXLayer() + { + return 1; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/particle/EntityLargeExplodeFX.java b/src/main/java/net/minecraft/client/particle/EntityLargeExplodeFX.java new file mode 100644 index 0000000..7b06ee1 --- /dev/null +++ b/src/main/java/net/minecraft/client/particle/EntityLargeExplodeFX.java @@ -0,0 +1,85 @@ +package net.minecraft.client.particle; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class EntityLargeExplodeFX extends EntityFX +{ + private static final ResourceLocation field_110127_a = new ResourceLocation("textures/entity/explosion.png"); + private int field_70581_a; + private int field_70584_aq; + private TextureManager theRenderEngine; + private float field_70582_as; + private static final String __OBFID = "CL_00000910"; + + public EntityLargeExplodeFX(TextureManager par1TextureManager, World par2World, double par3, double par5, double par7, double par9, double par11, double par13) + { + super(par2World, par3, par5, par7, 0.0D, 0.0D, 0.0D); + this.theRenderEngine = par1TextureManager; + this.field_70584_aq = 6 + this.rand.nextInt(4); + this.particleRed = this.particleGreen = this.particleBlue = this.rand.nextFloat() * 0.6F + 0.4F; + this.field_70582_as = 1.0F - (float)par9 * 0.5F; + } + + public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) + { + int i = (int)(((float)this.field_70581_a + par2) * 15.0F / (float)this.field_70584_aq); + + if (i <= 15) + { + this.theRenderEngine.bindTexture(field_110127_a); + float f6 = (float)(i % 4) / 4.0F; + float f7 = f6 + 0.24975F; + float f8 = (float)(i / 4) / 4.0F; + float f9 = f8 + 0.24975F; + float f10 = 2.0F * this.field_70582_as; + float f11 = (float)(this.prevPosX + (this.posX - this.prevPosX) * (double)par2 - interpPosX); + float f12 = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)par2 - interpPosY); + float f13 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)par2 - interpPosZ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_LIGHTING); + RenderHelper.disableStandardItemLighting(); + par1Tessellator.startDrawingQuads(); + par1Tessellator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, 1.0F); + par1Tessellator.setNormal(0.0F, 1.0F, 0.0F); + par1Tessellator.setBrightness(240); + par1Tessellator.addVertexWithUV((double)(f11 - par3 * f10 - par6 * f10), (double)(f12 - par4 * f10), (double)(f13 - par5 * f10 - par7 * f10), (double)f7, (double)f9); + par1Tessellator.addVertexWithUV((double)(f11 - par3 * f10 + par6 * f10), (double)(f12 + par4 * f10), (double)(f13 - par5 * f10 + par7 * f10), (double)f7, (double)f8); + par1Tessellator.addVertexWithUV((double)(f11 + par3 * f10 + par6 * f10), (double)(f12 + par4 * f10), (double)(f13 + par5 * f10 + par7 * f10), (double)f6, (double)f8); + par1Tessellator.addVertexWithUV((double)(f11 + par3 * f10 - par6 * f10), (double)(f12 - par4 * f10), (double)(f13 + par5 * f10 - par7 * f10), (double)f6, (double)f9); + par1Tessellator.draw(); + GL11.glPolygonOffset(0.0F, 0.0F); + GL11.glEnable(GL11.GL_LIGHTING); + } + } + + public int getBrightnessForRender(float par1) + { + return 61680; + } + + public void onUpdate() + { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + ++this.field_70581_a; + + if (this.field_70581_a == this.field_70584_aq) + { + this.setDead(); + } + } + + public int getFXLayer() + { + return 3; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/particle/EntityLavaFX.java b/src/main/java/net/minecraft/client/particle/EntityLavaFX.java new file mode 100644 index 0000000..167dede --- /dev/null +++ b/src/main/java/net/minecraft/client/particle/EntityLavaFX.java @@ -0,0 +1,91 @@ +package net.minecraft.client.particle; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.world.World; + +@SideOnly(Side.CLIENT) +public class EntityLavaFX extends EntityFX +{ + private float lavaParticleScale; + private static final String __OBFID = "CL_00000912"; + + public EntityLavaFX(World par1World, double par2, double par4, double par6) + { + super(par1World, par2, par4, par6, 0.0D, 0.0D, 0.0D); + this.motionX *= 0.800000011920929D; + this.motionY *= 0.800000011920929D; + this.motionZ *= 0.800000011920929D; + this.motionY = (double)(this.rand.nextFloat() * 0.4F + 0.05F); + this.particleRed = this.particleGreen = this.particleBlue = 1.0F; + this.particleScale *= this.rand.nextFloat() * 2.0F + 0.2F; + this.lavaParticleScale = this.particleScale; + this.particleMaxAge = (int)(16.0D / (Math.random() * 0.8D + 0.2D)); + this.noClip = false; + this.setParticleTextureIndex(49); + } + + public int getBrightnessForRender(float par1) + { + float f1 = ((float)this.particleAge + par1) / (float)this.particleMaxAge; + + if (f1 < 0.0F) + { + f1 = 0.0F; + } + + if (f1 > 1.0F) + { + f1 = 1.0F; + } + + int i = super.getBrightnessForRender(par1); + short short1 = 240; + int j = i >> 16 & 255; + return short1 | j << 16; + } + + public float getBrightness(float par1) + { + return 1.0F; + } + + public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) + { + float f6 = ((float)this.particleAge + par2) / (float)this.particleMaxAge; + this.particleScale = this.lavaParticleScale * (1.0F - f6 * f6); + super.renderParticle(par1Tessellator, par2, par3, par4, par5, par6, par7); + } + + public void onUpdate() + { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + + if (this.particleAge++ >= this.particleMaxAge) + { + this.setDead(); + } + + float f = (float)this.particleAge / (float)this.particleMaxAge; + + if (this.rand.nextFloat() > f) + { + this.worldObj.spawnParticle("smoke", this.posX, this.posY, this.posZ, this.motionX, this.motionY, this.motionZ); + } + + this.motionY -= 0.03D; + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.9990000128746033D; + this.motionY *= 0.9990000128746033D; + this.motionZ *= 0.9990000128746033D; + + if (this.onGround) + { + this.motionX *= 0.699999988079071D; + this.motionZ *= 0.699999988079071D; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/particle/EntityNoteFX.java b/src/main/java/net/minecraft/client/particle/EntityNoteFX.java new file mode 100644 index 0000000..7740bd0 --- /dev/null +++ b/src/main/java/net/minecraft/client/particle/EntityNoteFX.java @@ -0,0 +1,85 @@ +package net.minecraft.client.particle; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +@SideOnly(Side.CLIENT) +public class EntityNoteFX extends EntityFX +{ + float noteParticleScale; + private static final String __OBFID = "CL_00000913"; + + public EntityNoteFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12) + { + this(par1World, par2, par4, par6, par8, par10, par12, 2.0F); + } + + public EntityNoteFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12, float par14) + { + super(par1World, par2, par4, par6, 0.0D, 0.0D, 0.0D); + this.motionX *= 0.009999999776482582D; + this.motionY *= 0.009999999776482582D; + this.motionZ *= 0.009999999776482582D; + this.motionY += 0.2D; + this.particleRed = MathHelper.sin(((float)par8 + 0.0F) * (float)Math.PI * 2.0F) * 0.65F + 0.35F; + this.particleGreen = MathHelper.sin(((float)par8 + 0.33333334F) * (float)Math.PI * 2.0F) * 0.65F + 0.35F; + this.particleBlue = MathHelper.sin(((float)par8 + 0.6666667F) * (float)Math.PI * 2.0F) * 0.65F + 0.35F; + this.particleScale *= 0.75F; + this.particleScale *= par14; + this.noteParticleScale = this.particleScale; + this.particleMaxAge = 6; + this.noClip = false; + this.setParticleTextureIndex(64); + } + + public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) + { + float f6 = ((float)this.particleAge + par2) / (float)this.particleMaxAge * 32.0F; + + if (f6 < 0.0F) + { + f6 = 0.0F; + } + + if (f6 > 1.0F) + { + f6 = 1.0F; + } + + this.particleScale = this.noteParticleScale * f6; + super.renderParticle(par1Tessellator, par2, par3, par4, par5, par6, par7); + } + + public void onUpdate() + { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + + if (this.particleAge++ >= this.particleMaxAge) + { + this.setDead(); + } + + this.moveEntity(this.motionX, this.motionY, this.motionZ); + + if (this.posY == this.prevPosY) + { + this.motionX *= 1.1D; + this.motionZ *= 1.1D; + } + + this.motionX *= 0.6600000262260437D; + this.motionY *= 0.6600000262260437D; + this.motionZ *= 0.6600000262260437D; + + if (this.onGround) + { + this.motionX *= 0.699999988079071D; + this.motionZ *= 0.699999988079071D; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/particle/EntityPickupFX.java b/src/main/java/net/minecraft/client/particle/EntityPickupFX.java new file mode 100644 index 0000000..6f19a1d --- /dev/null +++ b/src/main/java/net/minecraft/client/particle/EntityPickupFX.java @@ -0,0 +1,69 @@ +package net.minecraft.client.particle; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.entity.Entity; +import net.minecraft.world.World; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class EntityPickupFX extends EntityFX +{ + private Entity entityToPickUp; + private Entity entityPickingUp; + private int age; + private int maxAge; + private float yOffs; + private static final String __OBFID = "CL_00000930"; + + public EntityPickupFX(World par1World, Entity par2Entity, Entity par3Entity, float par4) + { + super(par1World, par2Entity.posX, par2Entity.posY, par2Entity.posZ, par2Entity.motionX, par2Entity.motionY, par2Entity.motionZ); + this.entityToPickUp = par2Entity; + this.entityPickingUp = par3Entity; + this.maxAge = 3; + this.yOffs = par4; + } + + public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) + { + float f6 = ((float)this.age + par2) / (float)this.maxAge; + f6 *= f6; + double d0 = this.entityToPickUp.posX; + double d1 = this.entityToPickUp.posY; + double d2 = this.entityToPickUp.posZ; + double d3 = this.entityPickingUp.lastTickPosX + (this.entityPickingUp.posX - this.entityPickingUp.lastTickPosX) * (double)par2; + double d4 = this.entityPickingUp.lastTickPosY + (this.entityPickingUp.posY - this.entityPickingUp.lastTickPosY) * (double)par2 + (double)this.yOffs; + double d5 = this.entityPickingUp.lastTickPosZ + (this.entityPickingUp.posZ - this.entityPickingUp.lastTickPosZ) * (double)par2; + double d6 = d0 + (d3 - d0) * (double)f6; + double d7 = d1 + (d4 - d1) * (double)f6; + double d8 = d2 + (d5 - d2) * (double)f6; + int i = this.getBrightnessForRender(par2); + int j = i % 65536; + int k = i / 65536; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j / 1.0F, (float)k / 1.0F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + d6 -= interpPosX; + d7 -= interpPosY; + d8 -= interpPosZ; + RenderManager.instance.renderEntityWithPosYaw(this.entityToPickUp, (double)((float)d6), (double)((float)d7), (double)((float)d8), this.entityToPickUp.rotationYaw, par2); + } + + public void onUpdate() + { + ++this.age; + + if (this.age == this.maxAge) + { + this.setDead(); + } + } + + public int getFXLayer() + { + return 3; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/particle/EntityPortalFX.java b/src/main/java/net/minecraft/client/particle/EntityPortalFX.java new file mode 100644 index 0000000..c8f4f67 --- /dev/null +++ b/src/main/java/net/minecraft/client/particle/EntityPortalFX.java @@ -0,0 +1,90 @@ +package net.minecraft.client.particle; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.world.World; + +@SideOnly(Side.CLIENT) +public class EntityPortalFX extends EntityFX +{ + private float portalParticleScale; + private double portalPosX; + private double portalPosY; + private double portalPosZ; + private static final String __OBFID = "CL_00000921"; + + public EntityPortalFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12) + { + super(par1World, par2, par4, par6, par8, par10, par12); + this.motionX = par8; + this.motionY = par10; + this.motionZ = par12; + this.portalPosX = this.posX = par2; + this.portalPosY = this.posY = par4; + this.portalPosZ = this.posZ = par6; + float f = this.rand.nextFloat() * 0.6F + 0.4F; + this.portalParticleScale = this.particleScale = this.rand.nextFloat() * 0.2F + 0.5F; + this.particleRed = this.particleGreen = this.particleBlue = 1.0F * f; + this.particleGreen *= 0.3F; + this.particleRed *= 0.9F; + this.particleMaxAge = (int)(Math.random() * 10.0D) + 40; + this.noClip = true; + this.setParticleTextureIndex((int)(Math.random() * 8.0D)); + } + + public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) + { + float f6 = ((float)this.particleAge + par2) / (float)this.particleMaxAge; + f6 = 1.0F - f6; + f6 *= f6; + f6 = 1.0F - f6; + this.particleScale = this.portalParticleScale * f6; + super.renderParticle(par1Tessellator, par2, par3, par4, par5, par6, par7); + } + + public int getBrightnessForRender(float par1) + { + int i = super.getBrightnessForRender(par1); + float f1 = (float)this.particleAge / (float)this.particleMaxAge; + f1 *= f1; + f1 *= f1; + int j = i & 255; + int k = i >> 16 & 255; + k += (int)(f1 * 15.0F * 16.0F); + + if (k > 240) + { + k = 240; + } + + return j | k << 16; + } + + public float getBrightness(float par1) + { + float f1 = super.getBrightness(par1); + float f2 = (float)this.particleAge / (float)this.particleMaxAge; + f2 = f2 * f2 * f2 * f2; + return f1 * (1.0F - f2) + f2; + } + + public void onUpdate() + { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + float f = (float)this.particleAge / (float)this.particleMaxAge; + float f1 = f; + f = -f + f * f * 2.0F; + f = 1.0F - f; + this.posX = this.portalPosX + this.motionX * (double)f; + this.posY = this.portalPosY + this.motionY * (double)f + (double)(1.0F - f1); + this.posZ = this.portalPosZ + this.motionZ * (double)f; + + if (this.particleAge++ >= this.particleMaxAge) + { + this.setDead(); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/particle/EntityRainFX.java b/src/main/java/net/minecraft/client/particle/EntityRainFX.java new file mode 100644 index 0000000..1884b17 --- /dev/null +++ b/src/main/java/net/minecraft/client/particle/EntityRainFX.java @@ -0,0 +1,69 @@ +package net.minecraft.client.particle; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.BlockLiquid; +import net.minecraft.block.material.Material; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +@SideOnly(Side.CLIENT) +public class EntityRainFX extends EntityFX +{ + private static final String __OBFID = "CL_00000934"; + + public EntityRainFX(World par1World, double par2, double par4, double par6) + { + super(par1World, par2, par4, par6, 0.0D, 0.0D, 0.0D); + this.motionX *= 0.30000001192092896D; + this.motionY = (double)((float)Math.random() * 0.2F + 0.1F); + this.motionZ *= 0.30000001192092896D; + this.particleRed = 1.0F; + this.particleGreen = 1.0F; + this.particleBlue = 1.0F; + this.setParticleTextureIndex(19 + this.rand.nextInt(4)); + this.setSize(0.01F, 0.01F); + this.particleGravity = 0.06F; + this.particleMaxAge = (int)(8.0D / (Math.random() * 0.8D + 0.2D)); + } + + public void onUpdate() + { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + this.motionY -= (double)this.particleGravity; + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.9800000190734863D; + this.motionY *= 0.9800000190734863D; + this.motionZ *= 0.9800000190734863D; + + if (this.particleMaxAge-- <= 0) + { + this.setDead(); + } + + if (this.onGround) + { + if (Math.random() < 0.5D) + { + this.setDead(); + } + + this.motionX *= 0.699999988079071D; + this.motionZ *= 0.699999988079071D; + } + + Material material = this.worldObj.getBlock(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)).getMaterial(); + + if (material.isLiquid() || material.isSolid()) + { + double d0 = (double)((float)(MathHelper.floor_double(this.posY) + 1) - BlockLiquid.getLiquidHeightPercent(this.worldObj.getBlockMetadata(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)))); + + if (this.posY < d0) + { + this.setDead(); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/particle/EntityReddustFX.java b/src/main/java/net/minecraft/client/particle/EntityReddustFX.java new file mode 100644 index 0000000..ca90007 --- /dev/null +++ b/src/main/java/net/minecraft/client/particle/EntityReddustFX.java @@ -0,0 +1,91 @@ +package net.minecraft.client.particle; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.world.World; + +@SideOnly(Side.CLIENT) +public class EntityReddustFX extends EntityFX +{ + float reddustParticleScale; + private static final String __OBFID = "CL_00000923"; + + public EntityReddustFX(World par1World, double par2, double par4, double par6, float par8, float par9, float par10) + { + this(par1World, par2, par4, par6, 1.0F, par8, par9, par10); + } + + public EntityReddustFX(World par1World, double par2, double par4, double par6, float par8, float par9, float par10, float par11) + { + super(par1World, par2, par4, par6, 0.0D, 0.0D, 0.0D); + this.motionX *= 0.10000000149011612D; + this.motionY *= 0.10000000149011612D; + this.motionZ *= 0.10000000149011612D; + + if (par9 == 0.0F) + { + par9 = 1.0F; + } + + float f4 = (float)Math.random() * 0.4F + 0.6F; + this.particleRed = ((float)(Math.random() * 0.20000000298023224D) + 0.8F) * par9 * f4; + this.particleGreen = ((float)(Math.random() * 0.20000000298023224D) + 0.8F) * par10 * f4; + this.particleBlue = ((float)(Math.random() * 0.20000000298023224D) + 0.8F) * par11 * f4; + this.particleScale *= 0.75F; + this.particleScale *= par8; + this.reddustParticleScale = this.particleScale; + this.particleMaxAge = (int)(8.0D / (Math.random() * 0.8D + 0.2D)); + this.particleMaxAge = (int)((float)this.particleMaxAge * par8); + this.noClip = false; + } + + public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) + { + float f6 = ((float)this.particleAge + par2) / (float)this.particleMaxAge * 32.0F; + + if (f6 < 0.0F) + { + f6 = 0.0F; + } + + if (f6 > 1.0F) + { + f6 = 1.0F; + } + + this.particleScale = this.reddustParticleScale * f6; + super.renderParticle(par1Tessellator, par2, par3, par4, par5, par6, par7); + } + + public void onUpdate() + { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + + if (this.particleAge++ >= this.particleMaxAge) + { + this.setDead(); + } + + this.setParticleTextureIndex(7 - this.particleAge * 8 / this.particleMaxAge); + this.moveEntity(this.motionX, this.motionY, this.motionZ); + + if (this.posY == this.prevPosY) + { + this.motionX *= 1.1D; + this.motionZ *= 1.1D; + } + + this.motionX *= 0.9599999785423279D; + this.motionY *= 0.9599999785423279D; + this.motionZ *= 0.9599999785423279D; + + if (this.onGround) + { + this.motionX *= 0.699999988079071D; + this.motionZ *= 0.699999988079071D; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/particle/EntitySmokeFX.java b/src/main/java/net/minecraft/client/particle/EntitySmokeFX.java new file mode 100644 index 0000000..60533a8 --- /dev/null +++ b/src/main/java/net/minecraft/client/particle/EntitySmokeFX.java @@ -0,0 +1,86 @@ +package net.minecraft.client.particle; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.world.World; + +@SideOnly(Side.CLIENT) +public class EntitySmokeFX extends EntityFX +{ + float smokeParticleScale; + private static final String __OBFID = "CL_00000924"; + + public EntitySmokeFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12) + { + this(par1World, par2, par4, par6, par8, par10, par12, 1.0F); + } + + public EntitySmokeFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12, float par14) + { + super(par1World, par2, par4, par6, 0.0D, 0.0D, 0.0D); + this.motionX *= 0.10000000149011612D; + this.motionY *= 0.10000000149011612D; + this.motionZ *= 0.10000000149011612D; + this.motionX += par8; + this.motionY += par10; + this.motionZ += par12; + this.particleRed = this.particleGreen = this.particleBlue = (float)(Math.random() * 0.30000001192092896D); + this.particleScale *= 0.75F; + this.particleScale *= par14; + this.smokeParticleScale = this.particleScale; + this.particleMaxAge = (int)(8.0D / (Math.random() * 0.8D + 0.2D)); + this.particleMaxAge = (int)((float)this.particleMaxAge * par14); + this.noClip = false; + } + + public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) + { + float f6 = ((float)this.particleAge + par2) / (float)this.particleMaxAge * 32.0F; + + if (f6 < 0.0F) + { + f6 = 0.0F; + } + + if (f6 > 1.0F) + { + f6 = 1.0F; + } + + this.particleScale = this.smokeParticleScale * f6; + super.renderParticle(par1Tessellator, par2, par3, par4, par5, par6, par7); + } + + public void onUpdate() + { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + + if (this.particleAge++ >= this.particleMaxAge) + { + this.setDead(); + } + + this.setParticleTextureIndex(7 - this.particleAge * 8 / this.particleMaxAge); + this.motionY += 0.004D; + this.moveEntity(this.motionX, this.motionY, this.motionZ); + + if (this.posY == this.prevPosY) + { + this.motionX *= 1.1D; + this.motionZ *= 1.1D; + } + + this.motionX *= 0.9599999785423279D; + this.motionY *= 0.9599999785423279D; + this.motionZ *= 0.9599999785423279D; + + if (this.onGround) + { + this.motionX *= 0.699999988079071D; + this.motionZ *= 0.699999988079071D; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/particle/EntitySnowShovelFX.java b/src/main/java/net/minecraft/client/particle/EntitySnowShovelFX.java new file mode 100644 index 0000000..434b972 --- /dev/null +++ b/src/main/java/net/minecraft/client/particle/EntitySnowShovelFX.java @@ -0,0 +1,79 @@ +package net.minecraft.client.particle; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.world.World; + +@SideOnly(Side.CLIENT) +public class EntitySnowShovelFX extends EntityFX +{ + float snowDigParticleScale; + private static final String __OBFID = "CL_00000925"; + + public EntitySnowShovelFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12) + { + this(par1World, par2, par4, par6, par8, par10, par12, 1.0F); + } + + public EntitySnowShovelFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12, float par14) + { + super(par1World, par2, par4, par6, par8, par10, par12); + this.motionX *= 0.10000000149011612D; + this.motionY *= 0.10000000149011612D; + this.motionZ *= 0.10000000149011612D; + this.motionX += par8; + this.motionY += par10; + this.motionZ += par12; + this.particleRed = this.particleGreen = this.particleBlue = 1.0F - (float)(Math.random() * 0.30000001192092896D); + this.particleScale *= 0.75F; + this.particleScale *= par14; + this.snowDigParticleScale = this.particleScale; + this.particleMaxAge = (int)(8.0D / (Math.random() * 0.8D + 0.2D)); + this.particleMaxAge = (int)((float)this.particleMaxAge * par14); + this.noClip = false; + } + + public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) + { + float f6 = ((float)this.particleAge + par2) / (float)this.particleMaxAge * 32.0F; + + if (f6 < 0.0F) + { + f6 = 0.0F; + } + + if (f6 > 1.0F) + { + f6 = 1.0F; + } + + this.particleScale = this.snowDigParticleScale * f6; + super.renderParticle(par1Tessellator, par2, par3, par4, par5, par6, par7); + } + + public void onUpdate() + { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + + if (this.particleAge++ >= this.particleMaxAge) + { + this.setDead(); + } + + this.setParticleTextureIndex(7 - this.particleAge * 8 / this.particleMaxAge); + this.motionY -= 0.03D; + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.9900000095367432D; + this.motionY *= 0.9900000095367432D; + this.motionZ *= 0.9900000095367432D; + + if (this.onGround) + { + this.motionX *= 0.699999988079071D; + this.motionZ *= 0.699999988079071D; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/particle/EntitySpellParticleFX.java b/src/main/java/net/minecraft/client/particle/EntitySpellParticleFX.java new file mode 100644 index 0000000..2d04a25 --- /dev/null +++ b/src/main/java/net/minecraft/client/particle/EntitySpellParticleFX.java @@ -0,0 +1,83 @@ +package net.minecraft.client.particle; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.world.World; + +@SideOnly(Side.CLIENT) +public class EntitySpellParticleFX extends EntityFX +{ + private int baseSpellTextureIndex = 128; + private static final String __OBFID = "CL_00000926"; + + public EntitySpellParticleFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12) + { + super(par1World, par2, par4, par6, par8, par10, par12); + this.motionY *= 0.20000000298023224D; + + if (par8 == 0.0D && par12 == 0.0D) + { + this.motionX *= 0.10000000149011612D; + this.motionZ *= 0.10000000149011612D; + } + + this.particleScale *= 0.75F; + this.particleMaxAge = (int)(8.0D / (Math.random() * 0.8D + 0.2D)); + this.noClip = false; + } + + public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) + { + float f6 = ((float)this.particleAge + par2) / (float)this.particleMaxAge * 32.0F; + + if (f6 < 0.0F) + { + f6 = 0.0F; + } + + if (f6 > 1.0F) + { + f6 = 1.0F; + } + + super.renderParticle(par1Tessellator, par2, par3, par4, par5, par6, par7); + } + + public void onUpdate() + { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + + if (this.particleAge++ >= this.particleMaxAge) + { + this.setDead(); + } + + this.setParticleTextureIndex(this.baseSpellTextureIndex + (7 - this.particleAge * 8 / this.particleMaxAge)); + this.motionY += 0.004D; + this.moveEntity(this.motionX, this.motionY, this.motionZ); + + if (this.posY == this.prevPosY) + { + this.motionX *= 1.1D; + this.motionZ *= 1.1D; + } + + this.motionX *= 0.9599999785423279D; + this.motionY *= 0.9599999785423279D; + this.motionZ *= 0.9599999785423279D; + + if (this.onGround) + { + this.motionX *= 0.699999988079071D; + this.motionZ *= 0.699999988079071D; + } + } + + public void setBaseSpellTextureIndex(int par1) + { + this.baseSpellTextureIndex = par1; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/particle/EntitySplashFX.java b/src/main/java/net/minecraft/client/particle/EntitySplashFX.java new file mode 100644 index 0000000..98597f5 --- /dev/null +++ b/src/main/java/net/minecraft/client/particle/EntitySplashFX.java @@ -0,0 +1,25 @@ +package net.minecraft.client.particle; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.world.World; + +@SideOnly(Side.CLIENT) +public class EntitySplashFX extends EntityRainFX +{ + private static final String __OBFID = "CL_00000927"; + + public EntitySplashFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12) + { + super(par1World, par2, par4, par6); + this.particleGravity = 0.04F; + this.nextTextureIndexX(); + + if (par10 == 0.0D && (par8 != 0.0D || par12 != 0.0D)) + { + this.motionX = par8; + this.motionY = par10 + 0.1D; + this.motionZ = par12; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/particle/EntitySuspendFX.java b/src/main/java/net/minecraft/client/particle/EntitySuspendFX.java new file mode 100644 index 0000000..1242dd2 --- /dev/null +++ b/src/main/java/net/minecraft/client/particle/EntitySuspendFX.java @@ -0,0 +1,46 @@ +package net.minecraft.client.particle; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.material.Material; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +@SideOnly(Side.CLIENT) +public class EntitySuspendFX extends EntityFX +{ + private static final String __OBFID = "CL_00000928"; + + public EntitySuspendFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12) + { + super(par1World, par2, par4 - 0.125D, par6, par8, par10, par12); + this.particleRed = 0.4F; + this.particleGreen = 0.4F; + this.particleBlue = 0.7F; + this.setParticleTextureIndex(0); + this.setSize(0.01F, 0.01F); + this.particleScale *= this.rand.nextFloat() * 0.6F + 0.2F; + this.motionX = par8 * 0.0D; + this.motionY = par10 * 0.0D; + this.motionZ = par12 * 0.0D; + this.particleMaxAge = (int)(16.0D / (Math.random() * 0.8D + 0.2D)); + } + + public void onUpdate() + { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + this.moveEntity(this.motionX, this.motionY, this.motionZ); + + if (this.worldObj.getBlock(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)).getMaterial() != Material.water) + { + this.setDead(); + } + + if (this.particleMaxAge-- <= 0) + { + this.setDead(); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/ActiveRenderInfo.java b/src/main/java/net/minecraft/client/renderer/ActiveRenderInfo.java new file mode 100644 index 0000000..33ac9ce --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/ActiveRenderInfo.java @@ -0,0 +1,86 @@ +package net.minecraft.client.renderer; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; +import net.minecraft.block.Block; +import net.minecraft.block.BlockLiquid; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; +import net.minecraft.world.ChunkPosition; +import net.minecraft.world.World; +import org.lwjgl.opengl.GL11; +import org.lwjgl.util.glu.GLU; + +@SideOnly(Side.CLIENT) +public class ActiveRenderInfo +{ + public static float objectX; + public static float objectY; + public static float objectZ; + private static IntBuffer viewport = GLAllocation.createDirectIntBuffer(16); + private static FloatBuffer modelview = GLAllocation.createDirectFloatBuffer(16); + private static FloatBuffer projection = GLAllocation.createDirectFloatBuffer(16); + private static FloatBuffer objectCoords = GLAllocation.createDirectFloatBuffer(3); + public static float rotationX; + public static float rotationXZ; + public static float rotationZ; + public static float rotationYZ; + public static float rotationXY; + private static final String __OBFID = "CL_00000626"; + + public static void updateRenderInfo(EntityPlayer par0EntityPlayer, boolean par1) + { + GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, modelview); + GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, projection); + GL11.glGetInteger(GL11.GL_VIEWPORT, viewport); + float f = (float)((viewport.get(0) + viewport.get(2)) / 2); + float f1 = (float)((viewport.get(1) + viewport.get(3)) / 2); + GLU.gluUnProject(f, f1, 0.0F, modelview, projection, viewport, objectCoords); + objectX = objectCoords.get(0); + objectY = objectCoords.get(1); + objectZ = objectCoords.get(2); + int i = par1 ? 1 : 0; + float f2 = par0EntityPlayer.rotationPitch; + float f3 = par0EntityPlayer.rotationYaw; + rotationX = MathHelper.cos(f3 * (float)Math.PI / 180.0F) * (float)(1 - i * 2); + rotationZ = MathHelper.sin(f3 * (float)Math.PI / 180.0F) * (float)(1 - i * 2); + rotationYZ = -rotationZ * MathHelper.sin(f2 * (float)Math.PI / 180.0F) * (float)(1 - i * 2); + rotationXY = rotationX * MathHelper.sin(f2 * (float)Math.PI / 180.0F) * (float)(1 - i * 2); + rotationXZ = MathHelper.cos(f2 * (float)Math.PI / 180.0F); + } + + public static Vec3 projectViewFromEntity(EntityLivingBase par0EntityLivingBase, double par1) + { + double d1 = par0EntityLivingBase.prevPosX + (par0EntityLivingBase.posX - par0EntityLivingBase.prevPosX) * par1; + double d2 = par0EntityLivingBase.prevPosY + (par0EntityLivingBase.posY - par0EntityLivingBase.prevPosY) * par1 + (double)par0EntityLivingBase.getEyeHeight(); + double d3 = par0EntityLivingBase.prevPosZ + (par0EntityLivingBase.posZ - par0EntityLivingBase.prevPosZ) * par1; + double d4 = d1 + (double)(objectX * 1.0F); + double d5 = d2 + (double)(objectY * 1.0F); + double d6 = d3 + (double)(objectZ * 1.0F); + return par0EntityLivingBase.worldObj.getWorldVec3Pool().getVecFromPool(d4, d5, d6); + } + + public static Block getBlockAtEntityViewpoint(World p_151460_0_, EntityLivingBase p_151460_1_, float p_151460_2_) + { + Vec3 vec3 = projectViewFromEntity(p_151460_1_, (double)p_151460_2_); + ChunkPosition chunkposition = new ChunkPosition(vec3); + Block block = p_151460_0_.getBlock(chunkposition.chunkPosX, chunkposition.chunkPosY, chunkposition.chunkPosZ); + + if (block.getMaterial().isLiquid()) + { + float f1 = BlockLiquid.getLiquidHeightPercent(p_151460_0_.getBlockMetadata(chunkposition.chunkPosX, chunkposition.chunkPosY, chunkposition.chunkPosZ)) - 0.11111111F; + float f2 = (float)(chunkposition.chunkPosY + 1) - f1; + + if (vec3.yCoord >= (double)f2) + { + block = p_151460_0_.getBlock(chunkposition.chunkPosX, chunkposition.chunkPosY + 1, chunkposition.chunkPosZ); + } + } + + return block; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/DestroyBlockProgress.java b/src/main/java/net/minecraft/client/renderer/DestroyBlockProgress.java new file mode 100644 index 0000000..ed5dc60 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/DestroyBlockProgress.java @@ -0,0 +1,64 @@ +package net.minecraft.client.renderer; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class DestroyBlockProgress +{ + private final int miningPlayerEntId; + private final int partialBlockX; + private final int partialBlockY; + private final int partialBlockZ; + private int partialBlockProgress; + private int createdAtCloudUpdateTick; + private static final String __OBFID = "CL_00001427"; + + public DestroyBlockProgress(int par1, int par2, int par3, int par4) + { + this.miningPlayerEntId = par1; + this.partialBlockX = par2; + this.partialBlockY = par3; + this.partialBlockZ = par4; + } + + public int getPartialBlockX() + { + return this.partialBlockX; + } + + public int getPartialBlockY() + { + return this.partialBlockY; + } + + public int getPartialBlockZ() + { + return this.partialBlockZ; + } + + public void setPartialBlockDamage(int par1) + { + if (par1 > 10) + { + par1 = 10; + } + + this.partialBlockProgress = par1; + } + + public int getPartialBlockDamage() + { + return this.partialBlockProgress; + } + + public void setCloudUpdateTick(int par1) + { + this.createdAtCloudUpdateTick = par1; + } + + public int getCreationCloudUpdateTick() + { + return this.createdAtCloudUpdateTick; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/EntityRenderer.java b/src/main/java/net/minecraft/client/renderer/EntityRenderer.java new file mode 100644 index 0000000..38c9f18 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/EntityRenderer.java @@ -0,0 +1,1968 @@ +package net.minecraft.client.renderer; + +import com.google.gson.JsonSyntaxException; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import java.nio.FloatBuffer; +import java.util.List; +import java.util.Random; +import java.util.concurrent.Callable; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.client.gui.MapItemRenderer; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.multiplayer.WorldClient; +import net.minecraft.client.particle.EffectRenderer; +import net.minecraft.client.particle.EntityRainFX; +import net.minecraft.client.particle.EntitySmokeFX; +import net.minecraft.client.renderer.culling.ClippingHelperImpl; +import net.minecraft.client.renderer.culling.Frustrum; +import net.minecraft.client.renderer.texture.DynamicTexture; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.client.resources.IResourceManager; +import net.minecraft.client.resources.IResourceManagerReloadListener; +import net.minecraft.client.shader.ShaderGroup; +import net.minecraft.client.shader.ShaderLinkHelper; +import net.minecraft.crash.CrashReport; +import net.minecraft.crash.CrashReportCategory; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.boss.BossStatus; +import net.minecraft.entity.item.EntityItemFrame; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.potion.Potion; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MouseFilter; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.ReportedException; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Vec3; +import net.minecraft.world.biome.BiomeGenBase; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GLContext; +import org.lwjgl.util.glu.Project; +import net.minecraftforge.client.ForgeHooksClient; +import net.minecraftforge.client.IRenderHandler; +import net.minecraftforge.client.event.DrawBlockHighlightEvent; +import net.minecraftforge.client.event.RenderWorldLastEvent; +import net.minecraftforge.common.MinecraftForge; + +@SideOnly(Side.CLIENT) +public class EntityRenderer implements IResourceManagerReloadListener +{ + private static final Logger logger = LogManager.getLogger(); + private static final ResourceLocation locationRainPng = new ResourceLocation("textures/environment/rain.png"); + private static final ResourceLocation locationSnowPng = new ResourceLocation("textures/environment/snow.png"); + public static boolean anaglyphEnable; + public static int anaglyphField; + private Minecraft mc; + private float farPlaneDistance; + public final ItemRenderer itemRenderer; + private final MapItemRenderer theMapItemRenderer; + private int rendererUpdateCount; + private Entity pointedEntity; + private MouseFilter mouseFilterXAxis = new MouseFilter(); + private MouseFilter mouseFilterYAxis = new MouseFilter(); + private MouseFilter mouseFilterDummy1 = new MouseFilter(); + private MouseFilter mouseFilterDummy2 = new MouseFilter(); + private MouseFilter mouseFilterDummy3 = new MouseFilter(); + private MouseFilter mouseFilterDummy4 = new MouseFilter(); + private float thirdPersonDistance = 4.0F; + private float thirdPersonDistanceTemp = 4.0F; + private float debugCamYaw; + private float prevDebugCamYaw; + private float debugCamPitch; + private float prevDebugCamPitch; + private float smoothCamYaw; + private float smoothCamPitch; + private float smoothCamFilterX; + private float smoothCamFilterY; + private float smoothCamPartialTicks; + private float debugCamFOV; + private float prevDebugCamFOV; + private float camRoll; + private float prevCamRoll; + private final DynamicTexture lightmapTexture; + private final int[] lightmapColors; + private final ResourceLocation locationLightMap; + private float fovModifierHand; + private float fovModifierHandPrev; + private float fovMultiplierTemp; + private float bossColorModifier; + private float bossColorModifierPrev; + private boolean cloudFog; + private final IResourceManager resourceManager; + public ShaderGroup theShaderGroup; + private static final ResourceLocation[] shaderResourceLocations = new ResourceLocation[] {new ResourceLocation("shaders/post/fxaa.json"), new ResourceLocation("shaders/post/art.json"), new ResourceLocation("shaders/post/bumpy.json"), new ResourceLocation("shaders/post/blobs2.json"), new ResourceLocation("shaders/post/pencil.json"), new ResourceLocation("shaders/post/color_convolve.json"), new ResourceLocation("shaders/post/deconverge.json"), new ResourceLocation("shaders/post/flip.json"), new ResourceLocation("shaders/post/invert.json"), new ResourceLocation("shaders/post/ntsc.json"), new ResourceLocation("shaders/post/outline.json"), new ResourceLocation("shaders/post/phosphor.json"), new ResourceLocation("shaders/post/scan_pincushion.json"), new ResourceLocation("shaders/post/sobel.json"), new ResourceLocation("shaders/post/bits.json"), new ResourceLocation("shaders/post/desaturate.json"), new ResourceLocation("shaders/post/green.json"), new ResourceLocation("shaders/post/blur.json"), new ResourceLocation("shaders/post/wobble.json"), new ResourceLocation("shaders/post/blobs.json"), new ResourceLocation("shaders/post/antialias.json")}; + public static final int shaderCount = shaderResourceLocations.length; + private int shaderIndex; + private double cameraZoom; + private double cameraYaw; + private double cameraPitch; + private long prevFrameTime; + private long renderEndNanoTime; + private boolean lightmapUpdateNeeded; + float torchFlickerX; + float torchFlickerDX; + float torchFlickerY; + float torchFlickerDY; + private Random random; + private int rainSoundCounter; + float[] rainXCoords; + float[] rainYCoords; + FloatBuffer fogColorBuffer; + float fogColorRed; + float fogColorGreen; + float fogColorBlue; + private float fogColor2; + private float fogColor1; + public int debugViewDirection; + private static final String __OBFID = "CL_00000947"; + + public EntityRenderer(Minecraft p_i45076_1_, IResourceManager p_i45076_2_) + { + this.shaderIndex = shaderCount; + this.cameraZoom = 1.0D; + this.prevFrameTime = Minecraft.getSystemTime(); + this.random = new Random(); + this.fogColorBuffer = GLAllocation.createDirectFloatBuffer(16); + this.mc = p_i45076_1_; + this.resourceManager = p_i45076_2_; + this.theMapItemRenderer = new MapItemRenderer(p_i45076_1_.getTextureManager()); + this.itemRenderer = new ItemRenderer(p_i45076_1_); + this.lightmapTexture = new DynamicTexture(16, 16); + this.locationLightMap = p_i45076_1_.getTextureManager().getDynamicTextureLocation("lightMap", this.lightmapTexture); + this.lightmapColors = this.lightmapTexture.getTextureData(); + this.theShaderGroup = null; + } + + public boolean isShaderActive() + { + return OpenGlHelper.shadersSupported && this.theShaderGroup != null; + } + + public void deactivateShader() + { + if (this.theShaderGroup != null) + { + this.theShaderGroup.deleteShaderGroup(); + } + + this.theShaderGroup = null; + this.shaderIndex = shaderCount; + } + + public void activateNextShader() + { + if (OpenGlHelper.shadersSupported) + { + if (this.theShaderGroup != null) + { + this.theShaderGroup.deleteShaderGroup(); + } + + this.shaderIndex = (this.shaderIndex + 1) % (shaderResourceLocations.length + 1); + + if (this.shaderIndex != shaderCount) + { + try + { + logger.info("Selecting effect " + shaderResourceLocations[this.shaderIndex]); + this.theShaderGroup = new ShaderGroup(this.resourceManager, this.mc.getFramebuffer(), shaderResourceLocations[this.shaderIndex]); + this.theShaderGroup.createBindFramebuffers(this.mc.displayWidth, this.mc.displayHeight); + } + catch (IOException ioexception) + { + logger.warn("Failed to load shader: " + shaderResourceLocations[this.shaderIndex], ioexception); + this.shaderIndex = shaderCount; + } + catch (JsonSyntaxException jsonsyntaxexception) + { + logger.warn("Failed to load shader: " + shaderResourceLocations[this.shaderIndex], jsonsyntaxexception); + this.shaderIndex = shaderCount; + } + } + else + { + this.theShaderGroup = null; + logger.info("No effect selected"); + } + } + } + + public void onResourceManagerReload(IResourceManager par1ResourceManager) + { + if (this.theShaderGroup != null) + { + this.theShaderGroup.deleteShaderGroup(); + } + + if (this.shaderIndex != shaderCount) + { + try + { + this.theShaderGroup = new ShaderGroup(par1ResourceManager, this.mc.getFramebuffer(), shaderResourceLocations[this.shaderIndex]); + this.theShaderGroup.createBindFramebuffers(this.mc.displayWidth, this.mc.displayHeight); + } + catch (IOException ioexception) + { + logger.warn("Failed to load shader: " + shaderResourceLocations[this.shaderIndex], ioexception); + this.shaderIndex = shaderCount; + } + } + } + + public void updateRenderer() + { + if (OpenGlHelper.shadersSupported && ShaderLinkHelper.getStaticShaderLinkHelper() == null) + { + ShaderLinkHelper.setNewStaticShaderLinkHelper(); + } + + this.updateFovModifierHand(); + this.updateTorchFlicker(); + this.fogColor2 = this.fogColor1; + this.thirdPersonDistanceTemp = this.thirdPersonDistance; + this.prevDebugCamYaw = this.debugCamYaw; + this.prevDebugCamPitch = this.debugCamPitch; + this.prevDebugCamFOV = this.debugCamFOV; + this.prevCamRoll = this.camRoll; + float f; + float f1; + + if (this.mc.gameSettings.smoothCamera) + { + f = this.mc.gameSettings.mouseSensitivity * 0.6F + 0.2F; + f1 = f * f * f * 8.0F; + this.smoothCamFilterX = this.mouseFilterXAxis.smooth(this.smoothCamYaw, 0.05F * f1); + this.smoothCamFilterY = this.mouseFilterYAxis.smooth(this.smoothCamPitch, 0.05F * f1); + this.smoothCamPartialTicks = 0.0F; + this.smoothCamYaw = 0.0F; + this.smoothCamPitch = 0.0F; + } + + if (this.mc.renderViewEntity == null) + { + this.mc.renderViewEntity = this.mc.thePlayer; + } + + f = this.mc.theWorld.getLightBrightness(MathHelper.floor_double(this.mc.renderViewEntity.posX), MathHelper.floor_double(this.mc.renderViewEntity.posY), MathHelper.floor_double(this.mc.renderViewEntity.posZ)); + f1 = (float)(this.mc.gameSettings.renderDistanceChunks / 16); + float f2 = f * (1.0F - f1) + f1; + this.fogColor1 += (f2 - this.fogColor1) * 0.1F; + ++this.rendererUpdateCount; + this.itemRenderer.updateEquippedItem(); + this.addRainParticles(); + this.bossColorModifierPrev = this.bossColorModifier; + + if (BossStatus.hasColorModifier) + { + this.bossColorModifier += 0.05F; + + if (this.bossColorModifier > 1.0F) + { + this.bossColorModifier = 1.0F; + } + + BossStatus.hasColorModifier = false; + } + else if (this.bossColorModifier > 0.0F) + { + this.bossColorModifier -= 0.0125F; + } + } + + public ShaderGroup getShaderGroup() + { + return this.theShaderGroup; + } + + public void updateShaderGroupSize(int p_147704_1_, int p_147704_2_) + { + if (OpenGlHelper.shadersSupported) + { + if (this.theShaderGroup != null) + { + this.theShaderGroup.createBindFramebuffers(p_147704_1_, p_147704_2_); + } + } + } + + public void getMouseOver(float par1) + { + if (this.mc.renderViewEntity != null) + { + if (this.mc.theWorld != null) + { + this.mc.pointedEntity = null; + double d0 = (double)this.mc.playerController.getBlockReachDistance(); + this.mc.objectMouseOver = this.mc.renderViewEntity.rayTrace(d0, par1); + double d1 = d0; + Vec3 vec3 = this.mc.renderViewEntity.getPosition(par1); + + if (this.mc.playerController.extendedReach()) + { + d0 = 6.0D; + d1 = 6.0D; + } + else + { + if (d0 > 3.0D) + { + d1 = 3.0D; + } + + d0 = d1; + } + + if (this.mc.objectMouseOver != null) + { + d1 = this.mc.objectMouseOver.hitVec.distanceTo(vec3); + } + + Vec3 vec31 = this.mc.renderViewEntity.getLook(par1); + Vec3 vec32 = vec3.addVector(vec31.xCoord * d0, vec31.yCoord * d0, vec31.zCoord * d0); + this.pointedEntity = null; + Vec3 vec33 = null; + float f1 = 1.0F; + List list = this.mc.theWorld.getEntitiesWithinAABBExcludingEntity(this.mc.renderViewEntity, this.mc.renderViewEntity.boundingBox.addCoord(vec31.xCoord * d0, vec31.yCoord * d0, vec31.zCoord * d0).expand((double)f1, (double)f1, (double)f1)); + double d2 = d1; + + for (int i = 0; i < list.size(); ++i) + { + Entity entity = (Entity)list.get(i); + + if (entity.canBeCollidedWith()) + { + float f2 = entity.getCollisionBorderSize(); + AxisAlignedBB axisalignedbb = entity.boundingBox.expand((double)f2, (double)f2, (double)f2); + MovingObjectPosition movingobjectposition = axisalignedbb.calculateIntercept(vec3, vec32); + + if (axisalignedbb.isVecInside(vec3)) + { + if (0.0D < d2 || d2 == 0.0D) + { + this.pointedEntity = entity; + vec33 = movingobjectposition == null ? vec3 : movingobjectposition.hitVec; + d2 = 0.0D; + } + } + else if (movingobjectposition != null) + { + double d3 = vec3.distanceTo(movingobjectposition.hitVec); + + if (d3 < d2 || d2 == 0.0D) + { + if (entity == this.mc.renderViewEntity.ridingEntity && !entity.canRiderInteract()) + { + if (d2 == 0.0D) + { + this.pointedEntity = entity; + vec33 = movingobjectposition.hitVec; + } + } + else + { + this.pointedEntity = entity; + vec33 = movingobjectposition.hitVec; + d2 = d3; + } + } + } + } + } + + if (this.pointedEntity != null && (d2 < d1 || this.mc.objectMouseOver == null)) + { + this.mc.objectMouseOver = new MovingObjectPosition(this.pointedEntity, vec33); + + if (this.pointedEntity instanceof EntityLivingBase || this.pointedEntity instanceof EntityItemFrame) + { + this.mc.pointedEntity = this.pointedEntity; + } + } + } + } + } + + private void updateFovModifierHand() + { + if (mc.renderViewEntity instanceof EntityPlayerSP) + { + EntityPlayerSP entityplayersp = (EntityPlayerSP)this.mc.renderViewEntity; + this.fovMultiplierTemp = entityplayersp.getFOVMultiplier(); + } + else + { + this.fovMultiplierTemp = mc.thePlayer.getFOVMultiplier(); + } + this.fovModifierHandPrev = this.fovModifierHand; + this.fovModifierHand += (this.fovMultiplierTemp - this.fovModifierHand) * 0.5F; + + if (this.fovModifierHand > 1.5F) + { + this.fovModifierHand = 1.5F; + } + + if (this.fovModifierHand < 0.1F) + { + this.fovModifierHand = 0.1F; + } + } + + private float getFOVModifier(float par1, boolean par2) + { + if (this.debugViewDirection > 0) + { + return 90.0F; + } + else + { + EntityLivingBase entityplayer = (EntityLivingBase)this.mc.renderViewEntity; + float f1 = 70.0F; + + if (par2) + { + f1 += this.mc.gameSettings.fovSetting * 40.0F; + f1 *= this.fovModifierHandPrev + (this.fovModifierHand - this.fovModifierHandPrev) * par1; + } + + if (entityplayer.getHealth() <= 0.0F) + { + float f2 = (float)entityplayer.deathTime + par1; + f1 /= (1.0F - 500.0F / (f2 + 500.0F)) * 2.0F + 1.0F; + } + + Block block = ActiveRenderInfo.getBlockAtEntityViewpoint(this.mc.theWorld, entityplayer, par1); + + if (block.getMaterial() == Material.water) + { + f1 = f1 * 60.0F / 70.0F; + } + + return f1 + this.prevDebugCamFOV + (this.debugCamFOV - this.prevDebugCamFOV) * par1; + } + } + + private void hurtCameraEffect(float par1) + { + EntityLivingBase entitylivingbase = this.mc.renderViewEntity; + float f1 = (float)entitylivingbase.hurtTime - par1; + float f2; + + if (entitylivingbase.getHealth() <= 0.0F) + { + f2 = (float)entitylivingbase.deathTime + par1; + GL11.glRotatef(40.0F - 8000.0F / (f2 + 200.0F), 0.0F, 0.0F, 1.0F); + } + + if (f1 >= 0.0F) + { + f1 /= (float)entitylivingbase.maxHurtTime; + f1 = MathHelper.sin(f1 * f1 * f1 * f1 * (float)Math.PI); + f2 = entitylivingbase.attackedAtYaw; + GL11.glRotatef(-f2, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-f1 * 14.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(f2, 0.0F, 1.0F, 0.0F); + } + } + + private void setupViewBobbing(float par1) + { + if (this.mc.renderViewEntity instanceof EntityPlayer) + { + EntityPlayer entityplayer = (EntityPlayer)this.mc.renderViewEntity; + float f1 = entityplayer.distanceWalkedModified - entityplayer.prevDistanceWalkedModified; + float f2 = -(entityplayer.distanceWalkedModified + f1 * par1); + float f3 = entityplayer.prevCameraYaw + (entityplayer.cameraYaw - entityplayer.prevCameraYaw) * par1; + float f4 = entityplayer.prevCameraPitch + (entityplayer.cameraPitch - entityplayer.prevCameraPitch) * par1; + GL11.glTranslatef(MathHelper.sin(f2 * (float)Math.PI) * f3 * 0.5F, -Math.abs(MathHelper.cos(f2 * (float)Math.PI) * f3), 0.0F); + GL11.glRotatef(MathHelper.sin(f2 * (float)Math.PI) * f3 * 3.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(Math.abs(MathHelper.cos(f2 * (float)Math.PI - 0.2F) * f3) * 5.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(f4, 1.0F, 0.0F, 0.0F); + } + } + + private void orientCamera(float par1) + { + EntityLivingBase entitylivingbase = this.mc.renderViewEntity; + float f1 = entitylivingbase.yOffset - 1.62F; + double d0 = entitylivingbase.prevPosX + (entitylivingbase.posX - entitylivingbase.prevPosX) * (double)par1; + double d1 = entitylivingbase.prevPosY + (entitylivingbase.posY - entitylivingbase.prevPosY) * (double)par1 - (double)f1; + double d2 = entitylivingbase.prevPosZ + (entitylivingbase.posZ - entitylivingbase.prevPosZ) * (double)par1; + GL11.glRotatef(this.prevCamRoll + (this.camRoll - this.prevCamRoll) * par1, 0.0F, 0.0F, 1.0F); + + if (entitylivingbase.isPlayerSleeping()) + { + f1 = (float)((double)f1 + 1.0D); + GL11.glTranslatef(0.0F, 0.3F, 0.0F); + + if (!this.mc.gameSettings.debugCamEnable) + { + ForgeHooksClient.orientBedCamera(mc, entitylivingbase); + GL11.glRotatef(entitylivingbase.prevRotationYaw + (entitylivingbase.rotationYaw - entitylivingbase.prevRotationYaw) * par1 + 180.0F, 0.0F, -1.0F, 0.0F); + GL11.glRotatef(entitylivingbase.prevRotationPitch + (entitylivingbase.rotationPitch - entitylivingbase.prevRotationPitch) * par1, -1.0F, 0.0F, 0.0F); + } + } + else if (this.mc.gameSettings.thirdPersonView > 0) + { + double d7 = (double)(this.thirdPersonDistanceTemp + (this.thirdPersonDistance - this.thirdPersonDistanceTemp) * par1); + float f2; + float f6; + + if (this.mc.gameSettings.debugCamEnable) + { + f6 = this.prevDebugCamYaw + (this.debugCamYaw - this.prevDebugCamYaw) * par1; + f2 = this.prevDebugCamPitch + (this.debugCamPitch - this.prevDebugCamPitch) * par1; + GL11.glTranslatef(0.0F, 0.0F, (float)(-d7)); + GL11.glRotatef(f2, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(f6, 0.0F, 1.0F, 0.0F); + } + else + { + f6 = entitylivingbase.rotationYaw; + f2 = entitylivingbase.rotationPitch; + + if (this.mc.gameSettings.thirdPersonView == 2) + { + f2 += 180.0F; + } + + double d3 = (double)(-MathHelper.sin(f6 / 180.0F * (float)Math.PI) * MathHelper.cos(f2 / 180.0F * (float)Math.PI)) * d7; + double d4 = (double)(MathHelper.cos(f6 / 180.0F * (float)Math.PI) * MathHelper.cos(f2 / 180.0F * (float)Math.PI)) * d7; + double d5 = (double)(-MathHelper.sin(f2 / 180.0F * (float)Math.PI)) * d7; + + for (int k = 0; k < 8; ++k) + { + float f3 = (float)((k & 1) * 2 - 1); + float f4 = (float)((k >> 1 & 1) * 2 - 1); + float f5 = (float)((k >> 2 & 1) * 2 - 1); + f3 *= 0.1F; + f4 *= 0.1F; + f5 *= 0.1F; + MovingObjectPosition movingobjectposition = this.mc.theWorld.rayTraceBlocks(this.mc.theWorld.getWorldVec3Pool().getVecFromPool(d0 + (double)f3, d1 + (double)f4, d2 + (double)f5), this.mc.theWorld.getWorldVec3Pool().getVecFromPool(d0 - d3 + (double)f3 + (double)f5, d1 - d5 + (double)f4, d2 - d4 + (double)f5)); + + if (movingobjectposition != null) + { + double d6 = movingobjectposition.hitVec.distanceTo(this.mc.theWorld.getWorldVec3Pool().getVecFromPool(d0, d1, d2)); + + if (d6 < d7) + { + d7 = d6; + } + } + } + + if (this.mc.gameSettings.thirdPersonView == 2) + { + GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); + } + + GL11.glRotatef(entitylivingbase.rotationPitch - f2, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(entitylivingbase.rotationYaw - f6, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(0.0F, 0.0F, (float)(-d7)); + GL11.glRotatef(f6 - entitylivingbase.rotationYaw, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(f2 - entitylivingbase.rotationPitch, 1.0F, 0.0F, 0.0F); + } + } + else + { + GL11.glTranslatef(0.0F, 0.0F, -0.1F); + } + + if (!this.mc.gameSettings.debugCamEnable) + { + GL11.glRotatef(entitylivingbase.prevRotationPitch + (entitylivingbase.rotationPitch - entitylivingbase.prevRotationPitch) * par1, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(entitylivingbase.prevRotationYaw + (entitylivingbase.rotationYaw - entitylivingbase.prevRotationYaw) * par1 + 180.0F, 0.0F, 1.0F, 0.0F); + } + + GL11.glTranslatef(0.0F, f1, 0.0F); + d0 = entitylivingbase.prevPosX + (entitylivingbase.posX - entitylivingbase.prevPosX) * (double)par1; + d1 = entitylivingbase.prevPosY + (entitylivingbase.posY - entitylivingbase.prevPosY) * (double)par1 - (double)f1; + d2 = entitylivingbase.prevPosZ + (entitylivingbase.posZ - entitylivingbase.prevPosZ) * (double)par1; + this.cloudFog = this.mc.renderGlobal.hasCloudFog(d0, d1, d2, par1); + } + + private void setupCameraTransform(float par1, int par2) + { + this.farPlaneDistance = (float)(this.mc.gameSettings.renderDistanceChunks * 16); + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + float f1 = 0.07F; + + if (this.mc.gameSettings.anaglyph) + { + GL11.glTranslatef((float)(-(par2 * 2 - 1)) * f1, 0.0F, 0.0F); + } + + if (this.cameraZoom != 1.0D) + { + GL11.glTranslatef((float)this.cameraYaw, (float)(-this.cameraPitch), 0.0F); + GL11.glScaled(this.cameraZoom, this.cameraZoom, 1.0D); + } + + Project.gluPerspective(this.getFOVModifier(par1, true), (float)this.mc.displayWidth / (float)this.mc.displayHeight, 0.05F, this.farPlaneDistance * 2.0F); + float f2; + + if (this.mc.playerController.enableEverythingIsScrewedUpMode()) + { + f2 = 0.6666667F; + GL11.glScalef(1.0F, f2, 1.0F); + } + + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + + if (this.mc.gameSettings.anaglyph) + { + GL11.glTranslatef((float)(par2 * 2 - 1) * 0.1F, 0.0F, 0.0F); + } + + this.hurtCameraEffect(par1); + + if (this.mc.gameSettings.viewBobbing) + { + this.setupViewBobbing(par1); + } + + f2 = this.mc.thePlayer.prevTimeInPortal + (this.mc.thePlayer.timeInPortal - this.mc.thePlayer.prevTimeInPortal) * par1; + + if (f2 > 0.0F) + { + byte b0 = 20; + + if (this.mc.thePlayer.isPotionActive(Potion.confusion)) + { + b0 = 7; + } + + float f3 = 5.0F / (f2 * f2 + 5.0F) - f2 * 0.04F; + f3 *= f3; + GL11.glRotatef(((float)this.rendererUpdateCount + par1) * (float)b0, 0.0F, 1.0F, 1.0F); + GL11.glScalef(1.0F / f3, 1.0F, 1.0F); + GL11.glRotatef(-((float)this.rendererUpdateCount + par1) * (float)b0, 0.0F, 1.0F, 1.0F); + } + + this.orientCamera(par1); + + if (this.debugViewDirection > 0) + { + int j = this.debugViewDirection - 1; + + if (j == 1) + { + GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + } + + if (j == 2) + { + GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); + } + + if (j == 3) + { + GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); + } + + if (j == 4) + { + GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); + } + + if (j == 5) + { + GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F); + } + } + } + + private void renderHand(float par1, int par2) + { + if (this.debugViewDirection <= 0) + { + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + float f1 = 0.07F; + + if (this.mc.gameSettings.anaglyph) + { + GL11.glTranslatef((float)(-(par2 * 2 - 1)) * f1, 0.0F, 0.0F); + } + + if (this.cameraZoom != 1.0D) + { + GL11.glTranslatef((float)this.cameraYaw, (float)(-this.cameraPitch), 0.0F); + GL11.glScaled(this.cameraZoom, this.cameraZoom, 1.0D); + } + + Project.gluPerspective(this.getFOVModifier(par1, false), (float)this.mc.displayWidth / (float)this.mc.displayHeight, 0.05F, this.farPlaneDistance * 2.0F); + + if (this.mc.playerController.enableEverythingIsScrewedUpMode()) + { + float f2 = 0.6666667F; + GL11.glScalef(1.0F, f2, 1.0F); + } + + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + + if (this.mc.gameSettings.anaglyph) + { + GL11.glTranslatef((float)(par2 * 2 - 1) * 0.1F, 0.0F, 0.0F); + } + + GL11.glPushMatrix(); + this.hurtCameraEffect(par1); + + if (this.mc.gameSettings.viewBobbing) + { + this.setupViewBobbing(par1); + } + + if (this.mc.gameSettings.thirdPersonView == 0 && !this.mc.renderViewEntity.isPlayerSleeping() && !this.mc.gameSettings.hideGUI && !this.mc.playerController.enableEverythingIsScrewedUpMode()) + { + this.enableLightmap((double)par1); + this.itemRenderer.renderItemInFirstPerson(par1); + this.disableLightmap((double)par1); + } + + GL11.glPopMatrix(); + + if (this.mc.gameSettings.thirdPersonView == 0 && !this.mc.renderViewEntity.isPlayerSleeping()) + { + this.itemRenderer.renderOverlays(par1); + this.hurtCameraEffect(par1); + } + + if (this.mc.gameSettings.viewBobbing) + { + this.setupViewBobbing(par1); + } + } + } + + public void disableLightmap(double par1) + { + OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); + GL11.glDisable(GL11.GL_TEXTURE_2D); + OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); + } + + public void enableLightmap(double par1) + { + OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glLoadIdentity(); + float f = 0.00390625F; + GL11.glScalef(f, f, f); + GL11.glTranslatef(8.0F, 8.0F, 8.0F); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + this.mc.getTextureManager().bindTexture(this.locationLightMap); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glEnable(GL11.GL_TEXTURE_2D); + OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); + } + + private void updateTorchFlicker() + { + this.torchFlickerDX = (float)((double)this.torchFlickerDX + (Math.random() - Math.random()) * Math.random() * Math.random()); + this.torchFlickerDY = (float)((double)this.torchFlickerDY + (Math.random() - Math.random()) * Math.random() * Math.random()); + this.torchFlickerDX = (float)((double)this.torchFlickerDX * 0.9D); + this.torchFlickerDY = (float)((double)this.torchFlickerDY * 0.9D); + this.torchFlickerX += (this.torchFlickerDX - this.torchFlickerX) * 1.0F; + this.torchFlickerY += (this.torchFlickerDY - this.torchFlickerY) * 1.0F; + this.lightmapUpdateNeeded = true; + } + + private void updateLightmap(float par1) + { + WorldClient worldclient = this.mc.theWorld; + + if (worldclient != null) + { + for (int i = 0; i < 256; ++i) + { + float f1 = worldclient.getSunBrightness(1.0F) * 0.95F + 0.05F; + float f2 = worldclient.provider.lightBrightnessTable[i / 16] * f1; + float f3 = worldclient.provider.lightBrightnessTable[i % 16] * (this.torchFlickerX * 0.1F + 1.5F); + + if (worldclient.lastLightningBolt > 0) + { + f2 = worldclient.provider.lightBrightnessTable[i / 16]; + } + + float f4 = f2 * (worldclient.getSunBrightness(1.0F) * 0.65F + 0.35F); + float f5 = f2 * (worldclient.getSunBrightness(1.0F) * 0.65F + 0.35F); + float f6 = f3 * ((f3 * 0.6F + 0.4F) * 0.6F + 0.4F); + float f7 = f3 * (f3 * f3 * 0.6F + 0.4F); + float f8 = f4 + f3; + float f9 = f5 + f6; + float f10 = f2 + f7; + f8 = f8 * 0.96F + 0.03F; + f9 = f9 * 0.96F + 0.03F; + f10 = f10 * 0.96F + 0.03F; + float f11; + + if (this.bossColorModifier > 0.0F) + { + f11 = this.bossColorModifierPrev + (this.bossColorModifier - this.bossColorModifierPrev) * par1; + f8 = f8 * (1.0F - f11) + f8 * 0.7F * f11; + f9 = f9 * (1.0F - f11) + f9 * 0.6F * f11; + f10 = f10 * (1.0F - f11) + f10 * 0.6F * f11; + } + + if (worldclient.provider.dimensionId == 1) + { + f8 = 0.22F + f3 * 0.75F; + f9 = 0.28F + f6 * 0.75F; + f10 = 0.25F + f7 * 0.75F; + } + + float f12; + + if (this.mc.thePlayer.isPotionActive(Potion.nightVision)) + { + f11 = this.getNightVisionBrightness(this.mc.thePlayer, par1); + f12 = 1.0F / f8; + + if (f12 > 1.0F / f9) + { + f12 = 1.0F / f9; + } + + if (f12 > 1.0F / f10) + { + f12 = 1.0F / f10; + } + + f8 = f8 * (1.0F - f11) + f8 * f12 * f11; + f9 = f9 * (1.0F - f11) + f9 * f12 * f11; + f10 = f10 * (1.0F - f11) + f10 * f12 * f11; + } + + if (f8 > 1.0F) + { + f8 = 1.0F; + } + + if (f9 > 1.0F) + { + f9 = 1.0F; + } + + if (f10 > 1.0F) + { + f10 = 1.0F; + } + + f11 = this.mc.gameSettings.gammaSetting; + f12 = 1.0F - f8; + float f13 = 1.0F - f9; + float f14 = 1.0F - f10; + f12 = 1.0F - f12 * f12 * f12 * f12; + f13 = 1.0F - f13 * f13 * f13 * f13; + f14 = 1.0F - f14 * f14 * f14 * f14; + f8 = f8 * (1.0F - f11) + f12 * f11; + f9 = f9 * (1.0F - f11) + f13 * f11; + f10 = f10 * (1.0F - f11) + f14 * f11; + f8 = f8 * 0.96F + 0.03F; + f9 = f9 * 0.96F + 0.03F; + f10 = f10 * 0.96F + 0.03F; + + if (f8 > 1.0F) + { + f8 = 1.0F; + } + + if (f9 > 1.0F) + { + f9 = 1.0F; + } + + if (f10 > 1.0F) + { + f10 = 1.0F; + } + + if (f8 < 0.0F) + { + f8 = 0.0F; + } + + if (f9 < 0.0F) + { + f9 = 0.0F; + } + + if (f10 < 0.0F) + { + f10 = 0.0F; + } + + short short1 = 255; + int j = (int)(f8 * 255.0F); + int k = (int)(f9 * 255.0F); + int l = (int)(f10 * 255.0F); + this.lightmapColors[i] = short1 << 24 | j << 16 | k << 8 | l; + } + + this.lightmapTexture.updateDynamicTexture(); + this.lightmapUpdateNeeded = false; + } + } + + private float getNightVisionBrightness(EntityPlayer par1EntityPlayer, float par2) + { + int i = par1EntityPlayer.getActivePotionEffect(Potion.nightVision).getDuration(); + return i > 200 ? 1.0F : 0.7F + MathHelper.sin(((float)i - par2) * (float)Math.PI * 0.2F) * 0.3F; + } + + public void updateCameraAndRender(float par1) + { + this.mc.mcProfiler.startSection("lightTex"); + + if (this.lightmapUpdateNeeded) + { + this.updateLightmap(par1); + } + + this.mc.mcProfiler.endSection(); + boolean flag = Display.isActive(); + + if (!flag && this.mc.gameSettings.pauseOnLostFocus && (!this.mc.gameSettings.touchscreen || !Mouse.isButtonDown(1))) + { + if (Minecraft.getSystemTime() - this.prevFrameTime > 500L) + { + this.mc.displayInGameMenu(); + } + } + else + { + this.prevFrameTime = Minecraft.getSystemTime(); + } + + this.mc.mcProfiler.startSection("mouse"); + + if (this.mc.inGameHasFocus && flag) + { + this.mc.mouseHelper.mouseXYChange(); + float f1 = this.mc.gameSettings.mouseSensitivity * 0.6F + 0.2F; + float f2 = f1 * f1 * f1 * 8.0F; + float f3 = (float)this.mc.mouseHelper.deltaX * f2; + float f4 = (float)this.mc.mouseHelper.deltaY * f2; + byte b0 = 1; + + if (this.mc.gameSettings.invertMouse) + { + b0 = -1; + } + + if (this.mc.gameSettings.smoothCamera) + { + this.smoothCamYaw += f3; + this.smoothCamPitch += f4; + float f5 = par1 - this.smoothCamPartialTicks; + this.smoothCamPartialTicks = par1; + f3 = this.smoothCamFilterX * f5; + f4 = this.smoothCamFilterY * f5; + this.mc.thePlayer.setAngles(f3, f4 * (float)b0); + } + else + { + this.mc.thePlayer.setAngles(f3, f4 * (float)b0); + } + } + + this.mc.mcProfiler.endSection(); + + if (!this.mc.skipRenderWorld) + { + anaglyphEnable = this.mc.gameSettings.anaglyph; + final ScaledResolution scaledresolution = new ScaledResolution(this.mc.gameSettings, this.mc.displayWidth, this.mc.displayHeight); + int i = scaledresolution.getScaledWidth(); + int j = scaledresolution.getScaledHeight(); + final int k = Mouse.getX() * i / this.mc.displayWidth; + final int l = j - Mouse.getY() * j / this.mc.displayHeight - 1; + int i1 = this.mc.gameSettings.limitFramerate; + + if (this.mc.theWorld != null) + { + this.mc.mcProfiler.startSection("level"); + + if (this.mc.isFramerateLimitBelowMax()) + { + this.renderWorld(par1, this.renderEndNanoTime + (long)(1000000000 / i1)); + } + else + { + this.renderWorld(par1, 0L); + } + + if (OpenGlHelper.shadersSupported) + { + if (this.theShaderGroup != null) + { + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glPushMatrix(); + GL11.glLoadIdentity(); + this.theShaderGroup.loadShaderGroup(par1); + GL11.glPopMatrix(); + } + + this.mc.getFramebuffer().bindFramebuffer(true); + } + + this.renderEndNanoTime = System.nanoTime(); + this.mc.mcProfiler.endStartSection("gui"); + + if (!this.mc.gameSettings.hideGUI || this.mc.currentScreen != null) + { + GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); + this.mc.ingameGUI.renderGameOverlay(par1, this.mc.currentScreen != null, k, l); + } + + this.mc.mcProfiler.endSection(); + } + else + { + GL11.glViewport(0, 0, this.mc.displayWidth, this.mc.displayHeight); + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + this.setupOverlayRendering(); + this.renderEndNanoTime = System.nanoTime(); + } + + if (this.mc.currentScreen != null) + { + GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); + + try + { + this.mc.currentScreen.drawScreen(k, l, par1); + } + catch (Throwable throwable) + { + CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Rendering screen"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("Screen render details"); + crashreportcategory.addCrashSectionCallable("Screen name", new Callable() + { + private static final String __OBFID = "CL_00000948"; + public String call() + { + return EntityRenderer.this.mc.currentScreen.getClass().getCanonicalName(); + } + }); + crashreportcategory.addCrashSectionCallable("Mouse location", new Callable() + { + private static final String __OBFID = "CL_00000950"; + public String call() + { + return String.format("Scaled: (%d, %d). Absolute: (%d, %d)", new Object[] {Integer.valueOf(k), Integer.valueOf(l), Integer.valueOf(Mouse.getX()), Integer.valueOf(Mouse.getY())}); + } + }); + crashreportcategory.addCrashSectionCallable("Screen size", new Callable() + { + private static final String __OBFID = "CL_00000951"; + public String call() + { + return String.format("Scaled: (%d, %d). Absolute: (%d, %d). Scale factor of %d", new Object[] {Integer.valueOf(scaledresolution.getScaledWidth()), Integer.valueOf(scaledresolution.getScaledHeight()), Integer.valueOf(EntityRenderer.this.mc.displayWidth), Integer.valueOf(EntityRenderer.this.mc.displayHeight), Integer.valueOf(scaledresolution.getScaleFactor())}); + } + }); + throw new ReportedException(crashreport); + } + } + } + } + + public void renderWorld(float par1, long par2) + { + this.mc.mcProfiler.startSection("lightTex"); + + if (this.lightmapUpdateNeeded) + { + this.updateLightmap(par1); + } + + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.5F); + + if (this.mc.renderViewEntity == null) + { + this.mc.renderViewEntity = this.mc.thePlayer; + } + + this.mc.mcProfiler.endStartSection("pick"); + this.getMouseOver(par1); + EntityLivingBase entitylivingbase = this.mc.renderViewEntity; + RenderGlobal renderglobal = this.mc.renderGlobal; + EffectRenderer effectrenderer = this.mc.effectRenderer; + double d0 = entitylivingbase.lastTickPosX + (entitylivingbase.posX - entitylivingbase.lastTickPosX) * (double)par1; + double d1 = entitylivingbase.lastTickPosY + (entitylivingbase.posY - entitylivingbase.lastTickPosY) * (double)par1; + double d2 = entitylivingbase.lastTickPosZ + (entitylivingbase.posZ - entitylivingbase.lastTickPosZ) * (double)par1; + this.mc.mcProfiler.endStartSection("center"); + + for (int j = 0; j < 2; ++j) + { + if (this.mc.gameSettings.anaglyph) + { + anaglyphField = j; + + if (anaglyphField == 0) + { + GL11.glColorMask(false, true, true, false); + } + else + { + GL11.glColorMask(true, false, false, false); + } + } + + this.mc.mcProfiler.endStartSection("clear"); + GL11.glViewport(0, 0, this.mc.displayWidth, this.mc.displayHeight); + this.updateFogColor(par1); + GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); + GL11.glEnable(GL11.GL_CULL_FACE); + this.mc.mcProfiler.endStartSection("camera"); + this.setupCameraTransform(par1, j); + ActiveRenderInfo.updateRenderInfo(this.mc.thePlayer, this.mc.gameSettings.thirdPersonView == 2); + this.mc.mcProfiler.endStartSection("frustrum"); + ClippingHelperImpl.getInstance(); + + if (this.mc.gameSettings.renderDistanceChunks >= 4) + { + this.setupFog(-1, par1); + this.mc.mcProfiler.endStartSection("sky"); + renderglobal.renderSky(par1); + } + + GL11.glEnable(GL11.GL_FOG); + this.setupFog(1, par1); + + if (this.mc.gameSettings.ambientOcclusion != 0) + { + GL11.glShadeModel(GL11.GL_SMOOTH); + } + + this.mc.mcProfiler.endStartSection("culling"); + Frustrum frustrum = new Frustrum(); + frustrum.setPosition(d0, d1, d2); + this.mc.renderGlobal.clipRenderersByFrustum(frustrum, par1); + + if (j == 0) + { + this.mc.mcProfiler.endStartSection("updatechunks"); + + while (!this.mc.renderGlobal.updateRenderers(entitylivingbase, false) && par2 != 0L) + { + long k = par2 - System.nanoTime(); + + if (k < 0L || k > 1000000000L) + { + break; + } + } + } + + if (entitylivingbase.posY < 128.0D) + { + this.renderCloudsCheck(renderglobal, par1); + } + + this.mc.mcProfiler.endStartSection("prepareterrain"); + this.setupFog(0, par1); + GL11.glEnable(GL11.GL_FOG); + this.mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture); + RenderHelper.disableStandardItemLighting(); + this.mc.mcProfiler.endStartSection("terrain"); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glPushMatrix(); + renderglobal.sortAndRender(entitylivingbase, 0, (double)par1); + GL11.glShadeModel(GL11.GL_FLAT); + EntityPlayer entityplayer; + + if (this.debugViewDirection == 0) + { + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + RenderHelper.enableStandardItemLighting(); + this.mc.mcProfiler.endStartSection("entities"); + ForgeHooksClient.setRenderPass(0); + renderglobal.renderEntities(entitylivingbase, frustrum, par1); + ForgeHooksClient.setRenderPass(0); + // ToDo: Try and figure out how to make particles render sorted correctly.. {They render behind water} + this.enableLightmap((double)par1); + this.mc.mcProfiler.endStartSection("litParticles"); + effectrenderer.renderLitParticles(entitylivingbase, par1); + RenderHelper.disableStandardItemLighting(); + this.setupFog(0, par1); + this.mc.mcProfiler.endStartSection("particles"); + effectrenderer.renderParticles(entitylivingbase, par1); + this.disableLightmap((double)par1); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + + if (this.mc.objectMouseOver != null && entitylivingbase.isInsideOfMaterial(Material.water) && entitylivingbase instanceof EntityPlayer && !this.mc.gameSettings.hideGUI) + { + entityplayer = (EntityPlayer)entitylivingbase; + GL11.glDisable(GL11.GL_ALPHA_TEST); + this.mc.mcProfiler.endStartSection("outline"); + if (!ForgeHooksClient.onDrawBlockHighlight(renderglobal, entityplayer, mc.objectMouseOver, 0, entityplayer.inventory.getCurrentItem(), par1)) + { + renderglobal.drawSelectionBox(entityplayer, this.mc.objectMouseOver, 0, par1); + } + GL11.glEnable(GL11.GL_ALPHA_TEST); + } + } + + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glPopMatrix(); + + if (this.cameraZoom == 1.0D && entitylivingbase instanceof EntityPlayer && !this.mc.gameSettings.hideGUI && this.mc.objectMouseOver != null && !entitylivingbase.isInsideOfMaterial(Material.water)) + { + entityplayer = (EntityPlayer)entitylivingbase; + GL11.glDisable(GL11.GL_ALPHA_TEST); + this.mc.mcProfiler.endStartSection("outline"); + if (!ForgeHooksClient.onDrawBlockHighlight(renderglobal, entityplayer, mc.objectMouseOver, 0, entityplayer.inventory.getCurrentItem(), par1)) + { + renderglobal.drawSelectionBox(entityplayer, this.mc.objectMouseOver, 0, par1); + } + GL11.glEnable(GL11.GL_ALPHA_TEST); + } + + this.mc.mcProfiler.endStartSection("destroyProgress"); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 1, 1, 0); + renderglobal.drawBlockDamageTexture(Tessellator.instance, entitylivingbase, par1); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthMask(false); + GL11.glEnable(GL11.GL_CULL_FACE); + this.mc.mcProfiler.endStartSection("weather"); + this.renderRainSnow(par1); + GL11.glDepthMask(true); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_CULL_FACE); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); + this.setupFog(0, par1); + GL11.glEnable(GL11.GL_BLEND); + GL11.glDepthMask(false); + this.mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture); + + if (this.mc.gameSettings.fancyGraphics) + { + this.mc.mcProfiler.endStartSection("water"); + + if (this.mc.gameSettings.ambientOcclusion != 0) + { + GL11.glShadeModel(GL11.GL_SMOOTH); + } + + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + + if (this.mc.gameSettings.anaglyph) + { + if (anaglyphField == 0) + { + GL11.glColorMask(false, true, true, true); + } + else + { + GL11.glColorMask(true, false, false, true); + } + + renderglobal.sortAndRender(entitylivingbase, 1, (double)par1); + } + else + { + renderglobal.sortAndRender(entitylivingbase, 1, (double)par1); + } + + GL11.glDisable(GL11.GL_BLEND); + GL11.glShadeModel(GL11.GL_FLAT); + } + else + { + this.mc.mcProfiler.endStartSection("water"); + renderglobal.sortAndRender(entitylivingbase, 1, (double)par1); + } + + if (this.debugViewDirection == 0) //Only render if render pass 0 happens as well. + { + RenderHelper.enableStandardItemLighting(); + this.mc.mcProfiler.endStartSection("entities"); + ForgeHooksClient.setRenderPass(1); + renderglobal.renderEntities(entitylivingbase, frustrum, par1); + ForgeHooksClient.setRenderPass(-1); + RenderHelper.disableStandardItemLighting(); + } + + GL11.glDepthMask(true); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_FOG); + + if (entitylivingbase.posY >= 128.0D) + { + this.mc.mcProfiler.endStartSection("aboveClouds"); + this.renderCloudsCheck(renderglobal, par1); + } + + this.mc.mcProfiler.endStartSection("FRenderLast"); + ForgeHooksClient.dispatchRenderLast(renderglobal, par1); + + this.mc.mcProfiler.endStartSection("hand"); + + if (!ForgeHooksClient.renderFirstPersonHand(renderglobal, par1, j) && this.cameraZoom == 1.0D) + { + GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); + this.renderHand(par1, j); + } + + if (!this.mc.gameSettings.anaglyph) + { + this.mc.mcProfiler.endSection(); + return; + } + } + + GL11.glColorMask(true, true, true, false); + this.mc.mcProfiler.endSection(); + } + + private void renderCloudsCheck(RenderGlobal par1RenderGlobal, float par2) + { + if (this.mc.gameSettings.shouldRenderClouds()) + { + this.mc.mcProfiler.endStartSection("clouds"); + GL11.glPushMatrix(); + this.setupFog(0, par2); + GL11.glEnable(GL11.GL_FOG); + par1RenderGlobal.renderClouds(par2); + GL11.glDisable(GL11.GL_FOG); + this.setupFog(1, par2); + GL11.glPopMatrix(); + } + } + + private void addRainParticles() + { + float f = this.mc.theWorld.getRainStrength(1.0F); + + if (!this.mc.gameSettings.fancyGraphics) + { + f /= 2.0F; + } + + if (f != 0.0F) + { + this.random.setSeed((long)this.rendererUpdateCount * 312987231L); + EntityLivingBase entitylivingbase = this.mc.renderViewEntity; + WorldClient worldclient = this.mc.theWorld; + int i = MathHelper.floor_double(entitylivingbase.posX); + int j = MathHelper.floor_double(entitylivingbase.posY); + int k = MathHelper.floor_double(entitylivingbase.posZ); + byte b0 = 10; + double d0 = 0.0D; + double d1 = 0.0D; + double d2 = 0.0D; + int l = 0; + int i1 = (int)(100.0F * f * f); + + if (this.mc.gameSettings.particleSetting == 1) + { + i1 >>= 1; + } + else if (this.mc.gameSettings.particleSetting == 2) + { + i1 = 0; + } + + for (int j1 = 0; j1 < i1; ++j1) + { + int k1 = i + this.random.nextInt(b0) - this.random.nextInt(b0); + int l1 = k + this.random.nextInt(b0) - this.random.nextInt(b0); + int i2 = worldclient.getPrecipitationHeight(k1, l1); + Block block = worldclient.getBlock(k1, i2 - 1, l1); + BiomeGenBase biomegenbase = worldclient.getBiomeGenForCoords(k1, l1); + + if (i2 <= j + b0 && i2 >= j - b0 && biomegenbase.canSpawnLightningBolt() && biomegenbase.getFloatTemperature(k1, i2, l1) >= 0.15F) + { + float f1 = this.random.nextFloat(); + float f2 = this.random.nextFloat(); + + if (block.getMaterial() == Material.lava) + { + this.mc.effectRenderer.addEffect(new EntitySmokeFX(worldclient, (double)((float)k1 + f1), (double)((float)i2 + 0.1F) - block.getBlockBoundsMinY(), (double)((float)l1 + f2), 0.0D, 0.0D, 0.0D)); + } + else if (block.getMaterial() != Material.air) + { + ++l; + + if (this.random.nextInt(l) == 0) + { + d0 = (double)((float)k1 + f1); + d1 = (double)((float)i2 + 0.1F) - block.getBlockBoundsMinY(); + d2 = (double)((float)l1 + f2); + } + + this.mc.effectRenderer.addEffect(new EntityRainFX(worldclient, (double)((float)k1 + f1), (double)((float)i2 + 0.1F) - block.getBlockBoundsMinY(), (double)((float)l1 + f2))); + } + } + } + + if (l > 0 && this.random.nextInt(3) < this.rainSoundCounter++) + { + this.rainSoundCounter = 0; + + if (d1 > entitylivingbase.posY + 1.0D && worldclient.getPrecipitationHeight(MathHelper.floor_double(entitylivingbase.posX), MathHelper.floor_double(entitylivingbase.posZ)) > MathHelper.floor_double(entitylivingbase.posY)) + { + this.mc.theWorld.playSound(d0, d1, d2, "ambient.weather.rain", 0.1F, 0.5F, false); + } + else + { + this.mc.theWorld.playSound(d0, d1, d2, "ambient.weather.rain", 0.2F, 1.0F, false); + } + } + } + } + + protected void renderRainSnow(float par1) + { + IRenderHandler renderer = null; + if ((renderer = this.mc.theWorld.provider.getWeatherRenderer()) != null) + { + renderer.render(par1, this.mc.theWorld, mc); + return; + } + + float f1 = this.mc.theWorld.getRainStrength(par1); + + if (f1 > 0.0F) + { + this.enableLightmap((double)par1); + + if (this.rainXCoords == null) + { + this.rainXCoords = new float[1024]; + this.rainYCoords = new float[1024]; + + for (int i = 0; i < 32; ++i) + { + for (int j = 0; j < 32; ++j) + { + float f2 = (float)(j - 16); + float f3 = (float)(i - 16); + float f4 = MathHelper.sqrt_float(f2 * f2 + f3 * f3); + this.rainXCoords[i << 5 | j] = -f3 / f4; + this.rainYCoords[i << 5 | j] = f2 / f4; + } + } + } + + EntityLivingBase entitylivingbase = this.mc.renderViewEntity; + WorldClient worldclient = this.mc.theWorld; + int k2 = MathHelper.floor_double(entitylivingbase.posX); + int l2 = MathHelper.floor_double(entitylivingbase.posY); + int i3 = MathHelper.floor_double(entitylivingbase.posZ); + Tessellator tessellator = Tessellator.instance; + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glNormal3f(0.0F, 1.0F, 0.0F); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); + double d0 = entitylivingbase.lastTickPosX + (entitylivingbase.posX - entitylivingbase.lastTickPosX) * (double)par1; + double d1 = entitylivingbase.lastTickPosY + (entitylivingbase.posY - entitylivingbase.lastTickPosY) * (double)par1; + double d2 = entitylivingbase.lastTickPosZ + (entitylivingbase.posZ - entitylivingbase.lastTickPosZ) * (double)par1; + int k = MathHelper.floor_double(d1); + byte b0 = 5; + + if (this.mc.gameSettings.fancyGraphics) + { + b0 = 10; + } + + boolean flag = false; + byte b1 = -1; + float f5 = (float)this.rendererUpdateCount + par1; + + if (this.mc.gameSettings.fancyGraphics) + { + b0 = 10; + } + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + flag = false; + + for (int l = i3 - b0; l <= i3 + b0; ++l) + { + for (int i1 = k2 - b0; i1 <= k2 + b0; ++i1) + { + int j1 = (l - i3 + 16) * 32 + i1 - k2 + 16; + float f6 = this.rainXCoords[j1] * 0.5F; + float f7 = this.rainYCoords[j1] * 0.5F; + BiomeGenBase biomegenbase = worldclient.getBiomeGenForCoords(i1, l); + + if (biomegenbase.canSpawnLightningBolt() || biomegenbase.getEnableSnow()) + { + int k1 = worldclient.getPrecipitationHeight(i1, l); + int l1 = l2 - b0; + int i2 = l2 + b0; + + if (l1 < k1) + { + l1 = k1; + } + + if (i2 < k1) + { + i2 = k1; + } + + float f8 = 1.0F; + int j2 = k1; + + if (k1 < k) + { + j2 = k; + } + + if (l1 != i2) + { + this.random.setSeed((long)(i1 * i1 * 3121 + i1 * 45238971 ^ l * l * 418711 + l * 13761)); + float f9 = biomegenbase.getFloatTemperature(i1, l1, l); + float f10; + double d4; + + if (worldclient.getWorldChunkManager().getTemperatureAtHeight(f9, k1) >= 0.15F) + { + if (b1 != 0) + { + if (b1 >= 0) + { + tessellator.draw(); + } + + b1 = 0; + this.mc.getTextureManager().bindTexture(locationRainPng); + tessellator.startDrawingQuads(); + } + + f10 = ((float)(this.rendererUpdateCount + i1 * i1 * 3121 + i1 * 45238971 + l * l * 418711 + l * 13761 & 31) + par1) / 32.0F * (3.0F + this.random.nextFloat()); + double d3 = (double)((float)i1 + 0.5F) - entitylivingbase.posX; + d4 = (double)((float)l + 0.5F) - entitylivingbase.posZ; + float f12 = MathHelper.sqrt_double(d3 * d3 + d4 * d4) / (float)b0; + float f13 = 1.0F; + tessellator.setBrightness(worldclient.getLightBrightnessForSkyBlocks(i1, j2, l, 0)); + tessellator.setColorRGBA_F(f13, f13, f13, ((1.0F - f12 * f12) * 0.5F + 0.5F) * f1); + tessellator.setTranslation(-d0 * 1.0D, -d1 * 1.0D, -d2 * 1.0D); + tessellator.addVertexWithUV((double)((float)i1 - f6) + 0.5D, (double)l1, (double)((float)l - f7) + 0.5D, (double)(0.0F * f8), (double)((float)l1 * f8 / 4.0F + f10 * f8)); + tessellator.addVertexWithUV((double)((float)i1 + f6) + 0.5D, (double)l1, (double)((float)l + f7) + 0.5D, (double)(1.0F * f8), (double)((float)l1 * f8 / 4.0F + f10 * f8)); + tessellator.addVertexWithUV((double)((float)i1 + f6) + 0.5D, (double)i2, (double)((float)l + f7) + 0.5D, (double)(1.0F * f8), (double)((float)i2 * f8 / 4.0F + f10 * f8)); + tessellator.addVertexWithUV((double)((float)i1 - f6) + 0.5D, (double)i2, (double)((float)l - f7) + 0.5D, (double)(0.0F * f8), (double)((float)i2 * f8 / 4.0F + f10 * f8)); + tessellator.setTranslation(0.0D, 0.0D, 0.0D); + } + else + { + if (b1 != 1) + { + if (b1 >= 0) + { + tessellator.draw(); + } + + b1 = 1; + this.mc.getTextureManager().bindTexture(locationSnowPng); + tessellator.startDrawingQuads(); + } + + f10 = ((float)(this.rendererUpdateCount & 511) + par1) / 512.0F; + float f16 = this.random.nextFloat() + f5 * 0.01F * (float)this.random.nextGaussian(); + float f11 = this.random.nextFloat() + f5 * (float)this.random.nextGaussian() * 0.001F; + d4 = (double)((float)i1 + 0.5F) - entitylivingbase.posX; + double d5 = (double)((float)l + 0.5F) - entitylivingbase.posZ; + float f14 = MathHelper.sqrt_double(d4 * d4 + d5 * d5) / (float)b0; + float f15 = 1.0F; + tessellator.setBrightness((worldclient.getLightBrightnessForSkyBlocks(i1, j2, l, 0) * 3 + 15728880) / 4); + tessellator.setColorRGBA_F(f15, f15, f15, ((1.0F - f14 * f14) * 0.3F + 0.5F) * f1); + tessellator.setTranslation(-d0 * 1.0D, -d1 * 1.0D, -d2 * 1.0D); + tessellator.addVertexWithUV((double)((float)i1 - f6) + 0.5D, (double)l1, (double)((float)l - f7) + 0.5D, (double)(0.0F * f8 + f16), (double)((float)l1 * f8 / 4.0F + f10 * f8 + f11)); + tessellator.addVertexWithUV((double)((float)i1 + f6) + 0.5D, (double)l1, (double)((float)l + f7) + 0.5D, (double)(1.0F * f8 + f16), (double)((float)l1 * f8 / 4.0F + f10 * f8 + f11)); + tessellator.addVertexWithUV((double)((float)i1 + f6) + 0.5D, (double)i2, (double)((float)l + f7) + 0.5D, (double)(1.0F * f8 + f16), (double)((float)i2 * f8 / 4.0F + f10 * f8 + f11)); + tessellator.addVertexWithUV((double)((float)i1 - f6) + 0.5D, (double)i2, (double)((float)l - f7) + 0.5D, (double)(0.0F * f8 + f16), (double)((float)i2 * f8 / 4.0F + f10 * f8 + f11)); + tessellator.setTranslation(0.0D, 0.0D, 0.0D); + } + } + } + } + } + + if (b1 >= 0) + { + tessellator.draw(); + } + + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glDisable(GL11.GL_BLEND); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); + this.disableLightmap((double)par1); + } + } + + public void setupOverlayRendering() + { + ScaledResolution scaledresolution = new ScaledResolution(this.mc.gameSettings, this.mc.displayWidth, this.mc.displayHeight); + GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + GL11.glOrtho(0.0D, scaledresolution.getScaledWidth_double(), scaledresolution.getScaledHeight_double(), 0.0D, 1000.0D, 3000.0D); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + GL11.glTranslatef(0.0F, 0.0F, -2000.0F); + } + + private void updateFogColor(float par1) + { + WorldClient worldclient = this.mc.theWorld; + EntityLivingBase entitylivingbase = this.mc.renderViewEntity; + float f1 = 0.25F + 0.75F * (float)this.mc.gameSettings.renderDistanceChunks / 16.0F; + f1 = 1.0F - (float)Math.pow((double)f1, 0.25D); + Vec3 vec3 = worldclient.getSkyColor(this.mc.renderViewEntity, par1); + float f2 = (float)vec3.xCoord; + float f3 = (float)vec3.yCoord; + float f4 = (float)vec3.zCoord; + Vec3 vec31 = worldclient.getFogColor(par1); + this.fogColorRed = (float)vec31.xCoord; + this.fogColorGreen = (float)vec31.yCoord; + this.fogColorBlue = (float)vec31.zCoord; + float f5; + + if (this.mc.gameSettings.renderDistanceChunks >= 4) + { + Vec3 vec32 = MathHelper.sin(worldclient.getCelestialAngleRadians(par1)) > 0.0F ? worldclient.getWorldVec3Pool().getVecFromPool(-1.0D, 0.0D, 0.0D) : worldclient.getWorldVec3Pool().getVecFromPool(1.0D, 0.0D, 0.0D); + f5 = (float)entitylivingbase.getLook(par1).dotProduct(vec32); + + if (f5 < 0.0F) + { + f5 = 0.0F; + } + + if (f5 > 0.0F) + { + float[] afloat = worldclient.provider.calcSunriseSunsetColors(worldclient.getCelestialAngle(par1), par1); + + if (afloat != null) + { + f5 *= afloat[3]; + this.fogColorRed = this.fogColorRed * (1.0F - f5) + afloat[0] * f5; + this.fogColorGreen = this.fogColorGreen * (1.0F - f5) + afloat[1] * f5; + this.fogColorBlue = this.fogColorBlue * (1.0F - f5) + afloat[2] * f5; + } + } + } + + this.fogColorRed += (f2 - this.fogColorRed) * f1; + this.fogColorGreen += (f3 - this.fogColorGreen) * f1; + this.fogColorBlue += (f4 - this.fogColorBlue) * f1; + float f8 = worldclient.getRainStrength(par1); + float f9; + + if (f8 > 0.0F) + { + f5 = 1.0F - f8 * 0.5F; + f9 = 1.0F - f8 * 0.4F; + this.fogColorRed *= f5; + this.fogColorGreen *= f5; + this.fogColorBlue *= f9; + } + + f5 = worldclient.getWeightedThunderStrength(par1); + + if (f5 > 0.0F) + { + f9 = 1.0F - f5 * 0.5F; + this.fogColorRed *= f9; + this.fogColorGreen *= f9; + this.fogColorBlue *= f9; + } + + Block block = ActiveRenderInfo.getBlockAtEntityViewpoint(this.mc.theWorld, entitylivingbase, par1); + float f10; + + if (this.cloudFog) + { + Vec3 vec33 = worldclient.getCloudColour(par1); + this.fogColorRed = (float)vec33.xCoord; + this.fogColorGreen = (float)vec33.yCoord; + this.fogColorBlue = (float)vec33.zCoord; + } + else if (block.getMaterial() == Material.water) + { + f10 = (float)EnchantmentHelper.getRespiration(entitylivingbase) * 0.2F; + this.fogColorRed = 0.02F + f10; + this.fogColorGreen = 0.02F + f10; + this.fogColorBlue = 0.2F + f10; + } + else if (block.getMaterial() == Material.lava) + { + this.fogColorRed = 0.6F; + this.fogColorGreen = 0.1F; + this.fogColorBlue = 0.0F; + } + + f10 = this.fogColor2 + (this.fogColor1 - this.fogColor2) * par1; + this.fogColorRed *= f10; + this.fogColorGreen *= f10; + this.fogColorBlue *= f10; + double d0 = (entitylivingbase.lastTickPosY + (entitylivingbase.posY - entitylivingbase.lastTickPosY) * (double)par1) * worldclient.provider.getVoidFogYFactor(); + + if (entitylivingbase.isPotionActive(Potion.blindness)) + { + int i = entitylivingbase.getActivePotionEffect(Potion.blindness).getDuration(); + + if (i < 20) + { + d0 *= (double)(1.0F - (float)i / 20.0F); + } + else + { + d0 = 0.0D; + } + } + + if (d0 < 1.0D) + { + if (d0 < 0.0D) + { + d0 = 0.0D; + } + + d0 *= d0; + this.fogColorRed = (float)((double)this.fogColorRed * d0); + this.fogColorGreen = (float)((double)this.fogColorGreen * d0); + this.fogColorBlue = (float)((double)this.fogColorBlue * d0); + } + + float f11; + + if (this.bossColorModifier > 0.0F) + { + f11 = this.bossColorModifierPrev + (this.bossColorModifier - this.bossColorModifierPrev) * par1; + this.fogColorRed = this.fogColorRed * (1.0F - f11) + this.fogColorRed * 0.7F * f11; + this.fogColorGreen = this.fogColorGreen * (1.0F - f11) + this.fogColorGreen * 0.6F * f11; + this.fogColorBlue = this.fogColorBlue * (1.0F - f11) + this.fogColorBlue * 0.6F * f11; + } + + float f6; + + if (entitylivingbase.isPotionActive(Potion.nightVision)) + { + f11 = this.getNightVisionBrightness(this.mc.thePlayer, par1); + f6 = 1.0F / this.fogColorRed; + + if (f6 > 1.0F / this.fogColorGreen) + { + f6 = 1.0F / this.fogColorGreen; + } + + if (f6 > 1.0F / this.fogColorBlue) + { + f6 = 1.0F / this.fogColorBlue; + } + + this.fogColorRed = this.fogColorRed * (1.0F - f11) + this.fogColorRed * f6 * f11; + this.fogColorGreen = this.fogColorGreen * (1.0F - f11) + this.fogColorGreen * f6 * f11; + this.fogColorBlue = this.fogColorBlue * (1.0F - f11) + this.fogColorBlue * f6 * f11; + } + + if (this.mc.gameSettings.anaglyph) + { + f11 = (this.fogColorRed * 30.0F + this.fogColorGreen * 59.0F + this.fogColorBlue * 11.0F) / 100.0F; + f6 = (this.fogColorRed * 30.0F + this.fogColorGreen * 70.0F) / 100.0F; + float f7 = (this.fogColorRed * 30.0F + this.fogColorBlue * 70.0F) / 100.0F; + this.fogColorRed = f11; + this.fogColorGreen = f6; + this.fogColorBlue = f7; + } + + GL11.glClearColor(this.fogColorRed, this.fogColorGreen, this.fogColorBlue, 0.0F); + } + + private void setupFog(int par1, float par2) + { + EntityLivingBase entitylivingbase = this.mc.renderViewEntity; + boolean flag = false; + + if (entitylivingbase instanceof EntityPlayer) + { + flag = ((EntityPlayer)entitylivingbase).capabilities.isCreativeMode; + } + + if (par1 == 999) + { + GL11.glFog(GL11.GL_FOG_COLOR, this.setFogColorBuffer(0.0F, 0.0F, 0.0F, 1.0F)); + GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_LINEAR); + GL11.glFogf(GL11.GL_FOG_START, 0.0F); + GL11.glFogf(GL11.GL_FOG_END, 8.0F); + + if (GLContext.getCapabilities().GL_NV_fog_distance) + { + GL11.glFogi(34138, 34139); + } + + GL11.glFogf(GL11.GL_FOG_START, 0.0F); + } + else + { + GL11.glFog(GL11.GL_FOG_COLOR, this.setFogColorBuffer(this.fogColorRed, this.fogColorGreen, this.fogColorBlue, 1.0F)); + GL11.glNormal3f(0.0F, -1.0F, 0.0F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + Block block = ActiveRenderInfo.getBlockAtEntityViewpoint(this.mc.theWorld, entitylivingbase, par2); + float f1; + + if (entitylivingbase.isPotionActive(Potion.blindness)) + { + f1 = 5.0F; + int j = entitylivingbase.getActivePotionEffect(Potion.blindness).getDuration(); + + if (j < 20) + { + f1 = 5.0F + (this.farPlaneDistance - 5.0F) * (1.0F - (float)j / 20.0F); + } + + GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_LINEAR); + + if (par1 < 0) + { + GL11.glFogf(GL11.GL_FOG_START, 0.0F); + GL11.glFogf(GL11.GL_FOG_END, f1 * 0.8F); + } + else + { + GL11.glFogf(GL11.GL_FOG_START, f1 * 0.25F); + GL11.glFogf(GL11.GL_FOG_END, f1); + } + + if (GLContext.getCapabilities().GL_NV_fog_distance) + { + GL11.glFogi(34138, 34139); + } + } + else if (this.cloudFog) + { + GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_EXP); + GL11.glFogf(GL11.GL_FOG_DENSITY, 0.1F); + } + else if (block.getMaterial() == Material.water) + { + GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_EXP); + + if (entitylivingbase.isPotionActive(Potion.waterBreathing)) + { + GL11.glFogf(GL11.GL_FOG_DENSITY, 0.05F); + } + else + { + GL11.glFogf(GL11.GL_FOG_DENSITY, 0.1F - (float)EnchantmentHelper.getRespiration(entitylivingbase) * 0.03F); + } + } + else if (block.getMaterial() == Material.lava) + { + GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_EXP); + GL11.glFogf(GL11.GL_FOG_DENSITY, 2.0F); + } + else + { + f1 = this.farPlaneDistance; + + if (this.mc.theWorld.provider.getWorldHasVoidParticles() && !flag) + { + double d0 = (double)((entitylivingbase.getBrightnessForRender(par2) & 15728640) >> 20) / 16.0D + (entitylivingbase.lastTickPosY + (entitylivingbase.posY - entitylivingbase.lastTickPosY) * (double)par2 + 4.0D) / 32.0D; + + if (d0 < 1.0D) + { + if (d0 < 0.0D) + { + d0 = 0.0D; + } + + d0 *= d0; + float f2 = 100.0F * (float)d0; + + if (f2 < 5.0F) + { + f2 = 5.0F; + } + + if (f1 > f2) + { + f1 = f2; + } + } + } + + GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_LINEAR); + + if (par1 < 0) + { + GL11.glFogf(GL11.GL_FOG_START, 0.0F); + GL11.glFogf(GL11.GL_FOG_END, f1); + } + else + { + GL11.glFogf(GL11.GL_FOG_START, f1 * 0.75F); + GL11.glFogf(GL11.GL_FOG_END, f1); + } + + if (GLContext.getCapabilities().GL_NV_fog_distance) + { + GL11.glFogi(34138, 34139); + } + + if (this.mc.theWorld.provider.doesXZShowFog((int)entitylivingbase.posX, (int)entitylivingbase.posZ)) + { + GL11.glFogf(GL11.GL_FOG_START, f1 * 0.05F); + GL11.glFogf(GL11.GL_FOG_END, Math.min(f1, 192.0F) * 0.5F); + } + } + + GL11.glEnable(GL11.GL_COLOR_MATERIAL); + GL11.glColorMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT); + } + } + + private FloatBuffer setFogColorBuffer(float par1, float par2, float par3, float par4) + { + this.fogColorBuffer.clear(); + this.fogColorBuffer.put(par1).put(par2).put(par3).put(par4); + this.fogColorBuffer.flip(); + return this.fogColorBuffer; + } + + public MapItemRenderer getMapItemRenderer() + { + return this.theMapItemRenderer; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/EntitySorter.java b/src/main/java/net/minecraft/client/renderer/EntitySorter.java new file mode 100644 index 0000000..ee2d3cc --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/EntitySorter.java @@ -0,0 +1,38 @@ +package net.minecraft.client.renderer; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Comparator; +import net.minecraft.entity.Entity; + +@SideOnly(Side.CLIENT) +public class EntitySorter implements Comparator +{ + private double entityPosX; + private double entityPosY; + private double entityPosZ; + private static final String __OBFID = "CL_00000944"; + + public EntitySorter(Entity par1Entity) + { + this.entityPosX = -par1Entity.posX; + this.entityPosY = -par1Entity.posY; + this.entityPosZ = -par1Entity.posZ; + } + + public int compare(WorldRenderer par1WorldRenderer, WorldRenderer par2WorldRenderer) + { + double d0 = (double)par1WorldRenderer.posXPlus + this.entityPosX; + double d1 = (double)par1WorldRenderer.posYPlus + this.entityPosY; + double d2 = (double)par1WorldRenderer.posZPlus + this.entityPosZ; + double d3 = (double)par2WorldRenderer.posXPlus + this.entityPosX; + double d4 = (double)par2WorldRenderer.posYPlus + this.entityPosY; + double d5 = (double)par2WorldRenderer.posZPlus + this.entityPosZ; + return (int)((d0 * d0 + d1 * d1 + d2 * d2 - (d3 * d3 + d4 * d4 + d5 * d5)) * 1024.0D); + } + + public int compare(Object par1Obj, Object par2Obj) + { + return this.compare((WorldRenderer)par1Obj, (WorldRenderer)par2Obj); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/GLAllocation.java b/src/main/java/net/minecraft/client/renderer/GLAllocation.java new file mode 100644 index 0000000..1751b88 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/GLAllocation.java @@ -0,0 +1,63 @@ +package net.minecraft.client.renderer; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class GLAllocation +{ + private static final Map mapDisplayLists = new HashMap(); + private static final List listDummy = new ArrayList(); + private static final String __OBFID = "CL_00000630"; + + public static synchronized int generateDisplayLists(int par0) + { + int j = GL11.glGenLists(par0); + mapDisplayLists.put(Integer.valueOf(j), Integer.valueOf(par0)); + return j; + } + + public static synchronized void deleteDisplayLists(int par0) + { + GL11.glDeleteLists(par0, ((Integer)mapDisplayLists.remove(Integer.valueOf(par0))).intValue()); + } + + public static synchronized void deleteTexturesAndDisplayLists() + { + Iterator iterator = mapDisplayLists.entrySet().iterator(); + + while (iterator.hasNext()) + { + Entry entry = (Entry)iterator.next(); + GL11.glDeleteLists(((Integer)entry.getKey()).intValue(), ((Integer)entry.getValue()).intValue()); + } + + mapDisplayLists.clear(); + } + + public static synchronized ByteBuffer createDirectByteBuffer(int par0) + { + return ByteBuffer.allocateDirect(par0).order(ByteOrder.nativeOrder()); + } + + public static IntBuffer createDirectIntBuffer(int par0) + { + return createDirectByteBuffer(par0 << 2).asIntBuffer(); + } + + public static FloatBuffer createDirectFloatBuffer(int par0) + { + return createDirectByteBuffer(par0 << 2).asFloatBuffer(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/IImageBuffer.java b/src/main/java/net/minecraft/client/renderer/IImageBuffer.java new file mode 100644 index 0000000..4f23783 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/IImageBuffer.java @@ -0,0 +1,11 @@ +package net.minecraft.client.renderer; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.awt.image.BufferedImage; + +@SideOnly(Side.CLIENT) +public interface IImageBuffer +{ + BufferedImage parseUserSkin(BufferedImage var1); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/IconFlipped.java b/src/main/java/net/minecraft/client/renderer/IconFlipped.java new file mode 100644 index 0000000..da91ca6 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/IconFlipped.java @@ -0,0 +1,68 @@ +package net.minecraft.client.renderer; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.util.IIcon; + +@SideOnly(Side.CLIENT) +public class IconFlipped implements IIcon +{ + private final IIcon baseIcon; + private final boolean flipU; + private final boolean flipV; + private static final String __OBFID = "CL_00001511"; + + public IconFlipped(IIcon par1Icon, boolean par2, boolean par3) + { + this.baseIcon = par1Icon; + this.flipU = par2; + this.flipV = par3; + } + + public int getIconWidth() + { + return this.baseIcon.getIconWidth(); + } + + public int getIconHeight() + { + return this.baseIcon.getIconHeight(); + } + + public float getMinU() + { + return this.flipU ? this.baseIcon.getMaxU() : this.baseIcon.getMinU(); + } + + public float getMaxU() + { + return this.flipU ? this.baseIcon.getMinU() : this.baseIcon.getMaxU(); + } + + public float getInterpolatedU(double par1) + { + float f = this.getMaxU() - this.getMinU(); + return this.getMinU() + f * ((float)par1 / 16.0F); + } + + public float getMinV() + { + return this.flipV ? this.baseIcon.getMinV() : this.baseIcon.getMinV(); + } + + public float getMaxV() + { + return this.flipV ? this.baseIcon.getMinV() : this.baseIcon.getMaxV(); + } + + public float getInterpolatedV(double par1) + { + float f = this.getMaxV() - this.getMinV(); + return this.getMinV() + f * ((float)par1 / 16.0F); + } + + public String getIconName() + { + return this.baseIcon.getIconName(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/ImageBufferDownload.java b/src/main/java/net/minecraft/client/renderer/ImageBufferDownload.java new file mode 100644 index 0000000..7bf0085 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/ImageBufferDownload.java @@ -0,0 +1,82 @@ +package net.minecraft.client.renderer; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.awt.Graphics; +import java.awt.image.BufferedImage; +import java.awt.image.DataBufferInt; +import java.awt.image.ImageObserver; + +@SideOnly(Side.CLIENT) +public class ImageBufferDownload implements IImageBuffer +{ + private int[] imageData; + private int imageWidth; + private int imageHeight; + private static final String __OBFID = "CL_00000956"; + + public BufferedImage parseUserSkin(BufferedImage par1BufferedImage) + { + if (par1BufferedImage == null) + { + return null; + } + else + { + this.imageWidth = 64; + this.imageHeight = 32; + BufferedImage bufferedimage1 = new BufferedImage(this.imageWidth, this.imageHeight, 2); + Graphics graphics = bufferedimage1.getGraphics(); + graphics.drawImage(par1BufferedImage, 0, 0, (ImageObserver)null); + graphics.dispose(); + this.imageData = ((DataBufferInt)bufferedimage1.getRaster().getDataBuffer()).getData(); + this.setAreaOpaque(0, 0, 32, 16); + this.setAreaTransparent(32, 0, 64, 32); + this.setAreaOpaque(0, 16, 64, 32); + return bufferedimage1; + } + } + + private void setAreaTransparent(int par1, int par2, int par3, int par4) + { + if (!this.hasTransparency(par1, par2, par3, par4)) + { + for (int i1 = par1; i1 < par3; ++i1) + { + for (int j1 = par2; j1 < par4; ++j1) + { + this.imageData[i1 + j1 * this.imageWidth] &= 16777215; + } + } + } + } + + private void setAreaOpaque(int par1, int par2, int par3, int par4) + { + for (int i1 = par1; i1 < par3; ++i1) + { + for (int j1 = par2; j1 < par4; ++j1) + { + this.imageData[i1 + j1 * this.imageWidth] |= -16777216; + } + } + } + + private boolean hasTransparency(int par1, int par2, int par3, int par4) + { + for (int i1 = par1; i1 < par3; ++i1) + { + for (int j1 = par2; j1 < par4; ++j1) + { + int k1 = this.imageData[i1 + j1 * this.imageWidth]; + + if ((k1 >> 24 & 255) < 128) + { + return true; + } + } + } + + return false; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/InventoryEffectRenderer.java b/src/main/java/net/minecraft/client/renderer/InventoryEffectRenderer.java new file mode 100644 index 0000000..175c6dd --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/InventoryEffectRenderer.java @@ -0,0 +1,99 @@ +package net.minecraft.client.renderer; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Collection; +import java.util.Iterator; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.resources.I18n; +import net.minecraft.inventory.Container; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public abstract class InventoryEffectRenderer extends GuiContainer +{ + private boolean field_147045_u; + private static final String __OBFID = "CL_00000755"; + + public InventoryEffectRenderer(Container par1Container) + { + super(par1Container); + } + + public void initGui() + { + super.initGui(); + + if (!this.mc.thePlayer.getActivePotionEffects().isEmpty()) + { + this.guiLeft = 160 + (this.width - this.xSize - 200) / 2; + this.field_147045_u = true; + } + } + + public void drawScreen(int par1, int par2, float par3) + { + super.drawScreen(par1, par2, par3); + + if (this.field_147045_u) + { + this.func_147044_g(); + } + } + + private void func_147044_g() + { + int i = this.guiLeft - 124; + int j = this.guiTop; + boolean flag = true; + Collection collection = this.mc.thePlayer.getActivePotionEffects(); + + if (!collection.isEmpty()) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_LIGHTING); + int k = 33; + + if (collection.size() > 5) + { + k = 132 / (collection.size() - 1); + } + + for (Iterator iterator = this.mc.thePlayer.getActivePotionEffects().iterator(); iterator.hasNext(); j += k) + { + PotionEffect potioneffect = (PotionEffect)iterator.next(); + Potion potion = Potion.potionTypes[potioneffect.getPotionID()]; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(field_147001_a); + this.drawTexturedModalRect(i, j, 0, 166, 140, 32); + + if (potion.hasStatusIcon()) + { + int l = potion.getStatusIconIndex(); + this.drawTexturedModalRect(i + 6, j + 7, 0 + l % 8 * 18, 198 + l / 8 * 18, 18, 18); + } + + String s1 = I18n.format(potion.getName(), new Object[0]); + + if (potioneffect.getAmplifier() == 1) + { + s1 = s1 + " II"; + } + else if (potioneffect.getAmplifier() == 2) + { + s1 = s1 + " III"; + } + else if (potioneffect.getAmplifier() == 3) + { + s1 = s1 + " IV"; + } + + this.fontRendererObj.drawStringWithShadow(s1, i + 10 + 18, j + 6, 16777215); + String s = Potion.getDurationString(potioneffect); + this.fontRendererObj.drawStringWithShadow(s, i + 10 + 18, j + 6 + 10, 8355711); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/ItemRenderer.java b/src/main/java/net/minecraft/client/renderer/ItemRenderer.java new file mode 100644 index 0000000..a18cbc1 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/ItemRenderer.java @@ -0,0 +1,728 @@ +package net.minecraft.client.renderer; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityClientPlayerMP; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.entity.RenderPlayer; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.client.renderer.texture.TextureUtil; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.EnumAction; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemCloth; +import net.minecraft.item.ItemMap; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.storage.MapData; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import net.minecraftforge.client.ForgeHooksClient; +import net.minecraftforge.client.IItemRenderer; +import net.minecraftforge.client.IItemRenderer.ItemRenderType; +import net.minecraftforge.client.MinecraftForgeClient; +import static net.minecraftforge.client.IItemRenderer.ItemRenderType.*; +import static net.minecraftforge.client.IItemRenderer.ItemRendererHelper.*; + +@SideOnly(Side.CLIENT) +public class ItemRenderer +{ + private static final ResourceLocation RES_ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png"); + private static final ResourceLocation RES_MAP_BACKGROUND = new ResourceLocation("textures/map/map_background.png"); + private static final ResourceLocation RES_UNDERWATER_OVERLAY = new ResourceLocation("textures/misc/underwater.png"); + private Minecraft mc; + private ItemStack itemToRender; + private float equippedProgress; + private float prevEquippedProgress; + private RenderBlocks renderBlocksIr = new RenderBlocks(); + private int equippedItemSlot = -1; + private static final String __OBFID = "CL_00000953"; + + public ItemRenderer(Minecraft par1Minecraft) + { + this.mc = par1Minecraft; + } + + public void renderItem(EntityLivingBase par1EntityLivingBase, ItemStack par2ItemStack, int par3) + { + this.renderItem(par1EntityLivingBase, par2ItemStack, par3, EQUIPPED); + } + + public void renderItem(EntityLivingBase par1EntityLivingBase, ItemStack par2ItemStack, int par3, ItemRenderType type) + { + GL11.glPushMatrix(); + TextureManager texturemanager = this.mc.getTextureManager(); + Item item = par2ItemStack.getItem(); + Block block = Block.getBlockFromItem(item); + + IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(par2ItemStack, type); + if (customRenderer != null) + { + texturemanager.bindTexture(texturemanager.getResourceLocation(par2ItemStack.getItemSpriteNumber())); + ForgeHooksClient.renderEquippedItem(type, customRenderer, renderBlocksIr, par1EntityLivingBase, par2ItemStack); + } + else if (par2ItemStack.getItemSpriteNumber() == 0 && item instanceof ItemBlock && RenderBlocks.renderItemIn3d(block.getRenderType())) + { + texturemanager.bindTexture(texturemanager.getResourceLocation(0)); + + if (par2ItemStack != null && par2ItemStack.getItem() instanceof ItemCloth) + { + GL11.glEnable(GL11.GL_BLEND); + GL11.glDepthMask(false); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + this.renderBlocksIr.renderBlockAsItem(block, par2ItemStack.getItemDamage(), 1.0F); + GL11.glDepthMask(true); + GL11.glDisable(GL11.GL_BLEND); + } + else + { + this.renderBlocksIr.renderBlockAsItem(block, par2ItemStack.getItemDamage(), 1.0F); + } + } + else + { + IIcon iicon = par1EntityLivingBase.getItemIcon(par2ItemStack, par3); + + if (iicon == null) + { + GL11.glPopMatrix(); + return; + } + + texturemanager.bindTexture(texturemanager.getResourceLocation(par2ItemStack.getItemSpriteNumber())); + TextureUtil.func_147950_a(false, false); + Tessellator tessellator = Tessellator.instance; + float f = iicon.getMinU(); + float f1 = iicon.getMaxU(); + float f2 = iicon.getMinV(); + float f3 = iicon.getMaxV(); + float f4 = 0.0F; + float f5 = 0.3F; + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glTranslatef(-f4, -f5, 0.0F); + float f6 = 1.5F; + GL11.glScalef(f6, f6, f6); + GL11.glRotatef(50.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(335.0F, 0.0F, 0.0F, 1.0F); + GL11.glTranslatef(-0.9375F, -0.0625F, 0.0F); + renderItemIn2D(tessellator, f1, f2, f, f3, iicon.getIconWidth(), iicon.getIconHeight(), 0.0625F); + + if (par2ItemStack.hasEffect(par3)) + { + GL11.glDepthFunc(GL11.GL_EQUAL); + GL11.glDisable(GL11.GL_LIGHTING); + texturemanager.bindTexture(RES_ITEM_GLINT); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(768, 1, 1, 0); + float f7 = 0.76F; + GL11.glColor4f(0.5F * f7, 0.25F * f7, 0.8F * f7, 1.0F); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glPushMatrix(); + float f8 = 0.125F; + GL11.glScalef(f8, f8, f8); + float f9 = (float)(Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F; + GL11.glTranslatef(f9, 0.0F, 0.0F); + GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F); + renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glScalef(f8, f8, f8); + f9 = (float)(Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F; + GL11.glTranslatef(-f9, 0.0F, 0.0F); + GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); + renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F); + GL11.glPopMatrix(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDepthFunc(GL11.GL_LEQUAL); + } + + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + texturemanager.bindTexture(texturemanager.getResourceLocation(par2ItemStack.getItemSpriteNumber())); + TextureUtil.func_147945_b(); + } + + GL11.glPopMatrix(); + } + + public static void renderItemIn2D(Tessellator par0Tessellator, float par1, float par2, float par3, float par4, int par5, int par6, float par7) + { + par0Tessellator.startDrawingQuads(); + par0Tessellator.setNormal(0.0F, 0.0F, 1.0F); + par0Tessellator.addVertexWithUV(0.0D, 0.0D, 0.0D, (double)par1, (double)par4); + par0Tessellator.addVertexWithUV(1.0D, 0.0D, 0.0D, (double)par3, (double)par4); + par0Tessellator.addVertexWithUV(1.0D, 1.0D, 0.0D, (double)par3, (double)par2); + par0Tessellator.addVertexWithUV(0.0D, 1.0D, 0.0D, (double)par1, (double)par2); + par0Tessellator.draw(); + par0Tessellator.startDrawingQuads(); + par0Tessellator.setNormal(0.0F, 0.0F, -1.0F); + par0Tessellator.addVertexWithUV(0.0D, 1.0D, (double)(0.0F - par7), (double)par1, (double)par2); + par0Tessellator.addVertexWithUV(1.0D, 1.0D, (double)(0.0F - par7), (double)par3, (double)par2); + par0Tessellator.addVertexWithUV(1.0D, 0.0D, (double)(0.0F - par7), (double)par3, (double)par4); + par0Tessellator.addVertexWithUV(0.0D, 0.0D, (double)(0.0F - par7), (double)par1, (double)par4); + par0Tessellator.draw(); + float f5 = 0.5F * (par1 - par3) / (float)par5; + float f6 = 0.5F * (par4 - par2) / (float)par6; + par0Tessellator.startDrawingQuads(); + par0Tessellator.setNormal(-1.0F, 0.0F, 0.0F); + int k; + float f7; + float f8; + + for (k = 0; k < par5; ++k) + { + f7 = (float)k / (float)par5; + f8 = par1 + (par3 - par1) * f7 - f5; + par0Tessellator.addVertexWithUV((double)f7, 0.0D, (double)(0.0F - par7), (double)f8, (double)par4); + par0Tessellator.addVertexWithUV((double)f7, 0.0D, 0.0D, (double)f8, (double)par4); + par0Tessellator.addVertexWithUV((double)f7, 1.0D, 0.0D, (double)f8, (double)par2); + par0Tessellator.addVertexWithUV((double)f7, 1.0D, (double)(0.0F - par7), (double)f8, (double)par2); + } + + par0Tessellator.draw(); + par0Tessellator.startDrawingQuads(); + par0Tessellator.setNormal(1.0F, 0.0F, 0.0F); + float f9; + + for (k = 0; k < par5; ++k) + { + f7 = (float)k / (float)par5; + f8 = par1 + (par3 - par1) * f7 - f5; + f9 = f7 + 1.0F / (float)par5; + par0Tessellator.addVertexWithUV((double)f9, 1.0D, (double)(0.0F - par7), (double)f8, (double)par2); + par0Tessellator.addVertexWithUV((double)f9, 1.0D, 0.0D, (double)f8, (double)par2); + par0Tessellator.addVertexWithUV((double)f9, 0.0D, 0.0D, (double)f8, (double)par4); + par0Tessellator.addVertexWithUV((double)f9, 0.0D, (double)(0.0F - par7), (double)f8, (double)par4); + } + + par0Tessellator.draw(); + par0Tessellator.startDrawingQuads(); + par0Tessellator.setNormal(0.0F, 1.0F, 0.0F); + + for (k = 0; k < par6; ++k) + { + f7 = (float)k / (float)par6; + f8 = par4 + (par2 - par4) * f7 - f6; + f9 = f7 + 1.0F / (float)par6; + par0Tessellator.addVertexWithUV(0.0D, (double)f9, 0.0D, (double)par1, (double)f8); + par0Tessellator.addVertexWithUV(1.0D, (double)f9, 0.0D, (double)par3, (double)f8); + par0Tessellator.addVertexWithUV(1.0D, (double)f9, (double)(0.0F - par7), (double)par3, (double)f8); + par0Tessellator.addVertexWithUV(0.0D, (double)f9, (double)(0.0F - par7), (double)par1, (double)f8); + } + + par0Tessellator.draw(); + par0Tessellator.startDrawingQuads(); + par0Tessellator.setNormal(0.0F, -1.0F, 0.0F); + + for (k = 0; k < par6; ++k) + { + f7 = (float)k / (float)par6; + f8 = par4 + (par2 - par4) * f7 - f6; + par0Tessellator.addVertexWithUV(1.0D, (double)f7, 0.0D, (double)par3, (double)f8); + par0Tessellator.addVertexWithUV(0.0D, (double)f7, 0.0D, (double)par1, (double)f8); + par0Tessellator.addVertexWithUV(0.0D, (double)f7, (double)(0.0F - par7), (double)par1, (double)f8); + par0Tessellator.addVertexWithUV(1.0D, (double)f7, (double)(0.0F - par7), (double)par3, (double)f8); + } + + par0Tessellator.draw(); + } + + public void renderItemInFirstPerson(float par1) + { + float f1 = this.prevEquippedProgress + (this.equippedProgress - this.prevEquippedProgress) * par1; + EntityClientPlayerMP entityclientplayermp = this.mc.thePlayer; + float f2 = entityclientplayermp.prevRotationPitch + (entityclientplayermp.rotationPitch - entityclientplayermp.prevRotationPitch) * par1; + GL11.glPushMatrix(); + GL11.glRotatef(f2, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(entityclientplayermp.prevRotationYaw + (entityclientplayermp.rotationYaw - entityclientplayermp.prevRotationYaw) * par1, 0.0F, 1.0F, 0.0F); + RenderHelper.enableStandardItemLighting(); + GL11.glPopMatrix(); + EntityPlayerSP entityplayersp = (EntityPlayerSP)entityclientplayermp; + float f3 = entityplayersp.prevRenderArmPitch + (entityplayersp.renderArmPitch - entityplayersp.prevRenderArmPitch) * par1; + float f4 = entityplayersp.prevRenderArmYaw + (entityplayersp.renderArmYaw - entityplayersp.prevRenderArmYaw) * par1; + GL11.glRotatef((entityclientplayermp.rotationPitch - f3) * 0.1F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef((entityclientplayermp.rotationYaw - f4) * 0.1F, 0.0F, 1.0F, 0.0F); + ItemStack itemstack = this.itemToRender; + + if (itemstack != null && itemstack.getItem() instanceof ItemCloth) + { + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + } + + int i = this.mc.theWorld.getLightBrightnessForSkyBlocks(MathHelper.floor_double(entityclientplayermp.posX), MathHelper.floor_double(entityclientplayermp.posY), MathHelper.floor_double(entityclientplayermp.posZ), 0); + int j = i % 65536; + int k = i / 65536; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j / 1.0F, (float)k / 1.0F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + float f5; + float f6; + float f7; + + if (itemstack != null) + { + int l = itemstack.getItem().getColorFromItemStack(itemstack, 0); + f5 = (float)(l >> 16 & 255) / 255.0F; + f6 = (float)(l >> 8 & 255) / 255.0F; + f7 = (float)(l & 255) / 255.0F; + GL11.glColor4f(f5, f6, f7, 1.0F); + } + else + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + } + + float f8; + float f9; + float f10; + float f13; + Render render; + RenderPlayer renderplayer; + + if (itemstack != null && itemstack.getItem() instanceof ItemMap) + { + GL11.glPushMatrix(); + f13 = 0.8F; + f5 = entityclientplayermp.getSwingProgress(par1); + f6 = MathHelper.sin(f5 * (float)Math.PI); + f7 = MathHelper.sin(MathHelper.sqrt_float(f5) * (float)Math.PI); + GL11.glTranslatef(-f7 * 0.4F, MathHelper.sin(MathHelper.sqrt_float(f5) * (float)Math.PI * 2.0F) * 0.2F, -f6 * 0.2F); + f5 = 1.0F - f2 / 45.0F + 0.1F; + + if (f5 < 0.0F) + { + f5 = 0.0F; + } + + if (f5 > 1.0F) + { + f5 = 1.0F; + } + + f5 = -MathHelper.cos(f5 * (float)Math.PI) * 0.5F + 0.5F; + GL11.glTranslatef(0.0F, 0.0F * f13 - (1.0F - f1) * 1.2F - f5 * 0.5F + 0.04F, -0.9F * f13); + GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(f5 * -85.0F, 0.0F, 0.0F, 1.0F); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + this.mc.getTextureManager().bindTexture(entityclientplayermp.getLocationSkin()); + + for (int i1 = 0; i1 < 2; ++i1) + { + int j1 = i1 * 2 - 1; + GL11.glPushMatrix(); + GL11.glTranslatef(-0.0F, -0.6F, 1.1F * (float)j1); + GL11.glRotatef((float)(-45 * j1), 1.0F, 0.0F, 0.0F); + GL11.glRotatef(-90.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(59.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef((float)(-65 * j1), 0.0F, 1.0F, 0.0F); + render = RenderManager.instance.getEntityRenderObject(this.mc.thePlayer); + renderplayer = (RenderPlayer)render; + f10 = 1.0F; + GL11.glScalef(f10, f10, f10); + renderplayer.renderFirstPersonArm(this.mc.thePlayer); + GL11.glPopMatrix(); + } + + f6 = entityclientplayermp.getSwingProgress(par1); + f7 = MathHelper.sin(f6 * f6 * (float)Math.PI); + f8 = MathHelper.sin(MathHelper.sqrt_float(f6) * (float)Math.PI); + GL11.glRotatef(-f7 * 20.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-f8 * 20.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(-f8 * 80.0F, 1.0F, 0.0F, 0.0F); + f9 = 0.38F; + GL11.glScalef(f9, f9, f9); + GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); + GL11.glTranslatef(-1.0F, -1.0F, 0.0F); + f10 = 0.015625F; + GL11.glScalef(f10, f10, f10); + this.mc.getTextureManager().bindTexture(RES_MAP_BACKGROUND); + Tessellator tessellator = Tessellator.instance; + GL11.glNormal3f(0.0F, 0.0F, -1.0F); + tessellator.startDrawingQuads(); + byte b0 = 7; + tessellator.addVertexWithUV((double)(0 - b0), (double)(128 + b0), 0.0D, 0.0D, 1.0D); + tessellator.addVertexWithUV((double)(128 + b0), (double)(128 + b0), 0.0D, 1.0D, 1.0D); + tessellator.addVertexWithUV((double)(128 + b0), (double)(0 - b0), 0.0D, 1.0D, 0.0D); + tessellator.addVertexWithUV((double)(0 - b0), (double)(0 - b0), 0.0D, 0.0D, 0.0D); + tessellator.draw(); + + IItemRenderer custom = MinecraftForgeClient.getItemRenderer(itemstack, FIRST_PERSON_MAP); + MapData mapdata = ((ItemMap)itemstack.getItem()).getMapData(itemstack, this.mc.theWorld); + + if (custom == null) + { + if (mapdata != null) + { + this.mc.entityRenderer.getMapItemRenderer().func_148250_a(mapdata, false); + } + } + else + { + custom.renderItem(FIRST_PERSON_MAP, itemstack, mc.thePlayer, mc.getTextureManager(), mapdata); + } + + GL11.glPopMatrix(); + } + else if (itemstack != null) + { + GL11.glPushMatrix(); + f13 = 0.8F; + + if (entityclientplayermp.getItemInUseCount() > 0) + { + EnumAction enumaction = itemstack.getItemUseAction(); + + if (enumaction == EnumAction.eat || enumaction == EnumAction.drink) + { + f6 = (float)entityclientplayermp.getItemInUseCount() - par1 + 1.0F; + f7 = 1.0F - f6 / (float)itemstack.getMaxItemUseDuration(); + f8 = 1.0F - f7; + f8 = f8 * f8 * f8; + f8 = f8 * f8 * f8; + f8 = f8 * f8 * f8; + f9 = 1.0F - f8; + GL11.glTranslatef(0.0F, MathHelper.abs(MathHelper.cos(f6 / 4.0F * (float)Math.PI) * 0.1F) * (float)((double)f7 > 0.2D ? 1 : 0), 0.0F); + GL11.glTranslatef(f9 * 0.6F, -f9 * 0.5F, 0.0F); + GL11.glRotatef(f9 * 90.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(f9 * 10.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(f9 * 30.0F, 0.0F, 0.0F, 1.0F); + } + } + else + { + f5 = entityclientplayermp.getSwingProgress(par1); + f6 = MathHelper.sin(f5 * (float)Math.PI); + f7 = MathHelper.sin(MathHelper.sqrt_float(f5) * (float)Math.PI); + GL11.glTranslatef(-f7 * 0.4F, MathHelper.sin(MathHelper.sqrt_float(f5) * (float)Math.PI * 2.0F) * 0.2F, -f6 * 0.2F); + } + + GL11.glTranslatef(0.7F * f13, -0.65F * f13 - (1.0F - f1) * 0.6F, -0.9F * f13); + GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + f5 = entityclientplayermp.getSwingProgress(par1); + f6 = MathHelper.sin(f5 * f5 * (float)Math.PI); + f7 = MathHelper.sin(MathHelper.sqrt_float(f5) * (float)Math.PI); + GL11.glRotatef(-f6 * 20.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-f7 * 20.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(-f7 * 80.0F, 1.0F, 0.0F, 0.0F); + f8 = 0.4F; + GL11.glScalef(f8, f8, f8); + float f11; + float f12; + + if (entityclientplayermp.getItemInUseCount() > 0) + { + EnumAction enumaction1 = itemstack.getItemUseAction(); + + if (enumaction1 == EnumAction.block) + { + GL11.glTranslatef(-0.5F, 0.2F, 0.0F); + GL11.glRotatef(30.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-80.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(60.0F, 0.0F, 1.0F, 0.0F); + } + else if (enumaction1 == EnumAction.bow) + { + GL11.glRotatef(-18.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(-12.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-8.0F, 1.0F, 0.0F, 0.0F); + GL11.glTranslatef(-0.9F, 0.2F, 0.0F); + f10 = (float)itemstack.getMaxItemUseDuration() - ((float)entityclientplayermp.getItemInUseCount() - par1 + 1.0F); + f11 = f10 / 20.0F; + f11 = (f11 * f11 + f11 * 2.0F) / 3.0F; + + if (f11 > 1.0F) + { + f11 = 1.0F; + } + + if (f11 > 0.1F) + { + GL11.glTranslatef(0.0F, MathHelper.sin((f10 - 0.1F) * 1.3F) * 0.01F * (f11 - 0.1F), 0.0F); + } + + GL11.glTranslatef(0.0F, 0.0F, f11 * 0.1F); + GL11.glRotatef(-335.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(-50.0F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(0.0F, 0.5F, 0.0F); + f12 = 1.0F + f11 * 0.2F; + GL11.glScalef(1.0F, 1.0F, f12); + GL11.glTranslatef(0.0F, -0.5F, 0.0F); + GL11.glRotatef(50.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(335.0F, 0.0F, 0.0F, 1.0F); + } + } + + if (itemstack.getItem().shouldRotateAroundWhenRendering()) + { + GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); + } + + if (itemstack.getItem().requiresMultipleRenderPasses()) + { + this.renderItem(entityclientplayermp, itemstack, 0, EQUIPPED_FIRST_PERSON); + for (int x = 1; x < itemstack.getItem().getRenderPasses(itemstack.getItemDamage()); x++) + { + int k1 = itemstack.getItem().getColorFromItemStack(itemstack, 1); + f10 = (float)(k1 >> 16 & 255) / 255.0F; + f11 = (float)(k1 >> 8 & 255) / 255.0F; + f12 = (float)(k1 & 255) / 255.0F; + GL11.glColor4f(1.0F * f10, 1.0F * f11, 1.0F * f12, 1.0F); + this.renderItem(entityclientplayermp, itemstack, x, EQUIPPED_FIRST_PERSON); + } + } + else + { + this.renderItem(entityclientplayermp, itemstack, 0, EQUIPPED_FIRST_PERSON); + } + + GL11.glPopMatrix(); + } + else if (!entityclientplayermp.isInvisible()) + { + GL11.glPushMatrix(); + f13 = 0.8F; + f5 = entityclientplayermp.getSwingProgress(par1); + f6 = MathHelper.sin(f5 * (float)Math.PI); + f7 = MathHelper.sin(MathHelper.sqrt_float(f5) * (float)Math.PI); + GL11.glTranslatef(-f7 * 0.3F, MathHelper.sin(MathHelper.sqrt_float(f5) * (float)Math.PI * 2.0F) * 0.4F, -f6 * 0.4F); + GL11.glTranslatef(0.8F * f13, -0.75F * f13 - (1.0F - f1) * 0.6F, -0.9F * f13); + GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + f5 = entityclientplayermp.getSwingProgress(par1); + f6 = MathHelper.sin(f5 * f5 * (float)Math.PI); + f7 = MathHelper.sin(MathHelper.sqrt_float(f5) * (float)Math.PI); + GL11.glRotatef(f7 * 70.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-f6 * 20.0F, 0.0F, 0.0F, 1.0F); + this.mc.getTextureManager().bindTexture(entityclientplayermp.getLocationSkin()); + GL11.glTranslatef(-1.0F, 3.6F, 3.5F); + GL11.glRotatef(120.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(200.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F); + GL11.glScalef(1.0F, 1.0F, 1.0F); + GL11.glTranslatef(5.6F, 0.0F, 0.0F); + render = RenderManager.instance.getEntityRenderObject(this.mc.thePlayer); + renderplayer = (RenderPlayer)render; + f10 = 1.0F; + GL11.glScalef(f10, f10, f10); + renderplayer.renderFirstPersonArm(this.mc.thePlayer); + GL11.glPopMatrix(); + } + + if (itemstack != null && itemstack.getItem() instanceof ItemCloth) + { + GL11.glDisable(GL11.GL_BLEND); + } + + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + RenderHelper.disableStandardItemLighting(); + } + + public void renderOverlays(float par1) + { + GL11.glDisable(GL11.GL_ALPHA_TEST); + + if (this.mc.thePlayer.isBurning()) + { + this.renderFireInFirstPerson(par1); + } + + if (this.mc.thePlayer.isEntityInsideOpaqueBlock()) + { + int i = MathHelper.floor_double(this.mc.thePlayer.posX); + int j = MathHelper.floor_double(this.mc.thePlayer.posY); + int k = MathHelper.floor_double(this.mc.thePlayer.posZ); + Block block = this.mc.theWorld.getBlock(i, j, k); + + if (this.mc.theWorld.getBlock(i, j, k).isNormalCube()) + { + this.renderInsideOfBlock(par1, block.getBlockTextureFromSide(2)); + } + else + { + for (int l = 0; l < 8; ++l) + { + float f1 = ((float)((l >> 0) % 2) - 0.5F) * this.mc.thePlayer.width * 0.9F; + float f2 = ((float)((l >> 1) % 2) - 0.5F) * this.mc.thePlayer.height * 0.2F; + float f3 = ((float)((l >> 2) % 2) - 0.5F) * this.mc.thePlayer.width * 0.9F; + int i1 = MathHelper.floor_float((float)i + f1); + int j1 = MathHelper.floor_float((float)j + f2); + int k1 = MathHelper.floor_float((float)k + f3); + + if (this.mc.theWorld.getBlock(i1, j1, k1).isNormalCube()) + { + block = this.mc.theWorld.getBlock(i1, j1, k1); + } + } + } + + if (block.getMaterial() != Material.air) + { + this.renderInsideOfBlock(par1, block.getBlockTextureFromSide(2)); + } + } + + if (this.mc.thePlayer.isInsideOfMaterial(Material.water)) + { + this.renderWarpedTextureOverlay(par1); + } + + GL11.glEnable(GL11.GL_ALPHA_TEST); + } + + private void renderInsideOfBlock(float par1, IIcon par2Icon) + { + this.mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture); + Tessellator tessellator = Tessellator.instance; + float f1 = 0.1F; + GL11.glColor4f(f1, f1, f1, 0.5F); + GL11.glPushMatrix(); + float f2 = -1.0F; + float f3 = 1.0F; + float f4 = -1.0F; + float f5 = 1.0F; + float f6 = -0.5F; + float f7 = par2Icon.getMinU(); + float f8 = par2Icon.getMaxU(); + float f9 = par2Icon.getMinV(); + float f10 = par2Icon.getMaxV(); + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV((double)f2, (double)f4, (double)f6, (double)f8, (double)f10); + tessellator.addVertexWithUV((double)f3, (double)f4, (double)f6, (double)f7, (double)f10); + tessellator.addVertexWithUV((double)f3, (double)f5, (double)f6, (double)f7, (double)f9); + tessellator.addVertexWithUV((double)f2, (double)f5, (double)f6, (double)f8, (double)f9); + tessellator.draw(); + GL11.glPopMatrix(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + } + + private void renderWarpedTextureOverlay(float par1) + { + this.mc.getTextureManager().bindTexture(RES_UNDERWATER_OVERLAY); + Tessellator tessellator = Tessellator.instance; + float f1 = this.mc.thePlayer.getBrightness(par1); + GL11.glColor4f(f1, f1, f1, 0.5F); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glPushMatrix(); + float f2 = 4.0F; + float f3 = -1.0F; + float f4 = 1.0F; + float f5 = -1.0F; + float f6 = 1.0F; + float f7 = -0.5F; + float f8 = -this.mc.thePlayer.rotationYaw / 64.0F; + float f9 = this.mc.thePlayer.rotationPitch / 64.0F; + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV((double)f3, (double)f5, (double)f7, (double)(f2 + f8), (double)(f2 + f9)); + tessellator.addVertexWithUV((double)f4, (double)f5, (double)f7, (double)(0.0F + f8), (double)(f2 + f9)); + tessellator.addVertexWithUV((double)f4, (double)f6, (double)f7, (double)(0.0F + f8), (double)(0.0F + f9)); + tessellator.addVertexWithUV((double)f3, (double)f6, (double)f7, (double)(f2 + f8), (double)(0.0F + f9)); + tessellator.draw(); + GL11.glPopMatrix(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_BLEND); + } + + private void renderFireInFirstPerson(float par1) + { + Tessellator tessellator = Tessellator.instance; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.9F); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + float f1 = 1.0F; + + for (int i = 0; i < 2; ++i) + { + GL11.glPushMatrix(); + IIcon iicon = Blocks.fire.getFireIcon(1); + this.mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture); + float f2 = iicon.getMinU(); + float f3 = iicon.getMaxU(); + float f4 = iicon.getMinV(); + float f5 = iicon.getMaxV(); + float f6 = (0.0F - f1) / 2.0F; + float f7 = f6 + f1; + float f8 = 0.0F - f1 / 2.0F; + float f9 = f8 + f1; + float f10 = -0.5F; + GL11.glTranslatef((float)(-(i * 2 - 1)) * 0.24F, -0.3F, 0.0F); + GL11.glRotatef((float)(i * 2 - 1) * 10.0F, 0.0F, 1.0F, 0.0F); + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV((double)f6, (double)f8, (double)f10, (double)f3, (double)f5); + tessellator.addVertexWithUV((double)f7, (double)f8, (double)f10, (double)f2, (double)f5); + tessellator.addVertexWithUV((double)f7, (double)f9, (double)f10, (double)f2, (double)f4); + tessellator.addVertexWithUV((double)f6, (double)f9, (double)f10, (double)f3, (double)f4); + tessellator.draw(); + GL11.glPopMatrix(); + } + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_BLEND); + } + + public void updateEquippedItem() + { + this.prevEquippedProgress = this.equippedProgress; + EntityClientPlayerMP entityclientplayermp = this.mc.thePlayer; + ItemStack itemstack = entityclientplayermp.inventory.getCurrentItem(); + boolean flag = this.equippedItemSlot == entityclientplayermp.inventory.currentItem && itemstack == this.itemToRender; + + if (this.itemToRender == null && itemstack == null) + { + flag = true; + } + + if (itemstack != null && this.itemToRender != null && itemstack != this.itemToRender && itemstack.getItem() == this.itemToRender.getItem() && itemstack.getItemDamage() == this.itemToRender.getItemDamage()) + { + this.itemToRender = itemstack; + flag = true; + } + + float f = 0.4F; + float f1 = flag ? 1.0F : 0.0F; + float f2 = f1 - this.equippedProgress; + + if (f2 < -f) + { + f2 = -f; + } + + if (f2 > f) + { + f2 = f; + } + + this.equippedProgress += f2; + + if (this.equippedProgress < 0.1F) + { + this.itemToRender = itemstack; + this.equippedItemSlot = entityclientplayermp.inventory.currentItem; + } + } + + public void resetEquippedProgress() + { + this.equippedProgress = 0.0F; + } + + public void resetEquippedProgress2() + { + this.equippedProgress = 0.0F; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/OpenGlCapsChecker.java b/src/main/java/net/minecraft/client/renderer/OpenGlCapsChecker.java new file mode 100644 index 0000000..4e2b823 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/OpenGlCapsChecker.java @@ -0,0 +1,16 @@ +package net.minecraft.client.renderer; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import org.lwjgl.opengl.GLContext; + +@SideOnly(Side.CLIENT) +public class OpenGlCapsChecker +{ + private static final String __OBFID = "CL_00000649"; + + public static boolean checkARBOcclusion() + { + return GLContext.getCapabilities().GL_ARB_occlusion_query; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/OpenGlHelper.java b/src/main/java/net/minecraft/client/renderer/OpenGlHelper.java new file mode 100644 index 0000000..8464892 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/OpenGlHelper.java @@ -0,0 +1,113 @@ +package net.minecraft.client.renderer; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.Minecraft; +import net.minecraft.client.settings.GameSettings; +import org.lwjgl.opengl.ARBMultitexture; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL13; +import org.lwjgl.opengl.GL14; +import org.lwjgl.opengl.GLContext; + +@SideOnly(Side.CLIENT) +public class OpenGlHelper +{ + public static boolean openGL21; + public static int defaultTexUnit; + public static int lightmapTexUnit; + public static boolean anisotropicFilteringSupported; + public static int anisotropicFilteringMax; + private static boolean useMultitextureARB; + private static boolean openGL14; + public static boolean framebufferSupported; + public static boolean shadersSupported; + private static final String __OBFID = "CL_00001179"; + + /* Stores the last values sent into setLightmapTextureCoords */ + public static float lastBrightnessX = 0.0f; + public static float lastBrightnessY = 0.0f; + + public static void initializeTextures() + { + useMultitextureARB = GLContext.getCapabilities().GL_ARB_multitexture && !GLContext.getCapabilities().OpenGL13; + + if (useMultitextureARB) + { + defaultTexUnit = 33984; + lightmapTexUnit = 33985; + } + else + { + defaultTexUnit = 33984; + lightmapTexUnit = 33985; + } + + openGL14 = GLContext.getCapabilities().OpenGL14; + framebufferSupported = openGL14 && GLContext.getCapabilities().GL_ARB_framebuffer_object; + anisotropicFilteringSupported = GLContext.getCapabilities().GL_EXT_texture_filter_anisotropic; + anisotropicFilteringMax = (int)(anisotropicFilteringSupported ? GL11.glGetFloat(34047) : 0.0F); + GameSettings.Options.ANISOTROPIC_FILTERING.setValueMax((float)anisotropicFilteringMax); + openGL21 = GLContext.getCapabilities().OpenGL21; + shadersSupported = framebufferSupported && openGL21; + } + + public static void setActiveTexture(int par0) + { + if (useMultitextureARB) + { + ARBMultitexture.glActiveTextureARB(par0); + } + else + { + GL13.glActiveTexture(par0); + } + } + + public static void setClientActiveTexture(int par0) + { + if (useMultitextureARB) + { + ARBMultitexture.glClientActiveTextureARB(par0); + } + else + { + GL13.glClientActiveTexture(par0); + } + } + + public static void setLightmapTextureCoords(int par0, float par1, float par2) + { + if (useMultitextureARB) + { + ARBMultitexture.glMultiTexCoord2fARB(par0, par1, par2); + } + else + { + GL13.glMultiTexCoord2f(par0, par1, par2); + } + + if (par0 == lightmapTexUnit) + { + lastBrightnessX = par1; + lastBrightnessY = par2; + } + } + + public static void glBlendFunc(int p_148821_0_, int p_148821_1_, int p_148821_2_, int p_148821_3_) + { + if (openGL14) + { + GL14.glBlendFuncSeparate(p_148821_0_, p_148821_1_, p_148821_2_, p_148821_3_); + } + else + { + GL11.glBlendFunc(p_148821_0_, p_148821_1_); + } + } + + public static boolean isFramebufferEnabled() + { + return framebufferSupported && Minecraft.getMinecraft().gameSettings.fboEnable; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/RenderBlocks.java b/src/main/java/net/minecraft/client/renderer/RenderBlocks.java new file mode 100644 index 0000000..bbb8dc0 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/RenderBlocks.java @@ -0,0 +1,8225 @@ +package net.minecraft.client.renderer; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.block.BlockAnvil; +import net.minecraft.block.BlockBeacon; +import net.minecraft.block.BlockBed; +import net.minecraft.block.BlockBrewingStand; +import net.minecraft.block.BlockCauldron; +import net.minecraft.block.BlockCocoa; +import net.minecraft.block.BlockDirectional; +import net.minecraft.block.BlockDoublePlant; +import net.minecraft.block.BlockDragonEgg; +import net.minecraft.block.BlockEndPortalFrame; +import net.minecraft.block.BlockFence; +import net.minecraft.block.BlockFenceGate; +import net.minecraft.block.BlockFire; +import net.minecraft.block.BlockFlowerPot; +import net.minecraft.block.BlockGrass; +import net.minecraft.block.BlockHopper; +import net.minecraft.block.BlockLiquid; +import net.minecraft.block.BlockPane; +import net.minecraft.block.BlockPistonBase; +import net.minecraft.block.BlockPistonExtension; +import net.minecraft.block.BlockRailBase; +import net.minecraft.block.BlockRedstoneComparator; +import net.minecraft.block.BlockRedstoneDiode; +import net.minecraft.block.BlockRedstoneRepeater; +import net.minecraft.block.BlockRedstoneWire; +import net.minecraft.block.BlockStainedGlassPane; +import net.minecraft.block.BlockStairs; +import net.minecraft.block.BlockStem; +import net.minecraft.block.BlockTripWire; +import net.minecraft.block.BlockWall; +import net.minecraft.block.material.Material; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.client.renderer.tileentity.TileEntityRendererChestHelper; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.src.FMLRenderAccessLibrary; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityFlowerPot; +import net.minecraft.util.Direction; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import static net.minecraftforge.common.util.ForgeDirection.*; + +@SideOnly(Side.CLIENT) +public class RenderBlocks +{ + public IBlockAccess blockAccess; + public IIcon overrideBlockTexture; + public boolean flipTexture; + public boolean renderAllFaces; + public static boolean fancyGrass = true; + public boolean useInventoryTint = true; + public boolean renderFromInside = false; + public double renderMinX; + public double renderMaxX; + public double renderMinY; + public double renderMaxY; + public double renderMinZ; + public double renderMaxZ; + public boolean lockBlockBounds; + public boolean partialRenderBounds; + public final Minecraft minecraftRB; + public int uvRotateEast; + public int uvRotateWest; + public int uvRotateSouth; + public int uvRotateNorth; + public int uvRotateTop; + public int uvRotateBottom; + public boolean enableAO; + public float aoLightValueScratchXYZNNN; + public float aoLightValueScratchXYNN; + public float aoLightValueScratchXYZNNP; + public float aoLightValueScratchYZNN; + public float aoLightValueScratchYZNP; + public float aoLightValueScratchXYZPNN; + public float aoLightValueScratchXYPN; + public float aoLightValueScratchXYZPNP; + public float aoLightValueScratchXYZNPN; + public float aoLightValueScratchXYNP; + public float aoLightValueScratchXYZNPP; + public float aoLightValueScratchYZPN; + public float aoLightValueScratchXYZPPN; + public float aoLightValueScratchXYPP; + public float aoLightValueScratchYZPP; + public float aoLightValueScratchXYZPPP; + public float aoLightValueScratchXZNN; + public float aoLightValueScratchXZPN; + public float aoLightValueScratchXZNP; + public float aoLightValueScratchXZPP; + public int aoBrightnessXYZNNN; + public int aoBrightnessXYNN; + public int aoBrightnessXYZNNP; + public int aoBrightnessYZNN; + public int aoBrightnessYZNP; + public int aoBrightnessXYZPNN; + public int aoBrightnessXYPN; + public int aoBrightnessXYZPNP; + public int aoBrightnessXYZNPN; + public int aoBrightnessXYNP; + public int aoBrightnessXYZNPP; + public int aoBrightnessYZPN; + public int aoBrightnessXYZPPN; + public int aoBrightnessXYPP; + public int aoBrightnessYZPP; + public int aoBrightnessXYZPPP; + public int aoBrightnessXZNN; + public int aoBrightnessXZPN; + public int aoBrightnessXZNP; + public int aoBrightnessXZPP; + public int brightnessTopLeft; + public int brightnessBottomLeft; + public int brightnessBottomRight; + public int brightnessTopRight; + public float colorRedTopLeft; + public float colorRedBottomLeft; + public float colorRedBottomRight; + public float colorRedTopRight; + public float colorGreenTopLeft; + public float colorGreenBottomLeft; + public float colorGreenBottomRight; + public float colorGreenTopRight; + public float colorBlueTopLeft; + public float colorBlueBottomLeft; + public float colorBlueBottomRight; + public float colorBlueTopRight; + private static final String __OBFID = "CL_00000940"; + + public RenderBlocks(IBlockAccess par1IBlockAccess) + { + this.blockAccess = par1IBlockAccess; + this.minecraftRB = Minecraft.getMinecraft(); + } + + public RenderBlocks() + { + this.minecraftRB = Minecraft.getMinecraft(); + } + + public void setOverrideBlockTexture(IIcon p_147757_1_) + { + this.overrideBlockTexture = p_147757_1_; + } + + public void clearOverrideBlockTexture() + { + this.overrideBlockTexture = null; + } + + public boolean hasOverrideBlockTexture() + { + return this.overrideBlockTexture != null; + } + + public void setRenderFromInside(boolean p_147786_1_) + { + this.renderFromInside = p_147786_1_; + } + + public void setRenderAllFaces(boolean p_147753_1_) + { + this.renderAllFaces = p_147753_1_; + } + + public void setRenderBounds(double p_147782_1_, double p_147782_3_, double p_147782_5_, double p_147782_7_, double p_147782_9_, double p_147782_11_) + { + if (!this.lockBlockBounds) + { + this.renderMinX = p_147782_1_; + this.renderMaxX = p_147782_7_; + this.renderMinY = p_147782_3_; + this.renderMaxY = p_147782_9_; + this.renderMinZ = p_147782_5_; + this.renderMaxZ = p_147782_11_; + this.partialRenderBounds = this.minecraftRB.gameSettings.ambientOcclusion >= 2 && (this.renderMinX > 0.0D || this.renderMaxX < 1.0D || this.renderMinY > 0.0D || this.renderMaxY < 1.0D || this.renderMinZ > 0.0D || this.renderMaxZ < 1.0D); + } + } + + public void setRenderBoundsFromBlock(Block p_147775_1_) + { + if (!this.lockBlockBounds) + { + this.renderMinX = p_147775_1_.getBlockBoundsMinX(); + this.renderMaxX = p_147775_1_.getBlockBoundsMaxX(); + this.renderMinY = p_147775_1_.getBlockBoundsMinY(); + this.renderMaxY = p_147775_1_.getBlockBoundsMaxY(); + this.renderMinZ = p_147775_1_.getBlockBoundsMinZ(); + this.renderMaxZ = p_147775_1_.getBlockBoundsMaxZ(); + this.partialRenderBounds = this.minecraftRB.gameSettings.ambientOcclusion >= 2 && (this.renderMinX > 0.0D || this.renderMaxX < 1.0D || this.renderMinY > 0.0D || this.renderMaxY < 1.0D || this.renderMinZ > 0.0D || this.renderMaxZ < 1.0D); + } + } + + public void overrideBlockBounds(double p_147770_1_, double p_147770_3_, double p_147770_5_, double p_147770_7_, double p_147770_9_, double p_147770_11_) + { + this.renderMinX = p_147770_1_; + this.renderMaxX = p_147770_7_; + this.renderMinY = p_147770_3_; + this.renderMaxY = p_147770_9_; + this.renderMinZ = p_147770_5_; + this.renderMaxZ = p_147770_11_; + this.lockBlockBounds = true; + this.partialRenderBounds = this.minecraftRB.gameSettings.ambientOcclusion >= 2 && (this.renderMinX > 0.0D || this.renderMaxX < 1.0D || this.renderMinY > 0.0D || this.renderMaxY < 1.0D || this.renderMinZ > 0.0D || this.renderMaxZ < 1.0D); + } + + public void unlockBlockBounds() + { + this.lockBlockBounds = false; + } + + public void renderBlockUsingTexture(Block p_147792_1_, int p_147792_2_, int p_147792_3_, int p_147792_4_, IIcon p_147792_5_) + { + this.setOverrideBlockTexture(p_147792_5_); + this.renderBlockByRenderType(p_147792_1_, p_147792_2_, p_147792_3_, p_147792_4_); + this.clearOverrideBlockTexture(); + } + + public void renderBlockAllFaces(Block p_147769_1_, int p_147769_2_, int p_147769_3_, int p_147769_4_) + { + this.renderAllFaces = true; + this.renderBlockByRenderType(p_147769_1_, p_147769_2_, p_147769_3_, p_147769_4_); + this.renderAllFaces = false; + } + + public boolean renderBlockByRenderType(Block p_147805_1_, int p_147805_2_, int p_147805_3_, int p_147805_4_) + { + int l = p_147805_1_.getRenderType(); + + if (l == -1) + { + return false; + } + else + { + p_147805_1_.setBlockBoundsBasedOnState(this.blockAccess, p_147805_2_, p_147805_3_, p_147805_4_); + this.setRenderBoundsFromBlock(p_147805_1_); + + switch (l) + { + //regex: ' : \(l == ([\d]+) \?' replace: ';\ncase \1: return' ::: IMPORTANT: REMEMBER THIS ON FIRST line! + case 0 : return this.renderStandardBlock(p_147805_1_, p_147805_2_, p_147805_3_, p_147805_4_) ; + case 4: return this.renderBlockLiquid(p_147805_1_, p_147805_2_, p_147805_3_, p_147805_4_) ; + case 31: return this.renderBlockLog(p_147805_1_, p_147805_2_, p_147805_3_, p_147805_4_) ; + case 1: return this.renderCrossedSquares(p_147805_1_, p_147805_2_, p_147805_3_, p_147805_4_) ; + case 40: return this.renderBlockDoublePlant((BlockDoublePlant)p_147805_1_, p_147805_2_, p_147805_3_, p_147805_4_) ; + case 2: return this.renderBlockTorch(p_147805_1_, p_147805_2_, p_147805_3_, p_147805_4_) ; + case 20: return this.renderBlockVine(p_147805_1_, p_147805_2_, p_147805_3_, p_147805_4_) ; + case 11: return this.renderBlockFence((BlockFence)p_147805_1_, p_147805_2_, p_147805_3_, p_147805_4_) ; + case 39: return this.renderBlockQuartz(p_147805_1_, p_147805_2_, p_147805_3_, p_147805_4_) ; + case 5: return this.renderBlockRedstoneWire(p_147805_1_, p_147805_2_, p_147805_3_, p_147805_4_) ; + case 13: return this.renderBlockCactus(p_147805_1_, p_147805_2_, p_147805_3_, p_147805_4_) ; + case 9: return this.renderBlockMinecartTrack((BlockRailBase)p_147805_1_, p_147805_2_, p_147805_3_, p_147805_4_) ; + case 19: return this.renderBlockStem(p_147805_1_, p_147805_2_, p_147805_3_, p_147805_4_) ; + case 23: return this.renderBlockLilyPad(p_147805_1_, p_147805_2_, p_147805_3_, p_147805_4_) ; + case 6: return this.renderBlockCrops(p_147805_1_, p_147805_2_, p_147805_3_, p_147805_4_) ; + case 3: return this.renderBlockFire((BlockFire)p_147805_1_, p_147805_2_, p_147805_3_, p_147805_4_) ; + case 8: return this.renderBlockLadder(p_147805_1_, p_147805_2_, p_147805_3_, p_147805_4_) ; + case 7: return this.renderBlockDoor(p_147805_1_, p_147805_2_, p_147805_3_, p_147805_4_) ; + case 10: return this.renderBlockStairs((BlockStairs)p_147805_1_, p_147805_2_, p_147805_3_, p_147805_4_) ; + case 27: return this.renderBlockDragonEgg((BlockDragonEgg)p_147805_1_, p_147805_2_, p_147805_3_, p_147805_4_) ; + case 32: return this.renderBlockWall((BlockWall)p_147805_1_, p_147805_2_, p_147805_3_, p_147805_4_) ; + case 12: return this.renderBlockLever(p_147805_1_, p_147805_2_, p_147805_3_, p_147805_4_) ; + case 29: return this.renderBlockTripWireSource(p_147805_1_, p_147805_2_, p_147805_3_, p_147805_4_) ; + case 30: return this.renderBlockTripWire(p_147805_1_, p_147805_2_, p_147805_3_, p_147805_4_) ; + case 14: return this.renderBlockBed(p_147805_1_, p_147805_2_, p_147805_3_, p_147805_4_) ; + case 15: return this.renderBlockRepeater((BlockRedstoneRepeater)p_147805_1_, p_147805_2_, p_147805_3_, p_147805_4_) ; + case 36: return this.renderBlockRedstoneDiode((BlockRedstoneDiode)p_147805_1_, p_147805_2_, p_147805_3_, p_147805_4_) ; + case 37: return this.renderBlockRedstoneComparator((BlockRedstoneComparator)p_147805_1_, p_147805_2_, p_147805_3_, p_147805_4_) ; + case 16: return this.renderPistonBase(p_147805_1_, p_147805_2_, p_147805_3_, p_147805_4_, false) ; + case 17: return this.renderPistonExtension(p_147805_1_, p_147805_2_, p_147805_3_, p_147805_4_, true) ; + case 18: return this.renderBlockPane((BlockPane)p_147805_1_, p_147805_2_, p_147805_3_, p_147805_4_) ; + case 41: return this.renderBlockStainedGlassPane(p_147805_1_, p_147805_2_, p_147805_3_, p_147805_4_) ; + case 21: return this.renderBlockFenceGate((BlockFenceGate)p_147805_1_, p_147805_2_, p_147805_3_, p_147805_4_) ; + case 24: return this.renderBlockCauldron((BlockCauldron)p_147805_1_, p_147805_2_, p_147805_3_, p_147805_4_) ; + case 33: return this.renderBlockFlowerpot((BlockFlowerPot)p_147805_1_, p_147805_2_, p_147805_3_, p_147805_4_) ; + case 35: return this.renderBlockAnvil((BlockAnvil)p_147805_1_, p_147805_2_, p_147805_3_, p_147805_4_) ; + case 25: return this.renderBlockBrewingStand((BlockBrewingStand)p_147805_1_, p_147805_2_, p_147805_3_, p_147805_4_) ; + case 26: return this.renderBlockEndPortalFrame((BlockEndPortalFrame)p_147805_1_, p_147805_2_, p_147805_3_, p_147805_4_) ; + case 28: return this.renderBlockCocoa((BlockCocoa)p_147805_1_, p_147805_2_, p_147805_3_, p_147805_4_) ; + case 34: return this.renderBlockBeacon((BlockBeacon)p_147805_1_, p_147805_2_, p_147805_3_, p_147805_4_) ; + case 38: return this.renderBlockHopper((BlockHopper)p_147805_1_, p_147805_2_, p_147805_3_, p_147805_4_); + default: return FMLRenderAccessLibrary.renderWorldBlock(this, blockAccess, p_147805_2_, p_147805_3_, p_147805_4_, p_147805_1_, l); + } + } + } + + public boolean renderBlockEndPortalFrame(BlockEndPortalFrame p_147743_1_, int p_147743_2_, int p_147743_3_, int p_147743_4_) + { + int l = this.blockAccess.getBlockMetadata(p_147743_2_, p_147743_3_, p_147743_4_); + int i1 = l & 3; + + if (i1 == 0) + { + this.uvRotateTop = 3; + } + else if (i1 == 3) + { + this.uvRotateTop = 1; + } + else if (i1 == 1) + { + this.uvRotateTop = 2; + } + + if (!BlockEndPortalFrame.isEnderEyeInserted(l)) + { + this.setRenderBounds(0.0D, 0.0D, 0.0D, 1.0D, 0.8125D, 1.0D); + this.renderStandardBlock(p_147743_1_, p_147743_2_, p_147743_3_, p_147743_4_); + this.uvRotateTop = 0; + return true; + } + else + { + this.renderAllFaces = true; + this.setRenderBounds(0.0D, 0.0D, 0.0D, 1.0D, 0.8125D, 1.0D); + this.renderStandardBlock(p_147743_1_, p_147743_2_, p_147743_3_, p_147743_4_); + this.setOverrideBlockTexture(p_147743_1_.getIconEndPortalFrameEye()); + this.setRenderBounds(0.25D, 0.8125D, 0.25D, 0.75D, 1.0D, 0.75D); + this.renderStandardBlock(p_147743_1_, p_147743_2_, p_147743_3_, p_147743_4_); + this.renderAllFaces = false; + this.clearOverrideBlockTexture(); + this.uvRotateTop = 0; + return true; + } + } + + public boolean renderBlockBed(Block p_147773_1_, int p_147773_2_, int p_147773_3_, int p_147773_4_) + { + Tessellator tessellator = Tessellator.instance; + Block bed = this.blockAccess.getBlock(p_147773_2_, p_147773_3_, p_147773_4_); + int i1 = bed.getBedDirection(blockAccess, p_147773_2_, p_147773_3_, p_147773_4_); + boolean flag = bed.isBedFoot(blockAccess, p_147773_2_, p_147773_3_, p_147773_4_); + float f = 0.5F; + float f1 = 1.0F; + float f2 = 0.8F; + float f3 = 0.6F; + int j1 = p_147773_1_.getMixedBrightnessForBlock(this.blockAccess, p_147773_2_, p_147773_3_, p_147773_4_); + tessellator.setBrightness(j1); + tessellator.setColorOpaque_F(f, f, f); + IIcon iicon = this.getBlockIcon(p_147773_1_, this.blockAccess, p_147773_2_, p_147773_3_, p_147773_4_, 0); + if (hasOverrideBlockTexture()) iicon = overrideBlockTexture; //BugFix Proper breaking texture on underside + double d0 = (double)iicon.getMinU(); + double d1 = (double)iicon.getMaxU(); + double d2 = (double)iicon.getMinV(); + double d3 = (double)iicon.getMaxV(); + double d4 = (double)p_147773_2_ + this.renderMinX; + double d5 = (double)p_147773_2_ + this.renderMaxX; + double d6 = (double)p_147773_3_ + this.renderMinY + 0.1875D; + double d7 = (double)p_147773_4_ + this.renderMinZ; + double d8 = (double)p_147773_4_ + this.renderMaxZ; + tessellator.addVertexWithUV(d4, d6, d8, d0, d3); + tessellator.addVertexWithUV(d4, d6, d7, d0, d2); + tessellator.addVertexWithUV(d5, d6, d7, d1, d2); + tessellator.addVertexWithUV(d5, d6, d8, d1, d3); + tessellator.setBrightness(p_147773_1_.getMixedBrightnessForBlock(this.blockAccess, p_147773_2_, p_147773_3_ + 1, p_147773_4_)); + tessellator.setColorOpaque_F(f1, f1, f1); + iicon = this.getBlockIcon(p_147773_1_, this.blockAccess, p_147773_2_, p_147773_3_, p_147773_4_, 1); + if (hasOverrideBlockTexture()) iicon = overrideBlockTexture; //BugFix Proper breaking texture on underside + d0 = (double)iicon.getMinU(); + d1 = (double)iicon.getMaxU(); + d2 = (double)iicon.getMinV(); + d3 = (double)iicon.getMaxV(); + d4 = d0; + d5 = d1; + d6 = d2; + d7 = d2; + d8 = d0; + double d9 = d1; + double d10 = d3; + double d11 = d3; + + if (i1 == 0) + { + d5 = d0; + d6 = d3; + d8 = d1; + d11 = d2; + } + else if (i1 == 2) + { + d4 = d1; + d7 = d3; + d9 = d0; + d10 = d2; + } + else if (i1 == 3) + { + d4 = d1; + d7 = d3; + d9 = d0; + d10 = d2; + d5 = d0; + d6 = d3; + d8 = d1; + d11 = d2; + } + + double d12 = (double)p_147773_2_ + this.renderMinX; + double d13 = (double)p_147773_2_ + this.renderMaxX; + double d14 = (double)p_147773_3_ + this.renderMaxY; + double d15 = (double)p_147773_4_ + this.renderMinZ; + double d16 = (double)p_147773_4_ + this.renderMaxZ; + tessellator.addVertexWithUV(d13, d14, d16, d8, d10); + tessellator.addVertexWithUV(d13, d14, d15, d4, d6); + tessellator.addVertexWithUV(d12, d14, d15, d5, d7); + tessellator.addVertexWithUV(d12, d14, d16, d9, d11); + int k1 = Direction.directionToFacing[i1]; + + if (flag) + { + k1 = Direction.directionToFacing[Direction.rotateOpposite[i1]]; + } + + byte b0 = 4; + + switch (i1) + { + case 0: + b0 = 5; + break; + case 1: + b0 = 3; + case 2: + default: + break; + case 3: + b0 = 2; + } + + if (k1 != 2 && (this.renderAllFaces || p_147773_1_.shouldSideBeRendered(this.blockAccess, p_147773_2_, p_147773_3_, p_147773_4_ - 1, 2))) + { + tessellator.setBrightness(this.renderMinZ > 0.0D ? j1 : p_147773_1_.getMixedBrightnessForBlock(this.blockAccess, p_147773_2_, p_147773_3_, p_147773_4_ - 1)); + tessellator.setColorOpaque_F(f2, f2, f2); + this.flipTexture = b0 == 2; + this.renderFaceZNeg(p_147773_1_, (double)p_147773_2_, (double)p_147773_3_, (double)p_147773_4_, this.getBlockIcon(p_147773_1_, this.blockAccess, p_147773_2_, p_147773_3_, p_147773_4_, 2)); + } + + if (k1 != 3 && (this.renderAllFaces || p_147773_1_.shouldSideBeRendered(this.blockAccess, p_147773_2_, p_147773_3_, p_147773_4_ + 1, 3))) + { + tessellator.setBrightness(this.renderMaxZ < 1.0D ? j1 : p_147773_1_.getMixedBrightnessForBlock(this.blockAccess, p_147773_2_, p_147773_3_, p_147773_4_ + 1)); + tessellator.setColorOpaque_F(f2, f2, f2); + this.flipTexture = b0 == 3; + this.renderFaceZPos(p_147773_1_, (double)p_147773_2_, (double)p_147773_3_, (double)p_147773_4_, this.getBlockIcon(p_147773_1_, this.blockAccess, p_147773_2_, p_147773_3_, p_147773_4_, 3)); + } + + if (k1 != 4 && (this.renderAllFaces || p_147773_1_.shouldSideBeRendered(this.blockAccess, p_147773_2_ - 1, p_147773_3_, p_147773_4_, 4))) + { + tessellator.setBrightness(this.renderMinZ > 0.0D ? j1 : p_147773_1_.getMixedBrightnessForBlock(this.blockAccess, p_147773_2_ - 1, p_147773_3_, p_147773_4_)); + tessellator.setColorOpaque_F(f3, f3, f3); + this.flipTexture = b0 == 4; + this.renderFaceXNeg(p_147773_1_, (double)p_147773_2_, (double)p_147773_3_, (double)p_147773_4_, this.getBlockIcon(p_147773_1_, this.blockAccess, p_147773_2_, p_147773_3_, p_147773_4_, 4)); + } + + if (k1 != 5 && (this.renderAllFaces || p_147773_1_.shouldSideBeRendered(this.blockAccess, p_147773_2_ + 1, p_147773_3_, p_147773_4_, 5))) + { + tessellator.setBrightness(this.renderMaxZ < 1.0D ? j1 : p_147773_1_.getMixedBrightnessForBlock(this.blockAccess, p_147773_2_ + 1, p_147773_3_, p_147773_4_)); + tessellator.setColorOpaque_F(f3, f3, f3); + this.flipTexture = b0 == 5; + this.renderFaceXPos(p_147773_1_, (double)p_147773_2_, (double)p_147773_3_, (double)p_147773_4_, this.getBlockIcon(p_147773_1_, this.blockAccess, p_147773_2_, p_147773_3_, p_147773_4_, 5)); + } + + this.flipTexture = false; + return true; + } + + public boolean renderBlockBrewingStand(BlockBrewingStand p_147741_1_, int p_147741_2_, int p_147741_3_, int p_147741_4_) + { + this.setRenderBounds(0.4375D, 0.0D, 0.4375D, 0.5625D, 0.875D, 0.5625D); + this.renderStandardBlock(p_147741_1_, p_147741_2_, p_147741_3_, p_147741_4_); + this.setOverrideBlockTexture(p_147741_1_.getIconBrewingStandBase()); + this.renderAllFaces = true; + this.setRenderBounds(0.5625D, 0.0D, 0.3125D, 0.9375D, 0.125D, 0.6875D); + this.renderStandardBlock(p_147741_1_, p_147741_2_, p_147741_3_, p_147741_4_); + this.setRenderBounds(0.125D, 0.0D, 0.0625D, 0.5D, 0.125D, 0.4375D); + this.renderStandardBlock(p_147741_1_, p_147741_2_, p_147741_3_, p_147741_4_); + this.setRenderBounds(0.125D, 0.0D, 0.5625D, 0.5D, 0.125D, 0.9375D); + this.renderStandardBlock(p_147741_1_, p_147741_2_, p_147741_3_, p_147741_4_); + this.renderAllFaces = false; + this.clearOverrideBlockTexture(); + Tessellator tessellator = Tessellator.instance; + tessellator.setBrightness(p_147741_1_.getMixedBrightnessForBlock(this.blockAccess, p_147741_2_, p_147741_3_, p_147741_4_)); + int l = p_147741_1_.colorMultiplier(this.blockAccess, p_147741_2_, p_147741_3_, p_147741_4_); + float f = (float)(l >> 16 & 255) / 255.0F; + float f1 = (float)(l >> 8 & 255) / 255.0F; + float f2 = (float)(l & 255) / 255.0F; + + if (EntityRenderer.anaglyphEnable) + { + float f3 = (f * 30.0F + f1 * 59.0F + f2 * 11.0F) / 100.0F; + float f4 = (f * 30.0F + f1 * 70.0F) / 100.0F; + float f5 = (f * 30.0F + f2 * 70.0F) / 100.0F; + f = f3; + f1 = f4; + f2 = f5; + } + + tessellator.setColorOpaque_F(f, f1, f2); + IIcon iicon = this.getBlockIconFromSideAndMetadata(p_147741_1_, 0, 0); + + if (this.hasOverrideBlockTexture()) + { + iicon = this.overrideBlockTexture; + } + + double d8 = (double)iicon.getMinV(); + double d0 = (double)iicon.getMaxV(); + int i1 = this.blockAccess.getBlockMetadata(p_147741_2_, p_147741_3_, p_147741_4_); + + for (int j1 = 0; j1 < 3; ++j1) + { + double d1 = (double)j1 * Math.PI * 2.0D / 3.0D + (Math.PI / 2D); + double d2 = (double)iicon.getInterpolatedU(8.0D); + double d3 = (double)iicon.getMaxU(); + + if ((i1 & 1 << j1) != 0) + { + d3 = (double)iicon.getMinU(); + } + + double d4 = (double)p_147741_2_ + 0.5D; + double d5 = (double)p_147741_2_ + 0.5D + Math.sin(d1) * 8.0D / 16.0D; + double d6 = (double)p_147741_4_ + 0.5D; + double d7 = (double)p_147741_4_ + 0.5D + Math.cos(d1) * 8.0D / 16.0D; + tessellator.addVertexWithUV(d4, (double)(p_147741_3_ + 1), d6, d2, d8); + tessellator.addVertexWithUV(d4, (double)(p_147741_3_ + 0), d6, d2, d0); + tessellator.addVertexWithUV(d5, (double)(p_147741_3_ + 0), d7, d3, d0); + tessellator.addVertexWithUV(d5, (double)(p_147741_3_ + 1), d7, d3, d8); + tessellator.addVertexWithUV(d5, (double)(p_147741_3_ + 1), d7, d3, d8); + tessellator.addVertexWithUV(d5, (double)(p_147741_3_ + 0), d7, d3, d0); + tessellator.addVertexWithUV(d4, (double)(p_147741_3_ + 0), d6, d2, d0); + tessellator.addVertexWithUV(d4, (double)(p_147741_3_ + 1), d6, d2, d8); + } + + p_147741_1_.setBlockBoundsForItemRender(); + return true; + } + + public boolean renderBlockCauldron(BlockCauldron p_147785_1_, int p_147785_2_, int p_147785_3_, int p_147785_4_) + { + this.renderStandardBlock(p_147785_1_, p_147785_2_, p_147785_3_, p_147785_4_); + Tessellator tessellator = Tessellator.instance; + tessellator.setBrightness(p_147785_1_.getMixedBrightnessForBlock(this.blockAccess, p_147785_2_, p_147785_3_, p_147785_4_)); + int l = p_147785_1_.colorMultiplier(this.blockAccess, p_147785_2_, p_147785_3_, p_147785_4_); + float f = (float)(l >> 16 & 255) / 255.0F; + float f1 = (float)(l >> 8 & 255) / 255.0F; + float f2 = (float)(l & 255) / 255.0F; + float f4; + + if (EntityRenderer.anaglyphEnable) + { + float f3 = (f * 30.0F + f1 * 59.0F + f2 * 11.0F) / 100.0F; + f4 = (f * 30.0F + f1 * 70.0F) / 100.0F; + float f5 = (f * 30.0F + f2 * 70.0F) / 100.0F; + f = f3; + f1 = f4; + f2 = f5; + } + + tessellator.setColorOpaque_F(f, f1, f2); + IIcon iicon1 = p_147785_1_.getBlockTextureFromSide(2); + f4 = 0.125F; + this.renderFaceXPos(p_147785_1_, (double)((float)p_147785_2_ - 1.0F + f4), (double)p_147785_3_, (double)p_147785_4_, iicon1); + this.renderFaceXNeg(p_147785_1_, (double)((float)p_147785_2_ + 1.0F - f4), (double)p_147785_3_, (double)p_147785_4_, iicon1); + this.renderFaceZPos(p_147785_1_, (double)p_147785_2_, (double)p_147785_3_, (double)((float)p_147785_4_ - 1.0F + f4), iicon1); + this.renderFaceZNeg(p_147785_1_, (double)p_147785_2_, (double)p_147785_3_, (double)((float)p_147785_4_ + 1.0F - f4), iicon1); + IIcon iicon2 = BlockCauldron.getCauldronIcon("inner"); + this.renderFaceYPos(p_147785_1_, (double)p_147785_2_, (double)((float)p_147785_3_ - 1.0F + 0.25F), (double)p_147785_4_, iicon2); + this.renderFaceYNeg(p_147785_1_, (double)p_147785_2_, (double)((float)p_147785_3_ + 1.0F - 0.75F), (double)p_147785_4_, iicon2); + int i1 = this.blockAccess.getBlockMetadata(p_147785_2_, p_147785_3_, p_147785_4_); + + if (i1 > 0) + { + IIcon iicon = BlockLiquid.getLiquidIcon("water_still"); + this.renderFaceYPos(p_147785_1_, (double)p_147785_2_, (double)((float)p_147785_3_ - 1.0F + BlockCauldron.getRenderLiquidLevel(i1)), (double)p_147785_4_, iicon); + } + + return true; + } + + public boolean renderBlockFlowerpot(BlockFlowerPot p_147752_1_, int p_147752_2_, int p_147752_3_, int p_147752_4_) + { + this.renderStandardBlock(p_147752_1_, p_147752_2_, p_147752_3_, p_147752_4_); + Tessellator tessellator = Tessellator.instance; + tessellator.setBrightness(p_147752_1_.getMixedBrightnessForBlock(this.blockAccess, p_147752_2_, p_147752_3_, p_147752_4_)); + int l = p_147752_1_.colorMultiplier(this.blockAccess, p_147752_2_, p_147752_3_, p_147752_4_); + IIcon iicon = this.getBlockIconFromSide(p_147752_1_, 0); + float f = (float)(l >> 16 & 255) / 255.0F; + float f1 = (float)(l >> 8 & 255) / 255.0F; + float f2 = (float)(l & 255) / 255.0F; + float f3; + + if (EntityRenderer.anaglyphEnable) + { + f3 = (f * 30.0F + f1 * 59.0F + f2 * 11.0F) / 100.0F; + float f4 = (f * 30.0F + f1 * 70.0F) / 100.0F; + float f5 = (f * 30.0F + f2 * 70.0F) / 100.0F; + f = f3; + f1 = f4; + f2 = f5; + } + + tessellator.setColorOpaque_F(f, f1, f2); + f3 = 0.1865F; + this.renderFaceXPos(p_147752_1_, (double)((float)p_147752_2_ - 0.5F + f3), (double)p_147752_3_, (double)p_147752_4_, iicon); + this.renderFaceXNeg(p_147752_1_, (double)((float)p_147752_2_ + 0.5F - f3), (double)p_147752_3_, (double)p_147752_4_, iicon); + this.renderFaceZPos(p_147752_1_, (double)p_147752_2_, (double)p_147752_3_, (double)((float)p_147752_4_ - 0.5F + f3), iicon); + this.renderFaceZNeg(p_147752_1_, (double)p_147752_2_, (double)p_147752_3_, (double)((float)p_147752_4_ + 0.5F - f3), iicon); + this.renderFaceYPos(p_147752_1_, (double)p_147752_2_, (double)((float)p_147752_3_ - 0.5F + f3 + 0.1875F), (double)p_147752_4_, this.getBlockIcon(Blocks.dirt)); + TileEntity tileentity = this.blockAccess.getTileEntity(p_147752_2_, p_147752_3_, p_147752_4_); + + if (tileentity != null && tileentity instanceof TileEntityFlowerPot) + { + Item item = ((TileEntityFlowerPot)tileentity).getFlowerPotItem(); + int i1 = ((TileEntityFlowerPot)tileentity).getFlowerPotData(); + + if (item instanceof ItemBlock) + { + Block block = Block.getBlockFromItem(item); + int j1 = block.getRenderType(); + float f6 = 0.0F; + float f7 = 4.0F; + float f8 = 0.0F; + tessellator.addTranslation(f6 / 16.0F, f7 / 16.0F, f8 / 16.0F); + l = block.colorMultiplier(this.blockAccess, p_147752_2_, p_147752_3_, p_147752_4_); + + if (l != 16777215) + { + f = (float)(l >> 16 & 255) / 255.0F; + f1 = (float)(l >> 8 & 255) / 255.0F; + f2 = (float)(l & 255) / 255.0F; + tessellator.setColorOpaque_F(f, f1, f2); + } + + if (j1 == 1) + { + this.drawCrossedSquares(this.getBlockIconFromSideAndMetadata(block, 0, i1), (double)p_147752_2_, (double)p_147752_3_, (double)p_147752_4_, 0.75F); + } + else if (j1 == 13) + { + this.renderAllFaces = true; + float f9 = 0.125F; + this.setRenderBounds((double)(0.5F - f9), 0.0D, (double)(0.5F - f9), (double)(0.5F + f9), 0.25D, (double)(0.5F + f9)); + this.renderStandardBlock(block, p_147752_2_, p_147752_3_, p_147752_4_); + this.setRenderBounds((double)(0.5F - f9), 0.25D, (double)(0.5F - f9), (double)(0.5F + f9), 0.5D, (double)(0.5F + f9)); + this.renderStandardBlock(block, p_147752_2_, p_147752_3_, p_147752_4_); + this.setRenderBounds((double)(0.5F - f9), 0.5D, (double)(0.5F - f9), (double)(0.5F + f9), 0.75D, (double)(0.5F + f9)); + this.renderStandardBlock(block, p_147752_2_, p_147752_3_, p_147752_4_); + this.renderAllFaces = false; + this.setRenderBounds(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D); + } + + tessellator.addTranslation(-f6 / 16.0F, -f7 / 16.0F, -f8 / 16.0F); + } + } + + return true; + } + + public boolean renderBlockAnvil(BlockAnvil p_147725_1_, int p_147725_2_, int p_147725_3_, int p_147725_4_) + { + return this.renderBlockAnvilMetadata(p_147725_1_, p_147725_2_, p_147725_3_, p_147725_4_, this.blockAccess.getBlockMetadata(p_147725_2_, p_147725_3_, p_147725_4_)); + } + + public boolean renderBlockAnvilMetadata(BlockAnvil p_147780_1_, int p_147780_2_, int p_147780_3_, int p_147780_4_, int p_147780_5_) + { + Tessellator tessellator = Tessellator.instance; + tessellator.setBrightness(p_147780_1_.getMixedBrightnessForBlock(this.blockAccess, p_147780_2_, p_147780_3_, p_147780_4_)); + int i1 = p_147780_1_.colorMultiplier(this.blockAccess, p_147780_2_, p_147780_3_, p_147780_4_); + float f = (float)(i1 >> 16 & 255) / 255.0F; + float f1 = (float)(i1 >> 8 & 255) / 255.0F; + float f2 = (float)(i1 & 255) / 255.0F; + + if (EntityRenderer.anaglyphEnable) + { + float f3 = (f * 30.0F + f1 * 59.0F + f2 * 11.0F) / 100.0F; + float f4 = (f * 30.0F + f1 * 70.0F) / 100.0F; + float f5 = (f * 30.0F + f2 * 70.0F) / 100.0F; + f = f3; + f1 = f4; + f2 = f5; + } + + tessellator.setColorOpaque_F(f, f1, f2); + return this.renderBlockAnvilOrient(p_147780_1_, p_147780_2_, p_147780_3_, p_147780_4_, p_147780_5_, false); + } + + public boolean renderBlockAnvilOrient(BlockAnvil p_147728_1_, int p_147728_2_, int p_147728_3_, int p_147728_4_, int p_147728_5_, boolean p_147728_6_) + { + int i1 = p_147728_6_ ? 0 : p_147728_5_ & 3; + boolean flag1 = false; + float f = 0.0F; + + switch (i1) + { + case 0: + this.uvRotateSouth = 2; + this.uvRotateNorth = 1; + this.uvRotateTop = 3; + this.uvRotateBottom = 3; + break; + case 1: + this.uvRotateEast = 1; + this.uvRotateWest = 2; + this.uvRotateTop = 2; + this.uvRotateBottom = 1; + flag1 = true; + break; + case 2: + this.uvRotateSouth = 1; + this.uvRotateNorth = 2; + break; + case 3: + this.uvRotateEast = 2; + this.uvRotateWest = 1; + this.uvRotateTop = 1; + this.uvRotateBottom = 2; + flag1 = true; + } + + f = this.renderBlockAnvilRotate(p_147728_1_, p_147728_2_, p_147728_3_, p_147728_4_, 0, f, 0.75F, 0.25F, 0.75F, flag1, p_147728_6_, p_147728_5_); + f = this.renderBlockAnvilRotate(p_147728_1_, p_147728_2_, p_147728_3_, p_147728_4_, 1, f, 0.5F, 0.0625F, 0.625F, flag1, p_147728_6_, p_147728_5_); + f = this.renderBlockAnvilRotate(p_147728_1_, p_147728_2_, p_147728_3_, p_147728_4_, 2, f, 0.25F, 0.3125F, 0.5F, flag1, p_147728_6_, p_147728_5_); + this.renderBlockAnvilRotate(p_147728_1_, p_147728_2_, p_147728_3_, p_147728_4_, 3, f, 0.625F, 0.375F, 1.0F, flag1, p_147728_6_, p_147728_5_); + this.setRenderBounds(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D); + this.uvRotateEast = 0; + this.uvRotateWest = 0; + this.uvRotateSouth = 0; + this.uvRotateNorth = 0; + this.uvRotateTop = 0; + this.uvRotateBottom = 0; + return true; + } + + public float renderBlockAnvilRotate(BlockAnvil p_147737_1_, int p_147737_2_, int p_147737_3_, int p_147737_4_, int p_147737_5_, float p_147737_6_, float p_147737_7_, float p_147737_8_, float p_147737_9_, boolean p_147737_10_, boolean p_147737_11_, int p_147737_12_) + { + if (p_147737_10_) + { + float f4 = p_147737_7_; + p_147737_7_ = p_147737_9_; + p_147737_9_ = f4; + } + + p_147737_7_ /= 2.0F; + p_147737_9_ /= 2.0F; + p_147737_1_.anvilRenderSide = p_147737_5_; + this.setRenderBounds((double)(0.5F - p_147737_7_), (double)p_147737_6_, (double)(0.5F - p_147737_9_), (double)(0.5F + p_147737_7_), (double)(p_147737_6_ + p_147737_8_), (double)(0.5F + p_147737_9_)); + + if (p_147737_11_) + { + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + this.renderFaceYNeg(p_147737_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSideAndMetadata(p_147737_1_, 0, p_147737_12_)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + this.renderFaceYPos(p_147737_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSideAndMetadata(p_147737_1_, 1, p_147737_12_)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, -1.0F); + this.renderFaceZNeg(p_147737_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSideAndMetadata(p_147737_1_, 2, p_147737_12_)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + this.renderFaceZPos(p_147737_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSideAndMetadata(p_147737_1_, 3, p_147737_12_)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + this.renderFaceXNeg(p_147737_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSideAndMetadata(p_147737_1_, 4, p_147737_12_)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + this.renderFaceXPos(p_147737_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSideAndMetadata(p_147737_1_, 5, p_147737_12_)); + tessellator.draw(); + } + else + { + this.renderStandardBlock(p_147737_1_, p_147737_2_, p_147737_3_, p_147737_4_); + } + + return p_147737_6_ + p_147737_8_; + } + + public boolean renderBlockTorch(Block p_147791_1_, int p_147791_2_, int p_147791_3_, int p_147791_4_) + { + int l = this.blockAccess.getBlockMetadata(p_147791_2_, p_147791_3_, p_147791_4_); + Tessellator tessellator = Tessellator.instance; + tessellator.setBrightness(p_147791_1_.getMixedBrightnessForBlock(this.blockAccess, p_147791_2_, p_147791_3_, p_147791_4_)); + tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F); + double d0 = 0.4000000059604645D; + double d1 = 0.5D - d0; + double d2 = 0.20000000298023224D; + + if (l == 1) + { + this.renderTorchAtAngle(p_147791_1_, (double)p_147791_2_ - d1, (double)p_147791_3_ + d2, (double)p_147791_4_, -d0, 0.0D, 0); + } + else if (l == 2) + { + this.renderTorchAtAngle(p_147791_1_, (double)p_147791_2_ + d1, (double)p_147791_3_ + d2, (double)p_147791_4_, d0, 0.0D, 0); + } + else if (l == 3) + { + this.renderTorchAtAngle(p_147791_1_, (double)p_147791_2_, (double)p_147791_3_ + d2, (double)p_147791_4_ - d1, 0.0D, -d0, 0); + } + else if (l == 4) + { + this.renderTorchAtAngle(p_147791_1_, (double)p_147791_2_, (double)p_147791_3_ + d2, (double)p_147791_4_ + d1, 0.0D, d0, 0); + } + else + { + this.renderTorchAtAngle(p_147791_1_, (double)p_147791_2_, (double)p_147791_3_, (double)p_147791_4_, 0.0D, 0.0D, 0); + } + + return true; + } + + public boolean renderBlockRepeater(BlockRedstoneRepeater p_147759_1_, int p_147759_2_, int p_147759_3_, int p_147759_4_) + { + int l = this.blockAccess.getBlockMetadata(p_147759_2_, p_147759_3_, p_147759_4_); + int i1 = l & 3; + int j1 = (l & 12) >> 2; + Tessellator tessellator = Tessellator.instance; + tessellator.setBrightness(p_147759_1_.getMixedBrightnessForBlock(this.blockAccess, p_147759_2_, p_147759_3_, p_147759_4_)); + tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F); + double d0 = -0.1875D; + boolean flag = p_147759_1_.func_149910_g(this.blockAccess, p_147759_2_, p_147759_3_, p_147759_4_, l); + double d1 = 0.0D; + double d2 = 0.0D; + double d3 = 0.0D; + double d4 = 0.0D; + + switch (i1) + { + case 0: + d4 = -0.3125D; + d2 = BlockRedstoneRepeater.repeaterTorchOffset[j1]; + break; + case 1: + d3 = 0.3125D; + d1 = -BlockRedstoneRepeater.repeaterTorchOffset[j1]; + break; + case 2: + d4 = 0.3125D; + d2 = -BlockRedstoneRepeater.repeaterTorchOffset[j1]; + break; + case 3: + d3 = -0.3125D; + d1 = BlockRedstoneRepeater.repeaterTorchOffset[j1]; + } + + if (!flag) + { + this.renderTorchAtAngle(p_147759_1_, (double)p_147759_2_ + d1, (double)p_147759_3_ + d0, (double)p_147759_4_ + d2, 0.0D, 0.0D, 0); + } + else + { + IIcon iicon = this.getBlockIcon(Blocks.bedrock); + this.setOverrideBlockTexture(iicon); + float f = 2.0F; + float f1 = 14.0F; + float f2 = 7.0F; + float f3 = 9.0F; + + switch (i1) + { + case 1: + case 3: + f = 7.0F; + f1 = 9.0F; + f2 = 2.0F; + f3 = 14.0F; + case 0: + case 2: + default: + this.setRenderBounds((double)(f / 16.0F + (float)d1), 0.125D, (double)(f2 / 16.0F + (float)d2), (double)(f1 / 16.0F + (float)d1), 0.25D, (double)(f3 / 16.0F + (float)d2)); + double d5 = (double)iicon.getInterpolatedU((double)f); + double d6 = (double)iicon.getInterpolatedV((double)f2); + double d7 = (double)iicon.getInterpolatedU((double)f1); + double d8 = (double)iicon.getInterpolatedV((double)f3); + tessellator.addVertexWithUV((double)((float)p_147759_2_ + f / 16.0F) + d1, (double)((float)p_147759_3_ + 0.25F), (double)((float)p_147759_4_ + f2 / 16.0F) + d2, d5, d6); + tessellator.addVertexWithUV((double)((float)p_147759_2_ + f / 16.0F) + d1, (double)((float)p_147759_3_ + 0.25F), (double)((float)p_147759_4_ + f3 / 16.0F) + d2, d5, d8); + tessellator.addVertexWithUV((double)((float)p_147759_2_ + f1 / 16.0F) + d1, (double)((float)p_147759_3_ + 0.25F), (double)((float)p_147759_4_ + f3 / 16.0F) + d2, d7, d8); + tessellator.addVertexWithUV((double)((float)p_147759_2_ + f1 / 16.0F) + d1, (double)((float)p_147759_3_ + 0.25F), (double)((float)p_147759_4_ + f2 / 16.0F) + d2, d7, d6); + this.renderStandardBlock(p_147759_1_, p_147759_2_, p_147759_3_, p_147759_4_); + this.setRenderBounds(0.0D, 0.0D, 0.0D, 1.0D, 0.125D, 1.0D); + this.clearOverrideBlockTexture(); + } + } + + tessellator.setBrightness(p_147759_1_.getMixedBrightnessForBlock(this.blockAccess, p_147759_2_, p_147759_3_, p_147759_4_)); + tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F); + this.renderTorchAtAngle(p_147759_1_, (double)p_147759_2_ + d3, (double)p_147759_3_ + d0, (double)p_147759_4_ + d4, 0.0D, 0.0D, 0); + this.renderBlockRedstoneDiode(p_147759_1_, p_147759_2_, p_147759_3_, p_147759_4_); + return true; + } + + public boolean renderBlockRedstoneComparator(BlockRedstoneComparator p_147781_1_, int p_147781_2_, int p_147781_3_, int p_147781_4_) + { + Tessellator tessellator = Tessellator.instance; + tessellator.setBrightness(p_147781_1_.getMixedBrightnessForBlock(this.blockAccess, p_147781_2_, p_147781_3_, p_147781_4_)); + tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F); + int l = this.blockAccess.getBlockMetadata(p_147781_2_, p_147781_3_, p_147781_4_); + int i1 = l & 3; + double d0 = 0.0D; + double d1 = -0.1875D; + double d2 = 0.0D; + double d3 = 0.0D; + double d4 = 0.0D; + IIcon iicon; + + if (p_147781_1_.func_149969_d(l)) + { + iicon = Blocks.redstone_torch.getBlockTextureFromSide(0); + } + else + { + d1 -= 0.1875D; + iicon = Blocks.unlit_redstone_torch.getBlockTextureFromSide(0); + } + + switch (i1) + { + case 0: + d2 = -0.3125D; + d4 = 1.0D; + break; + case 1: + d0 = 0.3125D; + d3 = -1.0D; + break; + case 2: + d2 = 0.3125D; + d4 = -1.0D; + break; + case 3: + d0 = -0.3125D; + d3 = 1.0D; + } + + this.renderTorchAtAngle(p_147781_1_, (double)p_147781_2_ + 0.25D * d3 + 0.1875D * d4, (double)((float)p_147781_3_ - 0.1875F), (double)p_147781_4_ + 0.25D * d4 + 0.1875D * d3, 0.0D, 0.0D, l); + this.renderTorchAtAngle(p_147781_1_, (double)p_147781_2_ + 0.25D * d3 + -0.1875D * d4, (double)((float)p_147781_3_ - 0.1875F), (double)p_147781_4_ + 0.25D * d4 + -0.1875D * d3, 0.0D, 0.0D, l); + this.setOverrideBlockTexture(iicon); + this.renderTorchAtAngle(p_147781_1_, (double)p_147781_2_ + d0, (double)p_147781_3_ + d1, (double)p_147781_4_ + d2, 0.0D, 0.0D, l); + this.clearOverrideBlockTexture(); + this.renderBlockRedstoneDiodeMetadata(p_147781_1_, p_147781_2_, p_147781_3_, p_147781_4_, i1); + return true; + } + + public boolean renderBlockRedstoneDiode(BlockRedstoneDiode p_147748_1_, int p_147748_2_, int p_147748_3_, int p_147748_4_) + { + Tessellator tessellator = Tessellator.instance; + this.renderBlockRedstoneDiodeMetadata(p_147748_1_, p_147748_2_, p_147748_3_, p_147748_4_, this.blockAccess.getBlockMetadata(p_147748_2_, p_147748_3_, p_147748_4_) & 3); + return true; + } + + public void renderBlockRedstoneDiodeMetadata(BlockRedstoneDiode p_147732_1_, int p_147732_2_, int p_147732_3_, int p_147732_4_, int p_147732_5_) + { + this.renderStandardBlock(p_147732_1_, p_147732_2_, p_147732_3_, p_147732_4_); + Tessellator tessellator = Tessellator.instance; + tessellator.setBrightness(p_147732_1_.getMixedBrightnessForBlock(this.blockAccess, p_147732_2_, p_147732_3_, p_147732_4_)); + tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F); + int i1 = this.blockAccess.getBlockMetadata(p_147732_2_, p_147732_3_, p_147732_4_); + IIcon iicon = this.getBlockIconFromSideAndMetadata(p_147732_1_, 1, i1); + double d0 = (double)iicon.getMinU(); + double d1 = (double)iicon.getMaxU(); + double d2 = (double)iicon.getMinV(); + double d3 = (double)iicon.getMaxV(); + double d4 = 0.125D; + double d5 = (double)(p_147732_2_ + 1); + double d6 = (double)(p_147732_2_ + 1); + double d7 = (double)(p_147732_2_ + 0); + double d8 = (double)(p_147732_2_ + 0); + double d9 = (double)(p_147732_4_ + 0); + double d10 = (double)(p_147732_4_ + 1); + double d11 = (double)(p_147732_4_ + 1); + double d12 = (double)(p_147732_4_ + 0); + double d13 = (double)p_147732_3_ + d4; + + if (p_147732_5_ == 2) + { + d5 = d6 = (double)(p_147732_2_ + 0); + d7 = d8 = (double)(p_147732_2_ + 1); + d9 = d12 = (double)(p_147732_4_ + 1); + d10 = d11 = (double)(p_147732_4_ + 0); + } + else if (p_147732_5_ == 3) + { + d5 = d8 = (double)(p_147732_2_ + 0); + d6 = d7 = (double)(p_147732_2_ + 1); + d9 = d10 = (double)(p_147732_4_ + 0); + d11 = d12 = (double)(p_147732_4_ + 1); + } + else if (p_147732_5_ == 1) + { + d5 = d8 = (double)(p_147732_2_ + 1); + d6 = d7 = (double)(p_147732_2_ + 0); + d9 = d10 = (double)(p_147732_4_ + 1); + d11 = d12 = (double)(p_147732_4_ + 0); + } + + tessellator.addVertexWithUV(d8, d13, d12, d0, d2); + tessellator.addVertexWithUV(d7, d13, d11, d0, d3); + tessellator.addVertexWithUV(d6, d13, d10, d1, d3); + tessellator.addVertexWithUV(d5, d13, d9, d1, d2); + } + + public void renderPistonBaseAllFaces(Block p_147804_1_, int p_147804_2_, int p_147804_3_, int p_147804_4_) + { + this.renderAllFaces = true; + this.renderPistonBase(p_147804_1_, p_147804_2_, p_147804_3_, p_147804_4_, true); + this.renderAllFaces = false; + } + + public boolean renderPistonBase(Block p_147731_1_, int p_147731_2_, int p_147731_3_, int p_147731_4_, boolean p_147731_5_) + { + int l = this.blockAccess.getBlockMetadata(p_147731_2_, p_147731_3_, p_147731_4_); + boolean flag1 = p_147731_5_ || (l & 8) != 0; + int i1 = BlockPistonBase.getPistonOrientation(l); + float f = 0.25F; + + if (flag1) + { + switch (i1) + { + case 0: + this.uvRotateEast = 3; + this.uvRotateWest = 3; + this.uvRotateSouth = 3; + this.uvRotateNorth = 3; + this.setRenderBounds(0.0D, 0.25D, 0.0D, 1.0D, 1.0D, 1.0D); + break; + case 1: + this.setRenderBounds(0.0D, 0.0D, 0.0D, 1.0D, 0.75D, 1.0D); + break; + case 2: + this.uvRotateSouth = 1; + this.uvRotateNorth = 2; + this.setRenderBounds(0.0D, 0.0D, 0.25D, 1.0D, 1.0D, 1.0D); + break; + case 3: + this.uvRotateSouth = 2; + this.uvRotateNorth = 1; + this.uvRotateTop = 3; + this.uvRotateBottom = 3; + this.setRenderBounds(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 0.75D); + break; + case 4: + this.uvRotateEast = 1; + this.uvRotateWest = 2; + this.uvRotateTop = 2; + this.uvRotateBottom = 1; + this.setRenderBounds(0.25D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D); + break; + case 5: + this.uvRotateEast = 2; + this.uvRotateWest = 1; + this.uvRotateTop = 1; + this.uvRotateBottom = 2; + this.setRenderBounds(0.0D, 0.0D, 0.0D, 0.75D, 1.0D, 1.0D); + } + + ((BlockPistonBase)p_147731_1_).func_150070_b((float)this.renderMinX, (float)this.renderMinY, (float)this.renderMinZ, (float)this.renderMaxX, (float)this.renderMaxY, (float)this.renderMaxZ); + this.renderStandardBlock(p_147731_1_, p_147731_2_, p_147731_3_, p_147731_4_); + this.uvRotateEast = 0; + this.uvRotateWest = 0; + this.uvRotateSouth = 0; + this.uvRotateNorth = 0; + this.uvRotateTop = 0; + this.uvRotateBottom = 0; + this.setRenderBounds(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D); + ((BlockPistonBase)p_147731_1_).func_150070_b((float)this.renderMinX, (float)this.renderMinY, (float)this.renderMinZ, (float)this.renderMaxX, (float)this.renderMaxY, (float)this.renderMaxZ); + } + else + { + switch (i1) + { + case 0: + this.uvRotateEast = 3; + this.uvRotateWest = 3; + this.uvRotateSouth = 3; + this.uvRotateNorth = 3; + case 1: + default: + break; + case 2: + this.uvRotateSouth = 1; + this.uvRotateNorth = 2; + break; + case 3: + this.uvRotateSouth = 2; + this.uvRotateNorth = 1; + this.uvRotateTop = 3; + this.uvRotateBottom = 3; + break; + case 4: + this.uvRotateEast = 1; + this.uvRotateWest = 2; + this.uvRotateTop = 2; + this.uvRotateBottom = 1; + break; + case 5: + this.uvRotateEast = 2; + this.uvRotateWest = 1; + this.uvRotateTop = 1; + this.uvRotateBottom = 2; + } + + this.renderStandardBlock(p_147731_1_, p_147731_2_, p_147731_3_, p_147731_4_); + this.uvRotateEast = 0; + this.uvRotateWest = 0; + this.uvRotateSouth = 0; + this.uvRotateNorth = 0; + this.uvRotateTop = 0; + this.uvRotateBottom = 0; + } + + return true; + } + + public void renderPistonRodUD(double p_147763_1_, double p_147763_3_, double p_147763_5_, double p_147763_7_, double p_147763_9_, double p_147763_11_, float p_147763_13_, double p_147763_14_) + { + IIcon iicon = BlockPistonBase.getPistonBaseIcon("piston_side"); + + if (this.hasOverrideBlockTexture()) + { + iicon = this.overrideBlockTexture; + } + + Tessellator tessellator = Tessellator.instance; + double d7 = (double)iicon.getMinU(); + double d8 = (double)iicon.getMinV(); + double d9 = (double)iicon.getInterpolatedU(p_147763_14_); + double d10 = (double)iicon.getInterpolatedV(4.0D); + tessellator.setColorOpaque_F(p_147763_13_, p_147763_13_, p_147763_13_); + tessellator.addVertexWithUV(p_147763_1_, p_147763_7_, p_147763_9_, d9, d8); + tessellator.addVertexWithUV(p_147763_1_, p_147763_5_, p_147763_9_, d7, d8); + tessellator.addVertexWithUV(p_147763_3_, p_147763_5_, p_147763_11_, d7, d10); + tessellator.addVertexWithUV(p_147763_3_, p_147763_7_, p_147763_11_, d9, d10); + } + + public void renderPistonRodSN(double p_147789_1_, double p_147789_3_, double p_147789_5_, double p_147789_7_, double p_147789_9_, double p_147789_11_, float p_147789_13_, double p_147789_14_) + { + IIcon iicon = BlockPistonBase.getPistonBaseIcon("piston_side"); + + if (this.hasOverrideBlockTexture()) + { + iicon = this.overrideBlockTexture; + } + + Tessellator tessellator = Tessellator.instance; + double d7 = (double)iicon.getMinU(); + double d8 = (double)iicon.getMinV(); + double d9 = (double)iicon.getInterpolatedU(p_147789_14_); + double d10 = (double)iicon.getInterpolatedV(4.0D); + tessellator.setColorOpaque_F(p_147789_13_, p_147789_13_, p_147789_13_); + tessellator.addVertexWithUV(p_147789_1_, p_147789_5_, p_147789_11_, d9, d8); + tessellator.addVertexWithUV(p_147789_1_, p_147789_5_, p_147789_9_, d7, d8); + tessellator.addVertexWithUV(p_147789_3_, p_147789_7_, p_147789_9_, d7, d10); + tessellator.addVertexWithUV(p_147789_3_, p_147789_7_, p_147789_11_, d9, d10); + } + + public void renderPistonRodEW(double p_147738_1_, double p_147738_3_, double p_147738_5_, double p_147738_7_, double p_147738_9_, double p_147738_11_, float p_147738_13_, double p_147738_14_) + { + IIcon iicon = BlockPistonBase.getPistonBaseIcon("piston_side"); + + if (this.hasOverrideBlockTexture()) + { + iicon = this.overrideBlockTexture; + } + + Tessellator tessellator = Tessellator.instance; + double d7 = (double)iicon.getMinU(); + double d8 = (double)iicon.getMinV(); + double d9 = (double)iicon.getInterpolatedU(p_147738_14_); + double d10 = (double)iicon.getInterpolatedV(4.0D); + tessellator.setColorOpaque_F(p_147738_13_, p_147738_13_, p_147738_13_); + tessellator.addVertexWithUV(p_147738_3_, p_147738_5_, p_147738_9_, d9, d8); + tessellator.addVertexWithUV(p_147738_1_, p_147738_5_, p_147738_9_, d7, d8); + tessellator.addVertexWithUV(p_147738_1_, p_147738_7_, p_147738_11_, d7, d10); + tessellator.addVertexWithUV(p_147738_3_, p_147738_7_, p_147738_11_, d9, d10); + } + + public void renderPistonExtensionAllFaces(Block p_147750_1_, int p_147750_2_, int p_147750_3_, int p_147750_4_, boolean p_147750_5_) + { + this.renderAllFaces = true; + this.renderPistonExtension(p_147750_1_, p_147750_2_, p_147750_3_, p_147750_4_, p_147750_5_); + this.renderAllFaces = false; + } + + public boolean renderPistonExtension(Block p_147809_1_, int p_147809_2_, int p_147809_3_, int p_147809_4_, boolean p_147809_5_) + { + int l = this.blockAccess.getBlockMetadata(p_147809_2_, p_147809_3_, p_147809_4_); + int i1 = BlockPistonExtension.getDirectionMeta(l); + float f = 0.25F; + float f1 = 0.375F; + float f2 = 0.625F; + float f3 = p_147809_5_ ? 1.0F : 0.5F; + double d0 = p_147809_5_ ? 16.0D : 8.0D; + + switch (i1) + { + case 0: + this.uvRotateEast = 3; + this.uvRotateWest = 3; + this.uvRotateSouth = 3; + this.uvRotateNorth = 3; + this.setRenderBounds(0.0D, 0.0D, 0.0D, 1.0D, 0.25D, 1.0D); + this.renderStandardBlock(p_147809_1_, p_147809_2_, p_147809_3_, p_147809_4_); + this.renderPistonRodUD((double)((float)p_147809_2_ + 0.375F), (double)((float)p_147809_2_ + 0.625F), (double)((float)p_147809_3_ + 0.25F), (double)((float)p_147809_3_ + 0.25F + f3), (double)((float)p_147809_4_ + 0.625F), (double)((float)p_147809_4_ + 0.625F), 0.8F, d0); + this.renderPistonRodUD((double)((float)p_147809_2_ + 0.625F), (double)((float)p_147809_2_ + 0.375F), (double)((float)p_147809_3_ + 0.25F), (double)((float)p_147809_3_ + 0.25F + f3), (double)((float)p_147809_4_ + 0.375F), (double)((float)p_147809_4_ + 0.375F), 0.8F, d0); + this.renderPistonRodUD((double)((float)p_147809_2_ + 0.375F), (double)((float)p_147809_2_ + 0.375F), (double)((float)p_147809_3_ + 0.25F), (double)((float)p_147809_3_ + 0.25F + f3), (double)((float)p_147809_4_ + 0.375F), (double)((float)p_147809_4_ + 0.625F), 0.6F, d0); + this.renderPistonRodUD((double)((float)p_147809_2_ + 0.625F), (double)((float)p_147809_2_ + 0.625F), (double)((float)p_147809_3_ + 0.25F), (double)((float)p_147809_3_ + 0.25F + f3), (double)((float)p_147809_4_ + 0.625F), (double)((float)p_147809_4_ + 0.375F), 0.6F, d0); + break; + case 1: + this.setRenderBounds(0.0D, 0.75D, 0.0D, 1.0D, 1.0D, 1.0D); + this.renderStandardBlock(p_147809_1_, p_147809_2_, p_147809_3_, p_147809_4_); + this.renderPistonRodUD((double)((float)p_147809_2_ + 0.375F), (double)((float)p_147809_2_ + 0.625F), (double)((float)p_147809_3_ - 0.25F + 1.0F - f3), (double)((float)p_147809_3_ - 0.25F + 1.0F), (double)((float)p_147809_4_ + 0.625F), (double)((float)p_147809_4_ + 0.625F), 0.8F, d0); + this.renderPistonRodUD((double)((float)p_147809_2_ + 0.625F), (double)((float)p_147809_2_ + 0.375F), (double)((float)p_147809_3_ - 0.25F + 1.0F - f3), (double)((float)p_147809_3_ - 0.25F + 1.0F), (double)((float)p_147809_4_ + 0.375F), (double)((float)p_147809_4_ + 0.375F), 0.8F, d0); + this.renderPistonRodUD((double)((float)p_147809_2_ + 0.375F), (double)((float)p_147809_2_ + 0.375F), (double)((float)p_147809_3_ - 0.25F + 1.0F - f3), (double)((float)p_147809_3_ - 0.25F + 1.0F), (double)((float)p_147809_4_ + 0.375F), (double)((float)p_147809_4_ + 0.625F), 0.6F, d0); + this.renderPistonRodUD((double)((float)p_147809_2_ + 0.625F), (double)((float)p_147809_2_ + 0.625F), (double)((float)p_147809_3_ - 0.25F + 1.0F - f3), (double)((float)p_147809_3_ - 0.25F + 1.0F), (double)((float)p_147809_4_ + 0.625F), (double)((float)p_147809_4_ + 0.375F), 0.6F, d0); + break; + case 2: + this.uvRotateSouth = 1; + this.uvRotateNorth = 2; + this.setRenderBounds(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 0.25D); + this.renderStandardBlock(p_147809_1_, p_147809_2_, p_147809_3_, p_147809_4_); + this.renderPistonRodSN((double)((float)p_147809_2_ + 0.375F), (double)((float)p_147809_2_ + 0.375F), (double)((float)p_147809_3_ + 0.625F), (double)((float)p_147809_3_ + 0.375F), (double)((float)p_147809_4_ + 0.25F), (double)((float)p_147809_4_ + 0.25F + f3), 0.6F, d0); + this.renderPistonRodSN((double)((float)p_147809_2_ + 0.625F), (double)((float)p_147809_2_ + 0.625F), (double)((float)p_147809_3_ + 0.375F), (double)((float)p_147809_3_ + 0.625F), (double)((float)p_147809_4_ + 0.25F), (double)((float)p_147809_4_ + 0.25F + f3), 0.6F, d0); + this.renderPistonRodSN((double)((float)p_147809_2_ + 0.375F), (double)((float)p_147809_2_ + 0.625F), (double)((float)p_147809_3_ + 0.375F), (double)((float)p_147809_3_ + 0.375F), (double)((float)p_147809_4_ + 0.25F), (double)((float)p_147809_4_ + 0.25F + f3), 0.5F, d0); + this.renderPistonRodSN((double)((float)p_147809_2_ + 0.625F), (double)((float)p_147809_2_ + 0.375F), (double)((float)p_147809_3_ + 0.625F), (double)((float)p_147809_3_ + 0.625F), (double)((float)p_147809_4_ + 0.25F), (double)((float)p_147809_4_ + 0.25F + f3), 1.0F, d0); + break; + case 3: + this.uvRotateSouth = 2; + this.uvRotateNorth = 1; + this.uvRotateTop = 3; + this.uvRotateBottom = 3; + this.setRenderBounds(0.0D, 0.0D, 0.75D, 1.0D, 1.0D, 1.0D); + this.renderStandardBlock(p_147809_1_, p_147809_2_, p_147809_3_, p_147809_4_); + this.renderPistonRodSN((double)((float)p_147809_2_ + 0.375F), (double)((float)p_147809_2_ + 0.375F), (double)((float)p_147809_3_ + 0.625F), (double)((float)p_147809_3_ + 0.375F), (double)((float)p_147809_4_ - 0.25F + 1.0F - f3), (double)((float)p_147809_4_ - 0.25F + 1.0F), 0.6F, d0); + this.renderPistonRodSN((double)((float)p_147809_2_ + 0.625F), (double)((float)p_147809_2_ + 0.625F), (double)((float)p_147809_3_ + 0.375F), (double)((float)p_147809_3_ + 0.625F), (double)((float)p_147809_4_ - 0.25F + 1.0F - f3), (double)((float)p_147809_4_ - 0.25F + 1.0F), 0.6F, d0); + this.renderPistonRodSN((double)((float)p_147809_2_ + 0.375F), (double)((float)p_147809_2_ + 0.625F), (double)((float)p_147809_3_ + 0.375F), (double)((float)p_147809_3_ + 0.375F), (double)((float)p_147809_4_ - 0.25F + 1.0F - f3), (double)((float)p_147809_4_ - 0.25F + 1.0F), 0.5F, d0); + this.renderPistonRodSN((double)((float)p_147809_2_ + 0.625F), (double)((float)p_147809_2_ + 0.375F), (double)((float)p_147809_3_ + 0.625F), (double)((float)p_147809_3_ + 0.625F), (double)((float)p_147809_4_ - 0.25F + 1.0F - f3), (double)((float)p_147809_4_ - 0.25F + 1.0F), 1.0F, d0); + break; + case 4: + this.uvRotateEast = 1; + this.uvRotateWest = 2; + this.uvRotateTop = 2; + this.uvRotateBottom = 1; + this.setRenderBounds(0.0D, 0.0D, 0.0D, 0.25D, 1.0D, 1.0D); + this.renderStandardBlock(p_147809_1_, p_147809_2_, p_147809_3_, p_147809_4_); + this.renderPistonRodEW((double)((float)p_147809_2_ + 0.25F), (double)((float)p_147809_2_ + 0.25F + f3), (double)((float)p_147809_3_ + 0.375F), (double)((float)p_147809_3_ + 0.375F), (double)((float)p_147809_4_ + 0.625F), (double)((float)p_147809_4_ + 0.375F), 0.5F, d0); + this.renderPistonRodEW((double)((float)p_147809_2_ + 0.25F), (double)((float)p_147809_2_ + 0.25F + f3), (double)((float)p_147809_3_ + 0.625F), (double)((float)p_147809_3_ + 0.625F), (double)((float)p_147809_4_ + 0.375F), (double)((float)p_147809_4_ + 0.625F), 1.0F, d0); + this.renderPistonRodEW((double)((float)p_147809_2_ + 0.25F), (double)((float)p_147809_2_ + 0.25F + f3), (double)((float)p_147809_3_ + 0.375F), (double)((float)p_147809_3_ + 0.625F), (double)((float)p_147809_4_ + 0.375F), (double)((float)p_147809_4_ + 0.375F), 0.6F, d0); + this.renderPistonRodEW((double)((float)p_147809_2_ + 0.25F), (double)((float)p_147809_2_ + 0.25F + f3), (double)((float)p_147809_3_ + 0.625F), (double)((float)p_147809_3_ + 0.375F), (double)((float)p_147809_4_ + 0.625F), (double)((float)p_147809_4_ + 0.625F), 0.6F, d0); + break; + case 5: + this.uvRotateEast = 2; + this.uvRotateWest = 1; + this.uvRotateTop = 1; + this.uvRotateBottom = 2; + this.setRenderBounds(0.75D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D); + this.renderStandardBlock(p_147809_1_, p_147809_2_, p_147809_3_, p_147809_4_); + this.renderPistonRodEW((double)((float)p_147809_2_ - 0.25F + 1.0F - f3), (double)((float)p_147809_2_ - 0.25F + 1.0F), (double)((float)p_147809_3_ + 0.375F), (double)((float)p_147809_3_ + 0.375F), (double)((float)p_147809_4_ + 0.625F), (double)((float)p_147809_4_ + 0.375F), 0.5F, d0); + this.renderPistonRodEW((double)((float)p_147809_2_ - 0.25F + 1.0F - f3), (double)((float)p_147809_2_ - 0.25F + 1.0F), (double)((float)p_147809_3_ + 0.625F), (double)((float)p_147809_3_ + 0.625F), (double)((float)p_147809_4_ + 0.375F), (double)((float)p_147809_4_ + 0.625F), 1.0F, d0); + this.renderPistonRodEW((double)((float)p_147809_2_ - 0.25F + 1.0F - f3), (double)((float)p_147809_2_ - 0.25F + 1.0F), (double)((float)p_147809_3_ + 0.375F), (double)((float)p_147809_3_ + 0.625F), (double)((float)p_147809_4_ + 0.375F), (double)((float)p_147809_4_ + 0.375F), 0.6F, d0); + this.renderPistonRodEW((double)((float)p_147809_2_ - 0.25F + 1.0F - f3), (double)((float)p_147809_2_ - 0.25F + 1.0F), (double)((float)p_147809_3_ + 0.625F), (double)((float)p_147809_3_ + 0.375F), (double)((float)p_147809_4_ + 0.625F), (double)((float)p_147809_4_ + 0.625F), 0.6F, d0); + } + + this.uvRotateEast = 0; + this.uvRotateWest = 0; + this.uvRotateSouth = 0; + this.uvRotateNorth = 0; + this.uvRotateTop = 0; + this.uvRotateBottom = 0; + this.setRenderBounds(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D); + return true; + } + + public boolean renderBlockLever(Block p_147790_1_, int p_147790_2_, int p_147790_3_, int p_147790_4_) + { + int l = this.blockAccess.getBlockMetadata(p_147790_2_, p_147790_3_, p_147790_4_); + int i1 = l & 7; + boolean flag = (l & 8) > 0; + Tessellator tessellator = Tessellator.instance; + boolean flag1 = this.hasOverrideBlockTexture(); + + if (!flag1) + { + this.setOverrideBlockTexture(this.getBlockIcon(Blocks.cobblestone)); + } + + float f = 0.25F; + float f1 = 0.1875F; + float f2 = 0.1875F; + + if (i1 == 5) + { + this.setRenderBounds((double)(0.5F - f1), 0.0D, (double)(0.5F - f), (double)(0.5F + f1), (double)f2, (double)(0.5F + f)); + } + else if (i1 == 6) + { + this.setRenderBounds((double)(0.5F - f), 0.0D, (double)(0.5F - f1), (double)(0.5F + f), (double)f2, (double)(0.5F + f1)); + } + else if (i1 == 4) + { + this.setRenderBounds((double)(0.5F - f1), (double)(0.5F - f), (double)(1.0F - f2), (double)(0.5F + f1), (double)(0.5F + f), 1.0D); + } + else if (i1 == 3) + { + this.setRenderBounds((double)(0.5F - f1), (double)(0.5F - f), 0.0D, (double)(0.5F + f1), (double)(0.5F + f), (double)f2); + } + else if (i1 == 2) + { + this.setRenderBounds((double)(1.0F - f2), (double)(0.5F - f), (double)(0.5F - f1), 1.0D, (double)(0.5F + f), (double)(0.5F + f1)); + } + else if (i1 == 1) + { + this.setRenderBounds(0.0D, (double)(0.5F - f), (double)(0.5F - f1), (double)f2, (double)(0.5F + f), (double)(0.5F + f1)); + } + else if (i1 == 0) + { + this.setRenderBounds((double)(0.5F - f), (double)(1.0F - f2), (double)(0.5F - f1), (double)(0.5F + f), 1.0D, (double)(0.5F + f1)); + } + else if (i1 == 7) + { + this.setRenderBounds((double)(0.5F - f1), (double)(1.0F - f2), (double)(0.5F - f), (double)(0.5F + f1), 1.0D, (double)(0.5F + f)); + } + + this.renderStandardBlock(p_147790_1_, p_147790_2_, p_147790_3_, p_147790_4_); + + if (!flag1) + { + this.clearOverrideBlockTexture(); + } + + tessellator.setBrightness(p_147790_1_.getMixedBrightnessForBlock(this.blockAccess, p_147790_2_, p_147790_3_, p_147790_4_)); + tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F); + IIcon iicon = this.getBlockIconFromSide(p_147790_1_, 0); + + if (this.hasOverrideBlockTexture()) + { + iicon = this.overrideBlockTexture; + } + + double d0 = (double)iicon.getMinU(); + double d1 = (double)iicon.getMinV(); + double d2 = (double)iicon.getMaxU(); + double d3 = (double)iicon.getMaxV(); + Vec3[] avec3 = new Vec3[8]; + float f3 = 0.0625F; + float f4 = 0.0625F; + float f5 = 0.625F; + avec3[0] = this.blockAccess.getWorldVec3Pool().getVecFromPool((double)(-f3), 0.0D, (double)(-f4)); + avec3[1] = this.blockAccess.getWorldVec3Pool().getVecFromPool((double)f3, 0.0D, (double)(-f4)); + avec3[2] = this.blockAccess.getWorldVec3Pool().getVecFromPool((double)f3, 0.0D, (double)f4); + avec3[3] = this.blockAccess.getWorldVec3Pool().getVecFromPool((double)(-f3), 0.0D, (double)f4); + avec3[4] = this.blockAccess.getWorldVec3Pool().getVecFromPool((double)(-f3), (double)f5, (double)(-f4)); + avec3[5] = this.blockAccess.getWorldVec3Pool().getVecFromPool((double)f3, (double)f5, (double)(-f4)); + avec3[6] = this.blockAccess.getWorldVec3Pool().getVecFromPool((double)f3, (double)f5, (double)f4); + avec3[7] = this.blockAccess.getWorldVec3Pool().getVecFromPool((double)(-f3), (double)f5, (double)f4); + + for (int j1 = 0; j1 < 8; ++j1) + { + if (flag) + { + avec3[j1].zCoord -= 0.0625D; + avec3[j1].rotateAroundX(((float)Math.PI * 2F / 9F)); + } + else + { + avec3[j1].zCoord += 0.0625D; + avec3[j1].rotateAroundX(-((float)Math.PI * 2F / 9F)); + } + + if (i1 == 0 || i1 == 7) + { + avec3[j1].rotateAroundZ((float)Math.PI); + } + + if (i1 == 6 || i1 == 0) + { + avec3[j1].rotateAroundY(((float)Math.PI / 2F)); + } + + if (i1 > 0 && i1 < 5) + { + avec3[j1].yCoord -= 0.375D; + avec3[j1].rotateAroundX(((float)Math.PI / 2F)); + + if (i1 == 4) + { + avec3[j1].rotateAroundY(0.0F); + } + + if (i1 == 3) + { + avec3[j1].rotateAroundY((float)Math.PI); + } + + if (i1 == 2) + { + avec3[j1].rotateAroundY(((float)Math.PI / 2F)); + } + + if (i1 == 1) + { + avec3[j1].rotateAroundY(-((float)Math.PI / 2F)); + } + + avec3[j1].xCoord += (double)p_147790_2_ + 0.5D; + avec3[j1].yCoord += (double)((float)p_147790_3_ + 0.5F); + avec3[j1].zCoord += (double)p_147790_4_ + 0.5D; + } + else if (i1 != 0 && i1 != 7) + { + avec3[j1].xCoord += (double)p_147790_2_ + 0.5D; + avec3[j1].yCoord += (double)((float)p_147790_3_ + 0.125F); + avec3[j1].zCoord += (double)p_147790_4_ + 0.5D; + } + else + { + avec3[j1].xCoord += (double)p_147790_2_ + 0.5D; + avec3[j1].yCoord += (double)((float)p_147790_3_ + 0.875F); + avec3[j1].zCoord += (double)p_147790_4_ + 0.5D; + } + } + + Vec3 vec33 = null; + Vec3 vec3 = null; + Vec3 vec31 = null; + Vec3 vec32 = null; + + for (int k1 = 0; k1 < 6; ++k1) + { + if (k1 == 0) + { + d0 = (double)iicon.getInterpolatedU(7.0D); + d1 = (double)iicon.getInterpolatedV(6.0D); + d2 = (double)iicon.getInterpolatedU(9.0D); + d3 = (double)iicon.getInterpolatedV(8.0D); + } + else if (k1 == 2) + { + d0 = (double)iicon.getInterpolatedU(7.0D); + d1 = (double)iicon.getInterpolatedV(6.0D); + d2 = (double)iicon.getInterpolatedU(9.0D); + d3 = (double)iicon.getMaxV(); + } + + if (k1 == 0) + { + vec33 = avec3[0]; + vec3 = avec3[1]; + vec31 = avec3[2]; + vec32 = avec3[3]; + } + else if (k1 == 1) + { + vec33 = avec3[7]; + vec3 = avec3[6]; + vec31 = avec3[5]; + vec32 = avec3[4]; + } + else if (k1 == 2) + { + vec33 = avec3[1]; + vec3 = avec3[0]; + vec31 = avec3[4]; + vec32 = avec3[5]; + } + else if (k1 == 3) + { + vec33 = avec3[2]; + vec3 = avec3[1]; + vec31 = avec3[5]; + vec32 = avec3[6]; + } + else if (k1 == 4) + { + vec33 = avec3[3]; + vec3 = avec3[2]; + vec31 = avec3[6]; + vec32 = avec3[7]; + } + else if (k1 == 5) + { + vec33 = avec3[0]; + vec3 = avec3[3]; + vec31 = avec3[7]; + vec32 = avec3[4]; + } + + tessellator.addVertexWithUV(vec33.xCoord, vec33.yCoord, vec33.zCoord, d0, d3); + tessellator.addVertexWithUV(vec3.xCoord, vec3.yCoord, vec3.zCoord, d2, d3); + tessellator.addVertexWithUV(vec31.xCoord, vec31.yCoord, vec31.zCoord, d2, d1); + tessellator.addVertexWithUV(vec32.xCoord, vec32.yCoord, vec32.zCoord, d0, d1); + } + + return true; + } + + public boolean renderBlockTripWireSource(Block p_147723_1_, int p_147723_2_, int p_147723_3_, int p_147723_4_) + { + Tessellator tessellator = Tessellator.instance; + int l = this.blockAccess.getBlockMetadata(p_147723_2_, p_147723_3_, p_147723_4_); + int i1 = l & 3; + boolean flag = (l & 4) == 4; + boolean flag1 = (l & 8) == 8; + boolean flag2 = !World.doesBlockHaveSolidTopSurface(this.blockAccess, p_147723_2_, p_147723_3_ - 1, p_147723_4_); + boolean flag3 = this.hasOverrideBlockTexture(); + + if (!flag3) + { + this.setOverrideBlockTexture(this.getBlockIcon(Blocks.planks)); + } + + float f = 0.25F; + float f1 = 0.125F; + float f2 = 0.125F; + float f3 = 0.3F - f; + float f4 = 0.3F + f; + + if (i1 == 2) + { + this.setRenderBounds((double)(0.5F - f1), (double)f3, (double)(1.0F - f2), (double)(0.5F + f1), (double)f4, 1.0D); + } + else if (i1 == 0) + { + this.setRenderBounds((double)(0.5F - f1), (double)f3, 0.0D, (double)(0.5F + f1), (double)f4, (double)f2); + } + else if (i1 == 1) + { + this.setRenderBounds((double)(1.0F - f2), (double)f3, (double)(0.5F - f1), 1.0D, (double)f4, (double)(0.5F + f1)); + } + else if (i1 == 3) + { + this.setRenderBounds(0.0D, (double)f3, (double)(0.5F - f1), (double)f2, (double)f4, (double)(0.5F + f1)); + } + + this.renderStandardBlock(p_147723_1_, p_147723_2_, p_147723_3_, p_147723_4_); + + if (!flag3) + { + this.clearOverrideBlockTexture(); + } + + tessellator.setBrightness(p_147723_1_.getMixedBrightnessForBlock(this.blockAccess, p_147723_2_, p_147723_3_, p_147723_4_)); + tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F); + IIcon iicon = this.getBlockIconFromSide(p_147723_1_, 0); + + if (this.hasOverrideBlockTexture()) + { + iicon = this.overrideBlockTexture; + } + + double d0 = (double)iicon.getMinU(); + double d1 = (double)iicon.getMinV(); + double d2 = (double)iicon.getMaxU(); + double d3 = (double)iicon.getMaxV(); + Vec3[] avec3 = new Vec3[8]; + float f5 = 0.046875F; + float f6 = 0.046875F; + float f7 = 0.3125F; + avec3[0] = this.blockAccess.getWorldVec3Pool().getVecFromPool((double)(-f5), 0.0D, (double)(-f6)); + avec3[1] = this.blockAccess.getWorldVec3Pool().getVecFromPool((double)f5, 0.0D, (double)(-f6)); + avec3[2] = this.blockAccess.getWorldVec3Pool().getVecFromPool((double)f5, 0.0D, (double)f6); + avec3[3] = this.blockAccess.getWorldVec3Pool().getVecFromPool((double)(-f5), 0.0D, (double)f6); + avec3[4] = this.blockAccess.getWorldVec3Pool().getVecFromPool((double)(-f5), (double)f7, (double)(-f6)); + avec3[5] = this.blockAccess.getWorldVec3Pool().getVecFromPool((double)f5, (double)f7, (double)(-f6)); + avec3[6] = this.blockAccess.getWorldVec3Pool().getVecFromPool((double)f5, (double)f7, (double)f6); + avec3[7] = this.blockAccess.getWorldVec3Pool().getVecFromPool((double)(-f5), (double)f7, (double)f6); + + for (int j1 = 0; j1 < 8; ++j1) + { + avec3[j1].zCoord += 0.0625D; + + if (flag1) + { + avec3[j1].rotateAroundX(0.5235988F); + avec3[j1].yCoord -= 0.4375D; + } + else if (flag) + { + avec3[j1].rotateAroundX(0.08726647F); + avec3[j1].yCoord -= 0.4375D; + } + else + { + avec3[j1].rotateAroundX(-((float)Math.PI * 2F / 9F)); + avec3[j1].yCoord -= 0.375D; + } + + avec3[j1].rotateAroundX(((float)Math.PI / 2F)); + + if (i1 == 2) + { + avec3[j1].rotateAroundY(0.0F); + } + + if (i1 == 0) + { + avec3[j1].rotateAroundY((float)Math.PI); + } + + if (i1 == 1) + { + avec3[j1].rotateAroundY(((float)Math.PI / 2F)); + } + + if (i1 == 3) + { + avec3[j1].rotateAroundY(-((float)Math.PI / 2F)); + } + + avec3[j1].xCoord += (double)p_147723_2_ + 0.5D; + avec3[j1].yCoord += (double)((float)p_147723_3_ + 0.3125F); + avec3[j1].zCoord += (double)p_147723_4_ + 0.5D; + } + + Vec3 vec33 = null; + Vec3 vec3 = null; + Vec3 vec31 = null; + Vec3 vec32 = null; + byte b0 = 7; + byte b1 = 9; + byte b2 = 9; + byte b3 = 16; + + for (int k1 = 0; k1 < 6; ++k1) + { + if (k1 == 0) + { + vec33 = avec3[0]; + vec3 = avec3[1]; + vec31 = avec3[2]; + vec32 = avec3[3]; + d0 = (double)iicon.getInterpolatedU((double)b0); + d1 = (double)iicon.getInterpolatedV((double)b2); + d2 = (double)iicon.getInterpolatedU((double)b1); + d3 = (double)iicon.getInterpolatedV((double)(b2 + 2)); + } + else if (k1 == 1) + { + vec33 = avec3[7]; + vec3 = avec3[6]; + vec31 = avec3[5]; + vec32 = avec3[4]; + } + else if (k1 == 2) + { + vec33 = avec3[1]; + vec3 = avec3[0]; + vec31 = avec3[4]; + vec32 = avec3[5]; + d0 = (double)iicon.getInterpolatedU((double)b0); + d1 = (double)iicon.getInterpolatedV((double)b2); + d2 = (double)iicon.getInterpolatedU((double)b1); + d3 = (double)iicon.getInterpolatedV((double)b3); + } + else if (k1 == 3) + { + vec33 = avec3[2]; + vec3 = avec3[1]; + vec31 = avec3[5]; + vec32 = avec3[6]; + } + else if (k1 == 4) + { + vec33 = avec3[3]; + vec3 = avec3[2]; + vec31 = avec3[6]; + vec32 = avec3[7]; + } + else if (k1 == 5) + { + vec33 = avec3[0]; + vec3 = avec3[3]; + vec31 = avec3[7]; + vec32 = avec3[4]; + } + + tessellator.addVertexWithUV(vec33.xCoord, vec33.yCoord, vec33.zCoord, d0, d3); + tessellator.addVertexWithUV(vec3.xCoord, vec3.yCoord, vec3.zCoord, d2, d3); + tessellator.addVertexWithUV(vec31.xCoord, vec31.yCoord, vec31.zCoord, d2, d1); + tessellator.addVertexWithUV(vec32.xCoord, vec32.yCoord, vec32.zCoord, d0, d1); + } + + float f13 = 0.09375F; + float f8 = 0.09375F; + float f9 = 0.03125F; + avec3[0] = this.blockAccess.getWorldVec3Pool().getVecFromPool((double)(-f13), 0.0D, (double)(-f8)); + avec3[1] = this.blockAccess.getWorldVec3Pool().getVecFromPool((double)f13, 0.0D, (double)(-f8)); + avec3[2] = this.blockAccess.getWorldVec3Pool().getVecFromPool((double)f13, 0.0D, (double)f8); + avec3[3] = this.blockAccess.getWorldVec3Pool().getVecFromPool((double)(-f13), 0.0D, (double)f8); + avec3[4] = this.blockAccess.getWorldVec3Pool().getVecFromPool((double)(-f13), (double)f9, (double)(-f8)); + avec3[5] = this.blockAccess.getWorldVec3Pool().getVecFromPool((double)f13, (double)f9, (double)(-f8)); + avec3[6] = this.blockAccess.getWorldVec3Pool().getVecFromPool((double)f13, (double)f9, (double)f8); + avec3[7] = this.blockAccess.getWorldVec3Pool().getVecFromPool((double)(-f13), (double)f9, (double)f8); + + for (int l1 = 0; l1 < 8; ++l1) + { + avec3[l1].zCoord += 0.21875D; + + if (flag1) + { + avec3[l1].yCoord -= 0.09375D; + avec3[l1].zCoord -= 0.1625D; + avec3[l1].rotateAroundX(0.0F); + } + else if (flag) + { + avec3[l1].yCoord += 0.015625D; + avec3[l1].zCoord -= 0.171875D; + avec3[l1].rotateAroundX(0.17453294F); + } + else + { + avec3[l1].rotateAroundX(0.87266463F); + } + + if (i1 == 2) + { + avec3[l1].rotateAroundY(0.0F); + } + + if (i1 == 0) + { + avec3[l1].rotateAroundY((float)Math.PI); + } + + if (i1 == 1) + { + avec3[l1].rotateAroundY(((float)Math.PI / 2F)); + } + + if (i1 == 3) + { + avec3[l1].rotateAroundY(-((float)Math.PI / 2F)); + } + + avec3[l1].xCoord += (double)p_147723_2_ + 0.5D; + avec3[l1].yCoord += (double)((float)p_147723_3_ + 0.3125F); + avec3[l1].zCoord += (double)p_147723_4_ + 0.5D; + } + + byte b7 = 5; + byte b4 = 11; + byte b5 = 3; + byte b6 = 9; + + for (int i2 = 0; i2 < 6; ++i2) + { + if (i2 == 0) + { + vec33 = avec3[0]; + vec3 = avec3[1]; + vec31 = avec3[2]; + vec32 = avec3[3]; + d0 = (double)iicon.getInterpolatedU((double)b7); + d1 = (double)iicon.getInterpolatedV((double)b5); + d2 = (double)iicon.getInterpolatedU((double)b4); + d3 = (double)iicon.getInterpolatedV((double)b6); + } + else if (i2 == 1) + { + vec33 = avec3[7]; + vec3 = avec3[6]; + vec31 = avec3[5]; + vec32 = avec3[4]; + } + else if (i2 == 2) + { + vec33 = avec3[1]; + vec3 = avec3[0]; + vec31 = avec3[4]; + vec32 = avec3[5]; + d0 = (double)iicon.getInterpolatedU((double)b7); + d1 = (double)iicon.getInterpolatedV((double)b5); + d2 = (double)iicon.getInterpolatedU((double)b4); + d3 = (double)iicon.getInterpolatedV((double)(b5 + 2)); + } + else if (i2 == 3) + { + vec33 = avec3[2]; + vec3 = avec3[1]; + vec31 = avec3[5]; + vec32 = avec3[6]; + } + else if (i2 == 4) + { + vec33 = avec3[3]; + vec3 = avec3[2]; + vec31 = avec3[6]; + vec32 = avec3[7]; + } + else if (i2 == 5) + { + vec33 = avec3[0]; + vec3 = avec3[3]; + vec31 = avec3[7]; + vec32 = avec3[4]; + } + + tessellator.addVertexWithUV(vec33.xCoord, vec33.yCoord, vec33.zCoord, d0, d3); + tessellator.addVertexWithUV(vec3.xCoord, vec3.yCoord, vec3.zCoord, d2, d3); + tessellator.addVertexWithUV(vec31.xCoord, vec31.yCoord, vec31.zCoord, d2, d1); + tessellator.addVertexWithUV(vec32.xCoord, vec32.yCoord, vec32.zCoord, d0, d1); + } + + if (flag) + { + double d9 = avec3[0].yCoord; + float f10 = 0.03125F; + float f11 = 0.5F - f10 / 2.0F; + float f12 = f11 + f10; + double d4 = (double)iicon.getMinU(); + double d5 = (double)iicon.getInterpolatedV(flag ? 2.0D : 0.0D); + double d6 = (double)iicon.getMaxU(); + double d7 = (double)iicon.getInterpolatedV(flag ? 4.0D : 2.0D); + double d8 = (double)(flag2 ? 3.5F : 1.5F) / 16.0D; + tessellator.setColorOpaque_F(0.75F, 0.75F, 0.75F); + + if (i1 == 2) + { + tessellator.addVertexWithUV((double)((float)p_147723_2_ + f11), (double)p_147723_3_ + d8, (double)p_147723_4_ + 0.25D, d4, d5); + tessellator.addVertexWithUV((double)((float)p_147723_2_ + f12), (double)p_147723_3_ + d8, (double)p_147723_4_ + 0.25D, d4, d7); + tessellator.addVertexWithUV((double)((float)p_147723_2_ + f12), (double)p_147723_3_ + d8, (double)p_147723_4_, d6, d7); + tessellator.addVertexWithUV((double)((float)p_147723_2_ + f11), (double)p_147723_3_ + d8, (double)p_147723_4_, d6, d5); + tessellator.addVertexWithUV((double)((float)p_147723_2_ + f11), d9, (double)p_147723_4_ + 0.5D, d4, d5); + tessellator.addVertexWithUV((double)((float)p_147723_2_ + f12), d9, (double)p_147723_4_ + 0.5D, d4, d7); + tessellator.addVertexWithUV((double)((float)p_147723_2_ + f12), (double)p_147723_3_ + d8, (double)p_147723_4_ + 0.25D, d6, d7); + tessellator.addVertexWithUV((double)((float)p_147723_2_ + f11), (double)p_147723_3_ + d8, (double)p_147723_4_ + 0.25D, d6, d5); + } + else if (i1 == 0) + { + tessellator.addVertexWithUV((double)((float)p_147723_2_ + f11), (double)p_147723_3_ + d8, (double)p_147723_4_ + 0.75D, d4, d5); + tessellator.addVertexWithUV((double)((float)p_147723_2_ + f12), (double)p_147723_3_ + d8, (double)p_147723_4_ + 0.75D, d4, d7); + tessellator.addVertexWithUV((double)((float)p_147723_2_ + f12), d9, (double)p_147723_4_ + 0.5D, d6, d7); + tessellator.addVertexWithUV((double)((float)p_147723_2_ + f11), d9, (double)p_147723_4_ + 0.5D, d6, d5); + tessellator.addVertexWithUV((double)((float)p_147723_2_ + f11), (double)p_147723_3_ + d8, (double)(p_147723_4_ + 1), d4, d5); + tessellator.addVertexWithUV((double)((float)p_147723_2_ + f12), (double)p_147723_3_ + d8, (double)(p_147723_4_ + 1), d4, d7); + tessellator.addVertexWithUV((double)((float)p_147723_2_ + f12), (double)p_147723_3_ + d8, (double)p_147723_4_ + 0.75D, d6, d7); + tessellator.addVertexWithUV((double)((float)p_147723_2_ + f11), (double)p_147723_3_ + d8, (double)p_147723_4_ + 0.75D, d6, d5); + } + else if (i1 == 1) + { + tessellator.addVertexWithUV((double)p_147723_2_, (double)p_147723_3_ + d8, (double)((float)p_147723_4_ + f12), d4, d7); + tessellator.addVertexWithUV((double)p_147723_2_ + 0.25D, (double)p_147723_3_ + d8, (double)((float)p_147723_4_ + f12), d6, d7); + tessellator.addVertexWithUV((double)p_147723_2_ + 0.25D, (double)p_147723_3_ + d8, (double)((float)p_147723_4_ + f11), d6, d5); + tessellator.addVertexWithUV((double)p_147723_2_, (double)p_147723_3_ + d8, (double)((float)p_147723_4_ + f11), d4, d5); + tessellator.addVertexWithUV((double)p_147723_2_ + 0.25D, (double)p_147723_3_ + d8, (double)((float)p_147723_4_ + f12), d4, d7); + tessellator.addVertexWithUV((double)p_147723_2_ + 0.5D, d9, (double)((float)p_147723_4_ + f12), d6, d7); + tessellator.addVertexWithUV((double)p_147723_2_ + 0.5D, d9, (double)((float)p_147723_4_ + f11), d6, d5); + tessellator.addVertexWithUV((double)p_147723_2_ + 0.25D, (double)p_147723_3_ + d8, (double)((float)p_147723_4_ + f11), d4, d5); + } + else + { + tessellator.addVertexWithUV((double)p_147723_2_ + 0.5D, d9, (double)((float)p_147723_4_ + f12), d4, d7); + tessellator.addVertexWithUV((double)p_147723_2_ + 0.75D, (double)p_147723_3_ + d8, (double)((float)p_147723_4_ + f12), d6, d7); + tessellator.addVertexWithUV((double)p_147723_2_ + 0.75D, (double)p_147723_3_ + d8, (double)((float)p_147723_4_ + f11), d6, d5); + tessellator.addVertexWithUV((double)p_147723_2_ + 0.5D, d9, (double)((float)p_147723_4_ + f11), d4, d5); + tessellator.addVertexWithUV((double)p_147723_2_ + 0.75D, (double)p_147723_3_ + d8, (double)((float)p_147723_4_ + f12), d4, d7); + tessellator.addVertexWithUV((double)(p_147723_2_ + 1), (double)p_147723_3_ + d8, (double)((float)p_147723_4_ + f12), d6, d7); + tessellator.addVertexWithUV((double)(p_147723_2_ + 1), (double)p_147723_3_ + d8, (double)((float)p_147723_4_ + f11), d6, d5); + tessellator.addVertexWithUV((double)p_147723_2_ + 0.75D, (double)p_147723_3_ + d8, (double)((float)p_147723_4_ + f11), d4, d5); + } + } + + return true; + } + + public boolean renderBlockTripWire(Block p_147756_1_, int p_147756_2_, int p_147756_3_, int p_147756_4_) + { + Tessellator tessellator = Tessellator.instance; + IIcon iicon = this.getBlockIconFromSide(p_147756_1_, 0); + int l = this.blockAccess.getBlockMetadata(p_147756_2_, p_147756_3_, p_147756_4_); + boolean flag = (l & 4) == 4; + boolean flag1 = (l & 2) == 2; + + if (this.hasOverrideBlockTexture()) + { + iicon = this.overrideBlockTexture; + } + + tessellator.setBrightness(p_147756_1_.getMixedBrightnessForBlock(this.blockAccess, p_147756_2_, p_147756_3_, p_147756_4_)); + tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F); + double d0 = (double)iicon.getMinU(); + double d1 = (double)iicon.getInterpolatedV(flag ? 2.0D : 0.0D); + double d2 = (double)iicon.getMaxU(); + double d3 = (double)iicon.getInterpolatedV(flag ? 4.0D : 2.0D); + double d4 = (double)(flag1 ? 3.5F : 1.5F) / 16.0D; + boolean flag2 = BlockTripWire.func_150139_a(this.blockAccess, p_147756_2_, p_147756_3_, p_147756_4_, l, 1); + boolean flag3 = BlockTripWire.func_150139_a(this.blockAccess, p_147756_2_, p_147756_3_, p_147756_4_, l, 3); + boolean flag4 = BlockTripWire.func_150139_a(this.blockAccess, p_147756_2_, p_147756_3_, p_147756_4_, l, 2); + boolean flag5 = BlockTripWire.func_150139_a(this.blockAccess, p_147756_2_, p_147756_3_, p_147756_4_, l, 0); + float f = 0.03125F; + float f1 = 0.5F - f / 2.0F; + float f2 = f1 + f; + + if (!flag4 && !flag3 && !flag5 && !flag2) + { + flag4 = true; + flag5 = true; + } + + if (flag4) + { + tessellator.addVertexWithUV((double)((float)p_147756_2_ + f1), (double)p_147756_3_ + d4, (double)p_147756_4_ + 0.25D, d0, d1); + tessellator.addVertexWithUV((double)((float)p_147756_2_ + f2), (double)p_147756_3_ + d4, (double)p_147756_4_ + 0.25D, d0, d3); + tessellator.addVertexWithUV((double)((float)p_147756_2_ + f2), (double)p_147756_3_ + d4, (double)p_147756_4_, d2, d3); + tessellator.addVertexWithUV((double)((float)p_147756_2_ + f1), (double)p_147756_3_ + d4, (double)p_147756_4_, d2, d1); + tessellator.addVertexWithUV((double)((float)p_147756_2_ + f1), (double)p_147756_3_ + d4, (double)p_147756_4_, d2, d1); + tessellator.addVertexWithUV((double)((float)p_147756_2_ + f2), (double)p_147756_3_ + d4, (double)p_147756_4_, d2, d3); + tessellator.addVertexWithUV((double)((float)p_147756_2_ + f2), (double)p_147756_3_ + d4, (double)p_147756_4_ + 0.25D, d0, d3); + tessellator.addVertexWithUV((double)((float)p_147756_2_ + f1), (double)p_147756_3_ + d4, (double)p_147756_4_ + 0.25D, d0, d1); + } + + if (flag4 || flag5 && !flag3 && !flag2) + { + tessellator.addVertexWithUV((double)((float)p_147756_2_ + f1), (double)p_147756_3_ + d4, (double)p_147756_4_ + 0.5D, d0, d1); + tessellator.addVertexWithUV((double)((float)p_147756_2_ + f2), (double)p_147756_3_ + d4, (double)p_147756_4_ + 0.5D, d0, d3); + tessellator.addVertexWithUV((double)((float)p_147756_2_ + f2), (double)p_147756_3_ + d4, (double)p_147756_4_ + 0.25D, d2, d3); + tessellator.addVertexWithUV((double)((float)p_147756_2_ + f1), (double)p_147756_3_ + d4, (double)p_147756_4_ + 0.25D, d2, d1); + tessellator.addVertexWithUV((double)((float)p_147756_2_ + f1), (double)p_147756_3_ + d4, (double)p_147756_4_ + 0.25D, d2, d1); + tessellator.addVertexWithUV((double)((float)p_147756_2_ + f2), (double)p_147756_3_ + d4, (double)p_147756_4_ + 0.25D, d2, d3); + tessellator.addVertexWithUV((double)((float)p_147756_2_ + f2), (double)p_147756_3_ + d4, (double)p_147756_4_ + 0.5D, d0, d3); + tessellator.addVertexWithUV((double)((float)p_147756_2_ + f1), (double)p_147756_3_ + d4, (double)p_147756_4_ + 0.5D, d0, d1); + } + + if (flag5 || flag4 && !flag3 && !flag2) + { + tessellator.addVertexWithUV((double)((float)p_147756_2_ + f1), (double)p_147756_3_ + d4, (double)p_147756_4_ + 0.75D, d0, d1); + tessellator.addVertexWithUV((double)((float)p_147756_2_ + f2), (double)p_147756_3_ + d4, (double)p_147756_4_ + 0.75D, d0, d3); + tessellator.addVertexWithUV((double)((float)p_147756_2_ + f2), (double)p_147756_3_ + d4, (double)p_147756_4_ + 0.5D, d2, d3); + tessellator.addVertexWithUV((double)((float)p_147756_2_ + f1), (double)p_147756_3_ + d4, (double)p_147756_4_ + 0.5D, d2, d1); + tessellator.addVertexWithUV((double)((float)p_147756_2_ + f1), (double)p_147756_3_ + d4, (double)p_147756_4_ + 0.5D, d2, d1); + tessellator.addVertexWithUV((double)((float)p_147756_2_ + f2), (double)p_147756_3_ + d4, (double)p_147756_4_ + 0.5D, d2, d3); + tessellator.addVertexWithUV((double)((float)p_147756_2_ + f2), (double)p_147756_3_ + d4, (double)p_147756_4_ + 0.75D, d0, d3); + tessellator.addVertexWithUV((double)((float)p_147756_2_ + f1), (double)p_147756_3_ + d4, (double)p_147756_4_ + 0.75D, d0, d1); + } + + if (flag5) + { + tessellator.addVertexWithUV((double)((float)p_147756_2_ + f1), (double)p_147756_3_ + d4, (double)(p_147756_4_ + 1), d0, d1); + tessellator.addVertexWithUV((double)((float)p_147756_2_ + f2), (double)p_147756_3_ + d4, (double)(p_147756_4_ + 1), d0, d3); + tessellator.addVertexWithUV((double)((float)p_147756_2_ + f2), (double)p_147756_3_ + d4, (double)p_147756_4_ + 0.75D, d2, d3); + tessellator.addVertexWithUV((double)((float)p_147756_2_ + f1), (double)p_147756_3_ + d4, (double)p_147756_4_ + 0.75D, d2, d1); + tessellator.addVertexWithUV((double)((float)p_147756_2_ + f1), (double)p_147756_3_ + d4, (double)p_147756_4_ + 0.75D, d2, d1); + tessellator.addVertexWithUV((double)((float)p_147756_2_ + f2), (double)p_147756_3_ + d4, (double)p_147756_4_ + 0.75D, d2, d3); + tessellator.addVertexWithUV((double)((float)p_147756_2_ + f2), (double)p_147756_3_ + d4, (double)(p_147756_4_ + 1), d0, d3); + tessellator.addVertexWithUV((double)((float)p_147756_2_ + f1), (double)p_147756_3_ + d4, (double)(p_147756_4_ + 1), d0, d1); + } + + if (flag2) + { + tessellator.addVertexWithUV((double)p_147756_2_, (double)p_147756_3_ + d4, (double)((float)p_147756_4_ + f2), d0, d3); + tessellator.addVertexWithUV((double)p_147756_2_ + 0.25D, (double)p_147756_3_ + d4, (double)((float)p_147756_4_ + f2), d2, d3); + tessellator.addVertexWithUV((double)p_147756_2_ + 0.25D, (double)p_147756_3_ + d4, (double)((float)p_147756_4_ + f1), d2, d1); + tessellator.addVertexWithUV((double)p_147756_2_, (double)p_147756_3_ + d4, (double)((float)p_147756_4_ + f1), d0, d1); + tessellator.addVertexWithUV((double)p_147756_2_, (double)p_147756_3_ + d4, (double)((float)p_147756_4_ + f1), d0, d1); + tessellator.addVertexWithUV((double)p_147756_2_ + 0.25D, (double)p_147756_3_ + d4, (double)((float)p_147756_4_ + f1), d2, d1); + tessellator.addVertexWithUV((double)p_147756_2_ + 0.25D, (double)p_147756_3_ + d4, (double)((float)p_147756_4_ + f2), d2, d3); + tessellator.addVertexWithUV((double)p_147756_2_, (double)p_147756_3_ + d4, (double)((float)p_147756_4_ + f2), d0, d3); + } + + if (flag2 || flag3 && !flag4 && !flag5) + { + tessellator.addVertexWithUV((double)p_147756_2_ + 0.25D, (double)p_147756_3_ + d4, (double)((float)p_147756_4_ + f2), d0, d3); + tessellator.addVertexWithUV((double)p_147756_2_ + 0.5D, (double)p_147756_3_ + d4, (double)((float)p_147756_4_ + f2), d2, d3); + tessellator.addVertexWithUV((double)p_147756_2_ + 0.5D, (double)p_147756_3_ + d4, (double)((float)p_147756_4_ + f1), d2, d1); + tessellator.addVertexWithUV((double)p_147756_2_ + 0.25D, (double)p_147756_3_ + d4, (double)((float)p_147756_4_ + f1), d0, d1); + tessellator.addVertexWithUV((double)p_147756_2_ + 0.25D, (double)p_147756_3_ + d4, (double)((float)p_147756_4_ + f1), d0, d1); + tessellator.addVertexWithUV((double)p_147756_2_ + 0.5D, (double)p_147756_3_ + d4, (double)((float)p_147756_4_ + f1), d2, d1); + tessellator.addVertexWithUV((double)p_147756_2_ + 0.5D, (double)p_147756_3_ + d4, (double)((float)p_147756_4_ + f2), d2, d3); + tessellator.addVertexWithUV((double)p_147756_2_ + 0.25D, (double)p_147756_3_ + d4, (double)((float)p_147756_4_ + f2), d0, d3); + } + + if (flag3 || flag2 && !flag4 && !flag5) + { + tessellator.addVertexWithUV((double)p_147756_2_ + 0.5D, (double)p_147756_3_ + d4, (double)((float)p_147756_4_ + f2), d0, d3); + tessellator.addVertexWithUV((double)p_147756_2_ + 0.75D, (double)p_147756_3_ + d4, (double)((float)p_147756_4_ + f2), d2, d3); + tessellator.addVertexWithUV((double)p_147756_2_ + 0.75D, (double)p_147756_3_ + d4, (double)((float)p_147756_4_ + f1), d2, d1); + tessellator.addVertexWithUV((double)p_147756_2_ + 0.5D, (double)p_147756_3_ + d4, (double)((float)p_147756_4_ + f1), d0, d1); + tessellator.addVertexWithUV((double)p_147756_2_ + 0.5D, (double)p_147756_3_ + d4, (double)((float)p_147756_4_ + f1), d0, d1); + tessellator.addVertexWithUV((double)p_147756_2_ + 0.75D, (double)p_147756_3_ + d4, (double)((float)p_147756_4_ + f1), d2, d1); + tessellator.addVertexWithUV((double)p_147756_2_ + 0.75D, (double)p_147756_3_ + d4, (double)((float)p_147756_4_ + f2), d2, d3); + tessellator.addVertexWithUV((double)p_147756_2_ + 0.5D, (double)p_147756_3_ + d4, (double)((float)p_147756_4_ + f2), d0, d3); + } + + if (flag3) + { + tessellator.addVertexWithUV((double)p_147756_2_ + 0.75D, (double)p_147756_3_ + d4, (double)((float)p_147756_4_ + f2), d0, d3); + tessellator.addVertexWithUV((double)(p_147756_2_ + 1), (double)p_147756_3_ + d4, (double)((float)p_147756_4_ + f2), d2, d3); + tessellator.addVertexWithUV((double)(p_147756_2_ + 1), (double)p_147756_3_ + d4, (double)((float)p_147756_4_ + f1), d2, d1); + tessellator.addVertexWithUV((double)p_147756_2_ + 0.75D, (double)p_147756_3_ + d4, (double)((float)p_147756_4_ + f1), d0, d1); + tessellator.addVertexWithUV((double)p_147756_2_ + 0.75D, (double)p_147756_3_ + d4, (double)((float)p_147756_4_ + f1), d0, d1); + tessellator.addVertexWithUV((double)(p_147756_2_ + 1), (double)p_147756_3_ + d4, (double)((float)p_147756_4_ + f1), d2, d1); + tessellator.addVertexWithUV((double)(p_147756_2_ + 1), (double)p_147756_3_ + d4, (double)((float)p_147756_4_ + f2), d2, d3); + tessellator.addVertexWithUV((double)p_147756_2_ + 0.75D, (double)p_147756_3_ + d4, (double)((float)p_147756_4_ + f2), d0, d3); + } + + return true; + } + + public boolean renderBlockFire(BlockFire p_147801_1_, int p_147801_2_, int p_147801_3_, int p_147801_4_) + { + Tessellator tessellator = Tessellator.instance; + IIcon iicon = p_147801_1_.getFireIcon(0); + IIcon iicon1 = p_147801_1_.getFireIcon(1); + IIcon iicon2 = iicon; + + if (this.hasOverrideBlockTexture()) + { + iicon2 = this.overrideBlockTexture; + } + + tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F); + tessellator.setBrightness(p_147801_1_.getMixedBrightnessForBlock(this.blockAccess, p_147801_2_, p_147801_3_, p_147801_4_)); + double d0 = (double)iicon2.getMinU(); + double d1 = (double)iicon2.getMinV(); + double d2 = (double)iicon2.getMaxU(); + double d3 = (double)iicon2.getMaxV(); + float f = 1.4F; + double d5; + double d6; + double d7; + double d8; + double d9; + double d10; + double d11; + + if (!World.doesBlockHaveSolidTopSurface(this.blockAccess, p_147801_2_, p_147801_3_ - 1, p_147801_4_) && !Blocks.fire.canCatchFire(this.blockAccess, p_147801_2_, p_147801_3_ - 1, p_147801_4_, UP)) + { + float f2 = 0.2F; + float f1 = 0.0625F; + + if ((p_147801_2_ + p_147801_3_ + p_147801_4_ & 1) == 1) + { + d0 = (double)iicon1.getMinU(); + d1 = (double)iicon1.getMinV(); + d2 = (double)iicon1.getMaxU(); + d3 = (double)iicon1.getMaxV(); + } + + if ((p_147801_2_ / 2 + p_147801_3_ / 2 + p_147801_4_ / 2 & 1) == 1) + { + d5 = d2; + d2 = d0; + d0 = d5; + } + + if (Blocks.fire.canCatchFire(this.blockAccess, p_147801_2_ - 1, p_147801_3_, p_147801_4_, EAST)) + { + tessellator.addVertexWithUV((double)((float)p_147801_2_ + f2), (double)((float)p_147801_3_ + f + f1), (double)(p_147801_4_ + 1), d2, d1); + tessellator.addVertexWithUV((double)(p_147801_2_ + 0), (double)((float)(p_147801_3_ + 0) + f1), (double)(p_147801_4_ + 1), d2, d3); + tessellator.addVertexWithUV((double)(p_147801_2_ + 0), (double)((float)(p_147801_3_ + 0) + f1), (double)(p_147801_4_ + 0), d0, d3); + tessellator.addVertexWithUV((double)((float)p_147801_2_ + f2), (double)((float)p_147801_3_ + f + f1), (double)(p_147801_4_ + 0), d0, d1); + tessellator.addVertexWithUV((double)((float)p_147801_2_ + f2), (double)((float)p_147801_3_ + f + f1), (double)(p_147801_4_ + 0), d0, d1); + tessellator.addVertexWithUV((double)(p_147801_2_ + 0), (double)((float)(p_147801_3_ + 0) + f1), (double)(p_147801_4_ + 0), d0, d3); + tessellator.addVertexWithUV((double)(p_147801_2_ + 0), (double)((float)(p_147801_3_ + 0) + f1), (double)(p_147801_4_ + 1), d2, d3); + tessellator.addVertexWithUV((double)((float)p_147801_2_ + f2), (double)((float)p_147801_3_ + f + f1), (double)(p_147801_4_ + 1), d2, d1); + } + + if (Blocks.fire.canCatchFire(this.blockAccess, p_147801_2_ + 1, p_147801_3_, p_147801_4_, WEST)) + { + tessellator.addVertexWithUV((double)((float)(p_147801_2_ + 1) - f2), (double)((float)p_147801_3_ + f + f1), (double)(p_147801_4_ + 0), d0, d1); + tessellator.addVertexWithUV((double)(p_147801_2_ + 1 - 0), (double)((float)(p_147801_3_ + 0) + f1), (double)(p_147801_4_ + 0), d0, d3); + tessellator.addVertexWithUV((double)(p_147801_2_ + 1 - 0), (double)((float)(p_147801_3_ + 0) + f1), (double)(p_147801_4_ + 1), d2, d3); + tessellator.addVertexWithUV((double)((float)(p_147801_2_ + 1) - f2), (double)((float)p_147801_3_ + f + f1), (double)(p_147801_4_ + 1), d2, d1); + tessellator.addVertexWithUV((double)((float)(p_147801_2_ + 1) - f2), (double)((float)p_147801_3_ + f + f1), (double)(p_147801_4_ + 1), d2, d1); + tessellator.addVertexWithUV((double)(p_147801_2_ + 1 - 0), (double)((float)(p_147801_3_ + 0) + f1), (double)(p_147801_4_ + 1), d2, d3); + tessellator.addVertexWithUV((double)(p_147801_2_ + 1 - 0), (double)((float)(p_147801_3_ + 0) + f1), (double)(p_147801_4_ + 0), d0, d3); + tessellator.addVertexWithUV((double)((float)(p_147801_2_ + 1) - f2), (double)((float)p_147801_3_ + f + f1), (double)(p_147801_4_ + 0), d0, d1); + } + + if (Blocks.fire.canCatchFire(this.blockAccess, p_147801_2_, p_147801_3_, p_147801_4_ - 1, SOUTH)) + { + tessellator.addVertexWithUV((double)(p_147801_2_ + 0), (double)((float)p_147801_3_ + f + f1), (double)((float)p_147801_4_ + f2), d2, d1); + tessellator.addVertexWithUV((double)(p_147801_2_ + 0), (double)((float)(p_147801_3_ + 0) + f1), (double)(p_147801_4_ + 0), d2, d3); + tessellator.addVertexWithUV((double)(p_147801_2_ + 1), (double)((float)(p_147801_3_ + 0) + f1), (double)(p_147801_4_ + 0), d0, d3); + tessellator.addVertexWithUV((double)(p_147801_2_ + 1), (double)((float)p_147801_3_ + f + f1), (double)((float)p_147801_4_ + f2), d0, d1); + tessellator.addVertexWithUV((double)(p_147801_2_ + 1), (double)((float)p_147801_3_ + f + f1), (double)((float)p_147801_4_ + f2), d0, d1); + tessellator.addVertexWithUV((double)(p_147801_2_ + 1), (double)((float)(p_147801_3_ + 0) + f1), (double)(p_147801_4_ + 0), d0, d3); + tessellator.addVertexWithUV((double)(p_147801_2_ + 0), (double)((float)(p_147801_3_ + 0) + f1), (double)(p_147801_4_ + 0), d2, d3); + tessellator.addVertexWithUV((double)(p_147801_2_ + 0), (double)((float)p_147801_3_ + f + f1), (double)((float)p_147801_4_ + f2), d2, d1); + } + + if (Blocks.fire.canCatchFire(this.blockAccess, p_147801_2_, p_147801_3_, p_147801_4_ + 1, NORTH)) + { + tessellator.addVertexWithUV((double)(p_147801_2_ + 1), (double)((float)p_147801_3_ + f + f1), (double)((float)(p_147801_4_ + 1) - f2), d0, d1); + tessellator.addVertexWithUV((double)(p_147801_2_ + 1), (double)((float)(p_147801_3_ + 0) + f1), (double)(p_147801_4_ + 1 - 0), d0, d3); + tessellator.addVertexWithUV((double)(p_147801_2_ + 0), (double)((float)(p_147801_3_ + 0) + f1), (double)(p_147801_4_ + 1 - 0), d2, d3); + tessellator.addVertexWithUV((double)(p_147801_2_ + 0), (double)((float)p_147801_3_ + f + f1), (double)((float)(p_147801_4_ + 1) - f2), d2, d1); + tessellator.addVertexWithUV((double)(p_147801_2_ + 0), (double)((float)p_147801_3_ + f + f1), (double)((float)(p_147801_4_ + 1) - f2), d2, d1); + tessellator.addVertexWithUV((double)(p_147801_2_ + 0), (double)((float)(p_147801_3_ + 0) + f1), (double)(p_147801_4_ + 1 - 0), d2, d3); + tessellator.addVertexWithUV((double)(p_147801_2_ + 1), (double)((float)(p_147801_3_ + 0) + f1), (double)(p_147801_4_ + 1 - 0), d0, d3); + tessellator.addVertexWithUV((double)(p_147801_2_ + 1), (double)((float)p_147801_3_ + f + f1), (double)((float)(p_147801_4_ + 1) - f2), d0, d1); + } + + if (Blocks.fire.canCatchFire(this.blockAccess, p_147801_2_, p_147801_3_ + 1, p_147801_4_, DOWN)) + { + d5 = (double)p_147801_2_ + 0.5D + 0.5D; + d6 = (double)p_147801_2_ + 0.5D - 0.5D; + d7 = (double)p_147801_4_ + 0.5D + 0.5D; + d8 = (double)p_147801_4_ + 0.5D - 0.5D; + d9 = (double)p_147801_2_ + 0.5D - 0.5D; + d10 = (double)p_147801_2_ + 0.5D + 0.5D; + d11 = (double)p_147801_4_ + 0.5D - 0.5D; + double d12 = (double)p_147801_4_ + 0.5D + 0.5D; + d0 = (double)iicon.getMinU(); + d1 = (double)iicon.getMinV(); + d2 = (double)iicon.getMaxU(); + d3 = (double)iicon.getMaxV(); + ++p_147801_3_; + f = -0.2F; + + if ((p_147801_2_ + p_147801_3_ + p_147801_4_ & 1) == 0) + { + tessellator.addVertexWithUV(d9, (double)((float)p_147801_3_ + f), (double)(p_147801_4_ + 0), d2, d1); + tessellator.addVertexWithUV(d5, (double)(p_147801_3_ + 0), (double)(p_147801_4_ + 0), d2, d3); + tessellator.addVertexWithUV(d5, (double)(p_147801_3_ + 0), (double)(p_147801_4_ + 1), d0, d3); + tessellator.addVertexWithUV(d9, (double)((float)p_147801_3_ + f), (double)(p_147801_4_ + 1), d0, d1); + d0 = (double)iicon1.getMinU(); + d1 = (double)iicon1.getMinV(); + d2 = (double)iicon1.getMaxU(); + d3 = (double)iicon1.getMaxV(); + tessellator.addVertexWithUV(d10, (double)((float)p_147801_3_ + f), (double)(p_147801_4_ + 1), d2, d1); + tessellator.addVertexWithUV(d6, (double)(p_147801_3_ + 0), (double)(p_147801_4_ + 1), d2, d3); + tessellator.addVertexWithUV(d6, (double)(p_147801_3_ + 0), (double)(p_147801_4_ + 0), d0, d3); + tessellator.addVertexWithUV(d10, (double)((float)p_147801_3_ + f), (double)(p_147801_4_ + 0), d0, d1); + } + else + { + tessellator.addVertexWithUV((double)(p_147801_2_ + 0), (double)((float)p_147801_3_ + f), d12, d2, d1); + tessellator.addVertexWithUV((double)(p_147801_2_ + 0), (double)(p_147801_3_ + 0), d8, d2, d3); + tessellator.addVertexWithUV((double)(p_147801_2_ + 1), (double)(p_147801_3_ + 0), d8, d0, d3); + tessellator.addVertexWithUV((double)(p_147801_2_ + 1), (double)((float)p_147801_3_ + f), d12, d0, d1); + d0 = (double)iicon1.getMinU(); + d1 = (double)iicon1.getMinV(); + d2 = (double)iicon1.getMaxU(); + d3 = (double)iicon1.getMaxV(); + tessellator.addVertexWithUV((double)(p_147801_2_ + 1), (double)((float)p_147801_3_ + f), d11, d2, d1); + tessellator.addVertexWithUV((double)(p_147801_2_ + 1), (double)(p_147801_3_ + 0), d7, d2, d3); + tessellator.addVertexWithUV((double)(p_147801_2_ + 0), (double)(p_147801_3_ + 0), d7, d0, d3); + tessellator.addVertexWithUV((double)(p_147801_2_ + 0), (double)((float)p_147801_3_ + f), d11, d0, d1); + } + } + } + else + { + double d4 = (double)p_147801_2_ + 0.5D + 0.2D; + d5 = (double)p_147801_2_ + 0.5D - 0.2D; + d6 = (double)p_147801_4_ + 0.5D + 0.2D; + d7 = (double)p_147801_4_ + 0.5D - 0.2D; + d8 = (double)p_147801_2_ + 0.5D - 0.3D; + d9 = (double)p_147801_2_ + 0.5D + 0.3D; + d10 = (double)p_147801_4_ + 0.5D - 0.3D; + d11 = (double)p_147801_4_ + 0.5D + 0.3D; + tessellator.addVertexWithUV(d8, (double)((float)p_147801_3_ + f), (double)(p_147801_4_ + 1), d2, d1); + tessellator.addVertexWithUV(d4, (double)(p_147801_3_ + 0), (double)(p_147801_4_ + 1), d2, d3); + tessellator.addVertexWithUV(d4, (double)(p_147801_3_ + 0), (double)(p_147801_4_ + 0), d0, d3); + tessellator.addVertexWithUV(d8, (double)((float)p_147801_3_ + f), (double)(p_147801_4_ + 0), d0, d1); + tessellator.addVertexWithUV(d9, (double)((float)p_147801_3_ + f), (double)(p_147801_4_ + 0), d2, d1); + tessellator.addVertexWithUV(d5, (double)(p_147801_3_ + 0), (double)(p_147801_4_ + 0), d2, d3); + tessellator.addVertexWithUV(d5, (double)(p_147801_3_ + 0), (double)(p_147801_4_ + 1), d0, d3); + tessellator.addVertexWithUV(d9, (double)((float)p_147801_3_ + f), (double)(p_147801_4_ + 1), d0, d1); + d0 = (double)iicon1.getMinU(); + d1 = (double)iicon1.getMinV(); + d2 = (double)iicon1.getMaxU(); + d3 = (double)iicon1.getMaxV(); + tessellator.addVertexWithUV((double)(p_147801_2_ + 1), (double)((float)p_147801_3_ + f), d11, d2, d1); + tessellator.addVertexWithUV((double)(p_147801_2_ + 1), (double)(p_147801_3_ + 0), d7, d2, d3); + tessellator.addVertexWithUV((double)(p_147801_2_ + 0), (double)(p_147801_3_ + 0), d7, d0, d3); + tessellator.addVertexWithUV((double)(p_147801_2_ + 0), (double)((float)p_147801_3_ + f), d11, d0, d1); + tessellator.addVertexWithUV((double)(p_147801_2_ + 0), (double)((float)p_147801_3_ + f), d10, d2, d1); + tessellator.addVertexWithUV((double)(p_147801_2_ + 0), (double)(p_147801_3_ + 0), d6, d2, d3); + tessellator.addVertexWithUV((double)(p_147801_2_ + 1), (double)(p_147801_3_ + 0), d6, d0, d3); + tessellator.addVertexWithUV((double)(p_147801_2_ + 1), (double)((float)p_147801_3_ + f), d10, d0, d1); + d4 = (double)p_147801_2_ + 0.5D - 0.5D; + d5 = (double)p_147801_2_ + 0.5D + 0.5D; + d6 = (double)p_147801_4_ + 0.5D - 0.5D; + d7 = (double)p_147801_4_ + 0.5D + 0.5D; + d8 = (double)p_147801_2_ + 0.5D - 0.4D; + d9 = (double)p_147801_2_ + 0.5D + 0.4D; + d10 = (double)p_147801_4_ + 0.5D - 0.4D; + d11 = (double)p_147801_4_ + 0.5D + 0.4D; + tessellator.addVertexWithUV(d8, (double)((float)p_147801_3_ + f), (double)(p_147801_4_ + 0), d0, d1); + tessellator.addVertexWithUV(d4, (double)(p_147801_3_ + 0), (double)(p_147801_4_ + 0), d0, d3); + tessellator.addVertexWithUV(d4, (double)(p_147801_3_ + 0), (double)(p_147801_4_ + 1), d2, d3); + tessellator.addVertexWithUV(d8, (double)((float)p_147801_3_ + f), (double)(p_147801_4_ + 1), d2, d1); + tessellator.addVertexWithUV(d9, (double)((float)p_147801_3_ + f), (double)(p_147801_4_ + 1), d0, d1); + tessellator.addVertexWithUV(d5, (double)(p_147801_3_ + 0), (double)(p_147801_4_ + 1), d0, d3); + tessellator.addVertexWithUV(d5, (double)(p_147801_3_ + 0), (double)(p_147801_4_ + 0), d2, d3); + tessellator.addVertexWithUV(d9, (double)((float)p_147801_3_ + f), (double)(p_147801_4_ + 0), d2, d1); + d0 = (double)iicon.getMinU(); + d1 = (double)iicon.getMinV(); + d2 = (double)iicon.getMaxU(); + d3 = (double)iicon.getMaxV(); + tessellator.addVertexWithUV((double)(p_147801_2_ + 0), (double)((float)p_147801_3_ + f), d11, d0, d1); + tessellator.addVertexWithUV((double)(p_147801_2_ + 0), (double)(p_147801_3_ + 0), d7, d0, d3); + tessellator.addVertexWithUV((double)(p_147801_2_ + 1), (double)(p_147801_3_ + 0), d7, d2, d3); + tessellator.addVertexWithUV((double)(p_147801_2_ + 1), (double)((float)p_147801_3_ + f), d11, d2, d1); + tessellator.addVertexWithUV((double)(p_147801_2_ + 1), (double)((float)p_147801_3_ + f), d10, d0, d1); + tessellator.addVertexWithUV((double)(p_147801_2_ + 1), (double)(p_147801_3_ + 0), d6, d0, d3); + tessellator.addVertexWithUV((double)(p_147801_2_ + 0), (double)(p_147801_3_ + 0), d6, d2, d3); + tessellator.addVertexWithUV((double)(p_147801_2_ + 0), (double)((float)p_147801_3_ + f), d10, d2, d1); + } + + return true; + } + + public boolean renderBlockRedstoneWire(Block p_147788_1_, int p_147788_2_, int p_147788_3_, int p_147788_4_) + { + Tessellator tessellator = Tessellator.instance; + int l = this.blockAccess.getBlockMetadata(p_147788_2_, p_147788_3_, p_147788_4_); + IIcon iicon = BlockRedstoneWire.getRedstoneWireIcon("cross"); + IIcon iicon1 = BlockRedstoneWire.getRedstoneWireIcon("line"); + IIcon iicon2 = BlockRedstoneWire.getRedstoneWireIcon("cross_overlay"); + IIcon iicon3 = BlockRedstoneWire.getRedstoneWireIcon("line_overlay"); + tessellator.setBrightness(p_147788_1_.getMixedBrightnessForBlock(this.blockAccess, p_147788_2_, p_147788_3_, p_147788_4_)); + float f = (float)l / 15.0F; + float f1 = f * 0.6F + 0.4F; + + if (l == 0) + { + f1 = 0.3F; + } + + float f2 = f * f * 0.7F - 0.5F; + float f3 = f * f * 0.6F - 0.7F; + + if (f2 < 0.0F) + { + f2 = 0.0F; + } + + if (f3 < 0.0F) + { + f3 = 0.0F; + } + + tessellator.setColorOpaque_F(f1, f2, f3); + double d0 = 0.015625D; + double d1 = 0.015625D; + boolean flag = BlockRedstoneWire.isPowerProviderOrWire(this.blockAccess, p_147788_2_ - 1, p_147788_3_, p_147788_4_, 1) || !this.blockAccess.getBlock(p_147788_2_ - 1, p_147788_3_, p_147788_4_).isBlockNormalCube() && BlockRedstoneWire.isPowerProviderOrWire(this.blockAccess, p_147788_2_ - 1, p_147788_3_ - 1, p_147788_4_, -1); + boolean flag1 = BlockRedstoneWire.isPowerProviderOrWire(this.blockAccess, p_147788_2_ + 1, p_147788_3_, p_147788_4_, 3) || !this.blockAccess.getBlock(p_147788_2_ + 1, p_147788_3_, p_147788_4_).isBlockNormalCube() && BlockRedstoneWire.isPowerProviderOrWire(this.blockAccess, p_147788_2_ + 1, p_147788_3_ - 1, p_147788_4_, -1); + boolean flag2 = BlockRedstoneWire.isPowerProviderOrWire(this.blockAccess, p_147788_2_, p_147788_3_, p_147788_4_ - 1, 2) || !this.blockAccess.getBlock(p_147788_2_, p_147788_3_, p_147788_4_ - 1).isBlockNormalCube() && BlockRedstoneWire.isPowerProviderOrWire(this.blockAccess, p_147788_2_, p_147788_3_ - 1, p_147788_4_ - 1, -1); + boolean flag3 = BlockRedstoneWire.isPowerProviderOrWire(this.blockAccess, p_147788_2_, p_147788_3_, p_147788_4_ + 1, 0) || !this.blockAccess.getBlock(p_147788_2_, p_147788_3_, p_147788_4_ + 1).isBlockNormalCube() && BlockRedstoneWire.isPowerProviderOrWire(this.blockAccess, p_147788_2_, p_147788_3_ - 1, p_147788_4_ + 1, -1); + + if (!this.blockAccess.getBlock(p_147788_2_, p_147788_3_ + 1, p_147788_4_).isBlockNormalCube()) + { + if (this.blockAccess.getBlock(p_147788_2_ - 1, p_147788_3_, p_147788_4_).isBlockNormalCube() && BlockRedstoneWire.isPowerProviderOrWire(this.blockAccess, p_147788_2_ - 1, p_147788_3_ + 1, p_147788_4_, -1)) + { + flag = true; + } + + if (this.blockAccess.getBlock(p_147788_2_ + 1, p_147788_3_, p_147788_4_).isBlockNormalCube() && BlockRedstoneWire.isPowerProviderOrWire(this.blockAccess, p_147788_2_ + 1, p_147788_3_ + 1, p_147788_4_, -1)) + { + flag1 = true; + } + + if (this.blockAccess.getBlock(p_147788_2_, p_147788_3_, p_147788_4_ - 1).isBlockNormalCube() && BlockRedstoneWire.isPowerProviderOrWire(this.blockAccess, p_147788_2_, p_147788_3_ + 1, p_147788_4_ - 1, -1)) + { + flag2 = true; + } + + if (this.blockAccess.getBlock(p_147788_2_, p_147788_3_, p_147788_4_ + 1).isBlockNormalCube() && BlockRedstoneWire.isPowerProviderOrWire(this.blockAccess, p_147788_2_, p_147788_3_ + 1, p_147788_4_ + 1, -1)) + { + flag3 = true; + } + } + + float f4 = (float)(p_147788_2_ + 0); + float f5 = (float)(p_147788_2_ + 1); + float f6 = (float)(p_147788_4_ + 0); + float f7 = (float)(p_147788_4_ + 1); + int i1 = 0; + + if ((flag || flag1) && !flag2 && !flag3) + { + i1 = 1; + } + + if ((flag2 || flag3) && !flag1 && !flag) + { + i1 = 2; + } + + if (i1 == 0) + { + int j1 = 0; + int k1 = 0; + int l1 = 16; + int i2 = 16; + boolean flag4 = true; + + if (!flag) + { + f4 += 0.3125F; + } + + if (!flag) + { + j1 += 5; + } + + if (!flag1) + { + f5 -= 0.3125F; + } + + if (!flag1) + { + l1 -= 5; + } + + if (!flag2) + { + f6 += 0.3125F; + } + + if (!flag2) + { + k1 += 5; + } + + if (!flag3) + { + f7 -= 0.3125F; + } + + if (!flag3) + { + i2 -= 5; + } + + tessellator.addVertexWithUV((double)f5, (double)p_147788_3_ + 0.015625D, (double)f7, (double)iicon.getInterpolatedU((double)l1), (double)iicon.getInterpolatedV((double)i2)); + tessellator.addVertexWithUV((double)f5, (double)p_147788_3_ + 0.015625D, (double)f6, (double)iicon.getInterpolatedU((double)l1), (double)iicon.getInterpolatedV((double)k1)); + tessellator.addVertexWithUV((double)f4, (double)p_147788_3_ + 0.015625D, (double)f6, (double)iicon.getInterpolatedU((double)j1), (double)iicon.getInterpolatedV((double)k1)); + tessellator.addVertexWithUV((double)f4, (double)p_147788_3_ + 0.015625D, (double)f7, (double)iicon.getInterpolatedU((double)j1), (double)iicon.getInterpolatedV((double)i2)); + tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F); + tessellator.addVertexWithUV((double)f5, (double)p_147788_3_ + 0.015625D, (double)f7, (double)iicon2.getInterpolatedU((double)l1), (double)iicon2.getInterpolatedV((double)i2)); + tessellator.addVertexWithUV((double)f5, (double)p_147788_3_ + 0.015625D, (double)f6, (double)iicon2.getInterpolatedU((double)l1), (double)iicon2.getInterpolatedV((double)k1)); + tessellator.addVertexWithUV((double)f4, (double)p_147788_3_ + 0.015625D, (double)f6, (double)iicon2.getInterpolatedU((double)j1), (double)iicon2.getInterpolatedV((double)k1)); + tessellator.addVertexWithUV((double)f4, (double)p_147788_3_ + 0.015625D, (double)f7, (double)iicon2.getInterpolatedU((double)j1), (double)iicon2.getInterpolatedV((double)i2)); + } + else if (i1 == 1) + { + tessellator.addVertexWithUV((double)f5, (double)p_147788_3_ + 0.015625D, (double)f7, (double)iicon1.getMaxU(), (double)iicon1.getMaxV()); + tessellator.addVertexWithUV((double)f5, (double)p_147788_3_ + 0.015625D, (double)f6, (double)iicon1.getMaxU(), (double)iicon1.getMinV()); + tessellator.addVertexWithUV((double)f4, (double)p_147788_3_ + 0.015625D, (double)f6, (double)iicon1.getMinU(), (double)iicon1.getMinV()); + tessellator.addVertexWithUV((double)f4, (double)p_147788_3_ + 0.015625D, (double)f7, (double)iicon1.getMinU(), (double)iicon1.getMaxV()); + tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F); + tessellator.addVertexWithUV((double)f5, (double)p_147788_3_ + 0.015625D, (double)f7, (double)iicon3.getMaxU(), (double)iicon3.getMaxV()); + tessellator.addVertexWithUV((double)f5, (double)p_147788_3_ + 0.015625D, (double)f6, (double)iicon3.getMaxU(), (double)iicon3.getMinV()); + tessellator.addVertexWithUV((double)f4, (double)p_147788_3_ + 0.015625D, (double)f6, (double)iicon3.getMinU(), (double)iicon3.getMinV()); + tessellator.addVertexWithUV((double)f4, (double)p_147788_3_ + 0.015625D, (double)f7, (double)iicon3.getMinU(), (double)iicon3.getMaxV()); + } + else + { + tessellator.addVertexWithUV((double)f5, (double)p_147788_3_ + 0.015625D, (double)f7, (double)iicon1.getMaxU(), (double)iicon1.getMaxV()); + tessellator.addVertexWithUV((double)f5, (double)p_147788_3_ + 0.015625D, (double)f6, (double)iicon1.getMinU(), (double)iicon1.getMaxV()); + tessellator.addVertexWithUV((double)f4, (double)p_147788_3_ + 0.015625D, (double)f6, (double)iicon1.getMinU(), (double)iicon1.getMinV()); + tessellator.addVertexWithUV((double)f4, (double)p_147788_3_ + 0.015625D, (double)f7, (double)iicon1.getMaxU(), (double)iicon1.getMinV()); + tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F); + tessellator.addVertexWithUV((double)f5, (double)p_147788_3_ + 0.015625D, (double)f7, (double)iicon3.getMaxU(), (double)iicon3.getMaxV()); + tessellator.addVertexWithUV((double)f5, (double)p_147788_3_ + 0.015625D, (double)f6, (double)iicon3.getMinU(), (double)iicon3.getMaxV()); + tessellator.addVertexWithUV((double)f4, (double)p_147788_3_ + 0.015625D, (double)f6, (double)iicon3.getMinU(), (double)iicon3.getMinV()); + tessellator.addVertexWithUV((double)f4, (double)p_147788_3_ + 0.015625D, (double)f7, (double)iicon3.getMaxU(), (double)iicon3.getMinV()); + } + + if (!this.blockAccess.getBlock(p_147788_2_, p_147788_3_ + 1, p_147788_4_).isBlockNormalCube()) + { + float f8 = 0.021875F; + + if (this.blockAccess.getBlock(p_147788_2_ - 1, p_147788_3_, p_147788_4_).isBlockNormalCube() && this.blockAccess.getBlock(p_147788_2_ - 1, p_147788_3_ + 1, p_147788_4_) == Blocks.redstone_wire) + { + tessellator.setColorOpaque_F(f1, f2, f3); + tessellator.addVertexWithUV((double)p_147788_2_ + 0.015625D, (double)((float)(p_147788_3_ + 1) + 0.021875F), (double)(p_147788_4_ + 1), (double)iicon1.getMaxU(), (double)iicon1.getMinV()); + tessellator.addVertexWithUV((double)p_147788_2_ + 0.015625D, (double)(p_147788_3_ + 0), (double)(p_147788_4_ + 1), (double)iicon1.getMinU(), (double)iicon1.getMinV()); + tessellator.addVertexWithUV((double)p_147788_2_ + 0.015625D, (double)(p_147788_3_ + 0), (double)(p_147788_4_ + 0), (double)iicon1.getMinU(), (double)iicon1.getMaxV()); + tessellator.addVertexWithUV((double)p_147788_2_ + 0.015625D, (double)((float)(p_147788_3_ + 1) + 0.021875F), (double)(p_147788_4_ + 0), (double)iicon1.getMaxU(), (double)iicon1.getMaxV()); + tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F); + tessellator.addVertexWithUV((double)p_147788_2_ + 0.015625D, (double)((float)(p_147788_3_ + 1) + 0.021875F), (double)(p_147788_4_ + 1), (double)iicon3.getMaxU(), (double)iicon3.getMinV()); + tessellator.addVertexWithUV((double)p_147788_2_ + 0.015625D, (double)(p_147788_3_ + 0), (double)(p_147788_4_ + 1), (double)iicon3.getMinU(), (double)iicon3.getMinV()); + tessellator.addVertexWithUV((double)p_147788_2_ + 0.015625D, (double)(p_147788_3_ + 0), (double)(p_147788_4_ + 0), (double)iicon3.getMinU(), (double)iicon3.getMaxV()); + tessellator.addVertexWithUV((double)p_147788_2_ + 0.015625D, (double)((float)(p_147788_3_ + 1) + 0.021875F), (double)(p_147788_4_ + 0), (double)iicon3.getMaxU(), (double)iicon3.getMaxV()); + } + + if (this.blockAccess.getBlock(p_147788_2_ + 1, p_147788_3_, p_147788_4_).isBlockNormalCube() && this.blockAccess.getBlock(p_147788_2_ + 1, p_147788_3_ + 1, p_147788_4_) == Blocks.redstone_wire) + { + tessellator.setColorOpaque_F(f1, f2, f3); + tessellator.addVertexWithUV((double)(p_147788_2_ + 1) - 0.015625D, (double)(p_147788_3_ + 0), (double)(p_147788_4_ + 1), (double)iicon1.getMinU(), (double)iicon1.getMaxV()); + tessellator.addVertexWithUV((double)(p_147788_2_ + 1) - 0.015625D, (double)((float)(p_147788_3_ + 1) + 0.021875F), (double)(p_147788_4_ + 1), (double)iicon1.getMaxU(), (double)iicon1.getMaxV()); + tessellator.addVertexWithUV((double)(p_147788_2_ + 1) - 0.015625D, (double)((float)(p_147788_3_ + 1) + 0.021875F), (double)(p_147788_4_ + 0), (double)iicon1.getMaxU(), (double)iicon1.getMinV()); + tessellator.addVertexWithUV((double)(p_147788_2_ + 1) - 0.015625D, (double)(p_147788_3_ + 0), (double)(p_147788_4_ + 0), (double)iicon1.getMinU(), (double)iicon1.getMinV()); + tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F); + tessellator.addVertexWithUV((double)(p_147788_2_ + 1) - 0.015625D, (double)(p_147788_3_ + 0), (double)(p_147788_4_ + 1), (double)iicon3.getMinU(), (double)iicon3.getMaxV()); + tessellator.addVertexWithUV((double)(p_147788_2_ + 1) - 0.015625D, (double)((float)(p_147788_3_ + 1) + 0.021875F), (double)(p_147788_4_ + 1), (double)iicon3.getMaxU(), (double)iicon3.getMaxV()); + tessellator.addVertexWithUV((double)(p_147788_2_ + 1) - 0.015625D, (double)((float)(p_147788_3_ + 1) + 0.021875F), (double)(p_147788_4_ + 0), (double)iicon3.getMaxU(), (double)iicon3.getMinV()); + tessellator.addVertexWithUV((double)(p_147788_2_ + 1) - 0.015625D, (double)(p_147788_3_ + 0), (double)(p_147788_4_ + 0), (double)iicon3.getMinU(), (double)iicon3.getMinV()); + } + + if (this.blockAccess.getBlock(p_147788_2_, p_147788_3_, p_147788_4_ - 1).isBlockNormalCube() && this.blockAccess.getBlock(p_147788_2_, p_147788_3_ + 1, p_147788_4_ - 1) == Blocks.redstone_wire) + { + tessellator.setColorOpaque_F(f1, f2, f3); + tessellator.addVertexWithUV((double)(p_147788_2_ + 1), (double)(p_147788_3_ + 0), (double)p_147788_4_ + 0.015625D, (double)iicon1.getMinU(), (double)iicon1.getMaxV()); + tessellator.addVertexWithUV((double)(p_147788_2_ + 1), (double)((float)(p_147788_3_ + 1) + 0.021875F), (double)p_147788_4_ + 0.015625D, (double)iicon1.getMaxU(), (double)iicon1.getMaxV()); + tessellator.addVertexWithUV((double)(p_147788_2_ + 0), (double)((float)(p_147788_3_ + 1) + 0.021875F), (double)p_147788_4_ + 0.015625D, (double)iicon1.getMaxU(), (double)iicon1.getMinV()); + tessellator.addVertexWithUV((double)(p_147788_2_ + 0), (double)(p_147788_3_ + 0), (double)p_147788_4_ + 0.015625D, (double)iicon1.getMinU(), (double)iicon1.getMinV()); + tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F); + tessellator.addVertexWithUV((double)(p_147788_2_ + 1), (double)(p_147788_3_ + 0), (double)p_147788_4_ + 0.015625D, (double)iicon3.getMinU(), (double)iicon3.getMaxV()); + tessellator.addVertexWithUV((double)(p_147788_2_ + 1), (double)((float)(p_147788_3_ + 1) + 0.021875F), (double)p_147788_4_ + 0.015625D, (double)iicon3.getMaxU(), (double)iicon3.getMaxV()); + tessellator.addVertexWithUV((double)(p_147788_2_ + 0), (double)((float)(p_147788_3_ + 1) + 0.021875F), (double)p_147788_4_ + 0.015625D, (double)iicon3.getMaxU(), (double)iicon3.getMinV()); + tessellator.addVertexWithUV((double)(p_147788_2_ + 0), (double)(p_147788_3_ + 0), (double)p_147788_4_ + 0.015625D, (double)iicon3.getMinU(), (double)iicon3.getMinV()); + } + + if (this.blockAccess.getBlock(p_147788_2_, p_147788_3_, p_147788_4_ + 1).isBlockNormalCube() && this.blockAccess.getBlock(p_147788_2_, p_147788_3_ + 1, p_147788_4_ + 1) == Blocks.redstone_wire) + { + tessellator.setColorOpaque_F(f1, f2, f3); + tessellator.addVertexWithUV((double)(p_147788_2_ + 1), (double)((float)(p_147788_3_ + 1) + 0.021875F), (double)(p_147788_4_ + 1) - 0.015625D, (double)iicon1.getMaxU(), (double)iicon1.getMinV()); + tessellator.addVertexWithUV((double)(p_147788_2_ + 1), (double)(p_147788_3_ + 0), (double)(p_147788_4_ + 1) - 0.015625D, (double)iicon1.getMinU(), (double)iicon1.getMinV()); + tessellator.addVertexWithUV((double)(p_147788_2_ + 0), (double)(p_147788_3_ + 0), (double)(p_147788_4_ + 1) - 0.015625D, (double)iicon1.getMinU(), (double)iicon1.getMaxV()); + tessellator.addVertexWithUV((double)(p_147788_2_ + 0), (double)((float)(p_147788_3_ + 1) + 0.021875F), (double)(p_147788_4_ + 1) - 0.015625D, (double)iicon1.getMaxU(), (double)iicon1.getMaxV()); + tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F); + tessellator.addVertexWithUV((double)(p_147788_2_ + 1), (double)((float)(p_147788_3_ + 1) + 0.021875F), (double)(p_147788_4_ + 1) - 0.015625D, (double)iicon3.getMaxU(), (double)iicon3.getMinV()); + tessellator.addVertexWithUV((double)(p_147788_2_ + 1), (double)(p_147788_3_ + 0), (double)(p_147788_4_ + 1) - 0.015625D, (double)iicon3.getMinU(), (double)iicon3.getMinV()); + tessellator.addVertexWithUV((double)(p_147788_2_ + 0), (double)(p_147788_3_ + 0), (double)(p_147788_4_ + 1) - 0.015625D, (double)iicon3.getMinU(), (double)iicon3.getMaxV()); + tessellator.addVertexWithUV((double)(p_147788_2_ + 0), (double)((float)(p_147788_3_ + 1) + 0.021875F), (double)(p_147788_4_ + 1) - 0.015625D, (double)iicon3.getMaxU(), (double)iicon3.getMaxV()); + } + } + + return true; + } + + public boolean renderBlockMinecartTrack(BlockRailBase p_147766_1_, int p_147766_2_, int p_147766_3_, int p_147766_4_) + { + Tessellator tessellator = Tessellator.instance; + int l = this.blockAccess.getBlockMetadata(p_147766_2_, p_147766_3_, p_147766_4_); + IIcon iicon = this.getBlockIconFromSideAndMetadata(p_147766_1_, 0, l); + + if (this.hasOverrideBlockTexture()) + { + iicon = this.overrideBlockTexture; + } + + if (p_147766_1_.isPowered()) + { + l &= 7; + } + + tessellator.setBrightness(p_147766_1_.getMixedBrightnessForBlock(this.blockAccess, p_147766_2_, p_147766_3_, p_147766_4_)); + tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F); + double d0 = (double)iicon.getMinU(); + double d1 = (double)iicon.getMinV(); + double d2 = (double)iicon.getMaxU(); + double d3 = (double)iicon.getMaxV(); + double d4 = 0.0625D; + double d5 = (double)(p_147766_2_ + 1); + double d6 = (double)(p_147766_2_ + 1); + double d7 = (double)(p_147766_2_ + 0); + double d8 = (double)(p_147766_2_ + 0); + double d9 = (double)(p_147766_4_ + 0); + double d10 = (double)(p_147766_4_ + 1); + double d11 = (double)(p_147766_4_ + 1); + double d12 = (double)(p_147766_4_ + 0); + double d13 = (double)p_147766_3_ + d4; + double d14 = (double)p_147766_3_ + d4; + double d15 = (double)p_147766_3_ + d4; + double d16 = (double)p_147766_3_ + d4; + + if (l != 1 && l != 2 && l != 3 && l != 7) + { + if (l == 8) + { + d5 = d6 = (double)(p_147766_2_ + 0); + d7 = d8 = (double)(p_147766_2_ + 1); + d9 = d12 = (double)(p_147766_4_ + 1); + d10 = d11 = (double)(p_147766_4_ + 0); + } + else if (l == 9) + { + d5 = d8 = (double)(p_147766_2_ + 0); + d6 = d7 = (double)(p_147766_2_ + 1); + d9 = d10 = (double)(p_147766_4_ + 0); + d11 = d12 = (double)(p_147766_4_ + 1); + } + } + else + { + d5 = d8 = (double)(p_147766_2_ + 1); + d6 = d7 = (double)(p_147766_2_ + 0); + d9 = d10 = (double)(p_147766_4_ + 1); + d11 = d12 = (double)(p_147766_4_ + 0); + } + + if (l != 2 && l != 4) + { + if (l == 3 || l == 5) + { + ++d14; + ++d15; + } + } + else + { + ++d13; + ++d16; + } + + tessellator.addVertexWithUV(d5, d13, d9, d2, d1); + tessellator.addVertexWithUV(d6, d14, d10, d2, d3); + tessellator.addVertexWithUV(d7, d15, d11, d0, d3); + tessellator.addVertexWithUV(d8, d16, d12, d0, d1); + tessellator.addVertexWithUV(d8, d16, d12, d0, d1); + tessellator.addVertexWithUV(d7, d15, d11, d0, d3); + tessellator.addVertexWithUV(d6, d14, d10, d2, d3); + tessellator.addVertexWithUV(d5, d13, d9, d2, d1); + return true; + } + + public boolean renderBlockLadder(Block p_147794_1_, int p_147794_2_, int p_147794_3_, int p_147794_4_) + { + Tessellator tessellator = Tessellator.instance; + IIcon iicon = this.getBlockIconFromSide(p_147794_1_, 0); + + if (this.hasOverrideBlockTexture()) + { + iicon = this.overrideBlockTexture; + } + + tessellator.setBrightness(p_147794_1_.getMixedBrightnessForBlock(this.blockAccess, p_147794_2_, p_147794_3_, p_147794_4_)); + tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F); + double d0 = (double)iicon.getMinU(); + double d1 = (double)iicon.getMinV(); + double d2 = (double)iicon.getMaxU(); + double d3 = (double)iicon.getMaxV(); + int l = this.blockAccess.getBlockMetadata(p_147794_2_, p_147794_3_, p_147794_4_); + double d4 = 0.0D; + double d5 = 0.05000000074505806D; + + if (l == 5) + { + tessellator.addVertexWithUV((double)p_147794_2_ + d5, (double)(p_147794_3_ + 1) + d4, (double)(p_147794_4_ + 1) + d4, d0, d1); + tessellator.addVertexWithUV((double)p_147794_2_ + d5, (double)(p_147794_3_ + 0) - d4, (double)(p_147794_4_ + 1) + d4, d0, d3); + tessellator.addVertexWithUV((double)p_147794_2_ + d5, (double)(p_147794_3_ + 0) - d4, (double)(p_147794_4_ + 0) - d4, d2, d3); + tessellator.addVertexWithUV((double)p_147794_2_ + d5, (double)(p_147794_3_ + 1) + d4, (double)(p_147794_4_ + 0) - d4, d2, d1); + } + + if (l == 4) + { + tessellator.addVertexWithUV((double)(p_147794_2_ + 1) - d5, (double)(p_147794_3_ + 0) - d4, (double)(p_147794_4_ + 1) + d4, d2, d3); + tessellator.addVertexWithUV((double)(p_147794_2_ + 1) - d5, (double)(p_147794_3_ + 1) + d4, (double)(p_147794_4_ + 1) + d4, d2, d1); + tessellator.addVertexWithUV((double)(p_147794_2_ + 1) - d5, (double)(p_147794_3_ + 1) + d4, (double)(p_147794_4_ + 0) - d4, d0, d1); + tessellator.addVertexWithUV((double)(p_147794_2_ + 1) - d5, (double)(p_147794_3_ + 0) - d4, (double)(p_147794_4_ + 0) - d4, d0, d3); + } + + if (l == 3) + { + tessellator.addVertexWithUV((double)(p_147794_2_ + 1) + d4, (double)(p_147794_3_ + 0) - d4, (double)p_147794_4_ + d5, d2, d3); + tessellator.addVertexWithUV((double)(p_147794_2_ + 1) + d4, (double)(p_147794_3_ + 1) + d4, (double)p_147794_4_ + d5, d2, d1); + tessellator.addVertexWithUV((double)(p_147794_2_ + 0) - d4, (double)(p_147794_3_ + 1) + d4, (double)p_147794_4_ + d5, d0, d1); + tessellator.addVertexWithUV((double)(p_147794_2_ + 0) - d4, (double)(p_147794_3_ + 0) - d4, (double)p_147794_4_ + d5, d0, d3); + } + + if (l == 2) + { + tessellator.addVertexWithUV((double)(p_147794_2_ + 1) + d4, (double)(p_147794_3_ + 1) + d4, (double)(p_147794_4_ + 1) - d5, d0, d1); + tessellator.addVertexWithUV((double)(p_147794_2_ + 1) + d4, (double)(p_147794_3_ + 0) - d4, (double)(p_147794_4_ + 1) - d5, d0, d3); + tessellator.addVertexWithUV((double)(p_147794_2_ + 0) - d4, (double)(p_147794_3_ + 0) - d4, (double)(p_147794_4_ + 1) - d5, d2, d3); + tessellator.addVertexWithUV((double)(p_147794_2_ + 0) - d4, (double)(p_147794_3_ + 1) + d4, (double)(p_147794_4_ + 1) - d5, d2, d1); + } + + return true; + } + + public boolean renderBlockVine(Block p_147726_1_, int p_147726_2_, int p_147726_3_, int p_147726_4_) + { + Tessellator tessellator = Tessellator.instance; + IIcon iicon = this.getBlockIconFromSide(p_147726_1_, 0); + + if (this.hasOverrideBlockTexture()) + { + iicon = this.overrideBlockTexture; + } + + tessellator.setBrightness(p_147726_1_.getMixedBrightnessForBlock(this.blockAccess, p_147726_2_, p_147726_3_, p_147726_4_)); + int l = p_147726_1_.colorMultiplier(this.blockAccess, p_147726_2_, p_147726_3_, p_147726_4_); + float f = (float)(l >> 16 & 255) / 255.0F; + float f1 = (float)(l >> 8 & 255) / 255.0F; + float f2 = (float)(l & 255) / 255.0F; + tessellator.setColorOpaque_F(f, f1, f2); + double d3 = (double)iicon.getMinU(); + double d4 = (double)iicon.getMinV(); + double d0 = (double)iicon.getMaxU(); + double d1 = (double)iicon.getMaxV(); + double d2 = 0.05000000074505806D; + int i1 = this.blockAccess.getBlockMetadata(p_147726_2_, p_147726_3_, p_147726_4_); + + if ((i1 & 2) != 0) + { + tessellator.addVertexWithUV((double)p_147726_2_ + d2, (double)(p_147726_3_ + 1), (double)(p_147726_4_ + 1), d3, d4); + tessellator.addVertexWithUV((double)p_147726_2_ + d2, (double)(p_147726_3_ + 0), (double)(p_147726_4_ + 1), d3, d1); + tessellator.addVertexWithUV((double)p_147726_2_ + d2, (double)(p_147726_3_ + 0), (double)(p_147726_4_ + 0), d0, d1); + tessellator.addVertexWithUV((double)p_147726_2_ + d2, (double)(p_147726_3_ + 1), (double)(p_147726_4_ + 0), d0, d4); + tessellator.addVertexWithUV((double)p_147726_2_ + d2, (double)(p_147726_3_ + 1), (double)(p_147726_4_ + 0), d0, d4); + tessellator.addVertexWithUV((double)p_147726_2_ + d2, (double)(p_147726_3_ + 0), (double)(p_147726_4_ + 0), d0, d1); + tessellator.addVertexWithUV((double)p_147726_2_ + d2, (double)(p_147726_3_ + 0), (double)(p_147726_4_ + 1), d3, d1); + tessellator.addVertexWithUV((double)p_147726_2_ + d2, (double)(p_147726_3_ + 1), (double)(p_147726_4_ + 1), d3, d4); + } + + if ((i1 & 8) != 0) + { + tessellator.addVertexWithUV((double)(p_147726_2_ + 1) - d2, (double)(p_147726_3_ + 0), (double)(p_147726_4_ + 1), d0, d1); + tessellator.addVertexWithUV((double)(p_147726_2_ + 1) - d2, (double)(p_147726_3_ + 1), (double)(p_147726_4_ + 1), d0, d4); + tessellator.addVertexWithUV((double)(p_147726_2_ + 1) - d2, (double)(p_147726_3_ + 1), (double)(p_147726_4_ + 0), d3, d4); + tessellator.addVertexWithUV((double)(p_147726_2_ + 1) - d2, (double)(p_147726_3_ + 0), (double)(p_147726_4_ + 0), d3, d1); + tessellator.addVertexWithUV((double)(p_147726_2_ + 1) - d2, (double)(p_147726_3_ + 0), (double)(p_147726_4_ + 0), d3, d1); + tessellator.addVertexWithUV((double)(p_147726_2_ + 1) - d2, (double)(p_147726_3_ + 1), (double)(p_147726_4_ + 0), d3, d4); + tessellator.addVertexWithUV((double)(p_147726_2_ + 1) - d2, (double)(p_147726_3_ + 1), (double)(p_147726_4_ + 1), d0, d4); + tessellator.addVertexWithUV((double)(p_147726_2_ + 1) - d2, (double)(p_147726_3_ + 0), (double)(p_147726_4_ + 1), d0, d1); + } + + if ((i1 & 4) != 0) + { + tessellator.addVertexWithUV((double)(p_147726_2_ + 1), (double)(p_147726_3_ + 0), (double)p_147726_4_ + d2, d0, d1); + tessellator.addVertexWithUV((double)(p_147726_2_ + 1), (double)(p_147726_3_ + 1), (double)p_147726_4_ + d2, d0, d4); + tessellator.addVertexWithUV((double)(p_147726_2_ + 0), (double)(p_147726_3_ + 1), (double)p_147726_4_ + d2, d3, d4); + tessellator.addVertexWithUV((double)(p_147726_2_ + 0), (double)(p_147726_3_ + 0), (double)p_147726_4_ + d2, d3, d1); + tessellator.addVertexWithUV((double)(p_147726_2_ + 0), (double)(p_147726_3_ + 0), (double)p_147726_4_ + d2, d3, d1); + tessellator.addVertexWithUV((double)(p_147726_2_ + 0), (double)(p_147726_3_ + 1), (double)p_147726_4_ + d2, d3, d4); + tessellator.addVertexWithUV((double)(p_147726_2_ + 1), (double)(p_147726_3_ + 1), (double)p_147726_4_ + d2, d0, d4); + tessellator.addVertexWithUV((double)(p_147726_2_ + 1), (double)(p_147726_3_ + 0), (double)p_147726_4_ + d2, d0, d1); + } + + if ((i1 & 1) != 0) + { + tessellator.addVertexWithUV((double)(p_147726_2_ + 1), (double)(p_147726_3_ + 1), (double)(p_147726_4_ + 1) - d2, d3, d4); + tessellator.addVertexWithUV((double)(p_147726_2_ + 1), (double)(p_147726_3_ + 0), (double)(p_147726_4_ + 1) - d2, d3, d1); + tessellator.addVertexWithUV((double)(p_147726_2_ + 0), (double)(p_147726_3_ + 0), (double)(p_147726_4_ + 1) - d2, d0, d1); + tessellator.addVertexWithUV((double)(p_147726_2_ + 0), (double)(p_147726_3_ + 1), (double)(p_147726_4_ + 1) - d2, d0, d4); + tessellator.addVertexWithUV((double)(p_147726_2_ + 0), (double)(p_147726_3_ + 1), (double)(p_147726_4_ + 1) - d2, d0, d4); + tessellator.addVertexWithUV((double)(p_147726_2_ + 0), (double)(p_147726_3_ + 0), (double)(p_147726_4_ + 1) - d2, d0, d1); + tessellator.addVertexWithUV((double)(p_147726_2_ + 1), (double)(p_147726_3_ + 0), (double)(p_147726_4_ + 1) - d2, d3, d1); + tessellator.addVertexWithUV((double)(p_147726_2_ + 1), (double)(p_147726_3_ + 1), (double)(p_147726_4_ + 1) - d2, d3, d4); + } + + if (this.blockAccess.getBlock(p_147726_2_, p_147726_3_ + 1, p_147726_4_).isBlockNormalCube()) + { + tessellator.addVertexWithUV((double)(p_147726_2_ + 1), (double)(p_147726_3_ + 1) - d2, (double)(p_147726_4_ + 0), d3, d4); + tessellator.addVertexWithUV((double)(p_147726_2_ + 1), (double)(p_147726_3_ + 1) - d2, (double)(p_147726_4_ + 1), d3, d1); + tessellator.addVertexWithUV((double)(p_147726_2_ + 0), (double)(p_147726_3_ + 1) - d2, (double)(p_147726_4_ + 1), d0, d1); + tessellator.addVertexWithUV((double)(p_147726_2_ + 0), (double)(p_147726_3_ + 1) - d2, (double)(p_147726_4_ + 0), d0, d4); + } + + return true; + } + + public boolean renderBlockStainedGlassPane(Block p_147733_1_, int p_147733_2_, int p_147733_3_, int p_147733_4_) + { + int l = this.blockAccess.getHeight(); + Tessellator tessellator = Tessellator.instance; + tessellator.setBrightness(p_147733_1_.getMixedBrightnessForBlock(this.blockAccess, p_147733_2_, p_147733_3_, p_147733_4_)); + int i1 = p_147733_1_.colorMultiplier(this.blockAccess, p_147733_2_, p_147733_3_, p_147733_4_); + float f = (float)(i1 >> 16 & 255) / 255.0F; + float f1 = (float)(i1 >> 8 & 255) / 255.0F; + float f2 = (float)(i1 & 255) / 255.0F; + + if (EntityRenderer.anaglyphEnable) + { + float f3 = (f * 30.0F + f1 * 59.0F + f2 * 11.0F) / 100.0F; + float f4 = (f * 30.0F + f1 * 70.0F) / 100.0F; + float f5 = (f * 30.0F + f2 * 70.0F) / 100.0F; + f = f3; + f1 = f4; + f2 = f5; + } + + tessellator.setColorOpaque_F(f, f1, f2); + boolean flag5 = p_147733_1_ instanceof BlockStainedGlassPane; + IIcon iicon; + IIcon iicon1; + + if (this.hasOverrideBlockTexture()) + { + iicon = this.overrideBlockTexture; + iicon1 = this.overrideBlockTexture; + } + else + { + int j1 = this.blockAccess.getBlockMetadata(p_147733_2_, p_147733_3_, p_147733_4_); + iicon = this.getBlockIconFromSideAndMetadata(p_147733_1_, 0, j1); + iicon1 = flag5 ? ((BlockStainedGlassPane)p_147733_1_).func_150104_b(j1) : ((BlockPane)p_147733_1_).func_150097_e(); + } + + double d22 = (double)iicon.getMinU(); + double d0 = (double)iicon.getInterpolatedU(7.0D); + double d1 = (double)iicon.getInterpolatedU(9.0D); + double d2 = (double)iicon.getMaxU(); + double d3 = (double)iicon.getMinV(); + double d4 = (double)iicon.getMaxV(); + double d5 = (double)iicon1.getInterpolatedU(7.0D); + double d6 = (double)iicon1.getInterpolatedU(9.0D); + double d7 = (double)iicon1.getMinV(); + double d8 = (double)iicon1.getMaxV(); + double d9 = (double)iicon1.getInterpolatedV(7.0D); + double d10 = (double)iicon1.getInterpolatedV(9.0D); + double d11 = (double)p_147733_2_; + double d12 = (double)(p_147733_2_ + 1); + double d13 = (double)p_147733_4_; + double d14 = (double)(p_147733_4_ + 1); + double d15 = (double)p_147733_2_ + 0.5D - 0.0625D; + double d16 = (double)p_147733_2_ + 0.5D + 0.0625D; + double d17 = (double)p_147733_4_ + 0.5D - 0.0625D; + double d18 = (double)p_147733_4_ + 0.5D + 0.0625D; + boolean flag = flag5 ? ((BlockStainedGlassPane)p_147733_1_).canPaneConnectToBlock(this.blockAccess.getBlock(p_147733_2_, p_147733_3_, p_147733_4_ - 1)) : ((BlockPane)p_147733_1_).canPaneConnectToBlock(this.blockAccess.getBlock(p_147733_2_, p_147733_3_, p_147733_4_ - 1)); + boolean flag1 = flag5 ? ((BlockStainedGlassPane)p_147733_1_).canPaneConnectToBlock(this.blockAccess.getBlock(p_147733_2_, p_147733_3_, p_147733_4_ + 1)) : ((BlockPane)p_147733_1_).canPaneConnectToBlock(this.blockAccess.getBlock(p_147733_2_, p_147733_3_, p_147733_4_ + 1)); + boolean flag2 = flag5 ? ((BlockStainedGlassPane)p_147733_1_).canPaneConnectToBlock(this.blockAccess.getBlock(p_147733_2_ - 1, p_147733_3_, p_147733_4_)) : ((BlockPane)p_147733_1_).canPaneConnectToBlock(this.blockAccess.getBlock(p_147733_2_ - 1, p_147733_3_, p_147733_4_)); + boolean flag3 = flag5 ? ((BlockStainedGlassPane)p_147733_1_).canPaneConnectToBlock(this.blockAccess.getBlock(p_147733_2_ + 1, p_147733_3_, p_147733_4_)) : ((BlockPane)p_147733_1_).canPaneConnectToBlock(this.blockAccess.getBlock(p_147733_2_ + 1, p_147733_3_, p_147733_4_)); + double d19 = 0.001D; + double d20 = 0.999D; + double d21 = 0.001D; + boolean flag4 = !flag && !flag1 && !flag2 && !flag3; + + if (!flag2 && !flag4) + { + if (!flag && !flag1) + { + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.999D, d17, d0, d3); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.001D, d17, d0, d4); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.001D, d18, d1, d4); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.999D, d18, d1, d3); + } + } + else if (flag2 && flag3) + { + if (!flag) + { + tessellator.addVertexWithUV(d12, (double)p_147733_3_ + 0.999D, d17, d2, d3); + tessellator.addVertexWithUV(d12, (double)p_147733_3_ + 0.001D, d17, d2, d4); + tessellator.addVertexWithUV(d11, (double)p_147733_3_ + 0.001D, d17, d22, d4); + tessellator.addVertexWithUV(d11, (double)p_147733_3_ + 0.999D, d17, d22, d3); + } + else + { + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.999D, d17, d0, d3); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.001D, d17, d0, d4); + tessellator.addVertexWithUV(d11, (double)p_147733_3_ + 0.001D, d17, d22, d4); + tessellator.addVertexWithUV(d11, (double)p_147733_3_ + 0.999D, d17, d22, d3); + tessellator.addVertexWithUV(d12, (double)p_147733_3_ + 0.999D, d17, d2, d3); + tessellator.addVertexWithUV(d12, (double)p_147733_3_ + 0.001D, d17, d2, d4); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.001D, d17, d1, d4); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.999D, d17, d1, d3); + } + + if (!flag1) + { + tessellator.addVertexWithUV(d11, (double)p_147733_3_ + 0.999D, d18, d22, d3); + tessellator.addVertexWithUV(d11, (double)p_147733_3_ + 0.001D, d18, d22, d4); + tessellator.addVertexWithUV(d12, (double)p_147733_3_ + 0.001D, d18, d2, d4); + tessellator.addVertexWithUV(d12, (double)p_147733_3_ + 0.999D, d18, d2, d3); + } + else + { + tessellator.addVertexWithUV(d11, (double)p_147733_3_ + 0.999D, d18, d22, d3); + tessellator.addVertexWithUV(d11, (double)p_147733_3_ + 0.001D, d18, d22, d4); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.001D, d18, d0, d4); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.999D, d18, d0, d3); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.999D, d18, d1, d3); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.001D, d18, d1, d4); + tessellator.addVertexWithUV(d12, (double)p_147733_3_ + 0.001D, d18, d2, d4); + tessellator.addVertexWithUV(d12, (double)p_147733_3_ + 0.999D, d18, d2, d3); + } + + tessellator.addVertexWithUV(d11, (double)p_147733_3_ + 0.999D, d18, d6, d7); + tessellator.addVertexWithUV(d12, (double)p_147733_3_ + 0.999D, d18, d6, d8); + tessellator.addVertexWithUV(d12, (double)p_147733_3_ + 0.999D, d17, d5, d8); + tessellator.addVertexWithUV(d11, (double)p_147733_3_ + 0.999D, d17, d5, d7); + tessellator.addVertexWithUV(d12, (double)p_147733_3_ + 0.001D, d18, d5, d8); + tessellator.addVertexWithUV(d11, (double)p_147733_3_ + 0.001D, d18, d5, d7); + tessellator.addVertexWithUV(d11, (double)p_147733_3_ + 0.001D, d17, d6, d7); + tessellator.addVertexWithUV(d12, (double)p_147733_3_ + 0.001D, d17, d6, d8); + } + else + { + if (!flag && !flag4) + { + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.999D, d17, d1, d3); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.001D, d17, d1, d4); + tessellator.addVertexWithUV(d11, (double)p_147733_3_ + 0.001D, d17, d22, d4); + tessellator.addVertexWithUV(d11, (double)p_147733_3_ + 0.999D, d17, d22, d3); + } + else + { + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.999D, d17, d0, d3); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.001D, d17, d0, d4); + tessellator.addVertexWithUV(d11, (double)p_147733_3_ + 0.001D, d17, d22, d4); + tessellator.addVertexWithUV(d11, (double)p_147733_3_ + 0.999D, d17, d22, d3); + } + + if (!flag1 && !flag4) + { + tessellator.addVertexWithUV(d11, (double)p_147733_3_ + 0.999D, d18, d22, d3); + tessellator.addVertexWithUV(d11, (double)p_147733_3_ + 0.001D, d18, d22, d4); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.001D, d18, d1, d4); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.999D, d18, d1, d3); + } + else + { + tessellator.addVertexWithUV(d11, (double)p_147733_3_ + 0.999D, d18, d22, d3); + tessellator.addVertexWithUV(d11, (double)p_147733_3_ + 0.001D, d18, d22, d4); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.001D, d18, d0, d4); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.999D, d18, d0, d3); + } + + tessellator.addVertexWithUV(d11, (double)p_147733_3_ + 0.999D, d18, d6, d7); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.999D, d18, d6, d9); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.999D, d17, d5, d9); + tessellator.addVertexWithUV(d11, (double)p_147733_3_ + 0.999D, d17, d5, d7); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.001D, d18, d5, d9); + tessellator.addVertexWithUV(d11, (double)p_147733_3_ + 0.001D, d18, d5, d7); + tessellator.addVertexWithUV(d11, (double)p_147733_3_ + 0.001D, d17, d6, d7); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.001D, d17, d6, d9); + } + + if ((flag3 || flag4) && !flag2) + { + if (!flag1 && !flag4) + { + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.999D, d18, d0, d3); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.001D, d18, d0, d4); + tessellator.addVertexWithUV(d12, (double)p_147733_3_ + 0.001D, d18, d2, d4); + tessellator.addVertexWithUV(d12, (double)p_147733_3_ + 0.999D, d18, d2, d3); + } + else + { + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.999D, d18, d1, d3); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.001D, d18, d1, d4); + tessellator.addVertexWithUV(d12, (double)p_147733_3_ + 0.001D, d18, d2, d4); + tessellator.addVertexWithUV(d12, (double)p_147733_3_ + 0.999D, d18, d2, d3); + } + + if (!flag && !flag4) + { + tessellator.addVertexWithUV(d12, (double)p_147733_3_ + 0.999D, d17, d2, d3); + tessellator.addVertexWithUV(d12, (double)p_147733_3_ + 0.001D, d17, d2, d4); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.001D, d17, d0, d4); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.999D, d17, d0, d3); + } + else + { + tessellator.addVertexWithUV(d12, (double)p_147733_3_ + 0.999D, d17, d2, d3); + tessellator.addVertexWithUV(d12, (double)p_147733_3_ + 0.001D, d17, d2, d4); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.001D, d17, d1, d4); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.999D, d17, d1, d3); + } + + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.999D, d18, d6, d10); + tessellator.addVertexWithUV(d12, (double)p_147733_3_ + 0.999D, d18, d6, d7); + tessellator.addVertexWithUV(d12, (double)p_147733_3_ + 0.999D, d17, d5, d7); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.999D, d17, d5, d10); + tessellator.addVertexWithUV(d12, (double)p_147733_3_ + 0.001D, d18, d5, d8); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.001D, d18, d5, d10); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.001D, d17, d6, d10); + tessellator.addVertexWithUV(d12, (double)p_147733_3_ + 0.001D, d17, d6, d8); + } + else if (!flag3 && !flag && !flag1) + { + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.999D, d18, d0, d3); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.001D, d18, d0, d4); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.001D, d17, d1, d4); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.999D, d17, d1, d3); + } + + if (!flag && !flag4) + { + if (!flag3 && !flag2) + { + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.999D, d17, d1, d3); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.001D, d17, d1, d4); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.001D, d17, d0, d4); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.999D, d17, d0, d3); + } + } + else if (flag && flag1) + { + if (!flag2) + { + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.999D, d13, d22, d3); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.001D, d13, d22, d4); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.001D, d14, d2, d4); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.999D, d14, d2, d3); + } + else + { + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.999D, d13, d22, d3); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.001D, d13, d22, d4); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.001D, d17, d0, d4); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.999D, d17, d0, d3); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.999D, d18, d1, d3); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.001D, d18, d1, d4); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.001D, d14, d2, d4); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.999D, d14, d2, d3); + } + + if (!flag3) + { + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.999D, d14, d2, d3); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.001D, d14, d2, d4); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.001D, d13, d22, d4); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.999D, d13, d22, d3); + } + else + { + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.999D, d17, d0, d3); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.001D, d17, d0, d4); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.001D, d13, d22, d4); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.999D, d13, d22, d3); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.999D, d14, d2, d3); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.001D, d14, d2, d4); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.001D, d18, d1, d4); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.999D, d18, d1, d3); + } + + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.999D, d13, d6, d7); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.999D, d13, d5, d7); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.999D, d14, d5, d8); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.999D, d14, d6, d8); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.001D, d13, d5, d7); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.001D, d13, d6, d7); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.001D, d14, d6, d8); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.001D, d14, d5, d8); + } + else + { + if (!flag2 && !flag4) + { + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.999D, d13, d22, d3); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.001D, d13, d22, d4); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.001D, d18, d1, d4); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.999D, d18, d1, d3); + } + else + { + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.999D, d13, d22, d3); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.001D, d13, d22, d4); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.001D, d17, d0, d4); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.999D, d17, d0, d3); + } + + if (!flag3 && !flag4) + { + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.999D, d18, d1, d3); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.001D, d18, d1, d4); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.001D, d13, d22, d4); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.999D, d13, d22, d3); + } + else + { + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.999D, d17, d0, d3); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.001D, d17, d0, d4); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.001D, d13, d22, d4); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.999D, d13, d22, d3); + } + + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.999D, d13, d6, d7); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.999D, d13, d5, d7); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.999D, d17, d5, d9); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.999D, d17, d6, d9); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.001D, d13, d5, d7); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.001D, d13, d6, d7); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.001D, d17, d6, d9); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.001D, d17, d5, d9); + } + + if ((flag1 || flag4) && !flag) + { + if (!flag2 && !flag4) + { + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.999D, d17, d0, d3); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.001D, d17, d0, d4); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.001D, d14, d2, d4); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.999D, d14, d2, d3); + } + else + { + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.999D, d18, d1, d3); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.001D, d18, d1, d4); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.001D, d14, d2, d4); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.999D, d14, d2, d3); + } + + if (!flag3 && !flag4) + { + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.999D, d14, d2, d3); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.001D, d14, d2, d4); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.001D, d17, d0, d4); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.999D, d17, d0, d3); + } + else + { + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.999D, d14, d2, d3); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.001D, d14, d2, d4); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.001D, d18, d1, d4); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.999D, d18, d1, d3); + } + + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.999D, d18, d6, d10); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.999D, d18, d5, d10); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.999D, d14, d5, d8); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.999D, d14, d6, d8); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.001D, d18, d5, d10); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.001D, d18, d6, d10); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.001D, d14, d6, d8); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.001D, d14, d5, d8); + } + else if (!flag1 && !flag3 && !flag2) + { + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.999D, d18, d0, d3); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.001D, d18, d0, d4); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.001D, d18, d1, d4); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.999D, d18, d1, d3); + } + + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.999D, d17, d6, d9); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.999D, d17, d5, d9); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.999D, d18, d5, d10); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.999D, d18, d6, d10); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.001D, d17, d5, d9); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.001D, d17, d6, d9); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.001D, d18, d6, d10); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.001D, d18, d5, d10); + + if (flag4) + { + tessellator.addVertexWithUV(d11, (double)p_147733_3_ + 0.999D, d17, d0, d3); + tessellator.addVertexWithUV(d11, (double)p_147733_3_ + 0.001D, d17, d0, d4); + tessellator.addVertexWithUV(d11, (double)p_147733_3_ + 0.001D, d18, d1, d4); + tessellator.addVertexWithUV(d11, (double)p_147733_3_ + 0.999D, d18, d1, d3); + tessellator.addVertexWithUV(d12, (double)p_147733_3_ + 0.999D, d18, d0, d3); + tessellator.addVertexWithUV(d12, (double)p_147733_3_ + 0.001D, d18, d0, d4); + tessellator.addVertexWithUV(d12, (double)p_147733_3_ + 0.001D, d17, d1, d4); + tessellator.addVertexWithUV(d12, (double)p_147733_3_ + 0.999D, d17, d1, d3); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.999D, d13, d1, d3); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.001D, d13, d1, d4); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.001D, d13, d0, d4); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.999D, d13, d0, d3); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.999D, d14, d0, d3); + tessellator.addVertexWithUV(d15, (double)p_147733_3_ + 0.001D, d14, d0, d4); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.001D, d14, d1, d4); + tessellator.addVertexWithUV(d16, (double)p_147733_3_ + 0.999D, d14, d1, d3); + } + + return true; + } + + public boolean renderBlockPane(BlockPane p_147767_1_, int p_147767_2_, int p_147767_3_, int p_147767_4_) + { + int l = this.blockAccess.getHeight(); + Tessellator tessellator = Tessellator.instance; + tessellator.setBrightness(p_147767_1_.getMixedBrightnessForBlock(this.blockAccess, p_147767_2_, p_147767_3_, p_147767_4_)); + int i1 = p_147767_1_.colorMultiplier(this.blockAccess, p_147767_2_, p_147767_3_, p_147767_4_); + float f = (float)(i1 >> 16 & 255) / 255.0F; + float f1 = (float)(i1 >> 8 & 255) / 255.0F; + float f2 = (float)(i1 & 255) / 255.0F; + + if (EntityRenderer.anaglyphEnable) + { + float f3 = (f * 30.0F + f1 * 59.0F + f2 * 11.0F) / 100.0F; + float f4 = (f * 30.0F + f1 * 70.0F) / 100.0F; + float f5 = (f * 30.0F + f2 * 70.0F) / 100.0F; + f = f3; + f1 = f4; + f2 = f5; + } + + tessellator.setColorOpaque_F(f, f1, f2); + IIcon iicon; + IIcon iicon1; + + if (this.hasOverrideBlockTexture()) + { + iicon = this.overrideBlockTexture; + iicon1 = this.overrideBlockTexture; + } + else + { + int j1 = this.blockAccess.getBlockMetadata(p_147767_2_, p_147767_3_, p_147767_4_); + iicon = this.getBlockIconFromSideAndMetadata(p_147767_1_, 0, j1); + iicon1 = p_147767_1_.func_150097_e(); + } + + double d21 = (double)iicon.getMinU(); + double d0 = (double)iicon.getInterpolatedU(8.0D); + double d1 = (double)iicon.getMaxU(); + double d2 = (double)iicon.getMinV(); + double d3 = (double)iicon.getMaxV(); + double d4 = (double)iicon1.getInterpolatedU(7.0D); + double d5 = (double)iicon1.getInterpolatedU(9.0D); + double d6 = (double)iicon1.getMinV(); + double d7 = (double)iicon1.getInterpolatedV(8.0D); + double d8 = (double)iicon1.getMaxV(); + double d9 = (double)p_147767_2_; + double d10 = (double)p_147767_2_ + 0.5D; + double d11 = (double)(p_147767_2_ + 1); + double d12 = (double)p_147767_4_; + double d13 = (double)p_147767_4_ + 0.5D; + double d14 = (double)(p_147767_4_ + 1); + double d15 = (double)p_147767_2_ + 0.5D - 0.0625D; + double d16 = (double)p_147767_2_ + 0.5D + 0.0625D; + double d17 = (double)p_147767_4_ + 0.5D - 0.0625D; + double d18 = (double)p_147767_4_ + 0.5D + 0.0625D; + boolean flag = p_147767_1_.canPaneConnectTo(this.blockAccess, p_147767_2_, p_147767_3_, p_147767_4_ - 1, NORTH); + boolean flag1 = p_147767_1_.canPaneConnectTo(this.blockAccess, p_147767_2_, p_147767_3_, p_147767_4_ + 1, SOUTH); + boolean flag2 = p_147767_1_.canPaneConnectTo(this.blockAccess, p_147767_2_ - 1, p_147767_3_, p_147767_4_, WEST ); + boolean flag3 = p_147767_1_.canPaneConnectTo(this.blockAccess, p_147767_2_ + 1, p_147767_3_, p_147767_4_, EAST ); + boolean flag4 = p_147767_1_.shouldSideBeRendered(this.blockAccess, p_147767_2_, p_147767_3_ + 1, p_147767_4_, 1); + boolean flag5 = p_147767_1_.shouldSideBeRendered(this.blockAccess, p_147767_2_, p_147767_3_ - 1, p_147767_4_, 0); + double d19 = 0.01D; + double d20 = 0.005D; + + if ((!flag2 || !flag3) && (flag2 || flag3 || flag || flag1)) + { + if (flag2 && !flag3) + { + tessellator.addVertexWithUV(d9, (double)(p_147767_3_ + 1), d13, d21, d2); + tessellator.addVertexWithUV(d9, (double)(p_147767_3_ + 0), d13, d21, d3); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 0), d13, d0, d3); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 1), d13, d0, d2); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 1), d13, d21, d2); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 0), d13, d21, d3); + tessellator.addVertexWithUV(d9, (double)(p_147767_3_ + 0), d13, d0, d3); + tessellator.addVertexWithUV(d9, (double)(p_147767_3_ + 1), d13, d0, d2); + + if (!flag1 && !flag) + { + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 1), d18, d4, d6); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 0), d18, d4, d8); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 0), d17, d5, d8); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 1), d17, d5, d6); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 1), d17, d4, d6); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 0), d17, d4, d8); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 0), d18, d5, d8); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 1), d18, d5, d6); + } + + if (flag4 || p_147767_3_ < l - 1 && this.blockAccess.isAirBlock(p_147767_2_ - 1, p_147767_3_ + 1, p_147767_4_)) + { + tessellator.addVertexWithUV(d9, (double)(p_147767_3_ + 1) + 0.01D, d18, d5, d7); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 1) + 0.01D, d18, d5, d8); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 1) + 0.01D, d17, d4, d8); + tessellator.addVertexWithUV(d9, (double)(p_147767_3_ + 1) + 0.01D, d17, d4, d7); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 1) + 0.01D, d18, d5, d7); + tessellator.addVertexWithUV(d9, (double)(p_147767_3_ + 1) + 0.01D, d18, d5, d8); + tessellator.addVertexWithUV(d9, (double)(p_147767_3_ + 1) + 0.01D, d17, d4, d8); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 1) + 0.01D, d17, d4, d7); + } + + if (flag5 || p_147767_3_ > 1 && this.blockAccess.isAirBlock(p_147767_2_ - 1, p_147767_3_ - 1, p_147767_4_)) + { + tessellator.addVertexWithUV(d9, (double)p_147767_3_ - 0.01D, d18, d5, d7); + tessellator.addVertexWithUV(d10, (double)p_147767_3_ - 0.01D, d18, d5, d8); + tessellator.addVertexWithUV(d10, (double)p_147767_3_ - 0.01D, d17, d4, d8); + tessellator.addVertexWithUV(d9, (double)p_147767_3_ - 0.01D, d17, d4, d7); + tessellator.addVertexWithUV(d10, (double)p_147767_3_ - 0.01D, d18, d5, d7); + tessellator.addVertexWithUV(d9, (double)p_147767_3_ - 0.01D, d18, d5, d8); + tessellator.addVertexWithUV(d9, (double)p_147767_3_ - 0.01D, d17, d4, d8); + tessellator.addVertexWithUV(d10, (double)p_147767_3_ - 0.01D, d17, d4, d7); + } + } + else if (!flag2 && flag3) + { + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 1), d13, d0, d2); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 0), d13, d0, d3); + tessellator.addVertexWithUV(d11, (double)(p_147767_3_ + 0), d13, d1, d3); + tessellator.addVertexWithUV(d11, (double)(p_147767_3_ + 1), d13, d1, d2); + tessellator.addVertexWithUV(d11, (double)(p_147767_3_ + 1), d13, d0, d2); + tessellator.addVertexWithUV(d11, (double)(p_147767_3_ + 0), d13, d0, d3); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 0), d13, d1, d3); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 1), d13, d1, d2); + + if (!flag1 && !flag) + { + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 1), d17, d4, d6); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 0), d17, d4, d8); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 0), d18, d5, d8); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 1), d18, d5, d6); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 1), d18, d4, d6); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 0), d18, d4, d8); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 0), d17, d5, d8); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 1), d17, d5, d6); + } + + if (flag4 || p_147767_3_ < l - 1 && this.blockAccess.isAirBlock(p_147767_2_ + 1, p_147767_3_ + 1, p_147767_4_)) + { + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 1) + 0.01D, d18, d5, d6); + tessellator.addVertexWithUV(d11, (double)(p_147767_3_ + 1) + 0.01D, d18, d5, d7); + tessellator.addVertexWithUV(d11, (double)(p_147767_3_ + 1) + 0.01D, d17, d4, d7); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 1) + 0.01D, d17, d4, d6); + tessellator.addVertexWithUV(d11, (double)(p_147767_3_ + 1) + 0.01D, d18, d5, d6); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 1) + 0.01D, d18, d5, d7); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 1) + 0.01D, d17, d4, d7); + tessellator.addVertexWithUV(d11, (double)(p_147767_3_ + 1) + 0.01D, d17, d4, d6); + } + + if (flag5 || p_147767_3_ > 1 && this.blockAccess.isAirBlock(p_147767_2_ + 1, p_147767_3_ - 1, p_147767_4_)) + { + tessellator.addVertexWithUV(d10, (double)p_147767_3_ - 0.01D, d18, d5, d6); + tessellator.addVertexWithUV(d11, (double)p_147767_3_ - 0.01D, d18, d5, d7); + tessellator.addVertexWithUV(d11, (double)p_147767_3_ - 0.01D, d17, d4, d7); + tessellator.addVertexWithUV(d10, (double)p_147767_3_ - 0.01D, d17, d4, d6); + tessellator.addVertexWithUV(d11, (double)p_147767_3_ - 0.01D, d18, d5, d6); + tessellator.addVertexWithUV(d10, (double)p_147767_3_ - 0.01D, d18, d5, d7); + tessellator.addVertexWithUV(d10, (double)p_147767_3_ - 0.01D, d17, d4, d7); + tessellator.addVertexWithUV(d11, (double)p_147767_3_ - 0.01D, d17, d4, d6); + } + } + } + else + { + tessellator.addVertexWithUV(d9, (double)(p_147767_3_ + 1), d13, d21, d2); + tessellator.addVertexWithUV(d9, (double)(p_147767_3_ + 0), d13, d21, d3); + tessellator.addVertexWithUV(d11, (double)(p_147767_3_ + 0), d13, d1, d3); + tessellator.addVertexWithUV(d11, (double)(p_147767_3_ + 1), d13, d1, d2); + tessellator.addVertexWithUV(d11, (double)(p_147767_3_ + 1), d13, d21, d2); + tessellator.addVertexWithUV(d11, (double)(p_147767_3_ + 0), d13, d21, d3); + tessellator.addVertexWithUV(d9, (double)(p_147767_3_ + 0), d13, d1, d3); + tessellator.addVertexWithUV(d9, (double)(p_147767_3_ + 1), d13, d1, d2); + + if (flag4) + { + tessellator.addVertexWithUV(d9, (double)(p_147767_3_ + 1) + 0.01D, d18, d5, d8); + tessellator.addVertexWithUV(d11, (double)(p_147767_3_ + 1) + 0.01D, d18, d5, d6); + tessellator.addVertexWithUV(d11, (double)(p_147767_3_ + 1) + 0.01D, d17, d4, d6); + tessellator.addVertexWithUV(d9, (double)(p_147767_3_ + 1) + 0.01D, d17, d4, d8); + tessellator.addVertexWithUV(d11, (double)(p_147767_3_ + 1) + 0.01D, d18, d5, d8); + tessellator.addVertexWithUV(d9, (double)(p_147767_3_ + 1) + 0.01D, d18, d5, d6); + tessellator.addVertexWithUV(d9, (double)(p_147767_3_ + 1) + 0.01D, d17, d4, d6); + tessellator.addVertexWithUV(d11, (double)(p_147767_3_ + 1) + 0.01D, d17, d4, d8); + } + else + { + if (p_147767_3_ < l - 1 && this.blockAccess.isAirBlock(p_147767_2_ - 1, p_147767_3_ + 1, p_147767_4_)) + { + tessellator.addVertexWithUV(d9, (double)(p_147767_3_ + 1) + 0.01D, d18, d5, d7); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 1) + 0.01D, d18, d5, d8); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 1) + 0.01D, d17, d4, d8); + tessellator.addVertexWithUV(d9, (double)(p_147767_3_ + 1) + 0.01D, d17, d4, d7); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 1) + 0.01D, d18, d5, d7); + tessellator.addVertexWithUV(d9, (double)(p_147767_3_ + 1) + 0.01D, d18, d5, d8); + tessellator.addVertexWithUV(d9, (double)(p_147767_3_ + 1) + 0.01D, d17, d4, d8); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 1) + 0.01D, d17, d4, d7); + } + + if (p_147767_3_ < l - 1 && this.blockAccess.isAirBlock(p_147767_2_ + 1, p_147767_3_ + 1, p_147767_4_)) + { + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 1) + 0.01D, d18, d5, d6); + tessellator.addVertexWithUV(d11, (double)(p_147767_3_ + 1) + 0.01D, d18, d5, d7); + tessellator.addVertexWithUV(d11, (double)(p_147767_3_ + 1) + 0.01D, d17, d4, d7); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 1) + 0.01D, d17, d4, d6); + tessellator.addVertexWithUV(d11, (double)(p_147767_3_ + 1) + 0.01D, d18, d5, d6); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 1) + 0.01D, d18, d5, d7); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 1) + 0.01D, d17, d4, d7); + tessellator.addVertexWithUV(d11, (double)(p_147767_3_ + 1) + 0.01D, d17, d4, d6); + } + } + + if (flag5) + { + tessellator.addVertexWithUV(d9, (double)p_147767_3_ - 0.01D, d18, d5, d8); + tessellator.addVertexWithUV(d11, (double)p_147767_3_ - 0.01D, d18, d5, d6); + tessellator.addVertexWithUV(d11, (double)p_147767_3_ - 0.01D, d17, d4, d6); + tessellator.addVertexWithUV(d9, (double)p_147767_3_ - 0.01D, d17, d4, d8); + tessellator.addVertexWithUV(d11, (double)p_147767_3_ - 0.01D, d18, d5, d8); + tessellator.addVertexWithUV(d9, (double)p_147767_3_ - 0.01D, d18, d5, d6); + tessellator.addVertexWithUV(d9, (double)p_147767_3_ - 0.01D, d17, d4, d6); + tessellator.addVertexWithUV(d11, (double)p_147767_3_ - 0.01D, d17, d4, d8); + } + else + { + if (p_147767_3_ > 1 && this.blockAccess.isAirBlock(p_147767_2_ - 1, p_147767_3_ - 1, p_147767_4_)) + { + tessellator.addVertexWithUV(d9, (double)p_147767_3_ - 0.01D, d18, d5, d7); + tessellator.addVertexWithUV(d10, (double)p_147767_3_ - 0.01D, d18, d5, d8); + tessellator.addVertexWithUV(d10, (double)p_147767_3_ - 0.01D, d17, d4, d8); + tessellator.addVertexWithUV(d9, (double)p_147767_3_ - 0.01D, d17, d4, d7); + tessellator.addVertexWithUV(d10, (double)p_147767_3_ - 0.01D, d18, d5, d7); + tessellator.addVertexWithUV(d9, (double)p_147767_3_ - 0.01D, d18, d5, d8); + tessellator.addVertexWithUV(d9, (double)p_147767_3_ - 0.01D, d17, d4, d8); + tessellator.addVertexWithUV(d10, (double)p_147767_3_ - 0.01D, d17, d4, d7); + } + + if (p_147767_3_ > 1 && this.blockAccess.isAirBlock(p_147767_2_ + 1, p_147767_3_ - 1, p_147767_4_)) + { + tessellator.addVertexWithUV(d10, (double)p_147767_3_ - 0.01D, d18, d5, d6); + tessellator.addVertexWithUV(d11, (double)p_147767_3_ - 0.01D, d18, d5, d7); + tessellator.addVertexWithUV(d11, (double)p_147767_3_ - 0.01D, d17, d4, d7); + tessellator.addVertexWithUV(d10, (double)p_147767_3_ - 0.01D, d17, d4, d6); + tessellator.addVertexWithUV(d11, (double)p_147767_3_ - 0.01D, d18, d5, d6); + tessellator.addVertexWithUV(d10, (double)p_147767_3_ - 0.01D, d18, d5, d7); + tessellator.addVertexWithUV(d10, (double)p_147767_3_ - 0.01D, d17, d4, d7); + tessellator.addVertexWithUV(d11, (double)p_147767_3_ - 0.01D, d17, d4, d6); + } + } + } + + if ((!flag || !flag1) && (flag2 || flag3 || flag || flag1)) + { + if (flag && !flag1) + { + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 1), d12, d21, d2); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 0), d12, d21, d3); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 0), d13, d0, d3); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 1), d13, d0, d2); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 1), d13, d21, d2); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 0), d13, d21, d3); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 0), d12, d0, d3); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 1), d12, d0, d2); + + if (!flag3 && !flag2) + { + tessellator.addVertexWithUV(d15, (double)(p_147767_3_ + 1), d13, d4, d6); + tessellator.addVertexWithUV(d15, (double)(p_147767_3_ + 0), d13, d4, d8); + tessellator.addVertexWithUV(d16, (double)(p_147767_3_ + 0), d13, d5, d8); + tessellator.addVertexWithUV(d16, (double)(p_147767_3_ + 1), d13, d5, d6); + tessellator.addVertexWithUV(d16, (double)(p_147767_3_ + 1), d13, d4, d6); + tessellator.addVertexWithUV(d16, (double)(p_147767_3_ + 0), d13, d4, d8); + tessellator.addVertexWithUV(d15, (double)(p_147767_3_ + 0), d13, d5, d8); + tessellator.addVertexWithUV(d15, (double)(p_147767_3_ + 1), d13, d5, d6); + } + + if (flag4 || p_147767_3_ < l - 1 && this.blockAccess.isAirBlock(p_147767_2_, p_147767_3_ + 1, p_147767_4_ - 1)) + { + tessellator.addVertexWithUV(d15, (double)(p_147767_3_ + 1) + 0.005D, d12, d5, d6); + tessellator.addVertexWithUV(d15, (double)(p_147767_3_ + 1) + 0.005D, d13, d5, d7); + tessellator.addVertexWithUV(d16, (double)(p_147767_3_ + 1) + 0.005D, d13, d4, d7); + tessellator.addVertexWithUV(d16, (double)(p_147767_3_ + 1) + 0.005D, d12, d4, d6); + tessellator.addVertexWithUV(d15, (double)(p_147767_3_ + 1) + 0.005D, d13, d5, d6); + tessellator.addVertexWithUV(d15, (double)(p_147767_3_ + 1) + 0.005D, d12, d5, d7); + tessellator.addVertexWithUV(d16, (double)(p_147767_3_ + 1) + 0.005D, d12, d4, d7); + tessellator.addVertexWithUV(d16, (double)(p_147767_3_ + 1) + 0.005D, d13, d4, d6); + } + + if (flag5 || p_147767_3_ > 1 && this.blockAccess.isAirBlock(p_147767_2_, p_147767_3_ - 1, p_147767_4_ - 1)) + { + tessellator.addVertexWithUV(d15, (double)p_147767_3_ - 0.005D, d12, d5, d6); + tessellator.addVertexWithUV(d15, (double)p_147767_3_ - 0.005D, d13, d5, d7); + tessellator.addVertexWithUV(d16, (double)p_147767_3_ - 0.005D, d13, d4, d7); + tessellator.addVertexWithUV(d16, (double)p_147767_3_ - 0.005D, d12, d4, d6); + tessellator.addVertexWithUV(d15, (double)p_147767_3_ - 0.005D, d13, d5, d6); + tessellator.addVertexWithUV(d15, (double)p_147767_3_ - 0.005D, d12, d5, d7); + tessellator.addVertexWithUV(d16, (double)p_147767_3_ - 0.005D, d12, d4, d7); + tessellator.addVertexWithUV(d16, (double)p_147767_3_ - 0.005D, d13, d4, d6); + } + } + else if (!flag && flag1) + { + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 1), d13, d0, d2); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 0), d13, d0, d3); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 0), d14, d1, d3); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 1), d14, d1, d2); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 1), d14, d0, d2); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 0), d14, d0, d3); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 0), d13, d1, d3); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 1), d13, d1, d2); + + if (!flag3 && !flag2) + { + tessellator.addVertexWithUV(d16, (double)(p_147767_3_ + 1), d13, d4, d6); + tessellator.addVertexWithUV(d16, (double)(p_147767_3_ + 0), d13, d4, d8); + tessellator.addVertexWithUV(d15, (double)(p_147767_3_ + 0), d13, d5, d8); + tessellator.addVertexWithUV(d15, (double)(p_147767_3_ + 1), d13, d5, d6); + tessellator.addVertexWithUV(d15, (double)(p_147767_3_ + 1), d13, d4, d6); + tessellator.addVertexWithUV(d15, (double)(p_147767_3_ + 0), d13, d4, d8); + tessellator.addVertexWithUV(d16, (double)(p_147767_3_ + 0), d13, d5, d8); + tessellator.addVertexWithUV(d16, (double)(p_147767_3_ + 1), d13, d5, d6); + } + + if (flag4 || p_147767_3_ < l - 1 && this.blockAccess.isAirBlock(p_147767_2_, p_147767_3_ + 1, p_147767_4_ + 1)) + { + tessellator.addVertexWithUV(d15, (double)(p_147767_3_ + 1) + 0.005D, d13, d4, d7); + tessellator.addVertexWithUV(d15, (double)(p_147767_3_ + 1) + 0.005D, d14, d4, d8); + tessellator.addVertexWithUV(d16, (double)(p_147767_3_ + 1) + 0.005D, d14, d5, d8); + tessellator.addVertexWithUV(d16, (double)(p_147767_3_ + 1) + 0.005D, d13, d5, d7); + tessellator.addVertexWithUV(d15, (double)(p_147767_3_ + 1) + 0.005D, d14, d4, d7); + tessellator.addVertexWithUV(d15, (double)(p_147767_3_ + 1) + 0.005D, d13, d4, d8); + tessellator.addVertexWithUV(d16, (double)(p_147767_3_ + 1) + 0.005D, d13, d5, d8); + tessellator.addVertexWithUV(d16, (double)(p_147767_3_ + 1) + 0.005D, d14, d5, d7); + } + + if (flag5 || p_147767_3_ > 1 && this.blockAccess.isAirBlock(p_147767_2_, p_147767_3_ - 1, p_147767_4_ + 1)) + { + tessellator.addVertexWithUV(d15, (double)p_147767_3_ - 0.005D, d13, d4, d7); + tessellator.addVertexWithUV(d15, (double)p_147767_3_ - 0.005D, d14, d4, d8); + tessellator.addVertexWithUV(d16, (double)p_147767_3_ - 0.005D, d14, d5, d8); + tessellator.addVertexWithUV(d16, (double)p_147767_3_ - 0.005D, d13, d5, d7); + tessellator.addVertexWithUV(d15, (double)p_147767_3_ - 0.005D, d14, d4, d7); + tessellator.addVertexWithUV(d15, (double)p_147767_3_ - 0.005D, d13, d4, d8); + tessellator.addVertexWithUV(d16, (double)p_147767_3_ - 0.005D, d13, d5, d8); + tessellator.addVertexWithUV(d16, (double)p_147767_3_ - 0.005D, d14, d5, d7); + } + } + } + else + { + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 1), d14, d21, d2); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 0), d14, d21, d3); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 0), d12, d1, d3); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 1), d12, d1, d2); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 1), d12, d21, d2); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 0), d12, d21, d3); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 0), d14, d1, d3); + tessellator.addVertexWithUV(d10, (double)(p_147767_3_ + 1), d14, d1, d2); + + if (flag4) + { + tessellator.addVertexWithUV(d16, (double)(p_147767_3_ + 1) + 0.005D, d14, d5, d8); + tessellator.addVertexWithUV(d16, (double)(p_147767_3_ + 1) + 0.005D, d12, d5, d6); + tessellator.addVertexWithUV(d15, (double)(p_147767_3_ + 1) + 0.005D, d12, d4, d6); + tessellator.addVertexWithUV(d15, (double)(p_147767_3_ + 1) + 0.005D, d14, d4, d8); + tessellator.addVertexWithUV(d16, (double)(p_147767_3_ + 1) + 0.005D, d12, d5, d8); + tessellator.addVertexWithUV(d16, (double)(p_147767_3_ + 1) + 0.005D, d14, d5, d6); + tessellator.addVertexWithUV(d15, (double)(p_147767_3_ + 1) + 0.005D, d14, d4, d6); + tessellator.addVertexWithUV(d15, (double)(p_147767_3_ + 1) + 0.005D, d12, d4, d8); + } + else + { + if (p_147767_3_ < l - 1 && this.blockAccess.isAirBlock(p_147767_2_, p_147767_3_ + 1, p_147767_4_ - 1)) + { + tessellator.addVertexWithUV(d15, (double)(p_147767_3_ + 1) + 0.005D, d12, d5, d6); + tessellator.addVertexWithUV(d15, (double)(p_147767_3_ + 1) + 0.005D, d13, d5, d7); + tessellator.addVertexWithUV(d16, (double)(p_147767_3_ + 1) + 0.005D, d13, d4, d7); + tessellator.addVertexWithUV(d16, (double)(p_147767_3_ + 1) + 0.005D, d12, d4, d6); + tessellator.addVertexWithUV(d15, (double)(p_147767_3_ + 1) + 0.005D, d13, d5, d6); + tessellator.addVertexWithUV(d15, (double)(p_147767_3_ + 1) + 0.005D, d12, d5, d7); + tessellator.addVertexWithUV(d16, (double)(p_147767_3_ + 1) + 0.005D, d12, d4, d7); + tessellator.addVertexWithUV(d16, (double)(p_147767_3_ + 1) + 0.005D, d13, d4, d6); + } + + if (p_147767_3_ < l - 1 && this.blockAccess.isAirBlock(p_147767_2_, p_147767_3_ + 1, p_147767_4_ + 1)) + { + tessellator.addVertexWithUV(d15, (double)(p_147767_3_ + 1) + 0.005D, d13, d4, d7); + tessellator.addVertexWithUV(d15, (double)(p_147767_3_ + 1) + 0.005D, d14, d4, d8); + tessellator.addVertexWithUV(d16, (double)(p_147767_3_ + 1) + 0.005D, d14, d5, d8); + tessellator.addVertexWithUV(d16, (double)(p_147767_3_ + 1) + 0.005D, d13, d5, d7); + tessellator.addVertexWithUV(d15, (double)(p_147767_3_ + 1) + 0.005D, d14, d4, d7); + tessellator.addVertexWithUV(d15, (double)(p_147767_3_ + 1) + 0.005D, d13, d4, d8); + tessellator.addVertexWithUV(d16, (double)(p_147767_3_ + 1) + 0.005D, d13, d5, d8); + tessellator.addVertexWithUV(d16, (double)(p_147767_3_ + 1) + 0.005D, d14, d5, d7); + } + } + + if (flag5) + { + tessellator.addVertexWithUV(d16, (double)p_147767_3_ - 0.005D, d14, d5, d8); + tessellator.addVertexWithUV(d16, (double)p_147767_3_ - 0.005D, d12, d5, d6); + tessellator.addVertexWithUV(d15, (double)p_147767_3_ - 0.005D, d12, d4, d6); + tessellator.addVertexWithUV(d15, (double)p_147767_3_ - 0.005D, d14, d4, d8); + tessellator.addVertexWithUV(d16, (double)p_147767_3_ - 0.005D, d12, d5, d8); + tessellator.addVertexWithUV(d16, (double)p_147767_3_ - 0.005D, d14, d5, d6); + tessellator.addVertexWithUV(d15, (double)p_147767_3_ - 0.005D, d14, d4, d6); + tessellator.addVertexWithUV(d15, (double)p_147767_3_ - 0.005D, d12, d4, d8); + } + else + { + if (p_147767_3_ > 1 && this.blockAccess.isAirBlock(p_147767_2_, p_147767_3_ - 1, p_147767_4_ - 1)) + { + tessellator.addVertexWithUV(d15, (double)p_147767_3_ - 0.005D, d12, d5, d6); + tessellator.addVertexWithUV(d15, (double)p_147767_3_ - 0.005D, d13, d5, d7); + tessellator.addVertexWithUV(d16, (double)p_147767_3_ - 0.005D, d13, d4, d7); + tessellator.addVertexWithUV(d16, (double)p_147767_3_ - 0.005D, d12, d4, d6); + tessellator.addVertexWithUV(d15, (double)p_147767_3_ - 0.005D, d13, d5, d6); + tessellator.addVertexWithUV(d15, (double)p_147767_3_ - 0.005D, d12, d5, d7); + tessellator.addVertexWithUV(d16, (double)p_147767_3_ - 0.005D, d12, d4, d7); + tessellator.addVertexWithUV(d16, (double)p_147767_3_ - 0.005D, d13, d4, d6); + } + + if (p_147767_3_ > 1 && this.blockAccess.isAirBlock(p_147767_2_, p_147767_3_ - 1, p_147767_4_ + 1)) + { + tessellator.addVertexWithUV(d15, (double)p_147767_3_ - 0.005D, d13, d4, d7); + tessellator.addVertexWithUV(d15, (double)p_147767_3_ - 0.005D, d14, d4, d8); + tessellator.addVertexWithUV(d16, (double)p_147767_3_ - 0.005D, d14, d5, d8); + tessellator.addVertexWithUV(d16, (double)p_147767_3_ - 0.005D, d13, d5, d7); + tessellator.addVertexWithUV(d15, (double)p_147767_3_ - 0.005D, d14, d4, d7); + tessellator.addVertexWithUV(d15, (double)p_147767_3_ - 0.005D, d13, d4, d8); + tessellator.addVertexWithUV(d16, (double)p_147767_3_ - 0.005D, d13, d5, d8); + tessellator.addVertexWithUV(d16, (double)p_147767_3_ - 0.005D, d14, d5, d7); + } + } + } + + return true; + } + + public boolean renderCrossedSquares(Block p_147746_1_, int p_147746_2_, int p_147746_3_, int p_147746_4_) + { + Tessellator tessellator = Tessellator.instance; + tessellator.setBrightness(p_147746_1_.getMixedBrightnessForBlock(this.blockAccess, p_147746_2_, p_147746_3_, p_147746_4_)); + int l = p_147746_1_.colorMultiplier(this.blockAccess, p_147746_2_, p_147746_3_, p_147746_4_); + float f = (float)(l >> 16 & 255) / 255.0F; + float f1 = (float)(l >> 8 & 255) / 255.0F; + float f2 = (float)(l & 255) / 255.0F; + + if (EntityRenderer.anaglyphEnable) + { + float f3 = (f * 30.0F + f1 * 59.0F + f2 * 11.0F) / 100.0F; + float f4 = (f * 30.0F + f1 * 70.0F) / 100.0F; + float f5 = (f * 30.0F + f2 * 70.0F) / 100.0F; + f = f3; + f1 = f4; + f2 = f5; + } + + tessellator.setColorOpaque_F(f, f1, f2); + double d1 = (double)p_147746_2_; + double d2 = (double)p_147746_3_; + double d0 = (double)p_147746_4_; + long i1; + + if (p_147746_1_ == Blocks.tallgrass) + { + i1 = (long)(p_147746_2_ * 3129871) ^ (long)p_147746_4_ * 116129781L ^ (long)p_147746_3_; + i1 = i1 * i1 * 42317861L + i1 * 11L; + d1 += ((double)((float)(i1 >> 16 & 15L) / 15.0F) - 0.5D) * 0.5D; + d2 += ((double)((float)(i1 >> 20 & 15L) / 15.0F) - 1.0D) * 0.2D; + d0 += ((double)((float)(i1 >> 24 & 15L) / 15.0F) - 0.5D) * 0.5D; + } + else if (p_147746_1_ == Blocks.red_flower || p_147746_1_ == Blocks.yellow_flower) + { + i1 = (long)(p_147746_2_ * 3129871) ^ (long)p_147746_4_ * 116129781L ^ (long)p_147746_3_; + i1 = i1 * i1 * 42317861L + i1 * 11L; + d1 += ((double)((float)(i1 >> 16 & 15L) / 15.0F) - 0.5D) * 0.3D; + d0 += ((double)((float)(i1 >> 24 & 15L) / 15.0F) - 0.5D) * 0.3D; + } + + IIcon iicon = this.getBlockIconFromSideAndMetadata(p_147746_1_, 0, this.blockAccess.getBlockMetadata(p_147746_2_, p_147746_3_, p_147746_4_)); + this.drawCrossedSquares(iicon, d1, d2, d0, 1.0F); + return true; + } + + public boolean renderBlockDoublePlant(BlockDoublePlant p_147774_1_, int p_147774_2_, int p_147774_3_, int p_147774_4_) + { + Tessellator tessellator = Tessellator.instance; + tessellator.setBrightness(p_147774_1_.getMixedBrightnessForBlock(this.blockAccess, p_147774_2_, p_147774_3_, p_147774_4_)); + int l = p_147774_1_.colorMultiplier(this.blockAccess, p_147774_2_, p_147774_3_, p_147774_4_); + float f = (float)(l >> 16 & 255) / 255.0F; + float f1 = (float)(l >> 8 & 255) / 255.0F; + float f2 = (float)(l & 255) / 255.0F; + + if (EntityRenderer.anaglyphEnable) + { + float f3 = (f * 30.0F + f1 * 59.0F + f2 * 11.0F) / 100.0F; + float f4 = (f * 30.0F + f1 * 70.0F) / 100.0F; + float f5 = (f * 30.0F + f2 * 70.0F) / 100.0F; + f = f3; + f1 = f4; + f2 = f5; + } + + tessellator.setColorOpaque_F(f, f1, f2); + long j1 = (long)(p_147774_2_ * 3129871) ^ (long)p_147774_4_ * 116129781L; + j1 = j1 * j1 * 42317861L + j1 * 11L; + double d19 = (double)p_147774_2_; + double d0 = (double)p_147774_3_; + double d1 = (double)p_147774_4_; + d19 += ((double)((float)(j1 >> 16 & 15L) / 15.0F) - 0.5D) * 0.3D; + d1 += ((double)((float)(j1 >> 24 & 15L) / 15.0F) - 0.5D) * 0.3D; + int i1 = this.blockAccess.getBlockMetadata(p_147774_2_, p_147774_3_, p_147774_4_); + boolean flag = false; + boolean flag1 = BlockDoublePlant.func_149887_c(i1); + int k1; + + if (flag1) + { + if (this.blockAccess.getBlock(p_147774_2_, p_147774_3_ - 1, p_147774_4_) != p_147774_1_) + { + return false; + } + + k1 = BlockDoublePlant.func_149890_d(this.blockAccess.getBlockMetadata(p_147774_2_, p_147774_3_ - 1, p_147774_4_)); + } + else + { + k1 = BlockDoublePlant.func_149890_d(i1); + } + + IIcon iicon = p_147774_1_.func_149888_a(flag1, k1); + this.drawCrossedSquares(iicon, d19, d0, d1, 1.0F); + + if (flag1 && k1 == 0) + { + IIcon iicon1 = p_147774_1_.sunflowerIcons[0]; + double d2 = Math.cos((double)j1 * 0.8D) * Math.PI * 0.1D; + double d3 = Math.cos(d2); + double d4 = Math.sin(d2); + double d5 = (double)iicon1.getMinU(); + double d6 = (double)iicon1.getMinV(); + double d7 = (double)iicon1.getMaxU(); + double d8 = (double)iicon1.getMaxV(); + double d9 = 0.3D; + double d10 = -0.05D; + double d11 = 0.5D + 0.3D * d3 - 0.5D * d4; + double d12 = 0.5D + 0.5D * d3 + 0.3D * d4; + double d13 = 0.5D + 0.3D * d3 + 0.5D * d4; + double d14 = 0.5D + -0.5D * d3 + 0.3D * d4; + double d15 = 0.5D + -0.05D * d3 + 0.5D * d4; + double d16 = 0.5D + -0.5D * d3 + -0.05D * d4; + double d17 = 0.5D + -0.05D * d3 - 0.5D * d4; + double d18 = 0.5D + 0.5D * d3 + -0.05D * d4; + tessellator.addVertexWithUV(d19 + d15, d0 + 1.0D, d1 + d16, d5, d8); + tessellator.addVertexWithUV(d19 + d17, d0 + 1.0D, d1 + d18, d7, d8); + tessellator.addVertexWithUV(d19 + d11, d0 + 0.0D, d1 + d12, d7, d6); + tessellator.addVertexWithUV(d19 + d13, d0 + 0.0D, d1 + d14, d5, d6); + IIcon iicon2 = p_147774_1_.sunflowerIcons[1]; + d5 = (double)iicon2.getMinU(); + d6 = (double)iicon2.getMinV(); + d7 = (double)iicon2.getMaxU(); + d8 = (double)iicon2.getMaxV(); + tessellator.addVertexWithUV(d19 + d17, d0 + 1.0D, d1 + d18, d5, d8); + tessellator.addVertexWithUV(d19 + d15, d0 + 1.0D, d1 + d16, d7, d8); + tessellator.addVertexWithUV(d19 + d13, d0 + 0.0D, d1 + d14, d7, d6); + tessellator.addVertexWithUV(d19 + d11, d0 + 0.0D, d1 + d12, d5, d6); + } + + return true; + } + + public boolean renderBlockStem(Block p_147724_1_, int p_147724_2_, int p_147724_3_, int p_147724_4_) + { + BlockStem blockstem = (BlockStem)p_147724_1_; + Tessellator tessellator = Tessellator.instance; + tessellator.setBrightness(blockstem.getMixedBrightnessForBlock(this.blockAccess, p_147724_2_, p_147724_3_, p_147724_4_)); + int l = blockstem.colorMultiplier(this.blockAccess, p_147724_2_, p_147724_3_, p_147724_4_); + float f = (float)(l >> 16 & 255) / 255.0F; + float f1 = (float)(l >> 8 & 255) / 255.0F; + float f2 = (float)(l & 255) / 255.0F; + + if (EntityRenderer.anaglyphEnable) + { + float f3 = (f * 30.0F + f1 * 59.0F + f2 * 11.0F) / 100.0F; + float f4 = (f * 30.0F + f1 * 70.0F) / 100.0F; + float f5 = (f * 30.0F + f2 * 70.0F) / 100.0F; + f = f3; + f1 = f4; + f2 = f5; + } + + tessellator.setColorOpaque_F(f, f1, f2); + blockstem.setBlockBoundsBasedOnState(this.blockAccess, p_147724_2_, p_147724_3_, p_147724_4_); + int i1 = blockstem.getState(this.blockAccess, p_147724_2_, p_147724_3_, p_147724_4_); + + if (i1 < 0) + { + this.renderBlockStemSmall(blockstem, this.blockAccess.getBlockMetadata(p_147724_2_, p_147724_3_, p_147724_4_), this.renderMaxY, (double)p_147724_2_, (double)((float)p_147724_3_ - 0.0625F), (double)p_147724_4_); + } + else + { + this.renderBlockStemSmall(blockstem, this.blockAccess.getBlockMetadata(p_147724_2_, p_147724_3_, p_147724_4_), 0.5D, (double)p_147724_2_, (double)((float)p_147724_3_ - 0.0625F), (double)p_147724_4_); + this.renderBlockStemBig(blockstem, this.blockAccess.getBlockMetadata(p_147724_2_, p_147724_3_, p_147724_4_), i1, this.renderMaxY, (double)p_147724_2_, (double)((float)p_147724_3_ - 0.0625F), (double)p_147724_4_); + } + + return true; + } + + public boolean renderBlockCrops(Block p_147796_1_, int p_147796_2_, int p_147796_3_, int p_147796_4_) + { + Tessellator tessellator = Tessellator.instance; + tessellator.setBrightness(p_147796_1_.getMixedBrightnessForBlock(this.blockAccess, p_147796_2_, p_147796_3_, p_147796_4_)); + tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F); + this.renderBlockCropsImpl(p_147796_1_, this.blockAccess.getBlockMetadata(p_147796_2_, p_147796_3_, p_147796_4_), (double)p_147796_2_, (double)((float)p_147796_3_ - 0.0625F), (double)p_147796_4_); + return true; + } + + public void renderTorchAtAngle(Block p_147747_1_, double p_147747_2_, double p_147747_4_, double p_147747_6_, double p_147747_8_, double p_147747_10_, int p_147747_12_) + { + Tessellator tessellator = Tessellator.instance; + IIcon iicon = this.getBlockIconFromSideAndMetadata(p_147747_1_, 0, p_147747_12_); + + if (this.hasOverrideBlockTexture()) + { + iicon = this.overrideBlockTexture; + } + + double d5 = (double)iicon.getMinU(); + double d6 = (double)iicon.getMinV(); + double d7 = (double)iicon.getMaxU(); + double d8 = (double)iicon.getMaxV(); + double d9 = (double)iicon.getInterpolatedU(7.0D); + double d10 = (double)iicon.getInterpolatedV(6.0D); + double d11 = (double)iicon.getInterpolatedU(9.0D); + double d12 = (double)iicon.getInterpolatedV(8.0D); + double d13 = (double)iicon.getInterpolatedU(7.0D); + double d14 = (double)iicon.getInterpolatedV(13.0D); + double d15 = (double)iicon.getInterpolatedU(9.0D); + double d16 = (double)iicon.getInterpolatedV(15.0D); + p_147747_2_ += 0.5D; + p_147747_6_ += 0.5D; + double d17 = p_147747_2_ - 0.5D; + double d18 = p_147747_2_ + 0.5D; + double d19 = p_147747_6_ - 0.5D; + double d20 = p_147747_6_ + 0.5D; + double d21 = 0.0625D; + double d22 = 0.625D; + tessellator.addVertexWithUV(p_147747_2_ + p_147747_8_ * (1.0D - d22) - d21, p_147747_4_ + d22, p_147747_6_ + p_147747_10_ * (1.0D - d22) - d21, d9, d10); + tessellator.addVertexWithUV(p_147747_2_ + p_147747_8_ * (1.0D - d22) - d21, p_147747_4_ + d22, p_147747_6_ + p_147747_10_ * (1.0D - d22) + d21, d9, d12); + tessellator.addVertexWithUV(p_147747_2_ + p_147747_8_ * (1.0D - d22) + d21, p_147747_4_ + d22, p_147747_6_ + p_147747_10_ * (1.0D - d22) + d21, d11, d12); + tessellator.addVertexWithUV(p_147747_2_ + p_147747_8_ * (1.0D - d22) + d21, p_147747_4_ + d22, p_147747_6_ + p_147747_10_ * (1.0D - d22) - d21, d11, d10); + tessellator.addVertexWithUV(p_147747_2_ + d21 + p_147747_8_, p_147747_4_, p_147747_6_ - d21 + p_147747_10_, d15, d14); + tessellator.addVertexWithUV(p_147747_2_ + d21 + p_147747_8_, p_147747_4_, p_147747_6_ + d21 + p_147747_10_, d15, d16); + tessellator.addVertexWithUV(p_147747_2_ - d21 + p_147747_8_, p_147747_4_, p_147747_6_ + d21 + p_147747_10_, d13, d16); + tessellator.addVertexWithUV(p_147747_2_ - d21 + p_147747_8_, p_147747_4_, p_147747_6_ - d21 + p_147747_10_, d13, d14); + tessellator.addVertexWithUV(p_147747_2_ - d21, p_147747_4_ + 1.0D, d19, d5, d6); + tessellator.addVertexWithUV(p_147747_2_ - d21 + p_147747_8_, p_147747_4_ + 0.0D, d19 + p_147747_10_, d5, d8); + tessellator.addVertexWithUV(p_147747_2_ - d21 + p_147747_8_, p_147747_4_ + 0.0D, d20 + p_147747_10_, d7, d8); + tessellator.addVertexWithUV(p_147747_2_ - d21, p_147747_4_ + 1.0D, d20, d7, d6); + tessellator.addVertexWithUV(p_147747_2_ + d21, p_147747_4_ + 1.0D, d20, d5, d6); + tessellator.addVertexWithUV(p_147747_2_ + p_147747_8_ + d21, p_147747_4_ + 0.0D, d20 + p_147747_10_, d5, d8); + tessellator.addVertexWithUV(p_147747_2_ + p_147747_8_ + d21, p_147747_4_ + 0.0D, d19 + p_147747_10_, d7, d8); + tessellator.addVertexWithUV(p_147747_2_ + d21, p_147747_4_ + 1.0D, d19, d7, d6); + tessellator.addVertexWithUV(d17, p_147747_4_ + 1.0D, p_147747_6_ + d21, d5, d6); + tessellator.addVertexWithUV(d17 + p_147747_8_, p_147747_4_ + 0.0D, p_147747_6_ + d21 + p_147747_10_, d5, d8); + tessellator.addVertexWithUV(d18 + p_147747_8_, p_147747_4_ + 0.0D, p_147747_6_ + d21 + p_147747_10_, d7, d8); + tessellator.addVertexWithUV(d18, p_147747_4_ + 1.0D, p_147747_6_ + d21, d7, d6); + tessellator.addVertexWithUV(d18, p_147747_4_ + 1.0D, p_147747_6_ - d21, d5, d6); + tessellator.addVertexWithUV(d18 + p_147747_8_, p_147747_4_ + 0.0D, p_147747_6_ - d21 + p_147747_10_, d5, d8); + tessellator.addVertexWithUV(d17 + p_147747_8_, p_147747_4_ + 0.0D, p_147747_6_ - d21 + p_147747_10_, d7, d8); + tessellator.addVertexWithUV(d17, p_147747_4_ + 1.0D, p_147747_6_ - d21, d7, d6); + } + + public void drawCrossedSquares(IIcon p_147765_1_, double p_147765_2_, double p_147765_4_, double p_147765_6_, float p_147765_8_) + { + Tessellator tessellator = Tessellator.instance; + + if (this.hasOverrideBlockTexture()) + { + p_147765_1_ = this.overrideBlockTexture; + } + + double d3 = (double)p_147765_1_.getMinU(); + double d4 = (double)p_147765_1_.getMinV(); + double d5 = (double)p_147765_1_.getMaxU(); + double d6 = (double)p_147765_1_.getMaxV(); + double d7 = 0.45D * (double)p_147765_8_; + double d8 = p_147765_2_ + 0.5D - d7; + double d9 = p_147765_2_ + 0.5D + d7; + double d10 = p_147765_6_ + 0.5D - d7; + double d11 = p_147765_6_ + 0.5D + d7; + tessellator.addVertexWithUV(d8, p_147765_4_ + (double)p_147765_8_, d10, d3, d4); + tessellator.addVertexWithUV(d8, p_147765_4_ + 0.0D, d10, d3, d6); + tessellator.addVertexWithUV(d9, p_147765_4_ + 0.0D, d11, d5, d6); + tessellator.addVertexWithUV(d9, p_147765_4_ + (double)p_147765_8_, d11, d5, d4); + tessellator.addVertexWithUV(d9, p_147765_4_ + (double)p_147765_8_, d11, d3, d4); + tessellator.addVertexWithUV(d9, p_147765_4_ + 0.0D, d11, d3, d6); + tessellator.addVertexWithUV(d8, p_147765_4_ + 0.0D, d10, d5, d6); + tessellator.addVertexWithUV(d8, p_147765_4_ + (double)p_147765_8_, d10, d5, d4); + tessellator.addVertexWithUV(d8, p_147765_4_ + (double)p_147765_8_, d11, d3, d4); + tessellator.addVertexWithUV(d8, p_147765_4_ + 0.0D, d11, d3, d6); + tessellator.addVertexWithUV(d9, p_147765_4_ + 0.0D, d10, d5, d6); + tessellator.addVertexWithUV(d9, p_147765_4_ + (double)p_147765_8_, d10, d5, d4); + tessellator.addVertexWithUV(d9, p_147765_4_ + (double)p_147765_8_, d10, d3, d4); + tessellator.addVertexWithUV(d9, p_147765_4_ + 0.0D, d10, d3, d6); + tessellator.addVertexWithUV(d8, p_147765_4_ + 0.0D, d11, d5, d6); + tessellator.addVertexWithUV(d8, p_147765_4_ + (double)p_147765_8_, d11, d5, d4); + } + + public void renderBlockStemSmall(Block p_147730_1_, int p_147730_2_, double p_147730_3_, double p_147730_5_, double p_147730_7_, double p_147730_9_) + { + Tessellator tessellator = Tessellator.instance; + IIcon iicon = this.getBlockIconFromSideAndMetadata(p_147730_1_, 0, p_147730_2_); + + if (this.hasOverrideBlockTexture()) + { + iicon = this.overrideBlockTexture; + } + + double d4 = (double)iicon.getMinU(); + double d5 = (double)iicon.getMinV(); + double d6 = (double)iicon.getMaxU(); + double d7 = (double)iicon.getInterpolatedV(p_147730_3_ * 16.0D); + double d8 = p_147730_5_ + 0.5D - 0.44999998807907104D; + double d9 = p_147730_5_ + 0.5D + 0.44999998807907104D; + double d10 = p_147730_9_ + 0.5D - 0.44999998807907104D; + double d11 = p_147730_9_ + 0.5D + 0.44999998807907104D; + tessellator.addVertexWithUV(d8, p_147730_7_ + p_147730_3_, d10, d4, d5); + tessellator.addVertexWithUV(d8, p_147730_7_ + 0.0D, d10, d4, d7); + tessellator.addVertexWithUV(d9, p_147730_7_ + 0.0D, d11, d6, d7); + tessellator.addVertexWithUV(d9, p_147730_7_ + p_147730_3_, d11, d6, d5); + tessellator.addVertexWithUV(d9, p_147730_7_ + p_147730_3_, d11, d6, d5); + tessellator.addVertexWithUV(d9, p_147730_7_ + 0.0D, d11, d6, d7); + tessellator.addVertexWithUV(d8, p_147730_7_ + 0.0D, d10, d4, d7); + tessellator.addVertexWithUV(d8, p_147730_7_ + p_147730_3_, d10, d4, d5); + tessellator.addVertexWithUV(d8, p_147730_7_ + p_147730_3_, d11, d4, d5); + tessellator.addVertexWithUV(d8, p_147730_7_ + 0.0D, d11, d4, d7); + tessellator.addVertexWithUV(d9, p_147730_7_ + 0.0D, d10, d6, d7); + tessellator.addVertexWithUV(d9, p_147730_7_ + p_147730_3_, d10, d6, d5); + tessellator.addVertexWithUV(d9, p_147730_7_ + p_147730_3_, d10, d6, d5); + tessellator.addVertexWithUV(d9, p_147730_7_ + 0.0D, d10, d6, d7); + tessellator.addVertexWithUV(d8, p_147730_7_ + 0.0D, d11, d4, d7); + tessellator.addVertexWithUV(d8, p_147730_7_ + p_147730_3_, d11, d4, d5); + } + + public boolean renderBlockLilyPad(Block p_147783_1_, int p_147783_2_, int p_147783_3_, int p_147783_4_) + { + Tessellator tessellator = Tessellator.instance; + IIcon iicon = this.getBlockIconFromSide(p_147783_1_, 1); + + if (this.hasOverrideBlockTexture()) + { + iicon = this.overrideBlockTexture; + } + + float f = 0.015625F; + double d0 = (double)iicon.getMinU(); + double d1 = (double)iicon.getMinV(); + double d2 = (double)iicon.getMaxU(); + double d3 = (double)iicon.getMaxV(); + long l = (long)(p_147783_2_ * 3129871) ^ (long)p_147783_4_ * 116129781L ^ (long)p_147783_3_; + l = l * l * 42317861L + l * 11L; + int i1 = (int)(l >> 16 & 3L); + tessellator.setBrightness(p_147783_1_.getMixedBrightnessForBlock(this.blockAccess, p_147783_2_, p_147783_3_, p_147783_4_)); + float f1 = (float)p_147783_2_ + 0.5F; + float f2 = (float)p_147783_4_ + 0.5F; + float f3 = (float)(i1 & 1) * 0.5F * (float)(1 - i1 / 2 % 2 * 2); + float f4 = (float)(i1 + 1 & 1) * 0.5F * (float)(1 - (i1 + 1) / 2 % 2 * 2); + tessellator.setColorOpaque_I(p_147783_1_.getBlockColor()); + tessellator.addVertexWithUV((double)(f1 + f3 - f4), (double)((float)p_147783_3_ + f), (double)(f2 + f3 + f4), d0, d1); + tessellator.addVertexWithUV((double)(f1 + f3 + f4), (double)((float)p_147783_3_ + f), (double)(f2 - f3 + f4), d2, d1); + tessellator.addVertexWithUV((double)(f1 - f3 + f4), (double)((float)p_147783_3_ + f), (double)(f2 - f3 - f4), d2, d3); + tessellator.addVertexWithUV((double)(f1 - f3 - f4), (double)((float)p_147783_3_ + f), (double)(f2 + f3 - f4), d0, d3); + tessellator.setColorOpaque_I((p_147783_1_.getBlockColor() & 16711422) >> 1); + tessellator.addVertexWithUV((double)(f1 - f3 - f4), (double)((float)p_147783_3_ + f), (double)(f2 + f3 - f4), d0, d3); + tessellator.addVertexWithUV((double)(f1 - f3 + f4), (double)((float)p_147783_3_ + f), (double)(f2 - f3 - f4), d2, d3); + tessellator.addVertexWithUV((double)(f1 + f3 + f4), (double)((float)p_147783_3_ + f), (double)(f2 - f3 + f4), d2, d1); + tessellator.addVertexWithUV((double)(f1 + f3 - f4), (double)((float)p_147783_3_ + f), (double)(f2 + f3 + f4), d0, d1); + return true; + } + + public void renderBlockStemBig(BlockStem p_147740_1_, int p_147740_2_, int p_147740_3_, double p_147740_4_, double p_147740_6_, double p_147740_8_, double p_147740_10_) + { + Tessellator tessellator = Tessellator.instance; + IIcon iicon = p_147740_1_.getStemIcon(); + + if (this.hasOverrideBlockTexture()) + { + iicon = this.overrideBlockTexture; + } + + double d4 = (double)iicon.getMinU(); + double d5 = (double)iicon.getMinV(); + double d6 = (double)iicon.getMaxU(); + double d7 = (double)iicon.getMaxV(); + double d8 = p_147740_6_ + 0.5D - 0.5D; + double d9 = p_147740_6_ + 0.5D + 0.5D; + double d10 = p_147740_10_ + 0.5D - 0.5D; + double d11 = p_147740_10_ + 0.5D + 0.5D; + double d12 = p_147740_6_ + 0.5D; + double d13 = p_147740_10_ + 0.5D; + + if ((p_147740_3_ + 1) / 2 % 2 == 1) + { + double d14 = d6; + d6 = d4; + d4 = d14; + } + + if (p_147740_3_ < 2) + { + tessellator.addVertexWithUV(d8, p_147740_8_ + p_147740_4_, d13, d4, d5); + tessellator.addVertexWithUV(d8, p_147740_8_ + 0.0D, d13, d4, d7); + tessellator.addVertexWithUV(d9, p_147740_8_ + 0.0D, d13, d6, d7); + tessellator.addVertexWithUV(d9, p_147740_8_ + p_147740_4_, d13, d6, d5); + tessellator.addVertexWithUV(d9, p_147740_8_ + p_147740_4_, d13, d6, d5); + tessellator.addVertexWithUV(d9, p_147740_8_ + 0.0D, d13, d6, d7); + tessellator.addVertexWithUV(d8, p_147740_8_ + 0.0D, d13, d4, d7); + tessellator.addVertexWithUV(d8, p_147740_8_ + p_147740_4_, d13, d4, d5); + } + else + { + tessellator.addVertexWithUV(d12, p_147740_8_ + p_147740_4_, d11, d4, d5); + tessellator.addVertexWithUV(d12, p_147740_8_ + 0.0D, d11, d4, d7); + tessellator.addVertexWithUV(d12, p_147740_8_ + 0.0D, d10, d6, d7); + tessellator.addVertexWithUV(d12, p_147740_8_ + p_147740_4_, d10, d6, d5); + tessellator.addVertexWithUV(d12, p_147740_8_ + p_147740_4_, d10, d6, d5); + tessellator.addVertexWithUV(d12, p_147740_8_ + 0.0D, d10, d6, d7); + tessellator.addVertexWithUV(d12, p_147740_8_ + 0.0D, d11, d4, d7); + tessellator.addVertexWithUV(d12, p_147740_8_ + p_147740_4_, d11, d4, d5); + } + } + + public void renderBlockCropsImpl(Block p_147795_1_, int p_147795_2_, double p_147795_3_, double p_147795_5_, double p_147795_7_) + { + Tessellator tessellator = Tessellator.instance; + IIcon iicon = this.getBlockIconFromSideAndMetadata(p_147795_1_, 0, p_147795_2_); + + if (this.hasOverrideBlockTexture()) + { + iicon = this.overrideBlockTexture; + } + + double d3 = (double)iicon.getMinU(); + double d4 = (double)iicon.getMinV(); + double d5 = (double)iicon.getMaxU(); + double d6 = (double)iicon.getMaxV(); + double d7 = p_147795_3_ + 0.5D - 0.25D; + double d8 = p_147795_3_ + 0.5D + 0.25D; + double d9 = p_147795_7_ + 0.5D - 0.5D; + double d10 = p_147795_7_ + 0.5D + 0.5D; + tessellator.addVertexWithUV(d7, p_147795_5_ + 1.0D, d9, d3, d4); + tessellator.addVertexWithUV(d7, p_147795_5_ + 0.0D, d9, d3, d6); + tessellator.addVertexWithUV(d7, p_147795_5_ + 0.0D, d10, d5, d6); + tessellator.addVertexWithUV(d7, p_147795_5_ + 1.0D, d10, d5, d4); + tessellator.addVertexWithUV(d7, p_147795_5_ + 1.0D, d10, d3, d4); + tessellator.addVertexWithUV(d7, p_147795_5_ + 0.0D, d10, d3, d6); + tessellator.addVertexWithUV(d7, p_147795_5_ + 0.0D, d9, d5, d6); + tessellator.addVertexWithUV(d7, p_147795_5_ + 1.0D, d9, d5, d4); + tessellator.addVertexWithUV(d8, p_147795_5_ + 1.0D, d10, d3, d4); + tessellator.addVertexWithUV(d8, p_147795_5_ + 0.0D, d10, d3, d6); + tessellator.addVertexWithUV(d8, p_147795_5_ + 0.0D, d9, d5, d6); + tessellator.addVertexWithUV(d8, p_147795_5_ + 1.0D, d9, d5, d4); + tessellator.addVertexWithUV(d8, p_147795_5_ + 1.0D, d9, d3, d4); + tessellator.addVertexWithUV(d8, p_147795_5_ + 0.0D, d9, d3, d6); + tessellator.addVertexWithUV(d8, p_147795_5_ + 0.0D, d10, d5, d6); + tessellator.addVertexWithUV(d8, p_147795_5_ + 1.0D, d10, d5, d4); + d7 = p_147795_3_ + 0.5D - 0.5D; + d8 = p_147795_3_ + 0.5D + 0.5D; + d9 = p_147795_7_ + 0.5D - 0.25D; + d10 = p_147795_7_ + 0.5D + 0.25D; + tessellator.addVertexWithUV(d7, p_147795_5_ + 1.0D, d9, d3, d4); + tessellator.addVertexWithUV(d7, p_147795_5_ + 0.0D, d9, d3, d6); + tessellator.addVertexWithUV(d8, p_147795_5_ + 0.0D, d9, d5, d6); + tessellator.addVertexWithUV(d8, p_147795_5_ + 1.0D, d9, d5, d4); + tessellator.addVertexWithUV(d8, p_147795_5_ + 1.0D, d9, d3, d4); + tessellator.addVertexWithUV(d8, p_147795_5_ + 0.0D, d9, d3, d6); + tessellator.addVertexWithUV(d7, p_147795_5_ + 0.0D, d9, d5, d6); + tessellator.addVertexWithUV(d7, p_147795_5_ + 1.0D, d9, d5, d4); + tessellator.addVertexWithUV(d8, p_147795_5_ + 1.0D, d10, d3, d4); + tessellator.addVertexWithUV(d8, p_147795_5_ + 0.0D, d10, d3, d6); + tessellator.addVertexWithUV(d7, p_147795_5_ + 0.0D, d10, d5, d6); + tessellator.addVertexWithUV(d7, p_147795_5_ + 1.0D, d10, d5, d4); + tessellator.addVertexWithUV(d7, p_147795_5_ + 1.0D, d10, d3, d4); + tessellator.addVertexWithUV(d7, p_147795_5_ + 0.0D, d10, d3, d6); + tessellator.addVertexWithUV(d8, p_147795_5_ + 0.0D, d10, d5, d6); + tessellator.addVertexWithUV(d8, p_147795_5_ + 1.0D, d10, d5, d4); + } + + public boolean renderBlockLiquid(Block p_147721_1_, int p_147721_2_, int p_147721_3_, int p_147721_4_) + { + Tessellator tessellator = Tessellator.instance; + int l = p_147721_1_.colorMultiplier(this.blockAccess, p_147721_2_, p_147721_3_, p_147721_4_); + float f = (float)(l >> 16 & 255) / 255.0F; + float f1 = (float)(l >> 8 & 255) / 255.0F; + float f2 = (float)(l & 255) / 255.0F; + boolean flag = p_147721_1_.shouldSideBeRendered(this.blockAccess, p_147721_2_, p_147721_3_ + 1, p_147721_4_, 1); + boolean flag1 = p_147721_1_.shouldSideBeRendered(this.blockAccess, p_147721_2_, p_147721_3_ - 1, p_147721_4_, 0); + boolean[] aboolean = new boolean[] {p_147721_1_.shouldSideBeRendered(this.blockAccess, p_147721_2_, p_147721_3_, p_147721_4_ - 1, 2), p_147721_1_.shouldSideBeRendered(this.blockAccess, p_147721_2_, p_147721_3_, p_147721_4_ + 1, 3), p_147721_1_.shouldSideBeRendered(this.blockAccess, p_147721_2_ - 1, p_147721_3_, p_147721_4_, 4), p_147721_1_.shouldSideBeRendered(this.blockAccess, p_147721_2_ + 1, p_147721_3_, p_147721_4_, 5)}; + + if (!flag && !flag1 && !aboolean[0] && !aboolean[1] && !aboolean[2] && !aboolean[3]) + { + return false; + } + else + { + boolean flag2 = false; + float f3 = 0.5F; + float f4 = 1.0F; + float f5 = 0.8F; + float f6 = 0.6F; + double d0 = 0.0D; + double d1 = 1.0D; + Material material = p_147721_1_.getMaterial(); + int i1 = this.blockAccess.getBlockMetadata(p_147721_2_, p_147721_3_, p_147721_4_); + double d2 = (double)this.getLiquidHeight(p_147721_2_, p_147721_3_, p_147721_4_, material); + double d3 = (double)this.getLiquidHeight(p_147721_2_, p_147721_3_, p_147721_4_ + 1, material); + double d4 = (double)this.getLiquidHeight(p_147721_2_ + 1, p_147721_3_, p_147721_4_ + 1, material); + double d5 = (double)this.getLiquidHeight(p_147721_2_ + 1, p_147721_3_, p_147721_4_, material); + double d6 = 0.0010000000474974513D; + float f9; + float f10; + float f11; + + if (this.renderAllFaces || flag) + { + flag2 = true; + IIcon iicon = this.getBlockIconFromSideAndMetadata(p_147721_1_, 1, i1); + float f7 = (float)BlockLiquid.getFlowDirection(this.blockAccess, p_147721_2_, p_147721_3_, p_147721_4_, material); + + if (f7 > -999.0F) + { + iicon = this.getBlockIconFromSideAndMetadata(p_147721_1_, 2, i1); + } + + d2 -= d6; + d3 -= d6; + d4 -= d6; + d5 -= d6; + double d7; + double d8; + double d10; + double d12; + double d14; + double d16; + double d18; + double d20; + + if (f7 < -999.0F) + { + d7 = (double)iicon.getInterpolatedU(0.0D); + d14 = (double)iicon.getInterpolatedV(0.0D); + d8 = d7; + d16 = (double)iicon.getInterpolatedV(16.0D); + d10 = (double)iicon.getInterpolatedU(16.0D); + d18 = d16; + d12 = d10; + d20 = d14; + } + else + { + f9 = MathHelper.sin(f7) * 0.25F; + f10 = MathHelper.cos(f7) * 0.25F; + f11 = 8.0F; + d7 = (double)iicon.getInterpolatedU((double)(8.0F + (-f10 - f9) * 16.0F)); + d14 = (double)iicon.getInterpolatedV((double)(8.0F + (-f10 + f9) * 16.0F)); + d8 = (double)iicon.getInterpolatedU((double)(8.0F + (-f10 + f9) * 16.0F)); + d16 = (double)iicon.getInterpolatedV((double)(8.0F + (f10 + f9) * 16.0F)); + d10 = (double)iicon.getInterpolatedU((double)(8.0F + (f10 + f9) * 16.0F)); + d18 = (double)iicon.getInterpolatedV((double)(8.0F + (f10 - f9) * 16.0F)); + d12 = (double)iicon.getInterpolatedU((double)(8.0F + (f10 - f9) * 16.0F)); + d20 = (double)iicon.getInterpolatedV((double)(8.0F + (-f10 - f9) * 16.0F)); + } + + tessellator.setBrightness(p_147721_1_.getMixedBrightnessForBlock(this.blockAccess, p_147721_2_, p_147721_3_, p_147721_4_)); + tessellator.setColorOpaque_F(f4 * f, f4 * f1, f4 * f2); + tessellator.addVertexWithUV((double)(p_147721_2_ + 0), (double)p_147721_3_ + d2, (double)(p_147721_4_ + 0), d7, d14); + tessellator.addVertexWithUV((double)(p_147721_2_ + 0), (double)p_147721_3_ + d3, (double)(p_147721_4_ + 1), d8, d16); + tessellator.addVertexWithUV((double)(p_147721_2_ + 1), (double)p_147721_3_ + d4, (double)(p_147721_4_ + 1), d10, d18); + tessellator.addVertexWithUV((double)(p_147721_2_ + 1), (double)p_147721_3_ + d5, (double)(p_147721_4_ + 0), d12, d20); + } + + if (this.renderAllFaces || flag1) + { + tessellator.setBrightness(p_147721_1_.getMixedBrightnessForBlock(this.blockAccess, p_147721_2_, p_147721_3_ - 1, p_147721_4_)); + tessellator.setColorOpaque_F(f3, f3, f3); + this.renderFaceYNeg(p_147721_1_, (double)p_147721_2_, (double)p_147721_3_ + d6, (double)p_147721_4_, this.getBlockIconFromSide(p_147721_1_, 0)); + flag2 = true; + } + + for (int k1 = 0; k1 < 4; ++k1) + { + int l1 = p_147721_2_; + int j1 = p_147721_4_; + + if (k1 == 0) + { + j1 = p_147721_4_ - 1; + } + + if (k1 == 1) + { + ++j1; + } + + if (k1 == 2) + { + l1 = p_147721_2_ - 1; + } + + if (k1 == 3) + { + ++l1; + } + + IIcon iicon1 = this.getBlockIconFromSideAndMetadata(p_147721_1_, k1 + 2, i1); + + if (this.renderAllFaces || aboolean[k1]) + { + double d9; + double d11; + double d13; + double d15; + double d17; + double d19; + + if (k1 == 0) + { + d9 = d2; + d11 = d5; + d13 = (double)p_147721_2_; + d17 = (double)(p_147721_2_ + 1); + d15 = (double)p_147721_4_ + d6; + d19 = (double)p_147721_4_ + d6; + } + else if (k1 == 1) + { + d9 = d4; + d11 = d3; + d13 = (double)(p_147721_2_ + 1); + d17 = (double)p_147721_2_; + d15 = (double)(p_147721_4_ + 1) - d6; + d19 = (double)(p_147721_4_ + 1) - d6; + } + else if (k1 == 2) + { + d9 = d3; + d11 = d2; + d13 = (double)p_147721_2_ + d6; + d17 = (double)p_147721_2_ + d6; + d15 = (double)(p_147721_4_ + 1); + d19 = (double)p_147721_4_; + } + else + { + d9 = d5; + d11 = d4; + d13 = (double)(p_147721_2_ + 1) - d6; + d17 = (double)(p_147721_2_ + 1) - d6; + d15 = (double)p_147721_4_; + d19 = (double)(p_147721_4_ + 1); + } + + flag2 = true; + float f8 = iicon1.getInterpolatedU(0.0D); + f9 = iicon1.getInterpolatedU(8.0D); + f10 = iicon1.getInterpolatedV((1.0D - d9) * 16.0D * 0.5D); + f11 = iicon1.getInterpolatedV((1.0D - d11) * 16.0D * 0.5D); + float f12 = iicon1.getInterpolatedV(8.0D); + tessellator.setBrightness(p_147721_1_.getMixedBrightnessForBlock(this.blockAccess, l1, p_147721_3_, j1)); + float f13 = 1.0F; + f13 *= k1 < 2 ? f5 : f6; + tessellator.setColorOpaque_F(f4 * f13 * f, f4 * f13 * f1, f4 * f13 * f2); + tessellator.addVertexWithUV(d13, (double)p_147721_3_ + d9, d15, (double)f8, (double)f10); + tessellator.addVertexWithUV(d17, (double)p_147721_3_ + d11, d19, (double)f9, (double)f11); + tessellator.addVertexWithUV(d17, (double)(p_147721_3_ + 0), d19, (double)f9, (double)f12); + tessellator.addVertexWithUV(d13, (double)(p_147721_3_ + 0), d15, (double)f8, (double)f12); + } + } + + this.renderMinY = d0; + this.renderMaxY = d1; + return flag2; + } + } + + public float getLiquidHeight(int p_147729_1_, int p_147729_2_, int p_147729_3_, Material p_147729_4_) + { + int l = 0; + float f = 0.0F; + + for (int i1 = 0; i1 < 4; ++i1) + { + int j1 = p_147729_1_ - (i1 & 1); + int k1 = p_147729_3_ - (i1 >> 1 & 1); + + if (this.blockAccess.getBlock(j1, p_147729_2_ + 1, k1).getMaterial() == p_147729_4_) + { + return 1.0F; + } + + Material material1 = this.blockAccess.getBlock(j1, p_147729_2_, k1).getMaterial(); + + if (material1 == p_147729_4_) + { + int l1 = this.blockAccess.getBlockMetadata(j1, p_147729_2_, k1); + + if (l1 >= 8 || l1 == 0) + { + f += BlockLiquid.getLiquidHeightPercent(l1) * 10.0F; + l += 10; + } + + f += BlockLiquid.getLiquidHeightPercent(l1); + ++l; + } + else if (!material1.isSolid()) + { + ++f; + ++l; + } + } + + return 1.0F - f / (float)l; + } + + public void renderBlockSandFalling(Block p_147749_1_, World p_147749_2_, int p_147749_3_, int p_147749_4_, int p_147749_5_, int p_147749_6_) + { + float f = 0.5F; + float f1 = 1.0F; + float f2 = 0.8F; + float f3 = 0.6F; + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.setBrightness(p_147749_1_.getMixedBrightnessForBlock(p_147749_2_, p_147749_3_, p_147749_4_, p_147749_5_)); + tessellator.setColorOpaque_F(f, f, f); + this.renderFaceYNeg(p_147749_1_, -0.5D, -0.5D, -0.5D, this.getBlockIconFromSideAndMetadata(p_147749_1_, 0, p_147749_6_)); + tessellator.setColorOpaque_F(f1, f1, f1); + this.renderFaceYPos(p_147749_1_, -0.5D, -0.5D, -0.5D, this.getBlockIconFromSideAndMetadata(p_147749_1_, 1, p_147749_6_)); + tessellator.setColorOpaque_F(f2, f2, f2); + this.renderFaceZNeg(p_147749_1_, -0.5D, -0.5D, -0.5D, this.getBlockIconFromSideAndMetadata(p_147749_1_, 2, p_147749_6_)); + tessellator.setColorOpaque_F(f2, f2, f2); + this.renderFaceZPos(p_147749_1_, -0.5D, -0.5D, -0.5D, this.getBlockIconFromSideAndMetadata(p_147749_1_, 3, p_147749_6_)); + tessellator.setColorOpaque_F(f3, f3, f3); + this.renderFaceXNeg(p_147749_1_, -0.5D, -0.5D, -0.5D, this.getBlockIconFromSideAndMetadata(p_147749_1_, 4, p_147749_6_)); + tessellator.setColorOpaque_F(f3, f3, f3); + this.renderFaceXPos(p_147749_1_, -0.5D, -0.5D, -0.5D, this.getBlockIconFromSideAndMetadata(p_147749_1_, 5, p_147749_6_)); + tessellator.draw(); + } + + public boolean renderStandardBlock(Block p_147784_1_, int p_147784_2_, int p_147784_3_, int p_147784_4_) + { + int l = p_147784_1_.colorMultiplier(this.blockAccess, p_147784_2_, p_147784_3_, p_147784_4_); + float f = (float)(l >> 16 & 255) / 255.0F; + float f1 = (float)(l >> 8 & 255) / 255.0F; + float f2 = (float)(l & 255) / 255.0F; + + if (EntityRenderer.anaglyphEnable) + { + float f3 = (f * 30.0F + f1 * 59.0F + f2 * 11.0F) / 100.0F; + float f4 = (f * 30.0F + f1 * 70.0F) / 100.0F; + float f5 = (f * 30.0F + f2 * 70.0F) / 100.0F; + f = f3; + f1 = f4; + f2 = f5; + } + + return Minecraft.isAmbientOcclusionEnabled() && p_147784_1_.getLightValue() == 0 ? (this.partialRenderBounds ? this.renderStandardBlockWithAmbientOcclusionPartial(p_147784_1_, p_147784_2_, p_147784_3_, p_147784_4_, f, f1, f2) : this.renderStandardBlockWithAmbientOcclusion(p_147784_1_, p_147784_2_, p_147784_3_, p_147784_4_, f, f1, f2)) : this.renderStandardBlockWithColorMultiplier(p_147784_1_, p_147784_2_, p_147784_3_, p_147784_4_, f, f1, f2); + } + + public boolean renderBlockLog(Block p_147742_1_, int p_147742_2_, int p_147742_3_, int p_147742_4_) + { + int l = this.blockAccess.getBlockMetadata(p_147742_2_, p_147742_3_, p_147742_4_); + int i1 = l & 12; + + if (i1 == 4) + { + this.uvRotateEast = 1; + this.uvRotateWest = 1; + this.uvRotateTop = 1; + this.uvRotateBottom = 1; + } + else if (i1 == 8) + { + this.uvRotateSouth = 1; + this.uvRotateNorth = 1; + } + + boolean flag = this.renderStandardBlock(p_147742_1_, p_147742_2_, p_147742_3_, p_147742_4_); + this.uvRotateSouth = 0; + this.uvRotateEast = 0; + this.uvRotateWest = 0; + this.uvRotateNorth = 0; + this.uvRotateTop = 0; + this.uvRotateBottom = 0; + return flag; + } + + public boolean renderBlockQuartz(Block p_147779_1_, int p_147779_2_, int p_147779_3_, int p_147779_4_) + { + int l = this.blockAccess.getBlockMetadata(p_147779_2_, p_147779_3_, p_147779_4_); + + if (l == 3) + { + this.uvRotateEast = 1; + this.uvRotateWest = 1; + this.uvRotateTop = 1; + this.uvRotateBottom = 1; + } + else if (l == 4) + { + this.uvRotateSouth = 1; + this.uvRotateNorth = 1; + } + + boolean flag = this.renderStandardBlock(p_147779_1_, p_147779_2_, p_147779_3_, p_147779_4_); + this.uvRotateSouth = 0; + this.uvRotateEast = 0; + this.uvRotateWest = 0; + this.uvRotateNorth = 0; + this.uvRotateTop = 0; + this.uvRotateBottom = 0; + return flag; + } + + public boolean renderStandardBlockWithAmbientOcclusion(Block p_147751_1_, int p_147751_2_, int p_147751_3_, int p_147751_4_, float p_147751_5_, float p_147751_6_, float p_147751_7_) + { + this.enableAO = true; + boolean flag = false; + float f3 = 0.0F; + float f4 = 0.0F; + float f5 = 0.0F; + float f6 = 0.0F; + boolean flag1 = true; + int l = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_, p_147751_3_, p_147751_4_); + Tessellator tessellator = Tessellator.instance; + tessellator.setBrightness(983055); + + if (this.getBlockIcon(p_147751_1_).getIconName().equals("grass_top")) + { + flag1 = false; + } + else if (this.hasOverrideBlockTexture()) + { + flag1 = false; + } + + boolean flag2; + boolean flag3; + boolean flag4; + boolean flag5; + int i1; + float f7; + + if (this.renderAllFaces || p_147751_1_.shouldSideBeRendered(this.blockAccess, p_147751_2_, p_147751_3_ - 1, p_147751_4_, 0)) + { + if (this.renderMinY <= 0.0D) + { + --p_147751_3_; + } + + this.aoBrightnessXYNN = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_ - 1, p_147751_3_, p_147751_4_); + this.aoBrightnessYZNN = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_, p_147751_3_, p_147751_4_ - 1); + this.aoBrightnessYZNP = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_, p_147751_3_, p_147751_4_ + 1); + this.aoBrightnessXYPN = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_ + 1, p_147751_3_, p_147751_4_); + this.aoLightValueScratchXYNN = this.blockAccess.getBlock(p_147751_2_ - 1, p_147751_3_, p_147751_4_).getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZNN = this.blockAccess.getBlock(p_147751_2_, p_147751_3_, p_147751_4_ - 1).getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZNP = this.blockAccess.getBlock(p_147751_2_, p_147751_3_, p_147751_4_ + 1).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXYPN = this.blockAccess.getBlock(p_147751_2_ + 1, p_147751_3_, p_147751_4_).getAmbientOcclusionLightValue(); + flag2 = this.blockAccess.getBlock(p_147751_2_ + 1, p_147751_3_ - 1, p_147751_4_).getCanBlockGrass(); + flag3 = this.blockAccess.getBlock(p_147751_2_ - 1, p_147751_3_ - 1, p_147751_4_).getCanBlockGrass(); + flag4 = this.blockAccess.getBlock(p_147751_2_, p_147751_3_ - 1, p_147751_4_ + 1).getCanBlockGrass(); + flag5 = this.blockAccess.getBlock(p_147751_2_, p_147751_3_ - 1, p_147751_4_ - 1).getCanBlockGrass(); + + if (!flag5 && !flag3) + { + this.aoLightValueScratchXYZNNN = this.aoLightValueScratchXYNN; + this.aoBrightnessXYZNNN = this.aoBrightnessXYNN; + } + else + { + this.aoLightValueScratchXYZNNN = this.blockAccess.getBlock(p_147751_2_ - 1, p_147751_3_, p_147751_4_ - 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNNN = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_ - 1, p_147751_3_, p_147751_4_ - 1); + } + + if (!flag4 && !flag3) + { + this.aoLightValueScratchXYZNNP = this.aoLightValueScratchXYNN; + this.aoBrightnessXYZNNP = this.aoBrightnessXYNN; + } + else + { + this.aoLightValueScratchXYZNNP = this.blockAccess.getBlock(p_147751_2_ - 1, p_147751_3_, p_147751_4_ + 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNNP = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_ - 1, p_147751_3_, p_147751_4_ + 1); + } + + if (!flag5 && !flag2) + { + this.aoLightValueScratchXYZPNN = this.aoLightValueScratchXYPN; + this.aoBrightnessXYZPNN = this.aoBrightnessXYPN; + } + else + { + this.aoLightValueScratchXYZPNN = this.blockAccess.getBlock(p_147751_2_ + 1, p_147751_3_, p_147751_4_ - 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPNN = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_ + 1, p_147751_3_, p_147751_4_ - 1); + } + + if (!flag4 && !flag2) + { + this.aoLightValueScratchXYZPNP = this.aoLightValueScratchXYPN; + this.aoBrightnessXYZPNP = this.aoBrightnessXYPN; + } + else + { + this.aoLightValueScratchXYZPNP = this.blockAccess.getBlock(p_147751_2_ + 1, p_147751_3_, p_147751_4_ + 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPNP = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_ + 1, p_147751_3_, p_147751_4_ + 1); + } + + if (this.renderMinY <= 0.0D) + { + ++p_147751_3_; + } + + i1 = l; + + if (this.renderMinY <= 0.0D || !this.blockAccess.getBlock(p_147751_2_, p_147751_3_ - 1, p_147751_4_).isOpaqueCube()) + { + i1 = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_, p_147751_3_ - 1, p_147751_4_); + } + + f7 = this.blockAccess.getBlock(p_147751_2_, p_147751_3_ - 1, p_147751_4_).getAmbientOcclusionLightValue(); + f3 = (this.aoLightValueScratchXYZNNP + this.aoLightValueScratchXYNN + this.aoLightValueScratchYZNP + f7) / 4.0F; + f6 = (this.aoLightValueScratchYZNP + f7 + this.aoLightValueScratchXYZPNP + this.aoLightValueScratchXYPN) / 4.0F; + f5 = (f7 + this.aoLightValueScratchYZNN + this.aoLightValueScratchXYPN + this.aoLightValueScratchXYZPNN) / 4.0F; + f4 = (this.aoLightValueScratchXYNN + this.aoLightValueScratchXYZNNN + f7 + this.aoLightValueScratchYZNN) / 4.0F; + this.brightnessTopLeft = this.getAoBrightness(this.aoBrightnessXYZNNP, this.aoBrightnessXYNN, this.aoBrightnessYZNP, i1); + this.brightnessTopRight = this.getAoBrightness(this.aoBrightnessYZNP, this.aoBrightnessXYZPNP, this.aoBrightnessXYPN, i1); + this.brightnessBottomRight = this.getAoBrightness(this.aoBrightnessYZNN, this.aoBrightnessXYPN, this.aoBrightnessXYZPNN, i1); + this.brightnessBottomLeft = this.getAoBrightness(this.aoBrightnessXYNN, this.aoBrightnessXYZNNN, this.aoBrightnessYZNN, i1); + + if (flag1) + { + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = p_147751_5_ * 0.5F; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = p_147751_6_ * 0.5F; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = p_147751_7_ * 0.5F; + } + else + { + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = 0.5F; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = 0.5F; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = 0.5F; + } + + this.colorRedTopLeft *= f3; + this.colorGreenTopLeft *= f3; + this.colorBlueTopLeft *= f3; + this.colorRedBottomLeft *= f4; + this.colorGreenBottomLeft *= f4; + this.colorBlueBottomLeft *= f4; + this.colorRedBottomRight *= f5; + this.colorGreenBottomRight *= f5; + this.colorBlueBottomRight *= f5; + this.colorRedTopRight *= f6; + this.colorGreenTopRight *= f6; + this.colorBlueTopRight *= f6; + this.renderFaceYNeg(p_147751_1_, (double)p_147751_2_, (double)p_147751_3_, (double)p_147751_4_, this.getBlockIcon(p_147751_1_, this.blockAccess, p_147751_2_, p_147751_3_, p_147751_4_, 0)); + flag = true; + } + + if (this.renderAllFaces || p_147751_1_.shouldSideBeRendered(this.blockAccess, p_147751_2_, p_147751_3_ + 1, p_147751_4_, 1)) + { + if (this.renderMaxY >= 1.0D) + { + ++p_147751_3_; + } + + this.aoBrightnessXYNP = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_ - 1, p_147751_3_, p_147751_4_); + this.aoBrightnessXYPP = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_ + 1, p_147751_3_, p_147751_4_); + this.aoBrightnessYZPN = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_, p_147751_3_, p_147751_4_ - 1); + this.aoBrightnessYZPP = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_, p_147751_3_, p_147751_4_ + 1); + this.aoLightValueScratchXYNP = this.blockAccess.getBlock(p_147751_2_ - 1, p_147751_3_, p_147751_4_).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXYPP = this.blockAccess.getBlock(p_147751_2_ + 1, p_147751_3_, p_147751_4_).getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZPN = this.blockAccess.getBlock(p_147751_2_, p_147751_3_, p_147751_4_ - 1).getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZPP = this.blockAccess.getBlock(p_147751_2_, p_147751_3_, p_147751_4_ + 1).getAmbientOcclusionLightValue(); + flag2 = this.blockAccess.getBlock(p_147751_2_ + 1, p_147751_3_ + 1, p_147751_4_).getCanBlockGrass(); + flag3 = this.blockAccess.getBlock(p_147751_2_ - 1, p_147751_3_ + 1, p_147751_4_).getCanBlockGrass(); + flag4 = this.blockAccess.getBlock(p_147751_2_, p_147751_3_ + 1, p_147751_4_ + 1).getCanBlockGrass(); + flag5 = this.blockAccess.getBlock(p_147751_2_, p_147751_3_ + 1, p_147751_4_ - 1).getCanBlockGrass(); + + if (!flag5 && !flag3) + { + this.aoLightValueScratchXYZNPN = this.aoLightValueScratchXYNP; + this.aoBrightnessXYZNPN = this.aoBrightnessXYNP; + } + else + { + this.aoLightValueScratchXYZNPN = this.blockAccess.getBlock(p_147751_2_ - 1, p_147751_3_, p_147751_4_ - 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNPN = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_ - 1, p_147751_3_, p_147751_4_ - 1); + } + + if (!flag5 && !flag2) + { + this.aoLightValueScratchXYZPPN = this.aoLightValueScratchXYPP; + this.aoBrightnessXYZPPN = this.aoBrightnessXYPP; + } + else + { + this.aoLightValueScratchXYZPPN = this.blockAccess.getBlock(p_147751_2_ + 1, p_147751_3_, p_147751_4_ - 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPPN = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_ + 1, p_147751_3_, p_147751_4_ - 1); + } + + if (!flag4 && !flag3) + { + this.aoLightValueScratchXYZNPP = this.aoLightValueScratchXYNP; + this.aoBrightnessXYZNPP = this.aoBrightnessXYNP; + } + else + { + this.aoLightValueScratchXYZNPP = this.blockAccess.getBlock(p_147751_2_ - 1, p_147751_3_, p_147751_4_ + 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNPP = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_ - 1, p_147751_3_, p_147751_4_ + 1); + } + + if (!flag4 && !flag2) + { + this.aoLightValueScratchXYZPPP = this.aoLightValueScratchXYPP; + this.aoBrightnessXYZPPP = this.aoBrightnessXYPP; + } + else + { + this.aoLightValueScratchXYZPPP = this.blockAccess.getBlock(p_147751_2_ + 1, p_147751_3_, p_147751_4_ + 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPPP = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_ + 1, p_147751_3_, p_147751_4_ + 1); + } + + if (this.renderMaxY >= 1.0D) + { + --p_147751_3_; + } + + i1 = l; + + if (this.renderMaxY >= 1.0D || !this.blockAccess.getBlock(p_147751_2_, p_147751_3_ + 1, p_147751_4_).isOpaqueCube()) + { + i1 = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_, p_147751_3_ + 1, p_147751_4_); + } + + f7 = this.blockAccess.getBlock(p_147751_2_, p_147751_3_ + 1, p_147751_4_).getAmbientOcclusionLightValue(); + f6 = (this.aoLightValueScratchXYZNPP + this.aoLightValueScratchXYNP + this.aoLightValueScratchYZPP + f7) / 4.0F; + f3 = (this.aoLightValueScratchYZPP + f7 + this.aoLightValueScratchXYZPPP + this.aoLightValueScratchXYPP) / 4.0F; + f4 = (f7 + this.aoLightValueScratchYZPN + this.aoLightValueScratchXYPP + this.aoLightValueScratchXYZPPN) / 4.0F; + f5 = (this.aoLightValueScratchXYNP + this.aoLightValueScratchXYZNPN + f7 + this.aoLightValueScratchYZPN) / 4.0F; + this.brightnessTopRight = this.getAoBrightness(this.aoBrightnessXYZNPP, this.aoBrightnessXYNP, this.aoBrightnessYZPP, i1); + this.brightnessTopLeft = this.getAoBrightness(this.aoBrightnessYZPP, this.aoBrightnessXYZPPP, this.aoBrightnessXYPP, i1); + this.brightnessBottomLeft = this.getAoBrightness(this.aoBrightnessYZPN, this.aoBrightnessXYPP, this.aoBrightnessXYZPPN, i1); + this.brightnessBottomRight = this.getAoBrightness(this.aoBrightnessXYNP, this.aoBrightnessXYZNPN, this.aoBrightnessYZPN, i1); + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = p_147751_5_; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = p_147751_6_; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = p_147751_7_; + this.colorRedTopLeft *= f3; + this.colorGreenTopLeft *= f3; + this.colorBlueTopLeft *= f3; + this.colorRedBottomLeft *= f4; + this.colorGreenBottomLeft *= f4; + this.colorBlueBottomLeft *= f4; + this.colorRedBottomRight *= f5; + this.colorGreenBottomRight *= f5; + this.colorBlueBottomRight *= f5; + this.colorRedTopRight *= f6; + this.colorGreenTopRight *= f6; + this.colorBlueTopRight *= f6; + this.renderFaceYPos(p_147751_1_, (double)p_147751_2_, (double)p_147751_3_, (double)p_147751_4_, this.getBlockIcon(p_147751_1_, this.blockAccess, p_147751_2_, p_147751_3_, p_147751_4_, 1)); + flag = true; + } + + IIcon iicon; + + if (this.renderAllFaces || p_147751_1_.shouldSideBeRendered(this.blockAccess, p_147751_2_, p_147751_3_, p_147751_4_ - 1, 2)) + { + if (this.renderMinZ <= 0.0D) + { + --p_147751_4_; + } + + this.aoLightValueScratchXZNN = this.blockAccess.getBlock(p_147751_2_ - 1, p_147751_3_, p_147751_4_).getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZNN = this.blockAccess.getBlock(p_147751_2_, p_147751_3_ - 1, p_147751_4_).getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZPN = this.blockAccess.getBlock(p_147751_2_, p_147751_3_ + 1, p_147751_4_).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXZPN = this.blockAccess.getBlock(p_147751_2_ + 1, p_147751_3_, p_147751_4_).getAmbientOcclusionLightValue(); + this.aoBrightnessXZNN = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_ - 1, p_147751_3_, p_147751_4_); + this.aoBrightnessYZNN = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_, p_147751_3_ - 1, p_147751_4_); + this.aoBrightnessYZPN = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_, p_147751_3_ + 1, p_147751_4_); + this.aoBrightnessXZPN = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_ + 1, p_147751_3_, p_147751_4_); + flag2 = this.blockAccess.getBlock(p_147751_2_ + 1, p_147751_3_, p_147751_4_ - 1).getCanBlockGrass(); + flag3 = this.blockAccess.getBlock(p_147751_2_ - 1, p_147751_3_, p_147751_4_ - 1).getCanBlockGrass(); + flag4 = this.blockAccess.getBlock(p_147751_2_, p_147751_3_ + 1, p_147751_4_ - 1).getCanBlockGrass(); + flag5 = this.blockAccess.getBlock(p_147751_2_, p_147751_3_ - 1, p_147751_4_ - 1).getCanBlockGrass(); + + if (!flag3 && !flag5) + { + this.aoLightValueScratchXYZNNN = this.aoLightValueScratchXZNN; + this.aoBrightnessXYZNNN = this.aoBrightnessXZNN; + } + else + { + this.aoLightValueScratchXYZNNN = this.blockAccess.getBlock(p_147751_2_ - 1, p_147751_3_ - 1, p_147751_4_).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNNN = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_ - 1, p_147751_3_ - 1, p_147751_4_); + } + + if (!flag3 && !flag4) + { + this.aoLightValueScratchXYZNPN = this.aoLightValueScratchXZNN; + this.aoBrightnessXYZNPN = this.aoBrightnessXZNN; + } + else + { + this.aoLightValueScratchXYZNPN = this.blockAccess.getBlock(p_147751_2_ - 1, p_147751_3_ + 1, p_147751_4_).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNPN = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_ - 1, p_147751_3_ + 1, p_147751_4_); + } + + if (!flag2 && !flag5) + { + this.aoLightValueScratchXYZPNN = this.aoLightValueScratchXZPN; + this.aoBrightnessXYZPNN = this.aoBrightnessXZPN; + } + else + { + this.aoLightValueScratchXYZPNN = this.blockAccess.getBlock(p_147751_2_ + 1, p_147751_3_ - 1, p_147751_4_).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPNN = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_ + 1, p_147751_3_ - 1, p_147751_4_); + } + + if (!flag2 && !flag4) + { + this.aoLightValueScratchXYZPPN = this.aoLightValueScratchXZPN; + this.aoBrightnessXYZPPN = this.aoBrightnessXZPN; + } + else + { + this.aoLightValueScratchXYZPPN = this.blockAccess.getBlock(p_147751_2_ + 1, p_147751_3_ + 1, p_147751_4_).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPPN = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_ + 1, p_147751_3_ + 1, p_147751_4_); + } + + if (this.renderMinZ <= 0.0D) + { + ++p_147751_4_; + } + + i1 = l; + + if (this.renderMinZ <= 0.0D || !this.blockAccess.getBlock(p_147751_2_, p_147751_3_, p_147751_4_ - 1).isOpaqueCube()) + { + i1 = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_, p_147751_3_, p_147751_4_ - 1); + } + + f7 = this.blockAccess.getBlock(p_147751_2_, p_147751_3_, p_147751_4_ - 1).getAmbientOcclusionLightValue(); + f3 = (this.aoLightValueScratchXZNN + this.aoLightValueScratchXYZNPN + f7 + this.aoLightValueScratchYZPN) / 4.0F; + f4 = (f7 + this.aoLightValueScratchYZPN + this.aoLightValueScratchXZPN + this.aoLightValueScratchXYZPPN) / 4.0F; + f5 = (this.aoLightValueScratchYZNN + f7 + this.aoLightValueScratchXYZPNN + this.aoLightValueScratchXZPN) / 4.0F; + f6 = (this.aoLightValueScratchXYZNNN + this.aoLightValueScratchXZNN + this.aoLightValueScratchYZNN + f7) / 4.0F; + this.brightnessTopLeft = this.getAoBrightness(this.aoBrightnessXZNN, this.aoBrightnessXYZNPN, this.aoBrightnessYZPN, i1); + this.brightnessBottomLeft = this.getAoBrightness(this.aoBrightnessYZPN, this.aoBrightnessXZPN, this.aoBrightnessXYZPPN, i1); + this.brightnessBottomRight = this.getAoBrightness(this.aoBrightnessYZNN, this.aoBrightnessXYZPNN, this.aoBrightnessXZPN, i1); + this.brightnessTopRight = this.getAoBrightness(this.aoBrightnessXYZNNN, this.aoBrightnessXZNN, this.aoBrightnessYZNN, i1); + + if (flag1) + { + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = p_147751_5_ * 0.8F; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = p_147751_6_ * 0.8F; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = p_147751_7_ * 0.8F; + } + else + { + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = 0.8F; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = 0.8F; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = 0.8F; + } + + this.colorRedTopLeft *= f3; + this.colorGreenTopLeft *= f3; + this.colorBlueTopLeft *= f3; + this.colorRedBottomLeft *= f4; + this.colorGreenBottomLeft *= f4; + this.colorBlueBottomLeft *= f4; + this.colorRedBottomRight *= f5; + this.colorGreenBottomRight *= f5; + this.colorBlueBottomRight *= f5; + this.colorRedTopRight *= f6; + this.colorGreenTopRight *= f6; + this.colorBlueTopRight *= f6; + iicon = this.getBlockIcon(p_147751_1_, this.blockAccess, p_147751_2_, p_147751_3_, p_147751_4_, 2); + this.renderFaceZNeg(p_147751_1_, (double)p_147751_2_, (double)p_147751_3_, (double)p_147751_4_, iicon); + + if (fancyGrass && iicon.getIconName().equals("grass_side") && !this.hasOverrideBlockTexture()) + { + this.colorRedTopLeft *= p_147751_5_; + this.colorRedBottomLeft *= p_147751_5_; + this.colorRedBottomRight *= p_147751_5_; + this.colorRedTopRight *= p_147751_5_; + this.colorGreenTopLeft *= p_147751_6_; + this.colorGreenBottomLeft *= p_147751_6_; + this.colorGreenBottomRight *= p_147751_6_; + this.colorGreenTopRight *= p_147751_6_; + this.colorBlueTopLeft *= p_147751_7_; + this.colorBlueBottomLeft *= p_147751_7_; + this.colorBlueBottomRight *= p_147751_7_; + this.colorBlueTopRight *= p_147751_7_; + this.renderFaceZNeg(p_147751_1_, (double)p_147751_2_, (double)p_147751_3_, (double)p_147751_4_, BlockGrass.getIconSideOverlay()); + } + + flag = true; + } + + if (this.renderAllFaces || p_147751_1_.shouldSideBeRendered(this.blockAccess, p_147751_2_, p_147751_3_, p_147751_4_ + 1, 3)) + { + if (this.renderMaxZ >= 1.0D) + { + ++p_147751_4_; + } + + this.aoLightValueScratchXZNP = this.blockAccess.getBlock(p_147751_2_ - 1, p_147751_3_, p_147751_4_).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXZPP = this.blockAccess.getBlock(p_147751_2_ + 1, p_147751_3_, p_147751_4_).getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZNP = this.blockAccess.getBlock(p_147751_2_, p_147751_3_ - 1, p_147751_4_).getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZPP = this.blockAccess.getBlock(p_147751_2_, p_147751_3_ + 1, p_147751_4_).getAmbientOcclusionLightValue(); + this.aoBrightnessXZNP = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_ - 1, p_147751_3_, p_147751_4_); + this.aoBrightnessXZPP = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_ + 1, p_147751_3_, p_147751_4_); + this.aoBrightnessYZNP = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_, p_147751_3_ - 1, p_147751_4_); + this.aoBrightnessYZPP = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_, p_147751_3_ + 1, p_147751_4_); + flag2 = this.blockAccess.getBlock(p_147751_2_ + 1, p_147751_3_, p_147751_4_ + 1).getCanBlockGrass(); + flag3 = this.blockAccess.getBlock(p_147751_2_ - 1, p_147751_3_, p_147751_4_ + 1).getCanBlockGrass(); + flag4 = this.blockAccess.getBlock(p_147751_2_, p_147751_3_ + 1, p_147751_4_ + 1).getCanBlockGrass(); + flag5 = this.blockAccess.getBlock(p_147751_2_, p_147751_3_ - 1, p_147751_4_ + 1).getCanBlockGrass(); + + if (!flag3 && !flag5) + { + this.aoLightValueScratchXYZNNP = this.aoLightValueScratchXZNP; + this.aoBrightnessXYZNNP = this.aoBrightnessXZNP; + } + else + { + this.aoLightValueScratchXYZNNP = this.blockAccess.getBlock(p_147751_2_ - 1, p_147751_3_ - 1, p_147751_4_).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNNP = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_ - 1, p_147751_3_ - 1, p_147751_4_); + } + + if (!flag3 && !flag4) + { + this.aoLightValueScratchXYZNPP = this.aoLightValueScratchXZNP; + this.aoBrightnessXYZNPP = this.aoBrightnessXZNP; + } + else + { + this.aoLightValueScratchXYZNPP = this.blockAccess.getBlock(p_147751_2_ - 1, p_147751_3_ + 1, p_147751_4_).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNPP = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_ - 1, p_147751_3_ + 1, p_147751_4_); + } + + if (!flag2 && !flag5) + { + this.aoLightValueScratchXYZPNP = this.aoLightValueScratchXZPP; + this.aoBrightnessXYZPNP = this.aoBrightnessXZPP; + } + else + { + this.aoLightValueScratchXYZPNP = this.blockAccess.getBlock(p_147751_2_ + 1, p_147751_3_ - 1, p_147751_4_).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPNP = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_ + 1, p_147751_3_ - 1, p_147751_4_); + } + + if (!flag2 && !flag4) + { + this.aoLightValueScratchXYZPPP = this.aoLightValueScratchXZPP; + this.aoBrightnessXYZPPP = this.aoBrightnessXZPP; + } + else + { + this.aoLightValueScratchXYZPPP = this.blockAccess.getBlock(p_147751_2_ + 1, p_147751_3_ + 1, p_147751_4_).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPPP = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_ + 1, p_147751_3_ + 1, p_147751_4_); + } + + if (this.renderMaxZ >= 1.0D) + { + --p_147751_4_; + } + + i1 = l; + + if (this.renderMaxZ >= 1.0D || !this.blockAccess.getBlock(p_147751_2_, p_147751_3_, p_147751_4_ + 1).isOpaqueCube()) + { + i1 = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_, p_147751_3_, p_147751_4_ + 1); + } + + f7 = this.blockAccess.getBlock(p_147751_2_, p_147751_3_, p_147751_4_ + 1).getAmbientOcclusionLightValue(); + f3 = (this.aoLightValueScratchXZNP + this.aoLightValueScratchXYZNPP + f7 + this.aoLightValueScratchYZPP) / 4.0F; + f6 = (f7 + this.aoLightValueScratchYZPP + this.aoLightValueScratchXZPP + this.aoLightValueScratchXYZPPP) / 4.0F; + f5 = (this.aoLightValueScratchYZNP + f7 + this.aoLightValueScratchXYZPNP + this.aoLightValueScratchXZPP) / 4.0F; + f4 = (this.aoLightValueScratchXYZNNP + this.aoLightValueScratchXZNP + this.aoLightValueScratchYZNP + f7) / 4.0F; + this.brightnessTopLeft = this.getAoBrightness(this.aoBrightnessXZNP, this.aoBrightnessXYZNPP, this.aoBrightnessYZPP, i1); + this.brightnessTopRight = this.getAoBrightness(this.aoBrightnessYZPP, this.aoBrightnessXZPP, this.aoBrightnessXYZPPP, i1); + this.brightnessBottomRight = this.getAoBrightness(this.aoBrightnessYZNP, this.aoBrightnessXYZPNP, this.aoBrightnessXZPP, i1); + this.brightnessBottomLeft = this.getAoBrightness(this.aoBrightnessXYZNNP, this.aoBrightnessXZNP, this.aoBrightnessYZNP, i1); + + if (flag1) + { + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = p_147751_5_ * 0.8F; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = p_147751_6_ * 0.8F; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = p_147751_7_ * 0.8F; + } + else + { + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = 0.8F; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = 0.8F; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = 0.8F; + } + + this.colorRedTopLeft *= f3; + this.colorGreenTopLeft *= f3; + this.colorBlueTopLeft *= f3; + this.colorRedBottomLeft *= f4; + this.colorGreenBottomLeft *= f4; + this.colorBlueBottomLeft *= f4; + this.colorRedBottomRight *= f5; + this.colorGreenBottomRight *= f5; + this.colorBlueBottomRight *= f5; + this.colorRedTopRight *= f6; + this.colorGreenTopRight *= f6; + this.colorBlueTopRight *= f6; + iicon = this.getBlockIcon(p_147751_1_, this.blockAccess, p_147751_2_, p_147751_3_, p_147751_4_, 3); + this.renderFaceZPos(p_147751_1_, (double)p_147751_2_, (double)p_147751_3_, (double)p_147751_4_, this.getBlockIcon(p_147751_1_, this.blockAccess, p_147751_2_, p_147751_3_, p_147751_4_, 3)); + + if (fancyGrass && iicon.getIconName().equals("grass_side") && !this.hasOverrideBlockTexture()) + { + this.colorRedTopLeft *= p_147751_5_; + this.colorRedBottomLeft *= p_147751_5_; + this.colorRedBottomRight *= p_147751_5_; + this.colorRedTopRight *= p_147751_5_; + this.colorGreenTopLeft *= p_147751_6_; + this.colorGreenBottomLeft *= p_147751_6_; + this.colorGreenBottomRight *= p_147751_6_; + this.colorGreenTopRight *= p_147751_6_; + this.colorBlueTopLeft *= p_147751_7_; + this.colorBlueBottomLeft *= p_147751_7_; + this.colorBlueBottomRight *= p_147751_7_; + this.colorBlueTopRight *= p_147751_7_; + this.renderFaceZPos(p_147751_1_, (double)p_147751_2_, (double)p_147751_3_, (double)p_147751_4_, BlockGrass.getIconSideOverlay()); + } + + flag = true; + } + + if (this.renderAllFaces || p_147751_1_.shouldSideBeRendered(this.blockAccess, p_147751_2_ - 1, p_147751_3_, p_147751_4_, 4)) + { + if (this.renderMinX <= 0.0D) + { + --p_147751_2_; + } + + this.aoLightValueScratchXYNN = this.blockAccess.getBlock(p_147751_2_, p_147751_3_ - 1, p_147751_4_).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXZNN = this.blockAccess.getBlock(p_147751_2_, p_147751_3_, p_147751_4_ - 1).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXZNP = this.blockAccess.getBlock(p_147751_2_, p_147751_3_, p_147751_4_ + 1).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXYNP = this.blockAccess.getBlock(p_147751_2_, p_147751_3_ + 1, p_147751_4_).getAmbientOcclusionLightValue(); + this.aoBrightnessXYNN = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_, p_147751_3_ - 1, p_147751_4_); + this.aoBrightnessXZNN = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_, p_147751_3_, p_147751_4_ - 1); + this.aoBrightnessXZNP = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_, p_147751_3_, p_147751_4_ + 1); + this.aoBrightnessXYNP = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_, p_147751_3_ + 1, p_147751_4_); + flag2 = this.blockAccess.getBlock(p_147751_2_ - 1, p_147751_3_ + 1, p_147751_4_).getCanBlockGrass(); + flag3 = this.blockAccess.getBlock(p_147751_2_ - 1, p_147751_3_ - 1, p_147751_4_).getCanBlockGrass(); + flag4 = this.blockAccess.getBlock(p_147751_2_ - 1, p_147751_3_, p_147751_4_ - 1).getCanBlockGrass(); + flag5 = this.blockAccess.getBlock(p_147751_2_ - 1, p_147751_3_, p_147751_4_ + 1).getCanBlockGrass(); + + if (!flag4 && !flag3) + { + this.aoLightValueScratchXYZNNN = this.aoLightValueScratchXZNN; + this.aoBrightnessXYZNNN = this.aoBrightnessXZNN; + } + else + { + this.aoLightValueScratchXYZNNN = this.blockAccess.getBlock(p_147751_2_, p_147751_3_ - 1, p_147751_4_ - 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNNN = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_, p_147751_3_ - 1, p_147751_4_ - 1); + } + + if (!flag5 && !flag3) + { + this.aoLightValueScratchXYZNNP = this.aoLightValueScratchXZNP; + this.aoBrightnessXYZNNP = this.aoBrightnessXZNP; + } + else + { + this.aoLightValueScratchXYZNNP = this.blockAccess.getBlock(p_147751_2_, p_147751_3_ - 1, p_147751_4_ + 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNNP = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_, p_147751_3_ - 1, p_147751_4_ + 1); + } + + if (!flag4 && !flag2) + { + this.aoLightValueScratchXYZNPN = this.aoLightValueScratchXZNN; + this.aoBrightnessXYZNPN = this.aoBrightnessXZNN; + } + else + { + this.aoLightValueScratchXYZNPN = this.blockAccess.getBlock(p_147751_2_, p_147751_3_ + 1, p_147751_4_ - 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNPN = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_, p_147751_3_ + 1, p_147751_4_ - 1); + } + + if (!flag5 && !flag2) + { + this.aoLightValueScratchXYZNPP = this.aoLightValueScratchXZNP; + this.aoBrightnessXYZNPP = this.aoBrightnessXZNP; + } + else + { + this.aoLightValueScratchXYZNPP = this.blockAccess.getBlock(p_147751_2_, p_147751_3_ + 1, p_147751_4_ + 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNPP = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_, p_147751_3_ + 1, p_147751_4_ + 1); + } + + if (this.renderMinX <= 0.0D) + { + ++p_147751_2_; + } + + i1 = l; + + if (this.renderMinX <= 0.0D || !this.blockAccess.getBlock(p_147751_2_ - 1, p_147751_3_, p_147751_4_).isOpaqueCube()) + { + i1 = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_ - 1, p_147751_3_, p_147751_4_); + } + + f7 = this.blockAccess.getBlock(p_147751_2_ - 1, p_147751_3_, p_147751_4_).getAmbientOcclusionLightValue(); + f6 = (this.aoLightValueScratchXYNN + this.aoLightValueScratchXYZNNP + f7 + this.aoLightValueScratchXZNP) / 4.0F; + f3 = (f7 + this.aoLightValueScratchXZNP + this.aoLightValueScratchXYNP + this.aoLightValueScratchXYZNPP) / 4.0F; + f4 = (this.aoLightValueScratchXZNN + f7 + this.aoLightValueScratchXYZNPN + this.aoLightValueScratchXYNP) / 4.0F; + f5 = (this.aoLightValueScratchXYZNNN + this.aoLightValueScratchXYNN + this.aoLightValueScratchXZNN + f7) / 4.0F; + this.brightnessTopRight = this.getAoBrightness(this.aoBrightnessXYNN, this.aoBrightnessXYZNNP, this.aoBrightnessXZNP, i1); + this.brightnessTopLeft = this.getAoBrightness(this.aoBrightnessXZNP, this.aoBrightnessXYNP, this.aoBrightnessXYZNPP, i1); + this.brightnessBottomLeft = this.getAoBrightness(this.aoBrightnessXZNN, this.aoBrightnessXYZNPN, this.aoBrightnessXYNP, i1); + this.brightnessBottomRight = this.getAoBrightness(this.aoBrightnessXYZNNN, this.aoBrightnessXYNN, this.aoBrightnessXZNN, i1); + + if (flag1) + { + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = p_147751_5_ * 0.6F; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = p_147751_6_ * 0.6F; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = p_147751_7_ * 0.6F; + } + else + { + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = 0.6F; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = 0.6F; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = 0.6F; + } + + this.colorRedTopLeft *= f3; + this.colorGreenTopLeft *= f3; + this.colorBlueTopLeft *= f3; + this.colorRedBottomLeft *= f4; + this.colorGreenBottomLeft *= f4; + this.colorBlueBottomLeft *= f4; + this.colorRedBottomRight *= f5; + this.colorGreenBottomRight *= f5; + this.colorBlueBottomRight *= f5; + this.colorRedTopRight *= f6; + this.colorGreenTopRight *= f6; + this.colorBlueTopRight *= f6; + iicon = this.getBlockIcon(p_147751_1_, this.blockAccess, p_147751_2_, p_147751_3_, p_147751_4_, 4); + this.renderFaceXNeg(p_147751_1_, (double)p_147751_2_, (double)p_147751_3_, (double)p_147751_4_, iicon); + + if (fancyGrass && iicon.getIconName().equals("grass_side") && !this.hasOverrideBlockTexture()) + { + this.colorRedTopLeft *= p_147751_5_; + this.colorRedBottomLeft *= p_147751_5_; + this.colorRedBottomRight *= p_147751_5_; + this.colorRedTopRight *= p_147751_5_; + this.colorGreenTopLeft *= p_147751_6_; + this.colorGreenBottomLeft *= p_147751_6_; + this.colorGreenBottomRight *= p_147751_6_; + this.colorGreenTopRight *= p_147751_6_; + this.colorBlueTopLeft *= p_147751_7_; + this.colorBlueBottomLeft *= p_147751_7_; + this.colorBlueBottomRight *= p_147751_7_; + this.colorBlueTopRight *= p_147751_7_; + this.renderFaceXNeg(p_147751_1_, (double)p_147751_2_, (double)p_147751_3_, (double)p_147751_4_, BlockGrass.getIconSideOverlay()); + } + + flag = true; + } + + if (this.renderAllFaces || p_147751_1_.shouldSideBeRendered(this.blockAccess, p_147751_2_ + 1, p_147751_3_, p_147751_4_, 5)) + { + if (this.renderMaxX >= 1.0D) + { + ++p_147751_2_; + } + + this.aoLightValueScratchXYPN = this.blockAccess.getBlock(p_147751_2_, p_147751_3_ - 1, p_147751_4_).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXZPN = this.blockAccess.getBlock(p_147751_2_, p_147751_3_, p_147751_4_ - 1).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXZPP = this.blockAccess.getBlock(p_147751_2_, p_147751_3_, p_147751_4_ + 1).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXYPP = this.blockAccess.getBlock(p_147751_2_, p_147751_3_ + 1, p_147751_4_).getAmbientOcclusionLightValue(); + this.aoBrightnessXYPN = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_, p_147751_3_ - 1, p_147751_4_); + this.aoBrightnessXZPN = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_, p_147751_3_, p_147751_4_ - 1); + this.aoBrightnessXZPP = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_, p_147751_3_, p_147751_4_ + 1); + this.aoBrightnessXYPP = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_, p_147751_3_ + 1, p_147751_4_); + flag2 = this.blockAccess.getBlock(p_147751_2_ + 1, p_147751_3_ + 1, p_147751_4_).getCanBlockGrass(); + flag3 = this.blockAccess.getBlock(p_147751_2_ + 1, p_147751_3_ - 1, p_147751_4_).getCanBlockGrass(); + flag4 = this.blockAccess.getBlock(p_147751_2_ + 1, p_147751_3_, p_147751_4_ + 1).getCanBlockGrass(); + flag5 = this.blockAccess.getBlock(p_147751_2_ + 1, p_147751_3_, p_147751_4_ - 1).getCanBlockGrass(); + + if (!flag3 && !flag5) + { + this.aoLightValueScratchXYZPNN = this.aoLightValueScratchXZPN; + this.aoBrightnessXYZPNN = this.aoBrightnessXZPN; + } + else + { + this.aoLightValueScratchXYZPNN = this.blockAccess.getBlock(p_147751_2_, p_147751_3_ - 1, p_147751_4_ - 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPNN = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_, p_147751_3_ - 1, p_147751_4_ - 1); + } + + if (!flag3 && !flag4) + { + this.aoLightValueScratchXYZPNP = this.aoLightValueScratchXZPP; + this.aoBrightnessXYZPNP = this.aoBrightnessXZPP; + } + else + { + this.aoLightValueScratchXYZPNP = this.blockAccess.getBlock(p_147751_2_, p_147751_3_ - 1, p_147751_4_ + 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPNP = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_, p_147751_3_ - 1, p_147751_4_ + 1); + } + + if (!flag2 && !flag5) + { + this.aoLightValueScratchXYZPPN = this.aoLightValueScratchXZPN; + this.aoBrightnessXYZPPN = this.aoBrightnessXZPN; + } + else + { + this.aoLightValueScratchXYZPPN = this.blockAccess.getBlock(p_147751_2_, p_147751_3_ + 1, p_147751_4_ - 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPPN = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_, p_147751_3_ + 1, p_147751_4_ - 1); + } + + if (!flag2 && !flag4) + { + this.aoLightValueScratchXYZPPP = this.aoLightValueScratchXZPP; + this.aoBrightnessXYZPPP = this.aoBrightnessXZPP; + } + else + { + this.aoLightValueScratchXYZPPP = this.blockAccess.getBlock(p_147751_2_, p_147751_3_ + 1, p_147751_4_ + 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPPP = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_, p_147751_3_ + 1, p_147751_4_ + 1); + } + + if (this.renderMaxX >= 1.0D) + { + --p_147751_2_; + } + + i1 = l; + + if (this.renderMaxX >= 1.0D || !this.blockAccess.getBlock(p_147751_2_ + 1, p_147751_3_, p_147751_4_).isOpaqueCube()) + { + i1 = p_147751_1_.getMixedBrightnessForBlock(this.blockAccess, p_147751_2_ + 1, p_147751_3_, p_147751_4_); + } + + f7 = this.blockAccess.getBlock(p_147751_2_ + 1, p_147751_3_, p_147751_4_).getAmbientOcclusionLightValue(); + f3 = (this.aoLightValueScratchXYPN + this.aoLightValueScratchXYZPNP + f7 + this.aoLightValueScratchXZPP) / 4.0F; + f4 = (this.aoLightValueScratchXYZPNN + this.aoLightValueScratchXYPN + this.aoLightValueScratchXZPN + f7) / 4.0F; + f5 = (this.aoLightValueScratchXZPN + f7 + this.aoLightValueScratchXYZPPN + this.aoLightValueScratchXYPP) / 4.0F; + f6 = (f7 + this.aoLightValueScratchXZPP + this.aoLightValueScratchXYPP + this.aoLightValueScratchXYZPPP) / 4.0F; + this.brightnessTopLeft = this.getAoBrightness(this.aoBrightnessXYPN, this.aoBrightnessXYZPNP, this.aoBrightnessXZPP, i1); + this.brightnessTopRight = this.getAoBrightness(this.aoBrightnessXZPP, this.aoBrightnessXYPP, this.aoBrightnessXYZPPP, i1); + this.brightnessBottomRight = this.getAoBrightness(this.aoBrightnessXZPN, this.aoBrightnessXYZPPN, this.aoBrightnessXYPP, i1); + this.brightnessBottomLeft = this.getAoBrightness(this.aoBrightnessXYZPNN, this.aoBrightnessXYPN, this.aoBrightnessXZPN, i1); + + if (flag1) + { + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = p_147751_5_ * 0.6F; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = p_147751_6_ * 0.6F; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = p_147751_7_ * 0.6F; + } + else + { + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = 0.6F; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = 0.6F; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = 0.6F; + } + + this.colorRedTopLeft *= f3; + this.colorGreenTopLeft *= f3; + this.colorBlueTopLeft *= f3; + this.colorRedBottomLeft *= f4; + this.colorGreenBottomLeft *= f4; + this.colorBlueBottomLeft *= f4; + this.colorRedBottomRight *= f5; + this.colorGreenBottomRight *= f5; + this.colorBlueBottomRight *= f5; + this.colorRedTopRight *= f6; + this.colorGreenTopRight *= f6; + this.colorBlueTopRight *= f6; + iicon = this.getBlockIcon(p_147751_1_, this.blockAccess, p_147751_2_, p_147751_3_, p_147751_4_, 5); + this.renderFaceXPos(p_147751_1_, (double)p_147751_2_, (double)p_147751_3_, (double)p_147751_4_, iicon); + + if (fancyGrass && iicon.getIconName().equals("grass_side") && !this.hasOverrideBlockTexture()) + { + this.colorRedTopLeft *= p_147751_5_; + this.colorRedBottomLeft *= p_147751_5_; + this.colorRedBottomRight *= p_147751_5_; + this.colorRedTopRight *= p_147751_5_; + this.colorGreenTopLeft *= p_147751_6_; + this.colorGreenBottomLeft *= p_147751_6_; + this.colorGreenBottomRight *= p_147751_6_; + this.colorGreenTopRight *= p_147751_6_; + this.colorBlueTopLeft *= p_147751_7_; + this.colorBlueBottomLeft *= p_147751_7_; + this.colorBlueBottomRight *= p_147751_7_; + this.colorBlueTopRight *= p_147751_7_; + this.renderFaceXPos(p_147751_1_, (double)p_147751_2_, (double)p_147751_3_, (double)p_147751_4_, BlockGrass.getIconSideOverlay()); + } + + flag = true; + } + + this.enableAO = false; + return flag; + } + + public boolean renderStandardBlockWithAmbientOcclusionPartial(Block p_147808_1_, int p_147808_2_, int p_147808_3_, int p_147808_4_, float p_147808_5_, float p_147808_6_, float p_147808_7_) + { + this.enableAO = true; + boolean flag = false; + float f3 = 0.0F; + float f4 = 0.0F; + float f5 = 0.0F; + float f6 = 0.0F; + boolean flag1 = true; + int l = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_, p_147808_3_, p_147808_4_); + Tessellator tessellator = Tessellator.instance; + tessellator.setBrightness(983055); + + if (this.getBlockIcon(p_147808_1_).getIconName().equals("grass_top")) + { + flag1 = false; + } + else if (this.hasOverrideBlockTexture()) + { + flag1 = false; + } + + boolean flag2; + boolean flag3; + boolean flag4; + boolean flag5; + int i1; + float f7; + + if (this.renderAllFaces || p_147808_1_.shouldSideBeRendered(this.blockAccess, p_147808_2_, p_147808_3_ - 1, p_147808_4_, 0)) + { + if (this.renderMinY <= 0.0D) + { + --p_147808_3_; + } + + this.aoBrightnessXYNN = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_ - 1, p_147808_3_, p_147808_4_); + this.aoBrightnessYZNN = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_, p_147808_3_, p_147808_4_ - 1); + this.aoBrightnessYZNP = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_, p_147808_3_, p_147808_4_ + 1); + this.aoBrightnessXYPN = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_ + 1, p_147808_3_, p_147808_4_); + this.aoLightValueScratchXYNN = this.blockAccess.getBlock(p_147808_2_ - 1, p_147808_3_, p_147808_4_).getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZNN = this.blockAccess.getBlock(p_147808_2_, p_147808_3_, p_147808_4_ - 1).getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZNP = this.blockAccess.getBlock(p_147808_2_, p_147808_3_, p_147808_4_ + 1).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXYPN = this.blockAccess.getBlock(p_147808_2_ + 1, p_147808_3_, p_147808_4_).getAmbientOcclusionLightValue(); + flag2 = this.blockAccess.getBlock(p_147808_2_ + 1, p_147808_3_ - 1, p_147808_4_).getCanBlockGrass(); + flag3 = this.blockAccess.getBlock(p_147808_2_ - 1, p_147808_3_ - 1, p_147808_4_).getCanBlockGrass(); + flag4 = this.blockAccess.getBlock(p_147808_2_, p_147808_3_ - 1, p_147808_4_ + 1).getCanBlockGrass(); + flag5 = this.blockAccess.getBlock(p_147808_2_, p_147808_3_ - 1, p_147808_4_ - 1).getCanBlockGrass(); + + if (!flag5 && !flag3) + { + this.aoLightValueScratchXYZNNN = this.aoLightValueScratchXYNN; + this.aoBrightnessXYZNNN = this.aoBrightnessXYNN; + } + else + { + this.aoLightValueScratchXYZNNN = this.blockAccess.getBlock(p_147808_2_ - 1, p_147808_3_, p_147808_4_ - 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNNN = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_ - 1, p_147808_3_, p_147808_4_ - 1); + } + + if (!flag4 && !flag3) + { + this.aoLightValueScratchXYZNNP = this.aoLightValueScratchXYNN; + this.aoBrightnessXYZNNP = this.aoBrightnessXYNN; + } + else + { + this.aoLightValueScratchXYZNNP = this.blockAccess.getBlock(p_147808_2_ - 1, p_147808_3_, p_147808_4_ + 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNNP = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_ - 1, p_147808_3_, p_147808_4_ + 1); + } + + if (!flag5 && !flag2) + { + this.aoLightValueScratchXYZPNN = this.aoLightValueScratchXYPN; + this.aoBrightnessXYZPNN = this.aoBrightnessXYPN; + } + else + { + this.aoLightValueScratchXYZPNN = this.blockAccess.getBlock(p_147808_2_ + 1, p_147808_3_, p_147808_4_ - 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPNN = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_ + 1, p_147808_3_, p_147808_4_ - 1); + } + + if (!flag4 && !flag2) + { + this.aoLightValueScratchXYZPNP = this.aoLightValueScratchXYPN; + this.aoBrightnessXYZPNP = this.aoBrightnessXYPN; + } + else + { + this.aoLightValueScratchXYZPNP = this.blockAccess.getBlock(p_147808_2_ + 1, p_147808_3_, p_147808_4_ + 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPNP = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_ + 1, p_147808_3_, p_147808_4_ + 1); + } + + if (this.renderMinY <= 0.0D) + { + ++p_147808_3_; + } + + i1 = l; + + if (this.renderMinY <= 0.0D || !this.blockAccess.getBlock(p_147808_2_, p_147808_3_ - 1, p_147808_4_).isOpaqueCube()) + { + i1 = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_, p_147808_3_ - 1, p_147808_4_); + } + + f7 = this.blockAccess.getBlock(p_147808_2_, p_147808_3_ - 1, p_147808_4_).getAmbientOcclusionLightValue(); + f3 = (this.aoLightValueScratchXYZNNP + this.aoLightValueScratchXYNN + this.aoLightValueScratchYZNP + f7) / 4.0F; + f6 = (this.aoLightValueScratchYZNP + f7 + this.aoLightValueScratchXYZPNP + this.aoLightValueScratchXYPN) / 4.0F; + f5 = (f7 + this.aoLightValueScratchYZNN + this.aoLightValueScratchXYPN + this.aoLightValueScratchXYZPNN) / 4.0F; + f4 = (this.aoLightValueScratchXYNN + this.aoLightValueScratchXYZNNN + f7 + this.aoLightValueScratchYZNN) / 4.0F; + this.brightnessTopLeft = this.getAoBrightness(this.aoBrightnessXYZNNP, this.aoBrightnessXYNN, this.aoBrightnessYZNP, i1); + this.brightnessTopRight = this.getAoBrightness(this.aoBrightnessYZNP, this.aoBrightnessXYZPNP, this.aoBrightnessXYPN, i1); + this.brightnessBottomRight = this.getAoBrightness(this.aoBrightnessYZNN, this.aoBrightnessXYPN, this.aoBrightnessXYZPNN, i1); + this.brightnessBottomLeft = this.getAoBrightness(this.aoBrightnessXYNN, this.aoBrightnessXYZNNN, this.aoBrightnessYZNN, i1); + + if (flag1) + { + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = p_147808_5_ * 0.5F; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = p_147808_6_ * 0.5F; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = p_147808_7_ * 0.5F; + } + else + { + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = 0.5F; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = 0.5F; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = 0.5F; + } + + this.colorRedTopLeft *= f3; + this.colorGreenTopLeft *= f3; + this.colorBlueTopLeft *= f3; + this.colorRedBottomLeft *= f4; + this.colorGreenBottomLeft *= f4; + this.colorBlueBottomLeft *= f4; + this.colorRedBottomRight *= f5; + this.colorGreenBottomRight *= f5; + this.colorBlueBottomRight *= f5; + this.colorRedTopRight *= f6; + this.colorGreenTopRight *= f6; + this.colorBlueTopRight *= f6; + this.renderFaceYNeg(p_147808_1_, (double)p_147808_2_, (double)p_147808_3_, (double)p_147808_4_, this.getBlockIcon(p_147808_1_, this.blockAccess, p_147808_2_, p_147808_3_, p_147808_4_, 0)); + flag = true; + } + + if (this.renderAllFaces || p_147808_1_.shouldSideBeRendered(this.blockAccess, p_147808_2_, p_147808_3_ + 1, p_147808_4_, 1)) + { + if (this.renderMaxY >= 1.0D) + { + ++p_147808_3_; + } + + this.aoBrightnessXYNP = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_ - 1, p_147808_3_, p_147808_4_); + this.aoBrightnessXYPP = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_ + 1, p_147808_3_, p_147808_4_); + this.aoBrightnessYZPN = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_, p_147808_3_, p_147808_4_ - 1); + this.aoBrightnessYZPP = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_, p_147808_3_, p_147808_4_ + 1); + this.aoLightValueScratchXYNP = this.blockAccess.getBlock(p_147808_2_ - 1, p_147808_3_, p_147808_4_).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXYPP = this.blockAccess.getBlock(p_147808_2_ + 1, p_147808_3_, p_147808_4_).getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZPN = this.blockAccess.getBlock(p_147808_2_, p_147808_3_, p_147808_4_ - 1).getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZPP = this.blockAccess.getBlock(p_147808_2_, p_147808_3_, p_147808_4_ + 1).getAmbientOcclusionLightValue(); + flag2 = this.blockAccess.getBlock(p_147808_2_ + 1, p_147808_3_ + 1, p_147808_4_).getCanBlockGrass(); + flag3 = this.blockAccess.getBlock(p_147808_2_ - 1, p_147808_3_ + 1, p_147808_4_).getCanBlockGrass(); + flag4 = this.blockAccess.getBlock(p_147808_2_, p_147808_3_ + 1, p_147808_4_ + 1).getCanBlockGrass(); + flag5 = this.blockAccess.getBlock(p_147808_2_, p_147808_3_ + 1, p_147808_4_ - 1).getCanBlockGrass(); + + if (!flag5 && !flag3) + { + this.aoLightValueScratchXYZNPN = this.aoLightValueScratchXYNP; + this.aoBrightnessXYZNPN = this.aoBrightnessXYNP; + } + else + { + this.aoLightValueScratchXYZNPN = this.blockAccess.getBlock(p_147808_2_ - 1, p_147808_3_, p_147808_4_ - 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNPN = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_ - 1, p_147808_3_, p_147808_4_ - 1); + } + + if (!flag5 && !flag2) + { + this.aoLightValueScratchXYZPPN = this.aoLightValueScratchXYPP; + this.aoBrightnessXYZPPN = this.aoBrightnessXYPP; + } + else + { + this.aoLightValueScratchXYZPPN = this.blockAccess.getBlock(p_147808_2_ + 1, p_147808_3_, p_147808_4_ - 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPPN = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_ + 1, p_147808_3_, p_147808_4_ - 1); + } + + if (!flag4 && !flag3) + { + this.aoLightValueScratchXYZNPP = this.aoLightValueScratchXYNP; + this.aoBrightnessXYZNPP = this.aoBrightnessXYNP; + } + else + { + this.aoLightValueScratchXYZNPP = this.blockAccess.getBlock(p_147808_2_ - 1, p_147808_3_, p_147808_4_ + 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNPP = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_ - 1, p_147808_3_, p_147808_4_ + 1); + } + + if (!flag4 && !flag2) + { + this.aoLightValueScratchXYZPPP = this.aoLightValueScratchXYPP; + this.aoBrightnessXYZPPP = this.aoBrightnessXYPP; + } + else + { + this.aoLightValueScratchXYZPPP = this.blockAccess.getBlock(p_147808_2_ + 1, p_147808_3_, p_147808_4_ + 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPPP = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_ + 1, p_147808_3_, p_147808_4_ + 1); + } + + if (this.renderMaxY >= 1.0D) + { + --p_147808_3_; + } + + i1 = l; + + if (this.renderMaxY >= 1.0D || !this.blockAccess.getBlock(p_147808_2_, p_147808_3_ + 1, p_147808_4_).isOpaqueCube()) + { + i1 = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_, p_147808_3_ + 1, p_147808_4_); + } + + f7 = this.blockAccess.getBlock(p_147808_2_, p_147808_3_ + 1, p_147808_4_).getAmbientOcclusionLightValue(); + f6 = (this.aoLightValueScratchXYZNPP + this.aoLightValueScratchXYNP + this.aoLightValueScratchYZPP + f7) / 4.0F; + f3 = (this.aoLightValueScratchYZPP + f7 + this.aoLightValueScratchXYZPPP + this.aoLightValueScratchXYPP) / 4.0F; + f4 = (f7 + this.aoLightValueScratchYZPN + this.aoLightValueScratchXYPP + this.aoLightValueScratchXYZPPN) / 4.0F; + f5 = (this.aoLightValueScratchXYNP + this.aoLightValueScratchXYZNPN + f7 + this.aoLightValueScratchYZPN) / 4.0F; + this.brightnessTopRight = this.getAoBrightness(this.aoBrightnessXYZNPP, this.aoBrightnessXYNP, this.aoBrightnessYZPP, i1); + this.brightnessTopLeft = this.getAoBrightness(this.aoBrightnessYZPP, this.aoBrightnessXYZPPP, this.aoBrightnessXYPP, i1); + this.brightnessBottomLeft = this.getAoBrightness(this.aoBrightnessYZPN, this.aoBrightnessXYPP, this.aoBrightnessXYZPPN, i1); + this.brightnessBottomRight = this.getAoBrightness(this.aoBrightnessXYNP, this.aoBrightnessXYZNPN, this.aoBrightnessYZPN, i1); + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = p_147808_5_; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = p_147808_6_; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = p_147808_7_; + this.colorRedTopLeft *= f3; + this.colorGreenTopLeft *= f3; + this.colorBlueTopLeft *= f3; + this.colorRedBottomLeft *= f4; + this.colorGreenBottomLeft *= f4; + this.colorBlueBottomLeft *= f4; + this.colorRedBottomRight *= f5; + this.colorGreenBottomRight *= f5; + this.colorBlueBottomRight *= f5; + this.colorRedTopRight *= f6; + this.colorGreenTopRight *= f6; + this.colorBlueTopRight *= f6; + this.renderFaceYPos(p_147808_1_, (double)p_147808_2_, (double)p_147808_3_, (double)p_147808_4_, this.getBlockIcon(p_147808_1_, this.blockAccess, p_147808_2_, p_147808_3_, p_147808_4_, 1)); + flag = true; + } + + float f8; + float f9; + float f10; + float f11; + int j1; + int k1; + int l1; + int i2; + IIcon iicon; + + if (this.renderAllFaces || p_147808_1_.shouldSideBeRendered(this.blockAccess, p_147808_2_, p_147808_3_, p_147808_4_ - 1, 2)) + { + if (this.renderMinZ <= 0.0D) + { + --p_147808_4_; + } + + this.aoLightValueScratchXZNN = this.blockAccess.getBlock(p_147808_2_ - 1, p_147808_3_, p_147808_4_).getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZNN = this.blockAccess.getBlock(p_147808_2_, p_147808_3_ - 1, p_147808_4_).getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZPN = this.blockAccess.getBlock(p_147808_2_, p_147808_3_ + 1, p_147808_4_).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXZPN = this.blockAccess.getBlock(p_147808_2_ + 1, p_147808_3_, p_147808_4_).getAmbientOcclusionLightValue(); + this.aoBrightnessXZNN = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_ - 1, p_147808_3_, p_147808_4_); + this.aoBrightnessYZNN = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_, p_147808_3_ - 1, p_147808_4_); + this.aoBrightnessYZPN = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_, p_147808_3_ + 1, p_147808_4_); + this.aoBrightnessXZPN = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_ + 1, p_147808_3_, p_147808_4_); + flag2 = this.blockAccess.getBlock(p_147808_2_ + 1, p_147808_3_, p_147808_4_ - 1).getCanBlockGrass(); + flag3 = this.blockAccess.getBlock(p_147808_2_ - 1, p_147808_3_, p_147808_4_ - 1).getCanBlockGrass(); + flag4 = this.blockAccess.getBlock(p_147808_2_, p_147808_3_ + 1, p_147808_4_ - 1).getCanBlockGrass(); + flag5 = this.blockAccess.getBlock(p_147808_2_, p_147808_3_ - 1, p_147808_4_ - 1).getCanBlockGrass(); + + if (!flag3 && !flag5) + { + this.aoLightValueScratchXYZNNN = this.aoLightValueScratchXZNN; + this.aoBrightnessXYZNNN = this.aoBrightnessXZNN; + } + else + { + this.aoLightValueScratchXYZNNN = this.blockAccess.getBlock(p_147808_2_ - 1, p_147808_3_ - 1, p_147808_4_).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNNN = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_ - 1, p_147808_3_ - 1, p_147808_4_); + } + + if (!flag3 && !flag4) + { + this.aoLightValueScratchXYZNPN = this.aoLightValueScratchXZNN; + this.aoBrightnessXYZNPN = this.aoBrightnessXZNN; + } + else + { + this.aoLightValueScratchXYZNPN = this.blockAccess.getBlock(p_147808_2_ - 1, p_147808_3_ + 1, p_147808_4_).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNPN = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_ - 1, p_147808_3_ + 1, p_147808_4_); + } + + if (!flag2 && !flag5) + { + this.aoLightValueScratchXYZPNN = this.aoLightValueScratchXZPN; + this.aoBrightnessXYZPNN = this.aoBrightnessXZPN; + } + else + { + this.aoLightValueScratchXYZPNN = this.blockAccess.getBlock(p_147808_2_ + 1, p_147808_3_ - 1, p_147808_4_).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPNN = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_ + 1, p_147808_3_ - 1, p_147808_4_); + } + + if (!flag2 && !flag4) + { + this.aoLightValueScratchXYZPPN = this.aoLightValueScratchXZPN; + this.aoBrightnessXYZPPN = this.aoBrightnessXZPN; + } + else + { + this.aoLightValueScratchXYZPPN = this.blockAccess.getBlock(p_147808_2_ + 1, p_147808_3_ + 1, p_147808_4_).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPPN = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_ + 1, p_147808_3_ + 1, p_147808_4_); + } + + if (this.renderMinZ <= 0.0D) + { + ++p_147808_4_; + } + + i1 = l; + + if (this.renderMinZ <= 0.0D || !this.blockAccess.getBlock(p_147808_2_, p_147808_3_, p_147808_4_ - 1).isOpaqueCube()) + { + i1 = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_, p_147808_3_, p_147808_4_ - 1); + } + + f7 = this.blockAccess.getBlock(p_147808_2_, p_147808_3_, p_147808_4_ - 1).getAmbientOcclusionLightValue(); + f8 = (this.aoLightValueScratchXZNN + this.aoLightValueScratchXYZNPN + f7 + this.aoLightValueScratchYZPN) / 4.0F; + f9 = (f7 + this.aoLightValueScratchYZPN + this.aoLightValueScratchXZPN + this.aoLightValueScratchXYZPPN) / 4.0F; + f10 = (this.aoLightValueScratchYZNN + f7 + this.aoLightValueScratchXYZPNN + this.aoLightValueScratchXZPN) / 4.0F; + f11 = (this.aoLightValueScratchXYZNNN + this.aoLightValueScratchXZNN + this.aoLightValueScratchYZNN + f7) / 4.0F; + f3 = (float)((double)f8 * this.renderMaxY * (1.0D - this.renderMinX) + (double)f9 * this.renderMaxY * this.renderMinX + (double)f10 * (1.0D - this.renderMaxY) * this.renderMinX + (double)f11 * (1.0D - this.renderMaxY) * (1.0D - this.renderMinX)); + f4 = (float)((double)f8 * this.renderMaxY * (1.0D - this.renderMaxX) + (double)f9 * this.renderMaxY * this.renderMaxX + (double)f10 * (1.0D - this.renderMaxY) * this.renderMaxX + (double)f11 * (1.0D - this.renderMaxY) * (1.0D - this.renderMaxX)); + f5 = (float)((double)f8 * this.renderMinY * (1.0D - this.renderMaxX) + (double)f9 * this.renderMinY * this.renderMaxX + (double)f10 * (1.0D - this.renderMinY) * this.renderMaxX + (double)f11 * (1.0D - this.renderMinY) * (1.0D - this.renderMaxX)); + f6 = (float)((double)f8 * this.renderMinY * (1.0D - this.renderMinX) + (double)f9 * this.renderMinY * this.renderMinX + (double)f10 * (1.0D - this.renderMinY) * this.renderMinX + (double)f11 * (1.0D - this.renderMinY) * (1.0D - this.renderMinX)); + j1 = this.getAoBrightness(this.aoBrightnessXZNN, this.aoBrightnessXYZNPN, this.aoBrightnessYZPN, i1); + k1 = this.getAoBrightness(this.aoBrightnessYZPN, this.aoBrightnessXZPN, this.aoBrightnessXYZPPN, i1); + l1 = this.getAoBrightness(this.aoBrightnessYZNN, this.aoBrightnessXYZPNN, this.aoBrightnessXZPN, i1); + i2 = this.getAoBrightness(this.aoBrightnessXYZNNN, this.aoBrightnessXZNN, this.aoBrightnessYZNN, i1); + this.brightnessTopLeft = this.mixAoBrightness(j1, k1, l1, i2, this.renderMaxY * (1.0D - this.renderMinX), this.renderMaxY * this.renderMinX, (1.0D - this.renderMaxY) * this.renderMinX, (1.0D - this.renderMaxY) * (1.0D - this.renderMinX)); + this.brightnessBottomLeft = this.mixAoBrightness(j1, k1, l1, i2, this.renderMaxY * (1.0D - this.renderMaxX), this.renderMaxY * this.renderMaxX, (1.0D - this.renderMaxY) * this.renderMaxX, (1.0D - this.renderMaxY) * (1.0D - this.renderMaxX)); + this.brightnessBottomRight = this.mixAoBrightness(j1, k1, l1, i2, this.renderMinY * (1.0D - this.renderMaxX), this.renderMinY * this.renderMaxX, (1.0D - this.renderMinY) * this.renderMaxX, (1.0D - this.renderMinY) * (1.0D - this.renderMaxX)); + this.brightnessTopRight = this.mixAoBrightness(j1, k1, l1, i2, this.renderMinY * (1.0D - this.renderMinX), this.renderMinY * this.renderMinX, (1.0D - this.renderMinY) * this.renderMinX, (1.0D - this.renderMinY) * (1.0D - this.renderMinX)); + + if (flag1) + { + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = p_147808_5_ * 0.8F; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = p_147808_6_ * 0.8F; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = p_147808_7_ * 0.8F; + } + else + { + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = 0.8F; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = 0.8F; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = 0.8F; + } + + this.colorRedTopLeft *= f3; + this.colorGreenTopLeft *= f3; + this.colorBlueTopLeft *= f3; + this.colorRedBottomLeft *= f4; + this.colorGreenBottomLeft *= f4; + this.colorBlueBottomLeft *= f4; + this.colorRedBottomRight *= f5; + this.colorGreenBottomRight *= f5; + this.colorBlueBottomRight *= f5; + this.colorRedTopRight *= f6; + this.colorGreenTopRight *= f6; + this.colorBlueTopRight *= f6; + iicon = this.getBlockIcon(p_147808_1_, this.blockAccess, p_147808_2_, p_147808_3_, p_147808_4_, 2); + this.renderFaceZNeg(p_147808_1_, (double)p_147808_2_, (double)p_147808_3_, (double)p_147808_4_, iicon); + + if (fancyGrass && iicon.getIconName().equals("grass_side") && !this.hasOverrideBlockTexture()) + { + this.colorRedTopLeft *= p_147808_5_; + this.colorRedBottomLeft *= p_147808_5_; + this.colorRedBottomRight *= p_147808_5_; + this.colorRedTopRight *= p_147808_5_; + this.colorGreenTopLeft *= p_147808_6_; + this.colorGreenBottomLeft *= p_147808_6_; + this.colorGreenBottomRight *= p_147808_6_; + this.colorGreenTopRight *= p_147808_6_; + this.colorBlueTopLeft *= p_147808_7_; + this.colorBlueBottomLeft *= p_147808_7_; + this.colorBlueBottomRight *= p_147808_7_; + this.colorBlueTopRight *= p_147808_7_; + this.renderFaceZNeg(p_147808_1_, (double)p_147808_2_, (double)p_147808_3_, (double)p_147808_4_, BlockGrass.getIconSideOverlay()); + } + + flag = true; + } + + if (this.renderAllFaces || p_147808_1_.shouldSideBeRendered(this.blockAccess, p_147808_2_, p_147808_3_, p_147808_4_ + 1, 3)) + { + if (this.renderMaxZ >= 1.0D) + { + ++p_147808_4_; + } + + this.aoLightValueScratchXZNP = this.blockAccess.getBlock(p_147808_2_ - 1, p_147808_3_, p_147808_4_).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXZPP = this.blockAccess.getBlock(p_147808_2_ + 1, p_147808_3_, p_147808_4_).getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZNP = this.blockAccess.getBlock(p_147808_2_, p_147808_3_ - 1, p_147808_4_).getAmbientOcclusionLightValue(); + this.aoLightValueScratchYZPP = this.blockAccess.getBlock(p_147808_2_, p_147808_3_ + 1, p_147808_4_).getAmbientOcclusionLightValue(); + this.aoBrightnessXZNP = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_ - 1, p_147808_3_, p_147808_4_); + this.aoBrightnessXZPP = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_ + 1, p_147808_3_, p_147808_4_); + this.aoBrightnessYZNP = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_, p_147808_3_ - 1, p_147808_4_); + this.aoBrightnessYZPP = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_, p_147808_3_ + 1, p_147808_4_); + flag2 = this.blockAccess.getBlock(p_147808_2_ + 1, p_147808_3_, p_147808_4_ + 1).getCanBlockGrass(); + flag3 = this.blockAccess.getBlock(p_147808_2_ - 1, p_147808_3_, p_147808_4_ + 1).getCanBlockGrass(); + flag4 = this.blockAccess.getBlock(p_147808_2_, p_147808_3_ + 1, p_147808_4_ + 1).getCanBlockGrass(); + flag5 = this.blockAccess.getBlock(p_147808_2_, p_147808_3_ - 1, p_147808_4_ + 1).getCanBlockGrass(); + + if (!flag3 && !flag5) + { + this.aoLightValueScratchXYZNNP = this.aoLightValueScratchXZNP; + this.aoBrightnessXYZNNP = this.aoBrightnessXZNP; + } + else + { + this.aoLightValueScratchXYZNNP = this.blockAccess.getBlock(p_147808_2_ - 1, p_147808_3_ - 1, p_147808_4_).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNNP = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_ - 1, p_147808_3_ - 1, p_147808_4_); + } + + if (!flag3 && !flag4) + { + this.aoLightValueScratchXYZNPP = this.aoLightValueScratchXZNP; + this.aoBrightnessXYZNPP = this.aoBrightnessXZNP; + } + else + { + this.aoLightValueScratchXYZNPP = this.blockAccess.getBlock(p_147808_2_ - 1, p_147808_3_ + 1, p_147808_4_).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNPP = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_ - 1, p_147808_3_ + 1, p_147808_4_); + } + + if (!flag2 && !flag5) + { + this.aoLightValueScratchXYZPNP = this.aoLightValueScratchXZPP; + this.aoBrightnessXYZPNP = this.aoBrightnessXZPP; + } + else + { + this.aoLightValueScratchXYZPNP = this.blockAccess.getBlock(p_147808_2_ + 1, p_147808_3_ - 1, p_147808_4_).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPNP = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_ + 1, p_147808_3_ - 1, p_147808_4_); + } + + if (!flag2 && !flag4) + { + this.aoLightValueScratchXYZPPP = this.aoLightValueScratchXZPP; + this.aoBrightnessXYZPPP = this.aoBrightnessXZPP; + } + else + { + this.aoLightValueScratchXYZPPP = this.blockAccess.getBlock(p_147808_2_ + 1, p_147808_3_ + 1, p_147808_4_).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPPP = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_ + 1, p_147808_3_ + 1, p_147808_4_); + } + + if (this.renderMaxZ >= 1.0D) + { + --p_147808_4_; + } + + i1 = l; + + if (this.renderMaxZ >= 1.0D || !this.blockAccess.getBlock(p_147808_2_, p_147808_3_, p_147808_4_ + 1).isOpaqueCube()) + { + i1 = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_, p_147808_3_, p_147808_4_ + 1); + } + + f7 = this.blockAccess.getBlock(p_147808_2_, p_147808_3_, p_147808_4_ + 1).getAmbientOcclusionLightValue(); + f8 = (this.aoLightValueScratchXZNP + this.aoLightValueScratchXYZNPP + f7 + this.aoLightValueScratchYZPP) / 4.0F; + f9 = (f7 + this.aoLightValueScratchYZPP + this.aoLightValueScratchXZPP + this.aoLightValueScratchXYZPPP) / 4.0F; + f10 = (this.aoLightValueScratchYZNP + f7 + this.aoLightValueScratchXYZPNP + this.aoLightValueScratchXZPP) / 4.0F; + f11 = (this.aoLightValueScratchXYZNNP + this.aoLightValueScratchXZNP + this.aoLightValueScratchYZNP + f7) / 4.0F; + f3 = (float)((double)f8 * this.renderMaxY * (1.0D - this.renderMinX) + (double)f9 * this.renderMaxY * this.renderMinX + (double)f10 * (1.0D - this.renderMaxY) * this.renderMinX + (double)f11 * (1.0D - this.renderMaxY) * (1.0D - this.renderMinX)); + f4 = (float)((double)f8 * this.renderMinY * (1.0D - this.renderMinX) + (double)f9 * this.renderMinY * this.renderMinX + (double)f10 * (1.0D - this.renderMinY) * this.renderMinX + (double)f11 * (1.0D - this.renderMinY) * (1.0D - this.renderMinX)); + f5 = (float)((double)f8 * this.renderMinY * (1.0D - this.renderMaxX) + (double)f9 * this.renderMinY * this.renderMaxX + (double)f10 * (1.0D - this.renderMinY) * this.renderMaxX + (double)f11 * (1.0D - this.renderMinY) * (1.0D - this.renderMaxX)); + f6 = (float)((double)f8 * this.renderMaxY * (1.0D - this.renderMaxX) + (double)f9 * this.renderMaxY * this.renderMaxX + (double)f10 * (1.0D - this.renderMaxY) * this.renderMaxX + (double)f11 * (1.0D - this.renderMaxY) * (1.0D - this.renderMaxX)); + j1 = this.getAoBrightness(this.aoBrightnessXZNP, this.aoBrightnessXYZNPP, this.aoBrightnessYZPP, i1); + k1 = this.getAoBrightness(this.aoBrightnessYZPP, this.aoBrightnessXZPP, this.aoBrightnessXYZPPP, i1); + l1 = this.getAoBrightness(this.aoBrightnessYZNP, this.aoBrightnessXYZPNP, this.aoBrightnessXZPP, i1); + i2 = this.getAoBrightness(this.aoBrightnessXYZNNP, this.aoBrightnessXZNP, this.aoBrightnessYZNP, i1); + this.brightnessTopLeft = this.mixAoBrightness(j1, i2, l1, k1, this.renderMaxY * (1.0D - this.renderMinX), (1.0D - this.renderMaxY) * (1.0D - this.renderMinX), (1.0D - this.renderMaxY) * this.renderMinX, this.renderMaxY * this.renderMinX); + this.brightnessBottomLeft = this.mixAoBrightness(j1, i2, l1, k1, this.renderMinY * (1.0D - this.renderMinX), (1.0D - this.renderMinY) * (1.0D - this.renderMinX), (1.0D - this.renderMinY) * this.renderMinX, this.renderMinY * this.renderMinX); + this.brightnessBottomRight = this.mixAoBrightness(j1, i2, l1, k1, this.renderMinY * (1.0D - this.renderMaxX), (1.0D - this.renderMinY) * (1.0D - this.renderMaxX), (1.0D - this.renderMinY) * this.renderMaxX, this.renderMinY * this.renderMaxX); + this.brightnessTopRight = this.mixAoBrightness(j1, i2, l1, k1, this.renderMaxY * (1.0D - this.renderMaxX), (1.0D - this.renderMaxY) * (1.0D - this.renderMaxX), (1.0D - this.renderMaxY) * this.renderMaxX, this.renderMaxY * this.renderMaxX); + + if (flag1) + { + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = p_147808_5_ * 0.8F; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = p_147808_6_ * 0.8F; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = p_147808_7_ * 0.8F; + } + else + { + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = 0.8F; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = 0.8F; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = 0.8F; + } + + this.colorRedTopLeft *= f3; + this.colorGreenTopLeft *= f3; + this.colorBlueTopLeft *= f3; + this.colorRedBottomLeft *= f4; + this.colorGreenBottomLeft *= f4; + this.colorBlueBottomLeft *= f4; + this.colorRedBottomRight *= f5; + this.colorGreenBottomRight *= f5; + this.colorBlueBottomRight *= f5; + this.colorRedTopRight *= f6; + this.colorGreenTopRight *= f6; + this.colorBlueTopRight *= f6; + iicon = this.getBlockIcon(p_147808_1_, this.blockAccess, p_147808_2_, p_147808_3_, p_147808_4_, 3); + this.renderFaceZPos(p_147808_1_, (double)p_147808_2_, (double)p_147808_3_, (double)p_147808_4_, iicon); + + if (fancyGrass && iicon.getIconName().equals("grass_side") && !this.hasOverrideBlockTexture()) + { + this.colorRedTopLeft *= p_147808_5_; + this.colorRedBottomLeft *= p_147808_5_; + this.colorRedBottomRight *= p_147808_5_; + this.colorRedTopRight *= p_147808_5_; + this.colorGreenTopLeft *= p_147808_6_; + this.colorGreenBottomLeft *= p_147808_6_; + this.colorGreenBottomRight *= p_147808_6_; + this.colorGreenTopRight *= p_147808_6_; + this.colorBlueTopLeft *= p_147808_7_; + this.colorBlueBottomLeft *= p_147808_7_; + this.colorBlueBottomRight *= p_147808_7_; + this.colorBlueTopRight *= p_147808_7_; + this.renderFaceZPos(p_147808_1_, (double)p_147808_2_, (double)p_147808_3_, (double)p_147808_4_, BlockGrass.getIconSideOverlay()); + } + + flag = true; + } + + if (this.renderAllFaces || p_147808_1_.shouldSideBeRendered(this.blockAccess, p_147808_2_ - 1, p_147808_3_, p_147808_4_, 4)) + { + if (this.renderMinX <= 0.0D) + { + --p_147808_2_; + } + + this.aoLightValueScratchXYNN = this.blockAccess.getBlock(p_147808_2_, p_147808_3_ - 1, p_147808_4_).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXZNN = this.blockAccess.getBlock(p_147808_2_, p_147808_3_, p_147808_4_ - 1).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXZNP = this.blockAccess.getBlock(p_147808_2_, p_147808_3_, p_147808_4_ + 1).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXYNP = this.blockAccess.getBlock(p_147808_2_, p_147808_3_ + 1, p_147808_4_).getAmbientOcclusionLightValue(); + this.aoBrightnessXYNN = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_, p_147808_3_ - 1, p_147808_4_); + this.aoBrightnessXZNN = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_, p_147808_3_, p_147808_4_ - 1); + this.aoBrightnessXZNP = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_, p_147808_3_, p_147808_4_ + 1); + this.aoBrightnessXYNP = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_, p_147808_3_ + 1, p_147808_4_); + flag2 = this.blockAccess.getBlock(p_147808_2_ - 1, p_147808_3_ + 1, p_147808_4_).getCanBlockGrass(); + flag3 = this.blockAccess.getBlock(p_147808_2_ - 1, p_147808_3_ - 1, p_147808_4_).getCanBlockGrass(); + flag4 = this.blockAccess.getBlock(p_147808_2_ - 1, p_147808_3_, p_147808_4_ - 1).getCanBlockGrass(); + flag5 = this.blockAccess.getBlock(p_147808_2_ - 1, p_147808_3_, p_147808_4_ + 1).getCanBlockGrass(); + + if (!flag4 && !flag3) + { + this.aoLightValueScratchXYZNNN = this.aoLightValueScratchXZNN; + this.aoBrightnessXYZNNN = this.aoBrightnessXZNN; + } + else + { + this.aoLightValueScratchXYZNNN = this.blockAccess.getBlock(p_147808_2_, p_147808_3_ - 1, p_147808_4_ - 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNNN = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_, p_147808_3_ - 1, p_147808_4_ - 1); + } + + if (!flag5 && !flag3) + { + this.aoLightValueScratchXYZNNP = this.aoLightValueScratchXZNP; + this.aoBrightnessXYZNNP = this.aoBrightnessXZNP; + } + else + { + this.aoLightValueScratchXYZNNP = this.blockAccess.getBlock(p_147808_2_, p_147808_3_ - 1, p_147808_4_ + 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNNP = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_, p_147808_3_ - 1, p_147808_4_ + 1); + } + + if (!flag4 && !flag2) + { + this.aoLightValueScratchXYZNPN = this.aoLightValueScratchXZNN; + this.aoBrightnessXYZNPN = this.aoBrightnessXZNN; + } + else + { + this.aoLightValueScratchXYZNPN = this.blockAccess.getBlock(p_147808_2_, p_147808_3_ + 1, p_147808_4_ - 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNPN = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_, p_147808_3_ + 1, p_147808_4_ - 1); + } + + if (!flag5 && !flag2) + { + this.aoLightValueScratchXYZNPP = this.aoLightValueScratchXZNP; + this.aoBrightnessXYZNPP = this.aoBrightnessXZNP; + } + else + { + this.aoLightValueScratchXYZNPP = this.blockAccess.getBlock(p_147808_2_, p_147808_3_ + 1, p_147808_4_ + 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZNPP = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_, p_147808_3_ + 1, p_147808_4_ + 1); + } + + if (this.renderMinX <= 0.0D) + { + ++p_147808_2_; + } + + i1 = l; + + if (this.renderMinX <= 0.0D || !this.blockAccess.getBlock(p_147808_2_ - 1, p_147808_3_, p_147808_4_).isOpaqueCube()) + { + i1 = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_ - 1, p_147808_3_, p_147808_4_); + } + + f7 = this.blockAccess.getBlock(p_147808_2_ - 1, p_147808_3_, p_147808_4_).getAmbientOcclusionLightValue(); + f8 = (this.aoLightValueScratchXYNN + this.aoLightValueScratchXYZNNP + f7 + this.aoLightValueScratchXZNP) / 4.0F; + f9 = (f7 + this.aoLightValueScratchXZNP + this.aoLightValueScratchXYNP + this.aoLightValueScratchXYZNPP) / 4.0F; + f10 = (this.aoLightValueScratchXZNN + f7 + this.aoLightValueScratchXYZNPN + this.aoLightValueScratchXYNP) / 4.0F; + f11 = (this.aoLightValueScratchXYZNNN + this.aoLightValueScratchXYNN + this.aoLightValueScratchXZNN + f7) / 4.0F; + f3 = (float)((double)f9 * this.renderMaxY * this.renderMaxZ + (double)f10 * this.renderMaxY * (1.0D - this.renderMaxZ) + (double)f11 * (1.0D - this.renderMaxY) * (1.0D - this.renderMaxZ) + (double)f8 * (1.0D - this.renderMaxY) * this.renderMaxZ); + f4 = (float)((double)f9 * this.renderMaxY * this.renderMinZ + (double)f10 * this.renderMaxY * (1.0D - this.renderMinZ) + (double)f11 * (1.0D - this.renderMaxY) * (1.0D - this.renderMinZ) + (double)f8 * (1.0D - this.renderMaxY) * this.renderMinZ); + f5 = (float)((double)f9 * this.renderMinY * this.renderMinZ + (double)f10 * this.renderMinY * (1.0D - this.renderMinZ) + (double)f11 * (1.0D - this.renderMinY) * (1.0D - this.renderMinZ) + (double)f8 * (1.0D - this.renderMinY) * this.renderMinZ); + f6 = (float)((double)f9 * this.renderMinY * this.renderMaxZ + (double)f10 * this.renderMinY * (1.0D - this.renderMaxZ) + (double)f11 * (1.0D - this.renderMinY) * (1.0D - this.renderMaxZ) + (double)f8 * (1.0D - this.renderMinY) * this.renderMaxZ); + j1 = this.getAoBrightness(this.aoBrightnessXYNN, this.aoBrightnessXYZNNP, this.aoBrightnessXZNP, i1); + k1 = this.getAoBrightness(this.aoBrightnessXZNP, this.aoBrightnessXYNP, this.aoBrightnessXYZNPP, i1); + l1 = this.getAoBrightness(this.aoBrightnessXZNN, this.aoBrightnessXYZNPN, this.aoBrightnessXYNP, i1); + i2 = this.getAoBrightness(this.aoBrightnessXYZNNN, this.aoBrightnessXYNN, this.aoBrightnessXZNN, i1); + this.brightnessTopLeft = this.mixAoBrightness(k1, l1, i2, j1, this.renderMaxY * this.renderMaxZ, this.renderMaxY * (1.0D - this.renderMaxZ), (1.0D - this.renderMaxY) * (1.0D - this.renderMaxZ), (1.0D - this.renderMaxY) * this.renderMaxZ); + this.brightnessBottomLeft = this.mixAoBrightness(k1, l1, i2, j1, this.renderMaxY * this.renderMinZ, this.renderMaxY * (1.0D - this.renderMinZ), (1.0D - this.renderMaxY) * (1.0D - this.renderMinZ), (1.0D - this.renderMaxY) * this.renderMinZ); + this.brightnessBottomRight = this.mixAoBrightness(k1, l1, i2, j1, this.renderMinY * this.renderMinZ, this.renderMinY * (1.0D - this.renderMinZ), (1.0D - this.renderMinY) * (1.0D - this.renderMinZ), (1.0D - this.renderMinY) * this.renderMinZ); + this.brightnessTopRight = this.mixAoBrightness(k1, l1, i2, j1, this.renderMinY * this.renderMaxZ, this.renderMinY * (1.0D - this.renderMaxZ), (1.0D - this.renderMinY) * (1.0D - this.renderMaxZ), (1.0D - this.renderMinY) * this.renderMaxZ); + + if (flag1) + { + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = p_147808_5_ * 0.6F; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = p_147808_6_ * 0.6F; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = p_147808_7_ * 0.6F; + } + else + { + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = 0.6F; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = 0.6F; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = 0.6F; + } + + this.colorRedTopLeft *= f3; + this.colorGreenTopLeft *= f3; + this.colorBlueTopLeft *= f3; + this.colorRedBottomLeft *= f4; + this.colorGreenBottomLeft *= f4; + this.colorBlueBottomLeft *= f4; + this.colorRedBottomRight *= f5; + this.colorGreenBottomRight *= f5; + this.colorBlueBottomRight *= f5; + this.colorRedTopRight *= f6; + this.colorGreenTopRight *= f6; + this.colorBlueTopRight *= f6; + iicon = this.getBlockIcon(p_147808_1_, this.blockAccess, p_147808_2_, p_147808_3_, p_147808_4_, 4); + this.renderFaceXNeg(p_147808_1_, (double)p_147808_2_, (double)p_147808_3_, (double)p_147808_4_, iicon); + + if (fancyGrass && iicon.getIconName().equals("grass_side") && !this.hasOverrideBlockTexture()) + { + this.colorRedTopLeft *= p_147808_5_; + this.colorRedBottomLeft *= p_147808_5_; + this.colorRedBottomRight *= p_147808_5_; + this.colorRedTopRight *= p_147808_5_; + this.colorGreenTopLeft *= p_147808_6_; + this.colorGreenBottomLeft *= p_147808_6_; + this.colorGreenBottomRight *= p_147808_6_; + this.colorGreenTopRight *= p_147808_6_; + this.colorBlueTopLeft *= p_147808_7_; + this.colorBlueBottomLeft *= p_147808_7_; + this.colorBlueBottomRight *= p_147808_7_; + this.colorBlueTopRight *= p_147808_7_; + this.renderFaceXNeg(p_147808_1_, (double)p_147808_2_, (double)p_147808_3_, (double)p_147808_4_, BlockGrass.getIconSideOverlay()); + } + + flag = true; + } + + if (this.renderAllFaces || p_147808_1_.shouldSideBeRendered(this.blockAccess, p_147808_2_ + 1, p_147808_3_, p_147808_4_, 5)) + { + if (this.renderMaxX >= 1.0D) + { + ++p_147808_2_; + } + + this.aoLightValueScratchXYPN = this.blockAccess.getBlock(p_147808_2_, p_147808_3_ - 1, p_147808_4_).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXZPN = this.blockAccess.getBlock(p_147808_2_, p_147808_3_, p_147808_4_ - 1).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXZPP = this.blockAccess.getBlock(p_147808_2_, p_147808_3_, p_147808_4_ + 1).getAmbientOcclusionLightValue(); + this.aoLightValueScratchXYPP = this.blockAccess.getBlock(p_147808_2_, p_147808_3_ + 1, p_147808_4_).getAmbientOcclusionLightValue(); + this.aoBrightnessXYPN = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_, p_147808_3_ - 1, p_147808_4_); + this.aoBrightnessXZPN = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_, p_147808_3_, p_147808_4_ - 1); + this.aoBrightnessXZPP = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_, p_147808_3_, p_147808_4_ + 1); + this.aoBrightnessXYPP = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_, p_147808_3_ + 1, p_147808_4_); + flag2 = this.blockAccess.getBlock(p_147808_2_ + 1, p_147808_3_ + 1, p_147808_4_).getCanBlockGrass(); + flag3 = this.blockAccess.getBlock(p_147808_2_ + 1, p_147808_3_ - 1, p_147808_4_).getCanBlockGrass(); + flag4 = this.blockAccess.getBlock(p_147808_2_ + 1, p_147808_3_, p_147808_4_ + 1).getCanBlockGrass(); + flag5 = this.blockAccess.getBlock(p_147808_2_ + 1, p_147808_3_, p_147808_4_ - 1).getCanBlockGrass(); + + if (!flag3 && !flag5) + { + this.aoLightValueScratchXYZPNN = this.aoLightValueScratchXZPN; + this.aoBrightnessXYZPNN = this.aoBrightnessXZPN; + } + else + { + this.aoLightValueScratchXYZPNN = this.blockAccess.getBlock(p_147808_2_, p_147808_3_ - 1, p_147808_4_ - 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPNN = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_, p_147808_3_ - 1, p_147808_4_ - 1); + } + + if (!flag3 && !flag4) + { + this.aoLightValueScratchXYZPNP = this.aoLightValueScratchXZPP; + this.aoBrightnessXYZPNP = this.aoBrightnessXZPP; + } + else + { + this.aoLightValueScratchXYZPNP = this.blockAccess.getBlock(p_147808_2_, p_147808_3_ - 1, p_147808_4_ + 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPNP = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_, p_147808_3_ - 1, p_147808_4_ + 1); + } + + if (!flag2 && !flag5) + { + this.aoLightValueScratchXYZPPN = this.aoLightValueScratchXZPN; + this.aoBrightnessXYZPPN = this.aoBrightnessXZPN; + } + else + { + this.aoLightValueScratchXYZPPN = this.blockAccess.getBlock(p_147808_2_, p_147808_3_ + 1, p_147808_4_ - 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPPN = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_, p_147808_3_ + 1, p_147808_4_ - 1); + } + + if (!flag2 && !flag4) + { + this.aoLightValueScratchXYZPPP = this.aoLightValueScratchXZPP; + this.aoBrightnessXYZPPP = this.aoBrightnessXZPP; + } + else + { + this.aoLightValueScratchXYZPPP = this.blockAccess.getBlock(p_147808_2_, p_147808_3_ + 1, p_147808_4_ + 1).getAmbientOcclusionLightValue(); + this.aoBrightnessXYZPPP = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_, p_147808_3_ + 1, p_147808_4_ + 1); + } + + if (this.renderMaxX >= 1.0D) + { + --p_147808_2_; + } + + i1 = l; + + if (this.renderMaxX >= 1.0D || !this.blockAccess.getBlock(p_147808_2_ + 1, p_147808_3_, p_147808_4_).isOpaqueCube()) + { + i1 = p_147808_1_.getMixedBrightnessForBlock(this.blockAccess, p_147808_2_ + 1, p_147808_3_, p_147808_4_); + } + + f7 = this.blockAccess.getBlock(p_147808_2_ + 1, p_147808_3_, p_147808_4_).getAmbientOcclusionLightValue(); + f8 = (this.aoLightValueScratchXYPN + this.aoLightValueScratchXYZPNP + f7 + this.aoLightValueScratchXZPP) / 4.0F; + f9 = (this.aoLightValueScratchXYZPNN + this.aoLightValueScratchXYPN + this.aoLightValueScratchXZPN + f7) / 4.0F; + f10 = (this.aoLightValueScratchXZPN + f7 + this.aoLightValueScratchXYZPPN + this.aoLightValueScratchXYPP) / 4.0F; + f11 = (f7 + this.aoLightValueScratchXZPP + this.aoLightValueScratchXYPP + this.aoLightValueScratchXYZPPP) / 4.0F; + f3 = (float)((double)f8 * (1.0D - this.renderMinY) * this.renderMaxZ + (double)f9 * (1.0D - this.renderMinY) * (1.0D - this.renderMaxZ) + (double)f10 * this.renderMinY * (1.0D - this.renderMaxZ) + (double)f11 * this.renderMinY * this.renderMaxZ); + f4 = (float)((double)f8 * (1.0D - this.renderMinY) * this.renderMinZ + (double)f9 * (1.0D - this.renderMinY) * (1.0D - this.renderMinZ) + (double)f10 * this.renderMinY * (1.0D - this.renderMinZ) + (double)f11 * this.renderMinY * this.renderMinZ); + f5 = (float)((double)f8 * (1.0D - this.renderMaxY) * this.renderMinZ + (double)f9 * (1.0D - this.renderMaxY) * (1.0D - this.renderMinZ) + (double)f10 * this.renderMaxY * (1.0D - this.renderMinZ) + (double)f11 * this.renderMaxY * this.renderMinZ); + f6 = (float)((double)f8 * (1.0D - this.renderMaxY) * this.renderMaxZ + (double)f9 * (1.0D - this.renderMaxY) * (1.0D - this.renderMaxZ) + (double)f10 * this.renderMaxY * (1.0D - this.renderMaxZ) + (double)f11 * this.renderMaxY * this.renderMaxZ); + j1 = this.getAoBrightness(this.aoBrightnessXYPN, this.aoBrightnessXYZPNP, this.aoBrightnessXZPP, i1); + k1 = this.getAoBrightness(this.aoBrightnessXZPP, this.aoBrightnessXYPP, this.aoBrightnessXYZPPP, i1); + l1 = this.getAoBrightness(this.aoBrightnessXZPN, this.aoBrightnessXYZPPN, this.aoBrightnessXYPP, i1); + i2 = this.getAoBrightness(this.aoBrightnessXYZPNN, this.aoBrightnessXYPN, this.aoBrightnessXZPN, i1); + this.brightnessTopLeft = this.mixAoBrightness(j1, i2, l1, k1, (1.0D - this.renderMinY) * this.renderMaxZ, (1.0D - this.renderMinY) * (1.0D - this.renderMaxZ), this.renderMinY * (1.0D - this.renderMaxZ), this.renderMinY * this.renderMaxZ); + this.brightnessBottomLeft = this.mixAoBrightness(j1, i2, l1, k1, (1.0D - this.renderMinY) * this.renderMinZ, (1.0D - this.renderMinY) * (1.0D - this.renderMinZ), this.renderMinY * (1.0D - this.renderMinZ), this.renderMinY * this.renderMinZ); + this.brightnessBottomRight = this.mixAoBrightness(j1, i2, l1, k1, (1.0D - this.renderMaxY) * this.renderMinZ, (1.0D - this.renderMaxY) * (1.0D - this.renderMinZ), this.renderMaxY * (1.0D - this.renderMinZ), this.renderMaxY * this.renderMinZ); + this.brightnessTopRight = this.mixAoBrightness(j1, i2, l1, k1, (1.0D - this.renderMaxY) * this.renderMaxZ, (1.0D - this.renderMaxY) * (1.0D - this.renderMaxZ), this.renderMaxY * (1.0D - this.renderMaxZ), this.renderMaxY * this.renderMaxZ); + + if (flag1) + { + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = p_147808_5_ * 0.6F; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = p_147808_6_ * 0.6F; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = p_147808_7_ * 0.6F; + } + else + { + this.colorRedTopLeft = this.colorRedBottomLeft = this.colorRedBottomRight = this.colorRedTopRight = 0.6F; + this.colorGreenTopLeft = this.colorGreenBottomLeft = this.colorGreenBottomRight = this.colorGreenTopRight = 0.6F; + this.colorBlueTopLeft = this.colorBlueBottomLeft = this.colorBlueBottomRight = this.colorBlueTopRight = 0.6F; + } + + this.colorRedTopLeft *= f3; + this.colorGreenTopLeft *= f3; + this.colorBlueTopLeft *= f3; + this.colorRedBottomLeft *= f4; + this.colorGreenBottomLeft *= f4; + this.colorBlueBottomLeft *= f4; + this.colorRedBottomRight *= f5; + this.colorGreenBottomRight *= f5; + this.colorBlueBottomRight *= f5; + this.colorRedTopRight *= f6; + this.colorGreenTopRight *= f6; + this.colorBlueTopRight *= f6; + iicon = this.getBlockIcon(p_147808_1_, this.blockAccess, p_147808_2_, p_147808_3_, p_147808_4_, 5); + this.renderFaceXPos(p_147808_1_, (double)p_147808_2_, (double)p_147808_3_, (double)p_147808_4_, iicon); + + if (fancyGrass && iicon.getIconName().equals("grass_side") && !this.hasOverrideBlockTexture()) + { + this.colorRedTopLeft *= p_147808_5_; + this.colorRedBottomLeft *= p_147808_5_; + this.colorRedBottomRight *= p_147808_5_; + this.colorRedTopRight *= p_147808_5_; + this.colorGreenTopLeft *= p_147808_6_; + this.colorGreenBottomLeft *= p_147808_6_; + this.colorGreenBottomRight *= p_147808_6_; + this.colorGreenTopRight *= p_147808_6_; + this.colorBlueTopLeft *= p_147808_7_; + this.colorBlueBottomLeft *= p_147808_7_; + this.colorBlueBottomRight *= p_147808_7_; + this.colorBlueTopRight *= p_147808_7_; + this.renderFaceXPos(p_147808_1_, (double)p_147808_2_, (double)p_147808_3_, (double)p_147808_4_, BlockGrass.getIconSideOverlay()); + } + + flag = true; + } + + this.enableAO = false; + return flag; + } + + public int getAoBrightness(int p_147778_1_, int p_147778_2_, int p_147778_3_, int p_147778_4_) + { + if (p_147778_1_ == 0) + { + p_147778_1_ = p_147778_4_; + } + + if (p_147778_2_ == 0) + { + p_147778_2_ = p_147778_4_; + } + + if (p_147778_3_ == 0) + { + p_147778_3_ = p_147778_4_; + } + + return p_147778_1_ + p_147778_2_ + p_147778_3_ + p_147778_4_ >> 2 & 16711935; + } + + public int mixAoBrightness(int p_147727_1_, int p_147727_2_, int p_147727_3_, int p_147727_4_, double p_147727_5_, double p_147727_7_, double p_147727_9_, double p_147727_11_) + { + int i1 = (int)((double)(p_147727_1_ >> 16 & 255) * p_147727_5_ + (double)(p_147727_2_ >> 16 & 255) * p_147727_7_ + (double)(p_147727_3_ >> 16 & 255) * p_147727_9_ + (double)(p_147727_4_ >> 16 & 255) * p_147727_11_) & 255; + int j1 = (int)((double)(p_147727_1_ & 255) * p_147727_5_ + (double)(p_147727_2_ & 255) * p_147727_7_ + (double)(p_147727_3_ & 255) * p_147727_9_ + (double)(p_147727_4_ & 255) * p_147727_11_) & 255; + return i1 << 16 | j1; + } + + public boolean renderStandardBlockWithColorMultiplier(Block p_147736_1_, int p_147736_2_, int p_147736_3_, int p_147736_4_, float p_147736_5_, float p_147736_6_, float p_147736_7_) + { + this.enableAO = false; + Tessellator tessellator = Tessellator.instance; + boolean flag = false; + float f3 = 0.5F; + float f4 = 1.0F; + float f5 = 0.8F; + float f6 = 0.6F; + float f7 = f4 * p_147736_5_; + float f8 = f4 * p_147736_6_; + float f9 = f4 * p_147736_7_; + float f10 = f3; + float f11 = f5; + float f12 = f6; + float f13 = f3; + float f14 = f5; + float f15 = f6; + float f16 = f3; + float f17 = f5; + float f18 = f6; + + if (p_147736_1_ != Blocks.grass) + { + f10 = f3 * p_147736_5_; + f11 = f5 * p_147736_5_; + f12 = f6 * p_147736_5_; + f13 = f3 * p_147736_6_; + f14 = f5 * p_147736_6_; + f15 = f6 * p_147736_6_; + f16 = f3 * p_147736_7_; + f17 = f5 * p_147736_7_; + f18 = f6 * p_147736_7_; + } + + int l = p_147736_1_.getMixedBrightnessForBlock(this.blockAccess, p_147736_2_, p_147736_3_, p_147736_4_); + + if (this.renderAllFaces || p_147736_1_.shouldSideBeRendered(this.blockAccess, p_147736_2_, p_147736_3_ - 1, p_147736_4_, 0)) + { + tessellator.setBrightness(this.renderMinY > 0.0D ? l : p_147736_1_.getMixedBrightnessForBlock(this.blockAccess, p_147736_2_, p_147736_3_ - 1, p_147736_4_)); + tessellator.setColorOpaque_F(f10, f13, f16); + this.renderFaceYNeg(p_147736_1_, (double)p_147736_2_, (double)p_147736_3_, (double)p_147736_4_, this.getBlockIcon(p_147736_1_, this.blockAccess, p_147736_2_, p_147736_3_, p_147736_4_, 0)); + flag = true; + } + + if (this.renderAllFaces || p_147736_1_.shouldSideBeRendered(this.blockAccess, p_147736_2_, p_147736_3_ + 1, p_147736_4_, 1)) + { + tessellator.setBrightness(this.renderMaxY < 1.0D ? l : p_147736_1_.getMixedBrightnessForBlock(this.blockAccess, p_147736_2_, p_147736_3_ + 1, p_147736_4_)); + tessellator.setColorOpaque_F(f7, f8, f9); + this.renderFaceYPos(p_147736_1_, (double)p_147736_2_, (double)p_147736_3_, (double)p_147736_4_, this.getBlockIcon(p_147736_1_, this.blockAccess, p_147736_2_, p_147736_3_, p_147736_4_, 1)); + flag = true; + } + + IIcon iicon; + + if (this.renderAllFaces || p_147736_1_.shouldSideBeRendered(this.blockAccess, p_147736_2_, p_147736_3_, p_147736_4_ - 1, 2)) + { + tessellator.setBrightness(this.renderMinZ > 0.0D ? l : p_147736_1_.getMixedBrightnessForBlock(this.blockAccess, p_147736_2_, p_147736_3_, p_147736_4_ - 1)); + tessellator.setColorOpaque_F(f11, f14, f17); + iicon = this.getBlockIcon(p_147736_1_, this.blockAccess, p_147736_2_, p_147736_3_, p_147736_4_, 2); + this.renderFaceZNeg(p_147736_1_, (double)p_147736_2_, (double)p_147736_3_, (double)p_147736_4_, iicon); + + if (fancyGrass && iicon.getIconName().equals("grass_side") && !this.hasOverrideBlockTexture()) + { + tessellator.setColorOpaque_F(f11 * p_147736_5_, f14 * p_147736_6_, f17 * p_147736_7_); + this.renderFaceZNeg(p_147736_1_, (double)p_147736_2_, (double)p_147736_3_, (double)p_147736_4_, BlockGrass.getIconSideOverlay()); + } + + flag = true; + } + + if (this.renderAllFaces || p_147736_1_.shouldSideBeRendered(this.blockAccess, p_147736_2_, p_147736_3_, p_147736_4_ + 1, 3)) + { + tessellator.setBrightness(this.renderMaxZ < 1.0D ? l : p_147736_1_.getMixedBrightnessForBlock(this.blockAccess, p_147736_2_, p_147736_3_, p_147736_4_ + 1)); + tessellator.setColorOpaque_F(f11, f14, f17); + iicon = this.getBlockIcon(p_147736_1_, this.blockAccess, p_147736_2_, p_147736_3_, p_147736_4_, 3); + this.renderFaceZPos(p_147736_1_, (double)p_147736_2_, (double)p_147736_3_, (double)p_147736_4_, iicon); + + if (fancyGrass && iicon.getIconName().equals("grass_side") && !this.hasOverrideBlockTexture()) + { + tessellator.setColorOpaque_F(f11 * p_147736_5_, f14 * p_147736_6_, f17 * p_147736_7_); + this.renderFaceZPos(p_147736_1_, (double)p_147736_2_, (double)p_147736_3_, (double)p_147736_4_, BlockGrass.getIconSideOverlay()); + } + + flag = true; + } + + if (this.renderAllFaces || p_147736_1_.shouldSideBeRendered(this.blockAccess, p_147736_2_ - 1, p_147736_3_, p_147736_4_, 4)) + { + tessellator.setBrightness(this.renderMinX > 0.0D ? l : p_147736_1_.getMixedBrightnessForBlock(this.blockAccess, p_147736_2_ - 1, p_147736_3_, p_147736_4_)); + tessellator.setColorOpaque_F(f12, f15, f18); + iicon = this.getBlockIcon(p_147736_1_, this.blockAccess, p_147736_2_, p_147736_3_, p_147736_4_, 4); + this.renderFaceXNeg(p_147736_1_, (double)p_147736_2_, (double)p_147736_3_, (double)p_147736_4_, iicon); + + if (fancyGrass && iicon.getIconName().equals("grass_side") && !this.hasOverrideBlockTexture()) + { + tessellator.setColorOpaque_F(f12 * p_147736_5_, f15 * p_147736_6_, f18 * p_147736_7_); + this.renderFaceXNeg(p_147736_1_, (double)p_147736_2_, (double)p_147736_3_, (double)p_147736_4_, BlockGrass.getIconSideOverlay()); + } + + flag = true; + } + + if (this.renderAllFaces || p_147736_1_.shouldSideBeRendered(this.blockAccess, p_147736_2_ + 1, p_147736_3_, p_147736_4_, 5)) + { + tessellator.setBrightness(this.renderMaxX < 1.0D ? l : p_147736_1_.getMixedBrightnessForBlock(this.blockAccess, p_147736_2_ + 1, p_147736_3_, p_147736_4_)); + tessellator.setColorOpaque_F(f12, f15, f18); + iicon = this.getBlockIcon(p_147736_1_, this.blockAccess, p_147736_2_, p_147736_3_, p_147736_4_, 5); + this.renderFaceXPos(p_147736_1_, (double)p_147736_2_, (double)p_147736_3_, (double)p_147736_4_, iicon); + + if (fancyGrass && iicon.getIconName().equals("grass_side") && !this.hasOverrideBlockTexture()) + { + tessellator.setColorOpaque_F(f12 * p_147736_5_, f15 * p_147736_6_, f18 * p_147736_7_); + this.renderFaceXPos(p_147736_1_, (double)p_147736_2_, (double)p_147736_3_, (double)p_147736_4_, BlockGrass.getIconSideOverlay()); + } + + flag = true; + } + + return flag; + } + + public boolean renderBlockCocoa(BlockCocoa p_147772_1_, int p_147772_2_, int p_147772_3_, int p_147772_4_) + { + Tessellator tessellator = Tessellator.instance; + tessellator.setBrightness(p_147772_1_.getMixedBrightnessForBlock(this.blockAccess, p_147772_2_, p_147772_3_, p_147772_4_)); + tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F); + int l = this.blockAccess.getBlockMetadata(p_147772_2_, p_147772_3_, p_147772_4_); + int i1 = BlockDirectional.getDirection(l); + int j1 = BlockCocoa.func_149987_c(l); + IIcon iicon = p_147772_1_.getCocoaIcon(j1); + int k1 = 4 + j1 * 2; + int l1 = 5 + j1 * 2; + double d0 = 15.0D - (double)k1; + double d1 = 15.0D; + double d2 = 4.0D; + double d3 = 4.0D + (double)l1; + double d4 = (double)iicon.getInterpolatedU(d0); + double d5 = (double)iicon.getInterpolatedU(d1); + double d6 = (double)iicon.getInterpolatedV(d2); + double d7 = (double)iicon.getInterpolatedV(d3); + double d8 = 0.0D; + double d9 = 0.0D; + + switch (i1) + { + case 0: + d8 = 8.0D - (double)(k1 / 2); + d9 = 15.0D - (double)k1; + break; + case 1: + d8 = 1.0D; + d9 = 8.0D - (double)(k1 / 2); + break; + case 2: + d8 = 8.0D - (double)(k1 / 2); + d9 = 1.0D; + break; + case 3: + d8 = 15.0D - (double)k1; + d9 = 8.0D - (double)(k1 / 2); + } + + double d10 = (double)p_147772_2_ + d8 / 16.0D; + double d11 = (double)p_147772_2_ + (d8 + (double)k1) / 16.0D; + double d12 = (double)p_147772_3_ + (12.0D - (double)l1) / 16.0D; + double d13 = (double)p_147772_3_ + 0.75D; + double d14 = (double)p_147772_4_ + d9 / 16.0D; + double d15 = (double)p_147772_4_ + (d9 + (double)k1) / 16.0D; + tessellator.addVertexWithUV(d10, d12, d14, d4, d7); + tessellator.addVertexWithUV(d10, d12, d15, d5, d7); + tessellator.addVertexWithUV(d10, d13, d15, d5, d6); + tessellator.addVertexWithUV(d10, d13, d14, d4, d6); + tessellator.addVertexWithUV(d11, d12, d15, d4, d7); + tessellator.addVertexWithUV(d11, d12, d14, d5, d7); + tessellator.addVertexWithUV(d11, d13, d14, d5, d6); + tessellator.addVertexWithUV(d11, d13, d15, d4, d6); + tessellator.addVertexWithUV(d11, d12, d14, d4, d7); + tessellator.addVertexWithUV(d10, d12, d14, d5, d7); + tessellator.addVertexWithUV(d10, d13, d14, d5, d6); + tessellator.addVertexWithUV(d11, d13, d14, d4, d6); + tessellator.addVertexWithUV(d10, d12, d15, d4, d7); + tessellator.addVertexWithUV(d11, d12, d15, d5, d7); + tessellator.addVertexWithUV(d11, d13, d15, d5, d6); + tessellator.addVertexWithUV(d10, d13, d15, d4, d6); + int i2 = k1; + + if (j1 >= 2) + { + i2 = k1 - 1; + } + + d4 = (double)iicon.getMinU(); + d5 = (double)iicon.getInterpolatedU((double)i2); + d6 = (double)iicon.getMinV(); + d7 = (double)iicon.getInterpolatedV((double)i2); + tessellator.addVertexWithUV(d10, d13, d15, d4, d7); + tessellator.addVertexWithUV(d11, d13, d15, d5, d7); + tessellator.addVertexWithUV(d11, d13, d14, d5, d6); + tessellator.addVertexWithUV(d10, d13, d14, d4, d6); + tessellator.addVertexWithUV(d10, d12, d14, d4, d6); + tessellator.addVertexWithUV(d11, d12, d14, d5, d6); + tessellator.addVertexWithUV(d11, d12, d15, d5, d7); + tessellator.addVertexWithUV(d10, d12, d15, d4, d7); + d4 = (double)iicon.getInterpolatedU(12.0D); + d5 = (double)iicon.getMaxU(); + d6 = (double)iicon.getMinV(); + d7 = (double)iicon.getInterpolatedV(4.0D); + d8 = 8.0D; + d9 = 0.0D; + double d16; + + switch (i1) + { + case 0: + d8 = 8.0D; + d9 = 12.0D; + d16 = d4; + d4 = d5; + d5 = d16; + break; + case 1: + d8 = 0.0D; + d9 = 8.0D; + break; + case 2: + d8 = 8.0D; + d9 = 0.0D; + break; + case 3: + d8 = 12.0D; + d9 = 8.0D; + d16 = d4; + d4 = d5; + d5 = d16; + } + + d10 = (double)p_147772_2_ + d8 / 16.0D; + d11 = (double)p_147772_2_ + (d8 + 4.0D) / 16.0D; + d12 = (double)p_147772_3_ + 0.75D; + d13 = (double)p_147772_3_ + 1.0D; + d14 = (double)p_147772_4_ + d9 / 16.0D; + d15 = (double)p_147772_4_ + (d9 + 4.0D) / 16.0D; + + if (i1 != 2 && i1 != 0) + { + if (i1 == 1 || i1 == 3) + { + tessellator.addVertexWithUV(d11, d12, d14, d4, d7); + tessellator.addVertexWithUV(d10, d12, d14, d5, d7); + tessellator.addVertexWithUV(d10, d13, d14, d5, d6); + tessellator.addVertexWithUV(d11, d13, d14, d4, d6); + tessellator.addVertexWithUV(d10, d12, d14, d5, d7); + tessellator.addVertexWithUV(d11, d12, d14, d4, d7); + tessellator.addVertexWithUV(d11, d13, d14, d4, d6); + tessellator.addVertexWithUV(d10, d13, d14, d5, d6); + } + } + else + { + tessellator.addVertexWithUV(d10, d12, d14, d5, d7); + tessellator.addVertexWithUV(d10, d12, d15, d4, d7); + tessellator.addVertexWithUV(d10, d13, d15, d4, d6); + tessellator.addVertexWithUV(d10, d13, d14, d5, d6); + tessellator.addVertexWithUV(d10, d12, d15, d4, d7); + tessellator.addVertexWithUV(d10, d12, d14, d5, d7); + tessellator.addVertexWithUV(d10, d13, d14, d5, d6); + tessellator.addVertexWithUV(d10, d13, d15, d4, d6); + } + + return true; + } + + public boolean renderBlockBeacon(BlockBeacon p_147797_1_, int p_147797_2_, int p_147797_3_, int p_147797_4_) + { + float f = 0.1875F; + this.setOverrideBlockTexture(this.getBlockIcon(Blocks.glass)); + this.setRenderBounds(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D); + this.renderStandardBlock(p_147797_1_, p_147797_2_, p_147797_3_, p_147797_4_); + this.renderAllFaces = true; + this.setOverrideBlockTexture(this.getBlockIcon(Blocks.obsidian)); + this.setRenderBounds(0.125D, 0.0062500000931322575D, 0.125D, 0.875D, (double)f, 0.875D); + this.renderStandardBlock(p_147797_1_, p_147797_2_, p_147797_3_, p_147797_4_); + this.setOverrideBlockTexture(this.getBlockIcon(Blocks.beacon)); + this.setRenderBounds(0.1875D, (double)f, 0.1875D, 0.8125D, 0.875D, 0.8125D); + this.renderStandardBlock(p_147797_1_, p_147797_2_, p_147797_3_, p_147797_4_); + this.renderAllFaces = false; + this.clearOverrideBlockTexture(); + return true; + } + + public boolean renderBlockCactus(Block p_147755_1_, int p_147755_2_, int p_147755_3_, int p_147755_4_) + { + int l = p_147755_1_.colorMultiplier(this.blockAccess, p_147755_2_, p_147755_3_, p_147755_4_); + float f = (float)(l >> 16 & 255) / 255.0F; + float f1 = (float)(l >> 8 & 255) / 255.0F; + float f2 = (float)(l & 255) / 255.0F; + + if (EntityRenderer.anaglyphEnable) + { + float f3 = (f * 30.0F + f1 * 59.0F + f2 * 11.0F) / 100.0F; + float f4 = (f * 30.0F + f1 * 70.0F) / 100.0F; + float f5 = (f * 30.0F + f2 * 70.0F) / 100.0F; + f = f3; + f1 = f4; + f2 = f5; + } + + return this.renderBlockCactusImpl(p_147755_1_, p_147755_2_, p_147755_3_, p_147755_4_, f, f1, f2); + } + + public boolean renderBlockCactusImpl(Block p_147754_1_, int p_147754_2_, int p_147754_3_, int p_147754_4_, float p_147754_5_, float p_147754_6_, float p_147754_7_) + { + Tessellator tessellator = Tessellator.instance; + boolean flag = false; + float f3 = 0.5F; + float f4 = 1.0F; + float f5 = 0.8F; + float f6 = 0.6F; + float f7 = f3 * p_147754_5_; + float f8 = f4 * p_147754_5_; + float f9 = f5 * p_147754_5_; + float f10 = f6 * p_147754_5_; + float f11 = f3 * p_147754_6_; + float f12 = f4 * p_147754_6_; + float f13 = f5 * p_147754_6_; + float f14 = f6 * p_147754_6_; + float f15 = f3 * p_147754_7_; + float f16 = f4 * p_147754_7_; + float f17 = f5 * p_147754_7_; + float f18 = f6 * p_147754_7_; + float f19 = 0.0625F; + int l = p_147754_1_.getMixedBrightnessForBlock(this.blockAccess, p_147754_2_, p_147754_3_, p_147754_4_); + + if (this.renderAllFaces || p_147754_1_.shouldSideBeRendered(this.blockAccess, p_147754_2_, p_147754_3_ - 1, p_147754_4_, 0)) + { + tessellator.setBrightness(this.renderMinY > 0.0D ? l : p_147754_1_.getMixedBrightnessForBlock(this.blockAccess, p_147754_2_, p_147754_3_ - 1, p_147754_4_)); + tessellator.setColorOpaque_F(f7, f11, f15); + this.renderFaceYNeg(p_147754_1_, (double)p_147754_2_, (double)p_147754_3_, (double)p_147754_4_, this.getBlockIcon(p_147754_1_, this.blockAccess, p_147754_2_, p_147754_3_, p_147754_4_, 0)); + } + + if (this.renderAllFaces || p_147754_1_.shouldSideBeRendered(this.blockAccess, p_147754_2_, p_147754_3_ + 1, p_147754_4_, 1)) + { + tessellator.setBrightness(this.renderMaxY < 1.0D ? l : p_147754_1_.getMixedBrightnessForBlock(this.blockAccess, p_147754_2_, p_147754_3_ + 1, p_147754_4_)); + tessellator.setColorOpaque_F(f8, f12, f16); + this.renderFaceYPos(p_147754_1_, (double)p_147754_2_, (double)p_147754_3_, (double)p_147754_4_, this.getBlockIcon(p_147754_1_, this.blockAccess, p_147754_2_, p_147754_3_, p_147754_4_, 1)); + } + + tessellator.setBrightness(l); + tessellator.setColorOpaque_F(f9, f13, f17); + tessellator.addTranslation(0.0F, 0.0F, f19); + this.renderFaceZNeg(p_147754_1_, (double)p_147754_2_, (double)p_147754_3_, (double)p_147754_4_, this.getBlockIcon(p_147754_1_, this.blockAccess, p_147754_2_, p_147754_3_, p_147754_4_, 2)); + tessellator.addTranslation(0.0F, 0.0F, -f19); + tessellator.addTranslation(0.0F, 0.0F, -f19); + this.renderFaceZPos(p_147754_1_, (double)p_147754_2_, (double)p_147754_3_, (double)p_147754_4_, this.getBlockIcon(p_147754_1_, this.blockAccess, p_147754_2_, p_147754_3_, p_147754_4_, 3)); + tessellator.addTranslation(0.0F, 0.0F, f19); + tessellator.setColorOpaque_F(f10, f14, f18); + tessellator.addTranslation(f19, 0.0F, 0.0F); + this.renderFaceXNeg(p_147754_1_, (double)p_147754_2_, (double)p_147754_3_, (double)p_147754_4_, this.getBlockIcon(p_147754_1_, this.blockAccess, p_147754_2_, p_147754_3_, p_147754_4_, 4)); + tessellator.addTranslation(-f19, 0.0F, 0.0F); + tessellator.addTranslation(-f19, 0.0F, 0.0F); + this.renderFaceXPos(p_147754_1_, (double)p_147754_2_, (double)p_147754_3_, (double)p_147754_4_, this.getBlockIcon(p_147754_1_, this.blockAccess, p_147754_2_, p_147754_3_, p_147754_4_, 5)); + tessellator.addTranslation(f19, 0.0F, 0.0F); + return true; + } + + public boolean renderBlockFence(BlockFence p_147735_1_, int p_147735_2_, int p_147735_3_, int p_147735_4_) + { + boolean flag = false; + float f = 0.375F; + float f1 = 0.625F; + this.setRenderBounds((double)f, 0.0D, (double)f, (double)f1, 1.0D, (double)f1); + this.renderStandardBlock(p_147735_1_, p_147735_2_, p_147735_3_, p_147735_4_); + flag = true; + boolean flag1 = false; + boolean flag2 = false; + + if (p_147735_1_.canConnectFenceTo(this.blockAccess, p_147735_2_ - 1, p_147735_3_, p_147735_4_) || p_147735_1_.canConnectFenceTo(this.blockAccess, p_147735_2_ + 1, p_147735_3_, p_147735_4_)) + { + flag1 = true; + } + + if (p_147735_1_.canConnectFenceTo(this.blockAccess, p_147735_2_, p_147735_3_, p_147735_4_ - 1) || p_147735_1_.canConnectFenceTo(this.blockAccess, p_147735_2_, p_147735_3_, p_147735_4_ + 1)) + { + flag2 = true; + } + + boolean flag3 = p_147735_1_.canConnectFenceTo(this.blockAccess, p_147735_2_ - 1, p_147735_3_, p_147735_4_); + boolean flag4 = p_147735_1_.canConnectFenceTo(this.blockAccess, p_147735_2_ + 1, p_147735_3_, p_147735_4_); + boolean flag5 = p_147735_1_.canConnectFenceTo(this.blockAccess, p_147735_2_, p_147735_3_, p_147735_4_ - 1); + boolean flag6 = p_147735_1_.canConnectFenceTo(this.blockAccess, p_147735_2_, p_147735_3_, p_147735_4_ + 1); + + if (!flag1 && !flag2) + { + flag1 = true; + } + + f = 0.4375F; + f1 = 0.5625F; + float f2 = 0.75F; + float f3 = 0.9375F; + float f4 = flag3 ? 0.0F : f; + float f5 = flag4 ? 1.0F : f1; + float f6 = flag5 ? 0.0F : f; + float f7 = flag6 ? 1.0F : f1; + + if (flag1) + { + this.setRenderBounds((double)f4, (double)f2, (double)f, (double)f5, (double)f3, (double)f1); + this.renderStandardBlock(p_147735_1_, p_147735_2_, p_147735_3_, p_147735_4_); + flag = true; + } + + if (flag2) + { + this.setRenderBounds((double)f, (double)f2, (double)f6, (double)f1, (double)f3, (double)f7); + this.renderStandardBlock(p_147735_1_, p_147735_2_, p_147735_3_, p_147735_4_); + flag = true; + } + + f2 = 0.375F; + f3 = 0.5625F; + + if (flag1) + { + this.setRenderBounds((double)f4, (double)f2, (double)f, (double)f5, (double)f3, (double)f1); + this.renderStandardBlock(p_147735_1_, p_147735_2_, p_147735_3_, p_147735_4_); + flag = true; + } + + if (flag2) + { + this.setRenderBounds((double)f, (double)f2, (double)f6, (double)f1, (double)f3, (double)f7); + this.renderStandardBlock(p_147735_1_, p_147735_2_, p_147735_3_, p_147735_4_); + flag = true; + } + + p_147735_1_.setBlockBoundsBasedOnState(this.blockAccess, p_147735_2_, p_147735_3_, p_147735_4_); + return flag; + } + + public boolean renderBlockWall(BlockWall p_147807_1_, int p_147807_2_, int p_147807_3_, int p_147807_4_) + { + boolean flag = p_147807_1_.canConnectWallTo(this.blockAccess, p_147807_2_ - 1, p_147807_3_, p_147807_4_); + boolean flag1 = p_147807_1_.canConnectWallTo(this.blockAccess, p_147807_2_ + 1, p_147807_3_, p_147807_4_); + boolean flag2 = p_147807_1_.canConnectWallTo(this.blockAccess, p_147807_2_, p_147807_3_, p_147807_4_ - 1); + boolean flag3 = p_147807_1_.canConnectWallTo(this.blockAccess, p_147807_2_, p_147807_3_, p_147807_4_ + 1); + boolean flag4 = flag2 && flag3 && !flag && !flag1; + boolean flag5 = !flag2 && !flag3 && flag && flag1; + boolean flag6 = this.blockAccess.isAirBlock(p_147807_2_, p_147807_3_ + 1, p_147807_4_); + + if ((flag4 || flag5) && flag6) + { + if (flag4) + { + this.setRenderBounds(0.3125D, 0.0D, 0.0D, 0.6875D, 0.8125D, 1.0D); + this.renderStandardBlock(p_147807_1_, p_147807_2_, p_147807_3_, p_147807_4_); + } + else + { + this.setRenderBounds(0.0D, 0.0D, 0.3125D, 1.0D, 0.8125D, 0.6875D); + this.renderStandardBlock(p_147807_1_, p_147807_2_, p_147807_3_, p_147807_4_); + } + } + else + { + this.setRenderBounds(0.25D, 0.0D, 0.25D, 0.75D, 1.0D, 0.75D); + this.renderStandardBlock(p_147807_1_, p_147807_2_, p_147807_3_, p_147807_4_); + + if (flag) + { + this.setRenderBounds(0.0D, 0.0D, 0.3125D, 0.25D, 0.8125D, 0.6875D); + this.renderStandardBlock(p_147807_1_, p_147807_2_, p_147807_3_, p_147807_4_); + } + + if (flag1) + { + this.setRenderBounds(0.75D, 0.0D, 0.3125D, 1.0D, 0.8125D, 0.6875D); + this.renderStandardBlock(p_147807_1_, p_147807_2_, p_147807_3_, p_147807_4_); + } + + if (flag2) + { + this.setRenderBounds(0.3125D, 0.0D, 0.0D, 0.6875D, 0.8125D, 0.25D); + this.renderStandardBlock(p_147807_1_, p_147807_2_, p_147807_3_, p_147807_4_); + } + + if (flag3) + { + this.setRenderBounds(0.3125D, 0.0D, 0.75D, 0.6875D, 0.8125D, 1.0D); + this.renderStandardBlock(p_147807_1_, p_147807_2_, p_147807_3_, p_147807_4_); + } + } + + p_147807_1_.setBlockBoundsBasedOnState(this.blockAccess, p_147807_2_, p_147807_3_, p_147807_4_); + return true; + } + + public boolean renderBlockDragonEgg(BlockDragonEgg p_147802_1_, int p_147802_2_, int p_147802_3_, int p_147802_4_) + { + boolean flag = false; + int l = 0; + + for (int i1 = 0; i1 < 8; ++i1) + { + byte b0 = 0; + byte b1 = 1; + + if (i1 == 0) + { + b0 = 2; + } + + if (i1 == 1) + { + b0 = 3; + } + + if (i1 == 2) + { + b0 = 4; + } + + if (i1 == 3) + { + b0 = 5; + b1 = 2; + } + + if (i1 == 4) + { + b0 = 6; + b1 = 3; + } + + if (i1 == 5) + { + b0 = 7; + b1 = 5; + } + + if (i1 == 6) + { + b0 = 6; + b1 = 2; + } + + if (i1 == 7) + { + b0 = 3; + } + + float f = (float)b0 / 16.0F; + float f1 = 1.0F - (float)l / 16.0F; + float f2 = 1.0F - (float)(l + b1) / 16.0F; + l += b1; + this.setRenderBounds((double)(0.5F - f), (double)f2, (double)(0.5F - f), (double)(0.5F + f), (double)f1, (double)(0.5F + f)); + this.renderStandardBlock(p_147802_1_, p_147802_2_, p_147802_3_, p_147802_4_); + } + + flag = true; + this.setRenderBounds(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D); + return flag; + } + + public boolean renderBlockFenceGate(BlockFenceGate p_147776_1_, int p_147776_2_, int p_147776_3_, int p_147776_4_) + { + boolean flag = true; + int l = this.blockAccess.getBlockMetadata(p_147776_2_, p_147776_3_, p_147776_4_); + boolean flag1 = BlockFenceGate.isFenceGateOpen(l); + int i1 = BlockDirectional.getDirection(l); + float f = 0.375F; + float f1 = 0.5625F; + float f2 = 0.75F; + float f3 = 0.9375F; + float f4 = 0.3125F; + float f5 = 1.0F; + + if ((i1 == 2 || i1 == 0) && this.blockAccess.getBlock(p_147776_2_ - 1, p_147776_3_, p_147776_4_) == Blocks.cobblestone_wall && this.blockAccess.getBlock(p_147776_2_ + 1, p_147776_3_, p_147776_4_) == Blocks.cobblestone_wall || (i1 == 3 || i1 == 1) && this.blockAccess.getBlock(p_147776_2_, p_147776_3_, p_147776_4_ - 1) == Blocks.cobblestone_wall && this.blockAccess.getBlock(p_147776_2_, p_147776_3_, p_147776_4_ + 1) == Blocks.cobblestone_wall) + { + f -= 0.1875F; + f1 -= 0.1875F; + f2 -= 0.1875F; + f3 -= 0.1875F; + f4 -= 0.1875F; + f5 -= 0.1875F; + } + + this.renderAllFaces = true; + float f6; + float f7; + float f8; + float f9; + + if (i1 != 3 && i1 != 1) + { + f6 = 0.0F; + f7 = 0.125F; + f8 = 0.4375F; + f9 = 0.5625F; + this.setRenderBounds((double)f6, (double)f4, (double)f8, (double)f7, (double)f5, (double)f9); + this.renderStandardBlock(p_147776_1_, p_147776_2_, p_147776_3_, p_147776_4_); + f6 = 0.875F; + f7 = 1.0F; + this.setRenderBounds((double)f6, (double)f4, (double)f8, (double)f7, (double)f5, (double)f9); + this.renderStandardBlock(p_147776_1_, p_147776_2_, p_147776_3_, p_147776_4_); + } + else + { + this.uvRotateTop = 1; + f6 = 0.4375F; + f7 = 0.5625F; + f8 = 0.0F; + f9 = 0.125F; + this.setRenderBounds((double)f6, (double)f4, (double)f8, (double)f7, (double)f5, (double)f9); + this.renderStandardBlock(p_147776_1_, p_147776_2_, p_147776_3_, p_147776_4_); + f8 = 0.875F; + f9 = 1.0F; + this.setRenderBounds((double)f6, (double)f4, (double)f8, (double)f7, (double)f5, (double)f9); + this.renderStandardBlock(p_147776_1_, p_147776_2_, p_147776_3_, p_147776_4_); + this.uvRotateTop = 0; + } + + if (flag1) + { + if (i1 == 2 || i1 == 0) + { + this.uvRotateTop = 1; + } + + float f10; + float f11; + float f12; + + if (i1 == 3) + { + f6 = 0.0F; + f7 = 0.125F; + f8 = 0.875F; + f9 = 1.0F; + f10 = 0.5625F; + f11 = 0.8125F; + f12 = 0.9375F; + this.setRenderBounds(0.8125D, (double)f, 0.0D, 0.9375D, (double)f3, 0.125D); + this.renderStandardBlock(p_147776_1_, p_147776_2_, p_147776_3_, p_147776_4_); + this.setRenderBounds(0.8125D, (double)f, 0.875D, 0.9375D, (double)f3, 1.0D); + this.renderStandardBlock(p_147776_1_, p_147776_2_, p_147776_3_, p_147776_4_); + this.setRenderBounds(0.5625D, (double)f, 0.0D, 0.8125D, (double)f1, 0.125D); + this.renderStandardBlock(p_147776_1_, p_147776_2_, p_147776_3_, p_147776_4_); + this.setRenderBounds(0.5625D, (double)f, 0.875D, 0.8125D, (double)f1, 1.0D); + this.renderStandardBlock(p_147776_1_, p_147776_2_, p_147776_3_, p_147776_4_); + this.setRenderBounds(0.5625D, (double)f2, 0.0D, 0.8125D, (double)f3, 0.125D); + this.renderStandardBlock(p_147776_1_, p_147776_2_, p_147776_3_, p_147776_4_); + this.setRenderBounds(0.5625D, (double)f2, 0.875D, 0.8125D, (double)f3, 1.0D); + this.renderStandardBlock(p_147776_1_, p_147776_2_, p_147776_3_, p_147776_4_); + } + else if (i1 == 1) + { + f6 = 0.0F; + f7 = 0.125F; + f8 = 0.875F; + f9 = 1.0F; + f10 = 0.0625F; + f11 = 0.1875F; + f12 = 0.4375F; + this.setRenderBounds(0.0625D, (double)f, 0.0D, 0.1875D, (double)f3, 0.125D); + this.renderStandardBlock(p_147776_1_, p_147776_2_, p_147776_3_, p_147776_4_); + this.setRenderBounds(0.0625D, (double)f, 0.875D, 0.1875D, (double)f3, 1.0D); + this.renderStandardBlock(p_147776_1_, p_147776_2_, p_147776_3_, p_147776_4_); + this.setRenderBounds(0.1875D, (double)f, 0.0D, 0.4375D, (double)f1, 0.125D); + this.renderStandardBlock(p_147776_1_, p_147776_2_, p_147776_3_, p_147776_4_); + this.setRenderBounds(0.1875D, (double)f, 0.875D, 0.4375D, (double)f1, 1.0D); + this.renderStandardBlock(p_147776_1_, p_147776_2_, p_147776_3_, p_147776_4_); + this.setRenderBounds(0.1875D, (double)f2, 0.0D, 0.4375D, (double)f3, 0.125D); + this.renderStandardBlock(p_147776_1_, p_147776_2_, p_147776_3_, p_147776_4_); + this.setRenderBounds(0.1875D, (double)f2, 0.875D, 0.4375D, (double)f3, 1.0D); + this.renderStandardBlock(p_147776_1_, p_147776_2_, p_147776_3_, p_147776_4_); + } + else if (i1 == 0) + { + f6 = 0.0F; + f7 = 0.125F; + f8 = 0.875F; + f9 = 1.0F; + f10 = 0.5625F; + f11 = 0.8125F; + f12 = 0.9375F; + this.setRenderBounds(0.0D, (double)f, 0.8125D, 0.125D, (double)f3, 0.9375D); + this.renderStandardBlock(p_147776_1_, p_147776_2_, p_147776_3_, p_147776_4_); + this.setRenderBounds(0.875D, (double)f, 0.8125D, 1.0D, (double)f3, 0.9375D); + this.renderStandardBlock(p_147776_1_, p_147776_2_, p_147776_3_, p_147776_4_); + this.setRenderBounds(0.0D, (double)f, 0.5625D, 0.125D, (double)f1, 0.8125D); + this.renderStandardBlock(p_147776_1_, p_147776_2_, p_147776_3_, p_147776_4_); + this.setRenderBounds(0.875D, (double)f, 0.5625D, 1.0D, (double)f1, 0.8125D); + this.renderStandardBlock(p_147776_1_, p_147776_2_, p_147776_3_, p_147776_4_); + this.setRenderBounds(0.0D, (double)f2, 0.5625D, 0.125D, (double)f3, 0.8125D); + this.renderStandardBlock(p_147776_1_, p_147776_2_, p_147776_3_, p_147776_4_); + this.setRenderBounds(0.875D, (double)f2, 0.5625D, 1.0D, (double)f3, 0.8125D); + this.renderStandardBlock(p_147776_1_, p_147776_2_, p_147776_3_, p_147776_4_); + } + else if (i1 == 2) + { + f6 = 0.0F; + f7 = 0.125F; + f8 = 0.875F; + f9 = 1.0F; + f10 = 0.0625F; + f11 = 0.1875F; + f12 = 0.4375F; + this.setRenderBounds(0.0D, (double)f, 0.0625D, 0.125D, (double)f3, 0.1875D); + this.renderStandardBlock(p_147776_1_, p_147776_2_, p_147776_3_, p_147776_4_); + this.setRenderBounds(0.875D, (double)f, 0.0625D, 1.0D, (double)f3, 0.1875D); + this.renderStandardBlock(p_147776_1_, p_147776_2_, p_147776_3_, p_147776_4_); + this.setRenderBounds(0.0D, (double)f, 0.1875D, 0.125D, (double)f1, 0.4375D); + this.renderStandardBlock(p_147776_1_, p_147776_2_, p_147776_3_, p_147776_4_); + this.setRenderBounds(0.875D, (double)f, 0.1875D, 1.0D, (double)f1, 0.4375D); + this.renderStandardBlock(p_147776_1_, p_147776_2_, p_147776_3_, p_147776_4_); + this.setRenderBounds(0.0D, (double)f2, 0.1875D, 0.125D, (double)f3, 0.4375D); + this.renderStandardBlock(p_147776_1_, p_147776_2_, p_147776_3_, p_147776_4_); + this.setRenderBounds(0.875D, (double)f2, 0.1875D, 1.0D, (double)f3, 0.4375D); + this.renderStandardBlock(p_147776_1_, p_147776_2_, p_147776_3_, p_147776_4_); + } + } + else if (i1 != 3 && i1 != 1) + { + f6 = 0.375F; + f7 = 0.5F; + f8 = 0.4375F; + f9 = 0.5625F; + this.setRenderBounds((double)f6, (double)f, (double)f8, (double)f7, (double)f3, (double)f9); + this.renderStandardBlock(p_147776_1_, p_147776_2_, p_147776_3_, p_147776_4_); + f6 = 0.5F; + f7 = 0.625F; + this.setRenderBounds((double)f6, (double)f, (double)f8, (double)f7, (double)f3, (double)f9); + this.renderStandardBlock(p_147776_1_, p_147776_2_, p_147776_3_, p_147776_4_); + f6 = 0.625F; + f7 = 0.875F; + this.setRenderBounds((double)f6, (double)f, (double)f8, (double)f7, (double)f1, (double)f9); + this.renderStandardBlock(p_147776_1_, p_147776_2_, p_147776_3_, p_147776_4_); + this.setRenderBounds((double)f6, (double)f2, (double)f8, (double)f7, (double)f3, (double)f9); + this.renderStandardBlock(p_147776_1_, p_147776_2_, p_147776_3_, p_147776_4_); + f6 = 0.125F; + f7 = 0.375F; + this.setRenderBounds((double)f6, (double)f, (double)f8, (double)f7, (double)f1, (double)f9); + this.renderStandardBlock(p_147776_1_, p_147776_2_, p_147776_3_, p_147776_4_); + this.setRenderBounds((double)f6, (double)f2, (double)f8, (double)f7, (double)f3, (double)f9); + this.renderStandardBlock(p_147776_1_, p_147776_2_, p_147776_3_, p_147776_4_); + } + else + { + this.uvRotateTop = 1; + f6 = 0.4375F; + f7 = 0.5625F; + f8 = 0.375F; + f9 = 0.5F; + this.setRenderBounds((double)f6, (double)f, (double)f8, (double)f7, (double)f3, (double)f9); + this.renderStandardBlock(p_147776_1_, p_147776_2_, p_147776_3_, p_147776_4_); + f8 = 0.5F; + f9 = 0.625F; + this.setRenderBounds((double)f6, (double)f, (double)f8, (double)f7, (double)f3, (double)f9); + this.renderStandardBlock(p_147776_1_, p_147776_2_, p_147776_3_, p_147776_4_); + f8 = 0.625F; + f9 = 0.875F; + this.setRenderBounds((double)f6, (double)f, (double)f8, (double)f7, (double)f1, (double)f9); + this.renderStandardBlock(p_147776_1_, p_147776_2_, p_147776_3_, p_147776_4_); + this.setRenderBounds((double)f6, (double)f2, (double)f8, (double)f7, (double)f3, (double)f9); + this.renderStandardBlock(p_147776_1_, p_147776_2_, p_147776_3_, p_147776_4_); + f8 = 0.125F; + f9 = 0.375F; + this.setRenderBounds((double)f6, (double)f, (double)f8, (double)f7, (double)f1, (double)f9); + this.renderStandardBlock(p_147776_1_, p_147776_2_, p_147776_3_, p_147776_4_); + this.setRenderBounds((double)f6, (double)f2, (double)f8, (double)f7, (double)f3, (double)f9); + this.renderStandardBlock(p_147776_1_, p_147776_2_, p_147776_3_, p_147776_4_); + } + + this.renderAllFaces = false; + this.uvRotateTop = 0; + this.setRenderBounds(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D); + return flag; + } + + public boolean renderBlockHopper(BlockHopper p_147803_1_, int p_147803_2_, int p_147803_3_, int p_147803_4_) + { + Tessellator tessellator = Tessellator.instance; + tessellator.setBrightness(p_147803_1_.getMixedBrightnessForBlock(this.blockAccess, p_147803_2_, p_147803_3_, p_147803_4_)); + int l = p_147803_1_.colorMultiplier(this.blockAccess, p_147803_2_, p_147803_3_, p_147803_4_); + float f = (float)(l >> 16 & 255) / 255.0F; + float f1 = (float)(l >> 8 & 255) / 255.0F; + float f2 = (float)(l & 255) / 255.0F; + + if (EntityRenderer.anaglyphEnable) + { + float f3 = (f * 30.0F + f1 * 59.0F + f2 * 11.0F) / 100.0F; + float f4 = (f * 30.0F + f1 * 70.0F) / 100.0F; + float f5 = (f * 30.0F + f2 * 70.0F) / 100.0F; + f = f3; + f1 = f4; + f2 = f5; + } + + tessellator.setColorOpaque_F(f, f1, f2); + return this.renderBlockHopperMetadata(p_147803_1_, p_147803_2_, p_147803_3_, p_147803_4_, this.blockAccess.getBlockMetadata(p_147803_2_, p_147803_3_, p_147803_4_), false); + } + + public boolean renderBlockHopperMetadata(BlockHopper p_147799_1_, int p_147799_2_, int p_147799_3_, int p_147799_4_, int p_147799_5_, boolean p_147799_6_) + { + Tessellator tessellator = Tessellator.instance; + int i1 = BlockHopper.getDirectionFromMetadata(p_147799_5_); + double d0 = 0.625D; + this.setRenderBounds(0.0D, d0, 0.0D, 1.0D, 1.0D, 1.0D); + + if (p_147799_6_) + { + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + this.renderFaceYNeg(p_147799_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSideAndMetadata(p_147799_1_, 0, p_147799_5_)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + this.renderFaceYPos(p_147799_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSideAndMetadata(p_147799_1_, 1, p_147799_5_)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, -1.0F); + this.renderFaceZNeg(p_147799_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSideAndMetadata(p_147799_1_, 2, p_147799_5_)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + this.renderFaceZPos(p_147799_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSideAndMetadata(p_147799_1_, 3, p_147799_5_)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + this.renderFaceXNeg(p_147799_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSideAndMetadata(p_147799_1_, 4, p_147799_5_)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + this.renderFaceXPos(p_147799_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSideAndMetadata(p_147799_1_, 5, p_147799_5_)); + tessellator.draw(); + } + else + { + this.renderStandardBlock(p_147799_1_, p_147799_2_, p_147799_3_, p_147799_4_); + } + + float f1; + + if (!p_147799_6_) + { + tessellator.setBrightness(p_147799_1_.getMixedBrightnessForBlock(this.blockAccess, p_147799_2_, p_147799_3_, p_147799_4_)); + int j1 = p_147799_1_.colorMultiplier(this.blockAccess, p_147799_2_, p_147799_3_, p_147799_4_); + float f = (float)(j1 >> 16 & 255) / 255.0F; + f1 = (float)(j1 >> 8 & 255) / 255.0F; + float f2 = (float)(j1 & 255) / 255.0F; + + if (EntityRenderer.anaglyphEnable) + { + float f3 = (f * 30.0F + f1 * 59.0F + f2 * 11.0F) / 100.0F; + float f4 = (f * 30.0F + f1 * 70.0F) / 100.0F; + float f5 = (f * 30.0F + f2 * 70.0F) / 100.0F; + f = f3; + f1 = f4; + f2 = f5; + } + + tessellator.setColorOpaque_F(f, f1, f2); + } + + IIcon iicon = BlockHopper.getHopperIcon("hopper_outside"); + IIcon iicon1 = BlockHopper.getHopperIcon("hopper_inside"); + f1 = 0.125F; + + if (p_147799_6_) + { + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + this.renderFaceXPos(p_147799_1_, (double)(-1.0F + f1), 0.0D, 0.0D, iicon); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + this.renderFaceXNeg(p_147799_1_, (double)(1.0F - f1), 0.0D, 0.0D, iicon); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + this.renderFaceZPos(p_147799_1_, 0.0D, 0.0D, (double)(-1.0F + f1), iicon); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, -1.0F); + this.renderFaceZNeg(p_147799_1_, 0.0D, 0.0D, (double)(1.0F - f1), iicon); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + this.renderFaceYPos(p_147799_1_, 0.0D, -1.0D + d0, 0.0D, iicon1); + tessellator.draw(); + } + else + { + this.renderFaceXPos(p_147799_1_, (double)((float)p_147799_2_ - 1.0F + f1), (double)p_147799_3_, (double)p_147799_4_, iicon); + this.renderFaceXNeg(p_147799_1_, (double)((float)p_147799_2_ + 1.0F - f1), (double)p_147799_3_, (double)p_147799_4_, iicon); + this.renderFaceZPos(p_147799_1_, (double)p_147799_2_, (double)p_147799_3_, (double)((float)p_147799_4_ - 1.0F + f1), iicon); + this.renderFaceZNeg(p_147799_1_, (double)p_147799_2_, (double)p_147799_3_, (double)((float)p_147799_4_ + 1.0F - f1), iicon); + this.renderFaceYPos(p_147799_1_, (double)p_147799_2_, (double)((float)p_147799_3_ - 1.0F) + d0, (double)p_147799_4_, iicon1); + } + + this.setOverrideBlockTexture(iicon); + double d3 = 0.25D; + double d4 = 0.25D; + this.setRenderBounds(d3, d4, d3, 1.0D - d3, d0 - 0.002D, 1.0D - d3); + + if (p_147799_6_) + { + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + this.renderFaceXPos(p_147799_1_, 0.0D, 0.0D, 0.0D, iicon); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + this.renderFaceXNeg(p_147799_1_, 0.0D, 0.0D, 0.0D, iicon); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + this.renderFaceZPos(p_147799_1_, 0.0D, 0.0D, 0.0D, iicon); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, -1.0F); + this.renderFaceZNeg(p_147799_1_, 0.0D, 0.0D, 0.0D, iicon); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + this.renderFaceYPos(p_147799_1_, 0.0D, 0.0D, 0.0D, iicon); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + this.renderFaceYNeg(p_147799_1_, 0.0D, 0.0D, 0.0D, iicon); + tessellator.draw(); + } + else + { + this.renderStandardBlock(p_147799_1_, p_147799_2_, p_147799_3_, p_147799_4_); + } + + if (!p_147799_6_) + { + double d1 = 0.375D; + double d2 = 0.25D; + this.setOverrideBlockTexture(iicon); + + if (i1 == 0) + { + this.setRenderBounds(d1, 0.0D, d1, 1.0D - d1, 0.25D, 1.0D - d1); + this.renderStandardBlock(p_147799_1_, p_147799_2_, p_147799_3_, p_147799_4_); + } + + if (i1 == 2) + { + this.setRenderBounds(d1, d4, 0.0D, 1.0D - d1, d4 + d2, d3); + this.renderStandardBlock(p_147799_1_, p_147799_2_, p_147799_3_, p_147799_4_); + } + + if (i1 == 3) + { + this.setRenderBounds(d1, d4, 1.0D - d3, 1.0D - d1, d4 + d2, 1.0D); + this.renderStandardBlock(p_147799_1_, p_147799_2_, p_147799_3_, p_147799_4_); + } + + if (i1 == 4) + { + this.setRenderBounds(0.0D, d4, d1, d3, d4 + d2, 1.0D - d1); + this.renderStandardBlock(p_147799_1_, p_147799_2_, p_147799_3_, p_147799_4_); + } + + if (i1 == 5) + { + this.setRenderBounds(1.0D - d3, d4, d1, 1.0D, d4 + d2, 1.0D - d1); + this.renderStandardBlock(p_147799_1_, p_147799_2_, p_147799_3_, p_147799_4_); + } + } + + this.clearOverrideBlockTexture(); + return true; + } + + public boolean renderBlockStairs(BlockStairs p_147722_1_, int p_147722_2_, int p_147722_3_, int p_147722_4_) + { + p_147722_1_.func_150147_e(this.blockAccess, p_147722_2_, p_147722_3_, p_147722_4_); + this.setRenderBoundsFromBlock(p_147722_1_); + this.renderStandardBlock(p_147722_1_, p_147722_2_, p_147722_3_, p_147722_4_); + boolean flag = p_147722_1_.func_150145_f(this.blockAccess, p_147722_2_, p_147722_3_, p_147722_4_); + this.setRenderBoundsFromBlock(p_147722_1_); + this.renderStandardBlock(p_147722_1_, p_147722_2_, p_147722_3_, p_147722_4_); + + if (flag && p_147722_1_.func_150144_g(this.blockAccess, p_147722_2_, p_147722_3_, p_147722_4_)) + { + this.setRenderBoundsFromBlock(p_147722_1_); + this.renderStandardBlock(p_147722_1_, p_147722_2_, p_147722_3_, p_147722_4_); + } + + return true; + } + + public boolean renderBlockDoor(Block p_147760_1_, int p_147760_2_, int p_147760_3_, int p_147760_4_) + { + Tessellator tessellator = Tessellator.instance; + int l = this.blockAccess.getBlockMetadata(p_147760_2_, p_147760_3_, p_147760_4_); + + if ((l & 8) != 0) + { + if (this.blockAccess.getBlock(p_147760_2_, p_147760_3_ - 1, p_147760_4_) != p_147760_1_) + { + return false; + } + } + else if (this.blockAccess.getBlock(p_147760_2_, p_147760_3_ + 1, p_147760_4_) != p_147760_1_) + { + return false; + } + + boolean flag = false; + float f = 0.5F; + float f1 = 1.0F; + float f2 = 0.8F; + float f3 = 0.6F; + int i1 = p_147760_1_.getMixedBrightnessForBlock(this.blockAccess, p_147760_2_, p_147760_3_, p_147760_4_); + tessellator.setBrightness(this.renderMinY > 0.0D ? i1 : p_147760_1_.getMixedBrightnessForBlock(this.blockAccess, p_147760_2_, p_147760_3_ - 1, p_147760_4_)); + tessellator.setColorOpaque_F(f, f, f); + this.renderFaceYNeg(p_147760_1_, (double)p_147760_2_, (double)p_147760_3_, (double)p_147760_4_, this.getBlockIcon(p_147760_1_, this.blockAccess, p_147760_2_, p_147760_3_, p_147760_4_, 0)); + flag = true; + tessellator.setBrightness(this.renderMaxY < 1.0D ? i1 : p_147760_1_.getMixedBrightnessForBlock(this.blockAccess, p_147760_2_, p_147760_3_ + 1, p_147760_4_)); + tessellator.setColorOpaque_F(f1, f1, f1); + this.renderFaceYPos(p_147760_1_, (double)p_147760_2_, (double)p_147760_3_, (double)p_147760_4_, this.getBlockIcon(p_147760_1_, this.blockAccess, p_147760_2_, p_147760_3_, p_147760_4_, 1)); + flag = true; + tessellator.setBrightness(this.renderMinZ > 0.0D ? i1 : p_147760_1_.getMixedBrightnessForBlock(this.blockAccess, p_147760_2_, p_147760_3_, p_147760_4_ - 1)); + tessellator.setColorOpaque_F(f2, f2, f2); + IIcon iicon = this.getBlockIcon(p_147760_1_, this.blockAccess, p_147760_2_, p_147760_3_, p_147760_4_, 2); + this.renderFaceZNeg(p_147760_1_, (double)p_147760_2_, (double)p_147760_3_, (double)p_147760_4_, iicon); + flag = true; + this.flipTexture = false; + tessellator.setBrightness(this.renderMaxZ < 1.0D ? i1 : p_147760_1_.getMixedBrightnessForBlock(this.blockAccess, p_147760_2_, p_147760_3_, p_147760_4_ + 1)); + tessellator.setColorOpaque_F(f2, f2, f2); + iicon = this.getBlockIcon(p_147760_1_, this.blockAccess, p_147760_2_, p_147760_3_, p_147760_4_, 3); + this.renderFaceZPos(p_147760_1_, (double)p_147760_2_, (double)p_147760_3_, (double)p_147760_4_, iicon); + flag = true; + this.flipTexture = false; + tessellator.setBrightness(this.renderMinX > 0.0D ? i1 : p_147760_1_.getMixedBrightnessForBlock(this.blockAccess, p_147760_2_ - 1, p_147760_3_, p_147760_4_)); + tessellator.setColorOpaque_F(f3, f3, f3); + iicon = this.getBlockIcon(p_147760_1_, this.blockAccess, p_147760_2_, p_147760_3_, p_147760_4_, 4); + this.renderFaceXNeg(p_147760_1_, (double)p_147760_2_, (double)p_147760_3_, (double)p_147760_4_, iicon); + flag = true; + this.flipTexture = false; + tessellator.setBrightness(this.renderMaxX < 1.0D ? i1 : p_147760_1_.getMixedBrightnessForBlock(this.blockAccess, p_147760_2_ + 1, p_147760_3_, p_147760_4_)); + tessellator.setColorOpaque_F(f3, f3, f3); + iicon = this.getBlockIcon(p_147760_1_, this.blockAccess, p_147760_2_, p_147760_3_, p_147760_4_, 5); + this.renderFaceXPos(p_147760_1_, (double)p_147760_2_, (double)p_147760_3_, (double)p_147760_4_, iicon); + flag = true; + this.flipTexture = false; + return flag; + } + + public void renderFaceYNeg(Block p_147768_1_, double p_147768_2_, double p_147768_4_, double p_147768_6_, IIcon p_147768_8_) + { + Tessellator tessellator = Tessellator.instance; + + if (this.hasOverrideBlockTexture()) + { + p_147768_8_ = this.overrideBlockTexture; + } + + double d3 = (double)p_147768_8_.getInterpolatedU(this.renderMinX * 16.0D); + double d4 = (double)p_147768_8_.getInterpolatedU(this.renderMaxX * 16.0D); + double d5 = (double)p_147768_8_.getInterpolatedV(this.renderMinZ * 16.0D); + double d6 = (double)p_147768_8_.getInterpolatedV(this.renderMaxZ * 16.0D); + + if (this.renderMinX < 0.0D || this.renderMaxX > 1.0D) + { + d3 = (double)p_147768_8_.getMinU(); + d4 = (double)p_147768_8_.getMaxU(); + } + + if (this.renderMinZ < 0.0D || this.renderMaxZ > 1.0D) + { + d5 = (double)p_147768_8_.getMinV(); + d6 = (double)p_147768_8_.getMaxV(); + } + + double d7 = d4; + double d8 = d3; + double d9 = d5; + double d10 = d6; + + if (this.uvRotateBottom == 2) + { + d3 = (double)p_147768_8_.getInterpolatedU(this.renderMinZ * 16.0D); + d5 = (double)p_147768_8_.getInterpolatedV(16.0D - this.renderMaxX * 16.0D); + d4 = (double)p_147768_8_.getInterpolatedU(this.renderMaxZ * 16.0D); + d6 = (double)p_147768_8_.getInterpolatedV(16.0D - this.renderMinX * 16.0D); + d9 = d5; + d10 = d6; + d7 = d3; + d8 = d4; + d5 = d6; + d6 = d9; + } + else if (this.uvRotateBottom == 1) + { + d3 = (double)p_147768_8_.getInterpolatedU(16.0D - this.renderMaxZ * 16.0D); + d5 = (double)p_147768_8_.getInterpolatedV(this.renderMinX * 16.0D); + d4 = (double)p_147768_8_.getInterpolatedU(16.0D - this.renderMinZ * 16.0D); + d6 = (double)p_147768_8_.getInterpolatedV(this.renderMaxX * 16.0D); + d7 = d4; + d8 = d3; + d3 = d4; + d4 = d8; + d9 = d6; + d10 = d5; + } + else if (this.uvRotateBottom == 3) + { + d3 = (double)p_147768_8_.getInterpolatedU(16.0D - this.renderMinX * 16.0D); + d4 = (double)p_147768_8_.getInterpolatedU(16.0D - this.renderMaxX * 16.0D); + d5 = (double)p_147768_8_.getInterpolatedV(16.0D - this.renderMinZ * 16.0D); + d6 = (double)p_147768_8_.getInterpolatedV(16.0D - this.renderMaxZ * 16.0D); + d7 = d4; + d8 = d3; + d9 = d5; + d10 = d6; + } + + double d11 = p_147768_2_ + this.renderMinX; + double d12 = p_147768_2_ + this.renderMaxX; + double d13 = p_147768_4_ + this.renderMinY; + double d14 = p_147768_6_ + this.renderMinZ; + double d15 = p_147768_6_ + this.renderMaxZ; + + if (this.renderFromInside) + { + d11 = p_147768_2_ + this.renderMaxX; + d12 = p_147768_2_ + this.renderMinX; + } + + if (this.enableAO) + { + tessellator.setColorOpaque_F(this.colorRedTopLeft, this.colorGreenTopLeft, this.colorBlueTopLeft); + tessellator.setBrightness(this.brightnessTopLeft); + tessellator.addVertexWithUV(d11, d13, d15, d8, d10); + tessellator.setColorOpaque_F(this.colorRedBottomLeft, this.colorGreenBottomLeft, this.colorBlueBottomLeft); + tessellator.setBrightness(this.brightnessBottomLeft); + tessellator.addVertexWithUV(d11, d13, d14, d3, d5); + tessellator.setColorOpaque_F(this.colorRedBottomRight, this.colorGreenBottomRight, this.colorBlueBottomRight); + tessellator.setBrightness(this.brightnessBottomRight); + tessellator.addVertexWithUV(d12, d13, d14, d7, d9); + tessellator.setColorOpaque_F(this.colorRedTopRight, this.colorGreenTopRight, this.colorBlueTopRight); + tessellator.setBrightness(this.brightnessTopRight); + tessellator.addVertexWithUV(d12, d13, d15, d4, d6); + } + else + { + tessellator.addVertexWithUV(d11, d13, d15, d8, d10); + tessellator.addVertexWithUV(d11, d13, d14, d3, d5); + tessellator.addVertexWithUV(d12, d13, d14, d7, d9); + tessellator.addVertexWithUV(d12, d13, d15, d4, d6); + } + } + + public void renderFaceYPos(Block p_147806_1_, double p_147806_2_, double p_147806_4_, double p_147806_6_, IIcon p_147806_8_) + { + Tessellator tessellator = Tessellator.instance; + + if (this.hasOverrideBlockTexture()) + { + p_147806_8_ = this.overrideBlockTexture; + } + + double d3 = (double)p_147806_8_.getInterpolatedU(this.renderMinX * 16.0D); + double d4 = (double)p_147806_8_.getInterpolatedU(this.renderMaxX * 16.0D); + double d5 = (double)p_147806_8_.getInterpolatedV(this.renderMinZ * 16.0D); + double d6 = (double)p_147806_8_.getInterpolatedV(this.renderMaxZ * 16.0D); + + if (this.renderMinX < 0.0D || this.renderMaxX > 1.0D) + { + d3 = (double)p_147806_8_.getMinU(); + d4 = (double)p_147806_8_.getMaxU(); + } + + if (this.renderMinZ < 0.0D || this.renderMaxZ > 1.0D) + { + d5 = (double)p_147806_8_.getMinV(); + d6 = (double)p_147806_8_.getMaxV(); + } + + double d7 = d4; + double d8 = d3; + double d9 = d5; + double d10 = d6; + + if (this.uvRotateTop == 1) + { + d3 = (double)p_147806_8_.getInterpolatedU(this.renderMinZ * 16.0D); + d5 = (double)p_147806_8_.getInterpolatedV(16.0D - this.renderMaxX * 16.0D); + d4 = (double)p_147806_8_.getInterpolatedU(this.renderMaxZ * 16.0D); + d6 = (double)p_147806_8_.getInterpolatedV(16.0D - this.renderMinX * 16.0D); + d9 = d5; + d10 = d6; + d7 = d3; + d8 = d4; + d5 = d6; + d6 = d9; + } + else if (this.uvRotateTop == 2) + { + d3 = (double)p_147806_8_.getInterpolatedU(16.0D - this.renderMaxZ * 16.0D); + d5 = (double)p_147806_8_.getInterpolatedV(this.renderMinX * 16.0D); + d4 = (double)p_147806_8_.getInterpolatedU(16.0D - this.renderMinZ * 16.0D); + d6 = (double)p_147806_8_.getInterpolatedV(this.renderMaxX * 16.0D); + d7 = d4; + d8 = d3; + d3 = d4; + d4 = d8; + d9 = d6; + d10 = d5; + } + else if (this.uvRotateTop == 3) + { + d3 = (double)p_147806_8_.getInterpolatedU(16.0D - this.renderMinX * 16.0D); + d4 = (double)p_147806_8_.getInterpolatedU(16.0D - this.renderMaxX * 16.0D); + d5 = (double)p_147806_8_.getInterpolatedV(16.0D - this.renderMinZ * 16.0D); + d6 = (double)p_147806_8_.getInterpolatedV(16.0D - this.renderMaxZ * 16.0D); + d7 = d4; + d8 = d3; + d9 = d5; + d10 = d6; + } + + double d11 = p_147806_2_ + this.renderMinX; + double d12 = p_147806_2_ + this.renderMaxX; + double d13 = p_147806_4_ + this.renderMaxY; + double d14 = p_147806_6_ + this.renderMinZ; + double d15 = p_147806_6_ + this.renderMaxZ; + + if (this.renderFromInside) + { + d11 = p_147806_2_ + this.renderMaxX; + d12 = p_147806_2_ + this.renderMinX; + } + + if (this.enableAO) + { + tessellator.setColorOpaque_F(this.colorRedTopLeft, this.colorGreenTopLeft, this.colorBlueTopLeft); + tessellator.setBrightness(this.brightnessTopLeft); + tessellator.addVertexWithUV(d12, d13, d15, d4, d6); + tessellator.setColorOpaque_F(this.colorRedBottomLeft, this.colorGreenBottomLeft, this.colorBlueBottomLeft); + tessellator.setBrightness(this.brightnessBottomLeft); + tessellator.addVertexWithUV(d12, d13, d14, d7, d9); + tessellator.setColorOpaque_F(this.colorRedBottomRight, this.colorGreenBottomRight, this.colorBlueBottomRight); + tessellator.setBrightness(this.brightnessBottomRight); + tessellator.addVertexWithUV(d11, d13, d14, d3, d5); + tessellator.setColorOpaque_F(this.colorRedTopRight, this.colorGreenTopRight, this.colorBlueTopRight); + tessellator.setBrightness(this.brightnessTopRight); + tessellator.addVertexWithUV(d11, d13, d15, d8, d10); + } + else + { + tessellator.addVertexWithUV(d12, d13, d15, d4, d6); + tessellator.addVertexWithUV(d12, d13, d14, d7, d9); + tessellator.addVertexWithUV(d11, d13, d14, d3, d5); + tessellator.addVertexWithUV(d11, d13, d15, d8, d10); + } + } + + public void renderFaceZNeg(Block p_147761_1_, double p_147761_2_, double p_147761_4_, double p_147761_6_, IIcon p_147761_8_) + { + Tessellator tessellator = Tessellator.instance; + + if (this.hasOverrideBlockTexture()) + { + p_147761_8_ = this.overrideBlockTexture; + } + + double d3 = (double)p_147761_8_.getInterpolatedU(this.renderMaxX * 16.0D); + double d4 = (double)p_147761_8_.getInterpolatedU(this.renderMinX * 16.0D); + double d5 = (double)p_147761_8_.getInterpolatedV(16.0D - this.renderMaxY * 16.0D); + double d6 = (double)p_147761_8_.getInterpolatedV(16.0D - this.renderMinY * 16.0D); + double d7; + + if (this.flipTexture) + { + d7 = d3; + d3 = d4; + d4 = d7; + } + + if (this.renderMinX < 0.0D || this.renderMaxX > 1.0D) + { + d3 = (double)p_147761_8_.getMinU(); + d4 = (double)p_147761_8_.getMaxU(); + } + + if (this.renderMinY < 0.0D || this.renderMaxY > 1.0D) + { + d5 = (double)p_147761_8_.getMinV(); + d6 = (double)p_147761_8_.getMaxV(); + } + + d7 = d4; + double d8 = d3; + double d9 = d5; + double d10 = d6; + + if (this.uvRotateEast == 2) + { + d3 = (double)p_147761_8_.getInterpolatedU(this.renderMinY * 16.0D); + d5 = (double)p_147761_8_.getInterpolatedV(16.0D - this.renderMinX * 16.0D); + d4 = (double)p_147761_8_.getInterpolatedU(this.renderMaxY * 16.0D); + d6 = (double)p_147761_8_.getInterpolatedV(16.0D - this.renderMaxX * 16.0D); + d9 = d5; + d10 = d6; + d7 = d3; + d8 = d4; + d5 = d6; + d6 = d9; + } + else if (this.uvRotateEast == 1) + { + d3 = (double)p_147761_8_.getInterpolatedU(16.0D - this.renderMaxY * 16.0D); + d5 = (double)p_147761_8_.getInterpolatedV(this.renderMaxX * 16.0D); + d4 = (double)p_147761_8_.getInterpolatedU(16.0D - this.renderMinY * 16.0D); + d6 = (double)p_147761_8_.getInterpolatedV(this.renderMinX * 16.0D); + d7 = d4; + d8 = d3; + d3 = d4; + d4 = d8; + d9 = d6; + d10 = d5; + } + else if (this.uvRotateEast == 3) + { + d3 = (double)p_147761_8_.getInterpolatedU(16.0D - this.renderMinX * 16.0D); + d4 = (double)p_147761_8_.getInterpolatedU(16.0D - this.renderMaxX * 16.0D); + d5 = (double)p_147761_8_.getInterpolatedV(this.renderMaxY * 16.0D); + d6 = (double)p_147761_8_.getInterpolatedV(this.renderMinY * 16.0D); + d7 = d4; + d8 = d3; + d9 = d5; + d10 = d6; + } + + double d11 = p_147761_2_ + this.renderMinX; + double d12 = p_147761_2_ + this.renderMaxX; + double d13 = p_147761_4_ + this.renderMinY; + double d14 = p_147761_4_ + this.renderMaxY; + double d15 = p_147761_6_ + this.renderMinZ; + + if (this.renderFromInside) + { + d11 = p_147761_2_ + this.renderMaxX; + d12 = p_147761_2_ + this.renderMinX; + } + + if (this.enableAO) + { + tessellator.setColorOpaque_F(this.colorRedTopLeft, this.colorGreenTopLeft, this.colorBlueTopLeft); + tessellator.setBrightness(this.brightnessTopLeft); + tessellator.addVertexWithUV(d11, d14, d15, d7, d9); + tessellator.setColorOpaque_F(this.colorRedBottomLeft, this.colorGreenBottomLeft, this.colorBlueBottomLeft); + tessellator.setBrightness(this.brightnessBottomLeft); + tessellator.addVertexWithUV(d12, d14, d15, d3, d5); + tessellator.setColorOpaque_F(this.colorRedBottomRight, this.colorGreenBottomRight, this.colorBlueBottomRight); + tessellator.setBrightness(this.brightnessBottomRight); + tessellator.addVertexWithUV(d12, d13, d15, d8, d10); + tessellator.setColorOpaque_F(this.colorRedTopRight, this.colorGreenTopRight, this.colorBlueTopRight); + tessellator.setBrightness(this.brightnessTopRight); + tessellator.addVertexWithUV(d11, d13, d15, d4, d6); + } + else + { + tessellator.addVertexWithUV(d11, d14, d15, d7, d9); + tessellator.addVertexWithUV(d12, d14, d15, d3, d5); + tessellator.addVertexWithUV(d12, d13, d15, d8, d10); + tessellator.addVertexWithUV(d11, d13, d15, d4, d6); + } + } + + public void renderFaceZPos(Block p_147734_1_, double p_147734_2_, double p_147734_4_, double p_147734_6_, IIcon p_147734_8_) + { + Tessellator tessellator = Tessellator.instance; + + if (this.hasOverrideBlockTexture()) + { + p_147734_8_ = this.overrideBlockTexture; + } + + double d3 = (double)p_147734_8_.getInterpolatedU(this.renderMinX * 16.0D); + double d4 = (double)p_147734_8_.getInterpolatedU(this.renderMaxX * 16.0D); + double d5 = (double)p_147734_8_.getInterpolatedV(16.0D - this.renderMaxY * 16.0D); + double d6 = (double)p_147734_8_.getInterpolatedV(16.0D - this.renderMinY * 16.0D); + double d7; + + if (this.flipTexture) + { + d7 = d3; + d3 = d4; + d4 = d7; + } + + if (this.renderMinX < 0.0D || this.renderMaxX > 1.0D) + { + d3 = (double)p_147734_8_.getMinU(); + d4 = (double)p_147734_8_.getMaxU(); + } + + if (this.renderMinY < 0.0D || this.renderMaxY > 1.0D) + { + d5 = (double)p_147734_8_.getMinV(); + d6 = (double)p_147734_8_.getMaxV(); + } + + d7 = d4; + double d8 = d3; + double d9 = d5; + double d10 = d6; + + if (this.uvRotateWest == 1) + { + d3 = (double)p_147734_8_.getInterpolatedU(this.renderMinY * 16.0D); + d6 = (double)p_147734_8_.getInterpolatedV(16.0D - this.renderMinX * 16.0D); + d4 = (double)p_147734_8_.getInterpolatedU(this.renderMaxY * 16.0D); + d5 = (double)p_147734_8_.getInterpolatedV(16.0D - this.renderMaxX * 16.0D); + d9 = d5; + d10 = d6; + d7 = d3; + d8 = d4; + d5 = d6; + d6 = d9; + } + else if (this.uvRotateWest == 2) + { + d3 = (double)p_147734_8_.getInterpolatedU(16.0D - this.renderMaxY * 16.0D); + d5 = (double)p_147734_8_.getInterpolatedV(this.renderMinX * 16.0D); + d4 = (double)p_147734_8_.getInterpolatedU(16.0D - this.renderMinY * 16.0D); + d6 = (double)p_147734_8_.getInterpolatedV(this.renderMaxX * 16.0D); + d7 = d4; + d8 = d3; + d3 = d4; + d4 = d8; + d9 = d6; + d10 = d5; + } + else if (this.uvRotateWest == 3) + { + d3 = (double)p_147734_8_.getInterpolatedU(16.0D - this.renderMinX * 16.0D); + d4 = (double)p_147734_8_.getInterpolatedU(16.0D - this.renderMaxX * 16.0D); + d5 = (double)p_147734_8_.getInterpolatedV(this.renderMaxY * 16.0D); + d6 = (double)p_147734_8_.getInterpolatedV(this.renderMinY * 16.0D); + d7 = d4; + d8 = d3; + d9 = d5; + d10 = d6; + } + + double d11 = p_147734_2_ + this.renderMinX; + double d12 = p_147734_2_ + this.renderMaxX; + double d13 = p_147734_4_ + this.renderMinY; + double d14 = p_147734_4_ + this.renderMaxY; + double d15 = p_147734_6_ + this.renderMaxZ; + + if (this.renderFromInside) + { + d11 = p_147734_2_ + this.renderMaxX; + d12 = p_147734_2_ + this.renderMinX; + } + + if (this.enableAO) + { + tessellator.setColorOpaque_F(this.colorRedTopLeft, this.colorGreenTopLeft, this.colorBlueTopLeft); + tessellator.setBrightness(this.brightnessTopLeft); + tessellator.addVertexWithUV(d11, d14, d15, d3, d5); + tessellator.setColorOpaque_F(this.colorRedBottomLeft, this.colorGreenBottomLeft, this.colorBlueBottomLeft); + tessellator.setBrightness(this.brightnessBottomLeft); + tessellator.addVertexWithUV(d11, d13, d15, d8, d10); + tessellator.setColorOpaque_F(this.colorRedBottomRight, this.colorGreenBottomRight, this.colorBlueBottomRight); + tessellator.setBrightness(this.brightnessBottomRight); + tessellator.addVertexWithUV(d12, d13, d15, d4, d6); + tessellator.setColorOpaque_F(this.colorRedTopRight, this.colorGreenTopRight, this.colorBlueTopRight); + tessellator.setBrightness(this.brightnessTopRight); + tessellator.addVertexWithUV(d12, d14, d15, d7, d9); + } + else + { + tessellator.addVertexWithUV(d11, d14, d15, d3, d5); + tessellator.addVertexWithUV(d11, d13, d15, d8, d10); + tessellator.addVertexWithUV(d12, d13, d15, d4, d6); + tessellator.addVertexWithUV(d12, d14, d15, d7, d9); + } + } + + public void renderFaceXNeg(Block p_147798_1_, double p_147798_2_, double p_147798_4_, double p_147798_6_, IIcon p_147798_8_) + { + Tessellator tessellator = Tessellator.instance; + + if (this.hasOverrideBlockTexture()) + { + p_147798_8_ = this.overrideBlockTexture; + } + + double d3 = (double)p_147798_8_.getInterpolatedU(this.renderMinZ * 16.0D); + double d4 = (double)p_147798_8_.getInterpolatedU(this.renderMaxZ * 16.0D); + double d5 = (double)p_147798_8_.getInterpolatedV(16.0D - this.renderMaxY * 16.0D); + double d6 = (double)p_147798_8_.getInterpolatedV(16.0D - this.renderMinY * 16.0D); + double d7; + + if (this.flipTexture) + { + d7 = d3; + d3 = d4; + d4 = d7; + } + + if (this.renderMinZ < 0.0D || this.renderMaxZ > 1.0D) + { + d3 = (double)p_147798_8_.getMinU(); + d4 = (double)p_147798_8_.getMaxU(); + } + + if (this.renderMinY < 0.0D || this.renderMaxY > 1.0D) + { + d5 = (double)p_147798_8_.getMinV(); + d6 = (double)p_147798_8_.getMaxV(); + } + + d7 = d4; + double d8 = d3; + double d9 = d5; + double d10 = d6; + + if (this.uvRotateNorth == 1) + { + d3 = (double)p_147798_8_.getInterpolatedU(this.renderMinY * 16.0D); + d5 = (double)p_147798_8_.getInterpolatedV(16.0D - this.renderMaxZ * 16.0D); + d4 = (double)p_147798_8_.getInterpolatedU(this.renderMaxY * 16.0D); + d6 = (double)p_147798_8_.getInterpolatedV(16.0D - this.renderMinZ * 16.0D); + d9 = d5; + d10 = d6; + d7 = d3; + d8 = d4; + d5 = d6; + d6 = d9; + } + else if (this.uvRotateNorth == 2) + { + d3 = (double)p_147798_8_.getInterpolatedU(16.0D - this.renderMaxY * 16.0D); + d5 = (double)p_147798_8_.getInterpolatedV(this.renderMinZ * 16.0D); + d4 = (double)p_147798_8_.getInterpolatedU(16.0D - this.renderMinY * 16.0D); + d6 = (double)p_147798_8_.getInterpolatedV(this.renderMaxZ * 16.0D); + d7 = d4; + d8 = d3; + d3 = d4; + d4 = d8; + d9 = d6; + d10 = d5; + } + else if (this.uvRotateNorth == 3) + { + d3 = (double)p_147798_8_.getInterpolatedU(16.0D - this.renderMinZ * 16.0D); + d4 = (double)p_147798_8_.getInterpolatedU(16.0D - this.renderMaxZ * 16.0D); + d5 = (double)p_147798_8_.getInterpolatedV(this.renderMaxY * 16.0D); + d6 = (double)p_147798_8_.getInterpolatedV(this.renderMinY * 16.0D); + d7 = d4; + d8 = d3; + d9 = d5; + d10 = d6; + } + + double d11 = p_147798_2_ + this.renderMinX; + double d12 = p_147798_4_ + this.renderMinY; + double d13 = p_147798_4_ + this.renderMaxY; + double d14 = p_147798_6_ + this.renderMinZ; + double d15 = p_147798_6_ + this.renderMaxZ; + + if (this.renderFromInside) + { + d14 = p_147798_6_ + this.renderMaxZ; + d15 = p_147798_6_ + this.renderMinZ; + } + + if (this.enableAO) + { + tessellator.setColorOpaque_F(this.colorRedTopLeft, this.colorGreenTopLeft, this.colorBlueTopLeft); + tessellator.setBrightness(this.brightnessTopLeft); + tessellator.addVertexWithUV(d11, d13, d15, d7, d9); + tessellator.setColorOpaque_F(this.colorRedBottomLeft, this.colorGreenBottomLeft, this.colorBlueBottomLeft); + tessellator.setBrightness(this.brightnessBottomLeft); + tessellator.addVertexWithUV(d11, d13, d14, d3, d5); + tessellator.setColorOpaque_F(this.colorRedBottomRight, this.colorGreenBottomRight, this.colorBlueBottomRight); + tessellator.setBrightness(this.brightnessBottomRight); + tessellator.addVertexWithUV(d11, d12, d14, d8, d10); + tessellator.setColorOpaque_F(this.colorRedTopRight, this.colorGreenTopRight, this.colorBlueTopRight); + tessellator.setBrightness(this.brightnessTopRight); + tessellator.addVertexWithUV(d11, d12, d15, d4, d6); + } + else + { + tessellator.addVertexWithUV(d11, d13, d15, d7, d9); + tessellator.addVertexWithUV(d11, d13, d14, d3, d5); + tessellator.addVertexWithUV(d11, d12, d14, d8, d10); + tessellator.addVertexWithUV(d11, d12, d15, d4, d6); + } + } + + public void renderFaceXPos(Block p_147764_1_, double p_147764_2_, double p_147764_4_, double p_147764_6_, IIcon p_147764_8_) + { + Tessellator tessellator = Tessellator.instance; + + if (this.hasOverrideBlockTexture()) + { + p_147764_8_ = this.overrideBlockTexture; + } + + double d3 = (double)p_147764_8_.getInterpolatedU(this.renderMaxZ * 16.0D); + double d4 = (double)p_147764_8_.getInterpolatedU(this.renderMinZ * 16.0D); + double d5 = (double)p_147764_8_.getInterpolatedV(16.0D - this.renderMaxY * 16.0D); + double d6 = (double)p_147764_8_.getInterpolatedV(16.0D - this.renderMinY * 16.0D); + double d7; + + if (this.flipTexture) + { + d7 = d3; + d3 = d4; + d4 = d7; + } + + if (this.renderMinZ < 0.0D || this.renderMaxZ > 1.0D) + { + d3 = (double)p_147764_8_.getMinU(); + d4 = (double)p_147764_8_.getMaxU(); + } + + if (this.renderMinY < 0.0D || this.renderMaxY > 1.0D) + { + d5 = (double)p_147764_8_.getMinV(); + d6 = (double)p_147764_8_.getMaxV(); + } + + d7 = d4; + double d8 = d3; + double d9 = d5; + double d10 = d6; + + if (this.uvRotateSouth == 2) + { + d3 = (double)p_147764_8_.getInterpolatedU(this.renderMinY * 16.0D); + d5 = (double)p_147764_8_.getInterpolatedV(16.0D - this.renderMinZ * 16.0D); + d4 = (double)p_147764_8_.getInterpolatedU(this.renderMaxY * 16.0D); + d6 = (double)p_147764_8_.getInterpolatedV(16.0D - this.renderMaxZ * 16.0D); + d9 = d5; + d10 = d6; + d7 = d3; + d8 = d4; + d5 = d6; + d6 = d9; + } + else if (this.uvRotateSouth == 1) + { + d3 = (double)p_147764_8_.getInterpolatedU(16.0D - this.renderMaxY * 16.0D); + d5 = (double)p_147764_8_.getInterpolatedV(this.renderMaxZ * 16.0D); + d4 = (double)p_147764_8_.getInterpolatedU(16.0D - this.renderMinY * 16.0D); + d6 = (double)p_147764_8_.getInterpolatedV(this.renderMinZ * 16.0D); + d7 = d4; + d8 = d3; + d3 = d4; + d4 = d8; + d9 = d6; + d10 = d5; + } + else if (this.uvRotateSouth == 3) + { + d3 = (double)p_147764_8_.getInterpolatedU(16.0D - this.renderMinZ * 16.0D); + d4 = (double)p_147764_8_.getInterpolatedU(16.0D - this.renderMaxZ * 16.0D); + d5 = (double)p_147764_8_.getInterpolatedV(this.renderMaxY * 16.0D); + d6 = (double)p_147764_8_.getInterpolatedV(this.renderMinY * 16.0D); + d7 = d4; + d8 = d3; + d9 = d5; + d10 = d6; + } + + double d11 = p_147764_2_ + this.renderMaxX; + double d12 = p_147764_4_ + this.renderMinY; + double d13 = p_147764_4_ + this.renderMaxY; + double d14 = p_147764_6_ + this.renderMinZ; + double d15 = p_147764_6_ + this.renderMaxZ; + + if (this.renderFromInside) + { + d14 = p_147764_6_ + this.renderMaxZ; + d15 = p_147764_6_ + this.renderMinZ; + } + + if (this.enableAO) + { + tessellator.setColorOpaque_F(this.colorRedTopLeft, this.colorGreenTopLeft, this.colorBlueTopLeft); + tessellator.setBrightness(this.brightnessTopLeft); + tessellator.addVertexWithUV(d11, d12, d15, d8, d10); + tessellator.setColorOpaque_F(this.colorRedBottomLeft, this.colorGreenBottomLeft, this.colorBlueBottomLeft); + tessellator.setBrightness(this.brightnessBottomLeft); + tessellator.addVertexWithUV(d11, d12, d14, d4, d6); + tessellator.setColorOpaque_F(this.colorRedBottomRight, this.colorGreenBottomRight, this.colorBlueBottomRight); + tessellator.setBrightness(this.brightnessBottomRight); + tessellator.addVertexWithUV(d11, d13, d14, d7, d9); + tessellator.setColorOpaque_F(this.colorRedTopRight, this.colorGreenTopRight, this.colorBlueTopRight); + tessellator.setBrightness(this.brightnessTopRight); + tessellator.addVertexWithUV(d11, d13, d15, d3, d5); + } + else + { + tessellator.addVertexWithUV(d11, d12, d15, d8, d10); + tessellator.addVertexWithUV(d11, d12, d14, d4, d6); + tessellator.addVertexWithUV(d11, d13, d14, d7, d9); + tessellator.addVertexWithUV(d11, d13, d15, d3, d5); + } + } + + public void renderBlockAsItem(Block p_147800_1_, int p_147800_2_, float p_147800_3_) + { + Tessellator tessellator = Tessellator.instance; + boolean flag = p_147800_1_ == Blocks.grass; + + if (p_147800_1_ == Blocks.dispenser || p_147800_1_ == Blocks.dropper || p_147800_1_ == Blocks.furnace) + { + p_147800_2_ = 3; + } + + int j; + float f1; + float f2; + float f3; + + if (this.useInventoryTint) + { + j = p_147800_1_.getRenderColor(p_147800_2_); + + if (flag) + { + j = 16777215; + } + + f1 = (float)(j >> 16 & 255) / 255.0F; + f2 = (float)(j >> 8 & 255) / 255.0F; + f3 = (float)(j & 255) / 255.0F; + GL11.glColor4f(f1 * p_147800_3_, f2 * p_147800_3_, f3 * p_147800_3_, 1.0F); + } + + j = p_147800_1_.getRenderType(); + this.setRenderBoundsFromBlock(p_147800_1_); + int k; + + if (j != 0 && j != 31 && j != 39 && j != 16 && j != 26) + { + if (j == 1) + { + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + IIcon iicon = this.getBlockIconFromSideAndMetadata(p_147800_1_, 0, p_147800_2_); + this.drawCrossedSquares(iicon, -0.5D, -0.5D, -0.5D, 1.0F); + tessellator.draw(); + } + else if (j == 19) + { + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + p_147800_1_.setBlockBoundsForItemRender(); + this.renderBlockStemSmall(p_147800_1_, p_147800_2_, this.renderMaxY, -0.5D, -0.5D, -0.5D); + tessellator.draw(); + } + else if (j == 23) + { + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + p_147800_1_.setBlockBoundsForItemRender(); + tessellator.draw(); + } + else if (j == 13) + { + p_147800_1_.setBlockBoundsForItemRender(); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + f1 = 0.0625F; + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + this.renderFaceYNeg(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSide(p_147800_1_, 0)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + this.renderFaceYPos(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSide(p_147800_1_, 1)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, -1.0F); + tessellator.addTranslation(0.0F, 0.0F, f1); + this.renderFaceZNeg(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSide(p_147800_1_, 2)); + tessellator.addTranslation(0.0F, 0.0F, -f1); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + tessellator.addTranslation(0.0F, 0.0F, -f1); + this.renderFaceZPos(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSide(p_147800_1_, 3)); + tessellator.addTranslation(0.0F, 0.0F, f1); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + tessellator.addTranslation(f1, 0.0F, 0.0F); + this.renderFaceXNeg(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSide(p_147800_1_, 4)); + tessellator.addTranslation(-f1, 0.0F, 0.0F); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + tessellator.addTranslation(-f1, 0.0F, 0.0F); + this.renderFaceXPos(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSide(p_147800_1_, 5)); + tessellator.addTranslation(f1, 0.0F, 0.0F); + tessellator.draw(); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } + else if (j == 22) + { + GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + TileEntityRendererChestHelper.instance.renderChest(p_147800_1_, p_147800_2_, p_147800_3_); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + } + else if (j == 6) + { + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + this.renderBlockCropsImpl(p_147800_1_, p_147800_2_, -0.5D, -0.5D, -0.5D); + tessellator.draw(); + } + else if (j == 2) + { + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + this.renderTorchAtAngle(p_147800_1_, -0.5D, -0.5D, -0.5D, 0.0D, 0.0D, 0); + tessellator.draw(); + } + else if (j == 10) + { + for (k = 0; k < 2; ++k) + { + if (k == 0) + { + this.setRenderBounds(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 0.5D); + } + + if (k == 1) + { + this.setRenderBounds(0.0D, 0.0D, 0.5D, 1.0D, 0.5D, 1.0D); + } + + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + this.renderFaceYNeg(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSide(p_147800_1_, 0)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + this.renderFaceYPos(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSide(p_147800_1_, 1)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, -1.0F); + this.renderFaceZNeg(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSide(p_147800_1_, 2)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + this.renderFaceZPos(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSide(p_147800_1_, 3)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + this.renderFaceXNeg(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSide(p_147800_1_, 4)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + this.renderFaceXPos(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSide(p_147800_1_, 5)); + tessellator.draw(); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } + } + else if (j == 27) + { + k = 0; + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + tessellator.startDrawingQuads(); + + for (int l = 0; l < 8; ++l) + { + byte b0 = 0; + byte b1 = 1; + + if (l == 0) + { + b0 = 2; + } + + if (l == 1) + { + b0 = 3; + } + + if (l == 2) + { + b0 = 4; + } + + if (l == 3) + { + b0 = 5; + b1 = 2; + } + + if (l == 4) + { + b0 = 6; + b1 = 3; + } + + if (l == 5) + { + b0 = 7; + b1 = 5; + } + + if (l == 6) + { + b0 = 6; + b1 = 2; + } + + if (l == 7) + { + b0 = 3; + } + + float f5 = (float)b0 / 16.0F; + float f6 = 1.0F - (float)k / 16.0F; + float f7 = 1.0F - (float)(k + b1) / 16.0F; + k += b1; + this.setRenderBounds((double)(0.5F - f5), (double)f7, (double)(0.5F - f5), (double)(0.5F + f5), (double)f6, (double)(0.5F + f5)); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + this.renderFaceYNeg(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSide(p_147800_1_, 0)); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + this.renderFaceYPos(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSide(p_147800_1_, 1)); + tessellator.setNormal(0.0F, 0.0F, -1.0F); + this.renderFaceZNeg(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSide(p_147800_1_, 2)); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + this.renderFaceZPos(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSide(p_147800_1_, 3)); + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + this.renderFaceXNeg(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSide(p_147800_1_, 4)); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + this.renderFaceXPos(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSide(p_147800_1_, 5)); + } + + tessellator.draw(); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + this.setRenderBounds(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D); + } + else if (j == 11) + { + for (k = 0; k < 4; ++k) + { + f2 = 0.125F; + + if (k == 0) + { + this.setRenderBounds((double)(0.5F - f2), 0.0D, 0.0D, (double)(0.5F + f2), 1.0D, (double)(f2 * 2.0F)); + } + + if (k == 1) + { + this.setRenderBounds((double)(0.5F - f2), 0.0D, (double)(1.0F - f2 * 2.0F), (double)(0.5F + f2), 1.0D, 1.0D); + } + + f2 = 0.0625F; + + if (k == 2) + { + this.setRenderBounds((double)(0.5F - f2), (double)(1.0F - f2 * 3.0F), (double)(-f2 * 2.0F), (double)(0.5F + f2), (double)(1.0F - f2), (double)(1.0F + f2 * 2.0F)); + } + + if (k == 3) + { + this.setRenderBounds((double)(0.5F - f2), (double)(0.5F - f2 * 3.0F), (double)(-f2 * 2.0F), (double)(0.5F + f2), (double)(0.5F - f2), (double)(1.0F + f2 * 2.0F)); + } + + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + this.renderFaceYNeg(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSide(p_147800_1_, 0)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + this.renderFaceYPos(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSide(p_147800_1_, 1)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, -1.0F); + this.renderFaceZNeg(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSide(p_147800_1_, 2)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + this.renderFaceZPos(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSide(p_147800_1_, 3)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + this.renderFaceXNeg(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSide(p_147800_1_, 4)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + this.renderFaceXPos(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSide(p_147800_1_, 5)); + tessellator.draw(); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } + + this.setRenderBounds(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D); + } + else if (j == 21) + { + for (k = 0; k < 3; ++k) + { + f2 = 0.0625F; + + if (k == 0) + { + this.setRenderBounds((double)(0.5F - f2), 0.30000001192092896D, 0.0D, (double)(0.5F + f2), 1.0D, (double)(f2 * 2.0F)); + } + + if (k == 1) + { + this.setRenderBounds((double)(0.5F - f2), 0.30000001192092896D, (double)(1.0F - f2 * 2.0F), (double)(0.5F + f2), 1.0D, 1.0D); + } + + f2 = 0.0625F; + + if (k == 2) + { + this.setRenderBounds((double)(0.5F - f2), 0.5D, 0.0D, (double)(0.5F + f2), (double)(1.0F - f2), 1.0D); + } + + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + this.renderFaceYNeg(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSide(p_147800_1_, 0)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + this.renderFaceYPos(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSide(p_147800_1_, 1)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, -1.0F); + this.renderFaceZNeg(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSide(p_147800_1_, 2)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + this.renderFaceZPos(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSide(p_147800_1_, 3)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + this.renderFaceXNeg(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSide(p_147800_1_, 4)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + this.renderFaceXPos(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSide(p_147800_1_, 5)); + tessellator.draw(); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } + } + else if (j == 32) + { + for (k = 0; k < 2; ++k) + { + if (k == 0) + { + this.setRenderBounds(0.0D, 0.0D, 0.3125D, 1.0D, 0.8125D, 0.6875D); + } + + if (k == 1) + { + this.setRenderBounds(0.25D, 0.0D, 0.25D, 0.75D, 1.0D, 0.75D); + } + + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + this.renderFaceYNeg(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSideAndMetadata(p_147800_1_, 0, p_147800_2_)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + this.renderFaceYPos(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSideAndMetadata(p_147800_1_, 1, p_147800_2_)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, -1.0F); + this.renderFaceZNeg(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSideAndMetadata(p_147800_1_, 2, p_147800_2_)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + this.renderFaceZPos(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSideAndMetadata(p_147800_1_, 3, p_147800_2_)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + this.renderFaceXNeg(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSideAndMetadata(p_147800_1_, 4, p_147800_2_)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + this.renderFaceXPos(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSideAndMetadata(p_147800_1_, 5, p_147800_2_)); + tessellator.draw(); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } + + this.setRenderBounds(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D); + } + else if (j == 35) + { + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + this.renderBlockAnvilOrient((BlockAnvil)p_147800_1_, 0, 0, 0, p_147800_2_ << 2, true); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } + else if (j == 34) + { + for (k = 0; k < 3; ++k) + { + if (k == 0) + { + this.setRenderBounds(0.125D, 0.0D, 0.125D, 0.875D, 0.1875D, 0.875D); + this.setOverrideBlockTexture(this.getBlockIcon(Blocks.obsidian)); + } + else if (k == 1) + { + this.setRenderBounds(0.1875D, 0.1875D, 0.1875D, 0.8125D, 0.875D, 0.8125D); + this.setOverrideBlockTexture(this.getBlockIcon(Blocks.beacon)); + } + else if (k == 2) + { + this.setRenderBounds(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D); + this.setOverrideBlockTexture(this.getBlockIcon(Blocks.glass)); + } + + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + this.renderFaceYNeg(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSideAndMetadata(p_147800_1_, 0, p_147800_2_)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + this.renderFaceYPos(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSideAndMetadata(p_147800_1_, 1, p_147800_2_)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, -1.0F); + this.renderFaceZNeg(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSideAndMetadata(p_147800_1_, 2, p_147800_2_)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + this.renderFaceZPos(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSideAndMetadata(p_147800_1_, 3, p_147800_2_)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + this.renderFaceXNeg(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSideAndMetadata(p_147800_1_, 4, p_147800_2_)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + this.renderFaceXPos(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSideAndMetadata(p_147800_1_, 5, p_147800_2_)); + tessellator.draw(); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } + + this.setRenderBounds(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D); + this.clearOverrideBlockTexture(); + } + else if (j == 38) + { + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + this.renderBlockHopperMetadata((BlockHopper)p_147800_1_, 0, 0, 0, 0, true); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } + else + { + FMLRenderAccessLibrary.renderInventoryBlock(this, p_147800_1_, p_147800_2_, j); + } + } + else + { + if (j == 16) + { + p_147800_2_ = 1; + } + + p_147800_1_.setBlockBoundsForItemRender(); + this.setRenderBoundsFromBlock(p_147800_1_); + GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + this.renderFaceYNeg(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSideAndMetadata(p_147800_1_, 0, p_147800_2_)); + tessellator.draw(); + + if (flag && this.useInventoryTint) + { + k = p_147800_1_.getRenderColor(p_147800_2_); + f2 = (float)(k >> 16 & 255) / 255.0F; + f3 = (float)(k >> 8 & 255) / 255.0F; + float f4 = (float)(k & 255) / 255.0F; + GL11.glColor4f(f2 * p_147800_3_, f3 * p_147800_3_, f4 * p_147800_3_, 1.0F); + } + + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + this.renderFaceYPos(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSideAndMetadata(p_147800_1_, 1, p_147800_2_)); + tessellator.draw(); + + if (flag && this.useInventoryTint) + { + GL11.glColor4f(p_147800_3_, p_147800_3_, p_147800_3_, 1.0F); + } + + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, -1.0F); + this.renderFaceZNeg(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSideAndMetadata(p_147800_1_, 2, p_147800_2_)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + this.renderFaceZPos(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSideAndMetadata(p_147800_1_, 3, p_147800_2_)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + this.renderFaceXNeg(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSideAndMetadata(p_147800_1_, 4, p_147800_2_)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + this.renderFaceXPos(p_147800_1_, 0.0D, 0.0D, 0.0D, this.getBlockIconFromSideAndMetadata(p_147800_1_, 5, p_147800_2_)); + tessellator.draw(); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } + } + + public static boolean renderItemIn3d(int p_147739_0_) + { + switch (p_147739_0_) + { + case 0 : return true ; + case 31: return true ; + case 39: return true ; + case 13: return true ; + case 10: return true ; + case 11: return true ; + case 27: return true ; + case 22: return true ; + case 21: return true ; + case 16: return true ; + case 26: return true ; + case 32: return true ; + case 34: return true ; + case 35: return true ; + default: return FMLRenderAccessLibrary.renderItemAsFull3DBlock(p_147739_0_); + } + } + + public IIcon getBlockIcon(Block p_147793_1_, IBlockAccess p_147793_2_, int p_147793_3_, int p_147793_4_, int p_147793_5_, int p_147793_6_) + { + return this.getIconSafe(p_147793_1_.getIcon(p_147793_2_, p_147793_3_, p_147793_4_, p_147793_5_, p_147793_6_)); + } + + public IIcon getBlockIconFromSideAndMetadata(Block p_147787_1_, int p_147787_2_, int p_147787_3_) + { + return this.getIconSafe(p_147787_1_.getIcon(p_147787_2_, p_147787_3_)); + } + + public IIcon getBlockIconFromSide(Block p_147777_1_, int p_147777_2_) + { + return this.getIconSafe(p_147777_1_.getBlockTextureFromSide(p_147777_2_)); + } + + public IIcon getBlockIcon(Block p_147745_1_) + { + return this.getIconSafe(p_147745_1_.getBlockTextureFromSide(1)); + } + + public IIcon getIconSafe(IIcon p_147758_1_) + { + if (p_147758_1_ == null) + { + p_147758_1_ = ((TextureMap)Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno"); + } + + return (IIcon)p_147758_1_; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/RenderGlobal.java b/src/main/java/net/minecraft/client/renderer/RenderGlobal.java new file mode 100644 index 0000000..106f35d --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/RenderGlobal.java @@ -0,0 +1,2409 @@ +package net.minecraft.client.renderer; + +import com.google.common.collect.Maps; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.nio.IntBuffer; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.concurrent.Callable; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.Minecraft; +import net.minecraft.client.audio.ISound; +import net.minecraft.client.audio.PositionedSoundRecord; +import net.minecraft.client.multiplayer.WorldClient; +import net.minecraft.client.particle.EntityAuraFX; +import net.minecraft.client.particle.EntityBlockDustFX; +import net.minecraft.client.particle.EntityBreakingFX; +import net.minecraft.client.particle.EntityBubbleFX; +import net.minecraft.client.particle.EntityCloudFX; +import net.minecraft.client.particle.EntityCritFX; +import net.minecraft.client.particle.EntityDiggingFX; +import net.minecraft.client.particle.EntityDropParticleFX; +import net.minecraft.client.particle.EntityEnchantmentTableParticleFX; +import net.minecraft.client.particle.EntityExplodeFX; +import net.minecraft.client.particle.EntityFX; +import net.minecraft.client.particle.EntityFireworkSparkFX; +import net.minecraft.client.particle.EntityFishWakeFX; +import net.minecraft.client.particle.EntityFlameFX; +import net.minecraft.client.particle.EntityFootStepFX; +import net.minecraft.client.particle.EntityHeartFX; +import net.minecraft.client.particle.EntityHugeExplodeFX; +import net.minecraft.client.particle.EntityLargeExplodeFX; +import net.minecraft.client.particle.EntityLavaFX; +import net.minecraft.client.particle.EntityNoteFX; +import net.minecraft.client.particle.EntityPortalFX; +import net.minecraft.client.particle.EntityReddustFX; +import net.minecraft.client.particle.EntitySmokeFX; +import net.minecraft.client.particle.EntitySnowShovelFX; +import net.minecraft.client.particle.EntitySpellParticleFX; +import net.minecraft.client.particle.EntitySplashFX; +import net.minecraft.client.particle.EntitySuspendFX; +import net.minecraft.client.renderer.culling.ICamera; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; +import net.minecraft.client.util.RenderDistanceSorter; +import net.minecraft.crash.CrashReport; +import net.minecraft.crash.CrashReportCategory; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemDye; +import net.minecraft.item.ItemRecord; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.ReportedException; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Vec3; +import net.minecraft.world.IWorldAccess; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.lwjgl.opengl.ARBOcclusionQuery; +import org.lwjgl.opengl.GL11; + +import net.minecraftforge.client.IRenderHandler; +import net.minecraftforge.client.MinecraftForgeClient; + +@SideOnly(Side.CLIENT) +public class RenderGlobal implements IWorldAccess +{ + private static final Logger logger = LogManager.getLogger(); + private static final ResourceLocation locationMoonPhasesPng = new ResourceLocation("textures/environment/moon_phases.png"); + private static final ResourceLocation locationSunPng = new ResourceLocation("textures/environment/sun.png"); + private static final ResourceLocation locationCloudsPng = new ResourceLocation("textures/environment/clouds.png"); + private static final ResourceLocation locationEndSkyPng = new ResourceLocation("textures/environment/end_sky.png"); + public List tileEntities = new ArrayList(); + private WorldClient theWorld; + private final TextureManager renderEngine; + private List worldRenderersToUpdate = new ArrayList(); + private WorldRenderer[] sortedWorldRenderers; + private WorldRenderer[] worldRenderers; + private int renderChunksWide; + private int renderChunksTall; + private int renderChunksDeep; + private int glRenderListBase; + private Minecraft mc; + private RenderBlocks renderBlocksRg; + private IntBuffer glOcclusionQueryBase; + private boolean occlusionEnabled; + private int cloudTickCounter; + private int starGLCallList; + private int glSkyList; + private int glSkyList2; + private int minBlockX; + private int minBlockY; + private int minBlockZ; + private int maxBlockX; + private int maxBlockY; + private int maxBlockZ; + private final Map damagedBlocks = new HashMap(); + private final Map mapSoundPositions = Maps.newHashMap(); + private IIcon[] destroyBlockIcons; + private boolean displayListEntitiesDirty; + private int displayListEntities; + private int renderDistanceChunks = -1; + private int renderEntitiesStartupCounter = 2; + private int countEntitiesTotal; + private int countEntitiesRendered; + private int countEntitiesHidden; + IntBuffer occlusionResult = GLAllocation.createDirectIntBuffer(64); + private int renderersLoaded; + private int renderersBeingClipped; + private int renderersBeingOccluded; + private int renderersBeingRendered; + private int renderersSkippingRenderPass; + private int dummyRenderInt; + private int worldRenderersCheckIndex; + private List glRenderLists = new ArrayList(); + private RenderList[] allRenderLists = new RenderList[] {new RenderList(), new RenderList(), new RenderList(), new RenderList()}; + double prevSortX = -9999.0D; + double prevSortY = -9999.0D; + double prevSortZ = -9999.0D; + double prevRenderSortX = -9999.0D; + double prevRenderSortY = -9999.0D; + double prevRenderSortZ = -9999.0D; + int prevChunkSortX = -999; + int prevChunkSortY = -999; + int prevChunkSortZ = -999; + int frustumCheckOffset; + private static final String __OBFID = "CL_00000954"; + + public RenderGlobal(Minecraft par1Minecraft) + { + this.mc = par1Minecraft; + this.renderEngine = par1Minecraft.getTextureManager(); + byte b0 = 34; + byte b1 = 16; + this.glRenderListBase = GLAllocation.generateDisplayLists(b0 * b0 * b1 * 3); + this.displayListEntitiesDirty = false; + this.displayListEntities = GLAllocation.generateDisplayLists(1); + this.occlusionEnabled = OpenGlCapsChecker.checkARBOcclusion(); + + if (this.occlusionEnabled) + { + this.occlusionResult.clear(); + this.glOcclusionQueryBase = GLAllocation.createDirectIntBuffer(b0 * b0 * b1); + this.glOcclusionQueryBase.clear(); + this.glOcclusionQueryBase.position(0); + this.glOcclusionQueryBase.limit(b0 * b0 * b1); + ARBOcclusionQuery.glGenQueriesARB(this.glOcclusionQueryBase); + } + + this.starGLCallList = GLAllocation.generateDisplayLists(3); + GL11.glPushMatrix(); + GL11.glNewList(this.starGLCallList, GL11.GL_COMPILE); + this.renderStars(); + GL11.glEndList(); + GL11.glPopMatrix(); + Tessellator tessellator = Tessellator.instance; + this.glSkyList = this.starGLCallList + 1; + GL11.glNewList(this.glSkyList, GL11.GL_COMPILE); + byte b2 = 64; + int i = 256 / b2 + 2; + float f = 16.0F; + int j; + int k; + + for (j = -b2 * i; j <= b2 * i; j += b2) + { + for (k = -b2 * i; k <= b2 * i; k += b2) + { + tessellator.startDrawingQuads(); + tessellator.addVertex((double)(j + 0), (double)f, (double)(k + 0)); + tessellator.addVertex((double)(j + b2), (double)f, (double)(k + 0)); + tessellator.addVertex((double)(j + b2), (double)f, (double)(k + b2)); + tessellator.addVertex((double)(j + 0), (double)f, (double)(k + b2)); + tessellator.draw(); + } + } + + GL11.glEndList(); + this.glSkyList2 = this.starGLCallList + 2; + GL11.glNewList(this.glSkyList2, GL11.GL_COMPILE); + f = -16.0F; + tessellator.startDrawingQuads(); + + for (j = -b2 * i; j <= b2 * i; j += b2) + { + for (k = -b2 * i; k <= b2 * i; k += b2) + { + tessellator.addVertex((double)(j + b2), (double)f, (double)(k + 0)); + tessellator.addVertex((double)(j + 0), (double)f, (double)(k + 0)); + tessellator.addVertex((double)(j + 0), (double)f, (double)(k + b2)); + tessellator.addVertex((double)(j + b2), (double)f, (double)(k + b2)); + } + } + + tessellator.draw(); + GL11.glEndList(); + } + + private void renderStars() + { + Random random = new Random(10842L); + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + + for (int i = 0; i < 1500; ++i) + { + double d0 = (double)(random.nextFloat() * 2.0F - 1.0F); + double d1 = (double)(random.nextFloat() * 2.0F - 1.0F); + double d2 = (double)(random.nextFloat() * 2.0F - 1.0F); + double d3 = (double)(0.15F + random.nextFloat() * 0.1F); + double d4 = d0 * d0 + d1 * d1 + d2 * d2; + + if (d4 < 1.0D && d4 > 0.01D) + { + d4 = 1.0D / Math.sqrt(d4); + d0 *= d4; + d1 *= d4; + d2 *= d4; + double d5 = d0 * 100.0D; + double d6 = d1 * 100.0D; + double d7 = d2 * 100.0D; + double d8 = Math.atan2(d0, d2); + double d9 = Math.sin(d8); + double d10 = Math.cos(d8); + double d11 = Math.atan2(Math.sqrt(d0 * d0 + d2 * d2), d1); + double d12 = Math.sin(d11); + double d13 = Math.cos(d11); + double d14 = random.nextDouble() * Math.PI * 2.0D; + double d15 = Math.sin(d14); + double d16 = Math.cos(d14); + + for (int j = 0; j < 4; ++j) + { + double d17 = 0.0D; + double d18 = (double)((j & 2) - 1) * d3; + double d19 = (double)((j + 1 & 2) - 1) * d3; + double d20 = d18 * d16 - d19 * d15; + double d21 = d19 * d16 + d18 * d15; + double d22 = d20 * d12 + d17 * d13; + double d23 = d17 * d12 - d20 * d13; + double d24 = d23 * d9 - d21 * d10; + double d25 = d21 * d9 + d23 * d10; + tessellator.addVertex(d5 + d24, d6 + d22, d7 + d25); + } + } + } + + tessellator.draw(); + } + + public void setWorldAndLoadRenderers(WorldClient par1WorldClient) + { + if (this.theWorld != null) + { + this.theWorld.removeWorldAccess(this); + } + + this.prevSortX = -9999.0D; + this.prevSortY = -9999.0D; + this.prevSortZ = -9999.0D; + this.prevRenderSortX = -9999.0D; + this.prevRenderSortY = -9999.0D; + this.prevRenderSortZ = -9999.0D; + this.prevChunkSortX = -9999; + this.prevChunkSortY = -9999; + this.prevChunkSortZ = -9999; + RenderManager.instance.set(par1WorldClient); + this.theWorld = par1WorldClient; + this.renderBlocksRg = new RenderBlocks(par1WorldClient); + + if (par1WorldClient != null) + { + par1WorldClient.addWorldAccess(this); + this.loadRenderers(); + } + } + + public void loadRenderers() + { + if (this.theWorld != null) + { + Blocks.leaves.setGraphicsLevel(this.mc.gameSettings.fancyGraphics); + Blocks.leaves2.setGraphicsLevel(this.mc.gameSettings.fancyGraphics); + this.renderDistanceChunks = this.mc.gameSettings.renderDistanceChunks; + int i; + + if (this.worldRenderers != null) + { + for (i = 0; i < this.worldRenderers.length; ++i) + { + this.worldRenderers[i].stopRendering(); + } + } + + i = this.renderDistanceChunks * 2 + 1; + this.renderChunksWide = i; + this.renderChunksTall = 16; + this.renderChunksDeep = i; + this.worldRenderers = new WorldRenderer[this.renderChunksWide * this.renderChunksTall * this.renderChunksDeep]; + this.sortedWorldRenderers = new WorldRenderer[this.renderChunksWide * this.renderChunksTall * this.renderChunksDeep]; + int j = 0; + int k = 0; + this.minBlockX = 0; + this.minBlockY = 0; + this.minBlockZ = 0; + this.maxBlockX = this.renderChunksWide; + this.maxBlockY = this.renderChunksTall; + this.maxBlockZ = this.renderChunksDeep; + int l; + + for (l = 0; l < this.worldRenderersToUpdate.size(); ++l) + { + ((WorldRenderer)this.worldRenderersToUpdate.get(l)).needsUpdate = false; + } + + this.worldRenderersToUpdate.clear(); + this.tileEntities.clear(); + + for (l = 0; l < this.renderChunksWide; ++l) + { + for (int i1 = 0; i1 < this.renderChunksTall; ++i1) + { + for (int j1 = 0; j1 < this.renderChunksDeep; ++j1) + { + this.worldRenderers[(j1 * this.renderChunksTall + i1) * this.renderChunksWide + l] = new WorldRenderer(this.theWorld, this.tileEntities, l * 16, i1 * 16, j1 * 16, this.glRenderListBase + j); + + if (this.occlusionEnabled) + { + this.worldRenderers[(j1 * this.renderChunksTall + i1) * this.renderChunksWide + l].glOcclusionQuery = this.glOcclusionQueryBase.get(k); + } + + this.worldRenderers[(j1 * this.renderChunksTall + i1) * this.renderChunksWide + l].isWaitingOnOcclusionQuery = false; + this.worldRenderers[(j1 * this.renderChunksTall + i1) * this.renderChunksWide + l].isVisible = true; + this.worldRenderers[(j1 * this.renderChunksTall + i1) * this.renderChunksWide + l].isInFrustum = true; + this.worldRenderers[(j1 * this.renderChunksTall + i1) * this.renderChunksWide + l].chunkIndex = k++; + this.worldRenderers[(j1 * this.renderChunksTall + i1) * this.renderChunksWide + l].markDirty(); + this.sortedWorldRenderers[(j1 * this.renderChunksTall + i1) * this.renderChunksWide + l] = this.worldRenderers[(j1 * this.renderChunksTall + i1) * this.renderChunksWide + l]; + this.worldRenderersToUpdate.add(this.worldRenderers[(j1 * this.renderChunksTall + i1) * this.renderChunksWide + l]); + j += 3; + } + } + } + + if (this.theWorld != null) + { + EntityLivingBase entitylivingbase = this.mc.renderViewEntity; + + if (entitylivingbase != null) + { + this.markRenderersForNewPosition(MathHelper.floor_double(entitylivingbase.posX), MathHelper.floor_double(entitylivingbase.posY), MathHelper.floor_double(entitylivingbase.posZ)); + Arrays.sort(this.sortedWorldRenderers, new EntitySorter(entitylivingbase)); + } + } + + this.renderEntitiesStartupCounter = 2; + } + } + + public void renderEntities(EntityLivingBase p_147589_1_, ICamera p_147589_2_, float p_147589_3_) + { + int pass = MinecraftForgeClient.getRenderPass(); + if (this.renderEntitiesStartupCounter > 0) + { + if (pass > 0) return; + --this.renderEntitiesStartupCounter; + } + else + { + double d0 = p_147589_1_.prevPosX + (p_147589_1_.posX - p_147589_1_.prevPosX) * (double)p_147589_3_; + double d1 = p_147589_1_.prevPosY + (p_147589_1_.posY - p_147589_1_.prevPosY) * (double)p_147589_3_; + double d2 = p_147589_1_.prevPosZ + (p_147589_1_.posZ - p_147589_1_.prevPosZ) * (double)p_147589_3_; + this.theWorld.theProfiler.startSection("prepare"); + TileEntityRendererDispatcher.instance.cacheActiveRenderInfo(this.theWorld, this.mc.getTextureManager(), this.mc.fontRenderer, this.mc.renderViewEntity, p_147589_3_); + RenderManager.instance.cacheActiveRenderInfo(this.theWorld, this.mc.getTextureManager(), this.mc.fontRenderer, this.mc.renderViewEntity, this.mc.pointedEntity, this.mc.gameSettings, p_147589_3_); + if (pass == 0) // no indentation to shrink patch + { + this.countEntitiesTotal = 0; + this.countEntitiesRendered = 0; + this.countEntitiesHidden = 0; + } + EntityLivingBase entitylivingbase1 = this.mc.renderViewEntity; + double d3 = entitylivingbase1.lastTickPosX + (entitylivingbase1.posX - entitylivingbase1.lastTickPosX) * (double)p_147589_3_; + double d4 = entitylivingbase1.lastTickPosY + (entitylivingbase1.posY - entitylivingbase1.lastTickPosY) * (double)p_147589_3_; + double d5 = entitylivingbase1.lastTickPosZ + (entitylivingbase1.posZ - entitylivingbase1.lastTickPosZ) * (double)p_147589_3_; + TileEntityRendererDispatcher.staticPlayerX = d3; + TileEntityRendererDispatcher.staticPlayerY = d4; + TileEntityRendererDispatcher.staticPlayerZ = d5; + this.theWorld.theProfiler.endStartSection("staticentities"); + + if (this.displayListEntitiesDirty) + { + RenderManager.renderPosX = 0.0D; + RenderManager.renderPosY = 0.0D; + RenderManager.renderPosZ = 0.0D; + this.rebuildDisplayListEntities(); + } + + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glPushMatrix(); + GL11.glTranslated(-d3, -d4, -d5); + GL11.glCallList(this.displayListEntities); + GL11.glPopMatrix(); + RenderManager.renderPosX = d3; + RenderManager.renderPosY = d4; + RenderManager.renderPosZ = d5; + this.mc.entityRenderer.enableLightmap((double)p_147589_3_); + this.theWorld.theProfiler.endStartSection("global"); + List list = this.theWorld.getLoadedEntityList(); + if (pass == 0) // no indentation for smaller patch size + { + this.countEntitiesTotal = list.size(); + } + int i; + Entity entity; + + for (i = 0; i < this.theWorld.weatherEffects.size(); ++i) + { + entity = (Entity)this.theWorld.weatherEffects.get(i); + if (!entity.shouldRenderInPass(pass)) continue; + ++this.countEntitiesRendered; + + if (entity.isInRangeToRender3d(d0, d1, d2)) + { + RenderManager.instance.renderEntitySimple(entity, p_147589_3_); + } + } + + this.theWorld.theProfiler.endStartSection("entities"); + + for (i = 0; i < list.size(); ++i) + { + entity = (Entity)list.get(i); + if (!entity.shouldRenderInPass(pass)) continue; + boolean flag = entity.isInRangeToRender3d(d0, d1, d2) && (entity.ignoreFrustumCheck || p_147589_2_.isBoundingBoxInFrustum(entity.boundingBox) || entity.riddenByEntity == this.mc.thePlayer); + + if (!flag && entity instanceof EntityLiving) + { + EntityLiving entityliving = (EntityLiving)entity; + + if (entityliving.getLeashed() && entityliving.getLeashedToEntity() != null) + { + Entity entity1 = entityliving.getLeashedToEntity(); + flag = p_147589_2_.isBoundingBoxInFrustum(entity1.boundingBox); + } + } + + if (flag && (entity != this.mc.renderViewEntity || this.mc.gameSettings.thirdPersonView != 0 || this.mc.renderViewEntity.isPlayerSleeping()) && this.theWorld.blockExists(MathHelper.floor_double(entity.posX), 0, MathHelper.floor_double(entity.posZ))) + { + ++this.countEntitiesRendered; + RenderManager.instance.renderEntitySimple(entity, p_147589_3_); + } + } + + this.theWorld.theProfiler.endStartSection("blockentities"); + RenderHelper.enableStandardItemLighting(); + + for (i = 0; i < this.tileEntities.size(); ++i) + { + TileEntity tile = (TileEntity)this.tileEntities.get(i); + if (tile.shouldRenderInPass(pass) && p_147589_2_.isBoundingBoxInFrustum(tile.getRenderBoundingBox())) + { + TileEntityRendererDispatcher.instance.renderTileEntity(tile, p_147589_3_); + } + } + + this.mc.entityRenderer.disableLightmap((double)p_147589_3_); + this.theWorld.theProfiler.endSection(); + } + } + + public String getDebugInfoRenders() + { + return "C: " + this.renderersBeingRendered + "/" + this.renderersLoaded + ". F: " + this.renderersBeingClipped + ", O: " + this.renderersBeingOccluded + ", E: " + this.renderersSkippingRenderPass; + } + + public String getDebugInfoEntities() + { + return "E: " + this.countEntitiesRendered + "/" + this.countEntitiesTotal + ". B: " + this.countEntitiesHidden + ", I: " + (this.countEntitiesTotal - this.countEntitiesHidden - this.countEntitiesRendered); + } + + public void onStaticEntitiesChanged() + { + this.displayListEntitiesDirty = true; + } + + public void rebuildDisplayListEntities() + { + this.theWorld.theProfiler.startSection("staticentityrebuild"); + GL11.glPushMatrix(); + GL11.glNewList(this.displayListEntities, GL11.GL_COMPILE); + List list = this.theWorld.getLoadedEntityList(); + this.displayListEntitiesDirty = false; + + for (int i = 0; i < list.size(); ++i) + { + Entity entity = (Entity)list.get(i); + + if (RenderManager.instance.getEntityRenderObject(entity).isStaticEntity()) + { + this.displayListEntitiesDirty = this.displayListEntitiesDirty || !RenderManager.instance.renderEntityStatic(entity, 0.0F, true); + } + } + + GL11.glEndList(); + GL11.glPopMatrix(); + this.theWorld.theProfiler.endSection(); + } + + private void markRenderersForNewPosition(int par1, int par2, int par3) + { + par1 -= 8; + par2 -= 8; + par3 -= 8; + this.minBlockX = Integer.MAX_VALUE; + this.minBlockY = Integer.MAX_VALUE; + this.minBlockZ = Integer.MAX_VALUE; + this.maxBlockX = Integer.MIN_VALUE; + this.maxBlockY = Integer.MIN_VALUE; + this.maxBlockZ = Integer.MIN_VALUE; + int l = this.renderChunksWide * 16; + int i1 = l / 2; + + for (int j1 = 0; j1 < this.renderChunksWide; ++j1) + { + int k1 = j1 * 16; + int l1 = k1 + i1 - par1; + + if (l1 < 0) + { + l1 -= l - 1; + } + + l1 /= l; + k1 -= l1 * l; + + if (k1 < this.minBlockX) + { + this.minBlockX = k1; + } + + if (k1 > this.maxBlockX) + { + this.maxBlockX = k1; + } + + for (int i2 = 0; i2 < this.renderChunksDeep; ++i2) + { + int j2 = i2 * 16; + int k2 = j2 + i1 - par3; + + if (k2 < 0) + { + k2 -= l - 1; + } + + k2 /= l; + j2 -= k2 * l; + + if (j2 < this.minBlockZ) + { + this.minBlockZ = j2; + } + + if (j2 > this.maxBlockZ) + { + this.maxBlockZ = j2; + } + + for (int l2 = 0; l2 < this.renderChunksTall; ++l2) + { + int i3 = l2 * 16; + + if (i3 < this.minBlockY) + { + this.minBlockY = i3; + } + + if (i3 > this.maxBlockY) + { + this.maxBlockY = i3; + } + + WorldRenderer worldrenderer = this.worldRenderers[(i2 * this.renderChunksTall + l2) * this.renderChunksWide + j1]; + boolean flag = worldrenderer.needsUpdate; + worldrenderer.setPosition(k1, i3, j2); + + if (!flag && worldrenderer.needsUpdate) + { + this.worldRenderersToUpdate.add(worldrenderer); + } + } + } + } + } + + public int sortAndRender(EntityLivingBase par1EntityLivingBase, int par2, double par3) + { + this.theWorld.theProfiler.startSection("sortchunks"); + + for (int j = 0; j < 10; ++j) + { + this.worldRenderersCheckIndex = (this.worldRenderersCheckIndex + 1) % this.worldRenderers.length; + WorldRenderer worldrenderer = this.worldRenderers[this.worldRenderersCheckIndex]; + + if (worldrenderer.needsUpdate && !this.worldRenderersToUpdate.contains(worldrenderer)) + { + this.worldRenderersToUpdate.add(worldrenderer); + } + } + + if (this.mc.gameSettings.renderDistanceChunks != this.renderDistanceChunks) + { + this.loadRenderers(); + } + + if (par2 == 0) + { + this.renderersLoaded = 0; + this.dummyRenderInt = 0; + this.renderersBeingClipped = 0; + this.renderersBeingOccluded = 0; + this.renderersBeingRendered = 0; + this.renderersSkippingRenderPass = 0; + } + + double d9 = par1EntityLivingBase.lastTickPosX + (par1EntityLivingBase.posX - par1EntityLivingBase.lastTickPosX) * par3; + double d1 = par1EntityLivingBase.lastTickPosY + (par1EntityLivingBase.posY - par1EntityLivingBase.lastTickPosY) * par3; + double d2 = par1EntityLivingBase.lastTickPosZ + (par1EntityLivingBase.posZ - par1EntityLivingBase.lastTickPosZ) * par3; + double d3 = par1EntityLivingBase.posX - this.prevSortX; + double d4 = par1EntityLivingBase.posY - this.prevSortY; + double d5 = par1EntityLivingBase.posZ - this.prevSortZ; + + if (this.prevChunkSortX != par1EntityLivingBase.chunkCoordX || this.prevChunkSortY != par1EntityLivingBase.chunkCoordY || this.prevChunkSortZ != par1EntityLivingBase.chunkCoordZ || d3 * d3 + d4 * d4 + d5 * d5 > 16.0D) + { + this.prevSortX = par1EntityLivingBase.posX; + this.prevSortY = par1EntityLivingBase.posY; + this.prevSortZ = par1EntityLivingBase.posZ; + this.prevChunkSortX = par1EntityLivingBase.chunkCoordX; + this.prevChunkSortY = par1EntityLivingBase.chunkCoordY; + this.prevChunkSortZ = par1EntityLivingBase.chunkCoordZ; + this.markRenderersForNewPosition(MathHelper.floor_double(par1EntityLivingBase.posX), MathHelper.floor_double(par1EntityLivingBase.posY), MathHelper.floor_double(par1EntityLivingBase.posZ)); + Arrays.sort(this.sortedWorldRenderers, new EntitySorter(par1EntityLivingBase)); + } + + double d6 = par1EntityLivingBase.posX - this.prevRenderSortX; + double d7 = par1EntityLivingBase.posY - this.prevRenderSortY; + double d8 = par1EntityLivingBase.posZ - this.prevRenderSortZ; + int k; + + if (d6 * d6 + d7 * d7 + d8 * d8 > 1.0D) + { + this.prevRenderSortX = par1EntityLivingBase.posX; + this.prevRenderSortY = par1EntityLivingBase.posY; + this.prevRenderSortZ = par1EntityLivingBase.posZ; + + for (k = 0; k < 27; ++k) + { + this.sortedWorldRenderers[k].updateRendererSort(par1EntityLivingBase); + } + } + + RenderHelper.disableStandardItemLighting(); + byte b1 = 0; + + if (this.occlusionEnabled && this.mc.gameSettings.advancedOpengl && !this.mc.gameSettings.anaglyph && par2 == 0) + { + byte b0 = 0; + int l = 16; + this.checkOcclusionQueryResult(b0, l); + + for (int i1 = b0; i1 < l; ++i1) + { + this.sortedWorldRenderers[i1].isVisible = true; + } + + this.theWorld.theProfiler.endStartSection("render"); + k = b1 + this.renderSortedRenderers(b0, l, par2, par3); + + do + { + this.theWorld.theProfiler.endStartSection("occ"); + int l1 = l; + l *= 2; + + if (l > this.sortedWorldRenderers.length) + { + l = this.sortedWorldRenderers.length; + } + + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glDisable(GL11.GL_FOG); + GL11.glColorMask(false, false, false, false); + GL11.glDepthMask(false); + this.theWorld.theProfiler.startSection("check"); + this.checkOcclusionQueryResult(l1, l); + this.theWorld.theProfiler.endSection(); + GL11.glPushMatrix(); + float f9 = 0.0F; + float f = 0.0F; + float f1 = 0.0F; + + for (int j1 = l1; j1 < l; ++j1) + { + if (this.sortedWorldRenderers[j1].skipAllRenderPasses()) + { + this.sortedWorldRenderers[j1].isInFrustum = false; + } + else + { + if (!this.sortedWorldRenderers[j1].isInFrustum) + { + this.sortedWorldRenderers[j1].isVisible = true; + } + + if (this.sortedWorldRenderers[j1].isInFrustum && !this.sortedWorldRenderers[j1].isWaitingOnOcclusionQuery) + { + float f2 = MathHelper.sqrt_float(this.sortedWorldRenderers[j1].distanceToEntitySquared(par1EntityLivingBase)); + int k1 = (int)(1.0F + f2 / 128.0F); + + if (this.cloudTickCounter % k1 == j1 % k1) + { + WorldRenderer worldrenderer1 = this.sortedWorldRenderers[j1]; + float f3 = (float)((double)worldrenderer1.posXMinus - d9); + float f4 = (float)((double)worldrenderer1.posYMinus - d1); + float f5 = (float)((double)worldrenderer1.posZMinus - d2); + float f6 = f3 - f9; + float f7 = f4 - f; + float f8 = f5 - f1; + + if (f6 != 0.0F || f7 != 0.0F || f8 != 0.0F) + { + GL11.glTranslatef(f6, f7, f8); + f9 += f6; + f += f7; + f1 += f8; + } + + this.theWorld.theProfiler.startSection("bb"); + ARBOcclusionQuery.glBeginQueryARB(ARBOcclusionQuery.GL_SAMPLES_PASSED_ARB, this.sortedWorldRenderers[j1].glOcclusionQuery); + this.sortedWorldRenderers[j1].callOcclusionQueryList(); + ARBOcclusionQuery.glEndQueryARB(ARBOcclusionQuery.GL_SAMPLES_PASSED_ARB); + this.theWorld.theProfiler.endSection(); + this.sortedWorldRenderers[j1].isWaitingOnOcclusionQuery = true; + } + } + } + } + + GL11.glPopMatrix(); + + if (this.mc.gameSettings.anaglyph) + { + if (EntityRenderer.anaglyphField == 0) + { + GL11.glColorMask(false, true, true, true); + } + else + { + GL11.glColorMask(true, false, false, true); + } + } + else + { + GL11.glColorMask(true, true, true, true); + } + + GL11.glDepthMask(true); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_FOG); + this.theWorld.theProfiler.endStartSection("render"); + k += this.renderSortedRenderers(l1, l, par2, par3); + } + while (l < this.sortedWorldRenderers.length); + } + else + { + this.theWorld.theProfiler.endStartSection("render"); + k = b1 + this.renderSortedRenderers(0, this.sortedWorldRenderers.length, par2, par3); + } + + this.theWorld.theProfiler.endSection(); + return k; + } + + private void checkOcclusionQueryResult(int par1, int par2) + { + for (int k = par1; k < par2; ++k) + { + if (this.sortedWorldRenderers[k].isWaitingOnOcclusionQuery) + { + this.occlusionResult.clear(); + ARBOcclusionQuery.glGetQueryObjectuARB(this.sortedWorldRenderers[k].glOcclusionQuery, ARBOcclusionQuery.GL_QUERY_RESULT_AVAILABLE_ARB, this.occlusionResult); + + if (this.occlusionResult.get(0) != 0) + { + this.sortedWorldRenderers[k].isWaitingOnOcclusionQuery = false; + this.occlusionResult.clear(); + ARBOcclusionQuery.glGetQueryObjectuARB(this.sortedWorldRenderers[k].glOcclusionQuery, ARBOcclusionQuery.GL_QUERY_RESULT_ARB, this.occlusionResult); + this.sortedWorldRenderers[k].isVisible = this.occlusionResult.get(0) != 0; + } + } + } + } + + private int renderSortedRenderers(int par1, int par2, int par3, double par4) + { + this.glRenderLists.clear(); + int l = 0; + int i1 = par1; + int j1 = par2; + byte b0 = 1; + + if (par3 == 1) + { + i1 = this.sortedWorldRenderers.length - 1 - par1; + j1 = this.sortedWorldRenderers.length - 1 - par2; + b0 = -1; + } + + for (int k1 = i1; k1 != j1; k1 += b0) + { + if (par3 == 0) + { + ++this.renderersLoaded; + + if (this.sortedWorldRenderers[k1].skipRenderPass[par3]) + { + ++this.renderersSkippingRenderPass; + } + else if (!this.sortedWorldRenderers[k1].isInFrustum) + { + ++this.renderersBeingClipped; + } + else if (this.occlusionEnabled && !this.sortedWorldRenderers[k1].isVisible) + { + ++this.renderersBeingOccluded; + } + else + { + ++this.renderersBeingRendered; + } + } + + if (!this.sortedWorldRenderers[k1].skipRenderPass[par3] && this.sortedWorldRenderers[k1].isInFrustum && (!this.occlusionEnabled || this.sortedWorldRenderers[k1].isVisible)) + { + int l1 = this.sortedWorldRenderers[k1].getGLCallListForPass(par3); + + if (l1 >= 0) + { + this.glRenderLists.add(this.sortedWorldRenderers[k1]); + ++l; + } + } + } + + EntityLivingBase entitylivingbase = this.mc.renderViewEntity; + double d3 = entitylivingbase.lastTickPosX + (entitylivingbase.posX - entitylivingbase.lastTickPosX) * par4; + double d1 = entitylivingbase.lastTickPosY + (entitylivingbase.posY - entitylivingbase.lastTickPosY) * par4; + double d2 = entitylivingbase.lastTickPosZ + (entitylivingbase.posZ - entitylivingbase.lastTickPosZ) * par4; + int i2 = 0; + int j2; + + for (j2 = 0; j2 < this.allRenderLists.length; ++j2) + { + this.allRenderLists[j2].resetList(); + } + + for (j2 = 0; j2 < this.glRenderLists.size(); ++j2) + { + WorldRenderer worldrenderer = (WorldRenderer)this.glRenderLists.get(j2); + int k2 = -1; + + for (int l2 = 0; l2 < i2; ++l2) + { + if (this.allRenderLists[l2].rendersChunk(worldrenderer.posXMinus, worldrenderer.posYMinus, worldrenderer.posZMinus)) + { + k2 = l2; + } + } + + if (k2 < 0) + { + k2 = i2++; + this.allRenderLists[k2].setupRenderList(worldrenderer.posXMinus, worldrenderer.posYMinus, worldrenderer.posZMinus, d3, d1, d2); + } + + this.allRenderLists[k2].addGLRenderList(worldrenderer.getGLCallListForPass(par3)); + } + + Arrays.sort(this.allRenderLists, new RenderDistanceSorter()); + this.renderAllRenderLists(par3, par4); + return l; + } + + public void renderAllRenderLists(int par1, double par2) + { + this.mc.entityRenderer.enableLightmap(par2); + + for (int j = 0; j < this.allRenderLists.length; ++j) + { + this.allRenderLists[j].callLists(); + } + + this.mc.entityRenderer.disableLightmap(par2); + } + + public void updateClouds() + { + ++this.cloudTickCounter; + + if (this.cloudTickCounter % 20 == 0) + { + Iterator iterator = this.damagedBlocks.values().iterator(); + + while (iterator.hasNext()) + { + DestroyBlockProgress destroyblockprogress = (DestroyBlockProgress)iterator.next(); + int i = destroyblockprogress.getCreationCloudUpdateTick(); + + if (this.cloudTickCounter - i > 400) + { + iterator.remove(); + } + } + } + } + + public void renderSky(float par1) + { + IRenderHandler skyProvider = null; + if ((skyProvider = this.mc.theWorld.provider.getSkyRenderer()) != null) + { + skyProvider.render(par1, this.theWorld, mc); + return; + } + if (this.mc.theWorld.provider.dimensionId == 1) + { + GL11.glDisable(GL11.GL_FOG); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + RenderHelper.disableStandardItemLighting(); + GL11.glDepthMask(false); + this.renderEngine.bindTexture(locationEndSkyPng); + Tessellator tessellator = Tessellator.instance; + + for (int i = 0; i < 6; ++i) + { + GL11.glPushMatrix(); + + if (i == 1) + { + GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); + } + + if (i == 2) + { + GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F); + } + + if (i == 3) + { + GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F); + } + + if (i == 4) + { + GL11.glRotatef(90.0F, 0.0F, 0.0F, 1.0F); + } + + if (i == 5) + { + GL11.glRotatef(-90.0F, 0.0F, 0.0F, 1.0F); + } + + tessellator.startDrawingQuads(); + tessellator.setColorOpaque_I(2631720); + tessellator.addVertexWithUV(-100.0D, -100.0D, -100.0D, 0.0D, 0.0D); + tessellator.addVertexWithUV(-100.0D, -100.0D, 100.0D, 0.0D, 16.0D); + tessellator.addVertexWithUV(100.0D, -100.0D, 100.0D, 16.0D, 16.0D); + tessellator.addVertexWithUV(100.0D, -100.0D, -100.0D, 16.0D, 0.0D); + tessellator.draw(); + GL11.glPopMatrix(); + } + + GL11.glDepthMask(true); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_ALPHA_TEST); + } + else if (this.mc.theWorld.provider.isSurfaceWorld()) + { + GL11.glDisable(GL11.GL_TEXTURE_2D); + Vec3 vec3 = this.theWorld.getSkyColor(this.mc.renderViewEntity, par1); + float f1 = (float)vec3.xCoord; + float f2 = (float)vec3.yCoord; + float f3 = (float)vec3.zCoord; + float f6; + + if (this.mc.gameSettings.anaglyph) + { + float f4 = (f1 * 30.0F + f2 * 59.0F + f3 * 11.0F) / 100.0F; + float f5 = (f1 * 30.0F + f2 * 70.0F) / 100.0F; + f6 = (f1 * 30.0F + f3 * 70.0F) / 100.0F; + f1 = f4; + f2 = f5; + f3 = f6; + } + + GL11.glColor3f(f1, f2, f3); + Tessellator tessellator1 = Tessellator.instance; + GL11.glDepthMask(false); + GL11.glEnable(GL11.GL_FOG); + GL11.glColor3f(f1, f2, f3); + GL11.glCallList(this.glSkyList); + GL11.glDisable(GL11.GL_FOG); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + RenderHelper.disableStandardItemLighting(); + float[] afloat = this.theWorld.provider.calcSunriseSunsetColors(this.theWorld.getCelestialAngle(par1), par1); + float f7; + float f8; + float f9; + float f10; + + if (afloat != null) + { + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glShadeModel(GL11.GL_SMOOTH); + GL11.glPushMatrix(); + GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(MathHelper.sin(this.theWorld.getCelestialAngleRadians(par1)) < 0.0F ? 180.0F : 0.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(90.0F, 0.0F, 0.0F, 1.0F); + f6 = afloat[0]; + f7 = afloat[1]; + f8 = afloat[2]; + float f11; + + if (this.mc.gameSettings.anaglyph) + { + f9 = (f6 * 30.0F + f7 * 59.0F + f8 * 11.0F) / 100.0F; + f10 = (f6 * 30.0F + f7 * 70.0F) / 100.0F; + f11 = (f6 * 30.0F + f8 * 70.0F) / 100.0F; + f6 = f9; + f7 = f10; + f8 = f11; + } + + tessellator1.startDrawing(6); + tessellator1.setColorRGBA_F(f6, f7, f8, afloat[3]); + tessellator1.addVertex(0.0D, 100.0D, 0.0D); + byte b0 = 16; + tessellator1.setColorRGBA_F(afloat[0], afloat[1], afloat[2], 0.0F); + + for (int j = 0; j <= b0; ++j) + { + f11 = (float)j * (float)Math.PI * 2.0F / (float)b0; + float f12 = MathHelper.sin(f11); + float f13 = MathHelper.cos(f11); + tessellator1.addVertex((double)(f12 * 120.0F), (double)(f13 * 120.0F), (double)(-f13 * 40.0F * afloat[3])); + } + + tessellator1.draw(); + GL11.glPopMatrix(); + GL11.glShadeModel(GL11.GL_FLAT); + } + + GL11.glEnable(GL11.GL_TEXTURE_2D); + OpenGlHelper.glBlendFunc(770, 1, 1, 0); + GL11.glPushMatrix(); + f6 = 1.0F - this.theWorld.getRainStrength(par1); + f7 = 0.0F; + f8 = 0.0F; + f9 = 0.0F; + GL11.glColor4f(1.0F, 1.0F, 1.0F, f6); + GL11.glTranslatef(f7, f8, f9); + GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(this.theWorld.getCelestialAngle(par1) * 360.0F, 1.0F, 0.0F, 0.0F); + f10 = 30.0F; + this.renderEngine.bindTexture(locationSunPng); + tessellator1.startDrawingQuads(); + tessellator1.addVertexWithUV((double)(-f10), 100.0D, (double)(-f10), 0.0D, 0.0D); + tessellator1.addVertexWithUV((double)f10, 100.0D, (double)(-f10), 1.0D, 0.0D); + tessellator1.addVertexWithUV((double)f10, 100.0D, (double)f10, 1.0D, 1.0D); + tessellator1.addVertexWithUV((double)(-f10), 100.0D, (double)f10, 0.0D, 1.0D); + tessellator1.draw(); + f10 = 20.0F; + this.renderEngine.bindTexture(locationMoonPhasesPng); + int k = this.theWorld.getMoonPhase(); + int l = k % 4; + int i1 = k / 4 % 2; + float f14 = (float)(l + 0) / 4.0F; + float f15 = (float)(i1 + 0) / 2.0F; + float f16 = (float)(l + 1) / 4.0F; + float f17 = (float)(i1 + 1) / 2.0F; + tessellator1.startDrawingQuads(); + tessellator1.addVertexWithUV((double)(-f10), -100.0D, (double)f10, (double)f16, (double)f17); + tessellator1.addVertexWithUV((double)f10, -100.0D, (double)f10, (double)f14, (double)f17); + tessellator1.addVertexWithUV((double)f10, -100.0D, (double)(-f10), (double)f14, (double)f15); + tessellator1.addVertexWithUV((double)(-f10), -100.0D, (double)(-f10), (double)f16, (double)f15); + tessellator1.draw(); + GL11.glDisable(GL11.GL_TEXTURE_2D); + float f18 = this.theWorld.getStarBrightness(par1) * f6; + + if (f18 > 0.0F) + { + GL11.glColor4f(f18, f18, f18, f18); + GL11.glCallList(this.starGLCallList); + } + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_FOG); + GL11.glPopMatrix(); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glColor3f(0.0F, 0.0F, 0.0F); + double d0 = this.mc.thePlayer.getPosition(par1).yCoord - this.theWorld.getHorizon(); + + if (d0 < 0.0D) + { + GL11.glPushMatrix(); + GL11.glTranslatef(0.0F, 12.0F, 0.0F); + GL11.glCallList(this.glSkyList2); + GL11.glPopMatrix(); + f8 = 1.0F; + f9 = -((float)(d0 + 65.0D)); + f10 = -f8; + tessellator1.startDrawingQuads(); + tessellator1.setColorRGBA_I(0, 255); + tessellator1.addVertex((double)(-f8), (double)f9, (double)f8); + tessellator1.addVertex((double)f8, (double)f9, (double)f8); + tessellator1.addVertex((double)f8, (double)f10, (double)f8); + tessellator1.addVertex((double)(-f8), (double)f10, (double)f8); + tessellator1.addVertex((double)(-f8), (double)f10, (double)(-f8)); + tessellator1.addVertex((double)f8, (double)f10, (double)(-f8)); + tessellator1.addVertex((double)f8, (double)f9, (double)(-f8)); + tessellator1.addVertex((double)(-f8), (double)f9, (double)(-f8)); + tessellator1.addVertex((double)f8, (double)f10, (double)(-f8)); + tessellator1.addVertex((double)f8, (double)f10, (double)f8); + tessellator1.addVertex((double)f8, (double)f9, (double)f8); + tessellator1.addVertex((double)f8, (double)f9, (double)(-f8)); + tessellator1.addVertex((double)(-f8), (double)f9, (double)(-f8)); + tessellator1.addVertex((double)(-f8), (double)f9, (double)f8); + tessellator1.addVertex((double)(-f8), (double)f10, (double)f8); + tessellator1.addVertex((double)(-f8), (double)f10, (double)(-f8)); + tessellator1.addVertex((double)(-f8), (double)f10, (double)(-f8)); + tessellator1.addVertex((double)(-f8), (double)f10, (double)f8); + tessellator1.addVertex((double)f8, (double)f10, (double)f8); + tessellator1.addVertex((double)f8, (double)f10, (double)(-f8)); + tessellator1.draw(); + } + + if (this.theWorld.provider.isSkyColored()) + { + GL11.glColor3f(f1 * 0.2F + 0.04F, f2 * 0.2F + 0.04F, f3 * 0.6F + 0.1F); + } + else + { + GL11.glColor3f(f1, f2, f3); + } + + GL11.glPushMatrix(); + GL11.glTranslatef(0.0F, -((float)(d0 - 16.0D)), 0.0F); + GL11.glCallList(this.glSkyList2); + GL11.glPopMatrix(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDepthMask(true); + } + } + + public void renderClouds(float par1) + { + IRenderHandler renderer = null; + if ((renderer = theWorld.provider.getCloudRenderer()) != null) + { + renderer.render(par1, theWorld, mc); + return; + } + if (this.mc.theWorld.provider.isSurfaceWorld()) + { + if (this.mc.gameSettings.fancyGraphics) + { + this.renderCloudsFancy(par1); + } + else + { + GL11.glDisable(GL11.GL_CULL_FACE); + float f1 = (float)(this.mc.renderViewEntity.lastTickPosY + (this.mc.renderViewEntity.posY - this.mc.renderViewEntity.lastTickPosY) * (double)par1); + byte b0 = 32; + int i = 256 / b0; + Tessellator tessellator = Tessellator.instance; + this.renderEngine.bindTexture(locationCloudsPng); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + Vec3 vec3 = this.theWorld.getCloudColour(par1); + float f2 = (float)vec3.xCoord; + float f3 = (float)vec3.yCoord; + float f4 = (float)vec3.zCoord; + float f5; + + if (this.mc.gameSettings.anaglyph) + { + f5 = (f2 * 30.0F + f3 * 59.0F + f4 * 11.0F) / 100.0F; + float f6 = (f2 * 30.0F + f3 * 70.0F) / 100.0F; + float f7 = (f2 * 30.0F + f4 * 70.0F) / 100.0F; + f2 = f5; + f3 = f6; + f4 = f7; + } + + f5 = 4.8828125E-4F; + double d2 = (double)((float)this.cloudTickCounter + par1); + double d0 = this.mc.renderViewEntity.prevPosX + (this.mc.renderViewEntity.posX - this.mc.renderViewEntity.prevPosX) * (double)par1 + d2 * 0.029999999329447746D; + double d1 = this.mc.renderViewEntity.prevPosZ + (this.mc.renderViewEntity.posZ - this.mc.renderViewEntity.prevPosZ) * (double)par1; + int j = MathHelper.floor_double(d0 / 2048.0D); + int k = MathHelper.floor_double(d1 / 2048.0D); + d0 -= (double)(j * 2048); + d1 -= (double)(k * 2048); + float f8 = this.theWorld.provider.getCloudHeight() - f1 + 0.33F; + float f9 = (float)(d0 * (double)f5); + float f10 = (float)(d1 * (double)f5); + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_F(f2, f3, f4, 0.8F); + + for (int l = -b0 * i; l < b0 * i; l += b0) + { + for (int i1 = -b0 * i; i1 < b0 * i; i1 += b0) + { + tessellator.addVertexWithUV((double)(l + 0), (double)f8, (double)(i1 + b0), (double)((float)(l + 0) * f5 + f9), (double)((float)(i1 + b0) * f5 + f10)); + tessellator.addVertexWithUV((double)(l + b0), (double)f8, (double)(i1 + b0), (double)((float)(l + b0) * f5 + f9), (double)((float)(i1 + b0) * f5 + f10)); + tessellator.addVertexWithUV((double)(l + b0), (double)f8, (double)(i1 + 0), (double)((float)(l + b0) * f5 + f9), (double)((float)(i1 + 0) * f5 + f10)); + tessellator.addVertexWithUV((double)(l + 0), (double)f8, (double)(i1 + 0), (double)((float)(l + 0) * f5 + f9), (double)((float)(i1 + 0) * f5 + f10)); + } + } + + tessellator.draw(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_CULL_FACE); + } + } + } + + public boolean hasCloudFog(double par1, double par3, double par5, float par7) + { + return false; + } + + public void renderCloudsFancy(float par1) + { + GL11.glDisable(GL11.GL_CULL_FACE); + float f1 = (float)(this.mc.renderViewEntity.lastTickPosY + (this.mc.renderViewEntity.posY - this.mc.renderViewEntity.lastTickPosY) * (double)par1); + Tessellator tessellator = Tessellator.instance; + float f2 = 12.0F; + float f3 = 4.0F; + double d0 = (double)((float)this.cloudTickCounter + par1); + double d1 = (this.mc.renderViewEntity.prevPosX + (this.mc.renderViewEntity.posX - this.mc.renderViewEntity.prevPosX) * (double)par1 + d0 * 0.029999999329447746D) / (double)f2; + double d2 = (this.mc.renderViewEntity.prevPosZ + (this.mc.renderViewEntity.posZ - this.mc.renderViewEntity.prevPosZ) * (double)par1) / (double)f2 + 0.33000001311302185D; + float f4 = this.theWorld.provider.getCloudHeight() - f1 + 0.33F; + int i = MathHelper.floor_double(d1 / 2048.0D); + int j = MathHelper.floor_double(d2 / 2048.0D); + d1 -= (double)(i * 2048); + d2 -= (double)(j * 2048); + this.renderEngine.bindTexture(locationCloudsPng); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + Vec3 vec3 = this.theWorld.getCloudColour(par1); + float f5 = (float)vec3.xCoord; + float f6 = (float)vec3.yCoord; + float f7 = (float)vec3.zCoord; + float f8; + float f9; + float f10; + + if (this.mc.gameSettings.anaglyph) + { + f8 = (f5 * 30.0F + f6 * 59.0F + f7 * 11.0F) / 100.0F; + f9 = (f5 * 30.0F + f6 * 70.0F) / 100.0F; + f10 = (f5 * 30.0F + f7 * 70.0F) / 100.0F; + f5 = f8; + f6 = f9; + f7 = f10; + } + + f8 = (float)(d1 * 0.0D); + f9 = (float)(d2 * 0.0D); + f10 = 0.00390625F; + f8 = (float)MathHelper.floor_double(d1) * f10; + f9 = (float)MathHelper.floor_double(d2) * f10; + float f11 = (float)(d1 - (double)MathHelper.floor_double(d1)); + float f12 = (float)(d2 - (double)MathHelper.floor_double(d2)); + byte b0 = 8; + byte b1 = 4; + float f13 = 9.765625E-4F; + GL11.glScalef(f2, 1.0F, f2); + + for (int k = 0; k < 2; ++k) + { + if (k == 0) + { + GL11.glColorMask(false, false, false, false); + } + else if (this.mc.gameSettings.anaglyph) + { + if (EntityRenderer.anaglyphField == 0) + { + GL11.glColorMask(false, true, true, true); + } + else + { + GL11.glColorMask(true, false, false, true); + } + } + else + { + GL11.glColorMask(true, true, true, true); + } + + for (int l = -b1 + 1; l <= b1; ++l) + { + for (int i1 = -b1 + 1; i1 <= b1; ++i1) + { + tessellator.startDrawingQuads(); + float f14 = (float)(l * b0); + float f15 = (float)(i1 * b0); + float f16 = f14 - f11; + float f17 = f15 - f12; + + if (f4 > -f3 - 1.0F) + { + tessellator.setColorRGBA_F(f5 * 0.7F, f6 * 0.7F, f7 * 0.7F, 0.8F); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + tessellator.addVertexWithUV((double)(f16 + 0.0F), (double)(f4 + 0.0F), (double)(f17 + (float)b0), (double)((f14 + 0.0F) * f10 + f8), (double)((f15 + (float)b0) * f10 + f9)); + tessellator.addVertexWithUV((double)(f16 + (float)b0), (double)(f4 + 0.0F), (double)(f17 + (float)b0), (double)((f14 + (float)b0) * f10 + f8), (double)((f15 + (float)b0) * f10 + f9)); + tessellator.addVertexWithUV((double)(f16 + (float)b0), (double)(f4 + 0.0F), (double)(f17 + 0.0F), (double)((f14 + (float)b0) * f10 + f8), (double)((f15 + 0.0F) * f10 + f9)); + tessellator.addVertexWithUV((double)(f16 + 0.0F), (double)(f4 + 0.0F), (double)(f17 + 0.0F), (double)((f14 + 0.0F) * f10 + f8), (double)((f15 + 0.0F) * f10 + f9)); + } + + if (f4 <= f3 + 1.0F) + { + tessellator.setColorRGBA_F(f5, f6, f7, 0.8F); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + tessellator.addVertexWithUV((double)(f16 + 0.0F), (double)(f4 + f3 - f13), (double)(f17 + (float)b0), (double)((f14 + 0.0F) * f10 + f8), (double)((f15 + (float)b0) * f10 + f9)); + tessellator.addVertexWithUV((double)(f16 + (float)b0), (double)(f4 + f3 - f13), (double)(f17 + (float)b0), (double)((f14 + (float)b0) * f10 + f8), (double)((f15 + (float)b0) * f10 + f9)); + tessellator.addVertexWithUV((double)(f16 + (float)b0), (double)(f4 + f3 - f13), (double)(f17 + 0.0F), (double)((f14 + (float)b0) * f10 + f8), (double)((f15 + 0.0F) * f10 + f9)); + tessellator.addVertexWithUV((double)(f16 + 0.0F), (double)(f4 + f3 - f13), (double)(f17 + 0.0F), (double)((f14 + 0.0F) * f10 + f8), (double)((f15 + 0.0F) * f10 + f9)); + } + + tessellator.setColorRGBA_F(f5 * 0.9F, f6 * 0.9F, f7 * 0.9F, 0.8F); + int j1; + + if (l > -1) + { + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + + for (j1 = 0; j1 < b0; ++j1) + { + tessellator.addVertexWithUV((double)(f16 + (float)j1 + 0.0F), (double)(f4 + 0.0F), (double)(f17 + (float)b0), (double)((f14 + (float)j1 + 0.5F) * f10 + f8), (double)((f15 + (float)b0) * f10 + f9)); + tessellator.addVertexWithUV((double)(f16 + (float)j1 + 0.0F), (double)(f4 + f3), (double)(f17 + (float)b0), (double)((f14 + (float)j1 + 0.5F) * f10 + f8), (double)((f15 + (float)b0) * f10 + f9)); + tessellator.addVertexWithUV((double)(f16 + (float)j1 + 0.0F), (double)(f4 + f3), (double)(f17 + 0.0F), (double)((f14 + (float)j1 + 0.5F) * f10 + f8), (double)((f15 + 0.0F) * f10 + f9)); + tessellator.addVertexWithUV((double)(f16 + (float)j1 + 0.0F), (double)(f4 + 0.0F), (double)(f17 + 0.0F), (double)((f14 + (float)j1 + 0.5F) * f10 + f8), (double)((f15 + 0.0F) * f10 + f9)); + } + } + + if (l <= 1) + { + tessellator.setNormal(1.0F, 0.0F, 0.0F); + + for (j1 = 0; j1 < b0; ++j1) + { + tessellator.addVertexWithUV((double)(f16 + (float)j1 + 1.0F - f13), (double)(f4 + 0.0F), (double)(f17 + (float)b0), (double)((f14 + (float)j1 + 0.5F) * f10 + f8), (double)((f15 + (float)b0) * f10 + f9)); + tessellator.addVertexWithUV((double)(f16 + (float)j1 + 1.0F - f13), (double)(f4 + f3), (double)(f17 + (float)b0), (double)((f14 + (float)j1 + 0.5F) * f10 + f8), (double)((f15 + (float)b0) * f10 + f9)); + tessellator.addVertexWithUV((double)(f16 + (float)j1 + 1.0F - f13), (double)(f4 + f3), (double)(f17 + 0.0F), (double)((f14 + (float)j1 + 0.5F) * f10 + f8), (double)((f15 + 0.0F) * f10 + f9)); + tessellator.addVertexWithUV((double)(f16 + (float)j1 + 1.0F - f13), (double)(f4 + 0.0F), (double)(f17 + 0.0F), (double)((f14 + (float)j1 + 0.5F) * f10 + f8), (double)((f15 + 0.0F) * f10 + f9)); + } + } + + tessellator.setColorRGBA_F(f5 * 0.8F, f6 * 0.8F, f7 * 0.8F, 0.8F); + + if (i1 > -1) + { + tessellator.setNormal(0.0F, 0.0F, -1.0F); + + for (j1 = 0; j1 < b0; ++j1) + { + tessellator.addVertexWithUV((double)(f16 + 0.0F), (double)(f4 + f3), (double)(f17 + (float)j1 + 0.0F), (double)((f14 + 0.0F) * f10 + f8), (double)((f15 + (float)j1 + 0.5F) * f10 + f9)); + tessellator.addVertexWithUV((double)(f16 + (float)b0), (double)(f4 + f3), (double)(f17 + (float)j1 + 0.0F), (double)((f14 + (float)b0) * f10 + f8), (double)((f15 + (float)j1 + 0.5F) * f10 + f9)); + tessellator.addVertexWithUV((double)(f16 + (float)b0), (double)(f4 + 0.0F), (double)(f17 + (float)j1 + 0.0F), (double)((f14 + (float)b0) * f10 + f8), (double)((f15 + (float)j1 + 0.5F) * f10 + f9)); + tessellator.addVertexWithUV((double)(f16 + 0.0F), (double)(f4 + 0.0F), (double)(f17 + (float)j1 + 0.0F), (double)((f14 + 0.0F) * f10 + f8), (double)((f15 + (float)j1 + 0.5F) * f10 + f9)); + } + } + + if (i1 <= 1) + { + tessellator.setNormal(0.0F, 0.0F, 1.0F); + + for (j1 = 0; j1 < b0; ++j1) + { + tessellator.addVertexWithUV((double)(f16 + 0.0F), (double)(f4 + f3), (double)(f17 + (float)j1 + 1.0F - f13), (double)((f14 + 0.0F) * f10 + f8), (double)((f15 + (float)j1 + 0.5F) * f10 + f9)); + tessellator.addVertexWithUV((double)(f16 + (float)b0), (double)(f4 + f3), (double)(f17 + (float)j1 + 1.0F - f13), (double)((f14 + (float)b0) * f10 + f8), (double)((f15 + (float)j1 + 0.5F) * f10 + f9)); + tessellator.addVertexWithUV((double)(f16 + (float)b0), (double)(f4 + 0.0F), (double)(f17 + (float)j1 + 1.0F - f13), (double)((f14 + (float)b0) * f10 + f8), (double)((f15 + (float)j1 + 0.5F) * f10 + f9)); + tessellator.addVertexWithUV((double)(f16 + 0.0F), (double)(f4 + 0.0F), (double)(f17 + (float)j1 + 1.0F - f13), (double)((f14 + 0.0F) * f10 + f8), (double)((f15 + (float)j1 + 0.5F) * f10 + f9)); + } + } + + tessellator.draw(); + } + } + } + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_CULL_FACE); + } + + public boolean updateRenderers(EntityLivingBase par1EntityLivingBase, boolean par2) + { + byte b0 = 2; + RenderSorter rendersorter = new RenderSorter(par1EntityLivingBase); + WorldRenderer[] aworldrenderer = new WorldRenderer[b0]; + ArrayList arraylist = null; + int i = this.worldRenderersToUpdate.size(); + int j = 0; + this.theWorld.theProfiler.startSection("nearChunksSearch"); + int k; + WorldRenderer worldrenderer; + int l; + int i1; + label136: + + for (k = 0; k < i; ++k) + { + worldrenderer = (WorldRenderer)this.worldRenderersToUpdate.get(k); + + if (worldrenderer != null) + { + if (!par2) + { + if (worldrenderer.distanceToEntitySquared(par1EntityLivingBase) > 272.0F) + { + for (l = 0; l < b0 && (aworldrenderer[l] == null || rendersorter.compare(aworldrenderer[l], worldrenderer) <= 0); ++l) + { + ; + } + + --l; + + if (l > 0) + { + i1 = l; + + while (true) + { + --i1; + + if (i1 == 0) + { + aworldrenderer[l] = worldrenderer; + continue label136; + } + + aworldrenderer[i1 - 1] = aworldrenderer[i1]; + } + } + + continue; + } + } + else if (!worldrenderer.isInFrustum) + { + continue; + } + + if (arraylist == null) + { + arraylist = new ArrayList(); + } + + ++j; + arraylist.add(worldrenderer); + this.worldRenderersToUpdate.set(k, (Object)null); + } + } + + this.theWorld.theProfiler.endSection(); + this.theWorld.theProfiler.startSection("sort"); + + if (arraylist != null) + { + if (arraylist.size() > 1) + { + Collections.sort(arraylist, rendersorter); + } + + for (k = arraylist.size() - 1; k >= 0; --k) + { + worldrenderer = (WorldRenderer)arraylist.get(k); + worldrenderer.updateRenderer(par1EntityLivingBase); + worldrenderer.needsUpdate = false; + } + } + + this.theWorld.theProfiler.endSection(); + k = 0; + this.theWorld.theProfiler.startSection("rebuild"); + int k1; + + for (k1 = b0 - 1; k1 >= 0; --k1) + { + WorldRenderer worldrenderer2 = aworldrenderer[k1]; + + if (worldrenderer2 != null) + { + if (!worldrenderer2.isInFrustum && k1 != b0 - 1) + { + aworldrenderer[k1] = null; + aworldrenderer[0] = null; + break; + } + + aworldrenderer[k1].updateRenderer(par1EntityLivingBase); + aworldrenderer[k1].needsUpdate = false; + ++k; + } + } + + this.theWorld.theProfiler.endSection(); + this.theWorld.theProfiler.startSection("cleanup"); + k1 = 0; + l = 0; + + for (i1 = this.worldRenderersToUpdate.size(); k1 != i1; ++k1) + { + WorldRenderer worldrenderer1 = (WorldRenderer)this.worldRenderersToUpdate.get(k1); + + if (worldrenderer1 != null) + { + boolean flag1 = false; + + for (int j1 = 0; j1 < b0 && !flag1; ++j1) + { + if (worldrenderer1 == aworldrenderer[j1]) + { + flag1 = true; + } + } + + if (!flag1) + { + if (l != k1) + { + this.worldRenderersToUpdate.set(l, worldrenderer1); + } + + ++l; + } + } + } + + this.theWorld.theProfiler.endSection(); + this.theWorld.theProfiler.startSection("trim"); + + while (true) + { + --k1; + + if (k1 < l) + { + this.theWorld.theProfiler.endSection(); + return i == j + k; + } + + this.worldRenderersToUpdate.remove(k1); + } + } + + public void drawBlockDamageTexture(Tessellator par1Tessellator, EntityPlayer par2EntityPlayer, float par3) + { + drawBlockDamageTexture(par1Tessellator, (EntityLivingBase)par2EntityPlayer, par3); + } + + public void drawBlockDamageTexture(Tessellator par1Tessellator, EntityLivingBase par2EntityPlayer, float par3) + { + double d0 = par2EntityPlayer.lastTickPosX + (par2EntityPlayer.posX - par2EntityPlayer.lastTickPosX) * (double)par3; + double d1 = par2EntityPlayer.lastTickPosY + (par2EntityPlayer.posY - par2EntityPlayer.lastTickPosY) * (double)par3; + double d2 = par2EntityPlayer.lastTickPosZ + (par2EntityPlayer.posZ - par2EntityPlayer.lastTickPosZ) * (double)par3; + + if (!this.damagedBlocks.isEmpty()) + { + OpenGlHelper.glBlendFunc(774, 768, 1, 0); + this.renderEngine.bindTexture(TextureMap.locationBlocksTexture); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F); + GL11.glPushMatrix(); + GL11.glPolygonOffset(-3.0F, -3.0F); + GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL); + GL11.glEnable(GL11.GL_ALPHA_TEST); + par1Tessellator.startDrawingQuads(); + par1Tessellator.setTranslation(-d0, -d1, -d2); + par1Tessellator.disableColor(); + Iterator iterator = this.damagedBlocks.values().iterator(); + + while (iterator.hasNext()) + { + DestroyBlockProgress destroyblockprogress = (DestroyBlockProgress)iterator.next(); + double d3 = (double)destroyblockprogress.getPartialBlockX() - d0; + double d4 = (double)destroyblockprogress.getPartialBlockY() - d1; + double d5 = (double)destroyblockprogress.getPartialBlockZ() - d2; + + if (d3 * d3 + d4 * d4 + d5 * d5 > 1024.0D) + { + iterator.remove(); + } + else + { + Block block = this.theWorld.getBlock(destroyblockprogress.getPartialBlockX(), destroyblockprogress.getPartialBlockY(), destroyblockprogress.getPartialBlockZ()); + + if (block.getMaterial() != Material.air) + { + this.renderBlocksRg.renderBlockUsingTexture(block, destroyblockprogress.getPartialBlockX(), destroyblockprogress.getPartialBlockY(), destroyblockprogress.getPartialBlockZ(), this.destroyBlockIcons[destroyblockprogress.getPartialBlockDamage()]); + } + } + } + + par1Tessellator.draw(); + par1Tessellator.setTranslation(0.0D, 0.0D, 0.0D); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glPolygonOffset(0.0F, 0.0F); + GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glDepthMask(true); + GL11.glPopMatrix(); + } + } + + public void drawSelectionBox(EntityPlayer par1EntityPlayer, MovingObjectPosition par2MovingObjectPosition, int par3, float par4) + { + if (par3 == 0 && par2MovingObjectPosition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) + { + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glColor4f(0.0F, 0.0F, 0.0F, 0.4F); + GL11.glLineWidth(2.0F); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDepthMask(false); + float f1 = 0.002F; + Block block = this.theWorld.getBlock(par2MovingObjectPosition.blockX, par2MovingObjectPosition.blockY, par2MovingObjectPosition.blockZ); + + if (block.getMaterial() != Material.air) + { + block.setBlockBoundsBasedOnState(this.theWorld, par2MovingObjectPosition.blockX, par2MovingObjectPosition.blockY, par2MovingObjectPosition.blockZ); + double d0 = par1EntityPlayer.lastTickPosX + (par1EntityPlayer.posX - par1EntityPlayer.lastTickPosX) * (double)par4; + double d1 = par1EntityPlayer.lastTickPosY + (par1EntityPlayer.posY - par1EntityPlayer.lastTickPosY) * (double)par4; + double d2 = par1EntityPlayer.lastTickPosZ + (par1EntityPlayer.posZ - par1EntityPlayer.lastTickPosZ) * (double)par4; + drawOutlinedBoundingBox(block.getSelectedBoundingBoxFromPool(this.theWorld, par2MovingObjectPosition.blockX, par2MovingObjectPosition.blockY, par2MovingObjectPosition.blockZ).expand((double)f1, (double)f1, (double)f1).getOffsetBoundingBox(-d0, -d1, -d2), -1); + } + + GL11.glDepthMask(true); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_BLEND); + } + } + + public static void drawOutlinedBoundingBox(AxisAlignedBB p_147590_0_, int p_147590_1_) + { + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawing(3); + + if (p_147590_1_ != -1) + { + tessellator.setColorOpaque_I(p_147590_1_); + } + + tessellator.addVertex(p_147590_0_.minX, p_147590_0_.minY, p_147590_0_.minZ); + tessellator.addVertex(p_147590_0_.maxX, p_147590_0_.minY, p_147590_0_.minZ); + tessellator.addVertex(p_147590_0_.maxX, p_147590_0_.minY, p_147590_0_.maxZ); + tessellator.addVertex(p_147590_0_.minX, p_147590_0_.minY, p_147590_0_.maxZ); + tessellator.addVertex(p_147590_0_.minX, p_147590_0_.minY, p_147590_0_.minZ); + tessellator.draw(); + tessellator.startDrawing(3); + + if (p_147590_1_ != -1) + { + tessellator.setColorOpaque_I(p_147590_1_); + } + + tessellator.addVertex(p_147590_0_.minX, p_147590_0_.maxY, p_147590_0_.minZ); + tessellator.addVertex(p_147590_0_.maxX, p_147590_0_.maxY, p_147590_0_.minZ); + tessellator.addVertex(p_147590_0_.maxX, p_147590_0_.maxY, p_147590_0_.maxZ); + tessellator.addVertex(p_147590_0_.minX, p_147590_0_.maxY, p_147590_0_.maxZ); + tessellator.addVertex(p_147590_0_.minX, p_147590_0_.maxY, p_147590_0_.minZ); + tessellator.draw(); + tessellator.startDrawing(1); + + if (p_147590_1_ != -1) + { + tessellator.setColorOpaque_I(p_147590_1_); + } + + tessellator.addVertex(p_147590_0_.minX, p_147590_0_.minY, p_147590_0_.minZ); + tessellator.addVertex(p_147590_0_.minX, p_147590_0_.maxY, p_147590_0_.minZ); + tessellator.addVertex(p_147590_0_.maxX, p_147590_0_.minY, p_147590_0_.minZ); + tessellator.addVertex(p_147590_0_.maxX, p_147590_0_.maxY, p_147590_0_.minZ); + tessellator.addVertex(p_147590_0_.maxX, p_147590_0_.minY, p_147590_0_.maxZ); + tessellator.addVertex(p_147590_0_.maxX, p_147590_0_.maxY, p_147590_0_.maxZ); + tessellator.addVertex(p_147590_0_.minX, p_147590_0_.minY, p_147590_0_.maxZ); + tessellator.addVertex(p_147590_0_.minX, p_147590_0_.maxY, p_147590_0_.maxZ); + tessellator.draw(); + } + + public void markBlocksForUpdate(int par1, int par2, int par3, int par4, int par5, int par6) + { + int k1 = MathHelper.bucketInt(par1, 16); + int l1 = MathHelper.bucketInt(par2, 16); + int i2 = MathHelper.bucketInt(par3, 16); + int j2 = MathHelper.bucketInt(par4, 16); + int k2 = MathHelper.bucketInt(par5, 16); + int l2 = MathHelper.bucketInt(par6, 16); + + for (int i3 = k1; i3 <= j2; ++i3) + { + int j3 = i3 % this.renderChunksWide; + + if (j3 < 0) + { + j3 += this.renderChunksWide; + } + + for (int k3 = l1; k3 <= k2; ++k3) + { + int l3 = k3 % this.renderChunksTall; + + if (l3 < 0) + { + l3 += this.renderChunksTall; + } + + for (int i4 = i2; i4 <= l2; ++i4) + { + int j4 = i4 % this.renderChunksDeep; + + if (j4 < 0) + { + j4 += this.renderChunksDeep; + } + + int k4 = (j4 * this.renderChunksTall + l3) * this.renderChunksWide + j3; + WorldRenderer worldrenderer = this.worldRenderers[k4]; + + if (worldrenderer != null && !worldrenderer.needsUpdate) + { + this.worldRenderersToUpdate.add(worldrenderer); + worldrenderer.markDirty(); + } + } + } + } + } + + public void markBlockForUpdate(int p_147586_1_, int p_147586_2_, int p_147586_3_) + { + this.markBlocksForUpdate(p_147586_1_ - 1, p_147586_2_ - 1, p_147586_3_ - 1, p_147586_1_ + 1, p_147586_2_ + 1, p_147586_3_ + 1); + } + + public void markBlockForRenderUpdate(int p_147588_1_, int p_147588_2_, int p_147588_3_) + { + this.markBlocksForUpdate(p_147588_1_ - 1, p_147588_2_ - 1, p_147588_3_ - 1, p_147588_1_ + 1, p_147588_2_ + 1, p_147588_3_ + 1); + } + + public void markBlockRangeForRenderUpdate(int p_147585_1_, int p_147585_2_, int p_147585_3_, int p_147585_4_, int p_147585_5_, int p_147585_6_) + { + this.markBlocksForUpdate(p_147585_1_ - 1, p_147585_2_ - 1, p_147585_3_ - 1, p_147585_4_ + 1, p_147585_5_ + 1, p_147585_6_ + 1); + } + + public void clipRenderersByFrustum(ICamera par1ICamera, float par2) + { + for (int i = 0; i < this.worldRenderers.length; ++i) + { + if (!this.worldRenderers[i].skipAllRenderPasses() && (!this.worldRenderers[i].isInFrustum || (i + this.frustumCheckOffset & 15) == 0)) + { + this.worldRenderers[i].updateInFrustum(par1ICamera); + } + } + + ++this.frustumCheckOffset; + } + + public void playRecord(String par1Str, int par2, int par3, int par4) + { + ChunkCoordinates chunkcoordinates = new ChunkCoordinates(par2, par3, par4); + ISound isound = (ISound)this.mapSoundPositions.get(chunkcoordinates); + + if (isound != null) + { + this.mc.getSoundHandler().stopSound(isound); + this.mapSoundPositions.remove(chunkcoordinates); + } + + if (par1Str != null) + { + ItemRecord itemrecord = ItemRecord.getRecord(par1Str); + + ResourceLocation resource = null; + if (itemrecord != null) + { + this.mc.ingameGUI.setRecordPlayingMessage(itemrecord.getRecordNameLocal()); + resource = itemrecord.getRecordResource(par1Str); + } + + if (resource == null) resource = new ResourceLocation(par1Str); + PositionedSoundRecord positionedsoundrecord = PositionedSoundRecord.func_147675_a(resource, (float)par2, (float)par3, (float)par4); + this.mapSoundPositions.put(chunkcoordinates, positionedsoundrecord); + this.mc.getSoundHandler().playSound(positionedsoundrecord); + } + } + + public void playSound(String par1Str, double par2, double par4, double par6, float par8, float par9) {} + + public void playSoundToNearExcept(EntityPlayer par1EntityPlayer, String par2Str, double par3, double par5, double par7, float par9, float par10) {} + + public void spawnParticle(String par1Str, final double par2, final double par4, final double par6, double par8, double par10, double par12) + { + try + { + this.doSpawnParticle(par1Str, par2, par4, par6, par8, par10, par12); + } + catch (Throwable throwable) + { + CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Exception while adding particle"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("Particle being added"); + crashreportcategory.addCrashSection("Name", par1Str); + crashreportcategory.addCrashSectionCallable("Position", new Callable() + { + private static final String __OBFID = "CL_00000955"; + public String call() + { + return CrashReportCategory.func_85074_a(par2, par4, par6); + } + }); + throw new ReportedException(crashreport); + } + } + + public EntityFX doSpawnParticle(String par1Str, double par2, double par4, double par6, double par8, double par10, double par12) + { + if (this.mc != null && this.mc.renderViewEntity != null && this.mc.effectRenderer != null) + { + int i = this.mc.gameSettings.particleSetting; + + if (i == 1 && this.theWorld.rand.nextInt(3) == 0) + { + i = 2; + } + + double d6 = this.mc.renderViewEntity.posX - par2; + double d7 = this.mc.renderViewEntity.posY - par4; + double d8 = this.mc.renderViewEntity.posZ - par6; + EntityFX entityfx = null; + + if (par1Str.equals("hugeexplosion")) + { + this.mc.effectRenderer.addEffect(entityfx = new EntityHugeExplodeFX(this.theWorld, par2, par4, par6, par8, par10, par12)); + } + else if (par1Str.equals("largeexplode")) + { + this.mc.effectRenderer.addEffect(entityfx = new EntityLargeExplodeFX(this.renderEngine, this.theWorld, par2, par4, par6, par8, par10, par12)); + } + else if (par1Str.equals("fireworksSpark")) + { + this.mc.effectRenderer.addEffect(entityfx = new EntityFireworkSparkFX(this.theWorld, par2, par4, par6, par8, par10, par12, this.mc.effectRenderer)); + } + + if (entityfx != null) + { + return (EntityFX)entityfx; + } + else + { + double d9 = 16.0D; + + if (d6 * d6 + d7 * d7 + d8 * d8 > d9 * d9) + { + return null; + } + else if (i > 1) + { + return null; + } + else + { + if (par1Str.equals("bubble")) + { + entityfx = new EntityBubbleFX(this.theWorld, par2, par4, par6, par8, par10, par12); + } + else if (par1Str.equals("suspended")) + { + entityfx = new EntitySuspendFX(this.theWorld, par2, par4, par6, par8, par10, par12); + } + else if (par1Str.equals("depthsuspend")) + { + entityfx = new EntityAuraFX(this.theWorld, par2, par4, par6, par8, par10, par12); + } + else if (par1Str.equals("townaura")) + { + entityfx = new EntityAuraFX(this.theWorld, par2, par4, par6, par8, par10, par12); + } + else if (par1Str.equals("crit")) + { + entityfx = new EntityCritFX(this.theWorld, par2, par4, par6, par8, par10, par12); + } + else if (par1Str.equals("magicCrit")) + { + entityfx = new EntityCritFX(this.theWorld, par2, par4, par6, par8, par10, par12); + ((EntityFX)entityfx).setRBGColorF(((EntityFX)entityfx).getRedColorF() * 0.3F, ((EntityFX)entityfx).getGreenColorF() * 0.8F, ((EntityFX)entityfx).getBlueColorF()); + ((EntityFX)entityfx).nextTextureIndexX(); + } + else if (par1Str.equals("smoke")) + { + entityfx = new EntitySmokeFX(this.theWorld, par2, par4, par6, par8, par10, par12); + } + else if (par1Str.equals("mobSpell")) + { + entityfx = new EntitySpellParticleFX(this.theWorld, par2, par4, par6, 0.0D, 0.0D, 0.0D); + ((EntityFX)entityfx).setRBGColorF((float)par8, (float)par10, (float)par12); + } + else if (par1Str.equals("mobSpellAmbient")) + { + entityfx = new EntitySpellParticleFX(this.theWorld, par2, par4, par6, 0.0D, 0.0D, 0.0D); + ((EntityFX)entityfx).setAlphaF(0.15F); + ((EntityFX)entityfx).setRBGColorF((float)par8, (float)par10, (float)par12); + } + else if (par1Str.equals("spell")) + { + entityfx = new EntitySpellParticleFX(this.theWorld, par2, par4, par6, par8, par10, par12); + } + else if (par1Str.equals("instantSpell")) + { + entityfx = new EntitySpellParticleFX(this.theWorld, par2, par4, par6, par8, par10, par12); + ((EntitySpellParticleFX)entityfx).setBaseSpellTextureIndex(144); + } + else if (par1Str.equals("witchMagic")) + { + entityfx = new EntitySpellParticleFX(this.theWorld, par2, par4, par6, par8, par10, par12); + ((EntitySpellParticleFX)entityfx).setBaseSpellTextureIndex(144); + float f = this.theWorld.rand.nextFloat() * 0.5F + 0.35F; + ((EntityFX)entityfx).setRBGColorF(1.0F * f, 0.0F * f, 1.0F * f); + } + else if (par1Str.equals("note")) + { + entityfx = new EntityNoteFX(this.theWorld, par2, par4, par6, par8, par10, par12); + } + else if (par1Str.equals("portal")) + { + entityfx = new EntityPortalFX(this.theWorld, par2, par4, par6, par8, par10, par12); + } + else if (par1Str.equals("enchantmenttable")) + { + entityfx = new EntityEnchantmentTableParticleFX(this.theWorld, par2, par4, par6, par8, par10, par12); + } + else if (par1Str.equals("explode")) + { + entityfx = new EntityExplodeFX(this.theWorld, par2, par4, par6, par8, par10, par12); + } + else if (par1Str.equals("flame")) + { + entityfx = new EntityFlameFX(this.theWorld, par2, par4, par6, par8, par10, par12); + } + else if (par1Str.equals("lava")) + { + entityfx = new EntityLavaFX(this.theWorld, par2, par4, par6); + } + else if (par1Str.equals("footstep")) + { + entityfx = new EntityFootStepFX(this.renderEngine, this.theWorld, par2, par4, par6); + } + else if (par1Str.equals("splash")) + { + entityfx = new EntitySplashFX(this.theWorld, par2, par4, par6, par8, par10, par12); + } + else if (par1Str.equals("wake")) + { + entityfx = new EntityFishWakeFX(this.theWorld, par2, par4, par6, par8, par10, par12); + } + else if (par1Str.equals("largesmoke")) + { + entityfx = new EntitySmokeFX(this.theWorld, par2, par4, par6, par8, par10, par12, 2.5F); + } + else if (par1Str.equals("cloud")) + { + entityfx = new EntityCloudFX(this.theWorld, par2, par4, par6, par8, par10, par12); + } + else if (par1Str.equals("reddust")) + { + entityfx = new EntityReddustFX(this.theWorld, par2, par4, par6, (float)par8, (float)par10, (float)par12); + } + else if (par1Str.equals("snowballpoof")) + { + entityfx = new EntityBreakingFX(this.theWorld, par2, par4, par6, Items.snowball); + } + else if (par1Str.equals("dripWater")) + { + entityfx = new EntityDropParticleFX(this.theWorld, par2, par4, par6, Material.water); + } + else if (par1Str.equals("dripLava")) + { + entityfx = new EntityDropParticleFX(this.theWorld, par2, par4, par6, Material.lava); + } + else if (par1Str.equals("snowshovel")) + { + entityfx = new EntitySnowShovelFX(this.theWorld, par2, par4, par6, par8, par10, par12); + } + else if (par1Str.equals("slime")) + { + entityfx = new EntityBreakingFX(this.theWorld, par2, par4, par6, Items.slime_ball); + } + else if (par1Str.equals("heart")) + { + entityfx = new EntityHeartFX(this.theWorld, par2, par4, par6, par8, par10, par12); + } + else if (par1Str.equals("angryVillager")) + { + entityfx = new EntityHeartFX(this.theWorld, par2, par4 + 0.5D, par6, par8, par10, par12); + ((EntityFX)entityfx).setParticleTextureIndex(81); + ((EntityFX)entityfx).setRBGColorF(1.0F, 1.0F, 1.0F); + } + else if (par1Str.equals("happyVillager")) + { + entityfx = new EntityAuraFX(this.theWorld, par2, par4, par6, par8, par10, par12); + ((EntityFX)entityfx).setParticleTextureIndex(82); + ((EntityFX)entityfx).setRBGColorF(1.0F, 1.0F, 1.0F); + } + else + { + int k; + String[] astring; + + if (par1Str.startsWith("iconcrack_")) + { + astring = par1Str.split("_", 3); + int j = Integer.parseInt(astring[1]); + + if (astring.length > 2) + { + k = Integer.parseInt(astring[2]); + entityfx = new EntityBreakingFX(this.theWorld, par2, par4, par6, par8, par10, par12, Item.getItemById(j), k); + } + else + { + entityfx = new EntityBreakingFX(this.theWorld, par2, par4, par6, par8, par10, par12, Item.getItemById(j), 0); + } + } + else + { + Block block; + + if (par1Str.startsWith("blockcrack_")) + { + astring = par1Str.split("_", 3); + block = Block.getBlockById(Integer.parseInt(astring[1])); + k = Integer.parseInt(astring[2]); + entityfx = (new EntityDiggingFX(this.theWorld, par2, par4, par6, par8, par10, par12, block, k)).applyRenderColor(k); + } + else if (par1Str.startsWith("blockdust_")) + { + astring = par1Str.split("_", 3); + block = Block.getBlockById(Integer.parseInt(astring[1])); + k = Integer.parseInt(astring[2]); + entityfx = (new EntityBlockDustFX(this.theWorld, par2, par4, par6, par8, par10, par12, block, k)).applyRenderColor(k); + } + } + } + + if (entityfx != null) + { + this.mc.effectRenderer.addEffect((EntityFX)entityfx); + } + + return (EntityFX)entityfx; + } + } + } + else + { + return null; + } + } + + public void onEntityCreate(Entity par1Entity) {} + + public void onEntityDestroy(Entity par1Entity) {} + + public void deleteAllDisplayLists() + { + GLAllocation.deleteDisplayLists(this.glRenderListBase); + } + + public void broadcastSound(int par1, int par2, int par3, int par4, int par5) + { + Random random = this.theWorld.rand; + + switch (par1) + { + case 1013: + case 1018: + if (this.mc.renderViewEntity != null) + { + double d0 = (double)par2 - this.mc.renderViewEntity.posX; + double d1 = (double)par3 - this.mc.renderViewEntity.posY; + double d2 = (double)par4 - this.mc.renderViewEntity.posZ; + double d3 = Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2); + double d4 = this.mc.renderViewEntity.posX; + double d5 = this.mc.renderViewEntity.posY; + double d6 = this.mc.renderViewEntity.posZ; + + if (d3 > 0.0D) + { + d4 += d0 / d3 * 2.0D; + d5 += d1 / d3 * 2.0D; + d6 += d2 / d3 * 2.0D; + } + + if (par1 == 1013) + { + this.theWorld.playSound(d4, d5, d6, "mob.wither.spawn", 1.0F, 1.0F, false); + } + else if (par1 == 1018) + { + this.theWorld.playSound(d4, d5, d6, "mob.enderdragon.end", 5.0F, 1.0F, false); + } + } + default: + } + } + + public void playAuxSFX(EntityPlayer par1EntityPlayer, int par2, int par3, int par4, int par5, int par6) + { + Random random = this.theWorld.rand; + Block block = null; + double d0; + double d1; + double d2; + String s; + int k1; + double d4; + double d5; + double d6; + double d7; + int l2; + double d13; + + switch (par2) + { + case 1000: + this.theWorld.playSound((double)par3, (double)par4, (double)par5, "random.click", 1.0F, 1.0F, false); + break; + case 1001: + this.theWorld.playSound((double)par3, (double)par4, (double)par5, "random.click", 1.0F, 1.2F, false); + break; + case 1002: + this.theWorld.playSound((double)par3, (double)par4, (double)par5, "random.bow", 1.0F, 1.2F, false); + break; + case 1003: + if (Math.random() < 0.5D) + { + this.theWorld.playSound((double)par3 + 0.5D, (double)par4 + 0.5D, (double)par5 + 0.5D, "random.door_open", 1.0F, this.theWorld.rand.nextFloat() * 0.1F + 0.9F, false); + } + else + { + this.theWorld.playSound((double)par3 + 0.5D, (double)par4 + 0.5D, (double)par5 + 0.5D, "random.door_close", 1.0F, this.theWorld.rand.nextFloat() * 0.1F + 0.9F, false); + } + + break; + case 1004: + this.theWorld.playSound((double)((float)par3 + 0.5F), (double)((float)par4 + 0.5F), (double)((float)par5 + 0.5F), "random.fizz", 0.5F, 2.6F + (random.nextFloat() - random.nextFloat()) * 0.8F, false); + break; + case 1005: + if (Item.getItemById(par6) instanceof ItemRecord) + { + this.theWorld.playRecord("records." + ((ItemRecord)Item.getItemById(par6)).recordName, par3, par4, par5); + } + else + { + this.theWorld.playRecord((String)null, par3, par4, par5); + } + + break; + case 1007: + this.theWorld.playSound((double)par3 + 0.5D, (double)par4 + 0.5D, (double)par5 + 0.5D, "mob.ghast.charge", 10.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F, false); + break; + case 1008: + this.theWorld.playSound((double)par3 + 0.5D, (double)par4 + 0.5D, (double)par5 + 0.5D, "mob.ghast.fireball", 10.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F, false); + break; + case 1009: + this.theWorld.playSound((double)par3 + 0.5D, (double)par4 + 0.5D, (double)par5 + 0.5D, "mob.ghast.fireball", 2.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F, false); + break; + case 1010: + this.theWorld.playSound((double)par3 + 0.5D, (double)par4 + 0.5D, (double)par5 + 0.5D, "mob.zombie.wood", 2.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F, false); + break; + case 1011: + this.theWorld.playSound((double)par3 + 0.5D, (double)par4 + 0.5D, (double)par5 + 0.5D, "mob.zombie.metal", 2.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F, false); + break; + case 1012: + this.theWorld.playSound((double)par3 + 0.5D, (double)par4 + 0.5D, (double)par5 + 0.5D, "mob.zombie.woodbreak", 2.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F, false); + break; + case 1014: + this.theWorld.playSound((double)par3 + 0.5D, (double)par4 + 0.5D, (double)par5 + 0.5D, "mob.wither.shoot", 2.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F, false); + break; + case 1015: + this.theWorld.playSound((double)par3 + 0.5D, (double)par4 + 0.5D, (double)par5 + 0.5D, "mob.bat.takeoff", 0.05F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F, false); + break; + case 1016: + this.theWorld.playSound((double)par3 + 0.5D, (double)par4 + 0.5D, (double)par5 + 0.5D, "mob.zombie.infect", 2.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F, false); + break; + case 1017: + this.theWorld.playSound((double)par3 + 0.5D, (double)par4 + 0.5D, (double)par5 + 0.5D, "mob.zombie.unfect", 2.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F, false); + break; + case 1020: + this.theWorld.playSound((double)((float)par3 + 0.5F), (double)((float)par4 + 0.5F), (double)((float)par5 + 0.5F), "random.anvil_break", 1.0F, this.theWorld.rand.nextFloat() * 0.1F + 0.9F, false); + break; + case 1021: + this.theWorld.playSound((double)((float)par3 + 0.5F), (double)((float)par4 + 0.5F), (double)((float)par5 + 0.5F), "random.anvil_use", 1.0F, this.theWorld.rand.nextFloat() * 0.1F + 0.9F, false); + break; + case 1022: + this.theWorld.playSound((double)((float)par3 + 0.5F), (double)((float)par4 + 0.5F), (double)((float)par5 + 0.5F), "random.anvil_land", 0.3F, this.theWorld.rand.nextFloat() * 0.1F + 0.9F, false); + break; + case 2000: + int j2 = par6 % 3 - 1; + int j1 = par6 / 3 % 3 - 1; + d1 = (double)par3 + (double)j2 * 0.6D + 0.5D; + d2 = (double)par4 + 0.5D; + double d9 = (double)par5 + (double)j1 * 0.6D + 0.5D; + + for (int k2 = 0; k2 < 10; ++k2) + { + double d11 = random.nextDouble() * 0.2D + 0.01D; + double d12 = d1 + (double)j2 * 0.01D + (random.nextDouble() - 0.5D) * (double)j1 * 0.5D; + d4 = d2 + (random.nextDouble() - 0.5D) * 0.5D; + d13 = d9 + (double)j1 * 0.01D + (random.nextDouble() - 0.5D) * (double)j2 * 0.5D; + d5 = (double)j2 * d11 + random.nextGaussian() * 0.01D; + d6 = -0.03D + random.nextGaussian() * 0.01D; + d7 = (double)j1 * d11 + random.nextGaussian() * 0.01D; + this.spawnParticle("smoke", d12, d4, d13, d5, d6, d7); + } + + return; + case 2001: + block = Block.getBlockById(par6 & 4095); + + if (block.getMaterial() != Material.air) + { + this.mc.getSoundHandler().playSound(new PositionedSoundRecord(new ResourceLocation(block.stepSound.getBreakSound()), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F, (float)par3 + 0.5F, (float)par4 + 0.5F, (float)par5 + 0.5F)); + } + + this.mc.effectRenderer.addBlockDestroyEffects(par3, par4, par5, block, par6 >> 12 & 255); + break; + case 2002: + d0 = (double)par3; + d1 = (double)par4; + d2 = (double)par5; + s = "iconcrack_" + Item.getIdFromItem(Items.potionitem) + "_" + par6; + + for (k1 = 0; k1 < 8; ++k1) + { + this.spawnParticle(s, d0, d1, d2, random.nextGaussian() * 0.15D, random.nextDouble() * 0.2D, random.nextGaussian() * 0.15D); + } + + k1 = Items.potionitem.getColorFromDamage(par6); + float f = (float)(k1 >> 16 & 255) / 255.0F; + float f1 = (float)(k1 >> 8 & 255) / 255.0F; + float f2 = (float)(k1 >> 0 & 255) / 255.0F; + String s1 = "spell"; + + if (Items.potionitem.isEffectInstant(par6)) + { + s1 = "instantSpell"; + } + + for (l2 = 0; l2 < 100; ++l2) + { + d4 = random.nextDouble() * 4.0D; + d13 = random.nextDouble() * Math.PI * 2.0D; + d5 = Math.cos(d13) * d4; + d6 = 0.01D + random.nextDouble() * 0.5D; + d7 = Math.sin(d13) * d4; + EntityFX entityfx = this.doSpawnParticle(s1, d0 + d5 * 0.1D, d1 + 0.3D, d2 + d7 * 0.1D, d5, d6, d7); + + if (entityfx != null) + { + float f4 = 0.75F + random.nextFloat() * 0.25F; + entityfx.setRBGColorF(f * f4, f1 * f4, f2 * f4); + entityfx.multiplyVelocity((float)d4); + } + } + + this.theWorld.playSound((double)par3 + 0.5D, (double)par4 + 0.5D, (double)par5 + 0.5D, "game.potion.smash", 1.0F, this.theWorld.rand.nextFloat() * 0.1F + 0.9F, false); + break; + case 2003: + d0 = (double)par3 + 0.5D; + d1 = (double)par4; + d2 = (double)par5 + 0.5D; + s = "iconcrack_" + Item.getIdFromItem(Items.ender_eye); + + for (k1 = 0; k1 < 8; ++k1) + { + this.spawnParticle(s, d0, d1, d2, random.nextGaussian() * 0.15D, random.nextDouble() * 0.2D, random.nextGaussian() * 0.15D); + } + + for (double d10 = 0.0D; d10 < (Math.PI * 2D); d10 += 0.15707963267948966D) + { + this.spawnParticle("portal", d0 + Math.cos(d10) * 5.0D, d1 - 0.4D, d2 + Math.sin(d10) * 5.0D, Math.cos(d10) * -5.0D, 0.0D, Math.sin(d10) * -5.0D); + this.spawnParticle("portal", d0 + Math.cos(d10) * 5.0D, d1 - 0.4D, d2 + Math.sin(d10) * 5.0D, Math.cos(d10) * -7.0D, 0.0D, Math.sin(d10) * -7.0D); + } + + return; + case 2004: + for (l2 = 0; l2 < 20; ++l2) + { + d4 = (double)par3 + 0.5D + ((double)this.theWorld.rand.nextFloat() - 0.5D) * 2.0D; + d13 = (double)par4 + 0.5D + ((double)this.theWorld.rand.nextFloat() - 0.5D) * 2.0D; + d5 = (double)par5 + 0.5D + ((double)this.theWorld.rand.nextFloat() - 0.5D) * 2.0D; + this.theWorld.spawnParticle("smoke", d4, d13, d5, 0.0D, 0.0D, 0.0D); + this.theWorld.spawnParticle("flame", d4, d13, d5, 0.0D, 0.0D, 0.0D); + } + + return; + case 2005: + ItemDye.func_150918_a(this.theWorld, par3, par4, par5, par6); + break; + case 2006: + block = this.theWorld.getBlock(par3, par4, par5); + + if (block.getMaterial() != Material.air) + { + double d3 = (double)Math.min(0.2F + (float)par6 / 15.0F, 10.0F); + + if (d3 > 2.5D) + { + d3 = 2.5D; + } + + int l1 = (int)(150.0D * d3); + + for (int i2 = 0; i2 < l1; ++i2) + { + float f3 = MathHelper.randomFloatClamp(random, 0.0F, ((float)Math.PI * 2F)); + d5 = (double)MathHelper.randomFloatClamp(random, 0.75F, 1.0F); + d6 = 0.20000000298023224D + d3 / 100.0D; + d7 = (double)(MathHelper.cos(f3) * 0.2F) * d5 * d5 * (d3 + 0.2D); + double d8 = (double)(MathHelper.sin(f3) * 0.2F) * d5 * d5 * (d3 + 0.2D); + this.theWorld.spawnParticle("blockdust_" + Block.getIdFromBlock(block) + "_" + this.theWorld.getBlockMetadata(par3, par4, par5), (double)((float)par3 + 0.5F), (double)((float)par4 + 1.0F), (double)((float)par5 + 0.5F), d7, d6, d8); + } + } + } + } + + public void destroyBlockPartially(int p_147587_1_, int p_147587_2_, int p_147587_3_, int p_147587_4_, int p_147587_5_) + { + if (p_147587_5_ >= 0 && p_147587_5_ < 10) + { + DestroyBlockProgress destroyblockprogress = (DestroyBlockProgress)this.damagedBlocks.get(Integer.valueOf(p_147587_1_)); + + if (destroyblockprogress == null || destroyblockprogress.getPartialBlockX() != p_147587_2_ || destroyblockprogress.getPartialBlockY() != p_147587_3_ || destroyblockprogress.getPartialBlockZ() != p_147587_4_) + { + destroyblockprogress = new DestroyBlockProgress(p_147587_1_, p_147587_2_, p_147587_3_, p_147587_4_); + this.damagedBlocks.put(Integer.valueOf(p_147587_1_), destroyblockprogress); + } + + destroyblockprogress.setPartialBlockDamage(p_147587_5_); + destroyblockprogress.setCloudUpdateTick(this.cloudTickCounter); + } + else + { + this.damagedBlocks.remove(Integer.valueOf(p_147587_1_)); + } + } + + public void registerDestroyBlockIcons(IIconRegister par1IconRegister) + { + this.destroyBlockIcons = new IIcon[10]; + + for (int i = 0; i < this.destroyBlockIcons.length; ++i) + { + this.destroyBlockIcons[i] = par1IconRegister.registerIcon("destroy_stage_" + i); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/RenderHelper.java b/src/main/java/net/minecraft/client/renderer/RenderHelper.java new file mode 100644 index 0000000..d30f888 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/RenderHelper.java @@ -0,0 +1,68 @@ +package net.minecraft.client.renderer; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.nio.FloatBuffer; +import net.minecraft.util.Vec3; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class RenderHelper +{ + private static FloatBuffer colorBuffer = GLAllocation.createDirectFloatBuffer(16); + private static final Vec3 field_82884_b = Vec3.createVectorHelper(0.20000000298023224D, 1.0D, -0.699999988079071D).normalize(); + private static final Vec3 field_82885_c = Vec3.createVectorHelper(-0.20000000298023224D, 1.0D, 0.699999988079071D).normalize(); + private static final String __OBFID = "CL_00000629"; + + public static void disableStandardItemLighting() + { + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_LIGHT0); + GL11.glDisable(GL11.GL_LIGHT1); + GL11.glDisable(GL11.GL_COLOR_MATERIAL); + } + + public static void enableStandardItemLighting() + { + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_LIGHT0); + GL11.glEnable(GL11.GL_LIGHT1); + GL11.glEnable(GL11.GL_COLOR_MATERIAL); + GL11.glColorMaterial(GL11.GL_FRONT_AND_BACK, GL11.GL_AMBIENT_AND_DIFFUSE); + float f = 0.4F; + float f1 = 0.6F; + float f2 = 0.0F; + GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, setColorBuffer(field_82884_b.xCoord, field_82884_b.yCoord, field_82884_b.zCoord, 0.0D)); + GL11.glLight(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, setColorBuffer(f1, f1, f1, 1.0F)); + GL11.glLight(GL11.GL_LIGHT0, GL11.GL_AMBIENT, setColorBuffer(0.0F, 0.0F, 0.0F, 1.0F)); + GL11.glLight(GL11.GL_LIGHT0, GL11.GL_SPECULAR, setColorBuffer(f2, f2, f2, 1.0F)); + GL11.glLight(GL11.GL_LIGHT1, GL11.GL_POSITION, setColorBuffer(field_82885_c.xCoord, field_82885_c.yCoord, field_82885_c.zCoord, 0.0D)); + GL11.glLight(GL11.GL_LIGHT1, GL11.GL_DIFFUSE, setColorBuffer(f1, f1, f1, 1.0F)); + GL11.glLight(GL11.GL_LIGHT1, GL11.GL_AMBIENT, setColorBuffer(0.0F, 0.0F, 0.0F, 1.0F)); + GL11.glLight(GL11.GL_LIGHT1, GL11.GL_SPECULAR, setColorBuffer(f2, f2, f2, 1.0F)); + GL11.glShadeModel(GL11.GL_FLAT); + GL11.glLightModel(GL11.GL_LIGHT_MODEL_AMBIENT, setColorBuffer(f, f, f, 1.0F)); + } + + private static FloatBuffer setColorBuffer(double par0, double par2, double par4, double par6) + { + return setColorBuffer((float)par0, (float)par2, (float)par4, (float)par6); + } + + private static FloatBuffer setColorBuffer(float par0, float par1, float par2, float par3) + { + colorBuffer.clear(); + colorBuffer.put(par0).put(par1).put(par2).put(par3); + colorBuffer.flip(); + return colorBuffer; + } + + public static void enableGUIStandardItemLighting() + { + GL11.glPushMatrix(); + GL11.glRotatef(-30.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(165.0F, 1.0F, 0.0F, 0.0F); + enableStandardItemLighting(); + GL11.glPopMatrix(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/RenderList.java b/src/main/java/net/minecraft/client/renderer/RenderList.java new file mode 100644 index 0000000..2e62f60 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/RenderList.java @@ -0,0 +1,74 @@ +package net.minecraft.client.renderer; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.nio.IntBuffer; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class RenderList +{ + public int renderChunkX; + public int renderChunkY; + public int renderChunkZ; + private double cameraX; + private double cameraY; + private double cameraZ; + private IntBuffer glLists = GLAllocation.createDirectIntBuffer(65536); + private boolean valid; + private boolean bufferFlipped; + private static final String __OBFID = "CL_00000957"; + + public void setupRenderList(int par1, int par2, int par3, double par4, double par6, double par8) + { + this.valid = true; + this.glLists.clear(); + this.renderChunkX = par1; + this.renderChunkY = par2; + this.renderChunkZ = par3; + this.cameraX = par4; + this.cameraY = par6; + this.cameraZ = par8; + } + + public boolean rendersChunk(int par1, int par2, int par3) + { + return !this.valid ? false : par1 == this.renderChunkX && par2 == this.renderChunkY && par3 == this.renderChunkZ; + } + + public void addGLRenderList(int par1) + { + this.glLists.put(par1); + + if (this.glLists.remaining() == 0) + { + this.callLists(); + } + } + + public void callLists() + { + if (this.valid) + { + if (!this.bufferFlipped) + { + this.glLists.flip(); + this.bufferFlipped = true; + } + + if (this.glLists.remaining() > 0) + { + GL11.glPushMatrix(); + GL11.glTranslatef((float)((double)this.renderChunkX - this.cameraX), (float)((double)this.renderChunkY - this.cameraY), (float)((double)this.renderChunkZ - this.cameraZ)); + GL11.glCallLists(this.glLists); + GL11.glPopMatrix(); + } + } + } + + public void resetList() + { + this.valid = false; + this.bufferFlipped = false; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/RenderSorter.java b/src/main/java/net/minecraft/client/renderer/RenderSorter.java new file mode 100644 index 0000000..25398fc --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/RenderSorter.java @@ -0,0 +1,41 @@ +package net.minecraft.client.renderer; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Comparator; +import net.minecraft.entity.EntityLivingBase; + +@SideOnly(Side.CLIENT) +public class RenderSorter implements Comparator +{ + private EntityLivingBase baseEntity; + private static final String __OBFID = "CL_00000943"; + + public RenderSorter(EntityLivingBase par1EntityLivingBase) + { + this.baseEntity = par1EntityLivingBase; + } + + public int compare(WorldRenderer par1WorldRenderer, WorldRenderer par2WorldRenderer) + { + if (par1WorldRenderer.isInFrustum && !par2WorldRenderer.isInFrustum) + { + return 1; + } + else if (par2WorldRenderer.isInFrustum && !par1WorldRenderer.isInFrustum) + { + return -1; + } + else + { + double d0 = (double)par1WorldRenderer.distanceToEntitySquared(this.baseEntity); + double d1 = (double)par2WorldRenderer.distanceToEntitySquared(this.baseEntity); + return d0 < d1 ? 1 : (d0 > d1 ? -1 : (par1WorldRenderer.chunkIndex < par2WorldRenderer.chunkIndex ? 1 : -1)); + } + } + + public int compare(Object par1Obj, Object par2Obj) + { + return this.compare((WorldRenderer)par1Obj, (WorldRenderer)par2Obj); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/StitcherException.java b/src/main/java/net/minecraft/client/renderer/StitcherException.java new file mode 100644 index 0000000..ffbbb2b --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/StitcherException.java @@ -0,0 +1,18 @@ +package net.minecraft.client.renderer; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.texture.Stitcher; + +@SideOnly(Side.CLIENT) +public class StitcherException extends RuntimeException +{ + private final Stitcher.Holder field_98149_a; + private static final String __OBFID = "CL_00001057"; + + public StitcherException(Stitcher.Holder par1StitchHolder, String par2Str) + { + super(par2Str); + this.field_98149_a = par1StitchHolder; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/Tessellator.java b/src/main/java/net/minecraft/client/renderer/Tessellator.java new file mode 100644 index 0000000..a5cdcf8 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/Tessellator.java @@ -0,0 +1,413 @@ +package net.minecraft.client.renderer; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; +import java.nio.ShortBuffer; +import java.util.Arrays; +import java.util.PriorityQueue; +import net.minecraft.client.shader.TesselatorVertexState; +import net.minecraft.client.util.QuadComparator; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class Tessellator +{ + private static int nativeBufferSize = 0x200000; + private static int trivertsInBuffer = (nativeBufferSize / 48) * 6; + public static boolean renderingWorldRenderer = false; + public boolean defaultTexture = false; + private int rawBufferSize = 0; + public int textureID = 0; + + private static ByteBuffer byteBuffer = GLAllocation.createDirectByteBuffer(nativeBufferSize * 4); + private static IntBuffer intBuffer = byteBuffer.asIntBuffer(); + private static FloatBuffer floatBuffer = byteBuffer.asFloatBuffer(); + private static ShortBuffer shortBuffer = byteBuffer.asShortBuffer(); + private int[] rawBuffer; + private int vertexCount; + private double textureU; + private double textureV; + private int brightness; + private int color; + private boolean hasColor; + private boolean hasTexture; + private boolean hasBrightness; + private boolean hasNormals; + private int rawBufferIndex; + private int addedVertices; + private boolean isColorDisabled; + private int drawMode; + private double xOffset; + private double yOffset; + private double zOffset; + private int normal; + public static final Tessellator instance = new Tessellator(2097152); + private boolean isDrawing; + private int bufferSize; + private static final String __OBFID = "CL_00000960"; + + private Tessellator(int par1) + { + } + + public Tessellator() + { + } + + static + { + instance.defaultTexture = true; + } + + public int draw() + { + if (!this.isDrawing) + { + throw new IllegalStateException("Not tesselating!"); + } + else + { + this.isDrawing = false; + + int offs = 0; + while (offs < vertexCount) + { + int vtc = Math.min(vertexCount - offs, nativeBufferSize >> 5); + this.intBuffer.clear(); + this.intBuffer.put(this.rawBuffer, offs * 8, vtc * 8); + this.byteBuffer.position(0); + this.byteBuffer.limit(vtc * 32); + offs += vtc; + + if (this.hasTexture) + { + this.floatBuffer.position(3); + GL11.glTexCoordPointer(2, 32, this.floatBuffer); + GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); + } + + if (this.hasBrightness) + { + OpenGlHelper.setClientActiveTexture(OpenGlHelper.lightmapTexUnit); + this.shortBuffer.position(14); + GL11.glTexCoordPointer(2, 32, this.shortBuffer); + GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); + OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit); + } + + if (this.hasColor) + { + this.byteBuffer.position(20); + GL11.glColorPointer(4, true, 32, this.byteBuffer); + GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); + } + + if (this.hasNormals) + { + this.byteBuffer.position(24); + GL11.glNormalPointer(32, this.byteBuffer); + GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY); + } + + this.floatBuffer.position(0); + GL11.glVertexPointer(3, 32, this.floatBuffer); + GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); + GL11.glDrawArrays(this.drawMode, 0, vtc); + GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); + + if (this.hasTexture) + { + GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY); + } + + if (this.hasBrightness) + { + OpenGlHelper.setClientActiveTexture(OpenGlHelper.lightmapTexUnit); + GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY); + OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit); + } + + if (this.hasColor) + { + GL11.glDisableClientState(GL11.GL_COLOR_ARRAY); + } + + if (this.hasNormals) + { + GL11.glDisableClientState(GL11.GL_NORMAL_ARRAY); + } + } + + if (rawBufferSize > 0x20000 && rawBufferIndex < (rawBufferSize << 3)) + { + rawBufferSize = 0x10000; + rawBuffer = new int[rawBufferSize]; + } + + int i = this.rawBufferIndex * 4; + this.reset(); + return i; + } + } + + public TesselatorVertexState getVertexState(float p_147564_1_, float p_147564_2_, float p_147564_3_) + { + int[] aint = new int[this.rawBufferIndex]; + PriorityQueue priorityqueue = new PriorityQueue(this.rawBufferIndex, new QuadComparator(this.rawBuffer, p_147564_1_ + (float)this.xOffset, p_147564_2_ + (float)this.yOffset, p_147564_3_ + (float)this.zOffset)); + byte b0 = 32; + int i; + + for (i = 0; i < this.rawBufferIndex; i += b0) + { + priorityqueue.add(Integer.valueOf(i)); + } + + for (i = 0; !priorityqueue.isEmpty(); i += b0) + { + int j = ((Integer)priorityqueue.remove()).intValue(); + + for (int k = 0; k < b0; ++k) + { + aint[i + k] = this.rawBuffer[j + k]; + } + } + + System.arraycopy(aint, 0, this.rawBuffer, 0, aint.length); + return new TesselatorVertexState(aint, this.rawBufferIndex, this.vertexCount, this.hasTexture, this.hasBrightness, this.hasNormals, this.hasColor); + } + + public void setVertexState(TesselatorVertexState p_147565_1_) + { + while (p_147565_1_.getRawBuffer().length > rawBufferSize && rawBufferSize > 0) + { + rawBufferSize <<= 1; + } + if (rawBufferSize > rawBuffer.length) + { + rawBuffer = new int[rawBufferSize]; + } + System.arraycopy(p_147565_1_.getRawBuffer(), 0, this.rawBuffer, 0, p_147565_1_.getRawBuffer().length); + this.rawBufferIndex = p_147565_1_.getRawBufferIndex(); + this.vertexCount = p_147565_1_.getVertexCount(); + this.hasTexture = p_147565_1_.getHasTexture(); + this.hasBrightness = p_147565_1_.getHasBrightness(); + this.hasColor = p_147565_1_.getHasColor(); + this.hasNormals = p_147565_1_.getHasNormals(); + } + + private void reset() + { + this.vertexCount = 0; + this.byteBuffer.clear(); + this.rawBufferIndex = 0; + this.addedVertices = 0; + } + + public void startDrawingQuads() + { + this.startDrawing(7); + } + + public void startDrawing(int par1) + { + if (this.isDrawing) + { + throw new IllegalStateException("Already tesselating!"); + } + else + { + this.isDrawing = true; + this.reset(); + this.drawMode = par1; + this.hasNormals = false; + this.hasColor = false; + this.hasTexture = false; + this.hasBrightness = false; + this.isColorDisabled = false; + } + } + + public void setTextureUV(double par1, double par3) + { + this.hasTexture = true; + this.textureU = par1; + this.textureV = par3; + } + + public void setBrightness(int par1) + { + this.hasBrightness = true; + this.brightness = par1; + } + + public void setColorOpaque_F(float par1, float par2, float par3) + { + this.setColorOpaque((int)(par1 * 255.0F), (int)(par2 * 255.0F), (int)(par3 * 255.0F)); + } + + public void setColorRGBA_F(float par1, float par2, float par3, float par4) + { + this.setColorRGBA((int)(par1 * 255.0F), (int)(par2 * 255.0F), (int)(par3 * 255.0F), (int)(par4 * 255.0F)); + } + + public void setColorOpaque(int par1, int par2, int par3) + { + this.setColorRGBA(par1, par2, par3, 255); + } + + public void setColorRGBA(int par1, int par2, int par3, int par4) + { + if (!this.isColorDisabled) + { + if (par1 > 255) + { + par1 = 255; + } + + if (par2 > 255) + { + par2 = 255; + } + + if (par3 > 255) + { + par3 = 255; + } + + if (par4 > 255) + { + par4 = 255; + } + + if (par1 < 0) + { + par1 = 0; + } + + if (par2 < 0) + { + par2 = 0; + } + + if (par3 < 0) + { + par3 = 0; + } + + if (par4 < 0) + { + par4 = 0; + } + + this.hasColor = true; + + if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) + { + this.color = par4 << 24 | par3 << 16 | par2 << 8 | par1; + } + else + { + this.color = par1 << 24 | par2 << 16 | par3 << 8 | par4; + } + } + } + + public void addVertexWithUV(double par1, double par3, double par5, double par7, double par9) + { + this.setTextureUV(par7, par9); + this.addVertex(par1, par3, par5); + } + + public void addVertex(double par1, double par3, double par5) + { + if (rawBufferIndex >= rawBufferSize - 32) + { + if (rawBufferSize == 0) + { + rawBufferSize = 0x10000; + rawBuffer = new int[rawBufferSize]; + } + else + { + rawBufferSize *= 2; + rawBuffer = Arrays.copyOf(rawBuffer, rawBufferSize); + } + } + ++this.addedVertices; + + if (this.hasTexture) + { + this.rawBuffer[this.rawBufferIndex + 3] = Float.floatToRawIntBits((float)this.textureU); + this.rawBuffer[this.rawBufferIndex + 4] = Float.floatToRawIntBits((float)this.textureV); + } + + if (this.hasBrightness) + { + this.rawBuffer[this.rawBufferIndex + 7] = this.brightness; + } + + if (this.hasColor) + { + this.rawBuffer[this.rawBufferIndex + 5] = this.color; + } + + if (this.hasNormals) + { + this.rawBuffer[this.rawBufferIndex + 6] = this.normal; + } + + this.rawBuffer[this.rawBufferIndex + 0] = Float.floatToRawIntBits((float)(par1 + this.xOffset)); + this.rawBuffer[this.rawBufferIndex + 1] = Float.floatToRawIntBits((float)(par3 + this.yOffset)); + this.rawBuffer[this.rawBufferIndex + 2] = Float.floatToRawIntBits((float)(par5 + this.zOffset)); + this.rawBufferIndex += 8; + ++this.vertexCount; + } + + public void setColorOpaque_I(int par1) + { + int j = par1 >> 16 & 255; + int k = par1 >> 8 & 255; + int l = par1 & 255; + this.setColorOpaque(j, k, l); + } + + public void setColorRGBA_I(int par1, int par2) + { + int k = par1 >> 16 & 255; + int l = par1 >> 8 & 255; + int i1 = par1 & 255; + this.setColorRGBA(k, l, i1, par2); + } + + public void disableColor() + { + this.isColorDisabled = true; + } + + public void setNormal(float par1, float par2, float par3) + { + this.hasNormals = true; + byte b0 = (byte)((int)(par1 * 127.0F)); + byte b1 = (byte)((int)(par2 * 127.0F)); + byte b2 = (byte)((int)(par3 * 127.0F)); + this.normal = b0 & 255 | (b1 & 255) << 8 | (b2 & 255) << 16; + } + + public void setTranslation(double par1, double par3, double par5) + { + this.xOffset = par1; + this.yOffset = par3; + this.zOffset = par5; + } + + public void addTranslation(float par1, float par2, float par3) + { + this.xOffset += (double)par1; + this.yOffset += (double)par2; + this.zOffset += (double)par3; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/ThreadDownloadImageData.java b/src/main/java/net/minecraft/client/renderer/ThreadDownloadImageData.java new file mode 100644 index 0000000..59cf553 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/ThreadDownloadImageData.java @@ -0,0 +1,127 @@ +package net.minecraft.client.renderer; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.concurrent.atomic.AtomicInteger; +import javax.imageio.ImageIO; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.texture.SimpleTexture; +import net.minecraft.client.renderer.texture.TextureUtil; +import net.minecraft.client.resources.IResourceManager; +import net.minecraft.util.ResourceLocation; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +@SideOnly(Side.CLIENT) +public class ThreadDownloadImageData extends SimpleTexture +{ + private static final Logger logger = LogManager.getLogger(); + private static final AtomicInteger threadDownloadCounter = new AtomicInteger(0); + private final String imageUrl; + private final IImageBuffer imageBuffer; + private BufferedImage bufferedImage; + private Thread imageThread; + private boolean textureUploaded; + private static final String __OBFID = "CL_00001049"; + + public ThreadDownloadImageData(String par1Str, ResourceLocation par2ResourceLocation, IImageBuffer par3IImageBuffer) + { + super(par2ResourceLocation); + this.imageUrl = par1Str; + this.imageBuffer = par3IImageBuffer; + } + + private void checkTextureUploaded() + { + if (!this.textureUploaded) + { + if (this.bufferedImage != null) + { + if (this.textureLocation != null) + { + this.deleteGlTexture(); + } + + TextureUtil.uploadTextureImage(super.getGlTextureId(), this.bufferedImage); + this.textureUploaded = true; + } + } + } + + public int getGlTextureId() + { + this.checkTextureUploaded(); + return super.getGlTextureId(); + } + + public void setBufferedImage(BufferedImage p_147641_1_) + { + this.bufferedImage = p_147641_1_; + } + + public void loadTexture(IResourceManager par1ResourceManager) throws IOException + { + if (this.bufferedImage == null && this.textureLocation != null) + { + super.loadTexture(par1ResourceManager); + } + + if (this.imageThread == null) + { + this.imageThread = new Thread("Texture Downloader #" + threadDownloadCounter.incrementAndGet()) + { + private static final String __OBFID = "CL_00001050"; + public void run() + { + HttpURLConnection httpurlconnection = null; + + try + { + httpurlconnection = (HttpURLConnection)(new URL(ThreadDownloadImageData.this.imageUrl)).openConnection(Minecraft.getMinecraft().getProxy()); + httpurlconnection.setDoInput(true); + httpurlconnection.setDoOutput(false); + httpurlconnection.connect(); + + if (httpurlconnection.getResponseCode() / 100 == 2) + { + BufferedImage bufferedimage = ImageIO.read(httpurlconnection.getInputStream()); + + if (ThreadDownloadImageData.this.imageBuffer != null) + { + bufferedimage = ThreadDownloadImageData.this.imageBuffer.parseUserSkin(bufferedimage); + } + + ThreadDownloadImageData.this.setBufferedImage(bufferedimage); + return; + } + } + catch (Exception exception) + { + ThreadDownloadImageData.logger.error("Couldn\'t download http texture", exception); + return; + } + finally + { + if (httpurlconnection != null) + { + httpurlconnection.disconnect(); + } + } + } + }; + this.imageThread.setDaemon(true); + this.imageThread.setName("Skin downloader: " + this.imageUrl); + this.imageThread.start(); + } + } + + public boolean isTextureUploaded() + { + this.checkTextureUploaded(); + return this.textureUploaded; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/WorldRenderer.java b/src/main/java/net/minecraft/client/renderer/WorldRenderer.java new file mode 100644 index 0000000..d1024db --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/WorldRenderer.java @@ -0,0 +1,315 @@ +package net.minecraft.client.renderer; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.culling.ICamera; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; +import net.minecraft.client.shader.TesselatorVertexState; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.MathHelper; +import net.minecraft.world.ChunkCache; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class WorldRenderer +{ + private TesselatorVertexState vertexState; + public World worldObj; + private int glRenderList = -1; + //private static Tessellator tessellator = Tessellator.instance; + public static int chunksUpdated; + public int posX; + public int posY; + public int posZ; + public int posXMinus; + public int posYMinus; + public int posZMinus; + public int posXClip; + public int posYClip; + public int posZClip; + public boolean isInFrustum; + public boolean[] skipRenderPass = new boolean[2]; + public int posXPlus; + public int posYPlus; + public int posZPlus; + public boolean needsUpdate; + public AxisAlignedBB rendererBoundingBox; + public int chunkIndex; + public boolean isVisible = true; + public boolean isWaitingOnOcclusionQuery; + public int glOcclusionQuery; + public boolean isChunkLit; + private boolean isInitialized; + public List tileEntityRenderers = new ArrayList(); + private List tileEntities; + private int bytesDrawn; + private static final String __OBFID = "CL_00000942"; + + public WorldRenderer(World par1World, List par2List, int par3, int par4, int par5, int par6) + { + this.worldObj = par1World; + this.vertexState = null; + this.tileEntities = par2List; + this.glRenderList = par6; + this.posX = -999; + this.setPosition(par3, par4, par5); + this.needsUpdate = false; + } + + public void setPosition(int par1, int par2, int par3) + { + if (par1 != this.posX || par2 != this.posY || par3 != this.posZ) + { + this.setDontDraw(); + this.posX = par1; + this.posY = par2; + this.posZ = par3; + this.posXPlus = par1 + 8; + this.posYPlus = par2 + 8; + this.posZPlus = par3 + 8; + this.posXClip = par1 & 1023; + this.posYClip = par2; + this.posZClip = par3 & 1023; + this.posXMinus = par1 - this.posXClip; + this.posYMinus = par2 - this.posYClip; + this.posZMinus = par3 - this.posZClip; + float f = 6.0F; + this.rendererBoundingBox = AxisAlignedBB.getBoundingBox((double)((float)par1 - f), (double)((float)par2 - f), (double)((float)par3 - f), (double)((float)(par1 + 16) + f), (double)((float)(par2 + 16) + f), (double)((float)(par3 + 16) + f)); + GL11.glNewList(this.glRenderList + 2, GL11.GL_COMPILE); + RenderItem.renderAABB(AxisAlignedBB.getAABBPool().getAABB((double)((float)this.posXClip - f), (double)((float)this.posYClip - f), (double)((float)this.posZClip - f), (double)((float)(this.posXClip + 16) + f), (double)((float)(this.posYClip + 16) + f), (double)((float)(this.posZClip + 16) + f))); + GL11.glEndList(); + this.markDirty(); + } + } + + private void setupGLTranslation() + { + GL11.glTranslatef((float)this.posXClip, (float)this.posYClip, (float)this.posZClip); + } + + public void updateRenderer(EntityLivingBase p_147892_1_) + { + if (this.needsUpdate) + { + this.needsUpdate = false; + int i = this.posX; + int j = this.posY; + int k = this.posZ; + int l = this.posX + 16; + int i1 = this.posY + 16; + int j1 = this.posZ + 16; + + for (int k1 = 0; k1 < 2; ++k1) + { + this.skipRenderPass[k1] = true; + } + + Chunk.isLit = false; + HashSet hashset = new HashSet(); + hashset.addAll(this.tileEntityRenderers); + this.tileEntityRenderers.clear(); + Minecraft minecraft = Minecraft.getMinecraft(); + EntityLivingBase entitylivingbase1 = minecraft.renderViewEntity; + int l1 = MathHelper.floor_double(entitylivingbase1.posX); + int i2 = MathHelper.floor_double(entitylivingbase1.posY); + int j2 = MathHelper.floor_double(entitylivingbase1.posZ); + byte b0 = 1; + ChunkCache chunkcache = new ChunkCache(this.worldObj, i - b0, j - b0, k - b0, l + b0, i1 + b0, j1 + b0, b0); + + if (!chunkcache.extendedLevelsInChunkCache()) + { + ++chunksUpdated; + RenderBlocks renderblocks = new RenderBlocks(chunkcache); + this.bytesDrawn = 0; + this.vertexState = null; + + for (int k2 = 0; k2 < 2; ++k2) + { + boolean flag = false; + boolean flag1 = false; + boolean flag2 = false; + + for (int l2 = j; l2 < i1; ++l2) + { + for (int i3 = k; i3 < j1; ++i3) + { + for (int j3 = i; j3 < l; ++j3) + { + Block block = chunkcache.getBlock(j3, l2, i3); + + if (block.getMaterial() != Material.air) + { + if (!flag2) + { + flag2 = true; + this.preRenderBlocks(k2); + } + + if (k2 == 0 && block.hasTileEntity(chunkcache.getBlockMetadata(j3, l2, i3))) + { + TileEntity tileentity = chunkcache.getTileEntity(j3, l2, i3); + + if (TileEntityRendererDispatcher.instance.hasSpecialRenderer(tileentity)) + { + this.tileEntityRenderers.add(tileentity); + } + } + + int k3 = block.getRenderBlockPass(); + + if (k3 > k2) + { + flag = true; + } + + if (!block.canRenderInPass(k2)) continue; + + { + flag1 |= renderblocks.renderBlockByRenderType(block, j3, l2, i3); + + if (block.getRenderType() == 0 && j3 == l1 && l2 == i2 && i3 == j2) + { + renderblocks.setRenderFromInside(true); + renderblocks.setRenderAllFaces(true); + renderblocks.renderBlockByRenderType(block, j3, l2, i3); + renderblocks.setRenderFromInside(false); + renderblocks.setRenderAllFaces(false); + } + } + } + } + } + } + + if (flag1) + { + this.skipRenderPass[k2] = false; + } + + if (flag2) + { + this.postRenderBlocks(k2, p_147892_1_); + } + else + { + flag1 = false; + } + + if (!flag) + { + break; + } + } + } + + HashSet hashset1 = new HashSet(); + hashset1.addAll(this.tileEntityRenderers); + hashset1.removeAll(hashset); + this.tileEntities.addAll(hashset1); + hashset.removeAll(this.tileEntityRenderers); + this.tileEntities.removeAll(hashset); + this.isChunkLit = Chunk.isLit; + this.isInitialized = true; + } + } + + private void preRenderBlocks(int p_147890_1_) + { + GL11.glNewList(this.glRenderList + p_147890_1_, GL11.GL_COMPILE); + GL11.glPushMatrix(); + this.setupGLTranslation(); + float f = 1.000001F; + GL11.glTranslatef(-8.0F, -8.0F, -8.0F); + GL11.glScalef(f, f, f); + GL11.glTranslatef(8.0F, 8.0F, 8.0F); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setTranslation((double)(-this.posX), (double)(-this.posY), (double)(-this.posZ)); + } + + private void postRenderBlocks(int p_147891_1_, EntityLivingBase p_147891_2_) + { + if (p_147891_1_ == 1 && !this.skipRenderPass[p_147891_1_]) + { + this.vertexState = Tessellator.instance.getVertexState((float)p_147891_2_.posX, (float)p_147891_2_.posY, (float)p_147891_2_.posZ); + } + + //ForgeHooksClient.afterRenderPass(l1); Noop fo now, TODO: Event if anyone needs + this.bytesDrawn += Tessellator.instance.draw(); + GL11.glPopMatrix(); + GL11.glEndList(); + Tessellator.instance.setTranslation(0.0D, 0.0D, 0.0D); + } + + public void updateRendererSort(EntityLivingBase p_147889_1_) + { + if (this.vertexState != null && !this.skipRenderPass[1]) + { + this.preRenderBlocks(1); + Tessellator.instance.setVertexState(this.vertexState); + this.postRenderBlocks(1, p_147889_1_); + } + } + + public float distanceToEntitySquared(Entity par1Entity) + { + float f = (float)(par1Entity.posX - (double)this.posXPlus); + float f1 = (float)(par1Entity.posY - (double)this.posYPlus); + float f2 = (float)(par1Entity.posZ - (double)this.posZPlus); + return f * f + f1 * f1 + f2 * f2; + } + + public void setDontDraw() + { + for (int i = 0; i < 2; ++i) + { + this.skipRenderPass[i] = true; + } + + this.isInFrustum = false; + this.isInitialized = false; + this.vertexState = null; + } + + public void stopRendering() + { + this.setDontDraw(); + this.worldObj = null; + } + + public int getGLCallListForPass(int par1) + { + return !this.isInFrustum ? -1 : (!this.skipRenderPass[par1] ? this.glRenderList + par1 : -1); + } + + public void updateInFrustum(ICamera par1ICamera) + { + this.isInFrustum = par1ICamera.isBoundingBoxInFrustum(this.rendererBoundingBox); + } + + public void callOcclusionQueryList() + { + GL11.glCallList(this.glRenderList + 2); + } + + public boolean skipAllRenderPasses() + { + return !this.isInitialized ? false : this.skipRenderPass[0] && this.skipRenderPass[1]; + } + + public void markDirty() + { + this.needsUpdate = true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/culling/ClippingHelper.java b/src/main/java/net/minecraft/client/renderer/culling/ClippingHelper.java new file mode 100644 index 0000000..bcafb92 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/culling/ClippingHelper.java @@ -0,0 +1,27 @@ +package net.minecraft.client.renderer.culling; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class ClippingHelper +{ + public float[][] frustum = new float[16][16]; + public float[] projectionMatrix = new float[16]; + public float[] modelviewMatrix = new float[16]; + public float[] clippingMatrix = new float[16]; + private static final String __OBFID = "CL_00000977"; + + public boolean isBoxInFrustum(double par1, double par3, double par5, double par7, double par9, double par11) + { + for (int i = 0; i < 6; ++i) + { + if ((double)this.frustum[i][0] * par1 + (double)this.frustum[i][1] * par3 + (double)this.frustum[i][2] * par5 + (double)this.frustum[i][3] <= 0.0D && (double)this.frustum[i][0] * par7 + (double)this.frustum[i][1] * par3 + (double)this.frustum[i][2] * par5 + (double)this.frustum[i][3] <= 0.0D && (double)this.frustum[i][0] * par1 + (double)this.frustum[i][1] * par9 + (double)this.frustum[i][2] * par5 + (double)this.frustum[i][3] <= 0.0D && (double)this.frustum[i][0] * par7 + (double)this.frustum[i][1] * par9 + (double)this.frustum[i][2] * par5 + (double)this.frustum[i][3] <= 0.0D && (double)this.frustum[i][0] * par1 + (double)this.frustum[i][1] * par3 + (double)this.frustum[i][2] * par11 + (double)this.frustum[i][3] <= 0.0D && (double)this.frustum[i][0] * par7 + (double)this.frustum[i][1] * par3 + (double)this.frustum[i][2] * par11 + (double)this.frustum[i][3] <= 0.0D && (double)this.frustum[i][0] * par1 + (double)this.frustum[i][1] * par9 + (double)this.frustum[i][2] * par11 + (double)this.frustum[i][3] <= 0.0D && (double)this.frustum[i][0] * par7 + (double)this.frustum[i][1] * par9 + (double)this.frustum[i][2] * par11 + (double)this.frustum[i][3] <= 0.0D) + { + return false; + } + } + + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/culling/ClippingHelperImpl.java b/src/main/java/net/minecraft/client/renderer/culling/ClippingHelperImpl.java new file mode 100644 index 0000000..37cad3a --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/culling/ClippingHelperImpl.java @@ -0,0 +1,92 @@ +package net.minecraft.client.renderer.culling; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.nio.FloatBuffer; +import net.minecraft.client.renderer.GLAllocation; +import net.minecraft.util.MathHelper; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class ClippingHelperImpl extends ClippingHelper +{ + private static ClippingHelperImpl instance = new ClippingHelperImpl(); + private FloatBuffer projectionMatrixBuffer = GLAllocation.createDirectFloatBuffer(16); + private FloatBuffer modelviewMatrixBuffer = GLAllocation.createDirectFloatBuffer(16); + private FloatBuffer field_78564_h = GLAllocation.createDirectFloatBuffer(16); + private static final String __OBFID = "CL_00000975"; + + public static ClippingHelper getInstance() + { + instance.init(); + return instance; + } + + private void normalize(float[][] par1ArrayOfFloat, int par2) + { + float f = MathHelper.sqrt_float(par1ArrayOfFloat[par2][0] * par1ArrayOfFloat[par2][0] + par1ArrayOfFloat[par2][1] * par1ArrayOfFloat[par2][1] + par1ArrayOfFloat[par2][2] * par1ArrayOfFloat[par2][2]); + par1ArrayOfFloat[par2][0] /= f; + par1ArrayOfFloat[par2][1] /= f; + par1ArrayOfFloat[par2][2] /= f; + par1ArrayOfFloat[par2][3] /= f; + } + + private void init() + { + this.projectionMatrixBuffer.clear(); + this.modelviewMatrixBuffer.clear(); + this.field_78564_h.clear(); + GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, this.projectionMatrixBuffer); + GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, this.modelviewMatrixBuffer); + this.projectionMatrixBuffer.flip().limit(16); + this.projectionMatrixBuffer.get(this.projectionMatrix); + this.modelviewMatrixBuffer.flip().limit(16); + this.modelviewMatrixBuffer.get(this.modelviewMatrix); + this.clippingMatrix[0] = this.modelviewMatrix[0] * this.projectionMatrix[0] + this.modelviewMatrix[1] * this.projectionMatrix[4] + this.modelviewMatrix[2] * this.projectionMatrix[8] + this.modelviewMatrix[3] * this.projectionMatrix[12]; + this.clippingMatrix[1] = this.modelviewMatrix[0] * this.projectionMatrix[1] + this.modelviewMatrix[1] * this.projectionMatrix[5] + this.modelviewMatrix[2] * this.projectionMatrix[9] + this.modelviewMatrix[3] * this.projectionMatrix[13]; + this.clippingMatrix[2] = this.modelviewMatrix[0] * this.projectionMatrix[2] + this.modelviewMatrix[1] * this.projectionMatrix[6] + this.modelviewMatrix[2] * this.projectionMatrix[10] + this.modelviewMatrix[3] * this.projectionMatrix[14]; + this.clippingMatrix[3] = this.modelviewMatrix[0] * this.projectionMatrix[3] + this.modelviewMatrix[1] * this.projectionMatrix[7] + this.modelviewMatrix[2] * this.projectionMatrix[11] + this.modelviewMatrix[3] * this.projectionMatrix[15]; + this.clippingMatrix[4] = this.modelviewMatrix[4] * this.projectionMatrix[0] + this.modelviewMatrix[5] * this.projectionMatrix[4] + this.modelviewMatrix[6] * this.projectionMatrix[8] + this.modelviewMatrix[7] * this.projectionMatrix[12]; + this.clippingMatrix[5] = this.modelviewMatrix[4] * this.projectionMatrix[1] + this.modelviewMatrix[5] * this.projectionMatrix[5] + this.modelviewMatrix[6] * this.projectionMatrix[9] + this.modelviewMatrix[7] * this.projectionMatrix[13]; + this.clippingMatrix[6] = this.modelviewMatrix[4] * this.projectionMatrix[2] + this.modelviewMatrix[5] * this.projectionMatrix[6] + this.modelviewMatrix[6] * this.projectionMatrix[10] + this.modelviewMatrix[7] * this.projectionMatrix[14]; + this.clippingMatrix[7] = this.modelviewMatrix[4] * this.projectionMatrix[3] + this.modelviewMatrix[5] * this.projectionMatrix[7] + this.modelviewMatrix[6] * this.projectionMatrix[11] + this.modelviewMatrix[7] * this.projectionMatrix[15]; + this.clippingMatrix[8] = this.modelviewMatrix[8] * this.projectionMatrix[0] + this.modelviewMatrix[9] * this.projectionMatrix[4] + this.modelviewMatrix[10] * this.projectionMatrix[8] + this.modelviewMatrix[11] * this.projectionMatrix[12]; + this.clippingMatrix[9] = this.modelviewMatrix[8] * this.projectionMatrix[1] + this.modelviewMatrix[9] * this.projectionMatrix[5] + this.modelviewMatrix[10] * this.projectionMatrix[9] + this.modelviewMatrix[11] * this.projectionMatrix[13]; + this.clippingMatrix[10] = this.modelviewMatrix[8] * this.projectionMatrix[2] + this.modelviewMatrix[9] * this.projectionMatrix[6] + this.modelviewMatrix[10] * this.projectionMatrix[10] + this.modelviewMatrix[11] * this.projectionMatrix[14]; + this.clippingMatrix[11] = this.modelviewMatrix[8] * this.projectionMatrix[3] + this.modelviewMatrix[9] * this.projectionMatrix[7] + this.modelviewMatrix[10] * this.projectionMatrix[11] + this.modelviewMatrix[11] * this.projectionMatrix[15]; + this.clippingMatrix[12] = this.modelviewMatrix[12] * this.projectionMatrix[0] + this.modelviewMatrix[13] * this.projectionMatrix[4] + this.modelviewMatrix[14] * this.projectionMatrix[8] + this.modelviewMatrix[15] * this.projectionMatrix[12]; + this.clippingMatrix[13] = this.modelviewMatrix[12] * this.projectionMatrix[1] + this.modelviewMatrix[13] * this.projectionMatrix[5] + this.modelviewMatrix[14] * this.projectionMatrix[9] + this.modelviewMatrix[15] * this.projectionMatrix[13]; + this.clippingMatrix[14] = this.modelviewMatrix[12] * this.projectionMatrix[2] + this.modelviewMatrix[13] * this.projectionMatrix[6] + this.modelviewMatrix[14] * this.projectionMatrix[10] + this.modelviewMatrix[15] * this.projectionMatrix[14]; + this.clippingMatrix[15] = this.modelviewMatrix[12] * this.projectionMatrix[3] + this.modelviewMatrix[13] * this.projectionMatrix[7] + this.modelviewMatrix[14] * this.projectionMatrix[11] + this.modelviewMatrix[15] * this.projectionMatrix[15]; + this.frustum[0][0] = this.clippingMatrix[3] - this.clippingMatrix[0]; + this.frustum[0][1] = this.clippingMatrix[7] - this.clippingMatrix[4]; + this.frustum[0][2] = this.clippingMatrix[11] - this.clippingMatrix[8]; + this.frustum[0][3] = this.clippingMatrix[15] - this.clippingMatrix[12]; + this.normalize(this.frustum, 0); + this.frustum[1][0] = this.clippingMatrix[3] + this.clippingMatrix[0]; + this.frustum[1][1] = this.clippingMatrix[7] + this.clippingMatrix[4]; + this.frustum[1][2] = this.clippingMatrix[11] + this.clippingMatrix[8]; + this.frustum[1][3] = this.clippingMatrix[15] + this.clippingMatrix[12]; + this.normalize(this.frustum, 1); + this.frustum[2][0] = this.clippingMatrix[3] + this.clippingMatrix[1]; + this.frustum[2][1] = this.clippingMatrix[7] + this.clippingMatrix[5]; + this.frustum[2][2] = this.clippingMatrix[11] + this.clippingMatrix[9]; + this.frustum[2][3] = this.clippingMatrix[15] + this.clippingMatrix[13]; + this.normalize(this.frustum, 2); + this.frustum[3][0] = this.clippingMatrix[3] - this.clippingMatrix[1]; + this.frustum[3][1] = this.clippingMatrix[7] - this.clippingMatrix[5]; + this.frustum[3][2] = this.clippingMatrix[11] - this.clippingMatrix[9]; + this.frustum[3][3] = this.clippingMatrix[15] - this.clippingMatrix[13]; + this.normalize(this.frustum, 3); + this.frustum[4][0] = this.clippingMatrix[3] - this.clippingMatrix[2]; + this.frustum[4][1] = this.clippingMatrix[7] - this.clippingMatrix[6]; + this.frustum[4][2] = this.clippingMatrix[11] - this.clippingMatrix[10]; + this.frustum[4][3] = this.clippingMatrix[15] - this.clippingMatrix[14]; + this.normalize(this.frustum, 4); + this.frustum[5][0] = this.clippingMatrix[3] + this.clippingMatrix[2]; + this.frustum[5][1] = this.clippingMatrix[7] + this.clippingMatrix[6]; + this.frustum[5][2] = this.clippingMatrix[11] + this.clippingMatrix[10]; + this.frustum[5][3] = this.clippingMatrix[15] + this.clippingMatrix[14]; + this.normalize(this.frustum, 5); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/culling/Frustrum.java b/src/main/java/net/minecraft/client/renderer/culling/Frustrum.java new file mode 100644 index 0000000..a3975bd --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/culling/Frustrum.java @@ -0,0 +1,32 @@ +package net.minecraft.client.renderer.culling; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.util.AxisAlignedBB; + +@SideOnly(Side.CLIENT) +public class Frustrum implements ICamera +{ + private ClippingHelper clippingHelper = ClippingHelperImpl.getInstance(); + private double xPosition; + private double yPosition; + private double zPosition; + private static final String __OBFID = "CL_00000976"; + + public void setPosition(double par1, double par3, double par5) + { + this.xPosition = par1; + this.yPosition = par3; + this.zPosition = par5; + } + + public boolean isBoxInFrustum(double par1, double par3, double par5, double par7, double par9, double par11) + { + return this.clippingHelper.isBoxInFrustum(par1 - this.xPosition, par3 - this.yPosition, par5 - this.zPosition, par7 - this.xPosition, par9 - this.yPosition, par11 - this.zPosition); + } + + public boolean isBoundingBoxInFrustum(AxisAlignedBB par1AxisAlignedBB) + { + return this.isBoxInFrustum(par1AxisAlignedBB.minX, par1AxisAlignedBB.minY, par1AxisAlignedBB.minZ, par1AxisAlignedBB.maxX, par1AxisAlignedBB.maxY, par1AxisAlignedBB.maxZ); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/culling/ICamera.java b/src/main/java/net/minecraft/client/renderer/culling/ICamera.java new file mode 100644 index 0000000..e072423 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/culling/ICamera.java @@ -0,0 +1,13 @@ +package net.minecraft.client.renderer.culling; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.util.AxisAlignedBB; + +@SideOnly(Side.CLIENT) +public interface ICamera +{ + boolean isBoundingBoxInFrustum(AxisAlignedBB var1); + + void setPosition(double var1, double var3, double var5); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/Render.java b/src/main/java/net/minecraft/client/renderer/entity/Render.java new file mode 100644 index 0000000..a6a78ae --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/Render.java @@ -0,0 +1,353 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.init.Blocks; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public abstract class Render +{ + private static final ResourceLocation shadowTextures = new ResourceLocation("textures/misc/shadow.png"); + protected RenderManager renderManager; + protected RenderBlocks field_147909_c = new RenderBlocks(); + protected float shadowSize; + protected float shadowOpaque = 1.0F; + private boolean staticEntity = false; + private static final String __OBFID = "CL_00000992"; + + public abstract void doRender(Entity var1, double var2, double var4, double var6, float var8, float var9); + + protected abstract ResourceLocation getEntityTexture(Entity var1); + + public boolean isStaticEntity() + { + return this.staticEntity; + } + + protected void bindEntityTexture(Entity par1Entity) + { + this.bindTexture(this.getEntityTexture(par1Entity)); + } + + protected void bindTexture(ResourceLocation par1ResourceLocation) + { + this.renderManager.renderEngine.bindTexture(par1ResourceLocation); + } + + private void renderEntityOnFire(Entity par1Entity, double par2, double par4, double par6, float par8) + { + GL11.glDisable(GL11.GL_LIGHTING); + IIcon iicon = Blocks.fire.getFireIcon(0); + IIcon iicon1 = Blocks.fire.getFireIcon(1); + GL11.glPushMatrix(); + GL11.glTranslatef((float)par2, (float)par4, (float)par6); + float f1 = par1Entity.width * 1.4F; + GL11.glScalef(f1, f1, f1); + Tessellator tessellator = Tessellator.instance; + float f2 = 0.5F; + float f3 = 0.0F; + float f4 = par1Entity.height / f1; + float f5 = (float)(par1Entity.posY - par1Entity.boundingBox.minY); + GL11.glRotatef(-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(0.0F, 0.0F, -0.3F + (float)((int)f4) * 0.02F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + float f6 = 0.0F; + int i = 0; + tessellator.startDrawingQuads(); + + while (f4 > 0.0F) + { + IIcon iicon2 = i % 2 == 0 ? iicon : iicon1; + this.bindTexture(TextureMap.locationBlocksTexture); + float f7 = iicon2.getMinU(); + float f8 = iicon2.getMinV(); + float f9 = iicon2.getMaxU(); + float f10 = iicon2.getMaxV(); + + if (i / 2 % 2 == 0) + { + float f11 = f9; + f9 = f7; + f7 = f11; + } + + tessellator.addVertexWithUV((double)(f2 - f3), (double)(0.0F - f5), (double)f6, (double)f9, (double)f10); + tessellator.addVertexWithUV((double)(-f2 - f3), (double)(0.0F - f5), (double)f6, (double)f7, (double)f10); + tessellator.addVertexWithUV((double)(-f2 - f3), (double)(1.4F - f5), (double)f6, (double)f7, (double)f8); + tessellator.addVertexWithUV((double)(f2 - f3), (double)(1.4F - f5), (double)f6, (double)f9, (double)f8); + f4 -= 0.45F; + f5 -= 0.45F; + f2 *= 0.9F; + f6 += 0.03F; + ++i; + } + + tessellator.draw(); + GL11.glPopMatrix(); + GL11.glEnable(GL11.GL_LIGHTING); + } + + private void renderShadow(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) + { + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + this.renderManager.renderEngine.bindTexture(shadowTextures); + World world = this.getWorldFromRenderManager(); + GL11.glDepthMask(false); + float f2 = this.shadowSize; + + if (par1Entity instanceof EntityLiving) + { + EntityLiving entityliving = (EntityLiving)par1Entity; + f2 *= entityliving.getRenderSizeModifier(); + + if (entityliving.isChild()) + { + f2 *= 0.5F; + } + } + + double d8 = par1Entity.lastTickPosX + (par1Entity.posX - par1Entity.lastTickPosX) * (double)par9; + double d3 = par1Entity.lastTickPosY + (par1Entity.posY - par1Entity.lastTickPosY) * (double)par9 + (double)par1Entity.getShadowSize(); + double d4 = par1Entity.lastTickPosZ + (par1Entity.posZ - par1Entity.lastTickPosZ) * (double)par9; + int i = MathHelper.floor_double(d8 - (double)f2); + int j = MathHelper.floor_double(d8 + (double)f2); + int k = MathHelper.floor_double(d3 - (double)f2); + int l = MathHelper.floor_double(d3); + int i1 = MathHelper.floor_double(d4 - (double)f2); + int j1 = MathHelper.floor_double(d4 + (double)f2); + double d5 = par2 - d8; + double d6 = par4 - d3; + double d7 = par6 - d4; + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + + for (int k1 = i; k1 <= j; ++k1) + { + for (int l1 = k; l1 <= l; ++l1) + { + for (int i2 = i1; i2 <= j1; ++i2) + { + Block block = world.getBlock(k1, l1 - 1, i2); + + if (block.getMaterial() != Material.air && world.getBlockLightValue(k1, l1, i2) > 3) + { + this.func_147907_a(block, par2, par4 + (double)par1Entity.getShadowSize(), par6, k1, l1, i2, par8, f2, d5, d6 + (double)par1Entity.getShadowSize(), d7); + } + } + } + } + + tessellator.draw(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthMask(true); + } + + private World getWorldFromRenderManager() + { + return this.renderManager.worldObj; + } + + private void func_147907_a(Block p_147907_1_, double p_147907_2_, double p_147907_4_, double p_147907_6_, int p_147907_8_, int p_147907_9_, int p_147907_10_, float p_147907_11_, float p_147907_12_, double p_147907_13_, double p_147907_15_, double p_147907_17_) + { + Tessellator tessellator = Tessellator.instance; + + if (p_147907_1_.renderAsNormalBlock()) + { + double d6 = ((double)p_147907_11_ - (p_147907_4_ - ((double)p_147907_9_ + p_147907_15_)) / 2.0D) * 0.5D * (double)this.getWorldFromRenderManager().getLightBrightness(p_147907_8_, p_147907_9_, p_147907_10_); + + if (d6 >= 0.0D) + { + if (d6 > 1.0D) + { + d6 = 1.0D; + } + + tessellator.setColorRGBA_F(1.0F, 1.0F, 1.0F, (float)d6); + double d7 = (double)p_147907_8_ + p_147907_1_.getBlockBoundsMinX() + p_147907_13_; + double d8 = (double)p_147907_8_ + p_147907_1_.getBlockBoundsMaxX() + p_147907_13_; + double d9 = (double)p_147907_9_ + p_147907_1_.getBlockBoundsMinY() + p_147907_15_ + 0.015625D; + double d10 = (double)p_147907_10_ + p_147907_1_.getBlockBoundsMinZ() + p_147907_17_; + double d11 = (double)p_147907_10_ + p_147907_1_.getBlockBoundsMaxZ() + p_147907_17_; + float f2 = (float)((p_147907_2_ - d7) / 2.0D / (double)p_147907_12_ + 0.5D); + float f3 = (float)((p_147907_2_ - d8) / 2.0D / (double)p_147907_12_ + 0.5D); + float f4 = (float)((p_147907_6_ - d10) / 2.0D / (double)p_147907_12_ + 0.5D); + float f5 = (float)((p_147907_6_ - d11) / 2.0D / (double)p_147907_12_ + 0.5D); + tessellator.addVertexWithUV(d7, d9, d10, (double)f2, (double)f4); + tessellator.addVertexWithUV(d7, d9, d11, (double)f2, (double)f5); + tessellator.addVertexWithUV(d8, d9, d11, (double)f3, (double)f5); + tessellator.addVertexWithUV(d8, d9, d10, (double)f3, (double)f4); + } + } + } + + public static void renderOffsetAABB(AxisAlignedBB par0AxisAlignedBB, double par1, double par3, double par5) + { + GL11.glDisable(GL11.GL_TEXTURE_2D); + Tessellator tessellator = Tessellator.instance; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + tessellator.startDrawingQuads(); + tessellator.setTranslation(par1, par3, par5); + tessellator.setNormal(0.0F, 0.0F, -1.0F); + tessellator.addVertex(par0AxisAlignedBB.minX, par0AxisAlignedBB.maxY, par0AxisAlignedBB.minZ); + tessellator.addVertex(par0AxisAlignedBB.maxX, par0AxisAlignedBB.maxY, par0AxisAlignedBB.minZ); + tessellator.addVertex(par0AxisAlignedBB.maxX, par0AxisAlignedBB.minY, par0AxisAlignedBB.minZ); + tessellator.addVertex(par0AxisAlignedBB.minX, par0AxisAlignedBB.minY, par0AxisAlignedBB.minZ); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + tessellator.addVertex(par0AxisAlignedBB.minX, par0AxisAlignedBB.minY, par0AxisAlignedBB.maxZ); + tessellator.addVertex(par0AxisAlignedBB.maxX, par0AxisAlignedBB.minY, par0AxisAlignedBB.maxZ); + tessellator.addVertex(par0AxisAlignedBB.maxX, par0AxisAlignedBB.maxY, par0AxisAlignedBB.maxZ); + tessellator.addVertex(par0AxisAlignedBB.minX, par0AxisAlignedBB.maxY, par0AxisAlignedBB.maxZ); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + tessellator.addVertex(par0AxisAlignedBB.minX, par0AxisAlignedBB.minY, par0AxisAlignedBB.minZ); + tessellator.addVertex(par0AxisAlignedBB.maxX, par0AxisAlignedBB.minY, par0AxisAlignedBB.minZ); + tessellator.addVertex(par0AxisAlignedBB.maxX, par0AxisAlignedBB.minY, par0AxisAlignedBB.maxZ); + tessellator.addVertex(par0AxisAlignedBB.minX, par0AxisAlignedBB.minY, par0AxisAlignedBB.maxZ); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + tessellator.addVertex(par0AxisAlignedBB.minX, par0AxisAlignedBB.maxY, par0AxisAlignedBB.maxZ); + tessellator.addVertex(par0AxisAlignedBB.maxX, par0AxisAlignedBB.maxY, par0AxisAlignedBB.maxZ); + tessellator.addVertex(par0AxisAlignedBB.maxX, par0AxisAlignedBB.maxY, par0AxisAlignedBB.minZ); + tessellator.addVertex(par0AxisAlignedBB.minX, par0AxisAlignedBB.maxY, par0AxisAlignedBB.minZ); + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + tessellator.addVertex(par0AxisAlignedBB.minX, par0AxisAlignedBB.minY, par0AxisAlignedBB.maxZ); + tessellator.addVertex(par0AxisAlignedBB.minX, par0AxisAlignedBB.maxY, par0AxisAlignedBB.maxZ); + tessellator.addVertex(par0AxisAlignedBB.minX, par0AxisAlignedBB.maxY, par0AxisAlignedBB.minZ); + tessellator.addVertex(par0AxisAlignedBB.minX, par0AxisAlignedBB.minY, par0AxisAlignedBB.minZ); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + tessellator.addVertex(par0AxisAlignedBB.maxX, par0AxisAlignedBB.minY, par0AxisAlignedBB.minZ); + tessellator.addVertex(par0AxisAlignedBB.maxX, par0AxisAlignedBB.maxY, par0AxisAlignedBB.minZ); + tessellator.addVertex(par0AxisAlignedBB.maxX, par0AxisAlignedBB.maxY, par0AxisAlignedBB.maxZ); + tessellator.addVertex(par0AxisAlignedBB.maxX, par0AxisAlignedBB.minY, par0AxisAlignedBB.maxZ); + tessellator.setTranslation(0.0D, 0.0D, 0.0D); + tessellator.draw(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + + public static void renderAABB(AxisAlignedBB par0AxisAlignedBB) + { + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.addVertex(par0AxisAlignedBB.minX, par0AxisAlignedBB.maxY, par0AxisAlignedBB.minZ); + tessellator.addVertex(par0AxisAlignedBB.maxX, par0AxisAlignedBB.maxY, par0AxisAlignedBB.minZ); + tessellator.addVertex(par0AxisAlignedBB.maxX, par0AxisAlignedBB.minY, par0AxisAlignedBB.minZ); + tessellator.addVertex(par0AxisAlignedBB.minX, par0AxisAlignedBB.minY, par0AxisAlignedBB.minZ); + tessellator.addVertex(par0AxisAlignedBB.minX, par0AxisAlignedBB.minY, par0AxisAlignedBB.maxZ); + tessellator.addVertex(par0AxisAlignedBB.maxX, par0AxisAlignedBB.minY, par0AxisAlignedBB.maxZ); + tessellator.addVertex(par0AxisAlignedBB.maxX, par0AxisAlignedBB.maxY, par0AxisAlignedBB.maxZ); + tessellator.addVertex(par0AxisAlignedBB.minX, par0AxisAlignedBB.maxY, par0AxisAlignedBB.maxZ); + tessellator.addVertex(par0AxisAlignedBB.minX, par0AxisAlignedBB.minY, par0AxisAlignedBB.minZ); + tessellator.addVertex(par0AxisAlignedBB.maxX, par0AxisAlignedBB.minY, par0AxisAlignedBB.minZ); + tessellator.addVertex(par0AxisAlignedBB.maxX, par0AxisAlignedBB.minY, par0AxisAlignedBB.maxZ); + tessellator.addVertex(par0AxisAlignedBB.minX, par0AxisAlignedBB.minY, par0AxisAlignedBB.maxZ); + tessellator.addVertex(par0AxisAlignedBB.minX, par0AxisAlignedBB.maxY, par0AxisAlignedBB.maxZ); + tessellator.addVertex(par0AxisAlignedBB.maxX, par0AxisAlignedBB.maxY, par0AxisAlignedBB.maxZ); + tessellator.addVertex(par0AxisAlignedBB.maxX, par0AxisAlignedBB.maxY, par0AxisAlignedBB.minZ); + tessellator.addVertex(par0AxisAlignedBB.minX, par0AxisAlignedBB.maxY, par0AxisAlignedBB.minZ); + tessellator.addVertex(par0AxisAlignedBB.minX, par0AxisAlignedBB.minY, par0AxisAlignedBB.maxZ); + tessellator.addVertex(par0AxisAlignedBB.minX, par0AxisAlignedBB.maxY, par0AxisAlignedBB.maxZ); + tessellator.addVertex(par0AxisAlignedBB.minX, par0AxisAlignedBB.maxY, par0AxisAlignedBB.minZ); + tessellator.addVertex(par0AxisAlignedBB.minX, par0AxisAlignedBB.minY, par0AxisAlignedBB.minZ); + tessellator.addVertex(par0AxisAlignedBB.maxX, par0AxisAlignedBB.minY, par0AxisAlignedBB.minZ); + tessellator.addVertex(par0AxisAlignedBB.maxX, par0AxisAlignedBB.maxY, par0AxisAlignedBB.minZ); + tessellator.addVertex(par0AxisAlignedBB.maxX, par0AxisAlignedBB.maxY, par0AxisAlignedBB.maxZ); + tessellator.addVertex(par0AxisAlignedBB.maxX, par0AxisAlignedBB.minY, par0AxisAlignedBB.maxZ); + tessellator.draw(); + } + + public void setRenderManager(RenderManager par1RenderManager) + { + this.renderManager = par1RenderManager; + } + + public void doRenderShadowAndFire(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) + { + if (this.renderManager.options.fancyGraphics && this.shadowSize > 0.0F && !par1Entity.isInvisible()) + { + double d3 = this.renderManager.getDistanceToCamera(par1Entity.posX, par1Entity.posY, par1Entity.posZ); + float f2 = (float)((1.0D - d3 / 256.0D) * (double)this.shadowOpaque); + + if (f2 > 0.0F) + { + this.renderShadow(par1Entity, par2, par4, par6, f2, par9); + } + } + + if (par1Entity.canRenderOnFire()) + { + this.renderEntityOnFire(par1Entity, par2, par4, par6, par9); + } + } + + public FontRenderer getFontRendererFromRenderManager() + { + return this.renderManager.getFontRenderer(); + } + + public void updateIcons(IIconRegister par1IconRegister) {} + + protected void func_147906_a(Entity p_147906_1_, String p_147906_2_, double p_147906_3_, double p_147906_5_, double p_147906_7_, int p_147906_9_) + { + double d3 = p_147906_1_.getDistanceSqToEntity(this.renderManager.livingPlayer); + + if (d3 <= (double)(p_147906_9_ * p_147906_9_)) + { + FontRenderer fontrenderer = this.getFontRendererFromRenderManager(); + float f = 1.6F; + float f1 = 0.016666668F * f; + GL11.glPushMatrix(); + GL11.glTranslatef((float)p_147906_3_ + 0.0F, (float)p_147906_5_ + p_147906_1_.height + 0.5F, (float)p_147906_7_); + GL11.glNormal3f(0.0F, 1.0F, 0.0F); + GL11.glRotatef(-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F); + GL11.glScalef(-f1, -f1, f1); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDepthMask(false); + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + Tessellator tessellator = Tessellator.instance; + byte b0 = 0; + + if (p_147906_2_.equals("deadmau5")) + { + b0 = -10; + } + + GL11.glDisable(GL11.GL_TEXTURE_2D); + tessellator.startDrawingQuads(); + int j = fontrenderer.getStringWidth(p_147906_2_) / 2; + tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F); + tessellator.addVertex((double)(-j - 1), (double)(-1 + b0), 0.0D); + tessellator.addVertex((double)(-j - 1), (double)(8 + b0), 0.0D); + tessellator.addVertex((double)(j + 1), (double)(8 + b0), 0.0D); + tessellator.addVertex((double)(j + 1), (double)(-1 + b0), 0.0D); + tessellator.draw(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + fontrenderer.drawString(p_147906_2_, -fontrenderer.getStringWidth(p_147906_2_) / 2, b0, 553648127); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glDepthMask(true); + fontrenderer.drawString(p_147906_2_, -fontrenderer.getStringWidth(p_147906_2_) / 2, b0, -1); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_BLEND); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glPopMatrix(); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderArrow.java b/src/main/java/net/minecraft/client/renderer/entity/RenderArrow.java new file mode 100644 index 0000000..791ed13 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderArrow.java @@ -0,0 +1,94 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.entity.Entity; +import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +@SideOnly(Side.CLIENT) +public class RenderArrow extends Render +{ + private static final ResourceLocation arrowTextures = new ResourceLocation("textures/entity/arrow.png"); + private static final String __OBFID = "CL_00000978"; + + public void doRender(EntityArrow par1EntityArrow, double par2, double par4, double par6, float par8, float par9) + { + this.bindEntityTexture(par1EntityArrow); + GL11.glPushMatrix(); + GL11.glTranslatef((float)par2, (float)par4, (float)par6); + GL11.glRotatef(par1EntityArrow.prevRotationYaw + (par1EntityArrow.rotationYaw - par1EntityArrow.prevRotationYaw) * par9 - 90.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(par1EntityArrow.prevRotationPitch + (par1EntityArrow.rotationPitch - par1EntityArrow.prevRotationPitch) * par9, 0.0F, 0.0F, 1.0F); + Tessellator tessellator = Tessellator.instance; + byte b0 = 0; + float f2 = 0.0F; + float f3 = 0.5F; + float f4 = (float)(0 + b0 * 10) / 32.0F; + float f5 = (float)(5 + b0 * 10) / 32.0F; + float f6 = 0.0F; + float f7 = 0.15625F; + float f8 = (float)(5 + b0 * 10) / 32.0F; + float f9 = (float)(10 + b0 * 10) / 32.0F; + float f10 = 0.05625F; + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + float f11 = (float)par1EntityArrow.arrowShake - par9; + + if (f11 > 0.0F) + { + float f12 = -MathHelper.sin(f11 * 3.0F) * f11; + GL11.glRotatef(f12, 0.0F, 0.0F, 1.0F); + } + + GL11.glRotatef(45.0F, 1.0F, 0.0F, 0.0F); + GL11.glScalef(f10, f10, f10); + GL11.glTranslatef(-4.0F, 0.0F, 0.0F); + GL11.glNormal3f(f10, 0.0F, 0.0F); + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double)f6, (double)f8); + tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double)f7, (double)f8); + tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double)f7, (double)f9); + tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double)f6, (double)f9); + tessellator.draw(); + GL11.glNormal3f(-f10, 0.0F, 0.0F); + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double)f6, (double)f8); + tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double)f7, (double)f8); + tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double)f7, (double)f9); + tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double)f6, (double)f9); + tessellator.draw(); + + for (int i = 0; i < 4; ++i) + { + GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); + GL11.glNormal3f(0.0F, 0.0F, f10); + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV(-8.0D, -2.0D, 0.0D, (double)f2, (double)f4); + tessellator.addVertexWithUV(8.0D, -2.0D, 0.0D, (double)f3, (double)f4); + tessellator.addVertexWithUV(8.0D, 2.0D, 0.0D, (double)f3, (double)f5); + tessellator.addVertexWithUV(-8.0D, 2.0D, 0.0D, (double)f2, (double)f5); + tessellator.draw(); + } + + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } + + protected ResourceLocation getEntityTexture(EntityArrow par1EntityArrow) + { + return arrowTextures; + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntityArrow)par1Entity); + } + + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityArrow)par1Entity, par2, par4, par6, par8, par9); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderBat.java b/src/main/java/net/minecraft/client/renderer/entity/RenderBat.java new file mode 100644 index 0000000..c22fd9c --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderBat.java @@ -0,0 +1,103 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelBat; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.passive.EntityBat; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class RenderBat extends RenderLiving +{ + private static final ResourceLocation batTextures = new ResourceLocation("textures/entity/bat.png"); + private int renderedBatSize; + private static final String __OBFID = "CL_00000979"; + + public RenderBat() + { + super(new ModelBat(), 0.25F); + this.renderedBatSize = ((ModelBat)this.mainModel).getBatSize(); + } + + public void doRender(EntityBat par1EntityBat, double par2, double par4, double par6, float par8, float par9) + { + int i = ((ModelBat)this.mainModel).getBatSize(); + + if (i != this.renderedBatSize) + { + this.renderedBatSize = i; + this.mainModel = new ModelBat(); + } + + super.doRender((EntityLiving)par1EntityBat, par2, par4, par6, par8, par9); + } + + protected ResourceLocation getEntityTexture(EntityBat par1EntityBat) + { + return batTextures; + } + + protected void preRenderCallback(EntityBat par1EntityBat, float par2) + { + GL11.glScalef(0.35F, 0.35F, 0.35F); + } + + protected void renderLivingAt(EntityBat par1EntityBat, double par2, double par4, double par6) + { + super.renderLivingAt(par1EntityBat, par2, par4, par6); + } + + protected void rotateCorpse(EntityBat par1EntityBat, float par2, float par3, float par4) + { + if (!par1EntityBat.getIsBatHanging()) + { + GL11.glTranslatef(0.0F, MathHelper.cos(par2 * 0.3F) * 0.1F, 0.0F); + } + else + { + GL11.glTranslatef(0.0F, -0.1F, 0.0F); + } + + super.rotateCorpse(par1EntityBat, par2, par3, par4); + } + + public void doRender(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityBat)par1EntityLiving, par2, par4, par6, par8, par9); + } + + protected void preRenderCallback(EntityLivingBase par1EntityLivingBase, float par2) + { + this.preRenderCallback((EntityBat)par1EntityLivingBase, par2); + } + + protected void rotateCorpse(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4) + { + this.rotateCorpse((EntityBat)par1EntityLivingBase, par2, par3, par4); + } + + protected void renderLivingAt(EntityLivingBase par1EntityLivingBase, double par2, double par4, double par6) + { + this.renderLivingAt((EntityBat)par1EntityLivingBase, par2, par4, par6); + } + + public void doRender(EntityLivingBase par1EntityLivingBase, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityBat)par1EntityLivingBase, par2, par4, par6, par8, par9); + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntityBat)par1Entity); + } + + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityBat)par1Entity, par2, par4, par6, par8, par9); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderBiped.java b/src/main/java/net/minecraft/client/renderer/entity/RenderBiped.java new file mode 100644 index 0000000..e916143 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderBiped.java @@ -0,0 +1,384 @@ +package net.minecraft.client.renderer.entity; + +import com.google.common.collect.Maps; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Map; +import net.minecraft.block.Block; +import net.minecraft.client.model.ModelBiped; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.tileentity.TileEntitySkullRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemArmor; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import static net.minecraftforge.client.IItemRenderer.ItemRenderType.EQUIPPED; +import static net.minecraftforge.client.IItemRenderer.ItemRendererHelper.BLOCK_3D; +import net.minecraftforge.client.ForgeHooksClient; +import net.minecraftforge.client.IItemRenderer; +import net.minecraftforge.client.MinecraftForgeClient; + +@SideOnly(Side.CLIENT) +public class RenderBiped extends RenderLiving +{ + public ModelBiped modelBipedMain; + protected float field_77070_b; + protected ModelBiped field_82423_g; + protected ModelBiped field_82425_h; + private static final Map field_110859_k = Maps.newHashMap(); + public static String[] bipedArmorFilenamePrefix = new String[] {"leather", "chainmail", "iron", "diamond", "gold"}; + private static final String __OBFID = "CL_00001001"; + + public RenderBiped(ModelBiped par1ModelBiped, float par2) + { + this(par1ModelBiped, par2, 1.0F); + } + + public RenderBiped(ModelBiped par1ModelBiped, float par2, float par3) + { + super(par1ModelBiped, par2); + this.modelBipedMain = par1ModelBiped; + this.field_77070_b = par3; + this.func_82421_b(); + } + + protected void func_82421_b() + { + this.field_82423_g = new ModelBiped(1.0F); + this.field_82425_h = new ModelBiped(0.5F); + } + + @Deprecated //Use the more sensitive version getArmorResource below + public static ResourceLocation func_110857_a(ItemArmor par0ItemArmor, int par1) + { + return func_110858_a(par0ItemArmor, par1, (String)null); + } + + @Deprecated //Use the more sensitive version getArmorResource below + public static ResourceLocation func_110858_a(ItemArmor par0ItemArmor, int par1, String par2Str) + { + String s1 = String.format("textures/models/armor/%s_layer_%d%s.png", new Object[] {bipedArmorFilenamePrefix[par0ItemArmor.renderIndex], Integer.valueOf(par1 == 2 ? 2 : 1), par2Str == null ? "" : String.format("_%s", new Object[]{par2Str})}); + ResourceLocation resourcelocation = (ResourceLocation)field_110859_k.get(s1); + + if (resourcelocation == null) + { + resourcelocation = new ResourceLocation(s1); + field_110859_k.put(s1, resourcelocation); + } + + return resourcelocation; + } + + protected int shouldRenderPass(EntityLiving par1EntityLiving, int par2, float par3) + { + ItemStack itemstack = par1EntityLiving.func_130225_q(3 - par2); + + if (itemstack != null) + { + Item item = itemstack.getItem(); + + if (item instanceof ItemArmor) + { + ItemArmor itemarmor = (ItemArmor)item; + this.bindTexture(getArmorResource(par1EntityLiving, itemstack, par2, null)); + ModelBiped modelbiped = par2 == 2 ? this.field_82425_h : this.field_82423_g; + modelbiped.bipedHead.showModel = par2 == 0; + modelbiped.bipedHeadwear.showModel = par2 == 0; + modelbiped.bipedBody.showModel = par2 == 1 || par2 == 2; + modelbiped.bipedRightArm.showModel = par2 == 1; + modelbiped.bipedLeftArm.showModel = par2 == 1; + modelbiped.bipedRightLeg.showModel = par2 == 2 || par2 == 3; + modelbiped.bipedLeftLeg.showModel = par2 == 2 || par2 == 3; + modelbiped = ForgeHooksClient.getArmorModel(par1EntityLiving, itemstack, par2, modelbiped); + this.setRenderPassModel(modelbiped); + modelbiped.onGround = this.mainModel.onGround; + modelbiped.isRiding = this.mainModel.isRiding; + modelbiped.isChild = this.mainModel.isChild; + + //Move out of if to allow for more then just CLOTH to have color + int j = itemarmor.getColor(itemstack); + if (j != -1) + { + float f1 = (float)(j >> 16 & 255) / 255.0F; + float f2 = (float)(j >> 8 & 255) / 255.0F; + float f3 = (float)(j & 255) / 255.0F; + GL11.glColor3f(f1, f2, f3); + + if (itemstack.isItemEnchanted()) + { + return 31; + } + + return 16; + } + + GL11.glColor3f(1.0F, 1.0F, 1.0F); + + if (itemstack.isItemEnchanted()) + { + return 15; + } + + return 1; + } + } + + return -1; + } + + protected void func_82408_c(EntityLiving par1EntityLivingBase, int par2, float par3) + { + ItemStack itemstack = par1EntityLivingBase.func_130225_q(3 - par2); + + if (itemstack != null) + { + Item item = itemstack.getItem(); + + if (item instanceof ItemArmor) + { + this.bindTexture(getArmorResource(par1EntityLivingBase, itemstack, par2, "overlay")); + float f1 = 1.0F; + GL11.glColor3f(1.0F, 1.0F, 1.0F); + } + } + } + + public void doRender(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9) + { + GL11.glColor3f(1.0F, 1.0F, 1.0F); + ItemStack itemstack = par1EntityLiving.getHeldItem(); + this.func_82420_a(par1EntityLiving, itemstack); + double d3 = par4 - (double)par1EntityLiving.yOffset; + + if (par1EntityLiving.isSneaking()) + { + d3 -= 0.125D; + } + + super.doRender(par1EntityLiving, par2, d3, par6, par8, par9); + this.field_82423_g.aimedBow = this.field_82425_h.aimedBow = this.modelBipedMain.aimedBow = false; + this.field_82423_g.isSneak = this.field_82425_h.isSneak = this.modelBipedMain.isSneak = false; + this.field_82423_g.heldItemRight = this.field_82425_h.heldItemRight = this.modelBipedMain.heldItemRight = 0; + } + + protected ResourceLocation getEntityTexture(EntityLiving par1EntityLiving) + { + return null; + } + + protected void func_82420_a(EntityLiving par1EntityLiving, ItemStack par2ItemStack) + { + this.field_82423_g.heldItemRight = this.field_82425_h.heldItemRight = this.modelBipedMain.heldItemRight = par2ItemStack != null ? 1 : 0; + this.field_82423_g.isSneak = this.field_82425_h.isSneak = this.modelBipedMain.isSneak = par1EntityLiving.isSneaking(); + } + + protected void renderEquippedItems(EntityLiving par1EntityLiving, float par2) + { + GL11.glColor3f(1.0F, 1.0F, 1.0F); + super.renderEquippedItems(par1EntityLiving, par2); + ItemStack itemstack = par1EntityLiving.getHeldItem(); + ItemStack itemstack1 = par1EntityLiving.func_130225_q(3); + Item item; + float f1; + + if (itemstack1 != null) + { + GL11.glPushMatrix(); + this.modelBipedMain.bipedHead.postRender(0.0625F); + item = itemstack1.getItem(); + + IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemstack1, EQUIPPED); + boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, itemstack1, BLOCK_3D)); + + if (item instanceof ItemBlock) + { + if (is3D || RenderBlocks.renderItemIn3d(Block.getBlockFromItem(item).getRenderType())) + { + f1 = 0.625F; + GL11.glTranslatef(0.0F, -0.25F, 0.0F); + GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + GL11.glScalef(f1, -f1, -f1); + } + + this.renderManager.itemRenderer.renderItem(par1EntityLiving, itemstack1, 0); + } + else if (item == Items.skull) + { + f1 = 1.0625F; + GL11.glScalef(f1, -f1, -f1); + String s = ""; + + if (itemstack1.hasTagCompound() && itemstack1.getTagCompound().hasKey("SkullOwner", 8)) + { + s = itemstack1.getTagCompound().getString("SkullOwner"); + } + + TileEntitySkullRenderer.field_147536_b.func_147530_a(-0.5F, 0.0F, -0.5F, 1, 180.0F, itemstack1.getItemDamage(), s); + } + + GL11.glPopMatrix(); + } + + if (itemstack != null && itemstack.getItem() != null) + { + item = itemstack.getItem(); + GL11.glPushMatrix(); + + if (this.mainModel.isChild) + { + f1 = 0.5F; + GL11.glTranslatef(0.0F, 0.625F, 0.0F); + GL11.glRotatef(-20.0F, -1.0F, 0.0F, 0.0F); + GL11.glScalef(f1, f1, f1); + } + + this.modelBipedMain.bipedRightArm.postRender(0.0625F); + GL11.glTranslatef(-0.0625F, 0.4375F, 0.0625F); + + IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemstack, EQUIPPED); + boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, itemstack, BLOCK_3D)); + + if (item instanceof ItemBlock && (is3D || RenderBlocks.renderItemIn3d(Block.getBlockFromItem(item).getRenderType()))) + { + f1 = 0.5F; + GL11.glTranslatef(0.0F, 0.1875F, -0.3125F); + f1 *= 0.75F; + GL11.glRotatef(20.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); + GL11.glScalef(-f1, -f1, f1); + } + else if (item == Items.bow) + { + f1 = 0.625F; + GL11.glTranslatef(0.0F, 0.125F, 0.3125F); + GL11.glRotatef(-20.0F, 0.0F, 1.0F, 0.0F); + GL11.glScalef(f1, -f1, f1); + GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); + } + else if (item.isFull3D()) + { + f1 = 0.625F; + + if (item.shouldRotateAroundWhenRendering()) + { + GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); + GL11.glTranslatef(0.0F, -0.125F, 0.0F); + } + + this.func_82422_c(); + GL11.glScalef(f1, -f1, f1); + GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); + } + else + { + f1 = 0.375F; + GL11.glTranslatef(0.25F, 0.1875F, -0.1875F); + GL11.glScalef(f1, f1, f1); + GL11.glRotatef(60.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(20.0F, 0.0F, 0.0F, 1.0F); + } + + float f2; + float f3; + int i; + + if (itemstack.getItem().requiresMultipleRenderPasses()) + { + for (i = 0; i < itemstack.getItem().getRenderPasses(itemstack.getItemDamage()); ++i) + { + int j = itemstack.getItem().getColorFromItemStack(itemstack, i); + f2 = (float)(j >> 16 & 255) / 255.0F; + f3 = (float)(j >> 8 & 255) / 255.0F; + float f4 = (float)(j & 255) / 255.0F; + GL11.glColor4f(f2, f3, f4, 1.0F); + this.renderManager.itemRenderer.renderItem(par1EntityLiving, itemstack, i); + } + } + else + { + i = itemstack.getItem().getColorFromItemStack(itemstack, 0); + float f5 = (float)(i >> 16 & 255) / 255.0F; + f2 = (float)(i >> 8 & 255) / 255.0F; + f3 = (float)(i & 255) / 255.0F; + GL11.glColor4f(f5, f2, f3, 1.0F); + this.renderManager.itemRenderer.renderItem(par1EntityLiving, itemstack, 0); + } + + GL11.glPopMatrix(); + } + } + + protected void func_82422_c() + { + GL11.glTranslatef(0.0F, 0.1875F, 0.0F); + } + + protected void func_82408_c(EntityLivingBase par1EntityLivingBase, int par2, float par3) + { + this.func_82408_c((EntityLiving)par1EntityLivingBase, par2, par3); + } + + protected int shouldRenderPass(EntityLivingBase par1EntityLivingBase, int par2, float par3) + { + return this.shouldRenderPass((EntityLiving)par1EntityLivingBase, par2, par3); + } + + protected void renderEquippedItems(EntityLivingBase par1EntityLivingBase, float par2) + { + this.renderEquippedItems((EntityLiving)par1EntityLivingBase, par2); + } + + public void doRender(EntityLivingBase par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityLiving)par1Entity, par2, par4, par6, par8, par9); + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntityLiving)par1Entity); + } + + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityLiving)par1Entity, par2, par4, par6, par8, par9); + } + + /*=================================== FORGE START =========================================*/ + /** + * More generic ForgeHook version of the above function, it allows for Items to have more control over what texture they provide. + * + * @param entity Entity wearing the armor + * @param stack ItemStack for the armor + * @param slot Slot ID that the item is in + * @param type Subtype, can be null or "overlay" + * @return ResourceLocation pointing at the armor's texture + */ + public static ResourceLocation getArmorResource(Entity entity, ItemStack stack, int slot, String type) + { + ItemArmor item = (ItemArmor)stack.getItem(); + String s1 = String.format("textures/models/armor/%s_layer_%d%s.png", + bipedArmorFilenamePrefix[item.renderIndex], (slot == 2 ? 2 : 1), type == null ? "" : String.format("_%s", type)); + + s1 = ForgeHooksClient.getArmorTexture(entity, stack, s1, slot, type); + ResourceLocation resourcelocation = (ResourceLocation)field_110859_k.get(s1); + + if (resourcelocation == null) + { + resourcelocation = new ResourceLocation(s1); + field_110859_k.put(s1, resourcelocation); + } + + return resourcelocation; + } + /*=================================== FORGE END ===========================================*/ +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderBlaze.java b/src/main/java/net/minecraft/client/renderer/entity/RenderBlaze.java new file mode 100644 index 0000000..d5af948 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderBlaze.java @@ -0,0 +1,62 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelBlaze; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.monster.EntityBlaze; +import net.minecraft.util.ResourceLocation; + +@SideOnly(Side.CLIENT) +public class RenderBlaze extends RenderLiving +{ + private static final ResourceLocation blazeTextures = new ResourceLocation("textures/entity/blaze.png"); + private int field_77068_a; + private static final String __OBFID = "CL_00000980"; + + public RenderBlaze() + { + super(new ModelBlaze(), 0.5F); + this.field_77068_a = ((ModelBlaze)this.mainModel).func_78104_a(); + } + + public void doRender(EntityBlaze par1EntityBlaze, double par2, double par4, double par6, float par8, float par9) + { + int i = ((ModelBlaze)this.mainModel).func_78104_a(); + + if (i != this.field_77068_a) + { + this.field_77068_a = i; + this.mainModel = new ModelBlaze(); + } + + super.doRender((EntityLiving)par1EntityBlaze, par2, par4, par6, par8, par9); + } + + protected ResourceLocation getEntityTexture(EntityBlaze par1EntityBlaze) + { + return blazeTextures; + } + + public void doRender(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityBlaze)par1EntityLiving, par2, par4, par6, par8, par9); + } + + public void doRender(EntityLivingBase par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityBlaze)par1Entity, par2, par4, par6, par8, par9); + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntityBlaze)par1Entity); + } + + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityBlaze)par1Entity, par2, par4, par6, par8, par9); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderBoat.java b/src/main/java/net/minecraft/client/renderer/entity/RenderBoat.java new file mode 100644 index 0000000..7275aee --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderBoat.java @@ -0,0 +1,67 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelBoat; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityBoat; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class RenderBoat extends Render +{ + private static final ResourceLocation boatTextures = new ResourceLocation("textures/entity/boat.png"); + protected ModelBase modelBoat; + private static final String __OBFID = "CL_00000981"; + + public RenderBoat() + { + this.shadowSize = 0.5F; + this.modelBoat = new ModelBoat(); + } + + public void doRender(EntityBoat par1EntityBoat, double par2, double par4, double par6, float par8, float par9) + { + GL11.glPushMatrix(); + GL11.glTranslatef((float)par2, (float)par4, (float)par6); + GL11.glRotatef(180.0F - par8, 0.0F, 1.0F, 0.0F); + float f2 = (float)par1EntityBoat.getTimeSinceHit() - par9; + float f3 = par1EntityBoat.getDamageTaken() - par9; + + if (f3 < 0.0F) + { + f3 = 0.0F; + } + + if (f2 > 0.0F) + { + GL11.glRotatef(MathHelper.sin(f2) * f2 * f3 / 10.0F * (float)par1EntityBoat.getForwardDirection(), 1.0F, 0.0F, 0.0F); + } + + float f4 = 0.75F; + GL11.glScalef(f4, f4, f4); + GL11.glScalef(1.0F / f4, 1.0F / f4, 1.0F / f4); + this.bindEntityTexture(par1EntityBoat); + GL11.glScalef(-1.0F, -1.0F, 1.0F); + this.modelBoat.render(par1EntityBoat, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); + GL11.glPopMatrix(); + } + + protected ResourceLocation getEntityTexture(EntityBoat par1EntityBoat) + { + return boatTextures; + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntityBoat)par1Entity); + } + + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityBoat)par1Entity, par2, par4, par6, par8, par9); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderCaveSpider.java b/src/main/java/net/minecraft/client/renderer/entity/RenderCaveSpider.java new file mode 100644 index 0000000..2b6cda2 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderCaveSpider.java @@ -0,0 +1,47 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.monster.EntityCaveSpider; +import net.minecraft.entity.monster.EntitySpider; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class RenderCaveSpider extends RenderSpider +{ + private static final ResourceLocation caveSpiderTextures = new ResourceLocation("textures/entity/spider/cave_spider.png"); + private static final String __OBFID = "CL_00000982"; + + public RenderCaveSpider() + { + this.shadowSize *= 0.7F; + } + + protected void preRenderCallback(EntityCaveSpider par1EntityCaveSpider, float par2) + { + GL11.glScalef(0.7F, 0.7F, 0.7F); + } + + protected ResourceLocation getEntityTexture(EntityCaveSpider par1EntityCaveSpider) + { + return caveSpiderTextures; + } + + protected ResourceLocation getEntityTexture(EntitySpider par1EntitySpider) + { + return this.getEntityTexture((EntityCaveSpider)par1EntitySpider); + } + + protected void preRenderCallback(EntityLivingBase par1EntityLivingBase, float par2) + { + this.preRenderCallback((EntityCaveSpider)par1EntityLivingBase, par2); + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntityCaveSpider)par1Entity); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderChicken.java b/src/main/java/net/minecraft/client/renderer/entity/RenderChicken.java new file mode 100644 index 0000000..6c87abc --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderChicken.java @@ -0,0 +1,65 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelBase; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.passive.EntityChicken; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; + +@SideOnly(Side.CLIENT) +public class RenderChicken extends RenderLiving +{ + private static final ResourceLocation chickenTextures = new ResourceLocation("textures/entity/chicken.png"); + private static final String __OBFID = "CL_00000983"; + + public RenderChicken(ModelBase par1ModelBase, float par2) + { + super(par1ModelBase, par2); + } + + public void doRender(EntityChicken par1EntityChicken, double par2, double par4, double par6, float par8, float par9) + { + super.doRender((EntityLiving)par1EntityChicken, par2, par4, par6, par8, par9); + } + + protected ResourceLocation getEntityTexture(EntityChicken par1EntityChicken) + { + return chickenTextures; + } + + protected float handleRotationFloat(EntityChicken par1EntityChicken, float par2) + { + float f1 = par1EntityChicken.field_70888_h + (par1EntityChicken.field_70886_e - par1EntityChicken.field_70888_h) * par2; + float f2 = par1EntityChicken.field_70884_g + (par1EntityChicken.destPos - par1EntityChicken.field_70884_g) * par2; + return (MathHelper.sin(f1) + 1.0F) * f2; + } + + public void doRender(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityChicken)par1EntityLiving, par2, par4, par6, par8, par9); + } + + protected float handleRotationFloat(EntityLivingBase par1EntityLivingBase, float par2) + { + return this.handleRotationFloat((EntityChicken)par1EntityLivingBase, par2); + } + + public void doRender(EntityLivingBase par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityChicken)par1Entity, par2, par4, par6, par8, par9); + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntityChicken)par1Entity); + } + + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityChicken)par1Entity, par2, par4, par6, par8, par9); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderCow.java b/src/main/java/net/minecraft/client/renderer/entity/RenderCow.java new file mode 100644 index 0000000..33b3e56 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderCow.java @@ -0,0 +1,30 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelBase; +import net.minecraft.entity.Entity; +import net.minecraft.entity.passive.EntityCow; +import net.minecraft.util.ResourceLocation; + +@SideOnly(Side.CLIENT) +public class RenderCow extends RenderLiving +{ + private static final ResourceLocation cowTextures = new ResourceLocation("textures/entity/cow/cow.png"); + private static final String __OBFID = "CL_00000984"; + + public RenderCow(ModelBase par1ModelBase, float par2) + { + super(par1ModelBase, par2); + } + + protected ResourceLocation getEntityTexture(EntityCow par1EntityCow) + { + return cowTextures; + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntityCow)par1Entity); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderCreeper.java b/src/main/java/net/minecraft/client/renderer/entity/RenderCreeper.java new file mode 100644 index 0000000..0b6f918 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderCreeper.java @@ -0,0 +1,157 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelCreeper; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.monster.EntityCreeper; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class RenderCreeper extends RenderLiving +{ + private static final ResourceLocation armoredCreeperTextures = new ResourceLocation("textures/entity/creeper/creeper_armor.png"); + private static final ResourceLocation creeperTextures = new ResourceLocation("textures/entity/creeper/creeper.png"); + private ModelBase creeperModel = new ModelCreeper(2.0F); + private static final String __OBFID = "CL_00000985"; + + public RenderCreeper() + { + super(new ModelCreeper(), 0.5F); + } + + protected void preRenderCallback(EntityCreeper par1EntityCreeper, float par2) + { + float f1 = par1EntityCreeper.getCreeperFlashIntensity(par2); + float f2 = 1.0F + MathHelper.sin(f1 * 100.0F) * f1 * 0.01F; + + if (f1 < 0.0F) + { + f1 = 0.0F; + } + + if (f1 > 1.0F) + { + f1 = 1.0F; + } + + f1 *= f1; + f1 *= f1; + float f3 = (1.0F + f1 * 0.4F) * f2; + float f4 = (1.0F + f1 * 0.1F) / f2; + GL11.glScalef(f3, f4, f3); + } + + protected int getColorMultiplier(EntityCreeper par1EntityCreeper, float par2, float par3) + { + float f2 = par1EntityCreeper.getCreeperFlashIntensity(par3); + + if ((int)(f2 * 10.0F) % 2 == 0) + { + return 0; + } + else + { + int i = (int)(f2 * 0.2F * 255.0F); + + if (i < 0) + { + i = 0; + } + + if (i > 255) + { + i = 255; + } + + short short1 = 255; + short short2 = 255; + short short3 = 255; + return i << 24 | short1 << 16 | short2 << 8 | short3; + } + } + + protected int shouldRenderPass(EntityCreeper par1EntityCreeper, int par2, float par3) + { + if (par1EntityCreeper.getPowered()) + { + if (par1EntityCreeper.isInvisible()) + { + GL11.glDepthMask(false); + } + else + { + GL11.glDepthMask(true); + } + + if (par2 == 1) + { + float f1 = (float)par1EntityCreeper.ticksExisted + par3; + this.bindTexture(armoredCreeperTextures); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glLoadIdentity(); + float f2 = f1 * 0.01F; + float f3 = f1 * 0.01F; + GL11.glTranslatef(f2, f3, 0.0F); + this.setRenderPassModel(this.creeperModel); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glEnable(GL11.GL_BLEND); + float f4 = 0.5F; + GL11.glColor4f(f4, f4, f4, 1.0F); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); + return 1; + } + + if (par2 == 2) + { + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glLoadIdentity(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_BLEND); + } + } + + return -1; + } + + protected int inheritRenderPass(EntityCreeper par1EntityCreeper, int par2, float par3) + { + return -1; + } + + protected ResourceLocation getEntityTexture(EntityCreeper par1EntityCreeper) + { + return creeperTextures; + } + + protected void preRenderCallback(EntityLivingBase par1EntityLivingBase, float par2) + { + this.preRenderCallback((EntityCreeper)par1EntityLivingBase, par2); + } + + protected int getColorMultiplier(EntityLivingBase par1EntityLivingBase, float par2, float par3) + { + return this.getColorMultiplier((EntityCreeper)par1EntityLivingBase, par2, par3); + } + + protected int shouldRenderPass(EntityLivingBase par1EntityLivingBase, int par2, float par3) + { + return this.shouldRenderPass((EntityCreeper)par1EntityLivingBase, par2, par3); + } + + protected int inheritRenderPass(EntityLivingBase par1EntityLivingBase, int par2, float par3) + { + return this.inheritRenderPass((EntityCreeper)par1EntityLivingBase, par2, par3); + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntityCreeper)par1Entity); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderDragon.java b/src/main/java/net/minecraft/client/renderer/entity/RenderDragon.java new file mode 100644 index 0000000..5871094 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderDragon.java @@ -0,0 +1,270 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.client.model.ModelDragon; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.boss.BossStatus; +import net.minecraft.entity.boss.EntityDragon; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class RenderDragon extends RenderLiving +{ + private static final ResourceLocation enderDragonExplodingTextures = new ResourceLocation("textures/entity/enderdragon/dragon_exploding.png"); + private static final ResourceLocation enderDragonCrystalBeamTextures = new ResourceLocation("textures/entity/endercrystal/endercrystal_beam.png"); + private static final ResourceLocation enderDragonEyesTextures = new ResourceLocation("textures/entity/enderdragon/dragon_eyes.png"); + private static final ResourceLocation enderDragonTextures = new ResourceLocation("textures/entity/enderdragon/dragon.png"); + protected ModelDragon modelDragon; + private static final String __OBFID = "CL_00000988"; + + public RenderDragon() + { + super(new ModelDragon(0.0F), 0.5F); + this.modelDragon = (ModelDragon)this.mainModel; + this.setRenderPassModel(this.mainModel); + } + + protected void rotateCorpse(EntityDragon par1EntityDragon, float par2, float par3, float par4) + { + float f3 = (float)par1EntityDragon.getMovementOffsets(7, par4)[0]; + float f4 = (float)(par1EntityDragon.getMovementOffsets(5, par4)[1] - par1EntityDragon.getMovementOffsets(10, par4)[1]); + GL11.glRotatef(-f3, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(f4 * 10.0F, 1.0F, 0.0F, 0.0F); + GL11.glTranslatef(0.0F, 0.0F, 1.0F); + + if (par1EntityDragon.deathTime > 0) + { + float f5 = ((float)par1EntityDragon.deathTime + par4 - 1.0F) / 20.0F * 1.6F; + f5 = MathHelper.sqrt_float(f5); + + if (f5 > 1.0F) + { + f5 = 1.0F; + } + + GL11.glRotatef(f5 * this.getDeathMaxRotation(par1EntityDragon), 0.0F, 0.0F, 1.0F); + } + } + + protected void renderModel(EntityDragon par1EntityDragon, float par2, float par3, float par4, float par5, float par6, float par7) + { + if (par1EntityDragon.deathTicks > 0) + { + float f6 = (float)par1EntityDragon.deathTicks / 200.0F; + GL11.glDepthFunc(GL11.GL_LEQUAL); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glAlphaFunc(GL11.GL_GREATER, f6); + this.bindTexture(enderDragonExplodingTextures); + this.mainModel.render(par1EntityDragon, par2, par3, par4, par5, par6, par7); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); + GL11.glDepthFunc(GL11.GL_EQUAL); + } + + this.bindEntityTexture(par1EntityDragon); + this.mainModel.render(par1EntityDragon, par2, par3, par4, par5, par6, par7); + + if (par1EntityDragon.hurtTime > 0) + { + GL11.glDepthFunc(GL11.GL_EQUAL); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1.0F, 0.0F, 0.0F, 0.5F); + this.mainModel.render(par1EntityDragon, par2, par3, par4, par5, par6, par7); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthFunc(GL11.GL_LEQUAL); + } + } + + public void doRender(EntityDragon par1EntityDragon, double par2, double par4, double par6, float par8, float par9) + { + BossStatus.setBossStatus(par1EntityDragon, false); + super.doRender((EntityLiving)par1EntityDragon, par2, par4, par6, par8, par9); + + if (par1EntityDragon.healingEnderCrystal != null) + { + float f2 = (float)par1EntityDragon.healingEnderCrystal.innerRotation + par9; + float f3 = MathHelper.sin(f2 * 0.2F) / 2.0F + 0.5F; + f3 = (f3 * f3 + f3) * 0.2F; + float f4 = (float)(par1EntityDragon.healingEnderCrystal.posX - par1EntityDragon.posX - (par1EntityDragon.prevPosX - par1EntityDragon.posX) * (double)(1.0F - par9)); + float f5 = (float)((double)f3 + par1EntityDragon.healingEnderCrystal.posY - 1.0D - par1EntityDragon.posY - (par1EntityDragon.prevPosY - par1EntityDragon.posY) * (double)(1.0F - par9)); + float f6 = (float)(par1EntityDragon.healingEnderCrystal.posZ - par1EntityDragon.posZ - (par1EntityDragon.prevPosZ - par1EntityDragon.posZ) * (double)(1.0F - par9)); + float f7 = MathHelper.sqrt_float(f4 * f4 + f6 * f6); + float f8 = MathHelper.sqrt_float(f4 * f4 + f5 * f5 + f6 * f6); + GL11.glPushMatrix(); + GL11.glTranslatef((float)par2, (float)par4 + 2.0F, (float)par6); + GL11.glRotatef((float)(-Math.atan2((double)f6, (double)f4)) * 180.0F / (float)Math.PI - 90.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef((float)(-Math.atan2((double)f7, (double)f5)) * 180.0F / (float)Math.PI - 90.0F, 1.0F, 0.0F, 0.0F); + Tessellator tessellator = Tessellator.instance; + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL11.GL_CULL_FACE); + this.bindTexture(enderDragonCrystalBeamTextures); + GL11.glShadeModel(GL11.GL_SMOOTH); + float f9 = 0.0F - ((float)par1EntityDragon.ticksExisted + par9) * 0.01F; + float f10 = MathHelper.sqrt_float(f4 * f4 + f5 * f5 + f6 * f6) / 32.0F - ((float)par1EntityDragon.ticksExisted + par9) * 0.01F; + tessellator.startDrawing(5); + byte b0 = 8; + + for (int i = 0; i <= b0; ++i) + { + float f11 = MathHelper.sin((float)(i % b0) * (float)Math.PI * 2.0F / (float)b0) * 0.75F; + float f12 = MathHelper.cos((float)(i % b0) * (float)Math.PI * 2.0F / (float)b0) * 0.75F; + float f13 = (float)(i % b0) * 1.0F / (float)b0; + tessellator.setColorOpaque_I(0); + tessellator.addVertexWithUV((double)(f11 * 0.2F), (double)(f12 * 0.2F), 0.0D, (double)f13, (double)f10); + tessellator.setColorOpaque_I(16777215); + tessellator.addVertexWithUV((double)f11, (double)f12, (double)f8, (double)f13, (double)f9); + } + + tessellator.draw(); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glShadeModel(GL11.GL_FLAT); + RenderHelper.enableStandardItemLighting(); + GL11.glPopMatrix(); + } + } + + protected ResourceLocation getEntityTexture(EntityDragon par1EntityDragon) + { + return enderDragonTextures; + } + + protected void renderEquippedItems(EntityDragon par1EntityDragon, float par2) + { + super.renderEquippedItems(par1EntityDragon, par2); + Tessellator tessellator = Tessellator.instance; + + if (par1EntityDragon.deathTicks > 0) + { + RenderHelper.disableStandardItemLighting(); + float f1 = ((float)par1EntityDragon.deathTicks + par2) / 200.0F; + float f2 = 0.0F; + + if (f1 > 0.8F) + { + f2 = (f1 - 0.8F) / 0.2F; + } + + Random random = new Random(432L); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glShadeModel(GL11.GL_SMOOTH); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glDepthMask(false); + GL11.glPushMatrix(); + GL11.glTranslatef(0.0F, -1.0F, -2.0F); + + for (int i = 0; (float)i < (f1 + f1 * f1) / 2.0F * 60.0F; ++i) + { + GL11.glRotatef(random.nextFloat() * 360.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(random.nextFloat() * 360.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(random.nextFloat() * 360.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(random.nextFloat() * 360.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(random.nextFloat() * 360.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(random.nextFloat() * 360.0F + f1 * 90.0F, 0.0F, 0.0F, 1.0F); + tessellator.startDrawing(6); + float f3 = random.nextFloat() * 20.0F + 5.0F + f2 * 10.0F; + float f4 = random.nextFloat() * 2.0F + 1.0F + f2 * 2.0F; + tessellator.setColorRGBA_I(16777215, (int)(255.0F * (1.0F - f2))); + tessellator.addVertex(0.0D, 0.0D, 0.0D); + tessellator.setColorRGBA_I(16711935, 0); + tessellator.addVertex(-0.866D * (double)f4, (double)f3, (double)(-0.5F * f4)); + tessellator.addVertex(0.866D * (double)f4, (double)f3, (double)(-0.5F * f4)); + tessellator.addVertex(0.0D, (double)f3, (double)(1.0F * f4)); + tessellator.addVertex(-0.866D * (double)f4, (double)f3, (double)(-0.5F * f4)); + tessellator.draw(); + } + + GL11.glPopMatrix(); + GL11.glDepthMask(true); + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glDisable(GL11.GL_BLEND); + GL11.glShadeModel(GL11.GL_FLAT); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_ALPHA_TEST); + RenderHelper.enableStandardItemLighting(); + } + } + + protected int shouldRenderPass(EntityDragon par1EntityDragon, int par2, float par3) + { + if (par2 == 1) + { + GL11.glDepthFunc(GL11.GL_LEQUAL); + } + + if (par2 != 0) + { + return -1; + } + else + { + this.bindTexture(enderDragonEyesTextures); + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDepthFunc(GL11.GL_EQUAL); + char c0 = 61680; + int j = c0 % 65536; + int k = c0 / 65536; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j / 1.0F, (float)k / 1.0F); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + return 1; + } + } + + public void doRender(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityDragon)par1EntityLiving, par2, par4, par6, par8, par9); + } + + protected int shouldRenderPass(EntityLivingBase par1EntityLivingBase, int par2, float par3) + { + return this.shouldRenderPass((EntityDragon)par1EntityLivingBase, par2, par3); + } + + protected void renderEquippedItems(EntityLivingBase par1EntityLivingBase, float par2) + { + this.renderEquippedItems((EntityDragon)par1EntityLivingBase, par2); + } + + protected void rotateCorpse(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4) + { + this.rotateCorpse((EntityDragon)par1EntityLivingBase, par2, par3, par4); + } + + protected void renderModel(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4, float par5, float par6, float par7) + { + this.renderModel((EntityDragon)par1EntityLivingBase, par2, par3, par4, par5, par6, par7); + } + + public void doRender(EntityLivingBase par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityDragon)par1Entity, par2, par4, par6, par8, par9); + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntityDragon)par1Entity); + } + + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityDragon)par1Entity, par2, par4, par6, par8, par9); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderEnchantmentTable.java b/src/main/java/net/minecraft/client/renderer/entity/RenderEnchantmentTable.java new file mode 100644 index 0000000..b36d902 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderEnchantmentTable.java @@ -0,0 +1,78 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelBook; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityEnchantmentTable; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class RenderEnchantmentTable extends TileEntitySpecialRenderer +{ + private static final ResourceLocation field_147540_b = new ResourceLocation("textures/entity/enchanting_table_book.png"); + private ModelBook field_147541_c = new ModelBook(); + private static final String __OBFID = "CL_00000966"; + + public void renderTileEntityAt(TileEntityEnchantmentTable p_147539_1_, double p_147539_2_, double p_147539_4_, double p_147539_6_, float p_147539_8_) + { + GL11.glPushMatrix(); + GL11.glTranslatef((float)p_147539_2_ + 0.5F, (float)p_147539_4_ + 0.75F, (float)p_147539_6_ + 0.5F); + float f1 = (float)p_147539_1_.field_145926_a + p_147539_8_; + GL11.glTranslatef(0.0F, 0.1F + MathHelper.sin(f1 * 0.1F) * 0.01F, 0.0F); + float f2; + + for (f2 = p_147539_1_.field_145928_o - p_147539_1_.field_145925_p; f2 >= (float)Math.PI; f2 -= ((float)Math.PI * 2F)) + { + ; + } + + while (f2 < -(float)Math.PI) + { + f2 += ((float)Math.PI * 2F); + } + + float f3 = p_147539_1_.field_145925_p + f2 * p_147539_8_; + GL11.glRotatef(-f3 * 180.0F / (float)Math.PI, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(80.0F, 0.0F, 0.0F, 1.0F); + this.bindTexture(field_147540_b); + float f4 = p_147539_1_.field_145931_j + (p_147539_1_.field_145933_i - p_147539_1_.field_145931_j) * p_147539_8_ + 0.25F; + float f5 = p_147539_1_.field_145931_j + (p_147539_1_.field_145933_i - p_147539_1_.field_145931_j) * p_147539_8_ + 0.75F; + f4 = (f4 - (float)MathHelper.truncateDoubleToInt((double)f4)) * 1.6F - 0.3F; + f5 = (f5 - (float)MathHelper.truncateDoubleToInt((double)f5)) * 1.6F - 0.3F; + + if (f4 < 0.0F) + { + f4 = 0.0F; + } + + if (f5 < 0.0F) + { + f5 = 0.0F; + } + + if (f4 > 1.0F) + { + f4 = 1.0F; + } + + if (f5 > 1.0F) + { + f5 = 1.0F; + } + + float f6 = p_147539_1_.field_145927_n + (p_147539_1_.field_145930_m - p_147539_1_.field_145927_n) * p_147539_8_; + GL11.glEnable(GL11.GL_CULL_FACE); + this.field_147541_c.render((Entity)null, f1, f4, f5, f6, 0.0F, 0.0625F); + GL11.glPopMatrix(); + } + + public void renderTileEntityAt(TileEntity p_147500_1_, double p_147500_2_, double p_147500_4_, double p_147500_6_, float p_147500_8_) + { + this.renderTileEntityAt((TileEntityEnchantmentTable)p_147500_1_, p_147500_2_, p_147500_4_, p_147500_6_, p_147500_8_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderEnderman.java b/src/main/java/net/minecraft/client/renderer/entity/RenderEnderman.java new file mode 100644 index 0000000..5cda235 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderEnderman.java @@ -0,0 +1,143 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.client.model.ModelEnderman; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.monster.EntityEnderman; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +@SideOnly(Side.CLIENT) +public class RenderEnderman extends RenderLiving +{ + private static final ResourceLocation endermanEyesTexture = new ResourceLocation("textures/entity/enderman/enderman_eyes.png"); + private static final ResourceLocation endermanTextures = new ResourceLocation("textures/entity/enderman/enderman.png"); + private ModelEnderman endermanModel; + private Random rnd = new Random(); + private static final String __OBFID = "CL_00000989"; + + public RenderEnderman() + { + super(new ModelEnderman(), 0.5F); + this.endermanModel = (ModelEnderman)super.mainModel; + this.setRenderPassModel(this.endermanModel); + } + + public void doRender(EntityEnderman par1EntityEnderman, double par2, double par4, double par6, float par8, float par9) + { + this.endermanModel.isCarrying = par1EntityEnderman.func_146080_bZ().getMaterial() != Material.air; + this.endermanModel.isAttacking = par1EntityEnderman.isScreaming(); + + if (par1EntityEnderman.isScreaming()) + { + double d3 = 0.02D; + par2 += this.rnd.nextGaussian() * d3; + par6 += this.rnd.nextGaussian() * d3; + } + + super.doRender((EntityLiving)par1EntityEnderman, par2, par4, par6, par8, par9); + } + + protected ResourceLocation getEntityTexture(EntityEnderman par1EntityEnderman) + { + return endermanTextures; + } + + protected void renderEquippedItems(EntityEnderman par1EntityEnderman, float par2) + { + super.renderEquippedItems(par1EntityEnderman, par2); + + if (par1EntityEnderman.func_146080_bZ().getMaterial() != Material.air) + { + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glPushMatrix(); + float f1 = 0.5F; + GL11.glTranslatef(0.0F, 0.6875F, -0.75F); + f1 *= 1.0F; + GL11.glRotatef(20.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); + GL11.glScalef(-f1, -f1, f1); + int i = par1EntityEnderman.getBrightnessForRender(par2); + int j = i % 65536; + int k = i / 65536; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j / 1.0F, (float)k / 1.0F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.bindTexture(TextureMap.locationBlocksTexture); + this.field_147909_c.renderBlockAsItem(par1EntityEnderman.func_146080_bZ(), par1EntityEnderman.getCarryingData(), 1.0F); + GL11.glPopMatrix(); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + } + } + + protected int shouldRenderPass(EntityEnderman par1EntityEnderman, int par2, float par3) + { + if (par2 != 0) + { + return -1; + } + else + { + this.bindTexture(endermanEyesTexture); + float f1 = 1.0F; + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); + GL11.glDisable(GL11.GL_LIGHTING); + + if (par1EntityEnderman.isInvisible()) + { + GL11.glDepthMask(false); + } + else + { + GL11.glDepthMask(true); + } + + char c0 = 61680; + int j = c0 % 65536; + int k = c0 / 65536; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j / 1.0F, (float)k / 1.0F); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glColor4f(1.0F, 1.0F, 1.0F, f1); + return 1; + } + } + + public void doRender(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityEnderman)par1EntityLiving, par2, par4, par6, par8, par9); + } + + protected int shouldRenderPass(EntityLivingBase par1EntityLivingBase, int par2, float par3) + { + return this.shouldRenderPass((EntityEnderman)par1EntityLivingBase, par2, par3); + } + + protected void renderEquippedItems(EntityLivingBase par1EntityLivingBase, float par2) + { + this.renderEquippedItems((EntityEnderman)par1EntityLivingBase, par2); + } + + public void doRender(EntityLivingBase par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityEnderman)par1Entity, par2, par4, par6, par8, par9); + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntityEnderman)par1Entity); + } + + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityEnderman)par1Entity, par2, par4, par6, par8, par9); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderEntity.java b/src/main/java/net/minecraft/client/renderer/entity/RenderEntity.java new file mode 100644 index 0000000..4deee6d --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderEntity.java @@ -0,0 +1,25 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class RenderEntity extends Render +{ + private static final String __OBFID = "CL_00000986"; + + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) + { + GL11.glPushMatrix(); + renderOffsetAABB(par1Entity.boundingBox, par2 - par1Entity.lastTickPosX, par4 - par1Entity.lastTickPosY, par6 - par1Entity.lastTickPosZ); + GL11.glPopMatrix(); + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return null; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderFallingBlock.java b/src/main/java/net/minecraft/client/renderer/entity/RenderFallingBlock.java new file mode 100644 index 0000000..fee1bb7 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderFallingBlock.java @@ -0,0 +1,90 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.block.BlockAnvil; +import net.minecraft.block.BlockDragonEgg; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityFallingBlock; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class RenderFallingBlock extends Render +{ + private final RenderBlocks field_147920_a = new RenderBlocks(); + private static final String __OBFID = "CL_00000994"; + + public RenderFallingBlock() + { + this.shadowSize = 0.5F; + } + + public void doRender(EntityFallingBlock p_147918_1_, double p_147918_2_, double p_147918_4_, double p_147918_6_, float p_147918_8_, float p_147918_9_) + { + World world = p_147918_1_.func_145807_e(); + Block block = p_147918_1_.func_145805_f(); + int i = MathHelper.floor_double(p_147918_1_.posX); + int j = MathHelper.floor_double(p_147918_1_.posY); + int k = MathHelper.floor_double(p_147918_1_.posZ); + + if (block != null && block != world.getBlock(i, j, k)) + { + GL11.glPushMatrix(); + GL11.glTranslatef((float)p_147918_2_, (float)p_147918_4_, (float)p_147918_6_); + this.bindEntityTexture(p_147918_1_); + GL11.glDisable(GL11.GL_LIGHTING); + Tessellator tessellator; + + if (block instanceof BlockAnvil) + { + this.field_147920_a.blockAccess = world; + tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.setTranslation((double)((float)(-i) - 0.5F), (double)((float)(-j) - 0.5F), (double)((float)(-k) - 0.5F)); + this.field_147920_a.renderBlockAnvilMetadata((BlockAnvil)block, i, j, k, p_147918_1_.field_145814_a); + tessellator.setTranslation(0.0D, 0.0D, 0.0D); + tessellator.draw(); + } + else if (block instanceof BlockDragonEgg) + { + this.field_147920_a.blockAccess = world; + tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.setTranslation((double)((float)(-i) - 0.5F), (double)((float)(-j) - 0.5F), (double)((float)(-k) - 0.5F)); + this.field_147920_a.renderBlockDragonEgg((BlockDragonEgg)block, i, j, k); + tessellator.setTranslation(0.0D, 0.0D, 0.0D); + tessellator.draw(); + } + else + { + this.field_147920_a.setRenderBoundsFromBlock(block); + this.field_147920_a.renderBlockSandFalling(block, world, i, j, k, p_147918_1_.field_145814_a); + } + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } + } + + protected ResourceLocation getEntityTexture(EntityFallingBlock p_147919_1_) + { + return TextureMap.locationBlocksTexture; + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntityFallingBlock)par1Entity); + } + + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityFallingBlock)par1Entity, par2, par4, par6, par8, par9); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderFireball.java b/src/main/java/net/minecraft/client/renderer/entity/RenderFireball.java new file mode 100644 index 0000000..d3ec784 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderFireball.java @@ -0,0 +1,70 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.entity.Entity; +import net.minecraft.entity.projectile.EntityFireball; +import net.minecraft.init.Items; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +@SideOnly(Side.CLIENT) +public class RenderFireball extends Render +{ + private float field_77002_a; + private static final String __OBFID = "CL_00000995"; + + public RenderFireball(float par1) + { + this.field_77002_a = par1; + } + + public void doRender(EntityFireball par1EntityFireball, double par2, double par4, double par6, float par8, float par9) + { + GL11.glPushMatrix(); + this.bindEntityTexture(par1EntityFireball); + GL11.glTranslatef((float)par2, (float)par4, (float)par6); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + float f2 = this.field_77002_a; + GL11.glScalef(f2 / 1.0F, f2 / 1.0F, f2 / 1.0F); + IIcon iicon = Items.fire_charge.getIconFromDamage(0); + Tessellator tessellator = Tessellator.instance; + float f3 = iicon.getMinU(); + float f4 = iicon.getMaxU(); + float f5 = iicon.getMinV(); + float f6 = iicon.getMaxV(); + float f7 = 1.0F; + float f8 = 0.5F; + float f9 = 0.25F; + GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + tessellator.addVertexWithUV((double)(0.0F - f8), (double)(0.0F - f9), 0.0D, (double)f3, (double)f6); + tessellator.addVertexWithUV((double)(f7 - f8), (double)(0.0F - f9), 0.0D, (double)f4, (double)f6); + tessellator.addVertexWithUV((double)(f7 - f8), (double)(1.0F - f9), 0.0D, (double)f4, (double)f5); + tessellator.addVertexWithUV((double)(0.0F - f8), (double)(1.0F - f9), 0.0D, (double)f3, (double)f5); + tessellator.draw(); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } + + protected ResourceLocation getEntityTexture(EntityFireball par1EntityFireball) + { + return TextureMap.locationItemsTexture; + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntityFireball)par1Entity); + } + + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityFireball)par1Entity, par2, par4, par6, par8, par9); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderFish.java b/src/main/java/net/minecraft/client/renderer/entity/RenderFish.java new file mode 100644 index 0000000..8c3a60c --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderFish.java @@ -0,0 +1,112 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.entity.Entity; +import net.minecraft.entity.projectile.EntityFishHook; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Vec3; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +@SideOnly(Side.CLIENT) +public class RenderFish extends Render +{ + private static final ResourceLocation field_110792_a = new ResourceLocation("textures/particle/particles.png"); + private static final String __OBFID = "CL_00000996"; + + public void doRender(EntityFishHook p_147922_1_, double p_147922_2_, double p_147922_4_, double p_147922_6_, float p_147922_8_, float p_147922_9_) + { + GL11.glPushMatrix(); + GL11.glTranslatef((float)p_147922_2_, (float)p_147922_4_, (float)p_147922_6_); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glScalef(0.5F, 0.5F, 0.5F); + this.bindEntityTexture(p_147922_1_); + Tessellator tessellator = Tessellator.instance; + byte b0 = 1; + byte b1 = 2; + float f2 = (float)(b0 * 8 + 0) / 128.0F; + float f3 = (float)(b0 * 8 + 8) / 128.0F; + float f4 = (float)(b1 * 8 + 0) / 128.0F; + float f5 = (float)(b1 * 8 + 8) / 128.0F; + float f6 = 1.0F; + float f7 = 0.5F; + float f8 = 0.5F; + GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + tessellator.addVertexWithUV((double)(0.0F - f7), (double)(0.0F - f8), 0.0D, (double)f2, (double)f5); + tessellator.addVertexWithUV((double)(f6 - f7), (double)(0.0F - f8), 0.0D, (double)f3, (double)f5); + tessellator.addVertexWithUV((double)(f6 - f7), (double)(1.0F - f8), 0.0D, (double)f3, (double)f4); + tessellator.addVertexWithUV((double)(0.0F - f7), (double)(1.0F - f8), 0.0D, (double)f2, (double)f4); + tessellator.draw(); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + + if (p_147922_1_.field_146042_b != null) + { + float f9 = p_147922_1_.field_146042_b.getSwingProgress(p_147922_9_); + float f10 = MathHelper.sin(MathHelper.sqrt_float(f9) * (float)Math.PI); + Vec3 vec3 = p_147922_1_.worldObj.getWorldVec3Pool().getVecFromPool(-0.5D, 0.03D, 0.8D); + vec3.rotateAroundX(-(p_147922_1_.field_146042_b.prevRotationPitch + (p_147922_1_.field_146042_b.rotationPitch - p_147922_1_.field_146042_b.prevRotationPitch) * p_147922_9_) * (float)Math.PI / 180.0F); + vec3.rotateAroundY(-(p_147922_1_.field_146042_b.prevRotationYaw + (p_147922_1_.field_146042_b.rotationYaw - p_147922_1_.field_146042_b.prevRotationYaw) * p_147922_9_) * (float)Math.PI / 180.0F); + vec3.rotateAroundY(f10 * 0.5F); + vec3.rotateAroundX(-f10 * 0.7F); + double d3 = p_147922_1_.field_146042_b.prevPosX + (p_147922_1_.field_146042_b.posX - p_147922_1_.field_146042_b.prevPosX) * (double)p_147922_9_ + vec3.xCoord; + double d4 = p_147922_1_.field_146042_b.prevPosY + (p_147922_1_.field_146042_b.posY - p_147922_1_.field_146042_b.prevPosY) * (double)p_147922_9_ + vec3.yCoord; + double d5 = p_147922_1_.field_146042_b.prevPosZ + (p_147922_1_.field_146042_b.posZ - p_147922_1_.field_146042_b.prevPosZ) * (double)p_147922_9_ + vec3.zCoord; + double d6 = p_147922_1_.field_146042_b == Minecraft.getMinecraft().thePlayer ? 0.0D : (double)p_147922_1_.field_146042_b.getEyeHeight(); + + if (this.renderManager.options.thirdPersonView > 0 || p_147922_1_.field_146042_b != Minecraft.getMinecraft().thePlayer) + { + float f11 = (p_147922_1_.field_146042_b.prevRenderYawOffset + (p_147922_1_.field_146042_b.renderYawOffset - p_147922_1_.field_146042_b.prevRenderYawOffset) * p_147922_9_) * (float)Math.PI / 180.0F; + double d7 = (double)MathHelper.sin(f11); + double d9 = (double)MathHelper.cos(f11); + d3 = p_147922_1_.field_146042_b.prevPosX + (p_147922_1_.field_146042_b.posX - p_147922_1_.field_146042_b.prevPosX) * (double)p_147922_9_ - d9 * 0.35D - d7 * 0.85D; + d4 = p_147922_1_.field_146042_b.prevPosY + d6 + (p_147922_1_.field_146042_b.posY - p_147922_1_.field_146042_b.prevPosY) * (double)p_147922_9_ - 0.45D; + d5 = p_147922_1_.field_146042_b.prevPosZ + (p_147922_1_.field_146042_b.posZ - p_147922_1_.field_146042_b.prevPosZ) * (double)p_147922_9_ - d7 * 0.35D + d9 * 0.85D; + } + + double d14 = p_147922_1_.prevPosX + (p_147922_1_.posX - p_147922_1_.prevPosX) * (double)p_147922_9_; + double d8 = p_147922_1_.prevPosY + (p_147922_1_.posY - p_147922_1_.prevPosY) * (double)p_147922_9_ + 0.25D; + double d10 = p_147922_1_.prevPosZ + (p_147922_1_.posZ - p_147922_1_.prevPosZ) * (double)p_147922_9_; + double d11 = (double)((float)(d3 - d14)); + double d12 = (double)((float)(d4 - d8)); + double d13 = (double)((float)(d5 - d10)); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_LIGHTING); + tessellator.startDrawing(3); + tessellator.setColorOpaque_I(0); + byte b2 = 16; + + for (int i = 0; i <= b2; ++i) + { + float f12 = (float)i / (float)b2; + tessellator.addVertex(p_147922_2_ + d11 * (double)f12, p_147922_4_ + d12 * (double)(f12 * f12 + f12) * 0.5D + 0.25D, p_147922_6_ + d13 * (double)f12); + } + + tessellator.draw(); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + } + + protected ResourceLocation getEntityTexture(EntityFishHook p_147921_1_) + { + return field_110792_a; + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntityFishHook)par1Entity); + } + + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityFishHook)par1Entity, par2, par4, par6, par8, par9); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderGhast.java b/src/main/java/net/minecraft/client/renderer/entity/RenderGhast.java new file mode 100644 index 0000000..c678176 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderGhast.java @@ -0,0 +1,54 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelGhast; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.monster.EntityGhast; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class RenderGhast extends RenderLiving +{ + private static final ResourceLocation ghastTextures = new ResourceLocation("textures/entity/ghast/ghast.png"); + private static final ResourceLocation ghastShootingTextures = new ResourceLocation("textures/entity/ghast/ghast_shooting.png"); + private static final String __OBFID = "CL_00000997"; + + public RenderGhast() + { + super(new ModelGhast(), 0.5F); + } + + protected ResourceLocation getEntityTexture(EntityGhast par1EntityGhast) + { + return par1EntityGhast.func_110182_bF() ? ghastShootingTextures : ghastTextures; + } + + protected void preRenderCallback(EntityGhast par1EntityGhast, float par2) + { + float f1 = ((float)par1EntityGhast.prevAttackCounter + (float)(par1EntityGhast.attackCounter - par1EntityGhast.prevAttackCounter) * par2) / 20.0F; + + if (f1 < 0.0F) + { + f1 = 0.0F; + } + + f1 = 1.0F / (f1 * f1 * f1 * f1 * f1 * 2.0F + 1.0F); + float f2 = (8.0F + f1) / 2.0F; + float f3 = (8.0F + 1.0F / f1) / 2.0F; + GL11.glScalef(f3, f2, f3); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + } + + protected void preRenderCallback(EntityLivingBase par1EntityLivingBase, float par2) + { + this.preRenderCallback((EntityGhast)par1EntityLivingBase, par2); + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntityGhast)par1Entity); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderGiantZombie.java b/src/main/java/net/minecraft/client/renderer/entity/RenderGiantZombie.java new file mode 100644 index 0000000..b78937c --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderGiantZombie.java @@ -0,0 +1,44 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelBase; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.monster.EntityGiantZombie; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class RenderGiantZombie extends RenderLiving +{ + private static final ResourceLocation zombieTextures = new ResourceLocation("textures/entity/zombie/zombie.png"); + private float scale; + private static final String __OBFID = "CL_00000998"; + + public RenderGiantZombie(ModelBase par1ModelBase, float par2, float par3) + { + super(par1ModelBase, par2 * par3); + this.scale = par3; + } + + protected void preRenderCallback(EntityGiantZombie par1EntityGiantZombie, float par2) + { + GL11.glScalef(this.scale, this.scale, this.scale); + } + + protected ResourceLocation getEntityTexture(EntityGiantZombie par1EntityGiantZombie) + { + return zombieTextures; + } + + protected void preRenderCallback(EntityLivingBase par1EntityLivingBase, float par2) + { + this.preRenderCallback((EntityGiantZombie)par1EntityLivingBase, par2); + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntityGiantZombie)par1Entity); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderHorse.java b/src/main/java/net/minecraft/client/renderer/entity/RenderHorse.java new file mode 100644 index 0000000..231158d --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderHorse.java @@ -0,0 +1,117 @@ +package net.minecraft.client.renderer.entity; + +import com.google.common.collect.Maps; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Map; +import net.minecraft.client.Minecraft; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.renderer.texture.LayeredTexture; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.passive.EntityHorse; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class RenderHorse extends RenderLiving +{ + private static final Map field_110852_a = Maps.newHashMap(); + private static final ResourceLocation whiteHorseTextures = new ResourceLocation("textures/entity/horse/horse_white.png"); + private static final ResourceLocation muleTextures = new ResourceLocation("textures/entity/horse/mule.png"); + private static final ResourceLocation donkeyTextures = new ResourceLocation("textures/entity/horse/donkey.png"); + private static final ResourceLocation zombieHorseTextures = new ResourceLocation("textures/entity/horse/horse_zombie.png"); + private static final ResourceLocation skeletonHorseTextures = new ResourceLocation("textures/entity/horse/horse_skeleton.png"); + private static final String __OBFID = "CL_00001000"; + + public RenderHorse(ModelBase par1ModelBase, float par2) + { + super(par1ModelBase, par2); + } + + protected void preRenderCallback(EntityHorse par1EntityHorse, float par2) + { + float f1 = 1.0F; + int i = par1EntityHorse.getHorseType(); + + if (i == 1) + { + f1 *= 0.87F; + } + else if (i == 2) + { + f1 *= 0.92F; + } + + GL11.glScalef(f1, f1, f1); + super.preRenderCallback(par1EntityHorse, par2); + } + + protected void renderModel(EntityHorse par1EntityHorse, float par2, float par3, float par4, float par5, float par6, float par7) + { + if (par1EntityHorse.isInvisible()) + { + this.mainModel.setRotationAngles(par2, par3, par4, par5, par6, par7, par1EntityHorse); + } + else + { + this.bindEntityTexture(par1EntityHorse); + this.mainModel.render(par1EntityHorse, par2, par3, par4, par5, par6, par7); + } + } + + protected ResourceLocation getEntityTexture(EntityHorse par1EntityHorse) + { + if (!par1EntityHorse.func_110239_cn()) + { + switch (par1EntityHorse.getHorseType()) + { + case 0: + default: + return whiteHorseTextures; + case 1: + return donkeyTextures; + case 2: + return muleTextures; + case 3: + return zombieHorseTextures; + case 4: + return skeletonHorseTextures; + } + } + else + { + return this.func_110848_b(par1EntityHorse); + } + } + + private ResourceLocation func_110848_b(EntityHorse par1EntityHorse) + { + String s = par1EntityHorse.getHorseTexture(); + ResourceLocation resourcelocation = (ResourceLocation)field_110852_a.get(s); + + if (resourcelocation == null) + { + resourcelocation = new ResourceLocation(s); + Minecraft.getMinecraft().getTextureManager().loadTexture(resourcelocation, new LayeredTexture(par1EntityHorse.getVariantTexturePaths())); + field_110852_a.put(s, resourcelocation); + } + + return resourcelocation; + } + + protected void preRenderCallback(EntityLivingBase par1EntityLivingBase, float par2) + { + this.preRenderCallback((EntityHorse)par1EntityLivingBase, par2); + } + + protected void renderModel(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4, float par5, float par6, float par7) + { + this.renderModel((EntityHorse)par1EntityLivingBase, par2, par3, par4, par5, par6, par7); + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntityHorse)par1Entity); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderIronGolem.java b/src/main/java/net/minecraft/client/renderer/entity/RenderIronGolem.java new file mode 100644 index 0000000..124c436 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderIronGolem.java @@ -0,0 +1,107 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelIronGolem; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.monster.EntityIronGolem; +import net.minecraft.init.Blocks; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +@SideOnly(Side.CLIENT) +public class RenderIronGolem extends RenderLiving +{ + private static final ResourceLocation ironGolemTextures = new ResourceLocation("textures/entity/iron_golem.png"); + private final ModelIronGolem ironGolemModel; + private static final String __OBFID = "CL_00001031"; + + public RenderIronGolem() + { + super(new ModelIronGolem(), 0.5F); + this.ironGolemModel = (ModelIronGolem)this.mainModel; + } + + public void doRender(EntityIronGolem par1EntityIronGolem, double par2, double par4, double par6, float par8, float par9) + { + super.doRender((EntityLiving)par1EntityIronGolem, par2, par4, par6, par8, par9); + } + + protected ResourceLocation getEntityTexture(EntityIronGolem par1EntityIronGolem) + { + return ironGolemTextures; + } + + protected void rotateCorpse(EntityIronGolem par1EntityIronGolem, float par2, float par3, float par4) + { + super.rotateCorpse(par1EntityIronGolem, par2, par3, par4); + + if ((double)par1EntityIronGolem.limbSwingAmount >= 0.01D) + { + float f3 = 13.0F; + float f4 = par1EntityIronGolem.limbSwing - par1EntityIronGolem.limbSwingAmount * (1.0F - par4) + 6.0F; + float f5 = (Math.abs(f4 % f3 - f3 * 0.5F) - f3 * 0.25F) / (f3 * 0.25F); + GL11.glRotatef(6.5F * f5, 0.0F, 0.0F, 1.0F); + } + } + + protected void renderEquippedItems(EntityIronGolem par1EntityIronGolem, float par2) + { + super.renderEquippedItems(par1EntityIronGolem, par2); + + if (par1EntityIronGolem.getHoldRoseTick() != 0) + { + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glPushMatrix(); + GL11.glRotatef(5.0F + 180.0F * this.ironGolemModel.ironGolemRightArm.rotateAngleX / (float)Math.PI, 1.0F, 0.0F, 0.0F); + GL11.glTranslatef(-0.6875F, 1.25F, -0.9375F); + GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); + float f1 = 0.8F; + GL11.glScalef(f1, -f1, f1); + int i = par1EntityIronGolem.getBrightnessForRender(par2); + int j = i % 65536; + int k = i / 65536; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j / 1.0F, (float)k / 1.0F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.bindTexture(TextureMap.locationBlocksTexture); + this.field_147909_c.renderBlockAsItem(Blocks.red_flower, 0, 1.0F); + GL11.glPopMatrix(); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + } + } + + public void doRender(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityIronGolem)par1EntityLiving, par2, par4, par6, par8, par9); + } + + protected void renderEquippedItems(EntityLivingBase par1EntityLivingBase, float par2) + { + this.renderEquippedItems((EntityIronGolem)par1EntityLivingBase, par2); + } + + protected void rotateCorpse(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4) + { + this.rotateCorpse((EntityIronGolem)par1EntityLivingBase, par2, par3, par4); + } + + public void doRender(EntityLivingBase par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityIronGolem)par1Entity, par2, par4, par6, par8, par9); + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntityIronGolem)par1Entity); + } + + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityIronGolem)par1Entity, par2, par4, par6, par8, par9); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderItem.java b/src/main/java/net/minecraft/client/renderer/entity/RenderItem.java new file mode 100644 index 0000000..baa8cb7 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderItem.java @@ -0,0 +1,759 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import java.util.concurrent.Callable; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.renderer.ItemRenderer; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.crash.CrashReport; +import net.minecraft.crash.CrashReportCategory; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemCloth; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ReportedException; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import net.minecraftforge.client.ForgeHooksClient; + +@SideOnly(Side.CLIENT) +public class RenderItem extends Render +{ + private static final ResourceLocation RES_ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png"); + private RenderBlocks renderBlocksRi = new RenderBlocks(); + private Random random = new Random(); + public boolean renderWithColor = true; + public float zLevel; + public static boolean renderInFrame; + private static final String __OBFID = "CL_00001003"; + + public RenderItem() + { + this.shadowSize = 0.15F; + this.shadowOpaque = 0.75F; + } + + public void doRender(EntityItem par1EntityItem, double par2, double par4, double par6, float par8, float par9) + { + ItemStack itemstack = par1EntityItem.getEntityItem(); + + if (itemstack.getItem() != null) + { + this.bindEntityTexture(par1EntityItem); + this.random.setSeed(187L); + GL11.glPushMatrix(); + float f2 = shouldBob() ? MathHelper.sin(((float)par1EntityItem.age + par9) / 10.0F + par1EntityItem.hoverStart) * 0.1F + 0.1F : 0F; + float f3 = (((float)par1EntityItem.age + par9) / 20.0F + par1EntityItem.hoverStart) * (180F / (float)Math.PI); + byte b0 = 1; + + if (par1EntityItem.getEntityItem().stackSize > 1) + { + b0 = 2; + } + + if (par1EntityItem.getEntityItem().stackSize > 5) + { + b0 = 3; + } + + if (par1EntityItem.getEntityItem().stackSize > 20) + { + b0 = 4; + } + + if (par1EntityItem.getEntityItem().stackSize > 40) + { + b0 = 5; + } + + b0 = getMiniBlockCount(itemstack, b0); + + GL11.glTranslatef((float)par2, (float)par4 + f2, (float)par6); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + float f6; + float f7; + int k; + + if (ForgeHooksClient.renderEntityItem(par1EntityItem, itemstack, f2, f3, random, renderManager.renderEngine, field_147909_c, b0)) + { + ; + } + else // Code Style break here to prevent the patch from editing this line + if (itemstack.getItemSpriteNumber() == 0 && itemstack.getItem() instanceof ItemBlock && RenderBlocks.renderItemIn3d(Block.getBlockFromItem(itemstack.getItem()).getRenderType())) + { + Block block = Block.getBlockFromItem(itemstack.getItem()); + GL11.glRotatef(f3, 0.0F, 1.0F, 0.0F); + + if (renderInFrame) + { + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glTranslatef(0.0F, 0.05F, 0.0F); + GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); + } + + float f9 = 0.25F; + k = block.getRenderType(); + + if (k == 1 || k == 19 || k == 12 || k == 2) + { + f9 = 0.5F; + } + + if (block.getRenderBlockPass() > 0) + { + GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + } + + GL11.glScalef(f9, f9, f9); + + for (int l = 0; l < b0; ++l) + { + GL11.glPushMatrix(); + + if (l > 0) + { + f6 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / f9; + f7 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / f9; + float f8 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / f9; + GL11.glTranslatef(f6, f7, f8); + } + + this.renderBlocksRi.renderBlockAsItem(block, itemstack.getItemDamage(), 1.0F); + GL11.glPopMatrix(); + } + + if (block.getRenderBlockPass() > 0) + { + GL11.glDisable(GL11.GL_BLEND); + } + } + else + { + float f5; + + if (/*itemstack.getItemSpriteNumber() == 1 &&*/ itemstack.getItem().requiresMultipleRenderPasses()) + { + if (renderInFrame) + { + GL11.glScalef(0.5128205F, 0.5128205F, 0.5128205F); + GL11.glTranslatef(0.0F, -0.05F, 0.0F); + } + else + { + GL11.glScalef(0.5F, 0.5F, 0.5F); + } + + for (int j = 0; j < itemstack.getItem().getRenderPasses(itemstack.getItemDamage()); ++j) + { + this.random.setSeed(187L); + IIcon iicon1 = itemstack.getItem().getIcon(itemstack, j); + + if (this.renderWithColor) + { + k = itemstack.getItem().getColorFromItemStack(itemstack, j); + f5 = (float)(k >> 16 & 255) / 255.0F; + f6 = (float)(k >> 8 & 255) / 255.0F; + f7 = (float)(k & 255) / 255.0F; + GL11.glColor4f(f5, f6, f7, 1.0F); + this.renderDroppedItem(par1EntityItem, iicon1, b0, par9, f5, f6, f7, j); + } + else + { + this.renderDroppedItem(par1EntityItem, iicon1, b0, par9, 1.0F, 1.0F, 1.0F, j); + } + } + } + else + { + if (itemstack != null && itemstack.getItem() instanceof ItemCloth) + { + GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + } + + if (renderInFrame) + { + GL11.glScalef(0.5128205F, 0.5128205F, 0.5128205F); + GL11.glTranslatef(0.0F, -0.05F, 0.0F); + } + else + { + GL11.glScalef(0.5F, 0.5F, 0.5F); + } + + IIcon iicon = itemstack.getIconIndex(); + + if (this.renderWithColor) + { + int i = itemstack.getItem().getColorFromItemStack(itemstack, 0); + float f4 = (float)(i >> 16 & 255) / 255.0F; + f5 = (float)(i >> 8 & 255) / 255.0F; + f6 = (float)(i & 255) / 255.0F; + this.renderDroppedItem(par1EntityItem, iicon, b0, par9, f4, f5, f6); + } + else + { + this.renderDroppedItem(par1EntityItem, iicon, b0, par9, 1.0F, 1.0F, 1.0F); + } + + if (itemstack != null && itemstack.getItem() instanceof ItemCloth) + { + GL11.glDisable(GL11.GL_BLEND); + } + } + } + + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } + } + + protected ResourceLocation getEntityTexture(EntityItem par1EntityItem) + { + return this.renderManager.renderEngine.getResourceLocation(par1EntityItem.getEntityItem().getItemSpriteNumber()); + } + + private void renderDroppedItem(EntityItem par1EntityItem, IIcon par2Icon, int par3, float par4, float par5, float par6, float par7) + { + this.renderDroppedItem(par1EntityItem, par2Icon, par3, par4, par5, par6, par7, 0); + } + + private void renderDroppedItem(EntityItem par1EntityItem, IIcon par2Icon, int par3, float par4, float par5, float par6, float par7, int pass) + { + Tessellator tessellator = Tessellator.instance; + + if (par2Icon == null) + { + TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); + ResourceLocation resourcelocation = texturemanager.getResourceLocation(par1EntityItem.getEntityItem().getItemSpriteNumber()); + par2Icon = ((TextureMap)texturemanager.getTexture(resourcelocation)).getAtlasSprite("missingno"); + } + + float f14 = ((IIcon)par2Icon).getMinU(); + float f15 = ((IIcon)par2Icon).getMaxU(); + float f4 = ((IIcon)par2Icon).getMinV(); + float f5 = ((IIcon)par2Icon).getMaxV(); + float f6 = 1.0F; + float f7 = 0.5F; + float f8 = 0.25F; + float f10; + + if (this.renderManager.options.fancyGraphics) + { + GL11.glPushMatrix(); + + if (renderInFrame) + { + GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); + } + else + { + GL11.glRotatef((((float)par1EntityItem.age + par4) / 20.0F + par1EntityItem.hoverStart) * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F); + } + + float f9 = 0.0625F; + f10 = 0.021875F; + ItemStack itemstack = par1EntityItem.getEntityItem(); + int j = itemstack.stackSize; + byte b0; + + if (j < 2) + { + b0 = 1; + } + else if (j < 16) + { + b0 = 2; + } + else if (j < 32) + { + b0 = 3; + } + else + { + b0 = 4; + } + + b0 = getMiniItemCount(itemstack, b0); + + GL11.glTranslatef(-f7, -f8, -((f9 + f10) * (float)b0 / 2.0F)); + + for (int k = 0; k < b0; ++k) + { + // Makes items offset when in 3D, like when in 2D, looks much better. Considered a vanilla bug... + if (k > 0 && shouldSpreadItems()) + { + float x = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F; + float y = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F; + float z = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F; + GL11.glTranslatef(x, y, f9 + f10); + } + else + { + GL11.glTranslatef(0f, 0f, f9 + f10); + } + + if (itemstack.getItemSpriteNumber() == 0) + { + this.bindTexture(TextureMap.locationBlocksTexture); + } + else + { + this.bindTexture(TextureMap.locationItemsTexture); + } + + GL11.glColor4f(par5, par6, par7, 1.0F); + ItemRenderer.renderItemIn2D(tessellator, f15, f4, f14, f5, ((IIcon)par2Icon).getIconWidth(), ((IIcon)par2Icon).getIconHeight(), f9); + + if (itemstack.hasEffect(pass)) + { + GL11.glDepthFunc(GL11.GL_EQUAL); + GL11.glDisable(GL11.GL_LIGHTING); + this.renderManager.renderEngine.bindTexture(RES_ITEM_GLINT); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); + float f11 = 0.76F; + GL11.glColor4f(0.5F * f11, 0.25F * f11, 0.8F * f11, 1.0F); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glPushMatrix(); + float f12 = 0.125F; + GL11.glScalef(f12, f12, f12); + float f13 = (float)(Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F; + GL11.glTranslatef(f13, 0.0F, 0.0F); + GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F); + ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, f9); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glScalef(f12, f12, f12); + f13 = (float)(Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F; + GL11.glTranslatef(-f13, 0.0F, 0.0F); + GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); + ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, f9); + GL11.glPopMatrix(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDepthFunc(GL11.GL_LEQUAL); + } + } + + GL11.glPopMatrix(); + } + else + { + for (int l = 0; l < par3; ++l) + { + GL11.glPushMatrix(); + + if (l > 0) + { + f10 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F; + float f16 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F; + float f17 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F; + GL11.glTranslatef(f10, f16, f17); + } + + if (!renderInFrame) + { + GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); + } + + GL11.glColor4f(par5, par6, par7, 1.0F); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + tessellator.addVertexWithUV((double)(0.0F - f7), (double)(0.0F - f8), 0.0D, (double)f14, (double)f5); + tessellator.addVertexWithUV((double)(f6 - f7), (double)(0.0F - f8), 0.0D, (double)f15, (double)f5); + tessellator.addVertexWithUV((double)(f6 - f7), (double)(1.0F - f8), 0.0D, (double)f15, (double)f4); + tessellator.addVertexWithUV((double)(0.0F - f7), (double)(1.0F - f8), 0.0D, (double)f14, (double)f4); + tessellator.draw(); + GL11.glPopMatrix(); + } + } + } + + public void renderItemIntoGUI(FontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5) + { + this.renderItemIntoGUI(par1FontRenderer, par2TextureManager, par3ItemStack, par4, par5, false); + } + + public void renderItemIntoGUI(FontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5, boolean renderEffect) + { + int k = par3ItemStack.getItemDamage(); + Object object = par3ItemStack.getIconIndex(); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + int l; + float f; + float f3; + float f4; + + if (par3ItemStack.getItemSpriteNumber() == 0 && RenderBlocks.renderItemIn3d(Block.getBlockFromItem(par3ItemStack.getItem()).getRenderType())) + { + par2TextureManager.bindTexture(TextureMap.locationBlocksTexture); + Block block = Block.getBlockFromItem(par3ItemStack.getItem()); + GL11.glPushMatrix(); + GL11.glTranslatef((float)(par4 - 2), (float)(par5 + 3), -3.0F + this.zLevel); + GL11.glScalef(10.0F, 10.0F, 10.0F); + GL11.glTranslatef(1.0F, 0.5F, 1.0F); + GL11.glScalef(1.0F, 1.0F, -1.0F); + GL11.glRotatef(210.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); + l = par3ItemStack.getItem().getColorFromItemStack(par3ItemStack, 0); + f3 = (float)(l >> 16 & 255) / 255.0F; + f4 = (float)(l >> 8 & 255) / 255.0F; + f = (float)(l & 255) / 255.0F; + + if (this.renderWithColor) + { + GL11.glColor4f(f3, f4, f, 1.0F); + } + + GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); + this.renderBlocksRi.useInventoryTint = this.renderWithColor; + this.renderBlocksRi.renderBlockAsItem(block, k, 1.0F); + this.renderBlocksRi.useInventoryTint = true; + GL11.glPopMatrix(); + } + else if (par3ItemStack.getItem().requiresMultipleRenderPasses()) + { + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_ALPHA_TEST); + par2TextureManager.bindTexture(TextureMap.locationItemsTexture); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(0, 0, 0, 0); + GL11.glColorMask(false, false, false, true); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.setColorOpaque_I(-1); + tessellator.addVertex((double)(par4 - 2), (double)(par5 + 18), (double)this.zLevel); + tessellator.addVertex((double)(par4 + 18), (double)(par5 + 18), (double)this.zLevel); + tessellator.addVertex((double)(par4 + 18), (double)(par5 - 2), (double)this.zLevel); + tessellator.addVertex((double)(par4 - 2), (double)(par5 - 2), (double)this.zLevel); + tessellator.draw(); + GL11.glColorMask(true, true, true, true); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_ALPHA_TEST); + + Item item = par3ItemStack.getItem(); + for (l = 0; l < item.getRenderPasses(k); ++l) + { + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + par2TextureManager.bindTexture(item.getSpriteNumber() == 0 ? TextureMap.locationBlocksTexture : TextureMap.locationItemsTexture); + IIcon iicon = item.getIcon(par3ItemStack, l); + int i1 = par3ItemStack.getItem().getColorFromItemStack(par3ItemStack, l); + f = (float)(i1 >> 16 & 255) / 255.0F; + float f1 = (float)(i1 >> 8 & 255) / 255.0F; + float f2 = (float)(i1 & 255) / 255.0F; + + if (this.renderWithColor) + { + GL11.glColor4f(f, f1, f2, 1.0F); + } + + GL11.glDisable(GL11.GL_LIGHTING); //Forge: Make sure that render states are reset, ad renderEffect can derp them up. + GL11.glEnable(GL11.GL_ALPHA_TEST); + + this.renderIcon(par4, par5, iicon, 16, 16); + + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_LIGHTING); + + if (renderEffect && par3ItemStack.hasEffect(l)) + { + renderEffect(par2TextureManager, par4, par5); + } + } + + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_LIGHTING); + } + else + { + GL11.glDisable(GL11.GL_LIGHTING); + ResourceLocation resourcelocation = par2TextureManager.getResourceLocation(par3ItemStack.getItemSpriteNumber()); + par2TextureManager.bindTexture(resourcelocation); + + if (object == null) + { + object = ((TextureMap)Minecraft.getMinecraft().getTextureManager().getTexture(resourcelocation)).getAtlasSprite("missingno"); + } + + l = par3ItemStack.getItem().getColorFromItemStack(par3ItemStack, 0); + f3 = (float)(l >> 16 & 255) / 255.0F; + f4 = (float)(l >> 8 & 255) / 255.0F; + f = (float)(l & 255) / 255.0F; + + if (this.renderWithColor) + { + GL11.glColor4f(f3, f4, f, 1.0F); + } + + GL11.glDisable(GL11.GL_LIGHTING); //Forge: Make sure that render states are reset, ad renderEffect can derp them up. + GL11.glEnable(GL11.GL_ALPHA_TEST); + + this.renderIcon(par4, par5, (IIcon)object, 16, 16); + + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_LIGHTING); + + if (renderEffect && par3ItemStack.hasEffect(0)) + { + renderEffect(par2TextureManager, par4, par5); + } + GL11.glEnable(GL11.GL_LIGHTING); + } + + GL11.glEnable(GL11.GL_CULL_FACE); + } + + @SuppressWarnings("unused") + public void renderItemAndEffectIntoGUI(FontRenderer par1FontRenderer, TextureManager par2TextureManager, final ItemStack par3ItemStack, int par4, int par5) + { + if (par3ItemStack != null) + { + this.zLevel += 50.0F; + + try + { + if (!ForgeHooksClient.renderInventoryItem(this.field_147909_c, par2TextureManager, par3ItemStack, renderWithColor, zLevel, (float)par4, (float)par5)) + { + this.renderItemIntoGUI(par1FontRenderer, par2TextureManager, par3ItemStack, par4, par5, true); + } + } + catch (Throwable throwable) + { + CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Rendering item"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("Item being rendered"); + crashreportcategory.addCrashSectionCallable("Item Type", new Callable() + { + private static final String __OBFID = "CL_00001004"; + public String call() + { + return String.valueOf(par3ItemStack.getItem()); + } + }); + crashreportcategory.addCrashSectionCallable("Item Aux", new Callable() + { + private static final String __OBFID = "CL_00001005"; + public String call() + { + return String.valueOf(par3ItemStack.getItemDamage()); + } + }); + crashreportcategory.addCrashSectionCallable("Item NBT", new Callable() + { + private static final String __OBFID = "CL_00001006"; + public String call() + { + return String.valueOf(par3ItemStack.getTagCompound()); + } + }); + crashreportcategory.addCrashSectionCallable("Item Foil", new Callable() + { + private static final String __OBFID = "CL_00001007"; + public String call() + { + return String.valueOf(par3ItemStack.hasEffect()); + } + }); + throw new ReportedException(crashreport); + } + + // Forge: Bugfix, Move this to a per-render pass, modders must handle themselves + if (false && par3ItemStack.hasEffect()) + { + GL11.glDepthFunc(GL11.GL_EQUAL); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDepthMask(false); + par2TextureManager.bindTexture(RES_ITEM_GLINT); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_BLEND); + GL11.glColor4f(0.5F, 0.25F, 0.8F, 1.0F); + this.renderGlint(par4 * 431278612 + par5 * 32178161, par4 - 2, par5 - 2, 20, 20); + GL11.glDepthMask(true); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDepthFunc(GL11.GL_LEQUAL); + } + + this.zLevel -= 50.0F; + } + } + + public void renderEffect(TextureManager manager, int x, int y) + { + GL11.glDepthFunc(GL11.GL_EQUAL); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDepthMask(false); + manager.bindTexture(RES_ITEM_GLINT); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_BLEND); + GL11.glColor4f(0.5F, 0.25F, 0.8F, 1.0F); + this.renderGlint(x * 431278612 + y * 32178161, x - 2, y - 2, 20, 20); + GL11.glDepthMask(true); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDepthFunc(GL11.GL_LEQUAL); + } + + private void renderGlint(int par1, int par2, int par3, int par4, int par5) + { + for (int j1 = 0; j1 < 2; ++j1) + { + OpenGlHelper.glBlendFunc(772, 1, 0, 0); + float f = 0.00390625F; + float f1 = 0.00390625F; + float f2 = (float)(Minecraft.getSystemTime() % (long)(3000 + j1 * 1873)) / (3000.0F + (float)(j1 * 1873)) * 256.0F; + float f3 = 0.0F; + Tessellator tessellator = Tessellator.instance; + float f4 = 4.0F; + + if (j1 == 1) + { + f4 = -1.0F; + } + + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV((double)(par2 + 0), (double)(par3 + par5), (double)this.zLevel, (double)((f2 + (float)par5 * f4) * f), (double)((f3 + (float)par5) * f1)); + tessellator.addVertexWithUV((double)(par2 + par4), (double)(par3 + par5), (double)this.zLevel, (double)((f2 + (float)par4 + (float)par5 * f4) * f), (double)((f3 + (float)par5) * f1)); + tessellator.addVertexWithUV((double)(par2 + par4), (double)(par3 + 0), (double)this.zLevel, (double)((f2 + (float)par4) * f), (double)((f3 + 0.0F) * f1)); + tessellator.addVertexWithUV((double)(par2 + 0), (double)(par3 + 0), (double)this.zLevel, (double)((f2 + 0.0F) * f), (double)((f3 + 0.0F) * f1)); + tessellator.draw(); + } + } + + public void renderItemOverlayIntoGUI(FontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5) + { + this.renderItemOverlayIntoGUI(par1FontRenderer, par2TextureManager, par3ItemStack, par4, par5, (String)null); + } + + public void renderItemOverlayIntoGUI(FontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5, String par6Str) + { + if (par3ItemStack != null) + { + if (par3ItemStack.stackSize > 1 || par6Str != null) + { + String s1 = par6Str == null ? String.valueOf(par3ItemStack.stackSize) : par6Str; + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glDisable(GL11.GL_BLEND); + par1FontRenderer.drawStringWithShadow(s1, par4 + 19 - 2 - par1FontRenderer.getStringWidth(s1), par5 + 6 + 3, 16777215); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + } + + if (par3ItemStack.getItem().showDurabilityBar(par3ItemStack)) + { + double health = par3ItemStack.getItem().getDurabilityForDisplay(par3ItemStack); + int j1 = (int)Math.round(13.0D - health * 13.0D); + int k = (int)Math.round(255.0D - health * 255.0D); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glDisable(GL11.GL_BLEND); + Tessellator tessellator = Tessellator.instance; + int l = 255 - k << 16 | k << 8; + int i1 = (255 - k) / 4 << 16 | 16128; + this.renderQuad(tessellator, par4 + 2, par5 + 13, 13, 2, 0); + this.renderQuad(tessellator, par4 + 2, par5 + 13, 12, 1, i1); + this.renderQuad(tessellator, par4 + 2, par5 + 13, j1, 1, l); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + } + } + } + + private void renderQuad(Tessellator par1Tessellator, int par2, int par3, int par4, int par5, int par6) + { + par1Tessellator.startDrawingQuads(); + par1Tessellator.setColorOpaque_I(par6); + par1Tessellator.addVertex((double)(par2 + 0), (double)(par3 + 0), 0.0D); + par1Tessellator.addVertex((double)(par2 + 0), (double)(par3 + par5), 0.0D); + par1Tessellator.addVertex((double)(par2 + par4), (double)(par3 + par5), 0.0D); + par1Tessellator.addVertex((double)(par2 + par4), (double)(par3 + 0), 0.0D); + par1Tessellator.draw(); + } + + public void renderIcon(int par1, int par2, IIcon par3Icon, int par4, int par5) + { + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV((double)(par1 + 0), (double)(par2 + par5), (double)this.zLevel, (double)par3Icon.getMinU(), (double)par3Icon.getMaxV()); + tessellator.addVertexWithUV((double)(par1 + par4), (double)(par2 + par5), (double)this.zLevel, (double)par3Icon.getMaxU(), (double)par3Icon.getMaxV()); + tessellator.addVertexWithUV((double)(par1 + par4), (double)(par2 + 0), (double)this.zLevel, (double)par3Icon.getMaxU(), (double)par3Icon.getMinV()); + tessellator.addVertexWithUV((double)(par1 + 0), (double)(par2 + 0), (double)this.zLevel, (double)par3Icon.getMinU(), (double)par3Icon.getMinV()); + tessellator.draw(); + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntityItem)par1Entity); + } + + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityItem)par1Entity, par2, par4, par6, par8, par9); + } + + /*==================================== FORGE START ===========================================*/ + + /** + * Items should spread out when rendered in 3d? + * @return + */ + public boolean shouldSpreadItems() + { + return true; + } + + /** + * Items should have a bob effect + * @return + */ + public boolean shouldBob() + { + return true; + } + + public byte getMiniBlockCount(ItemStack stack, byte original) + { + return original; + } + + /** + * Allows for a subclass to override how many rendered items appear in a + * "mini item 3d stack" + * @param stack The item stack + * @param original The default amount vanilla would use + * @return + */ + public byte getMiniItemCount(ItemStack stack, byte original) + { + return original; + } + /*==================================== FORGE END =============================================*/ +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderLeashKnot.java b/src/main/java/net/minecraft/client/renderer/entity/RenderLeashKnot.java new file mode 100644 index 0000000..21775b6 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderLeashKnot.java @@ -0,0 +1,47 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelLeashKnot; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLeashKnot; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +@SideOnly(Side.CLIENT) +public class RenderLeashKnot extends Render +{ + private static final ResourceLocation leashKnotTextures = new ResourceLocation("textures/entity/lead_knot.png"); + private ModelLeashKnot leashKnotModel = new ModelLeashKnot(); + private static final String __OBFID = "CL_00001010"; + + public void doRender(EntityLeashKnot par1EntityLeashKnot, double par2, double par4, double par6, float par8, float par9) + { + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glTranslatef((float)par2, (float)par4, (float)par6); + float f2 = 0.0625F; + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glScalef(-1.0F, -1.0F, 1.0F); + GL11.glEnable(GL11.GL_ALPHA_TEST); + this.bindEntityTexture(par1EntityLeashKnot); + this.leashKnotModel.render(par1EntityLeashKnot, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, f2); + GL11.glPopMatrix(); + } + + protected ResourceLocation getEntityTexture(EntityLeashKnot par1EntityLeashKnot) + { + return leashKnotTextures; + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntityLeashKnot)par1Entity); + } + + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityLeashKnot)par1Entity, par2, par4, par6, par8, par9); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderLightningBolt.java b/src/main/java/net/minecraft/client/renderer/entity/RenderLightningBolt.java new file mode 100644 index 0000000..aab493c --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderLightningBolt.java @@ -0,0 +1,149 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.entity.Entity; +import net.minecraft.entity.effect.EntityLightningBolt; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class RenderLightningBolt extends Render +{ + private static final String __OBFID = "CL_00001011"; + + public void doRender(EntityLightningBolt par1EntityLightningBolt, double par2, double par4, double par6, float par8, float par9) + { + Tessellator tessellator = Tessellator.instance; + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); + double[] adouble = new double[8]; + double[] adouble1 = new double[8]; + double d3 = 0.0D; + double d4 = 0.0D; + Random random = new Random(par1EntityLightningBolt.boltVertex); + + for (int i = 7; i >= 0; --i) + { + adouble[i] = d3; + adouble1[i] = d4; + d3 += (double)(random.nextInt(11) - 5); + d4 += (double)(random.nextInt(11) - 5); + } + + for (int k1 = 0; k1 < 4; ++k1) + { + Random random1 = new Random(par1EntityLightningBolt.boltVertex); + + for (int j = 0; j < 3; ++j) + { + int k = 7; + int l = 0; + + if (j > 0) + { + k = 7 - j; + } + + if (j > 0) + { + l = k - 2; + } + + double d5 = adouble[k] - d3; + double d6 = adouble1[k] - d4; + + for (int i1 = k; i1 >= l; --i1) + { + double d7 = d5; + double d8 = d6; + + if (j == 0) + { + d5 += (double)(random1.nextInt(11) - 5); + d6 += (double)(random1.nextInt(11) - 5); + } + else + { + d5 += (double)(random1.nextInt(31) - 15); + d6 += (double)(random1.nextInt(31) - 15); + } + + tessellator.startDrawing(5); + float f2 = 0.5F; + tessellator.setColorRGBA_F(0.9F * f2, 0.9F * f2, 1.0F * f2, 0.3F); + double d9 = 0.1D + (double)k1 * 0.2D; + + if (j == 0) + { + d9 *= (double)i1 * 0.1D + 1.0D; + } + + double d10 = 0.1D + (double)k1 * 0.2D; + + if (j == 0) + { + d10 *= (double)(i1 - 1) * 0.1D + 1.0D; + } + + for (int j1 = 0; j1 < 5; ++j1) + { + double d11 = par2 + 0.5D - d9; + double d12 = par6 + 0.5D - d9; + + if (j1 == 1 || j1 == 2) + { + d11 += d9 * 2.0D; + } + + if (j1 == 2 || j1 == 3) + { + d12 += d9 * 2.0D; + } + + double d13 = par2 + 0.5D - d10; + double d14 = par6 + 0.5D - d10; + + if (j1 == 1 || j1 == 2) + { + d13 += d10 * 2.0D; + } + + if (j1 == 2 || j1 == 3) + { + d14 += d10 * 2.0D; + } + + tessellator.addVertex(d13 + d5, par4 + (double)(i1 * 16), d14 + d6); + tessellator.addVertex(d11 + d7, par4 + (double)((i1 + 1) * 16), d12 + d8); + } + + tessellator.draw(); + } + } + } + + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + + protected ResourceLocation getEntityTexture(EntityLightningBolt par1EntityLightningBolt) + { + return null; + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntityLightningBolt)par1Entity); + } + + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityLightningBolt)par1Entity, par2, par4, par6, par8, par9); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderLiving.java b/src/main/java/net/minecraft/client/renderer/entity/RenderLiving.java new file mode 100644 index 0000000..f963fd3 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderLiving.java @@ -0,0 +1,140 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityHanging; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public abstract class RenderLiving extends RendererLivingEntity +{ + private static final String __OBFID = "CL_00001015"; + + public RenderLiving(ModelBase par1ModelBase, float par2) + { + super(par1ModelBase, par2); + } + + protected boolean func_110813_b(EntityLiving par1EntityLiving) + { + return super.func_110813_b(par1EntityLiving) && (par1EntityLiving.getAlwaysRenderNameTagForRender() || par1EntityLiving.hasCustomNameTag() && par1EntityLiving == this.renderManager.field_147941_i); + } + + public void doRender(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9) + { + super.doRender((EntityLivingBase)par1EntityLiving, par2, par4, par6, par8, par9); + this.func_110827_b(par1EntityLiving, par2, par4, par6, par8, par9); + } + + private double func_110828_a(double par1, double par3, double par5) + { + return par1 + (par3 - par1) * par5; + } + + protected void func_110827_b(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9) + { + Entity entity = par1EntityLiving.getLeashedToEntity(); + + if (entity != null) + { + par4 -= (1.6D - (double)par1EntityLiving.height) * 0.5D; + Tessellator tessellator = Tessellator.instance; + double d3 = this.func_110828_a((double)entity.prevRotationYaw, (double)entity.rotationYaw, (double)(par9 * 0.5F)) * 0.01745329238474369D; + double d4 = this.func_110828_a((double)entity.prevRotationPitch, (double)entity.rotationPitch, (double)(par9 * 0.5F)) * 0.01745329238474369D; + double d5 = Math.cos(d3); + double d6 = Math.sin(d3); + double d7 = Math.sin(d4); + + if (entity instanceof EntityHanging) + { + d5 = 0.0D; + d6 = 0.0D; + d7 = -1.0D; + } + + double d8 = Math.cos(d4); + double d9 = this.func_110828_a(entity.prevPosX, entity.posX, (double)par9) - d5 * 0.7D - d6 * 0.5D * d8; + double d10 = this.func_110828_a(entity.prevPosY + (double)entity.getEyeHeight() * 0.7D, entity.posY + (double)entity.getEyeHeight() * 0.7D, (double)par9) - d7 * 0.5D - 0.25D; + double d11 = this.func_110828_a(entity.prevPosZ, entity.posZ, (double)par9) - d6 * 0.7D + d5 * 0.5D * d8; + double d12 = this.func_110828_a((double)par1EntityLiving.prevRenderYawOffset, (double)par1EntityLiving.renderYawOffset, (double)par9) * 0.01745329238474369D + (Math.PI / 2D); + d5 = Math.cos(d12) * (double)par1EntityLiving.width * 0.4D; + d6 = Math.sin(d12) * (double)par1EntityLiving.width * 0.4D; + double d13 = this.func_110828_a(par1EntityLiving.prevPosX, par1EntityLiving.posX, (double)par9) + d5; + double d14 = this.func_110828_a(par1EntityLiving.prevPosY, par1EntityLiving.posY, (double)par9); + double d15 = this.func_110828_a(par1EntityLiving.prevPosZ, par1EntityLiving.posZ, (double)par9) + d6; + par2 += d5; + par6 += d6; + double d16 = (double)((float)(d9 - d13)); + double d17 = (double)((float)(d10 - d14)); + double d18 = (double)((float)(d11 - d15)); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_CULL_FACE); + boolean flag = true; + double d19 = 0.025D; + tessellator.startDrawing(5); + int i; + float f2; + + for (i = 0; i <= 24; ++i) + { + if (i % 2 == 0) + { + tessellator.setColorRGBA_F(0.5F, 0.4F, 0.3F, 1.0F); + } + else + { + tessellator.setColorRGBA_F(0.35F, 0.28F, 0.21000001F, 1.0F); + } + + f2 = (float)i / 24.0F; + tessellator.addVertex(par2 + d16 * (double)f2 + 0.0D, par4 + d17 * (double)(f2 * f2 + f2) * 0.5D + (double)((24.0F - (float)i) / 18.0F + 0.125F), par6 + d18 * (double)f2); + tessellator.addVertex(par2 + d16 * (double)f2 + 0.025D, par4 + d17 * (double)(f2 * f2 + f2) * 0.5D + (double)((24.0F - (float)i) / 18.0F + 0.125F) + 0.025D, par6 + d18 * (double)f2); + } + + tessellator.draw(); + tessellator.startDrawing(5); + + for (i = 0; i <= 24; ++i) + { + if (i % 2 == 0) + { + tessellator.setColorRGBA_F(0.5F, 0.4F, 0.3F, 1.0F); + } + else + { + tessellator.setColorRGBA_F(0.35F, 0.28F, 0.21000001F, 1.0F); + } + + f2 = (float)i / 24.0F; + tessellator.addVertex(par2 + d16 * (double)f2 + 0.0D, par4 + d17 * (double)(f2 * f2 + f2) * 0.5D + (double)((24.0F - (float)i) / 18.0F + 0.125F) + 0.025D, par6 + d18 * (double)f2); + tessellator.addVertex(par2 + d16 * (double)f2 + 0.025D, par4 + d17 * (double)(f2 * f2 + f2) * 0.5D + (double)((24.0F - (float)i) / 18.0F + 0.125F), par6 + d18 * (double)f2 + 0.025D); + } + + tessellator.draw(); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_CULL_FACE); + } + } + + protected boolean func_110813_b(EntityLivingBase par1EntityLivingBase) + { + return this.func_110813_b((EntityLiving)par1EntityLivingBase); + } + + public void doRender(EntityLivingBase par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityLiving)par1Entity, par2, par4, par6, par8, par9); + } + + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityLiving)par1Entity, par2, par4, par6, par8, par9); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderMagmaCube.java b/src/main/java/net/minecraft/client/renderer/entity/RenderMagmaCube.java new file mode 100644 index 0000000..9546d58 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderMagmaCube.java @@ -0,0 +1,46 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelMagmaCube; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.monster.EntityMagmaCube; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class RenderMagmaCube extends RenderLiving +{ + private static final ResourceLocation magmaCubeTextures = new ResourceLocation("textures/entity/slime/magmacube.png"); + private static final String __OBFID = "CL_00001009"; + + public RenderMagmaCube() + { + super(new ModelMagmaCube(), 0.25F); + } + + protected ResourceLocation getEntityTexture(EntityMagmaCube par1EntityMagmaCube) + { + return magmaCubeTextures; + } + + protected void preRenderCallback(EntityMagmaCube par1EntityMagmaCube, float par2) + { + int i = par1EntityMagmaCube.getSlimeSize(); + float f1 = (par1EntityMagmaCube.prevSquishFactor + (par1EntityMagmaCube.squishFactor - par1EntityMagmaCube.prevSquishFactor) * par2) / ((float)i * 0.5F + 1.0F); + float f2 = 1.0F / (f1 + 1.0F); + float f3 = (float)i; + GL11.glScalef(f2 * f3, 1.0F / f2 * f3, f2 * f3); + } + + protected void preRenderCallback(EntityLivingBase par1EntityLivingBase, float par2) + { + this.preRenderCallback((EntityMagmaCube)par1EntityLivingBase, par2); + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntityMagmaCube)par1Entity); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderManager.java b/src/main/java/net/minecraft/client/renderer/entity/RenderManager.java new file mode 100644 index 0000000..199ed54 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderManager.java @@ -0,0 +1,388 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import net.minecraft.block.Block; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.model.ModelChicken; +import net.minecraft.client.model.ModelCow; +import net.minecraft.client.model.ModelHorse; +import net.minecraft.client.model.ModelOcelot; +import net.minecraft.client.model.ModelPig; +import net.minecraft.client.model.ModelSheep1; +import net.minecraft.client.model.ModelSheep2; +import net.minecraft.client.model.ModelSlime; +import net.minecraft.client.model.ModelSquid; +import net.minecraft.client.model.ModelWolf; +import net.minecraft.client.model.ModelZombie; +import net.minecraft.client.renderer.ItemRenderer; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderGlobal; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.client.renderer.tileentity.RenderEnderCrystal; +import net.minecraft.client.renderer.tileentity.RenderItemFrame; +import net.minecraft.client.renderer.tileentity.RenderWitherSkull; +import net.minecraft.client.settings.GameSettings; +import net.minecraft.crash.CrashReport; +import net.minecraft.crash.CrashReportCategory; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLeashKnot; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.ai.EntityMinecartMobSpawner; +import net.minecraft.entity.boss.EntityDragon; +import net.minecraft.entity.boss.EntityWither; +import net.minecraft.entity.effect.EntityLightningBolt; +import net.minecraft.entity.item.EntityBoat; +import net.minecraft.entity.item.EntityEnderCrystal; +import net.minecraft.entity.item.EntityEnderEye; +import net.minecraft.entity.item.EntityEnderPearl; +import net.minecraft.entity.item.EntityExpBottle; +import net.minecraft.entity.item.EntityFallingBlock; +import net.minecraft.entity.item.EntityFireworkRocket; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.item.EntityItemFrame; +import net.minecraft.entity.item.EntityMinecart; +import net.minecraft.entity.item.EntityMinecartTNT; +import net.minecraft.entity.item.EntityPainting; +import net.minecraft.entity.item.EntityTNTPrimed; +import net.minecraft.entity.item.EntityXPOrb; +import net.minecraft.entity.monster.EntityBlaze; +import net.minecraft.entity.monster.EntityCaveSpider; +import net.minecraft.entity.monster.EntityCreeper; +import net.minecraft.entity.monster.EntityEnderman; +import net.minecraft.entity.monster.EntityGhast; +import net.minecraft.entity.monster.EntityGiantZombie; +import net.minecraft.entity.monster.EntityIronGolem; +import net.minecraft.entity.monster.EntityMagmaCube; +import net.minecraft.entity.monster.EntitySilverfish; +import net.minecraft.entity.monster.EntitySkeleton; +import net.minecraft.entity.monster.EntitySlime; +import net.minecraft.entity.monster.EntitySnowman; +import net.minecraft.entity.monster.EntitySpider; +import net.minecraft.entity.monster.EntityWitch; +import net.minecraft.entity.monster.EntityZombie; +import net.minecraft.entity.passive.EntityBat; +import net.minecraft.entity.passive.EntityChicken; +import net.minecraft.entity.passive.EntityCow; +import net.minecraft.entity.passive.EntityHorse; +import net.minecraft.entity.passive.EntityMooshroom; +import net.minecraft.entity.passive.EntityOcelot; +import net.minecraft.entity.passive.EntityPig; +import net.minecraft.entity.passive.EntitySheep; +import net.minecraft.entity.passive.EntitySquid; +import net.minecraft.entity.passive.EntityVillager; +import net.minecraft.entity.passive.EntityWolf; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.entity.projectile.EntityEgg; +import net.minecraft.entity.projectile.EntityFishHook; +import net.minecraft.entity.projectile.EntityLargeFireball; +import net.minecraft.entity.projectile.EntityPotion; +import net.minecraft.entity.projectile.EntitySmallFireball; +import net.minecraft.entity.projectile.EntitySnowball; +import net.minecraft.entity.projectile.EntityWitherSkull; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ReportedException; +import net.minecraft.world.World; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class RenderManager +{ + public Map entityRenderMap = new HashMap(); + public static RenderManager instance = new RenderManager(); + private FontRenderer fontRenderer; + public static double renderPosX; + public static double renderPosY; + public static double renderPosZ; + public TextureManager renderEngine; + public ItemRenderer itemRenderer; + public World worldObj; + public EntityLivingBase livingPlayer; + public Entity field_147941_i; + public float playerViewY; + public float playerViewX; + public GameSettings options; + public double viewerPosX; + public double viewerPosY; + public double viewerPosZ; + public static boolean debugBoundingBox; + private static final String __OBFID = "CL_00000991"; + + private RenderManager() + { + this.entityRenderMap.put(EntityCaveSpider.class, new RenderCaveSpider()); + this.entityRenderMap.put(EntitySpider.class, new RenderSpider()); + this.entityRenderMap.put(EntityPig.class, new RenderPig(new ModelPig(), new ModelPig(0.5F), 0.7F)); + this.entityRenderMap.put(EntitySheep.class, new RenderSheep(new ModelSheep2(), new ModelSheep1(), 0.7F)); + this.entityRenderMap.put(EntityCow.class, new RenderCow(new ModelCow(), 0.7F)); + this.entityRenderMap.put(EntityMooshroom.class, new RenderMooshroom(new ModelCow(), 0.7F)); + this.entityRenderMap.put(EntityWolf.class, new RenderWolf(new ModelWolf(), new ModelWolf(), 0.5F)); + this.entityRenderMap.put(EntityChicken.class, new RenderChicken(new ModelChicken(), 0.3F)); + this.entityRenderMap.put(EntityOcelot.class, new RenderOcelot(new ModelOcelot(), 0.4F)); + this.entityRenderMap.put(EntitySilverfish.class, new RenderSilverfish()); + this.entityRenderMap.put(EntityCreeper.class, new RenderCreeper()); + this.entityRenderMap.put(EntityEnderman.class, new RenderEnderman()); + this.entityRenderMap.put(EntitySnowman.class, new RenderSnowMan()); + this.entityRenderMap.put(EntitySkeleton.class, new RenderSkeleton()); + this.entityRenderMap.put(EntityWitch.class, new RenderWitch()); + this.entityRenderMap.put(EntityBlaze.class, new RenderBlaze()); + this.entityRenderMap.put(EntityZombie.class, new RenderZombie()); + this.entityRenderMap.put(EntitySlime.class, new RenderSlime(new ModelSlime(16), new ModelSlime(0), 0.25F)); + this.entityRenderMap.put(EntityMagmaCube.class, new RenderMagmaCube()); + this.entityRenderMap.put(EntityPlayer.class, new RenderPlayer()); + this.entityRenderMap.put(EntityGiantZombie.class, new RenderGiantZombie(new ModelZombie(), 0.5F, 6.0F)); + this.entityRenderMap.put(EntityGhast.class, new RenderGhast()); + this.entityRenderMap.put(EntitySquid.class, new RenderSquid(new ModelSquid(), 0.7F)); + this.entityRenderMap.put(EntityVillager.class, new RenderVillager()); + this.entityRenderMap.put(EntityIronGolem.class, new RenderIronGolem()); + this.entityRenderMap.put(EntityBat.class, new RenderBat()); + this.entityRenderMap.put(EntityDragon.class, new RenderDragon()); + this.entityRenderMap.put(EntityEnderCrystal.class, new RenderEnderCrystal()); + this.entityRenderMap.put(EntityWither.class, new RenderWither()); + this.entityRenderMap.put(Entity.class, new RenderEntity()); + this.entityRenderMap.put(EntityPainting.class, new RenderPainting()); + this.entityRenderMap.put(EntityItemFrame.class, new RenderItemFrame()); + this.entityRenderMap.put(EntityLeashKnot.class, new RenderLeashKnot()); + this.entityRenderMap.put(EntityArrow.class, new RenderArrow()); + this.entityRenderMap.put(EntitySnowball.class, new RenderSnowball(Items.snowball)); + this.entityRenderMap.put(EntityEnderPearl.class, new RenderSnowball(Items.ender_pearl)); + this.entityRenderMap.put(EntityEnderEye.class, new RenderSnowball(Items.ender_eye)); + this.entityRenderMap.put(EntityEgg.class, new RenderSnowball(Items.egg)); + this.entityRenderMap.put(EntityPotion.class, new RenderSnowball(Items.potionitem, 16384)); + this.entityRenderMap.put(EntityExpBottle.class, new RenderSnowball(Items.experience_bottle)); + this.entityRenderMap.put(EntityFireworkRocket.class, new RenderSnowball(Items.fireworks)); + this.entityRenderMap.put(EntityLargeFireball.class, new RenderFireball(2.0F)); + this.entityRenderMap.put(EntitySmallFireball.class, new RenderFireball(0.5F)); + this.entityRenderMap.put(EntityWitherSkull.class, new RenderWitherSkull()); + this.entityRenderMap.put(EntityItem.class, new RenderItem()); + this.entityRenderMap.put(EntityXPOrb.class, new RenderXPOrb()); + this.entityRenderMap.put(EntityTNTPrimed.class, new RenderTNTPrimed()); + this.entityRenderMap.put(EntityFallingBlock.class, new RenderFallingBlock()); + this.entityRenderMap.put(EntityMinecartTNT.class, new RenderTntMinecart()); + this.entityRenderMap.put(EntityMinecartMobSpawner.class, new RenderMinecartMobSpawner()); + this.entityRenderMap.put(EntityMinecart.class, new RenderMinecart()); + this.entityRenderMap.put(EntityBoat.class, new RenderBoat()); + this.entityRenderMap.put(EntityFishHook.class, new RenderFish()); + this.entityRenderMap.put(EntityHorse.class, new RenderHorse(new ModelHorse(), 0.75F)); + this.entityRenderMap.put(EntityLightningBolt.class, new RenderLightningBolt()); + Iterator iterator = this.entityRenderMap.values().iterator(); + + while (iterator.hasNext()) + { + Render render = (Render)iterator.next(); + render.setRenderManager(this); + } + } + + public Render getEntityClassRenderObject(Class par1Class) + { + Render render = (Render)this.entityRenderMap.get(par1Class); + + if (render == null && par1Class != Entity.class) + { + render = this.getEntityClassRenderObject(par1Class.getSuperclass()); + this.entityRenderMap.put(par1Class, render); + } + + return render; + } + + public Render getEntityRenderObject(Entity par1Entity) + { + return this.getEntityClassRenderObject(par1Entity.getClass()); + } + + public void cacheActiveRenderInfo(World p_147938_1_, TextureManager p_147938_2_, FontRenderer p_147938_3_, EntityLivingBase p_147938_4_, Entity p_147938_5_, GameSettings p_147938_6_, float p_147938_7_) + { + this.worldObj = p_147938_1_; + this.renderEngine = p_147938_2_; + this.options = p_147938_6_; + this.livingPlayer = p_147938_4_; + this.field_147941_i = p_147938_5_; + this.fontRenderer = p_147938_3_; + + if (p_147938_4_.isPlayerSleeping()) + { + Block block = p_147938_1_.getBlock(MathHelper.floor_double(p_147938_4_.posX), MathHelper.floor_double(p_147938_4_.posY), MathHelper.floor_double(p_147938_4_.posZ)); + int x = MathHelper.floor_double(p_147938_4_.posX); + int y = MathHelper.floor_double(p_147938_4_.posY); + int z = MathHelper.floor_double(p_147938_4_.posZ); + + if (block.isBed(p_147938_1_, x, y, z, p_147938_4_)) + { + int j = block.getBedDirection(p_147938_1_, x, y, z); + this.playerViewY = (float)(j * 90 + 180); + this.playerViewX = 0.0F; + } + } + else + { + this.playerViewY = p_147938_4_.prevRotationYaw + (p_147938_4_.rotationYaw - p_147938_4_.prevRotationYaw) * p_147938_7_; + this.playerViewX = p_147938_4_.prevRotationPitch + (p_147938_4_.rotationPitch - p_147938_4_.prevRotationPitch) * p_147938_7_; + } + + if (p_147938_6_.thirdPersonView == 2) + { + this.playerViewY += 180.0F; + } + + this.viewerPosX = p_147938_4_.lastTickPosX + (p_147938_4_.posX - p_147938_4_.lastTickPosX) * (double)p_147938_7_; + this.viewerPosY = p_147938_4_.lastTickPosY + (p_147938_4_.posY - p_147938_4_.lastTickPosY) * (double)p_147938_7_; + this.viewerPosZ = p_147938_4_.lastTickPosZ + (p_147938_4_.posZ - p_147938_4_.lastTickPosZ) * (double)p_147938_7_; + } + + public boolean renderEntitySimple(Entity p_147937_1_, float p_147937_2_) + { + return this.renderEntityStatic(p_147937_1_, p_147937_2_, false); + } + + public boolean renderEntityStatic(Entity p_147936_1_, float p_147936_2_, boolean p_147936_3_) + { + if (p_147936_1_.ticksExisted == 0) + { + p_147936_1_.lastTickPosX = p_147936_1_.posX; + p_147936_1_.lastTickPosY = p_147936_1_.posY; + p_147936_1_.lastTickPosZ = p_147936_1_.posZ; + } + + double d0 = p_147936_1_.lastTickPosX + (p_147936_1_.posX - p_147936_1_.lastTickPosX) * (double)p_147936_2_; + double d1 = p_147936_1_.lastTickPosY + (p_147936_1_.posY - p_147936_1_.lastTickPosY) * (double)p_147936_2_; + double d2 = p_147936_1_.lastTickPosZ + (p_147936_1_.posZ - p_147936_1_.lastTickPosZ) * (double)p_147936_2_; + float f1 = p_147936_1_.prevRotationYaw + (p_147936_1_.rotationYaw - p_147936_1_.prevRotationYaw) * p_147936_2_; + int i = p_147936_1_.getBrightnessForRender(p_147936_2_); + + if (p_147936_1_.isBurning()) + { + i = 15728880; + } + + int j = i % 65536; + int k = i / 65536; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j / 1.0F, (float)k / 1.0F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + return this.func_147939_a(p_147936_1_, d0 - renderPosX, d1 - renderPosY, d2 - renderPosZ, f1, p_147936_2_, p_147936_3_); + } + + public boolean renderEntityWithPosYaw(Entity p_147940_1_, double p_147940_2_, double p_147940_4_, double p_147940_6_, float p_147940_8_, float p_147940_9_) + { + return this.func_147939_a(p_147940_1_, p_147940_2_, p_147940_4_, p_147940_6_, p_147940_8_, p_147940_9_, false); + } + + public boolean func_147939_a(Entity p_147939_1_, double p_147939_2_, double p_147939_4_, double p_147939_6_, float p_147939_8_, float p_147939_9_, boolean p_147939_10_) + { + Render render = null; + + try + { + render = this.getEntityRenderObject(p_147939_1_); + + if (render != null && this.renderEngine != null) + { + if (!render.isStaticEntity() || p_147939_10_) + { + try + { + render.doRender(p_147939_1_, p_147939_2_, p_147939_4_, p_147939_6_, p_147939_8_, p_147939_9_); + } + catch (Throwable throwable2) + { + throw new ReportedException(CrashReport.makeCrashReport(throwable2, "Rendering entity in world")); + } + + try + { + render.doRenderShadowAndFire(p_147939_1_, p_147939_2_, p_147939_4_, p_147939_6_, p_147939_8_, p_147939_9_); + } + catch (Throwable throwable1) + { + throw new ReportedException(CrashReport.makeCrashReport(throwable1, "Post-rendering entity in world")); + } + + if (debugBoundingBox && !p_147939_1_.isInvisible() && !p_147939_10_) + { + try + { + this.renderDebugBoundingBox(p_147939_1_, p_147939_2_, p_147939_4_, p_147939_6_, p_147939_8_, p_147939_9_); + } + catch (Throwable throwable) + { + throw new ReportedException(CrashReport.makeCrashReport(throwable, "Rendering entity hitbox in world")); + } + } + } + } + else if (this.renderEngine != null) + { + return false; + } + + return true; + } + catch (Throwable throwable3) + { + CrashReport crashreport = CrashReport.makeCrashReport(throwable3, "Rendering entity in world"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("Entity being rendered"); + p_147939_1_.addEntityCrashInfo(crashreportcategory); + CrashReportCategory crashreportcategory1 = crashreport.makeCategory("Renderer details"); + crashreportcategory1.addCrashSection("Assigned renderer", render); + crashreportcategory1.addCrashSection("Location", CrashReportCategory.func_85074_a(p_147939_2_, p_147939_4_, p_147939_6_)); + crashreportcategory1.addCrashSection("Rotation", Float.valueOf(p_147939_8_)); + crashreportcategory1.addCrashSection("Delta", Float.valueOf(p_147939_9_)); + throw new ReportedException(crashreport); + } + } + + private void renderDebugBoundingBox(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) + { + GL11.glDepthMask(false); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glDisable(GL11.GL_BLEND); + float f2 = par1Entity.width / 2.0F; + AxisAlignedBB axisalignedbb = AxisAlignedBB.getAABBPool().getAABB(par2 - (double)f2, par4, par6 - (double)f2, par2 + (double)f2, par4 + (double)par1Entity.height, par6 + (double)f2); + RenderGlobal.drawOutlinedBoundingBox(axisalignedbb, 16777215); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthMask(true); + } + + public void set(World par1World) + { + this.worldObj = par1World; + } + + public double getDistanceToCamera(double par1, double par3, double par5) + { + double d3 = par1 - this.viewerPosX; + double d4 = par3 - this.viewerPosY; + double d5 = par5 - this.viewerPosZ; + return d3 * d3 + d4 * d4 + d5 * d5; + } + + public FontRenderer getFontRenderer() + { + return this.fontRenderer; + } + + public void updateIcons(IIconRegister par1IconRegister) + { + Iterator iterator = this.entityRenderMap.values().iterator(); + + while (iterator.hasNext()) + { + Render render = (Render)iterator.next(); + render.updateIcons(par1IconRegister); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderMinecart.java b/src/main/java/net/minecraft/client/renderer/entity/RenderMinecart.java new file mode 100644 index 0000000..9a9fa01 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderMinecart.java @@ -0,0 +1,136 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelMinecart; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityMinecart; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Vec3; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class RenderMinecart extends Render +{ + private static final ResourceLocation minecartTextures = new ResourceLocation("textures/entity/minecart.png"); + protected ModelBase modelMinecart = new ModelMinecart(); + protected final RenderBlocks field_94145_f; + private static final String __OBFID = "CL_00001013"; + + public RenderMinecart() + { + this.shadowSize = 0.5F; + this.field_94145_f = new RenderBlocks(); + } + + public void doRender(EntityMinecart par1EntityMinecart, double par2, double par4, double par6, float par8, float par9) + { + GL11.glPushMatrix(); + this.bindEntityTexture(par1EntityMinecart); + long i = (long)par1EntityMinecart.getEntityId() * 493286711L; + i = i * i * 4392167121L + i * 98761L; + float f2 = (((float)(i >> 16 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F; + float f3 = (((float)(i >> 20 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F; + float f4 = (((float)(i >> 24 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F; + GL11.glTranslatef(f2, f3, f4); + double d3 = par1EntityMinecart.lastTickPosX + (par1EntityMinecart.posX - par1EntityMinecart.lastTickPosX) * (double)par9; + double d4 = par1EntityMinecart.lastTickPosY + (par1EntityMinecart.posY - par1EntityMinecart.lastTickPosY) * (double)par9; + double d5 = par1EntityMinecart.lastTickPosZ + (par1EntityMinecart.posZ - par1EntityMinecart.lastTickPosZ) * (double)par9; + double d6 = 0.30000001192092896D; + Vec3 vec3 = par1EntityMinecart.func_70489_a(d3, d4, d5); + float f5 = par1EntityMinecart.prevRotationPitch + (par1EntityMinecart.rotationPitch - par1EntityMinecart.prevRotationPitch) * par9; + + if (vec3 != null) + { + Vec3 vec31 = par1EntityMinecart.func_70495_a(d3, d4, d5, d6); + Vec3 vec32 = par1EntityMinecart.func_70495_a(d3, d4, d5, -d6); + + if (vec31 == null) + { + vec31 = vec3; + } + + if (vec32 == null) + { + vec32 = vec3; + } + + par2 += vec3.xCoord - d3; + par4 += (vec31.yCoord + vec32.yCoord) / 2.0D - d4; + par6 += vec3.zCoord - d5; + Vec3 vec33 = vec32.addVector(-vec31.xCoord, -vec31.yCoord, -vec31.zCoord); + + if (vec33.lengthVector() != 0.0D) + { + vec33 = vec33.normalize(); + par8 = (float)(Math.atan2(vec33.zCoord, vec33.xCoord) * 180.0D / Math.PI); + f5 = (float)(Math.atan(vec33.yCoord) * 73.0D); + } + } + + GL11.glTranslatef((float)par2, (float)par4, (float)par6); + GL11.glRotatef(180.0F - par8, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-f5, 0.0F, 0.0F, 1.0F); + float f7 = (float)par1EntityMinecart.getRollingAmplitude() - par9; + float f8 = par1EntityMinecart.getDamage() - par9; + + if (f8 < 0.0F) + { + f8 = 0.0F; + } + + if (f7 > 0.0F) + { + GL11.glRotatef(MathHelper.sin(f7) * f7 * f8 / 10.0F * (float)par1EntityMinecart.getRollingDirection(), 1.0F, 0.0F, 0.0F); + } + + int k = par1EntityMinecart.getDisplayTileOffset(); + Block block = par1EntityMinecart.func_145820_n(); + int j = par1EntityMinecart.getDisplayTileData(); + + if (block.getRenderType() != -1) + { + GL11.glPushMatrix(); + this.bindTexture(TextureMap.locationBlocksTexture); + float f6 = 0.75F; + GL11.glScalef(f6, f6, f6); + GL11.glTranslatef(0.0F, (float)k / 16.0F, 0.0F); + this.func_147910_a(par1EntityMinecart, par9, block, j); + GL11.glPopMatrix(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.bindEntityTexture(par1EntityMinecart); + } + + GL11.glScalef(-1.0F, -1.0F, 1.0F); + this.modelMinecart.render(par1EntityMinecart, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); + GL11.glPopMatrix(); + } + + protected ResourceLocation getEntityTexture(EntityMinecart par1EntityMinecart) + { + return minecartTextures; + } + + protected void func_147910_a(EntityMinecart p_147910_1_, float p_147910_2_, Block p_147910_3_, int p_147910_4_) + { + float f1 = p_147910_1_.getBrightness(p_147910_2_); + GL11.glPushMatrix(); + this.field_94145_f.renderBlockAsItem(p_147910_3_, p_147910_4_, f1); + GL11.glPopMatrix(); + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntityMinecart)par1Entity); + } + + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityMinecart)par1Entity, par2, par4, par6, par8, par9); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderMinecartMobSpawner.java b/src/main/java/net/minecraft/client/renderer/entity/RenderMinecartMobSpawner.java new file mode 100644 index 0000000..a01489f --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderMinecartMobSpawner.java @@ -0,0 +1,30 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.tileentity.TileEntityMobSpawnerRenderer; +import net.minecraft.entity.ai.EntityMinecartMobSpawner; +import net.minecraft.entity.item.EntityMinecart; +import net.minecraft.init.Blocks; + +@SideOnly(Side.CLIENT) +public class RenderMinecartMobSpawner extends RenderMinecart +{ + private static final String __OBFID = "CL_00001014"; + + protected void func_147910_a(EntityMinecartMobSpawner p_147911_1_, float p_147911_2_, Block p_147911_3_, int p_147911_4_) + { + super.func_147910_a(p_147911_1_, p_147911_2_, p_147911_3_, p_147911_4_); + + if (p_147911_3_ == Blocks.mob_spawner) + { + TileEntityMobSpawnerRenderer.func_147517_a(p_147911_1_.func_98039_d(), p_147911_1_.posX, p_147911_1_.posY, p_147911_1_.posZ, p_147911_2_); + } + } + + protected void func_147910_a(EntityMinecart p_147910_1_, float p_147910_2_, Block p_147910_3_, int p_147910_4_) + { + this.func_147910_a((EntityMinecartMobSpawner)p_147910_1_, p_147910_2_, p_147910_3_, p_147910_4_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderMooshroom.java b/src/main/java/net/minecraft/client/renderer/entity/RenderMooshroom.java new file mode 100644 index 0000000..f77fd26 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderMooshroom.java @@ -0,0 +1,89 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelQuadruped; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.passive.EntityMooshroom; +import net.minecraft.init.Blocks; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class RenderMooshroom extends RenderLiving +{ + private static final ResourceLocation mooshroomTextures = new ResourceLocation("textures/entity/cow/mooshroom.png"); + private static final String __OBFID = "CL_00001016"; + + public RenderMooshroom(ModelBase par1ModelBase, float par2) + { + super(par1ModelBase, par2); + } + + public void doRender(EntityMooshroom par1EntityMooshroom, double par2, double par4, double par6, float par8, float par9) + { + super.doRender((EntityLiving)par1EntityMooshroom, par2, par4, par6, par8, par9); + } + + protected ResourceLocation getEntityTexture(EntityMooshroom par1EntityMooshroom) + { + return mooshroomTextures; + } + + protected void renderEquippedItems(EntityMooshroom par1EntityMooshroom, float par2) + { + super.renderEquippedItems(par1EntityMooshroom, par2); + + if (!par1EntityMooshroom.isChild()) + { + this.bindTexture(TextureMap.locationBlocksTexture); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glPushMatrix(); + GL11.glScalef(1.0F, -1.0F, 1.0F); + GL11.glTranslatef(0.2F, 0.4F, 0.5F); + GL11.glRotatef(42.0F, 0.0F, 1.0F, 0.0F); + this.field_147909_c.renderBlockAsItem(Blocks.red_mushroom, 0, 1.0F); + GL11.glTranslatef(0.1F, 0.0F, -0.6F); + GL11.glRotatef(42.0F, 0.0F, 1.0F, 0.0F); + this.field_147909_c.renderBlockAsItem(Blocks.red_mushroom, 0, 1.0F); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + ((ModelQuadruped)this.mainModel).head.postRender(0.0625F); + GL11.glScalef(1.0F, -1.0F, 1.0F); + GL11.glTranslatef(0.0F, 0.75F, -0.2F); + GL11.glRotatef(12.0F, 0.0F, 1.0F, 0.0F); + this.field_147909_c.renderBlockAsItem(Blocks.red_mushroom, 0, 1.0F); + GL11.glPopMatrix(); + GL11.glDisable(GL11.GL_CULL_FACE); + } + } + + public void doRender(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityMooshroom)par1EntityLiving, par2, par4, par6, par8, par9); + } + + protected void renderEquippedItems(EntityLivingBase par1EntityLivingBase, float par2) + { + this.renderEquippedItems((EntityMooshroom)par1EntityLivingBase, par2); + } + + public void doRender(EntityLivingBase par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityMooshroom)par1Entity, par2, par4, par6, par8, par9); + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntityMooshroom)par1Entity); + } + + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityMooshroom)par1Entity, par2, par4, par6, par8, par9); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderOcelot.java b/src/main/java/net/minecraft/client/renderer/entity/RenderOcelot.java new file mode 100644 index 0000000..2c6e4c0 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderOcelot.java @@ -0,0 +1,82 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelBase; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.passive.EntityOcelot; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class RenderOcelot extends RenderLiving +{ + private static final ResourceLocation blackOcelotTextures = new ResourceLocation("textures/entity/cat/black.png"); + private static final ResourceLocation ocelotTextures = new ResourceLocation("textures/entity/cat/ocelot.png"); + private static final ResourceLocation redOcelotTextures = new ResourceLocation("textures/entity/cat/red.png"); + private static final ResourceLocation siameseOcelotTextures = new ResourceLocation("textures/entity/cat/siamese.png"); + private static final String __OBFID = "CL_00001017"; + + public RenderOcelot(ModelBase par1ModelBase, float par2) + { + super(par1ModelBase, par2); + } + + public void doRender(EntityOcelot par1EntityOcelot, double par2, double par4, double par6, float par8, float par9) + { + super.doRender((EntityLiving)par1EntityOcelot, par2, par4, par6, par8, par9); + } + + protected ResourceLocation getEntityTexture(EntityOcelot par1EntityOcelot) + { + switch (par1EntityOcelot.getTameSkin()) + { + case 0: + default: + return ocelotTextures; + case 1: + return blackOcelotTextures; + case 2: + return redOcelotTextures; + case 3: + return siameseOcelotTextures; + } + } + + protected void preRenderCallback(EntityOcelot par1EntityOcelot, float par2) + { + super.preRenderCallback(par1EntityOcelot, par2); + + if (par1EntityOcelot.isTamed()) + { + GL11.glScalef(0.8F, 0.8F, 0.8F); + } + } + + public void doRender(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityOcelot)par1EntityLiving, par2, par4, par6, par8, par9); + } + + protected void preRenderCallback(EntityLivingBase par1EntityLivingBase, float par2) + { + this.preRenderCallback((EntityOcelot)par1EntityLivingBase, par2); + } + + public void doRender(EntityLivingBase par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityOcelot)par1Entity, par2, par4, par6, par8, par9); + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntityOcelot)par1Entity); + } + + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityOcelot)par1Entity, par2, par4, par6, par8, par9); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderPainting.java b/src/main/java/net/minecraft/client/renderer/entity/RenderPainting.java new file mode 100644 index 0000000..68ad5c1 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderPainting.java @@ -0,0 +1,150 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityPainting; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +@SideOnly(Side.CLIENT) +public class RenderPainting extends Render +{ + private static final ResourceLocation field_110807_a = new ResourceLocation("textures/painting/paintings_kristoffer_zetterstrand.png"); + private static final String __OBFID = "CL_00001018"; + + public void doRender(EntityPainting par1EntityPainting, double par2, double par4, double par6, float par8, float par9) + { + GL11.glPushMatrix(); + GL11.glTranslated(par2, par4, par6); + GL11.glRotatef(par8, 0.0F, 1.0F, 0.0F); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + this.bindEntityTexture(par1EntityPainting); + EntityPainting.EnumArt enumart = par1EntityPainting.art; + float f2 = 0.0625F; + GL11.glScalef(f2, f2, f2); + this.func_77010_a(par1EntityPainting, enumart.sizeX, enumart.sizeY, enumart.offsetX, enumart.offsetY); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } + + protected ResourceLocation getEntityTexture(EntityPainting par1EntityPainting) + { + return field_110807_a; + } + + private void func_77010_a(EntityPainting par1EntityPainting, int par2, int par3, int par4, int par5) + { + float f = (float)(-par2) / 2.0F; + float f1 = (float)(-par3) / 2.0F; + float f2 = 0.5F; + float f3 = 0.75F; + float f4 = 0.8125F; + float f5 = 0.0F; + float f6 = 0.0625F; + float f7 = 0.75F; + float f8 = 0.8125F; + float f9 = 0.001953125F; + float f10 = 0.001953125F; + float f11 = 0.7519531F; + float f12 = 0.7519531F; + float f13 = 0.0F; + float f14 = 0.0625F; + + for (int i1 = 0; i1 < par2 / 16; ++i1) + { + for (int j1 = 0; j1 < par3 / 16; ++j1) + { + float f15 = f + (float)((i1 + 1) * 16); + float f16 = f + (float)(i1 * 16); + float f17 = f1 + (float)((j1 + 1) * 16); + float f18 = f1 + (float)(j1 * 16); + this.func_77008_a(par1EntityPainting, (f15 + f16) / 2.0F, (f17 + f18) / 2.0F); + float f19 = (float)(par4 + par2 - i1 * 16) / 256.0F; + float f20 = (float)(par4 + par2 - (i1 + 1) * 16) / 256.0F; + float f21 = (float)(par5 + par3 - j1 * 16) / 256.0F; + float f22 = (float)(par5 + par3 - (j1 + 1) * 16) / 256.0F; + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, -1.0F); + tessellator.addVertexWithUV((double)f15, (double)f18, (double)(-f2), (double)f20, (double)f21); + tessellator.addVertexWithUV((double)f16, (double)f18, (double)(-f2), (double)f19, (double)f21); + tessellator.addVertexWithUV((double)f16, (double)f17, (double)(-f2), (double)f19, (double)f22); + tessellator.addVertexWithUV((double)f15, (double)f17, (double)(-f2), (double)f20, (double)f22); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + tessellator.addVertexWithUV((double)f15, (double)f17, (double)f2, (double)f3, (double)f5); + tessellator.addVertexWithUV((double)f16, (double)f17, (double)f2, (double)f4, (double)f5); + tessellator.addVertexWithUV((double)f16, (double)f18, (double)f2, (double)f4, (double)f6); + tessellator.addVertexWithUV((double)f15, (double)f18, (double)f2, (double)f3, (double)f6); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + tessellator.addVertexWithUV((double)f15, (double)f17, (double)(-f2), (double)f7, (double)f9); + tessellator.addVertexWithUV((double)f16, (double)f17, (double)(-f2), (double)f8, (double)f9); + tessellator.addVertexWithUV((double)f16, (double)f17, (double)f2, (double)f8, (double)f10); + tessellator.addVertexWithUV((double)f15, (double)f17, (double)f2, (double)f7, (double)f10); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + tessellator.addVertexWithUV((double)f15, (double)f18, (double)f2, (double)f7, (double)f9); + tessellator.addVertexWithUV((double)f16, (double)f18, (double)f2, (double)f8, (double)f9); + tessellator.addVertexWithUV((double)f16, (double)f18, (double)(-f2), (double)f8, (double)f10); + tessellator.addVertexWithUV((double)f15, (double)f18, (double)(-f2), (double)f7, (double)f10); + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + tessellator.addVertexWithUV((double)f15, (double)f17, (double)f2, (double)f12, (double)f13); + tessellator.addVertexWithUV((double)f15, (double)f18, (double)f2, (double)f12, (double)f14); + tessellator.addVertexWithUV((double)f15, (double)f18, (double)(-f2), (double)f11, (double)f14); + tessellator.addVertexWithUV((double)f15, (double)f17, (double)(-f2), (double)f11, (double)f13); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + tessellator.addVertexWithUV((double)f16, (double)f17, (double)(-f2), (double)f12, (double)f13); + tessellator.addVertexWithUV((double)f16, (double)f18, (double)(-f2), (double)f12, (double)f14); + tessellator.addVertexWithUV((double)f16, (double)f18, (double)f2, (double)f11, (double)f14); + tessellator.addVertexWithUV((double)f16, (double)f17, (double)f2, (double)f11, (double)f13); + tessellator.draw(); + } + } + } + + private void func_77008_a(EntityPainting par1EntityPainting, float par2, float par3) + { + int i = MathHelper.floor_double(par1EntityPainting.posX); + int j = MathHelper.floor_double(par1EntityPainting.posY + (double)(par3 / 16.0F)); + int k = MathHelper.floor_double(par1EntityPainting.posZ); + + if (par1EntityPainting.hangingDirection == 2) + { + i = MathHelper.floor_double(par1EntityPainting.posX + (double)(par2 / 16.0F)); + } + + if (par1EntityPainting.hangingDirection == 1) + { + k = MathHelper.floor_double(par1EntityPainting.posZ - (double)(par2 / 16.0F)); + } + + if (par1EntityPainting.hangingDirection == 0) + { + i = MathHelper.floor_double(par1EntityPainting.posX - (double)(par2 / 16.0F)); + } + + if (par1EntityPainting.hangingDirection == 3) + { + k = MathHelper.floor_double(par1EntityPainting.posZ + (double)(par2 / 16.0F)); + } + + int l = this.renderManager.worldObj.getLightBrightnessForSkyBlocks(i, j, k, 0); + int i1 = l % 65536; + int j1 = l / 65536; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)i1, (float)j1); + GL11.glColor3f(1.0F, 1.0F, 1.0F); + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntityPainting)par1Entity); + } + + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityPainting)par1Entity, par2, par4, par6, par8, par9); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderPig.java b/src/main/java/net/minecraft/client/renderer/entity/RenderPig.java new file mode 100644 index 0000000..13747f3 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderPig.java @@ -0,0 +1,51 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelBase; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.passive.EntityPig; +import net.minecraft.util.ResourceLocation; + +@SideOnly(Side.CLIENT) +public class RenderPig extends RenderLiving +{ + private static final ResourceLocation saddledPigTextures = new ResourceLocation("textures/entity/pig/pig_saddle.png"); + private static final ResourceLocation pigTextures = new ResourceLocation("textures/entity/pig/pig.png"); + private static final String __OBFID = "CL_00001019"; + + public RenderPig(ModelBase par1ModelBase, ModelBase par2ModelBase, float par3) + { + super(par1ModelBase, par3); + this.setRenderPassModel(par2ModelBase); + } + + protected int shouldRenderPass(EntityPig par1EntityPig, int par2, float par3) + { + if (par2 == 0 && par1EntityPig.getSaddled()) + { + this.bindTexture(saddledPigTextures); + return 1; + } + else + { + return -1; + } + } + + protected ResourceLocation getEntityTexture(EntityPig par1EntityPig) + { + return pigTextures; + } + + protected int shouldRenderPass(EntityLivingBase par1EntityLivingBase, int par2, float par3) + { + return this.shouldRenderPass((EntityPig)par1EntityLivingBase, par2, par3); + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntityPig)par1Entity); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderPlayer.java b/src/main/java/net/minecraft/client/renderer/entity/RenderPlayer.java new file mode 100644 index 0000000..b9259ac --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderPlayer.java @@ -0,0 +1,522 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.client.entity.AbstractClientPlayer; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.client.model.ModelBiped; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.tileentity.TileEntitySkullRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.EnumAction; +import net.minecraft.item.Item; +import net.minecraft.item.ItemArmor; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.scoreboard.Score; +import net.minecraft.scoreboard.ScoreObjective; +import net.minecraft.scoreboard.Scoreboard; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.ForgeHooksClient; +import net.minecraftforge.client.IItemRenderer; +import net.minecraftforge.client.MinecraftForgeClient; +import net.minecraftforge.client.event.RenderPlayerEvent; +import net.minecraftforge.common.MinecraftForge; + +import org.lwjgl.opengl.GL11; +import static net.minecraftforge.client.IItemRenderer.ItemRenderType.EQUIPPED; +import static net.minecraftforge.client.IItemRenderer.ItemRendererHelper.BLOCK_3D; + +@SideOnly(Side.CLIENT) +public class RenderPlayer extends RendererLivingEntity +{ + private static final ResourceLocation steveTextures = new ResourceLocation("textures/entity/steve.png"); + public ModelBiped modelBipedMain; + public ModelBiped modelArmorChestplate; + public ModelBiped modelArmor; + private static final String __OBFID = "CL_00001020"; + + public RenderPlayer() + { + super(new ModelBiped(0.0F), 0.5F); + this.modelBipedMain = (ModelBiped)this.mainModel; + this.modelArmorChestplate = new ModelBiped(1.0F); + this.modelArmor = new ModelBiped(0.5F); + } + + protected int shouldRenderPass(AbstractClientPlayer par1AbstractClientPlayer, int par2, float par3) + { + ItemStack itemstack = par1AbstractClientPlayer.inventory.armorItemInSlot(3 - par2); + + RenderPlayerEvent.SetArmorModel event = new RenderPlayerEvent.SetArmorModel(par1AbstractClientPlayer, this, 3 - par2, par3, itemstack); + MinecraftForge.EVENT_BUS.post(event); + if (event.result != -1) + { + return event.result; + } + + if (itemstack != null) + { + Item item = itemstack.getItem(); + + if (item instanceof ItemArmor) + { + ItemArmor itemarmor = (ItemArmor)item; + this.bindTexture(RenderBiped.getArmorResource(par1AbstractClientPlayer, itemstack, par2, null)); + ModelBiped modelbiped = par2 == 2 ? this.modelArmor : this.modelArmorChestplate; + modelbiped.bipedHead.showModel = par2 == 0; + modelbiped.bipedHeadwear.showModel = par2 == 0; + modelbiped.bipedBody.showModel = par2 == 1 || par2 == 2; + modelbiped.bipedRightArm.showModel = par2 == 1; + modelbiped.bipedLeftArm.showModel = par2 == 1; + modelbiped.bipedRightLeg.showModel = par2 == 2 || par2 == 3; + modelbiped.bipedLeftLeg.showModel = par2 == 2 || par2 == 3; + modelbiped = ForgeHooksClient.getArmorModel(par1AbstractClientPlayer, itemstack, par2, modelbiped); + this.setRenderPassModel(modelbiped); + modelbiped.onGround = this.mainModel.onGround; + modelbiped.isRiding = this.mainModel.isRiding; + modelbiped.isChild = this.mainModel.isChild; + + //Move outside if to allow for more then just CLOTH + int j = itemarmor.getColor(itemstack); + if (j != -1) + { + float f1 = (float)(j >> 16 & 255) / 255.0F; + float f2 = (float)(j >> 8 & 255) / 255.0F; + float f3 = (float)(j & 255) / 255.0F; + GL11.glColor3f(f1, f2, f3); + + if (itemstack.isItemEnchanted()) + { + return 31; + } + + return 16; + } + + GL11.glColor3f(1.0F, 1.0F, 1.0F); + + if (itemstack.isItemEnchanted()) + { + return 15; + } + + return 1; + } + } + + return -1; + } + + protected void func_82408_c(AbstractClientPlayer par1AbstractClientPlayer, int par2, float par3) + { + ItemStack itemstack = par1AbstractClientPlayer.inventory.armorItemInSlot(3 - par2); + + if (itemstack != null) + { + Item item = itemstack.getItem(); + + if (item instanceof ItemArmor) + { + this.bindTexture(RenderBiped.getArmorResource(par1AbstractClientPlayer, itemstack, par2, "overlay")); + GL11.glColor3f(1.0F, 1.0F, 1.0F); + } + } + } + + public void doRender(AbstractClientPlayer par1AbstractClientPlayer, double par2, double par4, double par6, float par8, float par9) + { + if (MinecraftForge.EVENT_BUS.post(new RenderPlayerEvent.Pre(par1AbstractClientPlayer, this, par9))) return; + GL11.glColor3f(1.0F, 1.0F, 1.0F); + ItemStack itemstack = par1AbstractClientPlayer.inventory.getCurrentItem(); + this.modelArmorChestplate.heldItemRight = this.modelArmor.heldItemRight = this.modelBipedMain.heldItemRight = itemstack != null ? 1 : 0; + + if (itemstack != null && par1AbstractClientPlayer.getItemInUseCount() > 0) + { + EnumAction enumaction = itemstack.getItemUseAction(); + + if (enumaction == EnumAction.block) + { + this.modelArmorChestplate.heldItemRight = this.modelArmor.heldItemRight = this.modelBipedMain.heldItemRight = 3; + } + else if (enumaction == EnumAction.bow) + { + this.modelArmorChestplate.aimedBow = this.modelArmor.aimedBow = this.modelBipedMain.aimedBow = true; + } + } + + this.modelArmorChestplate.isSneak = this.modelArmor.isSneak = this.modelBipedMain.isSneak = par1AbstractClientPlayer.isSneaking(); + double d3 = par4 - (double)par1AbstractClientPlayer.yOffset; + + if (par1AbstractClientPlayer.isSneaking() && !(par1AbstractClientPlayer instanceof EntityPlayerSP)) + { + d3 -= 0.125D; + } + + super.doRender((EntityLivingBase)par1AbstractClientPlayer, par2, d3, par6, par8, par9); + this.modelArmorChestplate.aimedBow = this.modelArmor.aimedBow = this.modelBipedMain.aimedBow = false; + this.modelArmorChestplate.isSneak = this.modelArmor.isSneak = this.modelBipedMain.isSneak = false; + this.modelArmorChestplate.heldItemRight = this.modelArmor.heldItemRight = this.modelBipedMain.heldItemRight = 0; + MinecraftForge.EVENT_BUS.post(new RenderPlayerEvent.Post(par1AbstractClientPlayer, this, par9)); + } + + protected ResourceLocation getEntityTexture(AbstractClientPlayer par1AbstractClientPlayer) + { + return par1AbstractClientPlayer.getLocationSkin(); + } + + protected void renderEquippedItems(AbstractClientPlayer par1AbstractClientPlayer, float par2) + { + RenderPlayerEvent.Specials.Pre event = new RenderPlayerEvent.Specials.Pre(par1AbstractClientPlayer, this, par2); + if (MinecraftForge.EVENT_BUS.post(event)) + { + return; + } + + GL11.glColor3f(1.0F, 1.0F, 1.0F); + super.renderEquippedItems(par1AbstractClientPlayer, par2); + super.renderArrowsStuckInEntity(par1AbstractClientPlayer, par2); + ItemStack itemstack = par1AbstractClientPlayer.inventory.armorItemInSlot(3); + + if (itemstack != null && event.renderHelmet) + { + GL11.glPushMatrix(); + this.modelBipedMain.bipedHead.postRender(0.0625F); + float f1; + + if (itemstack.getItem() instanceof ItemBlock) + { + IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemstack, EQUIPPED); + boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, itemstack, BLOCK_3D)); + + if (is3D || RenderBlocks.renderItemIn3d(Block.getBlockFromItem(itemstack.getItem()).getRenderType())) + { + f1 = 0.625F; + GL11.glTranslatef(0.0F, -0.25F, 0.0F); + GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + GL11.glScalef(f1, -f1, -f1); + } + + this.renderManager.itemRenderer.renderItem(par1AbstractClientPlayer, itemstack, 0); + } + else if (itemstack.getItem() == Items.skull) + { + f1 = 1.0625F; + GL11.glScalef(f1, -f1, -f1); + String s = ""; + + if (itemstack.hasTagCompound() && itemstack.getTagCompound().hasKey("SkullOwner", 8)) + { + s = itemstack.getTagCompound().getString("SkullOwner"); + } + + TileEntitySkullRenderer.field_147536_b.func_147530_a(-0.5F, 0.0F, -0.5F, 1, 180.0F, itemstack.getItemDamage(), s); + } + + GL11.glPopMatrix(); + } + + float f3; + + if (par1AbstractClientPlayer.getCommandSenderName().equals("deadmau5") && par1AbstractClientPlayer.getTextureSkin().isTextureUploaded()) + { + this.bindTexture(par1AbstractClientPlayer.getLocationSkin()); + + for (int j = 0; j < 2; ++j) + { + float f10 = par1AbstractClientPlayer.prevRotationYaw + (par1AbstractClientPlayer.rotationYaw - par1AbstractClientPlayer.prevRotationYaw) * par2 - (par1AbstractClientPlayer.prevRenderYawOffset + (par1AbstractClientPlayer.renderYawOffset - par1AbstractClientPlayer.prevRenderYawOffset) * par2); + float f2 = par1AbstractClientPlayer.prevRotationPitch + (par1AbstractClientPlayer.rotationPitch - par1AbstractClientPlayer.prevRotationPitch) * par2; + GL11.glPushMatrix(); + GL11.glRotatef(f10, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(f2, 1.0F, 0.0F, 0.0F); + GL11.glTranslatef(0.375F * (float)(j * 2 - 1), 0.0F, 0.0F); + GL11.glTranslatef(0.0F, -0.375F, 0.0F); + GL11.glRotatef(-f2, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(-f10, 0.0F, 1.0F, 0.0F); + f3 = 1.3333334F; + GL11.glScalef(f3, f3, f3); + this.modelBipedMain.renderEars(0.0625F); + GL11.glPopMatrix(); + } + } + + boolean flag = par1AbstractClientPlayer.getTextureCape().isTextureUploaded(); + flag = event.renderCape && flag; + float f5; + + if (flag && !par1AbstractClientPlayer.isInvisible() && !par1AbstractClientPlayer.getHideCape()) + { + this.bindTexture(par1AbstractClientPlayer.getLocationCape()); + GL11.glPushMatrix(); + GL11.glTranslatef(0.0F, 0.0F, 0.125F); + double d3 = par1AbstractClientPlayer.field_71091_bM + (par1AbstractClientPlayer.field_71094_bP - par1AbstractClientPlayer.field_71091_bM) * (double)par2 - (par1AbstractClientPlayer.prevPosX + (par1AbstractClientPlayer.posX - par1AbstractClientPlayer.prevPosX) * (double)par2); + double d4 = par1AbstractClientPlayer.field_71096_bN + (par1AbstractClientPlayer.field_71095_bQ - par1AbstractClientPlayer.field_71096_bN) * (double)par2 - (par1AbstractClientPlayer.prevPosY + (par1AbstractClientPlayer.posY - par1AbstractClientPlayer.prevPosY) * (double)par2); + double d0 = par1AbstractClientPlayer.field_71097_bO + (par1AbstractClientPlayer.field_71085_bR - par1AbstractClientPlayer.field_71097_bO) * (double)par2 - (par1AbstractClientPlayer.prevPosZ + (par1AbstractClientPlayer.posZ - par1AbstractClientPlayer.prevPosZ) * (double)par2); + f5 = par1AbstractClientPlayer.prevRenderYawOffset + (par1AbstractClientPlayer.renderYawOffset - par1AbstractClientPlayer.prevRenderYawOffset) * par2; + double d1 = (double)MathHelper.sin(f5 * (float)Math.PI / 180.0F); + double d2 = (double)(-MathHelper.cos(f5 * (float)Math.PI / 180.0F)); + float f6 = (float)d4 * 10.0F; + + if (f6 < -6.0F) + { + f6 = -6.0F; + } + + if (f6 > 32.0F) + { + f6 = 32.0F; + } + + float f7 = (float)(d3 * d1 + d0 * d2) * 100.0F; + float f8 = (float)(d3 * d2 - d0 * d1) * 100.0F; + + if (f7 < 0.0F) + { + f7 = 0.0F; + } + + float f9 = par1AbstractClientPlayer.prevCameraYaw + (par1AbstractClientPlayer.cameraYaw - par1AbstractClientPlayer.prevCameraYaw) * par2; + f6 += MathHelper.sin((par1AbstractClientPlayer.prevDistanceWalkedModified + (par1AbstractClientPlayer.distanceWalkedModified - par1AbstractClientPlayer.prevDistanceWalkedModified) * par2) * 6.0F) * 32.0F * f9; + + if (par1AbstractClientPlayer.isSneaking()) + { + f6 += 25.0F; + } + + GL11.glRotatef(6.0F + f7 / 2.0F + f6, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(f8 / 2.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(-f8 / 2.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); + this.modelBipedMain.renderCloak(0.0625F); + GL11.glPopMatrix(); + } + + ItemStack itemstack1 = par1AbstractClientPlayer.inventory.getCurrentItem(); + + if (itemstack1 != null && event.renderItem) + { + GL11.glPushMatrix(); + this.modelBipedMain.bipedRightArm.postRender(0.0625F); + GL11.glTranslatef(-0.0625F, 0.4375F, 0.0625F); + + if (par1AbstractClientPlayer.fishEntity != null) + { + itemstack1 = new ItemStack(Items.stick); + } + + EnumAction enumaction = null; + + if (par1AbstractClientPlayer.getItemInUseCount() > 0) + { + enumaction = itemstack1.getItemUseAction(); + } + + IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemstack1, EQUIPPED); + boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, itemstack1, BLOCK_3D)); + + if (is3D || itemstack1.getItem() instanceof ItemBlock && RenderBlocks.renderItemIn3d(Block.getBlockFromItem(itemstack1.getItem()).getRenderType())) + { + f3 = 0.5F; + GL11.glTranslatef(0.0F, 0.1875F, -0.3125F); + f3 *= 0.75F; + GL11.glRotatef(20.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); + GL11.glScalef(-f3, -f3, f3); + } + else if (itemstack1.getItem() == Items.bow) + { + f3 = 0.625F; + GL11.glTranslatef(0.0F, 0.125F, 0.3125F); + GL11.glRotatef(-20.0F, 0.0F, 1.0F, 0.0F); + GL11.glScalef(f3, -f3, f3); + GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); + } + else if (itemstack1.getItem().isFull3D()) + { + f3 = 0.625F; + + if (itemstack1.getItem().shouldRotateAroundWhenRendering()) + { + GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); + GL11.glTranslatef(0.0F, -0.125F, 0.0F); + } + + if (par1AbstractClientPlayer.getItemInUseCount() > 0 && enumaction == EnumAction.block) + { + GL11.glTranslatef(0.05F, 0.0F, -0.1F); + GL11.glRotatef(-50.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-10.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(-60.0F, 0.0F, 0.0F, 1.0F); + } + + GL11.glTranslatef(0.0F, 0.1875F, 0.0F); + GL11.glScalef(f3, -f3, f3); + GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); + } + else + { + f3 = 0.375F; + GL11.glTranslatef(0.25F, 0.1875F, -0.1875F); + GL11.glScalef(f3, f3, f3); + GL11.glRotatef(60.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(20.0F, 0.0F, 0.0F, 1.0F); + } + + float f4; + int k; + float f12; + + if (itemstack1.getItem().requiresMultipleRenderPasses()) + { + for (k = 0; k < itemstack1.getItem().getRenderPasses(itemstack1.getItemDamage()); ++k) + { + int i = itemstack1.getItem().getColorFromItemStack(itemstack1, k); + f12 = (float)(i >> 16 & 255) / 255.0F; + f4 = (float)(i >> 8 & 255) / 255.0F; + f5 = (float)(i & 255) / 255.0F; + GL11.glColor4f(f12, f4, f5, 1.0F); + this.renderManager.itemRenderer.renderItem(par1AbstractClientPlayer, itemstack1, k); + } + } + else + { + k = itemstack1.getItem().getColorFromItemStack(itemstack1, 0); + float f11 = (float)(k >> 16 & 255) / 255.0F; + f12 = (float)(k >> 8 & 255) / 255.0F; + f4 = (float)(k & 255) / 255.0F; + GL11.glColor4f(f11, f12, f4, 1.0F); + this.renderManager.itemRenderer.renderItem(par1AbstractClientPlayer, itemstack1, 0); + } + + GL11.glPopMatrix(); + } + MinecraftForge.EVENT_BUS.post(new RenderPlayerEvent.Specials.Post(par1AbstractClientPlayer, this, par2)); + } + + protected void preRenderCallback(AbstractClientPlayer par1AbstractClientPlayer, float par2) + { + float f1 = 0.9375F; + GL11.glScalef(f1, f1, f1); + } + + protected void func_96449_a(AbstractClientPlayer par1AbstractClientPlayer, double par2, double par4, double par6, String par8Str, float par9, double par10) + { + if (par10 < 100.0D) + { + Scoreboard scoreboard = par1AbstractClientPlayer.getWorldScoreboard(); + ScoreObjective scoreobjective = scoreboard.func_96539_a(2); + + if (scoreobjective != null) + { + Score score = scoreboard.func_96529_a(par1AbstractClientPlayer.getCommandSenderName(), scoreobjective); + + if (par1AbstractClientPlayer.isPlayerSleeping()) + { + this.func_147906_a(par1AbstractClientPlayer, score.getScorePoints() + " " + scoreobjective.getDisplayName(), par2, par4 - 1.5D, par6, 64); + } + else + { + this.func_147906_a(par1AbstractClientPlayer, score.getScorePoints() + " " + scoreobjective.getDisplayName(), par2, par4, par6, 64); + } + + par4 += (double)((float)this.getFontRendererFromRenderManager().FONT_HEIGHT * 1.15F * par9); + } + } + + super.func_96449_a(par1AbstractClientPlayer, par2, par4, par6, par8Str, par9, par10); + } + + public void renderFirstPersonArm(EntityPlayer par1EntityPlayer) + { + float f = 1.0F; + GL11.glColor3f(f, f, f); + this.modelBipedMain.onGround = 0.0F; + this.modelBipedMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, par1EntityPlayer); + this.modelBipedMain.bipedRightArm.render(0.0625F); + } + + protected void renderLivingAt(AbstractClientPlayer par1AbstractClientPlayer, double par2, double par4, double par6) + { + if (par1AbstractClientPlayer.isEntityAlive() && par1AbstractClientPlayer.isPlayerSleeping()) + { + super.renderLivingAt(par1AbstractClientPlayer, par2 + (double)par1AbstractClientPlayer.field_71079_bU, par4 + (double)par1AbstractClientPlayer.field_71082_cx, par6 + (double)par1AbstractClientPlayer.field_71089_bV); + } + else + { + super.renderLivingAt(par1AbstractClientPlayer, par2, par4, par6); + } + } + + protected void rotateCorpse(AbstractClientPlayer par1AbstractClientPlayer, float par2, float par3, float par4) + { + if (par1AbstractClientPlayer.isEntityAlive() && par1AbstractClientPlayer.isPlayerSleeping()) + { + GL11.glRotatef(par1AbstractClientPlayer.getBedOrientationInDegrees(), 0.0F, 1.0F, 0.0F); + GL11.glRotatef(this.getDeathMaxRotation(par1AbstractClientPlayer), 0.0F, 0.0F, 1.0F); + GL11.glRotatef(270.0F, 0.0F, 1.0F, 0.0F); + } + else + { + super.rotateCorpse(par1AbstractClientPlayer, par2, par3, par4); + } + } + + protected void func_96449_a(EntityLivingBase par1EntityLivingBase, double par2, double par4, double par6, String par8Str, float par9, double par10) + { + this.func_96449_a((AbstractClientPlayer)par1EntityLivingBase, par2, par4, par6, par8Str, par9, par10); + } + + protected void preRenderCallback(EntityLivingBase par1EntityLivingBase, float par2) + { + this.preRenderCallback((AbstractClientPlayer)par1EntityLivingBase, par2); + } + + protected void func_82408_c(EntityLivingBase par1EntityLivingBase, int par2, float par3) + { + this.func_82408_c((AbstractClientPlayer)par1EntityLivingBase, par2, par3); + } + + protected int shouldRenderPass(EntityLivingBase par1EntityLivingBase, int par2, float par3) + { + return this.shouldRenderPass((AbstractClientPlayer)par1EntityLivingBase, par2, par3); + } + + protected void renderEquippedItems(EntityLivingBase par1EntityLivingBase, float par2) + { + this.renderEquippedItems((AbstractClientPlayer)par1EntityLivingBase, par2); + } + + protected void rotateCorpse(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4) + { + this.rotateCorpse((AbstractClientPlayer)par1EntityLivingBase, par2, par3, par4); + } + + protected void renderLivingAt(EntityLivingBase par1EntityLivingBase, double par2, double par4, double par6) + { + this.renderLivingAt((AbstractClientPlayer)par1EntityLivingBase, par2, par4, par6); + } + + public void doRender(EntityLivingBase par1EntityLivingBase, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((AbstractClientPlayer)par1EntityLivingBase, par2, par4, par6, par8, par9); + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((AbstractClientPlayer)par1Entity); + } + + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((AbstractClientPlayer)par1Entity, par2, par4, par6, par8, par9); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderSheep.java b/src/main/java/net/minecraft/client/renderer/entity/RenderSheep.java new file mode 100644 index 0000000..009e766 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderSheep.java @@ -0,0 +1,54 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelBase; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.passive.EntitySheep; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class RenderSheep extends RenderLiving +{ + private static final ResourceLocation sheepTextures = new ResourceLocation("textures/entity/sheep/sheep_fur.png"); + private static final ResourceLocation shearedSheepTextures = new ResourceLocation("textures/entity/sheep/sheep.png"); + private static final String __OBFID = "CL_00001021"; + + public RenderSheep(ModelBase par1ModelBase, ModelBase par2ModelBase, float par3) + { + super(par1ModelBase, par3); + this.setRenderPassModel(par2ModelBase); + } + + protected int shouldRenderPass(EntitySheep par1EntitySheep, int par2, float par3) + { + if (par2 == 0 && !par1EntitySheep.getSheared()) + { + this.bindTexture(sheepTextures); + int j = par1EntitySheep.getFleeceColor(); + GL11.glColor3f(EntitySheep.fleeceColorTable[j][0], EntitySheep.fleeceColorTable[j][1], EntitySheep.fleeceColorTable[j][2]); + return 1; + } + else + { + return -1; + } + } + + protected ResourceLocation getEntityTexture(EntitySheep par1EntitySheep) + { + return shearedSheepTextures; + } + + protected int shouldRenderPass(EntityLivingBase par1EntityLivingBase, int par2, float par3) + { + return this.shouldRenderPass((EntitySheep)par1EntityLivingBase, par2, par3); + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntitySheep)par1Entity); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderSilverfish.java b/src/main/java/net/minecraft/client/renderer/entity/RenderSilverfish.java new file mode 100644 index 0000000..b592998 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderSilverfish.java @@ -0,0 +1,72 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelSilverfish; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.monster.EntitySilverfish; +import net.minecraft.util.ResourceLocation; + +@SideOnly(Side.CLIENT) +public class RenderSilverfish extends RenderLiving +{ + private static final ResourceLocation silverfishTextures = new ResourceLocation("textures/entity/silverfish.png"); + private static final String __OBFID = "CL_00001022"; + + public RenderSilverfish() + { + super(new ModelSilverfish(), 0.3F); + } + + protected float getDeathMaxRotation(EntitySilverfish par1EntitySilverfish) + { + return 180.0F; + } + + public void doRender(EntitySilverfish par1EntitySilverfish, double par2, double par4, double par6, float par8, float par9) + { + super.doRender((EntityLiving)par1EntitySilverfish, par2, par4, par6, par8, par9); + } + + protected ResourceLocation getEntityTexture(EntitySilverfish par1EntitySilverfish) + { + return silverfishTextures; + } + + protected int shouldRenderPass(EntitySilverfish par1EntitySilverfish, int par2, float par3) + { + return -1; + } + + public void doRender(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntitySilverfish)par1EntityLiving, par2, par4, par6, par8, par9); + } + + protected float getDeathMaxRotation(EntityLivingBase par1EntityLivingBase) + { + return this.getDeathMaxRotation((EntitySilverfish)par1EntityLivingBase); + } + + protected int shouldRenderPass(EntityLivingBase par1EntityLivingBase, int par2, float par3) + { + return this.shouldRenderPass((EntitySilverfish)par1EntityLivingBase, par2, par3); + } + + public void doRender(EntityLivingBase par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntitySilverfish)par1Entity, par2, par4, par6, par8, par9); + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntitySilverfish)par1Entity); + } + + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntitySilverfish)par1Entity, par2, par4, par6, par8, par9); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderSkeleton.java b/src/main/java/net/minecraft/client/renderer/entity/RenderSkeleton.java new file mode 100644 index 0000000..1b6a6e6 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderSkeleton.java @@ -0,0 +1,57 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelSkeleton; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.monster.EntitySkeleton; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class RenderSkeleton extends RenderBiped +{ + private static final ResourceLocation skeletonTextures = new ResourceLocation("textures/entity/skeleton/skeleton.png"); + private static final ResourceLocation witherSkeletonTextures = new ResourceLocation("textures/entity/skeleton/wither_skeleton.png"); + private static final String __OBFID = "CL_00001023"; + + public RenderSkeleton() + { + super(new ModelSkeleton(), 0.5F); + } + + protected void preRenderCallback(EntitySkeleton par1EntitySkeleton, float par2) + { + if (par1EntitySkeleton.getSkeletonType() == 1) + { + GL11.glScalef(1.2F, 1.2F, 1.2F); + } + } + + protected void func_82422_c() + { + GL11.glTranslatef(0.09375F, 0.1875F, 0.0F); + } + + protected ResourceLocation getEntityTexture(EntitySkeleton par1EntitySkeleton) + { + return par1EntitySkeleton.getSkeletonType() == 1 ? witherSkeletonTextures : skeletonTextures; + } + + protected ResourceLocation getEntityTexture(EntityLiving par1EntityLiving) + { + return this.getEntityTexture((EntitySkeleton)par1EntityLiving); + } + + protected void preRenderCallback(EntityLivingBase par1EntityLivingBase, float par2) + { + this.preRenderCallback((EntitySkeleton)par1EntityLivingBase, par2); + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntitySkeleton)par1Entity); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderSlime.java b/src/main/java/net/minecraft/client/renderer/entity/RenderSlime.java new file mode 100644 index 0000000..210048a --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderSlime.java @@ -0,0 +1,78 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelBase; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.monster.EntitySlime; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class RenderSlime extends RenderLiving +{ + private static final ResourceLocation slimeTextures = new ResourceLocation("textures/entity/slime/slime.png"); + private ModelBase scaleAmount; + private static final String __OBFID = "CL_00001024"; + + public RenderSlime(ModelBase par1ModelBase, ModelBase par2ModelBase, float par3) + { + super(par1ModelBase, par3); + this.scaleAmount = par2ModelBase; + } + + protected int shouldRenderPass(EntitySlime par1EntitySlime, int par2, float par3) + { + if (par1EntitySlime.isInvisible()) + { + return 0; + } + else if (par2 == 0) + { + this.setRenderPassModel(this.scaleAmount); + GL11.glEnable(GL11.GL_NORMALIZE); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + return 1; + } + else + { + if (par2 == 1) + { + GL11.glDisable(GL11.GL_BLEND); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + } + + return -1; + } + } + + protected void preRenderCallback(EntitySlime par1EntitySlime, float par2) + { + float f1 = (float)par1EntitySlime.getSlimeSize(); + float f2 = (par1EntitySlime.prevSquishFactor + (par1EntitySlime.squishFactor - par1EntitySlime.prevSquishFactor) * par2) / (f1 * 0.5F + 1.0F); + float f3 = 1.0F / (f2 + 1.0F); + GL11.glScalef(f3 * f1, 1.0F / f3 * f1, f3 * f1); + } + + protected ResourceLocation getEntityTexture(EntitySlime par1EntitySlime) + { + return slimeTextures; + } + + protected void preRenderCallback(EntityLivingBase par1EntityLivingBase, float par2) + { + this.preRenderCallback((EntitySlime)par1EntityLivingBase, par2); + } + + protected int shouldRenderPass(EntityLivingBase par1EntityLivingBase, int par2, float par3) + { + return this.shouldRenderPass((EntitySlime)par1EntityLivingBase, par2, par3); + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntitySlime)par1Entity); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderSnowMan.java b/src/main/java/net/minecraft/client/renderer/entity/RenderSnowMan.java new file mode 100644 index 0000000..c8c6d72 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderSnowMan.java @@ -0,0 +1,75 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.client.model.ModelSnowMan; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.monster.EntitySnowman; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import net.minecraftforge.client.IItemRenderer; +import static net.minecraftforge.client.IItemRenderer.ItemRenderType.*; +import static net.minecraftforge.client.IItemRenderer.ItemRendererHelper.*; +import net.minecraftforge.client.MinecraftForgeClient; + +@SideOnly(Side.CLIENT) +public class RenderSnowMan extends RenderLiving +{ + private static final ResourceLocation snowManTextures = new ResourceLocation("textures/entity/snowman.png"); + private ModelSnowMan snowmanModel; + private static final String __OBFID = "CL_00001025"; + + public RenderSnowMan() + { + super(new ModelSnowMan(), 0.5F); + this.snowmanModel = (ModelSnowMan)super.mainModel; + this.setRenderPassModel(this.snowmanModel); + } + + protected void renderEquippedItems(EntitySnowman par1EntitySnowman, float par2) + { + super.renderEquippedItems(par1EntitySnowman, par2); + ItemStack itemstack = new ItemStack(Blocks.pumpkin, 1); + + if (itemstack.getItem() instanceof ItemBlock) + { + GL11.glPushMatrix(); + this.snowmanModel.head.postRender(0.0625F); + + IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemstack, EQUIPPED); + boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, itemstack, BLOCK_3D)); + + if (is3D || RenderBlocks.renderItemIn3d(Block.getBlockFromItem(itemstack.getItem()).getRenderType())) + { + float f1 = 0.625F; + GL11.glTranslatef(0.0F, -0.34375F, 0.0F); + GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + GL11.glScalef(f1, -f1, f1); + } + + this.renderManager.itemRenderer.renderItem(par1EntitySnowman, itemstack, 0); + GL11.glPopMatrix(); + } + } + + protected ResourceLocation getEntityTexture(EntitySnowman par1EntitySnowman) + { + return snowManTextures; + } + + protected void renderEquippedItems(EntityLivingBase par1EntityLivingBase, float par2) + { + this.renderEquippedItems((EntitySnowman)par1EntityLivingBase, par2); + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntitySnowman)par1Entity); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderSnowball.java b/src/main/java/net/minecraft/client/renderer/entity/RenderSnowball.java new file mode 100644 index 0000000..fda3dd5 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderSnowball.java @@ -0,0 +1,91 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.entity.Entity; +import net.minecraft.entity.projectile.EntityPotion; +import net.minecraft.item.Item; +import net.minecraft.item.ItemPotion; +import net.minecraft.potion.PotionHelper; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +@SideOnly(Side.CLIENT) +public class RenderSnowball extends Render +{ + private Item field_94151_a; + private int field_94150_f; + private static final String __OBFID = "CL_00001008"; + + public RenderSnowball(Item par1Item, int par2) + { + this.field_94151_a = par1Item; + this.field_94150_f = par2; + } + + public RenderSnowball(Item par1Item) + { + this(par1Item, 0); + } + + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) + { + IIcon iicon = this.field_94151_a.getIconFromDamage(this.field_94150_f); + + if (iicon != null) + { + GL11.glPushMatrix(); + GL11.glTranslatef((float)par2, (float)par4, (float)par6); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glScalef(0.5F, 0.5F, 0.5F); + this.bindEntityTexture(par1Entity); + Tessellator tessellator = Tessellator.instance; + + if (iicon == ItemPotion.func_94589_d("bottle_splash")) + { + int i = PotionHelper.func_77915_a(((EntityPotion)par1Entity).getPotionDamage(), false); + float f2 = (float)(i >> 16 & 255) / 255.0F; + float f3 = (float)(i >> 8 & 255) / 255.0F; + float f4 = (float)(i & 255) / 255.0F; + GL11.glColor3f(f2, f3, f4); + GL11.glPushMatrix(); + this.func_77026_a(tessellator, ItemPotion.func_94589_d("overlay")); + GL11.glPopMatrix(); + GL11.glColor3f(1.0F, 1.0F, 1.0F); + } + + this.func_77026_a(tessellator, iicon); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return TextureMap.locationItemsTexture; + } + + private void func_77026_a(Tessellator par1Tessellator, IIcon par2Icon) + { + float f = par2Icon.getMinU(); + float f1 = par2Icon.getMaxU(); + float f2 = par2Icon.getMinV(); + float f3 = par2Icon.getMaxV(); + float f4 = 1.0F; + float f5 = 0.5F; + float f6 = 0.25F; + GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F); + par1Tessellator.startDrawingQuads(); + par1Tessellator.setNormal(0.0F, 1.0F, 0.0F); + par1Tessellator.addVertexWithUV((double)(0.0F - f5), (double)(0.0F - f6), 0.0D, (double)f, (double)f3); + par1Tessellator.addVertexWithUV((double)(f4 - f5), (double)(0.0F - f6), 0.0D, (double)f1, (double)f3); + par1Tessellator.addVertexWithUV((double)(f4 - f5), (double)(f4 - f6), 0.0D, (double)f1, (double)f2); + par1Tessellator.addVertexWithUV((double)(0.0F - f5), (double)(f4 - f6), 0.0D, (double)f, (double)f2); + par1Tessellator.draw(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderSpider.java b/src/main/java/net/minecraft/client/renderer/entity/RenderSpider.java new file mode 100644 index 0000000..a03ea12 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderSpider.java @@ -0,0 +1,81 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelSpider; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.monster.EntitySpider; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class RenderSpider extends RenderLiving +{ + private static final ResourceLocation spiderEyesTextures = new ResourceLocation("textures/entity/spider_eyes.png"); + private static final ResourceLocation spiderTextures = new ResourceLocation("textures/entity/spider/spider.png"); + private static final String __OBFID = "CL_00001027"; + + public RenderSpider() + { + super(new ModelSpider(), 1.0F); + this.setRenderPassModel(new ModelSpider()); + } + + protected float getDeathMaxRotation(EntitySpider par1EntitySpider) + { + return 180.0F; + } + + protected int shouldRenderPass(EntitySpider par1EntitySpider, int par2, float par3) + { + if (par2 != 0) + { + return -1; + } + else + { + this.bindTexture(spiderEyesTextures); + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); + + if (par1EntitySpider.isInvisible()) + { + GL11.glDepthMask(false); + } + else + { + GL11.glDepthMask(true); + } + + char c0 = 61680; + int j = c0 % 65536; + int k = c0 / 65536; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j / 1.0F, (float)k / 1.0F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + return 1; + } + } + + protected ResourceLocation getEntityTexture(EntitySpider par1EntitySpider) + { + return spiderTextures; + } + + protected float getDeathMaxRotation(EntityLivingBase par1EntityLivingBase) + { + return this.getDeathMaxRotation((EntitySpider)par1EntityLivingBase); + } + + protected int shouldRenderPass(EntityLivingBase par1EntityLivingBase, int par2, float par3) + { + return this.shouldRenderPass((EntitySpider)par1EntityLivingBase, par2, par3); + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntitySpider)par1Entity); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderSquid.java b/src/main/java/net/minecraft/client/renderer/entity/RenderSquid.java new file mode 100644 index 0000000..5915e59 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderSquid.java @@ -0,0 +1,79 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelBase; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.passive.EntitySquid; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class RenderSquid extends RenderLiving +{ + private static final ResourceLocation squidTextures = new ResourceLocation("textures/entity/squid.png"); + private static final String __OBFID = "CL_00001028"; + + public RenderSquid(ModelBase par1ModelBase, float par2) + { + super(par1ModelBase, par2); + } + + public void doRender(EntitySquid par1EntitySquid, double par2, double par4, double par6, float par8, float par9) + { + super.doRender((EntityLiving)par1EntitySquid, par2, par4, par6, par8, par9); + } + + protected ResourceLocation getEntityTexture(EntitySquid par1EntitySquid) + { + return squidTextures; + } + + protected void rotateCorpse(EntitySquid par1EntitySquid, float par2, float par3, float par4) + { + float f3 = par1EntitySquid.prevSquidPitch + (par1EntitySquid.squidPitch - par1EntitySquid.prevSquidPitch) * par4; + float f4 = par1EntitySquid.prevSquidYaw + (par1EntitySquid.squidYaw - par1EntitySquid.prevSquidYaw) * par4; + GL11.glTranslatef(0.0F, 0.5F, 0.0F); + GL11.glRotatef(180.0F - par3, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(f3, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(f4, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(0.0F, -1.2F, 0.0F); + } + + protected float handleRotationFloat(EntitySquid par1EntitySquid, float par2) + { + return par1EntitySquid.lastTentacleAngle + (par1EntitySquid.tentacleAngle - par1EntitySquid.lastTentacleAngle) * par2; + } + + public void doRender(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntitySquid)par1EntityLiving, par2, par4, par6, par8, par9); + } + + protected float handleRotationFloat(EntityLivingBase par1EntityLivingBase, float par2) + { + return this.handleRotationFloat((EntitySquid)par1EntityLivingBase, par2); + } + + protected void rotateCorpse(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4) + { + this.rotateCorpse((EntitySquid)par1EntityLivingBase, par2, par3, par4); + } + + public void doRender(EntityLivingBase par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntitySquid)par1Entity, par2, par4, par6, par8, par9); + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntitySquid)par1Entity); + } + + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntitySquid)par1Entity, par2, par4, par6, par8, par9); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderTNTPrimed.java b/src/main/java/net/minecraft/client/renderer/entity/RenderTNTPrimed.java new file mode 100644 index 0000000..1aa2791 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderTNTPrimed.java @@ -0,0 +1,85 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityTNTPrimed; +import net.minecraft.init.Blocks; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class RenderTNTPrimed extends Render +{ + private RenderBlocks blockRenderer = new RenderBlocks(); + private static final String __OBFID = "CL_00001030"; + + public RenderTNTPrimed() + { + this.shadowSize = 0.5F; + } + + public void doRender(EntityTNTPrimed par1EntityTNTPrimed, double par2, double par4, double par6, float par8, float par9) + { + GL11.glPushMatrix(); + GL11.glTranslatef((float)par2, (float)par4, (float)par6); + float f2; + + if ((float)par1EntityTNTPrimed.fuse - par9 + 1.0F < 10.0F) + { + f2 = 1.0F - ((float)par1EntityTNTPrimed.fuse - par9 + 1.0F) / 10.0F; + + if (f2 < 0.0F) + { + f2 = 0.0F; + } + + if (f2 > 1.0F) + { + f2 = 1.0F; + } + + f2 *= f2; + f2 *= f2; + float f3 = 1.0F + f2 * 0.3F; + GL11.glScalef(f3, f3, f3); + } + + f2 = (1.0F - ((float)par1EntityTNTPrimed.fuse - par9 + 1.0F) / 100.0F) * 0.8F; + this.bindEntityTexture(par1EntityTNTPrimed); + this.blockRenderer.renderBlockAsItem(Blocks.tnt, 0, par1EntityTNTPrimed.getBrightness(par9)); + + if (par1EntityTNTPrimed.fuse / 5 % 2 == 0) + { + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_DST_ALPHA); + GL11.glColor4f(1.0F, 1.0F, 1.0F, f2); + this.blockRenderer.renderBlockAsItem(Blocks.tnt, 0, 1.0F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + + GL11.glPopMatrix(); + } + + protected ResourceLocation getEntityTexture(EntityTNTPrimed par1EntityTNTPrimed) + { + return TextureMap.locationBlocksTexture; + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntityTNTPrimed)par1Entity); + } + + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityTNTPrimed)par1Entity, par2, par4, par6, par8, par9); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderTntMinecart.java b/src/main/java/net/minecraft/client/renderer/entity/RenderTntMinecart.java new file mode 100644 index 0000000..a059b60 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderTntMinecart.java @@ -0,0 +1,63 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.entity.item.EntityMinecart; +import net.minecraft.entity.item.EntityMinecartTNT; +import net.minecraft.init.Blocks; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class RenderTntMinecart extends RenderMinecart +{ + private static final String __OBFID = "CL_00001029"; + + protected void func_147910_a(EntityMinecartTNT p_147912_1_, float p_147912_2_, Block p_147912_3_, int p_147912_4_) + { + int j = p_147912_1_.func_94104_d(); + + if (j > -1 && (float)j - p_147912_2_ + 1.0F < 10.0F) + { + float f1 = 1.0F - ((float)j - p_147912_2_ + 1.0F) / 10.0F; + + if (f1 < 0.0F) + { + f1 = 0.0F; + } + + if (f1 > 1.0F) + { + f1 = 1.0F; + } + + f1 *= f1; + f1 *= f1; + float f2 = 1.0F + f1 * 0.3F; + GL11.glScalef(f2, f2, f2); + } + + super.func_147910_a(p_147912_1_, p_147912_2_, p_147912_3_, p_147912_4_); + + if (j > -1 && j / 5 % 2 == 0) + { + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_DST_ALPHA); + GL11.glColor4f(1.0F, 1.0F, 1.0F, (1.0F - ((float)j - p_147912_2_ + 1.0F) / 100.0F) * 0.8F); + GL11.glPushMatrix(); + this.field_94145_f.renderBlockAsItem(Blocks.tnt, 0, 1.0F); + GL11.glPopMatrix(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + } + + protected void func_147910_a(EntityMinecart p_147910_1_, float p_147910_2_, Block p_147910_3_, int p_147910_4_) + { + this.func_147910_a((EntityMinecartTNT)p_147910_1_, p_147910_2_, p_147910_3_, p_147910_4_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderVillager.java b/src/main/java/net/minecraft/client/renderer/entity/RenderVillager.java new file mode 100644 index 0000000..7ca212d --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderVillager.java @@ -0,0 +1,117 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.common.registry.VillagerRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelVillager; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.passive.EntityVillager; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class RenderVillager extends RenderLiving +{ + private static final ResourceLocation villagerTextures = new ResourceLocation("textures/entity/villager/villager.png"); + private static final ResourceLocation farmerVillagerTextures = new ResourceLocation("textures/entity/villager/farmer.png"); + private static final ResourceLocation librarianVillagerTextures = new ResourceLocation("textures/entity/villager/librarian.png"); + private static final ResourceLocation priestVillagerTextures = new ResourceLocation("textures/entity/villager/priest.png"); + private static final ResourceLocation smithVillagerTextures = new ResourceLocation("textures/entity/villager/smith.png"); + private static final ResourceLocation butcherVillagerTextures = new ResourceLocation("textures/entity/villager/butcher.png"); + protected ModelVillager villagerModel; + private static final String __OBFID = "CL_00001032"; + + public RenderVillager() + { + super(new ModelVillager(0.0F), 0.5F); + this.villagerModel = (ModelVillager)this.mainModel; + } + + protected int shouldRenderPass(EntityVillager par1EntityVillager, int par2, float par3) + { + return -1; + } + + public void doRender(EntityVillager par1EntityVillager, double par2, double par4, double par6, float par8, float par9) + { + super.doRender((EntityLiving)par1EntityVillager, par2, par4, par6, par8, par9); + } + + protected ResourceLocation getEntityTexture(EntityVillager par1EntityVillager) + { + switch (par1EntityVillager.getProfession()) + { + case 0: + return farmerVillagerTextures; + case 1: + return librarianVillagerTextures; + case 2: + return priestVillagerTextures; + case 3: + return smithVillagerTextures; + case 4: + return butcherVillagerTextures; + default: + return VillagerRegistry.getVillagerSkin(par1EntityVillager.getProfession(), villagerTextures); + } + } + + protected void renderEquippedItems(EntityVillager par1EntityVillager, float par2) + { + super.renderEquippedItems(par1EntityVillager, par2); + } + + protected void preRenderCallback(EntityVillager par1EntityVillager, float par2) + { + float f1 = 0.9375F; + + if (par1EntityVillager.getGrowingAge() < 0) + { + f1 = (float)((double)f1 * 0.5D); + this.shadowSize = 0.25F; + } + else + { + this.shadowSize = 0.5F; + } + + GL11.glScalef(f1, f1, f1); + } + + public void doRender(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityVillager)par1EntityLiving, par2, par4, par6, par8, par9); + } + + protected void preRenderCallback(EntityLivingBase par1EntityLivingBase, float par2) + { + this.preRenderCallback((EntityVillager)par1EntityLivingBase, par2); + } + + protected int shouldRenderPass(EntityLivingBase par1EntityLivingBase, int par2, float par3) + { + return this.shouldRenderPass((EntityVillager)par1EntityLivingBase, par2, par3); + } + + protected void renderEquippedItems(EntityLivingBase par1EntityLivingBase, float par2) + { + this.renderEquippedItems((EntityVillager)par1EntityLivingBase, par2); + } + + public void doRender(EntityLivingBase par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityVillager)par1Entity, par2, par4, par6, par8, par9); + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntityVillager)par1Entity); + } + + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityVillager)par1Entity, par2, par4, par6, par8, par9); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderWitch.java b/src/main/java/net/minecraft/client/renderer/entity/RenderWitch.java new file mode 100644 index 0000000..6cfa58e --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderWitch.java @@ -0,0 +1,161 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.client.model.ModelWitch; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.monster.EntityWitch; +import net.minecraft.init.Items; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class RenderWitch extends RenderLiving +{ + private static final ResourceLocation witchTextures = new ResourceLocation("textures/entity/witch.png"); + private final ModelWitch witchModel; + private static final String __OBFID = "CL_00001033"; + + public RenderWitch() + { + super(new ModelWitch(0.0F), 0.5F); + this.witchModel = (ModelWitch)this.mainModel; + } + + public void doRender(EntityWitch par1EntityWitch, double par2, double par4, double par6, float par8, float par9) + { + ItemStack itemstack = par1EntityWitch.getHeldItem(); + this.witchModel.field_82900_g = itemstack != null; + super.doRender((EntityLiving)par1EntityWitch, par2, par4, par6, par8, par9); + } + + protected ResourceLocation getEntityTexture(EntityWitch par1EntityWitch) + { + return witchTextures; + } + + protected void renderEquippedItems(EntityWitch par1EntityWitch, float par2) + { + GL11.glColor3f(1.0F, 1.0F, 1.0F); + super.renderEquippedItems(par1EntityWitch, par2); + ItemStack itemstack = par1EntityWitch.getHeldItem(); + + if (itemstack != null) + { + GL11.glPushMatrix(); + float f1; + + if (this.mainModel.isChild) + { + f1 = 0.5F; + GL11.glTranslatef(0.0F, 0.625F, 0.0F); + GL11.glRotatef(-20.0F, -1.0F, 0.0F, 0.0F); + GL11.glScalef(f1, f1, f1); + } + + this.witchModel.villagerNose.postRender(0.0625F); + GL11.glTranslatef(-0.0625F, 0.53125F, 0.21875F); + + if (itemstack.getItem() instanceof ItemBlock && RenderBlocks.renderItemIn3d(Block.getBlockFromItem(itemstack.getItem()).getRenderType())) + { + f1 = 0.5F; + GL11.glTranslatef(0.0F, 0.1875F, -0.3125F); + f1 *= 0.75F; + GL11.glRotatef(20.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); + GL11.glScalef(f1, -f1, f1); + } + else if (itemstack.getItem() == Items.bow) + { + f1 = 0.625F; + GL11.glTranslatef(0.0F, 0.125F, 0.3125F); + GL11.glRotatef(-20.0F, 0.0F, 1.0F, 0.0F); + GL11.glScalef(f1, -f1, f1); + GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); + } + else if (itemstack.getItem().isFull3D()) + { + f1 = 0.625F; + + if (itemstack.getItem().shouldRotateAroundWhenRendering()) + { + GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); + GL11.glTranslatef(0.0F, -0.125F, 0.0F); + } + + this.func_82410_b(); + GL11.glScalef(f1, -f1, f1); + GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); + } + else + { + f1 = 0.375F; + GL11.glTranslatef(0.25F, 0.1875F, -0.1875F); + GL11.glScalef(f1, f1, f1); + GL11.glRotatef(60.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(20.0F, 0.0F, 0.0F, 1.0F); + } + + GL11.glRotatef(-15.0F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(40.0F, 0.0F, 0.0F, 1.0F); + this.renderManager.itemRenderer.renderItem(par1EntityWitch, itemstack, 0); + + if (itemstack.getItem().requiresMultipleRenderPasses()) + { + this.renderManager.itemRenderer.renderItem(par1EntityWitch, itemstack, 1); + } + + GL11.glPopMatrix(); + } + } + + protected void func_82410_b() + { + GL11.glTranslatef(0.0F, 0.1875F, 0.0F); + } + + protected void preRenderCallback(EntityWitch par1EntityWitch, float par2) + { + float f1 = 0.9375F; + GL11.glScalef(f1, f1, f1); + } + + public void doRender(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityWitch)par1EntityLiving, par2, par4, par6, par8, par9); + } + + protected void preRenderCallback(EntityLivingBase par1EntityLivingBase, float par2) + { + this.preRenderCallback((EntityWitch)par1EntityLivingBase, par2); + } + + protected void renderEquippedItems(EntityLivingBase par1EntityLivingBase, float par2) + { + this.renderEquippedItems((EntityWitch)par1EntityLivingBase, par2); + } + + public void doRender(EntityLivingBase par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityWitch)par1Entity, par2, par4, par6, par8, par9); + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntityWitch)par1Entity); + } + + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityWitch)par1Entity, par2, par4, par6, par8, par9); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderWither.java b/src/main/java/net/minecraft/client/renderer/entity/RenderWither.java new file mode 100644 index 0000000..2835bcf --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderWither.java @@ -0,0 +1,150 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelWither; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.boss.BossStatus; +import net.minecraft.entity.boss.EntityWither; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class RenderWither extends RenderLiving +{ + private static final ResourceLocation invulnerableWitherTextures = new ResourceLocation("textures/entity/wither/wither_invulnerable.png"); + private static final ResourceLocation witherTextures = new ResourceLocation("textures/entity/wither/wither.png"); + private int field_82419_a; + private static final String __OBFID = "CL_00001034"; + + public RenderWither() + { + super(new ModelWither(), 1.0F); + this.field_82419_a = ((ModelWither)this.mainModel).func_82903_a(); + } + + public void doRender(EntityWither par1EntityWither, double par2, double par4, double par6, float par8, float par9) + { + BossStatus.setBossStatus(par1EntityWither, true); + int i = ((ModelWither)this.mainModel).func_82903_a(); + + if (i != this.field_82419_a) + { + this.field_82419_a = i; + this.mainModel = new ModelWither(); + } + + super.doRender((EntityLiving)par1EntityWither, par2, par4, par6, par8, par9); + } + + protected ResourceLocation getEntityTexture(EntityWither par1EntityWither) + { + int i = par1EntityWither.func_82212_n(); + return i > 0 && (i > 80 || i / 5 % 2 != 1) ? invulnerableWitherTextures : witherTextures; + } + + protected void preRenderCallback(EntityWither par1EntityWither, float par2) + { + int i = par1EntityWither.func_82212_n(); + + if (i > 0) + { + float f1 = 2.0F - ((float)i - par2) / 220.0F * 0.5F; + GL11.glScalef(f1, f1, f1); + } + else + { + GL11.glScalef(2.0F, 2.0F, 2.0F); + } + } + + protected int shouldRenderPass(EntityWither par1EntityWither, int par2, float par3) + { + if (par1EntityWither.isArmored()) + { + if (par1EntityWither.isInvisible()) + { + GL11.glDepthMask(false); + } + else + { + GL11.glDepthMask(true); + } + + if (par2 == 1) + { + float f1 = (float)par1EntityWither.ticksExisted + par3; + this.bindTexture(invulnerableWitherTextures); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glLoadIdentity(); + float f2 = MathHelper.cos(f1 * 0.02F) * 3.0F; + float f3 = f1 * 0.01F; + GL11.glTranslatef(f2, f3, 0.0F); + this.setRenderPassModel(this.mainModel); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glEnable(GL11.GL_BLEND); + float f4 = 0.5F; + GL11.glColor4f(f4, f4, f4, 1.0F); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); + GL11.glTranslatef(0.0F, -0.01F, 0.0F); + GL11.glScalef(1.1F, 1.1F, 1.1F); + return 1; + } + + if (par2 == 2) + { + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glLoadIdentity(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_BLEND); + } + } + + return -1; + } + + protected int inheritRenderPass(EntityWither par1EntityWither, int par2, float par3) + { + return -1; + } + + public void doRender(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityWither)par1EntityLiving, par2, par4, par6, par8, par9); + } + + protected void preRenderCallback(EntityLivingBase par1EntityLivingBase, float par2) + { + this.preRenderCallback((EntityWither)par1EntityLivingBase, par2); + } + + protected int shouldRenderPass(EntityLivingBase par1EntityLivingBase, int par2, float par3) + { + return this.shouldRenderPass((EntityWither)par1EntityLivingBase, par2, par3); + } + + protected int inheritRenderPass(EntityLivingBase par1EntityLivingBase, int par2, float par3) + { + return this.inheritRenderPass((EntityWither)par1EntityLivingBase, par2, par3); + } + + public void doRender(EntityLivingBase par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityWither)par1Entity, par2, par4, par6, par8, par9); + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntityWither)par1Entity); + } + + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityWither)par1Entity, par2, par4, par6, par8, par9); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderWolf.java b/src/main/java/net/minecraft/client/renderer/entity/RenderWolf.java new file mode 100644 index 0000000..6cf9beb --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderWolf.java @@ -0,0 +1,74 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelBase; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.passive.EntitySheep; +import net.minecraft.entity.passive.EntityWolf; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class RenderWolf extends RenderLiving +{ + private static final ResourceLocation wolfTextures = new ResourceLocation("textures/entity/wolf/wolf.png"); + private static final ResourceLocation tamedWolfTextures = new ResourceLocation("textures/entity/wolf/wolf_tame.png"); + private static final ResourceLocation anrgyWolfTextures = new ResourceLocation("textures/entity/wolf/wolf_angry.png"); + private static final ResourceLocation wolfCollarTextures = new ResourceLocation("textures/entity/wolf/wolf_collar.png"); + private static final String __OBFID = "CL_00001036"; + + public RenderWolf(ModelBase par1ModelBase, ModelBase par2ModelBase, float par3) + { + super(par1ModelBase, par3); + this.setRenderPassModel(par2ModelBase); + } + + protected float handleRotationFloat(EntityWolf par1EntityWolf, float par2) + { + return par1EntityWolf.getTailRotation(); + } + + protected int shouldRenderPass(EntityWolf par1EntityWolf, int par2, float par3) + { + if (par2 == 0 && par1EntityWolf.getWolfShaking()) + { + float f1 = par1EntityWolf.getBrightness(par3) * par1EntityWolf.getShadingWhileShaking(par3); + this.bindTexture(wolfTextures); + GL11.glColor3f(f1, f1, f1); + return 1; + } + else if (par2 == 1 && par1EntityWolf.isTamed()) + { + this.bindTexture(wolfCollarTextures); + int j = par1EntityWolf.getCollarColor(); + GL11.glColor3f(EntitySheep.fleeceColorTable[j][0], EntitySheep.fleeceColorTable[j][1], EntitySheep.fleeceColorTable[j][2]); + return 1; + } + else + { + return -1; + } + } + + protected ResourceLocation getEntityTexture(EntityWolf par1EntityWolf) + { + return par1EntityWolf.isTamed() ? tamedWolfTextures : (par1EntityWolf.isAngry() ? anrgyWolfTextures : wolfTextures); + } + + protected int shouldRenderPass(EntityLivingBase par1EntityLivingBase, int par2, float par3) + { + return this.shouldRenderPass((EntityWolf)par1EntityLivingBase, par2, par3); + } + + protected float handleRotationFloat(EntityLivingBase par1EntityLivingBase, float par2) + { + return this.handleRotationFloat((EntityWolf)par1EntityLivingBase, par2); + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntityWolf)par1Entity); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderXPOrb.java b/src/main/java/net/minecraft/client/renderer/entity/RenderXPOrb.java new file mode 100644 index 0000000..a203c58 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderXPOrb.java @@ -0,0 +1,82 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityXPOrb; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +@SideOnly(Side.CLIENT) +public class RenderXPOrb extends Render +{ + private static final ResourceLocation experienceOrbTextures = new ResourceLocation("textures/entity/experience_orb.png"); + private static final String __OBFID = "CL_00000993"; + + public RenderXPOrb() + { + this.shadowSize = 0.15F; + this.shadowOpaque = 0.75F; + } + + public void doRender(EntityXPOrb par1EntityXPOrb, double par2, double par4, double par6, float par8, float par9) + { + GL11.glPushMatrix(); + GL11.glTranslatef((float)par2, (float)par4, (float)par6); + this.bindEntityTexture(par1EntityXPOrb); + int i = par1EntityXPOrb.getTextureByXP(); + float f2 = (float)(i % 4 * 16 + 0) / 64.0F; + float f3 = (float)(i % 4 * 16 + 16) / 64.0F; + float f4 = (float)(i / 4 * 16 + 0) / 64.0F; + float f5 = (float)(i / 4 * 16 + 16) / 64.0F; + float f6 = 1.0F; + float f7 = 0.5F; + float f8 = 0.25F; + int j = par1EntityXPOrb.getBrightnessForRender(par9); + int k = j % 65536; + int l = j / 65536; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)k / 1.0F, (float)l / 1.0F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + float f10 = 255.0F; + float f11 = ((float)par1EntityXPOrb.xpColor + par9) / 2.0F; + l = (int)((MathHelper.sin(f11 + 0.0F) + 1.0F) * 0.5F * f10); + int i1 = (int)f10; + int j1 = (int)((MathHelper.sin(f11 + 4.1887903F) + 1.0F) * 0.1F * f10); + int k1 = l << 16 | i1 << 8 | j1; + GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F); + float f9 = 0.3F; + GL11.glScalef(f9, f9, f9); + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_I(k1, 128); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + tessellator.addVertexWithUV((double)(0.0F - f7), (double)(0.0F - f8), 0.0D, (double)f2, (double)f5); + tessellator.addVertexWithUV((double)(f6 - f7), (double)(0.0F - f8), 0.0D, (double)f3, (double)f5); + tessellator.addVertexWithUV((double)(f6 - f7), (double)(1.0F - f8), 0.0D, (double)f3, (double)f4); + tessellator.addVertexWithUV((double)(0.0F - f7), (double)(1.0F - f8), 0.0D, (double)f2, (double)f4); + tessellator.draw(); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } + + protected ResourceLocation getEntityTexture(EntityXPOrb par1EntityXPOrb) + { + return experienceOrbTextures; + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntityXPOrb)par1Entity); + } + + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityXPOrb)par1Entity, par2, par4, par6, par8, par9); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RenderZombie.java b/src/main/java/net/minecraft/client/renderer/entity/RenderZombie.java new file mode 100644 index 0000000..5e7a3ad --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RenderZombie.java @@ -0,0 +1,155 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelBiped; +import net.minecraft.client.model.ModelZombie; +import net.minecraft.client.model.ModelZombieVillager; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.monster.EntityPigZombie; +import net.minecraft.entity.monster.EntityZombie; +import net.minecraft.util.ResourceLocation; + +@SideOnly(Side.CLIENT) +public class RenderZombie extends RenderBiped +{ + private static final ResourceLocation zombiePigmanTextures = new ResourceLocation("textures/entity/zombie_pigman.png"); + private static final ResourceLocation zombieTextures = new ResourceLocation("textures/entity/zombie/zombie.png"); + private static final ResourceLocation zombieVillagerTextures = new ResourceLocation("textures/entity/zombie/zombie_villager.png"); + private ModelBiped field_82434_o; + private ModelZombieVillager zombieVillagerModel; + protected ModelBiped field_82437_k; + protected ModelBiped field_82435_l; + protected ModelBiped field_82436_m; + protected ModelBiped field_82433_n; + private int field_82431_q = 1; + private static final String __OBFID = "CL_00001037"; + + public RenderZombie() + { + super(new ModelZombie(), 0.5F, 1.0F); + this.field_82434_o = this.modelBipedMain; + this.zombieVillagerModel = new ModelZombieVillager(); + } + + protected void func_82421_b() + { + this.field_82423_g = new ModelZombie(1.0F, true); + this.field_82425_h = new ModelZombie(0.5F, true); + this.field_82437_k = this.field_82423_g; + this.field_82435_l = this.field_82425_h; + this.field_82436_m = new ModelZombieVillager(1.0F, 0.0F, true); + this.field_82433_n = new ModelZombieVillager(0.5F, 0.0F, true); + } + + protected int shouldRenderPass(EntityZombie par1EntityZombie, int par2, float par3) + { + this.func_82427_a(par1EntityZombie); + return super.shouldRenderPass((EntityLiving)par1EntityZombie, par2, par3); + } + + public void doRender(EntityZombie par1EntityZombie, double par2, double par4, double par6, float par8, float par9) + { + this.func_82427_a(par1EntityZombie); + super.doRender((EntityLiving)par1EntityZombie, par2, par4, par6, par8, par9); + } + + protected ResourceLocation getEntityTexture(EntityZombie par1EntityZombie) + { + return par1EntityZombie instanceof EntityPigZombie ? zombiePigmanTextures : (par1EntityZombie.isVillager() ? zombieVillagerTextures : zombieTextures); + } + + protected void renderEquippedItems(EntityZombie par1EntityZombie, float par2) + { + this.func_82427_a(par1EntityZombie); + super.renderEquippedItems((EntityLiving)par1EntityZombie, par2); + } + + private void func_82427_a(EntityZombie par1EntityZombie) + { + if (par1EntityZombie.isVillager()) + { + if (this.field_82431_q != this.zombieVillagerModel.func_82897_a()) + { + this.zombieVillagerModel = new ModelZombieVillager(); + this.field_82431_q = this.zombieVillagerModel.func_82897_a(); + this.field_82436_m = new ModelZombieVillager(1.0F, 0.0F, true); + this.field_82433_n = new ModelZombieVillager(0.5F, 0.0F, true); + } + + this.mainModel = this.zombieVillagerModel; + this.field_82423_g = this.field_82436_m; + this.field_82425_h = this.field_82433_n; + } + else + { + this.mainModel = this.field_82434_o; + this.field_82423_g = this.field_82437_k; + this.field_82425_h = this.field_82435_l; + } + + this.modelBipedMain = (ModelBiped)this.mainModel; + } + + protected void rotateCorpse(EntityZombie par1EntityZombie, float par2, float par3, float par4) + { + if (par1EntityZombie.isConverting()) + { + par3 += (float)(Math.cos((double)par1EntityZombie.ticksExisted * 3.25D) * Math.PI * 0.25D); + } + + super.rotateCorpse(par1EntityZombie, par2, par3, par4); + } + + protected void renderEquippedItems(EntityLiving par1EntityLiving, float par2) + { + this.renderEquippedItems((EntityZombie)par1EntityLiving, par2); + } + + protected ResourceLocation getEntityTexture(EntityLiving par1EntityLiving) + { + return this.getEntityTexture((EntityZombie)par1EntityLiving); + } + + public void doRender(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityZombie)par1EntityLiving, par2, par4, par6, par8, par9); + } + + protected int shouldRenderPass(EntityLiving par1EntityLiving, int par2, float par3) + { + return this.shouldRenderPass((EntityZombie)par1EntityLiving, par2, par3); + } + + protected int shouldRenderPass(EntityLivingBase par1EntityLivingBase, int par2, float par3) + { + return this.shouldRenderPass((EntityZombie)par1EntityLivingBase, par2, par3); + } + + protected void renderEquippedItems(EntityLivingBase par1EntityLivingBase, float par2) + { + this.renderEquippedItems((EntityZombie)par1EntityLivingBase, par2); + } + + protected void rotateCorpse(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4) + { + this.rotateCorpse((EntityZombie)par1EntityLivingBase, par2, par3, par4); + } + + public void doRender(EntityLivingBase par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityZombie)par1Entity, par2, par4, par6, par8, par9); + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntityZombie)par1Entity); + } + + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityZombie)par1Entity, par2, par4, par6, par8, par9); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/entity/RendererLivingEntity.java b/src/main/java/net/minecraft/client/renderer/entity/RendererLivingEntity.java new file mode 100644 index 0000000..8dab2b1 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/entity/RendererLivingEntity.java @@ -0,0 +1,503 @@ +package net.minecraft.client.renderer.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelBox; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import net.minecraftforge.client.event.RenderLivingEvent; +import net.minecraftforge.common.MinecraftForge; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +@SideOnly(Side.CLIENT) +public abstract class RendererLivingEntity extends Render +{ + private static final Logger logger = LogManager.getLogger(); + private static final ResourceLocation RES_ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png"); + protected ModelBase mainModel; + protected ModelBase renderPassModel; + private static final String __OBFID = "CL_00001012"; + + public static float NAME_TAG_RANGE = 64.0f; + public static float NAME_TAG_RANGE_SNEAK = 32.0f; + + public RendererLivingEntity(ModelBase par1ModelBase, float par2) + { + this.mainModel = par1ModelBase; + this.shadowSize = par2; + } + + public void setRenderPassModel(ModelBase par1ModelBase) + { + this.renderPassModel = par1ModelBase; + } + + private float interpolateRotation(float par1, float par2, float par3) + { + float f3; + + for (f3 = par2 - par1; f3 < -180.0F; f3 += 360.0F) + { + ; + } + + while (f3 >= 180.0F) + { + f3 -= 360.0F; + } + + return par1 + par3 * f3; + } + + public void doRender(EntityLivingBase par1EntityLivingBase, double par2, double par4, double par6, float par8, float par9) + { + if (MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Pre(par1EntityLivingBase, this, par2, par4, par6))) return; + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_CULL_FACE); + this.mainModel.onGround = this.renderSwingProgress(par1EntityLivingBase, par9); + + if (this.renderPassModel != null) + { + this.renderPassModel.onGround = this.mainModel.onGround; + } + + this.mainModel.isRiding = par1EntityLivingBase.isRiding(); + + if (this.renderPassModel != null) + { + this.renderPassModel.isRiding = this.mainModel.isRiding; + } + + this.mainModel.isChild = par1EntityLivingBase.isChild(); + + if (this.renderPassModel != null) + { + this.renderPassModel.isChild = this.mainModel.isChild; + } + + try + { + float f2 = this.interpolateRotation(par1EntityLivingBase.prevRenderYawOffset, par1EntityLivingBase.renderYawOffset, par9); + float f3 = this.interpolateRotation(par1EntityLivingBase.prevRotationYawHead, par1EntityLivingBase.rotationYawHead, par9); + float f4; + + if (par1EntityLivingBase.isRiding() && par1EntityLivingBase.ridingEntity instanceof EntityLivingBase) + { + EntityLivingBase entitylivingbase1 = (EntityLivingBase)par1EntityLivingBase.ridingEntity; + f2 = this.interpolateRotation(entitylivingbase1.prevRenderYawOffset, entitylivingbase1.renderYawOffset, par9); + f4 = MathHelper.wrapAngleTo180_float(f3 - f2); + + if (f4 < -85.0F) + { + f4 = -85.0F; + } + + if (f4 >= 85.0F) + { + f4 = 85.0F; + } + + f2 = f3 - f4; + + if (f4 * f4 > 2500.0F) + { + f2 += f4 * 0.2F; + } + } + + float f13 = par1EntityLivingBase.prevRotationPitch + (par1EntityLivingBase.rotationPitch - par1EntityLivingBase.prevRotationPitch) * par9; + this.renderLivingAt(par1EntityLivingBase, par2, par4, par6); + f4 = this.handleRotationFloat(par1EntityLivingBase, par9); + this.rotateCorpse(par1EntityLivingBase, f4, f2, par9); + float f5 = 0.0625F; + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glScalef(-1.0F, -1.0F, 1.0F); + this.preRenderCallback(par1EntityLivingBase, par9); + GL11.glTranslatef(0.0F, -24.0F * f5 - 0.0078125F, 0.0F); + float f6 = par1EntityLivingBase.prevLimbSwingAmount + (par1EntityLivingBase.limbSwingAmount - par1EntityLivingBase.prevLimbSwingAmount) * par9; + float f7 = par1EntityLivingBase.limbSwing - par1EntityLivingBase.limbSwingAmount * (1.0F - par9); + + if (par1EntityLivingBase.isChild()) + { + f7 *= 3.0F; + } + + if (f6 > 1.0F) + { + f6 = 1.0F; + } + + GL11.glEnable(GL11.GL_ALPHA_TEST); + this.mainModel.setLivingAnimations(par1EntityLivingBase, f7, f6, par9); + this.renderModel(par1EntityLivingBase, f7, f6, f4, f3 - f2, f13, f5); + int j; + float f8; + float f9; + float f10; + + for (int i = 0; i < 4; ++i) + { + j = this.shouldRenderPass(par1EntityLivingBase, i, par9); + + if (j > 0) + { + this.renderPassModel.setLivingAnimations(par1EntityLivingBase, f7, f6, par9); + this.renderPassModel.render(par1EntityLivingBase, f7, f6, f4, f3 - f2, f13, f5); + + if ((j & 240) == 16) + { + this.func_82408_c(par1EntityLivingBase, i, par9); + this.renderPassModel.render(par1EntityLivingBase, f7, f6, f4, f3 - f2, f13, f5); + } + + if ((j & 15) == 15) + { + f8 = (float)par1EntityLivingBase.ticksExisted + par9; + this.bindTexture(RES_ITEM_GLINT); + GL11.glEnable(GL11.GL_BLEND); + f9 = 0.5F; + GL11.glColor4f(f9, f9, f9, 1.0F); + GL11.glDepthFunc(GL11.GL_EQUAL); + GL11.glDepthMask(false); + + for (int k = 0; k < 2; ++k) + { + GL11.glDisable(GL11.GL_LIGHTING); + f10 = 0.76F; + GL11.glColor4f(0.5F * f10, 0.25F * f10, 0.8F * f10, 1.0F); + GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glLoadIdentity(); + float f11 = f8 * (0.001F + (float)k * 0.003F) * 20.0F; + float f12 = 0.33333334F; + GL11.glScalef(f12, f12, f12); + GL11.glRotatef(30.0F - (float)k * 60.0F, 0.0F, 0.0F, 1.0F); + GL11.glTranslatef(0.0F, f11, 0.0F); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + this.renderPassModel.render(par1EntityLivingBase, f7, f6, f4, f3 - f2, f13, f5); + } + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glDepthMask(true); + GL11.glLoadIdentity(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthFunc(GL11.GL_LEQUAL); + } + + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_ALPHA_TEST); + } + } + + GL11.glDepthMask(true); + this.renderEquippedItems(par1EntityLivingBase, par9); + float f14 = par1EntityLivingBase.getBrightness(par9); + j = this.getColorMultiplier(par1EntityLivingBase, f14, par9); + OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); + GL11.glDisable(GL11.GL_TEXTURE_2D); + OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); + + if ((j >> 24 & 255) > 0 || par1EntityLivingBase.hurtTime > 0 || par1EntityLivingBase.deathTime > 0) + { + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glDepthFunc(GL11.GL_EQUAL); + + if (par1EntityLivingBase.hurtTime > 0 || par1EntityLivingBase.deathTime > 0) + { + GL11.glColor4f(f14, 0.0F, 0.0F, 0.4F); + this.mainModel.render(par1EntityLivingBase, f7, f6, f4, f3 - f2, f13, f5); + + for (int l = 0; l < 4; ++l) + { + if (this.inheritRenderPass(par1EntityLivingBase, l, par9) >= 0) + { + GL11.glColor4f(f14, 0.0F, 0.0F, 0.4F); + this.renderPassModel.render(par1EntityLivingBase, f7, f6, f4, f3 - f2, f13, f5); + } + } + } + + if ((j >> 24 & 255) > 0) + { + f8 = (float)(j >> 16 & 255) / 255.0F; + f9 = (float)(j >> 8 & 255) / 255.0F; + float f15 = (float)(j & 255) / 255.0F; + f10 = (float)(j >> 24 & 255) / 255.0F; + GL11.glColor4f(f8, f9, f15, f10); + this.mainModel.render(par1EntityLivingBase, f7, f6, f4, f3 - f2, f13, f5); + + for (int i1 = 0; i1 < 4; ++i1) + { + if (this.inheritRenderPass(par1EntityLivingBase, i1, par9) >= 0) + { + GL11.glColor4f(f8, f9, f15, f10); + this.renderPassModel.render(par1EntityLivingBase, f7, f6, f4, f3 - f2, f13, f5); + } + } + } + + GL11.glDepthFunc(GL11.GL_LEQUAL); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + } + catch (Exception exception) + { + logger.error("Couldn\'t render entity", exception); + } + + OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); + GL11.glEnable(GL11.GL_TEXTURE_2D); + OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glPopMatrix(); + this.passSpecialRender(par1EntityLivingBase, par2, par4, par6); + MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Post(par1EntityLivingBase, this, par2, par4, par6)); + } + + protected void renderModel(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4, float par5, float par6, float par7) + { + this.bindEntityTexture(par1EntityLivingBase); + + if (!par1EntityLivingBase.isInvisible()) + { + this.mainModel.render(par1EntityLivingBase, par2, par3, par4, par5, par6, par7); + } + else if (!par1EntityLivingBase.isInvisibleToPlayer(Minecraft.getMinecraft().thePlayer)) + { + GL11.glPushMatrix(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.15F); + GL11.glDepthMask(false); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F); + this.mainModel.render(par1EntityLivingBase, par2, par3, par4, par5, par6, par7); + GL11.glDisable(GL11.GL_BLEND); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); + GL11.glPopMatrix(); + GL11.glDepthMask(true); + } + else + { + this.mainModel.setRotationAngles(par2, par3, par4, par5, par6, par7, par1EntityLivingBase); + } + } + + protected void renderLivingAt(EntityLivingBase par1EntityLivingBase, double par2, double par4, double par6) + { + GL11.glTranslatef((float)par2, (float)par4, (float)par6); + } + + protected void rotateCorpse(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4) + { + GL11.glRotatef(180.0F - par3, 0.0F, 1.0F, 0.0F); + + if (par1EntityLivingBase.deathTime > 0) + { + float f3 = ((float)par1EntityLivingBase.deathTime + par4 - 1.0F) / 20.0F * 1.6F; + f3 = MathHelper.sqrt_float(f3); + + if (f3 > 1.0F) + { + f3 = 1.0F; + } + + GL11.glRotatef(f3 * this.getDeathMaxRotation(par1EntityLivingBase), 0.0F, 0.0F, 1.0F); + } + else + { + String s = EnumChatFormatting.getTextWithoutFormattingCodes(par1EntityLivingBase.getCommandSenderName()); + + if ((s.equals("Dinnerbone") || s.equals("Grumm")) && (!(par1EntityLivingBase instanceof EntityPlayer) || !((EntityPlayer)par1EntityLivingBase).getHideCape())) + { + GL11.glTranslatef(0.0F, par1EntityLivingBase.height + 0.1F, 0.0F); + GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); + } + } + } + + protected float renderSwingProgress(EntityLivingBase par1EntityLivingBase, float par2) + { + return par1EntityLivingBase.getSwingProgress(par2); + } + + protected float handleRotationFloat(EntityLivingBase par1EntityLivingBase, float par2) + { + return (float)par1EntityLivingBase.ticksExisted + par2; + } + + protected void renderEquippedItems(EntityLivingBase par1EntityLivingBase, float par2) {} + + protected void renderArrowsStuckInEntity(EntityLivingBase par1EntityLivingBase, float par2) + { + int i = par1EntityLivingBase.getArrowCountInEntity(); + + if (i > 0) + { + EntityArrow entityarrow = new EntityArrow(par1EntityLivingBase.worldObj, par1EntityLivingBase.posX, par1EntityLivingBase.posY, par1EntityLivingBase.posZ); + Random random = new Random((long)par1EntityLivingBase.getEntityId()); + RenderHelper.disableStandardItemLighting(); + + for (int j = 0; j < i; ++j) + { + GL11.glPushMatrix(); + ModelRenderer modelrenderer = this.mainModel.getRandomModelBox(random); + ModelBox modelbox = (ModelBox)modelrenderer.cubeList.get(random.nextInt(modelrenderer.cubeList.size())); + modelrenderer.postRender(0.0625F); + float f1 = random.nextFloat(); + float f2 = random.nextFloat(); + float f3 = random.nextFloat(); + float f4 = (modelbox.posX1 + (modelbox.posX2 - modelbox.posX1) * f1) / 16.0F; + float f5 = (modelbox.posY1 + (modelbox.posY2 - modelbox.posY1) * f2) / 16.0F; + float f6 = (modelbox.posZ1 + (modelbox.posZ2 - modelbox.posZ1) * f3) / 16.0F; + GL11.glTranslatef(f4, f5, f6); + f1 = f1 * 2.0F - 1.0F; + f2 = f2 * 2.0F - 1.0F; + f3 = f3 * 2.0F - 1.0F; + f1 *= -1.0F; + f2 *= -1.0F; + f3 *= -1.0F; + float f7 = MathHelper.sqrt_float(f1 * f1 + f3 * f3); + entityarrow.prevRotationYaw = entityarrow.rotationYaw = (float)(Math.atan2((double)f1, (double)f3) * 180.0D / Math.PI); + entityarrow.prevRotationPitch = entityarrow.rotationPitch = (float)(Math.atan2((double)f2, (double)f7) * 180.0D / Math.PI); + double d0 = 0.0D; + double d1 = 0.0D; + double d2 = 0.0D; + float f8 = 0.0F; + this.renderManager.renderEntityWithPosYaw(entityarrow, d0, d1, d2, f8, par2); + GL11.glPopMatrix(); + } + + RenderHelper.enableStandardItemLighting(); + } + } + + protected int inheritRenderPass(EntityLivingBase par1EntityLivingBase, int par2, float par3) + { + return this.shouldRenderPass(par1EntityLivingBase, par2, par3); + } + + protected int shouldRenderPass(EntityLivingBase par1EntityLivingBase, int par2, float par3) + { + return -1; + } + + protected void func_82408_c(EntityLivingBase par1EntityLivingBase, int par2, float par3) {} + + protected float getDeathMaxRotation(EntityLivingBase par1EntityLivingBase) + { + return 90.0F; + } + + protected int getColorMultiplier(EntityLivingBase par1EntityLivingBase, float par2, float par3) + { + return 0; + } + + protected void preRenderCallback(EntityLivingBase par1EntityLivingBase, float par2) {} + + protected void passSpecialRender(EntityLivingBase par1EntityLivingBase, double par2, double par4, double par6) + { + if (MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Specials.Pre(par1EntityLivingBase, this, par2, par4, par6))) return; + GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); + + if (this.func_110813_b(par1EntityLivingBase)) + { + float f = 1.6F; + float f1 = 0.016666668F * f; + double d3 = par1EntityLivingBase.getDistanceSqToEntity(this.renderManager.livingPlayer); + float f2 = par1EntityLivingBase.isSneaking() ? NAME_TAG_RANGE_SNEAK : NAME_TAG_RANGE; + + if (d3 < (double)(f2 * f2)) + { + String s = par1EntityLivingBase.func_145748_c_().getFormattedText(); + + if (par1EntityLivingBase.isSneaking()) + { + FontRenderer fontrenderer = this.getFontRendererFromRenderManager(); + GL11.glPushMatrix(); + GL11.glTranslatef((float)par2 + 0.0F, (float)par4 + par1EntityLivingBase.height + 0.5F, (float)par6); + GL11.glNormal3f(0.0F, 1.0F, 0.0F); + GL11.glRotatef(-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F); + GL11.glScalef(-f1, -f1, f1); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glTranslatef(0.0F, 0.25F / f1, 0.0F); + GL11.glDepthMask(false); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + Tessellator tessellator = Tessellator.instance; + GL11.glDisable(GL11.GL_TEXTURE_2D); + tessellator.startDrawingQuads(); + int i = fontrenderer.getStringWidth(s) / 2; + tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F); + tessellator.addVertex((double)(-i - 1), -1.0D, 0.0D); + tessellator.addVertex((double)(-i - 1), 8.0D, 0.0D); + tessellator.addVertex((double)(i + 1), 8.0D, 0.0D); + tessellator.addVertex((double)(i + 1), -1.0D, 0.0D); + tessellator.draw(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDepthMask(true); + fontrenderer.drawString(s, -fontrenderer.getStringWidth(s) / 2, 0, 553648127); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_BLEND); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glPopMatrix(); + } + else + { + this.func_96449_a(par1EntityLivingBase, par2, par4, par6, s, f1, d3); + } + } + } + MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Specials.Post(par1EntityLivingBase, this, par2, par4, par6)); + } + + protected boolean func_110813_b(EntityLivingBase par1EntityLivingBase) + { + return Minecraft.isGuiEnabled() && par1EntityLivingBase != this.renderManager.livingPlayer && !par1EntityLivingBase.isInvisibleToPlayer(Minecraft.getMinecraft().thePlayer) && par1EntityLivingBase.riddenByEntity == null; + } + + protected void func_96449_a(EntityLivingBase par1EntityLivingBase, double par2, double par4, double par6, String par8Str, float par9, double par10) + { + if (par1EntityLivingBase.isPlayerSleeping()) + { + this.func_147906_a(par1EntityLivingBase, par8Str, par2, par4 - 1.5D, par6, 64); + } + else + { + this.func_147906_a(par1EntityLivingBase, par8Str, par2, par4, par6, 64); + } + } + + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityLivingBase)par1Entity, par2, par4, par6, par8, par9); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/texture/AbstractTexture.java b/src/main/java/net/minecraft/client/renderer/texture/AbstractTexture.java new file mode 100644 index 0000000..891fdf8 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/texture/AbstractTexture.java @@ -0,0 +1,30 @@ +package net.minecraft.client.renderer.texture; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public abstract class AbstractTexture implements ITextureObject +{ + protected int glTextureId = -1; + private static final String __OBFID = "CL_00001047"; + + public int getGlTextureId() + { + if (this.glTextureId == -1) + { + this.glTextureId = TextureUtil.glGenTextures(); + } + + return this.glTextureId; + } + + public void deleteGlTexture() + { + if (this.glTextureId != -1) + { + TextureUtil.deleteTexture(this.glTextureId); + this.glTextureId = -1; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/texture/DynamicTexture.java b/src/main/java/net/minecraft/client/renderer/texture/DynamicTexture.java new file mode 100644 index 0000000..f6f6252 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/texture/DynamicTexture.java @@ -0,0 +1,43 @@ +package net.minecraft.client.renderer.texture; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.awt.image.BufferedImage; +import java.io.IOException; +import net.minecraft.client.resources.IResourceManager; + +@SideOnly(Side.CLIENT) +public class DynamicTexture extends AbstractTexture +{ + private final int[] dynamicTextureData; + private final int width; + private final int height; + private static final String __OBFID = "CL_00001048"; + + public DynamicTexture(BufferedImage par1BufferedImage) + { + this(par1BufferedImage.getWidth(), par1BufferedImage.getHeight()); + par1BufferedImage.getRGB(0, 0, par1BufferedImage.getWidth(), par1BufferedImage.getHeight(), this.dynamicTextureData, 0, par1BufferedImage.getWidth()); + this.updateDynamicTexture(); + } + + public DynamicTexture(int par1, int par2) + { + this.width = par1; + this.height = par2; + this.dynamicTextureData = new int[par1 * par2]; + TextureUtil.allocateTexture(this.getGlTextureId(), par1, par2); + } + + public void loadTexture(IResourceManager par1ResourceManager) throws IOException {} + + public void updateDynamicTexture() + { + TextureUtil.uploadTexture(this.getGlTextureId(), this.dynamicTextureData, this.width, this.height); + } + + public int[] getTextureData() + { + return this.dynamicTextureData; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/texture/IIconRegister.java b/src/main/java/net/minecraft/client/renderer/texture/IIconRegister.java new file mode 100644 index 0000000..dcbb256 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/texture/IIconRegister.java @@ -0,0 +1,11 @@ +package net.minecraft.client.renderer.texture; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.util.IIcon; + +@SideOnly(Side.CLIENT) +public interface IIconRegister +{ + IIcon registerIcon(String var1); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/texture/ITextureObject.java b/src/main/java/net/minecraft/client/renderer/texture/ITextureObject.java new file mode 100644 index 0000000..b625ac4 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/texture/ITextureObject.java @@ -0,0 +1,14 @@ +package net.minecraft.client.renderer.texture; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.client.resources.IResourceManager; + +@SideOnly(Side.CLIENT) +public interface ITextureObject +{ + void loadTexture(IResourceManager var1) throws IOException; + + int getGlTextureId(); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/texture/ITickable.java b/src/main/java/net/minecraft/client/renderer/texture/ITickable.java new file mode 100644 index 0000000..3964d5e --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/texture/ITickable.java @@ -0,0 +1,10 @@ +package net.minecraft.client.renderer.texture; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public interface ITickable +{ + void tick(); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/texture/ITickableTextureObject.java b/src/main/java/net/minecraft/client/renderer/texture/ITickableTextureObject.java new file mode 100644 index 0000000..0d21fc8 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/texture/ITickableTextureObject.java @@ -0,0 +1,9 @@ +package net.minecraft.client.renderer.texture; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public interface ITickableTextureObject extends ITextureObject, ITickable +{ +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/texture/LayeredTexture.java b/src/main/java/net/minecraft/client/renderer/texture/LayeredTexture.java new file mode 100644 index 0000000..3c22507 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/texture/LayeredTexture.java @@ -0,0 +1,65 @@ +package net.minecraft.client.renderer.texture; + +import com.google.common.collect.Lists; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.awt.image.BufferedImage; +import java.awt.image.ImageObserver; +import java.io.IOException; +import java.io.InputStream; +import java.util.Iterator; +import java.util.List; +import javax.imageio.ImageIO; +import net.minecraft.client.resources.IResourceManager; +import net.minecraft.util.ResourceLocation; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +@SideOnly(Side.CLIENT) +public class LayeredTexture extends AbstractTexture +{ + private static final Logger logger = LogManager.getLogger(); + public final List layeredTextureNames; + private static final String __OBFID = "CL_00001051"; + + public LayeredTexture(String ... par1ArrayOfStr) + { + this.layeredTextureNames = Lists.newArrayList(par1ArrayOfStr); + } + + public void loadTexture(IResourceManager par1ResourceManager) throws IOException + { + this.deleteGlTexture(); + BufferedImage bufferedimage = null; + + try + { + Iterator iterator = this.layeredTextureNames.iterator(); + + while (iterator.hasNext()) + { + String s = (String)iterator.next(); + + if (s != null) + { + InputStream inputstream = par1ResourceManager.getResource(new ResourceLocation(s)).getInputStream(); + BufferedImage bufferedimage1 = ImageIO.read(inputstream); + + if (bufferedimage == null) + { + bufferedimage = new BufferedImage(bufferedimage1.getWidth(), bufferedimage1.getHeight(), 2); + } + + bufferedimage.getGraphics().drawImage(bufferedimage1, 0, 0, (ImageObserver)null); + } + } + } + catch (IOException ioexception) + { + logger.error("Couldn\'t load layered image", ioexception); + return; + } + + TextureUtil.uploadTextureImage(this.getGlTextureId(), bufferedimage); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/texture/SimpleTexture.java b/src/main/java/net/minecraft/client/renderer/texture/SimpleTexture.java new file mode 100644 index 0000000..1c28f43 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/texture/SimpleTexture.java @@ -0,0 +1,69 @@ +package net.minecraft.client.renderer.texture; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.io.InputStream; +import javax.imageio.ImageIO; +import net.minecraft.client.resources.IResource; +import net.minecraft.client.resources.IResourceManager; +import net.minecraft.client.resources.data.TextureMetadataSection; +import net.minecraft.util.ResourceLocation; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +@SideOnly(Side.CLIENT) +public class SimpleTexture extends AbstractTexture +{ + private static final Logger logger = LogManager.getLogger(); + protected final ResourceLocation textureLocation; + private static final String __OBFID = "CL_00001052"; + + public SimpleTexture(ResourceLocation par1ResourceLocation) + { + this.textureLocation = par1ResourceLocation; + } + + public void loadTexture(IResourceManager par1ResourceManager) throws IOException + { + this.deleteGlTexture(); + InputStream inputstream = null; + + try + { + IResource iresource = par1ResourceManager.getResource(this.textureLocation); + inputstream = iresource.getInputStream(); + BufferedImage bufferedimage = ImageIO.read(inputstream); + boolean flag = false; + boolean flag1 = false; + + if (iresource.hasMetadata()) + { + try + { + TextureMetadataSection texturemetadatasection = (TextureMetadataSection)iresource.getMetadata("texture"); + + if (texturemetadatasection != null) + { + flag = texturemetadatasection.getTextureBlur(); + flag1 = texturemetadatasection.getTextureClamp(); + } + } + catch (RuntimeException runtimeexception) + { + logger.warn("Failed reading metadata of: " + this.textureLocation, runtimeexception); + } + } + + TextureUtil.uploadTextureImageAllocate(this.getGlTextureId(), bufferedimage, flag, flag1); + } + finally + { + if (inputstream != null) + { + inputstream.close(); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/texture/Stitcher.java b/src/main/java/net/minecraft/client/renderer/texture/Stitcher.java new file mode 100644 index 0000000..14abadd --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/texture/Stitcher.java @@ -0,0 +1,445 @@ +package net.minecraft.client.renderer.texture; + +import com.google.common.collect.Lists; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; +import net.minecraft.client.renderer.StitcherException; +import net.minecraft.util.MathHelper; + +@SideOnly(Side.CLIENT) +public class Stitcher +{ + private final int mipmapLevelStitcher; + private final Set setStitchHolders = new HashSet(256); + private final List stitchSlots = new ArrayList(256); + private int currentWidth; + private int currentHeight; + private final int maxWidth; + private final int maxHeight; + private final boolean forcePowerOf2; + private final int maxTileDimension; + private static final String __OBFID = "CL_00001054"; + + public Stitcher(int p_i45095_1_, int p_i45095_2_, boolean p_i45095_3_, int p_i45095_4_, int p_i45095_5_) + { + this.mipmapLevelStitcher = p_i45095_5_; + this.maxWidth = p_i45095_1_; + this.maxHeight = p_i45095_2_; + this.forcePowerOf2 = p_i45095_3_; + this.maxTileDimension = p_i45095_4_; + } + + public int getCurrentWidth() + { + return this.currentWidth; + } + + public int getCurrentHeight() + { + return this.currentHeight; + } + + public void addSprite(TextureAtlasSprite par1TextureAtlasSprite) + { + Stitcher.Holder holder = new Stitcher.Holder(par1TextureAtlasSprite, this.mipmapLevelStitcher); + + if (this.maxTileDimension > 0) + { + holder.setNewDimension(this.maxTileDimension); + } + + this.setStitchHolders.add(holder); + } + + public void doStitch() + { + Stitcher.Holder[] aholder = (Stitcher.Holder[])this.setStitchHolders.toArray(new Stitcher.Holder[this.setStitchHolders.size()]); + Arrays.sort(aholder); + Stitcher.Holder[] aholder1 = aholder; + int i = aholder.length; + + for (int j = 0; j < i; ++j) + { + Stitcher.Holder holder = aholder1[j]; + + if (!this.allocateSlot(holder)) + { + String s = String.format("Unable to fit: %s - size: %dx%d - Maybe try a lowerresolution texturepack?", new Object[] {holder.getAtlasSprite().getIconName(), Integer.valueOf(holder.getAtlasSprite().getIconWidth()), Integer.valueOf(holder.getAtlasSprite().getIconHeight())}); + throw new StitcherException(holder, s); + } + } + + if (this.forcePowerOf2) + { + this.currentWidth = MathHelper.roundUpToPowerOfTwo(this.currentWidth); + this.currentHeight = MathHelper.roundUpToPowerOfTwo(this.currentHeight); + } + } + + public List getStichSlots() + { + ArrayList arraylist = Lists.newArrayList(); + Iterator iterator = this.stitchSlots.iterator(); + + while (iterator.hasNext()) + { + Stitcher.Slot slot = (Stitcher.Slot)iterator.next(); + slot.getAllStitchSlots(arraylist); + } + + ArrayList arraylist1 = Lists.newArrayList(); + Iterator iterator1 = arraylist.iterator(); + + while (iterator1.hasNext()) + { + Stitcher.Slot slot1 = (Stitcher.Slot)iterator1.next(); + Stitcher.Holder holder = slot1.getStitchHolder(); + TextureAtlasSprite textureatlassprite = holder.getAtlasSprite(); + textureatlassprite.initSprite(this.currentWidth, this.currentHeight, slot1.getOriginX(), slot1.getOriginY(), holder.isRotated()); + arraylist1.add(textureatlassprite); + } + + return arraylist1; + } + + private static int getMipmapDimension(int p_147969_0_, int p_147969_1_) + { + return (p_147969_0_ >> p_147969_1_) + ((p_147969_0_ & (1 << p_147969_1_) - 1) == 0 ? 0 : 1) << p_147969_1_; + } + + private boolean allocateSlot(Stitcher.Holder par1StitchHolder) + { + for (int i = 0; i < this.stitchSlots.size(); ++i) + { + if (((Stitcher.Slot)this.stitchSlots.get(i)).addSlot(par1StitchHolder)) + { + return true; + } + + par1StitchHolder.rotate(); + + if (((Stitcher.Slot)this.stitchSlots.get(i)).addSlot(par1StitchHolder)) + { + return true; + } + + par1StitchHolder.rotate(); + } + + return this.expandAndAllocateSlot(par1StitchHolder); + } + + private boolean expandAndAllocateSlot(Stitcher.Holder par1StitchHolder) + { + int i = Math.min(par1StitchHolder.getWidth(), par1StitchHolder.getHeight()); + boolean flag = this.currentWidth == 0 && this.currentHeight == 0; + boolean flag1; + int j; + + if (this.forcePowerOf2) + { + j = MathHelper.roundUpToPowerOfTwo(this.currentWidth); + int k = MathHelper.roundUpToPowerOfTwo(this.currentHeight); + int l = MathHelper.roundUpToPowerOfTwo(this.currentWidth + i); + int i1 = MathHelper.roundUpToPowerOfTwo(this.currentHeight + i); + boolean flag2 = l <= this.maxWidth; + boolean flag3 = i1 <= this.maxHeight; + + if (!flag2 && !flag3) + { + return false; + } + + boolean flag4 = j != l; + boolean flag5 = k != i1; + + if (flag4 ^ flag5) + { + flag1 = flag5 && flag3; //Forge: Bug fix: Attempt to fill all downward space before expanding width + } + else + { + flag1 = flag2 && j <= k; + } + } + else + { + boolean flag6 = this.currentWidth + i <= this.maxWidth; + boolean flag7 = this.currentHeight + i <= this.maxHeight; + + if (!flag6 && !flag7) + { + return false; + } + + flag1 = flag6 && (flag || this.currentWidth <= this.currentHeight); + } + + j = Math.max(par1StitchHolder.getWidth(), par1StitchHolder.getHeight()); + + if (MathHelper.roundUpToPowerOfTwo((flag1 ? this.currentHeight : this.currentWidth) + j) > (flag1 ? this.maxHeight : this.maxWidth)) + { + return false; + } + else + { + Stitcher.Slot slot; + + if (flag1) + { + if (par1StitchHolder.getWidth() > par1StitchHolder.getHeight()) + { + par1StitchHolder.rotate(); + } + + if (this.currentHeight == 0) + { + this.currentHeight = par1StitchHolder.getHeight(); + } + + slot = new Stitcher.Slot(this.currentWidth, 0, par1StitchHolder.getWidth(), this.currentHeight); + this.currentWidth += par1StitchHolder.getWidth(); + } + else + { + slot = new Stitcher.Slot(0, this.currentHeight, this.currentWidth, par1StitchHolder.getHeight()); + this.currentHeight += par1StitchHolder.getHeight(); + } + + slot.addSlot(par1StitchHolder); + this.stitchSlots.add(slot); + return true; + } + } + + @SideOnly(Side.CLIENT) + public static class Holder implements Comparable + { + private final TextureAtlasSprite theTexture; + private final int width; + private final int height; + private final int mipmapLevelHolder; + private boolean rotated; + private float scaleFactor = 1.0F; + private static final String __OBFID = "CL_00001055"; + + public Holder(TextureAtlasSprite p_i45094_1_, int p_i45094_2_) + { + this.theTexture = p_i45094_1_; + this.width = p_i45094_1_.getIconWidth(); + this.height = p_i45094_1_.getIconHeight(); + this.mipmapLevelHolder = p_i45094_2_; + this.rotated = Stitcher.getMipmapDimension(this.height, p_i45094_2_) > Stitcher.getMipmapDimension(this.width, p_i45094_2_); + } + + public TextureAtlasSprite getAtlasSprite() + { + return this.theTexture; + } + + public int getWidth() + { + return this.rotated ? Stitcher.getMipmapDimension((int)((float)this.height * this.scaleFactor), this.mipmapLevelHolder) : Stitcher.getMipmapDimension((int)((float)this.width * this.scaleFactor), this.mipmapLevelHolder); + } + + public int getHeight() + { + return this.rotated ? Stitcher.getMipmapDimension((int)((float)this.width * this.scaleFactor), this.mipmapLevelHolder) : Stitcher.getMipmapDimension((int)((float)this.height * this.scaleFactor), this.mipmapLevelHolder); + } + + public void rotate() + { + this.rotated = !this.rotated; + } + + public boolean isRotated() + { + return this.rotated; + } + + public void setNewDimension(int par1) + { + if (this.width > par1 && this.height > par1) + { + this.scaleFactor = (float)par1 / (float)Math.min(this.width, this.height); + } + } + + public String toString() + { + return "Holder{width=" + this.width + ", height=" + this.height + '}'; + } + + public int compareTo(Stitcher.Holder par1StitchHolder) + { + int i; + + if (this.getHeight() == par1StitchHolder.getHeight()) + { + if (this.getWidth() == par1StitchHolder.getWidth()) + { + if (this.theTexture.getIconName() == null) + { + return par1StitchHolder.theTexture.getIconName() == null ? 0 : -1; + } + + return this.theTexture.getIconName().compareTo(par1StitchHolder.theTexture.getIconName()); + } + + i = this.getWidth() < par1StitchHolder.getWidth() ? 1 : -1; + } + else + { + i = this.getHeight() < par1StitchHolder.getHeight() ? 1 : -1; + } + + return i; + } + + public int compareTo(Object par1Obj) + { + return this.compareTo((Stitcher.Holder)par1Obj); + } + } + + @SideOnly(Side.CLIENT) + public static class Slot + { + private final int originX; + private final int originY; + private final int width; + private final int height; + private List subSlots; + private Stitcher.Holder holder; + private static final String __OBFID = "CL_00001056"; + + public Slot(int par1, int par2, int par3, int par4) + { + this.originX = par1; + this.originY = par2; + this.width = par3; + this.height = par4; + } + + public Stitcher.Holder getStitchHolder() + { + return this.holder; + } + + public int getOriginX() + { + return this.originX; + } + + public int getOriginY() + { + return this.originY; + } + + public boolean addSlot(Stitcher.Holder par1StitchHolder) + { + if (this.holder != null) + { + return false; + } + else + { + int i = par1StitchHolder.getWidth(); + int j = par1StitchHolder.getHeight(); + + if (i <= this.width && j <= this.height) + { + if (i == this.width && j == this.height) + { + this.holder = par1StitchHolder; + return true; + } + else + { + if (this.subSlots == null) + { + this.subSlots = new ArrayList(1); + this.subSlots.add(new Stitcher.Slot(this.originX, this.originY, i, j)); + int k = this.width - i; + int l = this.height - j; + + if (l > 0 && k > 0) + { + int i1 = Math.max(this.height, k); + int j1 = Math.max(this.width, l); + + if (i1 >= j1) + { + this.subSlots.add(new Stitcher.Slot(this.originX, this.originY + j, i, l)); + this.subSlots.add(new Stitcher.Slot(this.originX + i, this.originY, k, this.height)); + } + else + { + this.subSlots.add(new Stitcher.Slot(this.originX + i, this.originY, k, j)); + this.subSlots.add(new Stitcher.Slot(this.originX, this.originY + j, this.width, l)); + } + } + else if (k == 0) + { + this.subSlots.add(new Stitcher.Slot(this.originX, this.originY + j, i, l)); + } + else if (l == 0) + { + this.subSlots.add(new Stitcher.Slot(this.originX + i, this.originY, k, j)); + } + } + + Iterator iterator = this.subSlots.iterator(); + Stitcher.Slot slot; + + do + { + if (!iterator.hasNext()) + { + return false; + } + + slot = (Stitcher.Slot)iterator.next(); + } + while (!slot.addSlot(par1StitchHolder)); + + return true; + } + } + else + { + return false; + } + } + } + + public void getAllStitchSlots(List par1List) + { + if (this.holder != null) + { + par1List.add(this); + } + else if (this.subSlots != null) + { + Iterator iterator = this.subSlots.iterator(); + + while (iterator.hasNext()) + { + Stitcher.Slot slot = (Stitcher.Slot)iterator.next(); + slot.getAllStitchSlots(par1List); + } + } + } + + public String toString() + { + return "Slot{originX=" + this.originX + ", originY=" + this.originY + ", width=" + this.width + ", height=" + this.height + ", texture=" + this.holder + ", subSlots=" + this.subSlots + '}'; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/texture/TextureAtlasSprite.java b/src/main/java/net/minecraft/client/renderer/texture/TextureAtlasSprite.java new file mode 100644 index 0000000..1fecef6 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/texture/TextureAtlasSprite.java @@ -0,0 +1,456 @@ +package net.minecraft.client.renderer.texture; + +import com.google.common.collect.Lists; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.awt.image.BufferedImage; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.concurrent.Callable; +import net.minecraft.client.resources.IResourceManager; +import net.minecraft.client.resources.data.AnimationFrame; +import net.minecraft.client.resources.data.AnimationMetadataSection; +import net.minecraft.crash.CrashReport; +import net.minecraft.crash.CrashReportCategory; +import net.minecraft.util.IIcon; +import net.minecraft.util.ReportedException; +import net.minecraft.util.ResourceLocation; + +@SideOnly(Side.CLIENT) +public class TextureAtlasSprite implements IIcon +{ + private final String iconName; + protected List framesTextureData = Lists.newArrayList(); + private AnimationMetadataSection animationMetadata; + protected boolean rotated; + private boolean useAnisotropicFiltering; + protected int originX; + protected int originY; + protected int width; + protected int height; + private float minU; + private float maxU; + private float minV; + private float maxV; + protected int frameCounter; + protected int tickCounter; + private static final String __OBFID = "CL_00001062"; + + protected TextureAtlasSprite(String par1Str) + { + this.iconName = par1Str; + } + + public void initSprite(int par1, int par2, int par3, int par4, boolean par5) + { + this.originX = par3; + this.originY = par4; + this.rotated = par5; + float f = (float)(0.009999999776482582D / (double)par1); + float f1 = (float)(0.009999999776482582D / (double)par2); + this.minU = (float)par3 / (float)((double)par1) + f; + this.maxU = (float)(par3 + this.width) / (float)((double)par1) - f; + this.minV = (float)par4 / (float)par2 + f1; + this.maxV = (float)(par4 + this.height) / (float)par2 - f1; + + if (this.useAnisotropicFiltering) + { + float f2 = 8.0F / (float)par1; + float f3 = 8.0F / (float)par2; + this.minU += f2; + this.maxU -= f2; + this.minV += f3; + this.maxV -= f3; + } + } + + public void copyFrom(TextureAtlasSprite par1TextureAtlasSprite) + { + this.originX = par1TextureAtlasSprite.originX; + this.originY = par1TextureAtlasSprite.originY; + this.width = par1TextureAtlasSprite.width; + this.height = par1TextureAtlasSprite.height; + this.rotated = par1TextureAtlasSprite.rotated; + this.minU = par1TextureAtlasSprite.minU; + this.maxU = par1TextureAtlasSprite.maxU; + this.minV = par1TextureAtlasSprite.minV; + this.maxV = par1TextureAtlasSprite.maxV; + } + + public int getOriginX() + { + return this.originX; + } + + public int getOriginY() + { + return this.originY; + } + + public int getIconWidth() + { + return this.width; + } + + public int getIconHeight() + { + return this.height; + } + + public float getMinU() + { + return this.minU; + } + + public float getMaxU() + { + return this.maxU; + } + + public float getInterpolatedU(double par1) + { + float f = this.maxU - this.minU; + return this.minU + f * (float)par1 / 16.0F; + } + + public float getMinV() + { + return this.minV; + } + + public float getMaxV() + { + return this.maxV; + } + + public float getInterpolatedV(double par1) + { + float f = this.maxV - this.minV; + return this.minV + f * ((float)par1 / 16.0F); + } + + public String getIconName() + { + return this.iconName; + } + + public void updateAnimation() + { + ++this.tickCounter; + + if (this.tickCounter >= this.animationMetadata.getFrameTimeSingle(this.frameCounter)) + { + int i = this.animationMetadata.getFrameIndex(this.frameCounter); + int j = this.animationMetadata.getFrameCount() == 0 ? this.framesTextureData.size() : this.animationMetadata.getFrameCount(); + this.frameCounter = (this.frameCounter + 1) % j; + this.tickCounter = 0; + int k = this.animationMetadata.getFrameIndex(this.frameCounter); + + if (i != k && k >= 0 && k < this.framesTextureData.size()) + { + TextureUtil.uploadTextureMipmap((int[][])this.framesTextureData.get(k), this.width, this.height, this.originX, this.originY, false, false); + } + } + } + + public int[][] getFrameTextureData(int p_147965_1_) + { + return (int[][])this.framesTextureData.get(p_147965_1_); + } + + public int getFrameCount() + { + return this.framesTextureData.size(); + } + + public void setIconWidth(int par1) + { + this.width = par1; + } + + public void setIconHeight(int par1) + { + this.height = par1; + } + + public void loadSprite(BufferedImage[] p_147964_1_, AnimationMetadataSection p_147964_2_, boolean p_147964_3_) + { + this.resetSprite(); + this.useAnisotropicFiltering = p_147964_3_; + int i = p_147964_1_[0].getWidth(); + int j = p_147964_1_[0].getHeight(); + this.width = i; + this.height = j; + + if (p_147964_3_) + { + this.width += 16; + this.height += 16; + } + + int[][] aint = new int[p_147964_1_.length][]; + int k; + + for (k = 0; k < p_147964_1_.length; ++k) + { + BufferedImage bufferedimage = p_147964_1_[k]; + + if (bufferedimage != null) + { + if (k > 0 && (bufferedimage.getWidth() != i >> k || bufferedimage.getHeight() != j >> k)) + { + throw new RuntimeException(String.format("Unable to load miplevel: %d, image is size: %dx%d, expected %dx%d", new Object[] {Integer.valueOf(k), Integer.valueOf(bufferedimage.getWidth()), Integer.valueOf(bufferedimage.getHeight()), Integer.valueOf(i >> k), Integer.valueOf(j >> k)})); + } + + aint[k] = new int[bufferedimage.getWidth() * bufferedimage.getHeight()]; + bufferedimage.getRGB(0, 0, bufferedimage.getWidth(), bufferedimage.getHeight(), aint[k], 0, bufferedimage.getWidth()); + } + } + + if (p_147964_2_ == null) + { + if (j != i) + { + throw new RuntimeException("broken aspect ratio and not an animation"); + } + + this.fixTransparentPixels(aint); + this.framesTextureData.add(this.prepareAnisotropicFiltering(aint, i, j)); + } + else + { + k = j / i; + int j1 = i; + int l = i; + this.height = this.width; + int i1; + + if (p_147964_2_.getFrameCount() > 0) + { + Iterator iterator = p_147964_2_.getFrameIndexSet().iterator(); + + while (iterator.hasNext()) + { + i1 = ((Integer)iterator.next()).intValue(); + + if (i1 >= k) + { + throw new RuntimeException("invalid frameindex " + i1); + } + + this.allocateFrameTextureData(i1); + this.framesTextureData.set(i1, this.prepareAnisotropicFiltering(getFrameTextureData(aint, j1, l, i1), j1, l)); + } + + this.animationMetadata = p_147964_2_; + } + else + { + ArrayList arraylist = Lists.newArrayList(); + + for (i1 = 0; i1 < k; ++i1) + { + this.framesTextureData.add(this.prepareAnisotropicFiltering(getFrameTextureData(aint, j1, l, i1), j1, l)); + arraylist.add(new AnimationFrame(i1, -1)); + } + + this.animationMetadata = new AnimationMetadataSection(arraylist, this.width, this.height, p_147964_2_.getFrameTime()); + } + } + } + + public void generateMipmaps(int p_147963_1_) + { + ArrayList arraylist = Lists.newArrayList(); + + for (int j = 0; j < this.framesTextureData.size(); ++j) + { + final int[][] aint = (int[][])this.framesTextureData.get(j); + + if (aint != null) + { + try + { + arraylist.add(TextureUtil.generateMipmapData(p_147963_1_, this.width, aint)); + } + catch (Throwable throwable) + { + CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Generating mipmaps for frame"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("Frame being iterated"); + crashreportcategory.addCrashSection("Frame index", Integer.valueOf(j)); + crashreportcategory.addCrashSectionCallable("Frame sizes", new Callable() + { + private static final String __OBFID = "CL_00001063"; + public String call() + { + StringBuilder stringbuilder = new StringBuilder(); + int[][] aint1 = aint; + int k = aint1.length; + + for (int l = 0; l < k; ++l) + { + int[] aint2 = aint1[l]; + + if (stringbuilder.length() > 0) + { + stringbuilder.append(", "); + } + + stringbuilder.append(aint2 == null ? "null" : Integer.valueOf(aint2.length)); + } + + return stringbuilder.toString(); + } + }); + throw new ReportedException(crashreport); + } + } + } + + this.setFramesTextureData(arraylist); + } + + private void fixTransparentPixels(int[][] p_147961_1_) + { + int[] aint1 = p_147961_1_[0]; + int i = 0; + int j = 0; + int k = 0; + int l = 0; + int i1; + + for (i1 = 0; i1 < aint1.length; ++i1) + { + if ((aint1[i1] & -16777216) != 0) + { + j += aint1[i1] >> 16 & 255; + k += aint1[i1] >> 8 & 255; + l += aint1[i1] >> 0 & 255; + ++i; + } + } + + if (i != 0) + { + j /= i; + k /= i; + l /= i; + + for (i1 = 0; i1 < aint1.length; ++i1) + { + if ((aint1[i1] & -16777216) == 0) + { + aint1[i1] = j << 16 | k << 8 | l; + } + } + } + } + + private int[][] prepareAnisotropicFiltering(int[][] p_147960_1_, int p_147960_2_, int p_147960_3_) + { + if (!this.useAnisotropicFiltering) + { + return p_147960_1_; + } + else + { + int[][] aint1 = new int[p_147960_1_.length][]; + + for (int k = 0; k < p_147960_1_.length; ++k) + { + int[] aint2 = p_147960_1_[k]; + + if (aint2 != null) + { + int[] aint3 = new int[(p_147960_2_ + 16 >> k) * (p_147960_3_ + 16 >> k)]; + System.arraycopy(aint2, 0, aint3, 0, aint2.length); + aint1[k] = TextureUtil.prepareAnisotropicData(aint3, p_147960_2_ >> k, p_147960_3_ >> k, 8 >> k); + } + } + + return aint1; + } + } + + private void allocateFrameTextureData(int par1) + { + if (this.framesTextureData.size() <= par1) + { + for (int j = this.framesTextureData.size(); j <= par1; ++j) + { + this.framesTextureData.add((Object)null); + } + } + } + + private static int[][] getFrameTextureData(int[][] p_147962_0_, int p_147962_1_, int p_147962_2_, int p_147962_3_) + { + int[][] aint1 = new int[p_147962_0_.length][]; + + for (int l = 0; l < p_147962_0_.length; ++l) + { + int[] aint2 = p_147962_0_[l]; + + if (aint2 != null) + { + aint1[l] = new int[(p_147962_1_ >> l) * (p_147962_2_ >> l)]; + System.arraycopy(aint2, p_147962_3_ * aint1[l].length, aint1[l], 0, aint1[l].length); + } + } + + return aint1; + } + + public void clearFramesTextureData() + { + this.framesTextureData.clear(); + } + + public boolean hasAnimationMetadata() + { + return this.animationMetadata != null; + } + + public void setFramesTextureData(List par1List) + { + this.framesTextureData = par1List; + } + + private void resetSprite() + { + this.animationMetadata = null; + this.setFramesTextureData(Lists.newArrayList()); + this.frameCounter = 0; + this.tickCounter = 0; + } + + public String toString() + { + return "TextureAtlasSprite{name=\'" + this.iconName + '\'' + ", frameCount=" + this.framesTextureData.size() + ", rotated=" + this.rotated + ", x=" + this.originX + ", y=" + this.originY + ", height=" + this.height + ", width=" + this.width + ", u0=" + this.minU + ", u1=" + this.maxU + ", v0=" + this.minV + ", v1=" + this.maxV + '}'; + } + + /** + * The result of this function determines is the below 'load' function is called, and the + * default vanilla loading code is bypassed completely. + * @param manager + * @param location + * @return True to use your own custom load code and bypass vanilla loading. + */ + public boolean hasCustomLoader(IResourceManager manager, ResourceLocation location) + { + return false; + } + + /** + * Load the specified resource as this sprite's data. + * Returning false from this function will prevent this icon from being stitched onto the master texture. + * @param manager Main resource manager + * @param location File resource location + * @return False to prevent this Icon from being stitched + */ + public boolean load(IResourceManager manager, ResourceLocation location) + { + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/texture/TextureClock.java b/src/main/java/net/minecraft/client/renderer/texture/TextureClock.java new file mode 100644 index 0000000..35f146e --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/texture/TextureClock.java @@ -0,0 +1,76 @@ +package net.minecraft.client.renderer.texture; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.Minecraft; + +@SideOnly(Side.CLIENT) +public class TextureClock extends TextureAtlasSprite +{ + private double field_94239_h; + private double field_94240_i; + private static final String __OBFID = "CL_00001070"; + + public TextureClock(String par1Str) + { + super(par1Str); + } + + public void updateAnimation() + { + if (!this.framesTextureData.isEmpty()) + { + Minecraft minecraft = Minecraft.getMinecraft(); + double d0 = 0.0D; + + if (minecraft.theWorld != null && minecraft.thePlayer != null) + { + float f = minecraft.theWorld.getCelestialAngle(1.0F); + d0 = (double)f; + + if (!minecraft.theWorld.provider.isSurfaceWorld()) + { + d0 = Math.random(); + } + } + + double d1; + + for (d1 = d0 - this.field_94239_h; d1 < -0.5D; ++d1) + { + ; + } + + while (d1 >= 0.5D) + { + --d1; + } + + if (d1 < -1.0D) + { + d1 = -1.0D; + } + + if (d1 > 1.0D) + { + d1 = 1.0D; + } + + this.field_94240_i += d1 * 0.1D; + this.field_94240_i *= 0.8D; + this.field_94239_h += this.field_94240_i; + int i; + + for (i = (int)((this.field_94239_h + 1.0D) * (double)this.framesTextureData.size()) % this.framesTextureData.size(); i < 0; i = (i + this.framesTextureData.size()) % this.framesTextureData.size()) + { + ; + } + + if (i != this.frameCounter) + { + this.frameCounter = i; + TextureUtil.uploadTextureMipmap((int[][])this.framesTextureData.get(this.frameCounter), this.width, this.height, this.originX, this.originY, false, false); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/texture/TextureCompass.java b/src/main/java/net/minecraft/client/renderer/texture/TextureCompass.java new file mode 100644 index 0000000..7679b07 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/texture/TextureCompass.java @@ -0,0 +1,102 @@ +package net.minecraft.client.renderer.texture; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.Minecraft; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.world.World; + +@SideOnly(Side.CLIENT) +public class TextureCompass extends TextureAtlasSprite +{ + public double currentAngle; + public double angleDelta; + private static final String __OBFID = "CL_00001071"; + + public TextureCompass(String par1Str) + { + super(par1Str); + } + + public void updateAnimation() + { + Minecraft minecraft = Minecraft.getMinecraft(); + + if (minecraft.theWorld != null && minecraft.thePlayer != null) + { + this.updateCompass(minecraft.theWorld, minecraft.thePlayer.posX, minecraft.thePlayer.posZ, (double)minecraft.thePlayer.rotationYaw, false, false); + } + else + { + this.updateCompass((World)null, 0.0D, 0.0D, 0.0D, true, false); + } + } + + public void updateCompass(World par1World, double par2, double par4, double par6, boolean par8, boolean par9) + { + if (!this.framesTextureData.isEmpty()) + { + double d3 = 0.0D; + + if (par1World != null && !par8) + { + ChunkCoordinates chunkcoordinates = par1World.getSpawnPoint(); + double d4 = (double)chunkcoordinates.posX - par2; + double d5 = (double)chunkcoordinates.posZ - par4; + par6 %= 360.0D; + d3 = -((par6 - 90.0D) * Math.PI / 180.0D - Math.atan2(d5, d4)); + + if (!par1World.provider.isSurfaceWorld()) + { + d3 = Math.random() * Math.PI * 2.0D; + } + } + + if (par9) + { + this.currentAngle = d3; + } + else + { + double d6; + + for (d6 = d3 - this.currentAngle; d6 < -Math.PI; d6 += (Math.PI * 2D)) + { + ; + } + + while (d6 >= Math.PI) + { + d6 -= (Math.PI * 2D); + } + + if (d6 < -1.0D) + { + d6 = -1.0D; + } + + if (d6 > 1.0D) + { + d6 = 1.0D; + } + + this.angleDelta += d6 * 0.1D; + this.angleDelta *= 0.8D; + this.currentAngle += this.angleDelta; + } + + int i; + + for (i = (int)((this.currentAngle / (Math.PI * 2D) + 1.0D) * (double)this.framesTextureData.size()) % this.framesTextureData.size(); i < 0; i = (i + this.framesTextureData.size()) % this.framesTextureData.size()) + { + ; + } + + if (i != this.frameCounter) + { + this.frameCounter = i; + TextureUtil.uploadTextureMipmap((int[][])this.framesTextureData.get(this.frameCounter), this.width, this.height, this.originX, this.originY, false, false); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/texture/TextureManager.java b/src/main/java/net/minecraft/client/renderer/texture/TextureManager.java new file mode 100644 index 0000000..5b8bc7f --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/texture/TextureManager.java @@ -0,0 +1,173 @@ +package net.minecraft.client.renderer.texture; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.concurrent.Callable; +import net.minecraft.client.resources.IResourceManager; +import net.minecraft.client.resources.IResourceManagerReloadListener; +import net.minecraft.crash.CrashReport; +import net.minecraft.crash.CrashReportCategory; +import net.minecraft.util.ReportedException; +import net.minecraft.util.ResourceLocation; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +@SideOnly(Side.CLIENT) +public class TextureManager implements ITickable, IResourceManagerReloadListener +{ + private static final Logger logger = LogManager.getLogger(); + private final Map mapTextureObjects = Maps.newHashMap(); + private final Map mapResourceLocations = Maps.newHashMap(); + private final List listTickables = Lists.newArrayList(); + private final Map mapTextureCounters = Maps.newHashMap(); + private IResourceManager theResourceManager; + private static final String __OBFID = "CL_00001064"; + + public TextureManager(IResourceManager par1ResourceManager) + { + this.theResourceManager = par1ResourceManager; + } + + public void bindTexture(ResourceLocation par1ResourceLocation) + { + Object object = (ITextureObject)this.mapTextureObjects.get(par1ResourceLocation); + + if (object == null) + { + object = new SimpleTexture(par1ResourceLocation); + this.loadTexture(par1ResourceLocation, (ITextureObject)object); + } + + TextureUtil.bindTexture(((ITextureObject)object).getGlTextureId()); + } + + public ResourceLocation getResourceLocation(int par1) + { + return (ResourceLocation)this.mapResourceLocations.get(Integer.valueOf(par1)); + } + + public boolean loadTextureMap(ResourceLocation par1ResourceLocation, TextureMap par2TextureMap) + { + if (this.loadTickableTexture(par1ResourceLocation, par2TextureMap)) + { + this.mapResourceLocations.put(Integer.valueOf(par2TextureMap.getTextureType()), par1ResourceLocation); + return true; + } + else + { + return false; + } + } + + public boolean loadTickableTexture(ResourceLocation par1ResourceLocation, ITickableTextureObject par2TickableTextureObject) + { + if (this.loadTexture(par1ResourceLocation, par2TickableTextureObject)) + { + this.listTickables.add(par2TickableTextureObject); + return true; + } + else + { + return false; + } + } + + public boolean loadTexture(ResourceLocation par1ResourceLocation, final ITextureObject par2TextureObject) + { + boolean flag = true; + ITextureObject p_110579_2_2 = par2TextureObject; + + try + { + ((ITextureObject)par2TextureObject).loadTexture(this.theResourceManager); + } + catch (IOException ioexception) + { + logger.warn("Failed to load texture: " + par1ResourceLocation, ioexception); + p_110579_2_2 = TextureUtil.missingTexture; + this.mapTextureObjects.put(par1ResourceLocation, p_110579_2_2); + flag = false; + } + catch (Throwable throwable) + { + CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Registering texture"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("Resource location being registered"); + crashreportcategory.addCrashSection("Resource location", par1ResourceLocation); + crashreportcategory.addCrashSectionCallable("Texture object class", new Callable() + { + private static final String __OBFID = "CL_00001065"; + public String call() + { + return par2TextureObject.getClass().getName(); + } + }); + throw new ReportedException(crashreport); + } + + this.mapTextureObjects.put(par1ResourceLocation, p_110579_2_2); + return flag; + } + + public ITextureObject getTexture(ResourceLocation par1ResourceLocation) + { + return (ITextureObject)this.mapTextureObjects.get(par1ResourceLocation); + } + + public ResourceLocation getDynamicTextureLocation(String par1Str, DynamicTexture par2DynamicTexture) + { + Integer integer = (Integer)this.mapTextureCounters.get(par1Str); + + if (integer == null) + { + integer = Integer.valueOf(1); + } + else + { + integer = Integer.valueOf(integer.intValue() + 1); + } + + this.mapTextureCounters.put(par1Str, integer); + ResourceLocation resourcelocation = new ResourceLocation(String.format("dynamic/%s_%d", new Object[] {par1Str, integer})); + this.loadTexture(resourcelocation, par2DynamicTexture); + return resourcelocation; + } + + public void tick() + { + Iterator iterator = this.listTickables.iterator(); + + while (iterator.hasNext()) + { + ITickable itickable = (ITickable)iterator.next(); + itickable.tick(); + } + } + + public void deleteTexture(ResourceLocation p_147645_1_) + { + ITextureObject itextureobject = this.getTexture(p_147645_1_); + + if (itextureobject != null) + { + TextureUtil.deleteTexture(itextureobject.getGlTextureId()); + } + } + + public void onResourceManagerReload(IResourceManager par1ResourceManager) + { + Iterator iterator = this.mapTextureObjects.entrySet().iterator(); + + while (iterator.hasNext()) + { + Entry entry = (Entry)iterator.next(); + this.loadTexture((ResourceLocation)entry.getKey(), (ITextureObject)entry.getValue()); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/texture/TextureMap.java b/src/main/java/net/minecraft/client/renderer/texture/TextureMap.java new file mode 100644 index 0000000..e391cba --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/texture/TextureMap.java @@ -0,0 +1,454 @@ +package net.minecraft.client.renderer.texture; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.concurrent.Callable; +import javax.imageio.ImageIO; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.StitcherException; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.resources.IResource; +import net.minecraft.client.resources.IResourceManager; +import net.minecraft.client.resources.data.AnimationMetadataSection; +import net.minecraft.client.resources.data.TextureMetadataSection; +import net.minecraft.crash.CrashReport; +import net.minecraft.crash.CrashReportCategory; +import net.minecraft.item.Item; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ReportedException; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.ForgeHooksClient; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +@SideOnly(Side.CLIENT) +public class TextureMap extends AbstractTexture implements ITickableTextureObject, IIconRegister +{ + private static final Logger logger = LogManager.getLogger(); + public static final ResourceLocation locationBlocksTexture = new ResourceLocation("textures/atlas/blocks.png"); + public static final ResourceLocation locationItemsTexture = new ResourceLocation("textures/atlas/items.png"); + private final List listAnimatedSprites = Lists.newArrayList(); + private final Map mapRegisteredSprites = Maps.newHashMap(); + private final Map mapUploadedSprites = Maps.newHashMap(); + private final int textureType; + private final String basePath; + private int mipmapLevels; + private int anisotropicFiltering = 1; + private final TextureAtlasSprite missingImage = new TextureAtlasSprite("missingno"); + private static final String __OBFID = "CL_00001058"; + + public TextureMap(int par1, String par2Str) + { + this.textureType = par1; + this.basePath = par2Str; + this.registerIcons(); + } + + private void initMissingImage() + { + int[] aint; + + if ((float)this.anisotropicFiltering > 1.0F) + { + boolean flag = true; + boolean flag1 = true; + boolean flag2 = true; + this.missingImage.setIconWidth(32); + this.missingImage.setIconHeight(32); + aint = new int[1024]; + System.arraycopy(TextureUtil.missingTextureData, 0, aint, 0, TextureUtil.missingTextureData.length); + TextureUtil.prepareAnisotropicData(aint, 16, 16, 8); + } + else + { + aint = TextureUtil.missingTextureData; + this.missingImage.setIconWidth(16); + this.missingImage.setIconHeight(16); + } + + int[][] aint1 = new int[this.mipmapLevels + 1][]; + aint1[0] = aint; + this.missingImage.setFramesTextureData(Lists.newArrayList(new int[][][] {aint1})); + } + + public void loadTexture(IResourceManager par1ResourceManager) throws IOException + { + this.initMissingImage(); + this.deleteGlTexture(); + this.loadTextureAtlas(par1ResourceManager); + } + + public void loadTextureAtlas(IResourceManager par1ResourceManager) + { + registerIcons(); //Re-gather list of Icons, allows for addition/removal of blocks/items after this map was initially constructed. + + int i = Minecraft.getGLMaximumTextureSize(); + Stitcher stitcher = new Stitcher(i, i, true, 0, this.mipmapLevels); + this.mapUploadedSprites.clear(); + this.listAnimatedSprites.clear(); + int j = Integer.MAX_VALUE; + ForgeHooksClient.onTextureStitchedPre(this); + Iterator iterator = this.mapRegisteredSprites.entrySet().iterator(); + TextureAtlasSprite textureatlassprite; + + while (iterator.hasNext()) + { + Entry entry = (Entry)iterator.next(); + ResourceLocation resourcelocation = new ResourceLocation((String)entry.getKey()); + textureatlassprite = (TextureAtlasSprite)entry.getValue(); + ResourceLocation resourcelocation1 = this.completeResourceLocation(resourcelocation, 0); + + if (textureatlassprite.hasCustomLoader(par1ResourceManager, resourcelocation)) + { + if (!textureatlassprite.load(par1ResourceManager, resourcelocation)) + { + j = Math.min(j, Math.min(textureatlassprite.getIconWidth(), textureatlassprite.getIconHeight())); + stitcher.addSprite(textureatlassprite); + } + continue; + } + + try + { + IResource iresource = par1ResourceManager.getResource(resourcelocation1); + BufferedImage[] abufferedimage = new BufferedImage[1 + this.mipmapLevels]; + abufferedimage[0] = ImageIO.read(iresource.getInputStream()); + TextureMetadataSection texturemetadatasection = (TextureMetadataSection)iresource.getMetadata("texture"); + + if (texturemetadatasection != null) + { + List list = texturemetadatasection.getListMipmaps(); + int l; + + if (!list.isEmpty()) + { + int k = abufferedimage[0].getWidth(); + l = abufferedimage[0].getHeight(); + + if (MathHelper.roundUpToPowerOfTwo(k) != k || MathHelper.roundUpToPowerOfTwo(l) != l) + { + throw new RuntimeException("Unable to load extra miplevels, source-texture is not power of two"); + } + } + + Iterator iterator3 = list.iterator(); + + while (iterator3.hasNext()) + { + l = ((Integer)iterator3.next()).intValue(); + + if (l > 0 && l < abufferedimage.length - 1 && abufferedimage[l] == null) + { + ResourceLocation resourcelocation2 = this.completeResourceLocation(resourcelocation, l); + + try + { + abufferedimage[l] = ImageIO.read(par1ResourceManager.getResource(resourcelocation2).getInputStream()); + } + catch (IOException ioexception) + { + logger.error("Unable to load miplevel {} from: {}", new Object[] {Integer.valueOf(l), resourcelocation2, ioexception}); + } + } + } + } + + AnimationMetadataSection animationmetadatasection = (AnimationMetadataSection)iresource.getMetadata("animation"); + textureatlassprite.loadSprite(abufferedimage, animationmetadatasection, (float)this.anisotropicFiltering > 1.0F); + } + catch (RuntimeException runtimeexception) + { + logger.error("Unable to parse metadata from " + resourcelocation1, runtimeexception); + continue; + } + catch (IOException ioexception1) + { + logger.error("Using missing texture, unable to load " + resourcelocation1, ioexception1); + continue; + } + + j = Math.min(j, Math.min(textureatlassprite.getIconWidth(), textureatlassprite.getIconHeight())); + stitcher.addSprite(textureatlassprite); + } + + int i1 = MathHelper.calculateLogBaseTwo(j); + + if (i1 < this.mipmapLevels) + { + logger.debug("{}: dropping miplevel from {} to {}, because of minTexel: {}", new Object[] {this.basePath, Integer.valueOf(this.mipmapLevels), Integer.valueOf(i1), Integer.valueOf(j)}); + this.mipmapLevels = i1; + } + + Iterator iterator1 = this.mapRegisteredSprites.values().iterator(); + + while (iterator1.hasNext()) + { + final TextureAtlasSprite textureatlassprite1 = (TextureAtlasSprite)iterator1.next(); + + try + { + textureatlassprite1.generateMipmaps(this.mipmapLevels); + } + catch (Throwable throwable1) + { + CrashReport crashreport = CrashReport.makeCrashReport(throwable1, "Applying mipmap"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("Sprite being mipmapped"); + crashreportcategory.addCrashSectionCallable("Sprite name", new Callable() + { + private static final String __OBFID = "CL_00001059"; + public String call() + { + return textureatlassprite1.getIconName(); + } + }); + crashreportcategory.addCrashSectionCallable("Sprite size", new Callable() + { + private static final String __OBFID = "CL_00001060"; + public String call() + { + return textureatlassprite1.getIconWidth() + " x " + textureatlassprite1.getIconHeight(); + } + }); + crashreportcategory.addCrashSectionCallable("Sprite frames", new Callable() + { + private static final String __OBFID = "CL_00001061"; + public String call() + { + return textureatlassprite1.getFrameCount() + " frames"; + } + }); + crashreportcategory.addCrashSection("Mipmap levels", Integer.valueOf(this.mipmapLevels)); + throw new ReportedException(crashreport); + } + } + + this.missingImage.generateMipmaps(this.mipmapLevels); + stitcher.addSprite(this.missingImage); + + try + { + stitcher.doStitch(); + } + catch (StitcherException stitcherexception) + { + throw stitcherexception; + } + + logger.info("Created: {}x{} {}-atlas", new Object[] {Integer.valueOf(stitcher.getCurrentWidth()), Integer.valueOf(stitcher.getCurrentHeight()), this.basePath}); + TextureUtil.allocateTextureImpl(this.getGlTextureId(), this.mipmapLevels, stitcher.getCurrentWidth(), stitcher.getCurrentHeight(), (float)this.anisotropicFiltering); + HashMap hashmap = Maps.newHashMap(this.mapRegisteredSprites); + Iterator iterator2 = stitcher.getStichSlots().iterator(); + + while (iterator2.hasNext()) + { + textureatlassprite = (TextureAtlasSprite)iterator2.next(); + String s = textureatlassprite.getIconName(); + hashmap.remove(s); + this.mapUploadedSprites.put(s, textureatlassprite); + + try + { + TextureUtil.uploadTextureMipmap(textureatlassprite.getFrameTextureData(0), textureatlassprite.getIconWidth(), textureatlassprite.getIconHeight(), textureatlassprite.getOriginX(), textureatlassprite.getOriginY(), false, false); + } + catch (Throwable throwable) + { + CrashReport crashreport1 = CrashReport.makeCrashReport(throwable, "Stitching texture atlas"); + CrashReportCategory crashreportcategory1 = crashreport1.makeCategory("Texture being stitched together"); + crashreportcategory1.addCrashSection("Atlas path", this.basePath); + crashreportcategory1.addCrashSection("Sprite", textureatlassprite); + throw new ReportedException(crashreport1); + } + + if (textureatlassprite.hasAnimationMetadata()) + { + this.listAnimatedSprites.add(textureatlassprite); + } + else + { + textureatlassprite.clearFramesTextureData(); + } + } + + iterator2 = hashmap.values().iterator(); + + while (iterator2.hasNext()) + { + textureatlassprite = (TextureAtlasSprite)iterator2.next(); + textureatlassprite.copyFrom(this.missingImage); + } + ForgeHooksClient.onTextureStitchedPost(this); + } + + private ResourceLocation completeResourceLocation(ResourceLocation p_147634_1_, int p_147634_2_) + { + return p_147634_2_ == 0 ? new ResourceLocation(p_147634_1_.getResourceDomain(), String.format("%s/%s%s", new Object[] {this.basePath, p_147634_1_.getResourcePath(), ".png"})): new ResourceLocation(p_147634_1_.getResourceDomain(), String.format("%s/mipmaps/%s.%d%s", new Object[] {this.basePath, p_147634_1_.getResourcePath(), Integer.valueOf(p_147634_2_), ".png"})); + } + + private void registerIcons() + { + this.mapRegisteredSprites.clear(); + Iterator iterator; + + if (this.textureType == 0) + { + iterator = Block.blockRegistry.iterator(); + + while (iterator.hasNext()) + { + Block block = (Block)iterator.next(); + + if (block.getMaterial() != Material.air) + { + block.registerBlockIcons(this); + } + } + + Minecraft.getMinecraft().renderGlobal.registerDestroyBlockIcons(this); + RenderManager.instance.updateIcons(this); + } + + iterator = Item.itemRegistry.iterator(); + + while (iterator.hasNext()) + { + Item item = (Item)iterator.next(); + + if (item != null && item.getSpriteNumber() == this.textureType) + { + item.registerIcons(this); + } + } + } + + public TextureAtlasSprite getAtlasSprite(String par1Str) + { + TextureAtlasSprite textureatlassprite = (TextureAtlasSprite)this.mapUploadedSprites.get(par1Str); + + if (textureatlassprite == null) + { + textureatlassprite = this.missingImage; + } + + return textureatlassprite; + } + + public void updateAnimations() + { + TextureUtil.bindTexture(this.getGlTextureId()); + Iterator iterator = this.listAnimatedSprites.iterator(); + + while (iterator.hasNext()) + { + TextureAtlasSprite textureatlassprite = (TextureAtlasSprite)iterator.next(); + textureatlassprite.updateAnimation(); + } + } + + public IIcon registerIcon(String par1Str) + { + if (par1Str == null) + { + throw new IllegalArgumentException("Name cannot be null!"); + } + else if (par1Str.indexOf(92) == -1) // Disable backslashes (\) in texture asset paths. + { + Object object = (TextureAtlasSprite)this.mapRegisteredSprites.get(par1Str); + + if (object == null) + { + if (this.textureType == 1) + { + if ("clock".equals(par1Str)) + { + object = new TextureClock(par1Str); + } + else if ("compass".equals(par1Str)) + { + object = new TextureCompass(par1Str); + } + else + { + object = new TextureAtlasSprite(par1Str); + } + } + else + { + object = new TextureAtlasSprite(par1Str); + } + + this.mapRegisteredSprites.put(par1Str, object); + } + + return (IIcon)object; + } + else + { + throw new IllegalArgumentException("Name cannot contain slashes!"); + } + } + + public int getTextureType() + { + return this.textureType; + } + + public void tick() + { + this.updateAnimations(); + } + + public void setMipmapLevels(int p_147633_1_) + { + this.mipmapLevels = p_147633_1_; + } + + public void setAnisotropicFiltering(int p_147632_1_) + { + this.anisotropicFiltering = p_147632_1_; + } + + //=================================================================================================== + // Forge Start + //=================================================================================================== + /** + * Grabs the registered entry for the specified name, returning null if there was not a entry. + * Opposed to registerIcon, this will not instantiate the entry, useful to test if a mapping exists. + * + * @param name The name of the entry to find + * @return The registered entry, null if nothing was registered. + */ + public TextureAtlasSprite getTextureExtry(String name) + { + return (TextureAtlasSprite)mapRegisteredSprites.get(name); + } + + /** + * Adds a texture registry entry to this map for the specified name if one does not already exist. + * Returns false if the map already contains a entry for the specified name. + * + * @param name Entry name + * @param entry Entry instance + * @return True if the entry was added to the map, false otherwise. + */ + public boolean setTextureEntry(String name, TextureAtlasSprite entry) + { + if (!mapRegisteredSprites.containsKey(name)) + { + mapRegisteredSprites.put(name, entry); + return true; + } + return false; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/texture/TextureUtil.java b/src/main/java/net/minecraft/client/renderer/texture/TextureUtil.java new file mode 100644 index 0000000..296cc42 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/texture/TextureUtil.java @@ -0,0 +1,432 @@ +package net.minecraft.client.renderer.texture; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.nio.IntBuffer; +import javax.imageio.ImageIO; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GLAllocation; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.resources.IResourceManager; +import net.minecraft.util.ResourceLocation; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; +import org.lwjgl.opengl.GL12; + +@SideOnly(Side.CLIENT) +public class TextureUtil +{ + private static final Logger logger = LogManager.getLogger(); + private static final IntBuffer dataBuffer = GLAllocation.createDirectIntBuffer(4194304); + public static final DynamicTexture missingTexture = new DynamicTexture(16, 16); + public static final int[] missingTextureData = missingTexture.getTextureData(); + private static int field_147958_e = -1; + private static int field_147956_f = -1; + private static final int[] field_147957_g; + private static final String __OBFID = "CL_00001067"; + + public static int glGenTextures() + { + return GL11.glGenTextures(); + } + + public static void deleteTexture(int p_147942_0_) + { + GL11.glDeleteTextures(p_147942_0_); + } + + public static int uploadTextureImage(int par0, BufferedImage par1BufferedImage) + { + return uploadTextureImageAllocate(par0, par1BufferedImage, false, false); + } + + public static void uploadTexture(int par0, int[] par1ArrayOfInteger, int par2, int par3) + { + bindTexture(par0); + uploadTextureSub(0, par1ArrayOfInteger, par2, par3, 0, 0, false, false, false); + } + + public static int[][] generateMipmapData(int p_147949_0_, int p_147949_1_, int[][] p_147949_2_) + { + int[][] aint1 = new int[p_147949_0_ + 1][]; + aint1[0] = p_147949_2_[0]; + + if (p_147949_0_ > 0) + { + boolean flag = false; + int k; + + for (k = 0; k < p_147949_2_.length; ++k) + { + if (p_147949_2_[0][k] >> 24 == 0) + { + flag = true; + break; + } + } + + for (k = 1; k <= p_147949_0_; ++k) + { + if (p_147949_2_[k] != null) + { + aint1[k] = p_147949_2_[k]; + } + else + { + int[] aint2 = aint1[k - 1]; + int[] aint3 = new int[aint2.length >> 2]; + int l = p_147949_1_ >> k; + int i1 = aint3.length / l; + int j1 = l << 1; + + for (int k1 = 0; k1 < l; ++k1) + { + for (int l1 = 0; l1 < i1; ++l1) + { + int i2 = 2 * (k1 + l1 * j1); + aint3[k1 + l1 * l] = func_147943_a(aint2[i2 + 0], aint2[i2 + 1], aint2[i2 + 0 + j1], aint2[i2 + 1 + j1], flag); + } + } + + aint1[k] = aint3; + } + } + } + + return aint1; + } + + private static int func_147943_a(int p_147943_0_, int p_147943_1_, int p_147943_2_, int p_147943_3_, boolean p_147943_4_) + { + if (!p_147943_4_) + { + int i2 = func_147944_a(p_147943_0_, p_147943_1_, p_147943_2_, p_147943_3_, 24); + int j2 = func_147944_a(p_147943_0_, p_147943_1_, p_147943_2_, p_147943_3_, 16); + int k2 = func_147944_a(p_147943_0_, p_147943_1_, p_147943_2_, p_147943_3_, 8); + int l2 = func_147944_a(p_147943_0_, p_147943_1_, p_147943_2_, p_147943_3_, 0); + return i2 << 24 | j2 << 16 | k2 << 8 | l2; + } + else + { + field_147957_g[0] = p_147943_0_; + field_147957_g[1] = p_147943_1_; + field_147957_g[2] = p_147943_2_; + field_147957_g[3] = p_147943_3_; + float f = 0.0F; + float f1 = 0.0F; + float f2 = 0.0F; + float f3 = 0.0F; + int i1; + + for (i1 = 0; i1 < 4; ++i1) + { + if (field_147957_g[i1] >> 24 != 0) + { + f += (float)Math.pow((double)((float)(field_147957_g[i1] >> 24 & 255) / 255.0F), 2.2D); + f1 += (float)Math.pow((double)((float)(field_147957_g[i1] >> 16 & 255) / 255.0F), 2.2D); + f2 += (float)Math.pow((double)((float)(field_147957_g[i1] >> 8 & 255) / 255.0F), 2.2D); + f3 += (float)Math.pow((double)((float)(field_147957_g[i1] >> 0 & 255) / 255.0F), 2.2D); + } + } + + f /= 4.0F; + f1 /= 4.0F; + f2 /= 4.0F; + f3 /= 4.0F; + i1 = (int)(Math.pow((double)f, 0.45454545454545453D) * 255.0D); + int j1 = (int)(Math.pow((double)f1, 0.45454545454545453D) * 255.0D); + int k1 = (int)(Math.pow((double)f2, 0.45454545454545453D) * 255.0D); + int l1 = (int)(Math.pow((double)f3, 0.45454545454545453D) * 255.0D); + + if (i1 < 96) + { + i1 = 0; + } + + return i1 << 24 | j1 << 16 | k1 << 8 | l1; + } + } + + private static int func_147944_a(int p_147944_0_, int p_147944_1_, int p_147944_2_, int p_147944_3_, int p_147944_4_) + { + float f = (float)Math.pow((double)((float)(p_147944_0_ >> p_147944_4_ & 255) / 255.0F), 2.2D); + float f1 = (float)Math.pow((double)((float)(p_147944_1_ >> p_147944_4_ & 255) / 255.0F), 2.2D); + float f2 = (float)Math.pow((double)((float)(p_147944_2_ >> p_147944_4_ & 255) / 255.0F), 2.2D); + float f3 = (float)Math.pow((double)((float)(p_147944_3_ >> p_147944_4_ & 255) / 255.0F), 2.2D); + float f4 = (float)Math.pow((double)(f + f1 + f2 + f3) * 0.25D, 0.45454545454545453D); + return (int)((double)f4 * 255.0D); + } + + public static void uploadTextureMipmap(int[][] p_147955_0_, int p_147955_1_, int p_147955_2_, int p_147955_3_, int p_147955_4_, boolean p_147955_5_, boolean p_147955_6_) + { + for (int i1 = 0; i1 < p_147955_0_.length; ++i1) + { + int[] aint1 = p_147955_0_[i1]; + uploadTextureSub(i1, aint1, p_147955_1_ >> i1, p_147955_2_ >> i1, p_147955_3_ >> i1, p_147955_4_ >> i1, p_147955_5_, p_147955_6_, p_147955_0_.length > 1); + } + } + + private static void uploadTextureSub(int p_147947_0_, int[] p_147947_1_, int p_147947_2_, int p_147947_3_, int p_147947_4_, int p_147947_5_, boolean p_147947_6_, boolean p_147947_7_, boolean p_147947_8_) + { + int j1 = 4194304 / p_147947_2_; + func_147954_b(p_147947_6_, p_147947_8_); + setTextureClamped(p_147947_7_); + int i2; + + for (int k1 = 0; k1 < p_147947_2_ * p_147947_3_; k1 += p_147947_2_ * i2) + { + int l1 = k1 / p_147947_2_; + i2 = Math.min(j1, p_147947_3_ - l1); + int j2 = p_147947_2_ * i2; + copyToBufferPos(p_147947_1_, k1, j2); + GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, p_147947_0_, p_147947_4_, p_147947_5_ + l1, p_147947_2_, i2, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, dataBuffer); + } + } + + public static int uploadTextureImageAllocate(int par0, BufferedImage par1BufferedImage, boolean par2, boolean par3) + { + allocateTexture(par0, par1BufferedImage.getWidth(), par1BufferedImage.getHeight()); + return uploadTextureImageSub(par0, par1BufferedImage, 0, 0, par2, par3); + } + + public static void allocateTexture(int par0, int par1, int par2) + { + allocateTextureImpl(par0, 0, par1, par2, 1.0F); + } + + public static void allocateTextureImpl(int p_147946_0_, int p_147946_1_, int p_147946_2_, int p_147946_3_, float p_147946_4_) + { + deleteTexture(p_147946_0_); + bindTexture(p_147946_0_); + + if (OpenGlHelper.anisotropicFilteringSupported) + { + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, 34046, p_147946_4_); + } + + if (p_147946_1_ > 0) + { + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LEVEL, p_147946_1_); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MIN_LOD, 0.0F); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LOD, (float)p_147946_1_); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, 0.0F); + } + + for (int i1 = 0; i1 <= p_147946_1_; ++i1) + { + GL11.glTexImage2D(GL11.GL_TEXTURE_2D, i1, GL11.GL_RGBA, p_147946_2_ >> i1, p_147946_3_ >> i1, 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, (IntBuffer)null); + } + } + + public static int uploadTextureImageSub(int par0, BufferedImage par1BufferedImage, int par2, int par3, boolean par4, boolean par5) + { + bindTexture(par0); + uploadTextureImageSubImpl(par1BufferedImage, par2, par3, par4, par5); + return par0; + } + + private static void uploadTextureImageSubImpl(BufferedImage par0BufferedImage, int par1, int par2, boolean par3, boolean par4) + { + int k = par0BufferedImage.getWidth(); + int l = par0BufferedImage.getHeight(); + int i1 = 4194304 / k; + int[] aint = new int[i1 * k]; + setTextureBlurred(par3); + setTextureClamped(par4); + + for (int j1 = 0; j1 < k * l; j1 += k * i1) + { + int k1 = j1 / k; + int l1 = Math.min(i1, l - k1); + int i2 = k * l1; + par0BufferedImage.getRGB(0, k1, k, l1, aint, 0, k); + copyToBuffer(aint, i2); + GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, par1, par2 + k1, k, l1, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, dataBuffer); + } + } + + private static void setTextureClamped(boolean par0) + { + if (par0) + { + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP); + } + else + { + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT); + } + } + + private static void setTextureBlurred(boolean p_147951_0_) + { + func_147954_b(p_147951_0_, false); + } + + public static void func_147950_a(boolean p_147950_0_, boolean p_147950_1_) + { + field_147958_e = GL11.glGetTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER); + field_147956_f = GL11.glGetTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER); + func_147954_b(p_147950_0_, p_147950_1_); + } + + public static void func_147945_b() + { + if (field_147958_e >= 0 && field_147956_f >= 0) + { + func_147952_b(field_147958_e, field_147956_f); + field_147958_e = -1; + field_147956_f = -1; + } + } + + private static void func_147952_b(int p_147952_0_, int p_147952_1_) + { + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, p_147952_0_); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, p_147952_1_); + } + + private static void func_147954_b(boolean p_147954_0_, boolean p_147954_1_) + { + if (p_147954_0_) + { + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, p_147954_1_ ? GL11.GL_LINEAR_MIPMAP_LINEAR : GL11.GL_LINEAR); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); + } + else + { + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, p_147954_1_ ? GL11.GL_NEAREST_MIPMAP_LINEAR : GL11.GL_NEAREST); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); + } + } + + private static void copyToBuffer(int[] par0ArrayOfInteger, int par1) + { + copyToBufferPos(par0ArrayOfInteger, 0, par1); + } + + private static void copyToBufferPos(int[] par0ArrayOfInteger, int par1, int par2) + { + int[] aint1 = par0ArrayOfInteger; + + if (Minecraft.getMinecraft().gameSettings.anaglyph) + { + aint1 = updateAnaglyph(par0ArrayOfInteger); + } + + dataBuffer.clear(); + dataBuffer.put(aint1, par1, par2); + dataBuffer.position(0).limit(par2); + } + + static void bindTexture(int par0) + { + GL11.glBindTexture(GL11.GL_TEXTURE_2D, par0); + } + + public static int[] readImageData(IResourceManager par0ResourceManager, ResourceLocation par1ResourceLocation) throws IOException + { + BufferedImage bufferedimage = ImageIO.read(par0ResourceManager.getResource(par1ResourceLocation).getInputStream()); + int i = bufferedimage.getWidth(); + int j = bufferedimage.getHeight(); + int[] aint = new int[i * j]; + bufferedimage.getRGB(0, 0, i, j, aint, 0, i); + return aint; + } + + public static int[] updateAnaglyph(int[] par0ArrayOfInteger) + { + int[] aint1 = new int[par0ArrayOfInteger.length]; + + for (int i = 0; i < par0ArrayOfInteger.length; ++i) + { + int j = par0ArrayOfInteger[i] >> 24 & 255; + int k = par0ArrayOfInteger[i] >> 16 & 255; + int l = par0ArrayOfInteger[i] >> 8 & 255; + int i1 = par0ArrayOfInteger[i] & 255; + int j1 = (k * 30 + l * 59 + i1 * 11) / 100; + int k1 = (k * 30 + l * 70) / 100; + int l1 = (k * 30 + i1 * 70) / 100; + aint1[i] = j << 24 | j1 << 16 | k1 << 8 | l1; + } + + return aint1; + } + + public static int[] prepareAnisotropicData(int[] p_147948_0_, int p_147948_1_, int p_147948_2_, int p_147948_3_) + { + int l = p_147948_1_ + 2 * p_147948_3_; + int i1; + int j1; + + for (i1 = p_147948_2_ - 1; i1 >= 0; --i1) + { + j1 = i1 * p_147948_1_; + int k1 = p_147948_3_ + (i1 + p_147948_3_) * l; + int l1; + + for (l1 = 0; l1 < p_147948_3_; l1 += p_147948_1_) + { + int i2 = Math.min(p_147948_1_, p_147948_3_ - l1); + System.arraycopy(p_147948_0_, j1 + p_147948_1_ - i2, p_147948_0_, k1 - l1 - i2, i2); + } + + System.arraycopy(p_147948_0_, j1, p_147948_0_, k1, p_147948_1_); + + for (l1 = 0; l1 < p_147948_3_; l1 += p_147948_1_) + { + System.arraycopy(p_147948_0_, j1, p_147948_0_, k1 + p_147948_1_ + l1, Math.min(p_147948_1_, p_147948_3_ - l1)); + } + } + + for (i1 = 0; i1 < p_147948_3_; i1 += p_147948_2_) + { + j1 = Math.min(p_147948_2_, p_147948_3_ - i1); + System.arraycopy(p_147948_0_, (p_147948_3_ + p_147948_2_ - j1) * l, p_147948_0_, (p_147948_3_ - i1 - j1) * l, l * j1); + } + + for (i1 = 0; i1 < p_147948_3_; i1 += p_147948_2_) + { + j1 = Math.min(p_147948_2_, p_147948_3_ - i1); + System.arraycopy(p_147948_0_, p_147948_3_ * l, p_147948_0_, (p_147948_2_ + p_147948_3_ + i1) * l, l * j1); + } + + return p_147948_0_; + } + + public static void func_147953_a(int[] p_147953_0_, int p_147953_1_, int p_147953_2_) + { + int[] aint1 = new int[p_147953_1_]; + int k = p_147953_2_ / 2; + + for (int l = 0; l < k; ++l) + { + System.arraycopy(p_147953_0_, l * p_147953_1_, aint1, 0, p_147953_1_); + System.arraycopy(p_147953_0_, (p_147953_2_ - 1 - l) * p_147953_1_, p_147953_0_, l * p_147953_1_, p_147953_1_); + System.arraycopy(aint1, 0, p_147953_0_, (p_147953_2_ - 1 - l) * p_147953_1_, p_147953_1_); + } + } + + static + { + int var0 = -16777216; + int var1 = -524040; + int[] var2 = new int[] { -524040, -524040, -524040, -524040, -524040, -524040, -524040, -524040}; + int[] var3 = new int[] { -16777216, -16777216, -16777216, -16777216, -16777216, -16777216, -16777216, -16777216}; + int var4 = var2.length; + + for (int var5 = 0; var5 < 16; ++var5) + { + System.arraycopy(var5 < var4 ? var2 : var3, 0, missingTextureData, 16 * var5, var4); + System.arraycopy(var5 < var4 ? var3 : var2, 0, missingTextureData, 16 * var5 + var4, var4); + } + + missingTexture.updateDynamicTexture(); + field_147957_g = new int[4]; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/tileentity/RenderEndPortal.java b/src/main/java/net/minecraft/client/renderer/tileentity/RenderEndPortal.java new file mode 100644 index 0000000..bfd5693 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/tileentity/RenderEndPortal.java @@ -0,0 +1,132 @@ +package net.minecraft.client.renderer.tileentity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.nio.FloatBuffer; +import java.util.Random; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.ActiveRenderInfo; +import net.minecraft.client.renderer.GLAllocation; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityEndPortal; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class RenderEndPortal extends TileEntitySpecialRenderer +{ + private static final ResourceLocation field_147529_c = new ResourceLocation("textures/environment/end_sky.png"); + private static final ResourceLocation field_147526_d = new ResourceLocation("textures/entity/end_portal.png"); + private static final Random field_147527_e = new Random(31100L); + FloatBuffer field_147528_b = GLAllocation.createDirectFloatBuffer(16); + private static final String __OBFID = "CL_00000972"; + + public void renderTileEntityAt(TileEntityEndPortal p_147524_1_, double p_147524_2_, double p_147524_4_, double p_147524_6_, float p_147524_8_) + { + float f1 = (float)this.field_147501_a.field_147560_j; + float f2 = (float)this.field_147501_a.field_147561_k; + float f3 = (float)this.field_147501_a.field_147558_l; + GL11.glDisable(GL11.GL_LIGHTING); + field_147527_e.setSeed(31100L); + float f4 = 0.75F; + + for (int i = 0; i < 16; ++i) + { + GL11.glPushMatrix(); + float f5 = (float)(16 - i); + float f6 = 0.0625F; + float f7 = 1.0F / (f5 + 1.0F); + + if (i == 0) + { + this.bindTexture(field_147529_c); + f7 = 0.1F; + f5 = 65.0F; + f6 = 0.125F; + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + } + + if (i == 1) + { + this.bindTexture(field_147526_d); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); + f6 = 0.5F; + } + + float f8 = (float)(-(p_147524_4_ + (double)f4)); + float f9 = f8 + ActiveRenderInfo.objectY; + float f10 = f8 + f5 + ActiveRenderInfo.objectY; + float f11 = f9 / f10; + f11 += (float)(p_147524_4_ + (double)f4); + GL11.glTranslatef(f1, f11, f3); + GL11.glTexGeni(GL11.GL_S, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR); + GL11.glTexGeni(GL11.GL_T, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR); + GL11.glTexGeni(GL11.GL_R, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR); + GL11.glTexGeni(GL11.GL_Q, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_EYE_LINEAR); + GL11.glTexGen(GL11.GL_S, GL11.GL_OBJECT_PLANE, this.func_147525_a(1.0F, 0.0F, 0.0F, 0.0F)); + GL11.glTexGen(GL11.GL_T, GL11.GL_OBJECT_PLANE, this.func_147525_a(0.0F, 0.0F, 1.0F, 0.0F)); + GL11.glTexGen(GL11.GL_R, GL11.GL_OBJECT_PLANE, this.func_147525_a(0.0F, 0.0F, 0.0F, 1.0F)); + GL11.glTexGen(GL11.GL_Q, GL11.GL_EYE_PLANE, this.func_147525_a(0.0F, 1.0F, 0.0F, 0.0F)); + GL11.glEnable(GL11.GL_TEXTURE_GEN_S); + GL11.glEnable(GL11.GL_TEXTURE_GEN_T); + GL11.glEnable(GL11.GL_TEXTURE_GEN_R); + GL11.glEnable(GL11.GL_TEXTURE_GEN_Q); + GL11.glPopMatrix(); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glPushMatrix(); + GL11.glLoadIdentity(); + GL11.glTranslatef(0.0F, (float)(Minecraft.getSystemTime() % 700000L) / 700000.0F, 0.0F); + GL11.glScalef(f6, f6, f6); + GL11.glTranslatef(0.5F, 0.5F, 0.0F); + GL11.glRotatef((float)(i * i * 4321 + i * 9) * 2.0F, 0.0F, 0.0F, 1.0F); + GL11.glTranslatef(-0.5F, -0.5F, 0.0F); + GL11.glTranslatef(-f1, -f3, -f2); + f9 = f8 + ActiveRenderInfo.objectY; + GL11.glTranslatef(ActiveRenderInfo.objectX * f5 / f9, ActiveRenderInfo.objectZ * f5 / f9, -f2); + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + f11 = field_147527_e.nextFloat() * 0.5F + 0.1F; + float f12 = field_147527_e.nextFloat() * 0.5F + 0.4F; + float f13 = field_147527_e.nextFloat() * 0.5F + 0.5F; + + if (i == 0) + { + f13 = 1.0F; + f12 = 1.0F; + f11 = 1.0F; + } + + tessellator.setColorRGBA_F(f11 * f7, f12 * f7, f13 * f7, 1.0F); + tessellator.addVertex(p_147524_2_, p_147524_4_ + (double)f4, p_147524_6_); + tessellator.addVertex(p_147524_2_, p_147524_4_ + (double)f4, p_147524_6_ + 1.0D); + tessellator.addVertex(p_147524_2_ + 1.0D, p_147524_4_ + (double)f4, p_147524_6_ + 1.0D); + tessellator.addVertex(p_147524_2_ + 1.0D, p_147524_4_ + (double)f4, p_147524_6_); + tessellator.draw(); + GL11.glPopMatrix(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + } + + GL11.glDisable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_TEXTURE_GEN_S); + GL11.glDisable(GL11.GL_TEXTURE_GEN_T); + GL11.glDisable(GL11.GL_TEXTURE_GEN_R); + GL11.glDisable(GL11.GL_TEXTURE_GEN_Q); + GL11.glEnable(GL11.GL_LIGHTING); + } + + private FloatBuffer func_147525_a(float p_147525_1_, float p_147525_2_, float p_147525_3_, float p_147525_4_) + { + this.field_147528_b.clear(); + this.field_147528_b.put(p_147525_1_).put(p_147525_2_).put(p_147525_3_).put(p_147525_4_); + this.field_147528_b.flip(); + return this.field_147528_b; + } + + public void renderTileEntityAt(TileEntity p_147500_1_, double p_147500_2_, double p_147500_4_, double p_147500_6_, float p_147500_8_) + { + this.renderTileEntityAt((TileEntityEndPortal)p_147500_1_, p_147500_2_, p_147500_4_, p_147500_6_, p_147500_8_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/tileentity/RenderEnderCrystal.java b/src/main/java/net/minecraft/client/renderer/tileentity/RenderEnderCrystal.java new file mode 100644 index 0000000..6498084 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/tileentity/RenderEnderCrystal.java @@ -0,0 +1,53 @@ +package net.minecraft.client.renderer.tileentity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelEnderCrystal; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityEnderCrystal; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class RenderEnderCrystal extends Render +{ + private static final ResourceLocation enderCrystalTextures = new ResourceLocation("textures/entity/endercrystal/endercrystal.png"); + private ModelBase field_76995_b; + private static final String __OBFID = "CL_00000987"; + + public RenderEnderCrystal() + { + this.shadowSize = 0.5F; + this.field_76995_b = new ModelEnderCrystal(0.0F, true); + } + + public void doRender(EntityEnderCrystal par1EntityEnderCrystal, double par2, double par4, double par6, float par8, float par9) + { + float f2 = (float)par1EntityEnderCrystal.innerRotation + par9; + GL11.glPushMatrix(); + GL11.glTranslatef((float)par2, (float)par4, (float)par6); + this.bindTexture(enderCrystalTextures); + float f3 = MathHelper.sin(f2 * 0.2F) / 2.0F + 0.5F; + f3 += f3 * f3; + this.field_76995_b.render(par1EntityEnderCrystal, 0.0F, f2 * 3.0F, f3 * 0.2F, 0.0F, 0.0F, 0.0625F); + GL11.glPopMatrix(); + } + + protected ResourceLocation getEntityTexture(EntityEnderCrystal par1EntityEnderCrystal) + { + return enderCrystalTextures; + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntityEnderCrystal)par1Entity); + } + + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityEnderCrystal)par1Entity, par2, par4, par6, par8, par9); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/tileentity/RenderItemFrame.java b/src/main/java/net/minecraft/client/renderer/tileentity/RenderItemFrame.java new file mode 100644 index 0000000..5dfc585 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/tileentity/RenderItemFrame.java @@ -0,0 +1,314 @@ +package net.minecraft.client.renderer.tileentity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.renderer.texture.TextureCompass; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.item.EntityItemFrame; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Direction; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.storage.MapData; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class RenderItemFrame extends Render +{ + private static final ResourceLocation mapBackgroundTextures = new ResourceLocation("textures/map/map_background.png"); + private final RenderBlocks field_147916_f = new RenderBlocks(); + private final Minecraft field_147917_g = Minecraft.getMinecraft(); + private IIcon field_94147_f; + private static final String __OBFID = "CL_00001002"; + + public void updateIcons(IIconRegister par1IconRegister) + { + this.field_94147_f = par1IconRegister.registerIcon("itemframe_background"); + } + + public void doRender(EntityItemFrame par1EntityItemFrame, double par2, double par4, double par6, float par8, float par9) + { + GL11.glPushMatrix(); + double d3 = par1EntityItemFrame.posX - par2 - 0.5D; + double d4 = par1EntityItemFrame.posY - par4 - 0.5D; + double d5 = par1EntityItemFrame.posZ - par6 - 0.5D; + int i = par1EntityItemFrame.field_146063_b + Direction.offsetX[par1EntityItemFrame.hangingDirection]; + int j = par1EntityItemFrame.field_146064_c; + int k = par1EntityItemFrame.field_146062_d + Direction.offsetZ[par1EntityItemFrame.hangingDirection]; + GL11.glTranslated((double)i - d3, (double)j - d4, (double)k - d5); + + if (par1EntityItemFrame.getDisplayedItem() != null && par1EntityItemFrame.getDisplayedItem().getItem() == Items.filled_map) + { + this.func_147915_b(par1EntityItemFrame); + } + else + { + this.renderFrameItemAsBlock(par1EntityItemFrame); + } + + this.func_82402_b(par1EntityItemFrame); + GL11.glPopMatrix(); + this.func_147914_a(par1EntityItemFrame, par2 + (double)((float)Direction.offsetX[par1EntityItemFrame.hangingDirection] * 0.3F), par4 - 0.25D, par6 + (double)((float)Direction.offsetZ[par1EntityItemFrame.hangingDirection] * 0.3F)); + } + + protected ResourceLocation getEntityTexture(EntityItemFrame par1EntityItemFrame) + { + return null; + } + + private void func_147915_b(EntityItemFrame p_147915_1_) + { + GL11.glPushMatrix(); + GL11.glRotatef(p_147915_1_.rotationYaw, 0.0F, 1.0F, 0.0F); + this.renderManager.renderEngine.bindTexture(TextureMap.locationBlocksTexture); + Block block = Blocks.planks; + float f = 0.0625F; + float f1 = 1.0F; + float f2 = f1 / 2.0F; + GL11.glPushMatrix(); + this.field_147916_f.overrideBlockBounds(0.0D, (double)(0.5F - f2 + 0.0625F), (double)(0.5F - f2 + 0.0625F), (double)f, (double)(0.5F + f2 - 0.0625F), (double)(0.5F + f2 - 0.0625F)); + this.field_147916_f.setOverrideBlockTexture(this.field_94147_f); + this.field_147916_f.renderBlockAsItem(block, 0, 1.0F); + this.field_147916_f.clearOverrideBlockTexture(); + this.field_147916_f.unlockBlockBounds(); + GL11.glPopMatrix(); + this.field_147916_f.setOverrideBlockTexture(Blocks.planks.getIcon(1, 2)); + GL11.glPushMatrix(); + this.field_147916_f.overrideBlockBounds(0.0D, (double)(0.5F - f2), (double)(0.5F - f2), (double)(f + 1.0E-4F), (double)(f + 0.5F - f2), (double)(0.5F + f2)); + this.field_147916_f.renderBlockAsItem(block, 0, 1.0F); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + this.field_147916_f.overrideBlockBounds(0.0D, (double)(0.5F + f2 - f), (double)(0.5F - f2), (double)(f + 1.0E-4F), (double)(0.5F + f2), (double)(0.5F + f2)); + this.field_147916_f.renderBlockAsItem(block, 0, 1.0F); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + this.field_147916_f.overrideBlockBounds(0.0D, (double)(0.5F - f2), (double)(0.5F - f2), (double)f, (double)(0.5F + f2), (double)(f + 0.5F - f2)); + this.field_147916_f.renderBlockAsItem(block, 0, 1.0F); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + this.field_147916_f.overrideBlockBounds(0.0D, (double)(0.5F - f2), (double)(0.5F + f2 - f), (double)f, (double)(0.5F + f2), (double)(0.5F + f2)); + this.field_147916_f.renderBlockAsItem(block, 0, 1.0F); + GL11.glPopMatrix(); + this.field_147916_f.unlockBlockBounds(); + this.field_147916_f.clearOverrideBlockTexture(); + GL11.glPopMatrix(); + } + + private void renderFrameItemAsBlock(EntityItemFrame par1EntityItemFrame) + { + GL11.glPushMatrix(); + GL11.glRotatef(par1EntityItemFrame.rotationYaw, 0.0F, 1.0F, 0.0F); + this.renderManager.renderEngine.bindTexture(TextureMap.locationBlocksTexture); + Block block = Blocks.planks; + float f = 0.0625F; + float f1 = 0.75F; + float f2 = f1 / 2.0F; + GL11.glPushMatrix(); + this.field_147916_f.overrideBlockBounds(0.0D, (double)(0.5F - f2 + 0.0625F), (double)(0.5F - f2 + 0.0625F), (double)(f * 0.5F), (double)(0.5F + f2 - 0.0625F), (double)(0.5F + f2 - 0.0625F)); + this.field_147916_f.setOverrideBlockTexture(this.field_94147_f); + this.field_147916_f.renderBlockAsItem(block, 0, 1.0F); + this.field_147916_f.clearOverrideBlockTexture(); + this.field_147916_f.unlockBlockBounds(); + GL11.glPopMatrix(); + this.field_147916_f.setOverrideBlockTexture(Blocks.planks.getIcon(1, 2)); + GL11.glPushMatrix(); + this.field_147916_f.overrideBlockBounds(0.0D, (double)(0.5F - f2), (double)(0.5F - f2), (double)(f + 1.0E-4F), (double)(f + 0.5F - f2), (double)(0.5F + f2)); + this.field_147916_f.renderBlockAsItem(block, 0, 1.0F); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + this.field_147916_f.overrideBlockBounds(0.0D, (double)(0.5F + f2 - f), (double)(0.5F - f2), (double)(f + 1.0E-4F), (double)(0.5F + f2), (double)(0.5F + f2)); + this.field_147916_f.renderBlockAsItem(block, 0, 1.0F); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + this.field_147916_f.overrideBlockBounds(0.0D, (double)(0.5F - f2), (double)(0.5F - f2), (double)f, (double)(0.5F + f2), (double)(f + 0.5F - f2)); + this.field_147916_f.renderBlockAsItem(block, 0, 1.0F); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + this.field_147916_f.overrideBlockBounds(0.0D, (double)(0.5F - f2), (double)(0.5F + f2 - f), (double)f, (double)(0.5F + f2), (double)(0.5F + f2)); + this.field_147916_f.renderBlockAsItem(block, 0, 1.0F); + GL11.glPopMatrix(); + this.field_147916_f.unlockBlockBounds(); + this.field_147916_f.clearOverrideBlockTexture(); + GL11.glPopMatrix(); + } + + private void func_82402_b(EntityItemFrame par1EntityItemFrame) + { + ItemStack itemstack = par1EntityItemFrame.getDisplayedItem(); + + if (itemstack != null) + { + EntityItem entityitem = new EntityItem(par1EntityItemFrame.worldObj, 0.0D, 0.0D, 0.0D, itemstack); + Item item = entityitem.getEntityItem().getItem(); + entityitem.getEntityItem().stackSize = 1; + entityitem.hoverStart = 0.0F; + GL11.glPushMatrix(); + GL11.glTranslatef(-0.453125F * (float)Direction.offsetX[par1EntityItemFrame.hangingDirection], -0.18F, -0.453125F * (float)Direction.offsetZ[par1EntityItemFrame.hangingDirection]); + GL11.glRotatef(180.0F + par1EntityItemFrame.rotationYaw, 0.0F, 1.0F, 0.0F); + GL11.glRotatef((float)(-90 * par1EntityItemFrame.getRotation()), 0.0F, 0.0F, 1.0F); + + switch (par1EntityItemFrame.getRotation()) + { + case 1: + GL11.glTranslatef(-0.16F, -0.16F, 0.0F); + break; + case 2: + GL11.glTranslatef(0.0F, -0.32F, 0.0F); + break; + case 3: + GL11.glTranslatef(0.16F, -0.16F, 0.0F); + } + + if (item == Items.filled_map) + { + this.renderManager.renderEngine.bindTexture(mapBackgroundTextures); + Tessellator tessellator = Tessellator.instance; + GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); + float f = 0.0078125F; + GL11.glScalef(f, f, f); + + switch (par1EntityItemFrame.getRotation()) + { + case 0: + GL11.glTranslatef(-64.0F, -87.0F, -1.5F); + break; + case 1: + GL11.glTranslatef(-66.5F, -84.5F, -1.5F); + break; + case 2: + GL11.glTranslatef(-64.0F, -82.0F, -1.5F); + break; + case 3: + GL11.glTranslatef(-61.5F, -84.5F, -1.5F); + } + + GL11.glNormal3f(0.0F, 0.0F, -1.0F); + MapData mapdata = Items.filled_map.getMapData(entityitem.getEntityItem(), par1EntityItemFrame.worldObj); + GL11.glTranslatef(0.0F, 0.0F, -1.0F); + + if (mapdata != null) + { + this.field_147917_g.entityRenderer.getMapItemRenderer().func_148250_a(mapdata, true); + } + } + else + { + if (item == Items.compass) + { + TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); + texturemanager.bindTexture(TextureMap.locationItemsTexture); + TextureAtlasSprite textureatlassprite1 = ((TextureMap)texturemanager.getTexture(TextureMap.locationItemsTexture)).getAtlasSprite(Items.compass.getIconIndex(entityitem.getEntityItem()).getIconName()); + + if (textureatlassprite1 instanceof TextureCompass) + { + TextureCompass texturecompass = (TextureCompass)textureatlassprite1; + double d0 = texturecompass.currentAngle; + double d1 = texturecompass.angleDelta; + texturecompass.currentAngle = 0.0D; + texturecompass.angleDelta = 0.0D; + texturecompass.updateCompass(par1EntityItemFrame.worldObj, par1EntityItemFrame.posX, par1EntityItemFrame.posZ, (double)MathHelper.wrapAngleTo180_float((float)(180 + par1EntityItemFrame.hangingDirection * 90)), false, true); + texturecompass.currentAngle = d0; + texturecompass.angleDelta = d1; + } + } + + RenderItem.renderInFrame = true; + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderItem.renderInFrame = false; + + if (item == Items.compass) + { + TextureAtlasSprite textureatlassprite = ((TextureMap)Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationItemsTexture)).getAtlasSprite(Items.compass.getIconIndex(entityitem.getEntityItem()).getIconName()); + + if (textureatlassprite.getFrameCount() > 0) + { + textureatlassprite.updateAnimation(); + } + } + } + + GL11.glPopMatrix(); + } + } + + protected void func_147914_a(EntityItemFrame p_147914_1_, double p_147914_2_, double p_147914_4_, double p_147914_6_) + { + if (Minecraft.isGuiEnabled() && p_147914_1_.getDisplayedItem() != null && p_147914_1_.getDisplayedItem().hasDisplayName() && this.renderManager.field_147941_i == p_147914_1_) + { + float f = 1.6F; + float f1 = 0.016666668F * f; + double d3 = p_147914_1_.getDistanceSqToEntity(this.renderManager.livingPlayer); + float f2 = p_147914_1_.isSneaking() ? 32.0F : 64.0F; + + if (d3 < (double)(f2 * f2)) + { + String s = p_147914_1_.getDisplayedItem().getDisplayName(); + + if (p_147914_1_.isSneaking()) + { + FontRenderer fontrenderer = this.getFontRendererFromRenderManager(); + GL11.glPushMatrix(); + GL11.glTranslatef((float)p_147914_2_ + 0.0F, (float)p_147914_4_ + p_147914_1_.height + 0.5F, (float)p_147914_6_); + GL11.glNormal3f(0.0F, 1.0F, 0.0F); + GL11.glRotatef(-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F); + GL11.glScalef(-f1, -f1, f1); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glTranslatef(0.0F, 0.25F / f1, 0.0F); + GL11.glDepthMask(false); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + Tessellator tessellator = Tessellator.instance; + GL11.glDisable(GL11.GL_TEXTURE_2D); + tessellator.startDrawingQuads(); + int i = fontrenderer.getStringWidth(s) / 2; + tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F); + tessellator.addVertex((double)(-i - 1), -1.0D, 0.0D); + tessellator.addVertex((double)(-i - 1), 8.0D, 0.0D); + tessellator.addVertex((double)(i + 1), 8.0D, 0.0D); + tessellator.addVertex((double)(i + 1), -1.0D, 0.0D); + tessellator.draw(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDepthMask(true); + fontrenderer.drawString(s, -fontrenderer.getStringWidth(s) / 2, 0, 553648127); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_BLEND); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glPopMatrix(); + } + else + { + this.func_147906_a(p_147914_1_, s, p_147914_2_, p_147914_4_, p_147914_6_, 64); + } + } + } + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntityItemFrame)par1Entity); + } + + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityItemFrame)par1Entity, par2, par4, par6, par8, par9); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/tileentity/RenderWitherSkull.java b/src/main/java/net/minecraft/client/renderer/tileentity/RenderWitherSkull.java new file mode 100644 index 0000000..73bab83 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/tileentity/RenderWitherSkull.java @@ -0,0 +1,68 @@ +package net.minecraft.client.renderer.tileentity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelSkeletonHead; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.entity.Entity; +import net.minecraft.entity.projectile.EntityWitherSkull; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +@SideOnly(Side.CLIENT) +public class RenderWitherSkull extends Render +{ + private static final ResourceLocation invulnerableWitherTextures = new ResourceLocation("textures/entity/wither/wither_invulnerable.png"); + private static final ResourceLocation witherTextures = new ResourceLocation("textures/entity/wither/wither.png"); + private final ModelSkeletonHead skeletonHeadModel = new ModelSkeletonHead(); + private static final String __OBFID = "CL_00001035"; + + private float func_82400_a(float par1, float par2, float par3) + { + float f3; + + for (f3 = par2 - par1; f3 < -180.0F; f3 += 360.0F) + { + ; + } + + while (f3 >= 180.0F) + { + f3 -= 360.0F; + } + + return par1 + par3 * f3; + } + + public void doRender(EntityWitherSkull par1EntityWitherSkull, double par2, double par4, double par6, float par8, float par9) + { + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_CULL_FACE); + float f2 = this.func_82400_a(par1EntityWitherSkull.prevRotationYaw, par1EntityWitherSkull.rotationYaw, par9); + float f3 = par1EntityWitherSkull.prevRotationPitch + (par1EntityWitherSkull.rotationPitch - par1EntityWitherSkull.prevRotationPitch) * par9; + GL11.glTranslatef((float)par2, (float)par4, (float)par6); + float f4 = 0.0625F; + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glScalef(-1.0F, -1.0F, 1.0F); + GL11.glEnable(GL11.GL_ALPHA_TEST); + this.bindEntityTexture(par1EntityWitherSkull); + this.skeletonHeadModel.render(par1EntityWitherSkull, 0.0F, 0.0F, 0.0F, f2, f3, f4); + GL11.glPopMatrix(); + } + + protected ResourceLocation getEntityTexture(EntityWitherSkull par1EntityWitherSkull) + { + return par1EntityWitherSkull.isInvulnerable() ? invulnerableWitherTextures : witherTextures; + } + + protected ResourceLocation getEntityTexture(Entity par1Entity) + { + return this.getEntityTexture((EntityWitherSkull)par1Entity); + } + + public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) + { + this.doRender((EntityWitherSkull)par1Entity, par2, par4, par6, par8, par9); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/tileentity/TileEntityBeaconRenderer.java b/src/main/java/net/minecraft/client/renderer/tileentity/TileEntityBeaconRenderer.java new file mode 100644 index 0000000..0f80690 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/tileentity/TileEntityBeaconRenderer.java @@ -0,0 +1,119 @@ +package net.minecraft.client.renderer.tileentity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityBeacon; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class TileEntityBeaconRenderer extends TileEntitySpecialRenderer +{ + private static final ResourceLocation field_147523_b = new ResourceLocation("textures/entity/beacon_beam.png"); + private static final String __OBFID = "CL_00000962"; + + public void renderTileEntityAt(TileEntityBeacon p_147522_1_, double p_147522_2_, double p_147522_4_, double p_147522_6_, float p_147522_8_) + { + float f1 = p_147522_1_.func_146002_i(); + GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); + + if (f1 > 0.0F) + { + Tessellator tessellator = Tessellator.instance; + this.bindTexture(field_147523_b); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0F); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0F); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDepthMask(true); + OpenGlHelper.glBlendFunc(770, 1, 1, 0); + float f2 = (float)p_147522_1_.getWorldObj().getTotalWorldTime() + p_147522_8_; + float f3 = -f2 * 0.2F - (float)MathHelper.floor_float(-f2 * 0.1F); + byte b0 = 1; + double d3 = (double)f2 * 0.025D * (1.0D - (double)(b0 & 1) * 2.5D); + tessellator.startDrawingQuads(); + tessellator.setColorRGBA(255, 255, 255, 32); + double d5 = (double)b0 * 0.2D; + double d7 = 0.5D + Math.cos(d3 + 2.356194490192345D) * d5; + double d9 = 0.5D + Math.sin(d3 + 2.356194490192345D) * d5; + double d11 = 0.5D + Math.cos(d3 + (Math.PI / 4D)) * d5; + double d13 = 0.5D + Math.sin(d3 + (Math.PI / 4D)) * d5; + double d15 = 0.5D + Math.cos(d3 + 3.9269908169872414D) * d5; + double d17 = 0.5D + Math.sin(d3 + 3.9269908169872414D) * d5; + double d19 = 0.5D + Math.cos(d3 + 5.497787143782138D) * d5; + double d21 = 0.5D + Math.sin(d3 + 5.497787143782138D) * d5; + double d23 = (double)(256.0F * f1); + double d25 = 0.0D; + double d27 = 1.0D; + double d28 = (double)(-1.0F + f3); + double d29 = (double)(256.0F * f1) * (0.5D / d5) + d28; + tessellator.addVertexWithUV(p_147522_2_ + d7, p_147522_4_ + d23, p_147522_6_ + d9, d27, d29); + tessellator.addVertexWithUV(p_147522_2_ + d7, p_147522_4_, p_147522_6_ + d9, d27, d28); + tessellator.addVertexWithUV(p_147522_2_ + d11, p_147522_4_, p_147522_6_ + d13, d25, d28); + tessellator.addVertexWithUV(p_147522_2_ + d11, p_147522_4_ + d23, p_147522_6_ + d13, d25, d29); + tessellator.addVertexWithUV(p_147522_2_ + d19, p_147522_4_ + d23, p_147522_6_ + d21, d27, d29); + tessellator.addVertexWithUV(p_147522_2_ + d19, p_147522_4_, p_147522_6_ + d21, d27, d28); + tessellator.addVertexWithUV(p_147522_2_ + d15, p_147522_4_, p_147522_6_ + d17, d25, d28); + tessellator.addVertexWithUV(p_147522_2_ + d15, p_147522_4_ + d23, p_147522_6_ + d17, d25, d29); + tessellator.addVertexWithUV(p_147522_2_ + d11, p_147522_4_ + d23, p_147522_6_ + d13, d27, d29); + tessellator.addVertexWithUV(p_147522_2_ + d11, p_147522_4_, p_147522_6_ + d13, d27, d28); + tessellator.addVertexWithUV(p_147522_2_ + d19, p_147522_4_, p_147522_6_ + d21, d25, d28); + tessellator.addVertexWithUV(p_147522_2_ + d19, p_147522_4_ + d23, p_147522_6_ + d21, d25, d29); + tessellator.addVertexWithUV(p_147522_2_ + d15, p_147522_4_ + d23, p_147522_6_ + d17, d27, d29); + tessellator.addVertexWithUV(p_147522_2_ + d15, p_147522_4_, p_147522_6_ + d17, d27, d28); + tessellator.addVertexWithUV(p_147522_2_ + d7, p_147522_4_, p_147522_6_ + d9, d25, d28); + tessellator.addVertexWithUV(p_147522_2_ + d7, p_147522_4_ + d23, p_147522_6_ + d9, d25, d29); + tessellator.draw(); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glDepthMask(false); + tessellator.startDrawingQuads(); + tessellator.setColorRGBA(255, 255, 255, 32); + double d30 = 0.2D; + double d4 = 0.2D; + double d6 = 0.8D; + double d8 = 0.2D; + double d10 = 0.2D; + double d12 = 0.8D; + double d14 = 0.8D; + double d16 = 0.8D; + double d18 = (double)(256.0F * f1); + double d20 = 0.0D; + double d22 = 1.0D; + double d24 = (double)(-1.0F + f3); + double d26 = (double)(256.0F * f1) + d24; + tessellator.addVertexWithUV(p_147522_2_ + d30, p_147522_4_ + d18, p_147522_6_ + d4, d22, d26); + tessellator.addVertexWithUV(p_147522_2_ + d30, p_147522_4_, p_147522_6_ + d4, d22, d24); + tessellator.addVertexWithUV(p_147522_2_ + d6, p_147522_4_, p_147522_6_ + d8, d20, d24); + tessellator.addVertexWithUV(p_147522_2_ + d6, p_147522_4_ + d18, p_147522_6_ + d8, d20, d26); + tessellator.addVertexWithUV(p_147522_2_ + d14, p_147522_4_ + d18, p_147522_6_ + d16, d22, d26); + tessellator.addVertexWithUV(p_147522_2_ + d14, p_147522_4_, p_147522_6_ + d16, d22, d24); + tessellator.addVertexWithUV(p_147522_2_ + d10, p_147522_4_, p_147522_6_ + d12, d20, d24); + tessellator.addVertexWithUV(p_147522_2_ + d10, p_147522_4_ + d18, p_147522_6_ + d12, d20, d26); + tessellator.addVertexWithUV(p_147522_2_ + d6, p_147522_4_ + d18, p_147522_6_ + d8, d22, d26); + tessellator.addVertexWithUV(p_147522_2_ + d6, p_147522_4_, p_147522_6_ + d8, d22, d24); + tessellator.addVertexWithUV(p_147522_2_ + d14, p_147522_4_, p_147522_6_ + d16, d20, d24); + tessellator.addVertexWithUV(p_147522_2_ + d14, p_147522_4_ + d18, p_147522_6_ + d16, d20, d26); + tessellator.addVertexWithUV(p_147522_2_ + d10, p_147522_4_ + d18, p_147522_6_ + d12, d22, d26); + tessellator.addVertexWithUV(p_147522_2_ + d10, p_147522_4_, p_147522_6_ + d12, d22, d24); + tessellator.addVertexWithUV(p_147522_2_ + d30, p_147522_4_, p_147522_6_ + d4, d20, d24); + tessellator.addVertexWithUV(p_147522_2_ + d30, p_147522_4_ + d18, p_147522_6_ + d4, d20, d26); + tessellator.draw(); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDepthMask(true); + } + + GL11.glAlphaFunc(GL11.GL_GREATER, 0.5F); + } + + public void renderTileEntityAt(TileEntity p_147500_1_, double p_147500_2_, double p_147500_4_, double p_147500_6_, float p_147500_8_) + { + this.renderTileEntityAt((TileEntityBeacon)p_147500_1_, p_147500_2_, p_147500_4_, p_147500_6_, p_147500_8_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/tileentity/TileEntityChestRenderer.java b/src/main/java/net/minecraft/client/renderer/tileentity/TileEntityChestRenderer.java new file mode 100644 index 0000000..dd63587 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/tileentity/TileEntityChestRenderer.java @@ -0,0 +1,186 @@ +package net.minecraft.client.renderer.tileentity; + +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Calendar; +import net.minecraft.block.Block; +import net.minecraft.block.BlockChest; +import net.minecraft.client.model.ModelChest; +import net.minecraft.client.model.ModelLargeChest; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityChest; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +@SideOnly(Side.CLIENT) +public class TileEntityChestRenderer extends TileEntitySpecialRenderer +{ + private static final ResourceLocation field_147507_b = new ResourceLocation("textures/entity/chest/trapped_double.png"); + private static final ResourceLocation field_147508_c = new ResourceLocation("textures/entity/chest/christmas_double.png"); + private static final ResourceLocation field_147505_d = new ResourceLocation("textures/entity/chest/normal_double.png"); + private static final ResourceLocation field_147506_e = new ResourceLocation("textures/entity/chest/trapped.png"); + private static final ResourceLocation field_147503_f = new ResourceLocation("textures/entity/chest/christmas.png"); + private static final ResourceLocation field_147504_g = new ResourceLocation("textures/entity/chest/normal.png"); + private ModelChest field_147510_h = new ModelChest(); + private ModelChest field_147511_i = new ModelLargeChest(); + private boolean field_147509_j; + private static final String __OBFID = "CL_00000965"; + + public TileEntityChestRenderer() + { + Calendar calendar = Calendar.getInstance(); + + if (calendar.get(2) + 1 == 12 && calendar.get(5) >= 24 && calendar.get(5) <= 26) + { + this.field_147509_j = true; + } + } + + public void renderTileEntityAt(TileEntityChest p_147502_1_, double p_147502_2_, double p_147502_4_, double p_147502_6_, float p_147502_8_) + { + int i; + + if (!p_147502_1_.hasWorldObj()) + { + i = 0; + } + else + { + Block block = p_147502_1_.getBlockType(); + i = p_147502_1_.getBlockMetadata(); + + if (block instanceof BlockChest && i == 0) + { + try + { + ((BlockChest)block).func_149954_e(p_147502_1_.getWorldObj(), p_147502_1_.xCoord, p_147502_1_.yCoord, p_147502_1_.zCoord); + } + catch (ClassCastException e) + { + FMLLog.severe("Attempted to render a chest at %d, %d, %d that was not a chest", p_147502_1_.xCoord, p_147502_1_.yCoord, p_147502_1_.zCoord); + } + i = p_147502_1_.getBlockMetadata(); + } + + p_147502_1_.checkForAdjacentChests(); + } + + if (p_147502_1_.adjacentChestZNeg == null && p_147502_1_.adjacentChestXNeg == null) + { + ModelChest modelchest; + + if (p_147502_1_.adjacentChestXPos == null && p_147502_1_.adjacentChestZPos == null) + { + modelchest = this.field_147510_h; + + if (p_147502_1_.func_145980_j() == 1) + { + this.bindTexture(field_147506_e); + } + else if (this.field_147509_j) + { + this.bindTexture(field_147503_f); + } + else + { + this.bindTexture(field_147504_g); + } + } + else + { + modelchest = this.field_147511_i; + + if (p_147502_1_.func_145980_j() == 1) + { + this.bindTexture(field_147507_b); + } + else if (this.field_147509_j) + { + this.bindTexture(field_147508_c); + } + else + { + this.bindTexture(field_147505_d); + } + } + + GL11.glPushMatrix(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glTranslatef((float)p_147502_2_, (float)p_147502_4_ + 1.0F, (float)p_147502_6_ + 1.0F); + GL11.glScalef(1.0F, -1.0F, -1.0F); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + short short1 = 0; + + if (i == 2) + { + short1 = 180; + } + + if (i == 3) + { + short1 = 0; + } + + if (i == 4) + { + short1 = 90; + } + + if (i == 5) + { + short1 = -90; + } + + if (i == 2 && p_147502_1_.adjacentChestXPos != null) + { + GL11.glTranslatef(1.0F, 0.0F, 0.0F); + } + + if (i == 5 && p_147502_1_.adjacentChestZPos != null) + { + GL11.glTranslatef(0.0F, 0.0F, -1.0F); + } + + GL11.glRotatef((float)short1, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + float f1 = p_147502_1_.prevLidAngle + (p_147502_1_.lidAngle - p_147502_1_.prevLidAngle) * p_147502_8_; + float f2; + + if (p_147502_1_.adjacentChestZNeg != null) + { + f2 = p_147502_1_.adjacentChestZNeg.prevLidAngle + (p_147502_1_.adjacentChestZNeg.lidAngle - p_147502_1_.adjacentChestZNeg.prevLidAngle) * p_147502_8_; + + if (f2 > f1) + { + f1 = f2; + } + } + + if (p_147502_1_.adjacentChestXNeg != null) + { + f2 = p_147502_1_.adjacentChestXNeg.prevLidAngle + (p_147502_1_.adjacentChestXNeg.lidAngle - p_147502_1_.adjacentChestXNeg.prevLidAngle) * p_147502_8_; + + if (f2 > f1) + { + f1 = f2; + } + } + + f1 = 1.0F - f1; + f1 = 1.0F - f1 * f1 * f1; + modelchest.chestLid.rotateAngleX = -(f1 * (float)Math.PI / 2.0F); + modelchest.renderAll(); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + } + } + + public void renderTileEntityAt(TileEntity p_147500_1_, double p_147500_2_, double p_147500_4_, double p_147500_6_, float p_147500_8_) + { + this.renderTileEntityAt((TileEntityChest)p_147500_1_, p_147500_2_, p_147500_4_, p_147500_6_, p_147500_8_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/tileentity/TileEntityEnderChestRenderer.java b/src/main/java/net/minecraft/client/renderer/tileentity/TileEntityEnderChestRenderer.java new file mode 100644 index 0000000..064543e --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/tileentity/TileEntityEnderChestRenderer.java @@ -0,0 +1,73 @@ +package net.minecraft.client.renderer.tileentity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelChest; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityEnderChest; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +@SideOnly(Side.CLIENT) +public class TileEntityEnderChestRenderer extends TileEntitySpecialRenderer +{ + private static final ResourceLocation field_147520_b = new ResourceLocation("textures/entity/chest/ender.png"); + private ModelChest field_147521_c = new ModelChest(); + private static final String __OBFID = "CL_00000967"; + + public void renderTileEntityAt(TileEntityEnderChest p_147519_1_, double p_147519_2_, double p_147519_4_, double p_147519_6_, float p_147519_8_) + { + int i = 0; + + if (p_147519_1_.hasWorldObj()) + { + i = p_147519_1_.getBlockMetadata(); + } + + this.bindTexture(field_147520_b); + GL11.glPushMatrix(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glTranslatef((float)p_147519_2_, (float)p_147519_4_ + 1.0F, (float)p_147519_6_ + 1.0F); + GL11.glScalef(1.0F, -1.0F, -1.0F); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + short short1 = 0; + + if (i == 2) + { + short1 = 180; + } + + if (i == 3) + { + short1 = 0; + } + + if (i == 4) + { + short1 = 90; + } + + if (i == 5) + { + short1 = -90; + } + + GL11.glRotatef((float)short1, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + float f1 = p_147519_1_.field_145975_i + (p_147519_1_.field_145972_a - p_147519_1_.field_145975_i) * p_147519_8_; + f1 = 1.0F - f1; + f1 = 1.0F - f1 * f1 * f1; + this.field_147521_c.chestLid.rotateAngleX = -(f1 * (float)Math.PI / 2.0F); + this.field_147521_c.renderAll(); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + } + + public void renderTileEntityAt(TileEntity p_147500_1_, double p_147500_2_, double p_147500_4_, double p_147500_6_, float p_147500_8_) + { + this.renderTileEntityAt((TileEntityEnderChest)p_147500_1_, p_147500_2_, p_147500_4_, p_147500_6_, p_147500_8_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/tileentity/TileEntityMobSpawnerRenderer.java b/src/main/java/net/minecraft/client/renderer/tileentity/TileEntityMobSpawnerRenderer.java new file mode 100644 index 0000000..1f4dc75 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/tileentity/TileEntityMobSpawnerRenderer.java @@ -0,0 +1,47 @@ +package net.minecraft.client.renderer.tileentity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.entity.Entity; +import net.minecraft.tileentity.MobSpawnerBaseLogic; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityMobSpawner; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class TileEntityMobSpawnerRenderer extends TileEntitySpecialRenderer +{ + private static final String __OBFID = "CL_00000968"; + + public void renderTileEntityAt(TileEntityMobSpawner p_147518_1_, double p_147518_2_, double p_147518_4_, double p_147518_6_, float p_147518_8_) + { + GL11.glPushMatrix(); + GL11.glTranslatef((float)p_147518_2_ + 0.5F, (float)p_147518_4_, (float)p_147518_6_ + 0.5F); + func_147517_a(p_147518_1_.func_145881_a(), p_147518_2_, p_147518_4_, p_147518_6_, p_147518_8_); + GL11.glPopMatrix(); + } + + public static void func_147517_a(MobSpawnerBaseLogic p_147517_0_, double p_147517_1_, double p_147517_3_, double p_147517_5_, float p_147517_7_) + { + Entity entity = p_147517_0_.func_98281_h(); + + if (entity != null) + { + entity.setWorld(p_147517_0_.getSpawnerWorld()); + float f1 = 0.4375F; + GL11.glTranslatef(0.0F, 0.4F, 0.0F); + GL11.glRotatef((float)(p_147517_0_.field_98284_d + (p_147517_0_.field_98287_c - p_147517_0_.field_98284_d) * (double)p_147517_7_) * 10.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-30.0F, 1.0F, 0.0F, 0.0F); + GL11.glTranslatef(0.0F, -0.4F, 0.0F); + GL11.glScalef(f1, f1, f1); + entity.setLocationAndAngles(p_147517_1_, p_147517_3_, p_147517_5_, 0.0F, 0.0F); + RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, p_147517_7_); + } + } + + public void renderTileEntityAt(TileEntity p_147500_1_, double p_147500_2_, double p_147500_4_, double p_147500_6_, float p_147500_8_) + { + this.renderTileEntityAt((TileEntityMobSpawner)p_147500_1_, p_147500_2_, p_147500_4_, p_147500_6_, p_147500_8_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/tileentity/TileEntityRendererChestHelper.java b/src/main/java/net/minecraft/client/renderer/tileentity/TileEntityRendererChestHelper.java new file mode 100644 index 0000000..55cdf5a --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/tileentity/TileEntityRendererChestHelper.java @@ -0,0 +1,34 @@ +package net.minecraft.client.renderer.tileentity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntityChest; +import net.minecraft.tileentity.TileEntityEnderChest; + +@SideOnly(Side.CLIENT) +public class TileEntityRendererChestHelper +{ + public static TileEntityRendererChestHelper instance = new TileEntityRendererChestHelper(); + private TileEntityChest field_147717_b = new TileEntityChest(0); + private TileEntityChest field_147718_c = new TileEntityChest(1); + private TileEntityEnderChest field_147716_d = new TileEntityEnderChest(); + private static final String __OBFID = "CL_00000946"; + + public void renderChest(Block p_147715_1_, int p_147715_2_, float p_147715_3_) + { + if (p_147715_1_ == Blocks.ender_chest) + { + TileEntityRendererDispatcher.instance.renderTileEntityAt(this.field_147716_d, 0.0D, 0.0D, 0.0D, 0.0F); + } + else if (p_147715_1_ == Blocks.trapped_chest) + { + TileEntityRendererDispatcher.instance.renderTileEntityAt(this.field_147718_c, 0.0D, 0.0D, 0.0D, 0.0F); + } + else + { + TileEntityRendererDispatcher.instance.renderTileEntityAt(this.field_147717_b, 0.0D, 0.0D, 0.0D, 0.0F); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/tileentity/TileEntityRendererDispatcher.java b/src/main/java/net/minecraft/client/renderer/tileentity/TileEntityRendererDispatcher.java new file mode 100644 index 0000000..4adeaa3 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/tileentity/TileEntityRendererDispatcher.java @@ -0,0 +1,161 @@ +package net.minecraft.client.renderer.tileentity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.entity.RenderEnchantmentTable; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.crash.CrashReport; +import net.minecraft.crash.CrashReportCategory; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityBeacon; +import net.minecraft.tileentity.TileEntityChest; +import net.minecraft.tileentity.TileEntityEnchantmentTable; +import net.minecraft.tileentity.TileEntityEndPortal; +import net.minecraft.tileentity.TileEntityEnderChest; +import net.minecraft.tileentity.TileEntityMobSpawner; +import net.minecraft.tileentity.TileEntityPiston; +import net.minecraft.tileentity.TileEntitySign; +import net.minecraft.tileentity.TileEntitySkull; +import net.minecraft.util.ReportedException; +import net.minecraft.world.World; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class TileEntityRendererDispatcher +{ + public Map mapSpecialRenderers = new HashMap(); + public static TileEntityRendererDispatcher instance = new TileEntityRendererDispatcher(); + private FontRenderer field_147557_n; + public static double staticPlayerX; + public static double staticPlayerY; + public static double staticPlayerZ; + public TextureManager field_147553_e; + public World field_147550_f; + public EntityLivingBase field_147551_g; + public float field_147562_h; + public float field_147563_i; + public double field_147560_j; + public double field_147561_k; + public double field_147558_l; + private static final String __OBFID = "CL_00000963"; + + private TileEntityRendererDispatcher() + { + this.mapSpecialRenderers.put(TileEntitySign.class, new TileEntitySignRenderer()); + this.mapSpecialRenderers.put(TileEntityMobSpawner.class, new TileEntityMobSpawnerRenderer()); + this.mapSpecialRenderers.put(TileEntityPiston.class, new TileEntityRendererPiston()); + this.mapSpecialRenderers.put(TileEntityChest.class, new TileEntityChestRenderer()); + this.mapSpecialRenderers.put(TileEntityEnderChest.class, new TileEntityEnderChestRenderer()); + this.mapSpecialRenderers.put(TileEntityEnchantmentTable.class, new RenderEnchantmentTable()); + this.mapSpecialRenderers.put(TileEntityEndPortal.class, new RenderEndPortal()); + this.mapSpecialRenderers.put(TileEntityBeacon.class, new TileEntityBeaconRenderer()); + this.mapSpecialRenderers.put(TileEntitySkull.class, new TileEntitySkullRenderer()); + Iterator iterator = this.mapSpecialRenderers.values().iterator(); + + while (iterator.hasNext()) + { + TileEntitySpecialRenderer tileentityspecialrenderer = (TileEntitySpecialRenderer)iterator.next(); + tileentityspecialrenderer.func_147497_a(this); + } + } + + public TileEntitySpecialRenderer getSpecialRendererByClass(Class p_147546_1_) + { + TileEntitySpecialRenderer tileentityspecialrenderer = (TileEntitySpecialRenderer)this.mapSpecialRenderers.get(p_147546_1_); + + if (tileentityspecialrenderer == null && p_147546_1_ != TileEntity.class) + { + tileentityspecialrenderer = this.getSpecialRendererByClass(p_147546_1_.getSuperclass()); + this.mapSpecialRenderers.put(p_147546_1_, tileentityspecialrenderer); + } + + return tileentityspecialrenderer; + } + + public boolean hasSpecialRenderer(TileEntity p_147545_1_) + { + return this.getSpecialRenderer(p_147545_1_) != null; + } + + public TileEntitySpecialRenderer getSpecialRenderer(TileEntity p_147547_1_) + { + return p_147547_1_ == null ? null : this.getSpecialRendererByClass(p_147547_1_.getClass()); + } + + public void cacheActiveRenderInfo(World p_147542_1_, TextureManager p_147542_2_, FontRenderer p_147542_3_, EntityLivingBase p_147542_4_, float p_147542_5_) + { + if (this.field_147550_f != p_147542_1_) + { + this.func_147543_a(p_147542_1_); + } + + this.field_147553_e = p_147542_2_; + this.field_147551_g = p_147542_4_; + this.field_147557_n = p_147542_3_; + this.field_147562_h = p_147542_4_.prevRotationYaw + (p_147542_4_.rotationYaw - p_147542_4_.prevRotationYaw) * p_147542_5_; + this.field_147563_i = p_147542_4_.prevRotationPitch + (p_147542_4_.rotationPitch - p_147542_4_.prevRotationPitch) * p_147542_5_; + this.field_147560_j = p_147542_4_.lastTickPosX + (p_147542_4_.posX - p_147542_4_.lastTickPosX) * (double)p_147542_5_; + this.field_147561_k = p_147542_4_.lastTickPosY + (p_147542_4_.posY - p_147542_4_.lastTickPosY) * (double)p_147542_5_; + this.field_147558_l = p_147542_4_.lastTickPosZ + (p_147542_4_.posZ - p_147542_4_.lastTickPosZ) * (double)p_147542_5_; + } + + public void renderTileEntity(TileEntity p_147544_1_, float p_147544_2_) + { + if (p_147544_1_.getDistanceFrom(this.field_147560_j, this.field_147561_k, this.field_147558_l) < p_147544_1_.getMaxRenderDistanceSquared()) + { + int i = this.field_147550_f.getLightBrightnessForSkyBlocks(p_147544_1_.xCoord, p_147544_1_.yCoord, p_147544_1_.zCoord, 0); + int j = i % 65536; + int k = i / 65536; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j / 1.0F, (float)k / 1.0F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.renderTileEntityAt(p_147544_1_, (double)p_147544_1_.xCoord - staticPlayerX, (double)p_147544_1_.yCoord - staticPlayerY, (double)p_147544_1_.zCoord - staticPlayerZ, p_147544_2_); + } + } + + public void renderTileEntityAt(TileEntity p_147549_1_, double p_147549_2_, double p_147549_4_, double p_147549_6_, float p_147549_8_) + { + TileEntitySpecialRenderer tileentityspecialrenderer = this.getSpecialRenderer(p_147549_1_); + + if (tileentityspecialrenderer != null) + { + try + { + tileentityspecialrenderer.renderTileEntityAt(p_147549_1_, p_147549_2_, p_147549_4_, p_147549_6_, p_147549_8_); + } + catch (Throwable throwable) + { + CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Rendering Block Entity"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("Block Entity Details"); + p_147549_1_.func_145828_a(crashreportcategory); + throw new ReportedException(crashreport); + } + } + } + + public void func_147543_a(World p_147543_1_) + { + this.field_147550_f = p_147543_1_; + Iterator iterator = this.mapSpecialRenderers.values().iterator(); + + while (iterator.hasNext()) + { + TileEntitySpecialRenderer tileentityspecialrenderer = (TileEntitySpecialRenderer)iterator.next(); + + if (tileentityspecialrenderer != null) + { + tileentityspecialrenderer.func_147496_a(p_147543_1_); + } + } + } + + public FontRenderer getFontRenderer() + { + return this.field_147557_n; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/tileentity/TileEntityRendererPiston.java b/src/main/java/net/minecraft/client/renderer/tileentity/TileEntityRendererPiston.java new file mode 100644 index 0000000..64df6d9 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/tileentity/TileEntityRendererPiston.java @@ -0,0 +1,83 @@ +package net.minecraft.client.renderer.tileentity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.block.BlockPistonBase; +import net.minecraft.block.material.Material; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityPiston; +import net.minecraft.world.World; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class TileEntityRendererPiston extends TileEntitySpecialRenderer +{ + private RenderBlocks field_147516_b; + private static final String __OBFID = "CL_00000969"; + + public void renderTileEntityAt(TileEntityPiston p_147515_1_, double p_147515_2_, double p_147515_4_, double p_147515_6_, float p_147515_8_) + { + Block block = p_147515_1_.getStoredBlockID(); + + if (block.getMaterial() != Material.air && p_147515_1_.func_145860_a(p_147515_8_) < 1.0F) + { + Tessellator tessellator = Tessellator.instance; + this.bindTexture(TextureMap.locationBlocksTexture); + RenderHelper.disableStandardItemLighting(); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_CULL_FACE); + + if (Minecraft.isAmbientOcclusionEnabled()) + { + GL11.glShadeModel(GL11.GL_SMOOTH); + } + else + { + GL11.glShadeModel(GL11.GL_FLAT); + } + + tessellator.startDrawingQuads(); + tessellator.setTranslation((double)((float)p_147515_2_ - (float)p_147515_1_.xCoord + p_147515_1_.func_145865_b(p_147515_8_)), (double)((float)p_147515_4_ - (float)p_147515_1_.yCoord + p_147515_1_.func_145862_c(p_147515_8_)), (double)((float)p_147515_6_ - (float)p_147515_1_.zCoord + p_147515_1_.func_145859_d(p_147515_8_))); + tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F); + + if (block == Blocks.piston_head && p_147515_1_.func_145860_a(p_147515_8_) < 0.5F) + { + this.field_147516_b.renderPistonExtensionAllFaces(block, p_147515_1_.xCoord, p_147515_1_.yCoord, p_147515_1_.zCoord, false); + } + else if (p_147515_1_.func_145867_d() && !p_147515_1_.isExtending()) + { + Blocks.piston_head.func_150086_a(((BlockPistonBase)block).getPistonExtensionTexture()); + this.field_147516_b.renderPistonExtensionAllFaces(Blocks.piston_head, p_147515_1_.xCoord, p_147515_1_.yCoord, p_147515_1_.zCoord, p_147515_1_.func_145860_a(p_147515_8_) < 0.5F); + Blocks.piston_head.func_150087_e(); + tessellator.setTranslation((double)((float)p_147515_2_ - (float)p_147515_1_.xCoord), (double)((float)p_147515_4_ - (float)p_147515_1_.yCoord), (double)((float)p_147515_6_ - (float)p_147515_1_.zCoord)); + this.field_147516_b.renderPistonBaseAllFaces(block, p_147515_1_.xCoord, p_147515_1_.yCoord, p_147515_1_.zCoord); + } + else + { + this.field_147516_b.renderBlockAllFaces(block, p_147515_1_.xCoord, p_147515_1_.yCoord, p_147515_1_.zCoord); + } + + tessellator.setTranslation(0.0D, 0.0D, 0.0D); + tessellator.draw(); + RenderHelper.enableStandardItemLighting(); + } + } + + public void func_147496_a(World p_147496_1_) + { + this.field_147516_b = new RenderBlocks(p_147496_1_); + } + + public void renderTileEntityAt(TileEntity p_147500_1_, double p_147500_2_, double p_147500_4_, double p_147500_6_, float p_147500_8_) + { + this.renderTileEntityAt((TileEntityPiston)p_147500_1_, p_147500_2_, p_147500_4_, p_147500_6_, p_147500_8_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/tileentity/TileEntitySignRenderer.java b/src/main/java/net/minecraft/client/renderer/tileentity/TileEntitySignRenderer.java new file mode 100644 index 0000000..9e07885 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/tileentity/TileEntitySignRenderer.java @@ -0,0 +1,98 @@ +package net.minecraft.client.renderer.tileentity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.model.ModelSign; +import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntitySign; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class TileEntitySignRenderer extends TileEntitySpecialRenderer +{ + private static final ResourceLocation field_147513_b = new ResourceLocation("textures/entity/sign.png"); + private final ModelSign field_147514_c = new ModelSign(); + private static final String __OBFID = "CL_00000970"; + + public void renderTileEntityAt(TileEntitySign p_147512_1_, double p_147512_2_, double p_147512_4_, double p_147512_6_, float p_147512_8_) + { + Block block = p_147512_1_.getBlockType(); + GL11.glPushMatrix(); + float f1 = 0.6666667F; + float f3; + + if (block == Blocks.standing_sign) + { + GL11.glTranslatef((float)p_147512_2_ + 0.5F, (float)p_147512_4_ + 0.75F * f1, (float)p_147512_6_ + 0.5F); + float f2 = (float)(p_147512_1_.getBlockMetadata() * 360) / 16.0F; + GL11.glRotatef(-f2, 0.0F, 1.0F, 0.0F); + this.field_147514_c.signStick.showModel = true; + } + else + { + int j = p_147512_1_.getBlockMetadata(); + f3 = 0.0F; + + if (j == 2) + { + f3 = 180.0F; + } + + if (j == 4) + { + f3 = 90.0F; + } + + if (j == 5) + { + f3 = -90.0F; + } + + GL11.glTranslatef((float)p_147512_2_ + 0.5F, (float)p_147512_4_ + 0.75F * f1, (float)p_147512_6_ + 0.5F); + GL11.glRotatef(-f3, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(0.0F, -0.3125F, -0.4375F); + this.field_147514_c.signStick.showModel = false; + } + + this.bindTexture(field_147513_b); + GL11.glPushMatrix(); + GL11.glScalef(f1, -f1, -f1); + this.field_147514_c.renderSign(); + GL11.glPopMatrix(); + FontRenderer fontrenderer = this.func_147498_b(); + f3 = 0.016666668F * f1; + GL11.glTranslatef(0.0F, 0.5F * f1, 0.07F * f1); + GL11.glScalef(f3, -f3, f3); + GL11.glNormal3f(0.0F, 0.0F, -1.0F * f3); + GL11.glDepthMask(false); + byte b0 = 0; + + for (int i = 0; i < p_147512_1_.signText.length; ++i) + { + String s = p_147512_1_.signText[i]; + + if (i == p_147512_1_.lineBeingEdited) + { + s = "> " + s + " <"; + fontrenderer.drawString(s, -fontrenderer.getStringWidth(s) / 2, i * 10 - p_147512_1_.signText.length * 5, b0); + } + else + { + fontrenderer.drawString(s, -fontrenderer.getStringWidth(s) / 2, i * 10 - p_147512_1_.signText.length * 5, b0); + } + } + + GL11.glDepthMask(true); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glPopMatrix(); + } + + public void renderTileEntityAt(TileEntity p_147500_1_, double p_147500_2_, double p_147500_4_, double p_147500_6_, float p_147500_8_) + { + this.renderTileEntityAt((TileEntitySign)p_147500_1_, p_147500_2_, p_147500_4_, p_147500_6_, p_147500_8_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/tileentity/TileEntitySkullRenderer.java b/src/main/java/net/minecraft/client/renderer/tileentity/TileEntitySkullRenderer.java new file mode 100644 index 0000000..1f52931 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/tileentity/TileEntitySkullRenderer.java @@ -0,0 +1,110 @@ +package net.minecraft.client.renderer.tileentity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.entity.AbstractClientPlayer; +import net.minecraft.client.model.ModelSkeletonHead; +import net.minecraft.entity.Entity; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntitySkull; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +@SideOnly(Side.CLIENT) +public class TileEntitySkullRenderer extends TileEntitySpecialRenderer +{ + private static final ResourceLocation field_147537_c = new ResourceLocation("textures/entity/skeleton/skeleton.png"); + private static final ResourceLocation field_147534_d = new ResourceLocation("textures/entity/skeleton/wither_skeleton.png"); + private static final ResourceLocation field_147535_e = new ResourceLocation("textures/entity/zombie/zombie.png"); + private static final ResourceLocation field_147532_f = new ResourceLocation("textures/entity/creeper/creeper.png"); + public static TileEntitySkullRenderer field_147536_b; + private ModelSkeletonHead field_147533_g = new ModelSkeletonHead(0, 0, 64, 32); + private ModelSkeletonHead field_147538_h = new ModelSkeletonHead(0, 0, 64, 64); + private static final String __OBFID = "CL_00000971"; + + public void renderTileEntityAt(TileEntitySkull p_147531_1_, double p_147531_2_, double p_147531_4_, double p_147531_6_, float p_147531_8_) + { + this.func_147530_a((float)p_147531_2_, (float)p_147531_4_, (float)p_147531_6_, p_147531_1_.getBlockMetadata() & 7, (float)(p_147531_1_.func_145906_b() * 360) / 16.0F, p_147531_1_.func_145904_a(), p_147531_1_.func_145907_c()); + } + + public void func_147497_a(TileEntityRendererDispatcher p_147497_1_) + { + super.func_147497_a(p_147497_1_); + field_147536_b = this; + } + + public void func_147530_a(float p_147530_1_, float p_147530_2_, float p_147530_3_, int p_147530_4_, float p_147530_5_, int p_147530_6_, String p_147530_7_) + { + ModelSkeletonHead modelskeletonhead = this.field_147533_g; + + switch (p_147530_6_) + { + case 0: + default: + this.bindTexture(field_147537_c); + break; + case 1: + this.bindTexture(field_147534_d); + break; + case 2: + this.bindTexture(field_147535_e); + modelskeletonhead = this.field_147538_h; + break; + case 3: + ResourceLocation resourcelocation = AbstractClientPlayer.locationStevePng; + + if (p_147530_7_ != null && p_147530_7_.length() > 0) + { + resourcelocation = AbstractClientPlayer.getLocationSkull(p_147530_7_); + AbstractClientPlayer.getDownloadImageSkin(resourcelocation, p_147530_7_); + } + + this.bindTexture(resourcelocation); + break; + case 4: + this.bindTexture(field_147532_f); + } + + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_CULL_FACE); + + if (p_147530_4_ != 1) + { + switch (p_147530_4_) + { + case 2: + GL11.glTranslatef(p_147530_1_ + 0.5F, p_147530_2_ + 0.25F, p_147530_3_ + 0.74F); + break; + case 3: + GL11.glTranslatef(p_147530_1_ + 0.5F, p_147530_2_ + 0.25F, p_147530_3_ + 0.26F); + p_147530_5_ = 180.0F; + break; + case 4: + GL11.glTranslatef(p_147530_1_ + 0.74F, p_147530_2_ + 0.25F, p_147530_3_ + 0.5F); + p_147530_5_ = 270.0F; + break; + case 5: + default: + GL11.glTranslatef(p_147530_1_ + 0.26F, p_147530_2_ + 0.25F, p_147530_3_ + 0.5F); + p_147530_5_ = 90.0F; + } + } + else + { + GL11.glTranslatef(p_147530_1_ + 0.5F, p_147530_2_, p_147530_3_ + 0.5F); + } + + float f4 = 0.0625F; + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glScalef(-1.0F, -1.0F, 1.0F); + GL11.glEnable(GL11.GL_ALPHA_TEST); + modelskeletonhead.render((Entity)null, 0.0F, 0.0F, 0.0F, p_147530_5_, 0.0F, f4); + GL11.glPopMatrix(); + } + + public void renderTileEntityAt(TileEntity p_147500_1_, double p_147500_2_, double p_147500_4_, double p_147500_6_, float p_147500_8_) + { + this.renderTileEntityAt((TileEntitySkull)p_147500_1_, p_147500_2_, p_147500_4_, p_147500_6_, p_147500_8_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/renderer/tileentity/TileEntitySpecialRenderer.java b/src/main/java/net/minecraft/client/renderer/tileentity/TileEntitySpecialRenderer.java new file mode 100644 index 0000000..2260fd2 --- /dev/null +++ b/src/main/java/net/minecraft/client/renderer/tileentity/TileEntitySpecialRenderer.java @@ -0,0 +1,40 @@ +package net.minecraft.client.renderer.tileentity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; + +@SideOnly(Side.CLIENT) +public abstract class TileEntitySpecialRenderer +{ + protected TileEntityRendererDispatcher field_147501_a; + private static final String __OBFID = "CL_00000964"; + + public abstract void renderTileEntityAt(TileEntity var1, double var2, double var4, double var6, float var8); + + protected void bindTexture(ResourceLocation p_147499_1_) + { + TextureManager texturemanager = this.field_147501_a.field_147553_e; + + if (texturemanager != null) + { + texturemanager.bindTexture(p_147499_1_); + } + } + + public void func_147497_a(TileEntityRendererDispatcher p_147497_1_) + { + this.field_147501_a = p_147497_1_; + } + + public void func_147496_a(World p_147496_1_) {} + + public FontRenderer func_147498_b() + { + return this.field_147501_a.getFontRenderer(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/resources/AbstractResourcePack.java b/src/main/java/net/minecraft/client/resources/AbstractResourcePack.java new file mode 100644 index 0000000..8231e07 --- /dev/null +++ b/src/main/java/net/minecraft/client/resources/AbstractResourcePack.java @@ -0,0 +1,95 @@ +package net.minecraft.client.resources; + +import com.google.common.base.Charsets; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.awt.image.BufferedImage; +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import javax.imageio.ImageIO; +import net.minecraft.client.resources.data.IMetadataSection; +import net.minecraft.client.resources.data.IMetadataSerializer; +import net.minecraft.util.ResourceLocation; +import org.apache.commons.io.IOUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +@SideOnly(Side.CLIENT) +public abstract class AbstractResourcePack implements IResourcePack +{ + private static final Logger resourceLog = LogManager.getLogger(); + protected final File resourcePackFile; + private static final String __OBFID = "CL_00001072"; + + public AbstractResourcePack(File par1File) + { + this.resourcePackFile = par1File; + } + + private static String locationToName(ResourceLocation par0ResourceLocation) + { + return String.format("%s/%s/%s", new Object[] {"assets", par0ResourceLocation.getResourceDomain(), par0ResourceLocation.getResourcePath()}); + } + + protected static String getRelativeName(File par0File, File par1File) + { + return par0File.toURI().relativize(par1File.toURI()).getPath(); + } + + public InputStream getInputStream(ResourceLocation par1ResourceLocation) throws IOException + { + return this.getInputStreamByName(locationToName(par1ResourceLocation)); + } + + public boolean resourceExists(ResourceLocation par1ResourceLocation) + { + return this.hasResourceName(locationToName(par1ResourceLocation)); + } + + protected abstract InputStream getInputStreamByName(String var1) throws IOException; + + protected abstract boolean hasResourceName(String var1); + + protected void logNameNotLowercase(String par1Str) + { + resourceLog.warn("ResourcePack: ignored non-lowercase namespace: %s in %s", new Object[] {par1Str, this.resourcePackFile}); + } + + public IMetadataSection getPackMetadata(IMetadataSerializer par1MetadataSerializer, String par2Str) throws IOException + { + return readMetadata(par1MetadataSerializer, this.getInputStreamByName("pack.mcmeta"), par2Str); + } + + static IMetadataSection readMetadata(IMetadataSerializer par0MetadataSerializer, InputStream par1InputStream, String par2Str) + { + JsonObject jsonobject = null; + BufferedReader bufferedreader = null; + + try + { + bufferedreader = new BufferedReader(new InputStreamReader(par1InputStream, Charsets.UTF_8)); + jsonobject = (new JsonParser()).parse(bufferedreader).getAsJsonObject(); + } + finally + { + IOUtils.closeQuietly(bufferedreader); + } + + return par0MetadataSerializer.parseMetadataSection(par2Str, jsonobject); + } + + public BufferedImage getPackImage() throws IOException + { + return ImageIO.read(this.getInputStreamByName("pack.png")); + } + + public String getPackName() + { + return this.resourcePackFile.getName(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/resources/DefaultResourcePack.java b/src/main/java/net/minecraft/client/resources/DefaultResourcePack.java new file mode 100644 index 0000000..08f49a3 --- /dev/null +++ b/src/main/java/net/minecraft/client/resources/DefaultResourcePack.java @@ -0,0 +1,117 @@ +package net.minecraft.client.resources; + +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Maps; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.util.Map; +import java.util.Set; +import javax.imageio.ImageIO; +import net.minecraft.client.resources.data.IMetadataSection; +import net.minecraft.client.resources.data.IMetadataSerializer; +import net.minecraft.util.ResourceLocation; + +@SideOnly(Side.CLIENT) +public class DefaultResourcePack implements IResourcePack +{ + public static final Set defaultResourceDomains = ImmutableSet.of("minecraft"); + private final Map mapResourceFiles = Maps.newHashMap(); + private final File fileAssets; + private static final String __OBFID = "CL_00001073"; + + public DefaultResourcePack(File par1File) + { + this.fileAssets = par1File; + this.readAssetsDir(this.fileAssets); + } + + public InputStream getInputStream(ResourceLocation par1ResourceLocation) throws IOException + { + InputStream inputstream = this.getResourceStream(par1ResourceLocation); + + if (inputstream != null) + { + return inputstream; + } + else + { + File file1 = (File)this.mapResourceFiles.get(par1ResourceLocation.toString()); + + if (file1 != null) + { + return new FileInputStream(file1); + } + else + { + throw new FileNotFoundException(par1ResourceLocation.getResourcePath()); + } + } + } + + private InputStream getResourceStream(ResourceLocation par1ResourceLocation) + { + return DefaultResourcePack.class.getResourceAsStream("/assets/minecraft/" + par1ResourceLocation.getResourcePath()); + } + + public void addResourceFile(String par1Str, File par2File) + { + this.mapResourceFiles.put((new ResourceLocation(par1Str)).toString(), par2File); + } + + public boolean resourceExists(ResourceLocation par1ResourceLocation) + { + return this.getResourceStream(par1ResourceLocation) != null || this.mapResourceFiles.containsKey(par1ResourceLocation.toString()); + } + + public Set getResourceDomains() + { + return defaultResourceDomains; + } + + public void readAssetsDir(File par1File) + { + if (par1File.isDirectory()) + { + File[] afile = par1File.listFiles(); + int i = afile.length; + + for (int j = 0; j < i; ++j) + { + File file2 = afile[j]; + this.readAssetsDir(file2); + } + } + else + { + this.addResourceFile(AbstractResourcePack.getRelativeName(this.fileAssets, par1File), par1File); + } + } + + public IMetadataSection getPackMetadata(IMetadataSerializer par1MetadataSerializer, String par2Str) throws IOException + { + try + { + return AbstractResourcePack.readMetadata(par1MetadataSerializer, new FileInputStream(new File(this.fileAssets, "pack.mcmeta")), par2Str); + } + catch (FileNotFoundException filenotfoundexception) + { + return null; + } + } + + public BufferedImage getPackImage() throws IOException + { + return ImageIO.read(DefaultResourcePack.class.getResourceAsStream("/" + (new ResourceLocation("pack.png")).getResourcePath())); + } + + public String getPackName() + { + return "Default"; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/resources/FallbackResourceManager.java b/src/main/java/net/minecraft/client/resources/FallbackResourceManager.java new file mode 100644 index 0000000..e626b19 --- /dev/null +++ b/src/main/java/net/minecraft/client/resources/FallbackResourceManager.java @@ -0,0 +1,99 @@ +package net.minecraft.client.resources; + +import com.google.common.collect.Lists; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Set; +import net.minecraft.client.resources.data.IMetadataSerializer; +import net.minecraft.util.ResourceLocation; + +@SideOnly(Side.CLIENT) +public class FallbackResourceManager implements IResourceManager +{ + protected final List resourcePacks = new ArrayList(); + private final IMetadataSerializer frmMetadataSerializer; + private static final String __OBFID = "CL_00001074"; + + public FallbackResourceManager(IMetadataSerializer par1MetadataSerializer) + { + this.frmMetadataSerializer = par1MetadataSerializer; + } + + public void addResourcePack(IResourcePack par1ResourcePack) + { + this.resourcePacks.add(par1ResourcePack); + } + + public Set getResourceDomains() + { + return null; + } + + public IResource getResource(ResourceLocation par1ResourceLocation) throws IOException + { + IResourcePack iresourcepack = null; + ResourceLocation resourcelocation1 = getLocationMcmeta(par1ResourceLocation); + + for (int i = this.resourcePacks.size() - 1; i >= 0; --i) + { + IResourcePack iresourcepack1 = (IResourcePack)this.resourcePacks.get(i); + + if (iresourcepack == null && iresourcepack1.resourceExists(resourcelocation1)) + { + iresourcepack = iresourcepack1; + } + + if (iresourcepack1.resourceExists(par1ResourceLocation)) + { + InputStream inputstream = null; + + if (iresourcepack != null) + { + inputstream = iresourcepack.getInputStream(resourcelocation1); + } + + return new SimpleResource(par1ResourceLocation, iresourcepack1.getInputStream(par1ResourceLocation), inputstream, this.frmMetadataSerializer); + } + } + + throw new FileNotFoundException(par1ResourceLocation.toString()); + } + + public List getAllResources(ResourceLocation par1ResourceLocation) throws IOException + { + ArrayList arraylist = Lists.newArrayList(); + ResourceLocation resourcelocation1 = getLocationMcmeta(par1ResourceLocation); + Iterator iterator = this.resourcePacks.iterator(); + + while (iterator.hasNext()) + { + IResourcePack iresourcepack = (IResourcePack)iterator.next(); + + if (iresourcepack.resourceExists(par1ResourceLocation)) + { + InputStream inputstream = iresourcepack.resourceExists(resourcelocation1) ? iresourcepack.getInputStream(resourcelocation1) : null; + arraylist.add(new SimpleResource(par1ResourceLocation, iresourcepack.getInputStream(par1ResourceLocation), inputstream, this.frmMetadataSerializer)); + } + } + + if (arraylist.isEmpty()) + { + throw new FileNotFoundException(par1ResourceLocation.toString()); + } + else + { + return arraylist; + } + } + + static ResourceLocation getLocationMcmeta(ResourceLocation par0ResourceLocation) + { + return new ResourceLocation(par0ResourceLocation.getResourceDomain(), par0ResourceLocation.getResourcePath() + ".mcmeta"); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/resources/FileResourcePack.java b/src/main/java/net/minecraft/client/resources/FileResourcePack.java new file mode 100644 index 0000000..3a95342 --- /dev/null +++ b/src/main/java/net/minecraft/client/resources/FileResourcePack.java @@ -0,0 +1,127 @@ +package net.minecraft.client.resources; + +import com.google.common.base.Splitter; +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.Closeable; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Enumeration; +import java.util.HashSet; +import java.util.Set; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +@SideOnly(Side.CLIENT) +public class FileResourcePack extends AbstractResourcePack implements Closeable +{ + public static final Splitter entryNameSplitter = Splitter.on('/').omitEmptyStrings().limit(3); + private ZipFile resourcePackZipFile; + private static final String __OBFID = "CL_00001075"; + + public FileResourcePack(File par1File) + { + super(par1File); + } + + private ZipFile getResourcePackZipFile() throws IOException + { + if (this.resourcePackZipFile == null) + { + this.resourcePackZipFile = new ZipFile(this.resourcePackFile); + } + + return this.resourcePackZipFile; + } + + protected InputStream getInputStreamByName(String par1Str) throws IOException + { + ZipFile zipfile = this.getResourcePackZipFile(); + ZipEntry zipentry = zipfile.getEntry(par1Str); + + if (zipentry == null) + { + throw new ResourcePackFileNotFoundException(this.resourcePackFile, par1Str); + } + else + { + return zipfile.getInputStream(zipentry); + } + } + + public boolean hasResourceName(String par1Str) + { + try + { + return this.getResourcePackZipFile().getEntry(par1Str) != null; + } + catch (IOException ioexception) + { + return false; + } + } + + public Set getResourceDomains() + { + ZipFile zipfile; + + try + { + zipfile = this.getResourcePackZipFile(); + } + catch (IOException ioexception) + { + return Collections.emptySet(); + } + + Enumeration enumeration = zipfile.entries(); + HashSet hashset = Sets.newHashSet(); + + while (enumeration.hasMoreElements()) + { + ZipEntry zipentry = (ZipEntry)enumeration.nextElement(); + String s = zipentry.getName(); + + if (s.startsWith("assets/")) + { + ArrayList arraylist = Lists.newArrayList(entryNameSplitter.split(s)); + + if (arraylist.size() > 1) + { + String s1 = (String)arraylist.get(1); + + if (!s1.equals(s1.toLowerCase())) + { + this.logNameNotLowercase(s1); + } + else + { + hashset.add(s1); + } + } + } + } + + return hashset; + } + + protected void finalize() throws Throwable + { + this.close(); + super.finalize(); + } + + public void close() throws IOException + { + if (this.resourcePackZipFile != null) + { + this.resourcePackZipFile.close(); + this.resourcePackZipFile = null; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/resources/FolderResourcePack.java b/src/main/java/net/minecraft/client/resources/FolderResourcePack.java new file mode 100644 index 0000000..0e3722a --- /dev/null +++ b/src/main/java/net/minecraft/client/resources/FolderResourcePack.java @@ -0,0 +1,63 @@ +package net.minecraft.client.resources; + +import com.google.common.collect.Sets; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashSet; +import java.util.Set; +import org.apache.commons.io.filefilter.DirectoryFileFilter; + +@SideOnly(Side.CLIENT) +public class FolderResourcePack extends AbstractResourcePack +{ + private static final String __OBFID = "CL_00001076"; + + public FolderResourcePack(File par1File) + { + super(par1File); + } + + protected InputStream getInputStreamByName(String par1Str) throws IOException + { + return new BufferedInputStream(new FileInputStream(new File(this.resourcePackFile, par1Str))); + } + + protected boolean hasResourceName(String par1Str) + { + return (new File(this.resourcePackFile, par1Str)).isFile(); + } + + public Set getResourceDomains() + { + HashSet hashset = Sets.newHashSet(); + File file1 = new File(this.resourcePackFile, "assets/"); + + if (file1.isDirectory()) + { + File[] afile = file1.listFiles((java.io.FileFilter)DirectoryFileFilter.DIRECTORY); + int i = afile.length; + + for (int j = 0; j < i; ++j) + { + File file2 = afile[j]; + String s = getRelativeName(file1, file2); + + if (!s.equals(s.toLowerCase())) + { + this.logNameNotLowercase(s); + } + else + { + hashset.add(s.substring(0, s.length() - 1)); + } + } + } + + return hashset; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/resources/FoliageColorReloadListener.java b/src/main/java/net/minecraft/client/resources/FoliageColorReloadListener.java new file mode 100644 index 0000000..31463ff --- /dev/null +++ b/src/main/java/net/minecraft/client/resources/FoliageColorReloadListener.java @@ -0,0 +1,27 @@ +package net.minecraft.client.resources; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.client.renderer.texture.TextureUtil; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.ColorizerFoliage; + +@SideOnly(Side.CLIENT) +public class FoliageColorReloadListener implements IResourceManagerReloadListener +{ + private static final ResourceLocation field_130079_a = new ResourceLocation("textures/colormap/foliage.png"); + private static final String __OBFID = "CL_00001077"; + + public void onResourceManagerReload(IResourceManager par1ResourceManager) + { + try + { + ColorizerFoliage.setFoliageBiomeColorizer(TextureUtil.readImageData(par1ResourceManager, field_130079_a)); + } + catch (IOException ioexception) + { + ; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/resources/GrassColorReloadListener.java b/src/main/java/net/minecraft/client/resources/GrassColorReloadListener.java new file mode 100644 index 0000000..e5aec78 --- /dev/null +++ b/src/main/java/net/minecraft/client/resources/GrassColorReloadListener.java @@ -0,0 +1,27 @@ +package net.minecraft.client.resources; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.client.renderer.texture.TextureUtil; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.ColorizerGrass; + +@SideOnly(Side.CLIENT) +public class GrassColorReloadListener implements IResourceManagerReloadListener +{ + private static final ResourceLocation field_130078_a = new ResourceLocation("textures/colormap/grass.png"); + private static final String __OBFID = "CL_00001078"; + + public void onResourceManagerReload(IResourceManager par1ResourceManager) + { + try + { + ColorizerGrass.setGrassBiomeColorizer(TextureUtil.readImageData(par1ResourceManager, field_130078_a)); + } + catch (IOException ioexception) + { + ; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/resources/I18n.java b/src/main/java/net/minecraft/client/resources/I18n.java new file mode 100644 index 0000000..9446f66 --- /dev/null +++ b/src/main/java/net/minecraft/client/resources/I18n.java @@ -0,0 +1,21 @@ +package net.minecraft.client.resources; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class I18n +{ + private static Locale i18nLocale; + private static final String __OBFID = "CL_00001094"; + + static void setLocale(Locale par0Locale) + { + i18nLocale = par0Locale; + } + + public static String format(String par0Str, Object ... par1ArrayOfObj) + { + return i18nLocale.formatMessage(par0Str, par1ArrayOfObj); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/resources/IReloadableResourceManager.java b/src/main/java/net/minecraft/client/resources/IReloadableResourceManager.java new file mode 100644 index 0000000..064a345 --- /dev/null +++ b/src/main/java/net/minecraft/client/resources/IReloadableResourceManager.java @@ -0,0 +1,13 @@ +package net.minecraft.client.resources; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; + +@SideOnly(Side.CLIENT) +public interface IReloadableResourceManager extends IResourceManager +{ + void reloadResources(List var1); + + void registerReloadListener(IResourceManagerReloadListener var1); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/resources/IResource.java b/src/main/java/net/minecraft/client/resources/IResource.java new file mode 100644 index 0000000..05e31ce --- /dev/null +++ b/src/main/java/net/minecraft/client/resources/IResource.java @@ -0,0 +1,16 @@ +package net.minecraft.client.resources; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.InputStream; +import net.minecraft.client.resources.data.IMetadataSection; + +@SideOnly(Side.CLIENT) +public interface IResource +{ + InputStream getInputStream(); + + boolean hasMetadata(); + + IMetadataSection getMetadata(String var1); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/resources/IResourceManager.java b/src/main/java/net/minecraft/client/resources/IResourceManager.java new file mode 100644 index 0000000..3cebdd4 --- /dev/null +++ b/src/main/java/net/minecraft/client/resources/IResourceManager.java @@ -0,0 +1,18 @@ +package net.minecraft.client.resources; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import java.util.List; +import java.util.Set; +import net.minecraft.util.ResourceLocation; + +@SideOnly(Side.CLIENT) +public interface IResourceManager +{ + Set getResourceDomains(); + + IResource getResource(ResourceLocation var1) throws IOException; + + List getAllResources(ResourceLocation var1) throws IOException; +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/resources/IResourceManagerReloadListener.java b/src/main/java/net/minecraft/client/resources/IResourceManagerReloadListener.java new file mode 100644 index 0000000..53bfa50 --- /dev/null +++ b/src/main/java/net/minecraft/client/resources/IResourceManagerReloadListener.java @@ -0,0 +1,10 @@ +package net.minecraft.client.resources; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public interface IResourceManagerReloadListener +{ + void onResourceManagerReload(IResourceManager var1); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/resources/IResourcePack.java b/src/main/java/net/minecraft/client/resources/IResourcePack.java new file mode 100644 index 0000000..3af7c5e --- /dev/null +++ b/src/main/java/net/minecraft/client/resources/IResourcePack.java @@ -0,0 +1,27 @@ +package net.minecraft.client.resources; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.io.InputStream; +import java.util.Set; +import net.minecraft.client.resources.data.IMetadataSection; +import net.minecraft.client.resources.data.IMetadataSerializer; +import net.minecraft.util.ResourceLocation; + +@SideOnly(Side.CLIENT) +public interface IResourcePack +{ + InputStream getInputStream(ResourceLocation var1) throws IOException; + + boolean resourceExists(ResourceLocation var1); + + Set getResourceDomains(); + + IMetadataSection getPackMetadata(IMetadataSerializer var1, String var2) throws IOException; + + BufferedImage getPackImage() throws IOException; + + String getPackName(); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/resources/Language.java b/src/main/java/net/minecraft/client/resources/Language.java new file mode 100644 index 0000000..ad2da30 --- /dev/null +++ b/src/main/java/net/minecraft/client/resources/Language.java @@ -0,0 +1,57 @@ +package net.minecraft.client.resources; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class Language implements Comparable +{ + private final String languageCode; + private final String region; + private final String name; + private final boolean bidirectional; + private static final String __OBFID = "CL_00001095"; + + public Language(String par1Str, String par2Str, String par3Str, boolean par4) + { + this.languageCode = par1Str; + this.region = par2Str; + this.name = par3Str; + this.bidirectional = par4; + } + + public String getLanguageCode() + { + return this.languageCode; + } + + public boolean isBidirectional() + { + return this.bidirectional; + } + + public String toString() + { + return String.format("%s (%s)", new Object[] {this.name, this.region}); + } + + public boolean equals(Object par1Obj) + { + return this == par1Obj ? true : (!(par1Obj instanceof Language) ? false : this.languageCode.equals(((Language)par1Obj).languageCode)); + } + + public int hashCode() + { + return this.languageCode.hashCode(); + } + + public int compareTo(Language par1Language) + { + return this.languageCode.compareTo(par1Language.languageCode); + } + + public int compareTo(Object par1Obj) + { + return this.compareTo((Language)par1Obj); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/resources/LanguageManager.java b/src/main/java/net/minecraft/client/resources/LanguageManager.java new file mode 100644 index 0000000..ebe726c --- /dev/null +++ b/src/main/java/net/minecraft/client/resources/LanguageManager.java @@ -0,0 +1,116 @@ +package net.minecraft.client.resources; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; + +import cpw.mods.fml.common.registry.LanguageRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.SortedSet; +import net.minecraft.client.resources.data.IMetadataSerializer; +import net.minecraft.client.resources.data.LanguageMetadataSection; +import net.minecraft.util.StringTranslate; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +@SideOnly(Side.CLIENT) +public class LanguageManager implements IResourceManagerReloadListener +{ + private static final Logger logger = LogManager.getLogger(); + private final IMetadataSerializer theMetadataSerializer; + private String currentLanguage; + protected static final Locale currentLocale = new Locale(); + private Map languageMap = Maps.newHashMap(); + private static final String __OBFID = "CL_00001096"; + + public LanguageManager(IMetadataSerializer par1MetadataSerializer, String par2Str) + { + this.theMetadataSerializer = par1MetadataSerializer; + this.currentLanguage = par2Str; + I18n.setLocale(currentLocale); + } + + public void parseLanguageMetadata(List par1List) + { + this.languageMap.clear(); + Iterator iterator = par1List.iterator(); + + while (iterator.hasNext()) + { + IResourcePack iresourcepack = (IResourcePack)iterator.next(); + + try + { + LanguageMetadataSection languagemetadatasection = (LanguageMetadataSection)iresourcepack.getPackMetadata(this.theMetadataSerializer, "language"); + + if (languagemetadatasection != null) + { + Iterator iterator1 = languagemetadatasection.getLanguages().iterator(); + + while (iterator1.hasNext()) + { + Language language = (Language)iterator1.next(); + + if (!this.languageMap.containsKey(language.getLanguageCode())) + { + this.languageMap.put(language.getLanguageCode(), language); + } + } + } + } + catch (RuntimeException runtimeexception) + { + logger.warn("Unable to parse metadata section of resourcepack: " + iresourcepack.getPackName(), runtimeexception); + } + catch (IOException ioexception) + { + logger.warn("Unable to parse metadata section of resourcepack: " + iresourcepack.getPackName(), ioexception); + } + } + } + + public void onResourceManagerReload(IResourceManager par1ResourceManager) + { + ArrayList arraylist = Lists.newArrayList(new String[] {"en_US"}); + + if (!"en_US".equals(this.currentLanguage)) + { + arraylist.add(this.currentLanguage); + } + + currentLocale.loadLocaleDataFiles(par1ResourceManager, arraylist); + LanguageRegistry.instance().loadLanguageTable(currentLocale.field_135032_a, this.currentLanguage); + StringTranslate.replaceWith(currentLocale.field_135032_a); + } + + public boolean isCurrentLocaleUnicode() + { + return currentLocale.isUnicode(); + } + + public boolean isCurrentLanguageBidirectional() + { + return this.getCurrentLanguage() != null && this.getCurrentLanguage().isBidirectional(); + } + + public void setCurrentLanguage(Language par1Language) + { + this.currentLanguage = par1Language.getLanguageCode(); + } + + public Language getCurrentLanguage() + { + return this.languageMap.containsKey(this.currentLanguage) ? (Language)this.languageMap.get(this.currentLanguage) : (Language)this.languageMap.get("en_US"); + } + + public SortedSet getLanguages() + { + return Sets.newTreeSet(this.languageMap.values()); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/resources/Locale.java b/src/main/java/net/minecraft/client/resources/Locale.java new file mode 100644 index 0000000..151c874 --- /dev/null +++ b/src/main/java/net/minecraft/client/resources/Locale.java @@ -0,0 +1,140 @@ +package net.minecraft.client.resources; + +import com.google.common.base.Splitter; +import com.google.common.collect.Iterables; +import com.google.common.collect.Maps; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import java.io.InputStream; +import java.util.IllegalFormatException; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.regex.Pattern; +import net.minecraft.util.ResourceLocation; +import org.apache.commons.io.Charsets; +import org.apache.commons.io.IOUtils; + +@SideOnly(Side.CLIENT) +public class Locale +{ + private static final Splitter splitter = Splitter.on('=').limit(2); + private static final Pattern field_135031_c = Pattern.compile("%(\\d+\\$)?[\\d\\.]*[df]"); + Map field_135032_a = Maps.newHashMap(); + private boolean field_135029_d; + private static final String __OBFID = "CL_00001097"; + + public synchronized void loadLocaleDataFiles(IResourceManager par1ResourceManager, List par2List) + { + this.field_135032_a.clear(); + Iterator iterator = par2List.iterator(); + + while (iterator.hasNext()) + { + String s = (String)iterator.next(); + String s1 = String.format("lang/%s.lang", new Object[] {s}); + Iterator iterator1 = par1ResourceManager.getResourceDomains().iterator(); + + while (iterator1.hasNext()) + { + String s2 = (String)iterator1.next(); + + try + { + this.loadLocaleData(par1ResourceManager.getAllResources(new ResourceLocation(s2, s1))); + } + catch (IOException ioexception) + { + ; + } + } + } + + this.checkUnicode(); + } + + public boolean isUnicode() + { + return this.field_135029_d; + } + + private void checkUnicode() + { + this.field_135029_d = false; + int i = 0; + int j = 0; + Iterator iterator = this.field_135032_a.values().iterator(); + + while (iterator.hasNext()) + { + String s = (String)iterator.next(); + int k = s.length(); + j += k; + + for (int l = 0; l < k; ++l) + { + if (s.charAt(l) >= 256) + { + ++i; + } + } + } + + float f = (float)i / (float)j; + this.field_135029_d = (double)f > 0.1D; + } + + private void loadLocaleData(List par1List) throws IOException + { + Iterator iterator = par1List.iterator(); + + while (iterator.hasNext()) + { + IResource iresource = (IResource)iterator.next(); + this.loadLocaleData(iresource.getInputStream()); + } + } + + private void loadLocaleData(InputStream par1InputStream) throws IOException + { + Iterator iterator = IOUtils.readLines(par1InputStream, Charsets.UTF_8).iterator(); + + while (iterator.hasNext()) + { + String s = (String)iterator.next(); + + if (!s.isEmpty() && s.charAt(0) != 35) + { + String[] astring = (String[])Iterables.toArray(splitter.split(s), String.class); + + if (astring != null && astring.length == 2) + { + String s1 = astring[0]; + String s2 = field_135031_c.matcher(astring[1]).replaceAll("%$1s"); + this.field_135032_a.put(s1, s2); + } + } + } + } + + private String translateKeyPrivate(String par1Str) + { + String s1 = (String)this.field_135032_a.get(par1Str); + return s1 == null ? par1Str : s1; + } + + public String formatMessage(String par1Str, Object[] par2ArrayOfObj) + { + String s1 = this.translateKeyPrivate(par1Str); + + try + { + return String.format(s1, par2ArrayOfObj); + } + catch (IllegalFormatException illegalformatexception) + { + return "Format error: " + s1; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/resources/ResourcePackFileNotFoundException.java b/src/main/java/net/minecraft/client/resources/ResourcePackFileNotFoundException.java new file mode 100644 index 0000000..bd44f56 --- /dev/null +++ b/src/main/java/net/minecraft/client/resources/ResourcePackFileNotFoundException.java @@ -0,0 +1,17 @@ +package net.minecraft.client.resources; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.File; +import java.io.FileNotFoundException; + +@SideOnly(Side.CLIENT) +public class ResourcePackFileNotFoundException extends FileNotFoundException +{ + private static final String __OBFID = "CL_00001086"; + + public ResourcePackFileNotFoundException(File par1File, String par2Str) + { + super(String.format("\'%s\' in ResourcePack \'%s\'", new Object[] {par2Str, par1File})); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/resources/ResourcePackListEntry.java b/src/main/java/net/minecraft/client/resources/ResourcePackListEntry.java new file mode 100644 index 0000000..e78eb58 --- /dev/null +++ b/src/main/java/net/minecraft/client/resources/ResourcePackListEntry.java @@ -0,0 +1,190 @@ +package net.minecraft.client.resources; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.GuiListExtended; +import net.minecraft.client.gui.GuiScreenResourcePacks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public abstract class ResourcePackListEntry implements GuiListExtended.IGuiListEntry +{ + private static final ResourceLocation field_148316_c = new ResourceLocation("textures/gui/resource_packs.png"); + protected final Minecraft field_148317_a; + protected final GuiScreenResourcePacks field_148315_b; + private static final String __OBFID = "CL_00000821"; + + public ResourcePackListEntry(GuiScreenResourcePacks p_i45051_1_) + { + this.field_148315_b = p_i45051_1_; + this.field_148317_a = Minecraft.getMinecraft(); + } + + public void drawEntry(int p_148279_1_, int p_148279_2_, int p_148279_3_, int p_148279_4_, int p_148279_5_, Tessellator p_148279_6_, int p_148279_7_, int p_148279_8_, boolean p_148279_9_) + { + this.func_148313_c(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + Gui.func_146110_a(p_148279_2_, p_148279_3_, 0.0F, 0.0F, 32, 32, 32.0F, 32.0F); + int i2; + + if ((this.field_148317_a.gameSettings.touchscreen || p_148279_9_) && this.func_148310_d()) + { + this.field_148317_a.getTextureManager().bindTexture(field_148316_c); + Gui.drawRect(p_148279_2_, p_148279_3_, p_148279_2_ + 32, p_148279_3_ + 32, -1601138544); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int l1 = p_148279_7_ - p_148279_2_; + i2 = p_148279_8_ - p_148279_3_; + + if (this.func_148309_e()) + { + if (l1 < 32) + { + Gui.func_146110_a(p_148279_2_, p_148279_3_, 0.0F, 32.0F, 32, 32, 256.0F, 256.0F); + } + else + { + Gui.func_146110_a(p_148279_2_, p_148279_3_, 0.0F, 0.0F, 32, 32, 256.0F, 256.0F); + } + } + else + { + if (this.func_148308_f()) + { + if (l1 < 16) + { + Gui.func_146110_a(p_148279_2_, p_148279_3_, 32.0F, 32.0F, 32, 32, 256.0F, 256.0F); + } + else + { + Gui.func_146110_a(p_148279_2_, p_148279_3_, 32.0F, 0.0F, 32, 32, 256.0F, 256.0F); + } + } + + if (this.func_148314_g()) + { + if (l1 < 32 && l1 > 16 && i2 < 16) + { + Gui.func_146110_a(p_148279_2_, p_148279_3_, 96.0F, 32.0F, 32, 32, 256.0F, 256.0F); + } + else + { + Gui.func_146110_a(p_148279_2_, p_148279_3_, 96.0F, 0.0F, 32, 32, 256.0F, 256.0F); + } + } + + if (this.func_148307_h()) + { + if (l1 < 32 && l1 > 16 && i2 > 16) + { + Gui.func_146110_a(p_148279_2_, p_148279_3_, 64.0F, 32.0F, 32, 32, 256.0F, 256.0F); + } + else + { + Gui.func_146110_a(p_148279_2_, p_148279_3_, 64.0F, 0.0F, 32, 32, 256.0F, 256.0F); + } + } + } + } + + String s = this.func_148312_b(); + i2 = this.field_148317_a.fontRenderer.getStringWidth(s); + + if (i2 > 157) + { + s = this.field_148317_a.fontRenderer.trimStringToWidth(s, 157 - this.field_148317_a.fontRenderer.getStringWidth("...")) + "..."; + } + + this.field_148317_a.fontRenderer.drawStringWithShadow(s, p_148279_2_ + 32 + 2, p_148279_3_ + 1, 16777215); + List list = this.field_148317_a.fontRenderer.listFormattedStringToWidth(this.func_148311_a(), 157); + + for (int j2 = 0; j2 < 2 && j2 < list.size(); ++j2) + { + this.field_148317_a.fontRenderer.drawStringWithShadow((String)list.get(j2), p_148279_2_ + 32 + 2, p_148279_3_ + 12 + 10 * j2, 8421504); + } + } + + protected abstract String func_148311_a(); + + protected abstract String func_148312_b(); + + protected abstract void func_148313_c(); + + protected boolean func_148310_d() + { + return true; + } + + protected boolean func_148309_e() + { + return !this.field_148315_b.func_146961_a(this); + } + + protected boolean func_148308_f() + { + return this.field_148315_b.func_146961_a(this); + } + + protected boolean func_148314_g() + { + List list = this.field_148315_b.func_146962_b(this); + int i = list.indexOf(this); + return i > 0 && ((ResourcePackListEntry)list.get(i - 1)).func_148310_d(); + } + + protected boolean func_148307_h() + { + List list = this.field_148315_b.func_146962_b(this); + int i = list.indexOf(this); + return i >= 0 && i < list.size() - 1 && ((ResourcePackListEntry)list.get(i + 1)).func_148310_d(); + } + + public boolean mousePressed(int p_148278_1_, int p_148278_2_, int p_148278_3_, int p_148278_4_, int p_148278_5_, int p_148278_6_) + { + if (this.func_148310_d() && p_148278_5_ <= 32) + { + if (this.func_148309_e()) + { + this.field_148315_b.func_146962_b(this).remove(this); + this.field_148315_b.func_146963_h().add(0, this); + return true; + } + + if (p_148278_5_ < 16 && this.func_148308_f()) + { + this.field_148315_b.func_146962_b(this).remove(this); + this.field_148315_b.func_146964_g().add(0, this); + return true; + } + + List list; + int k1; + + if (p_148278_5_ > 16 && p_148278_6_ < 16 && this.func_148314_g()) + { + list = this.field_148315_b.func_146962_b(this); + k1 = list.indexOf(this); + list.remove(this); + list.add(k1 - 1, this); + return true; + } + + if (p_148278_5_ > 16 && p_148278_6_ > 16 && this.func_148307_h()) + { + list = this.field_148315_b.func_146962_b(this); + k1 = list.indexOf(this); + list.remove(this); + list.add(k1 + 1, this); + return true; + } + } + + return false; + } + + public void mouseReleased(int p_148277_1_, int p_148277_2_, int p_148277_3_, int p_148277_4_, int p_148277_5_, int p_148277_6_) {} +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/resources/ResourcePackListEntryDefault.java b/src/main/java/net/minecraft/client/resources/ResourcePackListEntryDefault.java new file mode 100644 index 0000000..f4f2f2c --- /dev/null +++ b/src/main/java/net/minecraft/client/resources/ResourcePackListEntryDefault.java @@ -0,0 +1,94 @@ +package net.minecraft.client.resources; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.client.gui.GuiScreenResourcePacks; +import net.minecraft.client.renderer.texture.DynamicTexture; +import net.minecraft.client.renderer.texture.TextureUtil; +import net.minecraft.client.resources.data.PackMetadataSection; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +@SideOnly(Side.CLIENT) +public class ResourcePackListEntryDefault extends ResourcePackListEntry +{ + private static final Logger logger = LogManager.getLogger(); + private final IResourcePack field_148320_d; + private final ResourceLocation field_148321_e; + private static final String __OBFID = "CL_00000822"; + + public ResourcePackListEntryDefault(GuiScreenResourcePacks p_i45052_1_) + { + super(p_i45052_1_); + this.field_148320_d = this.field_148317_a.getResourcePackRepository().rprDefaultResourcePack; + DynamicTexture dynamictexture; + + try + { + dynamictexture = new DynamicTexture(this.field_148320_d.getPackImage()); + } + catch (IOException ioexception) + { + dynamictexture = TextureUtil.missingTexture; + } + + this.field_148321_e = this.field_148317_a.getTextureManager().getDynamicTextureLocation("texturepackicon", dynamictexture); + } + + protected String func_148311_a() + { + try + { + PackMetadataSection packmetadatasection = (PackMetadataSection)this.field_148320_d.getPackMetadata(this.field_148317_a.getResourcePackRepository().rprMetadataSerializer, "pack"); + + if (packmetadatasection != null) + { + return packmetadatasection.getPackDescription(); + } + } + catch (IOException ioexception) + { + logger.error("Couldn\'t load metadata info", ioexception); + } + + return EnumChatFormatting.RED + "Missing " + "pack.mcmeta" + " :("; + } + + protected boolean func_148309_e() + { + return false; + } + + protected boolean func_148308_f() + { + return false; + } + + protected boolean func_148314_g() + { + return false; + } + + protected boolean func_148307_h() + { + return false; + } + + protected String func_148312_b() + { + return "Default"; + } + + protected void func_148313_c() + { + this.field_148317_a.getTextureManager().bindTexture(this.field_148321_e); + } + + protected boolean func_148310_d() + { + return false; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/resources/ResourcePackListEntryFound.java b/src/main/java/net/minecraft/client/resources/ResourcePackListEntryFound.java new file mode 100644 index 0000000..0c932a5 --- /dev/null +++ b/src/main/java/net/minecraft/client/resources/ResourcePackListEntryFound.java @@ -0,0 +1,38 @@ +package net.minecraft.client.resources; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.gui.GuiScreenResourcePacks; + +@SideOnly(Side.CLIENT) +public class ResourcePackListEntryFound extends ResourcePackListEntry +{ + private final ResourcePackRepository.Entry field_148319_c; + private static final String __OBFID = "CL_00000823"; + + public ResourcePackListEntryFound(GuiScreenResourcePacks p_i45053_1_, ResourcePackRepository.Entry p_i45053_2_) + { + super(p_i45053_1_); + this.field_148319_c = p_i45053_2_; + } + + protected void func_148313_c() + { + this.field_148319_c.bindTexturePackIcon(this.field_148317_a.getTextureManager()); + } + + protected String func_148311_a() + { + return this.field_148319_c.getTexturePackDescription(); + } + + protected String func_148312_b() + { + return this.field_148319_c.getResourcePackName(); + } + + public ResourcePackRepository.Entry func_148318_i() + { + return this.field_148319_c; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/resources/ResourcePackRepository.java b/src/main/java/net/minecraft/client/resources/ResourcePackRepository.java new file mode 100644 index 0000000..9eb09f5 --- /dev/null +++ b/src/main/java/net/minecraft/client/resources/ResourcePackRepository.java @@ -0,0 +1,304 @@ +package net.minecraft.client.resources; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.awt.image.BufferedImage; +import java.io.Closeable; +import java.io.File; +import java.io.FileFilter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreenWorking; +import net.minecraft.client.renderer.texture.DynamicTexture; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.client.resources.data.IMetadataSerializer; +import net.minecraft.client.resources.data.PackMetadataSection; +import net.minecraft.client.settings.GameSettings; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.HttpUtil; +import net.minecraft.util.ResourceLocation; +import org.apache.commons.io.IOUtils; + +@SideOnly(Side.CLIENT) +public class ResourcePackRepository +{ + protected static final FileFilter resourcePackFilter = new FileFilter() + { + private static final String __OBFID = "CL_00001088"; + public boolean accept(File par1File) + { + boolean flag = par1File.isFile() && par1File.getName().endsWith(".zip"); + boolean flag1 = par1File.isDirectory() && (new File(par1File, "pack.mcmeta")).isFile(); + return flag || flag1; + } + }; + private final File dirResourcepacks; + public final IResourcePack rprDefaultResourcePack; + private final File field_148534_e; + public final IMetadataSerializer rprMetadataSerializer; + private IResourcePack field_148532_f; + private boolean field_148533_g; + private List repositoryEntriesAll = Lists.newArrayList(); + private List repositoryEntries = Lists.newArrayList(); + private static final String __OBFID = "CL_00001087"; + + public ResourcePackRepository(File p_i45101_1_, File p_i45101_2_, IResourcePack p_i45101_3_, IMetadataSerializer p_i45101_4_, GameSettings p_i45101_5_) + { + this.dirResourcepacks = p_i45101_1_; + this.field_148534_e = p_i45101_2_; + this.rprDefaultResourcePack = p_i45101_3_; + this.rprMetadataSerializer = p_i45101_4_; + this.fixDirResourcepacks(); + this.updateRepositoryEntriesAll(); + Iterator iterator = p_i45101_5_.resourcePacks.iterator(); + + while (iterator.hasNext()) + { + String s = (String)iterator.next(); + Iterator iterator1 = this.repositoryEntriesAll.iterator(); + + while (iterator1.hasNext()) + { + ResourcePackRepository.Entry entry = (ResourcePackRepository.Entry)iterator1.next(); + + if (entry.getResourcePackName().equals(s)) + { + this.repositoryEntries.add(entry); + break; + } + } + } + } + + private void fixDirResourcepacks() + { + if (!this.dirResourcepacks.isDirectory()) + { + this.dirResourcepacks.delete(); + this.dirResourcepacks.mkdirs(); + } + } + + private List getResourcePackFiles() + { + return this.dirResourcepacks.isDirectory() ? Arrays.asList(this.dirResourcepacks.listFiles(resourcePackFilter)) : Collections.emptyList(); + } + + public void updateRepositoryEntriesAll() + { + ArrayList arraylist = Lists.newArrayList(); + Iterator iterator = this.getResourcePackFiles().iterator(); + + while (iterator.hasNext()) + { + File file1 = (File)iterator.next(); + ResourcePackRepository.Entry entry = new ResourcePackRepository.Entry(file1, null); + + if (!this.repositoryEntriesAll.contains(entry)) + { + try + { + entry.updateResourcePack(); + arraylist.add(entry); + } + catch (Exception exception) + { + arraylist.remove(entry); + } + } + else + { + int i = this.repositoryEntriesAll.indexOf(entry); + + if (i > -1 && i < this.repositoryEntriesAll.size()) + { + arraylist.add(this.repositoryEntriesAll.get(i)); + } + } + } + + this.repositoryEntriesAll.removeAll(arraylist); + iterator = this.repositoryEntriesAll.iterator(); + + while (iterator.hasNext()) + { + ResourcePackRepository.Entry entry1 = (ResourcePackRepository.Entry)iterator.next(); + entry1.closeResourcePack(); + } + + this.repositoryEntriesAll = arraylist; + } + + public List getRepositoryEntriesAll() + { + return ImmutableList.copyOf(this.repositoryEntriesAll); + } + + public List getRepositoryEntries() + { + return ImmutableList.copyOf(this.repositoryEntries); + } + + public void func_148527_a(List p_148527_1_) + { + this.repositoryEntries.clear(); + this.repositoryEntries.addAll(p_148527_1_); + } + + public File getDirResourcepacks() + { + return this.dirResourcepacks; + } + + public void func_148526_a(String p_148526_1_) + { + String s1 = p_148526_1_.substring(p_148526_1_.lastIndexOf("/") + 1); + + if (s1.contains("?")) + { + s1 = s1.substring(0, s1.indexOf("?")); + } + + if (s1.endsWith(".zip")) + { + File file1 = new File(this.field_148534_e, s1.replaceAll("\\W", "")); + this.func_148529_f(); + this.func_148528_a(p_148526_1_, file1); + } + } + + private void func_148528_a(String p_148528_1_, File p_148528_2_) + { + HashMap hashmap = Maps.newHashMap(); + GuiScreenWorking guiscreenworking = new GuiScreenWorking(); + hashmap.put("X-Minecraft-Username", Minecraft.getMinecraft().getSession().getUsername()); + hashmap.put("X-Minecraft-UUID", Minecraft.getMinecraft().getSession().getPlayerID()); + hashmap.put("X-Minecraft-Version", "1.7.2"); + this.field_148533_g = true; + Minecraft.getMinecraft().displayGuiScreen(guiscreenworking); + HttpUtil.func_151223_a(p_148528_2_, p_148528_1_, new HttpUtil.DownloadListener() + { + private static final String __OBFID = "CL_00001089"; + public void func_148522_a(File p_148522_1_) + { + if (ResourcePackRepository.this.field_148533_g) + { + ResourcePackRepository.this.field_148533_g = false; + ResourcePackRepository.this.field_148532_f = new FileResourcePack(p_148522_1_); + Minecraft.getMinecraft().scheduleResourcesRefresh(); + } + } + }, hashmap, 52428800, guiscreenworking, Minecraft.getMinecraft().getProxy()); + } + + public IResourcePack func_148530_e() + { + return this.field_148532_f; + } + + public void func_148529_f() + { + this.field_148532_f = null; + this.field_148533_g = false; + } + + @SideOnly(Side.CLIENT) + public class Entry + { + private final File resourcePackFile; + private IResourcePack reResourcePack; + private PackMetadataSection rePackMetadataSection; + private BufferedImage texturePackIcon; + private ResourceLocation locationTexturePackIcon; + private static final String __OBFID = "CL_00001090"; + + private Entry(File par2File) + { + this.resourcePackFile = par2File; + } + + public void updateResourcePack() throws IOException + { + this.reResourcePack = (IResourcePack)(this.resourcePackFile.isDirectory() ? new FolderResourcePack(this.resourcePackFile) : new FileResourcePack(this.resourcePackFile)); + this.rePackMetadataSection = (PackMetadataSection)this.reResourcePack.getPackMetadata(ResourcePackRepository.this.rprMetadataSerializer, "pack"); + + try + { + this.texturePackIcon = this.reResourcePack.getPackImage(); + } + catch (IOException ioexception) + { + ; + } + + if (this.texturePackIcon == null) + { + this.texturePackIcon = ResourcePackRepository.this.rprDefaultResourcePack.getPackImage(); + } + + this.closeResourcePack(); + } + + public void bindTexturePackIcon(TextureManager par1TextureManager) + { + if (this.locationTexturePackIcon == null) + { + this.locationTexturePackIcon = par1TextureManager.getDynamicTextureLocation("texturepackicon", new DynamicTexture(this.texturePackIcon)); + } + + par1TextureManager.bindTexture(this.locationTexturePackIcon); + } + + public void closeResourcePack() + { + if (this.reResourcePack instanceof Closeable) + { + IOUtils.closeQuietly((Closeable)this.reResourcePack); + } + } + + public IResourcePack getResourcePack() + { + return this.reResourcePack; + } + + public String getResourcePackName() + { + return this.reResourcePack.getPackName(); + } + + public String getTexturePackDescription() + { + return this.rePackMetadataSection == null ? EnumChatFormatting.RED + "Invalid pack.mcmeta (or missing \'pack\' section)" : this.rePackMetadataSection.getPackDescription(); + } + + public boolean equals(Object par1Obj) + { + return this == par1Obj ? true : (par1Obj instanceof ResourcePackRepository.Entry ? this.toString().equals(par1Obj.toString()) : false); + } + + public int hashCode() + { + return this.toString().hashCode(); + } + + public String toString() + { + return String.format("%s:%s:%d", new Object[] {this.resourcePackFile.getName(), this.resourcePackFile.isDirectory() ? "folder" : "zip", Long.valueOf(this.resourcePackFile.lastModified())}); + } + + Entry(File par2File, Object par3ResourcePackRepositoryFilter) + { + this(par2File); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/resources/SimpleReloadableResourceManager.java b/src/main/java/net/minecraft/client/resources/SimpleReloadableResourceManager.java new file mode 100644 index 0000000..f25b833 --- /dev/null +++ b/src/main/java/net/minecraft/client/resources/SimpleReloadableResourceManager.java @@ -0,0 +1,137 @@ +package net.minecraft.client.resources; + +import com.google.common.base.Function; +import com.google.common.base.Joiner; +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import net.minecraft.client.resources.data.IMetadataSerializer; +import net.minecraft.util.ResourceLocation; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +@SideOnly(Side.CLIENT) +public class SimpleReloadableResourceManager implements IReloadableResourceManager +{ + private static final Logger logger = LogManager.getLogger(); + private static final Joiner joinerResourcePacks = Joiner.on(", "); + private final Map domainResourceManagers = Maps.newHashMap(); + private final List reloadListeners = Lists.newArrayList(); + private final Set setResourceDomains = Sets.newLinkedHashSet(); + private final IMetadataSerializer rmMetadataSerializer; + private static final String __OBFID = "CL_00001091"; + + public SimpleReloadableResourceManager(IMetadataSerializer par1MetadataSerializer) + { + this.rmMetadataSerializer = par1MetadataSerializer; + } + + public void reloadResourcePack(IResourcePack par1ResourcePack) + { + FallbackResourceManager fallbackresourcemanager; + + for (Iterator iterator = par1ResourcePack.getResourceDomains().iterator(); iterator.hasNext(); fallbackresourcemanager.addResourcePack(par1ResourcePack)) + { + String s = (String)iterator.next(); + this.setResourceDomains.add(s); + fallbackresourcemanager = (FallbackResourceManager)this.domainResourceManagers.get(s); + + if (fallbackresourcemanager == null) + { + fallbackresourcemanager = new FallbackResourceManager(this.rmMetadataSerializer); + this.domainResourceManagers.put(s, fallbackresourcemanager); + } + } + } + + public Set getResourceDomains() + { + return this.setResourceDomains; + } + + public IResource getResource(ResourceLocation par1ResourceLocation) throws IOException + { + IResourceManager iresourcemanager = (IResourceManager)this.domainResourceManagers.get(par1ResourceLocation.getResourceDomain()); + + if (iresourcemanager != null) + { + return iresourcemanager.getResource(par1ResourceLocation); + } + else + { + throw new FileNotFoundException(par1ResourceLocation.toString()); + } + } + + public List getAllResources(ResourceLocation par1ResourceLocation) throws IOException + { + IResourceManager iresourcemanager = (IResourceManager)this.domainResourceManagers.get(par1ResourceLocation.getResourceDomain()); + + if (iresourcemanager != null) + { + return iresourcemanager.getAllResources(par1ResourceLocation); + } + else + { + throw new FileNotFoundException(par1ResourceLocation.toString()); + } + } + + private void clearResources() + { + this.domainResourceManagers.clear(); + this.setResourceDomains.clear(); + } + + public void reloadResources(List par1List) + { + this.clearResources(); + logger.info("Reloading ResourceManager: " + joinerResourcePacks.join(Iterables.transform(par1List, new Function() + { + private static final String __OBFID = "CL_00001092"; + public String apply(IResourcePack par1ResourcePack) + { + return par1ResourcePack.getPackName(); + } + public Object apply(Object par1Obj) + { + return this.apply((IResourcePack)par1Obj); + } + }))); + Iterator iterator = par1List.iterator(); + + while (iterator.hasNext()) + { + IResourcePack iresourcepack = (IResourcePack)iterator.next(); + this.reloadResourcePack(iresourcepack); + } + + this.notifyReloadListeners(); + } + + public void registerReloadListener(IResourceManagerReloadListener par1ResourceManagerReloadListener) + { + this.reloadListeners.add(par1ResourceManagerReloadListener); + par1ResourceManagerReloadListener.onResourceManagerReload(this); + } + + private void notifyReloadListeners() + { + Iterator iterator = this.reloadListeners.iterator(); + + while (iterator.hasNext()) + { + IResourceManagerReloadListener iresourcemanagerreloadlistener = (IResourceManagerReloadListener)iterator.next(); + iresourcemanagerreloadlistener.onResourceManagerReload(this); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/resources/SimpleResource.java b/src/main/java/net/minecraft/client/resources/SimpleResource.java new file mode 100644 index 0000000..2031e10 --- /dev/null +++ b/src/main/java/net/minecraft/client/resources/SimpleResource.java @@ -0,0 +1,103 @@ +package net.minecraft.client.resources; + +import com.google.common.collect.Maps; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.Map; +import net.minecraft.client.resources.data.IMetadataSection; +import net.minecraft.client.resources.data.IMetadataSerializer; +import net.minecraft.util.ResourceLocation; +import org.apache.commons.io.IOUtils; + +@SideOnly(Side.CLIENT) +public class SimpleResource implements IResource +{ + private final Map mapMetadataSections = Maps.newHashMap(); + private final ResourceLocation srResourceLocation; + private final InputStream resourceInputStream; + private final InputStream mcmetaInputStream; + private final IMetadataSerializer srMetadataSerializer; + private boolean mcmetaJsonChecked; + private JsonObject mcmetaJson; + private static final String __OBFID = "CL_00001093"; + + public SimpleResource(ResourceLocation par1ResourceLocation, InputStream par2InputStream, InputStream par3InputStream, IMetadataSerializer par4MetadataSerializer) + { + this.srResourceLocation = par1ResourceLocation; + this.resourceInputStream = par2InputStream; + this.mcmetaInputStream = par3InputStream; + this.srMetadataSerializer = par4MetadataSerializer; + } + + public InputStream getInputStream() + { + return this.resourceInputStream; + } + + public boolean hasMetadata() + { + return this.mcmetaInputStream != null; + } + + public IMetadataSection getMetadata(String par1Str) + { + if (!this.hasMetadata()) + { + return null; + } + else + { + if (this.mcmetaJson == null && !this.mcmetaJsonChecked) + { + this.mcmetaJsonChecked = true; + BufferedReader bufferedreader = null; + + try + { + bufferedreader = new BufferedReader(new InputStreamReader(this.mcmetaInputStream)); + this.mcmetaJson = (new JsonParser()).parse(bufferedreader).getAsJsonObject(); + } + finally + { + IOUtils.closeQuietly(bufferedreader); + } + } + + IMetadataSection imetadatasection = (IMetadataSection)this.mapMetadataSections.get(par1Str); + + if (imetadatasection == null) + { + imetadatasection = this.srMetadataSerializer.parseMetadataSection(par1Str, this.mcmetaJson); + } + + return imetadatasection; + } + } + + public boolean equals(Object par1Obj) + { + if (this == par1Obj) + { + return true; + } + else if (par1Obj instanceof SimpleResource) + { + SimpleResource simpleresource = (SimpleResource)par1Obj; + return this.srResourceLocation != null ? this.srResourceLocation.equals(simpleresource.srResourceLocation) : simpleresource.srResourceLocation == null; + } + else + { + return false; + } + } + + public int hashCode() + { + return this.srResourceLocation == null ? 0 : this.srResourceLocation.hashCode(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/resources/data/AnimationFrame.java b/src/main/java/net/minecraft/client/resources/data/AnimationFrame.java new file mode 100644 index 0000000..e8539f2 --- /dev/null +++ b/src/main/java/net/minecraft/client/resources/data/AnimationFrame.java @@ -0,0 +1,38 @@ +package net.minecraft.client.resources.data; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class AnimationFrame +{ + private final int frameIndex; + private final int frameTime; + private static final String __OBFID = "CL_00001104"; + + public AnimationFrame(int par1) + { + this(par1, -1); + } + + public AnimationFrame(int par1, int par2) + { + this.frameIndex = par1; + this.frameTime = par2; + } + + public boolean hasNoTime() + { + return this.frameTime == -1; + } + + public int getFrameTime() + { + return this.frameTime; + } + + public int getFrameIndex() + { + return this.frameIndex; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/resources/data/AnimationMetadataSection.java b/src/main/java/net/minecraft/client/resources/data/AnimationMetadataSection.java new file mode 100644 index 0000000..fc43a22 --- /dev/null +++ b/src/main/java/net/minecraft/client/resources/data/AnimationMetadataSection.java @@ -0,0 +1,82 @@ +package net.minecraft.client.resources.data; + +import com.google.common.collect.Sets; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +@SideOnly(Side.CLIENT) +public class AnimationMetadataSection implements IMetadataSection +{ + private final List animationFrames; + private final int frameWidth; + private final int frameHeight; + private final int frameTime; + private static final String __OBFID = "CL_00001106"; + + public AnimationMetadataSection(List par1List, int par2, int par3, int par4) + { + this.animationFrames = par1List; + this.frameWidth = par2; + this.frameHeight = par3; + this.frameTime = par4; + } + + public int getFrameHeight() + { + return this.frameHeight; + } + + public int getFrameWidth() + { + return this.frameWidth; + } + + public int getFrameCount() + { + return this.animationFrames.size(); + } + + public int getFrameTime() + { + return this.frameTime; + } + + private AnimationFrame getAnimationFrame(int par1) + { + return (AnimationFrame)this.animationFrames.get(par1); + } + + public int getFrameTimeSingle(int par1) + { + AnimationFrame animationframe = this.getAnimationFrame(par1); + return animationframe.hasNoTime() ? this.frameTime : animationframe.getFrameTime(); + } + + public boolean frameHasTime(int par1) + { + return !((AnimationFrame)this.animationFrames.get(par1)).hasNoTime(); + } + + public int getFrameIndex(int par1) + { + return ((AnimationFrame)this.animationFrames.get(par1)).getFrameIndex(); + } + + public Set getFrameIndexSet() + { + HashSet hashset = Sets.newHashSet(); + Iterator iterator = this.animationFrames.iterator(); + + while (iterator.hasNext()) + { + AnimationFrame animationframe = (AnimationFrame)iterator.next(); + hashset.add(Integer.valueOf(animationframe.getFrameIndex())); + } + + return hashset; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/resources/data/AnimationMetadataSectionSerializer.java b/src/main/java/net/minecraft/client/resources/data/AnimationMetadataSectionSerializer.java new file mode 100644 index 0000000..fb94d75 --- /dev/null +++ b/src/main/java/net/minecraft/client/resources/data/AnimationMetadataSectionSerializer.java @@ -0,0 +1,151 @@ +package net.minecraft.client.resources.data; + +import com.google.common.collect.Lists; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.JsonPrimitive; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.lang.reflect.Type; +import java.util.ArrayList; +import net.minecraft.util.JsonUtils; +import org.apache.commons.lang3.Validate; + +@SideOnly(Side.CLIENT) +public class AnimationMetadataSectionSerializer extends BaseMetadataSectionSerializer implements JsonSerializer +{ + private static final String __OBFID = "CL_00001107"; + + public AnimationMetadataSection deserialize(JsonElement par1JsonElement, Type par2Type, JsonDeserializationContext par3JsonDeserializationContext) + { + ArrayList arraylist = Lists.newArrayList(); + JsonObject jsonobject = JsonUtils.getJsonElementAsJsonObject(par1JsonElement, "metadata section"); + int i = JsonUtils.getJsonObjectIntegerFieldValueOrDefault(jsonobject, "frametime", 1); + + if (i != 1) + { + Validate.inclusiveBetween(Integer.valueOf(1), Integer.valueOf(Integer.MAX_VALUE), Integer.valueOf(i), "Invalid default frame time", new Object[0]); + } + + int j; + + if (jsonobject.has("frames")) + { + try + { + JsonArray jsonarray = JsonUtils.getJsonObjectJsonArrayField(jsonobject, "frames"); + + for (j = 0; j < jsonarray.size(); ++j) + { + JsonElement jsonelement1 = jsonarray.get(j); + AnimationFrame animationframe = this.parseAnimationFrame(j, jsonelement1); + + if (animationframe != null) + { + arraylist.add(animationframe); + } + } + } + catch (ClassCastException classcastexception) + { + throw new JsonParseException("Invalid animation->frames: expected array, was " + jsonobject.get("frames"), classcastexception); + } + } + + int k = JsonUtils.getJsonObjectIntegerFieldValueOrDefault(jsonobject, "width", -1); + j = JsonUtils.getJsonObjectIntegerFieldValueOrDefault(jsonobject, "height", -1); + + if (k != -1) + { + Validate.inclusiveBetween(Integer.valueOf(1), Integer.valueOf(Integer.MAX_VALUE), Integer.valueOf(k), "Invalid width", new Object[0]); + } + + if (j != -1) + { + Validate.inclusiveBetween(Integer.valueOf(1), Integer.valueOf(Integer.MAX_VALUE), Integer.valueOf(j), "Invalid height", new Object[0]); + } + + return new AnimationMetadataSection(arraylist, k, j, i); + } + + private AnimationFrame parseAnimationFrame(int par1, JsonElement par2JsonElement) + { + if (par2JsonElement.isJsonPrimitive()) + { + return new AnimationFrame(JsonUtils.getJsonElementIntegerValue(par2JsonElement, "frames[" + par1 + "]")); + } + else if (par2JsonElement.isJsonObject()) + { + JsonObject jsonobject = JsonUtils.getJsonElementAsJsonObject(par2JsonElement, "frames[" + par1 + "]"); + int j = JsonUtils.getJsonObjectIntegerFieldValueOrDefault(jsonobject, "time", -1); + + if (jsonobject.has("time")) + { + Validate.inclusiveBetween(Integer.valueOf(1), Integer.valueOf(Integer.MAX_VALUE), Integer.valueOf(j), "Invalid frame time", new Object[0]); + } + + int k = JsonUtils.getJsonObjectIntegerFieldValue(jsonobject, "index"); + Validate.inclusiveBetween(Integer.valueOf(0), Integer.valueOf(Integer.MAX_VALUE), Integer.valueOf(k), "Invalid frame index", new Object[0]); + return new AnimationFrame(k, j); + } + else + { + return null; + } + } + + public JsonElement serialize(AnimationMetadataSection par1AnimationMetadataSection, Type par2Type, JsonSerializationContext par3JsonSerializationContext) + { + JsonObject jsonobject = new JsonObject(); + jsonobject.addProperty("frametime", Integer.valueOf(par1AnimationMetadataSection.getFrameTime())); + + if (par1AnimationMetadataSection.getFrameWidth() != -1) + { + jsonobject.addProperty("width", Integer.valueOf(par1AnimationMetadataSection.getFrameWidth())); + } + + if (par1AnimationMetadataSection.getFrameHeight() != -1) + { + jsonobject.addProperty("height", Integer.valueOf(par1AnimationMetadataSection.getFrameHeight())); + } + + if (par1AnimationMetadataSection.getFrameCount() > 0) + { + JsonArray jsonarray = new JsonArray(); + + for (int i = 0; i < par1AnimationMetadataSection.getFrameCount(); ++i) + { + if (par1AnimationMetadataSection.frameHasTime(i)) + { + JsonObject jsonobject1 = new JsonObject(); + jsonobject1.addProperty("index", Integer.valueOf(par1AnimationMetadataSection.getFrameIndex(i))); + jsonobject1.addProperty("time", Integer.valueOf(par1AnimationMetadataSection.getFrameTimeSingle(i))); + jsonarray.add(jsonobject1); + } + else + { + jsonarray.add(new JsonPrimitive(Integer.valueOf(par1AnimationMetadataSection.getFrameIndex(i)))); + } + } + + jsonobject.add("frames", jsonarray); + } + + return jsonobject; + } + + public String getSectionName() + { + return "animation"; + } + + public JsonElement serialize(Object par1Obj, Type par2Type, JsonSerializationContext par3JsonSerializationContext) + { + return this.serialize((AnimationMetadataSection)par1Obj, par2Type, par3JsonSerializationContext); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/resources/data/BaseMetadataSectionSerializer.java b/src/main/java/net/minecraft/client/resources/data/BaseMetadataSectionSerializer.java new file mode 100644 index 0000000..7f14904 --- /dev/null +++ b/src/main/java/net/minecraft/client/resources/data/BaseMetadataSectionSerializer.java @@ -0,0 +1,10 @@ +package net.minecraft.client.resources.data; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public abstract class BaseMetadataSectionSerializer implements IMetadataSectionSerializer +{ + private static final String __OBFID = "CL_00001098"; +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/resources/data/FontMetadataSection.java b/src/main/java/net/minecraft/client/resources/data/FontMetadataSection.java new file mode 100644 index 0000000..e28ed15 --- /dev/null +++ b/src/main/java/net/minecraft/client/resources/data/FontMetadataSection.java @@ -0,0 +1,20 @@ +package net.minecraft.client.resources.data; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class FontMetadataSection implements IMetadataSection +{ + private final float[] charWidths; + private final float[] charLefts; + private final float[] charSpacings; + private static final String __OBFID = "CL_00001108"; + + public FontMetadataSection(float[] par1ArrayOfFloat, float[] par2ArrayOfFloat, float[] par3ArrayOfFloat) + { + this.charWidths = par1ArrayOfFloat; + this.charLefts = par2ArrayOfFloat; + this.charSpacings = par3ArrayOfFloat; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/resources/data/FontMetadataSectionSerializer.java b/src/main/java/net/minecraft/client/resources/data/FontMetadataSectionSerializer.java new file mode 100644 index 0000000..cdc9800 --- /dev/null +++ b/src/main/java/net/minecraft/client/resources/data/FontMetadataSectionSerializer.java @@ -0,0 +1,84 @@ +package net.minecraft.client.resources.data; + +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.lang.reflect.Type; +import net.minecraft.util.JsonUtils; +import org.apache.commons.lang3.Validate; + +@SideOnly(Side.CLIENT) +public class FontMetadataSectionSerializer extends BaseMetadataSectionSerializer +{ + private static final String __OBFID = "CL_00001109"; + + public FontMetadataSection deserialize(JsonElement par1JsonElement, Type par2Type, JsonDeserializationContext par3JsonDeserializationContext) + { + JsonObject jsonobject = par1JsonElement.getAsJsonObject(); + float[] afloat = new float[256]; + float[] afloat1 = new float[256]; + float[] afloat2 = new float[256]; + float f = 1.0F; + float f1 = 0.0F; + float f2 = 0.0F; + + if (jsonobject.has("characters")) + { + if (!jsonobject.get("characters").isJsonObject()) + { + throw new JsonParseException("Invalid font->characters: expected object, was " + jsonobject.get("characters")); + } + + JsonObject jsonobject1 = jsonobject.getAsJsonObject("characters"); + + if (jsonobject1.has("default")) + { + if (!jsonobject1.get("default").isJsonObject()) + { + throw new JsonParseException("Invalid font->characters->default: expected object, was " + jsonobject1.get("default")); + } + + JsonObject jsonobject2 = jsonobject1.getAsJsonObject("default"); + f = JsonUtils.getJsonObjectFloatFieldValueOrDefault(jsonobject2, "width", f); + Validate.inclusiveBetween(Float.valueOf(0.0F), Float.valueOf(Float.MAX_VALUE), Float.valueOf(f), "Invalid default width", new Object[0]); + f1 = JsonUtils.getJsonObjectFloatFieldValueOrDefault(jsonobject2, "spacing", f1); + Validate.inclusiveBetween(Float.valueOf(0.0F), Float.valueOf(Float.MAX_VALUE), Float.valueOf(f1), "Invalid default spacing", new Object[0]); + f2 = JsonUtils.getJsonObjectFloatFieldValueOrDefault(jsonobject2, "left", f1); + Validate.inclusiveBetween(Float.valueOf(0.0F), Float.valueOf(Float.MAX_VALUE), Float.valueOf(f2), "Invalid default left", new Object[0]); + } + + for (int i = 0; i < 256; ++i) + { + JsonElement jsonelement1 = jsonobject1.get(Integer.toString(i)); + float f3 = f; + float f4 = f1; + float f5 = f2; + + if (jsonelement1 != null) + { + JsonObject jsonobject3 = JsonUtils.getJsonElementAsJsonObject(jsonelement1, "characters[" + i + "]"); + f3 = JsonUtils.getJsonObjectFloatFieldValueOrDefault(jsonobject3, "width", f); + Validate.inclusiveBetween(Float.valueOf(0.0F), Float.valueOf(Float.MAX_VALUE), Float.valueOf(f3), "Invalid width", new Object[0]); + f4 = JsonUtils.getJsonObjectFloatFieldValueOrDefault(jsonobject3, "spacing", f1); + Validate.inclusiveBetween(Float.valueOf(0.0F), Float.valueOf(Float.MAX_VALUE), Float.valueOf(f4), "Invalid spacing", new Object[0]); + f5 = JsonUtils.getJsonObjectFloatFieldValueOrDefault(jsonobject3, "left", f2); + Validate.inclusiveBetween(Float.valueOf(0.0F), Float.valueOf(Float.MAX_VALUE), Float.valueOf(f5), "Invalid left", new Object[0]); + } + + afloat[i] = f3; + afloat1[i] = f4; + afloat2[i] = f5; + } + } + + return new FontMetadataSection(afloat, afloat2, afloat1); + } + + public String getSectionName() + { + return "font"; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/resources/data/IMetadataSection.java b/src/main/java/net/minecraft/client/resources/data/IMetadataSection.java new file mode 100644 index 0000000..89e6a77 --- /dev/null +++ b/src/main/java/net/minecraft/client/resources/data/IMetadataSection.java @@ -0,0 +1,9 @@ +package net.minecraft.client.resources.data; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public interface IMetadataSection +{ +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/resources/data/IMetadataSectionSerializer.java b/src/main/java/net/minecraft/client/resources/data/IMetadataSectionSerializer.java new file mode 100644 index 0000000..917afda --- /dev/null +++ b/src/main/java/net/minecraft/client/resources/data/IMetadataSectionSerializer.java @@ -0,0 +1,11 @@ +package net.minecraft.client.resources.data; + +import com.google.gson.JsonDeserializer; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public interface IMetadataSectionSerializer extends JsonDeserializer +{ + String getSectionName(); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/resources/data/IMetadataSerializer.java b/src/main/java/net/minecraft/client/resources/data/IMetadataSerializer.java new file mode 100644 index 0000000..fa73260 --- /dev/null +++ b/src/main/java/net/minecraft/client/resources/data/IMetadataSerializer.java @@ -0,0 +1,83 @@ +package net.minecraft.client.resources.data; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonObject; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.util.IRegistry; +import net.minecraft.util.RegistrySimple; + +@SideOnly(Side.CLIENT) +public class IMetadataSerializer +{ + private final IRegistry metadataSectionSerializerRegistry = new RegistrySimple(); + private final GsonBuilder gsonBuilder = new GsonBuilder(); + private Gson gson; + private static final String __OBFID = "CL_00001101"; + + public void registerMetadataSectionType(IMetadataSectionSerializer par1MetadataSectionSerializer, Class par2Class) + { + this.metadataSectionSerializerRegistry.putObject(par1MetadataSectionSerializer.getSectionName(), new IMetadataSerializer.Registration(par1MetadataSectionSerializer, par2Class, null)); + this.gsonBuilder.registerTypeAdapter(par2Class, par1MetadataSectionSerializer); + this.gson = null; + } + + public IMetadataSection parseMetadataSection(String par1Str, JsonObject par2JsonObject) + { + if (par1Str == null) + { + throw new IllegalArgumentException("Metadata section name cannot be null"); + } + else if (!par2JsonObject.has(par1Str)) + { + return null; + } + else if (!par2JsonObject.get(par1Str).isJsonObject()) + { + throw new IllegalArgumentException("Invalid metadata for \'" + par1Str + "\' - expected object, found " + par2JsonObject.get(par1Str)); + } + else + { + IMetadataSerializer.Registration registration = (IMetadataSerializer.Registration)this.metadataSectionSerializerRegistry.getObject(par1Str); + + if (registration == null) + { + throw new IllegalArgumentException("Don\'t know how to handle metadata section \'" + par1Str + "\'"); + } + else + { + return (IMetadataSection)this.getGson().fromJson(par2JsonObject.getAsJsonObject(par1Str), registration.field_110500_b); + } + } + } + + private Gson getGson() + { + if (this.gson == null) + { + this.gson = this.gsonBuilder.create(); + } + + return this.gson; + } + + @SideOnly(Side.CLIENT) + class Registration + { + final IMetadataSectionSerializer field_110502_a; + final Class field_110500_b; + private static final String __OBFID = "CL_00001103"; + + private Registration(IMetadataSectionSerializer par2MetadataSectionSerializer, Class par3Class) + { + this.field_110502_a = par2MetadataSectionSerializer; + this.field_110500_b = par3Class; + } + + Registration(IMetadataSectionSerializer par2MetadataSectionSerializer, Class par3Class, Object par4MetadataSerializerEmptyAnon) + { + this(par2MetadataSectionSerializer, par3Class); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/resources/data/LanguageMetadataSection.java b/src/main/java/net/minecraft/client/resources/data/LanguageMetadataSection.java new file mode 100644 index 0000000..dff9aa4 --- /dev/null +++ b/src/main/java/net/minecraft/client/resources/data/LanguageMetadataSection.java @@ -0,0 +1,22 @@ +package net.minecraft.client.resources.data; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Collection; + +@SideOnly(Side.CLIENT) +public class LanguageMetadataSection implements IMetadataSection +{ + private final Collection languages; + private static final String __OBFID = "CL_00001110"; + + public LanguageMetadataSection(Collection par1Collection) + { + this.languages = par1Collection; + } + + public Collection getLanguages() + { + return this.languages; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/resources/data/LanguageMetadataSectionSerializer.java b/src/main/java/net/minecraft/client/resources/data/LanguageMetadataSectionSerializer.java new file mode 100644 index 0000000..635bba7 --- /dev/null +++ b/src/main/java/net/minecraft/client/resources/data/LanguageMetadataSectionSerializer.java @@ -0,0 +1,65 @@ +package net.minecraft.client.resources.data; + +import com.google.common.collect.Sets; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.lang.reflect.Type; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map.Entry; +import net.minecraft.client.resources.Language; +import net.minecraft.util.JsonUtils; + +@SideOnly(Side.CLIENT) +public class LanguageMetadataSectionSerializer extends BaseMetadataSectionSerializer +{ + private static final String __OBFID = "CL_00001111"; + + public LanguageMetadataSection deserialize(JsonElement par1JsonElement, Type par2Type, JsonDeserializationContext par3JsonDeserializationContext) + { + JsonObject jsonobject = par1JsonElement.getAsJsonObject(); + HashSet hashset = Sets.newHashSet(); + Iterator iterator = jsonobject.entrySet().iterator(); + String s; + String s1; + String s2; + boolean flag; + + do + { + if (!iterator.hasNext()) + { + return new LanguageMetadataSection(hashset); + } + + Entry entry = (Entry)iterator.next(); + s = (String)entry.getKey(); + JsonObject jsonobject1 = JsonUtils.getJsonElementAsJsonObject((JsonElement)entry.getValue(), "language"); + s1 = JsonUtils.getJsonObjectStringFieldValue(jsonobject1, "region"); + s2 = JsonUtils.getJsonObjectStringFieldValue(jsonobject1, "name"); + flag = JsonUtils.getJsonObjectBooleanFieldValueOrDefault(jsonobject1, "bidirectional", false); + + if (s1.isEmpty()) + { + throw new JsonParseException("Invalid language->\'" + s + "\'->region: empty value"); + } + + if (s2.isEmpty()) + { + throw new JsonParseException("Invalid language->\'" + s + "\'->name: empty value"); + } + } + while (hashset.add(new Language(s, s1, s2, flag))); + + throw new JsonParseException("Duplicate language->\'" + s + "\' defined"); + } + + public String getSectionName() + { + return "language"; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/resources/data/PackMetadataSection.java b/src/main/java/net/minecraft/client/resources/data/PackMetadataSection.java new file mode 100644 index 0000000..d0ad4f3 --- /dev/null +++ b/src/main/java/net/minecraft/client/resources/data/PackMetadataSection.java @@ -0,0 +1,28 @@ +package net.minecraft.client.resources.data; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class PackMetadataSection implements IMetadataSection +{ + private final String packDescription; + private final int packFormat; + private static final String __OBFID = "CL_00001112"; + + public PackMetadataSection(String par1Str, int par2) + { + this.packDescription = par1Str; + this.packFormat = par2; + } + + public String getPackDescription() + { + return this.packDescription; + } + + public int getPackFormat() + { + return this.packFormat; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/resources/data/PackMetadataSectionSerializer.java b/src/main/java/net/minecraft/client/resources/data/PackMetadataSectionSerializer.java new file mode 100644 index 0000000..cd28b17 --- /dev/null +++ b/src/main/java/net/minecraft/client/resources/data/PackMetadataSectionSerializer.java @@ -0,0 +1,43 @@ +package net.minecraft.client.resources.data; + +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.lang.reflect.Type; +import net.minecraft.util.JsonUtils; + +@SideOnly(Side.CLIENT) +public class PackMetadataSectionSerializer extends BaseMetadataSectionSerializer implements JsonSerializer +{ + private static final String __OBFID = "CL_00001113"; + + public PackMetadataSection deserialize(JsonElement par1JsonElement, Type par2Type, JsonDeserializationContext par3JsonDeserializationContext) + { + JsonObject jsonobject = par1JsonElement.getAsJsonObject(); + String s = JsonUtils.getJsonObjectStringFieldValue(jsonobject, "description"); + int i = JsonUtils.getJsonObjectIntegerFieldValue(jsonobject, "pack_format"); + return new PackMetadataSection(s, i); + } + + public JsonElement serialize(PackMetadataSection par1PackMetadataSection, Type par2Type, JsonSerializationContext par3JsonSerializationContext) + { + JsonObject jsonobject = new JsonObject(); + jsonobject.addProperty("pack_format", Integer.valueOf(par1PackMetadataSection.getPackFormat())); + jsonobject.addProperty("description", par1PackMetadataSection.getPackDescription()); + return jsonobject; + } + + public String getSectionName() + { + return "pack"; + } + + public JsonElement serialize(Object par1Obj, Type par2Type, JsonSerializationContext par3JsonSerializationContext) + { + return this.serialize((PackMetadataSection)par1Obj, par2Type, par3JsonSerializationContext); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/resources/data/TextureMetadataSection.java b/src/main/java/net/minecraft/client/resources/data/TextureMetadataSection.java new file mode 100644 index 0000000..da4f4e6 --- /dev/null +++ b/src/main/java/net/minecraft/client/resources/data/TextureMetadataSection.java @@ -0,0 +1,37 @@ +package net.minecraft.client.resources.data; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Collections; +import java.util.List; + +@SideOnly(Side.CLIENT) +public class TextureMetadataSection implements IMetadataSection +{ + private final boolean textureBlur; + private final boolean textureClamp; + private final List listMipmaps; + private static final String __OBFID = "CL_00001114"; + + public TextureMetadataSection(boolean p_i45102_1_, boolean p_i45102_2_, List p_i45102_3_) + { + this.textureBlur = p_i45102_1_; + this.textureClamp = p_i45102_2_; + this.listMipmaps = p_i45102_3_; + } + + public boolean getTextureBlur() + { + return this.textureBlur; + } + + public boolean getTextureClamp() + { + return this.textureClamp; + } + + public List getListMipmaps() + { + return Collections.unmodifiableList(this.listMipmaps); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/resources/data/TextureMetadataSectionSerializer.java b/src/main/java/net/minecraft/client/resources/data/TextureMetadataSectionSerializer.java new file mode 100644 index 0000000..dded8be --- /dev/null +++ b/src/main/java/net/minecraft/client/resources/data/TextureMetadataSectionSerializer.java @@ -0,0 +1,67 @@ +package net.minecraft.client.resources.data; + +import com.google.common.collect.Lists; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.lang.reflect.Type; +import java.util.ArrayList; +import net.minecraft.util.JsonUtils; + +@SideOnly(Side.CLIENT) +public class TextureMetadataSectionSerializer extends BaseMetadataSectionSerializer +{ + private static final String __OBFID = "CL_00001115"; + + public TextureMetadataSection deserialize(JsonElement par1JsonElement, Type par2Type, JsonDeserializationContext par3JsonDeserializationContext) + { + JsonObject jsonobject = par1JsonElement.getAsJsonObject(); + boolean flag = JsonUtils.getJsonObjectBooleanFieldValueOrDefault(jsonobject, "blur", false); + boolean flag1 = JsonUtils.getJsonObjectBooleanFieldValueOrDefault(jsonobject, "clamp", false); + ArrayList arraylist = Lists.newArrayList(); + + if (jsonobject.has("mipmaps")) + { + try + { + JsonArray jsonarray = jsonobject.getAsJsonArray("mipmaps"); + + for (int i = 0; i < jsonarray.size(); ++i) + { + JsonElement jsonelement1 = jsonarray.get(i); + + if (jsonelement1.isJsonPrimitive()) + { + try + { + arraylist.add(Integer.valueOf(jsonelement1.getAsInt())); + } + catch (NumberFormatException numberformatexception) + { + throw new JsonParseException("Invalid texture->mipmap->" + i + ": expected number, was " + jsonelement1, numberformatexception); + } + } + else if (jsonelement1.isJsonObject()) + { + throw new JsonParseException("Invalid texture->mipmap->" + i + ": expected number, was " + jsonelement1); + } + } + } + catch (ClassCastException classcastexception) + { + throw new JsonParseException("Invalid texture->mipmaps: expected array, was " + jsonobject.get("mipmaps"), classcastexception); + } + } + + return new TextureMetadataSection(flag, flag1, arraylist); + } + + public String getSectionName() + { + return "texture"; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/settings/GameSettings.java b/src/main/java/net/minecraft/client/settings/GameSettings.java new file mode 100644 index 0000000..4429ce9 --- /dev/null +++ b/src/main/java/net/minecraft/client/settings/GameSettings.java @@ -0,0 +1,1289 @@ +package net.minecraft.client.settings; + +import com.google.common.collect.Maps; +import com.google.gson.Gson; + +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.PrintWriter; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import net.minecraft.client.Minecraft; +import net.minecraft.client.audio.SoundCategory; +import net.minecraft.client.gui.GuiNewChat; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.network.play.client.C15PacketClientSettings; +import net.minecraft.util.MathHelper; +import net.minecraft.world.EnumDifficulty; +import org.apache.commons.lang3.ArrayUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.Display; + +@SideOnly(Side.CLIENT) +public class GameSettings +{ + private static final Logger logger = LogManager.getLogger(); + private static final Gson gson = new Gson(); + private static final ParameterizedType typeListString = new ParameterizedType() + { + private static final String __OBFID = "CL_00000651"; + public Type[] getActualTypeArguments() + { + return new Type[] {String.class}; + } + public Type getRawType() + { + return List.class; + } + public Type getOwnerType() + { + return null; + } + }; + private static final String[] GUISCALES = new String[] {"options.guiScale.auto", "options.guiScale.small", "options.guiScale.normal", "options.guiScale.large"}; + private static final String[] PARTICLES = new String[] {"options.particles.all", "options.particles.decreased", "options.particles.minimal"}; + private static final String[] AMBIENT_OCCLUSIONS = new String[] {"options.ao.off", "options.ao.min", "options.ao.max"}; + public float mouseSensitivity = 0.5F; + public boolean invertMouse; + public int renderDistanceChunks = -1; + public boolean viewBobbing = true; + public boolean anaglyph; + public boolean advancedOpengl; + public boolean fboEnable = true; + public int limitFramerate = 120; + public boolean fancyGraphics = true; + public int ambientOcclusion = 2; + public boolean clouds = true; + public List resourcePacks = new ArrayList(); + public EntityPlayer.EnumChatVisibility chatVisibility; + public boolean chatColours; + public boolean chatLinks; + public boolean chatLinksPrompt; + public float chatOpacity; + public boolean serverTextures; + public boolean snooperEnabled; + public boolean fullScreen; + public boolean enableVsync; + public boolean hideServerAddress; + public boolean advancedItemTooltips; + public boolean pauseOnLostFocus; + public boolean showCape; + public boolean touchscreen; + public int overrideWidth; + public int overrideHeight; + public boolean heldItemTooltips; + public float chatScale; + public float chatWidth; + public float chatHeightUnfocused; + public float chatHeightFocused; + public boolean showInventoryAchievementHint; + public int mipmapLevels; + public int anisotropicFiltering; + private Map mapSoundLevels; + public KeyBinding keyBindForward; + public KeyBinding keyBindLeft; + public KeyBinding keyBindBack; + public KeyBinding keyBindRight; + public KeyBinding keyBindJump; + public KeyBinding keyBindSneak; + public KeyBinding keyBindInventory; + public KeyBinding keyBindUseItem; + public KeyBinding keyBindDrop; + public KeyBinding keyBindAttack; + public KeyBinding keyBindPickBlock; + public KeyBinding keyBindSprint; + public KeyBinding keyBindChat; + public KeyBinding keyBindPlayerList; + public KeyBinding keyBindCommand; + public KeyBinding keyBindScreenshot; + public KeyBinding keyBindTogglePerspective; + public KeyBinding keyBindSmoothCamera; + public KeyBinding[] keyBindsHotbar; + public KeyBinding[] keyBindings; + protected Minecraft mc; + private File optionsFile; + public EnumDifficulty difficulty; + public boolean hideGUI; + public int thirdPersonView; + public boolean showDebugInfo; + public boolean showDebugProfilerChart; + public String lastServer; + public boolean noclip; + public boolean smoothCamera; + public boolean debugCamEnable; + public float noclipRate; + public float debugCamRate; + public float fovSetting; + public float gammaSetting; + public float saturation; + public int guiScale; + public int particleSetting; + public String language; + public boolean forceUnicodeFont; + private static final String __OBFID = "CL_00000650"; + + public GameSettings(Minecraft par1Minecraft, File par2File) + { + this.chatVisibility = EntityPlayer.EnumChatVisibility.FULL; + this.chatColours = true; + this.chatLinks = true; + this.chatLinksPrompt = true; + this.chatOpacity = 1.0F; + this.serverTextures = true; + this.snooperEnabled = true; + this.enableVsync = true; + this.pauseOnLostFocus = true; + this.showCape = true; + this.heldItemTooltips = true; + this.chatScale = 1.0F; + this.chatWidth = 1.0F; + this.chatHeightUnfocused = 0.44366196F; + this.chatHeightFocused = 1.0F; + this.showInventoryAchievementHint = true; + this.mipmapLevels = 4; + this.anisotropicFiltering = 1; + this.mapSoundLevels = Maps.newEnumMap(SoundCategory.class); + this.keyBindForward = new KeyBinding("key.forward", 17, "key.categories.movement"); + this.keyBindLeft = new KeyBinding("key.left", 30, "key.categories.movement"); + this.keyBindBack = new KeyBinding("key.back", 31, "key.categories.movement"); + this.keyBindRight = new KeyBinding("key.right", 32, "key.categories.movement"); + this.keyBindJump = new KeyBinding("key.jump", 57, "key.categories.movement"); + this.keyBindSneak = new KeyBinding("key.sneak", 42, "key.categories.movement"); + this.keyBindInventory = new KeyBinding("key.inventory", 18, "key.categories.inventory"); + this.keyBindUseItem = new KeyBinding("key.use", -99, "key.categories.gameplay"); + this.keyBindDrop = new KeyBinding("key.drop", 16, "key.categories.gameplay"); + this.keyBindAttack = new KeyBinding("key.attack", -100, "key.categories.gameplay"); + this.keyBindPickBlock = new KeyBinding("key.pickItem", -98, "key.categories.gameplay"); + this.keyBindSprint = new KeyBinding("key.sprint", 29, "key.categories.gameplay"); + this.keyBindChat = new KeyBinding("key.chat", 20, "key.categories.multiplayer"); + this.keyBindPlayerList = new KeyBinding("key.playerlist", 15, "key.categories.multiplayer"); + this.keyBindCommand = new KeyBinding("key.command", 53, "key.categories.multiplayer"); + this.keyBindScreenshot = new KeyBinding("key.screenshot", 60, "key.categories.misc"); + this.keyBindTogglePerspective = new KeyBinding("key.togglePerspective", 63, "key.categories.misc"); + this.keyBindSmoothCamera = new KeyBinding("key.smoothCamera", 0, "key.categories.misc"); + this.keyBindsHotbar = new KeyBinding[] {new KeyBinding("key.hotbar.1", 2, "key.categories.inventory"), new KeyBinding("key.hotbar.2", 3, "key.categories.inventory"), new KeyBinding("key.hotbar.3", 4, "key.categories.inventory"), new KeyBinding("key.hotbar.4", 5, "key.categories.inventory"), new KeyBinding("key.hotbar.5", 6, "key.categories.inventory"), new KeyBinding("key.hotbar.6", 7, "key.categories.inventory"), new KeyBinding("key.hotbar.7", 8, "key.categories.inventory"), new KeyBinding("key.hotbar.8", 9, "key.categories.inventory"), new KeyBinding("key.hotbar.9", 10, "key.categories.inventory")}; + this.keyBindings = (KeyBinding[])ArrayUtils.addAll(new KeyBinding[] {this.keyBindAttack, this.keyBindUseItem, this.keyBindForward, this.keyBindLeft, this.keyBindBack, this.keyBindRight, this.keyBindJump, this.keyBindSneak, this.keyBindDrop, this.keyBindInventory, this.keyBindChat, this.keyBindPlayerList, this.keyBindPickBlock, this.keyBindCommand, this.keyBindScreenshot, this.keyBindTogglePerspective, this.keyBindSmoothCamera, this.keyBindSprint}, this.keyBindsHotbar); + this.difficulty = EnumDifficulty.NORMAL; + this.lastServer = ""; + this.noclipRate = 1.0F; + this.debugCamRate = 1.0F; + this.language = "en_US"; + this.forceUnicodeFont = false; + this.mc = par1Minecraft; + this.optionsFile = new File(par2File, "options.txt"); + GameSettings.Options.RENDER_DISTANCE.setValueMax(16.0F); + this.renderDistanceChunks = par1Minecraft.isJava64bit() ? 12 : 8; + this.loadOptions(); + } + + public GameSettings() + { + this.chatVisibility = EntityPlayer.EnumChatVisibility.FULL; + this.chatColours = true; + this.chatLinks = true; + this.chatLinksPrompt = true; + this.chatOpacity = 1.0F; + this.serverTextures = true; + this.snooperEnabled = true; + this.enableVsync = true; + this.pauseOnLostFocus = true; + this.showCape = true; + this.heldItemTooltips = true; + this.chatScale = 1.0F; + this.chatWidth = 1.0F; + this.chatHeightUnfocused = 0.44366196F; + this.chatHeightFocused = 1.0F; + this.showInventoryAchievementHint = true; + this.mipmapLevels = 4; + this.anisotropicFiltering = 1; + this.mapSoundLevels = Maps.newEnumMap(SoundCategory.class); + this.keyBindForward = new KeyBinding("key.forward", 17, "key.categories.movement"); + this.keyBindLeft = new KeyBinding("key.left", 30, "key.categories.movement"); + this.keyBindBack = new KeyBinding("key.back", 31, "key.categories.movement"); + this.keyBindRight = new KeyBinding("key.right", 32, "key.categories.movement"); + this.keyBindJump = new KeyBinding("key.jump", 57, "key.categories.movement"); + this.keyBindSneak = new KeyBinding("key.sneak", 42, "key.categories.movement"); + this.keyBindInventory = new KeyBinding("key.inventory", 18, "key.categories.inventory"); + this.keyBindUseItem = new KeyBinding("key.use", -99, "key.categories.gameplay"); + this.keyBindDrop = new KeyBinding("key.drop", 16, "key.categories.gameplay"); + this.keyBindAttack = new KeyBinding("key.attack", -100, "key.categories.gameplay"); + this.keyBindPickBlock = new KeyBinding("key.pickItem", -98, "key.categories.gameplay"); + this.keyBindSprint = new KeyBinding("key.sprint", 29, "key.categories.gameplay"); + this.keyBindChat = new KeyBinding("key.chat", 20, "key.categories.multiplayer"); + this.keyBindPlayerList = new KeyBinding("key.playerlist", 15, "key.categories.multiplayer"); + this.keyBindCommand = new KeyBinding("key.command", 53, "key.categories.multiplayer"); + this.keyBindScreenshot = new KeyBinding("key.screenshot", 60, "key.categories.misc"); + this.keyBindTogglePerspective = new KeyBinding("key.togglePerspective", 63, "key.categories.misc"); + this.keyBindSmoothCamera = new KeyBinding("key.smoothCamera", 0, "key.categories.misc"); + this.keyBindsHotbar = new KeyBinding[] {new KeyBinding("key.hotbar.1", 2, "key.categories.inventory"), new KeyBinding("key.hotbar.2", 3, "key.categories.inventory"), new KeyBinding("key.hotbar.3", 4, "key.categories.inventory"), new KeyBinding("key.hotbar.4", 5, "key.categories.inventory"), new KeyBinding("key.hotbar.5", 6, "key.categories.inventory"), new KeyBinding("key.hotbar.6", 7, "key.categories.inventory"), new KeyBinding("key.hotbar.7", 8, "key.categories.inventory"), new KeyBinding("key.hotbar.8", 9, "key.categories.inventory"), new KeyBinding("key.hotbar.9", 10, "key.categories.inventory")}; + this.keyBindings = (KeyBinding[])ArrayUtils.addAll(new KeyBinding[] {this.keyBindAttack, this.keyBindUseItem, this.keyBindForward, this.keyBindLeft, this.keyBindBack, this.keyBindRight, this.keyBindJump, this.keyBindSneak, this.keyBindDrop, this.keyBindInventory, this.keyBindChat, this.keyBindPlayerList, this.keyBindPickBlock, this.keyBindCommand, this.keyBindScreenshot, this.keyBindTogglePerspective, this.keyBindSmoothCamera, this.keyBindSprint}, this.keyBindsHotbar); + this.difficulty = EnumDifficulty.NORMAL; + this.lastServer = ""; + this.noclipRate = 1.0F; + this.debugCamRate = 1.0F; + this.language = "en_US"; + this.forceUnicodeFont = false; + } + + public static String getKeyDisplayString(int par0) + { + return par0 < 0 ? I18n.format("key.mouseButton", new Object[] {Integer.valueOf(par0 + 101)}): Keyboard.getKeyName(par0); + } + + public static boolean isKeyDown(KeyBinding par0KeyBinding) + { + return par0KeyBinding.getKeyCode() == 0 ? false : (par0KeyBinding.getKeyCode() < 0 ? Mouse.isButtonDown(par0KeyBinding.getKeyCode() + 100) : Keyboard.isKeyDown(par0KeyBinding.getKeyCode())); + } + + public void setOptionKeyBinding(KeyBinding p_151440_1_, int p_151440_2_) + { + p_151440_1_.setKeyCode(p_151440_2_); + this.saveOptions(); + } + + public void setOptionFloatValue(GameSettings.Options par1EnumOptions, float par2) + { + if (par1EnumOptions == GameSettings.Options.SENSITIVITY) + { + this.mouseSensitivity = par2; + } + + if (par1EnumOptions == GameSettings.Options.FOV) + { + this.fovSetting = par2; + } + + if (par1EnumOptions == GameSettings.Options.GAMMA) + { + this.gammaSetting = par2; + } + + if (par1EnumOptions == GameSettings.Options.FRAMERATE_LIMIT) + { + this.limitFramerate = (int)par2; + } + + if (par1EnumOptions == GameSettings.Options.CHAT_OPACITY) + { + this.chatOpacity = par2; + this.mc.ingameGUI.getChatGUI().refreshChat(); + } + + if (par1EnumOptions == GameSettings.Options.CHAT_HEIGHT_FOCUSED) + { + this.chatHeightFocused = par2; + this.mc.ingameGUI.getChatGUI().refreshChat(); + } + + if (par1EnumOptions == GameSettings.Options.CHAT_HEIGHT_UNFOCUSED) + { + this.chatHeightUnfocused = par2; + this.mc.ingameGUI.getChatGUI().refreshChat(); + } + + if (par1EnumOptions == GameSettings.Options.CHAT_WIDTH) + { + this.chatWidth = par2; + this.mc.ingameGUI.getChatGUI().refreshChat(); + } + + if (par1EnumOptions == GameSettings.Options.CHAT_SCALE) + { + this.chatScale = par2; + this.mc.ingameGUI.getChatGUI().refreshChat(); + } + + int i; + + if (par1EnumOptions == GameSettings.Options.ANISOTROPIC_FILTERING) + { + i = this.anisotropicFiltering; + this.anisotropicFiltering = (int)par2; + + if ((float)i != par2) + { + this.mc.getTextureMapBlocks().setAnisotropicFiltering(this.anisotropicFiltering); + this.mc.scheduleResourcesRefresh(); + } + } + + if (par1EnumOptions == GameSettings.Options.MIPMAP_LEVELS) + { + i = this.mipmapLevels; + this.mipmapLevels = (int)par2; + + if ((float)i != par2) + { + this.mc.getTextureMapBlocks().setMipmapLevels(this.mipmapLevels); + this.mc.scheduleResourcesRefresh(); + } + } + + if (par1EnumOptions == GameSettings.Options.RENDER_DISTANCE) + { + this.renderDistanceChunks = (int)par2; + } + } + + public void setOptionValue(GameSettings.Options par1EnumOptions, int par2) + { + if (par1EnumOptions == GameSettings.Options.INVERT_MOUSE) + { + this.invertMouse = !this.invertMouse; + } + + if (par1EnumOptions == GameSettings.Options.GUI_SCALE) + { + this.guiScale = this.guiScale + par2 & 3; + } + + if (par1EnumOptions == GameSettings.Options.PARTICLES) + { + this.particleSetting = (this.particleSetting + par2) % 3; + } + + if (par1EnumOptions == GameSettings.Options.VIEW_BOBBING) + { + this.viewBobbing = !this.viewBobbing; + } + + if (par1EnumOptions == GameSettings.Options.RENDER_CLOUDS) + { + this.clouds = !this.clouds; + } + + if (par1EnumOptions == GameSettings.Options.FORCE_UNICODE_FONT) + { + this.forceUnicodeFont = !this.forceUnicodeFont; + this.mc.fontRenderer.setUnicodeFlag(this.mc.getLanguageManager().isCurrentLocaleUnicode() || this.forceUnicodeFont); + } + + if (par1EnumOptions == GameSettings.Options.ADVANCED_OPENGL) + { + this.advancedOpengl = !this.advancedOpengl; + this.mc.renderGlobal.loadRenderers(); + } + + if (par1EnumOptions == GameSettings.Options.FBO_ENABLE) + { + this.fboEnable = !this.fboEnable; + } + + if (par1EnumOptions == GameSettings.Options.ANAGLYPH) + { + this.anaglyph = !this.anaglyph; + this.mc.refreshResources(); + } + + if (par1EnumOptions == GameSettings.Options.DIFFICULTY) + { + this.difficulty = EnumDifficulty.getDifficultyEnum(this.difficulty.getDifficultyId() + par2 & 3); + } + + if (par1EnumOptions == GameSettings.Options.GRAPHICS) + { + this.fancyGraphics = !this.fancyGraphics; + this.mc.renderGlobal.loadRenderers(); + } + + if (par1EnumOptions == GameSettings.Options.AMBIENT_OCCLUSION) + { + this.ambientOcclusion = (this.ambientOcclusion + par2) % 3; + this.mc.renderGlobal.loadRenderers(); + } + + if (par1EnumOptions == GameSettings.Options.CHAT_VISIBILITY) + { + this.chatVisibility = EntityPlayer.EnumChatVisibility.getEnumChatVisibility((this.chatVisibility.getChatVisibility() + par2) % 3); + } + + if (par1EnumOptions == GameSettings.Options.CHAT_COLOR) + { + this.chatColours = !this.chatColours; + } + + if (par1EnumOptions == GameSettings.Options.CHAT_LINKS) + { + this.chatLinks = !this.chatLinks; + } + + if (par1EnumOptions == GameSettings.Options.CHAT_LINKS_PROMPT) + { + this.chatLinksPrompt = !this.chatLinksPrompt; + } + + if (par1EnumOptions == GameSettings.Options.USE_SERVER_TEXTURES) + { + this.serverTextures = !this.serverTextures; + } + + if (par1EnumOptions == GameSettings.Options.SNOOPER_ENABLED) + { + this.snooperEnabled = !this.snooperEnabled; + } + + if (par1EnumOptions == GameSettings.Options.SHOW_CAPE) + { + this.showCape = !this.showCape; + } + + if (par1EnumOptions == GameSettings.Options.TOUCHSCREEN) + { + this.touchscreen = !this.touchscreen; + } + + if (par1EnumOptions == GameSettings.Options.USE_FULLSCREEN) + { + this.fullScreen = !this.fullScreen; + + if (this.mc.isFullScreen() != this.fullScreen) + { + this.mc.toggleFullscreen(); + } + } + + if (par1EnumOptions == GameSettings.Options.ENABLE_VSYNC) + { + this.enableVsync = !this.enableVsync; + Display.setVSyncEnabled(this.enableVsync); + } + + this.saveOptions(); + } + + public float getOptionFloatValue(GameSettings.Options par1EnumOptions) + { + return par1EnumOptions == GameSettings.Options.FOV ? this.fovSetting : (par1EnumOptions == GameSettings.Options.GAMMA ? this.gammaSetting : (par1EnumOptions == GameSettings.Options.SATURATION ? this.saturation : (par1EnumOptions == GameSettings.Options.SENSITIVITY ? this.mouseSensitivity : (par1EnumOptions == GameSettings.Options.CHAT_OPACITY ? this.chatOpacity : (par1EnumOptions == GameSettings.Options.CHAT_HEIGHT_FOCUSED ? this.chatHeightFocused : (par1EnumOptions == GameSettings.Options.CHAT_HEIGHT_UNFOCUSED ? this.chatHeightUnfocused : (par1EnumOptions == GameSettings.Options.CHAT_SCALE ? this.chatScale : (par1EnumOptions == GameSettings.Options.CHAT_WIDTH ? this.chatWidth : (par1EnumOptions == GameSettings.Options.FRAMERATE_LIMIT ? (float)this.limitFramerate : (par1EnumOptions == GameSettings.Options.ANISOTROPIC_FILTERING ? (float)this.anisotropicFiltering : (par1EnumOptions == GameSettings.Options.MIPMAP_LEVELS ? (float)this.mipmapLevels : (par1EnumOptions == GameSettings.Options.RENDER_DISTANCE ? (float)this.renderDistanceChunks : 0.0F)))))))))))); + } + + public boolean getOptionOrdinalValue(GameSettings.Options par1EnumOptions) + { + switch (GameSettings.SwitchOptions.optionIds[par1EnumOptions.ordinal()]) + { + case 1: + return this.invertMouse; + case 2: + return this.viewBobbing; + case 3: + return this.anaglyph; + case 4: + return this.advancedOpengl; + case 5: + return this.fboEnable; + case 6: + return this.clouds; + case 7: + return this.chatColours; + case 8: + return this.chatLinks; + case 9: + return this.chatLinksPrompt; + case 10: + return this.serverTextures; + case 11: + return this.snooperEnabled; + case 12: + return this.fullScreen; + case 13: + return this.enableVsync; + case 14: + return this.showCape; + case 15: + return this.touchscreen; + case 16: + return this.forceUnicodeFont; + default: + return false; + } + } + + private static String getTranslation(String[] par0ArrayOfStr, int par1) + { + if (par1 < 0 || par1 >= par0ArrayOfStr.length) + { + par1 = 0; + } + + return I18n.format(par0ArrayOfStr[par1], new Object[0]); + } + + public String getKeyBinding(GameSettings.Options par1EnumOptions) + { + String s = I18n.format(par1EnumOptions.getEnumString(), new Object[0]) + ": "; + + if (par1EnumOptions.getEnumFloat()) + { + float f1 = this.getOptionFloatValue(par1EnumOptions); + float f = par1EnumOptions.normalizeValue(f1); + return par1EnumOptions == GameSettings.Options.SENSITIVITY ? (f == 0.0F ? s + I18n.format("options.sensitivity.min", new Object[0]) : (f == 1.0F ? s + I18n.format("options.sensitivity.max", new Object[0]) : s + (int)(f * 200.0F) + "%")) : (par1EnumOptions == GameSettings.Options.FOV ? (f == 0.0F ? s + I18n.format("options.fov.min", new Object[0]) : (f == 1.0F ? s + I18n.format("options.fov.max", new Object[0]) : s + (int)(70.0F + f * 40.0F))) : (par1EnumOptions == GameSettings.Options.FRAMERATE_LIMIT ? (f1 == par1EnumOptions.valueMax ? s + I18n.format("options.framerateLimit.max", new Object[0]) : s + (int)f1 + " fps") : (par1EnumOptions == GameSettings.Options.GAMMA ? (f == 0.0F ? s + I18n.format("options.gamma.min", new Object[0]) : (f == 1.0F ? s + I18n.format("options.gamma.max", new Object[0]) : s + "+" + (int)(f * 100.0F) + "%")) : (par1EnumOptions == GameSettings.Options.SATURATION ? s + (int)(f * 400.0F) + "%" : (par1EnumOptions == GameSettings.Options.CHAT_OPACITY ? s + (int)(f * 90.0F + 10.0F) + "%" : (par1EnumOptions == GameSettings.Options.CHAT_HEIGHT_UNFOCUSED ? s + GuiNewChat.func_146243_b(f) + "px" : (par1EnumOptions == GameSettings.Options.CHAT_HEIGHT_FOCUSED ? s + GuiNewChat.func_146243_b(f) + "px" : (par1EnumOptions == GameSettings.Options.CHAT_WIDTH ? s + GuiNewChat.func_146233_a(f) + "px" : (par1EnumOptions == GameSettings.Options.RENDER_DISTANCE ? s + (int)f1 + " chunks" : (par1EnumOptions == GameSettings.Options.ANISOTROPIC_FILTERING ? (f1 == 1.0F ? s + I18n.format("options.off", new Object[0]) : s + (int)f1) : (par1EnumOptions == GameSettings.Options.MIPMAP_LEVELS ? (f1 == 0.0F ? s + I18n.format("options.off", new Object[0]) : s + (int)f1) : (f == 0.0F ? s + I18n.format("options.off", new Object[0]) : s + (int)(f * 100.0F) + "%")))))))))))); + } + else if (par1EnumOptions.getEnumBoolean()) + { + boolean flag = this.getOptionOrdinalValue(par1EnumOptions); + return flag ? s + I18n.format("options.on", new Object[0]) : s + I18n.format("options.off", new Object[0]); + } + else if (par1EnumOptions == GameSettings.Options.DIFFICULTY) + { + return s + I18n.format(this.difficulty.getDifficultyResourceKey(), new Object[0]); + } + else if (par1EnumOptions == GameSettings.Options.GUI_SCALE) + { + return s + getTranslation(GUISCALES, this.guiScale); + } + else if (par1EnumOptions == GameSettings.Options.CHAT_VISIBILITY) + { + return s + I18n.format(this.chatVisibility.getResourceKey(), new Object[0]); + } + else if (par1EnumOptions == GameSettings.Options.PARTICLES) + { + return s + getTranslation(PARTICLES, this.particleSetting); + } + else if (par1EnumOptions == GameSettings.Options.AMBIENT_OCCLUSION) + { + return s + getTranslation(AMBIENT_OCCLUSIONS, this.ambientOcclusion); + } + else if (par1EnumOptions == GameSettings.Options.GRAPHICS) + { + if (this.fancyGraphics) + { + return s + I18n.format("options.graphics.fancy", new Object[0]); + } + else + { + String s1 = "options.graphics.fast"; + return s + I18n.format("options.graphics.fast", new Object[0]); + } + } + else + { + return s; + } + } + + public void loadOptions() + { + try + { + if (!this.optionsFile.exists()) + { + return; + } + + BufferedReader bufferedreader = new BufferedReader(new FileReader(this.optionsFile)); + String s = ""; + this.mapSoundLevels.clear(); + + while ((s = bufferedreader.readLine()) != null) + { + try + { + String[] astring = s.split(":"); + + if (astring[0].equals("mouseSensitivity")) + { + this.mouseSensitivity = this.parseFloat(astring[1]); + } + + if (astring[0].equals("fov")) + { + this.fovSetting = this.parseFloat(astring[1]); + } + + if (astring[0].equals("gamma")) + { + this.gammaSetting = this.parseFloat(astring[1]); + } + + if (astring[0].equals("saturation")) + { + this.saturation = this.parseFloat(astring[1]); + } + + if (astring[0].equals("invertYMouse")) + { + this.invertMouse = astring[1].equals("true"); + } + + if (astring[0].equals("renderDistance")) + { + this.renderDistanceChunks = Integer.parseInt(astring[1]); + } + + if (astring[0].equals("guiScale")) + { + this.guiScale = Integer.parseInt(astring[1]); + } + + if (astring[0].equals("particles")) + { + this.particleSetting = Integer.parseInt(astring[1]); + } + + if (astring[0].equals("bobView")) + { + this.viewBobbing = astring[1].equals("true"); + } + + if (astring[0].equals("anaglyph3d")) + { + this.anaglyph = astring[1].equals("true"); + } + + if (astring[0].equals("advancedOpengl")) + { + this.advancedOpengl = astring[1].equals("true"); + } + + if (astring[0].equals("maxFps")) + { + this.limitFramerate = Integer.parseInt(astring[1]); + } + + if (astring[0].equals("fboEnable")) + { + this.fboEnable = astring[1].equals("true"); + } + + if (astring[0].equals("difficulty")) + { + this.difficulty = EnumDifficulty.getDifficultyEnum(Integer.parseInt(astring[1])); + } + + if (astring[0].equals("fancyGraphics")) + { + this.fancyGraphics = astring[1].equals("true"); + } + + if (astring[0].equals("ao")) + { + if (astring[1].equals("true")) + { + this.ambientOcclusion = 2; + } + else if (astring[1].equals("false")) + { + this.ambientOcclusion = 0; + } + else + { + this.ambientOcclusion = Integer.parseInt(astring[1]); + } + } + + if (astring[0].equals("clouds")) + { + this.clouds = astring[1].equals("true"); + } + + if (astring[0].equals("resourcePacks")) + { + this.resourcePacks = (List)gson.fromJson(s.substring(s.indexOf(58) + 1), typeListString); + + if (this.resourcePacks == null) + { + this.resourcePacks = new ArrayList(); + } + } + + if (astring[0].equals("lastServer") && astring.length >= 2) + { + this.lastServer = s.substring(s.indexOf(58) + 1); + } + + if (astring[0].equals("lang") && astring.length >= 2) + { + this.language = astring[1]; + } + + if (astring[0].equals("chatVisibility")) + { + this.chatVisibility = EntityPlayer.EnumChatVisibility.getEnumChatVisibility(Integer.parseInt(astring[1])); + } + + if (astring[0].equals("chatColors")) + { + this.chatColours = astring[1].equals("true"); + } + + if (astring[0].equals("chatLinks")) + { + this.chatLinks = astring[1].equals("true"); + } + + if (astring[0].equals("chatLinksPrompt")) + { + this.chatLinksPrompt = astring[1].equals("true"); + } + + if (astring[0].equals("chatOpacity")) + { + this.chatOpacity = this.parseFloat(astring[1]); + } + + if (astring[0].equals("serverTextures")) + { + this.serverTextures = astring[1].equals("true"); + } + + if (astring[0].equals("snooperEnabled")) + { + this.snooperEnabled = astring[1].equals("true"); + } + + if (astring[0].equals("fullscreen")) + { + this.fullScreen = astring[1].equals("true"); + } + + if (astring[0].equals("enableVsync")) + { + this.enableVsync = astring[1].equals("true"); + } + + if (astring[0].equals("hideServerAddress")) + { + this.hideServerAddress = astring[1].equals("true"); + } + + if (astring[0].equals("advancedItemTooltips")) + { + this.advancedItemTooltips = astring[1].equals("true"); + } + + if (astring[0].equals("pauseOnLostFocus")) + { + this.pauseOnLostFocus = astring[1].equals("true"); + } + + if (astring[0].equals("showCape")) + { + this.showCape = astring[1].equals("true"); + } + + if (astring[0].equals("touchscreen")) + { + this.touchscreen = astring[1].equals("true"); + } + + if (astring[0].equals("overrideHeight")) + { + this.overrideHeight = Integer.parseInt(astring[1]); + } + + if (astring[0].equals("overrideWidth")) + { + this.overrideWidth = Integer.parseInt(astring[1]); + } + + if (astring[0].equals("heldItemTooltips")) + { + this.heldItemTooltips = astring[1].equals("true"); + } + + if (astring[0].equals("chatHeightFocused")) + { + this.chatHeightFocused = this.parseFloat(astring[1]); + } + + if (astring[0].equals("chatHeightUnfocused")) + { + this.chatHeightUnfocused = this.parseFloat(astring[1]); + } + + if (astring[0].equals("chatScale")) + { + this.chatScale = this.parseFloat(astring[1]); + } + + if (astring[0].equals("chatWidth")) + { + this.chatWidth = this.parseFloat(astring[1]); + } + + if (astring[0].equals("showInventoryAchievementHint")) + { + this.showInventoryAchievementHint = astring[1].equals("true"); + } + + if (astring[0].equals("mipmapLevels")) + { + this.mipmapLevels = Integer.parseInt(astring[1]); + } + + if (astring[0].equals("anisotropicFiltering")) + { + this.anisotropicFiltering = Integer.parseInt(astring[1]); + } + + if (astring[0].equals("forceUnicodeFont")) + { + this.forceUnicodeFont = astring[1].equals("true"); + } + + KeyBinding[] akeybinding = this.keyBindings; + int i = akeybinding.length; + int j; + + for (j = 0; j < i; ++j) + { + KeyBinding keybinding = akeybinding[j]; + + if (astring[0].equals("key_" + keybinding.getKeyDescription())) + { + keybinding.setKeyCode(Integer.parseInt(astring[1])); + } + } + + SoundCategory[] asoundcategory = SoundCategory.values(); + i = asoundcategory.length; + + for (j = 0; j < i; ++j) + { + SoundCategory soundcategory = asoundcategory[j]; + + if (astring[0].equals("soundCategory_" + soundcategory.getCategoryName())) + { + this.mapSoundLevels.put(soundcategory, Float.valueOf(this.parseFloat(astring[1]))); + } + } + } + catch (Exception exception) + { + logger.warn("Skipping bad option: " + s); + } + } + + KeyBinding.resetKeyBindingArrayAndHash(); + bufferedreader.close(); + } + catch (Exception exception1) + { + logger.error("Failed to load options", exception1); + } + } + + private float parseFloat(String par1Str) + { + return par1Str.equals("true") ? 1.0F : (par1Str.equals("false") ? 0.0F : Float.parseFloat(par1Str)); + } + + public void saveOptions() + { + if (FMLClientHandler.instance().isLoading()) return; + try + { + PrintWriter printwriter = new PrintWriter(new FileWriter(this.optionsFile)); + printwriter.println("invertYMouse:" + this.invertMouse); + printwriter.println("mouseSensitivity:" + this.mouseSensitivity); + printwriter.println("fov:" + this.fovSetting); + printwriter.println("gamma:" + this.gammaSetting); + printwriter.println("saturation:" + this.saturation); + printwriter.println("renderDistance:" + this.renderDistanceChunks); + printwriter.println("guiScale:" + this.guiScale); + printwriter.println("particles:" + this.particleSetting); + printwriter.println("bobView:" + this.viewBobbing); + printwriter.println("anaglyph3d:" + this.anaglyph); + printwriter.println("advancedOpengl:" + this.advancedOpengl); + printwriter.println("maxFps:" + this.limitFramerate); + printwriter.println("fboEnable:" + this.fboEnable); + printwriter.println("difficulty:" + this.difficulty.getDifficultyId()); + printwriter.println("fancyGraphics:" + this.fancyGraphics); + printwriter.println("ao:" + this.ambientOcclusion); + printwriter.println("clouds:" + this.clouds); + printwriter.println("resourcePacks:" + gson.toJson(this.resourcePacks)); + printwriter.println("lastServer:" + this.lastServer); + printwriter.println("lang:" + this.language); + printwriter.println("chatVisibility:" + this.chatVisibility.getChatVisibility()); + printwriter.println("chatColors:" + this.chatColours); + printwriter.println("chatLinks:" + this.chatLinks); + printwriter.println("chatLinksPrompt:" + this.chatLinksPrompt); + printwriter.println("chatOpacity:" + this.chatOpacity); + printwriter.println("serverTextures:" + this.serverTextures); + printwriter.println("snooperEnabled:" + this.snooperEnabled); + printwriter.println("fullscreen:" + this.fullScreen); + printwriter.println("enableVsync:" + this.enableVsync); + printwriter.println("hideServerAddress:" + this.hideServerAddress); + printwriter.println("advancedItemTooltips:" + this.advancedItemTooltips); + printwriter.println("pauseOnLostFocus:" + this.pauseOnLostFocus); + printwriter.println("showCape:" + this.showCape); + printwriter.println("touchscreen:" + this.touchscreen); + printwriter.println("overrideWidth:" + this.overrideWidth); + printwriter.println("overrideHeight:" + this.overrideHeight); + printwriter.println("heldItemTooltips:" + this.heldItemTooltips); + printwriter.println("chatHeightFocused:" + this.chatHeightFocused); + printwriter.println("chatHeightUnfocused:" + this.chatHeightUnfocused); + printwriter.println("chatScale:" + this.chatScale); + printwriter.println("chatWidth:" + this.chatWidth); + printwriter.println("showInventoryAchievementHint:" + this.showInventoryAchievementHint); + printwriter.println("mipmapLevels:" + this.mipmapLevels); + printwriter.println("anisotropicFiltering:" + this.anisotropicFiltering); + printwriter.println("forceUnicodeFont:" + this.forceUnicodeFont); + KeyBinding[] akeybinding = this.keyBindings; + int i = akeybinding.length; + int j; + + for (j = 0; j < i; ++j) + { + KeyBinding keybinding = akeybinding[j]; + printwriter.println("key_" + keybinding.getKeyDescription() + ":" + keybinding.getKeyCode()); + } + + SoundCategory[] asoundcategory = SoundCategory.values(); + i = asoundcategory.length; + + for (j = 0; j < i; ++j) + { + SoundCategory soundcategory = asoundcategory[j]; + printwriter.println("soundCategory_" + soundcategory.getCategoryName() + ":" + this.getSoundLevel(soundcategory)); + } + + printwriter.close(); + } + catch (Exception exception) + { + logger.error("Failed to save options", exception); + } + + this.sendSettingsToServer(); + } + + public float getSoundLevel(SoundCategory p_151438_1_) + { + return this.mapSoundLevels.containsKey(p_151438_1_) ? ((Float)this.mapSoundLevels.get(p_151438_1_)).floatValue() : 1.0F; + } + + public void setSoundLevel(SoundCategory p_151439_1_, float p_151439_2_) + { + this.mc.getSoundHandler().setSoundLevel(p_151439_1_, p_151439_2_); + this.mapSoundLevels.put(p_151439_1_, Float.valueOf(p_151439_2_)); + } + + public void sendSettingsToServer() + { + if (this.mc.thePlayer != null) + { + this.mc.thePlayer.sendQueue.addToSendQueue(new C15PacketClientSettings(this.language, this.renderDistanceChunks, this.chatVisibility, this.chatColours, this.difficulty, this.showCape)); + } + } + + public boolean shouldRenderClouds() + { + return this.renderDistanceChunks >= 4 && this.clouds; + } + + @SideOnly(Side.CLIENT) + public static enum Options + { + INVERT_MOUSE("options.invertMouse", false, true), + SENSITIVITY("options.sensitivity", true, false), + FOV("options.fov", true, false), + GAMMA("options.gamma", true, false), + SATURATION("options.saturation", true, false), + RENDER_DISTANCE("options.renderDistance", true, false, 2.0F, 16.0F, 1.0F), + VIEW_BOBBING("options.viewBobbing", false, true), + ANAGLYPH("options.anaglyph", false, true), + ADVANCED_OPENGL("options.advancedOpengl", false, true), + FRAMERATE_LIMIT("options.framerateLimit", true, false, 10.0F, 260.0F, 10.0F), + FBO_ENABLE("options.fboEnable", false, true), + DIFFICULTY("options.difficulty", false, false), + GRAPHICS("options.graphics", false, false), + AMBIENT_OCCLUSION("options.ao", false, false), + GUI_SCALE("options.guiScale", false, false), + RENDER_CLOUDS("options.renderClouds", false, true), + PARTICLES("options.particles", false, false), + CHAT_VISIBILITY("options.chat.visibility", false, false), + CHAT_COLOR("options.chat.color", false, true), + CHAT_LINKS("options.chat.links", false, true), + CHAT_OPACITY("options.chat.opacity", true, false), + CHAT_LINKS_PROMPT("options.chat.links.prompt", false, true), + USE_SERVER_TEXTURES("options.serverTextures", false, true), + SNOOPER_ENABLED("options.snooper", false, true), + USE_FULLSCREEN("options.fullscreen", false, true), + ENABLE_VSYNC("options.vsync", false, true), + SHOW_CAPE("options.showCape", false, true), + TOUCHSCREEN("options.touchscreen", false, true), + CHAT_SCALE("options.chat.scale", true, false), + CHAT_WIDTH("options.chat.width", true, false), + CHAT_HEIGHT_FOCUSED("options.chat.height.focused", true, false), + CHAT_HEIGHT_UNFOCUSED("options.chat.height.unfocused", true, false), + MIPMAP_LEVELS("options.mipmapLevels", true, false, 0.0F, 4.0F, 1.0F), + ANISOTROPIC_FILTERING("options.anisotropicFiltering", true, false, 1.0F, 16.0F, 0.0F) + { + private static final String __OBFID = "CL_00000654"; + protected float snapToStep(float p_148264_1_) + { + return (float)MathHelper.roundUpToPowerOfTwo((int)p_148264_1_); + } + }, + FORCE_UNICODE_FONT("options.forceUnicodeFont", false, true); + private final boolean enumFloat; + private final boolean enumBoolean; + private final String enumString; + private final float valueStep; + private float valueMin; + private float valueMax; + + private static final String __OBFID = "CL_00000653"; + + public static GameSettings.Options getEnumOptions(int par0) + { + GameSettings.Options[] aoptions = values(); + int j = aoptions.length; + + for (int k = 0; k < j; ++k) + { + GameSettings.Options options = aoptions[k]; + + if (options.returnEnumOrdinal() == par0) + { + return options; + } + } + + return null; + } + + private Options(String par3Str, boolean par4, boolean par5) + { + this(par3Str, par4, par5, 0.0F, 1.0F, 0.0F); + } + + private Options(String p_i45004_3_, boolean p_i45004_4_, boolean p_i45004_5_, float p_i45004_6_, float p_i45004_7_, float p_i45004_8_) + { + this.enumString = p_i45004_3_; + this.enumFloat = p_i45004_4_; + this.enumBoolean = p_i45004_5_; + this.valueMin = p_i45004_6_; + this.valueMax = p_i45004_7_; + this.valueStep = p_i45004_8_; + } + + public boolean getEnumFloat() + { + return this.enumFloat; + } + + public boolean getEnumBoolean() + { + return this.enumBoolean; + } + + public int returnEnumOrdinal() + { + return this.ordinal(); + } + + public String getEnumString() + { + return this.enumString; + } + + public float getValueMax() + { + return this.valueMax; + } + + public void setValueMax(float p_148263_1_) + { + this.valueMax = p_148263_1_; + } + + public float normalizeValue(float p_148266_1_) + { + return MathHelper.clamp_float((this.snapToStepClamp(p_148266_1_) - this.valueMin) / (this.valueMax - this.valueMin), 0.0F, 1.0F); + } + + public float denormalizeValue(float p_148262_1_) + { + return this.snapToStepClamp(this.valueMin + (this.valueMax - this.valueMin) * MathHelper.clamp_float(p_148262_1_, 0.0F, 1.0F)); + } + + public float snapToStepClamp(float p_148268_1_) + { + p_148268_1_ = this.snapToStep(p_148268_1_); + return MathHelper.clamp_float(p_148268_1_, this.valueMin, this.valueMax); + } + + protected float snapToStep(float p_148264_1_) + { + if (this.valueStep > 0.0F) + { + p_148264_1_ = this.valueStep * (float)Math.round(p_148264_1_ / this.valueStep); + } + + return p_148264_1_; + } + + Options(String p_i45005_3_, boolean p_i45005_4_, boolean p_i45005_5_, float p_i45005_6_, float p_i45005_7_, float p_i45005_8_, Object p_i45005_9_) + { + this(p_i45005_3_, p_i45005_4_, p_i45005_5_, p_i45005_6_, p_i45005_7_, p_i45005_8_); + } + } + + @SideOnly(Side.CLIENT) + + static final class SwitchOptions + { + static final int[] optionIds = new int[GameSettings.Options.values().length]; + private static final String __OBFID = "CL_00000652"; + + static + { + try + { + optionIds[GameSettings.Options.INVERT_MOUSE.ordinal()] = 1; + } + catch (NoSuchFieldError var16) + { + ; + } + + try + { + optionIds[GameSettings.Options.VIEW_BOBBING.ordinal()] = 2; + } + catch (NoSuchFieldError var15) + { + ; + } + + try + { + optionIds[GameSettings.Options.ANAGLYPH.ordinal()] = 3; + } + catch (NoSuchFieldError var14) + { + ; + } + + try + { + optionIds[GameSettings.Options.ADVANCED_OPENGL.ordinal()] = 4; + } + catch (NoSuchFieldError var13) + { + ; + } + + try + { + optionIds[GameSettings.Options.FBO_ENABLE.ordinal()] = 5; + } + catch (NoSuchFieldError var12) + { + ; + } + + try + { + optionIds[GameSettings.Options.RENDER_CLOUDS.ordinal()] = 6; + } + catch (NoSuchFieldError var11) + { + ; + } + + try + { + optionIds[GameSettings.Options.CHAT_COLOR.ordinal()] = 7; + } + catch (NoSuchFieldError var10) + { + ; + } + + try + { + optionIds[GameSettings.Options.CHAT_LINKS.ordinal()] = 8; + } + catch (NoSuchFieldError var9) + { + ; + } + + try + { + optionIds[GameSettings.Options.CHAT_LINKS_PROMPT.ordinal()] = 9; + } + catch (NoSuchFieldError var8) + { + ; + } + + try + { + optionIds[GameSettings.Options.USE_SERVER_TEXTURES.ordinal()] = 10; + } + catch (NoSuchFieldError var7) + { + ; + } + + try + { + optionIds[GameSettings.Options.SNOOPER_ENABLED.ordinal()] = 11; + } + catch (NoSuchFieldError var6) + { + ; + } + + try + { + optionIds[GameSettings.Options.USE_FULLSCREEN.ordinal()] = 12; + } + catch (NoSuchFieldError var5) + { + ; + } + + try + { + optionIds[GameSettings.Options.ENABLE_VSYNC.ordinal()] = 13; + } + catch (NoSuchFieldError var4) + { + ; + } + + try + { + optionIds[GameSettings.Options.SHOW_CAPE.ordinal()] = 14; + } + catch (NoSuchFieldError var3) + { + ; + } + + try + { + optionIds[GameSettings.Options.TOUCHSCREEN.ordinal()] = 15; + } + catch (NoSuchFieldError var2) + { + ; + } + + try + { + optionIds[GameSettings.Options.FORCE_UNICODE_FONT.ordinal()] = 16; + } + catch (NoSuchFieldError var1) + { + ; + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/settings/KeyBinding.java b/src/main/java/net/minecraft/client/settings/KeyBinding.java new file mode 100644 index 0000000..c0e3b1a --- /dev/null +++ b/src/main/java/net/minecraft/client/settings/KeyBinding.java @@ -0,0 +1,157 @@ +package net.minecraft.client.settings; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; +import net.minecraft.client.resources.I18n; +import net.minecraft.util.IntHashMap; + +@SideOnly(Side.CLIENT) +public class KeyBinding implements Comparable +{ + private static final List keybindArray = new ArrayList(); + private static final IntHashMap hash = new IntHashMap(); + private static final Set keybindSet = new HashSet(); + private final String keyDescription; + private final int keyCodeDefault; + private final String keyCategory; + private int keyCode; + private boolean pressed; + private int pressTime; + private static final String __OBFID = "CL_00000628"; + + public static void onTick(int par0) + { + if (par0 != 0) + { + KeyBinding keybinding = (KeyBinding)hash.lookup(par0); + + if (keybinding != null) + { + ++keybinding.pressTime; + } + } + } + + public static void setKeyBindState(int par0, boolean par1) + { + if (par0 != 0) + { + KeyBinding keybinding = (KeyBinding)hash.lookup(par0); + + if (keybinding != null) + { + keybinding.pressed = par1; + } + } + } + + public static void unPressAllKeys() + { + Iterator iterator = keybindArray.iterator(); + + while (iterator.hasNext()) + { + KeyBinding keybinding = (KeyBinding)iterator.next(); + keybinding.unpressKey(); + } + } + + public static void resetKeyBindingArrayAndHash() + { + hash.clearMap(); + Iterator iterator = keybindArray.iterator(); + + while (iterator.hasNext()) + { + KeyBinding keybinding = (KeyBinding)iterator.next(); + hash.addKey(keybinding.keyCode, keybinding); + } + } + + public static Set getKeybinds() + { + return keybindSet; + } + + public KeyBinding(String p_i45001_1_, int p_i45001_2_, String p_i45001_3_) + { + this.keyDescription = p_i45001_1_; + this.keyCode = p_i45001_2_; + this.keyCodeDefault = p_i45001_2_; + this.keyCategory = p_i45001_3_; + keybindArray.add(this); + hash.addKey(p_i45001_2_, this); + keybindSet.add(p_i45001_3_); + } + + public boolean getIsKeyPressed() + { + return this.pressed; + } + + public String getKeyCategory() + { + return this.keyCategory; + } + + public boolean isPressed() + { + if (this.pressTime == 0) + { + return false; + } + else + { + --this.pressTime; + return true; + } + } + + private void unpressKey() + { + this.pressTime = 0; + this.pressed = false; + } + + public String getKeyDescription() + { + return this.keyDescription; + } + + public int getKeyCodeDefault() + { + return this.keyCodeDefault; + } + + public int getKeyCode() + { + return this.keyCode; + } + + public void setKeyCode(int p_151462_1_) + { + this.keyCode = p_151462_1_; + } + + public int compareTo(KeyBinding p_151465_1_) + { + int i = I18n.format(this.keyCategory, new Object[0]).compareTo(I18n.format(p_151465_1_.keyCategory, new Object[0])); + + if (i == 0) + { + i = I18n.format(this.keyDescription, new Object[0]).compareTo(I18n.format(p_151465_1_.keyDescription, new Object[0])); + } + + return i; + } + + public int compareTo(Object par1Obj) + { + return this.compareTo((KeyBinding)par1Obj); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/shader/Framebuffer.java b/src/main/java/net/minecraft/client/shader/Framebuffer.java new file mode 100644 index 0000000..ccc2e92 --- /dev/null +++ b/src/main/java/net/minecraft/client/shader/Framebuffer.java @@ -0,0 +1,281 @@ +package net.minecraft.client.shader; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.nio.ByteBuffer; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.TextureUtil; +import net.minecraftforge.client.MinecraftForgeClient; +import static org.lwjgl.opengl.EXTPackedDepthStencil.*; +import static org.lwjgl.opengl.EXTFramebufferObject.*; +import org.lwjgl.opengl.EXTFramebufferObject; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class Framebuffer +{ + public int framebufferTextureWidth; + public int framebufferTextureHeight; + public int framebufferWidth; + public int framebufferHeight; + public boolean useDepth; + public int framebufferObject; + public int framebufferTexture; + public int depthBuffer; + public float[] framebufferColor; + public int framebufferFilter; + private static final String __OBFID = "CL_00000959"; + + public Framebuffer(int p_i45078_1_, int p_i45078_2_, boolean p_i45078_3_) + { + this.useDepth = p_i45078_3_; + this.framebufferObject = -1; + this.framebufferTexture = -1; + this.depthBuffer = -1; + this.framebufferColor = new float[4]; + this.framebufferColor[0] = 1.0F; + this.framebufferColor[1] = 1.0F; + this.framebufferColor[2] = 1.0F; + this.framebufferColor[3] = 0.0F; + this.createBindFramebuffer(p_i45078_1_, p_i45078_2_); + } + + public void createBindFramebuffer(int p_147613_1_, int p_147613_2_) + { + if (!OpenGlHelper.isFramebufferEnabled()) + { + this.framebufferWidth = p_147613_1_; + this.framebufferHeight = p_147613_2_; + } + else + { + GL11.glEnable(GL11.GL_DEPTH_TEST); + + if (this.framebufferObject >= 0) + { + this.deleteFramebuffer(); + } + + this.createFramebuffer(p_147613_1_, p_147613_2_); + this.checkFramebufferComplete(); + EXTFramebufferObject.glBindFramebufferEXT(36160, 0); + } + } + + public void deleteFramebuffer() + { + if (OpenGlHelper.isFramebufferEnabled()) + { + this.unbindFramebufferTexture(); + this.unbindFramebuffer(); + + if (this.depthBuffer > -1) + { + EXTFramebufferObject.glDeleteRenderbuffersEXT(this.depthBuffer); + this.depthBuffer = -1; + } + + if (this.framebufferTexture > -1) + { + TextureUtil.deleteTexture(this.framebufferTexture); + this.framebufferTexture = -1; + } + + if (this.framebufferObject > -1) + { + EXTFramebufferObject.glBindFramebufferEXT(36160, 0); + EXTFramebufferObject.glDeleteFramebuffersEXT(this.framebufferObject); + this.framebufferObject = -1; + } + } + } + + public void createFramebuffer(int p_147605_1_, int p_147605_2_) + { + this.framebufferWidth = p_147605_1_; + this.framebufferHeight = p_147605_2_; + this.framebufferTextureWidth = p_147605_1_; + this.framebufferTextureHeight = p_147605_2_; + + if (!OpenGlHelper.isFramebufferEnabled()) + { + this.framebufferClear(); + } + else + { + this.framebufferObject = EXTFramebufferObject.glGenFramebuffersEXT(); + this.framebufferTexture = TextureUtil.glGenTextures(); + + if (this.useDepth) + { + this.depthBuffer = EXTFramebufferObject.glGenRenderbuffersEXT(); + } + + this.setFramebufferFilter(9729); + GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.framebufferTexture); + GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA8, this.framebufferTextureWidth, this.framebufferTextureHeight, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer)null); + EXTFramebufferObject.glBindFramebufferEXT(36160, this.framebufferObject); + EXTFramebufferObject.glFramebufferTexture2DEXT(36160, 36064, 3553, this.framebufferTexture, 0); + + if (this.useDepth) + { + EXTFramebufferObject.glBindRenderbufferEXT(36161, this.depthBuffer); + if (MinecraftForgeClient.getStencilBits() == 0) + { + EXTFramebufferObject.glRenderbufferStorageEXT(36161, 33190, this.framebufferTextureWidth, this.framebufferTextureHeight); + EXTFramebufferObject.glFramebufferRenderbufferEXT(36160, 36096, 36161, this.depthBuffer); + } + else + { + EXTFramebufferObject.glRenderbufferStorageEXT(36161, GL_DEPTH24_STENCIL8_EXT, this.framebufferTextureWidth, this.framebufferTextureHeight); + EXTFramebufferObject.glFramebufferRenderbufferEXT(36160, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, this.depthBuffer); + EXTFramebufferObject.glFramebufferRenderbufferEXT(36160, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, this.depthBuffer); + } + } + + this.framebufferClear(); + this.unbindFramebufferTexture(); + } + } + + public void setFramebufferFilter(int p_147607_1_) + { + if (OpenGlHelper.isFramebufferEnabled()) + { + this.framebufferFilter = p_147607_1_; + GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.framebufferTexture); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, (float)p_147607_1_); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, (float)p_147607_1_); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10496.0F); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10496.0F); + GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); + } + } + + public void checkFramebufferComplete() + { + int i = EXTFramebufferObject.glCheckFramebufferStatusEXT(36160); + + switch (i) + { + case 36053: + return; + case 36054: + throw new RuntimeException("GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT"); + case 36055: + throw new RuntimeException("GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT"); + case 36056: + default: + throw new RuntimeException("glCheckFramebufferStatusEXT returned unknown status:" + i); + case 36057: + throw new RuntimeException("GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT"); + case 36058: + throw new RuntimeException("GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT"); + case 36059: + throw new RuntimeException("GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT"); + case 36060: + throw new RuntimeException("GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT"); + } + } + + public void bindFramebufferTexture() + { + if (OpenGlHelper.isFramebufferEnabled()) + { + GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.framebufferTexture); + } + } + + public void unbindFramebufferTexture() + { + if (OpenGlHelper.isFramebufferEnabled()) + { + GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); + } + } + + public void bindFramebuffer(boolean p_147610_1_) + { + if (OpenGlHelper.isFramebufferEnabled()) + { + EXTFramebufferObject.glBindFramebufferEXT(36160, this.framebufferObject); + + if (p_147610_1_) + { + GL11.glViewport(0, 0, this.framebufferWidth, this.framebufferHeight); + } + } + } + + public void unbindFramebuffer() + { + if (OpenGlHelper.isFramebufferEnabled()) + { + EXTFramebufferObject.glBindFramebufferEXT(36160, 0); + } + } + + public void setFramebufferColor(float p_147604_1_, float p_147604_2_, float p_147604_3_, float p_147604_4_) + { + this.framebufferColor[0] = p_147604_1_; + this.framebufferColor[1] = p_147604_2_; + this.framebufferColor[2] = p_147604_3_; + this.framebufferColor[3] = p_147604_4_; + } + + public void framebufferRender(int p_147615_1_, int p_147615_2_) + { + if (OpenGlHelper.isFramebufferEnabled()) + { + GL11.glColorMask(true, true, true, false); + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glDepthMask(false); + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + GL11.glOrtho(0.0D, (double)p_147615_1_, (double)p_147615_2_, 0.0D, 1000.0D, 3000.0D); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + GL11.glTranslatef(0.0F, 0.0F, -2000.0F); + GL11.glViewport(0, 0, p_147615_1_, p_147615_2_); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glDisable(GL11.GL_BLEND); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glEnable(GL11.GL_COLOR_MATERIAL); + this.bindFramebufferTexture(); + float f = (float)p_147615_1_; + float f1 = (float)p_147615_2_; + float f2 = (float)this.framebufferWidth / (float)this.framebufferTextureWidth; + float f3 = (float)this.framebufferHeight / (float)this.framebufferTextureHeight; + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.setColorOpaque_I(-1); + tessellator.addVertexWithUV(0.0D, (double)f1, 0.0D, 0.0D, 0.0D); + tessellator.addVertexWithUV((double)f, (double)f1, 0.0D, (double)f2, 0.0D); + tessellator.addVertexWithUV((double)f, 0.0D, 0.0D, (double)f2, (double)f3); + tessellator.addVertexWithUV(0.0D, 0.0D, 0.0D, 0.0D, (double)f3); + tessellator.draw(); + this.unbindFramebufferTexture(); + GL11.glDepthMask(true); + GL11.glColorMask(true, true, true, true); + } + } + + public void framebufferClear() + { + this.bindFramebuffer(true); + GL11.glClearColor(this.framebufferColor[0], this.framebufferColor[1], this.framebufferColor[2], this.framebufferColor[3]); + int i = 16384; + + if (this.useDepth) + { + GL11.glClearDepth(1.0D); + i |= 256; + } + + GL11.glClear(i); + this.unbindFramebuffer(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/shader/Shader.java b/src/main/java/net/minecraft/client/shader/Shader.java new file mode 100644 index 0000000..2207e68 --- /dev/null +++ b/src/main/java/net/minecraft/client/shader/Shader.java @@ -0,0 +1,122 @@ +package net.minecraft.client.shader; + +import com.google.common.collect.Lists; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Iterator; +import java.util.List; +import javax.vecmath.Matrix4f; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.resources.IResourceManager; +import net.minecraft.client.util.JsonException; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class Shader +{ + private final ShaderManager manager; + public final Framebuffer framebufferIn; + public final Framebuffer framebufferOut; + private final List listAuxFramebuffers = Lists.newArrayList(); + private final List listAuxNames = Lists.newArrayList(); + private final List listAuxWidths = Lists.newArrayList(); + private final List listAuxHeights = Lists.newArrayList(); + private Matrix4f projectionMatrix; + private static final String __OBFID = "CL_00001042"; + + public Shader(IResourceManager p_i45089_1_, String p_i45089_2_, Framebuffer p_i45089_3_, Framebuffer p_i45089_4_) throws JsonException + { + this.manager = new ShaderManager(p_i45089_1_, p_i45089_2_); + this.framebufferIn = p_i45089_3_; + this.framebufferOut = p_i45089_4_; + } + + public void deleteShader() + { + this.manager.func_147988_a(); + } + + public void addAuxFramebuffer(String p_148041_1_, Object p_148041_2_, int p_148041_3_, int p_148041_4_) + { + this.listAuxNames.add(this.listAuxNames.size(), p_148041_1_); + this.listAuxFramebuffers.add(this.listAuxFramebuffers.size(), p_148041_2_); + this.listAuxWidths.add(this.listAuxWidths.size(), Integer.valueOf(p_148041_3_)); + this.listAuxHeights.add(this.listAuxHeights.size(), Integer.valueOf(p_148041_4_)); + } + + private void preLoadShader() + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glDisable(GL11.GL_FOG); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_COLOR_MATERIAL); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); + } + + public void setProjectionMatrix(Matrix4f p_148045_1_) + { + this.projectionMatrix = p_148045_1_; + } + + public void loadShader(float p_148042_1_) + { + this.preLoadShader(); + this.framebufferIn.unbindFramebuffer(); + float f1 = (float)this.framebufferOut.framebufferTextureWidth; + float f2 = (float)this.framebufferOut.framebufferTextureHeight; + GL11.glViewport(0, 0, (int)f1, (int)f2); + this.manager.func_147992_a("DiffuseSampler", this.framebufferIn); + + for (int i = 0; i < this.listAuxFramebuffers.size(); ++i) + { + this.manager.func_147992_a((String)this.listAuxNames.get(i), this.listAuxFramebuffers.get(i)); + this.manager.func_147984_b("AuxSize" + i).func_148087_a((float)((Integer)this.listAuxWidths.get(i)).intValue(), (float)((Integer)this.listAuxHeights.get(i)).intValue()); + } + + this.manager.func_147984_b("ProjMat").func_148088_a(this.projectionMatrix); + this.manager.func_147984_b("InSize").func_148087_a((float)this.framebufferIn.framebufferTextureWidth, (float)this.framebufferIn.framebufferTextureHeight); + this.manager.func_147984_b("OutSize").func_148087_a(f1, f2); + this.manager.func_147984_b("Time").func_148090_a(p_148042_1_); + Minecraft minecraft = Minecraft.getMinecraft(); + this.manager.func_147984_b("ScreenSize").func_148087_a((float)minecraft.displayWidth, (float)minecraft.displayHeight); + this.manager.func_147995_c(); + this.framebufferOut.framebufferClear(); + this.framebufferOut.bindFramebuffer(false); + GL11.glDepthMask(false); + GL11.glColorMask(true, true, true, false); + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.setColorOpaque_I(-1); + tessellator.addVertex(0.0D, (double)f2, 500.0D); + tessellator.addVertex((double)f1, (double)f2, 500.0D); + tessellator.addVertex((double)f1, 0.0D, 500.0D); + tessellator.addVertex(0.0D, 0.0D, 500.0D); + tessellator.draw(); + GL11.glDepthMask(true); + GL11.glColorMask(true, true, true, true); + this.manager.func_147993_b(); + this.framebufferOut.unbindFramebuffer(); + this.framebufferIn.unbindFramebufferTexture(); + Iterator iterator = this.listAuxFramebuffers.iterator(); + + while (iterator.hasNext()) + { + Object object = iterator.next(); + + if (object instanceof Framebuffer) + { + ((Framebuffer)object).unbindFramebufferTexture(); + } + } + } + + public ShaderManager getShaderManager() + { + return this.manager; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/shader/ShaderDefault.java b/src/main/java/net/minecraft/client/shader/ShaderDefault.java new file mode 100644 index 0000000..64e3571 --- /dev/null +++ b/src/main/java/net/minecraft/client/shader/ShaderDefault.java @@ -0,0 +1,34 @@ +package net.minecraft.client.shader; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import javax.vecmath.Matrix4f; + +@SideOnly(Side.CLIENT) +public class ShaderDefault extends ShaderUniform +{ + private static final String __OBFID = "CL_00001039"; + + public ShaderDefault() + { + super("dummy", 4, 1, (ShaderManager)null); + } + + public void func_148090_a(float p_148090_1_) {} + + public void func_148087_a(float p_148087_1_, float p_148087_2_) {} + + public void func_148095_a(float p_148095_1_, float p_148095_2_, float p_148095_3_) {} + + public void func_148081_a(float p_148081_1_, float p_148081_2_, float p_148081_3_, float p_148081_4_) {} + + public void func_148092_b(float p_148092_1_, float p_148092_2_, float p_148092_3_, float p_148092_4_) {} + + public void func_148083_a(int p_148083_1_, int p_148083_2_, int p_148083_3_, int p_148083_4_) {} + + public void func_148097_a(float[] p_148097_1_) {} + + public void func_148094_a(float p_148094_1_, float p_148094_2_, float p_148094_3_, float p_148094_4_, float p_148094_5_, float p_148094_6_, float p_148094_7_, float p_148094_8_, float p_148094_9_, float p_148094_10_, float p_148094_11_, float p_148094_12_, float p_148094_13_, float p_148094_14_, float p_148094_15_, float p_148094_16_) {} + + public void func_148088_a(Matrix4f p_148088_1_) {} +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/shader/ShaderGroup.java b/src/main/java/net/minecraft/client/shader/ShaderGroup.java new file mode 100644 index 0000000..df1bd34 --- /dev/null +++ b/src/main/java/net/minecraft/client/shader/ShaderGroup.java @@ -0,0 +1,387 @@ +package net.minecraft.client.shader; + +import com.google.common.base.Charsets; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.InputStream; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import javax.vecmath.Matrix4f; +import net.minecraft.client.resources.IResource; +import net.minecraft.client.resources.IResourceManager; +import net.minecraft.client.util.JsonException; +import net.minecraft.util.JsonUtils; +import net.minecraft.util.ResourceLocation; +import org.apache.commons.io.IOUtils; + +@SideOnly(Side.CLIENT) +public class ShaderGroup +{ + private final Framebuffer mainFramebuffer; + private final IResourceManager resourceManager; + private final String shaderGroupName; + private final List listShaders = Lists.newArrayList(); + private final Map mapFramebuffers = Maps.newHashMap(); + private final List listFramebuffers = Lists.newArrayList(); + private Matrix4f projectionMatrix; + private int mainFramebufferWidth; + private int mainFramebufferHeight; + private float field_148036_j; + private float field_148037_k; + private static final String __OBFID = "CL_00001041"; + + public ShaderGroup(IResourceManager p_i45088_1_, Framebuffer p_i45088_2_, ResourceLocation p_i45088_3_) throws JsonException + { + this.resourceManager = p_i45088_1_; + this.mainFramebuffer = p_i45088_2_; + this.field_148036_j = 0.0F; + this.field_148037_k = 0.0F; + this.mainFramebufferWidth = p_i45088_2_.framebufferWidth; + this.mainFramebufferHeight = p_i45088_2_.framebufferHeight; + this.shaderGroupName = p_i45088_3_.toString(); + this.resetProjectionMatrix(); + this.initFromLocation(p_i45088_3_); + } + + public void initFromLocation(ResourceLocation p_148025_1_) throws JsonException + { + JsonParser jsonparser = new JsonParser(); + InputStream inputstream = null; + + try + { + IResource iresource = this.resourceManager.getResource(p_148025_1_); + inputstream = iresource.getInputStream(); + JsonObject jsonobject = jsonparser.parse(IOUtils.toString(inputstream, Charsets.UTF_8)).getAsJsonObject(); + JsonArray jsonarray; + int i; + Iterator iterator; + JsonElement jsonelement; + JsonException jsonexception1; + + if (JsonUtils.jsonObjectFieldTypeIsArray(jsonobject, "targets")) + { + jsonarray = jsonobject.getAsJsonArray("targets"); + i = 0; + + for (iterator = jsonarray.iterator(); iterator.hasNext(); ++i) + { + jsonelement = (JsonElement)iterator.next(); + + try + { + this.initTarget(jsonelement); + } + catch (Exception exception1) + { + jsonexception1 = JsonException.func_151379_a(exception1); + jsonexception1.func_151380_a("targets[" + i + "]"); + throw jsonexception1; + } + } + } + + if (JsonUtils.jsonObjectFieldTypeIsArray(jsonobject, "passes")) + { + jsonarray = jsonobject.getAsJsonArray("passes"); + i = 0; + + for (iterator = jsonarray.iterator(); iterator.hasNext(); ++i) + { + jsonelement = (JsonElement)iterator.next(); + + try + { + this.initPass(jsonelement); + } + catch (Exception exception) + { + jsonexception1 = JsonException.func_151379_a(exception); + jsonexception1.func_151380_a("passes[" + i + "]"); + throw jsonexception1; + } + } + } + } + catch (Exception exception2) + { + JsonException jsonexception = JsonException.func_151379_a(exception2); + jsonexception.func_151381_b(p_148025_1_.getResourcePath()); + throw jsonexception; + } + finally + { + IOUtils.closeQuietly(inputstream); + } + } + + private void initTarget(JsonElement p_148027_1_) throws JsonException + { + if (JsonUtils.jsonElementTypeIsString(p_148027_1_)) + { + this.addFramebuffer(p_148027_1_.getAsString(), this.mainFramebufferWidth, this.mainFramebufferHeight); + } + else + { + JsonObject jsonobject = JsonUtils.getJsonElementAsJsonObject(p_148027_1_, "target"); + String s = JsonUtils.getJsonObjectStringFieldValue(jsonobject, "name"); + int i = JsonUtils.getJsonObjectIntegerFieldValueOrDefault(jsonobject, "width", this.mainFramebufferWidth); + int j = JsonUtils.getJsonObjectIntegerFieldValueOrDefault(jsonobject, "height", this.mainFramebufferHeight); + + if (this.mapFramebuffers.containsKey(s)) + { + throw new JsonException(s + " is already defined"); + } + + this.addFramebuffer(s, i, j); + } + } + + private void initPass(JsonElement p_148019_1_) throws JsonException + { + JsonObject jsonobject = JsonUtils.getJsonElementAsJsonObject(p_148019_1_, "pass"); + String s = JsonUtils.getJsonObjectStringFieldValue(jsonobject, "name"); + String s1 = JsonUtils.getJsonObjectStringFieldValue(jsonobject, "intarget"); + String s2 = JsonUtils.getJsonObjectStringFieldValue(jsonobject, "outtarget"); + Framebuffer framebuffer = this.getFramebuffer(s1); + Framebuffer framebuffer1 = this.getFramebuffer(s2); + + if (framebuffer == null) + { + throw new JsonException("Input target \'" + s1 + "\' does not exist"); + } + else if (framebuffer1 == null) + { + throw new JsonException("Output target \'" + s2 + "\' does not exist"); + } + else + { + Shader shader = this.addShader(s, framebuffer, framebuffer1); + JsonArray jsonarray = JsonUtils.getJsonObjectJsonArrayFieldOrDefault(jsonobject, "auxtargets", (JsonArray)null); + + if (jsonarray != null) + { + int i = 0; + + for (Iterator iterator = jsonarray.iterator(); iterator.hasNext(); ++i) + { + JsonElement jsonelement1 = (JsonElement)iterator.next(); + + try + { + JsonObject jsonobject1 = JsonUtils.getJsonElementAsJsonObject(jsonelement1, "auxtarget"); + String s4 = JsonUtils.getJsonObjectStringFieldValue(jsonobject1, "name"); + String s3 = JsonUtils.getJsonObjectStringFieldValue(jsonobject1, "id"); + Framebuffer framebuffer2 = this.getFramebuffer(s3); + + if (framebuffer2 == null) + { + throw new JsonException("Render target \'" + s3 + "\' does not exist"); + } + + shader.addAuxFramebuffer(s4, framebuffer2, framebuffer2.framebufferTextureWidth, framebuffer2.framebufferTextureHeight); + } + catch (Exception exception1) + { + JsonException jsonexception = JsonException.func_151379_a(exception1); + jsonexception.func_151380_a("auxtargets[" + i + "]"); + throw jsonexception; + } + } + } + + JsonArray jsonarray1 = JsonUtils.getJsonObjectJsonArrayFieldOrDefault(jsonobject, "uniforms", (JsonArray)null); + + if (jsonarray1 != null) + { + int j = 0; + + for (Iterator iterator1 = jsonarray1.iterator(); iterator1.hasNext(); ++j) + { + JsonElement jsonelement2 = (JsonElement)iterator1.next(); + + try + { + this.initUniform(jsonelement2); + } + catch (Exception exception) + { + JsonException jsonexception1 = JsonException.func_151379_a(exception); + jsonexception1.func_151380_a("uniforms[" + j + "]"); + throw jsonexception1; + } + } + } + } + } + + private void initUniform(JsonElement p_148028_1_) throws JsonException + { + JsonObject jsonobject = JsonUtils.getJsonElementAsJsonObject(p_148028_1_, "uniform"); + String s = JsonUtils.getJsonObjectStringFieldValue(jsonobject, "name"); + ShaderUniform shaderuniform = ((Shader)this.listShaders.get(this.listShaders.size() - 1)).getShaderManager().func_147991_a(s); + + if (shaderuniform == null) + { + throw new JsonException("Uniform \'" + s + "\' does not exist"); + } + else + { + float[] afloat = new float[4]; + int i = 0; + JsonArray jsonarray = JsonUtils.getJsonObjectJsonArrayField(jsonobject, "values"); + + for (Iterator iterator = jsonarray.iterator(); iterator.hasNext(); ++i) + { + JsonElement jsonelement1 = (JsonElement)iterator.next(); + + try + { + afloat[i] = JsonUtils.getJsonElementFloatValue(jsonelement1, "value"); + } + catch (Exception exception) + { + JsonException jsonexception = JsonException.func_151379_a(exception); + jsonexception.func_151380_a("values[" + i + "]"); + throw jsonexception; + } + } + + switch (i) + { + case 0: + default: + break; + case 1: + shaderuniform.func_148090_a(afloat[0]); + break; + case 2: + shaderuniform.func_148087_a(afloat[0], afloat[1]); + break; + case 3: + shaderuniform.func_148095_a(afloat[0], afloat[1], afloat[2]); + break; + case 4: + shaderuniform.func_148081_a(afloat[0], afloat[1], afloat[2], afloat[3]); + } + } + } + + public void addFramebuffer(String p_148020_1_, int p_148020_2_, int p_148020_3_) + { + Framebuffer framebuffer = new Framebuffer(p_148020_2_, p_148020_3_, true); + framebuffer.setFramebufferColor(0.0F, 0.0F, 0.0F, 0.0F); + this.mapFramebuffers.put(p_148020_1_, framebuffer); + + if (p_148020_2_ == this.mainFramebufferWidth && p_148020_3_ == this.mainFramebufferHeight) + { + this.listFramebuffers.add(framebuffer); + } + } + + public void deleteShaderGroup() + { + Iterator iterator = this.mapFramebuffers.values().iterator(); + + while (iterator.hasNext()) + { + Framebuffer framebuffer = (Framebuffer)iterator.next(); + framebuffer.deleteFramebuffer(); + } + + iterator = this.listShaders.iterator(); + + while (iterator.hasNext()) + { + Shader shader = (Shader)iterator.next(); + shader.deleteShader(); + } + + this.listShaders.clear(); + } + + public Shader addShader(String p_148023_1_, Framebuffer p_148023_2_, Framebuffer p_148023_3_) throws JsonException + { + Shader shader = new Shader(this.resourceManager, p_148023_1_, p_148023_2_, p_148023_3_); + this.listShaders.add(this.listShaders.size(), shader); + return shader; + } + + private void resetProjectionMatrix() + { + this.projectionMatrix = new Matrix4f(); + this.projectionMatrix.setIdentity(); + this.projectionMatrix.m00 = 2.0F / (float)this.mainFramebuffer.framebufferTextureWidth; + this.projectionMatrix.m11 = 2.0F / (float)(-this.mainFramebuffer.framebufferTextureHeight); + this.projectionMatrix.m22 = -0.0020001999F; + this.projectionMatrix.m33 = 1.0F; + this.projectionMatrix.m03 = -1.0F; + this.projectionMatrix.m13 = 1.0F; + this.projectionMatrix.m23 = -1.0001999F; + } + + public void createBindFramebuffers(int p_148026_1_, int p_148026_2_) + { + this.mainFramebufferWidth = this.mainFramebuffer.framebufferTextureWidth; + this.mainFramebufferHeight = this.mainFramebuffer.framebufferTextureHeight; + this.resetProjectionMatrix(); + Iterator iterator = this.listShaders.iterator(); + + while (iterator.hasNext()) + { + Shader shader = (Shader)iterator.next(); + shader.setProjectionMatrix(this.projectionMatrix); + } + + iterator = this.listFramebuffers.iterator(); + + while (iterator.hasNext()) + { + Framebuffer framebuffer = (Framebuffer)iterator.next(); + framebuffer.createBindFramebuffer(p_148026_1_, p_148026_2_); + } + } + + public void loadShaderGroup(float p_148018_1_) + { + if (p_148018_1_ < this.field_148037_k) + { + this.field_148036_j += 1.0F - this.field_148037_k; + this.field_148036_j += p_148018_1_; + } + else + { + this.field_148036_j += p_148018_1_ - this.field_148037_k; + } + + for (this.field_148037_k = p_148018_1_; this.field_148036_j > 20.0F; this.field_148036_j -= 20.0F) + { + ; + } + + Iterator iterator = this.listShaders.iterator(); + + while (iterator.hasNext()) + { + Shader shader = (Shader)iterator.next(); + shader.loadShader(this.field_148036_j / 20.0F); + } + } + + public final String getShaderGroupName() + { + return this.shaderGroupName; + } + + private Framebuffer getFramebuffer(String p_148017_1_) + { + return p_148017_1_ == null ? null : (p_148017_1_.equals("minecraft:main") ? this.mainFramebuffer : (Framebuffer)this.mapFramebuffers.get(p_148017_1_)); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/shader/ShaderLinkHelper.java b/src/main/java/net/minecraft/client/shader/ShaderLinkHelper.java new file mode 100644 index 0000000..3081481 --- /dev/null +++ b/src/main/java/net/minecraft/client/shader/ShaderLinkHelper.java @@ -0,0 +1,61 @@ +package net.minecraft.client.shader; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.util.JsonException; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.lwjgl.opengl.GL20; + +@SideOnly(Side.CLIENT) +public class ShaderLinkHelper +{ + private static final Logger logger = LogManager.getLogger(); + private static ShaderLinkHelper staticShaderLinkHelper; + private static final String __OBFID = "CL_00001045"; + + public static void setNewStaticShaderLinkHelper() + { + staticShaderLinkHelper = new ShaderLinkHelper(); + } + + public static ShaderLinkHelper getStaticShaderLinkHelper() + { + return staticShaderLinkHelper; + } + + public void func_148077_a(ShaderManager p_148077_1_) + { + p_148077_1_.func_147994_f().func_148054_b(p_148077_1_); + p_148077_1_.func_147989_e().func_148054_b(p_148077_1_); + GL20.glDeleteProgram(p_148077_1_.func_147986_h()); + } + + public int func_148078_c() throws JsonException + { + int i = GL20.glCreateProgram(); + + if (i <= 0) + { + throw new JsonException("Could not create shader program (returned program ID " + i + ")"); + } + else + { + return i; + } + } + + public void func_148075_b(ShaderManager p_148075_1_) + { + p_148075_1_.func_147994_f().func_148056_a(p_148075_1_); + p_148075_1_.func_147989_e().func_148056_a(p_148075_1_); + GL20.glLinkProgram(p_148075_1_.func_147986_h()); + int i = GL20.glGetProgrami(p_148075_1_.func_147986_h(), 35714); + + if (i == 0) + { + logger.warn("Error encountered when linking program containing VS " + p_148075_1_.func_147989_e().func_148055_a() + " and FS " + p_148075_1_.func_147994_f().func_148055_a() + ". Log output:"); + logger.warn(GL20.glGetProgramInfoLog(p_148075_1_.func_147986_h(), 32768)); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/shader/ShaderLoader.java b/src/main/java/net/minecraft/client/shader/ShaderLoader.java new file mode 100644 index 0000000..206a0cf --- /dev/null +++ b/src/main/java/net/minecraft/client/shader/ShaderLoader.java @@ -0,0 +1,126 @@ +package net.minecraft.client.shader; + +import com.google.common.collect.Maps; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.BufferedInputStream; +import java.io.IOException; +import java.nio.ByteBuffer; +import java.util.Map; +import net.minecraft.client.resources.IResourceManager; +import net.minecraft.client.util.JsonException; +import net.minecraft.util.ResourceLocation; +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.StringUtils; +import org.lwjgl.BufferUtils; +import org.lwjgl.opengl.GL20; + +@SideOnly(Side.CLIENT) +public class ShaderLoader +{ + private final ShaderLoader.ShaderType field_148061_a; + private final String field_148059_b; + private int field_148060_c; + private int field_148058_d = 0; + private static final String __OBFID = "CL_00001043"; + + private ShaderLoader(ShaderLoader.ShaderType p_i45091_1_, int p_i45091_2_, String p_i45091_3_) + { + this.field_148061_a = p_i45091_1_; + this.field_148060_c = p_i45091_2_; + this.field_148059_b = p_i45091_3_; + } + + public void func_148056_a(ShaderManager p_148056_1_) + { + ++this.field_148058_d; + GL20.glAttachShader(p_148056_1_.func_147986_h(), this.field_148060_c); + } + + public void func_148054_b(ShaderManager p_148054_1_) + { + --this.field_148058_d; + + if (this.field_148058_d <= 0) + { + GL20.glDeleteShader(this.field_148060_c); + this.field_148061_a.func_148064_d().remove(this.field_148059_b); + } + } + + public String func_148055_a() + { + return this.field_148059_b; + } + + public static ShaderLoader func_148057_a(IResourceManager p_148057_0_, ShaderLoader.ShaderType p_148057_1_, String p_148057_2_) throws IOException + { + ShaderLoader shaderloader = (ShaderLoader)p_148057_1_.func_148064_d().get(p_148057_2_); + + if (shaderloader == null) + { + ResourceLocation resourcelocation = new ResourceLocation("shaders/program/" + p_148057_2_ + p_148057_1_.func_148063_b()); + BufferedInputStream bufferedinputstream = new BufferedInputStream(p_148057_0_.getResource(resourcelocation).getInputStream()); + byte[] abyte = IOUtils.toByteArray(bufferedinputstream); + ByteBuffer bytebuffer = BufferUtils.createByteBuffer(abyte.length); + bytebuffer.put(abyte); + bytebuffer.position(0); + int i = GL20.glCreateShader(p_148057_1_.func_148065_c()); + GL20.glShaderSource(i, bytebuffer); + GL20.glCompileShader(i); + + if (GL20.glGetShaderi(i, 35713) == 0) + { + String s1 = StringUtils.trim(GL20.glGetShaderInfoLog(i, 32768)); + JsonException jsonexception = new JsonException("Couldn\'t compile " + p_148057_1_.func_148062_a() + " program: " + s1); + jsonexception.func_151381_b(resourcelocation.getResourcePath()); + throw jsonexception; + } + + shaderloader = new ShaderLoader(p_148057_1_, i, p_148057_2_); + p_148057_1_.func_148064_d().put(p_148057_2_, shaderloader); + } + + return shaderloader; + } + + @SideOnly(Side.CLIENT) + public static enum ShaderType + { + VERTEX("vertex", ".vsh", 35633), + FRAGMENT("fragment", ".fsh", 35632); + private final String field_148072_c; + private final String field_148069_d; + private final int field_148070_e; + private final Map field_148067_f = Maps.newHashMap(); + + private static final String __OBFID = "CL_00001044"; + + private ShaderType(String p_i45090_3_, String p_i45090_4_, int p_i45090_5_) + { + this.field_148072_c = p_i45090_3_; + this.field_148069_d = p_i45090_4_; + this.field_148070_e = p_i45090_5_; + } + + public String func_148062_a() + { + return this.field_148072_c; + } + + protected String func_148063_b() + { + return this.field_148069_d; + } + + protected int func_148065_c() + { + return this.field_148070_e; + } + + protected Map func_148064_d() + { + return this.field_148067_f; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/shader/ShaderManager.java b/src/main/java/net/minecraft/client/shader/ShaderManager.java new file mode 100644 index 0000000..9a55e05 --- /dev/null +++ b/src/main/java/net/minecraft/client/shader/ShaderManager.java @@ -0,0 +1,431 @@ +package net.minecraft.client.shader; + +import com.google.common.base.Charsets; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.InputStream; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import net.minecraft.client.renderer.texture.ITextureObject; +import net.minecraft.client.resources.IResourceManager; +import net.minecraft.client.util.JsonBlendingMode; +import net.minecraft.client.util.JsonException; +import net.minecraft.util.JsonUtils; +import net.minecraft.util.ResourceLocation; +import org.apache.commons.io.IOUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.ARBMultitexture; +import org.lwjgl.opengl.GL13; +import org.lwjgl.opengl.GL20; + +@SideOnly(Side.CLIENT) +public class ShaderManager +{ + private static final Logger logger = LogManager.getLogger(); + private static final ShaderDefault defaultShaderUniform = new ShaderDefault(); + private static ShaderManager staticShaderManager = null; + private static int field_147999_d = -1; + private static boolean field_148000_e = true; + private final Map field_147997_f = Maps.newHashMap(); + private final List field_147998_g = Lists.newArrayList(); + private final List field_148010_h = Lists.newArrayList(); + private final List field_148011_i = Lists.newArrayList(); + private final List field_148008_j = Lists.newArrayList(); + private final Map field_148009_k = Maps.newHashMap(); + private final int field_148006_l; + private final String field_148007_m; + private final boolean field_148004_n; + private boolean field_148005_o; + private final JsonBlendingMode field_148016_p; + private final List field_148015_q; + private final List field_148014_r; + private final ShaderLoader field_148013_s; + private final ShaderLoader field_148012_t; + private static final String __OBFID = "CL_00001040"; + + public ShaderManager(IResourceManager p_i45087_1_, String p_i45087_2_) throws JsonException + { + JsonParser jsonparser = new JsonParser(); + ResourceLocation resourcelocation = new ResourceLocation("shaders/program/" + p_i45087_2_ + ".json"); + this.field_148007_m = p_i45087_2_; + InputStream inputstream = null; + + try + { + inputstream = p_i45087_1_.getResource(resourcelocation).getInputStream(); + JsonObject jsonobject = jsonparser.parse(IOUtils.toString(inputstream, Charsets.UTF_8)).getAsJsonObject(); + String s1 = JsonUtils.getJsonObjectStringFieldValue(jsonobject, "vertex"); + String s2 = JsonUtils.getJsonObjectStringFieldValue(jsonobject, "fragment"); + JsonArray jsonarray = JsonUtils.getJsonObjectJsonArrayFieldOrDefault(jsonobject, "samplers", (JsonArray)null); + + if (jsonarray != null) + { + int i = 0; + + for (Iterator iterator = jsonarray.iterator(); iterator.hasNext(); ++i) + { + JsonElement jsonelement = (JsonElement)iterator.next(); + + try + { + this.func_147996_a(jsonelement); + } + catch (Exception exception2) + { + JsonException jsonexception1 = JsonException.func_151379_a(exception2); + jsonexception1.func_151380_a("samplers[" + i + "]"); + throw jsonexception1; + } + } + } + + JsonArray jsonarray1 = JsonUtils.getJsonObjectJsonArrayFieldOrDefault(jsonobject, "attributes", (JsonArray)null); + Iterator iterator1; + + if (jsonarray1 != null) + { + int j = 0; + this.field_148015_q = Lists.newArrayListWithCapacity(jsonarray1.size()); + this.field_148014_r = Lists.newArrayListWithCapacity(jsonarray1.size()); + + for (iterator1 = jsonarray1.iterator(); iterator1.hasNext(); ++j) + { + JsonElement jsonelement1 = (JsonElement)iterator1.next(); + + try + { + this.field_148014_r.add(JsonUtils.getJsonElementStringValue(jsonelement1, "attribute")); + } + catch (Exception exception1) + { + JsonException jsonexception2 = JsonException.func_151379_a(exception1); + jsonexception2.func_151380_a("attributes[" + j + "]"); + throw jsonexception2; + } + } + } + else + { + this.field_148015_q = null; + this.field_148014_r = null; + } + + JsonArray jsonarray2 = JsonUtils.getJsonObjectJsonArrayFieldOrDefault(jsonobject, "uniforms", (JsonArray)null); + + if (jsonarray2 != null) + { + int k = 0; + + for (Iterator iterator2 = jsonarray2.iterator(); iterator2.hasNext(); ++k) + { + JsonElement jsonelement2 = (JsonElement)iterator2.next(); + + try + { + this.func_147987_b(jsonelement2); + } + catch (Exception exception) + { + JsonException jsonexception3 = JsonException.func_151379_a(exception); + jsonexception3.func_151380_a("uniforms[" + k + "]"); + throw jsonexception3; + } + } + } + + this.field_148016_p = JsonBlendingMode.func_148110_a(JsonUtils.getJsonObjectFieldOrDefault(jsonobject, "blend", (JsonObject)null)); + this.field_148004_n = JsonUtils.getJsonObjectBooleanFieldValueOrDefault(jsonobject, "cull", true); + this.field_148013_s = ShaderLoader.func_148057_a(p_i45087_1_, ShaderLoader.ShaderType.VERTEX, s1); + this.field_148012_t = ShaderLoader.func_148057_a(p_i45087_1_, ShaderLoader.ShaderType.FRAGMENT, s2); + this.field_148006_l = ShaderLinkHelper.getStaticShaderLinkHelper().func_148078_c(); + ShaderLinkHelper.getStaticShaderLinkHelper().func_148075_b(this); + this.func_147990_i(); + + if (this.field_148014_r != null) + { + iterator1 = this.field_148014_r.iterator(); + + while (iterator1.hasNext()) + { + String s3 = (String)iterator1.next(); + int l = GL20.glGetAttribLocation(this.field_148006_l, s3); + this.field_148015_q.add(Integer.valueOf(l)); + } + } + } + catch (Exception exception3) + { + JsonException jsonexception = JsonException.func_151379_a(exception3); + jsonexception.func_151381_b(resourcelocation.getResourcePath()); + throw jsonexception; + } + finally + { + IOUtils.closeQuietly(inputstream); + } + + this.func_147985_d(); + } + + public void func_147988_a() + { + ShaderLinkHelper.getStaticShaderLinkHelper().func_148077_a(this); + } + + public void func_147993_b() + { + GL20.glUseProgram(0); + field_147999_d = -1; + staticShaderManager = null; + field_148000_e = true; + + for (int i = 0; i < this.field_148010_h.size(); ++i) + { + if (this.field_147997_f.get(this.field_147998_g.get(i)) != null) + { + GL13.glActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB + i); + GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); + } + } + } + + public void func_147995_c() + { + this.field_148005_o = false; + staticShaderManager = this; + this.field_148016_p.func_148109_a(); + + if (this.field_148006_l != field_147999_d) + { + GL20.glUseProgram(this.field_148006_l); + field_147999_d = this.field_148006_l; + } + + if (field_148000_e != this.field_148004_n) + { + field_148000_e = this.field_148004_n; + + if (this.field_148004_n) + { + GL11.glEnable(GL11.GL_CULL_FACE); + } + else + { + GL11.glDisable(GL11.GL_CULL_FACE); + } + } + + for (int i = 0; i < this.field_148010_h.size(); ++i) + { + if (this.field_147997_f.get(this.field_147998_g.get(i)) != null) + { + GL13.glActiveTexture(ARBMultitexture.GL_TEXTURE0_ARB + i); + GL11.glEnable(GL11.GL_TEXTURE_2D); + Object object = this.field_147997_f.get(this.field_147998_g.get(i)); + int j = -1; + + if (object instanceof Framebuffer) + { + j = ((Framebuffer)object).framebufferTexture; + } + else if (object instanceof ITextureObject) + { + j = ((ITextureObject)object).getGlTextureId(); + } + else if (object instanceof Integer) + { + j = ((Integer)object).intValue(); + } + + if (j != -1) + { + GL11.glBindTexture(GL11.GL_TEXTURE_2D, j); + GL20.glUniform1i(GL20.glGetUniformLocation(this.field_148006_l, (CharSequence)this.field_147998_g.get(i)), i); + } + } + } + + Iterator iterator = this.field_148011_i.iterator(); + + while (iterator.hasNext()) + { + ShaderUniform shaderuniform = (ShaderUniform)iterator.next(); + shaderuniform.func_148093_b(); + } + } + + public void func_147985_d() + { + this.field_148005_o = true; + } + + public ShaderUniform func_147991_a(String p_147991_1_) + { + return this.field_148009_k.containsKey(p_147991_1_) ? (ShaderUniform)this.field_148009_k.get(p_147991_1_) : null; + } + + public ShaderUniform func_147984_b(String p_147984_1_) + { + return (ShaderUniform)(this.field_148009_k.containsKey(p_147984_1_) ? (ShaderUniform)this.field_148009_k.get(p_147984_1_) : defaultShaderUniform); + } + + private void func_147990_i() + { + int i = 0; + String s; + int k; + + for (int j = 0; i < this.field_147998_g.size(); ++j) + { + s = (String)this.field_147998_g.get(i); + k = GL20.glGetUniformLocation(this.field_148006_l, s); + + if (k == -1) + { + logger.warn("Shader " + this.field_148007_m + "could not find sampler named " + s + " in the specified shader program."); + this.field_147997_f.remove(s); + this.field_147998_g.remove(j); + --j; + } + else + { + this.field_148010_h.add(Integer.valueOf(k)); + } + + ++i; + } + + Iterator iterator = this.field_148011_i.iterator(); + + while (iterator.hasNext()) + { + ShaderUniform shaderuniform = (ShaderUniform)iterator.next(); + s = shaderuniform.func_148086_a(); + k = GL20.glGetUniformLocation(this.field_148006_l, s); + + if (k == -1) + { + logger.warn("Could not find uniform named " + s + " in the specified" + " shader program."); + } + else + { + this.field_148008_j.add(Integer.valueOf(k)); + shaderuniform.func_148084_b(k); + this.field_148009_k.put(s, shaderuniform); + } + } + } + + private void func_147996_a(JsonElement p_147996_1_) + { + JsonObject jsonobject = JsonUtils.getJsonElementAsJsonObject(p_147996_1_, "sampler"); + String s = JsonUtils.getJsonObjectStringFieldValue(jsonobject, "name"); + + if (!JsonUtils.jsonObjectFieldTypeIsString(jsonobject, "file")) + { + this.field_147997_f.put(s, (Object)null); + this.field_147998_g.add(s); + } + else + { + this.field_147998_g.add(s); + } + } + + public void func_147992_a(String p_147992_1_, Object p_147992_2_) + { + if (this.field_147997_f.containsKey(p_147992_1_)) + { + this.field_147997_f.remove(p_147992_1_); + } + + this.field_147997_f.put(p_147992_1_, p_147992_2_); + this.func_147985_d(); + } + + private void func_147987_b(JsonElement p_147987_1_) throws JsonException + { + JsonObject jsonobject = JsonUtils.getJsonElementAsJsonObject(p_147987_1_, "uniform"); + String s = JsonUtils.getJsonObjectStringFieldValue(jsonobject, "name"); + int i = ShaderUniform.func_148085_a(JsonUtils.getJsonObjectStringFieldValue(jsonobject, "type")); + int j = JsonUtils.getJsonObjectIntegerFieldValue(jsonobject, "count"); + float[] afloat = new float[Math.max(j, 16)]; + JsonArray jsonarray = JsonUtils.getJsonObjectJsonArrayField(jsonobject, "values"); + + if (jsonarray.size() != j && jsonarray.size() > 1) + { + throw new JsonException("Invalid amount of values specified (expected " + j + ", found " + jsonarray.size() + ")"); + } + else + { + int k = 0; + + for (Iterator iterator = jsonarray.iterator(); iterator.hasNext(); ++k) + { + JsonElement jsonelement1 = (JsonElement)iterator.next(); + + try + { + afloat[k] = JsonUtils.getJsonElementFloatValue(jsonelement1, "value"); + } + catch (Exception exception) + { + JsonException jsonexception = JsonException.func_151379_a(exception); + jsonexception.func_151380_a("values[" + k + "]"); + throw jsonexception; + } + } + + if (j > 1 && jsonarray.size() == 1) + { + while (k < j) + { + afloat[k] = afloat[0]; + ++k; + } + } + + int l = j > 1 && j <= 4 && i < 8 ? j - 1 : 0; + ShaderUniform shaderuniform = new ShaderUniform(s, i + l, j, this); + + if (i <= 3) + { + shaderuniform.func_148083_a((int)afloat[0], (int)afloat[1], (int)afloat[2], (int)afloat[3]); + } + else if (i <= 7) + { + shaderuniform.func_148092_b(afloat[0], afloat[1], afloat[2], afloat[3]); + } + else + { + shaderuniform.func_148097_a(afloat); + } + + this.field_148011_i.add(shaderuniform); + } + } + + public ShaderLoader func_147989_e() + { + return this.field_148013_s; + } + + public ShaderLoader func_147994_f() + { + return this.field_148012_t; + } + + public int func_147986_h() + { + return this.field_148006_l; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/shader/ShaderUniform.java b/src/main/java/net/minecraft/client/shader/ShaderUniform.java new file mode 100644 index 0000000..1c3d2e4 --- /dev/null +++ b/src/main/java/net/minecraft/client/shader/ShaderUniform.java @@ -0,0 +1,359 @@ +package net.minecraft.client.shader; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; +import javax.vecmath.Matrix4f; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.lwjgl.BufferUtils; +import org.lwjgl.opengl.GL20; +import org.lwjgl.opengl.GL21; + +@SideOnly(Side.CLIENT) +public class ShaderUniform +{ + private static final Logger logger = LogManager.getLogger(); + private int field_148102_b; + private final int field_148103_c; + private final int field_148100_d; + private final IntBuffer field_148101_e; + private final FloatBuffer field_148098_f; + private final String field_148099_g; + private boolean field_148105_h; + private final ShaderManager field_148106_i; + private static final String __OBFID = "CL_00001046"; + + public ShaderUniform(String p_i45092_1_, int p_i45092_2_, int p_i45092_3_, ShaderManager p_i45092_4_) + { + this.field_148099_g = p_i45092_1_; + this.field_148103_c = p_i45092_3_; + this.field_148100_d = p_i45092_2_; + this.field_148106_i = p_i45092_4_; + + if (p_i45092_2_ <= 3) + { + this.field_148101_e = BufferUtils.createIntBuffer(p_i45092_3_); + this.field_148098_f = null; + } + else + { + this.field_148101_e = null; + this.field_148098_f = BufferUtils.createFloatBuffer(p_i45092_3_); + } + + this.field_148102_b = -1; + this.func_148096_h(); + } + + private void func_148096_h() + { + this.field_148105_h = true; + + if (this.field_148106_i != null) + { + this.field_148106_i.func_147985_d(); + } + } + + public static int func_148085_a(String p_148085_0_) + { + byte b0 = -1; + + if (p_148085_0_.equals("int")) + { + b0 = 0; + } + else if (p_148085_0_.equals("float")) + { + b0 = 4; + } + else if (p_148085_0_.startsWith("matrix")) + { + if (p_148085_0_.endsWith("2x2")) + { + b0 = 8; + } + else if (p_148085_0_.endsWith("3x3")) + { + b0 = 9; + } + else if (p_148085_0_.endsWith("4x4")) + { + b0 = 10; + } + else if (p_148085_0_.endsWith("2x3")) + { + b0 = 11; + } + else if (p_148085_0_.endsWith("2x4")) + { + b0 = 12; + } + else if (p_148085_0_.endsWith("3x2")) + { + b0 = 13; + } + else if (p_148085_0_.endsWith("3x4")) + { + b0 = 14; + } + else if (p_148085_0_.endsWith("4x2")) + { + b0 = 15; + } + else if (p_148085_0_.endsWith("4x3")) + { + b0 = 16; + } + } + + return b0; + } + + public void func_148084_b(int p_148084_1_) + { + this.field_148102_b = p_148084_1_; + } + + public String func_148086_a() + { + return this.field_148099_g; + } + + public void func_148090_a(float p_148090_1_) + { + this.field_148098_f.position(0); + this.field_148098_f.put(0, p_148090_1_); + this.func_148096_h(); + } + + public void func_148087_a(float p_148087_1_, float p_148087_2_) + { + this.field_148098_f.position(0); + this.field_148098_f.put(0, p_148087_1_); + this.field_148098_f.put(1, p_148087_2_); + this.func_148096_h(); + } + + public void func_148095_a(float p_148095_1_, float p_148095_2_, float p_148095_3_) + { + this.field_148098_f.position(0); + this.field_148098_f.put(0, p_148095_1_); + this.field_148098_f.put(1, p_148095_2_); + this.field_148098_f.put(2, p_148095_3_); + this.func_148096_h(); + } + + public void func_148081_a(float p_148081_1_, float p_148081_2_, float p_148081_3_, float p_148081_4_) + { + this.field_148098_f.position(0); + this.field_148098_f.put(p_148081_1_); + this.field_148098_f.put(p_148081_2_); + this.field_148098_f.put(p_148081_3_); + this.field_148098_f.put(p_148081_4_); + this.field_148098_f.flip(); + this.func_148096_h(); + } + + public void func_148092_b(float p_148092_1_, float p_148092_2_, float p_148092_3_, float p_148092_4_) + { + this.field_148098_f.position(0); + + if (this.field_148100_d >= 4) + { + this.field_148098_f.put(0, p_148092_1_); + } + + if (this.field_148100_d >= 5) + { + this.field_148098_f.put(1, p_148092_2_); + } + + if (this.field_148100_d >= 6) + { + this.field_148098_f.put(2, p_148092_3_); + } + + if (this.field_148100_d >= 7) + { + this.field_148098_f.put(3, p_148092_4_); + } + + this.func_148096_h(); + } + + public void func_148083_a(int p_148083_1_, int p_148083_2_, int p_148083_3_, int p_148083_4_) + { + this.field_148101_e.position(0); + + if (this.field_148100_d >= 0) + { + this.field_148101_e.put(0, p_148083_1_); + } + + if (this.field_148100_d >= 1) + { + this.field_148101_e.put(1, p_148083_2_); + } + + if (this.field_148100_d >= 2) + { + this.field_148101_e.put(2, p_148083_3_); + } + + if (this.field_148100_d >= 3) + { + this.field_148101_e.put(3, p_148083_4_); + } + + this.func_148096_h(); + } + + public void func_148097_a(float[] p_148097_1_) + { + if (p_148097_1_.length < this.field_148103_c) + { + logger.warn("Uniform.set called with a too-small value array (expected " + this.field_148103_c + ", got " + p_148097_1_.length + "). Ignoring."); + } + else + { + this.field_148098_f.position(0); + this.field_148098_f.put(p_148097_1_); + this.field_148098_f.position(0); + this.func_148096_h(); + } + } + + public void func_148094_a(float p_148094_1_, float p_148094_2_, float p_148094_3_, float p_148094_4_, float p_148094_5_, float p_148094_6_, float p_148094_7_, float p_148094_8_, float p_148094_9_, float p_148094_10_, float p_148094_11_, float p_148094_12_, float p_148094_13_, float p_148094_14_, float p_148094_15_, float p_148094_16_) + { + this.field_148098_f.position(0); + this.field_148098_f.put(0, p_148094_1_); + this.field_148098_f.put(1, p_148094_2_); + this.field_148098_f.put(2, p_148094_3_); + this.field_148098_f.put(3, p_148094_4_); + this.field_148098_f.put(4, p_148094_5_); + this.field_148098_f.put(5, p_148094_6_); + this.field_148098_f.put(6, p_148094_7_); + this.field_148098_f.put(7, p_148094_8_); + this.field_148098_f.put(8, p_148094_9_); + this.field_148098_f.put(9, p_148094_10_); + this.field_148098_f.put(10, p_148094_11_); + this.field_148098_f.put(11, p_148094_12_); + this.field_148098_f.put(12, p_148094_13_); + this.field_148098_f.put(13, p_148094_14_); + this.field_148098_f.put(14, p_148094_15_); + this.field_148098_f.put(15, p_148094_16_); + this.func_148096_h(); + } + + public void func_148088_a(Matrix4f p_148088_1_) + { + this.func_148094_a(p_148088_1_.m00, p_148088_1_.m01, p_148088_1_.m02, p_148088_1_.m03, p_148088_1_.m10, p_148088_1_.m11, p_148088_1_.m12, p_148088_1_.m13, p_148088_1_.m20, p_148088_1_.m21, p_148088_1_.m22, p_148088_1_.m23, p_148088_1_.m30, p_148088_1_.m31, p_148088_1_.m32, p_148088_1_.m33); + } + + public void func_148093_b() + { + if (!this.field_148105_h) + { + ; + } + + this.field_148105_h = false; + + if (this.field_148100_d <= 3) + { + this.func_148091_i(); + } + else if (this.field_148100_d <= 7) + { + this.func_148089_j(); + } + else + { + if (this.field_148100_d > 16) + { + logger.warn("Uniform.upload called, but type value (" + this.field_148100_d + ") is not " + "a valid type. Ignoring."); + return; + } + + this.func_148082_k(); + } + } + + private void func_148091_i() + { + switch (this.field_148100_d) + { + case 0: + GL20.glUniform1(this.field_148102_b, this.field_148101_e); + break; + case 1: + GL20.glUniform2(this.field_148102_b, this.field_148101_e); + break; + case 2: + GL20.glUniform3(this.field_148102_b, this.field_148101_e); + break; + case 3: + GL20.glUniform4(this.field_148102_b, this.field_148101_e); + break; + default: + logger.warn("Uniform.upload called, but count value (" + this.field_148103_c + ") is " + " not in the range of 1 to 4. Ignoring."); + } + } + + private void func_148089_j() + { + switch (this.field_148100_d) + { + case 4: + GL20.glUniform1(this.field_148102_b, this.field_148098_f); + break; + case 5: + GL20.glUniform2(this.field_148102_b, this.field_148098_f); + break; + case 6: + GL20.glUniform3(this.field_148102_b, this.field_148098_f); + break; + case 7: + GL20.glUniform4(this.field_148102_b, this.field_148098_f); + break; + default: + logger.warn("Uniform.upload called, but count value (" + this.field_148103_c + ") is " + "not in the range of 1 to 4. Ignoring."); + } + } + + private void func_148082_k() + { + switch (this.field_148100_d) + { + case 8: + GL20.glUniformMatrix2(this.field_148102_b, true, this.field_148098_f); + break; + case 9: + GL20.glUniformMatrix3(this.field_148102_b, true, this.field_148098_f); + break; + case 10: + GL20.glUniformMatrix4(this.field_148102_b, true, this.field_148098_f); + break; + case 11: + GL21.glUniformMatrix2x3(this.field_148102_b, true, this.field_148098_f); + break; + case 12: + GL21.glUniformMatrix2x4(this.field_148102_b, true, this.field_148098_f); + break; + case 13: + GL21.glUniformMatrix3x2(this.field_148102_b, true, this.field_148098_f); + break; + case 14: + GL21.glUniformMatrix3x4(this.field_148102_b, true, this.field_148098_f); + break; + case 15: + GL21.glUniformMatrix4x2(this.field_148102_b, true, this.field_148098_f); + break; + case 16: + GL21.glUniformMatrix4x3(this.field_148102_b, true, this.field_148098_f); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/shader/TesselatorVertexState.java b/src/main/java/net/minecraft/client/shader/TesselatorVertexState.java new file mode 100644 index 0000000..ba56a9c --- /dev/null +++ b/src/main/java/net/minecraft/client/shader/TesselatorVertexState.java @@ -0,0 +1,63 @@ +package net.minecraft.client.shader; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class TesselatorVertexState +{ + private int[] rawBuffer; + private int rawBufferIndex; + private int vertexCount; + private boolean hasTexture; + private boolean hasBrightness; + private boolean hasNormals; + private boolean hasColor; + private static final String __OBFID = "CL_00000961"; + + public TesselatorVertexState(int[] p_i45079_1_, int p_i45079_2_, int p_i45079_3_, boolean p_i45079_4_, boolean p_i45079_5_, boolean p_i45079_6_, boolean p_i45079_7_) + { + this.rawBuffer = p_i45079_1_; + this.rawBufferIndex = p_i45079_2_; + this.vertexCount = p_i45079_3_; + this.hasTexture = p_i45079_4_; + this.hasBrightness = p_i45079_5_; + this.hasNormals = p_i45079_6_; + this.hasColor = p_i45079_7_; + } + + public int[] getRawBuffer() + { + return this.rawBuffer; + } + + public int getRawBufferIndex() + { + return this.rawBufferIndex; + } + + public int getVertexCount() + { + return this.vertexCount; + } + + public boolean getHasTexture() + { + return this.hasTexture; + } + + public boolean getHasBrightness() + { + return this.hasBrightness; + } + + public boolean getHasNormals() + { + return this.hasNormals; + } + + public boolean getHasColor() + { + return this.hasColor; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/util/JsonBlendingMode.java b/src/main/java/net/minecraft/client/util/JsonBlendingMode.java new file mode 100644 index 0000000..198c5a3 --- /dev/null +++ b/src/main/java/net/minecraft/client/util/JsonBlendingMode.java @@ -0,0 +1,202 @@ +package net.minecraft.client.util; + +import com.google.gson.JsonObject; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.util.JsonUtils; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; + +@SideOnly(Side.CLIENT) +public class JsonBlendingMode +{ + private static JsonBlendingMode field_148118_a = null; + private final int field_148116_b; + private final int field_148117_c; + private final int field_148114_d; + private final int field_148115_e; + private final int field_148112_f; + private final boolean field_148113_g; + private final boolean field_148119_h; + private static final String __OBFID = "CL_00001038"; + + private JsonBlendingMode(boolean p_i45084_1_, boolean p_i45084_2_, int p_i45084_3_, int p_i45084_4_, int p_i45084_5_, int p_i45084_6_, int p_i45084_7_) + { + this.field_148113_g = p_i45084_1_; + this.field_148116_b = p_i45084_3_; + this.field_148114_d = p_i45084_4_; + this.field_148117_c = p_i45084_5_; + this.field_148115_e = p_i45084_6_; + this.field_148119_h = p_i45084_2_; + this.field_148112_f = p_i45084_7_; + } + + public JsonBlendingMode() + { + this(false, true, 1, 0, 1, 0, 32774); + } + + public JsonBlendingMode(int p_i45085_1_, int p_i45085_2_, int p_i45085_3_) + { + this(false, false, p_i45085_1_, p_i45085_2_, p_i45085_1_, p_i45085_2_, p_i45085_3_); + } + + public JsonBlendingMode(int p_i45086_1_, int p_i45086_2_, int p_i45086_3_, int p_i45086_4_, int p_i45086_5_) + { + this(true, false, p_i45086_1_, p_i45086_2_, p_i45086_3_, p_i45086_4_, p_i45086_5_); + } + + public void func_148109_a() + { + if (!this.equals(field_148118_a)) + { + if (field_148118_a == null || this.field_148119_h != field_148118_a.func_148111_b()) + { + field_148118_a = this; + + if (this.field_148119_h) + { + GL11.glDisable(GL11.GL_BLEND); + return; + } + + GL11.glEnable(GL11.GL_BLEND); + } + + GL14.glBlendEquation(this.field_148112_f); + + if (this.field_148113_g) + { + GL14.glBlendFuncSeparate(this.field_148116_b, this.field_148114_d, this.field_148117_c, this.field_148115_e); + } + else + { + GL11.glBlendFunc(this.field_148116_b, this.field_148114_d); + } + } + } + + public boolean equals(Object par1Obj) + { + if (this == par1Obj) + { + return true; + } + else if (!(par1Obj instanceof JsonBlendingMode)) + { + return false; + } + else + { + JsonBlendingMode jsonblendingmode = (JsonBlendingMode)par1Obj; + return this.field_148112_f != jsonblendingmode.field_148112_f ? false : (this.field_148115_e != jsonblendingmode.field_148115_e ? false : (this.field_148114_d != jsonblendingmode.field_148114_d ? false : (this.field_148119_h != jsonblendingmode.field_148119_h ? false : (this.field_148113_g != jsonblendingmode.field_148113_g ? false : (this.field_148117_c != jsonblendingmode.field_148117_c ? false : this.field_148116_b == jsonblendingmode.field_148116_b))))); + } + } + + public int hashCode() + { + int i = this.field_148116_b; + i = 31 * i + this.field_148117_c; + i = 31 * i + this.field_148114_d; + i = 31 * i + this.field_148115_e; + i = 31 * i + this.field_148112_f; + i = 31 * i + (this.field_148113_g ? 1 : 0); + i = 31 * i + (this.field_148119_h ? 1 : 0); + return i; + } + + public boolean func_148111_b() + { + return this.field_148119_h; + } + + public static JsonBlendingMode func_148110_a(JsonObject p_148110_0_) + { + if (p_148110_0_ == null) + { + return new JsonBlendingMode(); + } + else + { + int i = 32774; + int j = 1; + int k = 0; + int l = 1; + int i1 = 0; + boolean flag = true; + boolean flag1 = false; + + if (JsonUtils.jsonObjectFieldTypeIsString(p_148110_0_, "func")) + { + i = func_148108_a(p_148110_0_.get("func").getAsString()); + + if (i != 32774) + { + flag = false; + } + } + + if (JsonUtils.jsonObjectFieldTypeIsString(p_148110_0_, "srcrgb")) + { + j = func_148107_b(p_148110_0_.get("srcrgb").getAsString()); + + if (j != 1) + { + flag = false; + } + } + + if (JsonUtils.jsonObjectFieldTypeIsString(p_148110_0_, "dstrgb")) + { + k = func_148107_b(p_148110_0_.get("dstrgb").getAsString()); + + if (k != 0) + { + flag = false; + } + } + + if (JsonUtils.jsonObjectFieldTypeIsString(p_148110_0_, "srcalpha")) + { + l = func_148107_b(p_148110_0_.get("srcalpha").getAsString()); + + if (l != 1) + { + flag = false; + } + + flag1 = true; + } + + if (JsonUtils.jsonObjectFieldTypeIsString(p_148110_0_, "dstalpha")) + { + i1 = func_148107_b(p_148110_0_.get("dstalpha").getAsString()); + + if (i1 != 0) + { + flag = false; + } + + flag1 = true; + } + + return flag ? new JsonBlendingMode() : (flag1 ? new JsonBlendingMode(j, k, l, i1, i) : new JsonBlendingMode(j, k, i)); + } + } + + private static int func_148108_a(String p_148108_0_) + { + String s1 = p_148108_0_.trim().toLowerCase(); + return s1.equals("add") ? 32774 : (s1.equals("subtract") ? 32778 : (s1.equals("reversesubtract") ? 32779 : (s1.equals("reverse_subtract") ? 32779 : (s1.equals("min") ? 32775 : (s1.equals("max") ? 32776 : 32774))))); + } + + private static int func_148107_b(String p_148107_0_) + { + String s1 = p_148107_0_.trim().toLowerCase(); + s1 = s1.replaceAll("_", ""); + s1 = s1.replaceAll("one", "1"); + s1 = s1.replaceAll("zero", "0"); + s1 = s1.replaceAll("minus", "-"); + return s1.equals("0") ? 0 : (s1.equals("1") ? 1 : (s1.equals("srccolor") ? 768 : (s1.equals("1-srccolor") ? 769 : (s1.equals("dstcolor") ? 774 : (s1.equals("1-dstcolor") ? 775 : (s1.equals("srcalpha") ? 770 : (s1.equals("1-srcalpha") ? 771 : (s1.equals("dstalpha") ? 772 : (s1.equals("1-dstalpha") ? 773 : -1))))))))); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/util/JsonException.java b/src/main/java/net/minecraft/client/util/JsonException.java new file mode 100644 index 0000000..40750ce --- /dev/null +++ b/src/main/java/net/minecraft/client/util/JsonException.java @@ -0,0 +1,99 @@ +package net.minecraft.client.util; + +import com.google.common.collect.Lists; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.List; +import org.apache.commons.lang3.StringUtils; + +@SideOnly(Side.CLIENT) +public class JsonException extends IOException +{ + private final List field_151383_a = Lists.newArrayList(); + private final String field_151382_b; + private static final String __OBFID = "CL_00001414"; + + public JsonException(String p_i45279_1_) + { + this.field_151383_a.add(new JsonException.Entry(null)); + this.field_151382_b = p_i45279_1_; + } + + public JsonException(String p_i45280_1_, Throwable p_i45280_2_) + { + super(p_i45280_2_); + this.field_151383_a.add(new JsonException.Entry(null)); + this.field_151382_b = p_i45280_1_; + } + + public void func_151380_a(String p_151380_1_) + { + ((JsonException.Entry)this.field_151383_a.get(0)).func_151373_a(p_151380_1_); + } + + public void func_151381_b(String p_151381_1_) + { + ((JsonException.Entry)this.field_151383_a.get(0)).field_151376_a = p_151381_1_; + this.field_151383_a.add(0, new JsonException.Entry(null)); + } + + public String getMessage() + { + return "Invalid " + ((JsonException.Entry)this.field_151383_a.get(this.field_151383_a.size() - 1)).toString() + ": " + this.field_151382_b; + } + + public static JsonException func_151379_a(Exception p_151379_0_) + { + if (p_151379_0_ instanceof JsonException) + { + return (JsonException)p_151379_0_; + } + else + { + String s = p_151379_0_.getMessage(); + + if (p_151379_0_ instanceof FileNotFoundException) + { + s = "File not found"; + } + + return new JsonException(s, p_151379_0_); + } + } + + @SideOnly(Side.CLIENT) + public static class Entry + { + private String field_151376_a; + private final List field_151375_b; + private static final String __OBFID = "CL_00001416"; + + private Entry() + { + this.field_151376_a = null; + this.field_151375_b = Lists.newArrayList(); + } + + private void func_151373_a(String p_151373_1_) + { + this.field_151375_b.add(0, p_151373_1_); + } + + public String func_151372_b() + { + return StringUtils.join(this.field_151375_b, "->"); + } + + public String toString() + { + return this.field_151376_a != null ? (!this.field_151375_b.isEmpty() ? this.field_151376_a + " " + this.func_151372_b() : this.field_151376_a) : (!this.field_151375_b.isEmpty() ? "(Unknown file) " + this.func_151372_b() : "(Unknown file)"); + } + + Entry(Object p_i45278_1_) + { + this(); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/util/QuadComparator.java b/src/main/java/net/minecraft/client/util/QuadComparator.java new file mode 100644 index 0000000..587bcc5 --- /dev/null +++ b/src/main/java/net/minecraft/client/util/QuadComparator.java @@ -0,0 +1,65 @@ +package net.minecraft.client.util; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Comparator; + +@SideOnly(Side.CLIENT) +public class QuadComparator implements Comparator +{ + private float field_147630_a; + private float field_147628_b; + private float field_147629_c; + private int[] field_147627_d; + private static final String __OBFID = "CL_00000958"; + + public QuadComparator(int[] p_i45077_1_, float p_i45077_2_, float p_i45077_3_, float p_i45077_4_) + { + this.field_147627_d = p_i45077_1_; + this.field_147630_a = p_i45077_2_; + this.field_147628_b = p_i45077_3_; + this.field_147629_c = p_i45077_4_; + } + + public int compare(Integer p_147626_1_, Integer p_147626_2_) + { + float f = Float.intBitsToFloat(this.field_147627_d[p_147626_1_.intValue()]) - this.field_147630_a; + float f1 = Float.intBitsToFloat(this.field_147627_d[p_147626_1_.intValue() + 1]) - this.field_147628_b; + float f2 = Float.intBitsToFloat(this.field_147627_d[p_147626_1_.intValue() + 2]) - this.field_147629_c; + float f3 = Float.intBitsToFloat(this.field_147627_d[p_147626_1_.intValue() + 8]) - this.field_147630_a; + float f4 = Float.intBitsToFloat(this.field_147627_d[p_147626_1_.intValue() + 9]) - this.field_147628_b; + float f5 = Float.intBitsToFloat(this.field_147627_d[p_147626_1_.intValue() + 10]) - this.field_147629_c; + float f6 = Float.intBitsToFloat(this.field_147627_d[p_147626_1_.intValue() + 16]) - this.field_147630_a; + float f7 = Float.intBitsToFloat(this.field_147627_d[p_147626_1_.intValue() + 17]) - this.field_147628_b; + float f8 = Float.intBitsToFloat(this.field_147627_d[p_147626_1_.intValue() + 18]) - this.field_147629_c; + float f9 = Float.intBitsToFloat(this.field_147627_d[p_147626_1_.intValue() + 24]) - this.field_147630_a; + float f10 = Float.intBitsToFloat(this.field_147627_d[p_147626_1_.intValue() + 25]) - this.field_147628_b; + float f11 = Float.intBitsToFloat(this.field_147627_d[p_147626_1_.intValue() + 26]) - this.field_147629_c; + float f12 = Float.intBitsToFloat(this.field_147627_d[p_147626_2_.intValue()]) - this.field_147630_a; + float f13 = Float.intBitsToFloat(this.field_147627_d[p_147626_2_.intValue() + 1]) - this.field_147628_b; + float f14 = Float.intBitsToFloat(this.field_147627_d[p_147626_2_.intValue() + 2]) - this.field_147629_c; + float f15 = Float.intBitsToFloat(this.field_147627_d[p_147626_2_.intValue() + 8]) - this.field_147630_a; + float f16 = Float.intBitsToFloat(this.field_147627_d[p_147626_2_.intValue() + 9]) - this.field_147628_b; + float f17 = Float.intBitsToFloat(this.field_147627_d[p_147626_2_.intValue() + 10]) - this.field_147629_c; + float f18 = Float.intBitsToFloat(this.field_147627_d[p_147626_2_.intValue() + 16]) - this.field_147630_a; + float f19 = Float.intBitsToFloat(this.field_147627_d[p_147626_2_.intValue() + 17]) - this.field_147628_b; + float f20 = Float.intBitsToFloat(this.field_147627_d[p_147626_2_.intValue() + 18]) - this.field_147629_c; + float f21 = Float.intBitsToFloat(this.field_147627_d[p_147626_2_.intValue() + 24]) - this.field_147630_a; + float f22 = Float.intBitsToFloat(this.field_147627_d[p_147626_2_.intValue() + 25]) - this.field_147628_b; + float f23 = Float.intBitsToFloat(this.field_147627_d[p_147626_2_.intValue() + 26]) - this.field_147629_c; + float f24 = (f + f3 + f6 + f9) * 0.25F; + float f25 = (f1 + f4 + f7 + f10) * 0.25F; + float f26 = (f2 + f5 + f8 + f11) * 0.25F; + float f27 = (f12 + f15 + f18 + f21) * 0.25F; + float f28 = (f13 + f16 + f19 + f22) * 0.25F; + float f29 = (f14 + f17 + f20 + f23) * 0.25F; + float f30 = f24 * f24 + f25 * f25 + f26 * f26; + float f31 = f27 * f27 + f28 * f28 + f29 * f29; + return Float.compare(f31, f30); + } + + public int compare(Object par1Obj, Object par2Obj) + { + return this.compare((Integer)par1Obj, (Integer)par2Obj); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/util/RenderDistanceSorter.java b/src/main/java/net/minecraft/client/util/RenderDistanceSorter.java new file mode 100644 index 0000000..c30d827 --- /dev/null +++ b/src/main/java/net/minecraft/client/util/RenderDistanceSorter.java @@ -0,0 +1,25 @@ +package net.minecraft.client.util; + +import com.google.common.collect.ComparisonChain; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Comparator; +import net.minecraft.client.renderer.RenderList; + +@SideOnly(Side.CLIENT) +public class RenderDistanceSorter implements Comparator +{ + private static final String __OBFID = "CL_00000945"; + + public int compare(RenderList p_147714_1_, RenderList p_147714_2_) + { + int i = p_147714_2_.renderChunkX * p_147714_2_.renderChunkX + p_147714_2_.renderChunkY * p_147714_2_.renderChunkY + p_147714_2_.renderChunkZ * p_147714_2_.renderChunkZ; + int j = p_147714_1_.renderChunkX * p_147714_1_.renderChunkX + p_147714_1_.renderChunkY * p_147714_1_.renderChunkY + p_147714_1_.renderChunkZ * p_147714_1_.renderChunkZ; + return ComparisonChain.start().compare(i, j).result(); + } + + public int compare(Object par1Obj, Object par2Obj) + { + return this.compare((RenderList)par1Obj, (RenderList)par2Obj); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/CommandBase.java b/src/main/java/net/minecraft/command/CommandBase.java new file mode 100644 index 0000000..14a4d31 --- /dev/null +++ b/src/main/java/net/minecraft/command/CommandBase.java @@ -0,0 +1,496 @@ +package net.minecraft.command; + +import com.google.common.primitives.Doubles; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.Item; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IChatComponent; + +public abstract class CommandBase implements ICommand +{ + private static IAdminCommand theAdmin; + private static final String __OBFID = "CL_00001739"; + + public int getRequiredPermissionLevel() + { + return 4; + } + + public List getCommandAliases() + { + return null; + } + + public boolean canCommandSenderUseCommand(ICommandSender par1ICommandSender) + { + return par1ICommandSender.canCommandSenderUseCommand(this.getRequiredPermissionLevel(), this.getCommandName()); + } + + public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + return null; + } + + public static int parseInt(ICommandSender par0ICommandSender, String par1Str) + { + try + { + return Integer.parseInt(par1Str); + } + catch (NumberFormatException numberformatexception) + { + throw new NumberInvalidException("commands.generic.num.invalid", new Object[] {par1Str}); + } + } + + public static int parseIntWithMin(ICommandSender par0ICommandSender, String par1Str, int par2) + { + return parseIntBounded(par0ICommandSender, par1Str, par2, Integer.MAX_VALUE); + } + + public static int parseIntBounded(ICommandSender par0ICommandSender, String par1Str, int par2, int par3) + { + int k = parseInt(par0ICommandSender, par1Str); + + if (k < par2) + { + throw new NumberInvalidException("commands.generic.num.tooSmall", new Object[] {Integer.valueOf(k), Integer.valueOf(par2)}); + } + else if (k > par3) + { + throw new NumberInvalidException("commands.generic.num.tooBig", new Object[] {Integer.valueOf(k), Integer.valueOf(par3)}); + } + else + { + return k; + } + } + + public static double parseDouble(ICommandSender par0ICommandSender, String par1Str) + { + try + { + double d0 = Double.parseDouble(par1Str); + + if (!Doubles.isFinite(d0)) + { + throw new NumberInvalidException("commands.generic.num.invalid", new Object[] {par1Str}); + } + else + { + return d0; + } + } + catch (NumberFormatException numberformatexception) + { + throw new NumberInvalidException("commands.generic.num.invalid", new Object[] {par1Str}); + } + } + + public static double parseDoubleWithMin(ICommandSender par0ICommandSender, String par1Str, double par2) + { + return parseDoubleBounded(par0ICommandSender, par1Str, par2, Double.MAX_VALUE); + } + + public static double parseDoubleBounded(ICommandSender par0ICommandSender, String par1Str, double par2, double par4) + { + double d2 = parseDouble(par0ICommandSender, par1Str); + + if (d2 < par2) + { + throw new NumberInvalidException("commands.generic.double.tooSmall", new Object[] {Double.valueOf(d2), Double.valueOf(par2)}); + } + else if (d2 > par4) + { + throw new NumberInvalidException("commands.generic.double.tooBig", new Object[] {Double.valueOf(d2), Double.valueOf(par4)}); + } + else + { + return d2; + } + } + + public static boolean parseBoolean(ICommandSender par0ICommandSender, String par1Str) + { + if (!par1Str.equals("true") && !par1Str.equals("1")) + { + if (!par1Str.equals("false") && !par1Str.equals("0")) + { + throw new CommandException("commands.generic.boolean.invalid", new Object[] {par1Str}); + } + else + { + return false; + } + } + else + { + return true; + } + } + + public static EntityPlayerMP getCommandSenderAsPlayer(ICommandSender par0ICommandSender) + { + if (par0ICommandSender instanceof EntityPlayerMP) + { + return (EntityPlayerMP)par0ICommandSender; + } + else + { + throw new PlayerNotFoundException("You must specify which player you wish to perform this action on.", new Object[0]); + } + } + + public static EntityPlayerMP getPlayer(ICommandSender par0ICommandSender, String par1Str) + { + EntityPlayerMP entityplayermp = PlayerSelector.matchOnePlayer(par0ICommandSender, par1Str); + + if (entityplayermp != null) + { + return entityplayermp; + } + else + { + entityplayermp = MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername(par1Str); + + if (entityplayermp == null) + { + throw new PlayerNotFoundException(); + } + else + { + return entityplayermp; + } + } + } + + public static String func_96332_d(ICommandSender par0ICommandSender, String par1Str) + { + EntityPlayerMP entityplayermp = PlayerSelector.matchOnePlayer(par0ICommandSender, par1Str); + + if (entityplayermp != null) + { + return entityplayermp.getCommandSenderName(); + } + else if (PlayerSelector.hasArguments(par1Str)) + { + throw new PlayerNotFoundException(); + } + else + { + return par1Str; + } + } + + public static IChatComponent func_147178_a(ICommandSender p_147178_0_, String[] p_147178_1_, int p_147178_2_) + { + return func_147176_a(p_147178_0_, p_147178_1_, p_147178_2_, false); + } + + public static IChatComponent func_147176_a(ICommandSender p_147176_0_, String[] p_147176_1_, int p_147176_2_, boolean p_147176_3_) + { + ChatComponentText chatcomponenttext = new ChatComponentText(""); + + for (int j = p_147176_2_; j < p_147176_1_.length; ++j) + { + if (j > p_147176_2_) + { + chatcomponenttext.appendText(" "); + } + + Object object = new ChatComponentText(p_147176_1_[j]); + + if (p_147176_3_) + { + IChatComponent ichatcomponent = PlayerSelector.func_150869_b(p_147176_0_, p_147176_1_[j]); + + if (ichatcomponent != null) + { + object = ichatcomponent; + } + else if (PlayerSelector.hasArguments(p_147176_1_[j])) + { + throw new PlayerNotFoundException(); + } + } + + chatcomponenttext.appendSibling((IChatComponent)object); + } + + return chatcomponenttext; + } + + public static String func_82360_a(ICommandSender par0ICommandSender, String[] par1ArrayOfStr, int par2) + { + StringBuilder stringbuilder = new StringBuilder(); + + for (int j = par2; j < par1ArrayOfStr.length; ++j) + { + if (j > par2) + { + stringbuilder.append(" "); + } + + String s = par1ArrayOfStr[j]; + stringbuilder.append(s); + } + + return stringbuilder.toString(); + } + + public static double func_110666_a(ICommandSender par0ICommandSender, double par1, String par3Str) + { + return func_110665_a(par0ICommandSender, par1, par3Str, -30000000, 30000000); + } + + public static double func_110665_a(ICommandSender par0ICommandSender, double par1, String par3Str, int par4, int par5) + { + boolean flag = par3Str.startsWith("~"); + + if (flag && Double.isNaN(par1)) + { + throw new NumberInvalidException("commands.generic.num.invalid", new Object[] {Double.valueOf(par1)}); + } + else + { + double d1 = flag ? par1 : 0.0D; + + if (!flag || par3Str.length() > 1) + { + boolean flag1 = par3Str.contains("."); + + if (flag) + { + par3Str = par3Str.substring(1); + } + + d1 += parseDouble(par0ICommandSender, par3Str); + + if (!flag1 && !flag) + { + d1 += 0.5D; + } + } + + if (par4 != 0 || par5 != 0) + { + if (d1 < (double)par4) + { + throw new NumberInvalidException("commands.generic.double.tooSmall", new Object[] {Double.valueOf(d1), Integer.valueOf(par4)}); + } + + if (d1 > (double)par5) + { + throw new NumberInvalidException("commands.generic.double.tooBig", new Object[] {Double.valueOf(d1), Integer.valueOf(par5)}); + } + } + + return d1; + } + } + + public static Item getItemByText(ICommandSender p_147179_0_, String p_147179_1_) + { + Item item = (Item)Item.itemRegistry.getObject(p_147179_1_); + + if (item == null) + { + try + { + Item item1 = Item.getItemById(Integer.parseInt(p_147179_1_)); + + if (item1 != null) + { + ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("commands.generic.deprecatedId", new Object[] {Item.itemRegistry.getNameForObject(item1)}); + chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.GRAY); + p_147179_0_.addChatMessage(chatcomponenttranslation); + } + + item = item1; + } + catch (NumberFormatException numberformatexception) + { + ; + } + } + + if (item == null) + { + throw new NumberInvalidException("commands.give.notFound", new Object[] {p_147179_1_}); + } + else + { + return item; + } + } + + public static Block getBlockByText(ICommandSender p_147180_0_, String p_147180_1_) + { + if (Block.blockRegistry.containsKey(p_147180_1_)) + { + return (Block)Block.blockRegistry.getObject(p_147180_1_); + } + else + { + try + { + int i = Integer.parseInt(p_147180_1_); + + if (Block.blockRegistry.containsId(i)) + { + Block block = Block.getBlockById(i); + ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("commands.generic.deprecatedId", new Object[] {Block.blockRegistry.getNameForObject(block)}); + chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.GRAY); + p_147180_0_.addChatMessage(chatcomponenttranslation); + return block; + } + } + catch (NumberFormatException numberformatexception) + { + ; + } + + throw new NumberInvalidException("commands.give.notFound", new Object[] {p_147180_1_}); + } + } + + public static String joinNiceString(Object[] par0ArrayOfObj) + { + StringBuilder stringbuilder = new StringBuilder(); + + for (int i = 0; i < par0ArrayOfObj.length; ++i) + { + String s = par0ArrayOfObj[i].toString(); + + if (i > 0) + { + if (i == par0ArrayOfObj.length - 1) + { + stringbuilder.append(" and "); + } + else + { + stringbuilder.append(", "); + } + } + + stringbuilder.append(s); + } + + return stringbuilder.toString(); + } + + public static IChatComponent joinNiceString(IChatComponent[] p_147177_0_) + { + ChatComponentText chatcomponenttext = new ChatComponentText(""); + + for (int i = 0; i < p_147177_0_.length; ++i) + { + if (i > 0) + { + if (i == p_147177_0_.length - 1) + { + chatcomponenttext.appendText(" and "); + } + else if (i > 0) + { + chatcomponenttext.appendText(", "); + } + } + + chatcomponenttext.appendSibling(p_147177_0_[i]); + } + + return chatcomponenttext; + } + + public static String joinNiceStringFromCollection(Collection par0Collection) + { + return joinNiceString(par0Collection.toArray(new String[par0Collection.size()])); + } + + public static boolean doesStringStartWith(String par0Str, String par1Str) + { + return par1Str.regionMatches(true, 0, par0Str, 0, par0Str.length()); + } + + public static List getListOfStringsMatchingLastWord(String[] par0ArrayOfStr, String ... par1ArrayOfStr) + { + String s1 = par0ArrayOfStr[par0ArrayOfStr.length - 1]; + ArrayList arraylist = new ArrayList(); + String[] astring1 = par1ArrayOfStr; + int i = par1ArrayOfStr.length; + + for (int j = 0; j < i; ++j) + { + String s2 = astring1[j]; + + if (doesStringStartWith(s1, s2)) + { + arraylist.add(s2); + } + } + + return arraylist; + } + + public static List getListOfStringsFromIterableMatchingLastWord(String[] par0ArrayOfStr, Iterable par1Iterable) + { + String s = par0ArrayOfStr[par0ArrayOfStr.length - 1]; + ArrayList arraylist = new ArrayList(); + Iterator iterator = par1Iterable.iterator(); + + while (iterator.hasNext()) + { + String s1 = (String)iterator.next(); + + if (doesStringStartWith(s, s1)) + { + arraylist.add(s1); + } + } + + return arraylist; + } + + public boolean isUsernameIndex(String[] par1ArrayOfStr, int par2) + { + return false; + } + + public static void notifyAdmins(ICommandSender par0ICommandSender, String par1Str, Object ... par2ArrayOfObj) + { + notifyAdmins(par0ICommandSender, 0, par1Str, par2ArrayOfObj); + } + + public static void notifyAdmins(ICommandSender par0ICommandSender, int par1, String par2Str, Object ... par3ArrayOfObj) + { + if (theAdmin != null) + { + theAdmin.notifyAdmins(par0ICommandSender, par1, par2Str, par3ArrayOfObj); + } + } + + public static void setAdminCommander(IAdminCommand par0IAdminCommand) + { + theAdmin = par0IAdminCommand; + } + + public int compareTo(ICommand par1ICommand) + { + return this.getCommandName().compareTo(par1ICommand.getCommandName()); + } + + public int compareTo(Object par1Obj) + { + return this.compareTo((ICommand)par1Obj); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/CommandClearInventory.java b/src/main/java/net/minecraft/command/CommandClearInventory.java new file mode 100644 index 0000000..03931dc --- /dev/null +++ b/src/main/java/net/minecraft/command/CommandClearInventory.java @@ -0,0 +1,72 @@ +package net.minecraft.command; + +import java.util.List; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.Item; +import net.minecraft.server.MinecraftServer; + +public class CommandClearInventory extends CommandBase +{ + private static final String __OBFID = "CL_00000218"; + + public String getCommandName() + { + return "clear"; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.clear.usage"; + } + + public int getRequiredPermissionLevel() + { + return 2; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + EntityPlayerMP entityplayermp = par2ArrayOfStr.length == 0 ? getCommandSenderAsPlayer(par1ICommandSender) : getPlayer(par1ICommandSender, par2ArrayOfStr[0]); + Item item = par2ArrayOfStr.length >= 2 ? getItemByText(par1ICommandSender, par2ArrayOfStr[1]) : null; + int i = par2ArrayOfStr.length >= 3 ? parseIntWithMin(par1ICommandSender, par2ArrayOfStr[2], 0) : -1; + + if (par2ArrayOfStr.length >= 2 && item == null) + { + throw new CommandException("commands.clear.failure", new Object[] {entityplayermp.getCommandSenderName()}); + } + else + { + int j = entityplayermp.inventory.clearInventory(item, i); + entityplayermp.inventoryContainer.detectAndSendChanges(); + + if (!entityplayermp.capabilities.isCreativeMode) + { + entityplayermp.updateHeldItem(); + } + + if (j == 0) + { + throw new CommandException("commands.clear.failure", new Object[] {entityplayermp.getCommandSenderName()}); + } + else + { + notifyAdmins(par1ICommandSender, "commands.clear.success", new Object[] {entityplayermp.getCommandSenderName(), Integer.valueOf(j)}); + } + } + } + + public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + return par2ArrayOfStr.length == 1 ? getListOfStringsMatchingLastWord(par2ArrayOfStr, this.func_147209_d()) : (par2ArrayOfStr.length == 2 ? getListOfStringsFromIterableMatchingLastWord(par2ArrayOfStr, Item.itemRegistry.getKeys()) : null); + } + + protected String[] func_147209_d() + { + return MinecraftServer.getServer().getAllUsernames(); + } + + public boolean isUsernameIndex(String[] par1ArrayOfStr, int par2) + { + return par2 == 0; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/CommandDebug.java b/src/main/java/net/minecraft/command/CommandDebug.java new file mode 100644 index 0000000..ca8b11f --- /dev/null +++ b/src/main/java/net/minecraft/command/CommandDebug.java @@ -0,0 +1,158 @@ +package net.minecraft.command; + +import java.io.File; +import java.io.FileWriter; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; +import net.minecraft.profiler.Profiler; +import net.minecraft.server.MinecraftServer; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class CommandDebug extends CommandBase +{ + private static final Logger logger = LogManager.getLogger(); + private long field_147206_b; + private int field_147207_c; + private static final String __OBFID = "CL_00000270"; + + public String getCommandName() + { + return "debug"; + } + + public int getRequiredPermissionLevel() + { + return 3; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.debug.usage"; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + if (par2ArrayOfStr.length == 1) + { + if (par2ArrayOfStr[0].equals("start")) + { + notifyAdmins(par1ICommandSender, "commands.debug.start", new Object[0]); + MinecraftServer.getServer().enableProfiling(); + this.field_147206_b = MinecraftServer.getSystemTimeMillis(); + this.field_147207_c = MinecraftServer.getServer().getTickCounter(); + return; + } + + if (par2ArrayOfStr[0].equals("stop")) + { + if (!MinecraftServer.getServer().theProfiler.profilingEnabled) + { + throw new CommandException("commands.debug.notStarted", new Object[0]); + } + + long i = MinecraftServer.getSystemTimeMillis(); + int j = MinecraftServer.getServer().getTickCounter(); + long k = i - this.field_147206_b; + int l = j - this.field_147207_c; + this.func_147205_a(k, l); + MinecraftServer.getServer().theProfiler.profilingEnabled = false; + notifyAdmins(par1ICommandSender, "commands.debug.stop", new Object[] {Float.valueOf((float)k / 1000.0F), Integer.valueOf(l)}); + return; + } + } + + throw new WrongUsageException("commands.debug.usage", new Object[0]); + } + + private void func_147205_a(long p_147205_1_, int p_147205_3_) + { + File file1 = new File(MinecraftServer.getServer().getFile("debug"), "profile-results-" + (new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss")).format(new Date()) + ".txt"); + file1.getParentFile().mkdirs(); + + try + { + FileWriter filewriter = new FileWriter(file1); + filewriter.write(this.func_147204_b(p_147205_1_, p_147205_3_)); + filewriter.close(); + } + catch (Throwable throwable) + { + logger.error("Could not save profiler results to " + file1, throwable); + } + } + + private String func_147204_b(long p_147204_1_, int p_147204_3_) + { + StringBuilder stringbuilder = new StringBuilder(); + stringbuilder.append("---- Minecraft Profiler Results ----\n"); + stringbuilder.append("// "); + stringbuilder.append(func_147203_d()); + stringbuilder.append("\n\n"); + stringbuilder.append("Time span: ").append(p_147204_1_).append(" ms\n"); + stringbuilder.append("Tick span: ").append(p_147204_3_).append(" ticks\n"); + stringbuilder.append("// This is approximately ").append(String.format("%.2f", new Object[] {Float.valueOf((float)p_147204_3_ / ((float)p_147204_1_ / 1000.0F))})).append(" ticks per second. It should be ").append(20).append(" ticks per second\n\n"); + stringbuilder.append("--- BEGIN PROFILE DUMP ---\n\n"); + this.func_147202_a(0, "root", stringbuilder); + stringbuilder.append("--- END PROFILE DUMP ---\n\n"); + return stringbuilder.toString(); + } + + private void func_147202_a(int p_147202_1_, String p_147202_2_, StringBuilder p_147202_3_) + { + List list = MinecraftServer.getServer().theProfiler.getProfilingData(p_147202_2_); + + if (list != null && list.size() >= 3) + { + for (int j = 1; j < list.size(); ++j) + { + Profiler.Result result = (Profiler.Result)list.get(j); + p_147202_3_.append(String.format("[%02d] ", new Object[] {Integer.valueOf(p_147202_1_)})); + + for (int k = 0; k < p_147202_1_; ++k) + { + p_147202_3_.append(" "); + } + + p_147202_3_.append(result.field_76331_c); + p_147202_3_.append(" - "); + p_147202_3_.append(String.format("%.2f", new Object[] {Double.valueOf(result.field_76332_a)})); + p_147202_3_.append("%/"); + p_147202_3_.append(String.format("%.2f", new Object[] {Double.valueOf(result.field_76330_b)})); + p_147202_3_.append("%\n"); + + if (!result.field_76331_c.equals("unspecified")) + { + try + { + this.func_147202_a(p_147202_1_ + 1, p_147202_2_ + "." + result.field_76331_c, p_147202_3_); + } + catch (Exception exception) + { + p_147202_3_.append("[[ EXCEPTION " + exception + " ]]"); + } + } + } + } + } + + private static String func_147203_d() + { + String[] astring = new String[] {"Shiny numbers!", "Am I not running fast enough? :(", "I\'m working as hard as I can!", "Will I ever be good enough for you? :(", "Speedy. Zoooooom!", "Hello world", "40% better than a crash report.", "Now with extra numbers", "Now with less numbers", "Now with the same numbers", "You should add flames to things, it makes them go faster!", "Do you feel the need for... optimization?", "*cracks redstone whip*", "Maybe if you treated it better then it\'ll have more motivation to work faster! Poor server."}; + + try + { + return astring[(int)(System.nanoTime() % (long)astring.length)]; + } + catch (Throwable throwable) + { + return "Witty comment unavailable :("; + } + } + + public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + return par2ArrayOfStr.length == 1 ? getListOfStringsMatchingLastWord(par2ArrayOfStr, new String[] {"start", "stop"}): null; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/CommandDefaultGameMode.java b/src/main/java/net/minecraft/command/CommandDefaultGameMode.java new file mode 100644 index 0000000..be37f98 --- /dev/null +++ b/src/main/java/net/minecraft/command/CommandDefaultGameMode.java @@ -0,0 +1,52 @@ +package net.minecraft.command; + +import java.util.Iterator; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.world.WorldSettings; + +public class CommandDefaultGameMode extends CommandGameMode +{ + private static final String __OBFID = "CL_00000296"; + + public String getCommandName() + { + return "defaultgamemode"; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.defaultgamemode.usage"; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + if (par2ArrayOfStr.length > 0) + { + WorldSettings.GameType gametype = this.getGameModeFromCommand(par1ICommandSender, par2ArrayOfStr[0]); + this.setGameType(gametype); + notifyAdmins(par1ICommandSender, "commands.defaultgamemode.success", new Object[] {new ChatComponentTranslation("gameMode." + gametype.getName(), new Object[0])}); + } + else + { + throw new WrongUsageException("commands.defaultgamemode.usage", new Object[0]); + } + } + + protected void setGameType(WorldSettings.GameType par1EnumGameType) + { + MinecraftServer minecraftserver = MinecraftServer.getServer(); + minecraftserver.setGameType(par1EnumGameType); + EntityPlayerMP entityplayermp; + + if (minecraftserver.getForceGamemode()) + { + for (Iterator iterator = MinecraftServer.getServer().getConfigurationManager().playerEntityList.iterator(); iterator.hasNext(); entityplayermp.fallDistance = 0.0F) + { + entityplayermp = (EntityPlayerMP)iterator.next(); + entityplayermp.setGameType(par1EnumGameType); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/CommandDifficulty.java b/src/main/java/net/minecraft/command/CommandDifficulty.java new file mode 100644 index 0000000..9bb20f6 --- /dev/null +++ b/src/main/java/net/minecraft/command/CommandDifficulty.java @@ -0,0 +1,50 @@ +package net.minecraft.command; + +import java.util.List; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.world.EnumDifficulty; + +public class CommandDifficulty extends CommandBase +{ + private static final String __OBFID = "CL_00000422"; + + public String getCommandName() + { + return "difficulty"; + } + + public int getRequiredPermissionLevel() + { + return 2; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.difficulty.usage"; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + if (par2ArrayOfStr.length > 0) + { + EnumDifficulty enumdifficulty = this.func_147201_h(par1ICommandSender, par2ArrayOfStr[0]); + MinecraftServer.getServer().func_147139_a(enumdifficulty); + notifyAdmins(par1ICommandSender, "commands.difficulty.success", new Object[] {new ChatComponentTranslation(enumdifficulty.getDifficultyResourceKey(), new Object[0])}); + } + else + { + throw new WrongUsageException("commands.difficulty.usage", new Object[0]); + } + } + + protected EnumDifficulty func_147201_h(ICommandSender p_147201_1_, String p_147201_2_) + { + return !p_147201_2_.equalsIgnoreCase("peaceful") && !p_147201_2_.equalsIgnoreCase("p") ? (!p_147201_2_.equalsIgnoreCase("easy") && !p_147201_2_.equalsIgnoreCase("e") ? (!p_147201_2_.equalsIgnoreCase("normal") && !p_147201_2_.equalsIgnoreCase("n") ? (!p_147201_2_.equalsIgnoreCase("hard") && !p_147201_2_.equalsIgnoreCase("h") ? EnumDifficulty.getDifficultyEnum(parseIntBounded(p_147201_1_, p_147201_2_, 0, 3)) : EnumDifficulty.HARD) : EnumDifficulty.NORMAL) : EnumDifficulty.EASY) : EnumDifficulty.PEACEFUL; + } + + public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + return par2ArrayOfStr.length == 1 ? getListOfStringsMatchingLastWord(par2ArrayOfStr, new String[] {"peaceful", "easy", "normal", "hard"}): null; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/CommandEffect.java b/src/main/java/net/minecraft/command/CommandEffect.java new file mode 100644 index 0000000..27ea264 --- /dev/null +++ b/src/main/java/net/minecraft/command/CommandEffect.java @@ -0,0 +1,118 @@ +package net.minecraft.command; + +import java.util.List; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.ChatComponentTranslation; + +public class CommandEffect extends CommandBase +{ + private static final String __OBFID = "CL_00000323"; + + public String getCommandName() + { + return "effect"; + } + + public int getRequiredPermissionLevel() + { + return 2; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.effect.usage"; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + if (par2ArrayOfStr.length < 2) + { + throw new WrongUsageException("commands.effect.usage", new Object[0]); + } + else + { + EntityPlayerMP entityplayermp = getPlayer(par1ICommandSender, par2ArrayOfStr[0]); + + if (par2ArrayOfStr[1].equals("clear")) + { + if (entityplayermp.getActivePotionEffects().isEmpty()) + { + throw new CommandException("commands.effect.failure.notActive.all", new Object[] {entityplayermp.getCommandSenderName()}); + } + + entityplayermp.clearActivePotions(); + notifyAdmins(par1ICommandSender, "commands.effect.success.removed.all", new Object[] {entityplayermp.getCommandSenderName()}); + } + else + { + int i = parseIntWithMin(par1ICommandSender, par2ArrayOfStr[1], 1); + int j = 600; + int k = 30; + int l = 0; + + if (i < 0 || i >= Potion.potionTypes.length || Potion.potionTypes[i] == null) + { + throw new NumberInvalidException("commands.effect.notFound", new Object[] {Integer.valueOf(i)}); + } + + if (par2ArrayOfStr.length >= 3) + { + k = parseIntBounded(par1ICommandSender, par2ArrayOfStr[2], 0, 1000000); + + if (Potion.potionTypes[i].isInstant()) + { + j = k; + } + else + { + j = k * 20; + } + } + else if (Potion.potionTypes[i].isInstant()) + { + j = 1; + } + + if (par2ArrayOfStr.length >= 4) + { + l = parseIntBounded(par1ICommandSender, par2ArrayOfStr[3], 0, 255); + } + + if (k == 0) + { + if (!entityplayermp.isPotionActive(i)) + { + throw new CommandException("commands.effect.failure.notActive", new Object[] {new ChatComponentTranslation(Potion.potionTypes[i].getName(), new Object[0]), entityplayermp.getCommandSenderName()}); + } + + entityplayermp.removePotionEffect(i); + notifyAdmins(par1ICommandSender, "commands.effect.success.removed", new Object[] {new ChatComponentTranslation(Potion.potionTypes[i].getName(), new Object[0]), entityplayermp.getCommandSenderName()}); + } + else + { + PotionEffect potioneffect = new PotionEffect(i, j, l); + entityplayermp.addPotionEffect(potioneffect); + notifyAdmins(par1ICommandSender, "commands.effect.success", new Object[] {new ChatComponentTranslation(potioneffect.getEffectName(), new Object[0]), Integer.valueOf(i), Integer.valueOf(l), entityplayermp.getCommandSenderName(), Integer.valueOf(k)}); + } + } + } + } + + public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + return par2ArrayOfStr.length == 1 ? getListOfStringsMatchingLastWord(par2ArrayOfStr, this.getAllUsernames()) : null; + } + + protected String[] getAllUsernames() + { + return MinecraftServer.getServer().getAllUsernames(); + } + + public boolean isUsernameIndex(String[] par1ArrayOfStr, int par2) + { + return par2 == 0; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/CommandEnchant.java b/src/main/java/net/minecraft/command/CommandEnchant.java new file mode 100644 index 0000000..84502d9 --- /dev/null +++ b/src/main/java/net/minecraft/command/CommandEnchant.java @@ -0,0 +1,109 @@ +package net.minecraft.command; + +import java.util.List; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.server.MinecraftServer; + +public class CommandEnchant extends CommandBase +{ + private static final String __OBFID = "CL_00000377"; + + public String getCommandName() + { + return "enchant"; + } + + public int getRequiredPermissionLevel() + { + return 2; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.enchant.usage"; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + if (par2ArrayOfStr.length < 2) + { + throw new WrongUsageException("commands.enchant.usage", new Object[0]); + } + else + { + EntityPlayerMP entityplayermp = getPlayer(par1ICommandSender, par2ArrayOfStr[0]); + int i = parseIntBounded(par1ICommandSender, par2ArrayOfStr[1], 0, Enchantment.enchantmentsList.length - 1); + int j = 1; + ItemStack itemstack = entityplayermp.getCurrentEquippedItem(); + + if (itemstack == null) + { + throw new CommandException("commands.enchant.noItem", new Object[0]); + } + else + { + Enchantment enchantment = Enchantment.enchantmentsList[i]; + + if (enchantment == null) + { + throw new NumberInvalidException("commands.enchant.notFound", new Object[] {Integer.valueOf(i)}); + } + else if (!enchantment.canApply(itemstack)) + { + throw new CommandException("commands.enchant.cantEnchant", new Object[0]); + } + else + { + if (par2ArrayOfStr.length >= 3) + { + j = parseIntBounded(par1ICommandSender, par2ArrayOfStr[2], enchantment.getMinLevel(), enchantment.getMaxLevel()); + } + + if (itemstack.hasTagCompound()) + { + NBTTagList nbttaglist = itemstack.getEnchantmentTagList(); + + if (nbttaglist != null) + { + for (int k = 0; k < nbttaglist.tagCount(); ++k) + { + short short1 = nbttaglist.getCompoundTagAt(k).getShort("id"); + + if (Enchantment.enchantmentsList[short1] != null) + { + Enchantment enchantment1 = Enchantment.enchantmentsList[short1]; + + if (!enchantment1.canApplyTogether(enchantment)) + { + throw new CommandException("commands.enchant.cantCombine", new Object[] {enchantment.getTranslatedName(j), enchantment1.getTranslatedName(nbttaglist.getCompoundTagAt(k).getShort("lvl"))}); + } + } + } + } + } + + itemstack.addEnchantment(enchantment, j); + notifyAdmins(par1ICommandSender, "commands.enchant.success", new Object[0]); + } + } + } + } + + public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + return par2ArrayOfStr.length == 1 ? getListOfStringsMatchingLastWord(par2ArrayOfStr, this.getListOfPlayers()) : null; + } + + protected String[] getListOfPlayers() + { + return MinecraftServer.getServer().getAllUsernames(); + } + + public boolean isUsernameIndex(String[] par1ArrayOfStr, int par2) + { + return par2 == 0; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/CommandException.java b/src/main/java/net/minecraft/command/CommandException.java new file mode 100644 index 0000000..ac2f9b3 --- /dev/null +++ b/src/main/java/net/minecraft/command/CommandException.java @@ -0,0 +1,18 @@ +package net.minecraft.command; + +public class CommandException extends RuntimeException +{ + private Object[] errorObjects; + private static final String __OBFID = "CL_00001187"; + + public CommandException(String par1Str, Object ... par2ArrayOfObj) + { + super(par1Str); + this.errorObjects = par2ArrayOfObj; + } + + public Object[] getErrorOjbects() + { + return this.errorObjects; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/CommandGameMode.java b/src/main/java/net/minecraft/command/CommandGameMode.java new file mode 100644 index 0000000..60b1245 --- /dev/null +++ b/src/main/java/net/minecraft/command/CommandGameMode.java @@ -0,0 +1,72 @@ +package net.minecraft.command; + +import java.util.List; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.world.WorldSettings; + +public class CommandGameMode extends CommandBase +{ + private static final String __OBFID = "CL_00000448"; + + public String getCommandName() + { + return "gamemode"; + } + + public int getRequiredPermissionLevel() + { + return 2; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.gamemode.usage"; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + if (par2ArrayOfStr.length > 0) + { + WorldSettings.GameType gametype = this.getGameModeFromCommand(par1ICommandSender, par2ArrayOfStr[0]); + EntityPlayerMP entityplayermp = par2ArrayOfStr.length >= 2 ? getPlayer(par1ICommandSender, par2ArrayOfStr[1]) : getCommandSenderAsPlayer(par1ICommandSender); + entityplayermp.setGameType(gametype); + entityplayermp.fallDistance = 0.0F; + ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("gameMode." + gametype.getName(), new Object[0]); + + if (entityplayermp != par1ICommandSender) + { + notifyAdmins(par1ICommandSender, 1, "commands.gamemode.success.other", new Object[] {entityplayermp.getCommandSenderName(), chatcomponenttranslation}); + } + else + { + notifyAdmins(par1ICommandSender, 1, "commands.gamemode.success.self", new Object[] {chatcomponenttranslation}); + } + } + else + { + throw new WrongUsageException("commands.gamemode.usage", new Object[0]); + } + } + + protected WorldSettings.GameType getGameModeFromCommand(ICommandSender par1ICommandSender, String par2Str) + { + return !par2Str.equalsIgnoreCase(WorldSettings.GameType.SURVIVAL.getName()) && !par2Str.equalsIgnoreCase("s") ? (!par2Str.equalsIgnoreCase(WorldSettings.GameType.CREATIVE.getName()) && !par2Str.equalsIgnoreCase("c") ? (!par2Str.equalsIgnoreCase(WorldSettings.GameType.ADVENTURE.getName()) && !par2Str.equalsIgnoreCase("a") ? WorldSettings.getGameTypeById(parseIntBounded(par1ICommandSender, par2Str, 0, WorldSettings.GameType.values().length - 2)) : WorldSettings.GameType.ADVENTURE) : WorldSettings.GameType.CREATIVE) : WorldSettings.GameType.SURVIVAL; + } + + public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + return par2ArrayOfStr.length == 1 ? getListOfStringsMatchingLastWord(par2ArrayOfStr, new String[] {"survival", "creative", "adventure"}): (par2ArrayOfStr.length == 2 ? getListOfStringsMatchingLastWord(par2ArrayOfStr, this.getListOfPlayerUsernames()) : null); + } + + protected String[] getListOfPlayerUsernames() + { + return MinecraftServer.getServer().getAllUsernames(); + } + + public boolean isUsernameIndex(String[] par1ArrayOfStr, int par2) + { + return par2 == 1; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/CommandGameRule.java b/src/main/java/net/minecraft/command/CommandGameRule.java new file mode 100644 index 0000000..5f663e5 --- /dev/null +++ b/src/main/java/net/minecraft/command/CommandGameRule.java @@ -0,0 +1,82 @@ +package net.minecraft.command; + +import java.util.List; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.ChatComponentText; +import net.minecraft.world.GameRules; + +public class CommandGameRule extends CommandBase +{ + private static final String __OBFID = "CL_00000475"; + + public String getCommandName() + { + return "gamerule"; + } + + public int getRequiredPermissionLevel() + { + return 2; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.gamerule.usage"; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + String s1; + + if (par2ArrayOfStr.length == 2) + { + s1 = par2ArrayOfStr[0]; + String s2 = par2ArrayOfStr[1]; + GameRules gamerules2 = this.getGameRules(); + + if (gamerules2.hasRule(s1)) + { + gamerules2.setOrCreateGameRule(s1, s2); + notifyAdmins(par1ICommandSender, "commands.gamerule.success", new Object[0]); + } + else + { + notifyAdmins(par1ICommandSender, "commands.gamerule.norule", new Object[] {s1}); + } + } + else if (par2ArrayOfStr.length == 1) + { + s1 = par2ArrayOfStr[0]; + GameRules gamerules1 = this.getGameRules(); + + if (gamerules1.hasRule(s1)) + { + String s = gamerules1.getGameRuleStringValue(s1); + par1ICommandSender.addChatMessage((new ChatComponentText(s1)).appendText(" = ").appendText(s)); + } + else + { + notifyAdmins(par1ICommandSender, "commands.gamerule.norule", new Object[] {s1}); + } + } + else if (par2ArrayOfStr.length == 0) + { + GameRules gamerules = this.getGameRules(); + par1ICommandSender.addChatMessage(new ChatComponentText(joinNiceString(gamerules.getRules()))); + } + else + { + throw new WrongUsageException("commands.gamerule.usage", new Object[0]); + } + } + + public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + return par2ArrayOfStr.length == 1 ? getListOfStringsMatchingLastWord(par2ArrayOfStr, this.getGameRules().getRules()) : (par2ArrayOfStr.length == 2 ? getListOfStringsMatchingLastWord(par2ArrayOfStr, new String[] {"true", "false"}): null); + } + + private GameRules getGameRules() + { + return MinecraftServer.getServer().worldServerForDimension(0).getGameRules(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/CommandGive.java b/src/main/java/net/minecraft/command/CommandGive.java new file mode 100644 index 0000000..076308f --- /dev/null +++ b/src/main/java/net/minecraft/command/CommandGive.java @@ -0,0 +1,102 @@ +package net.minecraft.command; + +import java.util.List; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.JsonToNBT; +import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.NBTException; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.server.MinecraftServer; + +public class CommandGive extends CommandBase +{ + private static final String __OBFID = "CL_00000502"; + + public String getCommandName() + { + return "give"; + } + + public int getRequiredPermissionLevel() + { + return 2; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.give.usage"; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + if (par2ArrayOfStr.length < 2) + { + throw new WrongUsageException("commands.give.usage", new Object[0]); + } + else + { + EntityPlayerMP entityplayermp = getPlayer(par1ICommandSender, par2ArrayOfStr[0]); + Item item = getItemByText(par1ICommandSender, par2ArrayOfStr[1]); + int i = 1; + int j = 0; + + if (par2ArrayOfStr.length >= 3) + { + i = parseIntBounded(par1ICommandSender, par2ArrayOfStr[2], 1, 64); + } + + if (par2ArrayOfStr.length >= 4) + { + j = parseInt(par1ICommandSender, par2ArrayOfStr[3]); + } + + ItemStack itemstack = new ItemStack(item, i, j); + + if (par2ArrayOfStr.length >= 5) + { + String s = func_147178_a(par1ICommandSender, par2ArrayOfStr, 4).getUnformattedText(); + + try + { + NBTBase nbtbase = JsonToNBT.func_150315_a(s); + + if (!(nbtbase instanceof NBTTagCompound)) + { + notifyAdmins(par1ICommandSender, "commands.give.tagError", new Object[] {"Not a valid tag"}); + return; + } + + itemstack.setTagCompound((NBTTagCompound)nbtbase); + } + catch (NBTException nbtexception) + { + notifyAdmins(par1ICommandSender, "commands.give.tagError", new Object[] {nbtexception.getMessage()}); + return; + } + } + + EntityItem entityitem = entityplayermp.dropPlayerItemWithRandomChoice(itemstack, false); + entityitem.delayBeforeCanPickup = 0; + entityitem.func_145797_a(entityplayermp.getCommandSenderName()); + notifyAdmins(par1ICommandSender, "commands.give.success", new Object[] {itemstack.func_151000_E(), Integer.valueOf(i), entityplayermp.getCommandSenderName()}); + } + } + + public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + return par2ArrayOfStr.length == 1 ? getListOfStringsMatchingLastWord(par2ArrayOfStr, this.getPlayers()) : (par2ArrayOfStr.length == 2 ? getListOfStringsFromIterableMatchingLastWord(par2ArrayOfStr, Item.itemRegistry.getKeys()) : null); + } + + protected String[] getPlayers() + { + return MinecraftServer.getServer().getAllUsernames(); + } + + public boolean isUsernameIndex(String[] par1ArrayOfStr, int par2) + { + return par2 == 0; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/CommandHandler.java b/src/main/java/net/minecraft/command/CommandHandler.java new file mode 100644 index 0000000..b47cd0c --- /dev/null +++ b/src/main/java/net/minecraft/command/CommandHandler.java @@ -0,0 +1,243 @@ +package net.minecraft.command; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Map.Entry; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.EnumChatFormatting; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.CommandEvent; + +public class CommandHandler implements ICommandManager +{ + private static final Logger logger = LogManager.getLogger(); + private final Map commandMap = new HashMap(); + private final Set commandSet = new HashSet(); + private static final String __OBFID = "CL_00001765"; + + public int executeCommand(ICommandSender par1ICommandSender, String par2Str) + { + par2Str = par2Str.trim(); + + if (par2Str.startsWith("/")) + { + par2Str = par2Str.substring(1); + } + + String[] astring = par2Str.split(" "); + String s1 = astring[0]; + astring = dropFirstString(astring); + ICommand icommand = (ICommand)this.commandMap.get(s1); + int i = this.getUsernameIndex(icommand, astring); + int j = 0; + ChatComponentTranslation chatcomponenttranslation; + + try + { + if (icommand == null) + { + throw new CommandNotFoundException(); + } + + if (icommand.canCommandSenderUseCommand(par1ICommandSender)) + { + CommandEvent event = new CommandEvent(icommand, par1ICommandSender, astring); + if (MinecraftForge.EVENT_BUS.post(event)) + { + if (event.exception != null) + { + throw event.exception; + } + return 1; + } + + if (i > -1) + { + EntityPlayerMP[] aentityplayermp = PlayerSelector.matchPlayers(par1ICommandSender, astring[i]); + String s2 = astring[i]; + EntityPlayerMP[] aentityplayermp1 = aentityplayermp; + int k = aentityplayermp.length; + + for (int l = 0; l < k; ++l) + { + EntityPlayerMP entityplayermp = aentityplayermp1[l]; + astring[i] = entityplayermp.getCommandSenderName(); + + try + { + icommand.processCommand(par1ICommandSender, astring); + ++j; + } + catch (CommandException commandexception) + { + ChatComponentTranslation chatcomponenttranslation1 = new ChatComponentTranslation(commandexception.getMessage(), commandexception.getErrorOjbects()); + chatcomponenttranslation1.getChatStyle().setColor(EnumChatFormatting.RED); + par1ICommandSender.addChatMessage(chatcomponenttranslation1); + } + } + + astring[i] = s2; + } + else + { + icommand.processCommand(par1ICommandSender, astring); + ++j; + } + } + else + { + ChatComponentTranslation chatcomponenttranslation2 = new ChatComponentTranslation("commands.generic.permission", new Object[0]); + chatcomponenttranslation2.getChatStyle().setColor(EnumChatFormatting.RED); + par1ICommandSender.addChatMessage(chatcomponenttranslation2); + } + } + catch (WrongUsageException wrongusageexception) + { + chatcomponenttranslation = new ChatComponentTranslation("commands.generic.usage", new Object[] {new ChatComponentTranslation(wrongusageexception.getMessage(), wrongusageexception.getErrorOjbects())}); + chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.RED); + par1ICommandSender.addChatMessage(chatcomponenttranslation); + } + catch (CommandException commandexception1) + { + chatcomponenttranslation = new ChatComponentTranslation(commandexception1.getMessage(), commandexception1.getErrorOjbects()); + chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.RED); + par1ICommandSender.addChatMessage(chatcomponenttranslation); + } + catch (Throwable throwable) + { + chatcomponenttranslation = new ChatComponentTranslation("commands.generic.exception", new Object[0]); + chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.RED); + par1ICommandSender.addChatMessage(chatcomponenttranslation); + logger.error("Couldn\'t process command", throwable); + } + + return j; + } + + public ICommand registerCommand(ICommand par1ICommand) + { + List list = par1ICommand.getCommandAliases(); + this.commandMap.put(par1ICommand.getCommandName(), par1ICommand); + this.commandSet.add(par1ICommand); + + if (list != null) + { + Iterator iterator = list.iterator(); + + while (iterator.hasNext()) + { + String s = (String)iterator.next(); + ICommand icommand1 = (ICommand)this.commandMap.get(s); + + if (icommand1 == null || !icommand1.getCommandName().equals(s)) + { + this.commandMap.put(s, par1ICommand); + } + } + } + + return par1ICommand; + } + + private static String[] dropFirstString(String[] par0ArrayOfStr) + { + String[] astring1 = new String[par0ArrayOfStr.length - 1]; + + for (int i = 1; i < par0ArrayOfStr.length; ++i) + { + astring1[i - 1] = par0ArrayOfStr[i]; + } + + return astring1; + } + + public List getPossibleCommands(ICommandSender par1ICommandSender, String par2Str) + { + String[] astring = par2Str.split(" ", -1); + String s1 = astring[0]; + + if (astring.length == 1) + { + ArrayList arraylist = new ArrayList(); + Iterator iterator = this.commandMap.entrySet().iterator(); + + while (iterator.hasNext()) + { + Entry entry = (Entry)iterator.next(); + + if (CommandBase.doesStringStartWith(s1, (String)entry.getKey()) && ((ICommand)entry.getValue()).canCommandSenderUseCommand(par1ICommandSender)) + { + arraylist.add(entry.getKey()); + } + } + + return arraylist; + } + else + { + if (astring.length > 1) + { + ICommand icommand = (ICommand)this.commandMap.get(s1); + + if (icommand != null) + { + return icommand.addTabCompletionOptions(par1ICommandSender, dropFirstString(astring)); + } + } + + return null; + } + } + + public List getPossibleCommands(ICommandSender par1ICommandSender) + { + ArrayList arraylist = new ArrayList(); + Iterator iterator = this.commandSet.iterator(); + + while (iterator.hasNext()) + { + ICommand icommand = (ICommand)iterator.next(); + + if (icommand.canCommandSenderUseCommand(par1ICommandSender)) + { + arraylist.add(icommand); + } + } + + return arraylist; + } + + public Map getCommands() + { + return this.commandMap; + } + + private int getUsernameIndex(ICommand par1ICommand, String[] par2ArrayOfStr) + { + if (par1ICommand == null) + { + return -1; + } + else + { + for (int i = 0; i < par2ArrayOfStr.length; ++i) + { + if (par1ICommand.isUsernameIndex(par2ArrayOfStr, i) && PlayerSelector.matchesMultiplePlayers(par2ArrayOfStr[i])) + { + return i; + } + } + + return -1; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/CommandHelp.java b/src/main/java/net/minecraft/command/CommandHelp.java new file mode 100644 index 0000000..77060a3 --- /dev/null +++ b/src/main/java/net/minecraft/command/CommandHelp.java @@ -0,0 +1,100 @@ +package net.minecraft.command; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.event.ClickEvent; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.MathHelper; + +public class CommandHelp extends CommandBase +{ + private static final String __OBFID = "CL_00000529"; + + public String getCommandName() + { + return "help"; + } + + public int getRequiredPermissionLevel() + { + return 0; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.help.usage"; + } + + public List getCommandAliases() + { + return Arrays.asList(new String[] {"?"}); + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + List list = this.getSortedPossibleCommands(par1ICommandSender); + byte b0 = 7; + int i = (list.size() - 1) / b0; + boolean flag = false; + int k; + + try + { + k = par2ArrayOfStr.length == 0 ? 0 : parseIntBounded(par1ICommandSender, par2ArrayOfStr[0], 1, i + 1) - 1; + } + catch (NumberInvalidException numberinvalidexception) + { + Map map = this.getCommands(); + ICommand icommand = (ICommand)map.get(par2ArrayOfStr[0]); + + if (icommand != null) + { + throw new WrongUsageException(icommand.getCommandUsage(par1ICommandSender), new Object[0]); + } + + if (MathHelper.parseIntWithDefault(par2ArrayOfStr[0], -1) != -1) + { + throw numberinvalidexception; + } + + throw new CommandNotFoundException(); + } + + int j = Math.min((k + 1) * b0, list.size()); + ChatComponentTranslation chatcomponenttranslation1 = new ChatComponentTranslation("commands.help.header", new Object[] {Integer.valueOf(k + 1), Integer.valueOf(i + 1)}); + chatcomponenttranslation1.getChatStyle().setColor(EnumChatFormatting.DARK_GREEN); + par1ICommandSender.addChatMessage(chatcomponenttranslation1); + + for (int l = k * b0; l < j; ++l) + { + ICommand icommand1 = (ICommand)list.get(l); + ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation(icommand1.getCommandUsage(par1ICommandSender), new Object[0]); + chatcomponenttranslation.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/" + icommand1.getCommandName() + " ")); + par1ICommandSender.addChatMessage(chatcomponenttranslation); + } + + if (k == 0 && par1ICommandSender instanceof EntityPlayer) + { + ChatComponentTranslation chatcomponenttranslation2 = new ChatComponentTranslation("commands.help.footer", new Object[0]); + chatcomponenttranslation2.getChatStyle().setColor(EnumChatFormatting.GREEN); + par1ICommandSender.addChatMessage(chatcomponenttranslation2); + } + } + + protected List getSortedPossibleCommands(ICommandSender par1ICommandSender) + { + List list = MinecraftServer.getServer().getCommandManager().getPossibleCommands(par1ICommandSender); + Collections.sort(list); + return list; + } + + protected Map getCommands() + { + return MinecraftServer.getServer().getCommandManager().getCommands(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/CommandKill.java b/src/main/java/net/minecraft/command/CommandKill.java new file mode 100644 index 0000000..c71371c --- /dev/null +++ b/src/main/java/net/minecraft/command/CommandKill.java @@ -0,0 +1,32 @@ +package net.minecraft.command; + +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.DamageSource; + +public class CommandKill extends CommandBase +{ + private static final String __OBFID = "CL_00000570"; + + public String getCommandName() + { + return "kill"; + } + + public int getRequiredPermissionLevel() + { + return 0; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.kill.usage"; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + EntityPlayerMP entityplayermp = getCommandSenderAsPlayer(par1ICommandSender); + entityplayermp.attackEntityFrom(DamageSource.outOfWorld, Float.MAX_VALUE); + par1ICommandSender.addChatMessage(new ChatComponentTranslation("commands.kill.success", new Object[0])); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/CommandNotFoundException.java b/src/main/java/net/minecraft/command/CommandNotFoundException.java new file mode 100644 index 0000000..2c09267 --- /dev/null +++ b/src/main/java/net/minecraft/command/CommandNotFoundException.java @@ -0,0 +1,16 @@ +package net.minecraft.command; + +public class CommandNotFoundException extends CommandException +{ + private static final String __OBFID = "CL_00001191"; + + public CommandNotFoundException() + { + this("commands.generic.notFound", new Object[0]); + } + + public CommandNotFoundException(String par1Str, Object ... par2ArrayOfObj) + { + super(par1Str, par2ArrayOfObj); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/CommandPlaySound.java b/src/main/java/net/minecraft/command/CommandPlaySound.java new file mode 100644 index 0000000..3f1f308 --- /dev/null +++ b/src/main/java/net/minecraft/command/CommandPlaySound.java @@ -0,0 +1,114 @@ +package net.minecraft.command; + +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.network.play.server.S29PacketSoundEffect; + +public class CommandPlaySound extends CommandBase +{ + private static final String __OBFID = "CL_00000774"; + + public String getCommandName() + { + return "playsound"; + } + + public int getRequiredPermissionLevel() + { + return 2; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.playsound.usage"; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + if (par2ArrayOfStr.length < 2) + { + throw new WrongUsageException(this.getCommandUsage(par1ICommandSender), new Object[0]); + } + else + { + byte b0 = 0; + int i = b0 + 1; + String s = par2ArrayOfStr[b0]; + EntityPlayerMP entityplayermp = getPlayer(par1ICommandSender, par2ArrayOfStr[i++]); + double d0 = (double)entityplayermp.getPlayerCoordinates().posX; + double d1 = (double)entityplayermp.getPlayerCoordinates().posY; + double d2 = (double)entityplayermp.getPlayerCoordinates().posZ; + double d3 = 1.0D; + double d4 = 1.0D; + double d5 = 0.0D; + + if (par2ArrayOfStr.length > i) + { + d0 = func_110666_a(par1ICommandSender, d0, par2ArrayOfStr[i++]); + } + + if (par2ArrayOfStr.length > i) + { + d1 = func_110665_a(par1ICommandSender, d1, par2ArrayOfStr[i++], 0, 0); + } + + if (par2ArrayOfStr.length > i) + { + d2 = func_110666_a(par1ICommandSender, d2, par2ArrayOfStr[i++]); + } + + if (par2ArrayOfStr.length > i) + { + d3 = parseDoubleBounded(par1ICommandSender, par2ArrayOfStr[i++], 0.0D, 3.4028234663852886E38D); + } + + if (par2ArrayOfStr.length > i) + { + d4 = parseDoubleBounded(par1ICommandSender, par2ArrayOfStr[i++], 0.0D, 2.0D); + } + + if (par2ArrayOfStr.length > i) + { + d5 = parseDoubleBounded(par1ICommandSender, par2ArrayOfStr[i++], 0.0D, 1.0D); + } + + double d6 = d3 > 1.0D ? d3 * 16.0D : 16.0D; + double d7 = entityplayermp.getDistance(d0, d1, d2); + + if (d7 > d6) + { + if (d5 <= 0.0D) + { + throw new CommandException("commands.playsound.playerTooFar", new Object[] {entityplayermp.getCommandSenderName()}); + } + + double d8 = d0 - entityplayermp.posX; + double d9 = d1 - entityplayermp.posY; + double d10 = d2 - entityplayermp.posZ; + double d11 = Math.sqrt(d8 * d8 + d9 * d9 + d10 * d10); + double d12 = entityplayermp.posX; + double d13 = entityplayermp.posY; + double d14 = entityplayermp.posZ; + + if (d11 > 0.0D) + { + d12 += d8 / d11 * 2.0D; + d13 += d9 / d11 * 2.0D; + d14 += d10 / d11 * 2.0D; + } + + entityplayermp.playerNetServerHandler.sendPacket(new S29PacketSoundEffect(s, d12, d13, d14, (float)d5, (float)d4)); + } + else + { + entityplayermp.playerNetServerHandler.sendPacket(new S29PacketSoundEffect(s, d0, d1, d2, (float)d3, (float)d4)); + } + + notifyAdmins(par1ICommandSender, "commands.playsound.success", new Object[] {s, entityplayermp.getCommandSenderName()}); + } + } + + public boolean isUsernameIndex(String[] par1ArrayOfStr, int par2) + { + return par2 == 1; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/CommandServerKick.java b/src/main/java/net/minecraft/command/CommandServerKick.java new file mode 100644 index 0000000..f10865b --- /dev/null +++ b/src/main/java/net/minecraft/command/CommandServerKick.java @@ -0,0 +1,68 @@ +package net.minecraft.command; + +import java.util.List; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.server.MinecraftServer; + +public class CommandServerKick extends CommandBase +{ + private static final String __OBFID = "CL_00000550"; + + public String getCommandName() + { + return "kick"; + } + + public int getRequiredPermissionLevel() + { + return 3; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.kick.usage"; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + if (par2ArrayOfStr.length > 0 && par2ArrayOfStr[0].length() > 1) + { + EntityPlayerMP entityplayermp = MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername(par2ArrayOfStr[0]); + String s = "Kicked by an operator."; + boolean flag = false; + + if (entityplayermp == null) + { + throw new PlayerNotFoundException(); + } + else + { + if (par2ArrayOfStr.length >= 2) + { + s = func_147178_a(par1ICommandSender, par2ArrayOfStr, 1).getUnformattedText(); + flag = true; + } + + entityplayermp.playerNetServerHandler.kickPlayerFromServer(s); + + if (flag) + { + notifyAdmins(par1ICommandSender, "commands.kick.success.reason", new Object[] {entityplayermp.getCommandSenderName(), s}); + } + else + { + notifyAdmins(par1ICommandSender, "commands.kick.success", new Object[] {entityplayermp.getCommandSenderName()}); + } + } + } + else + { + throw new WrongUsageException("commands.kick.usage", new Object[0]); + } + } + + public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + return par2ArrayOfStr.length >= 1 ? getListOfStringsMatchingLastWord(par2ArrayOfStr, MinecraftServer.getServer().getAllUsernames()) : null; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/CommandSetPlayerTimeout.java b/src/main/java/net/minecraft/command/CommandSetPlayerTimeout.java new file mode 100644 index 0000000..5649eac --- /dev/null +++ b/src/main/java/net/minecraft/command/CommandSetPlayerTimeout.java @@ -0,0 +1,37 @@ +package net.minecraft.command; + +import net.minecraft.server.MinecraftServer; + +public class CommandSetPlayerTimeout extends CommandBase +{ + private static final String __OBFID = "CL_00000999"; + + public String getCommandName() + { + return "setidletimeout"; + } + + public int getRequiredPermissionLevel() + { + return 3; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.setidletimeout.usage"; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + if (par2ArrayOfStr.length == 1) + { + int i = parseIntWithMin(par1ICommandSender, par2ArrayOfStr[0], 0); + MinecraftServer.getServer().func_143006_e(i); + notifyAdmins(par1ICommandSender, "commands.setidletimeout.success", new Object[] {Integer.valueOf(i)}); + } + else + { + throw new WrongUsageException("commands.setidletimeout.usage", new Object[0]); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/CommandSetSpawnpoint.java b/src/main/java/net/minecraft/command/CommandSetSpawnpoint.java new file mode 100644 index 0000000..3dabf4d --- /dev/null +++ b/src/main/java/net/minecraft/command/CommandSetSpawnpoint.java @@ -0,0 +1,67 @@ +package net.minecraft.command; + +import java.util.List; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.ChunkCoordinates; + +public class CommandSetSpawnpoint extends CommandBase +{ + private static final String __OBFID = "CL_00001026"; + + public String getCommandName() + { + return "spawnpoint"; + } + + public int getRequiredPermissionLevel() + { + return 2; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.spawnpoint.usage"; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + EntityPlayerMP entityplayermp = par2ArrayOfStr.length == 0 ? getCommandSenderAsPlayer(par1ICommandSender) : getPlayer(par1ICommandSender, par2ArrayOfStr[0]); + + if (par2ArrayOfStr.length == 4) + { + if (entityplayermp.worldObj != null) + { + byte b0 = 1; + int i = 30000000; + int i1 = b0 + 1; + int j = parseIntBounded(par1ICommandSender, par2ArrayOfStr[b0], -i, i); + int k = parseIntBounded(par1ICommandSender, par2ArrayOfStr[i1++], 0, 256); + int l = parseIntBounded(par1ICommandSender, par2ArrayOfStr[i1++], -i, i); + entityplayermp.setSpawnChunk(new ChunkCoordinates(j, k, l), true); + notifyAdmins(par1ICommandSender, "commands.spawnpoint.success", new Object[] {entityplayermp.getCommandSenderName(), Integer.valueOf(j), Integer.valueOf(k), Integer.valueOf(l)}); + } + } + else + { + if (par2ArrayOfStr.length > 1) + { + throw new WrongUsageException("commands.spawnpoint.usage", new Object[0]); + } + + ChunkCoordinates chunkcoordinates = entityplayermp.getPlayerCoordinates(); + entityplayermp.setSpawnChunk(chunkcoordinates, true); + notifyAdmins(par1ICommandSender, "commands.spawnpoint.success", new Object[] {entityplayermp.getCommandSenderName(), Integer.valueOf(chunkcoordinates.posX), Integer.valueOf(chunkcoordinates.posY), Integer.valueOf(chunkcoordinates.posZ)}); + } + } + + public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + return par2ArrayOfStr.length != 1 && par2ArrayOfStr.length != 2 ? null : getListOfStringsMatchingLastWord(par2ArrayOfStr, MinecraftServer.getServer().getAllUsernames()); + } + + public boolean isUsernameIndex(String[] par1ArrayOfStr, int par2) + { + return par2 == 0; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/CommandShowSeed.java b/src/main/java/net/minecraft/command/CommandShowSeed.java new file mode 100644 index 0000000..4bf9ca5 --- /dev/null +++ b/src/main/java/net/minecraft/command/CommandShowSeed.java @@ -0,0 +1,37 @@ +package net.minecraft.command; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.world.World; + +public class CommandShowSeed extends CommandBase +{ + private static final String __OBFID = "CL_00001053"; + + public boolean canCommandSenderUseCommand(ICommandSender par1ICommandSender) + { + return MinecraftServer.getServer().isSinglePlayer() || super.canCommandSenderUseCommand(par1ICommandSender); + } + + public String getCommandName() + { + return "seed"; + } + + public int getRequiredPermissionLevel() + { + return 2; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.seed.usage"; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + Object object = par1ICommandSender instanceof EntityPlayer ? ((EntityPlayer)par1ICommandSender).worldObj : MinecraftServer.getServer().worldServerForDimension(0); + par1ICommandSender.addChatMessage(new ChatComponentTranslation("commands.seed.success", new Object[] {Long.valueOf(((World)object).getSeed())})); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/CommandSpreadPlayers.java b/src/main/java/net/minecraft/command/CommandSpreadPlayers.java new file mode 100644 index 0000000..b727b71 --- /dev/null +++ b/src/main/java/net/minecraft/command/CommandSpreadPlayers.java @@ -0,0 +1,397 @@ +package net.minecraft.command; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.scoreboard.Team; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class CommandSpreadPlayers extends CommandBase +{ + private static final String __OBFID = "CL_00001080"; + + public String getCommandName() + { + return "spreadplayers"; + } + + public int getRequiredPermissionLevel() + { + return 2; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.spreadplayers.usage"; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + if (par2ArrayOfStr.length < 6) + { + throw new WrongUsageException("commands.spreadplayers.usage", new Object[0]); + } + else + { + byte b0 = 0; + int i = b0 + 1; + double d0 = func_110666_a(par1ICommandSender, Double.NaN, par2ArrayOfStr[b0]); + double d1 = func_110666_a(par1ICommandSender, Double.NaN, par2ArrayOfStr[i++]); + double d2 = parseDoubleWithMin(par1ICommandSender, par2ArrayOfStr[i++], 0.0D); + double d3 = parseDoubleWithMin(par1ICommandSender, par2ArrayOfStr[i++], d2 + 1.0D); + boolean flag = parseBoolean(par1ICommandSender, par2ArrayOfStr[i++]); + ArrayList arraylist = Lists.newArrayList(); + + while (true) + { + while (i < par2ArrayOfStr.length) + { + String s = par2ArrayOfStr[i++]; + + if (PlayerSelector.hasArguments(s)) + { + EntityPlayerMP[] aentityplayermp = PlayerSelector.matchPlayers(par1ICommandSender, s); + + if (aentityplayermp == null || aentityplayermp.length == 0) + { + throw new PlayerNotFoundException(); + } + + Collections.addAll(arraylist, aentityplayermp); + } + else + { + EntityPlayerMP entityplayermp = MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername(s); + + if (entityplayermp == null) + { + throw new PlayerNotFoundException(); + } + + arraylist.add(entityplayermp); + } + } + + if (arraylist.isEmpty()) + { + throw new PlayerNotFoundException(); + } + + par1ICommandSender.addChatMessage(new ChatComponentTranslation("commands.spreadplayers.spreading." + (flag ? "teams" : "players"), new Object[] {Integer.valueOf(arraylist.size()), Double.valueOf(d3), Double.valueOf(d0), Double.valueOf(d1), Double.valueOf(d2)})); + this.func_110669_a(par1ICommandSender, arraylist, new CommandSpreadPlayers.Position(d0, d1), d2, d3, ((EntityLivingBase)arraylist.get(0)).worldObj, flag); + return; + } + } + } + + private void func_110669_a(ICommandSender par1ICommandSender, List par2List, CommandSpreadPlayers.Position par3CommandSpreadPlayersPosition, double par4, double par6, World par8World, boolean par9) + { + Random random = new Random(); + double d2 = par3CommandSpreadPlayersPosition.field_111101_a - par6; + double d3 = par3CommandSpreadPlayersPosition.field_111100_b - par6; + double d4 = par3CommandSpreadPlayersPosition.field_111101_a + par6; + double d5 = par3CommandSpreadPlayersPosition.field_111100_b + par6; + CommandSpreadPlayers.Position[] aposition = this.func_110670_a(random, par9 ? this.func_110667_a(par2List) : par2List.size(), d2, d3, d4, d5); + int i = this.func_110668_a(par3CommandSpreadPlayersPosition, par4, par8World, random, d2, d3, d4, d5, aposition, par9); + double d6 = this.func_110671_a(par2List, par8World, aposition, par9); + notifyAdmins(par1ICommandSender, "commands.spreadplayers.success." + (par9 ? "teams" : "players"), new Object[] {Integer.valueOf(aposition.length), Double.valueOf(par3CommandSpreadPlayersPosition.field_111101_a), Double.valueOf(par3CommandSpreadPlayersPosition.field_111100_b)}); + + if (aposition.length > 1) + { + par1ICommandSender.addChatMessage(new ChatComponentTranslation("commands.spreadplayers.info." + (par9 ? "teams" : "players"), new Object[] {String.format("%.2f", new Object[]{Double.valueOf(d6)}), Integer.valueOf(i)})); + } + } + + private int func_110667_a(List par1List) + { + HashSet hashset = Sets.newHashSet(); + Iterator iterator = par1List.iterator(); + + while (iterator.hasNext()) + { + EntityLivingBase entitylivingbase = (EntityLivingBase)iterator.next(); + + if (entitylivingbase instanceof EntityPlayer) + { + hashset.add(entitylivingbase.getTeam()); + } + else + { + hashset.add((Object)null); + } + } + + return hashset.size(); + } + + private int func_110668_a(CommandSpreadPlayers.Position par1CommandSpreadPlayersPosition, double par2, World par4World, Random par5Random, double par6, double par8, double par10, double par12, CommandSpreadPlayers.Position[] par14ArrayOfCommandSpreadPlayersPosition, boolean par15) + { + boolean flag1 = true; + double d5 = 3.4028234663852886E38D; + int i; + + for (i = 0; i < 10000 && flag1; ++i) + { + flag1 = false; + d5 = 3.4028234663852886E38D; + int k; + CommandSpreadPlayers.Position position1; + + for (int j = 0; j < par14ArrayOfCommandSpreadPlayersPosition.length; ++j) + { + CommandSpreadPlayers.Position position = par14ArrayOfCommandSpreadPlayersPosition[j]; + k = 0; + position1 = new CommandSpreadPlayers.Position(); + + for (int l = 0; l < par14ArrayOfCommandSpreadPlayersPosition.length; ++l) + { + if (j != l) + { + CommandSpreadPlayers.Position position2 = par14ArrayOfCommandSpreadPlayersPosition[l]; + double d6 = position.func_111099_a(position2); + d5 = Math.min(d6, d5); + + if (d6 < par2) + { + ++k; + position1.field_111101_a += position2.field_111101_a - position.field_111101_a; + position1.field_111100_b += position2.field_111100_b - position.field_111100_b; + } + } + } + + if (k > 0) + { + position1.field_111101_a /= (double)k; + position1.field_111100_b /= (double)k; + double d7 = (double)position1.func_111096_b(); + + if (d7 > 0.0D) + { + position1.func_111095_a(); + position.func_111094_b(position1); + } + else + { + position.func_111097_a(par5Random, par6, par8, par10, par12); + } + + flag1 = true; + } + + if (position.func_111093_a(par6, par8, par10, par12)) + { + flag1 = true; + } + } + + if (!flag1) + { + CommandSpreadPlayers.Position[] aposition = par14ArrayOfCommandSpreadPlayersPosition; + int i1 = par14ArrayOfCommandSpreadPlayersPosition.length; + + for (k = 0; k < i1; ++k) + { + position1 = aposition[k]; + + if (!position1.func_111098_b(par4World)) + { + position1.func_111097_a(par5Random, par6, par8, par10, par12); + flag1 = true; + } + } + } + } + + if (i >= 10000) + { + throw new CommandException("commands.spreadplayers.failure." + (par15 ? "teams" : "players"), new Object[] {Integer.valueOf(par14ArrayOfCommandSpreadPlayersPosition.length), Double.valueOf(par1CommandSpreadPlayersPosition.field_111101_a), Double.valueOf(par1CommandSpreadPlayersPosition.field_111100_b), String.format("%.2f", new Object[]{Double.valueOf(d5)})}); + } + else + { + return i; + } + } + + private double func_110671_a(List par1List, World par2World, CommandSpreadPlayers.Position[] par3ArrayOfCommandSpreadPlayersPosition, boolean par4) + { + double d0 = 0.0D; + int i = 0; + HashMap hashmap = Maps.newHashMap(); + + for (int j = 0; j < par1List.size(); ++j) + { + EntityLivingBase entitylivingbase = (EntityLivingBase)par1List.get(j); + CommandSpreadPlayers.Position position; + + if (par4) + { + Team team = entitylivingbase instanceof EntityPlayer ? entitylivingbase.getTeam() : null; + + if (!hashmap.containsKey(team)) + { + hashmap.put(team, par3ArrayOfCommandSpreadPlayersPosition[i++]); + } + + position = (CommandSpreadPlayers.Position)hashmap.get(team); + } + else + { + position = par3ArrayOfCommandSpreadPlayersPosition[i++]; + } + + entitylivingbase.setPositionAndUpdate((double)((float)MathHelper.floor_double(position.field_111101_a) + 0.5F), (double)position.func_111092_a(par2World), (double)MathHelper.floor_double(position.field_111100_b) + 0.5D); + double d2 = Double.MAX_VALUE; + + for (int k = 0; k < par3ArrayOfCommandSpreadPlayersPosition.length; ++k) + { + if (position != par3ArrayOfCommandSpreadPlayersPosition[k]) + { + double d1 = position.func_111099_a(par3ArrayOfCommandSpreadPlayersPosition[k]); + d2 = Math.min(d1, d2); + } + } + + d0 += d2; + } + + d0 /= (double)par1List.size(); + return d0; + } + + private CommandSpreadPlayers.Position[] func_110670_a(Random par1Random, int par2, double par3, double par5, double par7, double par9) + { + CommandSpreadPlayers.Position[] aposition = new CommandSpreadPlayers.Position[par2]; + + for (int j = 0; j < aposition.length; ++j) + { + CommandSpreadPlayers.Position position = new CommandSpreadPlayers.Position(); + position.func_111097_a(par1Random, par3, par5, par7, par9); + aposition[j] = position; + } + + return aposition; + } + + static class Position + { + double field_111101_a; + double field_111100_b; + private static final String __OBFID = "CL_00001105"; + + Position() {} + + Position(double par1, double par3) + { + this.field_111101_a = par1; + this.field_111100_b = par3; + } + + double func_111099_a(CommandSpreadPlayers.Position par1CommandSpreadPlayersPosition) + { + double d0 = this.field_111101_a - par1CommandSpreadPlayersPosition.field_111101_a; + double d1 = this.field_111100_b - par1CommandSpreadPlayersPosition.field_111100_b; + return Math.sqrt(d0 * d0 + d1 * d1); + } + + void func_111095_a() + { + double d0 = (double)this.func_111096_b(); + this.field_111101_a /= d0; + this.field_111100_b /= d0; + } + + float func_111096_b() + { + return MathHelper.sqrt_double(this.field_111101_a * this.field_111101_a + this.field_111100_b * this.field_111100_b); + } + + public void func_111094_b(CommandSpreadPlayers.Position par1CommandSpreadPlayersPosition) + { + this.field_111101_a -= par1CommandSpreadPlayersPosition.field_111101_a; + this.field_111100_b -= par1CommandSpreadPlayersPosition.field_111100_b; + } + + public boolean func_111093_a(double par1, double par3, double par5, double par7) + { + boolean flag = false; + + if (this.field_111101_a < par1) + { + this.field_111101_a = par1; + flag = true; + } + else if (this.field_111101_a > par5) + { + this.field_111101_a = par5; + flag = true; + } + + if (this.field_111100_b < par3) + { + this.field_111100_b = par3; + flag = true; + } + else if (this.field_111100_b > par7) + { + this.field_111100_b = par7; + flag = true; + } + + return flag; + } + + public int func_111092_a(World par1World) + { + int i = MathHelper.floor_double(this.field_111101_a); + int j = MathHelper.floor_double(this.field_111100_b); + + for (int k = 256; k > 0; --k) + { + if (par1World.getBlock(i, k, j).getMaterial() != Material.air) + { + return k + 1; + } + } + + return 257; + } + + public boolean func_111098_b(World par1World) + { + int i = MathHelper.floor_double(this.field_111101_a); + int j = MathHelper.floor_double(this.field_111100_b); + short short1 = 256; + + if (short1 <= 0) + { + return false; + } + else + { + Material material = par1World.getBlock(i, short1, j).getMaterial(); + return !material.isLiquid() && material != Material.fire; + } + } + + public void func_111097_a(Random par1Random, double par2, double par4, double par6, double par8) + { + this.field_111101_a = MathHelper.getRandomDoubleInRange(par1Random, par2, par6); + this.field_111100_b = MathHelper.getRandomDoubleInRange(par1Random, par4, par8); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/CommandTime.java b/src/main/java/net/minecraft/command/CommandTime.java new file mode 100644 index 0000000..4c2694f --- /dev/null +++ b/src/main/java/net/minecraft/command/CommandTime.java @@ -0,0 +1,85 @@ +package net.minecraft.command; + +import java.util.List; +import net.minecraft.server.MinecraftServer; +import net.minecraft.world.WorldServer; + +public class CommandTime extends CommandBase +{ + private static final String __OBFID = "CL_00001183"; + + public String getCommandName() + { + return "time"; + } + + public int getRequiredPermissionLevel() + { + return 2; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.time.usage"; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + if (par2ArrayOfStr.length > 1) + { + int i; + + if (par2ArrayOfStr[0].equals("set")) + { + if (par2ArrayOfStr[1].equals("day")) + { + i = 1000; + } + else if (par2ArrayOfStr[1].equals("night")) + { + i = 13000; + } + else + { + i = parseIntWithMin(par1ICommandSender, par2ArrayOfStr[1], 0); + } + + this.setTime(par1ICommandSender, i); + notifyAdmins(par1ICommandSender, "commands.time.set", new Object[] {Integer.valueOf(i)}); + return; + } + + if (par2ArrayOfStr[0].equals("add")) + { + i = parseIntWithMin(par1ICommandSender, par2ArrayOfStr[1], 0); + this.addTime(par1ICommandSender, i); + notifyAdmins(par1ICommandSender, "commands.time.added", new Object[] {Integer.valueOf(i)}); + return; + } + } + + throw new WrongUsageException("commands.time.usage", new Object[0]); + } + + public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + return par2ArrayOfStr.length == 1 ? getListOfStringsMatchingLastWord(par2ArrayOfStr, new String[] {"set", "add"}): (par2ArrayOfStr.length == 2 && par2ArrayOfStr[0].equals("set") ? getListOfStringsMatchingLastWord(par2ArrayOfStr, new String[] {"day", "night"}): null); + } + + protected void setTime(ICommandSender par1ICommandSender, int par2) + { + for (int j = 0; j < MinecraftServer.getServer().worldServers.length; ++j) + { + MinecraftServer.getServer().worldServers[j].setWorldTime((long)par2); + } + } + + protected void addTime(ICommandSender par1ICommandSender, int par2) + { + for (int j = 0; j < MinecraftServer.getServer().worldServers.length; ++j) + { + WorldServer worldserver = MinecraftServer.getServer().worldServers[j]; + worldserver.setWorldTime(worldserver.getWorldTime() + (long)par2); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/CommandToggleDownfall.java b/src/main/java/net/minecraft/command/CommandToggleDownfall.java new file mode 100644 index 0000000..7a215bc --- /dev/null +++ b/src/main/java/net/minecraft/command/CommandToggleDownfall.java @@ -0,0 +1,36 @@ +package net.minecraft.command; + +import net.minecraft.server.MinecraftServer; +import net.minecraft.world.storage.WorldInfo; + +public class CommandToggleDownfall extends CommandBase +{ + private static final String __OBFID = "CL_00001184"; + + public String getCommandName() + { + return "toggledownfall"; + } + + public int getRequiredPermissionLevel() + { + return 2; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.downfall.usage"; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + this.toggleDownfall(); + notifyAdmins(par1ICommandSender, "commands.downfall.success", new Object[0]); + } + + protected void toggleDownfall() + { + WorldInfo worldinfo = MinecraftServer.getServer().worldServers[0].getWorldInfo(); + worldinfo.setRaining(!worldinfo.isRaining()); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/CommandWeather.java b/src/main/java/net/minecraft/command/CommandWeather.java new file mode 100644 index 0000000..b916373 --- /dev/null +++ b/src/main/java/net/minecraft/command/CommandWeather.java @@ -0,0 +1,81 @@ +package net.minecraft.command; + +import java.util.List; +import java.util.Random; +import net.minecraft.server.MinecraftServer; +import net.minecraft.world.WorldServer; +import net.minecraft.world.storage.WorldInfo; + +public class CommandWeather extends CommandBase +{ + private static final String __OBFID = "CL_00001185"; + + public String getCommandName() + { + return "weather"; + } + + public int getRequiredPermissionLevel() + { + return 2; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.weather.usage"; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + if (par2ArrayOfStr.length >= 1 && par2ArrayOfStr.length <= 2) + { + int i = (300 + (new Random()).nextInt(600)) * 20; + + if (par2ArrayOfStr.length >= 2) + { + i = parseIntBounded(par1ICommandSender, par2ArrayOfStr[1], 1, 1000000) * 20; + } + + WorldServer worldserver = MinecraftServer.getServer().worldServers[0]; + WorldInfo worldinfo = worldserver.getWorldInfo(); + + if ("clear".equalsIgnoreCase(par2ArrayOfStr[0])) + { + worldinfo.setRainTime(0); + worldinfo.setThunderTime(0); + worldinfo.setRaining(false); + worldinfo.setThundering(false); + notifyAdmins(par1ICommandSender, "commands.weather.clear", new Object[0]); + } + else if ("rain".equalsIgnoreCase(par2ArrayOfStr[0])) + { + worldinfo.setRainTime(i); + worldinfo.setRaining(true); + worldinfo.setThundering(false); + notifyAdmins(par1ICommandSender, "commands.weather.rain", new Object[0]); + } + else + { + if (!"thunder".equalsIgnoreCase(par2ArrayOfStr[0])) + { + throw new WrongUsageException("commands.weather.usage", new Object[0]); + } + + worldinfo.setRainTime(i); + worldinfo.setThunderTime(i); + worldinfo.setRaining(true); + worldinfo.setThundering(true); + notifyAdmins(par1ICommandSender, "commands.weather.thunder", new Object[0]); + } + } + else + { + throw new WrongUsageException("commands.weather.usage", new Object[0]); + } + } + + public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + return par2ArrayOfStr.length == 1 ? getListOfStringsMatchingLastWord(par2ArrayOfStr, new String[] {"clear", "rain", "thunder"}): null; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/CommandXP.java b/src/main/java/net/minecraft/command/CommandXP.java new file mode 100644 index 0000000..d3687e8 --- /dev/null +++ b/src/main/java/net/minecraft/command/CommandXP.java @@ -0,0 +1,101 @@ +package net.minecraft.command; + +import java.util.List; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.server.MinecraftServer; + +public class CommandXP extends CommandBase +{ + private static final String __OBFID = "CL_00000398"; + + public String getCommandName() + { + return "xp"; + } + + public int getRequiredPermissionLevel() + { + return 2; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.xp.usage"; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + if (par2ArrayOfStr.length <= 0) + { + throw new WrongUsageException("commands.xp.usage", new Object[0]); + } + else + { + String s = par2ArrayOfStr[0]; + boolean flag = s.endsWith("l") || s.endsWith("L"); + + if (flag && s.length() > 1) + { + s = s.substring(0, s.length() - 1); + } + + int i = parseInt(par1ICommandSender, s); + boolean flag1 = i < 0; + + if (flag1) + { + i *= -1; + } + + EntityPlayerMP entityplayermp; + + if (par2ArrayOfStr.length > 1) + { + entityplayermp = getPlayer(par1ICommandSender, par2ArrayOfStr[1]); + } + else + { + entityplayermp = getCommandSenderAsPlayer(par1ICommandSender); + } + + if (flag) + { + if (flag1) + { + entityplayermp.addExperienceLevel(-i); + notifyAdmins(par1ICommandSender, "commands.xp.success.negative.levels", new Object[] {Integer.valueOf(i), entityplayermp.getCommandSenderName()}); + } + else + { + entityplayermp.addExperienceLevel(i); + notifyAdmins(par1ICommandSender, "commands.xp.success.levels", new Object[] {Integer.valueOf(i), entityplayermp.getCommandSenderName()}); + } + } + else + { + if (flag1) + { + throw new WrongUsageException("commands.xp.failure.widthdrawXp", new Object[0]); + } + + entityplayermp.addExperience(i); + notifyAdmins(par1ICommandSender, "commands.xp.success", new Object[] {Integer.valueOf(i), entityplayermp.getCommandSenderName()}); + } + } + } + + public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + return par2ArrayOfStr.length == 2 ? getListOfStringsMatchingLastWord(par2ArrayOfStr, this.getAllUsernames()) : null; + } + + protected String[] getAllUsernames() + { + return MinecraftServer.getServer().getAllUsernames(); + } + + public boolean isUsernameIndex(String[] par1ArrayOfStr, int par2) + { + return par2 == 1; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/IAdminCommand.java b/src/main/java/net/minecraft/command/IAdminCommand.java new file mode 100644 index 0000000..91461a7 --- /dev/null +++ b/src/main/java/net/minecraft/command/IAdminCommand.java @@ -0,0 +1,6 @@ +package net.minecraft.command; + +public interface IAdminCommand +{ + void notifyAdmins(ICommandSender var1, int var2, String var3, Object ... var4); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/ICommand.java b/src/main/java/net/minecraft/command/ICommand.java new file mode 100644 index 0000000..3af6359 --- /dev/null +++ b/src/main/java/net/minecraft/command/ICommand.java @@ -0,0 +1,20 @@ +package net.minecraft.command; + +import java.util.List; + +public interface ICommand extends Comparable +{ + String getCommandName(); + + String getCommandUsage(ICommandSender var1); + + List getCommandAliases(); + + void processCommand(ICommandSender var1, String[] var2); + + boolean canCommandSenderUseCommand(ICommandSender var1); + + List addTabCompletionOptions(ICommandSender var1, String[] var2); + + boolean isUsernameIndex(String[] var1, int var2); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/ICommandManager.java b/src/main/java/net/minecraft/command/ICommandManager.java new file mode 100644 index 0000000..bae807d --- /dev/null +++ b/src/main/java/net/minecraft/command/ICommandManager.java @@ -0,0 +1,15 @@ +package net.minecraft.command; + +import java.util.List; +import java.util.Map; + +public interface ICommandManager +{ + int executeCommand(ICommandSender var1, String var2); + + List getPossibleCommands(ICommandSender var1, String var2); + + List getPossibleCommands(ICommandSender var1); + + Map getCommands(); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/ICommandSender.java b/src/main/java/net/minecraft/command/ICommandSender.java new file mode 100644 index 0000000..75f2939 --- /dev/null +++ b/src/main/java/net/minecraft/command/ICommandSender.java @@ -0,0 +1,20 @@ +package net.minecraft.command; + +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.IChatComponent; +import net.minecraft.world.World; + +public interface ICommandSender +{ + String getCommandSenderName(); + + IChatComponent func_145748_c_(); + + void addChatMessage(IChatComponent var1); + + boolean canCommandSenderUseCommand(int var1, String var2); + + ChunkCoordinates getPlayerCoordinates(); + + World getEntityWorld(); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/IEntitySelector.java b/src/main/java/net/minecraft/command/IEntitySelector.java new file mode 100644 index 0000000..7da5a70 --- /dev/null +++ b/src/main/java/net/minecraft/command/IEntitySelector.java @@ -0,0 +1,58 @@ +package net.minecraft.command; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; + +public interface IEntitySelector +{ + IEntitySelector selectAnything = new IEntitySelector() + { + private static final String __OBFID = "CL_00001541"; + public boolean isEntityApplicable(Entity par1Entity) + { + return par1Entity.isEntityAlive(); + } + }; + IEntitySelector selectInventories = new IEntitySelector() + { + private static final String __OBFID = "CL_00001542"; + public boolean isEntityApplicable(Entity par1Entity) + { + return par1Entity instanceof IInventory && par1Entity.isEntityAlive(); + } + }; + + boolean isEntityApplicable(Entity var1); + + public static class ArmoredMob implements IEntitySelector + { + private final ItemStack field_96567_c; + private static final String __OBFID = "CL_00001543"; + + public ArmoredMob(ItemStack par1ItemStack) + { + this.field_96567_c = par1ItemStack; + } + + public boolean isEntityApplicable(Entity par1Entity) + { + if (!par1Entity.isEntityAlive()) + { + return false; + } + else if (!(par1Entity instanceof EntityLivingBase)) + { + return false; + } + else + { + EntityLivingBase entitylivingbase = (EntityLivingBase)par1Entity; + return entitylivingbase.getEquipmentInSlot(EntityLiving.getArmorPosition(this.field_96567_c)) != null ? false : (entitylivingbase instanceof EntityLiving ? ((EntityLiving)entitylivingbase).canPickUpLoot() : entitylivingbase instanceof EntityPlayer); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/NumberInvalidException.java b/src/main/java/net/minecraft/command/NumberInvalidException.java new file mode 100644 index 0000000..bb5cdb5 --- /dev/null +++ b/src/main/java/net/minecraft/command/NumberInvalidException.java @@ -0,0 +1,16 @@ +package net.minecraft.command; + +public class NumberInvalidException extends CommandException +{ + private static final String __OBFID = "CL_00001188"; + + public NumberInvalidException() + { + this("commands.generic.num.invalid", new Object[0]); + } + + public NumberInvalidException(String par1Str, Object ... par2ArrayOfObj) + { + super(par1Str, par2ArrayOfObj); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/PlayerNotFoundException.java b/src/main/java/net/minecraft/command/PlayerNotFoundException.java new file mode 100644 index 0000000..a3331e7 --- /dev/null +++ b/src/main/java/net/minecraft/command/PlayerNotFoundException.java @@ -0,0 +1,16 @@ +package net.minecraft.command; + +public class PlayerNotFoundException extends CommandException +{ + private static final String __OBFID = "CL_00001190"; + + public PlayerNotFoundException() + { + this("commands.generic.player.notFound", new Object[0]); + } + + public PlayerNotFoundException(String par1Str, Object ... par2ArrayOfObj) + { + super(par1Str, par2ArrayOfObj); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/PlayerSelector.java b/src/main/java/net/minecraft/command/PlayerSelector.java new file mode 100644 index 0000000..54c63fd --- /dev/null +++ b/src/main/java/net/minecraft/command/PlayerSelector.java @@ -0,0 +1,300 @@ +package net.minecraft.command; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.IChatComponent; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraft.world.WorldSettings; + +public class PlayerSelector +{ + private static final Pattern tokenPattern = Pattern.compile("^@([parf])(?:\\[([\\w=,!-]*)\\])?$"); + private static final Pattern intListPattern = Pattern.compile("\\G([-!]?[\\w-]*)(?:$|,)"); + private static final Pattern keyValueListPattern = Pattern.compile("\\G(\\w+)=([-!]?[\\w-]*)(?:$|,)"); + private static final String __OBFID = "CL_00000086"; + + public static EntityPlayerMP matchOnePlayer(ICommandSender par0ICommandSender, String par1Str) + { + EntityPlayerMP[] aentityplayermp = matchPlayers(par0ICommandSender, par1Str); + return aentityplayermp != null && aentityplayermp.length == 1 ? aentityplayermp[0] : null; + } + + public static IChatComponent func_150869_b(ICommandSender p_150869_0_, String p_150869_1_) + { + EntityPlayerMP[] aentityplayermp = matchPlayers(p_150869_0_, p_150869_1_); + + if (aentityplayermp != null && aentityplayermp.length != 0) + { + IChatComponent[] aichatcomponent = new IChatComponent[aentityplayermp.length]; + + for (int i = 0; i < aichatcomponent.length; ++i) + { + aichatcomponent[i] = aentityplayermp[i].func_145748_c_(); + } + + return CommandBase.joinNiceString(aichatcomponent); + } + else + { + return null; + } + } + + public static EntityPlayerMP[] matchPlayers(ICommandSender par0ICommandSender, String par1Str) + { + Matcher matcher = tokenPattern.matcher(par1Str); + + if (!matcher.matches()) + { + return null; + } + else + { + Map map = getArgumentMap(matcher.group(2)); + String s1 = matcher.group(1); + int i = getDefaultMinimumRange(s1); + int j = getDefaultMaximumRange(s1); + int k = getDefaultMinimumLevel(s1); + int l = getDefaultMaximumLevel(s1); + int i1 = getDefaultCount(s1); + int j1 = WorldSettings.GameType.NOT_SET.getID(); + ChunkCoordinates chunkcoordinates = par0ICommandSender.getPlayerCoordinates(); + Map map1 = func_96560_a(map); + String s2 = null; + String s3 = null; + boolean flag = false; + + if (map.containsKey("rm")) + { + i = MathHelper.parseIntWithDefault((String)map.get("rm"), i); + flag = true; + } + + if (map.containsKey("r")) + { + j = MathHelper.parseIntWithDefault((String)map.get("r"), j); + flag = true; + } + + if (map.containsKey("lm")) + { + k = MathHelper.parseIntWithDefault((String)map.get("lm"), k); + } + + if (map.containsKey("l")) + { + l = MathHelper.parseIntWithDefault((String)map.get("l"), l); + } + + if (map.containsKey("x")) + { + chunkcoordinates.posX = MathHelper.parseIntWithDefault((String)map.get("x"), chunkcoordinates.posX); + flag = true; + } + + if (map.containsKey("y")) + { + chunkcoordinates.posY = MathHelper.parseIntWithDefault((String)map.get("y"), chunkcoordinates.posY); + flag = true; + } + + if (map.containsKey("z")) + { + chunkcoordinates.posZ = MathHelper.parseIntWithDefault((String)map.get("z"), chunkcoordinates.posZ); + flag = true; + } + + if (map.containsKey("m")) + { + j1 = MathHelper.parseIntWithDefault((String)map.get("m"), j1); + } + + if (map.containsKey("c")) + { + i1 = MathHelper.parseIntWithDefault((String)map.get("c"), i1); + } + + if (map.containsKey("team")) + { + s3 = (String)map.get("team"); + } + + if (map.containsKey("name")) + { + s2 = (String)map.get("name"); + } + + World world = flag ? par0ICommandSender.getEntityWorld() : null; + List list; + + if (!s1.equals("p") && !s1.equals("a")) + { + if (!s1.equals("r")) + { + return null; + } + else + { + list = MinecraftServer.getServer().getConfigurationManager().findPlayers(chunkcoordinates, i, j, 0, j1, k, l, map1, s2, s3, world); + Collections.shuffle(list); + list = list.subList(0, Math.min(i1, list.size())); + return list != null && !list.isEmpty() ? (EntityPlayerMP[])list.toArray(new EntityPlayerMP[0]) : new EntityPlayerMP[0]; + } + } + else + { + list = MinecraftServer.getServer().getConfigurationManager().findPlayers(chunkcoordinates, i, j, i1, j1, k, l, map1, s2, s3, world); + return list != null && !list.isEmpty() ? (EntityPlayerMP[])list.toArray(new EntityPlayerMP[0]) : new EntityPlayerMP[0]; + } + } + } + + public static Map func_96560_a(Map par0Map) + { + HashMap hashmap = new HashMap(); + Iterator iterator = par0Map.keySet().iterator(); + + while (iterator.hasNext()) + { + String s = (String)iterator.next(); + + if (s.startsWith("score_") && s.length() > "score_".length()) + { + String s1 = s.substring("score_".length()); + hashmap.put(s1, Integer.valueOf(MathHelper.parseIntWithDefault((String)par0Map.get(s), 1))); + } + } + + return hashmap; + } + + public static boolean matchesMultiplePlayers(String par0Str) + { + Matcher matcher = tokenPattern.matcher(par0Str); + + if (matcher.matches()) + { + Map map = getArgumentMap(matcher.group(2)); + String s1 = matcher.group(1); + int i = getDefaultCount(s1); + + if (map.containsKey("c")) + { + i = MathHelper.parseIntWithDefault((String)map.get("c"), i); + } + + return i != 1; + } + else + { + return false; + } + } + + public static boolean hasTheseArguments(String par0Str, String par1Str) + { + Matcher matcher = tokenPattern.matcher(par0Str); + + if (matcher.matches()) + { + String s2 = matcher.group(1); + return par1Str == null || par1Str.equals(s2); + } + else + { + return false; + } + } + + public static boolean hasArguments(String par0Str) + { + return hasTheseArguments(par0Str, (String)null); + } + + private static final int getDefaultMinimumRange(String par0Str) + { + return 0; + } + + private static final int getDefaultMaximumRange(String par0Str) + { + return 0; + } + + private static final int getDefaultMaximumLevel(String par0Str) + { + return Integer.MAX_VALUE; + } + + private static final int getDefaultMinimumLevel(String par0Str) + { + return 0; + } + + private static final int getDefaultCount(String par0Str) + { + return par0Str.equals("a") ? 0 : 1; + } + + private static Map getArgumentMap(String par0Str) + { + HashMap hashmap = new HashMap(); + + if (par0Str == null) + { + return hashmap; + } + else + { + Matcher matcher = intListPattern.matcher(par0Str); + int i = 0; + int j; + + for (j = -1; matcher.find(); j = matcher.end()) + { + String s1 = null; + + switch (i++) + { + case 0: + s1 = "x"; + break; + case 1: + s1 = "y"; + break; + case 2: + s1 = "z"; + break; + case 3: + s1 = "r"; + } + + if (s1 != null && matcher.group(1).length() > 0) + { + hashmap.put(s1, matcher.group(1)); + } + } + + if (j < par0Str.length()) + { + matcher = keyValueListPattern.matcher(j == -1 ? par0Str : par0Str.substring(j)); + + while (matcher.find()) + { + hashmap.put(matcher.group(1), matcher.group(2)); + } + } + + return hashmap; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/ServerCommand.java b/src/main/java/net/minecraft/command/ServerCommand.java new file mode 100644 index 0000000..975cd07 --- /dev/null +++ b/src/main/java/net/minecraft/command/ServerCommand.java @@ -0,0 +1,18 @@ +package net.minecraft.command; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.SERVER) +public class ServerCommand +{ + public final String command; + public final ICommandSender sender; + private static final String __OBFID = "CL_00001779"; + + public ServerCommand(String par1Str, ICommandSender par2ICommandSender) + { + this.command = par1Str; + this.sender = par2ICommandSender; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/ServerCommandManager.java b/src/main/java/net/minecraft/command/ServerCommandManager.java new file mode 100644 index 0000000..e363828 --- /dev/null +++ b/src/main/java/net/minecraft/command/ServerCommandManager.java @@ -0,0 +1,138 @@ +package net.minecraft.command; + +import java.util.Iterator; +import net.minecraft.command.server.CommandAchievement; +import net.minecraft.command.server.CommandBanIp; +import net.minecraft.command.server.CommandBanPlayer; +import net.minecraft.command.server.CommandBlockLogic; +import net.minecraft.command.server.CommandBroadcast; +import net.minecraft.command.server.CommandDeOp; +import net.minecraft.command.server.CommandEmote; +import net.minecraft.command.server.CommandListBans; +import net.minecraft.command.server.CommandListPlayers; +import net.minecraft.command.server.CommandMessage; +import net.minecraft.command.server.CommandMessageRaw; +import net.minecraft.command.server.CommandOp; +import net.minecraft.command.server.CommandPardonIp; +import net.minecraft.command.server.CommandPardonPlayer; +import net.minecraft.command.server.CommandPublishLocalServer; +import net.minecraft.command.server.CommandSaveAll; +import net.minecraft.command.server.CommandSaveOff; +import net.minecraft.command.server.CommandSaveOn; +import net.minecraft.command.server.CommandScoreboard; +import net.minecraft.command.server.CommandSetBlock; +import net.minecraft.command.server.CommandSetDefaultSpawnpoint; +import net.minecraft.command.server.CommandStop; +import net.minecraft.command.server.CommandSummon; +import net.minecraft.command.server.CommandTeleport; +import net.minecraft.command.server.CommandTestFor; +import net.minecraft.command.server.CommandTestForBlock; +import net.minecraft.command.server.CommandWhitelist; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.EnumChatFormatting; + +public class ServerCommandManager extends CommandHandler implements IAdminCommand +{ + private static final String __OBFID = "CL_00000922"; + + public ServerCommandManager() + { + this.registerCommand(new CommandTime()); + this.registerCommand(new CommandGameMode()); + this.registerCommand(new CommandDifficulty()); + this.registerCommand(new CommandDefaultGameMode()); + this.registerCommand(new CommandKill()); + this.registerCommand(new CommandToggleDownfall()); + this.registerCommand(new CommandWeather()); + this.registerCommand(new CommandXP()); + this.registerCommand(new CommandTeleport()); + this.registerCommand(new CommandGive()); + this.registerCommand(new CommandEffect()); + this.registerCommand(new CommandEnchant()); + this.registerCommand(new CommandEmote()); + this.registerCommand(new CommandShowSeed()); + this.registerCommand(new CommandHelp()); + this.registerCommand(new CommandDebug()); + this.registerCommand(new CommandMessage()); + this.registerCommand(new CommandBroadcast()); + this.registerCommand(new CommandSetSpawnpoint()); + this.registerCommand(new CommandSetDefaultSpawnpoint()); + this.registerCommand(new CommandGameRule()); + this.registerCommand(new CommandClearInventory()); + this.registerCommand(new CommandTestFor()); + this.registerCommand(new CommandSpreadPlayers()); + this.registerCommand(new CommandPlaySound()); + this.registerCommand(new CommandScoreboard()); + this.registerCommand(new CommandAchievement()); + this.registerCommand(new CommandSummon()); + this.registerCommand(new CommandSetBlock()); + this.registerCommand(new CommandTestForBlock()); + this.registerCommand(new CommandMessageRaw()); + + if (MinecraftServer.getServer().isDedicatedServer()) + { + this.registerCommand(new CommandOp()); + this.registerCommand(new CommandDeOp()); + this.registerCommand(new CommandStop()); + this.registerCommand(new CommandSaveAll()); + this.registerCommand(new CommandSaveOff()); + this.registerCommand(new CommandSaveOn()); + this.registerCommand(new CommandBanIp()); + this.registerCommand(new CommandPardonIp()); + this.registerCommand(new CommandBanPlayer()); + this.registerCommand(new CommandListBans()); + this.registerCommand(new CommandPardonPlayer()); + this.registerCommand(new CommandServerKick()); + this.registerCommand(new CommandListPlayers()); + this.registerCommand(new CommandWhitelist()); + this.registerCommand(new CommandSetPlayerTimeout()); + } + else + { + this.registerCommand(new CommandPublishLocalServer()); + } + + CommandBase.setAdminCommander(this); + } + + public void notifyAdmins(ICommandSender par1ICommandSender, int par2, String par3Str, Object ... par4ArrayOfObj) + { + boolean flag = true; + + if (par1ICommandSender instanceof CommandBlockLogic && !MinecraftServer.getServer().worldServers[0].getGameRules().getGameRuleBooleanValue("commandBlockOutput")) + { + flag = false; + } + + ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("chat.type.admin", new Object[] {par1ICommandSender.getCommandSenderName(), new ChatComponentTranslation(par3Str, par4ArrayOfObj)}); + chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.GRAY); + chatcomponenttranslation.getChatStyle().setItalic(Boolean.valueOf(true)); + + if (flag) + { + Iterator iterator = MinecraftServer.getServer().getConfigurationManager().playerEntityList.iterator(); + + while (iterator.hasNext()) + { + EntityPlayerMP entityplayermp = (EntityPlayerMP)iterator.next(); + + if (entityplayermp != par1ICommandSender && MinecraftServer.getServer().getConfigurationManager().isPlayerOpped(entityplayermp.getCommandSenderName())) + { + entityplayermp.addChatMessage(chatcomponenttranslation); + } + } + } + + if (par1ICommandSender != MinecraftServer.getServer()) + { + MinecraftServer.getServer().addChatMessage(chatcomponenttranslation); + } + + if ((par2 & 1) != 1) + { + par1ICommandSender.addChatMessage(new ChatComponentTranslation(par3Str, par4ArrayOfObj)); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/SyntaxErrorException.java b/src/main/java/net/minecraft/command/SyntaxErrorException.java new file mode 100644 index 0000000..2b6d45a --- /dev/null +++ b/src/main/java/net/minecraft/command/SyntaxErrorException.java @@ -0,0 +1,16 @@ +package net.minecraft.command; + +public class SyntaxErrorException extends CommandException +{ + private static final String __OBFID = "CL_00001189"; + + public SyntaxErrorException() + { + this("commands.generic.snytax", new Object[0]); + } + + public SyntaxErrorException(String par1Str, Object ... par2ArrayOfObj) + { + super(par1Str, par2ArrayOfObj); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/WrongUsageException.java b/src/main/java/net/minecraft/command/WrongUsageException.java new file mode 100644 index 0000000..b91c792 --- /dev/null +++ b/src/main/java/net/minecraft/command/WrongUsageException.java @@ -0,0 +1,11 @@ +package net.minecraft.command; + +public class WrongUsageException extends SyntaxErrorException +{ + private static final String __OBFID = "CL_00001192"; + + public WrongUsageException(String par1Str, Object ... par2ArrayOfObj) + { + super(par1Str, par2ArrayOfObj); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/server/CommandAchievement.java b/src/main/java/net/minecraft/command/server/CommandAchievement.java new file mode 100644 index 0000000..1317a1e --- /dev/null +++ b/src/main/java/net/minecraft/command/server/CommandAchievement.java @@ -0,0 +1,134 @@ +package net.minecraft.command.server; + +import com.google.common.collect.Lists; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import net.minecraft.command.CommandBase; +import net.minecraft.command.CommandException; +import net.minecraft.command.ICommandSender; +import net.minecraft.command.WrongUsageException; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.server.MinecraftServer; +import net.minecraft.stats.Achievement; +import net.minecraft.stats.AchievementList; +import net.minecraft.stats.StatBase; +import net.minecraft.stats.StatList; + +public class CommandAchievement extends CommandBase +{ + private static final String __OBFID = "CL_00000113"; + + public String getCommandName() + { + return "achievement"; + } + + public int getRequiredPermissionLevel() + { + return 2; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.achievement.usage"; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + if (par2ArrayOfStr.length >= 2) + { + StatBase statbase = StatList.func_151177_a(par2ArrayOfStr[1]); + + if (statbase == null && !par2ArrayOfStr[1].equals("*")) + { + throw new CommandException("commands.achievement.unknownAchievement", new Object[] {par2ArrayOfStr[1]}); + } + + EntityPlayerMP entityplayermp; + + if (par2ArrayOfStr.length >= 3) + { + entityplayermp = getPlayer(par1ICommandSender, par2ArrayOfStr[2]); + } + else + { + entityplayermp = getCommandSenderAsPlayer(par1ICommandSender); + } + + if (par2ArrayOfStr[0].equalsIgnoreCase("give")) + { + if (statbase == null) + { + Iterator iterator = AchievementList.achievementList.iterator(); + + while (iterator.hasNext()) + { + Achievement achievement = (Achievement)iterator.next(); + entityplayermp.triggerAchievement(achievement); + } + + notifyAdmins(par1ICommandSender, "commands.achievement.give.success.all", new Object[] {entityplayermp.getCommandSenderName()}); + } + else + { + if (statbase instanceof Achievement) + { + Achievement achievement2 = (Achievement)statbase; + ArrayList arraylist; + + for (arraylist = Lists.newArrayList(); achievement2.parentAchievement != null && !entityplayermp.func_147099_x().hasAchievementUnlocked(achievement2.parentAchievement); achievement2 = achievement2.parentAchievement) + { + arraylist.add(achievement2.parentAchievement); + } + + Iterator iterator1 = Lists.reverse(arraylist).iterator(); + + while (iterator1.hasNext()) + { + Achievement achievement1 = (Achievement)iterator1.next(); + entityplayermp.triggerAchievement(achievement1); + } + } + + entityplayermp.triggerAchievement(statbase); + notifyAdmins(par1ICommandSender, "commands.achievement.give.success.one", new Object[] {entityplayermp.getCommandSenderName(), statbase.func_150955_j()}); + } + + return; + } + } + + throw new WrongUsageException("commands.achievement.usage", new Object[0]); + } + + public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + if (par2ArrayOfStr.length == 1) + { + return getListOfStringsMatchingLastWord(par2ArrayOfStr, new String[] {"give"}); + } + else if (par2ArrayOfStr.length != 2) + { + return par2ArrayOfStr.length == 3 ? getListOfStringsMatchingLastWord(par2ArrayOfStr, MinecraftServer.getServer().getAllUsernames()) : null; + } + else + { + ArrayList arraylist = Lists.newArrayList(); + Iterator iterator = StatList.allStats.iterator(); + + while (iterator.hasNext()) + { + StatBase statbase = (StatBase)iterator.next(); + arraylist.add(statbase.statId); + } + + return getListOfStringsFromIterableMatchingLastWord(par2ArrayOfStr, arraylist); + } + } + + public boolean isUsernameIndex(String[] par1ArrayOfStr, int par2) + { + return par2 == 2; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/server/CommandBanIp.java b/src/main/java/net/minecraft/command/server/CommandBanIp.java new file mode 100644 index 0000000..bde8ac4 --- /dev/null +++ b/src/main/java/net/minecraft/command/server/CommandBanIp.java @@ -0,0 +1,111 @@ +package net.minecraft.command.server; + +import java.util.Iterator; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandSender; +import net.minecraft.command.PlayerNotFoundException; +import net.minecraft.command.WrongUsageException; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.management.BanEntry; +import net.minecraft.util.IChatComponent; + +public class CommandBanIp extends CommandBase +{ + public static final Pattern field_147211_a = Pattern.compile("^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])$"); + private static final String __OBFID = "CL_00000139"; + + public String getCommandName() + { + return "ban-ip"; + } + + public int getRequiredPermissionLevel() + { + return 3; + } + + public boolean canCommandSenderUseCommand(ICommandSender par1ICommandSender) + { + return MinecraftServer.getServer().getConfigurationManager().getBannedIPs().isListActive() && super.canCommandSenderUseCommand(par1ICommandSender); + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.banip.usage"; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + if (par2ArrayOfStr.length >= 1 && par2ArrayOfStr[0].length() > 1) + { + Matcher matcher = field_147211_a.matcher(par2ArrayOfStr[0]); + IChatComponent ichatcomponent = null; + + if (par2ArrayOfStr.length >= 2) + { + ichatcomponent = func_147178_a(par1ICommandSender, par2ArrayOfStr, 1); + } + + if (matcher.matches()) + { + this.func_147210_a(par1ICommandSender, par2ArrayOfStr[0], ichatcomponent == null ? null : ichatcomponent.getUnformattedText()); + } + else + { + EntityPlayerMP entityplayermp = MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername(par2ArrayOfStr[0]); + + if (entityplayermp == null) + { + throw new PlayerNotFoundException("commands.banip.invalid", new Object[0]); + } + + this.func_147210_a(par1ICommandSender, entityplayermp.getPlayerIP(), ichatcomponent == null ? null : ichatcomponent.getUnformattedText()); + } + } + else + { + throw new WrongUsageException("commands.banip.usage", new Object[0]); + } + } + + public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + return par2ArrayOfStr.length == 1 ? getListOfStringsMatchingLastWord(par2ArrayOfStr, MinecraftServer.getServer().getAllUsernames()) : null; + } + + protected void func_147210_a(ICommandSender p_147210_1_, String p_147210_2_, String p_147210_3_) + { + BanEntry banentry = new BanEntry(p_147210_2_); + banentry.setBannedBy(p_147210_1_.getCommandSenderName()); + + if (p_147210_3_ != null) + { + banentry.setBanReason(p_147210_3_); + } + + MinecraftServer.getServer().getConfigurationManager().getBannedIPs().put(banentry); + List list = MinecraftServer.getServer().getConfigurationManager().getPlayerList(p_147210_2_); + String[] astring = new String[list.size()]; + int i = 0; + EntityPlayerMP entityplayermp; + + for (Iterator iterator = list.iterator(); iterator.hasNext(); astring[i++] = entityplayermp.getCommandSenderName()) + { + entityplayermp = (EntityPlayerMP)iterator.next(); + entityplayermp.playerNetServerHandler.kickPlayerFromServer("You have been IP banned."); + } + + if (list.isEmpty()) + { + notifyAdmins(p_147210_1_, "commands.banip.success", new Object[] {p_147210_2_}); + } + else + { + notifyAdmins(p_147210_1_, "commands.banip.success.players", new Object[] {p_147210_2_, joinNiceString(astring)}); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/server/CommandBanPlayer.java b/src/main/java/net/minecraft/command/server/CommandBanPlayer.java new file mode 100644 index 0000000..f68619f --- /dev/null +++ b/src/main/java/net/minecraft/command/server/CommandBanPlayer.java @@ -0,0 +1,67 @@ +package net.minecraft.command.server; + +import java.util.List; +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandSender; +import net.minecraft.command.WrongUsageException; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.management.BanEntry; + +public class CommandBanPlayer extends CommandBase +{ + private static final String __OBFID = "CL_00000165"; + + public String getCommandName() + { + return "ban"; + } + + public int getRequiredPermissionLevel() + { + return 3; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.ban.usage"; + } + + public boolean canCommandSenderUseCommand(ICommandSender par1ICommandSender) + { + return MinecraftServer.getServer().getConfigurationManager().getBannedPlayers().isListActive() && super.canCommandSenderUseCommand(par1ICommandSender); + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + if (par2ArrayOfStr.length >= 1 && par2ArrayOfStr[0].length() > 0) + { + EntityPlayerMP entityplayermp = MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername(par2ArrayOfStr[0]); + BanEntry banentry = new BanEntry(par2ArrayOfStr[0]); + banentry.setBannedBy(par1ICommandSender.getCommandSenderName()); + + if (par2ArrayOfStr.length >= 2) + { + banentry.setBanReason(func_147178_a(par1ICommandSender, par2ArrayOfStr, 1).getUnformattedText()); + } + + MinecraftServer.getServer().getConfigurationManager().getBannedPlayers().put(banentry); + + if (entityplayermp != null) + { + entityplayermp.playerNetServerHandler.kickPlayerFromServer("You are banned from this server."); + } + + notifyAdmins(par1ICommandSender, "commands.ban.success", new Object[] {par2ArrayOfStr[0]}); + } + else + { + throw new WrongUsageException("commands.ban.usage", new Object[0]); + } + } + + public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + return par2ArrayOfStr.length >= 1 ? getListOfStringsMatchingLastWord(par2ArrayOfStr, MinecraftServer.getServer().getAllUsernames()) : null; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/server/CommandBlockLogic.java b/src/main/java/net/minecraft/command/server/CommandBlockLogic.java new file mode 100644 index 0000000..d9c6a02 --- /dev/null +++ b/src/main/java/net/minecraft/command/server/CommandBlockLogic.java @@ -0,0 +1,142 @@ +package net.minecraft.command.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; +import java.text.SimpleDateFormat; +import java.util.Date; +import net.minecraft.command.ICommandManager; +import net.minecraft.command.ICommandSender; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.IChatComponent; +import net.minecraft.world.World; + +public abstract class CommandBlockLogic implements ICommandSender +{ + private static final SimpleDateFormat field_145766_a = new SimpleDateFormat("HH:mm:ss"); + private int field_145764_b; + private boolean field_145765_c = true; + private IChatComponent field_145762_d = null; + private String field_145763_e = ""; + private String field_145761_f = "@"; + private static final String __OBFID = "CL_00000128"; + + public int func_145760_g() + { + return this.field_145764_b; + } + + public IChatComponent func_145749_h() + { + return this.field_145762_d; + } + + public void func_145758_a(NBTTagCompound p_145758_1_) + { + p_145758_1_.setString("Command", this.field_145763_e); + p_145758_1_.setInteger("SuccessCount", this.field_145764_b); + p_145758_1_.setString("CustomName", this.field_145761_f); + + if (this.field_145762_d != null) + { + p_145758_1_.setString("LastOutput", IChatComponent.Serializer.func_150696_a(this.field_145762_d)); + } + + p_145758_1_.setBoolean("TrackOutput", this.field_145765_c); + } + + public void func_145759_b(NBTTagCompound p_145759_1_) + { + this.field_145763_e = p_145759_1_.getString("Command"); + this.field_145764_b = p_145759_1_.getInteger("SuccessCount"); + + if (p_145759_1_.hasKey("CustomName", 8)) + { + this.field_145761_f = p_145759_1_.getString("CustomName"); + } + + if (p_145759_1_.hasKey("LastOutput", 8)) + { + this.field_145762_d = IChatComponent.Serializer.func_150699_a(p_145759_1_.getString("LastOutput")); + } + + if (p_145759_1_.hasKey("TrackOutput", 1)) + { + this.field_145765_c = p_145759_1_.getBoolean("TrackOutput"); + } + } + + public boolean canCommandSenderUseCommand(int par1, String par2Str) + { + return par1 <= 2; + } + + public void func_145752_a(String p_145752_1_) + { + this.field_145763_e = p_145752_1_; + } + + public String func_145753_i() + { + return this.field_145763_e; + } + + public void func_145755_a(World p_145755_1_) + { + if (p_145755_1_.isRemote) + { + this.field_145764_b = 0; + } + + MinecraftServer minecraftserver = MinecraftServer.getServer(); + + if (minecraftserver != null && minecraftserver.isCommandBlockEnabled()) + { + ICommandManager icommandmanager = minecraftserver.getCommandManager(); + this.field_145764_b = icommandmanager.executeCommand(this, this.field_145763_e); + } + else + { + this.field_145764_b = 0; + } + } + + public String getCommandSenderName() + { + return this.field_145761_f; + } + + public IChatComponent func_145748_c_() + { + return new ChatComponentText(this.getCommandSenderName()); + } + + public void func_145754_b(String p_145754_1_) + { + this.field_145761_f = p_145754_1_; + } + + public void addChatMessage(IChatComponent p_145747_1_) + { + if (this.field_145765_c && this.getEntityWorld() != null && !this.getEntityWorld().isRemote) + { + this.field_145762_d = (new ChatComponentText("[" + field_145766_a.format(new Date()) + "] ")).appendSibling(p_145747_1_); + this.func_145756_e(); + } + } + + public abstract void func_145756_e(); + + @SideOnly(Side.CLIENT) + public abstract int func_145751_f(); + + @SideOnly(Side.CLIENT) + public abstract void func_145757_a(ByteBuf var1); + + public void func_145750_b(IChatComponent p_145750_1_) + { + this.field_145762_d = p_145750_1_; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/server/CommandBroadcast.java b/src/main/java/net/minecraft/command/server/CommandBroadcast.java new file mode 100644 index 0000000..df4ea56 --- /dev/null +++ b/src/main/java/net/minecraft/command/server/CommandBroadcast.java @@ -0,0 +1,47 @@ +package net.minecraft.command.server; + +import java.util.List; +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandSender; +import net.minecraft.command.WrongUsageException; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.IChatComponent; + +public class CommandBroadcast extends CommandBase +{ + private static final String __OBFID = "CL_00000191"; + + public String getCommandName() + { + return "say"; + } + + public int getRequiredPermissionLevel() + { + return 1; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.say.usage"; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + if (par2ArrayOfStr.length > 0 && par2ArrayOfStr[0].length() > 0) + { + IChatComponent ichatcomponent = func_147176_a(par1ICommandSender, par2ArrayOfStr, 0, true); + MinecraftServer.getServer().getConfigurationManager().sendChatMsg(new ChatComponentTranslation("chat.type.announcement", new Object[] {par1ICommandSender.getCommandSenderName(), ichatcomponent})); + } + else + { + throw new WrongUsageException("commands.say.usage", new Object[0]); + } + } + + public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + return par2ArrayOfStr.length >= 1 ? getListOfStringsMatchingLastWord(par2ArrayOfStr, MinecraftServer.getServer().getAllUsernames()) : null; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/server/CommandDeOp.java b/src/main/java/net/minecraft/command/server/CommandDeOp.java new file mode 100644 index 0000000..3bdbef6 --- /dev/null +++ b/src/main/java/net/minecraft/command/server/CommandDeOp.java @@ -0,0 +1,45 @@ +package net.minecraft.command.server; + +import java.util.List; +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandSender; +import net.minecraft.command.WrongUsageException; +import net.minecraft.server.MinecraftServer; + +public class CommandDeOp extends CommandBase +{ + private static final String __OBFID = "CL_00000244"; + + public String getCommandName() + { + return "deop"; + } + + public int getRequiredPermissionLevel() + { + return 3; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.deop.usage"; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + if (par2ArrayOfStr.length == 1 && par2ArrayOfStr[0].length() > 0) + { + MinecraftServer.getServer().getConfigurationManager().removeOp(par2ArrayOfStr[0]); + notifyAdmins(par1ICommandSender, "commands.deop.success", new Object[] {par2ArrayOfStr[0]}); + } + else + { + throw new WrongUsageException("commands.deop.usage", new Object[0]); + } + } + + public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + return par2ArrayOfStr.length == 1 ? getListOfStringsFromIterableMatchingLastWord(par2ArrayOfStr, MinecraftServer.getServer().getConfigurationManager().getOps()) : null; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/server/CommandEmote.java b/src/main/java/net/minecraft/command/server/CommandEmote.java new file mode 100644 index 0000000..5511585 --- /dev/null +++ b/src/main/java/net/minecraft/command/server/CommandEmote.java @@ -0,0 +1,47 @@ +package net.minecraft.command.server; + +import java.util.List; +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandSender; +import net.minecraft.command.WrongUsageException; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.IChatComponent; + +public class CommandEmote extends CommandBase +{ + private static final String __OBFID = "CL_00000351"; + + public String getCommandName() + { + return "me"; + } + + public int getRequiredPermissionLevel() + { + return 0; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.me.usage"; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + if (par2ArrayOfStr.length > 0) + { + IChatComponent ichatcomponent = func_147176_a(par1ICommandSender, par2ArrayOfStr, 0, par1ICommandSender.canCommandSenderUseCommand(1, "me")); + MinecraftServer.getServer().getConfigurationManager().sendChatMsg(new ChatComponentTranslation("chat.type.emote", new Object[] {par1ICommandSender.func_145748_c_(), ichatcomponent})); + } + else + { + throw new WrongUsageException("commands.me.usage", new Object[0]); + } + } + + public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + return getListOfStringsMatchingLastWord(par2ArrayOfStr, MinecraftServer.getServer().getAllUsernames()); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/server/CommandListBans.java b/src/main/java/net/minecraft/command/server/CommandListBans.java new file mode 100644 index 0000000..8e2c049 --- /dev/null +++ b/src/main/java/net/minecraft/command/server/CommandListBans.java @@ -0,0 +1,52 @@ +package net.minecraft.command.server; + +import java.util.List; +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandSender; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.ChatComponentTranslation; + +public class CommandListBans extends CommandBase +{ + private static final String __OBFID = "CL_00000596"; + + public String getCommandName() + { + return "banlist"; + } + + public int getRequiredPermissionLevel() + { + return 3; + } + + public boolean canCommandSenderUseCommand(ICommandSender par1ICommandSender) + { + return (MinecraftServer.getServer().getConfigurationManager().getBannedIPs().isListActive() || MinecraftServer.getServer().getConfigurationManager().getBannedPlayers().isListActive()) && super.canCommandSenderUseCommand(par1ICommandSender); + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.banlist.usage"; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + if (par2ArrayOfStr.length >= 1 && par2ArrayOfStr[0].equalsIgnoreCase("ips")) + { + par1ICommandSender.addChatMessage(new ChatComponentTranslation("commands.banlist.ips", new Object[] {Integer.valueOf(MinecraftServer.getServer().getConfigurationManager().getBannedIPs().getBannedList().size())})); + par1ICommandSender.addChatMessage(new ChatComponentText(joinNiceString(MinecraftServer.getServer().getConfigurationManager().getBannedIPs().getBannedList().keySet().toArray()))); + } + else + { + par1ICommandSender.addChatMessage(new ChatComponentTranslation("commands.banlist.players", new Object[] {Integer.valueOf(MinecraftServer.getServer().getConfigurationManager().getBannedPlayers().getBannedList().size())})); + par1ICommandSender.addChatMessage(new ChatComponentText(joinNiceString(MinecraftServer.getServer().getConfigurationManager().getBannedPlayers().getBannedList().keySet().toArray()))); + } + } + + public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + return par2ArrayOfStr.length == 1 ? getListOfStringsMatchingLastWord(par2ArrayOfStr, new String[] {"players", "ips"}): null; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/server/CommandListPlayers.java b/src/main/java/net/minecraft/command/server/CommandListPlayers.java new file mode 100644 index 0000000..80b3ecc --- /dev/null +++ b/src/main/java/net/minecraft/command/server/CommandListPlayers.java @@ -0,0 +1,33 @@ +package net.minecraft.command.server; + +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandSender; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.ChatComponentTranslation; + +public class CommandListPlayers extends CommandBase +{ + private static final String __OBFID = "CL_00000615"; + + public String getCommandName() + { + return "list"; + } + + public int getRequiredPermissionLevel() + { + return 0; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.players.usage"; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + par1ICommandSender.addChatMessage(new ChatComponentTranslation("commands.players.list", new Object[] {Integer.valueOf(MinecraftServer.getServer().getCurrentPlayerCount()), Integer.valueOf(MinecraftServer.getServer().getMaxPlayers())})); + par1ICommandSender.addChatMessage(new ChatComponentText(MinecraftServer.getServer().getConfigurationManager().getPlayerListAsString())); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/server/CommandMessage.java b/src/main/java/net/minecraft/command/server/CommandMessage.java new file mode 100644 index 0000000..811ecf2 --- /dev/null +++ b/src/main/java/net/minecraft/command/server/CommandMessage.java @@ -0,0 +1,80 @@ +package net.minecraft.command.server; + +import java.util.Arrays; +import java.util.List; +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandSender; +import net.minecraft.command.PlayerNotFoundException; +import net.minecraft.command.WrongUsageException; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IChatComponent; + +public class CommandMessage extends CommandBase +{ + private static final String __OBFID = "CL_00000641"; + + public List getCommandAliases() + { + return Arrays.asList(new String[] {"w", "msg"}); + } + + public String getCommandName() + { + return "tell"; + } + + public int getRequiredPermissionLevel() + { + return 0; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.message.usage"; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + if (par2ArrayOfStr.length < 2) + { + throw new WrongUsageException("commands.message.usage", new Object[0]); + } + else + { + EntityPlayerMP entityplayermp = getPlayer(par1ICommandSender, par2ArrayOfStr[0]); + + if (entityplayermp == null) + { + throw new PlayerNotFoundException(); + } + else if (entityplayermp == par1ICommandSender) + { + throw new PlayerNotFoundException("commands.message.sameTarget", new Object[0]); + } + else + { + IChatComponent ichatcomponent = func_147176_a(par1ICommandSender, par2ArrayOfStr, 1, !(par1ICommandSender instanceof EntityPlayer)); + ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("commands.message.display.incoming", new Object[] {par1ICommandSender.func_145748_c_(), ichatcomponent.createCopy()}); + ChatComponentTranslation chatcomponenttranslation1 = new ChatComponentTranslation("commands.message.display.outgoing", new Object[] {entityplayermp.func_145748_c_(), ichatcomponent.createCopy()}); + chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.GRAY).setItalic(Boolean.valueOf(true)); + chatcomponenttranslation1.getChatStyle().setColor(EnumChatFormatting.GRAY).setItalic(Boolean.valueOf(true)); + entityplayermp.addChatMessage(chatcomponenttranslation); + par1ICommandSender.addChatMessage(chatcomponenttranslation1); + } + } + } + + public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + return getListOfStringsMatchingLastWord(par2ArrayOfStr, MinecraftServer.getServer().getAllUsernames()); + } + + public boolean isUsernameIndex(String[] par1ArrayOfStr, int par2) + { + return par2 == 0; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/server/CommandMessageRaw.java b/src/main/java/net/minecraft/command/server/CommandMessageRaw.java new file mode 100644 index 0000000..aa7602a --- /dev/null +++ b/src/main/java/net/minecraft/command/server/CommandMessageRaw.java @@ -0,0 +1,65 @@ +package net.minecraft.command.server; + +import com.google.gson.JsonParseException; +import java.util.List; +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandSender; +import net.minecraft.command.SyntaxErrorException; +import net.minecraft.command.WrongUsageException; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.IChatComponent; +import org.apache.commons.lang3.exception.ExceptionUtils; + +public class CommandMessageRaw extends CommandBase +{ + private static final String __OBFID = "CL_00000667"; + + public String getCommandName() + { + return "tellraw"; + } + + public int getRequiredPermissionLevel() + { + return 2; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.tellraw.usage"; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + if (par2ArrayOfStr.length < 2) + { + throw new WrongUsageException("commands.tellraw.usage", new Object[0]); + } + else + { + EntityPlayerMP entityplayermp = getPlayer(par1ICommandSender, par2ArrayOfStr[0]); + String s = func_82360_a(par1ICommandSender, par2ArrayOfStr, 1); + + try + { + IChatComponent ichatcomponent = IChatComponent.Serializer.func_150699_a(s); + entityplayermp.addChatMessage(ichatcomponent); + } + catch (JsonParseException jsonparseexception) + { + throw new SyntaxErrorException("commands.tellraw.jsonException", new Object[] {ExceptionUtils.getRootCause(jsonparseexception).getMessage()}); + } + } + } + + public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + return par2ArrayOfStr.length == 1 ? getListOfStringsMatchingLastWord(par2ArrayOfStr, MinecraftServer.getServer().getAllUsernames()) : null; + } + + public boolean isUsernameIndex(String[] par1ArrayOfStr, int par2) + { + return par2 == 0; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/server/CommandOp.java b/src/main/java/net/minecraft/command/server/CommandOp.java new file mode 100644 index 0000000..b461fdd --- /dev/null +++ b/src/main/java/net/minecraft/command/server/CommandOp.java @@ -0,0 +1,68 @@ +package net.minecraft.command.server; + +import java.util.ArrayList; +import java.util.List; +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandSender; +import net.minecraft.command.WrongUsageException; +import net.minecraft.server.MinecraftServer; + +public class CommandOp extends CommandBase +{ + private static final String __OBFID = "CL_00000694"; + + public String getCommandName() + { + return "op"; + } + + public int getRequiredPermissionLevel() + { + return 3; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.op.usage"; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + if (par2ArrayOfStr.length == 1 && par2ArrayOfStr[0].length() > 0) + { + MinecraftServer.getServer().getConfigurationManager().addOp(par2ArrayOfStr[0]); + notifyAdmins(par1ICommandSender, "commands.op.success", new Object[] {par2ArrayOfStr[0]}); + } + else + { + throw new WrongUsageException("commands.op.usage", new Object[0]); + } + } + + public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + if (par2ArrayOfStr.length == 1) + { + String s = par2ArrayOfStr[par2ArrayOfStr.length - 1]; + ArrayList arraylist = new ArrayList(); + String[] astring1 = MinecraftServer.getServer().getAllUsernames(); + int i = astring1.length; + + for (int j = 0; j < i; ++j) + { + String s1 = astring1[j]; + + if (!MinecraftServer.getServer().getConfigurationManager().isPlayerOpped(s1) && doesStringStartWith(s, s1)) + { + arraylist.add(s1); + } + } + + return arraylist; + } + else + { + return null; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/server/CommandPardonIp.java b/src/main/java/net/minecraft/command/server/CommandPardonIp.java new file mode 100644 index 0000000..b09a3e9 --- /dev/null +++ b/src/main/java/net/minecraft/command/server/CommandPardonIp.java @@ -0,0 +1,61 @@ +package net.minecraft.command.server; + +import java.util.List; +import java.util.regex.Matcher; +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandSender; +import net.minecraft.command.SyntaxErrorException; +import net.minecraft.command.WrongUsageException; +import net.minecraft.server.MinecraftServer; + +public class CommandPardonIp extends CommandBase +{ + private static final String __OBFID = "CL_00000720"; + + public String getCommandName() + { + return "pardon-ip"; + } + + public int getRequiredPermissionLevel() + { + return 3; + } + + public boolean canCommandSenderUseCommand(ICommandSender par1ICommandSender) + { + return MinecraftServer.getServer().getConfigurationManager().getBannedIPs().isListActive() && super.canCommandSenderUseCommand(par1ICommandSender); + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.unbanip.usage"; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + if (par2ArrayOfStr.length == 1 && par2ArrayOfStr[0].length() > 1) + { + Matcher matcher = CommandBanIp.field_147211_a.matcher(par2ArrayOfStr[0]); + + if (matcher.matches()) + { + MinecraftServer.getServer().getConfigurationManager().getBannedIPs().remove(par2ArrayOfStr[0]); + notifyAdmins(par1ICommandSender, "commands.unbanip.success", new Object[] {par2ArrayOfStr[0]}); + } + else + { + throw new SyntaxErrorException("commands.unbanip.invalid", new Object[0]); + } + } + else + { + throw new WrongUsageException("commands.unbanip.usage", new Object[0]); + } + } + + public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + return par2ArrayOfStr.length == 1 ? getListOfStringsFromIterableMatchingLastWord(par2ArrayOfStr, MinecraftServer.getServer().getConfigurationManager().getBannedIPs().getBannedList().keySet()) : null; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/server/CommandPardonPlayer.java b/src/main/java/net/minecraft/command/server/CommandPardonPlayer.java new file mode 100644 index 0000000..1c13f48 --- /dev/null +++ b/src/main/java/net/minecraft/command/server/CommandPardonPlayer.java @@ -0,0 +1,50 @@ +package net.minecraft.command.server; + +import java.util.List; +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandSender; +import net.minecraft.command.WrongUsageException; +import net.minecraft.server.MinecraftServer; + +public class CommandPardonPlayer extends CommandBase +{ + private static final String __OBFID = "CL_00000747"; + + public String getCommandName() + { + return "pardon"; + } + + public int getRequiredPermissionLevel() + { + return 3; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.unban.usage"; + } + + public boolean canCommandSenderUseCommand(ICommandSender par1ICommandSender) + { + return MinecraftServer.getServer().getConfigurationManager().getBannedPlayers().isListActive() && super.canCommandSenderUseCommand(par1ICommandSender); + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + if (par2ArrayOfStr.length == 1 && par2ArrayOfStr[0].length() > 0) + { + MinecraftServer.getServer().getConfigurationManager().getBannedPlayers().remove(par2ArrayOfStr[0]); + notifyAdmins(par1ICommandSender, "commands.unban.success", new Object[] {par2ArrayOfStr[0]}); + } + else + { + throw new WrongUsageException("commands.unban.usage", new Object[0]); + } + } + + public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + return par2ArrayOfStr.length == 1 ? getListOfStringsFromIterableMatchingLastWord(par2ArrayOfStr, MinecraftServer.getServer().getConfigurationManager().getBannedPlayers().getBannedList().keySet()) : null; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/server/CommandPublishLocalServer.java b/src/main/java/net/minecraft/command/server/CommandPublishLocalServer.java new file mode 100644 index 0000000..fccfd16 --- /dev/null +++ b/src/main/java/net/minecraft/command/server/CommandPublishLocalServer.java @@ -0,0 +1,35 @@ +package net.minecraft.command.server; + +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandSender; +import net.minecraft.server.MinecraftServer; +import net.minecraft.world.WorldSettings; + +public class CommandPublishLocalServer extends CommandBase +{ + private static final String __OBFID = "CL_00000799"; + + public String getCommandName() + { + return "publish"; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.publish.usage"; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + String s = MinecraftServer.getServer().shareToLAN(WorldSettings.GameType.SURVIVAL, false); + + if (s != null) + { + notifyAdmins(par1ICommandSender, "commands.publish.started", new Object[] {s}); + } + else + { + notifyAdmins(par1ICommandSender, "commands.publish.failed", new Object[0]); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/server/CommandSaveAll.java b/src/main/java/net/minecraft/command/server/CommandSaveAll.java new file mode 100644 index 0000000..1dcc47f --- /dev/null +++ b/src/main/java/net/minecraft/command/server/CommandSaveAll.java @@ -0,0 +1,80 @@ +package net.minecraft.command.server; + +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandSender; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.IProgressUpdate; +import net.minecraft.world.MinecraftException; +import net.minecraft.world.WorldServer; + +public class CommandSaveAll extends CommandBase +{ + private static final String __OBFID = "CL_00000826"; + + public String getCommandName() + { + return "save-all"; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.save.usage"; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + MinecraftServer minecraftserver = MinecraftServer.getServer(); + par1ICommandSender.addChatMessage(new ChatComponentTranslation("commands.save.start", new Object[0])); + + if (minecraftserver.getConfigurationManager() != null) + { + minecraftserver.getConfigurationManager().saveAllPlayerData(); + } + + try + { + int i; + WorldServer worldserver; + boolean flag; + + for (i = 0; i < minecraftserver.worldServers.length; ++i) + { + if (minecraftserver.worldServers[i] != null) + { + worldserver = minecraftserver.worldServers[i]; + flag = worldserver.levelSaving; + worldserver.levelSaving = false; + worldserver.saveAllChunks(true, (IProgressUpdate)null); + worldserver.levelSaving = flag; + } + } + + if (par2ArrayOfStr.length > 0 && "flush".equals(par2ArrayOfStr[0])) + { + par1ICommandSender.addChatMessage(new ChatComponentTranslation("commands.save.flushStart", new Object[0])); + + for (i = 0; i < minecraftserver.worldServers.length; ++i) + { + if (minecraftserver.worldServers[i] != null) + { + worldserver = minecraftserver.worldServers[i]; + flag = worldserver.levelSaving; + worldserver.levelSaving = false; + worldserver.saveChunkData(); + worldserver.levelSaving = flag; + } + } + + par1ICommandSender.addChatMessage(new ChatComponentTranslation("commands.save.flushEnd", new Object[0])); + } + } + catch (MinecraftException minecraftexception) + { + notifyAdmins(par1ICommandSender, "commands.save.failed", new Object[] {minecraftexception.getMessage()}); + return; + } + + notifyAdmins(par1ICommandSender, "commands.save.success", new Object[0]); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/server/CommandSaveOff.java b/src/main/java/net/minecraft/command/server/CommandSaveOff.java new file mode 100644 index 0000000..fc18e54 --- /dev/null +++ b/src/main/java/net/minecraft/command/server/CommandSaveOff.java @@ -0,0 +1,51 @@ +package net.minecraft.command.server; + +import net.minecraft.command.CommandBase; +import net.minecraft.command.CommandException; +import net.minecraft.command.ICommandSender; +import net.minecraft.server.MinecraftServer; +import net.minecraft.world.WorldServer; + +public class CommandSaveOff extends CommandBase +{ + private static final String __OBFID = "CL_00000847"; + + public String getCommandName() + { + return "save-off"; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.save-off.usage"; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + MinecraftServer minecraftserver = MinecraftServer.getServer(); + boolean flag = false; + + for (int i = 0; i < minecraftserver.worldServers.length; ++i) + { + if (minecraftserver.worldServers[i] != null) + { + WorldServer worldserver = minecraftserver.worldServers[i]; + + if (!worldserver.levelSaving) + { + worldserver.levelSaving = true; + flag = true; + } + } + } + + if (flag) + { + notifyAdmins(par1ICommandSender, "commands.save.disabled", new Object[0]); + } + else + { + throw new CommandException("commands.save-off.alreadyOff", new Object[0]); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/server/CommandSaveOn.java b/src/main/java/net/minecraft/command/server/CommandSaveOn.java new file mode 100644 index 0000000..c749065 --- /dev/null +++ b/src/main/java/net/minecraft/command/server/CommandSaveOn.java @@ -0,0 +1,51 @@ +package net.minecraft.command.server; + +import net.minecraft.command.CommandBase; +import net.minecraft.command.CommandException; +import net.minecraft.command.ICommandSender; +import net.minecraft.server.MinecraftServer; +import net.minecraft.world.WorldServer; + +public class CommandSaveOn extends CommandBase +{ + private static final String __OBFID = "CL_00000873"; + + public String getCommandName() + { + return "save-on"; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.save-on.usage"; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + MinecraftServer minecraftserver = MinecraftServer.getServer(); + boolean flag = false; + + for (int i = 0; i < minecraftserver.worldServers.length; ++i) + { + if (minecraftserver.worldServers[i] != null) + { + WorldServer worldserver = minecraftserver.worldServers[i]; + + if (worldserver.levelSaving) + { + worldserver.levelSaving = false; + flag = true; + } + } + } + + if (flag) + { + notifyAdmins(par1ICommandSender, "commands.save.enabled", new Object[0]); + } + else + { + throw new CommandException("commands.save-on.alreadyOn", new Object[0]); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/server/CommandScoreboard.java b/src/main/java/net/minecraft/command/server/CommandScoreboard.java new file mode 100644 index 0000000..684160e --- /dev/null +++ b/src/main/java/net/minecraft/command/server/CommandScoreboard.java @@ -0,0 +1,924 @@ +package net.minecraft.command.server; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import net.minecraft.command.CommandBase; +import net.minecraft.command.CommandException; +import net.minecraft.command.ICommandSender; +import net.minecraft.command.SyntaxErrorException; +import net.minecraft.command.WrongUsageException; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.scoreboard.IScoreObjectiveCriteria; +import net.minecraft.scoreboard.Score; +import net.minecraft.scoreboard.ScoreObjective; +import net.minecraft.scoreboard.ScorePlayerTeam; +import net.minecraft.scoreboard.Scoreboard; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.EnumChatFormatting; + +public class CommandScoreboard extends CommandBase +{ + private static final String __OBFID = "CL_00000896"; + + public String getCommandName() + { + return "scoreboard"; + } + + public int getRequiredPermissionLevel() + { + return 2; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.scoreboard.usage"; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + if (par2ArrayOfStr.length >= 1) + { + if (par2ArrayOfStr[0].equalsIgnoreCase("objectives")) + { + if (par2ArrayOfStr.length == 1) + { + throw new WrongUsageException("commands.scoreboard.objectives.usage", new Object[0]); + } + + if (par2ArrayOfStr[1].equalsIgnoreCase("list")) + { + this.func_147196_d(par1ICommandSender); + } + else if (par2ArrayOfStr[1].equalsIgnoreCase("add")) + { + if (par2ArrayOfStr.length < 4) + { + throw new WrongUsageException("commands.scoreboard.objectives.add.usage", new Object[0]); + } + + this.func_147193_c(par1ICommandSender, par2ArrayOfStr, 2); + } + else if (par2ArrayOfStr[1].equalsIgnoreCase("remove")) + { + if (par2ArrayOfStr.length != 3) + { + throw new WrongUsageException("commands.scoreboard.objectives.remove.usage", new Object[0]); + } + + this.func_147191_h(par1ICommandSender, par2ArrayOfStr[2]); + } + else + { + if (!par2ArrayOfStr[1].equalsIgnoreCase("setdisplay")) + { + throw new WrongUsageException("commands.scoreboard.objectives.usage", new Object[0]); + } + + if (par2ArrayOfStr.length != 3 && par2ArrayOfStr.length != 4) + { + throw new WrongUsageException("commands.scoreboard.objectives.setdisplay.usage", new Object[0]); + } + + this.func_147198_k(par1ICommandSender, par2ArrayOfStr, 2); + } + + return; + } + + if (par2ArrayOfStr[0].equalsIgnoreCase("players")) + { + if (par2ArrayOfStr.length == 1) + { + throw new WrongUsageException("commands.scoreboard.players.usage", new Object[0]); + } + + if (par2ArrayOfStr[1].equalsIgnoreCase("list")) + { + if (par2ArrayOfStr.length > 3) + { + throw new WrongUsageException("commands.scoreboard.players.list.usage", new Object[0]); + } + + this.func_147195_l(par1ICommandSender, par2ArrayOfStr, 2); + } + else if (par2ArrayOfStr[1].equalsIgnoreCase("add")) + { + if (par2ArrayOfStr.length != 5) + { + throw new WrongUsageException("commands.scoreboard.players.add.usage", new Object[0]); + } + + this.func_147197_m(par1ICommandSender, par2ArrayOfStr, 2); + } + else if (par2ArrayOfStr[1].equalsIgnoreCase("remove")) + { + if (par2ArrayOfStr.length != 5) + { + throw new WrongUsageException("commands.scoreboard.players.remove.usage", new Object[0]); + } + + this.func_147197_m(par1ICommandSender, par2ArrayOfStr, 2); + } + else if (par2ArrayOfStr[1].equalsIgnoreCase("set")) + { + if (par2ArrayOfStr.length != 5) + { + throw new WrongUsageException("commands.scoreboard.players.set.usage", new Object[0]); + } + + this.func_147197_m(par1ICommandSender, par2ArrayOfStr, 2); + } + else + { + if (!par2ArrayOfStr[1].equalsIgnoreCase("reset")) + { + throw new WrongUsageException("commands.scoreboard.players.usage", new Object[0]); + } + + if (par2ArrayOfStr.length != 3) + { + throw new WrongUsageException("commands.scoreboard.players.reset.usage", new Object[0]); + } + + this.func_147187_n(par1ICommandSender, par2ArrayOfStr, 2); + } + + return; + } + + if (par2ArrayOfStr[0].equalsIgnoreCase("teams")) + { + if (par2ArrayOfStr.length == 1) + { + throw new WrongUsageException("commands.scoreboard.teams.usage", new Object[0]); + } + + if (par2ArrayOfStr[1].equalsIgnoreCase("list")) + { + if (par2ArrayOfStr.length > 3) + { + throw new WrongUsageException("commands.scoreboard.teams.list.usage", new Object[0]); + } + + this.func_147186_g(par1ICommandSender, par2ArrayOfStr, 2); + } + else if (par2ArrayOfStr[1].equalsIgnoreCase("add")) + { + if (par2ArrayOfStr.length < 3) + { + throw new WrongUsageException("commands.scoreboard.teams.add.usage", new Object[0]); + } + + this.func_147185_d(par1ICommandSender, par2ArrayOfStr, 2); + } + else if (par2ArrayOfStr[1].equalsIgnoreCase("remove")) + { + if (par2ArrayOfStr.length != 3) + { + throw new WrongUsageException("commands.scoreboard.teams.remove.usage", new Object[0]); + } + + this.func_147194_f(par1ICommandSender, par2ArrayOfStr, 2); + } + else if (par2ArrayOfStr[1].equalsIgnoreCase("empty")) + { + if (par2ArrayOfStr.length != 3) + { + throw new WrongUsageException("commands.scoreboard.teams.empty.usage", new Object[0]); + } + + this.func_147188_j(par1ICommandSender, par2ArrayOfStr, 2); + } + else if (par2ArrayOfStr[1].equalsIgnoreCase("join")) + { + if (par2ArrayOfStr.length < 4 && (par2ArrayOfStr.length != 3 || !(par1ICommandSender instanceof EntityPlayer))) + { + throw new WrongUsageException("commands.scoreboard.teams.join.usage", new Object[0]); + } + + this.func_147190_h(par1ICommandSender, par2ArrayOfStr, 2); + } + else if (par2ArrayOfStr[1].equalsIgnoreCase("leave")) + { + if (par2ArrayOfStr.length < 3 && !(par1ICommandSender instanceof EntityPlayer)) + { + throw new WrongUsageException("commands.scoreboard.teams.leave.usage", new Object[0]); + } + + this.func_147199_i(par1ICommandSender, par2ArrayOfStr, 2); + } + else + { + if (!par2ArrayOfStr[1].equalsIgnoreCase("option")) + { + throw new WrongUsageException("commands.scoreboard.teams.usage", new Object[0]); + } + + if (par2ArrayOfStr.length != 4 && par2ArrayOfStr.length != 5) + { + throw new WrongUsageException("commands.scoreboard.teams.option.usage", new Object[0]); + } + + this.func_147200_e(par1ICommandSender, par2ArrayOfStr, 2); + } + + return; + } + } + + throw new WrongUsageException("commands.scoreboard.usage", new Object[0]); + } + + protected Scoreboard func_147192_d() + { + return MinecraftServer.getServer().worldServerForDimension(0).getScoreboard(); + } + + protected ScoreObjective func_147189_a(String p_147189_1_, boolean p_147189_2_) + { + Scoreboard scoreboard = this.func_147192_d(); + ScoreObjective scoreobjective = scoreboard.getObjective(p_147189_1_); + + if (scoreobjective == null) + { + throw new CommandException("commands.scoreboard.objectiveNotFound", new Object[] {p_147189_1_}); + } + else if (p_147189_2_ && scoreobjective.getCriteria().isReadOnly()) + { + throw new CommandException("commands.scoreboard.objectiveReadOnly", new Object[] {p_147189_1_}); + } + else + { + return scoreobjective; + } + } + + protected ScorePlayerTeam func_147183_a(String p_147183_1_) + { + Scoreboard scoreboard = this.func_147192_d(); + ScorePlayerTeam scoreplayerteam = scoreboard.getTeam(p_147183_1_); + + if (scoreplayerteam == null) + { + throw new CommandException("commands.scoreboard.teamNotFound", new Object[] {p_147183_1_}); + } + else + { + return scoreplayerteam; + } + } + + protected void func_147193_c(ICommandSender p_147193_1_, String[] p_147193_2_, int p_147193_3_) + { + String s = p_147193_2_[p_147193_3_++]; + String s1 = p_147193_2_[p_147193_3_++]; + Scoreboard scoreboard = this.func_147192_d(); + IScoreObjectiveCriteria iscoreobjectivecriteria = (IScoreObjectiveCriteria)IScoreObjectiveCriteria.field_96643_a.get(s1); + + if (iscoreobjectivecriteria == null) + { + throw new WrongUsageException("commands.scoreboard.objectives.add.wrongType", new Object[] {s1}); + } + else if (scoreboard.getObjective(s) != null) + { + throw new CommandException("commands.scoreboard.objectives.add.alreadyExists", new Object[] {s}); + } + else if (s.length() > 16) + { + throw new SyntaxErrorException("commands.scoreboard.objectives.add.tooLong", new Object[] {s, Integer.valueOf(16)}); + } + else if (s.length() == 0) + { + throw new WrongUsageException("commands.scoreboard.objectives.add.usage", new Object[0]); + } + else + { + if (p_147193_2_.length > p_147193_3_) + { + String s2 = func_147178_a(p_147193_1_, p_147193_2_, p_147193_3_).getUnformattedText(); + + if (s2.length() > 32) + { + throw new SyntaxErrorException("commands.scoreboard.objectives.add.displayTooLong", new Object[] {s2, Integer.valueOf(32)}); + } + + if (s2.length() > 0) + { + scoreboard.addScoreObjective(s, iscoreobjectivecriteria).setDisplayName(s2); + } + else + { + scoreboard.addScoreObjective(s, iscoreobjectivecriteria); + } + } + else + { + scoreboard.addScoreObjective(s, iscoreobjectivecriteria); + } + + notifyAdmins(p_147193_1_, "commands.scoreboard.objectives.add.success", new Object[] {s}); + } + } + + protected void func_147185_d(ICommandSender p_147185_1_, String[] p_147185_2_, int p_147185_3_) + { + String s = p_147185_2_[p_147185_3_++]; + Scoreboard scoreboard = this.func_147192_d(); + + if (scoreboard.getTeam(s) != null) + { + throw new CommandException("commands.scoreboard.teams.add.alreadyExists", new Object[] {s}); + } + else if (s.length() > 16) + { + throw new SyntaxErrorException("commands.scoreboard.teams.add.tooLong", new Object[] {s, Integer.valueOf(16)}); + } + else if (s.length() == 0) + { + throw new WrongUsageException("commands.scoreboard.teams.add.usage", new Object[0]); + } + else + { + if (p_147185_2_.length > p_147185_3_) + { + String s1 = func_147178_a(p_147185_1_, p_147185_2_, p_147185_3_).getUnformattedText(); + + if (s1.length() > 32) + { + throw new SyntaxErrorException("commands.scoreboard.teams.add.displayTooLong", new Object[] {s1, Integer.valueOf(32)}); + } + + if (s1.length() > 0) + { + scoreboard.createTeam(s).setTeamName(s1); + } + else + { + scoreboard.createTeam(s); + } + } + else + { + scoreboard.createTeam(s); + } + + notifyAdmins(p_147185_1_, "commands.scoreboard.teams.add.success", new Object[] {s}); + } + } + + protected void func_147200_e(ICommandSender p_147200_1_, String[] p_147200_2_, int p_147200_3_) + { + ScorePlayerTeam scoreplayerteam = this.func_147183_a(p_147200_2_[p_147200_3_++]); + + if (scoreplayerteam != null) + { + String s = p_147200_2_[p_147200_3_++].toLowerCase(); + + if (!s.equalsIgnoreCase("color") && !s.equalsIgnoreCase("friendlyfire") && !s.equalsIgnoreCase("seeFriendlyInvisibles")) + { + throw new WrongUsageException("commands.scoreboard.teams.option.usage", new Object[0]); + } + else if (p_147200_2_.length == 4) + { + if (s.equalsIgnoreCase("color")) + { + throw new WrongUsageException("commands.scoreboard.teams.option.noValue", new Object[] {s, joinNiceStringFromCollection(EnumChatFormatting.getValidValues(true, false))}); + } + else if (!s.equalsIgnoreCase("friendlyfire") && !s.equalsIgnoreCase("seeFriendlyInvisibles")) + { + throw new WrongUsageException("commands.scoreboard.teams.option.usage", new Object[0]); + } + else + { + throw new WrongUsageException("commands.scoreboard.teams.option.noValue", new Object[] {s, joinNiceStringFromCollection(Arrays.asList(new String[]{"true", "false"}))}); + } + } + else + { + String s1 = p_147200_2_[p_147200_3_++]; + + if (s.equalsIgnoreCase("color")) + { + EnumChatFormatting enumchatformatting = EnumChatFormatting.getValueByName(s1); + + if (enumchatformatting == null || enumchatformatting.isFancyStyling()) + { + throw new WrongUsageException("commands.scoreboard.teams.option.noValue", new Object[] {s, joinNiceStringFromCollection(EnumChatFormatting.getValidValues(true, false))}); + } + + scoreplayerteam.setNamePrefix(enumchatformatting.toString()); + scoreplayerteam.setNameSuffix(EnumChatFormatting.RESET.toString()); + } + else if (s.equalsIgnoreCase("friendlyfire")) + { + if (!s1.equalsIgnoreCase("true") && !s1.equalsIgnoreCase("false")) + { + throw new WrongUsageException("commands.scoreboard.teams.option.noValue", new Object[] {s, joinNiceStringFromCollection(Arrays.asList(new String[]{"true", "false"}))}); + } + + scoreplayerteam.setAllowFriendlyFire(s1.equalsIgnoreCase("true")); + } + else if (s.equalsIgnoreCase("seeFriendlyInvisibles")) + { + if (!s1.equalsIgnoreCase("true") && !s1.equalsIgnoreCase("false")) + { + throw new WrongUsageException("commands.scoreboard.teams.option.noValue", new Object[] {s, joinNiceStringFromCollection(Arrays.asList(new String[]{"true", "false"}))}); + } + + scoreplayerteam.setSeeFriendlyInvisiblesEnabled(s1.equalsIgnoreCase("true")); + } + + notifyAdmins(p_147200_1_, "commands.scoreboard.teams.option.success", new Object[] {s, scoreplayerteam.getRegisteredName(), s1}); + } + } + } + + protected void func_147194_f(ICommandSender p_147194_1_, String[] p_147194_2_, int p_147194_3_) + { + Scoreboard scoreboard = this.func_147192_d(); + ScorePlayerTeam scoreplayerteam = this.func_147183_a(p_147194_2_[p_147194_3_++]); + + if (scoreplayerteam != null) + { + scoreboard.removeTeam(scoreplayerteam); + notifyAdmins(p_147194_1_, "commands.scoreboard.teams.remove.success", new Object[] {scoreplayerteam.getRegisteredName()}); + } + } + + protected void func_147186_g(ICommandSender p_147186_1_, String[] p_147186_2_, int p_147186_3_) + { + Scoreboard scoreboard = this.func_147192_d(); + + if (p_147186_2_.length > p_147186_3_) + { + ScorePlayerTeam scoreplayerteam = this.func_147183_a(p_147186_2_[p_147186_3_++]); + + if (scoreplayerteam == null) + { + return; + } + + Collection collection = scoreplayerteam.getMembershipCollection(); + + if (collection.size() <= 0) + { + throw new CommandException("commands.scoreboard.teams.list.player.empty", new Object[] {scoreplayerteam.getRegisteredName()}); + } + + ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("commands.scoreboard.teams.list.player.count", new Object[] {Integer.valueOf(collection.size()), scoreplayerteam.getRegisteredName()}); + chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.DARK_GREEN); + p_147186_1_.addChatMessage(chatcomponenttranslation); + p_147186_1_.addChatMessage(new ChatComponentText(joinNiceString(collection.toArray()))); + } + else + { + Collection collection1 = scoreboard.getTeams(); + + if (collection1.size() <= 0) + { + throw new CommandException("commands.scoreboard.teams.list.empty", new Object[0]); + } + + ChatComponentTranslation chatcomponenttranslation1 = new ChatComponentTranslation("commands.scoreboard.teams.list.count", new Object[] {Integer.valueOf(collection1.size())}); + chatcomponenttranslation1.getChatStyle().setColor(EnumChatFormatting.DARK_GREEN); + p_147186_1_.addChatMessage(chatcomponenttranslation1); + Iterator iterator = collection1.iterator(); + + while (iterator.hasNext()) + { + ScorePlayerTeam scoreplayerteam1 = (ScorePlayerTeam)iterator.next(); + p_147186_1_.addChatMessage(new ChatComponentTranslation("commands.scoreboard.teams.list.entry", new Object[] {scoreplayerteam1.getRegisteredName(), scoreplayerteam1.func_96669_c(), Integer.valueOf(scoreplayerteam1.getMembershipCollection().size())})); + } + } + } + + protected void func_147190_h(ICommandSender p_147190_1_, String[] p_147190_2_, int p_147190_3_) + { + Scoreboard scoreboard = this.func_147192_d(); + String s = p_147190_2_[p_147190_3_++]; + HashSet hashset = new HashSet(); + HashSet hashset1 = new HashSet(); + String s1; + + if (p_147190_1_ instanceof EntityPlayer && p_147190_3_ == p_147190_2_.length) + { + s1 = getCommandSenderAsPlayer(p_147190_1_).getCommandSenderName(); + + if (scoreboard.func_151392_a(s1, s)) + { + hashset.add(s1); + } + else + { + hashset1.add(s1); + } + } + else + { + while (p_147190_3_ < p_147190_2_.length) + { + s1 = func_96332_d(p_147190_1_, p_147190_2_[p_147190_3_++]); + + if (scoreboard.func_151392_a(s1, s)) + { + hashset.add(s1); + } + else + { + hashset1.add(s1); + } + } + } + + if (!hashset.isEmpty()) + { + notifyAdmins(p_147190_1_, "commands.scoreboard.teams.join.success", new Object[] {Integer.valueOf(hashset.size()), s, joinNiceString(hashset.toArray(new String[0]))}); + } + + if (!hashset1.isEmpty()) + { + throw new CommandException("commands.scoreboard.teams.join.failure", new Object[] {Integer.valueOf(hashset1.size()), s, joinNiceString(hashset1.toArray(new String[0]))}); + } + } + + protected void func_147199_i(ICommandSender p_147199_1_, String[] p_147199_2_, int p_147199_3_) + { + Scoreboard scoreboard = this.func_147192_d(); + HashSet hashset = new HashSet(); + HashSet hashset1 = new HashSet(); + String s; + + if (p_147199_1_ instanceof EntityPlayer && p_147199_3_ == p_147199_2_.length) + { + s = getCommandSenderAsPlayer(p_147199_1_).getCommandSenderName(); + + if (scoreboard.removePlayerFromTeams(s)) + { + hashset.add(s); + } + else + { + hashset1.add(s); + } + } + else + { + while (p_147199_3_ < p_147199_2_.length) + { + s = func_96332_d(p_147199_1_, p_147199_2_[p_147199_3_++]); + + if (scoreboard.removePlayerFromTeams(s)) + { + hashset.add(s); + } + else + { + hashset1.add(s); + } + } + } + + if (!hashset.isEmpty()) + { + notifyAdmins(p_147199_1_, "commands.scoreboard.teams.leave.success", new Object[] {Integer.valueOf(hashset.size()), joinNiceString(hashset.toArray(new String[0]))}); + } + + if (!hashset1.isEmpty()) + { + throw new CommandException("commands.scoreboard.teams.leave.failure", new Object[] {Integer.valueOf(hashset1.size()), joinNiceString(hashset1.toArray(new String[0]))}); + } + } + + protected void func_147188_j(ICommandSender p_147188_1_, String[] p_147188_2_, int p_147188_3_) + { + Scoreboard scoreboard = this.func_147192_d(); + ScorePlayerTeam scoreplayerteam = this.func_147183_a(p_147188_2_[p_147188_3_++]); + + if (scoreplayerteam != null) + { + ArrayList arraylist = new ArrayList(scoreplayerteam.getMembershipCollection()); + + if (arraylist.isEmpty()) + { + throw new CommandException("commands.scoreboard.teams.empty.alreadyEmpty", new Object[] {scoreplayerteam.getRegisteredName()}); + } + else + { + Iterator iterator = arraylist.iterator(); + + while (iterator.hasNext()) + { + String s = (String)iterator.next(); + scoreboard.removePlayerFromTeam(s, scoreplayerteam); + } + + notifyAdmins(p_147188_1_, "commands.scoreboard.teams.empty.success", new Object[] {Integer.valueOf(arraylist.size()), scoreplayerteam.getRegisteredName()}); + } + } + } + + protected void func_147191_h(ICommandSender p_147191_1_, String p_147191_2_) + { + Scoreboard scoreboard = this.func_147192_d(); + ScoreObjective scoreobjective = this.func_147189_a(p_147191_2_, false); + scoreboard.func_96519_k(scoreobjective); + notifyAdmins(p_147191_1_, "commands.scoreboard.objectives.remove.success", new Object[] {p_147191_2_}); + } + + protected void func_147196_d(ICommandSender p_147196_1_) + { + Scoreboard scoreboard = this.func_147192_d(); + Collection collection = scoreboard.getScoreObjectives(); + + if (collection.size() <= 0) + { + throw new CommandException("commands.scoreboard.objectives.list.empty", new Object[0]); + } + else + { + ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("commands.scoreboard.objectives.list.count", new Object[] {Integer.valueOf(collection.size())}); + chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.DARK_GREEN); + p_147196_1_.addChatMessage(chatcomponenttranslation); + Iterator iterator = collection.iterator(); + + while (iterator.hasNext()) + { + ScoreObjective scoreobjective = (ScoreObjective)iterator.next(); + p_147196_1_.addChatMessage(new ChatComponentTranslation("commands.scoreboard.objectives.list.entry", new Object[] {scoreobjective.getName(), scoreobjective.getDisplayName(), scoreobjective.getCriteria().func_96636_a()})); + } + } + } + + protected void func_147198_k(ICommandSender p_147198_1_, String[] p_147198_2_, int p_147198_3_) + { + Scoreboard scoreboard = this.func_147192_d(); + String s = p_147198_2_[p_147198_3_++]; + int j = Scoreboard.getObjectiveDisplaySlotNumber(s); + ScoreObjective scoreobjective = null; + + if (p_147198_2_.length == 4) + { + scoreobjective = this.func_147189_a(p_147198_2_[p_147198_3_++], false); + } + + if (j < 0) + { + throw new CommandException("commands.scoreboard.objectives.setdisplay.invalidSlot", new Object[] {s}); + } + else + { + scoreboard.func_96530_a(j, scoreobjective); + + if (scoreobjective != null) + { + notifyAdmins(p_147198_1_, "commands.scoreboard.objectives.setdisplay.successSet", new Object[] {Scoreboard.getObjectiveDisplaySlot(j), scoreobjective.getName()}); + } + else + { + notifyAdmins(p_147198_1_, "commands.scoreboard.objectives.setdisplay.successCleared", new Object[] {Scoreboard.getObjectiveDisplaySlot(j)}); + } + } + } + + protected void func_147195_l(ICommandSender p_147195_1_, String[] p_147195_2_, int p_147195_3_) + { + Scoreboard scoreboard = this.func_147192_d(); + + if (p_147195_2_.length > p_147195_3_) + { + String s = func_96332_d(p_147195_1_, p_147195_2_[p_147195_3_++]); + Map map = scoreboard.func_96510_d(s); + + if (map.size() <= 0) + { + throw new CommandException("commands.scoreboard.players.list.player.empty", new Object[] {s}); + } + + ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("commands.scoreboard.players.list.player.count", new Object[] {Integer.valueOf(map.size()), s}); + chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.DARK_GREEN); + p_147195_1_.addChatMessage(chatcomponenttranslation); + Iterator iterator = map.values().iterator(); + + while (iterator.hasNext()) + { + Score score = (Score)iterator.next(); + p_147195_1_.addChatMessage(new ChatComponentTranslation("commands.scoreboard.players.list.player.entry", new Object[] {Integer.valueOf(score.getScorePoints()), score.func_96645_d().getDisplayName(), score.func_96645_d().getName()})); + } + } + else + { + Collection collection = scoreboard.getObjectiveNames(); + + if (collection.size() <= 0) + { + throw new CommandException("commands.scoreboard.players.list.empty", new Object[0]); + } + + ChatComponentTranslation chatcomponenttranslation1 = new ChatComponentTranslation("commands.scoreboard.players.list.count", new Object[] {Integer.valueOf(collection.size())}); + chatcomponenttranslation1.getChatStyle().setColor(EnumChatFormatting.DARK_GREEN); + p_147195_1_.addChatMessage(chatcomponenttranslation1); + p_147195_1_.addChatMessage(new ChatComponentText(joinNiceString(collection.toArray()))); + } + } + + protected void func_147197_m(ICommandSender p_147197_1_, String[] p_147197_2_, int p_147197_3_) + { + String s = p_147197_2_[p_147197_3_ - 1]; + String s1 = func_96332_d(p_147197_1_, p_147197_2_[p_147197_3_++]); + ScoreObjective scoreobjective = this.func_147189_a(p_147197_2_[p_147197_3_++], true); + int j = s.equalsIgnoreCase("set") ? parseInt(p_147197_1_, p_147197_2_[p_147197_3_++]) : parseIntWithMin(p_147197_1_, p_147197_2_[p_147197_3_++], 1); + Scoreboard scoreboard = this.func_147192_d(); + Score score = scoreboard.func_96529_a(s1, scoreobjective); + + if (s.equalsIgnoreCase("set")) + { + score.setScorePoints(j); + } + else if (s.equalsIgnoreCase("add")) + { + score.increseScore(j); + } + else + { + score.decreaseScore(j); + } + + notifyAdmins(p_147197_1_, "commands.scoreboard.players.set.success", new Object[] {scoreobjective.getName(), s1, Integer.valueOf(score.getScorePoints())}); + } + + protected void func_147187_n(ICommandSender p_147187_1_, String[] p_147187_2_, int p_147187_3_) + { + Scoreboard scoreboard = this.func_147192_d(); + String s = func_96332_d(p_147187_1_, p_147187_2_[p_147187_3_++]); + scoreboard.func_96515_c(s); + notifyAdmins(p_147187_1_, "commands.scoreboard.players.reset.success", new Object[] {s}); + } + + public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + if (par2ArrayOfStr.length == 1) + { + return getListOfStringsMatchingLastWord(par2ArrayOfStr, new String[] {"objectives", "players", "teams"}); + } + else + { + if (par2ArrayOfStr[0].equalsIgnoreCase("objectives")) + { + if (par2ArrayOfStr.length == 2) + { + return getListOfStringsMatchingLastWord(par2ArrayOfStr, new String[] {"list", "add", "remove", "setdisplay"}); + } + + if (par2ArrayOfStr[1].equalsIgnoreCase("add")) + { + if (par2ArrayOfStr.length == 4) + { + Set set = IScoreObjectiveCriteria.field_96643_a.keySet(); + return getListOfStringsFromIterableMatchingLastWord(par2ArrayOfStr, set); + } + } + else if (par2ArrayOfStr[1].equalsIgnoreCase("remove")) + { + if (par2ArrayOfStr.length == 3) + { + return getListOfStringsFromIterableMatchingLastWord(par2ArrayOfStr, this.func_147184_a(false)); + } + } + else if (par2ArrayOfStr[1].equalsIgnoreCase("setdisplay")) + { + if (par2ArrayOfStr.length == 3) + { + return getListOfStringsMatchingLastWord(par2ArrayOfStr, new String[] {"list", "sidebar", "belowName"}); + } + + if (par2ArrayOfStr.length == 4) + { + return getListOfStringsFromIterableMatchingLastWord(par2ArrayOfStr, this.func_147184_a(false)); + } + } + } + else if (par2ArrayOfStr[0].equalsIgnoreCase("players")) + { + if (par2ArrayOfStr.length == 2) + { + return getListOfStringsMatchingLastWord(par2ArrayOfStr, new String[] {"set", "add", "remove", "reset", "list"}); + } + + if (!par2ArrayOfStr[1].equalsIgnoreCase("set") && !par2ArrayOfStr[1].equalsIgnoreCase("add") && !par2ArrayOfStr[1].equalsIgnoreCase("remove")) + { + if ((par2ArrayOfStr[1].equalsIgnoreCase("reset") || par2ArrayOfStr[1].equalsIgnoreCase("list")) && par2ArrayOfStr.length == 3) + { + return getListOfStringsFromIterableMatchingLastWord(par2ArrayOfStr, this.func_147192_d().getObjectiveNames()); + } + } + else + { + if (par2ArrayOfStr.length == 3) + { + return getListOfStringsMatchingLastWord(par2ArrayOfStr, MinecraftServer.getServer().getAllUsernames()); + } + + if (par2ArrayOfStr.length == 4) + { + return getListOfStringsFromIterableMatchingLastWord(par2ArrayOfStr, this.func_147184_a(true)); + } + } + } + else if (par2ArrayOfStr[0].equalsIgnoreCase("teams")) + { + if (par2ArrayOfStr.length == 2) + { + return getListOfStringsMatchingLastWord(par2ArrayOfStr, new String[] {"add", "remove", "join", "leave", "empty", "list", "option"}); + } + + if (par2ArrayOfStr[1].equalsIgnoreCase("join")) + { + if (par2ArrayOfStr.length == 3) + { + return getListOfStringsFromIterableMatchingLastWord(par2ArrayOfStr, this.func_147192_d().getTeamNames()); + } + + if (par2ArrayOfStr.length >= 4) + { + return getListOfStringsMatchingLastWord(par2ArrayOfStr, MinecraftServer.getServer().getAllUsernames()); + } + } + else + { + if (par2ArrayOfStr[1].equalsIgnoreCase("leave")) + { + return getListOfStringsMatchingLastWord(par2ArrayOfStr, MinecraftServer.getServer().getAllUsernames()); + } + + if (!par2ArrayOfStr[1].equalsIgnoreCase("empty") && !par2ArrayOfStr[1].equalsIgnoreCase("list") && !par2ArrayOfStr[1].equalsIgnoreCase("remove")) + { + if (par2ArrayOfStr[1].equalsIgnoreCase("option")) + { + if (par2ArrayOfStr.length == 3) + { + return getListOfStringsFromIterableMatchingLastWord(par2ArrayOfStr, this.func_147192_d().getTeamNames()); + } + + if (par2ArrayOfStr.length == 4) + { + return getListOfStringsMatchingLastWord(par2ArrayOfStr, new String[] {"color", "friendlyfire", "seeFriendlyInvisibles"}); + } + + if (par2ArrayOfStr.length == 5) + { + if (par2ArrayOfStr[3].equalsIgnoreCase("color")) + { + return getListOfStringsFromIterableMatchingLastWord(par2ArrayOfStr, EnumChatFormatting.getValidValues(true, false)); + } + + if (par2ArrayOfStr[3].equalsIgnoreCase("friendlyfire") || par2ArrayOfStr[3].equalsIgnoreCase("seeFriendlyInvisibles")) + { + return getListOfStringsMatchingLastWord(par2ArrayOfStr, new String[] {"true", "false"}); + } + } + } + } + else if (par2ArrayOfStr.length == 3) + { + return getListOfStringsFromIterableMatchingLastWord(par2ArrayOfStr, this.func_147192_d().getTeamNames()); + } + } + } + + return null; + } + } + + protected List func_147184_a(boolean p_147184_1_) + { + Collection collection = this.func_147192_d().getScoreObjectives(); + ArrayList arraylist = new ArrayList(); + Iterator iterator = collection.iterator(); + + while (iterator.hasNext()) + { + ScoreObjective scoreobjective = (ScoreObjective)iterator.next(); + + if (!p_147184_1_ || !scoreobjective.getCriteria().isReadOnly()) + { + arraylist.add(scoreobjective.getName()); + } + } + + return arraylist; + } + + public boolean isUsernameIndex(String[] par1ArrayOfStr, int par2) + { + return par1ArrayOfStr[0].equalsIgnoreCase("players") ? par2 == 2 : (!par1ArrayOfStr[0].equalsIgnoreCase("teams") ? false : par2 == 2 || par2 == 3); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/server/CommandSetBlock.java b/src/main/java/net/minecraft/command/server/CommandSetBlock.java new file mode 100644 index 0000000..cc8b026 --- /dev/null +++ b/src/main/java/net/minecraft/command/server/CommandSetBlock.java @@ -0,0 +1,132 @@ +package net.minecraft.command.server; + +import java.util.List; +import net.minecraft.block.Block; +import net.minecraft.command.CommandBase; +import net.minecraft.command.CommandException; +import net.minecraft.command.ICommandSender; +import net.minecraft.command.WrongUsageException; +import net.minecraft.nbt.JsonToNBT; +import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.NBTException; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class CommandSetBlock extends CommandBase +{ + private static final String __OBFID = "CL_00000949"; + + public String getCommandName() + { + return "setblock"; + } + + public int getRequiredPermissionLevel() + { + return 2; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.setblock.usage"; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + if (par2ArrayOfStr.length >= 4) + { + int i = par1ICommandSender.getPlayerCoordinates().posX; + int j = par1ICommandSender.getPlayerCoordinates().posY; + int k = par1ICommandSender.getPlayerCoordinates().posZ; + i = MathHelper.floor_double(func_110666_a(par1ICommandSender, (double)i, par2ArrayOfStr[0])); + j = MathHelper.floor_double(func_110666_a(par1ICommandSender, (double)j, par2ArrayOfStr[1])); + k = MathHelper.floor_double(func_110666_a(par1ICommandSender, (double)k, par2ArrayOfStr[2])); + Block block = CommandBase.getBlockByText(par1ICommandSender, par2ArrayOfStr[3]); + int l = 0; + + if (par2ArrayOfStr.length >= 5) + { + l = parseIntBounded(par1ICommandSender, par2ArrayOfStr[4], 0, 15); + } + + World world = par1ICommandSender.getEntityWorld(); + + if (!world.blockExists(i, j, k)) + { + throw new CommandException("commands.setblock.outOfWorld", new Object[0]); + } + else + { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + boolean flag = false; + + if (par2ArrayOfStr.length >= 7 && block.hasTileEntity()) + { + String s = func_147178_a(par1ICommandSender, par2ArrayOfStr, 6).getUnformattedText(); + + try + { + NBTBase nbtbase = JsonToNBT.func_150315_a(s); + + if (!(nbtbase instanceof NBTTagCompound)) + { + throw new CommandException("commands.setblock.tagError", new Object[] {"Not a valid tag"}); + } + + nbttagcompound = (NBTTagCompound)nbtbase; + flag = true; + } + catch (NBTException nbtexception) + { + throw new CommandException("commands.setblock.tagError", new Object[] {nbtexception.getMessage()}); + } + } + + if (par2ArrayOfStr.length >= 6) + { + if (par2ArrayOfStr[5].equals("destroy")) + { + world.func_147480_a(i, j, k, true); + } + else if (par2ArrayOfStr[5].equals("keep") && !world.isAirBlock(i, j, k)) + { + throw new CommandException("commands.setblock.noChange", new Object[0]); + } + } + + if (!world.setBlock(i, j, k, block, l, 3)) + { + throw new CommandException("commands.setblock.noChange", new Object[0]); + } + else + { + if (flag) + { + TileEntity tileentity = world.getTileEntity(i, j, k); + + if (tileentity != null) + { + nbttagcompound.setInteger("x", i); + nbttagcompound.setInteger("y", j); + nbttagcompound.setInteger("z", k); + tileentity.readFromNBT(nbttagcompound); + } + } + + notifyAdmins(par1ICommandSender, "commands.setblock.success", new Object[0]); + } + } + } + else + { + throw new WrongUsageException("commands.setblock.usage", new Object[0]); + } + } + + public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + return par2ArrayOfStr.length == 4 ? getListOfStringsFromIterableMatchingLastWord(par2ArrayOfStr, Block.blockRegistry.getKeys()) : (par2ArrayOfStr.length == 6 ? getListOfStringsMatchingLastWord(par2ArrayOfStr, new String[] {"replace", "destroy", "keep"}): null); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/server/CommandSetDefaultSpawnpoint.java b/src/main/java/net/minecraft/command/server/CommandSetDefaultSpawnpoint.java new file mode 100644 index 0000000..ca01957 --- /dev/null +++ b/src/main/java/net/minecraft/command/server/CommandSetDefaultSpawnpoint.java @@ -0,0 +1,56 @@ +package net.minecraft.command.server; + +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandSender; +import net.minecraft.command.WrongUsageException; +import net.minecraft.util.ChunkCoordinates; + +public class CommandSetDefaultSpawnpoint extends CommandBase +{ + private static final String __OBFID = "CL_00000973"; + + public String getCommandName() + { + return "setworldspawn"; + } + + public int getRequiredPermissionLevel() + { + return 2; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.setworldspawn.usage"; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + if (par2ArrayOfStr.length == 3) + { + if (par1ICommandSender.getEntityWorld() == null) + { + throw new WrongUsageException("commands.setworldspawn.usage", new Object[0]); + } + + byte b0 = 0; + int l = b0 + 1; + int i = parseIntBounded(par1ICommandSender, par2ArrayOfStr[b0], -30000000, 30000000); + int j = parseIntBounded(par1ICommandSender, par2ArrayOfStr[l++], 0, 256); + int k = parseIntBounded(par1ICommandSender, par2ArrayOfStr[l++], -30000000, 30000000); + par1ICommandSender.getEntityWorld().setSpawnLocation(i, j, k); + notifyAdmins(par1ICommandSender, "commands.setworldspawn.success", new Object[] {Integer.valueOf(i), Integer.valueOf(j), Integer.valueOf(k)}); + } + else + { + if (par2ArrayOfStr.length != 0) + { + throw new WrongUsageException("commands.setworldspawn.usage", new Object[0]); + } + + ChunkCoordinates chunkcoordinates = getCommandSenderAsPlayer(par1ICommandSender).getPlayerCoordinates(); + par1ICommandSender.getEntityWorld().setSpawnLocation(chunkcoordinates.posX, chunkcoordinates.posY, chunkcoordinates.posZ); + notifyAdmins(par1ICommandSender, "commands.setworldspawn.success", new Object[] {Integer.valueOf(chunkcoordinates.posX), Integer.valueOf(chunkcoordinates.posY), Integer.valueOf(chunkcoordinates.posZ)}); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/server/CommandStop.java b/src/main/java/net/minecraft/command/server/CommandStop.java new file mode 100644 index 0000000..029bf41 --- /dev/null +++ b/src/main/java/net/minecraft/command/server/CommandStop.java @@ -0,0 +1,26 @@ +package net.minecraft.command.server; + +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandSender; +import net.minecraft.server.MinecraftServer; + +public class CommandStop extends CommandBase +{ + private static final String __OBFID = "CL_00001132"; + + public String getCommandName() + { + return "stop"; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.stop.usage"; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + notifyAdmins(par1ICommandSender, "commands.stop.start", new Object[0]); + MinecraftServer.getServer().initiateShutdown(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/server/CommandSummon.java b/src/main/java/net/minecraft/command/server/CommandSummon.java new file mode 100644 index 0000000..1e66afa --- /dev/null +++ b/src/main/java/net/minecraft/command/server/CommandSummon.java @@ -0,0 +1,140 @@ +package net.minecraft.command.server; + +import java.util.List; +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandSender; +import net.minecraft.command.WrongUsageException; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityList; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.nbt.JsonToNBT; +import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.NBTException; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.IChatComponent; +import net.minecraft.world.World; + +public class CommandSummon extends CommandBase +{ + private static final String __OBFID = "CL_00001158"; + + public String getCommandName() + { + return "summon"; + } + + public int getRequiredPermissionLevel() + { + return 2; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.summon.usage"; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + if (par2ArrayOfStr.length >= 1) + { + String s = par2ArrayOfStr[0]; + double d0 = (double)par1ICommandSender.getPlayerCoordinates().posX + 0.5D; + double d1 = (double)par1ICommandSender.getPlayerCoordinates().posY; + double d2 = (double)par1ICommandSender.getPlayerCoordinates().posZ + 0.5D; + + if (par2ArrayOfStr.length >= 4) + { + d0 = func_110666_a(par1ICommandSender, d0, par2ArrayOfStr[1]); + d1 = func_110666_a(par1ICommandSender, d1, par2ArrayOfStr[2]); + d2 = func_110666_a(par1ICommandSender, d2, par2ArrayOfStr[3]); + } + + World world = par1ICommandSender.getEntityWorld(); + + if (!world.blockExists((int)d0, (int)d1, (int)d2)) + { + notifyAdmins(par1ICommandSender, "commands.summon.outOfWorld", new Object[0]); + } + else + { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + boolean flag = false; + + if (par2ArrayOfStr.length >= 5) + { + IChatComponent ichatcomponent = func_147178_a(par1ICommandSender, par2ArrayOfStr, 4); + + try + { + NBTBase nbtbase = JsonToNBT.func_150315_a(ichatcomponent.getUnformattedText()); + + if (!(nbtbase instanceof NBTTagCompound)) + { + notifyAdmins(par1ICommandSender, "commands.summon.tagError", new Object[] {"Not a valid tag"}); + return; + } + + nbttagcompound = (NBTTagCompound)nbtbase; + flag = true; + } + catch (NBTException nbtexception) + { + notifyAdmins(par1ICommandSender, "commands.summon.tagError", new Object[] {nbtexception.getMessage()}); + return; + } + } + + nbttagcompound.setString("id", s); + Entity entity1 = EntityList.createEntityFromNBT(nbttagcompound, world); + + if (entity1 != null) + { + entity1.setLocationAndAngles(d0, d1, d2, entity1.rotationYaw, entity1.rotationPitch); + + if (!flag && entity1 instanceof EntityLiving) + { + ((EntityLiving)entity1).onSpawnWithEgg((IEntityLivingData)null); + } + + world.spawnEntityInWorld(entity1); + Entity entity2 = entity1; + + for (NBTTagCompound nbttagcompound1 = nbttagcompound; nbttagcompound1.hasKey("Riding", 10); nbttagcompound1 = nbttagcompound1.getCompoundTag("Riding")) + { + Entity entity = EntityList.createEntityFromNBT(nbttagcompound1.getCompoundTag("Riding"), world); + + if (entity != null) + { + entity.setLocationAndAngles(d0, d1, d2, entity.rotationYaw, entity.rotationPitch); + world.spawnEntityInWorld(entity); + entity2.mountEntity(entity); + } + + entity2 = entity; + } + + notifyAdmins(par1ICommandSender, "commands.summon.success", new Object[0]); + } + else + { + notifyAdmins(par1ICommandSender, "commands.summon.failed", new Object[0]); + } + } + } + else + { + throw new WrongUsageException("commands.summon.usage", new Object[0]); + } + } + + public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + return par2ArrayOfStr.length == 1 ? getListOfStringsMatchingLastWord(par2ArrayOfStr, this.func_147182_d()) : null; + } + + protected String[] func_147182_d() + { + return (String[])EntityList.func_151515_b().toArray(new String[0]); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/server/CommandTeleport.java b/src/main/java/net/minecraft/command/server/CommandTeleport.java new file mode 100644 index 0000000..e56bf2c --- /dev/null +++ b/src/main/java/net/minecraft/command/server/CommandTeleport.java @@ -0,0 +1,99 @@ +package net.minecraft.command.server; + +import java.util.List; +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandSender; +import net.minecraft.command.PlayerNotFoundException; +import net.minecraft.command.WrongUsageException; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.server.MinecraftServer; + +public class CommandTeleport extends CommandBase +{ + private static final String __OBFID = "CL_00001180"; + + public String getCommandName() + { + return "tp"; + } + + public int getRequiredPermissionLevel() + { + return 2; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.tp.usage"; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + if (par2ArrayOfStr.length < 1) + { + throw new WrongUsageException("commands.tp.usage", new Object[0]); + } + else + { + EntityPlayerMP entityplayermp; + + if (par2ArrayOfStr.length != 2 && par2ArrayOfStr.length != 4) + { + entityplayermp = getCommandSenderAsPlayer(par1ICommandSender); + } + else + { + entityplayermp = getPlayer(par1ICommandSender, par2ArrayOfStr[0]); + + if (entityplayermp == null) + { + throw new PlayerNotFoundException(); + } + } + + if (par2ArrayOfStr.length != 3 && par2ArrayOfStr.length != 4) + { + if (par2ArrayOfStr.length == 1 || par2ArrayOfStr.length == 2) + { + EntityPlayerMP entityplayermp1 = getPlayer(par1ICommandSender, par2ArrayOfStr[par2ArrayOfStr.length - 1]); + + if (entityplayermp1 == null) + { + throw new PlayerNotFoundException(); + } + + if (entityplayermp1.worldObj != entityplayermp.worldObj) + { + notifyAdmins(par1ICommandSender, "commands.tp.notSameDimension", new Object[0]); + return; + } + + entityplayermp.mountEntity((Entity)null); + entityplayermp.playerNetServerHandler.setPlayerLocation(entityplayermp1.posX, entityplayermp1.posY, entityplayermp1.posZ, entityplayermp1.rotationYaw, entityplayermp1.rotationPitch); + notifyAdmins(par1ICommandSender, "commands.tp.success", new Object[] {entityplayermp.getCommandSenderName(), entityplayermp1.getCommandSenderName()}); + } + } + else if (entityplayermp.worldObj != null) + { + int i = par2ArrayOfStr.length - 3; + double d0 = func_110666_a(par1ICommandSender, entityplayermp.posX, par2ArrayOfStr[i++]); + double d1 = func_110665_a(par1ICommandSender, entityplayermp.posY, par2ArrayOfStr[i++], 0, 0); + double d2 = func_110666_a(par1ICommandSender, entityplayermp.posZ, par2ArrayOfStr[i++]); + entityplayermp.mountEntity((Entity)null); + entityplayermp.setPositionAndUpdate(d0, d1, d2); + notifyAdmins(par1ICommandSender, "commands.tp.success.coordinates", new Object[] {entityplayermp.getCommandSenderName(), Double.valueOf(d0), Double.valueOf(d1), Double.valueOf(d2)}); + } + } + } + + public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + return par2ArrayOfStr.length != 1 && par2ArrayOfStr.length != 2 ? null : getListOfStringsMatchingLastWord(par2ArrayOfStr, MinecraftServer.getServer().getAllUsernames()); + } + + public boolean isUsernameIndex(String[] par1ArrayOfStr, int par2) + { + return par2 == 0; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/server/CommandTestFor.java b/src/main/java/net/minecraft/command/server/CommandTestFor.java new file mode 100644 index 0000000..b6fc961 --- /dev/null +++ b/src/main/java/net/minecraft/command/server/CommandTestFor.java @@ -0,0 +1,47 @@ +package net.minecraft.command.server; + +import net.minecraft.command.CommandBase; +import net.minecraft.command.CommandException; +import net.minecraft.command.ICommandSender; +import net.minecraft.command.WrongUsageException; + +public class CommandTestFor extends CommandBase +{ + private static final String __OBFID = "CL_00001182"; + + public String getCommandName() + { + return "testfor"; + } + + public int getRequiredPermissionLevel() + { + return 2; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.testfor.usage"; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + if (par2ArrayOfStr.length != 1) + { + throw new WrongUsageException("commands.testfor.usage", new Object[0]); + } + else if (!(par1ICommandSender instanceof CommandBlockLogic)) + { + throw new CommandException("commands.testfor.failed", new Object[0]); + } + else + { + getPlayer(par1ICommandSender, par2ArrayOfStr[0]); + } + } + + public boolean isUsernameIndex(String[] par1ArrayOfStr, int par2) + { + return par2 == 0; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/server/CommandTestForBlock.java b/src/main/java/net/minecraft/command/server/CommandTestForBlock.java new file mode 100644 index 0000000..a76be0d --- /dev/null +++ b/src/main/java/net/minecraft/command/server/CommandTestForBlock.java @@ -0,0 +1,194 @@ +package net.minecraft.command.server; + +import java.util.Iterator; +import java.util.List; +import net.minecraft.block.Block; +import net.minecraft.command.CommandBase; +import net.minecraft.command.CommandException; +import net.minecraft.command.ICommandSender; +import net.minecraft.command.NumberInvalidException; +import net.minecraft.command.WrongUsageException; +import net.minecraft.nbt.JsonToNBT; +import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.NBTException; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class CommandTestForBlock extends CommandBase +{ + private static final String __OBFID = "CL_00001181"; + + public String getCommandName() + { + return "testforblock"; + } + + public int getRequiredPermissionLevel() + { + return 2; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.testforblock.usage"; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + if (par2ArrayOfStr.length >= 4) + { + int i = par1ICommandSender.getPlayerCoordinates().posX; + int j = par1ICommandSender.getPlayerCoordinates().posY; + int k = par1ICommandSender.getPlayerCoordinates().posZ; + i = MathHelper.floor_double(func_110666_a(par1ICommandSender, (double)i, par2ArrayOfStr[0])); + j = MathHelper.floor_double(func_110666_a(par1ICommandSender, (double)j, par2ArrayOfStr[1])); + k = MathHelper.floor_double(func_110666_a(par1ICommandSender, (double)k, par2ArrayOfStr[2])); + Block block = Block.getBlockFromName(par2ArrayOfStr[3]); + + if (block == null) + { + throw new NumberInvalidException("commands.setblock.notFound", new Object[] {par2ArrayOfStr[3]}); + } + else + { + int l = -1; + + if (par2ArrayOfStr.length >= 5) + { + l = parseIntBounded(par1ICommandSender, par2ArrayOfStr[4], -1, 15); + } + + World world = par1ICommandSender.getEntityWorld(); + + if (!world.blockExists(i, j, k)) + { + throw new CommandException("commands.testforblock.outOfWorld", new Object[0]); + } + else + { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + boolean flag = false; + + if (par2ArrayOfStr.length >= 6 && block.hasTileEntity()) + { + String s = func_147178_a(par1ICommandSender, par2ArrayOfStr, 5).getUnformattedText(); + + try + { + NBTBase nbtbase = JsonToNBT.func_150315_a(s); + + if (!(nbtbase instanceof NBTTagCompound)) + { + throw new CommandException("commands.setblock.tagError", new Object[] {"Not a valid tag"}); + } + + nbttagcompound = (NBTTagCompound)nbtbase; + flag = true; + } + catch (NBTException nbtexception) + { + throw new CommandException("commands.setblock.tagError", new Object[] {nbtexception.getMessage()}); + } + } + + Block block1 = world.getBlock(i, j, k); + + if (block1 != block) + { + throw new CommandException("commands.testforblock.failed.tile", new Object[] {Integer.valueOf(i), Integer.valueOf(j), Integer.valueOf(k), block1.getLocalizedName(), block.getLocalizedName()}); + } + else + { + if (l > -1) + { + int i1 = world.getBlockMetadata(i, j, k); + + if (i1 != l) + { + throw new CommandException("commands.testforblock.failed.data", new Object[] {Integer.valueOf(i), Integer.valueOf(j), Integer.valueOf(k), Integer.valueOf(i1), Integer.valueOf(l)}); + } + } + + if (flag) + { + TileEntity tileentity = world.getTileEntity(i, j, k); + + if (tileentity == null) + { + throw new CommandException("commands.testforblock.failed.tileEntity", new Object[] {Integer.valueOf(i), Integer.valueOf(j), Integer.valueOf(k)}); + } + + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + tileentity.writeToNBT(nbttagcompound1); + + if (!this.func_147181_a(nbttagcompound, nbttagcompound1)) + { + throw new CommandException("commands.testforblock.failed.nbt", new Object[] {Integer.valueOf(i), Integer.valueOf(j), Integer.valueOf(k)}); + } + } + + par1ICommandSender.addChatMessage(new ChatComponentTranslation("commands.testforblock.success", new Object[] {Integer.valueOf(i), Integer.valueOf(j), Integer.valueOf(k)})); + } + } + } + } + else + { + throw new WrongUsageException("commands.testforblock.usage", new Object[0]); + } + } + + public boolean func_147181_a(NBTBase p_147181_1_, NBTBase p_147181_2_) + { + if (p_147181_1_ == p_147181_2_) + { + return true; + } + else if (p_147181_1_ == null) + { + return true; + } + else if (p_147181_2_ == null) + { + return false; + } + else if (!p_147181_1_.getClass().equals(p_147181_2_.getClass())) + { + return false; + } + else if (p_147181_1_ instanceof NBTTagCompound) + { + NBTTagCompound nbttagcompound = (NBTTagCompound)p_147181_1_; + NBTTagCompound nbttagcompound1 = (NBTTagCompound)p_147181_2_; + Iterator iterator = nbttagcompound.func_150296_c().iterator(); + String s; + NBTBase nbtbase2; + + do + { + if (!iterator.hasNext()) + { + return true; + } + + s = (String)iterator.next(); + nbtbase2 = nbttagcompound.getTag(s); + } + while (this.func_147181_a(nbtbase2, nbttagcompound1.getTag(s))); + + return false; + } + else + { + return p_147181_1_.equals(p_147181_2_); + } + } + + public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + return par2ArrayOfStr.length == 4 ? getListOfStringsFromIterableMatchingLastWord(par2ArrayOfStr, Block.blockRegistry.getKeys()) : null; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/command/server/CommandWhitelist.java b/src/main/java/net/minecraft/command/server/CommandWhitelist.java new file mode 100644 index 0000000..4977c91 --- /dev/null +++ b/src/main/java/net/minecraft/command/server/CommandWhitelist.java @@ -0,0 +1,133 @@ +package net.minecraft.command.server; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandSender; +import net.minecraft.command.WrongUsageException; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.ChatComponentTranslation; + +public class CommandWhitelist extends CommandBase +{ + private static final String __OBFID = "CL_00001186"; + + public String getCommandName() + { + return "whitelist"; + } + + public int getRequiredPermissionLevel() + { + return 3; + } + + public String getCommandUsage(ICommandSender par1ICommandSender) + { + return "commands.whitelist.usage"; + } + + public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + if (par2ArrayOfStr.length >= 1) + { + if (par2ArrayOfStr[0].equals("on")) + { + MinecraftServer.getServer().getConfigurationManager().setWhiteListEnabled(true); + notifyAdmins(par1ICommandSender, "commands.whitelist.enabled", new Object[0]); + return; + } + + if (par2ArrayOfStr[0].equals("off")) + { + MinecraftServer.getServer().getConfigurationManager().setWhiteListEnabled(false); + notifyAdmins(par1ICommandSender, "commands.whitelist.disabled", new Object[0]); + return; + } + + if (par2ArrayOfStr[0].equals("list")) + { + par1ICommandSender.addChatMessage(new ChatComponentTranslation("commands.whitelist.list", new Object[] {Integer.valueOf(MinecraftServer.getServer().getConfigurationManager().getWhiteListedPlayers().size()), Integer.valueOf(MinecraftServer.getServer().getConfigurationManager().getAvailablePlayerDat().length)})); + Set set = MinecraftServer.getServer().getConfigurationManager().getWhiteListedPlayers(); + par1ICommandSender.addChatMessage(new ChatComponentText(joinNiceString(set.toArray(new String[set.size()])))); + return; + } + + if (par2ArrayOfStr[0].equals("add")) + { + if (par2ArrayOfStr.length < 2) + { + throw new WrongUsageException("commands.whitelist.add.usage", new Object[0]); + } + + MinecraftServer.getServer().getConfigurationManager().addToWhiteList(par2ArrayOfStr[1]); + notifyAdmins(par1ICommandSender, "commands.whitelist.add.success", new Object[] {par2ArrayOfStr[1]}); + return; + } + + if (par2ArrayOfStr[0].equals("remove")) + { + if (par2ArrayOfStr.length < 2) + { + throw new WrongUsageException("commands.whitelist.remove.usage", new Object[0]); + } + + MinecraftServer.getServer().getConfigurationManager().removeFromWhitelist(par2ArrayOfStr[1]); + notifyAdmins(par1ICommandSender, "commands.whitelist.remove.success", new Object[] {par2ArrayOfStr[1]}); + return; + } + + if (par2ArrayOfStr[0].equals("reload")) + { + MinecraftServer.getServer().getConfigurationManager().loadWhiteList(); + notifyAdmins(par1ICommandSender, "commands.whitelist.reloaded", new Object[0]); + return; + } + } + + throw new WrongUsageException("commands.whitelist.usage", new Object[0]); + } + + public List addTabCompletionOptions(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) + { + if (par2ArrayOfStr.length == 1) + { + return getListOfStringsMatchingLastWord(par2ArrayOfStr, new String[] {"on", "off", "list", "add", "remove", "reload"}); + } + else + { + if (par2ArrayOfStr.length == 2) + { + if (par2ArrayOfStr[0].equals("add")) + { + String[] astring1 = MinecraftServer.getServer().getConfigurationManager().getAvailablePlayerDat(); + ArrayList arraylist = new ArrayList(); + String s = par2ArrayOfStr[par2ArrayOfStr.length - 1]; + String[] astring2 = astring1; + int i = astring1.length; + + for (int j = 0; j < i; ++j) + { + String s1 = astring2[j]; + + if (doesStringStartWith(s, s1) && !MinecraftServer.getServer().getConfigurationManager().getWhiteListedPlayers().contains(s1)) + { + arraylist.add(s1); + } + } + + return arraylist; + } + + if (par2ArrayOfStr[0].equals("remove")) + { + return getListOfStringsFromIterableMatchingLastWord(par2ArrayOfStr, MinecraftServer.getServer().getConfigurationManager().getWhiteListedPlayers()); + } + } + + return null; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/crash/CrashReport.java b/src/main/java/net/minecraft/crash/CrashReport.java new file mode 100644 index 0000000..79b978e --- /dev/null +++ b/src/main/java/net/minecraft/crash/CrashReport.java @@ -0,0 +1,380 @@ +package net.minecraft.crash; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.File; +import java.io.FileWriter; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.lang.management.ManagementFactory; +import java.lang.management.RuntimeMXBean; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.List; +import java.util.concurrent.Callable; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.ReportedException; +import net.minecraft.world.gen.layer.IntCache; +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.ArrayUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class CrashReport +{ + private static final Logger logger = LogManager.getLogger(); + private final String description; + private final Throwable cause; + private final CrashReportCategory theReportCategory = new CrashReportCategory(this, "System Details"); + private final List crashReportSections = new ArrayList(); + private File crashReportFile; + private boolean field_85059_f = true; + private StackTraceElement[] stacktrace = new StackTraceElement[0]; + private static final String __OBFID = "CL_00000990"; + + public CrashReport(String par1Str, Throwable par2Throwable) + { + this.description = par1Str; + this.cause = par2Throwable; + this.populateEnvironment(); + } + + private void populateEnvironment() + { + this.theReportCategory.addCrashSectionCallable("Minecraft Version", new Callable() + { + private static final String __OBFID = "CL_00001197"; + public String call() + { + return "1.7.2"; + } + }); + this.theReportCategory.addCrashSectionCallable("Operating System", new Callable() + { + private static final String __OBFID = "CL_00001222"; + public String call() + { + return System.getProperty("os.name") + " (" + System.getProperty("os.arch") + ") version " + System.getProperty("os.version"); + } + }); + this.theReportCategory.addCrashSectionCallable("Java Version", new Callable() + { + private static final String __OBFID = "CL_00001248"; + public String call() + { + return System.getProperty("java.version") + ", " + System.getProperty("java.vendor"); + } + }); + this.theReportCategory.addCrashSectionCallable("Java VM Version", new Callable() + { + private static final String __OBFID = "CL_00001275"; + public String call() + { + return System.getProperty("java.vm.name") + " (" + System.getProperty("java.vm.info") + "), " + System.getProperty("java.vm.vendor"); + } + }); + this.theReportCategory.addCrashSectionCallable("Memory", new Callable() + { + private static final String __OBFID = "CL_00001302"; + public String call() + { + Runtime runtime = Runtime.getRuntime(); + long i = runtime.maxMemory(); + long j = runtime.totalMemory(); + long k = runtime.freeMemory(); + long l = i / 1024L / 1024L; + long i1 = j / 1024L / 1024L; + long j1 = k / 1024L / 1024L; + return k + " bytes (" + j1 + " MB) / " + j + " bytes (" + i1 + " MB) up to " + i + " bytes (" + l + " MB)"; + } + }); + this.theReportCategory.addCrashSectionCallable("JVM Flags", new Callable() + { + private static final String __OBFID = "CL_00001329"; + public String call() + { + RuntimeMXBean runtimemxbean = ManagementFactory.getRuntimeMXBean(); + List list = runtimemxbean.getInputArguments(); + int i = 0; + StringBuilder stringbuilder = new StringBuilder(); + Iterator iterator = list.iterator(); + + while (iterator.hasNext()) + { + String s = (String)iterator.next(); + + if (s.startsWith("-X")) + { + if (i++ > 0) + { + stringbuilder.append(" "); + } + + stringbuilder.append(s); + } + } + + return String.format("%d total; %s", new Object[] {Integer.valueOf(i), stringbuilder.toString()}); + } + }); + this.theReportCategory.addCrashSectionCallable("AABB Pool Size", new Callable() + { + private static final String __OBFID = "CL_00001355"; + public String call() + { + int i = AxisAlignedBB.getAABBPool().getlistAABBsize(); + int j = 56 * i; + int k = j / 1024 / 1024; + int l = AxisAlignedBB.getAABBPool().getnextPoolIndex(); + int i1 = 56 * l; + int j1 = i1 / 1024 / 1024; + return i + " (" + j + " bytes; " + k + " MB) allocated, " + l + " (" + i1 + " bytes; " + j1 + " MB) used"; + } + }); + this.theReportCategory.addCrashSectionCallable("IntCache", new Callable() + { + private static final String __OBFID = "CL_00001382"; + public String call() throws SecurityException, NoSuchFieldException, IllegalAccessException, IllegalArgumentException + { + return IntCache.getCacheSizes(); + } + }); + FMLCommonHandler.instance().enhanceCrashReport(this, this.theReportCategory); + } + + public String getDescription() + { + return this.description; + } + + public Throwable getCrashCause() + { + return this.cause; + } + + public void getSectionsInStringBuilder(StringBuilder par1StringBuilder) + { + if ((this.stacktrace == null || this.stacktrace.length <= 0) && this.crashReportSections.size() > 0) + { + this.stacktrace = (StackTraceElement[])ArrayUtils.subarray(((CrashReportCategory)this.crashReportSections.get(0)).func_147152_a(), 0, 1); + } + + if (this.stacktrace != null && this.stacktrace.length > 0) + { + par1StringBuilder.append("-- Head --\n"); + par1StringBuilder.append("Stacktrace:\n"); + StackTraceElement[] astacktraceelement = this.stacktrace; + int i = astacktraceelement.length; + + for (int j = 0; j < i; ++j) + { + StackTraceElement stacktraceelement = astacktraceelement[j]; + par1StringBuilder.append("\t").append("at ").append(stacktraceelement.toString()); + par1StringBuilder.append("\n"); + } + + par1StringBuilder.append("\n"); + } + + Iterator iterator = this.crashReportSections.iterator(); + + while (iterator.hasNext()) + { + CrashReportCategory crashreportcategory = (CrashReportCategory)iterator.next(); + crashreportcategory.appendToStringBuilder(par1StringBuilder); + par1StringBuilder.append("\n\n"); + } + + this.theReportCategory.appendToStringBuilder(par1StringBuilder); + } + + public String getCauseStackTraceOrString() + { + StringWriter stringwriter = null; + PrintWriter printwriter = null; + Object object = this.cause; + + if (((Throwable)object).getMessage() == null) + { + if (object instanceof NullPointerException) + { + object = new NullPointerException(this.description); + } + else if (object instanceof StackOverflowError) + { + object = new StackOverflowError(this.description); + } + else if (object instanceof OutOfMemoryError) + { + object = new OutOfMemoryError(this.description); + } + + ((Throwable)object).setStackTrace(this.cause.getStackTrace()); + } + + String s = ((Throwable)object).toString(); + + try + { + stringwriter = new StringWriter(); + printwriter = new PrintWriter(stringwriter); + ((Throwable)object).printStackTrace(printwriter); + s = stringwriter.toString(); + } + finally + { + IOUtils.closeQuietly(stringwriter); + IOUtils.closeQuietly(printwriter); + } + + return s; + } + + public String getCompleteReport() + { + StringBuilder stringbuilder = new StringBuilder(); + stringbuilder.append("---- Minecraft Crash Report ----\n"); + stringbuilder.append("// "); + stringbuilder.append(getWittyComment()); + stringbuilder.append("\n\n"); + stringbuilder.append("Time: "); + stringbuilder.append((new SimpleDateFormat()).format(new Date())); + stringbuilder.append("\n"); + stringbuilder.append("Description: "); + stringbuilder.append(this.description); + stringbuilder.append("\n\n"); + stringbuilder.append(this.getCauseStackTraceOrString()); + stringbuilder.append("\n\nA detailed walkthrough of the error, its code path and all known details is as follows:\n"); + + for (int i = 0; i < 87; ++i) + { + stringbuilder.append("-"); + } + + stringbuilder.append("\n\n"); + this.getSectionsInStringBuilder(stringbuilder); + return stringbuilder.toString(); + } + + @SideOnly(Side.CLIENT) + public File getFile() + { + return this.crashReportFile; + } + + public boolean saveToFile(File p_147149_1_) + { + if (this.crashReportFile != null) + { + return false; + } + else + { + if (p_147149_1_.getParentFile() != null) + { + p_147149_1_.getParentFile().mkdirs(); + } + + try + { + FileWriter filewriter = new FileWriter(p_147149_1_); + filewriter.write(this.getCompleteReport()); + filewriter.close(); + this.crashReportFile = p_147149_1_; + return true; + } + catch (Throwable throwable) + { + logger.error("Could not save crash report to " + p_147149_1_, throwable); + return false; + } + } + } + + public CrashReportCategory getCategory() + { + return this.theReportCategory; + } + + public CrashReportCategory makeCategory(String par1Str) + { + return this.makeCategoryDepth(par1Str, 1); + } + + public CrashReportCategory makeCategoryDepth(String par1Str, int par2) + { + CrashReportCategory crashreportcategory = new CrashReportCategory(this, par1Str); + + if (this.field_85059_f) + { + int j = crashreportcategory.getPrunedStackTrace(par2); + StackTraceElement[] astacktraceelement = this.cause.getStackTrace(); + StackTraceElement stacktraceelement = null; + StackTraceElement stacktraceelement1 = null; + + int idx = astacktraceelement.length - j; //Forge fix AIOOB exception. + if (astacktraceelement != null && idx < astacktraceelement.length && idx >= 0) + { + stacktraceelement = astacktraceelement[astacktraceelement.length - j]; + + if (astacktraceelement.length + 1 - j < astacktraceelement.length) + { + stacktraceelement1 = astacktraceelement[astacktraceelement.length + 1 - j]; + } + } + + this.field_85059_f = crashreportcategory.firstTwoElementsOfStackTraceMatch(stacktraceelement, stacktraceelement1); + + if (j > 0 && !this.crashReportSections.isEmpty()) + { + CrashReportCategory crashreportcategory1 = (CrashReportCategory)this.crashReportSections.get(this.crashReportSections.size() - 1); + crashreportcategory1.trimStackTraceEntriesFromBottom(j); + } + else if (astacktraceelement != null && astacktraceelement.length >= j) + { + this.stacktrace = new StackTraceElement[astacktraceelement.length - j]; + System.arraycopy(astacktraceelement, 0, this.stacktrace, 0, this.stacktrace.length); + } + else + { + this.field_85059_f = false; + } + } + + this.crashReportSections.add(crashreportcategory); + return crashreportcategory; + } + + private static String getWittyComment() + { + String[] astring = new String[] {"Who set us up the TNT?", "Everything\'s going to plan. No, really, that was supposed to happen.", "Uh... Did I do that?", "Oops.", "Why did you do that?", "I feel sad now :(", "My bad.", "I\'m sorry, Dave.", "I let you down. Sorry :(", "On the bright side, I bought you a teddy bear!", "Daisy, daisy...", "Oh - I know what I did wrong!", "Hey, that tickles! Hehehe!", "I blame Dinnerbone.", "You should try our sister game, Minceraft!", "Don\'t be sad. I\'ll do better next time, I promise!", "Don\'t be sad, have a hug! <3", "I just don\'t know what went wrong :(", "Shall we play a game?", "Quite honestly, I wouldn\'t worry myself about that.", "I bet Cylons wouldn\'t have this problem.", "Sorry :(", "Surprise! Haha. Well, this is awkward.", "Would you like a cupcake?", "Hi. I\'m Minecraft, and I\'m a crashaholic.", "Ooh. Shiny.", "This doesn\'t make any sense!", "Why is it breaking :(", "Don\'t do that.", "Ouch. That hurt :(", "You\'re mean.", "This is a token for 1 free hug. Redeem at your nearest Mojangsta: [~~HUG~~]", "There are four lights!"}; + + try + { + return astring[(int)(System.nanoTime() % (long)astring.length)]; + } + catch (Throwable throwable) + { + return "Witty comment unavailable :("; + } + } + + public static CrashReport makeCrashReport(Throwable par0Throwable, String par1Str) + { + CrashReport crashreport; + + if (par0Throwable instanceof ReportedException) + { + crashreport = ((ReportedException)par0Throwable).getCrashReport(); + } + else + { + crashreport = new CrashReport(par1Str, par0Throwable); + } + + return crashreport; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/crash/CrashReportCategory.java b/src/main/java/net/minecraft/crash/CrashReportCategory.java new file mode 100644 index 0000000..8e2bb2a --- /dev/null +++ b/src/main/java/net/minecraft/crash/CrashReportCategory.java @@ -0,0 +1,293 @@ +package net.minecraft.crash; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.concurrent.Callable; +import net.minecraft.block.Block; +import net.minecraft.util.MathHelper; + +public class CrashReportCategory +{ + private final CrashReport theCrashReport; + private final String field_85076_b; + private final List field_85077_c = new ArrayList(); + private StackTraceElement[] stackTrace = new StackTraceElement[0]; + private static final String __OBFID = "CL_00001409"; + + public CrashReportCategory(CrashReport par1CrashReport, String par2Str) + { + this.theCrashReport = par1CrashReport; + this.field_85076_b = par2Str; + } + + @SideOnly(Side.CLIENT) + public static String func_85074_a(double par0, double par2, double par4) + { + return String.format("%.2f,%.2f,%.2f - %s", new Object[] {Double.valueOf(par0), Double.valueOf(par2), Double.valueOf(par4), getLocationInfo(MathHelper.floor_double(par0), MathHelper.floor_double(par2), MathHelper.floor_double(par4))}); + } + + public static String getLocationInfo(int par0, int par1, int par2) + { + StringBuilder stringbuilder = new StringBuilder(); + + try + { + stringbuilder.append(String.format("World: (%d,%d,%d)", new Object[] {Integer.valueOf(par0), Integer.valueOf(par1), Integer.valueOf(par2)})); + } + catch (Throwable throwable2) + { + stringbuilder.append("(Error finding world loc)"); + } + + stringbuilder.append(", "); + int l; + int i1; + int j1; + int k1; + int l1; + int i2; + int j2; + int k2; + int l2; + + try + { + l = par0 >> 4; + i1 = par2 >> 4; + j1 = par0 & 15; + k1 = par1 >> 4; + l1 = par2 & 15; + i2 = l << 4; + j2 = i1 << 4; + k2 = (l + 1 << 4) - 1; + l2 = (i1 + 1 << 4) - 1; + stringbuilder.append(String.format("Chunk: (at %d,%d,%d in %d,%d; contains blocks %d,0,%d to %d,255,%d)", new Object[] {Integer.valueOf(j1), Integer.valueOf(k1), Integer.valueOf(l1), Integer.valueOf(l), Integer.valueOf(i1), Integer.valueOf(i2), Integer.valueOf(j2), Integer.valueOf(k2), Integer.valueOf(l2)})); + } + catch (Throwable throwable1) + { + stringbuilder.append("(Error finding chunk loc)"); + } + + stringbuilder.append(", "); + + try + { + l = par0 >> 9; + i1 = par2 >> 9; + j1 = l << 5; + k1 = i1 << 5; + l1 = (l + 1 << 5) - 1; + i2 = (i1 + 1 << 5) - 1; + j2 = l << 9; + k2 = i1 << 9; + l2 = (l + 1 << 9) - 1; + int i3 = (i1 + 1 << 9) - 1; + stringbuilder.append(String.format("Region: (%d,%d; contains chunks %d,%d to %d,%d, blocks %d,0,%d to %d,255,%d)", new Object[] {Integer.valueOf(l), Integer.valueOf(i1), Integer.valueOf(j1), Integer.valueOf(k1), Integer.valueOf(l1), Integer.valueOf(i2), Integer.valueOf(j2), Integer.valueOf(k2), Integer.valueOf(l2), Integer.valueOf(i3)})); + } + catch (Throwable throwable) + { + stringbuilder.append("(Error finding world loc)"); + } + + return stringbuilder.toString(); + } + + public void addCrashSectionCallable(String par1Str, Callable par2Callable) + { + try + { + this.addCrashSection(par1Str, par2Callable.call()); + } + catch (Throwable throwable) + { + this.addCrashSectionThrowable(par1Str, throwable); + } + } + + public void addCrashSection(String par1Str, Object par2Obj) + { + this.field_85077_c.add(new CrashReportCategory.Entry(par1Str, par2Obj)); + } + + public void addCrashSectionThrowable(String par1Str, Throwable par2Throwable) + { + this.addCrashSection(par1Str, par2Throwable); + } + + public int getPrunedStackTrace(int par1) + { + StackTraceElement[] astacktraceelement = Thread.currentThread().getStackTrace(); + + if (astacktraceelement.length <= 0) + { + return 0; + } + else + { + int len = astacktraceelement.length - 3 - par1; + // Really Mojang, Still, god damn... + if (len <= 0) len = astacktraceelement.length; + this.stackTrace = new StackTraceElement[len]; + System.arraycopy(astacktraceelement, astacktraceelement.length - len, this.stackTrace, 0, this.stackTrace.length); + return this.stackTrace.length; + } + } + + public boolean firstTwoElementsOfStackTraceMatch(StackTraceElement par1StackTraceElement, StackTraceElement par2StackTraceElement) + { + if (this.stackTrace.length != 0 && par1StackTraceElement != null) + { + StackTraceElement stacktraceelement2 = this.stackTrace[0]; + + if (stacktraceelement2.isNativeMethod() == par1StackTraceElement.isNativeMethod() && stacktraceelement2.getClassName().equals(par1StackTraceElement.getClassName()) && stacktraceelement2.getFileName().equals(par1StackTraceElement.getFileName()) && stacktraceelement2.getMethodName().equals(par1StackTraceElement.getMethodName())) + { + if (par2StackTraceElement != null != this.stackTrace.length > 1) + { + return false; + } + else if (par2StackTraceElement != null && !this.stackTrace[1].equals(par2StackTraceElement)) + { + return false; + } + else + { + this.stackTrace[0] = par1StackTraceElement; + return true; + } + } + else + { + return false; + } + } + else + { + return false; + } + } + + public void trimStackTraceEntriesFromBottom(int par1) + { + StackTraceElement[] astacktraceelement = new StackTraceElement[this.stackTrace.length - par1]; + System.arraycopy(this.stackTrace, 0, astacktraceelement, 0, astacktraceelement.length); + this.stackTrace = astacktraceelement; + } + + public void appendToStringBuilder(StringBuilder par1StringBuilder) + { + par1StringBuilder.append("-- ").append(this.field_85076_b).append(" --\n"); + par1StringBuilder.append("Details:"); + Iterator iterator = this.field_85077_c.iterator(); + + while (iterator.hasNext()) + { + CrashReportCategory.Entry entry = (CrashReportCategory.Entry)iterator.next(); + par1StringBuilder.append("\n\t"); + par1StringBuilder.append(entry.func_85089_a()); + par1StringBuilder.append(": "); + par1StringBuilder.append(entry.func_85090_b()); + } + + if (this.stackTrace != null && this.stackTrace.length > 0) + { + par1StringBuilder.append("\nStacktrace:"); + StackTraceElement[] astacktraceelement = this.stackTrace; + int j = astacktraceelement.length; + + for (int i = 0; i < j; ++i) + { + StackTraceElement stacktraceelement = astacktraceelement[i]; + par1StringBuilder.append("\n\tat "); + par1StringBuilder.append(stacktraceelement.toString()); + } + } + } + + public StackTraceElement[] func_147152_a() + { + return this.stackTrace; + } + + public static void func_147153_a(CrashReportCategory p_147153_0_, final int p_147153_1_, final int p_147153_2_, final int p_147153_3_, final Block p_147153_4_, final int p_147153_5_) + { + final int i = Block.getIdFromBlock(p_147153_4_); + p_147153_0_.addCrashSectionCallable("Block type", new Callable() + { + private static final String __OBFID = "CL_00001426"; + public String call() + { + try + { + return String.format("ID #%d (%s // %s)", new Object[] {Integer.valueOf(i), p_147153_4_.getUnlocalizedName(), p_147153_4_.getClass().getCanonicalName()}); + } + catch (Throwable throwable) + { + return "ID #" + i; + } + } + }); + p_147153_0_.addCrashSectionCallable("Block data value", new Callable() + { + private static final String __OBFID = "CL_00001441"; + public String call() + { + if (p_147153_5_ < 0) + { + return "Unknown? (Got " + p_147153_5_ + ")"; + } + else + { + String s = String.format("%4s", new Object[] {Integer.toBinaryString(p_147153_5_)}).replace(" ", "0"); + return String.format("%1$d / 0x%1$X / 0b%2$s", new Object[] {Integer.valueOf(p_147153_5_), s}); + } + } + }); + p_147153_0_.addCrashSectionCallable("Block location", new Callable() + { + private static final String __OBFID = "CL_00001465"; + public String call() + { + return CrashReportCategory.getLocationInfo(p_147153_1_, p_147153_2_, p_147153_3_); + } + }); + } + + static class Entry + { + private final String field_85092_a; + private final String field_85091_b; + private static final String __OBFID = "CL_00001489"; + + public Entry(String par1Str, Object par2Obj) + { + this.field_85092_a = par1Str; + + if (par2Obj == null) + { + this.field_85091_b = "~~NULL~~"; + } + else if (par2Obj instanceof Throwable) + { + Throwable throwable = (Throwable)par2Obj; + this.field_85091_b = "~~ERROR~~ " + throwable.getClass().getSimpleName() + ": " + throwable.getMessage(); + } + else + { + this.field_85091_b = par2Obj.toString(); + } + } + + public String func_85089_a() + { + return this.field_85092_a; + } + + public String func_85090_b() + { + return this.field_85091_b; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/creativetab/CreativeTabs.java b/src/main/java/net/minecraft/creativetab/CreativeTabs.java new file mode 100644 index 0000000..b30ad12 --- /dev/null +++ b/src/main/java/net/minecraft/creativetab/CreativeTabs.java @@ -0,0 +1,376 @@ +package net.minecraft.creativetab; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Iterator; +import java.util.List; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnchantmentData; +import net.minecraft.enchantment.EnumEnchantmentType; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +public abstract class CreativeTabs +{ + public static CreativeTabs[] creativeTabArray = new CreativeTabs[12]; + public static final CreativeTabs tabBlock = new CreativeTabs(0, "buildingBlocks") + { + private static final String __OBFID = "CL_00000010"; + @SideOnly(Side.CLIENT) + public Item getTabIconItem() + { + return Item.getItemFromBlock(Blocks.brick_block); + } + }; + public static final CreativeTabs tabDecorations = new CreativeTabs(1, "decorations") + { + private static final String __OBFID = "CL_00000011"; + @SideOnly(Side.CLIENT) + public Item getTabIconItem() + { + return Item.getItemFromBlock(Blocks.double_plant); + } + @SideOnly(Side.CLIENT) + public int func_151243_f() + { + return 5; + } + }; + public static final CreativeTabs tabRedstone = new CreativeTabs(2, "redstone") + { + private static final String __OBFID = "CL_00000012"; + @SideOnly(Side.CLIENT) + public Item getTabIconItem() + { + return Items.redstone; + } + }; + public static final CreativeTabs tabTransport = new CreativeTabs(3, "transportation") + { + private static final String __OBFID = "CL_00000014"; + @SideOnly(Side.CLIENT) + public Item getTabIconItem() + { + return Item.getItemFromBlock(Blocks.golden_rail); + } + }; + public static final CreativeTabs tabMisc = (new CreativeTabs(4, "misc") + { + private static final String __OBFID = "CL_00000015"; + @SideOnly(Side.CLIENT) + public Item getTabIconItem() + { + return Items.lava_bucket; + } + }).func_111229_a(new EnumEnchantmentType[] {EnumEnchantmentType.all}); + public static final CreativeTabs tabAllSearch = (new CreativeTabs(5, "search") + { + private static final String __OBFID = "CL_00000016"; + @SideOnly(Side.CLIENT) + public Item getTabIconItem() + { + return Items.compass; + } + }).setBackgroundImageName("item_search.png"); + public static final CreativeTabs tabFood = new CreativeTabs(6, "food") + { + private static final String __OBFID = "CL_00000017"; + @SideOnly(Side.CLIENT) + public Item getTabIconItem() + { + return Items.apple; + } + }; + public static final CreativeTabs tabTools = (new CreativeTabs(7, "tools") + { + private static final String __OBFID = "CL_00000018"; + @SideOnly(Side.CLIENT) + public Item getTabIconItem() + { + return Items.iron_axe; + } + }).func_111229_a(new EnumEnchantmentType[] {EnumEnchantmentType.digger, EnumEnchantmentType.fishing_rod, EnumEnchantmentType.breakable}); + public static final CreativeTabs tabCombat = (new CreativeTabs(8, "combat") + { + private static final String __OBFID = "CL_00000007"; + @SideOnly(Side.CLIENT) + public Item getTabIconItem() + { + return Items.golden_sword; + } + }).func_111229_a(new EnumEnchantmentType[] {EnumEnchantmentType.armor, EnumEnchantmentType.armor_feet, EnumEnchantmentType.armor_head, EnumEnchantmentType.armor_legs, EnumEnchantmentType.armor_torso, EnumEnchantmentType.bow, EnumEnchantmentType.weapon}); + public static final CreativeTabs tabBrewing = new CreativeTabs(9, "brewing") + { + private static final String __OBFID = "CL_00000008"; + @SideOnly(Side.CLIENT) + public Item getTabIconItem() + { + return Items.potionitem; + } + }; + public static final CreativeTabs tabMaterials = new CreativeTabs(10, "materials") + { + private static final String __OBFID = "CL_00000009"; + @SideOnly(Side.CLIENT) + public Item getTabIconItem() + { + return Items.stick; + } + }; + public static final CreativeTabs tabInventory = (new CreativeTabs(11, "inventory") + { + private static final String __OBFID = "CL_00000006"; + @SideOnly(Side.CLIENT) + public Item getTabIconItem() + { + return Item.getItemFromBlock(Blocks.chest); + } + }).setBackgroundImageName("inventory.png").setNoScrollbar().setNoTitle(); + private final int tabIndex; + private final String tabLabel; + private String backgroundImageName = "items.png"; + private boolean hasScrollbar = true; + private boolean drawTitle = true; + private EnumEnchantmentType[] field_111230_s; + @SideOnly(Side.CLIENT) + private ItemStack field_151245_t; + private static final String __OBFID = "CL_00000005"; + + public CreativeTabs(String lable) + { + this(getNextID(), lable); + } + + public CreativeTabs(int par1, String par2Str) + { + if (par1 >= creativeTabArray.length) + { + CreativeTabs[] tmp = new CreativeTabs[par1 + 1]; + for (int x = 0; x < creativeTabArray.length; x++) + { + tmp[x] = creativeTabArray[x]; + } + creativeTabArray = tmp; + } + this.tabIndex = par1; + this.tabLabel = par2Str; + creativeTabArray[par1] = this; + } + + @SideOnly(Side.CLIENT) + public int getTabIndex() + { + return this.tabIndex; + } + + public CreativeTabs setBackgroundImageName(String par1Str) + { + this.backgroundImageName = par1Str; + return this; + } + + @SideOnly(Side.CLIENT) + public String getTabLabel() + { + return this.tabLabel; + } + + @SideOnly(Side.CLIENT) + public String getTranslatedTabLabel() + { + return "itemGroup." + this.getTabLabel(); + } + + @SideOnly(Side.CLIENT) + public ItemStack getIconItemStack() + { + if (this.field_151245_t == null) + { + this.field_151245_t = new ItemStack(this.getTabIconItem(), 1, this.func_151243_f()); + } + + return this.field_151245_t; + } + + @SideOnly(Side.CLIENT) + public abstract Item getTabIconItem(); + + @SideOnly(Side.CLIENT) + public int func_151243_f() + { + return 0; + } + + @SideOnly(Side.CLIENT) + public String getBackgroundImageName() + { + return this.backgroundImageName; + } + + @SideOnly(Side.CLIENT) + public boolean drawInForegroundOfTab() + { + return this.drawTitle; + } + + public CreativeTabs setNoTitle() + { + this.drawTitle = false; + return this; + } + + @SideOnly(Side.CLIENT) + public boolean shouldHidePlayerInventory() + { + return this.hasScrollbar; + } + + public CreativeTabs setNoScrollbar() + { + this.hasScrollbar = false; + return this; + } + + @SideOnly(Side.CLIENT) + public int getTabColumn() + { + if (tabIndex > 11) + { + return ((tabIndex - 12) % 10) % 5; + } + return this.tabIndex % 6; + } + + @SideOnly(Side.CLIENT) + public boolean isTabInFirstRow() + { + if (tabIndex > 11) + { + return ((tabIndex - 12) % 10) < 5; + } + return this.tabIndex < 6; + } + + @SideOnly(Side.CLIENT) + public EnumEnchantmentType[] func_111225_m() + { + return this.field_111230_s; + } + + public CreativeTabs func_111229_a(EnumEnchantmentType ... par1ArrayOfEnumEnchantmentType) + { + this.field_111230_s = par1ArrayOfEnumEnchantmentType; + return this; + } + + @SideOnly(Side.CLIENT) + public boolean func_111226_a(EnumEnchantmentType par1EnumEnchantmentType) + { + if (this.field_111230_s == null) + { + return false; + } + else + { + EnumEnchantmentType[] aenumenchantmenttype = this.field_111230_s; + int i = aenumenchantmenttype.length; + + for (int j = 0; j < i; ++j) + { + EnumEnchantmentType enumenchantmenttype1 = aenumenchantmenttype[j]; + + if (enumenchantmenttype1 == par1EnumEnchantmentType) + { + return true; + } + } + + return false; + } + } + + @SideOnly(Side.CLIENT) + public void displayAllReleventItems(List par1List) + { + Iterator iterator = Item.itemRegistry.iterator(); + + while (iterator.hasNext()) + { + Item item = (Item)iterator.next(); + + if (item == null) + { + continue; + } + + for (CreativeTabs tab : item.getCreativeTabs()) + { + if (tab == this) + { + item.getSubItems(item, this, par1List); + } + } + } + + if (this.func_111225_m() != null) + { + this.addEnchantmentBooksToList(par1List, this.func_111225_m()); + } + } + + @SideOnly(Side.CLIENT) + public void addEnchantmentBooksToList(List par1List, EnumEnchantmentType ... par2ArrayOfEnumEnchantmentType) + { + Enchantment[] aenchantment = Enchantment.enchantmentsList; + int i = aenchantment.length; + + for (int j = 0; j < i; ++j) + { + Enchantment enchantment = aenchantment[j]; + + if (enchantment != null && enchantment.type != null) + { + boolean flag = false; + + for (int k = 0; k < par2ArrayOfEnumEnchantmentType.length && !flag; ++k) + { + if (enchantment.type == par2ArrayOfEnumEnchantmentType[k]) + { + flag = true; + } + } + + if (flag) + { + par1List.add(Items.enchanted_book.getEnchantedItemStack(new EnchantmentData(enchantment, enchantment.getMaxLevel()))); + } + } + } + } + + public int getTabPage() + { + if (tabIndex > 11) + { + return ((tabIndex - 12) / 10) + 1; + } + return 0; + } + + public static int getNextID() + { + return creativeTabArray.length; + } + + /** + * Determines if the search bar should be shown for this tab. + * + * @return True to show the bar + */ + public boolean hasSearchBar() + { + return tabIndex == CreativeTabs.tabAllSearch.tabIndex; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/dispenser/BehaviorDefaultDispenseItem.java b/src/main/java/net/minecraft/dispenser/BehaviorDefaultDispenseItem.java new file mode 100644 index 0000000..ceb6219 --- /dev/null +++ b/src/main/java/net/minecraft/dispenser/BehaviorDefaultDispenseItem.java @@ -0,0 +1,60 @@ +package net.minecraft.dispenser; + +import net.minecraft.block.BlockDispenser; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; +import net.minecraft.world.World; + +public class BehaviorDefaultDispenseItem implements IBehaviorDispenseItem +{ + private static final String __OBFID = "CL_00001195"; + + public final ItemStack dispense(IBlockSource par1IBlockSource, ItemStack par2ItemStack) + { + ItemStack itemstack1 = this.dispenseStack(par1IBlockSource, par2ItemStack); + this.playDispenseSound(par1IBlockSource); + this.spawnDispenseParticles(par1IBlockSource, BlockDispenser.func_149937_b(par1IBlockSource.getBlockMetadata())); + return itemstack1; + } + + protected ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) + { + EnumFacing enumfacing = BlockDispenser.func_149937_b(par1IBlockSource.getBlockMetadata()); + IPosition iposition = BlockDispenser.func_149939_a(par1IBlockSource); + ItemStack itemstack1 = par2ItemStack.splitStack(1); + doDispense(par1IBlockSource.getWorld(), itemstack1, 6, enumfacing, iposition); + return par2ItemStack; + } + + public static void doDispense(World par0World, ItemStack par1ItemStack, int par2, EnumFacing par3EnumFacing, IPosition par4IPosition) + { + double d0 = par4IPosition.getX(); + double d1 = par4IPosition.getY(); + double d2 = par4IPosition.getZ(); + EntityItem entityitem = new EntityItem(par0World, d0, d1 - 0.3D, d2, par1ItemStack); + double d3 = par0World.rand.nextDouble() * 0.1D + 0.2D; + entityitem.motionX = (double)par3EnumFacing.getFrontOffsetX() * d3; + entityitem.motionY = 0.20000000298023224D; + entityitem.motionZ = (double)par3EnumFacing.getFrontOffsetZ() * d3; + entityitem.motionX += par0World.rand.nextGaussian() * 0.007499999832361937D * (double)par2; + entityitem.motionY += par0World.rand.nextGaussian() * 0.007499999832361937D * (double)par2; + entityitem.motionZ += par0World.rand.nextGaussian() * 0.007499999832361937D * (double)par2; + par0World.spawnEntityInWorld(entityitem); + } + + protected void playDispenseSound(IBlockSource par1IBlockSource) + { + par1IBlockSource.getWorld().playAuxSFX(1000, par1IBlockSource.getXInt(), par1IBlockSource.getYInt(), par1IBlockSource.getZInt(), 0); + } + + protected void spawnDispenseParticles(IBlockSource par1IBlockSource, EnumFacing par2EnumFacing) + { + par1IBlockSource.getWorld().playAuxSFX(2000, par1IBlockSource.getXInt(), par1IBlockSource.getYInt(), par1IBlockSource.getZInt(), this.func_82488_a(par2EnumFacing)); + } + + private int func_82488_a(EnumFacing par1EnumFacing) + { + return par1EnumFacing.getFrontOffsetX() + 1 + (par1EnumFacing.getFrontOffsetZ() + 1) * 3; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/dispenser/BehaviorProjectileDispense.java b/src/main/java/net/minecraft/dispenser/BehaviorProjectileDispense.java new file mode 100644 index 0000000..02d2933 --- /dev/null +++ b/src/main/java/net/minecraft/dispenser/BehaviorProjectileDispense.java @@ -0,0 +1,42 @@ +package net.minecraft.dispenser; + +import net.minecraft.block.BlockDispenser; +import net.minecraft.entity.Entity; +import net.minecraft.entity.IProjectile; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; +import net.minecraft.world.World; + +public abstract class BehaviorProjectileDispense extends BehaviorDefaultDispenseItem +{ + private static final String __OBFID = "CL_00001394"; + + public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) + { + World world = par1IBlockSource.getWorld(); + IPosition iposition = BlockDispenser.func_149939_a(par1IBlockSource); + EnumFacing enumfacing = BlockDispenser.func_149937_b(par1IBlockSource.getBlockMetadata()); + IProjectile iprojectile = this.getProjectileEntity(world, iposition); + iprojectile.setThrowableHeading((double)enumfacing.getFrontOffsetX(), (double)((float)enumfacing.getFrontOffsetY() + 0.1F), (double)enumfacing.getFrontOffsetZ(), this.func_82500_b(), this.func_82498_a()); + world.spawnEntityInWorld((Entity)iprojectile); + par2ItemStack.splitStack(1); + return par2ItemStack; + } + + protected void playDispenseSound(IBlockSource par1IBlockSource) + { + par1IBlockSource.getWorld().playAuxSFX(1002, par1IBlockSource.getXInt(), par1IBlockSource.getYInt(), par1IBlockSource.getZInt(), 0); + } + + protected abstract IProjectile getProjectileEntity(World var1, IPosition var2); + + protected float func_82498_a() + { + return 6.0F; + } + + protected float func_82500_b() + { + return 1.1F; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/dispenser/IBehaviorDispenseItem.java b/src/main/java/net/minecraft/dispenser/IBehaviorDispenseItem.java new file mode 100644 index 0000000..ada9f21 --- /dev/null +++ b/src/main/java/net/minecraft/dispenser/IBehaviorDispenseItem.java @@ -0,0 +1,17 @@ +package net.minecraft.dispenser; + +import net.minecraft.item.ItemStack; + +public interface IBehaviorDispenseItem +{ + IBehaviorDispenseItem itemDispenseBehaviorProvider = new IBehaviorDispenseItem() + { + private static final String __OBFID = "CL_00001200"; + public ItemStack dispense(IBlockSource par1IBlockSource, ItemStack par2ItemStack) + { + return par2ItemStack; + } + }; + + ItemStack dispense(IBlockSource var1, ItemStack var2); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/dispenser/IBlockSource.java b/src/main/java/net/minecraft/dispenser/IBlockSource.java new file mode 100644 index 0000000..0b8aca8 --- /dev/null +++ b/src/main/java/net/minecraft/dispenser/IBlockSource.java @@ -0,0 +1,22 @@ +package net.minecraft.dispenser; + +import net.minecraft.tileentity.TileEntity; + +public interface IBlockSource extends ILocatableSource +{ + double getX(); + + double getY(); + + double getZ(); + + int getXInt(); + + int getYInt(); + + int getZInt(); + + int getBlockMetadata(); + + TileEntity getBlockTileEntity(); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/dispenser/ILocatableSource.java b/src/main/java/net/minecraft/dispenser/ILocatableSource.java new file mode 100644 index 0000000..ce7bf95 --- /dev/null +++ b/src/main/java/net/minecraft/dispenser/ILocatableSource.java @@ -0,0 +1,5 @@ +package net.minecraft.dispenser; + +public interface ILocatableSource extends ILocation +{ +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/dispenser/ILocation.java b/src/main/java/net/minecraft/dispenser/ILocation.java new file mode 100644 index 0000000..31204de --- /dev/null +++ b/src/main/java/net/minecraft/dispenser/ILocation.java @@ -0,0 +1,8 @@ +package net.minecraft.dispenser; + +import net.minecraft.world.World; + +public interface ILocation extends IPosition +{ + World getWorld(); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/dispenser/IPosition.java b/src/main/java/net/minecraft/dispenser/IPosition.java new file mode 100644 index 0000000..a270e83 --- /dev/null +++ b/src/main/java/net/minecraft/dispenser/IPosition.java @@ -0,0 +1,10 @@ +package net.minecraft.dispenser; + +public interface IPosition +{ + double getX(); + + double getY(); + + double getZ(); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/dispenser/PositionImpl.java b/src/main/java/net/minecraft/dispenser/PositionImpl.java new file mode 100644 index 0000000..7857cd8 --- /dev/null +++ b/src/main/java/net/minecraft/dispenser/PositionImpl.java @@ -0,0 +1,31 @@ +package net.minecraft.dispenser; + +public class PositionImpl implements IPosition +{ + protected final double x; + protected final double y; + protected final double z; + private static final String __OBFID = "CL_00001208"; + + public PositionImpl(double par1, double par3, double par5) + { + this.x = par1; + this.y = par3; + this.z = par5; + } + + public double getX() + { + return this.x; + } + + public double getY() + { + return this.y; + } + + public double getZ() + { + return this.z; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/enchantment/Enchantment.java b/src/main/java/net/minecraft/enchantment/Enchantment.java new file mode 100644 index 0000000..7581ffc --- /dev/null +++ b/src/main/java/net/minecraft/enchantment/Enchantment.java @@ -0,0 +1,174 @@ +package net.minecraft.enchantment; + +import java.util.ArrayList; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; +import net.minecraft.util.DamageSource; +import net.minecraft.util.StatCollector; + +public abstract class Enchantment +{ + public static final Enchantment[] enchantmentsList = new Enchantment[256]; + public static final Enchantment[] enchantmentsBookList; + public static final Enchantment protection = new EnchantmentProtection(0, 10, 0); + public static final Enchantment fireProtection = new EnchantmentProtection(1, 5, 1); + public static final Enchantment featherFalling = new EnchantmentProtection(2, 5, 2); + public static final Enchantment blastProtection = new EnchantmentProtection(3, 2, 3); + public static final Enchantment projectileProtection = new EnchantmentProtection(4, 5, 4); + public static final Enchantment respiration = new EnchantmentOxygen(5, 2); + public static final Enchantment aquaAffinity = new EnchantmentWaterWorker(6, 2); + public static final Enchantment thorns = new EnchantmentThorns(7, 1); + public static final Enchantment sharpness = new EnchantmentDamage(16, 10, 0); + public static final Enchantment smite = new EnchantmentDamage(17, 5, 1); + public static final Enchantment baneOfArthropods = new EnchantmentDamage(18, 5, 2); + public static final Enchantment knockback = new EnchantmentKnockback(19, 5); + public static final Enchantment fireAspect = new EnchantmentFireAspect(20, 2); + public static final Enchantment looting = new EnchantmentLootBonus(21, 2, EnumEnchantmentType.weapon); + public static final Enchantment efficiency = new EnchantmentDigging(32, 10); + public static final Enchantment silkTouch = new EnchantmentUntouching(33, 1); + public static final Enchantment unbreaking = new EnchantmentDurability(34, 5); + public static final Enchantment fortune = new EnchantmentLootBonus(35, 2, EnumEnchantmentType.digger); + public static final Enchantment power = new EnchantmentArrowDamage(48, 10); + public static final Enchantment punch = new EnchantmentArrowKnockback(49, 2); + public static final Enchantment flame = new EnchantmentArrowFire(50, 2); + public static final Enchantment infinity = new EnchantmentArrowInfinite(51, 1); + public static final Enchantment field_151370_z = new EnchantmentLootBonus(61, 2, EnumEnchantmentType.fishing_rod); + public static final Enchantment field_151369_A = new EnchantmentFishingSpeed(62, 2, EnumEnchantmentType.fishing_rod); + public final int effectId; + private final int weight; + public EnumEnchantmentType type; + protected String name; + private static final String __OBFID = "CL_00000105"; + + protected Enchantment(int par1, int par2, EnumEnchantmentType par3EnumEnchantmentType) + { + this.effectId = par1; + this.weight = par2; + this.type = par3EnumEnchantmentType; + + if (enchantmentsList[par1] != null) + { + throw new IllegalArgumentException("Duplicate enchantment id!"); + } + else + { + enchantmentsList[par1] = this; + } + } + + public int getWeight() + { + return this.weight; + } + + public int getMinLevel() + { + return 1; + } + + public int getMaxLevel() + { + return 1; + } + + public int getMinEnchantability(int par1) + { + return 1 + par1 * 10; + } + + public int getMaxEnchantability(int par1) + { + return this.getMinEnchantability(par1) + 5; + } + + public int calcModifierDamage(int par1, DamageSource par2DamageSource) + { + return 0; + } + + public float calcModifierLiving(int par1, EntityLivingBase par2EntityLivingBase) + { + return 0.0F; + } + + public boolean canApplyTogether(Enchantment par1Enchantment) + { + return this != par1Enchantment; + } + + public Enchantment setName(String par1Str) + { + this.name = par1Str; + return this; + } + + public String getName() + { + return "enchantment." + this.name; + } + + public String getTranslatedName(int par1) + { + String s = StatCollector.translateToLocal(this.getName()); + return s + " " + StatCollector.translateToLocal("enchantment.level." + par1); + } + + public boolean canApply(ItemStack par1ItemStack) + { + return this.type.canEnchantItem(par1ItemStack.getItem()); + } + + public void func_151368_a(EntityLivingBase p_151368_1_, Entity p_151368_2_, int p_151368_3_) {} + + public void func_151367_b(EntityLivingBase p_151367_1_, Entity p_151367_2_, int p_151367_3_) {} + + /** + * This applies specifically to applying at the enchanting table. The other method {@link #canApply(ItemStack)} + * applies for all possible enchantments. + * @param stack + * @return + */ + public boolean canApplyAtEnchantingTable(ItemStack stack) + { + return canApply(stack); + } + + /** + * Add to the list of enchantments applicable by the anvil from a book + * + * @param enchantment + */ + public static void addToBookList(Enchantment enchantment) + { + com.google.common.collect.ObjectArrays.concat(enchantmentsBookList, enchantment); + } + + /** + * Is this enchantment allowed to be enchanted on books via Enchantment Table + * @return false to disable the vanilla feature + */ + public boolean isAllowedOnBooks() + { + return true; + } + + static + { + ArrayList var0 = new ArrayList(); + Enchantment[] var1 = enchantmentsList; + int var2 = var1.length; + + for (int var3 = 0; var3 < var2; ++var3) + { + Enchantment var4 = var1[var3]; + + if (var4 != null) + { + var0.add(var4); + } + } + + enchantmentsBookList = (Enchantment[])var0.toArray(new Enchantment[0]); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/enchantment/EnchantmentArrowDamage.java b/src/main/java/net/minecraft/enchantment/EnchantmentArrowDamage.java new file mode 100644 index 0000000..6436914 --- /dev/null +++ b/src/main/java/net/minecraft/enchantment/EnchantmentArrowDamage.java @@ -0,0 +1,27 @@ +package net.minecraft.enchantment; + +public class EnchantmentArrowDamage extends Enchantment +{ + private static final String __OBFID = "CL_00000098"; + + public EnchantmentArrowDamage(int par1, int par2) + { + super(par1, par2, EnumEnchantmentType.bow); + this.setName("arrowDamage"); + } + + public int getMinEnchantability(int par1) + { + return 1 + (par1 - 1) * 10; + } + + public int getMaxEnchantability(int par1) + { + return this.getMinEnchantability(par1) + 15; + } + + public int getMaxLevel() + { + return 5; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/enchantment/EnchantmentArrowFire.java b/src/main/java/net/minecraft/enchantment/EnchantmentArrowFire.java new file mode 100644 index 0000000..5a15998 --- /dev/null +++ b/src/main/java/net/minecraft/enchantment/EnchantmentArrowFire.java @@ -0,0 +1,27 @@ +package net.minecraft.enchantment; + +public class EnchantmentArrowFire extends Enchantment +{ + private static final String __OBFID = "CL_00000099"; + + public EnchantmentArrowFire(int par1, int par2) + { + super(par1, par2, EnumEnchantmentType.bow); + this.setName("arrowFire"); + } + + public int getMinEnchantability(int par1) + { + return 20; + } + + public int getMaxEnchantability(int par1) + { + return 50; + } + + public int getMaxLevel() + { + return 1; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/enchantment/EnchantmentArrowInfinite.java b/src/main/java/net/minecraft/enchantment/EnchantmentArrowInfinite.java new file mode 100644 index 0000000..7b40b21 --- /dev/null +++ b/src/main/java/net/minecraft/enchantment/EnchantmentArrowInfinite.java @@ -0,0 +1,27 @@ +package net.minecraft.enchantment; + +public class EnchantmentArrowInfinite extends Enchantment +{ + private static final String __OBFID = "CL_00000100"; + + public EnchantmentArrowInfinite(int par1, int par2) + { + super(par1, par2, EnumEnchantmentType.bow); + this.setName("arrowInfinite"); + } + + public int getMinEnchantability(int par1) + { + return 20; + } + + public int getMaxEnchantability(int par1) + { + return 50; + } + + public int getMaxLevel() + { + return 1; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/enchantment/EnchantmentArrowKnockback.java b/src/main/java/net/minecraft/enchantment/EnchantmentArrowKnockback.java new file mode 100644 index 0000000..3f253f5 --- /dev/null +++ b/src/main/java/net/minecraft/enchantment/EnchantmentArrowKnockback.java @@ -0,0 +1,27 @@ +package net.minecraft.enchantment; + +public class EnchantmentArrowKnockback extends Enchantment +{ + private static final String __OBFID = "CL_00000101"; + + public EnchantmentArrowKnockback(int par1, int par2) + { + super(par1, par2, EnumEnchantmentType.bow); + this.setName("arrowKnockback"); + } + + public int getMinEnchantability(int par1) + { + return 12 + (par1 - 1) * 20; + } + + public int getMaxEnchantability(int par1) + { + return this.getMinEnchantability(par1) + 25; + } + + public int getMaxLevel() + { + return 2; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/enchantment/EnchantmentDamage.java b/src/main/java/net/minecraft/enchantment/EnchantmentDamage.java new file mode 100644 index 0000000..4119b02 --- /dev/null +++ b/src/main/java/net/minecraft/enchantment/EnchantmentDamage.java @@ -0,0 +1,74 @@ +package net.minecraft.enchantment; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.EnumCreatureAttribute; +import net.minecraft.item.ItemAxe; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; + +public class EnchantmentDamage extends Enchantment +{ + private static final String[] protectionName = new String[] {"all", "undead", "arthropods"}; + private static final int[] baseEnchantability = new int[] {1, 5, 5}; + private static final int[] levelEnchantability = new int[] {11, 8, 8}; + private static final int[] thresholdEnchantability = new int[] {20, 20, 20}; + public final int damageType; + private static final String __OBFID = "CL_00000102"; + + public EnchantmentDamage(int par1, int par2, int par3) + { + super(par1, par2, EnumEnchantmentType.weapon); + this.damageType = par3; + } + + public int getMinEnchantability(int par1) + { + return baseEnchantability[this.damageType] + (par1 - 1) * levelEnchantability[this.damageType]; + } + + public int getMaxEnchantability(int par1) + { + return this.getMinEnchantability(par1) + thresholdEnchantability[this.damageType]; + } + + public int getMaxLevel() + { + return 5; + } + + public float calcModifierLiving(int par1, EntityLivingBase par2EntityLivingBase) + { + return this.damageType == 0 ? (float)par1 * 1.25F : (this.damageType == 1 && par2EntityLivingBase.getCreatureAttribute() == EnumCreatureAttribute.UNDEAD ? (float)par1 * 2.5F : (this.damageType == 2 && par2EntityLivingBase.getCreatureAttribute() == EnumCreatureAttribute.ARTHROPOD ? (float)par1 * 2.5F : 0.0F)); + } + + public String getName() + { + return "enchantment.damage." + protectionName[this.damageType]; + } + + public boolean canApplyTogether(Enchantment par1Enchantment) + { + return !(par1Enchantment instanceof EnchantmentDamage); + } + + public boolean canApply(ItemStack par1ItemStack) + { + return par1ItemStack.getItem() instanceof ItemAxe ? true : super.canApply(par1ItemStack); + } + + public void func_151368_a(EntityLivingBase p_151368_1_, Entity p_151368_2_, int p_151368_3_) + { + if (p_151368_2_ instanceof EntityLivingBase) + { + EntityLivingBase entitylivingbase1 = (EntityLivingBase)p_151368_2_; + + if (this.damageType == 2 && entitylivingbase1.getCreatureAttribute() == EnumCreatureAttribute.ARTHROPOD) + { + int j = 20 + p_151368_1_.getRNG().nextInt(10 * p_151368_3_); + entitylivingbase1.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, j, 3)); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/enchantment/EnchantmentData.java b/src/main/java/net/minecraft/enchantment/EnchantmentData.java new file mode 100644 index 0000000..1174bb2 --- /dev/null +++ b/src/main/java/net/minecraft/enchantment/EnchantmentData.java @@ -0,0 +1,22 @@ +package net.minecraft.enchantment; + +import net.minecraft.util.WeightedRandom; + +public class EnchantmentData extends WeightedRandom.Item +{ + public final Enchantment enchantmentobj; + public final int enchantmentLevel; + private static final String __OBFID = "CL_00000115"; + + public EnchantmentData(Enchantment par1Enchantment, int par2) + { + super(par1Enchantment.getWeight()); + this.enchantmentobj = par1Enchantment; + this.enchantmentLevel = par2; + } + + public EnchantmentData(int par1, int par2) + { + this(Enchantment.enchantmentsList[par1], par2); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/enchantment/EnchantmentDigging.java b/src/main/java/net/minecraft/enchantment/EnchantmentDigging.java new file mode 100644 index 0000000..430617a --- /dev/null +++ b/src/main/java/net/minecraft/enchantment/EnchantmentDigging.java @@ -0,0 +1,35 @@ +package net.minecraft.enchantment; + +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; + +public class EnchantmentDigging extends Enchantment +{ + private static final String __OBFID = "CL_00000104"; + + protected EnchantmentDigging(int par1, int par2) + { + super(par1, par2, EnumEnchantmentType.digger); + this.setName("digging"); + } + + public int getMinEnchantability(int par1) + { + return 1 + 10 * (par1 - 1); + } + + public int getMaxEnchantability(int par1) + { + return super.getMinEnchantability(par1) + 50; + } + + public int getMaxLevel() + { + return 5; + } + + public boolean canApply(ItemStack par1ItemStack) + { + return par1ItemStack.getItem() == Items.shears ? true : super.canApply(par1ItemStack); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/enchantment/EnchantmentDurability.java b/src/main/java/net/minecraft/enchantment/EnchantmentDurability.java new file mode 100644 index 0000000..f40ba3e --- /dev/null +++ b/src/main/java/net/minecraft/enchantment/EnchantmentDurability.java @@ -0,0 +1,41 @@ +package net.minecraft.enchantment; + +import java.util.Random; +import net.minecraft.item.ItemArmor; +import net.minecraft.item.ItemStack; + +public class EnchantmentDurability extends Enchantment +{ + private static final String __OBFID = "CL_00000103"; + + protected EnchantmentDurability(int par1, int par2) + { + super(par1, par2, EnumEnchantmentType.breakable); + this.setName("durability"); + } + + public int getMinEnchantability(int par1) + { + return 5 + (par1 - 1) * 8; + } + + public int getMaxEnchantability(int par1) + { + return super.getMinEnchantability(par1) + 50; + } + + public int getMaxLevel() + { + return 3; + } + + public boolean canApply(ItemStack par1ItemStack) + { + return par1ItemStack.isItemStackDamageable() ? true : super.canApply(par1ItemStack); + } + + public static boolean negateDamage(ItemStack par0ItemStack, int par1, Random par2Random) + { + return par0ItemStack.getItem() instanceof ItemArmor && par2Random.nextFloat() < 0.6F ? false : par2Random.nextInt(par1 + 1) > 0; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/enchantment/EnchantmentFireAspect.java b/src/main/java/net/minecraft/enchantment/EnchantmentFireAspect.java new file mode 100644 index 0000000..b10f09f --- /dev/null +++ b/src/main/java/net/minecraft/enchantment/EnchantmentFireAspect.java @@ -0,0 +1,27 @@ +package net.minecraft.enchantment; + +public class EnchantmentFireAspect extends Enchantment +{ + private static final String __OBFID = "CL_00000116"; + + protected EnchantmentFireAspect(int par1, int par2) + { + super(par1, par2, EnumEnchantmentType.weapon); + this.setName("fire"); + } + + public int getMinEnchantability(int par1) + { + return 10 + 20 * (par1 - 1); + } + + public int getMaxEnchantability(int par1) + { + return super.getMinEnchantability(par1) + 50; + } + + public int getMaxLevel() + { + return 2; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/enchantment/EnchantmentFishingSpeed.java b/src/main/java/net/minecraft/enchantment/EnchantmentFishingSpeed.java new file mode 100644 index 0000000..1706ee6 --- /dev/null +++ b/src/main/java/net/minecraft/enchantment/EnchantmentFishingSpeed.java @@ -0,0 +1,27 @@ +package net.minecraft.enchantment; + +public class EnchantmentFishingSpeed extends Enchantment +{ + private static final String __OBFID = "CL_00000117"; + + protected EnchantmentFishingSpeed(int p_i45361_1_, int p_i45361_2_, EnumEnchantmentType p_i45361_3_) + { + super(p_i45361_1_, p_i45361_2_, p_i45361_3_); + this.setName("fishingSpeed"); + } + + public int getMinEnchantability(int par1) + { + return 15 + (par1 - 1) * 9; + } + + public int getMaxEnchantability(int par1) + { + return super.getMinEnchantability(par1) + 50; + } + + public int getMaxLevel() + { + return 3; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/enchantment/EnchantmentHelper.java b/src/main/java/net/minecraft/enchantment/EnchantmentHelper.java new file mode 100644 index 0000000..05b65d9 --- /dev/null +++ b/src/main/java/net/minecraft/enchantment/EnchantmentHelper.java @@ -0,0 +1,533 @@ +package net.minecraft.enchantment; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Random; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.DamageSource; +import net.minecraft.util.WeightedRandom; + +public class EnchantmentHelper +{ + private static final Random enchantmentRand = new Random(); + private static final EnchantmentHelper.ModifierDamage enchantmentModifierDamage = new EnchantmentHelper.ModifierDamage(null); + private static final EnchantmentHelper.ModifierLiving enchantmentModifierLiving = new EnchantmentHelper.ModifierLiving(null); + private static final EnchantmentHelper.HurtIterator field_151388_d = new EnchantmentHelper.HurtIterator(null); + private static final EnchantmentHelper.DamageIterator field_151389_e = new EnchantmentHelper.DamageIterator(null); + private static final String __OBFID = "CL_00000107"; + + public static int getEnchantmentLevel(int par0, ItemStack par1ItemStack) + { + if (par1ItemStack == null) + { + return 0; + } + else + { + NBTTagList nbttaglist = par1ItemStack.getEnchantmentTagList(); + + if (nbttaglist == null) + { + return 0; + } + else + { + for (int j = 0; j < nbttaglist.tagCount(); ++j) + { + short short1 = nbttaglist.getCompoundTagAt(j).getShort("id"); + short short2 = nbttaglist.getCompoundTagAt(j).getShort("lvl"); + + if (short1 == par0) + { + return short2; + } + } + + return 0; + } + } + } + + public static Map getEnchantments(ItemStack par0ItemStack) + { + LinkedHashMap linkedhashmap = new LinkedHashMap(); + NBTTagList nbttaglist = par0ItemStack.getItem() == Items.enchanted_book ? Items.enchanted_book.func_92110_g(par0ItemStack) : par0ItemStack.getEnchantmentTagList(); + + if (nbttaglist != null) + { + for (int i = 0; i < nbttaglist.tagCount(); ++i) + { + short short1 = nbttaglist.getCompoundTagAt(i).getShort("id"); + short short2 = nbttaglist.getCompoundTagAt(i).getShort("lvl"); + linkedhashmap.put(Integer.valueOf(short1), Integer.valueOf(short2)); + } + } + + return linkedhashmap; + } + + public static void setEnchantments(Map par0Map, ItemStack par1ItemStack) + { + NBTTagList nbttaglist = new NBTTagList(); + Iterator iterator = par0Map.keySet().iterator(); + + while (iterator.hasNext()) + { + int i = ((Integer)iterator.next()).intValue(); + NBTTagCompound nbttagcompound = new NBTTagCompound(); + nbttagcompound.setShort("id", (short)i); + nbttagcompound.setShort("lvl", (short)((Integer)par0Map.get(Integer.valueOf(i))).intValue()); + nbttaglist.appendTag(nbttagcompound); + + if (par1ItemStack.getItem() == Items.enchanted_book) + { + Items.enchanted_book.addEnchantment(par1ItemStack, new EnchantmentData(i, ((Integer)par0Map.get(Integer.valueOf(i))).intValue())); + } + } + + if (nbttaglist.tagCount() > 0) + { + if (par1ItemStack.getItem() != Items.enchanted_book) + { + par1ItemStack.setTagInfo("ench", nbttaglist); + } + } + else if (par1ItemStack.hasTagCompound()) + { + par1ItemStack.getTagCompound().removeTag("ench"); + } + } + + public static int getMaxEnchantmentLevel(int par0, ItemStack[] par1ArrayOfItemStack) + { + if (par1ArrayOfItemStack == null) + { + return 0; + } + else + { + int j = 0; + ItemStack[] aitemstack1 = par1ArrayOfItemStack; + int k = par1ArrayOfItemStack.length; + + for (int l = 0; l < k; ++l) + { + ItemStack itemstack = aitemstack1[l]; + int i1 = getEnchantmentLevel(par0, itemstack); + + if (i1 > j) + { + j = i1; + } + } + + return j; + } + } + + private static void applyEnchantmentModifier(EnchantmentHelper.IModifier par0IEnchantmentModifier, ItemStack par1ItemStack) + { + if (par1ItemStack != null) + { + NBTTagList nbttaglist = par1ItemStack.getEnchantmentTagList(); + + if (nbttaglist != null) + { + for (int i = 0; i < nbttaglist.tagCount(); ++i) + { + short short1 = nbttaglist.getCompoundTagAt(i).getShort("id"); + short short2 = nbttaglist.getCompoundTagAt(i).getShort("lvl"); + + if (Enchantment.enchantmentsList[short1] != null) + { + par0IEnchantmentModifier.calculateModifier(Enchantment.enchantmentsList[short1], short2); + } + } + } + } + } + + private static void applyEnchantmentModifierArray(EnchantmentHelper.IModifier par0IEnchantmentModifier, ItemStack[] par1ArrayOfItemStack) + { + ItemStack[] aitemstack1 = par1ArrayOfItemStack; + int i = par1ArrayOfItemStack.length; + + for (int j = 0; j < i; ++j) + { + ItemStack itemstack = aitemstack1[j]; + applyEnchantmentModifier(par0IEnchantmentModifier, itemstack); + } + } + + public static int getEnchantmentModifierDamage(ItemStack[] par0ArrayOfItemStack, DamageSource par1DamageSource) + { + enchantmentModifierDamage.damageModifier = 0; + enchantmentModifierDamage.source = par1DamageSource; + applyEnchantmentModifierArray(enchantmentModifierDamage, par0ArrayOfItemStack); + + if (enchantmentModifierDamage.damageModifier > 25) + { + enchantmentModifierDamage.damageModifier = 25; + } + + return (enchantmentModifierDamage.damageModifier + 1 >> 1) + enchantmentRand.nextInt((enchantmentModifierDamage.damageModifier >> 1) + 1); + } + + public static float getEnchantmentModifierLiving(EntityLivingBase par0EntityLivingBase, EntityLivingBase par1EntityLivingBase) + { + enchantmentModifierLiving.livingModifier = 0.0F; + enchantmentModifierLiving.entityLiving = par1EntityLivingBase; + applyEnchantmentModifier(enchantmentModifierLiving, par0EntityLivingBase.getHeldItem()); + return enchantmentModifierLiving.livingModifier; + } + + public static void func_151384_a(EntityLivingBase p_151384_0_, Entity p_151384_1_) + { + field_151388_d.field_151363_b = p_151384_1_; + field_151388_d.field_151364_a = p_151384_0_; + applyEnchantmentModifierArray(field_151388_d, p_151384_0_.getLastActiveItems()); + + if (p_151384_1_ instanceof EntityPlayer) + { + applyEnchantmentModifier(field_151388_d, p_151384_0_.getHeldItem()); + } + } + + public static void func_151385_b(EntityLivingBase p_151385_0_, Entity p_151385_1_) + { + field_151389_e.field_151366_a = p_151385_0_; + field_151389_e.field_151365_b = p_151385_1_; + applyEnchantmentModifierArray(field_151389_e, p_151385_0_.getLastActiveItems()); + + if (p_151385_0_ instanceof EntityPlayer) + { + applyEnchantmentModifier(field_151389_e, p_151385_0_.getHeldItem()); + } + } + + public static int getKnockbackModifier(EntityLivingBase par0EntityLivingBase, EntityLivingBase par1EntityLivingBase) + { + return getEnchantmentLevel(Enchantment.knockback.effectId, par0EntityLivingBase.getHeldItem()); + } + + public static int getFireAspectModifier(EntityLivingBase par0EntityLivingBase) + { + return getEnchantmentLevel(Enchantment.fireAspect.effectId, par0EntityLivingBase.getHeldItem()); + } + + public static int getRespiration(EntityLivingBase par0EntityLivingBase) + { + return getMaxEnchantmentLevel(Enchantment.respiration.effectId, par0EntityLivingBase.getLastActiveItems()); + } + + public static int getEfficiencyModifier(EntityLivingBase par0EntityLivingBase) + { + return getEnchantmentLevel(Enchantment.efficiency.effectId, par0EntityLivingBase.getHeldItem()); + } + + public static boolean getSilkTouchModifier(EntityLivingBase par0EntityLivingBase) + { + return getEnchantmentLevel(Enchantment.silkTouch.effectId, par0EntityLivingBase.getHeldItem()) > 0; + } + + public static int getFortuneModifier(EntityLivingBase par0EntityLivingBase) + { + return getEnchantmentLevel(Enchantment.fortune.effectId, par0EntityLivingBase.getHeldItem()); + } + + public static int func_151386_g(EntityLivingBase p_151386_0_) + { + return getEnchantmentLevel(Enchantment.field_151370_z.effectId, p_151386_0_.getHeldItem()); + } + + public static int func_151387_h(EntityLivingBase p_151387_0_) + { + return getEnchantmentLevel(Enchantment.field_151369_A.effectId, p_151387_0_.getHeldItem()); + } + + public static int getLootingModifier(EntityLivingBase par0EntityLivingBase) + { + return getEnchantmentLevel(Enchantment.looting.effectId, par0EntityLivingBase.getHeldItem()); + } + + public static boolean getAquaAffinityModifier(EntityLivingBase par0EntityLivingBase) + { + return getMaxEnchantmentLevel(Enchantment.aquaAffinity.effectId, par0EntityLivingBase.getLastActiveItems()) > 0; + } + + public static ItemStack func_92099_a(Enchantment par0Enchantment, EntityLivingBase par1EntityLivingBase) + { + ItemStack[] aitemstack = par1EntityLivingBase.getLastActiveItems(); + int i = aitemstack.length; + + for (int j = 0; j < i; ++j) + { + ItemStack itemstack = aitemstack[j]; + + if (itemstack != null && getEnchantmentLevel(par0Enchantment.effectId, itemstack) > 0) + { + return itemstack; + } + } + + return null; + } + + public static int calcItemStackEnchantability(Random par0Random, int par1, int par2, ItemStack par3ItemStack) + { + Item item = par3ItemStack.getItem(); + int k = item.getItemEnchantability(); + + if (k <= 0) + { + return 0; + } + else + { + if (par2 > 15) + { + par2 = 15; + } + + int l = par0Random.nextInt(8) + 1 + (par2 >> 1) + par0Random.nextInt(par2 + 1); + return par1 == 0 ? Math.max(l / 3, 1) : (par1 == 1 ? l * 2 / 3 + 1 : Math.max(l, par2 * 2)); + } + } + + public static ItemStack addRandomEnchantment(Random par0Random, ItemStack par1ItemStack, int par2) + { + List list = buildEnchantmentList(par0Random, par1ItemStack, par2); + boolean flag = par1ItemStack.getItem() == Items.book; + + if (flag) + { + par1ItemStack.func_150996_a(Items.enchanted_book); + } + + if (list != null) + { + Iterator iterator = list.iterator(); + + while (iterator.hasNext()) + { + EnchantmentData enchantmentdata = (EnchantmentData)iterator.next(); + + if (flag) + { + Items.enchanted_book.addEnchantment(par1ItemStack, enchantmentdata); + } + else + { + par1ItemStack.addEnchantment(enchantmentdata.enchantmentobj, enchantmentdata.enchantmentLevel); + } + } + } + + return par1ItemStack; + } + + public static List buildEnchantmentList(Random par0Random, ItemStack par1ItemStack, int par2) + { + Item item = par1ItemStack.getItem(); + int j = item.getItemEnchantability(); + + if (j <= 0) + { + return null; + } + else + { + j /= 2; + j = 1 + par0Random.nextInt((j >> 1) + 1) + par0Random.nextInt((j >> 1) + 1); + int k = j + par2; + float f = (par0Random.nextFloat() + par0Random.nextFloat() - 1.0F) * 0.15F; + int l = (int)((float)k * (1.0F + f) + 0.5F); + + if (l < 1) + { + l = 1; + } + + ArrayList arraylist = null; + Map map = mapEnchantmentData(l, par1ItemStack); + + if (map != null && !map.isEmpty()) + { + EnchantmentData enchantmentdata = (EnchantmentData)WeightedRandom.getRandomItem(par0Random, map.values()); + + if (enchantmentdata != null) + { + arraylist = new ArrayList(); + arraylist.add(enchantmentdata); + + for (int i1 = l; par0Random.nextInt(50) <= i1; i1 >>= 1) + { + Iterator iterator = map.keySet().iterator(); + + while (iterator.hasNext()) + { + Integer integer = (Integer)iterator.next(); + boolean flag = true; + Iterator iterator1 = arraylist.iterator(); + + while (true) + { + if (iterator1.hasNext()) + { + EnchantmentData enchantmentdata1 = (EnchantmentData)iterator1.next(); + + if (enchantmentdata1.enchantmentobj.canApplyTogether(Enchantment.enchantmentsList[integer.intValue()])) + { + continue; + } + + flag = false; + } + + if (!flag) + { + iterator.remove(); + } + + break; + } + } + + if (!map.isEmpty()) + { + EnchantmentData enchantmentdata2 = (EnchantmentData)WeightedRandom.getRandomItem(par0Random, map.values()); + arraylist.add(enchantmentdata2); + } + } + } + } + + return arraylist; + } + } + + public static Map mapEnchantmentData(int par0, ItemStack par1ItemStack) + { + Item item = par1ItemStack.getItem(); + HashMap hashmap = null; + boolean flag = par1ItemStack.getItem() == Items.book; + Enchantment[] aenchantment = Enchantment.enchantmentsList; + int j = aenchantment.length; + + for (int k = 0; k < j; ++k) + { + Enchantment enchantment = aenchantment[k]; + + if (enchantment == null) continue; + if (enchantment.canApplyAtEnchantingTable(par1ItemStack) || ((item == Items.book) && enchantment.isAllowedOnBooks())) + { + for (int l = enchantment.getMinLevel(); l <= enchantment.getMaxLevel(); ++l) + { + if (par0 >= enchantment.getMinEnchantability(l) && par0 <= enchantment.getMaxEnchantability(l)) + { + if (hashmap == null) + { + hashmap = new HashMap(); + } + + hashmap.put(Integer.valueOf(enchantment.effectId), new EnchantmentData(enchantment, l)); + } + } + } + } + + return hashmap; + } + + static final class DamageIterator implements EnchantmentHelper.IModifier + { + public EntityLivingBase field_151366_a; + public Entity field_151365_b; + private static final String __OBFID = "CL_00000109"; + + private DamageIterator() {} + + public void calculateModifier(Enchantment par1Enchantment, int par2) + { + par1Enchantment.func_151368_a(this.field_151366_a, this.field_151365_b, par2); + } + + DamageIterator(Object p_i45359_1_) + { + this(); + } + } + + static final class HurtIterator implements EnchantmentHelper.IModifier + { + public EntityLivingBase field_151364_a; + public Entity field_151363_b; + private static final String __OBFID = "CL_00000110"; + + private HurtIterator() {} + + public void calculateModifier(Enchantment par1Enchantment, int par2) + { + par1Enchantment.func_151367_b(this.field_151364_a, this.field_151363_b, par2); + } + + HurtIterator(Object p_i45360_1_) + { + this(); + } + } + + interface IModifier + { + void calculateModifier(Enchantment var1, int var2); + } + + static final class ModifierDamage implements EnchantmentHelper.IModifier + { + public int damageModifier; + public DamageSource source; + private static final String __OBFID = "CL_00000114"; + + private ModifierDamage() {} + + public void calculateModifier(Enchantment par1Enchantment, int par2) + { + this.damageModifier += par1Enchantment.calcModifierDamage(par2, this.source); + } + + ModifierDamage(Object par1Empty3) + { + this(); + } + } + + static final class ModifierLiving implements EnchantmentHelper.IModifier + { + public float livingModifier; + public EntityLivingBase entityLiving; + private static final String __OBFID = "CL_00000112"; + + private ModifierLiving() {} + + public void calculateModifier(Enchantment par1Enchantment, int par2) + { + this.livingModifier += par1Enchantment.calcModifierLiving(par2, this.entityLiving); + } + + ModifierLiving(Object par1Empty3) + { + this(); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/enchantment/EnchantmentKnockback.java b/src/main/java/net/minecraft/enchantment/EnchantmentKnockback.java new file mode 100644 index 0000000..c76cd1b --- /dev/null +++ b/src/main/java/net/minecraft/enchantment/EnchantmentKnockback.java @@ -0,0 +1,27 @@ +package net.minecraft.enchantment; + +public class EnchantmentKnockback extends Enchantment +{ + private static final String __OBFID = "CL_00000118"; + + protected EnchantmentKnockback(int par1, int par2) + { + super(par1, par2, EnumEnchantmentType.weapon); + this.setName("knockback"); + } + + public int getMinEnchantability(int par1) + { + return 5 + 20 * (par1 - 1); + } + + public int getMaxEnchantability(int par1) + { + return super.getMinEnchantability(par1) + 50; + } + + public int getMaxLevel() + { + return 2; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/enchantment/EnchantmentLootBonus.java b/src/main/java/net/minecraft/enchantment/EnchantmentLootBonus.java new file mode 100644 index 0000000..22c3a51 --- /dev/null +++ b/src/main/java/net/minecraft/enchantment/EnchantmentLootBonus.java @@ -0,0 +1,44 @@ +package net.minecraft.enchantment; + +public class EnchantmentLootBonus extends Enchantment +{ + private static final String __OBFID = "CL_00000119"; + + protected EnchantmentLootBonus(int par1, int par2, EnumEnchantmentType par3EnumEnchantmentType) + { + super(par1, par2, par3EnumEnchantmentType); + + if (par3EnumEnchantmentType == EnumEnchantmentType.digger) + { + this.setName("lootBonusDigger"); + } + else if (par3EnumEnchantmentType == EnumEnchantmentType.fishing_rod) + { + this.setName("lootBonusFishing"); + } + else + { + this.setName("lootBonus"); + } + } + + public int getMinEnchantability(int par1) + { + return 15 + (par1 - 1) * 9; + } + + public int getMaxEnchantability(int par1) + { + return super.getMinEnchantability(par1) + 50; + } + + public int getMaxLevel() + { + return 3; + } + + public boolean canApplyTogether(Enchantment par1Enchantment) + { + return super.canApplyTogether(par1Enchantment) && par1Enchantment.effectId != silkTouch.effectId; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/enchantment/EnchantmentOxygen.java b/src/main/java/net/minecraft/enchantment/EnchantmentOxygen.java new file mode 100644 index 0000000..7c8a9fe --- /dev/null +++ b/src/main/java/net/minecraft/enchantment/EnchantmentOxygen.java @@ -0,0 +1,27 @@ +package net.minecraft.enchantment; + +public class EnchantmentOxygen extends Enchantment +{ + private static final String __OBFID = "CL_00000120"; + + public EnchantmentOxygen(int par1, int par2) + { + super(par1, par2, EnumEnchantmentType.armor_head); + this.setName("oxygen"); + } + + public int getMinEnchantability(int par1) + { + return 10 * par1; + } + + public int getMaxEnchantability(int par1) + { + return this.getMinEnchantability(par1) + 30; + } + + public int getMaxLevel() + { + return 3; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/enchantment/EnchantmentProtection.java b/src/main/java/net/minecraft/enchantment/EnchantmentProtection.java new file mode 100644 index 0000000..94cc346 --- /dev/null +++ b/src/main/java/net/minecraft/enchantment/EnchantmentProtection.java @@ -0,0 +1,96 @@ +package net.minecraft.enchantment; + +import net.minecraft.entity.Entity; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; + +public class EnchantmentProtection extends Enchantment +{ + private static final String[] protectionName = new String[] {"all", "fire", "fall", "explosion", "projectile"}; + private static final int[] baseEnchantability = new int[] {1, 10, 5, 5, 3}; + private static final int[] levelEnchantability = new int[] {11, 8, 6, 8, 6}; + private static final int[] thresholdEnchantability = new int[] {20, 12, 10, 12, 15}; + public final int protectionType; + private static final String __OBFID = "CL_00000121"; + + public EnchantmentProtection(int par1, int par2, int par3) + { + super(par1, par2, EnumEnchantmentType.armor); + this.protectionType = par3; + + if (par3 == 2) + { + this.type = EnumEnchantmentType.armor_feet; + } + } + + public int getMinEnchantability(int par1) + { + return baseEnchantability[this.protectionType] + (par1 - 1) * levelEnchantability[this.protectionType]; + } + + public int getMaxEnchantability(int par1) + { + return this.getMinEnchantability(par1) + thresholdEnchantability[this.protectionType]; + } + + public int getMaxLevel() + { + return 4; + } + + public int calcModifierDamage(int par1, DamageSource par2DamageSource) + { + if (par2DamageSource.canHarmInCreative()) + { + return 0; + } + else + { + float f = (float)(6 + par1 * par1) / 3.0F; + return this.protectionType == 0 ? MathHelper.floor_float(f * 0.75F) : (this.protectionType == 1 && par2DamageSource.isFireDamage() ? MathHelper.floor_float(f * 1.25F) : (this.protectionType == 2 && par2DamageSource == DamageSource.fall ? MathHelper.floor_float(f * 2.5F) : (this.protectionType == 3 && par2DamageSource.isExplosion() ? MathHelper.floor_float(f * 1.5F) : (this.protectionType == 4 && par2DamageSource.isProjectile() ? MathHelper.floor_float(f * 1.5F) : 0)))); + } + } + + public String getName() + { + return "enchantment.protect." + protectionName[this.protectionType]; + } + + public boolean canApplyTogether(Enchantment par1Enchantment) + { + if (par1Enchantment instanceof EnchantmentProtection) + { + EnchantmentProtection enchantmentprotection = (EnchantmentProtection)par1Enchantment; + return enchantmentprotection.protectionType == this.protectionType ? false : this.protectionType == 2 || enchantmentprotection.protectionType == 2; + } + else + { + return super.canApplyTogether(par1Enchantment); + } + } + + public static int getFireTimeForEntity(Entity par0Entity, int par1) + { + int j = EnchantmentHelper.getMaxEnchantmentLevel(Enchantment.fireProtection.effectId, par0Entity.getLastActiveItems()); + + if (j > 0) + { + par1 -= MathHelper.floor_float((float)par1 * (float)j * 0.15F); + } + + return par1; + } + + public static double func_92092_a(Entity par0Entity, double par1) + { + int i = EnchantmentHelper.getMaxEnchantmentLevel(Enchantment.blastProtection.effectId, par0Entity.getLastActiveItems()); + + if (i > 0) + { + par1 -= (double)MathHelper.floor_double(par1 * (double)((float)i * 0.15F)); + } + + return par1; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/enchantment/EnchantmentThorns.java b/src/main/java/net/minecraft/enchantment/EnchantmentThorns.java new file mode 100644 index 0000000..99e2b22 --- /dev/null +++ b/src/main/java/net/minecraft/enchantment/EnchantmentThorns.java @@ -0,0 +1,70 @@ +package net.minecraft.enchantment; + +import java.util.Random; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemArmor; +import net.minecraft.item.ItemStack; +import net.minecraft.util.DamageSource; + +public class EnchantmentThorns extends Enchantment +{ + private static final String __OBFID = "CL_00000122"; + + public EnchantmentThorns(int par1, int par2) + { + super(par1, par2, EnumEnchantmentType.armor_torso); + this.setName("thorns"); + } + + public int getMinEnchantability(int par1) + { + return 10 + 20 * (par1 - 1); + } + + public int getMaxEnchantability(int par1) + { + return super.getMinEnchantability(par1) + 50; + } + + public int getMaxLevel() + { + return 3; + } + + public boolean canApply(ItemStack par1ItemStack) + { + return par1ItemStack.getItem() instanceof ItemArmor ? true : super.canApply(par1ItemStack); + } + + public void func_151367_b(EntityLivingBase p_151367_1_, Entity p_151367_2_, int p_151367_3_) + { + Random random = p_151367_1_.getRNG(); + ItemStack itemstack = EnchantmentHelper.func_92099_a(Enchantment.thorns, p_151367_1_); + + if (func_92094_a(p_151367_3_, random)) + { + p_151367_2_.attackEntityFrom(DamageSource.causeThornsDamage(p_151367_1_), (float)func_92095_b(p_151367_3_, random)); + p_151367_2_.playSound("damage.thorns", 0.5F, 1.0F); + + if (itemstack != null) + { + itemstack.damageItem(3, p_151367_1_); + } + } + else if (itemstack != null) + { + itemstack.damageItem(1, p_151367_1_); + } + } + + public static boolean func_92094_a(int par0, Random par1Random) + { + return par0 <= 0 ? false : par1Random.nextFloat() < 0.15F * (float)par0; + } + + public static int func_92095_b(int par0, Random par1Random) + { + return par0 > 10 ? par0 - 10 : 1 + par1Random.nextInt(4); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/enchantment/EnchantmentUntouching.java b/src/main/java/net/minecraft/enchantment/EnchantmentUntouching.java new file mode 100644 index 0000000..1c492cd --- /dev/null +++ b/src/main/java/net/minecraft/enchantment/EnchantmentUntouching.java @@ -0,0 +1,40 @@ +package net.minecraft.enchantment; + +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; + +public class EnchantmentUntouching extends Enchantment +{ + private static final String __OBFID = "CL_00000123"; + + protected EnchantmentUntouching(int par1, int par2) + { + super(par1, par2, EnumEnchantmentType.digger); + this.setName("untouching"); + } + + public int getMinEnchantability(int par1) + { + return 15; + } + + public int getMaxEnchantability(int par1) + { + return super.getMinEnchantability(par1) + 50; + } + + public int getMaxLevel() + { + return 1; + } + + public boolean canApplyTogether(Enchantment par1Enchantment) + { + return super.canApplyTogether(par1Enchantment) && par1Enchantment.effectId != fortune.effectId; + } + + public boolean canApply(ItemStack par1ItemStack) + { + return par1ItemStack.getItem() == Items.shears ? true : super.canApply(par1ItemStack); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/enchantment/EnchantmentWaterWorker.java b/src/main/java/net/minecraft/enchantment/EnchantmentWaterWorker.java new file mode 100644 index 0000000..e62528b --- /dev/null +++ b/src/main/java/net/minecraft/enchantment/EnchantmentWaterWorker.java @@ -0,0 +1,27 @@ +package net.minecraft.enchantment; + +public class EnchantmentWaterWorker extends Enchantment +{ + private static final String __OBFID = "CL_00000124"; + + public EnchantmentWaterWorker(int par1, int par2) + { + super(par1, par2, EnumEnchantmentType.armor_head); + this.setName("waterWorker"); + } + + public int getMinEnchantability(int par1) + { + return 1; + } + + public int getMaxEnchantability(int par1) + { + return this.getMinEnchantability(par1) + 40; + } + + public int getMaxLevel() + { + return 1; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/enchantment/EnumEnchantmentType.java b/src/main/java/net/minecraft/enchantment/EnumEnchantmentType.java new file mode 100644 index 0000000..f1bf525 --- /dev/null +++ b/src/main/java/net/minecraft/enchantment/EnumEnchantmentType.java @@ -0,0 +1,53 @@ +package net.minecraft.enchantment; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemArmor; +import net.minecraft.item.ItemBow; +import net.minecraft.item.ItemFishingRod; +import net.minecraft.item.ItemSword; +import net.minecraft.item.ItemTool; + +public enum EnumEnchantmentType +{ + all, + armor, + armor_feet, + armor_legs, + armor_torso, + armor_head, + weapon, + digger, + fishing_rod, + breakable, + bow; + + private static final String __OBFID = "CL_00000106"; + + public boolean canEnchantItem(Item par1Item) + { + if (this == all) + { + return true; + } + else if (this == breakable && par1Item.isDamageable()) + { + return true; + } + else if (par1Item instanceof ItemArmor) + { + if (this == armor) + { + return true; + } + else + { + ItemArmor itemarmor = (ItemArmor)par1Item; + return itemarmor.armorType == 0 ? this == armor_head : (itemarmor.armorType == 2 ? this == armor_legs : (itemarmor.armorType == 1 ? this == armor_torso : (itemarmor.armorType == 3 ? this == armor_feet : false))); + } + } + else + { + return par1Item instanceof ItemSword ? this == weapon : (par1Item instanceof ItemTool ? this == digger : (par1Item instanceof ItemBow ? this == bow : (par1Item instanceof ItemFishingRod ? this == fishing_rod : false))); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/DataWatcher.java b/src/main/java/net/minecraft/entity/DataWatcher.java new file mode 100644 index 0000000..a5398dd --- /dev/null +++ b/src/main/java/net/minecraft/entity/DataWatcher.java @@ -0,0 +1,401 @@ +package net.minecraft.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.concurrent.locks.ReadWriteLock; +import java.util.concurrent.locks.ReentrantReadWriteLock; +import net.minecraft.crash.CrashReport; +import net.minecraft.crash.CrashReportCategory; +import net.minecraft.item.ItemStack; +import net.minecraft.network.PacketBuffer; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.ReportedException; +import org.apache.commons.lang3.ObjectUtils; + +public class DataWatcher +{ + private final Entity field_151511_a; + private boolean isBlank = true; + private static final HashMap dataTypes = new HashMap(); + private final Map watchedObjects = new HashMap(); + private boolean objectChanged; + private ReadWriteLock lock = new ReentrantReadWriteLock(); + private static final String __OBFID = "CL_00001559"; + + public DataWatcher(Entity p_i45313_1_) + { + this.field_151511_a = p_i45313_1_; + } + + public void addObject(int par1, Object par2Obj) + { + Integer integer = (Integer)dataTypes.get(par2Obj.getClass()); + + if (integer == null) + { + throw new IllegalArgumentException("Unknown data type: " + par2Obj.getClass()); + } + else if (par1 > 31) + { + throw new IllegalArgumentException("Data value id is too big with " + par1 + "! (Max is " + 31 + ")"); + } + else if (this.watchedObjects.containsKey(Integer.valueOf(par1))) + { + throw new IllegalArgumentException("Duplicate id value for " + par1 + "!"); + } + else + { + DataWatcher.WatchableObject watchableobject = new DataWatcher.WatchableObject(integer.intValue(), par1, par2Obj); + this.lock.writeLock().lock(); + this.watchedObjects.put(Integer.valueOf(par1), watchableobject); + this.lock.writeLock().unlock(); + this.isBlank = false; + } + } + + public void addObjectByDataType(int par1, int par2) + { + DataWatcher.WatchableObject watchableobject = new DataWatcher.WatchableObject(par2, par1, (Object)null); + this.lock.writeLock().lock(); + this.watchedObjects.put(Integer.valueOf(par1), watchableobject); + this.lock.writeLock().unlock(); + this.isBlank = false; + } + + public byte getWatchableObjectByte(int par1) + { + return ((Byte)this.getWatchedObject(par1).getObject()).byteValue(); + } + + public short getWatchableObjectShort(int par1) + { + return ((Short)this.getWatchedObject(par1).getObject()).shortValue(); + } + + public int getWatchableObjectInt(int par1) + { + return ((Integer)this.getWatchedObject(par1).getObject()).intValue(); + } + + public float getWatchableObjectFloat(int par1) + { + return ((Float)this.getWatchedObject(par1).getObject()).floatValue(); + } + + public String getWatchableObjectString(int par1) + { + return (String)this.getWatchedObject(par1).getObject(); + } + + public ItemStack getWatchableObjectItemStack(int par1) + { + return (ItemStack)this.getWatchedObject(par1).getObject(); + } + + private DataWatcher.WatchableObject getWatchedObject(int par1) + { + this.lock.readLock().lock(); + DataWatcher.WatchableObject watchableobject; + + try + { + watchableobject = (DataWatcher.WatchableObject)this.watchedObjects.get(Integer.valueOf(par1)); + } + catch (Throwable throwable) + { + CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Getting synched entity data"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("Synched entity data"); + crashreportcategory.addCrashSection("Data ID", Integer.valueOf(par1)); + throw new ReportedException(crashreport); + } + + this.lock.readLock().unlock(); + return watchableobject; + } + + public void updateObject(int par1, Object par2Obj) + { + DataWatcher.WatchableObject watchableobject = this.getWatchedObject(par1); + + if (ObjectUtils.notEqual(par2Obj, watchableobject.getObject())) + { + watchableobject.setObject(par2Obj); + this.field_151511_a.func_145781_i(par1); + watchableobject.setWatched(true); + this.objectChanged = true; + } + } + + public void setObjectWatched(int par1) + { + this.getWatchedObject(par1).watched = true; + this.objectChanged = true; + } + + public boolean hasChanges() + { + return this.objectChanged; + } + + public static void writeWatchedListToPacketBuffer(List p_151507_0_, PacketBuffer p_151507_1_) throws IOException + { + if (p_151507_0_ != null) + { + Iterator iterator = p_151507_0_.iterator(); + + while (iterator.hasNext()) + { + DataWatcher.WatchableObject watchableobject = (DataWatcher.WatchableObject)iterator.next(); + writeWatchableObjectToPacketBuffer(p_151507_1_, watchableobject); + } + } + + p_151507_1_.writeByte(127); + } + + public List getChanged() + { + ArrayList arraylist = null; + + if (this.objectChanged) + { + this.lock.readLock().lock(); + Iterator iterator = this.watchedObjects.values().iterator(); + + while (iterator.hasNext()) + { + DataWatcher.WatchableObject watchableobject = (DataWatcher.WatchableObject)iterator.next(); + + if (watchableobject.isWatched()) + { + watchableobject.setWatched(false); + + if (arraylist == null) + { + arraylist = new ArrayList(); + } + + arraylist.add(watchableobject); + } + } + + this.lock.readLock().unlock(); + } + + this.objectChanged = false; + return arraylist; + } + + public void func_151509_a(PacketBuffer p_151509_1_) throws IOException + { + this.lock.readLock().lock(); + Iterator iterator = this.watchedObjects.values().iterator(); + + while (iterator.hasNext()) + { + DataWatcher.WatchableObject watchableobject = (DataWatcher.WatchableObject)iterator.next(); + writeWatchableObjectToPacketBuffer(p_151509_1_, watchableobject); + } + + this.lock.readLock().unlock(); + p_151509_1_.writeByte(127); + } + + public List getAllWatched() + { + ArrayList arraylist = null; + this.lock.readLock().lock(); + DataWatcher.WatchableObject watchableobject; + + for (Iterator iterator = this.watchedObjects.values().iterator(); iterator.hasNext(); arraylist.add(watchableobject)) + { + watchableobject = (DataWatcher.WatchableObject)iterator.next(); + + if (arraylist == null) + { + arraylist = new ArrayList(); + } + } + + this.lock.readLock().unlock(); + return arraylist; + } + + private static void writeWatchableObjectToPacketBuffer(PacketBuffer p_151510_0_, DataWatcher.WatchableObject p_151510_1_) throws IOException + { + int i = (p_151510_1_.getObjectType() << 5 | p_151510_1_.getDataValueId() & 31) & 255; + p_151510_0_.writeByte(i); + + switch (p_151510_1_.getObjectType()) + { + case 0: + p_151510_0_.writeByte(((Byte)p_151510_1_.getObject()).byteValue()); + break; + case 1: + p_151510_0_.writeShort(((Short)p_151510_1_.getObject()).shortValue()); + break; + case 2: + p_151510_0_.writeInt(((Integer)p_151510_1_.getObject()).intValue()); + break; + case 3: + p_151510_0_.writeFloat(((Float)p_151510_1_.getObject()).floatValue()); + break; + case 4: + p_151510_0_.writeStringToBuffer((String)p_151510_1_.getObject()); + break; + case 5: + ItemStack itemstack = (ItemStack)p_151510_1_.getObject(); + p_151510_0_.writeItemStackToBuffer(itemstack); + break; + case 6: + ChunkCoordinates chunkcoordinates = (ChunkCoordinates)p_151510_1_.getObject(); + p_151510_0_.writeInt(chunkcoordinates.posX); + p_151510_0_.writeInt(chunkcoordinates.posY); + p_151510_0_.writeInt(chunkcoordinates.posZ); + } + } + + public static List readWatchedListFromPacketBuffer(PacketBuffer p_151508_0_) throws IOException + { + ArrayList arraylist = null; + + for (byte b0 = p_151508_0_.readByte(); b0 != 127; b0 = p_151508_0_.readByte()) + { + if (arraylist == null) + { + arraylist = new ArrayList(); + } + + int i = (b0 & 224) >> 5; + int j = b0 & 31; + DataWatcher.WatchableObject watchableobject = null; + + switch (i) + { + case 0: + watchableobject = new DataWatcher.WatchableObject(i, j, Byte.valueOf(p_151508_0_.readByte())); + break; + case 1: + watchableobject = new DataWatcher.WatchableObject(i, j, Short.valueOf(p_151508_0_.readShort())); + break; + case 2: + watchableobject = new DataWatcher.WatchableObject(i, j, Integer.valueOf(p_151508_0_.readInt())); + break; + case 3: + watchableobject = new DataWatcher.WatchableObject(i, j, Float.valueOf(p_151508_0_.readFloat())); + break; + case 4: + watchableobject = new DataWatcher.WatchableObject(i, j, p_151508_0_.readStringFromBuffer(32767)); + break; + case 5: + watchableobject = new DataWatcher.WatchableObject(i, j, p_151508_0_.readItemStackFromBuffer()); + break; + case 6: + int k = p_151508_0_.readInt(); + int l = p_151508_0_.readInt(); + int i1 = p_151508_0_.readInt(); + watchableobject = new DataWatcher.WatchableObject(i, j, new ChunkCoordinates(k, l, i1)); + } + + arraylist.add(watchableobject); + } + + return arraylist; + } + + @SideOnly(Side.CLIENT) + public void updateWatchedObjectsFromList(List par1List) + { + this.lock.writeLock().lock(); + Iterator iterator = par1List.iterator(); + + while (iterator.hasNext()) + { + DataWatcher.WatchableObject watchableobject = (DataWatcher.WatchableObject)iterator.next(); + DataWatcher.WatchableObject watchableobject1 = (DataWatcher.WatchableObject)this.watchedObjects.get(Integer.valueOf(watchableobject.getDataValueId())); + + if (watchableobject1 != null) + { + watchableobject1.setObject(watchableobject.getObject()); + this.field_151511_a.func_145781_i(watchableobject.getDataValueId()); + } + } + + this.lock.writeLock().unlock(); + this.objectChanged = true; + } + + public boolean getIsBlank() + { + return this.isBlank; + } + + public void func_111144_e() + { + this.objectChanged = false; + } + + static + { + dataTypes.put(Byte.class, Integer.valueOf(0)); + dataTypes.put(Short.class, Integer.valueOf(1)); + dataTypes.put(Integer.class, Integer.valueOf(2)); + dataTypes.put(Float.class, Integer.valueOf(3)); + dataTypes.put(String.class, Integer.valueOf(4)); + dataTypes.put(ItemStack.class, Integer.valueOf(5)); + dataTypes.put(ChunkCoordinates.class, Integer.valueOf(6)); + } + + public static class WatchableObject + { + private final int objectType; + private final int dataValueId; + private Object watchedObject; + private boolean watched; + private static final String __OBFID = "CL_00001560"; + + public WatchableObject(int par1, int par2, Object par3Obj) + { + this.dataValueId = par2; + this.watchedObject = par3Obj; + this.objectType = par1; + this.watched = true; + } + + public int getDataValueId() + { + return this.dataValueId; + } + + public void setObject(Object par1Obj) + { + this.watchedObject = par1Obj; + } + + public Object getObject() + { + return this.watchedObject; + } + + public int getObjectType() + { + return this.objectType; + } + + public boolean isWatched() + { + return this.watched; + } + + public void setWatched(boolean par1) + { + this.watched = par1; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/Entity.java b/src/main/java/net/minecraft/entity/Entity.java new file mode 100644 index 0000000..a9a47f6 --- /dev/null +++ b/src/main/java/net/minecraft/entity/Entity.java @@ -0,0 +1,2466 @@ +package net.minecraft.entity; + +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Random; +import java.util.UUID; +import java.util.concurrent.Callable; +import net.minecraft.block.Block; +import net.minecraft.block.BlockLiquid; +import net.minecraft.block.material.Material; +import net.minecraft.crash.CrashReport; +import net.minecraft.crash.CrashReportCategory; +import net.minecraft.enchantment.EnchantmentProtection; +import net.minecraft.entity.effect.EntityLightningBolt; +import net.minecraft.entity.item.EntityBoat; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.item.EntityItemFrame; +import net.minecraft.entity.item.EntityMinecart; +import net.minecraft.entity.item.EntityPainting; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagDouble; +import net.minecraft.nbt.NBTTagFloat; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.DamageSource; +import net.minecraft.util.Direction; +import net.minecraft.util.IChatComponent; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.ReportedException; +import net.minecraft.util.StatCollector; +import net.minecraft.util.Vec3; +import net.minecraft.world.Explosion; +import net.minecraft.world.World; +import net.minecraft.world.WorldServer; +import net.minecraftforge.common.IExtendedEntityProperties; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.EntityEvent; +import net.minecraftforge.fluids.IFluidBlock; + +public abstract class Entity +{ + private static int nextEntityID; + private int entityId; + public double renderDistanceWeight; + public boolean preventEntitySpawning; + public Entity riddenByEntity; + public Entity ridingEntity; + public boolean forceSpawn; + public World worldObj; + public double prevPosX; + public double prevPosY; + public double prevPosZ; + public double posX; + public double posY; + public double posZ; + public double motionX; + public double motionY; + public double motionZ; + public float rotationYaw; + public float rotationPitch; + public float prevRotationYaw; + public float prevRotationPitch; + public final AxisAlignedBB boundingBox; + public boolean onGround; + public boolean isCollidedHorizontally; + public boolean isCollidedVertically; + public boolean isCollided; + public boolean velocityChanged; + protected boolean isInWeb; + public boolean field_70135_K; + public boolean isDead; + public float yOffset; + public float width; + public float height; + public float prevDistanceWalkedModified; + public float distanceWalkedModified; + public float distanceWalkedOnStepModified; + public float fallDistance; + private int nextStepDistance; + public double lastTickPosX; + public double lastTickPosY; + public double lastTickPosZ; + public float ySize; + public float stepHeight; + public boolean noClip; + public float entityCollisionReduction; + protected Random rand; + public int ticksExisted; + public int fireResistance; + private int fire; + protected boolean inWater; + public int hurtResistantTime; + private boolean firstUpdate; + protected boolean isImmuneToFire; + protected DataWatcher dataWatcher; + private double entityRiderPitchDelta; + private double entityRiderYawDelta; + public boolean addedToChunk; + public int chunkCoordX; + public int chunkCoordY; + public int chunkCoordZ; + @SideOnly(Side.CLIENT) + public int serverPosX; + @SideOnly(Side.CLIENT) + public int serverPosY; + @SideOnly(Side.CLIENT) + public int serverPosZ; + public boolean ignoreFrustumCheck; + public boolean isAirBorne; + public int timeUntilPortal; + protected boolean inPortal; + protected int portalCounter; + public int dimension; + protected int teleportDirection; + private boolean invulnerable; + protected UUID entityUniqueID; + public Entity.EnumEntitySize myEntitySize; + private static final String __OBFID = "CL_00001533"; + /** Forge: Used to store custom data for each entity. */ + private NBTTagCompound customEntityData; + public boolean captureDrops = false; + public ArrayList capturedDrops = new ArrayList(); + private UUID persistentID; + + private HashMap extendedProperties; + + public int getEntityId() + { + return this.entityId; + } + + public void setEntityId(int p_145769_1_) + { + this.entityId = p_145769_1_; + } + + public Entity(World par1World) + { + this.entityId = nextEntityID++; + this.renderDistanceWeight = 1.0D; + this.boundingBox = AxisAlignedBB.getBoundingBox(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D); + this.field_70135_K = true; + this.width = 0.6F; + this.height = 1.8F; + this.nextStepDistance = 1; + this.rand = new Random(); + this.fireResistance = 1; + this.firstUpdate = true; + this.entityUniqueID = UUID.randomUUID(); + this.myEntitySize = Entity.EnumEntitySize.SIZE_2; + this.worldObj = par1World; + this.setPosition(0.0D, 0.0D, 0.0D); + + if (par1World != null) + { + this.dimension = par1World.provider.dimensionId; + } + + this.dataWatcher = new DataWatcher(this); + this.dataWatcher.addObject(0, Byte.valueOf((byte)0)); + this.dataWatcher.addObject(1, Short.valueOf((short)300)); + this.entityInit(); + + extendedProperties = new HashMap(); + + MinecraftForge.EVENT_BUS.post(new EntityEvent.EntityConstructing(this)); + + for (IExtendedEntityProperties props : this.extendedProperties.values()) + { + props.init(this, par1World); + } + } + + protected abstract void entityInit(); + + public DataWatcher getDataWatcher() + { + return this.dataWatcher; + } + + public boolean equals(Object par1Obj) + { + return par1Obj instanceof Entity ? ((Entity)par1Obj).entityId == this.entityId : false; + } + + public int hashCode() + { + return this.entityId; + } + + @SideOnly(Side.CLIENT) + protected void preparePlayerToSpawn() + { + if (this.worldObj != null) + { + while (this.posY > 0.0D) + { + this.setPosition(this.posX, this.posY, this.posZ); + + if (this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox).isEmpty()) + { + break; + } + + ++this.posY; + } + + this.motionX = this.motionY = this.motionZ = 0.0D; + this.rotationPitch = 0.0F; + } + } + + public void setDead() + { + this.isDead = true; + } + + protected void setSize(float par1, float par2) + { + float f2; + + if (par1 != this.width || par2 != this.height) + { + f2 = this.width; + this.width = par1; + this.height = par2; + this.boundingBox.maxX = this.boundingBox.minX + (double)this.width; + this.boundingBox.maxZ = this.boundingBox.minZ + (double)this.width; + this.boundingBox.maxY = this.boundingBox.minY + (double)this.height; + + if (this.width > f2 && !this.firstUpdate && !this.worldObj.isRemote) + { + this.moveEntity((double)(f2 - this.width), 0.0D, (double)(f2 - this.width)); + } + } + + f2 = par1 % 2.0F; + + if ((double)f2 < 0.375D) + { + this.myEntitySize = Entity.EnumEntitySize.SIZE_1; + } + else if ((double)f2 < 0.75D) + { + this.myEntitySize = Entity.EnumEntitySize.SIZE_2; + } + else if ((double)f2 < 1.0D) + { + this.myEntitySize = Entity.EnumEntitySize.SIZE_3; + } + else if ((double)f2 < 1.375D) + { + this.myEntitySize = Entity.EnumEntitySize.SIZE_4; + } + else if ((double)f2 < 1.75D) + { + this.myEntitySize = Entity.EnumEntitySize.SIZE_5; + } + else + { + this.myEntitySize = Entity.EnumEntitySize.SIZE_6; + } + } + + protected void setRotation(float par1, float par2) + { + this.rotationYaw = par1 % 360.0F; + this.rotationPitch = par2 % 360.0F; + } + + public void setPosition(double par1, double par3, double par5) + { + this.posX = par1; + this.posY = par3; + this.posZ = par5; + float f = this.width / 2.0F; + float f1 = this.height; + this.boundingBox.setBounds(par1 - (double)f, par3 - (double)this.yOffset + (double)this.ySize, par5 - (double)f, par1 + (double)f, par3 - (double)this.yOffset + (double)this.ySize + (double)f1, par5 + (double)f); + } + + @SideOnly(Side.CLIENT) + public void setAngles(float par1, float par2) + { + float f2 = this.rotationPitch; + float f3 = this.rotationYaw; + this.rotationYaw = (float)((double)this.rotationYaw + (double)par1 * 0.15D); + this.rotationPitch = (float)((double)this.rotationPitch - (double)par2 * 0.15D); + + if (this.rotationPitch < -90.0F) + { + this.rotationPitch = -90.0F; + } + + if (this.rotationPitch > 90.0F) + { + this.rotationPitch = 90.0F; + } + + this.prevRotationPitch += this.rotationPitch - f2; + this.prevRotationYaw += this.rotationYaw - f3; + } + + public void onUpdate() + { + this.onEntityUpdate(); + } + + public void onEntityUpdate() + { + this.worldObj.theProfiler.startSection("entityBaseTick"); + + if (this.ridingEntity != null && this.ridingEntity.isDead) + { + this.ridingEntity = null; + } + + this.prevDistanceWalkedModified = this.distanceWalkedModified; + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + this.prevRotationPitch = this.rotationPitch; + this.prevRotationYaw = this.rotationYaw; + int i; + + if (!this.worldObj.isRemote && this.worldObj instanceof WorldServer) + { + this.worldObj.theProfiler.startSection("portal"); + MinecraftServer minecraftserver = ((WorldServer)this.worldObj).func_73046_m(); + i = this.getMaxInPortalTime(); + + if (this.inPortal) + { + if (minecraftserver.getAllowNether()) + { + if (this.ridingEntity == null && this.portalCounter++ >= i) + { + this.portalCounter = i; + this.timeUntilPortal = this.getPortalCooldown(); + byte b0; + + if (this.worldObj.provider.dimensionId == -1) + { + b0 = 0; + } + else + { + b0 = -1; + } + + this.travelToDimension(b0); + } + + this.inPortal = false; + } + } + else + { + if (this.portalCounter > 0) + { + this.portalCounter -= 4; + } + + if (this.portalCounter < 0) + { + this.portalCounter = 0; + } + } + + if (this.timeUntilPortal > 0) + { + --this.timeUntilPortal; + } + + this.worldObj.theProfiler.endSection(); + } + + if (this.isSprinting() && !this.isInWater()) + { + int j = MathHelper.floor_double(this.posX); + i = MathHelper.floor_double(this.posY - 0.20000000298023224D - (double)this.yOffset); + int k = MathHelper.floor_double(this.posZ); + Block block = this.worldObj.getBlock(j, i, k); + + if (block.getMaterial() != Material.air) + { + this.worldObj.spawnParticle("blockcrack_" + Block.getIdFromBlock(block) + "_" + this.worldObj.getBlockMetadata(j, i, k), this.posX + ((double)this.rand.nextFloat() - 0.5D) * (double)this.width, this.boundingBox.minY + 0.1D, this.posZ + ((double)this.rand.nextFloat() - 0.5D) * (double)this.width, -this.motionX * 4.0D, 1.5D, -this.motionZ * 4.0D); + } + } + + this.handleWaterMovement(); + + if (this.worldObj.isRemote) + { + this.fire = 0; + } + else if (this.fire > 0) + { + if (this.isImmuneToFire) + { + this.fire -= 4; + + if (this.fire < 0) + { + this.fire = 0; + } + } + else + { + if (this.fire % 20 == 0) + { + this.attackEntityFrom(DamageSource.onFire, 1.0F); + } + + --this.fire; + } + } + + if (this.handleLavaMovement()) + { + this.setOnFireFromLava(); + this.fallDistance *= 0.5F; + } + + if (this.posY < -64.0D) + { + this.kill(); + } + + if (!this.worldObj.isRemote) + { + this.setFlag(0, this.fire > 0); + } + + this.firstUpdate = false; + this.worldObj.theProfiler.endSection(); + } + + public int getMaxInPortalTime() + { + return 0; + } + + protected void setOnFireFromLava() + { + if (!this.isImmuneToFire) + { + this.attackEntityFrom(DamageSource.lava, 4.0F); + this.setFire(15); + } + } + + public void setFire(int par1) + { + int j = par1 * 20; + j = EnchantmentProtection.getFireTimeForEntity(this, j); + + if (this.fire < j) + { + this.fire = j; + } + } + + public void extinguish() + { + this.fire = 0; + } + + protected void kill() + { + this.setDead(); + } + + public boolean isOffsetPositionInLiquid(double par1, double par3, double par5) + { + AxisAlignedBB axisalignedbb = this.boundingBox.getOffsetBoundingBox(par1, par3, par5); + List list = this.worldObj.getCollidingBoundingBoxes(this, axisalignedbb); + return !list.isEmpty() ? false : !this.worldObj.isAnyLiquid(axisalignedbb); + } + + public void moveEntity(double par1, double par3, double par5) + { + if (this.noClip) + { + this.boundingBox.offset(par1, par3, par5); + this.posX = (this.boundingBox.minX + this.boundingBox.maxX) / 2.0D; + this.posY = this.boundingBox.minY + (double)this.yOffset - (double)this.ySize; + this.posZ = (this.boundingBox.minZ + this.boundingBox.maxZ) / 2.0D; + } + else + { + this.worldObj.theProfiler.startSection("move"); + this.ySize *= 0.4F; + double d3 = this.posX; + double d4 = this.posY; + double d5 = this.posZ; + + if (this.isInWeb) + { + this.isInWeb = false; + par1 *= 0.25D; + par3 *= 0.05000000074505806D; + par5 *= 0.25D; + this.motionX = 0.0D; + this.motionY = 0.0D; + this.motionZ = 0.0D; + } + + double d6 = par1; + double d7 = par3; + double d8 = par5; + AxisAlignedBB axisalignedbb = this.boundingBox.copy(); + boolean flag = this.onGround && this.isSneaking() && this instanceof EntityPlayer; + + if (flag) + { + double d9; + + for (d9 = 0.05D; par1 != 0.0D && this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox.getOffsetBoundingBox(par1, -1.0D, 0.0D)).isEmpty(); d6 = par1) + { + if (par1 < d9 && par1 >= -d9) + { + par1 = 0.0D; + } + else if (par1 > 0.0D) + { + par1 -= d9; + } + else + { + par1 += d9; + } + } + + for (; par5 != 0.0D && this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox.getOffsetBoundingBox(0.0D, -1.0D, par5)).isEmpty(); d8 = par5) + { + if (par5 < d9 && par5 >= -d9) + { + par5 = 0.0D; + } + else if (par5 > 0.0D) + { + par5 -= d9; + } + else + { + par5 += d9; + } + } + + while (par1 != 0.0D && par5 != 0.0D && this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox.getOffsetBoundingBox(par1, -1.0D, par5)).isEmpty()) + { + if (par1 < d9 && par1 >= -d9) + { + par1 = 0.0D; + } + else if (par1 > 0.0D) + { + par1 -= d9; + } + else + { + par1 += d9; + } + + if (par5 < d9 && par5 >= -d9) + { + par5 = 0.0D; + } + else if (par5 > 0.0D) + { + par5 -= d9; + } + else + { + par5 += d9; + } + + d6 = par1; + d8 = par5; + } + } + + List list = this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox.addCoord(par1, par3, par5)); + + for (int i = 0; i < list.size(); ++i) + { + par3 = ((AxisAlignedBB)list.get(i)).calculateYOffset(this.boundingBox, par3); + } + + this.boundingBox.offset(0.0D, par3, 0.0D); + + if (!this.field_70135_K && d7 != par3) + { + par5 = 0.0D; + par3 = 0.0D; + par1 = 0.0D; + } + + boolean flag1 = this.onGround || d7 != par3 && d7 < 0.0D; + int j; + + for (j = 0; j < list.size(); ++j) + { + par1 = ((AxisAlignedBB)list.get(j)).calculateXOffset(this.boundingBox, par1); + } + + this.boundingBox.offset(par1, 0.0D, 0.0D); + + if (!this.field_70135_K && d6 != par1) + { + par5 = 0.0D; + par3 = 0.0D; + par1 = 0.0D; + } + + for (j = 0; j < list.size(); ++j) + { + par5 = ((AxisAlignedBB)list.get(j)).calculateZOffset(this.boundingBox, par5); + } + + this.boundingBox.offset(0.0D, 0.0D, par5); + + if (!this.field_70135_K && d8 != par5) + { + par5 = 0.0D; + par3 = 0.0D; + par1 = 0.0D; + } + + double d10; + double d11; + int k; + double d12; + + if (this.stepHeight > 0.0F && flag1 && (flag || this.ySize < 0.05F) && (d6 != par1 || d8 != par5)) + { + d12 = par1; + d10 = par3; + d11 = par5; + par1 = d6; + par3 = (double)this.stepHeight; + par5 = d8; + AxisAlignedBB axisalignedbb1 = this.boundingBox.copy(); + this.boundingBox.setBB(axisalignedbb); + list = this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox.addCoord(d6, par3, d8)); + + for (k = 0; k < list.size(); ++k) + { + par3 = ((AxisAlignedBB)list.get(k)).calculateYOffset(this.boundingBox, par3); + } + + this.boundingBox.offset(0.0D, par3, 0.0D); + + if (!this.field_70135_K && d7 != par3) + { + par5 = 0.0D; + par3 = 0.0D; + par1 = 0.0D; + } + + for (k = 0; k < list.size(); ++k) + { + par1 = ((AxisAlignedBB)list.get(k)).calculateXOffset(this.boundingBox, par1); + } + + this.boundingBox.offset(par1, 0.0D, 0.0D); + + if (!this.field_70135_K && d6 != par1) + { + par5 = 0.0D; + par3 = 0.0D; + par1 = 0.0D; + } + + for (k = 0; k < list.size(); ++k) + { + par5 = ((AxisAlignedBB)list.get(k)).calculateZOffset(this.boundingBox, par5); + } + + this.boundingBox.offset(0.0D, 0.0D, par5); + + if (!this.field_70135_K && d8 != par5) + { + par5 = 0.0D; + par3 = 0.0D; + par1 = 0.0D; + } + + if (!this.field_70135_K && d7 != par3) + { + par5 = 0.0D; + par3 = 0.0D; + par1 = 0.0D; + } + else + { + par3 = (double)(-this.stepHeight); + + for (k = 0; k < list.size(); ++k) + { + par3 = ((AxisAlignedBB)list.get(k)).calculateYOffset(this.boundingBox, par3); + } + + this.boundingBox.offset(0.0D, par3, 0.0D); + } + + if (d12 * d12 + d11 * d11 >= par1 * par1 + par5 * par5) + { + par1 = d12; + par3 = d10; + par5 = d11; + this.boundingBox.setBB(axisalignedbb1); + } + } + + this.worldObj.theProfiler.endSection(); + this.worldObj.theProfiler.startSection("rest"); + this.posX = (this.boundingBox.minX + this.boundingBox.maxX) / 2.0D; + this.posY = this.boundingBox.minY + (double)this.yOffset - (double)this.ySize; + this.posZ = (this.boundingBox.minZ + this.boundingBox.maxZ) / 2.0D; + this.isCollidedHorizontally = d6 != par1 || d8 != par5; + this.isCollidedVertically = d7 != par3; + this.onGround = d7 != par3 && d7 < 0.0D; + this.isCollided = this.isCollidedHorizontally || this.isCollidedVertically; + this.updateFallState(par3, this.onGround); + + if (d6 != par1) + { + this.motionX = 0.0D; + } + + if (d7 != par3) + { + this.motionY = 0.0D; + } + + if (d8 != par5) + { + this.motionZ = 0.0D; + } + + d12 = this.posX - d3; + d10 = this.posY - d4; + d11 = this.posZ - d5; + + if (this.canTriggerWalking() && !flag && this.ridingEntity == null) + { + int j1 = MathHelper.floor_double(this.posX); + k = MathHelper.floor_double(this.posY - 0.20000000298023224D - (double)this.yOffset); + int l = MathHelper.floor_double(this.posZ); + Block block = this.worldObj.getBlock(j1, k, l); + int i1 = this.worldObj.getBlock(j1, k - 1, l).getRenderType(); + + if (i1 == 11 || i1 == 32 || i1 == 21) + { + block = this.worldObj.getBlock(j1, k - 1, l); + } + + if (block != Blocks.ladder) + { + d10 = 0.0D; + } + + this.distanceWalkedModified = (float)((double)this.distanceWalkedModified + (double)MathHelper.sqrt_double(d12 * d12 + d11 * d11) * 0.6D); + this.distanceWalkedOnStepModified = (float)((double)this.distanceWalkedOnStepModified + (double)MathHelper.sqrt_double(d12 * d12 + d10 * d10 + d11 * d11) * 0.6D); + + if (this.distanceWalkedOnStepModified > (float)this.nextStepDistance && block.getMaterial() != Material.air) + { + this.nextStepDistance = (int)this.distanceWalkedOnStepModified + 1; + + if (this.isInWater()) + { + float f = MathHelper.sqrt_double(this.motionX * this.motionX * 0.20000000298023224D + this.motionY * this.motionY + this.motionZ * this.motionZ * 0.20000000298023224D) * 0.35F; + + if (f > 1.0F) + { + f = 1.0F; + } + + this.playSound(this.getSwimSound(), f, 1.0F + (this.rand.nextFloat() - this.rand.nextFloat()) * 0.4F); + } + + this.func_145780_a(j1, k, l, block); + block.onEntityWalking(this.worldObj, j1, k, l, this); + } + } + + try + { + this.func_145775_I(); + } + catch (Throwable throwable) + { + CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Checking entity block collision"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("Entity being checked for collision"); + this.addEntityCrashInfo(crashreportcategory); + throw new ReportedException(crashreport); + } + + boolean flag2 = this.isWet(); + + if (this.worldObj.func_147470_e(this.boundingBox.contract(0.001D, 0.001D, 0.001D))) + { + this.dealFireDamage(1); + + if (!flag2) + { + ++this.fire; + + if (this.fire == 0) + { + this.setFire(8); + } + } + } + else if (this.fire <= 0) + { + this.fire = -this.fireResistance; + } + + if (flag2 && this.fire > 0) + { + this.playSound("random.fizz", 0.7F, 1.6F + (this.rand.nextFloat() - this.rand.nextFloat()) * 0.4F); + this.fire = -this.fireResistance; + } + + this.worldObj.theProfiler.endSection(); + } + } + + protected String getSwimSound() + { + return "game.neutral.swim"; + } + + protected void func_145775_I() + { + int i = MathHelper.floor_double(this.boundingBox.minX + 0.001D); + int j = MathHelper.floor_double(this.boundingBox.minY + 0.001D); + int k = MathHelper.floor_double(this.boundingBox.minZ + 0.001D); + int l = MathHelper.floor_double(this.boundingBox.maxX - 0.001D); + int i1 = MathHelper.floor_double(this.boundingBox.maxY - 0.001D); + int j1 = MathHelper.floor_double(this.boundingBox.maxZ - 0.001D); + + if (this.worldObj.checkChunksExist(i, j, k, l, i1, j1)) + { + for (int k1 = i; k1 <= l; ++k1) + { + for (int l1 = j; l1 <= i1; ++l1) + { + for (int i2 = k; i2 <= j1; ++i2) + { + Block block = this.worldObj.getBlock(k1, l1, i2); + + try + { + block.onEntityCollidedWithBlock(this.worldObj, k1, l1, i2, this); + } + catch (Throwable throwable) + { + CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Colliding entity with block"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("Block being collided with"); + CrashReportCategory.func_147153_a(crashreportcategory, k1, l1, i2, block, this.worldObj.getBlockMetadata(k1, l1, i2)); + throw new ReportedException(crashreport); + } + } + } + } + } + } + + protected void func_145780_a(int p_145780_1_, int p_145780_2_, int p_145780_3_, Block p_145780_4_) + { + Block.SoundType soundtype = p_145780_4_.stepSound; + + if (this.worldObj.getBlock(p_145780_1_, p_145780_2_ + 1, p_145780_3_) == Blocks.snow_layer) + { + soundtype = Blocks.snow_layer.stepSound; + this.playSound(soundtype.getStepResourcePath(), soundtype.getVolume() * 0.15F, soundtype.getPitch()); + } + else if (!p_145780_4_.getMaterial().isLiquid()) + { + this.playSound(soundtype.getStepResourcePath(), soundtype.getVolume() * 0.15F, soundtype.getPitch()); + } + } + + public void playSound(String par1Str, float par2, float par3) + { + this.worldObj.playSoundAtEntity(this, par1Str, par2, par3); + } + + protected boolean canTriggerWalking() + { + return true; + } + + protected void updateFallState(double par1, boolean par3) + { + if (par3) + { + if (this.fallDistance > 0.0F) + { + this.fall(this.fallDistance); + this.fallDistance = 0.0F; + } + } + else if (par1 < 0.0D) + { + this.fallDistance = (float)((double)this.fallDistance - par1); + } + } + + public AxisAlignedBB getBoundingBox() + { + return null; + } + + protected void dealFireDamage(int par1) + { + if (!this.isImmuneToFire) + { + this.attackEntityFrom(DamageSource.inFire, (float)par1); + } + } + + public final boolean isImmuneToFire() + { + return this.isImmuneToFire; + } + + protected void fall(float par1) + { + if (this.riddenByEntity != null) + { + this.riddenByEntity.fall(par1); + } + } + + public boolean isWet() + { + return this.inWater || this.worldObj.canLightningStrikeAt(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)) || this.worldObj.canLightningStrikeAt(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY + (double)this.height), MathHelper.floor_double(this.posZ)); + } + + public boolean isInWater() + { + return this.inWater; + } + + public boolean handleWaterMovement() + { + if (this.worldObj.handleMaterialAcceleration(this.boundingBox.expand(0.0D, -0.4000000059604645D, 0.0D).contract(0.001D, 0.001D, 0.001D), Material.water, this)) + { + if (!this.inWater && !this.firstUpdate) + { + float f = MathHelper.sqrt_double(this.motionX * this.motionX * 0.20000000298023224D + this.motionY * this.motionY + this.motionZ * this.motionZ * 0.20000000298023224D) * 0.2F; + + if (f > 1.0F) + { + f = 1.0F; + } + + this.playSound(this.getSplashSound(), f, 1.0F + (this.rand.nextFloat() - this.rand.nextFloat()) * 0.4F); + float f1 = (float)MathHelper.floor_double(this.boundingBox.minY); + int i; + float f2; + float f3; + + for (i = 0; (float)i < 1.0F + this.width * 20.0F; ++i) + { + f2 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width; + f3 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width; + this.worldObj.spawnParticle("bubble", this.posX + (double)f2, (double)(f1 + 1.0F), this.posZ + (double)f3, this.motionX, this.motionY - (double)(this.rand.nextFloat() * 0.2F), this.motionZ); + } + + for (i = 0; (float)i < 1.0F + this.width * 20.0F; ++i) + { + f2 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width; + f3 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width; + this.worldObj.spawnParticle("splash", this.posX + (double)f2, (double)(f1 + 1.0F), this.posZ + (double)f3, this.motionX, this.motionY, this.motionZ); + } + } + + this.fallDistance = 0.0F; + this.inWater = true; + this.fire = 0; + } + else + { + this.inWater = false; + } + + return this.inWater; + } + + protected String getSplashSound() + { + return "game.neutral.swim.splash"; + } + + public boolean isInsideOfMaterial(Material par1Material) + { + double d0 = this.posY + (double)this.getEyeHeight(); + int i = MathHelper.floor_double(this.posX); + int j = MathHelper.floor_float((float)MathHelper.floor_double(d0)); + int k = MathHelper.floor_double(this.posZ); + Block block = this.worldObj.getBlock(i, j, k); + + if (block.getMaterial() == par1Material) + { + double filled = 1.0f; //If it's not a liquid assume it's a solid block + if (block instanceof IFluidBlock) + { + filled = ((IFluidBlock)block).getFilledPercentage(worldObj, i, j, k); + } + + if (filled < 0) + { + filled *= -1; + //filled -= 0.11111111F; //Why this is needed.. not sure... + return d0 > (double)(j + (1 - filled)); + } + else + { + return d0 < (double)(j + filled); + } + } + else + { + return false; + } + } + + public float getEyeHeight() + { + return 0.0F; + } + + public boolean handleLavaMovement() + { + return this.worldObj.isMaterialInBB(this.boundingBox.expand(-0.10000000149011612D, -0.4000000059604645D, -0.10000000149011612D), Material.lava); + } + + public void moveFlying(float par1, float par2, float par3) + { + float f3 = par1 * par1 + par2 * par2; + + if (f3 >= 1.0E-4F) + { + f3 = MathHelper.sqrt_float(f3); + + if (f3 < 1.0F) + { + f3 = 1.0F; + } + + f3 = par3 / f3; + par1 *= f3; + par2 *= f3; + float f4 = MathHelper.sin(this.rotationYaw * (float)Math.PI / 180.0F); + float f5 = MathHelper.cos(this.rotationYaw * (float)Math.PI / 180.0F); + this.motionX += (double)(par1 * f5 - par2 * f4); + this.motionZ += (double)(par2 * f5 + par1 * f4); + } + } + + @SideOnly(Side.CLIENT) + public int getBrightnessForRender(float par1) + { + int i = MathHelper.floor_double(this.posX); + int j = MathHelper.floor_double(this.posZ); + + if (this.worldObj.blockExists(i, 0, j)) + { + double d0 = (this.boundingBox.maxY - this.boundingBox.minY) * 0.66D; + int k = MathHelper.floor_double(this.posY - (double)this.yOffset + d0); + return this.worldObj.getLightBrightnessForSkyBlocks(i, k, j, 0); + } + else + { + return 0; + } + } + + public float getBrightness(float par1) + { + int i = MathHelper.floor_double(this.posX); + int j = MathHelper.floor_double(this.posZ); + + if (this.worldObj.blockExists(i, 0, j)) + { + double d0 = (this.boundingBox.maxY - this.boundingBox.minY) * 0.66D; + int k = MathHelper.floor_double(this.posY - (double)this.yOffset + d0); + return this.worldObj.getLightBrightness(i, k, j); + } + else + { + return 0.0F; + } + } + + public void setWorld(World par1World) + { + this.worldObj = par1World; + } + + public void setPositionAndRotation(double par1, double par3, double par5, float par7, float par8) + { + this.prevPosX = this.posX = par1; + this.prevPosY = this.posY = par3; + this.prevPosZ = this.posZ = par5; + this.prevRotationYaw = this.rotationYaw = par7; + this.prevRotationPitch = this.rotationPitch = par8; + this.ySize = 0.0F; + double d3 = (double)(this.prevRotationYaw - par7); + + if (d3 < -180.0D) + { + this.prevRotationYaw += 360.0F; + } + + if (d3 >= 180.0D) + { + this.prevRotationYaw -= 360.0F; + } + + this.setPosition(this.posX, this.posY, this.posZ); + this.setRotation(par7, par8); + } + + public void setLocationAndAngles(double par1, double par3, double par5, float par7, float par8) + { + this.lastTickPosX = this.prevPosX = this.posX = par1; + this.lastTickPosY = this.prevPosY = this.posY = par3 + (double)this.yOffset; + this.lastTickPosZ = this.prevPosZ = this.posZ = par5; + this.rotationYaw = par7; + this.rotationPitch = par8; + this.setPosition(this.posX, this.posY, this.posZ); + } + + public float getDistanceToEntity(Entity par1Entity) + { + float f = (float)(this.posX - par1Entity.posX); + float f1 = (float)(this.posY - par1Entity.posY); + float f2 = (float)(this.posZ - par1Entity.posZ); + return MathHelper.sqrt_float(f * f + f1 * f1 + f2 * f2); + } + + public double getDistanceSq(double par1, double par3, double par5) + { + double d3 = this.posX - par1; + double d4 = this.posY - par3; + double d5 = this.posZ - par5; + return d3 * d3 + d4 * d4 + d5 * d5; + } + + public double getDistance(double par1, double par3, double par5) + { + double d3 = this.posX - par1; + double d4 = this.posY - par3; + double d5 = this.posZ - par5; + return (double)MathHelper.sqrt_double(d3 * d3 + d4 * d4 + d5 * d5); + } + + public double getDistanceSqToEntity(Entity par1Entity) + { + double d0 = this.posX - par1Entity.posX; + double d1 = this.posY - par1Entity.posY; + double d2 = this.posZ - par1Entity.posZ; + return d0 * d0 + d1 * d1 + d2 * d2; + } + + public void onCollideWithPlayer(EntityPlayer par1EntityPlayer) {} + + public void applyEntityCollision(Entity par1Entity) + { + if (par1Entity.riddenByEntity != this && par1Entity.ridingEntity != this) + { + double d0 = par1Entity.posX - this.posX; + double d1 = par1Entity.posZ - this.posZ; + double d2 = MathHelper.abs_max(d0, d1); + + if (d2 >= 0.009999999776482582D) + { + d2 = (double)MathHelper.sqrt_double(d2); + d0 /= d2; + d1 /= d2; + double d3 = 1.0D / d2; + + if (d3 > 1.0D) + { + d3 = 1.0D; + } + + d0 *= d3; + d1 *= d3; + d0 *= 0.05000000074505806D; + d1 *= 0.05000000074505806D; + d0 *= (double)(1.0F - this.entityCollisionReduction); + d1 *= (double)(1.0F - this.entityCollisionReduction); + this.addVelocity(-d0, 0.0D, -d1); + par1Entity.addVelocity(d0, 0.0D, d1); + } + } + } + + public void addVelocity(double par1, double par3, double par5) + { + this.motionX += par1; + this.motionY += par3; + this.motionZ += par5; + this.isAirBorne = true; + } + + protected void setBeenAttacked() + { + this.velocityChanged = true; + } + + public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) + { + if (this.isEntityInvulnerable()) + { + return false; + } + else + { + this.setBeenAttacked(); + return false; + } + } + + public boolean canBeCollidedWith() + { + return false; + } + + public boolean canBePushed() + { + return false; + } + + public void addToPlayerScore(Entity par1Entity, int par2) {} + + @SideOnly(Side.CLIENT) + public boolean isInRangeToRender3d(double p_145770_1_, double p_145770_3_, double p_145770_5_) + { + double d3 = this.posX - p_145770_1_; + double d4 = this.posY - p_145770_3_; + double d5 = this.posZ - p_145770_5_; + double d6 = d3 * d3 + d4 * d4 + d5 * d5; + return this.isInRangeToRenderDist(d6); + } + + @SideOnly(Side.CLIENT) + public boolean isInRangeToRenderDist(double par1) + { + double d1 = this.boundingBox.getAverageEdgeLength(); + d1 *= 64.0D * this.renderDistanceWeight; + return par1 < d1 * d1; + } + + public boolean writeMountToNBT(NBTTagCompound par1NBTTagCompound) + { + String s = this.getEntityString(); + + if (!this.isDead && s != null) + { + par1NBTTagCompound.setString("id", s); + this.writeToNBT(par1NBTTagCompound); + return true; + } + else + { + return false; + } + } + + public boolean writeToNBTOptional(NBTTagCompound par1NBTTagCompound) + { + String s = this.getEntityString(); + + if (!this.isDead && s != null && this.riddenByEntity == null) + { + par1NBTTagCompound.setString("id", s); + this.writeToNBT(par1NBTTagCompound); + return true; + } + else + { + return false; + } + } + + public void writeToNBT(NBTTagCompound par1NBTTagCompound) + { + try + { + par1NBTTagCompound.setTag("Pos", this.newDoubleNBTList(new double[] {this.posX, this.posY + (double)this.ySize, this.posZ})); + par1NBTTagCompound.setTag("Motion", this.newDoubleNBTList(new double[] {this.motionX, this.motionY, this.motionZ})); + par1NBTTagCompound.setTag("Rotation", this.newFloatNBTList(new float[] {this.rotationYaw, this.rotationPitch})); + par1NBTTagCompound.setFloat("FallDistance", this.fallDistance); + par1NBTTagCompound.setShort("Fire", (short)this.fire); + par1NBTTagCompound.setShort("Air", (short)this.getAir()); + par1NBTTagCompound.setBoolean("OnGround", this.onGround); + par1NBTTagCompound.setInteger("Dimension", this.dimension); + par1NBTTagCompound.setBoolean("Invulnerable", this.invulnerable); + par1NBTTagCompound.setInteger("PortalCooldown", this.timeUntilPortal); + par1NBTTagCompound.setLong("UUIDMost", this.getUniqueID().getMostSignificantBits()); + par1NBTTagCompound.setLong("UUIDLeast", this.getUniqueID().getLeastSignificantBits()); + if (customEntityData != null) + { + par1NBTTagCompound.setTag("ForgeData", customEntityData); + } + + for (String identifier : this.extendedProperties.keySet()) + { + try + { + IExtendedEntityProperties props = this.extendedProperties.get(identifier); + props.saveNBTData(par1NBTTagCompound); + } + catch (Throwable t) + { + FMLLog.severe("Failed to save extended properties for %s. This is a mod issue.", identifier); + t.printStackTrace(); + } + } + + this.writeEntityToNBT(par1NBTTagCompound); + + if (this.ridingEntity != null) + { + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + + if (this.ridingEntity.writeMountToNBT(nbttagcompound1)) + { + par1NBTTagCompound.setTag("Riding", nbttagcompound1); + } + } + } + catch (Throwable throwable) + { + CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Saving entity NBT"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("Entity being saved"); + this.addEntityCrashInfo(crashreportcategory); + throw new ReportedException(crashreport); + } + } + + public void readFromNBT(NBTTagCompound par1NBTTagCompound) + { + try + { + NBTTagList nbttaglist = par1NBTTagCompound.getTagList("Pos", 6); + NBTTagList nbttaglist1 = par1NBTTagCompound.getTagList("Motion", 6); + NBTTagList nbttaglist2 = par1NBTTagCompound.getTagList("Rotation", 5); + this.motionX = nbttaglist1.func_150309_d(0); + this.motionY = nbttaglist1.func_150309_d(1); + this.motionZ = nbttaglist1.func_150309_d(2); + + if (Math.abs(this.motionX) > 10.0D) + { + this.motionX = 0.0D; + } + + if (Math.abs(this.motionY) > 10.0D) + { + this.motionY = 0.0D; + } + + if (Math.abs(this.motionZ) > 10.0D) + { + this.motionZ = 0.0D; + } + + this.prevPosX = this.lastTickPosX = this.posX = nbttaglist.func_150309_d(0); + this.prevPosY = this.lastTickPosY = this.posY = nbttaglist.func_150309_d(1); + this.prevPosZ = this.lastTickPosZ = this.posZ = nbttaglist.func_150309_d(2); + this.prevRotationYaw = this.rotationYaw = nbttaglist2.func_150308_e(0); + this.prevRotationPitch = this.rotationPitch = nbttaglist2.func_150308_e(1); + this.fallDistance = par1NBTTagCompound.getFloat("FallDistance"); + this.fire = par1NBTTagCompound.getShort("Fire"); + this.setAir(par1NBTTagCompound.getShort("Air")); + this.onGround = par1NBTTagCompound.getBoolean("OnGround"); + this.dimension = par1NBTTagCompound.getInteger("Dimension"); + this.invulnerable = par1NBTTagCompound.getBoolean("Invulnerable"); + this.timeUntilPortal = par1NBTTagCompound.getInteger("PortalCooldown"); + + if (par1NBTTagCompound.hasKey("UUIDMost", 4) && par1NBTTagCompound.hasKey("UUIDLeast", 4)) + { + this.entityUniqueID = new UUID(par1NBTTagCompound.getLong("UUIDMost"), par1NBTTagCompound.getLong("UUIDLeast")); + } + + this.setPosition(this.posX, this.posY, this.posZ); + this.setRotation(this.rotationYaw, this.rotationPitch); + if (par1NBTTagCompound.hasKey("ForgeData")) + { + customEntityData = par1NBTTagCompound.getCompoundTag("ForgeData"); + } + + for (String identifier : this.extendedProperties.keySet()) + { + try + { + IExtendedEntityProperties props = this.extendedProperties.get(identifier); + props.loadNBTData(par1NBTTagCompound); + } + catch (Throwable t) + { + FMLLog.severe("Failed to load extended properties for %s. This is a mod issue.", identifier); + t.printStackTrace(); + } + } + + //Rawr, legacy code, Vanilla added a UUID, keep this so older maps will convert properly + if (par1NBTTagCompound.hasKey("PersistentIDMSB") && par1NBTTagCompound.hasKey("PersistentIDLSB")) + { + this.entityUniqueID = new UUID(par1NBTTagCompound.getLong("PersistentIDMSB"), par1NBTTagCompound.getLong("PersistentIDLSB")); + } + this.readEntityFromNBT(par1NBTTagCompound); + + if (this.shouldSetPosAfterLoading()) + { + this.setPosition(this.posX, this.posY, this.posZ); + } + } + catch (Throwable throwable) + { + CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Loading entity NBT"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("Entity being loaded"); + this.addEntityCrashInfo(crashreportcategory); + throw new ReportedException(crashreport); + } + } + + protected boolean shouldSetPosAfterLoading() + { + return true; + } + + protected final String getEntityString() + { + return EntityList.getEntityString(this); + } + + protected abstract void readEntityFromNBT(NBTTagCompound var1); + + protected abstract void writeEntityToNBT(NBTTagCompound var1); + + public void onChunkLoad() {} + + protected NBTTagList newDoubleNBTList(double ... par1ArrayOfDouble) + { + NBTTagList nbttaglist = new NBTTagList(); + double[] adouble = par1ArrayOfDouble; + int i = par1ArrayOfDouble.length; + + for (int j = 0; j < i; ++j) + { + double d1 = adouble[j]; + nbttaglist.appendTag(new NBTTagDouble(d1)); + } + + return nbttaglist; + } + + protected NBTTagList newFloatNBTList(float ... par1ArrayOfFloat) + { + NBTTagList nbttaglist = new NBTTagList(); + float[] afloat = par1ArrayOfFloat; + int i = par1ArrayOfFloat.length; + + for (int j = 0; j < i; ++j) + { + float f1 = afloat[j]; + nbttaglist.appendTag(new NBTTagFloat(f1)); + } + + return nbttaglist; + } + + public EntityItem dropItem(Item p_145779_1_, int p_145779_2_) + { + return this.func_145778_a(p_145779_1_, p_145779_2_, 0.0F); + } + + public EntityItem func_145778_a(Item p_145778_1_, int p_145778_2_, float p_145778_3_) + { + return this.entityDropItem(new ItemStack(p_145778_1_, p_145778_2_, 0), p_145778_3_); + } + + public EntityItem entityDropItem(ItemStack par1ItemStack, float par2) + { + if (par1ItemStack.stackSize != 0 && par1ItemStack.getItem() != null) + { + EntityItem entityitem = new EntityItem(this.worldObj, this.posX, this.posY + (double)par2, this.posZ, par1ItemStack); + entityitem.delayBeforeCanPickup = 10; + if (captureDrops) + { + capturedDrops.add(entityitem); + } + else + { + this.worldObj.spawnEntityInWorld(entityitem); + } + return entityitem; + } + else + { + return null; + } + } + + @SideOnly(Side.CLIENT) + public float getShadowSize() + { + return this.height / 2.0F; + } + + public boolean isEntityAlive() + { + return !this.isDead; + } + + public boolean isEntityInsideOpaqueBlock() + { + for (int i = 0; i < 8; ++i) + { + float f = ((float)((i >> 0) % 2) - 0.5F) * this.width * 0.8F; + float f1 = ((float)((i >> 1) % 2) - 0.5F) * 0.1F; + float f2 = ((float)((i >> 2) % 2) - 0.5F) * this.width * 0.8F; + int j = MathHelper.floor_double(this.posX + (double)f); + int k = MathHelper.floor_double(this.posY + (double)this.getEyeHeight() + (double)f1); + int l = MathHelper.floor_double(this.posZ + (double)f2); + + if (this.worldObj.getBlock(j, k, l).isNormalCube()) + { + return true; + } + } + + return false; + } + + public boolean interactFirst(EntityPlayer par1EntityPlayer) + { + return false; + } + + public AxisAlignedBB getCollisionBox(Entity par1Entity) + { + return null; + } + + public void updateRidden() + { + if (this.ridingEntity.isDead) + { + this.ridingEntity = null; + } + else + { + this.motionX = 0.0D; + this.motionY = 0.0D; + this.motionZ = 0.0D; + this.onUpdate(); + + if (this.ridingEntity != null) + { + this.ridingEntity.updateRiderPosition(); + this.entityRiderYawDelta += (double)(this.ridingEntity.rotationYaw - this.ridingEntity.prevRotationYaw); + + for (this.entityRiderPitchDelta += (double)(this.ridingEntity.rotationPitch - this.ridingEntity.prevRotationPitch); this.entityRiderYawDelta >= 180.0D; this.entityRiderYawDelta -= 360.0D) + { + ; + } + + while (this.entityRiderYawDelta < -180.0D) + { + this.entityRiderYawDelta += 360.0D; + } + + while (this.entityRiderPitchDelta >= 180.0D) + { + this.entityRiderPitchDelta -= 360.0D; + } + + while (this.entityRiderPitchDelta < -180.0D) + { + this.entityRiderPitchDelta += 360.0D; + } + + double d0 = this.entityRiderYawDelta * 0.5D; + double d1 = this.entityRiderPitchDelta * 0.5D; + float f = 10.0F; + + if (d0 > (double)f) + { + d0 = (double)f; + } + + if (d0 < (double)(-f)) + { + d0 = (double)(-f); + } + + if (d1 > (double)f) + { + d1 = (double)f; + } + + if (d1 < (double)(-f)) + { + d1 = (double)(-f); + } + + this.entityRiderYawDelta -= d0; + this.entityRiderPitchDelta -= d1; + } + } + } + + public void updateRiderPosition() + { + if (this.riddenByEntity != null) + { + this.riddenByEntity.setPosition(this.posX, this.posY + this.getMountedYOffset() + this.riddenByEntity.getYOffset(), this.posZ); + } + } + + public double getYOffset() + { + return (double)this.yOffset; + } + + public double getMountedYOffset() + { + return (double)this.height * 0.75D; + } + + public void mountEntity(Entity par1Entity) + { + this.entityRiderPitchDelta = 0.0D; + this.entityRiderYawDelta = 0.0D; + + if (par1Entity == null) + { + if (this.ridingEntity != null) + { + this.setLocationAndAngles(this.ridingEntity.posX, this.ridingEntity.boundingBox.minY + (double)this.ridingEntity.height, this.ridingEntity.posZ, this.rotationYaw, this.rotationPitch); + this.ridingEntity.riddenByEntity = null; + } + + this.ridingEntity = null; + } + else + { + if (this.ridingEntity != null) + { + this.ridingEntity.riddenByEntity = null; + } + + this.ridingEntity = par1Entity; + par1Entity.riddenByEntity = this; + } + } + + @SideOnly(Side.CLIENT) + public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9) + { + this.setPosition(par1, par3, par5); + this.setRotation(par7, par8); + List list = this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox.contract(0.03125D, 0.0D, 0.03125D)); + + if (!list.isEmpty()) + { + double d3 = 0.0D; + + for (int j = 0; j < list.size(); ++j) + { + AxisAlignedBB axisalignedbb = (AxisAlignedBB)list.get(j); + + if (axisalignedbb.maxY > d3) + { + d3 = axisalignedbb.maxY; + } + } + + par3 += d3 - this.boundingBox.minY; + this.setPosition(par1, par3, par5); + } + } + + public float getCollisionBorderSize() + { + return 0.1F; + } + + public Vec3 getLookVec() + { + return null; + } + + public void setInPortal() + { + if (this.timeUntilPortal > 0) + { + this.timeUntilPortal = this.getPortalCooldown(); + } + else + { + double d0 = this.prevPosX - this.posX; + double d1 = this.prevPosZ - this.posZ; + + if (!this.worldObj.isRemote && !this.inPortal) + { + this.teleportDirection = Direction.getMovementDirection(d0, d1); + } + + this.inPortal = true; + } + } + + public int getPortalCooldown() + { + return 300; + } + + @SideOnly(Side.CLIENT) + public void setVelocity(double par1, double par3, double par5) + { + this.motionX = par1; + this.motionY = par3; + this.motionZ = par5; + } + + @SideOnly(Side.CLIENT) + public void handleHealthUpdate(byte par1) {} + + @SideOnly(Side.CLIENT) + public void performHurtAnimation() {} + + public ItemStack[] getLastActiveItems() + { + return null; + } + + public void setCurrentItemOrArmor(int par1, ItemStack par2ItemStack) {} + + public boolean isBurning() + { + boolean flag = this.worldObj != null && this.worldObj.isRemote; + return !this.isImmuneToFire && (this.fire > 0 || flag && this.getFlag(0)); + } + + public boolean isRiding() + { + return this.ridingEntity != null && ridingEntity.shouldRiderSit(); + } + + public boolean isSneaking() + { + return this.getFlag(1); + } + + public void setSneaking(boolean par1) + { + this.setFlag(1, par1); + } + + public boolean isSprinting() + { + return this.getFlag(3); + } + + public void setSprinting(boolean par1) + { + this.setFlag(3, par1); + } + + public boolean isInvisible() + { + return this.getFlag(5); + } + + @SideOnly(Side.CLIENT) + public boolean isInvisibleToPlayer(EntityPlayer par1EntityPlayer) + { + return this.isInvisible(); + } + + public void setInvisible(boolean par1) + { + this.setFlag(5, par1); + } + + @SideOnly(Side.CLIENT) + public boolean isEating() + { + return this.getFlag(4); + } + + public void setEating(boolean par1) + { + this.setFlag(4, par1); + } + + protected boolean getFlag(int par1) + { + return (this.dataWatcher.getWatchableObjectByte(0) & 1 << par1) != 0; + } + + protected void setFlag(int par1, boolean par2) + { + byte b0 = this.dataWatcher.getWatchableObjectByte(0); + + if (par2) + { + this.dataWatcher.updateObject(0, Byte.valueOf((byte)(b0 | 1 << par1))); + } + else + { + this.dataWatcher.updateObject(0, Byte.valueOf((byte)(b0 & ~(1 << par1)))); + } + } + + public int getAir() + { + return this.dataWatcher.getWatchableObjectShort(1); + } + + public void setAir(int par1) + { + this.dataWatcher.updateObject(1, Short.valueOf((short)par1)); + } + + public void onStruckByLightning(EntityLightningBolt par1EntityLightningBolt) + { + this.dealFireDamage(5); + ++this.fire; + + if (this.fire == 0) + { + this.setFire(8); + } + } + + public void onKillEntity(EntityLivingBase par1EntityLivingBase) {} + + protected boolean func_145771_j(double p_145771_1_, double p_145771_3_, double p_145771_5_) + { + int i = MathHelper.floor_double(p_145771_1_); + int j = MathHelper.floor_double(p_145771_3_); + int k = MathHelper.floor_double(p_145771_5_); + double d3 = p_145771_1_ - (double)i; + double d4 = p_145771_3_ - (double)j; + double d5 = p_145771_5_ - (double)k; + List list = this.worldObj.func_147461_a(this.boundingBox); + + if (list.isEmpty() && !this.worldObj.func_147469_q(i, j, k)) + { + return false; + } + else + { + boolean flag = !this.worldObj.func_147469_q(i - 1, j, k); + boolean flag1 = !this.worldObj.func_147469_q(i + 1, j, k); + boolean flag2 = !this.worldObj.func_147469_q(i, j - 1, k); + boolean flag3 = !this.worldObj.func_147469_q(i, j + 1, k); + boolean flag4 = !this.worldObj.func_147469_q(i, j, k - 1); + boolean flag5 = !this.worldObj.func_147469_q(i, j, k + 1); + byte b0 = 3; + double d6 = 9999.0D; + + if (flag && d3 < d6) + { + d6 = d3; + b0 = 0; + } + + if (flag1 && 1.0D - d3 < d6) + { + d6 = 1.0D - d3; + b0 = 1; + } + + if (flag3 && 1.0D - d4 < d6) + { + d6 = 1.0D - d4; + b0 = 3; + } + + if (flag4 && d5 < d6) + { + d6 = d5; + b0 = 4; + } + + if (flag5 && 1.0D - d5 < d6) + { + d6 = 1.0D - d5; + b0 = 5; + } + + float f = this.rand.nextFloat() * 0.2F + 0.1F; + + if (b0 == 0) + { + this.motionX = (double)(-f); + } + + if (b0 == 1) + { + this.motionX = (double)f; + } + + if (b0 == 2) + { + this.motionY = (double)(-f); + } + + if (b0 == 3) + { + this.motionY = (double)f; + } + + if (b0 == 4) + { + this.motionZ = (double)(-f); + } + + if (b0 == 5) + { + this.motionZ = (double)f; + } + + return true; + } + } + + public void setInWeb() + { + this.isInWeb = true; + this.fallDistance = 0.0F; + } + + public String getCommandSenderName() + { + String s = EntityList.getEntityString(this); + + if (s == null) + { + s = "generic"; + } + + return StatCollector.translateToLocal("entity." + s + ".name"); + } + + public Entity[] getParts() + { + return null; + } + + public boolean isEntityEqual(Entity par1Entity) + { + return this == par1Entity; + } + + public float getRotationYawHead() + { + return 0.0F; + } + + @SideOnly(Side.CLIENT) + public void setRotationYawHead(float par1) {} + + public boolean canAttackWithItem() + { + return true; + } + + public boolean hitByEntity(Entity par1Entity) + { + return false; + } + + public String toString() + { + return String.format("%s[\'%s\'/%d, l=\'%s\', x=%.2f, y=%.2f, z=%.2f]", new Object[] {this.getClass().getSimpleName(), this.getCommandSenderName(), Integer.valueOf(this.entityId), this.worldObj == null ? "~NULL~" : this.worldObj.getWorldInfo().getWorldName(), Double.valueOf(this.posX), Double.valueOf(this.posY), Double.valueOf(this.posZ)}); + } + + public boolean isEntityInvulnerable() + { + return this.invulnerable; + } + + public void copyLocationAndAnglesFrom(Entity par1Entity) + { + this.setLocationAndAngles(par1Entity.posX, par1Entity.posY, par1Entity.posZ, par1Entity.rotationYaw, par1Entity.rotationPitch); + } + + public void copyDataFrom(Entity par1Entity, boolean par2) + { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + par1Entity.writeToNBT(nbttagcompound); + this.readFromNBT(nbttagcompound); + this.timeUntilPortal = par1Entity.timeUntilPortal; + this.teleportDirection = par1Entity.teleportDirection; + } + + public void travelToDimension(int par1) + { + if (!this.worldObj.isRemote && !this.isDead) + { + this.worldObj.theProfiler.startSection("changeDimension"); + MinecraftServer minecraftserver = MinecraftServer.getServer(); + int j = this.dimension; + WorldServer worldserver = minecraftserver.worldServerForDimension(j); + WorldServer worldserver1 = minecraftserver.worldServerForDimension(par1); + this.dimension = par1; + + if (j == 1 && par1 == 1) + { + worldserver1 = minecraftserver.worldServerForDimension(0); + this.dimension = 0; + } + + this.worldObj.removeEntity(this); + this.isDead = false; + this.worldObj.theProfiler.startSection("reposition"); + minecraftserver.getConfigurationManager().transferEntityToWorld(this, j, worldserver, worldserver1); + this.worldObj.theProfiler.endStartSection("reloading"); + Entity entity = EntityList.createEntityByName(EntityList.getEntityString(this), worldserver1); + + if (entity != null) + { + entity.copyDataFrom(this, true); + + if (j == 1 && par1 == 1) + { + ChunkCoordinates chunkcoordinates = worldserver1.getSpawnPoint(); + chunkcoordinates.posY = this.worldObj.getTopSolidOrLiquidBlock(chunkcoordinates.posX, chunkcoordinates.posZ); + entity.setLocationAndAngles((double)chunkcoordinates.posX, (double)chunkcoordinates.posY, (double)chunkcoordinates.posZ, entity.rotationYaw, entity.rotationPitch); + } + + worldserver1.spawnEntityInWorld(entity); + } + + this.isDead = true; + this.worldObj.theProfiler.endSection(); + worldserver.resetUpdateEntityTick(); + worldserver1.resetUpdateEntityTick(); + this.worldObj.theProfiler.endSection(); + } + } + + public float func_145772_a(Explosion p_145772_1_, World p_145772_2_, int p_145772_3_, int p_145772_4_, int p_145772_5_, Block p_145772_6_) + { + return p_145772_6_.getExplosionResistance(this, p_145772_2_, p_145772_3_, p_145772_3_, p_145772_4_, posX, posY + getEyeHeight(), posZ); + } + + public boolean func_145774_a(Explosion p_145774_1_, World p_145774_2_, int p_145774_3_, int p_145774_4_, int p_145774_5_, Block p_145774_6_, float p_145774_7_) + { + return true; + } + + public int getMaxSafePointTries() + { + return 3; + } + + public int getTeleportDirection() + { + return this.teleportDirection; + } + + public boolean doesEntityNotTriggerPressurePlate() + { + return false; + } + + public void addEntityCrashInfo(CrashReportCategory par1CrashReportCategory) + { + par1CrashReportCategory.addCrashSectionCallable("Entity Type", new Callable() + { + private static final String __OBFID = "CL_00001534"; + public String call() + { + return EntityList.getEntityString(Entity.this) + " (" + Entity.this.getClass().getCanonicalName() + ")"; + } + }); + par1CrashReportCategory.addCrashSection("Entity ID", Integer.valueOf(this.entityId)); + par1CrashReportCategory.addCrashSectionCallable("Entity Name", new Callable() + { + private static final String __OBFID = "CL_00001535"; + public String call() + { + return Entity.this.getCommandSenderName(); + } + }); + par1CrashReportCategory.addCrashSection("Entity\'s Exact location", String.format("%.2f, %.2f, %.2f", new Object[] {Double.valueOf(this.posX), Double.valueOf(this.posY), Double.valueOf(this.posZ)})); + par1CrashReportCategory.addCrashSection("Entity\'s Block location", CrashReportCategory.getLocationInfo(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ))); + par1CrashReportCategory.addCrashSection("Entity\'s Momentum", String.format("%.2f, %.2f, %.2f", new Object[] {Double.valueOf(this.motionX), Double.valueOf(this.motionY), Double.valueOf(this.motionZ)})); + } + + @SideOnly(Side.CLIENT) + public boolean canRenderOnFire() + { + return this.isBurning(); + } + + public UUID getUniqueID() + { + return this.entityUniqueID; + } + + public boolean isPushedByWater() + { + return true; + } + + public IChatComponent func_145748_c_() + { + return new ChatComponentText(this.getCommandSenderName()); + } + + public void func_145781_i(int p_145781_1_) {} + + /* ================================== Forge Start =====================================*/ + /** + * Returns a NBTTagCompound that can be used to store custom data for this entity. + * It will be written, and read from disc, so it persists over world saves. + * @return A NBTTagCompound + */ + public NBTTagCompound getEntityData() + { + if (customEntityData == null) + { + customEntityData = new NBTTagCompound(); + } + return customEntityData; + } + + /** + * Used in model rendering to determine if the entity riding this entity should be in the 'sitting' position. + * @return false to prevent an entity that is mounted to this entity from displaying the 'sitting' animation. + */ + public boolean shouldRiderSit() + { + return true; + } + + /** + * Called when a user uses the creative pick block button on this entity. + * + * @param target The full target the player is looking at + * @return A ItemStack to add to the player's inventory, Null if nothing should be added. + */ + public ItemStack getPickedResult(MovingObjectPosition target) + { + if (this instanceof EntityPainting) + { + return new ItemStack(Items.painting); + } + else if (this instanceof EntityLeashKnot) + { + return new ItemStack(Items.lead); + } + else if (this instanceof EntityItemFrame) + { + ItemStack held = ((EntityItemFrame)this).getDisplayedItem(); + if (held == null) + { + return new ItemStack(Items.item_frame); + } + else + { + return held.copy(); + } + } + else if (this instanceof EntityMinecart) + { + return ((EntityMinecart)this).getCartItem(); + } + else if (this instanceof EntityBoat) + { + return new ItemStack(Items.boat); + } + else + { + int id = EntityList.getEntityID(this); + if (id > 0 && EntityList.entityEggs.containsKey(id)) + { + return new ItemStack(Items.spawn_egg, 1, id); + } + } + return null; + } + + public UUID getPersistentID() + { + return entityUniqueID; + } + + /** + * Reset the entity ID to a new value. Not to be used from Mod code + */ + public final void resetEntityId() + { + this.entityId = nextEntityID++; + } + + public boolean shouldRenderInPass(int pass) + { + return pass == 0; + } + + /** + * Returns true if the entity is of the @link{EnumCreatureType} provided + * @param type The EnumCreatureType type this entity is evaluating + * @param forSpawnCount If this is being invoked to check spawn count caps. + * @return If the creature is of the type provided + */ + public boolean isCreatureType(EnumCreatureType type, boolean forSpawnCount) + { + return type.getCreatureClass().isAssignableFrom(this.getClass()); + } + + /** + * Register the instance of IExtendedProperties into the entity's collection. + * @param identifier The identifier which you can use to retrieve these properties for the entity. + * @param properties The instanceof IExtendedProperties to register + * @return The identifier that was used to register the extended properties. Empty String indicates an error. If your requested key already existed, this will return a modified one that is unique. + */ + public String registerExtendedProperties(String identifier, IExtendedEntityProperties properties) + { + if (identifier == null) + { + FMLLog.warning("Someone is attempting to register extended properties using a null identifier. This is not allowed. Aborting. This may have caused instability."); + return ""; + } + if (properties == null) + { + FMLLog.warning("Someone is attempting to register null extended properties. This is not allowed. Aborting. This may have caused instability."); + return ""; + } + + String baseIdentifier = identifier; + int identifierModCount = 1; + while (this.extendedProperties.containsKey(identifier)) + { + identifier = String.format("%s%d", baseIdentifier, identifierModCount++); + } + + if (baseIdentifier != identifier) + { + FMLLog.info("An attempt was made to register exended properties using an existing key. The duplicate identifier (%s) has been remapped to %s.", baseIdentifier, identifier); + } + + this.extendedProperties.put(identifier, properties); + return identifier; + } + + /** + * Gets the extended properties identified by the passed in key + * @param identifier The key that identifies the extended properties. + * @return The instance of IExtendedProperties that was found, or null. + */ + public IExtendedEntityProperties getExtendedProperties(String identifier) + { + return this.extendedProperties.get(identifier); + } + + /** + * If a rider of this entity can interact with this entity. Should return true on the + * ridden entity if so. + * + * @return if the entity can be interacted with from a rider + */ + public boolean canRiderInteract() + { + return false; + } + + /** + * If the rider should be dismounted from the entity when the entity goes under water + * + * @param rider The entity that is riding + * @return if the entity should be dismounted when under water + */ + public boolean shouldDismountInWater(Entity rider) + { + return this instanceof EntityLivingBase; + } + /* ================================== Forge End =====================================*/ + + public static enum EnumEntitySize + { + SIZE_1, + SIZE_2, + SIZE_3, + SIZE_4, + SIZE_5, + SIZE_6; + + private static final String __OBFID = "CL_00001537"; + + public int multiplyBy32AndRound(double par1) + { + double d1 = par1 - ((double)MathHelper.floor_double(par1) + 0.5D); + + switch (Entity.SwitchEnumEntitySize.field_96565_a[this.ordinal()]) + { + case 1: + if (d1 < 0.0D) + { + if (d1 < -0.3125D) + { + return MathHelper.ceiling_double_int(par1 * 32.0D); + } + } + else if (d1 < 0.3125D) + { + return MathHelper.ceiling_double_int(par1 * 32.0D); + } + + return MathHelper.floor_double(par1 * 32.0D); + case 2: + if (d1 < 0.0D) + { + if (d1 < -0.3125D) + { + return MathHelper.floor_double(par1 * 32.0D); + } + } + else if (d1 < 0.3125D) + { + return MathHelper.floor_double(par1 * 32.0D); + } + + return MathHelper.ceiling_double_int(par1 * 32.0D); + case 3: + if (d1 > 0.0D) + { + return MathHelper.floor_double(par1 * 32.0D); + } + + return MathHelper.ceiling_double_int(par1 * 32.0D); + case 4: + if (d1 < 0.0D) + { + if (d1 < -0.1875D) + { + return MathHelper.ceiling_double_int(par1 * 32.0D); + } + } + else if (d1 < 0.1875D) + { + return MathHelper.ceiling_double_int(par1 * 32.0D); + } + + return MathHelper.floor_double(par1 * 32.0D); + case 5: + if (d1 < 0.0D) + { + if (d1 < -0.1875D) + { + return MathHelper.floor_double(par1 * 32.0D); + } + } + else if (d1 < 0.1875D) + { + return MathHelper.floor_double(par1 * 32.0D); + } + + return MathHelper.ceiling_double_int(par1 * 32.0D); + case 6: + default: + if (d1 > 0.0D) + { + return MathHelper.ceiling_double_int(par1 * 32.0D); + } + else + { + return MathHelper.floor_double(par1 * 32.0D); + } + } + } + } + + static final class SwitchEnumEntitySize + { + static final int[] field_96565_a = new int[Entity.EnumEntitySize.values().length]; + private static final String __OBFID = "CL_00001536"; + + static + { + try + { + field_96565_a[Entity.EnumEntitySize.SIZE_1.ordinal()] = 1; + } + catch (NoSuchFieldError var6) + { + ; + } + + try + { + field_96565_a[Entity.EnumEntitySize.SIZE_2.ordinal()] = 2; + } + catch (NoSuchFieldError var5) + { + ; + } + + try + { + field_96565_a[Entity.EnumEntitySize.SIZE_3.ordinal()] = 3; + } + catch (NoSuchFieldError var4) + { + ; + } + + try + { + field_96565_a[Entity.EnumEntitySize.SIZE_4.ordinal()] = 4; + } + catch (NoSuchFieldError var3) + { + ; + } + + try + { + field_96565_a[Entity.EnumEntitySize.SIZE_5.ordinal()] = 5; + } + catch (NoSuchFieldError var2) + { + ; + } + + try + { + field_96565_a[Entity.EnumEntitySize.SIZE_6.ordinal()] = 6; + } + catch (NoSuchFieldError var1) + { + ; + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/EntityAgeable.java b/src/main/java/net/minecraft/entity/EntityAgeable.java new file mode 100644 index 0000000..fbca017 --- /dev/null +++ b/src/main/java/net/minecraft/entity/EntityAgeable.java @@ -0,0 +1,161 @@ +package net.minecraft.entity; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +public abstract class EntityAgeable extends EntityCreature +{ + private float field_98056_d = -1.0F; + private float field_98057_e; + private static final String __OBFID = "CL_00001530"; + + public EntityAgeable(World par1World) + { + super(par1World); + } + + public abstract EntityAgeable createChild(EntityAgeable var1); + + public boolean interact(EntityPlayer par1EntityPlayer) + { + ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem(); + + if (itemstack != null && itemstack.getItem() == Items.spawn_egg) + { + if (!this.worldObj.isRemote) + { + Class oclass = EntityList.getClassFromID(itemstack.getItemDamage()); + + if (oclass != null && oclass.isAssignableFrom(this.getClass())) + { + EntityAgeable entityageable = this.createChild(this); + + if (entityageable != null) + { + entityageable.setGrowingAge(-24000); + entityageable.setLocationAndAngles(this.posX, this.posY, this.posZ, 0.0F, 0.0F); + this.worldObj.spawnEntityInWorld(entityageable); + + if (itemstack.hasDisplayName()) + { + entityageable.setCustomNameTag(itemstack.getDisplayName()); + } + + if (!par1EntityPlayer.capabilities.isCreativeMode) + { + --itemstack.stackSize; + + if (itemstack.stackSize <= 0) + { + par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack)null); + } + } + } + } + } + + return true; + } + else + { + return false; + } + } + + protected void entityInit() + { + super.entityInit(); + this.dataWatcher.addObject(12, new Integer(0)); + } + + public int getGrowingAge() + { + return this.dataWatcher.getWatchableObjectInt(12); + } + + public void addGrowth(int par1) + { + int j = this.getGrowingAge(); + j += par1 * 20; + + if (j > 0) + { + j = 0; + } + + this.setGrowingAge(j); + } + + public void setGrowingAge(int par1) + { + this.dataWatcher.updateObject(12, Integer.valueOf(par1)); + this.setScaleForAge(this.isChild()); + } + + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeEntityToNBT(par1NBTTagCompound); + par1NBTTagCompound.setInteger("Age", this.getGrowingAge()); + } + + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + super.readEntityFromNBT(par1NBTTagCompound); + this.setGrowingAge(par1NBTTagCompound.getInteger("Age")); + } + + public void onLivingUpdate() + { + super.onLivingUpdate(); + + if (this.worldObj.isRemote) + { + this.setScaleForAge(this.isChild()); + } + else + { + int i = this.getGrowingAge(); + + if (i < 0) + { + ++i; + this.setGrowingAge(i); + } + else if (i > 0) + { + --i; + this.setGrowingAge(i); + } + } + } + + public boolean isChild() + { + return this.getGrowingAge() < 0; + } + + public void setScaleForAge(boolean par1) + { + this.setScale(par1 ? 0.5F : 1.0F); + } + + protected final void setSize(float par1, float par2) + { + boolean flag = this.field_98056_d > 0.0F; + this.field_98056_d = par1; + this.field_98057_e = par2; + + if (!flag) + { + this.setScale(1.0F); + } + } + + protected final void setScale(float par1) + { + super.setSize(this.field_98056_d * par1, this.field_98057_e * par1); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/EntityBodyHelper.java b/src/main/java/net/minecraft/entity/EntityBodyHelper.java new file mode 100644 index 0000000..0e8795c --- /dev/null +++ b/src/main/java/net/minecraft/entity/EntityBodyHelper.java @@ -0,0 +1,69 @@ +package net.minecraft.entity; + +import net.minecraft.util.MathHelper; + +public class EntityBodyHelper +{ + private EntityLivingBase theLiving; + private int field_75666_b; + private float field_75667_c; + private static final String __OBFID = "CL_00001570"; + + public EntityBodyHelper(EntityLivingBase par1EntityLivingBase) + { + this.theLiving = par1EntityLivingBase; + } + + public void func_75664_a() + { + double d0 = this.theLiving.posX - this.theLiving.prevPosX; + double d1 = this.theLiving.posZ - this.theLiving.prevPosZ; + + if (d0 * d0 + d1 * d1 > 2.500000277905201E-7D) + { + this.theLiving.renderYawOffset = this.theLiving.rotationYaw; + this.theLiving.rotationYawHead = this.func_75665_a(this.theLiving.renderYawOffset, this.theLiving.rotationYawHead, 75.0F); + this.field_75667_c = this.theLiving.rotationYawHead; + this.field_75666_b = 0; + } + else + { + float f = 75.0F; + + if (Math.abs(this.theLiving.rotationYawHead - this.field_75667_c) > 15.0F) + { + this.field_75666_b = 0; + this.field_75667_c = this.theLiving.rotationYawHead; + } + else + { + ++this.field_75666_b; + boolean flag = true; + + if (this.field_75666_b > 10) + { + f = Math.max(1.0F - (float)(this.field_75666_b - 10) / 10.0F, 0.0F) * 75.0F; + } + } + + this.theLiving.renderYawOffset = this.func_75665_a(this.theLiving.rotationYawHead, this.theLiving.renderYawOffset, f); + } + } + + private float func_75665_a(float par1, float par2, float par3) + { + float f3 = MathHelper.wrapAngleTo180_float(par1 - par2); + + if (f3 < -par3) + { + f3 = -par3; + } + + if (f3 >= par3) + { + f3 = par3; + } + + return par1 - f3; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/EntityCreature.java b/src/main/java/net/minecraft/entity/EntityCreature.java new file mode 100644 index 0000000..b021fe5 --- /dev/null +++ b/src/main/java/net/minecraft/entity/EntityCreature.java @@ -0,0 +1,351 @@ +package net.minecraft.entity; + +import java.util.UUID; +import net.minecraft.entity.ai.EntityAIBase; +import net.minecraft.entity.ai.EntityAIMoveTowardsRestriction; +import net.minecraft.entity.ai.attributes.AttributeModifier; +import net.minecraft.entity.ai.attributes.IAttributeInstance; +import net.minecraft.entity.passive.EntityTameable; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.pathfinding.PathEntity; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; + +public abstract class EntityCreature extends EntityLiving +{ + public static final UUID field_110179_h = UUID.fromString("E199AD21-BA8A-4C53-8D13-6182D5C69D3A"); + public static final AttributeModifier field_110181_i = (new AttributeModifier(field_110179_h, "Fleeing speed bonus", 2.0D, 2)).setSaved(false); + private PathEntity pathToEntity; + protected Entity entityToAttack; + protected boolean hasAttacked; + protected int fleeingTick; + private ChunkCoordinates homePosition = new ChunkCoordinates(0, 0, 0); + private float maximumHomeDistance = -1.0F; + private EntityAIBase field_110178_bs = new EntityAIMoveTowardsRestriction(this, 1.0D); + private boolean field_110180_bt; + private static final String __OBFID = "CL_00001558"; + + public EntityCreature(World par1World) + { + super(par1World); + } + + protected boolean isMovementCeased() + { + return false; + } + + protected void updateEntityActionState() + { + this.worldObj.theProfiler.startSection("ai"); + + if (this.fleeingTick > 0 && --this.fleeingTick == 0) + { + IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed); + iattributeinstance.removeModifier(field_110181_i); + } + + this.hasAttacked = this.isMovementCeased(); + float f4 = 16.0F; + + if (this.entityToAttack == null) + { + this.entityToAttack = this.findPlayerToAttack(); + + if (this.entityToAttack != null) + { + this.pathToEntity = this.worldObj.getPathEntityToEntity(this, this.entityToAttack, f4, true, false, false, true); + } + } + else if (this.entityToAttack.isEntityAlive()) + { + float f = this.entityToAttack.getDistanceToEntity(this); + + if (this.canEntityBeSeen(this.entityToAttack)) + { + this.attackEntity(this.entityToAttack, f); + } + } + else + { + this.entityToAttack = null; + } + + if (this.entityToAttack instanceof EntityPlayerMP && ((EntityPlayerMP)this.entityToAttack).theItemInWorldManager.isCreative()) + { + this.entityToAttack = null; + } + + this.worldObj.theProfiler.endSection(); + + if (!this.hasAttacked && this.entityToAttack != null && (this.pathToEntity == null || this.rand.nextInt(20) == 0)) + { + this.pathToEntity = this.worldObj.getPathEntityToEntity(this, this.entityToAttack, f4, true, false, false, true); + } + else if (!this.hasAttacked && (this.pathToEntity == null && this.rand.nextInt(180) == 0 || this.rand.nextInt(120) == 0 || this.fleeingTick > 0) && this.entityAge < 100) + { + this.updateWanderPath(); + } + + int i = MathHelper.floor_double(this.boundingBox.minY + 0.5D); + boolean flag = this.isInWater(); + boolean flag1 = this.handleLavaMovement(); + this.rotationPitch = 0.0F; + + if (this.pathToEntity != null && this.rand.nextInt(100) != 0) + { + this.worldObj.theProfiler.startSection("followpath"); + Vec3 vec3 = this.pathToEntity.getPosition(this); + double d0 = (double)(this.width * 2.0F); + + while (vec3 != null && vec3.squareDistanceTo(this.posX, vec3.yCoord, this.posZ) < d0 * d0) + { + this.pathToEntity.incrementPathIndex(); + + if (this.pathToEntity.isFinished()) + { + vec3 = null; + this.pathToEntity = null; + } + else + { + vec3 = this.pathToEntity.getPosition(this); + } + } + + this.isJumping = false; + + if (vec3 != null) + { + double d1 = vec3.xCoord - this.posX; + double d2 = vec3.zCoord - this.posZ; + double d3 = vec3.yCoord - (double)i; + float f1 = (float)(Math.atan2(d2, d1) * 180.0D / Math.PI) - 90.0F; + float f2 = MathHelper.wrapAngleTo180_float(f1 - this.rotationYaw); + this.moveForward = (float)this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue(); + + if (f2 > 30.0F) + { + f2 = 30.0F; + } + + if (f2 < -30.0F) + { + f2 = -30.0F; + } + + this.rotationYaw += f2; + + if (this.hasAttacked && this.entityToAttack != null) + { + double d4 = this.entityToAttack.posX - this.posX; + double d5 = this.entityToAttack.posZ - this.posZ; + float f3 = this.rotationYaw; + this.rotationYaw = (float)(Math.atan2(d5, d4) * 180.0D / Math.PI) - 90.0F; + f2 = (f3 - this.rotationYaw + 90.0F) * (float)Math.PI / 180.0F; + this.moveStrafing = -MathHelper.sin(f2) * this.moveForward * 1.0F; + this.moveForward = MathHelper.cos(f2) * this.moveForward * 1.0F; + } + + if (d3 > 0.0D) + { + this.isJumping = true; + } + } + + if (this.entityToAttack != null) + { + this.faceEntity(this.entityToAttack, 30.0F, 30.0F); + } + + if (this.isCollidedHorizontally && !this.hasPath()) + { + this.isJumping = true; + } + + if (this.rand.nextFloat() < 0.8F && (flag || flag1)) + { + this.isJumping = true; + } + + this.worldObj.theProfiler.endSection(); + } + else + { + super.updateEntityActionState(); + this.pathToEntity = null; + } + } + + protected void updateWanderPath() + { + this.worldObj.theProfiler.startSection("stroll"); + boolean flag = false; + int i = -1; + int j = -1; + int k = -1; + float f = -99999.0F; + + for (int l = 0; l < 10; ++l) + { + int i1 = MathHelper.floor_double(this.posX + (double)this.rand.nextInt(13) - 6.0D); + int j1 = MathHelper.floor_double(this.posY + (double)this.rand.nextInt(7) - 3.0D); + int k1 = MathHelper.floor_double(this.posZ + (double)this.rand.nextInt(13) - 6.0D); + float f1 = this.getBlockPathWeight(i1, j1, k1); + + if (f1 > f) + { + f = f1; + i = i1; + j = j1; + k = k1; + flag = true; + } + } + + if (flag) + { + this.pathToEntity = this.worldObj.getEntityPathToXYZ(this, i, j, k, 10.0F, true, false, false, true); + } + + this.worldObj.theProfiler.endSection(); + } + + protected void attackEntity(Entity par1Entity, float par2) {} + + public float getBlockPathWeight(int par1, int par2, int par3) + { + return 0.0F; + } + + protected Entity findPlayerToAttack() + { + return null; + } + + public boolean getCanSpawnHere() + { + int i = MathHelper.floor_double(this.posX); + int j = MathHelper.floor_double(this.boundingBox.minY); + int k = MathHelper.floor_double(this.posZ); + return super.getCanSpawnHere() && this.getBlockPathWeight(i, j, k) >= 0.0F; + } + + public boolean hasPath() + { + return this.pathToEntity != null; + } + + public void setPathToEntity(PathEntity par1PathEntity) + { + this.pathToEntity = par1PathEntity; + } + + public Entity getEntityToAttack() + { + return this.entityToAttack; + } + + public void setTarget(Entity par1Entity) + { + this.entityToAttack = par1Entity; + } + + public boolean isWithinHomeDistanceCurrentPosition() + { + return this.isWithinHomeDistance(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)); + } + + public boolean isWithinHomeDistance(int par1, int par2, int par3) + { + return this.maximumHomeDistance == -1.0F ? true : this.homePosition.getDistanceSquared(par1, par2, par3) < this.maximumHomeDistance * this.maximumHomeDistance; + } + + public void setHomeArea(int par1, int par2, int par3, int par4) + { + this.homePosition.set(par1, par2, par3); + this.maximumHomeDistance = (float)par4; + } + + public ChunkCoordinates getHomePosition() + { + return this.homePosition; + } + + public float func_110174_bM() + { + return this.maximumHomeDistance; + } + + public void detachHome() + { + this.maximumHomeDistance = -1.0F; + } + + public boolean hasHome() + { + return this.maximumHomeDistance != -1.0F; + } + + protected void updateLeashedState() + { + super.updateLeashedState(); + + if (this.getLeashed() && this.getLeashedToEntity() != null && this.getLeashedToEntity().worldObj == this.worldObj) + { + Entity entity = this.getLeashedToEntity(); + this.setHomeArea((int)entity.posX, (int)entity.posY, (int)entity.posZ, 5); + float f = this.getDistanceToEntity(entity); + + if (this instanceof EntityTameable && ((EntityTameable)this).isSitting()) + { + if (f > 10.0F) + { + this.clearLeashed(true, true); + } + + return; + } + + if (!this.field_110180_bt) + { + this.tasks.addTask(2, this.field_110178_bs); + this.getNavigator().setAvoidsWater(false); + this.field_110180_bt = true; + } + + this.func_142017_o(f); + + if (f > 4.0F) + { + this.getNavigator().tryMoveToEntityLiving(entity, 1.0D); + } + + if (f > 6.0F) + { + double d0 = (entity.posX - this.posX) / (double)f; + double d1 = (entity.posY - this.posY) / (double)f; + double d2 = (entity.posZ - this.posZ) / (double)f; + this.motionX += d0 * Math.abs(d0) * 0.4D; + this.motionY += d1 * Math.abs(d1) * 0.4D; + this.motionZ += d2 * Math.abs(d2) * 0.4D; + } + + if (f > 10.0F) + { + this.clearLeashed(true, true); + } + } + else if (!this.getLeashed() && this.field_110180_bt) + { + this.field_110180_bt = false; + this.tasks.removeTask(this.field_110178_bs); + this.getNavigator().setAvoidsWater(true); + this.detachHome(); + } + } + + protected void func_142017_o(float par1) {} +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/EntityFlying.java b/src/main/java/net/minecraft/entity/EntityFlying.java new file mode 100644 index 0000000..ac89c7f --- /dev/null +++ b/src/main/java/net/minecraft/entity/EntityFlying.java @@ -0,0 +1,79 @@ +package net.minecraft.entity; + +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public abstract class EntityFlying extends EntityLiving +{ + private static final String __OBFID = "CL_00001545"; + + public EntityFlying(World par1World) + { + super(par1World); + } + + protected void fall(float par1) {} + + protected void updateFallState(double par1, boolean par3) {} + + public void moveEntityWithHeading(float par1, float par2) + { + if (this.isInWater()) + { + this.moveFlying(par1, par2, 0.02F); + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.800000011920929D; + this.motionY *= 0.800000011920929D; + this.motionZ *= 0.800000011920929D; + } + else if (this.handleLavaMovement()) + { + this.moveFlying(par1, par2, 0.02F); + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.5D; + this.motionY *= 0.5D; + this.motionZ *= 0.5D; + } + else + { + float f2 = 0.91F; + + if (this.onGround) + { + f2 = this.worldObj.getBlock(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.boundingBox.minY) - 1, MathHelper.floor_double(this.posZ)).slipperiness * 0.91F; + } + + float f3 = 0.16277136F / (f2 * f2 * f2); + this.moveFlying(par1, par2, this.onGround ? 0.1F * f3 : 0.02F); + f2 = 0.91F; + + if (this.onGround) + { + f2 = this.worldObj.getBlock(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.boundingBox.minY) - 1, MathHelper.floor_double(this.posZ)).slipperiness * 0.91F; + } + + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= (double)f2; + this.motionY *= (double)f2; + this.motionZ *= (double)f2; + } + + this.prevLimbSwingAmount = this.limbSwingAmount; + double d1 = this.posX - this.prevPosX; + double d0 = this.posZ - this.prevPosZ; + float f4 = MathHelper.sqrt_double(d1 * d1 + d0 * d0) * 4.0F; + + if (f4 > 1.0F) + { + f4 = 1.0F; + } + + this.limbSwingAmount += (f4 - this.limbSwingAmount) * 0.4F; + this.limbSwing += this.limbSwingAmount; + } + + public boolean isOnLadder() + { + return false; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/EntityHanging.java b/src/main/java/net/minecraft/entity/EntityHanging.java new file mode 100644 index 0000000..793f5b6 --- /dev/null +++ b/src/main/java/net/minecraft/entity/EntityHanging.java @@ -0,0 +1,326 @@ +package net.minecraft.entity; + +import java.util.Iterator; +import java.util.List; +import net.minecraft.block.material.Material; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.DamageSource; +import net.minecraft.util.Direction; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public abstract class EntityHanging extends Entity +{ + private int tickCounter1; + public int hangingDirection; + public int field_146063_b; + public int field_146064_c; + public int field_146062_d; + private static final String __OBFID = "CL_00001546"; + + public EntityHanging(World par1World) + { + super(par1World); + this.yOffset = 0.0F; + this.setSize(0.5F, 0.5F); + } + + public EntityHanging(World par1World, int par2, int par3, int par4, int par5) + { + this(par1World); + this.field_146063_b = par2; + this.field_146064_c = par3; + this.field_146062_d = par4; + } + + protected void entityInit() {} + + public void setDirection(int par1) + { + this.hangingDirection = par1; + this.prevRotationYaw = this.rotationYaw = (float)(par1 * 90); + float f = (float)this.getWidthPixels(); + float f1 = (float)this.getHeightPixels(); + float f2 = (float)this.getWidthPixels(); + + if (par1 != 2 && par1 != 0) + { + f = 0.5F; + } + else + { + f2 = 0.5F; + this.rotationYaw = this.prevRotationYaw = (float)(Direction.rotateOpposite[par1] * 90); + } + + f /= 32.0F; + f1 /= 32.0F; + f2 /= 32.0F; + float f3 = (float)this.field_146063_b + 0.5F; + float f4 = (float)this.field_146064_c + 0.5F; + float f5 = (float)this.field_146062_d + 0.5F; + float f6 = 0.5625F; + + if (par1 == 2) + { + f5 -= f6; + } + + if (par1 == 1) + { + f3 -= f6; + } + + if (par1 == 0) + { + f5 += f6; + } + + if (par1 == 3) + { + f3 += f6; + } + + if (par1 == 2) + { + f3 -= this.func_70517_b(this.getWidthPixels()); + } + + if (par1 == 1) + { + f5 += this.func_70517_b(this.getWidthPixels()); + } + + if (par1 == 0) + { + f3 += this.func_70517_b(this.getWidthPixels()); + } + + if (par1 == 3) + { + f5 -= this.func_70517_b(this.getWidthPixels()); + } + + f4 += this.func_70517_b(this.getHeightPixels()); + this.setPosition((double)f3, (double)f4, (double)f5); + float f7 = -0.03125F; + this.boundingBox.setBounds((double)(f3 - f - f7), (double)(f4 - f1 - f7), (double)(f5 - f2 - f7), (double)(f3 + f + f7), (double)(f4 + f1 + f7), (double)(f5 + f2 + f7)); + } + + private float func_70517_b(int par1) + { + return par1 == 32 ? 0.5F : (par1 == 64 ? 0.5F : 0.0F); + } + + public void onUpdate() + { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + + if (this.tickCounter1++ == 100 && !this.worldObj.isRemote) + { + this.tickCounter1 = 0; + + if (!this.isDead && !this.onValidSurface()) + { + this.setDead(); + this.onBroken((Entity)null); + } + } + } + + public boolean onValidSurface() + { + if (!this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox).isEmpty()) + { + return false; + } + else + { + int i = Math.max(1, this.getWidthPixels() / 16); + int j = Math.max(1, this.getHeightPixels() / 16); + int k = this.field_146063_b; + int l = this.field_146064_c; + int i1 = this.field_146062_d; + + if (this.hangingDirection == 2) + { + k = MathHelper.floor_double(this.posX - (double)((float)this.getWidthPixels() / 32.0F)); + } + + if (this.hangingDirection == 1) + { + i1 = MathHelper.floor_double(this.posZ - (double)((float)this.getWidthPixels() / 32.0F)); + } + + if (this.hangingDirection == 0) + { + k = MathHelper.floor_double(this.posX - (double)((float)this.getWidthPixels() / 32.0F)); + } + + if (this.hangingDirection == 3) + { + i1 = MathHelper.floor_double(this.posZ - (double)((float)this.getWidthPixels() / 32.0F)); + } + + l = MathHelper.floor_double(this.posY - (double)((float)this.getHeightPixels() / 32.0F)); + + for (int j1 = 0; j1 < i; ++j1) + { + for (int k1 = 0; k1 < j; ++k1) + { + Material material; + + if (this.hangingDirection != 2 && this.hangingDirection != 0) + { + material = this.worldObj.getBlock(this.field_146063_b, l + k1, i1 + j1).getMaterial(); + } + else + { + material = this.worldObj.getBlock(k + j1, l + k1, this.field_146062_d).getMaterial(); + } + + if (!material.isSolid()) + { + return false; + } + } + } + + List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox); + Iterator iterator = list.iterator(); + Entity entity; + + do + { + if (!iterator.hasNext()) + { + return true; + } + + entity = (Entity)iterator.next(); + } + while (!(entity instanceof EntityHanging)); + + return false; + } + } + + public boolean canBeCollidedWith() + { + return true; + } + + public boolean hitByEntity(Entity par1Entity) + { + return par1Entity instanceof EntityPlayer ? this.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer)par1Entity), 0.0F) : false; + } + + public void func_145781_i(int p_145781_1_) + { + this.worldObj.func_147450_X(); + } + + public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) + { + if (this.isEntityInvulnerable()) + { + return false; + } + else + { + if (!this.isDead && !this.worldObj.isRemote) + { + this.setDead(); + this.setBeenAttacked(); + this.onBroken(par1DamageSource.getEntity()); + } + + return true; + } + } + + public void moveEntity(double par1, double par3, double par5) + { + if (!this.worldObj.isRemote && !this.isDead && par1 * par1 + par3 * par3 + par5 * par5 > 0.0D) + { + this.setDead(); + this.onBroken((Entity)null); + } + } + + public void addVelocity(double par1, double par3, double par5) + { + if (!this.worldObj.isRemote && !this.isDead && par1 * par1 + par3 * par3 + par5 * par5 > 0.0D) + { + this.setDead(); + this.onBroken((Entity)null); + } + } + + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + par1NBTTagCompound.setByte("Direction", (byte)this.hangingDirection); + par1NBTTagCompound.setInteger("TileX", this.field_146063_b); + par1NBTTagCompound.setInteger("TileY", this.field_146064_c); + par1NBTTagCompound.setInteger("TileZ", this.field_146062_d); + + switch (this.hangingDirection) + { + case 0: + par1NBTTagCompound.setByte("Dir", (byte)2); + break; + case 1: + par1NBTTagCompound.setByte("Dir", (byte)1); + break; + case 2: + par1NBTTagCompound.setByte("Dir", (byte)0); + break; + case 3: + par1NBTTagCompound.setByte("Dir", (byte)3); + } + } + + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + if (par1NBTTagCompound.hasKey("Direction", 99)) + { + this.hangingDirection = par1NBTTagCompound.getByte("Direction"); + } + else + { + switch (par1NBTTagCompound.getByte("Dir")) + { + case 0: + this.hangingDirection = 2; + break; + case 1: + this.hangingDirection = 1; + break; + case 2: + this.hangingDirection = 0; + break; + case 3: + this.hangingDirection = 3; + } + } + + this.field_146063_b = par1NBTTagCompound.getInteger("TileX"); + this.field_146064_c = par1NBTTagCompound.getInteger("TileY"); + this.field_146062_d = par1NBTTagCompound.getInteger("TileZ"); + this.setDirection(this.hangingDirection); + } + + public abstract int getWidthPixels(); + + public abstract int getHeightPixels(); + + public abstract void onBroken(Entity var1); + + protected boolean shouldSetPosAfterLoading() + { + return false; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/EntityLeashKnot.java b/src/main/java/net/minecraft/entity/EntityLeashKnot.java new file mode 100644 index 0000000..21a262f --- /dev/null +++ b/src/main/java/net/minecraft/entity/EntityLeashKnot.java @@ -0,0 +1,157 @@ +package net.minecraft.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Iterator; +import java.util.List; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; + +public class EntityLeashKnot extends EntityHanging +{ + private static final String __OBFID = "CL_00001548"; + + public EntityLeashKnot(World par1World) + { + super(par1World); + } + + public EntityLeashKnot(World par1World, int par2, int par3, int par4) + { + super(par1World, par2, par3, par4, 0); + this.setPosition((double)par2 + 0.5D, (double)par3 + 0.5D, (double)par4 + 0.5D); + } + + protected void entityInit() + { + super.entityInit(); + } + + public void setDirection(int par1) {} + + public int getWidthPixels() + { + return 9; + } + + public int getHeightPixels() + { + return 9; + } + + @SideOnly(Side.CLIENT) + public boolean isInRangeToRenderDist(double par1) + { + return par1 < 1024.0D; + } + + public void onBroken(Entity par1Entity) {} + + public boolean writeToNBTOptional(NBTTagCompound par1NBTTagCompound) + { + return false; + } + + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) {} + + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {} + + public boolean interactFirst(EntityPlayer par1EntityPlayer) + { + ItemStack itemstack = par1EntityPlayer.getHeldItem(); + boolean flag = false; + double d0; + List list; + Iterator iterator; + EntityLiving entityliving; + + if (itemstack != null && itemstack.getItem() == Items.lead && !this.worldObj.isRemote) + { + d0 = 7.0D; + list = this.worldObj.getEntitiesWithinAABB(EntityLiving.class, AxisAlignedBB.getAABBPool().getAABB(this.posX - d0, this.posY - d0, this.posZ - d0, this.posX + d0, this.posY + d0, this.posZ + d0)); + + if (list != null) + { + iterator = list.iterator(); + + while (iterator.hasNext()) + { + entityliving = (EntityLiving)iterator.next(); + + if (entityliving.getLeashed() && entityliving.getLeashedToEntity() == par1EntityPlayer) + { + entityliving.setLeashedToEntity(this, true); + flag = true; + } + } + } + } + + if (!this.worldObj.isRemote && !flag) + { + this.setDead(); + + if (par1EntityPlayer.capabilities.isCreativeMode) + { + d0 = 7.0D; + list = this.worldObj.getEntitiesWithinAABB(EntityLiving.class, AxisAlignedBB.getAABBPool().getAABB(this.posX - d0, this.posY - d0, this.posZ - d0, this.posX + d0, this.posY + d0, this.posZ + d0)); + + if (list != null) + { + iterator = list.iterator(); + + while (iterator.hasNext()) + { + entityliving = (EntityLiving)iterator.next(); + + if (entityliving.getLeashed() && entityliving.getLeashedToEntity() == this) + { + entityliving.clearLeashed(true, false); + } + } + } + } + } + + return true; + } + + public boolean onValidSurface() + { + return this.worldObj.getBlock(this.field_146063_b, this.field_146064_c, this.field_146062_d).getRenderType() == 11; + } + + public static EntityLeashKnot func_110129_a(World par0World, int par1, int par2, int par3) + { + EntityLeashKnot entityleashknot = new EntityLeashKnot(par0World, par1, par2, par3); + entityleashknot.forceSpawn = true; + par0World.spawnEntityInWorld(entityleashknot); + return entityleashknot; + } + + public static EntityLeashKnot getKnotForBlock(World par0World, int par1, int par2, int par3) + { + List list = par0World.getEntitiesWithinAABB(EntityLeashKnot.class, AxisAlignedBB.getAABBPool().getAABB((double)par1 - 1.0D, (double)par2 - 1.0D, (double)par3 - 1.0D, (double)par1 + 1.0D, (double)par2 + 1.0D, (double)par3 + 1.0D)); + + if (list != null) + { + Iterator iterator = list.iterator(); + + while (iterator.hasNext()) + { + EntityLeashKnot entityleashknot = (EntityLeashKnot)iterator.next(); + + if (entityleashknot.field_146063_b == par1 && entityleashknot.field_146064_c == par2 && entityleashknot.field_146062_d == par3) + { + return entityleashknot; + } + } + } + + return null; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/EntityList.java b/src/main/java/net/minecraft/entity/EntityList.java new file mode 100644 index 0000000..71ca317 --- /dev/null +++ b/src/main/java/net/minecraft/entity/EntityList.java @@ -0,0 +1,324 @@ +package net.minecraft.entity; + +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Set; + +import net.minecraft.entity.ai.EntityMinecartMobSpawner; +import net.minecraft.entity.boss.EntityDragon; +import net.minecraft.entity.boss.EntityWither; +import net.minecraft.entity.item.EntityBoat; +import net.minecraft.entity.item.EntityEnderCrystal; +import net.minecraft.entity.item.EntityEnderEye; +import net.minecraft.entity.item.EntityEnderPearl; +import net.minecraft.entity.item.EntityExpBottle; +import net.minecraft.entity.item.EntityFallingBlock; +import net.minecraft.entity.item.EntityFireworkRocket; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.item.EntityItemFrame; +import net.minecraft.entity.item.EntityMinecartChest; +import net.minecraft.entity.item.EntityMinecartEmpty; +import net.minecraft.entity.item.EntityMinecartFurnace; +import net.minecraft.entity.item.EntityMinecartHopper; +import net.minecraft.entity.item.EntityMinecartTNT; +import net.minecraft.entity.item.EntityPainting; +import net.minecraft.entity.item.EntityTNTPrimed; +import net.minecraft.entity.item.EntityXPOrb; +import net.minecraft.entity.monster.EntityBlaze; +import net.minecraft.entity.monster.EntityCaveSpider; +import net.minecraft.entity.monster.EntityCreeper; +import net.minecraft.entity.monster.EntityEnderman; +import net.minecraft.entity.monster.EntityGhast; +import net.minecraft.entity.monster.EntityGiantZombie; +import net.minecraft.entity.monster.EntityIronGolem; +import net.minecraft.entity.monster.EntityMagmaCube; +import net.minecraft.entity.monster.EntityMob; +import net.minecraft.entity.monster.EntityPigZombie; +import net.minecraft.entity.monster.EntitySilverfish; +import net.minecraft.entity.monster.EntitySkeleton; +import net.minecraft.entity.monster.EntitySlime; +import net.minecraft.entity.monster.EntitySnowman; +import net.minecraft.entity.monster.EntitySpider; +import net.minecraft.entity.monster.EntityWitch; +import net.minecraft.entity.monster.EntityZombie; +import net.minecraft.entity.passive.EntityBat; +import net.minecraft.entity.passive.EntityChicken; +import net.minecraft.entity.passive.EntityCow; +import net.minecraft.entity.passive.EntityHorse; +import net.minecraft.entity.passive.EntityMooshroom; +import net.minecraft.entity.passive.EntityOcelot; +import net.minecraft.entity.passive.EntityPig; +import net.minecraft.entity.passive.EntitySheep; +import net.minecraft.entity.passive.EntitySquid; +import net.minecraft.entity.passive.EntityVillager; +import net.minecraft.entity.passive.EntityWolf; +import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.entity.projectile.EntityLargeFireball; +import net.minecraft.entity.projectile.EntityPotion; +import net.minecraft.entity.projectile.EntitySmallFireball; +import net.minecraft.entity.projectile.EntitySnowball; +import net.minecraft.entity.projectile.EntityWitherSkull; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.stats.StatBase; +import net.minecraft.stats.StatList; +import net.minecraft.world.World; + +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import cpw.mods.fml.common.FMLLog; + +public class EntityList +{ + private static final Logger logger = LogManager.getLogger(); + public static Map stringToClassMapping = new HashMap(); + public static Map classToStringMapping = new HashMap(); + public static Map IDtoClassMapping = new HashMap(); + private static Map classToIDMapping = new HashMap(); + private static Map stringToIDMapping = new HashMap(); + public static HashMap entityEggs = new LinkedHashMap(); + private static final String __OBFID = "CL_00001538"; + + public static void addMapping(Class par0Class, String par1Str, int par2) + { + if (stringToClassMapping.containsKey(par1Str)) + { + throw new IllegalArgumentException("ID is already registered: " + par1Str); + } + else if (IDtoClassMapping.containsKey(Integer.valueOf(par2))) + { + throw new IllegalArgumentException("ID is already registered: " + par2); + } + else + { + stringToClassMapping.put(par1Str, par0Class); + classToStringMapping.put(par0Class, par1Str); + IDtoClassMapping.put(Integer.valueOf(par2), par0Class); + classToIDMapping.put(par0Class, Integer.valueOf(par2)); + stringToIDMapping.put(par1Str, Integer.valueOf(par2)); + } + } + + public static void addMapping(Class par0Class, String par1Str, int par2, int par3, int par4) + { + addMapping(par0Class, par1Str, par2); + entityEggs.put(Integer.valueOf(par2), new EntityList.EntityEggInfo(par2, par3, par4)); + } + + public static Entity createEntityByName(String par0Str, World par1World) + { + Entity entity = null; + + try + { + Class oclass = (Class)stringToClassMapping.get(par0Str); + + if (oclass != null) + { + entity = (Entity)oclass.getConstructor(new Class[] {World.class}).newInstance(new Object[] {par1World}); + } + } + catch (Exception exception) + { + exception.printStackTrace(); + } + + return entity; + } + + public static Entity createEntityFromNBT(NBTTagCompound par0NBTTagCompound, World par1World) + { + Entity entity = null; + + if ("Minecart".equals(par0NBTTagCompound.getString("id"))) + { + switch (par0NBTTagCompound.getInteger("Type")) + { + case 0: + par0NBTTagCompound.setString("id", "MinecartRideable"); + break; + case 1: + par0NBTTagCompound.setString("id", "MinecartChest"); + break; + case 2: + par0NBTTagCompound.setString("id", "MinecartFurnace"); + } + + par0NBTTagCompound.removeTag("Type"); + } + + Class oclass = null; + try + { + oclass = (Class)stringToClassMapping.get(par0NBTTagCompound.getString("id")); + + if (oclass != null) + { + entity = (Entity)oclass.getConstructor(new Class[] {World.class}).newInstance(new Object[] {par1World}); + } + } + catch (Exception exception) + { + exception.printStackTrace(); + } + + if (entity != null) + { + try + { + entity.readFromNBT(par0NBTTagCompound); + } + catch (Exception e) + { + FMLLog.log(Level.ERROR, e, + "An Entity %s(%s) has thrown an exception during loading, its state cannot be restored. Report this to the mod author", + par0NBTTagCompound.getString("id"), oclass.getName()); + entity = null; + } + } + else + { + logger.warn("Skipping Entity with id " + par0NBTTagCompound.getString("id")); + } + + return entity; + } + + public static Entity createEntityByID(int par0, World par1World) + { + Entity entity = null; + + try + { + Class oclass = getClassFromID(par0); + + if (oclass != null) + { + entity = (Entity)oclass.getConstructor(new Class[] {World.class}).newInstance(new Object[] {par1World}); + } + } + catch (Exception exception) + { + exception.printStackTrace(); + } + + if (entity == null) + { + logger.warn("Skipping Entity with id " + par0); + } + + return entity; + } + + public static int getEntityID(Entity par0Entity) + { + Class oclass = par0Entity.getClass(); + return classToIDMapping.containsKey(oclass) ? ((Integer)classToIDMapping.get(oclass)).intValue() : 0; + } + + public static Class getClassFromID(int par0) + { + return (Class)IDtoClassMapping.get(Integer.valueOf(par0)); + } + + public static String getEntityString(Entity par0Entity) + { + return (String)classToStringMapping.get(par0Entity.getClass()); + } + + public static String getStringFromID(int par0) + { + Class oclass = getClassFromID(par0); + return oclass != null ? (String)classToStringMapping.get(oclass) : null; + } + + public static void func_151514_a() {} + + public static Set func_151515_b() + { + return Collections.unmodifiableSet(stringToIDMapping.keySet()); + } + + static + { + addMapping(EntityItem.class, "Item", 1); + addMapping(EntityXPOrb.class, "XPOrb", 2); + addMapping(EntityLeashKnot.class, "LeashKnot", 8); + addMapping(EntityPainting.class, "Painting", 9); + addMapping(EntityArrow.class, "Arrow", 10); + addMapping(EntitySnowball.class, "Snowball", 11); + addMapping(EntityLargeFireball.class, "Fireball", 12); + addMapping(EntitySmallFireball.class, "SmallFireball", 13); + addMapping(EntityEnderPearl.class, "ThrownEnderpearl", 14); + addMapping(EntityEnderEye.class, "EyeOfEnderSignal", 15); + addMapping(EntityPotion.class, "ThrownPotion", 16); + addMapping(EntityExpBottle.class, "ThrownExpBottle", 17); + addMapping(EntityItemFrame.class, "ItemFrame", 18); + addMapping(EntityWitherSkull.class, "WitherSkull", 19); + addMapping(EntityTNTPrimed.class, "PrimedTnt", 20); + addMapping(EntityFallingBlock.class, "FallingSand", 21); + addMapping(EntityFireworkRocket.class, "FireworksRocketEntity", 22); + addMapping(EntityBoat.class, "Boat", 41); + addMapping(EntityMinecartEmpty.class, "MinecartRideable", 42); + addMapping(EntityMinecartChest.class, "MinecartChest", 43); + addMapping(EntityMinecartFurnace.class, "MinecartFurnace", 44); + addMapping(EntityMinecartTNT.class, "MinecartTNT", 45); + addMapping(EntityMinecartHopper.class, "MinecartHopper", 46); + addMapping(EntityMinecartMobSpawner.class, "MinecartSpawner", 47); + addMapping(EntityMinecartCommandBlock.class, "MinecartCommandBlock", 40); + addMapping(EntityLiving.class, "Mob", 48); + addMapping(EntityMob.class, "Monster", 49); + addMapping(EntityCreeper.class, "Creeper", 50, 894731, 0); + addMapping(EntitySkeleton.class, "Skeleton", 51, 12698049, 4802889); + addMapping(EntitySpider.class, "Spider", 52, 3419431, 11013646); + addMapping(EntityGiantZombie.class, "Giant", 53); + addMapping(EntityZombie.class, "Zombie", 54, 44975, 7969893); + addMapping(EntitySlime.class, "Slime", 55, 5349438, 8306542); + addMapping(EntityGhast.class, "Ghast", 56, 16382457, 12369084); + addMapping(EntityPigZombie.class, "PigZombie", 57, 15373203, 5009705); + addMapping(EntityEnderman.class, "Enderman", 58, 1447446, 0); + addMapping(EntityCaveSpider.class, "CaveSpider", 59, 803406, 11013646); + addMapping(EntitySilverfish.class, "Silverfish", 60, 7237230, 3158064); + addMapping(EntityBlaze.class, "Blaze", 61, 16167425, 16775294); + addMapping(EntityMagmaCube.class, "LavaSlime", 62, 3407872, 16579584); + addMapping(EntityDragon.class, "EnderDragon", 63); + addMapping(EntityWither.class, "WitherBoss", 64); + addMapping(EntityBat.class, "Bat", 65, 4996656, 986895); + addMapping(EntityWitch.class, "Witch", 66, 3407872, 5349438); + addMapping(EntityPig.class, "Pig", 90, 15771042, 14377823); + addMapping(EntitySheep.class, "Sheep", 91, 15198183, 16758197); + addMapping(EntityCow.class, "Cow", 92, 4470310, 10592673); + addMapping(EntityChicken.class, "Chicken", 93, 10592673, 16711680); + addMapping(EntitySquid.class, "Squid", 94, 2243405, 7375001); + addMapping(EntityWolf.class, "Wolf", 95, 14144467, 13545366); + addMapping(EntityMooshroom.class, "MushroomCow", 96, 10489616, 12040119); + addMapping(EntitySnowman.class, "SnowMan", 97); + addMapping(EntityOcelot.class, "Ozelot", 98, 15720061, 5653556); + addMapping(EntityIronGolem.class, "VillagerGolem", 99); + addMapping(EntityHorse.class, "EntityHorse", 100, 12623485, 15656192); + addMapping(EntityVillager.class, "Villager", 120, 5651507, 12422002); + addMapping(EntityEnderCrystal.class, "EnderCrystal", 200); + } + + public static class EntityEggInfo + { + public final int spawnedID; + public final int primaryColor; + public final int secondaryColor; + public final StatBase field_151512_d; + public final StatBase field_151513_e; + private static final String __OBFID = "CL_00001539"; + + public EntityEggInfo(int par1, int par2, int par3) + { + this.spawnedID = par1; + this.primaryColor = par2; + this.secondaryColor = par3; + this.field_151512_d = StatList.func_151182_a(this); + this.field_151513_e = StatList.func_151176_b(this); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/EntityLiving.java b/src/main/java/net/minecraft/entity/EntityLiving.java new file mode 100644 index 0000000..1e79d18 --- /dev/null +++ b/src/main/java/net/minecraft/entity/EntityLiving.java @@ -0,0 +1,1145 @@ +package net.minecraft.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Iterator; +import java.util.List; +import java.util.UUID; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.ai.EntityAITasks; +import net.minecraft.entity.ai.EntityJumpHelper; +import net.minecraft.entity.ai.EntityLookHelper; +import net.minecraft.entity.ai.EntityMoveHelper; +import net.minecraft.entity.ai.EntitySenses; +import net.minecraft.entity.ai.attributes.AttributeModifier; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.monster.EntityCreeper; +import net.minecraft.entity.monster.EntityGhast; +import net.minecraft.entity.monster.IMob; +import net.minecraft.entity.passive.EntityTameable; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemArmor; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemSword; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagFloat; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.network.play.server.S1BPacketEntityAttach; +import net.minecraft.pathfinding.PathNavigate; +import net.minecraft.stats.AchievementList; +import net.minecraft.util.MathHelper; +import net.minecraft.world.EnumDifficulty; +import net.minecraft.world.World; +import net.minecraft.world.WorldServer; +import net.minecraftforge.common.ForgeHooks; +import cpw.mods.fml.common.eventhandler.Event.Result; +import net.minecraftforge.event.ForgeEventFactory; + +public abstract class EntityLiving extends EntityLivingBase +{ + public int livingSoundTime; + protected int experienceValue; + private EntityLookHelper lookHelper; + private EntityMoveHelper moveHelper; + private EntityJumpHelper jumpHelper; + private EntityBodyHelper bodyHelper; + private PathNavigate navigator; + public final EntityAITasks tasks; + public final EntityAITasks targetTasks; + private EntityLivingBase attackTarget; + private EntitySenses senses; + private ItemStack[] equipment = new ItemStack[5]; + protected float[] equipmentDropChances = new float[5]; + private boolean canPickUpLoot; + private boolean persistenceRequired; + protected float defaultPitch; + private Entity currentTarget; + protected int numTicksToChaseTarget; + private boolean isLeashed; + private Entity leashedToEntity; + private NBTTagCompound field_110170_bx; + private static final String __OBFID = "CL_00001550"; + + public EntityLiving(World par1World) + { + super(par1World); + this.tasks = new EntityAITasks(par1World != null && par1World.theProfiler != null ? par1World.theProfiler : null); + this.targetTasks = new EntityAITasks(par1World != null && par1World.theProfiler != null ? par1World.theProfiler : null); + this.lookHelper = new EntityLookHelper(this); + this.moveHelper = new EntityMoveHelper(this); + this.jumpHelper = new EntityJumpHelper(this); + this.bodyHelper = new EntityBodyHelper(this); + this.navigator = new PathNavigate(this, par1World); + this.senses = new EntitySenses(this); + + for (int i = 0; i < this.equipmentDropChances.length; ++i) + { + this.equipmentDropChances[i] = 0.085F; + } + } + + protected void applyEntityAttributes() + { + super.applyEntityAttributes(); + this.getAttributeMap().registerAttribute(SharedMonsterAttributes.followRange).setBaseValue(16.0D); + } + + public EntityLookHelper getLookHelper() + { + return this.lookHelper; + } + + public EntityMoveHelper getMoveHelper() + { + return this.moveHelper; + } + + public EntityJumpHelper getJumpHelper() + { + return this.jumpHelper; + } + + public PathNavigate getNavigator() + { + return this.navigator; + } + + public EntitySenses getEntitySenses() + { + return this.senses; + } + + public EntityLivingBase getAttackTarget() + { + return this.attackTarget; + } + + public void setAttackTarget(EntityLivingBase par1EntityLivingBase) + { + this.attackTarget = par1EntityLivingBase; + ForgeHooks.onLivingSetAttackTarget(this, par1EntityLivingBase); + } + + public boolean canAttackClass(Class par1Class) + { + return EntityCreeper.class != par1Class && EntityGhast.class != par1Class; + } + + public void eatGrassBonus() {} + + protected void entityInit() + { + super.entityInit(); + this.dataWatcher.addObject(11, Byte.valueOf((byte)0)); + this.dataWatcher.addObject(10, ""); + } + + public int getTalkInterval() + { + return 80; + } + + public void playLivingSound() + { + String s = this.getLivingSound(); + + if (s != null) + { + this.playSound(s, this.getSoundVolume(), this.getSoundPitch()); + } + } + + public void onEntityUpdate() + { + super.onEntityUpdate(); + this.worldObj.theProfiler.startSection("mobBaseTick"); + + if (this.isEntityAlive() && this.rand.nextInt(1000) < this.livingSoundTime++) + { + this.livingSoundTime = -this.getTalkInterval(); + this.playLivingSound(); + } + + this.worldObj.theProfiler.endSection(); + } + + protected int getExperiencePoints(EntityPlayer par1EntityPlayer) + { + if (this.experienceValue > 0) + { + int i = this.experienceValue; + ItemStack[] aitemstack = this.getLastActiveItems(); + + for (int j = 0; j < aitemstack.length; ++j) + { + if (aitemstack[j] != null && this.equipmentDropChances[j] <= 1.0F) + { + i += 1 + this.rand.nextInt(3); + } + } + + return i; + } + else + { + return this.experienceValue; + } + } + + public void spawnExplosionParticle() + { + for (int i = 0; i < 20; ++i) + { + double d0 = this.rand.nextGaussian() * 0.02D; + double d1 = this.rand.nextGaussian() * 0.02D; + double d2 = this.rand.nextGaussian() * 0.02D; + double d3 = 10.0D; + this.worldObj.spawnParticle("explode", this.posX + (double)(this.rand.nextFloat() * this.width * 2.0F) - (double)this.width - d0 * d3, this.posY + (double)(this.rand.nextFloat() * this.height) - d1 * d3, this.posZ + (double)(this.rand.nextFloat() * this.width * 2.0F) - (double)this.width - d2 * d3, d0, d1, d2); + } + } + + public void onUpdate() + { + super.onUpdate(); + + if (!this.worldObj.isRemote) + { + this.updateLeashedState(); + } + } + + protected float func_110146_f(float par1, float par2) + { + if (this.isAIEnabled()) + { + this.bodyHelper.func_75664_a(); + return par2; + } + else + { + return super.func_110146_f(par1, par2); + } + } + + protected String getLivingSound() + { + return null; + } + + protected Item getDropItem() + { + return Item.getItemById(0); + } + + protected void dropFewItems(boolean par1, int par2) + { + Item item = this.getDropItem(); + + if (item != null) + { + int j = this.rand.nextInt(3); + + if (par2 > 0) + { + j += this.rand.nextInt(par2 + 1); + } + + for (int k = 0; k < j; ++k) + { + this.dropItem(item, 1); + } + } + } + + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeEntityToNBT(par1NBTTagCompound); + par1NBTTagCompound.setBoolean("CanPickUpLoot", this.canPickUpLoot()); + par1NBTTagCompound.setBoolean("PersistenceRequired", this.persistenceRequired); + NBTTagList nbttaglist = new NBTTagList(); + NBTTagCompound nbttagcompound1; + + for (int i = 0; i < this.equipment.length; ++i) + { + nbttagcompound1 = new NBTTagCompound(); + + if (this.equipment[i] != null) + { + this.equipment[i].writeToNBT(nbttagcompound1); + } + + nbttaglist.appendTag(nbttagcompound1); + } + + par1NBTTagCompound.setTag("Equipment", nbttaglist); + NBTTagList nbttaglist1 = new NBTTagList(); + + for (int j = 0; j < this.equipmentDropChances.length; ++j) + { + nbttaglist1.appendTag(new NBTTagFloat(this.equipmentDropChances[j])); + } + + par1NBTTagCompound.setTag("DropChances", nbttaglist1); + par1NBTTagCompound.setString("CustomName", this.getCustomNameTag()); + par1NBTTagCompound.setBoolean("CustomNameVisible", this.getAlwaysRenderNameTag()); + par1NBTTagCompound.setBoolean("Leashed", this.isLeashed); + + if (this.leashedToEntity != null) + { + nbttagcompound1 = new NBTTagCompound(); + + if (this.leashedToEntity instanceof EntityLivingBase) + { + nbttagcompound1.setLong("UUIDMost", this.leashedToEntity.getUniqueID().getMostSignificantBits()); + nbttagcompound1.setLong("UUIDLeast", this.leashedToEntity.getUniqueID().getLeastSignificantBits()); + } + else if (this.leashedToEntity instanceof EntityHanging) + { + EntityHanging entityhanging = (EntityHanging)this.leashedToEntity; + nbttagcompound1.setInteger("X", entityhanging.field_146063_b); + nbttagcompound1.setInteger("Y", entityhanging.field_146064_c); + nbttagcompound1.setInteger("Z", entityhanging.field_146062_d); + } + + par1NBTTagCompound.setTag("Leash", nbttagcompound1); + } + } + + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + super.readEntityFromNBT(par1NBTTagCompound); + this.setCanPickUpLoot(par1NBTTagCompound.getBoolean("CanPickUpLoot")); + this.persistenceRequired = par1NBTTagCompound.getBoolean("PersistenceRequired"); + + if (par1NBTTagCompound.hasKey("CustomName", 8) && par1NBTTagCompound.getString("CustomName").length() > 0) + { + this.setCustomNameTag(par1NBTTagCompound.getString("CustomName")); + } + + this.setAlwaysRenderNameTag(par1NBTTagCompound.getBoolean("CustomNameVisible")); + NBTTagList nbttaglist; + int i; + + if (par1NBTTagCompound.hasKey("Equipment", 9)) + { + nbttaglist = par1NBTTagCompound.getTagList("Equipment", 10); + + for (i = 0; i < this.equipment.length; ++i) + { + this.equipment[i] = ItemStack.loadItemStackFromNBT(nbttaglist.getCompoundTagAt(i)); + } + } + + if (par1NBTTagCompound.hasKey("DropChances", 9)) + { + nbttaglist = par1NBTTagCompound.getTagList("DropChances", 5); + + for (i = 0; i < nbttaglist.tagCount(); ++i) + { + this.equipmentDropChances[i] = nbttaglist.func_150308_e(i); + } + } + + this.isLeashed = par1NBTTagCompound.getBoolean("Leashed"); + + if (this.isLeashed && par1NBTTagCompound.hasKey("Leash", 10)) + { + this.field_110170_bx = par1NBTTagCompound.getCompoundTag("Leash"); + } + } + + public void setMoveForward(float par1) + { + this.moveForward = par1; + } + + public void setAIMoveSpeed(float par1) + { + super.setAIMoveSpeed(par1); + this.setMoveForward(par1); + } + + public void onLivingUpdate() + { + super.onLivingUpdate(); + this.worldObj.theProfiler.startSection("looting"); + + if (!this.worldObj.isRemote && this.canPickUpLoot() && !this.dead && this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing")) + { + List list = this.worldObj.getEntitiesWithinAABB(EntityItem.class, this.boundingBox.expand(1.0D, 0.0D, 1.0D)); + Iterator iterator = list.iterator(); + + while (iterator.hasNext()) + { + EntityItem entityitem = (EntityItem)iterator.next(); + + if (!entityitem.isDead && entityitem.getEntityItem() != null) + { + ItemStack itemstack = entityitem.getEntityItem(); + int i = getArmorPosition(itemstack); + + if (i > -1) + { + boolean flag = true; + ItemStack itemstack1 = this.getEquipmentInSlot(i); + + if (itemstack1 != null) + { + if (i == 0) + { + if (itemstack.getItem() instanceof ItemSword && !(itemstack1.getItem() instanceof ItemSword)) + { + flag = true; + } + else if (itemstack.getItem() instanceof ItemSword && itemstack1.getItem() instanceof ItemSword) + { + ItemSword itemsword = (ItemSword)itemstack.getItem(); + ItemSword itemsword1 = (ItemSword)itemstack1.getItem(); + + if (itemsword.func_150931_i() == itemsword1.func_150931_i()) + { + flag = itemstack.getItemDamage() > itemstack1.getItemDamage() || itemstack.hasTagCompound() && !itemstack1.hasTagCompound(); + } + else + { + flag = itemsword.func_150931_i() > itemsword1.func_150931_i(); + } + } + else + { + flag = false; + } + } + else if (itemstack.getItem() instanceof ItemArmor && !(itemstack1.getItem() instanceof ItemArmor)) + { + flag = true; + } + else if (itemstack.getItem() instanceof ItemArmor && itemstack1.getItem() instanceof ItemArmor) + { + ItemArmor itemarmor = (ItemArmor)itemstack.getItem(); + ItemArmor itemarmor1 = (ItemArmor)itemstack1.getItem(); + + if (itemarmor.damageReduceAmount == itemarmor1.damageReduceAmount) + { + flag = itemstack.getItemDamage() > itemstack1.getItemDamage() || itemstack.hasTagCompound() && !itemstack1.hasTagCompound(); + } + else + { + flag = itemarmor.damageReduceAmount > itemarmor1.damageReduceAmount; + } + } + else + { + flag = false; + } + } + + if (flag) + { + if (itemstack1 != null && this.rand.nextFloat() - 0.1F < this.equipmentDropChances[i]) + { + this.entityDropItem(itemstack1, 0.0F); + } + + if (itemstack.getItem() == Items.diamond && entityitem.func_145800_j() != null) + { + EntityPlayer entityplayer = this.worldObj.getPlayerEntityByName(entityitem.func_145800_j()); + + if (entityplayer != null) + { + entityplayer.triggerAchievement(AchievementList.field_150966_x); + } + } + + this.setCurrentItemOrArmor(i, itemstack); + this.equipmentDropChances[i] = 2.0F; + this.persistenceRequired = true; + this.onItemPickup(entityitem, 1); + entityitem.setDead(); + } + } + } + } + } + + this.worldObj.theProfiler.endSection(); + } + + protected boolean isAIEnabled() + { + return false; + } + + protected boolean canDespawn() + { + return true; + } + + protected void despawnEntity() + { + Result result = null; + if (this.persistenceRequired) + { + this.entityAge = 0; + } + else if ((this.entityAge & 0x1F) == 0x1F && (result = ForgeEventFactory.canEntityDespawn(this)) != Result.DEFAULT) + { + if (result == Result.DENY) + { + this.entityAge = 0; + } + else + { + this.setDead(); + } + } + else + { + EntityPlayer entityplayer = this.worldObj.getClosestPlayerToEntity(this, -1.0D); + + if (entityplayer != null) + { + double d0 = entityplayer.posX - this.posX; + double d1 = entityplayer.posY - this.posY; + double d2 = entityplayer.posZ - this.posZ; + double d3 = d0 * d0 + d1 * d1 + d2 * d2; + + if (this.canDespawn() && d3 > 16384.0D) + { + this.setDead(); + } + + if (this.entityAge > 600 && this.rand.nextInt(800) == 0 && d3 > 1024.0D && this.canDespawn()) + { + this.setDead(); + } + else if (d3 < 1024.0D) + { + this.entityAge = 0; + } + } + } + } + + protected void updateAITasks() + { + ++this.entityAge; + this.worldObj.theProfiler.startSection("checkDespawn"); + this.despawnEntity(); + this.worldObj.theProfiler.endSection(); + this.worldObj.theProfiler.startSection("sensing"); + this.senses.clearSensingCache(); + this.worldObj.theProfiler.endSection(); + this.worldObj.theProfiler.startSection("targetSelector"); + this.targetTasks.onUpdateTasks(); + this.worldObj.theProfiler.endSection(); + this.worldObj.theProfiler.startSection("goalSelector"); + this.tasks.onUpdateTasks(); + this.worldObj.theProfiler.endSection(); + this.worldObj.theProfiler.startSection("navigation"); + this.navigator.onUpdateNavigation(); + this.worldObj.theProfiler.endSection(); + this.worldObj.theProfiler.startSection("mob tick"); + this.updateAITick(); + this.worldObj.theProfiler.endSection(); + this.worldObj.theProfiler.startSection("controls"); + this.worldObj.theProfiler.startSection("move"); + this.moveHelper.onUpdateMoveHelper(); + this.worldObj.theProfiler.endStartSection("look"); + this.lookHelper.onUpdateLook(); + this.worldObj.theProfiler.endStartSection("jump"); + this.jumpHelper.doJump(); + this.worldObj.theProfiler.endSection(); + this.worldObj.theProfiler.endSection(); + } + + protected void updateEntityActionState() + { + super.updateEntityActionState(); + this.moveStrafing = 0.0F; + this.moveForward = 0.0F; + this.despawnEntity(); + float f = 8.0F; + + if (this.rand.nextFloat() < 0.02F) + { + EntityPlayer entityplayer = this.worldObj.getClosestPlayerToEntity(this, (double)f); + + if (entityplayer != null) + { + this.currentTarget = entityplayer; + this.numTicksToChaseTarget = 10 + this.rand.nextInt(20); + } + else + { + this.randomYawVelocity = (this.rand.nextFloat() - 0.5F) * 20.0F; + } + } + + if (this.currentTarget != null) + { + this.faceEntity(this.currentTarget, 10.0F, (float)this.getVerticalFaceSpeed()); + + if (this.numTicksToChaseTarget-- <= 0 || this.currentTarget.isDead || this.currentTarget.getDistanceSqToEntity(this) > (double)(f * f)) + { + this.currentTarget = null; + } + } + else + { + if (this.rand.nextFloat() < 0.05F) + { + this.randomYawVelocity = (this.rand.nextFloat() - 0.5F) * 20.0F; + } + + this.rotationYaw += this.randomYawVelocity; + this.rotationPitch = this.defaultPitch; + } + + boolean flag1 = this.isInWater(); + boolean flag = this.handleLavaMovement(); + + if (flag1 || flag) + { + this.isJumping = this.rand.nextFloat() < 0.8F; + } + } + + public int getVerticalFaceSpeed() + { + return 40; + } + + public void faceEntity(Entity par1Entity, float par2, float par3) + { + double d0 = par1Entity.posX - this.posX; + double d2 = par1Entity.posZ - this.posZ; + double d1; + + if (par1Entity instanceof EntityLivingBase) + { + EntityLivingBase entitylivingbase = (EntityLivingBase)par1Entity; + d1 = entitylivingbase.posY + (double)entitylivingbase.getEyeHeight() - (this.posY + (double)this.getEyeHeight()); + } + else + { + d1 = (par1Entity.boundingBox.minY + par1Entity.boundingBox.maxY) / 2.0D - (this.posY + (double)this.getEyeHeight()); + } + + double d3 = (double)MathHelper.sqrt_double(d0 * d0 + d2 * d2); + float f2 = (float)(Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F; + float f3 = (float)(-(Math.atan2(d1, d3) * 180.0D / Math.PI)); + this.rotationPitch = this.updateRotation(this.rotationPitch, f3, par3); + this.rotationYaw = this.updateRotation(this.rotationYaw, f2, par2); + } + + private float updateRotation(float par1, float par2, float par3) + { + float f3 = MathHelper.wrapAngleTo180_float(par2 - par1); + + if (f3 > par3) + { + f3 = par3; + } + + if (f3 < -par3) + { + f3 = -par3; + } + + return par1 + f3; + } + + public boolean getCanSpawnHere() + { + return this.worldObj.checkNoEntityCollision(this.boundingBox) && this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox).isEmpty() && !this.worldObj.isAnyLiquid(this.boundingBox); + } + + public float getRenderSizeModifier() + { + return 1.0F; + } + + public int getMaxSpawnedInChunk() + { + return 4; + } + + public int getMaxSafePointTries() + { + if (this.getAttackTarget() == null) + { + return 3; + } + else + { + int i = (int)(this.getHealth() - this.getMaxHealth() * 0.33F); + i -= (3 - this.worldObj.difficultySetting.getDifficultyId()) * 4; + + if (i < 0) + { + i = 0; + } + + return i + 3; + } + } + + public ItemStack getHeldItem() + { + return this.equipment[0]; + } + + public ItemStack getEquipmentInSlot(int par1) + { + return this.equipment[par1]; + } + + public ItemStack func_130225_q(int par1) + { + return this.equipment[par1 + 1]; + } + + public void setCurrentItemOrArmor(int par1, ItemStack par2ItemStack) + { + this.equipment[par1] = par2ItemStack; + } + + public ItemStack[] getLastActiveItems() + { + return this.equipment; + } + + protected void dropEquipment(boolean par1, int par2) + { + for (int j = 0; j < this.getLastActiveItems().length; ++j) + { + ItemStack itemstack = this.getEquipmentInSlot(j); + boolean flag1 = this.equipmentDropChances[j] > 1.0F; + + if (itemstack != null && (par1 || flag1) && this.rand.nextFloat() - (float)par2 * 0.01F < this.equipmentDropChances[j]) + { + if (!flag1 && itemstack.isItemStackDamageable()) + { + int k = Math.max(itemstack.getMaxDamage() - 25, 1); + int l = itemstack.getMaxDamage() - this.rand.nextInt(this.rand.nextInt(k) + 1); + + if (l > k) + { + l = k; + } + + if (l < 1) + { + l = 1; + } + + itemstack.setItemDamage(l); + } + + this.entityDropItem(itemstack, 0.0F); + } + } + } + + protected void addRandomArmor() + { + if (this.rand.nextFloat() < 0.15F * this.worldObj.func_147462_b(this.posX, this.posY, this.posZ)) + { + int i = this.rand.nextInt(2); + float f = this.worldObj.difficultySetting == EnumDifficulty.HARD ? 0.1F : 0.25F; + + if (this.rand.nextFloat() < 0.095F) + { + ++i; + } + + if (this.rand.nextFloat() < 0.095F) + { + ++i; + } + + if (this.rand.nextFloat() < 0.095F) + { + ++i; + } + + for (int j = 3; j >= 0; --j) + { + ItemStack itemstack = this.func_130225_q(j); + + if (j < 3 && this.rand.nextFloat() < f) + { + break; + } + + if (itemstack == null) + { + Item item = getArmorItemForSlot(j + 1, i); + + if (item != null) + { + this.setCurrentItemOrArmor(j + 1, new ItemStack(item)); + } + } + } + } + } + + public static int getArmorPosition(ItemStack par0ItemStack) + { + if (par0ItemStack.getItem() != Item.getItemFromBlock(Blocks.pumpkin) && par0ItemStack.getItem() != Items.skull) + { + if (par0ItemStack.getItem() instanceof ItemArmor) + { + switch (((ItemArmor)par0ItemStack.getItem()).armorType) + { + case 0: + return 4; + case 1: + return 3; + case 2: + return 2; + case 3: + return 1; + } + } + + return 0; + } + else + { + return 4; + } + } + + public static Item getArmorItemForSlot(int par0, int par1) + { + switch (par0) + { + case 4: + if (par1 == 0) + { + return Items.leather_helmet; + } + else if (par1 == 1) + { + return Items.golden_helmet; + } + else if (par1 == 2) + { + return Items.chainmail_helmet; + } + else if (par1 == 3) + { + return Items.iron_helmet; + } + else if (par1 == 4) + { + return Items.diamond_helmet; + } + case 3: + if (par1 == 0) + { + return Items.leather_chestplate; + } + else if (par1 == 1) + { + return Items.golden_chestplate; + } + else if (par1 == 2) + { + return Items.chainmail_chestplate; + } + else if (par1 == 3) + { + return Items.iron_chestplate; + } + else if (par1 == 4) + { + return Items.diamond_chestplate; + } + case 2: + if (par1 == 0) + { + return Items.leather_leggings; + } + else if (par1 == 1) + { + return Items.golden_leggings; + } + else if (par1 == 2) + { + return Items.chainmail_leggings; + } + else if (par1 == 3) + { + return Items.iron_leggings; + } + else if (par1 == 4) + { + return Items.diamond_leggings; + } + case 1: + if (par1 == 0) + { + return Items.leather_boots; + } + else if (par1 == 1) + { + return Items.golden_boots; + } + else if (par1 == 2) + { + return Items.chainmail_boots; + } + else if (par1 == 3) + { + return Items.iron_boots; + } + else if (par1 == 4) + { + return Items.diamond_boots; + } + default: + return null; + } + } + + protected void enchantEquipment() + { + float f = this.worldObj.func_147462_b(this.posX, this.posY, this.posZ); + + if (this.getHeldItem() != null && this.rand.nextFloat() < 0.25F * f) + { + EnchantmentHelper.addRandomEnchantment(this.rand, this.getHeldItem(), (int)(5.0F + f * (float)this.rand.nextInt(18))); + } + + for (int i = 0; i < 4; ++i) + { + ItemStack itemstack = this.func_130225_q(i); + + if (itemstack != null && this.rand.nextFloat() < 0.5F * f) + { + EnchantmentHelper.addRandomEnchantment(this.rand, itemstack, (int)(5.0F + f * (float)this.rand.nextInt(18))); + } + } + } + + public IEntityLivingData onSpawnWithEgg(IEntityLivingData par1EntityLivingData) + { + this.getEntityAttribute(SharedMonsterAttributes.followRange).applyModifier(new AttributeModifier("Random spawn bonus", this.rand.nextGaussian() * 0.05D, 1)); + return par1EntityLivingData; + } + + public boolean canBeSteered() + { + return false; + } + + public String getCommandSenderName() + { + return this.hasCustomNameTag() ? this.getCustomNameTag() : super.getCommandSenderName(); + } + + public void func_110163_bv() + { + this.persistenceRequired = true; + } + + public void setCustomNameTag(String par1Str) + { + this.dataWatcher.updateObject(10, par1Str); + } + + public String getCustomNameTag() + { + return this.dataWatcher.getWatchableObjectString(10); + } + + public boolean hasCustomNameTag() + { + return this.dataWatcher.getWatchableObjectString(10).length() > 0; + } + + public void setAlwaysRenderNameTag(boolean par1) + { + this.dataWatcher.updateObject(11, Byte.valueOf((byte)(par1 ? 1 : 0))); + } + + public boolean getAlwaysRenderNameTag() + { + return this.dataWatcher.getWatchableObjectByte(11) == 1; + } + + @SideOnly(Side.CLIENT) + public boolean getAlwaysRenderNameTagForRender() + { + return this.getAlwaysRenderNameTag(); + } + + public void setEquipmentDropChance(int par1, float par2) + { + this.equipmentDropChances[par1] = par2; + } + + public boolean canPickUpLoot() + { + return this.canPickUpLoot; + } + + public void setCanPickUpLoot(boolean par1) + { + this.canPickUpLoot = par1; + } + + public boolean isNoDespawnRequired() + { + return this.persistenceRequired; + } + + public final boolean interactFirst(EntityPlayer par1EntityPlayer) + { + if (this.getLeashed() && this.getLeashedToEntity() == par1EntityPlayer) + { + this.clearLeashed(true, !par1EntityPlayer.capabilities.isCreativeMode); + return true; + } + else + { + ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem(); + + if (itemstack != null && itemstack.getItem() == Items.lead && this.allowLeashing()) + { + if (!(this instanceof EntityTameable) || !((EntityTameable)this).isTamed()) + { + this.setLeashedToEntity(par1EntityPlayer, true); + --itemstack.stackSize; + return true; + } + + if (par1EntityPlayer.getCommandSenderName().equalsIgnoreCase(((EntityTameable)this).getOwnerName())) + { + this.setLeashedToEntity(par1EntityPlayer, true); + --itemstack.stackSize; + return true; + } + } + + return this.interact(par1EntityPlayer) ? true : super.interactFirst(par1EntityPlayer); + } + } + + protected boolean interact(EntityPlayer par1EntityPlayer) + { + return false; + } + + protected void updateLeashedState() + { + if (this.field_110170_bx != null) + { + this.recreateLeash(); + } + + if (this.isLeashed) + { + if (this.leashedToEntity == null || this.leashedToEntity.isDead) + { + this.clearLeashed(true, true); + } + } + } + + public void clearLeashed(boolean par1, boolean par2) + { + if (this.isLeashed) + { + this.isLeashed = false; + this.leashedToEntity = null; + + if (!this.worldObj.isRemote && par2) + { + this.dropItem(Items.lead, 1); + } + + if (!this.worldObj.isRemote && par1 && this.worldObj instanceof WorldServer) + { + ((WorldServer)this.worldObj).getEntityTracker().func_151247_a(this, new S1BPacketEntityAttach(1, this, (Entity)null)); + } + } + } + + public boolean allowLeashing() + { + return !this.getLeashed() && !(this instanceof IMob); + } + + public boolean getLeashed() + { + return this.isLeashed; + } + + public Entity getLeashedToEntity() + { + return this.leashedToEntity; + } + + public void setLeashedToEntity(Entity par1Entity, boolean par2) + { + this.isLeashed = true; + this.leashedToEntity = par1Entity; + + if (!this.worldObj.isRemote && par2 && this.worldObj instanceof WorldServer) + { + ((WorldServer)this.worldObj).getEntityTracker().func_151247_a(this, new S1BPacketEntityAttach(1, this, this.leashedToEntity)); + } + } + + private void recreateLeash() + { + if (this.isLeashed && this.field_110170_bx != null) + { + if (this.field_110170_bx.hasKey("UUIDMost", 4) && this.field_110170_bx.hasKey("UUIDLeast", 4)) + { + UUID uuid = new UUID(this.field_110170_bx.getLong("UUIDMost"), this.field_110170_bx.getLong("UUIDLeast")); + List list = this.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, this.boundingBox.expand(10.0D, 10.0D, 10.0D)); + Iterator iterator = list.iterator(); + + while (iterator.hasNext()) + { + EntityLivingBase entitylivingbase = (EntityLivingBase)iterator.next(); + + if (entitylivingbase.getUniqueID().equals(uuid)) + { + this.leashedToEntity = entitylivingbase; + break; + } + } + } + else if (this.field_110170_bx.hasKey("X", 99) && this.field_110170_bx.hasKey("Y", 99) && this.field_110170_bx.hasKey("Z", 99)) + { + int i = this.field_110170_bx.getInteger("X"); + int j = this.field_110170_bx.getInteger("Y"); + int k = this.field_110170_bx.getInteger("Z"); + EntityLeashKnot entityleashknot = EntityLeashKnot.getKnotForBlock(this.worldObj, i, j, k); + + if (entityleashknot == null) + { + entityleashknot = EntityLeashKnot.func_110129_a(this.worldObj, i, j, k); + } + + this.leashedToEntity = entityleashknot; + } + else + { + this.clearLeashed(false, true); + } + } + + this.field_110170_bx = null; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/EntityLivingBase.java b/src/main/java/net/minecraft/entity/EntityLivingBase.java new file mode 100644 index 0000000..5166f50 --- /dev/null +++ b/src/main/java/net/minecraft/entity/EntityLivingBase.java @@ -0,0 +1,2076 @@ +package net.minecraft.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import java.util.UUID; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.ai.attributes.AttributeModifier; +import net.minecraft.entity.ai.attributes.BaseAttributeMap; +import net.minecraft.entity.ai.attributes.IAttribute; +import net.minecraft.entity.ai.attributes.IAttributeInstance; +import net.minecraft.entity.ai.attributes.ServersideAttributeMap; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.item.EntityXPOrb; +import net.minecraft.entity.monster.EntityZombie; +import net.minecraft.entity.passive.EntityPig; +import net.minecraft.entity.passive.EntityWolf; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemArmor; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagFloat; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.nbt.NBTTagShort; +import net.minecraft.network.play.server.S04PacketEntityEquipment; +import net.minecraft.network.play.server.S0BPacketAnimation; +import net.minecraft.network.play.server.S0DPacketCollectItem; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.potion.PotionHelper; +import net.minecraft.scoreboard.Team; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.CombatTracker; +import net.minecraft.util.DamageSource; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; +import net.minecraft.world.WorldServer; +import net.minecraftforge.common.ForgeHooks; + +public abstract class EntityLivingBase extends Entity +{ + private static final UUID sprintingSpeedBoostModifierUUID = UUID.fromString("662A6B8D-DA3E-4C1C-8813-96EA6097278D"); + private static final AttributeModifier sprintingSpeedBoostModifier = (new AttributeModifier(sprintingSpeedBoostModifierUUID, "Sprinting speed boost", 0.30000001192092896D, 2)).setSaved(false); + private BaseAttributeMap attributeMap; + private final CombatTracker _combatTracker = new CombatTracker(this); + private final HashMap activePotionsMap = new HashMap(); + private final ItemStack[] previousEquipment = new ItemStack[5]; + public boolean isSwingInProgress; + public int swingProgressInt; + public int arrowHitTimer; + public float prevHealth; + public int hurtTime; + public int maxHurtTime; + public float attackedAtYaw; + public int deathTime; + public int attackTime; + public float prevSwingProgress; + public float swingProgress; + public float prevLimbSwingAmount; + public float limbSwingAmount; + public float limbSwing; + public int maxHurtResistantTime = 20; + public float prevCameraPitch; + public float cameraPitch; + public float field_70769_ao; + public float field_70770_ap; + public float renderYawOffset; + public float prevRenderYawOffset; + public float rotationYawHead; + public float prevRotationYawHead; + public float jumpMovementFactor = 0.02F; + protected EntityPlayer attackingPlayer; + protected int recentlyHit; + protected boolean dead; + protected int entityAge; + protected float field_70768_au; + protected float field_110154_aX; + protected float field_70764_aw; + protected float field_70763_ax; + protected float field_70741_aB; + protected int scoreValue; + protected float lastDamage; + protected boolean isJumping; + public float moveStrafing; + public float moveForward; + protected float randomYawVelocity; + protected int newPosRotationIncrements; + protected double newPosX; + protected double newPosY; + protected double newPosZ; + protected double newRotationYaw; + protected double newRotationPitch; + private boolean potionsNeedUpdate = true; + private EntityLivingBase entityLivingToAttack; + private int revengeTimer; + private EntityLivingBase lastAttacker; + private int lastAttackerTime; + private float landMovementFactor; + private int jumpTicks; + private float field_110151_bq; + private static final String __OBFID = "CL_00001549"; + + public EntityLivingBase(World par1World) + { + super(par1World); + this.applyEntityAttributes(); + this.setHealth(this.getMaxHealth()); + this.preventEntitySpawning = true; + this.field_70770_ap = (float)(Math.random() + 1.0D) * 0.01F; + this.setPosition(this.posX, this.posY, this.posZ); + this.field_70769_ao = (float)Math.random() * 12398.0F; + this.rotationYaw = (float)(Math.random() * Math.PI * 2.0D); + this.rotationYawHead = this.rotationYaw; + this.stepHeight = 0.5F; + } + + protected void entityInit() + { + this.dataWatcher.addObject(7, Integer.valueOf(0)); + this.dataWatcher.addObject(8, Byte.valueOf((byte)0)); + this.dataWatcher.addObject(9, Byte.valueOf((byte)0)); + this.dataWatcher.addObject(6, Float.valueOf(1.0F)); + } + + protected void applyEntityAttributes() + { + this.getAttributeMap().registerAttribute(SharedMonsterAttributes.maxHealth); + this.getAttributeMap().registerAttribute(SharedMonsterAttributes.knockbackResistance); + this.getAttributeMap().registerAttribute(SharedMonsterAttributes.movementSpeed); + + if (!this.isAIEnabled()) + { + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.10000000149011612D); + } + } + + protected void updateFallState(double par1, boolean par3) + { + if (!this.isInWater()) + { + this.handleWaterMovement(); + } + + if (par3 && this.fallDistance > 0.0F) + { + int i = MathHelper.floor_double(this.posX); + int j = MathHelper.floor_double(this.posY - 0.20000000298023224D - (double)this.yOffset); + int k = MathHelper.floor_double(this.posZ); + Block block = this.worldObj.getBlock(i, j, k); + + if (block.getMaterial() == Material.air) + { + int l = this.worldObj.getBlock(i, j - 1, k).getRenderType(); + + if (l == 11 || l == 32 || l == 21) + { + block = this.worldObj.getBlock(i, j - 1, k); + } + } + else if (!this.worldObj.isRemote && this.fallDistance > 3.0F) + { + this.worldObj.playAuxSFX(2006, i, j, k, MathHelper.ceiling_float_int(this.fallDistance - 3.0F)); + } + + block.onFallenUpon(this.worldObj, i, j, k, this, this.fallDistance); + } + + super.updateFallState(par1, par3); + } + + public boolean canBreatheUnderwater() + { + return false; + } + + public void onEntityUpdate() + { + this.prevSwingProgress = this.swingProgress; + super.onEntityUpdate(); + this.worldObj.theProfiler.startSection("livingEntityBaseTick"); + + if (this.isEntityAlive() && this.isEntityInsideOpaqueBlock()) + { + this.attackEntityFrom(DamageSource.inWall, 1.0F); + } + + if (this.isImmuneToFire() || this.worldObj.isRemote) + { + this.extinguish(); + } + + boolean flag = this instanceof EntityPlayer && ((EntityPlayer)this).capabilities.disableDamage; + + if (this.isEntityAlive() && this.isInsideOfMaterial(Material.water)) + { + if (!this.canBreatheUnderwater() && !this.isPotionActive(Potion.waterBreathing.id) && !flag) + { + this.setAir(this.decreaseAirSupply(this.getAir())); + + if (this.getAir() == -20) + { + this.setAir(0); + + for (int i = 0; i < 8; ++i) + { + float f = this.rand.nextFloat() - this.rand.nextFloat(); + float f1 = this.rand.nextFloat() - this.rand.nextFloat(); + float f2 = this.rand.nextFloat() - this.rand.nextFloat(); + this.worldObj.spawnParticle("bubble", this.posX + (double)f, this.posY + (double)f1, this.posZ + (double)f2, this.motionX, this.motionY, this.motionZ); + } + + this.attackEntityFrom(DamageSource.drown, 2.0F); + } + } + + if (!this.worldObj.isRemote && this.isRiding() && this.ridingEntity != null && ridingEntity.shouldDismountInWater(this)) + { + this.mountEntity((Entity)null); + } + } + else + { + this.setAir(300); + } + + if (this.isEntityAlive() && this.isWet()) + { + this.extinguish(); + } + + this.prevCameraPitch = this.cameraPitch; + + if (this.attackTime > 0) + { + --this.attackTime; + } + + if (this.hurtTime > 0) + { + --this.hurtTime; + } + + if (this.hurtResistantTime > 0 && !(this instanceof EntityPlayerMP)) + { + --this.hurtResistantTime; + } + + if (this.getHealth() <= 0.0F) + { + this.onDeathUpdate(); + } + + if (this.recentlyHit > 0) + { + --this.recentlyHit; + } + else + { + this.attackingPlayer = null; + } + + if (this.lastAttacker != null && !this.lastAttacker.isEntityAlive()) + { + this.lastAttacker = null; + } + + if (this.entityLivingToAttack != null) + { + if (!this.entityLivingToAttack.isEntityAlive()) + { + this.setRevengeTarget((EntityLivingBase)null); + } + else if (this.ticksExisted - this.revengeTimer > 100) + { + this.setRevengeTarget((EntityLivingBase)null); + } + } + + this.updatePotionEffects(); + this.field_70763_ax = this.field_70764_aw; + this.prevRenderYawOffset = this.renderYawOffset; + this.prevRotationYawHead = this.rotationYawHead; + this.prevRotationYaw = this.rotationYaw; + this.prevRotationPitch = this.rotationPitch; + this.worldObj.theProfiler.endSection(); + } + + public boolean isChild() + { + return false; + } + + protected void onDeathUpdate() + { + ++this.deathTime; + + if (this.deathTime == 20) + { + int i; + + if (!this.worldObj.isRemote && (this.recentlyHit > 0 || this.isPlayer()) && this.func_146066_aG() && this.worldObj.getGameRules().getGameRuleBooleanValue("doMobLoot")) + { + i = this.getExperiencePoints(this.attackingPlayer); + + while (i > 0) + { + int j = EntityXPOrb.getXPSplit(i); + i -= j; + this.worldObj.spawnEntityInWorld(new EntityXPOrb(this.worldObj, this.posX, this.posY, this.posZ, j)); + } + } + + this.setDead(); + + for (i = 0; i < 20; ++i) + { + double d2 = this.rand.nextGaussian() * 0.02D; + double d0 = this.rand.nextGaussian() * 0.02D; + double d1 = this.rand.nextGaussian() * 0.02D; + this.worldObj.spawnParticle("explode", this.posX + (double)(this.rand.nextFloat() * this.width * 2.0F) - (double)this.width, this.posY + (double)(this.rand.nextFloat() * this.height), this.posZ + (double)(this.rand.nextFloat() * this.width * 2.0F) - (double)this.width, d2, d0, d1); + } + } + } + + protected boolean func_146066_aG() + { + return !this.isChild(); + } + + protected int decreaseAirSupply(int par1) + { + int j = EnchantmentHelper.getRespiration(this); + return j > 0 && this.rand.nextInt(j + 1) > 0 ? par1 : par1 - 1; + } + + protected int getExperiencePoints(EntityPlayer par1EntityPlayer) + { + return 0; + } + + protected boolean isPlayer() + { + return false; + } + + public Random getRNG() + { + return this.rand; + } + + public EntityLivingBase getAITarget() + { + return this.entityLivingToAttack; + } + + public int func_142015_aE() + { + return this.revengeTimer; + } + + public void setRevengeTarget(EntityLivingBase par1EntityLivingBase) + { + this.entityLivingToAttack = par1EntityLivingBase; + this.revengeTimer = this.ticksExisted; + ForgeHooks.onLivingSetAttackTarget(this, par1EntityLivingBase); + } + + public EntityLivingBase getLastAttacker() + { + return this.lastAttacker; + } + + public int getLastAttackerTime() + { + return this.lastAttackerTime; + } + + public void setLastAttacker(Entity par1Entity) + { + if (par1Entity instanceof EntityLivingBase) + { + this.lastAttacker = (EntityLivingBase)par1Entity; + } + else + { + this.lastAttacker = null; + } + + this.lastAttackerTime = this.ticksExisted; + } + + public int getAge() + { + return this.entityAge; + } + + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + par1NBTTagCompound.setFloat("HealF", this.getHealth()); + par1NBTTagCompound.setShort("Health", (short)((int)Math.ceil((double)this.getHealth()))); + par1NBTTagCompound.setShort("HurtTime", (short)this.hurtTime); + par1NBTTagCompound.setShort("DeathTime", (short)this.deathTime); + par1NBTTagCompound.setShort("AttackTime", (short)this.attackTime); + par1NBTTagCompound.setFloat("AbsorptionAmount", this.getAbsorptionAmount()); + ItemStack[] aitemstack = this.getLastActiveItems(); + int i = aitemstack.length; + int j; + ItemStack itemstack; + + for (j = 0; j < i; ++j) + { + itemstack = aitemstack[j]; + + if (itemstack != null) + { + this.attributeMap.removeAttributeModifiers(itemstack.getAttributeModifiers()); + } + } + + par1NBTTagCompound.setTag("Attributes", SharedMonsterAttributes.writeBaseAttributeMapToNBT(this.getAttributeMap())); + aitemstack = this.getLastActiveItems(); + i = aitemstack.length; + + for (j = 0; j < i; ++j) + { + itemstack = aitemstack[j]; + + if (itemstack != null) + { + this.attributeMap.applyAttributeModifiers(itemstack.getAttributeModifiers()); + } + } + + if (!this.activePotionsMap.isEmpty()) + { + NBTTagList nbttaglist = new NBTTagList(); + Iterator iterator = this.activePotionsMap.values().iterator(); + + while (iterator.hasNext()) + { + PotionEffect potioneffect = (PotionEffect)iterator.next(); + nbttaglist.appendTag(potioneffect.writeCustomPotionEffectToNBT(new NBTTagCompound())); + } + + par1NBTTagCompound.setTag("ActiveEffects", nbttaglist); + } + } + + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + this.setAbsorptionAmount(par1NBTTagCompound.getFloat("AbsorptionAmount")); + + if (par1NBTTagCompound.hasKey("Attributes", 9) && this.worldObj != null && !this.worldObj.isRemote) + { + SharedMonsterAttributes.func_151475_a(this.getAttributeMap(), par1NBTTagCompound.getTagList("Attributes", 10)); + } + + if (par1NBTTagCompound.hasKey("ActiveEffects", 9)) + { + NBTTagList nbttaglist = par1NBTTagCompound.getTagList("ActiveEffects", 10); + + for (int i = 0; i < nbttaglist.tagCount(); ++i) + { + NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); + PotionEffect potioneffect = PotionEffect.readCustomPotionEffectFromNBT(nbttagcompound1); + + if (potioneffect != null) + { + this.activePotionsMap.put(Integer.valueOf(potioneffect.getPotionID()), potioneffect); + } + } + } + + if (par1NBTTagCompound.hasKey("HealF", 99)) + { + this.setHealth(par1NBTTagCompound.getFloat("HealF")); + } + else + { + NBTBase nbtbase = par1NBTTagCompound.getTag("Health"); + + if (nbtbase == null) + { + this.setHealth(this.getMaxHealth()); + } + else if (nbtbase.getId() == 5) + { + this.setHealth(((NBTTagFloat)nbtbase).func_150288_h()); + } + else if (nbtbase.getId() == 2) + { + this.setHealth((float)((NBTTagShort)nbtbase).func_150289_e()); + } + } + + this.hurtTime = par1NBTTagCompound.getShort("HurtTime"); + this.deathTime = par1NBTTagCompound.getShort("DeathTime"); + this.attackTime = par1NBTTagCompound.getShort("AttackTime"); + } + + protected void updatePotionEffects() + { + Iterator iterator = this.activePotionsMap.keySet().iterator(); + + while (iterator.hasNext()) + { + Integer integer = (Integer)iterator.next(); + PotionEffect potioneffect = (PotionEffect)this.activePotionsMap.get(integer); + + if (!potioneffect.onUpdate(this)) + { + if (!this.worldObj.isRemote) + { + iterator.remove(); + this.onFinishedPotionEffect(potioneffect); + } + } + else if (potioneffect.getDuration() % 600 == 0) + { + this.onChangedPotionEffect(potioneffect, false); + } + } + + int i; + + if (this.potionsNeedUpdate) + { + if (!this.worldObj.isRemote) + { + if (this.activePotionsMap.isEmpty()) + { + this.dataWatcher.updateObject(8, Byte.valueOf((byte)0)); + this.dataWatcher.updateObject(7, Integer.valueOf(0)); + this.setInvisible(false); + } + else + { + i = PotionHelper.calcPotionLiquidColor(this.activePotionsMap.values()); + this.dataWatcher.updateObject(8, Byte.valueOf((byte)(PotionHelper.func_82817_b(this.activePotionsMap.values()) ? 1 : 0))); + this.dataWatcher.updateObject(7, Integer.valueOf(i)); + this.setInvisible(this.isPotionActive(Potion.invisibility.id)); + } + } + + this.potionsNeedUpdate = false; + } + + i = this.dataWatcher.getWatchableObjectInt(7); + boolean flag1 = this.dataWatcher.getWatchableObjectByte(8) > 0; + + if (i > 0) + { + boolean flag = false; + + if (!this.isInvisible()) + { + flag = this.rand.nextBoolean(); + } + else + { + flag = this.rand.nextInt(15) == 0; + } + + if (flag1) + { + flag &= this.rand.nextInt(5) == 0; + } + + if (flag && i > 0) + { + double d0 = (double)(i >> 16 & 255) / 255.0D; + double d1 = (double)(i >> 8 & 255) / 255.0D; + double d2 = (double)(i >> 0 & 255) / 255.0D; + this.worldObj.spawnParticle(flag1 ? "mobSpellAmbient" : "mobSpell", this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, this.posY + this.rand.nextDouble() * (double)this.height - (double)this.yOffset, this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, d0, d1, d2); + } + } + } + + public void clearActivePotions() + { + Iterator iterator = this.activePotionsMap.keySet().iterator(); + + while (iterator.hasNext()) + { + Integer integer = (Integer)iterator.next(); + PotionEffect potioneffect = (PotionEffect)this.activePotionsMap.get(integer); + + if (!this.worldObj.isRemote) + { + iterator.remove(); + this.onFinishedPotionEffect(potioneffect); + } + } + } + + public Collection getActivePotionEffects() + { + return this.activePotionsMap.values(); + } + + public boolean isPotionActive(int par1) + { + return this.activePotionsMap.containsKey(Integer.valueOf(par1)); + } + + public boolean isPotionActive(Potion par1Potion) + { + return this.activePotionsMap.containsKey(Integer.valueOf(par1Potion.id)); + } + + public PotionEffect getActivePotionEffect(Potion par1Potion) + { + return (PotionEffect)this.activePotionsMap.get(Integer.valueOf(par1Potion.id)); + } + + public void addPotionEffect(PotionEffect par1PotionEffect) + { + if (this.isPotionApplicable(par1PotionEffect)) + { + if (this.activePotionsMap.containsKey(Integer.valueOf(par1PotionEffect.getPotionID()))) + { + ((PotionEffect)this.activePotionsMap.get(Integer.valueOf(par1PotionEffect.getPotionID()))).combine(par1PotionEffect); + this.onChangedPotionEffect((PotionEffect)this.activePotionsMap.get(Integer.valueOf(par1PotionEffect.getPotionID())), true); + } + else + { + this.activePotionsMap.put(Integer.valueOf(par1PotionEffect.getPotionID()), par1PotionEffect); + this.onNewPotionEffect(par1PotionEffect); + } + } + } + + public boolean isPotionApplicable(PotionEffect par1PotionEffect) + { + if (this.getCreatureAttribute() == EnumCreatureAttribute.UNDEAD) + { + int i = par1PotionEffect.getPotionID(); + + if (i == Potion.regeneration.id || i == Potion.poison.id) + { + return false; + } + } + + return true; + } + + public boolean isEntityUndead() + { + return this.getCreatureAttribute() == EnumCreatureAttribute.UNDEAD; + } + + public void removePotionEffectClient(int par1) + { + this.activePotionsMap.remove(Integer.valueOf(par1)); + } + + public void removePotionEffect(int par1) + { + PotionEffect potioneffect = (PotionEffect)this.activePotionsMap.remove(Integer.valueOf(par1)); + + if (potioneffect != null) + { + this.onFinishedPotionEffect(potioneffect); + } + } + + protected void onNewPotionEffect(PotionEffect par1PotionEffect) + { + this.potionsNeedUpdate = true; + + if (!this.worldObj.isRemote) + { + Potion.potionTypes[par1PotionEffect.getPotionID()].applyAttributesModifiersToEntity(this, this.getAttributeMap(), par1PotionEffect.getAmplifier()); + } + } + + protected void onChangedPotionEffect(PotionEffect par1PotionEffect, boolean par2) + { + this.potionsNeedUpdate = true; + + if (par2 && !this.worldObj.isRemote) + { + Potion.potionTypes[par1PotionEffect.getPotionID()].removeAttributesModifiersFromEntity(this, this.getAttributeMap(), par1PotionEffect.getAmplifier()); + Potion.potionTypes[par1PotionEffect.getPotionID()].applyAttributesModifiersToEntity(this, this.getAttributeMap(), par1PotionEffect.getAmplifier()); + } + } + + protected void onFinishedPotionEffect(PotionEffect par1PotionEffect) + { + this.potionsNeedUpdate = true; + + if (!this.worldObj.isRemote) + { + Potion.potionTypes[par1PotionEffect.getPotionID()].removeAttributesModifiersFromEntity(this, this.getAttributeMap(), par1PotionEffect.getAmplifier()); + } + } + + public void heal(float par1) + { + float f1 = this.getHealth(); + + if (f1 > 0.0F) + { + this.setHealth(f1 + par1); + } + } + + public final float getHealth() + { + return this.dataWatcher.getWatchableObjectFloat(6); + } + + public void setHealth(float par1) + { + this.dataWatcher.updateObject(6, Float.valueOf(MathHelper.clamp_float(par1, 0.0F, this.getMaxHealth()))); + } + + public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) + { + if (ForgeHooks.onLivingAttack(this, par1DamageSource, par2)) return false; + if (this.isEntityInvulnerable()) + { + return false; + } + else if (this.worldObj.isRemote) + { + return false; + } + else + { + this.entityAge = 0; + + if (this.getHealth() <= 0.0F) + { + return false; + } + else if (par1DamageSource.isFireDamage() && this.isPotionActive(Potion.fireResistance)) + { + return false; + } + else + { + if ((par1DamageSource == DamageSource.anvil || par1DamageSource == DamageSource.fallingBlock) && this.getEquipmentInSlot(4) != null) + { + this.getEquipmentInSlot(4).damageItem((int)(par2 * 4.0F + this.rand.nextFloat() * par2 * 2.0F), this); + par2 *= 0.75F; + } + + this.limbSwingAmount = 1.5F; + boolean flag = true; + + if ((float)this.hurtResistantTime > (float)this.maxHurtResistantTime / 2.0F) + { + if (par2 <= this.lastDamage) + { + return false; + } + + this.damageEntity(par1DamageSource, par2 - this.lastDamage); + this.lastDamage = par2; + flag = false; + } + else + { + this.lastDamage = par2; + this.prevHealth = this.getHealth(); + this.hurtResistantTime = this.maxHurtResistantTime; + this.damageEntity(par1DamageSource, par2); + this.hurtTime = this.maxHurtTime = 10; + } + + this.attackedAtYaw = 0.0F; + Entity entity = par1DamageSource.getEntity(); + + if (entity != null) + { + if (entity instanceof EntityLivingBase) + { + this.setRevengeTarget((EntityLivingBase)entity); + } + + if (entity instanceof EntityPlayer) + { + this.recentlyHit = 100; + this.attackingPlayer = (EntityPlayer)entity; + } + else if (entity instanceof EntityWolf) + { + EntityWolf entitywolf = (EntityWolf)entity; + + if (entitywolf.isTamed()) + { + this.recentlyHit = 100; + this.attackingPlayer = null; + } + } + } + + if (flag) + { + this.worldObj.setEntityState(this, (byte)2); + + if (par1DamageSource != DamageSource.drown) + { + this.setBeenAttacked(); + } + + if (entity != null) + { + double d1 = entity.posX - this.posX; + double d0; + + for (d0 = entity.posZ - this.posZ; d1 * d1 + d0 * d0 < 1.0E-4D; d0 = (Math.random() - Math.random()) * 0.01D) + { + d1 = (Math.random() - Math.random()) * 0.01D; + } + + this.attackedAtYaw = (float)(Math.atan2(d0, d1) * 180.0D / Math.PI) - this.rotationYaw; + this.knockBack(entity, par2, d1, d0); + } + else + { + this.attackedAtYaw = (float)((int)(Math.random() * 2.0D) * 180); + } + } + + String s; + + if (this.getHealth() <= 0.0F) + { + s = this.getDeathSound(); + + if (flag && s != null) + { + this.playSound(s, this.getSoundVolume(), this.getSoundPitch()); + } + + this.onDeath(par1DamageSource); + } + else + { + s = this.getHurtSound(); + + if (flag && s != null) + { + this.playSound(s, this.getSoundVolume(), this.getSoundPitch()); + } + } + + return true; + } + } + } + + public void renderBrokenItemStack(ItemStack par1ItemStack) + { + this.playSound("random.break", 0.8F, 0.8F + this.worldObj.rand.nextFloat() * 0.4F); + + for (int i = 0; i < 5; ++i) + { + Vec3 vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(((double)this.rand.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D); + vec3.rotateAroundX(-this.rotationPitch * (float)Math.PI / 180.0F); + vec3.rotateAroundY(-this.rotationYaw * (float)Math.PI / 180.0F); + Vec3 vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(((double)this.rand.nextFloat() - 0.5D) * 0.3D, (double)(-this.rand.nextFloat()) * 0.6D - 0.3D, 0.6D); + vec31.rotateAroundX(-this.rotationPitch * (float)Math.PI / 180.0F); + vec31.rotateAroundY(-this.rotationYaw * (float)Math.PI / 180.0F); + vec31 = vec31.addVector(this.posX, this.posY + (double)this.getEyeHeight(), this.posZ); + this.worldObj.spawnParticle("iconcrack_" + Item.getIdFromItem(par1ItemStack.getItem()), vec31.xCoord, vec31.yCoord, vec31.zCoord, vec3.xCoord, vec3.yCoord + 0.05D, vec3.zCoord); + } + } + + public void onDeath(DamageSource par1DamageSource) + { + if (ForgeHooks.onLivingDeath(this, par1DamageSource)) return; + Entity entity = par1DamageSource.getEntity(); + EntityLivingBase entitylivingbase = this.func_94060_bK(); + + if (this.scoreValue >= 0 && entitylivingbase != null) + { + entitylivingbase.addToPlayerScore(this, this.scoreValue); + } + + if (entity != null) + { + entity.onKillEntity(this); + } + + this.dead = true; + + if (!this.worldObj.isRemote) + { + int i = 0; + + if (entity instanceof EntityPlayer) + { + i = EnchantmentHelper.getLootingModifier((EntityLivingBase)entity); + } + + captureDrops = true; + capturedDrops.clear(); + int j = 0; + + if (this.func_146066_aG() && this.worldObj.getGameRules().getGameRuleBooleanValue("doMobLoot")) + { + this.dropFewItems(this.recentlyHit > 0, i); + this.dropEquipment(this.recentlyHit > 0, i); + + if (this.recentlyHit > 0) + { + j = this.rand.nextInt(200) - i; + + if (j < 5) + { + this.dropRareDrop(j <= 0 ? 1 : 0); + } + } + } + + captureDrops = false; + + if (!ForgeHooks.onLivingDrops(this, par1DamageSource, capturedDrops, i, recentlyHit > 0, j)) + { + for (EntityItem item : capturedDrops) + { + worldObj.spawnEntityInWorld(item); + } + } + } + + this.worldObj.setEntityState(this, (byte)3); + } + + protected void dropEquipment(boolean par1, int par2) {} + + public void knockBack(Entity par1Entity, float par2, double par3, double par5) + { + if (this.rand.nextDouble() >= this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).getAttributeValue()) + { + this.isAirBorne = true; + float f1 = MathHelper.sqrt_double(par3 * par3 + par5 * par5); + float f2 = 0.4F; + this.motionX /= 2.0D; + this.motionY /= 2.0D; + this.motionZ /= 2.0D; + this.motionX -= par3 / (double)f1 * (double)f2; + this.motionY += (double)f2; + this.motionZ -= par5 / (double)f1 * (double)f2; + + if (this.motionY > 0.4000000059604645D) + { + this.motionY = 0.4000000059604645D; + } + } + } + + protected String getHurtSound() + { + return "game.neutral.hurt"; + } + + protected String getDeathSound() + { + return "game.neutral.die"; + } + + protected void dropRareDrop(int par1) {} + + protected void dropFewItems(boolean par1, int par2) {} + + public boolean isOnLadder() + { + int i = MathHelper.floor_double(this.posX); + int j = MathHelper.floor_double(this.boundingBox.minY); + int k = MathHelper.floor_double(this.posZ); + Block block = this.worldObj.getBlock(i, j, k); + return ForgeHooks.isLivingOnLadder(block, worldObj, i, j, k, this); + } + + public boolean isEntityAlive() + { + return !this.isDead && this.getHealth() > 0.0F; + } + + protected void fall(float par1) + { + par1 = ForgeHooks.onLivingFall(this, par1); + if (par1 <= 0) return; + super.fall(par1); + PotionEffect potioneffect = this.getActivePotionEffect(Potion.jump); + float f1 = potioneffect != null ? (float)(potioneffect.getAmplifier() + 1) : 0.0F; + int i = MathHelper.ceiling_float_int(par1 - 3.0F - f1); + + if (i > 0) + { + this.playSound(this.func_146067_o(i), 1.0F, 1.0F); + this.attackEntityFrom(DamageSource.fall, (float)i); + int j = MathHelper.floor_double(this.posX); + int k = MathHelper.floor_double(this.posY - 0.20000000298023224D - (double)this.yOffset); + int l = MathHelper.floor_double(this.posZ); + Block block = this.worldObj.getBlock(j, k, l); + + if (block.getMaterial() != Material.air) + { + Block.SoundType soundtype = block.stepSound; + this.playSound(soundtype.getStepResourcePath(), soundtype.getVolume() * 0.5F, soundtype.getPitch() * 0.75F); + } + } + } + + protected String func_146067_o(int p_146067_1_) + { + return p_146067_1_ > 4 ? "game.neutral.hurt.fall.big" : "game.neutral.hurt.fall.small"; + } + + @SideOnly(Side.CLIENT) + public void performHurtAnimation() + { + this.hurtTime = this.maxHurtTime = 10; + this.attackedAtYaw = 0.0F; + } + + public int getTotalArmorValue() + { + int i = 0; + ItemStack[] aitemstack = this.getLastActiveItems(); + int j = aitemstack.length; + + for (int k = 0; k < j; ++k) + { + ItemStack itemstack = aitemstack[k]; + + if (itemstack != null && itemstack.getItem() instanceof ItemArmor) + { + int l = ((ItemArmor)itemstack.getItem()).damageReduceAmount; + i += l; + } + } + + return i; + } + + protected void damageArmor(float par1) {} + + protected float applyArmorCalculations(DamageSource par1DamageSource, float par2) + { + if (!par1DamageSource.isUnblockable()) + { + int i = 25 - this.getTotalArmorValue(); + float f1 = par2 * (float)i; + this.damageArmor(par2); + par2 = f1 / 25.0F; + } + + return par2; + } + + protected float applyPotionDamageCalculations(DamageSource par1DamageSource, float par2) + { + if (par1DamageSource.isDamageAbsolute()) + { + return par2; + } + else + { + if (this instanceof EntityZombie) + { + //par2 = par2; // Forge: Noop Warning + } + + int i; + int j; + float f1; + + if (this.isPotionActive(Potion.resistance) && par1DamageSource != DamageSource.outOfWorld) + { + i = (this.getActivePotionEffect(Potion.resistance).getAmplifier() + 1) * 5; + j = 25 - i; + f1 = par2 * (float)j; + par2 = f1 / 25.0F; + } + + if (par2 <= 0.0F) + { + return 0.0F; + } + else + { + i = EnchantmentHelper.getEnchantmentModifierDamage(this.getLastActiveItems(), par1DamageSource); + + if (i > 20) + { + i = 20; + } + + if (i > 0 && i <= 20) + { + j = 25 - i; + f1 = par2 * (float)j; + par2 = f1 / 25.0F; + } + + return par2; + } + } + } + + protected void damageEntity(DamageSource par1DamageSource, float par2) + { + if (!this.isEntityInvulnerable()) + { + par2 = ForgeHooks.onLivingHurt(this, par1DamageSource, par2); + if (par2 <= 0) return; + par2 = this.applyArmorCalculations(par1DamageSource, par2); + par2 = this.applyPotionDamageCalculations(par1DamageSource, par2); + float f1 = par2; + par2 = Math.max(par2 - this.getAbsorptionAmount(), 0.0F); + this.setAbsorptionAmount(this.getAbsorptionAmount() - (f1 - par2)); + + if (par2 != 0.0F) + { + float f2 = this.getHealth(); + this.setHealth(f2 - par2); + this.func_110142_aN().func_94547_a(par1DamageSource, f2, par2); + this.setAbsorptionAmount(this.getAbsorptionAmount() - par2); + } + } + } + + public CombatTracker func_110142_aN() + { + return this._combatTracker; + } + + public EntityLivingBase func_94060_bK() + { + return (EntityLivingBase)(this._combatTracker.func_94550_c() != null ? this._combatTracker.func_94550_c() : (this.attackingPlayer != null ? this.attackingPlayer : (this.entityLivingToAttack != null ? this.entityLivingToAttack : null))); + } + + public final float getMaxHealth() + { + return (float)this.getEntityAttribute(SharedMonsterAttributes.maxHealth).getAttributeValue(); + } + + public final int getArrowCountInEntity() + { + return this.dataWatcher.getWatchableObjectByte(9); + } + + public final void setArrowCountInEntity(int par1) + { + this.dataWatcher.updateObject(9, Byte.valueOf((byte)par1)); + } + + private int getArmSwingAnimationEnd() + { + return this.isPotionActive(Potion.digSpeed) ? 6 - (1 + this.getActivePotionEffect(Potion.digSpeed).getAmplifier()) * 1 : (this.isPotionActive(Potion.digSlowdown) ? 6 + (1 + this.getActivePotionEffect(Potion.digSlowdown).getAmplifier()) * 2 : 6); + } + + public void swingItem() + { + ItemStack stack = this.getHeldItem(); + + if (stack != null && stack.getItem() != null) + { + Item item = stack.getItem(); + if (item.onEntitySwing(this, stack)) + { + return; + } + } + + if (!this.isSwingInProgress || this.swingProgressInt >= this.getArmSwingAnimationEnd() / 2 || this.swingProgressInt < 0) + { + this.swingProgressInt = -1; + this.isSwingInProgress = true; + + if (this.worldObj instanceof WorldServer) + { + ((WorldServer)this.worldObj).getEntityTracker().func_151247_a(this, new S0BPacketAnimation(this, 0)); + } + } + } + + @SideOnly(Side.CLIENT) + public void handleHealthUpdate(byte par1) + { + if (par1 == 2) + { + this.limbSwingAmount = 1.5F; + this.hurtResistantTime = this.maxHurtResistantTime; + this.hurtTime = this.maxHurtTime = 10; + this.attackedAtYaw = 0.0F; + this.playSound(this.getHurtSound(), this.getSoundVolume(), (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F); + this.attackEntityFrom(DamageSource.generic, 0.0F); + } + else if (par1 == 3) + { + this.playSound(this.getDeathSound(), this.getSoundVolume(), (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F); + this.setHealth(0.0F); + this.onDeath(DamageSource.generic); + } + else + { + super.handleHealthUpdate(par1); + } + } + + protected void kill() + { + this.attackEntityFrom(DamageSource.outOfWorld, 4.0F); + } + + protected void updateArmSwingProgress() + { + int i = this.getArmSwingAnimationEnd(); + + if (this.isSwingInProgress) + { + ++this.swingProgressInt; + + if (this.swingProgressInt >= i) + { + this.swingProgressInt = 0; + this.isSwingInProgress = false; + } + } + else + { + this.swingProgressInt = 0; + } + + this.swingProgress = (float)this.swingProgressInt / (float)i; + } + + public IAttributeInstance getEntityAttribute(IAttribute par1Attribute) + { + return this.getAttributeMap().getAttributeInstance(par1Attribute); + } + + public BaseAttributeMap getAttributeMap() + { + if (this.attributeMap == null) + { + this.attributeMap = new ServersideAttributeMap(); + } + + return this.attributeMap; + } + + public EnumCreatureAttribute getCreatureAttribute() + { + return EnumCreatureAttribute.UNDEFINED; + } + + public abstract ItemStack getHeldItem(); + + public abstract ItemStack getEquipmentInSlot(int var1); + + public abstract void setCurrentItemOrArmor(int var1, ItemStack var2); + + public void setSprinting(boolean par1) + { + super.setSprinting(par1); + IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed); + + if (iattributeinstance.getModifier(sprintingSpeedBoostModifierUUID) != null) + { + iattributeinstance.removeModifier(sprintingSpeedBoostModifier); + } + + if (par1) + { + iattributeinstance.applyModifier(sprintingSpeedBoostModifier); + } + } + + public abstract ItemStack[] getLastActiveItems(); + + protected float getSoundVolume() + { + return 1.0F; + } + + protected float getSoundPitch() + { + return this.isChild() ? (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.5F : (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F; + } + + protected boolean isMovementBlocked() + { + return this.getHealth() <= 0.0F; + } + + public void setPositionAndUpdate(double par1, double par3, double par5) + { + this.setLocationAndAngles(par1, par3, par5, this.rotationYaw, this.rotationPitch); + } + + public void dismountEntity(Entity par1Entity) + { + double d0 = par1Entity.posX; + double d1 = par1Entity.boundingBox.minY + (double)par1Entity.height; + double d2 = par1Entity.posZ; + byte b0 = 3; + + for (int i = -b0; i <= b0; ++i) + { + for (int j = -b0; j < b0; ++j) + { + if (i != 0 || j != 0) + { + int k = (int)(this.posX + (double)i); + int l = (int)(this.posZ + (double)j); + AxisAlignedBB axisalignedbb = this.boundingBox.getOffsetBoundingBox((double)i, 1.0D, (double)j); + + if (this.worldObj.func_147461_a(axisalignedbb).isEmpty()) + { + if (World.doesBlockHaveSolidTopSurface(this.worldObj, k, (int)this.posY, l)) + { + this.setPositionAndUpdate(this.posX + (double)i, this.posY + 1.0D, this.posZ + (double)j); + return; + } + + if (World.doesBlockHaveSolidTopSurface(this.worldObj, k, (int)this.posY - 1, l) || this.worldObj.getBlock(k, (int)this.posY - 1, l).getMaterial() == Material.water) + { + d0 = this.posX + (double)i; + d1 = this.posY + 1.0D; + d2 = this.posZ + (double)j; + } + } + } + } + } + + this.setPositionAndUpdate(d0, d1, d2); + } + + @SideOnly(Side.CLIENT) + public boolean getAlwaysRenderNameTagForRender() + { + return false; + } + + @SideOnly(Side.CLIENT) + public IIcon getItemIcon(ItemStack par1ItemStack, int par2) + { + return par1ItemStack.getItem().requiresMultipleRenderPasses() ? par1ItemStack.getItem().getIconFromDamageForRenderPass(par1ItemStack.getItemDamage(), par2) : par1ItemStack.getIconIndex(); + } + + protected void jump() + { + this.motionY = 0.41999998688697815D; + + if (this.isPotionActive(Potion.jump)) + { + this.motionY += (double)((float)(this.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F); + } + + if (this.isSprinting()) + { + float f = this.rotationYaw * 0.017453292F; + this.motionX -= (double)(MathHelper.sin(f) * 0.2F); + this.motionZ += (double)(MathHelper.cos(f) * 0.2F); + } + + this.isAirBorne = true; + ForgeHooks.onLivingJump(this); + } + + public void moveEntityWithHeading(float par1, float par2) + { + double d0; + + if (this.isInWater() && (!(this instanceof EntityPlayer) || !((EntityPlayer)this).capabilities.isFlying)) + { + d0 = this.posY; + this.moveFlying(par1, par2, this.isAIEnabled() ? 0.04F : 0.02F); + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.800000011920929D; + this.motionY *= 0.800000011920929D; + this.motionZ *= 0.800000011920929D; + this.motionY -= 0.02D; + + if (this.isCollidedHorizontally && this.isOffsetPositionInLiquid(this.motionX, this.motionY + 0.6000000238418579D - this.posY + d0, this.motionZ)) + { + this.motionY = 0.30000001192092896D; + } + } + else if (this.handleLavaMovement() && (!(this instanceof EntityPlayer) || !((EntityPlayer)this).capabilities.isFlying)) + { + d0 = this.posY; + this.moveFlying(par1, par2, 0.02F); + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.5D; + this.motionY *= 0.5D; + this.motionZ *= 0.5D; + this.motionY -= 0.02D; + + if (this.isCollidedHorizontally && this.isOffsetPositionInLiquid(this.motionX, this.motionY + 0.6000000238418579D - this.posY + d0, this.motionZ)) + { + this.motionY = 0.30000001192092896D; + } + } + else + { + float f2 = 0.91F; + + if (this.onGround) + { + f2 = this.worldObj.getBlock(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.boundingBox.minY) - 1, MathHelper.floor_double(this.posZ)).slipperiness * 0.91F; + } + + float f3 = 0.16277136F / (f2 * f2 * f2); + float f4; + + if (this.onGround) + { + f4 = this.getAIMoveSpeed() * f3; + } + else + { + f4 = this.jumpMovementFactor; + } + + this.moveFlying(par1, par2, f4); + f2 = 0.91F; + + if (this.onGround) + { + f2 = this.worldObj.getBlock(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.boundingBox.minY) - 1, MathHelper.floor_double(this.posZ)).slipperiness * 0.91F; + } + + if (this.isOnLadder()) + { + float f5 = 0.15F; + + if (this.motionX < (double)(-f5)) + { + this.motionX = (double)(-f5); + } + + if (this.motionX > (double)f5) + { + this.motionX = (double)f5; + } + + if (this.motionZ < (double)(-f5)) + { + this.motionZ = (double)(-f5); + } + + if (this.motionZ > (double)f5) + { + this.motionZ = (double)f5; + } + + this.fallDistance = 0.0F; + + if (this.motionY < -0.15D) + { + this.motionY = -0.15D; + } + + boolean flag = this.isSneaking() && this instanceof EntityPlayer; + + if (flag && this.motionY < 0.0D) + { + this.motionY = 0.0D; + } + } + + this.moveEntity(this.motionX, this.motionY, this.motionZ); + + if (this.isCollidedHorizontally && this.isOnLadder()) + { + this.motionY = 0.2D; + } + + if (this.worldObj.isRemote && (!this.worldObj.blockExists((int)this.posX, 0, (int)this.posZ) || !this.worldObj.getChunkFromBlockCoords((int)this.posX, (int)this.posZ).isChunkLoaded)) + { + if (this.posY > 0.0D) + { + this.motionY = -0.1D; + } + else + { + this.motionY = 0.0D; + } + } + else + { + this.motionY -= 0.08D; + } + + this.motionY *= 0.9800000190734863D; + this.motionX *= (double)f2; + this.motionZ *= (double)f2; + } + + this.prevLimbSwingAmount = this.limbSwingAmount; + d0 = this.posX - this.prevPosX; + double d1 = this.posZ - this.prevPosZ; + float f6 = MathHelper.sqrt_double(d0 * d0 + d1 * d1) * 4.0F; + + if (f6 > 1.0F) + { + f6 = 1.0F; + } + + this.limbSwingAmount += (f6 - this.limbSwingAmount) * 0.4F; + this.limbSwing += this.limbSwingAmount; + } + + protected boolean isAIEnabled() + { + return false; + } + + public float getAIMoveSpeed() + { + return this.isAIEnabled() ? this.landMovementFactor : 0.1F; + } + + public void setAIMoveSpeed(float par1) + { + this.landMovementFactor = par1; + } + + public boolean attackEntityAsMob(Entity par1Entity) + { + this.setLastAttacker(par1Entity); + return false; + } + + public boolean isPlayerSleeping() + { + return false; + } + + public void onUpdate() + { + if (ForgeHooks.onLivingUpdate(this)) return; + super.onUpdate(); + + if (!this.worldObj.isRemote) + { + int i = this.getArrowCountInEntity(); + + if (i > 0) + { + if (this.arrowHitTimer <= 0) + { + this.arrowHitTimer = 20 * (30 - i); + } + + --this.arrowHitTimer; + + if (this.arrowHitTimer <= 0) + { + this.setArrowCountInEntity(i - 1); + } + } + + for (int j = 0; j < 5; ++j) + { + ItemStack itemstack = this.previousEquipment[j]; + ItemStack itemstack1 = this.getEquipmentInSlot(j); + + if (!ItemStack.areItemStacksEqual(itemstack1, itemstack)) + { + ((WorldServer)this.worldObj).getEntityTracker().func_151247_a(this, new S04PacketEntityEquipment(this.getEntityId(), j, itemstack1)); + + if (itemstack != null) + { + this.attributeMap.removeAttributeModifiers(itemstack.getAttributeModifiers()); + } + + if (itemstack1 != null) + { + this.attributeMap.applyAttributeModifiers(itemstack1.getAttributeModifiers()); + } + + this.previousEquipment[j] = itemstack1 == null ? null : itemstack1.copy(); + } + } + } + + this.onLivingUpdate(); + double d0 = this.posX - this.prevPosX; + double d1 = this.posZ - this.prevPosZ; + float f = (float)(d0 * d0 + d1 * d1); + float f1 = this.renderYawOffset; + float f2 = 0.0F; + this.field_70768_au = this.field_110154_aX; + float f3 = 0.0F; + + if (f > 0.0025000002F) + { + f3 = 1.0F; + f2 = (float)Math.sqrt((double)f) * 3.0F; + f1 = (float)Math.atan2(d1, d0) * 180.0F / (float)Math.PI - 90.0F; + } + + if (this.swingProgress > 0.0F) + { + f1 = this.rotationYaw; + } + + if (!this.onGround) + { + f3 = 0.0F; + } + + this.field_110154_aX += (f3 - this.field_110154_aX) * 0.3F; + this.worldObj.theProfiler.startSection("headTurn"); + f2 = this.func_110146_f(f1, f2); + this.worldObj.theProfiler.endSection(); + this.worldObj.theProfiler.startSection("rangeChecks"); + + while (this.rotationYaw - this.prevRotationYaw < -180.0F) + { + this.prevRotationYaw -= 360.0F; + } + + while (this.rotationYaw - this.prevRotationYaw >= 180.0F) + { + this.prevRotationYaw += 360.0F; + } + + while (this.renderYawOffset - this.prevRenderYawOffset < -180.0F) + { + this.prevRenderYawOffset -= 360.0F; + } + + while (this.renderYawOffset - this.prevRenderYawOffset >= 180.0F) + { + this.prevRenderYawOffset += 360.0F; + } + + while (this.rotationPitch - this.prevRotationPitch < -180.0F) + { + this.prevRotationPitch -= 360.0F; + } + + while (this.rotationPitch - this.prevRotationPitch >= 180.0F) + { + this.prevRotationPitch += 360.0F; + } + + while (this.rotationYawHead - this.prevRotationYawHead < -180.0F) + { + this.prevRotationYawHead -= 360.0F; + } + + while (this.rotationYawHead - this.prevRotationYawHead >= 180.0F) + { + this.prevRotationYawHead += 360.0F; + } + + this.worldObj.theProfiler.endSection(); + this.field_70764_aw += f2; + } + + protected float func_110146_f(float par1, float par2) + { + float f2 = MathHelper.wrapAngleTo180_float(par1 - this.renderYawOffset); + this.renderYawOffset += f2 * 0.3F; + float f3 = MathHelper.wrapAngleTo180_float(this.rotationYaw - this.renderYawOffset); + boolean flag = f3 < -90.0F || f3 >= 90.0F; + + if (f3 < -75.0F) + { + f3 = -75.0F; + } + + if (f3 >= 75.0F) + { + f3 = 75.0F; + } + + this.renderYawOffset = this.rotationYaw - f3; + + if (f3 * f3 > 2500.0F) + { + this.renderYawOffset += f3 * 0.2F; + } + + if (flag) + { + par2 *= -1.0F; + } + + return par2; + } + + public void onLivingUpdate() + { + if (this.jumpTicks > 0) + { + --this.jumpTicks; + } + + if (this.newPosRotationIncrements > 0) + { + double d0 = this.posX + (this.newPosX - this.posX) / (double)this.newPosRotationIncrements; + double d1 = this.posY + (this.newPosY - this.posY) / (double)this.newPosRotationIncrements; + double d2 = this.posZ + (this.newPosZ - this.posZ) / (double)this.newPosRotationIncrements; + double d3 = MathHelper.wrapAngleTo180_double(this.newRotationYaw - (double)this.rotationYaw); + this.rotationYaw = (float)((double)this.rotationYaw + d3 / (double)this.newPosRotationIncrements); + this.rotationPitch = (float)((double)this.rotationPitch + (this.newRotationPitch - (double)this.rotationPitch) / (double)this.newPosRotationIncrements); + --this.newPosRotationIncrements; + this.setPosition(d0, d1, d2); + this.setRotation(this.rotationYaw, this.rotationPitch); + } + else if (!this.isClientWorld()) + { + this.motionX *= 0.98D; + this.motionY *= 0.98D; + this.motionZ *= 0.98D; + } + + if (Math.abs(this.motionX) < 0.005D) + { + this.motionX = 0.0D; + } + + if (Math.abs(this.motionY) < 0.005D) + { + this.motionY = 0.0D; + } + + if (Math.abs(this.motionZ) < 0.005D) + { + this.motionZ = 0.0D; + } + + this.worldObj.theProfiler.startSection("ai"); + + if (this.isMovementBlocked()) + { + this.isJumping = false; + this.moveStrafing = 0.0F; + this.moveForward = 0.0F; + this.randomYawVelocity = 0.0F; + } + else if (this.isClientWorld()) + { + if (this.isAIEnabled()) + { + this.worldObj.theProfiler.startSection("newAi"); + this.updateAITasks(); + this.worldObj.theProfiler.endSection(); + } + else + { + this.worldObj.theProfiler.startSection("oldAi"); + this.updateEntityActionState(); + this.worldObj.theProfiler.endSection(); + this.rotationYawHead = this.rotationYaw; + } + } + + this.worldObj.theProfiler.endSection(); + this.worldObj.theProfiler.startSection("jump"); + + if (this.isJumping) + { + if (!this.isInWater() && !this.handleLavaMovement()) + { + if (this.onGround && this.jumpTicks == 0) + { + this.jump(); + this.jumpTicks = 10; + } + } + else + { + this.motionY += 0.03999999910593033D; + } + } + else + { + this.jumpTicks = 0; + } + + this.worldObj.theProfiler.endSection(); + this.worldObj.theProfiler.startSection("travel"); + this.moveStrafing *= 0.98F; + this.moveForward *= 0.98F; + this.randomYawVelocity *= 0.9F; + this.moveEntityWithHeading(this.moveStrafing, this.moveForward); + this.worldObj.theProfiler.endSection(); + this.worldObj.theProfiler.startSection("push"); + + if (!this.worldObj.isRemote) + { + this.collideWithNearbyEntities(); + } + + this.worldObj.theProfiler.endSection(); + } + + protected void updateAITasks() {} + + protected void collideWithNearbyEntities() + { + List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.expand(0.20000000298023224D, 0.0D, 0.20000000298023224D)); + + if (list != null && !list.isEmpty()) + { + for (int i = 0; i < list.size(); ++i) + { + Entity entity = (Entity)list.get(i); + + if (entity.canBePushed()) + { + this.collideWithEntity(entity); + } + } + } + } + + protected void collideWithEntity(Entity par1Entity) + { + par1Entity.applyEntityCollision(this); + } + + public void updateRidden() + { + super.updateRidden(); + this.field_70768_au = this.field_110154_aX; + this.field_110154_aX = 0.0F; + this.fallDistance = 0.0F; + } + + @SideOnly(Side.CLIENT) + public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9) + { + this.yOffset = 0.0F; + this.newPosX = par1; + this.newPosY = par3; + this.newPosZ = par5; + this.newRotationYaw = (double)par7; + this.newRotationPitch = (double)par8; + this.newPosRotationIncrements = par9; + } + + protected void updateAITick() {} + + protected void updateEntityActionState() + { + ++this.entityAge; + } + + public void setJumping(boolean par1) + { + this.isJumping = par1; + } + + public void onItemPickup(Entity par1Entity, int par2) + { + if (!par1Entity.isDead && !this.worldObj.isRemote) + { + EntityTracker entitytracker = ((WorldServer)this.worldObj).getEntityTracker(); + + if (par1Entity instanceof EntityItem) + { + entitytracker.func_151247_a(par1Entity, new S0DPacketCollectItem(par1Entity.getEntityId(), this.getEntityId())); + } + + if (par1Entity instanceof EntityArrow) + { + entitytracker.func_151247_a(par1Entity, new S0DPacketCollectItem(par1Entity.getEntityId(), this.getEntityId())); + } + + if (par1Entity instanceof EntityXPOrb) + { + entitytracker.func_151247_a(par1Entity, new S0DPacketCollectItem(par1Entity.getEntityId(), this.getEntityId())); + } + } + } + + public boolean canEntityBeSeen(Entity par1Entity) + { + return this.worldObj.rayTraceBlocks(this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY + (double)this.getEyeHeight(), this.posZ), this.worldObj.getWorldVec3Pool().getVecFromPool(par1Entity.posX, par1Entity.posY + (double)par1Entity.getEyeHeight(), par1Entity.posZ)) == null; + } + + public Vec3 getLookVec() + { + return this.getLook(1.0F); + } + + public Vec3 getLook(float par1) + { + float f1; + float f2; + float f3; + float f4; + + if (par1 == 1.0F) + { + f1 = MathHelper.cos(-this.rotationYaw * 0.017453292F - (float)Math.PI); + f2 = MathHelper.sin(-this.rotationYaw * 0.017453292F - (float)Math.PI); + f3 = -MathHelper.cos(-this.rotationPitch * 0.017453292F); + f4 = MathHelper.sin(-this.rotationPitch * 0.017453292F); + return this.worldObj.getWorldVec3Pool().getVecFromPool((double)(f2 * f3), (double)f4, (double)(f1 * f3)); + } + else + { + f1 = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * par1; + f2 = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * par1; + f3 = MathHelper.cos(-f2 * 0.017453292F - (float)Math.PI); + f4 = MathHelper.sin(-f2 * 0.017453292F - (float)Math.PI); + float f5 = -MathHelper.cos(-f1 * 0.017453292F); + float f6 = MathHelper.sin(-f1 * 0.017453292F); + return this.worldObj.getWorldVec3Pool().getVecFromPool((double)(f4 * f5), (double)f6, (double)(f3 * f5)); + } + } + + @SideOnly(Side.CLIENT) + public float getSwingProgress(float par1) + { + float f1 = this.swingProgress - this.prevSwingProgress; + + if (f1 < 0.0F) + { + ++f1; + } + + return this.prevSwingProgress + f1 * par1; + } + + @SideOnly(Side.CLIENT) + public Vec3 getPosition(float par1) + { + if (par1 == 1.0F) + { + return this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ); + } + else + { + double d0 = this.prevPosX + (this.posX - this.prevPosX) * (double)par1; + double d1 = this.prevPosY + (this.posY - this.prevPosY) * (double)par1; + double d2 = this.prevPosZ + (this.posZ - this.prevPosZ) * (double)par1; + return this.worldObj.getWorldVec3Pool().getVecFromPool(d0, d1, d2); + } + } + + @SideOnly(Side.CLIENT) + public MovingObjectPosition rayTrace(double par1, float par3) + { + Vec3 vec3 = this.getPosition(par3); + Vec3 vec31 = this.getLook(par3); + Vec3 vec32 = vec3.addVector(vec31.xCoord * par1, vec31.yCoord * par1, vec31.zCoord * par1); + return this.worldObj.func_147447_a(vec3, vec32, false, false, true); + } + + public boolean isClientWorld() + { + return !this.worldObj.isRemote; + } + + public boolean canBeCollidedWith() + { + return !this.isDead; + } + + public boolean canBePushed() + { + return !this.isDead; + } + + public float getEyeHeight() + { + return this.height * 0.85F; + } + + protected void setBeenAttacked() + { + this.velocityChanged = this.rand.nextDouble() >= this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).getAttributeValue(); + } + + public float getRotationYawHead() + { + return this.rotationYawHead; + } + + @SideOnly(Side.CLIENT) + public void setRotationYawHead(float par1) + { + this.rotationYawHead = par1; + } + + public float getAbsorptionAmount() + { + return this.field_110151_bq; + } + + public void setAbsorptionAmount(float par1) + { + if (par1 < 0.0F) + { + par1 = 0.0F; + } + + this.field_110151_bq = par1; + } + + public Team getTeam() + { + return null; + } + + public boolean isOnSameTeam(EntityLivingBase par1EntityLivingBase) + { + return this.isOnTeam(par1EntityLivingBase.getTeam()); + } + + public boolean isOnTeam(Team par1Team) + { + return this.getTeam() != null ? this.getTeam().isSameTeam(par1Team) : false; + } + + /*** + * Removes all potion effects that have curativeItem as a curative item for its effect + * @param curativeItem The itemstack we are using to cure potion effects + */ + public void curePotionEffects(ItemStack curativeItem) + { + Iterator potionKey = activePotionsMap.keySet().iterator(); + + if (worldObj.isRemote) + { + return; + } + + while (potionKey.hasNext()) + { + Integer key = potionKey.next(); + PotionEffect effect = (PotionEffect)activePotionsMap.get(key); + + if (effect.isCurativeItem(curativeItem)) + { + potionKey.remove(); + onFinishedPotionEffect(effect); + } + } + } + + /** + * Returns true if the entity's rider (EntityPlayer) should face forward when mounted. + * currently only used in vanilla code by pigs. + * + * @param player The player who is riding the entity. + * @return If the player should orient the same direction as this entity. + */ + public boolean shouldRiderFaceForward(EntityPlayer player) + { + return this instanceof EntityPig; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/EntityMinecartCommandBlock.java b/src/main/java/net/minecraft/entity/EntityMinecartCommandBlock.java new file mode 100644 index 0000000..afc4bdb --- /dev/null +++ b/src/main/java/net/minecraft/entity/EntityMinecartCommandBlock.java @@ -0,0 +1,134 @@ +package net.minecraft.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; +import net.minecraft.block.Block; +import net.minecraft.command.server.CommandBlockLogic; +import net.minecraft.entity.item.EntityMinecart; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.IChatComponent; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class EntityMinecartCommandBlock extends EntityMinecart +{ + private final CommandBlockLogic field_145824_a = new CommandBlockLogic() + { + private static final String __OBFID = "CL_00001673"; + public void func_145756_e() + { + EntityMinecartCommandBlock.this.getDataWatcher().updateObject(23, this.func_145753_i()); + EntityMinecartCommandBlock.this.getDataWatcher().updateObject(24, IChatComponent.Serializer.func_150696_a(this.func_145749_h())); + } + @SideOnly(Side.CLIENT) + public int func_145751_f() + { + return 1; + } + @SideOnly(Side.CLIENT) + public void func_145757_a(ByteBuf p_145757_1_) + { + p_145757_1_.writeInt(EntityMinecartCommandBlock.this.getEntityId()); + } + public ChunkCoordinates getPlayerCoordinates() + { + return new ChunkCoordinates(MathHelper.floor_double(EntityMinecartCommandBlock.this.posX), MathHelper.floor_double(EntityMinecartCommandBlock.this.posY + 0.5D), MathHelper.floor_double(EntityMinecartCommandBlock.this.posZ)); + } + public World getEntityWorld() + { + return EntityMinecartCommandBlock.this.worldObj; + } + }; + private int field_145823_b = 0; + private static final String __OBFID = "CL_00001672"; + + public EntityMinecartCommandBlock(World p_i45321_1_) + { + super(p_i45321_1_); + } + + public EntityMinecartCommandBlock(World p_i45322_1_, double p_i45322_2_, double p_i45322_4_, double p_i45322_6_) + { + super(p_i45322_1_, p_i45322_2_, p_i45322_4_, p_i45322_6_); + } + + protected void entityInit() + { + super.entityInit(); + this.getDataWatcher().addObject(23, ""); + this.getDataWatcher().addObject(24, ""); + } + + protected void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + super.readEntityFromNBT(par1NBTTagCompound); + this.field_145824_a.func_145759_b(par1NBTTagCompound); + this.getDataWatcher().updateObject(23, this.func_145822_e().func_145753_i()); + this.getDataWatcher().updateObject(24, IChatComponent.Serializer.func_150696_a(this.func_145822_e().func_145749_h())); + } + + protected void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeEntityToNBT(par1NBTTagCompound); + this.field_145824_a.func_145758_a(par1NBTTagCompound); + } + + public int getMinecartType() + { + return 6; + } + + public Block func_145817_o() + { + return Blocks.command_block; + } + + public CommandBlockLogic func_145822_e() + { + return this.field_145824_a; + } + + public void onActivatorRailPass(int par1, int par2, int par3, boolean par4) + { + if (par4 && this.ticksExisted - this.field_145823_b >= 4) + { + this.func_145822_e().func_145755_a(this.worldObj); + this.field_145823_b = this.ticksExisted; + } + } + + public boolean interactFirst(EntityPlayer par1EntityPlayer) + { + if (this.worldObj.isRemote) + { + par1EntityPlayer.func_146095_a(this.func_145822_e()); + } + + return super.interactFirst(par1EntityPlayer); + } + + public void func_145781_i(int p_145781_1_) + { + super.func_145781_i(p_145781_1_); + + if (p_145781_1_ == 24) + { + try + { + this.field_145824_a.func_145750_b(IChatComponent.Serializer.func_150699_a(this.getDataWatcher().getWatchableObjectString(24))); + } + catch (Throwable throwable) + { + ; + } + } + else if (p_145781_1_ == 23) + { + this.field_145824_a.func_145752_a(this.getDataWatcher().getWatchableObjectString(23)); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/EntityTracker.java b/src/main/java/net/minecraft/entity/EntityTracker.java new file mode 100644 index 0000000..06273f8 --- /dev/null +++ b/src/main/java/net/minecraft/entity/EntityTracker.java @@ -0,0 +1,340 @@ +package net.minecraft.entity; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; +import java.util.concurrent.Callable; +import net.minecraft.crash.CrashReport; +import net.minecraft.crash.CrashReportCategory; +import net.minecraft.entity.boss.EntityDragon; +import net.minecraft.entity.boss.EntityWither; +import net.minecraft.entity.item.EntityBoat; +import net.minecraft.entity.item.EntityEnderCrystal; +import net.minecraft.entity.item.EntityEnderEye; +import net.minecraft.entity.item.EntityEnderPearl; +import net.minecraft.entity.item.EntityExpBottle; +import net.minecraft.entity.item.EntityFallingBlock; +import net.minecraft.entity.item.EntityFireworkRocket; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.item.EntityMinecart; +import net.minecraft.entity.item.EntityTNTPrimed; +import net.minecraft.entity.item.EntityXPOrb; +import net.minecraft.entity.passive.EntityBat; +import net.minecraft.entity.passive.EntitySquid; +import net.minecraft.entity.passive.IAnimals; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.entity.projectile.EntityEgg; +import net.minecraft.entity.projectile.EntityFireball; +import net.minecraft.entity.projectile.EntityFishHook; +import net.minecraft.entity.projectile.EntityPotion; +import net.minecraft.entity.projectile.EntitySmallFireball; +import net.minecraft.entity.projectile.EntitySnowball; +import net.minecraft.network.Packet; +import net.minecraft.util.IntHashMap; +import net.minecraft.util.ReportedException; +import net.minecraft.world.WorldServer; +import net.minecraft.world.chunk.Chunk; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import cpw.mods.fml.common.registry.EntityRegistry; + +public class EntityTracker +{ + private static final Logger logger = LogManager.getLogger(); + private final WorldServer theWorld; + private Set trackedEntities = new HashSet(); + private IntHashMap trackedEntityIDs = new IntHashMap(); + private int entityViewDistance; + private static final String __OBFID = "CL_00001431"; + + public EntityTracker(WorldServer par1WorldServer) + { + this.theWorld = par1WorldServer; + this.entityViewDistance = par1WorldServer.func_73046_m().getConfigurationManager().getEntityViewDistance(); + } + + public void addEntityToTracker(Entity par1Entity) + { + if (EntityRegistry.instance().tryTrackingEntity(this, par1Entity)) + { + return; + } + + if (par1Entity instanceof EntityPlayerMP) + { + this.addEntityToTracker(par1Entity, 512, 2); + EntityPlayerMP entityplayermp = (EntityPlayerMP)par1Entity; + Iterator iterator = this.trackedEntities.iterator(); + + while (iterator.hasNext()) + { + EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry)iterator.next(); + + if (entitytrackerentry.myEntity != entityplayermp) + { + entitytrackerentry.tryStartWachingThis(entityplayermp); + } + } + } + else if (par1Entity instanceof EntityFishHook) + { + this.addEntityToTracker(par1Entity, 64, 5, true); + } + else if (par1Entity instanceof EntityArrow) + { + this.addEntityToTracker(par1Entity, 64, 20, false); + } + else if (par1Entity instanceof EntitySmallFireball) + { + this.addEntityToTracker(par1Entity, 64, 10, false); + } + else if (par1Entity instanceof EntityFireball) + { + this.addEntityToTracker(par1Entity, 64, 10, false); + } + else if (par1Entity instanceof EntitySnowball) + { + this.addEntityToTracker(par1Entity, 64, 10, true); + } + else if (par1Entity instanceof EntityEnderPearl) + { + this.addEntityToTracker(par1Entity, 64, 10, true); + } + else if (par1Entity instanceof EntityEnderEye) + { + this.addEntityToTracker(par1Entity, 64, 4, true); + } + else if (par1Entity instanceof EntityEgg) + { + this.addEntityToTracker(par1Entity, 64, 10, true); + } + else if (par1Entity instanceof EntityPotion) + { + this.addEntityToTracker(par1Entity, 64, 10, true); + } + else if (par1Entity instanceof EntityExpBottle) + { + this.addEntityToTracker(par1Entity, 64, 10, true); + } + else if (par1Entity instanceof EntityFireworkRocket) + { + this.addEntityToTracker(par1Entity, 64, 10, true); + } + else if (par1Entity instanceof EntityItem) + { + this.addEntityToTracker(par1Entity, 64, 20, true); + } + else if (par1Entity instanceof EntityMinecart) + { + this.addEntityToTracker(par1Entity, 80, 3, true); + } + else if (par1Entity instanceof EntityBoat) + { + this.addEntityToTracker(par1Entity, 80, 3, true); + } + else if (par1Entity instanceof EntitySquid) + { + this.addEntityToTracker(par1Entity, 64, 3, true); + } + else if (par1Entity instanceof EntityWither) + { + this.addEntityToTracker(par1Entity, 80, 3, false); + } + else if (par1Entity instanceof EntityBat) + { + this.addEntityToTracker(par1Entity, 80, 3, false); + } + else if (par1Entity instanceof IAnimals) + { + this.addEntityToTracker(par1Entity, 80, 3, true); + } + else if (par1Entity instanceof EntityDragon) + { + this.addEntityToTracker(par1Entity, 160, 3, true); + } + else if (par1Entity instanceof EntityTNTPrimed) + { + this.addEntityToTracker(par1Entity, 160, 10, true); + } + else if (par1Entity instanceof EntityFallingBlock) + { + this.addEntityToTracker(par1Entity, 160, 20, true); + } + else if (par1Entity instanceof EntityHanging) + { + this.addEntityToTracker(par1Entity, 160, Integer.MAX_VALUE, false); + } + else if (par1Entity instanceof EntityXPOrb) + { + this.addEntityToTracker(par1Entity, 160, 20, true); + } + else if (par1Entity instanceof EntityEnderCrystal) + { + this.addEntityToTracker(par1Entity, 256, Integer.MAX_VALUE, false); + } + } + + public void addEntityToTracker(Entity par1Entity, int par2, int par3) + { + this.addEntityToTracker(par1Entity, par2, par3, false); + } + + public void addEntityToTracker(Entity par1Entity, int par2, final int par3, boolean par4) + { + if (par2 > this.entityViewDistance) + { + par2 = this.entityViewDistance; + } + + try + { + if (this.trackedEntityIDs.containsItem(par1Entity.getEntityId())) + { + throw new IllegalStateException("Entity is already tracked!"); + } + + EntityTrackerEntry entitytrackerentry = new EntityTrackerEntry(par1Entity, par2, par3, par4); + this.trackedEntities.add(entitytrackerentry); + this.trackedEntityIDs.addKey(par1Entity.getEntityId(), entitytrackerentry); + entitytrackerentry.sendEventsToPlayers(this.theWorld.playerEntities); + } + catch (Throwable throwable) + { + CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Adding entity to track"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("Entity To Track"); + crashreportcategory.addCrashSection("Tracking range", par2 + " blocks"); + crashreportcategory.addCrashSectionCallable("Update interval", new Callable() + { + private static final String __OBFID = "CL_00001432"; + public String call() + { + String s = "Once per " + par3 + " ticks"; + + if (par3 == Integer.MAX_VALUE) + { + s = "Maximum (" + s + ")"; + } + + return s; + } + }); + par1Entity.addEntityCrashInfo(crashreportcategory); + CrashReportCategory crashreportcategory1 = crashreport.makeCategory("Entity That Is Already Tracked"); + ((EntityTrackerEntry)this.trackedEntityIDs.lookup(par1Entity.getEntityId())).myEntity.addEntityCrashInfo(crashreportcategory1); + + try + { + throw new ReportedException(crashreport); + } + catch (ReportedException reportedexception) + { + logger.error("\"Silently\" catching entity tracking error.", reportedexception); + } + } + } + + public void removeEntityFromAllTrackingPlayers(Entity par1Entity) + { + if (par1Entity instanceof EntityPlayerMP) + { + EntityPlayerMP entityplayermp = (EntityPlayerMP)par1Entity; + Iterator iterator = this.trackedEntities.iterator(); + + while (iterator.hasNext()) + { + EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry)iterator.next(); + entitytrackerentry.removeFromWatchingList(entityplayermp); + } + } + + EntityTrackerEntry entitytrackerentry1 = (EntityTrackerEntry)this.trackedEntityIDs.removeObject(par1Entity.getEntityId()); + + if (entitytrackerentry1 != null) + { + this.trackedEntities.remove(entitytrackerentry1); + entitytrackerentry1.informAllAssociatedPlayersOfItemDestruction(); + } + } + + public void updateTrackedEntities() + { + ArrayList arraylist = new ArrayList(); + Iterator iterator = this.trackedEntities.iterator(); + + while (iterator.hasNext()) + { + EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry)iterator.next(); + entitytrackerentry.sendLocationToAllClients(this.theWorld.playerEntities); + + if (entitytrackerentry.playerEntitiesUpdated && entitytrackerentry.myEntity instanceof EntityPlayerMP) + { + arraylist.add((EntityPlayerMP)entitytrackerentry.myEntity); + } + } + + for (int i = 0; i < arraylist.size(); ++i) + { + EntityPlayerMP entityplayermp = (EntityPlayerMP)arraylist.get(i); + Iterator iterator1 = this.trackedEntities.iterator(); + + while (iterator1.hasNext()) + { + EntityTrackerEntry entitytrackerentry1 = (EntityTrackerEntry)iterator1.next(); + + if (entitytrackerentry1.myEntity != entityplayermp) + { + entitytrackerentry1.tryStartWachingThis(entityplayermp); + } + } + } + } + + public void func_151247_a(Entity p_151247_1_, Packet p_151247_2_) + { + EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry)this.trackedEntityIDs.lookup(p_151247_1_.getEntityId()); + + if (entitytrackerentry != null) + { + entitytrackerentry.func_151259_a(p_151247_2_); + } + } + + public void func_151248_b(Entity p_151248_1_, Packet p_151248_2_) + { + EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry)this.trackedEntityIDs.lookup(p_151248_1_.getEntityId()); + + if (entitytrackerentry != null) + { + entitytrackerentry.func_151261_b(p_151248_2_); + } + } + + public void removePlayerFromTrackers(EntityPlayerMP par1EntityPlayerMP) + { + Iterator iterator = this.trackedEntities.iterator(); + + while (iterator.hasNext()) + { + EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry)iterator.next(); + entitytrackerentry.removePlayerFromTracker(par1EntityPlayerMP); + } + } + + public void func_85172_a(EntityPlayerMP par1EntityPlayerMP, Chunk par2Chunk) + { + Iterator iterator = this.trackedEntities.iterator(); + + while (iterator.hasNext()) + { + EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry)iterator.next(); + + if (entitytrackerentry.myEntity != par1EntityPlayerMP && entitytrackerentry.myEntity.chunkCoordX == par2Chunk.xPosition && entitytrackerentry.myEntity.chunkCoordZ == par2Chunk.zPosition) + { + entitytrackerentry.tryStartWachingThis(par1EntityPlayerMP); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/EntityTrackerEntry.java b/src/main/java/net/minecraft/entity/EntityTrackerEntry.java new file mode 100644 index 0000000..f3fb2c0 --- /dev/null +++ b/src/main/java/net/minecraft/entity/EntityTrackerEntry.java @@ -0,0 +1,625 @@ +package net.minecraft.entity; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; +import net.minecraft.block.Block; +import net.minecraft.entity.ai.attributes.ServersideAttributeMap; +import net.minecraft.entity.boss.EntityDragon; +import net.minecraft.entity.item.EntityBoat; +import net.minecraft.entity.item.EntityEnderCrystal; +import net.minecraft.entity.item.EntityEnderEye; +import net.minecraft.entity.item.EntityEnderPearl; +import net.minecraft.entity.item.EntityExpBottle; +import net.minecraft.entity.item.EntityFallingBlock; +import net.minecraft.entity.item.EntityFireworkRocket; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.item.EntityItemFrame; +import net.minecraft.entity.item.EntityMinecart; +import net.minecraft.entity.item.EntityPainting; +import net.minecraft.entity.item.EntityTNTPrimed; +import net.minecraft.entity.item.EntityXPOrb; +import net.minecraft.entity.passive.IAnimals; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.entity.projectile.EntityEgg; +import net.minecraft.entity.projectile.EntityFireball; +import net.minecraft.entity.projectile.EntityFishHook; +import net.minecraft.entity.projectile.EntityPotion; +import net.minecraft.entity.projectile.EntitySmallFireball; +import net.minecraft.entity.projectile.EntitySnowball; +import net.minecraft.entity.projectile.EntityWitherSkull; +import net.minecraft.init.Items; +import net.minecraft.item.ItemMap; +import net.minecraft.item.ItemStack; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S04PacketEntityEquipment; +import net.minecraft.network.play.server.S0APacketUseBed; +import net.minecraft.network.play.server.S0CPacketSpawnPlayer; +import net.minecraft.network.play.server.S0EPacketSpawnObject; +import net.minecraft.network.play.server.S0FPacketSpawnMob; +import net.minecraft.network.play.server.S10PacketSpawnPainting; +import net.minecraft.network.play.server.S11PacketSpawnExperienceOrb; +import net.minecraft.network.play.server.S12PacketEntityVelocity; +import net.minecraft.network.play.server.S14PacketEntity; +import net.minecraft.network.play.server.S18PacketEntityTeleport; +import net.minecraft.network.play.server.S19PacketEntityHeadLook; +import net.minecraft.network.play.server.S1BPacketEntityAttach; +import net.minecraft.network.play.server.S1CPacketEntityMetadata; +import net.minecraft.network.play.server.S1DPacketEntityEffect; +import net.minecraft.network.play.server.S20PacketEntityProperties; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.MathHelper; +import net.minecraft.world.storage.MapData; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import cpw.mods.fml.common.network.internal.FMLNetworkHandler; + +public class EntityTrackerEntry +{ + private static final Logger logger = LogManager.getLogger(); + public Entity myEntity; + public int blocksDistanceThreshold; + public int updateFrequency; + public int lastScaledXPosition; + public int lastScaledYPosition; + public int lastScaledZPosition; + public int lastYaw; + public int lastPitch; + public int lastHeadMotion; + public double motionX; + public double motionY; + public double motionZ; + public int ticks; + private double posX; + private double posY; + private double posZ; + private boolean isDataInitialized; + private boolean sendVelocityUpdates; + private int ticksSinceLastForcedTeleport; + private Entity field_85178_v; + private boolean ridingEntity; + public boolean playerEntitiesUpdated; + public Set trackingPlayers = new HashSet(); + private static final String __OBFID = "CL_00001443"; + + public EntityTrackerEntry(Entity par1Entity, int par2, int par3, boolean par4) + { + this.myEntity = par1Entity; + this.blocksDistanceThreshold = par2; + this.updateFrequency = par3; + this.sendVelocityUpdates = par4; + this.lastScaledXPosition = MathHelper.floor_double(par1Entity.posX * 32.0D); + this.lastScaledYPosition = MathHelper.floor_double(par1Entity.posY * 32.0D); + this.lastScaledZPosition = MathHelper.floor_double(par1Entity.posZ * 32.0D); + this.lastYaw = MathHelper.floor_float(par1Entity.rotationYaw * 256.0F / 360.0F); + this.lastPitch = MathHelper.floor_float(par1Entity.rotationPitch * 256.0F / 360.0F); + this.lastHeadMotion = MathHelper.floor_float(par1Entity.getRotationYawHead() * 256.0F / 360.0F); + } + + public boolean equals(Object par1Obj) + { + return par1Obj instanceof EntityTrackerEntry ? ((EntityTrackerEntry)par1Obj).myEntity.getEntityId() == this.myEntity.getEntityId() : false; + } + + public int hashCode() + { + return this.myEntity.getEntityId(); + } + + public void sendLocationToAllClients(List par1List) + { + this.playerEntitiesUpdated = false; + + if (!this.isDataInitialized || this.myEntity.getDistanceSq(this.posX, this.posY, this.posZ) > 16.0D) + { + this.posX = this.myEntity.posX; + this.posY = this.myEntity.posY; + this.posZ = this.myEntity.posZ; + this.isDataInitialized = true; + this.playerEntitiesUpdated = true; + this.sendEventsToPlayers(par1List); + } + + if (this.field_85178_v != this.myEntity.ridingEntity || this.myEntity.ridingEntity != null && this.ticks % 60 == 0) + { + this.field_85178_v = this.myEntity.ridingEntity; + this.func_151259_a(new S1BPacketEntityAttach(0, this.myEntity, this.myEntity.ridingEntity)); + } + + if (this.myEntity instanceof EntityItemFrame && this.ticks % 10 == 0) + { + EntityItemFrame entityitemframe = (EntityItemFrame)this.myEntity; + ItemStack itemstack = entityitemframe.getDisplayedItem(); + + if (itemstack != null && itemstack.getItem() instanceof ItemMap) + { + MapData mapdata = Items.filled_map.getMapData(itemstack, this.myEntity.worldObj); + Iterator iterator = par1List.iterator(); + + while (iterator.hasNext()) + { + EntityPlayer entityplayer = (EntityPlayer)iterator.next(); + EntityPlayerMP entityplayermp = (EntityPlayerMP)entityplayer; + mapdata.updateVisiblePlayers(entityplayermp, itemstack); + Packet packet = Items.filled_map.func_150911_c(itemstack, this.myEntity.worldObj, entityplayermp); + + if (packet != null) + { + entityplayermp.playerNetServerHandler.sendPacket(packet); + } + } + } + + this.sendMetadataToAllAssociatedPlayers(); + } + else if (this.ticks % this.updateFrequency == 0 || this.myEntity.isAirBorne || this.myEntity.getDataWatcher().hasChanges()) + { + int i; + int j; + + if (this.myEntity.ridingEntity == null) + { + ++this.ticksSinceLastForcedTeleport; + i = this.myEntity.myEntitySize.multiplyBy32AndRound(this.myEntity.posX); + j = MathHelper.floor_double(this.myEntity.posY * 32.0D); + int k = this.myEntity.myEntitySize.multiplyBy32AndRound(this.myEntity.posZ); + int l = MathHelper.floor_float(this.myEntity.rotationYaw * 256.0F / 360.0F); + int i1 = MathHelper.floor_float(this.myEntity.rotationPitch * 256.0F / 360.0F); + int j1 = i - this.lastScaledXPosition; + int k1 = j - this.lastScaledYPosition; + int l1 = k - this.lastScaledZPosition; + Object object = null; + boolean flag = Math.abs(j1) >= 4 || Math.abs(k1) >= 4 || Math.abs(l1) >= 4 || this.ticks % 60 == 0; + boolean flag1 = Math.abs(l - this.lastYaw) >= 4 || Math.abs(i1 - this.lastPitch) >= 4; + + if (this.ticks > 0 || this.myEntity instanceof EntityArrow) + { + if (j1 >= -128 && j1 < 128 && k1 >= -128 && k1 < 128 && l1 >= -128 && l1 < 128 && this.ticksSinceLastForcedTeleport <= 400 && !this.ridingEntity) + { + if (flag && flag1) + { + object = new S14PacketEntity.S17PacketEntityLookMove(this.myEntity.getEntityId(), (byte)j1, (byte)k1, (byte)l1, (byte)l, (byte)i1); + } + else if (flag) + { + object = new S14PacketEntity.S15PacketEntityRelMove(this.myEntity.getEntityId(), (byte)j1, (byte)k1, (byte)l1); + } + else if (flag1) + { + object = new S14PacketEntity.S16PacketEntityLook(this.myEntity.getEntityId(), (byte)l, (byte)i1); + } + } + else + { + this.ticksSinceLastForcedTeleport = 0; + object = new S18PacketEntityTeleport(this.myEntity.getEntityId(), i, j, k, (byte)l, (byte)i1); + } + } + + if (this.sendVelocityUpdates) + { + double d0 = this.myEntity.motionX - this.motionX; + double d1 = this.myEntity.motionY - this.motionY; + double d2 = this.myEntity.motionZ - this.motionZ; + double d3 = 0.02D; + double d4 = d0 * d0 + d1 * d1 + d2 * d2; + + if (d4 > d3 * d3 || d4 > 0.0D && this.myEntity.motionX == 0.0D && this.myEntity.motionY == 0.0D && this.myEntity.motionZ == 0.0D) + { + this.motionX = this.myEntity.motionX; + this.motionY = this.myEntity.motionY; + this.motionZ = this.myEntity.motionZ; + this.func_151259_a(new S12PacketEntityVelocity(this.myEntity.getEntityId(), this.motionX, this.motionY, this.motionZ)); + } + } + + if (object != null) + { + this.func_151259_a((Packet)object); + } + + this.sendMetadataToAllAssociatedPlayers(); + + if (flag) + { + this.lastScaledXPosition = i; + this.lastScaledYPosition = j; + this.lastScaledZPosition = k; + } + + if (flag1) + { + this.lastYaw = l; + this.lastPitch = i1; + } + + this.ridingEntity = false; + } + else + { + i = MathHelper.floor_float(this.myEntity.rotationYaw * 256.0F / 360.0F); + j = MathHelper.floor_float(this.myEntity.rotationPitch * 256.0F / 360.0F); + boolean flag2 = Math.abs(i - this.lastYaw) >= 4 || Math.abs(j - this.lastPitch) >= 4; + + if (flag2) + { + this.func_151259_a(new S14PacketEntity.S16PacketEntityLook(this.myEntity.getEntityId(), (byte)i, (byte)j)); + this.lastYaw = i; + this.lastPitch = j; + } + + this.lastScaledXPosition = this.myEntity.myEntitySize.multiplyBy32AndRound(this.myEntity.posX); + this.lastScaledYPosition = MathHelper.floor_double(this.myEntity.posY * 32.0D); + this.lastScaledZPosition = this.myEntity.myEntitySize.multiplyBy32AndRound(this.myEntity.posZ); + this.sendMetadataToAllAssociatedPlayers(); + this.ridingEntity = true; + } + + i = MathHelper.floor_float(this.myEntity.getRotationYawHead() * 256.0F / 360.0F); + + if (Math.abs(i - this.lastHeadMotion) >= 4) + { + this.func_151259_a(new S19PacketEntityHeadLook(this.myEntity, (byte)i)); + this.lastHeadMotion = i; + } + + this.myEntity.isAirBorne = false; + } + + ++this.ticks; + + if (this.myEntity.velocityChanged) + { + this.func_151261_b(new S12PacketEntityVelocity(this.myEntity)); + this.myEntity.velocityChanged = false; + } + } + + private void sendMetadataToAllAssociatedPlayers() + { + DataWatcher datawatcher = this.myEntity.getDataWatcher(); + + if (datawatcher.hasChanges()) + { + this.func_151261_b(new S1CPacketEntityMetadata(this.myEntity.getEntityId(), datawatcher, false)); + } + + if (this.myEntity instanceof EntityLivingBase) + { + ServersideAttributeMap serversideattributemap = (ServersideAttributeMap)((EntityLivingBase)this.myEntity).getAttributeMap(); + Set set = serversideattributemap.getAttributeInstanceSet(); + + if (!set.isEmpty()) + { + this.func_151261_b(new S20PacketEntityProperties(this.myEntity.getEntityId(), set)); + } + + set.clear(); + } + } + + public void func_151259_a(Packet p_151259_1_) + { + Iterator iterator = this.trackingPlayers.iterator(); + + while (iterator.hasNext()) + { + EntityPlayerMP entityplayermp = (EntityPlayerMP)iterator.next(); + entityplayermp.playerNetServerHandler.sendPacket(p_151259_1_); + } + } + + public void func_151261_b(Packet p_151261_1_) + { + this.func_151259_a(p_151261_1_); + + if (this.myEntity instanceof EntityPlayerMP) + { + ((EntityPlayerMP)this.myEntity).playerNetServerHandler.sendPacket(p_151261_1_); + } + } + + public void informAllAssociatedPlayersOfItemDestruction() + { + Iterator iterator = this.trackingPlayers.iterator(); + + while (iterator.hasNext()) + { + EntityPlayerMP entityplayermp = (EntityPlayerMP)iterator.next(); + entityplayermp.destroyedItemsNetCache.add(Integer.valueOf(this.myEntity.getEntityId())); + } + } + + public void removeFromWatchingList(EntityPlayerMP par1EntityPlayerMP) + { + if (this.trackingPlayers.contains(par1EntityPlayerMP)) + { + par1EntityPlayerMP.destroyedItemsNetCache.add(Integer.valueOf(this.myEntity.getEntityId())); + this.trackingPlayers.remove(par1EntityPlayerMP); + } + } + + public void tryStartWachingThis(EntityPlayerMP par1EntityPlayerMP) + { + if (par1EntityPlayerMP != this.myEntity) + { + double d0 = par1EntityPlayerMP.posX - (double)(this.lastScaledXPosition / 32); + double d1 = par1EntityPlayerMP.posZ - (double)(this.lastScaledZPosition / 32); + + if (d0 >= (double)(-this.blocksDistanceThreshold) && d0 <= (double)this.blocksDistanceThreshold && d1 >= (double)(-this.blocksDistanceThreshold) && d1 <= (double)this.blocksDistanceThreshold) + { + if (!this.trackingPlayers.contains(par1EntityPlayerMP) && (this.isPlayerWatchingThisChunk(par1EntityPlayerMP) || this.myEntity.forceSpawn)) + { + this.trackingPlayers.add(par1EntityPlayerMP); + Packet packet = this.func_151260_c(); + par1EntityPlayerMP.playerNetServerHandler.sendPacket(packet); + + if (!this.myEntity.getDataWatcher().getIsBlank()) + { + par1EntityPlayerMP.playerNetServerHandler.sendPacket(new S1CPacketEntityMetadata(this.myEntity.getEntityId(), this.myEntity.getDataWatcher(), true)); + } + + if (this.myEntity instanceof EntityLivingBase) + { + ServersideAttributeMap serversideattributemap = (ServersideAttributeMap)((EntityLivingBase)this.myEntity).getAttributeMap(); + Collection collection = serversideattributemap.getWatchedAttributes(); + + if (!collection.isEmpty()) + { + par1EntityPlayerMP.playerNetServerHandler.sendPacket(new S20PacketEntityProperties(this.myEntity.getEntityId(), collection)); + } + } + + this.motionX = this.myEntity.motionX; + this.motionY = this.myEntity.motionY; + this.motionZ = this.myEntity.motionZ; + + int posX = MathHelper.floor_double(this.myEntity.posX * 32.0D); + int posY = MathHelper.floor_double(this.myEntity.posY * 32.0D); + int posZ = MathHelper.floor_double(this.myEntity.posZ * 32.0D); + if (posX != this.lastScaledXPosition || posY != this.lastScaledYPosition || posZ != this.lastScaledZPosition) + { + FMLNetworkHandler.makeEntitySpawnAdjustment(this.myEntity, par1EntityPlayerMP, this.lastScaledXPosition, this.lastScaledYPosition, this.lastScaledZPosition); + } + + if (this.sendVelocityUpdates && !(packet instanceof S0FPacketSpawnMob)) + { + par1EntityPlayerMP.playerNetServerHandler.sendPacket(new S12PacketEntityVelocity(this.myEntity.getEntityId(), this.myEntity.motionX, this.myEntity.motionY, this.myEntity.motionZ)); + } + + if (this.myEntity.ridingEntity != null) + { + par1EntityPlayerMP.playerNetServerHandler.sendPacket(new S1BPacketEntityAttach(0, this.myEntity, this.myEntity.ridingEntity)); + } + + if (this.myEntity instanceof EntityLiving && ((EntityLiving)this.myEntity).getLeashedToEntity() != null) + { + par1EntityPlayerMP.playerNetServerHandler.sendPacket(new S1BPacketEntityAttach(1, this.myEntity, ((EntityLiving)this.myEntity).getLeashedToEntity())); + } + + if (this.myEntity instanceof EntityLivingBase) + { + for (int i = 0; i < 5; ++i) + { + ItemStack itemstack = ((EntityLivingBase)this.myEntity).getEquipmentInSlot(i); + + if (itemstack != null) + { + par1EntityPlayerMP.playerNetServerHandler.sendPacket(new S04PacketEntityEquipment(this.myEntity.getEntityId(), i, itemstack)); + } + } + } + + if (this.myEntity instanceof EntityPlayer) + { + EntityPlayer entityplayer = (EntityPlayer)this.myEntity; + + if (entityplayer.isPlayerSleeping()) + { + par1EntityPlayerMP.playerNetServerHandler.sendPacket(new S0APacketUseBed(entityplayer, MathHelper.floor_double(this.myEntity.posX), MathHelper.floor_double(this.myEntity.posY), MathHelper.floor_double(this.myEntity.posZ))); + } + } + + if (this.myEntity instanceof EntityLivingBase) + { + EntityLivingBase entitylivingbase = (EntityLivingBase)this.myEntity; + Iterator iterator = entitylivingbase.getActivePotionEffects().iterator(); + + while (iterator.hasNext()) + { + PotionEffect potioneffect = (PotionEffect)iterator.next(); + par1EntityPlayerMP.playerNetServerHandler.sendPacket(new S1DPacketEntityEffect(this.myEntity.getEntityId(), potioneffect)); + } + } + } + } + else if (this.trackingPlayers.contains(par1EntityPlayerMP)) + { + this.trackingPlayers.remove(par1EntityPlayerMP); + par1EntityPlayerMP.destroyedItemsNetCache.add(Integer.valueOf(this.myEntity.getEntityId())); + } + } + } + + private boolean isPlayerWatchingThisChunk(EntityPlayerMP par1EntityPlayerMP) + { + return par1EntityPlayerMP.getServerForPlayer().getPlayerManager().isPlayerWatchingChunk(par1EntityPlayerMP, this.myEntity.chunkCoordX, this.myEntity.chunkCoordZ); + } + + public void sendEventsToPlayers(List par1List) + { + for (int i = 0; i < par1List.size(); ++i) + { + this.tryStartWachingThis((EntityPlayerMP)par1List.get(i)); + } + } + + private Packet func_151260_c() + { + if (this.myEntity.isDead) + { + logger.warn("Fetching addPacket for removed entity"); + } + + Packet pkt = FMLNetworkHandler.getEntitySpawningPacket(this.myEntity); + + if (pkt != null) + { + return pkt; + } + if (this.myEntity instanceof EntityItem) + { + return new S0EPacketSpawnObject(this.myEntity, 2, 1); + } + else if (this.myEntity instanceof EntityPlayerMP) + { + return new S0CPacketSpawnPlayer((EntityPlayer)this.myEntity); + } + else if (this.myEntity instanceof EntityMinecart) + { + EntityMinecart entityminecart = (EntityMinecart)this.myEntity; + return new S0EPacketSpawnObject(this.myEntity, 10, entityminecart.getMinecartType()); + } + else if (this.myEntity instanceof EntityBoat) + { + return new S0EPacketSpawnObject(this.myEntity, 1); + } + else if (!(this.myEntity instanceof IAnimals) && !(this.myEntity instanceof EntityDragon)) + { + if (this.myEntity instanceof EntityFishHook) + { + EntityPlayer entityplayer = ((EntityFishHook)this.myEntity).field_146042_b; + return new S0EPacketSpawnObject(this.myEntity, 90, entityplayer != null ? entityplayer.getEntityId() : this.myEntity.getEntityId()); + } + else if (this.myEntity instanceof EntityArrow) + { + Entity entity = ((EntityArrow)this.myEntity).shootingEntity; + return new S0EPacketSpawnObject(this.myEntity, 60, entity != null ? entity.getEntityId() : this.myEntity.getEntityId()); + } + else if (this.myEntity instanceof EntitySnowball) + { + return new S0EPacketSpawnObject(this.myEntity, 61); + } + else if (this.myEntity instanceof EntityPotion) + { + return new S0EPacketSpawnObject(this.myEntity, 73, ((EntityPotion)this.myEntity).getPotionDamage()); + } + else if (this.myEntity instanceof EntityExpBottle) + { + return new S0EPacketSpawnObject(this.myEntity, 75); + } + else if (this.myEntity instanceof EntityEnderPearl) + { + return new S0EPacketSpawnObject(this.myEntity, 65); + } + else if (this.myEntity instanceof EntityEnderEye) + { + return new S0EPacketSpawnObject(this.myEntity, 72); + } + else if (this.myEntity instanceof EntityFireworkRocket) + { + return new S0EPacketSpawnObject(this.myEntity, 76); + } + else + { + S0EPacketSpawnObject s0epacketspawnobject; + + if (this.myEntity instanceof EntityFireball) + { + EntityFireball entityfireball = (EntityFireball)this.myEntity; + s0epacketspawnobject = null; + byte b0 = 63; + + if (this.myEntity instanceof EntitySmallFireball) + { + b0 = 64; + } + else if (this.myEntity instanceof EntityWitherSkull) + { + b0 = 66; + } + + if (entityfireball.shootingEntity != null) + { + s0epacketspawnobject = new S0EPacketSpawnObject(this.myEntity, b0, ((EntityFireball)this.myEntity).shootingEntity.getEntityId()); + } + else + { + s0epacketspawnobject = new S0EPacketSpawnObject(this.myEntity, b0, 0); + } + + s0epacketspawnobject.func_149003_d((int)(entityfireball.accelerationX * 8000.0D)); + s0epacketspawnobject.func_149000_e((int)(entityfireball.accelerationY * 8000.0D)); + s0epacketspawnobject.func_149007_f((int)(entityfireball.accelerationZ * 8000.0D)); + return s0epacketspawnobject; + } + else if (this.myEntity instanceof EntityEgg) + { + return new S0EPacketSpawnObject(this.myEntity, 62); + } + else if (this.myEntity instanceof EntityTNTPrimed) + { + return new S0EPacketSpawnObject(this.myEntity, 50); + } + else if (this.myEntity instanceof EntityEnderCrystal) + { + return new S0EPacketSpawnObject(this.myEntity, 51); + } + else if (this.myEntity instanceof EntityFallingBlock) + { + EntityFallingBlock entityfallingblock = (EntityFallingBlock)this.myEntity; + return new S0EPacketSpawnObject(this.myEntity, 70, Block.getIdFromBlock(entityfallingblock.func_145805_f()) | entityfallingblock.field_145814_a << 16); + } + else if (this.myEntity instanceof EntityPainting) + { + return new S10PacketSpawnPainting((EntityPainting)this.myEntity); + } + else if (this.myEntity instanceof EntityItemFrame) + { + EntityItemFrame entityitemframe = (EntityItemFrame)this.myEntity; + s0epacketspawnobject = new S0EPacketSpawnObject(this.myEntity, 71, entityitemframe.hangingDirection); + s0epacketspawnobject.func_148996_a(MathHelper.floor_float((float)(entityitemframe.field_146063_b * 32))); + s0epacketspawnobject.func_148995_b(MathHelper.floor_float((float)(entityitemframe.field_146064_c * 32))); + s0epacketspawnobject.func_149005_c(MathHelper.floor_float((float)(entityitemframe.field_146062_d * 32))); + return s0epacketspawnobject; + } + else if (this.myEntity instanceof EntityLeashKnot) + { + EntityLeashKnot entityleashknot = (EntityLeashKnot)this.myEntity; + s0epacketspawnobject = new S0EPacketSpawnObject(this.myEntity, 77); + s0epacketspawnobject.func_148996_a(MathHelper.floor_float((float)(entityleashknot.field_146063_b * 32))); + s0epacketspawnobject.func_148995_b(MathHelper.floor_float((float)(entityleashknot.field_146064_c * 32))); + s0epacketspawnobject.func_149005_c(MathHelper.floor_float((float)(entityleashknot.field_146062_d * 32))); + return s0epacketspawnobject; + } + else if (this.myEntity instanceof EntityXPOrb) + { + return new S11PacketSpawnExperienceOrb((EntityXPOrb)this.myEntity); + } + else + { + throw new IllegalArgumentException("Don\'t know how to add " + this.myEntity.getClass() + "!"); + } + } + } + else + { + this.lastHeadMotion = MathHelper.floor_float(this.myEntity.getRotationYawHead() * 256.0F / 360.0F); + return new S0FPacketSpawnMob((EntityLivingBase)this.myEntity); + } + } + + public void removePlayerFromTracker(EntityPlayerMP par1EntityPlayerMP) + { + if (this.trackingPlayers.contains(par1EntityPlayerMP)) + { + this.trackingPlayers.remove(par1EntityPlayerMP); + par1EntityPlayerMP.destroyedItemsNetCache.add(Integer.valueOf(this.myEntity.getEntityId())); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/EnumCreatureAttribute.java b/src/main/java/net/minecraft/entity/EnumCreatureAttribute.java new file mode 100644 index 0000000..8b61629 --- /dev/null +++ b/src/main/java/net/minecraft/entity/EnumCreatureAttribute.java @@ -0,0 +1,10 @@ +package net.minecraft.entity; + +public enum EnumCreatureAttribute +{ + UNDEFINED, + UNDEAD, + ARTHROPOD; + + private static final String __OBFID = "CL_00001553"; +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/EnumCreatureType.java b/src/main/java/net/minecraft/entity/EnumCreatureType.java new file mode 100644 index 0000000..c768808 --- /dev/null +++ b/src/main/java/net/minecraft/entity/EnumCreatureType.java @@ -0,0 +1,56 @@ +package net.minecraft.entity; + +import net.minecraft.block.material.Material; +import net.minecraft.entity.monster.IMob; +import net.minecraft.entity.passive.EntityAmbientCreature; +import net.minecraft.entity.passive.EntityAnimal; +import net.minecraft.entity.passive.EntityWaterMob; + +public enum EnumCreatureType +{ + monster(IMob.class, 70, Material.air, false, false), + creature(EntityAnimal.class, 10, Material.air, true, true), + ambient(EntityAmbientCreature.class, 15, Material.air, true, false), + waterCreature(EntityWaterMob.class, 5, Material.water, true, false); + private final Class creatureClass; + private final int maxNumberOfCreature; + private final Material creatureMaterial; + private final boolean isPeacefulCreature; + private final boolean isAnimal; + + private static final String __OBFID = "CL_00001551"; + + private EnumCreatureType(Class par3Class, int par4, Material par5Material, boolean par6, boolean par7) + { + this.creatureClass = par3Class; + this.maxNumberOfCreature = par4; + this.creatureMaterial = par5Material; + this.isPeacefulCreature = par6; + this.isAnimal = par7; + } + + public Class getCreatureClass() + { + return this.creatureClass; + } + + public int getMaxNumberOfCreature() + { + return this.maxNumberOfCreature; + } + + public Material getCreatureMaterial() + { + return this.creatureMaterial; + } + + public boolean getPeacefulCreature() + { + return this.isPeacefulCreature; + } + + public boolean getAnimal() + { + return this.isAnimal; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/IEntityLivingData.java b/src/main/java/net/minecraft/entity/IEntityLivingData.java new file mode 100644 index 0000000..f111c18 --- /dev/null +++ b/src/main/java/net/minecraft/entity/IEntityLivingData.java @@ -0,0 +1,5 @@ +package net.minecraft.entity; + +public interface IEntityLivingData +{ +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/IEntityMultiPart.java b/src/main/java/net/minecraft/entity/IEntityMultiPart.java new file mode 100644 index 0000000..88bb7a9 --- /dev/null +++ b/src/main/java/net/minecraft/entity/IEntityMultiPart.java @@ -0,0 +1,12 @@ +package net.minecraft.entity; + +import net.minecraft.entity.boss.EntityDragonPart; +import net.minecraft.util.DamageSource; +import net.minecraft.world.World; + +public interface IEntityMultiPart +{ + World func_82194_d(); + + boolean attackEntityFromPart(EntityDragonPart var1, DamageSource var2, float var3); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/IEntityOwnable.java b/src/main/java/net/minecraft/entity/IEntityOwnable.java new file mode 100644 index 0000000..717a503 --- /dev/null +++ b/src/main/java/net/minecraft/entity/IEntityOwnable.java @@ -0,0 +1,8 @@ +package net.minecraft.entity; + +public interface IEntityOwnable +{ + String getOwnerName(); + + Entity getOwner(); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/IMerchant.java b/src/main/java/net/minecraft/entity/IMerchant.java new file mode 100644 index 0000000..a18b215 --- /dev/null +++ b/src/main/java/net/minecraft/entity/IMerchant.java @@ -0,0 +1,24 @@ +package net.minecraft.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.village.MerchantRecipe; +import net.minecraft.village.MerchantRecipeList; + +public interface IMerchant +{ + void setCustomer(EntityPlayer var1); + + EntityPlayer getCustomer(); + + MerchantRecipeList getRecipes(EntityPlayer var1); + + @SideOnly(Side.CLIENT) + void setRecipes(MerchantRecipeList var1); + + void useRecipe(MerchantRecipe var1); + + void func_110297_a_(ItemStack var1); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/INpc.java b/src/main/java/net/minecraft/entity/INpc.java new file mode 100644 index 0000000..2d877be --- /dev/null +++ b/src/main/java/net/minecraft/entity/INpc.java @@ -0,0 +1,7 @@ +package net.minecraft.entity; + +import net.minecraft.entity.passive.IAnimals; + +public interface INpc extends IAnimals +{ +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/IProjectile.java b/src/main/java/net/minecraft/entity/IProjectile.java new file mode 100644 index 0000000..0c07e93 --- /dev/null +++ b/src/main/java/net/minecraft/entity/IProjectile.java @@ -0,0 +1,6 @@ +package net.minecraft.entity; + +public interface IProjectile +{ + void setThrowableHeading(double var1, double var3, double var5, float var7, float var8); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/IRangedAttackMob.java b/src/main/java/net/minecraft/entity/IRangedAttackMob.java new file mode 100644 index 0000000..0d73b94 --- /dev/null +++ b/src/main/java/net/minecraft/entity/IRangedAttackMob.java @@ -0,0 +1,6 @@ +package net.minecraft.entity; + +public interface IRangedAttackMob +{ + void attackEntityWithRangedAttack(EntityLivingBase var1, float var2); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/NpcMerchant.java b/src/main/java/net/minecraft/entity/NpcMerchant.java new file mode 100644 index 0000000..da38248 --- /dev/null +++ b/src/main/java/net/minecraft/entity/NpcMerchant.java @@ -0,0 +1,45 @@ +package net.minecraft.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.InventoryMerchant; +import net.minecraft.item.ItemStack; +import net.minecraft.village.MerchantRecipe; +import net.minecraft.village.MerchantRecipeList; + +@SideOnly(Side.CLIENT) +public class NpcMerchant implements IMerchant +{ + private InventoryMerchant theMerchantInventory; + private EntityPlayer customer; + private MerchantRecipeList recipeList; + private static final String __OBFID = "CL_00001705"; + + public NpcMerchant(EntityPlayer par1EntityPlayer) + { + this.customer = par1EntityPlayer; + this.theMerchantInventory = new InventoryMerchant(par1EntityPlayer, this); + } + + public EntityPlayer getCustomer() + { + return this.customer; + } + + public void setCustomer(EntityPlayer par1EntityPlayer) {} + + public MerchantRecipeList getRecipes(EntityPlayer par1EntityPlayer) + { + return this.recipeList; + } + + public void setRecipes(MerchantRecipeList par1MerchantRecipeList) + { + this.recipeList = par1MerchantRecipeList; + } + + public void useRecipe(MerchantRecipe par1MerchantRecipe) {} + + public void func_110297_a_(ItemStack par1ItemStack) {} +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/SharedMonsterAttributes.java b/src/main/java/net/minecraft/entity/SharedMonsterAttributes.java new file mode 100644 index 0000000..a2d6f1c --- /dev/null +++ b/src/main/java/net/minecraft/entity/SharedMonsterAttributes.java @@ -0,0 +1,126 @@ +package net.minecraft.entity; + +import java.util.Collection; +import java.util.Iterator; +import java.util.UUID; +import net.minecraft.entity.ai.attributes.AttributeModifier; +import net.minecraft.entity.ai.attributes.BaseAttributeMap; +import net.minecraft.entity.ai.attributes.IAttribute; +import net.minecraft.entity.ai.attributes.IAttributeInstance; +import net.minecraft.entity.ai.attributes.RangedAttribute; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class SharedMonsterAttributes +{ + private static final Logger logger = LogManager.getLogger(); + public static final IAttribute maxHealth = (new RangedAttribute("generic.maxHealth", 20.0D, 0.0D, Double.MAX_VALUE)).setDescription("Max Health").setShouldWatch(true); + public static final IAttribute followRange = (new RangedAttribute("generic.followRange", 32.0D, 0.0D, 2048.0D)).setDescription("Follow Range"); + public static final IAttribute knockbackResistance = (new RangedAttribute("generic.knockbackResistance", 0.0D, 0.0D, 1.0D)).setDescription("Knockback Resistance"); + public static final IAttribute movementSpeed = (new RangedAttribute("generic.movementSpeed", 0.699999988079071D, 0.0D, Double.MAX_VALUE)).setDescription("Movement Speed").setShouldWatch(true); + public static final IAttribute attackDamage = new RangedAttribute("generic.attackDamage", 2.0D, 0.0D, Double.MAX_VALUE); + private static final String __OBFID = "CL_00001695"; + + public static NBTTagList writeBaseAttributeMapToNBT(BaseAttributeMap par0BaseAttributeMap) + { + NBTTagList nbttaglist = new NBTTagList(); + Iterator iterator = par0BaseAttributeMap.getAllAttributes().iterator(); + + while (iterator.hasNext()) + { + IAttributeInstance iattributeinstance = (IAttributeInstance)iterator.next(); + nbttaglist.appendTag(writeAttributeInstanceToNBT(iattributeinstance)); + } + + return nbttaglist; + } + + private static NBTTagCompound writeAttributeInstanceToNBT(IAttributeInstance par0AttributeInstance) + { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + IAttribute iattribute = par0AttributeInstance.getAttribute(); + nbttagcompound.setString("Name", iattribute.getAttributeUnlocalizedName()); + nbttagcompound.setDouble("Base", par0AttributeInstance.getBaseValue()); + Collection collection = par0AttributeInstance.func_111122_c(); + + if (collection != null && !collection.isEmpty()) + { + NBTTagList nbttaglist = new NBTTagList(); + Iterator iterator = collection.iterator(); + + while (iterator.hasNext()) + { + AttributeModifier attributemodifier = (AttributeModifier)iterator.next(); + + if (attributemodifier.isSaved()) + { + nbttaglist.appendTag(writeAttributeModifierToNBT(attributemodifier)); + } + } + + nbttagcompound.setTag("Modifiers", nbttaglist); + } + + return nbttagcompound; + } + + private static NBTTagCompound writeAttributeModifierToNBT(AttributeModifier par0AttributeModifier) + { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + nbttagcompound.setString("Name", par0AttributeModifier.getName()); + nbttagcompound.setDouble("Amount", par0AttributeModifier.getAmount()); + nbttagcompound.setInteger("Operation", par0AttributeModifier.getOperation()); + nbttagcompound.setLong("UUIDMost", par0AttributeModifier.getID().getMostSignificantBits()); + nbttagcompound.setLong("UUIDLeast", par0AttributeModifier.getID().getLeastSignificantBits()); + return nbttagcompound; + } + + public static void func_151475_a(BaseAttributeMap p_151475_0_, NBTTagList p_151475_1_) + { + for (int i = 0; i < p_151475_1_.tagCount(); ++i) + { + NBTTagCompound nbttagcompound = p_151475_1_.getCompoundTagAt(i); + IAttributeInstance iattributeinstance = p_151475_0_.getAttributeInstanceByName(nbttagcompound.getString("Name")); + + if (iattributeinstance != null) + { + applyModifiersToAttributeInstance(iattributeinstance, nbttagcompound); + } + else + { + logger.warn("Ignoring unknown attribute \'" + nbttagcompound.getString("Name") + "\'"); + } + } + } + + private static void applyModifiersToAttributeInstance(IAttributeInstance par0AttributeInstance, NBTTagCompound par1NBTTagCompound) + { + par0AttributeInstance.setBaseValue(par1NBTTagCompound.getDouble("Base")); + + if (par1NBTTagCompound.hasKey("Modifiers", 9)) + { + NBTTagList nbttaglist = par1NBTTagCompound.getTagList("Modifiers", 10); + + for (int i = 0; i < nbttaglist.tagCount(); ++i) + { + AttributeModifier attributemodifier = readAttributeModifierFromNBT(nbttaglist.getCompoundTagAt(i)); + AttributeModifier attributemodifier1 = par0AttributeInstance.getModifier(attributemodifier.getID()); + + if (attributemodifier1 != null) + { + par0AttributeInstance.removeModifier(attributemodifier1); + } + + par0AttributeInstance.applyModifier(attributemodifier); + } + } + } + + public static AttributeModifier readAttributeModifierFromNBT(NBTTagCompound par0NBTTagCompound) + { + UUID uuid = new UUID(par0NBTTagCompound.getLong("UUIDMost"), par0NBTTagCompound.getLong("UUIDLeast")); + return new AttributeModifier(uuid, par0NBTTagCompound.getString("Name"), par0NBTTagCompound.getDouble("Amount"), par0NBTTagCompound.getInteger("Operation")); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAIArrowAttack.java b/src/main/java/net/minecraft/entity/ai/EntityAIArrowAttack.java new file mode 100644 index 0000000..6a62dae --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAIArrowAttack.java @@ -0,0 +1,130 @@ +package net.minecraft.entity.ai; + +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IRangedAttackMob; +import net.minecraft.util.MathHelper; + +public class EntityAIArrowAttack extends EntityAIBase +{ + private final EntityLiving entityHost; + private final IRangedAttackMob rangedAttackEntityHost; + private EntityLivingBase attackTarget; + private int rangedAttackTime; + private double entityMoveSpeed; + private int field_75318_f; + private int field_96561_g; + private int maxRangedAttackTime; + private float field_96562_i; + private float field_82642_h; + private static final String __OBFID = "CL_00001609"; + + public EntityAIArrowAttack(IRangedAttackMob par1IRangedAttackMob, double par2, int par4, float par5) + { + this(par1IRangedAttackMob, par2, par4, par4, par5); + } + + public EntityAIArrowAttack(IRangedAttackMob par1IRangedAttackMob, double par2, int par4, int par5, float par6) + { + this.rangedAttackTime = -1; + + if (!(par1IRangedAttackMob instanceof EntityLivingBase)) + { + throw new IllegalArgumentException("ArrowAttackGoal requires Mob implements RangedAttackMob"); + } + else + { + this.rangedAttackEntityHost = par1IRangedAttackMob; + this.entityHost = (EntityLiving)par1IRangedAttackMob; + this.entityMoveSpeed = par2; + this.field_96561_g = par4; + this.maxRangedAttackTime = par5; + this.field_96562_i = par6; + this.field_82642_h = par6 * par6; + this.setMutexBits(3); + } + } + + public boolean shouldExecute() + { + EntityLivingBase entitylivingbase = this.entityHost.getAttackTarget(); + + if (entitylivingbase == null) + { + return false; + } + else + { + this.attackTarget = entitylivingbase; + return true; + } + } + + public boolean continueExecuting() + { + return this.shouldExecute() || !this.entityHost.getNavigator().noPath(); + } + + public void resetTask() + { + this.attackTarget = null; + this.field_75318_f = 0; + this.rangedAttackTime = -1; + } + + public void updateTask() + { + double d0 = this.entityHost.getDistanceSq(this.attackTarget.posX, this.attackTarget.boundingBox.minY, this.attackTarget.posZ); + boolean flag = this.entityHost.getEntitySenses().canSee(this.attackTarget); + + if (flag) + { + ++this.field_75318_f; + } + else + { + this.field_75318_f = 0; + } + + if (d0 <= (double)this.field_82642_h && this.field_75318_f >= 20) + { + this.entityHost.getNavigator().clearPathEntity(); + } + else + { + this.entityHost.getNavigator().tryMoveToEntityLiving(this.attackTarget, this.entityMoveSpeed); + } + + this.entityHost.getLookHelper().setLookPositionWithEntity(this.attackTarget, 30.0F, 30.0F); + float f; + + if (--this.rangedAttackTime == 0) + { + if (d0 > (double)this.field_82642_h || !flag) + { + return; + } + + f = MathHelper.sqrt_double(d0) / this.field_96562_i; + float f1 = f; + + if (f < 0.1F) + { + f1 = 0.1F; + } + + if (f1 > 1.0F) + { + f1 = 1.0F; + } + + this.rangedAttackEntityHost.attackEntityWithRangedAttack(this.attackTarget, f1); + this.rangedAttackTime = MathHelper.floor_float(f * (float)(this.maxRangedAttackTime - this.field_96561_g) + (float)this.field_96561_g); + } + else if (this.rangedAttackTime < 0) + { + f = MathHelper.sqrt_double(d0) / this.field_96562_i; + this.rangedAttackTime = MathHelper.floor_float(f * (float)(this.maxRangedAttackTime - this.field_96561_g) + (float)this.field_96561_g); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAIAttackOnCollide.java b/src/main/java/net/minecraft/entity/ai/EntityAIAttackOnCollide.java new file mode 100644 index 0000000..b9b9dab --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAIAttackOnCollide.java @@ -0,0 +1,151 @@ +package net.minecraft.entity.ai; + +import net.minecraft.entity.EntityCreature; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.pathfinding.PathEntity; +import net.minecraft.pathfinding.PathPoint; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class EntityAIAttackOnCollide extends EntityAIBase +{ + World worldObj; + EntityCreature attacker; + int attackTick; + double speedTowardsTarget; + boolean longMemory; + PathEntity entityPathEntity; + Class classTarget; + private int field_75445_i; + private double field_151497_i; + private double field_151495_j; + private double field_151496_k; + private static final String __OBFID = "CL_00001595"; + + private int failedPathFindingPenalty; + + public EntityAIAttackOnCollide(EntityCreature par1EntityCreature, Class par2Class, double par3, boolean par5) + { + this(par1EntityCreature, par3, par5); + this.classTarget = par2Class; + } + + public EntityAIAttackOnCollide(EntityCreature par1EntityCreature, double par2, boolean par4) + { + this.attacker = par1EntityCreature; + this.worldObj = par1EntityCreature.worldObj; + this.speedTowardsTarget = par2; + this.longMemory = par4; + this.setMutexBits(3); + } + + public boolean shouldExecute() + { + EntityLivingBase entitylivingbase = this.attacker.getAttackTarget(); + + if (entitylivingbase == null) + { + return false; + } + else if (!entitylivingbase.isEntityAlive()) + { + return false; + } + else if (this.classTarget != null && !this.classTarget.isAssignableFrom(entitylivingbase.getClass())) + { + return false; + } + else + { + if (-- this.field_75445_i <= 0) + { + this.entityPathEntity = this.attacker.getNavigator().getPathToEntityLiving(entitylivingbase); + this.field_75445_i = 4 + this.attacker.getRNG().nextInt(7); + return this.entityPathEntity != null; + } + else + { + return true; + } + } + } + + public boolean continueExecuting() + { + EntityLivingBase entitylivingbase = this.attacker.getAttackTarget(); + return entitylivingbase == null ? false : (!entitylivingbase.isEntityAlive() ? false : (!this.longMemory ? !this.attacker.getNavigator().noPath() : this.attacker.isWithinHomeDistance(MathHelper.floor_double(entitylivingbase.posX), MathHelper.floor_double(entitylivingbase.posY), MathHelper.floor_double(entitylivingbase.posZ)))); + } + + public void startExecuting() + { + this.attacker.getNavigator().setPath(this.entityPathEntity, this.speedTowardsTarget); + this.field_75445_i = 0; + } + + public void resetTask() + { + this.attacker.getNavigator().clearPathEntity(); + } + + public void updateTask() + { + EntityLivingBase entitylivingbase = this.attacker.getAttackTarget(); + this.attacker.getLookHelper().setLookPositionWithEntity(entitylivingbase, 30.0F, 30.0F); + double d0 = this.attacker.getDistanceSq(entitylivingbase.posX, entitylivingbase.boundingBox.minY, entitylivingbase.posZ); + double d1 = (double)(this.attacker.width * 2.0F * this.attacker.width * 2.0F + entitylivingbase.width); + --this.field_75445_i; + + if ((this.longMemory || this.attacker.getEntitySenses().canSee(entitylivingbase)) && this.field_75445_i <= 0 && (this.field_151497_i == 0.0D && this.field_151495_j == 0.0D && this.field_151496_k == 0.0D || entitylivingbase.getDistanceSq(this.field_151497_i, this.field_151495_j, this.field_151496_k) >= 1.0D || this.attacker.getRNG().nextFloat() < 0.05F)) + { + this.field_151497_i = entitylivingbase.posX; + this.field_151495_j = entitylivingbase.boundingBox.minY; + this.field_151496_k = entitylivingbase.posZ; + this.field_75445_i = failedPathFindingPenalty + 4 + this.attacker.getRNG().nextInt(7); + + if (this.attacker.getNavigator().getPath() != null) + { + PathPoint finalPathPoint = this.attacker.getNavigator().getPath().getFinalPathPoint(); + if (finalPathPoint != null && entitylivingbase.getDistanceSq(finalPathPoint.xCoord, finalPathPoint.yCoord, finalPathPoint.zCoord) < 1) + { + failedPathFindingPenalty = 0; + } + else + { + failedPathFindingPenalty += 10; + } + } + else + { + failedPathFindingPenalty += 10; + } + + if (d0 > 1024.0D) + { + this.field_75445_i += 10; + } + else if (d0 > 256.0D) + { + this.field_75445_i += 5; + } + + if (!this.attacker.getNavigator().tryMoveToEntityLiving(entitylivingbase, this.speedTowardsTarget)) + { + this.field_75445_i += 15; + } + } + + this.attackTick = Math.max(this.attackTick - 1, 0); + + if (d0 <= d1 && this.attackTick <= 20) + { + this.attackTick = 20; + + if (this.attacker.getHeldItem() != null) + { + this.attacker.swingItem(); + } + + this.attacker.attackEntityAsMob(entitylivingbase); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAIAvoidEntity.java b/src/main/java/net/minecraft/entity/ai/EntityAIAvoidEntity.java new file mode 100644 index 0000000..4d8e22e --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAIAvoidEntity.java @@ -0,0 +1,115 @@ +package net.minecraft.entity.ai; + +import java.util.List; +import net.minecraft.command.IEntitySelector; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityCreature; +import net.minecraft.entity.passive.EntityTameable; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.pathfinding.PathEntity; +import net.minecraft.pathfinding.PathNavigate; +import net.minecraft.util.Vec3; + +public class EntityAIAvoidEntity extends EntityAIBase +{ + public final IEntitySelector field_98218_a = new IEntitySelector() + { + private static final String __OBFID = "CL_00001575"; + public boolean isEntityApplicable(Entity par1Entity) + { + return par1Entity.isEntityAlive() && EntityAIAvoidEntity.this.theEntity.getEntitySenses().canSee(par1Entity); + } + }; + private EntityCreature theEntity; + private double farSpeed; + private double nearSpeed; + private Entity closestLivingEntity; + private float distanceFromEntity; + private PathEntity entityPathEntity; + private PathNavigate entityPathNavigate; + private Class targetEntityClass; + private static final String __OBFID = "CL_00001574"; + + public EntityAIAvoidEntity(EntityCreature par1EntityCreature, Class par2Class, float par3, double par4, double par6) + { + this.theEntity = par1EntityCreature; + this.targetEntityClass = par2Class; + this.distanceFromEntity = par3; + this.farSpeed = par4; + this.nearSpeed = par6; + this.entityPathNavigate = par1EntityCreature.getNavigator(); + this.setMutexBits(1); + } + + public boolean shouldExecute() + { + if (this.targetEntityClass == EntityPlayer.class) + { + if (this.theEntity instanceof EntityTameable && ((EntityTameable)this.theEntity).isTamed()) + { + return false; + } + + this.closestLivingEntity = this.theEntity.worldObj.getClosestPlayerToEntity(this.theEntity, (double)this.distanceFromEntity); + + if (this.closestLivingEntity == null) + { + return false; + } + } + else + { + List list = this.theEntity.worldObj.selectEntitiesWithinAABB(this.targetEntityClass, this.theEntity.boundingBox.expand((double)this.distanceFromEntity, 3.0D, (double)this.distanceFromEntity), this.field_98218_a); + + if (list.isEmpty()) + { + return false; + } + + this.closestLivingEntity = (Entity)list.get(0); + } + + Vec3 vec3 = RandomPositionGenerator.findRandomTargetBlockAwayFrom(this.theEntity, 16, 7, this.theEntity.worldObj.getWorldVec3Pool().getVecFromPool(this.closestLivingEntity.posX, this.closestLivingEntity.posY, this.closestLivingEntity.posZ)); + + if (vec3 == null) + { + return false; + } + else if (this.closestLivingEntity.getDistanceSq(vec3.xCoord, vec3.yCoord, vec3.zCoord) < this.closestLivingEntity.getDistanceSqToEntity(this.theEntity)) + { + return false; + } + else + { + this.entityPathEntity = this.entityPathNavigate.getPathToXYZ(vec3.xCoord, vec3.yCoord, vec3.zCoord); + return this.entityPathEntity == null ? false : this.entityPathEntity.isDestinationSame(vec3); + } + } + + public boolean continueExecuting() + { + return !this.entityPathNavigate.noPath(); + } + + public void startExecuting() + { + this.entityPathNavigate.setPath(this.entityPathEntity, this.farSpeed); + } + + public void resetTask() + { + this.closestLivingEntity = null; + } + + public void updateTask() + { + if (this.theEntity.getDistanceSqToEntity(this.closestLivingEntity) < 49.0D) + { + this.theEntity.getNavigator().setSpeed(this.nearSpeed); + } + else + { + this.theEntity.getNavigator().setSpeed(this.farSpeed); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAIBase.java b/src/main/java/net/minecraft/entity/ai/EntityAIBase.java new file mode 100644 index 0000000..635140b --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAIBase.java @@ -0,0 +1,35 @@ +package net.minecraft.entity.ai; + +public abstract class EntityAIBase +{ + private int mutexBits; + private static final String __OBFID = "CL_00001587"; + + public abstract boolean shouldExecute(); + + public boolean continueExecuting() + { + return this.shouldExecute(); + } + + public boolean isInterruptible() + { + return true; + } + + public void startExecuting() {} + + public void resetTask() {} + + public void updateTask() {} + + public void setMutexBits(int par1) + { + this.mutexBits = par1; + } + + public int getMutexBits() + { + return this.mutexBits; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAIBeg.java b/src/main/java/net/minecraft/entity/ai/EntityAIBeg.java new file mode 100644 index 0000000..72f6287 --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAIBeg.java @@ -0,0 +1,60 @@ +package net.minecraft.entity.ai; + +import net.minecraft.entity.passive.EntityWolf; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class EntityAIBeg extends EntityAIBase +{ + private EntityWolf theWolf; + private EntityPlayer thePlayer; + private World worldObject; + private float minPlayerDistance; + private int field_75384_e; + private static final String __OBFID = "CL_00001576"; + + public EntityAIBeg(EntityWolf par1EntityWolf, float par2) + { + this.theWolf = par1EntityWolf; + this.worldObject = par1EntityWolf.worldObj; + this.minPlayerDistance = par2; + this.setMutexBits(2); + } + + public boolean shouldExecute() + { + this.thePlayer = this.worldObject.getClosestPlayerToEntity(this.theWolf, (double)this.minPlayerDistance); + return this.thePlayer == null ? false : this.hasPlayerGotBoneInHand(this.thePlayer); + } + + public boolean continueExecuting() + { + return !this.thePlayer.isEntityAlive() ? false : (this.theWolf.getDistanceSqToEntity(this.thePlayer) > (double)(this.minPlayerDistance * this.minPlayerDistance) ? false : this.field_75384_e > 0 && this.hasPlayerGotBoneInHand(this.thePlayer)); + } + + public void startExecuting() + { + this.theWolf.func_70918_i(true); + this.field_75384_e = 40 + this.theWolf.getRNG().nextInt(40); + } + + public void resetTask() + { + this.theWolf.func_70918_i(false); + this.thePlayer = null; + } + + public void updateTask() + { + this.theWolf.getLookHelper().setLookPosition(this.thePlayer.posX, this.thePlayer.posY + (double)this.thePlayer.getEyeHeight(), this.thePlayer.posZ, 10.0F, (float)this.theWolf.getVerticalFaceSpeed()); + --this.field_75384_e; + } + + private boolean hasPlayerGotBoneInHand(EntityPlayer par1EntityPlayer) + { + ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem(); + return itemstack == null ? false : (!this.theWolf.isTamed() && itemstack.getItem() == Items.bone ? true : this.theWolf.isBreedingItem(itemstack)); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAIBreakDoor.java b/src/main/java/net/minecraft/entity/ai/EntityAIBreakDoor.java new file mode 100644 index 0000000..8039134 --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAIBreakDoor.java @@ -0,0 +1,66 @@ +package net.minecraft.entity.ai; + +import net.minecraft.block.Block; +import net.minecraft.entity.EntityLiving; +import net.minecraft.world.EnumDifficulty; + +public class EntityAIBreakDoor extends EntityAIDoorInteract +{ + private int breakingTime; + private int field_75358_j = -1; + private static final String __OBFID = "CL_00001577"; + + public EntityAIBreakDoor(EntityLiving par1EntityLiving) + { + super(par1EntityLiving); + } + + public boolean shouldExecute() + { + return !super.shouldExecute() ? false : (!this.theEntity.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing") ? false : !this.field_151504_e.func_150015_f(this.theEntity.worldObj, this.entityPosX, this.entityPosY, this.entityPosZ)); + } + + public void startExecuting() + { + super.startExecuting(); + this.breakingTime = 0; + } + + public boolean continueExecuting() + { + double d0 = this.theEntity.getDistanceSq((double)this.entityPosX, (double)this.entityPosY, (double)this.entityPosZ); + return this.breakingTime <= 240 && !this.field_151504_e.func_150015_f(this.theEntity.worldObj, this.entityPosX, this.entityPosY, this.entityPosZ) && d0 < 4.0D; + } + + public void resetTask() + { + super.resetTask(); + this.theEntity.worldObj.destroyBlockInWorldPartially(this.theEntity.getEntityId(), this.entityPosX, this.entityPosY, this.entityPosZ, -1); + } + + public void updateTask() + { + super.updateTask(); + + if (this.theEntity.getRNG().nextInt(20) == 0) + { + this.theEntity.worldObj.playAuxSFX(1010, this.entityPosX, this.entityPosY, this.entityPosZ, 0); + } + + ++this.breakingTime; + int i = (int)((float)this.breakingTime / 240.0F * 10.0F); + + if (i != this.field_75358_j) + { + this.theEntity.worldObj.destroyBlockInWorldPartially(this.theEntity.getEntityId(), this.entityPosX, this.entityPosY, this.entityPosZ, i); + this.field_75358_j = i; + } + + if (this.breakingTime == 240 && this.theEntity.worldObj.difficultySetting == EnumDifficulty.HARD) + { + this.theEntity.worldObj.setBlockToAir(this.entityPosX, this.entityPosY, this.entityPosZ); + this.theEntity.worldObj.playAuxSFX(1012, this.entityPosX, this.entityPosY, this.entityPosZ, 0); + this.theEntity.worldObj.playAuxSFX(2001, this.entityPosX, this.entityPosY, this.entityPosZ, Block.getIdFromBlock(this.field_151504_e)); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAIControlledByPlayer.java b/src/main/java/net/minecraft/entity/ai/EntityAIControlledByPlayer.java new file mode 100644 index 0000000..19a3aae --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAIControlledByPlayer.java @@ -0,0 +1,193 @@ +package net.minecraft.entity.ai; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockSlab; +import net.minecraft.block.material.Material; +import net.minecraft.entity.EntityCreature; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.pathfinding.PathFinder; +import net.minecraft.pathfinding.PathPoint; +import net.minecraft.util.MathHelper; + +public class EntityAIControlledByPlayer extends EntityAIBase +{ + private final EntityLiving thisEntity; + private final float maxSpeed; + private float currentSpeed; + private boolean speedBoosted; + private int speedBoostTime; + private int maxSpeedBoostTime; + private static final String __OBFID = "CL_00001580"; + + public EntityAIControlledByPlayer(EntityLiving par1EntityLiving, float par2) + { + this.thisEntity = par1EntityLiving; + this.maxSpeed = par2; + this.setMutexBits(7); + } + + public void startExecuting() + { + this.currentSpeed = 0.0F; + } + + public void resetTask() + { + this.speedBoosted = false; + this.currentSpeed = 0.0F; + } + + public boolean shouldExecute() + { + return this.thisEntity.isEntityAlive() && this.thisEntity.riddenByEntity != null && this.thisEntity.riddenByEntity instanceof EntityPlayer && (this.speedBoosted || this.thisEntity.canBeSteered()); + } + + public void updateTask() + { + EntityPlayer entityplayer = (EntityPlayer)this.thisEntity.riddenByEntity; + EntityCreature entitycreature = (EntityCreature)this.thisEntity; + float f = MathHelper.wrapAngleTo180_float(entityplayer.rotationYaw - this.thisEntity.rotationYaw) * 0.5F; + + if (f > 5.0F) + { + f = 5.0F; + } + + if (f < -5.0F) + { + f = -5.0F; + } + + this.thisEntity.rotationYaw = MathHelper.wrapAngleTo180_float(this.thisEntity.rotationYaw + f); + + if (this.currentSpeed < this.maxSpeed) + { + this.currentSpeed += (this.maxSpeed - this.currentSpeed) * 0.01F; + } + + if (this.currentSpeed > this.maxSpeed) + { + this.currentSpeed = this.maxSpeed; + } + + int i = MathHelper.floor_double(this.thisEntity.posX); + int j = MathHelper.floor_double(this.thisEntity.posY); + int k = MathHelper.floor_double(this.thisEntity.posZ); + float f1 = this.currentSpeed; + + if (this.speedBoosted) + { + if (this.speedBoostTime++ > this.maxSpeedBoostTime) + { + this.speedBoosted = false; + } + + f1 += f1 * 1.15F * MathHelper.sin((float)this.speedBoostTime / (float)this.maxSpeedBoostTime * (float)Math.PI); + } + + float f2 = 0.91F; + + if (this.thisEntity.onGround) + { + f2 = this.thisEntity.worldObj.getBlock(MathHelper.floor_float((float)i), MathHelper.floor_float((float)j) - 1, MathHelper.floor_float((float)k)).slipperiness * 0.91F; + } + + float f3 = 0.16277136F / (f2 * f2 * f2); + float f4 = MathHelper.sin(entitycreature.rotationYaw * (float)Math.PI / 180.0F); + float f5 = MathHelper.cos(entitycreature.rotationYaw * (float)Math.PI / 180.0F); + float f6 = entitycreature.getAIMoveSpeed() * f3; + float f7 = Math.max(f1, 1.0F); + f7 = f6 / f7; + float f8 = f1 * f7; + float f9 = -(f8 * f4); + float f10 = f8 * f5; + + if (MathHelper.abs(f9) > MathHelper.abs(f10)) + { + if (f9 < 0.0F) + { + f9 -= this.thisEntity.width / 2.0F; + } + + if (f9 > 0.0F) + { + f9 += this.thisEntity.width / 2.0F; + } + + f10 = 0.0F; + } + else + { + f9 = 0.0F; + + if (f10 < 0.0F) + { + f10 -= this.thisEntity.width / 2.0F; + } + + if (f10 > 0.0F) + { + f10 += this.thisEntity.width / 2.0F; + } + } + + int l = MathHelper.floor_double(this.thisEntity.posX + (double)f9); + int i1 = MathHelper.floor_double(this.thisEntity.posZ + (double)f10); + PathPoint pathpoint = new PathPoint(MathHelper.floor_float(this.thisEntity.width + 1.0F), MathHelper.floor_float(this.thisEntity.height + entityplayer.height + 1.0F), MathHelper.floor_float(this.thisEntity.width + 1.0F)); + + if (i != l || k != i1) + { + Block block = this.thisEntity.worldObj.getBlock(i, j, k); + boolean flag = !this.func_151498_a(block) && (block.getMaterial() != Material.air || !this.func_151498_a(this.thisEntity.worldObj.getBlock(i, j - 1, k))); + + if (flag && PathFinder.func_82565_a(this.thisEntity, l, j, i1, pathpoint, false, false, true) == 0 && PathFinder.func_82565_a(this.thisEntity, i, j + 1, k, pathpoint, false, false, true) == 1 && PathFinder.func_82565_a(this.thisEntity, l, j + 1, i1, pathpoint, false, false, true) == 1) + { + entitycreature.getJumpHelper().setJumping(); + } + } + + if (!entityplayer.capabilities.isCreativeMode && this.currentSpeed >= this.maxSpeed * 0.5F && this.thisEntity.getRNG().nextFloat() < 0.006F && !this.speedBoosted) + { + ItemStack itemstack = entityplayer.getHeldItem(); + + if (itemstack != null && itemstack.getItem() == Items.carrot_on_a_stick) + { + itemstack.damageItem(1, entityplayer); + + if (itemstack.stackSize == 0) + { + ItemStack itemstack1 = new ItemStack(Items.fishing_rod); + itemstack1.setTagCompound(itemstack.stackTagCompound); + entityplayer.inventory.mainInventory[entityplayer.inventory.currentItem] = itemstack1; + } + } + } + + this.thisEntity.moveEntityWithHeading(0.0F, f1); + } + + private boolean func_151498_a(Block p_151498_1_) + { + return p_151498_1_.getRenderType() == 10 || p_151498_1_ instanceof BlockSlab; + } + + public boolean isSpeedBoosted() + { + return this.speedBoosted; + } + + public void boostSpeed() + { + this.speedBoosted = true; + this.speedBoostTime = 0; + this.maxSpeedBoostTime = this.thisEntity.getRNG().nextInt(841) + 140; + } + + public boolean isControlledByPlayer() + { + return !this.isSpeedBoosted() && this.currentSpeed > this.maxSpeed * 0.3F; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAICreeperSwell.java b/src/main/java/net/minecraft/entity/ai/EntityAICreeperSwell.java new file mode 100644 index 0000000..0ffd0e4 --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAICreeperSwell.java @@ -0,0 +1,54 @@ +package net.minecraft.entity.ai; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.monster.EntityCreeper; + +public class EntityAICreeperSwell extends EntityAIBase +{ + EntityCreeper swellingCreeper; + EntityLivingBase creeperAttackTarget; + private static final String __OBFID = "CL_00001614"; + + public EntityAICreeperSwell(EntityCreeper par1EntityCreeper) + { + this.swellingCreeper = par1EntityCreeper; + this.setMutexBits(1); + } + + public boolean shouldExecute() + { + EntityLivingBase entitylivingbase = this.swellingCreeper.getAttackTarget(); + return this.swellingCreeper.getCreeperState() > 0 || entitylivingbase != null && this.swellingCreeper.getDistanceSqToEntity(entitylivingbase) < 9.0D; + } + + public void startExecuting() + { + this.swellingCreeper.getNavigator().clearPathEntity(); + this.creeperAttackTarget = this.swellingCreeper.getAttackTarget(); + } + + public void resetTask() + { + this.creeperAttackTarget = null; + } + + public void updateTask() + { + if (this.creeperAttackTarget == null) + { + this.swellingCreeper.setCreeperState(-1); + } + else if (this.swellingCreeper.getDistanceSqToEntity(this.creeperAttackTarget) > 49.0D) + { + this.swellingCreeper.setCreeperState(-1); + } + else if (!this.swellingCreeper.getEntitySenses().canSee(this.creeperAttackTarget)) + { + this.swellingCreeper.setCreeperState(-1); + } + else + { + this.swellingCreeper.setCreeperState(1); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAIDefendVillage.java b/src/main/java/net/minecraft/entity/ai/EntityAIDefendVillage.java new file mode 100644 index 0000000..a4a5c9a --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAIDefendVillage.java @@ -0,0 +1,56 @@ +package net.minecraft.entity.ai; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.monster.EntityIronGolem; +import net.minecraft.village.Village; + +public class EntityAIDefendVillage extends EntityAITarget +{ + EntityIronGolem irongolem; + EntityLivingBase villageAgressorTarget; + private static final String __OBFID = "CL_00001618"; + + public EntityAIDefendVillage(EntityIronGolem par1EntityIronGolem) + { + super(par1EntityIronGolem, false, true); + this.irongolem = par1EntityIronGolem; + this.setMutexBits(1); + } + + public boolean shouldExecute() + { + Village village = this.irongolem.getVillage(); + + if (village == null) + { + return false; + } + else + { + this.villageAgressorTarget = village.findNearestVillageAggressor(this.irongolem); + + if (!this.isSuitableTarget(this.villageAgressorTarget, false)) + { + if (this.taskOwner.getRNG().nextInt(20) == 0) + { + this.villageAgressorTarget = village.func_82685_c(this.irongolem); + return this.isSuitableTarget(this.villageAgressorTarget, false); + } + else + { + return false; + } + } + else + { + return true; + } + } + } + + public void startExecuting() + { + this.irongolem.setAttackTarget(this.villageAgressorTarget); + super.startExecuting(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAIDoorInteract.java b/src/main/java/net/minecraft/entity/ai/EntityAIDoorInteract.java new file mode 100644 index 0000000..7dade83 --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAIDoorInteract.java @@ -0,0 +1,102 @@ +package net.minecraft.entity.ai; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockDoor; +import net.minecraft.entity.EntityLiving; +import net.minecraft.init.Blocks; +import net.minecraft.pathfinding.PathEntity; +import net.minecraft.pathfinding.PathNavigate; +import net.minecraft.pathfinding.PathPoint; +import net.minecraft.util.MathHelper; + +public abstract class EntityAIDoorInteract extends EntityAIBase +{ + protected EntityLiving theEntity; + protected int entityPosX; + protected int entityPosY; + protected int entityPosZ; + protected BlockDoor field_151504_e; + boolean hasStoppedDoorInteraction; + float entityPositionX; + float entityPositionZ; + private static final String __OBFID = "CL_00001581"; + + public EntityAIDoorInteract(EntityLiving par1EntityLiving) + { + this.theEntity = par1EntityLiving; + } + + public boolean shouldExecute() + { + if (!this.theEntity.isCollidedHorizontally) + { + return false; + } + else + { + PathNavigate pathnavigate = this.theEntity.getNavigator(); + PathEntity pathentity = pathnavigate.getPath(); + + if (pathentity != null && !pathentity.isFinished() && pathnavigate.getCanBreakDoors()) + { + for (int i = 0; i < Math.min(pathentity.getCurrentPathIndex() + 2, pathentity.getCurrentPathLength()); ++i) + { + PathPoint pathpoint = pathentity.getPathPointFromIndex(i); + this.entityPosX = pathpoint.xCoord; + this.entityPosY = pathpoint.yCoord + 1; + this.entityPosZ = pathpoint.zCoord; + + if (this.theEntity.getDistanceSq((double)this.entityPosX, this.theEntity.posY, (double)this.entityPosZ) <= 2.25D) + { + this.field_151504_e = this.func_151503_a(this.entityPosX, this.entityPosY, this.entityPosZ); + + if (this.field_151504_e != null) + { + return true; + } + } + } + + this.entityPosX = MathHelper.floor_double(this.theEntity.posX); + this.entityPosY = MathHelper.floor_double(this.theEntity.posY + 1.0D); + this.entityPosZ = MathHelper.floor_double(this.theEntity.posZ); + this.field_151504_e = this.func_151503_a(this.entityPosX, this.entityPosY, this.entityPosZ); + return this.field_151504_e != null; + } + else + { + return false; + } + } + } + + public boolean continueExecuting() + { + return !this.hasStoppedDoorInteraction; + } + + public void startExecuting() + { + this.hasStoppedDoorInteraction = false; + this.entityPositionX = (float)((double)((float)this.entityPosX + 0.5F) - this.theEntity.posX); + this.entityPositionZ = (float)((double)((float)this.entityPosZ + 0.5F) - this.theEntity.posZ); + } + + public void updateTask() + { + float f = (float)((double)((float)this.entityPosX + 0.5F) - this.theEntity.posX); + float f1 = (float)((double)((float)this.entityPosZ + 0.5F) - this.theEntity.posZ); + float f2 = this.entityPositionX * f + this.entityPositionZ * f1; + + if (f2 < 0.0F) + { + this.hasStoppedDoorInteraction = true; + } + } + + private BlockDoor func_151503_a(int p_151503_1_, int p_151503_2_, int p_151503_3_) + { + Block block = this.theEntity.worldObj.getBlock(p_151503_1_, p_151503_2_, p_151503_3_); + return block != Blocks.wooden_door ? null : (BlockDoor)block; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAIEatGrass.java b/src/main/java/net/minecraft/entity/ai/EntityAIEatGrass.java new file mode 100644 index 0000000..1834817 --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAIEatGrass.java @@ -0,0 +1,91 @@ +package net.minecraft.entity.ai; + +import net.minecraft.block.Block; +import net.minecraft.entity.EntityLiving; +import net.minecraft.init.Blocks; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class EntityAIEatGrass extends EntityAIBase +{ + private EntityLiving field_151500_b; + private World field_151501_c; + int field_151502_a; + private static final String __OBFID = "CL_00001582"; + + public EntityAIEatGrass(EntityLiving p_i45314_1_) + { + this.field_151500_b = p_i45314_1_; + this.field_151501_c = p_i45314_1_.worldObj; + this.setMutexBits(7); + } + + public boolean shouldExecute() + { + if (this.field_151500_b.getRNG().nextInt(this.field_151500_b.isChild() ? 50 : 1000) != 0) + { + return false; + } + else + { + int i = MathHelper.floor_double(this.field_151500_b.posX); + int j = MathHelper.floor_double(this.field_151500_b.posY); + int k = MathHelper.floor_double(this.field_151500_b.posZ); + return this.field_151501_c.getBlock(i, j, k) == Blocks.tallgrass && this.field_151501_c.getBlockMetadata(i, j, k) == 1 ? true : this.field_151501_c.getBlock(i, j - 1, k) == Blocks.grass; + } + } + + public void startExecuting() + { + this.field_151502_a = 40; + this.field_151501_c.setEntityState(this.field_151500_b, (byte)10); + this.field_151500_b.getNavigator().clearPathEntity(); + } + + public void resetTask() + { + this.field_151502_a = 0; + } + + public boolean continueExecuting() + { + return this.field_151502_a > 0; + } + + public int func_151499_f() + { + return this.field_151502_a; + } + + public void updateTask() + { + this.field_151502_a = Math.max(0, this.field_151502_a - 1); + + if (this.field_151502_a == 4) + { + int i = MathHelper.floor_double(this.field_151500_b.posX); + int j = MathHelper.floor_double(this.field_151500_b.posY); + int k = MathHelper.floor_double(this.field_151500_b.posZ); + + if (this.field_151501_c.getBlock(i, j, k) == Blocks.tallgrass) + { + if (this.field_151501_c.getGameRules().getGameRuleBooleanValue("mobGriefing")) + { + this.field_151501_c.func_147480_a(i, j, k, false); + } + + this.field_151500_b.eatGrassBonus(); + } + else if (this.field_151501_c.getBlock(i, j - 1, k) == Blocks.grass) + { + if (this.field_151501_c.getGameRules().getGameRuleBooleanValue("mobGriefing")) + { + this.field_151501_c.playAuxSFX(2001, i, j - 1, k, Block.getIdFromBlock(Blocks.grass)); + this.field_151501_c.setBlock(i, j - 1, k, Blocks.dirt, 0, 2); + } + + this.field_151500_b.eatGrassBonus(); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAIFleeSun.java b/src/main/java/net/minecraft/entity/ai/EntityAIFleeSun.java new file mode 100644 index 0000000..895fdee --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAIFleeSun.java @@ -0,0 +1,87 @@ +package net.minecraft.entity.ai; + +import java.util.Random; +import net.minecraft.entity.EntityCreature; +import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; + +public class EntityAIFleeSun extends EntityAIBase +{ + private EntityCreature theCreature; + private double shelterX; + private double shelterY; + private double shelterZ; + private double movementSpeed; + private World theWorld; + private static final String __OBFID = "CL_00001583"; + + public EntityAIFleeSun(EntityCreature par1EntityCreature, double par2) + { + this.theCreature = par1EntityCreature; + this.movementSpeed = par2; + this.theWorld = par1EntityCreature.worldObj; + this.setMutexBits(1); + } + + public boolean shouldExecute() + { + if (!this.theWorld.isDaytime()) + { + return false; + } + else if (!this.theCreature.isBurning()) + { + return false; + } + else if (!this.theWorld.canBlockSeeTheSky(MathHelper.floor_double(this.theCreature.posX), (int)this.theCreature.boundingBox.minY, MathHelper.floor_double(this.theCreature.posZ))) + { + return false; + } + else + { + Vec3 vec3 = this.findPossibleShelter(); + + if (vec3 == null) + { + return false; + } + else + { + this.shelterX = vec3.xCoord; + this.shelterY = vec3.yCoord; + this.shelterZ = vec3.zCoord; + return true; + } + } + } + + public boolean continueExecuting() + { + return !this.theCreature.getNavigator().noPath(); + } + + public void startExecuting() + { + this.theCreature.getNavigator().tryMoveToXYZ(this.shelterX, this.shelterY, this.shelterZ, this.movementSpeed); + } + + private Vec3 findPossibleShelter() + { + Random random = this.theCreature.getRNG(); + + for (int i = 0; i < 10; ++i) + { + int j = MathHelper.floor_double(this.theCreature.posX + (double)random.nextInt(20) - 10.0D); + int k = MathHelper.floor_double(this.theCreature.boundingBox.minY + (double)random.nextInt(6) - 3.0D); + int l = MathHelper.floor_double(this.theCreature.posZ + (double)random.nextInt(20) - 10.0D); + + if (!this.theWorld.canBlockSeeTheSky(j, k, l) && this.theCreature.getBlockPathWeight(j, k, l) < 0.0F) + { + return this.theWorld.getWorldVec3Pool().getVecFromPool((double)j, (double)k, (double)l); + } + } + + return null; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAIFollowGolem.java b/src/main/java/net/minecraft/entity/ai/EntityAIFollowGolem.java new file mode 100644 index 0000000..f64b130 --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAIFollowGolem.java @@ -0,0 +1,94 @@ +package net.minecraft.entity.ai; + +import java.util.Iterator; +import java.util.List; +import net.minecraft.entity.monster.EntityIronGolem; +import net.minecraft.entity.passive.EntityVillager; + +public class EntityAIFollowGolem extends EntityAIBase +{ + private EntityVillager theVillager; + private EntityIronGolem theGolem; + private int takeGolemRoseTick; + private boolean tookGolemRose; + private static final String __OBFID = "CL_00001615"; + + public EntityAIFollowGolem(EntityVillager par1EntityVillager) + { + this.theVillager = par1EntityVillager; + this.setMutexBits(3); + } + + public boolean shouldExecute() + { + if (this.theVillager.getGrowingAge() >= 0) + { + return false; + } + else if (!this.theVillager.worldObj.isDaytime()) + { + return false; + } + else + { + List list = this.theVillager.worldObj.getEntitiesWithinAABB(EntityIronGolem.class, this.theVillager.boundingBox.expand(6.0D, 2.0D, 6.0D)); + + if (list.isEmpty()) + { + return false; + } + else + { + Iterator iterator = list.iterator(); + + while (iterator.hasNext()) + { + EntityIronGolem entityirongolem = (EntityIronGolem)iterator.next(); + + if (entityirongolem.getHoldRoseTick() > 0) + { + this.theGolem = entityirongolem; + break; + } + } + + return this.theGolem != null; + } + } + } + + public boolean continueExecuting() + { + return this.theGolem.getHoldRoseTick() > 0; + } + + public void startExecuting() + { + this.takeGolemRoseTick = this.theVillager.getRNG().nextInt(320); + this.tookGolemRose = false; + this.theGolem.getNavigator().clearPathEntity(); + } + + public void resetTask() + { + this.theGolem = null; + this.theVillager.getNavigator().clearPathEntity(); + } + + public void updateTask() + { + this.theVillager.getLookHelper().setLookPositionWithEntity(this.theGolem, 30.0F, 30.0F); + + if (this.theGolem.getHoldRoseTick() == this.takeGolemRoseTick) + { + this.theVillager.getNavigator().tryMoveToEntityLiving(this.theGolem, 0.5D); + this.tookGolemRose = true; + } + + if (this.tookGolemRose && this.theVillager.getDistanceSqToEntity(this.theGolem) < 4.0D) + { + this.theGolem.setHoldingRose(false); + this.theVillager.getNavigator().clearPathEntity(); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAIFollowOwner.java b/src/main/java/net/minecraft/entity/ai/EntityAIFollowOwner.java new file mode 100644 index 0000000..86bdc2c --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAIFollowOwner.java @@ -0,0 +1,113 @@ +package net.minecraft.entity.ai; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.passive.EntityTameable; +import net.minecraft.pathfinding.PathNavigate; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class EntityAIFollowOwner extends EntityAIBase +{ + private EntityTameable thePet; + private EntityLivingBase theOwner; + World theWorld; + private double field_75336_f; + private PathNavigate petPathfinder; + private int field_75343_h; + float maxDist; + float minDist; + private boolean field_75344_i; + private static final String __OBFID = "CL_00001585"; + + public EntityAIFollowOwner(EntityTameable par1EntityTameable, double par2, float par4, float par5) + { + this.thePet = par1EntityTameable; + this.theWorld = par1EntityTameable.worldObj; + this.field_75336_f = par2; + this.petPathfinder = par1EntityTameable.getNavigator(); + this.minDist = par4; + this.maxDist = par5; + this.setMutexBits(3); + } + + public boolean shouldExecute() + { + EntityLivingBase entitylivingbase = this.thePet.getOwner(); + + if (entitylivingbase == null) + { + return false; + } + else if (this.thePet.isSitting()) + { + return false; + } + else if (this.thePet.getDistanceSqToEntity(entitylivingbase) < (double)(this.minDist * this.minDist)) + { + return false; + } + else + { + this.theOwner = entitylivingbase; + return true; + } + } + + public boolean continueExecuting() + { + return !this.petPathfinder.noPath() && this.thePet.getDistanceSqToEntity(this.theOwner) > (double)(this.maxDist * this.maxDist) && !this.thePet.isSitting(); + } + + public void startExecuting() + { + this.field_75343_h = 0; + this.field_75344_i = this.thePet.getNavigator().getAvoidsWater(); + this.thePet.getNavigator().setAvoidsWater(false); + } + + public void resetTask() + { + this.theOwner = null; + this.petPathfinder.clearPathEntity(); + this.thePet.getNavigator().setAvoidsWater(this.field_75344_i); + } + + public void updateTask() + { + this.thePet.getLookHelper().setLookPositionWithEntity(this.theOwner, 10.0F, (float)this.thePet.getVerticalFaceSpeed()); + + if (!this.thePet.isSitting()) + { + if (--this.field_75343_h <= 0) + { + this.field_75343_h = 10; + + if (!this.petPathfinder.tryMoveToEntityLiving(this.theOwner, this.field_75336_f)) + { + if (!this.thePet.getLeashed()) + { + if (this.thePet.getDistanceSqToEntity(this.theOwner) >= 144.0D) + { + int i = MathHelper.floor_double(this.theOwner.posX) - 2; + int j = MathHelper.floor_double(this.theOwner.posZ) - 2; + int k = MathHelper.floor_double(this.theOwner.boundingBox.minY); + + for (int l = 0; l <= 4; ++l) + { + for (int i1 = 0; i1 <= 4; ++i1) + { + if ((l < 1 || i1 < 1 || l > 3 || i1 > 3) && World.doesBlockHaveSolidTopSurface(this.theWorld, i + l, k - 1, j + i1) && !this.theWorld.getBlock(i + l, k, j + i1).isNormalCube() && !this.theWorld.getBlock(i + l, k + 1, j + i1).isNormalCube()) + { + this.thePet.setLocationAndAngles((double)((float)(i + l) + 0.5F), (double)k, (double)((float)(j + i1) + 0.5F), this.thePet.rotationYaw, this.thePet.rotationPitch); + this.petPathfinder.clearPathEntity(); + return; + } + } + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAIFollowParent.java b/src/main/java/net/minecraft/entity/ai/EntityAIFollowParent.java new file mode 100644 index 0000000..28491e3 --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAIFollowParent.java @@ -0,0 +1,97 @@ +package net.minecraft.entity.ai; + +import java.util.Iterator; +import java.util.List; +import net.minecraft.entity.passive.EntityAnimal; + +public class EntityAIFollowParent extends EntityAIBase +{ + EntityAnimal childAnimal; + EntityAnimal parentAnimal; + double field_75347_c; + private int field_75345_d; + private static final String __OBFID = "CL_00001586"; + + public EntityAIFollowParent(EntityAnimal par1EntityAnimal, double par2) + { + this.childAnimal = par1EntityAnimal; + this.field_75347_c = par2; + } + + public boolean shouldExecute() + { + if (this.childAnimal.getGrowingAge() >= 0) + { + return false; + } + else + { + List list = this.childAnimal.worldObj.getEntitiesWithinAABB(this.childAnimal.getClass(), this.childAnimal.boundingBox.expand(8.0D, 4.0D, 8.0D)); + EntityAnimal entityanimal = null; + double d0 = Double.MAX_VALUE; + Iterator iterator = list.iterator(); + + while (iterator.hasNext()) + { + EntityAnimal entityanimal1 = (EntityAnimal)iterator.next(); + + if (entityanimal1.getGrowingAge() >= 0) + { + double d1 = this.childAnimal.getDistanceSqToEntity(entityanimal1); + + if (d1 <= d0) + { + d0 = d1; + entityanimal = entityanimal1; + } + } + } + + if (entityanimal == null) + { + return false; + } + else if (d0 < 9.0D) + { + return false; + } + else + { + this.parentAnimal = entityanimal; + return true; + } + } + } + + public boolean continueExecuting() + { + if (!this.parentAnimal.isEntityAlive()) + { + return false; + } + else + { + double d0 = this.childAnimal.getDistanceSqToEntity(this.parentAnimal); + return d0 >= 9.0D && d0 <= 256.0D; + } + } + + public void startExecuting() + { + this.field_75345_d = 0; + } + + public void resetTask() + { + this.parentAnimal = null; + } + + public void updateTask() + { + if (--this.field_75345_d <= 0) + { + this.field_75345_d = 10; + this.childAnimal.getNavigator().tryMoveToEntityLiving(this.parentAnimal, this.field_75347_c); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAIHurtByTarget.java b/src/main/java/net/minecraft/entity/ai/EntityAIHurtByTarget.java new file mode 100644 index 0000000..bcc56e2 --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAIHurtByTarget.java @@ -0,0 +1,51 @@ +package net.minecraft.entity.ai; + +import java.util.Iterator; +import java.util.List; +import net.minecraft.entity.EntityCreature; +import net.minecraft.util.AxisAlignedBB; + +public class EntityAIHurtByTarget extends EntityAITarget +{ + boolean entityCallsForHelp; + private int field_142052_b; + private static final String __OBFID = "CL_00001619"; + + public EntityAIHurtByTarget(EntityCreature par1EntityCreature, boolean par2) + { + super(par1EntityCreature, false); + this.entityCallsForHelp = par2; + this.setMutexBits(1); + } + + public boolean shouldExecute() + { + int i = this.taskOwner.func_142015_aE(); + return i != this.field_142052_b && this.isSuitableTarget(this.taskOwner.getAITarget(), false); + } + + public void startExecuting() + { + this.taskOwner.setAttackTarget(this.taskOwner.getAITarget()); + this.field_142052_b = this.taskOwner.func_142015_aE(); + + if (this.entityCallsForHelp) + { + double d0 = this.getTargetDistance(); + List list = this.taskOwner.worldObj.getEntitiesWithinAABB(this.taskOwner.getClass(), AxisAlignedBB.getAABBPool().getAABB(this.taskOwner.posX, this.taskOwner.posY, this.taskOwner.posZ, this.taskOwner.posX + 1.0D, this.taskOwner.posY + 1.0D, this.taskOwner.posZ + 1.0D).expand(d0, 10.0D, d0)); + Iterator iterator = list.iterator(); + + while (iterator.hasNext()) + { + EntityCreature entitycreature = (EntityCreature)iterator.next(); + + if (this.taskOwner != entitycreature && entitycreature.getAttackTarget() == null && !entitycreature.isOnSameTeam(this.taskOwner.getAITarget())) + { + entitycreature.setAttackTarget(this.taskOwner.getAITarget()); + } + } + } + + super.startExecuting(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAILeapAtTarget.java b/src/main/java/net/minecraft/entity/ai/EntityAILeapAtTarget.java new file mode 100644 index 0000000..f36e787 --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAILeapAtTarget.java @@ -0,0 +1,50 @@ +package net.minecraft.entity.ai; + +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.util.MathHelper; + +public class EntityAILeapAtTarget extends EntityAIBase +{ + EntityLiving leaper; + EntityLivingBase leapTarget; + float leapMotionY; + private static final String __OBFID = "CL_00001591"; + + public EntityAILeapAtTarget(EntityLiving par1EntityLiving, float par2) + { + this.leaper = par1EntityLiving; + this.leapMotionY = par2; + this.setMutexBits(5); + } + + public boolean shouldExecute() + { + this.leapTarget = this.leaper.getAttackTarget(); + + if (this.leapTarget == null) + { + return false; + } + else + { + double d0 = this.leaper.getDistanceSqToEntity(this.leapTarget); + return d0 >= 4.0D && d0 <= 16.0D ? (!this.leaper.onGround ? false : this.leaper.getRNG().nextInt(5) == 0) : false; + } + } + + public boolean continueExecuting() + { + return !this.leaper.onGround; + } + + public void startExecuting() + { + double d0 = this.leapTarget.posX - this.leaper.posX; + double d1 = this.leapTarget.posZ - this.leaper.posZ; + float f = MathHelper.sqrt_double(d0 * d0 + d1 * d1); + this.leaper.motionX += d0 / (double)f * 0.5D * 0.800000011920929D + this.leaper.motionX * 0.20000000298023224D; + this.leaper.motionZ += d1 / (double)f * 0.5D * 0.800000011920929D + this.leaper.motionZ * 0.20000000298023224D; + this.leaper.motionY = (double)this.leapMotionY; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAILookAtTradePlayer.java b/src/main/java/net/minecraft/entity/ai/EntityAILookAtTradePlayer.java new file mode 100644 index 0000000..baaf042 --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAILookAtTradePlayer.java @@ -0,0 +1,29 @@ +package net.minecraft.entity.ai; + +import net.minecraft.entity.passive.EntityVillager; +import net.minecraft.entity.player.EntityPlayer; + +public class EntityAILookAtTradePlayer extends EntityAIWatchClosest +{ + private final EntityVillager theMerchant; + private static final String __OBFID = "CL_00001593"; + + public EntityAILookAtTradePlayer(EntityVillager par1EntityVillager) + { + super(par1EntityVillager, EntityPlayer.class, 8.0F); + this.theMerchant = par1EntityVillager; + } + + public boolean shouldExecute() + { + if (this.theMerchant.isTrading()) + { + this.closestEntity = this.theMerchant.getCustomer(); + return true; + } + else + { + return false; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAILookAtVillager.java b/src/main/java/net/minecraft/entity/ai/EntityAILookAtVillager.java new file mode 100644 index 0000000..de3f755 --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAILookAtVillager.java @@ -0,0 +1,58 @@ +package net.minecraft.entity.ai; + +import net.minecraft.entity.monster.EntityIronGolem; +import net.minecraft.entity.passive.EntityVillager; + +public class EntityAILookAtVillager extends EntityAIBase +{ + private EntityIronGolem theGolem; + private EntityVillager theVillager; + private int lookTime; + private static final String __OBFID = "CL_00001602"; + + public EntityAILookAtVillager(EntityIronGolem par1EntityIronGolem) + { + this.theGolem = par1EntityIronGolem; + this.setMutexBits(3); + } + + public boolean shouldExecute() + { + if (!this.theGolem.worldObj.isDaytime()) + { + return false; + } + else if (this.theGolem.getRNG().nextInt(8000) != 0) + { + return false; + } + else + { + this.theVillager = (EntityVillager)this.theGolem.worldObj.findNearestEntityWithinAABB(EntityVillager.class, this.theGolem.boundingBox.expand(6.0D, 2.0D, 6.0D), this.theGolem); + return this.theVillager != null; + } + } + + public boolean continueExecuting() + { + return this.lookTime > 0; + } + + public void startExecuting() + { + this.lookTime = 400; + this.theGolem.setHoldingRose(true); + } + + public void resetTask() + { + this.theGolem.setHoldingRose(false); + this.theVillager = null; + } + + public void updateTask() + { + this.theGolem.getLookHelper().setLookPositionWithEntity(this.theVillager, 30.0F, 30.0F); + --this.lookTime; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAILookIdle.java b/src/main/java/net/minecraft/entity/ai/EntityAILookIdle.java new file mode 100644 index 0000000..3fd77e7 --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAILookIdle.java @@ -0,0 +1,42 @@ +package net.minecraft.entity.ai; + +import net.minecraft.entity.EntityLiving; + +public class EntityAILookIdle extends EntityAIBase +{ + private EntityLiving idleEntity; + private double lookX; + private double lookZ; + private int idleTime; + private static final String __OBFID = "CL_00001607"; + + public EntityAILookIdle(EntityLiving par1EntityLiving) + { + this.idleEntity = par1EntityLiving; + this.setMutexBits(3); + } + + public boolean shouldExecute() + { + return this.idleEntity.getRNG().nextFloat() < 0.02F; + } + + public boolean continueExecuting() + { + return this.idleTime >= 0; + } + + public void startExecuting() + { + double d0 = (Math.PI * 2D) * this.idleEntity.getRNG().nextDouble(); + this.lookX = Math.cos(d0); + this.lookZ = Math.sin(d0); + this.idleTime = 20 + this.idleEntity.getRNG().nextInt(20); + } + + public void updateTask() + { + --this.idleTime; + this.idleEntity.getLookHelper().setLookPosition(this.idleEntity.posX + this.lookX, this.idleEntity.posY + (double)this.idleEntity.getEyeHeight(), this.idleEntity.posZ + this.lookZ, 10.0F, (float)this.idleEntity.getVerticalFaceSpeed()); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAIMate.java b/src/main/java/net/minecraft/entity/ai/EntityAIMate.java new file mode 100644 index 0000000..0aaf1d3 --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAIMate.java @@ -0,0 +1,136 @@ +package net.minecraft.entity.ai; + +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import net.minecraft.entity.EntityAgeable; +import net.minecraft.entity.item.EntityXPOrb; +import net.minecraft.entity.passive.EntityAnimal; +import net.minecraft.entity.passive.EntityCow; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.stats.AchievementList; +import net.minecraft.stats.StatList; +import net.minecraft.world.World; + +public class EntityAIMate extends EntityAIBase +{ + private EntityAnimal theAnimal; + World theWorld; + private EntityAnimal targetMate; + int spawnBabyDelay; + double moveSpeed; + private static final String __OBFID = "CL_00001578"; + + public EntityAIMate(EntityAnimal par1EntityAnimal, double par2) + { + this.theAnimal = par1EntityAnimal; + this.theWorld = par1EntityAnimal.worldObj; + this.moveSpeed = par2; + this.setMutexBits(3); + } + + public boolean shouldExecute() + { + if (!this.theAnimal.isInLove()) + { + return false; + } + else + { + this.targetMate = this.getNearbyMate(); + return this.targetMate != null; + } + } + + public boolean continueExecuting() + { + return this.targetMate.isEntityAlive() && this.targetMate.isInLove() && this.spawnBabyDelay < 60; + } + + public void resetTask() + { + this.targetMate = null; + this.spawnBabyDelay = 0; + } + + public void updateTask() + { + this.theAnimal.getLookHelper().setLookPositionWithEntity(this.targetMate, 10.0F, (float)this.theAnimal.getVerticalFaceSpeed()); + this.theAnimal.getNavigator().tryMoveToEntityLiving(this.targetMate, this.moveSpeed); + ++this.spawnBabyDelay; + + if (this.spawnBabyDelay >= 60 && this.theAnimal.getDistanceSqToEntity(this.targetMate) < 9.0D) + { + this.spawnBaby(); + } + } + + private EntityAnimal getNearbyMate() + { + float f = 8.0F; + List list = this.theWorld.getEntitiesWithinAABB(this.theAnimal.getClass(), this.theAnimal.boundingBox.expand((double)f, (double)f, (double)f)); + double d0 = Double.MAX_VALUE; + EntityAnimal entityanimal = null; + Iterator iterator = list.iterator(); + + while (iterator.hasNext()) + { + EntityAnimal entityanimal1 = (EntityAnimal)iterator.next(); + + if (this.theAnimal.canMateWith(entityanimal1) && this.theAnimal.getDistanceSqToEntity(entityanimal1) < d0) + { + entityanimal = entityanimal1; + d0 = this.theAnimal.getDistanceSqToEntity(entityanimal1); + } + } + + return entityanimal; + } + + private void spawnBaby() + { + EntityAgeable entityageable = this.theAnimal.createChild(this.targetMate); + + if (entityageable != null) + { + EntityPlayer entityplayer = this.theAnimal.func_146083_cb(); + + if (entityplayer == null && this.targetMate.func_146083_cb() != null) + { + entityplayer = this.targetMate.func_146083_cb(); + } + + if (entityplayer != null) + { + entityplayer.triggerAchievement(StatList.field_151186_x); + + if (this.theAnimal instanceof EntityCow) + { + entityplayer.triggerAchievement(AchievementList.field_150962_H); + } + } + + this.theAnimal.setGrowingAge(6000); + this.targetMate.setGrowingAge(6000); + this.theAnimal.resetInLove(); + this.targetMate.resetInLove(); + entityageable.setGrowingAge(-24000); + entityageable.setLocationAndAngles(this.theAnimal.posX, this.theAnimal.posY, this.theAnimal.posZ, 0.0F, 0.0F); + this.theWorld.spawnEntityInWorld(entityageable); + Random random = this.theAnimal.getRNG(); + + for (int i = 0; i < 7; ++i) + { + double d0 = random.nextGaussian() * 0.02D; + double d1 = random.nextGaussian() * 0.02D; + double d2 = random.nextGaussian() * 0.02D; + this.theWorld.spawnParticle("heart", this.theAnimal.posX + (double)(random.nextFloat() * this.theAnimal.width * 2.0F) - (double)this.theAnimal.width, this.theAnimal.posY + 0.5D + (double)(random.nextFloat() * this.theAnimal.height), this.theAnimal.posZ + (double)(random.nextFloat() * this.theAnimal.width * 2.0F) - (double)this.theAnimal.width, d0, d1, d2); + } + + if (this.theWorld.getGameRules().getGameRuleBooleanValue("doMobLoot")) + { + this.theWorld.spawnEntityInWorld(new EntityXPOrb(this.theWorld, this.theAnimal.posX, this.theAnimal.posY, this.theAnimal.posZ, random.nextInt(7) + 1)); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAIMoveIndoors.java b/src/main/java/net/minecraft/entity/ai/EntityAIMoveIndoors.java new file mode 100644 index 0000000..da7f8d5 --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAIMoveIndoors.java @@ -0,0 +1,90 @@ +package net.minecraft.entity.ai; + +import net.minecraft.entity.EntityCreature; +import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; +import net.minecraft.village.Village; +import net.minecraft.village.VillageDoorInfo; + +public class EntityAIMoveIndoors extends EntityAIBase +{ + private EntityCreature entityObj; + private VillageDoorInfo doorInfo; + private int insidePosX = -1; + private int insidePosZ = -1; + private static final String __OBFID = "CL_00001596"; + + public EntityAIMoveIndoors(EntityCreature par1EntityCreature) + { + this.entityObj = par1EntityCreature; + this.setMutexBits(1); + } + + public boolean shouldExecute() + { + int i = MathHelper.floor_double(this.entityObj.posX); + int j = MathHelper.floor_double(this.entityObj.posY); + int k = MathHelper.floor_double(this.entityObj.posZ); + + if ((!this.entityObj.worldObj.isDaytime() || this.entityObj.worldObj.isRaining() || !this.entityObj.worldObj.getBiomeGenForCoords(i, k).canSpawnLightningBolt()) && !this.entityObj.worldObj.provider.hasNoSky) + { + if (this.entityObj.getRNG().nextInt(50) != 0) + { + return false; + } + else if (this.insidePosX != -1 && this.entityObj.getDistanceSq((double)this.insidePosX, this.entityObj.posY, (double)this.insidePosZ) < 4.0D) + { + return false; + } + else + { + Village village = this.entityObj.worldObj.villageCollectionObj.findNearestVillage(i, j, k, 14); + + if (village == null) + { + return false; + } + else + { + this.doorInfo = village.findNearestDoorUnrestricted(i, j, k); + return this.doorInfo != null; + } + } + } + else + { + return false; + } + } + + public boolean continueExecuting() + { + return !this.entityObj.getNavigator().noPath(); + } + + public void startExecuting() + { + this.insidePosX = -1; + + if (this.entityObj.getDistanceSq((double)this.doorInfo.getInsidePosX(), (double)this.doorInfo.posY, (double)this.doorInfo.getInsidePosZ()) > 256.0D) + { + Vec3 vec3 = RandomPositionGenerator.findRandomTargetBlockTowards(this.entityObj, 14, 3, this.entityObj.worldObj.getWorldVec3Pool().getVecFromPool((double)this.doorInfo.getInsidePosX() + 0.5D, (double)this.doorInfo.getInsidePosY(), (double)this.doorInfo.getInsidePosZ() + 0.5D)); + + if (vec3 != null) + { + this.entityObj.getNavigator().tryMoveToXYZ(vec3.xCoord, vec3.yCoord, vec3.zCoord, 1.0D); + } + } + else + { + this.entityObj.getNavigator().tryMoveToXYZ((double)this.doorInfo.getInsidePosX() + 0.5D, (double)this.doorInfo.getInsidePosY(), (double)this.doorInfo.getInsidePosZ() + 0.5D, 1.0D); + } + } + + public void resetTask() + { + this.insidePosX = this.doorInfo.getInsidePosX(); + this.insidePosZ = this.doorInfo.getInsidePosZ(); + this.doorInfo = null; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAIMoveThroughVillage.java b/src/main/java/net/minecraft/entity/ai/EntityAIMoveThroughVillage.java new file mode 100644 index 0000000..5379ac6 --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAIMoveThroughVillage.java @@ -0,0 +1,161 @@ +package net.minecraft.entity.ai; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import net.minecraft.entity.EntityCreature; +import net.minecraft.pathfinding.PathEntity; +import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; +import net.minecraft.village.Village; +import net.minecraft.village.VillageDoorInfo; + +public class EntityAIMoveThroughVillage extends EntityAIBase +{ + private EntityCreature theEntity; + private double movementSpeed; + private PathEntity entityPathNavigate; + private VillageDoorInfo doorInfo; + private boolean isNocturnal; + private List doorList = new ArrayList(); + private static final String __OBFID = "CL_00001597"; + + public EntityAIMoveThroughVillage(EntityCreature par1EntityCreature, double par2, boolean par4) + { + this.theEntity = par1EntityCreature; + this.movementSpeed = par2; + this.isNocturnal = par4; + this.setMutexBits(1); + } + + public boolean shouldExecute() + { + this.func_75414_f(); + + if (this.isNocturnal && this.theEntity.worldObj.isDaytime()) + { + return false; + } + else + { + Village village = this.theEntity.worldObj.villageCollectionObj.findNearestVillage(MathHelper.floor_double(this.theEntity.posX), MathHelper.floor_double(this.theEntity.posY), MathHelper.floor_double(this.theEntity.posZ), 0); + + if (village == null) + { + return false; + } + else + { + this.doorInfo = this.func_75412_a(village); + + if (this.doorInfo == null) + { + return false; + } + else + { + boolean flag = this.theEntity.getNavigator().getCanBreakDoors(); + this.theEntity.getNavigator().setBreakDoors(false); + this.entityPathNavigate = this.theEntity.getNavigator().getPathToXYZ((double)this.doorInfo.posX, (double)this.doorInfo.posY, (double)this.doorInfo.posZ); + this.theEntity.getNavigator().setBreakDoors(flag); + + if (this.entityPathNavigate != null) + { + return true; + } + else + { + Vec3 vec3 = RandomPositionGenerator.findRandomTargetBlockTowards(this.theEntity, 10, 7, this.theEntity.worldObj.getWorldVec3Pool().getVecFromPool((double)this.doorInfo.posX, (double)this.doorInfo.posY, (double)this.doorInfo.posZ)); + + if (vec3 == null) + { + return false; + } + else + { + this.theEntity.getNavigator().setBreakDoors(false); + this.entityPathNavigate = this.theEntity.getNavigator().getPathToXYZ(vec3.xCoord, vec3.yCoord, vec3.zCoord); + this.theEntity.getNavigator().setBreakDoors(flag); + return this.entityPathNavigate != null; + } + } + } + } + } + } + + public boolean continueExecuting() + { + if (this.theEntity.getNavigator().noPath()) + { + return false; + } + else + { + float f = this.theEntity.width + 4.0F; + return this.theEntity.getDistanceSq((double)this.doorInfo.posX, (double)this.doorInfo.posY, (double)this.doorInfo.posZ) > (double)(f * f); + } + } + + public void startExecuting() + { + this.theEntity.getNavigator().setPath(this.entityPathNavigate, this.movementSpeed); + } + + public void resetTask() + { + if (this.theEntity.getNavigator().noPath() || this.theEntity.getDistanceSq((double)this.doorInfo.posX, (double)this.doorInfo.posY, (double)this.doorInfo.posZ) < 16.0D) + { + this.doorList.add(this.doorInfo); + } + } + + private VillageDoorInfo func_75412_a(Village par1Village) + { + VillageDoorInfo villagedoorinfo = null; + int i = Integer.MAX_VALUE; + List list = par1Village.getVillageDoorInfoList(); + Iterator iterator = list.iterator(); + + while (iterator.hasNext()) + { + VillageDoorInfo villagedoorinfo1 = (VillageDoorInfo)iterator.next(); + int j = villagedoorinfo1.getDistanceSquared(MathHelper.floor_double(this.theEntity.posX), MathHelper.floor_double(this.theEntity.posY), MathHelper.floor_double(this.theEntity.posZ)); + + if (j < i && !this.func_75413_a(villagedoorinfo1)) + { + villagedoorinfo = villagedoorinfo1; + i = j; + } + } + + return villagedoorinfo; + } + + private boolean func_75413_a(VillageDoorInfo par1VillageDoorInfo) + { + Iterator iterator = this.doorList.iterator(); + VillageDoorInfo villagedoorinfo1; + + do + { + if (!iterator.hasNext()) + { + return false; + } + + villagedoorinfo1 = (VillageDoorInfo)iterator.next(); + } + while (par1VillageDoorInfo.posX != villagedoorinfo1.posX || par1VillageDoorInfo.posY != villagedoorinfo1.posY || par1VillageDoorInfo.posZ != villagedoorinfo1.posZ); + + return true; + } + + private void func_75414_f() + { + if (this.doorList.size() > 15) + { + this.doorList.remove(0); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAIMoveTowardsRestriction.java b/src/main/java/net/minecraft/entity/ai/EntityAIMoveTowardsRestriction.java new file mode 100644 index 0000000..0594df1 --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAIMoveTowardsRestriction.java @@ -0,0 +1,57 @@ +package net.minecraft.entity.ai; + +import net.minecraft.entity.EntityCreature; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.Vec3; + +public class EntityAIMoveTowardsRestriction extends EntityAIBase +{ + private EntityCreature theEntity; + private double movePosX; + private double movePosY; + private double movePosZ; + private double movementSpeed; + private static final String __OBFID = "CL_00001598"; + + public EntityAIMoveTowardsRestriction(EntityCreature par1EntityCreature, double par2) + { + this.theEntity = par1EntityCreature; + this.movementSpeed = par2; + this.setMutexBits(1); + } + + public boolean shouldExecute() + { + if (this.theEntity.isWithinHomeDistanceCurrentPosition()) + { + return false; + } + else + { + ChunkCoordinates chunkcoordinates = this.theEntity.getHomePosition(); + Vec3 vec3 = RandomPositionGenerator.findRandomTargetBlockTowards(this.theEntity, 16, 7, this.theEntity.worldObj.getWorldVec3Pool().getVecFromPool((double)chunkcoordinates.posX, (double)chunkcoordinates.posY, (double)chunkcoordinates.posZ)); + + if (vec3 == null) + { + return false; + } + else + { + this.movePosX = vec3.xCoord; + this.movePosY = vec3.yCoord; + this.movePosZ = vec3.zCoord; + return true; + } + } + } + + public boolean continueExecuting() + { + return !this.theEntity.getNavigator().noPath(); + } + + public void startExecuting() + { + this.theEntity.getNavigator().tryMoveToXYZ(this.movePosX, this.movePosY, this.movePosZ, this.movementSpeed); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAIMoveTowardsTarget.java b/src/main/java/net/minecraft/entity/ai/EntityAIMoveTowardsTarget.java new file mode 100644 index 0000000..abf2755 --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAIMoveTowardsTarget.java @@ -0,0 +1,70 @@ +package net.minecraft.entity.ai; + +import net.minecraft.entity.EntityCreature; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.util.Vec3; + +public class EntityAIMoveTowardsTarget extends EntityAIBase +{ + private EntityCreature theEntity; + private EntityLivingBase targetEntity; + private double movePosX; + private double movePosY; + private double movePosZ; + private double speed; + private float maxTargetDistance; + private static final String __OBFID = "CL_00001599"; + + public EntityAIMoveTowardsTarget(EntityCreature par1EntityCreature, double par2, float par4) + { + this.theEntity = par1EntityCreature; + this.speed = par2; + this.maxTargetDistance = par4; + this.setMutexBits(1); + } + + public boolean shouldExecute() + { + this.targetEntity = this.theEntity.getAttackTarget(); + + if (this.targetEntity == null) + { + return false; + } + else if (this.targetEntity.getDistanceSqToEntity(this.theEntity) > (double)(this.maxTargetDistance * this.maxTargetDistance)) + { + return false; + } + else + { + Vec3 vec3 = RandomPositionGenerator.findRandomTargetBlockTowards(this.theEntity, 16, 7, this.theEntity.worldObj.getWorldVec3Pool().getVecFromPool(this.targetEntity.posX, this.targetEntity.posY, this.targetEntity.posZ)); + + if (vec3 == null) + { + return false; + } + else + { + this.movePosX = vec3.xCoord; + this.movePosY = vec3.yCoord; + this.movePosZ = vec3.zCoord; + return true; + } + } + } + + public boolean continueExecuting() + { + return !this.theEntity.getNavigator().noPath() && this.targetEntity.isEntityAlive() && this.targetEntity.getDistanceSqToEntity(this.theEntity) < (double)(this.maxTargetDistance * this.maxTargetDistance); + } + + public void resetTask() + { + this.targetEntity = null; + } + + public void startExecuting() + { + this.theEntity.getNavigator().tryMoveToXYZ(this.movePosX, this.movePosY, this.movePosZ, this.speed); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAINearestAttackableTarget.java b/src/main/java/net/minecraft/entity/ai/EntityAINearestAttackableTarget.java new file mode 100644 index 0000000..5f030d3 --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAINearestAttackableTarget.java @@ -0,0 +1,99 @@ +package net.minecraft.entity.ai; + +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import net.minecraft.command.IEntitySelector; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityCreature; +import net.minecraft.entity.EntityLivingBase; + +public class EntityAINearestAttackableTarget extends EntityAITarget +{ + private final Class targetClass; + private final int targetChance; + private final EntityAINearestAttackableTarget.Sorter theNearestAttackableTargetSorter; + private final IEntitySelector targetEntitySelector; + private EntityLivingBase targetEntity; + private static final String __OBFID = "CL_00001620"; + + public EntityAINearestAttackableTarget(EntityCreature par1EntityCreature, Class par2Class, int par3, boolean par4) + { + this(par1EntityCreature, par2Class, par3, par4, false); + } + + public EntityAINearestAttackableTarget(EntityCreature par1EntityCreature, Class par2Class, int par3, boolean par4, boolean par5) + { + this(par1EntityCreature, par2Class, par3, par4, par5, (IEntitySelector)null); + } + + public EntityAINearestAttackableTarget(EntityCreature par1EntityCreature, Class par2Class, int par3, boolean par4, boolean par5, final IEntitySelector par6IEntitySelector) + { + super(par1EntityCreature, par4, par5); + this.targetClass = par2Class; + this.targetChance = par3; + this.theNearestAttackableTargetSorter = new EntityAINearestAttackableTarget.Sorter(par1EntityCreature); + this.setMutexBits(1); + this.targetEntitySelector = new IEntitySelector() + { + private static final String __OBFID = "CL_00001621"; + public boolean isEntityApplicable(Entity par1Entity) + { + return !(par1Entity instanceof EntityLivingBase) ? false : (par6IEntitySelector != null && !par6IEntitySelector.isEntityApplicable(par1Entity) ? false : EntityAINearestAttackableTarget.this.isSuitableTarget((EntityLivingBase)par1Entity, false)); + } + }; + } + + public boolean shouldExecute() + { + if (this.targetChance > 0 && this.taskOwner.getRNG().nextInt(this.targetChance) != 0) + { + return false; + } + else + { + double d0 = this.getTargetDistance(); + List list = this.taskOwner.worldObj.selectEntitiesWithinAABB(this.targetClass, this.taskOwner.boundingBox.expand(d0, 4.0D, d0), this.targetEntitySelector); + Collections.sort(list, this.theNearestAttackableTargetSorter); + + if (list.isEmpty()) + { + return false; + } + else + { + this.targetEntity = (EntityLivingBase)list.get(0); + return true; + } + } + } + + public void startExecuting() + { + this.taskOwner.setAttackTarget(this.targetEntity); + super.startExecuting(); + } + + public static class Sorter implements Comparator + { + private final Entity theEntity; + private static final String __OBFID = "CL_00001622"; + + public Sorter(Entity par1Entity) + { + this.theEntity = par1Entity; + } + + public int compare(Entity par1Entity, Entity par2Entity) + { + double d0 = this.theEntity.getDistanceSqToEntity(par1Entity); + double d1 = this.theEntity.getDistanceSqToEntity(par2Entity); + return d0 < d1 ? -1 : (d0 > d1 ? 1 : 0); + } + + public int compare(Object par1Obj, Object par2Obj) + { + return this.compare((Entity)par1Obj, (Entity)par2Obj); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAIOcelotAttack.java b/src/main/java/net/minecraft/entity/ai/EntityAIOcelotAttack.java new file mode 100644 index 0000000..743df16 --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAIOcelotAttack.java @@ -0,0 +1,76 @@ +package net.minecraft.entity.ai; + +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.world.World; + +public class EntityAIOcelotAttack extends EntityAIBase +{ + World theWorld; + EntityLiving theEntity; + EntityLivingBase theVictim; + int attackCountdown; + private static final String __OBFID = "CL_00001600"; + + public EntityAIOcelotAttack(EntityLiving par1EntityLiving) + { + this.theEntity = par1EntityLiving; + this.theWorld = par1EntityLiving.worldObj; + this.setMutexBits(3); + } + + public boolean shouldExecute() + { + EntityLivingBase entitylivingbase = this.theEntity.getAttackTarget(); + + if (entitylivingbase == null) + { + return false; + } + else + { + this.theVictim = entitylivingbase; + return true; + } + } + + public boolean continueExecuting() + { + return !this.theVictim.isEntityAlive() ? false : (this.theEntity.getDistanceSqToEntity(this.theVictim) > 225.0D ? false : !this.theEntity.getNavigator().noPath() || this.shouldExecute()); + } + + public void resetTask() + { + this.theVictim = null; + this.theEntity.getNavigator().clearPathEntity(); + } + + public void updateTask() + { + this.theEntity.getLookHelper().setLookPositionWithEntity(this.theVictim, 30.0F, 30.0F); + double d0 = (double)(this.theEntity.width * 2.0F * this.theEntity.width * 2.0F); + double d1 = this.theEntity.getDistanceSq(this.theVictim.posX, this.theVictim.boundingBox.minY, this.theVictim.posZ); + double d2 = 0.8D; + + if (d1 > d0 && d1 < 16.0D) + { + d2 = 1.33D; + } + else if (d1 < 225.0D) + { + d2 = 0.6D; + } + + this.theEntity.getNavigator().tryMoveToEntityLiving(this.theVictim, d2); + this.attackCountdown = Math.max(this.attackCountdown - 1, 0); + + if (d1 <= d0) + { + if (this.attackCountdown <= 0) + { + this.attackCountdown = 20; + this.theEntity.attackEntityAsMob(this.theVictim); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAIOcelotSit.java b/src/main/java/net/minecraft/entity/ai/EntityAIOcelotSit.java new file mode 100644 index 0000000..b084b69 --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAIOcelotSit.java @@ -0,0 +1,130 @@ +package net.minecraft.entity.ai; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockBed; +import net.minecraft.entity.passive.EntityOcelot; +import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntityChest; +import net.minecraft.world.World; + +public class EntityAIOcelotSit extends EntityAIBase +{ + private final EntityOcelot field_151493_a; + private final double field_151491_b; + private int field_151492_c; + private int field_151489_d; + private int field_151490_e; + private int field_151487_f; + private int field_151488_g; + private int field_151494_h; + private static final String __OBFID = "CL_00001601"; + + public EntityAIOcelotSit(EntityOcelot p_i45315_1_, double p_i45315_2_) + { + this.field_151493_a = p_i45315_1_; + this.field_151491_b = p_i45315_2_; + this.setMutexBits(5); + } + + public boolean shouldExecute() + { + return this.field_151493_a.isTamed() && !this.field_151493_a.isSitting() && this.field_151493_a.getRNG().nextDouble() <= 0.006500000134110451D && this.func_151485_f(); + } + + public boolean continueExecuting() + { + return this.field_151492_c <= this.field_151490_e && this.field_151489_d <= 60 && this.func_151486_a(this.field_151493_a.worldObj, this.field_151487_f, this.field_151488_g, this.field_151494_h); + } + + public void startExecuting() + { + this.field_151493_a.getNavigator().tryMoveToXYZ((double)((float)this.field_151487_f) + 0.5D, (double)(this.field_151488_g + 1), (double)((float)this.field_151494_h) + 0.5D, this.field_151491_b); + this.field_151492_c = 0; + this.field_151489_d = 0; + this.field_151490_e = this.field_151493_a.getRNG().nextInt(this.field_151493_a.getRNG().nextInt(1200) + 1200) + 1200; + this.field_151493_a.func_70907_r().setSitting(false); + } + + public void resetTask() + { + this.field_151493_a.setSitting(false); + } + + public void updateTask() + { + ++this.field_151492_c; + this.field_151493_a.func_70907_r().setSitting(false); + + if (this.field_151493_a.getDistanceSq((double)this.field_151487_f, (double)(this.field_151488_g + 1), (double)this.field_151494_h) > 1.0D) + { + this.field_151493_a.setSitting(false); + this.field_151493_a.getNavigator().tryMoveToXYZ((double)((float)this.field_151487_f) + 0.5D, (double)(this.field_151488_g + 1), (double)((float)this.field_151494_h) + 0.5D, this.field_151491_b); + ++this.field_151489_d; + } + else if (!this.field_151493_a.isSitting()) + { + this.field_151493_a.setSitting(true); + } + else + { + --this.field_151489_d; + } + } + + private boolean func_151485_f() + { + int i = (int)this.field_151493_a.posY; + double d0 = 2.147483647E9D; + + for (int j = (int)this.field_151493_a.posX - 8; (double)j < this.field_151493_a.posX + 8.0D; ++j) + { + for (int k = (int)this.field_151493_a.posZ - 8; (double)k < this.field_151493_a.posZ + 8.0D; ++k) + { + if (this.func_151486_a(this.field_151493_a.worldObj, j, i, k) && this.field_151493_a.worldObj.isAirBlock(j, i + 1, k)) + { + double d1 = this.field_151493_a.getDistanceSq((double)j, (double)i, (double)k); + + if (d1 < d0) + { + this.field_151487_f = j; + this.field_151488_g = i; + this.field_151494_h = k; + d0 = d1; + } + } + } + } + + return d0 < 2.147483647E9D; + } + + private boolean func_151486_a(World p_151486_1_, int p_151486_2_, int p_151486_3_, int p_151486_4_) + { + Block block = p_151486_1_.getBlock(p_151486_2_, p_151486_3_, p_151486_4_); + int l = p_151486_1_.getBlockMetadata(p_151486_2_, p_151486_3_, p_151486_4_); + + if (block == Blocks.chest) + { + TileEntityChest tileentitychest = (TileEntityChest)p_151486_1_.getTileEntity(p_151486_2_, p_151486_3_, p_151486_4_); + + if (tileentitychest.numPlayersUsing < 1) + { + return true; + } + } + else + { + if (block == Blocks.lit_furnace) + { + return true; + } + + if (block == Blocks.bed && !BlockBed.isBlockHeadOfBed(l)) + { + return true; + } + } + + return false; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAIOpenDoor.java b/src/main/java/net/minecraft/entity/ai/EntityAIOpenDoor.java new file mode 100644 index 0000000..1290ed3 --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAIOpenDoor.java @@ -0,0 +1,42 @@ +package net.minecraft.entity.ai; + +import net.minecraft.entity.EntityLiving; + +public class EntityAIOpenDoor extends EntityAIDoorInteract +{ + boolean field_75361_i; + int field_75360_j; + private static final String __OBFID = "CL_00001603"; + + public EntityAIOpenDoor(EntityLiving par1EntityLiving, boolean par2) + { + super(par1EntityLiving); + this.theEntity = par1EntityLiving; + this.field_75361_i = par2; + } + + public boolean continueExecuting() + { + return this.field_75361_i && this.field_75360_j > 0 && super.continueExecuting(); + } + + public void startExecuting() + { + this.field_75360_j = 20; + this.field_151504_e.func_150014_a(this.theEntity.worldObj, this.entityPosX, this.entityPosY, this.entityPosZ, true); + } + + public void resetTask() + { + if (this.field_75361_i) + { + this.field_151504_e.func_150014_a(this.theEntity.worldObj, this.entityPosX, this.entityPosY, this.entityPosZ, false); + } + } + + public void updateTask() + { + --this.field_75360_j; + super.updateTask(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAIOwnerHurtByTarget.java b/src/main/java/net/minecraft/entity/ai/EntityAIOwnerHurtByTarget.java new file mode 100644 index 0000000..947528a --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAIOwnerHurtByTarget.java @@ -0,0 +1,55 @@ +package net.minecraft.entity.ai; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.passive.EntityTameable; + +public class EntityAIOwnerHurtByTarget extends EntityAITarget +{ + EntityTameable theDefendingTameable; + EntityLivingBase theOwnerAttacker; + private int field_142051_e; + private static final String __OBFID = "CL_00001624"; + + public EntityAIOwnerHurtByTarget(EntityTameable par1EntityTameable) + { + super(par1EntityTameable, false); + this.theDefendingTameable = par1EntityTameable; + this.setMutexBits(1); + } + + public boolean shouldExecute() + { + if (!this.theDefendingTameable.isTamed()) + { + return false; + } + else + { + EntityLivingBase entitylivingbase = this.theDefendingTameable.getOwner(); + + if (entitylivingbase == null) + { + return false; + } + else + { + this.theOwnerAttacker = entitylivingbase.getAITarget(); + int i = entitylivingbase.func_142015_aE(); + return i != this.field_142051_e && this.isSuitableTarget(this.theOwnerAttacker, false) && this.theDefendingTameable.func_142018_a(this.theOwnerAttacker, entitylivingbase); + } + } + } + + public void startExecuting() + { + this.taskOwner.setAttackTarget(this.theOwnerAttacker); + EntityLivingBase entitylivingbase = this.theDefendingTameable.getOwner(); + + if (entitylivingbase != null) + { + this.field_142051_e = entitylivingbase.func_142015_aE(); + } + + super.startExecuting(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAIOwnerHurtTarget.java b/src/main/java/net/minecraft/entity/ai/EntityAIOwnerHurtTarget.java new file mode 100644 index 0000000..1294d59 --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAIOwnerHurtTarget.java @@ -0,0 +1,55 @@ +package net.minecraft.entity.ai; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.passive.EntityTameable; + +public class EntityAIOwnerHurtTarget extends EntityAITarget +{ + EntityTameable theEntityTameable; + EntityLivingBase theTarget; + private int field_142050_e; + private static final String __OBFID = "CL_00001625"; + + public EntityAIOwnerHurtTarget(EntityTameable par1EntityTameable) + { + super(par1EntityTameable, false); + this.theEntityTameable = par1EntityTameable; + this.setMutexBits(1); + } + + public boolean shouldExecute() + { + if (!this.theEntityTameable.isTamed()) + { + return false; + } + else + { + EntityLivingBase entitylivingbase = this.theEntityTameable.getOwner(); + + if (entitylivingbase == null) + { + return false; + } + else + { + this.theTarget = entitylivingbase.getLastAttacker(); + int i = entitylivingbase.getLastAttackerTime(); + return i != this.field_142050_e && this.isSuitableTarget(this.theTarget, false) && this.theEntityTameable.func_142018_a(this.theTarget, entitylivingbase); + } + } + } + + public void startExecuting() + { + this.taskOwner.setAttackTarget(this.theTarget); + EntityLivingBase entitylivingbase = this.theEntityTameable.getOwner(); + + if (entitylivingbase != null) + { + this.field_142050_e = entitylivingbase.getLastAttackerTime(); + } + + super.startExecuting(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAIPanic.java b/src/main/java/net/minecraft/entity/ai/EntityAIPanic.java new file mode 100644 index 0000000..e7872d5 --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAIPanic.java @@ -0,0 +1,55 @@ +package net.minecraft.entity.ai; + +import net.minecraft.entity.EntityCreature; +import net.minecraft.util.Vec3; + +public class EntityAIPanic extends EntityAIBase +{ + private EntityCreature theEntityCreature; + private double speed; + private double randPosX; + private double randPosY; + private double randPosZ; + private static final String __OBFID = "CL_00001604"; + + public EntityAIPanic(EntityCreature par1EntityCreature, double par2) + { + this.theEntityCreature = par1EntityCreature; + this.speed = par2; + this.setMutexBits(1); + } + + public boolean shouldExecute() + { + if (this.theEntityCreature.getAITarget() == null && !this.theEntityCreature.isBurning()) + { + return false; + } + else + { + Vec3 vec3 = RandomPositionGenerator.findRandomTarget(this.theEntityCreature, 5, 4); + + if (vec3 == null) + { + return false; + } + else + { + this.randPosX = vec3.xCoord; + this.randPosY = vec3.yCoord; + this.randPosZ = vec3.zCoord; + return true; + } + } + } + + public void startExecuting() + { + this.theEntityCreature.getNavigator().tryMoveToXYZ(this.randPosX, this.randPosY, this.randPosZ, this.speed); + } + + public boolean continueExecuting() + { + return !this.theEntityCreature.getNavigator().noPath(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAIPlay.java b/src/main/java/net/minecraft/entity/ai/EntityAIPlay.java new file mode 100644 index 0000000..d12ca1e --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAIPlay.java @@ -0,0 +1,114 @@ +package net.minecraft.entity.ai; + +import java.util.Iterator; +import java.util.List; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.passive.EntityVillager; +import net.minecraft.util.Vec3; + +public class EntityAIPlay extends EntityAIBase +{ + private EntityVillager villagerObj; + private EntityLivingBase targetVillager; + private double field_75261_c; + private int playTime; + private static final String __OBFID = "CL_00001605"; + + public EntityAIPlay(EntityVillager par1EntityVillager, double par2) + { + this.villagerObj = par1EntityVillager; + this.field_75261_c = par2; + this.setMutexBits(1); + } + + public boolean shouldExecute() + { + if (this.villagerObj.getGrowingAge() >= 0) + { + return false; + } + else if (this.villagerObj.getRNG().nextInt(400) != 0) + { + return false; + } + else + { + List list = this.villagerObj.worldObj.getEntitiesWithinAABB(EntityVillager.class, this.villagerObj.boundingBox.expand(6.0D, 3.0D, 6.0D)); + double d0 = Double.MAX_VALUE; + Iterator iterator = list.iterator(); + + while (iterator.hasNext()) + { + EntityVillager entityvillager = (EntityVillager)iterator.next(); + + if (entityvillager != this.villagerObj && !entityvillager.isPlaying() && entityvillager.getGrowingAge() < 0) + { + double d1 = entityvillager.getDistanceSqToEntity(this.villagerObj); + + if (d1 <= d0) + { + d0 = d1; + this.targetVillager = entityvillager; + } + } + } + + if (this.targetVillager == null) + { + Vec3 vec3 = RandomPositionGenerator.findRandomTarget(this.villagerObj, 16, 3); + + if (vec3 == null) + { + return false; + } + } + + return true; + } + } + + public boolean continueExecuting() + { + return this.playTime > 0; + } + + public void startExecuting() + { + if (this.targetVillager != null) + { + this.villagerObj.setPlaying(true); + } + + this.playTime = 1000; + } + + public void resetTask() + { + this.villagerObj.setPlaying(false); + this.targetVillager = null; + } + + public void updateTask() + { + --this.playTime; + + if (this.targetVillager != null) + { + if (this.villagerObj.getDistanceSqToEntity(this.targetVillager) > 4.0D) + { + this.villagerObj.getNavigator().tryMoveToEntityLiving(this.targetVillager, this.field_75261_c); + } + } + else if (this.villagerObj.getNavigator().noPath()) + { + Vec3 vec3 = RandomPositionGenerator.findRandomTarget(this.villagerObj, 16, 3); + + if (vec3 == null) + { + return; + } + + this.villagerObj.getNavigator().tryMoveToXYZ(vec3.xCoord, vec3.yCoord, vec3.zCoord, this.field_75261_c); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAIRestrictOpenDoor.java b/src/main/java/net/minecraft/entity/ai/EntityAIRestrictOpenDoor.java new file mode 100644 index 0000000..acff457 --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAIRestrictOpenDoor.java @@ -0,0 +1,63 @@ +package net.minecraft.entity.ai; + +import net.minecraft.entity.EntityCreature; +import net.minecraft.util.MathHelper; +import net.minecraft.village.Village; +import net.minecraft.village.VillageDoorInfo; + +public class EntityAIRestrictOpenDoor extends EntityAIBase +{ + private EntityCreature entityObj; + private VillageDoorInfo frontDoor; + private static final String __OBFID = "CL_00001610"; + + public EntityAIRestrictOpenDoor(EntityCreature par1EntityCreature) + { + this.entityObj = par1EntityCreature; + } + + public boolean shouldExecute() + { + if (this.entityObj.worldObj.isDaytime()) + { + return false; + } + else + { + Village village = this.entityObj.worldObj.villageCollectionObj.findNearestVillage(MathHelper.floor_double(this.entityObj.posX), MathHelper.floor_double(this.entityObj.posY), MathHelper.floor_double(this.entityObj.posZ), 16); + + if (village == null) + { + return false; + } + else + { + this.frontDoor = village.findNearestDoor(MathHelper.floor_double(this.entityObj.posX), MathHelper.floor_double(this.entityObj.posY), MathHelper.floor_double(this.entityObj.posZ)); + return this.frontDoor == null ? false : (double)this.frontDoor.getInsideDistanceSquare(MathHelper.floor_double(this.entityObj.posX), MathHelper.floor_double(this.entityObj.posY), MathHelper.floor_double(this.entityObj.posZ)) < 2.25D; + } + } + } + + public boolean continueExecuting() + { + return this.entityObj.worldObj.isDaytime() ? false : !this.frontDoor.isDetachedFromVillageFlag && this.frontDoor.isInside(MathHelper.floor_double(this.entityObj.posX), MathHelper.floor_double(this.entityObj.posZ)); + } + + public void startExecuting() + { + this.entityObj.getNavigator().setBreakDoors(false); + this.entityObj.getNavigator().setEnterDoors(false); + } + + public void resetTask() + { + this.entityObj.getNavigator().setBreakDoors(true); + this.entityObj.getNavigator().setEnterDoors(true); + this.frontDoor = null; + } + + public void updateTask() + { + this.frontDoor.incrementDoorOpeningRestrictionCounter(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAIRestrictSun.java b/src/main/java/net/minecraft/entity/ai/EntityAIRestrictSun.java new file mode 100644 index 0000000..7120753 --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAIRestrictSun.java @@ -0,0 +1,29 @@ +package net.minecraft.entity.ai; + +import net.minecraft.entity.EntityCreature; + +public class EntityAIRestrictSun extends EntityAIBase +{ + private EntityCreature theEntity; + private static final String __OBFID = "CL_00001611"; + + public EntityAIRestrictSun(EntityCreature par1EntityCreature) + { + this.theEntity = par1EntityCreature; + } + + public boolean shouldExecute() + { + return this.theEntity.worldObj.isDaytime(); + } + + public void startExecuting() + { + this.theEntity.getNavigator().setAvoidSun(true); + } + + public void resetTask() + { + this.theEntity.getNavigator().setAvoidSun(false); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAIRunAroundLikeCrazy.java b/src/main/java/net/minecraft/entity/ai/EntityAIRunAroundLikeCrazy.java new file mode 100644 index 0000000..816906a --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAIRunAroundLikeCrazy.java @@ -0,0 +1,83 @@ +package net.minecraft.entity.ai; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.passive.EntityHorse; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.Vec3; + +public class EntityAIRunAroundLikeCrazy extends EntityAIBase +{ + private EntityHorse horseHost; + private double field_111178_b; + private double field_111179_c; + private double field_111176_d; + private double field_111177_e; + private static final String __OBFID = "CL_00001612"; + + public EntityAIRunAroundLikeCrazy(EntityHorse par1EntityHorse, double par2) + { + this.horseHost = par1EntityHorse; + this.field_111178_b = par2; + this.setMutexBits(1); + } + + public boolean shouldExecute() + { + if (!this.horseHost.isTame() && this.horseHost.riddenByEntity != null) + { + Vec3 vec3 = RandomPositionGenerator.findRandomTarget(this.horseHost, 5, 4); + + if (vec3 == null) + { + return false; + } + else + { + this.field_111179_c = vec3.xCoord; + this.field_111176_d = vec3.yCoord; + this.field_111177_e = vec3.zCoord; + return true; + } + } + else + { + return false; + } + } + + public void startExecuting() + { + this.horseHost.getNavigator().tryMoveToXYZ(this.field_111179_c, this.field_111176_d, this.field_111177_e, this.field_111178_b); + } + + public boolean continueExecuting() + { + return !this.horseHost.getNavigator().noPath() && this.horseHost.riddenByEntity != null; + } + + public void updateTask() + { + if (this.horseHost.getRNG().nextInt(50) == 0) + { + if (this.horseHost.riddenByEntity instanceof EntityPlayer) + { + int i = this.horseHost.getTemper(); + int j = this.horseHost.getMaxTemper(); + + if (j > 0 && this.horseHost.getRNG().nextInt(j) < i) + { + this.horseHost.setTamedBy((EntityPlayer)this.horseHost.riddenByEntity); + this.horseHost.worldObj.setEntityState(this.horseHost, (byte)7); + return; + } + + this.horseHost.increaseTemper(5); + } + + this.horseHost.riddenByEntity.mountEntity((Entity)null); + this.horseHost.riddenByEntity = null; + this.horseHost.makeHorseRearWithSound(); + this.horseHost.worldObj.setEntityState(this.horseHost, (byte)6); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAISit.java b/src/main/java/net/minecraft/entity/ai/EntityAISit.java new file mode 100644 index 0000000..ca1ef5c --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAISit.java @@ -0,0 +1,54 @@ +package net.minecraft.entity.ai; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.passive.EntityTameable; + +public class EntityAISit extends EntityAIBase +{ + private EntityTameable theEntity; + private boolean isSitting; + private static final String __OBFID = "CL_00001613"; + + public EntityAISit(EntityTameable par1EntityTameable) + { + this.theEntity = par1EntityTameable; + this.setMutexBits(5); + } + + public boolean shouldExecute() + { + if (!this.theEntity.isTamed()) + { + return false; + } + else if (this.theEntity.isInWater()) + { + return false; + } + else if (!this.theEntity.onGround) + { + return false; + } + else + { + EntityLivingBase entitylivingbase = this.theEntity.getOwner(); + return entitylivingbase == null ? true : (this.theEntity.getDistanceSqToEntity(entitylivingbase) < 144.0D && entitylivingbase.getAITarget() != null ? false : this.isSitting); + } + } + + public void startExecuting() + { + this.theEntity.getNavigator().clearPathEntity(); + this.theEntity.setSitting(true); + } + + public void resetTask() + { + this.theEntity.setSitting(false); + } + + public void setSitting(boolean par1) + { + this.isSitting = par1; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAISwimming.java b/src/main/java/net/minecraft/entity/ai/EntityAISwimming.java new file mode 100644 index 0000000..f172922 --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAISwimming.java @@ -0,0 +1,29 @@ +package net.minecraft.entity.ai; + +import net.minecraft.entity.EntityLiving; + +public class EntityAISwimming extends EntityAIBase +{ + private EntityLiving theEntity; + private static final String __OBFID = "CL_00001584"; + + public EntityAISwimming(EntityLiving par1EntityLiving) + { + this.theEntity = par1EntityLiving; + this.setMutexBits(4); + par1EntityLiving.getNavigator().setCanSwim(true); + } + + public boolean shouldExecute() + { + return this.theEntity.isInWater() || this.theEntity.handleLavaMovement(); + } + + public void updateTask() + { + if (this.theEntity.getRNG().nextFloat() < 0.8F) + { + this.theEntity.getJumpHelper().setJumping(); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAITarget.java b/src/main/java/net/minecraft/entity/ai/EntityAITarget.java new file mode 100644 index 0000000..0fbb3c0 --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAITarget.java @@ -0,0 +1,189 @@ +package net.minecraft.entity.ai; + +import net.minecraft.entity.EntityCreature; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IEntityOwnable; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.attributes.IAttributeInstance; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.pathfinding.PathEntity; +import net.minecraft.pathfinding.PathPoint; +import net.minecraft.util.MathHelper; +import org.apache.commons.lang3.StringUtils; + +public abstract class EntityAITarget extends EntityAIBase +{ + protected EntityCreature taskOwner; + protected boolean shouldCheckSight; + private boolean nearbyOnly; + private int targetSearchStatus; + private int targetSearchDelay; + private int field_75298_g; + private static final String __OBFID = "CL_00001626"; + + public EntityAITarget(EntityCreature par1EntityCreature, boolean par2) + { + this(par1EntityCreature, par2, false); + } + + public EntityAITarget(EntityCreature par1EntityCreature, boolean par2, boolean par3) + { + this.taskOwner = par1EntityCreature; + this.shouldCheckSight = par2; + this.nearbyOnly = par3; + } + + public boolean continueExecuting() + { + EntityLivingBase entitylivingbase = this.taskOwner.getAttackTarget(); + + if (entitylivingbase == null) + { + return false; + } + else if (!entitylivingbase.isEntityAlive()) + { + return false; + } + else + { + double d0 = this.getTargetDistance(); + + if (this.taskOwner.getDistanceSqToEntity(entitylivingbase) > d0 * d0) + { + return false; + } + else + { + if (this.shouldCheckSight) + { + if (this.taskOwner.getEntitySenses().canSee(entitylivingbase)) + { + this.field_75298_g = 0; + } + else if (++this.field_75298_g > 60) + { + return false; + } + } + + return !(entitylivingbase instanceof EntityPlayerMP) || !((EntityPlayerMP)entitylivingbase).theItemInWorldManager.isCreative(); + } + } + } + + protected double getTargetDistance() + { + IAttributeInstance iattributeinstance = this.taskOwner.getEntityAttribute(SharedMonsterAttributes.followRange); + return iattributeinstance == null ? 16.0D : iattributeinstance.getAttributeValue(); + } + + public void startExecuting() + { + this.targetSearchStatus = 0; + this.targetSearchDelay = 0; + this.field_75298_g = 0; + } + + public void resetTask() + { + this.taskOwner.setAttackTarget((EntityLivingBase)null); + } + + protected boolean isSuitableTarget(EntityLivingBase par1EntityLivingBase, boolean par2) + { + if (par1EntityLivingBase == null) + { + return false; + } + else if (par1EntityLivingBase == this.taskOwner) + { + return false; + } + else if (!par1EntityLivingBase.isEntityAlive()) + { + return false; + } + else if (!this.taskOwner.canAttackClass(par1EntityLivingBase.getClass())) + { + return false; + } + else + { + if (this.taskOwner instanceof IEntityOwnable && StringUtils.isNotEmpty(((IEntityOwnable)this.taskOwner).getOwnerName())) + { + if (par1EntityLivingBase instanceof IEntityOwnable && ((IEntityOwnable)this.taskOwner).getOwnerName().equals(((IEntityOwnable)par1EntityLivingBase).getOwnerName())) + { + return false; + } + + if (par1EntityLivingBase == ((IEntityOwnable)this.taskOwner).getOwner()) + { + return false; + } + } + else if (par1EntityLivingBase instanceof EntityPlayer && !par2 && ((EntityPlayer)par1EntityLivingBase).capabilities.disableDamage) + { + return false; + } + + if (!this.taskOwner.isWithinHomeDistance(MathHelper.floor_double(par1EntityLivingBase.posX), MathHelper.floor_double(par1EntityLivingBase.posY), MathHelper.floor_double(par1EntityLivingBase.posZ))) + { + return false; + } + else if (this.shouldCheckSight && !this.taskOwner.getEntitySenses().canSee(par1EntityLivingBase)) + { + return false; + } + else + { + if (this.nearbyOnly) + { + if (--this.targetSearchDelay <= 0) + { + this.targetSearchStatus = 0; + } + + if (this.targetSearchStatus == 0) + { + this.targetSearchStatus = this.canEasilyReach(par1EntityLivingBase) ? 1 : 2; + } + + if (this.targetSearchStatus == 2) + { + return false; + } + } + + return true; + } + } + } + + private boolean canEasilyReach(EntityLivingBase par1EntityLivingBase) + { + this.targetSearchDelay = 10 + this.taskOwner.getRNG().nextInt(5); + PathEntity pathentity = this.taskOwner.getNavigator().getPathToEntityLiving(par1EntityLivingBase); + + if (pathentity == null) + { + return false; + } + else + { + PathPoint pathpoint = pathentity.getFinalPathPoint(); + + if (pathpoint == null) + { + return false; + } + else + { + int i = pathpoint.xCoord - MathHelper.floor_double(par1EntityLivingBase.posX); + int j = pathpoint.zCoord - MathHelper.floor_double(par1EntityLivingBase.posZ); + return (double)(i * i + j * j) <= 2.25D; + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAITargetNonTamed.java b/src/main/java/net/minecraft/entity/ai/EntityAITargetNonTamed.java new file mode 100644 index 0000000..6100cd0 --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAITargetNonTamed.java @@ -0,0 +1,20 @@ +package net.minecraft.entity.ai; + +import net.minecraft.entity.passive.EntityTameable; + +public class EntityAITargetNonTamed extends EntityAINearestAttackableTarget +{ + private EntityTameable theTameable; + private static final String __OBFID = "CL_00001623"; + + public EntityAITargetNonTamed(EntityTameable par1EntityTameable, Class par2Class, int par3, boolean par4) + { + super(par1EntityTameable, par2Class, par3, par4); + this.theTameable = par1EntityTameable; + } + + public boolean shouldExecute() + { + return !this.theTameable.isTamed() && super.shouldExecute(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAITasks.java b/src/main/java/net/minecraft/entity/ai/EntityAITasks.java new file mode 100644 index 0000000..d8c1b6d --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAITasks.java @@ -0,0 +1,181 @@ +package net.minecraft.entity.ai; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import net.minecraft.profiler.Profiler; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class EntityAITasks +{ + private static final Logger logger = LogManager.getLogger(); + public List taskEntries = new ArrayList(); + private List executingTaskEntries = new ArrayList(); + private final Profiler theProfiler; + private int tickCount; + private int tickRate = 3; + private static final String __OBFID = "CL_00001588"; + + public EntityAITasks(Profiler par1Profiler) + { + this.theProfiler = par1Profiler; + } + + public void addTask(int par1, EntityAIBase par2EntityAIBase) + { + this.taskEntries.add(new EntityAITasks.EntityAITaskEntry(par1, par2EntityAIBase)); + } + + public void removeTask(EntityAIBase par1EntityAIBase) + { + Iterator iterator = this.taskEntries.iterator(); + + while (iterator.hasNext()) + { + EntityAITasks.EntityAITaskEntry entityaitaskentry = (EntityAITasks.EntityAITaskEntry)iterator.next(); + EntityAIBase entityaibase1 = entityaitaskentry.action; + + if (entityaibase1 == par1EntityAIBase) + { + if (this.executingTaskEntries.contains(entityaitaskentry)) + { + entityaibase1.resetTask(); + this.executingTaskEntries.remove(entityaitaskentry); + } + + iterator.remove(); + } + } + } + + public void onUpdateTasks() + { + ArrayList arraylist = new ArrayList(); + Iterator iterator; + EntityAITasks.EntityAITaskEntry entityaitaskentry; + + if (this.tickCount++ % this.tickRate == 0) + { + iterator = this.taskEntries.iterator(); + + while (iterator.hasNext()) + { + entityaitaskentry = (EntityAITasks.EntityAITaskEntry)iterator.next(); + boolean flag = this.executingTaskEntries.contains(entityaitaskentry); + + if (flag) + { + if (this.canUse(entityaitaskentry) && this.canContinue(entityaitaskentry)) + { + continue; + } + + entityaitaskentry.action.resetTask(); + this.executingTaskEntries.remove(entityaitaskentry); + } + + if (this.canUse(entityaitaskentry) && entityaitaskentry.action.shouldExecute()) + { + arraylist.add(entityaitaskentry); + this.executingTaskEntries.add(entityaitaskentry); + } + } + } + else + { + iterator = this.executingTaskEntries.iterator(); + + while (iterator.hasNext()) + { + entityaitaskentry = (EntityAITasks.EntityAITaskEntry)iterator.next(); + + if (!entityaitaskentry.action.continueExecuting()) + { + entityaitaskentry.action.resetTask(); + iterator.remove(); + } + } + } + + this.theProfiler.startSection("goalStart"); + iterator = arraylist.iterator(); + + while (iterator.hasNext()) + { + entityaitaskentry = (EntityAITasks.EntityAITaskEntry)iterator.next(); + this.theProfiler.startSection(entityaitaskentry.action.getClass().getSimpleName()); + entityaitaskentry.action.startExecuting(); + this.theProfiler.endSection(); + } + + this.theProfiler.endSection(); + this.theProfiler.startSection("goalTick"); + iterator = this.executingTaskEntries.iterator(); + + while (iterator.hasNext()) + { + entityaitaskentry = (EntityAITasks.EntityAITaskEntry)iterator.next(); + entityaitaskentry.action.updateTask(); + } + + this.theProfiler.endSection(); + } + + private boolean canContinue(EntityAITasks.EntityAITaskEntry par1EntityAITaskEntry) + { + this.theProfiler.startSection("canContinue"); + boolean flag = par1EntityAITaskEntry.action.continueExecuting(); + this.theProfiler.endSection(); + return flag; + } + + private boolean canUse(EntityAITasks.EntityAITaskEntry par1EntityAITaskEntry) + { + this.theProfiler.startSection("canUse"); + Iterator iterator = this.taskEntries.iterator(); + + while (iterator.hasNext()) + { + EntityAITasks.EntityAITaskEntry entityaitaskentry = (EntityAITasks.EntityAITaskEntry)iterator.next(); + + if (entityaitaskentry != par1EntityAITaskEntry) + { + if (par1EntityAITaskEntry.priority >= entityaitaskentry.priority) + { + if (this.executingTaskEntries.contains(entityaitaskentry) && !this.areTasksCompatible(par1EntityAITaskEntry, entityaitaskentry)) + { + this.theProfiler.endSection(); + return false; + } + } + else if (this.executingTaskEntries.contains(entityaitaskentry) && !entityaitaskentry.action.isInterruptible()) + { + this.theProfiler.endSection(); + return false; + } + } + } + + this.theProfiler.endSection(); + return true; + } + + private boolean areTasksCompatible(EntityAITasks.EntityAITaskEntry par1EntityAITaskEntry, EntityAITasks.EntityAITaskEntry par2EntityAITaskEntry) + { + return (par1EntityAITaskEntry.action.getMutexBits() & par2EntityAITaskEntry.action.getMutexBits()) == 0; + } + + public class EntityAITaskEntry + { + public EntityAIBase action; + public int priority; + private static final String __OBFID = "CL_00001589"; + + public EntityAITaskEntry(int par2, EntityAIBase par3EntityAIBase) + { + this.priority = par2; + this.action = par3EntityAIBase; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAITempt.java b/src/main/java/net/minecraft/entity/ai/EntityAITempt.java new file mode 100644 index 0000000..03c8b54 --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAITempt.java @@ -0,0 +1,124 @@ +package net.minecraft.entity.ai; + +import net.minecraft.entity.EntityCreature; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +public class EntityAITempt extends EntityAIBase +{ + private EntityCreature temptedEntity; + private double field_75282_b; + private double targetX; + private double targetY; + private double targetZ; + private double field_75278_f; + private double field_75279_g; + private EntityPlayer temptingPlayer; + private int delayTemptCounter; + private boolean isRunning; + private Item field_151484_k; + private boolean scaredByPlayerMovement; + private boolean field_75286_m; + private static final String __OBFID = "CL_00001616"; + + public EntityAITempt(EntityCreature p_i45316_1_, double p_i45316_2_, Item p_i45316_4_, boolean p_i45316_5_) + { + this.temptedEntity = p_i45316_1_; + this.field_75282_b = p_i45316_2_; + this.field_151484_k = p_i45316_4_; + this.scaredByPlayerMovement = p_i45316_5_; + this.setMutexBits(3); + } + + public boolean shouldExecute() + { + if (this.delayTemptCounter > 0) + { + --this.delayTemptCounter; + return false; + } + else + { + this.temptingPlayer = this.temptedEntity.worldObj.getClosestPlayerToEntity(this.temptedEntity, 10.0D); + + if (this.temptingPlayer == null) + { + return false; + } + else + { + ItemStack itemstack = this.temptingPlayer.getCurrentEquippedItem(); + return itemstack == null ? false : itemstack.getItem() == this.field_151484_k; + } + } + } + + public boolean continueExecuting() + { + if (this.scaredByPlayerMovement) + { + if (this.temptedEntity.getDistanceSqToEntity(this.temptingPlayer) < 36.0D) + { + if (this.temptingPlayer.getDistanceSq(this.targetX, this.targetY, this.targetZ) > 0.010000000000000002D) + { + return false; + } + + if (Math.abs((double)this.temptingPlayer.rotationPitch - this.field_75278_f) > 5.0D || Math.abs((double)this.temptingPlayer.rotationYaw - this.field_75279_g) > 5.0D) + { + return false; + } + } + else + { + this.targetX = this.temptingPlayer.posX; + this.targetY = this.temptingPlayer.posY; + this.targetZ = this.temptingPlayer.posZ; + } + + this.field_75278_f = (double)this.temptingPlayer.rotationPitch; + this.field_75279_g = (double)this.temptingPlayer.rotationYaw; + } + + return this.shouldExecute(); + } + + public void startExecuting() + { + this.targetX = this.temptingPlayer.posX; + this.targetY = this.temptingPlayer.posY; + this.targetZ = this.temptingPlayer.posZ; + this.isRunning = true; + this.field_75286_m = this.temptedEntity.getNavigator().getAvoidsWater(); + this.temptedEntity.getNavigator().setAvoidsWater(false); + } + + public void resetTask() + { + this.temptingPlayer = null; + this.temptedEntity.getNavigator().clearPathEntity(); + this.delayTemptCounter = 100; + this.isRunning = false; + this.temptedEntity.getNavigator().setAvoidsWater(this.field_75286_m); + } + + public void updateTask() + { + this.temptedEntity.getLookHelper().setLookPositionWithEntity(this.temptingPlayer, 30.0F, (float)this.temptedEntity.getVerticalFaceSpeed()); + + if (this.temptedEntity.getDistanceSqToEntity(this.temptingPlayer) < 6.25D) + { + this.temptedEntity.getNavigator().clearPathEntity(); + } + else + { + this.temptedEntity.getNavigator().tryMoveToEntityLiving(this.temptingPlayer, this.field_75282_b); + } + } + + public boolean isRunning() + { + return this.isRunning; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAITradePlayer.java b/src/main/java/net/minecraft/entity/ai/EntityAITradePlayer.java new file mode 100644 index 0000000..5a41454 --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAITradePlayer.java @@ -0,0 +1,52 @@ +package net.minecraft.entity.ai; + +import net.minecraft.entity.passive.EntityVillager; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; + +public class EntityAITradePlayer extends EntityAIBase +{ + private EntityVillager villager; + private static final String __OBFID = "CL_00001617"; + + public EntityAITradePlayer(EntityVillager par1EntityVillager) + { + this.villager = par1EntityVillager; + this.setMutexBits(5); + } + + public boolean shouldExecute() + { + if (!this.villager.isEntityAlive()) + { + return false; + } + else if (this.villager.isInWater()) + { + return false; + } + else if (!this.villager.onGround) + { + return false; + } + else if (this.villager.velocityChanged) + { + return false; + } + else + { + EntityPlayer entityplayer = this.villager.getCustomer(); + return entityplayer == null ? false : (this.villager.getDistanceSqToEntity(entityplayer) > 16.0D ? false : entityplayer.openContainer instanceof Container); + } + } + + public void startExecuting() + { + this.villager.getNavigator().clearPathEntity(); + } + + public void resetTask() + { + this.villager.setCustomer((EntityPlayer)null); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAIVillagerMate.java b/src/main/java/net/minecraft/entity/ai/EntityAIVillagerMate.java new file mode 100644 index 0000000..0f88968 --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAIVillagerMate.java @@ -0,0 +1,125 @@ +package net.minecraft.entity.ai; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.passive.EntityVillager; +import net.minecraft.util.MathHelper; +import net.minecraft.village.Village; +import net.minecraft.world.World; + +public class EntityAIVillagerMate extends EntityAIBase +{ + private EntityVillager villagerObj; + private EntityVillager mate; + private World worldObj; + private int matingTimeout; + Village villageObj; + private static final String __OBFID = "CL_00001594"; + + public EntityAIVillagerMate(EntityVillager par1EntityVillager) + { + this.villagerObj = par1EntityVillager; + this.worldObj = par1EntityVillager.worldObj; + this.setMutexBits(3); + } + + public boolean shouldExecute() + { + if (this.villagerObj.getGrowingAge() != 0) + { + return false; + } + else if (this.villagerObj.getRNG().nextInt(500) != 0) + { + return false; + } + else + { + this.villageObj = this.worldObj.villageCollectionObj.findNearestVillage(MathHelper.floor_double(this.villagerObj.posX), MathHelper.floor_double(this.villagerObj.posY), MathHelper.floor_double(this.villagerObj.posZ), 0); + + if (this.villageObj == null) + { + return false; + } + else if (!this.checkSufficientDoorsPresentForNewVillager()) + { + return false; + } + else + { + Entity entity = this.worldObj.findNearestEntityWithinAABB(EntityVillager.class, this.villagerObj.boundingBox.expand(8.0D, 3.0D, 8.0D), this.villagerObj); + + if (entity == null) + { + return false; + } + else + { + this.mate = (EntityVillager)entity; + return this.mate.getGrowingAge() == 0; + } + } + } + } + + public void startExecuting() + { + this.matingTimeout = 300; + this.villagerObj.setMating(true); + } + + public void resetTask() + { + this.villageObj = null; + this.mate = null; + this.villagerObj.setMating(false); + } + + public boolean continueExecuting() + { + return this.matingTimeout >= 0 && this.checkSufficientDoorsPresentForNewVillager() && this.villagerObj.getGrowingAge() == 0; + } + + public void updateTask() + { + --this.matingTimeout; + this.villagerObj.getLookHelper().setLookPositionWithEntity(this.mate, 10.0F, 30.0F); + + if (this.villagerObj.getDistanceSqToEntity(this.mate) > 2.25D) + { + this.villagerObj.getNavigator().tryMoveToEntityLiving(this.mate, 0.25D); + } + else if (this.matingTimeout == 0 && this.mate.isMating()) + { + this.giveBirth(); + } + + if (this.villagerObj.getRNG().nextInt(35) == 0) + { + this.worldObj.setEntityState(this.villagerObj, (byte)12); + } + } + + private boolean checkSufficientDoorsPresentForNewVillager() + { + if (!this.villageObj.isMatingSeason()) + { + return false; + } + else + { + int i = (int)((double)((float)this.villageObj.getNumVillageDoors()) * 0.35D); + return this.villageObj.getNumVillagers() < i; + } + } + + private void giveBirth() + { + EntityVillager entityvillager = this.villagerObj.createChild(this.mate); + this.mate.setGrowingAge(6000); + this.villagerObj.setGrowingAge(6000); + entityvillager.setGrowingAge(-24000); + entityvillager.setLocationAndAngles(this.villagerObj.posX, this.villagerObj.posY, this.villagerObj.posZ, 0.0F, 0.0F); + this.worldObj.spawnEntityInWorld(entityvillager); + this.worldObj.setEntityState(entityvillager, (byte)12); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAIWander.java b/src/main/java/net/minecraft/entity/ai/EntityAIWander.java new file mode 100644 index 0000000..bf38852 --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAIWander.java @@ -0,0 +1,59 @@ +package net.minecraft.entity.ai; + +import net.minecraft.entity.EntityCreature; +import net.minecraft.util.Vec3; + +public class EntityAIWander extends EntityAIBase +{ + private EntityCreature entity; + private double xPosition; + private double yPosition; + private double zPosition; + private double speed; + private static final String __OBFID = "CL_00001608"; + + public EntityAIWander(EntityCreature par1EntityCreature, double par2) + { + this.entity = par1EntityCreature; + this.speed = par2; + this.setMutexBits(1); + } + + public boolean shouldExecute() + { + if (this.entity.getAge() >= 100) + { + return false; + } + else if (this.entity.getRNG().nextInt(120) != 0) + { + return false; + } + else + { + Vec3 vec3 = RandomPositionGenerator.findRandomTarget(this.entity, 10, 7); + + if (vec3 == null) + { + return false; + } + else + { + this.xPosition = vec3.xCoord; + this.yPosition = vec3.yCoord; + this.zPosition = vec3.zCoord; + return true; + } + } + } + + public boolean continueExecuting() + { + return !this.entity.getNavigator().noPath(); + } + + public void startExecuting() + { + this.entity.getNavigator().tryMoveToXYZ(this.xPosition, this.yPosition, this.zPosition, this.speed); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAIWatchClosest.java b/src/main/java/net/minecraft/entity/ai/EntityAIWatchClosest.java new file mode 100644 index 0000000..1df5281 --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAIWatchClosest.java @@ -0,0 +1,81 @@ +package net.minecraft.entity.ai; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.player.EntityPlayer; + +public class EntityAIWatchClosest extends EntityAIBase +{ + private EntityLiving theWatcher; + protected Entity closestEntity; + private float maxDistanceForPlayer; + private int lookTime; + private float field_75331_e; + private Class watchedClass; + private static final String __OBFID = "CL_00001592"; + + public EntityAIWatchClosest(EntityLiving par1EntityLiving, Class par2Class, float par3) + { + this.theWatcher = par1EntityLiving; + this.watchedClass = par2Class; + this.maxDistanceForPlayer = par3; + this.field_75331_e = 0.02F; + this.setMutexBits(2); + } + + public EntityAIWatchClosest(EntityLiving par1EntityLiving, Class par2Class, float par3, float par4) + { + this.theWatcher = par1EntityLiving; + this.watchedClass = par2Class; + this.maxDistanceForPlayer = par3; + this.field_75331_e = par4; + this.setMutexBits(2); + } + + public boolean shouldExecute() + { + if (this.theWatcher.getRNG().nextFloat() >= this.field_75331_e) + { + return false; + } + else + { + if (this.theWatcher.getAttackTarget() != null) + { + this.closestEntity = this.theWatcher.getAttackTarget(); + } + + if (this.watchedClass == EntityPlayer.class) + { + this.closestEntity = this.theWatcher.worldObj.getClosestPlayerToEntity(this.theWatcher, (double)this.maxDistanceForPlayer); + } + else + { + this.closestEntity = this.theWatcher.worldObj.findNearestEntityWithinAABB(this.watchedClass, this.theWatcher.boundingBox.expand((double)this.maxDistanceForPlayer, 3.0D, (double)this.maxDistanceForPlayer), this.theWatcher); + } + + return this.closestEntity != null; + } + } + + public boolean continueExecuting() + { + return !this.closestEntity.isEntityAlive() ? false : (this.theWatcher.getDistanceSqToEntity(this.closestEntity) > (double)(this.maxDistanceForPlayer * this.maxDistanceForPlayer) ? false : this.lookTime > 0); + } + + public void startExecuting() + { + this.lookTime = 40 + this.theWatcher.getRNG().nextInt(40); + } + + public void resetTask() + { + this.closestEntity = null; + } + + public void updateTask() + { + this.theWatcher.getLookHelper().setLookPosition(this.closestEntity.posX, this.closestEntity.posY + (double)this.closestEntity.getEyeHeight(), this.closestEntity.posZ, 10.0F, (float)this.theWatcher.getVerticalFaceSpeed()); + --this.lookTime; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityAIWatchClosest2.java b/src/main/java/net/minecraft/entity/ai/EntityAIWatchClosest2.java new file mode 100644 index 0000000..daeb94c --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityAIWatchClosest2.java @@ -0,0 +1,14 @@ +package net.minecraft.entity.ai; + +import net.minecraft.entity.EntityLiving; + +public class EntityAIWatchClosest2 extends EntityAIWatchClosest +{ + private static final String __OBFID = "CL_00001590"; + + public EntityAIWatchClosest2(EntityLiving par1EntityLiving, Class par2Class, float par3, float par4) + { + super(par1EntityLiving, par2Class, par3, par4); + this.setMutexBits(3); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityJumpHelper.java b/src/main/java/net/minecraft/entity/ai/EntityJumpHelper.java new file mode 100644 index 0000000..e5cc039 --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityJumpHelper.java @@ -0,0 +1,26 @@ +package net.minecraft.entity.ai; + +import net.minecraft.entity.EntityLiving; + +public class EntityJumpHelper +{ + private EntityLiving entity; + private boolean isJumping; + private static final String __OBFID = "CL_00001571"; + + public EntityJumpHelper(EntityLiving par1EntityLiving) + { + this.entity = par1EntityLiving; + } + + public void setJumping() + { + this.isJumping = true; + } + + public void doJump() + { + this.entity.setJumping(this.isJumping); + this.isJumping = false; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityLookHelper.java b/src/main/java/net/minecraft/entity/ai/EntityLookHelper.java new file mode 100644 index 0000000..4963520 --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityLookHelper.java @@ -0,0 +1,106 @@ +package net.minecraft.entity.ai; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.util.MathHelper; + +public class EntityLookHelper +{ + private EntityLiving entity; + private float deltaLookYaw; + private float deltaLookPitch; + private boolean isLooking; + private double posX; + private double posY; + private double posZ; + private static final String __OBFID = "CL_00001572"; + + public EntityLookHelper(EntityLiving par1EntityLiving) + { + this.entity = par1EntityLiving; + } + + public void setLookPositionWithEntity(Entity par1Entity, float par2, float par3) + { + this.posX = par1Entity.posX; + + if (par1Entity instanceof EntityLivingBase) + { + this.posY = par1Entity.posY + (double)par1Entity.getEyeHeight(); + } + else + { + this.posY = (par1Entity.boundingBox.minY + par1Entity.boundingBox.maxY) / 2.0D; + } + + this.posZ = par1Entity.posZ; + this.deltaLookYaw = par2; + this.deltaLookPitch = par3; + this.isLooking = true; + } + + public void setLookPosition(double par1, double par3, double par5, float par7, float par8) + { + this.posX = par1; + this.posY = par3; + this.posZ = par5; + this.deltaLookYaw = par7; + this.deltaLookPitch = par8; + this.isLooking = true; + } + + public void onUpdateLook() + { + this.entity.rotationPitch = 0.0F; + + if (this.isLooking) + { + this.isLooking = false; + double d0 = this.posX - this.entity.posX; + double d1 = this.posY - (this.entity.posY + (double)this.entity.getEyeHeight()); + double d2 = this.posZ - this.entity.posZ; + double d3 = (double)MathHelper.sqrt_double(d0 * d0 + d2 * d2); + float f = (float)(Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F; + float f1 = (float)(-(Math.atan2(d1, d3) * 180.0D / Math.PI)); + this.entity.rotationPitch = this.updateRotation(this.entity.rotationPitch, f1, this.deltaLookPitch); + this.entity.rotationYawHead = this.updateRotation(this.entity.rotationYawHead, f, this.deltaLookYaw); + } + else + { + this.entity.rotationYawHead = this.updateRotation(this.entity.rotationYawHead, this.entity.renderYawOffset, 10.0F); + } + + float f2 = MathHelper.wrapAngleTo180_float(this.entity.rotationYawHead - this.entity.renderYawOffset); + + if (!this.entity.getNavigator().noPath()) + { + if (f2 < -75.0F) + { + this.entity.rotationYawHead = this.entity.renderYawOffset - 75.0F; + } + + if (f2 > 75.0F) + { + this.entity.rotationYawHead = this.entity.renderYawOffset + 75.0F; + } + } + } + + private float updateRotation(float par1, float par2, float par3) + { + float f3 = MathHelper.wrapAngleTo180_float(par2 - par1); + + if (f3 > par3) + { + f3 = par3; + } + + if (f3 < -par3) + { + f3 = -par3; + } + + return par1 + f3; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityMinecartMobSpawner.java b/src/main/java/net/minecraft/entity/ai/EntityMinecartMobSpawner.java new file mode 100644 index 0000000..f96025b --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityMinecartMobSpawner.java @@ -0,0 +1,90 @@ +package net.minecraft.entity.ai; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.entity.item.EntityMinecart; +import net.minecraft.init.Blocks; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.MobSpawnerBaseLogic; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class EntityMinecartMobSpawner extends EntityMinecart +{ + private final MobSpawnerBaseLogic mobSpawnerLogic = new MobSpawnerBaseLogic() + { + private static final String __OBFID = "CL_00001679"; + public void func_98267_a(int par1) + { + EntityMinecartMobSpawner.this.worldObj.setEntityState(EntityMinecartMobSpawner.this, (byte)par1); + } + public World getSpawnerWorld() + { + return EntityMinecartMobSpawner.this.worldObj; + } + public int getSpawnerX() + { + return MathHelper.floor_double(EntityMinecartMobSpawner.this.posX); + } + public int getSpawnerY() + { + return MathHelper.floor_double(EntityMinecartMobSpawner.this.posY); + } + public int getSpawnerZ() + { + return MathHelper.floor_double(EntityMinecartMobSpawner.this.posZ); + } + }; + private static final String __OBFID = "CL_00001678"; + + public EntityMinecartMobSpawner(World par1World) + { + super(par1World); + } + + public EntityMinecartMobSpawner(World par1World, double par2, double par4, double par6) + { + super(par1World, par2, par4, par6); + } + + public int getMinecartType() + { + return 4; + } + + public Block func_145817_o() + { + return Blocks.mob_spawner; + } + + protected void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + super.readEntityFromNBT(par1NBTTagCompound); + this.mobSpawnerLogic.readFromNBT(par1NBTTagCompound); + } + + protected void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeEntityToNBT(par1NBTTagCompound); + this.mobSpawnerLogic.writeToNBT(par1NBTTagCompound); + } + + @SideOnly(Side.CLIENT) + public void handleHealthUpdate(byte par1) + { + this.mobSpawnerLogic.setDelayToMin(par1); + } + + public void onUpdate() + { + super.onUpdate(); + this.mobSpawnerLogic.updateSpawner(); + } + + @SideOnly(Side.CLIENT) + public MobSpawnerBaseLogic func_98039_d() + { + return this.mobSpawnerLogic; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntityMoveHelper.java b/src/main/java/net/minecraft/entity/ai/EntityMoveHelper.java new file mode 100644 index 0000000..0131871 --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntityMoveHelper.java @@ -0,0 +1,87 @@ +package net.minecraft.entity.ai; + +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.util.MathHelper; + +public class EntityMoveHelper +{ + private EntityLiving entity; + private double posX; + private double posY; + private double posZ; + private double speed; + private boolean update; + private static final String __OBFID = "CL_00001573"; + + public EntityMoveHelper(EntityLiving par1EntityLiving) + { + this.entity = par1EntityLiving; + this.posX = par1EntityLiving.posX; + this.posY = par1EntityLiving.posY; + this.posZ = par1EntityLiving.posZ; + } + + public boolean isUpdating() + { + return this.update; + } + + public double getSpeed() + { + return this.speed; + } + + public void setMoveTo(double par1, double par3, double par5, double par7) + { + this.posX = par1; + this.posY = par3; + this.posZ = par5; + this.speed = par7; + this.update = true; + } + + public void onUpdateMoveHelper() + { + this.entity.setMoveForward(0.0F); + + if (this.update) + { + this.update = false; + int i = MathHelper.floor_double(this.entity.boundingBox.minY + 0.5D); + double d0 = this.posX - this.entity.posX; + double d1 = this.posZ - this.entity.posZ; + double d2 = this.posY - (double)i; + double d3 = d0 * d0 + d2 * d2 + d1 * d1; + + if (d3 >= 2.500000277905201E-7D) + { + float f = (float)(Math.atan2(d1, d0) * 180.0D / Math.PI) - 90.0F; + this.entity.rotationYaw = this.limitAngle(this.entity.rotationYaw, f, 30.0F); + this.entity.setAIMoveSpeed((float)(this.speed * this.entity.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue())); + + if (d2 > 0.0D && d0 * d0 + d1 * d1 < 1.0D) + { + this.entity.getJumpHelper().setJumping(); + } + } + } + } + + private float limitAngle(float par1, float par2, float par3) + { + float f3 = MathHelper.wrapAngleTo180_float(par2 - par1); + + if (f3 > par3) + { + f3 = par3; + } + + if (f3 < -par3) + { + f3 = -par3; + } + + return par1 + f3; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/EntitySenses.java b/src/main/java/net/minecraft/entity/ai/EntitySenses.java new file mode 100644 index 0000000..32a1285 --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/EntitySenses.java @@ -0,0 +1,54 @@ +package net.minecraft.entity.ai; + +import java.util.ArrayList; +import java.util.List; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; + +public class EntitySenses +{ + EntityLiving entityObj; + List seenEntities = new ArrayList(); + List unseenEntities = new ArrayList(); + private static final String __OBFID = "CL_00001628"; + + public EntitySenses(EntityLiving par1EntityLiving) + { + this.entityObj = par1EntityLiving; + } + + public void clearSensingCache() + { + this.seenEntities.clear(); + this.unseenEntities.clear(); + } + + public boolean canSee(Entity par1Entity) + { + if (this.seenEntities.contains(par1Entity)) + { + return true; + } + else if (this.unseenEntities.contains(par1Entity)) + { + return false; + } + else + { + this.entityObj.worldObj.theProfiler.startSection("canSee"); + boolean flag = this.entityObj.canEntityBeSeen(par1Entity); + this.entityObj.worldObj.theProfiler.endSection(); + + if (flag) + { + this.seenEntities.add(par1Entity); + } + else + { + this.unseenEntities.add(par1Entity); + } + + return flag; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/RandomPositionGenerator.java b/src/main/java/net/minecraft/entity/ai/RandomPositionGenerator.java new file mode 100644 index 0000000..932cb37 --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/RandomPositionGenerator.java @@ -0,0 +1,92 @@ +package net.minecraft.entity.ai; + +import java.util.Random; +import net.minecraft.entity.EntityCreature; +import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; + +public class RandomPositionGenerator +{ + private static Vec3 staticVector = Vec3.createVectorHelper(0.0D, 0.0D, 0.0D); + private static final String __OBFID = "CL_00001629"; + + public static Vec3 findRandomTarget(EntityCreature par0EntityCreature, int par1, int par2) + { + return findRandomTargetBlock(par0EntityCreature, par1, par2, (Vec3)null); + } + + public static Vec3 findRandomTargetBlockTowards(EntityCreature par0EntityCreature, int par1, int par2, Vec3 par3Vec3) + { + staticVector.xCoord = par3Vec3.xCoord - par0EntityCreature.posX; + staticVector.yCoord = par3Vec3.yCoord - par0EntityCreature.posY; + staticVector.zCoord = par3Vec3.zCoord - par0EntityCreature.posZ; + return findRandomTargetBlock(par0EntityCreature, par1, par2, staticVector); + } + + public static Vec3 findRandomTargetBlockAwayFrom(EntityCreature par0EntityCreature, int par1, int par2, Vec3 par3Vec3) + { + staticVector.xCoord = par0EntityCreature.posX - par3Vec3.xCoord; + staticVector.yCoord = par0EntityCreature.posY - par3Vec3.yCoord; + staticVector.zCoord = par0EntityCreature.posZ - par3Vec3.zCoord; + return findRandomTargetBlock(par0EntityCreature, par1, par2, staticVector); + } + + private static Vec3 findRandomTargetBlock(EntityCreature par0EntityCreature, int par1, int par2, Vec3 par3Vec3) + { + Random random = par0EntityCreature.getRNG(); + boolean flag = false; + int k = 0; + int l = 0; + int i1 = 0; + float f = -99999.0F; + boolean flag1; + + if (par0EntityCreature.hasHome()) + { + double d0 = (double)(par0EntityCreature.getHomePosition().getDistanceSquared(MathHelper.floor_double(par0EntityCreature.posX), MathHelper.floor_double(par0EntityCreature.posY), MathHelper.floor_double(par0EntityCreature.posZ)) + 4.0F); + double d1 = (double)(par0EntityCreature.func_110174_bM() + (float)par1); + flag1 = d0 < d1 * d1; + } + else + { + flag1 = false; + } + + for (int l1 = 0; l1 < 10; ++l1) + { + int j1 = random.nextInt(2 * par1) - par1; + int i2 = random.nextInt(2 * par2) - par2; + int k1 = random.nextInt(2 * par1) - par1; + + if (par3Vec3 == null || (double)j1 * par3Vec3.xCoord + (double)k1 * par3Vec3.zCoord >= 0.0D) + { + j1 += MathHelper.floor_double(par0EntityCreature.posX); + i2 += MathHelper.floor_double(par0EntityCreature.posY); + k1 += MathHelper.floor_double(par0EntityCreature.posZ); + + if (!flag1 || par0EntityCreature.isWithinHomeDistance(j1, i2, k1)) + { + float f1 = par0EntityCreature.getBlockPathWeight(j1, i2, k1); + + if (f1 > f) + { + f = f1; + k = j1; + l = i2; + i1 = k1; + flag = true; + } + } + } + } + + if (flag) + { + return par0EntityCreature.worldObj.getWorldVec3Pool().getVecFromPool((double)k, (double)l, (double)i1); + } + else + { + return null; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/attributes/AttributeModifier.java b/src/main/java/net/minecraft/entity/ai/attributes/AttributeModifier.java new file mode 100644 index 0000000..43f45ff --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/attributes/AttributeModifier.java @@ -0,0 +1,101 @@ +package net.minecraft.entity.ai.attributes; + +import java.util.UUID; +import org.apache.commons.lang3.Validate; + +public class AttributeModifier +{ + private final double amount; + private final int operation; + private final String name; + private final UUID id; + private boolean isSaved; + private static final String __OBFID = "CL_00001564"; + + public AttributeModifier(String par1Str, double par2, int par4) + { + this(UUID.randomUUID(), par1Str, par2, par4); + } + + public AttributeModifier(UUID par1UUID, String par2Str, double par3, int par5) + { + this.isSaved = true; + this.id = par1UUID; + this.name = par2Str; + this.amount = par3; + this.operation = par5; + Validate.notEmpty(par2Str, "Modifier name cannot be empty", new Object[0]); + Validate.inclusiveBetween(Integer.valueOf(0), Integer.valueOf(2), Integer.valueOf(par5), "Invalid operation", new Object[0]); + } + + public UUID getID() + { + return this.id; + } + + public String getName() + { + return this.name; + } + + public int getOperation() + { + return this.operation; + } + + public double getAmount() + { + return this.amount; + } + + public boolean isSaved() + { + return this.isSaved; + } + + public AttributeModifier setSaved(boolean par1) + { + this.isSaved = par1; + return this; + } + + public boolean equals(Object par1Obj) + { + if (this == par1Obj) + { + return true; + } + else if (par1Obj != null && this.getClass() == par1Obj.getClass()) + { + AttributeModifier attributemodifier = (AttributeModifier)par1Obj; + + if (this.id != null) + { + if (!this.id.equals(attributemodifier.id)) + { + return false; + } + } + else if (attributemodifier.id != null) + { + return false; + } + + return true; + } + else + { + return false; + } + } + + public int hashCode() + { + return this.id != null ? this.id.hashCode() : 0; + } + + public String toString() + { + return "AttributeModifier{amount=" + this.amount + ", operation=" + this.operation + ", name=\'" + this.name + '\'' + ", id=" + this.id + ", serialize=" + this.isSaved + '}'; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/attributes/BaseAttribute.java b/src/main/java/net/minecraft/entity/ai/attributes/BaseAttribute.java new file mode 100644 index 0000000..558bf35 --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/attributes/BaseAttribute.java @@ -0,0 +1,46 @@ +package net.minecraft.entity.ai.attributes; + +public abstract class BaseAttribute implements IAttribute +{ + private final String unlocalizedName; + private final double defaultValue; + private boolean shouldWatch; + private static final String __OBFID = "CL_00001565"; + + protected BaseAttribute(String par1Str, double par2) + { + this.unlocalizedName = par1Str; + this.defaultValue = par2; + + if (par1Str == null) + { + throw new IllegalArgumentException("Name cannot be null!"); + } + } + + public String getAttributeUnlocalizedName() + { + return this.unlocalizedName; + } + + public double getDefaultValue() + { + return this.defaultValue; + } + + public boolean getShouldWatch() + { + return this.shouldWatch; + } + + public BaseAttribute setShouldWatch(boolean par1) + { + this.shouldWatch = par1; + return this; + } + + public int hashCode() + { + return this.unlocalizedName.hashCode(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/attributes/BaseAttributeMap.java b/src/main/java/net/minecraft/entity/ai/attributes/BaseAttributeMap.java new file mode 100644 index 0000000..987575e --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/attributes/BaseAttributeMap.java @@ -0,0 +1,68 @@ +package net.minecraft.entity.ai.attributes; + +import com.google.common.collect.Multimap; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; +import net.minecraft.server.management.LowerStringMap; + +public abstract class BaseAttributeMap +{ + protected final Map attributes = new HashMap(); + protected final Map attributesByName = new LowerStringMap(); + private static final String __OBFID = "CL_00001566"; + + public IAttributeInstance getAttributeInstance(IAttribute par1Attribute) + { + return (IAttributeInstance)this.attributes.get(par1Attribute); + } + + public IAttributeInstance getAttributeInstanceByName(String par1Str) + { + return (IAttributeInstance)this.attributesByName.get(par1Str); + } + + public abstract IAttributeInstance registerAttribute(IAttribute var1); + + public Collection getAllAttributes() + { + return this.attributesByName.values(); + } + + public void addAttributeInstance(ModifiableAttributeInstance par1ModifiableAttributeInstance) {} + + public void removeAttributeModifiers(Multimap par1Multimap) + { + Iterator iterator = par1Multimap.entries().iterator(); + + while (iterator.hasNext()) + { + Entry entry = (Entry)iterator.next(); + IAttributeInstance iattributeinstance = this.getAttributeInstanceByName((String)entry.getKey()); + + if (iattributeinstance != null) + { + iattributeinstance.removeModifier((AttributeModifier)entry.getValue()); + } + } + } + + public void applyAttributeModifiers(Multimap par1Multimap) + { + Iterator iterator = par1Multimap.entries().iterator(); + + while (iterator.hasNext()) + { + Entry entry = (Entry)iterator.next(); + IAttributeInstance iattributeinstance = this.getAttributeInstanceByName((String)entry.getKey()); + + if (iattributeinstance != null) + { + iattributeinstance.removeModifier((AttributeModifier)entry.getValue()); + iattributeinstance.applyModifier((AttributeModifier)entry.getValue()); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/attributes/IAttribute.java b/src/main/java/net/minecraft/entity/ai/attributes/IAttribute.java new file mode 100644 index 0000000..d1cd16d --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/attributes/IAttribute.java @@ -0,0 +1,12 @@ +package net.minecraft.entity.ai.attributes; + +public interface IAttribute +{ + String getAttributeUnlocalizedName(); + + double clampValue(double var1); + + double getDefaultValue(); + + boolean getShouldWatch(); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/attributes/IAttributeInstance.java b/src/main/java/net/minecraft/entity/ai/attributes/IAttributeInstance.java new file mode 100644 index 0000000..59ef857 --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/attributes/IAttributeInstance.java @@ -0,0 +1,28 @@ +package net.minecraft.entity.ai.attributes; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Collection; +import java.util.UUID; + +public interface IAttributeInstance +{ + IAttribute getAttribute(); + + double getBaseValue(); + + void setBaseValue(double var1); + + Collection func_111122_c(); + + AttributeModifier getModifier(UUID var1); + + void applyModifier(AttributeModifier var1); + + void removeModifier(AttributeModifier var1); + + @SideOnly(Side.CLIENT) + void removeAllModifiers(); + + double getAttributeValue(); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/attributes/ModifiableAttributeInstance.java b/src/main/java/net/minecraft/entity/ai/attributes/ModifiableAttributeInstance.java new file mode 100644 index 0000000..9bef987 --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/attributes/ModifiableAttributeInstance.java @@ -0,0 +1,187 @@ +package net.minecraft.entity.ai.attributes; + +import com.google.common.collect.Maps; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; +import java.util.UUID; + +public class ModifiableAttributeInstance implements IAttributeInstance +{ + private final BaseAttributeMap attributeMap; + private final IAttribute genericAttribute; + private final Map mapByOperation = Maps.newHashMap(); + private final Map mapByName = Maps.newHashMap(); + private final Map mapByUUID = Maps.newHashMap(); + private double baseValue; + private boolean needsUpdate = true; + private double cachedValue; + private static final String __OBFID = "CL_00001567"; + + public ModifiableAttributeInstance(BaseAttributeMap par1BaseAttributeMap, IAttribute par2Attribute) + { + this.attributeMap = par1BaseAttributeMap; + this.genericAttribute = par2Attribute; + this.baseValue = par2Attribute.getDefaultValue(); + + for (int i = 0; i < 3; ++i) + { + this.mapByOperation.put(Integer.valueOf(i), new HashSet()); + } + } + + public IAttribute getAttribute() + { + return this.genericAttribute; + } + + public double getBaseValue() + { + return this.baseValue; + } + + public void setBaseValue(double par1) + { + if (par1 != this.getBaseValue()) + { + this.baseValue = par1; + this.flagForUpdate(); + } + } + + public Collection getModifiersByOperation(int par1) + { + return (Collection)this.mapByOperation.get(Integer.valueOf(par1)); + } + + public Collection func_111122_c() + { + HashSet hashset = new HashSet(); + + for (int i = 0; i < 3; ++i) + { + hashset.addAll(this.getModifiersByOperation(i)); + } + + return hashset; + } + + public AttributeModifier getModifier(UUID par1UUID) + { + return (AttributeModifier)this.mapByUUID.get(par1UUID); + } + + public void applyModifier(AttributeModifier par1AttributeModifier) + { + if (this.getModifier(par1AttributeModifier.getID()) != null) + { + throw new IllegalArgumentException("Modifier is already applied on this attribute!"); + } + else + { + Object object = (Set)this.mapByName.get(par1AttributeModifier.getName()); + + if (object == null) + { + object = new HashSet(); + this.mapByName.put(par1AttributeModifier.getName(), object); + } + + ((Set)this.mapByOperation.get(Integer.valueOf(par1AttributeModifier.getOperation()))).add(par1AttributeModifier); + ((Set)object).add(par1AttributeModifier); + this.mapByUUID.put(par1AttributeModifier.getID(), par1AttributeModifier); + this.flagForUpdate(); + } + } + + private void flagForUpdate() + { + this.needsUpdate = true; + this.attributeMap.addAttributeInstance(this); + } + + public void removeModifier(AttributeModifier par1AttributeModifier) + { + for (int i = 0; i < 3; ++i) + { + Set set = (Set)this.mapByOperation.get(Integer.valueOf(i)); + set.remove(par1AttributeModifier); + } + + Set set1 = (Set)this.mapByName.get(par1AttributeModifier.getName()); + + if (set1 != null) + { + set1.remove(par1AttributeModifier); + + if (set1.isEmpty()) + { + this.mapByName.remove(par1AttributeModifier.getName()); + } + } + + this.mapByUUID.remove(par1AttributeModifier.getID()); + this.flagForUpdate(); + } + + @SideOnly(Side.CLIENT) + public void removeAllModifiers() + { + Collection collection = this.func_111122_c(); + + if (collection != null) + { + ArrayList arraylist = new ArrayList(collection); + Iterator iterator = arraylist.iterator(); + + while (iterator.hasNext()) + { + AttributeModifier attributemodifier = (AttributeModifier)iterator.next(); + this.removeModifier(attributemodifier); + } + } + } + + public double getAttributeValue() + { + if (this.needsUpdate) + { + this.cachedValue = this.computeValue(); + this.needsUpdate = false; + } + + return this.cachedValue; + } + + private double computeValue() + { + double d0 = this.getBaseValue(); + AttributeModifier attributemodifier; + + for (Iterator iterator = this.getModifiersByOperation(0).iterator(); iterator.hasNext(); d0 += attributemodifier.getAmount()) + { + attributemodifier = (AttributeModifier)iterator.next(); + } + + double d1 = d0; + Iterator iterator1; + AttributeModifier attributemodifier1; + + for (iterator1 = this.getModifiersByOperation(1).iterator(); iterator1.hasNext(); d1 += d0 * attributemodifier1.getAmount()) + { + attributemodifier1 = (AttributeModifier)iterator1.next(); + } + + for (iterator1 = this.getModifiersByOperation(2).iterator(); iterator1.hasNext(); d1 *= 1.0D + attributemodifier1.getAmount()) + { + attributemodifier1 = (AttributeModifier)iterator1.next(); + } + + return this.genericAttribute.clampValue(d1); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/attributes/RangedAttribute.java b/src/main/java/net/minecraft/entity/ai/attributes/RangedAttribute.java new file mode 100644 index 0000000..0e8c78c --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/attributes/RangedAttribute.java @@ -0,0 +1,55 @@ +package net.minecraft.entity.ai.attributes; + +public class RangedAttribute extends BaseAttribute +{ + private final double minimumValue; + private final double maximumValue; + private String description; + private static final String __OBFID = "CL_00001568"; + + public RangedAttribute(String par1Str, double par2, double par4, double par6) + { + super(par1Str, par2); + this.minimumValue = par4; + this.maximumValue = par6; + + if (par4 > par6) + { + throw new IllegalArgumentException("Minimum value cannot be bigger than maximum value!"); + } + else if (par2 < par4) + { + throw new IllegalArgumentException("Default value cannot be lower than minimum value!"); + } + else if (par2 > par6) + { + throw new IllegalArgumentException("Default value cannot be bigger than maximum value!"); + } + } + + public RangedAttribute setDescription(String par1Str) + { + this.description = par1Str; + return this; + } + + public String getDescription() + { + return this.description; + } + + public double clampValue(double par1) + { + if (par1 < this.minimumValue) + { + par1 = this.minimumValue; + } + + if (par1 > this.maximumValue) + { + par1 = this.maximumValue; + } + + return par1; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/ai/attributes/ServersideAttributeMap.java b/src/main/java/net/minecraft/entity/ai/attributes/ServersideAttributeMap.java new file mode 100644 index 0000000..7c3116c --- /dev/null +++ b/src/main/java/net/minecraft/entity/ai/attributes/ServersideAttributeMap.java @@ -0,0 +1,85 @@ +package net.minecraft.entity.ai.attributes; + +import com.google.common.collect.Sets; +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; +import net.minecraft.server.management.LowerStringMap; + +public class ServersideAttributeMap extends BaseAttributeMap +{ + private final Set attributeInstanceSet = Sets.newHashSet(); + protected final Map descriptionToAttributeInstanceMap = new LowerStringMap(); + private static final String __OBFID = "CL_00001569"; + + public ModifiableAttributeInstance getAttributeInstance(IAttribute par1Attribute) + { + return (ModifiableAttributeInstance)super.getAttributeInstance(par1Attribute); + } + + public ModifiableAttributeInstance getAttributeInstanceByName(String par1Str) + { + IAttributeInstance iattributeinstance = super.getAttributeInstanceByName(par1Str); + + if (iattributeinstance == null) + { + iattributeinstance = (IAttributeInstance)this.descriptionToAttributeInstanceMap.get(par1Str); + } + + return (ModifiableAttributeInstance)iattributeinstance; + } + + public IAttributeInstance registerAttribute(IAttribute par1Attribute) + { + if (this.attributesByName.containsKey(par1Attribute.getAttributeUnlocalizedName())) + { + throw new IllegalArgumentException("Attribute is already registered!"); + } + else + { + ModifiableAttributeInstance modifiableattributeinstance = new ModifiableAttributeInstance(this, par1Attribute); + this.attributesByName.put(par1Attribute.getAttributeUnlocalizedName(), modifiableattributeinstance); + + if (par1Attribute instanceof RangedAttribute && ((RangedAttribute)par1Attribute).getDescription() != null) + { + this.descriptionToAttributeInstanceMap.put(((RangedAttribute)par1Attribute).getDescription(), modifiableattributeinstance); + } + + this.attributes.put(par1Attribute, modifiableattributeinstance); + return modifiableattributeinstance; + } + } + + public void addAttributeInstance(ModifiableAttributeInstance par1ModifiableAttributeInstance) + { + if (par1ModifiableAttributeInstance.getAttribute().getShouldWatch()) + { + this.attributeInstanceSet.add(par1ModifiableAttributeInstance); + } + } + + public Set getAttributeInstanceSet() + { + return this.attributeInstanceSet; + } + + public Collection getWatchedAttributes() + { + HashSet hashset = Sets.newHashSet(); + Iterator iterator = this.getAllAttributes().iterator(); + + while (iterator.hasNext()) + { + IAttributeInstance iattributeinstance = (IAttributeInstance)iterator.next(); + + if (iattributeinstance.getAttribute().getShouldWatch()) + { + hashset.add(iattributeinstance); + } + } + + return hashset; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/boss/BossStatus.java b/src/main/java/net/minecraft/entity/boss/BossStatus.java new file mode 100644 index 0000000..2292c7c --- /dev/null +++ b/src/main/java/net/minecraft/entity/boss/BossStatus.java @@ -0,0 +1,22 @@ +package net.minecraft.entity.boss; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public final class BossStatus +{ + public static float healthScale; + public static int statusBarTime; + public static String bossName; + public static boolean hasColorModifier; + private static final String __OBFID = "CL_00000941"; + + public static void setBossStatus(IBossDisplayData par0IBossDisplayData, boolean par1) + { + healthScale = par0IBossDisplayData.getHealth() / par0IBossDisplayData.getMaxHealth(); + statusBarTime = 100; + bossName = par0IBossDisplayData.func_145748_c_().getFormattedText(); + hasColorModifier = par1; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/boss/EntityDragon.java b/src/main/java/net/minecraft/entity/boss/EntityDragon.java new file mode 100644 index 0000000..6e6e0f5 --- /dev/null +++ b/src/main/java/net/minecraft/entity/boss/EntityDragon.java @@ -0,0 +1,678 @@ +package net.minecraft.entity.boss; + +import java.util.Iterator; +import java.util.List; +import net.minecraft.block.Block; +import net.minecraft.block.BlockEndPortal; +import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IEntityMultiPart; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.item.EntityEnderCrystal; +import net.minecraft.entity.item.EntityXPOrb; +import net.minecraft.entity.monster.IMob; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; +import net.minecraft.world.Explosion; +import net.minecraft.world.World; + +public class EntityDragon extends EntityLiving implements IBossDisplayData, IEntityMultiPart, IMob +{ + public double targetX; + public double targetY; + public double targetZ; + public double[][] ringBuffer = new double[64][3]; + public int ringBufferIndex = -1; + public EntityDragonPart[] dragonPartArray; + public EntityDragonPart dragonPartHead; + public EntityDragonPart dragonPartBody; + public EntityDragonPart dragonPartTail1; + public EntityDragonPart dragonPartTail2; + public EntityDragonPart dragonPartTail3; + public EntityDragonPart dragonPartWing1; + public EntityDragonPart dragonPartWing2; + public float prevAnimTime; + public float animTime; + public boolean forceNewTarget; + public boolean slowed; + private Entity target; + public int deathTicks; + public EntityEnderCrystal healingEnderCrystal; + private static final String __OBFID = "CL_00001659"; + + public EntityDragon(World par1World) + { + super(par1World); + this.dragonPartArray = new EntityDragonPart[] {this.dragonPartHead = new EntityDragonPart(this, "head", 6.0F, 6.0F), this.dragonPartBody = new EntityDragonPart(this, "body", 8.0F, 8.0F), this.dragonPartTail1 = new EntityDragonPart(this, "tail", 4.0F, 4.0F), this.dragonPartTail2 = new EntityDragonPart(this, "tail", 4.0F, 4.0F), this.dragonPartTail3 = new EntityDragonPart(this, "tail", 4.0F, 4.0F), this.dragonPartWing1 = new EntityDragonPart(this, "wing", 4.0F, 4.0F), this.dragonPartWing2 = new EntityDragonPart(this, "wing", 4.0F, 4.0F)}; + this.setHealth(this.getMaxHealth()); + this.setSize(16.0F, 8.0F); + this.noClip = true; + this.isImmuneToFire = true; + this.targetY = 100.0D; + this.ignoreFrustumCheck = true; + } + + protected void applyEntityAttributes() + { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(200.0D); + } + + protected void entityInit() + { + super.entityInit(); + } + + public double[] getMovementOffsets(int par1, float par2) + { + if (this.getHealth() <= 0.0F) + { + par2 = 0.0F; + } + + par2 = 1.0F - par2; + int j = this.ringBufferIndex - par1 * 1 & 63; + int k = this.ringBufferIndex - par1 * 1 - 1 & 63; + double[] adouble = new double[3]; + double d0 = this.ringBuffer[j][0]; + double d1 = MathHelper.wrapAngleTo180_double(this.ringBuffer[k][0] - d0); + adouble[0] = d0 + d1 * (double)par2; + d0 = this.ringBuffer[j][1]; + d1 = this.ringBuffer[k][1] - d0; + adouble[1] = d0 + d1 * (double)par2; + adouble[2] = this.ringBuffer[j][2] + (this.ringBuffer[k][2] - this.ringBuffer[j][2]) * (double)par2; + return adouble; + } + + public void onLivingUpdate() + { + float f; + float f1; + + if (this.worldObj.isRemote) + { + f = MathHelper.cos(this.animTime * (float)Math.PI * 2.0F); + f1 = MathHelper.cos(this.prevAnimTime * (float)Math.PI * 2.0F); + + if (f1 <= -0.3F && f >= -0.3F) + { + this.worldObj.playSound(this.posX, this.posY, this.posZ, "mob.enderdragon.wings", 5.0F, 0.8F + this.rand.nextFloat() * 0.3F, false); + } + } + + this.prevAnimTime = this.animTime; + float f2; + + if (this.getHealth() <= 0.0F) + { + f = (this.rand.nextFloat() - 0.5F) * 8.0F; + f1 = (this.rand.nextFloat() - 0.5F) * 4.0F; + f2 = (this.rand.nextFloat() - 0.5F) * 8.0F; + this.worldObj.spawnParticle("largeexplode", this.posX + (double)f, this.posY + 2.0D + (double)f1, this.posZ + (double)f2, 0.0D, 0.0D, 0.0D); + } + else + { + this.updateDragonEnderCrystal(); + f = 0.2F / (MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ) * 10.0F + 1.0F); + f *= (float)Math.pow(2.0D, this.motionY); + + if (this.slowed) + { + this.animTime += f * 0.5F; + } + else + { + this.animTime += f; + } + + this.rotationYaw = MathHelper.wrapAngleTo180_float(this.rotationYaw); + + if (this.ringBufferIndex < 0) + { + for (int i = 0; i < this.ringBuffer.length; ++i) + { + this.ringBuffer[i][0] = (double)this.rotationYaw; + this.ringBuffer[i][1] = this.posY; + } + } + + if (++this.ringBufferIndex == this.ringBuffer.length) + { + this.ringBufferIndex = 0; + } + + this.ringBuffer[this.ringBufferIndex][0] = (double)this.rotationYaw; + this.ringBuffer[this.ringBufferIndex][1] = this.posY; + double d0; + double d1; + double d2; + double d10; + float f12; + + if (this.worldObj.isRemote) + { + if (this.newPosRotationIncrements > 0) + { + d10 = this.posX + (this.newPosX - this.posX) / (double)this.newPosRotationIncrements; + d0 = this.posY + (this.newPosY - this.posY) / (double)this.newPosRotationIncrements; + d1 = this.posZ + (this.newPosZ - this.posZ) / (double)this.newPosRotationIncrements; + d2 = MathHelper.wrapAngleTo180_double(this.newRotationYaw - (double)this.rotationYaw); + this.rotationYaw = (float)((double)this.rotationYaw + d2 / (double)this.newPosRotationIncrements); + this.rotationPitch = (float)((double)this.rotationPitch + (this.newRotationPitch - (double)this.rotationPitch) / (double)this.newPosRotationIncrements); + --this.newPosRotationIncrements; + this.setPosition(d10, d0, d1); + this.setRotation(this.rotationYaw, this.rotationPitch); + } + } + else + { + d10 = this.targetX - this.posX; + d0 = this.targetY - this.posY; + d1 = this.targetZ - this.posZ; + d2 = d10 * d10 + d0 * d0 + d1 * d1; + + if (this.target != null) + { + this.targetX = this.target.posX; + this.targetZ = this.target.posZ; + double d3 = this.targetX - this.posX; + double d5 = this.targetZ - this.posZ; + double d7 = Math.sqrt(d3 * d3 + d5 * d5); + double d8 = 0.4000000059604645D + d7 / 80.0D - 1.0D; + + if (d8 > 10.0D) + { + d8 = 10.0D; + } + + this.targetY = this.target.boundingBox.minY + d8; + } + else + { + this.targetX += this.rand.nextGaussian() * 2.0D; + this.targetZ += this.rand.nextGaussian() * 2.0D; + } + + if (this.forceNewTarget || d2 < 100.0D || d2 > 22500.0D || this.isCollidedHorizontally || this.isCollidedVertically) + { + this.setNewTarget(); + } + + d0 /= (double)MathHelper.sqrt_double(d10 * d10 + d1 * d1); + f12 = 0.6F; + + if (d0 < (double)(-f12)) + { + d0 = (double)(-f12); + } + + if (d0 > (double)f12) + { + d0 = (double)f12; + } + + this.motionY += d0 * 0.10000000149011612D; + this.rotationYaw = MathHelper.wrapAngleTo180_float(this.rotationYaw); + double d4 = 180.0D - Math.atan2(d10, d1) * 180.0D / Math.PI; + double d6 = MathHelper.wrapAngleTo180_double(d4 - (double)this.rotationYaw); + + if (d6 > 50.0D) + { + d6 = 50.0D; + } + + if (d6 < -50.0D) + { + d6 = -50.0D; + } + + Vec3 vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.targetX - this.posX, this.targetY - this.posY, this.targetZ - this.posZ).normalize(); + Vec3 vec32 = this.worldObj.getWorldVec3Pool().getVecFromPool((double)MathHelper.sin(this.rotationYaw * (float)Math.PI / 180.0F), this.motionY, (double)(-MathHelper.cos(this.rotationYaw * (float)Math.PI / 180.0F))).normalize(); + float f5 = (float)(vec32.dotProduct(vec3) + 0.5D) / 1.5F; + + if (f5 < 0.0F) + { + f5 = 0.0F; + } + + this.randomYawVelocity *= 0.8F; + float f6 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ) * 1.0F + 1.0F; + double d9 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ) * 1.0D + 1.0D; + + if (d9 > 40.0D) + { + d9 = 40.0D; + } + + this.randomYawVelocity = (float)((double)this.randomYawVelocity + d6 * (0.699999988079071D / d9 / (double)f6)); + this.rotationYaw += this.randomYawVelocity * 0.1F; + float f7 = (float)(2.0D / (d9 + 1.0D)); + float f8 = 0.06F; + this.moveFlying(0.0F, -1.0F, f8 * (f5 * f7 + (1.0F - f7))); + + if (this.slowed) + { + this.moveEntity(this.motionX * 0.800000011920929D, this.motionY * 0.800000011920929D, this.motionZ * 0.800000011920929D); + } + else + { + this.moveEntity(this.motionX, this.motionY, this.motionZ); + } + + Vec3 vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.motionX, this.motionY, this.motionZ).normalize(); + float f9 = (float)(vec31.dotProduct(vec32) + 1.0D) / 2.0F; + f9 = 0.8F + 0.15F * f9; + this.motionX *= (double)f9; + this.motionZ *= (double)f9; + this.motionY *= 0.9100000262260437D; + } + + this.renderYawOffset = this.rotationYaw; + this.dragonPartHead.width = this.dragonPartHead.height = 3.0F; + this.dragonPartTail1.width = this.dragonPartTail1.height = 2.0F; + this.dragonPartTail2.width = this.dragonPartTail2.height = 2.0F; + this.dragonPartTail3.width = this.dragonPartTail3.height = 2.0F; + this.dragonPartBody.height = 3.0F; + this.dragonPartBody.width = 5.0F; + this.dragonPartWing1.height = 2.0F; + this.dragonPartWing1.width = 4.0F; + this.dragonPartWing2.height = 3.0F; + this.dragonPartWing2.width = 4.0F; + f1 = (float)(this.getMovementOffsets(5, 1.0F)[1] - this.getMovementOffsets(10, 1.0F)[1]) * 10.0F / 180.0F * (float)Math.PI; + f2 = MathHelper.cos(f1); + float f10 = -MathHelper.sin(f1); + float f3 = this.rotationYaw * (float)Math.PI / 180.0F; + float f11 = MathHelper.sin(f3); + float f4 = MathHelper.cos(f3); + this.dragonPartBody.onUpdate(); + this.dragonPartBody.setLocationAndAngles(this.posX + (double)(f11 * 0.5F), this.posY, this.posZ - (double)(f4 * 0.5F), 0.0F, 0.0F); + this.dragonPartWing1.onUpdate(); + this.dragonPartWing1.setLocationAndAngles(this.posX + (double)(f4 * 4.5F), this.posY + 2.0D, this.posZ + (double)(f11 * 4.5F), 0.0F, 0.0F); + this.dragonPartWing2.onUpdate(); + this.dragonPartWing2.setLocationAndAngles(this.posX - (double)(f4 * 4.5F), this.posY + 2.0D, this.posZ - (double)(f11 * 4.5F), 0.0F, 0.0F); + + if (!this.worldObj.isRemote && this.hurtTime == 0) + { + this.collideWithEntities(this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.dragonPartWing1.boundingBox.expand(4.0D, 2.0D, 4.0D).offset(0.0D, -2.0D, 0.0D))); + this.collideWithEntities(this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.dragonPartWing2.boundingBox.expand(4.0D, 2.0D, 4.0D).offset(0.0D, -2.0D, 0.0D))); + this.attackEntitiesInList(this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.dragonPartHead.boundingBox.expand(1.0D, 1.0D, 1.0D))); + } + + double[] adouble1 = this.getMovementOffsets(5, 1.0F); + double[] adouble = this.getMovementOffsets(0, 1.0F); + f12 = MathHelper.sin(this.rotationYaw * (float)Math.PI / 180.0F - this.randomYawVelocity * 0.01F); + float f13 = MathHelper.cos(this.rotationYaw * (float)Math.PI / 180.0F - this.randomYawVelocity * 0.01F); + this.dragonPartHead.onUpdate(); + this.dragonPartHead.setLocationAndAngles(this.posX + (double)(f12 * 5.5F * f2), this.posY + (adouble[1] - adouble1[1]) * 1.0D + (double)(f10 * 5.5F), this.posZ - (double)(f13 * 5.5F * f2), 0.0F, 0.0F); + + for (int j = 0; j < 3; ++j) + { + EntityDragonPart entitydragonpart = null; + + if (j == 0) + { + entitydragonpart = this.dragonPartTail1; + } + + if (j == 1) + { + entitydragonpart = this.dragonPartTail2; + } + + if (j == 2) + { + entitydragonpart = this.dragonPartTail3; + } + + double[] adouble2 = this.getMovementOffsets(12 + j * 2, 1.0F); + float f14 = this.rotationYaw * (float)Math.PI / 180.0F + this.simplifyAngle(adouble2[0] - adouble1[0]) * (float)Math.PI / 180.0F * 1.0F; + float f15 = MathHelper.sin(f14); + float f16 = MathHelper.cos(f14); + float f17 = 1.5F; + float f18 = (float)(j + 1) * 2.0F; + entitydragonpart.onUpdate(); + entitydragonpart.setLocationAndAngles(this.posX - (double)((f11 * f17 + f15 * f18) * f2), this.posY + (adouble2[1] - adouble1[1]) * 1.0D - (double)((f18 + f17) * f10) + 1.5D, this.posZ + (double)((f4 * f17 + f16 * f18) * f2), 0.0F, 0.0F); + } + + if (!this.worldObj.isRemote) + { + this.slowed = this.destroyBlocksInAABB(this.dragonPartHead.boundingBox) | this.destroyBlocksInAABB(this.dragonPartBody.boundingBox); + } + } + } + + private void updateDragonEnderCrystal() + { + if (this.healingEnderCrystal != null) + { + if (this.healingEnderCrystal.isDead) + { + if (!this.worldObj.isRemote) + { + this.attackEntityFromPart(this.dragonPartHead, DamageSource.setExplosionSource((Explosion)null), 10.0F); + } + + this.healingEnderCrystal = null; + } + else if (this.ticksExisted % 10 == 0 && this.getHealth() < this.getMaxHealth()) + { + this.setHealth(this.getHealth() + 1.0F); + } + } + + if (this.rand.nextInt(10) == 0) + { + float f = 32.0F; + List list = this.worldObj.getEntitiesWithinAABB(EntityEnderCrystal.class, this.boundingBox.expand((double)f, (double)f, (double)f)); + EntityEnderCrystal entityendercrystal = null; + double d0 = Double.MAX_VALUE; + Iterator iterator = list.iterator(); + + while (iterator.hasNext()) + { + EntityEnderCrystal entityendercrystal1 = (EntityEnderCrystal)iterator.next(); + double d1 = entityendercrystal1.getDistanceSqToEntity(this); + + if (d1 < d0) + { + d0 = d1; + entityendercrystal = entityendercrystal1; + } + } + + this.healingEnderCrystal = entityendercrystal; + } + } + + private void collideWithEntities(List par1List) + { + double d0 = (this.dragonPartBody.boundingBox.minX + this.dragonPartBody.boundingBox.maxX) / 2.0D; + double d1 = (this.dragonPartBody.boundingBox.minZ + this.dragonPartBody.boundingBox.maxZ) / 2.0D; + Iterator iterator = par1List.iterator(); + + while (iterator.hasNext()) + { + Entity entity = (Entity)iterator.next(); + + if (entity instanceof EntityLivingBase) + { + double d2 = entity.posX - d0; + double d3 = entity.posZ - d1; + double d4 = d2 * d2 + d3 * d3; + entity.addVelocity(d2 / d4 * 4.0D, 0.20000000298023224D, d3 / d4 * 4.0D); + } + } + } + + private void attackEntitiesInList(List par1List) + { + for (int i = 0; i < par1List.size(); ++i) + { + Entity entity = (Entity)par1List.get(i); + + if (entity instanceof EntityLivingBase) + { + entity.attackEntityFrom(DamageSource.causeMobDamage(this), 10.0F); + } + } + } + + private void setNewTarget() + { + this.forceNewTarget = false; + + if (this.rand.nextInt(2) == 0 && !this.worldObj.playerEntities.isEmpty()) + { + this.target = (Entity)this.worldObj.playerEntities.get(this.rand.nextInt(this.worldObj.playerEntities.size())); + } + else + { + boolean flag = false; + + do + { + this.targetX = 0.0D; + this.targetY = (double)(70.0F + this.rand.nextFloat() * 50.0F); + this.targetZ = 0.0D; + this.targetX += (double)(this.rand.nextFloat() * 120.0F - 60.0F); + this.targetZ += (double)(this.rand.nextFloat() * 120.0F - 60.0F); + double d0 = this.posX - this.targetX; + double d1 = this.posY - this.targetY; + double d2 = this.posZ - this.targetZ; + flag = d0 * d0 + d1 * d1 + d2 * d2 > 100.0D; + } + while (!flag); + + this.target = null; + } + } + + private float simplifyAngle(double par1) + { + return (float)MathHelper.wrapAngleTo180_double(par1); + } + + private boolean destroyBlocksInAABB(AxisAlignedBB par1AxisAlignedBB) + { + int i = MathHelper.floor_double(par1AxisAlignedBB.minX); + int j = MathHelper.floor_double(par1AxisAlignedBB.minY); + int k = MathHelper.floor_double(par1AxisAlignedBB.minZ); + int l = MathHelper.floor_double(par1AxisAlignedBB.maxX); + int i1 = MathHelper.floor_double(par1AxisAlignedBB.maxY); + int j1 = MathHelper.floor_double(par1AxisAlignedBB.maxZ); + boolean flag = false; + boolean flag1 = false; + + for (int k1 = i; k1 <= l; ++k1) + { + for (int l1 = j; l1 <= i1; ++l1) + { + for (int i2 = k; i2 <= j1; ++i2) + { + Block block = this.worldObj.getBlock(k1, l1, i2); + + if (!block.isAir(worldObj, k1, l1, i2)) + { + if (block.canEntityDestroy(worldObj, k1, l1, i2, this) && this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing")) + { + flag1 = this.worldObj.setBlockToAir(k1, l1, i2) || flag1; + } + else + { + flag = true; + } + } + } + } + } + + if (flag1) + { + double d1 = par1AxisAlignedBB.minX + (par1AxisAlignedBB.maxX - par1AxisAlignedBB.minX) * (double)this.rand.nextFloat(); + double d2 = par1AxisAlignedBB.minY + (par1AxisAlignedBB.maxY - par1AxisAlignedBB.minY) * (double)this.rand.nextFloat(); + double d0 = par1AxisAlignedBB.minZ + (par1AxisAlignedBB.maxZ - par1AxisAlignedBB.minZ) * (double)this.rand.nextFloat(); + this.worldObj.spawnParticle("largeexplode", d1, d2, d0, 0.0D, 0.0D, 0.0D); + } + + return flag; + } + + public boolean attackEntityFromPart(EntityDragonPart par1EntityDragonPart, DamageSource par2DamageSource, float par3) + { + if (par1EntityDragonPart != this.dragonPartHead) + { + par3 = par3 / 4.0F + 1.0F; + } + + float f1 = this.rotationYaw * (float)Math.PI / 180.0F; + float f2 = MathHelper.sin(f1); + float f3 = MathHelper.cos(f1); + this.targetX = this.posX + (double)(f2 * 5.0F) + (double)((this.rand.nextFloat() - 0.5F) * 2.0F); + this.targetY = this.posY + (double)(this.rand.nextFloat() * 3.0F) + 1.0D; + this.targetZ = this.posZ - (double)(f3 * 5.0F) + (double)((this.rand.nextFloat() - 0.5F) * 2.0F); + this.target = null; + + if (par2DamageSource.getEntity() instanceof EntityPlayer || par2DamageSource.isExplosion()) + { + this.func_82195_e(par2DamageSource, par3); + } + + return true; + } + + public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) + { + return false; + } + + protected boolean func_82195_e(DamageSource par1DamageSource, float par2) + { + return super.attackEntityFrom(par1DamageSource, par2); + } + + protected void onDeathUpdate() + { + ++this.deathTicks; + + if (this.deathTicks >= 180 && this.deathTicks <= 200) + { + float f = (this.rand.nextFloat() - 0.5F) * 8.0F; + float f1 = (this.rand.nextFloat() - 0.5F) * 4.0F; + float f2 = (this.rand.nextFloat() - 0.5F) * 8.0F; + this.worldObj.spawnParticle("hugeexplosion", this.posX + (double)f, this.posY + 2.0D + (double)f1, this.posZ + (double)f2, 0.0D, 0.0D, 0.0D); + } + + int i; + int j; + + if (!this.worldObj.isRemote) + { + if (this.deathTicks > 150 && this.deathTicks % 5 == 0) + { + i = 1000; + + while (i > 0) + { + j = EntityXPOrb.getXPSplit(i); + i -= j; + this.worldObj.spawnEntityInWorld(new EntityXPOrb(this.worldObj, this.posX, this.posY, this.posZ, j)); + } + } + + if (this.deathTicks == 1) + { + this.worldObj.playBroadcastSound(1018, (int)this.posX, (int)this.posY, (int)this.posZ, 0); + } + } + + this.moveEntity(0.0D, 0.10000000149011612D, 0.0D); + this.renderYawOffset = this.rotationYaw += 20.0F; + + if (this.deathTicks == 200 && !this.worldObj.isRemote) + { + i = 2000; + + while (i > 0) + { + j = EntityXPOrb.getXPSplit(i); + i -= j; + this.worldObj.spawnEntityInWorld(new EntityXPOrb(this.worldObj, this.posX, this.posY, this.posZ, j)); + } + + this.createEnderPortal(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posZ)); + this.setDead(); + } + } + + private void createEnderPortal(int par1, int par2) + { + byte b0 = 64; + BlockEndPortal.field_149948_a = true; + byte b1 = 4; + + for (int k = b0 - 1; k <= b0 + 32; ++k) + { + for (int l = par1 - b1; l <= par1 + b1; ++l) + { + for (int i1 = par2 - b1; i1 <= par2 + b1; ++i1) + { + double d0 = (double)(l - par1); + double d1 = (double)(i1 - par2); + double d2 = d0 * d0 + d1 * d1; + + if (d2 <= ((double)b1 - 0.5D) * ((double)b1 - 0.5D)) + { + if (k < b0) + { + if (d2 <= ((double)(b1 - 1) - 0.5D) * ((double)(b1 - 1) - 0.5D)) + { + this.worldObj.setBlock(l, k, i1, Blocks.bedrock); + } + } + else if (k > b0) + { + this.worldObj.setBlock(l, k, i1, Blocks.air); + } + else if (d2 > ((double)(b1 - 1) - 0.5D) * ((double)(b1 - 1) - 0.5D)) + { + this.worldObj.setBlock(l, k, i1, Blocks.bedrock); + } + else + { + this.worldObj.setBlock(l, k, i1, Blocks.end_portal); + } + } + } + } + } + + this.worldObj.setBlock(par1, b0 + 0, par2, Blocks.bedrock); + this.worldObj.setBlock(par1, b0 + 1, par2, Blocks.bedrock); + this.worldObj.setBlock(par1, b0 + 2, par2, Blocks.bedrock); + this.worldObj.setBlock(par1 - 1, b0 + 2, par2, Blocks.torch); + this.worldObj.setBlock(par1 + 1, b0 + 2, par2, Blocks.torch); + this.worldObj.setBlock(par1, b0 + 2, par2 - 1, Blocks.torch); + this.worldObj.setBlock(par1, b0 + 2, par2 + 1, Blocks.torch); + this.worldObj.setBlock(par1, b0 + 3, par2, Blocks.bedrock); + this.worldObj.setBlock(par1, b0 + 4, par2, Blocks.dragon_egg); + BlockEndPortal.field_149948_a = false; + } + + protected void despawnEntity() {} + + public Entity[] getParts() + { + return this.dragonPartArray; + } + + public boolean canBeCollidedWith() + { + return false; + } + + public World func_82194_d() + { + return this.worldObj; + } + + protected String getLivingSound() + { + return "mob.enderdragon.growl"; + } + + protected String getHurtSound() + { + return "mob.enderdragon.hit"; + } + + protected float getSoundVolume() + { + return 5.0F; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/boss/EntityDragonPart.java b/src/main/java/net/minecraft/entity/boss/EntityDragonPart.java new file mode 100644 index 0000000..9e7ccbf --- /dev/null +++ b/src/main/java/net/minecraft/entity/boss/EntityDragonPart.java @@ -0,0 +1,42 @@ +package net.minecraft.entity.boss; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.IEntityMultiPart; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.DamageSource; + +public class EntityDragonPart extends Entity +{ + public final IEntityMultiPart entityDragonObj; + public final String field_146032_b; + private static final String __OBFID = "CL_00001657"; + + public EntityDragonPart(IEntityMultiPart par1IEntityMultiPart, String par2Str, float par3, float par4) + { + super(par1IEntityMultiPart.func_82194_d()); + this.setSize(par3, par4); + this.entityDragonObj = par1IEntityMultiPart; + this.field_146032_b = par2Str; + } + + protected void entityInit() {} + + protected void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {} + + protected void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) {} + + public boolean canBeCollidedWith() + { + return true; + } + + public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) + { + return this.isEntityInvulnerable() ? false : this.entityDragonObj.attackEntityFromPart(this, par1DamageSource, par2); + } + + public boolean isEntityEqual(Entity par1Entity) + { + return this == par1Entity || this.entityDragonObj == par1Entity; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/boss/EntityWither.java b/src/main/java/net/minecraft/entity/boss/EntityWither.java new file mode 100644 index 0000000..70e11c0 --- /dev/null +++ b/src/main/java/net/minecraft/entity/boss/EntityWither.java @@ -0,0 +1,608 @@ +package net.minecraft.entity.boss; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Iterator; +import java.util.List; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.command.IEntitySelector; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.EnumCreatureAttribute; +import net.minecraft.entity.IRangedAttackMob; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.EntityAIArrowAttack; +import net.minecraft.entity.ai.EntityAIHurtByTarget; +import net.minecraft.entity.ai.EntityAILookIdle; +import net.minecraft.entity.ai.EntityAINearestAttackableTarget; +import net.minecraft.entity.ai.EntityAISwimming; +import net.minecraft.entity.ai.EntityAIWander; +import net.minecraft.entity.ai.EntityAIWatchClosest; +import net.minecraft.entity.monster.EntityMob; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.entity.projectile.EntityWitherSkull; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.PotionEffect; +import net.minecraft.stats.AchievementList; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.world.EnumDifficulty; +import net.minecraft.world.World; + +public class EntityWither extends EntityMob implements IBossDisplayData, IRangedAttackMob +{ + private float[] field_82220_d = new float[2]; + private float[] field_82221_e = new float[2]; + private float[] field_82217_f = new float[2]; + private float[] field_82218_g = new float[2]; + private int[] field_82223_h = new int[2]; + private int[] field_82224_i = new int[2]; + private int field_82222_j; + private static final IEntitySelector attackEntitySelector = new IEntitySelector() + { + private static final String __OBFID = "CL_00001662"; + public boolean isEntityApplicable(Entity par1Entity) + { + return par1Entity instanceof EntityLivingBase && ((EntityLivingBase)par1Entity).getCreatureAttribute() != EnumCreatureAttribute.UNDEAD; + } + }; + private static final String __OBFID = "CL_00001661"; + + public EntityWither(World par1World) + { + super(par1World); + this.setHealth(this.getMaxHealth()); + this.setSize(0.9F, 4.0F); + this.isImmuneToFire = true; + this.getNavigator().setCanSwim(true); + this.tasks.addTask(0, new EntityAISwimming(this)); + this.tasks.addTask(2, new EntityAIArrowAttack(this, 1.0D, 40, 20.0F)); + this.tasks.addTask(5, new EntityAIWander(this, 1.0D)); + this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); + this.tasks.addTask(7, new EntityAILookIdle(this)); + this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false)); + this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityLiving.class, 0, false, false, attackEntitySelector)); + this.experienceValue = 50; + } + + protected void entityInit() + { + super.entityInit(); + this.dataWatcher.addObject(17, new Integer(0)); + this.dataWatcher.addObject(18, new Integer(0)); + this.dataWatcher.addObject(19, new Integer(0)); + this.dataWatcher.addObject(20, new Integer(0)); + } + + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeEntityToNBT(par1NBTTagCompound); + par1NBTTagCompound.setInteger("Invul", this.func_82212_n()); + } + + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + super.readEntityFromNBT(par1NBTTagCompound); + this.func_82215_s(par1NBTTagCompound.getInteger("Invul")); + } + + @SideOnly(Side.CLIENT) + public float getShadowSize() + { + return this.height / 8.0F; + } + + protected String getLivingSound() + { + return "mob.wither.idle"; + } + + protected String getHurtSound() + { + return "mob.wither.hurt"; + } + + protected String getDeathSound() + { + return "mob.wither.death"; + } + + public void onLivingUpdate() + { + this.motionY *= 0.6000000238418579D; + double d1; + double d3; + double d5; + + if (!this.worldObj.isRemote && this.getWatchedTargetId(0) > 0) + { + Entity entity = this.worldObj.getEntityByID(this.getWatchedTargetId(0)); + + if (entity != null) + { + if (this.posY < entity.posY || !this.isArmored() && this.posY < entity.posY + 5.0D) + { + if (this.motionY < 0.0D) + { + this.motionY = 0.0D; + } + + this.motionY += (0.5D - this.motionY) * 0.6000000238418579D; + } + + double d0 = entity.posX - this.posX; + d1 = entity.posZ - this.posZ; + d3 = d0 * d0 + d1 * d1; + + if (d3 > 9.0D) + { + d5 = (double)MathHelper.sqrt_double(d3); + this.motionX += (d0 / d5 * 0.5D - this.motionX) * 0.6000000238418579D; + this.motionZ += (d1 / d5 * 0.5D - this.motionZ) * 0.6000000238418579D; + } + } + } + + if (this.motionX * this.motionX + this.motionZ * this.motionZ > 0.05000000074505806D) + { + this.rotationYaw = (float)Math.atan2(this.motionZ, this.motionX) * (180F / (float)Math.PI) - 90.0F; + } + + super.onLivingUpdate(); + int i; + + for (i = 0; i < 2; ++i) + { + this.field_82218_g[i] = this.field_82221_e[i]; + this.field_82217_f[i] = this.field_82220_d[i]; + } + + int j; + + for (i = 0; i < 2; ++i) + { + j = this.getWatchedTargetId(i + 1); + Entity entity1 = null; + + if (j > 0) + { + entity1 = this.worldObj.getEntityByID(j); + } + + if (entity1 != null) + { + d1 = this.func_82214_u(i + 1); + d3 = this.func_82208_v(i + 1); + d5 = this.func_82213_w(i + 1); + double d6 = entity1.posX - d1; + double d7 = entity1.posY + (double)entity1.getEyeHeight() - d3; + double d8 = entity1.posZ - d5; + double d9 = (double)MathHelper.sqrt_double(d6 * d6 + d8 * d8); + float f = (float)(Math.atan2(d8, d6) * 180.0D / Math.PI) - 90.0F; + float f1 = (float)(-(Math.atan2(d7, d9) * 180.0D / Math.PI)); + this.field_82220_d[i] = this.func_82204_b(this.field_82220_d[i], f1, 40.0F); + this.field_82221_e[i] = this.func_82204_b(this.field_82221_e[i], f, 10.0F); + } + else + { + this.field_82221_e[i] = this.func_82204_b(this.field_82221_e[i], this.renderYawOffset, 10.0F); + } + } + + boolean flag = this.isArmored(); + + for (j = 0; j < 3; ++j) + { + double d10 = this.func_82214_u(j); + double d2 = this.func_82208_v(j); + double d4 = this.func_82213_w(j); + this.worldObj.spawnParticle("smoke", d10 + this.rand.nextGaussian() * 0.30000001192092896D, d2 + this.rand.nextGaussian() * 0.30000001192092896D, d4 + this.rand.nextGaussian() * 0.30000001192092896D, 0.0D, 0.0D, 0.0D); + + if (flag && this.worldObj.rand.nextInt(4) == 0) + { + this.worldObj.spawnParticle("mobSpell", d10 + this.rand.nextGaussian() * 0.30000001192092896D, d2 + this.rand.nextGaussian() * 0.30000001192092896D, d4 + this.rand.nextGaussian() * 0.30000001192092896D, 0.699999988079071D, 0.699999988079071D, 0.5D); + } + } + + if (this.func_82212_n() > 0) + { + for (j = 0; j < 3; ++j) + { + this.worldObj.spawnParticle("mobSpell", this.posX + this.rand.nextGaussian() * 1.0D, this.posY + (double)(this.rand.nextFloat() * 3.3F), this.posZ + this.rand.nextGaussian() * 1.0D, 0.699999988079071D, 0.699999988079071D, 0.8999999761581421D); + } + } + } + + protected void updateAITasks() + { + int i; + + if (this.func_82212_n() > 0) + { + i = this.func_82212_n() - 1; + + if (i <= 0) + { + this.worldObj.newExplosion(this, this.posX, this.posY + (double)this.getEyeHeight(), this.posZ, 7.0F, false, this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing")); + this.worldObj.playBroadcastSound(1013, (int)this.posX, (int)this.posY, (int)this.posZ, 0); + } + + this.func_82215_s(i); + + if (this.ticksExisted % 10 == 0) + { + this.heal(10.0F); + } + } + else + { + super.updateAITasks(); + int i1; + + for (i = 1; i < 3; ++i) + { + if (this.ticksExisted >= this.field_82223_h[i - 1]) + { + this.field_82223_h[i - 1] = this.ticksExisted + 10 + this.rand.nextInt(10); + + if (this.worldObj.difficultySetting == EnumDifficulty.NORMAL || this.worldObj.difficultySetting == EnumDifficulty.HARD) + { + int k2 = i - 1; + int l2 = this.field_82224_i[i - 1]; + this.field_82224_i[k2] = this.field_82224_i[i - 1] + 1; + + if (l2 > 15) + { + float f = 10.0F; + float f1 = 5.0F; + double d0 = MathHelper.getRandomDoubleInRange(this.rand, this.posX - (double)f, this.posX + (double)f); + double d1 = MathHelper.getRandomDoubleInRange(this.rand, this.posY - (double)f1, this.posY + (double)f1); + double d2 = MathHelper.getRandomDoubleInRange(this.rand, this.posZ - (double)f, this.posZ + (double)f); + this.func_82209_a(i + 1, d0, d1, d2, true); + this.field_82224_i[i - 1] = 0; + } + } + + i1 = this.getWatchedTargetId(i); + + if (i1 > 0) + { + Entity entity = this.worldObj.getEntityByID(i1); + + if (entity != null && entity.isEntityAlive() && this.getDistanceSqToEntity(entity) <= 900.0D && this.canEntityBeSeen(entity)) + { + this.func_82216_a(i + 1, (EntityLivingBase)entity); + this.field_82223_h[i - 1] = this.ticksExisted + 40 + this.rand.nextInt(20); + this.field_82224_i[i - 1] = 0; + } + else + { + this.func_82211_c(i, 0); + } + } + else + { + List list = this.worldObj.selectEntitiesWithinAABB(EntityLivingBase.class, this.boundingBox.expand(20.0D, 8.0D, 20.0D), attackEntitySelector); + + for (int k1 = 0; k1 < 10 && !list.isEmpty(); ++k1) + { + EntityLivingBase entitylivingbase = (EntityLivingBase)list.get(this.rand.nextInt(list.size())); + + if (entitylivingbase != this && entitylivingbase.isEntityAlive() && this.canEntityBeSeen(entitylivingbase)) + { + if (entitylivingbase instanceof EntityPlayer) + { + if (!((EntityPlayer)entitylivingbase).capabilities.disableDamage) + { + this.func_82211_c(i, entitylivingbase.getEntityId()); + } + } + else + { + this.func_82211_c(i, entitylivingbase.getEntityId()); + } + + break; + } + + list.remove(entitylivingbase); + } + } + } + } + + if (this.getAttackTarget() != null) + { + this.func_82211_c(0, this.getAttackTarget().getEntityId()); + } + else + { + this.func_82211_c(0, 0); + } + + if (this.field_82222_j > 0) + { + --this.field_82222_j; + + if (this.field_82222_j == 0 && this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing")) + { + i = MathHelper.floor_double(this.posY); + i1 = MathHelper.floor_double(this.posX); + int j1 = MathHelper.floor_double(this.posZ); + boolean flag = false; + + for (int l1 = -1; l1 <= 1; ++l1) + { + for (int i2 = -1; i2 <= 1; ++i2) + { + for (int j = 0; j <= 3; ++j) + { + int j2 = i1 + l1; + int k = i + j; + int l = j1 + i2; + Block block = this.worldObj.getBlock(j2, k, l); + + if (!block.isAir(worldObj, j2, k, l) && block.canEntityDestroy(worldObj, j2, k, l, this)) + { + flag = this.worldObj.func_147480_a(j2, k, l, true) || flag; + } + } + } + } + + if (flag) + { + this.worldObj.playAuxSFXAtEntity((EntityPlayer)null, 1012, (int)this.posX, (int)this.posY, (int)this.posZ, 0); + } + } + } + + if (this.ticksExisted % 20 == 0) + { + this.heal(1.0F); + } + } + } + + public void func_82206_m() + { + this.func_82215_s(220); + this.setHealth(this.getMaxHealth() / 3.0F); + } + + public void setInWeb() {} + + public int getTotalArmorValue() + { + return 4; + } + + private double func_82214_u(int par1) + { + if (par1 <= 0) + { + return this.posX; + } + else + { + float f = (this.renderYawOffset + (float)(180 * (par1 - 1))) / 180.0F * (float)Math.PI; + float f1 = MathHelper.cos(f); + return this.posX + (double)f1 * 1.3D; + } + } + + private double func_82208_v(int par1) + { + return par1 <= 0 ? this.posY + 3.0D : this.posY + 2.2D; + } + + private double func_82213_w(int par1) + { + if (par1 <= 0) + { + return this.posZ; + } + else + { + float f = (this.renderYawOffset + (float)(180 * (par1 - 1))) / 180.0F * (float)Math.PI; + float f1 = MathHelper.sin(f); + return this.posZ + (double)f1 * 1.3D; + } + } + + private float func_82204_b(float par1, float par2, float par3) + { + float f3 = MathHelper.wrapAngleTo180_float(par2 - par1); + + if (f3 > par3) + { + f3 = par3; + } + + if (f3 < -par3) + { + f3 = -par3; + } + + return par1 + f3; + } + + private void func_82216_a(int par1, EntityLivingBase par2EntityLivingBase) + { + this.func_82209_a(par1, par2EntityLivingBase.posX, par2EntityLivingBase.posY + (double)par2EntityLivingBase.getEyeHeight() * 0.5D, par2EntityLivingBase.posZ, par1 == 0 && this.rand.nextFloat() < 0.001F); + } + + private void func_82209_a(int par1, double par2, double par4, double par6, boolean par8) + { + this.worldObj.playAuxSFXAtEntity((EntityPlayer)null, 1014, (int)this.posX, (int)this.posY, (int)this.posZ, 0); + double d3 = this.func_82214_u(par1); + double d4 = this.func_82208_v(par1); + double d5 = this.func_82213_w(par1); + double d6 = par2 - d3; + double d7 = par4 - d4; + double d8 = par6 - d5; + EntityWitherSkull entitywitherskull = new EntityWitherSkull(this.worldObj, this, d6, d7, d8); + + if (par8) + { + entitywitherskull.setInvulnerable(true); + } + + entitywitherskull.posY = d4; + entitywitherskull.posX = d3; + entitywitherskull.posZ = d5; + this.worldObj.spawnEntityInWorld(entitywitherskull); + } + + public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2) + { + this.func_82216_a(0, par1EntityLivingBase); + } + + public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) + { + if (this.isEntityInvulnerable()) + { + return false; + } + else if (par1DamageSource == DamageSource.drown) + { + return false; + } + else if (this.func_82212_n() > 0) + { + return false; + } + else + { + Entity entity; + + if (this.isArmored()) + { + entity = par1DamageSource.getSourceOfDamage(); + + if (entity instanceof EntityArrow) + { + return false; + } + } + + entity = par1DamageSource.getEntity(); + + if (entity != null && !(entity instanceof EntityPlayer) && entity instanceof EntityLivingBase && ((EntityLivingBase)entity).getCreatureAttribute() == this.getCreatureAttribute()) + { + return false; + } + else + { + if (this.field_82222_j <= 0) + { + this.field_82222_j = 20; + } + + for (int i = 0; i < this.field_82224_i.length; ++i) + { + this.field_82224_i[i] += 3; + } + + return super.attackEntityFrom(par1DamageSource, par2); + } + } + } + + protected void dropFewItems(boolean par1, int par2) + { + this.dropItem(Items.nether_star, 1); + + if (!this.worldObj.isRemote) + { + Iterator iterator = this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, this.boundingBox.expand(50.0D, 100.0D, 50.0D)).iterator(); + + while (iterator.hasNext()) + { + EntityPlayer entityplayer = (EntityPlayer)iterator.next(); + entityplayer.triggerAchievement(AchievementList.field_150964_J); + } + } + } + + protected void despawnEntity() + { + this.entityAge = 0; + } + + @SideOnly(Side.CLIENT) + public int getBrightnessForRender(float par1) + { + return 15728880; + } + + protected void fall(float par1) {} + + public void addPotionEffect(PotionEffect par1PotionEffect) {} + + protected boolean isAIEnabled() + { + return true; + } + + protected void applyEntityAttributes() + { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(300.0D); + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.6000000238418579D); + this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(40.0D); + } + + @SideOnly(Side.CLIENT) + public float func_82207_a(int par1) + { + return this.field_82221_e[par1]; + } + + @SideOnly(Side.CLIENT) + public float func_82210_r(int par1) + { + return this.field_82220_d[par1]; + } + + public int func_82212_n() + { + return this.dataWatcher.getWatchableObjectInt(20); + } + + public void func_82215_s(int par1) + { + this.dataWatcher.updateObject(20, Integer.valueOf(par1)); + } + + public int getWatchedTargetId(int par1) + { + return this.dataWatcher.getWatchableObjectInt(17 + par1); + } + + public void func_82211_c(int par1, int par2) + { + this.dataWatcher.updateObject(17 + par1, Integer.valueOf(par2)); + } + + public boolean isArmored() + { + return this.getHealth() <= this.getMaxHealth() / 2.0F; + } + + public EnumCreatureAttribute getCreatureAttribute() + { + return EnumCreatureAttribute.UNDEAD; + } + + public void mountEntity(Entity par1Entity) + { + this.ridingEntity = null; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/boss/IBossDisplayData.java b/src/main/java/net/minecraft/entity/boss/IBossDisplayData.java new file mode 100644 index 0000000..b79987f --- /dev/null +++ b/src/main/java/net/minecraft/entity/boss/IBossDisplayData.java @@ -0,0 +1,14 @@ +package net.minecraft.entity.boss; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.util.IChatComponent; + +public interface IBossDisplayData +{ + float getMaxHealth(); + + float getHealth(); + + IChatComponent func_145748_c_(); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/effect/EntityLightningBolt.java b/src/main/java/net/minecraft/entity/effect/EntityLightningBolt.java new file mode 100644 index 0000000..5564004 --- /dev/null +++ b/src/main/java/net/minecraft/entity/effect/EntityLightningBolt.java @@ -0,0 +1,117 @@ +package net.minecraft.entity.effect; + +import java.util.List; +import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; +import net.minecraft.init.Blocks; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.MathHelper; +import net.minecraft.world.EnumDifficulty; +import net.minecraft.world.World; + +public class EntityLightningBolt extends EntityWeatherEffect +{ + private int lightningState; + public long boltVertex; + private int boltLivingTime; + private static final String __OBFID = "CL_00001666"; + + public EntityLightningBolt(World par1World, double par2, double par4, double par6) + { + super(par1World); + this.setLocationAndAngles(par2, par4, par6, 0.0F, 0.0F); + this.lightningState = 2; + this.boltVertex = this.rand.nextLong(); + this.boltLivingTime = this.rand.nextInt(3) + 1; + + if (!par1World.isRemote && par1World.getGameRules().getGameRuleBooleanValue("doFireTick") && (par1World.difficultySetting == EnumDifficulty.NORMAL || par1World.difficultySetting == EnumDifficulty.HARD) && par1World.doChunksNearChunkExist(MathHelper.floor_double(par2), MathHelper.floor_double(par4), MathHelper.floor_double(par6), 10)) + { + int i = MathHelper.floor_double(par2); + int j = MathHelper.floor_double(par4); + int k = MathHelper.floor_double(par6); + + if (par1World.getBlock(i, j, k).getMaterial() == Material.air && Blocks.fire.canPlaceBlockAt(par1World, i, j, k)) + { + par1World.setBlock(i, j, k, Blocks.fire); + } + + for (i = 0; i < 4; ++i) + { + j = MathHelper.floor_double(par2) + this.rand.nextInt(3) - 1; + k = MathHelper.floor_double(par4) + this.rand.nextInt(3) - 1; + int l = MathHelper.floor_double(par6) + this.rand.nextInt(3) - 1; + + if (par1World.getBlock(j, k, l).getMaterial() == Material.air && Blocks.fire.canPlaceBlockAt(par1World, j, k, l)) + { + par1World.setBlock(j, k, l, Blocks.fire); + } + } + } + } + + public void onUpdate() + { + super.onUpdate(); + + if (this.lightningState == 2) + { + this.worldObj.playSoundEffect(this.posX, this.posY, this.posZ, "ambient.weather.thunder", 10000.0F, 0.8F + this.rand.nextFloat() * 0.2F); + this.worldObj.playSoundEffect(this.posX, this.posY, this.posZ, "random.explode", 2.0F, 0.5F + this.rand.nextFloat() * 0.2F); + } + + --this.lightningState; + + if (this.lightningState < 0) + { + if (this.boltLivingTime == 0) + { + this.setDead(); + } + else if (this.lightningState < -this.rand.nextInt(10)) + { + --this.boltLivingTime; + this.lightningState = 1; + this.boltVertex = this.rand.nextLong(); + + if (!this.worldObj.isRemote && this.worldObj.getGameRules().getGameRuleBooleanValue("doFireTick") && this.worldObj.doChunksNearChunkExist(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ), 10)) + { + int i = MathHelper.floor_double(this.posX); + int j = MathHelper.floor_double(this.posY); + int k = MathHelper.floor_double(this.posZ); + + if (this.worldObj.getBlock(i, j, k).getMaterial() == Material.air && Blocks.fire.canPlaceBlockAt(this.worldObj, i, j, k)) + { + this.worldObj.setBlock(i, j, k, Blocks.fire); + } + } + } + } + + if (this.lightningState >= 0) + { + if (this.worldObj.isRemote) + { + this.worldObj.lastLightningBolt = 2; + } + else + { + double d0 = 3.0D; + List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, AxisAlignedBB.getAABBPool().getAABB(this.posX - d0, this.posY - d0, this.posZ - d0, this.posX + d0, this.posY + 6.0D + d0, this.posZ + d0)); + + for (int l = 0; l < list.size(); ++l) + { + Entity entity = (Entity)list.get(l); + if (!net.minecraftforge.event.ForgeEventFactory.onEntityStruckByLightning(entity, this)) + entity.onStruckByLightning(this); + } + } + } + } + + protected void entityInit() {} + + protected void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {} + + protected void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) {} +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/effect/EntityWeatherEffect.java b/src/main/java/net/minecraft/entity/effect/EntityWeatherEffect.java new file mode 100644 index 0000000..1863b01 --- /dev/null +++ b/src/main/java/net/minecraft/entity/effect/EntityWeatherEffect.java @@ -0,0 +1,14 @@ +package net.minecraft.entity.effect; + +import net.minecraft.entity.Entity; +import net.minecraft.world.World; + +public abstract class EntityWeatherEffect extends Entity +{ + private static final String __OBFID = "CL_00001665"; + + public EntityWeatherEffect(World par1World) + { + super(par1World); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/item/EntityBoat.java b/src/main/java/net/minecraft/entity/item/EntityBoat.java new file mode 100644 index 0000000..2c9b046 --- /dev/null +++ b/src/main/java/net/minecraft/entity/item/EntityBoat.java @@ -0,0 +1,553 @@ +package net.minecraft.entity.item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +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.Items; +import net.minecraft.item.Item; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class EntityBoat extends Entity +{ + private boolean isBoatEmpty; + private double speedMultiplier; + private int boatPosRotationIncrements; + private double boatX; + private double boatY; + private double boatZ; + private double boatYaw; + private double boatPitch; + @SideOnly(Side.CLIENT) + private double velocityX; + @SideOnly(Side.CLIENT) + private double velocityY; + @SideOnly(Side.CLIENT) + private double velocityZ; + private static final String __OBFID = "CL_00001667"; + + public EntityBoat(World par1World) + { + super(par1World); + this.isBoatEmpty = true; + this.speedMultiplier = 0.07D; + this.preventEntitySpawning = true; + this.setSize(1.5F, 0.6F); + this.yOffset = this.height / 2.0F; + } + + protected boolean canTriggerWalking() + { + return false; + } + + protected void entityInit() + { + this.dataWatcher.addObject(17, new Integer(0)); + this.dataWatcher.addObject(18, new Integer(1)); + this.dataWatcher.addObject(19, new Float(0.0F)); + } + + public AxisAlignedBB getCollisionBox(Entity par1Entity) + { + return par1Entity.boundingBox; + } + + public AxisAlignedBB getBoundingBox() + { + return this.boundingBox; + } + + public boolean canBePushed() + { + return true; + } + + public EntityBoat(World par1World, double par2, double par4, double par6) + { + this(par1World); + this.setPosition(par2, par4 + (double)this.yOffset, par6); + this.motionX = 0.0D; + this.motionY = 0.0D; + this.motionZ = 0.0D; + this.prevPosX = par2; + this.prevPosY = par4; + this.prevPosZ = par6; + } + + public double getMountedYOffset() + { + return (double)this.height * 0.0D - 0.30000001192092896D; + } + + public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) + { + if (this.isEntityInvulnerable()) + { + return false; + } + else if (!this.worldObj.isRemote && !this.isDead) + { + this.setForwardDirection(-this.getForwardDirection()); + this.setTimeSinceHit(10); + this.setDamageTaken(this.getDamageTaken() + par2 * 10.0F); + this.setBeenAttacked(); + boolean flag = par1DamageSource.getEntity() instanceof EntityPlayer && ((EntityPlayer)par1DamageSource.getEntity()).capabilities.isCreativeMode; + + if (flag || this.getDamageTaken() > 40.0F) + { + if (this.riddenByEntity != null) + { + this.riddenByEntity.mountEntity(this); + } + + if (!flag) + { + this.func_145778_a(Items.boat, 1, 0.0F); + } + + this.setDead(); + } + + return true; + } + else + { + return true; + } + } + + @SideOnly(Side.CLIENT) + public void performHurtAnimation() + { + this.setForwardDirection(-this.getForwardDirection()); + this.setTimeSinceHit(10); + this.setDamageTaken(this.getDamageTaken() * 11.0F); + } + + public boolean canBeCollidedWith() + { + return !this.isDead; + } + + @SideOnly(Side.CLIENT) + public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9) + { + if (this.isBoatEmpty) + { + this.boatPosRotationIncrements = par9 + 5; + } + else + { + double d3 = par1 - this.posX; + double d4 = par3 - this.posY; + double d5 = par5 - this.posZ; + double d6 = d3 * d3 + d4 * d4 + d5 * d5; + + if (d6 <= 1.0D) + { + return; + } + + this.boatPosRotationIncrements = 3; + } + + this.boatX = par1; + this.boatY = par3; + this.boatZ = par5; + this.boatYaw = (double)par7; + this.boatPitch = (double)par8; + this.motionX = this.velocityX; + this.motionY = this.velocityY; + this.motionZ = this.velocityZ; + } + + @SideOnly(Side.CLIENT) + public void setVelocity(double par1, double par3, double par5) + { + this.velocityX = this.motionX = par1; + this.velocityY = this.motionY = par3; + this.velocityZ = this.motionZ = par5; + } + + public void onUpdate() + { + super.onUpdate(); + + if (this.getTimeSinceHit() > 0) + { + this.setTimeSinceHit(this.getTimeSinceHit() - 1); + } + + if (this.getDamageTaken() > 0.0F) + { + this.setDamageTaken(this.getDamageTaken() - 1.0F); + } + + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + byte b0 = 5; + double d0 = 0.0D; + + for (int i = 0; i < b0; ++i) + { + double d1 = this.boundingBox.minY + (this.boundingBox.maxY - this.boundingBox.minY) * (double)(i + 0) / (double)b0 - 0.125D; + double d3 = this.boundingBox.minY + (this.boundingBox.maxY - this.boundingBox.minY) * (double)(i + 1) / (double)b0 - 0.125D; + AxisAlignedBB axisalignedbb = AxisAlignedBB.getAABBPool().getAABB(this.boundingBox.minX, d1, this.boundingBox.minZ, this.boundingBox.maxX, d3, this.boundingBox.maxZ); + + if (this.worldObj.isAABBInMaterial(axisalignedbb, Material.water)) + { + d0 += 1.0D / (double)b0; + } + } + + double d10 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ); + double d2; + double d4; + int j; + + if (d10 > 0.26249999999999996D) + { + d2 = Math.cos((double)this.rotationYaw * Math.PI / 180.0D); + d4 = Math.sin((double)this.rotationYaw * Math.PI / 180.0D); + + for (j = 0; (double)j < 1.0D + d10 * 60.0D; ++j) + { + double d5 = (double)(this.rand.nextFloat() * 2.0F - 1.0F); + double d6 = (double)(this.rand.nextInt(2) * 2 - 1) * 0.7D; + double d8; + double d9; + + if (this.rand.nextBoolean()) + { + d8 = this.posX - d2 * d5 * 0.8D + d4 * d6; + d9 = this.posZ - d4 * d5 * 0.8D - d2 * d6; + this.worldObj.spawnParticle("splash", d8, this.posY - 0.125D, d9, this.motionX, this.motionY, this.motionZ); + } + else + { + d8 = this.posX + d2 + d4 * d5 * 0.7D; + d9 = this.posZ + d4 - d2 * d5 * 0.7D; + this.worldObj.spawnParticle("splash", d8, this.posY - 0.125D, d9, this.motionX, this.motionY, this.motionZ); + } + } + } + + double d11; + double d12; + + if (this.worldObj.isRemote && this.isBoatEmpty) + { + if (this.boatPosRotationIncrements > 0) + { + d2 = this.posX + (this.boatX - this.posX) / (double)this.boatPosRotationIncrements; + d4 = this.posY + (this.boatY - this.posY) / (double)this.boatPosRotationIncrements; + d11 = this.posZ + (this.boatZ - this.posZ) / (double)this.boatPosRotationIncrements; + d12 = MathHelper.wrapAngleTo180_double(this.boatYaw - (double)this.rotationYaw); + this.rotationYaw = (float)((double)this.rotationYaw + d12 / (double)this.boatPosRotationIncrements); + this.rotationPitch = (float)((double)this.rotationPitch + (this.boatPitch - (double)this.rotationPitch) / (double)this.boatPosRotationIncrements); + --this.boatPosRotationIncrements; + this.setPosition(d2, d4, d11); + this.setRotation(this.rotationYaw, this.rotationPitch); + } + else + { + d2 = this.posX + this.motionX; + d4 = this.posY + this.motionY; + d11 = this.posZ + this.motionZ; + this.setPosition(d2, d4, d11); + + if (this.onGround) + { + this.motionX *= 0.5D; + this.motionY *= 0.5D; + this.motionZ *= 0.5D; + } + + this.motionX *= 0.9900000095367432D; + this.motionY *= 0.949999988079071D; + this.motionZ *= 0.9900000095367432D; + } + } + else + { + if (d0 < 1.0D) + { + d2 = d0 * 2.0D - 1.0D; + this.motionY += 0.03999999910593033D * d2; + } + else + { + if (this.motionY < 0.0D) + { + this.motionY /= 2.0D; + } + + this.motionY += 0.007000000216066837D; + } + + if (this.riddenByEntity != null && this.riddenByEntity instanceof EntityLivingBase) + { + EntityLivingBase entitylivingbase = (EntityLivingBase)this.riddenByEntity; + float f = this.riddenByEntity.rotationYaw + -entitylivingbase.moveStrafing * 90.0F; + this.motionX += -Math.sin((double)(f * (float)Math.PI / 180.0F)) * this.speedMultiplier * (double)entitylivingbase.moveForward * 0.05000000074505806D; + this.motionZ += Math.cos((double)(f * (float)Math.PI / 180.0F)) * this.speedMultiplier * (double)entitylivingbase.moveForward * 0.05000000074505806D; + } + + d2 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ); + + if (d2 > 0.35D) + { + d4 = 0.35D / d2; + this.motionX *= d4; + this.motionZ *= d4; + d2 = 0.35D; + } + + if (d2 > d10 && this.speedMultiplier < 0.35D) + { + this.speedMultiplier += (0.35D - this.speedMultiplier) / 35.0D; + + if (this.speedMultiplier > 0.35D) + { + this.speedMultiplier = 0.35D; + } + } + else + { + this.speedMultiplier -= (this.speedMultiplier - 0.07D) / 35.0D; + + if (this.speedMultiplier < 0.07D) + { + this.speedMultiplier = 0.07D; + } + } + + int l; + + for (l = 0; l < 4; ++l) + { + int i1 = MathHelper.floor_double(this.posX + ((double)(l % 2) - 0.5D) * 0.8D); + j = MathHelper.floor_double(this.posZ + ((double)(l / 2) - 0.5D) * 0.8D); + + for (int j1 = 0; j1 < 2; ++j1) + { + int k = MathHelper.floor_double(this.posY) + j1; + Block block = this.worldObj.getBlock(i1, k, j); + + if (block == Blocks.snow_layer) + { + this.worldObj.setBlockToAir(i1, k, j); + this.isCollidedHorizontally = false; + } + else if (block == Blocks.waterlily) + { + this.worldObj.func_147480_a(i1, k, j, true); + this.isCollidedHorizontally = false; + } + } + } + + if (this.onGround) + { + this.motionX *= 0.5D; + this.motionY *= 0.5D; + this.motionZ *= 0.5D; + } + + this.moveEntity(this.motionX, this.motionY, this.motionZ); + + if (this.isCollidedHorizontally && d10 > 0.2D) + { + if (!this.worldObj.isRemote && !this.isDead) + { + this.setDead(); + + for (l = 0; l < 3; ++l) + { + this.func_145778_a(Item.getItemFromBlock(Blocks.planks), 1, 0.0F); + } + + for (l = 0; l < 2; ++l) + { + this.func_145778_a(Items.stick, 1, 0.0F); + } + } + } + else + { + this.motionX *= 0.9900000095367432D; + this.motionY *= 0.949999988079071D; + this.motionZ *= 0.9900000095367432D; + } + + this.rotationPitch = 0.0F; + d4 = (double)this.rotationYaw; + d11 = this.prevPosX - this.posX; + d12 = this.prevPosZ - this.posZ; + + if (d11 * d11 + d12 * d12 > 0.001D) + { + d4 = (double)((float)(Math.atan2(d12, d11) * 180.0D / Math.PI)); + } + + double d7 = MathHelper.wrapAngleTo180_double(d4 - (double)this.rotationYaw); + + if (d7 > 20.0D) + { + d7 = 20.0D; + } + + if (d7 < -20.0D) + { + d7 = -20.0D; + } + + this.rotationYaw = (float)((double)this.rotationYaw + d7); + this.setRotation(this.rotationYaw, this.rotationPitch); + + if (!this.worldObj.isRemote) + { + List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.expand(0.20000000298023224D, 0.0D, 0.20000000298023224D)); + + if (list != null && !list.isEmpty()) + { + for (int k1 = 0; k1 < list.size(); ++k1) + { + Entity entity = (Entity)list.get(k1); + + if (entity != this.riddenByEntity && entity.canBePushed() && entity instanceof EntityBoat) + { + entity.applyEntityCollision(this); + } + } + } + + if (this.riddenByEntity != null && this.riddenByEntity.isDead) + { + this.riddenByEntity = null; + } + } + } + } + + public void updateRiderPosition() + { + if (this.riddenByEntity != null) + { + double d0 = Math.cos((double)this.rotationYaw * Math.PI / 180.0D) * 0.4D; + double d1 = Math.sin((double)this.rotationYaw * Math.PI / 180.0D) * 0.4D; + this.riddenByEntity.setPosition(this.posX + d0, this.posY + this.getMountedYOffset() + this.riddenByEntity.getYOffset(), this.posZ + d1); + } + } + + protected void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) {} + + protected void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {} + + @SideOnly(Side.CLIENT) + public float getShadowSize() + { + return 0.0F; + } + + public boolean interactFirst(EntityPlayer par1EntityPlayer) + { + if (this.riddenByEntity != null && this.riddenByEntity instanceof EntityPlayer && this.riddenByEntity != par1EntityPlayer) + { + return true; + } + else + { + if (!this.worldObj.isRemote) + { + par1EntityPlayer.mountEntity(this); + } + + return true; + } + } + + protected void updateFallState(double par1, boolean par3) + { + int i = MathHelper.floor_double(this.posX); + int j = MathHelper.floor_double(this.posY); + int k = MathHelper.floor_double(this.posZ); + + if (par3) + { + if (this.fallDistance > 3.0F) + { + this.fall(this.fallDistance); + + if (!this.worldObj.isRemote && !this.isDead) + { + this.setDead(); + int l; + + for (l = 0; l < 3; ++l) + { + this.func_145778_a(Item.getItemFromBlock(Blocks.planks), 1, 0.0F); + } + + for (l = 0; l < 2; ++l) + { + this.func_145778_a(Items.stick, 1, 0.0F); + } + } + + this.fallDistance = 0.0F; + } + } + else if (this.worldObj.getBlock(i, j - 1, k).getMaterial() != Material.water && par1 < 0.0D) + { + this.fallDistance = (float)((double)this.fallDistance - par1); + } + } + + public void setDamageTaken(float par1) + { + this.dataWatcher.updateObject(19, Float.valueOf(par1)); + } + + public float getDamageTaken() + { + return this.dataWatcher.getWatchableObjectFloat(19); + } + + public void setTimeSinceHit(int par1) + { + this.dataWatcher.updateObject(17, Integer.valueOf(par1)); + } + + public int getTimeSinceHit() + { + return this.dataWatcher.getWatchableObjectInt(17); + } + + public void setForwardDirection(int par1) + { + this.dataWatcher.updateObject(18, Integer.valueOf(par1)); + } + + public int getForwardDirection() + { + return this.dataWatcher.getWatchableObjectInt(18); + } + + @SideOnly(Side.CLIENT) + public void setIsBoatEmpty(boolean par1) + { + this.isBoatEmpty = par1; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/item/EntityEnderCrystal.java b/src/main/java/net/minecraft/entity/item/EntityEnderCrystal.java new file mode 100644 index 0000000..5029cfa --- /dev/null +++ b/src/main/java/net/minecraft/entity/item/EntityEnderCrystal.java @@ -0,0 +1,104 @@ +package net.minecraft.entity.item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; +import net.minecraft.init.Blocks; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraft.world.WorldProviderEnd; + +public class EntityEnderCrystal extends Entity +{ + public int innerRotation; + public int health; + private static final String __OBFID = "CL_00001658"; + + public EntityEnderCrystal(World par1World) + { + super(par1World); + this.preventEntitySpawning = true; + this.setSize(2.0F, 2.0F); + this.yOffset = this.height / 2.0F; + this.health = 5; + this.innerRotation = this.rand.nextInt(100000); + } + + @SideOnly(Side.CLIENT) + public EntityEnderCrystal(World par1World, double par2, double par4, double par6) + { + this(par1World); + this.setPosition(par2, par4, par6); + } + + protected boolean canTriggerWalking() + { + return false; + } + + protected void entityInit() + { + this.dataWatcher.addObject(8, Integer.valueOf(this.health)); + } + + public void onUpdate() + { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + ++this.innerRotation; + this.dataWatcher.updateObject(8, Integer.valueOf(this.health)); + int i = MathHelper.floor_double(this.posX); + int j = MathHelper.floor_double(this.posY); + int k = MathHelper.floor_double(this.posZ); + + if (this.worldObj.provider instanceof WorldProviderEnd && this.worldObj.getBlock(i, j, k) != Blocks.fire) + { + this.worldObj.setBlock(i, j, k, Blocks.fire); + } + } + + protected void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) {} + + protected void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {} + + @SideOnly(Side.CLIENT) + public float getShadowSize() + { + return 0.0F; + } + + public boolean canBeCollidedWith() + { + return true; + } + + public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) + { + if (this.isEntityInvulnerable()) + { + return false; + } + else + { + if (!this.isDead && !this.worldObj.isRemote) + { + this.health = 0; + + if (this.health <= 0) + { + this.setDead(); + + if (!this.worldObj.isRemote) + { + this.worldObj.createExplosion((Entity)null, this.posX, this.posY, this.posZ, 6.0F, true); + } + } + } + + return true; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/item/EntityEnderEye.java b/src/main/java/net/minecraft/entity/item/EntityEnderEye.java new file mode 100644 index 0000000..080ab77 --- /dev/null +++ b/src/main/java/net/minecraft/entity/item/EntityEnderEye.java @@ -0,0 +1,206 @@ +package net.minecraft.entity.item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class EntityEnderEye extends Entity +{ + private double targetX; + private double targetY; + private double targetZ; + private int despawnTimer; + private boolean shatterOrDrop; + private static final String __OBFID = "CL_00001716"; + + public EntityEnderEye(World par1World) + { + super(par1World); + this.setSize(0.25F, 0.25F); + } + + protected void entityInit() {} + + @SideOnly(Side.CLIENT) + public boolean isInRangeToRenderDist(double par1) + { + double d1 = this.boundingBox.getAverageEdgeLength() * 4.0D; + d1 *= 64.0D; + return par1 < d1 * d1; + } + + public EntityEnderEye(World par1World, double par2, double par4, double par6) + { + super(par1World); + this.despawnTimer = 0; + this.setSize(0.25F, 0.25F); + this.setPosition(par2, par4, par6); + this.yOffset = 0.0F; + } + + public void moveTowards(double par1, int par3, double par4) + { + double d2 = par1 - this.posX; + double d3 = par4 - this.posZ; + float f = MathHelper.sqrt_double(d2 * d2 + d3 * d3); + + if (f > 12.0F) + { + this.targetX = this.posX + d2 / (double)f * 12.0D; + this.targetZ = this.posZ + d3 / (double)f * 12.0D; + this.targetY = this.posY + 8.0D; + } + else + { + this.targetX = par1; + this.targetY = (double)par3; + this.targetZ = par4; + } + + this.despawnTimer = 0; + this.shatterOrDrop = this.rand.nextInt(5) > 0; + } + + @SideOnly(Side.CLIENT) + public void setVelocity(double par1, double par3, double par5) + { + this.motionX = par1; + this.motionY = par3; + this.motionZ = par5; + + if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) + { + float f = MathHelper.sqrt_double(par1 * par1 + par5 * par5); + this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(par1, par5) * 180.0D / Math.PI); + this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(par3, (double)f) * 180.0D / Math.PI); + } + } + + public void onUpdate() + { + this.lastTickPosX = this.posX; + this.lastTickPosY = this.posY; + this.lastTickPosZ = this.posZ; + super.onUpdate(); + this.posX += this.motionX; + this.posY += this.motionY; + this.posZ += this.motionZ; + float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); + this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); + + for (this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) + { + ; + } + + while (this.rotationPitch - this.prevRotationPitch >= 180.0F) + { + this.prevRotationPitch += 360.0F; + } + + while (this.rotationYaw - this.prevRotationYaw < -180.0F) + { + this.prevRotationYaw -= 360.0F; + } + + while (this.rotationYaw - this.prevRotationYaw >= 180.0F) + { + this.prevRotationYaw += 360.0F; + } + + this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F; + this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F; + + if (!this.worldObj.isRemote) + { + double d0 = this.targetX - this.posX; + double d1 = this.targetZ - this.posZ; + float f1 = (float)Math.sqrt(d0 * d0 + d1 * d1); + float f2 = (float)Math.atan2(d1, d0); + double d2 = (double)f + (double)(f1 - f) * 0.0025D; + + if (f1 < 1.0F) + { + d2 *= 0.8D; + this.motionY *= 0.8D; + } + + this.motionX = Math.cos((double)f2) * d2; + this.motionZ = Math.sin((double)f2) * d2; + + if (this.posY < this.targetY) + { + this.motionY += (1.0D - this.motionY) * 0.014999999664723873D; + } + else + { + this.motionY += (-1.0D - this.motionY) * 0.014999999664723873D; + } + } + + float f3 = 0.25F; + + if (this.isInWater()) + { + for (int i = 0; i < 4; ++i) + { + this.worldObj.spawnParticle("bubble", this.posX - this.motionX * (double)f3, this.posY - this.motionY * (double)f3, this.posZ - this.motionZ * (double)f3, this.motionX, this.motionY, this.motionZ); + } + } + else + { + this.worldObj.spawnParticle("portal", this.posX - this.motionX * (double)f3 + this.rand.nextDouble() * 0.6D - 0.3D, this.posY - this.motionY * (double)f3 - 0.5D, this.posZ - this.motionZ * (double)f3 + this.rand.nextDouble() * 0.6D - 0.3D, this.motionX, this.motionY, this.motionZ); + } + + if (!this.worldObj.isRemote) + { + this.setPosition(this.posX, this.posY, this.posZ); + ++this.despawnTimer; + + if (this.despawnTimer > 80 && !this.worldObj.isRemote) + { + this.setDead(); + + if (this.shatterOrDrop) + { + this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.posX, this.posY, this.posZ, new ItemStack(Items.ender_eye))); + } + else + { + this.worldObj.playAuxSFX(2003, (int)Math.round(this.posX), (int)Math.round(this.posY), (int)Math.round(this.posZ), 0); + } + } + } + } + + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) {} + + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {} + + @SideOnly(Side.CLIENT) + public float getShadowSize() + { + return 0.0F; + } + + public float getBrightness(float par1) + { + return 1.0F; + } + + @SideOnly(Side.CLIENT) + public int getBrightnessForRender(float par1) + { + return 15728880; + } + + public boolean canAttackWithItem() + { + return false; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/item/EntityEnderPearl.java b/src/main/java/net/minecraft/entity/item/EntityEnderPearl.java new file mode 100644 index 0000000..141858a --- /dev/null +++ b/src/main/java/net/minecraft/entity/item/EntityEnderPearl.java @@ -0,0 +1,73 @@ +package net.minecraft.entity.item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.entity.projectile.EntityThrowable; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.living.EnderTeleportEvent; + +public class EntityEnderPearl extends EntityThrowable +{ + private static final String __OBFID = "CL_00001725"; + + public EntityEnderPearl(World par1World) + { + super(par1World); + } + + public EntityEnderPearl(World par1World, EntityLivingBase par2EntityLivingBase) + { + super(par1World, par2EntityLivingBase); + } + + @SideOnly(Side.CLIENT) + public EntityEnderPearl(World par1World, double par2, double par4, double par6) + { + super(par1World, par2, par4, par6); + } + + protected void onImpact(MovingObjectPosition par1MovingObjectPosition) + { + if (par1MovingObjectPosition.entityHit != null) + { + par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 0.0F); + } + + for (int i = 0; i < 32; ++i) + { + this.worldObj.spawnParticle("portal", this.posX, this.posY + this.rand.nextDouble() * 2.0D, this.posZ, this.rand.nextGaussian(), 0.0D, this.rand.nextGaussian()); + } + + if (!this.worldObj.isRemote) + { + if (this.getThrower() != null && this.getThrower() instanceof EntityPlayerMP) + { + EntityPlayerMP entityplayermp = (EntityPlayerMP)this.getThrower(); + + if (entityplayermp.playerNetServerHandler.func_147362_b().isChannelOpen() && entityplayermp.worldObj == this.worldObj) + { + EnderTeleportEvent event = new EnderTeleportEvent(entityplayermp, this.posX, this.posY, this.posZ, 5.0F); + if (!MinecraftForge.EVENT_BUS.post(event)) + { // Don't indent to lower patch size + if (this.getThrower().isRiding()) + { + this.getThrower().mountEntity((Entity)null); + } + + this.getThrower().setPositionAndUpdate(this.posX, this.posY, this.posZ); + this.getThrower().fallDistance = 0.0F; + this.getThrower().attackEntityFrom(DamageSource.fall, 5.0F); + } + } + } + + this.setDead(); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/item/EntityExpBottle.java b/src/main/java/net/minecraft/entity/item/EntityExpBottle.java new file mode 100644 index 0000000..4845631 --- /dev/null +++ b/src/main/java/net/minecraft/entity/item/EntityExpBottle.java @@ -0,0 +1,59 @@ +package net.minecraft.entity.item; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.projectile.EntityThrowable; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; + +public class EntityExpBottle extends EntityThrowable +{ + private static final String __OBFID = "CL_00001726"; + + public EntityExpBottle(World par1World) + { + super(par1World); + } + + public EntityExpBottle(World par1World, EntityLivingBase par2EntityLivingBase) + { + super(par1World, par2EntityLivingBase); + } + + public EntityExpBottle(World par1World, double par2, double par4, double par6) + { + super(par1World, par2, par4, par6); + } + + protected float getGravityVelocity() + { + return 0.07F; + } + + protected float func_70182_d() + { + return 0.7F; + } + + protected float func_70183_g() + { + return -20.0F; + } + + protected void onImpact(MovingObjectPosition par1MovingObjectPosition) + { + if (!this.worldObj.isRemote) + { + this.worldObj.playAuxSFX(2002, (int)Math.round(this.posX), (int)Math.round(this.posY), (int)Math.round(this.posZ), 0); + int i = 3 + this.worldObj.rand.nextInt(5) + this.worldObj.rand.nextInt(5); + + while (i > 0) + { + int j = EntityXPOrb.getXPSplit(i); + i -= j; + this.worldObj.spawnEntityInWorld(new EntityXPOrb(this.worldObj, this.posX, this.posY, this.posZ, j)); + } + + this.setDead(); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/item/EntityFallingBlock.java b/src/main/java/net/minecraft/entity/item/EntityFallingBlock.java new file mode 100644 index 0000000..0cf842d --- /dev/null +++ b/src/main/java/net/minecraft/entity/item/EntityFallingBlock.java @@ -0,0 +1,307 @@ +package net.minecraft.entity.item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.Iterator; +import net.minecraft.block.Block; +import net.minecraft.block.BlockFalling; +import net.minecraft.block.ITileEntityProvider; +import net.minecraft.block.material.Material; +import net.minecraft.crash.CrashReportCategory; +import net.minecraft.entity.Entity; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class EntityFallingBlock extends Entity +{ + private Block field_145811_e; + public int field_145814_a; + public int field_145812_b; + public boolean field_145813_c; + private boolean field_145808_f; + private boolean field_145809_g; + private int field_145815_h; + private float field_145816_i; + public NBTTagCompound field_145810_d; + private static final String __OBFID = "CL_00001668"; + + public EntityFallingBlock(World par1World) + { + super(par1World); + this.field_145813_c = true; + this.field_145815_h = 40; + this.field_145816_i = 2.0F; + } + + public EntityFallingBlock(World p_i45318_1_, double p_i45318_2_, double p_i45318_4_, double p_i45318_6_, Block p_i45318_8_) + { + this(p_i45318_1_, p_i45318_2_, p_i45318_4_, p_i45318_6_, p_i45318_8_, 0); + } + + public EntityFallingBlock(World p_i45319_1_, double p_i45319_2_, double p_i45319_4_, double p_i45319_6_, Block p_i45319_8_, int p_i45319_9_) + { + super(p_i45319_1_); + this.field_145813_c = true; + this.field_145815_h = 40; + this.field_145816_i = 2.0F; + this.field_145811_e = p_i45319_8_; + this.field_145814_a = p_i45319_9_; + this.preventEntitySpawning = true; + this.setSize(0.98F, 0.98F); + this.yOffset = this.height / 2.0F; + this.setPosition(p_i45319_2_, p_i45319_4_, p_i45319_6_); + this.motionX = 0.0D; + this.motionY = 0.0D; + this.motionZ = 0.0D; + this.prevPosX = p_i45319_2_; + this.prevPosY = p_i45319_4_; + this.prevPosZ = p_i45319_6_; + } + + protected boolean canTriggerWalking() + { + return false; + } + + protected void entityInit() {} + + public boolean canBeCollidedWith() + { + return !this.isDead; + } + + public void onUpdate() + { + if (this.field_145811_e.getMaterial() == Material.air) + { + this.setDead(); + } + else + { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + ++this.field_145812_b; + this.motionY -= 0.03999999910593033D; + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.9800000190734863D; + this.motionY *= 0.9800000190734863D; + this.motionZ *= 0.9800000190734863D; + + if (!this.worldObj.isRemote) + { + int i = MathHelper.floor_double(this.posX); + int j = MathHelper.floor_double(this.posY); + int k = MathHelper.floor_double(this.posZ); + + if (this.field_145812_b == 1) + { + if (this.worldObj.getBlock(i, j, k) != this.field_145811_e) + { + this.setDead(); + return; + } + + this.worldObj.setBlockToAir(i, j, k); + } + + if (this.onGround) + { + this.motionX *= 0.699999988079071D; + this.motionZ *= 0.699999988079071D; + this.motionY *= -0.5D; + + if (this.worldObj.getBlock(i, j, k) != Blocks.piston_extension) + { + this.setDead(); + + if (!this.field_145808_f && this.worldObj.canPlaceEntityOnSide(this.field_145811_e, i, j, k, true, 1, (Entity)null, (ItemStack)null) && !BlockFalling.func_149831_e(this.worldObj, i, j - 1, k) && this.worldObj.setBlock(i, j, k, this.field_145811_e, this.field_145814_a, 3)) + { + if (this.field_145811_e instanceof BlockFalling) + { + ((BlockFalling)this.field_145811_e).func_149828_a(this.worldObj, i, j, k, this.field_145814_a); + } + + if (this.field_145810_d != null && this.field_145811_e instanceof ITileEntityProvider) + { + TileEntity tileentity = this.worldObj.getTileEntity(i, j, k); + + if (tileentity != null) + { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + tileentity.writeToNBT(nbttagcompound); + Iterator iterator = this.field_145810_d.func_150296_c().iterator(); + + while (iterator.hasNext()) + { + String s = (String)iterator.next(); + NBTBase nbtbase = this.field_145810_d.getTag(s); + + if (!s.equals("x") && !s.equals("y") && !s.equals("z")) + { + nbttagcompound.setTag(s, nbtbase.copy()); + } + } + + tileentity.readFromNBT(nbttagcompound); + tileentity.markDirty(); + } + } + } + else if (this.field_145813_c && !this.field_145808_f) + { + this.entityDropItem(new ItemStack(this.field_145811_e, 1, this.field_145811_e.damageDropped(this.field_145814_a)), 0.0F); + } + } + } + else if (this.field_145812_b > 100 && !this.worldObj.isRemote && (j < 1 || j > 256) || this.field_145812_b > 600) + { + if (this.field_145813_c) + { + this.entityDropItem(new ItemStack(this.field_145811_e, 1, this.field_145811_e.damageDropped(this.field_145814_a)), 0.0F); + } + + this.setDead(); + } + } + } + } + + protected void fall(float par1) + { + if (this.field_145809_g) + { + int i = MathHelper.ceiling_float_int(par1 - 1.0F); + + if (i > 0) + { + ArrayList arraylist = new ArrayList(this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox)); + boolean flag = this.field_145811_e == Blocks.anvil; + DamageSource damagesource = flag ? DamageSource.anvil : DamageSource.fallingBlock; + Iterator iterator = arraylist.iterator(); + + while (iterator.hasNext()) + { + Entity entity = (Entity)iterator.next(); + entity.attackEntityFrom(damagesource, (float)Math.min(MathHelper.floor_float((float)i * this.field_145816_i), this.field_145815_h)); + } + + if (flag && (double)this.rand.nextFloat() < 0.05000000074505806D + (double)i * 0.05D) + { + int j = this.field_145814_a >> 2; + int k = this.field_145814_a & 3; + ++j; + + if (j > 2) + { + this.field_145808_f = true; + } + else + { + this.field_145814_a = k | j << 2; + } + } + } + } + } + + protected void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + par1NBTTagCompound.setByte("Tile", (byte)Block.getIdFromBlock(this.field_145811_e)); + par1NBTTagCompound.setInteger("TileID", Block.getIdFromBlock(this.field_145811_e)); + par1NBTTagCompound.setByte("Data", (byte)this.field_145814_a); + par1NBTTagCompound.setByte("Time", (byte)this.field_145812_b); + par1NBTTagCompound.setBoolean("DropItem", this.field_145813_c); + par1NBTTagCompound.setBoolean("HurtEntities", this.field_145809_g); + par1NBTTagCompound.setFloat("FallHurtAmount", this.field_145816_i); + par1NBTTagCompound.setInteger("FallHurtMax", this.field_145815_h); + + if (this.field_145810_d != null) + { + par1NBTTagCompound.setTag("TileEntityData", this.field_145810_d); + } + } + + protected void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + if (par1NBTTagCompound.hasKey("TileID", 99)) + { + this.field_145811_e = Block.getBlockById(par1NBTTagCompound.getInteger("TileID")); + } + else + { + this.field_145811_e = Block.getBlockById(par1NBTTagCompound.getByte("Tile") & 255); + } + + this.field_145814_a = par1NBTTagCompound.getByte("Data") & 255; + this.field_145812_b = par1NBTTagCompound.getByte("Time") & 255; + + if (par1NBTTagCompound.hasKey("HurtEntities", 99)) + { + this.field_145809_g = par1NBTTagCompound.getBoolean("HurtEntities"); + this.field_145816_i = par1NBTTagCompound.getFloat("FallHurtAmount"); + this.field_145815_h = par1NBTTagCompound.getInteger("FallHurtMax"); + } + else if (this.field_145811_e == Blocks.anvil) + { + this.field_145809_g = true; + } + + if (par1NBTTagCompound.hasKey("DropItem", 99)) + { + this.field_145813_c = par1NBTTagCompound.getBoolean("DropItem"); + } + + if (par1NBTTagCompound.hasKey("TileEntityData", 10)) + { + this.field_145810_d = par1NBTTagCompound.getCompoundTag("TileEntityData"); + } + + if (this.field_145811_e.getMaterial() == Material.air) + { + this.field_145811_e = Blocks.sand; + } + } + + public void func_145806_a(boolean p_145806_1_) + { + this.field_145809_g = p_145806_1_; + } + + public void addEntityCrashInfo(CrashReportCategory par1CrashReportCategory) + { + super.addEntityCrashInfo(par1CrashReportCategory); + par1CrashReportCategory.addCrashSection("Immitating block ID", Integer.valueOf(Block.getIdFromBlock(this.field_145811_e))); + par1CrashReportCategory.addCrashSection("Immitating block data", Integer.valueOf(this.field_145814_a)); + } + + @SideOnly(Side.CLIENT) + public float getShadowSize() + { + return 0.0F; + } + + @SideOnly(Side.CLIENT) + public World func_145807_e() + { + return this.worldObj; + } + + @SideOnly(Side.CLIENT) + public boolean canRenderOnFire() + { + return false; + } + + public Block func_145805_f() + { + return this.field_145811_e; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/item/EntityFireworkRocket.java b/src/main/java/net/minecraft/entity/item/EntityFireworkRocket.java new file mode 100644 index 0000000..871d9d0 --- /dev/null +++ b/src/main/java/net/minecraft/entity/item/EntityFireworkRocket.java @@ -0,0 +1,202 @@ +package net.minecraft.entity.item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class EntityFireworkRocket extends Entity +{ + private int fireworkAge; + private int lifetime; + private static final String __OBFID = "CL_00001718"; + + public EntityFireworkRocket(World par1World) + { + super(par1World); + this.setSize(0.25F, 0.25F); + } + + protected void entityInit() + { + this.dataWatcher.addObjectByDataType(8, 5); + } + + @SideOnly(Side.CLIENT) + public boolean isInRangeToRenderDist(double par1) + { + return par1 < 4096.0D; + } + + public EntityFireworkRocket(World par1World, double par2, double par4, double par6, ItemStack par8ItemStack) + { + super(par1World); + this.fireworkAge = 0; + this.setSize(0.25F, 0.25F); + this.setPosition(par2, par4, par6); + this.yOffset = 0.0F; + int i = 1; + + if (par8ItemStack != null && par8ItemStack.hasTagCompound()) + { + this.dataWatcher.updateObject(8, par8ItemStack); + NBTTagCompound nbttagcompound = par8ItemStack.getTagCompound(); + NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("Fireworks"); + + if (nbttagcompound1 != null) + { + i += nbttagcompound1.getByte("Flight"); + } + } + + this.motionX = this.rand.nextGaussian() * 0.001D; + this.motionZ = this.rand.nextGaussian() * 0.001D; + this.motionY = 0.05D; + this.lifetime = 10 * i + this.rand.nextInt(6) + this.rand.nextInt(7); + } + + @SideOnly(Side.CLIENT) + public void setVelocity(double par1, double par3, double par5) + { + this.motionX = par1; + this.motionY = par3; + this.motionZ = par5; + + if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) + { + float f = MathHelper.sqrt_double(par1 * par1 + par5 * par5); + this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(par1, par5) * 180.0D / Math.PI); + this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(par3, (double)f) * 180.0D / Math.PI); + } + } + + public void onUpdate() + { + this.lastTickPosX = this.posX; + this.lastTickPosY = this.posY; + this.lastTickPosZ = this.posZ; + super.onUpdate(); + this.motionX *= 1.15D; + this.motionZ *= 1.15D; + this.motionY += 0.04D; + this.moveEntity(this.motionX, this.motionY, this.motionZ); + float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); + this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); + + for (this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) + { + ; + } + + while (this.rotationPitch - this.prevRotationPitch >= 180.0F) + { + this.prevRotationPitch += 360.0F; + } + + while (this.rotationYaw - this.prevRotationYaw < -180.0F) + { + this.prevRotationYaw -= 360.0F; + } + + while (this.rotationYaw - this.prevRotationYaw >= 180.0F) + { + this.prevRotationYaw += 360.0F; + } + + this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F; + this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F; + + if (this.fireworkAge == 0) + { + this.worldObj.playSoundAtEntity(this, "fireworks.launch", 3.0F, 1.0F); + } + + ++this.fireworkAge; + + if (this.worldObj.isRemote && this.fireworkAge % 2 < 2) + { + this.worldObj.spawnParticle("fireworksSpark", this.posX, this.posY - 0.3D, this.posZ, this.rand.nextGaussian() * 0.05D, -this.motionY * 0.5D, this.rand.nextGaussian() * 0.05D); + } + + if (!this.worldObj.isRemote && this.fireworkAge > this.lifetime) + { + this.worldObj.setEntityState(this, (byte)17); + this.setDead(); + } + } + + @SideOnly(Side.CLIENT) + public void handleHealthUpdate(byte par1) + { + if (par1 == 17 && this.worldObj.isRemote) + { + ItemStack itemstack = this.dataWatcher.getWatchableObjectItemStack(8); + NBTTagCompound nbttagcompound = null; + + if (itemstack != null && itemstack.hasTagCompound()) + { + nbttagcompound = itemstack.getTagCompound().getCompoundTag("Fireworks"); + } + + this.worldObj.makeFireworks(this.posX, this.posY, this.posZ, this.motionX, this.motionY, this.motionZ, nbttagcompound); + } + + super.handleHealthUpdate(par1); + } + + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + par1NBTTagCompound.setInteger("Life", this.fireworkAge); + par1NBTTagCompound.setInteger("LifeTime", this.lifetime); + ItemStack itemstack = this.dataWatcher.getWatchableObjectItemStack(8); + + if (itemstack != null) + { + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + itemstack.writeToNBT(nbttagcompound1); + par1NBTTagCompound.setTag("FireworksItem", nbttagcompound1); + } + } + + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + this.fireworkAge = par1NBTTagCompound.getInteger("Life"); + this.lifetime = par1NBTTagCompound.getInteger("LifeTime"); + NBTTagCompound nbttagcompound1 = par1NBTTagCompound.getCompoundTag("FireworksItem"); + + if (nbttagcompound1 != null) + { + ItemStack itemstack = ItemStack.loadItemStackFromNBT(nbttagcompound1); + + if (itemstack != null) + { + this.dataWatcher.updateObject(8, itemstack); + } + } + } + + @SideOnly(Side.CLIENT) + public float getShadowSize() + { + return 0.0F; + } + + public float getBrightness(float par1) + { + return super.getBrightness(par1); + } + + @SideOnly(Side.CLIENT) + public int getBrightnessForRender(float par1) + { + return super.getBrightnessForRender(par1); + } + + public boolean canAttackWithItem() + { + return false; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/item/EntityItem.java b/src/main/java/net/minecraft/entity/item/EntityItem.java new file mode 100644 index 0000000..2fd1d04 --- /dev/null +++ b/src/main/java/net/minecraft/entity/item/EntityItem.java @@ -0,0 +1,467 @@ +package net.minecraft.entity.item; + +import java.util.Iterator; +import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.stats.AchievementList; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.item.ItemExpireEvent; +import net.minecraftforge.event.entity.player.EntityItemPickupEvent; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.eventhandler.Event.Result; + +public class EntityItem extends Entity +{ + private static final Logger logger = LogManager.getLogger(); + public int age; + public int delayBeforeCanPickup; + private int health; + private String field_145801_f; + private String field_145802_g; + public float hoverStart; + private static final String __OBFID = "CL_00001669"; + + /** + * The maximum age of this EntityItem. The item is expired once this is reached. + */ + public int lifespan = 6000; + + public EntityItem(World par1World, double par2, double par4, double par6) + { + super(par1World); + this.health = 5; + this.hoverStart = (float)(Math.random() * Math.PI * 2.0D); + this.setSize(0.25F, 0.25F); + this.yOffset = this.height / 2.0F; + this.setPosition(par2, par4, par6); + this.rotationYaw = (float)(Math.random() * 360.0D); + this.motionX = (double)((float)(Math.random() * 0.20000000298023224D - 0.10000000149011612D)); + this.motionY = 0.20000000298023224D; + this.motionZ = (double)((float)(Math.random() * 0.20000000298023224D - 0.10000000149011612D)); + } + + public EntityItem(World par1World, double par2, double par4, double par6, ItemStack par8ItemStack) + { + this(par1World, par2, par4, par6); + this.setEntityItemStack(par8ItemStack); + this.lifespan = (par8ItemStack.getItem() == null ? 6000 : par8ItemStack.getItem().getEntityLifespan(par8ItemStack, par1World)); + } + + protected boolean canTriggerWalking() + { + return false; + } + + public EntityItem(World par1World) + { + super(par1World); + this.health = 5; + this.hoverStart = (float)(Math.random() * Math.PI * 2.0D); + this.setSize(0.25F, 0.25F); + this.yOffset = this.height / 2.0F; + } + + protected void entityInit() + { + this.getDataWatcher().addObjectByDataType(10, 5); + } + + public void onUpdate() + { + ItemStack stack = this.getDataWatcher().getWatchableObjectItemStack(10); + if (stack != null && stack.getItem() != null) + { + if (stack.getItem().onEntityItemUpdate(this)) + { + return; + } + } + + if (this.getEntityItem() == null) + { + this.setDead(); + } + else + { + super.onUpdate(); + + if (this.delayBeforeCanPickup > 0) + { + --this.delayBeforeCanPickup; + } + + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + this.motionY -= 0.03999999910593033D; + this.noClip = this.func_145771_j(this.posX, (this.boundingBox.minY + this.boundingBox.maxY) / 2.0D, this.posZ); + this.moveEntity(this.motionX, this.motionY, this.motionZ); + boolean flag = (int)this.prevPosX != (int)this.posX || (int)this.prevPosY != (int)this.posY || (int)this.prevPosZ != (int)this.posZ; + + if (flag || this.ticksExisted % 25 == 0) + { + if (this.worldObj.getBlock(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)).getMaterial() == Material.lava) + { + this.motionY = 0.20000000298023224D; + this.motionX = (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F); + this.motionZ = (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F); + this.playSound("random.fizz", 0.4F, 2.0F + this.rand.nextFloat() * 0.4F); + } + + if (!this.worldObj.isRemote) + { + this.searchForOtherItemsNearby(); + } + } + + float f = 0.98F; + + if (this.onGround) + { + f = this.worldObj.getBlock(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.boundingBox.minY) - 1, MathHelper.floor_double(this.posZ)).slipperiness * 0.98F; + } + + this.motionX *= (double)f; + this.motionY *= 0.9800000190734863D; + this.motionZ *= (double)f; + + if (this.onGround) + { + this.motionY *= -0.5D; + } + + ++this.age; + + ItemStack item = getDataWatcher().getWatchableObjectItemStack(10); + + if (!this.worldObj.isRemote && this.age >= lifespan) + { + if (item != null) + { + ItemExpireEvent event = new ItemExpireEvent(this, (item.getItem() == null ? 6000 : item.getItem().getEntityLifespan(item, worldObj))); + if (MinecraftForge.EVENT_BUS.post(event)) + { + lifespan += event.extraLife; + } + else + { + this.setDead(); + } + } + else + { + this.setDead(); + } + } + + if (item != null && item.stackSize <= 0) + { + this.setDead(); + } + } + } + + private void searchForOtherItemsNearby() + { + Iterator iterator = this.worldObj.getEntitiesWithinAABB(EntityItem.class, this.boundingBox.expand(0.5D, 0.0D, 0.5D)).iterator(); + + while (iterator.hasNext()) + { + EntityItem entityitem = (EntityItem)iterator.next(); + this.combineItems(entityitem); + } + } + + public boolean combineItems(EntityItem par1EntityItem) + { + if (par1EntityItem == this) + { + return false; + } + else if (par1EntityItem.isEntityAlive() && this.isEntityAlive()) + { + ItemStack itemstack = this.getEntityItem(); + ItemStack itemstack1 = par1EntityItem.getEntityItem(); + + if (itemstack1.getItem() != itemstack.getItem()) + { + return false; + } + else if (itemstack1.hasTagCompound() ^ itemstack.hasTagCompound()) + { + return false; + } + else if (itemstack1.hasTagCompound() && !itemstack1.getTagCompound().equals(itemstack.getTagCompound())) + { + return false; + } + else if (itemstack1.getItem() == null) + { + return false; + } + else if (itemstack1.getItem().getHasSubtypes() && itemstack1.getItemDamage() != itemstack.getItemDamage()) + { + return false; + } + else if (itemstack1.stackSize < itemstack.stackSize) + { + return par1EntityItem.combineItems(this); + } + else if (itemstack1.stackSize + itemstack.stackSize > itemstack1.getMaxStackSize()) + { + return false; + } + else + { + itemstack1.stackSize += itemstack.stackSize; + par1EntityItem.delayBeforeCanPickup = Math.max(par1EntityItem.delayBeforeCanPickup, this.delayBeforeCanPickup); + par1EntityItem.age = Math.min(par1EntityItem.age, this.age); + par1EntityItem.setEntityItemStack(itemstack1); + this.setDead(); + return true; + } + } + else + { + return false; + } + } + + public void setAgeToCreativeDespawnTime() + { + this.age = 4800; + } + + public boolean handleWaterMovement() + { + return this.worldObj.handleMaterialAcceleration(this.boundingBox, Material.water, this); + } + + protected void dealFireDamage(int par1) + { + this.attackEntityFrom(DamageSource.inFire, (float)par1); + } + + public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) + { + if (this.isEntityInvulnerable()) + { + return false; + } + else if (this.getEntityItem() != null && this.getEntityItem().getItem() == Items.nether_star && par1DamageSource.isExplosion()) + { + return false; + } + else + { + this.setBeenAttacked(); + this.health = (int)((float)this.health - par2); + + if (this.health <= 0) + { + this.setDead(); + } + + return false; + } + } + + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + par1NBTTagCompound.setShort("Health", (short)((byte)this.health)); + par1NBTTagCompound.setShort("Age", (short)this.age); + par1NBTTagCompound.setInteger("Lifespan", lifespan); + + if (this.func_145800_j() != null) + { + par1NBTTagCompound.setString("Thrower", this.field_145801_f); + } + + if (this.func_145798_i() != null) + { + par1NBTTagCompound.setString("Owner", this.field_145802_g); + } + + if (this.getEntityItem() != null) + { + par1NBTTagCompound.setTag("Item", this.getEntityItem().writeToNBT(new NBTTagCompound())); + } + } + + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + this.health = par1NBTTagCompound.getShort("Health") & 255; + this.age = par1NBTTagCompound.getShort("Age"); + + if (par1NBTTagCompound.hasKey("Owner")) + { + this.field_145802_g = par1NBTTagCompound.getString("Owner"); + } + + if (par1NBTTagCompound.hasKey("Thrower")) + { + this.field_145801_f = par1NBTTagCompound.getString("Thrower"); + } + + NBTTagCompound nbttagcompound1 = par1NBTTagCompound.getCompoundTag("Item"); + this.setEntityItemStack(ItemStack.loadItemStackFromNBT(nbttagcompound1)); + + ItemStack item = getDataWatcher().getWatchableObjectItemStack(10); + + if (item == null || item.stackSize <= 0) + { + this.setDead(); + } + + if (par1NBTTagCompound.hasKey("Lifespan")) + { + lifespan = par1NBTTagCompound.getInteger("Lifespan"); + } + } + + public void onCollideWithPlayer(EntityPlayer par1EntityPlayer) + { + if (!this.worldObj.isRemote) + { + if (this.delayBeforeCanPickup > 0) + { + return; + } + + EntityItemPickupEvent event = new EntityItemPickupEvent(par1EntityPlayer, this); + + if (MinecraftForge.EVENT_BUS.post(event)) + { + return; + } + + ItemStack itemstack = this.getEntityItem(); + int i = itemstack.stackSize; + + if (this.delayBeforeCanPickup <= 0 && (this.field_145802_g == null || lifespan - this.age <= 200 || this.field_145802_g.equals(par1EntityPlayer.getCommandSenderName())) && (event.getResult() == Result.ALLOW || i <= 0 || par1EntityPlayer.inventory.addItemStackToInventory(itemstack))) + { + if (itemstack.getItem() == Item.getItemFromBlock(Blocks.log)) + { + par1EntityPlayer.triggerAchievement(AchievementList.mineWood); + } + + if (itemstack.getItem() == Item.getItemFromBlock(Blocks.log2)) + { + par1EntityPlayer.triggerAchievement(AchievementList.mineWood); + } + + if (itemstack.getItem() == Items.leather) + { + par1EntityPlayer.triggerAchievement(AchievementList.killCow); + } + + if (itemstack.getItem() == Items.diamond) + { + par1EntityPlayer.triggerAchievement(AchievementList.diamonds); + } + + if (itemstack.getItem() == Items.blaze_rod) + { + par1EntityPlayer.triggerAchievement(AchievementList.blazeRod); + } + + if (itemstack.getItem() == Items.diamond && this.func_145800_j() != null) + { + EntityPlayer entityplayer1 = this.worldObj.getPlayerEntityByName(this.func_145800_j()); + + if (entityplayer1 != null && entityplayer1 != par1EntityPlayer) + { + entityplayer1.triggerAchievement(AchievementList.field_150966_x); + } + } + + FMLCommonHandler.instance().firePlayerItemPickupEvent(par1EntityPlayer, this); + + this.worldObj.playSoundAtEntity(par1EntityPlayer, "random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); + par1EntityPlayer.onItemPickup(this, i); + + if (itemstack.stackSize <= 0) + { + this.setDead(); + } + } + } + } + + public String getCommandSenderName() + { + return StatCollector.translateToLocal("item." + this.getEntityItem().getUnlocalizedName()); + } + + public boolean canAttackWithItem() + { + return false; + } + + public void travelToDimension(int par1) + { + super.travelToDimension(par1); + + if (!this.worldObj.isRemote) + { + this.searchForOtherItemsNearby(); + } + } + + public ItemStack getEntityItem() + { + ItemStack itemstack = this.getDataWatcher().getWatchableObjectItemStack(10); + + if (itemstack == null) + { + if (this.worldObj != null) + { + logger.error("Item entity " + this.getEntityId() + " has no item?!"); + } + + return new ItemStack(Blocks.stone); + } + else + { + return itemstack; + } + } + + public void setEntityItemStack(ItemStack par1ItemStack) + { + this.getDataWatcher().updateObject(10, par1ItemStack); + this.getDataWatcher().setObjectWatched(10); + } + + public String func_145798_i() + { + return this.field_145802_g; + } + + public void func_145797_a(String p_145797_1_) + { + this.field_145802_g = p_145797_1_; + } + + public String func_145800_j() + { + return this.field_145801_f; + } + + public void func_145799_b(String p_145799_1_) + { + this.field_145801_f = p_145799_1_; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/item/EntityItemFrame.java b/src/main/java/net/minecraft/entity/item/EntityItemFrame.java new file mode 100644 index 0000000..d666b0a --- /dev/null +++ b/src/main/java/net/minecraft/entity/item/EntityItemFrame.java @@ -0,0 +1,206 @@ +package net.minecraft.entity.item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityHanging; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.ItemMap; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.DamageSource; +import net.minecraft.world.World; +import net.minecraft.world.storage.MapData; + +public class EntityItemFrame extends EntityHanging +{ + private float itemDropChance = 1.0F; + private static final String __OBFID = "CL_00001547"; + + public EntityItemFrame(World par1World) + { + super(par1World); + } + + public EntityItemFrame(World par1World, int par2, int par3, int par4, int par5) + { + super(par1World, par2, par3, par4, par5); + this.setDirection(par5); + } + + protected void entityInit() + { + this.getDataWatcher().addObjectByDataType(2, 5); + this.getDataWatcher().addObject(3, Byte.valueOf((byte)0)); + } + + public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) + { + if (this.isEntityInvulnerable()) + { + return false; + } + else if (this.getDisplayedItem() != null) + { + if (!this.worldObj.isRemote) + { + this.func_146065_b(par1DamageSource.getEntity(), false); + this.setDisplayedItem((ItemStack)null); + } + + return true; + } + else + { + return super.attackEntityFrom(par1DamageSource, par2); + } + } + + public int getWidthPixels() + { + return 9; + } + + public int getHeightPixels() + { + return 9; + } + + @SideOnly(Side.CLIENT) + public boolean isInRangeToRenderDist(double par1) + { + double d1 = 16.0D; + d1 *= 64.0D * this.renderDistanceWeight; + return par1 < d1 * d1; + } + + public void onBroken(Entity par1Entity) + { + this.func_146065_b(par1Entity, true); + } + + public void func_146065_b(Entity p_146065_1_, boolean p_146065_2_) + { + ItemStack itemstack = this.getDisplayedItem(); + + if (p_146065_1_ instanceof EntityPlayer) + { + EntityPlayer entityplayer = (EntityPlayer)p_146065_1_; + + if (entityplayer.capabilities.isCreativeMode) + { + this.removeFrameFromMap(itemstack); + return; + } + } + + if (p_146065_2_) + { + this.entityDropItem(new ItemStack(Items.item_frame), 0.0F); + } + + if (itemstack != null && this.rand.nextFloat() < this.itemDropChance) + { + itemstack = itemstack.copy(); + this.removeFrameFromMap(itemstack); + this.entityDropItem(itemstack, 0.0F); + } + } + + private void removeFrameFromMap(ItemStack par1ItemStack) + { + if (par1ItemStack != null) + { + if (par1ItemStack.getItem() == Items.filled_map) + { + MapData mapdata = ((ItemMap)par1ItemStack.getItem()).getMapData(par1ItemStack, this.worldObj); + mapdata.playersVisibleOnMap.remove("frame-" + this.getEntityId()); + } + + par1ItemStack.setItemFrame((EntityItemFrame)null); + } + } + + public ItemStack getDisplayedItem() + { + return this.getDataWatcher().getWatchableObjectItemStack(2); + } + + public void setDisplayedItem(ItemStack par1ItemStack) + { + if (par1ItemStack != null) + { + par1ItemStack = par1ItemStack.copy(); + par1ItemStack.stackSize = 1; + par1ItemStack.setItemFrame(this); + } + + this.getDataWatcher().updateObject(2, par1ItemStack); + this.getDataWatcher().setObjectWatched(2); + } + + public int getRotation() + { + return this.getDataWatcher().getWatchableObjectByte(3); + } + + public void setItemRotation(int par1) + { + this.getDataWatcher().updateObject(3, Byte.valueOf((byte)(par1 % 4))); + } + + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + if (this.getDisplayedItem() != null) + { + par1NBTTagCompound.setTag("Item", this.getDisplayedItem().writeToNBT(new NBTTagCompound())); + par1NBTTagCompound.setByte("ItemRotation", (byte)this.getRotation()); + par1NBTTagCompound.setFloat("ItemDropChance", this.itemDropChance); + } + + super.writeEntityToNBT(par1NBTTagCompound); + } + + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + NBTTagCompound nbttagcompound1 = par1NBTTagCompound.getCompoundTag("Item"); + + if (nbttagcompound1 != null && !nbttagcompound1.hasNoTags()) + { + this.setDisplayedItem(ItemStack.loadItemStackFromNBT(nbttagcompound1)); + this.setItemRotation(par1NBTTagCompound.getByte("ItemRotation")); + + if (par1NBTTagCompound.hasKey("ItemDropChance", 99)) + { + this.itemDropChance = par1NBTTagCompound.getFloat("ItemDropChance"); + } + } + + super.readEntityFromNBT(par1NBTTagCompound); + } + + public boolean interactFirst(EntityPlayer par1EntityPlayer) + { + if (this.getDisplayedItem() == null) + { + ItemStack itemstack = par1EntityPlayer.getHeldItem(); + + if (itemstack != null && !this.worldObj.isRemote) + { + this.setDisplayedItem(itemstack); + + if (!par1EntityPlayer.capabilities.isCreativeMode && --itemstack.stackSize <= 0) + { + par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack)null); + } + } + } + else if (!this.worldObj.isRemote) + { + this.setItemRotation(this.getRotation() + 1); + } + + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/item/EntityMinecart.java b/src/main/java/net/minecraft/entity/item/EntityMinecart.java new file mode 100644 index 0000000..5e79d72 --- /dev/null +++ b/src/main/java/net/minecraft/entity/item/EntityMinecart.java @@ -0,0 +1,1304 @@ +package net.minecraft.entity.item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.block.Block; +import net.minecraft.block.BlockRailBase; +import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.EntityMinecartCommandBlock; +import net.minecraft.entity.ai.EntityMinecartMobSpawner; +import net.minecraft.entity.monster.EntityIronGolem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; +import net.minecraft.world.WorldServer; +import net.minecraftforge.common.IMinecartCollisionHandler; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.minecart.MinecartCollisionEvent; +import net.minecraftforge.event.entity.minecart.MinecartUpdateEvent; + +public abstract class EntityMinecart extends Entity +{ + private boolean isInReverse; + private String entityName; + private static final int[][][] matrix = new int[][][] {{{0, 0, -1}, {0, 0, 1}}, {{ -1, 0, 0}, {1, 0, 0}}, {{ -1, -1, 0}, {1, 0, 0}}, {{ -1, 0, 0}, {1, -1, 0}}, {{0, 0, -1}, {0, -1, 1}}, {{0, -1, -1}, {0, 0, 1}}, {{0, 0, 1}, {1, 0, 0}}, {{0, 0, 1}, { -1, 0, 0}}, {{0, 0, -1}, { -1, 0, 0}}, {{0, 0, -1}, {1, 0, 0}}}; + private int turnProgress; + private double minecartX; + private double minecartY; + private double minecartZ; + private double minecartYaw; + private double minecartPitch; + @SideOnly(Side.CLIENT) + private double velocityX; + @SideOnly(Side.CLIENT) + private double velocityY; + @SideOnly(Side.CLIENT) + private double velocityZ; + private static final String __OBFID = "CL_00001670"; + + /* Forge: Minecart Compatibility Layer Integration. */ + public static float defaultMaxSpeedAirLateral = 0.4f; + public static float defaultMaxSpeedAirVertical = -1f; + public static double defaultDragAir = 0.94999998807907104D; + protected boolean canUseRail = true; + protected boolean canBePushed = true; + private static IMinecartCollisionHandler collisionHandler = null; + + /* Instance versions of the above physics properties */ + private float currentSpeedRail = getMaxCartSpeedOnRail(); + protected float maxSpeedAirLateral = defaultMaxSpeedAirLateral; + protected float maxSpeedAirVertical = defaultMaxSpeedAirVertical; + protected double dragAir = defaultDragAir; + + public EntityMinecart(World par1World) + { + super(par1World); + this.preventEntitySpawning = true; + this.setSize(0.98F, 0.7F); + this.yOffset = this.height / 2.0F; + } + + public static EntityMinecart createMinecart(World par0World, double par1, double par3, double par5, int par7) + { + switch (par7) + { + case 1: + return new EntityMinecartChest(par0World, par1, par3, par5); + case 2: + return new EntityMinecartFurnace(par0World, par1, par3, par5); + case 3: + return new EntityMinecartTNT(par0World, par1, par3, par5); + case 4: + return new EntityMinecartMobSpawner(par0World, par1, par3, par5); + case 5: + return new EntityMinecartHopper(par0World, par1, par3, par5); + case 6: + return new EntityMinecartCommandBlock(par0World, par1, par3, par5); + default: + return new EntityMinecartEmpty(par0World, par1, par3, par5); + } + } + + protected boolean canTriggerWalking() + { + return false; + } + + protected void entityInit() + { + this.dataWatcher.addObject(17, new Integer(0)); + this.dataWatcher.addObject(18, new Integer(1)); + this.dataWatcher.addObject(19, new Float(0.0F)); + this.dataWatcher.addObject(20, new Integer(0)); + this.dataWatcher.addObject(21, new Integer(6)); + this.dataWatcher.addObject(22, Byte.valueOf((byte)0)); + } + + public AxisAlignedBB getCollisionBox(Entity par1Entity) + { + if (getCollisionHandler() != null) + { + return getCollisionHandler().getCollisionBox(this, par1Entity); + } + return par1Entity.canBePushed() ? par1Entity.boundingBox : null; + } + + public AxisAlignedBB getBoundingBox() + { + if (getCollisionHandler() != null) + { + return getCollisionHandler().getBoundingBox(this); + } + return null; + } + + public boolean canBePushed() + { + return canBePushed; + } + + public EntityMinecart(World par1World, double par2, double par4, double par6) + { + this(par1World); + this.setPosition(par2, par4, par6); + this.motionX = 0.0D; + this.motionY = 0.0D; + this.motionZ = 0.0D; + this.prevPosX = par2; + this.prevPosY = par4; + this.prevPosZ = par6; + } + + public double getMountedYOffset() + { + return (double)this.height * 0.0D - 0.30000001192092896D; + } + + public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) + { + if (!this.worldObj.isRemote && !this.isDead) + { + if (this.isEntityInvulnerable()) + { + return false; + } + else + { + this.setRollingDirection(-this.getRollingDirection()); + this.setRollingAmplitude(10); + this.setBeenAttacked(); + this.setDamage(this.getDamage() + par2 * 10.0F); + boolean flag = par1DamageSource.getEntity() instanceof EntityPlayer && ((EntityPlayer)par1DamageSource.getEntity()).capabilities.isCreativeMode; + + if (flag || this.getDamage() > 40.0F) + { + if (this.riddenByEntity != null) + { + this.riddenByEntity.mountEntity(this); + } + + if (flag && !this.hasCustomInventoryName()) + { + this.setDead(); + } + else + { + this.killMinecart(par1DamageSource); + } + } + + return true; + } + } + else + { + return true; + } + } + + public void killMinecart(DamageSource par1DamageSource) + { + this.setDead(); + ItemStack itemstack = new ItemStack(Items.minecart, 1); + + if (this.entityName != null) + { + itemstack.setStackDisplayName(this.entityName); + } + + this.entityDropItem(itemstack, 0.0F); + } + + @SideOnly(Side.CLIENT) + public void performHurtAnimation() + { + this.setRollingDirection(-this.getRollingDirection()); + this.setRollingAmplitude(10); + this.setDamage(this.getDamage() + this.getDamage() * 10.0F); + } + + public boolean canBeCollidedWith() + { + return !this.isDead; + } + + public void setDead() + { + super.setDead(); + } + + public void onUpdate() + { + if (this.getRollingAmplitude() > 0) + { + this.setRollingAmplitude(this.getRollingAmplitude() - 1); + } + + if (this.getDamage() > 0.0F) + { + this.setDamage(this.getDamage() - 1.0F); + } + + if (this.posY < -64.0D) + { + this.kill(); + } + + int i; + + if (!this.worldObj.isRemote && this.worldObj instanceof WorldServer) + { + this.worldObj.theProfiler.startSection("portal"); + MinecraftServer minecraftserver = ((WorldServer)this.worldObj).func_73046_m(); + i = this.getMaxInPortalTime(); + + if (this.inPortal) + { + if (minecraftserver.getAllowNether()) + { + if (this.ridingEntity == null && this.portalCounter++ >= i) + { + this.portalCounter = i; + this.timeUntilPortal = this.getPortalCooldown(); + byte b0; + + if (this.worldObj.provider.dimensionId == -1) + { + b0 = 0; + } + else + { + b0 = -1; + } + + this.travelToDimension(b0); + } + + this.inPortal = false; + } + } + else + { + if (this.portalCounter > 0) + { + this.portalCounter -= 4; + } + + if (this.portalCounter < 0) + { + this.portalCounter = 0; + } + } + + if (this.timeUntilPortal > 0) + { + --this.timeUntilPortal; + } + + this.worldObj.theProfiler.endSection(); + } + + if (this.worldObj.isRemote) + { + if (this.turnProgress > 0) + { + double d6 = this.posX + (this.minecartX - this.posX) / (double)this.turnProgress; + double d7 = this.posY + (this.minecartY - this.posY) / (double)this.turnProgress; + double d1 = this.posZ + (this.minecartZ - this.posZ) / (double)this.turnProgress; + double d3 = MathHelper.wrapAngleTo180_double(this.minecartYaw - (double)this.rotationYaw); + this.rotationYaw = (float)((double)this.rotationYaw + d3 / (double)this.turnProgress); + this.rotationPitch = (float)((double)this.rotationPitch + (this.minecartPitch - (double)this.rotationPitch) / (double)this.turnProgress); + --this.turnProgress; + this.setPosition(d6, d7, d1); + this.setRotation(this.rotationYaw, this.rotationPitch); + } + else + { + this.setPosition(this.posX, this.posY, this.posZ); + this.setRotation(this.rotationYaw, this.rotationPitch); + } + } + else + { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + this.motionY -= 0.03999999910593033D; + int l = MathHelper.floor_double(this.posX); + i = MathHelper.floor_double(this.posY); + int i1 = MathHelper.floor_double(this.posZ); + + if (BlockRailBase.func_150049_b_(this.worldObj, l, i - 1, i1)) + { + --i; + } + + double d0 = 0.4D; + double d2 = 0.0078125D; + Block block = this.worldObj.getBlock(l, i, i1); + + if (canUseRail() && BlockRailBase.func_150051_a(block)) + { + float railMaxSpeed = ((BlockRailBase)block).getRailMaxSpeed(worldObj, this, l, i, i1); + double maxSpeed = Math.min(railMaxSpeed, getCurrentCartSpeedCapOnRail()); + this.func_145821_a(l, i, i1, maxSpeed, getSlopeAdjustment(), block, ((BlockRailBase)block).getBasicRailMetadata(worldObj, this, l, i, i1)); + + if (block == Blocks.activator_rail) + { + this.onActivatorRailPass(l, i, i1, (worldObj.getBlockMetadata(l, i, i1) & 8) != 0); + } + } + else + { + this.func_94088_b(onGround ? d0 : getMaxSpeedAirLateral()); + } + + this.func_145775_I(); + this.rotationPitch = 0.0F; + double d8 = this.prevPosX - this.posX; + double d4 = this.prevPosZ - this.posZ; + + if (d8 * d8 + d4 * d4 > 0.001D) + { + this.rotationYaw = (float)(Math.atan2(d4, d8) * 180.0D / Math.PI); + + if (this.isInReverse) + { + this.rotationYaw += 180.0F; + } + } + + double d5 = (double)MathHelper.wrapAngleTo180_float(this.rotationYaw - this.prevRotationYaw); + + if (d5 < -170.0D || d5 >= 170.0D) + { + this.rotationYaw += 180.0F; + this.isInReverse = !this.isInReverse; + } + + this.setRotation(this.rotationYaw, this.rotationPitch); + + AxisAlignedBB box; + if (getCollisionHandler() != null) + { + box = getCollisionHandler().getMinecartCollisionBox(this); + } + else + { + box = boundingBox.expand(0.2D, 0.0D, 0.2D); + } + + List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, box); + + if (list != null && !list.isEmpty()) + { + for (int k = 0; k < list.size(); ++k) + { + Entity entity = (Entity)list.get(k); + + if (entity != this.riddenByEntity && entity.canBePushed() && entity instanceof EntityMinecart) + { + entity.applyEntityCollision(this); + } + } + } + + if (this.riddenByEntity != null && this.riddenByEntity.isDead) + { + if (this.riddenByEntity.ridingEntity == this) + { + this.riddenByEntity.ridingEntity = null; + } + + this.riddenByEntity = null; + } + + MinecraftForge.EVENT_BUS.post(new MinecartUpdateEvent(this, l, i, i1)); + } + } + + public void onActivatorRailPass(int par1, int par2, int par3, boolean par4) {} + + protected void func_94088_b(double par1) + { + if (this.motionX < -par1) + { + this.motionX = -par1; + } + + if (this.motionX > par1) + { + this.motionX = par1; + } + + if (this.motionZ < -par1) + { + this.motionZ = -par1; + } + + if (this.motionZ > par1) + { + this.motionZ = par1; + } + + double moveY = motionY; + if(getMaxSpeedAirVertical() > 0 && motionY > getMaxSpeedAirVertical()) + { + moveY = getMaxSpeedAirVertical(); + if(Math.abs(motionX) < 0.3f && Math.abs(motionZ) < 0.3f) + { + moveY = 0.15f; + motionY = moveY; + } + } + + if (this.onGround) + { + this.motionX *= 0.5D; + this.motionY *= 0.5D; + this.motionZ *= 0.5D; + } + + this.moveEntity(this.motionX, moveY, this.motionZ); + + if (!this.onGround) + { + this.motionX *= getDragAir(); + this.motionY *= getDragAir(); + this.motionZ *= getDragAir(); + } + } + + protected void func_145821_a(int p_145821_1_, int p_145821_2_, int p_145821_3_, double p_145821_4_, double p_145821_6_, Block p_145821_8_, int p_145821_9_) + { + this.fallDistance = 0.0F; + Vec3 vec3 = this.func_70489_a(this.posX, this.posY, this.posZ); + this.posY = (double)p_145821_2_; + boolean flag = false; + boolean flag1 = false; + + if (p_145821_8_ == Blocks.golden_rail) + { + flag = (worldObj.getBlockMetadata(p_145821_1_, p_145821_2_, p_145821_3_) & 8) != 0; + flag1 = !flag; + } + + if (((BlockRailBase)p_145821_8_).isPowered()) + { + p_145821_9_ &= 7; + } + + if (p_145821_9_ >= 2 && p_145821_9_ <= 5) + { + this.posY = (double)(p_145821_2_ + 1); + } + + if (p_145821_9_ == 2) + { + this.motionX -= p_145821_6_; + } + + if (p_145821_9_ == 3) + { + this.motionX += p_145821_6_; + } + + if (p_145821_9_ == 4) + { + this.motionZ += p_145821_6_; + } + + if (p_145821_9_ == 5) + { + this.motionZ -= p_145821_6_; + } + + int[][] aint = matrix[p_145821_9_]; + double d2 = (double)(aint[1][0] - aint[0][0]); + double d3 = (double)(aint[1][2] - aint[0][2]); + double d4 = Math.sqrt(d2 * d2 + d3 * d3); + double d5 = this.motionX * d2 + this.motionZ * d3; + + if (d5 < 0.0D) + { + d2 = -d2; + d3 = -d3; + } + + double d6 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ); + + if (d6 > 2.0D) + { + d6 = 2.0D; + } + + this.motionX = d6 * d2 / d4; + this.motionZ = d6 * d3 / d4; + double d7; + double d8; + double d9; + double d10; + + if (this.riddenByEntity != null && this.riddenByEntity instanceof EntityLivingBase) + { + d7 = (double)((EntityLivingBase)this.riddenByEntity).moveForward; + + if (d7 > 0.0D) + { + d8 = -Math.sin((double)(this.riddenByEntity.rotationYaw * (float)Math.PI / 180.0F)); + d9 = Math.cos((double)(this.riddenByEntity.rotationYaw * (float)Math.PI / 180.0F)); + d10 = this.motionX * this.motionX + this.motionZ * this.motionZ; + + if (d10 < 0.01D) + { + this.motionX += d8 * 0.1D; + this.motionZ += d9 * 0.1D; + flag1 = false; + } + } + } + + if (flag1 && shouldDoRailFunctions()) + { + d7 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ); + + if (d7 < 0.03D) + { + this.motionX *= 0.0D; + this.motionY *= 0.0D; + this.motionZ *= 0.0D; + } + else + { + this.motionX *= 0.5D; + this.motionY *= 0.0D; + this.motionZ *= 0.5D; + } + } + + d7 = 0.0D; + d8 = (double)p_145821_1_ + 0.5D + (double)aint[0][0] * 0.5D; + d9 = (double)p_145821_3_ + 0.5D + (double)aint[0][2] * 0.5D; + d10 = (double)p_145821_1_ + 0.5D + (double)aint[1][0] * 0.5D; + double d11 = (double)p_145821_3_ + 0.5D + (double)aint[1][2] * 0.5D; + d2 = d10 - d8; + d3 = d11 - d9; + double d12; + double d13; + + if (d2 == 0.0D) + { + this.posX = (double)p_145821_1_ + 0.5D; + d7 = this.posZ - (double)p_145821_3_; + } + else if (d3 == 0.0D) + { + this.posZ = (double)p_145821_3_ + 0.5D; + d7 = this.posX - (double)p_145821_1_; + } + else + { + d12 = this.posX - d8; + d13 = this.posZ - d9; + d7 = (d12 * d2 + d13 * d3) * 2.0D; + } + + this.posX = d8 + d2 * d7; + this.posZ = d9 + d3 * d7; + this.setPosition(this.posX, this.posY + (double)this.yOffset, this.posZ); + + moveMinecartOnRail(p_145821_1_, p_145821_2_, p_145821_3_, p_145821_4_); + + if (aint[0][1] != 0 && MathHelper.floor_double(this.posX) - p_145821_1_ == aint[0][0] && MathHelper.floor_double(this.posZ) - p_145821_3_ == aint[0][2]) + { + this.setPosition(this.posX, this.posY + (double)aint[0][1], this.posZ); + } + else if (aint[1][1] != 0 && MathHelper.floor_double(this.posX) - p_145821_1_ == aint[1][0] && MathHelper.floor_double(this.posZ) - p_145821_3_ == aint[1][2]) + { + this.setPosition(this.posX, this.posY + (double)aint[1][1], this.posZ); + } + + this.applyDrag(); + Vec3 vec31 = this.func_70489_a(this.posX, this.posY, this.posZ); + + if (vec31 != null && vec3 != null) + { + double d14 = (vec3.yCoord - vec31.yCoord) * 0.05D; + d6 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ); + + if (d6 > 0.0D) + { + this.motionX = this.motionX / d6 * (d6 + d14); + this.motionZ = this.motionZ / d6 * (d6 + d14); + } + + this.setPosition(this.posX, vec31.yCoord, this.posZ); + } + + int j1 = MathHelper.floor_double(this.posX); + int i1 = MathHelper.floor_double(this.posZ); + + if (j1 != p_145821_1_ || i1 != p_145821_3_) + { + d6 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ); + this.motionX = d6 * (double)(j1 - p_145821_1_); + this.motionZ = d6 * (double)(i1 - p_145821_3_); + } + + if(shouldDoRailFunctions()) + { + ((BlockRailBase)p_145821_8_).onMinecartPass(worldObj, this, p_145821_1_, p_145821_2_, p_145821_3_); + } + + if (flag && shouldDoRailFunctions()) + { + double d15 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ); + + if (d15 > 0.01D) + { + double d16 = 0.06D; + this.motionX += this.motionX / d15 * d16; + this.motionZ += this.motionZ / d15 * d16; + } + else if (p_145821_9_ == 1) + { + if (this.worldObj.getBlock(p_145821_1_ - 1, p_145821_2_, p_145821_3_).isNormalCube()) + { + this.motionX = 0.02D; + } + else if (this.worldObj.getBlock(p_145821_1_ + 1, p_145821_2_, p_145821_3_).isNormalCube()) + { + this.motionX = -0.02D; + } + } + else if (p_145821_9_ == 0) + { + if (this.worldObj.getBlock(p_145821_1_, p_145821_2_, p_145821_3_ - 1).isNormalCube()) + { + this.motionZ = 0.02D; + } + else if (this.worldObj.getBlock(p_145821_1_, p_145821_2_, p_145821_3_ + 1).isNormalCube()) + { + this.motionZ = -0.02D; + } + } + } + } + + protected void applyDrag() + { + if (this.riddenByEntity != null) + { + this.motionX *= 0.996999979019165D; + this.motionY *= 0.0D; + this.motionZ *= 0.996999979019165D; + } + else + { + this.motionX *= 0.9599999785423279D; + this.motionY *= 0.0D; + this.motionZ *= 0.9599999785423279D; + } + } + + @SideOnly(Side.CLIENT) + public Vec3 func_70495_a(double par1, double par3, double par5, double par7) + { + int i = MathHelper.floor_double(par1); + int j = MathHelper.floor_double(par3); + int k = MathHelper.floor_double(par5); + + if (BlockRailBase.func_150049_b_(this.worldObj, i, j - 1, k)) + { + --j; + } + + Block block = this.worldObj.getBlock(i, j, k); + + if (!BlockRailBase.func_150051_a(block)) + { + return null; + } + else + { + int l = ((BlockRailBase)block).getBasicRailMetadata(worldObj, this, i, j, k); + + par3 = (double)j; + + if (l >= 2 && l <= 5) + { + par3 = (double)(j + 1); + } + + int[][] aint = matrix[l]; + double d4 = (double)(aint[1][0] - aint[0][0]); + double d5 = (double)(aint[1][2] - aint[0][2]); + double d6 = Math.sqrt(d4 * d4 + d5 * d5); + d4 /= d6; + d5 /= d6; + par1 += d4 * par7; + par5 += d5 * par7; + + if (aint[0][1] != 0 && MathHelper.floor_double(par1) - i == aint[0][0] && MathHelper.floor_double(par5) - k == aint[0][2]) + { + par3 += (double)aint[0][1]; + } + else if (aint[1][1] != 0 && MathHelper.floor_double(par1) - i == aint[1][0] && MathHelper.floor_double(par5) - k == aint[1][2]) + { + par3 += (double)aint[1][1]; + } + + return this.func_70489_a(par1, par3, par5); + } + } + + public Vec3 func_70489_a(double par1, double par3, double par5) + { + int i = MathHelper.floor_double(par1); + int j = MathHelper.floor_double(par3); + int k = MathHelper.floor_double(par5); + + if (BlockRailBase.func_150049_b_(this.worldObj, i, j - 1, k)) + { + --j; + } + + Block block = this.worldObj.getBlock(i, j, k); + + if (BlockRailBase.func_150051_a(block)) + { + int l = ((BlockRailBase)block).getBasicRailMetadata(worldObj, this, i, j, k); + par3 = (double)j; + + if (l >= 2 && l <= 5) + { + par3 = (double)(j + 1); + } + + int[][] aint = matrix[l]; + double d3 = 0.0D; + double d4 = (double)i + 0.5D + (double)aint[0][0] * 0.5D; + double d5 = (double)j + 0.5D + (double)aint[0][1] * 0.5D; + double d6 = (double)k + 0.5D + (double)aint[0][2] * 0.5D; + double d7 = (double)i + 0.5D + (double)aint[1][0] * 0.5D; + double d8 = (double)j + 0.5D + (double)aint[1][1] * 0.5D; + double d9 = (double)k + 0.5D + (double)aint[1][2] * 0.5D; + double d10 = d7 - d4; + double d11 = (d8 - d5) * 2.0D; + double d12 = d9 - d6; + + if (d10 == 0.0D) + { + par1 = (double)i + 0.5D; + d3 = par5 - (double)k; + } + else if (d12 == 0.0D) + { + par5 = (double)k + 0.5D; + d3 = par1 - (double)i; + } + else + { + double d13 = par1 - d4; + double d14 = par5 - d6; + d3 = (d13 * d10 + d14 * d12) * 2.0D; + } + + par1 = d4 + d10 * d3; + par3 = d5 + d11 * d3; + par5 = d6 + d12 * d3; + + if (d11 < 0.0D) + { + ++par3; + } + + if (d11 > 0.0D) + { + par3 += 0.5D; + } + + return this.worldObj.getWorldVec3Pool().getVecFromPool(par1, par3, par5); + } + else + { + return null; + } + } + + protected void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + if (par1NBTTagCompound.getBoolean("CustomDisplayTile")) + { + this.func_145819_k(par1NBTTagCompound.getInteger("DisplayTile")); + this.setDisplayTileData(par1NBTTagCompound.getInteger("DisplayData")); + this.setDisplayTileOffset(par1NBTTagCompound.getInteger("DisplayOffset")); + } + + if (par1NBTTagCompound.hasKey("CustomName", 8) && par1NBTTagCompound.getString("CustomName").length() > 0) + { + this.entityName = par1NBTTagCompound.getString("CustomName"); + } + } + + protected void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + if (this.hasDisplayTile()) + { + par1NBTTagCompound.setBoolean("CustomDisplayTile", true); + par1NBTTagCompound.setInteger("DisplayTile", this.func_145820_n().getMaterial() == Material.air ? 0 : Block.getIdFromBlock(this.func_145820_n())); + par1NBTTagCompound.setInteger("DisplayData", this.getDisplayTileData()); + par1NBTTagCompound.setInteger("DisplayOffset", this.getDisplayTileOffset()); + } + + if (this.entityName != null && this.entityName.length() > 0) + { + par1NBTTagCompound.setString("CustomName", this.entityName); + } + } + + @SideOnly(Side.CLIENT) + public float getShadowSize() + { + return 0.0F; + } + + public void applyEntityCollision(Entity par1Entity) + { + MinecraftForge.EVENT_BUS.post(new MinecartCollisionEvent(this, par1Entity)); + if (getCollisionHandler() != null) + { + getCollisionHandler().onEntityCollision(this, par1Entity); + return; + } + if (!this.worldObj.isRemote) + { + if (par1Entity != this.riddenByEntity) + { + if (par1Entity instanceof EntityLivingBase && !(par1Entity instanceof EntityPlayer) && !(par1Entity instanceof EntityIronGolem) && canBeRidden() && this.motionX * this.motionX + this.motionZ * this.motionZ > 0.01D && this.riddenByEntity == null && par1Entity.ridingEntity == null) + { + par1Entity.mountEntity(this); + } + + double d0 = par1Entity.posX - this.posX; + double d1 = par1Entity.posZ - this.posZ; + double d2 = d0 * d0 + d1 * d1; + + if (d2 >= 9.999999747378752E-5D) + { + d2 = (double)MathHelper.sqrt_double(d2); + d0 /= d2; + d1 /= d2; + double d3 = 1.0D / d2; + + if (d3 > 1.0D) + { + d3 = 1.0D; + } + + d0 *= d3; + d1 *= d3; + d0 *= 0.10000000149011612D; + d1 *= 0.10000000149011612D; + d0 *= (double)(1.0F - this.entityCollisionReduction); + d1 *= (double)(1.0F - this.entityCollisionReduction); + d0 *= 0.5D; + d1 *= 0.5D; + + if (par1Entity instanceof EntityMinecart) + { + double d4 = par1Entity.posX - this.posX; + double d5 = par1Entity.posZ - this.posZ; + Vec3 vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(d4, 0.0D, d5).normalize(); + Vec3 vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool((double)MathHelper.cos(this.rotationYaw * (float)Math.PI / 180.0F), 0.0D, (double)MathHelper.sin(this.rotationYaw * (float)Math.PI / 180.0F)).normalize(); + double d6 = Math.abs(vec3.dotProduct(vec31)); + + if (d6 < 0.800000011920929D) + { + return; + } + + double d7 = par1Entity.motionX + this.motionX; + double d8 = par1Entity.motionZ + this.motionZ; + + if (((EntityMinecart)par1Entity).isPoweredCart() && !isPoweredCart()) + { + this.motionX *= 0.20000000298023224D; + this.motionZ *= 0.20000000298023224D; + this.addVelocity(par1Entity.motionX - d0, 0.0D, par1Entity.motionZ - d1); + par1Entity.motionX *= 0.949999988079071D; + par1Entity.motionZ *= 0.949999988079071D; + } + else if (((EntityMinecart)par1Entity).isPoweredCart() && !isPoweredCart()) + { + par1Entity.motionX *= 0.20000000298023224D; + par1Entity.motionZ *= 0.20000000298023224D; + par1Entity.addVelocity(this.motionX + d0, 0.0D, this.motionZ + d1); + this.motionX *= 0.949999988079071D; + this.motionZ *= 0.949999988079071D; + } + else + { + d7 /= 2.0D; + d8 /= 2.0D; + this.motionX *= 0.20000000298023224D; + this.motionZ *= 0.20000000298023224D; + this.addVelocity(d7 - d0, 0.0D, d8 - d1); + par1Entity.motionX *= 0.20000000298023224D; + par1Entity.motionZ *= 0.20000000298023224D; + par1Entity.addVelocity(d7 + d0, 0.0D, d8 + d1); + } + } + else + { + this.addVelocity(-d0, 0.0D, -d1); + par1Entity.addVelocity(d0 / 4.0D, 0.0D, d1 / 4.0D); + } + } + } + } + } + + @SideOnly(Side.CLIENT) + public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9) + { + this.minecartX = par1; + this.minecartY = par3; + this.minecartZ = par5; + this.minecartYaw = (double)par7; + this.minecartPitch = (double)par8; + this.turnProgress = par9 + 2; + this.motionX = this.velocityX; + this.motionY = this.velocityY; + this.motionZ = this.velocityZ; + } + + public void setDamage(float par1) + { + this.dataWatcher.updateObject(19, Float.valueOf(par1)); + } + + @SideOnly(Side.CLIENT) + public void setVelocity(double par1, double par3, double par5) + { + this.velocityX = this.motionX = par1; + this.velocityY = this.motionY = par3; + this.velocityZ = this.motionZ = par5; + } + + public float getDamage() + { + return this.dataWatcher.getWatchableObjectFloat(19); + } + + public void setRollingAmplitude(int par1) + { + this.dataWatcher.updateObject(17, Integer.valueOf(par1)); + } + + public int getRollingAmplitude() + { + return this.dataWatcher.getWatchableObjectInt(17); + } + + public void setRollingDirection(int par1) + { + this.dataWatcher.updateObject(18, Integer.valueOf(par1)); + } + + public int getRollingDirection() + { + return this.dataWatcher.getWatchableObjectInt(18); + } + + public abstract int getMinecartType(); + + public Block func_145820_n() + { + if (!this.hasDisplayTile()) + { + return this.func_145817_o(); + } + else + { + int i = this.getDataWatcher().getWatchableObjectInt(20) & 65535; + return Block.getBlockById(i); + } + } + + public Block func_145817_o() + { + return Blocks.air; + } + + public int getDisplayTileData() + { + return !this.hasDisplayTile() ? this.getDefaultDisplayTileData() : this.getDataWatcher().getWatchableObjectInt(20) >> 16; + } + + public int getDefaultDisplayTileData() + { + return 0; + } + + public int getDisplayTileOffset() + { + return !this.hasDisplayTile() ? this.getDefaultDisplayTileOffset() : this.getDataWatcher().getWatchableObjectInt(21); + } + + public int getDefaultDisplayTileOffset() + { + return 6; + } + + public void func_145819_k(int p_145819_1_) + { + this.getDataWatcher().updateObject(20, Integer.valueOf(p_145819_1_ & 65535 | this.getDisplayTileData() << 16)); + this.setHasDisplayTile(true); + } + + public void setDisplayTileData(int par1) + { + this.getDataWatcher().updateObject(20, Integer.valueOf(Block.getIdFromBlock(this.func_145820_n()) & 65535 | par1 << 16)); + this.setHasDisplayTile(true); + } + + public void setDisplayTileOffset(int par1) + { + this.getDataWatcher().updateObject(21, Integer.valueOf(par1)); + this.setHasDisplayTile(true); + } + + public boolean hasDisplayTile() + { + return this.getDataWatcher().getWatchableObjectByte(22) == 1; + } + + public void setHasDisplayTile(boolean par1) + { + this.getDataWatcher().updateObject(22, Byte.valueOf((byte)(par1 ? 1 : 0))); + } + + public void setMinecartName(String par1Str) + { + this.entityName = par1Str; + } + + public String getCommandSenderName() + { + return this.entityName != null ? this.entityName : super.getCommandSenderName(); + } + + public boolean hasCustomInventoryName() + { + return this.entityName != null; + } + + public String func_95999_t() + { + return this.entityName; + } + /* =================================== FORGE START ===========================================*/ + /** + * Moved to allow overrides. + * This code handles minecart movement and speed capping when on a rail. + */ + public void moveMinecartOnRail(int x, int y, int z, double par4){ + double d12 = this.motionX; + double d13 = this.motionZ; + + if (this.riddenByEntity != null) + { + d12 *= 0.75D; + d13 *= 0.75D; + } + + if (d12 < -par4) + { + d12 = -par4; + } + + if (d12 > par4) + { + d12 = par4; + } + + if (d13 < -par4) + { + d13 = -par4; + } + + if (d13 > par4) + { + d13 = par4; + } + + this.moveEntity(d12, 0.0D, d13); + } + + /** + * Gets the current global Minecart Collision handler if none + * is registered, returns null + * @return The collision handler or null + */ + public static IMinecartCollisionHandler getCollisionHandler() + { + return collisionHandler; + } + + /** + * Sets the global Minecart Collision handler, overwrites any + * that is currently set. + * @param handler The new handler + */ + public static void setCollisionHandler(IMinecartCollisionHandler handler) + { + collisionHandler = handler; + } + + /** + * This function returns an ItemStack that represents this cart. + * This should be an ItemStack that can be used by the player to place the cart, + * but is not necessary the item the cart drops when destroyed. + * @return An ItemStack that can be used to place the cart. + */ + public ItemStack getCartItem() + { + if (this instanceof EntityMinecartFurnace) + { + return new ItemStack(Items.furnace_minecart); + } + else if (this instanceof EntityMinecartChest) + { + return new ItemStack(Items.chest_minecart); + } + else if (this instanceof EntityMinecartTNT) + { + return new ItemStack(Items.tnt_minecart); + } + else if (this instanceof EntityMinecartHopper) + { + return new ItemStack(Items.hopper_minecart); + } + else if (this instanceof EntityMinecartHopper) + { + return new ItemStack(Items.command_block_minecart); + } + return new ItemStack(Items.minecart); + } + + /** + * Returns true if this cart can currently use rails. + * This function is mainly used to gracefully detach a minecart from a rail. + * @return True if the minecart can use rails. + */ + public boolean canUseRail() + { + return canUseRail; + } + + /** + * Set whether the minecart can use rails. + * This function is mainly used to gracefully detach a minecart from a rail. + * @param use Whether the minecart can currently use rails. + */ + public void setCanUseRail(boolean use) + { + canUseRail = use; + } + + /** + * Return false if this cart should not call onMinecartPass() and should ignore Powered Rails. + * @return True if this cart should call onMinecartPass(). + */ + public boolean shouldDoRailFunctions() + { + return true; + } + + /** + * Returns true if this cart is self propelled. + * @return True if powered. + */ + public boolean isPoweredCart() + { + return getMinecartType()== 2; + } + + /** + * Returns true if this cart can be ridden by an Entity. + * @return True if this cart can be ridden. + */ + public boolean canBeRidden() + { + if(this instanceof EntityMinecartEmpty) + { + return true; + } + return false; + } + + /** + * Getters/setters for physics variables + */ + + /** + * Returns the carts max speed when traveling on rails. Carts going faster + * than 1.1 cause issues with chunk loading. Carts cant traverse slopes or + * corners at greater than 0.5 - 0.6. This value is compared with the rails + * max speed and the carts current speed cap to determine the carts current + * max speed. A normal rail's max speed is 0.4. + * + * @return Carts max speed. + */ + public float getMaxCartSpeedOnRail() + { + return 1.2f; + } + + /** + * Returns the current speed cap for the cart when traveling on rails. This + * functions differs from getMaxCartSpeedOnRail() in that it controls + * current movement and cannot be overridden. The value however can never be + * higher than getMaxCartSpeedOnRail(). + * + * @return + */ + public final float getCurrentCartSpeedCapOnRail() + { + return currentSpeedRail; + } + + public final void setCurrentCartSpeedCapOnRail(float value) + { + value = Math.min(value, getMaxCartSpeedOnRail()); + currentSpeedRail = value; + } + + public float getMaxSpeedAirLateral() + { + return maxSpeedAirLateral; + } + + public void setMaxSpeedAirLateral(float value) + { + maxSpeedAirLateral = value; + } + + public float getMaxSpeedAirVertical() + { + return maxSpeedAirVertical; + } + + public void setMaxSpeedAirVertical(float value) + { + maxSpeedAirVertical = value; + } + + public double getDragAir() + { + return dragAir; + } + + public void setDragAir(double value) + { + dragAir = value; + } + + public double getSlopeAdjustment() + { + return 0.0078125D; + } + /* =================================== FORGE END ===========================================*/ +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/item/EntityMinecartChest.java b/src/main/java/net/minecraft/entity/item/EntityMinecartChest.java new file mode 100644 index 0000000..a120c22 --- /dev/null +++ b/src/main/java/net/minecraft/entity/item/EntityMinecartChest.java @@ -0,0 +1,48 @@ +package net.minecraft.entity.item; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.util.DamageSource; +import net.minecraft.world.World; + +public class EntityMinecartChest extends EntityMinecartContainer +{ + private static final String __OBFID = "CL_00001671"; + + public EntityMinecartChest(World par1World) + { + super(par1World); + } + + public EntityMinecartChest(World par1World, double par2, double par4, double par6) + { + super(par1World, par2, par4, par6); + } + + public void killMinecart(DamageSource par1DamageSource) + { + super.killMinecart(par1DamageSource); + this.func_145778_a(Item.getItemFromBlock(Blocks.chest), 1, 0.0F); + } + + public int getSizeInventory() + { + return 27; + } + + public int getMinecartType() + { + return 1; + } + + public Block func_145817_o() + { + return Blocks.chest; + } + + public int getDefaultDisplayTileOffset() + { + return 8; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/item/EntityMinecartContainer.java b/src/main/java/net/minecraft/entity/item/EntityMinecartContainer.java new file mode 100644 index 0000000..56fbf50 --- /dev/null +++ b/src/main/java/net/minecraft/entity/item/EntityMinecartContainer.java @@ -0,0 +1,254 @@ +package net.minecraft.entity.item; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.DamageSource; +import net.minecraft.world.World; + +public abstract class EntityMinecartContainer extends EntityMinecart implements IInventory +{ + private ItemStack[] minecartContainerItems = new ItemStack[36]; + private boolean dropContentsWhenDead = true; + private static final String __OBFID = "CL_00001674"; + + public EntityMinecartContainer(World par1World) + { + super(par1World); + } + + public EntityMinecartContainer(World par1World, double par2, double par4, double par6) + { + super(par1World, par2, par4, par6); + } + + public void killMinecart(DamageSource par1DamageSource) + { + super.killMinecart(par1DamageSource); + + for (int i = 0; i < this.getSizeInventory(); ++i) + { + ItemStack itemstack = this.getStackInSlot(i); + + if (itemstack != null) + { + float f = this.rand.nextFloat() * 0.8F + 0.1F; + float f1 = this.rand.nextFloat() * 0.8F + 0.1F; + float f2 = this.rand.nextFloat() * 0.8F + 0.1F; + + while (itemstack.stackSize > 0) + { + int j = this.rand.nextInt(21) + 10; + + if (j > itemstack.stackSize) + { + j = itemstack.stackSize; + } + + itemstack.stackSize -= j; + EntityItem entityitem = new EntityItem(this.worldObj, this.posX + (double)f, this.posY + (double)f1, this.posZ + (double)f2, new ItemStack(itemstack.getItem(), j, itemstack.getItemDamage())); + float f3 = 0.05F; + entityitem.motionX = (double)((float)this.rand.nextGaussian() * f3); + entityitem.motionY = (double)((float)this.rand.nextGaussian() * f3 + 0.2F); + entityitem.motionZ = (double)((float)this.rand.nextGaussian() * f3); + this.worldObj.spawnEntityInWorld(entityitem); + } + } + } + } + + public ItemStack getStackInSlot(int par1) + { + return this.minecartContainerItems[par1]; + } + + public ItemStack decrStackSize(int par1, int par2) + { + if (this.minecartContainerItems[par1] != null) + { + ItemStack itemstack; + + if (this.minecartContainerItems[par1].stackSize <= par2) + { + itemstack = this.minecartContainerItems[par1]; + this.minecartContainerItems[par1] = null; + return itemstack; + } + else + { + itemstack = this.minecartContainerItems[par1].splitStack(par2); + + if (this.minecartContainerItems[par1].stackSize == 0) + { + this.minecartContainerItems[par1] = null; + } + + return itemstack; + } + } + else + { + return null; + } + } + + public ItemStack getStackInSlotOnClosing(int par1) + { + if (this.minecartContainerItems[par1] != null) + { + ItemStack itemstack = this.minecartContainerItems[par1]; + this.minecartContainerItems[par1] = null; + return itemstack; + } + else + { + return null; + } + } + + public void setInventorySlotContents(int par1, ItemStack par2ItemStack) + { + this.minecartContainerItems[par1] = par2ItemStack; + + if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit()) + { + par2ItemStack.stackSize = this.getInventoryStackLimit(); + } + } + + public void markDirty() {} + + public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) + { + return this.isDead ? false : par1EntityPlayer.getDistanceSqToEntity(this) <= 64.0D; + } + + public void openInventory() {} + + public void closeInventory() {} + + public boolean isItemValidForSlot(int par1, ItemStack par2ItemStack) + { + return true; + } + + public String getInventoryName() + { + return this.hasCustomInventoryName() ? this.func_95999_t() : "container.minecart"; + } + + public int getInventoryStackLimit() + { + return 64; + } + + public void travelToDimension(int par1) + { + this.dropContentsWhenDead = false; + super.travelToDimension(par1); + } + + public void setDead() + { + if (this.dropContentsWhenDead) + { + for (int i = 0; i < this.getSizeInventory(); ++i) + { + ItemStack itemstack = this.getStackInSlot(i); + + if (itemstack != null) + { + float f = this.rand.nextFloat() * 0.8F + 0.1F; + float f1 = this.rand.nextFloat() * 0.8F + 0.1F; + float f2 = this.rand.nextFloat() * 0.8F + 0.1F; + + while (itemstack.stackSize > 0) + { + int j = this.rand.nextInt(21) + 10; + + if (j > itemstack.stackSize) + { + j = itemstack.stackSize; + } + + itemstack.stackSize -= j; + EntityItem entityitem = new EntityItem(this.worldObj, this.posX + (double)f, this.posY + (double)f1, this.posZ + (double)f2, new ItemStack(itemstack.getItem(), j, itemstack.getItemDamage())); + + if (itemstack.hasTagCompound()) + { + entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); + } + + float f3 = 0.05F; + entityitem.motionX = (double)((float)this.rand.nextGaussian() * f3); + entityitem.motionY = (double)((float)this.rand.nextGaussian() * f3 + 0.2F); + entityitem.motionZ = (double)((float)this.rand.nextGaussian() * f3); + this.worldObj.spawnEntityInWorld(entityitem); + } + } + } + } + + super.setDead(); + } + + protected void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeEntityToNBT(par1NBTTagCompound); + NBTTagList nbttaglist = new NBTTagList(); + + for (int i = 0; i < this.minecartContainerItems.length; ++i) + { + if (this.minecartContainerItems[i] != null) + { + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + nbttagcompound1.setByte("Slot", (byte)i); + this.minecartContainerItems[i].writeToNBT(nbttagcompound1); + nbttaglist.appendTag(nbttagcompound1); + } + } + + par1NBTTagCompound.setTag("Items", nbttaglist); + } + + protected void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + super.readEntityFromNBT(par1NBTTagCompound); + NBTTagList nbttaglist = par1NBTTagCompound.getTagList("Items", 10); + this.minecartContainerItems = new ItemStack[this.getSizeInventory()]; + + for (int i = 0; i < nbttaglist.tagCount(); ++i) + { + NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); + int j = nbttagcompound1.getByte("Slot") & 255; + + if (j >= 0 && j < this.minecartContainerItems.length) + { + this.minecartContainerItems[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); + } + } + } + + public boolean interactFirst(EntityPlayer par1EntityPlayer) + { + if(net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.minecart.MinecartInteractEvent(this, par1EntityPlayer))) return true; + if (!this.worldObj.isRemote) + { + par1EntityPlayer.displayGUIChest(this); + } + + return true; + } + + protected void applyDrag() + { + int i = 15 - Container.calcRedstoneFromInventory(this); + float f = 0.98F + (float)i * 0.001F; + this.motionX *= (double)f; + this.motionY *= 0.0D; + this.motionZ *= (double)f; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/item/EntityMinecartEmpty.java b/src/main/java/net/minecraft/entity/item/EntityMinecartEmpty.java new file mode 100644 index 0000000..23e6cb5 --- /dev/null +++ b/src/main/java/net/minecraft/entity/item/EntityMinecartEmpty.java @@ -0,0 +1,46 @@ +package net.minecraft.entity.item; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; + +public class EntityMinecartEmpty extends EntityMinecart +{ + private static final String __OBFID = "CL_00001677"; + + public EntityMinecartEmpty(World par1World) + { + super(par1World); + } + + public EntityMinecartEmpty(World par1World, double par2, double par4, double par6) + { + super(par1World, par2, par4, par6); + } + + public boolean interactFirst(EntityPlayer par1EntityPlayer) + { + if(net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.minecart.MinecartInteractEvent(this, par1EntityPlayer))) return true; + if (this.riddenByEntity != null && this.riddenByEntity instanceof EntityPlayer && this.riddenByEntity != par1EntityPlayer) + { + return true; + } + else if (this.riddenByEntity != null && this.riddenByEntity != par1EntityPlayer) + { + return false; + } + else + { + if (!this.worldObj.isRemote) + { + par1EntityPlayer.mountEntity(this); + } + + return true; + } + } + + public int getMinecartType() + { + return 0; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/item/EntityMinecartFurnace.java b/src/main/java/net/minecraft/entity/item/EntityMinecartFurnace.java new file mode 100644 index 0000000..1b93277 --- /dev/null +++ b/src/main/java/net/minecraft/entity/item/EntityMinecartFurnace.java @@ -0,0 +1,185 @@ +package net.minecraft.entity.item; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class EntityMinecartFurnace extends EntityMinecart +{ + private int fuel; + public double pushX; + public double pushZ; + private static final String __OBFID = "CL_00001675"; + + public EntityMinecartFurnace(World par1World) + { + super(par1World); + } + + public EntityMinecartFurnace(World par1World, double par2, double par4, double par6) + { + super(par1World, par2, par4, par6); + } + + public int getMinecartType() + { + return 2; + } + + protected void entityInit() + { + super.entityInit(); + this.dataWatcher.addObject(16, new Byte((byte)0)); + } + + public void onUpdate() + { + super.onUpdate(); + + if (this.fuel > 0) + { + --this.fuel; + } + + if (this.fuel <= 0) + { + this.pushX = this.pushZ = 0.0D; + } + + this.setMinecartPowered(this.fuel > 0); + + if (this.isMinecartPowered() && this.rand.nextInt(4) == 0) + { + this.worldObj.spawnParticle("largesmoke", this.posX, this.posY + 0.8D, this.posZ, 0.0D, 0.0D, 0.0D); + } + } + + public void killMinecart(DamageSource par1DamageSource) + { + super.killMinecart(par1DamageSource); + + if (!par1DamageSource.isExplosion()) + { + this.entityDropItem(new ItemStack(Blocks.furnace, 1), 0.0F); + } + } + + protected void func_145821_a(int p_145821_1_, int p_145821_2_, int p_145821_3_, double p_145821_4_, double p_145821_6_, Block p_145821_8_, int p_145821_9_) + { + super.func_145821_a(p_145821_1_, p_145821_2_, p_145821_3_, p_145821_4_, p_145821_6_, p_145821_8_, p_145821_9_); + double d2 = this.pushX * this.pushX + this.pushZ * this.pushZ; + + if (d2 > 1.0E-4D && this.motionX * this.motionX + this.motionZ * this.motionZ > 0.001D) + { + d2 = (double)MathHelper.sqrt_double(d2); + this.pushX /= d2; + this.pushZ /= d2; + + if (this.pushX * this.motionX + this.pushZ * this.motionZ < 0.0D) + { + this.pushX = 0.0D; + this.pushZ = 0.0D; + } + else + { + this.pushX = this.motionX; + this.pushZ = this.motionZ; + } + } + } + + protected void applyDrag() + { + double d0 = this.pushX * this.pushX + this.pushZ * this.pushZ; + + if (d0 > 1.0E-4D) + { + d0 = (double)MathHelper.sqrt_double(d0); + this.pushX /= d0; + this.pushZ /= d0; + double d1 = 0.05D; + this.motionX *= 0.800000011920929D; + this.motionY *= 0.0D; + this.motionZ *= 0.800000011920929D; + this.motionX += this.pushX * d1; + this.motionZ += this.pushZ * d1; + } + else + { + this.motionX *= 0.9800000190734863D; + this.motionY *= 0.0D; + this.motionZ *= 0.9800000190734863D; + } + + super.applyDrag(); + } + + public boolean interactFirst(EntityPlayer par1EntityPlayer) + { + if(net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.minecart.MinecartInteractEvent(this, par1EntityPlayer))) return true; + ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem(); + + if (itemstack != null && itemstack.getItem() == Items.coal) + { + if (!par1EntityPlayer.capabilities.isCreativeMode && --itemstack.stackSize == 0) + { + par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack)null); + } + + this.fuel += 3600; + } + + this.pushX = this.posX - par1EntityPlayer.posX; + this.pushZ = this.posZ - par1EntityPlayer.posZ; + return true; + } + + protected void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeEntityToNBT(par1NBTTagCompound); + par1NBTTagCompound.setDouble("PushX", this.pushX); + par1NBTTagCompound.setDouble("PushZ", this.pushZ); + par1NBTTagCompound.setShort("Fuel", (short)this.fuel); + } + + protected void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + super.readEntityFromNBT(par1NBTTagCompound); + this.pushX = par1NBTTagCompound.getDouble("PushX"); + this.pushZ = par1NBTTagCompound.getDouble("PushZ"); + this.fuel = par1NBTTagCompound.getShort("Fuel"); + } + + protected boolean isMinecartPowered() + { + return (this.dataWatcher.getWatchableObjectByte(16) & 1) != 0; + } + + protected void setMinecartPowered(boolean par1) + { + if (par1) + { + this.dataWatcher.updateObject(16, Byte.valueOf((byte)(this.dataWatcher.getWatchableObjectByte(16) | 1))); + } + else + { + this.dataWatcher.updateObject(16, Byte.valueOf((byte)(this.dataWatcher.getWatchableObjectByte(16) & -2))); + } + } + + public Block func_145817_o() + { + return Blocks.lit_furnace; + } + + public int getDefaultDisplayTileData() + { + return 2; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/item/EntityMinecartHopper.java b/src/main/java/net/minecraft/entity/item/EntityMinecartHopper.java new file mode 100644 index 0000000..706e47d --- /dev/null +++ b/src/main/java/net/minecraft/entity/item/EntityMinecartHopper.java @@ -0,0 +1,169 @@ +package net.minecraft.entity.item; + +import java.util.List; +import net.minecraft.block.Block; +import net.minecraft.command.IEntitySelector; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.IHopper; +import net.minecraft.tileentity.TileEntityHopper; +import net.minecraft.util.DamageSource; +import net.minecraft.world.World; + +public class EntityMinecartHopper extends EntityMinecartContainer implements IHopper +{ + private boolean isBlocked = true; + private int transferTicker = -1; + private static final String __OBFID = "CL_00001676"; + + public EntityMinecartHopper(World par1World) + { + super(par1World); + } + + public EntityMinecartHopper(World par1World, double par2, double par4, double par6) + { + super(par1World, par2, par4, par6); + } + + public int getMinecartType() + { + return 5; + } + + public Block func_145817_o() + { + return Blocks.hopper; + } + + public int getDefaultDisplayTileOffset() + { + return 1; + } + + public int getSizeInventory() + { + return 5; + } + + public boolean interactFirst(EntityPlayer par1EntityPlayer) + { + if(net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.minecart.MinecartInteractEvent(this, par1EntityPlayer))) return true; + if (!this.worldObj.isRemote) + { + par1EntityPlayer.displayGUIHopperMinecart(this); + } + + return true; + } + + public void onActivatorRailPass(int par1, int par2, int par3, boolean par4) + { + boolean flag1 = !par4; + + if (flag1 != this.getBlocked()) + { + this.setBlocked(flag1); + } + } + + public boolean getBlocked() + { + return this.isBlocked; + } + + public void setBlocked(boolean par1) + { + this.isBlocked = par1; + } + + public World getWorldObj() + { + return this.worldObj; + } + + public double getXPos() + { + return this.posX; + } + + public double getYPos() + { + return this.posY; + } + + public double getZPos() + { + return this.posZ; + } + + public void onUpdate() + { + super.onUpdate(); + + if (!this.worldObj.isRemote && this.isEntityAlive() && this.getBlocked()) + { + --this.transferTicker; + + if (!this.canTransfer()) + { + this.setTransferTicker(0); + + if (this.func_96112_aD()) + { + this.setTransferTicker(4); + this.markDirty(); + } + } + } + } + + public boolean func_96112_aD() + { + if (TileEntityHopper.func_145891_a(this)) + { + return true; + } + else + { + List list = this.worldObj.selectEntitiesWithinAABB(EntityItem.class, this.boundingBox.expand(0.25D, 0.0D, 0.25D), IEntitySelector.selectAnything); + + if (list.size() > 0) + { + TileEntityHopper.func_145898_a(this, (EntityItem)list.get(0)); + } + + return false; + } + } + + public void killMinecart(DamageSource par1DamageSource) + { + super.killMinecart(par1DamageSource); + this.func_145778_a(Item.getItemFromBlock(Blocks.hopper), 1, 0.0F); + } + + protected void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeEntityToNBT(par1NBTTagCompound); + par1NBTTagCompound.setInteger("TransferCooldown", this.transferTicker); + } + + protected void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + super.readEntityFromNBT(par1NBTTagCompound); + this.transferTicker = par1NBTTagCompound.getInteger("TransferCooldown"); + } + + public void setTransferTicker(int par1) + { + this.transferTicker = par1; + } + + public boolean canTransfer() + { + return this.transferTicker > 0; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/item/EntityMinecartTNT.java b/src/main/java/net/minecraft/entity/item/EntityMinecartTNT.java new file mode 100644 index 0000000..a56e241 --- /dev/null +++ b/src/main/java/net/minecraft/entity/item/EntityMinecartTNT.java @@ -0,0 +1,175 @@ +package net.minecraft.entity.item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.block.BlockRailBase; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.DamageSource; +import net.minecraft.world.Explosion; +import net.minecraft.world.World; + +public class EntityMinecartTNT extends EntityMinecart +{ + private int minecartTNTFuse = -1; + private static final String __OBFID = "CL_00001680"; + + public EntityMinecartTNT(World par1World) + { + super(par1World); + } + + public EntityMinecartTNT(World par1World, double par2, double par4, double par6) + { + super(par1World, par2, par4, par6); + } + + public int getMinecartType() + { + return 3; + } + + public Block func_145817_o() + { + return Blocks.tnt; + } + + public void onUpdate() + { + super.onUpdate(); + + if (this.minecartTNTFuse > 0) + { + --this.minecartTNTFuse; + this.worldObj.spawnParticle("smoke", this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D); + } + else if (this.minecartTNTFuse == 0) + { + this.explodeCart(this.motionX * this.motionX + this.motionZ * this.motionZ); + } + + if (this.isCollidedHorizontally) + { + double d0 = this.motionX * this.motionX + this.motionZ * this.motionZ; + + if (d0 >= 0.009999999776482582D) + { + this.explodeCart(d0); + } + } + } + + public void killMinecart(DamageSource par1DamageSource) + { + super.killMinecart(par1DamageSource); + double d0 = this.motionX * this.motionX + this.motionZ * this.motionZ; + + if (!par1DamageSource.isExplosion()) + { + this.entityDropItem(new ItemStack(Blocks.tnt, 1), 0.0F); + } + + if (par1DamageSource.isFireDamage() || par1DamageSource.isExplosion() || d0 >= 0.009999999776482582D) + { + this.explodeCart(d0); + } + } + + protected void explodeCart(double par1) + { + if (!this.worldObj.isRemote) + { + double d1 = Math.sqrt(par1); + + if (d1 > 5.0D) + { + d1 = 5.0D; + } + + this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, (float)(4.0D + this.rand.nextDouble() * 1.5D * d1), true); + this.setDead(); + } + } + + protected void fall(float par1) + { + if (par1 >= 3.0F) + { + float f1 = par1 / 10.0F; + this.explodeCart((double)(f1 * f1)); + } + + super.fall(par1); + } + + public void onActivatorRailPass(int par1, int par2, int par3, boolean par4) + { + if (par4 && this.minecartTNTFuse < 0) + { + this.ignite(); + } + } + + @SideOnly(Side.CLIENT) + public void handleHealthUpdate(byte par1) + { + if (par1 == 10) + { + this.ignite(); + } + else + { + super.handleHealthUpdate(par1); + } + } + + public void ignite() + { + this.minecartTNTFuse = 80; + + if (!this.worldObj.isRemote) + { + this.worldObj.setEntityState(this, (byte)10); + this.worldObj.playSoundAtEntity(this, "game.tnt.primed", 1.0F, 1.0F); + } + } + + @SideOnly(Side.CLIENT) + public int func_94104_d() + { + return this.minecartTNTFuse; + } + + public boolean isIgnited() + { + return this.minecartTNTFuse > -1; + } + + public float func_145772_a(Explosion p_145772_1_, World p_145772_2_, int p_145772_3_, int p_145772_4_, int p_145772_5_, Block p_145772_6_) + { + return this.isIgnited() && (BlockRailBase.func_150051_a(p_145772_6_) || BlockRailBase.func_150049_b_(p_145772_2_, p_145772_3_, p_145772_4_ + 1, p_145772_5_)) ? 0.0F : super.func_145772_a(p_145772_1_, p_145772_2_, p_145772_3_, p_145772_4_, p_145772_5_, p_145772_6_); + } + + public boolean func_145774_a(Explosion p_145774_1_, World p_145774_2_, int p_145774_3_, int p_145774_4_, int p_145774_5_, Block p_145774_6_, float p_145774_7_) + { + return this.isIgnited() && (BlockRailBase.func_150051_a(p_145774_6_) || BlockRailBase.func_150049_b_(p_145774_2_, p_145774_3_, p_145774_4_ + 1, p_145774_5_)) ? false : super.func_145774_a(p_145774_1_, p_145774_2_, p_145774_3_, p_145774_4_, p_145774_5_, p_145774_6_, p_145774_7_); + } + + protected void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + super.readEntityFromNBT(par1NBTTagCompound); + + if (par1NBTTagCompound.hasKey("TNTFuse", 99)) + { + this.minecartTNTFuse = par1NBTTagCompound.getInteger("TNTFuse"); + } + } + + protected void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeEntityToNBT(par1NBTTagCompound); + par1NBTTagCompound.setInteger("TNTFuse", this.minecartTNTFuse); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/item/EntityPainting.java b/src/main/java/net/minecraft/entity/item/EntityPainting.java new file mode 100644 index 0000000..46f5544 --- /dev/null +++ b/src/main/java/net/minecraft/entity/item/EntityPainting.java @@ -0,0 +1,173 @@ +package net.minecraft.entity.item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityHanging; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +public class EntityPainting extends EntityHanging +{ + public EntityPainting.EnumArt art; + private static final String __OBFID = "CL_00001556"; + + public EntityPainting(World par1World) + { + super(par1World); + } + + public EntityPainting(World par1World, int par2, int par3, int par4, int par5) + { + super(par1World, par2, par3, par4, par5); + ArrayList arraylist = new ArrayList(); + EntityPainting.EnumArt[] aenumart = EntityPainting.EnumArt.values(); + int i1 = aenumart.length; + + for (int j1 = 0; j1 < i1; ++j1) + { + EntityPainting.EnumArt enumart = aenumart[j1]; + this.art = enumart; + this.setDirection(par5); + + if (this.onValidSurface()) + { + arraylist.add(enumart); + } + } + + if (!arraylist.isEmpty()) + { + this.art = (EntityPainting.EnumArt)arraylist.get(this.rand.nextInt(arraylist.size())); + } + + this.setDirection(par5); + } + + @SideOnly(Side.CLIENT) + public EntityPainting(World par1World, int par2, int par3, int par4, int par5, String par6Str) + { + this(par1World, par2, par3, par4, par5); + EntityPainting.EnumArt[] aenumart = EntityPainting.EnumArt.values(); + int i1 = aenumart.length; + + for (int j1 = 0; j1 < i1; ++j1) + { + EntityPainting.EnumArt enumart = aenumart[j1]; + + if (enumart.title.equals(par6Str)) + { + this.art = enumart; + break; + } + } + + this.setDirection(par5); + } + + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + par1NBTTagCompound.setString("Motive", this.art.title); + super.writeEntityToNBT(par1NBTTagCompound); + } + + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + String s = par1NBTTagCompound.getString("Motive"); + EntityPainting.EnumArt[] aenumart = EntityPainting.EnumArt.values(); + int i = aenumart.length; + + for (int j = 0; j < i; ++j) + { + EntityPainting.EnumArt enumart = aenumart[j]; + + if (enumart.title.equals(s)) + { + this.art = enumart; + } + } + + if (this.art == null) + { + this.art = EntityPainting.EnumArt.Kebab; + } + + super.readEntityFromNBT(par1NBTTagCompound); + } + + public int getWidthPixels() + { + return this.art.sizeX; + } + + public int getHeightPixels() + { + return this.art.sizeY; + } + + public void onBroken(Entity par1Entity) + { + if (par1Entity instanceof EntityPlayer) + { + EntityPlayer entityplayer = (EntityPlayer)par1Entity; + + if (entityplayer.capabilities.isCreativeMode) + { + return; + } + } + + this.entityDropItem(new ItemStack(Items.painting), 0.0F); + } + + public static enum EnumArt + { + Kebab("Kebab", 16, 16, 0, 0), + Aztec("Aztec", 16, 16, 16, 0), + Alban("Alban", 16, 16, 32, 0), + Aztec2("Aztec2", 16, 16, 48, 0), + Bomb("Bomb", 16, 16, 64, 0), + Plant("Plant", 16, 16, 80, 0), + Wasteland("Wasteland", 16, 16, 96, 0), + Pool("Pool", 32, 16, 0, 32), + Courbet("Courbet", 32, 16, 32, 32), + Sea("Sea", 32, 16, 64, 32), + Sunset("Sunset", 32, 16, 96, 32), + Creebet("Creebet", 32, 16, 128, 32), + Wanderer("Wanderer", 16, 32, 0, 64), + Graham("Graham", 16, 32, 16, 64), + Match("Match", 32, 32, 0, 128), + Bust("Bust", 32, 32, 32, 128), + Stage("Stage", 32, 32, 64, 128), + Void("Void", 32, 32, 96, 128), + SkullAndRoses("SkullAndRoses", 32, 32, 128, 128), + Wither("Wither", 32, 32, 160, 128), + Fighters("Fighters", 64, 32, 0, 96), + Pointer("Pointer", 64, 64, 0, 192), + Pigscene("Pigscene", 64, 64, 64, 192), + BurningSkull("BurningSkull", 64, 64, 128, 192), + Skeleton("Skeleton", 64, 48, 192, 64), + DonkeyKong("DonkeyKong", 64, 48, 192, 112); + public static final int maxArtTitleLength = "SkullAndRoses".length(); + public final String title; + public final int sizeX; + public final int sizeY; + public final int offsetX; + public final int offsetY; + + private static final String __OBFID = "CL_00001557"; + + private EnumArt(String par3Str, int par4, int par5, int par6, int par7) + { + this.title = par3Str; + this.sizeX = par4; + this.sizeY = par5; + this.offsetX = par6; + this.offsetY = par7; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/item/EntityTNTPrimed.java b/src/main/java/net/minecraft/entity/item/EntityTNTPrimed.java new file mode 100644 index 0000000..878ea4a --- /dev/null +++ b/src/main/java/net/minecraft/entity/item/EntityTNTPrimed.java @@ -0,0 +1,110 @@ +package net.minecraft.entity.item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +public class EntityTNTPrimed extends Entity +{ + public int fuse; + private EntityLivingBase tntPlacedBy; + private static final String __OBFID = "CL_00001681"; + + public EntityTNTPrimed(World par1World) + { + super(par1World); + this.preventEntitySpawning = true; + this.setSize(0.98F, 0.98F); + this.yOffset = this.height / 2.0F; + } + + public EntityTNTPrimed(World par1World, double par2, double par4, double par6, EntityLivingBase par8EntityLivingBase) + { + this(par1World); + this.setPosition(par2, par4, par6); + float f = (float)(Math.random() * Math.PI * 2.0D); + this.motionX = (double)(-((float)Math.sin((double)f)) * 0.02F); + this.motionY = 0.20000000298023224D; + this.motionZ = (double)(-((float)Math.cos((double)f)) * 0.02F); + this.fuse = 80; + this.prevPosX = par2; + this.prevPosY = par4; + this.prevPosZ = par6; + this.tntPlacedBy = par8EntityLivingBase; + } + + protected void entityInit() {} + + protected boolean canTriggerWalking() + { + return false; + } + + public boolean canBeCollidedWith() + { + return !this.isDead; + } + + public void onUpdate() + { + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + this.motionY -= 0.03999999910593033D; + this.moveEntity(this.motionX, this.motionY, this.motionZ); + this.motionX *= 0.9800000190734863D; + this.motionY *= 0.9800000190734863D; + this.motionZ *= 0.9800000190734863D; + + if (this.onGround) + { + this.motionX *= 0.699999988079071D; + this.motionZ *= 0.699999988079071D; + this.motionY *= -0.5D; + } + + if (this.fuse-- <= 0) + { + this.setDead(); + + if (!this.worldObj.isRemote) + { + this.explode(); + } + } + else + { + this.worldObj.spawnParticle("smoke", this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D); + } + } + + private void explode() + { + float f = 4.0F; + this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, f, true); + } + + protected void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + par1NBTTagCompound.setByte("Fuse", (byte)this.fuse); + } + + protected void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + this.fuse = par1NBTTagCompound.getByte("Fuse"); + } + + @SideOnly(Side.CLIENT) + public float getShadowSize() + { + return 0.0F; + } + + public EntityLivingBase getTntPlacedBy() + { + return this.tntPlacedBy; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/item/EntityXPOrb.java b/src/main/java/net/minecraft/entity/item/EntityXPOrb.java new file mode 100644 index 0000000..79ac49e --- /dev/null +++ b/src/main/java/net/minecraft/entity/item/EntityXPOrb.java @@ -0,0 +1,239 @@ +package net.minecraft.entity.item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.player.PlayerPickupXpEvent; + +public class EntityXPOrb extends Entity +{ + public int xpColor; + public int xpOrbAge; + public int field_70532_c; + private int xpOrbHealth = 5; + public int xpValue; + private EntityPlayer closestPlayer; + private int xpTargetColor; + private static final String __OBFID = "CL_00001544"; + + public EntityXPOrb(World par1World, double par2, double par4, double par6, int par8) + { + super(par1World); + this.setSize(0.5F, 0.5F); + this.yOffset = this.height / 2.0F; + this.setPosition(par2, par4, par6); + this.rotationYaw = (float)(Math.random() * 360.0D); + this.motionX = (double)((float)(Math.random() * 0.20000000298023224D - 0.10000000149011612D) * 2.0F); + this.motionY = (double)((float)(Math.random() * 0.2D) * 2.0F); + this.motionZ = (double)((float)(Math.random() * 0.20000000298023224D - 0.10000000149011612D) * 2.0F); + this.xpValue = par8; + } + + protected boolean canTriggerWalking() + { + return false; + } + + public EntityXPOrb(World par1World) + { + super(par1World); + this.setSize(0.25F, 0.25F); + this.yOffset = this.height / 2.0F; + } + + protected void entityInit() {} + + @SideOnly(Side.CLIENT) + public int getBrightnessForRender(float par1) + { + float f1 = 0.5F; + + if (f1 < 0.0F) + { + f1 = 0.0F; + } + + if (f1 > 1.0F) + { + f1 = 1.0F; + } + + int i = super.getBrightnessForRender(par1); + int j = i & 255; + int k = i >> 16 & 255; + j += (int)(f1 * 15.0F * 16.0F); + + if (j > 240) + { + j = 240; + } + + return j | k << 16; + } + + public void onUpdate() + { + super.onUpdate(); + + if (this.field_70532_c > 0) + { + --this.field_70532_c; + } + + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + this.motionY -= 0.029999999329447746D; + + if (this.worldObj.getBlock(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)).getMaterial() == Material.lava) + { + this.motionY = 0.20000000298023224D; + this.motionX = (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F); + this.motionZ = (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F); + this.playSound("random.fizz", 0.4F, 2.0F + this.rand.nextFloat() * 0.4F); + } + + this.func_145771_j(this.posX, (this.boundingBox.minY + this.boundingBox.maxY) / 2.0D, this.posZ); + double d0 = 8.0D; + + if (this.xpTargetColor < this.xpColor - 20 + this.getEntityId() % 100) + { + if (this.closestPlayer == null || this.closestPlayer.getDistanceSqToEntity(this) > d0 * d0) + { + this.closestPlayer = this.worldObj.getClosestPlayerToEntity(this, d0); + } + + this.xpTargetColor = this.xpColor; + } + + if (this.closestPlayer != null) + { + double d1 = (this.closestPlayer.posX - this.posX) / d0; + double d2 = (this.closestPlayer.posY + (double)this.closestPlayer.getEyeHeight() - this.posY) / d0; + double d3 = (this.closestPlayer.posZ - this.posZ) / d0; + double d4 = Math.sqrt(d1 * d1 + d2 * d2 + d3 * d3); + double d5 = 1.0D - d4; + + if (d5 > 0.0D) + { + d5 *= d5; + this.motionX += d1 / d4 * d5 * 0.1D; + this.motionY += d2 / d4 * d5 * 0.1D; + this.motionZ += d3 / d4 * d5 * 0.1D; + } + } + + this.moveEntity(this.motionX, this.motionY, this.motionZ); + float f = 0.98F; + + if (this.onGround) + { + f = this.worldObj.getBlock(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.boundingBox.minY) - 1, MathHelper.floor_double(this.posZ)).slipperiness * 0.98F; + } + + this.motionX *= (double)f; + this.motionY *= 0.9800000190734863D; + this.motionZ *= (double)f; + + if (this.onGround) + { + this.motionY *= -0.8999999761581421D; + } + + ++this.xpColor; + ++this.xpOrbAge; + + if (this.xpOrbAge >= 6000) + { + this.setDead(); + } + } + + public boolean handleWaterMovement() + { + return this.worldObj.handleMaterialAcceleration(this.boundingBox, Material.water, this); + } + + protected void dealFireDamage(int par1) + { + this.attackEntityFrom(DamageSource.inFire, (float)par1); + } + + public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) + { + if (this.isEntityInvulnerable()) + { + return false; + } + else + { + this.setBeenAttacked(); + this.xpOrbHealth = (int)((float)this.xpOrbHealth - par2); + + if (this.xpOrbHealth <= 0) + { + this.setDead(); + } + + return false; + } + } + + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + par1NBTTagCompound.setShort("Health", (short)((byte)this.xpOrbHealth)); + par1NBTTagCompound.setShort("Age", (short)this.xpOrbAge); + par1NBTTagCompound.setShort("Value", (short)this.xpValue); + } + + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + this.xpOrbHealth = par1NBTTagCompound.getShort("Health") & 255; + this.xpOrbAge = par1NBTTagCompound.getShort("Age"); + this.xpValue = par1NBTTagCompound.getShort("Value"); + } + + public void onCollideWithPlayer(EntityPlayer par1EntityPlayer) + { + if (!this.worldObj.isRemote) + { + if (this.field_70532_c == 0 && par1EntityPlayer.xpCooldown == 0) + { + if (MinecraftForge.EVENT_BUS.post(new PlayerPickupXpEvent(par1EntityPlayer, this))) return; + par1EntityPlayer.xpCooldown = 2; + this.worldObj.playSoundAtEntity(par1EntityPlayer, "random.orb", 0.1F, 0.5F * ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.8F)); + par1EntityPlayer.onItemPickup(this, 1); + par1EntityPlayer.addExperience(this.xpValue); + this.setDead(); + } + } + } + + public int getXpValue() + { + return this.xpValue; + } + + @SideOnly(Side.CLIENT) + public int getTextureByXP() + { + return this.xpValue >= 2477 ? 10 : (this.xpValue >= 1237 ? 9 : (this.xpValue >= 617 ? 8 : (this.xpValue >= 307 ? 7 : (this.xpValue >= 149 ? 6 : (this.xpValue >= 73 ? 5 : (this.xpValue >= 37 ? 4 : (this.xpValue >= 17 ? 3 : (this.xpValue >= 7 ? 2 : (this.xpValue >= 3 ? 1 : 0))))))))); + } + + public static int getXPSplit(int par0) + { + return par0 >= 2477 ? 2477 : (par0 >= 1237 ? 1237 : (par0 >= 617 ? 617 : (par0 >= 307 ? 307 : (par0 >= 149 ? 149 : (par0 >= 73 ? 73 : (par0 >= 37 ? 37 : (par0 >= 17 ? 17 : (par0 >= 7 ? 7 : (par0 >= 3 ? 3 : 1))))))))); + } + + public boolean canAttackWithItem() + { + return false; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/monster/EntityBlaze.java b/src/main/java/net/minecraft/entity/monster/EntityBlaze.java new file mode 100644 index 0000000..ffda021 --- /dev/null +++ b/src/main/java/net/minecraft/entity/monster/EntityBlaze.java @@ -0,0 +1,210 @@ +package net.minecraft.entity.monster; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.projectile.EntitySmallFireball; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class EntityBlaze extends EntityMob +{ + private float heightOffset = 0.5F; + private int heightOffsetUpdateTime; + private int field_70846_g; + private static final String __OBFID = "CL_00001682"; + + public EntityBlaze(World par1World) + { + super(par1World); + this.isImmuneToFire = true; + this.experienceValue = 10; + } + + protected void applyEntityAttributes() + { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(6.0D); + } + + protected void entityInit() + { + super.entityInit(); + this.dataWatcher.addObject(16, new Byte((byte)0)); + } + + protected String getLivingSound() + { + return "mob.blaze.breathe"; + } + + protected String getHurtSound() + { + return "mob.blaze.hit"; + } + + protected String getDeathSound() + { + return "mob.blaze.death"; + } + + @SideOnly(Side.CLIENT) + public int getBrightnessForRender(float par1) + { + return 15728880; + } + + public float getBrightness(float par1) + { + return 1.0F; + } + + public void onLivingUpdate() + { + if (!this.worldObj.isRemote) + { + if (this.isWet()) + { + this.attackEntityFrom(DamageSource.drown, 1.0F); + } + + --this.heightOffsetUpdateTime; + + if (this.heightOffsetUpdateTime <= 0) + { + this.heightOffsetUpdateTime = 100; + this.heightOffset = 0.5F + (float)this.rand.nextGaussian() * 3.0F; + } + + if (this.getEntityToAttack() != null && this.getEntityToAttack().posY + (double)this.getEntityToAttack().getEyeHeight() > this.posY + (double)this.getEyeHeight() + (double)this.heightOffset) + { + this.motionY += (0.30000001192092896D - this.motionY) * 0.30000001192092896D; + } + } + + if (this.rand.nextInt(24) == 0) + { + this.worldObj.playSoundEffect(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D, "fire.fire", 1.0F + this.rand.nextFloat(), this.rand.nextFloat() * 0.7F + 0.3F); + } + + if (!this.onGround && this.motionY < 0.0D) + { + this.motionY *= 0.6D; + } + + for (int i = 0; i < 2; ++i) + { + this.worldObj.spawnParticle("largesmoke", this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, this.posY + this.rand.nextDouble() * (double)this.height, this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, 0.0D, 0.0D, 0.0D); + } + + super.onLivingUpdate(); + } + + protected void attackEntity(Entity par1Entity, float par2) + { + if (this.attackTime <= 0 && par2 < 2.0F && par1Entity.boundingBox.maxY > this.boundingBox.minY && par1Entity.boundingBox.minY < this.boundingBox.maxY) + { + this.attackTime = 20; + this.attackEntityAsMob(par1Entity); + } + else if (par2 < 30.0F) + { + double d0 = par1Entity.posX - this.posX; + double d1 = par1Entity.boundingBox.minY + (double)(par1Entity.height / 2.0F) - (this.posY + (double)(this.height / 2.0F)); + double d2 = par1Entity.posZ - this.posZ; + + if (this.attackTime == 0) + { + ++this.field_70846_g; + + if (this.field_70846_g == 1) + { + this.attackTime = 60; + this.func_70844_e(true); + } + else if (this.field_70846_g <= 4) + { + this.attackTime = 6; + } + else + { + this.attackTime = 100; + this.field_70846_g = 0; + this.func_70844_e(false); + } + + if (this.field_70846_g > 1) + { + float f1 = MathHelper.sqrt_float(par2) * 0.5F; + this.worldObj.playAuxSFXAtEntity((EntityPlayer)null, 1009, (int)this.posX, (int)this.posY, (int)this.posZ, 0); + + for (int i = 0; i < 1; ++i) + { + EntitySmallFireball entitysmallfireball = new EntitySmallFireball(this.worldObj, this, d0 + this.rand.nextGaussian() * (double)f1, d1, d2 + this.rand.nextGaussian() * (double)f1); + entitysmallfireball.posY = this.posY + (double)(this.height / 2.0F) + 0.5D; + this.worldObj.spawnEntityInWorld(entitysmallfireball); + } + } + } + + this.rotationYaw = (float)(Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F; + this.hasAttacked = true; + } + } + + protected void fall(float par1) {} + + protected Item getDropItem() + { + return Items.blaze_rod; + } + + public boolean isBurning() + { + return this.func_70845_n(); + } + + protected void dropFewItems(boolean par1, int par2) + { + if (par1) + { + int j = this.rand.nextInt(2 + par2); + + for (int k = 0; k < j; ++k) + { + this.dropItem(Items.blaze_rod, 1); + } + } + } + + public boolean func_70845_n() + { + return (this.dataWatcher.getWatchableObjectByte(16) & 1) != 0; + } + + public void func_70844_e(boolean par1) + { + byte b0 = this.dataWatcher.getWatchableObjectByte(16); + + if (par1) + { + b0 = (byte)(b0 | 1); + } + else + { + b0 &= -2; + } + + this.dataWatcher.updateObject(16, Byte.valueOf(b0)); + } + + protected boolean isValidLightLevel() + { + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/monster/EntityCaveSpider.java b/src/main/java/net/minecraft/entity/monster/EntityCaveSpider.java new file mode 100644 index 0000000..f1f0e7d --- /dev/null +++ b/src/main/java/net/minecraft/entity/monster/EntityCaveSpider.java @@ -0,0 +1,63 @@ +package net.minecraft.entity.monster; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.world.EnumDifficulty; +import net.minecraft.world.World; + +public class EntityCaveSpider extends EntitySpider +{ + private static final String __OBFID = "CL_00001683"; + + public EntityCaveSpider(World par1World) + { + super(par1World); + this.setSize(0.7F, 0.5F); + } + + protected void applyEntityAttributes() + { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(12.0D); + } + + public boolean attackEntityAsMob(Entity par1Entity) + { + if (super.attackEntityAsMob(par1Entity)) + { + if (par1Entity instanceof EntityLivingBase) + { + byte b0 = 0; + + if (this.worldObj.difficultySetting == EnumDifficulty.NORMAL) + { + b0 = 7; + } + else if (this.worldObj.difficultySetting == EnumDifficulty.HARD) + { + b0 = 15; + } + + if (b0 > 0) + { + ((EntityLivingBase)par1Entity).addPotionEffect(new PotionEffect(Potion.poison.id, b0 * 20, 0)); + } + } + + return true; + } + else + { + return false; + } + } + + public IEntityLivingData onSpawnWithEgg(IEntityLivingData par1EntityLivingData) + { + return par1EntityLivingData; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/monster/EntityCreeper.java b/src/main/java/net/minecraft/entity/monster/EntityCreeper.java new file mode 100644 index 0000000..8b8bbe3 --- /dev/null +++ b/src/main/java/net/minecraft/entity/monster/EntityCreeper.java @@ -0,0 +1,261 @@ +package net.minecraft.entity.monster; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.EntityAIAttackOnCollide; +import net.minecraft.entity.ai.EntityAIAvoidEntity; +import net.minecraft.entity.ai.EntityAICreeperSwell; +import net.minecraft.entity.ai.EntityAIHurtByTarget; +import net.minecraft.entity.ai.EntityAILookIdle; +import net.minecraft.entity.ai.EntityAINearestAttackableTarget; +import net.minecraft.entity.ai.EntityAISwimming; +import net.minecraft.entity.ai.EntityAIWander; +import net.minecraft.entity.ai.EntityAIWatchClosest; +import net.minecraft.entity.effect.EntityLightningBolt; +import net.minecraft.entity.passive.EntityOcelot; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.DamageSource; +import net.minecraft.world.World; + +public class EntityCreeper extends EntityMob +{ + private int lastActiveTime; + private int timeSinceIgnited; + private int fuseTime = 30; + private int explosionRadius = 3; + private static final String __OBFID = "CL_00001684"; + + public EntityCreeper(World par1World) + { + super(par1World); + this.tasks.addTask(1, new EntityAISwimming(this)); + this.tasks.addTask(2, new EntityAICreeperSwell(this)); + this.tasks.addTask(3, new EntityAIAvoidEntity(this, EntityOcelot.class, 6.0F, 1.0D, 1.2D)); + this.tasks.addTask(4, new EntityAIAttackOnCollide(this, 1.0D, false)); + this.tasks.addTask(5, new EntityAIWander(this, 0.8D)); + this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); + this.tasks.addTask(6, new EntityAILookIdle(this)); + this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true)); + this.targetTasks.addTask(2, new EntityAIHurtByTarget(this, false)); + } + + protected void applyEntityAttributes() + { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.25D); + } + + public boolean isAIEnabled() + { + return true; + } + + public int getMaxSafePointTries() + { + return this.getAttackTarget() == null ? 3 : 3 + (int)(this.getHealth() - 1.0F); + } + + protected void fall(float par1) + { + super.fall(par1); + this.timeSinceIgnited = (int)((float)this.timeSinceIgnited + par1 * 1.5F); + + if (this.timeSinceIgnited > this.fuseTime - 5) + { + this.timeSinceIgnited = this.fuseTime - 5; + } + } + + protected void entityInit() + { + super.entityInit(); + this.dataWatcher.addObject(16, Byte.valueOf((byte) - 1)); + this.dataWatcher.addObject(17, Byte.valueOf((byte)0)); + this.dataWatcher.addObject(18, Byte.valueOf((byte)0)); + } + + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeEntityToNBT(par1NBTTagCompound); + + if (this.dataWatcher.getWatchableObjectByte(17) == 1) + { + par1NBTTagCompound.setBoolean("powered", true); + } + + par1NBTTagCompound.setShort("Fuse", (short)this.fuseTime); + par1NBTTagCompound.setByte("ExplosionRadius", (byte)this.explosionRadius); + par1NBTTagCompound.setBoolean("ignited", this.func_146078_ca()); + } + + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + super.readEntityFromNBT(par1NBTTagCompound); + this.dataWatcher.updateObject(17, Byte.valueOf((byte)(par1NBTTagCompound.getBoolean("powered") ? 1 : 0))); + + if (par1NBTTagCompound.hasKey("Fuse", 99)) + { + this.fuseTime = par1NBTTagCompound.getShort("Fuse"); + } + + if (par1NBTTagCompound.hasKey("ExplosionRadius", 99)) + { + this.explosionRadius = par1NBTTagCompound.getByte("ExplosionRadius"); + } + + if (par1NBTTagCompound.getBoolean("ignited")) + { + this.func_146079_cb(); + } + } + + public void onUpdate() + { + if (this.isEntityAlive()) + { + this.lastActiveTime = this.timeSinceIgnited; + + if (this.func_146078_ca()) + { + this.setCreeperState(1); + } + + int i = this.getCreeperState(); + + if (i > 0 && this.timeSinceIgnited == 0) + { + this.playSound("creeper.primed", 1.0F, 0.5F); + } + + this.timeSinceIgnited += i; + + if (this.timeSinceIgnited < 0) + { + this.timeSinceIgnited = 0; + } + + if (this.timeSinceIgnited >= this.fuseTime) + { + this.timeSinceIgnited = this.fuseTime; + this.func_146077_cc(); + } + } + + super.onUpdate(); + } + + protected String getHurtSound() + { + return "mob.creeper.say"; + } + + protected String getDeathSound() + { + return "mob.creeper.death"; + } + + public void onDeath(DamageSource par1DamageSource) + { + super.onDeath(par1DamageSource); + + if (par1DamageSource.getEntity() instanceof EntitySkeleton) + { + int i = Item.getIdFromItem(Items.record_13); + int j = Item.getIdFromItem(Items.record_wait); + int k = i + this.rand.nextInt(j - i + 1); + this.dropItem(Item.getItemById(k), 1); + } + } + + public boolean attackEntityAsMob(Entity par1Entity) + { + return true; + } + + public boolean getPowered() + { + return this.dataWatcher.getWatchableObjectByte(17) == 1; + } + + @SideOnly(Side.CLIENT) + public float getCreeperFlashIntensity(float par1) + { + return ((float)this.lastActiveTime + (float)(this.timeSinceIgnited - this.lastActiveTime) * par1) / (float)(this.fuseTime - 2); + } + + protected Item getDropItem() + { + return Items.gunpowder; + } + + public int getCreeperState() + { + return this.dataWatcher.getWatchableObjectByte(16); + } + + public void setCreeperState(int par1) + { + this.dataWatcher.updateObject(16, Byte.valueOf((byte)par1)); + } + + public void onStruckByLightning(EntityLightningBolt par1EntityLightningBolt) + { + super.onStruckByLightning(par1EntityLightningBolt); + this.dataWatcher.updateObject(17, Byte.valueOf((byte)1)); + } + + protected boolean interact(EntityPlayer par1EntityPlayer) + { + ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem(); + + if (itemstack != null && itemstack.getItem() == Items.flint_and_steel) + { + this.worldObj.playSoundEffect(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D, "fire.ignite", 1.0F, this.rand.nextFloat() * 0.4F + 0.8F); + par1EntityPlayer.swingItem(); + + if (!this.worldObj.isRemote) + { + this.func_146079_cb(); + itemstack.damageItem(1, par1EntityPlayer); + return true; + } + } + + return super.interact(par1EntityPlayer); + } + + private void func_146077_cc() + { + if (!this.worldObj.isRemote) + { + boolean flag = this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing"); + + if (this.getPowered()) + { + this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, (float)(this.explosionRadius * 2), flag); + } + else + { + this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, (float)this.explosionRadius, flag); + } + + this.setDead(); + } + } + + public boolean func_146078_ca() + { + return this.dataWatcher.getWatchableObjectByte(18) != 0; + } + + public void func_146079_cb() + { + this.dataWatcher.updateObject(18, Byte.valueOf((byte)1)); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/monster/EntityEnderman.java b/src/main/java/net/minecraft/entity/monster/EntityEnderman.java new file mode 100644 index 0000000..6a62ce6 --- /dev/null +++ b/src/main/java/net/minecraft/entity/monster/EntityEnderman.java @@ -0,0 +1,481 @@ +package net.minecraft.entity.monster; + +import java.util.IdentityHashMap; +import java.util.UUID; +import com.google.common.collect.Maps; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.attributes.AttributeModifier; +import net.minecraft.entity.ai.attributes.IAttributeInstance; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.DamageSource; +import net.minecraft.util.EntityDamageSource; +import net.minecraft.util.EntityDamageSourceIndirect; +import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.living.EnderTeleportEvent; + +public class EntityEnderman extends EntityMob +{ + private static final UUID attackingSpeedBoostModifierUUID = UUID.fromString("020E0DFB-87AE-4653-9556-831010E291A0"); + private static final AttributeModifier attackingSpeedBoostModifier = (new AttributeModifier(attackingSpeedBoostModifierUUID, "Attacking speed boost", 6.199999809265137D, 0)).setSaved(false); + @Deprecated //DO NOT TOUCH THIS EVER + private static boolean[] carriableBlocks = new boolean[256]; + private int teleportDelay; + private int stareTimer; + private Entity lastEntityToAttack; + private boolean isAggressive; + private static final String __OBFID = "CL_00001685"; + + public EntityEnderman(World par1World) + { + super(par1World); + this.setSize(0.6F, 2.9F); + this.stepHeight = 1.0F; + } + + protected void applyEntityAttributes() + { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(40.0D); + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.30000001192092896D); + this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(7.0D); + } + + protected void entityInit() + { + super.entityInit(); + this.dataWatcher.addObject(16, new Byte((byte)0)); + this.dataWatcher.addObject(17, new Byte((byte)0)); + this.dataWatcher.addObject(18, new Byte((byte)0)); + } + + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeEntityToNBT(par1NBTTagCompound); + par1NBTTagCompound.setShort("carried", (short)Block.getIdFromBlock(this.func_146080_bZ())); + par1NBTTagCompound.setShort("carriedData", (short)this.getCarryingData()); + } + + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + super.readEntityFromNBT(par1NBTTagCompound); + this.func_146081_a(Block.getBlockById(par1NBTTagCompound.getShort("carried"))); + this.setCarryingData(par1NBTTagCompound.getShort("carriedData")); + } + + protected Entity findPlayerToAttack() + { + EntityPlayer entityplayer = this.worldObj.getClosestVulnerablePlayerToEntity(this, 64.0D); + + if (entityplayer != null) + { + if (this.shouldAttackPlayer(entityplayer)) + { + this.isAggressive = true; + + if (this.stareTimer == 0) + { + this.worldObj.playSoundEffect(entityplayer.posX, entityplayer.posY, entityplayer.posZ, "mob.endermen.stare", 1.0F, 1.0F); + } + + if (this.stareTimer++ == 5) + { + this.stareTimer = 0; + this.setScreaming(true); + return entityplayer; + } + } + else + { + this.stareTimer = 0; + } + } + + return null; + } + + private boolean shouldAttackPlayer(EntityPlayer par1EntityPlayer) + { + ItemStack itemstack = par1EntityPlayer.inventory.armorInventory[3]; + + if (itemstack != null && itemstack.getItem() == Item.getItemFromBlock(Blocks.pumpkin)) + { + return false; + } + else + { + Vec3 vec3 = par1EntityPlayer.getLook(1.0F).normalize(); + Vec3 vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX - par1EntityPlayer.posX, this.boundingBox.minY + (double)(this.height / 2.0F) - (par1EntityPlayer.posY + (double)par1EntityPlayer.getEyeHeight()), this.posZ - par1EntityPlayer.posZ); + double d0 = vec31.lengthVector(); + vec31 = vec31.normalize(); + double d1 = vec3.dotProduct(vec31); + return d1 > 1.0D - 0.025D / d0 ? par1EntityPlayer.canEntityBeSeen(this) : false; + } + } + + public void onLivingUpdate() + { + if (this.isWet()) + { + this.attackEntityFrom(DamageSource.drown, 1.0F); + } + + if (this.lastEntityToAttack != this.entityToAttack) + { + IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed); + iattributeinstance.removeModifier(attackingSpeedBoostModifier); + + if (this.entityToAttack != null) + { + iattributeinstance.applyModifier(attackingSpeedBoostModifier); + } + } + + this.lastEntityToAttack = this.entityToAttack; + int k; + + if (!this.worldObj.isRemote && this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing")) + { + int i; + int j; + Block block; + + if (this.func_146080_bZ().getMaterial() == Material.air) + { + if (this.rand.nextInt(20) == 0) + { + k = MathHelper.floor_double(this.posX - 2.0D + this.rand.nextDouble() * 4.0D); + i = MathHelper.floor_double(this.posY + this.rand.nextDouble() * 3.0D); + j = MathHelper.floor_double(this.posZ - 2.0D + this.rand.nextDouble() * 4.0D); + block = this.worldObj.getBlock(k, i, j); + + if (EntityEnderman.getCarriable(block)) + { + this.func_146081_a(block); + this.setCarryingData(this.worldObj.getBlockMetadata(k, i, j)); + this.worldObj.setBlock(k, i, j, Blocks.air); + } + } + } + else if (this.rand.nextInt(2000) == 0) + { + k = MathHelper.floor_double(this.posX - 1.0D + this.rand.nextDouble() * 2.0D); + i = MathHelper.floor_double(this.posY + this.rand.nextDouble() * 2.0D); + j = MathHelper.floor_double(this.posZ - 1.0D + this.rand.nextDouble() * 2.0D); + block = this.worldObj.getBlock(k, i, j); + Block block1 = this.worldObj.getBlock(k, i - 1, j); + + if (block.getMaterial() == Material.air && block1.getMaterial() != Material.air && block1.renderAsNormalBlock()) + { + this.worldObj.setBlock(k, i, j, this.func_146080_bZ(), this.getCarryingData(), 3); + this.func_146081_a(Blocks.air); + } + } + } + + for (k = 0; k < 2; ++k) + { + this.worldObj.spawnParticle("portal", this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, this.posY + this.rand.nextDouble() * (double)this.height - 0.25D, this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, (this.rand.nextDouble() - 0.5D) * 2.0D, -this.rand.nextDouble(), (this.rand.nextDouble() - 0.5D) * 2.0D); + } + + if (this.worldObj.isDaytime() && !this.worldObj.isRemote) + { + float f = this.getBrightness(1.0F); + + if (f > 0.5F && this.worldObj.canBlockSeeTheSky(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)) && this.rand.nextFloat() * 30.0F < (f - 0.4F) * 2.0F) + { + this.entityToAttack = null; + this.setScreaming(false); + this.isAggressive = false; + this.teleportRandomly(); + } + } + + if (this.isWet() || this.isBurning()) + { + this.entityToAttack = null; + this.setScreaming(false); + this.isAggressive = false; + this.teleportRandomly(); + } + + if (this.isScreaming() && !this.isAggressive && this.rand.nextInt(100) == 0) + { + this.setScreaming(false); + } + + this.isJumping = false; + + if (this.entityToAttack != null) + { + this.faceEntity(this.entityToAttack, 100.0F, 100.0F); + } + + if (!this.worldObj.isRemote && this.isEntityAlive()) + { + if (this.entityToAttack != null) + { + if (this.entityToAttack instanceof EntityPlayer && this.shouldAttackPlayer((EntityPlayer)this.entityToAttack)) + { + if (this.entityToAttack.getDistanceSqToEntity(this) < 16.0D) + { + this.teleportRandomly(); + } + + this.teleportDelay = 0; + } + else if (this.entityToAttack.getDistanceSqToEntity(this) > 256.0D && this.teleportDelay++ >= 30 && this.teleportToEntity(this.entityToAttack)) + { + this.teleportDelay = 0; + } + } + else + { + this.setScreaming(false); + this.teleportDelay = 0; + } + } + + super.onLivingUpdate(); + } + + protected boolean teleportRandomly() + { + double d0 = this.posX + (this.rand.nextDouble() - 0.5D) * 64.0D; + double d1 = this.posY + (double)(this.rand.nextInt(64) - 32); + double d2 = this.posZ + (this.rand.nextDouble() - 0.5D) * 64.0D; + return this.teleportTo(d0, d1, d2); + } + + protected boolean teleportToEntity(Entity par1Entity) + { + Vec3 vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX - par1Entity.posX, this.boundingBox.minY + (double)(this.height / 2.0F) - par1Entity.posY + (double)par1Entity.getEyeHeight(), this.posZ - par1Entity.posZ); + vec3 = vec3.normalize(); + double d0 = 16.0D; + double d1 = this.posX + (this.rand.nextDouble() - 0.5D) * 8.0D - vec3.xCoord * d0; + double d2 = this.posY + (double)(this.rand.nextInt(16) - 8) - vec3.yCoord * d0; + double d3 = this.posZ + (this.rand.nextDouble() - 0.5D) * 8.0D - vec3.zCoord * d0; + return this.teleportTo(d1, d2, d3); + } + + protected boolean teleportTo(double par1, double par3, double par5) + { + EnderTeleportEvent event = new EnderTeleportEvent(this, par1, par3, par5, 0); + if (MinecraftForge.EVENT_BUS.post(event)){ + return false; + } + double d3 = this.posX; + double d4 = this.posY; + double d5 = this.posZ; + this.posX = event.targetX; + this.posY = event.targetY; + this.posZ = event.targetZ; + boolean flag = false; + int i = MathHelper.floor_double(this.posX); + int j = MathHelper.floor_double(this.posY); + int k = MathHelper.floor_double(this.posZ); + + if (this.worldObj.blockExists(i, j, k)) + { + boolean flag1 = false; + + while (!flag1 && j > 0) + { + Block block = this.worldObj.getBlock(i, j - 1, k); + + if (block.getMaterial().blocksMovement()) + { + flag1 = true; + } + else + { + --this.posY; + --j; + } + } + + if (flag1) + { + this.setPosition(this.posX, this.posY, this.posZ); + + if (this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox).isEmpty() && !this.worldObj.isAnyLiquid(this.boundingBox)) + { + flag = true; + } + } + } + + if (!flag) + { + this.setPosition(d3, d4, d5); + return false; + } + else + { + short short1 = 128; + + for (int l = 0; l < short1; ++l) + { + double d6 = (double)l / ((double)short1 - 1.0D); + float f = (this.rand.nextFloat() - 0.5F) * 0.2F; + float f1 = (this.rand.nextFloat() - 0.5F) * 0.2F; + float f2 = (this.rand.nextFloat() - 0.5F) * 0.2F; + double d7 = d3 + (this.posX - d3) * d6 + (this.rand.nextDouble() - 0.5D) * (double)this.width * 2.0D; + double d8 = d4 + (this.posY - d4) * d6 + this.rand.nextDouble() * (double)this.height; + double d9 = d5 + (this.posZ - d5) * d6 + (this.rand.nextDouble() - 0.5D) * (double)this.width * 2.0D; + this.worldObj.spawnParticle("portal", d7, d8, d9, (double)f, (double)f1, (double)f2); + } + + this.worldObj.playSoundEffect(d3, d4, d5, "mob.endermen.portal", 1.0F, 1.0F); + this.playSound("mob.endermen.portal", 1.0F, 1.0F); + return true; + } + } + + protected String getLivingSound() + { + return this.isScreaming() ? "mob.endermen.scream" : "mob.endermen.idle"; + } + + protected String getHurtSound() + { + return "mob.endermen.hit"; + } + + protected String getDeathSound() + { + return "mob.endermen.death"; + } + + protected Item getDropItem() + { + return Items.ender_pearl; + } + + protected void dropFewItems(boolean par1, int par2) + { + Item item = this.getDropItem(); + + if (item != null) + { + int j = this.rand.nextInt(2 + par2); + + for (int k = 0; k < j; ++k) + { + this.dropItem(item, 1); + } + } + } + + public void func_146081_a(Block p_146081_1_) + { + this.dataWatcher.updateObject(16, Byte.valueOf((byte)(Block.getIdFromBlock(p_146081_1_) & 255))); + } + + public Block func_146080_bZ() + { + return Block.getBlockById(this.dataWatcher.getWatchableObjectByte(16)); + } + + public void setCarryingData(int par1) + { + this.dataWatcher.updateObject(17, Byte.valueOf((byte)(par1 & 255))); + } + + public int getCarryingData() + { + return this.dataWatcher.getWatchableObjectByte(17); + } + + public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) + { + if (this.isEntityInvulnerable()) + { + return false; + } + else + { + this.setScreaming(true); + + if (par1DamageSource instanceof EntityDamageSource && par1DamageSource.getEntity() instanceof EntityPlayer) + { + this.isAggressive = true; + } + + if (par1DamageSource instanceof EntityDamageSourceIndirect) + { + this.isAggressive = false; + + for (int i = 0; i < 64; ++i) + { + if (this.teleportRandomly()) + { + return true; + } + } + + return super.attackEntityFrom(par1DamageSource, par2); + } + else + { + return super.attackEntityFrom(par1DamageSource, par2); + } + } + } + + public boolean isScreaming() + { + return this.dataWatcher.getWatchableObjectByte(18) > 0; + } + + public void setScreaming(boolean par1) + { + this.dataWatcher.updateObject(18, Byte.valueOf((byte)(par1 ? 1 : 0))); + } + + static + { + carriableBlocks[Block.getIdFromBlock(Blocks.grass)] = true; + carriableBlocks[Block.getIdFromBlock(Blocks.dirt)] = true; + carriableBlocks[Block.getIdFromBlock(Blocks.sand)] = true; + carriableBlocks[Block.getIdFromBlock(Blocks.gravel)] = true; + carriableBlocks[Block.getIdFromBlock(Blocks.yellow_flower)] = true; + carriableBlocks[Block.getIdFromBlock(Blocks.red_flower)] = true; + carriableBlocks[Block.getIdFromBlock(Blocks.brown_mushroom)] = true; + carriableBlocks[Block.getIdFromBlock(Blocks.red_mushroom)] = true; + carriableBlocks[Block.getIdFromBlock(Blocks.tnt)] = true; + carriableBlocks[Block.getIdFromBlock(Blocks.cactus)] = true; + carriableBlocks[Block.getIdFromBlock(Blocks.clay)] = true; + carriableBlocks[Block.getIdFromBlock(Blocks.pumpkin)] = true; + carriableBlocks[Block.getIdFromBlock(Blocks.melon_block)] = true; + carriableBlocks[Block.getIdFromBlock(Blocks.mycelium)] = true; + for (int x = 0; x < carriableBlocks.length; x++) + { + if (carriableBlocks[x]) setCarriable(Block.getBlockById(x), true); + } + } + + /*===================================== Forge Start ==============================*/ + private static IdentityHashMap carriable; + public static void setCarriable(Block block, boolean canCarry) + { + if (carriable == null) carriable = new IdentityHashMap(4096); + carriable.put(block, canCarry); + } + public static boolean getCarriable(Block block) + { + Boolean ret = carriable.get(block); + return ret != null ? ret : false; + } + /*===================================== Forge End ==============================*/ +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/monster/EntityGhast.java b/src/main/java/net/minecraft/entity/monster/EntityGhast.java new file mode 100644 index 0000000..9d92a56 --- /dev/null +++ b/src/main/java/net/minecraft/entity/monster/EntityGhast.java @@ -0,0 +1,280 @@ +package net.minecraft.entity.monster; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityFlying; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.projectile.EntityLargeFireball; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.stats.AchievementList; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; +import net.minecraft.world.EnumDifficulty; +import net.minecraft.world.World; + +public class EntityGhast extends EntityFlying implements IMob +{ + public int courseChangeCooldown; + public double waypointX; + public double waypointY; + public double waypointZ; + private Entity targetedEntity; + private int aggroCooldown; + public int prevAttackCounter; + public int attackCounter; + private int explosionStrength = 1; + private static final String __OBFID = "CL_00001689"; + + public EntityGhast(World par1World) + { + super(par1World); + this.setSize(4.0F, 4.0F); + this.isImmuneToFire = true; + this.experienceValue = 5; + } + + @SideOnly(Side.CLIENT) + public boolean func_110182_bF() + { + return this.dataWatcher.getWatchableObjectByte(16) != 0; + } + + public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) + { + if (this.isEntityInvulnerable()) + { + return false; + } + else if ("fireball".equals(par1DamageSource.getDamageType()) && par1DamageSource.getEntity() instanceof EntityPlayer) + { + super.attackEntityFrom(par1DamageSource, 1000.0F); + ((EntityPlayer)par1DamageSource.getEntity()).triggerAchievement(AchievementList.ghast); + return true; + } + else + { + return super.attackEntityFrom(par1DamageSource, par2); + } + } + + protected void entityInit() + { + super.entityInit(); + this.dataWatcher.addObject(16, Byte.valueOf((byte)0)); + } + + protected void applyEntityAttributes() + { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(10.0D); + } + + protected void updateEntityActionState() + { + if (!this.worldObj.isRemote && this.worldObj.difficultySetting == EnumDifficulty.PEACEFUL) + { + this.setDead(); + } + + this.despawnEntity(); + this.prevAttackCounter = this.attackCounter; + double d0 = this.waypointX - this.posX; + double d1 = this.waypointY - this.posY; + double d2 = this.waypointZ - this.posZ; + double d3 = d0 * d0 + d1 * d1 + d2 * d2; + + if (d3 < 1.0D || d3 > 3600.0D) + { + this.waypointX = this.posX + (double)((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F); + this.waypointY = this.posY + (double)((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F); + this.waypointZ = this.posZ + (double)((this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F); + } + + if (this.courseChangeCooldown-- <= 0) + { + this.courseChangeCooldown += this.rand.nextInt(5) + 2; + d3 = (double)MathHelper.sqrt_double(d3); + + if (this.isCourseTraversable(this.waypointX, this.waypointY, this.waypointZ, d3)) + { + this.motionX += d0 / d3 * 0.1D; + this.motionY += d1 / d3 * 0.1D; + this.motionZ += d2 / d3 * 0.1D; + } + else + { + this.waypointX = this.posX; + this.waypointY = this.posY; + this.waypointZ = this.posZ; + } + } + + if (this.targetedEntity != null && this.targetedEntity.isDead) + { + this.targetedEntity = null; + } + + if (this.targetedEntity == null || this.aggroCooldown-- <= 0) + { + this.targetedEntity = this.worldObj.getClosestVulnerablePlayerToEntity(this, 100.0D); + + if (this.targetedEntity != null) + { + this.aggroCooldown = 20; + } + } + + double d4 = 64.0D; + + if (this.targetedEntity != null && this.targetedEntity.getDistanceSqToEntity(this) < d4 * d4) + { + double d5 = this.targetedEntity.posX - this.posX; + double d6 = this.targetedEntity.boundingBox.minY + (double)(this.targetedEntity.height / 2.0F) - (this.posY + (double)(this.height / 2.0F)); + double d7 = this.targetedEntity.posZ - this.posZ; + this.renderYawOffset = this.rotationYaw = -((float)Math.atan2(d5, d7)) * 180.0F / (float)Math.PI; + + if (this.canEntityBeSeen(this.targetedEntity)) + { + if (this.attackCounter == 10) + { + this.worldObj.playAuxSFXAtEntity((EntityPlayer)null, 1007, (int)this.posX, (int)this.posY, (int)this.posZ, 0); + } + + ++this.attackCounter; + + if (this.attackCounter == 20) + { + this.worldObj.playAuxSFXAtEntity((EntityPlayer)null, 1008, (int)this.posX, (int)this.posY, (int)this.posZ, 0); + EntityLargeFireball entitylargefireball = new EntityLargeFireball(this.worldObj, this, d5, d6, d7); + entitylargefireball.field_92057_e = this.explosionStrength; + double d8 = 4.0D; + Vec3 vec3 = this.getLook(1.0F); + entitylargefireball.posX = this.posX + vec3.xCoord * d8; + entitylargefireball.posY = this.posY + (double)(this.height / 2.0F) + 0.5D; + entitylargefireball.posZ = this.posZ + vec3.zCoord * d8; + this.worldObj.spawnEntityInWorld(entitylargefireball); + this.attackCounter = -40; + } + } + else if (this.attackCounter > 0) + { + --this.attackCounter; + } + } + else + { + this.renderYawOffset = this.rotationYaw = -((float)Math.atan2(this.motionX, this.motionZ)) * 180.0F / (float)Math.PI; + + if (this.attackCounter > 0) + { + --this.attackCounter; + } + } + + if (!this.worldObj.isRemote) + { + byte b1 = this.dataWatcher.getWatchableObjectByte(16); + byte b0 = (byte)(this.attackCounter > 10 ? 1 : 0); + + if (b1 != b0) + { + this.dataWatcher.updateObject(16, Byte.valueOf(b0)); + } + } + } + + private boolean isCourseTraversable(double par1, double par3, double par5, double par7) + { + double d4 = (this.waypointX - this.posX) / par7; + double d5 = (this.waypointY - this.posY) / par7; + double d6 = (this.waypointZ - this.posZ) / par7; + AxisAlignedBB axisalignedbb = this.boundingBox.copy(); + + for (int i = 1; (double)i < par7; ++i) + { + axisalignedbb.offset(d4, d5, d6); + + if (!this.worldObj.getCollidingBoundingBoxes(this, axisalignedbb).isEmpty()) + { + return false; + } + } + + return true; + } + + protected String getLivingSound() + { + return "mob.ghast.moan"; + } + + protected String getHurtSound() + { + return "mob.ghast.scream"; + } + + protected String getDeathSound() + { + return "mob.ghast.death"; + } + + protected Item getDropItem() + { + return Items.gunpowder; + } + + protected void dropFewItems(boolean par1, int par2) + { + int j = this.rand.nextInt(2) + this.rand.nextInt(1 + par2); + int k; + + for (k = 0; k < j; ++k) + { + this.dropItem(Items.ghast_tear, 1); + } + + j = this.rand.nextInt(3) + this.rand.nextInt(1 + par2); + + for (k = 0; k < j; ++k) + { + this.dropItem(Items.gunpowder, 1); + } + } + + protected float getSoundVolume() + { + return 10.0F; + } + + public boolean getCanSpawnHere() + { + return this.rand.nextInt(20) == 0 && super.getCanSpawnHere() && this.worldObj.difficultySetting != EnumDifficulty.PEACEFUL; + } + + public int getMaxSpawnedInChunk() + { + return 1; + } + + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeEntityToNBT(par1NBTTagCompound); + par1NBTTagCompound.setInteger("ExplosionPower", this.explosionStrength); + } + + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + super.readEntityFromNBT(par1NBTTagCompound); + + if (par1NBTTagCompound.hasKey("ExplosionPower", 99)) + { + this.explosionStrength = par1NBTTagCompound.getInteger("ExplosionPower"); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/monster/EntityGiantZombie.java b/src/main/java/net/minecraft/entity/monster/EntityGiantZombie.java new file mode 100644 index 0000000..3150c0e --- /dev/null +++ b/src/main/java/net/minecraft/entity/monster/EntityGiantZombie.java @@ -0,0 +1,29 @@ +package net.minecraft.entity.monster; + +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.world.World; + +public class EntityGiantZombie extends EntityMob +{ + private static final String __OBFID = "CL_00001690"; + + public EntityGiantZombie(World par1World) + { + super(par1World); + this.yOffset *= 6.0F; + this.setSize(this.width * 6.0F, this.height * 6.0F); + } + + protected void applyEntityAttributes() + { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(100.0D); + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.5D); + this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(50.0D); + } + + public float getBlockPathWeight(int par1, int par2, int par3) + { + return this.worldObj.getLightBrightness(par1, par2, par3) - 0.5F; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/monster/EntityGolem.java b/src/main/java/net/minecraft/entity/monster/EntityGolem.java new file mode 100644 index 0000000..5af4ee7 --- /dev/null +++ b/src/main/java/net/minecraft/entity/monster/EntityGolem.java @@ -0,0 +1,42 @@ +package net.minecraft.entity.monster; + +import net.minecraft.entity.EntityCreature; +import net.minecraft.entity.passive.IAnimals; +import net.minecraft.world.World; + +public abstract class EntityGolem extends EntityCreature implements IAnimals +{ + private static final String __OBFID = "CL_00001644"; + + public EntityGolem(World par1World) + { + super(par1World); + } + + protected void fall(float par1) {} + + protected String getLivingSound() + { + return "none"; + } + + protected String getHurtSound() + { + return "none"; + } + + protected String getDeathSound() + { + return "none"; + } + + public int getTalkInterval() + { + return 120; + } + + protected boolean canDespawn() + { + return false; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/monster/EntityIronGolem.java b/src/main/java/net/minecraft/entity/monster/EntityIronGolem.java new file mode 100644 index 0000000..da8c7dd --- /dev/null +++ b/src/main/java/net/minecraft/entity/monster/EntityIronGolem.java @@ -0,0 +1,274 @@ +package net.minecraft.entity.monster; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.EntityAIAttackOnCollide; +import net.minecraft.entity.ai.EntityAIDefendVillage; +import net.minecraft.entity.ai.EntityAIHurtByTarget; +import net.minecraft.entity.ai.EntityAILookAtVillager; +import net.minecraft.entity.ai.EntityAILookIdle; +import net.minecraft.entity.ai.EntityAIMoveThroughVillage; +import net.minecraft.entity.ai.EntityAIMoveTowardsRestriction; +import net.minecraft.entity.ai.EntityAIMoveTowardsTarget; +import net.minecraft.entity.ai.EntityAINearestAttackableTarget; +import net.minecraft.entity.ai.EntityAIWander; +import net.minecraft.entity.ai.EntityAIWatchClosest; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.village.Village; +import net.minecraft.world.World; + +public class EntityIronGolem extends EntityGolem +{ + private int homeCheckTimer; + Village villageObj; + private int attackTimer; + private int holdRoseTick; + private static final String __OBFID = "CL_00001652"; + + public EntityIronGolem(World par1World) + { + super(par1World); + this.setSize(1.4F, 2.9F); + this.getNavigator().setAvoidsWater(true); + this.tasks.addTask(1, new EntityAIAttackOnCollide(this, 1.0D, true)); + this.tasks.addTask(2, new EntityAIMoveTowardsTarget(this, 0.9D, 32.0F)); + this.tasks.addTask(3, new EntityAIMoveThroughVillage(this, 0.6D, true)); + this.tasks.addTask(4, new EntityAIMoveTowardsRestriction(this, 1.0D)); + this.tasks.addTask(5, new EntityAILookAtVillager(this)); + this.tasks.addTask(6, new EntityAIWander(this, 0.6D)); + this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F)); + this.tasks.addTask(8, new EntityAILookIdle(this)); + this.targetTasks.addTask(1, new EntityAIDefendVillage(this)); + this.targetTasks.addTask(2, new EntityAIHurtByTarget(this, false)); + this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityLiving.class, 0, false, true, IMob.mobSelector)); + } + + protected void entityInit() + { + super.entityInit(); + this.dataWatcher.addObject(16, Byte.valueOf((byte)0)); + } + + public boolean isAIEnabled() + { + return true; + } + + protected void updateAITick() + { + if (--this.homeCheckTimer <= 0) + { + this.homeCheckTimer = 70 + this.rand.nextInt(50); + this.villageObj = this.worldObj.villageCollectionObj.findNearestVillage(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ), 32); + + if (this.villageObj == null) + { + this.detachHome(); + } + else + { + ChunkCoordinates chunkcoordinates = this.villageObj.getCenter(); + this.setHomeArea(chunkcoordinates.posX, chunkcoordinates.posY, chunkcoordinates.posZ, (int)((float)this.villageObj.getVillageRadius() * 0.6F)); + } + } + + super.updateAITick(); + } + + protected void applyEntityAttributes() + { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(100.0D); + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.25D); + } + + protected int decreaseAirSupply(int par1) + { + return par1; + } + + protected void collideWithEntity(Entity par1Entity) + { + if (par1Entity instanceof IMob && this.getRNG().nextInt(20) == 0) + { + this.setAttackTarget((EntityLivingBase)par1Entity); + } + + super.collideWithEntity(par1Entity); + } + + public void onLivingUpdate() + { + super.onLivingUpdate(); + + if (this.attackTimer > 0) + { + --this.attackTimer; + } + + if (this.holdRoseTick > 0) + { + --this.holdRoseTick; + } + + if (this.motionX * this.motionX + this.motionZ * this.motionZ > 2.500000277905201E-7D && this.rand.nextInt(5) == 0) + { + int i = MathHelper.floor_double(this.posX); + int j = MathHelper.floor_double(this.posY - 0.20000000298023224D - (double)this.yOffset); + int k = MathHelper.floor_double(this.posZ); + Block block = this.worldObj.getBlock(i, j, k); + + if (block.getMaterial() != Material.air) + { + this.worldObj.spawnParticle("blockcrack_" + Block.getIdFromBlock(block) + "_" + this.worldObj.getBlockMetadata(i, j, k), this.posX + ((double)this.rand.nextFloat() - 0.5D) * (double)this.width, this.boundingBox.minY + 0.1D, this.posZ + ((double)this.rand.nextFloat() - 0.5D) * (double)this.width, 4.0D * ((double)this.rand.nextFloat() - 0.5D), 0.5D, ((double)this.rand.nextFloat() - 0.5D) * 4.0D); + } + } + } + + public boolean canAttackClass(Class par1Class) + { + return this.isPlayerCreated() && EntityPlayer.class.isAssignableFrom(par1Class) ? false : super.canAttackClass(par1Class); + } + + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeEntityToNBT(par1NBTTagCompound); + par1NBTTagCompound.setBoolean("PlayerCreated", this.isPlayerCreated()); + } + + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + super.readEntityFromNBT(par1NBTTagCompound); + this.setPlayerCreated(par1NBTTagCompound.getBoolean("PlayerCreated")); + } + + public boolean attackEntityAsMob(Entity par1Entity) + { + this.attackTimer = 10; + this.worldObj.setEntityState(this, (byte)4); + boolean flag = par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float)(7 + this.rand.nextInt(15))); + + if (flag) + { + par1Entity.motionY += 0.4000000059604645D; + } + + this.playSound("mob.irongolem.throw", 1.0F, 1.0F); + return flag; + } + + @SideOnly(Side.CLIENT) + public void handleHealthUpdate(byte par1) + { + if (par1 == 4) + { + this.attackTimer = 10; + this.playSound("mob.irongolem.throw", 1.0F, 1.0F); + } + else if (par1 == 11) + { + this.holdRoseTick = 400; + } + else + { + super.handleHealthUpdate(par1); + } + } + + public Village getVillage() + { + return this.villageObj; + } + + @SideOnly(Side.CLIENT) + public int getAttackTimer() + { + return this.attackTimer; + } + + public void setHoldingRose(boolean par1) + { + this.holdRoseTick = par1 ? 400 : 0; + this.worldObj.setEntityState(this, (byte)11); + } + + protected String getHurtSound() + { + return "mob.irongolem.hit"; + } + + protected String getDeathSound() + { + return "mob.irongolem.death"; + } + + protected void func_145780_a(int p_145780_1_, int p_145780_2_, int p_145780_3_, Block p_145780_4_) + { + this.playSound("mob.irongolem.walk", 1.0F, 1.0F); + } + + protected void dropFewItems(boolean par1, int par2) + { + int j = this.rand.nextInt(3); + int k; + + for (k = 0; k < j; ++k) + { + this.func_145778_a(Item.getItemFromBlock(Blocks.red_flower), 1, 0.0F); + } + + k = 3 + this.rand.nextInt(3); + + for (int l = 0; l < k; ++l) + { + this.dropItem(Items.iron_ingot, 1); + } + } + + public int getHoldRoseTick() + { + return this.holdRoseTick; + } + + public boolean isPlayerCreated() + { + return (this.dataWatcher.getWatchableObjectByte(16) & 1) != 0; + } + + public void setPlayerCreated(boolean par1) + { + byte b0 = this.dataWatcher.getWatchableObjectByte(16); + + if (par1) + { + this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 | 1))); + } + else + { + this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 & -2))); + } + } + + public void onDeath(DamageSource par1DamageSource) + { + if (!this.isPlayerCreated() && this.attackingPlayer != null && this.villageObj != null) + { + this.villageObj.setReputationForPlayer(this.attackingPlayer.getCommandSenderName(), -5); + } + + super.onDeath(par1DamageSource); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/monster/EntityMagmaCube.java b/src/main/java/net/minecraft/entity/monster/EntityMagmaCube.java new file mode 100644 index 0000000..e2f0ea4 --- /dev/null +++ b/src/main/java/net/minecraft/entity/monster/EntityMagmaCube.java @@ -0,0 +1,130 @@ +package net.minecraft.entity.monster; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.world.EnumDifficulty; +import net.minecraft.world.World; + +public class EntityMagmaCube extends EntitySlime +{ + private static final String __OBFID = "CL_00001691"; + + public EntityMagmaCube(World par1World) + { + super(par1World); + this.isImmuneToFire = true; + } + + protected void applyEntityAttributes() + { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.20000000298023224D); + } + + public boolean getCanSpawnHere() + { + return this.worldObj.difficultySetting != EnumDifficulty.PEACEFUL && this.worldObj.checkNoEntityCollision(this.boundingBox) && this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox).isEmpty() && !this.worldObj.isAnyLiquid(this.boundingBox); + } + + public int getTotalArmorValue() + { + return this.getSlimeSize() * 3; + } + + @SideOnly(Side.CLIENT) + public int getBrightnessForRender(float par1) + { + return 15728880; + } + + public float getBrightness(float par1) + { + return 1.0F; + } + + protected String getSlimeParticle() + { + return "flame"; + } + + protected EntitySlime createInstance() + { + return new EntityMagmaCube(this.worldObj); + } + + protected Item getDropItem() + { + return Items.magma_cream; + } + + protected void dropFewItems(boolean par1, int par2) + { + Item item = this.getDropItem(); + + if (item != null && this.getSlimeSize() > 1) + { + int j = this.rand.nextInt(4) - 2; + + if (par2 > 0) + { + j += this.rand.nextInt(par2 + 1); + } + + for (int k = 0; k < j; ++k) + { + this.dropItem(item, 1); + } + } + } + + public boolean isBurning() + { + return false; + } + + protected int getJumpDelay() + { + return super.getJumpDelay() * 4; + } + + protected void alterSquishAmount() + { + this.squishAmount *= 0.9F; + } + + protected void jump() + { + this.motionY = (double)(0.42F + (float)this.getSlimeSize() * 0.1F); + this.isAirBorne = true; + } + + protected void fall(float par1) {} + + protected boolean canDamagePlayer() + { + return true; + } + + protected int getAttackStrength() + { + return super.getAttackStrength() + 2; + } + + protected String getJumpSound() + { + return this.getSlimeSize() > 1 ? "mob.magmacube.big" : "mob.magmacube.small"; + } + + public boolean handleLavaMovement() + { + return false; + } + + protected boolean makesSoundOnLand() + { + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/monster/EntityMob.java b/src/main/java/net/minecraft/entity/monster/EntityMob.java new file mode 100644 index 0000000..ab0b7ad --- /dev/null +++ b/src/main/java/net/minecraft/entity/monster/EntityMob.java @@ -0,0 +1,204 @@ +package net.minecraft.entity.monster; + +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityCreature; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.world.EnumDifficulty; +import net.minecraft.world.EnumSkyBlock; +import net.minecraft.world.World; + +public abstract class EntityMob extends EntityCreature implements IMob +{ + private static final String __OBFID = "CL_00001692"; + + public EntityMob(World par1World) + { + super(par1World); + this.experienceValue = 5; + } + + public void onLivingUpdate() + { + this.updateArmSwingProgress(); + float f = this.getBrightness(1.0F); + + if (f > 0.5F) + { + this.entityAge += 2; + } + + super.onLivingUpdate(); + } + + public void onUpdate() + { + super.onUpdate(); + + if (!this.worldObj.isRemote && this.worldObj.difficultySetting == EnumDifficulty.PEACEFUL) + { + this.setDead(); + } + } + + protected String getSwimSound() + { + return "game.hostile.swim"; + } + + protected String getSplashSound() + { + return "game.hostile.swim.splash"; + } + + protected Entity findPlayerToAttack() + { + EntityPlayer entityplayer = this.worldObj.getClosestVulnerablePlayerToEntity(this, 16.0D); + return entityplayer != null && this.canEntityBeSeen(entityplayer) ? entityplayer : null; + } + + public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) + { + if (this.isEntityInvulnerable()) + { + return false; + } + else if (super.attackEntityFrom(par1DamageSource, par2)) + { + Entity entity = par1DamageSource.getEntity(); + + if (this.riddenByEntity != entity && this.ridingEntity != entity) + { + if (entity != this) + { + this.entityToAttack = entity; + } + + return true; + } + else + { + return true; + } + } + else + { + return false; + } + } + + protected String getHurtSound() + { + return "game.hostile.hurt"; + } + + protected String getDeathSound() + { + return "game.hostile.die"; + } + + protected String func_146067_o(int p_146067_1_) + { + return p_146067_1_ > 4 ? "game.hostile.hurt.fall.big" : "game.hostile.hurt.fall.small"; + } + + public boolean attackEntityAsMob(Entity par1Entity) + { + float f = (float)this.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue(); + int i = 0; + + if (par1Entity instanceof EntityLivingBase) + { + f += EnchantmentHelper.getEnchantmentModifierLiving(this, (EntityLivingBase)par1Entity); + i += EnchantmentHelper.getKnockbackModifier(this, (EntityLivingBase)par1Entity); + } + + boolean flag = par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), f); + + if (flag) + { + if (i > 0) + { + par1Entity.addVelocity((double)(-MathHelper.sin(this.rotationYaw * (float)Math.PI / 180.0F) * (float)i * 0.5F), 0.1D, (double)(MathHelper.cos(this.rotationYaw * (float)Math.PI / 180.0F) * (float)i * 0.5F)); + this.motionX *= 0.6D; + this.motionZ *= 0.6D; + } + + int j = EnchantmentHelper.getFireAspectModifier(this); + + if (j > 0) + { + par1Entity.setFire(j * 4); + } + + if (par1Entity instanceof EntityLivingBase) + { + EnchantmentHelper.func_151384_a((EntityLivingBase)par1Entity, this); + } + + EnchantmentHelper.func_151385_b(this, par1Entity); + } + + return flag; + } + + protected void attackEntity(Entity par1Entity, float par2) + { + if (this.attackTime <= 0 && par2 < 2.0F && par1Entity.boundingBox.maxY > this.boundingBox.minY && par1Entity.boundingBox.minY < this.boundingBox.maxY) + { + this.attackTime = 20; + this.attackEntityAsMob(par1Entity); + } + } + + public float getBlockPathWeight(int par1, int par2, int par3) + { + return 0.5F - this.worldObj.getLightBrightness(par1, par2, par3); + } + + protected boolean isValidLightLevel() + { + int i = MathHelper.floor_double(this.posX); + int j = MathHelper.floor_double(this.boundingBox.minY); + int k = MathHelper.floor_double(this.posZ); + + if (this.worldObj.getSavedLightValue(EnumSkyBlock.Sky, i, j, k) > this.rand.nextInt(32)) + { + return false; + } + else + { + int l = this.worldObj.getBlockLightValue(i, j, k); + + if (this.worldObj.isThundering()) + { + int i1 = this.worldObj.skylightSubtracted; + this.worldObj.skylightSubtracted = 10; + l = this.worldObj.getBlockLightValue(i, j, k); + this.worldObj.skylightSubtracted = i1; + } + + return l <= this.rand.nextInt(8); + } + } + + public boolean getCanSpawnHere() + { + return this.worldObj.difficultySetting != EnumDifficulty.PEACEFUL && this.isValidLightLevel() && super.getCanSpawnHere(); + } + + protected void applyEntityAttributes() + { + super.applyEntityAttributes(); + this.getAttributeMap().registerAttribute(SharedMonsterAttributes.attackDamage); + } + + protected boolean func_146066_aG() + { + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/monster/EntityPigZombie.java b/src/main/java/net/minecraft/entity/monster/EntityPigZombie.java new file mode 100644 index 0000000..8a0ee42 --- /dev/null +++ b/src/main/java/net/minecraft/entity/monster/EntityPigZombie.java @@ -0,0 +1,184 @@ +package net.minecraft.entity.monster; + +import java.util.List; +import java.util.UUID; +import net.minecraft.entity.Entity; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.attributes.AttributeModifier; +import net.minecraft.entity.ai.attributes.IAttributeInstance; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.DamageSource; +import net.minecraft.world.EnumDifficulty; +import net.minecraft.world.World; + +public class EntityPigZombie extends EntityZombie +{ + private static final UUID field_110189_bq = UUID.fromString("49455A49-7EC5-45BA-B886-3B90B23A1718"); + private static final AttributeModifier field_110190_br = (new AttributeModifier(field_110189_bq, "Attacking speed boost", 0.45D, 0)).setSaved(false); + private int angerLevel; + private int randomSoundDelay; + private Entity field_110191_bu; + private static final String __OBFID = "CL_00001693"; + + public EntityPigZombie(World par1World) + { + super(par1World); + this.isImmuneToFire = true; + } + + protected void applyEntityAttributes() + { + super.applyEntityAttributes(); + this.getEntityAttribute(field_110186_bp).setBaseValue(0.0D); + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.5D); + this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(5.0D); + } + + protected boolean isAIEnabled() + { + return false; + } + + public void onUpdate() + { + if (this.field_110191_bu != this.entityToAttack && !this.worldObj.isRemote) + { + IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed); + iattributeinstance.removeModifier(field_110190_br); + + if (this.entityToAttack != null) + { + iattributeinstance.applyModifier(field_110190_br); + } + } + + this.field_110191_bu = this.entityToAttack; + + if (this.randomSoundDelay > 0 && --this.randomSoundDelay == 0) + { + this.playSound("mob.zombiepig.zpigangry", this.getSoundVolume() * 2.0F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F) * 1.8F); + } + + super.onUpdate(); + } + + public boolean getCanSpawnHere() + { + return this.worldObj.difficultySetting != EnumDifficulty.PEACEFUL && this.worldObj.checkNoEntityCollision(this.boundingBox) && this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox).isEmpty() && !this.worldObj.isAnyLiquid(this.boundingBox); + } + + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeEntityToNBT(par1NBTTagCompound); + par1NBTTagCompound.setShort("Anger", (short)this.angerLevel); + } + + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + super.readEntityFromNBT(par1NBTTagCompound); + this.angerLevel = par1NBTTagCompound.getShort("Anger"); + } + + protected Entity findPlayerToAttack() + { + return this.angerLevel == 0 ? null : super.findPlayerToAttack(); + } + + public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) + { + if (this.isEntityInvulnerable()) + { + return false; + } + else + { + Entity entity = par1DamageSource.getEntity(); + + if (entity instanceof EntityPlayer) + { + List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.expand(32.0D, 32.0D, 32.0D)); + + for (int i = 0; i < list.size(); ++i) + { + Entity entity1 = (Entity)list.get(i); + + if (entity1 instanceof EntityPigZombie) + { + EntityPigZombie entitypigzombie = (EntityPigZombie)entity1; + entitypigzombie.becomeAngryAt(entity); + } + } + + this.becomeAngryAt(entity); + } + + return super.attackEntityFrom(par1DamageSource, par2); + } + } + + private void becomeAngryAt(Entity par1Entity) + { + this.entityToAttack = par1Entity; + this.angerLevel = 400 + this.rand.nextInt(400); + this.randomSoundDelay = this.rand.nextInt(40); + } + + protected String getLivingSound() + { + return "mob.zombiepig.zpig"; + } + + protected String getHurtSound() + { + return "mob.zombiepig.zpighurt"; + } + + protected String getDeathSound() + { + return "mob.zombiepig.zpigdeath"; + } + + protected void dropFewItems(boolean par1, int par2) + { + int j = this.rand.nextInt(2 + par2); + int k; + + for (k = 0; k < j; ++k) + { + this.dropItem(Items.rotten_flesh, 1); + } + + j = this.rand.nextInt(2 + par2); + + for (k = 0; k < j; ++k) + { + this.dropItem(Items.gold_nugget, 1); + } + } + + public boolean interact(EntityPlayer par1EntityPlayer) + { + return false; + } + + protected void dropRareDrop(int par1) + { + this.dropItem(Items.gold_ingot, 1); + } + + protected void addRandomArmor() + { + this.setCurrentItemOrArmor(0, new ItemStack(Items.golden_sword)); + } + + public IEntityLivingData onSpawnWithEgg(IEntityLivingData par1EntityLivingData) + { + super.onSpawnWithEgg(par1EntityLivingData); + this.setVillager(false); + return par1EntityLivingData; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/monster/EntitySilverfish.java b/src/main/java/net/minecraft/entity/monster/EntitySilverfish.java new file mode 100644 index 0000000..75fea9f --- /dev/null +++ b/src/main/java/net/minecraft/entity/monster/EntitySilverfish.java @@ -0,0 +1,214 @@ +package net.minecraft.entity.monster; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockSilverfish; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EnumCreatureAttribute; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.util.DamageSource; +import net.minecraft.util.EntityDamageSource; +import net.minecraft.util.Facing; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import org.apache.commons.lang3.tuple.ImmutablePair; + +public class EntitySilverfish extends EntityMob +{ + private int allySummonCooldown; + private static final String __OBFID = "CL_00001696"; + + public EntitySilverfish(World par1World) + { + super(par1World); + this.setSize(0.3F, 0.7F); + } + + protected void applyEntityAttributes() + { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(8.0D); + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.6000000238418579D); + this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(1.0D); + } + + protected boolean canTriggerWalking() + { + return false; + } + + protected Entity findPlayerToAttack() + { + double d0 = 8.0D; + return this.worldObj.getClosestVulnerablePlayerToEntity(this, d0); + } + + protected String getLivingSound() + { + return "mob.silverfish.say"; + } + + protected String getHurtSound() + { + return "mob.silverfish.hit"; + } + + protected String getDeathSound() + { + return "mob.silverfish.kill"; + } + + public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) + { + if (this.isEntityInvulnerable()) + { + return false; + } + else + { + if (this.allySummonCooldown <= 0 && (par1DamageSource instanceof EntityDamageSource || par1DamageSource == DamageSource.magic)) + { + this.allySummonCooldown = 20; + } + + return super.attackEntityFrom(par1DamageSource, par2); + } + } + + protected void attackEntity(Entity par1Entity, float par2) + { + if (this.attackTime <= 0 && par2 < 1.2F && par1Entity.boundingBox.maxY > this.boundingBox.minY && par1Entity.boundingBox.minY < this.boundingBox.maxY) + { + this.attackTime = 20; + this.attackEntityAsMob(par1Entity); + } + } + + protected void func_145780_a(int p_145780_1_, int p_145780_2_, int p_145780_3_, Block p_145780_4_) + { + this.playSound("mob.silverfish.step", 0.15F, 1.0F); + } + + protected Item getDropItem() + { + return Item.getItemById(0); + } + + public void onUpdate() + { + this.renderYawOffset = this.rotationYaw; + super.onUpdate(); + } + + protected void updateEntityActionState() + { + super.updateEntityActionState(); + + if (!this.worldObj.isRemote) + { + int i; + int j; + int k; + int i1; + + if (this.allySummonCooldown > 0) + { + --this.allySummonCooldown; + + if (this.allySummonCooldown == 0) + { + i = MathHelper.floor_double(this.posX); + j = MathHelper.floor_double(this.posY); + k = MathHelper.floor_double(this.posZ); + boolean flag = false; + + for (int l = 0; !flag && l <= 5 && l >= -5; l = l <= 0 ? 1 - l : 0 - l) + { + for (i1 = 0; !flag && i1 <= 10 && i1 >= -10; i1 = i1 <= 0 ? 1 - i1 : 0 - i1) + { + for (int j1 = 0; !flag && j1 <= 10 && j1 >= -10; j1 = j1 <= 0 ? 1 - j1 : 0 - j1) + { + if (this.worldObj.getBlock(i + i1, j + l, k + j1) == Blocks.monster_egg) + { + if (!this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing")) + { + int k1 = this.worldObj.getBlockMetadata(i + i1, j + l, k + j1); + ImmutablePair immutablepair = BlockSilverfish.func_150197_b(k1); + this.worldObj.setBlock(i + i1, j + l, k + j1, (Block)immutablepair.getLeft(), ((Integer)immutablepair.getRight()).intValue(), 3); + } + else + { + this.worldObj.func_147480_a(i + i1, j + l, k + j1, false); + } + + Blocks.monster_egg.onBlockDestroyedByPlayer(this.worldObj, i + i1, j + l, k + j1, 0); + + if (this.rand.nextBoolean()) + { + flag = true; + break; + } + } + } + } + } + } + } + + if (this.entityToAttack == null && !this.hasPath()) + { + i = MathHelper.floor_double(this.posX); + j = MathHelper.floor_double(this.posY + 0.5D); + k = MathHelper.floor_double(this.posZ); + int l1 = this.rand.nextInt(6); + Block block = this.worldObj.getBlock(i + Facing.offsetsXForSide[l1], j + Facing.offsetsYForSide[l1], k + Facing.offsetsZForSide[l1]); + i1 = this.worldObj.getBlockMetadata(i + Facing.offsetsXForSide[l1], j + Facing.offsetsYForSide[l1], k + Facing.offsetsZForSide[l1]); + + if (BlockSilverfish.func_150196_a(block)) + { + this.worldObj.setBlock(i + Facing.offsetsXForSide[l1], j + Facing.offsetsYForSide[l1], k + Facing.offsetsZForSide[l1], Blocks.monster_egg, BlockSilverfish.func_150195_a(block, i1), 3); + this.spawnExplosionParticle(); + this.setDead(); + } + else + { + this.updateWanderPath(); + } + } + else if (this.entityToAttack != null && !this.hasPath()) + { + this.entityToAttack = null; + } + } + } + + public float getBlockPathWeight(int par1, int par2, int par3) + { + return this.worldObj.getBlock(par1, par2 - 1, par3) == Blocks.stone ? 10.0F : super.getBlockPathWeight(par1, par2, par3); + } + + protected boolean isValidLightLevel() + { + return true; + } + + public boolean getCanSpawnHere() + { + if (super.getCanSpawnHere()) + { + EntityPlayer entityplayer = this.worldObj.getClosestPlayerToEntity(this, 5.0D); + return entityplayer == null; + } + else + { + return false; + } + } + + public EnumCreatureAttribute getCreatureAttribute() + { + return EnumCreatureAttribute.ARTHROPOD; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/monster/EntitySkeleton.java b/src/main/java/net/minecraft/entity/monster/EntitySkeleton.java new file mode 100644 index 0000000..965e8dd --- /dev/null +++ b/src/main/java/net/minecraft/entity/monster/EntitySkeleton.java @@ -0,0 +1,372 @@ +package net.minecraft.entity.monster; + +import java.util.Calendar; +import net.minecraft.block.Block; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityCreature; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.EnumCreatureAttribute; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.entity.IRangedAttackMob; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.EntityAIArrowAttack; +import net.minecraft.entity.ai.EntityAIAttackOnCollide; +import net.minecraft.entity.ai.EntityAIFleeSun; +import net.minecraft.entity.ai.EntityAIHurtByTarget; +import net.minecraft.entity.ai.EntityAILookIdle; +import net.minecraft.entity.ai.EntityAINearestAttackableTarget; +import net.minecraft.entity.ai.EntityAIRestrictSun; +import net.minecraft.entity.ai.EntityAISwimming; +import net.minecraft.entity.ai.EntityAIWander; +import net.minecraft.entity.ai.EntityAIWatchClosest; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.stats.AchievementList; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraft.world.WorldProviderHell; + +public class EntitySkeleton extends EntityMob implements IRangedAttackMob +{ + private EntityAIArrowAttack aiArrowAttack = new EntityAIArrowAttack(this, 1.0D, 20, 60, 15.0F); + private EntityAIAttackOnCollide aiAttackOnCollide = new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.2D, false); + private static final String __OBFID = "CL_00001697"; + + public EntitySkeleton(World par1World) + { + super(par1World); + this.tasks.addTask(1, new EntityAISwimming(this)); + this.tasks.addTask(2, new EntityAIRestrictSun(this)); + this.tasks.addTask(3, new EntityAIFleeSun(this, 1.0D)); + this.tasks.addTask(5, new EntityAIWander(this, 1.0D)); + this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); + this.tasks.addTask(6, new EntityAILookIdle(this)); + this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false)); + this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true)); + + if (par1World != null && !par1World.isRemote) + { + this.setCombatTask(); + } + } + + protected void applyEntityAttributes() + { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.25D); + } + + protected void entityInit() + { + super.entityInit(); + this.dataWatcher.addObject(13, new Byte((byte)0)); + } + + public boolean isAIEnabled() + { + return true; + } + + protected String getLivingSound() + { + return "mob.skeleton.say"; + } + + protected String getHurtSound() + { + return "mob.skeleton.hurt"; + } + + protected String getDeathSound() + { + return "mob.skeleton.death"; + } + + protected void func_145780_a(int p_145780_1_, int p_145780_2_, int p_145780_3_, Block p_145780_4_) + { + this.playSound("mob.skeleton.step", 0.15F, 1.0F); + } + + public boolean attackEntityAsMob(Entity par1Entity) + { + if (super.attackEntityAsMob(par1Entity)) + { + if (this.getSkeletonType() == 1 && par1Entity instanceof EntityLivingBase) + { + ((EntityLivingBase)par1Entity).addPotionEffect(new PotionEffect(Potion.wither.id, 200)); + } + + return true; + } + else + { + return false; + } + } + + public EnumCreatureAttribute getCreatureAttribute() + { + return EnumCreatureAttribute.UNDEAD; + } + + public void onLivingUpdate() + { + if (this.worldObj.isDaytime() && !this.worldObj.isRemote) + { + float f = this.getBrightness(1.0F); + + if (f > 0.5F && this.rand.nextFloat() * 30.0F < (f - 0.4F) * 2.0F && this.worldObj.canBlockSeeTheSky(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ))) + { + boolean flag = true; + ItemStack itemstack = this.getEquipmentInSlot(4); + + if (itemstack != null) + { + if (itemstack.isItemStackDamageable()) + { + itemstack.setItemDamage(itemstack.getItemDamageForDisplay() + this.rand.nextInt(2)); + + if (itemstack.getItemDamageForDisplay() >= itemstack.getMaxDamage()) + { + this.renderBrokenItemStack(itemstack); + this.setCurrentItemOrArmor(4, (ItemStack)null); + } + } + + flag = false; + } + + if (flag) + { + this.setFire(8); + } + } + } + + if (this.worldObj.isRemote && this.getSkeletonType() == 1) + { + this.setSize(0.72F, 2.34F); + } + + super.onLivingUpdate(); + } + + public void updateRidden() + { + super.updateRidden(); + + if (this.ridingEntity instanceof EntityCreature) + { + EntityCreature entitycreature = (EntityCreature)this.ridingEntity; + this.renderYawOffset = entitycreature.renderYawOffset; + } + } + + public void onDeath(DamageSource par1DamageSource) + { + super.onDeath(par1DamageSource); + + if (par1DamageSource.getSourceOfDamage() instanceof EntityArrow && par1DamageSource.getEntity() instanceof EntityPlayer) + { + EntityPlayer entityplayer = (EntityPlayer)par1DamageSource.getEntity(); + double d0 = entityplayer.posX - this.posX; + double d1 = entityplayer.posZ - this.posZ; + + if (d0 * d0 + d1 * d1 >= 2500.0D) + { + entityplayer.triggerAchievement(AchievementList.snipeSkeleton); + } + } + } + + protected Item getDropItem() + { + return Items.arrow; + } + + protected void dropFewItems(boolean par1, int par2) + { + int j; + int k; + + if (this.getSkeletonType() == 1) + { + j = this.rand.nextInt(3 + par2) - 1; + + for (k = 0; k < j; ++k) + { + this.dropItem(Items.coal, 1); + } + } + else + { + j = this.rand.nextInt(3 + par2); + + for (k = 0; k < j; ++k) + { + this.dropItem(Items.arrow, 1); + } + } + + j = this.rand.nextInt(3 + par2); + + for (k = 0; k < j; ++k) + { + this.dropItem(Items.bone, 1); + } + } + + protected void dropRareDrop(int par1) + { + if (this.getSkeletonType() == 1) + { + this.entityDropItem(new ItemStack(Items.skull, 1, 1), 0.0F); + } + } + + protected void addRandomArmor() + { + super.addRandomArmor(); + this.setCurrentItemOrArmor(0, new ItemStack(Items.bow)); + } + + public IEntityLivingData onSpawnWithEgg(IEntityLivingData par1EntityLivingData) + { + par1EntityLivingData = super.onSpawnWithEgg(par1EntityLivingData); + + if (this.worldObj.provider instanceof WorldProviderHell && this.getRNG().nextInt(5) > 0) + { + this.tasks.addTask(4, this.aiAttackOnCollide); + this.setSkeletonType(1); + this.setCurrentItemOrArmor(0, new ItemStack(Items.stone_sword)); + this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(4.0D); + } + else + { + this.tasks.addTask(4, this.aiArrowAttack); + this.addRandomArmor(); + this.enchantEquipment(); + } + + this.setCanPickUpLoot(this.rand.nextFloat() < 0.55F * this.worldObj.func_147462_b(this.posX, this.posY, this.posZ)); + + if (this.getEquipmentInSlot(4) == null) + { + Calendar calendar = this.worldObj.getCurrentDate(); + + if (calendar.get(2) + 1 == 10 && calendar.get(5) == 31 && this.rand.nextFloat() < 0.25F) + { + this.setCurrentItemOrArmor(4, new ItemStack(this.rand.nextFloat() < 0.1F ? Blocks.lit_pumpkin : Blocks.pumpkin)); + this.equipmentDropChances[4] = 0.0F; + } + } + + return par1EntityLivingData; + } + + public void setCombatTask() + { + this.tasks.removeTask(this.aiAttackOnCollide); + this.tasks.removeTask(this.aiArrowAttack); + ItemStack itemstack = this.getHeldItem(); + + if (itemstack != null && itemstack.getItem() == Items.bow) + { + this.tasks.addTask(4, this.aiArrowAttack); + } + else + { + this.tasks.addTask(4, this.aiAttackOnCollide); + } + } + + public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2) + { + EntityArrow entityarrow = new EntityArrow(this.worldObj, this, par1EntityLivingBase, 1.6F, (float)(14 - this.worldObj.difficultySetting.getDifficultyId() * 4)); + int i = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, this.getHeldItem()); + int j = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, this.getHeldItem()); + entityarrow.setDamage((double)(par2 * 2.0F) + this.rand.nextGaussian() * 0.25D + (double)((float)this.worldObj.difficultySetting.getDifficultyId() * 0.11F)); + + if (i > 0) + { + entityarrow.setDamage(entityarrow.getDamage() + (double)i * 0.5D + 0.5D); + } + + if (j > 0) + { + entityarrow.setKnockbackStrength(j); + } + + if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, this.getHeldItem()) > 0 || this.getSkeletonType() == 1) + { + entityarrow.setFire(100); + } + + this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F)); + this.worldObj.spawnEntityInWorld(entityarrow); + } + + public int getSkeletonType() + { + return this.dataWatcher.getWatchableObjectByte(13); + } + + public void setSkeletonType(int par1) + { + this.dataWatcher.updateObject(13, Byte.valueOf((byte)par1)); + this.isImmuneToFire = par1 == 1; + + if (par1 == 1) + { + this.setSize(0.72F, 2.34F); + } + else + { + this.setSize(0.6F, 1.8F); + } + } + + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + super.readEntityFromNBT(par1NBTTagCompound); + + if (par1NBTTagCompound.hasKey("SkeletonType", 99)) + { + byte b0 = par1NBTTagCompound.getByte("SkeletonType"); + this.setSkeletonType(b0); + } + + this.setCombatTask(); + } + + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeEntityToNBT(par1NBTTagCompound); + par1NBTTagCompound.setByte("SkeletonType", (byte)this.getSkeletonType()); + } + + public void setCurrentItemOrArmor(int par1, ItemStack par2ItemStack) + { + super.setCurrentItemOrArmor(par1, par2ItemStack); + + if (!this.worldObj.isRemote && par1 == 0) + { + this.setCombatTask(); + } + } + + public double getYOffset() + { + return super.getYOffset() - 0.5D; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/monster/EntitySlime.java b/src/main/java/net/minecraft/entity/monster/EntitySlime.java new file mode 100644 index 0000000..7fa9fec --- /dev/null +++ b/src/main/java/net/minecraft/entity/monster/EntitySlime.java @@ -0,0 +1,287 @@ +package net.minecraft.entity.monster; + +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.world.EnumDifficulty; +import net.minecraft.world.World; +import net.minecraft.world.WorldType; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.chunk.Chunk; + +public class EntitySlime extends EntityLiving implements IMob +{ + public float squishAmount; + public float squishFactor; + public float prevSquishFactor; + private int slimeJumpDelay; + private static final String __OBFID = "CL_00001698"; + + public EntitySlime(World par1World) + { + super(par1World); + int i = 1 << this.rand.nextInt(3); + this.yOffset = 0.0F; + this.slimeJumpDelay = this.rand.nextInt(20) + 10; + this.setSlimeSize(i); + } + + protected void entityInit() + { + super.entityInit(); + this.dataWatcher.addObject(16, new Byte((byte)1)); + } + + protected void setSlimeSize(int par1) + { + this.dataWatcher.updateObject(16, new Byte((byte)par1)); + this.setSize(0.6F * (float)par1, 0.6F * (float)par1); + this.setPosition(this.posX, this.posY, this.posZ); + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue((double)(par1 * par1)); + this.setHealth(this.getMaxHealth()); + this.experienceValue = par1; + } + + public int getSlimeSize() + { + return this.dataWatcher.getWatchableObjectByte(16); + } + + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeEntityToNBT(par1NBTTagCompound); + par1NBTTagCompound.setInteger("Size", this.getSlimeSize() - 1); + } + + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + super.readEntityFromNBT(par1NBTTagCompound); + this.setSlimeSize(par1NBTTagCompound.getInteger("Size") + 1); + } + + protected String getSlimeParticle() + { + return "slime"; + } + + protected String getJumpSound() + { + return "mob.slime." + (this.getSlimeSize() > 1 ? "big" : "small"); + } + + public void onUpdate() + { + if (!this.worldObj.isRemote && this.worldObj.difficultySetting == EnumDifficulty.PEACEFUL && this.getSlimeSize() > 0) + { + this.isDead = true; + } + + this.squishFactor += (this.squishAmount - this.squishFactor) * 0.5F; + this.prevSquishFactor = this.squishFactor; + boolean flag = this.onGround; + super.onUpdate(); + int i; + + if (this.onGround && !flag) + { + i = this.getSlimeSize(); + + for (int j = 0; j < i * 8; ++j) + { + float f = this.rand.nextFloat() * (float)Math.PI * 2.0F; + float f1 = this.rand.nextFloat() * 0.5F + 0.5F; + float f2 = MathHelper.sin(f) * (float)i * 0.5F * f1; + float f3 = MathHelper.cos(f) * (float)i * 0.5F * f1; + this.worldObj.spawnParticle(this.getSlimeParticle(), this.posX + (double)f2, this.boundingBox.minY, this.posZ + (double)f3, 0.0D, 0.0D, 0.0D); + } + + if (this.makesSoundOnLand()) + { + this.playSound(this.getJumpSound(), this.getSoundVolume(), ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F) / 0.8F); + } + + this.squishAmount = -0.5F; + } + else if (!this.onGround && flag) + { + this.squishAmount = 1.0F; + } + + this.alterSquishAmount(); + + if (this.worldObj.isRemote) + { + i = this.getSlimeSize(); + this.setSize(0.6F * (float)i, 0.6F * (float)i); + } + } + + protected void updateEntityActionState() + { + this.despawnEntity(); + EntityPlayer entityplayer = this.worldObj.getClosestVulnerablePlayerToEntity(this, 16.0D); + + if (entityplayer != null) + { + this.faceEntity(entityplayer, 10.0F, 20.0F); + } + + if (this.onGround && this.slimeJumpDelay-- <= 0) + { + this.slimeJumpDelay = this.getJumpDelay(); + + if (entityplayer != null) + { + this.slimeJumpDelay /= 3; + } + + this.isJumping = true; + + if (this.makesSoundOnJump()) + { + this.playSound(this.getJumpSound(), this.getSoundVolume(), ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F) * 0.8F); + } + + this.moveStrafing = 1.0F - this.rand.nextFloat() * 2.0F; + this.moveForward = (float)(1 * this.getSlimeSize()); + } + else + { + this.isJumping = false; + + if (this.onGround) + { + this.moveStrafing = this.moveForward = 0.0F; + } + } + } + + protected void alterSquishAmount() + { + this.squishAmount *= 0.6F; + } + + protected int getJumpDelay() + { + return this.rand.nextInt(20) + 10; + } + + protected EntitySlime createInstance() + { + return new EntitySlime(this.worldObj); + } + + public void setDead() + { + int i = this.getSlimeSize(); + + if (!this.worldObj.isRemote && i > 1 && this.getHealth() <= 0.0F) + { + int j = 2 + this.rand.nextInt(3); + + for (int k = 0; k < j; ++k) + { + float f = ((float)(k % 2) - 0.5F) * (float)i / 4.0F; + float f1 = ((float)(k / 2) - 0.5F) * (float)i / 4.0F; + EntitySlime entityslime = this.createInstance(); + entityslime.setSlimeSize(i / 2); + entityslime.setLocationAndAngles(this.posX + (double)f, this.posY + 0.5D, this.posZ + (double)f1, this.rand.nextFloat() * 360.0F, 0.0F); + this.worldObj.spawnEntityInWorld(entityslime); + } + } + + super.setDead(); + } + + public void onCollideWithPlayer(EntityPlayer par1EntityPlayer) + { + if (this.canDamagePlayer()) + { + int i = this.getSlimeSize(); + + if (this.canEntityBeSeen(par1EntityPlayer) && this.getDistanceSqToEntity(par1EntityPlayer) < 0.6D * (double)i * 0.6D * (double)i && par1EntityPlayer.attackEntityFrom(DamageSource.causeMobDamage(this), (float)this.getAttackStrength())) + { + this.playSound("mob.attack", 1.0F, (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F); + } + } + } + + protected boolean canDamagePlayer() + { + return this.getSlimeSize() > 1; + } + + protected int getAttackStrength() + { + return this.getSlimeSize(); + } + + protected String getHurtSound() + { + return "mob.slime." + (this.getSlimeSize() > 1 ? "big" : "small"); + } + + protected String getDeathSound() + { + return "mob.slime." + (this.getSlimeSize() > 1 ? "big" : "small"); + } + + protected Item getDropItem() + { + return this.getSlimeSize() == 1 ? Items.slime_ball : Item.getItemById(0); + } + + public boolean getCanSpawnHere() + { + Chunk chunk = this.worldObj.getChunkFromBlockCoords(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posZ)); + + if (this.worldObj.getWorldInfo().getTerrainType().handleSlimeSpawnReduction(rand, worldObj)) + { + return false; + } + else + { + if (this.getSlimeSize() == 1 || this.worldObj.difficultySetting != EnumDifficulty.PEACEFUL) + { + BiomeGenBase biomegenbase = this.worldObj.getBiomeGenForCoords(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posZ)); + + if (biomegenbase == BiomeGenBase.swampland && this.posY > 50.0D && this.posY < 70.0D && this.rand.nextFloat() < 0.5F && this.rand.nextFloat() < this.worldObj.getCurrentMoonPhaseFactor() && this.worldObj.getBlockLightValue(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)) <= this.rand.nextInt(8)) + { + return super.getCanSpawnHere(); + } + + if (this.rand.nextInt(10) == 0 && chunk.getRandomWithSeed(987234911L).nextInt(10) == 0 && this.posY < 40.0D) + { + return super.getCanSpawnHere(); + } + } + + return false; + } + } + + protected float getSoundVolume() + { + return 0.4F * (float)this.getSlimeSize(); + } + + public int getVerticalFaceSpeed() + { + return 0; + } + + protected boolean makesSoundOnJump() + { + return this.getSlimeSize() > 0; + } + + protected boolean makesSoundOnLand() + { + return this.getSlimeSize() > 2; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/monster/EntitySnowman.java b/src/main/java/net/minecraft/entity/monster/EntitySnowman.java new file mode 100644 index 0000000..d23bf37 --- /dev/null +++ b/src/main/java/net/minecraft/entity/monster/EntitySnowman.java @@ -0,0 +1,106 @@ +package net.minecraft.entity.monster; + +import net.minecraft.block.material.Material; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IRangedAttackMob; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.EntityAIArrowAttack; +import net.minecraft.entity.ai.EntityAILookIdle; +import net.minecraft.entity.ai.EntityAINearestAttackableTarget; +import net.minecraft.entity.ai.EntityAIWander; +import net.minecraft.entity.ai.EntityAIWatchClosest; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.projectile.EntitySnowball; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class EntitySnowman extends EntityGolem implements IRangedAttackMob +{ + private static final String __OBFID = "CL_00001650"; + + public EntitySnowman(World par1World) + { + super(par1World); + this.setSize(0.4F, 1.8F); + this.getNavigator().setAvoidsWater(true); + this.tasks.addTask(1, new EntityAIArrowAttack(this, 1.25D, 20, 10.0F)); + this.tasks.addTask(2, new EntityAIWander(this, 1.0D)); + this.tasks.addTask(3, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F)); + this.tasks.addTask(4, new EntityAILookIdle(this)); + this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityLiving.class, 0, true, false, IMob.mobSelector)); + } + + public boolean isAIEnabled() + { + return true; + } + + protected void applyEntityAttributes() + { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(4.0D); + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.20000000298023224D); + } + + public void onLivingUpdate() + { + super.onLivingUpdate(); + int i = MathHelper.floor_double(this.posX); + int j = MathHelper.floor_double(this.posY); + int k = MathHelper.floor_double(this.posZ); + + if (this.isWet()) + { + this.attackEntityFrom(DamageSource.drown, 1.0F); + } + + if (this.worldObj.getBiomeGenForCoords(i, k).getFloatTemperature(i, j, k) > 1.0F) + { + this.attackEntityFrom(DamageSource.onFire, 1.0F); + } + + for (int l = 0; l < 4; ++l) + { + i = MathHelper.floor_double(this.posX + (double)((float)(l % 2 * 2 - 1) * 0.25F)); + j = MathHelper.floor_double(this.posY); + k = MathHelper.floor_double(this.posZ + (double)((float)(l / 2 % 2 * 2 - 1) * 0.25F)); + + if (this.worldObj.getBlock(i, j, k).getMaterial() == Material.air && this.worldObj.getBiomeGenForCoords(i, k).getFloatTemperature(i, j, k) < 0.8F && Blocks.snow_layer.canPlaceBlockAt(this.worldObj, i, j, k)) + { + this.worldObj.setBlock(i, j, k, Blocks.snow_layer); + } + } + } + + protected Item getDropItem() + { + return Items.snowball; + } + + protected void dropFewItems(boolean par1, int par2) + { + int j = this.rand.nextInt(16); + + for (int k = 0; k < j; ++k) + { + this.dropItem(Items.snowball, 1); + } + } + + public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2) + { + EntitySnowball entitysnowball = new EntitySnowball(this.worldObj, this); + double d0 = par1EntityLivingBase.posX - this.posX; + double d1 = par1EntityLivingBase.posY + (double)par1EntityLivingBase.getEyeHeight() - 1.100000023841858D - entitysnowball.posY; + double d2 = par1EntityLivingBase.posZ - this.posZ; + float f1 = MathHelper.sqrt_double(d0 * d0 + d2 * d2) * 0.2F; + entitysnowball.setThrowableHeading(d0, d1 + (double)f1, d2, 1.6F, 12.0F); + this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F)); + this.worldObj.spawnEntityInWorld(entitysnowball); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/monster/EntitySpider.java b/src/main/java/net/minecraft/entity/monster/EntitySpider.java new file mode 100644 index 0000000..20dd8b0 --- /dev/null +++ b/src/main/java/net/minecraft/entity/monster/EntitySpider.java @@ -0,0 +1,230 @@ +package net.minecraft.entity.monster; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EnumCreatureAttribute; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.MathHelper; +import net.minecraft.world.EnumDifficulty; +import net.minecraft.world.World; + +public class EntitySpider extends EntityMob +{ + private static final String __OBFID = "CL_00001699"; + + public EntitySpider(World par1World) + { + super(par1World); + this.setSize(1.4F, 0.9F); + } + + protected void entityInit() + { + super.entityInit(); + this.dataWatcher.addObject(16, new Byte((byte)0)); + } + + public void onUpdate() + { + super.onUpdate(); + + if (!this.worldObj.isRemote) + { + this.setBesideClimbableBlock(this.isCollidedHorizontally); + } + } + + protected void applyEntityAttributes() + { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(16.0D); + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.800000011920929D); + } + + protected Entity findPlayerToAttack() + { + float f = this.getBrightness(1.0F); + + if (f < 0.5F) + { + double d0 = 16.0D; + return this.worldObj.getClosestVulnerablePlayerToEntity(this, d0); + } + else + { + return null; + } + } + + protected String getLivingSound() + { + return "mob.spider.say"; + } + + protected String getHurtSound() + { + return "mob.spider.say"; + } + + protected String getDeathSound() + { + return "mob.spider.death"; + } + + protected void func_145780_a(int p_145780_1_, int p_145780_2_, int p_145780_3_, Block p_145780_4_) + { + this.playSound("mob.spider.step", 0.15F, 1.0F); + } + + protected void attackEntity(Entity par1Entity, float par2) + { + float f1 = this.getBrightness(1.0F); + + if (f1 > 0.5F && this.rand.nextInt(100) == 0) + { + this.entityToAttack = null; + } + else + { + if (par2 > 2.0F && par2 < 6.0F && this.rand.nextInt(10) == 0) + { + if (this.onGround) + { + double d0 = par1Entity.posX - this.posX; + double d1 = par1Entity.posZ - this.posZ; + float f2 = MathHelper.sqrt_double(d0 * d0 + d1 * d1); + this.motionX = d0 / (double)f2 * 0.5D * 0.800000011920929D + this.motionX * 0.20000000298023224D; + this.motionZ = d1 / (double)f2 * 0.5D * 0.800000011920929D + this.motionZ * 0.20000000298023224D; + this.motionY = 0.4000000059604645D; + } + } + else + { + super.attackEntity(par1Entity, par2); + } + } + } + + protected Item getDropItem() + { + return Items.string; + } + + protected void dropFewItems(boolean par1, int par2) + { + super.dropFewItems(par1, par2); + + if (par1 && (this.rand.nextInt(3) == 0 || this.rand.nextInt(1 + par2) > 0)) + { + this.dropItem(Items.spider_eye, 1); + } + } + + public boolean isOnLadder() + { + return this.isBesideClimbableBlock(); + } + + public void setInWeb() {} + + public EnumCreatureAttribute getCreatureAttribute() + { + return EnumCreatureAttribute.ARTHROPOD; + } + + public boolean isPotionApplicable(PotionEffect par1PotionEffect) + { + return par1PotionEffect.getPotionID() == Potion.poison.id ? false : super.isPotionApplicable(par1PotionEffect); + } + + public boolean isBesideClimbableBlock() + { + return (this.dataWatcher.getWatchableObjectByte(16) & 1) != 0; + } + + public void setBesideClimbableBlock(boolean par1) + { + byte b0 = this.dataWatcher.getWatchableObjectByte(16); + + if (par1) + { + b0 = (byte)(b0 | 1); + } + else + { + b0 &= -2; + } + + this.dataWatcher.updateObject(16, Byte.valueOf(b0)); + } + + public IEntityLivingData onSpawnWithEgg(IEntityLivingData par1EntityLivingData) + { + Object p_110161_1_1 = super.onSpawnWithEgg(par1EntityLivingData); + + if (this.worldObj.rand.nextInt(100) == 0) + { + EntitySkeleton entityskeleton = new EntitySkeleton(this.worldObj); + entityskeleton.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F); + entityskeleton.onSpawnWithEgg((IEntityLivingData)null); + this.worldObj.spawnEntityInWorld(entityskeleton); + entityskeleton.mountEntity(this); + } + + if (p_110161_1_1 == null) + { + p_110161_1_1 = new EntitySpider.GroupData(); + + if (this.worldObj.difficultySetting == EnumDifficulty.HARD && this.worldObj.rand.nextFloat() < 0.1F * this.worldObj.func_147462_b(this.posX, this.posY, this.posZ)) + { + ((EntitySpider.GroupData)p_110161_1_1).func_111104_a(this.worldObj.rand); + } + } + + if (p_110161_1_1 instanceof EntitySpider.GroupData) + { + int i = ((EntitySpider.GroupData)p_110161_1_1).field_111105_a; + + if (i > 0 && Potion.potionTypes[i] != null) + { + this.addPotionEffect(new PotionEffect(i, Integer.MAX_VALUE)); + } + } + + return (IEntityLivingData)p_110161_1_1; + } + + public static class GroupData implements IEntityLivingData + { + public int field_111105_a; + private static final String __OBFID = "CL_00001700"; + + public void func_111104_a(Random par1Random) + { + int i = par1Random.nextInt(5); + + if (i <= 1) + { + this.field_111105_a = Potion.moveSpeed.id; + } + else if (i <= 2) + { + this.field_111105_a = Potion.damageBoost.id; + } + else if (i <= 3) + { + this.field_111105_a = Potion.regeneration.id; + } + else if (i <= 4) + { + this.field_111105_a = Potion.invisibility.id; + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/monster/EntityWitch.java b/src/main/java/net/minecraft/entity/monster/EntityWitch.java new file mode 100644 index 0000000..50eb25c --- /dev/null +++ b/src/main/java/net/minecraft/entity/monster/EntityWitch.java @@ -0,0 +1,253 @@ +package net.minecraft.entity.monster; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Iterator; +import java.util.List; +import java.util.UUID; +import net.minecraft.block.material.Material; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IRangedAttackMob; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.EntityAIArrowAttack; +import net.minecraft.entity.ai.EntityAIHurtByTarget; +import net.minecraft.entity.ai.EntityAILookIdle; +import net.minecraft.entity.ai.EntityAINearestAttackableTarget; +import net.minecraft.entity.ai.EntityAISwimming; +import net.minecraft.entity.ai.EntityAIWander; +import net.minecraft.entity.ai.EntityAIWatchClosest; +import net.minecraft.entity.ai.attributes.AttributeModifier; +import net.minecraft.entity.ai.attributes.IAttributeInstance; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.projectile.EntityPotion; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class EntityWitch extends EntityMob implements IRangedAttackMob +{ + private static final UUID field_110184_bp = UUID.fromString("5CD17E52-A79A-43D3-A529-90FDE04B181E"); + private static final AttributeModifier field_110185_bq = (new AttributeModifier(field_110184_bp, "Drinking speed penalty", -0.25D, 0)).setSaved(false); + private static final Item[] witchDrops = new Item[] {Items.glowstone_dust, Items.sugar, Items.redstone, Items.spider_eye, Items.glass_bottle, Items.gunpowder, Items.stick, Items.stick}; + private int witchAttackTimer; + private static final String __OBFID = "CL_00001701"; + + public EntityWitch(World par1World) + { + super(par1World); + this.tasks.addTask(1, new EntityAISwimming(this)); + this.tasks.addTask(2, new EntityAIArrowAttack(this, 1.0D, 60, 10.0F)); + this.tasks.addTask(2, new EntityAIWander(this, 1.0D)); + this.tasks.addTask(3, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); + this.tasks.addTask(3, new EntityAILookIdle(this)); + this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false)); + this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true)); + } + + protected void entityInit() + { + super.entityInit(); + this.getDataWatcher().addObject(21, Byte.valueOf((byte)0)); + } + + protected String getLivingSound() + { + return "mob.witch.idle"; + } + + protected String getHurtSound() + { + return "mob.witch.hurt"; + } + + protected String getDeathSound() + { + return "mob.witch.death"; + } + + public void setAggressive(boolean par1) + { + this.getDataWatcher().updateObject(21, Byte.valueOf((byte)(par1 ? 1 : 0))); + } + + public boolean getAggressive() + { + return this.getDataWatcher().getWatchableObjectByte(21) == 1; + } + + protected void applyEntityAttributes() + { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(26.0D); + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.25D); + } + + public boolean isAIEnabled() + { + return true; + } + + public void onLivingUpdate() + { + if (!this.worldObj.isRemote) + { + if (this.getAggressive()) + { + if (this.witchAttackTimer-- <= 0) + { + this.setAggressive(false); + ItemStack itemstack = this.getHeldItem(); + this.setCurrentItemOrArmor(0, (ItemStack)null); + + if (itemstack != null && itemstack.getItem() == Items.potionitem) + { + List list = Items.potionitem.getEffects(itemstack); + + if (list != null) + { + Iterator iterator = list.iterator(); + + while (iterator.hasNext()) + { + PotionEffect potioneffect = (PotionEffect)iterator.next(); + this.addPotionEffect(new PotionEffect(potioneffect)); + } + } + } + + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).removeModifier(field_110185_bq); + } + } + else + { + short short1 = -1; + + if (this.rand.nextFloat() < 0.15F && this.isInsideOfMaterial(Material.water) && !this.isPotionActive(Potion.waterBreathing)) + { + short1 = 8237; + } + else if (this.rand.nextFloat() < 0.15F && this.isBurning() && !this.isPotionActive(Potion.fireResistance)) + { + short1 = 16307; + } + else if (this.rand.nextFloat() < 0.05F && this.getHealth() < this.getMaxHealth()) + { + short1 = 16341; + } + else if (this.rand.nextFloat() < 0.25F && this.getAttackTarget() != null && !this.isPotionActive(Potion.moveSpeed) && this.getAttackTarget().getDistanceSqToEntity(this) > 121.0D) + { + short1 = 16274; + } + else if (this.rand.nextFloat() < 0.25F && this.getAttackTarget() != null && !this.isPotionActive(Potion.moveSpeed) && this.getAttackTarget().getDistanceSqToEntity(this) > 121.0D) + { + short1 = 16274; + } + + if (short1 > -1) + { + this.setCurrentItemOrArmor(0, new ItemStack(Items.potionitem, 1, short1)); + this.witchAttackTimer = this.getHeldItem().getMaxItemUseDuration(); + this.setAggressive(true); + IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed); + iattributeinstance.removeModifier(field_110185_bq); + iattributeinstance.applyModifier(field_110185_bq); + } + } + + if (this.rand.nextFloat() < 7.5E-4F) + { + this.worldObj.setEntityState(this, (byte)15); + } + } + + super.onLivingUpdate(); + } + + @SideOnly(Side.CLIENT) + public void handleHealthUpdate(byte par1) + { + if (par1 == 15) + { + for (int i = 0; i < this.rand.nextInt(35) + 10; ++i) + { + this.worldObj.spawnParticle("witchMagic", this.posX + this.rand.nextGaussian() * 0.12999999523162842D, this.boundingBox.maxY + 0.5D + this.rand.nextGaussian() * 0.12999999523162842D, this.posZ + this.rand.nextGaussian() * 0.12999999523162842D, 0.0D, 0.0D, 0.0D); + } + } + else + { + super.handleHealthUpdate(par1); + } + } + + protected float applyPotionDamageCalculations(DamageSource par1DamageSource, float par2) + { + par2 = super.applyPotionDamageCalculations(par1DamageSource, par2); + + if (par1DamageSource.getEntity() == this) + { + par2 = 0.0F; + } + + if (par1DamageSource.isMagicDamage()) + { + par2 = (float)((double)par2 * 0.15D); + } + + return par2; + } + + protected void dropFewItems(boolean par1, int par2) + { + int j = this.rand.nextInt(3) + 1; + + for (int k = 0; k < j; ++k) + { + int l = this.rand.nextInt(3); + Item item = witchDrops[this.rand.nextInt(witchDrops.length)]; + + if (par2 > 0) + { + l += this.rand.nextInt(par2 + 1); + } + + for (int i1 = 0; i1 < l; ++i1) + { + this.dropItem(item, 1); + } + } + } + + public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2) + { + if (!this.getAggressive()) + { + EntityPotion entitypotion = new EntityPotion(this.worldObj, this, 32732); + entitypotion.rotationPitch -= -20.0F; + double d0 = par1EntityLivingBase.posX + par1EntityLivingBase.motionX - this.posX; + double d1 = par1EntityLivingBase.posY + (double)par1EntityLivingBase.getEyeHeight() - 1.100000023841858D - this.posY; + double d2 = par1EntityLivingBase.posZ + par1EntityLivingBase.motionZ - this.posZ; + float f1 = MathHelper.sqrt_double(d0 * d0 + d2 * d2); + + if (f1 >= 8.0F && !par1EntityLivingBase.isPotionActive(Potion.moveSlowdown)) + { + entitypotion.setPotionDamage(32698); + } + else if (par1EntityLivingBase.getHealth() >= 8.0F && !par1EntityLivingBase.isPotionActive(Potion.poison)) + { + entitypotion.setPotionDamage(32660); + } + else if (f1 <= 3.0F && !par1EntityLivingBase.isPotionActive(Potion.weakness) && this.rand.nextFloat() < 0.25F) + { + entitypotion.setPotionDamage(32696); + } + + entitypotion.setThrowableHeading(d0, d1 + (double)(f1 * 0.2F), d2, 0.75F, 8.0F); + this.worldObj.spawnEntityInWorld(entitypotion); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/monster/EntityZombie.java b/src/main/java/net/minecraft/entity/monster/EntityZombie.java new file mode 100644 index 0000000..db1be0c --- /dev/null +++ b/src/main/java/net/minecraft/entity/monster/EntityZombie.java @@ -0,0 +1,657 @@ +package net.minecraft.entity.monster; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Calendar; +import java.util.UUID; +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.EnumCreatureAttribute; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.EntityAIAttackOnCollide; +import net.minecraft.entity.ai.EntityAIBreakDoor; +import net.minecraft.entity.ai.EntityAIHurtByTarget; +import net.minecraft.entity.ai.EntityAILookIdle; +import net.minecraft.entity.ai.EntityAIMoveThroughVillage; +import net.minecraft.entity.ai.EntityAIMoveTowardsRestriction; +import net.minecraft.entity.ai.EntityAINearestAttackableTarget; +import net.minecraft.entity.ai.EntityAISwimming; +import net.minecraft.entity.ai.EntityAIWander; +import net.minecraft.entity.ai.EntityAIWatchClosest; +import net.minecraft.entity.ai.attributes.AttributeModifier; +import net.minecraft.entity.ai.attributes.IAttribute; +import net.minecraft.entity.ai.attributes.IAttributeInstance; +import net.minecraft.entity.ai.attributes.RangedAttribute; +import net.minecraft.entity.passive.EntityVillager; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.world.EnumDifficulty; +import net.minecraft.world.World; +import net.minecraftforge.common.ForgeModContainer; +import cpw.mods.fml.common.eventhandler.Event.Result; +import net.minecraftforge.event.ForgeEventFactory; +import net.minecraftforge.event.entity.living.ZombieEvent.SummonAidEvent; + +public class EntityZombie extends EntityMob +{ + protected static final IAttribute field_110186_bp = (new RangedAttribute("zombie.spawnReinforcements", 0.0D, 0.0D, 1.0D)).setDescription("Spawn Reinforcements Chance"); + private static final UUID babySpeedBoostUUID = UUID.fromString("B9766B59-9566-4402-BC1F-2EE2A276D836"); + private static final AttributeModifier babySpeedBoostModifier = new AttributeModifier(babySpeedBoostUUID, "Baby speed boost", 0.5D, 1); + private final EntityAIBreakDoor field_146075_bs = new EntityAIBreakDoor(this); + private int conversionTime; + private boolean field_146076_bu = false; + private float field_146074_bv = -1.0F; + private float field_146073_bw; + private static final String __OBFID = "CL_00001702"; + + public EntityZombie(World par1World) + { + super(par1World); + this.getNavigator().setBreakDoors(true); + this.tasks.addTask(0, new EntityAISwimming(this)); + this.tasks.addTask(2, new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.0D, false)); + this.tasks.addTask(4, new EntityAIAttackOnCollide(this, EntityVillager.class, 1.0D, true)); + this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 1.0D)); + this.tasks.addTask(6, new EntityAIMoveThroughVillage(this, 1.0D, false)); + this.tasks.addTask(7, new EntityAIWander(this, 1.0D)); + this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); + this.tasks.addTask(8, new EntityAILookIdle(this)); + this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true)); + this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true)); + this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityVillager.class, 0, false)); + this.setSize(0.6F, 1.8F); + } + + protected void applyEntityAttributes() + { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(40.0D); + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.23000000417232513D); + this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(3.0D); + this.getAttributeMap().registerAttribute(field_110186_bp).setBaseValue(this.rand.nextDouble() * ForgeModContainer.zombieSummonBaseChance); + } + + protected void entityInit() + { + super.entityInit(); + this.getDataWatcher().addObject(12, Byte.valueOf((byte)0)); + this.getDataWatcher().addObject(13, Byte.valueOf((byte)0)); + this.getDataWatcher().addObject(14, Byte.valueOf((byte)0)); + } + + public int getTotalArmorValue() + { + int i = super.getTotalArmorValue() + 2; + + if (i > 20) + { + i = 20; + } + + return i; + } + + protected boolean isAIEnabled() + { + return true; + } + + public boolean func_146072_bX() + { + return this.field_146076_bu; + } + + public void func_146070_a(boolean p_146070_1_) + { + if (this.field_146076_bu != p_146070_1_) + { + this.field_146076_bu = p_146070_1_; + + if (p_146070_1_) + { + this.tasks.addTask(1, this.field_146075_bs); + } + else + { + this.tasks.removeTask(this.field_146075_bs); + } + } + } + + public boolean isChild() + { + return this.getDataWatcher().getWatchableObjectByte(12) == 1; + } + + protected int getExperiencePoints(EntityPlayer par1EntityPlayer) + { + if (this.isChild()) + { + this.experienceValue = (int)((float)this.experienceValue * 2.5F); + } + + return super.getExperiencePoints(par1EntityPlayer); + } + + public void setChild(boolean par1) + { + this.getDataWatcher().updateObject(12, Byte.valueOf((byte)(par1 ? 1 : 0))); + + if (this.worldObj != null && !this.worldObj.isRemote) + { + IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed); + iattributeinstance.removeModifier(babySpeedBoostModifier); + + if (par1) + { + iattributeinstance.applyModifier(babySpeedBoostModifier); + } + } + + this.func_146071_k(par1); + } + + public boolean isVillager() + { + return this.getDataWatcher().getWatchableObjectByte(13) == 1; + } + + public void setVillager(boolean par1) + { + this.getDataWatcher().updateObject(13, Byte.valueOf((byte)(par1 ? 1 : 0))); + } + + public void onLivingUpdate() + { + if (this.worldObj.isDaytime() && !this.worldObj.isRemote && !this.isChild()) + { + float f = this.getBrightness(1.0F); + + if (f > 0.5F && this.rand.nextFloat() * 30.0F < (f - 0.4F) * 2.0F && this.worldObj.canBlockSeeTheSky(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ))) + { + boolean flag = true; + ItemStack itemstack = this.getEquipmentInSlot(4); + + if (itemstack != null) + { + if (itemstack.isItemStackDamageable()) + { + itemstack.setItemDamage(itemstack.getItemDamageForDisplay() + this.rand.nextInt(2)); + + if (itemstack.getItemDamageForDisplay() >= itemstack.getMaxDamage()) + { + this.renderBrokenItemStack(itemstack); + this.setCurrentItemOrArmor(4, (ItemStack)null); + } + } + + flag = false; + } + + if (flag) + { + this.setFire(8); + } + } + } + + super.onLivingUpdate(); + } + + public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) + { + if (!super.attackEntityFrom(par1DamageSource, par2)) + { + return false; + } + else + { + EntityLivingBase entitylivingbase = this.getAttackTarget(); + + if (entitylivingbase == null && this.getEntityToAttack() instanceof EntityLivingBase) + { + entitylivingbase = (EntityLivingBase)this.getEntityToAttack(); + } + + if (entitylivingbase == null && par1DamageSource.getEntity() instanceof EntityLivingBase) + { + entitylivingbase = (EntityLivingBase)par1DamageSource.getEntity(); + } + + + int i = MathHelper.floor_double(this.posX); + int j = MathHelper.floor_double(this.posY); + int k = MathHelper.floor_double(this.posZ); + + SummonAidEvent summonAid = ForgeEventFactory.fireZombieSummonAid(this, worldObj, i, j, k, entitylivingbase, this.getEntityAttribute(field_110186_bp).getAttributeValue()); + + if (summonAid.getResult() == Result.DENY) + { + return true; + } + else if (summonAid.getResult() == Result.ALLOW || entitylivingbase != null && this.worldObj.difficultySetting == EnumDifficulty.HARD && (double)this.rand.nextFloat() < this.getEntityAttribute(field_110186_bp).getAttributeValue()) + { + EntityZombie entityzombie; + if (summonAid.customSummonedAid != null && summonAid.getResult() == Result.ALLOW) + { + entityzombie = summonAid.customSummonedAid; + } + else + { + entityzombie = new EntityZombie(this.worldObj); + } + + for (int l = 0; l < 50; ++l) + { + int i1 = i + MathHelper.getRandomIntegerInRange(this.rand, 7, 40) * MathHelper.getRandomIntegerInRange(this.rand, -1, 1); + int j1 = j + MathHelper.getRandomIntegerInRange(this.rand, 7, 40) * MathHelper.getRandomIntegerInRange(this.rand, -1, 1); + int k1 = k + MathHelper.getRandomIntegerInRange(this.rand, 7, 40) * MathHelper.getRandomIntegerInRange(this.rand, -1, 1); + + if (World.doesBlockHaveSolidTopSurface(this.worldObj, i1, j1 - 1, k1) && this.worldObj.getBlockLightValue(i1, j1, k1) < 10) + { + entityzombie.setPosition((double)i1, (double)j1, (double)k1); + + if (this.worldObj.checkNoEntityCollision(entityzombie.boundingBox) && this.worldObj.getCollidingBoundingBoxes(entityzombie, entityzombie.boundingBox).isEmpty() && !this.worldObj.isAnyLiquid(entityzombie.boundingBox)) + { + this.worldObj.spawnEntityInWorld(entityzombie); + if (entitylivingbase != null) entityzombie.setAttackTarget(entitylivingbase); + entityzombie.onSpawnWithEgg((IEntityLivingData)null); + this.getEntityAttribute(field_110186_bp).applyModifier(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, 0)); + entityzombie.getEntityAttribute(field_110186_bp).applyModifier(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, 0)); + break; + } + } + } + } + + return true; + } + } + + public void onUpdate() + { + if (!this.worldObj.isRemote && this.isConverting()) + { + int i = this.getConversionTimeBoost(); + this.conversionTime -= i; + + if (this.conversionTime <= 0) + { + this.convertToVillager(); + } + } + + super.onUpdate(); + } + + public boolean attackEntityAsMob(Entity par1Entity) + { + boolean flag = super.attackEntityAsMob(par1Entity); + + if (flag) + { + int i = this.worldObj.difficultySetting.getDifficultyId(); + + if (this.getHeldItem() == null && this.isBurning() && this.rand.nextFloat() < (float)i * 0.3F) + { + par1Entity.setFire(2 * i); + } + } + + return flag; + } + + protected String getLivingSound() + { + return "mob.zombie.say"; + } + + protected String getHurtSound() + { + return "mob.zombie.hurt"; + } + + protected String getDeathSound() + { + return "mob.zombie.death"; + } + + protected void func_145780_a(int p_145780_1_, int p_145780_2_, int p_145780_3_, Block p_145780_4_) + { + this.playSound("mob.zombie.step", 0.15F, 1.0F); + } + + protected Item getDropItem() + { + return Items.rotten_flesh; + } + + public EnumCreatureAttribute getCreatureAttribute() + { + return EnumCreatureAttribute.UNDEAD; + } + + protected void dropRareDrop(int par1) + { + switch (this.rand.nextInt(3)) + { + case 0: + this.dropItem(Items.iron_ingot, 1); + break; + case 1: + this.dropItem(Items.carrot, 1); + break; + case 2: + this.dropItem(Items.potato, 1); + } + } + + protected void addRandomArmor() + { + super.addRandomArmor(); + + if (this.rand.nextFloat() < (this.worldObj.difficultySetting == EnumDifficulty.HARD ? 0.05F : 0.01F)) + { + int i = this.rand.nextInt(3); + + if (i == 0) + { + this.setCurrentItemOrArmor(0, new ItemStack(Items.iron_sword)); + } + else + { + this.setCurrentItemOrArmor(0, new ItemStack(Items.iron_shovel)); + } + } + } + + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeEntityToNBT(par1NBTTagCompound); + + if (this.isChild()) + { + par1NBTTagCompound.setBoolean("IsBaby", true); + } + + if (this.isVillager()) + { + par1NBTTagCompound.setBoolean("IsVillager", true); + } + + par1NBTTagCompound.setInteger("ConversionTime", this.isConverting() ? this.conversionTime : -1); + par1NBTTagCompound.setBoolean("CanBreakDoors", this.func_146072_bX()); + } + + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + super.readEntityFromNBT(par1NBTTagCompound); + + if (par1NBTTagCompound.getBoolean("IsBaby")) + { + this.setChild(true); + } + + if (par1NBTTagCompound.getBoolean("IsVillager")) + { + this.setVillager(true); + } + + if (par1NBTTagCompound.hasKey("ConversionTime", 99) && par1NBTTagCompound.getInteger("ConversionTime") > -1) + { + this.startConversion(par1NBTTagCompound.getInteger("ConversionTime")); + } + + this.func_146070_a(par1NBTTagCompound.getBoolean("CanBreakDoors")); + } + + public void onKillEntity(EntityLivingBase par1EntityLivingBase) + { + super.onKillEntity(par1EntityLivingBase); + + if ((this.worldObj.difficultySetting == EnumDifficulty.NORMAL || this.worldObj.difficultySetting == EnumDifficulty.HARD) && par1EntityLivingBase instanceof EntityVillager) + { + if (this.rand.nextBoolean()) + { + return; + } + + EntityZombie entityzombie = new EntityZombie(this.worldObj); + entityzombie.copyLocationAndAnglesFrom(par1EntityLivingBase); + this.worldObj.removeEntity(par1EntityLivingBase); + entityzombie.onSpawnWithEgg((IEntityLivingData)null); + entityzombie.setVillager(true); + + if (par1EntityLivingBase.isChild()) + { + entityzombie.setChild(true); + } + + this.worldObj.spawnEntityInWorld(entityzombie); + this.worldObj.playAuxSFXAtEntity((EntityPlayer)null, 1016, (int)this.posX, (int)this.posY, (int)this.posZ, 0); + } + } + + public IEntityLivingData onSpawnWithEgg(IEntityLivingData par1EntityLivingData) + { + Object p_110161_1_1 = super.onSpawnWithEgg(par1EntityLivingData); + float f = this.worldObj.func_147462_b(this.posX, this.posY, this.posZ); + this.setCanPickUpLoot(this.rand.nextFloat() < 0.55F * f); + + if (p_110161_1_1 == null) + { + p_110161_1_1 = new EntityZombie.GroupData(this.worldObj.rand.nextFloat() < ForgeModContainer.zombieBabyChance, this.worldObj.rand.nextFloat() < 0.05F, null); + } + + if (p_110161_1_1 instanceof EntityZombie.GroupData) + { + EntityZombie.GroupData groupdata = (EntityZombie.GroupData)p_110161_1_1; + + if (groupdata.field_142046_b) + { + this.setVillager(true); + } + + if (groupdata.field_142048_a) + { + this.setChild(true); + } + } + + this.func_146070_a(this.rand.nextFloat() < f * 0.1F); + this.addRandomArmor(); + this.enchantEquipment(); + + if (this.getEquipmentInSlot(4) == null) + { + Calendar calendar = this.worldObj.getCurrentDate(); + + if (calendar.get(2) + 1 == 10 && calendar.get(5) == 31 && this.rand.nextFloat() < 0.25F) + { + this.setCurrentItemOrArmor(4, new ItemStack(this.rand.nextFloat() < 0.1F ? Blocks.lit_pumpkin : Blocks.pumpkin)); + this.equipmentDropChances[4] = 0.0F; + } + } + + this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).applyModifier(new AttributeModifier("Random spawn bonus", this.rand.nextDouble() * 0.05000000074505806D, 0)); + double d0 = this.rand.nextDouble() * 1.5D * (double)this.worldObj.func_147462_b(this.posX, this.posY, this.posZ); + + if (d0 > 1.0D) + { + this.getEntityAttribute(SharedMonsterAttributes.followRange).applyModifier(new AttributeModifier("Random zombie-spawn bonus", d0, 2)); + } + + if (this.rand.nextFloat() < f * 0.05F) + { + this.getEntityAttribute(field_110186_bp).applyModifier(new AttributeModifier("Leader zombie bonus", this.rand.nextDouble() * 0.25D + 0.5D, 0)); + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).applyModifier(new AttributeModifier("Leader zombie bonus", this.rand.nextDouble() * 3.0D + 1.0D, 2)); + this.func_146070_a(true); + } + + return (IEntityLivingData)p_110161_1_1; + } + + public boolean interact(EntityPlayer par1EntityPlayer) + { + ItemStack itemstack = par1EntityPlayer.getCurrentEquippedItem(); + + if (itemstack != null && itemstack.getItem() == Items.golden_apple && itemstack.getItemDamage() == 0 && this.isVillager() && this.isPotionActive(Potion.weakness)) + { + if (!par1EntityPlayer.capabilities.isCreativeMode) + { + --itemstack.stackSize; + } + + if (itemstack.stackSize <= 0) + { + par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack)null); + } + + if (!this.worldObj.isRemote) + { + this.startConversion(this.rand.nextInt(2401) + 3600); + } + + return true; + } + else + { + return false; + } + } + + protected void startConversion(int par1) + { + this.conversionTime = par1; + this.getDataWatcher().updateObject(14, Byte.valueOf((byte)1)); + this.removePotionEffect(Potion.weakness.id); + this.addPotionEffect(new PotionEffect(Potion.damageBoost.id, par1, Math.min(this.worldObj.difficultySetting.getDifficultyId() - 1, 0))); + this.worldObj.setEntityState(this, (byte)16); + } + + @SideOnly(Side.CLIENT) + public void handleHealthUpdate(byte par1) + { + if (par1 == 16) + { + this.worldObj.playSound(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D, "mob.zombie.remedy", 1.0F + this.rand.nextFloat(), this.rand.nextFloat() * 0.7F + 0.3F, false); + } + else + { + super.handleHealthUpdate(par1); + } + } + + protected boolean canDespawn() + { + return !this.isConverting(); + } + + public boolean isConverting() + { + return this.getDataWatcher().getWatchableObjectByte(14) == 1; + } + + protected void convertToVillager() + { + EntityVillager entityvillager = new EntityVillager(this.worldObj); + entityvillager.copyLocationAndAnglesFrom(this); + entityvillager.onSpawnWithEgg((IEntityLivingData)null); + entityvillager.setLookingForHome(); + + if (this.isChild()) + { + entityvillager.setGrowingAge(-24000); + } + + this.worldObj.removeEntity(this); + this.worldObj.spawnEntityInWorld(entityvillager); + entityvillager.addPotionEffect(new PotionEffect(Potion.confusion.id, 200, 0)); + this.worldObj.playAuxSFXAtEntity((EntityPlayer)null, 1017, (int)this.posX, (int)this.posY, (int)this.posZ, 0); + } + + protected int getConversionTimeBoost() + { + int i = 1; + + if (this.rand.nextFloat() < 0.01F) + { + int j = 0; + + for (int k = (int)this.posX - 4; k < (int)this.posX + 4 && j < 14; ++k) + { + for (int l = (int)this.posY - 4; l < (int)this.posY + 4 && j < 14; ++l) + { + for (int i1 = (int)this.posZ - 4; i1 < (int)this.posZ + 4 && j < 14; ++i1) + { + Block block = this.worldObj.getBlock(k, l, i1); + + if (block == Blocks.iron_bars || block == Blocks.bed) + { + if (this.rand.nextFloat() < 0.3F) + { + ++i; + } + + ++j; + } + } + } + } + } + + return i; + } + + public void func_146071_k(boolean p_146071_1_) + { + this.func_146069_a(p_146071_1_ ? 0.5F : 1.0F); + } + + protected final void setSize(float par1, float par2) + { + boolean flag = this.field_146074_bv > 0.0F && this.field_146073_bw > 0.0F; + this.field_146074_bv = par1; + this.field_146073_bw = par2; + + if (!flag) + { + this.func_146069_a(1.0F); + } + } + + protected final void func_146069_a(float p_146069_1_) + { + super.setSize(this.field_146074_bv * p_146069_1_, this.field_146073_bw * p_146069_1_); + } + + class GroupData implements IEntityLivingData + { + public boolean field_142048_a; + public boolean field_142046_b; + private static final String __OBFID = "CL_00001704"; + + private GroupData(boolean par2, boolean par3) + { + this.field_142048_a = false; + this.field_142046_b = false; + this.field_142048_a = par2; + this.field_142046_b = par3; + } + + GroupData(boolean par2, boolean par3, Object par4EntityZombieINNER1) + { + this(par2, par3); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/monster/IMob.java b/src/main/java/net/minecraft/entity/monster/IMob.java new file mode 100644 index 0000000..2dc0274 --- /dev/null +++ b/src/main/java/net/minecraft/entity/monster/IMob.java @@ -0,0 +1,17 @@ +package net.minecraft.entity.monster; + +import net.minecraft.command.IEntitySelector; +import net.minecraft.entity.Entity; +import net.minecraft.entity.passive.IAnimals; + +public interface IMob extends IAnimals +{ + IEntitySelector mobSelector = new IEntitySelector() + { + private static final String __OBFID = "CL_00001688"; + public boolean isEntityApplicable(Entity par1Entity) + { + return par1Entity instanceof IMob; + } + }; +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/passive/EntityAmbientCreature.java b/src/main/java/net/minecraft/entity/passive/EntityAmbientCreature.java new file mode 100644 index 0000000..6ac5a1d --- /dev/null +++ b/src/main/java/net/minecraft/entity/passive/EntityAmbientCreature.java @@ -0,0 +1,25 @@ +package net.minecraft.entity.passive; + +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; + +public abstract class EntityAmbientCreature extends EntityLiving implements IAnimals +{ + private static final String __OBFID = "CL_00001636"; + + public EntityAmbientCreature(World par1World) + { + super(par1World); + } + + public boolean allowLeashing() + { + return false; + } + + protected boolean interact(EntityPlayer par1EntityPlayer) + { + return false; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/passive/EntityAnimal.java b/src/main/java/net/minecraft/entity/passive/EntityAnimal.java new file mode 100644 index 0000000..619df1e --- /dev/null +++ b/src/main/java/net/minecraft/entity/passive/EntityAnimal.java @@ -0,0 +1,383 @@ +package net.minecraft.entity.passive; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityAgeable; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.attributes.IAttributeInstance; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.stats.AchievementList; +import net.minecraft.stats.StatList; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public abstract class EntityAnimal extends EntityAgeable implements IAnimals +{ + private int inLove; + private int breeding; + private EntityPlayer field_146084_br; + private static final String __OBFID = "CL_00001638"; + + public EntityAnimal(World par1World) + { + super(par1World); + } + + protected void updateAITick() + { + if (this.getGrowingAge() != 0) + { + this.inLove = 0; + } + + super.updateAITick(); + } + + public void onLivingUpdate() + { + super.onLivingUpdate(); + + if (this.getGrowingAge() != 0) + { + this.inLove = 0; + } + + if (this.inLove > 0) + { + --this.inLove; + String s = "heart"; + + if (this.inLove % 10 == 0) + { + double d0 = this.rand.nextGaussian() * 0.02D; + double d1 = this.rand.nextGaussian() * 0.02D; + double d2 = this.rand.nextGaussian() * 0.02D; + this.worldObj.spawnParticle(s, this.posX + (double)(this.rand.nextFloat() * this.width * 2.0F) - (double)this.width, this.posY + 0.5D + (double)(this.rand.nextFloat() * this.height), this.posZ + (double)(this.rand.nextFloat() * this.width * 2.0F) - (double)this.width, d0, d1, d2); + } + } + else + { + this.breeding = 0; + } + } + + protected void attackEntity(Entity par1Entity, float par2) + { + if (par1Entity instanceof EntityPlayer) + { + if (par2 < 3.0F) + { + double d0 = par1Entity.posX - this.posX; + double d1 = par1Entity.posZ - this.posZ; + this.rotationYaw = (float)(Math.atan2(d1, d0) * 180.0D / Math.PI) - 90.0F; + this.hasAttacked = true; + } + + EntityPlayer entityplayer = (EntityPlayer)par1Entity; + + if (entityplayer.getCurrentEquippedItem() == null || !this.isBreedingItem(entityplayer.getCurrentEquippedItem())) + { + this.entityToAttack = null; + } + } + else if (par1Entity instanceof EntityAnimal) + { + EntityAnimal entityanimal = (EntityAnimal)par1Entity; + + if (this.getGrowingAge() > 0 && entityanimal.getGrowingAge() < 0) + { + if ((double)par2 < 2.5D) + { + this.hasAttacked = true; + } + } + else if (this.inLove > 0 && entityanimal.inLove > 0) + { + if (entityanimal.entityToAttack == null) + { + entityanimal.entityToAttack = this; + } + + if (entityanimal.entityToAttack == this && (double)par2 < 3.5D) + { + ++entityanimal.inLove; + ++this.inLove; + ++this.breeding; + + if (this.breeding % 4 == 0) + { + this.worldObj.spawnParticle("heart", this.posX + (double)(this.rand.nextFloat() * this.width * 2.0F) - (double)this.width, this.posY + 0.5D + (double)(this.rand.nextFloat() * this.height), this.posZ + (double)(this.rand.nextFloat() * this.width * 2.0F) - (double)this.width, 0.0D, 0.0D, 0.0D); + } + + if (this.breeding == 60) + { + this.procreate((EntityAnimal)par1Entity); + } + } + else + { + this.breeding = 0; + } + } + else + { + this.breeding = 0; + this.entityToAttack = null; + } + } + } + + private void procreate(EntityAnimal par1EntityAnimal) + { + EntityAgeable entityageable = this.createChild(par1EntityAnimal); + + if (entityageable != null) + { + if (this.field_146084_br == null && par1EntityAnimal.func_146083_cb() != null) + { + this.field_146084_br = par1EntityAnimal.func_146083_cb(); + } + + if (this.field_146084_br != null) + { + this.field_146084_br.triggerAchievement(StatList.field_151186_x); + + if (this instanceof EntityCow) + { + this.field_146084_br.triggerAchievement(AchievementList.field_150962_H); + } + } + + this.setGrowingAge(6000); + par1EntityAnimal.setGrowingAge(6000); + this.inLove = 0; + this.breeding = 0; + this.entityToAttack = null; + par1EntityAnimal.entityToAttack = null; + par1EntityAnimal.breeding = 0; + par1EntityAnimal.inLove = 0; + entityageable.setGrowingAge(-24000); + entityageable.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch); + + for (int i = 0; i < 7; ++i) + { + double d0 = this.rand.nextGaussian() * 0.02D; + double d1 = this.rand.nextGaussian() * 0.02D; + double d2 = this.rand.nextGaussian() * 0.02D; + this.worldObj.spawnParticle("heart", this.posX + (double)(this.rand.nextFloat() * this.width * 2.0F) - (double)this.width, this.posY + 0.5D + (double)(this.rand.nextFloat() * this.height), this.posZ + (double)(this.rand.nextFloat() * this.width * 2.0F) - (double)this.width, d0, d1, d2); + } + + this.worldObj.spawnEntityInWorld(entityageable); + } + } + + public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) + { + if (this.isEntityInvulnerable()) + { + return false; + } + else + { + this.fleeingTick = 60; + + if (!this.isAIEnabled()) + { + IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed); + + if (iattributeinstance.getModifier(field_110179_h) == null) + { + iattributeinstance.applyModifier(field_110181_i); + } + } + + this.entityToAttack = null; + this.inLove = 0; + return super.attackEntityFrom(par1DamageSource, par2); + } + } + + public float getBlockPathWeight(int par1, int par2, int par3) + { + return this.worldObj.getBlock(par1, par2 - 1, par3) == Blocks.grass ? 10.0F : this.worldObj.getLightBrightness(par1, par2, par3) - 0.5F; + } + + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeEntityToNBT(par1NBTTagCompound); + par1NBTTagCompound.setInteger("InLove", this.inLove); + } + + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + super.readEntityFromNBT(par1NBTTagCompound); + this.inLove = par1NBTTagCompound.getInteger("InLove"); + } + + protected Entity findPlayerToAttack() + { + if (this.fleeingTick > 0) + { + return null; + } + else + { + float f = 8.0F; + List list; + int i; + EntityAnimal entityanimal; + + if (this.inLove > 0) + { + list = this.worldObj.getEntitiesWithinAABB(this.getClass(), this.boundingBox.expand((double)f, (double)f, (double)f)); + + for (i = 0; i < list.size(); ++i) + { + entityanimal = (EntityAnimal)list.get(i); + + if (entityanimal != this && entityanimal.inLove > 0) + { + return entityanimal; + } + } + } + else if (this.getGrowingAge() == 0) + { + list = this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, this.boundingBox.expand((double)f, (double)f, (double)f)); + + for (i = 0; i < list.size(); ++i) + { + EntityPlayer entityplayer = (EntityPlayer)list.get(i); + + if (entityplayer.getCurrentEquippedItem() != null && this.isBreedingItem(entityplayer.getCurrentEquippedItem())) + { + return entityplayer; + } + } + } + else if (this.getGrowingAge() > 0) + { + list = this.worldObj.getEntitiesWithinAABB(this.getClass(), this.boundingBox.expand((double)f, (double)f, (double)f)); + + for (i = 0; i < list.size(); ++i) + { + entityanimal = (EntityAnimal)list.get(i); + + if (entityanimal != this && entityanimal.getGrowingAge() < 0) + { + return entityanimal; + } + } + } + + return null; + } + } + + public boolean getCanSpawnHere() + { + int i = MathHelper.floor_double(this.posX); + int j = MathHelper.floor_double(this.boundingBox.minY); + int k = MathHelper.floor_double(this.posZ); + return this.worldObj.getBlock(i, j - 1, k) == Blocks.grass && this.worldObj.getFullBlockLightValue(i, j, k) > 8 && super.getCanSpawnHere(); + } + + public int getTalkInterval() + { + return 120; + } + + protected boolean canDespawn() + { + return false; + } + + protected int getExperiencePoints(EntityPlayer par1EntityPlayer) + { + return 1 + this.worldObj.rand.nextInt(3); + } + + public boolean isBreedingItem(ItemStack par1ItemStack) + { + return par1ItemStack.getItem() == Items.wheat; + } + + public boolean interact(EntityPlayer par1EntityPlayer) + { + ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem(); + + if (itemstack != null && this.isBreedingItem(itemstack) && this.getGrowingAge() == 0 && this.inLove <= 0) + { + if (!par1EntityPlayer.capabilities.isCreativeMode) + { + --itemstack.stackSize; + + if (itemstack.stackSize <= 0) + { + par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack)null); + } + } + + this.func_146082_f(par1EntityPlayer); + return true; + } + else + { + return super.interact(par1EntityPlayer); + } + } + + public void func_146082_f(EntityPlayer p_146082_1_) + { + this.inLove = 600; + this.field_146084_br = p_146082_1_; + this.entityToAttack = null; + this.worldObj.setEntityState(this, (byte)18); + } + + public EntityPlayer func_146083_cb() + { + return this.field_146084_br; + } + + public boolean isInLove() + { + return this.inLove > 0; + } + + public void resetInLove() + { + this.inLove = 0; + } + + public boolean canMateWith(EntityAnimal par1EntityAnimal) + { + return par1EntityAnimal == this ? false : (par1EntityAnimal.getClass() != this.getClass() ? false : this.isInLove() && par1EntityAnimal.isInLove()); + } + + @SideOnly(Side.CLIENT) + public void handleHealthUpdate(byte par1) + { + if (par1 == 18) + { + for (int i = 0; i < 7; ++i) + { + double d0 = this.rand.nextGaussian() * 0.02D; + double d1 = this.rand.nextGaussian() * 0.02D; + double d2 = this.rand.nextGaussian() * 0.02D; + this.worldObj.spawnParticle("heart", this.posX + (double)(this.rand.nextFloat() * this.width * 2.0F) - (double)this.width, this.posY + 0.5D + (double)(this.rand.nextFloat() * this.height), this.posZ + (double)(this.rand.nextFloat() * this.width * 2.0F) - (double)this.width, d0, d1, d2); + } + } + else + { + super.handleHealthUpdate(par1); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/passive/EntityBat.java b/src/main/java/net/minecraft/entity/passive/EntityBat.java new file mode 100644 index 0000000..eccb322 --- /dev/null +++ b/src/main/java/net/minecraft/entity/passive/EntityBat.java @@ -0,0 +1,239 @@ +package net.minecraft.entity.passive; + +import java.util.Calendar; +import net.minecraft.entity.Entity; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class EntityBat extends EntityAmbientCreature +{ + private ChunkCoordinates spawnPosition; + private static final String __OBFID = "CL_00001637"; + + public EntityBat(World par1World) + { + super(par1World); + this.setSize(0.5F, 0.9F); + this.setIsBatHanging(true); + } + + protected void entityInit() + { + super.entityInit(); + this.dataWatcher.addObject(16, new Byte((byte)0)); + } + + protected float getSoundVolume() + { + return 0.1F; + } + + protected float getSoundPitch() + { + return super.getSoundPitch() * 0.95F; + } + + protected String getLivingSound() + { + return this.getIsBatHanging() && this.rand.nextInt(4) != 0 ? null : "mob.bat.idle"; + } + + protected String getHurtSound() + { + return "mob.bat.hurt"; + } + + protected String getDeathSound() + { + return "mob.bat.death"; + } + + public boolean canBePushed() + { + return false; + } + + protected void collideWithEntity(Entity par1Entity) {} + + protected void collideWithNearbyEntities() {} + + protected void applyEntityAttributes() + { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(6.0D); + } + + public boolean getIsBatHanging() + { + return (this.dataWatcher.getWatchableObjectByte(16) & 1) != 0; + } + + public void setIsBatHanging(boolean par1) + { + byte b0 = this.dataWatcher.getWatchableObjectByte(16); + + if (par1) + { + this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 | 1))); + } + else + { + this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 & -2))); + } + } + + protected boolean isAIEnabled() + { + return true; + } + + public void onUpdate() + { + super.onUpdate(); + + if (this.getIsBatHanging()) + { + this.motionX = this.motionY = this.motionZ = 0.0D; + this.posY = (double)MathHelper.floor_double(this.posY) + 1.0D - (double)this.height; + } + else + { + this.motionY *= 0.6000000238418579D; + } + } + + protected void updateAITasks() + { + super.updateAITasks(); + + if (this.getIsBatHanging()) + { + if (!this.worldObj.getBlock(MathHelper.floor_double(this.posX), (int)this.posY + 1, MathHelper.floor_double(this.posZ)).isNormalCube()) + { + this.setIsBatHanging(false); + this.worldObj.playAuxSFXAtEntity((EntityPlayer)null, 1015, (int)this.posX, (int)this.posY, (int)this.posZ, 0); + } + else + { + if (this.rand.nextInt(200) == 0) + { + this.rotationYawHead = (float)this.rand.nextInt(360); + } + + if (this.worldObj.getClosestPlayerToEntity(this, 4.0D) != null) + { + this.setIsBatHanging(false); + this.worldObj.playAuxSFXAtEntity((EntityPlayer)null, 1015, (int)this.posX, (int)this.posY, (int)this.posZ, 0); + } + } + } + else + { + if (this.spawnPosition != null && (!this.worldObj.isAirBlock(this.spawnPosition.posX, this.spawnPosition.posY, this.spawnPosition.posZ) || this.spawnPosition.posY < 1)) + { + this.spawnPosition = null; + } + + if (this.spawnPosition == null || this.rand.nextInt(30) == 0 || this.spawnPosition.getDistanceSquared((int)this.posX, (int)this.posY, (int)this.posZ) < 4.0F) + { + this.spawnPosition = new ChunkCoordinates((int)this.posX + this.rand.nextInt(7) - this.rand.nextInt(7), (int)this.posY + this.rand.nextInt(6) - 2, (int)this.posZ + this.rand.nextInt(7) - this.rand.nextInt(7)); + } + + double d0 = (double)this.spawnPosition.posX + 0.5D - this.posX; + double d1 = (double)this.spawnPosition.posY + 0.1D - this.posY; + double d2 = (double)this.spawnPosition.posZ + 0.5D - this.posZ; + this.motionX += (Math.signum(d0) * 0.5D - this.motionX) * 0.10000000149011612D; + this.motionY += (Math.signum(d1) * 0.699999988079071D - this.motionY) * 0.10000000149011612D; + this.motionZ += (Math.signum(d2) * 0.5D - this.motionZ) * 0.10000000149011612D; + float f = (float)(Math.atan2(this.motionZ, this.motionX) * 180.0D / Math.PI) - 90.0F; + float f1 = MathHelper.wrapAngleTo180_float(f - this.rotationYaw); + this.moveForward = 0.5F; + this.rotationYaw += f1; + + if (this.rand.nextInt(100) == 0 && this.worldObj.getBlock(MathHelper.floor_double(this.posX), (int)this.posY + 1, MathHelper.floor_double(this.posZ)).isNormalCube()) + { + this.setIsBatHanging(true); + } + } + } + + protected boolean canTriggerWalking() + { + return false; + } + + protected void fall(float par1) {} + + protected void updateFallState(double par1, boolean par3) {} + + public boolean doesEntityNotTriggerPressurePlate() + { + return true; + } + + public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) + { + if (this.isEntityInvulnerable()) + { + return false; + } + else + { + if (!this.worldObj.isRemote && this.getIsBatHanging()) + { + this.setIsBatHanging(false); + } + + return super.attackEntityFrom(par1DamageSource, par2); + } + } + + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + super.readEntityFromNBT(par1NBTTagCompound); + this.dataWatcher.updateObject(16, Byte.valueOf(par1NBTTagCompound.getByte("BatFlags"))); + } + + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeEntityToNBT(par1NBTTagCompound); + par1NBTTagCompound.setByte("BatFlags", this.dataWatcher.getWatchableObjectByte(16)); + } + + public boolean getCanSpawnHere() + { + int i = MathHelper.floor_double(this.boundingBox.minY); + + if (i >= 63) + { + return false; + } + else + { + int j = MathHelper.floor_double(this.posX); + int k = MathHelper.floor_double(this.posZ); + int l = this.worldObj.getBlockLightValue(j, i, k); + byte b0 = 4; + Calendar calendar = this.worldObj.getCurrentDate(); + + if ((calendar.get(2) + 1 != 10 || calendar.get(5) < 20) && (calendar.get(2) + 1 != 11 || calendar.get(5) > 3)) + { + if (this.rand.nextBoolean()) + { + return false; + } + } + else + { + b0 = 7; + } + + return l > this.rand.nextInt(b0) ? false : super.getCanSpawnHere(); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/passive/EntityChicken.java b/src/main/java/net/minecraft/entity/passive/EntityChicken.java new file mode 100644 index 0000000..b779222 --- /dev/null +++ b/src/main/java/net/minecraft/entity/passive/EntityChicken.java @@ -0,0 +1,152 @@ +package net.minecraft.entity.passive; + +import net.minecraft.block.Block; +import net.minecraft.entity.EntityAgeable; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.EntityAIFollowParent; +import net.minecraft.entity.ai.EntityAILookIdle; +import net.minecraft.entity.ai.EntityAIMate; +import net.minecraft.entity.ai.EntityAIPanic; +import net.minecraft.entity.ai.EntityAISwimming; +import net.minecraft.entity.ai.EntityAITempt; +import net.minecraft.entity.ai.EntityAIWander; +import net.minecraft.entity.ai.EntityAIWatchClosest; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemSeeds; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class EntityChicken extends EntityAnimal +{ + public float field_70886_e; + public float destPos; + public float field_70884_g; + public float field_70888_h; + public float field_70889_i = 1.0F; + public int timeUntilNextEgg; + private static final String __OBFID = "CL_00001639"; + + public EntityChicken(World par1World) + { + super(par1World); + this.setSize(0.3F, 0.7F); + this.timeUntilNextEgg = this.rand.nextInt(6000) + 6000; + this.tasks.addTask(0, new EntityAISwimming(this)); + this.tasks.addTask(1, new EntityAIPanic(this, 1.4D)); + this.tasks.addTask(2, new EntityAIMate(this, 1.0D)); + this.tasks.addTask(3, new EntityAITempt(this, 1.0D, Items.wheat_seeds, false)); + this.tasks.addTask(4, new EntityAIFollowParent(this, 1.1D)); + this.tasks.addTask(5, new EntityAIWander(this, 1.0D)); + this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F)); + this.tasks.addTask(7, new EntityAILookIdle(this)); + } + + public boolean isAIEnabled() + { + return true; + } + + protected void applyEntityAttributes() + { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(4.0D); + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.25D); + } + + public void onLivingUpdate() + { + super.onLivingUpdate(); + this.field_70888_h = this.field_70886_e; + this.field_70884_g = this.destPos; + this.destPos = (float)((double)this.destPos + (double)(this.onGround ? -1 : 4) * 0.3D); + + if (this.destPos < 0.0F) + { + this.destPos = 0.0F; + } + + if (this.destPos > 1.0F) + { + this.destPos = 1.0F; + } + + if (!this.onGround && this.field_70889_i < 1.0F) + { + this.field_70889_i = 1.0F; + } + + this.field_70889_i = (float)((double)this.field_70889_i * 0.9D); + + if (!this.onGround && this.motionY < 0.0D) + { + this.motionY *= 0.6D; + } + + this.field_70886_e += this.field_70889_i * 2.0F; + + if (!this.isChild() && !this.worldObj.isRemote && --this.timeUntilNextEgg <= 0) + { + this.playSound("mob.chicken.plop", 1.0F, (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F); + this.dropItem(Items.egg, 1); + this.timeUntilNextEgg = this.rand.nextInt(6000) + 6000; + } + } + + protected void fall(float par1) {} + + protected String getLivingSound() + { + return "mob.chicken.say"; + } + + protected String getHurtSound() + { + return "mob.chicken.hurt"; + } + + protected String getDeathSound() + { + return "mob.chicken.hurt"; + } + + protected void func_145780_a(int p_145780_1_, int p_145780_2_, int p_145780_3_, Block p_145780_4_) + { + this.playSound("mob.chicken.step", 0.15F, 1.0F); + } + + protected Item getDropItem() + { + return Items.feather; + } + + protected void dropFewItems(boolean par1, int par2) + { + int j = this.rand.nextInt(3) + this.rand.nextInt(1 + par2); + + for (int k = 0; k < j; ++k) + { + this.dropItem(Items.feather, 1); + } + + if (this.isBurning()) + { + this.dropItem(Items.cooked_chicken, 1); + } + else + { + this.dropItem(Items.chicken, 1); + } + } + + public EntityChicken createChild(EntityAgeable par1EntityAgeable) + { + return new EntityChicken(this.worldObj); + } + + public boolean isBreedingItem(ItemStack par1ItemStack) + { + return par1ItemStack != null && par1ItemStack.getItem() instanceof ItemSeeds; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/passive/EntityCow.java b/src/main/java/net/minecraft/entity/passive/EntityCow.java new file mode 100644 index 0000000..d9a7dc7 --- /dev/null +++ b/src/main/java/net/minecraft/entity/passive/EntityCow.java @@ -0,0 +1,133 @@ +package net.minecraft.entity.passive; + +import net.minecraft.block.Block; +import net.minecraft.entity.EntityAgeable; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.EntityAIFollowParent; +import net.minecraft.entity.ai.EntityAILookIdle; +import net.minecraft.entity.ai.EntityAIMate; +import net.minecraft.entity.ai.EntityAIPanic; +import net.minecraft.entity.ai.EntityAISwimming; +import net.minecraft.entity.ai.EntityAITempt; +import net.minecraft.entity.ai.EntityAIWander; +import net.minecraft.entity.ai.EntityAIWatchClosest; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class EntityCow extends EntityAnimal +{ + private static final String __OBFID = "CL_00001640"; + + public EntityCow(World par1World) + { + super(par1World); + this.setSize(0.9F, 1.3F); + this.getNavigator().setAvoidsWater(true); + this.tasks.addTask(0, new EntityAISwimming(this)); + this.tasks.addTask(1, new EntityAIPanic(this, 2.0D)); + this.tasks.addTask(2, new EntityAIMate(this, 1.0D)); + this.tasks.addTask(3, new EntityAITempt(this, 1.25D, Items.wheat, false)); + this.tasks.addTask(4, new EntityAIFollowParent(this, 1.25D)); + this.tasks.addTask(5, new EntityAIWander(this, 1.0D)); + this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F)); + this.tasks.addTask(7, new EntityAILookIdle(this)); + } + + public boolean isAIEnabled() + { + return true; + } + + protected void applyEntityAttributes() + { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(10.0D); + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.20000000298023224D); + } + + protected String getLivingSound() + { + return "mob.cow.say"; + } + + protected String getHurtSound() + { + return "mob.cow.hurt"; + } + + protected String getDeathSound() + { + return "mob.cow.hurt"; + } + + protected void func_145780_a(int p_145780_1_, int p_145780_2_, int p_145780_3_, Block p_145780_4_) + { + this.playSound("mob.cow.step", 0.15F, 1.0F); + } + + protected float getSoundVolume() + { + return 0.4F; + } + + protected Item getDropItem() + { + return Items.leather; + } + + protected void dropFewItems(boolean par1, int par2) + { + int j = this.rand.nextInt(3) + this.rand.nextInt(1 + par2); + int k; + + for (k = 0; k < j; ++k) + { + this.dropItem(Items.leather, 1); + } + + j = this.rand.nextInt(3) + 1 + this.rand.nextInt(1 + par2); + + for (k = 0; k < j; ++k) + { + if (this.isBurning()) + { + this.dropItem(Items.cooked_beef, 1); + } + else + { + this.dropItem(Items.beef, 1); + } + } + } + + public boolean interact(EntityPlayer par1EntityPlayer) + { + ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem(); + + if (itemstack != null && itemstack.getItem() == Items.bucket && !par1EntityPlayer.capabilities.isCreativeMode) + { + if (itemstack.stackSize-- == 1) + { + par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, new ItemStack(Items.milk_bucket)); + } + else if (!par1EntityPlayer.inventory.addItemStackToInventory(new ItemStack(Items.milk_bucket))) + { + par1EntityPlayer.dropPlayerItemWithRandomChoice(new ItemStack(Items.milk_bucket, 1, 0), false); + } + + return true; + } + else + { + return super.interact(par1EntityPlayer); + } + } + + public EntityCow createChild(EntityAgeable par1EntityAgeable) + { + return new EntityCow(this.worldObj); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/passive/EntityHorse.java b/src/main/java/net/minecraft/entity/passive/EntityHorse.java new file mode 100644 index 0000000..6f80e71 --- /dev/null +++ b/src/main/java/net/minecraft/entity/passive/EntityHorse.java @@ -0,0 +1,1676 @@ +package net.minecraft.entity.passive; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Iterator; +import java.util.List; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.command.IEntitySelector; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityAgeable; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.EntityAIFollowParent; +import net.minecraft.entity.ai.EntityAILookIdle; +import net.minecraft.entity.ai.EntityAIMate; +import net.minecraft.entity.ai.EntityAIPanic; +import net.minecraft.entity.ai.EntityAIRunAroundLikeCrazy; +import net.minecraft.entity.ai.EntityAISwimming; +import net.minecraft.entity.ai.EntityAIWander; +import net.minecraft.entity.ai.EntityAIWatchClosest; +import net.minecraft.entity.ai.attributes.IAttribute; +import net.minecraft.entity.ai.attributes.IAttributeInstance; +import net.minecraft.entity.ai.attributes.RangedAttribute; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.inventory.AnimalChest; +import net.minecraft.inventory.IInvBasic; +import net.minecraft.inventory.InventoryBasic; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.pathfinding.PathEntity; +import net.minecraft.potion.Potion; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +public class EntityHorse extends EntityAnimal implements IInvBasic +{ + private static final IEntitySelector horseBreedingSelector = new IEntitySelector() + { + private static final String __OBFID = "CL_00001642"; + public boolean isEntityApplicable(Entity par1Entity) + { + return par1Entity instanceof EntityHorse && ((EntityHorse)par1Entity).func_110205_ce(); + } + }; + private static final IAttribute horseJumpStrength = (new RangedAttribute("horse.jumpStrength", 0.7D, 0.0D, 2.0D)).setDescription("Jump Strength").setShouldWatch(true); + private static final String[] horseArmorTextures = new String[] {null, "textures/entity/horse/armor/horse_armor_iron.png", "textures/entity/horse/armor/horse_armor_gold.png", "textures/entity/horse/armor/horse_armor_diamond.png"}; + private static final String[] field_110273_bx = new String[] {"", "meo", "goo", "dio"}; + private static final int[] armorValues = new int[] {0, 5, 7, 11}; + private static final String[] horseTextures = new String[] {"textures/entity/horse/horse_white.png", "textures/entity/horse/horse_creamy.png", "textures/entity/horse/horse_chestnut.png", "textures/entity/horse/horse_brown.png", "textures/entity/horse/horse_black.png", "textures/entity/horse/horse_gray.png", "textures/entity/horse/horse_darkbrown.png"}; + private static final String[] field_110269_bA = new String[] {"hwh", "hcr", "hch", "hbr", "hbl", "hgr", "hdb"}; + private static final String[] horseMarkingTextures = new String[] {null, "textures/entity/horse/horse_markings_white.png", "textures/entity/horse/horse_markings_whitefield.png", "textures/entity/horse/horse_markings_whitedots.png", "textures/entity/horse/horse_markings_blackdots.png"}; + private static final String[] field_110292_bC = new String[] {"", "wo_", "wmo", "wdo", "bdo"}; + private int eatingHaystackCounter; + private int openMouthCounter; + private int jumpRearingCounter; + public int field_110278_bp; + public int field_110279_bq; + protected boolean horseJumping; + private AnimalChest horseChest; + private boolean hasReproduced; + protected int temper; + protected float jumpPower; + private boolean field_110294_bI; + private float headLean; + private float prevHeadLean; + private float rearingAmount; + private float prevRearingAmount; + private float mouthOpenness; + private float prevMouthOpenness; + private int field_110285_bP; + private String field_110286_bQ; + private String[] field_110280_bR = new String[3]; + private static final String __OBFID = "CL_00001641"; + + public EntityHorse(World par1World) + { + super(par1World); + this.setSize(1.4F, 1.6F); + this.isImmuneToFire = false; + this.setChested(false); + this.getNavigator().setAvoidsWater(true); + this.tasks.addTask(0, new EntityAISwimming(this)); + this.tasks.addTask(1, new EntityAIPanic(this, 1.2D)); + this.tasks.addTask(1, new EntityAIRunAroundLikeCrazy(this, 1.2D)); + this.tasks.addTask(2, new EntityAIMate(this, 1.0D)); + this.tasks.addTask(4, new EntityAIFollowParent(this, 1.0D)); + this.tasks.addTask(6, new EntityAIWander(this, 0.7D)); + this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F)); + this.tasks.addTask(8, new EntityAILookIdle(this)); + this.func_110226_cD(); + } + + protected void entityInit() + { + super.entityInit(); + this.dataWatcher.addObject(16, Integer.valueOf(0)); + this.dataWatcher.addObject(19, Byte.valueOf((byte)0)); + this.dataWatcher.addObject(20, Integer.valueOf(0)); + this.dataWatcher.addObject(21, String.valueOf("")); + this.dataWatcher.addObject(22, Integer.valueOf(0)); + } + + public void setHorseType(int par1) + { + this.dataWatcher.updateObject(19, Byte.valueOf((byte)par1)); + this.func_110230_cF(); + } + + public int getHorseType() + { + return this.dataWatcher.getWatchableObjectByte(19); + } + + public void setHorseVariant(int par1) + { + this.dataWatcher.updateObject(20, Integer.valueOf(par1)); + this.func_110230_cF(); + } + + public int getHorseVariant() + { + return this.dataWatcher.getWatchableObjectInt(20); + } + + public String getCommandSenderName() + { + if (this.hasCustomNameTag()) + { + return this.getCustomNameTag(); + } + else + { + int i = this.getHorseType(); + + switch (i) + { + case 0: + default: + return StatCollector.translateToLocal("entity.horse.name"); + case 1: + return StatCollector.translateToLocal("entity.donkey.name"); + case 2: + return StatCollector.translateToLocal("entity.mule.name"); + case 3: + return StatCollector.translateToLocal("entity.zombiehorse.name"); + case 4: + return StatCollector.translateToLocal("entity.skeletonhorse.name"); + } + } + } + + private boolean getHorseWatchableBoolean(int par1) + { + return (this.dataWatcher.getWatchableObjectInt(16) & par1) != 0; + } + + private void setHorseWatchableBoolean(int par1, boolean par2) + { + int j = this.dataWatcher.getWatchableObjectInt(16); + + if (par2) + { + this.dataWatcher.updateObject(16, Integer.valueOf(j | par1)); + } + else + { + this.dataWatcher.updateObject(16, Integer.valueOf(j & ~par1)); + } + } + + public boolean isAdultHorse() + { + return !this.isChild(); + } + + public boolean isTame() + { + return this.getHorseWatchableBoolean(2); + } + + public boolean func_110253_bW() + { + return this.isAdultHorse(); + } + + public String getOwnerName() + { + return this.dataWatcher.getWatchableObjectString(21); + } + + public void setOwnerName(String par1Str) + { + this.dataWatcher.updateObject(21, par1Str); + } + + public float getHorseSize() + { + int i = this.getGrowingAge(); + return i >= 0 ? 1.0F : 0.5F + (float)(-24000 - i) / -24000.0F * 0.5F; + } + + public void setScaleForAge(boolean par1) + { + if (par1) + { + this.setScale(this.getHorseSize()); + } + else + { + this.setScale(1.0F); + } + } + + public boolean isHorseJumping() + { + return this.horseJumping; + } + + public void setHorseTamed(boolean par1) + { + this.setHorseWatchableBoolean(2, par1); + } + + public void setHorseJumping(boolean par1) + { + this.horseJumping = par1; + } + + public boolean allowLeashing() + { + return !this.func_110256_cu() && super.allowLeashing(); + } + + protected void func_142017_o(float par1) + { + if (par1 > 6.0F && this.isEatingHaystack()) + { + this.setEatingHaystack(false); + } + } + + public boolean isChested() + { + return this.getHorseWatchableBoolean(8); + } + + public int func_110241_cb() + { + return this.dataWatcher.getWatchableObjectInt(22); + } + + private int getHorseArmorIndex(ItemStack par1ItemStack) + { + if (par1ItemStack == null) + { + return 0; + } + else + { + Item item = par1ItemStack.getItem(); + return item == Items.iron_horse_armor ? 1 : (item == Items.golden_horse_armor ? 2 : (item == Items.diamond_horse_armor ? 3 : 0)); + } + } + + public boolean isEatingHaystack() + { + return this.getHorseWatchableBoolean(32); + } + + public boolean isRearing() + { + return this.getHorseWatchableBoolean(64); + } + + public boolean func_110205_ce() + { + return this.getHorseWatchableBoolean(16); + } + + public boolean getHasReproduced() + { + return this.hasReproduced; + } + + public void func_146086_d(ItemStack p_146086_1_) + { + this.dataWatcher.updateObject(22, Integer.valueOf(this.getHorseArmorIndex(p_146086_1_))); + this.func_110230_cF(); + } + + public void func_110242_l(boolean par1) + { + this.setHorseWatchableBoolean(16, par1); + } + + public void setChested(boolean par1) + { + this.setHorseWatchableBoolean(8, par1); + } + + public void setHasReproduced(boolean par1) + { + this.hasReproduced = par1; + } + + public void setHorseSaddled(boolean par1) + { + this.setHorseWatchableBoolean(4, par1); + } + + public int getTemper() + { + return this.temper; + } + + public void setTemper(int par1) + { + this.temper = par1; + } + + public int increaseTemper(int par1) + { + int j = MathHelper.clamp_int(this.getTemper() + par1, 0, this.getMaxTemper()); + this.setTemper(j); + return j; + } + + public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) + { + Entity entity = par1DamageSource.getEntity(); + return this.riddenByEntity != null && this.riddenByEntity.equals(entity) ? false : super.attackEntityFrom(par1DamageSource, par2); + } + + public int getTotalArmorValue() + { + return armorValues[this.func_110241_cb()]; + } + + public boolean canBePushed() + { + return this.riddenByEntity == null; + } + + public boolean prepareChunkForSpawn() + { + int i = MathHelper.floor_double(this.posX); + int j = MathHelper.floor_double(this.posZ); + this.worldObj.getBiomeGenForCoords(i, j); + return true; + } + + public void dropChests() + { + if (!this.worldObj.isRemote && this.isChested()) + { + this.dropItem(Item.getItemFromBlock(Blocks.chest), 1); + this.setChested(false); + } + } + + private void func_110266_cB() + { + this.openHorseMouth(); + this.worldObj.playSoundAtEntity(this, "eating", 1.0F, 1.0F + (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F); + } + + protected void fall(float par1) + { + if (par1 > 1.0F) + { + this.playSound("mob.horse.land", 0.4F, 1.0F); + } + + int i = MathHelper.ceiling_float_int(par1 * 0.5F - 3.0F); + + if (i > 0) + { + this.attackEntityFrom(DamageSource.fall, (float)i); + + if (this.riddenByEntity != null) + { + this.riddenByEntity.attackEntityFrom(DamageSource.fall, (float)i); + } + + Block block = this.worldObj.getBlock(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY - 0.2D - (double)this.prevRotationYaw), MathHelper.floor_double(this.posZ)); + + if (block.getMaterial() != Material.air) + { + Block.SoundType soundtype = block.stepSound; + this.worldObj.playSoundAtEntity(this, soundtype.getStepResourcePath(), soundtype.getVolume() * 0.5F, soundtype.getPitch() * 0.75F); + } + } + } + + private int func_110225_cC() + { + int i = this.getHorseType(); + return this.isChested() && (i == 1 || i == 2) ? 17 : 2; + } + + private void func_110226_cD() + { + AnimalChest animalchest = this.horseChest; + this.horseChest = new AnimalChest("HorseChest", this.func_110225_cC()); + this.horseChest.func_110133_a(this.getCommandSenderName()); + + if (animalchest != null) + { + animalchest.func_110132_b(this); + int i = Math.min(animalchest.getSizeInventory(), this.horseChest.getSizeInventory()); + + for (int j = 0; j < i; ++j) + { + ItemStack itemstack = animalchest.getStackInSlot(j); + + if (itemstack != null) + { + this.horseChest.setInventorySlotContents(j, itemstack.copy()); + } + } + + animalchest = null; + } + + this.horseChest.func_110134_a(this); + this.func_110232_cE(); + } + + private void func_110232_cE() + { + if (!this.worldObj.isRemote) + { + this.setHorseSaddled(this.horseChest.getStackInSlot(0) != null); + + if (this.func_110259_cr()) + { + this.func_146086_d(this.horseChest.getStackInSlot(1)); + } + } + } + + public void onInventoryChanged(InventoryBasic par1InventoryBasic) + { + int i = this.func_110241_cb(); + boolean flag = this.isHorseSaddled(); + this.func_110232_cE(); + + if (this.ticksExisted > 20) + { + if (i == 0 && i != this.func_110241_cb()) + { + this.playSound("mob.horse.armor", 0.5F, 1.0F); + } + else if (i != this.func_110241_cb()) + { + this.playSound("mob.horse.armor", 0.5F, 1.0F); + } + + if (!flag && this.isHorseSaddled()) + { + this.playSound("mob.horse.leather", 0.5F, 1.0F); + } + } + } + + public boolean getCanSpawnHere() + { + this.prepareChunkForSpawn(); + return super.getCanSpawnHere(); + } + + protected EntityHorse getClosestHorse(Entity par1Entity, double par2) + { + double d1 = Double.MAX_VALUE; + Entity entity1 = null; + List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(par1Entity, par1Entity.boundingBox.addCoord(par2, par2, par2), horseBreedingSelector); + Iterator iterator = list.iterator(); + + while (iterator.hasNext()) + { + Entity entity2 = (Entity)iterator.next(); + double d2 = entity2.getDistanceSq(par1Entity.posX, par1Entity.posY, par1Entity.posZ); + + if (d2 < d1) + { + entity1 = entity2; + d1 = d2; + } + } + + return (EntityHorse)entity1; + } + + public double getHorseJumpStrength() + { + return this.getEntityAttribute(horseJumpStrength).getAttributeValue(); + } + + protected String getDeathSound() + { + this.openHorseMouth(); + int i = this.getHorseType(); + return i == 3 ? "mob.horse.zombie.death" : (i == 4 ? "mob.horse.skeleton.death" : (i != 1 && i != 2 ? "mob.horse.death" : "mob.horse.donkey.death")); + } + + protected Item getDropItem() + { + boolean flag = this.rand.nextInt(4) == 0; + int i = this.getHorseType(); + return i == 4 ? Items.bone : (i == 3 ? (flag ? Item.getItemById(0) : Items.rotten_flesh) : Items.leather); + } + + protected String getHurtSound() + { + this.openHorseMouth(); + + if (this.rand.nextInt(3) == 0) + { + this.makeHorseRear(); + } + + int i = this.getHorseType(); + return i == 3 ? "mob.horse.zombie.hit" : (i == 4 ? "mob.horse.skeleton.hit" : (i != 1 && i != 2 ? "mob.horse.hit" : "mob.horse.donkey.hit")); + } + + public boolean isHorseSaddled() + { + return this.getHorseWatchableBoolean(4); + } + + protected String getLivingSound() + { + this.openHorseMouth(); + + if (this.rand.nextInt(10) == 0 && !this.isMovementBlocked()) + { + this.makeHorseRear(); + } + + int i = this.getHorseType(); + return i == 3 ? "mob.horse.zombie.idle" : (i == 4 ? "mob.horse.skeleton.idle" : (i != 1 && i != 2 ? "mob.horse.idle" : "mob.horse.donkey.idle")); + } + + protected String getAngrySoundName() + { + this.openHorseMouth(); + this.makeHorseRear(); + int i = this.getHorseType(); + return i != 3 && i != 4 ? (i != 1 && i != 2 ? "mob.horse.angry" : "mob.horse.donkey.angry") : null; + } + + protected void func_145780_a(int p_145780_1_, int p_145780_2_, int p_145780_3_, Block p_145780_4_) + { + Block.SoundType soundtype = p_145780_4_.stepSound; + + if (this.worldObj.getBlock(p_145780_1_, p_145780_2_ + 1, p_145780_3_) == Blocks.snow_layer) + { + soundtype = Blocks.snow_layer.stepSound; + } + + if (!p_145780_4_.getMaterial().isLiquid()) + { + int l = this.getHorseType(); + + if (this.riddenByEntity != null && l != 1 && l != 2) + { + ++this.field_110285_bP; + + if (this.field_110285_bP > 5 && this.field_110285_bP % 3 == 0) + { + this.playSound("mob.horse.gallop", soundtype.getVolume() * 0.15F, soundtype.getPitch()); + + if (l == 0 && this.rand.nextInt(10) == 0) + { + this.playSound("mob.horse.breathe", soundtype.getVolume() * 0.6F, soundtype.getPitch()); + } + } + else if (this.field_110285_bP <= 5) + { + this.playSound("mob.horse.wood", soundtype.getVolume() * 0.15F, soundtype.getPitch()); + } + } + else if (soundtype == Block.soundTypeWood) + { + this.playSound("mob.horse.wood", soundtype.getVolume() * 0.15F, soundtype.getPitch()); + } + else + { + this.playSound("mob.horse.soft", soundtype.getVolume() * 0.15F, soundtype.getPitch()); + } + } + } + + protected void applyEntityAttributes() + { + super.applyEntityAttributes(); + this.getAttributeMap().registerAttribute(horseJumpStrength); + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(53.0D); + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.22499999403953552D); + } + + public int getMaxSpawnedInChunk() + { + return 6; + } + + public int getMaxTemper() + { + return 100; + } + + protected float getSoundVolume() + { + return 0.8F; + } + + public int getTalkInterval() + { + return 400; + } + + @SideOnly(Side.CLIENT) + public boolean func_110239_cn() + { + return this.getHorseType() == 0 || this.func_110241_cb() > 0; + } + + private void func_110230_cF() + { + this.field_110286_bQ = null; + } + + @SideOnly(Side.CLIENT) + private void setHorseTexturePaths() + { + this.field_110286_bQ = "horse/"; + this.field_110280_bR[0] = null; + this.field_110280_bR[1] = null; + this.field_110280_bR[2] = null; + int i = this.getHorseType(); + int j = this.getHorseVariant(); + int k; + + if (i == 0) + { + k = j & 255; + int l = (j & 65280) >> 8; + this.field_110280_bR[0] = horseTextures[k]; + this.field_110286_bQ = this.field_110286_bQ + field_110269_bA[k]; + this.field_110280_bR[1] = horseMarkingTextures[l]; + this.field_110286_bQ = this.field_110286_bQ + field_110292_bC[l]; + } + else + { + this.field_110280_bR[0] = ""; + this.field_110286_bQ = this.field_110286_bQ + "_" + i + "_"; + } + + k = this.func_110241_cb(); + this.field_110280_bR[2] = horseArmorTextures[k]; + this.field_110286_bQ = this.field_110286_bQ + field_110273_bx[k]; + } + + @SideOnly(Side.CLIENT) + public String getHorseTexture() + { + if (this.field_110286_bQ == null) + { + this.setHorseTexturePaths(); + } + + return this.field_110286_bQ; + } + + @SideOnly(Side.CLIENT) + public String[] getVariantTexturePaths() + { + if (this.field_110286_bQ == null) + { + this.setHorseTexturePaths(); + } + + return this.field_110280_bR; + } + + public void openGUI(EntityPlayer par1EntityPlayer) + { + if (!this.worldObj.isRemote && (this.riddenByEntity == null || this.riddenByEntity == par1EntityPlayer) && this.isTame()) + { + this.horseChest.func_110133_a(this.getCommandSenderName()); + par1EntityPlayer.displayGUIHorse(this, this.horseChest); + } + } + + public boolean interact(EntityPlayer par1EntityPlayer) + { + ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem(); + + if (itemstack != null && itemstack.getItem() == Items.spawn_egg) + { + return super.interact(par1EntityPlayer); + } + else if (!this.isTame() && this.func_110256_cu()) + { + return false; + } + else if (this.isTame() && this.isAdultHorse() && par1EntityPlayer.isSneaking()) + { + this.openGUI(par1EntityPlayer); + return true; + } + else if (this.func_110253_bW() && this.riddenByEntity != null) + { + return super.interact(par1EntityPlayer); + } + else + { + if (itemstack != null) + { + boolean flag = false; + + if (this.func_110259_cr()) + { + byte b0 = -1; + + if (itemstack.getItem() == Items.iron_horse_armor) + { + b0 = 1; + } + else if (itemstack.getItem() == Items.golden_horse_armor) + { + b0 = 2; + } + else if (itemstack.getItem() == Items.diamond_horse_armor) + { + b0 = 3; + } + + if (b0 >= 0) + { + if (!this.isTame()) + { + this.makeHorseRearWithSound(); + return true; + } + + this.openGUI(par1EntityPlayer); + return true; + } + } + + if (!flag && !this.func_110256_cu()) + { + float f = 0.0F; + short short1 = 0; + byte b1 = 0; + + if (itemstack.getItem() == Items.wheat) + { + f = 2.0F; + short1 = 60; + b1 = 3; + } + else if (itemstack.getItem() == Items.sugar) + { + f = 1.0F; + short1 = 30; + b1 = 3; + } + else if (itemstack.getItem() == Items.bread) + { + f = 7.0F; + short1 = 180; + b1 = 3; + } + else if (Block.getBlockFromItem(itemstack.getItem()) == Blocks.hay_block) + { + f = 20.0F; + short1 = 180; + } + else if (itemstack.getItem() == Items.apple) + { + f = 3.0F; + short1 = 60; + b1 = 3; + } + else if (itemstack.getItem() == Items.golden_carrot) + { + f = 4.0F; + short1 = 60; + b1 = 5; + + if (this.isTame() && this.getGrowingAge() == 0) + { + flag = true; + this.func_146082_f(par1EntityPlayer); + } + } + else if (itemstack.getItem() == Items.golden_apple) + { + f = 10.0F; + short1 = 240; + b1 = 10; + + if (this.isTame() && this.getGrowingAge() == 0) + { + flag = true; + this.func_146082_f(par1EntityPlayer); + } + } + + if (this.getHealth() < this.getMaxHealth() && f > 0.0F) + { + this.heal(f); + flag = true; + } + + if (!this.isAdultHorse() && short1 > 0) + { + this.addGrowth(short1); + flag = true; + } + + if (b1 > 0 && (flag || !this.isTame()) && b1 < this.getMaxTemper()) + { + flag = true; + this.increaseTemper(b1); + } + + if (flag) + { + this.func_110266_cB(); + } + } + + if (!this.isTame() && !flag) + { + if (itemstack != null && itemstack.interactWithEntity(par1EntityPlayer, this)) + { + return true; + } + + this.makeHorseRearWithSound(); + return true; + } + + if (!flag && this.func_110229_cs() && !this.isChested() && itemstack.getItem() == Item.getItemFromBlock(Blocks.chest)) + { + this.setChested(true); + this.playSound("mob.chickenplop", 1.0F, (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F); + flag = true; + this.func_110226_cD(); + } + + if (!flag && this.func_110253_bW() && !this.isHorseSaddled() && itemstack.getItem() == Items.saddle) + { + this.openGUI(par1EntityPlayer); + return true; + } + + if (flag) + { + if (!par1EntityPlayer.capabilities.isCreativeMode && --itemstack.stackSize == 0) + { + par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack)null); + } + + return true; + } + } + + if (this.func_110253_bW() && this.riddenByEntity == null) + { + if (itemstack != null && itemstack.interactWithEntity(par1EntityPlayer, this)) + { + return true; + } + else + { + this.func_110237_h(par1EntityPlayer); + return true; + } + } + else + { + return super.interact(par1EntityPlayer); + } + } + } + + private void func_110237_h(EntityPlayer par1EntityPlayer) + { + par1EntityPlayer.rotationYaw = this.rotationYaw; + par1EntityPlayer.rotationPitch = this.rotationPitch; + this.setEatingHaystack(false); + this.setRearing(false); + + if (!this.worldObj.isRemote) + { + par1EntityPlayer.mountEntity(this); + } + } + + public boolean func_110259_cr() + { + return this.getHorseType() == 0; + } + + public boolean func_110229_cs() + { + int i = this.getHorseType(); + return i == 2 || i == 1; + } + + protected boolean isMovementBlocked() + { + return this.riddenByEntity != null && this.isHorseSaddled() ? true : this.isEatingHaystack() || this.isRearing(); + } + + public boolean func_110256_cu() + { + int i = this.getHorseType(); + return i == 3 || i == 4; + } + + public boolean func_110222_cv() + { + return this.func_110256_cu() || this.getHorseType() == 2; + } + + public boolean isBreedingItem(ItemStack par1ItemStack) + { + return false; + } + + private void func_110210_cH() + { + this.field_110278_bp = 1; + } + + public void onDeath(DamageSource par1DamageSource) + { + super.onDeath(par1DamageSource); + + if (!this.worldObj.isRemote) + { + this.dropChestItems(); + } + } + + public void onLivingUpdate() + { + if (this.rand.nextInt(200) == 0) + { + this.func_110210_cH(); + } + + super.onLivingUpdate(); + + if (!this.worldObj.isRemote) + { + if (this.rand.nextInt(900) == 0 && this.deathTime == 0) + { + this.heal(1.0F); + } + + if (!this.isEatingHaystack() && this.riddenByEntity == null && this.rand.nextInt(300) == 0 && this.worldObj.getBlock(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY) - 1, MathHelper.floor_double(this.posZ)) == Blocks.grass) + { + this.setEatingHaystack(true); + } + + if (this.isEatingHaystack() && ++this.eatingHaystackCounter > 50) + { + this.eatingHaystackCounter = 0; + this.setEatingHaystack(false); + } + + if (this.func_110205_ce() && !this.isAdultHorse() && !this.isEatingHaystack()) + { + EntityHorse entityhorse = this.getClosestHorse(this, 16.0D); + + if (entityhorse != null && this.getDistanceSqToEntity(entityhorse) > 4.0D) + { + PathEntity pathentity = this.worldObj.getPathEntityToEntity(this, entityhorse, 16.0F, true, false, false, true); + this.setPathToEntity(pathentity); + } + } + } + } + + public void onUpdate() + { + super.onUpdate(); + + if (this.worldObj.isRemote && this.dataWatcher.hasChanges()) + { + this.dataWatcher.func_111144_e(); + this.func_110230_cF(); + } + + if (this.openMouthCounter > 0 && ++this.openMouthCounter > 30) + { + this.openMouthCounter = 0; + this.setHorseWatchableBoolean(128, false); + } + + if (!this.worldObj.isRemote && this.jumpRearingCounter > 0 && ++this.jumpRearingCounter > 20) + { + this.jumpRearingCounter = 0; + this.setRearing(false); + } + + if (this.field_110278_bp > 0 && ++this.field_110278_bp > 8) + { + this.field_110278_bp = 0; + } + + if (this.field_110279_bq > 0) + { + ++this.field_110279_bq; + + if (this.field_110279_bq > 300) + { + this.field_110279_bq = 0; + } + } + + this.prevHeadLean = this.headLean; + + if (this.isEatingHaystack()) + { + this.headLean += (1.0F - this.headLean) * 0.4F + 0.05F; + + if (this.headLean > 1.0F) + { + this.headLean = 1.0F; + } + } + else + { + this.headLean += (0.0F - this.headLean) * 0.4F - 0.05F; + + if (this.headLean < 0.0F) + { + this.headLean = 0.0F; + } + } + + this.prevRearingAmount = this.rearingAmount; + + if (this.isRearing()) + { + this.prevHeadLean = this.headLean = 0.0F; + this.rearingAmount += (1.0F - this.rearingAmount) * 0.4F + 0.05F; + + if (this.rearingAmount > 1.0F) + { + this.rearingAmount = 1.0F; + } + } + else + { + this.field_110294_bI = false; + this.rearingAmount += (0.8F * this.rearingAmount * this.rearingAmount * this.rearingAmount - this.rearingAmount) * 0.6F - 0.05F; + + if (this.rearingAmount < 0.0F) + { + this.rearingAmount = 0.0F; + } + } + + this.prevMouthOpenness = this.mouthOpenness; + + if (this.getHorseWatchableBoolean(128)) + { + this.mouthOpenness += (1.0F - this.mouthOpenness) * 0.7F + 0.05F; + + if (this.mouthOpenness > 1.0F) + { + this.mouthOpenness = 1.0F; + } + } + else + { + this.mouthOpenness += (0.0F - this.mouthOpenness) * 0.7F - 0.05F; + + if (this.mouthOpenness < 0.0F) + { + this.mouthOpenness = 0.0F; + } + } + } + + private void openHorseMouth() + { + if (!this.worldObj.isRemote) + { + this.openMouthCounter = 1; + this.setHorseWatchableBoolean(128, true); + } + } + + private boolean func_110200_cJ() + { + return this.riddenByEntity == null && this.ridingEntity == null && this.isTame() && this.isAdultHorse() && !this.func_110222_cv() && this.getHealth() >= this.getMaxHealth(); + } + + public void setEating(boolean par1) + { + this.setHorseWatchableBoolean(32, par1); + } + + public void setEatingHaystack(boolean par1) + { + this.setEating(par1); + } + + public void setRearing(boolean par1) + { + if (par1) + { + this.setEatingHaystack(false); + } + + this.setHorseWatchableBoolean(64, par1); + } + + private void makeHorseRear() + { + if (!this.worldObj.isRemote) + { + this.jumpRearingCounter = 1; + this.setRearing(true); + } + } + + public void makeHorseRearWithSound() + { + this.makeHorseRear(); + String s = this.getAngrySoundName(); + + if (s != null) + { + this.playSound(s, this.getSoundVolume(), this.getSoundPitch()); + } + } + + public void dropChestItems() + { + this.dropItemsInChest(this, this.horseChest); + this.dropChests(); + } + + private void dropItemsInChest(Entity par1Entity, AnimalChest par2AnimalChest) + { + if (par2AnimalChest != null && !this.worldObj.isRemote) + { + for (int i = 0; i < par2AnimalChest.getSizeInventory(); ++i) + { + ItemStack itemstack = par2AnimalChest.getStackInSlot(i); + + if (itemstack != null) + { + this.entityDropItem(itemstack, 0.0F); + } + } + } + } + + public boolean setTamedBy(EntityPlayer par1EntityPlayer) + { + this.setOwnerName(par1EntityPlayer.getCommandSenderName()); + this.setHorseTamed(true); + return true; + } + + public void moveEntityWithHeading(float par1, float par2) + { + if (this.riddenByEntity != null && this.isHorseSaddled()) + { + this.prevRotationYaw = this.rotationYaw = this.riddenByEntity.rotationYaw; + this.rotationPitch = this.riddenByEntity.rotationPitch * 0.5F; + this.setRotation(this.rotationYaw, this.rotationPitch); + this.rotationYawHead = this.renderYawOffset = this.rotationYaw; + par1 = ((EntityLivingBase)this.riddenByEntity).moveStrafing * 0.5F; + par2 = ((EntityLivingBase)this.riddenByEntity).moveForward; + + if (par2 <= 0.0F) + { + par2 *= 0.25F; + this.field_110285_bP = 0; + } + + if (this.onGround && this.jumpPower == 0.0F && this.isRearing() && !this.field_110294_bI) + { + par1 = 0.0F; + par2 = 0.0F; + } + + if (this.jumpPower > 0.0F && !this.isHorseJumping() && this.onGround) + { + this.motionY = this.getHorseJumpStrength() * (double)this.jumpPower; + + if (this.isPotionActive(Potion.jump)) + { + this.motionY += (double)((float)(this.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F); + } + + this.setHorseJumping(true); + this.isAirBorne = true; + + if (par2 > 0.0F) + { + float f2 = MathHelper.sin(this.rotationYaw * (float)Math.PI / 180.0F); + float f3 = MathHelper.cos(this.rotationYaw * (float)Math.PI / 180.0F); + this.motionX += (double)(-0.4F * f2 * this.jumpPower); + this.motionZ += (double)(0.4F * f3 * this.jumpPower); + this.playSound("mob.horse.jump", 0.4F, 1.0F); + } + + this.jumpPower = 0.0F; + } + + this.stepHeight = 1.0F; + this.jumpMovementFactor = this.getAIMoveSpeed() * 0.1F; + + if (!this.worldObj.isRemote) + { + this.setAIMoveSpeed((float)this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue()); + super.moveEntityWithHeading(par1, par2); + } + + if (this.onGround) + { + this.jumpPower = 0.0F; + this.setHorseJumping(false); + } + + this.prevLimbSwingAmount = this.limbSwingAmount; + double d1 = this.posX - this.prevPosX; + double d0 = this.posZ - this.prevPosZ; + float f4 = MathHelper.sqrt_double(d1 * d1 + d0 * d0) * 4.0F; + + if (f4 > 1.0F) + { + f4 = 1.0F; + } + + this.limbSwingAmount += (f4 - this.limbSwingAmount) * 0.4F; + this.limbSwing += this.limbSwingAmount; + } + else + { + this.stepHeight = 0.5F; + this.jumpMovementFactor = 0.02F; + super.moveEntityWithHeading(par1, par2); + } + } + + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeEntityToNBT(par1NBTTagCompound); + par1NBTTagCompound.setBoolean("EatingHaystack", this.isEatingHaystack()); + par1NBTTagCompound.setBoolean("ChestedHorse", this.isChested()); + par1NBTTagCompound.setBoolean("HasReproduced", this.getHasReproduced()); + par1NBTTagCompound.setBoolean("Bred", this.func_110205_ce()); + par1NBTTagCompound.setInteger("Type", this.getHorseType()); + par1NBTTagCompound.setInteger("Variant", this.getHorseVariant()); + par1NBTTagCompound.setInteger("Temper", this.getTemper()); + par1NBTTagCompound.setBoolean("Tame", this.isTame()); + par1NBTTagCompound.setString("OwnerName", this.getOwnerName()); + + if (this.isChested()) + { + NBTTagList nbttaglist = new NBTTagList(); + + for (int i = 2; i < this.horseChest.getSizeInventory(); ++i) + { + ItemStack itemstack = this.horseChest.getStackInSlot(i); + + if (itemstack != null) + { + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + nbttagcompound1.setByte("Slot", (byte)i); + itemstack.writeToNBT(nbttagcompound1); + nbttaglist.appendTag(nbttagcompound1); + } + } + + par1NBTTagCompound.setTag("Items", nbttaglist); + } + + if (this.horseChest.getStackInSlot(1) != null) + { + par1NBTTagCompound.setTag("ArmorItem", this.horseChest.getStackInSlot(1).writeToNBT(new NBTTagCompound())); + } + + if (this.horseChest.getStackInSlot(0) != null) + { + par1NBTTagCompound.setTag("SaddleItem", this.horseChest.getStackInSlot(0).writeToNBT(new NBTTagCompound())); + } + } + + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + super.readEntityFromNBT(par1NBTTagCompound); + this.setEatingHaystack(par1NBTTagCompound.getBoolean("EatingHaystack")); + this.func_110242_l(par1NBTTagCompound.getBoolean("Bred")); + this.setChested(par1NBTTagCompound.getBoolean("ChestedHorse")); + this.setHasReproduced(par1NBTTagCompound.getBoolean("HasReproduced")); + this.setHorseType(par1NBTTagCompound.getInteger("Type")); + this.setHorseVariant(par1NBTTagCompound.getInteger("Variant")); + this.setTemper(par1NBTTagCompound.getInteger("Temper")); + this.setHorseTamed(par1NBTTagCompound.getBoolean("Tame")); + + if (par1NBTTagCompound.hasKey("OwnerName", 8)) + { + this.setOwnerName(par1NBTTagCompound.getString("OwnerName")); + } + + IAttributeInstance iattributeinstance = this.getAttributeMap().getAttributeInstanceByName("Speed"); + + if (iattributeinstance != null) + { + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(iattributeinstance.getBaseValue() * 0.25D); + } + + if (this.isChested()) + { + NBTTagList nbttaglist = par1NBTTagCompound.getTagList("Items", 10); + this.func_110226_cD(); + + for (int i = 0; i < nbttaglist.tagCount(); ++i) + { + NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); + int j = nbttagcompound1.getByte("Slot") & 255; + + if (j >= 2 && j < this.horseChest.getSizeInventory()) + { + this.horseChest.setInventorySlotContents(j, ItemStack.loadItemStackFromNBT(nbttagcompound1)); + } + } + } + + ItemStack itemstack; + + if (par1NBTTagCompound.hasKey("ArmorItem", 10)) + { + itemstack = ItemStack.loadItemStackFromNBT(par1NBTTagCompound.getCompoundTag("ArmorItem")); + + if (itemstack != null && func_146085_a(itemstack.getItem())) + { + this.horseChest.setInventorySlotContents(1, itemstack); + } + } + + if (par1NBTTagCompound.hasKey("SaddleItem", 10)) + { + itemstack = ItemStack.loadItemStackFromNBT(par1NBTTagCompound.getCompoundTag("SaddleItem")); + + if (itemstack != null && itemstack.getItem() == Items.saddle) + { + this.horseChest.setInventorySlotContents(0, itemstack); + } + } + else if (par1NBTTagCompound.getBoolean("Saddle")) + { + this.horseChest.setInventorySlotContents(0, new ItemStack(Items.saddle)); + } + + this.func_110232_cE(); + } + + public boolean canMateWith(EntityAnimal par1EntityAnimal) + { + if (par1EntityAnimal == this) + { + return false; + } + else if (par1EntityAnimal.getClass() != this.getClass()) + { + return false; + } + else + { + EntityHorse entityhorse = (EntityHorse)par1EntityAnimal; + + if (this.func_110200_cJ() && entityhorse.func_110200_cJ()) + { + int i = this.getHorseType(); + int j = entityhorse.getHorseType(); + return i == j || i == 0 && j == 1 || i == 1 && j == 0; + } + else + { + return false; + } + } + } + + public EntityAgeable createChild(EntityAgeable par1EntityAgeable) + { + EntityHorse entityhorse = (EntityHorse)par1EntityAgeable; + EntityHorse entityhorse1 = new EntityHorse(this.worldObj); + int i = this.getHorseType(); + int j = entityhorse.getHorseType(); + int k = 0; + + if (i == j) + { + k = i; + } + else if (i == 0 && j == 1 || i == 1 && j == 0) + { + k = 2; + } + + if (k == 0) + { + int i1 = this.rand.nextInt(9); + int l; + + if (i1 < 4) + { + l = this.getHorseVariant() & 255; + } + else if (i1 < 8) + { + l = entityhorse.getHorseVariant() & 255; + } + else + { + l = this.rand.nextInt(7); + } + + int j1 = this.rand.nextInt(5); + + if (j1 < 2) + { + l |= this.getHorseVariant() & 65280; + } + else if (j1 < 4) + { + l |= entityhorse.getHorseVariant() & 65280; + } + else + { + l |= this.rand.nextInt(5) << 8 & 65280; + } + + entityhorse1.setHorseVariant(l); + } + + entityhorse1.setHorseType(k); + double d1 = this.getEntityAttribute(SharedMonsterAttributes.maxHealth).getBaseValue() + par1EntityAgeable.getEntityAttribute(SharedMonsterAttributes.maxHealth).getBaseValue() + (double)this.func_110267_cL(); + entityhorse1.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(d1 / 3.0D); + double d2 = this.getEntityAttribute(horseJumpStrength).getBaseValue() + par1EntityAgeable.getEntityAttribute(horseJumpStrength).getBaseValue() + this.func_110245_cM(); + entityhorse1.getEntityAttribute(horseJumpStrength).setBaseValue(d2 / 3.0D); + double d0 = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getBaseValue() + par1EntityAgeable.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getBaseValue() + this.func_110203_cN(); + entityhorse1.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(d0 / 3.0D); + return entityhorse1; + } + + public IEntityLivingData onSpawnWithEgg(IEntityLivingData par1EntityLivingData) + { + Object p_110161_1_1 = super.onSpawnWithEgg(par1EntityLivingData); + boolean flag = false; + int i = 0; + int l; + + if (p_110161_1_1 instanceof EntityHorse.GroupData) + { + l = ((EntityHorse.GroupData)p_110161_1_1).field_111107_a; + i = ((EntityHorse.GroupData)p_110161_1_1).field_111106_b & 255 | this.rand.nextInt(5) << 8; + } + else + { + if (this.rand.nextInt(10) == 0) + { + l = 1; + } + else + { + int j = this.rand.nextInt(7); + int k = this.rand.nextInt(5); + l = 0; + i = j | k << 8; + } + + p_110161_1_1 = new EntityHorse.GroupData(l, i); + } + + this.setHorseType(l); + this.setHorseVariant(i); + + if (this.rand.nextInt(5) == 0) + { + this.setGrowingAge(-24000); + } + + if (l != 4 && l != 3) + { + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue((double)this.func_110267_cL()); + + if (l == 0) + { + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(this.func_110203_cN()); + } + else + { + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.17499999701976776D); + } + } + else + { + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(15.0D); + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.20000000298023224D); + } + + if (l != 2 && l != 1) + { + this.getEntityAttribute(horseJumpStrength).setBaseValue(this.func_110245_cM()); + } + else + { + this.getEntityAttribute(horseJumpStrength).setBaseValue(0.5D); + } + + this.setHealth(this.getMaxHealth()); + return (IEntityLivingData)p_110161_1_1; + } + + @SideOnly(Side.CLIENT) + public float getGrassEatingAmount(float par1) + { + return this.prevHeadLean + (this.headLean - this.prevHeadLean) * par1; + } + + @SideOnly(Side.CLIENT) + public float getRearingAmount(float par1) + { + return this.prevRearingAmount + (this.rearingAmount - this.prevRearingAmount) * par1; + } + + @SideOnly(Side.CLIENT) + public float func_110201_q(float par1) + { + return this.prevMouthOpenness + (this.mouthOpenness - this.prevMouthOpenness) * par1; + } + + protected boolean isAIEnabled() + { + return true; + } + + public void setJumpPower(int par1) + { + if (this.isHorseSaddled()) + { + if (par1 < 0) + { + par1 = 0; + } + else + { + this.field_110294_bI = true; + this.makeHorseRear(); + } + + if (par1 >= 90) + { + this.jumpPower = 1.0F; + } + else + { + this.jumpPower = 0.4F + 0.4F * (float)par1 / 90.0F; + } + } + } + + @SideOnly(Side.CLIENT) + protected void spawnHorseParticles(boolean par1) + { + String s = par1 ? "heart" : "smoke"; + + for (int i = 0; i < 7; ++i) + { + double d0 = this.rand.nextGaussian() * 0.02D; + double d1 = this.rand.nextGaussian() * 0.02D; + double d2 = this.rand.nextGaussian() * 0.02D; + this.worldObj.spawnParticle(s, this.posX + (double)(this.rand.nextFloat() * this.width * 2.0F) - (double)this.width, this.posY + 0.5D + (double)(this.rand.nextFloat() * this.height), this.posZ + (double)(this.rand.nextFloat() * this.width * 2.0F) - (double)this.width, d0, d1, d2); + } + } + + @SideOnly(Side.CLIENT) + public void handleHealthUpdate(byte par1) + { + if (par1 == 7) + { + this.spawnHorseParticles(true); + } + else if (par1 == 6) + { + this.spawnHorseParticles(false); + } + else + { + super.handleHealthUpdate(par1); + } + } + + public void updateRiderPosition() + { + super.updateRiderPosition(); + + if (this.prevRearingAmount > 0.0F) + { + float f = MathHelper.sin(this.renderYawOffset * (float)Math.PI / 180.0F); + float f1 = MathHelper.cos(this.renderYawOffset * (float)Math.PI / 180.0F); + float f2 = 0.7F * this.prevRearingAmount; + float f3 = 0.15F * this.prevRearingAmount; + this.riddenByEntity.setPosition(this.posX + (double)(f2 * f), this.posY + this.getMountedYOffset() + this.riddenByEntity.getYOffset() + (double)f3, this.posZ - (double)(f2 * f1)); + + if (this.riddenByEntity instanceof EntityLivingBase) + { + ((EntityLivingBase)this.riddenByEntity).renderYawOffset = this.renderYawOffset; + } + } + } + + private float func_110267_cL() + { + return 15.0F + (float)this.rand.nextInt(8) + (float)this.rand.nextInt(9); + } + + private double func_110245_cM() + { + return 0.4000000059604645D + this.rand.nextDouble() * 0.2D + this.rand.nextDouble() * 0.2D + this.rand.nextDouble() * 0.2D; + } + + private double func_110203_cN() + { + return (0.44999998807907104D + this.rand.nextDouble() * 0.3D + this.rand.nextDouble() * 0.3D + this.rand.nextDouble() * 0.3D) * 0.25D; + } + + public static boolean func_146085_a(Item p_146085_0_) + { + return p_146085_0_ == Items.iron_horse_armor || p_146085_0_ == Items.golden_horse_armor || p_146085_0_ == Items.diamond_horse_armor; + } + + public boolean isOnLadder() + { + return false; + } + + public static class GroupData implements IEntityLivingData + { + public int field_111107_a; + public int field_111106_b; + private static final String __OBFID = "CL_00001643"; + + public GroupData(int par1, int par2) + { + this.field_111107_a = par1; + this.field_111106_b = par2; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/passive/EntityMooshroom.java b/src/main/java/net/minecraft/entity/passive/EntityMooshroom.java new file mode 100644 index 0000000..dfbbac3 --- /dev/null +++ b/src/main/java/net/minecraft/entity/passive/EntityMooshroom.java @@ -0,0 +1,79 @@ +package net.minecraft.entity.passive; + +import java.util.ArrayList; + +import net.minecraft.entity.EntityAgeable; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.IShearable; + +public class EntityMooshroom extends EntityCow implements IShearable +{ + private static final String __OBFID = "CL_00001645"; + + public EntityMooshroom(World par1World) + { + super(par1World); + this.setSize(0.9F, 1.3F); + } + + public boolean interact(EntityPlayer par1EntityPlayer) + { + ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem(); + + if (itemstack != null && itemstack.getItem() == Items.bowl && this.getGrowingAge() >= 0) + { + if (itemstack.stackSize == 1) + { + par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, new ItemStack(Items.mushroom_stew)); + return true; + } + + if (par1EntityPlayer.inventory.addItemStackToInventory(new ItemStack(Items.mushroom_stew)) && !par1EntityPlayer.capabilities.isCreativeMode) + { + par1EntityPlayer.inventory.decrStackSize(par1EntityPlayer.inventory.currentItem, 1); + return true; + } + } + + { + return super.interact(par1EntityPlayer); + } + } + + public EntityMooshroom createChild(EntityAgeable par1EntityAgeable) + { + return new EntityMooshroom(this.worldObj); + } + + @Override + public boolean isShearable(ItemStack item, IBlockAccess world, int x, int y, int z) + { + return getGrowingAge() >= 0; + } + + @Override + public ArrayList onSheared(ItemStack item, IBlockAccess world, int x, int y, int z, int fortune) + { + setDead(); + EntityCow entitycow = new EntityCow(worldObj); + entitycow.setLocationAndAngles(posX, posY, posZ, rotationYaw, rotationPitch); + entitycow.setHealth(this.getHealth()); + entitycow.renderYawOffset = renderYawOffset; + worldObj.spawnEntityInWorld(entitycow); + worldObj.spawnParticle("largeexplode", posX, posY + (double)(height / 2.0F), posZ, 0.0D, 0.0D, 0.0D); + + ArrayList ret = new ArrayList(); + for (int i = 0; i < 5; i++) + { + ret.add(new ItemStack(Blocks.red_mushroom)); + } + playSound("mob.sheep.shear", 1.0F, 1.0F); + return ret; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/passive/EntityOcelot.java b/src/main/java/net/minecraft/entity/passive/EntityOcelot.java new file mode 100644 index 0000000..f03b2d8 --- /dev/null +++ b/src/main/java/net/minecraft/entity/passive/EntityOcelot.java @@ -0,0 +1,316 @@ +package net.minecraft.entity.passive; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityAgeable; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.EntityAIAvoidEntity; +import net.minecraft.entity.ai.EntityAIFollowOwner; +import net.minecraft.entity.ai.EntityAILeapAtTarget; +import net.minecraft.entity.ai.EntityAIMate; +import net.minecraft.entity.ai.EntityAIOcelotAttack; +import net.minecraft.entity.ai.EntityAIOcelotSit; +import net.minecraft.entity.ai.EntityAISwimming; +import net.minecraft.entity.ai.EntityAITargetNonTamed; +import net.minecraft.entity.ai.EntityAITempt; +import net.minecraft.entity.ai.EntityAIWander; +import net.minecraft.entity.ai.EntityAIWatchClosest; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +public class EntityOcelot extends EntityTameable +{ + private EntityAITempt aiTempt; + private static final String __OBFID = "CL_00001646"; + + public EntityOcelot(World par1World) + { + super(par1World); + this.setSize(0.6F, 0.8F); + this.getNavigator().setAvoidsWater(true); + this.tasks.addTask(1, new EntityAISwimming(this)); + this.tasks.addTask(2, this.aiSit); + this.tasks.addTask(3, this.aiTempt = new EntityAITempt(this, 0.6D, Items.fish, true)); + this.tasks.addTask(4, new EntityAIAvoidEntity(this, EntityPlayer.class, 16.0F, 0.8D, 1.33D)); + this.tasks.addTask(5, new EntityAIFollowOwner(this, 1.0D, 10.0F, 5.0F)); + this.tasks.addTask(6, new EntityAIOcelotSit(this, 1.33D)); + this.tasks.addTask(7, new EntityAILeapAtTarget(this, 0.3F)); + this.tasks.addTask(8, new EntityAIOcelotAttack(this)); + this.tasks.addTask(9, new EntityAIMate(this, 0.8D)); + this.tasks.addTask(10, new EntityAIWander(this, 0.8D)); + this.tasks.addTask(11, new EntityAIWatchClosest(this, EntityPlayer.class, 10.0F)); + this.targetTasks.addTask(1, new EntityAITargetNonTamed(this, EntityChicken.class, 750, false)); + } + + protected void entityInit() + { + super.entityInit(); + this.dataWatcher.addObject(18, Byte.valueOf((byte)0)); + } + + public void updateAITick() + { + if (this.getMoveHelper().isUpdating()) + { + double d0 = this.getMoveHelper().getSpeed(); + + if (d0 == 0.6D) + { + this.setSneaking(true); + this.setSprinting(false); + } + else if (d0 == 1.33D) + { + this.setSneaking(false); + this.setSprinting(true); + } + else + { + this.setSneaking(false); + this.setSprinting(false); + } + } + else + { + this.setSneaking(false); + this.setSprinting(false); + } + } + + protected boolean canDespawn() + { + return !this.isTamed() && this.ticksExisted > 2400; + } + + public boolean isAIEnabled() + { + return true; + } + + protected void applyEntityAttributes() + { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(10.0D); + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.30000001192092896D); + } + + protected void fall(float par1) {} + + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeEntityToNBT(par1NBTTagCompound); + par1NBTTagCompound.setInteger("CatType", this.getTameSkin()); + } + + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + super.readEntityFromNBT(par1NBTTagCompound); + this.setTameSkin(par1NBTTagCompound.getInteger("CatType")); + } + + protected String getLivingSound() + { + return this.isTamed() ? (this.isInLove() ? "mob.cat.purr" : (this.rand.nextInt(4) == 0 ? "mob.cat.purreow" : "mob.cat.meow")) : ""; + } + + protected String getHurtSound() + { + return "mob.cat.hitt"; + } + + protected String getDeathSound() + { + return "mob.cat.hitt"; + } + + protected float getSoundVolume() + { + return 0.4F; + } + + protected Item getDropItem() + { + return Items.leather; + } + + public boolean attackEntityAsMob(Entity par1Entity) + { + return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), 3.0F); + } + + public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) + { + if (this.isEntityInvulnerable()) + { + return false; + } + else + { + this.aiSit.setSitting(false); + return super.attackEntityFrom(par1DamageSource, par2); + } + } + + protected void dropFewItems(boolean par1, int par2) {} + + public boolean interact(EntityPlayer par1EntityPlayer) + { + ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem(); + + if (this.isTamed()) + { + if (par1EntityPlayer.getCommandSenderName().equalsIgnoreCase(this.getOwnerName()) && !this.worldObj.isRemote && !this.isBreedingItem(itemstack)) + { + this.aiSit.setSitting(!this.isSitting()); + } + } + else if (this.aiTempt.isRunning() && itemstack != null && itemstack.getItem() == Items.fish && par1EntityPlayer.getDistanceSqToEntity(this) < 9.0D) + { + if (!par1EntityPlayer.capabilities.isCreativeMode) + { + --itemstack.stackSize; + } + + if (itemstack.stackSize <= 0) + { + par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack)null); + } + + if (!this.worldObj.isRemote) + { + if (this.rand.nextInt(3) == 0) + { + this.setTamed(true); + this.setTameSkin(1 + this.worldObj.rand.nextInt(3)); + this.setOwner(par1EntityPlayer.getCommandSenderName()); + this.playTameEffect(true); + this.aiSit.setSitting(true); + this.worldObj.setEntityState(this, (byte)7); + } + else + { + this.playTameEffect(false); + this.worldObj.setEntityState(this, (byte)6); + } + } + + return true; + } + + return super.interact(par1EntityPlayer); + } + + public EntityOcelot createChild(EntityAgeable par1EntityAgeable) + { + EntityOcelot entityocelot = new EntityOcelot(this.worldObj); + + if (this.isTamed()) + { + entityocelot.setOwner(this.getOwnerName()); + entityocelot.setTamed(true); + entityocelot.setTameSkin(this.getTameSkin()); + } + + return entityocelot; + } + + public boolean isBreedingItem(ItemStack par1ItemStack) + { + return par1ItemStack != null && par1ItemStack.getItem() == Items.fish; + } + + public boolean canMateWith(EntityAnimal par1EntityAnimal) + { + if (par1EntityAnimal == this) + { + return false; + } + else if (!this.isTamed()) + { + return false; + } + else if (!(par1EntityAnimal instanceof EntityOcelot)) + { + return false; + } + else + { + EntityOcelot entityocelot = (EntityOcelot)par1EntityAnimal; + return !entityocelot.isTamed() ? false : this.isInLove() && entityocelot.isInLove(); + } + } + + public int getTameSkin() + { + return this.dataWatcher.getWatchableObjectByte(18); + } + + public void setTameSkin(int par1) + { + this.dataWatcher.updateObject(18, Byte.valueOf((byte)par1)); + } + + public boolean getCanSpawnHere() + { + if (this.worldObj.rand.nextInt(3) == 0) + { + return false; + } + else + { + if (this.worldObj.checkNoEntityCollision(this.boundingBox) && this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox).isEmpty() && !this.worldObj.isAnyLiquid(this.boundingBox)) + { + int i = MathHelper.floor_double(this.posX); + int j = MathHelper.floor_double(this.boundingBox.minY); + int k = MathHelper.floor_double(this.posZ); + + if (j < 63) + { + return false; + } + + Block block = this.worldObj.getBlock(i, j - 1, k); + + if (block == Blocks.grass || block.isLeaves(worldObj, i, j - 1, k)) + { + return true; + } + } + + return false; + } + } + + public String getCommandSenderName() + { + return this.hasCustomNameTag() ? this.getCustomNameTag() : (this.isTamed() ? StatCollector.translateToLocal("entity.Cat.name") : super.getCommandSenderName()); + } + + public IEntityLivingData onSpawnWithEgg(IEntityLivingData par1EntityLivingData) + { + par1EntityLivingData = super.onSpawnWithEgg(par1EntityLivingData); + + if (this.worldObj.rand.nextInt(7) == 0) + { + for (int i = 0; i < 2; ++i) + { + EntityOcelot entityocelot = new EntityOcelot(this.worldObj); + entityocelot.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F); + entityocelot.setGrowingAge(-24000); + this.worldObj.spawnEntityInWorld(entityocelot); + } + } + + return par1EntityLivingData; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/passive/EntityPig.java b/src/main/java/net/minecraft/entity/passive/EntityPig.java new file mode 100644 index 0000000..70d2092 --- /dev/null +++ b/src/main/java/net/minecraft/entity/passive/EntityPig.java @@ -0,0 +1,205 @@ +package net.minecraft.entity.passive; + +import net.minecraft.block.Block; +import net.minecraft.entity.EntityAgeable; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.EntityAIControlledByPlayer; +import net.minecraft.entity.ai.EntityAIFollowParent; +import net.minecraft.entity.ai.EntityAILookIdle; +import net.minecraft.entity.ai.EntityAIMate; +import net.minecraft.entity.ai.EntityAIPanic; +import net.minecraft.entity.ai.EntityAISwimming; +import net.minecraft.entity.ai.EntityAITempt; +import net.minecraft.entity.ai.EntityAIWander; +import net.minecraft.entity.ai.EntityAIWatchClosest; +import net.minecraft.entity.effect.EntityLightningBolt; +import net.minecraft.entity.monster.EntityPigZombie; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.stats.AchievementList; +import net.minecraft.world.World; + +public class EntityPig extends EntityAnimal +{ + private final EntityAIControlledByPlayer aiControlledByPlayer; + private static final String __OBFID = "CL_00001647"; + + public EntityPig(World par1World) + { + super(par1World); + this.setSize(0.9F, 0.9F); + this.getNavigator().setAvoidsWater(true); + this.tasks.addTask(0, new EntityAISwimming(this)); + this.tasks.addTask(1, new EntityAIPanic(this, 1.25D)); + this.tasks.addTask(2, this.aiControlledByPlayer = new EntityAIControlledByPlayer(this, 0.3F)); + this.tasks.addTask(3, new EntityAIMate(this, 1.0D)); + this.tasks.addTask(4, new EntityAITempt(this, 1.2D, Items.carrot_on_a_stick, false)); + this.tasks.addTask(4, new EntityAITempt(this, 1.2D, Items.carrot, false)); + this.tasks.addTask(5, new EntityAIFollowParent(this, 1.1D)); + this.tasks.addTask(6, new EntityAIWander(this, 1.0D)); + this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F)); + this.tasks.addTask(8, new EntityAILookIdle(this)); + } + + public boolean isAIEnabled() + { + return true; + } + + protected void applyEntityAttributes() + { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(10.0D); + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.25D); + } + + protected void updateAITasks() + { + super.updateAITasks(); + } + + public boolean canBeSteered() + { + ItemStack itemstack = ((EntityPlayer)this.riddenByEntity).getHeldItem(); + return itemstack != null && itemstack.getItem() == Items.carrot_on_a_stick; + } + + protected void entityInit() + { + super.entityInit(); + this.dataWatcher.addObject(16, Byte.valueOf((byte)0)); + } + + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeEntityToNBT(par1NBTTagCompound); + par1NBTTagCompound.setBoolean("Saddle", this.getSaddled()); + } + + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + super.readEntityFromNBT(par1NBTTagCompound); + this.setSaddled(par1NBTTagCompound.getBoolean("Saddle")); + } + + protected String getLivingSound() + { + return "mob.pig.say"; + } + + protected String getHurtSound() + { + return "mob.pig.say"; + } + + protected String getDeathSound() + { + return "mob.pig.death"; + } + + protected void func_145780_a(int p_145780_1_, int p_145780_2_, int p_145780_3_, Block p_145780_4_) + { + this.playSound("mob.pig.step", 0.15F, 1.0F); + } + + public boolean interact(EntityPlayer par1EntityPlayer) + { + if (super.interact(par1EntityPlayer)) + { + return true; + } + else if (this.getSaddled() && !this.worldObj.isRemote && (this.riddenByEntity == null || this.riddenByEntity == par1EntityPlayer)) + { + par1EntityPlayer.mountEntity(this); + return true; + } + else + { + return false; + } + } + + protected Item getDropItem() + { + return this.isBurning() ? Items.cooked_porkchop : Items.porkchop; + } + + protected void dropFewItems(boolean par1, int par2) + { + int j = this.rand.nextInt(3) + 1 + this.rand.nextInt(1 + par2); + + for (int k = 0; k < j; ++k) + { + if (this.isBurning()) + { + this.dropItem(Items.cooked_porkchop, 1); + } + else + { + this.dropItem(Items.porkchop, 1); + } + } + + if (this.getSaddled()) + { + this.dropItem(Items.saddle, 1); + } + } + + public boolean getSaddled() + { + return (this.dataWatcher.getWatchableObjectByte(16) & 1) != 0; + } + + public void setSaddled(boolean par1) + { + if (par1) + { + this.dataWatcher.updateObject(16, Byte.valueOf((byte)1)); + } + else + { + this.dataWatcher.updateObject(16, Byte.valueOf((byte)0)); + } + } + + public void onStruckByLightning(EntityLightningBolt par1EntityLightningBolt) + { + if (!this.worldObj.isRemote) + { + EntityPigZombie entitypigzombie = new EntityPigZombie(this.worldObj); + entitypigzombie.setCurrentItemOrArmor(0, new ItemStack(Items.golden_sword)); + entitypigzombie.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch); + this.worldObj.spawnEntityInWorld(entitypigzombie); + this.setDead(); + } + } + + protected void fall(float par1) + { + super.fall(par1); + + if (par1 > 5.0F && this.riddenByEntity instanceof EntityPlayer) + { + ((EntityPlayer)this.riddenByEntity).triggerAchievement(AchievementList.flyPig); + } + } + + public EntityPig createChild(EntityAgeable par1EntityAgeable) + { + return new EntityPig(this.worldObj); + } + + public boolean isBreedingItem(ItemStack par1ItemStack) + { + return par1ItemStack != null && par1ItemStack.getItem() == Items.carrot; + } + + public EntityAIControlledByPlayer getAIControlledByPlayer() + { + return this.aiControlledByPlayer; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/passive/EntitySheep.java b/src/main/java/net/minecraft/entity/passive/EntitySheep.java new file mode 100644 index 0000000..e68efd6 --- /dev/null +++ b/src/main/java/net/minecraft/entity/passive/EntitySheep.java @@ -0,0 +1,294 @@ +package net.minecraft.entity.passive; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.entity.EntityAgeable; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.EntityAIEatGrass; +import net.minecraft.entity.ai.EntityAIFollowParent; +import net.minecraft.entity.ai.EntityAILookIdle; +import net.minecraft.entity.ai.EntityAIMate; +import net.minecraft.entity.ai.EntityAIPanic; +import net.minecraft.entity.ai.EntityAISwimming; +import net.minecraft.entity.ai.EntityAITempt; +import net.minecraft.entity.ai.EntityAIWander; +import net.minecraft.entity.ai.EntityAIWatchClosest; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.MathHelper; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.IShearable; + +public class EntitySheep extends EntityAnimal implements IShearable +{ + private final InventoryCrafting field_90016_e = new InventoryCrafting(new Container() + { + private static final String __OBFID = "CL_00001649"; + public boolean canInteractWith(EntityPlayer par1EntityPlayer) + { + return false; + } + }, 2, 1); + public static final float[][] fleeceColorTable = new float[][] {{1.0F, 1.0F, 1.0F}, {0.85F, 0.5F, 0.2F}, {0.7F, 0.3F, 0.85F}, {0.4F, 0.6F, 0.85F}, {0.9F, 0.9F, 0.2F}, {0.5F, 0.8F, 0.1F}, {0.95F, 0.5F, 0.65F}, {0.3F, 0.3F, 0.3F}, {0.6F, 0.6F, 0.6F}, {0.3F, 0.5F, 0.6F}, {0.5F, 0.25F, 0.7F}, {0.2F, 0.3F, 0.7F}, {0.4F, 0.3F, 0.2F}, {0.4F, 0.5F, 0.2F}, {0.6F, 0.2F, 0.2F}, {0.1F, 0.1F, 0.1F}}; + private int sheepTimer; + private EntityAIEatGrass field_146087_bs = new EntityAIEatGrass(this); + private static final String __OBFID = "CL_00001648"; + + public EntitySheep(World par1World) + { + super(par1World); + this.setSize(0.9F, 1.3F); + this.getNavigator().setAvoidsWater(true); + this.tasks.addTask(0, new EntityAISwimming(this)); + this.tasks.addTask(1, new EntityAIPanic(this, 1.25D)); + this.tasks.addTask(2, new EntityAIMate(this, 1.0D)); + this.tasks.addTask(3, new EntityAITempt(this, 1.1D, Items.wheat, false)); + this.tasks.addTask(4, new EntityAIFollowParent(this, 1.1D)); + this.tasks.addTask(5, this.field_146087_bs); + this.tasks.addTask(6, new EntityAIWander(this, 1.0D)); + this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F)); + this.tasks.addTask(8, new EntityAILookIdle(this)); + this.field_90016_e.setInventorySlotContents(0, new ItemStack(Items.dye, 1, 0)); + this.field_90016_e.setInventorySlotContents(1, new ItemStack(Items.dye, 1, 0)); + } + + protected boolean isAIEnabled() + { + return true; + } + + protected void updateAITasks() + { + this.sheepTimer = this.field_146087_bs.func_151499_f(); + super.updateAITasks(); + } + + public void onLivingUpdate() + { + if (this.worldObj.isRemote) + { + this.sheepTimer = Math.max(0, this.sheepTimer - 1); + } + + super.onLivingUpdate(); + } + + protected void applyEntityAttributes() + { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(8.0D); + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.23000000417232513D); + } + + protected void entityInit() + { + super.entityInit(); + this.dataWatcher.addObject(16, new Byte((byte)0)); + } + + protected void dropFewItems(boolean par1, int par2) + { + if (!this.getSheared()) + { + this.entityDropItem(new ItemStack(Item.getItemFromBlock(Blocks.wool), 1, this.getFleeceColor()), 0.0F); + } + } + + protected Item getDropItem() + { + return Item.getItemFromBlock(Blocks.wool); + } + + @SideOnly(Side.CLIENT) + public void handleHealthUpdate(byte par1) + { + if (par1 == 10) + { + this.sheepTimer = 40; + } + else + { + super.handleHealthUpdate(par1); + } + } + + public boolean interact(EntityPlayer par1EntityPlayer) + { + return super.interact(par1EntityPlayer); + } + + @SideOnly(Side.CLIENT) + public float func_70894_j(float par1) + { + return this.sheepTimer <= 0 ? 0.0F : (this.sheepTimer >= 4 && this.sheepTimer <= 36 ? 1.0F : (this.sheepTimer < 4 ? ((float)this.sheepTimer - par1) / 4.0F : -((float)(this.sheepTimer - 40) - par1) / 4.0F)); + } + + @SideOnly(Side.CLIENT) + public float func_70890_k(float par1) + { + if (this.sheepTimer > 4 && this.sheepTimer <= 36) + { + float f1 = ((float)(this.sheepTimer - 4) - par1) / 32.0F; + return ((float)Math.PI / 5F) + ((float)Math.PI * 7F / 100F) * MathHelper.sin(f1 * 28.7F); + } + else + { + return this.sheepTimer > 0 ? ((float)Math.PI / 5F) : this.rotationPitch / (180F / (float)Math.PI); + } + } + + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeEntityToNBT(par1NBTTagCompound); + par1NBTTagCompound.setBoolean("Sheared", this.getSheared()); + par1NBTTagCompound.setByte("Color", (byte)this.getFleeceColor()); + } + + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + super.readEntityFromNBT(par1NBTTagCompound); + this.setSheared(par1NBTTagCompound.getBoolean("Sheared")); + this.setFleeceColor(par1NBTTagCompound.getByte("Color")); + } + + protected String getLivingSound() + { + return "mob.sheep.say"; + } + + protected String getHurtSound() + { + return "mob.sheep.say"; + } + + protected String getDeathSound() + { + return "mob.sheep.say"; + } + + protected void func_145780_a(int p_145780_1_, int p_145780_2_, int p_145780_3_, Block p_145780_4_) + { + this.playSound("mob.sheep.step", 0.15F, 1.0F); + } + + public int getFleeceColor() + { + return this.dataWatcher.getWatchableObjectByte(16) & 15; + } + + public void setFleeceColor(int par1) + { + byte b0 = this.dataWatcher.getWatchableObjectByte(16); + this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 & 240 | par1 & 15))); + } + + public boolean getSheared() + { + return (this.dataWatcher.getWatchableObjectByte(16) & 16) != 0; + } + + public void setSheared(boolean par1) + { + byte b0 = this.dataWatcher.getWatchableObjectByte(16); + + if (par1) + { + this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 | 16))); + } + else + { + this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 & -17))); + } + } + + public static int getRandomFleeceColor(Random par0Random) + { + int i = par0Random.nextInt(100); + return i < 5 ? 15 : (i < 10 ? 7 : (i < 15 ? 8 : (i < 18 ? 12 : (par0Random.nextInt(500) == 0 ? 6 : 0)))); + } + + public EntitySheep createChild(EntityAgeable par1EntityAgeable) + { + EntitySheep entitysheep = (EntitySheep)par1EntityAgeable; + EntitySheep entitysheep1 = new EntitySheep(this.worldObj); + int i = this.func_90014_a(this, entitysheep); + entitysheep1.setFleeceColor(15 - i); + return entitysheep1; + } + + public void eatGrassBonus() + { + this.setSheared(false); + + if (this.isChild()) + { + this.addGrowth(60); + } + } + + public IEntityLivingData onSpawnWithEgg(IEntityLivingData par1EntityLivingData) + { + par1EntityLivingData = super.onSpawnWithEgg(par1EntityLivingData); + this.setFleeceColor(getRandomFleeceColor(this.worldObj.rand)); + return par1EntityLivingData; + } + + private int func_90014_a(EntityAnimal par1EntityAnimal, EntityAnimal par2EntityAnimal) + { + int i = this.func_90013_b(par1EntityAnimal); + int j = this.func_90013_b(par2EntityAnimal); + this.field_90016_e.getStackInSlot(0).setItemDamage(i); + this.field_90016_e.getStackInSlot(1).setItemDamage(j); + ItemStack itemstack = CraftingManager.getInstance().findMatchingRecipe(this.field_90016_e, ((EntitySheep)par1EntityAnimal).worldObj); + int k; + + if (itemstack != null && itemstack.getItem() == Items.dye) + { + k = itemstack.getItemDamage(); + } + else + { + k = this.worldObj.rand.nextBoolean() ? i : j; + } + + return k; + } + + private int func_90013_b(EntityAnimal par1EntityAnimal) + { + return 15 - ((EntitySheep)par1EntityAnimal).getFleeceColor(); + } + + @Override + public boolean isShearable(ItemStack item, IBlockAccess world, int x, int y, int z) + { + return !getSheared() && !isChild(); + } + + @Override + public ArrayList onSheared(ItemStack item, IBlockAccess world, int x, int y, int z, int fortune) + { + ArrayList ret = new ArrayList(); + setSheared(true); + int i = 1 + rand.nextInt(3); + for (int j = 0; j < i; j++) + { + ret.add(new ItemStack(Blocks.wool, 1, getFleeceColor())); + } + this.playSound("mob.sheep.shear", 1.0F, 1.0F); + return ret; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/passive/EntitySquid.java b/src/main/java/net/minecraft/entity/passive/EntitySquid.java new file mode 100644 index 0000000..df9846c --- /dev/null +++ b/src/main/java/net/minecraft/entity/passive/EntitySquid.java @@ -0,0 +1,189 @@ +package net.minecraft.entity.passive; + +import net.minecraft.block.material.Material; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class EntitySquid extends EntityWaterMob +{ + public float squidPitch; + public float prevSquidPitch; + public float squidYaw; + public float prevSquidYaw; + public float squidRotation; + public float prevSquidRotation; + public float tentacleAngle; + public float lastTentacleAngle; + private float randomMotionSpeed; + private float rotationVelocity; + private float field_70871_bB; + private float randomMotionVecX; + private float randomMotionVecY; + private float randomMotionVecZ; + private static final String __OBFID = "CL_00001651"; + + public EntitySquid(World par1World) + { + super(par1World); + this.setSize(0.95F, 0.95F); + this.rotationVelocity = 1.0F / (this.rand.nextFloat() + 1.0F) * 0.2F; + } + + protected void applyEntityAttributes() + { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(10.0D); + } + + protected String getLivingSound() + { + return null; + } + + protected String getHurtSound() + { + return null; + } + + protected String getDeathSound() + { + return null; + } + + protected float getSoundVolume() + { + return 0.4F; + } + + protected Item getDropItem() + { + return Item.getItemById(0); + } + + protected boolean canTriggerWalking() + { + return false; + } + + protected void dropFewItems(boolean par1, int par2) + { + int j = this.rand.nextInt(3 + par2) + 1; + + for (int k = 0; k < j; ++k) + { + this.entityDropItem(new ItemStack(Items.dye, 1, 0), 0.0F); + } + } + + public boolean isInWater() + { + return this.worldObj.handleMaterialAcceleration(this.boundingBox.expand(0.0D, -0.6000000238418579D, 0.0D), Material.water, this); + } + + public void onLivingUpdate() + { + super.onLivingUpdate(); + this.prevSquidPitch = this.squidPitch; + this.prevSquidYaw = this.squidYaw; + this.prevSquidRotation = this.squidRotation; + this.lastTentacleAngle = this.tentacleAngle; + this.squidRotation += this.rotationVelocity; + + if (this.squidRotation > ((float)Math.PI * 2F)) + { + this.squidRotation -= ((float)Math.PI * 2F); + + if (this.rand.nextInt(10) == 0) + { + this.rotationVelocity = 1.0F / (this.rand.nextFloat() + 1.0F) * 0.2F; + } + } + + if (this.isInWater()) + { + float f; + + if (this.squidRotation < (float)Math.PI) + { + f = this.squidRotation / (float)Math.PI; + this.tentacleAngle = MathHelper.sin(f * f * (float)Math.PI) * (float)Math.PI * 0.25F; + + if ((double)f > 0.75D) + { + this.randomMotionSpeed = 1.0F; + this.field_70871_bB = 1.0F; + } + else + { + this.field_70871_bB *= 0.8F; + } + } + else + { + this.tentacleAngle = 0.0F; + this.randomMotionSpeed *= 0.9F; + this.field_70871_bB *= 0.99F; + } + + if (!this.worldObj.isRemote) + { + this.motionX = (double)(this.randomMotionVecX * this.randomMotionSpeed); + this.motionY = (double)(this.randomMotionVecY * this.randomMotionSpeed); + this.motionZ = (double)(this.randomMotionVecZ * this.randomMotionSpeed); + } + + f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); + this.renderYawOffset += (-((float)Math.atan2(this.motionX, this.motionZ)) * 180.0F / (float)Math.PI - this.renderYawOffset) * 0.1F; + this.rotationYaw = this.renderYawOffset; + this.squidYaw += (float)Math.PI * this.field_70871_bB * 1.5F; + this.squidPitch += (-((float)Math.atan2((double)f, this.motionY)) * 180.0F / (float)Math.PI - this.squidPitch) * 0.1F; + } + else + { + this.tentacleAngle = MathHelper.abs(MathHelper.sin(this.squidRotation)) * (float)Math.PI * 0.25F; + + if (!this.worldObj.isRemote) + { + this.motionX = 0.0D; + this.motionY -= 0.08D; + this.motionY *= 0.9800000190734863D; + this.motionZ = 0.0D; + } + + this.squidPitch = (float)((double)this.squidPitch + (double)(-90.0F - this.squidPitch) * 0.02D); + } + } + + public void moveEntityWithHeading(float par1, float par2) + { + this.moveEntity(this.motionX, this.motionY, this.motionZ); + } + + protected void updateEntityActionState() + { + ++this.entityAge; + + if (this.entityAge > 100) + { + this.randomMotionVecX = this.randomMotionVecY = this.randomMotionVecZ = 0.0F; + } + else if (this.rand.nextInt(50) == 0 || !this.inWater || this.randomMotionVecX == 0.0F && this.randomMotionVecY == 0.0F && this.randomMotionVecZ == 0.0F) + { + float f = this.rand.nextFloat() * (float)Math.PI * 2.0F; + this.randomMotionVecX = MathHelper.cos(f) * 0.2F; + this.randomMotionVecY = -0.1F + this.rand.nextFloat() * 0.2F; + this.randomMotionVecZ = MathHelper.sin(f) * 0.2F; + } + + this.despawnEntity(); + } + + public boolean getCanSpawnHere() + { + return this.posY > 45.0D && this.posY < 63.0D && super.getCanSpawnHere(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/passive/EntityTameable.java b/src/main/java/net/minecraft/entity/passive/EntityTameable.java new file mode 100644 index 0000000..d420be3 --- /dev/null +++ b/src/main/java/net/minecraft/entity/passive/EntityTameable.java @@ -0,0 +1,193 @@ +package net.minecraft.entity.passive; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IEntityOwnable; +import net.minecraft.entity.ai.EntityAISit; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.scoreboard.Team; +import net.minecraft.world.World; + +public abstract class EntityTameable extends EntityAnimal implements IEntityOwnable +{ + protected EntityAISit aiSit = new EntityAISit(this); + private static final String __OBFID = "CL_00001561"; + + public EntityTameable(World par1World) + { + super(par1World); + } + + protected void entityInit() + { + super.entityInit(); + this.dataWatcher.addObject(16, Byte.valueOf((byte)0)); + this.dataWatcher.addObject(17, ""); + } + + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeEntityToNBT(par1NBTTagCompound); + + if (this.getOwnerName() == null) + { + par1NBTTagCompound.setString("Owner", ""); + } + else + { + par1NBTTagCompound.setString("Owner", this.getOwnerName()); + } + + par1NBTTagCompound.setBoolean("Sitting", this.isSitting()); + } + + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + super.readEntityFromNBT(par1NBTTagCompound); + String s = par1NBTTagCompound.getString("Owner"); + + if (s.length() > 0) + { + this.setOwner(s); + this.setTamed(true); + } + + this.aiSit.setSitting(par1NBTTagCompound.getBoolean("Sitting")); + this.setSitting(par1NBTTagCompound.getBoolean("Sitting")); + } + + protected void playTameEffect(boolean par1) + { + String s = "heart"; + + if (!par1) + { + s = "smoke"; + } + + for (int i = 0; i < 7; ++i) + { + double d0 = this.rand.nextGaussian() * 0.02D; + double d1 = this.rand.nextGaussian() * 0.02D; + double d2 = this.rand.nextGaussian() * 0.02D; + this.worldObj.spawnParticle(s, this.posX + (double)(this.rand.nextFloat() * this.width * 2.0F) - (double)this.width, this.posY + 0.5D + (double)(this.rand.nextFloat() * this.height), this.posZ + (double)(this.rand.nextFloat() * this.width * 2.0F) - (double)this.width, d0, d1, d2); + } + } + + @SideOnly(Side.CLIENT) + public void handleHealthUpdate(byte par1) + { + if (par1 == 7) + { + this.playTameEffect(true); + } + else if (par1 == 6) + { + this.playTameEffect(false); + } + else + { + super.handleHealthUpdate(par1); + } + } + + public boolean isTamed() + { + return (this.dataWatcher.getWatchableObjectByte(16) & 4) != 0; + } + + public void setTamed(boolean par1) + { + byte b0 = this.dataWatcher.getWatchableObjectByte(16); + + if (par1) + { + this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 | 4))); + } + else + { + this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 & -5))); + } + } + + public boolean isSitting() + { + return (this.dataWatcher.getWatchableObjectByte(16) & 1) != 0; + } + + public void setSitting(boolean par1) + { + byte b0 = this.dataWatcher.getWatchableObjectByte(16); + + if (par1) + { + this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 | 1))); + } + else + { + this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 & -2))); + } + } + + public String getOwnerName() + { + return this.dataWatcher.getWatchableObjectString(17); + } + + public void setOwner(String par1Str) + { + this.dataWatcher.updateObject(17, par1Str); + } + + public EntityLivingBase getOwner() + { + return this.worldObj.getPlayerEntityByName(this.getOwnerName()); + } + + public EntityAISit func_70907_r() + { + return this.aiSit; + } + + public boolean func_142018_a(EntityLivingBase par1EntityLivingBase, EntityLivingBase par2EntityLivingBase) + { + return true; + } + + public Team getTeam() + { + if (this.isTamed()) + { + EntityLivingBase entitylivingbase = this.getOwner(); + + if (entitylivingbase != null) + { + return entitylivingbase.getTeam(); + } + } + + return super.getTeam(); + } + + public boolean isOnSameTeam(EntityLivingBase par1EntityLivingBase) + { + if (this.isTamed()) + { + EntityLivingBase entitylivingbase1 = this.getOwner(); + + if (par1EntityLivingBase == entitylivingbase1) + { + return true; + } + + if (entitylivingbase1 != null) + { + return entitylivingbase1.isOnSameTeam(par1EntityLivingBase); + } + } + + return super.isOnSameTeam(par1EntityLivingBase); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/passive/EntityVillager.java b/src/main/java/net/minecraft/entity/passive/EntityVillager.java new file mode 100644 index 0000000..fd2ac26 --- /dev/null +++ b/src/main/java/net/minecraft/entity/passive/EntityVillager.java @@ -0,0 +1,731 @@ +package net.minecraft.entity.passive; + +import cpw.mods.fml.common.registry.VillagerRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Random; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnchantmentData; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityAgeable; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.entity.IMerchant; +import net.minecraft.entity.INpc; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.EntityAIAvoidEntity; +import net.minecraft.entity.ai.EntityAIFollowGolem; +import net.minecraft.entity.ai.EntityAILookAtTradePlayer; +import net.minecraft.entity.ai.EntityAIMoveIndoors; +import net.minecraft.entity.ai.EntityAIMoveTowardsRestriction; +import net.minecraft.entity.ai.EntityAIOpenDoor; +import net.minecraft.entity.ai.EntityAIPlay; +import net.minecraft.entity.ai.EntityAIRestrictOpenDoor; +import net.minecraft.entity.ai.EntityAISwimming; +import net.minecraft.entity.ai.EntityAITradePlayer; +import net.minecraft.entity.ai.EntityAIVillagerMate; +import net.minecraft.entity.ai.EntityAIWander; +import net.minecraft.entity.ai.EntityAIWatchClosest; +import net.minecraft.entity.ai.EntityAIWatchClosest2; +import net.minecraft.entity.monster.EntityZombie; +import net.minecraft.entity.monster.IMob; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.util.Tuple; +import net.minecraft.village.MerchantRecipe; +import net.minecraft.village.MerchantRecipeList; +import net.minecraft.village.Village; +import net.minecraft.world.World; + +public class EntityVillager extends EntityAgeable implements IMerchant, INpc +{ + private int randomTickDivider; + private boolean isMating; + private boolean isPlaying; + Village villageObj; + private EntityPlayer buyingPlayer; + private MerchantRecipeList buyingList; + private int timeUntilReset; + private boolean needsInitilization; + private int wealth; + private String lastBuyingPlayer; + private boolean isLookingForHome; + private float field_82191_bN; + public static final Map villagersSellingList = new HashMap(); + public static final Map blacksmithSellingList = new HashMap(); + private static final String __OBFID = "CL_00001707"; + + public EntityVillager(World par1World) + { + this(par1World, 0); + } + + public EntityVillager(World par1World, int par2) + { + super(par1World); + this.setProfession(par2); + this.setSize(0.6F, 1.8F); + this.getNavigator().setBreakDoors(true); + this.getNavigator().setAvoidsWater(true); + this.tasks.addTask(0, new EntityAISwimming(this)); + this.tasks.addTask(1, new EntityAIAvoidEntity(this, EntityZombie.class, 8.0F, 0.6D, 0.6D)); + this.tasks.addTask(1, new EntityAITradePlayer(this)); + this.tasks.addTask(1, new EntityAILookAtTradePlayer(this)); + this.tasks.addTask(2, new EntityAIMoveIndoors(this)); + this.tasks.addTask(3, new EntityAIRestrictOpenDoor(this)); + this.tasks.addTask(4, new EntityAIOpenDoor(this, true)); + this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 0.6D)); + this.tasks.addTask(6, new EntityAIVillagerMate(this)); + this.tasks.addTask(7, new EntityAIFollowGolem(this)); + this.tasks.addTask(8, new EntityAIPlay(this, 0.32D)); + this.tasks.addTask(9, new EntityAIWatchClosest2(this, EntityPlayer.class, 3.0F, 1.0F)); + this.tasks.addTask(9, new EntityAIWatchClosest2(this, EntityVillager.class, 5.0F, 0.02F)); + this.tasks.addTask(9, new EntityAIWander(this, 0.6D)); + this.tasks.addTask(10, new EntityAIWatchClosest(this, EntityLiving.class, 8.0F)); + } + + protected void applyEntityAttributes() + { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.5D); + } + + public boolean isAIEnabled() + { + return true; + } + + protected void updateAITick() + { + if (--this.randomTickDivider <= 0) + { + this.worldObj.villageCollectionObj.addVillagerPosition(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)); + this.randomTickDivider = 70 + this.rand.nextInt(50); + this.villageObj = this.worldObj.villageCollectionObj.findNearestVillage(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ), 32); + + if (this.villageObj == null) + { + this.detachHome(); + } + else + { + ChunkCoordinates chunkcoordinates = this.villageObj.getCenter(); + this.setHomeArea(chunkcoordinates.posX, chunkcoordinates.posY, chunkcoordinates.posZ, (int)((float)this.villageObj.getVillageRadius() * 0.6F)); + + if (this.isLookingForHome) + { + this.isLookingForHome = false; + this.villageObj.setDefaultPlayerReputation(5); + } + } + } + + if (!this.isTrading() && this.timeUntilReset > 0) + { + --this.timeUntilReset; + + if (this.timeUntilReset <= 0) + { + if (this.needsInitilization) + { + if (this.buyingList.size() > 1) + { + Iterator iterator = this.buyingList.iterator(); + + while (iterator.hasNext()) + { + MerchantRecipe merchantrecipe = (MerchantRecipe)iterator.next(); + + if (merchantrecipe.isRecipeDisabled()) + { + merchantrecipe.func_82783_a(this.rand.nextInt(6) + this.rand.nextInt(6) + 2); + } + } + } + + this.addDefaultEquipmentAndRecipies(1); + this.needsInitilization = false; + + if (this.villageObj != null && this.lastBuyingPlayer != null) + { + this.worldObj.setEntityState(this, (byte)14); + this.villageObj.setReputationForPlayer(this.lastBuyingPlayer, 1); + } + } + + this.addPotionEffect(new PotionEffect(Potion.regeneration.id, 200, 0)); + } + } + + super.updateAITick(); + } + + public boolean interact(EntityPlayer par1EntityPlayer) + { + ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem(); + boolean flag = itemstack != null && itemstack.getItem() == Items.spawn_egg; + + if (!flag && this.isEntityAlive() && !this.isTrading() && !this.isChild() && !par1EntityPlayer.isSneaking()) + { + if (!this.worldObj.isRemote) + { + this.setCustomer(par1EntityPlayer); + par1EntityPlayer.displayGUIMerchant(this, this.getCustomNameTag()); + } + + return true; + } + else + { + return super.interact(par1EntityPlayer); + } + } + + protected void entityInit() + { + super.entityInit(); + this.dataWatcher.addObject(16, Integer.valueOf(0)); + } + + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeEntityToNBT(par1NBTTagCompound); + par1NBTTagCompound.setInteger("Profession", this.getProfession()); + par1NBTTagCompound.setInteger("Riches", this.wealth); + + if (this.buyingList != null) + { + par1NBTTagCompound.setTag("Offers", this.buyingList.getRecipiesAsTags()); + } + } + + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + super.readEntityFromNBT(par1NBTTagCompound); + this.setProfession(par1NBTTagCompound.getInteger("Profession")); + this.wealth = par1NBTTagCompound.getInteger("Riches"); + + if (par1NBTTagCompound.hasKey("Offers", 10)) + { + NBTTagCompound nbttagcompound1 = par1NBTTagCompound.getCompoundTag("Offers"); + this.buyingList = new MerchantRecipeList(nbttagcompound1); + } + } + + protected boolean canDespawn() + { + return false; + } + + protected String getLivingSound() + { + return this.isTrading() ? "mob.villager.haggle" : "mob.villager.idle"; + } + + protected String getHurtSound() + { + return "mob.villager.hit"; + } + + protected String getDeathSound() + { + return "mob.villager.death"; + } + + public void setProfession(int par1) + { + this.dataWatcher.updateObject(16, Integer.valueOf(par1)); + } + + public int getProfession() + { + return this.dataWatcher.getWatchableObjectInt(16); + } + + public boolean isMating() + { + return this.isMating; + } + + public void setMating(boolean par1) + { + this.isMating = par1; + } + + public void setPlaying(boolean par1) + { + this.isPlaying = par1; + } + + public boolean isPlaying() + { + return this.isPlaying; + } + + public void setRevengeTarget(EntityLivingBase par1EntityLivingBase) + { + super.setRevengeTarget(par1EntityLivingBase); + + if (this.villageObj != null && par1EntityLivingBase != null) + { + this.villageObj.addOrRenewAgressor(par1EntityLivingBase); + + if (par1EntityLivingBase instanceof EntityPlayer) + { + byte b0 = -1; + + if (this.isChild()) + { + b0 = -3; + } + + this.villageObj.setReputationForPlayer(par1EntityLivingBase.getCommandSenderName(), b0); + + if (this.isEntityAlive()) + { + this.worldObj.setEntityState(this, (byte)13); + } + } + } + } + + public void onDeath(DamageSource par1DamageSource) + { + if (this.villageObj != null) + { + Entity entity = par1DamageSource.getEntity(); + + if (entity != null) + { + if (entity instanceof EntityPlayer) + { + this.villageObj.setReputationForPlayer(entity.getCommandSenderName(), -2); + } + else if (entity instanceof IMob) + { + this.villageObj.endMatingSeason(); + } + } + else if (entity == null) + { + EntityPlayer entityplayer = this.worldObj.getClosestPlayerToEntity(this, 16.0D); + + if (entityplayer != null) + { + this.villageObj.endMatingSeason(); + } + } + } + + super.onDeath(par1DamageSource); + } + + public void setCustomer(EntityPlayer par1EntityPlayer) + { + this.buyingPlayer = par1EntityPlayer; + } + + public EntityPlayer getCustomer() + { + return this.buyingPlayer; + } + + public boolean isTrading() + { + return this.buyingPlayer != null; + } + + public void useRecipe(MerchantRecipe par1MerchantRecipe) + { + par1MerchantRecipe.incrementToolUses(); + this.livingSoundTime = -this.getTalkInterval(); + this.playSound("mob.villager.yes", this.getSoundVolume(), this.getSoundPitch()); + + if (par1MerchantRecipe.hasSameIDsAs((MerchantRecipe)this.buyingList.get(this.buyingList.size() - 1))) + { + this.timeUntilReset = 40; + this.needsInitilization = true; + + if (this.buyingPlayer != null) + { + this.lastBuyingPlayer = this.buyingPlayer.getCommandSenderName(); + } + else + { + this.lastBuyingPlayer = null; + } + } + + if (par1MerchantRecipe.getItemToBuy().getItem() == Items.emerald) + { + this.wealth += par1MerchantRecipe.getItemToBuy().stackSize; + } + } + + public void func_110297_a_(ItemStack par1ItemStack) + { + if (!this.worldObj.isRemote && this.livingSoundTime > -this.getTalkInterval() + 20) + { + this.livingSoundTime = -this.getTalkInterval(); + + if (par1ItemStack != null) + { + this.playSound("mob.villager.yes", this.getSoundVolume(), this.getSoundPitch()); + } + else + { + this.playSound("mob.villager.no", this.getSoundVolume(), this.getSoundPitch()); + } + } + } + + public MerchantRecipeList getRecipes(EntityPlayer par1EntityPlayer) + { + if (this.buyingList == null) + { + this.addDefaultEquipmentAndRecipies(1); + } + + return this.buyingList; + } + + private float adjustProbability(float par1) + { + float f1 = par1 + this.field_82191_bN; + return f1 > 0.9F ? 0.9F - (f1 - 0.9F) : f1; + } + + private void addDefaultEquipmentAndRecipies(int par1) + { + if (this.buyingList != null) + { + this.field_82191_bN = MathHelper.sqrt_float((float)this.buyingList.size()) * 0.2F; + } + else + { + this.field_82191_bN = 0.0F; + } + + MerchantRecipeList merchantrecipelist; + merchantrecipelist = new MerchantRecipeList(); + VillagerRegistry.manageVillagerTrades(merchantrecipelist, this, this.getProfession(), this.rand); + int k; + label50: + + switch (this.getProfession()) + { + case 0: + func_146091_a(merchantrecipelist, Items.wheat, this.rand, this.adjustProbability(0.9F)); + func_146091_a(merchantrecipelist, Item.getItemFromBlock(Blocks.wool), this.rand, this.adjustProbability(0.5F)); + func_146091_a(merchantrecipelist, Items.chicken, this.rand, this.adjustProbability(0.5F)); + func_146091_a(merchantrecipelist, Items.cooked_fished, this.rand, this.adjustProbability(0.4F)); + func_146089_b(merchantrecipelist, Items.bread, this.rand, this.adjustProbability(0.9F)); + func_146089_b(merchantrecipelist, Items.melon, this.rand, this.adjustProbability(0.3F)); + func_146089_b(merchantrecipelist, Items.apple, this.rand, this.adjustProbability(0.3F)); + func_146089_b(merchantrecipelist, Items.cookie, this.rand, this.adjustProbability(0.3F)); + func_146089_b(merchantrecipelist, Items.shears, this.rand, this.adjustProbability(0.3F)); + func_146089_b(merchantrecipelist, Items.flint_and_steel, this.rand, this.adjustProbability(0.3F)); + func_146089_b(merchantrecipelist, Items.cooked_chicken, this.rand, this.adjustProbability(0.3F)); + func_146089_b(merchantrecipelist, Items.arrow, this.rand, this.adjustProbability(0.5F)); + + if (this.rand.nextFloat() < this.adjustProbability(0.5F)) + { + merchantrecipelist.add(new MerchantRecipe(new ItemStack(Blocks.gravel, 10), new ItemStack(Items.emerald), new ItemStack(Items.flint, 4 + this.rand.nextInt(2), 0))); + } + + break; + case 1: + func_146091_a(merchantrecipelist, Items.paper, this.rand, this.adjustProbability(0.8F)); + func_146091_a(merchantrecipelist, Items.book, this.rand, this.adjustProbability(0.8F)); + func_146091_a(merchantrecipelist, Items.written_book, this.rand, this.adjustProbability(0.3F)); + func_146089_b(merchantrecipelist, Item.getItemFromBlock(Blocks.bookshelf), this.rand, this.adjustProbability(0.8F)); + func_146089_b(merchantrecipelist, Item.getItemFromBlock(Blocks.glass), this.rand, this.adjustProbability(0.2F)); + func_146089_b(merchantrecipelist, Items.compass, this.rand, this.adjustProbability(0.2F)); + func_146089_b(merchantrecipelist, Items.clock, this.rand, this.adjustProbability(0.2F)); + + if (this.rand.nextFloat() < this.adjustProbability(0.07F)) + { + Enchantment enchantment = Enchantment.enchantmentsBookList[this.rand.nextInt(Enchantment.enchantmentsBookList.length)]; + int i1 = MathHelper.getRandomIntegerInRange(this.rand, enchantment.getMinLevel(), enchantment.getMaxLevel()); + ItemStack itemstack = Items.enchanted_book.getEnchantedItemStack(new EnchantmentData(enchantment, i1)); + k = 2 + this.rand.nextInt(5 + i1 * 10) + 3 * i1; + merchantrecipelist.add(new MerchantRecipe(new ItemStack(Items.book), new ItemStack(Items.emerald, k), itemstack)); + } + + break; + case 2: + func_146089_b(merchantrecipelist, Items.ender_eye, this.rand, this.adjustProbability(0.3F)); + func_146089_b(merchantrecipelist, Items.experience_bottle, this.rand, this.adjustProbability(0.2F)); + func_146089_b(merchantrecipelist, Items.redstone, this.rand, this.adjustProbability(0.4F)); + func_146089_b(merchantrecipelist, Item.getItemFromBlock(Blocks.glowstone), this.rand, this.adjustProbability(0.3F)); + Item[] aitem = new Item[] {Items.iron_sword, Items.diamond_sword, Items.iron_chestplate, Items.diamond_chestplate, Items.iron_axe, Items.diamond_axe, Items.iron_pickaxe, Items.diamond_pickaxe}; + Item[] aitem1 = aitem; + int j = aitem.length; + k = 0; + + while (true) + { + if (k >= j) + { + break label50; + } + + Item item = aitem1[k]; + + if (this.rand.nextFloat() < this.adjustProbability(0.05F)) + { + merchantrecipelist.add(new MerchantRecipe(new ItemStack(item, 1, 0), new ItemStack(Items.emerald, 2 + this.rand.nextInt(3), 0), EnchantmentHelper.addRandomEnchantment(this.rand, new ItemStack(item, 1, 0), 5 + this.rand.nextInt(15)))); + } + + ++k; + } + case 3: + func_146091_a(merchantrecipelist, Items.coal, this.rand, this.adjustProbability(0.7F)); + func_146091_a(merchantrecipelist, Items.iron_ingot, this.rand, this.adjustProbability(0.5F)); + func_146091_a(merchantrecipelist, Items.gold_ingot, this.rand, this.adjustProbability(0.5F)); + func_146091_a(merchantrecipelist, Items.diamond, this.rand, this.adjustProbability(0.5F)); + func_146089_b(merchantrecipelist, Items.iron_sword, this.rand, this.adjustProbability(0.5F)); + func_146089_b(merchantrecipelist, Items.diamond_sword, this.rand, this.adjustProbability(0.5F)); + func_146089_b(merchantrecipelist, Items.iron_axe, this.rand, this.adjustProbability(0.3F)); + func_146089_b(merchantrecipelist, Items.diamond_axe, this.rand, this.adjustProbability(0.3F)); + func_146089_b(merchantrecipelist, Items.iron_pickaxe, this.rand, this.adjustProbability(0.5F)); + func_146089_b(merchantrecipelist, Items.diamond_pickaxe, this.rand, this.adjustProbability(0.5F)); + func_146089_b(merchantrecipelist, Items.iron_shovel, this.rand, this.adjustProbability(0.2F)); + func_146089_b(merchantrecipelist, Items.diamond_shovel, this.rand, this.adjustProbability(0.2F)); + func_146089_b(merchantrecipelist, Items.iron_hoe, this.rand, this.adjustProbability(0.2F)); + func_146089_b(merchantrecipelist, Items.diamond_hoe, this.rand, this.adjustProbability(0.2F)); + func_146089_b(merchantrecipelist, Items.iron_boots, this.rand, this.adjustProbability(0.2F)); + func_146089_b(merchantrecipelist, Items.diamond_boots, this.rand, this.adjustProbability(0.2F)); + func_146089_b(merchantrecipelist, Items.iron_helmet, this.rand, this.adjustProbability(0.2F)); + func_146089_b(merchantrecipelist, Items.diamond_helmet, this.rand, this.adjustProbability(0.2F)); + func_146089_b(merchantrecipelist, Items.iron_chestplate, this.rand, this.adjustProbability(0.2F)); + func_146089_b(merchantrecipelist, Items.diamond_chestplate, this.rand, this.adjustProbability(0.2F)); + func_146089_b(merchantrecipelist, Items.iron_leggings, this.rand, this.adjustProbability(0.2F)); + func_146089_b(merchantrecipelist, Items.diamond_leggings, this.rand, this.adjustProbability(0.2F)); + func_146089_b(merchantrecipelist, Items.chainmail_boots, this.rand, this.adjustProbability(0.1F)); + func_146089_b(merchantrecipelist, Items.chainmail_helmet, this.rand, this.adjustProbability(0.1F)); + func_146089_b(merchantrecipelist, Items.chainmail_chestplate, this.rand, this.adjustProbability(0.1F)); + func_146089_b(merchantrecipelist, Items.chainmail_leggings, this.rand, this.adjustProbability(0.1F)); + break; + case 4: + func_146091_a(merchantrecipelist, Items.coal, this.rand, this.adjustProbability(0.7F)); + func_146091_a(merchantrecipelist, Items.porkchop, this.rand, this.adjustProbability(0.5F)); + func_146091_a(merchantrecipelist, Items.beef, this.rand, this.adjustProbability(0.5F)); + func_146089_b(merchantrecipelist, Items.saddle, this.rand, this.adjustProbability(0.1F)); + func_146089_b(merchantrecipelist, Items.leather_chestplate, this.rand, this.adjustProbability(0.3F)); + func_146089_b(merchantrecipelist, Items.leather_boots, this.rand, this.adjustProbability(0.3F)); + func_146089_b(merchantrecipelist, Items.leather_helmet, this.rand, this.adjustProbability(0.3F)); + func_146089_b(merchantrecipelist, Items.leather_leggings, this.rand, this.adjustProbability(0.3F)); + func_146089_b(merchantrecipelist, Items.cooked_porkchop, this.rand, this.adjustProbability(0.3F)); + func_146089_b(merchantrecipelist, Items.cooked_beef, this.rand, this.adjustProbability(0.3F)); + } + + if (merchantrecipelist.isEmpty()) + { + func_146091_a(merchantrecipelist, Items.gold_ingot, this.rand, 1.0F); + } + + Collections.shuffle(merchantrecipelist); + + if (this.buyingList == null) + { + this.buyingList = new MerchantRecipeList(); + } + + for (int l = 0; l < par1 && l < merchantrecipelist.size(); ++l) + { + this.buyingList.addToListWithCheck((MerchantRecipe)merchantrecipelist.get(l)); + } + } + + @SideOnly(Side.CLIENT) + public void setRecipes(MerchantRecipeList par1MerchantRecipeList) {} + + public static void func_146091_a(MerchantRecipeList p_146091_0_, Item p_146091_1_, Random p_146091_2_, float p_146091_3_) + { + if (p_146091_2_.nextFloat() < p_146091_3_) + { + p_146091_0_.add(new MerchantRecipe(func_146088_a(p_146091_1_, p_146091_2_), Items.emerald)); + } + } + + private static ItemStack func_146088_a(Item p_146088_0_, Random p_146088_1_) + { + return new ItemStack(p_146088_0_, func_146092_b(p_146088_0_, p_146088_1_), 0); + } + + private static int func_146092_b(Item p_146092_0_, Random p_146092_1_) + { + Tuple tuple = (Tuple)villagersSellingList.get(p_146092_0_); + return tuple == null ? 1 : (((Integer)tuple.getFirst()).intValue() >= ((Integer)tuple.getSecond()).intValue() ? ((Integer)tuple.getFirst()).intValue() : ((Integer)tuple.getFirst()).intValue() + p_146092_1_.nextInt(((Integer)tuple.getSecond()).intValue() - ((Integer)tuple.getFirst()).intValue())); + } + + public static void func_146089_b(MerchantRecipeList p_146089_0_, Item p_146089_1_, Random p_146089_2_, float p_146089_3_) + { + if (p_146089_2_.nextFloat() < p_146089_3_) + { + int i = func_146090_c(p_146089_1_, p_146089_2_); + ItemStack itemstack; + ItemStack itemstack1; + + if (i < 0) + { + itemstack = new ItemStack(Items.emerald, 1, 0); + itemstack1 = new ItemStack(p_146089_1_, -i, 0); + } + else + { + itemstack = new ItemStack(Items.emerald, i, 0); + itemstack1 = new ItemStack(p_146089_1_, 1, 0); + } + + p_146089_0_.add(new MerchantRecipe(itemstack, itemstack1)); + } + } + + private static int func_146090_c(Item p_146090_0_, Random p_146090_1_) + { + Tuple tuple = (Tuple)blacksmithSellingList.get(p_146090_0_); + return tuple == null ? 1 : (((Integer)tuple.getFirst()).intValue() >= ((Integer)tuple.getSecond()).intValue() ? ((Integer)tuple.getFirst()).intValue() : ((Integer)tuple.getFirst()).intValue() + p_146090_1_.nextInt(((Integer)tuple.getSecond()).intValue() - ((Integer)tuple.getFirst()).intValue())); + } + + @SideOnly(Side.CLIENT) + public void handleHealthUpdate(byte par1) + { + if (par1 == 12) + { + this.generateRandomParticles("heart"); + } + else if (par1 == 13) + { + this.generateRandomParticles("angryVillager"); + } + else if (par1 == 14) + { + this.generateRandomParticles("happyVillager"); + } + else + { + super.handleHealthUpdate(par1); + } + } + + public IEntityLivingData onSpawnWithEgg(IEntityLivingData par1EntityLivingData) + { + par1EntityLivingData = super.onSpawnWithEgg(par1EntityLivingData); + VillagerRegistry.applyRandomTrade(this, worldObj.rand); + return par1EntityLivingData; + } + + @SideOnly(Side.CLIENT) + private void generateRandomParticles(String par1Str) + { + for (int i = 0; i < 5; ++i) + { + double d0 = this.rand.nextGaussian() * 0.02D; + double d1 = this.rand.nextGaussian() * 0.02D; + double d2 = this.rand.nextGaussian() * 0.02D; + this.worldObj.spawnParticle(par1Str, this.posX + (double)(this.rand.nextFloat() * this.width * 2.0F) - (double)this.width, this.posY + 1.0D + (double)(this.rand.nextFloat() * this.height), this.posZ + (double)(this.rand.nextFloat() * this.width * 2.0F) - (double)this.width, d0, d1, d2); + } + } + + public void setLookingForHome() + { + this.isLookingForHome = true; + } + + public EntityVillager createChild(EntityAgeable par1EntityAgeable) + { + EntityVillager entityvillager = new EntityVillager(this.worldObj); + entityvillager.onSpawnWithEgg((IEntityLivingData)null); + return entityvillager; + } + + public boolean allowLeashing() + { + return false; + } + + static + { + villagersSellingList.put(Items.coal, new Tuple(Integer.valueOf(16), Integer.valueOf(24))); + villagersSellingList.put(Items.iron_ingot, new Tuple(Integer.valueOf(8), Integer.valueOf(10))); + villagersSellingList.put(Items.gold_ingot, new Tuple(Integer.valueOf(8), Integer.valueOf(10))); + villagersSellingList.put(Items.diamond, new Tuple(Integer.valueOf(4), Integer.valueOf(6))); + villagersSellingList.put(Items.paper, new Tuple(Integer.valueOf(24), Integer.valueOf(36))); + villagersSellingList.put(Items.book, new Tuple(Integer.valueOf(11), Integer.valueOf(13))); + villagersSellingList.put(Items.written_book, new Tuple(Integer.valueOf(1), Integer.valueOf(1))); + villagersSellingList.put(Items.ender_pearl, new Tuple(Integer.valueOf(3), Integer.valueOf(4))); + villagersSellingList.put(Items.ender_eye, new Tuple(Integer.valueOf(2), Integer.valueOf(3))); + villagersSellingList.put(Items.porkchop, new Tuple(Integer.valueOf(14), Integer.valueOf(18))); + villagersSellingList.put(Items.beef, new Tuple(Integer.valueOf(14), Integer.valueOf(18))); + villagersSellingList.put(Items.chicken, new Tuple(Integer.valueOf(14), Integer.valueOf(18))); + villagersSellingList.put(Items.cooked_fished, new Tuple(Integer.valueOf(9), Integer.valueOf(13))); + villagersSellingList.put(Items.wheat_seeds, new Tuple(Integer.valueOf(34), Integer.valueOf(48))); + villagersSellingList.put(Items.melon_seeds, new Tuple(Integer.valueOf(30), Integer.valueOf(38))); + villagersSellingList.put(Items.pumpkin_seeds, new Tuple(Integer.valueOf(30), Integer.valueOf(38))); + villagersSellingList.put(Items.wheat, new Tuple(Integer.valueOf(18), Integer.valueOf(22))); + villagersSellingList.put(Item.getItemFromBlock(Blocks.wool), new Tuple(Integer.valueOf(14), Integer.valueOf(22))); + villagersSellingList.put(Items.rotten_flesh, new Tuple(Integer.valueOf(36), Integer.valueOf(64))); + blacksmithSellingList.put(Items.flint_and_steel, new Tuple(Integer.valueOf(3), Integer.valueOf(4))); + blacksmithSellingList.put(Items.shears, new Tuple(Integer.valueOf(3), Integer.valueOf(4))); + blacksmithSellingList.put(Items.iron_sword, new Tuple(Integer.valueOf(7), Integer.valueOf(11))); + blacksmithSellingList.put(Items.diamond_sword, new Tuple(Integer.valueOf(12), Integer.valueOf(14))); + blacksmithSellingList.put(Items.iron_axe, new Tuple(Integer.valueOf(6), Integer.valueOf(8))); + blacksmithSellingList.put(Items.diamond_axe, new Tuple(Integer.valueOf(9), Integer.valueOf(12))); + blacksmithSellingList.put(Items.iron_pickaxe, new Tuple(Integer.valueOf(7), Integer.valueOf(9))); + blacksmithSellingList.put(Items.diamond_pickaxe, new Tuple(Integer.valueOf(10), Integer.valueOf(12))); + blacksmithSellingList.put(Items.iron_shovel, new Tuple(Integer.valueOf(4), Integer.valueOf(6))); + blacksmithSellingList.put(Items.diamond_shovel, new Tuple(Integer.valueOf(7), Integer.valueOf(8))); + blacksmithSellingList.put(Items.iron_hoe, new Tuple(Integer.valueOf(4), Integer.valueOf(6))); + blacksmithSellingList.put(Items.diamond_hoe, new Tuple(Integer.valueOf(7), Integer.valueOf(8))); + blacksmithSellingList.put(Items.iron_boots, new Tuple(Integer.valueOf(4), Integer.valueOf(6))); + blacksmithSellingList.put(Items.diamond_boots, new Tuple(Integer.valueOf(7), Integer.valueOf(8))); + blacksmithSellingList.put(Items.iron_helmet, new Tuple(Integer.valueOf(4), Integer.valueOf(6))); + blacksmithSellingList.put(Items.diamond_helmet, new Tuple(Integer.valueOf(7), Integer.valueOf(8))); + blacksmithSellingList.put(Items.iron_chestplate, new Tuple(Integer.valueOf(10), Integer.valueOf(14))); + blacksmithSellingList.put(Items.diamond_chestplate, new Tuple(Integer.valueOf(16), Integer.valueOf(19))); + blacksmithSellingList.put(Items.iron_leggings, new Tuple(Integer.valueOf(8), Integer.valueOf(10))); + blacksmithSellingList.put(Items.diamond_leggings, new Tuple(Integer.valueOf(11), Integer.valueOf(14))); + blacksmithSellingList.put(Items.chainmail_boots, new Tuple(Integer.valueOf(5), Integer.valueOf(7))); + blacksmithSellingList.put(Items.chainmail_helmet, new Tuple(Integer.valueOf(5), Integer.valueOf(7))); + blacksmithSellingList.put(Items.chainmail_chestplate, new Tuple(Integer.valueOf(11), Integer.valueOf(15))); + blacksmithSellingList.put(Items.chainmail_leggings, new Tuple(Integer.valueOf(9), Integer.valueOf(11))); + blacksmithSellingList.put(Items.bread, new Tuple(Integer.valueOf(-4), Integer.valueOf(-2))); + blacksmithSellingList.put(Items.melon, new Tuple(Integer.valueOf(-8), Integer.valueOf(-4))); + blacksmithSellingList.put(Items.apple, new Tuple(Integer.valueOf(-8), Integer.valueOf(-4))); + blacksmithSellingList.put(Items.cookie, new Tuple(Integer.valueOf(-10), Integer.valueOf(-7))); + blacksmithSellingList.put(Item.getItemFromBlock(Blocks.glass), new Tuple(Integer.valueOf(-5), Integer.valueOf(-3))); + blacksmithSellingList.put(Item.getItemFromBlock(Blocks.bookshelf), new Tuple(Integer.valueOf(3), Integer.valueOf(4))); + blacksmithSellingList.put(Items.leather_chestplate, new Tuple(Integer.valueOf(4), Integer.valueOf(5))); + blacksmithSellingList.put(Items.leather_boots, new Tuple(Integer.valueOf(2), Integer.valueOf(4))); + blacksmithSellingList.put(Items.leather_helmet, new Tuple(Integer.valueOf(2), Integer.valueOf(4))); + blacksmithSellingList.put(Items.leather_leggings, new Tuple(Integer.valueOf(2), Integer.valueOf(4))); + blacksmithSellingList.put(Items.saddle, new Tuple(Integer.valueOf(6), Integer.valueOf(8))); + blacksmithSellingList.put(Items.experience_bottle, new Tuple(Integer.valueOf(-4), Integer.valueOf(-1))); + blacksmithSellingList.put(Items.redstone, new Tuple(Integer.valueOf(-4), Integer.valueOf(-1))); + blacksmithSellingList.put(Items.compass, new Tuple(Integer.valueOf(10), Integer.valueOf(12))); + blacksmithSellingList.put(Items.clock, new Tuple(Integer.valueOf(10), Integer.valueOf(12))); + blacksmithSellingList.put(Item.getItemFromBlock(Blocks.glowstone), new Tuple(Integer.valueOf(-3), Integer.valueOf(-1))); + blacksmithSellingList.put(Items.cooked_porkchop, new Tuple(Integer.valueOf(-7), Integer.valueOf(-5))); + blacksmithSellingList.put(Items.cooked_beef, new Tuple(Integer.valueOf(-7), Integer.valueOf(-5))); + blacksmithSellingList.put(Items.cooked_chicken, new Tuple(Integer.valueOf(-8), Integer.valueOf(-6))); + blacksmithSellingList.put(Items.ender_eye, new Tuple(Integer.valueOf(7), Integer.valueOf(11))); + blacksmithSellingList.put(Items.arrow, new Tuple(Integer.valueOf(-12), Integer.valueOf(-8))); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/passive/EntityWaterMob.java b/src/main/java/net/minecraft/entity/passive/EntityWaterMob.java new file mode 100644 index 0000000..593b81b --- /dev/null +++ b/src/main/java/net/minecraft/entity/passive/EntityWaterMob.java @@ -0,0 +1,63 @@ +package net.minecraft.entity.passive; + +import net.minecraft.entity.EntityCreature; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.DamageSource; +import net.minecraft.world.World; + +public abstract class EntityWaterMob extends EntityCreature implements IAnimals +{ + private static final String __OBFID = "CL_00001653"; + + public EntityWaterMob(World par1World) + { + super(par1World); + } + + public boolean canBreatheUnderwater() + { + return true; + } + + public boolean getCanSpawnHere() + { + return this.worldObj.checkNoEntityCollision(this.boundingBox); + } + + public int getTalkInterval() + { + return 120; + } + + protected boolean canDespawn() + { + return true; + } + + protected int getExperiencePoints(EntityPlayer par1EntityPlayer) + { + return 1 + this.worldObj.rand.nextInt(3); + } + + public void onEntityUpdate() + { + int i = this.getAir(); + super.onEntityUpdate(); + + if (this.isEntityAlive() && !this.isInWater()) + { + --i; + this.setAir(i); + + if (this.getAir() == -20) + { + this.setAir(0); + this.attackEntityFrom(DamageSource.drown, 2.0F); + } + } + else + { + this.setAir(300); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/passive/EntityWolf.java b/src/main/java/net/minecraft/entity/passive/EntityWolf.java new file mode 100644 index 0000000..f3c87cb --- /dev/null +++ b/src/main/java/net/minecraft/entity/passive/EntityWolf.java @@ -0,0 +1,554 @@ +package net.minecraft.entity.passive; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.block.BlockColored; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityAgeable; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.EntityAIAttackOnCollide; +import net.minecraft.entity.ai.EntityAIBeg; +import net.minecraft.entity.ai.EntityAIFollowOwner; +import net.minecraft.entity.ai.EntityAIHurtByTarget; +import net.minecraft.entity.ai.EntityAILeapAtTarget; +import net.minecraft.entity.ai.EntityAILookIdle; +import net.minecraft.entity.ai.EntityAIMate; +import net.minecraft.entity.ai.EntityAIOwnerHurtByTarget; +import net.minecraft.entity.ai.EntityAIOwnerHurtTarget; +import net.minecraft.entity.ai.EntityAISwimming; +import net.minecraft.entity.ai.EntityAITargetNonTamed; +import net.minecraft.entity.ai.EntityAIWander; +import net.minecraft.entity.ai.EntityAIWatchClosest; +import net.minecraft.entity.monster.EntityCreeper; +import net.minecraft.entity.monster.EntityGhast; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemFood; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.pathfinding.PathEntity; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class EntityWolf extends EntityTameable +{ + private float field_70926_e; + private float field_70924_f; + private boolean isShaking; + private boolean field_70928_h; + private float timeWolfIsShaking; + private float prevTimeWolfIsShaking; + private static final String __OBFID = "CL_00001654"; + + public EntityWolf(World par1World) + { + super(par1World); + this.setSize(0.6F, 0.8F); + this.getNavigator().setAvoidsWater(true); + this.tasks.addTask(1, new EntityAISwimming(this)); + this.tasks.addTask(2, this.aiSit); + this.tasks.addTask(3, new EntityAILeapAtTarget(this, 0.4F)); + this.tasks.addTask(4, new EntityAIAttackOnCollide(this, 1.0D, true)); + this.tasks.addTask(5, new EntityAIFollowOwner(this, 1.0D, 10.0F, 2.0F)); + this.tasks.addTask(6, new EntityAIMate(this, 1.0D)); + this.tasks.addTask(7, new EntityAIWander(this, 1.0D)); + this.tasks.addTask(8, new EntityAIBeg(this, 8.0F)); + this.tasks.addTask(9, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); + this.tasks.addTask(9, new EntityAILookIdle(this)); + this.targetTasks.addTask(1, new EntityAIOwnerHurtByTarget(this)); + this.targetTasks.addTask(2, new EntityAIOwnerHurtTarget(this)); + this.targetTasks.addTask(3, new EntityAIHurtByTarget(this, true)); + this.targetTasks.addTask(4, new EntityAITargetNonTamed(this, EntitySheep.class, 200, false)); + this.setTamed(false); + } + + protected void applyEntityAttributes() + { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.30000001192092896D); + + if (this.isTamed()) + { + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20.0D); + } + else + { + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(8.0D); + } + } + + public boolean isAIEnabled() + { + return true; + } + + public void setAttackTarget(EntityLivingBase par1EntityLivingBase) + { + super.setAttackTarget(par1EntityLivingBase); + + if (par1EntityLivingBase == null) + { + this.setAngry(false); + } + else if (!this.isTamed()) + { + this.setAngry(true); + } + } + + protected void updateAITick() + { + this.dataWatcher.updateObject(18, Float.valueOf(this.getHealth())); + } + + protected void entityInit() + { + super.entityInit(); + this.dataWatcher.addObject(18, new Float(this.getHealth())); + this.dataWatcher.addObject(19, new Byte((byte)0)); + this.dataWatcher.addObject(20, new Byte((byte)BlockColored.func_150032_b(1))); + } + + protected void func_145780_a(int p_145780_1_, int p_145780_2_, int p_145780_3_, Block p_145780_4_) + { + this.playSound("mob.wolf.step", 0.15F, 1.0F); + } + + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeEntityToNBT(par1NBTTagCompound); + par1NBTTagCompound.setBoolean("Angry", this.isAngry()); + par1NBTTagCompound.setByte("CollarColor", (byte)this.getCollarColor()); + } + + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + super.readEntityFromNBT(par1NBTTagCompound); + this.setAngry(par1NBTTagCompound.getBoolean("Angry")); + + if (par1NBTTagCompound.hasKey("CollarColor", 99)) + { + this.setCollarColor(par1NBTTagCompound.getByte("CollarColor")); + } + } + + protected String getLivingSound() + { + return this.isAngry() ? "mob.wolf.growl" : (this.rand.nextInt(3) == 0 ? (this.isTamed() && this.dataWatcher.getWatchableObjectFloat(18) < 10.0F ? "mob.wolf.whine" : "mob.wolf.panting") : "mob.wolf.bark"); + } + + protected String getHurtSound() + { + return "mob.wolf.hurt"; + } + + protected String getDeathSound() + { + return "mob.wolf.death"; + } + + protected float getSoundVolume() + { + return 0.4F; + } + + protected Item getDropItem() + { + return Item.getItemById(-1); + } + + public void onLivingUpdate() + { + super.onLivingUpdate(); + + if (!this.worldObj.isRemote && this.isShaking && !this.field_70928_h && !this.hasPath() && this.onGround) + { + this.field_70928_h = true; + this.timeWolfIsShaking = 0.0F; + this.prevTimeWolfIsShaking = 0.0F; + this.worldObj.setEntityState(this, (byte)8); + } + } + + public void onUpdate() + { + super.onUpdate(); + this.field_70924_f = this.field_70926_e; + + if (this.func_70922_bv()) + { + this.field_70926_e += (1.0F - this.field_70926_e) * 0.4F; + } + else + { + this.field_70926_e += (0.0F - this.field_70926_e) * 0.4F; + } + + if (this.func_70922_bv()) + { + this.numTicksToChaseTarget = 10; + } + + if (this.isWet()) + { + this.isShaking = true; + this.field_70928_h = false; + this.timeWolfIsShaking = 0.0F; + this.prevTimeWolfIsShaking = 0.0F; + } + else if ((this.isShaking || this.field_70928_h) && this.field_70928_h) + { + if (this.timeWolfIsShaking == 0.0F) + { + this.playSound("mob.wolf.shake", this.getSoundVolume(), (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F); + } + + this.prevTimeWolfIsShaking = this.timeWolfIsShaking; + this.timeWolfIsShaking += 0.05F; + + if (this.prevTimeWolfIsShaking >= 2.0F) + { + this.isShaking = false; + this.field_70928_h = false; + this.prevTimeWolfIsShaking = 0.0F; + this.timeWolfIsShaking = 0.0F; + } + + if (this.timeWolfIsShaking > 0.4F) + { + float f = (float)this.boundingBox.minY; + int i = (int)(MathHelper.sin((this.timeWolfIsShaking - 0.4F) * (float)Math.PI) * 7.0F); + + for (int j = 0; j < i; ++j) + { + float f1 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width * 0.5F; + float f2 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width * 0.5F; + this.worldObj.spawnParticle("splash", this.posX + (double)f1, (double)(f + 0.8F), this.posZ + (double)f2, this.motionX, this.motionY, this.motionZ); + } + } + } + } + + @SideOnly(Side.CLIENT) + public boolean getWolfShaking() + { + return this.isShaking; + } + + @SideOnly(Side.CLIENT) + public float getShadingWhileShaking(float par1) + { + return 0.75F + (this.prevTimeWolfIsShaking + (this.timeWolfIsShaking - this.prevTimeWolfIsShaking) * par1) / 2.0F * 0.25F; + } + + @SideOnly(Side.CLIENT) + public float getShakeAngle(float par1, float par2) + { + float f2 = (this.prevTimeWolfIsShaking + (this.timeWolfIsShaking - this.prevTimeWolfIsShaking) * par1 + par2) / 1.8F; + + if (f2 < 0.0F) + { + f2 = 0.0F; + } + else if (f2 > 1.0F) + { + f2 = 1.0F; + } + + return MathHelper.sin(f2 * (float)Math.PI) * MathHelper.sin(f2 * (float)Math.PI * 11.0F) * 0.15F * (float)Math.PI; + } + + public float getEyeHeight() + { + return this.height * 0.8F; + } + + @SideOnly(Side.CLIENT) + public float getInterestedAngle(float par1) + { + return (this.field_70924_f + (this.field_70926_e - this.field_70924_f) * par1) * 0.15F * (float)Math.PI; + } + + public int getVerticalFaceSpeed() + { + return this.isSitting() ? 20 : super.getVerticalFaceSpeed(); + } + + public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) + { + if (this.isEntityInvulnerable()) + { + return false; + } + else + { + Entity entity = par1DamageSource.getEntity(); + this.aiSit.setSitting(false); + + if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow)) + { + par2 = (par2 + 1.0F) / 2.0F; + } + + return super.attackEntityFrom(par1DamageSource, par2); + } + } + + public boolean attackEntityAsMob(Entity par1Entity) + { + int i = this.isTamed() ? 4 : 2; + return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float)i); + } + + public void setTamed(boolean par1) + { + super.setTamed(par1); + + if (par1) + { + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20.0D); + } + else + { + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(8.0D); + } + } + + public boolean interact(EntityPlayer par1EntityPlayer) + { + ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem(); + + if (this.isTamed()) + { + if (itemstack != null) + { + if (itemstack.getItem() instanceof ItemFood) + { + ItemFood itemfood = (ItemFood)itemstack.getItem(); + + if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < 20.0F) + { + if (!par1EntityPlayer.capabilities.isCreativeMode) + { + --itemstack.stackSize; + } + + this.heal((float)itemfood.func_150905_g(itemstack)); + + if (itemstack.stackSize <= 0) + { + par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack)null); + } + + return true; + } + } + else if (itemstack.getItem() == Items.dye) + { + int i = BlockColored.func_150032_b(itemstack.getItemDamage()); + + if (i != this.getCollarColor()) + { + this.setCollarColor(i); + + if (!par1EntityPlayer.capabilities.isCreativeMode && --itemstack.stackSize <= 0) + { + par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack)null); + } + + return true; + } + } + } + + if (par1EntityPlayer.getCommandSenderName().equalsIgnoreCase(this.getOwnerName()) && !this.worldObj.isRemote && !this.isBreedingItem(itemstack)) + { + this.aiSit.setSitting(!this.isSitting()); + this.isJumping = false; + this.setPathToEntity((PathEntity)null); + this.setTarget((Entity)null); + this.setAttackTarget((EntityLivingBase)null); + } + } + else if (itemstack != null && itemstack.getItem() == Items.bone && !this.isAngry()) + { + if (!par1EntityPlayer.capabilities.isCreativeMode) + { + --itemstack.stackSize; + } + + if (itemstack.stackSize <= 0) + { + par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack)null); + } + + if (!this.worldObj.isRemote) + { + if (this.rand.nextInt(3) == 0) + { + this.setTamed(true); + this.setPathToEntity((PathEntity)null); + this.setAttackTarget((EntityLivingBase)null); + this.aiSit.setSitting(true); + this.setHealth(20.0F); + this.setOwner(par1EntityPlayer.getCommandSenderName()); + this.playTameEffect(true); + this.worldObj.setEntityState(this, (byte)7); + } + else + { + this.playTameEffect(false); + this.worldObj.setEntityState(this, (byte)6); + } + } + + return true; + } + + return super.interact(par1EntityPlayer); + } + + @SideOnly(Side.CLIENT) + public void handleHealthUpdate(byte par1) + { + if (par1 == 8) + { + this.field_70928_h = true; + this.timeWolfIsShaking = 0.0F; + this.prevTimeWolfIsShaking = 0.0F; + } + else + { + super.handleHealthUpdate(par1); + } + } + + @SideOnly(Side.CLIENT) + public float getTailRotation() + { + return this.isAngry() ? 1.5393804F : (this.isTamed() ? (0.55F - (20.0F - this.dataWatcher.getWatchableObjectFloat(18)) * 0.02F) * (float)Math.PI : ((float)Math.PI / 5F)); + } + + public boolean isBreedingItem(ItemStack par1ItemStack) + { + return par1ItemStack == null ? false : (!(par1ItemStack.getItem() instanceof ItemFood) ? false : ((ItemFood)par1ItemStack.getItem()).isWolfsFavoriteMeat()); + } + + public int getMaxSpawnedInChunk() + { + return 8; + } + + public boolean isAngry() + { + return (this.dataWatcher.getWatchableObjectByte(16) & 2) != 0; + } + + public void setAngry(boolean par1) + { + byte b0 = this.dataWatcher.getWatchableObjectByte(16); + + if (par1) + { + this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 | 2))); + } + else + { + this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 & -3))); + } + } + + public int getCollarColor() + { + return this.dataWatcher.getWatchableObjectByte(20) & 15; + } + + public void setCollarColor(int par1) + { + this.dataWatcher.updateObject(20, Byte.valueOf((byte)(par1 & 15))); + } + + public EntityWolf createChild(EntityAgeable par1EntityAgeable) + { + EntityWolf entitywolf = new EntityWolf(this.worldObj); + String s = this.getOwnerName(); + + if (s != null && s.trim().length() > 0) + { + entitywolf.setOwner(s); + entitywolf.setTamed(true); + } + + return entitywolf; + } + + public void func_70918_i(boolean par1) + { + if (par1) + { + this.dataWatcher.updateObject(19, Byte.valueOf((byte)1)); + } + else + { + this.dataWatcher.updateObject(19, Byte.valueOf((byte)0)); + } + } + + public boolean canMateWith(EntityAnimal par1EntityAnimal) + { + if (par1EntityAnimal == this) + { + return false; + } + else if (!this.isTamed()) + { + return false; + } + else if (!(par1EntityAnimal instanceof EntityWolf)) + { + return false; + } + else + { + EntityWolf entitywolf = (EntityWolf)par1EntityAnimal; + return !entitywolf.isTamed() ? false : (entitywolf.isSitting() ? false : this.isInLove() && entitywolf.isInLove()); + } + } + + public boolean func_70922_bv() + { + return this.dataWatcher.getWatchableObjectByte(19) == 1; + } + + protected boolean canDespawn() + { + return !this.isTamed() && this.ticksExisted > 2400; + } + + public boolean func_142018_a(EntityLivingBase par1EntityLivingBase, EntityLivingBase par2EntityLivingBase) + { + if (!(par1EntityLivingBase instanceof EntityCreeper) && !(par1EntityLivingBase instanceof EntityGhast)) + { + if (par1EntityLivingBase instanceof EntityWolf) + { + EntityWolf entitywolf = (EntityWolf)par1EntityLivingBase; + + if (entitywolf.isTamed() && entitywolf.getOwner() == par2EntityLivingBase) + { + return false; + } + } + + return par1EntityLivingBase instanceof EntityPlayer && par2EntityLivingBase instanceof EntityPlayer && !((EntityPlayer)par2EntityLivingBase).canAttackPlayer((EntityPlayer)par1EntityLivingBase) ? false : !(par1EntityLivingBase instanceof EntityHorse) || !((EntityHorse)par1EntityLivingBase).isTame(); + } + else + { + return false; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/passive/IAnimals.java b/src/main/java/net/minecraft/entity/passive/IAnimals.java new file mode 100644 index 0000000..d3d8677 --- /dev/null +++ b/src/main/java/net/minecraft/entity/passive/IAnimals.java @@ -0,0 +1,5 @@ +package net.minecraft.entity.passive; + +public interface IAnimals +{ +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/player/EntityPlayer.java b/src/main/java/net/minecraft/entity/player/EntityPlayer.java new file mode 100644 index 0000000..13cceb6 --- /dev/null +++ b/src/main/java/net/minecraft/entity/player/EntityPlayer.java @@ -0,0 +1,2330 @@ +package net.minecraft.entity.player; + +import com.google.common.base.Charsets; +import com.mojang.authlib.GameProfile; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.network.internal.FMLNetworkHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.UUID; +import java.util.Map.Entry; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockBed; +import net.minecraft.block.material.Material; +import net.minecraft.command.ICommandSender; +import net.minecraft.command.server.CommandBlockLogic; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityList; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IEntityMultiPart; +import net.minecraft.entity.IMerchant; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.attributes.IAttributeInstance; +import net.minecraft.entity.boss.EntityDragonPart; +import net.minecraft.entity.item.EntityBoat; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.item.EntityMinecart; +import net.minecraft.entity.item.EntityMinecartHopper; +import net.minecraft.entity.monster.EntityMob; +import net.minecraft.entity.monster.IMob; +import net.minecraft.entity.passive.EntityHorse; +import net.minecraft.entity.passive.EntityPig; +import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.entity.projectile.EntityFishHook; +import net.minecraft.event.ClickEvent; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ContainerPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.InventoryEnderChest; +import net.minecraft.item.EnumAction; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.potion.Potion; +import net.minecraft.scoreboard.IScoreObjectiveCriteria; +import net.minecraft.scoreboard.Score; +import net.minecraft.scoreboard.ScoreObjective; +import net.minecraft.scoreboard.ScorePlayerTeam; +import net.minecraft.scoreboard.Scoreboard; +import net.minecraft.scoreboard.Team; +import net.minecraft.stats.AchievementList; +import net.minecraft.stats.StatBase; +import net.minecraft.stats.StatList; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityBeacon; +import net.minecraft.tileentity.TileEntityBrewingStand; +import net.minecraft.tileentity.TileEntityDispenser; +import net.minecraft.tileentity.TileEntityFurnace; +import net.minecraft.tileentity.TileEntityHopper; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.DamageSource; +import net.minecraft.util.FoodStats; +import net.minecraft.util.IChatComponent; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.util.Util; +import net.minecraft.util.Vec3; +import net.minecraft.world.EnumDifficulty; +import net.minecraft.world.World; +import net.minecraft.world.WorldSettings; +import net.minecraft.world.chunk.IChunkProvider; + +import net.minecraftforge.common.ForgeHooks; +import net.minecraftforge.common.ISpecialArmor.ArmorProperties; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.ForgeEventFactory; +import net.minecraftforge.event.entity.living.LivingHurtEvent; +import net.minecraftforge.event.entity.player.AttackEntityEvent; +import net.minecraftforge.event.entity.player.EntityInteractEvent; +import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent; +import net.minecraftforge.event.entity.player.PlayerDropsEvent; +import net.minecraftforge.event.entity.player.PlayerFlyableFallEvent; +import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent; + +public abstract class EntityPlayer extends EntityLivingBase implements ICommandSender +{ + public static final String PERSISTED_NBT_TAG = "PlayerPersisted"; + private HashMap spawnChunkMap = new HashMap(); + private HashMap spawnForcedMap = new HashMap(); + + public InventoryPlayer inventory = new InventoryPlayer(this); + private InventoryEnderChest theInventoryEnderChest = new InventoryEnderChest(); + public Container inventoryContainer; + public Container openContainer; + protected FoodStats foodStats = new FoodStats(); + protected int flyToggleTimer; + public float prevCameraYaw; + public float cameraYaw; + public int xpCooldown; + public double field_71091_bM; + public double field_71096_bN; + public double field_71097_bO; + public double field_71094_bP; + public double field_71095_bQ; + public double field_71085_bR; + protected boolean sleeping; + public ChunkCoordinates playerLocation; + private int sleepTimer; + public float field_71079_bU; + @SideOnly(Side.CLIENT) + public float field_71082_cx; + public float field_71089_bV; + private ChunkCoordinates spawnChunk; + private boolean spawnForced; + private ChunkCoordinates startMinecartRidingCoordinate; + public PlayerCapabilities capabilities = new PlayerCapabilities(); + public int experienceLevel; + public int experienceTotal; + public float experience; + private ItemStack itemInUse; + private int itemInUseCount; + protected float speedOnGround = 0.1F; + protected float speedInAir = 0.02F; + private int field_82249_h; + private final GameProfile field_146106_i; + public EntityFishHook fishEntity; + private static final String __OBFID = "CL_00001711"; + + public EntityPlayer(World p_i45324_1_, GameProfile p_i45324_2_) + { + super(p_i45324_1_); + this.entityUniqueID = func_146094_a(p_i45324_2_); + this.field_146106_i = p_i45324_2_; + this.inventoryContainer = new ContainerPlayer(this.inventory, !p_i45324_1_.isRemote, this); + this.openContainer = this.inventoryContainer; + this.yOffset = 1.62F; + ChunkCoordinates chunkcoordinates = p_i45324_1_.getSpawnPoint(); + this.setLocationAndAngles((double)chunkcoordinates.posX + 0.5D, (double)(chunkcoordinates.posY + 1), (double)chunkcoordinates.posZ + 0.5D, 0.0F, 0.0F); + this.field_70741_aB = 180.0F; + this.fireResistance = 20; + this.eyeHeight = this.getDefaultEyeHeight(); + } + + protected void applyEntityAttributes() + { + super.applyEntityAttributes(); + this.getAttributeMap().registerAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(1.0D); + } + + protected void entityInit() + { + super.entityInit(); + this.dataWatcher.addObject(16, Byte.valueOf((byte)0)); + this.dataWatcher.addObject(17, Float.valueOf(0.0F)); + this.dataWatcher.addObject(18, Integer.valueOf(0)); + } + + @SideOnly(Side.CLIENT) + public ItemStack getItemInUse() + { + return this.itemInUse; + } + + @SideOnly(Side.CLIENT) + public int getItemInUseCount() + { + return this.itemInUseCount; + } + + public boolean isUsingItem() + { + return this.itemInUse != null; + } + + @SideOnly(Side.CLIENT) + public int getItemInUseDuration() + { + return this.isUsingItem() ? this.itemInUse.getMaxItemUseDuration() - this.itemInUseCount : 0; + } + + public void stopUsingItem() + { + if (this.itemInUse != null) + { + if (!ForgeEventFactory.onUseItemStop(this, itemInUse, itemInUseCount)) + this.itemInUse.onPlayerStoppedUsing(this.worldObj, this, this.itemInUseCount); + } + + this.clearItemInUse(); + } + + public void clearItemInUse() + { + this.itemInUse = null; + this.itemInUseCount = 0; + + if (!this.worldObj.isRemote) + { + this.setEating(false); + } + } + + public boolean isBlocking() + { + return this.isUsingItem() && this.itemInUse.getItem().getItemUseAction(this.itemInUse) == EnumAction.block; + } + + public void onUpdate() + { + FMLCommonHandler.instance().onPlayerPreTick(this); + if (this.itemInUse != null) + { + ItemStack itemstack = this.inventory.getCurrentItem(); + + if (itemstack == this.itemInUse) + { + itemInUseCount = ForgeEventFactory.onItemUseTick(this, itemInUse, itemInUseCount); + if (itemInUseCount <= 0) + { + this.onItemUseFinish(); + } + else + { + itemInUse.getItem().onUsingTick(itemInUse, this, itemInUseCount); + if (this.itemInUseCount <= 25 && this.itemInUseCount % 4 == 0) + { + this.updateItemUse(itemstack, 5); + } + + if (--this.itemInUseCount == 0 && !this.worldObj.isRemote) + { + this.onItemUseFinish(); + } + } + } + else + { + this.clearItemInUse(); + } + } + + if (this.xpCooldown > 0) + { + --this.xpCooldown; + } + + if (this.isPlayerSleeping()) + { + ++this.sleepTimer; + + if (this.sleepTimer > 100) + { + this.sleepTimer = 100; + } + + if (!this.worldObj.isRemote) + { + if (!this.isInBed()) + { + this.wakeUpPlayer(true, true, false); + } + else if (this.worldObj.isDaytime()) + { + this.wakeUpPlayer(false, true, true); + } + } + } + else if (this.sleepTimer > 0) + { + ++this.sleepTimer; + + if (this.sleepTimer >= 110) + { + this.sleepTimer = 0; + } + } + + super.onUpdate(); + + if (!this.worldObj.isRemote && this.openContainer != null && !ForgeHooks.canInteractWith(this, this.openContainer)) + { + this.closeScreen(); + this.openContainer = this.inventoryContainer; + } + + if (this.isBurning() && this.capabilities.disableDamage) + { + this.extinguish(); + } + + this.field_71091_bM = this.field_71094_bP; + this.field_71096_bN = this.field_71095_bQ; + this.field_71097_bO = this.field_71085_bR; + double d3 = this.posX - this.field_71094_bP; + double d0 = this.posY - this.field_71095_bQ; + double d1 = this.posZ - this.field_71085_bR; + double d2 = 10.0D; + + if (d3 > d2) + { + this.field_71091_bM = this.field_71094_bP = this.posX; + } + + if (d1 > d2) + { + this.field_71097_bO = this.field_71085_bR = this.posZ; + } + + if (d0 > d2) + { + this.field_71096_bN = this.field_71095_bQ = this.posY; + } + + if (d3 < -d2) + { + this.field_71091_bM = this.field_71094_bP = this.posX; + } + + if (d1 < -d2) + { + this.field_71097_bO = this.field_71085_bR = this.posZ; + } + + if (d0 < -d2) + { + this.field_71096_bN = this.field_71095_bQ = this.posY; + } + + this.field_71094_bP += d3 * 0.25D; + this.field_71085_bR += d1 * 0.25D; + this.field_71095_bQ += d0 * 0.25D; + + if (this.ridingEntity == null) + { + this.startMinecartRidingCoordinate = null; + } + + if (!this.worldObj.isRemote) + { + this.foodStats.onUpdate(this); + this.addStat(StatList.minutesPlayedStat, 1); + } + FMLCommonHandler.instance().onPlayerPostTick(this); + } + + public int getMaxInPortalTime() + { + return this.capabilities.disableDamage ? 0 : 80; + } + + protected String getSwimSound() + { + return "game.player.swim"; + } + + protected String getSplashSound() + { + return "game.player.swim.splash"; + } + + public int getPortalCooldown() + { + return 10; + } + + public void playSound(String par1Str, float par2, float par3) + { + this.worldObj.playSoundToNearExcept(this, par1Str, par2, par3); + } + + protected void updateItemUse(ItemStack par1ItemStack, int par2) + { + if (par1ItemStack.getItemUseAction() == EnumAction.drink) + { + this.playSound("random.drink", 0.5F, this.worldObj.rand.nextFloat() * 0.1F + 0.9F); + } + + if (par1ItemStack.getItemUseAction() == EnumAction.eat) + { + for (int j = 0; j < par2; ++j) + { + Vec3 vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(((double)this.rand.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D); + vec3.rotateAroundX(-this.rotationPitch * (float)Math.PI / 180.0F); + vec3.rotateAroundY(-this.rotationYaw * (float)Math.PI / 180.0F); + Vec3 vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(((double)this.rand.nextFloat() - 0.5D) * 0.3D, (double)(-this.rand.nextFloat()) * 0.6D - 0.3D, 0.6D); + vec31.rotateAroundX(-this.rotationPitch * (float)Math.PI / 180.0F); + vec31.rotateAroundY(-this.rotationYaw * (float)Math.PI / 180.0F); + vec31 = vec31.addVector(this.posX, this.posY + (double)this.getEyeHeight(), this.posZ); + String s = "iconcrack_" + Item.getIdFromItem(par1ItemStack.getItem()); + + if (par1ItemStack.getHasSubtypes()) + { + s = s + "_" + par1ItemStack.getItemDamage(); + } + + this.worldObj.spawnParticle(s, vec31.xCoord, vec31.yCoord, vec31.zCoord, vec3.xCoord, vec3.yCoord + 0.05D, vec3.zCoord); + } + + this.playSound("random.eat", 0.5F + 0.5F * (float)this.rand.nextInt(2), (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F); + } + } + + protected void onItemUseFinish() + { + if (this.itemInUse != null) + { + this.updateItemUse(this.itemInUse, 16); + int i = this.itemInUse.stackSize; + ItemStack itemstack = this.itemInUse.onFoodEaten(this.worldObj, this); + + itemstack = ForgeEventFactory.onItemUseFinish(this, itemInUse, itemInUseCount, itemstack); + + if (itemstack != this.itemInUse || itemstack != null && itemstack.stackSize != i) + { + this.inventory.mainInventory[this.inventory.currentItem] = itemstack; + + if (itemstack != null && itemstack.stackSize == 0) + { + this.inventory.mainInventory[this.inventory.currentItem] = null; + } + } + + this.clearItemInUse(); + } + } + + @SideOnly(Side.CLIENT) + public void handleHealthUpdate(byte par1) + { + if (par1 == 9) + { + this.onItemUseFinish(); + } + else + { + super.handleHealthUpdate(par1); + } + } + + protected boolean isMovementBlocked() + { + return this.getHealth() <= 0.0F || this.isPlayerSleeping(); + } + + public void closeScreen() + { + this.openContainer = this.inventoryContainer; + } + + public void mountEntity(Entity par1Entity) + { + if (this.ridingEntity != null && par1Entity == null) + { + if (!this.worldObj.isRemote) + { + this.dismountEntity(this.ridingEntity); + } + + if (this.ridingEntity != null) + { + this.ridingEntity.riddenByEntity = null; + } + + this.ridingEntity = null; + } + else + { + super.mountEntity(par1Entity); + } + } + + public void updateRidden() + { + if (!this.worldObj.isRemote && this.isSneaking()) + { + this.mountEntity((Entity)null); + this.setSneaking(false); + } + else + { + double d0 = this.posX; + double d1 = this.posY; + double d2 = this.posZ; + float f = this.rotationYaw; + float f1 = this.rotationPitch; + super.updateRidden(); + this.prevCameraYaw = this.cameraYaw; + this.cameraYaw = 0.0F; + this.addMountedMovementStat(this.posX - d0, this.posY - d1, this.posZ - d2); + + if (this.ridingEntity instanceof EntityLivingBase && ((EntityLivingBase)ridingEntity).shouldRiderFaceForward(this)) + { + this.rotationPitch = f1; + this.rotationYaw = f; + this.renderYawOffset = ((EntityLivingBase)this.ridingEntity).renderYawOffset; + } + } + } + + @SideOnly(Side.CLIENT) + public void preparePlayerToSpawn() + { + this.yOffset = 1.62F; + this.setSize(0.6F, 1.8F); + super.preparePlayerToSpawn(); + this.setHealth(this.getMaxHealth()); + this.deathTime = 0; + } + + protected void updateEntityActionState() + { + super.updateEntityActionState(); + this.updateArmSwingProgress(); + } + + public void onLivingUpdate() + { + if (this.flyToggleTimer > 0) + { + --this.flyToggleTimer; + } + + if (this.worldObj.difficultySetting == EnumDifficulty.PEACEFUL && this.getHealth() < this.getMaxHealth() && this.worldObj.getGameRules().getGameRuleBooleanValue("naturalRegeneration") && this.ticksExisted % 20 * 12 == 0) + { + this.heal(1.0F); + } + + this.inventory.decrementAnimations(); + this.prevCameraYaw = this.cameraYaw; + super.onLivingUpdate(); + IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed); + + if (!this.worldObj.isRemote) + { + iattributeinstance.setBaseValue((double)this.capabilities.getWalkSpeed()); + } + + this.jumpMovementFactor = this.speedInAir; + + if (this.isSprinting()) + { + this.jumpMovementFactor = (float)((double)this.jumpMovementFactor + (double)this.speedInAir * 0.3D); + } + + this.setAIMoveSpeed((float)iattributeinstance.getAttributeValue()); + float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); + float f1 = (float)Math.atan(-this.motionY * 0.20000000298023224D) * 15.0F; + + if (f > 0.1F) + { + f = 0.1F; + } + + if (!this.onGround || this.getHealth() <= 0.0F) + { + f = 0.0F; + } + + if (this.onGround || this.getHealth() <= 0.0F) + { + f1 = 0.0F; + } + + this.cameraYaw += (f - this.cameraYaw) * 0.4F; + this.cameraPitch += (f1 - this.cameraPitch) * 0.8F; + + if (this.getHealth() > 0.0F) + { + AxisAlignedBB axisalignedbb = null; + + if (this.ridingEntity != null && !this.ridingEntity.isDead) + { + axisalignedbb = this.boundingBox.func_111270_a(this.ridingEntity.boundingBox).expand(1.0D, 0.0D, 1.0D); + } + else + { + axisalignedbb = this.boundingBox.expand(1.0D, 0.5D, 1.0D); + } + + List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, axisalignedbb); + + if (list != null) + { + for (int i = 0; i < list.size(); ++i) + { + Entity entity = (Entity)list.get(i); + + if (!entity.isDead) + { + this.collideWithPlayer(entity); + } + } + } + } + } + + private void collideWithPlayer(Entity par1Entity) + { + par1Entity.onCollideWithPlayer(this); + } + + public int getScore() + { + return this.dataWatcher.getWatchableObjectInt(18); + } + + public void setScore(int par1) + { + this.dataWatcher.updateObject(18, Integer.valueOf(par1)); + } + + public void addScore(int par1) + { + int j = this.getScore(); + this.dataWatcher.updateObject(18, Integer.valueOf(j + par1)); + } + + public void onDeath(DamageSource par1DamageSource) + { + if (ForgeHooks.onLivingDeath(this, par1DamageSource)) return; + super.onDeath(par1DamageSource); + this.setSize(0.2F, 0.2F); + this.setPosition(this.posX, this.posY, this.posZ); + this.motionY = 0.10000000149011612D; + + captureDrops = true; + capturedDrops.clear(); + + if (this.getCommandSenderName().equals("Notch")) + { + this.func_146097_a(new ItemStack(Items.apple, 1), true, false); + } + + if (!this.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory")) + { + this.inventory.dropAllItems(); + } + + captureDrops = false; + + if (!worldObj.isRemote) + { + PlayerDropsEvent event = new PlayerDropsEvent(this, par1DamageSource, capturedDrops, recentlyHit > 0); + if (!MinecraftForge.EVENT_BUS.post(event)) + { + for (EntityItem item : capturedDrops) + { + joinEntityItemWithWorld(item); + } + } + } + + if (par1DamageSource != null) + { + this.motionX = (double)(-MathHelper.cos((this.attackedAtYaw + this.rotationYaw) * (float)Math.PI / 180.0F) * 0.1F); + this.motionZ = (double)(-MathHelper.sin((this.attackedAtYaw + this.rotationYaw) * (float)Math.PI / 180.0F) * 0.1F); + } + else + { + this.motionX = this.motionZ = 0.0D; + } + + this.yOffset = 0.1F; + this.addStat(StatList.deathsStat, 1); + } + + protected String getHurtSound() + { + return "game.player.hurt"; + } + + protected String getDeathSound() + { + return "game.player.die"; + } + + public void addToPlayerScore(Entity par1Entity, int par2) + { + this.addScore(par2); + Collection collection = this.getWorldScoreboard().func_96520_a(IScoreObjectiveCriteria.totalKillCount); + + if (par1Entity instanceof EntityPlayer) + { + this.addStat(StatList.playerKillsStat, 1); + collection.addAll(this.getWorldScoreboard().func_96520_a(IScoreObjectiveCriteria.playerKillCount)); + } + else + { + this.addStat(StatList.mobKillsStat, 1); + } + + Iterator iterator = collection.iterator(); + + while (iterator.hasNext()) + { + ScoreObjective scoreobjective = (ScoreObjective)iterator.next(); + Score score = this.getWorldScoreboard().func_96529_a(this.getCommandSenderName(), scoreobjective); + score.func_96648_a(); + } + } + + public EntityItem dropOneItem(boolean par1) + { + ItemStack stack = inventory.getCurrentItem(); + + if (stack == null) + { + return null; + } + + if (stack.getItem().onDroppedByPlayer(stack, this)) + { + int count = par1 && this.inventory.getCurrentItem() != null ? this.inventory.getCurrentItem().stackSize : 1; + return ForgeHooks.onPlayerTossEvent(this, inventory.decrStackSize(inventory.currentItem, count), true); + } + + return null; + } + + public EntityItem dropPlayerItemWithRandomChoice(ItemStack par1ItemStack, boolean par2) + { + return ForgeHooks.onPlayerTossEvent(this, par1ItemStack, false); + } + + public EntityItem func_146097_a(ItemStack p_146097_1_, boolean p_146097_2_, boolean p_146097_3_) + { + if (p_146097_1_ == null) + { + return null; + } + else if (p_146097_1_.stackSize == 0) + { + return null; + } + else + { + EntityItem entityitem = new EntityItem(this.worldObj, this.posX, this.posY - 0.30000001192092896D + (double)this.getEyeHeight(), this.posZ, p_146097_1_); + entityitem.delayBeforeCanPickup = 40; + + if (p_146097_3_) + { + entityitem.func_145799_b(this.getCommandSenderName()); + } + + float f = 0.1F; + float f1; + + if (p_146097_2_) + { + f1 = this.rand.nextFloat() * 0.5F; + float f2 = this.rand.nextFloat() * (float)Math.PI * 2.0F; + entityitem.motionX = (double)(-MathHelper.sin(f2) * f1); + entityitem.motionZ = (double)(MathHelper.cos(f2) * f1); + entityitem.motionY = 0.20000000298023224D; + } + else + { + f = 0.3F; + entityitem.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * f); + entityitem.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * f); + entityitem.motionY = (double)(-MathHelper.sin(this.rotationPitch / 180.0F * (float)Math.PI) * f + 0.1F); + f = 0.02F; + f1 = this.rand.nextFloat() * (float)Math.PI * 2.0F; + f *= this.rand.nextFloat(); + entityitem.motionX += Math.cos((double)f1) * (double)f; + entityitem.motionY += (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.1F); + entityitem.motionZ += Math.sin((double)f1) * (double)f; + } + + this.joinEntityItemWithWorld(entityitem); + this.addStat(StatList.dropStat, 1); + return entityitem; + } + } + + public void joinEntityItemWithWorld(EntityItem par1EntityItem) + { + if (captureDrops) + { + capturedDrops.add(par1EntityItem); + return; + } + this.worldObj.spawnEntityInWorld(par1EntityItem); + } + + @Deprecated //Metadata sensitive version, named getBreakSpeed + public float getCurrentPlayerStrVsBlock(Block p_146096_1_, boolean p_146096_2_) + { + return getBreakSpeed(p_146096_1_, p_146096_2_, 0, 0, -1, 0); + } + + @Deprecated //Location Specifc, one below, remove in 1.8 + public float getBreakSpeed(Block p_146096_1_, boolean p_146096_2_, int meta) + { + return getBreakSpeed(p_146096_1_, p_146096_2_, meta, 0, -1, 0); + } + + public float getBreakSpeed(Block p_146096_1_, boolean p_146096_2_, int meta, int x, int y, int z) + { + ItemStack stack = inventory.getCurrentItem(); + float f = (stack == null ? 1.0F : stack.getItem().getDigSpeed(stack, p_146096_1_, meta)); + + if (f > 1.0F) + { + int i = EnchantmentHelper.getEfficiencyModifier(this); + ItemStack itemstack = this.inventory.getCurrentItem(); + + if (i > 0 && itemstack != null) + { + float f1 = (float)(i * i + 1); + + boolean canHarvest = ForgeHooks.canToolHarvestBlock(p_146096_1_, meta, itemstack); + + if (!canHarvest && f <= 1.0F) + { + f += f1 * 0.08F; + } + else + { + f += f1; + } + } + } + + if (this.isPotionActive(Potion.digSpeed)) + { + f *= 1.0F + (float)(this.getActivePotionEffect(Potion.digSpeed).getAmplifier() + 1) * 0.2F; + } + + if (this.isPotionActive(Potion.digSlowdown)) + { + f *= 1.0F - (float)(this.getActivePotionEffect(Potion.digSlowdown).getAmplifier() + 1) * 0.2F; + } + + if (this.isInsideOfMaterial(Material.water) && !EnchantmentHelper.getAquaAffinityModifier(this)) + { + f /= 5.0F; + } + + if (!this.onGround) + { + f /= 5.0F; + } + + f = ForgeEventFactory.getBreakSpeed(this, p_146096_1_, meta, f, x, y, z); + return (f < 0 ? 0 : f); + } + + public boolean canHarvestBlock(Block p_146099_1_) + { + return ForgeEventFactory.doPlayerHarvestCheck(this, p_146099_1_, this.inventory.func_146025_b(p_146099_1_)); + } + + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + super.readEntityFromNBT(par1NBTTagCompound); + this.entityUniqueID = func_146094_a(this.field_146106_i); + NBTTagList nbttaglist = par1NBTTagCompound.getTagList("Inventory", 10); + this.inventory.readFromNBT(nbttaglist); + this.inventory.currentItem = par1NBTTagCompound.getInteger("SelectedItemSlot"); + this.sleeping = par1NBTTagCompound.getBoolean("Sleeping"); + this.sleepTimer = par1NBTTagCompound.getShort("SleepTimer"); + this.experience = par1NBTTagCompound.getFloat("XpP"); + this.experienceLevel = par1NBTTagCompound.getInteger("XpLevel"); + this.experienceTotal = par1NBTTagCompound.getInteger("XpTotal"); + this.setScore(par1NBTTagCompound.getInteger("Score")); + + if (this.sleeping) + { + this.playerLocation = new ChunkCoordinates(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)); + this.wakeUpPlayer(true, true, false); + } + + if (par1NBTTagCompound.hasKey("SpawnX", 99) && par1NBTTagCompound.hasKey("SpawnY", 99) && par1NBTTagCompound.hasKey("SpawnZ", 99)) + { + this.spawnChunk = new ChunkCoordinates(par1NBTTagCompound.getInteger("SpawnX"), par1NBTTagCompound.getInteger("SpawnY"), par1NBTTagCompound.getInteger("SpawnZ")); + this.spawnForced = par1NBTTagCompound.getBoolean("SpawnForced"); + } + + NBTTagList spawnlist = null; + spawnlist = par1NBTTagCompound.getTagList("Spawns", 10); + for (int i = 0; i < spawnlist.tagCount(); i++) + { + NBTTagCompound spawndata = (NBTTagCompound)spawnlist.getCompoundTagAt(i); + int spawndim = spawndata.getInteger("Dim"); + this.spawnChunkMap.put(spawndim, new ChunkCoordinates(spawndata.getInteger("SpawnX"), spawndata.getInteger("SpawnY"), spawndata.getInteger("SpawnZ"))); + this.spawnForcedMap.put(spawndim, spawndata.getBoolean("SpawnForced")); + } + + this.foodStats.readNBT(par1NBTTagCompound); + this.capabilities.readCapabilitiesFromNBT(par1NBTTagCompound); + + if (par1NBTTagCompound.hasKey("EnderItems", 9)) + { + NBTTagList nbttaglist1 = par1NBTTagCompound.getTagList("EnderItems", 10); + this.theInventoryEnderChest.loadInventoryFromNBT(nbttaglist1); + } + } + + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeEntityToNBT(par1NBTTagCompound); + par1NBTTagCompound.setTag("Inventory", this.inventory.writeToNBT(new NBTTagList())); + par1NBTTagCompound.setInteger("SelectedItemSlot", this.inventory.currentItem); + par1NBTTagCompound.setBoolean("Sleeping", this.sleeping); + par1NBTTagCompound.setShort("SleepTimer", (short)this.sleepTimer); + par1NBTTagCompound.setFloat("XpP", this.experience); + par1NBTTagCompound.setInteger("XpLevel", this.experienceLevel); + par1NBTTagCompound.setInteger("XpTotal", this.experienceTotal); + par1NBTTagCompound.setInteger("Score", this.getScore()); + + if (this.spawnChunk != null) + { + par1NBTTagCompound.setInteger("SpawnX", this.spawnChunk.posX); + par1NBTTagCompound.setInteger("SpawnY", this.spawnChunk.posY); + par1NBTTagCompound.setInteger("SpawnZ", this.spawnChunk.posZ); + par1NBTTagCompound.setBoolean("SpawnForced", this.spawnForced); + } + + NBTTagList spawnlist = new NBTTagList(); + for (Entry entry : this.spawnChunkMap.entrySet()) + { + ChunkCoordinates spawn = entry.getValue(); + if (spawn == null) continue; + Boolean forced = spawnForcedMap.get(entry.getKey()); + if (forced == null) forced = false; + NBTTagCompound spawndata = new NBTTagCompound(); + spawndata.setInteger("Dim", entry.getKey()); + spawndata.setInteger("SpawnX", spawn.posX); + spawndata.setInteger("SpawnY", spawn.posY); + spawndata.setInteger("SpawnZ", spawn.posZ); + spawndata.setBoolean("SpawnForced", forced); + spawnlist.appendTag(spawndata); + } + par1NBTTagCompound.setTag("Spawns", spawnlist); + + this.foodStats.writeNBT(par1NBTTagCompound); + this.capabilities.writeCapabilitiesToNBT(par1NBTTagCompound); + par1NBTTagCompound.setTag("EnderItems", this.theInventoryEnderChest.saveInventoryToNBT()); + } + + public void displayGUIChest(IInventory par1IInventory) {} + + public void func_146093_a(TileEntityHopper p_146093_1_) {} + + public void displayGUIHopperMinecart(EntityMinecartHopper par1EntityMinecartHopper) {} + + public void displayGUIHorse(EntityHorse par1EntityHorse, IInventory par2IInventory) {} + + public void displayGUIEnchantment(int par1, int par2, int par3, String par4Str) {} + + public void displayGUIAnvil(int par1, int par2, int par3) {} + + public void displayGUIWorkbench(int par1, int par2, int par3) {} + + public float getEyeHeight() + { + return eyeHeight; + } + + protected void resetHeight() + { + this.yOffset = 1.62F; + } + + public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) + { + if (ForgeHooks.onLivingAttack(this, par1DamageSource, par2)) return false; + if (this.isEntityInvulnerable()) + { + return false; + } + else if (this.capabilities.disableDamage && !par1DamageSource.canHarmInCreative()) + { + return false; + } + else + { + this.entityAge = 0; + + if (this.getHealth() <= 0.0F) + { + return false; + } + else + { + if (this.isPlayerSleeping() && !this.worldObj.isRemote) + { + this.wakeUpPlayer(true, true, false); + } + + if (par1DamageSource.isDifficultyScaled()) + { + if (this.worldObj.difficultySetting == EnumDifficulty.PEACEFUL) + { + par2 = 0.0F; + } + + if (this.worldObj.difficultySetting == EnumDifficulty.EASY) + { + par2 = par2 / 2.0F + 1.0F; + } + + if (this.worldObj.difficultySetting == EnumDifficulty.HARD) + { + par2 = par2 * 3.0F / 2.0F; + } + } + + if (par2 == 0.0F) + { + return false; + } + else + { + Entity entity = par1DamageSource.getEntity(); + + if (entity instanceof EntityArrow && ((EntityArrow)entity).shootingEntity != null) + { + entity = ((EntityArrow)entity).shootingEntity; + } + + this.addStat(StatList.damageTakenStat, Math.round(par2 * 10.0F)); + return super.attackEntityFrom(par1DamageSource, par2); + } + } + } + } + + public boolean canAttackPlayer(EntityPlayer par1EntityPlayer) + { + Team team = this.getTeam(); + Team team1 = par1EntityPlayer.getTeam(); + return team == null ? true : (!team.isSameTeam(team1) ? true : team.getAllowFriendlyFire()); + } + + protected void damageArmor(float par1) + { + this.inventory.damageArmor(par1); + } + + public int getTotalArmorValue() + { + return this.inventory.getTotalArmorValue(); + } + + public float getArmorVisibility() + { + int i = 0; + ItemStack[] aitemstack = this.inventory.armorInventory; + int j = aitemstack.length; + + for (int k = 0; k < j; ++k) + { + ItemStack itemstack = aitemstack[k]; + + if (itemstack != null) + { + ++i; + } + } + + return (float)i / (float)this.inventory.armorInventory.length; + } + + protected void damageEntity(DamageSource par1DamageSource, float par2) + { + if (!this.isEntityInvulnerable()) + { + par2 = ForgeHooks.onLivingHurt(this, par1DamageSource, par2); + if (par2 <= 0) return; + if (!par1DamageSource.isUnblockable() && this.isBlocking() && par2 > 0.0F) + { + par2 = (1.0F + par2) * 0.5F; + } + + par2 = ArmorProperties.ApplyArmor(this, inventory.armorInventory, par1DamageSource, par2); + if (par2 <= 0) return; + par2 = this.applyPotionDamageCalculations(par1DamageSource, par2); + float f1 = par2; + par2 = Math.max(par2 - this.getAbsorptionAmount(), 0.0F); + this.setAbsorptionAmount(this.getAbsorptionAmount() - (f1 - par2)); + + if (par2 != 0.0F) + { + this.addExhaustion(par1DamageSource.getHungerDamage()); + float f2 = this.getHealth(); + this.setHealth(this.getHealth() - par2); + this.func_110142_aN().func_94547_a(par1DamageSource, f2, par2); + } + } + } + + public void func_146101_a(TileEntityFurnace p_146101_1_) {} + + public void func_146102_a(TileEntityDispenser p_146102_1_) {} + + public void func_146100_a(TileEntity p_146100_1_) {} + + public void func_146095_a(CommandBlockLogic p_146095_1_) {} + + public void func_146098_a(TileEntityBrewingStand p_146098_1_) {} + + public void func_146104_a(TileEntityBeacon p_146104_1_) {} + + public void displayGUIMerchant(IMerchant par1IMerchant, String par2Str) {} + + public void displayGUIBook(ItemStack par1ItemStack) {} + + public boolean interactWith(Entity par1Entity) + { + if (MinecraftForge.EVENT_BUS.post(new EntityInteractEvent(this, par1Entity))) return false; + ItemStack itemstack = this.getCurrentEquippedItem(); + ItemStack itemstack1 = itemstack != null ? itemstack.copy() : null; + + if (!par1Entity.interactFirst(this)) + { + if (itemstack != null && par1Entity instanceof EntityLivingBase) + { + if (this.capabilities.isCreativeMode) + { + itemstack = itemstack1; + } + + if (itemstack.interactWithEntity(this, (EntityLivingBase)par1Entity)) + { + if (itemstack.stackSize <= 0 && !this.capabilities.isCreativeMode) + { + this.destroyCurrentEquippedItem(); + } + + return true; + } + } + + return false; + } + else + { + if (itemstack != null && itemstack == this.getCurrentEquippedItem()) + { + if (itemstack.stackSize <= 0 && !this.capabilities.isCreativeMode) + { + this.destroyCurrentEquippedItem(); + } + else if (itemstack.stackSize < itemstack1.stackSize && this.capabilities.isCreativeMode) + { + itemstack.stackSize = itemstack1.stackSize; + } + } + + return true; + } + } + + public ItemStack getCurrentEquippedItem() + { + return this.inventory.getCurrentItem(); + } + + public void destroyCurrentEquippedItem() + { + ItemStack orig = getCurrentEquippedItem(); + this.inventory.setInventorySlotContents(this.inventory.currentItem, (ItemStack)null); + MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(this, orig)); + } + + public double getYOffset() + { + return (double)(this.yOffset - 0.5F); + } + + public void attackTargetEntityWithCurrentItem(Entity par1Entity) + { + if (MinecraftForge.EVENT_BUS.post(new AttackEntityEvent(this, par1Entity))) + { + return; + } + ItemStack stack = getCurrentEquippedItem(); + if (stack != null && stack.getItem().onLeftClickEntity(stack, this, par1Entity)) + { + return; + } + if (par1Entity.canAttackWithItem()) + { + if (!par1Entity.hitByEntity(this)) + { + float f = (float)this.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue(); + int i = 0; + float f1 = 0.0F; + + if (par1Entity instanceof EntityLivingBase) + { + f1 = EnchantmentHelper.getEnchantmentModifierLiving(this, (EntityLivingBase)par1Entity); + i += EnchantmentHelper.getKnockbackModifier(this, (EntityLivingBase)par1Entity); + } + + if (this.isSprinting()) + { + ++i; + } + + if (f > 0.0F || f1 > 0.0F) + { + boolean flag = this.fallDistance > 0.0F && !this.onGround && !this.isOnLadder() && !this.isInWater() && !this.isPotionActive(Potion.blindness) && this.ridingEntity == null && par1Entity instanceof EntityLivingBase; + + if (flag && f > 0.0F) + { + f *= 1.5F; + } + + f += f1; + boolean flag1 = false; + int j = EnchantmentHelper.getFireAspectModifier(this); + + if (par1Entity instanceof EntityLivingBase && j > 0 && !par1Entity.isBurning()) + { + flag1 = true; + par1Entity.setFire(1); + } + + boolean flag2 = par1Entity.attackEntityFrom(DamageSource.causePlayerDamage(this), f); + + if (flag2) + { + if (i > 0) + { + par1Entity.addVelocity((double)(-MathHelper.sin(this.rotationYaw * (float)Math.PI / 180.0F) * (float)i * 0.5F), 0.1D, (double)(MathHelper.cos(this.rotationYaw * (float)Math.PI / 180.0F) * (float)i * 0.5F)); + this.motionX *= 0.6D; + this.motionZ *= 0.6D; + this.setSprinting(false); + } + + if (flag) + { + this.onCriticalHit(par1Entity); + } + + if (f1 > 0.0F) + { + this.onEnchantmentCritical(par1Entity); + } + + if (f >= 18.0F) + { + this.triggerAchievement(AchievementList.overkill); + } + + this.setLastAttacker(par1Entity); + + if (par1Entity instanceof EntityLivingBase) + { + EnchantmentHelper.func_151384_a((EntityLivingBase)par1Entity, this); + } + + EnchantmentHelper.func_151385_b(this, par1Entity); + ItemStack itemstack = this.getCurrentEquippedItem(); + Object object = par1Entity; + + if (par1Entity instanceof EntityDragonPart) + { + IEntityMultiPart ientitymultipart = ((EntityDragonPart)par1Entity).entityDragonObj; + + if (ientitymultipart != null && ientitymultipart instanceof EntityLivingBase) + { + object = (EntityLivingBase)ientitymultipart; + } + } + + if (itemstack != null && object instanceof EntityLivingBase) + { + itemstack.hitEntity((EntityLivingBase)object, this); + + if (itemstack.stackSize <= 0) + { + this.destroyCurrentEquippedItem(); + } + } + + if (par1Entity instanceof EntityLivingBase) + { + this.addStat(StatList.damageDealtStat, Math.round(f * 10.0F)); + + if (j > 0) + { + par1Entity.setFire(j * 4); + } + } + + this.addExhaustion(0.3F); + } + else if (flag1) + { + par1Entity.extinguish(); + } + } + } + } + } + + public void onCriticalHit(Entity par1Entity) {} + + public void onEnchantmentCritical(Entity par1Entity) {} + + @SideOnly(Side.CLIENT) + public void respawnPlayer() {} + + public void setDead() + { + super.setDead(); + this.inventoryContainer.onContainerClosed(this); + + if (this.openContainer != null) + { + this.openContainer.onContainerClosed(this); + } + } + + public boolean isEntityInsideOpaqueBlock() + { + return !this.sleeping && super.isEntityInsideOpaqueBlock(); + } + + public GameProfile getGameProfile() + { + return this.field_146106_i; + } + + public EntityPlayer.EnumStatus sleepInBedAt(int par1, int par2, int par3) + { + PlayerSleepInBedEvent event = new PlayerSleepInBedEvent(this, par1, par2, par3); + MinecraftForge.EVENT_BUS.post(event); + if (event.result != null) + { + return event.result; + } + if (!this.worldObj.isRemote) + { + if (this.isPlayerSleeping() || !this.isEntityAlive()) + { + return EntityPlayer.EnumStatus.OTHER_PROBLEM; + } + + if (!this.worldObj.provider.isSurfaceWorld()) + { + return EntityPlayer.EnumStatus.NOT_POSSIBLE_HERE; + } + + if (this.worldObj.isDaytime()) + { + return EntityPlayer.EnumStatus.NOT_POSSIBLE_NOW; + } + + if (Math.abs(this.posX - (double)par1) > 3.0D || Math.abs(this.posY - (double)par2) > 2.0D || Math.abs(this.posZ - (double)par3) > 3.0D) + { + return EntityPlayer.EnumStatus.TOO_FAR_AWAY; + } + + double d0 = 8.0D; + double d1 = 5.0D; + List list = this.worldObj.getEntitiesWithinAABB(EntityMob.class, AxisAlignedBB.getAABBPool().getAABB((double)par1 - d0, (double)par2 - d1, (double)par3 - d0, (double)par1 + d0, (double)par2 + d1, (double)par3 + d0)); + + if (!list.isEmpty()) + { + return EntityPlayer.EnumStatus.NOT_SAFE; + } + } + + if (this.isRiding()) + { + this.mountEntity((Entity)null); + } + + this.setSize(0.2F, 0.2F); + this.yOffset = 0.2F; + + if (this.worldObj.blockExists(par1, par2, par3)) + { + int l = worldObj.getBlock(par1, par2, par3).getBedDirection(worldObj, par1, par2, par3); + float f1 = 0.5F; + float f = 0.5F; + + switch (l) + { + case 0: + f = 0.9F; + break; + case 1: + f1 = 0.1F; + break; + case 2: + f = 0.1F; + break; + case 3: + f1 = 0.9F; + } + + this.func_71013_b(l); + this.setPosition((double)((float)par1 + f1), (double)((float)par2 + 0.9375F), (double)((float)par3 + f)); + } + else + { + this.setPosition((double)((float)par1 + 0.5F), (double)((float)par2 + 0.9375F), (double)((float)par3 + 0.5F)); + } + + this.sleeping = true; + this.sleepTimer = 0; + this.playerLocation = new ChunkCoordinates(par1, par2, par3); + this.motionX = this.motionZ = this.motionY = 0.0D; + + if (!this.worldObj.isRemote) + { + this.worldObj.updateAllPlayersSleepingFlag(); + } + + return EntityPlayer.EnumStatus.OK; + } + + private void func_71013_b(int par1) + { + this.field_71079_bU = 0.0F; + this.field_71089_bV = 0.0F; + + switch (par1) + { + case 0: + this.field_71089_bV = -1.8F; + break; + case 1: + this.field_71079_bU = 1.8F; + break; + case 2: + this.field_71089_bV = 1.8F; + break; + case 3: + this.field_71079_bU = -1.8F; + } + } + + public void wakeUpPlayer(boolean par1, boolean par2, boolean par3) + { + this.setSize(0.6F, 1.8F); + this.resetHeight(); + ChunkCoordinates chunkcoordinates = this.playerLocation; + ChunkCoordinates chunkcoordinates1 = this.playerLocation; + Block block = (chunkcoordinates == null ? null : worldObj.getBlock(chunkcoordinates.posX, chunkcoordinates.posY, chunkcoordinates.posZ)); + + if (chunkcoordinates != null && block.isBed(worldObj, chunkcoordinates.posX, chunkcoordinates.posY, chunkcoordinates.posZ, this)) + { + block.setBedOccupied(this.worldObj, chunkcoordinates.posX, chunkcoordinates.posY, chunkcoordinates.posZ, this, false); + chunkcoordinates1 = block.getBedSpawnPosition(this.worldObj, chunkcoordinates.posX, chunkcoordinates.posY, chunkcoordinates.posZ, this); + + if (chunkcoordinates1 == null) + { + chunkcoordinates1 = new ChunkCoordinates(chunkcoordinates.posX, chunkcoordinates.posY + 1, chunkcoordinates.posZ); + } + + this.setPosition((double)((float)chunkcoordinates1.posX + 0.5F), (double)((float)chunkcoordinates1.posY + this.yOffset + 0.1F), (double)((float)chunkcoordinates1.posZ + 0.5F)); + } + + this.sleeping = false; + + if (!this.worldObj.isRemote && par2) + { + this.worldObj.updateAllPlayersSleepingFlag(); + } + + if (par1) + { + this.sleepTimer = 0; + } + else + { + this.sleepTimer = 100; + } + + if (par3) + { + this.setSpawnChunk(this.playerLocation, false); + } + } + + private boolean isInBed() + { + return this.worldObj.getBlock(this.playerLocation.posX, this.playerLocation.posY, this.playerLocation.posZ).isBed(worldObj, playerLocation.posX, playerLocation.posY, playerLocation.posZ, this); + } + + public static ChunkCoordinates verifyRespawnCoordinates(World par0World, ChunkCoordinates par1ChunkCoordinates, boolean par2) + { + IChunkProvider ichunkprovider = par0World.getChunkProvider(); + ichunkprovider.loadChunk(par1ChunkCoordinates.posX - 3 >> 4, par1ChunkCoordinates.posZ - 3 >> 4); + ichunkprovider.loadChunk(par1ChunkCoordinates.posX + 3 >> 4, par1ChunkCoordinates.posZ - 3 >> 4); + ichunkprovider.loadChunk(par1ChunkCoordinates.posX - 3 >> 4, par1ChunkCoordinates.posZ + 3 >> 4); + ichunkprovider.loadChunk(par1ChunkCoordinates.posX + 3 >> 4, par1ChunkCoordinates.posZ + 3 >> 4); + + if (par0World.getBlock(par1ChunkCoordinates.posX, par1ChunkCoordinates.posY, par1ChunkCoordinates.posZ).isBed(par0World, par1ChunkCoordinates.posX, par1ChunkCoordinates.posY, par1ChunkCoordinates.posZ, null)) + { + ChunkCoordinates chunkcoordinates1 = par0World.getBlock(par1ChunkCoordinates.posX, par1ChunkCoordinates.posY, par1ChunkCoordinates.posZ).getBedSpawnPosition(par0World, par1ChunkCoordinates.posX, par1ChunkCoordinates.posY, par1ChunkCoordinates.posZ, null); + return chunkcoordinates1; + } + else + { + Material material = par0World.getBlock(par1ChunkCoordinates.posX, par1ChunkCoordinates.posY, par1ChunkCoordinates.posZ).getMaterial(); + Material material1 = par0World.getBlock(par1ChunkCoordinates.posX, par1ChunkCoordinates.posY + 1, par1ChunkCoordinates.posZ).getMaterial(); + boolean flag1 = !material.isSolid() && !material.isLiquid(); + boolean flag2 = !material1.isSolid() && !material1.isLiquid(); + return par2 && flag1 && flag2 ? par1ChunkCoordinates : null; + } + } + + @SideOnly(Side.CLIENT) + public float getBedOrientationInDegrees() + { + if (this.playerLocation != null) + { + int x = playerLocation.posX; + int y = playerLocation.posY; + int z = playerLocation.posZ; + int j = worldObj.getBlock(x, y, z).getBedDirection(worldObj, x, y, z); + + switch (j) + { + case 0: + return 90.0F; + case 1: + return 0.0F; + case 2: + return 270.0F; + case 3: + return 180.0F; + } + } + + return 0.0F; + } + + public boolean isPlayerSleeping() + { + return this.sleeping; + } + + public boolean isPlayerFullyAsleep() + { + return this.sleeping && this.sleepTimer >= 100; + } + + @SideOnly(Side.CLIENT) + public int getSleepTimer() + { + return this.sleepTimer; + } + + @SideOnly(Side.CLIENT) + protected boolean getHideCape(int par1) + { + return (this.dataWatcher.getWatchableObjectByte(16) & 1 << par1) != 0; + } + + protected void setHideCape(int par1, boolean par2) + { + byte b0 = this.dataWatcher.getWatchableObjectByte(16); + + if (par2) + { + this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 | 1 << par1))); + } + else + { + this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 & ~(1 << par1)))); + } + } + + public void addChatComponentMessage(IChatComponent p_146105_1_) {} + + @Deprecated + public ChunkCoordinates getBedLocation() + { + return getBedLocation(this.dimension); + } + + @Deprecated + public boolean isSpawnForced() + { + return isSpawnForced(this.dimension); + } + + public void setSpawnChunk(ChunkCoordinates par1ChunkCoordinates, boolean par2) + { + if (this.dimension != 0) + { + setSpawnChunk(par1ChunkCoordinates, par2, this.dimension); + return; + } + if (par1ChunkCoordinates != null) + { + this.spawnChunk = new ChunkCoordinates(par1ChunkCoordinates); + this.spawnForced = par2; + } + else + { + this.spawnChunk = null; + this.spawnForced = false; + } + } + + public void triggerAchievement(StatBase par1StatBase) + { + this.addStat(par1StatBase, 1); + } + + public void addStat(StatBase par1StatBase, int par2) {} + + public void jump() + { + super.jump(); + this.addStat(StatList.jumpStat, 1); + + if (this.isSprinting()) + { + this.addExhaustion(0.8F); + } + else + { + this.addExhaustion(0.2F); + } + } + + public void moveEntityWithHeading(float par1, float par2) + { + double d0 = this.posX; + double d1 = this.posY; + double d2 = this.posZ; + + if (this.capabilities.isFlying && this.ridingEntity == null) + { + double d3 = this.motionY; + float f2 = this.jumpMovementFactor; + this.jumpMovementFactor = this.capabilities.getFlySpeed(); + super.moveEntityWithHeading(par1, par2); + this.motionY = d3 * 0.6D; + this.jumpMovementFactor = f2; + } + else + { + super.moveEntityWithHeading(par1, par2); + } + + this.addMovementStat(this.posX - d0, this.posY - d1, this.posZ - d2); + } + + public float getAIMoveSpeed() + { + return (float)this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue(); + } + + public void addMovementStat(double par1, double par3, double par5) + { + if (this.ridingEntity == null) + { + int i; + + if (this.isInsideOfMaterial(Material.water)) + { + i = Math.round(MathHelper.sqrt_double(par1 * par1 + par3 * par3 + par5 * par5) * 100.0F); + + if (i > 0) + { + this.addStat(StatList.distanceDoveStat, i); + this.addExhaustion(0.015F * (float)i * 0.01F); + } + } + else if (this.isInWater()) + { + i = Math.round(MathHelper.sqrt_double(par1 * par1 + par5 * par5) * 100.0F); + + if (i > 0) + { + this.addStat(StatList.distanceSwumStat, i); + this.addExhaustion(0.015F * (float)i * 0.01F); + } + } + else if (this.isOnLadder()) + { + if (par3 > 0.0D) + { + this.addStat(StatList.distanceClimbedStat, (int)Math.round(par3 * 100.0D)); + } + } + else if (this.onGround) + { + i = Math.round(MathHelper.sqrt_double(par1 * par1 + par5 * par5) * 100.0F); + + if (i > 0) + { + this.addStat(StatList.distanceWalkedStat, i); + + if (this.isSprinting()) + { + this.addExhaustion(0.099999994F * (float)i * 0.01F); + } + else + { + this.addExhaustion(0.01F * (float)i * 0.01F); + } + } + } + else + { + i = Math.round(MathHelper.sqrt_double(par1 * par1 + par5 * par5) * 100.0F); + + if (i > 25) + { + this.addStat(StatList.distanceFlownStat, i); + } + } + } + } + + private void addMountedMovementStat(double par1, double par3, double par5) + { + if (this.ridingEntity != null) + { + int i = Math.round(MathHelper.sqrt_double(par1 * par1 + par3 * par3 + par5 * par5) * 100.0F); + + if (i > 0) + { + if (this.ridingEntity instanceof EntityMinecart) + { + this.addStat(StatList.distanceByMinecartStat, i); + + if (this.startMinecartRidingCoordinate == null) + { + this.startMinecartRidingCoordinate = new ChunkCoordinates(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)); + } + else if ((double)this.startMinecartRidingCoordinate.getDistanceSquared(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)) >= 1000000.0D) + { + this.addStat(AchievementList.onARail, 1); + } + } + else if (this.ridingEntity instanceof EntityBoat) + { + this.addStat(StatList.distanceByBoatStat, i); + } + else if (this.ridingEntity instanceof EntityPig) + { + this.addStat(StatList.distanceByPigStat, i); + } + else if (this.ridingEntity instanceof EntityHorse) + { + this.addStat(StatList.field_151185_q, i); + } + } + } + } + + protected void fall(float par1) + { + if (!this.capabilities.allowFlying) + { + if (par1 >= 2.0F) + { + this.addStat(StatList.distanceFallenStat, (int)Math.round((double)par1 * 100.0D)); + } + + super.fall(par1); + } + else + { + MinecraftForge.EVENT_BUS.post(new PlayerFlyableFallEvent(this, par1)); + } + } + + protected String func_146067_o(int p_146067_1_) + { + return p_146067_1_ > 4 ? "game.player.hurt.fall.big" : "game.player.hurt.fall.small"; + } + + public void onKillEntity(EntityLivingBase par1EntityLivingBase) + { + if (par1EntityLivingBase instanceof IMob) + { + this.triggerAchievement(AchievementList.killEnemy); + } + + int i = EntityList.getEntityID(par1EntityLivingBase); + EntityList.EntityEggInfo entityegginfo = (EntityList.EntityEggInfo)EntityList.entityEggs.get(Integer.valueOf(i)); + + if (entityegginfo != null) + { + this.addStat(entityegginfo.field_151512_d, 1); + } + } + + public void setInWeb() + { + if (!this.capabilities.isFlying) + { + super.setInWeb(); + } + } + + @SideOnly(Side.CLIENT) + public IIcon getItemIcon(ItemStack par1ItemStack, int par2) + { + IIcon iicon = super.getItemIcon(par1ItemStack, par2); + + if (par1ItemStack.getItem() == Items.fishing_rod && this.fishEntity != null) + { + iicon = Items.fishing_rod.func_94597_g(); + } + else + { + if (this.itemInUse != null && par1ItemStack.getItem() == Items.bow) + { + int j = par1ItemStack.getMaxItemUseDuration() - this.itemInUseCount; + + if (j >= 18) + { + return Items.bow.getItemIconForUseDuration(2); + } + + if (j > 13) + { + return Items.bow.getItemIconForUseDuration(1); + } + + if (j > 0) + { + return Items.bow.getItemIconForUseDuration(0); + } + } + iicon = par1ItemStack.getItem().getIcon(par1ItemStack, par2, this, itemInUse, itemInUseCount); + } + + return iicon; + } + + public ItemStack getCurrentArmor(int par1) + { + return this.inventory.armorItemInSlot(par1); + } + + public void addExperience(int par1) + { + this.addScore(par1); + int j = Integer.MAX_VALUE - this.experienceTotal; + + if (par1 > j) + { + par1 = j; + } + + this.experience += (float)par1 / (float)this.xpBarCap(); + + for (this.experienceTotal += par1; this.experience >= 1.0F; this.experience /= (float)this.xpBarCap()) + { + this.experience = (this.experience - 1.0F) * (float)this.xpBarCap(); + this.addExperienceLevel(1); + } + } + + public void addExperienceLevel(int par1) + { + this.experienceLevel += par1; + + if (this.experienceLevel < 0) + { + this.experienceLevel = 0; + this.experience = 0.0F; + this.experienceTotal = 0; + } + + if (par1 > 0 && this.experienceLevel % 5 == 0 && (float)this.field_82249_h < (float)this.ticksExisted - 100.0F) + { + float f = this.experienceLevel > 30 ? 1.0F : (float)this.experienceLevel / 30.0F; + this.worldObj.playSoundAtEntity(this, "random.levelup", f * 0.75F, 1.0F); + this.field_82249_h = this.ticksExisted; + } + } + + public int xpBarCap() + { + return this.experienceLevel >= 30 ? 62 + (this.experienceLevel - 30) * 7 : (this.experienceLevel >= 15 ? 17 + (this.experienceLevel - 15) * 3 : 17); + } + + public void addExhaustion(float par1) + { + if (!this.capabilities.disableDamage) + { + if (!this.worldObj.isRemote) + { + this.foodStats.addExhaustion(par1); + } + } + } + + public FoodStats getFoodStats() + { + return this.foodStats; + } + + public boolean canEat(boolean par1) + { + return (par1 || this.foodStats.needFood()) && !this.capabilities.disableDamage; + } + + public boolean shouldHeal() + { + return this.getHealth() > 0.0F && this.getHealth() < this.getMaxHealth(); + } + + public void setItemInUse(ItemStack par1ItemStack, int par2) + { + if (par1ItemStack != this.itemInUse) + { + par2 = ForgeEventFactory.onItemUseStart(this, par1ItemStack, par2); + if (par2 <= 0) return; + this.itemInUse = par1ItemStack; + this.itemInUseCount = par2; + + if (!this.worldObj.isRemote) + { + this.setEating(true); + } + } + } + + public boolean isCurrentToolAdventureModeExempt(int par1, int par2, int par3) + { + if (this.capabilities.allowEdit) + { + return true; + } + else + { + Block block = this.worldObj.getBlock(par1, par2, par3); + + if (block.getMaterial() != Material.air) + { + if (block.getMaterial().isAdventureModeExempt()) + { + return true; + } + + if (this.getCurrentEquippedItem() != null) + { + ItemStack itemstack = this.getCurrentEquippedItem(); + + if (itemstack.func_150998_b(block) || itemstack.func_150997_a(block) > 1.0F) + { + return true; + } + } + } + + return false; + } + } + + public boolean canPlayerEdit(int par1, int par2, int par3, int par4, ItemStack par5ItemStack) + { + return this.capabilities.allowEdit ? true : (par5ItemStack != null ? par5ItemStack.canEditBlocks() : false); + } + + protected int getExperiencePoints(EntityPlayer par1EntityPlayer) + { + if (this.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory")) + { + return 0; + } + else + { + int i = this.experienceLevel * 7; + return i > 100 ? 100 : i; + } + } + + protected boolean isPlayer() + { + return true; + } + + @SideOnly(Side.CLIENT) + public boolean getAlwaysRenderNameTagForRender() + { + return true; + } + + public void clonePlayer(EntityPlayer par1EntityPlayer, boolean par2) + { + if (par2) + { + this.inventory.copyInventory(par1EntityPlayer.inventory); + this.setHealth(par1EntityPlayer.getHealth()); + this.foodStats = par1EntityPlayer.foodStats; + this.experienceLevel = par1EntityPlayer.experienceLevel; + this.experienceTotal = par1EntityPlayer.experienceTotal; + this.experience = par1EntityPlayer.experience; + this.setScore(par1EntityPlayer.getScore()); + this.teleportDirection = par1EntityPlayer.teleportDirection; + } + else if (this.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory")) + { + this.inventory.copyInventory(par1EntityPlayer.inventory); + this.experienceLevel = par1EntityPlayer.experienceLevel; + this.experienceTotal = par1EntityPlayer.experienceTotal; + this.experience = par1EntityPlayer.experience; + this.setScore(par1EntityPlayer.getScore()); + } + + this.theInventoryEnderChest = par1EntityPlayer.theInventoryEnderChest; + + this.spawnChunkMap = par1EntityPlayer.spawnChunkMap; + this.spawnForcedMap = par1EntityPlayer.spawnForcedMap; + + //Copy over a section of the Entity Data from the old player. + //Allows mods to specify data that persists after players respawn. + NBTTagCompound old = par1EntityPlayer.getEntityData(); + if (old.hasKey(PERSISTED_NBT_TAG)) + { + getEntityData().setTag(PERSISTED_NBT_TAG, old.getCompoundTag(PERSISTED_NBT_TAG)); + } + } + + protected boolean canTriggerWalking() + { + return !this.capabilities.isFlying; + } + + public void sendPlayerAbilities() {} + + public void setGameType(WorldSettings.GameType par1EnumGameType) {} + + public String getCommandSenderName() + { + return this.field_146106_i.getName(); + } + + public World getEntityWorld() + { + return this.worldObj; + } + + public InventoryEnderChest getInventoryEnderChest() + { + return this.theInventoryEnderChest; + } + + public ItemStack getEquipmentInSlot(int par1) + { + return par1 == 0 ? this.inventory.getCurrentItem() : this.inventory.armorInventory[par1 - 1]; + } + + public ItemStack getHeldItem() + { + return this.inventory.getCurrentItem(); + } + + public void setCurrentItemOrArmor(int par1, ItemStack par2ItemStack) + { + if (par1 == 0) + { + this.inventory.mainInventory[this.inventory.currentItem] = par2ItemStack; + } + else + { + this.inventory.armorInventory[par1 - 1] = par2ItemStack; + } + } + + @SideOnly(Side.CLIENT) + public boolean isInvisibleToPlayer(EntityPlayer par1EntityPlayer) + { + if (!this.isInvisible()) + { + return false; + } + else + { + Team team = this.getTeam(); + return team == null || par1EntityPlayer == null || par1EntityPlayer.getTeam() != team || !team.func_98297_h(); + } + } + + public ItemStack[] getLastActiveItems() + { + return this.inventory.armorInventory; + } + + @SideOnly(Side.CLIENT) + public boolean getHideCape() + { + return this.getHideCape(1); + } + + public boolean isPushedByWater() + { + return !this.capabilities.isFlying; + } + + public Scoreboard getWorldScoreboard() + { + return this.worldObj.getScoreboard(); + } + + public Team getTeam() + { + return this.getWorldScoreboard().getPlayersTeam(this.getCommandSenderName()); + } + + public IChatComponent func_145748_c_() + { + ChatComponentText chatcomponenttext = new ChatComponentText(ScorePlayerTeam.formatPlayerName(this.getTeam(), this.getDisplayName())); + chatcomponenttext.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/msg " + this.getCommandSenderName() + " ")); + return chatcomponenttext; + } + + public void setAbsorptionAmount(float par1) + { + if (par1 < 0.0F) + { + par1 = 0.0F; + } + + this.getDataWatcher().updateObject(17, Float.valueOf(par1)); + } + + public float getAbsorptionAmount() + { + return this.getDataWatcher().getWatchableObjectFloat(17); + } + + public static UUID func_146094_a(GameProfile p_146094_0_) + { + UUID uuid = Util.tryGetUUIDFromString(p_146094_0_.getId()); + + if (uuid == null) + { + uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + p_146094_0_.getName()).getBytes(Charsets.UTF_8)); + } + + return uuid; + } + + public static enum EnumChatVisibility + { + FULL(0, "options.chat.visibility.full"), + SYSTEM(1, "options.chat.visibility.system"), + HIDDEN(2, "options.chat.visibility.hidden"); + private static final EntityPlayer.EnumChatVisibility[] field_151432_d = new EntityPlayer.EnumChatVisibility[values().length]; + private final int chatVisibility; + private final String resourceKey; + + private static final String __OBFID = "CL_00001714"; + + private EnumChatVisibility(int p_i45323_3_, String p_i45323_4_) + { + this.chatVisibility = p_i45323_3_; + this.resourceKey = p_i45323_4_; + } + + public int getChatVisibility() + { + return this.chatVisibility; + } + + public static EntityPlayer.EnumChatVisibility getEnumChatVisibility(int p_151426_0_) + { + return field_151432_d[p_151426_0_ % field_151432_d.length]; + } + + @SideOnly(Side.CLIENT) + public String getResourceKey() + { + return this.resourceKey; + } + + static + { + EntityPlayer.EnumChatVisibility[] var0 = values(); + int var1 = var0.length; + + for (int var2 = 0; var2 < var1; ++var2) + { + EntityPlayer.EnumChatVisibility var3 = var0[var2]; + field_151432_d[var3.chatVisibility] = var3; + } + } + } + + public void openGui(Object mod, int modGuiId, World world, int x, int y, int z) + { + FMLNetworkHandler.openGui(this, mod, modGuiId, world, x, y, z); + } + + /* ======================================== FORGE START =====================================*/ + @SideOnly(Side.CLIENT) + @Override + public Vec3 getPosition(float par1) + { + if (par1 == 1.0F) + { + return this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY + (this.getEyeHeight() - this.getDefaultEyeHeight()), this.posZ); + } + else + { + double d0 = this.prevPosX + (this.posX - this.prevPosX) * (double)par1; + double d1 = this.prevPosY + (this.posY - this.prevPosY) * (double)par1 + (this.getEyeHeight() - this.getDefaultEyeHeight()); + double d2 = this.prevPosZ + (this.posZ - this.prevPosZ) * (double)par1; + return this.worldObj.getWorldVec3Pool().getVecFromPool(d0, d1, d2); + } + } + + /** + * A dimension aware version of getBedLocation. + * @param dimension The dimension to get the bed spawn for + * @return The player specific spawn location for the dimension. May be null. + */ + public ChunkCoordinates getBedLocation(int dimension) + { + return dimension == 0 ? spawnChunk : spawnChunkMap.get(dimension); + } + + /** + * A dimension aware version of isSpawnForced. + * Noramally isSpawnForced is used to determine if the respawn system should check for a bed or not. + * This just extends that to be dimension aware. + * @param dimension The dimension to get whether to check for a bed before spawning for + * @return The player specific spawn location for the dimension. May be null. + */ + public boolean isSpawnForced(int dimension) + { + if (dimension == 0) return this.spawnForced; + Boolean forced = this.spawnForcedMap.get(dimension); + return forced == null ? false : forced; + } + + /** + * A dimension aware version of setSpawnChunk. + * This functions identically, but allows you to specify which dimension to affect, rather than affecting the player's current dimension. + * @param chunkCoordinates The spawn point to set as the player-specific spawn point for the dimension + * @param forced Whether or not the respawn code should check for a bed at this location (true means it won't check for a bed) + * @param dimension Which dimension to apply the player-specific respawn point to + */ + public void setSpawnChunk(ChunkCoordinates chunkCoordinates, boolean forced, int dimension) + { + if (dimension == 0) + { + if (chunkCoordinates != null) + { + spawnChunk = new ChunkCoordinates(chunkCoordinates); + spawnForced = forced; + } + else + { + spawnChunk = null; + spawnForced = false; + } + return; + } + + if (chunkCoordinates != null) + { + spawnChunkMap.put(dimension, new ChunkCoordinates(chunkCoordinates)); + spawnForcedMap.put(dimension, forced); + } + else + { + spawnChunkMap.remove(dimension); + spawnForcedMap.remove(dimension); + } + } + + public float eyeHeight; + private String displayname; + + /** + * Returns the default eye height of the player + * @return player default eye height + */ + public float getDefaultEyeHeight() + { + return 0.12F; + } + + /** + * Get the currently computed display name, cached for efficiency. + * @return the current display name + */ + public String getDisplayName() + { + if(this.displayname == null) + { + this.displayname = ForgeEventFactory.getPlayerDisplayName(this, this.getCommandSenderName()); + } + return this.displayname; + } + + /** + * Force the displayed name to refresh + */ + public void refreshDisplayName() + { + this.displayname = ForgeEventFactory.getPlayerDisplayName(this, this.getCommandSenderName()); + } + /* ======================================== FORGE END =====================================*/ + + public static enum EnumStatus + { + OK, + NOT_POSSIBLE_HERE, + NOT_POSSIBLE_NOW, + TOO_FAR_AWAY, + OTHER_PROBLEM, + NOT_SAFE; + + private static final String __OBFID = "CL_00001712"; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/player/EntityPlayerMP.java b/src/main/java/net/minecraft/entity/player/EntityPlayerMP.java new file mode 100644 index 0000000..f8cfa79 --- /dev/null +++ b/src/main/java/net/minecraft/entity/player/EntityPlayerMP.java @@ -0,0 +1,1013 @@ +package net.minecraft.entity.player; + +import com.google.common.collect.Sets; +import com.mojang.authlib.GameProfile; +import io.netty.buffer.Unpooled; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import net.minecraft.crash.CrashReport; +import net.minecraft.crash.CrashReportCategory; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityList; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IMerchant; +import net.minecraft.entity.item.EntityMinecartHopper; +import net.minecraft.entity.passive.EntityHorse; +import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ContainerBeacon; +import net.minecraft.inventory.ContainerBrewingStand; +import net.minecraft.inventory.ContainerChest; +import net.minecraft.inventory.ContainerDispenser; +import net.minecraft.inventory.ContainerEnchantment; +import net.minecraft.inventory.ContainerFurnace; +import net.minecraft.inventory.ContainerHopper; +import net.minecraft.inventory.ContainerHorseInventory; +import net.minecraft.inventory.ContainerMerchant; +import net.minecraft.inventory.ContainerRepair; +import net.minecraft.inventory.ContainerWorkbench; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.InventoryMerchant; +import net.minecraft.inventory.SlotCrafting; +import net.minecraft.item.EnumAction; +import net.minecraft.item.ItemMapBase; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetHandlerPlayServer; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.client.C15PacketClientSettings; +import net.minecraft.network.play.server.S02PacketChat; +import net.minecraft.network.play.server.S06PacketUpdateHealth; +import net.minecraft.network.play.server.S0APacketUseBed; +import net.minecraft.network.play.server.S0BPacketAnimation; +import net.minecraft.network.play.server.S13PacketDestroyEntities; +import net.minecraft.network.play.server.S19PacketEntityStatus; +import net.minecraft.network.play.server.S1BPacketEntityAttach; +import net.minecraft.network.play.server.S1DPacketEntityEffect; +import net.minecraft.network.play.server.S1EPacketRemoveEntityEffect; +import net.minecraft.network.play.server.S1FPacketSetExperience; +import net.minecraft.network.play.server.S26PacketMapChunkBulk; +import net.minecraft.network.play.server.S2BPacketChangeGameState; +import net.minecraft.network.play.server.S2DPacketOpenWindow; +import net.minecraft.network.play.server.S2EPacketCloseWindow; +import net.minecraft.network.play.server.S2FPacketSetSlot; +import net.minecraft.network.play.server.S30PacketWindowItems; +import net.minecraft.network.play.server.S31PacketWindowProperty; +import net.minecraft.network.play.server.S36PacketSignEditorOpen; +import net.minecraft.network.play.server.S39PacketPlayerAbilities; +import net.minecraft.network.play.server.S3FPacketCustomPayload; +import net.minecraft.potion.PotionEffect; +import net.minecraft.scoreboard.IScoreObjectiveCriteria; +import net.minecraft.scoreboard.Score; +import net.minecraft.scoreboard.ScoreObjective; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.management.ItemInWorldManager; +import net.minecraft.stats.AchievementList; +import net.minecraft.stats.StatBase; +import net.minecraft.stats.StatList; +import net.minecraft.stats.StatisticsFile; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityBeacon; +import net.minecraft.tileentity.TileEntityBrewingStand; +import net.minecraft.tileentity.TileEntityDispenser; +import net.minecraft.tileentity.TileEntityDropper; +import net.minecraft.tileentity.TileEntityFurnace; +import net.minecraft.tileentity.TileEntityHopper; +import net.minecraft.tileentity.TileEntitySign; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.DamageSource; +import net.minecraft.util.EntityDamageSource; +import net.minecraft.util.IChatComponent; +import net.minecraft.util.JsonSerializableSet; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ReportedException; +import net.minecraft.village.MerchantRecipeList; +import net.minecraft.world.ChunkCoordIntPair; +import net.minecraft.world.WorldServer; +import net.minecraft.world.WorldSettings; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.chunk.Chunk; +import org.apache.commons.io.Charsets; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import net.minecraft.entity.item.EntityItem; +import net.minecraftforge.common.ForgeHooks; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.player.PlayerDropsEvent; +import net.minecraftforge.event.world.ChunkWatchEvent; + +public class EntityPlayerMP extends EntityPlayer implements ICrafting +{ + private static final Logger logger = LogManager.getLogger(); + private String translator = "en_US"; + public NetHandlerPlayServer playerNetServerHandler; + public final MinecraftServer mcServer; + public final ItemInWorldManager theItemInWorldManager; + public double managedPosX; + public double managedPosZ; + public final List loadedChunks = new LinkedList(); + public final List destroyedItemsNetCache = new LinkedList(); + private final StatisticsFile field_147103_bO; + private float field_130068_bO = Float.MIN_VALUE; + private float lastHealth = -1.0E8F; + private int lastFoodLevel = -99999999; + private boolean wasHungry = true; + private int lastExperience = -99999999; + private int field_147101_bU = 60; + private int renderDistance; + private EntityPlayer.EnumChatVisibility chatVisibility; + private boolean chatColours = true; + private long field_143005_bX = 0L; + public int currentWindowId; + public boolean isChangingQuantityOnly; + public int ping; + public boolean playerConqueredTheEnd; + private static final String __OBFID = "CL_00001440"; + + public EntityPlayerMP(MinecraftServer p_i45285_1_, WorldServer p_i45285_2_, GameProfile p_i45285_3_, ItemInWorldManager p_i45285_4_) + { + super(p_i45285_2_, p_i45285_3_); + p_i45285_4_.thisPlayerMP = this; + this.theItemInWorldManager = p_i45285_4_; + this.renderDistance = p_i45285_1_.getConfigurationManager().getViewDistance(); + ChunkCoordinates chunkcoordinates = p_i45285_2_.provider.getRandomizedSpawnPoint(); + int i = chunkcoordinates.posX; + int j = chunkcoordinates.posZ; + int k = chunkcoordinates.posY; + + this.mcServer = p_i45285_1_; + this.field_147103_bO = p_i45285_1_.getConfigurationManager().func_148538_i(this.getCommandSenderName()); + this.stepHeight = 0.0F; + this.yOffset = 0.0F; + this.setLocationAndAngles((double)i + 0.5D, (double)k, (double)j + 0.5D, 0.0F, 0.0F); + + while (!p_i45285_2_.getCollidingBoundingBoxes(this, this.boundingBox).isEmpty()) + { + this.setPosition(this.posX, this.posY + 1.0D, this.posZ); + } + } + + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + super.readEntityFromNBT(par1NBTTagCompound); + + if (par1NBTTagCompound.hasKey("playerGameType", 99)) + { + if (MinecraftServer.getServer().getForceGamemode()) + { + this.theItemInWorldManager.setGameType(MinecraftServer.getServer().getGameType()); + } + else + { + this.theItemInWorldManager.setGameType(WorldSettings.GameType.getByID(par1NBTTagCompound.getInteger("playerGameType"))); + } + } + } + + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeEntityToNBT(par1NBTTagCompound); + par1NBTTagCompound.setInteger("playerGameType", this.theItemInWorldManager.getGameType().getID()); + } + + public void addExperienceLevel(int par1) + { + super.addExperienceLevel(par1); + this.lastExperience = -1; + } + + public void addSelfToInternalCraftingInventory() + { + this.openContainer.addCraftingToCrafters(this); + } + + protected void resetHeight() + { + this.yOffset = 0.0F; + } + + public float getEyeHeight() + { + return super.getEyeHeight(); + } + + public void onUpdate() + { + this.theItemInWorldManager.updateBlockRemoving(); + --this.field_147101_bU; + + if (this.hurtResistantTime > 0) + { + --this.hurtResistantTime; + } + + this.openContainer.detectAndSendChanges(); + + if (!this.worldObj.isRemote && !ForgeHooks.canInteractWith(this, this.openContainer)) + { + this.closeScreen(); + this.openContainer = this.inventoryContainer; + } + + while (!this.destroyedItemsNetCache.isEmpty()) + { + int i = Math.min(this.destroyedItemsNetCache.size(), 127); + int[] aint = new int[i]; + Iterator iterator = this.destroyedItemsNetCache.iterator(); + int j = 0; + + while (iterator.hasNext() && j < i) + { + aint[j++] = ((Integer)iterator.next()).intValue(); + iterator.remove(); + } + + this.playerNetServerHandler.sendPacket(new S13PacketDestroyEntities(aint)); + } + + if (!this.loadedChunks.isEmpty()) + { + ArrayList arraylist = new ArrayList(); + Iterator iterator1 = this.loadedChunks.iterator(); + ArrayList arraylist1 = new ArrayList(); + Chunk chunk; + + while (iterator1.hasNext() && arraylist.size() < S26PacketMapChunkBulk.func_149258_c()) + { + ChunkCoordIntPair chunkcoordintpair = (ChunkCoordIntPair)iterator1.next(); + + if (chunkcoordintpair != null) + { + if (this.worldObj.blockExists(chunkcoordintpair.chunkXPos << 4, 0, chunkcoordintpair.chunkZPos << 4)) + { + chunk = this.worldObj.getChunkFromChunkCoords(chunkcoordintpair.chunkXPos, chunkcoordintpair.chunkZPos); + + if (chunk.func_150802_k()) + { + arraylist.add(chunk); + arraylist1.addAll(((WorldServer)this.worldObj).func_147486_a(chunkcoordintpair.chunkXPos * 16, 0, chunkcoordintpair.chunkZPos * 16, chunkcoordintpair.chunkXPos * 16 + 15, 256, chunkcoordintpair.chunkZPos * 16 + 15)); + //BugFix: 16 makes it load an extra chunk, which isn't associated with a player, which makes it not unload unless a player walks near it. + iterator1.remove(); + } + } + } + else + { + iterator1.remove(); + } + } + + if (!arraylist.isEmpty()) + { + this.playerNetServerHandler.sendPacket(new S26PacketMapChunkBulk(arraylist)); + Iterator iterator2 = arraylist1.iterator(); + + while (iterator2.hasNext()) + { + TileEntity tileentity = (TileEntity)iterator2.next(); + this.func_147097_b(tileentity); + } + + iterator2 = arraylist.iterator(); + + while (iterator2.hasNext()) + { + chunk = (Chunk)iterator2.next(); + this.getServerForPlayer().getEntityTracker().func_85172_a(this, chunk); + MinecraftForge.EVENT_BUS.post(new ChunkWatchEvent.Watch(chunk.getChunkCoordIntPair(), this)); + } + } + } + + if (this.field_143005_bX > 0L && this.mcServer.func_143007_ar() > 0 && MinecraftServer.getSystemTimeMillis() - this.field_143005_bX > (long)(this.mcServer.func_143007_ar() * 1000 * 60)) + { + this.playerNetServerHandler.kickPlayerFromServer("You have been idle for too long!"); + } + } + + public void onUpdateEntity() + { + try + { + super.onUpdate(); + + for (int i = 0; i < this.inventory.getSizeInventory(); ++i) + { + ItemStack itemstack = this.inventory.getStackInSlot(i); + + if (itemstack != null && itemstack.getItem().isMap()) + { + Packet packet = ((ItemMapBase)itemstack.getItem()).func_150911_c(itemstack, this.worldObj, this); + + if (packet != null) + { + this.playerNetServerHandler.sendPacket(packet); + } + } + } + + if (this.getHealth() != this.lastHealth || this.lastFoodLevel != this.foodStats.getFoodLevel() || this.foodStats.getSaturationLevel() == 0.0F != this.wasHungry) + { + this.playerNetServerHandler.sendPacket(new S06PacketUpdateHealth(this.getHealth(), this.foodStats.getFoodLevel(), this.foodStats.getSaturationLevel())); + this.lastHealth = this.getHealth(); + this.lastFoodLevel = this.foodStats.getFoodLevel(); + this.wasHungry = this.foodStats.getSaturationLevel() == 0.0F; + } + + if (this.getHealth() + this.getAbsorptionAmount() != this.field_130068_bO) + { + this.field_130068_bO = this.getHealth() + this.getAbsorptionAmount(); + Collection collection = this.getWorldScoreboard().func_96520_a(IScoreObjectiveCriteria.health); + Iterator iterator = collection.iterator(); + + while (iterator.hasNext()) + { + ScoreObjective scoreobjective = (ScoreObjective)iterator.next(); + this.getWorldScoreboard().func_96529_a(this.getCommandSenderName(), scoreobjective).func_96651_a(Arrays.asList(new EntityPlayer[] {this})); + } + } + + if (this.experienceTotal != this.lastExperience) + { + this.lastExperience = this.experienceTotal; + this.playerNetServerHandler.sendPacket(new S1FPacketSetExperience(this.experience, this.experienceTotal, this.experienceLevel)); + } + + if (this.ticksExisted % 20 * 5 == 0 && !this.func_147099_x().hasAchievementUnlocked(AchievementList.field_150961_L)) + { + this.func_147098_j(); + } + } + catch (Throwable throwable) + { + CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Ticking player"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("Player being ticked"); + this.addEntityCrashInfo(crashreportcategory); + throw new ReportedException(crashreport); + } + } + + protected void func_147098_j() + { + BiomeGenBase biomegenbase = this.worldObj.getBiomeGenForCoords(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posZ)); + + if (biomegenbase != null) + { + String s = biomegenbase.biomeName; + JsonSerializableSet jsonserializableset = (JsonSerializableSet)this.func_147099_x().func_150870_b(AchievementList.field_150961_L); + + if (jsonserializableset == null) + { + jsonserializableset = (JsonSerializableSet)this.func_147099_x().func_150872_a(AchievementList.field_150961_L, new JsonSerializableSet()); + } + + jsonserializableset.add(s); + + if (this.func_147099_x().canUnlockAchievement(AchievementList.field_150961_L) && jsonserializableset.size() == BiomeGenBase.explorationBiomesList.size()) + { + HashSet hashset = Sets.newHashSet(BiomeGenBase.explorationBiomesList); + Iterator iterator = jsonserializableset.iterator(); + + while (iterator.hasNext()) + { + String s1 = (String)iterator.next(); + Iterator iterator1 = hashset.iterator(); + + while (iterator1.hasNext()) + { + BiomeGenBase biomegenbase1 = (BiomeGenBase)iterator1.next(); + + if (biomegenbase1.biomeName.equals(s1)) + { + iterator1.remove(); + } + } + + if (hashset.isEmpty()) + { + break; + } + } + + if (hashset.isEmpty()) + { + this.triggerAchievement(AchievementList.field_150961_L); + } + } + } + } + + public void onDeath(DamageSource par1DamageSource) + { + if (ForgeHooks.onLivingDeath(this, par1DamageSource)) return; + this.mcServer.getConfigurationManager().sendChatMsg(this.func_110142_aN().func_151521_b()); + + if (!this.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory")) + { + captureDrops = true; + capturedDrops.clear(); + + this.inventory.dropAllItems(); + + captureDrops = false; + PlayerDropsEvent event = new PlayerDropsEvent(this, par1DamageSource, capturedDrops, recentlyHit > 0); + if (!MinecraftForge.EVENT_BUS.post(event)) + { + for (EntityItem item : capturedDrops) + { + joinEntityItemWithWorld(item); + } + } + } + + Collection collection = this.worldObj.getScoreboard().func_96520_a(IScoreObjectiveCriteria.deathCount); + Iterator iterator = collection.iterator(); + + while (iterator.hasNext()) + { + ScoreObjective scoreobjective = (ScoreObjective)iterator.next(); + Score score = this.getWorldScoreboard().func_96529_a(this.getCommandSenderName(), scoreobjective); + score.func_96648_a(); + } + + EntityLivingBase entitylivingbase = this.func_94060_bK(); + + if (entitylivingbase != null) + { + int i = EntityList.getEntityID(entitylivingbase); + EntityList.EntityEggInfo entityegginfo = (EntityList.EntityEggInfo)EntityList.entityEggs.get(Integer.valueOf(i)); + + if (entityegginfo != null) + { + this.addStat(entityegginfo.field_151513_e, 1); + } + + entitylivingbase.addToPlayerScore(this, this.scoreValue); + } + + this.addStat(StatList.deathsStat, 1); + } + + public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) + { + if (this.isEntityInvulnerable()) + { + return false; + } + else + { + boolean flag = this.mcServer.isDedicatedServer() && this.mcServer.isPVPEnabled() && "fall".equals(par1DamageSource.damageType); + + if (!flag && this.field_147101_bU > 0 && par1DamageSource != DamageSource.outOfWorld) + { + return false; + } + else + { + if (par1DamageSource instanceof EntityDamageSource) + { + Entity entity = par1DamageSource.getEntity(); + + if (entity instanceof EntityPlayer && !this.canAttackPlayer((EntityPlayer)entity)) + { + return false; + } + + if (entity instanceof EntityArrow) + { + EntityArrow entityarrow = (EntityArrow)entity; + + if (entityarrow.shootingEntity instanceof EntityPlayer && !this.canAttackPlayer((EntityPlayer)entityarrow.shootingEntity)) + { + return false; + } + } + } + + return super.attackEntityFrom(par1DamageSource, par2); + } + } + } + + public boolean canAttackPlayer(EntityPlayer par1EntityPlayer) + { + return !this.mcServer.isPVPEnabled() ? false : super.canAttackPlayer(par1EntityPlayer); + } + + public void travelToDimension(int par1) + { + if (this.dimension == 1 && par1 == 1) + { + this.triggerAchievement(AchievementList.theEnd2); + this.worldObj.removeEntity(this); + this.playerConqueredTheEnd = true; + this.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(4, 0.0F)); + } + else + { + if (this.dimension == 0 && par1 == 1) + { + this.triggerAchievement(AchievementList.theEnd); + ChunkCoordinates chunkcoordinates = this.mcServer.worldServerForDimension(par1).getEntrancePortalLocation(); + + if (chunkcoordinates != null) + { + this.playerNetServerHandler.setPlayerLocation((double)chunkcoordinates.posX, (double)chunkcoordinates.posY, (double)chunkcoordinates.posZ, 0.0F, 0.0F); + } + + par1 = 1; + } + else + { + this.triggerAchievement(AchievementList.portal); + } + + this.mcServer.getConfigurationManager().transferPlayerToDimension(this, par1); + this.lastExperience = -1; + this.lastHealth = -1.0F; + this.lastFoodLevel = -1; + } + } + + private void func_147097_b(TileEntity p_147097_1_) + { + if (p_147097_1_ != null) + { + Packet packet = p_147097_1_.getDescriptionPacket(); + + if (packet != null) + { + this.playerNetServerHandler.sendPacket(packet); + } + } + } + + public void onItemPickup(Entity par1Entity, int par2) + { + super.onItemPickup(par1Entity, par2); + this.openContainer.detectAndSendChanges(); + } + + public EntityPlayer.EnumStatus sleepInBedAt(int par1, int par2, int par3) + { + EntityPlayer.EnumStatus enumstatus = super.sleepInBedAt(par1, par2, par3); + + if (enumstatus == EntityPlayer.EnumStatus.OK) + { + S0APacketUseBed s0apacketusebed = new S0APacketUseBed(this, par1, par2, par3); + this.getServerForPlayer().getEntityTracker().func_151247_a(this, s0apacketusebed); + this.playerNetServerHandler.setPlayerLocation(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch); + this.playerNetServerHandler.sendPacket(s0apacketusebed); + } + + return enumstatus; + } + + public void wakeUpPlayer(boolean par1, boolean par2, boolean par3) + { + if (this.isPlayerSleeping()) + { + this.getServerForPlayer().getEntityTracker().func_151248_b(this, new S0BPacketAnimation(this, 2)); + } + + super.wakeUpPlayer(par1, par2, par3); + + if (this.playerNetServerHandler != null) + { + this.playerNetServerHandler.setPlayerLocation(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch); + } + } + + public void mountEntity(Entity par1Entity) + { + super.mountEntity(par1Entity); + this.playerNetServerHandler.sendPacket(new S1BPacketEntityAttach(0, this, this.ridingEntity)); + this.playerNetServerHandler.setPlayerLocation(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch); + } + + protected void updateFallState(double par1, boolean par3) {} + + public void handleFalling(double par1, boolean par3) + { + super.updateFallState(par1, par3); + } + + public void func_146100_a(TileEntity p_146100_1_) + { + if (p_146100_1_ instanceof TileEntitySign) + { + ((TileEntitySign)p_146100_1_).func_145912_a(this); + this.playerNetServerHandler.sendPacket(new S36PacketSignEditorOpen(p_146100_1_.xCoord, p_146100_1_.yCoord, p_146100_1_.zCoord)); + } + } + + public void getNextWindowId() + { + this.currentWindowId = this.currentWindowId % 100 + 1; + } + + public void displayGUIWorkbench(int par1, int par2, int par3) + { + this.getNextWindowId(); + this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 1, "Crafting", 9, true)); + this.openContainer = new ContainerWorkbench(this.inventory, this.worldObj, par1, par2, par3); + this.openContainer.windowId = this.currentWindowId; + this.openContainer.addCraftingToCrafters(this); + } + + public void displayGUIEnchantment(int par1, int par2, int par3, String par4Str) + { + this.getNextWindowId(); + this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 4, par4Str == null ? "" : par4Str, 9, par4Str != null)); + this.openContainer = new ContainerEnchantment(this.inventory, this.worldObj, par1, par2, par3); + this.openContainer.windowId = this.currentWindowId; + this.openContainer.addCraftingToCrafters(this); + } + + public void displayGUIAnvil(int par1, int par2, int par3) + { + this.getNextWindowId(); + this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 8, "Repairing", 9, true)); + this.openContainer = new ContainerRepair(this.inventory, this.worldObj, par1, par2, par3, this); + this.openContainer.windowId = this.currentWindowId; + this.openContainer.addCraftingToCrafters(this); + } + + public void displayGUIChest(IInventory par1IInventory) + { + if (this.openContainer != this.inventoryContainer) + { + this.closeScreen(); + } + + this.getNextWindowId(); + this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 0, par1IInventory.getInventoryName(), par1IInventory.getSizeInventory(), par1IInventory.hasCustomInventoryName())); + this.openContainer = new ContainerChest(this.inventory, par1IInventory); + this.openContainer.windowId = this.currentWindowId; + this.openContainer.addCraftingToCrafters(this); + } + + public void func_146093_a(TileEntityHopper p_146093_1_) + { + this.getNextWindowId(); + this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 9, p_146093_1_.getInventoryName(), p_146093_1_.getSizeInventory(), p_146093_1_.hasCustomInventoryName())); + this.openContainer = new ContainerHopper(this.inventory, p_146093_1_); + this.openContainer.windowId = this.currentWindowId; + this.openContainer.addCraftingToCrafters(this); + } + + public void displayGUIHopperMinecart(EntityMinecartHopper par1EntityMinecartHopper) + { + this.getNextWindowId(); + this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 9, par1EntityMinecartHopper.getInventoryName(), par1EntityMinecartHopper.getSizeInventory(), par1EntityMinecartHopper.hasCustomInventoryName())); + this.openContainer = new ContainerHopper(this.inventory, par1EntityMinecartHopper); + this.openContainer.windowId = this.currentWindowId; + this.openContainer.addCraftingToCrafters(this); + } + + public void func_146101_a(TileEntityFurnace p_146101_1_) + { + this.getNextWindowId(); + this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 2, p_146101_1_.getInventoryName(), p_146101_1_.getSizeInventory(), p_146101_1_.hasCustomInventoryName())); + this.openContainer = new ContainerFurnace(this.inventory, p_146101_1_); + this.openContainer.windowId = this.currentWindowId; + this.openContainer.addCraftingToCrafters(this); + } + + public void func_146102_a(TileEntityDispenser p_146102_1_) + { + this.getNextWindowId(); + this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, p_146102_1_ instanceof TileEntityDropper ? 10 : 3, p_146102_1_.getInventoryName(), p_146102_1_.getSizeInventory(), p_146102_1_.hasCustomInventoryName())); + this.openContainer = new ContainerDispenser(this.inventory, p_146102_1_); + this.openContainer.windowId = this.currentWindowId; + this.openContainer.addCraftingToCrafters(this); + } + + public void func_146098_a(TileEntityBrewingStand p_146098_1_) + { + this.getNextWindowId(); + this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 5, p_146098_1_.getInventoryName(), p_146098_1_.getSizeInventory(), p_146098_1_.hasCustomInventoryName())); + this.openContainer = new ContainerBrewingStand(this.inventory, p_146098_1_); + this.openContainer.windowId = this.currentWindowId; + this.openContainer.addCraftingToCrafters(this); + } + + public void func_146104_a(TileEntityBeacon p_146104_1_) + { + this.getNextWindowId(); + this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 7, p_146104_1_.getInventoryName(), p_146104_1_.getSizeInventory(), p_146104_1_.hasCustomInventoryName())); + this.openContainer = new ContainerBeacon(this.inventory, p_146104_1_); + this.openContainer.windowId = this.currentWindowId; + this.openContainer.addCraftingToCrafters(this); + } + + public void displayGUIMerchant(IMerchant par1IMerchant, String par2Str) + { + this.getNextWindowId(); + this.openContainer = new ContainerMerchant(this.inventory, par1IMerchant, this.worldObj); + this.openContainer.windowId = this.currentWindowId; + this.openContainer.addCraftingToCrafters(this); + InventoryMerchant inventorymerchant = ((ContainerMerchant)this.openContainer).getMerchantInventory(); + this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 6, par2Str == null ? "" : par2Str, inventorymerchant.getSizeInventory(), par2Str != null)); + MerchantRecipeList merchantrecipelist = par1IMerchant.getRecipes(this); + + if (merchantrecipelist != null) + { + try + { + PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer()); + packetbuffer.writeInt(this.currentWindowId); + merchantrecipelist.func_151391_a(packetbuffer); + this.playerNetServerHandler.sendPacket(new S3FPacketCustomPayload("MC|TrList", packetbuffer)); + } + catch (IOException ioexception) + { + logger.error("Couldn\'t send trade list", ioexception); + } + } + } + + public void displayGUIHorse(EntityHorse par1EntityHorse, IInventory par2IInventory) + { + if (this.openContainer != this.inventoryContainer) + { + this.closeScreen(); + } + + this.getNextWindowId(); + this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 11, par2IInventory.getInventoryName(), par2IInventory.getSizeInventory(), par2IInventory.hasCustomInventoryName(), par1EntityHorse.getEntityId())); + this.openContainer = new ContainerHorseInventory(this.inventory, par2IInventory, par1EntityHorse); + this.openContainer.windowId = this.currentWindowId; + this.openContainer.addCraftingToCrafters(this); + } + + public void sendSlotContents(Container par1Container, int par2, ItemStack par3ItemStack) + { + if (!(par1Container.getSlot(par2) instanceof SlotCrafting)) + { + if (!this.isChangingQuantityOnly) + { + this.playerNetServerHandler.sendPacket(new S2FPacketSetSlot(par1Container.windowId, par2, par3ItemStack)); + } + } + } + + public void sendContainerToPlayer(Container par1Container) + { + this.sendContainerAndContentsToPlayer(par1Container, par1Container.getInventory()); + } + + public void sendContainerAndContentsToPlayer(Container par1Container, List par2List) + { + this.playerNetServerHandler.sendPacket(new S30PacketWindowItems(par1Container.windowId, par2List)); + this.playerNetServerHandler.sendPacket(new S2FPacketSetSlot(-1, -1, this.inventory.getItemStack())); + } + + public void sendProgressBarUpdate(Container par1Container, int par2, int par3) + { + this.playerNetServerHandler.sendPacket(new S31PacketWindowProperty(par1Container.windowId, par2, par3)); + } + + public void closeScreen() + { + this.playerNetServerHandler.sendPacket(new S2EPacketCloseWindow(this.openContainer.windowId)); + this.closeContainer(); + } + + public void updateHeldItem() + { + if (!this.isChangingQuantityOnly) + { + this.playerNetServerHandler.sendPacket(new S2FPacketSetSlot(-1, -1, this.inventory.getItemStack())); + } + } + + public void closeContainer() + { + this.openContainer.onContainerClosed(this); + this.openContainer = this.inventoryContainer; + } + + public void setEntityActionState(float par1, float par2, boolean par3, boolean par4) + { + if (this.ridingEntity != null) + { + if (par1 >= -1.0F && par1 <= 1.0F) + { + this.moveStrafing = par1; + } + + if (par2 >= -1.0F && par2 <= 1.0F) + { + this.moveForward = par2; + } + + this.isJumping = par3; + this.setSneaking(par4); + } + } + + public void addStat(StatBase par1StatBase, int par2) + { + if (par1StatBase != null) + { + this.field_147103_bO.func_150871_b(this, par1StatBase, par2); + Iterator iterator = this.getWorldScoreboard().func_96520_a(par1StatBase.func_150952_k()).iterator(); + + while (iterator.hasNext()) + { + ScoreObjective scoreobjective = (ScoreObjective)iterator.next(); + this.getWorldScoreboard().func_96529_a(this.getCommandSenderName(), scoreobjective).func_96648_a(); + } + + if (this.field_147103_bO.func_150879_e()) + { + this.field_147103_bO.func_150876_a(this); + } + } + } + + public void mountEntityAndWakeUp() + { + if (this.riddenByEntity != null) + { + this.riddenByEntity.mountEntity(this); + } + + if (this.sleeping) + { + this.wakeUpPlayer(true, false, false); + } + } + + public void setPlayerHealthUpdated() + { + this.lastHealth = -1.0E8F; + } + + public void addChatComponentMessage(IChatComponent p_146105_1_) + { + this.playerNetServerHandler.sendPacket(new S02PacketChat(p_146105_1_)); + } + + protected void onItemUseFinish() + { + this.playerNetServerHandler.sendPacket(new S19PacketEntityStatus(this, (byte)9)); + super.onItemUseFinish(); + } + + public void setItemInUse(ItemStack par1ItemStack, int par2) + { + super.setItemInUse(par1ItemStack, par2); + + if (par1ItemStack != null && par1ItemStack.getItem() != null && par1ItemStack.getItem().getItemUseAction(par1ItemStack) == EnumAction.eat) + { + this.getServerForPlayer().getEntityTracker().func_151248_b(this, new S0BPacketAnimation(this, 3)); + } + } + + public void clonePlayer(EntityPlayer par1EntityPlayer, boolean par2) + { + super.clonePlayer(par1EntityPlayer, par2); + this.lastExperience = -1; + this.lastHealth = -1.0F; + this.lastFoodLevel = -1; + this.destroyedItemsNetCache.addAll(((EntityPlayerMP)par1EntityPlayer).destroyedItemsNetCache); + } + + protected void onNewPotionEffect(PotionEffect par1PotionEffect) + { + super.onNewPotionEffect(par1PotionEffect); + this.playerNetServerHandler.sendPacket(new S1DPacketEntityEffect(this.getEntityId(), par1PotionEffect)); + } + + protected void onChangedPotionEffect(PotionEffect par1PotionEffect, boolean par2) + { + super.onChangedPotionEffect(par1PotionEffect, par2); + this.playerNetServerHandler.sendPacket(new S1DPacketEntityEffect(this.getEntityId(), par1PotionEffect)); + } + + protected void onFinishedPotionEffect(PotionEffect par1PotionEffect) + { + super.onFinishedPotionEffect(par1PotionEffect); + this.playerNetServerHandler.sendPacket(new S1EPacketRemoveEntityEffect(this.getEntityId(), par1PotionEffect)); + } + + public void setPositionAndUpdate(double par1, double par3, double par5) + { + this.playerNetServerHandler.setPlayerLocation(par1, par3, par5, this.rotationYaw, this.rotationPitch); + } + + public void onCriticalHit(Entity par1Entity) + { + this.getServerForPlayer().getEntityTracker().func_151248_b(this, new S0BPacketAnimation(par1Entity, 4)); + } + + public void onEnchantmentCritical(Entity par1Entity) + { + this.getServerForPlayer().getEntityTracker().func_151248_b(this, new S0BPacketAnimation(par1Entity, 5)); + } + + public void sendPlayerAbilities() + { + if (this.playerNetServerHandler != null) + { + this.playerNetServerHandler.sendPacket(new S39PacketPlayerAbilities(this.capabilities)); + } + } + + public WorldServer getServerForPlayer() + { + return (WorldServer)this.worldObj; + } + + public void setGameType(WorldSettings.GameType par1EnumGameType) + { + this.theItemInWorldManager.setGameType(par1EnumGameType); + this.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(3, (float)par1EnumGameType.getID())); + } + + public void addChatMessage(IChatComponent p_145747_1_) + { + this.playerNetServerHandler.sendPacket(new S02PacketChat(p_145747_1_)); + } + + public boolean canCommandSenderUseCommand(int par1, String par2Str) + { + return "seed".equals(par2Str) && !this.mcServer.isDedicatedServer() ? true : (!"tell".equals(par2Str) && !"help".equals(par2Str) && !"me".equals(par2Str) ? (this.mcServer.getConfigurationManager().isPlayerOpped(this.getCommandSenderName()) ? this.mcServer.getOpPermissionLevel() >= par1 : false) : true); + } + + public String getPlayerIP() + { + String s = this.playerNetServerHandler.netManager.getSocketAddress().toString(); + s = s.substring(s.indexOf("/") + 1); + s = s.substring(0, s.indexOf(":")); + return s; + } + + public void func_147100_a(C15PacketClientSettings p_147100_1_) + { + this.translator = p_147100_1_.func_149524_c(); + int i = 256 >> p_147100_1_.func_149521_d(); + + if (i > 3 && i < 15) + { + this.renderDistance = i; + } + + this.chatVisibility = p_147100_1_.func_149523_e(); + this.chatColours = p_147100_1_.func_149520_f(); + + if (this.mcServer.isSinglePlayer() && this.mcServer.getServerOwner().equals(this.getCommandSenderName())) + { + this.mcServer.func_147139_a(p_147100_1_.func_149518_g()); + } + + this.setHideCape(1, !p_147100_1_.func_149519_h()); + } + + public EntityPlayer.EnumChatVisibility func_147096_v() + { + return this.chatVisibility; + } + + public void requestTexturePackLoad(String p_147095_1_) + { + this.playerNetServerHandler.sendPacket(new S3FPacketCustomPayload("MC|RPack", p_147095_1_.getBytes(Charsets.UTF_8))); + } + + public ChunkCoordinates getPlayerCoordinates() + { + return new ChunkCoordinates(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY + 0.5D), MathHelper.floor_double(this.posZ)); + } + + public void func_143004_u() + { + this.field_143005_bX = MinecraftServer.getSystemTimeMillis(); + } + + public StatisticsFile func_147099_x() + { + return this.field_147103_bO; + } + + /* ===================================== FORGE START =====================================*/ + /** + * Returns the default eye height of the player + * @return player default eye height + */ + @Override + public float getDefaultEyeHeight() + { + return 1.62F; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/player/InventoryPlayer.java b/src/main/java/net/minecraft/entity/player/InventoryPlayer.java new file mode 100644 index 0000000..e70b6d0 --- /dev/null +++ b/src/main/java/net/minecraft/entity/player/InventoryPlayer.java @@ -0,0 +1,743 @@ +package net.minecraft.entity.player; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.concurrent.Callable; +import net.minecraft.block.Block; +import net.minecraft.crash.CrashReport; +import net.minecraft.crash.CrashReportCategory; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.Item; +import net.minecraft.item.ItemArmor; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.ReportedException; + +public class InventoryPlayer implements IInventory +{ + public ItemStack[] mainInventory = new ItemStack[36]; + public ItemStack[] armorInventory = new ItemStack[4]; + public int currentItem; + @SideOnly(Side.CLIENT) + private ItemStack currentItemStack; + public EntityPlayer player; + private ItemStack itemStack; + public boolean inventoryChanged; + private static final String __OBFID = "CL_00001709"; + + public InventoryPlayer(EntityPlayer par1EntityPlayer) + { + this.player = par1EntityPlayer; + } + + public ItemStack getCurrentItem() + { + return this.currentItem < 9 && this.currentItem >= 0 ? this.mainInventory[this.currentItem] : null; + } + + public static int getHotbarSize() + { + return 9; + } + + private int func_146029_c(Item p_146029_1_) + { + for (int i = 0; i < this.mainInventory.length; ++i) + { + if (this.mainInventory[i] != null && this.mainInventory[i].getItem() == p_146029_1_) + { + return i; + } + } + + return -1; + } + + @SideOnly(Side.CLIENT) + private int func_146024_c(Item p_146024_1_, int p_146024_2_) + { + for (int j = 0; j < this.mainInventory.length; ++j) + { + if (this.mainInventory[j] != null && this.mainInventory[j].getItem() == p_146024_1_ && this.mainInventory[j].getItemDamage() == p_146024_2_) + { + return j; + } + } + + return -1; + } + + private int storeItemStack(ItemStack par1ItemStack) + { + for (int i = 0; i < this.mainInventory.length; ++i) + { + if (this.mainInventory[i] != null && this.mainInventory[i].getItem() == par1ItemStack.getItem() && this.mainInventory[i].isStackable() && this.mainInventory[i].stackSize < this.mainInventory[i].getMaxStackSize() && this.mainInventory[i].stackSize < this.getInventoryStackLimit() && (!this.mainInventory[i].getHasSubtypes() || this.mainInventory[i].getItemDamage() == par1ItemStack.getItemDamage()) && ItemStack.areItemStackTagsEqual(this.mainInventory[i], par1ItemStack)) + { + return i; + } + } + + return -1; + } + + public int getFirstEmptyStack() + { + for (int i = 0; i < this.mainInventory.length; ++i) + { + if (this.mainInventory[i] == null) + { + return i; + } + } + + return -1; + } + + @SideOnly(Side.CLIENT) + public void func_146030_a(Item p_146030_1_, int p_146030_2_, boolean p_146030_3_, boolean p_146030_4_) + { + boolean flag2 = true; + this.currentItemStack = this.getCurrentItem(); + int k; + + if (p_146030_3_) + { + k = this.func_146024_c(p_146030_1_, p_146030_2_); + } + else + { + k = this.func_146029_c(p_146030_1_); + } + + if (k >= 0 && k < 9) + { + this.currentItem = k; + } + else + { + if (p_146030_4_ && p_146030_1_ != null) + { + int j = this.getFirstEmptyStack(); + + if (j >= 0 && j < 9) + { + this.currentItem = j; + } + + this.func_70439_a(p_146030_1_, p_146030_2_); + } + } + } + + public int clearInventory(Item p_146027_1_, int p_146027_2_) + { + int j = 0; + int k; + ItemStack itemstack; + + for (k = 0; k < this.mainInventory.length; ++k) + { + itemstack = this.mainInventory[k]; + + if (itemstack != null && (p_146027_1_ == null || itemstack.getItem() == p_146027_1_) && (p_146027_2_ <= -1 || itemstack.getItemDamage() == p_146027_2_)) + { + j += itemstack.stackSize; + this.mainInventory[k] = null; + } + } + + for (k = 0; k < this.armorInventory.length; ++k) + { + itemstack = this.armorInventory[k]; + + if (itemstack != null && (p_146027_1_ == null || itemstack.getItem() == p_146027_1_) && (p_146027_2_ <= -1 || itemstack.getItemDamage() == p_146027_2_)) + { + j += itemstack.stackSize; + this.armorInventory[k] = null; + } + } + + if (this.itemStack != null) + { + if (p_146027_1_ != null && this.itemStack.getItem() != p_146027_1_) + { + return j; + } + + if (p_146027_2_ > -1 && this.itemStack.getItemDamage() != p_146027_2_) + { + return j; + } + + j += this.itemStack.stackSize; + this.setItemStack((ItemStack)null); + } + + return j; + } + + @SideOnly(Side.CLIENT) + public void changeCurrentItem(int par1) + { + if (par1 > 0) + { + par1 = 1; + } + + if (par1 < 0) + { + par1 = -1; + } + + for (this.currentItem -= par1; this.currentItem < 0; this.currentItem += 9) + { + ; + } + + while (this.currentItem >= 9) + { + this.currentItem -= 9; + } + } + + @SideOnly(Side.CLIENT) + public void func_70439_a(Item par1Item, int par2) + { + if (par1Item != null) + { + if (this.currentItemStack != null && this.currentItemStack.isItemEnchantable() && this.func_146024_c(this.currentItemStack.getItem(), this.currentItemStack.getItemDamageForDisplay()) == this.currentItem) + { + return; + } + + int j = this.func_146024_c(par1Item, par2); + + if (j >= 0) + { + int k = this.mainInventory[j].stackSize; + this.mainInventory[j] = this.mainInventory[this.currentItem]; + this.mainInventory[this.currentItem] = new ItemStack(par1Item, k, par2); + } + else + { + this.mainInventory[this.currentItem] = new ItemStack(par1Item, 1, par2); + } + } + } + + private int storePartialItemStack(ItemStack par1ItemStack) + { + Item item = par1ItemStack.getItem(); + int i = par1ItemStack.stackSize; + int j; + + if (par1ItemStack.getMaxStackSize() == 1) + { + j = this.getFirstEmptyStack(); + + if (j < 0) + { + return i; + } + else + { + if (this.mainInventory[j] == null) + { + this.mainInventory[j] = ItemStack.copyItemStack(par1ItemStack); + } + + return 0; + } + } + else + { + j = this.storeItemStack(par1ItemStack); + + if (j < 0) + { + j = this.getFirstEmptyStack(); + } + + if (j < 0) + { + return i; + } + else + { + if (this.mainInventory[j] == null) + { + this.mainInventory[j] = new ItemStack(item, 0, par1ItemStack.getItemDamage()); + + if (par1ItemStack.hasTagCompound()) + { + this.mainInventory[j].setTagCompound((NBTTagCompound)par1ItemStack.getTagCompound().copy()); + } + } + + int k = i; + + if (i > this.mainInventory[j].getMaxStackSize() - this.mainInventory[j].stackSize) + { + k = this.mainInventory[j].getMaxStackSize() - this.mainInventory[j].stackSize; + } + + if (k > this.getInventoryStackLimit() - this.mainInventory[j].stackSize) + { + k = this.getInventoryStackLimit() - this.mainInventory[j].stackSize; + } + + if (k == 0) + { + return i; + } + else + { + i -= k; + this.mainInventory[j].stackSize += k; + this.mainInventory[j].animationsToGo = 5; + return i; + } + } + } + } + + public void decrementAnimations() + { + for (int i = 0; i < this.mainInventory.length; ++i) + { + if (this.mainInventory[i] != null) + { + this.mainInventory[i].updateAnimation(this.player.worldObj, this.player, i, this.currentItem == i); + } + } + + for (int i = 0; i < armorInventory.length; i++) + { + if (armorInventory[i] != null) + { + armorInventory[i].getItem().onArmorTick(player.worldObj, player, armorInventory[i]); + } + } + } + + public boolean consumeInventoryItem(Item p_146026_1_) + { + int i = this.func_146029_c(p_146026_1_); + + if (i < 0) + { + return false; + } + else + { + if (--this.mainInventory[i].stackSize <= 0) + { + this.mainInventory[i] = null; + } + + return true; + } + } + + public boolean hasItem(Item p_146028_1_) + { + int i = this.func_146029_c(p_146028_1_); + return i >= 0; + } + + public boolean addItemStackToInventory(final ItemStack par1ItemStack) + { + if (par1ItemStack != null && par1ItemStack.stackSize != 0 && par1ItemStack.getItem() != null) + { + try + { + int i; + + if (par1ItemStack.isItemDamaged()) + { + i = this.getFirstEmptyStack(); + + if (i >= 0) + { + this.mainInventory[i] = ItemStack.copyItemStack(par1ItemStack); + this.mainInventory[i].animationsToGo = 5; + par1ItemStack.stackSize = 0; + return true; + } + else if (this.player.capabilities.isCreativeMode) + { + par1ItemStack.stackSize = 0; + return true; + } + else + { + return false; + } + } + else + { + do + { + i = par1ItemStack.stackSize; + par1ItemStack.stackSize = this.storePartialItemStack(par1ItemStack); + } + while (par1ItemStack.stackSize > 0 && par1ItemStack.stackSize < i); + + if (par1ItemStack.stackSize == i && this.player.capabilities.isCreativeMode) + { + par1ItemStack.stackSize = 0; + return true; + } + else + { + return par1ItemStack.stackSize < i; + } + } + } + catch (Throwable throwable) + { + CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Adding item to inventory"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("Item being added"); + crashreportcategory.addCrashSection("Item ID", Integer.valueOf(Item.getIdFromItem(par1ItemStack.getItem()))); + crashreportcategory.addCrashSection("Item data", Integer.valueOf(par1ItemStack.getItemDamage())); + crashreportcategory.addCrashSectionCallable("Item name", new Callable() + { + private static final String __OBFID = "CL_00001710"; + public String call() + { + return par1ItemStack.getDisplayName(); + } + }); + throw new ReportedException(crashreport); + } + } + else + { + return false; + } + } + + public ItemStack decrStackSize(int par1, int par2) + { + ItemStack[] aitemstack = this.mainInventory; + + if (par1 >= this.mainInventory.length) + { + aitemstack = this.armorInventory; + par1 -= this.mainInventory.length; + } + + if (aitemstack[par1] != null) + { + ItemStack itemstack; + + if (aitemstack[par1].stackSize <= par2) + { + itemstack = aitemstack[par1]; + aitemstack[par1] = null; + return itemstack; + } + else + { + itemstack = aitemstack[par1].splitStack(par2); + + if (aitemstack[par1].stackSize == 0) + { + aitemstack[par1] = null; + } + + return itemstack; + } + } + else + { + return null; + } + } + + public ItemStack getStackInSlotOnClosing(int par1) + { + ItemStack[] aitemstack = this.mainInventory; + + if (par1 >= this.mainInventory.length) + { + aitemstack = this.armorInventory; + par1 -= this.mainInventory.length; + } + + if (aitemstack[par1] != null) + { + ItemStack itemstack = aitemstack[par1]; + aitemstack[par1] = null; + return itemstack; + } + else + { + return null; + } + } + + public void setInventorySlotContents(int par1, ItemStack par2ItemStack) + { + ItemStack[] aitemstack = this.mainInventory; + + if (par1 >= aitemstack.length) + { + par1 -= aitemstack.length; + aitemstack = this.armorInventory; + } + + aitemstack[par1] = par2ItemStack; + } + + public float func_146023_a(Block p_146023_1_) + { + float f = 1.0F; + + if (this.mainInventory[this.currentItem] != null) + { + f *= this.mainInventory[this.currentItem].func_150997_a(p_146023_1_); + } + + return f; + } + + public NBTTagList writeToNBT(NBTTagList par1NBTTagList) + { + int i; + NBTTagCompound nbttagcompound; + + for (i = 0; i < this.mainInventory.length; ++i) + { + if (this.mainInventory[i] != null) + { + nbttagcompound = new NBTTagCompound(); + nbttagcompound.setByte("Slot", (byte)i); + this.mainInventory[i].writeToNBT(nbttagcompound); + par1NBTTagList.appendTag(nbttagcompound); + } + } + + for (i = 0; i < this.armorInventory.length; ++i) + { + if (this.armorInventory[i] != null) + { + nbttagcompound = new NBTTagCompound(); + nbttagcompound.setByte("Slot", (byte)(i + 100)); + this.armorInventory[i].writeToNBT(nbttagcompound); + par1NBTTagList.appendTag(nbttagcompound); + } + } + + return par1NBTTagList; + } + + public void readFromNBT(NBTTagList par1NBTTagList) + { + this.mainInventory = new ItemStack[36]; + this.armorInventory = new ItemStack[4]; + + for (int i = 0; i < par1NBTTagList.tagCount(); ++i) + { + NBTTagCompound nbttagcompound = par1NBTTagList.getCompoundTagAt(i); + int j = nbttagcompound.getByte("Slot") & 255; + ItemStack itemstack = ItemStack.loadItemStackFromNBT(nbttagcompound); + + if (itemstack != null) + { + if (j >= 0 && j < this.mainInventory.length) + { + this.mainInventory[j] = itemstack; + } + + if (j >= 100 && j < this.armorInventory.length + 100) + { + this.armorInventory[j - 100] = itemstack; + } + } + } + } + + public int getSizeInventory() + { + return this.mainInventory.length + 4; + } + + public ItemStack getStackInSlot(int par1) + { + ItemStack[] aitemstack = this.mainInventory; + + if (par1 >= aitemstack.length) + { + par1 -= aitemstack.length; + aitemstack = this.armorInventory; + } + + return aitemstack[par1]; + } + + public String getInventoryName() + { + return "container.inventory"; + } + + public boolean hasCustomInventoryName() + { + return false; + } + + public int getInventoryStackLimit() + { + return 64; + } + + public boolean func_146025_b(Block p_146025_1_) + { + if (p_146025_1_.getMaterial().isToolNotRequired()) + { + return true; + } + else + { + ItemStack itemstack = this.getStackInSlot(this.currentItem); + return itemstack != null ? itemstack.func_150998_b(p_146025_1_) : false; + } + } + + public ItemStack armorItemInSlot(int par1) + { + return this.armorInventory[par1]; + } + + public int getTotalArmorValue() + { + int i = 0; + + for (int j = 0; j < this.armorInventory.length; ++j) + { + if (this.armorInventory[j] != null && this.armorInventory[j].getItem() instanceof ItemArmor) + { + int k = ((ItemArmor)this.armorInventory[j].getItem()).damageReduceAmount; + i += k; + } + } + + return i; + } + + public void damageArmor(float par1) + { + par1 /= 4.0F; + + if (par1 < 1.0F) + { + par1 = 1.0F; + } + + for (int i = 0; i < this.armorInventory.length; ++i) + { + if (this.armorInventory[i] != null && this.armorInventory[i].getItem() instanceof ItemArmor) + { + this.armorInventory[i].damageItem((int)par1, this.player); + + if (this.armorInventory[i].stackSize == 0) + { + this.armorInventory[i] = null; + } + } + } + } + + public void dropAllItems() + { + int i; + + for (i = 0; i < this.mainInventory.length; ++i) + { + if (this.mainInventory[i] != null) + { + this.player.func_146097_a(this.mainInventory[i], true, false); + this.mainInventory[i] = null; + } + } + + for (i = 0; i < this.armorInventory.length; ++i) + { + if (this.armorInventory[i] != null) + { + this.player.func_146097_a(this.armorInventory[i], true, false); + this.armorInventory[i] = null; + } + } + } + + public void markDirty() + { + this.inventoryChanged = true; + } + + public void setItemStack(ItemStack par1ItemStack) + { + this.itemStack = par1ItemStack; + } + + public ItemStack getItemStack() + { + return this.itemStack; + } + + public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) + { + return this.player.isDead ? false : par1EntityPlayer.getDistanceSqToEntity(this.player) <= 64.0D; + } + + public boolean hasItemStack(ItemStack par1ItemStack) + { + int i; + + for (i = 0; i < this.armorInventory.length; ++i) + { + if (this.armorInventory[i] != null && this.armorInventory[i].isItemEqual(par1ItemStack)) + { + return true; + } + } + + for (i = 0; i < this.mainInventory.length; ++i) + { + if (this.mainInventory[i] != null && this.mainInventory[i].isItemEqual(par1ItemStack)) + { + return true; + } + } + + return false; + } + + public void openInventory() {} + + public void closeInventory() {} + + public boolean isItemValidForSlot(int par1, ItemStack par2ItemStack) + { + return true; + } + + public void copyInventory(InventoryPlayer par1InventoryPlayer) + { + int i; + + for (i = 0; i < this.mainInventory.length; ++i) + { + this.mainInventory[i] = ItemStack.copyItemStack(par1InventoryPlayer.mainInventory[i]); + } + + for (i = 0; i < this.armorInventory.length; ++i) + { + this.armorInventory[i] = ItemStack.copyItemStack(par1InventoryPlayer.armorInventory[i]); + } + + this.currentItem = par1InventoryPlayer.currentItem; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/player/PlayerCapabilities.java b/src/main/java/net/minecraft/entity/player/PlayerCapabilities.java new file mode 100644 index 0000000..9fd1d4f --- /dev/null +++ b/src/main/java/net/minecraft/entity/player/PlayerCapabilities.java @@ -0,0 +1,75 @@ +package net.minecraft.entity.player; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.nbt.NBTTagCompound; + +public class PlayerCapabilities +{ + public boolean disableDamage; + public boolean isFlying; + public boolean allowFlying; + public boolean isCreativeMode; + public boolean allowEdit = true; + private float flySpeed = 0.05F; + private float walkSpeed = 0.1F; + private static final String __OBFID = "CL_00001708"; + + public void writeCapabilitiesToNBT(NBTTagCompound par1NBTTagCompound) + { + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + nbttagcompound1.setBoolean("invulnerable", this.disableDamage); + nbttagcompound1.setBoolean("flying", this.isFlying); + nbttagcompound1.setBoolean("mayfly", this.allowFlying); + nbttagcompound1.setBoolean("instabuild", this.isCreativeMode); + nbttagcompound1.setBoolean("mayBuild", this.allowEdit); + nbttagcompound1.setFloat("flySpeed", this.flySpeed); + nbttagcompound1.setFloat("walkSpeed", this.walkSpeed); + par1NBTTagCompound.setTag("abilities", nbttagcompound1); + } + + public void readCapabilitiesFromNBT(NBTTagCompound par1NBTTagCompound) + { + if (par1NBTTagCompound.hasKey("abilities", 10)) + { + NBTTagCompound nbttagcompound1 = par1NBTTagCompound.getCompoundTag("abilities"); + this.disableDamage = nbttagcompound1.getBoolean("invulnerable"); + this.isFlying = nbttagcompound1.getBoolean("flying"); + this.allowFlying = nbttagcompound1.getBoolean("mayfly"); + this.isCreativeMode = nbttagcompound1.getBoolean("instabuild"); + + if (nbttagcompound1.hasKey("flySpeed", 99)) + { + this.flySpeed = nbttagcompound1.getFloat("flySpeed"); + this.walkSpeed = nbttagcompound1.getFloat("walkSpeed"); + } + + if (nbttagcompound1.hasKey("mayBuild", 1)) + { + this.allowEdit = nbttagcompound1.getBoolean("mayBuild"); + } + } + } + + public float getFlySpeed() + { + return this.flySpeed; + } + + @SideOnly(Side.CLIENT) + public void setFlySpeed(float par1) + { + this.flySpeed = par1; + } + + public float getWalkSpeed() + { + return this.walkSpeed; + } + + @SideOnly(Side.CLIENT) + public void setPlayerWalkSpeed(float par1) + { + this.walkSpeed = par1; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/projectile/EntityArrow.java b/src/main/java/net/minecraft/entity/projectile/EntityArrow.java new file mode 100644 index 0000000..5a6cccd --- /dev/null +++ b/src/main/java/net/minecraft/entity/projectile/EntityArrow.java @@ -0,0 +1,556 @@ +package net.minecraft.entity.projectile; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IProjectile; +import net.minecraft.entity.monster.EntityEnderman; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.play.server.S2BPacketChangeGameState; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; + +public class EntityArrow extends Entity implements IProjectile +{ + private int field_145791_d = -1; + private int field_145792_e = -1; + private int field_145789_f = -1; + private Block field_145790_g; + private int inData; + private boolean inGround; + public int canBePickedUp; + public int arrowShake; + public Entity shootingEntity; + private int ticksInGround; + private int ticksInAir; + private double damage = 2.0D; + private int knockbackStrength; + private static final String __OBFID = "CL_00001715"; + + public EntityArrow(World par1World) + { + super(par1World); + this.renderDistanceWeight = 10.0D; + this.setSize(0.5F, 0.5F); + } + + public EntityArrow(World par1World, double par2, double par4, double par6) + { + super(par1World); + this.renderDistanceWeight = 10.0D; + this.setSize(0.5F, 0.5F); + this.setPosition(par2, par4, par6); + this.yOffset = 0.0F; + } + + public EntityArrow(World par1World, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase, float par4, float par5) + { + super(par1World); + this.renderDistanceWeight = 10.0D; + this.shootingEntity = par2EntityLivingBase; + + if (par2EntityLivingBase instanceof EntityPlayer) + { + this.canBePickedUp = 1; + } + + this.posY = par2EntityLivingBase.posY + (double)par2EntityLivingBase.getEyeHeight() - 0.10000000149011612D; + double d0 = par3EntityLivingBase.posX - par2EntityLivingBase.posX; + double d1 = par3EntityLivingBase.boundingBox.minY + (double)(par3EntityLivingBase.height / 3.0F) - this.posY; + double d2 = par3EntityLivingBase.posZ - par2EntityLivingBase.posZ; + double d3 = (double)MathHelper.sqrt_double(d0 * d0 + d2 * d2); + + if (d3 >= 1.0E-7D) + { + float f2 = (float)(Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F; + float f3 = (float)(-(Math.atan2(d1, d3) * 180.0D / Math.PI)); + double d4 = d0 / d3; + double d5 = d2 / d3; + this.setLocationAndAngles(par2EntityLivingBase.posX + d4, this.posY, par2EntityLivingBase.posZ + d5, f2, f3); + this.yOffset = 0.0F; + float f4 = (float)d3 * 0.2F; + this.setThrowableHeading(d0, d1 + (double)f4, d2, par4, par5); + } + } + + public EntityArrow(World par1World, EntityLivingBase par2EntityLivingBase, float par3) + { + super(par1World); + this.renderDistanceWeight = 10.0D; + this.shootingEntity = par2EntityLivingBase; + + if (par2EntityLivingBase instanceof EntityPlayer) + { + this.canBePickedUp = 1; + } + + this.setSize(0.5F, 0.5F); + this.setLocationAndAngles(par2EntityLivingBase.posX, par2EntityLivingBase.posY + (double)par2EntityLivingBase.getEyeHeight(), par2EntityLivingBase.posZ, par2EntityLivingBase.rotationYaw, par2EntityLivingBase.rotationPitch); + this.posX -= (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F); + this.posY -= 0.10000000149011612D; + this.posZ -= (double)(MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F); + this.setPosition(this.posX, this.posY, this.posZ); + this.yOffset = 0.0F; + this.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI)); + this.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI)); + this.motionY = (double)(-MathHelper.sin(this.rotationPitch / 180.0F * (float)Math.PI)); + this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, par3 * 1.5F, 1.0F); + } + + protected void entityInit() + { + this.dataWatcher.addObject(16, Byte.valueOf((byte)0)); + } + + public void setThrowableHeading(double par1, double par3, double par5, float par7, float par8) + { + float f2 = MathHelper.sqrt_double(par1 * par1 + par3 * par3 + par5 * par5); + par1 /= (double)f2; + par3 /= (double)f2; + par5 /= (double)f2; + par1 += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)par8; + par3 += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)par8; + par5 += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)par8; + par1 *= (double)par7; + par3 *= (double)par7; + par5 *= (double)par7; + this.motionX = par1; + this.motionY = par3; + this.motionZ = par5; + float f3 = MathHelper.sqrt_double(par1 * par1 + par5 * par5); + this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(par1, par5) * 180.0D / Math.PI); + this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(par3, (double)f3) * 180.0D / Math.PI); + this.ticksInGround = 0; + } + + @SideOnly(Side.CLIENT) + public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9) + { + this.setPosition(par1, par3, par5); + this.setRotation(par7, par8); + } + + @SideOnly(Side.CLIENT) + public void setVelocity(double par1, double par3, double par5) + { + this.motionX = par1; + this.motionY = par3; + this.motionZ = par5; + + if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) + { + float f = MathHelper.sqrt_double(par1 * par1 + par5 * par5); + this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(par1, par5) * 180.0D / Math.PI); + this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(par3, (double)f) * 180.0D / Math.PI); + this.prevRotationPitch = this.rotationPitch; + this.prevRotationYaw = this.rotationYaw; + this.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch); + this.ticksInGround = 0; + } + } + + public void onUpdate() + { + super.onUpdate(); + + if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) + { + float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); + this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); + this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f) * 180.0D / Math.PI); + } + + Block block = this.worldObj.getBlock(this.field_145791_d, this.field_145792_e, this.field_145789_f); + + if (block.getMaterial() != Material.air) + { + block.setBlockBoundsBasedOnState(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f); + AxisAlignedBB axisalignedbb = block.getCollisionBoundingBoxFromPool(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f); + + if (axisalignedbb != null && axisalignedbb.isVecInside(this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ))) + { + this.inGround = true; + } + } + + if (this.arrowShake > 0) + { + --this.arrowShake; + } + + if (this.inGround) + { + int j = this.worldObj.getBlockMetadata(this.field_145791_d, this.field_145792_e, this.field_145789_f); + + if (block == this.field_145790_g && j == this.inData) + { + ++this.ticksInGround; + + if (this.ticksInGround == 1200) + { + this.setDead(); + } + } + else + { + this.inGround = false; + this.motionX *= (double)(this.rand.nextFloat() * 0.2F); + this.motionY *= (double)(this.rand.nextFloat() * 0.2F); + this.motionZ *= (double)(this.rand.nextFloat() * 0.2F); + this.ticksInGround = 0; + this.ticksInAir = 0; + } + } + else + { + ++this.ticksInAir; + Vec3 vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ); + Vec3 vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); + MovingObjectPosition movingobjectposition = this.worldObj.func_147447_a(vec31, vec3, false, true, false); + vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ); + vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); + + if (movingobjectposition != null) + { + vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord); + } + + Entity entity = null; + List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D)); + double d0 = 0.0D; + int i; + float f1; + + for (i = 0; i < list.size(); ++i) + { + Entity entity1 = (Entity)list.get(i); + + if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5)) + { + f1 = 0.3F; + AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand((double)f1, (double)f1, (double)f1); + MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec31, vec3); + + if (movingobjectposition1 != null) + { + double d1 = vec31.distanceTo(movingobjectposition1.hitVec); + + if (d1 < d0 || d0 == 0.0D) + { + entity = entity1; + d0 = d1; + } + } + } + } + + if (entity != null) + { + movingobjectposition = new MovingObjectPosition(entity); + } + + if (movingobjectposition != null && movingobjectposition.entityHit != null && movingobjectposition.entityHit instanceof EntityPlayer) + { + EntityPlayer entityplayer = (EntityPlayer)movingobjectposition.entityHit; + + if (entityplayer.capabilities.disableDamage || this.shootingEntity instanceof EntityPlayer && !((EntityPlayer)this.shootingEntity).canAttackPlayer(entityplayer)) + { + movingobjectposition = null; + } + } + + float f2; + float f4; + + if (movingobjectposition != null) + { + if (movingobjectposition.entityHit != null) + { + f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); + int k = MathHelper.ceiling_double_int((double)f2 * this.damage); + + if (this.getIsCritical()) + { + k += this.rand.nextInt(k / 2 + 2); + } + + DamageSource damagesource = null; + + if (this.shootingEntity == null) + { + damagesource = DamageSource.causeArrowDamage(this, this); + } + else + { + damagesource = DamageSource.causeArrowDamage(this, this.shootingEntity); + } + + if (this.isBurning() && !(movingobjectposition.entityHit instanceof EntityEnderman)) + { + movingobjectposition.entityHit.setFire(5); + } + + if (movingobjectposition.entityHit.attackEntityFrom(damagesource, (float)k)) + { + if (movingobjectposition.entityHit instanceof EntityLivingBase) + { + EntityLivingBase entitylivingbase = (EntityLivingBase)movingobjectposition.entityHit; + + if (!this.worldObj.isRemote) + { + entitylivingbase.setArrowCountInEntity(entitylivingbase.getArrowCountInEntity() + 1); + } + + if (this.knockbackStrength > 0) + { + f4 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); + + if (f4 > 0.0F) + { + movingobjectposition.entityHit.addVelocity(this.motionX * (double)this.knockbackStrength * 0.6000000238418579D / (double)f4, 0.1D, this.motionZ * (double)this.knockbackStrength * 0.6000000238418579D / (double)f4); + } + } + + if (this.shootingEntity != null && this.shootingEntity instanceof EntityLivingBase) + { + EnchantmentHelper.func_151384_a(entitylivingbase, this.shootingEntity); + EnchantmentHelper.func_151385_b((EntityLivingBase)this.shootingEntity, entitylivingbase); + } + + if (this.shootingEntity != null && movingobjectposition.entityHit != this.shootingEntity && movingobjectposition.entityHit instanceof EntityPlayer && this.shootingEntity instanceof EntityPlayerMP) + { + ((EntityPlayerMP)this.shootingEntity).playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(6, 0.0F)); + } + } + + this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); + + if (!(movingobjectposition.entityHit instanceof EntityEnderman)) + { + this.setDead(); + } + } + else + { + this.motionX *= -0.10000000149011612D; + this.motionY *= -0.10000000149011612D; + this.motionZ *= -0.10000000149011612D; + this.rotationYaw += 180.0F; + this.prevRotationYaw += 180.0F; + this.ticksInAir = 0; + } + } + else + { + this.field_145791_d = movingobjectposition.blockX; + this.field_145792_e = movingobjectposition.blockY; + this.field_145789_f = movingobjectposition.blockZ; + this.field_145790_g = block; + this.inData = this.worldObj.getBlockMetadata(this.field_145791_d, this.field_145792_e, this.field_145789_f); + this.motionX = (double)((float)(movingobjectposition.hitVec.xCoord - this.posX)); + this.motionY = (double)((float)(movingobjectposition.hitVec.yCoord - this.posY)); + this.motionZ = (double)((float)(movingobjectposition.hitVec.zCoord - this.posZ)); + f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); + this.posX -= this.motionX / (double)f2 * 0.05000000074505806D; + this.posY -= this.motionY / (double)f2 * 0.05000000074505806D; + this.posZ -= this.motionZ / (double)f2 * 0.05000000074505806D; + this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); + this.inGround = true; + this.arrowShake = 7; + this.setIsCritical(false); + + if (this.field_145790_g.getMaterial() != Material.air) + { + this.field_145790_g.onEntityCollidedWithBlock(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f, this); + } + } + } + + if (this.getIsCritical()) + { + for (i = 0; i < 4; ++i) + { + this.worldObj.spawnParticle("crit", this.posX + this.motionX * (double)i / 4.0D, this.posY + this.motionY * (double)i / 4.0D, this.posZ + this.motionZ * (double)i / 4.0D, -this.motionX, -this.motionY + 0.2D, -this.motionZ); + } + } + + this.posX += this.motionX; + this.posY += this.motionY; + this.posZ += this.motionZ; + f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); + this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); + + for (this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f2) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) + { + ; + } + + while (this.rotationPitch - this.prevRotationPitch >= 180.0F) + { + this.prevRotationPitch += 360.0F; + } + + while (this.rotationYaw - this.prevRotationYaw < -180.0F) + { + this.prevRotationYaw -= 360.0F; + } + + while (this.rotationYaw - this.prevRotationYaw >= 180.0F) + { + this.prevRotationYaw += 360.0F; + } + + this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F; + this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F; + float f3 = 0.99F; + f1 = 0.05F; + + if (this.isInWater()) + { + for (int l = 0; l < 4; ++l) + { + f4 = 0.25F; + this.worldObj.spawnParticle("bubble", this.posX - this.motionX * (double)f4, this.posY - this.motionY * (double)f4, this.posZ - this.motionZ * (double)f4, this.motionX, this.motionY, this.motionZ); + } + + f3 = 0.8F; + } + + if (this.isWet()) + { + this.extinguish(); + } + + this.motionX *= (double)f3; + this.motionY *= (double)f3; + this.motionZ *= (double)f3; + this.motionY -= (double)f1; + this.setPosition(this.posX, this.posY, this.posZ); + this.func_145775_I(); + } + } + + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + par1NBTTagCompound.setShort("xTile", (short)this.field_145791_d); + par1NBTTagCompound.setShort("yTile", (short)this.field_145792_e); + par1NBTTagCompound.setShort("zTile", (short)this.field_145789_f); + par1NBTTagCompound.setShort("life", (short)this.ticksInGround); + par1NBTTagCompound.setByte("inTile", (byte)Block.getIdFromBlock(this.field_145790_g)); + par1NBTTagCompound.setByte("inData", (byte)this.inData); + par1NBTTagCompound.setByte("shake", (byte)this.arrowShake); + par1NBTTagCompound.setByte("inGround", (byte)(this.inGround ? 1 : 0)); + par1NBTTagCompound.setByte("pickup", (byte)this.canBePickedUp); + par1NBTTagCompound.setDouble("damage", this.damage); + } + + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + this.field_145791_d = par1NBTTagCompound.getShort("xTile"); + this.field_145792_e = par1NBTTagCompound.getShort("yTile"); + this.field_145789_f = par1NBTTagCompound.getShort("zTile"); + this.ticksInGround = par1NBTTagCompound.getShort("life"); + this.field_145790_g = Block.getBlockById(par1NBTTagCompound.getByte("inTile") & 255); + this.inData = par1NBTTagCompound.getByte("inData") & 255; + this.arrowShake = par1NBTTagCompound.getByte("shake") & 255; + this.inGround = par1NBTTagCompound.getByte("inGround") == 1; + + if (par1NBTTagCompound.hasKey("damage", 99)) + { + this.damage = par1NBTTagCompound.getDouble("damage"); + } + + if (par1NBTTagCompound.hasKey("pickup", 99)) + { + this.canBePickedUp = par1NBTTagCompound.getByte("pickup"); + } + else if (par1NBTTagCompound.hasKey("player", 99)) + { + this.canBePickedUp = par1NBTTagCompound.getBoolean("player") ? 1 : 0; + } + } + + public void onCollideWithPlayer(EntityPlayer par1EntityPlayer) + { + if (!this.worldObj.isRemote && this.inGround && this.arrowShake <= 0) + { + boolean flag = this.canBePickedUp == 1 || this.canBePickedUp == 2 && par1EntityPlayer.capabilities.isCreativeMode; + + if (this.canBePickedUp == 1 && !par1EntityPlayer.inventory.addItemStackToInventory(new ItemStack(Items.arrow, 1))) + { + flag = false; + } + + if (flag) + { + this.playSound("random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); + par1EntityPlayer.onItemPickup(this, 1); + this.setDead(); + } + } + } + + protected boolean canTriggerWalking() + { + return false; + } + + @SideOnly(Side.CLIENT) + public float getShadowSize() + { + return 0.0F; + } + + public void setDamage(double par1) + { + this.damage = par1; + } + + public double getDamage() + { + return this.damage; + } + + public void setKnockbackStrength(int par1) + { + this.knockbackStrength = par1; + } + + public boolean canAttackWithItem() + { + return false; + } + + public void setIsCritical(boolean par1) + { + byte b0 = this.dataWatcher.getWatchableObjectByte(16); + + if (par1) + { + this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 | 1))); + } + else + { + this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 & -2))); + } + } + + public boolean getIsCritical() + { + byte b0 = this.dataWatcher.getWatchableObjectByte(16); + return (b0 & 1) != 0; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/projectile/EntityEgg.java b/src/main/java/net/minecraft/entity/projectile/EntityEgg.java new file mode 100644 index 0000000..92a36d2 --- /dev/null +++ b/src/main/java/net/minecraft/entity/projectile/EntityEgg.java @@ -0,0 +1,63 @@ +package net.minecraft.entity.projectile; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.passive.EntityChicken; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; + +public class EntityEgg extends EntityThrowable +{ + private static final String __OBFID = "CL_00001724"; + + public EntityEgg(World par1World) + { + super(par1World); + } + + public EntityEgg(World par1World, EntityLivingBase par2EntityLivingBase) + { + super(par1World, par2EntityLivingBase); + } + + public EntityEgg(World par1World, double par2, double par4, double par6) + { + super(par1World, par2, par4, par6); + } + + protected void onImpact(MovingObjectPosition par1MovingObjectPosition) + { + if (par1MovingObjectPosition.entityHit != null) + { + par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 0.0F); + } + + if (!this.worldObj.isRemote && this.rand.nextInt(8) == 0) + { + byte b0 = 1; + + if (this.rand.nextInt(32) == 0) + { + b0 = 4; + } + + for (int i = 0; i < b0; ++i) + { + EntityChicken entitychicken = new EntityChicken(this.worldObj); + entitychicken.setGrowingAge(-24000); + entitychicken.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F); + this.worldObj.spawnEntityInWorld(entitychicken); + } + } + + for (int j = 0; j < 8; ++j) + { + this.worldObj.spawnParticle("snowballpoof", this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D); + } + + if (!this.worldObj.isRemote) + { + this.setDead(); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/projectile/EntityFireball.java b/src/main/java/net/minecraft/entity/projectile/EntityFireball.java new file mode 100644 index 0000000..987c668 --- /dev/null +++ b/src/main/java/net/minecraft/entity/projectile/EntityFireball.java @@ -0,0 +1,318 @@ +package net.minecraft.entity.projectile; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; + +public abstract class EntityFireball extends Entity +{ + private int field_145795_e = -1; + private int field_145793_f = -1; + private int field_145794_g = -1; + private Block field_145796_h; + private boolean inGround; + public EntityLivingBase shootingEntity; + private int ticksAlive; + private int ticksInAir; + public double accelerationX; + public double accelerationY; + public double accelerationZ; + private static final String __OBFID = "CL_00001717"; + + public EntityFireball(World par1World) + { + super(par1World); + this.setSize(1.0F, 1.0F); + } + + protected void entityInit() {} + + @SideOnly(Side.CLIENT) + public boolean isInRangeToRenderDist(double par1) + { + double d1 = this.boundingBox.getAverageEdgeLength() * 4.0D; + d1 *= 64.0D; + return par1 < d1 * d1; + } + + public EntityFireball(World par1World, double par2, double par4, double par6, double par8, double par10, double par12) + { + super(par1World); + this.setSize(1.0F, 1.0F); + this.setLocationAndAngles(par2, par4, par6, this.rotationYaw, this.rotationPitch); + this.setPosition(par2, par4, par6); + double d6 = (double)MathHelper.sqrt_double(par8 * par8 + par10 * par10 + par12 * par12); + this.accelerationX = par8 / d6 * 0.1D; + this.accelerationY = par10 / d6 * 0.1D; + this.accelerationZ = par12 / d6 * 0.1D; + } + + public EntityFireball(World par1World, EntityLivingBase par2EntityLivingBase, double par3, double par5, double par7) + { + super(par1World); + this.shootingEntity = par2EntityLivingBase; + this.setSize(1.0F, 1.0F); + this.setLocationAndAngles(par2EntityLivingBase.posX, par2EntityLivingBase.posY, par2EntityLivingBase.posZ, par2EntityLivingBase.rotationYaw, par2EntityLivingBase.rotationPitch); + this.setPosition(this.posX, this.posY, this.posZ); + this.yOffset = 0.0F; + this.motionX = this.motionY = this.motionZ = 0.0D; + par3 += this.rand.nextGaussian() * 0.4D; + par5 += this.rand.nextGaussian() * 0.4D; + par7 += this.rand.nextGaussian() * 0.4D; + double d3 = (double)MathHelper.sqrt_double(par3 * par3 + par5 * par5 + par7 * par7); + this.accelerationX = par3 / d3 * 0.1D; + this.accelerationY = par5 / d3 * 0.1D; + this.accelerationZ = par7 / d3 * 0.1D; + } + + public void onUpdate() + { + if (!this.worldObj.isRemote && (this.shootingEntity != null && this.shootingEntity.isDead || !this.worldObj.blockExists((int)this.posX, (int)this.posY, (int)this.posZ))) + { + this.setDead(); + } + else + { + super.onUpdate(); + this.setFire(1); + + if (this.inGround) + { + if (this.worldObj.getBlock(this.field_145795_e, this.field_145793_f, this.field_145794_g) == this.field_145796_h) + { + ++this.ticksAlive; + + if (this.ticksAlive == 600) + { + this.setDead(); + } + + return; + } + + this.inGround = false; + this.motionX *= (double)(this.rand.nextFloat() * 0.2F); + this.motionY *= (double)(this.rand.nextFloat() * 0.2F); + this.motionZ *= (double)(this.rand.nextFloat() * 0.2F); + this.ticksAlive = 0; + this.ticksInAir = 0; + } + else + { + ++this.ticksInAir; + } + + Vec3 vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ); + Vec3 vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); + MovingObjectPosition movingobjectposition = this.worldObj.rayTraceBlocks(vec3, vec31); + vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ); + vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); + + if (movingobjectposition != null) + { + vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord); + } + + Entity entity = null; + List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D)); + double d0 = 0.0D; + + for (int i = 0; i < list.size(); ++i) + { + Entity entity1 = (Entity)list.get(i); + + if (entity1.canBeCollidedWith() && (!entity1.isEntityEqual(this.shootingEntity) || this.ticksInAir >= 25)) + { + float f = 0.3F; + AxisAlignedBB axisalignedbb = entity1.boundingBox.expand((double)f, (double)f, (double)f); + MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3, vec31); + + if (movingobjectposition1 != null) + { + double d1 = vec3.distanceTo(movingobjectposition1.hitVec); + + if (d1 < d0 || d0 == 0.0D) + { + entity = entity1; + d0 = d1; + } + } + } + } + + if (entity != null) + { + movingobjectposition = new MovingObjectPosition(entity); + } + + if (movingobjectposition != null) + { + this.onImpact(movingobjectposition); + } + + this.posX += this.motionX; + this.posY += this.motionY; + this.posZ += this.motionZ; + float f1 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); + this.rotationYaw = (float)(Math.atan2(this.motionZ, this.motionX) * 180.0D / Math.PI) + 90.0F; + + for (this.rotationPitch = (float)(Math.atan2((double)f1, this.motionY) * 180.0D / Math.PI) - 90.0F; this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) + { + ; + } + + while (this.rotationPitch - this.prevRotationPitch >= 180.0F) + { + this.prevRotationPitch += 360.0F; + } + + while (this.rotationYaw - this.prevRotationYaw < -180.0F) + { + this.prevRotationYaw -= 360.0F; + } + + while (this.rotationYaw - this.prevRotationYaw >= 180.0F) + { + this.prevRotationYaw += 360.0F; + } + + this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F; + this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F; + float f2 = this.getMotionFactor(); + + if (this.isInWater()) + { + for (int j = 0; j < 4; ++j) + { + float f3 = 0.25F; + this.worldObj.spawnParticle("bubble", this.posX - this.motionX * (double)f3, this.posY - this.motionY * (double)f3, this.posZ - this.motionZ * (double)f3, this.motionX, this.motionY, this.motionZ); + } + + f2 = 0.8F; + } + + this.motionX += this.accelerationX; + this.motionY += this.accelerationY; + this.motionZ += this.accelerationZ; + this.motionX *= (double)f2; + this.motionY *= (double)f2; + this.motionZ *= (double)f2; + this.worldObj.spawnParticle("smoke", this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D); + this.setPosition(this.posX, this.posY, this.posZ); + } + } + + protected float getMotionFactor() + { + return 0.95F; + } + + protected abstract void onImpact(MovingObjectPosition var1); + + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + par1NBTTagCompound.setShort("xTile", (short)this.field_145795_e); + par1NBTTagCompound.setShort("yTile", (short)this.field_145793_f); + par1NBTTagCompound.setShort("zTile", (short)this.field_145794_g); + par1NBTTagCompound.setByte("inTile", (byte)Block.getIdFromBlock(this.field_145796_h)); + par1NBTTagCompound.setByte("inGround", (byte)(this.inGround ? 1 : 0)); + par1NBTTagCompound.setTag("direction", this.newDoubleNBTList(new double[] {this.motionX, this.motionY, this.motionZ})); + } + + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + this.field_145795_e = par1NBTTagCompound.getShort("xTile"); + this.field_145793_f = par1NBTTagCompound.getShort("yTile"); + this.field_145794_g = par1NBTTagCompound.getShort("zTile"); + this.field_145796_h = Block.getBlockById(par1NBTTagCompound.getByte("inTile") & 255); + this.inGround = par1NBTTagCompound.getByte("inGround") == 1; + + if (par1NBTTagCompound.hasKey("direction", 9)) + { + NBTTagList nbttaglist = par1NBTTagCompound.getTagList("direction", 6); + this.motionX = nbttaglist.func_150309_d(0); + this.motionY = nbttaglist.func_150309_d(1); + this.motionZ = nbttaglist.func_150309_d(2); + } + else + { + this.setDead(); + } + } + + public boolean canBeCollidedWith() + { + return true; + } + + public float getCollisionBorderSize() + { + return 1.0F; + } + + public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) + { + if (this.isEntityInvulnerable()) + { + return false; + } + else + { + this.setBeenAttacked(); + + if (par1DamageSource.getEntity() != null) + { + Vec3 vec3 = par1DamageSource.getEntity().getLookVec(); + + if (vec3 != null) + { + this.motionX = vec3.xCoord; + this.motionY = vec3.yCoord; + this.motionZ = vec3.zCoord; + this.accelerationX = this.motionX * 0.1D; + this.accelerationY = this.motionY * 0.1D; + this.accelerationZ = this.motionZ * 0.1D; + } + + if (par1DamageSource.getEntity() instanceof EntityLivingBase) + { + this.shootingEntity = (EntityLivingBase)par1DamageSource.getEntity(); + } + + return true; + } + else + { + return false; + } + } + } + + @SideOnly(Side.CLIENT) + public float getShadowSize() + { + return 0.0F; + } + + public float getBrightness(float par1) + { + return 1.0F; + } + + @SideOnly(Side.CLIENT) + public int getBrightnessForRender(float par1) + { + return 15728880; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/projectile/EntityFishHook.java b/src/main/java/net/minecraft/entity/projectile/EntityFishHook.java new file mode 100644 index 0000000..7a86af8 --- /dev/null +++ b/src/main/java/net/minecraft/entity/projectile/EntityFishHook.java @@ -0,0 +1,591 @@ +package net.minecraft.entity.projectile; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Arrays; +import java.util.List; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.item.EntityXPOrb; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemFishFood; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.stats.StatList; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.Vec3; +import net.minecraft.util.WeightedRandom; +import net.minecraft.util.WeightedRandomFishable; +import net.minecraft.world.World; +import net.minecraft.world.WorldServer; + +public class EntityFishHook extends Entity +{ + private static final List field_146039_d = Arrays.asList(new WeightedRandomFishable[] {(new WeightedRandomFishable(new ItemStack(Items.leather_boots), 10)).func_150709_a(0.9F), new WeightedRandomFishable(new ItemStack(Items.leather), 10), new WeightedRandomFishable(new ItemStack(Items.bone), 10), new WeightedRandomFishable(new ItemStack(Items.potionitem), 10), new WeightedRandomFishable(new ItemStack(Items.string), 5), (new WeightedRandomFishable(new ItemStack(Items.fishing_rod), 2)).func_150709_a(0.9F), new WeightedRandomFishable(new ItemStack(Items.bowl), 10), new WeightedRandomFishable(new ItemStack(Items.stick), 5), new WeightedRandomFishable(new ItemStack(Items.dye, 10, 0), 1), new WeightedRandomFishable(new ItemStack(Blocks.tripwire_hook), 10), new WeightedRandomFishable(new ItemStack(Items.rotten_flesh), 10)}); + private static final List field_146041_e = Arrays.asList(new WeightedRandomFishable[] {new WeightedRandomFishable(new ItemStack(Blocks.waterlily), 1), new WeightedRandomFishable(new ItemStack(Items.name_tag), 1), new WeightedRandomFishable(new ItemStack(Items.saddle), 1), (new WeightedRandomFishable(new ItemStack(Items.bow), 1)).func_150709_a(0.25F).func_150707_a(), (new WeightedRandomFishable(new ItemStack(Items.fishing_rod), 1)).func_150709_a(0.25F).func_150707_a(), (new WeightedRandomFishable(new ItemStack(Items.book), 1)).func_150707_a()}); + private static final List field_146036_f = Arrays.asList(new WeightedRandomFishable[] {new WeightedRandomFishable(new ItemStack(Items.fish, 1, ItemFishFood.FishType.COD.func_150976_a()), 60), new WeightedRandomFishable(new ItemStack(Items.fish, 1, ItemFishFood.FishType.SALMON.func_150976_a()), 25), new WeightedRandomFishable(new ItemStack(Items.fish, 1, ItemFishFood.FishType.CLOWNFISH.func_150976_a()), 2), new WeightedRandomFishable(new ItemStack(Items.fish, 1, ItemFishFood.FishType.PUFFERFISH.func_150976_a()), 13)}); + private int field_146037_g; + private int field_146048_h; + private int field_146050_i; + private Block field_146046_j; + private boolean field_146051_au; + public int field_146044_a; + public EntityPlayer field_146042_b; + private int field_146049_av; + private int field_146047_aw; + private int field_146045_ax; + private int field_146040_ay; + private int field_146038_az; + private float field_146054_aA; + public Entity field_146043_c; + private int field_146055_aB; + private double field_146056_aC; + private double field_146057_aD; + private double field_146058_aE; + private double field_146059_aF; + private double field_146060_aG; + @SideOnly(Side.CLIENT) + private double field_146061_aH; + @SideOnly(Side.CLIENT) + private double field_146052_aI; + @SideOnly(Side.CLIENT) + private double field_146053_aJ; + private static final String __OBFID = "CL_00001663"; + + public EntityFishHook(World par1World) + { + super(par1World); + this.field_146037_g = -1; + this.field_146048_h = -1; + this.field_146050_i = -1; + this.setSize(0.25F, 0.25F); + this.ignoreFrustumCheck = true; + } + + @SideOnly(Side.CLIENT) + public EntityFishHook(World par1World, double par2, double par4, double par6, EntityPlayer par8EntityPlayer) + { + this(par1World); + this.setPosition(par2, par4, par6); + this.ignoreFrustumCheck = true; + this.field_146042_b = par8EntityPlayer; + par8EntityPlayer.fishEntity = this; + } + + public EntityFishHook(World par1World, EntityPlayer par2EntityPlayer) + { + super(par1World); + this.field_146037_g = -1; + this.field_146048_h = -1; + this.field_146050_i = -1; + this.ignoreFrustumCheck = true; + this.field_146042_b = par2EntityPlayer; + this.field_146042_b.fishEntity = this; + this.setSize(0.25F, 0.25F); + this.setLocationAndAngles(par2EntityPlayer.posX, par2EntityPlayer.posY + 1.62D - (double)par2EntityPlayer.yOffset, par2EntityPlayer.posZ, par2EntityPlayer.rotationYaw, par2EntityPlayer.rotationPitch); + this.posX -= (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F); + this.posY -= 0.10000000149011612D; + this.posZ -= (double)(MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F); + this.setPosition(this.posX, this.posY, this.posZ); + this.yOffset = 0.0F; + float f = 0.4F; + this.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * f); + this.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * f); + this.motionY = (double)(-MathHelper.sin(this.rotationPitch / 180.0F * (float)Math.PI) * f); + this.func_146035_c(this.motionX, this.motionY, this.motionZ, 1.5F, 1.0F); + } + + protected void entityInit() {} + + public void func_146035_c(double p_146035_1_, double p_146035_3_, double p_146035_5_, float p_146035_7_, float p_146035_8_) + { + float f2 = MathHelper.sqrt_double(p_146035_1_ * p_146035_1_ + p_146035_3_ * p_146035_3_ + p_146035_5_ * p_146035_5_); + p_146035_1_ /= (double)f2; + p_146035_3_ /= (double)f2; + p_146035_5_ /= (double)f2; + p_146035_1_ += this.rand.nextGaussian() * 0.007499999832361937D * (double)p_146035_8_; + p_146035_3_ += this.rand.nextGaussian() * 0.007499999832361937D * (double)p_146035_8_; + p_146035_5_ += this.rand.nextGaussian() * 0.007499999832361937D * (double)p_146035_8_; + p_146035_1_ *= (double)p_146035_7_; + p_146035_3_ *= (double)p_146035_7_; + p_146035_5_ *= (double)p_146035_7_; + this.motionX = p_146035_1_; + this.motionY = p_146035_3_; + this.motionZ = p_146035_5_; + float f3 = MathHelper.sqrt_double(p_146035_1_ * p_146035_1_ + p_146035_5_ * p_146035_5_); + this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(p_146035_1_, p_146035_5_) * 180.0D / Math.PI); + this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(p_146035_3_, (double)f3) * 180.0D / Math.PI); + this.field_146049_av = 0; + } + + @SideOnly(Side.CLIENT) + public boolean isInRangeToRenderDist(double par1) + { + double d1 = this.boundingBox.getAverageEdgeLength() * 4.0D; + d1 *= 64.0D; + return par1 < d1 * d1; + } + + @SideOnly(Side.CLIENT) + public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9) + { + this.field_146056_aC = par1; + this.field_146057_aD = par3; + this.field_146058_aE = par5; + this.field_146059_aF = (double)par7; + this.field_146060_aG = (double)par8; + this.field_146055_aB = par9; + this.motionX = this.field_146061_aH; + this.motionY = this.field_146052_aI; + this.motionZ = this.field_146053_aJ; + } + + @SideOnly(Side.CLIENT) + public void setVelocity(double par1, double par3, double par5) + { + this.field_146061_aH = this.motionX = par1; + this.field_146052_aI = this.motionY = par3; + this.field_146053_aJ = this.motionZ = par5; + } + + public void onUpdate() + { + super.onUpdate(); + + if (this.field_146055_aB > 0) + { + double d7 = this.posX + (this.field_146056_aC - this.posX) / (double)this.field_146055_aB; + double d8 = this.posY + (this.field_146057_aD - this.posY) / (double)this.field_146055_aB; + double d9 = this.posZ + (this.field_146058_aE - this.posZ) / (double)this.field_146055_aB; + double d1 = MathHelper.wrapAngleTo180_double(this.field_146059_aF - (double)this.rotationYaw); + this.rotationYaw = (float)((double)this.rotationYaw + d1 / (double)this.field_146055_aB); + this.rotationPitch = (float)((double)this.rotationPitch + (this.field_146060_aG - (double)this.rotationPitch) / (double)this.field_146055_aB); + --this.field_146055_aB; + this.setPosition(d7, d8, d9); + this.setRotation(this.rotationYaw, this.rotationPitch); + } + else + { + if (!this.worldObj.isRemote) + { + ItemStack itemstack = this.field_146042_b.getCurrentEquippedItem(); + + if (this.field_146042_b.isDead || !this.field_146042_b.isEntityAlive() || itemstack == null || itemstack.getItem() != Items.fishing_rod || this.getDistanceSqToEntity(this.field_146042_b) > 1024.0D) + { + this.setDead(); + this.field_146042_b.fishEntity = null; + return; + } + + if (this.field_146043_c != null) + { + if (!this.field_146043_c.isDead) + { + this.posX = this.field_146043_c.posX; + this.posY = this.field_146043_c.boundingBox.minY + (double)this.field_146043_c.height * 0.8D; + this.posZ = this.field_146043_c.posZ; + return; + } + + this.field_146043_c = null; + } + } + + if (this.field_146044_a > 0) + { + --this.field_146044_a; + } + + if (this.field_146051_au) + { + if (this.worldObj.getBlock(this.field_146037_g, this.field_146048_h, this.field_146050_i) == this.field_146046_j) + { + ++this.field_146049_av; + + if (this.field_146049_av == 1200) + { + this.setDead(); + } + + return; + } + + this.field_146051_au = false; + this.motionX *= (double)(this.rand.nextFloat() * 0.2F); + this.motionY *= (double)(this.rand.nextFloat() * 0.2F); + this.motionZ *= (double)(this.rand.nextFloat() * 0.2F); + this.field_146049_av = 0; + this.field_146047_aw = 0; + } + else + { + ++this.field_146047_aw; + } + + Vec3 vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ); + Vec3 vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); + MovingObjectPosition movingobjectposition = this.worldObj.rayTraceBlocks(vec31, vec3); + vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ); + vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); + + if (movingobjectposition != null) + { + vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord); + } + + Entity entity = null; + List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D)); + double d0 = 0.0D; + double d2; + + for (int i = 0; i < list.size(); ++i) + { + Entity entity1 = (Entity)list.get(i); + + if (entity1.canBeCollidedWith() && (entity1 != this.field_146042_b || this.field_146047_aw >= 5)) + { + float f = 0.3F; + AxisAlignedBB axisalignedbb = entity1.boundingBox.expand((double)f, (double)f, (double)f); + MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec31, vec3); + + if (movingobjectposition1 != null) + { + d2 = vec31.distanceTo(movingobjectposition1.hitVec); + + if (d2 < d0 || d0 == 0.0D) + { + entity = entity1; + d0 = d2; + } + } + } + } + + if (entity != null) + { + movingobjectposition = new MovingObjectPosition(entity); + } + + if (movingobjectposition != null) + { + if (movingobjectposition.entityHit != null) + { + if (movingobjectposition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.field_146042_b), 0.0F)) + { + this.field_146043_c = movingobjectposition.entityHit; + } + } + else + { + this.field_146051_au = true; + } + } + + if (!this.field_146051_au) + { + this.moveEntity(this.motionX, this.motionY, this.motionZ); + float f5 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); + this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); + + for (this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f5) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) + { + ; + } + + while (this.rotationPitch - this.prevRotationPitch >= 180.0F) + { + this.prevRotationPitch += 360.0F; + } + + while (this.rotationYaw - this.prevRotationYaw < -180.0F) + { + this.prevRotationYaw -= 360.0F; + } + + while (this.rotationYaw - this.prevRotationYaw >= 180.0F) + { + this.prevRotationYaw += 360.0F; + } + + this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F; + this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F; + float f6 = 0.92F; + + if (this.onGround || this.isCollidedHorizontally) + { + f6 = 0.5F; + } + + byte b0 = 5; + double d10 = 0.0D; + + for (int j = 0; j < b0; ++j) + { + double d3 = this.boundingBox.minY + (this.boundingBox.maxY - this.boundingBox.minY) * (double)(j + 0) / (double)b0 - 0.125D + 0.125D; + double d4 = this.boundingBox.minY + (this.boundingBox.maxY - this.boundingBox.minY) * (double)(j + 1) / (double)b0 - 0.125D + 0.125D; + AxisAlignedBB axisalignedbb1 = AxisAlignedBB.getAABBPool().getAABB(this.boundingBox.minX, d3, this.boundingBox.minZ, this.boundingBox.maxX, d4, this.boundingBox.maxZ); + + if (this.worldObj.isAABBInMaterial(axisalignedbb1, Material.water)) + { + d10 += 1.0D / (double)b0; + } + } + + if (!this.worldObj.isRemote && d10 > 0.0D) + { + WorldServer worldserver = (WorldServer)this.worldObj; + int k = 1; + + if (this.rand.nextFloat() < 0.25F && this.worldObj.canLightningStrikeAt(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY) + 1, MathHelper.floor_double(this.posZ))) + { + k = 2; + } + + if (this.rand.nextFloat() < 0.5F && !this.worldObj.canBlockSeeTheSky(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY) + 1, MathHelper.floor_double(this.posZ))) + { + --k; + } + + if (this.field_146045_ax > 0) + { + --this.field_146045_ax; + + if (this.field_146045_ax <= 0) + { + this.field_146040_ay = 0; + this.field_146038_az = 0; + } + } + else + { + float f1; + float f2; + double d5; + double d6; + float f7; + double d11; + + if (this.field_146038_az > 0) + { + this.field_146038_az -= k; + + if (this.field_146038_az <= 0) + { + this.motionY -= 0.20000000298023224D; + this.playSound("random.splash", 0.25F, 1.0F + (this.rand.nextFloat() - this.rand.nextFloat()) * 0.4F); + f1 = (float)MathHelper.floor_double(this.boundingBox.minY); + worldserver.func_147487_a("bubble", this.posX, (double)(f1 + 1.0F), this.posZ, (int)(1.0F + this.width * 20.0F), (double)this.width, 0.0D, (double)this.width, 0.20000000298023224D); + worldserver.func_147487_a("wake", this.posX, (double)(f1 + 1.0F), this.posZ, (int)(1.0F + this.width * 20.0F), (double)this.width, 0.0D, (double)this.width, 0.20000000298023224D); + this.field_146045_ax = MathHelper.getRandomIntegerInRange(this.rand, 10, 30); + } + else + { + this.field_146054_aA = (float)((double)this.field_146054_aA + this.rand.nextGaussian() * 4.0D); + f1 = this.field_146054_aA * 0.017453292F; + f7 = MathHelper.sin(f1); + f2 = MathHelper.cos(f1); + d11 = this.posX + (double)(f7 * (float)this.field_146038_az * 0.1F); + d5 = (double)((float)MathHelper.floor_double(this.boundingBox.minY) + 1.0F); + d6 = this.posZ + (double)(f2 * (float)this.field_146038_az * 0.1F); + + if (this.rand.nextFloat() < 0.15F) + { + worldserver.func_147487_a("bubble", d11, d5 - 0.10000000149011612D, d6, 1, (double)f7, 0.1D, (double)f2, 0.0D); + } + + float f3 = f7 * 0.04F; + float f4 = f2 * 0.04F; + worldserver.func_147487_a("wake", d11, d5, d6, 0, (double)f4, 0.01D, (double)(-f3), 1.0D); + worldserver.func_147487_a("wake", d11, d5, d6, 0, (double)(-f4), 0.01D, (double)f3, 1.0D); + } + } + else if (this.field_146040_ay > 0) + { + this.field_146040_ay -= k; + f1 = 0.15F; + + if (this.field_146040_ay < 20) + { + f1 = (float)((double)f1 + (double)(20 - this.field_146040_ay) * 0.05D); + } + else if (this.field_146040_ay < 40) + { + f1 = (float)((double)f1 + (double)(40 - this.field_146040_ay) * 0.02D); + } + else if (this.field_146040_ay < 60) + { + f1 = (float)((double)f1 + (double)(60 - this.field_146040_ay) * 0.01D); + } + + if (this.rand.nextFloat() < f1) + { + f7 = MathHelper.randomFloatClamp(this.rand, 0.0F, 360.0F) * 0.017453292F; + f2 = MathHelper.randomFloatClamp(this.rand, 25.0F, 60.0F); + d11 = this.posX + (double)(MathHelper.sin(f7) * f2 * 0.1F); + d5 = (double)((float)MathHelper.floor_double(this.boundingBox.minY) + 1.0F); + d6 = this.posZ + (double)(MathHelper.cos(f7) * f2 * 0.1F); + worldserver.func_147487_a("splash", d11, d5, d6, 2 + this.rand.nextInt(2), 0.10000000149011612D, 0.0D, 0.10000000149011612D, 0.0D); + } + + if (this.field_146040_ay <= 0) + { + this.field_146054_aA = MathHelper.randomFloatClamp(this.rand, 0.0F, 360.0F); + this.field_146038_az = MathHelper.getRandomIntegerInRange(this.rand, 20, 80); + } + } + else + { + this.field_146040_ay = MathHelper.getRandomIntegerInRange(this.rand, 100, 900); + this.field_146040_ay -= EnchantmentHelper.func_151387_h(this.field_146042_b) * 20 * 5; + } + } + + if (this.field_146045_ax > 0) + { + this.motionY -= (double)(this.rand.nextFloat() * this.rand.nextFloat() * this.rand.nextFloat()) * 0.2D; + } + } + + d2 = d10 * 2.0D - 1.0D; + this.motionY += 0.03999999910593033D * d2; + + if (d10 > 0.0D) + { + f6 = (float)((double)f6 * 0.9D); + this.motionY *= 0.8D; + } + + this.motionX *= (double)f6; + this.motionY *= (double)f6; + this.motionZ *= (double)f6; + this.setPosition(this.posX, this.posY, this.posZ); + } + } + } + + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + par1NBTTagCompound.setShort("xTile", (short)this.field_146037_g); + par1NBTTagCompound.setShort("yTile", (short)this.field_146048_h); + par1NBTTagCompound.setShort("zTile", (short)this.field_146050_i); + par1NBTTagCompound.setByte("inTile", (byte)Block.getIdFromBlock(this.field_146046_j)); + par1NBTTagCompound.setByte("shake", (byte)this.field_146044_a); + par1NBTTagCompound.setByte("inGround", (byte)(this.field_146051_au ? 1 : 0)); + } + + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + this.field_146037_g = par1NBTTagCompound.getShort("xTile"); + this.field_146048_h = par1NBTTagCompound.getShort("yTile"); + this.field_146050_i = par1NBTTagCompound.getShort("zTile"); + this.field_146046_j = Block.getBlockById(par1NBTTagCompound.getByte("inTile") & 255); + this.field_146044_a = par1NBTTagCompound.getByte("shake") & 255; + this.field_146051_au = par1NBTTagCompound.getByte("inGround") == 1; + } + + @SideOnly(Side.CLIENT) + public float getShadowSize() + { + return 0.0F; + } + + public int func_146034_e() + { + if (this.worldObj.isRemote) + { + return 0; + } + else + { + byte b0 = 0; + + if (this.field_146043_c != null) + { + double d0 = this.field_146042_b.posX - this.posX; + double d2 = this.field_146042_b.posY - this.posY; + double d4 = this.field_146042_b.posZ - this.posZ; + double d6 = (double)MathHelper.sqrt_double(d0 * d0 + d2 * d2 + d4 * d4); + double d8 = 0.1D; + this.field_146043_c.motionX += d0 * d8; + this.field_146043_c.motionY += d2 * d8 + (double)MathHelper.sqrt_double(d6) * 0.08D; + this.field_146043_c.motionZ += d4 * d8; + b0 = 3; + } + else if (this.field_146045_ax > 0) + { + EntityItem entityitem = new EntityItem(this.worldObj, this.posX, this.posY, this.posZ, this.func_146033_f()); + double d1 = this.field_146042_b.posX - this.posX; + double d3 = this.field_146042_b.posY - this.posY; + double d5 = this.field_146042_b.posZ - this.posZ; + double d7 = (double)MathHelper.sqrt_double(d1 * d1 + d3 * d3 + d5 * d5); + double d9 = 0.1D; + entityitem.motionX = d1 * d9; + entityitem.motionY = d3 * d9 + (double)MathHelper.sqrt_double(d7) * 0.08D; + entityitem.motionZ = d5 * d9; + this.worldObj.spawnEntityInWorld(entityitem); + this.field_146042_b.worldObj.spawnEntityInWorld(new EntityXPOrb(this.field_146042_b.worldObj, this.field_146042_b.posX, this.field_146042_b.posY + 0.5D, this.field_146042_b.posZ + 0.5D, this.rand.nextInt(6) + 1)); + b0 = 1; + } + + if (this.field_146051_au) + { + b0 = 2; + } + + this.setDead(); + this.field_146042_b.fishEntity = null; + return b0; + } + } + + private ItemStack func_146033_f() + { + float f = this.worldObj.rand.nextFloat(); + int i = EnchantmentHelper.func_151386_g(this.field_146042_b); + int j = EnchantmentHelper.func_151387_h(this.field_146042_b); + float f1 = 0.1F - (float)i * 0.025F - (float)j * 0.01F; + float f2 = 0.05F + (float)i * 0.01F - (float)j * 0.01F; + f1 = MathHelper.clamp_float(f1, 0.0F, 1.0F); + f2 = MathHelper.clamp_float(f2, 0.0F, 1.0F); + + if (f < f1) + { + this.field_146042_b.addStat(StatList.field_151183_A, 1); + return ((WeightedRandomFishable)WeightedRandom.getRandomItem(this.rand, field_146039_d)).func_150708_a(this.rand); + } + else + { + f -= f1; + + if (f < f2) + { + this.field_146042_b.addStat(StatList.field_151184_B, 1); + return ((WeightedRandomFishable)WeightedRandom.getRandomItem(this.rand, field_146041_e)).func_150708_a(this.rand); + } + else + { + float f3 = f - f2; + this.field_146042_b.addStat(StatList.fishCaughtStat, 1); + return ((WeightedRandomFishable)WeightedRandom.getRandomItem(this.rand, field_146036_f)).func_150708_a(this.rand); + } + } + } + + public void setDead() + { + super.setDead(); + + if (this.field_146042_b != null) + { + this.field_146042_b.fishEntity = null; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/projectile/EntityLargeFireball.java b/src/main/java/net/minecraft/entity/projectile/EntityLargeFireball.java new file mode 100644 index 0000000..16dce5f --- /dev/null +++ b/src/main/java/net/minecraft/entity/projectile/EntityLargeFireball.java @@ -0,0 +1,62 @@ +package net.minecraft.entity.projectile; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; + +public class EntityLargeFireball extends EntityFireball +{ + public int field_92057_e = 1; + private static final String __OBFID = "CL_00001719"; + + public EntityLargeFireball(World par1World) + { + super(par1World); + } + + @SideOnly(Side.CLIENT) + public EntityLargeFireball(World par1World, double par2, double par4, double par6, double par8, double par10, double par12) + { + super(par1World, par2, par4, par6, par8, par10, par12); + } + + public EntityLargeFireball(World par1World, EntityLivingBase par2EntityLivingBase, double par3, double par5, double par7) + { + super(par1World, par2EntityLivingBase, par3, par5, par7); + } + + protected void onImpact(MovingObjectPosition par1MovingObjectPosition) + { + if (!this.worldObj.isRemote) + { + if (par1MovingObjectPosition.entityHit != null) + { + par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeFireballDamage(this, this.shootingEntity), 6.0F); + } + + this.worldObj.newExplosion((Entity)null, this.posX, this.posY, this.posZ, (float)this.field_92057_e, true, this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing")); + this.setDead(); + } + } + + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeEntityToNBT(par1NBTTagCompound); + par1NBTTagCompound.setInteger("ExplosionPower", this.field_92057_e); + } + + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + super.readEntityFromNBT(par1NBTTagCompound); + + if (par1NBTTagCompound.hasKey("ExplosionPower", 99)) + { + this.field_92057_e = par1NBTTagCompound.getInteger("ExplosionPower"); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/projectile/EntityPotion.java b/src/main/java/net/minecraft/entity/projectile/EntityPotion.java new file mode 100644 index 0000000..bf90871 --- /dev/null +++ b/src/main/java/net/minecraft/entity/projectile/EntityPotion.java @@ -0,0 +1,173 @@ +package net.minecraft.entity.projectile; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Iterator; +import java.util.List; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; + +public class EntityPotion extends EntityThrowable +{ + private ItemStack potionDamage; + private static final String __OBFID = "CL_00001727"; + + public EntityPotion(World par1World) + { + super(par1World); + } + + public EntityPotion(World par1World, EntityLivingBase par2EntityLivingBase, int par3) + { + this(par1World, par2EntityLivingBase, new ItemStack(Items.potionitem, 1, par3)); + } + + public EntityPotion(World par1World, EntityLivingBase par2EntityLivingBase, ItemStack par3ItemStack) + { + super(par1World, par2EntityLivingBase); + this.potionDamage = par3ItemStack; + } + + @SideOnly(Side.CLIENT) + public EntityPotion(World par1World, double par2, double par4, double par6, int par8) + { + this(par1World, par2, par4, par6, new ItemStack(Items.potionitem, 1, par8)); + } + + public EntityPotion(World par1World, double par2, double par4, double par6, ItemStack par8ItemStack) + { + super(par1World, par2, par4, par6); + this.potionDamage = par8ItemStack; + } + + protected float getGravityVelocity() + { + return 0.05F; + } + + protected float func_70182_d() + { + return 0.5F; + } + + protected float func_70183_g() + { + return -20.0F; + } + + public void setPotionDamage(int par1) + { + if (this.potionDamage == null) + { + this.potionDamage = new ItemStack(Items.potionitem, 1, 0); + } + + this.potionDamage.setItemDamage(par1); + } + + public int getPotionDamage() + { + if (this.potionDamage == null) + { + this.potionDamage = new ItemStack(Items.potionitem, 1, 0); + } + + return this.potionDamage.getItemDamage(); + } + + protected void onImpact(MovingObjectPosition par1MovingObjectPosition) + { + if (!this.worldObj.isRemote) + { + List list = Items.potionitem.getEffects(this.potionDamage); + + if (list != null && !list.isEmpty()) + { + AxisAlignedBB axisalignedbb = this.boundingBox.expand(4.0D, 2.0D, 4.0D); + List list1 = this.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb); + + if (list1 != null && !list1.isEmpty()) + { + Iterator iterator = list1.iterator(); + + while (iterator.hasNext()) + { + EntityLivingBase entitylivingbase = (EntityLivingBase)iterator.next(); + double d0 = this.getDistanceSqToEntity(entitylivingbase); + + if (d0 < 16.0D) + { + double d1 = 1.0D - Math.sqrt(d0) / 4.0D; + + if (entitylivingbase == par1MovingObjectPosition.entityHit) + { + d1 = 1.0D; + } + + Iterator iterator1 = list.iterator(); + + while (iterator1.hasNext()) + { + PotionEffect potioneffect = (PotionEffect)iterator1.next(); + int i = potioneffect.getPotionID(); + + if (Potion.potionTypes[i].isInstant()) + { + Potion.potionTypes[i].affectEntity(this.getThrower(), entitylivingbase, potioneffect.getAmplifier(), d1); + } + else + { + int j = (int)(d1 * (double)potioneffect.getDuration() + 0.5D); + + if (j > 20) + { + entitylivingbase.addPotionEffect(new PotionEffect(i, j, potioneffect.getAmplifier())); + } + } + } + } + } + } + } + + this.worldObj.playAuxSFX(2002, (int)Math.round(this.posX), (int)Math.round(this.posY), (int)Math.round(this.posZ), this.getPotionDamage()); + this.setDead(); + } + } + + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + super.readEntityFromNBT(par1NBTTagCompound); + + if (par1NBTTagCompound.hasKey("Potion", 10)) + { + this.potionDamage = ItemStack.loadItemStackFromNBT(par1NBTTagCompound.getCompoundTag("Potion")); + } + else + { + this.setPotionDamage(par1NBTTagCompound.getInteger("potionValue")); + } + + if (this.potionDamage == null) + { + this.setDead(); + } + } + + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeEntityToNBT(par1NBTTagCompound); + + if (this.potionDamage != null) + { + par1NBTTagCompound.setTag("Potion", this.potionDamage.writeToNBT(new NBTTagCompound())); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/projectile/EntitySmallFireball.java b/src/main/java/net/minecraft/entity/projectile/EntitySmallFireball.java new file mode 100644 index 0000000..87d8864 --- /dev/null +++ b/src/main/java/net/minecraft/entity/projectile/EntitySmallFireball.java @@ -0,0 +1,88 @@ +package net.minecraft.entity.projectile; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.init.Blocks; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; + +public class EntitySmallFireball extends EntityFireball +{ + private static final String __OBFID = "CL_00001721"; + + public EntitySmallFireball(World par1World) + { + super(par1World); + this.setSize(0.3125F, 0.3125F); + } + + public EntitySmallFireball(World par1World, EntityLivingBase par2EntityLivingBase, double par3, double par5, double par7) + { + super(par1World, par2EntityLivingBase, par3, par5, par7); + this.setSize(0.3125F, 0.3125F); + } + + public EntitySmallFireball(World par1World, double par2, double par4, double par6, double par8, double par10, double par12) + { + super(par1World, par2, par4, par6, par8, par10, par12); + this.setSize(0.3125F, 0.3125F); + } + + protected void onImpact(MovingObjectPosition par1MovingObjectPosition) + { + if (!this.worldObj.isRemote) + { + if (par1MovingObjectPosition.entityHit != null) + { + if (!par1MovingObjectPosition.entityHit.isImmuneToFire() && par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeFireballDamage(this, this.shootingEntity), 5.0F)) + { + par1MovingObjectPosition.entityHit.setFire(5); + } + } + else + { + int i = par1MovingObjectPosition.blockX; + int j = par1MovingObjectPosition.blockY; + int k = par1MovingObjectPosition.blockZ; + + switch (par1MovingObjectPosition.sideHit) + { + case 0: + --j; + break; + case 1: + ++j; + break; + case 2: + --k; + break; + case 3: + ++k; + break; + case 4: + --i; + break; + case 5: + ++i; + } + + if (this.worldObj.isAirBlock(i, j, k)) + { + this.worldObj.setBlock(i, j, k, Blocks.fire); + } + } + + this.setDead(); + } + } + + public boolean canBeCollidedWith() + { + return false; + } + + public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) + { + return false; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/projectile/EntitySnowball.java b/src/main/java/net/minecraft/entity/projectile/EntitySnowball.java new file mode 100644 index 0000000..8664d83 --- /dev/null +++ b/src/main/java/net/minecraft/entity/projectile/EntitySnowball.java @@ -0,0 +1,52 @@ +package net.minecraft.entity.projectile; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.monster.EntityBlaze; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; + +public class EntitySnowball extends EntityThrowable +{ + private static final String __OBFID = "CL_00001722"; + + public EntitySnowball(World par1World) + { + super(par1World); + } + + public EntitySnowball(World par1World, EntityLivingBase par2EntityLivingBase) + { + super(par1World, par2EntityLivingBase); + } + + public EntitySnowball(World par1World, double par2, double par4, double par6) + { + super(par1World, par2, par4, par6); + } + + protected void onImpact(MovingObjectPosition par1MovingObjectPosition) + { + if (par1MovingObjectPosition.entityHit != null) + { + byte b0 = 0; + + if (par1MovingObjectPosition.entityHit instanceof EntityBlaze) + { + b0 = 3; + } + + par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (float)b0); + } + + for (int i = 0; i < 8; ++i) + { + this.worldObj.spawnParticle("snowballpoof", this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D); + } + + if (!this.worldObj.isRemote) + { + this.setDead(); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/projectile/EntityThrowable.java b/src/main/java/net/minecraft/entity/projectile/EntityThrowable.java new file mode 100644 index 0000000..34ef579 --- /dev/null +++ b/src/main/java/net/minecraft/entity/projectile/EntityThrowable.java @@ -0,0 +1,323 @@ +package net.minecraft.entity.projectile; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IProjectile; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; + +public abstract class EntityThrowable extends Entity implements IProjectile +{ + private int field_145788_c = -1; + private int field_145786_d = -1; + private int field_145787_e = -1; + private Block field_145785_f; + protected boolean inGround; + public int throwableShake; + private EntityLivingBase thrower; + private String throwerName; + private int ticksInGround; + private int ticksInAir; + private static final String __OBFID = "CL_00001723"; + + public EntityThrowable(World par1World) + { + super(par1World); + this.setSize(0.25F, 0.25F); + } + + protected void entityInit() {} + + @SideOnly(Side.CLIENT) + public boolean isInRangeToRenderDist(double par1) + { + double d1 = this.boundingBox.getAverageEdgeLength() * 4.0D; + d1 *= 64.0D; + return par1 < d1 * d1; + } + + public EntityThrowable(World par1World, EntityLivingBase par2EntityLivingBase) + { + super(par1World); + this.thrower = par2EntityLivingBase; + this.setSize(0.25F, 0.25F); + this.setLocationAndAngles(par2EntityLivingBase.posX, par2EntityLivingBase.posY + (double)par2EntityLivingBase.getEyeHeight(), par2EntityLivingBase.posZ, par2EntityLivingBase.rotationYaw, par2EntityLivingBase.rotationPitch); + this.posX -= (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F); + this.posY -= 0.10000000149011612D; + this.posZ -= (double)(MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F); + this.setPosition(this.posX, this.posY, this.posZ); + this.yOffset = 0.0F; + float f = 0.4F; + this.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * f); + this.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * f); + this.motionY = (double)(-MathHelper.sin((this.rotationPitch + this.func_70183_g()) / 180.0F * (float)Math.PI) * f); + this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, this.func_70182_d(), 1.0F); + } + + public EntityThrowable(World par1World, double par2, double par4, double par6) + { + super(par1World); + this.ticksInGround = 0; + this.setSize(0.25F, 0.25F); + this.setPosition(par2, par4, par6); + this.yOffset = 0.0F; + } + + protected float func_70182_d() + { + return 1.5F; + } + + protected float func_70183_g() + { + return 0.0F; + } + + public void setThrowableHeading(double par1, double par3, double par5, float par7, float par8) + { + float f2 = MathHelper.sqrt_double(par1 * par1 + par3 * par3 + par5 * par5); + par1 /= (double)f2; + par3 /= (double)f2; + par5 /= (double)f2; + par1 += this.rand.nextGaussian() * 0.007499999832361937D * (double)par8; + par3 += this.rand.nextGaussian() * 0.007499999832361937D * (double)par8; + par5 += this.rand.nextGaussian() * 0.007499999832361937D * (double)par8; + par1 *= (double)par7; + par3 *= (double)par7; + par5 *= (double)par7; + this.motionX = par1; + this.motionY = par3; + this.motionZ = par5; + float f3 = MathHelper.sqrt_double(par1 * par1 + par5 * par5); + this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(par1, par5) * 180.0D / Math.PI); + this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(par3, (double)f3) * 180.0D / Math.PI); + this.ticksInGround = 0; + } + + @SideOnly(Side.CLIENT) + public void setVelocity(double par1, double par3, double par5) + { + this.motionX = par1; + this.motionY = par3; + this.motionZ = par5; + + if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) + { + float f = MathHelper.sqrt_double(par1 * par1 + par5 * par5); + this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(par1, par5) * 180.0D / Math.PI); + this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(par3, (double)f) * 180.0D / Math.PI); + } + } + + public void onUpdate() + { + this.lastTickPosX = this.posX; + this.lastTickPosY = this.posY; + this.lastTickPosZ = this.posZ; + super.onUpdate(); + + if (this.throwableShake > 0) + { + --this.throwableShake; + } + + if (this.inGround) + { + if (this.worldObj.getBlock(this.field_145788_c, this.field_145786_d, this.field_145787_e) == this.field_145785_f) + { + ++this.ticksInGround; + + if (this.ticksInGround == 1200) + { + this.setDead(); + } + + return; + } + + this.inGround = false; + this.motionX *= (double)(this.rand.nextFloat() * 0.2F); + this.motionY *= (double)(this.rand.nextFloat() * 0.2F); + this.motionZ *= (double)(this.rand.nextFloat() * 0.2F); + this.ticksInGround = 0; + this.ticksInAir = 0; + } + else + { + ++this.ticksInAir; + } + + Vec3 vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ); + Vec3 vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); + MovingObjectPosition movingobjectposition = this.worldObj.rayTraceBlocks(vec3, vec31); + vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ); + vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); + + if (movingobjectposition != null) + { + vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord); + } + + if (!this.worldObj.isRemote) + { + Entity entity = null; + List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D)); + double d0 = 0.0D; + EntityLivingBase entitylivingbase = this.getThrower(); + + for (int j = 0; j < list.size(); ++j) + { + Entity entity1 = (Entity)list.get(j); + + if (entity1.canBeCollidedWith() && (entity1 != entitylivingbase || this.ticksInAir >= 5)) + { + float f = 0.3F; + AxisAlignedBB axisalignedbb = entity1.boundingBox.expand((double)f, (double)f, (double)f); + MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3, vec31); + + if (movingobjectposition1 != null) + { + double d1 = vec3.distanceTo(movingobjectposition1.hitVec); + + if (d1 < d0 || d0 == 0.0D) + { + entity = entity1; + d0 = d1; + } + } + } + } + + if (entity != null) + { + movingobjectposition = new MovingObjectPosition(entity); + } + } + + if (movingobjectposition != null) + { + if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && this.worldObj.getBlock(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ) == Blocks.portal) + { + this.setInPortal(); + } + else + { + this.onImpact(movingobjectposition); + } + } + + this.posX += this.motionX; + this.posY += this.motionY; + this.posZ += this.motionZ; + float f1 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); + this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); + + for (this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f1) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) + { + ; + } + + while (this.rotationPitch - this.prevRotationPitch >= 180.0F) + { + this.prevRotationPitch += 360.0F; + } + + while (this.rotationYaw - this.prevRotationYaw < -180.0F) + { + this.prevRotationYaw -= 360.0F; + } + + while (this.rotationYaw - this.prevRotationYaw >= 180.0F) + { + this.prevRotationYaw += 360.0F; + } + + this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F; + this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F; + float f2 = 0.99F; + float f3 = this.getGravityVelocity(); + + if (this.isInWater()) + { + for (int i = 0; i < 4; ++i) + { + float f4 = 0.25F; + this.worldObj.spawnParticle("bubble", this.posX - this.motionX * (double)f4, this.posY - this.motionY * (double)f4, this.posZ - this.motionZ * (double)f4, this.motionX, this.motionY, this.motionZ); + } + + f2 = 0.8F; + } + + this.motionX *= (double)f2; + this.motionY *= (double)f2; + this.motionZ *= (double)f2; + this.motionY -= (double)f3; + this.setPosition(this.posX, this.posY, this.posZ); + } + + protected float getGravityVelocity() + { + return 0.03F; + } + + protected abstract void onImpact(MovingObjectPosition var1); + + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + par1NBTTagCompound.setShort("xTile", (short)this.field_145788_c); + par1NBTTagCompound.setShort("yTile", (short)this.field_145786_d); + par1NBTTagCompound.setShort("zTile", (short)this.field_145787_e); + par1NBTTagCompound.setByte("inTile", (byte)Block.getIdFromBlock(this.field_145785_f)); + par1NBTTagCompound.setByte("shake", (byte)this.throwableShake); + par1NBTTagCompound.setByte("inGround", (byte)(this.inGround ? 1 : 0)); + + if ((this.throwerName == null || this.throwerName.length() == 0) && this.thrower != null && this.thrower instanceof EntityPlayer) + { + this.throwerName = this.thrower.getCommandSenderName(); + } + + par1NBTTagCompound.setString("ownerName", this.throwerName == null ? "" : this.throwerName); + } + + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + this.field_145788_c = par1NBTTagCompound.getShort("xTile"); + this.field_145786_d = par1NBTTagCompound.getShort("yTile"); + this.field_145787_e = par1NBTTagCompound.getShort("zTile"); + this.field_145785_f = Block.getBlockById(par1NBTTagCompound.getByte("inTile") & 255); + this.throwableShake = par1NBTTagCompound.getByte("shake") & 255; + this.inGround = par1NBTTagCompound.getByte("inGround") == 1; + this.throwerName = par1NBTTagCompound.getString("ownerName"); + + if (this.throwerName != null && this.throwerName.length() == 0) + { + this.throwerName = null; + } + } + + @SideOnly(Side.CLIENT) + public float getShadowSize() + { + return 0.0F; + } + + public EntityLivingBase getThrower() + { + if (this.thrower == null && this.throwerName != null && this.throwerName.length() > 0) + { + this.thrower = this.worldObj.getPlayerEntityByName(this.throwerName); + } + + return this.thrower; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/entity/projectile/EntityWitherSkull.java b/src/main/java/net/minecraft/entity/projectile/EntityWitherSkull.java new file mode 100644 index 0000000..dfa14b5 --- /dev/null +++ b/src/main/java/net/minecraft/entity/projectile/EntityWitherSkull.java @@ -0,0 +1,128 @@ +package net.minecraft.entity.projectile; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.init.Blocks; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.EnumDifficulty; +import net.minecraft.world.Explosion; +import net.minecraft.world.World; + +public class EntityWitherSkull extends EntityFireball +{ + private static final String __OBFID = "CL_00001728"; + + public EntityWitherSkull(World par1World) + { + super(par1World); + this.setSize(0.3125F, 0.3125F); + } + + public EntityWitherSkull(World par1World, EntityLivingBase par2EntityLivingBase, double par3, double par5, double par7) + { + super(par1World, par2EntityLivingBase, par3, par5, par7); + this.setSize(0.3125F, 0.3125F); + } + + protected float getMotionFactor() + { + return this.isInvulnerable() ? 0.73F : super.getMotionFactor(); + } + + @SideOnly(Side.CLIENT) + public EntityWitherSkull(World par1World, double par2, double par4, double par6, double par8, double par10, double par12) + { + super(par1World, par2, par4, par6, par8, par10, par12); + this.setSize(0.3125F, 0.3125F); + } + + public boolean isBurning() + { + return false; + } + + public float func_145772_a(Explosion p_145772_1_, World p_145772_2_, int p_145772_3_, int p_145772_4_, int p_145772_5_, Block p_145772_6_) + { + float f = super.func_145772_a(p_145772_1_, p_145772_2_, p_145772_3_, p_145772_4_, p_145772_5_, p_145772_6_); + + if (this.isInvulnerable() && p_145772_6_ != Blocks.bedrock && p_145772_6_ != Blocks.end_portal && p_145772_6_ != Blocks.end_portal_frame && p_145772_6_ != Blocks.command_block) + { + f = Math.min(0.8F, f); + } + + return f; + } + + protected void onImpact(MovingObjectPosition par1MovingObjectPosition) + { + if (!this.worldObj.isRemote) + { + if (par1MovingObjectPosition.entityHit != null) + { + if (this.shootingEntity != null) + { + if (par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeMobDamage(this.shootingEntity), 8.0F) && !par1MovingObjectPosition.entityHit.isEntityAlive()) + { + this.shootingEntity.heal(5.0F); + } + } + else + { + par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.magic, 5.0F); + } + + if (par1MovingObjectPosition.entityHit instanceof EntityLivingBase) + { + byte b0 = 0; + + if (this.worldObj.difficultySetting == EnumDifficulty.NORMAL) + { + b0 = 10; + } + else if (this.worldObj.difficultySetting == EnumDifficulty.HARD) + { + b0 = 40; + } + + if (b0 > 0) + { + ((EntityLivingBase)par1MovingObjectPosition.entityHit).addPotionEffect(new PotionEffect(Potion.wither.id, 20 * b0, 1)); + } + } + } + + this.worldObj.newExplosion(this, this.posX, this.posY, this.posZ, 1.0F, false, this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing")); + this.setDead(); + } + } + + public boolean canBeCollidedWith() + { + return false; + } + + public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) + { + return false; + } + + protected void entityInit() + { + this.dataWatcher.addObject(10, Byte.valueOf((byte)0)); + } + + public boolean isInvulnerable() + { + return this.dataWatcher.getWatchableObjectByte(10) == 1; + } + + public void setInvulnerable(boolean par1) + { + this.dataWatcher.updateObject(10, Byte.valueOf((byte)(par1 ? 1 : 0))); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/event/ClickEvent.java b/src/main/java/net/minecraft/event/ClickEvent.java new file mode 100644 index 0000000..a40500f --- /dev/null +++ b/src/main/java/net/minecraft/event/ClickEvent.java @@ -0,0 +1,122 @@ +package net.minecraft.event; + +import com.google.common.collect.Maps; +import java.util.Map; + +public class ClickEvent +{ + private final ClickEvent.Action action; + private final String value; + private static final String __OBFID = "CL_00001260"; + + public ClickEvent(ClickEvent.Action p_i45156_1_, String p_i45156_2_) + { + this.action = p_i45156_1_; + this.value = p_i45156_2_; + } + + public ClickEvent.Action getAction() + { + return this.action; + } + + public String getValue() + { + return this.value; + } + + public boolean equals(Object par1Obj) + { + if (this == par1Obj) + { + return true; + } + else if (par1Obj != null && this.getClass() == par1Obj.getClass()) + { + ClickEvent clickevent = (ClickEvent)par1Obj; + + if (this.action != clickevent.action) + { + return false; + } + else + { + if (this.value != null) + { + if (!this.value.equals(clickevent.value)) + { + return false; + } + } + else if (clickevent.value != null) + { + return false; + } + + return true; + } + } + else + { + return false; + } + } + + public String toString() + { + return "ClickEvent{action=" + this.action + ", value=\'" + this.value + '\'' + '}'; + } + + public int hashCode() + { + int i = this.action.hashCode(); + i = 31 * i + (this.value != null ? this.value.hashCode() : 0); + return i; + } + + public static enum Action + { + OPEN_URL("open_url", true), + OPEN_FILE("open_file", false), + RUN_COMMAND("run_command", true), + SUGGEST_COMMAND("suggest_command", true); + private static final Map nameMapping = Maps.newHashMap(); + private final boolean allowedInChat; + private final String canonicalName; + + private static final String __OBFID = "CL_00001261"; + + private Action(String p_i45155_3_, boolean p_i45155_4_) + { + this.canonicalName = p_i45155_3_; + this.allowedInChat = p_i45155_4_; + } + + public boolean shouldAllowInChat() + { + return this.allowedInChat; + } + + public String getCanonicalName() + { + return this.canonicalName; + } + + public static ClickEvent.Action getValueByCanonicalName(String p_150672_0_) + { + return (ClickEvent.Action)nameMapping.get(p_150672_0_); + } + + static + { + ClickEvent.Action[] var0 = values(); + int var1 = var0.length; + + for (int var2 = 0; var2 < var1; ++var2) + { + ClickEvent.Action var3 = var0[var2]; + nameMapping.put(var3.getCanonicalName(), var3); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/event/HoverEvent.java b/src/main/java/net/minecraft/event/HoverEvent.java new file mode 100644 index 0000000..a276aca --- /dev/null +++ b/src/main/java/net/minecraft/event/HoverEvent.java @@ -0,0 +1,122 @@ +package net.minecraft.event; + +import com.google.common.collect.Maps; +import java.util.Map; +import net.minecraft.util.IChatComponent; + +public class HoverEvent +{ + private final HoverEvent.Action action; + private final IChatComponent value; + private static final String __OBFID = "CL_00001264"; + + public HoverEvent(HoverEvent.Action p_i45158_1_, IChatComponent p_i45158_2_) + { + this.action = p_i45158_1_; + this.value = p_i45158_2_; + } + + public HoverEvent.Action getAction() + { + return this.action; + } + + public IChatComponent getValue() + { + return this.value; + } + + public boolean equals(Object par1Obj) + { + if (this == par1Obj) + { + return true; + } + else if (par1Obj != null && this.getClass() == par1Obj.getClass()) + { + HoverEvent hoverevent = (HoverEvent)par1Obj; + + if (this.action != hoverevent.action) + { + return false; + } + else + { + if (this.value != null) + { + if (!this.value.equals(hoverevent.value)) + { + return false; + } + } + else if (hoverevent.value != null) + { + return false; + } + + return true; + } + } + else + { + return false; + } + } + + public String toString() + { + return "HoverEvent{action=" + this.action + ", value=\'" + this.value + '\'' + '}'; + } + + public int hashCode() + { + int i = this.action.hashCode(); + i = 31 * i + (this.value != null ? this.value.hashCode() : 0); + return i; + } + + public static enum Action + { + SHOW_TEXT("show_text", true), + SHOW_ACHIEVEMENT("show_achievement", true), + SHOW_ITEM("show_item", true); + private static final Map nameMapping = Maps.newHashMap(); + private final boolean allowedInChat; + private final String canonicalName; + + private static final String __OBFID = "CL_00001265"; + + private Action(String p_i45157_3_, boolean p_i45157_4_) + { + this.canonicalName = p_i45157_3_; + this.allowedInChat = p_i45157_4_; + } + + public boolean shouldAllowInChat() + { + return this.allowedInChat; + } + + public String getCanonicalName() + { + return this.canonicalName; + } + + public static HoverEvent.Action getValueByCanonicalName(String p_150684_0_) + { + return (HoverEvent.Action)nameMapping.get(p_150684_0_); + } + + static + { + HoverEvent.Action[] var0 = values(); + int var1 = var0.length; + + for (int var2 = 0; var2 < var1; ++var2) + { + HoverEvent.Action var3 = var0[var2]; + nameMapping.put(var3.getCanonicalName(), var3); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/init/Blocks.java b/src/main/java/net/minecraft/init/Blocks.java new file mode 100644 index 0000000..06bb889 --- /dev/null +++ b/src/main/java/net/minecraft/init/Blocks.java @@ -0,0 +1,205 @@ +package net.minecraft.init; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockBeacon; +import net.minecraft.block.BlockBush; +import net.minecraft.block.BlockCauldron; +import net.minecraft.block.BlockChest; +import net.minecraft.block.BlockDaylightDetector; +import net.minecraft.block.BlockDeadBush; +import net.minecraft.block.BlockDoublePlant; +import net.minecraft.block.BlockFire; +import net.minecraft.block.BlockFlower; +import net.minecraft.block.BlockGrass; +import net.minecraft.block.BlockHopper; +import net.minecraft.block.BlockLeaves; +import net.minecraft.block.BlockLiquid; +import net.minecraft.block.BlockMycelium; +import net.minecraft.block.BlockPistonBase; +import net.minecraft.block.BlockPistonExtension; +import net.minecraft.block.BlockPistonMoving; +import net.minecraft.block.BlockPortal; +import net.minecraft.block.BlockRedstoneComparator; +import net.minecraft.block.BlockRedstoneRepeater; +import net.minecraft.block.BlockRedstoneWire; +import net.minecraft.block.BlockSlab; +import net.minecraft.block.BlockStainedGlass; +import net.minecraft.block.BlockStainedGlassPane; +import net.minecraft.block.BlockTallGrass; +import net.minecraft.block.BlockTripWireHook; + +public class Blocks +{ + public static final Block air = (Block)Block.blockRegistry.getObject("air"); + public static final Block stone = (Block)Block.blockRegistry.getObject("stone"); + public static final BlockGrass grass = (BlockGrass)Block.blockRegistry.getObject("grass"); + public static final Block dirt = (Block)Block.blockRegistry.getObject("dirt"); + public static final Block cobblestone = (Block)Block.blockRegistry.getObject("cobblestone"); + public static final Block planks = (Block)Block.blockRegistry.getObject("planks"); + public static final Block sapling = (Block)Block.blockRegistry.getObject("sapling"); + public static final Block bedrock = (Block)Block.blockRegistry.getObject("bedrock"); + public static final BlockLiquid flowing_water = (BlockLiquid)Block.blockRegistry.getObject("flowing_water"); + public static final Block water = (Block)Block.blockRegistry.getObject("water"); + public static final BlockLiquid flowing_lava = (BlockLiquid)Block.blockRegistry.getObject("flowing_lava"); + public static final Block lava = (Block)Block.blockRegistry.getObject("lava"); + public static final Block sand = (Block)Block.blockRegistry.getObject("sand"); + public static final Block gravel = (Block)Block.blockRegistry.getObject("gravel"); + public static final Block gold_ore = (Block)Block.blockRegistry.getObject("gold_ore"); + public static final Block iron_ore = (Block)Block.blockRegistry.getObject("iron_ore"); + public static final Block coal_ore = (Block)Block.blockRegistry.getObject("coal_ore"); + public static final Block log = (Block)Block.blockRegistry.getObject("log"); + public static final Block log2 = (Block)Block.blockRegistry.getObject("log2"); + public static final BlockLeaves leaves = (BlockLeaves)Block.blockRegistry.getObject("leaves"); + public static final BlockLeaves leaves2 = (BlockLeaves)Block.blockRegistry.getObject("leaves2"); + public static final Block sponge = (Block)Block.blockRegistry.getObject("sponge"); + public static final Block glass = (Block)Block.blockRegistry.getObject("glass"); + public static final Block lapis_ore = (Block)Block.blockRegistry.getObject("lapis_ore"); + public static final Block lapis_block = (Block)Block.blockRegistry.getObject("lapis_block"); + public static final Block dispenser = (Block)Block.blockRegistry.getObject("dispenser"); + public static final Block sandstone = (Block)Block.blockRegistry.getObject("sandstone"); + public static final Block noteblock = (Block)Block.blockRegistry.getObject("noteblock"); + public static final Block bed = (Block)Block.blockRegistry.getObject("bed"); + public static final Block golden_rail = (Block)Block.blockRegistry.getObject("golden_rail"); + public static final Block detector_rail = (Block)Block.blockRegistry.getObject("detector_rail"); + public static final BlockPistonBase sticky_piston = (BlockPistonBase)Block.blockRegistry.getObject("sticky_piston"); + public static final Block web = (Block)Block.blockRegistry.getObject("web"); + public static final BlockTallGrass tallgrass = (BlockTallGrass)Block.blockRegistry.getObject("tallgrass"); + public static final BlockDeadBush deadbush = (BlockDeadBush)Block.blockRegistry.getObject("deadbush"); + public static final BlockPistonBase piston = (BlockPistonBase)Block.blockRegistry.getObject("piston"); + public static final BlockPistonExtension piston_head = (BlockPistonExtension)Block.blockRegistry.getObject("piston_head"); + public static final Block wool = (Block)Block.blockRegistry.getObject("wool"); + public static final BlockPistonMoving piston_extension = (BlockPistonMoving)Block.blockRegistry.getObject("piston_extension"); + public static final BlockFlower yellow_flower = (BlockFlower)Block.blockRegistry.getObject("yellow_flower"); + public static final BlockFlower red_flower = (BlockFlower)Block.blockRegistry.getObject("red_flower"); + public static final BlockBush brown_mushroom = (BlockBush)Block.blockRegistry.getObject("brown_mushroom"); + public static final BlockBush red_mushroom = (BlockBush)Block.blockRegistry.getObject("red_mushroom"); + public static final Block gold_block = (Block)Block.blockRegistry.getObject("gold_block"); + public static final Block iron_block = (Block)Block.blockRegistry.getObject("iron_block"); + public static final BlockSlab double_stone_slab = (BlockSlab)Block.blockRegistry.getObject("double_stone_slab"); + public static final BlockSlab stone_slab = (BlockSlab)Block.blockRegistry.getObject("stone_slab"); + public static final Block brick_block = (Block)Block.blockRegistry.getObject("brick_block"); + public static final Block tnt = (Block)Block.blockRegistry.getObject("tnt"); + public static final Block bookshelf = (Block)Block.blockRegistry.getObject("bookshelf"); + public static final Block mossy_cobblestone = (Block)Block.blockRegistry.getObject("mossy_cobblestone"); + public static final Block obsidian = (Block)Block.blockRegistry.getObject("obsidian"); + public static final Block torch = (Block)Block.blockRegistry.getObject("torch"); + public static final BlockFire fire = (BlockFire)Block.blockRegistry.getObject("fire"); + public static final Block mob_spawner = (Block)Block.blockRegistry.getObject("mob_spawner"); + public static final Block oak_stairs = (Block)Block.blockRegistry.getObject("oak_stairs"); + public static final BlockChest chest = (BlockChest)Block.blockRegistry.getObject("chest"); + public static final BlockRedstoneWire redstone_wire = (BlockRedstoneWire)Block.blockRegistry.getObject("redstone_wire"); + public static final Block diamond_ore = (Block)Block.blockRegistry.getObject("diamond_ore"); + public static final Block diamond_block = (Block)Block.blockRegistry.getObject("diamond_block"); + public static final Block crafting_table = (Block)Block.blockRegistry.getObject("crafting_table"); + public static final Block wheat = (Block)Block.blockRegistry.getObject("wheat"); + public static final Block farmland = (Block)Block.blockRegistry.getObject("farmland"); + public static final Block furnace = (Block)Block.blockRegistry.getObject("furnace"); + public static final Block lit_furnace = (Block)Block.blockRegistry.getObject("lit_furnace"); + public static final Block standing_sign = (Block)Block.blockRegistry.getObject("standing_sign"); + public static final Block wooden_door = (Block)Block.blockRegistry.getObject("wooden_door"); + public static final Block ladder = (Block)Block.blockRegistry.getObject("ladder"); + public static final Block rail = (Block)Block.blockRegistry.getObject("rail"); + public static final Block stone_stairs = (Block)Block.blockRegistry.getObject("stone_stairs"); + public static final Block wall_sign = (Block)Block.blockRegistry.getObject("wall_sign"); + public static final Block lever = (Block)Block.blockRegistry.getObject("lever"); + public static final Block stone_pressure_plate = (Block)Block.blockRegistry.getObject("stone_pressure_plate"); + public static final Block iron_door = (Block)Block.blockRegistry.getObject("iron_door"); + public static final Block wooden_pressure_plate = (Block)Block.blockRegistry.getObject("wooden_pressure_plate"); + public static final Block redstone_ore = (Block)Block.blockRegistry.getObject("redstone_ore"); + public static final Block lit_redstone_ore = (Block)Block.blockRegistry.getObject("lit_redstone_ore"); + public static final Block unlit_redstone_torch = (Block)Block.blockRegistry.getObject("unlit_redstone_torch"); + public static final Block redstone_torch = (Block)Block.blockRegistry.getObject("redstone_torch"); + public static final Block stone_button = (Block)Block.blockRegistry.getObject("stone_button"); + public static final Block snow_layer = (Block)Block.blockRegistry.getObject("snow_layer"); + public static final Block ice = (Block)Block.blockRegistry.getObject("ice"); + public static final Block snow = (Block)Block.blockRegistry.getObject("snow"); + public static final Block cactus = (Block)Block.blockRegistry.getObject("cactus"); + public static final Block clay = (Block)Block.blockRegistry.getObject("clay"); + public static final Block reeds = (Block)Block.blockRegistry.getObject("reeds"); + public static final Block jukebox = (Block)Block.blockRegistry.getObject("jukebox"); + public static final Block fence = (Block)Block.blockRegistry.getObject("fence"); + public static final Block pumpkin = (Block)Block.blockRegistry.getObject("pumpkin"); + public static final Block netherrack = (Block)Block.blockRegistry.getObject("netherrack"); + public static final Block soul_sand = (Block)Block.blockRegistry.getObject("soul_sand"); + public static final Block glowstone = (Block)Block.blockRegistry.getObject("glowstone"); + public static final BlockPortal portal = (BlockPortal)Block.blockRegistry.getObject("portal"); + public static final Block lit_pumpkin = (Block)Block.blockRegistry.getObject("lit_pumpkin"); + public static final Block cake = (Block)Block.blockRegistry.getObject("cake"); + public static final BlockRedstoneRepeater unpowered_repeater = (BlockRedstoneRepeater)Block.blockRegistry.getObject("unpowered_repeater"); + public static final BlockRedstoneRepeater powered_repeater = (BlockRedstoneRepeater)Block.blockRegistry.getObject("powered_repeater"); + public static final Block trapdoor = (Block)Block.blockRegistry.getObject("trapdoor"); + public static final Block monster_egg = (Block)Block.blockRegistry.getObject("monster_egg"); + public static final Block stonebrick = (Block)Block.blockRegistry.getObject("stonebrick"); + public static final Block brown_mushroom_block = (Block)Block.blockRegistry.getObject("brown_mushroom_block"); + public static final Block red_mushroom_block = (Block)Block.blockRegistry.getObject("red_mushroom_block"); + public static final Block iron_bars = (Block)Block.blockRegistry.getObject("iron_bars"); + public static final Block glass_pane = (Block)Block.blockRegistry.getObject("glass_pane"); + public static final Block melon_block = (Block)Block.blockRegistry.getObject("melon_block"); + public static final Block pumpkin_stem = (Block)Block.blockRegistry.getObject("pumpkin_stem"); + public static final Block melon_stem = (Block)Block.blockRegistry.getObject("melon_stem"); + public static final Block vine = (Block)Block.blockRegistry.getObject("vine"); + public static final Block fence_gate = (Block)Block.blockRegistry.getObject("fence_gate"); + public static final Block brick_stairs = (Block)Block.blockRegistry.getObject("brick_stairs"); + public static final Block stone_brick_stairs = (Block)Block.blockRegistry.getObject("stone_brick_stairs"); + public static final BlockMycelium mycelium = (BlockMycelium)Block.blockRegistry.getObject("mycelium"); + public static final Block waterlily = (Block)Block.blockRegistry.getObject("waterlily"); + public static final Block nether_brick = (Block)Block.blockRegistry.getObject("nether_brick"); + public static final Block nether_brick_fence = (Block)Block.blockRegistry.getObject("nether_brick_fence"); + public static final Block nether_brick_stairs = (Block)Block.blockRegistry.getObject("nether_brick_stairs"); + public static final Block nether_wart = (Block)Block.blockRegistry.getObject("nether_wart"); + public static final Block enchanting_table = (Block)Block.blockRegistry.getObject("enchanting_table"); + public static final Block brewing_stand = (Block)Block.blockRegistry.getObject("brewing_stand"); + public static final BlockCauldron cauldron = (BlockCauldron)Block.blockRegistry.getObject("cauldron"); + public static final Block end_portal = (Block)Block.blockRegistry.getObject("end_portal"); + public static final Block end_portal_frame = (Block)Block.blockRegistry.getObject("end_portal_frame"); + public static final Block end_stone = (Block)Block.blockRegistry.getObject("end_stone"); + public static final Block dragon_egg = (Block)Block.blockRegistry.getObject("dragon_egg"); + public static final Block redstone_lamp = (Block)Block.blockRegistry.getObject("redstone_lamp"); + public static final Block lit_redstone_lamp = (Block)Block.blockRegistry.getObject("lit_redstone_lamp"); + public static final BlockSlab double_wooden_slab = (BlockSlab)Block.blockRegistry.getObject("double_wooden_slab"); + public static final BlockSlab wooden_slab = (BlockSlab)Block.blockRegistry.getObject("wooden_slab"); + public static final Block cocoa = (Block)Block.blockRegistry.getObject("cocoa"); + public static final Block sandstone_stairs = (Block)Block.blockRegistry.getObject("sandstone_stairs"); + public static final Block emerald_ore = (Block)Block.blockRegistry.getObject("emerald_ore"); + public static final Block ender_chest = (Block)Block.blockRegistry.getObject("ender_chest"); + public static final BlockTripWireHook tripwire_hook = (BlockTripWireHook)Block.blockRegistry.getObject("tripwire_hook"); + public static final Block tripwire = (Block)Block.blockRegistry.getObject("tripwire"); + public static final Block emerald_block = (Block)Block.blockRegistry.getObject("emerald_block"); + public static final Block spruce_stairs = (Block)Block.blockRegistry.getObject("spruce_stairs"); + public static final Block birch_stairs = (Block)Block.blockRegistry.getObject("birch_stairs"); + public static final Block jungle_stairs = (Block)Block.blockRegistry.getObject("jungle_stairs"); + public static final Block command_block = (Block)Block.blockRegistry.getObject("command_block"); + public static final BlockBeacon beacon = (BlockBeacon)Block.blockRegistry.getObject("beacon"); + public static final Block cobblestone_wall = (Block)Block.blockRegistry.getObject("cobblestone_wall"); + public static final Block flower_pot = (Block)Block.blockRegistry.getObject("flower_pot"); + public static final Block carrots = (Block)Block.blockRegistry.getObject("carrots"); + public static final Block potatoes = (Block)Block.blockRegistry.getObject("potatoes"); + public static final Block wooden_button = (Block)Block.blockRegistry.getObject("wooden_button"); + public static final Block skull = (Block)Block.blockRegistry.getObject("skull"); + public static final Block anvil = (Block)Block.blockRegistry.getObject("anvil"); + public static final Block trapped_chest = (Block)Block.blockRegistry.getObject("trapped_chest"); + public static final Block light_weighted_pressure_plate = (Block)Block.blockRegistry.getObject("light_weighted_pressure_plate"); + public static final Block heavy_weighted_pressure_plate = (Block)Block.blockRegistry.getObject("heavy_weighted_pressure_plate"); + public static final BlockRedstoneComparator unpowered_comparator = (BlockRedstoneComparator)Block.blockRegistry.getObject("unpowered_comparator"); + public static final BlockRedstoneComparator powered_comparator = (BlockRedstoneComparator)Block.blockRegistry.getObject("powered_comparator"); + public static final BlockDaylightDetector daylight_detector = (BlockDaylightDetector)Block.blockRegistry.getObject("daylight_detector"); + public static final Block redstone_block = (Block)Block.blockRegistry.getObject("redstone_block"); + public static final Block quartz_ore = (Block)Block.blockRegistry.getObject("quartz_ore"); + public static final BlockHopper hopper = (BlockHopper)Block.blockRegistry.getObject("hopper"); + public static final Block quartz_block = (Block)Block.blockRegistry.getObject("quartz_block"); + public static final Block quartz_stairs = (Block)Block.blockRegistry.getObject("quartz_stairs"); + public static final Block activator_rail = (Block)Block.blockRegistry.getObject("activator_rail"); + public static final Block dropper = (Block)Block.blockRegistry.getObject("dropper"); + public static final Block stained_hardened_clay = (Block)Block.blockRegistry.getObject("stained_hardened_clay"); + public static final Block hay_block = (Block)Block.blockRegistry.getObject("hay_block"); + public static final Block carpet = (Block)Block.blockRegistry.getObject("carpet"); + public static final Block hardened_clay = (Block)Block.blockRegistry.getObject("hardened_clay"); + public static final Block coal_block = (Block)Block.blockRegistry.getObject("coal_block"); + public static final Block packed_ice = (Block)Block.blockRegistry.getObject("packed_ice"); + public static final Block acacia_stairs = (Block)Block.blockRegistry.getObject("acacia_stairs"); + public static final Block dark_oak_stairs = (Block)Block.blockRegistry.getObject("dark_oak_stairs"); + public static final BlockDoublePlant double_plant = (BlockDoublePlant)Block.blockRegistry.getObject("double_plant"); + public static final BlockStainedGlass stained_glass = (BlockStainedGlass)Block.blockRegistry.getObject("stained_glass"); + public static final BlockStainedGlassPane stained_glass_pane = (BlockStainedGlassPane)Block.blockRegistry.getObject("stained_glass_pane"); + private static final String __OBFID = "CL_00000204"; +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/init/Bootstrap.java b/src/main/java/net/minecraft/init/Bootstrap.java new file mode 100644 index 0000000..4b0769c --- /dev/null +++ b/src/main/java/net/minecraft/init/Bootstrap.java @@ -0,0 +1,404 @@ +package net.minecraft.init; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.block.BlockDispenser; +import net.minecraft.block.BlockFire; +import net.minecraft.block.material.Material; +import net.minecraft.dispenser.BehaviorDefaultDispenseItem; +import net.minecraft.dispenser.BehaviorProjectileDispense; +import net.minecraft.dispenser.IBehaviorDispenseItem; +import net.minecraft.dispenser.IBlockSource; +import net.minecraft.dispenser.IPosition; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IProjectile; +import net.minecraft.entity.item.EntityBoat; +import net.minecraft.entity.item.EntityExpBottle; +import net.minecraft.entity.item.EntityFireworkRocket; +import net.minecraft.entity.item.EntityTNTPrimed; +import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.entity.projectile.EntityEgg; +import net.minecraft.entity.projectile.EntityPotion; +import net.minecraft.entity.projectile.EntitySmallFireball; +import net.minecraft.entity.projectile.EntitySnowball; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBucket; +import net.minecraft.item.ItemDye; +import net.minecraft.item.ItemMonsterPlacer; +import net.minecraft.item.ItemPotion; +import net.minecraft.item.ItemStack; +import net.minecraft.stats.StatList; +import net.minecraft.tileentity.TileEntityDispenser; +import net.minecraft.util.EnumFacing; +import net.minecraft.world.World; + +public class Bootstrap +{ + private static boolean field_151355_a = false; + private static final String __OBFID = "CL_00001397"; + + static void func_151353_a() + { + BlockDispenser.dispenseBehaviorRegistry.putObject(Items.arrow, new BehaviorProjectileDispense() + { + private static final String __OBFID = "CL_00001398"; + protected IProjectile getProjectileEntity(World par1World, IPosition par2IPosition) + { + EntityArrow entityarrow = new EntityArrow(par1World, par2IPosition.getX(), par2IPosition.getY(), par2IPosition.getZ()); + entityarrow.canBePickedUp = 1; + return entityarrow; + } + }); + BlockDispenser.dispenseBehaviorRegistry.putObject(Items.egg, new BehaviorProjectileDispense() + { + private static final String __OBFID = "CL_00001404"; + protected IProjectile getProjectileEntity(World par1World, IPosition par2IPosition) + { + return new EntityEgg(par1World, par2IPosition.getX(), par2IPosition.getY(), par2IPosition.getZ()); + } + }); + BlockDispenser.dispenseBehaviorRegistry.putObject(Items.snowball, new BehaviorProjectileDispense() + { + private static final String __OBFID = "CL_00001405"; + protected IProjectile getProjectileEntity(World par1World, IPosition par2IPosition) + { + return new EntitySnowball(par1World, par2IPosition.getX(), par2IPosition.getY(), par2IPosition.getZ()); + } + }); + BlockDispenser.dispenseBehaviorRegistry.putObject(Items.experience_bottle, new BehaviorProjectileDispense() + { + private static final String __OBFID = "CL_00001406"; + protected IProjectile getProjectileEntity(World par1World, IPosition par2IPosition) + { + return new EntityExpBottle(par1World, par2IPosition.getX(), par2IPosition.getY(), par2IPosition.getZ()); + } + protected float func_82498_a() + { + return super.func_82498_a() * 0.5F; + } + protected float func_82500_b() + { + return super.func_82500_b() * 1.25F; + } + }); + BlockDispenser.dispenseBehaviorRegistry.putObject(Items.potionitem, new IBehaviorDispenseItem() + { + private final BehaviorDefaultDispenseItem field_150843_b = new BehaviorDefaultDispenseItem(); + private static final String __OBFID = "CL_00001407"; + public ItemStack dispense(IBlockSource par1IBlockSource, final ItemStack par2ItemStack) + { + return ItemPotion.isSplash(par2ItemStack.getItemDamage()) ? (new BehaviorProjectileDispense() + { + private static final String __OBFID = "CL_00001408"; + protected IProjectile getProjectileEntity(World par1World, IPosition par2IPosition) + { + return new EntityPotion(par1World, par2IPosition.getX(), par2IPosition.getY(), par2IPosition.getZ(), par2ItemStack.copy()); + } + protected float func_82498_a() + { + return super.func_82498_a() * 0.5F; + } + protected float func_82500_b() + { + return super.func_82500_b() * 1.25F; + } + }).dispense(par1IBlockSource, par2ItemStack): this.field_150843_b.dispense(par1IBlockSource, par2ItemStack); + } + }); + BlockDispenser.dispenseBehaviorRegistry.putObject(Items.spawn_egg, new BehaviorDefaultDispenseItem() + { + private static final String __OBFID = "CL_00001410"; + public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) + { + EnumFacing enumfacing = BlockDispenser.func_149937_b(par1IBlockSource.getBlockMetadata()); + double d0 = par1IBlockSource.getX() + (double)enumfacing.getFrontOffsetX(); + double d1 = (double)((float)par1IBlockSource.getYInt() + 0.2F); + double d2 = par1IBlockSource.getZ() + (double)enumfacing.getFrontOffsetZ(); + Entity entity = ItemMonsterPlacer.spawnCreature(par1IBlockSource.getWorld(), par2ItemStack.getItemDamage(), d0, d1, d2); + + if (entity instanceof EntityLivingBase && par2ItemStack.hasDisplayName()) + { + ((EntityLiving)entity).setCustomNameTag(par2ItemStack.getDisplayName()); + } + + par2ItemStack.splitStack(1); + return par2ItemStack; + } + }); + BlockDispenser.dispenseBehaviorRegistry.putObject(Items.fireworks, new BehaviorDefaultDispenseItem() + { + private static final String __OBFID = "CL_00001411"; + public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) + { + EnumFacing enumfacing = BlockDispenser.func_149937_b(par1IBlockSource.getBlockMetadata()); + double d0 = par1IBlockSource.getX() + (double)enumfacing.getFrontOffsetX(); + double d1 = (double)((float)par1IBlockSource.getYInt() + 0.2F); + double d2 = par1IBlockSource.getZ() + (double)enumfacing.getFrontOffsetZ(); + EntityFireworkRocket entityfireworkrocket = new EntityFireworkRocket(par1IBlockSource.getWorld(), d0, d1, d2, par2ItemStack); + par1IBlockSource.getWorld().spawnEntityInWorld(entityfireworkrocket); + par2ItemStack.splitStack(1); + return par2ItemStack; + } + protected void playDispenseSound(IBlockSource par1IBlockSource) + { + par1IBlockSource.getWorld().playAuxSFX(1002, par1IBlockSource.getXInt(), par1IBlockSource.getYInt(), par1IBlockSource.getZInt(), 0); + } + }); + BlockDispenser.dispenseBehaviorRegistry.putObject(Items.fire_charge, new BehaviorDefaultDispenseItem() + { + private static final String __OBFID = "CL_00001412"; + public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) + { + EnumFacing enumfacing = BlockDispenser.func_149937_b(par1IBlockSource.getBlockMetadata()); + IPosition iposition = BlockDispenser.func_149939_a(par1IBlockSource); + double d0 = iposition.getX() + (double)((float)enumfacing.getFrontOffsetX() * 0.3F); + double d1 = iposition.getY() + (double)((float)enumfacing.getFrontOffsetX() * 0.3F); + double d2 = iposition.getZ() + (double)((float)enumfacing.getFrontOffsetZ() * 0.3F); + World world = par1IBlockSource.getWorld(); + Random random = world.rand; + double d3 = random.nextGaussian() * 0.05D + (double)enumfacing.getFrontOffsetX(); + double d4 = random.nextGaussian() * 0.05D + (double)enumfacing.getFrontOffsetY(); + double d5 = random.nextGaussian() * 0.05D + (double)enumfacing.getFrontOffsetZ(); + world.spawnEntityInWorld(new EntitySmallFireball(world, d0, d1, d2, d3, d4, d5)); + par2ItemStack.splitStack(1); + return par2ItemStack; + } + protected void playDispenseSound(IBlockSource par1IBlockSource) + { + par1IBlockSource.getWorld().playAuxSFX(1009, par1IBlockSource.getXInt(), par1IBlockSource.getYInt(), par1IBlockSource.getZInt(), 0); + } + }); + BlockDispenser.dispenseBehaviorRegistry.putObject(Items.boat, new BehaviorDefaultDispenseItem() + { + private final BehaviorDefaultDispenseItem field_150842_b = new BehaviorDefaultDispenseItem(); + private static final String __OBFID = "CL_00001413"; + public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) + { + EnumFacing enumfacing = BlockDispenser.func_149937_b(par1IBlockSource.getBlockMetadata()); + World world = par1IBlockSource.getWorld(); + double d0 = par1IBlockSource.getX() + (double)((float)enumfacing.getFrontOffsetX() * 1.125F); + double d1 = par1IBlockSource.getY() + (double)((float)enumfacing.getFrontOffsetY() * 1.125F); + double d2 = par1IBlockSource.getZ() + (double)((float)enumfacing.getFrontOffsetZ() * 1.125F); + int i = par1IBlockSource.getXInt() + enumfacing.getFrontOffsetX(); + int j = par1IBlockSource.getYInt() + enumfacing.getFrontOffsetY(); + int k = par1IBlockSource.getZInt() + enumfacing.getFrontOffsetZ(); + Material material = world.getBlock(i, j, k).getMaterial(); + double d3; + + if (Material.water.equals(material)) + { + d3 = 1.0D; + } + else + { + if (!Material.air.equals(material) || !Material.water.equals(world.getBlock(i, j - 1, k).getMaterial())) + { + return this.field_150842_b.dispense(par1IBlockSource, par2ItemStack); + } + + d3 = 0.0D; + } + + EntityBoat entityboat = new EntityBoat(world, d0, d1 + d3, d2); + world.spawnEntityInWorld(entityboat); + par2ItemStack.splitStack(1); + return par2ItemStack; + } + protected void playDispenseSound(IBlockSource par1IBlockSource) + { + par1IBlockSource.getWorld().playAuxSFX(1000, par1IBlockSource.getXInt(), par1IBlockSource.getYInt(), par1IBlockSource.getZInt(), 0); + } + }); + BehaviorDefaultDispenseItem behaviordefaultdispenseitem = new BehaviorDefaultDispenseItem() + { + private final BehaviorDefaultDispenseItem field_150841_b = new BehaviorDefaultDispenseItem(); + private static final String __OBFID = "CL_00001399"; + public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) + { + ItemBucket itembucket = (ItemBucket)par2ItemStack.getItem(); + int i = par1IBlockSource.getXInt(); + int j = par1IBlockSource.getYInt(); + int k = par1IBlockSource.getZInt(); + EnumFacing enumfacing = BlockDispenser.func_149937_b(par1IBlockSource.getBlockMetadata()); + + if (itembucket.tryPlaceContainedLiquid(par1IBlockSource.getWorld(), i + enumfacing.getFrontOffsetX(), j + enumfacing.getFrontOffsetY(), k + enumfacing.getFrontOffsetZ())) + { + par2ItemStack.func_150996_a(Items.bucket); + par2ItemStack.stackSize = 1; + return par2ItemStack; + } + else + { + return this.field_150841_b.dispense(par1IBlockSource, par2ItemStack); + } + } + }; + BlockDispenser.dispenseBehaviorRegistry.putObject(Items.lava_bucket, behaviordefaultdispenseitem); + BlockDispenser.dispenseBehaviorRegistry.putObject(Items.water_bucket, behaviordefaultdispenseitem); + BlockDispenser.dispenseBehaviorRegistry.putObject(Items.bucket, new BehaviorDefaultDispenseItem() + { + private final BehaviorDefaultDispenseItem field_150840_b = new BehaviorDefaultDispenseItem(); + private static final String __OBFID = "CL_00001400"; + public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) + { + EnumFacing enumfacing = BlockDispenser.func_149937_b(par1IBlockSource.getBlockMetadata()); + World world = par1IBlockSource.getWorld(); + int i = par1IBlockSource.getXInt() + enumfacing.getFrontOffsetX(); + int j = par1IBlockSource.getYInt() + enumfacing.getFrontOffsetY(); + int k = par1IBlockSource.getZInt() + enumfacing.getFrontOffsetZ(); + Material material = world.getBlock(i, j, k).getMaterial(); + int l = world.getBlockMetadata(i, j, k); + Item item; + + if (Material.water.equals(material) && l == 0) + { + item = Items.water_bucket; + } + else + { + if (!Material.lava.equals(material) || l != 0) + { + return super.dispenseStack(par1IBlockSource, par2ItemStack); + } + + item = Items.lava_bucket; + } + + world.setBlockToAir(i, j, k); + + if (--par2ItemStack.stackSize == 0) + { + par2ItemStack.func_150996_a(item); + par2ItemStack.stackSize = 1; + } + else if (((TileEntityDispenser)par1IBlockSource.getBlockTileEntity()).func_146019_a(new ItemStack(item)) < 0) + { + this.field_150840_b.dispense(par1IBlockSource, new ItemStack(item)); + } + + return par2ItemStack; + } + }); + BlockDispenser.dispenseBehaviorRegistry.putObject(Items.flint_and_steel, new BehaviorDefaultDispenseItem() + { + private boolean field_150839_b = true; + private static final String __OBFID = "CL_00001401"; + protected ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) + { + EnumFacing enumfacing = BlockDispenser.func_149937_b(par1IBlockSource.getBlockMetadata()); + World world = par1IBlockSource.getWorld(); + int i = par1IBlockSource.getXInt() + enumfacing.getFrontOffsetX(); + int j = par1IBlockSource.getYInt() + enumfacing.getFrontOffsetY(); + int k = par1IBlockSource.getZInt() + enumfacing.getFrontOffsetZ(); + + if (world.isAirBlock(i, j, k)) + { + world.setBlock(i, j, k, Blocks.fire); + + if (par2ItemStack.attemptDamageItem(1, world.rand)) + { + par2ItemStack.stackSize = 0; + } + } + else if (world.getBlock(i, j, k) == Blocks.tnt) + { + Blocks.tnt.onBlockDestroyedByPlayer(world, i, j, k, 1); + world.setBlockToAir(i, j, k); + } + else + { + this.field_150839_b = false; + } + + return par2ItemStack; + } + protected void playDispenseSound(IBlockSource par1IBlockSource) + { + if (this.field_150839_b) + { + par1IBlockSource.getWorld().playAuxSFX(1000, par1IBlockSource.getXInt(), par1IBlockSource.getYInt(), par1IBlockSource.getZInt(), 0); + } + else + { + par1IBlockSource.getWorld().playAuxSFX(1001, par1IBlockSource.getXInt(), par1IBlockSource.getYInt(), par1IBlockSource.getZInt(), 0); + } + } + }); + BlockDispenser.dispenseBehaviorRegistry.putObject(Items.dye, new BehaviorDefaultDispenseItem() + { + private boolean field_150838_b = true; + private static final String __OBFID = "CL_00001402"; + protected ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) + { + if (par2ItemStack.getItemDamage() == 15) + { + EnumFacing enumfacing = BlockDispenser.func_149937_b(par1IBlockSource.getBlockMetadata()); + World world = par1IBlockSource.getWorld(); + int i = par1IBlockSource.getXInt() + enumfacing.getFrontOffsetX(); + int j = par1IBlockSource.getYInt() + enumfacing.getFrontOffsetY(); + int k = par1IBlockSource.getZInt() + enumfacing.getFrontOffsetZ(); + + if (ItemDye.func_150919_a(par2ItemStack, world, i, j, k)) + { + if (!world.isRemote) + { + world.playAuxSFX(2005, i, j, k, 0); + } + } + else + { + this.field_150838_b = false; + } + + return par2ItemStack; + } + else + { + return super.dispenseStack(par1IBlockSource, par2ItemStack); + } + } + protected void playDispenseSound(IBlockSource par1IBlockSource) + { + if (this.field_150838_b) + { + par1IBlockSource.getWorld().playAuxSFX(1000, par1IBlockSource.getXInt(), par1IBlockSource.getYInt(), par1IBlockSource.getZInt(), 0); + } + else + { + par1IBlockSource.getWorld().playAuxSFX(1001, par1IBlockSource.getXInt(), par1IBlockSource.getYInt(), par1IBlockSource.getZInt(), 0); + } + } + }); + BlockDispenser.dispenseBehaviorRegistry.putObject(Item.getItemFromBlock(Blocks.tnt), new BehaviorDefaultDispenseItem() + { + private static final String __OBFID = "CL_00001403"; + protected ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) + { + EnumFacing enumfacing = BlockDispenser.func_149937_b(par1IBlockSource.getBlockMetadata()); + World world = par1IBlockSource.getWorld(); + int i = par1IBlockSource.getXInt() + enumfacing.getFrontOffsetX(); + int j = par1IBlockSource.getYInt() + enumfacing.getFrontOffsetY(); + int k = par1IBlockSource.getZInt() + enumfacing.getFrontOffsetZ(); + EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double)((float)i + 0.5F), (double)((float)j + 0.5F), (double)((float)k + 0.5F), (EntityLivingBase)null); + world.spawnEntityInWorld(entitytntprimed); + --par2ItemStack.stackSize; + return par2ItemStack; + } + }); + } + + public static void func_151354_b() + { + if (!field_151355_a) + { + field_151355_a = true; + Block.registerBlocks(); + BlockFire.func_149843_e(); + Item.registerItems(); + StatList.func_151178_a(); + func_151353_a(); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/init/Items.java b/src/main/java/net/minecraft/init/Items.java new file mode 100644 index 0000000..e06f5f5 --- /dev/null +++ b/src/main/java/net/minecraft/init/Items.java @@ -0,0 +1,187 @@ +package net.minecraft.init; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemArmor; +import net.minecraft.item.ItemBow; +import net.minecraft.item.ItemEmptyMap; +import net.minecraft.item.ItemEnchantedBook; +import net.minecraft.item.ItemFishingRod; +import net.minecraft.item.ItemMap; +import net.minecraft.item.ItemPotion; +import net.minecraft.item.ItemShears; + +public class Items +{ + public static final Item iron_shovel = (Item)Item.itemRegistry.getObject("iron_shovel"); + public static final Item iron_pickaxe = (Item)Item.itemRegistry.getObject("iron_pickaxe"); + public static final Item iron_axe = (Item)Item.itemRegistry.getObject("iron_axe"); + public static final Item flint_and_steel = (Item)Item.itemRegistry.getObject("flint_and_steel"); + public static final Item apple = (Item)Item.itemRegistry.getObject("apple"); + public static final ItemBow bow = (ItemBow)Item.itemRegistry.getObject("bow"); + public static final Item arrow = (Item)Item.itemRegistry.getObject("arrow"); + public static final Item coal = (Item)Item.itemRegistry.getObject("coal"); + public static final Item diamond = (Item)Item.itemRegistry.getObject("diamond"); + public static final Item iron_ingot = (Item)Item.itemRegistry.getObject("iron_ingot"); + public static final Item gold_ingot = (Item)Item.itemRegistry.getObject("gold_ingot"); + public static final Item iron_sword = (Item)Item.itemRegistry.getObject("iron_sword"); + public static final Item wooden_sword = (Item)Item.itemRegistry.getObject("wooden_sword"); + public static final Item wooden_shovel = (Item)Item.itemRegistry.getObject("wooden_shovel"); + public static final Item wooden_pickaxe = (Item)Item.itemRegistry.getObject("wooden_pickaxe"); + public static final Item wooden_axe = (Item)Item.itemRegistry.getObject("wooden_axe"); + public static final Item stone_sword = (Item)Item.itemRegistry.getObject("stone_sword"); + public static final Item stone_shovel = (Item)Item.itemRegistry.getObject("stone_shovel"); + public static final Item stone_pickaxe = (Item)Item.itemRegistry.getObject("stone_pickaxe"); + public static final Item stone_axe = (Item)Item.itemRegistry.getObject("stone_axe"); + public static final Item diamond_sword = (Item)Item.itemRegistry.getObject("diamond_sword"); + public static final Item diamond_shovel = (Item)Item.itemRegistry.getObject("diamond_shovel"); + public static final Item diamond_pickaxe = (Item)Item.itemRegistry.getObject("diamond_pickaxe"); + public static final Item diamond_axe = (Item)Item.itemRegistry.getObject("diamond_axe"); + public static final Item stick = (Item)Item.itemRegistry.getObject("stick"); + public static final Item bowl = (Item)Item.itemRegistry.getObject("bowl"); + public static final Item mushroom_stew = (Item)Item.itemRegistry.getObject("mushroom_stew"); + public static final Item golden_sword = (Item)Item.itemRegistry.getObject("golden_sword"); + public static final Item golden_shovel = (Item)Item.itemRegistry.getObject("golden_shovel"); + public static final Item golden_pickaxe = (Item)Item.itemRegistry.getObject("golden_pickaxe"); + public static final Item golden_axe = (Item)Item.itemRegistry.getObject("golden_axe"); + public static final Item string = (Item)Item.itemRegistry.getObject("string"); + public static final Item feather = (Item)Item.itemRegistry.getObject("feather"); + public static final Item gunpowder = (Item)Item.itemRegistry.getObject("gunpowder"); + public static final Item wooden_hoe = (Item)Item.itemRegistry.getObject("wooden_hoe"); + public static final Item stone_hoe = (Item)Item.itemRegistry.getObject("stone_hoe"); + public static final Item iron_hoe = (Item)Item.itemRegistry.getObject("iron_hoe"); + public static final Item diamond_hoe = (Item)Item.itemRegistry.getObject("diamond_hoe"); + public static final Item golden_hoe = (Item)Item.itemRegistry.getObject("golden_hoe"); + public static final Item wheat_seeds = (Item)Item.itemRegistry.getObject("wheat_seeds"); + public static final Item wheat = (Item)Item.itemRegistry.getObject("wheat"); + public static final Item bread = (Item)Item.itemRegistry.getObject("bread"); + public static final ItemArmor leather_helmet = (ItemArmor)Item.itemRegistry.getObject("leather_helmet"); + public static final ItemArmor leather_chestplate = (ItemArmor)Item.itemRegistry.getObject("leather_chestplate"); + public static final ItemArmor leather_leggings = (ItemArmor)Item.itemRegistry.getObject("leather_leggings"); + public static final ItemArmor leather_boots = (ItemArmor)Item.itemRegistry.getObject("leather_boots"); + public static final ItemArmor chainmail_helmet = (ItemArmor)Item.itemRegistry.getObject("chainmail_helmet"); + public static final ItemArmor chainmail_chestplate = (ItemArmor)Item.itemRegistry.getObject("chainmail_chestplate"); + public static final ItemArmor chainmail_leggings = (ItemArmor)Item.itemRegistry.getObject("chainmail_leggings"); + public static final ItemArmor chainmail_boots = (ItemArmor)Item.itemRegistry.getObject("chainmail_boots"); + public static final ItemArmor iron_helmet = (ItemArmor)Item.itemRegistry.getObject("iron_helmet"); + public static final ItemArmor iron_chestplate = (ItemArmor)Item.itemRegistry.getObject("iron_chestplate"); + public static final ItemArmor iron_leggings = (ItemArmor)Item.itemRegistry.getObject("iron_leggings"); + public static final ItemArmor iron_boots = (ItemArmor)Item.itemRegistry.getObject("iron_boots"); + public static final ItemArmor diamond_helmet = (ItemArmor)Item.itemRegistry.getObject("diamond_helmet"); + public static final ItemArmor diamond_chestplate = (ItemArmor)Item.itemRegistry.getObject("diamond_chestplate"); + public static final ItemArmor diamond_leggings = (ItemArmor)Item.itemRegistry.getObject("diamond_leggings"); + public static final ItemArmor diamond_boots = (ItemArmor)Item.itemRegistry.getObject("diamond_boots"); + public static final ItemArmor golden_helmet = (ItemArmor)Item.itemRegistry.getObject("golden_helmet"); + public static final ItemArmor golden_chestplate = (ItemArmor)Item.itemRegistry.getObject("golden_chestplate"); + public static final ItemArmor golden_leggings = (ItemArmor)Item.itemRegistry.getObject("golden_leggings"); + public static final ItemArmor golden_boots = (ItemArmor)Item.itemRegistry.getObject("golden_boots"); + public static final Item flint = (Item)Item.itemRegistry.getObject("flint"); + public static final Item porkchop = (Item)Item.itemRegistry.getObject("porkchop"); + public static final Item cooked_porkchop = (Item)Item.itemRegistry.getObject("cooked_porkchop"); + public static final Item painting = (Item)Item.itemRegistry.getObject("painting"); + public static final Item golden_apple = (Item)Item.itemRegistry.getObject("golden_apple"); + public static final Item sign = (Item)Item.itemRegistry.getObject("sign"); + public static final Item wooden_door = (Item)Item.itemRegistry.getObject("wooden_door"); + public static final Item bucket = (Item)Item.itemRegistry.getObject("bucket"); + public static final Item water_bucket = (Item)Item.itemRegistry.getObject("water_bucket"); + public static final Item lava_bucket = (Item)Item.itemRegistry.getObject("lava_bucket"); + public static final Item minecart = (Item)Item.itemRegistry.getObject("minecart"); + public static final Item saddle = (Item)Item.itemRegistry.getObject("saddle"); + public static final Item iron_door = (Item)Item.itemRegistry.getObject("iron_door"); + public static final Item redstone = (Item)Item.itemRegistry.getObject("redstone"); + public static final Item snowball = (Item)Item.itemRegistry.getObject("snowball"); + public static final Item boat = (Item)Item.itemRegistry.getObject("boat"); + public static final Item leather = (Item)Item.itemRegistry.getObject("leather"); + public static final Item milk_bucket = (Item)Item.itemRegistry.getObject("milk_bucket"); + public static final Item brick = (Item)Item.itemRegistry.getObject("brick"); + public static final Item clay_ball = (Item)Item.itemRegistry.getObject("clay_ball"); + public static final Item reeds = (Item)Item.itemRegistry.getObject("reeds"); + public static final Item paper = (Item)Item.itemRegistry.getObject("paper"); + public static final Item book = (Item)Item.itemRegistry.getObject("book"); + public static final Item slime_ball = (Item)Item.itemRegistry.getObject("slime_ball"); + public static final Item chest_minecart = (Item)Item.itemRegistry.getObject("chest_minecart"); + public static final Item furnace_minecart = (Item)Item.itemRegistry.getObject("furnace_minecart"); + public static final Item egg = (Item)Item.itemRegistry.getObject("egg"); + public static final Item compass = (Item)Item.itemRegistry.getObject("compass"); + public static final ItemFishingRod fishing_rod = (ItemFishingRod)Item.itemRegistry.getObject("fishing_rod"); + public static final Item clock = (Item)Item.itemRegistry.getObject("clock"); + public static final Item glowstone_dust = (Item)Item.itemRegistry.getObject("glowstone_dust"); + public static final Item fish = (Item)Item.itemRegistry.getObject("fish"); + public static final Item cooked_fished = (Item)Item.itemRegistry.getObject("cooked_fished"); + public static final Item dye = (Item)Item.itemRegistry.getObject("dye"); + public static final Item bone = (Item)Item.itemRegistry.getObject("bone"); + public static final Item sugar = (Item)Item.itemRegistry.getObject("sugar"); + public static final Item cake = (Item)Item.itemRegistry.getObject("cake"); + public static final Item bed = (Item)Item.itemRegistry.getObject("bed"); + public static final Item repeater = (Item)Item.itemRegistry.getObject("repeater"); + public static final Item cookie = (Item)Item.itemRegistry.getObject("cookie"); + public static final ItemMap filled_map = (ItemMap)Item.itemRegistry.getObject("filled_map"); + public static final ItemShears shears = (ItemShears)Item.itemRegistry.getObject("shears"); + public static final Item melon = (Item)Item.itemRegistry.getObject("melon"); + public static final Item pumpkin_seeds = (Item)Item.itemRegistry.getObject("pumpkin_seeds"); + public static final Item melon_seeds = (Item)Item.itemRegistry.getObject("melon_seeds"); + public static final Item beef = (Item)Item.itemRegistry.getObject("beef"); + public static final Item cooked_beef = (Item)Item.itemRegistry.getObject("cooked_beef"); + public static final Item chicken = (Item)Item.itemRegistry.getObject("chicken"); + public static final Item cooked_chicken = (Item)Item.itemRegistry.getObject("cooked_chicken"); + public static final Item rotten_flesh = (Item)Item.itemRegistry.getObject("rotten_flesh"); + public static final Item ender_pearl = (Item)Item.itemRegistry.getObject("ender_pearl"); + public static final Item blaze_rod = (Item)Item.itemRegistry.getObject("blaze_rod"); + public static final Item ghast_tear = (Item)Item.itemRegistry.getObject("ghast_tear"); + public static final Item gold_nugget = (Item)Item.itemRegistry.getObject("gold_nugget"); + public static final Item nether_wart = (Item)Item.itemRegistry.getObject("nether_wart"); + public static final ItemPotion potionitem = (ItemPotion)Item.itemRegistry.getObject("potion"); + public static final Item glass_bottle = (Item)Item.itemRegistry.getObject("glass_bottle"); + public static final Item spider_eye = (Item)Item.itemRegistry.getObject("spider_eye"); + public static final Item fermented_spider_eye = (Item)Item.itemRegistry.getObject("fermented_spider_eye"); + public static final Item blaze_powder = (Item)Item.itemRegistry.getObject("blaze_powder"); + public static final Item magma_cream = (Item)Item.itemRegistry.getObject("magma_cream"); + public static final Item brewing_stand = (Item)Item.itemRegistry.getObject("brewing_stand"); + public static final Item cauldron = (Item)Item.itemRegistry.getObject("cauldron"); + public static final Item ender_eye = (Item)Item.itemRegistry.getObject("ender_eye"); + public static final Item speckled_melon = (Item)Item.itemRegistry.getObject("speckled_melon"); + public static final Item spawn_egg = (Item)Item.itemRegistry.getObject("spawn_egg"); + public static final Item experience_bottle = (Item)Item.itemRegistry.getObject("experience_bottle"); + public static final Item fire_charge = (Item)Item.itemRegistry.getObject("fire_charge"); + public static final Item writable_book = (Item)Item.itemRegistry.getObject("writable_book"); + public static final Item written_book = (Item)Item.itemRegistry.getObject("written_book"); + public static final Item emerald = (Item)Item.itemRegistry.getObject("emerald"); + public static final Item item_frame = (Item)Item.itemRegistry.getObject("item_frame"); + public static final Item flower_pot = (Item)Item.itemRegistry.getObject("flower_pot"); + public static final Item carrot = (Item)Item.itemRegistry.getObject("carrot"); + public static final Item potato = (Item)Item.itemRegistry.getObject("potato"); + public static final Item baked_potato = (Item)Item.itemRegistry.getObject("baked_potato"); + public static final Item poisonous_potato = (Item)Item.itemRegistry.getObject("poisonous_potato"); + public static final ItemEmptyMap map = (ItemEmptyMap)Item.itemRegistry.getObject("map"); + public static final Item golden_carrot = (Item)Item.itemRegistry.getObject("golden_carrot"); + public static final Item skull = (Item)Item.itemRegistry.getObject("skull"); + public static final Item carrot_on_a_stick = (Item)Item.itemRegistry.getObject("carrot_on_a_stick"); + public static final Item nether_star = (Item)Item.itemRegistry.getObject("nether_star"); + public static final Item pumpkin_pie = (Item)Item.itemRegistry.getObject("pumpkin_pie"); + public static final Item fireworks = (Item)Item.itemRegistry.getObject("fireworks"); + public static final Item firework_charge = (Item)Item.itemRegistry.getObject("firework_charge"); + public static final ItemEnchantedBook enchanted_book = (ItemEnchantedBook)Item.itemRegistry.getObject("enchanted_book"); + public static final Item comparator = (Item)Item.itemRegistry.getObject("comparator"); + public static final Item netherbrick = (Item)Item.itemRegistry.getObject("netherbrick"); + public static final Item quartz = (Item)Item.itemRegistry.getObject("quartz"); + public static final Item tnt_minecart = (Item)Item.itemRegistry.getObject("tnt_minecart"); + public static final Item hopper_minecart = (Item)Item.itemRegistry.getObject("hopper_minecart"); + public static final Item iron_horse_armor = (Item)Item.itemRegistry.getObject("iron_horse_armor"); + public static final Item golden_horse_armor = (Item)Item.itemRegistry.getObject("golden_horse_armor"); + public static final Item diamond_horse_armor = (Item)Item.itemRegistry.getObject("diamond_horse_armor"); + public static final Item lead = (Item)Item.itemRegistry.getObject("lead"); + public static final Item name_tag = (Item)Item.itemRegistry.getObject("name_tag"); + public static final Item command_block_minecart = (Item)Item.itemRegistry.getObject("command_block_minecart"); + public static final Item record_13 = (Item)Item.itemRegistry.getObject("record_13"); + public static final Item record_cat = (Item)Item.itemRegistry.getObject("record_cat"); + public static final Item record_blocks = (Item)Item.itemRegistry.getObject("record_blocks"); + public static final Item record_chirp = (Item)Item.itemRegistry.getObject("record_chirp"); + public static final Item record_far = (Item)Item.itemRegistry.getObject("record_far"); + public static final Item record_mall = (Item)Item.itemRegistry.getObject("record_mall"); + public static final Item record_mellohi = (Item)Item.itemRegistry.getObject("record_mellohi"); + public static final Item record_stal = (Item)Item.itemRegistry.getObject("record_stal"); + public static final Item record_strad = (Item)Item.itemRegistry.getObject("record_strad"); + public static final Item record_ward = (Item)Item.itemRegistry.getObject("record_ward"); + public static final Item record_11 = (Item)Item.itemRegistry.getObject("record_11"); + public static final Item record_wait = (Item)Item.itemRegistry.getObject("record_wait"); + private static final String __OBFID = "CL_00000044"; +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/inventory/AnimalChest.java b/src/main/java/net/minecraft/inventory/AnimalChest.java new file mode 100644 index 0000000..05d6d53 --- /dev/null +++ b/src/main/java/net/minecraft/inventory/AnimalChest.java @@ -0,0 +1,20 @@ +package net.minecraft.inventory; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class AnimalChest extends InventoryBasic +{ + private static final String __OBFID = "CL_00001731"; + + public AnimalChest(String par1Str, int par2) + { + super(par1Str, false, par2); + } + + @SideOnly(Side.CLIENT) + public AnimalChest(String par1Str, boolean par2, int par3) + { + super(par1Str, par2, par3); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/inventory/Container.java b/src/main/java/net/minecraft/inventory/Container.java new file mode 100644 index 0000000..521e9e7 --- /dev/null +++ b/src/main/java/net/minecraft/inventory/Container.java @@ -0,0 +1,733 @@ +package net.minecraft.inventory; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MathHelper; + +public abstract class Container +{ + public List inventoryItemStacks = new ArrayList(); + public List inventorySlots = new ArrayList(); + public int windowId; + @SideOnly(Side.CLIENT) + private short transactionID; + private int field_94535_f = -1; + private int field_94536_g; + private final Set field_94537_h = new HashSet(); + protected List crafters = new ArrayList(); + private Set playerList = new HashSet(); + private static final String __OBFID = "CL_00001730"; + + protected Slot addSlotToContainer(Slot par1Slot) + { + par1Slot.slotNumber = this.inventorySlots.size(); + this.inventorySlots.add(par1Slot); + this.inventoryItemStacks.add((Object)null); + return par1Slot; + } + + public void addCraftingToCrafters(ICrafting par1ICrafting) + { + if (this.crafters.contains(par1ICrafting)) + { + throw new IllegalArgumentException("Listener already listening"); + } + else + { + this.crafters.add(par1ICrafting); + par1ICrafting.sendContainerAndContentsToPlayer(this, this.getInventory()); + this.detectAndSendChanges(); + } + } + + public List getInventory() + { + ArrayList arraylist = new ArrayList(); + + for (int i = 0; i < this.inventorySlots.size(); ++i) + { + arraylist.add(((Slot)this.inventorySlots.get(i)).getStack()); + } + + return arraylist; + } + + @SideOnly(Side.CLIENT) + public void removeCraftingFromCrafters(ICrafting par1ICrafting) + { + this.crafters.remove(par1ICrafting); + } + + public void detectAndSendChanges() + { + for (int i = 0; i < this.inventorySlots.size(); ++i) + { + ItemStack itemstack = ((Slot)this.inventorySlots.get(i)).getStack(); + ItemStack itemstack1 = (ItemStack)this.inventoryItemStacks.get(i); + + if (!ItemStack.areItemStacksEqual(itemstack1, itemstack)) + { + itemstack1 = itemstack == null ? null : itemstack.copy(); + this.inventoryItemStacks.set(i, itemstack1); + + for (int j = 0; j < this.crafters.size(); ++j) + { + ((ICrafting)this.crafters.get(j)).sendSlotContents(this, i, itemstack1); + } + } + } + } + + public boolean enchantItem(EntityPlayer par1EntityPlayer, int par2) + { + return false; + } + + public Slot getSlotFromInventory(IInventory par1IInventory, int par2) + { + for (int j = 0; j < this.inventorySlots.size(); ++j) + { + Slot slot = (Slot)this.inventorySlots.get(j); + + if (slot.isSlotInInventory(par1IInventory, par2)) + { + return slot; + } + } + + return null; + } + + public Slot getSlot(int par1) + { + return (Slot)this.inventorySlots.get(par1); + } + + public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) + { + Slot slot = (Slot)this.inventorySlots.get(par2); + return slot != null ? slot.getStack() : null; + } + + public ItemStack slotClick(int par1, int par2, int par3, EntityPlayer par4EntityPlayer) + { + ItemStack itemstack = null; + InventoryPlayer inventoryplayer = par4EntityPlayer.inventory; + int i1; + ItemStack itemstack3; + + if (par3 == 5) + { + int l = this.field_94536_g; + this.field_94536_g = func_94532_c(par2); + + if ((l != 1 || this.field_94536_g != 2) && l != this.field_94536_g) + { + this.func_94533_d(); + } + else if (inventoryplayer.getItemStack() == null) + { + this.func_94533_d(); + } + else if (this.field_94536_g == 0) + { + this.field_94535_f = func_94529_b(par2); + + if (func_94528_d(this.field_94535_f)) + { + this.field_94536_g = 1; + this.field_94537_h.clear(); + } + else + { + this.func_94533_d(); + } + } + else if (this.field_94536_g == 1) + { + Slot slot = (Slot)this.inventorySlots.get(par1); + + if (slot != null && func_94527_a(slot, inventoryplayer.getItemStack(), true) && slot.isItemValid(inventoryplayer.getItemStack()) && inventoryplayer.getItemStack().stackSize > this.field_94537_h.size() && this.canDragIntoSlot(slot)) + { + this.field_94537_h.add(slot); + } + } + else if (this.field_94536_g == 2) + { + if (!this.field_94537_h.isEmpty()) + { + itemstack3 = inventoryplayer.getItemStack().copy(); + i1 = inventoryplayer.getItemStack().stackSize; + Iterator iterator = this.field_94537_h.iterator(); + + while (iterator.hasNext()) + { + Slot slot1 = (Slot)iterator.next(); + + if (slot1 != null && func_94527_a(slot1, inventoryplayer.getItemStack(), true) && slot1.isItemValid(inventoryplayer.getItemStack()) && inventoryplayer.getItemStack().stackSize >= this.field_94537_h.size() && this.canDragIntoSlot(slot1)) + { + ItemStack itemstack1 = itemstack3.copy(); + int j1 = slot1.getHasStack() ? slot1.getStack().stackSize : 0; + func_94525_a(this.field_94537_h, this.field_94535_f, itemstack1, j1); + + if (itemstack1.stackSize > itemstack1.getMaxStackSize()) + { + itemstack1.stackSize = itemstack1.getMaxStackSize(); + } + + if (itemstack1.stackSize > slot1.getSlotStackLimit()) + { + itemstack1.stackSize = slot1.getSlotStackLimit(); + } + + i1 -= itemstack1.stackSize - j1; + slot1.putStack(itemstack1); + } + } + + itemstack3.stackSize = i1; + + if (itemstack3.stackSize <= 0) + { + itemstack3 = null; + } + + inventoryplayer.setItemStack(itemstack3); + } + + this.func_94533_d(); + } + else + { + this.func_94533_d(); + } + } + else if (this.field_94536_g != 0) + { + this.func_94533_d(); + } + else + { + Slot slot2; + int l1; + ItemStack itemstack5; + + if ((par3 == 0 || par3 == 1) && (par2 == 0 || par2 == 1)) + { + if (par1 == -999) + { + if (inventoryplayer.getItemStack() != null && par1 == -999) + { + if (par2 == 0) + { + par4EntityPlayer.dropPlayerItemWithRandomChoice(inventoryplayer.getItemStack(), true); + inventoryplayer.setItemStack((ItemStack)null); + } + + if (par2 == 1) + { + par4EntityPlayer.dropPlayerItemWithRandomChoice(inventoryplayer.getItemStack().splitStack(1), true); + + if (inventoryplayer.getItemStack().stackSize == 0) + { + inventoryplayer.setItemStack((ItemStack)null); + } + } + } + } + else if (par3 == 1) + { + if (par1 < 0) + { + return null; + } + + slot2 = (Slot)this.inventorySlots.get(par1); + + if (slot2 != null && slot2.canTakeStack(par4EntityPlayer)) + { + itemstack3 = this.transferStackInSlot(par4EntityPlayer, par1); + + if (itemstack3 != null) + { + Item item = itemstack3.getItem(); + itemstack = itemstack3.copy(); + + if (slot2.getStack() != null && slot2.getStack().getItem() == item) + { + this.retrySlotClick(par1, par2, true, par4EntityPlayer); + } + } + } + } + else + { + if (par1 < 0) + { + return null; + } + + slot2 = (Slot)this.inventorySlots.get(par1); + + if (slot2 != null) + { + itemstack3 = slot2.getStack(); + ItemStack itemstack4 = inventoryplayer.getItemStack(); + + if (itemstack3 != null) + { + itemstack = itemstack3.copy(); + } + + if (itemstack3 == null) + { + if (itemstack4 != null && slot2.isItemValid(itemstack4)) + { + l1 = par2 == 0 ? itemstack4.stackSize : 1; + + if (l1 > slot2.getSlotStackLimit()) + { + l1 = slot2.getSlotStackLimit(); + } + + if (itemstack4.stackSize >= l1) + { + slot2.putStack(itemstack4.splitStack(l1)); + } + + if (itemstack4.stackSize == 0) + { + inventoryplayer.setItemStack((ItemStack)null); + } + } + } + else if (slot2.canTakeStack(par4EntityPlayer)) + { + if (itemstack4 == null) + { + l1 = par2 == 0 ? itemstack3.stackSize : (itemstack3.stackSize + 1) / 2; + itemstack5 = slot2.decrStackSize(l1); + inventoryplayer.setItemStack(itemstack5); + + if (itemstack3.stackSize == 0) + { + slot2.putStack((ItemStack)null); + } + + slot2.onPickupFromSlot(par4EntityPlayer, inventoryplayer.getItemStack()); + } + else if (slot2.isItemValid(itemstack4)) + { + if (itemstack3.getItem() == itemstack4.getItem() && itemstack3.getItemDamage() == itemstack4.getItemDamage() && ItemStack.areItemStackTagsEqual(itemstack3, itemstack4)) + { + l1 = par2 == 0 ? itemstack4.stackSize : 1; + + if (l1 > slot2.getSlotStackLimit() - itemstack3.stackSize) + { + l1 = slot2.getSlotStackLimit() - itemstack3.stackSize; + } + + if (l1 > itemstack4.getMaxStackSize() - itemstack3.stackSize) + { + l1 = itemstack4.getMaxStackSize() - itemstack3.stackSize; + } + + itemstack4.splitStack(l1); + + if (itemstack4.stackSize == 0) + { + inventoryplayer.setItemStack((ItemStack)null); + } + + itemstack3.stackSize += l1; + } + else if (itemstack4.stackSize <= slot2.getSlotStackLimit()) + { + slot2.putStack(itemstack4); + inventoryplayer.setItemStack(itemstack3); + } + } + else if (itemstack3.getItem() == itemstack4.getItem() && itemstack4.getMaxStackSize() > 1 && (!itemstack3.getHasSubtypes() || itemstack3.getItemDamage() == itemstack4.getItemDamage()) && ItemStack.areItemStackTagsEqual(itemstack3, itemstack4)) + { + l1 = itemstack3.stackSize; + + if (l1 > 0 && l1 + itemstack4.stackSize <= itemstack4.getMaxStackSize()) + { + itemstack4.stackSize += l1; + itemstack3 = slot2.decrStackSize(l1); + + if (itemstack3.stackSize == 0) + { + slot2.putStack((ItemStack)null); + } + + slot2.onPickupFromSlot(par4EntityPlayer, inventoryplayer.getItemStack()); + } + } + } + + slot2.onSlotChanged(); + } + } + } + else if (par3 == 2 && par2 >= 0 && par2 < 9) + { + slot2 = (Slot)this.inventorySlots.get(par1); + + if (slot2.canTakeStack(par4EntityPlayer)) + { + itemstack3 = inventoryplayer.getStackInSlot(par2); + boolean flag = itemstack3 == null || slot2.inventory == inventoryplayer && slot2.isItemValid(itemstack3); + l1 = -1; + + if (!flag) + { + l1 = inventoryplayer.getFirstEmptyStack(); + flag |= l1 > -1; + } + + if (slot2.getHasStack() && flag) + { + itemstack5 = slot2.getStack(); + inventoryplayer.setInventorySlotContents(par2, itemstack5.copy()); + + if ((slot2.inventory != inventoryplayer || !slot2.isItemValid(itemstack3)) && itemstack3 != null) + { + if (l1 > -1) + { + inventoryplayer.addItemStackToInventory(itemstack3); + slot2.decrStackSize(itemstack5.stackSize); + slot2.putStack((ItemStack)null); + slot2.onPickupFromSlot(par4EntityPlayer, itemstack5); + } + } + else + { + slot2.decrStackSize(itemstack5.stackSize); + slot2.putStack(itemstack3); + slot2.onPickupFromSlot(par4EntityPlayer, itemstack5); + } + } + else if (!slot2.getHasStack() && itemstack3 != null && slot2.isItemValid(itemstack3)) + { + inventoryplayer.setInventorySlotContents(par2, (ItemStack)null); + slot2.putStack(itemstack3); + } + } + } + else if (par3 == 3 && par4EntityPlayer.capabilities.isCreativeMode && inventoryplayer.getItemStack() == null && par1 >= 0) + { + slot2 = (Slot)this.inventorySlots.get(par1); + + if (slot2 != null && slot2.getHasStack()) + { + itemstack3 = slot2.getStack().copy(); + itemstack3.stackSize = itemstack3.getMaxStackSize(); + inventoryplayer.setItemStack(itemstack3); + } + } + else if (par3 == 4 && inventoryplayer.getItemStack() == null && par1 >= 0) + { + slot2 = (Slot)this.inventorySlots.get(par1); + + if (slot2 != null && slot2.getHasStack() && slot2.canTakeStack(par4EntityPlayer)) + { + itemstack3 = slot2.decrStackSize(par2 == 0 ? 1 : slot2.getStack().stackSize); + slot2.onPickupFromSlot(par4EntityPlayer, itemstack3); + par4EntityPlayer.dropPlayerItemWithRandomChoice(itemstack3, true); + } + } + else if (par3 == 6 && par1 >= 0) + { + slot2 = (Slot)this.inventorySlots.get(par1); + itemstack3 = inventoryplayer.getItemStack(); + + if (itemstack3 != null && (slot2 == null || !slot2.getHasStack() || !slot2.canTakeStack(par4EntityPlayer))) + { + i1 = par2 == 0 ? 0 : this.inventorySlots.size() - 1; + l1 = par2 == 0 ? 1 : -1; + + for (int i2 = 0; i2 < 2; ++i2) + { + for (int j2 = i1; j2 >= 0 && j2 < this.inventorySlots.size() && itemstack3.stackSize < itemstack3.getMaxStackSize(); j2 += l1) + { + Slot slot3 = (Slot)this.inventorySlots.get(j2); + + if (slot3.getHasStack() && func_94527_a(slot3, itemstack3, true) && slot3.canTakeStack(par4EntityPlayer) && this.func_94530_a(itemstack3, slot3) && (i2 != 0 || slot3.getStack().stackSize != slot3.getStack().getMaxStackSize())) + { + int k1 = Math.min(itemstack3.getMaxStackSize() - itemstack3.stackSize, slot3.getStack().stackSize); + ItemStack itemstack2 = slot3.decrStackSize(k1); + itemstack3.stackSize += k1; + + if (itemstack2.stackSize <= 0) + { + slot3.putStack((ItemStack)null); + } + + slot3.onPickupFromSlot(par4EntityPlayer, itemstack2); + } + } + } + } + + this.detectAndSendChanges(); + } + } + + return itemstack; + } + + public boolean func_94530_a(ItemStack par1ItemStack, Slot par2Slot) + { + return true; + } + + protected void retrySlotClick(int par1, int par2, boolean par3, EntityPlayer par4EntityPlayer) + { + this.slotClick(par1, par2, 1, par4EntityPlayer); + } + + public void onContainerClosed(EntityPlayer par1EntityPlayer) + { + InventoryPlayer inventoryplayer = par1EntityPlayer.inventory; + + if (inventoryplayer.getItemStack() != null) + { + par1EntityPlayer.dropPlayerItemWithRandomChoice(inventoryplayer.getItemStack(), false); + inventoryplayer.setItemStack((ItemStack)null); + } + } + + public void onCraftMatrixChanged(IInventory par1IInventory) + { + this.detectAndSendChanges(); + } + + public void putStackInSlot(int par1, ItemStack par2ItemStack) + { + this.getSlot(par1).putStack(par2ItemStack); + } + + @SideOnly(Side.CLIENT) + public void putStacksInSlots(ItemStack[] par1ArrayOfItemStack) + { + for (int i = 0; i < par1ArrayOfItemStack.length; ++i) + { + this.getSlot(i).putStack(par1ArrayOfItemStack[i]); + } + } + + @SideOnly(Side.CLIENT) + public void updateProgressBar(int par1, int par2) {} + + @SideOnly(Side.CLIENT) + public short getNextTransactionID(InventoryPlayer par1InventoryPlayer) + { + ++this.transactionID; + return this.transactionID; + } + + public boolean isPlayerNotUsingContainer(EntityPlayer par1EntityPlayer) + { + return !this.playerList.contains(par1EntityPlayer); + } + + public void setPlayerIsPresent(EntityPlayer par1EntityPlayer, boolean par2) + { + if (par2) + { + this.playerList.remove(par1EntityPlayer); + } + else + { + this.playerList.add(par1EntityPlayer); + } + } + + public abstract boolean canInteractWith(EntityPlayer var1); + + protected boolean mergeItemStack(ItemStack par1ItemStack, int par2, int par3, boolean par4) + { + boolean flag1 = false; + int k = par2; + + if (par4) + { + k = par3 - 1; + } + + Slot slot; + ItemStack itemstack1; + + if (par1ItemStack.isStackable()) + { + while (par1ItemStack.stackSize > 0 && (!par4 && k < par3 || par4 && k >= par2)) + { + slot = (Slot)this.inventorySlots.get(k); + itemstack1 = slot.getStack(); + + if (itemstack1 != null && itemstack1.getItem() == par1ItemStack.getItem() && (!par1ItemStack.getHasSubtypes() || par1ItemStack.getItemDamage() == itemstack1.getItemDamage()) && ItemStack.areItemStackTagsEqual(par1ItemStack, itemstack1)) + { + int l = itemstack1.stackSize + par1ItemStack.stackSize; + + if (l <= par1ItemStack.getMaxStackSize()) + { + par1ItemStack.stackSize = 0; + itemstack1.stackSize = l; + slot.onSlotChanged(); + flag1 = true; + } + else if (itemstack1.stackSize < par1ItemStack.getMaxStackSize()) + { + par1ItemStack.stackSize -= par1ItemStack.getMaxStackSize() - itemstack1.stackSize; + itemstack1.stackSize = par1ItemStack.getMaxStackSize(); + slot.onSlotChanged(); + flag1 = true; + } + } + + if (par4) + { + --k; + } + else + { + ++k; + } + } + } + + if (par1ItemStack.stackSize > 0) + { + if (par4) + { + k = par3 - 1; + } + else + { + k = par2; + } + + while (!par4 && k < par3 || par4 && k >= par2) + { + slot = (Slot)this.inventorySlots.get(k); + itemstack1 = slot.getStack(); + + if (itemstack1 == null) + { + slot.putStack(par1ItemStack.copy()); + slot.onSlotChanged(); + par1ItemStack.stackSize = 0; + flag1 = true; + break; + } + + if (par4) + { + --k; + } + else + { + ++k; + } + } + } + + return flag1; + } + + public static int func_94529_b(int par0) + { + return par0 >> 2 & 3; + } + + public static int func_94532_c(int par0) + { + return par0 & 3; + } + + @SideOnly(Side.CLIENT) + public static int func_94534_d(int par0, int par1) + { + return par0 & 3 | (par1 & 3) << 2; + } + + public static boolean func_94528_d(int par0) + { + return par0 == 0 || par0 == 1; + } + + protected void func_94533_d() + { + this.field_94536_g = 0; + this.field_94537_h.clear(); + } + + public static boolean func_94527_a(Slot par0Slot, ItemStack par1ItemStack, boolean par2) + { + boolean flag1 = par0Slot == null || !par0Slot.getHasStack(); + + if (par0Slot != null && par0Slot.getHasStack() && par1ItemStack != null && par1ItemStack.isItemEqual(par0Slot.getStack()) && ItemStack.areItemStackTagsEqual(par0Slot.getStack(), par1ItemStack)) + { + int i = par2 ? 0 : par1ItemStack.stackSize; + flag1 |= par0Slot.getStack().stackSize + i <= par1ItemStack.getMaxStackSize(); + } + + return flag1; + } + + public static void func_94525_a(Set par0Set, int par1, ItemStack par2ItemStack, int par3) + { + switch (par1) + { + case 0: + par2ItemStack.stackSize = MathHelper.floor_float((float)par2ItemStack.stackSize / (float)par0Set.size()); + break; + case 1: + par2ItemStack.stackSize = 1; + } + + par2ItemStack.stackSize += par3; + } + + public boolean canDragIntoSlot(Slot par1Slot) + { + return true; + } + + public static int calcRedstoneFromInventory(IInventory par0IInventory) + { + if (par0IInventory == null) + { + return 0; + } + else + { + int i = 0; + float f = 0.0F; + + for (int j = 0; j < par0IInventory.getSizeInventory(); ++j) + { + ItemStack itemstack = par0IInventory.getStackInSlot(j); + + if (itemstack != null) + { + f += (float)itemstack.stackSize / (float)Math.min(par0IInventory.getInventoryStackLimit(), itemstack.getMaxStackSize()); + ++i; + } + } + + f /= (float)par0IInventory.getSizeInventory(); + return MathHelper.floor_float(f * 14.0F) + (i > 0 ? 1 : 0); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/inventory/ContainerBeacon.java b/src/main/java/net/minecraft/inventory/ContainerBeacon.java new file mode 100644 index 0000000..40cd7fc --- /dev/null +++ b/src/main/java/net/minecraft/inventory/ContainerBeacon.java @@ -0,0 +1,167 @@ +package net.minecraft.inventory; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntityBeacon; + +public class ContainerBeacon extends Container +{ + private TileEntityBeacon tileBeacon; + private final ContainerBeacon.BeaconSlot beaconSlot; + private int field_82865_g; + private int field_82867_h; + private int field_82868_i; + private static final String __OBFID = "CL_00001735"; + + public ContainerBeacon(InventoryPlayer par1InventoryPlayer, TileEntityBeacon par2TileEntityBeacon) + { + this.tileBeacon = par2TileEntityBeacon; + this.addSlotToContainer(this.beaconSlot = new ContainerBeacon.BeaconSlot(par2TileEntityBeacon, 0, 136, 110)); + byte b0 = 36; + short short1 = 137; + int i; + + for (i = 0; i < 3; ++i) + { + for (int j = 0; j < 9; ++j) + { + this.addSlotToContainer(new Slot(par1InventoryPlayer, j + i * 9 + 9, b0 + j * 18, short1 + i * 18)); + } + } + + for (i = 0; i < 9; ++i) + { + this.addSlotToContainer(new Slot(par1InventoryPlayer, i, b0 + i * 18, 58 + short1)); + } + + this.field_82865_g = par2TileEntityBeacon.getLevels(); + this.field_82867_h = par2TileEntityBeacon.getPrimaryEffect(); + this.field_82868_i = par2TileEntityBeacon.getSecondaryEffect(); + } + + public void addCraftingToCrafters(ICrafting par1ICrafting) + { + super.addCraftingToCrafters(par1ICrafting); + par1ICrafting.sendProgressBarUpdate(this, 0, this.field_82865_g); + par1ICrafting.sendProgressBarUpdate(this, 1, this.field_82867_h); + par1ICrafting.sendProgressBarUpdate(this, 2, this.field_82868_i); + } + + @SideOnly(Side.CLIENT) + public void updateProgressBar(int par1, int par2) + { + if (par1 == 0) + { + this.tileBeacon.func_146005_c(par2); + } + + if (par1 == 1) + { + this.tileBeacon.setPrimaryEffect(par2); + } + + if (par1 == 2) + { + this.tileBeacon.setSecondaryEffect(par2); + } + } + + public TileEntityBeacon func_148327_e() + { + return this.tileBeacon; + } + + public boolean canInteractWith(EntityPlayer par1EntityPlayer) + { + return this.tileBeacon.isUseableByPlayer(par1EntityPlayer); + } + + public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) + { + ItemStack itemstack = null; + Slot slot = (Slot)this.inventorySlots.get(par2); + + if (slot != null && slot.getHasStack()) + { + ItemStack itemstack1 = slot.getStack(); + itemstack = itemstack1.copy(); + + if (par2 == 0) + { + if (!this.mergeItemStack(itemstack1, 1, 37, true)) + { + return null; + } + + slot.onSlotChange(itemstack1, itemstack); + } + else if (!this.beaconSlot.getHasStack() && this.beaconSlot.isItemValid(itemstack1) && itemstack1.stackSize == 1) + { + if (!this.mergeItemStack(itemstack1, 0, 1, false)) + { + return null; + } + } + else if (par2 >= 1 && par2 < 28) + { + if (!this.mergeItemStack(itemstack1, 28, 37, false)) + { + return null; + } + } + else if (par2 >= 28 && par2 < 37) + { + if (!this.mergeItemStack(itemstack1, 1, 28, false)) + { + return null; + } + } + else if (!this.mergeItemStack(itemstack1, 1, 37, false)) + { + return null; + } + + if (itemstack1.stackSize == 0) + { + slot.putStack((ItemStack)null); + } + else + { + slot.onSlotChanged(); + } + + if (itemstack1.stackSize == itemstack.stackSize) + { + return null; + } + + slot.onPickupFromSlot(par1EntityPlayer, itemstack1); + } + + return itemstack; + } + + class BeaconSlot extends Slot + { + private static final String __OBFID = "CL_00001736"; + + public BeaconSlot(IInventory par2IInventory, int par3, int par4, int par5) + { + super(par2IInventory, par3, par4, par5); + } + + public boolean isItemValid(ItemStack par1ItemStack) + { + return par1ItemStack == null ? false : par1ItemStack.getItem() == Items.emerald || par1ItemStack.getItem() == Items.diamond || par1ItemStack.getItem() == Items.gold_ingot || par1ItemStack.getItem() == Items.iron_ingot; + } + + public int getSlotStackLimit() + { + return 1; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/inventory/ContainerBrewingStand.java b/src/main/java/net/minecraft/inventory/ContainerBrewingStand.java new file mode 100644 index 0000000..57f2d3a --- /dev/null +++ b/src/main/java/net/minecraft/inventory/ContainerBrewingStand.java @@ -0,0 +1,211 @@ +package net.minecraft.inventory; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.ItemPotion; +import net.minecraft.item.ItemStack; +import net.minecraft.stats.AchievementList; +import net.minecraft.tileentity.TileEntityBrewingStand; + +public class ContainerBrewingStand extends Container +{ + private TileEntityBrewingStand tileBrewingStand; + private final Slot theSlot; + private int brewTime; + private static final String __OBFID = "CL_00001737"; + + public ContainerBrewingStand(InventoryPlayer par1InventoryPlayer, TileEntityBrewingStand par2TileEntityBrewingStand) + { + this.tileBrewingStand = par2TileEntityBrewingStand; + this.addSlotToContainer(new ContainerBrewingStand.Potion(par1InventoryPlayer.player, par2TileEntityBrewingStand, 0, 56, 46)); + this.addSlotToContainer(new ContainerBrewingStand.Potion(par1InventoryPlayer.player, par2TileEntityBrewingStand, 1, 79, 53)); + this.addSlotToContainer(new ContainerBrewingStand.Potion(par1InventoryPlayer.player, par2TileEntityBrewingStand, 2, 102, 46)); + this.theSlot = this.addSlotToContainer(new ContainerBrewingStand.Ingredient(par2TileEntityBrewingStand, 3, 79, 17)); + int i; + + for (i = 0; i < 3; ++i) + { + for (int j = 0; j < 9; ++j) + { + this.addSlotToContainer(new Slot(par1InventoryPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + } + } + + for (i = 0; i < 9; ++i) + { + this.addSlotToContainer(new Slot(par1InventoryPlayer, i, 8 + i * 18, 142)); + } + } + + public void addCraftingToCrafters(ICrafting par1ICrafting) + { + super.addCraftingToCrafters(par1ICrafting); + par1ICrafting.sendProgressBarUpdate(this, 0, this.tileBrewingStand.getBrewTime()); + } + + public void detectAndSendChanges() + { + super.detectAndSendChanges(); + + for (int i = 0; i < this.crafters.size(); ++i) + { + ICrafting icrafting = (ICrafting)this.crafters.get(i); + + if (this.brewTime != this.tileBrewingStand.getBrewTime()) + { + icrafting.sendProgressBarUpdate(this, 0, this.tileBrewingStand.getBrewTime()); + } + } + + this.brewTime = this.tileBrewingStand.getBrewTime(); + } + + @SideOnly(Side.CLIENT) + public void updateProgressBar(int par1, int par2) + { + if (par1 == 0) + { + this.tileBrewingStand.func_145938_d(par2); + } + } + + public boolean canInteractWith(EntityPlayer par1EntityPlayer) + { + return this.tileBrewingStand.isUseableByPlayer(par1EntityPlayer); + } + + public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) + { + ItemStack itemstack = null; + Slot slot = (Slot)this.inventorySlots.get(par2); + + if (slot != null && slot.getHasStack()) + { + ItemStack itemstack1 = slot.getStack(); + itemstack = itemstack1.copy(); + + if ((par2 < 0 || par2 > 2) && par2 != 3) + { + if (!this.theSlot.getHasStack() && this.theSlot.isItemValid(itemstack1)) + { + if (!this.mergeItemStack(itemstack1, 3, 4, false)) + { + return null; + } + } + else if (ContainerBrewingStand.Potion.canHoldPotion(itemstack)) + { + if (!this.mergeItemStack(itemstack1, 0, 3, false)) + { + return null; + } + } + else if (par2 >= 4 && par2 < 31) + { + if (!this.mergeItemStack(itemstack1, 31, 40, false)) + { + return null; + } + } + else if (par2 >= 31 && par2 < 40) + { + if (!this.mergeItemStack(itemstack1, 4, 31, false)) + { + return null; + } + } + else if (!this.mergeItemStack(itemstack1, 4, 40, false)) + { + return null; + } + } + else + { + if (!this.mergeItemStack(itemstack1, 4, 40, true)) + { + return null; + } + + slot.onSlotChange(itemstack1, itemstack); + } + + if (itemstack1.stackSize == 0) + { + slot.putStack((ItemStack)null); + } + else + { + slot.onSlotChanged(); + } + + if (itemstack1.stackSize == itemstack.stackSize) + { + return null; + } + + slot.onPickupFromSlot(par1EntityPlayer, itemstack1); + } + + return itemstack; + } + + class Ingredient extends Slot + { + private static final String __OBFID = "CL_00001738"; + + public Ingredient(IInventory par2IInventory, int par3, int par4, int par5) + { + super(par2IInventory, par3, par4, par5); + } + + public boolean isItemValid(ItemStack par1ItemStack) + { + return par1ItemStack != null ? par1ItemStack.getItem().isPotionIngredient(par1ItemStack) : false; + } + + public int getSlotStackLimit() + { + return 64; + } + } + + static class Potion extends Slot + { + private EntityPlayer player; + private static final String __OBFID = "CL_00001740"; + + public Potion(EntityPlayer par1EntityPlayer, IInventory par2IInventory, int par3, int par4, int par5) + { + super(par2IInventory, par3, par4, par5); + this.player = par1EntityPlayer; + } + + public boolean isItemValid(ItemStack par1ItemStack) + { + return canHoldPotion(par1ItemStack); + } + + public int getSlotStackLimit() + { + return 1; + } + + public void onPickupFromSlot(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack) + { + if (par2ItemStack.getItem() instanceof ItemPotion && par2ItemStack.getItemDamage() > 0) + { + this.player.addStat(AchievementList.potion, 1); + } + + super.onPickupFromSlot(par1EntityPlayer, par2ItemStack); + } + + public static boolean canHoldPotion(ItemStack par0ItemStack) + { + return par0ItemStack != null && (par0ItemStack.getItem() instanceof ItemPotion || par0ItemStack.getItem() == Items.glass_bottle); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/inventory/ContainerChest.java b/src/main/java/net/minecraft/inventory/ContainerChest.java new file mode 100644 index 0000000..c1323c6 --- /dev/null +++ b/src/main/java/net/minecraft/inventory/ContainerChest.java @@ -0,0 +1,93 @@ +package net.minecraft.inventory; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +public class ContainerChest extends Container +{ + private IInventory lowerChestInventory; + private int numRows; + private static final String __OBFID = "CL_00001742"; + + public ContainerChest(IInventory par1IInventory, IInventory par2IInventory) + { + this.lowerChestInventory = par2IInventory; + this.numRows = par2IInventory.getSizeInventory() / 9; + par2IInventory.openInventory(); + int i = (this.numRows - 4) * 18; + int j; + int k; + + for (j = 0; j < this.numRows; ++j) + { + for (k = 0; k < 9; ++k) + { + this.addSlotToContainer(new Slot(par2IInventory, k + j * 9, 8 + k * 18, 18 + j * 18)); + } + } + + for (j = 0; j < 3; ++j) + { + for (k = 0; k < 9; ++k) + { + this.addSlotToContainer(new Slot(par1IInventory, k + j * 9 + 9, 8 + k * 18, 103 + j * 18 + i)); + } + } + + for (j = 0; j < 9; ++j) + { + this.addSlotToContainer(new Slot(par1IInventory, j, 8 + j * 18, 161 + i)); + } + } + + public boolean canInteractWith(EntityPlayer par1EntityPlayer) + { + return this.lowerChestInventory.isUseableByPlayer(par1EntityPlayer); + } + + public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) + { + ItemStack itemstack = null; + Slot slot = (Slot)this.inventorySlots.get(par2); + + if (slot != null && slot.getHasStack()) + { + ItemStack itemstack1 = slot.getStack(); + itemstack = itemstack1.copy(); + + if (par2 < this.numRows * 9) + { + if (!this.mergeItemStack(itemstack1, this.numRows * 9, this.inventorySlots.size(), true)) + { + return null; + } + } + else if (!this.mergeItemStack(itemstack1, 0, this.numRows * 9, false)) + { + return null; + } + + if (itemstack1.stackSize == 0) + { + slot.putStack((ItemStack)null); + } + else + { + slot.onSlotChanged(); + } + } + + return itemstack; + } + + public void onContainerClosed(EntityPlayer par1EntityPlayer) + { + super.onContainerClosed(par1EntityPlayer); + this.lowerChestInventory.closeInventory(); + } + + public IInventory getLowerChestInventory() + { + return this.lowerChestInventory; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/inventory/ContainerDispenser.java b/src/main/java/net/minecraft/inventory/ContainerDispenser.java new file mode 100644 index 0000000..b546e71 --- /dev/null +++ b/src/main/java/net/minecraft/inventory/ContainerDispenser.java @@ -0,0 +1,86 @@ +package net.minecraft.inventory; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntityDispenser; + +public class ContainerDispenser extends Container +{ + private TileEntityDispenser tileDispenser; + private static final String __OBFID = "CL_00001763"; + + public ContainerDispenser(IInventory par1IInventory, TileEntityDispenser par2TileEntityDispenser) + { + this.tileDispenser = par2TileEntityDispenser; + int i; + int j; + + for (i = 0; i < 3; ++i) + { + for (j = 0; j < 3; ++j) + { + this.addSlotToContainer(new Slot(par2TileEntityDispenser, j + i * 3, 62 + j * 18, 17 + i * 18)); + } + } + + for (i = 0; i < 3; ++i) + { + for (j = 0; j < 9; ++j) + { + this.addSlotToContainer(new Slot(par1IInventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + } + } + + for (i = 0; i < 9; ++i) + { + this.addSlotToContainer(new Slot(par1IInventory, i, 8 + i * 18, 142)); + } + } + + public boolean canInteractWith(EntityPlayer par1EntityPlayer) + { + return this.tileDispenser.isUseableByPlayer(par1EntityPlayer); + } + + public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) + { + ItemStack itemstack = null; + Slot slot = (Slot)this.inventorySlots.get(par2); + + if (slot != null && slot.getHasStack()) + { + ItemStack itemstack1 = slot.getStack(); + itemstack = itemstack1.copy(); + + if (par2 < 9) + { + if (!this.mergeItemStack(itemstack1, 9, 45, true)) + { + return null; + } + } + else if (!this.mergeItemStack(itemstack1, 0, 9, false)) + { + return null; + } + + if (itemstack1.stackSize == 0) + { + slot.putStack((ItemStack)null); + } + else + { + slot.onSlotChanged(); + } + + if (itemstack1.stackSize == itemstack.stackSize) + { + return null; + } + + slot.onPickupFromSlot(par1EntityPlayer, itemstack1); + } + + return itemstack; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/inventory/ContainerEnchantment.java b/src/main/java/net/minecraft/inventory/ContainerEnchantment.java new file mode 100644 index 0000000..c1061c3 --- /dev/null +++ b/src/main/java/net/minecraft/inventory/ContainerEnchantment.java @@ -0,0 +1,286 @@ +package net.minecraft.inventory; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import java.util.Random; +import net.minecraft.enchantment.EnchantmentData; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraftforge.common.ForgeHooks; + +public class ContainerEnchantment extends Container +{ + public IInventory tableInventory = new InventoryBasic("Enchant", true, 1) + { + private static final String __OBFID = "CL_00001746"; + public int getInventoryStackLimit() + { + return 1; + } + public void markDirty() + { + super.markDirty(); + ContainerEnchantment.this.onCraftMatrixChanged(this); + } + }; + private World worldPointer; + private int posX; + private int posY; + private int posZ; + private Random rand = new Random(); + public long nameSeed; + public int[] enchantLevels = new int[3]; + private static final String __OBFID = "CL_00001745"; + + public ContainerEnchantment(InventoryPlayer par1InventoryPlayer, World par2World, int par3, int par4, int par5) + { + this.worldPointer = par2World; + this.posX = par3; + this.posY = par4; + this.posZ = par5; + this.addSlotToContainer(new Slot(this.tableInventory, 0, 25, 47) + { + private static final String __OBFID = "CL_00001747"; + public boolean isItemValid(ItemStack par1ItemStack) + { + return true; + } + }); + int l; + + for (l = 0; l < 3; ++l) + { + for (int i1 = 0; i1 < 9; ++i1) + { + this.addSlotToContainer(new Slot(par1InventoryPlayer, i1 + l * 9 + 9, 8 + i1 * 18, 84 + l * 18)); + } + } + + for (l = 0; l < 9; ++l) + { + this.addSlotToContainer(new Slot(par1InventoryPlayer, l, 8 + l * 18, 142)); + } + } + + public void addCraftingToCrafters(ICrafting par1ICrafting) + { + super.addCraftingToCrafters(par1ICrafting); + par1ICrafting.sendProgressBarUpdate(this, 0, this.enchantLevels[0]); + par1ICrafting.sendProgressBarUpdate(this, 1, this.enchantLevels[1]); + par1ICrafting.sendProgressBarUpdate(this, 2, this.enchantLevels[2]); + } + + public void detectAndSendChanges() + { + super.detectAndSendChanges(); + + for (int i = 0; i < this.crafters.size(); ++i) + { + ICrafting icrafting = (ICrafting)this.crafters.get(i); + icrafting.sendProgressBarUpdate(this, 0, this.enchantLevels[0]); + icrafting.sendProgressBarUpdate(this, 1, this.enchantLevels[1]); + icrafting.sendProgressBarUpdate(this, 2, this.enchantLevels[2]); + } + } + + @SideOnly(Side.CLIENT) + public void updateProgressBar(int par1, int par2) + { + if (par1 >= 0 && par1 <= 2) + { + this.enchantLevels[par1] = par2; + } + else + { + super.updateProgressBar(par1, par2); + } + } + + public void onCraftMatrixChanged(IInventory par1IInventory) + { + if (par1IInventory == this.tableInventory) + { + ItemStack itemstack = par1IInventory.getStackInSlot(0); + int i; + + if (itemstack != null && itemstack.isItemEnchantable()) + { + this.nameSeed = this.rand.nextLong(); + + if (!this.worldPointer.isRemote) + { + i = 0; + int j; + float power = 0; + + for (j = -1; j <= 1; ++j) + { + for (int k = -1; k <= 1; ++k) + { + if ((j != 0 || k != 0) && this.worldPointer.isAirBlock(this.posX + k, this.posY, this.posZ + j) && this.worldPointer.isAirBlock(this.posX + k, this.posY + 1, this.posZ + j)) + { + power += ForgeHooks.getEnchantPower(worldPointer, posX + k * 2, posY, posZ + j * 2); + power += ForgeHooks.getEnchantPower(worldPointer, posX + k * 2, posY + 1, posZ + j * 2); + + if (k != 0 && j != 0) + { + power += ForgeHooks.getEnchantPower(worldPointer, posX + k * 2, posY, posZ + j ); + power += ForgeHooks.getEnchantPower(worldPointer, posX + k * 2, posY + 1, posZ + j ); + power += ForgeHooks.getEnchantPower(worldPointer, posX + k, posY, posZ + j * 2); + power += ForgeHooks.getEnchantPower(worldPointer, posX + k, posY + 1, posZ + j * 2); + } + } + } + } + + for (j = 0; j < 3; ++j) + { + this.enchantLevels[j] = EnchantmentHelper.calcItemStackEnchantability(this.rand, j, (int)power, itemstack); + } + + this.detectAndSendChanges(); + } + } + else + { + for (i = 0; i < 3; ++i) + { + this.enchantLevels[i] = 0; + } + } + } + } + + public boolean enchantItem(EntityPlayer par1EntityPlayer, int par2) + { + ItemStack itemstack = this.tableInventory.getStackInSlot(0); + + if (this.enchantLevels[par2] > 0 && itemstack != null && (par1EntityPlayer.experienceLevel >= this.enchantLevels[par2] || par1EntityPlayer.capabilities.isCreativeMode)) + { + if (!this.worldPointer.isRemote) + { + List list = EnchantmentHelper.buildEnchantmentList(this.rand, itemstack, this.enchantLevels[par2]); + boolean flag = itemstack.getItem() == Items.book; + + if (list != null) + { + par1EntityPlayer.addExperienceLevel(-this.enchantLevels[par2]); + + if (flag) + { + itemstack.func_150996_a(Items.enchanted_book); + } + + int j = flag && list.size() > 1 ? this.rand.nextInt(list.size()) : -1; + + for (int k = 0; k < list.size(); ++k) + { + EnchantmentData enchantmentdata = (EnchantmentData)list.get(k); + + if (!flag || k != j) + { + if (flag) + { + Items.enchanted_book.addEnchantment(itemstack, enchantmentdata); + } + else + { + itemstack.addEnchantment(enchantmentdata.enchantmentobj, enchantmentdata.enchantmentLevel); + } + } + } + + this.onCraftMatrixChanged(this.tableInventory); + } + } + + return true; + } + else + { + return false; + } + } + + public void onContainerClosed(EntityPlayer par1EntityPlayer) + { + super.onContainerClosed(par1EntityPlayer); + + if (!this.worldPointer.isRemote) + { + ItemStack itemstack = this.tableInventory.getStackInSlotOnClosing(0); + + if (itemstack != null) + { + par1EntityPlayer.dropPlayerItemWithRandomChoice(itemstack, false); + } + } + } + + public boolean canInteractWith(EntityPlayer par1EntityPlayer) + { + return this.worldPointer.getBlock(this.posX, this.posY, this.posZ) != Blocks.enchanting_table ? false : par1EntityPlayer.getDistanceSq((double)this.posX + 0.5D, (double)this.posY + 0.5D, (double)this.posZ + 0.5D) <= 64.0D; + } + + public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) + { + ItemStack itemstack = null; + Slot slot = (Slot)this.inventorySlots.get(par2); + + if (slot != null && slot.getHasStack()) + { + ItemStack itemstack1 = slot.getStack(); + itemstack = itemstack1.copy(); + + if (par2 == 0) + { + if (!this.mergeItemStack(itemstack1, 1, 37, true)) + { + return null; + } + } + else + { + if (((Slot)this.inventorySlots.get(0)).getHasStack() || !((Slot)this.inventorySlots.get(0)).isItemValid(itemstack1)) + { + return null; + } + + if (itemstack1.hasTagCompound() && itemstack1.stackSize == 1) + { + ((Slot)this.inventorySlots.get(0)).putStack(itemstack1.copy()); + itemstack1.stackSize = 0; + } + else if (itemstack1.stackSize >= 1) + { + ((Slot)this.inventorySlots.get(0)).putStack(new ItemStack(itemstack1.getItem(), 1, itemstack1.getItemDamage())); + --itemstack1.stackSize; + } + } + + if (itemstack1.stackSize == 0) + { + slot.putStack((ItemStack)null); + } + else + { + slot.onSlotChanged(); + } + + if (itemstack1.stackSize == itemstack.stackSize) + { + return null; + } + + slot.onPickupFromSlot(par1EntityPlayer, itemstack1); + } + + return itemstack; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/inventory/ContainerFurnace.java b/src/main/java/net/minecraft/inventory/ContainerFurnace.java new file mode 100644 index 0000000..6d94cb7 --- /dev/null +++ b/src/main/java/net/minecraft/inventory/ContainerFurnace.java @@ -0,0 +1,173 @@ +package net.minecraft.inventory; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.FurnaceRecipes; +import net.minecraft.tileentity.TileEntityFurnace; + +public class ContainerFurnace extends Container +{ + private TileEntityFurnace tileFurnace; + private int lastCookTime; + private int lastBurnTime; + private int lastItemBurnTime; + private static final String __OBFID = "CL_00001748"; + + public ContainerFurnace(InventoryPlayer par1InventoryPlayer, TileEntityFurnace par2TileEntityFurnace) + { + this.tileFurnace = par2TileEntityFurnace; + this.addSlotToContainer(new Slot(par2TileEntityFurnace, 0, 56, 17)); + this.addSlotToContainer(new Slot(par2TileEntityFurnace, 1, 56, 53)); + this.addSlotToContainer(new SlotFurnace(par1InventoryPlayer.player, par2TileEntityFurnace, 2, 116, 35)); + int i; + + for (i = 0; i < 3; ++i) + { + for (int j = 0; j < 9; ++j) + { + this.addSlotToContainer(new Slot(par1InventoryPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + } + } + + for (i = 0; i < 9; ++i) + { + this.addSlotToContainer(new Slot(par1InventoryPlayer, i, 8 + i * 18, 142)); + } + } + + public void addCraftingToCrafters(ICrafting par1ICrafting) + { + super.addCraftingToCrafters(par1ICrafting); + par1ICrafting.sendProgressBarUpdate(this, 0, this.tileFurnace.furnaceCookTime); + par1ICrafting.sendProgressBarUpdate(this, 1, this.tileFurnace.furnaceBurnTime); + par1ICrafting.sendProgressBarUpdate(this, 2, this.tileFurnace.currentItemBurnTime); + } + + public void detectAndSendChanges() + { + super.detectAndSendChanges(); + + for (int i = 0; i < this.crafters.size(); ++i) + { + ICrafting icrafting = (ICrafting)this.crafters.get(i); + + if (this.lastCookTime != this.tileFurnace.furnaceCookTime) + { + icrafting.sendProgressBarUpdate(this, 0, this.tileFurnace.furnaceCookTime); + } + + if (this.lastBurnTime != this.tileFurnace.furnaceBurnTime) + { + icrafting.sendProgressBarUpdate(this, 1, this.tileFurnace.furnaceBurnTime); + } + + if (this.lastItemBurnTime != this.tileFurnace.currentItemBurnTime) + { + icrafting.sendProgressBarUpdate(this, 2, this.tileFurnace.currentItemBurnTime); + } + } + + this.lastCookTime = this.tileFurnace.furnaceCookTime; + this.lastBurnTime = this.tileFurnace.furnaceBurnTime; + this.lastItemBurnTime = this.tileFurnace.currentItemBurnTime; + } + + @SideOnly(Side.CLIENT) + public void updateProgressBar(int par1, int par2) + { + if (par1 == 0) + { + this.tileFurnace.furnaceCookTime = par2; + } + + if (par1 == 1) + { + this.tileFurnace.furnaceBurnTime = par2; + } + + if (par1 == 2) + { + this.tileFurnace.currentItemBurnTime = par2; + } + } + + public boolean canInteractWith(EntityPlayer par1EntityPlayer) + { + return this.tileFurnace.isUseableByPlayer(par1EntityPlayer); + } + + public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) + { + ItemStack itemstack = null; + Slot slot = (Slot)this.inventorySlots.get(par2); + + if (slot != null && slot.getHasStack()) + { + ItemStack itemstack1 = slot.getStack(); + itemstack = itemstack1.copy(); + + if (par2 == 2) + { + if (!this.mergeItemStack(itemstack1, 3, 39, true)) + { + return null; + } + + slot.onSlotChange(itemstack1, itemstack); + } + else if (par2 != 1 && par2 != 0) + { + if (FurnaceRecipes.smelting().getSmeltingResult(itemstack1) != null) + { + if (!this.mergeItemStack(itemstack1, 0, 1, false)) + { + return null; + } + } + else if (TileEntityFurnace.isItemFuel(itemstack1)) + { + if (!this.mergeItemStack(itemstack1, 1, 2, false)) + { + return null; + } + } + else if (par2 >= 3 && par2 < 30) + { + if (!this.mergeItemStack(itemstack1, 30, 39, false)) + { + return null; + } + } + else if (par2 >= 30 && par2 < 39 && !this.mergeItemStack(itemstack1, 3, 30, false)) + { + return null; + } + } + else if (!this.mergeItemStack(itemstack1, 3, 39, false)) + { + return null; + } + + if (itemstack1.stackSize == 0) + { + slot.putStack((ItemStack)null); + } + else + { + slot.onSlotChanged(); + } + + if (itemstack1.stackSize == itemstack.stackSize) + { + return null; + } + + slot.onPickupFromSlot(par1EntityPlayer, itemstack1); + } + + return itemstack; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/inventory/ContainerHopper.java b/src/main/java/net/minecraft/inventory/ContainerHopper.java new file mode 100644 index 0000000..786ea06 --- /dev/null +++ b/src/main/java/net/minecraft/inventory/ContainerHopper.java @@ -0,0 +1,83 @@ +package net.minecraft.inventory; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; + +public class ContainerHopper extends Container +{ + private final IInventory field_94538_a; + private static final String __OBFID = "CL_00001750"; + + public ContainerHopper(InventoryPlayer par1InventoryPlayer, IInventory par2IInventory) + { + this.field_94538_a = par2IInventory; + par2IInventory.openInventory(); + byte b0 = 51; + int i; + + for (i = 0; i < par2IInventory.getSizeInventory(); ++i) + { + this.addSlotToContainer(new Slot(par2IInventory, i, 44 + i * 18, 20)); + } + + for (i = 0; i < 3; ++i) + { + for (int j = 0; j < 9; ++j) + { + this.addSlotToContainer(new Slot(par1InventoryPlayer, j + i * 9 + 9, 8 + j * 18, i * 18 + b0)); + } + } + + for (i = 0; i < 9; ++i) + { + this.addSlotToContainer(new Slot(par1InventoryPlayer, i, 8 + i * 18, 58 + b0)); + } + } + + public boolean canInteractWith(EntityPlayer par1EntityPlayer) + { + return this.field_94538_a.isUseableByPlayer(par1EntityPlayer); + } + + public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) + { + ItemStack itemstack = null; + Slot slot = (Slot)this.inventorySlots.get(par2); + + if (slot != null && slot.getHasStack()) + { + ItemStack itemstack1 = slot.getStack(); + itemstack = itemstack1.copy(); + + if (par2 < this.field_94538_a.getSizeInventory()) + { + if (!this.mergeItemStack(itemstack1, this.field_94538_a.getSizeInventory(), this.inventorySlots.size(), true)) + { + return null; + } + } + else if (!this.mergeItemStack(itemstack1, 0, this.field_94538_a.getSizeInventory(), false)) + { + return null; + } + + if (itemstack1.stackSize == 0) + { + slot.putStack((ItemStack)null); + } + else + { + slot.onSlotChanged(); + } + } + + return itemstack; + } + + public void onContainerClosed(EntityPlayer par1EntityPlayer) + { + super.onContainerClosed(par1EntityPlayer); + this.field_94538_a.closeInventory(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/inventory/ContainerHorseInventory.java b/src/main/java/net/minecraft/inventory/ContainerHorseInventory.java new file mode 100644 index 0000000..0fb537c --- /dev/null +++ b/src/main/java/net/minecraft/inventory/ContainerHorseInventory.java @@ -0,0 +1,131 @@ +package net.minecraft.inventory; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.passive.EntityHorse; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; + +public class ContainerHorseInventory extends Container +{ + private IInventory field_111243_a; + private EntityHorse theHorse; + private static final String __OBFID = "CL_00001751"; + + public ContainerHorseInventory(IInventory par1IInventory, final IInventory par2IInventory, final EntityHorse par3EntityHorse) + { + this.field_111243_a = par2IInventory; + this.theHorse = par3EntityHorse; + byte b0 = 3; + par2IInventory.openInventory(); + int i = (b0 - 4) * 18; + this.addSlotToContainer(new Slot(par2IInventory, 0, 8, 18) + { + private static final String __OBFID = "CL_00001752"; + public boolean isItemValid(ItemStack par1ItemStack) + { + return super.isItemValid(par1ItemStack) && par1ItemStack.getItem() == Items.saddle && !this.getHasStack(); + } + }); + this.addSlotToContainer(new Slot(par2IInventory, 1, 8, 36) + { + private static final String __OBFID = "CL_00001753"; + public boolean isItemValid(ItemStack par1ItemStack) + { + return super.isItemValid(par1ItemStack) && par3EntityHorse.func_110259_cr() && EntityHorse.func_146085_a(par1ItemStack.getItem()); + } + @SideOnly(Side.CLIENT) + public boolean func_111238_b() + { + return par3EntityHorse.func_110259_cr(); + } + }); + int j; + int k; + + if (par3EntityHorse.isChested()) + { + for (j = 0; j < b0; ++j) + { + for (k = 0; k < 5; ++k) + { + this.addSlotToContainer(new Slot(par2IInventory, 2 + k + j * 5, 80 + k * 18, 18 + j * 18)); + } + } + } + + for (j = 0; j < 3; ++j) + { + for (k = 0; k < 9; ++k) + { + this.addSlotToContainer(new Slot(par1IInventory, k + j * 9 + 9, 8 + k * 18, 102 + j * 18 + i)); + } + } + + for (j = 0; j < 9; ++j) + { + this.addSlotToContainer(new Slot(par1IInventory, j, 8 + j * 18, 160 + i)); + } + } + + public boolean canInteractWith(EntityPlayer par1EntityPlayer) + { + return this.field_111243_a.isUseableByPlayer(par1EntityPlayer) && this.theHorse.isEntityAlive() && this.theHorse.getDistanceToEntity(par1EntityPlayer) < 8.0F; + } + + public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) + { + ItemStack itemstack = null; + Slot slot = (Slot)this.inventorySlots.get(par2); + + if (slot != null && slot.getHasStack()) + { + ItemStack itemstack1 = slot.getStack(); + itemstack = itemstack1.copy(); + + if (par2 < this.field_111243_a.getSizeInventory()) + { + if (!this.mergeItemStack(itemstack1, this.field_111243_a.getSizeInventory(), this.inventorySlots.size(), true)) + { + return null; + } + } + else if (this.getSlot(1).isItemValid(itemstack1) && !this.getSlot(1).getHasStack()) + { + if (!this.mergeItemStack(itemstack1, 1, 2, false)) + { + return null; + } + } + else if (this.getSlot(0).isItemValid(itemstack1)) + { + if (!this.mergeItemStack(itemstack1, 0, 1, false)) + { + return null; + } + } + else if (this.field_111243_a.getSizeInventory() <= 2 || !this.mergeItemStack(itemstack1, 2, this.field_111243_a.getSizeInventory(), false)) + { + return null; + } + + if (itemstack1.stackSize == 0) + { + slot.putStack((ItemStack)null); + } + else + { + slot.onSlotChanged(); + } + } + + return itemstack; + } + + public void onContainerClosed(EntityPlayer par1EntityPlayer) + { + super.onContainerClosed(par1EntityPlayer); + this.field_111243_a.closeInventory(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/inventory/ContainerMerchant.java b/src/main/java/net/minecraft/inventory/ContainerMerchant.java new file mode 100644 index 0000000..a48402b --- /dev/null +++ b/src/main/java/net/minecraft/inventory/ContainerMerchant.java @@ -0,0 +1,157 @@ +package net.minecraft.inventory; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.IMerchant; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class ContainerMerchant extends Container +{ + private IMerchant theMerchant; + private InventoryMerchant merchantInventory; + private final World theWorld; + private static final String __OBFID = "CL_00001757"; + + public ContainerMerchant(InventoryPlayer par1InventoryPlayer, IMerchant par2IMerchant, World par3World) + { + this.theMerchant = par2IMerchant; + this.theWorld = par3World; + this.merchantInventory = new InventoryMerchant(par1InventoryPlayer.player, par2IMerchant); + this.addSlotToContainer(new Slot(this.merchantInventory, 0, 36, 53)); + this.addSlotToContainer(new Slot(this.merchantInventory, 1, 62, 53)); + this.addSlotToContainer(new SlotMerchantResult(par1InventoryPlayer.player, par2IMerchant, this.merchantInventory, 2, 120, 53)); + int i; + + for (i = 0; i < 3; ++i) + { + for (int j = 0; j < 9; ++j) + { + this.addSlotToContainer(new Slot(par1InventoryPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + } + } + + for (i = 0; i < 9; ++i) + { + this.addSlotToContainer(new Slot(par1InventoryPlayer, i, 8 + i * 18, 142)); + } + } + + public InventoryMerchant getMerchantInventory() + { + return this.merchantInventory; + } + + public void addCraftingToCrafters(ICrafting par1ICrafting) + { + super.addCraftingToCrafters(par1ICrafting); + } + + public void detectAndSendChanges() + { + super.detectAndSendChanges(); + } + + public void onCraftMatrixChanged(IInventory par1IInventory) + { + this.merchantInventory.resetRecipeAndSlots(); + super.onCraftMatrixChanged(par1IInventory); + } + + public void setCurrentRecipeIndex(int par1) + { + this.merchantInventory.setCurrentRecipeIndex(par1); + } + + @SideOnly(Side.CLIENT) + public void updateProgressBar(int par1, int par2) {} + + public boolean canInteractWith(EntityPlayer par1EntityPlayer) + { + return this.theMerchant.getCustomer() == par1EntityPlayer; + } + + public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) + { + ItemStack itemstack = null; + Slot slot = (Slot)this.inventorySlots.get(par2); + + if (slot != null && slot.getHasStack()) + { + ItemStack itemstack1 = slot.getStack(); + itemstack = itemstack1.copy(); + + if (par2 == 2) + { + if (!this.mergeItemStack(itemstack1, 3, 39, true)) + { + return null; + } + + slot.onSlotChange(itemstack1, itemstack); + } + else if (par2 != 0 && par2 != 1) + { + if (par2 >= 3 && par2 < 30) + { + if (!this.mergeItemStack(itemstack1, 30, 39, false)) + { + return null; + } + } + else if (par2 >= 30 && par2 < 39 && !this.mergeItemStack(itemstack1, 3, 30, false)) + { + return null; + } + } + else if (!this.mergeItemStack(itemstack1, 3, 39, false)) + { + return null; + } + + if (itemstack1.stackSize == 0) + { + slot.putStack((ItemStack)null); + } + else + { + slot.onSlotChanged(); + } + + if (itemstack1.stackSize == itemstack.stackSize) + { + return null; + } + + slot.onPickupFromSlot(par1EntityPlayer, itemstack1); + } + + return itemstack; + } + + public void onContainerClosed(EntityPlayer par1EntityPlayer) + { + super.onContainerClosed(par1EntityPlayer); + this.theMerchant.setCustomer((EntityPlayer)null); + super.onContainerClosed(par1EntityPlayer); + + if (!this.theWorld.isRemote) + { + ItemStack itemstack = this.merchantInventory.getStackInSlotOnClosing(0); + + if (itemstack != null) + { + par1EntityPlayer.dropPlayerItemWithRandomChoice(itemstack, false); + } + + itemstack = this.merchantInventory.getStackInSlotOnClosing(1); + + if (itemstack != null) + { + par1EntityPlayer.dropPlayerItemWithRandomChoice(itemstack, false); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/inventory/ContainerPlayer.java b/src/main/java/net/minecraft/inventory/ContainerPlayer.java new file mode 100644 index 0000000..12ff7e1 --- /dev/null +++ b/src/main/java/net/minecraft/inventory/ContainerPlayer.java @@ -0,0 +1,190 @@ +package net.minecraft.inventory; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemArmor; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.util.IIcon; + +public class ContainerPlayer extends Container +{ + public InventoryCrafting craftMatrix = new InventoryCrafting(this, 2, 2); + public IInventory craftResult = new InventoryCraftResult(); + public boolean isLocalWorld; + private final EntityPlayer thePlayer; + private static final String __OBFID = "CL_00001754"; + + public ContainerPlayer(final InventoryPlayer par1InventoryPlayer, boolean par2, EntityPlayer par3EntityPlayer) + { + this.isLocalWorld = par2; + this.thePlayer = par3EntityPlayer; + this.addSlotToContainer(new SlotCrafting(par1InventoryPlayer.player, this.craftMatrix, this.craftResult, 0, 144, 36)); + int i; + int j; + + for (i = 0; i < 2; ++i) + { + for (j = 0; j < 2; ++j) + { + this.addSlotToContainer(new Slot(this.craftMatrix, j + i * 2, 88 + j * 18, 26 + i * 18)); + } + } + + for (i = 0; i < 4; ++i) + { + final int k = i; + this.addSlotToContainer(new Slot(par1InventoryPlayer, par1InventoryPlayer.getSizeInventory() - 1 - i, 8, 8 + i * 18) + { + private static final String __OBFID = "CL_00001755"; + public int getSlotStackLimit() + { + return 1; + } + public boolean isItemValid(ItemStack par1ItemStack) + { + if (par1ItemStack == null) return false; + return par1ItemStack.getItem().isValidArmor(par1ItemStack, k, thePlayer); + } + @SideOnly(Side.CLIENT) + public IIcon getBackgroundIconIndex() + { + return ItemArmor.func_94602_b(k); + } + }); + } + + for (i = 0; i < 3; ++i) + { + for (j = 0; j < 9; ++j) + { + this.addSlotToContainer(new Slot(par1InventoryPlayer, j + (i + 1) * 9, 8 + j * 18, 84 + i * 18)); + } + } + + for (i = 0; i < 9; ++i) + { + this.addSlotToContainer(new Slot(par1InventoryPlayer, i, 8 + i * 18, 142)); + } + + this.onCraftMatrixChanged(this.craftMatrix); + } + + public void onCraftMatrixChanged(IInventory par1IInventory) + { + this.craftResult.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(this.craftMatrix, this.thePlayer.worldObj)); + } + + public void onContainerClosed(EntityPlayer par1EntityPlayer) + { + super.onContainerClosed(par1EntityPlayer); + + for (int i = 0; i < 4; ++i) + { + ItemStack itemstack = this.craftMatrix.getStackInSlotOnClosing(i); + + if (itemstack != null) + { + par1EntityPlayer.dropPlayerItemWithRandomChoice(itemstack, false); + } + } + + this.craftResult.setInventorySlotContents(0, (ItemStack)null); + } + + public boolean canInteractWith(EntityPlayer par1EntityPlayer) + { + return true; + } + + public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) + { + ItemStack itemstack = null; + Slot slot = (Slot)this.inventorySlots.get(par2); + + if (slot != null && slot.getHasStack()) + { + ItemStack itemstack1 = slot.getStack(); + itemstack = itemstack1.copy(); + + if (par2 == 0) + { + if (!this.mergeItemStack(itemstack1, 9, 45, true)) + { + return null; + } + + slot.onSlotChange(itemstack1, itemstack); + } + else if (par2 >= 1 && par2 < 5) + { + if (!this.mergeItemStack(itemstack1, 9, 45, false)) + { + return null; + } + } + else if (par2 >= 5 && par2 < 9) + { + if (!this.mergeItemStack(itemstack1, 9, 45, false)) + { + return null; + } + } + else if (itemstack.getItem() instanceof ItemArmor && !((Slot)this.inventorySlots.get(5 + ((ItemArmor)itemstack.getItem()).armorType)).getHasStack()) + { + int j = 5 + ((ItemArmor)itemstack.getItem()).armorType; + + if (!this.mergeItemStack(itemstack1, j, j + 1, false)) + { + return null; + } + } + else if (par2 >= 9 && par2 < 36) + { + if (!this.mergeItemStack(itemstack1, 36, 45, false)) + { + return null; + } + } + else if (par2 >= 36 && par2 < 45) + { + if (!this.mergeItemStack(itemstack1, 9, 36, false)) + { + return null; + } + } + else if (!this.mergeItemStack(itemstack1, 9, 45, false)) + { + return null; + } + + if (itemstack1.stackSize == 0) + { + slot.putStack((ItemStack)null); + } + else + { + slot.onSlotChanged(); + } + + if (itemstack1.stackSize == itemstack.stackSize) + { + return null; + } + + slot.onPickupFromSlot(par1EntityPlayer, itemstack1); + } + + return itemstack; + } + + public boolean func_94530_a(ItemStack par1ItemStack, Slot par2Slot) + { + return par2Slot.inventory != this.craftResult && super.func_94530_a(par1ItemStack, par2Slot); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/inventory/ContainerRepair.java b/src/main/java/net/minecraft/inventory/ContainerRepair.java new file mode 100644 index 0000000..fc833b3 --- /dev/null +++ b/src/main/java/net/minecraft/inventory/ContainerRepair.java @@ -0,0 +1,535 @@ +package net.minecraft.inventory; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Iterator; +import java.util.Map; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraftforge.common.ForgeHooks; +import org.apache.commons.lang3.StringUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class ContainerRepair extends Container +{ + private static final Logger logger = LogManager.getLogger(); + private IInventory outputSlot = new InventoryCraftResult(); + private IInventory inputSlots = new InventoryBasic("Repair", true, 2) + { + private static final String __OBFID = "CL_00001733"; + public void markDirty() + { + super.markDirty(); + ContainerRepair.this.onCraftMatrixChanged(this); + } + }; + private World theWorld; + private int field_82861_i; + private int field_82858_j; + private int field_82859_k; + public int maximumCost; + private int stackSizeToBeUsedInRepair; + private String repairedItemName; + private final EntityPlayer thePlayer; + private static final String __OBFID = "CL_00001732"; + + public ContainerRepair(InventoryPlayer par1InventoryPlayer, final World par2World, final int par3, final int par4, final int par5, EntityPlayer par6EntityPlayer) + { + this.theWorld = par2World; + this.field_82861_i = par3; + this.field_82858_j = par4; + this.field_82859_k = par5; + this.thePlayer = par6EntityPlayer; + this.addSlotToContainer(new Slot(this.inputSlots, 0, 27, 47)); + this.addSlotToContainer(new Slot(this.inputSlots, 1, 76, 47)); + this.addSlotToContainer(new Slot(this.outputSlot, 2, 134, 47) + { + private static final String __OBFID = "CL_00001734"; + public boolean isItemValid(ItemStack par1ItemStack) + { + return false; + } + public boolean canTakeStack(EntityPlayer par1EntityPlayer) + { + return (par1EntityPlayer.capabilities.isCreativeMode || par1EntityPlayer.experienceLevel >= ContainerRepair.this.maximumCost) && ContainerRepair.this.maximumCost > 0 && this.getHasStack(); + } + public void onPickupFromSlot(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack) + { + if (!par1EntityPlayer.capabilities.isCreativeMode) + { + par1EntityPlayer.addExperienceLevel(-ContainerRepair.this.maximumCost); + } + + ContainerRepair.this.inputSlots.setInventorySlotContents(0, (ItemStack)null); + + if (ContainerRepair.this.stackSizeToBeUsedInRepair > 0) + { + ItemStack itemstack1 = ContainerRepair.this.inputSlots.getStackInSlot(1); + + if (itemstack1 != null && itemstack1.stackSize > ContainerRepair.this.stackSizeToBeUsedInRepair) + { + itemstack1.stackSize -= ContainerRepair.this.stackSizeToBeUsedInRepair; + ContainerRepair.this.inputSlots.setInventorySlotContents(1, itemstack1); + } + else + { + ContainerRepair.this.inputSlots.setInventorySlotContents(1, (ItemStack)null); + } + } + else + { + ContainerRepair.this.inputSlots.setInventorySlotContents(1, (ItemStack)null); + } + + ContainerRepair.this.maximumCost = 0; + + if (!par1EntityPlayer.capabilities.isCreativeMode && !par2World.isRemote && par2World.getBlock(par3, par4, par5) == Blocks.anvil && par1EntityPlayer.getRNG().nextFloat() < 0.12F) + { + int i1 = par2World.getBlockMetadata(par3, par4, par5); + int k = i1 & 3; + int l = i1 >> 2; + ++l; + + if (l > 2) + { + par2World.setBlockToAir(par3, par4, par5); + par2World.playAuxSFX(1020, par3, par4, par5, 0); + } + else + { + par2World.setBlockMetadataWithNotify(par3, par4, par5, k | l << 2, 2); + par2World.playAuxSFX(1021, par3, par4, par5, 0); + } + } + else if (!par2World.isRemote) + { + par2World.playAuxSFX(1021, par3, par4, par5, 0); + } + } + }); + int i; + + for (i = 0; i < 3; ++i) + { + for (int j = 0; j < 9; ++j) + { + this.addSlotToContainer(new Slot(par1InventoryPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + } + } + + for (i = 0; i < 9; ++i) + { + this.addSlotToContainer(new Slot(par1InventoryPlayer, i, 8 + i * 18, 142)); + } + } + + public void onCraftMatrixChanged(IInventory par1IInventory) + { + super.onCraftMatrixChanged(par1IInventory); + + if (par1IInventory == this.inputSlots) + { + this.updateRepairOutput(); + } + } + + public void updateRepairOutput() + { + ItemStack itemstack = this.inputSlots.getStackInSlot(0); + this.maximumCost = 0; + int i = 0; + byte b0 = 0; + int j = 0; + + if (itemstack == null) + { + this.outputSlot.setInventorySlotContents(0, (ItemStack)null); + this.maximumCost = 0; + } + else + { + ItemStack itemstack1 = itemstack.copy(); + ItemStack itemstack2 = this.inputSlots.getStackInSlot(1); + Map map = EnchantmentHelper.getEnchantments(itemstack1); + boolean flag = false; + int k2 = b0 + itemstack.getRepairCost() + (itemstack2 == null ? 0 : itemstack2.getRepairCost()); + this.stackSizeToBeUsedInRepair = 0; + int k; + int l; + int i1; + int k1; + int l1; + Iterator iterator1; + Enchantment enchantment; + + if (itemstack2 != null) + { + if (!ForgeHooks.onAnvilChange(this, itemstack, itemstack2, outputSlot, repairedItemName, k2)) return; + flag = itemstack2.getItem() == Items.enchanted_book && Items.enchanted_book.func_92110_g(itemstack2).tagCount() > 0; + + if (itemstack1.isItemStackDamageable() && itemstack1.getItem().getIsRepairable(itemstack, itemstack2)) + { + k = Math.min(itemstack1.getItemDamageForDisplay(), itemstack1.getMaxDamage() / 4); + + if (k <= 0) + { + this.outputSlot.setInventorySlotContents(0, (ItemStack)null); + this.maximumCost = 0; + return; + } + + for (l = 0; k > 0 && l < itemstack2.stackSize; ++l) + { + i1 = itemstack1.getItemDamageForDisplay() - k; + itemstack1.setItemDamage(i1); + i += Math.max(1, k / 100) + map.size(); + k = Math.min(itemstack1.getItemDamageForDisplay(), itemstack1.getMaxDamage() / 4); + } + + this.stackSizeToBeUsedInRepair = l; + } + else + { + if (!flag && (itemstack1.getItem() != itemstack2.getItem() || !itemstack1.isItemStackDamageable())) + { + this.outputSlot.setInventorySlotContents(0, (ItemStack)null); + this.maximumCost = 0; + return; + } + + if (itemstack1.isItemStackDamageable() && !flag) + { + k = itemstack.getMaxDamage() - itemstack.getItemDamageForDisplay(); + l = itemstack2.getMaxDamage() - itemstack2.getItemDamageForDisplay(); + i1 = l + itemstack1.getMaxDamage() * 12 / 100; + int j1 = k + i1; + k1 = itemstack1.getMaxDamage() - j1; + + if (k1 < 0) + { + k1 = 0; + } + + if (k1 < itemstack1.getItemDamage()) + { + itemstack1.setItemDamage(k1); + i += Math.max(1, i1 / 100); + } + } + + Map map1 = EnchantmentHelper.getEnchantments(itemstack2); + iterator1 = map1.keySet().iterator(); + + while (iterator1.hasNext()) + { + i1 = ((Integer)iterator1.next()).intValue(); + enchantment = Enchantment.enchantmentsList[i1]; + k1 = map.containsKey(Integer.valueOf(i1)) ? ((Integer)map.get(Integer.valueOf(i1))).intValue() : 0; + l1 = ((Integer)map1.get(Integer.valueOf(i1))).intValue(); + int i3; + + if (k1 == l1) + { + ++l1; + i3 = l1; + } + else + { + i3 = Math.max(l1, k1); + } + + l1 = i3; + int i2 = l1 - k1; + boolean flag1 = enchantment.canApply(itemstack); + + if (this.thePlayer.capabilities.isCreativeMode || itemstack.getItem() == Items.enchanted_book) + { + flag1 = true; + } + + Iterator iterator = map.keySet().iterator(); + + while (iterator.hasNext()) + { + int j2 = ((Integer)iterator.next()).intValue(); + + if (j2 != i1 && !enchantment.canApplyTogether(Enchantment.enchantmentsList[j2])) + { + flag1 = false; + i += i2; + } + } + + if (flag1) + { + if (l1 > enchantment.getMaxLevel()) + { + l1 = enchantment.getMaxLevel(); + } + + map.put(Integer.valueOf(i1), Integer.valueOf(l1)); + int l2 = 0; + + switch (enchantment.getWeight()) + { + case 1: + l2 = 8; + break; + case 2: + l2 = 4; + case 3: + case 4: + case 6: + case 7: + case 8: + case 9: + default: + break; + case 5: + l2 = 2; + break; + case 10: + l2 = 1; + } + + if (flag) + { + l2 = Math.max(1, l2 / 2); + } + + i += l2 * i2; + } + } + } + } + + if (StringUtils.isBlank(this.repairedItemName)) + { + if (itemstack.hasDisplayName()) + { + j = itemstack.isItemStackDamageable() ? 7 : itemstack.stackSize * 5; + i += j; + itemstack1.func_135074_t(); + } + } + else if (!this.repairedItemName.equals(itemstack.getDisplayName())) + { + j = itemstack.isItemStackDamageable() ? 7 : itemstack.stackSize * 5; + i += j; + + if (itemstack.hasDisplayName()) + { + k2 += j / 2; + } + + itemstack1.setStackDisplayName(this.repairedItemName); + } + + k = 0; + + for (iterator1 = map.keySet().iterator(); iterator1.hasNext(); k2 += k + k1 * l1) + { + i1 = ((Integer)iterator1.next()).intValue(); + enchantment = Enchantment.enchantmentsList[i1]; + k1 = ((Integer)map.get(Integer.valueOf(i1))).intValue(); + l1 = 0; + ++k; + + switch (enchantment.getWeight()) + { + case 1: + l1 = 8; + break; + case 2: + l1 = 4; + case 3: + case 4: + case 6: + case 7: + case 8: + case 9: + default: + break; + case 5: + l1 = 2; + break; + case 10: + l1 = 1; + } + + if (flag) + { + l1 = Math.max(1, l1 / 2); + } + } + + if (flag) + { + k2 = Math.max(1, k2 / 2); + } + + if (flag && !itemstack1.getItem().isBookEnchantable(itemstack1, itemstack2)) itemstack1 = null; + + this.maximumCost = k2 + i; + + if (i <= 0) + { + itemstack1 = null; + } + + if (j == i && j > 0 && this.maximumCost >= 40) + { + this.maximumCost = 39; + } + + if (this.maximumCost >= 40 && !this.thePlayer.capabilities.isCreativeMode) + { + itemstack1 = null; + } + + if (itemstack1 != null) + { + l = itemstack1.getRepairCost(); + + if (itemstack2 != null && l < itemstack2.getRepairCost()) + { + l = itemstack2.getRepairCost(); + } + + if (itemstack1.hasDisplayName()) + { + l -= 9; + } + + if (l < 0) + { + l = 0; + } + + l += 2; + itemstack1.setRepairCost(l); + EnchantmentHelper.setEnchantments(map, itemstack1); + } + + this.outputSlot.setInventorySlotContents(0, itemstack1); + this.detectAndSendChanges(); + } + } + + public void addCraftingToCrafters(ICrafting par1ICrafting) + { + super.addCraftingToCrafters(par1ICrafting); + par1ICrafting.sendProgressBarUpdate(this, 0, this.maximumCost); + } + + @SideOnly(Side.CLIENT) + public void updateProgressBar(int par1, int par2) + { + if (par1 == 0) + { + this.maximumCost = par2; + } + } + + public void onContainerClosed(EntityPlayer par1EntityPlayer) + { + super.onContainerClosed(par1EntityPlayer); + + if (!this.theWorld.isRemote) + { + for (int i = 0; i < this.inputSlots.getSizeInventory(); ++i) + { + ItemStack itemstack = this.inputSlots.getStackInSlotOnClosing(i); + + if (itemstack != null) + { + par1EntityPlayer.dropPlayerItemWithRandomChoice(itemstack, false); + } + } + } + } + + public boolean canInteractWith(EntityPlayer par1EntityPlayer) + { + return this.theWorld.getBlock(this.field_82861_i, this.field_82858_j, this.field_82859_k) != Blocks.anvil ? false : par1EntityPlayer.getDistanceSq((double)this.field_82861_i + 0.5D, (double)this.field_82858_j + 0.5D, (double)this.field_82859_k + 0.5D) <= 64.0D; + } + + public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) + { + ItemStack itemstack = null; + Slot slot = (Slot)this.inventorySlots.get(par2); + + if (slot != null && slot.getHasStack()) + { + ItemStack itemstack1 = slot.getStack(); + itemstack = itemstack1.copy(); + + if (par2 == 2) + { + if (!this.mergeItemStack(itemstack1, 3, 39, true)) + { + return null; + } + + slot.onSlotChange(itemstack1, itemstack); + } + else if (par2 != 0 && par2 != 1) + { + if (par2 >= 3 && par2 < 39 && !this.mergeItemStack(itemstack1, 0, 2, false)) + { + return null; + } + } + else if (!this.mergeItemStack(itemstack1, 3, 39, false)) + { + return null; + } + + if (itemstack1.stackSize == 0) + { + slot.putStack((ItemStack)null); + } + else + { + slot.onSlotChanged(); + } + + if (itemstack1.stackSize == itemstack.stackSize) + { + return null; + } + + slot.onPickupFromSlot(par1EntityPlayer, itemstack1); + } + + return itemstack; + } + + public void updateItemName(String par1Str) + { + this.repairedItemName = par1Str; + + if (this.getSlot(2).getHasStack()) + { + ItemStack itemstack = this.getSlot(2).getStack(); + + if (StringUtils.isBlank(par1Str)) + { + itemstack.func_135074_t(); + } + else + { + itemstack.setStackDisplayName(this.repairedItemName); + } + } + + this.updateRepairOutput(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/inventory/ContainerWorkbench.java b/src/main/java/net/minecraft/inventory/ContainerWorkbench.java new file mode 100644 index 0000000..fb397d0 --- /dev/null +++ b/src/main/java/net/minecraft/inventory/ContainerWorkbench.java @@ -0,0 +1,144 @@ +package net.minecraft.inventory; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.world.World; + +public class ContainerWorkbench extends Container +{ + public InventoryCrafting craftMatrix = new InventoryCrafting(this, 3, 3); + public IInventory craftResult = new InventoryCraftResult(); + private World worldObj; + private int posX; + private int posY; + private int posZ; + private static final String __OBFID = "CL_00001744"; + + public ContainerWorkbench(InventoryPlayer par1InventoryPlayer, World par2World, int par3, int par4, int par5) + { + this.worldObj = par2World; + this.posX = par3; + this.posY = par4; + this.posZ = par5; + this.addSlotToContainer(new SlotCrafting(par1InventoryPlayer.player, this.craftMatrix, this.craftResult, 0, 124, 35)); + int l; + int i1; + + for (l = 0; l < 3; ++l) + { + for (i1 = 0; i1 < 3; ++i1) + { + this.addSlotToContainer(new Slot(this.craftMatrix, i1 + l * 3, 30 + i1 * 18, 17 + l * 18)); + } + } + + for (l = 0; l < 3; ++l) + { + for (i1 = 0; i1 < 9; ++i1) + { + this.addSlotToContainer(new Slot(par1InventoryPlayer, i1 + l * 9 + 9, 8 + i1 * 18, 84 + l * 18)); + } + } + + for (l = 0; l < 9; ++l) + { + this.addSlotToContainer(new Slot(par1InventoryPlayer, l, 8 + l * 18, 142)); + } + + this.onCraftMatrixChanged(this.craftMatrix); + } + + public void onCraftMatrixChanged(IInventory par1IInventory) + { + this.craftResult.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(this.craftMatrix, this.worldObj)); + } + + public void onContainerClosed(EntityPlayer par1EntityPlayer) + { + super.onContainerClosed(par1EntityPlayer); + + if (!this.worldObj.isRemote) + { + for (int i = 0; i < 9; ++i) + { + ItemStack itemstack = this.craftMatrix.getStackInSlotOnClosing(i); + + if (itemstack != null) + { + par1EntityPlayer.dropPlayerItemWithRandomChoice(itemstack, false); + } + } + } + } + + public boolean canInteractWith(EntityPlayer par1EntityPlayer) + { + return this.worldObj.getBlock(this.posX, this.posY, this.posZ) != Blocks.crafting_table ? false : par1EntityPlayer.getDistanceSq((double)this.posX + 0.5D, (double)this.posY + 0.5D, (double)this.posZ + 0.5D) <= 64.0D; + } + + public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) + { + ItemStack itemstack = null; + Slot slot = (Slot)this.inventorySlots.get(par2); + + if (slot != null && slot.getHasStack()) + { + ItemStack itemstack1 = slot.getStack(); + itemstack = itemstack1.copy(); + + if (par2 == 0) + { + if (!this.mergeItemStack(itemstack1, 10, 46, true)) + { + return null; + } + + slot.onSlotChange(itemstack1, itemstack); + } + else if (par2 >= 10 && par2 < 37) + { + if (!this.mergeItemStack(itemstack1, 37, 46, false)) + { + return null; + } + } + else if (par2 >= 37 && par2 < 46) + { + if (!this.mergeItemStack(itemstack1, 10, 37, false)) + { + return null; + } + } + else if (!this.mergeItemStack(itemstack1, 10, 46, false)) + { + return null; + } + + if (itemstack1.stackSize == 0) + { + slot.putStack((ItemStack)null); + } + else + { + slot.onSlotChanged(); + } + + if (itemstack1.stackSize == itemstack.stackSize) + { + return null; + } + + slot.onPickupFromSlot(par1EntityPlayer, itemstack1); + } + + return itemstack; + } + + public boolean func_94530_a(ItemStack par1ItemStack, Slot par2Slot) + { + return par2Slot.inventory != this.craftResult && super.func_94530_a(par1ItemStack, par2Slot); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/inventory/ICrafting.java b/src/main/java/net/minecraft/inventory/ICrafting.java new file mode 100644 index 0000000..c03f515 --- /dev/null +++ b/src/main/java/net/minecraft/inventory/ICrafting.java @@ -0,0 +1,13 @@ +package net.minecraft.inventory; + +import java.util.List; +import net.minecraft.item.ItemStack; + +public interface ICrafting +{ + void sendContainerAndContentsToPlayer(Container var1, List var2); + + void sendSlotContents(Container var1, int var2, ItemStack var3); + + void sendProgressBarUpdate(Container var1, int var2, int var3); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/inventory/IInvBasic.java b/src/main/java/net/minecraft/inventory/IInvBasic.java new file mode 100644 index 0000000..573dbfb --- /dev/null +++ b/src/main/java/net/minecraft/inventory/IInvBasic.java @@ -0,0 +1,6 @@ +package net.minecraft.inventory; + +public interface IInvBasic +{ + void onInventoryChanged(InventoryBasic var1); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/inventory/IInventory.java b/src/main/java/net/minecraft/inventory/IInventory.java new file mode 100644 index 0000000..0f17597 --- /dev/null +++ b/src/main/java/net/minecraft/inventory/IInventory.java @@ -0,0 +1,33 @@ +package net.minecraft.inventory; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +public interface IInventory +{ + int getSizeInventory(); + + ItemStack getStackInSlot(int var1); + + ItemStack decrStackSize(int var1, int var2); + + ItemStack getStackInSlotOnClosing(int var1); + + void setInventorySlotContents(int var1, ItemStack var2); + + String getInventoryName(); + + boolean hasCustomInventoryName(); + + int getInventoryStackLimit(); + + void markDirty(); + + boolean isUseableByPlayer(EntityPlayer var1); + + void openInventory(); + + void closeInventory(); + + boolean isItemValidForSlot(int var1, ItemStack var2); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/inventory/ISidedInventory.java b/src/main/java/net/minecraft/inventory/ISidedInventory.java new file mode 100644 index 0000000..1bf4bb6 --- /dev/null +++ b/src/main/java/net/minecraft/inventory/ISidedInventory.java @@ -0,0 +1,12 @@ +package net.minecraft.inventory; + +import net.minecraft.item.ItemStack; + +public interface ISidedInventory extends IInventory +{ + int[] getAccessibleSlotsFromSide(int var1); + + boolean canInsertItem(int var1, ItemStack var2, int var3); + + boolean canExtractItem(int var1, ItemStack var2, int var3); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/inventory/InventoryBasic.java b/src/main/java/net/minecraft/inventory/InventoryBasic.java new file mode 100644 index 0000000..fe892a0 --- /dev/null +++ b/src/main/java/net/minecraft/inventory/InventoryBasic.java @@ -0,0 +1,153 @@ +package net.minecraft.inventory; + +import java.util.ArrayList; +import java.util.List; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +public class InventoryBasic implements IInventory +{ + private String inventoryTitle; + private int slotsCount; + private ItemStack[] inventoryContents; + private List field_70480_d; + private boolean field_94051_e; + private static final String __OBFID = "CL_00001514"; + + public InventoryBasic(String par1Str, boolean par2, int par3) + { + this.inventoryTitle = par1Str; + this.field_94051_e = par2; + this.slotsCount = par3; + this.inventoryContents = new ItemStack[par3]; + } + + public void func_110134_a(IInvBasic par1IInvBasic) + { + if (this.field_70480_d == null) + { + this.field_70480_d = new ArrayList(); + } + + this.field_70480_d.add(par1IInvBasic); + } + + public void func_110132_b(IInvBasic par1IInvBasic) + { + this.field_70480_d.remove(par1IInvBasic); + } + + public ItemStack getStackInSlot(int par1) + { + return this.inventoryContents[par1]; + } + + public ItemStack decrStackSize(int par1, int par2) + { + if (this.inventoryContents[par1] != null) + { + ItemStack itemstack; + + if (this.inventoryContents[par1].stackSize <= par2) + { + itemstack = this.inventoryContents[par1]; + this.inventoryContents[par1] = null; + this.markDirty(); + return itemstack; + } + else + { + itemstack = this.inventoryContents[par1].splitStack(par2); + + if (this.inventoryContents[par1].stackSize == 0) + { + this.inventoryContents[par1] = null; + } + + this.markDirty(); + return itemstack; + } + } + else + { + return null; + } + } + + public ItemStack getStackInSlotOnClosing(int par1) + { + if (this.inventoryContents[par1] != null) + { + ItemStack itemstack = this.inventoryContents[par1]; + this.inventoryContents[par1] = null; + return itemstack; + } + else + { + return null; + } + } + + public void setInventorySlotContents(int par1, ItemStack par2ItemStack) + { + this.inventoryContents[par1] = par2ItemStack; + + if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit()) + { + par2ItemStack.stackSize = this.getInventoryStackLimit(); + } + + this.markDirty(); + } + + public int getSizeInventory() + { + return this.slotsCount; + } + + public String getInventoryName() + { + return this.inventoryTitle; + } + + public boolean hasCustomInventoryName() + { + return this.field_94051_e; + } + + public void func_110133_a(String par1Str) + { + this.field_94051_e = true; + this.inventoryTitle = par1Str; + } + + public int getInventoryStackLimit() + { + return 64; + } + + public void markDirty() + { + if (this.field_70480_d != null) + { + for (int i = 0; i < this.field_70480_d.size(); ++i) + { + ((IInvBasic)this.field_70480_d.get(i)).onInventoryChanged(this); + } + } + } + + public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) + { + return true; + } + + public void openInventory() {} + + public void closeInventory() {} + + public boolean isItemValidForSlot(int par1, ItemStack par2ItemStack) + { + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/inventory/InventoryCraftResult.java b/src/main/java/net/minecraft/inventory/InventoryCraftResult.java new file mode 100644 index 0000000..8f749cc --- /dev/null +++ b/src/main/java/net/minecraft/inventory/InventoryCraftResult.java @@ -0,0 +1,84 @@ +package net.minecraft.inventory; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +public class InventoryCraftResult implements IInventory +{ + private ItemStack[] stackResult = new ItemStack[1]; + private static final String __OBFID = "CL_00001760"; + + public int getSizeInventory() + { + return 1; + } + + public ItemStack getStackInSlot(int par1) + { + return this.stackResult[0]; + } + + public String getInventoryName() + { + return "Result"; + } + + public boolean hasCustomInventoryName() + { + return false; + } + + public ItemStack decrStackSize(int par1, int par2) + { + if (this.stackResult[0] != null) + { + ItemStack itemstack = this.stackResult[0]; + this.stackResult[0] = null; + return itemstack; + } + else + { + return null; + } + } + + public ItemStack getStackInSlotOnClosing(int par1) + { + if (this.stackResult[0] != null) + { + ItemStack itemstack = this.stackResult[0]; + this.stackResult[0] = null; + return itemstack; + } + else + { + return null; + } + } + + public void setInventorySlotContents(int par1, ItemStack par2ItemStack) + { + this.stackResult[0] = par2ItemStack; + } + + public int getInventoryStackLimit() + { + return 64; + } + + public void markDirty() {} + + public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) + { + return true; + } + + public void openInventory() {} + + public void closeInventory() {} + + public boolean isItemValidForSlot(int par1, ItemStack par2ItemStack) + { + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/inventory/InventoryCrafting.java b/src/main/java/net/minecraft/inventory/InventoryCrafting.java new file mode 100644 index 0000000..2c96448 --- /dev/null +++ b/src/main/java/net/minecraft/inventory/InventoryCrafting.java @@ -0,0 +1,126 @@ +package net.minecraft.inventory; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +public class InventoryCrafting implements IInventory +{ + private ItemStack[] stackList; + private int inventoryWidth; + private Container eventHandler; + private static final String __OBFID = "CL_00001743"; + + public InventoryCrafting(Container par1Container, int par2, int par3) + { + int k = par2 * par3; + this.stackList = new ItemStack[k]; + this.eventHandler = par1Container; + this.inventoryWidth = par2; + } + + public int getSizeInventory() + { + return this.stackList.length; + } + + public ItemStack getStackInSlot(int par1) + { + return par1 >= this.getSizeInventory() ? null : this.stackList[par1]; + } + + public ItemStack getStackInRowAndColumn(int par1, int par2) + { + if (par1 >= 0 && par1 < this.inventoryWidth) + { + int k = par1 + par2 * this.inventoryWidth; + return this.getStackInSlot(k); + } + else + { + return null; + } + } + + public String getInventoryName() + { + return "container.crafting"; + } + + public boolean hasCustomInventoryName() + { + return false; + } + + public ItemStack getStackInSlotOnClosing(int par1) + { + if (this.stackList[par1] != null) + { + ItemStack itemstack = this.stackList[par1]; + this.stackList[par1] = null; + return itemstack; + } + else + { + return null; + } + } + + public ItemStack decrStackSize(int par1, int par2) + { + if (this.stackList[par1] != null) + { + ItemStack itemstack; + + if (this.stackList[par1].stackSize <= par2) + { + itemstack = this.stackList[par1]; + this.stackList[par1] = null; + this.eventHandler.onCraftMatrixChanged(this); + return itemstack; + } + else + { + itemstack = this.stackList[par1].splitStack(par2); + + if (this.stackList[par1].stackSize == 0) + { + this.stackList[par1] = null; + } + + this.eventHandler.onCraftMatrixChanged(this); + return itemstack; + } + } + else + { + return null; + } + } + + public void setInventorySlotContents(int par1, ItemStack par2ItemStack) + { + this.stackList[par1] = par2ItemStack; + this.eventHandler.onCraftMatrixChanged(this); + } + + public int getInventoryStackLimit() + { + return 64; + } + + public void markDirty() {} + + public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) + { + return true; + } + + public void openInventory() {} + + public void closeInventory() {} + + public boolean isItemValidForSlot(int par1, ItemStack par2ItemStack) + { + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/inventory/InventoryEnderChest.java b/src/main/java/net/minecraft/inventory/InventoryEnderChest.java new file mode 100644 index 0000000..83ab74a --- /dev/null +++ b/src/main/java/net/minecraft/inventory/InventoryEnderChest.java @@ -0,0 +1,90 @@ +package net.minecraft.inventory; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.tileentity.TileEntityEnderChest; + +public class InventoryEnderChest extends InventoryBasic +{ + private TileEntityEnderChest associatedChest; + private static final String __OBFID = "CL_00001759"; + + public InventoryEnderChest() + { + super("container.enderchest", false, 27); + } + + public void func_146031_a(TileEntityEnderChest p_146031_1_) + { + this.associatedChest = p_146031_1_; + } + + public void loadInventoryFromNBT(NBTTagList par1NBTTagList) + { + int i; + + for (i = 0; i < this.getSizeInventory(); ++i) + { + this.setInventorySlotContents(i, (ItemStack)null); + } + + for (i = 0; i < par1NBTTagList.tagCount(); ++i) + { + NBTTagCompound nbttagcompound = par1NBTTagList.getCompoundTagAt(i); + int j = nbttagcompound.getByte("Slot") & 255; + + if (j >= 0 && j < this.getSizeInventory()) + { + this.setInventorySlotContents(j, ItemStack.loadItemStackFromNBT(nbttagcompound)); + } + } + } + + public NBTTagList saveInventoryToNBT() + { + NBTTagList nbttaglist = new NBTTagList(); + + for (int i = 0; i < this.getSizeInventory(); ++i) + { + ItemStack itemstack = this.getStackInSlot(i); + + if (itemstack != null) + { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + nbttagcompound.setByte("Slot", (byte)i); + itemstack.writeToNBT(nbttagcompound); + nbttaglist.appendTag(nbttagcompound); + } + } + + return nbttaglist; + } + + public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) + { + return this.associatedChest != null && !this.associatedChest.func_145971_a(par1EntityPlayer) ? false : super.isUseableByPlayer(par1EntityPlayer); + } + + public void openInventory() + { + if (this.associatedChest != null) + { + this.associatedChest.func_145969_a(); + } + + super.openInventory(); + } + + public void closeInventory() + { + if (this.associatedChest != null) + { + this.associatedChest.func_145970_b(); + } + + super.closeInventory(); + this.associatedChest = null; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/inventory/InventoryLargeChest.java b/src/main/java/net/minecraft/inventory/InventoryLargeChest.java new file mode 100644 index 0000000..746d135 --- /dev/null +++ b/src/main/java/net/minecraft/inventory/InventoryLargeChest.java @@ -0,0 +1,110 @@ +package net.minecraft.inventory; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +public class InventoryLargeChest implements IInventory +{ + private String name; + private IInventory upperChest; + private IInventory lowerChest; + private static final String __OBFID = "CL_00001507"; + + public InventoryLargeChest(String par1Str, IInventory par2IInventory, IInventory par3IInventory) + { + this.name = par1Str; + + if (par2IInventory == null) + { + par2IInventory = par3IInventory; + } + + if (par3IInventory == null) + { + par3IInventory = par2IInventory; + } + + this.upperChest = par2IInventory; + this.lowerChest = par3IInventory; + } + + public int getSizeInventory() + { + return this.upperChest.getSizeInventory() + this.lowerChest.getSizeInventory(); + } + + public boolean isPartOfLargeChest(IInventory par1IInventory) + { + return this.upperChest == par1IInventory || this.lowerChest == par1IInventory; + } + + public String getInventoryName() + { + return this.upperChest.hasCustomInventoryName() ? this.upperChest.getInventoryName() : (this.lowerChest.hasCustomInventoryName() ? this.lowerChest.getInventoryName() : this.name); + } + + public boolean hasCustomInventoryName() + { + return this.upperChest.hasCustomInventoryName() || this.lowerChest.hasCustomInventoryName(); + } + + public ItemStack getStackInSlot(int par1) + { + return par1 >= this.upperChest.getSizeInventory() ? this.lowerChest.getStackInSlot(par1 - this.upperChest.getSizeInventory()) : this.upperChest.getStackInSlot(par1); + } + + public ItemStack decrStackSize(int par1, int par2) + { + return par1 >= this.upperChest.getSizeInventory() ? this.lowerChest.decrStackSize(par1 - this.upperChest.getSizeInventory(), par2) : this.upperChest.decrStackSize(par1, par2); + } + + public ItemStack getStackInSlotOnClosing(int par1) + { + return par1 >= this.upperChest.getSizeInventory() ? this.lowerChest.getStackInSlotOnClosing(par1 - this.upperChest.getSizeInventory()) : this.upperChest.getStackInSlotOnClosing(par1); + } + + public void setInventorySlotContents(int par1, ItemStack par2ItemStack) + { + if (par1 >= this.upperChest.getSizeInventory()) + { + this.lowerChest.setInventorySlotContents(par1 - this.upperChest.getSizeInventory(), par2ItemStack); + } + else + { + this.upperChest.setInventorySlotContents(par1, par2ItemStack); + } + } + + public int getInventoryStackLimit() + { + return this.upperChest.getInventoryStackLimit(); + } + + public void markDirty() + { + this.upperChest.markDirty(); + this.lowerChest.markDirty(); + } + + public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) + { + return this.upperChest.isUseableByPlayer(par1EntityPlayer) && this.lowerChest.isUseableByPlayer(par1EntityPlayer); + } + + public void openInventory() + { + this.upperChest.openInventory(); + this.lowerChest.openInventory(); + } + + public void closeInventory() + { + this.upperChest.closeInventory(); + this.lowerChest.closeInventory(); + } + + public boolean isItemValidForSlot(int par1, ItemStack par2ItemStack) + { + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/inventory/InventoryMerchant.java b/src/main/java/net/minecraft/inventory/InventoryMerchant.java new file mode 100644 index 0000000..a5ecf84 --- /dev/null +++ b/src/main/java/net/minecraft/inventory/InventoryMerchant.java @@ -0,0 +1,212 @@ +package net.minecraft.inventory; + +import net.minecraft.entity.IMerchant; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.village.MerchantRecipe; +import net.minecraft.village.MerchantRecipeList; + +public class InventoryMerchant implements IInventory +{ + private final IMerchant theMerchant; + private ItemStack[] theInventory = new ItemStack[3]; + private final EntityPlayer thePlayer; + private MerchantRecipe currentRecipe; + private int currentRecipeIndex; + private static final String __OBFID = "CL_00001756"; + + public InventoryMerchant(EntityPlayer par1EntityPlayer, IMerchant par2IMerchant) + { + this.thePlayer = par1EntityPlayer; + this.theMerchant = par2IMerchant; + } + + public int getSizeInventory() + { + return this.theInventory.length; + } + + public ItemStack getStackInSlot(int par1) + { + return this.theInventory[par1]; + } + + public ItemStack decrStackSize(int par1, int par2) + { + if (this.theInventory[par1] != null) + { + ItemStack itemstack; + + if (par1 == 2) + { + itemstack = this.theInventory[par1]; + this.theInventory[par1] = null; + return itemstack; + } + else if (this.theInventory[par1].stackSize <= par2) + { + itemstack = this.theInventory[par1]; + this.theInventory[par1] = null; + + if (this.inventoryResetNeededOnSlotChange(par1)) + { + this.resetRecipeAndSlots(); + } + + return itemstack; + } + else + { + itemstack = this.theInventory[par1].splitStack(par2); + + if (this.theInventory[par1].stackSize == 0) + { + this.theInventory[par1] = null; + } + + if (this.inventoryResetNeededOnSlotChange(par1)) + { + this.resetRecipeAndSlots(); + } + + return itemstack; + } + } + else + { + return null; + } + } + + private boolean inventoryResetNeededOnSlotChange(int par1) + { + return par1 == 0 || par1 == 1; + } + + public ItemStack getStackInSlotOnClosing(int par1) + { + if (this.theInventory[par1] != null) + { + ItemStack itemstack = this.theInventory[par1]; + this.theInventory[par1] = null; + return itemstack; + } + else + { + return null; + } + } + + public void setInventorySlotContents(int par1, ItemStack par2ItemStack) + { + this.theInventory[par1] = par2ItemStack; + + if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit()) + { + par2ItemStack.stackSize = this.getInventoryStackLimit(); + } + + if (this.inventoryResetNeededOnSlotChange(par1)) + { + this.resetRecipeAndSlots(); + } + } + + public String getInventoryName() + { + return "mob.villager"; + } + + public boolean hasCustomInventoryName() + { + return false; + } + + public int getInventoryStackLimit() + { + return 64; + } + + public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) + { + return this.theMerchant.getCustomer() == par1EntityPlayer; + } + + public void openInventory() {} + + public void closeInventory() {} + + public boolean isItemValidForSlot(int par1, ItemStack par2ItemStack) + { + return true; + } + + public void markDirty() + { + this.resetRecipeAndSlots(); + } + + public void resetRecipeAndSlots() + { + this.currentRecipe = null; + ItemStack itemstack = this.theInventory[0]; + ItemStack itemstack1 = this.theInventory[1]; + + if (itemstack == null) + { + itemstack = itemstack1; + itemstack1 = null; + } + + if (itemstack == null) + { + this.setInventorySlotContents(2, (ItemStack)null); + } + else + { + MerchantRecipeList merchantrecipelist = this.theMerchant.getRecipes(this.thePlayer); + + if (merchantrecipelist != null) + { + MerchantRecipe merchantrecipe = merchantrecipelist.canRecipeBeUsed(itemstack, itemstack1, this.currentRecipeIndex); + + if (merchantrecipe != null && !merchantrecipe.isRecipeDisabled()) + { + this.currentRecipe = merchantrecipe; + this.setInventorySlotContents(2, merchantrecipe.getItemToSell().copy()); + } + else if (itemstack1 != null) + { + merchantrecipe = merchantrecipelist.canRecipeBeUsed(itemstack1, itemstack, this.currentRecipeIndex); + + if (merchantrecipe != null && !merchantrecipe.isRecipeDisabled()) + { + this.currentRecipe = merchantrecipe; + this.setInventorySlotContents(2, merchantrecipe.getItemToSell().copy()); + } + else + { + this.setInventorySlotContents(2, (ItemStack)null); + } + } + else + { + this.setInventorySlotContents(2, (ItemStack)null); + } + } + } + + this.theMerchant.func_110297_a_(this.getStackInSlot(2)); + } + + public MerchantRecipe getCurrentRecipe() + { + return this.currentRecipe; + } + + public void setCurrentRecipeIndex(int par1) + { + this.currentRecipeIndex = par1; + this.resetRecipeAndSlots(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/inventory/Slot.java b/src/main/java/net/minecraft/inventory/Slot.java new file mode 100644 index 0000000..4294b23 --- /dev/null +++ b/src/main/java/net/minecraft/inventory/Slot.java @@ -0,0 +1,159 @@ +package net.minecraft.inventory; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; + +public class Slot +{ + private final int slotIndex; + public final IInventory inventory; + public int slotNumber; + public int xDisplayPosition; + public int yDisplayPosition; + private static final String __OBFID = "CL_00001762"; + + /** Position within background texture file, normally -1 which causes no background to be drawn. */ + protected IIcon backgroundIcon = null; + + /** Background texture file assigned to this slot, if any. Vanilla "/gui/items.png" is used if this is null. */ + @SideOnly(Side.CLIENT) + protected ResourceLocation texture; + + public Slot(IInventory par1IInventory, int par2, int par3, int par4) + { + this.inventory = par1IInventory; + this.slotIndex = par2; + this.xDisplayPosition = par3; + this.yDisplayPosition = par4; + } + + public void onSlotChange(ItemStack par1ItemStack, ItemStack par2ItemStack) + { + if (par1ItemStack != null && par2ItemStack != null) + { + if (par1ItemStack.getItem() == par2ItemStack.getItem()) + { + int i = par2ItemStack.stackSize - par1ItemStack.stackSize; + + if (i > 0) + { + this.onCrafting(par1ItemStack, i); + } + } + } + } + + protected void onCrafting(ItemStack par1ItemStack, int par2) {} + + protected void onCrafting(ItemStack par1ItemStack) {} + + public void onPickupFromSlot(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack) + { + this.onSlotChanged(); + } + + public boolean isItemValid(ItemStack par1ItemStack) + { + return true; + } + + public ItemStack getStack() + { + return this.inventory.getStackInSlot(this.slotIndex); + } + + public boolean getHasStack() + { + return this.getStack() != null; + } + + public void putStack(ItemStack par1ItemStack) + { + this.inventory.setInventorySlotContents(this.slotIndex, par1ItemStack); + this.onSlotChanged(); + } + + public void onSlotChanged() + { + this.inventory.markDirty(); + } + + public int getSlotStackLimit() + { + return this.inventory.getInventoryStackLimit(); + } + + public ItemStack decrStackSize(int par1) + { + return this.inventory.decrStackSize(this.slotIndex, par1); + } + + public boolean isSlotInInventory(IInventory par1IInventory, int par2) + { + return par1IInventory == this.inventory && par2 == this.slotIndex; + } + + public boolean canTakeStack(EntityPlayer par1EntityPlayer) + { + return true; + } + + @SideOnly(Side.CLIENT) + public IIcon getBackgroundIconIndex() + { + return backgroundIcon; + } + + @SideOnly(Side.CLIENT) + public boolean func_111238_b() + { + return true; + } + + /*========================================= FORGE START =====================================*/ + /** + * Gets the path of the texture file to use for the background image of this slot when drawing the GUI. + * @return String: The texture file that will be used in GuiContainer.drawSlotInventory for the slot background. + */ + @SideOnly(Side.CLIENT) + public ResourceLocation getBackgroundIconTexture() + { + return (texture == null ? TextureMap.locationItemsTexture : texture); + } + + /** + * Sets which icon index to use as the background image of the slot when it's empty. + * @param icon The icon to use, null for none + */ + public void setBackgroundIcon(IIcon icon) + { + backgroundIcon = icon; + } + + /** + * Sets the texture file to use for the background image of the slot when it's empty. + * @param textureFilename String: Path of texture file to use, or null to use "/gui/items.png" + */ + @SideOnly(Side.CLIENT) + public void setBackgroundIconTexture(ResourceLocation texture) + { + this.texture = texture; + } + + /** + * Retrieves the index in the inventory for this slot, this value should typically not + * be used, but can be useful for some occasions. + * + * @return Index in associated inventory for this slot. + */ + public int getSlotIndex() + { + return slotIndex; + } + /*========================================= FORGE END =====================================*/ +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/inventory/SlotCrafting.java b/src/main/java/net/minecraft/inventory/SlotCrafting.java new file mode 100644 index 0000000..568d56e --- /dev/null +++ b/src/main/java/net/minecraft/inventory/SlotCrafting.java @@ -0,0 +1,145 @@ +package net.minecraft.inventory; + +import cpw.mods.fml.common.FMLCommonHandler; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemHoe; +import net.minecraft.item.ItemPickaxe; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemSword; +import net.minecraft.stats.AchievementList; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent; + +public class SlotCrafting extends Slot +{ + private final IInventory craftMatrix; + private EntityPlayer thePlayer; + private int amountCrafted; + private static final String __OBFID = "CL_00001761"; + + public SlotCrafting(EntityPlayer par1EntityPlayer, IInventory par2IInventory, IInventory par3IInventory, int par4, int par5, int par6) + { + super(par3IInventory, par4, par5, par6); + this.thePlayer = par1EntityPlayer; + this.craftMatrix = par2IInventory; + } + + public boolean isItemValid(ItemStack par1ItemStack) + { + return false; + } + + public ItemStack decrStackSize(int par1) + { + if (this.getHasStack()) + { + this.amountCrafted += Math.min(par1, this.getStack().stackSize); + } + + return super.decrStackSize(par1); + } + + protected void onCrafting(ItemStack par1ItemStack, int par2) + { + this.amountCrafted += par2; + this.onCrafting(par1ItemStack); + } + + protected void onCrafting(ItemStack par1ItemStack) + { + par1ItemStack.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.amountCrafted); + this.amountCrafted = 0; + + if (par1ItemStack.getItem() == Item.getItemFromBlock(Blocks.crafting_table)) + { + this.thePlayer.addStat(AchievementList.buildWorkBench, 1); + } + + if (par1ItemStack.getItem() instanceof ItemPickaxe) + { + this.thePlayer.addStat(AchievementList.buildPickaxe, 1); + } + + if (par1ItemStack.getItem() == Item.getItemFromBlock(Blocks.furnace)) + { + this.thePlayer.addStat(AchievementList.buildFurnace, 1); + } + + if (par1ItemStack.getItem() instanceof ItemHoe) + { + this.thePlayer.addStat(AchievementList.buildHoe, 1); + } + + if (par1ItemStack.getItem() == Items.bread) + { + this.thePlayer.addStat(AchievementList.makeBread, 1); + } + + if (par1ItemStack.getItem() == Items.cake) + { + this.thePlayer.addStat(AchievementList.bakeCake, 1); + } + + if (par1ItemStack.getItem() instanceof ItemPickaxe && ((ItemPickaxe)par1ItemStack.getItem()).func_150913_i() != Item.ToolMaterial.WOOD) + { + this.thePlayer.addStat(AchievementList.buildBetterPickaxe, 1); + } + + if (par1ItemStack.getItem() instanceof ItemSword) + { + this.thePlayer.addStat(AchievementList.buildSword, 1); + } + + if (par1ItemStack.getItem() == Item.getItemFromBlock(Blocks.enchanting_table)) + { + this.thePlayer.addStat(AchievementList.enchantments, 1); + } + + if (par1ItemStack.getItem() == Item.getItemFromBlock(Blocks.bookshelf)) + { + this.thePlayer.addStat(AchievementList.bookcase, 1); + } + } + + public void onPickupFromSlot(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack) + { + FMLCommonHandler.instance().firePlayerCraftingEvent(par1EntityPlayer, par2ItemStack, craftMatrix); + this.onCrafting(par2ItemStack); + + for (int i = 0; i < this.craftMatrix.getSizeInventory(); ++i) + { + ItemStack itemstack1 = this.craftMatrix.getStackInSlot(i); + + if (itemstack1 != null) + { + this.craftMatrix.decrStackSize(i, 1); + + if (itemstack1.getItem().hasContainerItem(itemstack1)) + { + ItemStack itemstack2 = itemstack1.getItem().getContainerItem(itemstack1); + + if (itemstack2 != null && itemstack2.isItemStackDamageable() && itemstack2.getItemDamage() > itemstack2.getMaxDamage()) + { + MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(thePlayer, itemstack2)); + continue; + } + + if (!itemstack1.getItem().doesContainerItemLeaveCraftingGrid(itemstack1) || !this.thePlayer.inventory.addItemStackToInventory(itemstack2)) + { + if (this.craftMatrix.getStackInSlot(i) == null) + { + this.craftMatrix.setInventorySlotContents(i, itemstack2); + } + else + { + this.thePlayer.dropPlayerItemWithRandomChoice(itemstack2, false); + } + } + } + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/inventory/SlotFurnace.java b/src/main/java/net/minecraft/inventory/SlotFurnace.java new file mode 100644 index 0000000..29d45a9 --- /dev/null +++ b/src/main/java/net/minecraft/inventory/SlotFurnace.java @@ -0,0 +1,99 @@ +package net.minecraft.inventory; + +import cpw.mods.fml.common.FMLCommonHandler; +import net.minecraft.entity.item.EntityXPOrb; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.FurnaceRecipes; +import net.minecraft.stats.AchievementList; +import net.minecraft.util.MathHelper; + +public class SlotFurnace extends Slot +{ + private EntityPlayer thePlayer; + private int field_75228_b; + private static final String __OBFID = "CL_00001749"; + + public SlotFurnace(EntityPlayer par1EntityPlayer, IInventory par2IInventory, int par3, int par4, int par5) + { + super(par2IInventory, par3, par4, par5); + this.thePlayer = par1EntityPlayer; + } + + public boolean isItemValid(ItemStack par1ItemStack) + { + return false; + } + + public ItemStack decrStackSize(int par1) + { + if (this.getHasStack()) + { + this.field_75228_b += Math.min(par1, this.getStack().stackSize); + } + + return super.decrStackSize(par1); + } + + public void onPickupFromSlot(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack) + { + this.onCrafting(par2ItemStack); + super.onPickupFromSlot(par1EntityPlayer, par2ItemStack); + } + + protected void onCrafting(ItemStack par1ItemStack, int par2) + { + this.field_75228_b += par2; + this.onCrafting(par1ItemStack); + } + + protected void onCrafting(ItemStack par1ItemStack) + { + par1ItemStack.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.field_75228_b); + + if (!this.thePlayer.worldObj.isRemote) + { + int i = this.field_75228_b; + float f = FurnaceRecipes.smelting().func_151398_b(par1ItemStack); + int j; + + if (f == 0.0F) + { + i = 0; + } + else if (f < 1.0F) + { + j = MathHelper.floor_float((float)i * f); + + if (j < MathHelper.ceiling_float_int((float)i * f) && (float)Math.random() < (float)i * f - (float)j) + { + ++j; + } + + i = j; + } + + while (i > 0) + { + j = EntityXPOrb.getXPSplit(i); + i -= j; + this.thePlayer.worldObj.spawnEntityInWorld(new EntityXPOrb(this.thePlayer.worldObj, this.thePlayer.posX, this.thePlayer.posY + 0.5D, this.thePlayer.posZ + 0.5D, j)); + } + } + + this.field_75228_b = 0; + + FMLCommonHandler.instance().firePlayerSmeltedEvent(thePlayer, par1ItemStack); + + if (par1ItemStack.getItem() == Items.iron_ingot) + { + this.thePlayer.addStat(AchievementList.acquireIron, 1); + } + + if (par1ItemStack.getItem() == Items.cooked_fished) + { + this.thePlayer.addStat(AchievementList.cookFish, 1); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/inventory/SlotMerchantResult.java b/src/main/java/net/minecraft/inventory/SlotMerchantResult.java new file mode 100644 index 0000000..287693e --- /dev/null +++ b/src/main/java/net/minecraft/inventory/SlotMerchantResult.java @@ -0,0 +1,104 @@ +package net.minecraft.inventory; + +import net.minecraft.entity.IMerchant; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.village.MerchantRecipe; + +public class SlotMerchantResult extends Slot +{ + private final InventoryMerchant theMerchantInventory; + private EntityPlayer thePlayer; + private int field_75231_g; + private final IMerchant theMerchant; + private static final String __OBFID = "CL_00001758"; + + public SlotMerchantResult(EntityPlayer par1EntityPlayer, IMerchant par2IMerchant, InventoryMerchant par3InventoryMerchant, int par4, int par5, int par6) + { + super(par3InventoryMerchant, par4, par5, par6); + this.thePlayer = par1EntityPlayer; + this.theMerchant = par2IMerchant; + this.theMerchantInventory = par3InventoryMerchant; + } + + public boolean isItemValid(ItemStack par1ItemStack) + { + return false; + } + + public ItemStack decrStackSize(int par1) + { + if (this.getHasStack()) + { + this.field_75231_g += Math.min(par1, this.getStack().stackSize); + } + + return super.decrStackSize(par1); + } + + protected void onCrafting(ItemStack par1ItemStack, int par2) + { + this.field_75231_g += par2; + this.onCrafting(par1ItemStack); + } + + protected void onCrafting(ItemStack par1ItemStack) + { + par1ItemStack.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.field_75231_g); + this.field_75231_g = 0; + } + + public void onPickupFromSlot(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack) + { + this.onCrafting(par2ItemStack); + MerchantRecipe merchantrecipe = this.theMerchantInventory.getCurrentRecipe(); + + if (merchantrecipe != null) + { + ItemStack itemstack1 = this.theMerchantInventory.getStackInSlot(0); + ItemStack itemstack2 = this.theMerchantInventory.getStackInSlot(1); + + if (this.func_75230_a(merchantrecipe, itemstack1, itemstack2) || this.func_75230_a(merchantrecipe, itemstack2, itemstack1)) + { + this.theMerchant.useRecipe(merchantrecipe); + + if (itemstack1 != null && itemstack1.stackSize <= 0) + { + itemstack1 = null; + } + + if (itemstack2 != null && itemstack2.stackSize <= 0) + { + itemstack2 = null; + } + + this.theMerchantInventory.setInventorySlotContents(0, itemstack1); + this.theMerchantInventory.setInventorySlotContents(1, itemstack2); + } + } + } + + private boolean func_75230_a(MerchantRecipe par1MerchantRecipe, ItemStack par2ItemStack, ItemStack par3ItemStack) + { + ItemStack itemstack2 = par1MerchantRecipe.getItemToBuy(); + ItemStack itemstack3 = par1MerchantRecipe.getSecondItemToBuy(); + + if (par2ItemStack != null && par2ItemStack.getItem() == itemstack2.getItem()) + { + if (itemstack3 != null && par3ItemStack != null && itemstack3.getItem() == par3ItemStack.getItem()) + { + par2ItemStack.stackSize -= itemstack2.stackSize; + par3ItemStack.stackSize -= itemstack3.stackSize; + return true; + } + + if (itemstack3 == null && par3ItemStack == null) + { + par2ItemStack.stackSize -= itemstack2.stackSize; + return true; + } + } + + return false; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/EnumAction.java b/src/main/java/net/minecraft/item/EnumAction.java new file mode 100644 index 0000000..f8102b9 --- /dev/null +++ b/src/main/java/net/minecraft/item/EnumAction.java @@ -0,0 +1,12 @@ +package net.minecraft.item; + +public enum EnumAction +{ + none, + eat, + drink, + block, + bow; + + private static final String __OBFID = "CL_00000073"; +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/EnumRarity.java b/src/main/java/net/minecraft/item/EnumRarity.java new file mode 100644 index 0000000..b044b03 --- /dev/null +++ b/src/main/java/net/minecraft/item/EnumRarity.java @@ -0,0 +1,21 @@ +package net.minecraft.item; + +import net.minecraft.util.EnumChatFormatting; + +public enum EnumRarity +{ + common(EnumChatFormatting.WHITE, "Common"), + uncommon(EnumChatFormatting.YELLOW, "Uncommon"), + rare(EnumChatFormatting.AQUA, "Rare"), + epic(EnumChatFormatting.LIGHT_PURPLE, "Epic"); + public final EnumChatFormatting rarityColor; + public final String rarityName; + + private static final String __OBFID = "CL_00000056"; + + private EnumRarity(EnumChatFormatting p_i45349_3_, String p_i45349_4_) + { + this.rarityColor = p_i45349_3_; + this.rarityName = p_i45349_4_; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/Item.java b/src/main/java/net/minecraft/item/Item.java new file mode 100644 index 0000000..3b51fca --- /dev/null +++ b/src/main/java/net/minecraft/item/Item.java @@ -0,0 +1,1376 @@ +package net.minecraft.item; + +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; +import com.google.common.collect.Sets; + +import cpw.mods.fml.common.registry.GameData; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import java.util.Set; +import java.util.UUID; +import net.minecraft.block.Block; +import net.minecraft.block.BlockDirt; +import net.minecraft.block.BlockDoublePlant; +import net.minecraft.block.BlockFlower; +import net.minecraft.block.BlockNewLog; +import net.minecraft.block.BlockOldLog; +import net.minecraft.block.BlockQuartz; +import net.minecraft.block.BlockSand; +import net.minecraft.block.BlockSandStone; +import net.minecraft.block.BlockSapling; +import net.minecraft.block.BlockSilverfish; +import net.minecraft.block.BlockStoneBrick; +import net.minecraft.block.BlockWall; +import net.minecraft.block.BlockWood; +import net.minecraft.block.material.Material; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.model.ModelBiped; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.item.EntityItemFrame; +import net.minecraft.entity.item.EntityPainting; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionHelper; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.RegistryNamespaced; +import net.minecraft.util.StatCollector; +import net.minecraft.util.Vec3; +import net.minecraft.util.WeightedRandomChestContent; +import net.minecraft.world.World; +import net.minecraftforge.common.ChestGenHooks; +import net.minecraftforge.common.util.EnumHelper; + +public class Item +{ + public static final RegistryNamespaced itemRegistry = GameData.getItemRegistry(); + protected static final UUID field_111210_e = UUID.fromString("CB3F55D3-645C-4F38-A497-9C13A33DB5CF"); + private CreativeTabs tabToDisplayOn; + protected static Random itemRand = new Random(); + protected int maxStackSize = 64; + private int maxDamage; + protected boolean bFull3D; + protected boolean hasSubtypes; + private Item containerItem; + private String potionEffect; + private String unlocalizedName; + @SideOnly(Side.CLIENT) + protected IIcon itemIcon; + protected String iconString; + private static final String __OBFID = "CL_00000041"; + + public static int getIdFromItem(Item p_150891_0_) + { + return p_150891_0_ == null ? 0 : itemRegistry.getIDForObject(p_150891_0_); + } + + public static Item getItemById(int p_150899_0_) + { + return (Item)itemRegistry.getObjectById(p_150899_0_); + } + + public static Item getItemFromBlock(Block p_150898_0_) + { + return getItemById(Block.getIdFromBlock(p_150898_0_)); + } + + public static void registerItems() + { + itemRegistry.addObject(256, "iron_shovel", (new ItemSpade(Item.ToolMaterial.IRON)).setUnlocalizedName("shovelIron").setTextureName("iron_shovel")); + itemRegistry.addObject(257, "iron_pickaxe", (new ItemPickaxe(Item.ToolMaterial.IRON)).setUnlocalizedName("pickaxeIron").setTextureName("iron_pickaxe")); + itemRegistry.addObject(258, "iron_axe", (new ItemAxe(Item.ToolMaterial.IRON)).setUnlocalizedName("hatchetIron").setTextureName("iron_axe")); + itemRegistry.addObject(259, "flint_and_steel", (new ItemFlintAndSteel()).setUnlocalizedName("flintAndSteel").setTextureName("flint_and_steel")); + itemRegistry.addObject(260, "apple", (new ItemFood(4, 0.3F, false)).setUnlocalizedName("apple").setTextureName("apple")); + itemRegistry.addObject(261, "bow", (new ItemBow()).setUnlocalizedName("bow").setTextureName("bow")); + itemRegistry.addObject(262, "arrow", (new Item()).setUnlocalizedName("arrow").setCreativeTab(CreativeTabs.tabCombat).setTextureName("arrow")); + itemRegistry.addObject(263, "coal", (new ItemCoal()).setUnlocalizedName("coal").setTextureName("coal")); + itemRegistry.addObject(264, "diamond", (new Item()).setUnlocalizedName("diamond").setCreativeTab(CreativeTabs.tabMaterials).setTextureName("diamond")); + itemRegistry.addObject(265, "iron_ingot", (new Item()).setUnlocalizedName("ingotIron").setCreativeTab(CreativeTabs.tabMaterials).setTextureName("iron_ingot")); + itemRegistry.addObject(266, "gold_ingot", (new Item()).setUnlocalizedName("ingotGold").setCreativeTab(CreativeTabs.tabMaterials).setTextureName("gold_ingot")); + itemRegistry.addObject(267, "iron_sword", (new ItemSword(Item.ToolMaterial.IRON)).setUnlocalizedName("swordIron").setTextureName("iron_sword")); + itemRegistry.addObject(268, "wooden_sword", (new ItemSword(Item.ToolMaterial.WOOD)).setUnlocalizedName("swordWood").setTextureName("wood_sword")); + itemRegistry.addObject(269, "wooden_shovel", (new ItemSpade(Item.ToolMaterial.WOOD)).setUnlocalizedName("shovelWood").setTextureName("wood_shovel")); + itemRegistry.addObject(270, "wooden_pickaxe", (new ItemPickaxe(Item.ToolMaterial.WOOD)).setUnlocalizedName("pickaxeWood").setTextureName("wood_pickaxe")); + itemRegistry.addObject(271, "wooden_axe", (new ItemAxe(Item.ToolMaterial.WOOD)).setUnlocalizedName("hatchetWood").setTextureName("wood_axe")); + itemRegistry.addObject(272, "stone_sword", (new ItemSword(Item.ToolMaterial.STONE)).setUnlocalizedName("swordStone").setTextureName("stone_sword")); + itemRegistry.addObject(273, "stone_shovel", (new ItemSpade(Item.ToolMaterial.STONE)).setUnlocalizedName("shovelStone").setTextureName("stone_shovel")); + itemRegistry.addObject(274, "stone_pickaxe", (new ItemPickaxe(Item.ToolMaterial.STONE)).setUnlocalizedName("pickaxeStone").setTextureName("stone_pickaxe")); + itemRegistry.addObject(275, "stone_axe", (new ItemAxe(Item.ToolMaterial.STONE)).setUnlocalizedName("hatchetStone").setTextureName("stone_axe")); + itemRegistry.addObject(276, "diamond_sword", (new ItemSword(Item.ToolMaterial.EMERALD)).setUnlocalizedName("swordDiamond").setTextureName("diamond_sword")); + itemRegistry.addObject(277, "diamond_shovel", (new ItemSpade(Item.ToolMaterial.EMERALD)).setUnlocalizedName("shovelDiamond").setTextureName("diamond_shovel")); + itemRegistry.addObject(278, "diamond_pickaxe", (new ItemPickaxe(Item.ToolMaterial.EMERALD)).setUnlocalizedName("pickaxeDiamond").setTextureName("diamond_pickaxe")); + itemRegistry.addObject(279, "diamond_axe", (new ItemAxe(Item.ToolMaterial.EMERALD)).setUnlocalizedName("hatchetDiamond").setTextureName("diamond_axe")); + itemRegistry.addObject(280, "stick", (new Item()).setFull3D().setUnlocalizedName("stick").setCreativeTab(CreativeTabs.tabMaterials).setTextureName("stick")); + itemRegistry.addObject(281, "bowl", (new Item()).setUnlocalizedName("bowl").setCreativeTab(CreativeTabs.tabMaterials).setTextureName("bowl")); + itemRegistry.addObject(282, "mushroom_stew", (new ItemSoup(6)).setUnlocalizedName("mushroomStew").setTextureName("mushroom_stew")); + itemRegistry.addObject(283, "golden_sword", (new ItemSword(Item.ToolMaterial.GOLD)).setUnlocalizedName("swordGold").setTextureName("gold_sword")); + itemRegistry.addObject(284, "golden_shovel", (new ItemSpade(Item.ToolMaterial.GOLD)).setUnlocalizedName("shovelGold").setTextureName("gold_shovel")); + itemRegistry.addObject(285, "golden_pickaxe", (new ItemPickaxe(Item.ToolMaterial.GOLD)).setUnlocalizedName("pickaxeGold").setTextureName("gold_pickaxe")); + itemRegistry.addObject(286, "golden_axe", (new ItemAxe(Item.ToolMaterial.GOLD)).setUnlocalizedName("hatchetGold").setTextureName("gold_axe")); + itemRegistry.addObject(287, "string", (new ItemReed(Blocks.tripwire)).setUnlocalizedName("string").setCreativeTab(CreativeTabs.tabMaterials).setTextureName("string")); + itemRegistry.addObject(288, "feather", (new Item()).setUnlocalizedName("feather").setCreativeTab(CreativeTabs.tabMaterials).setTextureName("feather")); + itemRegistry.addObject(289, "gunpowder", (new Item()).setUnlocalizedName("sulphur").setPotionEffect(PotionHelper.gunpowderEffect).setCreativeTab(CreativeTabs.tabMaterials).setTextureName("gunpowder")); + itemRegistry.addObject(290, "wooden_hoe", (new ItemHoe(Item.ToolMaterial.WOOD)).setUnlocalizedName("hoeWood").setTextureName("wood_hoe")); + itemRegistry.addObject(291, "stone_hoe", (new ItemHoe(Item.ToolMaterial.STONE)).setUnlocalizedName("hoeStone").setTextureName("stone_hoe")); + itemRegistry.addObject(292, "iron_hoe", (new ItemHoe(Item.ToolMaterial.IRON)).setUnlocalizedName("hoeIron").setTextureName("iron_hoe")); + itemRegistry.addObject(293, "diamond_hoe", (new ItemHoe(Item.ToolMaterial.EMERALD)).setUnlocalizedName("hoeDiamond").setTextureName("diamond_hoe")); + itemRegistry.addObject(294, "golden_hoe", (new ItemHoe(Item.ToolMaterial.GOLD)).setUnlocalizedName("hoeGold").setTextureName("gold_hoe")); + itemRegistry.addObject(295, "wheat_seeds", (new ItemSeeds(Blocks.wheat, Blocks.farmland)).setUnlocalizedName("seeds").setTextureName("seeds_wheat")); + itemRegistry.addObject(296, "wheat", (new Item()).setUnlocalizedName("wheat").setCreativeTab(CreativeTabs.tabMaterials).setTextureName("wheat")); + itemRegistry.addObject(297, "bread", (new ItemFood(5, 0.6F, false)).setUnlocalizedName("bread").setTextureName("bread")); + itemRegistry.addObject(298, "leather_helmet", (new ItemArmor(ItemArmor.ArmorMaterial.CLOTH, 0, 0)).setUnlocalizedName("helmetCloth").setTextureName("leather_helmet")); + itemRegistry.addObject(299, "leather_chestplate", (new ItemArmor(ItemArmor.ArmorMaterial.CLOTH, 0, 1)).setUnlocalizedName("chestplateCloth").setTextureName("leather_chestplate")); + itemRegistry.addObject(300, "leather_leggings", (new ItemArmor(ItemArmor.ArmorMaterial.CLOTH, 0, 2)).setUnlocalizedName("leggingsCloth").setTextureName("leather_leggings")); + itemRegistry.addObject(301, "leather_boots", (new ItemArmor(ItemArmor.ArmorMaterial.CLOTH, 0, 3)).setUnlocalizedName("bootsCloth").setTextureName("leather_boots")); + itemRegistry.addObject(302, "chainmail_helmet", (new ItemArmor(ItemArmor.ArmorMaterial.CHAIN, 1, 0)).setUnlocalizedName("helmetChain").setTextureName("chainmail_helmet")); + itemRegistry.addObject(303, "chainmail_chestplate", (new ItemArmor(ItemArmor.ArmorMaterial.CHAIN, 1, 1)).setUnlocalizedName("chestplateChain").setTextureName("chainmail_chestplate")); + itemRegistry.addObject(304, "chainmail_leggings", (new ItemArmor(ItemArmor.ArmorMaterial.CHAIN, 1, 2)).setUnlocalizedName("leggingsChain").setTextureName("chainmail_leggings")); + itemRegistry.addObject(305, "chainmail_boots", (new ItemArmor(ItemArmor.ArmorMaterial.CHAIN, 1, 3)).setUnlocalizedName("bootsChain").setTextureName("chainmail_boots")); + itemRegistry.addObject(306, "iron_helmet", (new ItemArmor(ItemArmor.ArmorMaterial.IRON, 2, 0)).setUnlocalizedName("helmetIron").setTextureName("iron_helmet")); + itemRegistry.addObject(307, "iron_chestplate", (new ItemArmor(ItemArmor.ArmorMaterial.IRON, 2, 1)).setUnlocalizedName("chestplateIron").setTextureName("iron_chestplate")); + itemRegistry.addObject(308, "iron_leggings", (new ItemArmor(ItemArmor.ArmorMaterial.IRON, 2, 2)).setUnlocalizedName("leggingsIron").setTextureName("iron_leggings")); + itemRegistry.addObject(309, "iron_boots", (new ItemArmor(ItemArmor.ArmorMaterial.IRON, 2, 3)).setUnlocalizedName("bootsIron").setTextureName("iron_boots")); + itemRegistry.addObject(310, "diamond_helmet", (new ItemArmor(ItemArmor.ArmorMaterial.DIAMOND, 3, 0)).setUnlocalizedName("helmetDiamond").setTextureName("diamond_helmet")); + itemRegistry.addObject(311, "diamond_chestplate", (new ItemArmor(ItemArmor.ArmorMaterial.DIAMOND, 3, 1)).setUnlocalizedName("chestplateDiamond").setTextureName("diamond_chestplate")); + itemRegistry.addObject(312, "diamond_leggings", (new ItemArmor(ItemArmor.ArmorMaterial.DIAMOND, 3, 2)).setUnlocalizedName("leggingsDiamond").setTextureName("diamond_leggings")); + itemRegistry.addObject(313, "diamond_boots", (new ItemArmor(ItemArmor.ArmorMaterial.DIAMOND, 3, 3)).setUnlocalizedName("bootsDiamond").setTextureName("diamond_boots")); + itemRegistry.addObject(314, "golden_helmet", (new ItemArmor(ItemArmor.ArmorMaterial.GOLD, 4, 0)).setUnlocalizedName("helmetGold").setTextureName("gold_helmet")); + itemRegistry.addObject(315, "golden_chestplate", (new ItemArmor(ItemArmor.ArmorMaterial.GOLD, 4, 1)).setUnlocalizedName("chestplateGold").setTextureName("gold_chestplate")); + itemRegistry.addObject(316, "golden_leggings", (new ItemArmor(ItemArmor.ArmorMaterial.GOLD, 4, 2)).setUnlocalizedName("leggingsGold").setTextureName("gold_leggings")); + itemRegistry.addObject(317, "golden_boots", (new ItemArmor(ItemArmor.ArmorMaterial.GOLD, 4, 3)).setUnlocalizedName("bootsGold").setTextureName("gold_boots")); + itemRegistry.addObject(318, "flint", (new Item()).setUnlocalizedName("flint").setCreativeTab(CreativeTabs.tabMaterials).setTextureName("flint")); + itemRegistry.addObject(319, "porkchop", (new ItemFood(3, 0.3F, true)).setUnlocalizedName("porkchopRaw").setTextureName("porkchop_raw")); + itemRegistry.addObject(320, "cooked_porkchop", (new ItemFood(8, 0.8F, true)).setUnlocalizedName("porkchopCooked").setTextureName("porkchop_cooked")); + itemRegistry.addObject(321, "painting", (new ItemHangingEntity(EntityPainting.class)).setUnlocalizedName("painting").setTextureName("painting")); + itemRegistry.addObject(322, "golden_apple", (new ItemAppleGold(4, 1.2F, false)).setAlwaysEdible().setPotionEffect(Potion.regeneration.id, 5, 1, 1.0F).setUnlocalizedName("appleGold").setTextureName("apple_golden")); + itemRegistry.addObject(323, "sign", (new ItemSign()).setUnlocalizedName("sign").setTextureName("sign")); + itemRegistry.addObject(324, "wooden_door", (new ItemDoor(Material.wood)).setUnlocalizedName("doorWood").setTextureName("door_wood")); + Item item = (new ItemBucket(Blocks.air)).setUnlocalizedName("bucket").setMaxStackSize(16).setTextureName("bucket_empty"); + itemRegistry.addObject(325, "bucket", item); + itemRegistry.addObject(326, "water_bucket", (new ItemBucket(Blocks.flowing_water)).setUnlocalizedName("bucketWater").setContainerItem(item).setTextureName("bucket_water")); + itemRegistry.addObject(327, "lava_bucket", (new ItemBucket(Blocks.flowing_lava)).setUnlocalizedName("bucketLava").setContainerItem(item).setTextureName("bucket_lava")); + itemRegistry.addObject(328, "minecart", (new ItemMinecart(0)).setUnlocalizedName("minecart").setTextureName("minecart_normal")); + itemRegistry.addObject(329, "saddle", (new ItemSaddle()).setUnlocalizedName("saddle").setTextureName("saddle")); + itemRegistry.addObject(330, "iron_door", (new ItemDoor(Material.iron)).setUnlocalizedName("doorIron").setTextureName("door_iron")); + itemRegistry.addObject(331, "redstone", (new ItemRedstone()).setUnlocalizedName("redstone").setPotionEffect(PotionHelper.redstoneEffect).setTextureName("redstone_dust")); + itemRegistry.addObject(332, "snowball", (new ItemSnowball()).setUnlocalizedName("snowball").setTextureName("snowball")); + itemRegistry.addObject(333, "boat", (new ItemBoat()).setUnlocalizedName("boat").setTextureName("boat")); + itemRegistry.addObject(334, "leather", (new Item()).setUnlocalizedName("leather").setCreativeTab(CreativeTabs.tabMaterials).setTextureName("leather")); + itemRegistry.addObject(335, "milk_bucket", (new ItemBucketMilk()).setUnlocalizedName("milk").setContainerItem(item).setTextureName("bucket_milk")); + itemRegistry.addObject(336, "brick", (new Item()).setUnlocalizedName("brick").setCreativeTab(CreativeTabs.tabMaterials).setTextureName("brick")); + itemRegistry.addObject(337, "clay_ball", (new Item()).setUnlocalizedName("clay").setCreativeTab(CreativeTabs.tabMaterials).setTextureName("clay_ball")); + itemRegistry.addObject(338, "reeds", (new ItemReed(Blocks.reeds)).setUnlocalizedName("reeds").setCreativeTab(CreativeTabs.tabMaterials).setTextureName("reeds")); + itemRegistry.addObject(339, "paper", (new Item()).setUnlocalizedName("paper").setCreativeTab(CreativeTabs.tabMisc).setTextureName("paper")); + itemRegistry.addObject(340, "book", (new ItemBook()).setUnlocalizedName("book").setCreativeTab(CreativeTabs.tabMisc).setTextureName("book_normal")); + itemRegistry.addObject(341, "slime_ball", (new Item()).setUnlocalizedName("slimeball").setCreativeTab(CreativeTabs.tabMisc).setTextureName("slimeball")); + itemRegistry.addObject(342, "chest_minecart", (new ItemMinecart(1)).setUnlocalizedName("minecartChest").setTextureName("minecart_chest")); + itemRegistry.addObject(343, "furnace_minecart", (new ItemMinecart(2)).setUnlocalizedName("minecartFurnace").setTextureName("minecart_furnace")); + itemRegistry.addObject(344, "egg", (new ItemEgg()).setUnlocalizedName("egg").setTextureName("egg")); + itemRegistry.addObject(345, "compass", (new Item()).setUnlocalizedName("compass").setCreativeTab(CreativeTabs.tabTools).setTextureName("compass")); + itemRegistry.addObject(346, "fishing_rod", (new ItemFishingRod()).setUnlocalizedName("fishingRod").setTextureName("fishing_rod")); + itemRegistry.addObject(347, "clock", (new Item()).setUnlocalizedName("clock").setCreativeTab(CreativeTabs.tabTools).setTextureName("clock")); + itemRegistry.addObject(348, "glowstone_dust", (new Item()).setUnlocalizedName("yellowDust").setPotionEffect(PotionHelper.glowstoneEffect).setCreativeTab(CreativeTabs.tabMaterials).setTextureName("glowstone_dust")); + itemRegistry.addObject(349, "fish", (new ItemFishFood(false)).setUnlocalizedName("fish").setTextureName("fish_raw").setHasSubtypes(true)); + itemRegistry.addObject(350, "cooked_fished", (new ItemFishFood(true)).setUnlocalizedName("fish").setTextureName("fish_cooked").setHasSubtypes(true)); + itemRegistry.addObject(351, "dye", (new ItemDye()).setUnlocalizedName("dyePowder").setTextureName("dye_powder")); + itemRegistry.addObject(352, "bone", (new Item()).setUnlocalizedName("bone").setFull3D().setCreativeTab(CreativeTabs.tabMisc).setTextureName("bone")); + itemRegistry.addObject(353, "sugar", (new Item()).setUnlocalizedName("sugar").setPotionEffect(PotionHelper.sugarEffect).setCreativeTab(CreativeTabs.tabMaterials).setTextureName("sugar")); + itemRegistry.addObject(354, "cake", (new ItemReed(Blocks.cake)).setMaxStackSize(1).setUnlocalizedName("cake").setCreativeTab(CreativeTabs.tabFood).setTextureName("cake")); + itemRegistry.addObject(355, "bed", (new ItemBed()).setMaxStackSize(1).setUnlocalizedName("bed").setTextureName("bed")); + itemRegistry.addObject(356, "repeater", (new ItemReed(Blocks.unpowered_repeater)).setUnlocalizedName("diode").setCreativeTab(CreativeTabs.tabRedstone).setTextureName("repeater")); + itemRegistry.addObject(357, "cookie", (new ItemFood(2, 0.1F, false)).setUnlocalizedName("cookie").setTextureName("cookie")); + itemRegistry.addObject(358, "filled_map", (new ItemMap()).setUnlocalizedName("map").setTextureName("map_filled")); + itemRegistry.addObject(359, "shears", (new ItemShears()).setUnlocalizedName("shears").setTextureName("shears")); + itemRegistry.addObject(360, "melon", (new ItemFood(2, 0.3F, false)).setUnlocalizedName("melon").setTextureName("melon")); + itemRegistry.addObject(361, "pumpkin_seeds", (new ItemSeeds(Blocks.pumpkin_stem, Blocks.farmland)).setUnlocalizedName("seeds_pumpkin").setTextureName("seeds_pumpkin")); + itemRegistry.addObject(362, "melon_seeds", (new ItemSeeds(Blocks.melon_stem, Blocks.farmland)).setUnlocalizedName("seeds_melon").setTextureName("seeds_melon")); + itemRegistry.addObject(363, "beef", (new ItemFood(3, 0.3F, true)).setUnlocalizedName("beefRaw").setTextureName("beef_raw")); + itemRegistry.addObject(364, "cooked_beef", (new ItemFood(8, 0.8F, true)).setUnlocalizedName("beefCooked").setTextureName("beef_cooked")); + itemRegistry.addObject(365, "chicken", (new ItemFood(2, 0.3F, true)).setPotionEffect(Potion.hunger.id, 30, 0, 0.3F).setUnlocalizedName("chickenRaw").setTextureName("chicken_raw")); + itemRegistry.addObject(366, "cooked_chicken", (new ItemFood(6, 0.6F, true)).setUnlocalizedName("chickenCooked").setTextureName("chicken_cooked")); + itemRegistry.addObject(367, "rotten_flesh", (new ItemFood(4, 0.1F, true)).setPotionEffect(Potion.hunger.id, 30, 0, 0.8F).setUnlocalizedName("rottenFlesh").setTextureName("rotten_flesh")); + itemRegistry.addObject(368, "ender_pearl", (new ItemEnderPearl()).setUnlocalizedName("enderPearl").setTextureName("ender_pearl")); + itemRegistry.addObject(369, "blaze_rod", (new Item()).setUnlocalizedName("blazeRod").setCreativeTab(CreativeTabs.tabMaterials).setTextureName("blaze_rod")); + itemRegistry.addObject(370, "ghast_tear", (new Item()).setUnlocalizedName("ghastTear").setPotionEffect(PotionHelper.ghastTearEffect).setCreativeTab(CreativeTabs.tabBrewing).setTextureName("ghast_tear")); + itemRegistry.addObject(371, "gold_nugget", (new Item()).setUnlocalizedName("goldNugget").setCreativeTab(CreativeTabs.tabMaterials).setTextureName("gold_nugget")); + itemRegistry.addObject(372, "nether_wart", (new ItemSeeds(Blocks.nether_wart, Blocks.soul_sand)).setUnlocalizedName("netherStalkSeeds").setPotionEffect("+4").setTextureName("nether_wart")); + itemRegistry.addObject(373, "potion", (new ItemPotion()).setUnlocalizedName("potion").setTextureName("potion")); + itemRegistry.addObject(374, "glass_bottle", (new ItemGlassBottle()).setUnlocalizedName("glassBottle").setTextureName("potion_bottle_empty")); + itemRegistry.addObject(375, "spider_eye", (new ItemFood(2, 0.8F, false)).setPotionEffect(Potion.poison.id, 5, 0, 1.0F).setUnlocalizedName("spiderEye").setPotionEffect(PotionHelper.spiderEyeEffect).setTextureName("spider_eye")); + itemRegistry.addObject(376, "fermented_spider_eye", (new Item()).setUnlocalizedName("fermentedSpiderEye").setPotionEffect(PotionHelper.fermentedSpiderEyeEffect).setCreativeTab(CreativeTabs.tabBrewing).setTextureName("spider_eye_fermented")); + itemRegistry.addObject(377, "blaze_powder", (new Item()).setUnlocalizedName("blazePowder").setPotionEffect(PotionHelper.blazePowderEffect).setCreativeTab(CreativeTabs.tabBrewing).setTextureName("blaze_powder")); + itemRegistry.addObject(378, "magma_cream", (new Item()).setUnlocalizedName("magmaCream").setPotionEffect(PotionHelper.magmaCreamEffect).setCreativeTab(CreativeTabs.tabBrewing).setTextureName("magma_cream")); + itemRegistry.addObject(379, "brewing_stand", (new ItemReed(Blocks.brewing_stand)).setUnlocalizedName("brewingStand").setCreativeTab(CreativeTabs.tabBrewing).setTextureName("brewing_stand")); + itemRegistry.addObject(380, "cauldron", (new ItemReed(Blocks.cauldron)).setUnlocalizedName("cauldron").setCreativeTab(CreativeTabs.tabBrewing).setTextureName("cauldron")); + itemRegistry.addObject(381, "ender_eye", (new ItemEnderEye()).setUnlocalizedName("eyeOfEnder").setTextureName("ender_eye")); + itemRegistry.addObject(382, "speckled_melon", (new Item()).setUnlocalizedName("speckledMelon").setPotionEffect(PotionHelper.speckledMelonEffect).setCreativeTab(CreativeTabs.tabBrewing).setTextureName("melon_speckled")); + itemRegistry.addObject(383, "spawn_egg", (new ItemMonsterPlacer()).setUnlocalizedName("monsterPlacer").setTextureName("spawn_egg")); + itemRegistry.addObject(384, "experience_bottle", (new ItemExpBottle()).setUnlocalizedName("expBottle").setTextureName("experience_bottle")); + itemRegistry.addObject(385, "fire_charge", (new ItemFireball()).setUnlocalizedName("fireball").setTextureName("fireball")); + itemRegistry.addObject(386, "writable_book", (new ItemWritableBook()).setUnlocalizedName("writingBook").setCreativeTab(CreativeTabs.tabMisc).setTextureName("book_writable")); + itemRegistry.addObject(387, "written_book", (new ItemEditableBook()).setUnlocalizedName("writtenBook").setTextureName("book_written").setMaxStackSize(16)); + itemRegistry.addObject(388, "emerald", (new Item()).setUnlocalizedName("emerald").setCreativeTab(CreativeTabs.tabMaterials).setTextureName("emerald")); + itemRegistry.addObject(389, "item_frame", (new ItemHangingEntity(EntityItemFrame.class)).setUnlocalizedName("frame").setTextureName("item_frame")); + itemRegistry.addObject(390, "flower_pot", (new ItemReed(Blocks.flower_pot)).setUnlocalizedName("flowerPot").setCreativeTab(CreativeTabs.tabDecorations).setTextureName("flower_pot")); + itemRegistry.addObject(391, "carrot", (new ItemSeedFood(4, 0.6F, Blocks.carrots, Blocks.farmland)).setUnlocalizedName("carrots").setTextureName("carrot")); + itemRegistry.addObject(392, "potato", (new ItemSeedFood(1, 0.3F, Blocks.potatoes, Blocks.farmland)).setUnlocalizedName("potato").setTextureName("potato")); + itemRegistry.addObject(393, "baked_potato", (new ItemFood(6, 0.6F, false)).setUnlocalizedName("potatoBaked").setTextureName("potato_baked")); + itemRegistry.addObject(394, "poisonous_potato", (new ItemFood(2, 0.3F, false)).setPotionEffect(Potion.poison.id, 5, 0, 0.6F).setUnlocalizedName("potatoPoisonous").setTextureName("potato_poisonous")); + itemRegistry.addObject(395, "map", (new ItemEmptyMap()).setUnlocalizedName("emptyMap").setTextureName("map_empty")); + itemRegistry.addObject(396, "golden_carrot", (new ItemFood(6, 1.2F, false)).setUnlocalizedName("carrotGolden").setPotionEffect(PotionHelper.goldenCarrotEffect).setTextureName("carrot_golden")); + itemRegistry.addObject(397, "skull", (new ItemSkull()).setUnlocalizedName("skull").setTextureName("skull")); + itemRegistry.addObject(398, "carrot_on_a_stick", (new ItemCarrotOnAStick()).setUnlocalizedName("carrotOnAStick").setTextureName("carrot_on_a_stick")); + itemRegistry.addObject(399, "nether_star", (new ItemSimpleFoiled()).setUnlocalizedName("netherStar").setCreativeTab(CreativeTabs.tabMaterials).setTextureName("nether_star")); + itemRegistry.addObject(400, "pumpkin_pie", (new ItemFood(8, 0.3F, false)).setUnlocalizedName("pumpkinPie").setCreativeTab(CreativeTabs.tabFood).setTextureName("pumpkin_pie")); + itemRegistry.addObject(401, "fireworks", (new ItemFirework()).setUnlocalizedName("fireworks").setTextureName("fireworks")); + itemRegistry.addObject(402, "firework_charge", (new ItemFireworkCharge()).setUnlocalizedName("fireworksCharge").setCreativeTab(CreativeTabs.tabMisc).setTextureName("fireworks_charge")); + itemRegistry.addObject(403, "enchanted_book", (new ItemEnchantedBook()).setMaxStackSize(1).setUnlocalizedName("enchantedBook").setTextureName("book_enchanted")); + itemRegistry.addObject(404, "comparator", (new ItemReed(Blocks.unpowered_comparator)).setUnlocalizedName("comparator").setCreativeTab(CreativeTabs.tabRedstone).setTextureName("comparator")); + itemRegistry.addObject(405, "netherbrick", (new Item()).setUnlocalizedName("netherbrick").setCreativeTab(CreativeTabs.tabMaterials).setTextureName("netherbrick")); + itemRegistry.addObject(406, "quartz", (new Item()).setUnlocalizedName("netherquartz").setCreativeTab(CreativeTabs.tabMaterials).setTextureName("quartz")); + itemRegistry.addObject(407, "tnt_minecart", (new ItemMinecart(3)).setUnlocalizedName("minecartTnt").setTextureName("minecart_tnt")); + itemRegistry.addObject(408, "hopper_minecart", (new ItemMinecart(5)).setUnlocalizedName("minecartHopper").setTextureName("minecart_hopper")); + itemRegistry.addObject(417, "iron_horse_armor", (new Item()).setUnlocalizedName("horsearmormetal").setMaxStackSize(1).setCreativeTab(CreativeTabs.tabMisc).setTextureName("iron_horse_armor")); + itemRegistry.addObject(418, "golden_horse_armor", (new Item()).setUnlocalizedName("horsearmorgold").setMaxStackSize(1).setCreativeTab(CreativeTabs.tabMisc).setTextureName("gold_horse_armor")); + itemRegistry.addObject(419, "diamond_horse_armor", (new Item()).setUnlocalizedName("horsearmordiamond").setMaxStackSize(1).setCreativeTab(CreativeTabs.tabMisc).setTextureName("diamond_horse_armor")); + itemRegistry.addObject(420, "lead", (new ItemLead()).setUnlocalizedName("leash").setTextureName("lead")); + itemRegistry.addObject(421, "name_tag", (new ItemNameTag()).setUnlocalizedName("nameTag").setTextureName("name_tag")); + itemRegistry.addObject(422, "command_block_minecart", (new ItemMinecart(6)).setUnlocalizedName("minecartCommandBlock").setTextureName("minecart_command_block").setCreativeTab((CreativeTabs)null)); + itemRegistry.addObject(2256, "record_13", (new ItemRecord("13")).setUnlocalizedName("record").setTextureName("record_13")); + itemRegistry.addObject(2257, "record_cat", (new ItemRecord("cat")).setUnlocalizedName("record").setTextureName("record_cat")); + itemRegistry.addObject(2258, "record_blocks", (new ItemRecord("blocks")).setUnlocalizedName("record").setTextureName("record_blocks")); + itemRegistry.addObject(2259, "record_chirp", (new ItemRecord("chirp")).setUnlocalizedName("record").setTextureName("record_chirp")); + itemRegistry.addObject(2260, "record_far", (new ItemRecord("far")).setUnlocalizedName("record").setTextureName("record_far")); + itemRegistry.addObject(2261, "record_mall", (new ItemRecord("mall")).setUnlocalizedName("record").setTextureName("record_mall")); + itemRegistry.addObject(2262, "record_mellohi", (new ItemRecord("mellohi")).setUnlocalizedName("record").setTextureName("record_mellohi")); + itemRegistry.addObject(2263, "record_stal", (new ItemRecord("stal")).setUnlocalizedName("record").setTextureName("record_stal")); + itemRegistry.addObject(2264, "record_strad", (new ItemRecord("strad")).setUnlocalizedName("record").setTextureName("record_strad")); + itemRegistry.addObject(2265, "record_ward", (new ItemRecord("ward")).setUnlocalizedName("record").setTextureName("record_ward")); + itemRegistry.addObject(2266, "record_11", (new ItemRecord("11")).setUnlocalizedName("record").setTextureName("record_11")); + itemRegistry.addObject(2267, "record_wait", (new ItemRecord("wait")).setUnlocalizedName("record").setTextureName("record_wait")); + HashSet hashset = Sets.newHashSet(new Block[] {Blocks.air, Blocks.brewing_stand, Blocks.bed, Blocks.nether_wart, Blocks.cauldron, Blocks.flower_pot, Blocks.wheat, Blocks.reeds, Blocks.cake, Blocks.skull, Blocks.piston_head, Blocks.piston_extension, Blocks.lit_redstone_ore, Blocks.powered_repeater, Blocks.pumpkin_stem, Blocks.standing_sign, Blocks.powered_comparator, Blocks.tripwire, Blocks.lit_redstone_lamp, Blocks.melon_stem, Blocks.unlit_redstone_torch, Blocks.unpowered_comparator, Blocks.redstone_wire, Blocks.wall_sign, Blocks.unpowered_repeater, Blocks.iron_door, Blocks.wooden_door}); + Iterator iterator = Block.blockRegistry.getKeys().iterator(); + + while (iterator.hasNext()) + { + String s = (String)iterator.next(); + Block block = (Block)Block.blockRegistry.getObject(s); + Object object; + + if (block == Blocks.wool) + { + object = (new ItemCloth(Blocks.wool)).setUnlocalizedName("cloth"); + } + else if (block == Blocks.stained_hardened_clay) + { + object = (new ItemCloth(Blocks.stained_hardened_clay)).setUnlocalizedName("clayHardenedStained"); + } + else if (block == Blocks.stained_glass) + { + object = (new ItemCloth(Blocks.stained_glass)).setUnlocalizedName("stainedGlass"); + } + else if (block == Blocks.stained_glass_pane) + { + object = (new ItemCloth(Blocks.stained_glass_pane)).setUnlocalizedName("stainedGlassPane"); + } + else if (block == Blocks.carpet) + { + object = (new ItemCloth(Blocks.carpet)).setUnlocalizedName("woolCarpet"); + } + else if (block == Blocks.dirt) + { + object = (new ItemMultiTexture(Blocks.dirt, Blocks.dirt, BlockDirt.field_150009_a)).setUnlocalizedName("dirt"); + } + else if (block == Blocks.sand) + { + object = (new ItemMultiTexture(Blocks.sand, Blocks.sand, BlockSand.field_149838_a)).setUnlocalizedName("sand"); + } + else if (block == Blocks.log) + { + object = (new ItemMultiTexture(Blocks.log, Blocks.log, BlockOldLog.field_150168_M)).setUnlocalizedName("log"); + } + else if (block == Blocks.log2) + { + object = (new ItemMultiTexture(Blocks.log2, Blocks.log2, BlockNewLog.field_150169_M)).setUnlocalizedName("log"); + } + else if (block == Blocks.planks) + { + object = (new ItemMultiTexture(Blocks.planks, Blocks.planks, BlockWood.field_150096_a)).setUnlocalizedName("wood"); + } + else if (block == Blocks.monster_egg) + { + object = (new ItemMultiTexture(Blocks.monster_egg, Blocks.monster_egg, BlockSilverfish.field_150198_a)).setUnlocalizedName("monsterStoneEgg"); + } + else if (block == Blocks.stonebrick) + { + object = (new ItemMultiTexture(Blocks.stonebrick, Blocks.stonebrick, BlockStoneBrick.field_150142_a)).setUnlocalizedName("stonebricksmooth"); + } + else if (block == Blocks.sandstone) + { + object = (new ItemMultiTexture(Blocks.sandstone, Blocks.sandstone, BlockSandStone.field_150157_a)).setUnlocalizedName("sandStone"); + } + else if (block == Blocks.quartz_block) + { + object = (new ItemMultiTexture(Blocks.quartz_block, Blocks.quartz_block, BlockQuartz.field_150191_a)).setUnlocalizedName("quartzBlock"); + } + else if (block == Blocks.stone_slab) + { + object = (new ItemSlab(Blocks.stone_slab, Blocks.stone_slab, Blocks.double_stone_slab, false)).setUnlocalizedName("stoneSlab"); + } + else if (block == Blocks.double_stone_slab) + { + object = (new ItemSlab(Blocks.double_stone_slab, Blocks.stone_slab, Blocks.double_stone_slab, true)).setUnlocalizedName("stoneSlab"); + } + else if (block == Blocks.wooden_slab) + { + object = (new ItemSlab(Blocks.wooden_slab, Blocks.wooden_slab, Blocks.double_wooden_slab, false)).setUnlocalizedName("woodSlab"); + } + else if (block == Blocks.double_wooden_slab) + { + object = (new ItemSlab(Blocks.double_wooden_slab, Blocks.wooden_slab, Blocks.double_wooden_slab, true)).setUnlocalizedName("woodSlab"); + } + else if (block == Blocks.sapling) + { + object = (new ItemMultiTexture(Blocks.sapling, Blocks.sapling, BlockSapling.field_149882_a)).setUnlocalizedName("sapling"); + } + else if (block == Blocks.leaves) + { + object = (new ItemLeaves(Blocks.leaves)).setUnlocalizedName("leaves"); + } + else if (block == Blocks.leaves2) + { + object = (new ItemLeaves(Blocks.leaves2)).setUnlocalizedName("leaves"); + } + else if (block == Blocks.vine) + { + object = new ItemColored(Blocks.vine, false); + } + else if (block == Blocks.tallgrass) + { + object = (new ItemColored(Blocks.tallgrass, true)).func_150943_a(new String[] {"shrub", "grass", "fern"}); + } + else if (block == Blocks.yellow_flower) + { + object = (new ItemMultiTexture(Blocks.yellow_flower, Blocks.yellow_flower, BlockFlower.field_149858_b)).setUnlocalizedName("flower"); + } + else if (block == Blocks.red_flower) + { + object = (new ItemMultiTexture(Blocks.red_flower, Blocks.red_flower, BlockFlower.field_149859_a)).setUnlocalizedName("rose"); + } + else if (block == Blocks.snow_layer) + { + object = new ItemSnow(Blocks.snow_layer, Blocks.snow_layer); + } + else if (block == Blocks.waterlily) + { + object = new ItemLilyPad(Blocks.waterlily); + } + else if (block == Blocks.piston) + { + object = new ItemPiston(Blocks.piston); + } + else if (block == Blocks.sticky_piston) + { + object = new ItemPiston(Blocks.sticky_piston); + } + else if (block == Blocks.cobblestone_wall) + { + object = (new ItemMultiTexture(Blocks.cobblestone_wall, Blocks.cobblestone_wall, BlockWall.field_150092_a)).setUnlocalizedName("cobbleWall"); + } + else if (block == Blocks.anvil) + { + object = (new ItemAnvilBlock(Blocks.anvil)).setUnlocalizedName("anvil"); + } + else if (block == Blocks.double_plant) + { + object = (new ItemDoublePlant(Blocks.double_plant, Blocks.double_plant, BlockDoublePlant.field_149892_a)).setUnlocalizedName("doublePlant"); + } + else + { + if (hashset.contains(block)) + { + continue; + } + + object = new ItemBlock(block); + } + + itemRegistry.addObject(Block.getIdFromBlock(block), s, object); + } + } + + public Item setMaxStackSize(int par1) + { + this.maxStackSize = par1; + return this; + } + + @SideOnly(Side.CLIENT) + public int getSpriteNumber() + { + return 1; + } + + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int par1) + { + return this.itemIcon; + } + + @SideOnly(Side.CLIENT) + public IIcon getIconIndex(ItemStack par1ItemStack) + { + return this.getIconFromDamage(par1ItemStack.getItemDamage()); + } + + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) + { + return false; + } + + public float func_150893_a(ItemStack p_150893_1_, Block p_150893_2_) + { + return 1.0F; + } + + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + { + return par1ItemStack; + } + + public ItemStack onEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + { + return par1ItemStack; + } + + @Deprecated + public int getItemStackLimit() + { + return this.maxStackSize; + } + + public int getMetadata(int par1) + { + return 0; + } + + public boolean getHasSubtypes() + { + return this.hasSubtypes; + } + + public Item setHasSubtypes(boolean par1) + { + this.hasSubtypes = par1; + return this; + } + + public int getMaxDamage() + { + return this.maxDamage; + } + + public Item setMaxDamage(int par1) + { + this.maxDamage = par1; + return this; + } + + public boolean isDamageable() + { + return this.maxDamage > 0 && !this.hasSubtypes; + } + + public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase) + { + return false; + } + + public boolean onBlockDestroyed(ItemStack p_150894_1_, World p_150894_2_, Block p_150894_3_, int p_150894_4_, int p_150894_5_, int p_150894_6_, EntityLivingBase p_150894_7_) + { + return false; + } + + public boolean func_150897_b(Block p_150897_1_) + { + return false; + } + + public boolean itemInteractionForEntity(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, EntityLivingBase par3EntityLivingBase) + { + return false; + } + + public Item setFull3D() + { + this.bFull3D = true; + return this; + } + + @SideOnly(Side.CLIENT) + public boolean isFull3D() + { + return this.bFull3D; + } + + @SideOnly(Side.CLIENT) + public boolean shouldRotateAroundWhenRendering() + { + return false; + } + + public Item setUnlocalizedName(String par1Str) + { + this.unlocalizedName = par1Str; + return this; + } + + public String getUnlocalizedNameInefficiently(ItemStack par1ItemStack) + { + String s = this.getUnlocalizedName(par1ItemStack); + return s == null ? "" : StatCollector.translateToLocal(s); + } + + public String getUnlocalizedName() + { + return "item." + this.unlocalizedName; + } + + public String getUnlocalizedName(ItemStack par1ItemStack) + { + return "item." + this.unlocalizedName; + } + + public Item setContainerItem(Item par1Item) + { + this.containerItem = par1Item; + return this; + } + + public boolean doesContainerItemLeaveCraftingGrid(ItemStack par1ItemStack) + { + return true; + } + + public boolean getShareTag() + { + return true; + } + + public Item getContainerItem() + { + return this.containerItem; + } + + @Deprecated // Use ItemStack sensitive version below. + public boolean hasContainerItem() + { + return this.containerItem != null; + } + + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) + { + return 16777215; + } + + public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) {} + + public void onCreated(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {} + + public boolean isMap() + { + return false; + } + + public EnumAction getItemUseAction(ItemStack par1ItemStack) + { + return EnumAction.none; + } + + public int getMaxItemUseDuration(ItemStack par1ItemStack) + { + return 0; + } + + public void onPlayerStoppedUsing(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, int par4) {} + + public Item setPotionEffect(String par1Str) + { + this.potionEffect = par1Str; + return this; + } + + public String getPotionEffect(ItemStack p_150896_1_) + { + return this.potionEffect; + } + + public boolean isPotionIngredient(ItemStack p_150892_1_) + { + return this.getPotionEffect(p_150892_1_) != null; + } + + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {} + + public String getItemStackDisplayName(ItemStack par1ItemStack) + { + return ("" + StatCollector.translateToLocal(this.getUnlocalizedNameInefficiently(par1ItemStack) + ".name")).trim(); + } + + @SideOnly(Side.CLIENT) + @Deprecated + public boolean hasEffect(ItemStack par1ItemStack) + { + return par1ItemStack.isItemEnchanted(); + } + + public EnumRarity getRarity(ItemStack par1ItemStack) + { + return par1ItemStack.isItemEnchanted() ? EnumRarity.rare : EnumRarity.common; + } + + public boolean isItemTool(ItemStack par1ItemStack) + { + return this.getItemStackLimit(par1ItemStack) == 1 && this.isDamageable(); + } + + protected MovingObjectPosition getMovingObjectPositionFromPlayer(World par1World, EntityPlayer par2EntityPlayer, boolean par3) + { + float f = 1.0F; + float f1 = par2EntityPlayer.prevRotationPitch + (par2EntityPlayer.rotationPitch - par2EntityPlayer.prevRotationPitch) * f; + float f2 = par2EntityPlayer.prevRotationYaw + (par2EntityPlayer.rotationYaw - par2EntityPlayer.prevRotationYaw) * f; + double d0 = par2EntityPlayer.prevPosX + (par2EntityPlayer.posX - par2EntityPlayer.prevPosX) * (double)f; + double d1 = par2EntityPlayer.prevPosY + (par2EntityPlayer.posY - par2EntityPlayer.prevPosY) * (double)f + (double)(par1World.isRemote ? par2EntityPlayer.getEyeHeight() - par2EntityPlayer.getDefaultEyeHeight() : par2EntityPlayer.getEyeHeight()); // isRemote check to revert changes to ray trace position due to adding the eye height clientside and player yOffset differences + double d2 = par2EntityPlayer.prevPosZ + (par2EntityPlayer.posZ - par2EntityPlayer.prevPosZ) * (double)f; + Vec3 vec3 = par1World.getWorldVec3Pool().getVecFromPool(d0, d1, d2); + float f3 = MathHelper.cos(-f2 * 0.017453292F - (float)Math.PI); + float f4 = MathHelper.sin(-f2 * 0.017453292F - (float)Math.PI); + float f5 = -MathHelper.cos(-f1 * 0.017453292F); + float f6 = MathHelper.sin(-f1 * 0.017453292F); + float f7 = f4 * f5; + float f8 = f3 * f5; + double d3 = 5.0D; + if (par2EntityPlayer instanceof EntityPlayerMP) + { + d3 = ((EntityPlayerMP)par2EntityPlayer).theItemInWorldManager.getBlockReachDistance(); + } + Vec3 vec31 = vec3.addVector((double)f7 * d3, (double)f6 * d3, (double)f8 * d3); + return par1World.func_147447_a(vec3, vec31, par3, !par3, false); + } + + public int getItemEnchantability() + { + return 0; + } + + @SideOnly(Side.CLIENT) + public boolean requiresMultipleRenderPasses() + { + return false; + } + + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamageForRenderPass(int par1, int par2) + { + return this.getIconFromDamage(par1); + } + + @SideOnly(Side.CLIENT) + public void getSubItems(Item p_150895_1_, CreativeTabs p_150895_2_, List p_150895_3_) + { + p_150895_3_.add(new ItemStack(p_150895_1_, 1, 0)); + } + + public Item setCreativeTab(CreativeTabs par1CreativeTabs) + { + this.tabToDisplayOn = par1CreativeTabs; + return this; + } + + @SideOnly(Side.CLIENT) + public CreativeTabs getCreativeTab() + { + return this.tabToDisplayOn; + } + + public boolean canItemEditBlocks() + { + return true; + } + + public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) + { + return false; + } + + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) + { + this.itemIcon = par1IconRegister.registerIcon(this.getIconString()); + } + + @Deprecated + public Multimap getItemAttributeModifiers() + { + return HashMultimap.create(); + } + + public Item setTextureName(String par1Str) + { + this.iconString = par1Str; + return this; + } + + @SideOnly(Side.CLIENT) + protected String getIconString() + { + return this.iconString == null ? "MISSING_ICON_ITEM_" + itemRegistry.getIDForObject(this) + "_" + this.unlocalizedName : this.iconString; + } + + /* ======================================== FORGE START =====================================*/ + /** + * ItemStack sensitive version of getItemAttributeModifiers + */ + public Multimap getAttributeModifiers(ItemStack stack) + { + return this.getItemAttributeModifiers(); + } + + /** + * Called when a player drops the item into the world, + * returning false from this will prevent the item from + * being removed from the players inventory and spawning + * in the world + * + * @param player The player that dropped the item + * @param item The item stack, before the item is removed. + */ + public boolean onDroppedByPlayer(ItemStack item, EntityPlayer player) + { + return true; + } + + /** + * This is called when the item is used, before the block is activated. + * @param stack The Item Stack + * @param player The Player that used the item + * @param world The Current World + * @param x Target X Position + * @param y Target Y Position + * @param z Target Z Position + * @param side The side of the target hit + * @return Return true to prevent any further processing. + */ + public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) + { + return false; + } + + /** + * Metadata-sensitive version of getStrVsBlock + * @param itemstack The Item Stack + * @param block The block the item is trying to break + * @param metadata The items current metadata + * @return The damage strength + */ + public float getDigSpeed(ItemStack itemstack, Block block, int metadata) + { + return func_150893_a(itemstack, block); + } + + protected boolean canRepair = true; + /** + * Called by CraftingManager to determine if an item is reparable. + * @return True if reparable + */ + public boolean isRepairable() + { + return canRepair && isDamageable(); + } + + /** + * Call to disable repair recipes. + * @return The current Item instance + */ + public Item setNoRepair() + { + canRepair = false; + return this; + } + + /** + * Called before a block is broken. Return true to prevent default block harvesting. + * + * Note: In SMP, this is called on both client and server sides! + * + * @param itemstack The current ItemStack + * @param X The X Position + * @param Y The X Position + * @param Z The X Position + * @param player The Player that is wielding the item + * @return True to prevent harvesting, false to continue as normal + */ + public boolean onBlockStartBreak(ItemStack itemstack, int X, int Y, int Z, EntityPlayer player) + { + return false; + } + + /** + * Called each tick while using an item. + * @param stack The Item being used + * @param player The Player using the item + * @param count The amount of time in tick the item has been used for continuously + */ + public void onUsingTick(ItemStack stack, EntityPlayer player, int count) + { + } + + /** + * Called when the player Left Clicks (attacks) an entity. + * Processed before damage is done, if return value is true further processing is canceled + * and the entity is not attacked. + * + * @param stack The Item being used + * @param player The player that is attacking + * @param entity The entity being attacked + * @return True to cancel the rest of the interaction. + */ + public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) + { + return false; + } + + /** + * Player, Render pass, and item usage sensitive version of getIconIndex. + * + * @param stack The item stack to get the icon for. (Usually this, and usingItem will be the same if usingItem is not null) + * @param renderPass The pass to get the icon for, 0 is default. + * @param player The player holding the item + * @param usingItem The item the player is actively using. Can be null if not using anything. + * @param useRemaining The ticks remaining for the active item. + * @return The icon index + */ + public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) + { + return getIcon(stack, renderPass); + } + + /** + * Returns the number of render passes/layers this item has. + * Usually equates to ItemRenderer.renderItem being called for this many passes. + * Does not get called unless requiresMultipleRenderPasses() is true; + * + * @param metadata The item's metadata + * @return The number of passes to run. + */ + public int getRenderPasses(int metadata) + { + return requiresMultipleRenderPasses() ? 2 : 1; + } + + /** + * ItemStack sensitive version of getContainerItem. + * Returns a full ItemStack instance of the result. + * + * @param itemStack The current ItemStack + * @return The resulting ItemStack + */ + public ItemStack getContainerItem(ItemStack itemStack) + { + if (!hasContainerItem(itemStack)) + { + return null; + } + return new ItemStack(getContainerItem()); + } + + /** + * ItemStack sensitive version of hasContainerItem + * @param stack The current item stack + * @return True if this item has a 'container' + */ + public boolean hasContainerItem(ItemStack stack) + { + return hasContainerItem(); + } + + /** + * Retrieves the normal 'lifespan' of this item when it is dropped on the ground as a EntityItem. + * This is in ticks, standard result is 6000, or 5 mins. + * + * @param itemStack The current ItemStack + * @param world The world the entity is in + * @return The normal lifespan in ticks. + */ + public int getEntityLifespan(ItemStack itemStack, World world) + { + return 6000; + } + + /** + * Determines if this Item has a special entity for when they are in the world. + * Is called when a EntityItem is spawned in the world, if true and Item#createCustomEntity + * returns non null, the EntityItem will be destroyed and the new Entity will be added to the world. + * + * @param stack The current item stack + * @return True of the item has a custom entity, If true, Item#createCustomEntity will be called + */ + public boolean hasCustomEntity(ItemStack stack) + { + return false; + } + + /** + * This function should return a new entity to replace the dropped item. + * Returning null here will not kill the EntityItem and will leave it to function normally. + * Called when the item it placed in a world. + * + * @param world The world object + * @param location The EntityItem object, useful for getting the position of the entity + * @param itemstack The current item stack + * @return A new Entity object to spawn or null + */ + public Entity createEntity(World world, Entity location, ItemStack itemstack) + { + return null; + } + + /** + * Called by the default implemetation of EntityItem's onUpdate method, allowing for cleaner + * control over the update of the item without having to write a subclass. + * + * @param entityItem The entity Item + * @return Return true to skip any further update code. + */ + public boolean onEntityItemUpdate(EntityItem entityItem) + { + return false; + } + + /** + * Gets a list of tabs that items belonging to this class can display on, + * combined properly with getSubItems allows for a single item to span + * many sub-items across many tabs. + * + * @return A list of all tabs that this item could possibly be one. + */ + public CreativeTabs[] getCreativeTabs() + { + return new CreativeTabs[]{ getCreativeTab() }; + } + + /** + * Determines the base experience for a player when they remove this item from a furnace slot. + * This number must be between 0 and 1 for it to be valid. + * This number will be multiplied by the stack size to get the total experience. + * + * @param item The item stack the player is picking up. + * @return The amount to award for each item. + */ + public float getSmeltingExperience(ItemStack item) + { + return -1; //-1 will default to the old lookups. + } + + /** + * Return the correct icon for rendering based on the supplied ItemStack and render pass. + * + * Defers to {@link #getIconFromDamageForRenderPass(int, int)} + * @param stack to render for + * @param pass the multi-render pass + * @return the icon + */ + public IIcon getIcon(ItemStack stack, int pass) + { + return getIconFromDamageForRenderPass(stack.getItemDamage(), pass); + } + + /** + * Generates the base Random item for a specific instance of the chest gen, + * Enchanted books use this to pick a random enchantment. + * + * @param chest The chest category to generate for + * @param rnd World RNG + * @param original Original result registered with the chest gen hooks. + * @return New values to use as the random item, typically this will be original + */ + public WeightedRandomChestContent getChestGenBase(ChestGenHooks chest, Random rnd, WeightedRandomChestContent original) + { + if (this instanceof ItemEnchantedBook) + { + return ((ItemEnchantedBook)this).func_92112_a(rnd, + original.theMinimumChanceToGenerateItem, + original.theMaximumChanceToGenerateItem, original.itemWeight); + } + return original; + } + + /** + * + * Should this item, when held, allow sneak-clicks to pass through to the underlying block? + * + * @param world The world + * @param x The X Position + * @param y The X Position + * @param z The X Position + * @param player The Player that is wielding the item + * @return + */ + public boolean doesSneakBypassUse(World world, int x, int y, int z, EntityPlayer player) + { + return false; + } + + /** + * Called to tick armor in the armor slot. Override to do something + * + * @param world + * @param player + * @param itemStack + */ + public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) + { + + } + + /** + * Determines if the specific ItemStack can be placed in the specified armor slot. + * + * @param stack The ItemStack + * @param armorType Armor slot ID: 0: Helmet, 1: Chest, 2: Legs, 3: Boots + * @param entity The entity trying to equip the armor + * @return True if the given ItemStack can be inserted in the slot + */ + public boolean isValidArmor(ItemStack stack, int armorType, Entity entity) + { + if (this instanceof ItemArmor) + { + return ((ItemArmor)this).armorType == armorType; + } + + if (armorType == 0) + { + return this == Item.getItemFromBlock(Blocks.pumpkin) || this == Items.skull; + } + + return false; + } + + /** + * Allow or forbid the specific book/item combination as an anvil enchant + * + * @param stack The item + * @param book The book + * @return if the enchantment is allowed + */ + public boolean isBookEnchantable(ItemStack stack, ItemStack book) + { + return true; + } + + /** + * Called by RenderBiped and RenderPlayer to determine the armor texture that + * should be use for the currently equiped item. + * This will only be called on instances of ItemArmor. + * + * Returning null from this function will use the default value. + * + * @param stack ItemStack for the equpt armor + * @param entity The entity wearing the armor + * @param slot The slot the armor is in + * @param type The subtype, can be null or "overlay" + * @return Path of texture to bind, or null to use default + */ + public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) + { + return null; + } + + /** + * Returns the font renderer used to render tooltips and overlays for this item. + * Returning null will use the standard font renderer. + * + * @param stack The current item stack + * @return A instance of FontRenderer or null to use default + */ + @SideOnly(Side.CLIENT) + public FontRenderer getFontRenderer(ItemStack stack) + { + return null; + } + + /** + * Override this method to have an item handle its own armor rendering. + * + * @param entityLiving The entity wearing the armor + * @param itemStack The itemStack to render the model of + * @param armorSlot 0=head, 1=torso, 2=legs, 3=feet + * + * @return A ModelBiped to render instead of the default + */ + @SideOnly(Side.CLIENT) + public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) + { + return null; + } + + /** + * Called when a entity tries to play the 'swing' animation. + * + * @param entityLiving The entity swinging the item. + * @param stack The Item stack + * @return True to cancel any further processing by EntityLiving + */ + public boolean onEntitySwing(EntityLivingBase entityLiving, ItemStack stack) + { + return false; + } + + /** + * Called when the client starts rendering the HUD, for whatever item the player currently has as a helmet. + * This is where pumpkins would render there overlay. + * + * @param stack The ItemStack that is equipped + * @param player Reference to the current client entity + * @param resolution Resolution information about the current viewport and configured GUI Scale + * @param partialTicks Partial ticks for the renderer, useful for interpolation + * @param hasScreen If the player has a screen up, which will be rendered after this. + * @param mouseX Mouse's X position on screen + * @param mouseY Mouse's Y position on screen + */ + @SideOnly(Side.CLIENT) + public void renderHelmetOverlay(ItemStack stack, EntityPlayer player, ScaledResolution resolution, float partialTicks, boolean hasScreen, int mouseX, int mouseY){} + + /** + * Return the itemDamage represented by this ItemStack. Defaults to the itemDamage field on ItemStack, but can be overridden here for other sources such as NBT. + * + * @param stack The itemstack that is damaged + * @return the damage value + */ + public int getDamage(ItemStack stack) + { + return stack.itemDamage; + } + + @Deprecated // This isn't 'display' its normal Damage, the above function is 'Aux' data, but the same value. + public int getDisplayDamage(ItemStack stack) + { + return stack.itemDamage; + } + + /** + * Determines if the durability bar should be rendered for this item. + * Defaults to vanilla stack.isDamaged behavior. + * But modders can use this for any data they wish. + * + * @param stack The current Item Stack + * @return True if it should render the 'durability' bar. + */ + public boolean showDurabilityBar(ItemStack stack) + { + return stack.isItemDamaged(); + } + + /** + * Queries the percentage of the 'Durability' bar that should be drawn. + * + * @param stack The current ItemStack + * @return 1.0 for 100% 0 for 0% + */ + public double getDurabilityForDisplay(ItemStack stack) + { + return (double)stack.getItemDamageForDisplay() / (double)stack.getMaxDamage(); + } + + /** + * Return the maxDamage for this ItemStack. Defaults to the maxDamage field in this item, + * but can be overridden here for other sources such as NBT. + * + * @param stack The itemstack that is damaged + * @return the damage value + */ + public int getMaxDamage(ItemStack stack) + { + return getMaxDamage(); + } + + /** + * Return if this itemstack is damaged. Note only called if {@link #isDamageable()} is true. + * @param stack the stack + * @return if the stack is damaged + */ + public boolean isDamaged(ItemStack stack) + { + return stack.itemDamage > 0; + } + + /** + * Set the damage for this itemstack. Note, this method is responsible for zero checking. + * @param stack the stack + * @param damage the new damage value + */ + public void setDamage(ItemStack stack, int damage) + { + stack.itemDamage = damage; + + if (stack.itemDamage < 0) + { + stack.itemDamage = 0; + } + } + + /** + * ItemStack sensitive version of {@link #canHarvestBlock(Block)} + * @param par1Block The block trying to harvest + * @param itemStack The itemstack used to harvest the block + * @return true if can harvest the block + */ + public boolean canHarvestBlock(Block par1Block, ItemStack itemStack) + { + return func_150897_b(par1Block); + } + + /** + * Render Pass sensitive version of hasEffect() + */ + @SideOnly(Side.CLIENT) + public boolean hasEffect(ItemStack par1ItemStack, int pass) + { + return hasEffect(par1ItemStack) && (pass == 0 || this != Items.potionitem); + } + + /** + * Gets the maximum number of items that this stack should be able to hold. + * This is a ItemStack (and thus NBT) sensitive version of Item.getItemStackLimit() + * + * @param stack The ItemStack + * @return THe maximum number this item can be stacked to + */ + public int getItemStackLimit(ItemStack stack) + { + return this.getItemStackLimit(); + } + + private HashMap toolClasses = new HashMap(); + /** + * Sets or removes the harvest level for the specified tool class. + * + * @param toolClass Class + * @param level Harvest level: + * Wood: 0 + * Stone: 1 + * Iron: 2 + * Diamond: 3 + * Gold: 0 + */ + public void setHarvestLevel(String toolClass, int level) + { + if (level < 0) + toolClasses.remove(toolClass); + else + toolClasses.put(toolClass, level); + } + + public Set getToolClasses(ItemStack stack) + { + return toolClasses.keySet(); + } + + /** + * Queries the harvest level of this item stack for the specifred tool class, + * Returns -1 if this tool is not of the specified type + * + * @param stack This item stack instance + * @param toolClass Tool Class + * @return Harvest level, or -1 if not the specified tool type. + */ + public int getHarvestLevel(ItemStack stack, String toolClass) + { + Integer ret = toolClasses.get(toolClass); + return ret == null ? -1 : ret; + } + /* ======================================== FORGE END =====================================*/ + + public static enum ToolMaterial + { + WOOD(0, 59, 2.0F, 0.0F, 15), + STONE(1, 131, 4.0F, 1.0F, 5), + IRON(2, 250, 6.0F, 2.0F, 14), + EMERALD(3, 1561, 8.0F, 3.0F, 10), + GOLD(0, 32, 12.0F, 0.0F, 22); + private final int harvestLevel; + private final int maxUses; + private final float efficiencyOnProperMaterial; + private final float damageVsEntity; + private final int enchantability; + + private static final String __OBFID = "CL_00000042"; + + //Added by forge for custom Tool materials. + public Item customCraftingMaterial = null; + + private ToolMaterial(int par3, int par4, float par5, float par6, int par7) + { + this.harvestLevel = par3; + this.maxUses = par4; + this.efficiencyOnProperMaterial = par5; + this.damageVsEntity = par6; + this.enchantability = par7; + } + + public int getMaxUses() + { + return this.maxUses; + } + + public float getEfficiencyOnProperMaterial() + { + return this.efficiencyOnProperMaterial; + } + + public float getDamageVsEntity() + { + return this.damageVsEntity; + } + + public int getHarvestLevel() + { + return this.harvestLevel; + } + + public int getEnchantability() + { + return this.enchantability; + } + + public Item func_150995_f() + { + switch (this) + { + case WOOD: return Item.getItemFromBlock(Blocks.planks); + case STONE: return Item.getItemFromBlock(Blocks.cobblestone); + case GOLD: return Items.gold_ingot; + case IRON: return Items.iron_ingot; + case EMERALD: return Items.diamond; + default: return customCraftingMaterial; + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemAnvilBlock.java b/src/main/java/net/minecraft/item/ItemAnvilBlock.java new file mode 100644 index 0000000..bada25d --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemAnvilBlock.java @@ -0,0 +1,19 @@ +package net.minecraft.item; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockAnvil; + +public class ItemAnvilBlock extends ItemMultiTexture +{ + private static final String __OBFID = "CL_00001764"; + + public ItemAnvilBlock(Block par1Block) + { + super(par1Block, par1Block, BlockAnvil.anvilDamageNames); + } + + public int getMetadata(int par1) + { + return par1 << 2; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemAppleGold.java b/src/main/java/net/minecraft/item/ItemAppleGold.java new file mode 100644 index 0000000..96b74ef --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemAppleGold.java @@ -0,0 +1,61 @@ +package net.minecraft.item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.world.World; + +public class ItemAppleGold extends ItemFood +{ + private static final String __OBFID = "CL_00000037"; + + public ItemAppleGold(int p_i45341_1_, float p_i45341_2_, boolean p_i45341_3_) + { + super(p_i45341_1_, p_i45341_2_, p_i45341_3_); + this.setHasSubtypes(true); + } + + @SideOnly(Side.CLIENT) + public boolean hasEffect(ItemStack par1ItemStack) + { + return par1ItemStack.getItemDamage() > 0; + } + + public EnumRarity getRarity(ItemStack par1ItemStack) + { + return par1ItemStack.getItemDamage() == 0 ? EnumRarity.rare : EnumRarity.epic; + } + + protected void onFoodEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + { + if (!par2World.isRemote) + { + par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.field_76444_x.id, 2400, 0)); + } + + if (par1ItemStack.getItemDamage() > 0) + { + if (!par2World.isRemote) + { + par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.regeneration.id, 600, 4)); + par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.resistance.id, 6000, 0)); + par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 6000, 0)); + } + } + else + { + super.onFoodEaten(par1ItemStack, par2World, par3EntityPlayer); + } + } + + @SideOnly(Side.CLIENT) + public void getSubItems(Item p_150895_1_, CreativeTabs p_150895_2_, List p_150895_3_) + { + p_150895_3_.add(new ItemStack(p_150895_1_, 1, 0)); + p_150895_3_.add(new ItemStack(p_150895_1_, 1, 1)); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemArmor.java b/src/main/java/net/minecraft/item/ItemArmor.java new file mode 100644 index 0000000..fea1f33 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemArmor.java @@ -0,0 +1,300 @@ +package net.minecraft.item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.block.BlockDispenser; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.command.IEntitySelector; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.dispenser.BehaviorDefaultDispenseItem; +import net.minecraft.dispenser.IBehaviorDispenseItem; +import net.minecraft.dispenser.IBlockSource; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +public class ItemArmor extends Item +{ + private static final int[] maxDamageArray = new int[] {11, 16, 15, 13}; + private static final String[] CLOTH_OVERLAY_NAMES = new String[] {"leather_helmet_overlay", "leather_chestplate_overlay", "leather_leggings_overlay", "leather_boots_overlay"}; + public static final String[] EMPTY_SLOT_NAMES = new String[] {"empty_armor_slot_helmet", "empty_armor_slot_chestplate", "empty_armor_slot_leggings", "empty_armor_slot_boots"}; + private static final IBehaviorDispenseItem dispenserBehavior = new BehaviorDefaultDispenseItem() + { + private static final String __OBFID = "CL_00001767"; + protected ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) + { + EnumFacing enumfacing = BlockDispenser.func_149937_b(par1IBlockSource.getBlockMetadata()); + int i = par1IBlockSource.getXInt() + enumfacing.getFrontOffsetX(); + int j = par1IBlockSource.getYInt() + enumfacing.getFrontOffsetY(); + int k = par1IBlockSource.getZInt() + enumfacing.getFrontOffsetZ(); + AxisAlignedBB axisalignedbb = AxisAlignedBB.getAABBPool().getAABB((double)i, (double)j, (double)k, (double)(i + 1), (double)(j + 1), (double)(k + 1)); + List list = par1IBlockSource.getWorld().selectEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb, new IEntitySelector.ArmoredMob(par2ItemStack)); + + if (list.size() > 0) + { + EntityLivingBase entitylivingbase = (EntityLivingBase)list.get(0); + int l = entitylivingbase instanceof EntityPlayer ? 1 : 0; + int i1 = EntityLiving.getArmorPosition(par2ItemStack); + ItemStack itemstack1 = par2ItemStack.copy(); + itemstack1.stackSize = 1; + entitylivingbase.setCurrentItemOrArmor(i1 - l, itemstack1); + + if (entitylivingbase instanceof EntityLiving) + { + ((EntityLiving)entitylivingbase).setEquipmentDropChance(i1, 2.0F); + } + + --par2ItemStack.stackSize; + return par2ItemStack; + } + else + { + return super.dispenseStack(par1IBlockSource, par2ItemStack); + } + } + }; + public final int armorType; + public final int damageReduceAmount; + public final int renderIndex; + private final ItemArmor.ArmorMaterial material; + @SideOnly(Side.CLIENT) + private IIcon overlayIcon; + @SideOnly(Side.CLIENT) + private IIcon emptySlotIcon; + private static final String __OBFID = "CL_00001766"; + + public ItemArmor(ItemArmor.ArmorMaterial p_i45325_1_, int p_i45325_2_, int p_i45325_3_) + { + this.material = p_i45325_1_; + this.armorType = p_i45325_3_; + this.renderIndex = p_i45325_2_; + this.damageReduceAmount = p_i45325_1_.getDamageReductionAmount(p_i45325_3_); + this.setMaxDamage(p_i45325_1_.getDurability(p_i45325_3_)); + this.maxStackSize = 1; + this.setCreativeTab(CreativeTabs.tabCombat); + BlockDispenser.dispenseBehaviorRegistry.putObject(this, dispenserBehavior); + } + + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) + { + if (par2 > 0) + { + return 16777215; + } + else + { + int j = this.getColor(par1ItemStack); + + if (j < 0) + { + j = 16777215; + } + + return j; + } + } + + @SideOnly(Side.CLIENT) + public boolean requiresMultipleRenderPasses() + { + return this.material == ItemArmor.ArmorMaterial.CLOTH; + } + + public int getItemEnchantability() + { + return this.material.getEnchantability(); + } + + public ItemArmor.ArmorMaterial getArmorMaterial() + { + return this.material; + } + + public boolean hasColor(ItemStack par1ItemStack) + { + return this.material != ItemArmor.ArmorMaterial.CLOTH ? false : (!par1ItemStack.hasTagCompound() ? false : (!par1ItemStack.getTagCompound().hasKey("display", 10) ? false : par1ItemStack.getTagCompound().getCompoundTag("display").hasKey("color", 3))); + } + + public int getColor(ItemStack par1ItemStack) + { + if (this.material != ItemArmor.ArmorMaterial.CLOTH) + { + return -1; + } + else + { + NBTTagCompound nbttagcompound = par1ItemStack.getTagCompound(); + + if (nbttagcompound == null) + { + return 10511680; + } + else + { + NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("display"); + return nbttagcompound1 == null ? 10511680 : (nbttagcompound1.hasKey("color", 3) ? nbttagcompound1.getInteger("color") : 10511680); + } + } + } + + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamageForRenderPass(int par1, int par2) + { + return par2 == 1 ? this.overlayIcon : super.getIconFromDamageForRenderPass(par1, par2); + } + + public void removeColor(ItemStack par1ItemStack) + { + if (this.material == ItemArmor.ArmorMaterial.CLOTH) + { + NBTTagCompound nbttagcompound = par1ItemStack.getTagCompound(); + + if (nbttagcompound != null) + { + NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("display"); + + if (nbttagcompound1.hasKey("color")) + { + nbttagcompound1.removeTag("color"); + } + } + } + } + + public void func_82813_b(ItemStack par1ItemStack, int par2) + { + if (this.material != ItemArmor.ArmorMaterial.CLOTH) + { + throw new UnsupportedOperationException("Can\'t dye non-leather!"); + } + else + { + NBTTagCompound nbttagcompound = par1ItemStack.getTagCompound(); + + if (nbttagcompound == null) + { + nbttagcompound = new NBTTagCompound(); + par1ItemStack.setTagCompound(nbttagcompound); + } + + NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("display"); + + if (!nbttagcompound.hasKey("display", 10)) + { + nbttagcompound.setTag("display", nbttagcompound1); + } + + nbttagcompound1.setInteger("color", par2); + } + } + + public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) + { + return this.material.func_151685_b() == par2ItemStack.getItem() ? true : super.getIsRepairable(par1ItemStack, par2ItemStack); + } + + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) + { + super.registerIcons(par1IconRegister); + + if (this.material == ItemArmor.ArmorMaterial.CLOTH) + { + this.overlayIcon = par1IconRegister.registerIcon(CLOTH_OVERLAY_NAMES[this.armorType]); + } + + this.emptySlotIcon = par1IconRegister.registerIcon(EMPTY_SLOT_NAMES[this.armorType]); + } + + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + { + int i = EntityLiving.getArmorPosition(par1ItemStack) - 1; + ItemStack itemstack1 = par3EntityPlayer.getCurrentArmor(i); + + if (itemstack1 == null) + { + par3EntityPlayer.setCurrentItemOrArmor(i + 1, par1ItemStack.copy()); //Forge: Vanilla bug fix associated with fixed setCurrentItemOrArmor indexs for players. + par1ItemStack.stackSize = 0; + } + + return par1ItemStack; + } + + @SideOnly(Side.CLIENT) + public static IIcon func_94602_b(int par0) + { + switch (par0) + { + case 0: + return Items.diamond_helmet.emptySlotIcon; + case 1: + return Items.diamond_chestplate.emptySlotIcon; + case 2: + return Items.diamond_leggings.emptySlotIcon; + case 3: + return Items.diamond_boots.emptySlotIcon; + default: + return null; + } + } + + public static enum ArmorMaterial + { + CLOTH(5, new int[]{1, 3, 2, 1}, 15), + CHAIN(15, new int[]{2, 5, 4, 1}, 12), + IRON(15, new int[]{2, 6, 5, 2}, 9), + GOLD(7, new int[]{2, 5, 3, 1}, 25), + DIAMOND(33, new int[]{3, 8, 6, 3}, 10); + private int maxDamageFactor; + private int[] damageReductionAmountArray; + private int enchantability; + + private static final String __OBFID = "CL_00001768"; + + //Added by forge for custom Armor materials. + public Item customCraftingMaterial = null; + + private ArmorMaterial(int par3, int[] par4ArrayOfInteger, int par5) + { + this.maxDamageFactor = par3; + this.damageReductionAmountArray = par4ArrayOfInteger; + this.enchantability = par5; + } + + public int getDurability(int par1) + { + return ItemArmor.maxDamageArray[par1] * this.maxDamageFactor; + } + + public int getDamageReductionAmount(int par1) + { + return this.damageReductionAmountArray[par1]; + } + + public int getEnchantability() + { + return this.enchantability; + } + + public Item func_151685_b() + { + switch (this) + { + case CLOTH: return Items.leather; + case CHAIN: return Items.iron_ingot; + case GOLD: return Items.gold_ingot; + case IRON: return Items.iron_ingot; + case DIAMOND: return Items.diamond; + default: return customCraftingMaterial; + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemAxe.java b/src/main/java/net/minecraft/item/ItemAxe.java new file mode 100644 index 0000000..342fe7c --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemAxe.java @@ -0,0 +1,23 @@ +package net.minecraft.item; + +import com.google.common.collect.Sets; +import java.util.Set; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; + +public class ItemAxe extends ItemTool +{ + private static final Set field_150917_c = Sets.newHashSet(new Block[] {Blocks.planks, Blocks.bookshelf, Blocks.log, Blocks.log2, Blocks.chest, Blocks.pumpkin, Blocks.lit_pumpkin}); + private static final String __OBFID = "CL_00001770"; + + protected ItemAxe(Item.ToolMaterial p_i45327_1_) + { + super(3.0F, p_i45327_1_, field_150917_c); + } + + public float func_150893_a(ItemStack p_150893_1_, Block p_150893_2_) + { + return p_150893_2_.getMaterial() != Material.wood && p_150893_2_.getMaterial() != Material.plants && p_150893_2_.getMaterial() != Material.vine ? super.func_150893_a(p_150893_1_, p_150893_2_) : this.efficiencyOnProperMaterial; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemBed.java b/src/main/java/net/minecraft/item/ItemBed.java new file mode 100644 index 0000000..7f95bbf --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemBed.java @@ -0,0 +1,82 @@ +package net.minecraft.item; + +import net.minecraft.block.BlockBed; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class ItemBed extends Item +{ + private static final String __OBFID = "CL_00001771"; + + public ItemBed() + { + this.setCreativeTab(CreativeTabs.tabDecorations); + } + + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) + { + if (par3World.isRemote) + { + return true; + } + else if (par7 != 1) + { + return false; + } + else + { + ++par5; + BlockBed blockbed = (BlockBed)Blocks.bed; + int i1 = MathHelper.floor_double((double)(par2EntityPlayer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + byte b0 = 0; + byte b1 = 0; + + if (i1 == 0) + { + b1 = 1; + } + + if (i1 == 1) + { + b0 = -1; + } + + if (i1 == 2) + { + b1 = -1; + } + + if (i1 == 3) + { + b0 = 1; + } + + if (par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack) && par2EntityPlayer.canPlayerEdit(par4 + b0, par5, par6 + b1, par7, par1ItemStack)) + { + if (par3World.isAirBlock(par4, par5, par6) && par3World.isAirBlock(par4 + b0, par5, par6 + b1) && World.doesBlockHaveSolidTopSurface(par3World, par4, par5 - 1, par6) && World.doesBlockHaveSolidTopSurface(par3World, par4 + b0, par5 - 1, par6 + b1)) + { + par3World.setBlock(par4, par5, par6, blockbed, i1, 3); + + if (par3World.getBlock(par4, par5, par6) == blockbed) + { + par3World.setBlock(par4 + b0, par5, par6 + b1, blockbed, i1 + 8, 3); + } + + --par1ItemStack.stackSize; + return true; + } + else + { + return false; + } + } + else + { + return false; + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemBlock.java b/src/main/java/net/minecraft/item/ItemBlock.java new file mode 100644 index 0000000..60be6fa --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemBlock.java @@ -0,0 +1,219 @@ +package net.minecraft.item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +public class ItemBlock extends Item +{ + public final Block field_150939_a; + @SideOnly(Side.CLIENT) + private IIcon field_150938_b; + private static final String __OBFID = "CL_00001772"; + + public ItemBlock(Block p_i45328_1_) + { + this.field_150939_a = p_i45328_1_; + } + + public ItemBlock setUnlocalizedName(String p_150937_1_) + { + super.setUnlocalizedName(p_150937_1_); + return this; + } + + @SideOnly(Side.CLIENT) + public int getSpriteNumber() + { + return this.field_150939_a.getItemIconName() != null ? 1 : 0; + } + + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int par1) + { + return this.field_150938_b != null ? this.field_150938_b : this.field_150939_a.getBlockTextureFromSide(1); + } + + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) + { + Block block = par3World.getBlock(par4, par5, par6); + + if (block == Blocks.snow_layer && (par3World.getBlockMetadata(par4, par5, par6) & 7) < 1) + { + par7 = 1; + } + else if (block != Blocks.vine && block != Blocks.tallgrass && block != Blocks.deadbush && !block.isReplaceable(par3World, par4, par5, par6)) + { + if (par7 == 0) + { + --par5; + } + + if (par7 == 1) + { + ++par5; + } + + if (par7 == 2) + { + --par6; + } + + if (par7 == 3) + { + ++par6; + } + + if (par7 == 4) + { + --par4; + } + + if (par7 == 5) + { + ++par4; + } + } + + if (par1ItemStack.stackSize == 0) + { + return false; + } + else if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack)) + { + return false; + } + else if (par5 == 255 && this.field_150939_a.getMaterial().isSolid()) + { + return false; + } + else if (par3World.canPlaceEntityOnSide(this.field_150939_a, par4, par5, par6, false, par7, par2EntityPlayer, par1ItemStack)) + { + int i1 = this.getMetadata(par1ItemStack.getItemDamage()); + int j1 = this.field_150939_a.onBlockPlaced(par3World, par4, par5, par6, par7, par8, par9, par10, i1); + + if (placeBlockAt(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10, j1)) + { + par3World.playSoundEffect((double)((float)par4 + 0.5F), (double)((float)par5 + 0.5F), (double)((float)par6 + 0.5F), this.field_150939_a.stepSound.func_150496_b(), (this.field_150939_a.stepSound.getVolume() + 1.0F) / 2.0F, this.field_150939_a.stepSound.getPitch() * 0.8F); + --par1ItemStack.stackSize; + } + + return true; + } + else + { + return false; + } + } + + @SideOnly(Side.CLIENT) + public boolean func_150936_a(World p_150936_1_, int p_150936_2_, int p_150936_3_, int p_150936_4_, int p_150936_5_, EntityPlayer p_150936_6_, ItemStack p_150936_7_) + { + Block block = p_150936_1_.getBlock(p_150936_2_, p_150936_3_, p_150936_4_); + + if (block == Blocks.snow_layer) + { + p_150936_5_ = 1; + } + else if (block != Blocks.vine && block != Blocks.tallgrass && block != Blocks.deadbush && !block.isReplaceable(p_150936_1_, p_150936_2_, p_150936_3_, p_150936_4_)) + { + if (p_150936_5_ == 0) + { + --p_150936_3_; + } + + if (p_150936_5_ == 1) + { + ++p_150936_3_; + } + + if (p_150936_5_ == 2) + { + --p_150936_4_; + } + + if (p_150936_5_ == 3) + { + ++p_150936_4_; + } + + if (p_150936_5_ == 4) + { + --p_150936_2_; + } + + if (p_150936_5_ == 5) + { + ++p_150936_2_; + } + } + + return p_150936_1_.canPlaceEntityOnSide(this.field_150939_a, p_150936_2_, p_150936_3_, p_150936_4_, false, p_150936_5_, (Entity)null, p_150936_7_); + } + + public String getUnlocalizedName(ItemStack par1ItemStack) + { + return this.field_150939_a.getUnlocalizedName(); + } + + public String getUnlocalizedName() + { + return this.field_150939_a.getUnlocalizedName(); + } + + @SideOnly(Side.CLIENT) + public CreativeTabs getCreativeTab() + { + return this.field_150939_a.getCreativeTabToDisplayOn(); + } + + @SideOnly(Side.CLIENT) + public void getSubItems(Item p_150895_1_, CreativeTabs p_150895_2_, List p_150895_3_) + { + this.field_150939_a.getSubBlocks(p_150895_1_, p_150895_2_, p_150895_3_); + } + + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) + { + String s = this.field_150939_a.getItemIconName(); + + if (s != null) + { + this.field_150938_b = par1IconRegister.registerIcon(s); + } + } + + /** + * Called to actually place the block, after the location is determined + * and all permission checks have been made. + * + * @param stack The item stack that was used to place the block. This can be changed inside the method. + * @param player The player who is placing the block. Can be null if the block is not being placed by a player. + * @param side The side the player (or machine) right-clicked on. + */ + public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) + { + + if (!world.setBlock(x, y, z, field_150939_a, metadata, 3)) + { + return false; + } + + if (world.getBlock(x, y, z) == field_150939_a) + { + field_150939_a.onBlockPlacedBy(world, x, y, z, player, stack); + field_150939_a.onPostBlockPlaced(world, x, y, z, metadata); + } + + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemBlockWithMetadata.java b/src/main/java/net/minecraft/item/ItemBlockWithMetadata.java new file mode 100644 index 0000000..789a13a --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemBlockWithMetadata.java @@ -0,0 +1,31 @@ +package net.minecraft.item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.util.IIcon; + +public class ItemBlockWithMetadata extends ItemBlock +{ + private Block field_150950_b; + private static final String __OBFID = "CL_00001769"; + + public ItemBlockWithMetadata(Block p_i45326_1_, Block p_i45326_2_) + { + super(p_i45326_1_); + this.field_150950_b = p_i45326_2_; + this.setMaxDamage(0); + this.setHasSubtypes(true); + } + + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int par1) + { + return this.field_150950_b.getIcon(2, par1); + } + + public int getMetadata(int par1) + { + return par1; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemBoat.java b/src/main/java/net/minecraft/item/ItemBoat.java new file mode 100644 index 0000000..fd36781 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemBoat.java @@ -0,0 +1,112 @@ +package net.minecraft.item; + +import java.util.List; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityBoat; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; + +public class ItemBoat extends Item +{ + private static final String __OBFID = "CL_00001774"; + + public ItemBoat() + { + this.maxStackSize = 1; + this.setCreativeTab(CreativeTabs.tabTransport); + } + + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + { + float f = 1.0F; + float f1 = par3EntityPlayer.prevRotationPitch + (par3EntityPlayer.rotationPitch - par3EntityPlayer.prevRotationPitch) * f; + float f2 = par3EntityPlayer.prevRotationYaw + (par3EntityPlayer.rotationYaw - par3EntityPlayer.prevRotationYaw) * f; + double d0 = par3EntityPlayer.prevPosX + (par3EntityPlayer.posX - par3EntityPlayer.prevPosX) * (double)f; + double d1 = par3EntityPlayer.prevPosY + (par3EntityPlayer.posY - par3EntityPlayer.prevPosY) * (double)f + 1.62D - (double)par3EntityPlayer.yOffset; + double d2 = par3EntityPlayer.prevPosZ + (par3EntityPlayer.posZ - par3EntityPlayer.prevPosZ) * (double)f; + Vec3 vec3 = par2World.getWorldVec3Pool().getVecFromPool(d0, d1, d2); + float f3 = MathHelper.cos(-f2 * 0.017453292F - (float)Math.PI); + float f4 = MathHelper.sin(-f2 * 0.017453292F - (float)Math.PI); + float f5 = -MathHelper.cos(-f1 * 0.017453292F); + float f6 = MathHelper.sin(-f1 * 0.017453292F); + float f7 = f4 * f5; + float f8 = f3 * f5; + double d3 = 5.0D; + Vec3 vec31 = vec3.addVector((double)f7 * d3, (double)f6 * d3, (double)f8 * d3); + MovingObjectPosition movingobjectposition = par2World.rayTraceBlocks(vec3, vec31, true); + + if (movingobjectposition == null) + { + return par1ItemStack; + } + else + { + Vec3 vec32 = par3EntityPlayer.getLook(f); + boolean flag = false; + float f9 = 1.0F; + List list = par2World.getEntitiesWithinAABBExcludingEntity(par3EntityPlayer, par3EntityPlayer.boundingBox.addCoord(vec32.xCoord * d3, vec32.yCoord * d3, vec32.zCoord * d3).expand((double)f9, (double)f9, (double)f9)); + int i; + + for (i = 0; i < list.size(); ++i) + { + Entity entity = (Entity)list.get(i); + + if (entity.canBeCollidedWith()) + { + float f10 = entity.getCollisionBorderSize(); + AxisAlignedBB axisalignedbb = entity.boundingBox.expand((double)f10, (double)f10, (double)f10); + + if (axisalignedbb.isVecInside(vec3)) + { + flag = true; + } + } + } + + if (flag) + { + return par1ItemStack; + } + else + { + if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) + { + i = movingobjectposition.blockX; + int j = movingobjectposition.blockY; + int k = movingobjectposition.blockZ; + + if (par2World.getBlock(i, j, k) == Blocks.snow_layer) + { + --j; + } + + EntityBoat entityboat = new EntityBoat(par2World, (double)((float)i + 0.5F), (double)((float)j + 1.0F), (double)((float)k + 0.5F)); + entityboat.rotationYaw = (float)(((MathHelper.floor_double((double)(par3EntityPlayer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3) - 1) * 90); + + if (!par2World.getCollidingBoundingBoxes(entityboat, entityboat.boundingBox.expand(-0.1D, -0.1D, -0.1D)).isEmpty()) + { + return par1ItemStack; + } + + if (!par2World.isRemote) + { + par2World.spawnEntityInWorld(entityboat); + } + + if (!par3EntityPlayer.capabilities.isCreativeMode) + { + --par1ItemStack.stackSize; + } + } + + return par1ItemStack; + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemBook.java b/src/main/java/net/minecraft/item/ItemBook.java new file mode 100644 index 0000000..f59e6e6 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemBook.java @@ -0,0 +1,16 @@ +package net.minecraft.item; + +public class ItemBook extends Item +{ + private static final String __OBFID = "CL_00001775"; + + public boolean isItemTool(ItemStack par1ItemStack) + { + return par1ItemStack.stackSize == 1; + } + + public int getItemEnchantability() + { + return 1; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemBow.java b/src/main/java/net/minecraft/item/ItemBow.java new file mode 100644 index 0000000..b163726 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemBow.java @@ -0,0 +1,160 @@ +package net.minecraft.item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.init.Items; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.player.ArrowLooseEvent; +import net.minecraftforge.event.entity.player.ArrowNockEvent; + +public class ItemBow extends Item +{ + public static final String[] bowPullIconNameArray = new String[] {"pulling_0", "pulling_1", "pulling_2"}; + @SideOnly(Side.CLIENT) + private IIcon[] iconArray; + private static final String __OBFID = "CL_00001777"; + + public ItemBow() + { + this.maxStackSize = 1; + this.setMaxDamage(384); + this.setCreativeTab(CreativeTabs.tabCombat); + } + + public void onPlayerStoppedUsing(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, int par4) + { + int j = this.getMaxItemUseDuration(par1ItemStack) - par4; + + ArrowLooseEvent event = new ArrowLooseEvent(par3EntityPlayer, par1ItemStack, j); + MinecraftForge.EVENT_BUS.post(event); + if (event.isCanceled()) + { + return; + } + j = event.charge; + + boolean flag = par3EntityPlayer.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, par1ItemStack) > 0; + + if (flag || par3EntityPlayer.inventory.hasItem(Items.arrow)) + { + float f = (float)j / 20.0F; + f = (f * f + f * 2.0F) / 3.0F; + + if ((double)f < 0.1D) + { + return; + } + + if (f > 1.0F) + { + f = 1.0F; + } + + EntityArrow entityarrow = new EntityArrow(par2World, par3EntityPlayer, f * 2.0F); + + if (f == 1.0F) + { + entityarrow.setIsCritical(true); + } + + int k = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, par1ItemStack); + + if (k > 0) + { + entityarrow.setDamage(entityarrow.getDamage() + (double)k * 0.5D + 0.5D); + } + + int l = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, par1ItemStack); + + if (l > 0) + { + entityarrow.setKnockbackStrength(l); + } + + if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, par1ItemStack) > 0) + { + entityarrow.setFire(100); + } + + par1ItemStack.damageItem(1, par3EntityPlayer); + par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F); + + if (flag) + { + entityarrow.canBePickedUp = 2; + } + else + { + par3EntityPlayer.inventory.consumeInventoryItem(Items.arrow); + } + + if (!par2World.isRemote) + { + par2World.spawnEntityInWorld(entityarrow); + } + } + } + + public ItemStack onEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + { + return par1ItemStack; + } + + public int getMaxItemUseDuration(ItemStack par1ItemStack) + { + return 72000; + } + + public EnumAction getItemUseAction(ItemStack par1ItemStack) + { + return EnumAction.bow; + } + + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + { + ArrowNockEvent event = new ArrowNockEvent(par3EntityPlayer, par1ItemStack); + MinecraftForge.EVENT_BUS.post(event); + if (event.isCanceled()) + { + return event.result; + } + + if (par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(Items.arrow)) + { + par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); + } + + return par1ItemStack; + } + + public int getItemEnchantability() + { + return 1; + } + + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) + { + this.itemIcon = par1IconRegister.registerIcon(this.getIconString() + "_standby"); + this.iconArray = new IIcon[bowPullIconNameArray.length]; + + for (int i = 0; i < this.iconArray.length; ++i) + { + this.iconArray[i] = par1IconRegister.registerIcon(this.getIconString() + "_" + bowPullIconNameArray[i]); + } + } + + @SideOnly(Side.CLIENT) + public IIcon getItemIconForUseDuration(int par1) + { + return this.iconArray[par1]; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemBucket.java b/src/main/java/net/minecraft/item/ItemBucket.java new file mode 100644 index 0000000..7d0901b --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemBucket.java @@ -0,0 +1,210 @@ +package net.minecraft.item; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; +import cpw.mods.fml.common.eventhandler.Event; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.player.FillBucketEvent; + +public class ItemBucket extends Item +{ + private Block isFull; + private static final String __OBFID = "CL_00000000"; + + public ItemBucket(Block p_i45331_1_) + { + this.maxStackSize = 1; + this.isFull = p_i45331_1_; + this.setCreativeTab(CreativeTabs.tabMisc); + } + + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + { + boolean flag = this.isFull == Blocks.air; + MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, flag); + + if (movingobjectposition == null) + { + return par1ItemStack; + } + else + { + FillBucketEvent event = new FillBucketEvent(par3EntityPlayer, par1ItemStack, par2World, movingobjectposition); + if (MinecraftForge.EVENT_BUS.post(event)) + { + return par1ItemStack; + } + + if (event.getResult() == Event.Result.ALLOW) + { + if (par3EntityPlayer.capabilities.isCreativeMode) + { + return par1ItemStack; + } + + if (--par1ItemStack.stackSize <= 0) + { + return event.result; + } + + if (!par3EntityPlayer.inventory.addItemStackToInventory(event.result)) + { + par3EntityPlayer.dropPlayerItemWithRandomChoice(event.result, false); + } + + return par1ItemStack; + } + if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) + { + int i = movingobjectposition.blockX; + int j = movingobjectposition.blockY; + int k = movingobjectposition.blockZ; + + if (!par2World.canMineBlock(par3EntityPlayer, i, j, k)) + { + return par1ItemStack; + } + + if (flag) + { + if (!par3EntityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, par1ItemStack)) + { + return par1ItemStack; + } + + Material material = par2World.getBlock(i, j, k).getMaterial(); + int l = par2World.getBlockMetadata(i, j, k); + + if (material == Material.water && l == 0) + { + par2World.setBlockToAir(i, j, k); + return this.func_150910_a(par1ItemStack, par3EntityPlayer, Items.water_bucket); + } + + if (material == Material.lava && l == 0) + { + par2World.setBlockToAir(i, j, k); + return this.func_150910_a(par1ItemStack, par3EntityPlayer, Items.lava_bucket); + } + } + else + { + if (this.isFull == Blocks.air) + { + return new ItemStack(Items.bucket); + } + + if (movingobjectposition.sideHit == 0) + { + --j; + } + + if (movingobjectposition.sideHit == 1) + { + ++j; + } + + if (movingobjectposition.sideHit == 2) + { + --k; + } + + if (movingobjectposition.sideHit == 3) + { + ++k; + } + + if (movingobjectposition.sideHit == 4) + { + --i; + } + + if (movingobjectposition.sideHit == 5) + { + ++i; + } + + if (!par3EntityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, par1ItemStack)) + { + return par1ItemStack; + } + + if (this.tryPlaceContainedLiquid(par2World, i, j, k) && !par3EntityPlayer.capabilities.isCreativeMode) + { + return new ItemStack(Items.bucket); + } + } + } + + return par1ItemStack; + } + } + + private ItemStack func_150910_a(ItemStack p_150910_1_, EntityPlayer p_150910_2_, Item p_150910_3_) + { + if (p_150910_2_.capabilities.isCreativeMode) + { + return p_150910_1_; + } + else if (--p_150910_1_.stackSize <= 0) + { + return new ItemStack(p_150910_3_); + } + else + { + if (!p_150910_2_.inventory.addItemStackToInventory(new ItemStack(p_150910_3_))) + { + p_150910_2_.dropPlayerItemWithRandomChoice(new ItemStack(p_150910_3_, 1, 0), false); + } + + return p_150910_1_; + } + } + + public boolean tryPlaceContainedLiquid(World par1World, int par2, int par3, int par4) + { + if (this.isFull == Blocks.air) + { + return false; + } + else + { + Material material = par1World.getBlock(par2, par3, par4).getMaterial(); + boolean flag = !material.isSolid(); + + if (!par1World.isAirBlock(par2, par3, par4) && !flag) + { + return false; + } + else + { + if (par1World.provider.isHellWorld && this.isFull == Blocks.flowing_water) + { + par1World.playSoundEffect((double)((float)par2 + 0.5F), (double)((float)par3 + 0.5F), (double)((float)par4 + 0.5F), "random.fizz", 0.5F, 2.6F + (par1World.rand.nextFloat() - par1World.rand.nextFloat()) * 0.8F); + + for (int l = 0; l < 8; ++l) + { + par1World.spawnParticle("largesmoke", (double)par2 + Math.random(), (double)par3 + Math.random(), (double)par4 + Math.random(), 0.0D, 0.0D, 0.0D); + } + } + else + { + if (!par1World.isRemote && flag && !material.isLiquid()) + { + par1World.func_147480_a(par2, par3, par4, true); + } + + par1World.setBlock(par2, par3, par4, this.isFull, 0, 3); + } + + return true; + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemBucketMilk.java b/src/main/java/net/minecraft/item/ItemBucketMilk.java new file mode 100644 index 0000000..4ff82b8 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemBucketMilk.java @@ -0,0 +1,48 @@ +package net.minecraft.item; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.world.World; + +public class ItemBucketMilk extends Item +{ + private static final String __OBFID = "CL_00000048"; + + public ItemBucketMilk() + { + this.setMaxStackSize(1); + this.setCreativeTab(CreativeTabs.tabMisc); + } + + public ItemStack onEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + { + if (!par3EntityPlayer.capabilities.isCreativeMode) + { + --par1ItemStack.stackSize; + } + + if (!par2World.isRemote) + { + par3EntityPlayer.curePotionEffects(par1ItemStack); + } + + return par1ItemStack.stackSize <= 0 ? new ItemStack(Items.bucket) : par1ItemStack; + } + + public int getMaxItemUseDuration(ItemStack par1ItemStack) + { + return 32; + } + + public EnumAction getItemUseAction(ItemStack par1ItemStack) + { + return EnumAction.drink; + } + + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + { + par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); + return par1ItemStack; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemCarrotOnAStick.java b/src/main/java/net/minecraft/item/ItemCarrotOnAStick.java new file mode 100644 index 0000000..aa63b26 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemCarrotOnAStick.java @@ -0,0 +1,56 @@ +package net.minecraft.item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.passive.EntityPig; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.world.World; + +public class ItemCarrotOnAStick extends Item +{ + private static final String __OBFID = "CL_00000001"; + + public ItemCarrotOnAStick() + { + this.setCreativeTab(CreativeTabs.tabTransport); + this.setMaxStackSize(1); + this.setMaxDamage(25); + } + + @SideOnly(Side.CLIENT) + public boolean isFull3D() + { + return true; + } + + @SideOnly(Side.CLIENT) + public boolean shouldRotateAroundWhenRendering() + { + return true; + } + + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + { + if (par3EntityPlayer.isRiding() && par3EntityPlayer.ridingEntity instanceof EntityPig) + { + EntityPig entitypig = (EntityPig)par3EntityPlayer.ridingEntity; + + if (entitypig.getAIControlledByPlayer().isControlledByPlayer() && par1ItemStack.getMaxDamage() - par1ItemStack.getItemDamage() >= 7) + { + entitypig.getAIControlledByPlayer().boostSpeed(); + par1ItemStack.damageItem(7, par3EntityPlayer); + + if (par1ItemStack.stackSize == 0) + { + ItemStack itemstack1 = new ItemStack(Items.fishing_rod); + itemstack1.setTagCompound(par1ItemStack.stackTagCompound); + return itemstack1; + } + } + } + + return par1ItemStack; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemCloth.java b/src/main/java/net/minecraft/item/ItemCloth.java new file mode 100644 index 0000000..c03657b --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemCloth.java @@ -0,0 +1,35 @@ +package net.minecraft.item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.block.BlockColored; +import net.minecraft.util.IIcon; + +public class ItemCloth extends ItemBlock +{ + private static final String __OBFID = "CL_00000075"; + + public ItemCloth(Block p_i45358_1_) + { + super(p_i45358_1_); + this.setMaxDamage(0); + this.setHasSubtypes(true); + } + + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int par1) + { + return this.field_150939_a.func_149735_b(2, BlockColored.func_150032_b(par1)); + } + + public int getMetadata(int par1) + { + return par1; + } + + public String getUnlocalizedName(ItemStack par1ItemStack) + { + return super.getUnlocalizedName() + "." + ItemDye.field_150923_a[BlockColored.func_150032_b(par1ItemStack.getItemDamage())]; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemCoal.java b/src/main/java/net/minecraft/item/ItemCoal.java new file mode 100644 index 0000000..6878ac0 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemCoal.java @@ -0,0 +1,47 @@ +package net.minecraft.item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.util.IIcon; + +public class ItemCoal extends Item +{ + @SideOnly(Side.CLIENT) + private IIcon field_111220_a; + private static final String __OBFID = "CL_00000002"; + + public ItemCoal() + { + this.setHasSubtypes(true); + this.setMaxDamage(0); + this.setCreativeTab(CreativeTabs.tabMaterials); + } + + public String getUnlocalizedName(ItemStack par1ItemStack) + { + return par1ItemStack.getItemDamage() == 1 ? "item.charcoal" : "item.coal"; + } + + @SideOnly(Side.CLIENT) + public void getSubItems(Item p_150895_1_, CreativeTabs p_150895_2_, List p_150895_3_) + { + p_150895_3_.add(new ItemStack(p_150895_1_, 1, 0)); + p_150895_3_.add(new ItemStack(p_150895_1_, 1, 1)); + } + + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int par1) + { + return par1 == 1 ? this.field_111220_a : super.getIconFromDamage(par1); + } + + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) + { + super.registerIcons(par1IconRegister); + this.field_111220_a = par1IconRegister.registerIcon("charcoal"); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemColored.java b/src/main/java/net/minecraft/item/ItemColored.java new file mode 100644 index 0000000..94d982b --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemColored.java @@ -0,0 +1,61 @@ +package net.minecraft.item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.util.IIcon; + +public class ItemColored extends ItemBlock +{ + private final Block field_150944_b; + private String[] field_150945_c; + private static final String __OBFID = "CL_00000003"; + + public ItemColored(Block p_i45332_1_, boolean p_i45332_2_) + { + super(p_i45332_1_); + this.field_150944_b = p_i45332_1_; + + if (p_i45332_2_) + { + this.setMaxDamage(0); + this.setHasSubtypes(true); + } + } + + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) + { + return this.field_150944_b.getRenderColor(par1ItemStack.getItemDamage()); + } + + public int getMetadata(int par1) + { + return par1; + } + + public ItemColored func_150943_a(String[] p_150943_1_) + { + this.field_150945_c = p_150943_1_; + return this; + } + + public String getUnlocalizedName(ItemStack par1ItemStack) + { + if (this.field_150945_c == null) + { + return super.getUnlocalizedName(par1ItemStack); + } + else + { + int i = par1ItemStack.getItemDamage(); + return i >= 0 && i < this.field_150945_c.length ? super.getUnlocalizedName(par1ItemStack) + "." + this.field_150945_c[i] : super.getUnlocalizedName(par1ItemStack); + } + } + + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int par1) + { + return this.field_150944_b.getIcon(0, par1); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemDoor.java b/src/main/java/net/minecraft/item/ItemDoor.java new file mode 100644 index 0000000..c01dea4 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemDoor.java @@ -0,0 +1,109 @@ +package net.minecraft.item; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class ItemDoor extends Item +{ + private Material doorMaterial; + private static final String __OBFID = "CL_00000020"; + + public ItemDoor(Material p_i45334_1_) + { + this.doorMaterial = p_i45334_1_; + this.maxStackSize = 1; + this.setCreativeTab(CreativeTabs.tabRedstone); + } + + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) + { + if (par7 != 1) + { + return false; + } + else + { + ++par5; + Block block; + + if (this.doorMaterial == Material.wood) + { + block = Blocks.wooden_door; + } + else + { + block = Blocks.iron_door; + } + + if (par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack) && par2EntityPlayer.canPlayerEdit(par4, par5 + 1, par6, par7, par1ItemStack)) + { + if (!block.canPlaceBlockAt(par3World, par4, par5, par6)) + { + return false; + } + else + { + int i1 = MathHelper.floor_double((double)((par2EntityPlayer.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3; + placeDoorBlock(par3World, par4, par5, par6, i1, block); + --par1ItemStack.stackSize; + return true; + } + } + else + { + return false; + } + } + } + + public static void placeDoorBlock(World p_150924_0_, int p_150924_1_, int p_150924_2_, int p_150924_3_, int p_150924_4_, Block p_150924_5_) + { + byte b0 = 0; + byte b1 = 0; + + if (p_150924_4_ == 0) + { + b1 = 1; + } + + if (p_150924_4_ == 1) + { + b0 = -1; + } + + if (p_150924_4_ == 2) + { + b1 = -1; + } + + if (p_150924_4_ == 3) + { + b0 = 1; + } + + int i1 = (p_150924_0_.getBlock(p_150924_1_ - b0, p_150924_2_, p_150924_3_ - b1).isNormalCube() ? 1 : 0) + (p_150924_0_.getBlock(p_150924_1_ - b0, p_150924_2_ + 1, p_150924_3_ - b1).isNormalCube() ? 1 : 0); + int j1 = (p_150924_0_.getBlock(p_150924_1_ + b0, p_150924_2_, p_150924_3_ + b1).isNormalCube() ? 1 : 0) + (p_150924_0_.getBlock(p_150924_1_ + b0, p_150924_2_ + 1, p_150924_3_ + b1).isNormalCube() ? 1 : 0); + boolean flag = p_150924_0_.getBlock(p_150924_1_ - b0, p_150924_2_, p_150924_3_ - b1) == p_150924_5_ || p_150924_0_.getBlock(p_150924_1_ - b0, p_150924_2_ + 1, p_150924_3_ - b1) == p_150924_5_; + boolean flag1 = p_150924_0_.getBlock(p_150924_1_ + b0, p_150924_2_, p_150924_3_ + b1) == p_150924_5_ || p_150924_0_.getBlock(p_150924_1_ + b0, p_150924_2_ + 1, p_150924_3_ + b1) == p_150924_5_; + boolean flag2 = false; + + if (flag && !flag1) + { + flag2 = true; + } + else if (j1 > i1) + { + flag2 = true; + } + + p_150924_0_.setBlock(p_150924_1_, p_150924_2_, p_150924_3_, p_150924_5_, p_150924_4_, 2); + p_150924_0_.setBlock(p_150924_1_, p_150924_2_ + 1, p_150924_3_, p_150924_5_, 8 | (flag2 ? 1 : 0), 2); + p_150924_0_.notifyBlocksOfNeighborChange(p_150924_1_, p_150924_2_, p_150924_3_, p_150924_5_); + p_150924_0_.notifyBlocksOfNeighborChange(p_150924_1_, p_150924_2_ + 1, p_150924_3_, p_150924_5_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemDoublePlant.java b/src/main/java/net/minecraft/item/ItemDoublePlant.java new file mode 100644 index 0000000..771e941 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemDoublePlant.java @@ -0,0 +1,31 @@ +package net.minecraft.item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.block.BlockDoublePlant; +import net.minecraft.util.IIcon; +import net.minecraft.world.ColorizerGrass; + +public class ItemDoublePlant extends ItemMultiTexture +{ + private static final String __OBFID = "CL_00000021"; + + public ItemDoublePlant(Block p_i45335_1_, BlockDoublePlant p_i45335_2_, String[] p_i45335_3_) + { + super(p_i45335_1_, p_i45335_2_, p_i45335_3_); + } + + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int par1) + { + return BlockDoublePlant.func_149890_d(par1) == 0 ? ((BlockDoublePlant)this.field_150941_b).sunflowerIcons[0] : ((BlockDoublePlant)this.field_150941_b).func_149888_a(true, par1); + } + + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) + { + int j = BlockDoublePlant.func_149890_d(par1ItemStack.getItemDamage()); + return j != 2 && j != 3 ? super.getColorFromItemStack(par1ItemStack, par2) : ColorizerGrass.getGrassColor(0.5D, 1.0D); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemDye.java b/src/main/java/net/minecraft/item/ItemDye.java new file mode 100644 index 0000000..19d18f8 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemDye.java @@ -0,0 +1,254 @@ +package net.minecraft.item; + +import cpw.mods.fml.common.eventhandler.Event.Result; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.block.Block; +import net.minecraft.block.BlockColored; +import net.minecraft.block.BlockLog; +import net.minecraft.block.IGrowable; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.passive.EntitySheep; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraft.world.WorldServer; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.util.FakePlayerFactory; +import net.minecraftforge.event.entity.player.BonemealEvent; + +public class ItemDye extends Item +{ + public static final String[] field_150923_a = new String[] {"black", "red", "green", "brown", "blue", "purple", "cyan", "silver", "gray", "pink", "lime", "yellow", "lightBlue", "magenta", "orange", "white"}; + public static final String[] field_150921_b = new String[] {"black", "red", "green", "brown", "blue", "purple", "cyan", "silver", "gray", "pink", "lime", "yellow", "light_blue", "magenta", "orange", "white"}; + public static final int[] field_150922_c = new int[] {1973019, 11743532, 3887386, 5320730, 2437522, 8073150, 2651799, 11250603, 4408131, 14188952, 4312372, 14602026, 6719955, 12801229, 15435844, 15790320}; + @SideOnly(Side.CLIENT) + private IIcon[] field_150920_d; + private static final String __OBFID = "CL_00000022"; + + public ItemDye() + { + this.setHasSubtypes(true); + this.setMaxDamage(0); + this.setCreativeTab(CreativeTabs.tabMaterials); + } + + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int par1) + { + int j = MathHelper.clamp_int(par1, 0, 15); + return this.field_150920_d[j]; + } + + public String getUnlocalizedName(ItemStack par1ItemStack) + { + int i = MathHelper.clamp_int(par1ItemStack.getItemDamage(), 0, 15); + return super.getUnlocalizedName() + "." + field_150923_a[i]; + } + + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) + { + if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack)) + { + return false; + } + else + { + if (par1ItemStack.getItemDamage() == 15) + { + if (applyBonemeal(par1ItemStack, par3World, par4, par5, par6, par2EntityPlayer)) + { + if (!par3World.isRemote) + { + par3World.playAuxSFX(2005, par4, par5, par6, 0); + } + + return true; + } + } + else if (par1ItemStack.getItemDamage() == 3) + { + Block block = par3World.getBlock(par4, par5, par6); + int i1 = par3World.getBlockMetadata(par4, par5, par6); + + if (block == Blocks.log && BlockLog.func_150165_c(i1) == 3) + { + if (par7 == 0) + { + return false; + } + + if (par7 == 1) + { + return false; + } + + if (par7 == 2) + { + --par6; + } + + if (par7 == 3) + { + ++par6; + } + + if (par7 == 4) + { + --par4; + } + + if (par7 == 5) + { + ++par4; + } + + if (par3World.isAirBlock(par4, par5, par6)) + { + int j1 = Blocks.cocoa.onBlockPlaced(par3World, par4, par5, par6, par7, par8, par9, par10, 0); + par3World.setBlock(par4, par5, par6, Blocks.cocoa, j1, 2); + + if (!par2EntityPlayer.capabilities.isCreativeMode) + { + --par1ItemStack.stackSize; + } + } + + return true; + } + } + + return false; + } + } + + public static boolean func_150919_a(ItemStack p_150919_0_, World p_150919_1_, int p_150919_2_, int p_150919_3_, int p_150919_4_) + { + if (p_150919_1_ instanceof WorldServer) + return applyBonemeal(p_150919_0_, p_150919_1_, p_150919_2_, p_150919_3_, p_150919_4_, FakePlayerFactory.getMinecraft((WorldServer)p_150919_1_)); + return false; + } + + public static boolean applyBonemeal(ItemStack p_150919_0_, World p_150919_1_, int p_150919_2_, int p_150919_3_, int p_150919_4_, EntityPlayer player) + { + Block block = p_150919_1_.getBlock(p_150919_2_, p_150919_3_, p_150919_4_); + + BonemealEvent event = new BonemealEvent(player, p_150919_1_, block, p_150919_2_, p_150919_3_, p_150919_4_); + if (MinecraftForge.EVENT_BUS.post(event)) + { + return false; + } + + if (event.getResult() == Result.ALLOW) + { + if (!p_150919_1_.isRemote) + { + p_150919_0_.stackSize--; + } + return true; + } + + if (block instanceof IGrowable) + { + IGrowable igrowable = (IGrowable)block; + + if (igrowable.func_149851_a(p_150919_1_, p_150919_2_, p_150919_3_, p_150919_4_, p_150919_1_.isRemote)) + { + if (!p_150919_1_.isRemote) + { + if (igrowable.func_149852_a(p_150919_1_, p_150919_1_.rand, p_150919_2_, p_150919_3_, p_150919_4_)) + { + igrowable.func_149853_b(p_150919_1_, p_150919_1_.rand, p_150919_2_, p_150919_3_, p_150919_4_); + } + + --p_150919_0_.stackSize; + } + + return true; + } + } + + return false; + } + + @SideOnly(Side.CLIENT) + public static void func_150918_a(World p_150918_0_, int p_150918_1_, int p_150918_2_, int p_150918_3_, int p_150918_4_) + { + if (p_150918_4_ == 0) + { + p_150918_4_ = 15; + } + + Block block = p_150918_0_.getBlock(p_150918_1_, p_150918_2_, p_150918_3_); + + if (block.getMaterial() != Material.air) + { + block.setBlockBoundsBasedOnState(p_150918_0_, p_150918_1_, p_150918_2_, p_150918_3_); + + for (int i1 = 0; i1 < p_150918_4_; ++i1) + { + double d0 = itemRand.nextGaussian() * 0.02D; + double d1 = itemRand.nextGaussian() * 0.02D; + double d2 = itemRand.nextGaussian() * 0.02D; + p_150918_0_.spawnParticle("happyVillager", (double)((float)p_150918_1_ + itemRand.nextFloat()), (double)p_150918_2_ + (double)itemRand.nextFloat() * block.getBlockBoundsMaxY(), (double)((float)p_150918_3_ + itemRand.nextFloat()), d0, d1, d2); + } + } + else + { + for (int i1 = 0; i1 < p_150918_4_; ++i1) + { + double d0 = itemRand.nextGaussian() * 0.02D; + double d1 = itemRand.nextGaussian() * 0.02D; + double d2 = itemRand.nextGaussian() * 0.02D; + p_150918_0_.spawnParticle("happyVillager", (double)((float)p_150918_1_ + itemRand.nextFloat()), (double)p_150918_2_ + (double)itemRand.nextFloat() * 1.0f, (double)((float)p_150918_3_ + itemRand.nextFloat()), d0, d1, d2); + } + } + } + + public boolean itemInteractionForEntity(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, EntityLivingBase par3EntityLivingBase) + { + if (par3EntityLivingBase instanceof EntitySheep) + { + EntitySheep entitysheep = (EntitySheep)par3EntityLivingBase; + int i = BlockColored.func_150032_b(par1ItemStack.getItemDamage()); + + if (!entitysheep.getSheared() && entitysheep.getFleeceColor() != i) + { + entitysheep.setFleeceColor(i); + --par1ItemStack.stackSize; + } + + return true; + } + else + { + return false; + } + } + + @SideOnly(Side.CLIENT) + public void getSubItems(Item p_150895_1_, CreativeTabs p_150895_2_, List p_150895_3_) + { + for (int i = 0; i < 16; ++i) + { + p_150895_3_.add(new ItemStack(p_150895_1_, 1, i)); + } + } + + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) + { + this.field_150920_d = new IIcon[field_150921_b.length]; + + for (int i = 0; i < field_150921_b.length; ++i) + { + this.field_150920_d[i] = par1IconRegister.registerIcon(this.getIconString() + "_" + field_150921_b[i]); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemEditableBook.java b/src/main/java/net/minecraft/item/ItemEditableBook.java new file mode 100644 index 0000000..63ceebf --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemEditableBook.java @@ -0,0 +1,86 @@ +package net.minecraft.item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; +import net.minecraft.util.StringUtils; +import net.minecraft.world.World; + +public class ItemEditableBook extends Item +{ + private static final String __OBFID = "CL_00000077"; + + public ItemEditableBook() + { + this.setMaxStackSize(1); + } + + public static boolean validBookTagContents(NBTTagCompound par0NBTTagCompound) + { + if (!ItemWritableBook.func_150930_a(par0NBTTagCompound)) + { + return false; + } + else if (!par0NBTTagCompound.hasKey("title", 8)) + { + return false; + } + else + { + String s = par0NBTTagCompound.getString("title"); + return s != null && s.length() <= 16 ? par0NBTTagCompound.hasKey("author", 8) : false; + } + } + + public String getItemStackDisplayName(ItemStack par1ItemStack) + { + if (par1ItemStack.hasTagCompound()) + { + NBTTagCompound nbttagcompound = par1ItemStack.getTagCompound(); + String s = nbttagcompound.getString("title"); + + if (!StringUtils.isNullOrEmpty(s)) + { + return s; + } + } + + return super.getItemStackDisplayName(par1ItemStack); + } + + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) + { + if (par1ItemStack.hasTagCompound()) + { + NBTTagCompound nbttagcompound = par1ItemStack.getTagCompound(); + String s = nbttagcompound.getString("author"); + + if (!StringUtils.isNullOrEmpty(s)) + { + par3List.add(EnumChatFormatting.GRAY + StatCollector.translateToLocalFormatted("book.byAuthor", new Object[] {s})); + } + } + } + + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + { + par3EntityPlayer.displayGUIBook(par1ItemStack); + return par1ItemStack; + } + + public boolean getShareTag() + { + return true; + } + + @SideOnly(Side.CLIENT) + public boolean hasEffect(ItemStack par1ItemStack) + { + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemEgg.java b/src/main/java/net/minecraft/item/ItemEgg.java new file mode 100644 index 0000000..7e2d654 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemEgg.java @@ -0,0 +1,34 @@ +package net.minecraft.item; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.projectile.EntityEgg; +import net.minecraft.world.World; + +public class ItemEgg extends Item +{ + private static final String __OBFID = "CL_00000023"; + + public ItemEgg() + { + this.maxStackSize = 16; + this.setCreativeTab(CreativeTabs.tabMaterials); + } + + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + { + if (!par3EntityPlayer.capabilities.isCreativeMode) + { + --par1ItemStack.stackSize; + } + + par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); + + if (!par2World.isRemote) + { + par2World.spawnEntityInWorld(new EntityEgg(par2World, par3EntityPlayer)); + } + + return par1ItemStack; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemEmptyMap.java b/src/main/java/net/minecraft/item/ItemEmptyMap.java new file mode 100644 index 0000000..f0c9a31 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemEmptyMap.java @@ -0,0 +1,46 @@ +package net.minecraft.item; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.world.World; +import net.minecraft.world.storage.MapData; + +public class ItemEmptyMap extends ItemMapBase +{ + private static final String __OBFID = "CL_00000024"; + + protected ItemEmptyMap() + { + this.setCreativeTab(CreativeTabs.tabMisc); + } + + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + { + ItemStack itemstack1 = new ItemStack(Items.filled_map, 1, par2World.getUniqueDataId("map")); + String s = "map_" + itemstack1.getItemDamage(); + MapData mapdata = new MapData(s); + par2World.setItemData(s, mapdata); + mapdata.scale = 0; + int i = 128 * (1 << mapdata.scale); + mapdata.xCenter = (int)(Math.round(par3EntityPlayer.posX / (double)i) * (long)i); + mapdata.zCenter = (int)(Math.round(par3EntityPlayer.posZ / (double)i) * (long)i); + mapdata.dimension = par2World.provider.dimensionId; + mapdata.markDirty(); + --par1ItemStack.stackSize; + + if (par1ItemStack.stackSize <= 0) + { + return itemstack1; + } + else + { + if (!par3EntityPlayer.inventory.addItemStackToInventory(itemstack1.copy())) + { + par3EntityPlayer.dropPlayerItemWithRandomChoice(itemstack1, false); + } + + return par1ItemStack; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemEnchantedBook.java b/src/main/java/net/minecraft/item/ItemEnchantedBook.java new file mode 100644 index 0000000..95e9a16 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemEnchantedBook.java @@ -0,0 +1,126 @@ +package net.minecraft.item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import java.util.Random; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnchantmentData; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.WeightedRandomChestContent; + +public class ItemEnchantedBook extends Item +{ + private static final String __OBFID = "CL_00000025"; + + @SideOnly(Side.CLIENT) + public boolean hasEffect(ItemStack par1ItemStack) + { + return true; + } + + public boolean isItemTool(ItemStack par1ItemStack) + { + return false; + } + + public EnumRarity getRarity(ItemStack par1ItemStack) + { + return this.func_92110_g(par1ItemStack).tagCount() > 0 ? EnumRarity.uncommon : super.getRarity(par1ItemStack); + } + + public NBTTagList func_92110_g(ItemStack par1ItemStack) + { + return par1ItemStack.stackTagCompound != null && par1ItemStack.stackTagCompound.hasKey("StoredEnchantments", 9) ? (NBTTagList)par1ItemStack.stackTagCompound.getTag("StoredEnchantments") : new NBTTagList(); + } + + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) + { + super.addInformation(par1ItemStack, par2EntityPlayer, par3List, par4); + NBTTagList nbttaglist = this.func_92110_g(par1ItemStack); + + if (nbttaglist != null) + { + for (int i = 0; i < nbttaglist.tagCount(); ++i) + { + short short1 = nbttaglist.getCompoundTagAt(i).getShort("id"); + short short2 = nbttaglist.getCompoundTagAt(i).getShort("lvl"); + + if (Enchantment.enchantmentsList[short1] != null) + { + par3List.add(Enchantment.enchantmentsList[short1].getTranslatedName(short2)); + } + } + } + } + + public void addEnchantment(ItemStack par1ItemStack, EnchantmentData par2EnchantmentData) + { + NBTTagList nbttaglist = this.func_92110_g(par1ItemStack); + boolean flag = true; + + for (int i = 0; i < nbttaglist.tagCount(); ++i) + { + NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i); + + if (nbttagcompound.getShort("id") == par2EnchantmentData.enchantmentobj.effectId) + { + if (nbttagcompound.getShort("lvl") < par2EnchantmentData.enchantmentLevel) + { + nbttagcompound.setShort("lvl", (short)par2EnchantmentData.enchantmentLevel); + } + + flag = false; + break; + } + } + + if (flag) + { + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + nbttagcompound1.setShort("id", (short)par2EnchantmentData.enchantmentobj.effectId); + nbttagcompound1.setShort("lvl", (short)par2EnchantmentData.enchantmentLevel); + nbttaglist.appendTag(nbttagcompound1); + } + + if (!par1ItemStack.hasTagCompound()) + { + par1ItemStack.setTagCompound(new NBTTagCompound()); + } + + par1ItemStack.getTagCompound().setTag("StoredEnchantments", nbttaglist); + } + + public ItemStack getEnchantedItemStack(EnchantmentData par1EnchantmentData) + { + ItemStack itemstack = new ItemStack(this); + this.addEnchantment(itemstack, par1EnchantmentData); + return itemstack; + } + + @SideOnly(Side.CLIENT) + public void func_92113_a(Enchantment par1Enchantment, List par2List) + { + for (int i = par1Enchantment.getMinLevel(); i <= par1Enchantment.getMaxLevel(); ++i) + { + par2List.add(this.getEnchantedItemStack(new EnchantmentData(par1Enchantment, i))); + } + } + + public WeightedRandomChestContent func_92114_b(Random par1Random) + { + return this.func_92112_a(par1Random, 1, 1, 1); + } + + public WeightedRandomChestContent func_92112_a(Random par1Random, int par2, int par3, int par4) + { + ItemStack itemstack = new ItemStack(Items.book, 1, 0); + EnchantmentHelper.addRandomEnchantment(par1Random, itemstack, 30); + return new WeightedRandomChestContent(itemstack, par2, par3, par4); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemEnderEye.java b/src/main/java/net/minecraft/item/ItemEnderEye.java new file mode 100644 index 0000000..51f8ec8 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemEnderEye.java @@ -0,0 +1,177 @@ +package net.minecraft.item; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockEndPortalFrame; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.item.EntityEnderEye; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.util.Direction; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.ChunkPosition; +import net.minecraft.world.World; + +public class ItemEnderEye extends Item +{ + private static final String __OBFID = "CL_00000026"; + + public ItemEnderEye() + { + this.setCreativeTab(CreativeTabs.tabMisc); + } + + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) + { + Block block = par3World.getBlock(par4, par5, par6); + int i1 = par3World.getBlockMetadata(par4, par5, par6); + + if (par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack) && block == Blocks.end_portal_frame && !BlockEndPortalFrame.isEnderEyeInserted(i1)) + { + if (par3World.isRemote) + { + return true; + } + else + { + par3World.setBlockMetadataWithNotify(par4, par5, par6, i1 + 4, 2); + par3World.func_147453_f(par4, par5, par6, Blocks.end_portal_frame); + --par1ItemStack.stackSize; + int j1; + + for (j1 = 0; j1 < 16; ++j1) + { + double d0 = (double)((float)par4 + (5.0F + itemRand.nextFloat() * 6.0F) / 16.0F); + double d1 = (double)((float)par5 + 0.8125F); + double d2 = (double)((float)par6 + (5.0F + itemRand.nextFloat() * 6.0F) / 16.0F); + double d3 = 0.0D; + double d4 = 0.0D; + double d5 = 0.0D; + par3World.spawnParticle("smoke", d0, d1, d2, d3, d4, d5); + } + + j1 = i1 & 3; + int j2 = 0; + int k1 = 0; + boolean flag1 = false; + boolean flag = true; + int k2 = Direction.rotateRight[j1]; + int l1; + int i2; + int l2; + + for (l1 = -2; l1 <= 2; ++l1) + { + l2 = par4 + Direction.offsetX[k2] * l1; + i2 = par6 + Direction.offsetZ[k2] * l1; + + if (par3World.getBlock(l2, par5, i2) == Blocks.end_portal_frame) + { + if (!BlockEndPortalFrame.isEnderEyeInserted(par3World.getBlockMetadata(l2, par5, i2))) + { + flag = false; + break; + } + + k1 = l1; + + if (!flag1) + { + j2 = l1; + flag1 = true; + } + } + } + + if (flag && k1 == j2 + 2) + { + for (l1 = j2; l1 <= k1; ++l1) + { + l2 = par4 + Direction.offsetX[k2] * l1; + i2 = par6 + Direction.offsetZ[k2] * l1; + l2 += Direction.offsetX[j1] * 4; + i2 += Direction.offsetZ[j1] * 4; + + if (par3World.getBlock(l2, par5, i2) != Blocks.end_portal_frame || !BlockEndPortalFrame.isEnderEyeInserted(par3World.getBlockMetadata(l2, par5, i2))) + { + flag = false; + break; + } + } + + int i3; + + for (l1 = j2 - 1; l1 <= k1 + 1; l1 += 4) + { + for (l2 = 1; l2 <= 3; ++l2) + { + i2 = par4 + Direction.offsetX[k2] * l1; + i3 = par6 + Direction.offsetZ[k2] * l1; + i2 += Direction.offsetX[j1] * l2; + i3 += Direction.offsetZ[j1] * l2; + + if (par3World.getBlock(i2, par5, i3) != Blocks.end_portal_frame || !BlockEndPortalFrame.isEnderEyeInserted(par3World.getBlockMetadata(i2, par5, i3))) + { + flag = false; + break; + } + } + } + + if (flag) + { + for (l1 = j2; l1 <= k1; ++l1) + { + for (l2 = 1; l2 <= 3; ++l2) + { + i2 = par4 + Direction.offsetX[k2] * l1; + i3 = par6 + Direction.offsetZ[k2] * l1; + i2 += Direction.offsetX[j1] * l2; + i3 += Direction.offsetZ[j1] * l2; + par3World.setBlock(i2, par5, i3, Blocks.end_portal, 0, 2); + } + } + } + } + + return true; + } + } + else + { + return false; + } + } + + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + { + MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, false); + + if (movingobjectposition != null && movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && par2World.getBlock(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ) == Blocks.end_portal_frame) + { + return par1ItemStack; + } + else + { + if (!par2World.isRemote) + { + ChunkPosition chunkposition = par2World.findClosestStructure("Stronghold", (int)par3EntityPlayer.posX, (int)par3EntityPlayer.posY, (int)par3EntityPlayer.posZ); + + if (chunkposition != null) + { + EntityEnderEye entityendereye = new EntityEnderEye(par2World, par3EntityPlayer.posX, par3EntityPlayer.posY + 1.62D - (double)par3EntityPlayer.yOffset, par3EntityPlayer.posZ); + entityendereye.moveTowards((double)chunkposition.chunkPosX, chunkposition.chunkPosY, (double)chunkposition.chunkPosZ); + par2World.spawnEntityInWorld(entityendereye); + par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); + par2World.playAuxSFXAtEntity((EntityPlayer)null, 1002, (int)par3EntityPlayer.posX, (int)par3EntityPlayer.posY, (int)par3EntityPlayer.posZ, 0); + + if (!par3EntityPlayer.capabilities.isCreativeMode) + { + --par1ItemStack.stackSize; + } + } + } + + return par1ItemStack; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemEnderPearl.java b/src/main/java/net/minecraft/item/ItemEnderPearl.java new file mode 100644 index 0000000..0436125 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemEnderPearl.java @@ -0,0 +1,37 @@ +package net.minecraft.item; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.item.EntityEnderPearl; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; + +public class ItemEnderPearl extends Item +{ + private static final String __OBFID = "CL_00000027"; + + public ItemEnderPearl() + { + this.maxStackSize = 16; + this.setCreativeTab(CreativeTabs.tabMisc); + } + + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + { + if (par3EntityPlayer.capabilities.isCreativeMode) + { + return par1ItemStack; + } + else + { + --par1ItemStack.stackSize; + par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); + + if (!par2World.isRemote) + { + par2World.spawnEntityInWorld(new EntityEnderPearl(par2World, par3EntityPlayer)); + } + + return par1ItemStack; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemExpBottle.java b/src/main/java/net/minecraft/item/ItemExpBottle.java new file mode 100644 index 0000000..bb37b3e --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemExpBottle.java @@ -0,0 +1,41 @@ +package net.minecraft.item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.item.EntityExpBottle; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; + +public class ItemExpBottle extends Item +{ + private static final String __OBFID = "CL_00000028"; + + public ItemExpBottle() + { + this.setCreativeTab(CreativeTabs.tabMisc); + } + + @SideOnly(Side.CLIENT) + public boolean hasEffect(ItemStack par1ItemStack) + { + return true; + } + + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + { + if (!par3EntityPlayer.capabilities.isCreativeMode) + { + --par1ItemStack.stackSize; + } + + par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); + + if (!par2World.isRemote) + { + par2World.spawnEntityInWorld(new EntityExpBottle(par2World, par3EntityPlayer)); + } + + return par1ItemStack; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemFireball.java b/src/main/java/net/minecraft/item/ItemFireball.java new file mode 100644 index 0000000..b191108 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemFireball.java @@ -0,0 +1,77 @@ +package net.minecraft.item; + +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; + +public class ItemFireball extends Item +{ + private static final String __OBFID = "CL_00000029"; + + public ItemFireball() + { + this.setCreativeTab(CreativeTabs.tabMisc); + } + + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) + { + if (par3World.isRemote) + { + return true; + } + else + { + if (par7 == 0) + { + --par5; + } + + if (par7 == 1) + { + ++par5; + } + + if (par7 == 2) + { + --par6; + } + + if (par7 == 3) + { + ++par6; + } + + if (par7 == 4) + { + --par4; + } + + if (par7 == 5) + { + ++par4; + } + + if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack)) + { + return false; + } + else + { + if (par3World.getBlock(par4, par5, par6).getMaterial() == Material.air) + { + par3World.playSoundEffect((double)par4 + 0.5D, (double)par5 + 0.5D, (double)par6 + 0.5D, "fire.ignite", 1.0F, itemRand.nextFloat() * 0.4F + 0.8F); + par3World.setBlock(par4, par5, par6, Blocks.fire); + } + + if (!par2EntityPlayer.capabilities.isCreativeMode) + { + --par1ItemStack.stackSize; + } + + return true; + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemFirework.java b/src/main/java/net/minecraft/item/ItemFirework.java new file mode 100644 index 0000000..20c1ed7 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemFirework.java @@ -0,0 +1,76 @@ +package net.minecraft.item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.List; +import net.minecraft.entity.item.EntityFireworkRocket; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +public class ItemFirework extends Item +{ + private static final String __OBFID = "CL_00000031"; + + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) + { + if (!par3World.isRemote) + { + EntityFireworkRocket entityfireworkrocket = new EntityFireworkRocket(par3World, (double)((float)par4 + par8), (double)((float)par5 + par9), (double)((float)par6 + par10), par1ItemStack); + par3World.spawnEntityInWorld(entityfireworkrocket); + + if (!par2EntityPlayer.capabilities.isCreativeMode) + { + --par1ItemStack.stackSize; + } + + return true; + } + else + { + return false; + } + } + + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) + { + if (par1ItemStack.hasTagCompound()) + { + NBTTagCompound nbttagcompound = par1ItemStack.getTagCompound().getCompoundTag("Fireworks"); + + if (nbttagcompound != null) + { + if (nbttagcompound.hasKey("Flight", 99)) + { + par3List.add(StatCollector.translateToLocal("item.fireworks.flight") + " " + nbttagcompound.getByte("Flight")); + } + + NBTTagList nbttaglist = nbttagcompound.getTagList("Explosions", 10); + + if (nbttaglist != null && nbttaglist.tagCount() > 0) + { + for (int i = 0; i < nbttaglist.tagCount(); ++i) + { + NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); + ArrayList arraylist = new ArrayList(); + ItemFireworkCharge.func_150902_a(nbttagcompound1, arraylist); + + if (arraylist.size() > 0) + { + for (int j = 1; j < arraylist.size(); ++j) + { + arraylist.set(j, " " + (String)arraylist.get(j)); + } + + par3List.addAll(arraylist); + } + } + } + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemFireworkCharge.java b/src/main/java/net/minecraft/item/ItemFireworkCharge.java new file mode 100644 index 0000000..d1d6078 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemFireworkCharge.java @@ -0,0 +1,229 @@ +package net.minecraft.item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagIntArray; +import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; + +public class ItemFireworkCharge extends Item +{ + @SideOnly(Side.CLIENT) + private IIcon field_150904_a; + private static final String __OBFID = "CL_00000030"; + + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamageForRenderPass(int par1, int par2) + { + return par2 > 0 ? this.field_150904_a : super.getIconFromDamageForRenderPass(par1, par2); + } + + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) + { + if (par2 != 1) + { + return super.getColorFromItemStack(par1ItemStack, par2); + } + else + { + NBTBase nbtbase = func_150903_a(par1ItemStack, "Colors"); + + if (nbtbase != null && nbtbase instanceof NBTTagIntArray) + { + NBTTagIntArray nbttagintarray = (NBTTagIntArray)nbtbase; + int[] aint = nbttagintarray.func_150302_c(); + + if (aint.length == 1) + { + return aint[0]; + } + else + { + int j = 0; + int k = 0; + int l = 0; + int[] aint1 = aint; + int i1 = aint.length; + + for (int j1 = 0; j1 < i1; ++j1) + { + int k1 = aint1[j1]; + j += (k1 & 16711680) >> 16; + k += (k1 & 65280) >> 8; + l += (k1 & 255) >> 0; + } + + j /= aint.length; + k /= aint.length; + l /= aint.length; + return j << 16 | k << 8 | l; + } + } + else + { + return 9079434; + } + } + } + + @SideOnly(Side.CLIENT) + public boolean requiresMultipleRenderPasses() + { + return true; + } + + @SideOnly(Side.CLIENT) + public static NBTBase func_150903_a(ItemStack p_150903_0_, String p_150903_1_) + { + if (p_150903_0_.hasTagCompound()) + { + NBTTagCompound nbttagcompound = p_150903_0_.getTagCompound().getCompoundTag("Explosion"); + + if (nbttagcompound != null) + { + return nbttagcompound.getTag(p_150903_1_); + } + } + + return null; + } + + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) + { + if (par1ItemStack.hasTagCompound()) + { + NBTTagCompound nbttagcompound = par1ItemStack.getTagCompound().getCompoundTag("Explosion"); + + if (nbttagcompound != null) + { + func_150902_a(nbttagcompound, par3List); + } + } + } + + @SideOnly(Side.CLIENT) + public static void func_150902_a(NBTTagCompound p_150902_0_, List p_150902_1_) + { + byte b0 = p_150902_0_.getByte("Type"); + + if (b0 >= 0 && b0 <= 4) + { + p_150902_1_.add(StatCollector.translateToLocal("item.fireworksCharge.type." + b0).trim()); + } + else + { + p_150902_1_.add(StatCollector.translateToLocal("item.fireworksCharge.type").trim()); + } + + int[] aint = p_150902_0_.getIntArray("Colors"); + int j; + int k; + + if (aint.length > 0) + { + boolean flag = true; + String s = ""; + int[] aint1 = aint; + int i = aint.length; + + for (j = 0; j < i; ++j) + { + k = aint1[j]; + + if (!flag) + { + s = s + ", "; + } + + flag = false; + boolean flag1 = false; + + for (int l = 0; l < 16; ++l) + { + if (k == ItemDye.field_150922_c[l]) + { + flag1 = true; + s = s + StatCollector.translateToLocal("item.fireworksCharge." + ItemDye.field_150923_a[l]); + break; + } + } + + if (!flag1) + { + s = s + StatCollector.translateToLocal("item.fireworksCharge.customColor"); + } + } + + p_150902_1_.add(s); + } + + int[] aint2 = p_150902_0_.getIntArray("FadeColors"); + boolean flag2; + + if (aint2.length > 0) + { + flag2 = true; + String s1 = StatCollector.translateToLocal("item.fireworksCharge.fadeTo") + " "; + int[] aint3 = aint2; + j = aint2.length; + + for (k = 0; k < j; ++k) + { + int j1 = aint3[k]; + + if (!flag2) + { + s1 = s1 + ", "; + } + + flag2 = false; + boolean flag4 = false; + + for (int i1 = 0; i1 < 16; ++i1) + { + if (j1 == ItemDye.field_150922_c[i1]) + { + flag4 = true; + s1 = s1 + StatCollector.translateToLocal("item.fireworksCharge." + ItemDye.field_150923_a[i1]); + break; + } + } + + if (!flag4) + { + s1 = s1 + StatCollector.translateToLocal("item.fireworksCharge.customColor"); + } + } + + p_150902_1_.add(s1); + } + + flag2 = p_150902_0_.getBoolean("Trail"); + + if (flag2) + { + p_150902_1_.add(StatCollector.translateToLocal("item.fireworksCharge.trail")); + } + + boolean flag3 = p_150902_0_.getBoolean("Flicker"); + + if (flag3) + { + p_150902_1_.add(StatCollector.translateToLocal("item.fireworksCharge.flicker")); + } + } + + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) + { + super.registerIcons(par1IconRegister); + this.field_150904_a = par1IconRegister.registerIcon(this.getIconString() + "_overlay"); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemFishFood.java b/src/main/java/net/minecraft/item/ItemFishFood.java new file mode 100644 index 0000000..6f1ee3a --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemFishFood.java @@ -0,0 +1,226 @@ +package net.minecraft.item; + +import com.google.common.collect.Maps; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import java.util.Map; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.potion.PotionHelper; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +public class ItemFishFood extends ItemFood +{ + private final boolean field_150907_b; + private static final String __OBFID = "CL_00000032"; + + public ItemFishFood(boolean p_i45338_1_) + { + super(0, 0.0F, false); + this.field_150907_b = p_i45338_1_; + } + + public int func_150905_g(ItemStack p_150905_1_) + { + ItemFishFood.FishType fishtype = ItemFishFood.FishType.func_150978_a(p_150905_1_); + return this.field_150907_b && fishtype.func_150973_i() ? fishtype.func_150970_e() : fishtype.func_150975_c(); + } + + public float func_150906_h(ItemStack p_150906_1_) + { + ItemFishFood.FishType fishtype = ItemFishFood.FishType.func_150978_a(p_150906_1_); + return this.field_150907_b && fishtype.func_150973_i() ? fishtype.func_150977_f() : fishtype.func_150967_d(); + } + + public String getPotionEffect(ItemStack p_150896_1_) + { + return ItemFishFood.FishType.func_150978_a(p_150896_1_) == ItemFishFood.FishType.PUFFERFISH ? PotionHelper.field_151423_m : null; + } + + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) + { + ItemFishFood.FishType[] afishtype = ItemFishFood.FishType.values(); + int i = afishtype.length; + + for (int j = 0; j < i; ++j) + { + ItemFishFood.FishType fishtype = afishtype[j]; + fishtype.func_150968_a(par1IconRegister); + } + } + + protected void onFoodEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + { + ItemFishFood.FishType fishtype = ItemFishFood.FishType.func_150978_a(par1ItemStack); + + if (fishtype == ItemFishFood.FishType.PUFFERFISH) + { + par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.poison.id, 1200, 3)); + par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.hunger.id, 300, 2)); + par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.confusion.id, 300, 1)); + } + + super.onFoodEaten(par1ItemStack, par2World, par3EntityPlayer); + } + + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int par1) + { + ItemFishFood.FishType fishtype = ItemFishFood.FishType.func_150974_a(par1); + return this.field_150907_b && fishtype.func_150973_i() ? fishtype.func_150979_h() : fishtype.func_150971_g(); + } + + @SideOnly(Side.CLIENT) + public void getSubItems(Item p_150895_1_, CreativeTabs p_150895_2_, List p_150895_3_) + { + ItemFishFood.FishType[] afishtype = ItemFishFood.FishType.values(); + int i = afishtype.length; + + for (int j = 0; j < i; ++j) + { + ItemFishFood.FishType fishtype = afishtype[j]; + + if (!this.field_150907_b || fishtype.func_150973_i()) + { + p_150895_3_.add(new ItemStack(this, 1, fishtype.func_150976_a())); + } + } + } + + public String getUnlocalizedName(ItemStack par1ItemStack) + { + ItemFishFood.FishType fishtype = ItemFishFood.FishType.func_150978_a(par1ItemStack); + return this.getUnlocalizedName() + "." + fishtype.func_150972_b() + "." + (this.field_150907_b && fishtype.func_150973_i() ? "cooked" : "raw"); + } + + public static enum FishType + { + COD(0, "cod", 2, 0.1F, 5, 0.6F), + SALMON(1, "salmon", 2, 0.1F, 6, 0.8F), + CLOWNFISH(2, "clownfish", 1, 0.1F), + PUFFERFISH(3, "pufferfish", 1, 0.1F); + private static final Map field_150983_e = Maps.newHashMap(); + private final int field_150980_f; + private final String field_150981_g; + @SideOnly(Side.CLIENT) + private IIcon field_150993_h; + @SideOnly(Side.CLIENT) + private IIcon field_150994_i; + private final int field_150991_j; + private final float field_150992_k; + private final int field_150989_l; + private final float field_150990_m; + private boolean field_150987_n = false; + + private static final String __OBFID = "CL_00000033"; + + private FishType(int p_i45336_3_, String p_i45336_4_, int p_i45336_5_, float p_i45336_6_, int p_i45336_7_, float p_i45336_8_) + { + this.field_150980_f = p_i45336_3_; + this.field_150981_g = p_i45336_4_; + this.field_150991_j = p_i45336_5_; + this.field_150992_k = p_i45336_6_; + this.field_150989_l = p_i45336_7_; + this.field_150990_m = p_i45336_8_; + this.field_150987_n = true; + } + + private FishType(int p_i45337_3_, String p_i45337_4_, int p_i45337_5_, float p_i45337_6_) + { + this.field_150980_f = p_i45337_3_; + this.field_150981_g = p_i45337_4_; + this.field_150991_j = p_i45337_5_; + this.field_150992_k = p_i45337_6_; + this.field_150989_l = 0; + this.field_150990_m = 0.0F; + this.field_150987_n = false; + } + + public int func_150976_a() + { + return this.field_150980_f; + } + + public String func_150972_b() + { + return this.field_150981_g; + } + + public int func_150975_c() + { + return this.field_150991_j; + } + + public float func_150967_d() + { + return this.field_150992_k; + } + + public int func_150970_e() + { + return this.field_150989_l; + } + + public float func_150977_f() + { + return this.field_150990_m; + } + + @SideOnly(Side.CLIENT) + public void func_150968_a(IIconRegister p_150968_1_) + { + this.field_150993_h = p_150968_1_.registerIcon("fish_" + this.field_150981_g + "_raw"); + + if (this.field_150987_n) + { + this.field_150994_i = p_150968_1_.registerIcon("fish_" + this.field_150981_g + "_cooked"); + } + } + + @SideOnly(Side.CLIENT) + public IIcon func_150971_g() + { + return this.field_150993_h; + } + + @SideOnly(Side.CLIENT) + public IIcon func_150979_h() + { + return this.field_150994_i; + } + + public boolean func_150973_i() + { + return this.field_150987_n; + } + + public static ItemFishFood.FishType func_150974_a(int p_150974_0_) + { + ItemFishFood.FishType fishtype = (ItemFishFood.FishType)field_150983_e.get(Integer.valueOf(p_150974_0_)); + return fishtype == null ? COD : fishtype; + } + + public static ItemFishFood.FishType func_150978_a(ItemStack p_150978_0_) + { + return p_150978_0_.getItem() instanceof ItemFishFood ? func_150974_a(p_150978_0_.getItemDamage()) : COD; + } + + static + { + ItemFishFood.FishType[] var0 = values(); + int var1 = var0.length; + + for (int var2 = 0; var2 < var1; ++var2) + { + ItemFishFood.FishType var3 = var0[var2]; + field_150983_e.put(Integer.valueOf(var3.func_150976_a()), var3); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemFishingRod.java b/src/main/java/net/minecraft/item/ItemFishingRod.java new file mode 100644 index 0000000..ddd341a --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemFishingRod.java @@ -0,0 +1,82 @@ +package net.minecraft.item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.projectile.EntityFishHook; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +public class ItemFishingRod extends Item +{ + @SideOnly(Side.CLIENT) + private IIcon theIcon; + private static final String __OBFID = "CL_00000034"; + + public ItemFishingRod() + { + this.setMaxDamage(64); + this.setMaxStackSize(1); + this.setCreativeTab(CreativeTabs.tabTools); + } + + @SideOnly(Side.CLIENT) + public boolean isFull3D() + { + return true; + } + + @SideOnly(Side.CLIENT) + public boolean shouldRotateAroundWhenRendering() + { + return true; + } + + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + { + if (par3EntityPlayer.fishEntity != null) + { + int i = par3EntityPlayer.fishEntity.func_146034_e(); + par1ItemStack.damageItem(i, par3EntityPlayer); + par3EntityPlayer.swingItem(); + } + else + { + par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); + + if (!par2World.isRemote) + { + par2World.spawnEntityInWorld(new EntityFishHook(par2World, par3EntityPlayer)); + } + + par3EntityPlayer.swingItem(); + } + + return par1ItemStack; + } + + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) + { + this.itemIcon = par1IconRegister.registerIcon(this.getIconString() + "_uncast"); + this.theIcon = par1IconRegister.registerIcon(this.getIconString() + "_cast"); + } + + @SideOnly(Side.CLIENT) + public IIcon func_94597_g() + { + return this.theIcon; + } + + public boolean isItemTool(ItemStack par1ItemStack) + { + return super.isItemTool(par1ItemStack); + } + + public int getItemEnchantability() + { + return 1; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemFlintAndSteel.java b/src/main/java/net/minecraft/item/ItemFlintAndSteel.java new file mode 100644 index 0000000..46ad89f --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemFlintAndSteel.java @@ -0,0 +1,68 @@ +package net.minecraft.item; + +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; + +public class ItemFlintAndSteel extends Item +{ + private static final String __OBFID = "CL_00000035"; + + public ItemFlintAndSteel() + { + this.maxStackSize = 1; + this.setMaxDamage(64); + this.setCreativeTab(CreativeTabs.tabTools); + } + + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) + { + if (par7 == 0) + { + --par5; + } + + if (par7 == 1) + { + ++par5; + } + + if (par7 == 2) + { + --par6; + } + + if (par7 == 3) + { + ++par6; + } + + if (par7 == 4) + { + --par4; + } + + if (par7 == 5) + { + ++par4; + } + + if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack)) + { + return false; + } + else + { + if (par3World.isAirBlock(par4, par5, par6)) + { + par3World.playSoundEffect((double)par4 + 0.5D, (double)par5 + 0.5D, (double)par6 + 0.5D, "fire.ignite", 1.0F, itemRand.nextFloat() * 0.4F + 0.8F); + par3World.setBlock(par4, par5, par6, Blocks.fire); + } + + par1ItemStack.damageItem(1, par2EntityPlayer); + return true; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemFood.java b/src/main/java/net/minecraft/item/ItemFood.java new file mode 100644 index 0000000..49de9b6 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemFood.java @@ -0,0 +1,101 @@ +package net.minecraft.item; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.potion.PotionEffect; +import net.minecraft.world.World; + +public class ItemFood extends Item +{ + public final int itemUseDuration; + private final int healAmount; + private final float saturationModifier; + private final boolean isWolfsFavoriteMeat; + private boolean alwaysEdible; + private int potionId; + private int potionDuration; + private int potionAmplifier; + private float potionEffectProbability; + private static final String __OBFID = "CL_00000036"; + + public ItemFood(int p_i45339_1_, float p_i45339_2_, boolean p_i45339_3_) + { + this.itemUseDuration = 32; + this.healAmount = p_i45339_1_; + this.isWolfsFavoriteMeat = p_i45339_3_; + this.saturationModifier = p_i45339_2_; + this.setCreativeTab(CreativeTabs.tabFood); + } + + public ItemFood(int p_i45340_1_, boolean p_i45340_2_) + { + this(p_i45340_1_, 0.6F, p_i45340_2_); + } + + public ItemStack onEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + { + --par1ItemStack.stackSize; + par3EntityPlayer.getFoodStats().func_151686_a(this, par1ItemStack); + par2World.playSoundAtEntity(par3EntityPlayer, "random.burp", 0.5F, par2World.rand.nextFloat() * 0.1F + 0.9F); + this.onFoodEaten(par1ItemStack, par2World, par3EntityPlayer); + return par1ItemStack; + } + + protected void onFoodEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + { + if (!par2World.isRemote && this.potionId > 0 && par2World.rand.nextFloat() < this.potionEffectProbability) + { + par3EntityPlayer.addPotionEffect(new PotionEffect(this.potionId, this.potionDuration * 20, this.potionAmplifier)); + } + } + + public int getMaxItemUseDuration(ItemStack par1ItemStack) + { + return 32; + } + + public EnumAction getItemUseAction(ItemStack par1ItemStack) + { + return EnumAction.eat; + } + + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + { + if (par3EntityPlayer.canEat(this.alwaysEdible)) + { + par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); + } + + return par1ItemStack; + } + + public int func_150905_g(ItemStack p_150905_1_) + { + return this.healAmount; + } + + public float func_150906_h(ItemStack p_150906_1_) + { + return this.saturationModifier; + } + + public boolean isWolfsFavoriteMeat() + { + return this.isWolfsFavoriteMeat; + } + + public ItemFood setPotionEffect(int par1, int par2, int par3, float par4) + { + this.potionId = par1; + this.potionDuration = par2; + this.potionAmplifier = par3; + this.potionEffectProbability = par4; + return this; + } + + public ItemFood setAlwaysEdible() + { + this.alwaysEdible = true; + return this; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemGlassBottle.java b/src/main/java/net/minecraft/item/ItemGlassBottle.java new file mode 100644 index 0000000..607a492 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemGlassBottle.java @@ -0,0 +1,77 @@ +package net.minecraft.item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.util.IIcon; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; + +public class ItemGlassBottle extends Item +{ + private static final String __OBFID = "CL_00001776"; + + public ItemGlassBottle() + { + this.setCreativeTab(CreativeTabs.tabBrewing); + } + + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int par1) + { + return Items.potionitem.getIconFromDamage(0); + } + + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + { + MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, true); + + if (movingobjectposition == null) + { + return par1ItemStack; + } + else + { + if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) + { + int i = movingobjectposition.blockX; + int j = movingobjectposition.blockY; + int k = movingobjectposition.blockZ; + + if (!par2World.canMineBlock(par3EntityPlayer, i, j, k)) + { + return par1ItemStack; + } + + if (!par3EntityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, par1ItemStack)) + { + return par1ItemStack; + } + + if (par2World.getBlock(i, j, k).getMaterial() == Material.water) + { + --par1ItemStack.stackSize; + + if (par1ItemStack.stackSize <= 0) + { + return new ItemStack(Items.potionitem); + } + + if (!par3EntityPlayer.inventory.addItemStackToInventory(new ItemStack(Items.potionitem))) + { + par3EntityPlayer.dropPlayerItemWithRandomChoice(new ItemStack(Items.potionitem, 1, 0), false); + } + } + } + + return par1ItemStack; + } + } + + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) {} +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemHangingEntity.java b/src/main/java/net/minecraft/item/ItemHangingEntity.java new file mode 100644 index 0000000..63b7b6a --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemHangingEntity.java @@ -0,0 +1,62 @@ +package net.minecraft.item; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityHanging; +import net.minecraft.entity.item.EntityItemFrame; +import net.minecraft.entity.item.EntityPainting; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.Direction; +import net.minecraft.world.World; + +public class ItemHangingEntity extends Item +{ + private final Class hangingEntityClass; + private static final String __OBFID = "CL_00000038"; + + public ItemHangingEntity(Class p_i45342_1_) + { + this.hangingEntityClass = p_i45342_1_; + this.setCreativeTab(CreativeTabs.tabDecorations); + } + + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) + { + if (par7 == 0) + { + return false; + } + else if (par7 == 1) + { + return false; + } + else + { + int i1 = Direction.facingToDirection[par7]; + EntityHanging entityhanging = this.createHangingEntity(par3World, par4, par5, par6, i1); + + if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack)) + { + return false; + } + else + { + if (entityhanging != null && entityhanging.onValidSurface()) + { + if (!par3World.isRemote) + { + par3World.spawnEntityInWorld(entityhanging); + } + + --par1ItemStack.stackSize; + } + + return true; + } + } + } + + private EntityHanging createHangingEntity(World par1World, int par2, int par3, int par4, int par5) + { + return (EntityHanging)(this.hangingEntityClass == EntityPainting.class ? new EntityPainting(par1World, par2, par3, par4, par5) : (this.hangingEntityClass == EntityItemFrame.class ? new EntityItemFrame(par1World, par2, par3, par4, par5) : null)); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemHoe.java b/src/main/java/net/minecraft/item/ItemHoe.java new file mode 100644 index 0000000..a996f3b --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemHoe.java @@ -0,0 +1,83 @@ +package net.minecraft.item; + +import cpw.mods.fml.common.eventhandler.Event.Result; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.player.UseHoeEvent; + +public class ItemHoe extends Item +{ + protected Item.ToolMaterial theToolMaterial; + private static final String __OBFID = "CL_00000039"; + + public ItemHoe(Item.ToolMaterial p_i45343_1_) + { + this.theToolMaterial = p_i45343_1_; + this.maxStackSize = 1; + this.setMaxDamage(p_i45343_1_.getMaxUses()); + this.setCreativeTab(CreativeTabs.tabTools); + } + + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) + { + if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack)) + { + return false; + } + else + { + UseHoeEvent event = new UseHoeEvent(par2EntityPlayer, par1ItemStack, par3World, par4, par5, par6); + if (MinecraftForge.EVENT_BUS.post(event)) + { + return false; + } + + if (event.getResult() == Result.ALLOW) + { + par1ItemStack.damageItem(1, par2EntityPlayer); + return true; + } + + Block block = par3World.getBlock(par4, par5, par6); + + if (par7 != 0 && par3World.getBlock(par4, par5 + 1, par6).isAir(par3World, par4, par5 + 1, par6) && (block == Blocks.grass || block == Blocks.dirt)) + { + Block block1 = Blocks.farmland; + par3World.playSoundEffect((double)((float)par4 + 0.5F), (double)((float)par5 + 0.5F), (double)((float)par6 + 0.5F), block1.stepSound.getStepResourcePath(), (block1.stepSound.getVolume() + 1.0F) / 2.0F, block1.stepSound.getPitch() * 0.8F); + + if (par3World.isRemote) + { + return true; + } + else + { + par3World.setBlock(par4, par5, par6, block1); + par1ItemStack.damageItem(1, par2EntityPlayer); + return true; + } + } + else + { + return false; + } + } + } + + @SideOnly(Side.CLIENT) + public boolean isFull3D() + { + return true; + } + + public String getToolMaterialName() + { + return this.theToolMaterial.toString(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemLead.java b/src/main/java/net/minecraft/item/ItemLead.java new file mode 100644 index 0000000..63ed876 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemLead.java @@ -0,0 +1,74 @@ +package net.minecraft.item; + +import java.util.Iterator; +import java.util.List; +import net.minecraft.block.Block; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLeashKnot; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; + +public class ItemLead extends Item +{ + private static final String __OBFID = "CL_00000045"; + + public ItemLead() + { + this.setCreativeTab(CreativeTabs.tabTools); + } + + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) + { + Block block = par3World.getBlock(par4, par5, par6); + + if (block.getRenderType() == 11) + { + if (par3World.isRemote) + { + return true; + } + else + { + func_150909_a(par2EntityPlayer, par3World, par4, par5, par6); + return true; + } + } + else + { + return false; + } + } + + public static boolean func_150909_a(EntityPlayer p_150909_0_, World p_150909_1_, int p_150909_2_, int p_150909_3_, int p_150909_4_) + { + EntityLeashKnot entityleashknot = EntityLeashKnot.getKnotForBlock(p_150909_1_, p_150909_2_, p_150909_3_, p_150909_4_); + boolean flag = false; + double d0 = 7.0D; + List list = p_150909_1_.getEntitiesWithinAABB(EntityLiving.class, AxisAlignedBB.getAABBPool().getAABB((double)p_150909_2_ - d0, (double)p_150909_3_ - d0, (double)p_150909_4_ - d0, (double)p_150909_2_ + d0, (double)p_150909_3_ + d0, (double)p_150909_4_ + d0)); + + if (list != null) + { + Iterator iterator = list.iterator(); + + while (iterator.hasNext()) + { + EntityLiving entityliving = (EntityLiving)iterator.next(); + + if (entityliving.getLeashed() && entityliving.getLeashedToEntity() == p_150909_0_) + { + if (entityleashknot == null) + { + entityleashknot = EntityLeashKnot.func_110129_a(p_150909_1_, p_150909_2_, p_150909_3_, p_150909_4_); + } + + entityliving.setLeashedToEntity(entityleashknot, true); + flag = true; + } + } + } + + return flag; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemLeaves.java b/src/main/java/net/minecraft/item/ItemLeaves.java new file mode 100644 index 0000000..02f4cf5 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemLeaves.java @@ -0,0 +1,49 @@ +package net.minecraft.item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.BlockLeaves; +import net.minecraft.util.IIcon; + +public class ItemLeaves extends ItemBlock +{ + private final BlockLeaves field_150940_b; + private static final String __OBFID = "CL_00000046"; + + public ItemLeaves(BlockLeaves p_i45344_1_) + { + super(p_i45344_1_); + this.field_150940_b = p_i45344_1_; + this.setMaxDamage(0); + this.setHasSubtypes(true); + } + + public int getMetadata(int par1) + { + return par1 | 4; + } + + public String getUnlocalizedName(ItemStack par1ItemStack) + { + int i = par1ItemStack.getItemDamage(); + + if (i < 0 || i >= this.field_150940_b.func_150125_e().length) + { + i = 0; + } + + return super.getUnlocalizedName() + "." + this.field_150940_b.func_150125_e()[i]; + } + + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int par1) + { + return this.field_150940_b.getIcon(0, par1); + } + + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) + { + return this.field_150940_b.getRenderColor(par1ItemStack.getItemDamage()); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemLilyPad.java b/src/main/java/net/minecraft/item/ItemLilyPad.java new file mode 100644 index 0000000..e9e67e6 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemLilyPad.java @@ -0,0 +1,67 @@ +package net.minecraft.item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; + +public class ItemLilyPad extends ItemColored +{ + private static final String __OBFID = "CL_00000074"; + + public ItemLilyPad(Block p_i45357_1_) + { + super(p_i45357_1_, false); + } + + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + { + MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, true); + + if (movingobjectposition == null) + { + return par1ItemStack; + } + else + { + if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) + { + int i = movingobjectposition.blockX; + int j = movingobjectposition.blockY; + int k = movingobjectposition.blockZ; + + if (!par2World.canMineBlock(par3EntityPlayer, i, j, k)) + { + return par1ItemStack; + } + + if (!par3EntityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, par1ItemStack)) + { + return par1ItemStack; + } + + if (par2World.getBlock(i, j, k).getMaterial() == Material.water && par2World.getBlockMetadata(i, j, k) == 0 && par2World.isAirBlock(i, j + 1, k)) + { + par2World.setBlock(i, j + 1, k, Blocks.waterlily); + + if (!par3EntityPlayer.capabilities.isCreativeMode) + { + --par1ItemStack.stackSize; + } + } + } + + return par1ItemStack; + } + } + + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) + { + return Blocks.waterlily.getRenderColor(par1ItemStack.getItemDamage()); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemMap.java b/src/main/java/net/minecraft/item/ItemMap.java new file mode 100644 index 0000000..7c6eec2 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemMap.java @@ -0,0 +1,303 @@ +package net.minecraft.item; + +import com.google.common.collect.HashMultiset; +import com.google.common.collect.Iterables; +import com.google.common.collect.Multisets; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.block.Block; +import net.minecraft.block.material.MapColor; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S34PacketMaps; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.storage.MapData; + +public class ItemMap extends ItemMapBase +{ + private static final String __OBFID = "CL_00000047"; + + protected ItemMap() + { + this.setHasSubtypes(true); + } + + @SideOnly(Side.CLIENT) + public static MapData func_150912_a(int p_150912_0_, World p_150912_1_) + { + String s = "map_" + p_150912_0_; + MapData mapdata = (MapData)p_150912_1_.loadItemData(MapData.class, s); + + if (mapdata == null) + { + mapdata = new MapData(s); + p_150912_1_.setItemData(s, mapdata); + } + + return mapdata; + } + + public MapData getMapData(ItemStack par1ItemStack, World par2World) + { + String s = "map_" + par1ItemStack.getItemDamage(); + MapData mapdata = (MapData)par2World.loadItemData(MapData.class, s); + + if (mapdata == null && !par2World.isRemote) + { + par1ItemStack.setItemDamage(par2World.getUniqueDataId("map")); + s = "map_" + par1ItemStack.getItemDamage(); + mapdata = new MapData(s); + mapdata.scale = 3; + int i = 128 * (1 << mapdata.scale); + mapdata.xCenter = Math.round((float)par2World.getWorldInfo().getSpawnX() / (float)i) * i; + mapdata.zCenter = Math.round((float)(par2World.getWorldInfo().getSpawnZ() / i)) * i; + mapdata.dimension = par2World.provider.dimensionId; + mapdata.markDirty(); + par2World.setItemData(s, mapdata); + } + + return mapdata; + } + + public void updateMapData(World par1World, Entity par2Entity, MapData par3MapData) + { + if (par1World.provider.dimensionId == par3MapData.dimension && par2Entity instanceof EntityPlayer) + { + int i = 1 << par3MapData.scale; + int j = par3MapData.xCenter; + int k = par3MapData.zCenter; + int l = MathHelper.floor_double(par2Entity.posX - (double)j) / i + 64; + int i1 = MathHelper.floor_double(par2Entity.posZ - (double)k) / i + 64; + int j1 = 128 / i; + + if (par1World.provider.hasNoSky) + { + j1 /= 2; + } + + MapData.MapInfo mapinfo = par3MapData.func_82568_a((EntityPlayer)par2Entity); + ++mapinfo.field_82569_d; + + for (int k1 = l - j1 + 1; k1 < l + j1; ++k1) + { + if ((k1 & 15) == (mapinfo.field_82569_d & 15)) + { + int l1 = 255; + int i2 = 0; + double d0 = 0.0D; + + for (int j2 = i1 - j1 - 1; j2 < i1 + j1; ++j2) + { + if (k1 >= 0 && j2 >= -1 && k1 < 128 && j2 < 128) + { + int k2 = k1 - l; + int l2 = j2 - i1; + boolean flag = k2 * k2 + l2 * l2 > (j1 - 2) * (j1 - 2); + int i3 = (j / i + k1 - 64) * i; + int j3 = (k / i + j2 - 64) * i; + HashMultiset hashmultiset = HashMultiset.create(); + Chunk chunk = par1World.getChunkFromBlockCoords(i3, j3); + + if (!chunk.isEmpty()) + { + int k3 = i3 & 15; + int l3 = j3 & 15; + int i4 = 0; + double d1 = 0.0D; + int j4; + + if (par1World.provider.hasNoSky) + { + j4 = i3 + j3 * 231871; + j4 = j4 * j4 * 31287121 + j4 * 11; + + if ((j4 >> 20 & 1) == 0) + { + hashmultiset.add(Blocks.dirt.getMapColor(0), 10); + } + else + { + hashmultiset.add(Blocks.stone.getMapColor(0), 100); + } + + d1 = 100.0D; + } + else + { + for (j4 = 0; j4 < i; ++j4) + { + for (int k4 = 0; k4 < i; ++k4) + { + int l4 = chunk.getHeightValue(j4 + k3, k4 + l3) + 1; + Block block = Blocks.air; + int i5 = 0; + + if (l4 > 1) + { + do + { + --l4; + block = chunk.getBlock(j4 + k3, l4, k4 + l3); + i5 = chunk.getBlockMetadata(j4 + k3, l4, k4 + l3); + } + while (block.getMapColor(i5) == MapColor.airColor && l4 > 0); + + if (l4 > 0 && block.getMaterial().isLiquid()) + { + int j5 = l4 - 1; + Block block1; + + do + { + block1 = chunk.getBlock(j4 + k3, j5--, k4 + l3); + ++i4; + } + while (j5 > 0 && block1.getMaterial().isLiquid()); + } + } + + d1 += (double)l4 / (double)(i * i); + hashmultiset.add(block.getMapColor(i5)); + } + } + } + + i4 /= i * i; + double d2 = (d1 - d0) * 4.0D / (double)(i + 4) + ((double)(k1 + j2 & 1) - 0.5D) * 0.4D; + byte b0 = 1; + + if (d2 > 0.6D) + { + b0 = 2; + } + + if (d2 < -0.6D) + { + b0 = 0; + } + + MapColor mapcolor = (MapColor)Iterables.getFirst(Multisets.copyHighestCountFirst(hashmultiset), MapColor.airColor); + + if (mapcolor == MapColor.waterColor) + { + d2 = (double)i4 * 0.1D + (double)(k1 + j2 & 1) * 0.2D; + b0 = 1; + + if (d2 < 0.5D) + { + b0 = 2; + } + + if (d2 > 0.9D) + { + b0 = 0; + } + } + + d0 = d1; + + if (j2 >= 0 && k2 * k2 + l2 * l2 < j1 * j1 && (!flag || (k1 + j2 & 1) != 0)) + { + byte b1 = par3MapData.colors[k1 + j2 * 128]; + byte b2 = (byte)(mapcolor.colorIndex * 4 + b0); + + if (b1 != b2) + { + if (l1 > j2) + { + l1 = j2; + } + + if (i2 < j2) + { + i2 = j2; + } + + par3MapData.colors[k1 + j2 * 128] = b2; + } + } + } + } + } + + if (l1 <= i2) + { + par3MapData.setColumnDirty(k1, l1, i2); + } + } + } + } + } + + public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) + { + if (!par2World.isRemote) + { + MapData mapdata = this.getMapData(par1ItemStack, par2World); + + if (par3Entity instanceof EntityPlayer) + { + EntityPlayer entityplayer = (EntityPlayer)par3Entity; + mapdata.updateVisiblePlayers(entityplayer, par1ItemStack); + } + + if (par5) + { + this.updateMapData(par2World, par3Entity, mapdata); + } + } + } + + public Packet func_150911_c(ItemStack p_150911_1_, World p_150911_2_, EntityPlayer p_150911_3_) + { + byte[] abyte = this.getMapData(p_150911_1_, p_150911_2_).getUpdatePacketData(p_150911_1_, p_150911_2_, p_150911_3_); + return abyte == null ? null : new S34PacketMaps(p_150911_1_.getItemDamage(), abyte); + } + + public void onCreated(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + { + if (par1ItemStack.hasTagCompound() && par1ItemStack.getTagCompound().getBoolean("map_is_scaling")) + { + MapData mapdata = Items.filled_map.getMapData(par1ItemStack, par2World); + par1ItemStack.setItemDamage(par2World.getUniqueDataId("map")); + MapData mapdata1 = new MapData("map_" + par1ItemStack.getItemDamage()); + mapdata1.scale = (byte)(mapdata.scale + 1); + + if (mapdata1.scale > 4) + { + mapdata1.scale = 4; + } + + mapdata1.xCenter = mapdata.xCenter; + mapdata1.zCenter = mapdata.zCenter; + mapdata1.dimension = mapdata.dimension; + mapdata1.markDirty(); + par2World.setItemData("map_" + par1ItemStack.getItemDamage(), mapdata1); + } + } + + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) + { + MapData mapdata = this.getMapData(par1ItemStack, par2EntityPlayer.worldObj); + + if (par4) + { + if (mapdata == null) + { + par3List.add("Unknown map"); + } + else + { + par3List.add("Scaling at 1:" + (1 << mapdata.scale)); + par3List.add("(Level " + mapdata.scale + "/" + 4 + ")"); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemMapBase.java b/src/main/java/net/minecraft/item/ItemMapBase.java new file mode 100644 index 0000000..4face48 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemMapBase.java @@ -0,0 +1,20 @@ +package net.minecraft.item; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.network.Packet; +import net.minecraft.world.World; + +public class ItemMapBase extends Item +{ + private static final String __OBFID = "CL_00000004"; + + public boolean isMap() + { + return true; + } + + public Packet func_150911_c(ItemStack p_150911_1_, World p_150911_2_, EntityPlayer p_150911_3_) + { + return null; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemMinecart.java b/src/main/java/net/minecraft/item/ItemMinecart.java new file mode 100644 index 0000000..5f3da36 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemMinecart.java @@ -0,0 +1,100 @@ +package net.minecraft.item; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockDispenser; +import net.minecraft.block.BlockRailBase; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.dispenser.BehaviorDefaultDispenseItem; +import net.minecraft.dispenser.IBehaviorDispenseItem; +import net.minecraft.dispenser.IBlockSource; +import net.minecraft.entity.item.EntityMinecart; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.EnumFacing; +import net.minecraft.world.World; + +public class ItemMinecart extends Item +{ + private static final IBehaviorDispenseItem dispenserMinecartBehavior = new BehaviorDefaultDispenseItem() + { + private final BehaviorDefaultDispenseItem behaviourDefaultDispenseItem = new BehaviorDefaultDispenseItem(); + private static final String __OBFID = "CL_00000050"; + public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) + { + EnumFacing enumfacing = BlockDispenser.func_149937_b(par1IBlockSource.getBlockMetadata()); + World world = par1IBlockSource.getWorld(); + double d0 = par1IBlockSource.getX() + (double)((float)enumfacing.getFrontOffsetX() * 1.125F); + double d1 = par1IBlockSource.getY() + (double)((float)enumfacing.getFrontOffsetY() * 1.125F); + double d2 = par1IBlockSource.getZ() + (double)((float)enumfacing.getFrontOffsetZ() * 1.125F); + int i = par1IBlockSource.getXInt() + enumfacing.getFrontOffsetX(); + int j = par1IBlockSource.getYInt() + enumfacing.getFrontOffsetY(); + int k = par1IBlockSource.getZInt() + enumfacing.getFrontOffsetZ(); + Block block = world.getBlock(i, j, k); + double d3; + + if (BlockRailBase.func_150051_a(block)) + { + d3 = 0.0D; + } + else + { + if (block.getMaterial() != Material.air || !BlockRailBase.func_150051_a(world.getBlock(i, j - 1, k))) + { + return this.behaviourDefaultDispenseItem.dispense(par1IBlockSource, par2ItemStack); + } + + d3 = -1.0D; + } + + EntityMinecart entityminecart = EntityMinecart.createMinecart(world, d0, d1 + d3, d2, ((ItemMinecart)par2ItemStack.getItem()).minecartType); + + if (par2ItemStack.hasDisplayName()) + { + entityminecart.setMinecartName(par2ItemStack.getDisplayName()); + } + + world.spawnEntityInWorld(entityminecart); + par2ItemStack.splitStack(1); + return par2ItemStack; + } + protected void playDispenseSound(IBlockSource par1IBlockSource) + { + par1IBlockSource.getWorld().playAuxSFX(1000, par1IBlockSource.getXInt(), par1IBlockSource.getYInt(), par1IBlockSource.getZInt(), 0); + } + }; + public int minecartType; + private static final String __OBFID = "CL_00000049"; + + public ItemMinecart(int p_i45345_1_) + { + this.maxStackSize = 1; + this.minecartType = p_i45345_1_; + this.setCreativeTab(CreativeTabs.tabTransport); + BlockDispenser.dispenseBehaviorRegistry.putObject(this, dispenserMinecartBehavior); + } + + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) + { + if (BlockRailBase.func_150051_a(par3World.getBlock(par4, par5, par6))) + { + if (!par3World.isRemote) + { + EntityMinecart entityminecart = EntityMinecart.createMinecart(par3World, (double)((float)par4 + 0.5F), (double)((float)par5 + 0.5F), (double)((float)par6 + 0.5F), this.minecartType); + + if (par1ItemStack.hasDisplayName()) + { + entityminecart.setMinecartName(par1ItemStack.getDisplayName()); + } + + par3World.spawnEntityInWorld(entityminecart); + } + + --par1ItemStack.stackSize; + return true; + } + else + { + return false; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemMonsterPlacer.java b/src/main/java/net/minecraft/item/ItemMonsterPlacer.java new file mode 100644 index 0000000..88b2c93 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemMonsterPlacer.java @@ -0,0 +1,210 @@ +package net.minecraft.item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Iterator; +import java.util.List; +import net.minecraft.block.Block; +import net.minecraft.block.BlockLiquid; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityList; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.Facing; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +public class ItemMonsterPlacer extends Item +{ + @SideOnly(Side.CLIENT) + private IIcon theIcon; + private static final String __OBFID = "CL_00000070"; + + public ItemMonsterPlacer() + { + this.setHasSubtypes(true); + this.setCreativeTab(CreativeTabs.tabMisc); + } + + public String getItemStackDisplayName(ItemStack par1ItemStack) + { + String s = ("" + StatCollector.translateToLocal(this.getUnlocalizedName() + ".name")).trim(); + String s1 = EntityList.getStringFromID(par1ItemStack.getItemDamage()); + + if (s1 != null) + { + s = s + " " + StatCollector.translateToLocal("entity." + s1 + ".name"); + } + + return s; + } + + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) + { + EntityList.EntityEggInfo entityegginfo = (EntityList.EntityEggInfo)EntityList.entityEggs.get(Integer.valueOf(par1ItemStack.getItemDamage())); + return entityegginfo != null ? (par2 == 0 ? entityegginfo.primaryColor : entityegginfo.secondaryColor) : 16777215; + } + + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) + { + if (par3World.isRemote) + { + return true; + } + else + { + Block block = par3World.getBlock(par4, par5, par6); + par4 += Facing.offsetsXForSide[par7]; + par5 += Facing.offsetsYForSide[par7]; + par6 += Facing.offsetsZForSide[par7]; + double d0 = 0.0D; + + if (par7 == 1 && block.getRenderType() == 11) + { + d0 = 0.5D; + } + + Entity entity = spawnCreature(par3World, par1ItemStack.getItemDamage(), (double)par4 + 0.5D, (double)par5 + d0, (double)par6 + 0.5D); + + if (entity != null) + { + if (entity instanceof EntityLivingBase && par1ItemStack.hasDisplayName()) + { + ((EntityLiving)entity).setCustomNameTag(par1ItemStack.getDisplayName()); + } + + if (!par2EntityPlayer.capabilities.isCreativeMode) + { + --par1ItemStack.stackSize; + } + } + + return true; + } + } + + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + { + if (par2World.isRemote) + { + return par1ItemStack; + } + else + { + MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, true); + + if (movingobjectposition == null) + { + return par1ItemStack; + } + else + { + if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) + { + int i = movingobjectposition.blockX; + int j = movingobjectposition.blockY; + int k = movingobjectposition.blockZ; + + if (!par2World.canMineBlock(par3EntityPlayer, i, j, k)) + { + return par1ItemStack; + } + + if (!par3EntityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, par1ItemStack)) + { + return par1ItemStack; + } + + if (par2World.getBlock(i, j, k) instanceof BlockLiquid) + { + Entity entity = spawnCreature(par2World, par1ItemStack.getItemDamage(), (double)i, (double)j, (double)k); + + if (entity != null) + { + if (entity instanceof EntityLivingBase && par1ItemStack.hasDisplayName()) + { + ((EntityLiving)entity).setCustomNameTag(par1ItemStack.getDisplayName()); + } + + if (!par3EntityPlayer.capabilities.isCreativeMode) + { + --par1ItemStack.stackSize; + } + } + } + } + + return par1ItemStack; + } + } + } + + public static Entity spawnCreature(World par0World, int par1, double par2, double par4, double par6) + { + if (!EntityList.entityEggs.containsKey(Integer.valueOf(par1))) + { + return null; + } + else + { + Entity entity = null; + + for (int j = 0; j < 1; ++j) + { + entity = EntityList.createEntityByID(par1, par0World); + + if (entity != null && entity instanceof EntityLivingBase) + { + EntityLiving entityliving = (EntityLiving)entity; + entity.setLocationAndAngles(par2, par4, par6, MathHelper.wrapAngleTo180_float(par0World.rand.nextFloat() * 360.0F), 0.0F); + entityliving.rotationYawHead = entityliving.rotationYaw; + entityliving.renderYawOffset = entityliving.rotationYaw; + entityliving.onSpawnWithEgg((IEntityLivingData)null); + par0World.spawnEntityInWorld(entity); + entityliving.playLivingSound(); + } + } + + return entity; + } + } + + @SideOnly(Side.CLIENT) + public boolean requiresMultipleRenderPasses() + { + return true; + } + + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamageForRenderPass(int par1, int par2) + { + return par2 > 0 ? this.theIcon : super.getIconFromDamageForRenderPass(par1, par2); + } + + @SideOnly(Side.CLIENT) + public void getSubItems(Item p_150895_1_, CreativeTabs p_150895_2_, List p_150895_3_) + { + Iterator iterator = EntityList.entityEggs.values().iterator(); + + while (iterator.hasNext()) + { + EntityList.EntityEggInfo entityegginfo = (EntityList.EntityEggInfo)iterator.next(); + p_150895_3_.add(new ItemStack(p_150895_1_, 1, entityegginfo.spawnedID)); + } + } + + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) + { + super.registerIcons(par1IconRegister); + this.theIcon = par1IconRegister.registerIcon(this.getIconString() + "_overlay"); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemMultiTexture.java b/src/main/java/net/minecraft/item/ItemMultiTexture.java new file mode 100644 index 0000000..e1f6484 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemMultiTexture.java @@ -0,0 +1,45 @@ +package net.minecraft.item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.util.IIcon; + +public class ItemMultiTexture extends ItemBlock +{ + protected final Block field_150941_b; + protected final String[] field_150942_c; + private static final String __OBFID = "CL_00000051"; + + public ItemMultiTexture(Block p_i45346_1_, Block p_i45346_2_, String[] p_i45346_3_) + { + super(p_i45346_1_); + this.field_150941_b = p_i45346_2_; + this.field_150942_c = p_i45346_3_; + this.setMaxDamage(0); + this.setHasSubtypes(true); + } + + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int par1) + { + return this.field_150941_b.getIcon(2, par1); + } + + public int getMetadata(int par1) + { + return par1; + } + + public String getUnlocalizedName(ItemStack par1ItemStack) + { + int i = par1ItemStack.getItemDamage(); + + if (i < 0 || i >= this.field_150942_c.length) + { + i = 0; + } + + return super.getUnlocalizedName() + "." + this.field_150942_c[i]; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemNameTag.java b/src/main/java/net/minecraft/item/ItemNameTag.java new file mode 100644 index 0000000..c5bed5f --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemNameTag.java @@ -0,0 +1,36 @@ +package net.minecraft.item; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; + +public class ItemNameTag extends Item +{ + private static final String __OBFID = "CL_00000052"; + + public ItemNameTag() + { + this.setCreativeTab(CreativeTabs.tabTools); + } + + public boolean itemInteractionForEntity(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, EntityLivingBase par3EntityLivingBase) + { + if (!par1ItemStack.hasDisplayName()) + { + return false; + } + else if (par3EntityLivingBase instanceof EntityLiving) + { + EntityLiving entityliving = (EntityLiving)par3EntityLivingBase; + entityliving.setCustomNameTag(par1ItemStack.getDisplayName()); + entityliving.func_110163_bv(); + --par1ItemStack.stackSize; + return true; + } + else + { + return super.itemInteractionForEntity(par1ItemStack, par2EntityPlayer, par3EntityLivingBase); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemPickaxe.java b/src/main/java/net/minecraft/item/ItemPickaxe.java new file mode 100644 index 0000000..3d90a3a --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemPickaxe.java @@ -0,0 +1,28 @@ +package net.minecraft.item; + +import com.google.common.collect.Sets; +import java.util.Set; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; + +public class ItemPickaxe extends ItemTool +{ + private static final Set field_150915_c = Sets.newHashSet(new Block[] {Blocks.cobblestone, Blocks.double_stone_slab, Blocks.stone_slab, Blocks.stone, Blocks.sandstone, Blocks.mossy_cobblestone, Blocks.iron_ore, Blocks.iron_block, Blocks.coal_ore, Blocks.gold_block, Blocks.gold_ore, Blocks.diamond_ore, Blocks.diamond_block, Blocks.ice, Blocks.netherrack, Blocks.lapis_ore, Blocks.lapis_block, Blocks.redstone_ore, Blocks.lit_redstone_ore, Blocks.rail, Blocks.detector_rail, Blocks.golden_rail, Blocks.activator_rail}); + private static final String __OBFID = "CL_00000053"; + + protected ItemPickaxe(Item.ToolMaterial p_i45347_1_) + { + super(2.0F, p_i45347_1_, field_150915_c); + } + + public boolean func_150897_b(Block p_150897_1_) + { + return p_150897_1_ == Blocks.obsidian ? this.toolMaterial.getHarvestLevel() == 3 : (p_150897_1_ != Blocks.diamond_block && p_150897_1_ != Blocks.diamond_ore ? (p_150897_1_ != Blocks.emerald_ore && p_150897_1_ != Blocks.emerald_block ? (p_150897_1_ != Blocks.gold_block && p_150897_1_ != Blocks.gold_ore ? (p_150897_1_ != Blocks.iron_block && p_150897_1_ != Blocks.iron_ore ? (p_150897_1_ != Blocks.lapis_block && p_150897_1_ != Blocks.lapis_ore ? (p_150897_1_ != Blocks.redstone_ore && p_150897_1_ != Blocks.lit_redstone_ore ? (p_150897_1_.getMaterial() == Material.rock ? true : (p_150897_1_.getMaterial() == Material.iron ? true : p_150897_1_.getMaterial() == Material.anvil)) : this.toolMaterial.getHarvestLevel() >= 2) : this.toolMaterial.getHarvestLevel() >= 1) : this.toolMaterial.getHarvestLevel() >= 1) : this.toolMaterial.getHarvestLevel() >= 2) : this.toolMaterial.getHarvestLevel() >= 2) : this.toolMaterial.getHarvestLevel() >= 2); + } + + public float func_150893_a(ItemStack p_150893_1_, Block p_150893_2_) + { + return p_150893_2_.getMaterial() != Material.iron && p_150893_2_.getMaterial() != Material.anvil && p_150893_2_.getMaterial() != Material.rock ? super.func_150893_a(p_150893_1_, p_150893_2_) : this.efficiencyOnProperMaterial; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemPiston.java b/src/main/java/net/minecraft/item/ItemPiston.java new file mode 100644 index 0000000..e9b13d9 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemPiston.java @@ -0,0 +1,18 @@ +package net.minecraft.item; + +import net.minecraft.block.Block; + +public class ItemPiston extends ItemBlock +{ + private static final String __OBFID = "CL_00000054"; + + public ItemPiston(Block p_i45348_1_) + { + super(p_i45348_1_); + } + + public int getMetadata(int par1) + { + return 7; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemPotion.java b/src/main/java/net/minecraft/item/ItemPotion.java new file mode 100644 index 0000000..d7bbcdc --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemPotion.java @@ -0,0 +1,443 @@ +package net.minecraft.item; + +import com.google.common.collect.HashMultimap; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.ai.attributes.AttributeModifier; +import net.minecraft.entity.ai.attributes.IAttribute; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.projectile.EntityPotion; +import net.minecraft.init.Items; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.potion.PotionHelper; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +public class ItemPotion extends Item +{ + private HashMap effectCache = new HashMap(); + private static final Map field_77835_b = new LinkedHashMap(); + @SideOnly(Side.CLIENT) + private IIcon field_94591_c; + @SideOnly(Side.CLIENT) + private IIcon field_94590_d; + @SideOnly(Side.CLIENT) + private IIcon field_94592_ct; + private static final String __OBFID = "CL_00000055"; + + public ItemPotion() + { + this.setMaxStackSize(1); + this.setHasSubtypes(true); + this.setMaxDamage(0); + this.setCreativeTab(CreativeTabs.tabBrewing); + } + + public List getEffects(ItemStack par1ItemStack) + { + if (par1ItemStack.hasTagCompound() && par1ItemStack.getTagCompound().hasKey("CustomPotionEffects", 9)) + { + ArrayList arraylist = new ArrayList(); + NBTTagList nbttaglist = par1ItemStack.getTagCompound().getTagList("CustomPotionEffects", 10); + + for (int i = 0; i < nbttaglist.tagCount(); ++i) + { + NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i); + PotionEffect potioneffect = PotionEffect.readCustomPotionEffectFromNBT(nbttagcompound); + + if (potioneffect != null) + { + arraylist.add(potioneffect); + } + } + + return arraylist; + } + else + { + List list = (List)this.effectCache.get(Integer.valueOf(par1ItemStack.getItemDamage())); + + if (list == null) + { + list = PotionHelper.getPotionEffects(par1ItemStack.getItemDamage(), false); + this.effectCache.put(Integer.valueOf(par1ItemStack.getItemDamage()), list); + } + + return list; + } + } + + public List getEffects(int par1) + { + List list = (List)this.effectCache.get(Integer.valueOf(par1)); + + if (list == null) + { + list = PotionHelper.getPotionEffects(par1, false); + this.effectCache.put(Integer.valueOf(par1), list); + } + + return list; + } + + public ItemStack onEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + { + if (!par3EntityPlayer.capabilities.isCreativeMode) + { + --par1ItemStack.stackSize; + } + + if (!par2World.isRemote) + { + List list = this.getEffects(par1ItemStack); + + if (list != null) + { + Iterator iterator = list.iterator(); + + while (iterator.hasNext()) + { + PotionEffect potioneffect = (PotionEffect)iterator.next(); + par3EntityPlayer.addPotionEffect(new PotionEffect(potioneffect)); + } + } + } + + if (!par3EntityPlayer.capabilities.isCreativeMode) + { + if (par1ItemStack.stackSize <= 0) + { + return new ItemStack(Items.glass_bottle); + } + + par3EntityPlayer.inventory.addItemStackToInventory(new ItemStack(Items.glass_bottle)); + } + + return par1ItemStack; + } + + public int getMaxItemUseDuration(ItemStack par1ItemStack) + { + return 32; + } + + public EnumAction getItemUseAction(ItemStack par1ItemStack) + { + return EnumAction.drink; + } + + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + { + if (isSplash(par1ItemStack.getItemDamage())) + { + if (!par3EntityPlayer.capabilities.isCreativeMode) + { + --par1ItemStack.stackSize; + } + + par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); + + if (!par2World.isRemote) + { + par2World.spawnEntityInWorld(new EntityPotion(par2World, par3EntityPlayer, par1ItemStack)); + } + + return par1ItemStack; + } + else + { + par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); + return par1ItemStack; + } + } + + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) + { + return false; + } + + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int par1) + { + return isSplash(par1) ? this.field_94591_c : this.field_94590_d; + } + + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamageForRenderPass(int par1, int par2) + { + return par2 == 0 ? this.field_94592_ct : super.getIconFromDamageForRenderPass(par1, par2); + } + + public static boolean isSplash(int par0) + { + return (par0 & 16384) != 0; + } + + @SideOnly(Side.CLIENT) + public int getColorFromDamage(int par1) + { + return PotionHelper.func_77915_a(par1, false); + } + + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack par1ItemStack, int par2) + { + return par2 > 0 ? 16777215 : this.getColorFromDamage(par1ItemStack.getItemDamage()); + } + + @SideOnly(Side.CLIENT) + public boolean requiresMultipleRenderPasses() + { + return true; + } + + @SideOnly(Side.CLIENT) + public boolean isEffectInstant(int par1) + { + List list = this.getEffects(par1); + + if (list != null && !list.isEmpty()) + { + Iterator iterator = list.iterator(); + PotionEffect potioneffect; + + do + { + if (!iterator.hasNext()) + { + return false; + } + + potioneffect = (PotionEffect)iterator.next(); + } + while (!Potion.potionTypes[potioneffect.getPotionID()].isInstant()); + + return true; + } + else + { + return false; + } + } + + public String getItemStackDisplayName(ItemStack par1ItemStack) + { + if (par1ItemStack.getItemDamage() == 0) + { + return StatCollector.translateToLocal("item.emptyPotion.name").trim(); + } + else + { + String s = ""; + + if (isSplash(par1ItemStack.getItemDamage())) + { + s = StatCollector.translateToLocal("potion.prefix.grenade").trim() + " "; + } + + List list = Items.potionitem.getEffects(par1ItemStack); + String s1; + + if (list != null && !list.isEmpty()) + { + s1 = ((PotionEffect)list.get(0)).getEffectName(); + s1 = s1 + ".postfix"; + return s + StatCollector.translateToLocal(s1).trim(); + } + else + { + s1 = PotionHelper.func_77905_c(par1ItemStack.getItemDamage()); + return StatCollector.translateToLocal(s1).trim() + " " + super.getItemStackDisplayName(par1ItemStack); + } + } + } + + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) + { + if (par1ItemStack.getItemDamage() != 0) + { + List list1 = Items.potionitem.getEffects(par1ItemStack); + HashMultimap hashmultimap = HashMultimap.create(); + Iterator iterator1; + + if (list1 != null && !list1.isEmpty()) + { + iterator1 = list1.iterator(); + + while (iterator1.hasNext()) + { + PotionEffect potioneffect = (PotionEffect)iterator1.next(); + String s1 = StatCollector.translateToLocal(potioneffect.getEffectName()).trim(); + Potion potion = Potion.potionTypes[potioneffect.getPotionID()]; + Map map = potion.func_111186_k(); + + if (map != null && map.size() > 0) + { + Iterator iterator = map.entrySet().iterator(); + + while (iterator.hasNext()) + { + Entry entry = (Entry)iterator.next(); + AttributeModifier attributemodifier = (AttributeModifier)entry.getValue(); + AttributeModifier attributemodifier1 = new AttributeModifier(attributemodifier.getName(), potion.func_111183_a(potioneffect.getAmplifier(), attributemodifier), attributemodifier.getOperation()); + hashmultimap.put(((IAttribute)entry.getKey()).getAttributeUnlocalizedName(), attributemodifier1); + } + } + + if (potioneffect.getAmplifier() > 0) + { + s1 = s1 + " " + StatCollector.translateToLocal("potion.potency." + potioneffect.getAmplifier()).trim(); + } + + if (potioneffect.getDuration() > 20) + { + s1 = s1 + " (" + Potion.getDurationString(potioneffect) + ")"; + } + + if (potion.isBadEffect()) + { + par3List.add(EnumChatFormatting.RED + s1); + } + else + { + par3List.add(EnumChatFormatting.GRAY + s1); + } + } + } + else + { + String s = StatCollector.translateToLocal("potion.empty").trim(); + par3List.add(EnumChatFormatting.GRAY + s); + } + + if (!hashmultimap.isEmpty()) + { + par3List.add(""); + par3List.add(EnumChatFormatting.DARK_PURPLE + StatCollector.translateToLocal("potion.effects.whenDrank")); + iterator1 = hashmultimap.entries().iterator(); + + while (iterator1.hasNext()) + { + Entry entry1 = (Entry)iterator1.next(); + AttributeModifier attributemodifier2 = (AttributeModifier)entry1.getValue(); + double d0 = attributemodifier2.getAmount(); + double d1; + + if (attributemodifier2.getOperation() != 1 && attributemodifier2.getOperation() != 2) + { + d1 = attributemodifier2.getAmount(); + } + else + { + d1 = attributemodifier2.getAmount() * 100.0D; + } + + if (d0 > 0.0D) + { + par3List.add(EnumChatFormatting.BLUE + StatCollector.translateToLocalFormatted("attribute.modifier.plus." + attributemodifier2.getOperation(), new Object[] {ItemStack.field_111284_a.format(d1), StatCollector.translateToLocal("attribute.name." + (String)entry1.getKey())})); + } + else if (d0 < 0.0D) + { + d1 *= -1.0D; + par3List.add(EnumChatFormatting.RED + StatCollector.translateToLocalFormatted("attribute.modifier.take." + attributemodifier2.getOperation(), new Object[] {ItemStack.field_111284_a.format(d1), StatCollector.translateToLocal("attribute.name." + (String)entry1.getKey())})); + } + } + } + } + } + + @SideOnly(Side.CLIENT) + public boolean hasEffect(ItemStack par1ItemStack) + { + List list = this.getEffects(par1ItemStack); + return list != null && !list.isEmpty(); + } + + @SideOnly(Side.CLIENT) + public void getSubItems(Item p_150895_1_, CreativeTabs p_150895_2_, List p_150895_3_) + { + super.getSubItems(p_150895_1_, p_150895_2_, p_150895_3_); + int j; + + if (field_77835_b.isEmpty()) + { + for (int i = 0; i <= 15; ++i) + { + for (j = 0; j <= 1; ++j) + { + int k; + + if (j == 0) + { + k = i | 8192; + } + else + { + k = i | 16384; + } + + for (int l = 0; l <= 2; ++l) + { + int i1 = k; + + if (l != 0) + { + if (l == 1) + { + i1 = k | 32; + } + else if (l == 2) + { + i1 = k | 64; + } + } + + List list1 = PotionHelper.getPotionEffects(i1, false); + + if (list1 != null && !list1.isEmpty()) + { + field_77835_b.put(list1, Integer.valueOf(i1)); + } + } + } + } + } + + Iterator iterator = field_77835_b.values().iterator(); + + while (iterator.hasNext()) + { + j = ((Integer)iterator.next()).intValue(); + p_150895_3_.add(new ItemStack(p_150895_1_, 1, j)); + } + } + + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) + { + this.field_94590_d = par1IconRegister.registerIcon(this.getIconString() + "_" + "bottle_drinkable"); + this.field_94591_c = par1IconRegister.registerIcon(this.getIconString() + "_" + "bottle_splash"); + this.field_94592_ct = par1IconRegister.registerIcon(this.getIconString() + "_" + "overlay"); + } + + @SideOnly(Side.CLIENT) + public static IIcon func_94589_d(String par0Str) + { + return par0Str.equals("bottle_drinkable") ? Items.potionitem.field_94590_d : (par0Str.equals("bottle_splash") ? Items.potionitem.field_94591_c : (par0Str.equals("overlay") ? Items.potionitem.field_94592_ct : null)); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemRecord.java b/src/main/java/net/minecraft/item/ItemRecord.java new file mode 100644 index 0000000..b4a1797 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemRecord.java @@ -0,0 +1,92 @@ +package net.minecraft.item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import net.minecraft.block.BlockJukebox; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +public class ItemRecord extends Item +{ + private static final Map field_150928_b = new HashMap(); + public final String recordName; + private static final String __OBFID = "CL_00000057"; + + protected ItemRecord(String p_i45350_1_) + { + this.recordName = p_i45350_1_; + this.maxStackSize = 1; + this.setCreativeTab(CreativeTabs.tabMisc); + field_150928_b.put("records." + p_i45350_1_, this); //Forge Bug Fix: RenderGlobal adds a "records." when looking up below. + } + + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int par1) + { + return this.itemIcon; + } + + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) + { + if (par3World.getBlock(par4, par5, par6) == Blocks.jukebox && par3World.getBlockMetadata(par4, par5, par6) == 0) + { + if (par3World.isRemote) + { + return true; + } + else + { + ((BlockJukebox)Blocks.jukebox).func_149926_b(par3World, par4, par5, par6, par1ItemStack); + par3World.playAuxSFXAtEntity((EntityPlayer)null, 1005, par4, par5, par6, Item.getIdFromItem(this)); + --par1ItemStack.stackSize; + return true; + } + } + else + { + return false; + } + } + + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) + { + par3List.add(this.getRecordNameLocal()); + } + + @SideOnly(Side.CLIENT) + public String getRecordNameLocal() + { + return StatCollector.translateToLocal("item.record." + this.recordName + ".desc"); + } + + public EnumRarity getRarity(ItemStack par1ItemStack) + { + return EnumRarity.rare; + } + + @SideOnly(Side.CLIENT) + public static ItemRecord getRecord(String p_150926_0_) + { + return (ItemRecord)field_150928_b.get(p_150926_0_); + } + + /** + * Retrieves the resource location of the sound to play for this record. + * + * @param name The name of the record to play + * @return The resource location for the audio, null to use default. + */ + public ResourceLocation getRecordResource(String name) + { + return new ResourceLocation(name); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemRedstone.java b/src/main/java/net/minecraft/item/ItemRedstone.java new file mode 100644 index 0000000..d9fdebb --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemRedstone.java @@ -0,0 +1,72 @@ +package net.minecraft.item; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; + +public class ItemRedstone extends Item +{ + private static final String __OBFID = "CL_00000058"; + + public ItemRedstone() + { + this.setCreativeTab(CreativeTabs.tabRedstone); + } + + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) + { + if (par3World.getBlock(par4, par5, par6) != Blocks.snow_layer) + { + if (par7 == 0) + { + --par5; + } + + if (par7 == 1) + { + ++par5; + } + + if (par7 == 2) + { + --par6; + } + + if (par7 == 3) + { + ++par6; + } + + if (par7 == 4) + { + --par4; + } + + if (par7 == 5) + { + ++par4; + } + + if (!par3World.isAirBlock(par4, par5, par6)) + { + return false; + } + } + + if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack)) + { + return false; + } + else + { + if (Blocks.redstone_wire.canPlaceBlockAt(par3World, par4, par5, par6)) + { + --par1ItemStack.stackSize; + par3World.setBlock(par4, par5, par6, Blocks.redstone_wire); + } + + return true; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemReed.java b/src/main/java/net/minecraft/item/ItemReed.java new file mode 100644 index 0000000..82424e9 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemReed.java @@ -0,0 +1,90 @@ +package net.minecraft.item; + +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; + +public class ItemReed extends Item +{ + private Block field_150935_a; + private static final String __OBFID = "CL_00001773"; + + public ItemReed(Block p_i45329_1_) + { + this.field_150935_a = p_i45329_1_; + } + + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) + { + Block block = par3World.getBlock(par4, par5, par6); + + if (block == Blocks.snow_layer && (par3World.getBlockMetadata(par4, par5, par6) & 7) < 1) + { + par7 = 1; + } + else if (block != Blocks.vine && block != Blocks.tallgrass && block != Blocks.deadbush) + { + if (par7 == 0) + { + --par5; + } + + if (par7 == 1) + { + ++par5; + } + + if (par7 == 2) + { + --par6; + } + + if (par7 == 3) + { + ++par6; + } + + if (par7 == 4) + { + --par4; + } + + if (par7 == 5) + { + ++par4; + } + } + + if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack)) + { + return false; + } + else if (par1ItemStack.stackSize == 0) + { + return false; + } + else + { + if (par3World.canPlaceEntityOnSide(this.field_150935_a, par4, par5, par6, false, par7, (Entity)null, par1ItemStack)) + { + int i1 = this.field_150935_a.onBlockPlaced(par3World, par4, par5, par6, par7, par8, par9, par10, 0); + + if (par3World.setBlock(par4, par5, par6, this.field_150935_a, i1, 3)) + { + if (par3World.getBlock(par4, par5, par6) == this.field_150935_a) + { + this.field_150935_a.onBlockPlacedBy(par3World, par4, par5, par6, par2EntityPlayer, par1ItemStack); + this.field_150935_a.onPostBlockPlaced(par3World, par4, par5, par6, i1); + } + + par3World.playSoundEffect((double)((float)par4 + 0.5F), (double)((float)par5 + 0.5F), (double)((float)par6 + 0.5F), this.field_150935_a.stepSound.func_150496_b(), (this.field_150935_a.stepSound.getVolume() + 1.0F) / 2.0F, this.field_150935_a.stepSound.getPitch() * 0.8F); + --par1ItemStack.stackSize; + } + } + + return true; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemSaddle.java b/src/main/java/net/minecraft/item/ItemSaddle.java new file mode 100644 index 0000000..fff9571 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemSaddle.java @@ -0,0 +1,44 @@ +package net.minecraft.item; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.passive.EntityPig; +import net.minecraft.entity.player.EntityPlayer; + +public class ItemSaddle extends Item +{ + private static final String __OBFID = "CL_00000059"; + + public ItemSaddle() + { + this.maxStackSize = 1; + this.setCreativeTab(CreativeTabs.tabTransport); + } + + public boolean itemInteractionForEntity(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, EntityLivingBase par3EntityLivingBase) + { + if (par3EntityLivingBase instanceof EntityPig) + { + EntityPig entitypig = (EntityPig)par3EntityLivingBase; + + if (!entitypig.getSaddled() && !entitypig.isChild()) + { + entitypig.setSaddled(true); + entitypig.worldObj.playSoundAtEntity(entitypig, "mob.horse.leather", 0.5F, 1.0F); + --par1ItemStack.stackSize; + } + + return true; + } + else + { + return false; + } + } + + public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase) + { + this.itemInteractionForEntity(par1ItemStack, (EntityPlayer)null, par2EntityLivingBase); + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemSeedFood.java b/src/main/java/net/minecraft/item/ItemSeedFood.java new file mode 100644 index 0000000..3b83eb0 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemSeedFood.java @@ -0,0 +1,66 @@ +package net.minecraft.item; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.EnumPlantType; +import net.minecraftforge.common.IPlantable; +import net.minecraftforge.common.util.ForgeDirection; + +public class ItemSeedFood extends ItemFood implements IPlantable +{ + private Block field_150908_b; + private Block soilId; + private static final String __OBFID = "CL_00000060"; + + public ItemSeedFood(int p_i45351_1_, float p_i45351_2_, Block p_i45351_3_, Block p_i45351_4_) + { + super(p_i45351_1_, p_i45351_2_, false); + this.field_150908_b = p_i45351_3_; + this.soilId = p_i45351_4_; + } + + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) + { + if (par7 != 1) + { + return false; + } + else if (par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack) && par2EntityPlayer.canPlayerEdit(par4, par5 + 1, par6, par7, par1ItemStack)) + { + if (par3World.getBlock(par4, par5, par6).canSustainPlant(par3World, par4, par5, par6, ForgeDirection.UP, this) && par3World.isAirBlock(par4, par5 + 1, par6)) + { + par3World.setBlock(par4, par5 + 1, par6, this.field_150908_b); + --par1ItemStack.stackSize; + return true; + } + else + { + return false; + } + } + else + { + return false; + } + } + + @Override + public EnumPlantType getPlantType(IBlockAccess world, int x, int y, int z) + { + return EnumPlantType.Crop; + } + + @Override + public Block getPlant(IBlockAccess world, int x, int y, int z) + { + return field_150908_b; + } + + @Override + public int getPlantMetadata(IBlockAccess world, int x, int y, int z) + { + return 0; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemSeeds.java b/src/main/java/net/minecraft/item/ItemSeeds.java new file mode 100644 index 0000000..76a52e1 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemSeeds.java @@ -0,0 +1,68 @@ +package net.minecraft.item; + +import net.minecraft.block.Block; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.EnumPlantType; +import net.minecraftforge.common.IPlantable; +import net.minecraftforge.common.util.ForgeDirection; + +public class ItemSeeds extends Item implements IPlantable +{ + private Block field_150925_a; + private Block soilBlockID; + private static final String __OBFID = "CL_00000061"; + + public ItemSeeds(Block p_i45352_1_, Block p_i45352_2_) + { + this.field_150925_a = p_i45352_1_; + this.soilBlockID = p_i45352_2_; + this.setCreativeTab(CreativeTabs.tabMaterials); + } + + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) + { + if (par7 != 1) + { + return false; + } + else if (par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack) && par2EntityPlayer.canPlayerEdit(par4, par5 + 1, par6, par7, par1ItemStack)) + { + if (par3World.getBlock(par4, par5, par6).canSustainPlant(par3World, par4, par5, par6, ForgeDirection.UP, this) && par3World.isAirBlock(par4, par5 + 1, par6)) + { + par3World.setBlock(par4, par5 + 1, par6, this.field_150925_a); + --par1ItemStack.stackSize; + return true; + } + else + { + return false; + } + } + else + { + return false; + } + } + + @Override + public EnumPlantType getPlantType(IBlockAccess world, int x, int y, int z) + { + return field_150925_a == Blocks.nether_wart ? EnumPlantType.Nether : EnumPlantType.Crop; + } + + @Override + public Block getPlant(IBlockAccess world, int x, int y, int z) + { + return field_150925_a; + } + + @Override + public int getPlantMetadata(IBlockAccess world, int x, int y, int z) + { + return 0; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemShears.java b/src/main/java/net/minecraft/item/ItemShears.java new file mode 100644 index 0000000..538b3d1 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemShears.java @@ -0,0 +1,116 @@ +package net.minecraft.item; + +import java.util.ArrayList; +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.stats.StatList; +import net.minecraft.world.World; +import net.minecraftforge.common.IShearable; + +public class ItemShears extends Item +{ + private static final String __OBFID = "CL_00000062"; + + public ItemShears() + { + this.setMaxStackSize(1); + this.setMaxDamage(238); + this.setCreativeTab(CreativeTabs.tabTools); + } + + public boolean onBlockDestroyed(ItemStack p_150894_1_, World p_150894_2_, Block p_150894_3_, int p_150894_4_, int p_150894_5_, int p_150894_6_, EntityLivingBase p_150894_7_) + { + if (p_150894_3_.getMaterial() != Material.leaves && p_150894_3_ != Blocks.web && p_150894_3_ != Blocks.tallgrass && p_150894_3_ != Blocks.vine && p_150894_3_ != Blocks.tripwire && !(p_150894_3_ instanceof IShearable)) + { + return super.onBlockDestroyed(p_150894_1_, p_150894_2_, p_150894_3_, p_150894_4_, p_150894_5_, p_150894_6_, p_150894_7_); + } + else + { + return true; + } + } + + public boolean func_150897_b(Block p_150897_1_) + { + return p_150897_1_ == Blocks.web || p_150897_1_ == Blocks.redstone_wire || p_150897_1_ == Blocks.tripwire; + } + + public float func_150893_a(ItemStack p_150893_1_, Block p_150893_2_) + { + return p_150893_2_ != Blocks.web && p_150893_2_.getMaterial() != Material.leaves ? (p_150893_2_ == Blocks.wool ? 5.0F : super.func_150893_a(p_150893_1_, p_150893_2_)) : 15.0F; + } + + @Override + public boolean itemInteractionForEntity(ItemStack itemstack, EntityPlayer player, EntityLivingBase entity) + { + if (entity.worldObj.isRemote) + { + return false; + } + if (entity instanceof IShearable) + { + IShearable target = (IShearable)entity; + if (target.isShearable(itemstack, entity.worldObj, (int)entity.posX, (int)entity.posY, (int)entity.posZ)) + { + ArrayList drops = target.onSheared(itemstack, entity.worldObj, (int)entity.posX, (int)entity.posY, (int)entity.posZ, + EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, itemstack)); + + Random rand = new Random(); + for(ItemStack stack : drops) + { + EntityItem ent = entity.entityDropItem(stack, 1.0F); + ent.motionY += rand.nextFloat() * 0.05F; + ent.motionX += (rand.nextFloat() - rand.nextFloat()) * 0.1F; + ent.motionZ += (rand.nextFloat() - rand.nextFloat()) * 0.1F; + } + itemstack.damageItem(1, entity); + } + return true; + } + return false; + } + + @Override + public boolean onBlockStartBreak(ItemStack itemstack, int x, int y, int z, EntityPlayer player) + { + if (player.worldObj.isRemote) + { + return false; + } + Block block = player.worldObj.getBlock(x, y, z); + if (block instanceof IShearable) + { + IShearable target = (IShearable)block; + if (target.isShearable(itemstack, player.worldObj, x, y, z)) + { + ArrayList drops = target.onSheared(itemstack, player.worldObj, x, y, z, + EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, itemstack)); + Random rand = new Random(); + + for(ItemStack stack : drops) + { + float f = 0.7F; + double d = (double)(rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D; + double d1 = (double)(rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D; + double d2 = (double)(rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D; + EntityItem entityitem = new EntityItem(player.worldObj, (double)x + d, (double)y + d1, (double)z + d2, stack); + entityitem.delayBeforeCanPickup = 10; + player.worldObj.spawnEntityInWorld(entityitem); + } + + itemstack.damageItem(1, player); + player.addStat(StatList.mineBlockStatArray[Block.getIdFromBlock(block)], 1); + } + } + return false; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemSign.java b/src/main/java/net/minecraft/item/ItemSign.java new file mode 100644 index 0000000..1c2234a --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemSign.java @@ -0,0 +1,93 @@ +package net.minecraft.item; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntitySign; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class ItemSign extends Item +{ + private static final String __OBFID = "CL_00000064"; + + public ItemSign() + { + this.maxStackSize = 16; + this.setCreativeTab(CreativeTabs.tabDecorations); + } + + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) + { + if (par7 == 0) + { + return false; + } + else if (!par3World.getBlock(par4, par5, par6).getMaterial().isSolid()) + { + return false; + } + else + { + if (par7 == 1) + { + ++par5; + } + + if (par7 == 2) + { + --par6; + } + + if (par7 == 3) + { + ++par6; + } + + if (par7 == 4) + { + --par4; + } + + if (par7 == 5) + { + ++par4; + } + + if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack)) + { + return false; + } + else if (!Blocks.standing_sign.canPlaceBlockAt(par3World, par4, par5, par6)) + { + return false; + } + else if (par3World.isRemote) + { + return true; + } + else + { + if (par7 == 1) + { + int i1 = MathHelper.floor_double((double)((par2EntityPlayer.rotationYaw + 180.0F) * 16.0F / 360.0F) + 0.5D) & 15; + par3World.setBlock(par4, par5, par6, Blocks.standing_sign, i1, 3); + } + else + { + par3World.setBlock(par4, par5, par6, Blocks.wall_sign, par7, 3); + } + + --par1ItemStack.stackSize; + TileEntitySign tileentitysign = (TileEntitySign)par3World.getTileEntity(par4, par5, par6); + + if (tileentitysign != null) + { + par2EntityPlayer.func_146100_a(tileentitysign); + } + + return true; + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemSimpleFoiled.java b/src/main/java/net/minecraft/item/ItemSimpleFoiled.java new file mode 100644 index 0000000..27df88d --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemSimpleFoiled.java @@ -0,0 +1,15 @@ +package net.minecraft.item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class ItemSimpleFoiled extends Item +{ + private static final String __OBFID = "CL_00000065"; + + @SideOnly(Side.CLIENT) + public boolean hasEffect(ItemStack par1ItemStack) + { + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemSkull.java b/src/main/java/net/minecraft/item/ItemSkull.java new file mode 100644 index 0000000..03f3a17 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemSkull.java @@ -0,0 +1,162 @@ +package net.minecraft.item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.block.BlockSkull; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntitySkull; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +public class ItemSkull extends Item +{ + private static final String[] skullTypes = new String[] {"skeleton", "wither", "zombie", "char", "creeper"}; + public static final String[] field_94587_a = new String[] {"skeleton", "wither", "zombie", "steve", "creeper"}; + @SideOnly(Side.CLIENT) + private IIcon[] field_94586_c; + private static final String __OBFID = "CL_00000067"; + + public ItemSkull() + { + this.setCreativeTab(CreativeTabs.tabDecorations); + this.setMaxDamage(0); + this.setHasSubtypes(true); + } + + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) + { + if (par7 == 0) + { + return false; + } + else if (!par3World.getBlock(par4, par5, par6).getMaterial().isSolid()) + { + return false; + } + else + { + if (par7 == 1) + { + ++par5; + } + + if (par7 == 2) + { + --par6; + } + + if (par7 == 3) + { + ++par6; + } + + if (par7 == 4) + { + --par4; + } + + if (par7 == 5) + { + ++par4; + } + + if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack)) + { + return false; + } + else if (!Blocks.skull.canPlaceBlockAt(par3World, par4, par5, par6)) + { + return false; + } + else + { + par3World.setBlock(par4, par5, par6, Blocks.skull, par7, 2); + int i1 = 0; + + if (par7 == 1) + { + i1 = MathHelper.floor_double((double)(par2EntityPlayer.rotationYaw * 16.0F / 360.0F) + 0.5D) & 15; + } + + TileEntity tileentity = par3World.getTileEntity(par4, par5, par6); + + if (tileentity != null && tileentity instanceof TileEntitySkull) + { + String s = ""; + + if (par1ItemStack.hasTagCompound() && par1ItemStack.getTagCompound().hasKey("SkullOwner", 8)) + { + s = par1ItemStack.getTagCompound().getString("SkullOwner"); + } + + ((TileEntitySkull)tileentity).func_145905_a(par1ItemStack.getItemDamage(), s); + ((TileEntitySkull)tileentity).func_145903_a(i1); + ((BlockSkull)Blocks.skull).func_149965_a(par3World, par4, par5, par6, (TileEntitySkull)tileentity); + } + + --par1ItemStack.stackSize; + return true; + } + } + } + + @SideOnly(Side.CLIENT) + public void getSubItems(Item p_150895_1_, CreativeTabs p_150895_2_, List p_150895_3_) + { + for (int i = 0; i < skullTypes.length; ++i) + { + p_150895_3_.add(new ItemStack(p_150895_1_, 1, i)); + } + } + + public int getMetadata(int par1) + { + return par1; + } + + public String getUnlocalizedName(ItemStack par1ItemStack) + { + int i = par1ItemStack.getItemDamage(); + + if (i < 0 || i >= skullTypes.length) + { + i = 0; + } + + return super.getUnlocalizedName() + "." + skullTypes[i]; + } + + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int par1) + { + if (par1 < 0 || par1 >= skullTypes.length) + { + par1 = 0; + } + + return this.field_94586_c[par1]; + } + + public String getItemStackDisplayName(ItemStack par1ItemStack) + { + return par1ItemStack.getItemDamage() == 3 && par1ItemStack.hasTagCompound() && par1ItemStack.getTagCompound().hasKey("SkullOwner", 8) ? StatCollector.translateToLocalFormatted("item.skull.player.name", new Object[] {par1ItemStack.getTagCompound().getString("SkullOwner")}): super.getItemStackDisplayName(par1ItemStack); + } + + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) + { + this.field_94586_c = new IIcon[field_94587_a.length]; + + for (int i = 0; i < field_94587_a.length; ++i) + { + this.field_94586_c[i] = par1IconRegister.registerIcon(this.getIconString() + "_" + field_94587_a[i]); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemSlab.java b/src/main/java/net/minecraft/item/ItemSlab.java new file mode 100644 index 0000000..d85cd4d --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemSlab.java @@ -0,0 +1,187 @@ +package net.minecraft.item; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.block.BlockSlab; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +public class ItemSlab extends ItemBlock +{ + private final boolean field_150948_b; + private final BlockSlab field_150949_c; + private final BlockSlab field_150947_d; + private static final String __OBFID = "CL_00000071"; + + public ItemSlab(Block p_i45355_1_, BlockSlab p_i45355_2_, BlockSlab p_i45355_3_, boolean p_i45355_4_) + { + super(p_i45355_1_); + this.field_150949_c = p_i45355_2_; + this.field_150947_d = p_i45355_3_; + this.field_150948_b = p_i45355_4_; + this.setMaxDamage(0); + this.setHasSubtypes(true); + } + + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(int par1) + { + return Block.getBlockFromItem(this).getIcon(2, par1); + } + + public int getMetadata(int par1) + { + return par1; + } + + public String getUnlocalizedName(ItemStack par1ItemStack) + { + return this.field_150949_c.func_150002_b(par1ItemStack.getItemDamage()); + } + + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) + { + if (this.field_150948_b) + { + return super.onItemUse(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10); + } + else if (par1ItemStack.stackSize == 0) + { + return false; + } + else if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack)) + { + return false; + } + else + { + Block block = par3World.getBlock(par4, par5, par6); + int i1 = par3World.getBlockMetadata(par4, par5, par6); + int j1 = i1 & 7; + boolean flag = (i1 & 8) != 0; + + if ((par7 == 1 && !flag || par7 == 0 && flag) && block == this.field_150949_c && j1 == par1ItemStack.getItemDamage()) + { + if (par3World.checkNoEntityCollision(this.field_150947_d.getCollisionBoundingBoxFromPool(par3World, par4, par5, par6)) && par3World.setBlock(par4, par5, par6, this.field_150947_d, j1, 3)) + { + par3World.playSoundEffect((double)((float)par4 + 0.5F), (double)((float)par5 + 0.5F), (double)((float)par6 + 0.5F), this.field_150947_d.stepSound.func_150496_b(), (this.field_150947_d.stepSound.getVolume() + 1.0F) / 2.0F, this.field_150947_d.stepSound.getPitch() * 0.8F); + --par1ItemStack.stackSize; + } + + return true; + } + else + { + return this.func_150946_a(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7) ? true : super.onItemUse(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10); + } + } + } + + @SideOnly(Side.CLIENT) + public boolean func_150936_a(World p_150936_1_, int p_150936_2_, int p_150936_3_, int p_150936_4_, int p_150936_5_, EntityPlayer p_150936_6_, ItemStack p_150936_7_) + { + int i1 = p_150936_2_; + int j1 = p_150936_3_; + int k1 = p_150936_4_; + Block block = p_150936_1_.getBlock(p_150936_2_, p_150936_3_, p_150936_4_); + int l1 = p_150936_1_.getBlockMetadata(p_150936_2_, p_150936_3_, p_150936_4_); + int i2 = l1 & 7; + boolean flag = (l1 & 8) != 0; + + if ((p_150936_5_ == 1 && !flag || p_150936_5_ == 0 && flag) && block == this.field_150949_c && i2 == p_150936_7_.getItemDamage()) + { + return true; + } + else + { + if (p_150936_5_ == 0) + { + --p_150936_3_; + } + + if (p_150936_5_ == 1) + { + ++p_150936_3_; + } + + if (p_150936_5_ == 2) + { + --p_150936_4_; + } + + if (p_150936_5_ == 3) + { + ++p_150936_4_; + } + + if (p_150936_5_ == 4) + { + --p_150936_2_; + } + + if (p_150936_5_ == 5) + { + ++p_150936_2_; + } + + Block block1 = p_150936_1_.getBlock(p_150936_2_, p_150936_3_, p_150936_4_); + int j2 = p_150936_1_.getBlockMetadata(p_150936_2_, p_150936_3_, p_150936_4_); + i2 = j2 & 7; + return block1 == this.field_150949_c && i2 == p_150936_7_.getItemDamage() ? true : super.func_150936_a(p_150936_1_, i1, j1, k1, p_150936_5_, p_150936_6_, p_150936_7_); + } + } + + private boolean func_150946_a(ItemStack p_150946_1_, EntityPlayer p_150946_2_, World p_150946_3_, int p_150946_4_, int p_150946_5_, int p_150946_6_, int p_150946_7_) + { + if (p_150946_7_ == 0) + { + --p_150946_5_; + } + + if (p_150946_7_ == 1) + { + ++p_150946_5_; + } + + if (p_150946_7_ == 2) + { + --p_150946_6_; + } + + if (p_150946_7_ == 3) + { + ++p_150946_6_; + } + + if (p_150946_7_ == 4) + { + --p_150946_4_; + } + + if (p_150946_7_ == 5) + { + ++p_150946_4_; + } + + Block block = p_150946_3_.getBlock(p_150946_4_, p_150946_5_, p_150946_6_); + int i1 = p_150946_3_.getBlockMetadata(p_150946_4_, p_150946_5_, p_150946_6_); + int j1 = i1 & 7; + + if (block == this.field_150949_c && j1 == p_150946_1_.getItemDamage()) + { + if (p_150946_3_.checkNoEntityCollision(this.field_150947_d.getCollisionBoundingBoxFromPool(p_150946_3_, p_150946_4_, p_150946_5_, p_150946_6_)) && p_150946_3_.setBlock(p_150946_4_, p_150946_5_, p_150946_6_, this.field_150947_d, j1, 3)) + { + p_150946_3_.playSoundEffect((double)((float)p_150946_4_ + 0.5F), (double)((float)p_150946_5_ + 0.5F), (double)((float)p_150946_6_ + 0.5F), this.field_150947_d.stepSound.func_150496_b(), (this.field_150947_d.stepSound.getVolume() + 1.0F) / 2.0F, this.field_150947_d.stepSound.getPitch() * 0.8F); + --p_150946_1_.stackSize; + } + + return true; + } + else + { + return false; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemSnow.java b/src/main/java/net/minecraft/item/ItemSnow.java new file mode 100644 index 0000000..6119cb8 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemSnow.java @@ -0,0 +1,47 @@ +package net.minecraft.item; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; + +public class ItemSnow extends ItemBlockWithMetadata +{ + private static final String __OBFID = "CL_00000068"; + + public ItemSnow(Block p_i45354_1_, Block p_i45354_2_) + { + super(p_i45354_1_, p_i45354_2_); + } + + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) + { + if (par1ItemStack.stackSize == 0) + { + return false; + } + else if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack)) + { + return false; + } + else + { + Block block = par3World.getBlock(par4, par5, par6); + + if (block == Blocks.snow_layer) + { + int i1 = par3World.getBlockMetadata(par4, par5, par6); + int j1 = i1 & 7; + + if (j1 <= 6 && par3World.checkNoEntityCollision(this.field_150939_a.getCollisionBoundingBoxFromPool(par3World, par4, par5, par6)) && par3World.setBlockMetadataWithNotify(par4, par5, par6, j1 + 1 | i1 & -8, 2)) + { + par3World.playSoundEffect((double)((float)par4 + 0.5F), (double)((float)par5 + 0.5F), (double)((float)par6 + 0.5F), this.field_150939_a.stepSound.func_150496_b(), (this.field_150939_a.stepSound.getVolume() + 1.0F) / 2.0F, this.field_150939_a.stepSound.getPitch() * 0.8F); + --par1ItemStack.stackSize; + return true; + } + } + + return super.onItemUse(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemSnowball.java b/src/main/java/net/minecraft/item/ItemSnowball.java new file mode 100644 index 0000000..ab69819 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemSnowball.java @@ -0,0 +1,34 @@ +package net.minecraft.item; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.projectile.EntitySnowball; +import net.minecraft.world.World; + +public class ItemSnowball extends Item +{ + private static final String __OBFID = "CL_00000069"; + + public ItemSnowball() + { + this.maxStackSize = 16; + this.setCreativeTab(CreativeTabs.tabMisc); + } + + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + { + if (!par3EntityPlayer.capabilities.isCreativeMode) + { + --par1ItemStack.stackSize; + } + + par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); + + if (!par2World.isRemote) + { + par2World.spawnEntityInWorld(new EntitySnowball(par2World, par3EntityPlayer)); + } + + return par1ItemStack; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemSoup.java b/src/main/java/net/minecraft/item/ItemSoup.java new file mode 100644 index 0000000..5c05742 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemSoup.java @@ -0,0 +1,22 @@ +package net.minecraft.item; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.world.World; + +public class ItemSoup extends ItemFood +{ + private static final String __OBFID = "CL_00001778"; + + public ItemSoup(int p_i45330_1_) + { + super(p_i45330_1_, false); + this.setMaxStackSize(1); + } + + public ItemStack onEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + { + super.onEaten(par1ItemStack, par2World, par3EntityPlayer); + return new ItemStack(Items.bowl); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemSpade.java b/src/main/java/net/minecraft/item/ItemSpade.java new file mode 100644 index 0000000..fd912ad --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemSpade.java @@ -0,0 +1,22 @@ +package net.minecraft.item; + +import com.google.common.collect.Sets; +import java.util.Set; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; + +public class ItemSpade extends ItemTool +{ + private static final Set field_150916_c = Sets.newHashSet(new Block[] {Blocks.grass, Blocks.dirt, Blocks.sand, Blocks.gravel, Blocks.snow_layer, Blocks.snow, Blocks.clay, Blocks.farmland, Blocks.soul_sand, Blocks.mycelium}); + private static final String __OBFID = "CL_00000063"; + + public ItemSpade(Item.ToolMaterial p_i45353_1_) + { + super(1.0F, p_i45353_1_, field_150916_c); + } + + public boolean func_150897_b(Block p_150897_1_) + { + return p_150897_1_ == Blocks.snow_layer ? true : p_150897_1_ == Blocks.snow; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemStack.java b/src/main/java/net/minecraft/item/ItemStack.java new file mode 100644 index 0000000..426b129 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemStack.java @@ -0,0 +1,761 @@ +package net.minecraft.item; + +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import java.util.Map.Entry; +import net.minecraft.block.Block; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnchantmentDurability; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.attributes.AttributeModifier; +import net.minecraft.entity.item.EntityItemFrame; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.event.HoverEvent; +import net.minecraft.init.Items; +import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.stats.StatList; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IChatComponent; +import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import net.minecraftforge.event.ForgeEventFactory; + +public final class ItemStack +{ + public static final DecimalFormat field_111284_a = new DecimalFormat("#.###"); + public int stackSize; + public int animationsToGo; + private Item field_151002_e; + public NBTTagCompound stackTagCompound; + int itemDamage; + private EntityItemFrame itemFrame; + private static final String __OBFID = "CL_00000043"; + + public ItemStack(Block par1Block) + { + this(par1Block, 1); + } + + public ItemStack(Block par1Block, int par2) + { + this(par1Block, par2, 0); + } + + public ItemStack(Block par1Block, int par2, int par3) + { + this(Item.getItemFromBlock(par1Block), par2, par3); + } + + public ItemStack(Item par1Item) + { + this(par1Item, 1); + } + + public ItemStack(Item par1Item, int par2) + { + this(par1Item, par2, 0); + } + + public ItemStack(Item par1Item, int par2, int par3) + { + this.field_151002_e = par1Item; + this.stackSize = par2; + this.itemDamage = par3; + + if (this.itemDamage < 0) + { + this.itemDamage = 0; + } + } + + public static ItemStack loadItemStackFromNBT(NBTTagCompound par0NBTTagCompound) + { + ItemStack itemstack = new ItemStack(); + itemstack.readFromNBT(par0NBTTagCompound); + return itemstack.getItem() != null ? itemstack : null; + } + + private ItemStack() {} + + public ItemStack splitStack(int par1) + { + ItemStack itemstack = new ItemStack(this.field_151002_e, par1, this.itemDamage); + + if (this.stackTagCompound != null) + { + itemstack.stackTagCompound = (NBTTagCompound)this.stackTagCompound.copy(); + } + + this.stackSize -= par1; + return itemstack; + } + + public Item getItem() + { + return this.field_151002_e; + } + + @SideOnly(Side.CLIENT) + public IIcon getIconIndex() + { + return this.getItem().getIconIndex(this); + } + + @SideOnly(Side.CLIENT) + public int getItemSpriteNumber() + { + return this.getItem().getSpriteNumber(); + } + + public boolean tryPlaceItemIntoWorld(EntityPlayer par1EntityPlayer, World par2World, int par3, int par4, int par5, int par6, float par7, float par8, float par9) + { + boolean flag = this.getItem().onItemUse(this, par1EntityPlayer, par2World, par3, par4, par5, par6, par7, par8, par9); + + if (flag) + { + par1EntityPlayer.addStat(StatList.objectUseStats[Item.getIdFromItem(this.field_151002_e)], 1); + } + + return flag; + } + + public float func_150997_a(Block p_150997_1_) + { + return this.getItem().func_150893_a(this, p_150997_1_); + } + + public ItemStack useItemRightClick(World par1World, EntityPlayer par2EntityPlayer) + { + return this.getItem().onItemRightClick(this, par1World, par2EntityPlayer); + } + + public ItemStack onFoodEaten(World par1World, EntityPlayer par2EntityPlayer) + { + return this.getItem().onEaten(this, par1World, par2EntityPlayer); + } + + public NBTTagCompound writeToNBT(NBTTagCompound par1NBTTagCompound) + { + par1NBTTagCompound.setShort("id", (short)Item.getIdFromItem(this.field_151002_e)); + par1NBTTagCompound.setByte("Count", (byte)this.stackSize); + par1NBTTagCompound.setShort("Damage", (short)this.itemDamage); + + if (this.stackTagCompound != null) + { + par1NBTTagCompound.setTag("tag", this.stackTagCompound); + } + + return par1NBTTagCompound; + } + + public void readFromNBT(NBTTagCompound par1NBTTagCompound) + { + this.field_151002_e = Item.getItemById(par1NBTTagCompound.getShort("id")); + this.stackSize = par1NBTTagCompound.getByte("Count"); + this.itemDamage = par1NBTTagCompound.getShort("Damage"); + + if (this.itemDamage < 0) + { + this.itemDamage = 0; + } + + if (par1NBTTagCompound.hasKey("tag", 10)) + { + this.stackTagCompound = par1NBTTagCompound.getCompoundTag("tag"); + } + } + + public int getMaxStackSize() + { + return this.getItem().getItemStackLimit(this); + } + + public boolean isStackable() + { + return this.getMaxStackSize() > 1 && (!this.isItemStackDamageable() || !this.isItemDamaged()); + } + + public boolean isItemStackDamageable() + { + return this.field_151002_e.getMaxDamage(this) <= 0 ? false : !this.hasTagCompound() || !this.getTagCompound().getBoolean("Unbreakable"); + } + + public boolean getHasSubtypes() + { + return this.field_151002_e.getHasSubtypes(); + } + + public boolean isItemDamaged() + { + return this.isItemStackDamageable() && getItem().isDamaged(this); + } + + public int getItemDamageForDisplay() + { + return getItem().getDisplayDamage(this); + } + + public int getItemDamage() + { + return getItem().getDamage(this); + } + + public void setItemDamage(int par1) + { + getItem().setDamage(this, par1); + } + + public int getMaxDamage() + { + return getItem().getMaxDamage(this); + } + + public boolean attemptDamageItem(int par1, Random par2Random) + { + if (!this.isItemStackDamageable()) + { + return false; + } + else + { + if (par1 > 0) + { + int j = EnchantmentHelper.getEnchantmentLevel(Enchantment.unbreaking.effectId, this); + int k = 0; + + for (int l = 0; j > 0 && l < par1; ++l) + { + if (EnchantmentDurability.negateDamage(this, j, par2Random)) + { + ++k; + } + } + + par1 -= k; + + if (par1 <= 0) + { + return false; + } + } + + setItemDamage(getItemDamage() + par1); //Redirect through Item's callback if applicable. + return getItemDamage() > getMaxDamage(); + } + } + + public void damageItem(int par1, EntityLivingBase par2EntityLivingBase) + { + if (!(par2EntityLivingBase instanceof EntityPlayer) || !((EntityPlayer)par2EntityLivingBase).capabilities.isCreativeMode) + { + if (this.isItemStackDamageable()) + { + if (this.attemptDamageItem(par1, par2EntityLivingBase.getRNG())) + { + par2EntityLivingBase.renderBrokenItemStack(this); + --this.stackSize; + + if (par2EntityLivingBase instanceof EntityPlayer) + { + EntityPlayer entityplayer = (EntityPlayer)par2EntityLivingBase; + entityplayer.addStat(StatList.objectBreakStats[Item.getIdFromItem(this.field_151002_e)], 1); + + if (this.stackSize == 0 && this.getItem() instanceof ItemBow) + { + entityplayer.destroyCurrentEquippedItem(); + } + } + + if (this.stackSize < 0) + { + this.stackSize = 0; + } + + this.itemDamage = 0; + } + } + } + } + + public void hitEntity(EntityLivingBase par1EntityLivingBase, EntityPlayer par2EntityPlayer) + { + boolean flag = this.field_151002_e.hitEntity(this, par1EntityLivingBase, par2EntityPlayer); + + if (flag) + { + par2EntityPlayer.addStat(StatList.objectUseStats[Item.getIdFromItem(this.field_151002_e)], 1); + } + } + + public void func_150999_a(World p_150999_1_, Block p_150999_2_, int p_150999_3_, int p_150999_4_, int p_150999_5_, EntityPlayer p_150999_6_) + { + boolean flag = this.field_151002_e.onBlockDestroyed(this, p_150999_1_, p_150999_2_, p_150999_3_, p_150999_4_, p_150999_5_, p_150999_6_); + + if (flag) + { + p_150999_6_.addStat(StatList.objectUseStats[Item.getIdFromItem(this.field_151002_e)], 1); + } + } + + public boolean func_150998_b(Block p_150998_1_) + { + return getItem().canHarvestBlock(p_150998_1_, this); + } + + public boolean interactWithEntity(EntityPlayer par1EntityPlayer, EntityLivingBase par2EntityLivingBase) + { + return this.field_151002_e.itemInteractionForEntity(this, par1EntityPlayer, par2EntityLivingBase); + } + + public ItemStack copy() + { + ItemStack itemstack = new ItemStack(this.field_151002_e, this.stackSize, this.itemDamage); + + if (this.stackTagCompound != null) + { + itemstack.stackTagCompound = (NBTTagCompound)this.stackTagCompound.copy(); + } + + return itemstack; + } + + public static boolean areItemStackTagsEqual(ItemStack par0ItemStack, ItemStack par1ItemStack) + { + return par0ItemStack == null && par1ItemStack == null ? true : (par0ItemStack != null && par1ItemStack != null ? (par0ItemStack.stackTagCompound == null && par1ItemStack.stackTagCompound != null ? false : par0ItemStack.stackTagCompound == null || par0ItemStack.stackTagCompound.equals(par1ItemStack.stackTagCompound)) : false); + } + + public static boolean areItemStacksEqual(ItemStack par0ItemStack, ItemStack par1ItemStack) + { + return par0ItemStack == null && par1ItemStack == null ? true : (par0ItemStack != null && par1ItemStack != null ? par0ItemStack.isItemStackEqual(par1ItemStack) : false); + } + + private boolean isItemStackEqual(ItemStack par1ItemStack) + { + return this.stackSize != par1ItemStack.stackSize ? false : (this.field_151002_e != par1ItemStack.field_151002_e ? false : (this.itemDamage != par1ItemStack.itemDamage ? false : (this.stackTagCompound == null && par1ItemStack.stackTagCompound != null ? false : this.stackTagCompound == null || this.stackTagCompound.equals(par1ItemStack.stackTagCompound)))); + } + + public boolean isItemEqual(ItemStack par1ItemStack) + { + return this.field_151002_e == par1ItemStack.field_151002_e && this.itemDamage == par1ItemStack.itemDamage; + } + + public String getUnlocalizedName() + { + return this.field_151002_e.getUnlocalizedName(this); + } + + public static ItemStack copyItemStack(ItemStack par0ItemStack) + { + return par0ItemStack == null ? null : par0ItemStack.copy(); + } + + public String toString() + { + return this.stackSize + "x" + this.field_151002_e.getUnlocalizedName() + "@" + this.itemDamage; + } + + public void updateAnimation(World par1World, Entity par2Entity, int par3, boolean par4) + { + if (this.animationsToGo > 0) + { + --this.animationsToGo; + } + + this.field_151002_e.onUpdate(this, par1World, par2Entity, par3, par4); + } + + public void onCrafting(World par1World, EntityPlayer par2EntityPlayer, int par3) + { + par2EntityPlayer.addStat(StatList.objectCraftStats[Item.getIdFromItem(this.field_151002_e)], par3); + this.field_151002_e.onCreated(this, par1World, par2EntityPlayer); + } + + public int getMaxItemUseDuration() + { + return this.getItem().getMaxItemUseDuration(this); + } + + public EnumAction getItemUseAction() + { + return this.getItem().getItemUseAction(this); + } + + public void onPlayerStoppedUsing(World par1World, EntityPlayer par2EntityPlayer, int par3) + { + this.getItem().onPlayerStoppedUsing(this, par1World, par2EntityPlayer, par3); + } + + public boolean hasTagCompound() + { + return this.stackTagCompound != null; + } + + public NBTTagCompound getTagCompound() + { + return this.stackTagCompound; + } + + public NBTTagList getEnchantmentTagList() + { + return this.stackTagCompound == null ? null : this.stackTagCompound.getTagList("ench", 10); + } + + public void setTagCompound(NBTTagCompound par1NBTTagCompound) + { + this.stackTagCompound = par1NBTTagCompound; + } + + public String getDisplayName() + { + String s = this.getItem().getItemStackDisplayName(this); + + if (this.stackTagCompound != null && this.stackTagCompound.hasKey("display", 10)) + { + NBTTagCompound nbttagcompound = this.stackTagCompound.getCompoundTag("display"); + + if (nbttagcompound.hasKey("Name", 8)) + { + s = nbttagcompound.getString("Name"); + } + } + + return s; + } + + public ItemStack setStackDisplayName(String p_151001_1_) + { + if (this.stackTagCompound == null) + { + this.stackTagCompound = new NBTTagCompound(); + } + + if (!this.stackTagCompound.hasKey("display", 10)) + { + this.stackTagCompound.setTag("display", new NBTTagCompound()); + } + + this.stackTagCompound.getCompoundTag("display").setString("Name", p_151001_1_); + return this; + } + + public void func_135074_t() + { + if (this.stackTagCompound != null) + { + if (this.stackTagCompound.hasKey("display", 10)) + { + NBTTagCompound nbttagcompound = this.stackTagCompound.getCompoundTag("display"); + nbttagcompound.removeTag("Name"); + + if (nbttagcompound.hasNoTags()) + { + this.stackTagCompound.removeTag("display"); + + if (this.stackTagCompound.hasNoTags()) + { + this.setTagCompound((NBTTagCompound)null); + } + } + } + } + } + + public boolean hasDisplayName() + { + return this.stackTagCompound == null ? false : (!this.stackTagCompound.hasKey("display", 10) ? false : this.stackTagCompound.getCompoundTag("display").hasKey("Name", 8)); + } + + @SideOnly(Side.CLIENT) + public List getTooltip(EntityPlayer par1EntityPlayer, boolean par2) + { + ArrayList arraylist = new ArrayList(); + String s = this.getDisplayName(); + + if (this.hasDisplayName()) + { + s = EnumChatFormatting.ITALIC + s + EnumChatFormatting.RESET; + } + + int i; + + if (par2) + { + String s1 = ""; + + if (s.length() > 0) + { + s = s + " ("; + s1 = ")"; + } + + i = Item.getIdFromItem(this.field_151002_e); + + if (this.getHasSubtypes()) + { + s = s + String.format("#%04d/%d%s", new Object[] {Integer.valueOf(i), Integer.valueOf(this.itemDamage), s1}); + } + else + { + s = s + String.format("#%04d%s", new Object[] {Integer.valueOf(i), s1}); + } + } + else if (!this.hasDisplayName() && this.field_151002_e == Items.filled_map) + { + s = s + " #" + this.itemDamage; + } + + arraylist.add(s); + this.field_151002_e.addInformation(this, par1EntityPlayer, arraylist, par2); + + if (this.hasTagCompound()) + { + NBTTagList nbttaglist = this.getEnchantmentTagList(); + + if (nbttaglist != null) + { + for (i = 0; i < nbttaglist.tagCount(); ++i) + { + short short1 = nbttaglist.getCompoundTagAt(i).getShort("id"); + short short2 = nbttaglist.getCompoundTagAt(i).getShort("lvl"); + + if (Enchantment.enchantmentsList[short1] != null) + { + arraylist.add(Enchantment.enchantmentsList[short1].getTranslatedName(short2)); + } + } + } + + if (this.stackTagCompound.hasKey("display", 10)) + { + NBTTagCompound nbttagcompound = this.stackTagCompound.getCompoundTag("display"); + + if (nbttagcompound.hasKey("color", 3)) + { + if (par2) + { + arraylist.add("Color: #" + Integer.toHexString(nbttagcompound.getInteger("color")).toUpperCase()); + } + else + { + arraylist.add(EnumChatFormatting.ITALIC + StatCollector.translateToLocal("item.dyed")); + } + } + + if (nbttagcompound.func_150299_b("Lore") == 9) + { + NBTTagList nbttaglist1 = nbttagcompound.getTagList("Lore", 8); + + if (nbttaglist1.tagCount() > 0) + { + for (int j = 0; j < nbttaglist1.tagCount(); ++j) + { + arraylist.add(EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC + nbttaglist1.getStringTagAt(j)); + } + } + } + } + } + + Multimap multimap = this.getAttributeModifiers(); + + if (!multimap.isEmpty()) + { + arraylist.add(""); + Iterator iterator = multimap.entries().iterator(); + + while (iterator.hasNext()) + { + Entry entry = (Entry)iterator.next(); + AttributeModifier attributemodifier = (AttributeModifier)entry.getValue(); + double d0 = attributemodifier.getAmount(); + double d1; + + if (attributemodifier.getOperation() != 1 && attributemodifier.getOperation() != 2) + { + d1 = attributemodifier.getAmount(); + } + else + { + d1 = attributemodifier.getAmount() * 100.0D; + } + + if (d0 > 0.0D) + { + arraylist.add(EnumChatFormatting.BLUE + StatCollector.translateToLocalFormatted("attribute.modifier.plus." + attributemodifier.getOperation(), new Object[] {field_111284_a.format(d1), StatCollector.translateToLocal("attribute.name." + (String)entry.getKey())})); + } + else if (d0 < 0.0D) + { + d1 *= -1.0D; + arraylist.add(EnumChatFormatting.RED + StatCollector.translateToLocalFormatted("attribute.modifier.take." + attributemodifier.getOperation(), new Object[] {field_111284_a.format(d1), StatCollector.translateToLocal("attribute.name." + (String)entry.getKey())})); + } + } + } + + if (this.hasTagCompound() && this.getTagCompound().getBoolean("Unbreakable")) + { + arraylist.add(EnumChatFormatting.BLUE + StatCollector.translateToLocal("item.unbreakable")); + } + + if (par2 && this.isItemDamaged()) + { + arraylist.add("Durability: " + (this.getMaxDamage() - this.getItemDamageForDisplay()) + " / " + this.getMaxDamage()); + } + ForgeEventFactory.onItemTooltip(this, par1EntityPlayer, arraylist, par2); + + return arraylist; + } + + @Deprecated + @SideOnly(Side.CLIENT) + public boolean hasEffect() + { + return hasEffect(0); + } + + @SideOnly(Side.CLIENT) + public boolean hasEffect(int pass) + { + return this.getItem().hasEffect(this, pass); + } + + public EnumRarity getRarity() + { + return this.getItem().getRarity(this); + } + + public boolean isItemEnchantable() + { + return !this.getItem().isItemTool(this) ? false : !this.isItemEnchanted(); + } + + public void addEnchantment(Enchantment par1Enchantment, int par2) + { + if (this.stackTagCompound == null) + { + this.setTagCompound(new NBTTagCompound()); + } + + if (!this.stackTagCompound.hasKey("ench", 9)) + { + this.stackTagCompound.setTag("ench", new NBTTagList()); + } + + NBTTagList nbttaglist = this.stackTagCompound.getTagList("ench", 10); + NBTTagCompound nbttagcompound = new NBTTagCompound(); + nbttagcompound.setShort("id", (short)par1Enchantment.effectId); + nbttagcompound.setShort("lvl", (short)((byte)par2)); + nbttaglist.appendTag(nbttagcompound); + } + + public boolean isItemEnchanted() + { + return this.stackTagCompound != null && this.stackTagCompound.hasKey("ench", 9); + } + + public void setTagInfo(String par1Str, NBTBase par2NBTBase) + { + if (this.stackTagCompound == null) + { + this.setTagCompound(new NBTTagCompound()); + } + + this.stackTagCompound.setTag(par1Str, par2NBTBase); + } + + public boolean canEditBlocks() + { + return this.getItem().canItemEditBlocks(); + } + + public boolean isOnItemFrame() + { + return this.itemFrame != null; + } + + public void setItemFrame(EntityItemFrame par1EntityItemFrame) + { + this.itemFrame = par1EntityItemFrame; + } + + public EntityItemFrame getItemFrame() + { + return this.itemFrame; + } + + public int getRepairCost() + { + return this.hasTagCompound() && this.stackTagCompound.hasKey("RepairCost", 3) ? this.stackTagCompound.getInteger("RepairCost") : 0; + } + + public void setRepairCost(int par1) + { + if (!this.hasTagCompound()) + { + this.stackTagCompound = new NBTTagCompound(); + } + + this.stackTagCompound.setInteger("RepairCost", par1); + } + + public Multimap getAttributeModifiers() + { + Object object; + + if (this.hasTagCompound() && this.stackTagCompound.hasKey("AttributeModifiers", 9)) + { + object = HashMultimap.create(); + NBTTagList nbttaglist = this.stackTagCompound.getTagList("AttributeModifiers", 10); + + for (int i = 0; i < nbttaglist.tagCount(); ++i) + { + NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i); + AttributeModifier attributemodifier = SharedMonsterAttributes.readAttributeModifierFromNBT(nbttagcompound); + + if (attributemodifier.getID().getLeastSignificantBits() != 0L && attributemodifier.getID().getMostSignificantBits() != 0L) + { + ((Multimap)object).put(nbttagcompound.getString("AttributeName"), attributemodifier); + } + } + } + else + { + object = this.getItem().getAttributeModifiers(this); + } + + return (Multimap)object; + } + + public void func_150996_a(Item p_150996_1_) + { + this.field_151002_e = p_150996_1_; + } + + public IChatComponent func_151000_E() + { + IChatComponent ichatcomponent = (new ChatComponentText("[")).appendText(this.getDisplayName()).appendText("]"); + + if (this.field_151002_e != null) + { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + this.writeToNBT(nbttagcompound); + ichatcomponent.getChatStyle().setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_ITEM, new ChatComponentText(nbttagcompound.toString()))); + ichatcomponent.getChatStyle().setColor(this.getRarity().rarityColor); + } + + return ichatcomponent; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemSword.java b/src/main/java/net/minecraft/item/ItemSword.java new file mode 100644 index 0000000..19c06c4 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemSword.java @@ -0,0 +1,113 @@ +package net.minecraft.item; + +import com.google.common.collect.Multimap; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.attributes.AttributeModifier; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; + +public class ItemSword extends Item +{ + private float field_150934_a; + private final Item.ToolMaterial field_150933_b; + private static final String __OBFID = "CL_00000072"; + + public ItemSword(Item.ToolMaterial p_i45356_1_) + { + this.field_150933_b = p_i45356_1_; + this.maxStackSize = 1; + this.setMaxDamage(p_i45356_1_.getMaxUses()); + this.setCreativeTab(CreativeTabs.tabCombat); + this.field_150934_a = 4.0F + p_i45356_1_.getDamageVsEntity(); + } + + public float func_150931_i() + { + return this.field_150933_b.getDamageVsEntity(); + } + + public float func_150893_a(ItemStack p_150893_1_, Block p_150893_2_) + { + if (p_150893_2_ == Blocks.web) + { + return 15.0F; + } + else + { + Material material = p_150893_2_.getMaterial(); + return material != Material.plants && material != Material.vine && material != Material.coral && material != Material.leaves && material != Material.gourd ? 1.0F : 1.5F; + } + } + + public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase) + { + par1ItemStack.damageItem(1, par3EntityLivingBase); + return true; + } + + public boolean onBlockDestroyed(ItemStack p_150894_1_, World p_150894_2_, Block p_150894_3_, int p_150894_4_, int p_150894_5_, int p_150894_6_, EntityLivingBase p_150894_7_) + { + if ((double)p_150894_3_.getBlockHardness(p_150894_2_, p_150894_4_, p_150894_5_, p_150894_6_) != 0.0D) + { + p_150894_1_.damageItem(2, p_150894_7_); + } + + return true; + } + + @SideOnly(Side.CLIENT) + public boolean isFull3D() + { + return true; + } + + public EnumAction getItemUseAction(ItemStack par1ItemStack) + { + return EnumAction.block; + } + + public int getMaxItemUseDuration(ItemStack par1ItemStack) + { + return 72000; + } + + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + { + par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); + return par1ItemStack; + } + + public boolean func_150897_b(Block p_150897_1_) + { + return p_150897_1_ == Blocks.web; + } + + public int getItemEnchantability() + { + return this.field_150933_b.getEnchantability(); + } + + public String getToolMaterialName() + { + return this.field_150933_b.toString(); + } + + public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) + { + return this.field_150933_b.func_150995_f() == par2ItemStack.getItem() ? true : super.getIsRepairable(par1ItemStack, par2ItemStack); + } + + public Multimap getItemAttributeModifiers() + { + Multimap multimap = super.getItemAttributeModifiers(); + multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Weapon modifier", (double)this.field_150934_a, 0)); + return multimap; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemTool.java b/src/main/java/net/minecraft/item/ItemTool.java new file mode 100644 index 0000000..56261f0 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemTool.java @@ -0,0 +1,133 @@ +package net.minecraft.item; + +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Multimap; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Set; +import net.minecraft.block.Block; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.attributes.AttributeModifier; +import net.minecraft.world.World; +import net.minecraftforge.common.ForgeHooks; + +public class ItemTool extends Item +{ + private Set field_150914_c; + protected float efficiencyOnProperMaterial = 4.0F; + private float damageVsEntity; + protected Item.ToolMaterial toolMaterial; + private static final String __OBFID = "CL_00000019"; + + protected ItemTool(float p_i45333_1_, Item.ToolMaterial p_i45333_2_, Set p_i45333_3_) + { + this.toolMaterial = p_i45333_2_; + this.field_150914_c = p_i45333_3_; + this.maxStackSize = 1; + this.setMaxDamage(p_i45333_2_.getMaxUses()); + this.efficiencyOnProperMaterial = p_i45333_2_.getEfficiencyOnProperMaterial(); + this.damageVsEntity = p_i45333_1_ + p_i45333_2_.getDamageVsEntity(); + this.setCreativeTab(CreativeTabs.tabTools); + if (this instanceof ItemPickaxe) + { + toolClass = "pickaxe"; + } + else if (this instanceof ItemAxe) + { + toolClass = "axe"; + } + else if (this instanceof ItemSpade) + { + toolClass = "shovel"; + } + } + + public float func_150893_a(ItemStack p_150893_1_, Block p_150893_2_) + { + return this.field_150914_c.contains(p_150893_2_) ? this.efficiencyOnProperMaterial : 1.0F; + } + + public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase) + { + par1ItemStack.damageItem(2, par3EntityLivingBase); + return true; + } + + public boolean onBlockDestroyed(ItemStack p_150894_1_, World p_150894_2_, Block p_150894_3_, int p_150894_4_, int p_150894_5_, int p_150894_6_, EntityLivingBase p_150894_7_) + { + if ((double)p_150894_3_.getBlockHardness(p_150894_2_, p_150894_4_, p_150894_5_, p_150894_6_) != 0.0D) + { + p_150894_1_.damageItem(1, p_150894_7_); + } + + return true; + } + + @SideOnly(Side.CLIENT) + public boolean isFull3D() + { + return true; + } + + public Item.ToolMaterial func_150913_i() + { + return this.toolMaterial; + } + + public int getItemEnchantability() + { + return this.toolMaterial.getEnchantability(); + } + + public String getToolMaterialName() + { + return this.toolMaterial.toString(); + } + + public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) + { + return this.toolMaterial.func_150995_f() == par2ItemStack.getItem() ? true : super.getIsRepairable(par1ItemStack, par2ItemStack); + } + + public Multimap getItemAttributeModifiers() + { + Multimap multimap = super.getItemAttributeModifiers(); + multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Tool modifier", (double)this.damageVsEntity, 0)); + return multimap; + } + + /*===================================== FORGE START =================================*/ + private String toolClass; + @Override + public int getHarvestLevel(ItemStack stack, String toolClass) + { + int level = super.getHarvestLevel(stack, toolClass); + if (level == -1 && toolClass != null && toolClass.equals(this.toolClass)) + { + return this.toolMaterial.getHarvestLevel(); + } + else + { + return level; + } + } + + @Override + public Set getToolClasses(ItemStack stack) + { + return toolClass != null ? ImmutableSet.of(toolClass) : super.getToolClasses(stack); + } + + @Override + public float getDigSpeed(ItemStack stack, Block block, int meta) + { + if (ForgeHooks.isToolEffective(stack, block, meta)) + { + return efficiencyOnProperMaterial; + } + return super.getDigSpeed(stack, block, meta); + } + /*===================================== FORGE END =================================*/ +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/ItemWritableBook.java b/src/main/java/net/minecraft/item/ItemWritableBook.java new file mode 100644 index 0000000..3f03a48 --- /dev/null +++ b/src/main/java/net/minecraft/item/ItemWritableBook.java @@ -0,0 +1,60 @@ +package net.minecraft.item; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.world.World; + +public class ItemWritableBook extends Item +{ + private static final String __OBFID = "CL_00000076"; + + public ItemWritableBook() + { + this.setMaxStackSize(1); + } + + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + { + par3EntityPlayer.displayGUIBook(par1ItemStack); + return par1ItemStack; + } + + public boolean getShareTag() + { + return true; + } + + public static boolean func_150930_a(NBTTagCompound p_150930_0_) + { + if (p_150930_0_ == null) + { + return false; + } + else if (!p_150930_0_.hasKey("pages", 9)) + { + return false; + } + else + { + NBTTagList nbttaglist = p_150930_0_.getTagList("pages", 8); + + for (int i = 0; i < nbttaglist.tagCount(); ++i) + { + String s = nbttaglist.getStringTagAt(i); + + if (s == null) + { + return false; + } + + if (s.length() > 256) + { + return false; + } + } + + return true; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/crafting/CraftingManager.java b/src/main/java/net/minecraft/item/crafting/CraftingManager.java new file mode 100644 index 0000000..075a878 --- /dev/null +++ b/src/main/java/net/minecraft/item/crafting/CraftingManager.java @@ -0,0 +1,337 @@ +package net.minecraft.item.crafting; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class CraftingManager +{ + private static final CraftingManager instance = new CraftingManager(); + private List recipes = new ArrayList(); + private static final String __OBFID = "CL_00000090"; + + public static final CraftingManager getInstance() + { + return instance; + } + + private CraftingManager() + { + (new RecipesTools()).addRecipes(this); + (new RecipesWeapons()).addRecipes(this); + (new RecipesIngots()).addRecipes(this); + (new RecipesFood()).addRecipes(this); + (new RecipesCrafting()).addRecipes(this); + (new RecipesArmor()).addRecipes(this); + (new RecipesDyes()).addRecipes(this); + this.recipes.add(new RecipesArmorDyes()); + this.recipes.add(new RecipeBookCloning()); + this.recipes.add(new RecipesMapCloning()); + this.recipes.add(new RecipesMapExtending()); + this.recipes.add(new RecipeFireworks()); + this.addRecipe(new ItemStack(Items.paper, 3), new Object[] {"###", '#', Items.reeds}); + this.addShapelessRecipe(new ItemStack(Items.book, 1), new Object[] {Items.paper, Items.paper, Items.paper, Items.leather}); + this.addShapelessRecipe(new ItemStack(Items.writable_book, 1), new Object[] {Items.book, new ItemStack(Items.dye, 1, 0), Items.feather}); + this.addRecipe(new ItemStack(Blocks.fence, 2), new Object[] {"###", "###", '#', Items.stick}); + this.addRecipe(new ItemStack(Blocks.cobblestone_wall, 6, 0), new Object[] {"###", "###", '#', Blocks.cobblestone}); + this.addRecipe(new ItemStack(Blocks.cobblestone_wall, 6, 1), new Object[] {"###", "###", '#', Blocks.mossy_cobblestone}); + this.addRecipe(new ItemStack(Blocks.nether_brick_fence, 6), new Object[] {"###", "###", '#', Blocks.nether_brick}); + this.addRecipe(new ItemStack(Blocks.fence_gate, 1), new Object[] {"#W#", "#W#", '#', Items.stick, 'W', Blocks.planks}); + this.addRecipe(new ItemStack(Blocks.jukebox, 1), new Object[] {"###", "#X#", "###", '#', Blocks.planks, 'X', Items.diamond}); + this.addRecipe(new ItemStack(Items.lead, 2), new Object[] {"~~ ", "~O ", " ~", '~', Items.string, 'O', Items.slime_ball}); + this.addRecipe(new ItemStack(Blocks.noteblock, 1), new Object[] {"###", "#X#", "###", '#', Blocks.planks, 'X', Items.redstone}); + this.addRecipe(new ItemStack(Blocks.bookshelf, 1), new Object[] {"###", "XXX", "###", '#', Blocks.planks, 'X', Items.book}); + this.addRecipe(new ItemStack(Blocks.snow, 1), new Object[] {"##", "##", '#', Items.snowball}); + this.addRecipe(new ItemStack(Blocks.snow_layer, 6), new Object[] {"###", '#', Blocks.snow}); + this.addRecipe(new ItemStack(Blocks.clay, 1), new Object[] {"##", "##", '#', Items.clay_ball}); + this.addRecipe(new ItemStack(Blocks.brick_block, 1), new Object[] {"##", "##", '#', Items.brick}); + this.addRecipe(new ItemStack(Blocks.glowstone, 1), new Object[] {"##", "##", '#', Items.glowstone_dust}); + this.addRecipe(new ItemStack(Blocks.quartz_block, 1), new Object[] {"##", "##", '#', Items.quartz}); + this.addRecipe(new ItemStack(Blocks.wool, 1), new Object[] {"##", "##", '#', Items.string}); + this.addRecipe(new ItemStack(Blocks.tnt, 1), new Object[] {"X#X", "#X#", "X#X", 'X', Items.gunpowder, '#', Blocks.sand}); + this.addRecipe(new ItemStack(Blocks.stone_slab, 6, 3), new Object[] {"###", '#', Blocks.cobblestone}); + this.addRecipe(new ItemStack(Blocks.stone_slab, 6, 0), new Object[] {"###", '#', Blocks.stone}); + this.addRecipe(new ItemStack(Blocks.stone_slab, 6, 1), new Object[] {"###", '#', Blocks.sandstone}); + this.addRecipe(new ItemStack(Blocks.stone_slab, 6, 4), new Object[] {"###", '#', Blocks.brick_block}); + this.addRecipe(new ItemStack(Blocks.stone_slab, 6, 5), new Object[] {"###", '#', Blocks.stonebrick}); + this.addRecipe(new ItemStack(Blocks.stone_slab, 6, 6), new Object[] {"###", '#', Blocks.nether_brick}); + this.addRecipe(new ItemStack(Blocks.stone_slab, 6, 7), new Object[] {"###", '#', Blocks.quartz_block}); + this.addRecipe(new ItemStack(Blocks.wooden_slab, 6, 0), new Object[] {"###", '#', new ItemStack(Blocks.planks, 1, 0)}); + this.addRecipe(new ItemStack(Blocks.wooden_slab, 6, 2), new Object[] {"###", '#', new ItemStack(Blocks.planks, 1, 2)}); + this.addRecipe(new ItemStack(Blocks.wooden_slab, 6, 1), new Object[] {"###", '#', new ItemStack(Blocks.planks, 1, 1)}); + this.addRecipe(new ItemStack(Blocks.wooden_slab, 6, 3), new Object[] {"###", '#', new ItemStack(Blocks.planks, 1, 3)}); + this.addRecipe(new ItemStack(Blocks.wooden_slab, 6, 4), new Object[] {"###", '#', new ItemStack(Blocks.planks, 1, 4)}); + this.addRecipe(new ItemStack(Blocks.wooden_slab, 6, 5), new Object[] {"###", '#', new ItemStack(Blocks.planks, 1, 5)}); + this.addRecipe(new ItemStack(Blocks.ladder, 3), new Object[] {"# #", "###", "# #", '#', Items.stick}); + this.addRecipe(new ItemStack(Items.wooden_door, 1), new Object[] {"##", "##", "##", '#', Blocks.planks}); + this.addRecipe(new ItemStack(Blocks.trapdoor, 2), new Object[] {"###", "###", '#', Blocks.planks}); + this.addRecipe(new ItemStack(Items.iron_door, 1), new Object[] {"##", "##", "##", '#', Items.iron_ingot}); + this.addRecipe(new ItemStack(Items.sign, 3), new Object[] {"###", "###", " X ", '#', Blocks.planks, 'X', Items.stick}); + this.addRecipe(new ItemStack(Items.cake, 1), new Object[] {"AAA", "BEB", "CCC", 'A', Items.milk_bucket, 'B', Items.sugar, 'C', Items.wheat, 'E', Items.egg}); + this.addRecipe(new ItemStack(Items.sugar, 1), new Object[] {"#", '#', Items.reeds}); + this.addRecipe(new ItemStack(Blocks.planks, 4, 0), new Object[] {"#", '#', new ItemStack(Blocks.log, 1, 0)}); + this.addRecipe(new ItemStack(Blocks.planks, 4, 1), new Object[] {"#", '#', new ItemStack(Blocks.log, 1, 1)}); + this.addRecipe(new ItemStack(Blocks.planks, 4, 2), new Object[] {"#", '#', new ItemStack(Blocks.log, 1, 2)}); + this.addRecipe(new ItemStack(Blocks.planks, 4, 3), new Object[] {"#", '#', new ItemStack(Blocks.log, 1, 3)}); + this.addRecipe(new ItemStack(Blocks.planks, 4, 4), new Object[] {"#", '#', new ItemStack(Blocks.log2, 1, 0)}); + this.addRecipe(new ItemStack(Blocks.planks, 4, 5), new Object[] {"#", '#', new ItemStack(Blocks.log2, 1, 1)}); + this.addRecipe(new ItemStack(Items.stick, 4), new Object[] {"#", "#", '#', Blocks.planks}); + this.addRecipe(new ItemStack(Blocks.torch, 4), new Object[] {"X", "#", 'X', Items.coal, '#', Items.stick}); + this.addRecipe(new ItemStack(Blocks.torch, 4), new Object[] {"X", "#", 'X', new ItemStack(Items.coal, 1, 1), '#', Items.stick}); + this.addRecipe(new ItemStack(Items.bowl, 4), new Object[] {"# #", " # ", '#', Blocks.planks}); + this.addRecipe(new ItemStack(Items.glass_bottle, 3), new Object[] {"# #", " # ", '#', Blocks.glass}); + this.addRecipe(new ItemStack(Blocks.rail, 16), new Object[] {"X X", "X#X", "X X", 'X', Items.iron_ingot, '#', Items.stick}); + this.addRecipe(new ItemStack(Blocks.golden_rail, 6), new Object[] {"X X", "X#X", "XRX", 'X', Items.gold_ingot, 'R', Items.redstone, '#', Items.stick}); + this.addRecipe(new ItemStack(Blocks.activator_rail, 6), new Object[] {"XSX", "X#X", "XSX", 'X', Items.iron_ingot, '#', Blocks.redstone_torch, 'S', Items.stick}); + this.addRecipe(new ItemStack(Blocks.detector_rail, 6), new Object[] {"X X", "X#X", "XRX", 'X', Items.iron_ingot, 'R', Items.redstone, '#', Blocks.stone_pressure_plate}); + this.addRecipe(new ItemStack(Items.minecart, 1), new Object[] {"# #", "###", '#', Items.iron_ingot}); + this.addRecipe(new ItemStack(Items.cauldron, 1), new Object[] {"# #", "# #", "###", '#', Items.iron_ingot}); + this.addRecipe(new ItemStack(Items.brewing_stand, 1), new Object[] {" B ", "###", '#', Blocks.cobblestone, 'B', Items.blaze_rod}); + this.addRecipe(new ItemStack(Blocks.lit_pumpkin, 1), new Object[] {"A", "B", 'A', Blocks.pumpkin, 'B', Blocks.torch}); + this.addRecipe(new ItemStack(Items.chest_minecart, 1), new Object[] {"A", "B", 'A', Blocks.chest, 'B', Items.minecart}); + this.addRecipe(new ItemStack(Items.furnace_minecart, 1), new Object[] {"A", "B", 'A', Blocks.furnace, 'B', Items.minecart}); + this.addRecipe(new ItemStack(Items.tnt_minecart, 1), new Object[] {"A", "B", 'A', Blocks.tnt, 'B', Items.minecart}); + this.addRecipe(new ItemStack(Items.hopper_minecart, 1), new Object[] {"A", "B", 'A', Blocks.hopper, 'B', Items.minecart}); + this.addRecipe(new ItemStack(Items.boat, 1), new Object[] {"# #", "###", '#', Blocks.planks}); + this.addRecipe(new ItemStack(Items.bucket, 1), new Object[] {"# #", " # ", '#', Items.iron_ingot}); + this.addRecipe(new ItemStack(Items.flower_pot, 1), new Object[] {"# #", " # ", '#', Items.brick}); + this.addShapelessRecipe(new ItemStack(Items.flint_and_steel, 1), new Object[] {new ItemStack(Items.iron_ingot, 1), new ItemStack(Items.flint, 1)}); + this.addRecipe(new ItemStack(Items.bread, 1), new Object[] {"###", '#', Items.wheat}); + this.addRecipe(new ItemStack(Blocks.oak_stairs, 4), new Object[] {"# ", "## ", "###", '#', new ItemStack(Blocks.planks, 1, 0)}); + this.addRecipe(new ItemStack(Blocks.birch_stairs, 4), new Object[] {"# ", "## ", "###", '#', new ItemStack(Blocks.planks, 1, 2)}); + this.addRecipe(new ItemStack(Blocks.spruce_stairs, 4), new Object[] {"# ", "## ", "###", '#', new ItemStack(Blocks.planks, 1, 1)}); + this.addRecipe(new ItemStack(Blocks.jungle_stairs, 4), new Object[] {"# ", "## ", "###", '#', new ItemStack(Blocks.planks, 1, 3)}); + this.addRecipe(new ItemStack(Blocks.acacia_stairs, 4), new Object[] {"# ", "## ", "###", '#', new ItemStack(Blocks.planks, 1, 4)}); + this.addRecipe(new ItemStack(Blocks.dark_oak_stairs, 4), new Object[] {"# ", "## ", "###", '#', new ItemStack(Blocks.planks, 1, 5)}); + this.addRecipe(new ItemStack(Items.fishing_rod, 1), new Object[] {" #", " #X", "# X", '#', Items.stick, 'X', Items.string}); + this.addRecipe(new ItemStack(Items.carrot_on_a_stick, 1), new Object[] {"# ", " X", '#', Items.fishing_rod, 'X', Items.carrot}).func_92100_c(); + this.addRecipe(new ItemStack(Blocks.stone_stairs, 4), new Object[] {"# ", "## ", "###", '#', Blocks.cobblestone}); + this.addRecipe(new ItemStack(Blocks.brick_stairs, 4), new Object[] {"# ", "## ", "###", '#', Blocks.brick_block}); + this.addRecipe(new ItemStack(Blocks.stone_brick_stairs, 4), new Object[] {"# ", "## ", "###", '#', Blocks.stonebrick}); + this.addRecipe(new ItemStack(Blocks.nether_brick_stairs, 4), new Object[] {"# ", "## ", "###", '#', Blocks.nether_brick}); + this.addRecipe(new ItemStack(Blocks.sandstone_stairs, 4), new Object[] {"# ", "## ", "###", '#', Blocks.sandstone}); + this.addRecipe(new ItemStack(Blocks.quartz_stairs, 4), new Object[] {"# ", "## ", "###", '#', Blocks.quartz_block}); + this.addRecipe(new ItemStack(Items.painting, 1), new Object[] {"###", "#X#", "###", '#', Items.stick, 'X', Blocks.wool}); + this.addRecipe(new ItemStack(Items.item_frame, 1), new Object[] {"###", "#X#", "###", '#', Items.stick, 'X', Items.leather}); + this.addRecipe(new ItemStack(Items.golden_apple, 1, 0), new Object[] {"###", "#X#", "###", '#', Items.gold_ingot, 'X', Items.apple}); + this.addRecipe(new ItemStack(Items.golden_apple, 1, 1), new Object[] {"###", "#X#", "###", '#', Blocks.gold_block, 'X', Items.apple}); + this.addRecipe(new ItemStack(Items.golden_carrot, 1, 0), new Object[] {"###", "#X#", "###", '#', Items.gold_nugget, 'X', Items.carrot}); + this.addRecipe(new ItemStack(Items.speckled_melon, 1), new Object[] {"###", "#X#", "###", '#', Items.gold_nugget, 'X', Items.melon}); + this.addRecipe(new ItemStack(Blocks.lever, 1), new Object[] {"X", "#", '#', Blocks.cobblestone, 'X', Items.stick}); + this.addRecipe(new ItemStack(Blocks.tripwire_hook, 2), new Object[] {"I", "S", "#", '#', Blocks.planks, 'S', Items.stick, 'I', Items.iron_ingot}); + this.addRecipe(new ItemStack(Blocks.redstone_torch, 1), new Object[] {"X", "#", '#', Items.stick, 'X', Items.redstone}); + this.addRecipe(new ItemStack(Items.repeater, 1), new Object[] {"#X#", "III", '#', Blocks.redstone_torch, 'X', Items.redstone, 'I', Blocks.stone}); + this.addRecipe(new ItemStack(Items.comparator, 1), new Object[] {" # ", "#X#", "III", '#', Blocks.redstone_torch, 'X', Items.quartz, 'I', Blocks.stone}); + this.addRecipe(new ItemStack(Items.clock, 1), new Object[] {" # ", "#X#", " # ", '#', Items.gold_ingot, 'X', Items.redstone}); + this.addRecipe(new ItemStack(Items.compass, 1), new Object[] {" # ", "#X#", " # ", '#', Items.iron_ingot, 'X', Items.redstone}); + this.addRecipe(new ItemStack(Items.map, 1), new Object[] {"###", "#X#", "###", '#', Items.paper, 'X', Items.compass}); + this.addRecipe(new ItemStack(Blocks.stone_button, 1), new Object[] {"#", '#', Blocks.stone}); + this.addRecipe(new ItemStack(Blocks.wooden_button, 1), new Object[] {"#", '#', Blocks.planks}); + this.addRecipe(new ItemStack(Blocks.stone_pressure_plate, 1), new Object[] {"##", '#', Blocks.stone}); + this.addRecipe(new ItemStack(Blocks.wooden_pressure_plate, 1), new Object[] {"##", '#', Blocks.planks}); + this.addRecipe(new ItemStack(Blocks.heavy_weighted_pressure_plate, 1), new Object[] {"##", '#', Items.iron_ingot}); + this.addRecipe(new ItemStack(Blocks.light_weighted_pressure_plate, 1), new Object[] {"##", '#', Items.gold_ingot}); + this.addRecipe(new ItemStack(Blocks.dispenser, 1), new Object[] {"###", "#X#", "#R#", '#', Blocks.cobblestone, 'X', Items.bow, 'R', Items.redstone}); + this.addRecipe(new ItemStack(Blocks.dropper, 1), new Object[] {"###", "# #", "#R#", '#', Blocks.cobblestone, 'R', Items.redstone}); + this.addRecipe(new ItemStack(Blocks.piston, 1), new Object[] {"TTT", "#X#", "#R#", '#', Blocks.cobblestone, 'X', Items.iron_ingot, 'R', Items.redstone, 'T', Blocks.planks}); + this.addRecipe(new ItemStack(Blocks.sticky_piston, 1), new Object[] {"S", "P", 'S', Items.slime_ball, 'P', Blocks.piston}); + this.addRecipe(new ItemStack(Items.bed, 1), new Object[] {"###", "XXX", '#', Blocks.wool, 'X', Blocks.planks}); + this.addRecipe(new ItemStack(Blocks.enchanting_table, 1), new Object[] {" B ", "D#D", "###", '#', Blocks.obsidian, 'B', Items.book, 'D', Items.diamond}); + this.addRecipe(new ItemStack(Blocks.anvil, 1), new Object[] {"III", " i ", "iii", 'I', Blocks.iron_block, 'i', Items.iron_ingot}); + this.addShapelessRecipe(new ItemStack(Items.ender_eye, 1), new Object[] {Items.ender_pearl, Items.blaze_powder}); + this.addShapelessRecipe(new ItemStack(Items.fire_charge, 3), new Object[] {Items.gunpowder, Items.blaze_powder, Items.coal}); + this.addShapelessRecipe(new ItemStack(Items.fire_charge, 3), new Object[] {Items.gunpowder, Items.blaze_powder, new ItemStack(Items.coal, 1, 1)}); + this.addRecipe(new ItemStack(Blocks.daylight_detector), new Object[] {"GGG", "QQQ", "WWW", 'G', Blocks.glass, 'Q', Items.quartz, 'W', Blocks.wooden_slab}); + this.addRecipe(new ItemStack(Blocks.hopper), new Object[] {"I I", "ICI", " I ", 'I', Items.iron_ingot, 'C', Blocks.chest}); + Collections.sort(this.recipes, new Comparator() + { + private static final String __OBFID = "CL_00000091"; + public int compare(IRecipe par1IRecipe, IRecipe par2IRecipe) + { + return par1IRecipe instanceof ShapelessRecipes && par2IRecipe instanceof ShapedRecipes ? 1 : (par2IRecipe instanceof ShapelessRecipes && par1IRecipe instanceof ShapedRecipes ? -1 : (par2IRecipe.getRecipeSize() < par1IRecipe.getRecipeSize() ? -1 : (par2IRecipe.getRecipeSize() > par1IRecipe.getRecipeSize() ? 1 : 0))); + } + public int compare(Object par1Obj, Object par2Obj) + { + return this.compare((IRecipe)par1Obj, (IRecipe)par2Obj); + } + }); + } + + public ShapedRecipes addRecipe(ItemStack par1ItemStack, Object ... par2ArrayOfObj) + { + String s = ""; + int i = 0; + int j = 0; + int k = 0; + + if (par2ArrayOfObj[i] instanceof String[]) + { + String[] astring = (String[])((String[])par2ArrayOfObj[i++]); + + for (int l = 0; l < astring.length; ++l) + { + String s1 = astring[l]; + ++k; + j = s1.length(); + s = s + s1; + } + } + else + { + while (par2ArrayOfObj[i] instanceof String) + { + String s2 = (String)par2ArrayOfObj[i++]; + ++k; + j = s2.length(); + s = s + s2; + } + } + + HashMap hashmap; + + for (hashmap = new HashMap(); i < par2ArrayOfObj.length; i += 2) + { + Character character = (Character)par2ArrayOfObj[i]; + ItemStack itemstack1 = null; + + if (par2ArrayOfObj[i + 1] instanceof Item) + { + itemstack1 = new ItemStack((Item)par2ArrayOfObj[i + 1]); + } + else if (par2ArrayOfObj[i + 1] instanceof Block) + { + itemstack1 = new ItemStack((Block)par2ArrayOfObj[i + 1], 1, 32767); + } + else if (par2ArrayOfObj[i + 1] instanceof ItemStack) + { + itemstack1 = (ItemStack)par2ArrayOfObj[i + 1]; + } + + hashmap.put(character, itemstack1); + } + + ItemStack[] aitemstack = new ItemStack[j * k]; + + for (int i1 = 0; i1 < j * k; ++i1) + { + char c0 = s.charAt(i1); + + if (hashmap.containsKey(Character.valueOf(c0))) + { + aitemstack[i1] = ((ItemStack)hashmap.get(Character.valueOf(c0))).copy(); + } + else + { + aitemstack[i1] = null; + } + } + + ShapedRecipes shapedrecipes = new ShapedRecipes(j, k, aitemstack, par1ItemStack); + this.recipes.add(shapedrecipes); + return shapedrecipes; + } + + public void addShapelessRecipe(ItemStack par1ItemStack, Object ... par2ArrayOfObj) + { + ArrayList arraylist = new ArrayList(); + Object[] aobject = par2ArrayOfObj; + int i = par2ArrayOfObj.length; + + for (int j = 0; j < i; ++j) + { + Object object1 = aobject[j]; + + if (object1 instanceof ItemStack) + { + arraylist.add(((ItemStack)object1).copy()); + } + else if (object1 instanceof Item) + { + arraylist.add(new ItemStack((Item)object1)); + } + else + { + if (!(object1 instanceof Block)) + { + throw new RuntimeException("Invalid shapeless recipy!"); + } + + arraylist.add(new ItemStack((Block)object1)); + } + } + + this.recipes.add(new ShapelessRecipes(par1ItemStack, arraylist)); + } + + public ItemStack findMatchingRecipe(InventoryCrafting par1InventoryCrafting, World par2World) + { + int i = 0; + ItemStack itemstack = null; + ItemStack itemstack1 = null; + int j; + + for (j = 0; j < par1InventoryCrafting.getSizeInventory(); ++j) + { + ItemStack itemstack2 = par1InventoryCrafting.getStackInSlot(j); + + if (itemstack2 != null) + { + if (i == 0) + { + itemstack = itemstack2; + } + + if (i == 1) + { + itemstack1 = itemstack2; + } + + ++i; + } + } + + if (i == 2 && itemstack.getItem() == itemstack1.getItem() && itemstack.stackSize == 1 && itemstack1.stackSize == 1 && itemstack.getItem().isRepairable()) + { + Item item = itemstack.getItem(); + int j1 = item.getMaxDamage() - itemstack.getItemDamageForDisplay(); + int k = item.getMaxDamage() - itemstack1.getItemDamageForDisplay(); + int l = j1 + k + item.getMaxDamage() * 5 / 100; + int i1 = item.getMaxDamage() - l; + + if (i1 < 0) + { + i1 = 0; + } + + return new ItemStack(itemstack.getItem(), 1, i1); + } + else + { + for (j = 0; j < this.recipes.size(); ++j) + { + IRecipe irecipe = (IRecipe)this.recipes.get(j); + + if (irecipe.matches(par1InventoryCrafting, par2World)) + { + return irecipe.getCraftingResult(par1InventoryCrafting); + } + } + + return null; + } + } + + public List getRecipeList() + { + return this.recipes; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/crafting/FurnaceRecipes.java b/src/main/java/net/minecraft/item/crafting/FurnaceRecipes.java new file mode 100644 index 0000000..2dc87e1 --- /dev/null +++ b/src/main/java/net/minecraft/item/crafting/FurnaceRecipes.java @@ -0,0 +1,129 @@ +package net.minecraft.item.crafting; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemFishFood; +import net.minecraft.item.ItemStack; + +public class FurnaceRecipes +{ + private static final FurnaceRecipes smeltingBase = new FurnaceRecipes(); + private Map smeltingList = new HashMap(); + private Map experienceList = new HashMap(); + private static final String __OBFID = "CL_00000085"; + + public static FurnaceRecipes smelting() + { + return smeltingBase; + } + + private FurnaceRecipes() + { + this.func_151393_a(Blocks.iron_ore, new ItemStack(Items.iron_ingot), 0.7F); + this.func_151393_a(Blocks.gold_ore, new ItemStack(Items.gold_ingot), 1.0F); + this.func_151393_a(Blocks.diamond_ore, new ItemStack(Items.diamond), 1.0F); + this.func_151393_a(Blocks.sand, new ItemStack(Blocks.glass), 0.1F); + this.func_151396_a(Items.porkchop, new ItemStack(Items.cooked_porkchop), 0.35F); + this.func_151396_a(Items.beef, new ItemStack(Items.cooked_beef), 0.35F); + this.func_151396_a(Items.chicken, new ItemStack(Items.cooked_chicken), 0.35F); + this.func_151393_a(Blocks.cobblestone, new ItemStack(Blocks.stone), 0.1F); + this.func_151396_a(Items.clay_ball, new ItemStack(Items.brick), 0.3F); + this.func_151393_a(Blocks.clay, new ItemStack(Blocks.hardened_clay), 0.35F); + this.func_151393_a(Blocks.cactus, new ItemStack(Items.dye, 1, 2), 0.2F); + this.func_151393_a(Blocks.log, new ItemStack(Items.coal, 1, 1), 0.15F); + this.func_151393_a(Blocks.log2, new ItemStack(Items.coal, 1, 1), 0.15F); + this.func_151393_a(Blocks.emerald_ore, new ItemStack(Items.emerald), 1.0F); + this.func_151396_a(Items.potato, new ItemStack(Items.baked_potato), 0.35F); + this.func_151393_a(Blocks.netherrack, new ItemStack(Items.netherbrick), 0.1F); + ItemFishFood.FishType[] afishtype = ItemFishFood.FishType.values(); + int i = afishtype.length; + + for (int j = 0; j < i; ++j) + { + ItemFishFood.FishType fishtype = afishtype[j]; + + if (fishtype.func_150973_i()) + { + this.func_151394_a(new ItemStack(Items.fish, 1, fishtype.func_150976_a()), new ItemStack(Items.cooked_fished, 1, fishtype.func_150976_a()), 0.35F); + } + } + + this.func_151393_a(Blocks.coal_ore, new ItemStack(Items.coal), 0.1F); + this.func_151393_a(Blocks.redstone_ore, new ItemStack(Items.redstone), 0.7F); + this.func_151393_a(Blocks.lapis_ore, new ItemStack(Items.dye, 1, 4), 0.2F); + this.func_151393_a(Blocks.quartz_ore, new ItemStack(Items.quartz), 0.2F); + } + + public void func_151393_a(Block p_151393_1_, ItemStack p_151393_2_, float p_151393_3_) + { + this.func_151396_a(Item.getItemFromBlock(p_151393_1_), p_151393_2_, p_151393_3_); + } + + public void func_151396_a(Item p_151396_1_, ItemStack p_151396_2_, float p_151396_3_) + { + this.func_151394_a(new ItemStack(p_151396_1_, 1, 32767), p_151396_2_, p_151396_3_); + } + + public void func_151394_a(ItemStack p_151394_1_, ItemStack p_151394_2_, float p_151394_3_) + { + this.smeltingList.put(p_151394_1_, p_151394_2_); + this.experienceList.put(p_151394_2_, Float.valueOf(p_151394_3_)); + } + + public ItemStack getSmeltingResult(ItemStack p_151395_1_) + { + Iterator iterator = this.smeltingList.entrySet().iterator(); + Entry entry; + + do + { + if (!iterator.hasNext()) + { + return null; + } + + entry = (Entry)iterator.next(); + } + while (!this.func_151397_a(p_151395_1_, (ItemStack)entry.getKey())); + + return (ItemStack)entry.getValue(); + } + + private boolean func_151397_a(ItemStack p_151397_1_, ItemStack p_151397_2_) + { + return p_151397_2_.getItem() == p_151397_1_.getItem() && (p_151397_2_.getItemDamage() == 32767 || p_151397_2_.getItemDamage() == p_151397_1_.getItemDamage()); + } + + public Map getSmeltingList() + { + return this.smeltingList; + } + + public float func_151398_b(ItemStack p_151398_1_) + { + float ret = p_151398_1_.getItem().getSmeltingExperience(p_151398_1_); + if (ret != -1) return ret; + + Iterator iterator = this.experienceList.entrySet().iterator(); + Entry entry; + + do + { + if (!iterator.hasNext()) + { + return 0.0F; + } + + entry = (Entry)iterator.next(); + } + while (!this.func_151397_a(p_151398_1_, (ItemStack)entry.getKey())); + + return ((Float)entry.getValue()).floatValue(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/crafting/IRecipe.java b/src/main/java/net/minecraft/item/crafting/IRecipe.java new file mode 100644 index 0000000..5e899f3 --- /dev/null +++ b/src/main/java/net/minecraft/item/crafting/IRecipe.java @@ -0,0 +1,16 @@ +package net.minecraft.item.crafting; + +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public interface IRecipe +{ + boolean matches(InventoryCrafting var1, World var2); + + ItemStack getCraftingResult(InventoryCrafting var1); + + int getRecipeSize(); + + ItemStack getRecipeOutput(); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/crafting/RecipeBookCloning.java b/src/main/java/net/minecraft/item/crafting/RecipeBookCloning.java new file mode 100644 index 0000000..1beb86d --- /dev/null +++ b/src/main/java/net/minecraft/item/crafting/RecipeBookCloning.java @@ -0,0 +1,107 @@ +package net.minecraft.item.crafting; + +import net.minecraft.init.Items; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +public class RecipeBookCloning implements IRecipe +{ + private static final String __OBFID = "CL_00000081"; + + public boolean matches(InventoryCrafting par1InventoryCrafting, World par2World) + { + int i = 0; + ItemStack itemstack = null; + + for (int j = 0; j < par1InventoryCrafting.getSizeInventory(); ++j) + { + ItemStack itemstack1 = par1InventoryCrafting.getStackInSlot(j); + + if (itemstack1 != null) + { + if (itemstack1.getItem() == Items.written_book) + { + if (itemstack != null) + { + return false; + } + + itemstack = itemstack1; + } + else + { + if (itemstack1.getItem() != Items.writable_book) + { + return false; + } + + ++i; + } + } + } + + return itemstack != null && i > 0; + } + + public ItemStack getCraftingResult(InventoryCrafting par1InventoryCrafting) + { + int i = 0; + ItemStack itemstack = null; + + for (int j = 0; j < par1InventoryCrafting.getSizeInventory(); ++j) + { + ItemStack itemstack1 = par1InventoryCrafting.getStackInSlot(j); + + if (itemstack1 != null) + { + if (itemstack1.getItem() == Items.written_book) + { + if (itemstack != null) + { + return null; + } + + itemstack = itemstack1; + } + else + { + if (itemstack1.getItem() != Items.writable_book) + { + return null; + } + + ++i; + } + } + } + + if (itemstack != null && i >= 1) + { + ItemStack itemstack2 = new ItemStack(Items.written_book, i + 1); + itemstack2.setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); + + if (itemstack.hasDisplayName()) + { + itemstack2.setStackDisplayName(itemstack.getDisplayName()); + } + + return itemstack2; + } + else + { + return null; + } + } + + public int getRecipeSize() + { + return 9; + } + + public ItemStack getRecipeOutput() + { + return null; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/crafting/RecipeFireworks.java b/src/main/java/net/minecraft/item/crafting/RecipeFireworks.java new file mode 100644 index 0000000..ab549a1 --- /dev/null +++ b/src/main/java/net/minecraft/item/crafting/RecipeFireworks.java @@ -0,0 +1,247 @@ +package net.minecraft.item.crafting; + +import java.util.ArrayList; +import net.minecraft.init.Items; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.ItemDye; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.world.World; + +public class RecipeFireworks implements IRecipe +{ + private ItemStack field_92102_a; + private static final String __OBFID = "CL_00000083"; + + public boolean matches(InventoryCrafting par1InventoryCrafting, World par2World) + { + this.field_92102_a = null; + int i = 0; + int j = 0; + int k = 0; + int l = 0; + int i1 = 0; + int j1 = 0; + + for (int k1 = 0; k1 < par1InventoryCrafting.getSizeInventory(); ++k1) + { + ItemStack itemstack = par1InventoryCrafting.getStackInSlot(k1); + + if (itemstack != null) + { + if (itemstack.getItem() == Items.gunpowder) + { + ++j; + } + else if (itemstack.getItem() == Items.firework_charge) + { + ++l; + } + else if (itemstack.getItem() == Items.dye) + { + ++k; + } + else if (itemstack.getItem() == Items.paper) + { + ++i; + } + else if (itemstack.getItem() == Items.glowstone_dust) + { + ++i1; + } + else if (itemstack.getItem() == Items.diamond) + { + ++i1; + } + else if (itemstack.getItem() == Items.fire_charge) + { + ++j1; + } + else if (itemstack.getItem() == Items.feather) + { + ++j1; + } + else if (itemstack.getItem() == Items.gold_nugget) + { + ++j1; + } + else + { + if (itemstack.getItem() != Items.skull) + { + return false; + } + + ++j1; + } + } + } + + i1 += k + j1; + + if (j <= 3 && i <= 1) + { + NBTTagCompound nbttagcompound; + NBTTagCompound nbttagcompound1; + + if (j >= 1 && i == 1 && i1 == 0) + { + this.field_92102_a = new ItemStack(Items.fireworks); + + nbttagcompound = new NBTTagCompound(); + if (l > 0) + { + nbttagcompound1 = new NBTTagCompound(); + NBTTagList nbttaglist = new NBTTagList(); + + for (int k2 = 0; k2 < par1InventoryCrafting.getSizeInventory(); ++k2) + { + ItemStack itemstack3 = par1InventoryCrafting.getStackInSlot(k2); + + if (itemstack3 != null && itemstack3.getItem() == Items.firework_charge && itemstack3.hasTagCompound() && itemstack3.getTagCompound().hasKey("Explosion", 10)) + { + nbttaglist.appendTag(itemstack3.getTagCompound().getCompoundTag("Explosion")); + } + } + + nbttagcompound1.setTag("Explosions", nbttaglist); + nbttagcompound1.setByte("Flight", (byte)j); + nbttagcompound.setTag("Fireworks", nbttagcompound1); + } + this.field_92102_a.setTagCompound(nbttagcompound); //Forge BugFix: NPE Protection + + return true; + } + else if (j == 1 && i == 0 && l == 0 && k > 0 && j1 <= 1) + { + this.field_92102_a = new ItemStack(Items.firework_charge); + nbttagcompound = new NBTTagCompound(); + nbttagcompound1 = new NBTTagCompound(); + byte b0 = 0; + ArrayList arraylist = new ArrayList(); + + for (int l1 = 0; l1 < par1InventoryCrafting.getSizeInventory(); ++l1) + { + ItemStack itemstack2 = par1InventoryCrafting.getStackInSlot(l1); + + if (itemstack2 != null) + { + if (itemstack2.getItem() == Items.dye) + { + arraylist.add(Integer.valueOf(ItemDye.field_150922_c[itemstack2.getItemDamage()])); + } + else if (itemstack2.getItem() == Items.glowstone_dust) + { + nbttagcompound1.setBoolean("Flicker", true); + } + else if (itemstack2.getItem() == Items.diamond) + { + nbttagcompound1.setBoolean("Trail", true); + } + else if (itemstack2.getItem() == Items.fire_charge) + { + b0 = 1; + } + else if (itemstack2.getItem() == Items.feather) + { + b0 = 4; + } + else if (itemstack2.getItem() == Items.gold_nugget) + { + b0 = 2; + } + else if (itemstack2.getItem() == Items.skull) + { + b0 = 3; + } + } + } + + int[] aint1 = new int[arraylist.size()]; + + for (int l2 = 0; l2 < aint1.length; ++l2) + { + aint1[l2] = ((Integer)arraylist.get(l2)).intValue(); + } + + nbttagcompound1.setIntArray("Colors", aint1); + nbttagcompound1.setByte("Type", b0); + nbttagcompound.setTag("Explosion", nbttagcompound1); + this.field_92102_a.setTagCompound(nbttagcompound); + return true; + } + else if (j == 0 && i == 0 && l == 1 && k > 0 && k == i1) + { + ArrayList arraylist1 = new ArrayList(); + + for (int i2 = 0; i2 < par1InventoryCrafting.getSizeInventory(); ++i2) + { + ItemStack itemstack1 = par1InventoryCrafting.getStackInSlot(i2); + + if (itemstack1 != null) + { + if (itemstack1.getItem() == Items.dye) + { + arraylist1.add(Integer.valueOf(ItemDye.field_150922_c[itemstack1.getItemDamage()])); + } + else if (itemstack1.getItem() == Items.firework_charge) + { + this.field_92102_a = itemstack1.copy(); + this.field_92102_a.stackSize = 1; + } + } + } + + int[] aint = new int[arraylist1.size()]; + + for (int j2 = 0; j2 < aint.length; ++j2) + { + aint[j2] = ((Integer)arraylist1.get(j2)).intValue(); + } + + if (this.field_92102_a != null && this.field_92102_a.hasTagCompound()) + { + NBTTagCompound nbttagcompound2 = this.field_92102_a.getTagCompound().getCompoundTag("Explosion"); + + if (nbttagcompound2 == null) + { + return false; + } + else + { + nbttagcompound2.setIntArray("FadeColors", aint); + return true; + } + } + else + { + return false; + } + } + else + { + return false; + } + } + else + { + return false; + } + } + + public ItemStack getCraftingResult(InventoryCrafting par1InventoryCrafting) + { + return this.field_92102_a.copy(); + } + + public int getRecipeSize() + { + return 10; + } + + public ItemStack getRecipeOutput() + { + return this.field_92102_a; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/crafting/RecipesArmor.java b/src/main/java/net/minecraft/item/crafting/RecipesArmor.java new file mode 100644 index 0000000..10869d2 --- /dev/null +++ b/src/main/java/net/minecraft/item/crafting/RecipesArmor.java @@ -0,0 +1,32 @@ +package net.minecraft.item.crafting; + +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +public class RecipesArmor +{ + private String[][] recipePatterns = new String[][] {{"XXX", "X X"}, {"X X", "XXX", "XXX"}, {"XXX", "X X", "X X"}, {"X X", "X X"}}; + private Object[][] recipeItems; + private static final String __OBFID = "CL_00000080"; + + public RecipesArmor() + { + this.recipeItems = new Object[][] {{Items.leather, Blocks.fire, Items.iron_ingot, Items.diamond, Items.gold_ingot}, {Items.leather_helmet, Items.chainmail_helmet, Items.iron_helmet, Items.diamond_helmet, Items.golden_helmet}, {Items.leather_chestplate, Items.chainmail_chestplate, Items.iron_chestplate, Items.diamond_chestplate, Items.golden_chestplate}, {Items.leather_leggings, Items.chainmail_leggings, Items.iron_leggings, Items.diamond_leggings, Items.golden_leggings}, {Items.leather_boots, Items.chainmail_boots, Items.iron_boots, Items.diamond_boots, Items.golden_boots}}; + } + + public void addRecipes(CraftingManager par1CraftingManager) + { + for (int i = 0; i < this.recipeItems[0].length; ++i) + { + Object object = this.recipeItems[0][i]; + + for (int j = 0; j < this.recipeItems.length - 1; ++j) + { + Item item = (Item)this.recipeItems[j + 1][i]; + par1CraftingManager.addRecipe(new ItemStack(item), new Object[] {this.recipePatterns[j], 'X', object}); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/crafting/RecipesArmorDyes.java b/src/main/java/net/minecraft/item/crafting/RecipesArmorDyes.java new file mode 100644 index 0000000..85026ac --- /dev/null +++ b/src/main/java/net/minecraft/item/crafting/RecipesArmorDyes.java @@ -0,0 +1,147 @@ +package net.minecraft.item.crafting; + +import java.util.ArrayList; +import net.minecraft.block.BlockColored; +import net.minecraft.entity.passive.EntitySheep; +import net.minecraft.init.Items; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.ItemArmor; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class RecipesArmorDyes implements IRecipe +{ + private static final String __OBFID = "CL_00000079"; + + public boolean matches(InventoryCrafting par1InventoryCrafting, World par2World) + { + ItemStack itemstack = null; + ArrayList arraylist = new ArrayList(); + + for (int i = 0; i < par1InventoryCrafting.getSizeInventory(); ++i) + { + ItemStack itemstack1 = par1InventoryCrafting.getStackInSlot(i); + + if (itemstack1 != null) + { + if (itemstack1.getItem() instanceof ItemArmor) + { + ItemArmor itemarmor = (ItemArmor)itemstack1.getItem(); + + if (itemarmor.getArmorMaterial() != ItemArmor.ArmorMaterial.CLOTH || itemstack != null) + { + return false; + } + + itemstack = itemstack1; + } + else + { + if (itemstack1.getItem() != Items.dye) + { + return false; + } + + arraylist.add(itemstack1); + } + } + } + + return itemstack != null && !arraylist.isEmpty(); + } + + public ItemStack getCraftingResult(InventoryCrafting par1InventoryCrafting) + { + ItemStack itemstack = null; + int[] aint = new int[3]; + int i = 0; + int j = 0; + ItemArmor itemarmor = null; + int k; + int l; + float f; + float f1; + int l1; + + for (k = 0; k < par1InventoryCrafting.getSizeInventory(); ++k) + { + ItemStack itemstack1 = par1InventoryCrafting.getStackInSlot(k); + + if (itemstack1 != null) + { + if (itemstack1.getItem() instanceof ItemArmor) + { + itemarmor = (ItemArmor)itemstack1.getItem(); + + if (itemarmor.getArmorMaterial() != ItemArmor.ArmorMaterial.CLOTH || itemstack != null) + { + return null; + } + + itemstack = itemstack1.copy(); + itemstack.stackSize = 1; + + if (itemarmor.hasColor(itemstack1)) + { + l = itemarmor.getColor(itemstack); + f = (float)(l >> 16 & 255) / 255.0F; + f1 = (float)(l >> 8 & 255) / 255.0F; + float f2 = (float)(l & 255) / 255.0F; + i = (int)((float)i + Math.max(f, Math.max(f1, f2)) * 255.0F); + aint[0] = (int)((float)aint[0] + f * 255.0F); + aint[1] = (int)((float)aint[1] + f1 * 255.0F); + aint[2] = (int)((float)aint[2] + f2 * 255.0F); + ++j; + } + } + else + { + if (itemstack1.getItem() != Items.dye) + { + return null; + } + + float[] afloat = EntitySheep.fleeceColorTable[BlockColored.func_150032_b(itemstack1.getItemDamage())]; + int j1 = (int)(afloat[0] * 255.0F); + int k1 = (int)(afloat[1] * 255.0F); + l1 = (int)(afloat[2] * 255.0F); + i += Math.max(j1, Math.max(k1, l1)); + aint[0] += j1; + aint[1] += k1; + aint[2] += l1; + ++j; + } + } + } + + if (itemarmor == null) + { + return null; + } + else + { + k = aint[0] / j; + int i1 = aint[1] / j; + l = aint[2] / j; + f = (float)i / (float)j; + f1 = (float)Math.max(k, Math.max(i1, l)); + k = (int)((float)k * f / f1); + i1 = (int)((float)i1 * f / f1); + l = (int)((float)l * f / f1); + l1 = (k << 8) + i1; + l1 = (l1 << 8) + l; + itemarmor.func_82813_b(itemstack, l1); + return itemstack; + } + } + + public int getRecipeSize() + { + return 10; + } + + public ItemStack getRecipeOutput() + { + return null; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/crafting/RecipesCrafting.java b/src/main/java/net/minecraft/item/crafting/RecipesCrafting.java new file mode 100644 index 0000000..01ce10b --- /dev/null +++ b/src/main/java/net/minecraft/item/crafting/RecipesCrafting.java @@ -0,0 +1,30 @@ +package net.minecraft.item.crafting; + +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; + +public class RecipesCrafting +{ + private static final String __OBFID = "CL_00000095"; + + public void addRecipes(CraftingManager par1CraftingManager) + { + par1CraftingManager.addRecipe(new ItemStack(Blocks.chest), new Object[] {"###", "# #", "###", '#', Blocks.planks}); + par1CraftingManager.addRecipe(new ItemStack(Blocks.trapped_chest), new Object[] {"#-", '#', Blocks.chest, '-', Blocks.tripwire_hook}); + par1CraftingManager.addRecipe(new ItemStack(Blocks.ender_chest), new Object[] {"###", "#E#", "###", '#', Blocks.obsidian, 'E', Items.ender_eye}); + par1CraftingManager.addRecipe(new ItemStack(Blocks.furnace), new Object[] {"###", "# #", "###", '#', Blocks.cobblestone}); + par1CraftingManager.addRecipe(new ItemStack(Blocks.crafting_table), new Object[] {"##", "##", '#', Blocks.planks}); + par1CraftingManager.addRecipe(new ItemStack(Blocks.sandstone), new Object[] {"##", "##", '#', new ItemStack(Blocks.sand, 1, 0)}); + par1CraftingManager.addRecipe(new ItemStack(Blocks.sandstone, 4, 2), new Object[] {"##", "##", '#', Blocks.sandstone}); + par1CraftingManager.addRecipe(new ItemStack(Blocks.sandstone, 1, 1), new Object[] {"#", "#", '#', new ItemStack(Blocks.stone_slab, 1, 1)}); + par1CraftingManager.addRecipe(new ItemStack(Blocks.quartz_block, 1, 1), new Object[] {"#", "#", '#', new ItemStack(Blocks.stone_slab, 1, 7)}); + par1CraftingManager.addRecipe(new ItemStack(Blocks.quartz_block, 2, 2), new Object[] {"#", "#", '#', new ItemStack(Blocks.quartz_block, 1, 0)}); + par1CraftingManager.addRecipe(new ItemStack(Blocks.stonebrick, 4), new Object[] {"##", "##", '#', Blocks.stone}); + par1CraftingManager.addRecipe(new ItemStack(Blocks.iron_bars, 16), new Object[] {"###", "###", '#', Items.iron_ingot}); + par1CraftingManager.addRecipe(new ItemStack(Blocks.glass_pane, 16), new Object[] {"###", "###", '#', Blocks.glass}); + par1CraftingManager.addRecipe(new ItemStack(Blocks.redstone_lamp, 1), new Object[] {" R ", "RGR", " R ", 'R', Items.redstone, 'G', Blocks.glowstone}); + par1CraftingManager.addRecipe(new ItemStack(Blocks.beacon, 1), new Object[] {"GGG", "GSG", "OOO", 'G', Blocks.glass, 'S', Items.nether_star, 'O', Blocks.obsidian}); + par1CraftingManager.addRecipe(new ItemStack(Blocks.nether_brick, 1), new Object[] {"NN", "NN", 'N', Items.netherbrick}); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/crafting/RecipesDyes.java b/src/main/java/net/minecraft/item/crafting/RecipesDyes.java new file mode 100644 index 0000000..47de094 --- /dev/null +++ b/src/main/java/net/minecraft/item/crafting/RecipesDyes.java @@ -0,0 +1,58 @@ +package net.minecraft.item.crafting; + +import net.minecraft.block.BlockColored; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +public class RecipesDyes +{ + private static final String __OBFID = "CL_00000082"; + + public void addRecipes(CraftingManager par1CraftingManager) + { + int i; + + for (i = 0; i < 16; ++i) + { + par1CraftingManager.addShapelessRecipe(new ItemStack(Blocks.wool, 1, BlockColored.func_150031_c(i)), new Object[] {new ItemStack(Items.dye, 1, i), new ItemStack(Item.getItemFromBlock(Blocks.wool), 1, 0)}); + par1CraftingManager.addRecipe(new ItemStack(Blocks.stained_hardened_clay, 8, BlockColored.func_150031_c(i)), new Object[] {"###", "#X#", "###", '#', new ItemStack(Blocks.hardened_clay), 'X', new ItemStack(Items.dye, 1, i)}); + par1CraftingManager.addRecipe(new ItemStack(Blocks.stained_glass, 8, BlockColored.func_150031_c(i)), new Object[] {"###", "#X#", "###", '#', new ItemStack(Blocks.glass), 'X', new ItemStack(Items.dye, 1, i)}); + par1CraftingManager.addRecipe(new ItemStack(Blocks.stained_glass_pane, 16, i), new Object[] {"###", "###", '#', new ItemStack(Blocks.stained_glass, 1, i)}); + } + + par1CraftingManager.addShapelessRecipe(new ItemStack(Items.dye, 1, 11), new Object[] {new ItemStack(Blocks.yellow_flower, 1, 0)}); + par1CraftingManager.addShapelessRecipe(new ItemStack(Items.dye, 1, 1), new Object[] {new ItemStack(Blocks.red_flower, 1, 0)}); + par1CraftingManager.addShapelessRecipe(new ItemStack(Items.dye, 3, 15), new Object[] {Items.bone}); + par1CraftingManager.addShapelessRecipe(new ItemStack(Items.dye, 2, 9), new Object[] {new ItemStack(Items.dye, 1, 1), new ItemStack(Items.dye, 1, 15)}); + par1CraftingManager.addShapelessRecipe(new ItemStack(Items.dye, 2, 14), new Object[] {new ItemStack(Items.dye, 1, 1), new ItemStack(Items.dye, 1, 11)}); + par1CraftingManager.addShapelessRecipe(new ItemStack(Items.dye, 2, 10), new Object[] {new ItemStack(Items.dye, 1, 2), new ItemStack(Items.dye, 1, 15)}); + par1CraftingManager.addShapelessRecipe(new ItemStack(Items.dye, 2, 8), new Object[] {new ItemStack(Items.dye, 1, 0), new ItemStack(Items.dye, 1, 15)}); + par1CraftingManager.addShapelessRecipe(new ItemStack(Items.dye, 2, 7), new Object[] {new ItemStack(Items.dye, 1, 8), new ItemStack(Items.dye, 1, 15)}); + par1CraftingManager.addShapelessRecipe(new ItemStack(Items.dye, 3, 7), new Object[] {new ItemStack(Items.dye, 1, 0), new ItemStack(Items.dye, 1, 15), new ItemStack(Items.dye, 1, 15)}); + par1CraftingManager.addShapelessRecipe(new ItemStack(Items.dye, 2, 12), new Object[] {new ItemStack(Items.dye, 1, 4), new ItemStack(Items.dye, 1, 15)}); + par1CraftingManager.addShapelessRecipe(new ItemStack(Items.dye, 2, 6), new Object[] {new ItemStack(Items.dye, 1, 4), new ItemStack(Items.dye, 1, 2)}); + par1CraftingManager.addShapelessRecipe(new ItemStack(Items.dye, 2, 5), new Object[] {new ItemStack(Items.dye, 1, 4), new ItemStack(Items.dye, 1, 1)}); + par1CraftingManager.addShapelessRecipe(new ItemStack(Items.dye, 2, 13), new Object[] {new ItemStack(Items.dye, 1, 5), new ItemStack(Items.dye, 1, 9)}); + par1CraftingManager.addShapelessRecipe(new ItemStack(Items.dye, 3, 13), new Object[] {new ItemStack(Items.dye, 1, 4), new ItemStack(Items.dye, 1, 1), new ItemStack(Items.dye, 1, 9)}); + par1CraftingManager.addShapelessRecipe(new ItemStack(Items.dye, 4, 13), new Object[] {new ItemStack(Items.dye, 1, 4), new ItemStack(Items.dye, 1, 1), new ItemStack(Items.dye, 1, 1), new ItemStack(Items.dye, 1, 15)}); + par1CraftingManager.addShapelessRecipe(new ItemStack(Items.dye, 1, 12), new Object[] {new ItemStack(Blocks.red_flower, 1, 1)}); + par1CraftingManager.addShapelessRecipe(new ItemStack(Items.dye, 1, 13), new Object[] {new ItemStack(Blocks.red_flower, 1, 2)}); + par1CraftingManager.addShapelessRecipe(new ItemStack(Items.dye, 1, 7), new Object[] {new ItemStack(Blocks.red_flower, 1, 3)}); + par1CraftingManager.addShapelessRecipe(new ItemStack(Items.dye, 1, 1), new Object[] {new ItemStack(Blocks.red_flower, 1, 4)}); + par1CraftingManager.addShapelessRecipe(new ItemStack(Items.dye, 1, 14), new Object[] {new ItemStack(Blocks.red_flower, 1, 5)}); + par1CraftingManager.addShapelessRecipe(new ItemStack(Items.dye, 1, 7), new Object[] {new ItemStack(Blocks.red_flower, 1, 6)}); + par1CraftingManager.addShapelessRecipe(new ItemStack(Items.dye, 1, 9), new Object[] {new ItemStack(Blocks.red_flower, 1, 7)}); + par1CraftingManager.addShapelessRecipe(new ItemStack(Items.dye, 1, 7), new Object[] {new ItemStack(Blocks.red_flower, 1, 8)}); + par1CraftingManager.addShapelessRecipe(new ItemStack(Items.dye, 2, 11), new Object[] {new ItemStack(Blocks.double_plant, 1, 0)}); + par1CraftingManager.addShapelessRecipe(new ItemStack(Items.dye, 2, 13), new Object[] {new ItemStack(Blocks.double_plant, 1, 1)}); + par1CraftingManager.addShapelessRecipe(new ItemStack(Items.dye, 2, 1), new Object[] {new ItemStack(Blocks.double_plant, 1, 4)}); + par1CraftingManager.addShapelessRecipe(new ItemStack(Items.dye, 2, 9), new Object[] {new ItemStack(Blocks.double_plant, 1, 5)}); + + for (i = 0; i < 16; ++i) + { + par1CraftingManager.addRecipe(new ItemStack(Blocks.carpet, 3, i), new Object[] {"##", '#', new ItemStack(Blocks.wool, 1, i)}); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/crafting/RecipesFood.java b/src/main/java/net/minecraft/item/crafting/RecipesFood.java new file mode 100644 index 0000000..db6f5b9 --- /dev/null +++ b/src/main/java/net/minecraft/item/crafting/RecipesFood.java @@ -0,0 +1,23 @@ +package net.minecraft.item.crafting; + +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; + +public class RecipesFood +{ + private static final String __OBFID = "CL_00000084"; + + public void addRecipes(CraftingManager par1CraftingManager) + { + par1CraftingManager.addShapelessRecipe(new ItemStack(Items.mushroom_stew), new Object[] {Blocks.brown_mushroom, Blocks.red_mushroom, Items.bowl}); + par1CraftingManager.addRecipe(new ItemStack(Items.cookie, 8), new Object[] {"#X#", 'X', new ItemStack(Items.dye, 1, 3), '#', Items.wheat}); + par1CraftingManager.addRecipe(new ItemStack(Blocks.melon_block), new Object[] {"MMM", "MMM", "MMM", 'M', Items.melon}); + par1CraftingManager.addRecipe(new ItemStack(Items.melon_seeds), new Object[] {"M", 'M', Items.melon}); + par1CraftingManager.addRecipe(new ItemStack(Items.pumpkin_seeds, 4), new Object[] {"M", 'M', Blocks.pumpkin}); + par1CraftingManager.addShapelessRecipe(new ItemStack(Items.pumpkin_pie), new Object[] {Blocks.pumpkin, Items.sugar, Items.egg}); + par1CraftingManager.addShapelessRecipe(new ItemStack(Items.fermented_spider_eye), new Object[] {Items.spider_eye, Blocks.brown_mushroom, Items.sugar}); + par1CraftingManager.addShapelessRecipe(new ItemStack(Items.blaze_powder, 2), new Object[] {Items.blaze_rod}); + par1CraftingManager.addShapelessRecipe(new ItemStack(Items.magma_cream), new Object[] {Items.blaze_powder, Items.slime_ball}); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/crafting/RecipesIngots.java b/src/main/java/net/minecraft/item/crafting/RecipesIngots.java new file mode 100644 index 0000000..68f2fbe --- /dev/null +++ b/src/main/java/net/minecraft/item/crafting/RecipesIngots.java @@ -0,0 +1,31 @@ +package net.minecraft.item.crafting; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; + +public class RecipesIngots +{ + private Object[][] recipeItems; + private static final String __OBFID = "CL_00000089"; + + public RecipesIngots() + { + this.recipeItems = new Object[][] {{Blocks.gold_block, new ItemStack(Items.gold_ingot, 9)}, {Blocks.iron_block, new ItemStack(Items.iron_ingot, 9)}, {Blocks.diamond_block, new ItemStack(Items.diamond, 9)}, {Blocks.emerald_block, new ItemStack(Items.emerald, 9)}, {Blocks.lapis_block, new ItemStack(Items.dye, 9, 4)}, {Blocks.redstone_block, new ItemStack(Items.redstone, 9)}, {Blocks.coal_block, new ItemStack(Items.coal, 9, 0)}, {Blocks.hay_block, new ItemStack(Items.wheat, 9)}}; + } + + public void addRecipes(CraftingManager par1CraftingManager) + { + for (int i = 0; i < this.recipeItems.length; ++i) + { + Block block = (Block)this.recipeItems[i][0]; + ItemStack itemstack = (ItemStack)this.recipeItems[i][1]; + par1CraftingManager.addRecipe(new ItemStack(block), new Object[] {"###", "###", "###", '#', itemstack}); + par1CraftingManager.addRecipe(itemstack, new Object[] {"#", '#', block}); + } + + par1CraftingManager.addRecipe(new ItemStack(Items.gold_ingot), new Object[] {"###", "###", "###", '#', Items.gold_nugget}); + par1CraftingManager.addRecipe(new ItemStack(Items.gold_nugget, 9), new Object[] {"#", '#', Items.gold_ingot}); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/crafting/RecipesMapCloning.java b/src/main/java/net/minecraft/item/crafting/RecipesMapCloning.java new file mode 100644 index 0000000..776eb2b --- /dev/null +++ b/src/main/java/net/minecraft/item/crafting/RecipesMapCloning.java @@ -0,0 +1,105 @@ +package net.minecraft.item.crafting; + +import net.minecraft.init.Items; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class RecipesMapCloning implements IRecipe +{ + private static final String __OBFID = "CL_00000087"; + + public boolean matches(InventoryCrafting par1InventoryCrafting, World par2World) + { + int i = 0; + ItemStack itemstack = null; + + for (int j = 0; j < par1InventoryCrafting.getSizeInventory(); ++j) + { + ItemStack itemstack1 = par1InventoryCrafting.getStackInSlot(j); + + if (itemstack1 != null) + { + if (itemstack1.getItem() == Items.filled_map) + { + if (itemstack != null) + { + return false; + } + + itemstack = itemstack1; + } + else + { + if (itemstack1.getItem() != Items.map) + { + return false; + } + + ++i; + } + } + } + + return itemstack != null && i > 0; + } + + public ItemStack getCraftingResult(InventoryCrafting par1InventoryCrafting) + { + int i = 0; + ItemStack itemstack = null; + + for (int j = 0; j < par1InventoryCrafting.getSizeInventory(); ++j) + { + ItemStack itemstack1 = par1InventoryCrafting.getStackInSlot(j); + + if (itemstack1 != null) + { + if (itemstack1.getItem() == Items.filled_map) + { + if (itemstack != null) + { + return null; + } + + itemstack = itemstack1; + } + else + { + if (itemstack1.getItem() != Items.map) + { + return null; + } + + ++i; + } + } + } + + if (itemstack != null && i >= 1) + { + ItemStack itemstack2 = new ItemStack(Items.filled_map, i + 1, itemstack.getItemDamage()); + + if (itemstack.hasDisplayName()) + { + itemstack2.setStackDisplayName(itemstack.getDisplayName()); + } + + return itemstack2; + } + else + { + return null; + } + } + + public int getRecipeSize() + { + return 9; + } + + public ItemStack getRecipeOutput() + { + return null; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/crafting/RecipesMapExtending.java b/src/main/java/net/minecraft/item/crafting/RecipesMapExtending.java new file mode 100644 index 0000000..42afe2c --- /dev/null +++ b/src/main/java/net/minecraft/item/crafting/RecipesMapExtending.java @@ -0,0 +1,76 @@ +package net.minecraft.item.crafting; + +import net.minecraft.init.Items; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; +import net.minecraft.world.storage.MapData; + +public class RecipesMapExtending extends ShapedRecipes +{ + private static final String __OBFID = "CL_00000088"; + + public RecipesMapExtending() + { + super(3, 3, new ItemStack[] {new ItemStack(Items.paper), new ItemStack(Items.paper), new ItemStack(Items.paper), new ItemStack(Items.paper), new ItemStack(Items.filled_map, 0, 32767), new ItemStack(Items.paper), new ItemStack(Items.paper), new ItemStack(Items.paper), new ItemStack(Items.paper)}, new ItemStack(Items.map, 0, 0)); + } + + public boolean matches(InventoryCrafting par1InventoryCrafting, World par2World) + { + if (!super.matches(par1InventoryCrafting, par2World)) + { + return false; + } + else + { + ItemStack itemstack = null; + + for (int i = 0; i < par1InventoryCrafting.getSizeInventory() && itemstack == null; ++i) + { + ItemStack itemstack1 = par1InventoryCrafting.getStackInSlot(i); + + if (itemstack1 != null && itemstack1.getItem() == Items.filled_map) + { + itemstack = itemstack1; + } + } + + if (itemstack == null) + { + return false; + } + else + { + MapData mapdata = Items.filled_map.getMapData(itemstack, par2World); + return mapdata == null ? false : mapdata.scale < 4; + } + } + } + + public ItemStack getCraftingResult(InventoryCrafting par1InventoryCrafting) + { + ItemStack itemstack = null; + + for (int i = 0; i < par1InventoryCrafting.getSizeInventory() && itemstack == null; ++i) + { + ItemStack itemstack1 = par1InventoryCrafting.getStackInSlot(i); + + if (itemstack1 != null && itemstack1.getItem() == Items.filled_map) + { + itemstack = itemstack1; + } + } + + itemstack = itemstack.copy(); + itemstack.stackSize = 1; + + if (itemstack.getTagCompound() == null) + { + itemstack.setTagCompound(new NBTTagCompound()); + } + + itemstack.getTagCompound().setBoolean("map_is_scaling", true); + return itemstack; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/crafting/RecipesTools.java b/src/main/java/net/minecraft/item/crafting/RecipesTools.java new file mode 100644 index 0000000..294e60f --- /dev/null +++ b/src/main/java/net/minecraft/item/crafting/RecipesTools.java @@ -0,0 +1,34 @@ +package net.minecraft.item.crafting; + +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +public class RecipesTools +{ + private String[][] recipePatterns = new String[][] {{"XXX", " # ", " # "}, {"X", "#", "#"}, {"XX", "X#", " #"}, {"XX", " #", " #"}}; + private Object[][] recipeItems; + private static final String __OBFID = "CL_00000096"; + + public RecipesTools() + { + this.recipeItems = new Object[][] {{Blocks.planks, Blocks.cobblestone, Items.iron_ingot, Items.diamond, Items.gold_ingot}, {Items.wooden_pickaxe, Items.stone_pickaxe, Items.iron_pickaxe, Items.diamond_pickaxe, Items.golden_pickaxe}, {Items.wooden_shovel, Items.stone_shovel, Items.iron_shovel, Items.diamond_shovel, Items.golden_shovel}, {Items.wooden_axe, Items.stone_axe, Items.iron_axe, Items.diamond_axe, Items.golden_axe}, {Items.wooden_hoe, Items.stone_hoe, Items.iron_hoe, Items.diamond_hoe, Items.golden_hoe}}; + } + + public void addRecipes(CraftingManager par1CraftingManager) + { + for (int i = 0; i < this.recipeItems[0].length; ++i) + { + Object object = this.recipeItems[0][i]; + + for (int j = 0; j < this.recipeItems.length - 1; ++j) + { + Item item = (Item)this.recipeItems[j + 1][i]; + par1CraftingManager.addRecipe(new ItemStack(item), new Object[] {this.recipePatterns[j], '#', Items.stick, 'X', object}); + } + } + + par1CraftingManager.addRecipe(new ItemStack(Items.shears), new Object[] {" #", "# ", '#', Items.iron_ingot}); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/crafting/RecipesWeapons.java b/src/main/java/net/minecraft/item/crafting/RecipesWeapons.java new file mode 100644 index 0000000..a88a96f --- /dev/null +++ b/src/main/java/net/minecraft/item/crafting/RecipesWeapons.java @@ -0,0 +1,35 @@ +package net.minecraft.item.crafting; + +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +public class RecipesWeapons +{ + private String[][] recipePatterns = new String[][] {{"X", "X", "#"}}; + private Object[][] recipeItems; + private static final String __OBFID = "CL_00000097"; + + public RecipesWeapons() + { + this.recipeItems = new Object[][] {{Blocks.planks, Blocks.cobblestone, Items.iron_ingot, Items.diamond, Items.gold_ingot}, {Items.wooden_sword, Items.stone_sword, Items.iron_sword, Items.diamond_sword, Items.golden_sword}}; + } + + public void addRecipes(CraftingManager par1CraftingManager) + { + for (int i = 0; i < this.recipeItems[0].length; ++i) + { + Object object = this.recipeItems[0][i]; + + for (int j = 0; j < this.recipeItems.length - 1; ++j) + { + Item item = (Item)this.recipeItems[j + 1][i]; + par1CraftingManager.addRecipe(new ItemStack(item), new Object[] {this.recipePatterns[j], '#', Items.stick, 'X', object}); + } + } + + par1CraftingManager.addRecipe(new ItemStack(Items.bow, 1), new Object[] {" #X", "# X", " #X", 'X', Items.string, '#', Items.stick}); + par1CraftingManager.addRecipe(new ItemStack(Items.arrow, 4), new Object[] {"X", "#", "Y", 'Y', Items.feather, 'X', Items.flint, '#', Items.stick}); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/crafting/ShapedRecipes.java b/src/main/java/net/minecraft/item/crafting/ShapedRecipes.java new file mode 100644 index 0000000..3cd7927 --- /dev/null +++ b/src/main/java/net/minecraft/item/crafting/ShapedRecipes.java @@ -0,0 +1,128 @@ +package net.minecraft.item.crafting; + +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +public class ShapedRecipes implements IRecipe +{ + public final int recipeWidth; + public final int recipeHeight; + public final ItemStack[] recipeItems; + private ItemStack recipeOutput; + private boolean field_92101_f; + private static final String __OBFID = "CL_00000093"; + + public ShapedRecipes(int par1, int par2, ItemStack[] par3ArrayOfItemStack, ItemStack par4ItemStack) + { + this.recipeWidth = par1; + this.recipeHeight = par2; + this.recipeItems = par3ArrayOfItemStack; + this.recipeOutput = par4ItemStack; + } + + public ItemStack getRecipeOutput() + { + return this.recipeOutput; + } + + public boolean matches(InventoryCrafting par1InventoryCrafting, World par2World) + { + for (int i = 0; i <= 3 - this.recipeWidth; ++i) + { + for (int j = 0; j <= 3 - this.recipeHeight; ++j) + { + if (this.checkMatch(par1InventoryCrafting, i, j, true)) + { + return true; + } + + if (this.checkMatch(par1InventoryCrafting, i, j, false)) + { + return true; + } + } + } + + return false; + } + + private boolean checkMatch(InventoryCrafting par1InventoryCrafting, int par2, int par3, boolean par4) + { + for (int k = 0; k < 3; ++k) + { + for (int l = 0; l < 3; ++l) + { + int i1 = k - par2; + int j1 = l - par3; + ItemStack itemstack = null; + + if (i1 >= 0 && j1 >= 0 && i1 < this.recipeWidth && j1 < this.recipeHeight) + { + if (par4) + { + itemstack = this.recipeItems[this.recipeWidth - i1 - 1 + j1 * this.recipeWidth]; + } + else + { + itemstack = this.recipeItems[i1 + j1 * this.recipeWidth]; + } + } + + ItemStack itemstack1 = par1InventoryCrafting.getStackInRowAndColumn(k, l); + + if (itemstack1 != null || itemstack != null) + { + if (itemstack1 == null && itemstack != null || itemstack1 != null && itemstack == null) + { + return false; + } + + if (itemstack.getItem() != itemstack1.getItem()) + { + return false; + } + + if (itemstack.getItemDamage() != 32767 && itemstack.getItemDamage() != itemstack1.getItemDamage()) + { + return false; + } + } + } + } + + return true; + } + + public ItemStack getCraftingResult(InventoryCrafting par1InventoryCrafting) + { + ItemStack itemstack = this.getRecipeOutput().copy(); + + if (this.field_92101_f) + { + for (int i = 0; i < par1InventoryCrafting.getSizeInventory(); ++i) + { + ItemStack itemstack1 = par1InventoryCrafting.getStackInSlot(i); + + if (itemstack1 != null && itemstack1.hasTagCompound()) + { + itemstack.setTagCompound((NBTTagCompound)itemstack1.stackTagCompound.copy()); + } + } + } + + return itemstack; + } + + public int getRecipeSize() + { + return this.recipeWidth * this.recipeHeight; + } + + public ShapedRecipes func_92100_c() + { + this.field_92101_f = true; + return this; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/item/crafting/ShapelessRecipes.java b/src/main/java/net/minecraft/item/crafting/ShapelessRecipes.java new file mode 100644 index 0000000..8f713bb --- /dev/null +++ b/src/main/java/net/minecraft/item/crafting/ShapelessRecipes.java @@ -0,0 +1,74 @@ +package net.minecraft.item.crafting; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class ShapelessRecipes implements IRecipe +{ + private final ItemStack recipeOutput; + public final List recipeItems; + private static final String __OBFID = "CL_00000094"; + + public ShapelessRecipes(ItemStack par1ItemStack, List par2List) + { + this.recipeOutput = par1ItemStack; + this.recipeItems = par2List; + } + + public ItemStack getRecipeOutput() + { + return this.recipeOutput; + } + + public boolean matches(InventoryCrafting par1InventoryCrafting, World par2World) + { + ArrayList arraylist = new ArrayList(this.recipeItems); + + for (int i = 0; i < 3; ++i) + { + for (int j = 0; j < 3; ++j) + { + ItemStack itemstack = par1InventoryCrafting.getStackInRowAndColumn(j, i); + + if (itemstack != null) + { + boolean flag = false; + Iterator iterator = arraylist.iterator(); + + while (iterator.hasNext()) + { + ItemStack itemstack1 = (ItemStack)iterator.next(); + + if (itemstack.getItem() == itemstack1.getItem() && (itemstack1.getItemDamage() == 32767 || itemstack.getItemDamage() == itemstack1.getItemDamage())) + { + flag = true; + arraylist.remove(itemstack1); + break; + } + } + + if (!flag) + { + return false; + } + } + } + } + + return arraylist.isEmpty(); + } + + public ItemStack getCraftingResult(InventoryCrafting par1InventoryCrafting) + { + return this.recipeOutput.copy(); + } + + public int getRecipeSize() + { + return this.recipeItems.size(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/nbt/CompressedStreamTools.java b/src/main/java/net/minecraft/nbt/CompressedStreamTools.java new file mode 100644 index 0000000..b7a3e5a --- /dev/null +++ b/src/main/java/net/minecraft/nbt/CompressedStreamTools.java @@ -0,0 +1,213 @@ +package net.minecraft.nbt; + +import java.io.BufferedInputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.DataInput; +import java.io.DataInputStream; +import java.io.DataOutput; +import java.io.DataOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.zip.GZIPInputStream; +import java.util.zip.GZIPOutputStream; +import net.minecraft.crash.CrashReport; +import net.minecraft.crash.CrashReportCategory; +import net.minecraft.util.ReportedException; + +public class CompressedStreamTools +{ + private static final String __OBFID = "CL_00001226"; + + public static NBTTagCompound readCompressed(InputStream par0InputStream) throws IOException + { + DataInputStream datainputstream = new DataInputStream(new BufferedInputStream(new GZIPInputStream(par0InputStream))); + NBTTagCompound nbttagcompound; + + try + { + nbttagcompound = read(datainputstream); + } + finally + { + datainputstream.close(); + } + + return nbttagcompound; + } + + public static void writeCompressed(NBTTagCompound par0NBTTagCompound, OutputStream par1OutputStream) throws IOException + { + DataOutputStream dataoutputstream = new DataOutputStream(new GZIPOutputStream(par1OutputStream)); + + try + { + write(par0NBTTagCompound, dataoutputstream); + } + finally + { + dataoutputstream.close(); + } + } + + public static NBTTagCompound decompress(byte[] par0ArrayOfByte) throws IOException + { + DataInputStream datainputstream = new DataInputStream(new BufferedInputStream(new GZIPInputStream(new ByteArrayInputStream(par0ArrayOfByte)))); + NBTTagCompound nbttagcompound; + + try + { + nbttagcompound = read(datainputstream); + } + finally + { + datainputstream.close(); + } + + return nbttagcompound; + } + + public static byte[] compress(NBTTagCompound par0NBTTagCompound) throws IOException + { + ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream(); + DataOutputStream dataoutputstream = new DataOutputStream(new GZIPOutputStream(bytearrayoutputstream)); + + try + { + write(par0NBTTagCompound, dataoutputstream); + } + finally + { + dataoutputstream.close(); + } + + return bytearrayoutputstream.toByteArray(); + } + + public static void safeWrite(NBTTagCompound par0NBTTagCompound, File par1File) throws IOException + { + File file2 = new File(par1File.getAbsolutePath() + "_tmp"); + + if (file2.exists()) + { + file2.delete(); + } + + write(par0NBTTagCompound, file2); + + if (par1File.exists()) + { + par1File.delete(); + } + + if (par1File.exists()) + { + throw new IOException("Failed to delete " + par1File); + } + else + { + file2.renameTo(par1File); + } + } + + public static NBTTagCompound read(DataInput par0DataInput) throws IOException + { + NBTBase nbtbase = func_150664_a(par0DataInput, 0); + + if (nbtbase instanceof NBTTagCompound) + { + return (NBTTagCompound)nbtbase; + } + else + { + throw new IOException("Root tag must be a named compound tag"); + } + } + + public static void write(NBTTagCompound par0NBTTagCompound, DataOutput par1DataOutput) throws IOException + { + func_150663_a(par0NBTTagCompound, par1DataOutput); + } + + private static void func_150663_a(NBTBase p_150663_0_, DataOutput p_150663_1_) throws IOException + { + p_150663_1_.writeByte(p_150663_0_.getId()); + + if (p_150663_0_.getId() != 0) + { + p_150663_1_.writeUTF(""); + p_150663_0_.write(p_150663_1_); + } + } + + private static NBTBase func_150664_a(DataInput p_150664_0_, int p_150664_1_) throws IOException + { + byte b0 = p_150664_0_.readByte(); + + if (b0 == 0) + { + return new NBTTagEnd(); + } + else + { + p_150664_0_.readUTF(); + NBTBase nbtbase = NBTBase.func_150284_a(b0); + + try + { + nbtbase.load(p_150664_0_, p_150664_1_); + return nbtbase; + } + catch (IOException ioexception) + { + CrashReport crashreport = CrashReport.makeCrashReport(ioexception, "Loading NBT data"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("NBT Tag"); + crashreportcategory.addCrashSection("Tag name", "[UNNAMED TAG]"); + crashreportcategory.addCrashSection("Tag type", Byte.valueOf(b0)); + throw new ReportedException(crashreport); + } + } + } + + public static void write(NBTTagCompound par0NBTTagCompound, File par1File) throws IOException + { + DataOutputStream dataoutputstream = new DataOutputStream(new FileOutputStream(par1File)); + + try + { + write(par0NBTTagCompound, dataoutputstream); + } + finally + { + dataoutputstream.close(); + } + } + + public static NBTTagCompound read(File par0File) throws IOException + { + if (!par0File.exists()) + { + return null; + } + else + { + DataInputStream datainputstream = new DataInputStream(new FileInputStream(par0File)); + NBTTagCompound nbttagcompound; + + try + { + nbttagcompound = read(datainputstream); + } + finally + { + datainputstream.close(); + } + + return nbttagcompound; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/nbt/JsonToNBT.java b/src/main/java/net/minecraft/nbt/JsonToNBT.java new file mode 100644 index 0000000..c6f5912 --- /dev/null +++ b/src/main/java/net/minecraft/nbt/JsonToNBT.java @@ -0,0 +1,560 @@ +package net.minecraft.nbt; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.Stack; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class JsonToNBT +{ + private static final Logger logger = LogManager.getLogger(); + private static final String __OBFID = "CL_00001232"; + + public static NBTBase func_150315_a(String p_150315_0_) throws NBTException + { + p_150315_0_ = p_150315_0_.trim(); + int i = func_150310_b(p_150315_0_); + + if (i != 1) + { + throw new NBTException("Encountered multiple top tags, only one expected"); + } + else + { + JsonToNBT.Any any = null; + + if (p_150315_0_.startsWith("{")) + { + any = func_150316_a("tag", p_150315_0_); + } + else + { + any = func_150316_a(func_150313_b(p_150315_0_, false), func_150311_c(p_150315_0_, false)); + } + + return any.func_150489_a(); + } + } + + static int func_150310_b(String p_150310_0_) throws NBTException + { + int i = 0; + boolean flag = false; + Stack stack = new Stack(); + + for (int j = 0; j < p_150310_0_.length(); ++j) + { + char c0 = p_150310_0_.charAt(j); + + if (c0 == 34) + { + if (j > 0 && p_150310_0_.charAt(j - 1) == 92) + { + if (!flag) + { + throw new NBTException("Illegal use of \\\": " + p_150310_0_); + } + } + else + { + flag = !flag; + } + } + else if (!flag) + { + if (c0 != 123 && c0 != 91) + { + if (c0 == 125 && (stack.isEmpty() || ((Character)stack.pop()).charValue() != 123)) + { + throw new NBTException("Unbalanced curly brackets {}: " + p_150310_0_); + } + + if (c0 == 93 && (stack.isEmpty() || ((Character)stack.pop()).charValue() != 91)) + { + throw new NBTException("Unbalanced square brackets []: " + p_150310_0_); + } + } + else + { + if (stack.isEmpty()) + { + ++i; + } + + stack.push(Character.valueOf(c0)); + } + } + } + + if (flag) + { + throw new NBTException("Unbalanced quotation: " + p_150310_0_); + } + else if (!stack.isEmpty()) + { + throw new NBTException("Unbalanced brackets: " + p_150310_0_); + } + else if (i == 0 && !p_150310_0_.isEmpty()) + { + return 1; + } + else + { + return i; + } + } + + static JsonToNBT.Any func_150316_a(String p_150316_0_, String p_150316_1_) throws NBTException + { + p_150316_1_ = p_150316_1_.trim(); + func_150310_b(p_150316_1_); + String s2; + String s3; + String s4; + char c0; + + if (p_150316_1_.startsWith("{")) + { + if (!p_150316_1_.endsWith("}")) + { + throw new NBTException("Unable to locate ending bracket for: " + p_150316_1_); + } + else + { + p_150316_1_ = p_150316_1_.substring(1, p_150316_1_.length() - 1); + JsonToNBT.Compound compound = new JsonToNBT.Compound(p_150316_0_); + + while (p_150316_1_.length() > 0) + { + s2 = func_150314_a(p_150316_1_, false); + + if (s2.length() > 0) + { + s3 = func_150313_b(s2, false); + s4 = func_150311_c(s2, false); + compound.field_150491_b.add(func_150316_a(s3, s4)); + + if (p_150316_1_.length() < s2.length() + 1) + { + break; + } + + c0 = p_150316_1_.charAt(s2.length()); + + if (c0 != 44 && c0 != 123 && c0 != 125 && c0 != 91 && c0 != 93) + { + throw new NBTException("Unexpected token \'" + c0 + "\' at: " + p_150316_1_.substring(s2.length())); + } + + p_150316_1_ = p_150316_1_.substring(s2.length() + 1); + } + } + + return compound; + } + } + else if (p_150316_1_.startsWith("[") && !p_150316_1_.matches("\\[[-\\d|,\\s]+\\]")) + { + if (!p_150316_1_.endsWith("]")) + { + throw new NBTException("Unable to locate ending bracket for: " + p_150316_1_); + } + else + { + p_150316_1_ = p_150316_1_.substring(1, p_150316_1_.length() - 1); + JsonToNBT.List list = new JsonToNBT.List(p_150316_0_); + + while (p_150316_1_.length() > 0) + { + s2 = func_150314_a(p_150316_1_, true); + + if (s2.length() > 0) + { + s3 = func_150313_b(s2, true); + s4 = func_150311_c(s2, true); + list.field_150492_b.add(func_150316_a(s3, s4)); + + if (p_150316_1_.length() < s2.length() + 1) + { + break; + } + + c0 = p_150316_1_.charAt(s2.length()); + + if (c0 != 44 && c0 != 123 && c0 != 125 && c0 != 91 && c0 != 93) + { + throw new NBTException("Unexpected token \'" + c0 + "\' at: " + p_150316_1_.substring(s2.length())); + } + + p_150316_1_ = p_150316_1_.substring(s2.length() + 1); + } + else + { + logger.debug(p_150316_1_); + } + } + + return list; + } + } + else + { + return new JsonToNBT.Primitive(p_150316_0_, p_150316_1_); + } + } + + private static String func_150314_a(String p_150314_0_, boolean p_150314_1_) throws NBTException + { + int i = func_150312_a(p_150314_0_, ':'); + + if (i < 0 && !p_150314_1_) + { + throw new NBTException("Unable to locate name/value separator for string: " + p_150314_0_); + } + else + { + int j = func_150312_a(p_150314_0_, ','); + + if (j >= 0 && j < i && !p_150314_1_) + { + throw new NBTException("Name error at: " + p_150314_0_); + } + else + { + if (p_150314_1_ && (i < 0 || i > j)) + { + i = -1; + } + + Stack stack = new Stack(); + int k = i + 1; + boolean flag1 = false; + boolean flag2 = false; + boolean flag3 = false; + + for (int l = 0; k < p_150314_0_.length(); ++k) + { + char c0 = p_150314_0_.charAt(k); + + if (c0 == 34) + { + if (k > 0 && p_150314_0_.charAt(k - 1) == 92) + { + if (!flag1) + { + throw new NBTException("Illegal use of \\\": " + p_150314_0_); + } + } + else + { + flag1 = !flag1; + + if (flag1 && !flag3) + { + flag2 = true; + } + + if (!flag1) + { + l = k; + } + } + } + else if (!flag1) + { + if (c0 != 123 && c0 != 91) + { + if (c0 == 125 && (stack.isEmpty() || ((Character)stack.pop()).charValue() != 123)) + { + throw new NBTException("Unbalanced curly brackets {}: " + p_150314_0_); + } + + if (c0 == 93 && (stack.isEmpty() || ((Character)stack.pop()).charValue() != 91)) + { + throw new NBTException("Unbalanced square brackets []: " + p_150314_0_); + } + + if (c0 == 44 && stack.isEmpty()) + { + return p_150314_0_.substring(0, k); + } + } + else + { + stack.push(Character.valueOf(c0)); + } + } + + if (!Character.isWhitespace(c0)) + { + if (!flag1 && flag2 && l != k) + { + return p_150314_0_.substring(0, l + 1); + } + + flag3 = true; + } + } + + return p_150314_0_.substring(0, k); + } + } + } + + private static String func_150313_b(String p_150313_0_, boolean p_150313_1_) throws NBTException + { + if (p_150313_1_) + { + p_150313_0_ = p_150313_0_.trim(); + + if (p_150313_0_.startsWith("{") || p_150313_0_.startsWith("[")) + { + return ""; + } + } + + int i = p_150313_0_.indexOf(58); + + if (i < 0) + { + if (p_150313_1_) + { + return ""; + } + else + { + throw new NBTException("Unable to locate name/value separator for string: " + p_150313_0_); + } + } + else + { + return p_150313_0_.substring(0, i).trim(); + } + } + + private static String func_150311_c(String p_150311_0_, boolean p_150311_1_) throws NBTException + { + if (p_150311_1_) + { + p_150311_0_ = p_150311_0_.trim(); + + if (p_150311_0_.startsWith("{") || p_150311_0_.startsWith("[")) + { + return p_150311_0_; + } + } + + int i = p_150311_0_.indexOf(58); + + if (i < 0) + { + if (p_150311_1_) + { + return p_150311_0_; + } + else + { + throw new NBTException("Unable to locate name/value separator for string: " + p_150311_0_); + } + } + else + { + return p_150311_0_.substring(i + 1).trim(); + } + } + + private static int func_150312_a(String p_150312_0_, char p_150312_1_) + { + int i = 0; + + for (boolean flag = false; i < p_150312_0_.length(); ++i) + { + char c1 = p_150312_0_.charAt(i); + + if (c1 == 34) + { + if (i <= 0 || p_150312_0_.charAt(i - 1) != 92) + { + flag = !flag; + } + } + else if (!flag) + { + if (c1 == p_150312_1_) + { + return i; + } + + if (c1 == 123 || c1 == 91) + { + return -1; + } + } + } + + return -1; + } + + abstract static class Any + { + protected String field_150490_a; + private static final String __OBFID = "CL_00001233"; + + public abstract NBTBase func_150489_a(); + } + + static class Compound extends JsonToNBT.Any + { + protected ArrayList field_150491_b = new ArrayList(); + private static final String __OBFID = "CL_00001234"; + + public Compound(String p_i45137_1_) + { + this.field_150490_a = p_i45137_1_; + } + + public NBTBase func_150489_a() + { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + Iterator iterator = this.field_150491_b.iterator(); + + while (iterator.hasNext()) + { + JsonToNBT.Any any = (JsonToNBT.Any)iterator.next(); + nbttagcompound.setTag(any.field_150490_a, any.func_150489_a()); + } + + return nbttagcompound; + } + } + + static class List extends JsonToNBT.Any + { + protected ArrayList field_150492_b = new ArrayList(); + private static final String __OBFID = "CL_00001235"; + + public List(String p_i45138_1_) + { + this.field_150490_a = p_i45138_1_; + } + + public NBTBase func_150489_a() + { + NBTTagList nbttaglist = new NBTTagList(); + Iterator iterator = this.field_150492_b.iterator(); + + while (iterator.hasNext()) + { + JsonToNBT.Any any = (JsonToNBT.Any)iterator.next(); + nbttaglist.appendTag(any.func_150489_a()); + } + + return nbttaglist; + } + } + + static class Primitive extends JsonToNBT.Any + { + protected String field_150493_b; + private static final String __OBFID = "CL_00001236"; + + public Primitive(String p_i45139_1_, String p_i45139_2_) + { + this.field_150490_a = p_i45139_1_; + this.field_150493_b = p_i45139_2_; + } + + public NBTBase func_150489_a() + { + try + { + if (this.field_150493_b.matches("[-+]?[0-9]*\\.?[0-9]+[d|D]")) + { + return new NBTTagDouble(Double.parseDouble(this.field_150493_b.substring(0, this.field_150493_b.length() - 1))); + } + else if (this.field_150493_b.matches("[-+]?[0-9]*\\.?[0-9]+[f|F]")) + { + return new NBTTagFloat(Float.parseFloat(this.field_150493_b.substring(0, this.field_150493_b.length() - 1))); + } + else if (this.field_150493_b.matches("[-+]?[0-9]+[b|B]")) + { + return new NBTTagByte(Byte.parseByte(this.field_150493_b.substring(0, this.field_150493_b.length() - 1))); + } + else if (this.field_150493_b.matches("[-+]?[0-9]+[l|L]")) + { + return new NBTTagLong(Long.parseLong(this.field_150493_b.substring(0, this.field_150493_b.length() - 1))); + } + else if (this.field_150493_b.matches("[-+]?[0-9]+[s|S]")) + { + return new NBTTagShort(Short.parseShort(this.field_150493_b.substring(0, this.field_150493_b.length() - 1))); + } + else if (this.field_150493_b.matches("[-+]?[0-9]+")) + { + return new NBTTagInt(Integer.parseInt(this.field_150493_b.substring(0, this.field_150493_b.length()))); + } + else if (this.field_150493_b.matches("[-+]?[0-9]*\\.?[0-9]+")) + { + return new NBTTagDouble(Double.parseDouble(this.field_150493_b.substring(0, this.field_150493_b.length()))); + } + else if (!this.field_150493_b.equalsIgnoreCase("true") && !this.field_150493_b.equalsIgnoreCase("false")) + { + if (this.field_150493_b.startsWith("[") && this.field_150493_b.endsWith("]")) + { + if (this.field_150493_b.length() > 2) + { + String s = this.field_150493_b.substring(1, this.field_150493_b.length() - 1); + String[] astring = s.split(","); + + try + { + if (astring.length <= 1) + { + return new NBTTagIntArray(new int[] {Integer.parseInt(s.trim())}); + } + else + { + int[] aint = new int[astring.length]; + + for (int i = 0; i < astring.length; ++i) + { + aint[i] = Integer.parseInt(astring[i].trim()); + } + + return new NBTTagIntArray(aint); + } + } + catch (NumberFormatException numberformatexception) + { + return new NBTTagString(this.field_150493_b); + } + } + else + { + return new NBTTagIntArray(); + } + } + else + { + if (this.field_150493_b.startsWith("\"") && this.field_150493_b.endsWith("\"") && this.field_150493_b.length() > 2) + { + this.field_150493_b = this.field_150493_b.substring(1, this.field_150493_b.length() - 1); + } + + this.field_150493_b = this.field_150493_b.replaceAll("\\\\\"", "\""); + return new NBTTagString(this.field_150493_b); + } + } + else + { + return new NBTTagByte((byte)(Boolean.parseBoolean(this.field_150493_b) ? 1 : 0)); + } + } + catch (NumberFormatException numberformatexception1) + { + this.field_150493_b = this.field_150493_b.replaceAll("\\\\\"", "\""); + return new NBTTagString(this.field_150493_b); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/nbt/NBTBase.java b/src/main/java/net/minecraft/nbt/NBTBase.java new file mode 100644 index 0000000..b4a8d18 --- /dev/null +++ b/src/main/java/net/minecraft/nbt/NBTBase.java @@ -0,0 +1,129 @@ +package net.minecraft.nbt; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +public abstract class NBTBase +{ + public static final String[] NBTTypes = new String[] {"END", "BYTE", "SHORT", "INT", "LONG", "FLOAT", "DOUBLE", "BYTE[]", "STRING", "LIST", "COMPOUND", "INT[]"}; + private static final String __OBFID = "CL_00001229"; + + abstract void write(DataOutput var1) throws IOException; + + abstract void load(DataInput var1, int var2) throws IOException; + + public abstract String toString(); + + public abstract byte getId(); + + protected static NBTBase func_150284_a(byte p_150284_0_) + { + switch (p_150284_0_) + { + case 0: + return new NBTTagEnd(); + case 1: + return new NBTTagByte(); + case 2: + return new NBTTagShort(); + case 3: + return new NBTTagInt(); + case 4: + return new NBTTagLong(); + case 5: + return new NBTTagFloat(); + case 6: + return new NBTTagDouble(); + case 7: + return new NBTTagByteArray(); + case 8: + return new NBTTagString(); + case 9: + return new NBTTagList(); + case 10: + return new NBTTagCompound(); + case 11: + return new NBTTagIntArray(); + default: + return null; + } + } + + public static String func_150283_g(int p_150283_0_) + { + switch (p_150283_0_) + { + case 0: + return "TAG_End"; + case 1: + return "TAG_Byte"; + case 2: + return "TAG_Short"; + case 3: + return "TAG_Int"; + case 4: + return "TAG_Long"; + case 5: + return "TAG_Float"; + case 6: + return "TAG_Double"; + case 7: + return "TAG_Byte_Array"; + case 8: + return "TAG_String"; + case 9: + return "TAG_List"; + case 10: + return "TAG_Compound"; + case 11: + return "TAG_Int_Array"; + case 99: + return "Any Numeric Tag"; + default: + return "UNKNOWN"; + } + } + + public abstract NBTBase copy(); + + public boolean equals(Object par1Obj) + { + if (!(par1Obj instanceof NBTBase)) + { + return false; + } + else + { + NBTBase nbtbase = (NBTBase)par1Obj; + return this.getId() == nbtbase.getId(); + } + } + + public int hashCode() + { + return this.getId(); + } + + protected String func_150285_a_() + { + return this.toString(); + } + + public abstract static class NBTPrimitive extends NBTBase + { + private static final String __OBFID = "CL_00001230"; + + public abstract long func_150291_c(); + + public abstract int func_150287_d(); + + public abstract short func_150289_e(); + + public abstract byte func_150290_f(); + + public abstract double func_150286_g(); + + public abstract float func_150288_h(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/nbt/NBTException.java b/src/main/java/net/minecraft/nbt/NBTException.java new file mode 100644 index 0000000..8da5683 --- /dev/null +++ b/src/main/java/net/minecraft/nbt/NBTException.java @@ -0,0 +1,11 @@ +package net.minecraft.nbt; + +public class NBTException extends Exception +{ + private static final String __OBFID = "CL_00001231"; + + public NBTException(String p_i45136_1_) + { + super(p_i45136_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/nbt/NBTTagByte.java b/src/main/java/net/minecraft/nbt/NBTTagByte.java new file mode 100644 index 0000000..c0514a5 --- /dev/null +++ b/src/main/java/net/minecraft/nbt/NBTTagByte.java @@ -0,0 +1,91 @@ +package net.minecraft.nbt; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +public class NBTTagByte extends NBTBase.NBTPrimitive +{ + private byte data; + private static final String __OBFID = "CL_00001214"; + + NBTTagByte() {} + + public NBTTagByte(byte p_i45129_1_) + { + this.data = p_i45129_1_; + } + + void write(DataOutput par1DataOutput) throws IOException + { + par1DataOutput.writeByte(this.data); + } + + void load(DataInput par1DataInput, int par2) throws IOException + { + this.data = par1DataInput.readByte(); + } + + public byte getId() + { + return (byte)1; + } + + public String toString() + { + return "" + this.data + "b"; + } + + public NBTBase copy() + { + return new NBTTagByte(this.data); + } + + public boolean equals(Object par1Obj) + { + if (super.equals(par1Obj)) + { + NBTTagByte nbttagbyte = (NBTTagByte)par1Obj; + return this.data == nbttagbyte.data; + } + else + { + return false; + } + } + + public int hashCode() + { + return super.hashCode() ^ this.data; + } + + public long func_150291_c() + { + return (long)this.data; + } + + public int func_150287_d() + { + return this.data; + } + + public short func_150289_e() + { + return (short)this.data; + } + + public byte func_150290_f() + { + return this.data; + } + + public double func_150286_g() + { + return (double)this.data; + } + + public float func_150288_h() + { + return (float)this.data; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/nbt/NBTTagByteArray.java b/src/main/java/net/minecraft/nbt/NBTTagByteArray.java new file mode 100644 index 0000000..58cae1b --- /dev/null +++ b/src/main/java/net/minecraft/nbt/NBTTagByteArray.java @@ -0,0 +1,64 @@ +package net.minecraft.nbt; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; +import java.util.Arrays; + +public class NBTTagByteArray extends NBTBase +{ + private byte[] byteArray; + private static final String __OBFID = "CL_00001213"; + + NBTTagByteArray() {} + + public NBTTagByteArray(byte[] p_i45128_1_) + { + this.byteArray = p_i45128_1_; + } + + void write(DataOutput par1DataOutput) throws IOException + { + par1DataOutput.writeInt(this.byteArray.length); + par1DataOutput.write(this.byteArray); + } + + void load(DataInput par1DataInput, int par2) throws IOException + { + int j = par1DataInput.readInt(); + this.byteArray = new byte[j]; + par1DataInput.readFully(this.byteArray); + } + + public byte getId() + { + return (byte)7; + } + + public String toString() + { + return "[" + this.byteArray.length + " bytes]"; + } + + public NBTBase copy() + { + byte[] abyte = new byte[this.byteArray.length]; + System.arraycopy(this.byteArray, 0, abyte, 0, this.byteArray.length); + return new NBTTagByteArray(abyte); + } + + public boolean equals(Object par1Obj) + { + return super.equals(par1Obj) ? Arrays.equals(this.byteArray, ((NBTTagByteArray)par1Obj).byteArray) : false; + } + + public int hashCode() + { + return super.hashCode() ^ Arrays.hashCode(this.byteArray); + } + + public byte[] func_150292_c() + { + return this.byteArray; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/nbt/NBTTagCompound.java b/src/main/java/net/minecraft/nbt/NBTTagCompound.java new file mode 100644 index 0000000..33d366f --- /dev/null +++ b/src/main/java/net/minecraft/nbt/NBTTagCompound.java @@ -0,0 +1,424 @@ +package net.minecraft.nbt; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.Callable; +import net.minecraft.crash.CrashReport; +import net.minecraft.crash.CrashReportCategory; +import net.minecraft.util.ReportedException; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class NBTTagCompound extends NBTBase +{ + private static final Logger logger = LogManager.getLogger(); + private Map tagMap = new HashMap(); + private static final String __OBFID = "CL_00001215"; + + void write(DataOutput par1DataOutput) throws IOException + { + Iterator iterator = this.tagMap.keySet().iterator(); + + while (iterator.hasNext()) + { + String s = (String)iterator.next(); + NBTBase nbtbase = (NBTBase)this.tagMap.get(s); + func_150298_a(s, nbtbase, par1DataOutput); + } + + par1DataOutput.writeByte(0); + } + + void load(DataInput par1DataInput, int par2) throws IOException + { + if (par2 > 512) + { + throw new RuntimeException("Tried to read NBT tag with too high complexity, depth > 512"); + } + else + { + this.tagMap.clear(); + byte b0; + + while ((b0 = func_150300_a(par1DataInput)) != 0) + { + String s = func_150294_b(par1DataInput); + NBTBase nbtbase = func_150293_a(b0, s, par1DataInput, par2 + 1); + this.tagMap.put(s, nbtbase); + } + } + } + + public Set func_150296_c() + { + return this.tagMap.keySet(); + } + + public byte getId() + { + return (byte)10; + } + + public void setTag(String par1Str, NBTBase par2NBTBase) + { + this.tagMap.put(par1Str, par2NBTBase); + } + + public void setByte(String par1Str, byte par2) + { + this.tagMap.put(par1Str, new NBTTagByte(par2)); + } + + public void setShort(String par1Str, short par2) + { + this.tagMap.put(par1Str, new NBTTagShort(par2)); + } + + public void setInteger(String par1Str, int par2) + { + this.tagMap.put(par1Str, new NBTTagInt(par2)); + } + + public void setLong(String par1Str, long par2) + { + this.tagMap.put(par1Str, new NBTTagLong(par2)); + } + + public void setFloat(String par1Str, float par2) + { + this.tagMap.put(par1Str, new NBTTagFloat(par2)); + } + + public void setDouble(String par1Str, double par2) + { + this.tagMap.put(par1Str, new NBTTagDouble(par2)); + } + + public void setString(String par1Str, String par2Str) + { + this.tagMap.put(par1Str, new NBTTagString(par2Str)); + } + + public void setByteArray(String par1Str, byte[] par2ArrayOfByte) + { + this.tagMap.put(par1Str, new NBTTagByteArray(par2ArrayOfByte)); + } + + public void setIntArray(String par1Str, int[] par2ArrayOfInteger) + { + this.tagMap.put(par1Str, new NBTTagIntArray(par2ArrayOfInteger)); + } + + public void setBoolean(String par1Str, boolean par2) + { + this.setByte(par1Str, (byte)(par2 ? 1 : 0)); + } + + public NBTBase getTag(String par1Str) + { + return (NBTBase)this.tagMap.get(par1Str); + } + + public byte func_150299_b(String p_150299_1_) + { + NBTBase nbtbase = (NBTBase)this.tagMap.get(p_150299_1_); + return nbtbase != null ? nbtbase.getId() : 0; + } + + public boolean hasKey(String par1Str) + { + return this.tagMap.containsKey(par1Str); + } + + public boolean hasKey(String p_150297_1_, int p_150297_2_) + { + byte b0 = this.func_150299_b(p_150297_1_); + + if (b0 == p_150297_2_) + { + return true; + } + else if (p_150297_2_ != 99) + { + if (b0 > 0) + { + logger.warn("NBT tag {} was of wrong type; expected {}, found {}", new Object[] {p_150297_1_, func_150283_g(p_150297_2_), func_150283_g(b0)}); + } + + return false; + } + else + { + return b0 == 1 || b0 == 2 || b0 == 3 || b0 == 4 || b0 == 5 || b0 == 6; + } + } + + public byte getByte(String par1Str) + { + try + { + return !this.tagMap.containsKey(par1Str) ? 0 : ((NBTBase.NBTPrimitive)this.tagMap.get(par1Str)).func_150290_f(); + } + catch (ClassCastException classcastexception) + { + return (byte)0; + } + } + + public short getShort(String par1Str) + { + try + { + return !this.tagMap.containsKey(par1Str) ? 0 : ((NBTBase.NBTPrimitive)this.tagMap.get(par1Str)).func_150289_e(); + } + catch (ClassCastException classcastexception) + { + return (short)0; + } + } + + public int getInteger(String par1Str) + { + try + { + return !this.tagMap.containsKey(par1Str) ? 0 : ((NBTBase.NBTPrimitive)this.tagMap.get(par1Str)).func_150287_d(); + } + catch (ClassCastException classcastexception) + { + return 0; + } + } + + public long getLong(String par1Str) + { + try + { + return !this.tagMap.containsKey(par1Str) ? 0L : ((NBTBase.NBTPrimitive)this.tagMap.get(par1Str)).func_150291_c(); + } + catch (ClassCastException classcastexception) + { + return 0L; + } + } + + public float getFloat(String par1Str) + { + try + { + return !this.tagMap.containsKey(par1Str) ? 0.0F : ((NBTBase.NBTPrimitive)this.tagMap.get(par1Str)).func_150288_h(); + } + catch (ClassCastException classcastexception) + { + return 0.0F; + } + } + + public double getDouble(String par1Str) + { + try + { + return !this.tagMap.containsKey(par1Str) ? 0.0D : ((NBTBase.NBTPrimitive)this.tagMap.get(par1Str)).func_150286_g(); + } + catch (ClassCastException classcastexception) + { + return 0.0D; + } + } + + public String getString(String par1Str) + { + try + { + return !this.tagMap.containsKey(par1Str) ? "" : ((NBTBase)this.tagMap.get(par1Str)).func_150285_a_(); + } + catch (ClassCastException classcastexception) + { + return ""; + } + } + + public byte[] getByteArray(String par1Str) + { + try + { + return !this.tagMap.containsKey(par1Str) ? new byte[0] : ((NBTTagByteArray)this.tagMap.get(par1Str)).func_150292_c(); + } + catch (ClassCastException classcastexception) + { + throw new ReportedException(this.createCrashReport(par1Str, 7, classcastexception)); + } + } + + public int[] getIntArray(String par1Str) + { + try + { + return !this.tagMap.containsKey(par1Str) ? new int[0] : ((NBTTagIntArray)this.tagMap.get(par1Str)).func_150302_c(); + } + catch (ClassCastException classcastexception) + { + throw new ReportedException(this.createCrashReport(par1Str, 11, classcastexception)); + } + } + + public NBTTagCompound getCompoundTag(String par1Str) + { + try + { + return !this.tagMap.containsKey(par1Str) ? new NBTTagCompound() : (NBTTagCompound)this.tagMap.get(par1Str); + } + catch (ClassCastException classcastexception) + { + throw new ReportedException(this.createCrashReport(par1Str, 10, classcastexception)); + } + } + + public NBTTagList getTagList(String p_150295_1_, int p_150295_2_) + { + try + { + if (this.func_150299_b(p_150295_1_) != 9) + { + return new NBTTagList(); + } + else + { + NBTTagList nbttaglist = (NBTTagList)this.tagMap.get(p_150295_1_); + return nbttaglist.tagCount() > 0 && nbttaglist.func_150303_d() != p_150295_2_ ? new NBTTagList() : nbttaglist; + } + } + catch (ClassCastException classcastexception) + { + throw new ReportedException(this.createCrashReport(p_150295_1_, 9, classcastexception)); + } + } + + public boolean getBoolean(String par1Str) + { + return this.getByte(par1Str) != 0; + } + + public void removeTag(String par1Str) + { + this.tagMap.remove(par1Str); + } + + public String toString() + { + String s = "{"; + String s1; + + for (Iterator iterator = this.tagMap.keySet().iterator(); iterator.hasNext(); s = s + s1 + ':' + this.tagMap.get(s1) + ',') + { + s1 = (String)iterator.next(); + } + + return s + "}"; + } + + public boolean hasNoTags() + { + return this.tagMap.isEmpty(); + } + + private CrashReport createCrashReport(final String par1Str, final int par2, ClassCastException par3ClassCastException) + { + CrashReport crashreport = CrashReport.makeCrashReport(par3ClassCastException, "Reading NBT data"); + CrashReportCategory crashreportcategory = crashreport.makeCategoryDepth("Corrupt NBT tag", 1); + crashreportcategory.addCrashSectionCallable("Tag type found", new Callable() + { + private static final String __OBFID = "CL_00001216"; + public String call() + { + return NBTBase.NBTTypes[((NBTBase)NBTTagCompound.this.tagMap.get(par1Str)).getId()]; + } + }); + crashreportcategory.addCrashSectionCallable("Tag type expected", new Callable() + { + private static final String __OBFID = "CL_00001217"; + public String call() + { + return NBTBase.NBTTypes[par2]; + } + }); + crashreportcategory.addCrashSection("Tag name", par1Str); + return crashreport; + } + + public NBTBase copy() + { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + Iterator iterator = this.tagMap.keySet().iterator(); + + while (iterator.hasNext()) + { + String s = (String)iterator.next(); + nbttagcompound.setTag(s, ((NBTBase)this.tagMap.get(s)).copy()); + } + + return nbttagcompound; + } + + public boolean equals(Object par1Obj) + { + if (super.equals(par1Obj)) + { + NBTTagCompound nbttagcompound = (NBTTagCompound)par1Obj; + return this.tagMap.entrySet().equals(nbttagcompound.tagMap.entrySet()); + } + else + { + return false; + } + } + + public int hashCode() + { + return super.hashCode() ^ this.tagMap.hashCode(); + } + + private static void func_150298_a(String p_150298_0_, NBTBase p_150298_1_, DataOutput p_150298_2_) throws IOException + { + p_150298_2_.writeByte(p_150298_1_.getId()); + + if (p_150298_1_.getId() != 0) + { + p_150298_2_.writeUTF(p_150298_0_); + p_150298_1_.write(p_150298_2_); + } + } + + private static byte func_150300_a(DataInput p_150300_0_) throws IOException + { + return p_150300_0_.readByte(); + } + + private static String func_150294_b(DataInput p_150294_0_) throws IOException + { + return p_150294_0_.readUTF(); + } + + static NBTBase func_150293_a(byte p_150293_0_, String p_150293_1_, DataInput p_150293_2_, int p_150293_3_) + { + NBTBase nbtbase = NBTBase.func_150284_a(p_150293_0_); + + try + { + nbtbase.load(p_150293_2_, p_150293_3_); + return nbtbase; + } + catch (IOException ioexception) + { + CrashReport crashreport = CrashReport.makeCrashReport(ioexception, "Loading NBT data"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("NBT Tag"); + crashreportcategory.addCrashSection("Tag name", p_150293_1_); + crashreportcategory.addCrashSection("Tag type", Byte.valueOf(p_150293_0_)); + throw new ReportedException(crashreport); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/nbt/NBTTagDouble.java b/src/main/java/net/minecraft/nbt/NBTTagDouble.java new file mode 100644 index 0000000..de4ff4e --- /dev/null +++ b/src/main/java/net/minecraft/nbt/NBTTagDouble.java @@ -0,0 +1,93 @@ +package net.minecraft.nbt; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; +import net.minecraft.util.MathHelper; + +public class NBTTagDouble extends NBTBase.NBTPrimitive +{ + private double data; + private static final String __OBFID = "CL_00001218"; + + NBTTagDouble() {} + + public NBTTagDouble(double p_i45130_1_) + { + this.data = p_i45130_1_; + } + + void write(DataOutput par1DataOutput) throws IOException + { + par1DataOutput.writeDouble(this.data); + } + + void load(DataInput par1DataInput, int par2) throws IOException + { + this.data = par1DataInput.readDouble(); + } + + public byte getId() + { + return (byte)6; + } + + public String toString() + { + return "" + this.data + "d"; + } + + public NBTBase copy() + { + return new NBTTagDouble(this.data); + } + + public boolean equals(Object par1Obj) + { + if (super.equals(par1Obj)) + { + NBTTagDouble nbttagdouble = (NBTTagDouble)par1Obj; + return this.data == nbttagdouble.data; + } + else + { + return false; + } + } + + public int hashCode() + { + long i = Double.doubleToLongBits(this.data); + return super.hashCode() ^ (int)(i ^ i >>> 32); + } + + public long func_150291_c() + { + return (long)Math.floor(this.data); + } + + public int func_150287_d() + { + return MathHelper.floor_double(this.data); + } + + public short func_150289_e() + { + return (short)(MathHelper.floor_double(this.data) & 65535); + } + + public byte func_150290_f() + { + return (byte)(MathHelper.floor_double(this.data) & 255); + } + + public double func_150286_g() + { + return this.data; + } + + public float func_150288_h() + { + return (float)this.data; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/nbt/NBTTagEnd.java b/src/main/java/net/minecraft/nbt/NBTTagEnd.java new file mode 100644 index 0000000..4ab60f9 --- /dev/null +++ b/src/main/java/net/minecraft/nbt/NBTTagEnd.java @@ -0,0 +1,29 @@ +package net.minecraft.nbt; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +public class NBTTagEnd extends NBTBase +{ + private static final String __OBFID = "CL_00001219"; + + void load(DataInput par1DataInput, int par2) throws IOException {} + + void write(DataOutput par1DataOutput) throws IOException {} + + public byte getId() + { + return (byte)0; + } + + public String toString() + { + return "END"; + } + + public NBTBase copy() + { + return new NBTTagEnd(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/nbt/NBTTagFloat.java b/src/main/java/net/minecraft/nbt/NBTTagFloat.java new file mode 100644 index 0000000..179063c --- /dev/null +++ b/src/main/java/net/minecraft/nbt/NBTTagFloat.java @@ -0,0 +1,92 @@ +package net.minecraft.nbt; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; +import net.minecraft.util.MathHelper; + +public class NBTTagFloat extends NBTBase.NBTPrimitive +{ + private float data; + private static final String __OBFID = "CL_00001220"; + + NBTTagFloat() {} + + public NBTTagFloat(float p_i45131_1_) + { + this.data = p_i45131_1_; + } + + void write(DataOutput par1DataOutput) throws IOException + { + par1DataOutput.writeFloat(this.data); + } + + void load(DataInput par1DataInput, int par2) throws IOException + { + this.data = par1DataInput.readFloat(); + } + + public byte getId() + { + return (byte)5; + } + + public String toString() + { + return "" + this.data + "f"; + } + + public NBTBase copy() + { + return new NBTTagFloat(this.data); + } + + public boolean equals(Object par1Obj) + { + if (super.equals(par1Obj)) + { + NBTTagFloat nbttagfloat = (NBTTagFloat)par1Obj; + return this.data == nbttagfloat.data; + } + else + { + return false; + } + } + + public int hashCode() + { + return super.hashCode() ^ Float.floatToIntBits(this.data); + } + + public long func_150291_c() + { + return (long)this.data; + } + + public int func_150287_d() + { + return MathHelper.floor_float(this.data); + } + + public short func_150289_e() + { + return (short)(MathHelper.floor_float(this.data) & 65535); + } + + public byte func_150290_f() + { + return (byte)(MathHelper.floor_float(this.data) & 255); + } + + public double func_150286_g() + { + return (double)this.data; + } + + public float func_150288_h() + { + return this.data; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/nbt/NBTTagInt.java b/src/main/java/net/minecraft/nbt/NBTTagInt.java new file mode 100644 index 0000000..1f6320f --- /dev/null +++ b/src/main/java/net/minecraft/nbt/NBTTagInt.java @@ -0,0 +1,91 @@ +package net.minecraft.nbt; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +public class NBTTagInt extends NBTBase.NBTPrimitive +{ + private int data; + private static final String __OBFID = "CL_00001223"; + + NBTTagInt() {} + + public NBTTagInt(int p_i45133_1_) + { + this.data = p_i45133_1_; + } + + void write(DataOutput par1DataOutput) throws IOException + { + par1DataOutput.writeInt(this.data); + } + + void load(DataInput par1DataInput, int par2) throws IOException + { + this.data = par1DataInput.readInt(); + } + + public byte getId() + { + return (byte)3; + } + + public String toString() + { + return "" + this.data; + } + + public NBTBase copy() + { + return new NBTTagInt(this.data); + } + + public boolean equals(Object par1Obj) + { + if (super.equals(par1Obj)) + { + NBTTagInt nbttagint = (NBTTagInt)par1Obj; + return this.data == nbttagint.data; + } + else + { + return false; + } + } + + public int hashCode() + { + return super.hashCode() ^ this.data; + } + + public long func_150291_c() + { + return (long)this.data; + } + + public int func_150287_d() + { + return this.data; + } + + public short func_150289_e() + { + return (short)(this.data & 65535); + } + + public byte func_150290_f() + { + return (byte)(this.data & 255); + } + + public double func_150286_g() + { + return (double)this.data; + } + + public float func_150288_h() + { + return (float)this.data; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/nbt/NBTTagIntArray.java b/src/main/java/net/minecraft/nbt/NBTTagIntArray.java new file mode 100644 index 0000000..2cb63af --- /dev/null +++ b/src/main/java/net/minecraft/nbt/NBTTagIntArray.java @@ -0,0 +1,82 @@ +package net.minecraft.nbt; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; +import java.util.Arrays; + +public class NBTTagIntArray extends NBTBase +{ + private int[] intArray; + private static final String __OBFID = "CL_00001221"; + + NBTTagIntArray() {} + + public NBTTagIntArray(int[] p_i45132_1_) + { + this.intArray = p_i45132_1_; + } + + void write(DataOutput par1DataOutput) throws IOException + { + par1DataOutput.writeInt(this.intArray.length); + + for (int i = 0; i < this.intArray.length; ++i) + { + par1DataOutput.writeInt(this.intArray[i]); + } + } + + void load(DataInput par1DataInput, int par2) throws IOException + { + int j = par1DataInput.readInt(); + this.intArray = new int[j]; + + for (int k = 0; k < j; ++k) + { + this.intArray[k] = par1DataInput.readInt(); + } + } + + public byte getId() + { + return (byte)11; + } + + public String toString() + { + String s = "["; + int[] aint = this.intArray; + int i = aint.length; + + for (int j = 0; j < i; ++j) + { + int k = aint[j]; + s = s + k + ","; + } + + return s + "]"; + } + + public NBTBase copy() + { + int[] aint = new int[this.intArray.length]; + System.arraycopy(this.intArray, 0, aint, 0, this.intArray.length); + return new NBTTagIntArray(aint); + } + + public boolean equals(Object par1Obj) + { + return super.equals(par1Obj) ? Arrays.equals(this.intArray, ((NBTTagIntArray)par1Obj).intArray) : false; + } + + public int hashCode() + { + return super.hashCode() ^ Arrays.hashCode(this.intArray); + } + + public int[] func_150302_c() + { + return this.intArray; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/nbt/NBTTagList.java b/src/main/java/net/minecraft/nbt/NBTTagList.java new file mode 100644 index 0000000..8df4b50 --- /dev/null +++ b/src/main/java/net/minecraft/nbt/NBTTagList.java @@ -0,0 +1,228 @@ +package net.minecraft.nbt; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +public class NBTTagList extends NBTBase +{ + private List tagList = new ArrayList(); + private byte tagType = 0; + private static final String __OBFID = "CL_00001224"; + + void write(DataOutput par1DataOutput) throws IOException + { + if (!this.tagList.isEmpty()) + { + this.tagType = ((NBTBase)this.tagList.get(0)).getId(); + } + else + { + this.tagType = 0; + } + + par1DataOutput.writeByte(this.tagType); + par1DataOutput.writeInt(this.tagList.size()); + + for (int i = 0; i < this.tagList.size(); ++i) + { + ((NBTBase)this.tagList.get(i)).write(par1DataOutput); + } + } + + void load(DataInput par1DataInput, int par2) throws IOException + { + if (par2 > 512) + { + throw new RuntimeException("Tried to read NBT tag with too high complexity, depth > 512"); + } + else + { + this.tagType = par1DataInput.readByte(); + int j = par1DataInput.readInt(); + this.tagList = new ArrayList(); + + for (int k = 0; k < j; ++k) + { + NBTBase nbtbase = NBTBase.func_150284_a(this.tagType); + nbtbase.load(par1DataInput, par2 + 1); + this.tagList.add(nbtbase); + } + } + } + + public byte getId() + { + return (byte)9; + } + + public String toString() + { + String s = "["; + int i = 0; + + for (Iterator iterator = this.tagList.iterator(); iterator.hasNext(); ++i) + { + NBTBase nbtbase = (NBTBase)iterator.next(); + s = s + "" + i + ':' + nbtbase + ','; + } + + return s + "]"; + } + + public void appendTag(NBTBase par1NBTBase) + { + if (this.tagType == 0) + { + this.tagType = par1NBTBase.getId(); + } + else if (this.tagType != par1NBTBase.getId()) + { + System.err.println("WARNING: Adding mismatching tag types to tag list"); + return; + } + + this.tagList.add(par1NBTBase); + } + + public void func_150304_a(int p_150304_1_, NBTBase p_150304_2_) + { + if (p_150304_1_ >= 0 && p_150304_1_ < this.tagList.size()) + { + if (this.tagType == 0) + { + this.tagType = p_150304_2_.getId(); + } + else if (this.tagType != p_150304_2_.getId()) + { + System.err.println("WARNING: Adding mismatching tag types to tag list"); + return; + } + + this.tagList.set(p_150304_1_, p_150304_2_); + } + else + { + System.err.println("WARNING: index out of bounds to set tag in tag list"); + } + } + + public NBTBase removeTag(int par1) + { + return (NBTBase)this.tagList.remove(par1); + } + + public NBTTagCompound getCompoundTagAt(int p_150305_1_) + { + if (p_150305_1_ >= 0 && p_150305_1_ < this.tagList.size()) + { + NBTBase nbtbase = (NBTBase)this.tagList.get(p_150305_1_); + return nbtbase.getId() == 10 ? (NBTTagCompound)nbtbase : new NBTTagCompound(); + } + else + { + return new NBTTagCompound(); + } + } + + public int[] func_150306_c(int p_150306_1_) + { + if (p_150306_1_ >= 0 && p_150306_1_ < this.tagList.size()) + { + NBTBase nbtbase = (NBTBase)this.tagList.get(p_150306_1_); + return nbtbase.getId() == 11 ? ((NBTTagIntArray)nbtbase).func_150302_c() : new int[0]; + } + else + { + return new int[0]; + } + } + + public double func_150309_d(int p_150309_1_) + { + if (p_150309_1_ >= 0 && p_150309_1_ < this.tagList.size()) + { + NBTBase nbtbase = (NBTBase)this.tagList.get(p_150309_1_); + return nbtbase.getId() == 6 ? ((NBTTagDouble)nbtbase).func_150286_g() : 0.0D; + } + else + { + return 0.0D; + } + } + + public float func_150308_e(int p_150308_1_) + { + if (p_150308_1_ >= 0 && p_150308_1_ < this.tagList.size()) + { + NBTBase nbtbase = (NBTBase)this.tagList.get(p_150308_1_); + return nbtbase.getId() == 5 ? ((NBTTagFloat)nbtbase).func_150288_h() : 0.0F; + } + else + { + return 0.0F; + } + } + + public String getStringTagAt(int p_150307_1_) + { + if (p_150307_1_ >= 0 && p_150307_1_ < this.tagList.size()) + { + NBTBase nbtbase = (NBTBase)this.tagList.get(p_150307_1_); + return nbtbase.getId() == 8 ? nbtbase.func_150285_a_() : nbtbase.toString(); + } + else + { + return ""; + } + } + + public int tagCount() + { + return this.tagList.size(); + } + + public NBTBase copy() + { + NBTTagList nbttaglist = new NBTTagList(); + nbttaglist.tagType = this.tagType; + Iterator iterator = this.tagList.iterator(); + + while (iterator.hasNext()) + { + NBTBase nbtbase = (NBTBase)iterator.next(); + NBTBase nbtbase1 = nbtbase.copy(); + nbttaglist.tagList.add(nbtbase1); + } + + return nbttaglist; + } + + public boolean equals(Object par1Obj) + { + if (super.equals(par1Obj)) + { + NBTTagList nbttaglist = (NBTTagList)par1Obj; + + if (this.tagType == nbttaglist.tagType) + { + return this.tagList.equals(nbttaglist.tagList); + } + } + + return false; + } + + public int hashCode() + { + return super.hashCode() ^ this.tagList.hashCode(); + } + + public int func_150303_d() + { + return this.tagType; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/nbt/NBTTagLong.java b/src/main/java/net/minecraft/nbt/NBTTagLong.java new file mode 100644 index 0000000..05b7663 --- /dev/null +++ b/src/main/java/net/minecraft/nbt/NBTTagLong.java @@ -0,0 +1,91 @@ +package net.minecraft.nbt; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +public class NBTTagLong extends NBTBase.NBTPrimitive +{ + private long data; + private static final String __OBFID = "CL_00001225"; + + NBTTagLong() {} + + public NBTTagLong(long p_i45134_1_) + { + this.data = p_i45134_1_; + } + + void write(DataOutput par1DataOutput) throws IOException + { + par1DataOutput.writeLong(this.data); + } + + void load(DataInput par1DataInput, int par2) throws IOException + { + this.data = par1DataInput.readLong(); + } + + public byte getId() + { + return (byte)4; + } + + public String toString() + { + return "" + this.data + "L"; + } + + public NBTBase copy() + { + return new NBTTagLong(this.data); + } + + public boolean equals(Object par1Obj) + { + if (super.equals(par1Obj)) + { + NBTTagLong nbttaglong = (NBTTagLong)par1Obj; + return this.data == nbttaglong.data; + } + else + { + return false; + } + } + + public int hashCode() + { + return super.hashCode() ^ (int)(this.data ^ this.data >>> 32); + } + + public long func_150291_c() + { + return this.data; + } + + public int func_150287_d() + { + return (int)(this.data & -1L); + } + + public short func_150289_e() + { + return (short)((int)(this.data & 65535L)); + } + + public byte func_150290_f() + { + return (byte)((int)(this.data & 255L)); + } + + public double func_150286_g() + { + return (double)this.data; + } + + public float func_150288_h() + { + return (float)this.data; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/nbt/NBTTagShort.java b/src/main/java/net/minecraft/nbt/NBTTagShort.java new file mode 100644 index 0000000..86db63f --- /dev/null +++ b/src/main/java/net/minecraft/nbt/NBTTagShort.java @@ -0,0 +1,91 @@ +package net.minecraft.nbt; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +public class NBTTagShort extends NBTBase.NBTPrimitive +{ + private short data; + private static final String __OBFID = "CL_00001227"; + + public NBTTagShort() {} + + public NBTTagShort(short p_i45135_1_) + { + this.data = p_i45135_1_; + } + + void write(DataOutput par1DataOutput) throws IOException + { + par1DataOutput.writeShort(this.data); + } + + void load(DataInput par1DataInput, int par2) throws IOException + { + this.data = par1DataInput.readShort(); + } + + public byte getId() + { + return (byte)2; + } + + public String toString() + { + return "" + this.data + "s"; + } + + public NBTBase copy() + { + return new NBTTagShort(this.data); + } + + public boolean equals(Object par1Obj) + { + if (super.equals(par1Obj)) + { + NBTTagShort nbttagshort = (NBTTagShort)par1Obj; + return this.data == nbttagshort.data; + } + else + { + return false; + } + } + + public int hashCode() + { + return super.hashCode() ^ this.data; + } + + public long func_150291_c() + { + return (long)this.data; + } + + public int func_150287_d() + { + return this.data; + } + + public short func_150289_e() + { + return this.data; + } + + public byte func_150290_f() + { + return (byte)(this.data & 255); + } + + public double func_150286_g() + { + return (double)this.data; + } + + public float func_150288_h() + { + return (float)this.data; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/nbt/NBTTagString.java b/src/main/java/net/minecraft/nbt/NBTTagString.java new file mode 100644 index 0000000..026e8f0 --- /dev/null +++ b/src/main/java/net/minecraft/nbt/NBTTagString.java @@ -0,0 +1,74 @@ +package net.minecraft.nbt; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +public class NBTTagString extends NBTBase +{ + private String data; + private static final String __OBFID = "CL_00001228"; + + public NBTTagString() + { + this.data = ""; + } + + public NBTTagString(String par1Str) + { + this.data = par1Str; + + if (par1Str == null) + { + throw new IllegalArgumentException("Empty string not allowed"); + } + } + + void write(DataOutput par1DataOutput) throws IOException + { + par1DataOutput.writeUTF(this.data); + } + + void load(DataInput par1DataInput, int par2) throws IOException + { + this.data = par1DataInput.readUTF(); + } + + public byte getId() + { + return (byte)8; + } + + public String toString() + { + return "\"" + this.data + "\""; + } + + public NBTBase copy() + { + return new NBTTagString(this.data); + } + + public boolean equals(Object par1Obj) + { + if (!super.equals(par1Obj)) + { + return false; + } + else + { + NBTTagString nbttagstring = (NBTTagString)par1Obj; + return this.data == null && nbttagstring.data == null || this.data != null && this.data.equals(nbttagstring.data); + } + } + + public int hashCode() + { + return super.hashCode() ^ this.data.hashCode(); + } + + public String func_150285_a_() + { + return this.data; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/EnumConnectionState.java b/src/main/java/net/minecraft/network/EnumConnectionState.java new file mode 100644 index 0000000..e5dd5ad --- /dev/null +++ b/src/main/java/net/minecraft/network/EnumConnectionState.java @@ -0,0 +1,356 @@ +package net.minecraft.network; + +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; +import com.google.common.collect.Iterables; +import com.google.common.collect.Maps; +import gnu.trove.map.TIntObjectMap; +import gnu.trove.map.hash.TIntObjectHashMap; +import java.util.Iterator; +import java.util.Map; +import net.minecraft.network.handshake.client.C00Handshake; +import net.minecraft.network.login.client.C00PacketLoginStart; +import net.minecraft.network.login.client.C01PacketEncryptionResponse; +import net.minecraft.network.login.server.S00PacketDisconnect; +import net.minecraft.network.login.server.S01PacketEncryptionRequest; +import net.minecraft.network.login.server.S02PacketLoginSuccess; +import net.minecraft.network.play.client.C00PacketKeepAlive; +import net.minecraft.network.play.client.C01PacketChatMessage; +import net.minecraft.network.play.client.C02PacketUseEntity; +import net.minecraft.network.play.client.C03PacketPlayer; +import net.minecraft.network.play.client.C07PacketPlayerDigging; +import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement; +import net.minecraft.network.play.client.C09PacketHeldItemChange; +import net.minecraft.network.play.client.C0APacketAnimation; +import net.minecraft.network.play.client.C0BPacketEntityAction; +import net.minecraft.network.play.client.C0CPacketInput; +import net.minecraft.network.play.client.C0DPacketCloseWindow; +import net.minecraft.network.play.client.C0EPacketClickWindow; +import net.minecraft.network.play.client.C0FPacketConfirmTransaction; +import net.minecraft.network.play.client.C10PacketCreativeInventoryAction; +import net.minecraft.network.play.client.C11PacketEnchantItem; +import net.minecraft.network.play.client.C12PacketUpdateSign; +import net.minecraft.network.play.client.C13PacketPlayerAbilities; +import net.minecraft.network.play.client.C14PacketTabComplete; +import net.minecraft.network.play.client.C15PacketClientSettings; +import net.minecraft.network.play.client.C16PacketClientStatus; +import net.minecraft.network.play.client.C17PacketCustomPayload; +import net.minecraft.network.play.server.S00PacketKeepAlive; +import net.minecraft.network.play.server.S01PacketJoinGame; +import net.minecraft.network.play.server.S02PacketChat; +import net.minecraft.network.play.server.S03PacketTimeUpdate; +import net.minecraft.network.play.server.S04PacketEntityEquipment; +import net.minecraft.network.play.server.S05PacketSpawnPosition; +import net.minecraft.network.play.server.S06PacketUpdateHealth; +import net.minecraft.network.play.server.S07PacketRespawn; +import net.minecraft.network.play.server.S08PacketPlayerPosLook; +import net.minecraft.network.play.server.S09PacketHeldItemChange; +import net.minecraft.network.play.server.S0APacketUseBed; +import net.minecraft.network.play.server.S0BPacketAnimation; +import net.minecraft.network.play.server.S0CPacketSpawnPlayer; +import net.minecraft.network.play.server.S0DPacketCollectItem; +import net.minecraft.network.play.server.S0EPacketSpawnObject; +import net.minecraft.network.play.server.S0FPacketSpawnMob; +import net.minecraft.network.play.server.S10PacketSpawnPainting; +import net.minecraft.network.play.server.S11PacketSpawnExperienceOrb; +import net.minecraft.network.play.server.S12PacketEntityVelocity; +import net.minecraft.network.play.server.S13PacketDestroyEntities; +import net.minecraft.network.play.server.S14PacketEntity; +import net.minecraft.network.play.server.S18PacketEntityTeleport; +import net.minecraft.network.play.server.S19PacketEntityHeadLook; +import net.minecraft.network.play.server.S19PacketEntityStatus; +import net.minecraft.network.play.server.S1BPacketEntityAttach; +import net.minecraft.network.play.server.S1CPacketEntityMetadata; +import net.minecraft.network.play.server.S1DPacketEntityEffect; +import net.minecraft.network.play.server.S1EPacketRemoveEntityEffect; +import net.minecraft.network.play.server.S1FPacketSetExperience; +import net.minecraft.network.play.server.S20PacketEntityProperties; +import net.minecraft.network.play.server.S21PacketChunkData; +import net.minecraft.network.play.server.S22PacketMultiBlockChange; +import net.minecraft.network.play.server.S23PacketBlockChange; +import net.minecraft.network.play.server.S24PacketBlockAction; +import net.minecraft.network.play.server.S25PacketBlockBreakAnim; +import net.minecraft.network.play.server.S26PacketMapChunkBulk; +import net.minecraft.network.play.server.S27PacketExplosion; +import net.minecraft.network.play.server.S28PacketEffect; +import net.minecraft.network.play.server.S29PacketSoundEffect; +import net.minecraft.network.play.server.S2APacketParticles; +import net.minecraft.network.play.server.S2BPacketChangeGameState; +import net.minecraft.network.play.server.S2CPacketSpawnGlobalEntity; +import net.minecraft.network.play.server.S2DPacketOpenWindow; +import net.minecraft.network.play.server.S2EPacketCloseWindow; +import net.minecraft.network.play.server.S2FPacketSetSlot; +import net.minecraft.network.play.server.S30PacketWindowItems; +import net.minecraft.network.play.server.S31PacketWindowProperty; +import net.minecraft.network.play.server.S32PacketConfirmTransaction; +import net.minecraft.network.play.server.S33PacketUpdateSign; +import net.minecraft.network.play.server.S34PacketMaps; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.network.play.server.S36PacketSignEditorOpen; +import net.minecraft.network.play.server.S37PacketStatistics; +import net.minecraft.network.play.server.S38PacketPlayerListItem; +import net.minecraft.network.play.server.S39PacketPlayerAbilities; +import net.minecraft.network.play.server.S3APacketTabComplete; +import net.minecraft.network.play.server.S3BPacketScoreboardObjective; +import net.minecraft.network.play.server.S3CPacketUpdateScore; +import net.minecraft.network.play.server.S3DPacketDisplayScoreboard; +import net.minecraft.network.play.server.S3EPacketTeams; +import net.minecraft.network.play.server.S3FPacketCustomPayload; +import net.minecraft.network.play.server.S40PacketDisconnect; +import net.minecraft.network.status.client.C00PacketServerQuery; +import net.minecraft.network.status.client.C01PacketPing; +import net.minecraft.network.status.server.S00PacketServerInfo; +import net.minecraft.network.status.server.S01PacketPong; +import org.apache.logging.log4j.LogManager; + +public enum EnumConnectionState +{ + HANDSHAKING(-1) + { + private static final String __OBFID = "CL_00001249"; + { + this.func_150751_a(0, C00Handshake.class); + } + }, + PLAY(0) + { + private static final String __OBFID = "CL_00001247"; + { + this.func_150756_b(0, S00PacketKeepAlive.class); + this.func_150756_b(1, S01PacketJoinGame.class); + this.func_150756_b(2, S02PacketChat.class); + this.func_150756_b(3, S03PacketTimeUpdate.class); + this.func_150756_b(4, S04PacketEntityEquipment.class); + this.func_150756_b(5, S05PacketSpawnPosition.class); + this.func_150756_b(6, S06PacketUpdateHealth.class); + this.func_150756_b(7, S07PacketRespawn.class); + this.func_150756_b(8, S08PacketPlayerPosLook.class); + this.func_150756_b(9, S09PacketHeldItemChange.class); + this.func_150756_b(10, S0APacketUseBed.class); + this.func_150756_b(11, S0BPacketAnimation.class); + this.func_150756_b(12, S0CPacketSpawnPlayer.class); + this.func_150756_b(13, S0DPacketCollectItem.class); + this.func_150756_b(14, S0EPacketSpawnObject.class); + this.func_150756_b(15, S0FPacketSpawnMob.class); + this.func_150756_b(16, S10PacketSpawnPainting.class); + this.func_150756_b(17, S11PacketSpawnExperienceOrb.class); + this.func_150756_b(18, S12PacketEntityVelocity.class); + this.func_150756_b(19, S13PacketDestroyEntities.class); + this.func_150756_b(20, S14PacketEntity.class); + this.func_150756_b(21, S14PacketEntity.S15PacketEntityRelMove.class); + this.func_150756_b(22, S14PacketEntity.S16PacketEntityLook.class); + this.func_150756_b(23, S14PacketEntity.S17PacketEntityLookMove.class); + this.func_150756_b(24, S18PacketEntityTeleport.class); + this.func_150756_b(25, S19PacketEntityHeadLook.class); + this.func_150756_b(26, S19PacketEntityStatus.class); + this.func_150756_b(27, S1BPacketEntityAttach.class); + this.func_150756_b(28, S1CPacketEntityMetadata.class); + this.func_150756_b(29, S1DPacketEntityEffect.class); + this.func_150756_b(30, S1EPacketRemoveEntityEffect.class); + this.func_150756_b(31, S1FPacketSetExperience.class); + this.func_150756_b(32, S20PacketEntityProperties.class); + this.func_150756_b(33, S21PacketChunkData.class); + this.func_150756_b(34, S22PacketMultiBlockChange.class); + this.func_150756_b(35, S23PacketBlockChange.class); + this.func_150756_b(36, S24PacketBlockAction.class); + this.func_150756_b(37, S25PacketBlockBreakAnim.class); + this.func_150756_b(38, S26PacketMapChunkBulk.class); + this.func_150756_b(39, S27PacketExplosion.class); + this.func_150756_b(40, S28PacketEffect.class); + this.func_150756_b(41, S29PacketSoundEffect.class); + this.func_150756_b(42, S2APacketParticles.class); + this.func_150756_b(43, S2BPacketChangeGameState.class); + this.func_150756_b(44, S2CPacketSpawnGlobalEntity.class); + this.func_150756_b(45, S2DPacketOpenWindow.class); + this.func_150756_b(46, S2EPacketCloseWindow.class); + this.func_150756_b(47, S2FPacketSetSlot.class); + this.func_150756_b(48, S30PacketWindowItems.class); + this.func_150756_b(49, S31PacketWindowProperty.class); + this.func_150756_b(50, S32PacketConfirmTransaction.class); + this.func_150756_b(51, S33PacketUpdateSign.class); + this.func_150756_b(52, S34PacketMaps.class); + this.func_150756_b(53, S35PacketUpdateTileEntity.class); + this.func_150756_b(54, S36PacketSignEditorOpen.class); + this.func_150756_b(55, S37PacketStatistics.class); + this.func_150756_b(56, S38PacketPlayerListItem.class); + this.func_150756_b(57, S39PacketPlayerAbilities.class); + this.func_150756_b(58, S3APacketTabComplete.class); + this.func_150756_b(59, S3BPacketScoreboardObjective.class); + this.func_150756_b(60, S3CPacketUpdateScore.class); + this.func_150756_b(61, S3DPacketDisplayScoreboard.class); + this.func_150756_b(62, S3EPacketTeams.class); + this.func_150756_b(63, S3FPacketCustomPayload.class); + this.func_150756_b(64, S40PacketDisconnect.class); + this.func_150751_a(0, C00PacketKeepAlive.class); + this.func_150751_a(1, C01PacketChatMessage.class); + this.func_150751_a(2, C02PacketUseEntity.class); + this.func_150751_a(3, C03PacketPlayer.class); + this.func_150751_a(4, C03PacketPlayer.C04PacketPlayerPosition.class); + this.func_150751_a(5, C03PacketPlayer.C05PacketPlayerLook.class); + this.func_150751_a(6, C03PacketPlayer.C06PacketPlayerPosLook.class); + this.func_150751_a(7, C07PacketPlayerDigging.class); + this.func_150751_a(8, C08PacketPlayerBlockPlacement.class); + this.func_150751_a(9, C09PacketHeldItemChange.class); + this.func_150751_a(10, C0APacketAnimation.class); + this.func_150751_a(11, C0BPacketEntityAction.class); + this.func_150751_a(12, C0CPacketInput.class); + this.func_150751_a(13, C0DPacketCloseWindow.class); + this.func_150751_a(14, C0EPacketClickWindow.class); + this.func_150751_a(15, C0FPacketConfirmTransaction.class); + this.func_150751_a(16, C10PacketCreativeInventoryAction.class); + this.func_150751_a(17, C11PacketEnchantItem.class); + this.func_150751_a(18, C12PacketUpdateSign.class); + this.func_150751_a(19, C13PacketPlayerAbilities.class); + this.func_150751_a(20, C14PacketTabComplete.class); + this.func_150751_a(21, C15PacketClientSettings.class); + this.func_150751_a(22, C16PacketClientStatus.class); + this.func_150751_a(23, C17PacketCustomPayload.class); + } + }, + STATUS(1) + { + private static final String __OBFID = "CL_00001246"; + { + this.func_150751_a(0, C00PacketServerQuery.class); + this.func_150756_b(0, S00PacketServerInfo.class); + this.func_150751_a(1, C01PacketPing.class); + this.func_150756_b(1, S01PacketPong.class); + } + }, + LOGIN(2) + { + private static final String __OBFID = "CL_00001250"; + { + this.func_150756_b(0, S00PacketDisconnect.class); + this.func_150756_b(1, S01PacketEncryptionRequest.class); + this.func_150756_b(2, S02PacketLoginSuccess.class); + this.func_150751_a(0, C00PacketLoginStart.class); + this.func_150751_a(1, C01PacketEncryptionResponse.class); + } + }; + private static final TIntObjectMap field_150764_e = new TIntObjectHashMap(); + private static final Map field_150761_f = Maps.newHashMap(); + private final int field_150762_g; + private final BiMap field_150769_h; + private final BiMap field_150770_i; + + private static final String __OBFID = "CL_00001245"; + + private EnumConnectionState(int p_i45152_3_) + { + this.field_150769_h = HashBiMap.create(); + this.field_150770_i = HashBiMap.create(); + this.field_150762_g = p_i45152_3_; + } + + protected EnumConnectionState func_150751_a(int p_150751_1_, Class p_150751_2_) + { + String s; + + if (this.field_150769_h.containsKey(Integer.valueOf(p_150751_1_))) + { + s = "Serverbound packet ID " + p_150751_1_ + " is already assigned to " + this.field_150769_h.get(Integer.valueOf(p_150751_1_)) + "; cannot re-assign to " + p_150751_2_; + LogManager.getLogger().fatal(s); + throw new IllegalArgumentException(s); + } + else if (this.field_150769_h.containsValue(p_150751_2_)) + { + s = "Serverbound packet " + p_150751_2_ + " is already assigned to ID " + this.field_150769_h.inverse().get(p_150751_2_) + "; cannot re-assign to " + p_150751_1_; + LogManager.getLogger().fatal(s); + throw new IllegalArgumentException(s); + } + else + { + this.field_150769_h.put(Integer.valueOf(p_150751_1_), p_150751_2_); + return this; + } + } + + protected EnumConnectionState func_150756_b(int p_150756_1_, Class p_150756_2_) + { + String s; + + if (this.field_150770_i.containsKey(Integer.valueOf(p_150756_1_))) + { + s = "Clientbound packet ID " + p_150756_1_ + " is already assigned to " + this.field_150770_i.get(Integer.valueOf(p_150756_1_)) + "; cannot re-assign to " + p_150756_2_; + LogManager.getLogger().fatal(s); + throw new IllegalArgumentException(s); + } + else if (this.field_150770_i.containsValue(p_150756_2_)) + { + s = "Clientbound packet " + p_150756_2_ + " is already assigned to ID " + this.field_150770_i.inverse().get(p_150756_2_) + "; cannot re-assign to " + p_150756_1_; + LogManager.getLogger().fatal(s); + throw new IllegalArgumentException(s); + } + else + { + this.field_150770_i.put(Integer.valueOf(p_150756_1_), p_150756_2_); + return this; + } + } + + public BiMap func_150753_a() + { + return this.field_150769_h; + } + + public BiMap func_150755_b() + { + return this.field_150770_i; + } + + public BiMap func_150757_a(boolean p_150757_1_) + { + return p_150757_1_ ? this.func_150755_b() : this.func_150753_a(); + } + + public BiMap func_150754_b(boolean p_150754_1_) + { + return p_150754_1_ ? this.func_150753_a() : this.func_150755_b(); + } + + public int func_150759_c() + { + return this.field_150762_g; + } + + public static EnumConnectionState func_150760_a(int p_150760_0_) + { + return (EnumConnectionState)field_150764_e.get(p_150760_0_); + } + + public static EnumConnectionState func_150752_a(Packet p_150752_0_) + { + return (EnumConnectionState)field_150761_f.get(p_150752_0_.getClass()); + } + + EnumConnectionState(int i, Object object) + { + this(i); + } + + static + { + EnumConnectionState[] var0 = values(); + int var1 = var0.length; + + for (int var2 = 0; var2 < var1; ++var2) + { + EnumConnectionState var3 = var0[var2]; + field_150764_e.put(var3.func_150759_c(), var3); + Iterator var4 = Iterables.concat(var3.func_150755_b().values(), var3.func_150753_a().values()).iterator(); + + while (var4.hasNext()) + { + Class var5 = (Class)var4.next(); + + if (field_150761_f.containsKey(var5) && field_150761_f.get(var5) != var3) + { + throw new Error("Packet " + var5 + " is already assigned to protocol " + field_150761_f.get(var5) + " - can\'t reassign to " + var3); + } + + field_150761_f.put(var5, var3); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/INetHandler.java b/src/main/java/net/minecraft/network/INetHandler.java new file mode 100644 index 0000000..f7c41f7 --- /dev/null +++ b/src/main/java/net/minecraft/network/INetHandler.java @@ -0,0 +1,12 @@ +package net.minecraft.network; + +import net.minecraft.util.IChatComponent; + +public interface INetHandler +{ + void onDisconnect(IChatComponent var1); + + void onConnectionStateTransition(EnumConnectionState var1, EnumConnectionState var2); + + void onNetworkTick(); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/NetHandlerPlayServer.java b/src/main/java/net/minecraft/network/NetHandlerPlayServer.java new file mode 100644 index 0000000..429851a --- /dev/null +++ b/src/main/java/net/minecraft/network/NetHandlerPlayServer.java @@ -0,0 +1,1279 @@ +package net.minecraft.network; + +import com.google.common.base.Charsets; +import com.google.common.collect.Lists; +import io.netty.buffer.Unpooled; +import io.netty.util.concurrent.Future; +import io.netty.util.concurrent.GenericFutureListener; +import java.io.ByteArrayInputStream; +import java.io.DataInputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.Random; +import java.util.concurrent.Callable; +import net.minecraft.block.material.Material; +import net.minecraft.command.server.CommandBlockLogic; +import net.minecraft.crash.CrashReport; +import net.minecraft.crash.CrashReportCategory; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityMinecartCommandBlock; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.item.EntityXPOrb; +import net.minecraft.entity.passive.EntityHorse; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.init.Items; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ContainerBeacon; +import net.minecraft.inventory.ContainerMerchant; +import net.minecraft.inventory.ContainerRepair; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemEditableBook; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemWritableBook; +import net.minecraft.nbt.NBTTagString; +import net.minecraft.network.play.INetHandlerPlayServer; +import net.minecraft.network.play.client.C00PacketKeepAlive; +import net.minecraft.network.play.client.C01PacketChatMessage; +import net.minecraft.network.play.client.C02PacketUseEntity; +import net.minecraft.network.play.client.C03PacketPlayer; +import net.minecraft.network.play.client.C07PacketPlayerDigging; +import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement; +import net.minecraft.network.play.client.C09PacketHeldItemChange; +import net.minecraft.network.play.client.C0APacketAnimation; +import net.minecraft.network.play.client.C0BPacketEntityAction; +import net.minecraft.network.play.client.C0CPacketInput; +import net.minecraft.network.play.client.C0DPacketCloseWindow; +import net.minecraft.network.play.client.C0EPacketClickWindow; +import net.minecraft.network.play.client.C0FPacketConfirmTransaction; +import net.minecraft.network.play.client.C10PacketCreativeInventoryAction; +import net.minecraft.network.play.client.C11PacketEnchantItem; +import net.minecraft.network.play.client.C12PacketUpdateSign; +import net.minecraft.network.play.client.C13PacketPlayerAbilities; +import net.minecraft.network.play.client.C14PacketTabComplete; +import net.minecraft.network.play.client.C15PacketClientSettings; +import net.minecraft.network.play.client.C16PacketClientStatus; +import net.minecraft.network.play.client.C17PacketCustomPayload; +import net.minecraft.network.play.server.S00PacketKeepAlive; +import net.minecraft.network.play.server.S02PacketChat; +import net.minecraft.network.play.server.S08PacketPlayerPosLook; +import net.minecraft.network.play.server.S23PacketBlockChange; +import net.minecraft.network.play.server.S2FPacketSetSlot; +import net.minecraft.network.play.server.S32PacketConfirmTransaction; +import net.minecraft.network.play.server.S3APacketTabComplete; +import net.minecraft.network.play.server.S40PacketDisconnect; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.management.BanEntry; +import net.minecraft.stats.AchievementList; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityBeacon; +import net.minecraft.tileentity.TileEntityCommandBlock; +import net.minecraft.tileentity.TileEntitySign; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.ChatAllowedCharacters; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IChatComponent; +import net.minecraft.util.IntHashMap; +import net.minecraft.util.ReportedException; +import net.minecraft.world.WorldServer; +import org.apache.commons.lang3.StringUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import net.minecraftforge.common.ForgeHooks; +import net.minecraftforge.common.MinecraftForge; +import cpw.mods.fml.common.eventhandler.Event; +import net.minecraftforge.event.ForgeEventFactory; +import net.minecraftforge.event.ServerChatEvent; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; +import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action; + +public class NetHandlerPlayServer implements INetHandlerPlayServer +{ + private static final Logger logger = LogManager.getLogger(); + public final NetworkManager netManager; + private final MinecraftServer serverController; + public EntityPlayerMP playerEntity; + private int networkTickCount; + private int floatingTickCount; + private boolean field_147366_g; + private int field_147378_h; + private long field_147379_i; + private static Random field_147376_j = new Random(); + private long field_147377_k; + private int chatSpamThresholdCount; + private int field_147375_m; + private IntHashMap field_147372_n = new IntHashMap(); + private double lastPosX; + private double lastPosY; + private double lastPosZ; + private boolean hasMoved = true; + private static final String __OBFID = "CL_00001452"; + + public NetHandlerPlayServer(MinecraftServer par1MinecraftServer, NetworkManager par2INetworkManager, EntityPlayerMP par3EntityPlayerMP) + { + this.serverController = par1MinecraftServer; + this.netManager = par2INetworkManager; + par2INetworkManager.setNetHandler(this); + this.playerEntity = par3EntityPlayerMP; + par3EntityPlayerMP.playerNetServerHandler = this; + } + + public void onNetworkTick() + { + this.field_147366_g = false; + ++this.networkTickCount; + this.serverController.theProfiler.startSection("keepAlive"); + + if ((long)this.networkTickCount - this.field_147377_k > 40L) + { + this.field_147377_k = (long)this.networkTickCount; + this.field_147379_i = this.func_147363_d(); + this.field_147378_h = (int)this.field_147379_i; + this.sendPacket(new S00PacketKeepAlive(this.field_147378_h)); + } + + if (this.chatSpamThresholdCount > 0) + { + --this.chatSpamThresholdCount; + } + + if (this.field_147375_m > 0) + { + --this.field_147375_m; + } + + this.serverController.theProfiler.endStartSection("playerTick"); + this.serverController.theProfiler.endSection(); + } + + public NetworkManager func_147362_b() + { + return this.netManager; + } + + public void kickPlayerFromServer(String p_147360_1_) + { + final ChatComponentText chatcomponenttext = new ChatComponentText(p_147360_1_); + this.netManager.scheduleOutboundPacket(new S40PacketDisconnect(chatcomponenttext), new GenericFutureListener[] {new GenericFutureListener() + { + private static final String __OBFID = "CL_00001453"; + public void operationComplete(Future p_operationComplete_1_) + { + NetHandlerPlayServer.this.netManager.closeChannel(chatcomponenttext); + } + } + }); + this.netManager.disableAutoRead(); + } + + public void processInput(C0CPacketInput p_147358_1_) + { + this.playerEntity.setEntityActionState(p_147358_1_.func_149620_c(), p_147358_1_.func_149616_d(), p_147358_1_.func_149618_e(), p_147358_1_.func_149617_f()); + } + + public void processPlayer(C03PacketPlayer p_147347_1_) + { + WorldServer worldserver = this.serverController.worldServerForDimension(this.playerEntity.dimension); + this.field_147366_g = true; + + if (!this.playerEntity.playerConqueredTheEnd) + { + double d0; + + if (!this.hasMoved) + { + d0 = p_147347_1_.func_149467_d() - this.lastPosY; + + if (p_147347_1_.func_149464_c() == this.lastPosX && d0 * d0 < 0.01D && p_147347_1_.func_149472_e() == this.lastPosZ) + { + this.hasMoved = true; + } + } + + if (this.hasMoved) + { + double d1; + double d2; + double d3; + + if (this.playerEntity.ridingEntity != null) + { + float f4 = this.playerEntity.rotationYaw; + float f = this.playerEntity.rotationPitch; + this.playerEntity.ridingEntity.updateRiderPosition(); + d1 = this.playerEntity.posX; + d2 = this.playerEntity.posY; + d3 = this.playerEntity.posZ; + + if (p_147347_1_.func_149463_k()) + { + f4 = p_147347_1_.func_149462_g(); + f = p_147347_1_.func_149470_h(); + } + + this.playerEntity.onGround = p_147347_1_.func_149465_i(); + this.playerEntity.onUpdateEntity(); + this.playerEntity.ySize = 0.0F; + this.playerEntity.setPositionAndRotation(d1, d2, d3, f4, f); + + if (this.playerEntity.ridingEntity != null) + { + this.playerEntity.ridingEntity.updateRiderPosition(); + } + + if (!this.hasMoved) //Fixes teleportation kick while riding entities + { + return; + } + + this.serverController.getConfigurationManager().updatePlayerPertinentChunks(this.playerEntity); + + if (this.hasMoved) + { + this.lastPosX = this.playerEntity.posX; + this.lastPosY = this.playerEntity.posY; + this.lastPosZ = this.playerEntity.posZ; + } + + worldserver.updateEntity(this.playerEntity); + return; + } + + if (this.playerEntity.isPlayerSleeping()) + { + this.playerEntity.onUpdateEntity(); + this.playerEntity.setPositionAndRotation(this.lastPosX, this.lastPosY, this.lastPosZ, this.playerEntity.rotationYaw, this.playerEntity.rotationPitch); + worldserver.updateEntity(this.playerEntity); + return; + } + + d0 = this.playerEntity.posY; + this.lastPosX = this.playerEntity.posX; + this.lastPosY = this.playerEntity.posY; + this.lastPosZ = this.playerEntity.posZ; + d1 = this.playerEntity.posX; + d2 = this.playerEntity.posY; + d3 = this.playerEntity.posZ; + float f1 = this.playerEntity.rotationYaw; + float f2 = this.playerEntity.rotationPitch; + + if (p_147347_1_.func_149466_j() && p_147347_1_.func_149467_d() == -999.0D && p_147347_1_.func_149471_f() == -999.0D) + { + p_147347_1_.func_149469_a(false); + } + + double d4; + + if (p_147347_1_.func_149466_j()) + { + d1 = p_147347_1_.func_149464_c(); + d2 = p_147347_1_.func_149467_d(); + d3 = p_147347_1_.func_149472_e(); + d4 = p_147347_1_.func_149471_f() - p_147347_1_.func_149467_d(); + + if (!this.playerEntity.isPlayerSleeping() && (d4 > 1.65D || d4 < 0.1D)) + { + this.kickPlayerFromServer("Illegal stance"); + logger.warn(this.playerEntity.getCommandSenderName() + " had an illegal stance: " + d4); + return; + } + + if (Math.abs(p_147347_1_.func_149464_c()) > 3.2E7D || Math.abs(p_147347_1_.func_149472_e()) > 3.2E7D) + { + this.kickPlayerFromServer("Illegal position"); + return; + } + } + + if (p_147347_1_.func_149463_k()) + { + f1 = p_147347_1_.func_149462_g(); + f2 = p_147347_1_.func_149470_h(); + } + + this.playerEntity.onUpdateEntity(); + this.playerEntity.ySize = 0.0F; + this.playerEntity.setPositionAndRotation(this.lastPosX, this.lastPosY, this.lastPosZ, f1, f2); + + if (!this.hasMoved) + { + return; + } + + d4 = d1 - this.playerEntity.posX; + double d5 = d2 - this.playerEntity.posY; + double d6 = d3 - this.playerEntity.posZ; + //BUGFIX: min -> max, grabs the highest distance + double d7 = Math.max(Math.abs(d4), Math.abs(this.playerEntity.motionX)); + double d8 = Math.max(Math.abs(d5), Math.abs(this.playerEntity.motionY)); + double d9 = Math.max(Math.abs(d6), Math.abs(this.playerEntity.motionZ)); + double d10 = d7 * d7 + d8 * d8 + d9 * d9; + + if (d10 > 100.0D && (!this.serverController.isSinglePlayer() || !this.serverController.getServerOwner().equals(this.playerEntity.getCommandSenderName()))) + { + logger.warn(this.playerEntity.getCommandSenderName() + " moved too quickly! " + d4 + "," + d5 + "," + d6 + " (" + d7 + ", " + d8 + ", " + d9 + ")"); + this.setPlayerLocation(this.lastPosX, this.lastPosY, this.lastPosZ, this.playerEntity.rotationYaw, this.playerEntity.rotationPitch); + return; + } + + float f3 = 0.0625F; + boolean flag = worldserver.getCollidingBoundingBoxes(this.playerEntity, this.playerEntity.boundingBox.copy().contract((double)f3, (double)f3, (double)f3)).isEmpty(); + + if (this.playerEntity.onGround && !p_147347_1_.func_149465_i() && d5 > 0.0D) + { + this.playerEntity.jump(); + } + + if (!this.hasMoved) //Fixes "Moved Too Fast" kick when being teleported while moving + { + return; + } + + this.playerEntity.moveEntity(d4, d5, d6); + this.playerEntity.onGround = p_147347_1_.func_149465_i(); + this.playerEntity.addMovementStat(d4, d5, d6); + double d11 = d5; + d4 = d1 - this.playerEntity.posX; + d5 = d2 - this.playerEntity.posY; + + if (d5 > -0.5D || d5 < 0.5D) + { + d5 = 0.0D; + } + + d6 = d3 - this.playerEntity.posZ; + d10 = d4 * d4 + d5 * d5 + d6 * d6; + boolean flag1 = false; + + if (d10 > 0.0625D && !this.playerEntity.isPlayerSleeping() && !this.playerEntity.theItemInWorldManager.isCreative()) + { + flag1 = true; + logger.warn(this.playerEntity.getCommandSenderName() + " moved wrongly!"); + } + + if (!this.hasMoved) //Fixes "Moved Too Fast" kick when being teleported while moving + { + return; + } + + this.playerEntity.setPositionAndRotation(d1, d2, d3, f1, f2); + boolean flag2 = worldserver.getCollidingBoundingBoxes(this.playerEntity, this.playerEntity.boundingBox.copy().contract((double)f3, (double)f3, (double)f3)).isEmpty(); + + if (flag && (flag1 || !flag2) && !this.playerEntity.isPlayerSleeping() && !this.playerEntity.noClip) + { + this.setPlayerLocation(this.lastPosX, this.lastPosY, this.lastPosZ, f1, f2); + return; + } + + AxisAlignedBB axisalignedbb = this.playerEntity.boundingBox.copy().expand((double)f3, (double)f3, (double)f3).addCoord(0.0D, -0.55D, 0.0D); + + if (!this.serverController.isFlightAllowed() && !this.playerEntity.theItemInWorldManager.isCreative() && !worldserver.checkBlockCollision(axisalignedbb) && !this.playerEntity.capabilities.allowFlying) + { + if (d11 >= -0.03125D) + { + ++this.floatingTickCount; + + if (this.floatingTickCount > 80) + { + logger.warn(this.playerEntity.getCommandSenderName() + " was kicked for floating too long!"); + this.kickPlayerFromServer("Flying is not enabled on this server"); + return; + } + } + } + else + { + this.floatingTickCount = 0; + } + + if (!this.hasMoved) //Fixes "Moved Too Fast" kick when being teleported while moving + { + return; + } + + this.playerEntity.onGround = p_147347_1_.func_149465_i(); + this.serverController.getConfigurationManager().updatePlayerPertinentChunks(this.playerEntity); + this.playerEntity.handleFalling(this.playerEntity.posY - d0, p_147347_1_.func_149465_i()); + } + else if (this.networkTickCount % 20 == 0) + { + this.setPlayerLocation(this.lastPosX, this.lastPosY, this.lastPosZ, this.playerEntity.rotationYaw, this.playerEntity.rotationPitch); + } + } + } + + public void setPlayerLocation(double p_147364_1_, double p_147364_3_, double p_147364_5_, float p_147364_7_, float p_147364_8_) + { + this.hasMoved = false; + this.lastPosX = p_147364_1_; + this.lastPosY = p_147364_3_; + this.lastPosZ = p_147364_5_; + this.playerEntity.setPositionAndRotation(p_147364_1_, p_147364_3_, p_147364_5_, p_147364_7_, p_147364_8_); + this.playerEntity.playerNetServerHandler.sendPacket(new S08PacketPlayerPosLook(p_147364_1_, p_147364_3_ + 1.6200000047683716D, p_147364_5_, p_147364_7_, p_147364_8_, false)); + } + + public void processPlayerDigging(C07PacketPlayerDigging p_147345_1_) + { + WorldServer worldserver = this.serverController.worldServerForDimension(this.playerEntity.dimension); + this.playerEntity.func_143004_u(); + + if (p_147345_1_.func_149506_g() == 4) + { + this.playerEntity.dropOneItem(false); + } + else if (p_147345_1_.func_149506_g() == 3) + { + this.playerEntity.dropOneItem(true); + } + else if (p_147345_1_.func_149506_g() == 5) + { + this.playerEntity.stopUsingItem(); + } + else + { + boolean flag = false; + + if (p_147345_1_.func_149506_g() == 0) + { + flag = true; + } + + if (p_147345_1_.func_149506_g() == 1) + { + flag = true; + } + + if (p_147345_1_.func_149506_g() == 2) + { + flag = true; + } + + int i = p_147345_1_.func_149505_c(); + int j = p_147345_1_.func_149503_d(); + int k = p_147345_1_.func_149502_e(); + + if (flag) + { + double d0 = this.playerEntity.posX - ((double)i + 0.5D); + double d1 = this.playerEntity.posY - ((double)j + 0.5D) + 1.5D; + double d2 = this.playerEntity.posZ - ((double)k + 0.5D); + double d3 = d0 * d0 + d1 * d1 + d2 * d2; + + double dist = playerEntity.theItemInWorldManager.getBlockReachDistance() + 1; + dist *= dist; + + if (d3 > dist) + { + return; + } + + if (j >= this.serverController.getBuildLimit()) + { + return; + } + } + + if (p_147345_1_.func_149506_g() == 0) + { + if (!this.serverController.isBlockProtected(worldserver, i, j, k, this.playerEntity)) + { + this.playerEntity.theItemInWorldManager.onBlockClicked(i, j, k, p_147345_1_.func_149501_f()); + } + else + { + this.playerEntity.playerNetServerHandler.sendPacket(new S23PacketBlockChange(i, j, k, worldserver)); + } + } + else if (p_147345_1_.func_149506_g() == 2) + { + this.playerEntity.theItemInWorldManager.uncheckedTryHarvestBlock(i, j, k); + + if (worldserver.getBlock(i, j, k).getMaterial() != Material.air) + { + this.playerEntity.playerNetServerHandler.sendPacket(new S23PacketBlockChange(i, j, k, worldserver)); + } + } + else if (p_147345_1_.func_149506_g() == 1) + { + this.playerEntity.theItemInWorldManager.cancelDestroyingBlock(i, j, k); + + if (worldserver.getBlock(i, j, k).getMaterial() != Material.air) + { + this.playerEntity.playerNetServerHandler.sendPacket(new S23PacketBlockChange(i, j, k, worldserver)); + } + } + } + } + + public void processPlayerBlockPlacement(C08PacketPlayerBlockPlacement p_147346_1_) + { + WorldServer worldserver = this.serverController.worldServerForDimension(this.playerEntity.dimension); + ItemStack itemstack = this.playerEntity.inventory.getCurrentItem(); + boolean flag = false; + int i = p_147346_1_.func_149576_c(); + int j = p_147346_1_.func_149571_d(); + int k = p_147346_1_.func_149570_e(); + int l = p_147346_1_.func_149568_f(); + this.playerEntity.func_143004_u(); + + if (p_147346_1_.func_149568_f() == 255) + { + if (itemstack == null) + { + return; + } + + PlayerInteractEvent event = ForgeEventFactory.onPlayerInteract(playerEntity, PlayerInteractEvent.Action.RIGHT_CLICK_AIR, 0, 0, 0, -1); + if (event.useItem != Event.Result.DENY) + { + this.playerEntity.theItemInWorldManager.tryUseItem(this.playerEntity, worldserver, itemstack); + } + } + else if (p_147346_1_.func_149571_d() >= this.serverController.getBuildLimit() - 1 && (p_147346_1_.func_149568_f() == 1 || p_147346_1_.func_149571_d() >= this.serverController.getBuildLimit())) + { + ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("build.tooHigh", new Object[] {Integer.valueOf(this.serverController.getBuildLimit())}); + chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.RED); + this.playerEntity.playerNetServerHandler.sendPacket(new S02PacketChat(chatcomponenttranslation)); + flag = true; + } + else + { + double dist = playerEntity.theItemInWorldManager.getBlockReachDistance() + 1; + dist *= dist; + if (this.hasMoved && this.playerEntity.getDistanceSq((double)i + 0.5D, (double)j + 0.5D, (double)k + 0.5D) < dist && !this.serverController.isBlockProtected(worldserver, i, j, k, this.playerEntity)) + { + this.playerEntity.theItemInWorldManager.activateBlockOrUseItem(this.playerEntity, worldserver, itemstack, i, j, k, l, p_147346_1_.func_149573_h(), p_147346_1_.func_149569_i(), p_147346_1_.func_149575_j()); + } + + flag = true; + } + + if (flag) + { + this.playerEntity.playerNetServerHandler.sendPacket(new S23PacketBlockChange(i, j, k, worldserver)); + + if (l == 0) + { + --j; + } + + if (l == 1) + { + ++j; + } + + if (l == 2) + { + --k; + } + + if (l == 3) + { + ++k; + } + + if (l == 4) + { + --i; + } + + if (l == 5) + { + ++i; + } + + this.playerEntity.playerNetServerHandler.sendPacket(new S23PacketBlockChange(i, j, k, worldserver)); + } + + itemstack = this.playerEntity.inventory.getCurrentItem(); + + if (itemstack != null && itemstack.stackSize == 0) + { + this.playerEntity.inventory.mainInventory[this.playerEntity.inventory.currentItem] = null; + itemstack = null; + } + + if (itemstack == null || itemstack.getMaxItemUseDuration() == 0) + { + this.playerEntity.isChangingQuantityOnly = true; + this.playerEntity.inventory.mainInventory[this.playerEntity.inventory.currentItem] = ItemStack.copyItemStack(this.playerEntity.inventory.mainInventory[this.playerEntity.inventory.currentItem]); + Slot slot = this.playerEntity.openContainer.getSlotFromInventory(this.playerEntity.inventory, this.playerEntity.inventory.currentItem); + this.playerEntity.openContainer.detectAndSendChanges(); + this.playerEntity.isChangingQuantityOnly = false; + + if (!ItemStack.areItemStacksEqual(this.playerEntity.inventory.getCurrentItem(), p_147346_1_.func_149574_g())) + { + this.sendPacket(new S2FPacketSetSlot(this.playerEntity.openContainer.windowId, slot.slotNumber, this.playerEntity.inventory.getCurrentItem())); + } + } + } + + public void onDisconnect(IChatComponent p_147231_1_) + { + logger.info(this.playerEntity.getCommandSenderName() + " lost connection: " + p_147231_1_); + this.serverController.func_147132_au(); + ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("multiplayer.player.left", new Object[] {this.playerEntity.func_145748_c_()}); + chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.YELLOW); + this.serverController.getConfigurationManager().sendChatMsg(chatcomponenttranslation); + this.playerEntity.mountEntityAndWakeUp(); + this.serverController.getConfigurationManager().playerLoggedOut(this.playerEntity); + + if (this.serverController.isSinglePlayer() && this.playerEntity.getCommandSenderName().equals(this.serverController.getServerOwner())) + { + logger.info("Stopping singleplayer server as player logged out"); + this.serverController.initiateShutdown(); + } + } + + public void sendPacket(final Packet p_147359_1_) + { + if (p_147359_1_ instanceof S02PacketChat) + { + S02PacketChat s02packetchat = (S02PacketChat)p_147359_1_; + EntityPlayer.EnumChatVisibility enumchatvisibility = this.playerEntity.func_147096_v(); + + if (enumchatvisibility == EntityPlayer.EnumChatVisibility.HIDDEN) + { + return; + } + + if (enumchatvisibility == EntityPlayer.EnumChatVisibility.SYSTEM && !s02packetchat.func_148916_d()) + { + return; + } + } + + try + { + this.netManager.scheduleOutboundPacket(p_147359_1_, new GenericFutureListener[0]); + } + catch (Throwable throwable) + { + CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Sending packet"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("Packet being sent"); + crashreportcategory.addCrashSectionCallable("Packet class", new Callable() + { + private static final String __OBFID = "CL_00001454"; + public String call() + { + return p_147359_1_.getClass().getCanonicalName(); + } + }); + throw new ReportedException(crashreport); + } + } + + public void processHeldItemChange(C09PacketHeldItemChange p_147355_1_) + { + if (p_147355_1_.func_149614_c() >= 0 && p_147355_1_.func_149614_c() < InventoryPlayer.getHotbarSize()) + { + this.playerEntity.inventory.currentItem = p_147355_1_.func_149614_c(); + this.playerEntity.func_143004_u(); + } + else + { + logger.warn(this.playerEntity.getCommandSenderName() + " tried to set an invalid carried item"); + } + } + + public void processChatMessage(C01PacketChatMessage p_147354_1_) + { + if (this.playerEntity.func_147096_v() == EntityPlayer.EnumChatVisibility.HIDDEN) + { + ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("chat.cannotSend", new Object[0]); + chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.RED); + this.sendPacket(new S02PacketChat(chatcomponenttranslation)); + } + else + { + this.playerEntity.func_143004_u(); + String s = p_147354_1_.func_149439_c(); + s = StringUtils.normalizeSpace(s); + + for (int i = 0; i < s.length(); ++i) + { + if (!ChatAllowedCharacters.isAllowedCharacter(s.charAt(i))) + { + this.kickPlayerFromServer("Illegal characters in chat"); + return; + } + } + + if (s.startsWith("/")) + { + this.handleSlashCommand(s); + } + else + { + ChatComponentTranslation chatcomponenttranslation1 = new ChatComponentTranslation("chat.type.text", new Object[] {this.playerEntity.func_145748_c_(), s}); + chatcomponenttranslation1 = ForgeHooks.onServerChatEvent(this, s, chatcomponenttranslation1); + if (chatcomponenttranslation1 == null) return; + this.serverController.getConfigurationManager().sendChatMsgImpl(chatcomponenttranslation1, false); + } + + this.chatSpamThresholdCount += 20; + + if (this.chatSpamThresholdCount > 200 && !this.serverController.getConfigurationManager().isPlayerOpped(this.playerEntity.getCommandSenderName())) + { + this.kickPlayerFromServer("disconnect.spam"); + } + } + } + + private void handleSlashCommand(String p_147361_1_) + { + this.serverController.getCommandManager().executeCommand(this.playerEntity, p_147361_1_); + } + + public void processAnimation(C0APacketAnimation p_147350_1_) + { + this.playerEntity.func_143004_u(); + + if (p_147350_1_.func_149421_d() == 1) + { + this.playerEntity.swingItem(); + } + } + + public void processEntityAction(C0BPacketEntityAction p_147357_1_) + { + this.playerEntity.func_143004_u(); + + if (p_147357_1_.func_149513_d() == 1) + { + this.playerEntity.setSneaking(true); + } + else if (p_147357_1_.func_149513_d() == 2) + { + this.playerEntity.setSneaking(false); + } + else if (p_147357_1_.func_149513_d() == 4) + { + this.playerEntity.setSprinting(true); + } + else if (p_147357_1_.func_149513_d() == 5) + { + this.playerEntity.setSprinting(false); + } + else if (p_147357_1_.func_149513_d() == 3) + { + this.playerEntity.wakeUpPlayer(false, true, true); + this.hasMoved = false; + } + else if (p_147357_1_.func_149513_d() == 6) + { + if (this.playerEntity.ridingEntity != null && this.playerEntity.ridingEntity instanceof EntityHorse) + { + ((EntityHorse)this.playerEntity.ridingEntity).setJumpPower(p_147357_1_.func_149512_e()); + } + } + else if (p_147357_1_.func_149513_d() == 7 && this.playerEntity.ridingEntity != null && this.playerEntity.ridingEntity instanceof EntityHorse) + { + ((EntityHorse)this.playerEntity.ridingEntity).openGUI(this.playerEntity); + } + } + + public void processUseEntity(C02PacketUseEntity p_147340_1_) + { + WorldServer worldserver = this.serverController.worldServerForDimension(this.playerEntity.dimension); + Entity entity = p_147340_1_.func_149564_a(worldserver); + this.playerEntity.func_143004_u(); + + if (entity != null) + { + boolean flag = this.playerEntity.canEntityBeSeen(entity); + double d0 = 36.0D; + + if (!flag) + { + d0 = 9.0D; + } + + if (this.playerEntity.getDistanceSqToEntity(entity) < d0) + { + if (p_147340_1_.func_149565_c() == C02PacketUseEntity.Action.INTERACT) + { + this.playerEntity.interactWith(entity); + } + else if (p_147340_1_.func_149565_c() == C02PacketUseEntity.Action.ATTACK) + { + if (entity instanceof EntityItem || entity instanceof EntityXPOrb || entity instanceof EntityArrow || entity == this.playerEntity) + { + this.kickPlayerFromServer("Attempting to attack an invalid entity"); + this.serverController.logWarning("Player " + this.playerEntity.getCommandSenderName() + " tried to attack an invalid entity"); + return; + } + + this.playerEntity.attackTargetEntityWithCurrentItem(entity); + } + } + } + } + + public void processClientStatus(C16PacketClientStatus p_147342_1_) + { + this.playerEntity.func_143004_u(); + C16PacketClientStatus.EnumState enumstate = p_147342_1_.func_149435_c(); + + switch (NetHandlerPlayServer.SwitchEnumState.field_151290_a[enumstate.ordinal()]) + { + case 1: + if (this.playerEntity.playerConqueredTheEnd) + { + this.playerEntity = this.serverController.getConfigurationManager().respawnPlayer(this.playerEntity, 0, true); + } + else if (this.playerEntity.getServerForPlayer().getWorldInfo().isHardcoreModeEnabled()) + { + if (this.serverController.isSinglePlayer() && this.playerEntity.getCommandSenderName().equals(this.serverController.getServerOwner())) + { + this.playerEntity.playerNetServerHandler.kickPlayerFromServer("You have died. Game over, man, it\'s game over!"); + this.serverController.deleteWorldAndStopServer(); + } + else + { + BanEntry banentry = new BanEntry(this.playerEntity.getCommandSenderName()); + banentry.setBanReason("Death in Hardcore"); + this.serverController.getConfigurationManager().getBannedPlayers().put(banentry); + this.playerEntity.playerNetServerHandler.kickPlayerFromServer("You have died. Game over, man, it\'s game over!"); + } + } + else + { + if (this.playerEntity.getHealth() > 0.0F) + { + return; + } + + this.playerEntity = this.serverController.getConfigurationManager().respawnPlayer(this.playerEntity, playerEntity.dimension, false); + } + + break; + case 2: + this.playerEntity.func_147099_x().func_150876_a(this.playerEntity); + break; + case 3: + this.playerEntity.triggerAchievement(AchievementList.openInventory); + } + } + + public void processCloseWindow(C0DPacketCloseWindow p_147356_1_) + { + this.playerEntity.closeContainer(); + } + + public void processClickWindow(C0EPacketClickWindow p_147351_1_) + { + this.playerEntity.func_143004_u(); + + if (this.playerEntity.openContainer.windowId == p_147351_1_.func_149548_c() && this.playerEntity.openContainer.isPlayerNotUsingContainer(this.playerEntity)) + { + ItemStack itemstack = this.playerEntity.openContainer.slotClick(p_147351_1_.func_149544_d(), p_147351_1_.func_149543_e(), p_147351_1_.func_149542_h(), this.playerEntity); + + if (ItemStack.areItemStacksEqual(p_147351_1_.func_149546_g(), itemstack)) + { + this.playerEntity.playerNetServerHandler.sendPacket(new S32PacketConfirmTransaction(p_147351_1_.func_149548_c(), p_147351_1_.func_149547_f(), true)); + this.playerEntity.isChangingQuantityOnly = true; + this.playerEntity.openContainer.detectAndSendChanges(); + this.playerEntity.updateHeldItem(); + this.playerEntity.isChangingQuantityOnly = false; + } + else + { + this.field_147372_n.addKey(this.playerEntity.openContainer.windowId, Short.valueOf(p_147351_1_.func_149547_f())); + this.playerEntity.playerNetServerHandler.sendPacket(new S32PacketConfirmTransaction(p_147351_1_.func_149548_c(), p_147351_1_.func_149547_f(), false)); + this.playerEntity.openContainer.setPlayerIsPresent(this.playerEntity, false); + ArrayList arraylist = new ArrayList(); + + for (int i = 0; i < this.playerEntity.openContainer.inventorySlots.size(); ++i) + { + arraylist.add(((Slot)this.playerEntity.openContainer.inventorySlots.get(i)).getStack()); + } + + this.playerEntity.sendContainerAndContentsToPlayer(this.playerEntity.openContainer, arraylist); + } + } + } + + public void processEnchantItem(C11PacketEnchantItem p_147338_1_) + { + this.playerEntity.func_143004_u(); + + if (this.playerEntity.openContainer.windowId == p_147338_1_.func_149539_c() && this.playerEntity.openContainer.isPlayerNotUsingContainer(this.playerEntity)) + { + this.playerEntity.openContainer.enchantItem(this.playerEntity, p_147338_1_.func_149537_d()); + this.playerEntity.openContainer.detectAndSendChanges(); + } + } + + public void processCreativeInventoryAction(C10PacketCreativeInventoryAction p_147344_1_) + { + if (this.playerEntity.theItemInWorldManager.isCreative()) + { + boolean flag = p_147344_1_.func_149627_c() < 0; + ItemStack itemstack = p_147344_1_.func_149625_d(); + boolean flag1 = p_147344_1_.func_149627_c() >= 1 && p_147344_1_.func_149627_c() < 36 + InventoryPlayer.getHotbarSize(); + boolean flag2 = itemstack == null || itemstack.getItem() != null; + boolean flag3 = itemstack == null || itemstack.getItemDamage() >= 0 && itemstack.stackSize <= 64 && itemstack.stackSize > 0; + + if (flag1 && flag2 && flag3) + { + if (itemstack == null) + { + this.playerEntity.inventoryContainer.putStackInSlot(p_147344_1_.func_149627_c(), (ItemStack)null); + } + else + { + this.playerEntity.inventoryContainer.putStackInSlot(p_147344_1_.func_149627_c(), itemstack); + } + + this.playerEntity.inventoryContainer.setPlayerIsPresent(this.playerEntity, true); + } + else if (flag && flag2 && flag3 && this.field_147375_m < 200) + { + this.field_147375_m += 20; + EntityItem entityitem = this.playerEntity.dropPlayerItemWithRandomChoice(itemstack, true); + + if (entityitem != null) + { + entityitem.setAgeToCreativeDespawnTime(); + } + } + } + } + + public void processConfirmTransaction(C0FPacketConfirmTransaction p_147339_1_) + { + Short oshort = (Short)this.field_147372_n.lookup(this.playerEntity.openContainer.windowId); + + if (oshort != null && p_147339_1_.func_149533_d() == oshort.shortValue() && this.playerEntity.openContainer.windowId == p_147339_1_.func_149532_c() && !this.playerEntity.openContainer.isPlayerNotUsingContainer(this.playerEntity)) + { + this.playerEntity.openContainer.setPlayerIsPresent(this.playerEntity, true); + } + } + + public void processUpdateSign(C12PacketUpdateSign p_147343_1_) + { + this.playerEntity.func_143004_u(); + WorldServer worldserver = this.serverController.worldServerForDimension(this.playerEntity.dimension); + + if (worldserver.blockExists(p_147343_1_.func_149588_c(), p_147343_1_.func_149586_d(), p_147343_1_.func_149585_e())) + { + TileEntity tileentity = worldserver.getTileEntity(p_147343_1_.func_149588_c(), p_147343_1_.func_149586_d(), p_147343_1_.func_149585_e()); + + if (tileentity instanceof TileEntitySign) + { + TileEntitySign tileentitysign = (TileEntitySign)tileentity; + + if (!tileentitysign.func_145914_a() || tileentitysign.func_145911_b() != this.playerEntity) + { + this.serverController.logWarning("Player " + this.playerEntity.getCommandSenderName() + " just tried to change non-editable sign"); + return; + } + } + + int i; + int j; + + for (j = 0; j < 4; ++j) + { + boolean flag = true; + + if (p_147343_1_.func_149589_f()[j].length() > 15) + { + flag = false; + } + else + { + for (i = 0; i < p_147343_1_.func_149589_f()[j].length(); ++i) + { + if (!ChatAllowedCharacters.isAllowedCharacter(p_147343_1_.func_149589_f()[j].charAt(i))) + { + flag = false; + } + } + } + + if (!flag) + { + p_147343_1_.func_149589_f()[j] = "!?"; + } + } + + if (tileentity instanceof TileEntitySign) + { + j = p_147343_1_.func_149588_c(); + int k = p_147343_1_.func_149586_d(); + i = p_147343_1_.func_149585_e(); + TileEntitySign tileentitysign1 = (TileEntitySign)tileentity; + System.arraycopy(p_147343_1_.func_149589_f(), 0, tileentitysign1.signText, 0, 4); + tileentitysign1.markDirty(); + worldserver.markBlockForUpdate(j, k, i); + } + } + } + + public void processKeepAlive(C00PacketKeepAlive p_147353_1_) + { + if (p_147353_1_.func_149460_c() == this.field_147378_h) + { + int i = (int)(this.func_147363_d() - this.field_147379_i); + this.playerEntity.ping = (this.playerEntity.ping * 3 + i) / 4; + } + } + + private long func_147363_d() + { + return System.nanoTime() / 1000000L; + } + + public void processPlayerAbilities(C13PacketPlayerAbilities p_147348_1_) + { + this.playerEntity.capabilities.isFlying = p_147348_1_.func_149488_d() && this.playerEntity.capabilities.allowFlying; + } + + public void processTabComplete(C14PacketTabComplete p_147341_1_) + { + ArrayList arraylist = Lists.newArrayList(); + Iterator iterator = this.serverController.getPossibleCompletions(this.playerEntity, p_147341_1_.func_149419_c()).iterator(); + + while (iterator.hasNext()) + { + String s = (String)iterator.next(); + arraylist.add(s); + } + + this.playerEntity.playerNetServerHandler.sendPacket(new S3APacketTabComplete((String[])arraylist.toArray(new String[arraylist.size()]))); + } + + public void processClientSettings(C15PacketClientSettings p_147352_1_) + { + this.playerEntity.func_147100_a(p_147352_1_); + } + + public void processVanilla250Packet(C17PacketCustomPayload p_147349_1_) + { + ItemStack itemstack; + ItemStack itemstack1; + + if ("MC|BEdit".equals(p_147349_1_.func_149559_c())) + { + try + { + itemstack = (new PacketBuffer(Unpooled.wrappedBuffer(p_147349_1_.func_149558_e()))).readItemStackFromBuffer(); + + if (!ItemWritableBook.func_150930_a(itemstack.getTagCompound())) + { + throw new IOException("Invalid book tag!"); + } + + itemstack1 = this.playerEntity.inventory.getCurrentItem(); + + if (itemstack.getItem() == Items.writable_book && itemstack.getItem() == itemstack1.getItem()) + { + itemstack1.setTagInfo("pages", itemstack.getTagCompound().getTagList("pages", 8)); + } + } + catch (Exception exception4) + { + logger.error("Couldn\'t handle book info", exception4); + } + } + else if ("MC|BSign".equals(p_147349_1_.func_149559_c())) + { + try + { + itemstack = (new PacketBuffer(Unpooled.wrappedBuffer(p_147349_1_.func_149558_e()))).readItemStackFromBuffer(); + + if (!ItemEditableBook.validBookTagContents(itemstack.getTagCompound())) + { + throw new IOException("Invalid book tag!"); + } + + itemstack1 = this.playerEntity.inventory.getCurrentItem(); + + if (itemstack.getItem() == Items.written_book && itemstack1.getItem() == Items.writable_book) + { + itemstack1.setTagInfo("author", new NBTTagString(this.playerEntity.getCommandSenderName())); + itemstack1.setTagInfo("title", new NBTTagString(itemstack.getTagCompound().getString("title"))); + itemstack1.setTagInfo("pages", itemstack.getTagCompound().getTagList("pages", 8)); + itemstack1.func_150996_a(Items.written_book); + } + } + catch (Exception exception3) + { + logger.error("Couldn\'t sign book", exception3); + } + } + else + { + DataInputStream datainputstream; + int i; + + if ("MC|TrSel".equals(p_147349_1_.func_149559_c())) + { + try + { + datainputstream = new DataInputStream(new ByteArrayInputStream(p_147349_1_.func_149558_e())); + i = datainputstream.readInt(); + Container container = this.playerEntity.openContainer; + + if (container instanceof ContainerMerchant) + { + ((ContainerMerchant)container).setCurrentRecipeIndex(i); + } + } + catch (Exception exception2) + { + logger.error("Couldn\'t select trade", exception2); + } + } + else if ("MC|AdvCdm".equals(p_147349_1_.func_149559_c())) + { + if (!this.serverController.isCommandBlockEnabled()) + { + this.playerEntity.addChatMessage(new ChatComponentTranslation("advMode.notEnabled", new Object[0])); + } + else if (this.playerEntity.canCommandSenderUseCommand(2, "") && this.playerEntity.capabilities.isCreativeMode) + { + try + { + PacketBuffer packetbuffer = new PacketBuffer(Unpooled.wrappedBuffer(p_147349_1_.func_149558_e())); + byte b0 = packetbuffer.readByte(); + CommandBlockLogic commandblocklogic = null; + + if (b0 == 0) + { + TileEntity tileentity = this.playerEntity.worldObj.getTileEntity(packetbuffer.readInt(), packetbuffer.readInt(), packetbuffer.readInt()); + + if (tileentity instanceof TileEntityCommandBlock) + { + commandblocklogic = ((TileEntityCommandBlock)tileentity).func_145993_a(); + } + } + else if (b0 == 1) + { + Entity entity = this.playerEntity.worldObj.getEntityByID(packetbuffer.readInt()); + + if (entity instanceof EntityMinecartCommandBlock) + { + commandblocklogic = ((EntityMinecartCommandBlock)entity).func_145822_e(); + } + } + + String s1 = packetbuffer.readStringFromBuffer(packetbuffer.readableBytes()); + + if (commandblocklogic != null) + { + commandblocklogic.func_145752_a(s1); + commandblocklogic.func_145756_e(); + this.playerEntity.addChatMessage(new ChatComponentTranslation("advMode.setCommand.success", new Object[] {s1})); + } + } + catch (Exception exception1) + { + logger.error("Couldn\'t set command block", exception1); + } + } + else + { + this.playerEntity.addChatMessage(new ChatComponentTranslation("advMode.notAllowed", new Object[0])); + } + } + else if ("MC|Beacon".equals(p_147349_1_.func_149559_c())) + { + if (this.playerEntity.openContainer instanceof ContainerBeacon) + { + try + { + datainputstream = new DataInputStream(new ByteArrayInputStream(p_147349_1_.func_149558_e())); + i = datainputstream.readInt(); + int j = datainputstream.readInt(); + ContainerBeacon containerbeacon = (ContainerBeacon)this.playerEntity.openContainer; + Slot slot = containerbeacon.getSlot(0); + + if (slot.getHasStack()) + { + slot.decrStackSize(1); + TileEntityBeacon tileentitybeacon = containerbeacon.func_148327_e(); + tileentitybeacon.setPrimaryEffect(i); + tileentitybeacon.setSecondaryEffect(j); + tileentitybeacon.markDirty(); + } + } + catch (Exception exception) + { + logger.error("Couldn\'t set beacon", exception); + } + } + } + else if ("MC|ItemName".equals(p_147349_1_.func_149559_c()) && this.playerEntity.openContainer instanceof ContainerRepair) + { + ContainerRepair containerrepair = (ContainerRepair)this.playerEntity.openContainer; + + if (p_147349_1_.func_149558_e() != null && p_147349_1_.func_149558_e().length >= 1) + { + String s = ChatAllowedCharacters.filerAllowedCharacters(new String(p_147349_1_.func_149558_e(), Charsets.UTF_8)); + + if (s.length() <= 30) + { + containerrepair.updateItemName(s); + } + } + else + { + containerrepair.updateItemName(""); + } + } + } + } + + public void onConnectionStateTransition(EnumConnectionState p_147232_1_, EnumConnectionState p_147232_2_) + { + if (p_147232_2_ != EnumConnectionState.PLAY) + { + throw new IllegalStateException("Unexpected change in protocol!"); + } + } + + static final class SwitchEnumState + { + static final int[] field_151290_a = new int[C16PacketClientStatus.EnumState.values().length]; + private static final String __OBFID = "CL_00001455"; + + static + { + try + { + field_151290_a[C16PacketClientStatus.EnumState.PERFORM_RESPAWN.ordinal()] = 1; + } + catch (NoSuchFieldError var3) + { + ; + } + + try + { + field_151290_a[C16PacketClientStatus.EnumState.REQUEST_STATS.ordinal()] = 2; + } + catch (NoSuchFieldError var2) + { + ; + } + + try + { + field_151290_a[C16PacketClientStatus.EnumState.OPEN_INVENTORY_ACHIEVEMENT.ordinal()] = 3; + } + catch (NoSuchFieldError var1) + { + ; + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/NettyEncryptingDecoder.java b/src/main/java/net/minecraft/network/NettyEncryptingDecoder.java new file mode 100644 index 0000000..2e29225 --- /dev/null +++ b/src/main/java/net/minecraft/network/NettyEncryptingDecoder.java @@ -0,0 +1,29 @@ +package net.minecraft.network; + +import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelHandlerContext; +import io.netty.handler.codec.MessageToMessageDecoder; +import java.util.List; +import javax.crypto.Cipher; +import javax.crypto.ShortBufferException; + +public class NettyEncryptingDecoder extends MessageToMessageDecoder +{ + private final NettyEncryptionTranslator field_150509_a; + private static final String __OBFID = "CL_00001238"; + + public NettyEncryptingDecoder(Cipher p_i45141_1_) + { + this.field_150509_a = new NettyEncryptionTranslator(p_i45141_1_); + } + + protected void decode(ChannelHandlerContext p_150508_1_, ByteBuf p_150508_2_, List p_150508_3_) throws ShortBufferException + { + p_150508_3_.add(this.field_150509_a.func_150503_a(p_150508_1_, p_150508_2_)); + } + + protected void decode(ChannelHandlerContext p_decode_1_, Object p_decode_2_, List p_decode_3_) throws ShortBufferException + { + this.decode(p_decode_1_, (ByteBuf)p_decode_2_, p_decode_3_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/NettyEncryptingEncoder.java b/src/main/java/net/minecraft/network/NettyEncryptingEncoder.java new file mode 100644 index 0000000..8838e2e --- /dev/null +++ b/src/main/java/net/minecraft/network/NettyEncryptingEncoder.java @@ -0,0 +1,28 @@ +package net.minecraft.network; + +import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelHandlerContext; +import io.netty.handler.codec.MessageToByteEncoder; +import javax.crypto.Cipher; +import javax.crypto.ShortBufferException; + +public class NettyEncryptingEncoder extends MessageToByteEncoder +{ + private final NettyEncryptionTranslator field_150750_a; + private static final String __OBFID = "CL_00001239"; + + public NettyEncryptingEncoder(Cipher p_i45142_1_) + { + this.field_150750_a = new NettyEncryptionTranslator(p_i45142_1_); + } + + protected void encode(ChannelHandlerContext p_150749_1_, ByteBuf p_150749_2_, ByteBuf p_150749_3_) throws ShortBufferException + { + this.field_150750_a.func_150504_a(p_150749_2_, p_150749_3_); + } + + protected void encode(ChannelHandlerContext p_encode_1_, Object p_encode_2_, ByteBuf p_encode_3_) throws ShortBufferException + { + this.encode(p_encode_1_, (ByteBuf)p_encode_2_, p_encode_3_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/NettyEncryptionTranslator.java b/src/main/java/net/minecraft/network/NettyEncryptionTranslator.java new file mode 100644 index 0000000..7d30b5f --- /dev/null +++ b/src/main/java/net/minecraft/network/NettyEncryptionTranslator.java @@ -0,0 +1,55 @@ +package net.minecraft.network; + +import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelHandlerContext; +import javax.crypto.Cipher; +import javax.crypto.ShortBufferException; + +public class NettyEncryptionTranslator +{ + private final Cipher field_150507_a; + private byte[] field_150505_b = new byte[0]; + private byte[] field_150506_c = new byte[0]; + private static final String __OBFID = "CL_00001237"; + + protected NettyEncryptionTranslator(Cipher p_i45140_1_) + { + this.field_150507_a = p_i45140_1_; + } + + private byte[] func_150502_a(ByteBuf p_150502_1_) + { + int i = p_150502_1_.readableBytes(); + + if (this.field_150505_b.length < i) + { + this.field_150505_b = new byte[i]; + } + + p_150502_1_.readBytes(this.field_150505_b, 0, i); + return this.field_150505_b; + } + + protected ByteBuf func_150503_a(ChannelHandlerContext p_150503_1_, ByteBuf p_150503_2_) throws ShortBufferException + { + int i = p_150503_2_.readableBytes(); + byte[] abyte = this.func_150502_a(p_150503_2_); + ByteBuf bytebuf1 = p_150503_1_.alloc().heapBuffer(this.field_150507_a.getOutputSize(i)); + bytebuf1.writerIndex(this.field_150507_a.update(abyte, 0, i, bytebuf1.array(), bytebuf1.arrayOffset())); + return bytebuf1; + } + + protected void func_150504_a(ByteBuf p_150504_1_, ByteBuf p_150504_2_) throws ShortBufferException + { + int i = p_150504_1_.readableBytes(); + byte[] abyte = this.func_150502_a(p_150504_1_); + int j = this.field_150507_a.getOutputSize(i); + + if (this.field_150506_c.length < j) + { + this.field_150506_c = new byte[j]; + } + + p_150504_2_.writeBytes(this.field_150506_c, 0, this.field_150507_a.update(abyte, 0, i, this.field_150506_c)); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/NetworkManager.java b/src/main/java/net/minecraft/network/NetworkManager.java new file mode 100644 index 0000000..d79c55f --- /dev/null +++ b/src/main/java/net/minecraft/network/NetworkManager.java @@ -0,0 +1,321 @@ +package net.minecraft.network; + +import com.google.common.collect.Queues; +import com.google.common.util.concurrent.ThreadFactoryBuilder; + +import cpw.mods.fml.common.network.internal.FMLProxyPacket; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.bootstrap.Bootstrap; +import io.netty.channel.Channel; +import io.netty.channel.ChannelException; +import io.netty.channel.ChannelFutureListener; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelInitializer; +import io.netty.channel.ChannelOption; +import io.netty.channel.SimpleChannelInboundHandler; +import io.netty.channel.local.LocalChannel; +import io.netty.channel.local.LocalServerChannel; +import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.channel.socket.nio.NioSocketChannel; +import io.netty.handler.timeout.ReadTimeoutHandler; +import io.netty.util.AttributeKey; +import io.netty.util.concurrent.GenericFutureListener; +import java.net.InetAddress; +import java.net.SocketAddress; +import java.util.Queue; +import javax.crypto.SecretKey; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.CryptManager; +import net.minecraft.util.IChatComponent; +import net.minecraft.util.MessageDeserializer; +import net.minecraft.util.MessageDeserializer2; +import net.minecraft.util.MessageSerializer; +import net.minecraft.util.MessageSerializer2; +import org.apache.commons.lang3.Validate; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.Marker; +import org.apache.logging.log4j.MarkerManager; + +public class NetworkManager extends SimpleChannelInboundHandler +{ + private static final Logger logger = LogManager.getLogger(); + public static final Marker logMarkerNetwork = MarkerManager.getMarker("NETWORK"); + public static final Marker logMarkerPackets = MarkerManager.getMarker("NETWORK_PACKETS", logMarkerNetwork); + public static final AttributeKey attrKeyConnectionState = new AttributeKey("protocol"); + public static final AttributeKey attrKeyReceivable = new AttributeKey("receivable_packets"); + public static final AttributeKey attrKeySendable = new AttributeKey("sendable_packets"); + public static final NioEventLoopGroup eventLoops = new NioEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Client IO #%d").setDaemon(true).build()); + private final boolean isClientSide; + private final Queue receivedPacketsQueue = Queues.newConcurrentLinkedQueue(); + private final Queue outboundPacketsQueue = Queues.newConcurrentLinkedQueue(); + private Channel channel; + private SocketAddress socketAddress; + private INetHandler netHandler; + private EnumConnectionState connectionState; + private IChatComponent terminationReason; + private static final String __OBFID = "CL_00001240"; + + public NetworkManager(boolean p_i45147_1_) + { + this.isClientSide = p_i45147_1_; + } + + public void channelActive(ChannelHandlerContext p_channelActive_1_) throws Exception + { + super.channelActive(p_channelActive_1_); + this.channel = p_channelActive_1_.channel(); + this.socketAddress = this.channel.remoteAddress(); + this.setConnectionState(EnumConnectionState.HANDSHAKING); + } + + public void setConnectionState(EnumConnectionState p_150723_1_) + { + this.connectionState = (EnumConnectionState)this.channel.attr(attrKeyConnectionState).getAndSet(p_150723_1_); + this.channel.attr(attrKeyReceivable).set(p_150723_1_.func_150757_a(this.isClientSide)); + this.channel.attr(attrKeySendable).set(p_150723_1_.func_150754_b(this.isClientSide)); + this.channel.config().setAutoRead(true); + logger.debug("Enabled auto read"); + } + + public void channelInactive(ChannelHandlerContext p_channelInactive_1_) + { + this.closeChannel(new ChatComponentTranslation("disconnect.endOfStream", new Object[0])); + } + + public void exceptionCaught(ChannelHandlerContext p_exceptionCaught_1_, Throwable p_exceptionCaught_2_) + { + this.closeChannel(new ChatComponentTranslation("disconnect.genericReason", new Object[] {"Internal Exception: " + p_exceptionCaught_2_})); + } + + protected void channelRead0(ChannelHandlerContext p_150728_1_, Packet p_150728_2_) + { + if (this.channel.isOpen()) + { + if (p_150728_2_.hasPriority()) + { + p_150728_2_.processPacket(this.netHandler); + } + else + { + this.receivedPacketsQueue.add(p_150728_2_); + } + } + } + + public void setNetHandler(INetHandler p_150719_1_) + { + Validate.notNull(p_150719_1_, "packetListener", new Object[0]); + logger.debug("Set listener of {} to {}", new Object[] {this, p_150719_1_}); + this.netHandler = p_150719_1_; + } + + public void scheduleOutboundPacket(Packet p_150725_1_, GenericFutureListener ... p_150725_2_) + { + if (this.channel != null && this.channel.isOpen()) + { + this.flushOutboundQueue(); + this.dispatchPacket(p_150725_1_, p_150725_2_); + } + else + { + this.outboundPacketsQueue.add(new NetworkManager.InboundHandlerTuplePacketListener(p_150725_1_, p_150725_2_)); + } + } + + private void dispatchPacket(final Packet p_150732_1_, final GenericFutureListener[] p_150732_2_) + { + final EnumConnectionState enumconnectionstate = EnumConnectionState.func_150752_a(p_150732_1_); + final EnumConnectionState enumconnectionstate1 = (EnumConnectionState)this.channel.attr(attrKeyConnectionState).get(); + + if (enumconnectionstate1 != enumconnectionstate && !( p_150732_1_ instanceof FMLProxyPacket)) + { + logger.debug("Disabled auto read"); + this.channel.config().setAutoRead(false); + } + + if (this.channel.eventLoop().inEventLoop()) + { + if (enumconnectionstate != enumconnectionstate1 && !( p_150732_1_ instanceof FMLProxyPacket)) + { + this.setConnectionState(enumconnectionstate); + } + + this.channel.writeAndFlush(p_150732_1_).addListeners(p_150732_2_).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); + } + else + { + this.channel.eventLoop().execute(new Runnable() + { + private static final String __OBFID = "CL_00001241"; + public void run() + { + if (enumconnectionstate != enumconnectionstate1 && !( p_150732_1_ instanceof FMLProxyPacket)) + { + NetworkManager.this.setConnectionState(enumconnectionstate); + } + + NetworkManager.this.channel.writeAndFlush(p_150732_1_).addListeners(p_150732_2_).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); + } + }); + } + } + + private void flushOutboundQueue() + { + if (this.channel != null && this.channel.isOpen()) + { + while (!this.outboundPacketsQueue.isEmpty()) + { + NetworkManager.InboundHandlerTuplePacketListener inboundhandlertuplepacketlistener = (NetworkManager.InboundHandlerTuplePacketListener)this.outboundPacketsQueue.poll(); + this.dispatchPacket(inboundhandlertuplepacketlistener.field_150774_a, inboundhandlertuplepacketlistener.field_150773_b); + } + } + } + + public void processReceivedPackets() + { + this.flushOutboundQueue(); + EnumConnectionState enumconnectionstate = (EnumConnectionState)this.channel.attr(attrKeyConnectionState).get(); + + if (this.connectionState != enumconnectionstate) + { + if (this.connectionState != null) + { + this.netHandler.onConnectionStateTransition(this.connectionState, enumconnectionstate); + } + + this.connectionState = enumconnectionstate; + } + + if (this.netHandler != null) + { + for (int i = 1000; !this.receivedPacketsQueue.isEmpty() && i >= 0; --i) + { + Packet packet = (Packet)this.receivedPacketsQueue.poll(); + packet.processPacket(this.netHandler); + } + + this.netHandler.onNetworkTick(); + } + + this.channel.flush(); + } + + public SocketAddress getSocketAddress() + { + return this.socketAddress; + } + + public void closeChannel(IChatComponent p_150718_1_) + { + if (this.channel.isOpen()) + { + this.channel.close(); + this.terminationReason = p_150718_1_; + } + } + + public boolean isLocalChannel() + { + return this.channel instanceof LocalChannel || this.channel instanceof LocalServerChannel; + } + + @SideOnly(Side.CLIENT) + public static NetworkManager provideLanClient(InetAddress p_150726_0_, int p_150726_1_) + { + final NetworkManager networkmanager = new NetworkManager(true); + ((Bootstrap)((Bootstrap)((Bootstrap)(new Bootstrap()).group(eventLoops)).handler(new ChannelInitializer() + { + private static final String __OBFID = "CL_00001242"; + protected void initChannel(Channel p_initChannel_1_) + { + try + { + p_initChannel_1_.config().setOption(ChannelOption.IP_TOS, Integer.valueOf(24)); + } + catch (ChannelException channelexception1) + { + ; + } + + try + { + p_initChannel_1_.config().setOption(ChannelOption.TCP_NODELAY, Boolean.valueOf(false)); + } + catch (ChannelException channelexception) + { + ; + } + + p_initChannel_1_.pipeline().addLast("timeout", new ReadTimeoutHandler(20)).addLast("splitter", new MessageDeserializer2()).addLast("decoder", new MessageDeserializer()).addLast("prepender", new MessageSerializer2()).addLast("encoder", new MessageSerializer()).addLast("packet_handler", networkmanager); + } + })).channel(NioSocketChannel.class)).connect(p_150726_0_, p_150726_1_).syncUninterruptibly(); + return networkmanager; + } + + @SideOnly(Side.CLIENT) + public static NetworkManager provideLocalClient(SocketAddress p_150722_0_) + { + final NetworkManager networkmanager = new NetworkManager(true); + ((Bootstrap)((Bootstrap)((Bootstrap)(new Bootstrap()).group(eventLoops)).handler(new ChannelInitializer() + { + private static final String __OBFID = "CL_00001243"; + protected void initChannel(Channel p_initChannel_1_) + { + p_initChannel_1_.pipeline().addLast("packet_handler", networkmanager); + } + })).channel(LocalChannel.class)).connect(p_150722_0_).syncUninterruptibly(); + return networkmanager; + } + + public void enableEncryption(SecretKey p_150727_1_) + { + this.channel.pipeline().addBefore("splitter", "decrypt", new NettyEncryptingDecoder(CryptManager.func_151229_a(2, p_150727_1_))); + this.channel.pipeline().addBefore("prepender", "encrypt", new NettyEncryptingEncoder(CryptManager.func_151229_a(1, p_150727_1_))); + } + + public boolean isChannelOpen() + { + return this.channel != null && this.channel.isOpen(); + } + + public INetHandler getNetHandler() + { + return this.netHandler; + } + + public IChatComponent getExitMessage() + { + return this.terminationReason; + } + + public void disableAutoRead() + { + this.channel.config().setAutoRead(false); + } + + protected void channelRead0(ChannelHandlerContext p_channelRead0_1_, Object p_channelRead0_2_) + { + this.channelRead0(p_channelRead0_1_, (Packet)p_channelRead0_2_); + } + + public Channel channel() + { + return channel; + } + + static class InboundHandlerTuplePacketListener + { + private final Packet field_150774_a; + private final GenericFutureListener[] field_150773_b; + private static final String __OBFID = "CL_00001244"; + + public InboundHandlerTuplePacketListener(Packet p_i45146_1_, GenericFutureListener ... p_i45146_2_) + { + this.field_150774_a = p_i45146_1_; + this.field_150773_b = p_i45146_2_; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/NetworkSystem.java b/src/main/java/net/minecraft/network/NetworkSystem.java new file mode 100644 index 0000000..e8a40cd --- /dev/null +++ b/src/main/java/net/minecraft/network/NetworkSystem.java @@ -0,0 +1,206 @@ +package net.minecraft.network; + +import com.google.common.util.concurrent.ThreadFactoryBuilder; + +import cpw.mods.fml.common.network.internal.FMLNetworkHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.bootstrap.ServerBootstrap; +import io.netty.channel.Channel; +import io.netty.channel.ChannelException; +import io.netty.channel.ChannelFuture; +import io.netty.channel.ChannelInitializer; +import io.netty.channel.ChannelOption; +import io.netty.channel.local.LocalAddress; +import io.netty.channel.local.LocalServerChannel; +import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.channel.socket.nio.NioServerSocketChannel; +import io.netty.handler.timeout.ReadTimeoutHandler; +import io.netty.util.concurrent.Future; +import io.netty.util.concurrent.GenericFutureListener; +import java.io.IOException; +import java.net.InetAddress; +import java.net.SocketAddress; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.concurrent.Callable; +import net.minecraft.client.network.NetHandlerHandshakeMemory; +import net.minecraft.crash.CrashReport; +import net.minecraft.crash.CrashReportCategory; +import net.minecraft.network.play.server.S40PacketDisconnect; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.network.NetHandlerHandshakeTCP; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.MessageDeserializer; +import net.minecraft.util.MessageDeserializer2; +import net.minecraft.util.MessageSerializer; +import net.minecraft.util.MessageSerializer2; +import net.minecraft.util.ReportedException; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class NetworkSystem +{ + private static final Logger logger = LogManager.getLogger(); + private static final NioEventLoopGroup eventLoops = new NioEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty IO #%d").setDaemon(true).build()); + private final MinecraftServer mcServer; + public volatile boolean isAlive; + private final List endpoints = Collections.synchronizedList(new ArrayList()); + private final List networkManagers = Collections.synchronizedList(new ArrayList()); + private static final String __OBFID = "CL_00001447"; + + public NetworkSystem(MinecraftServer p_i45292_1_) + { + this.mcServer = p_i45292_1_; + this.isAlive = true; + } + + public void addLanEndpoint(InetAddress p_151265_1_, int p_151265_2_) throws IOException + { + List list = this.endpoints; + + synchronized (this.endpoints) + { + this.endpoints.add(((ServerBootstrap)((ServerBootstrap)(new ServerBootstrap()).channel(NioServerSocketChannel.class)).childHandler(new ChannelInitializer() + { + private static final String __OBFID = "CL_00001448"; + protected void initChannel(Channel p_initChannel_1_) + { + try + { + p_initChannel_1_.config().setOption(ChannelOption.IP_TOS, Integer.valueOf(24)); + } + catch (ChannelException channelexception1) + { + ; + } + + try + { + p_initChannel_1_.config().setOption(ChannelOption.TCP_NODELAY, Boolean.valueOf(false)); + } + catch (ChannelException channelexception) + { + ; + } + + p_initChannel_1_.pipeline().addLast("timeout", new ReadTimeoutHandler(FMLNetworkHandler.READ_TIMEOUT)).addLast("legacy_query", new PingResponseHandler(NetworkSystem.this)).addLast("splitter", new MessageDeserializer2()).addLast("decoder", new MessageDeserializer()).addLast("prepender", new MessageSerializer2()).addLast("encoder", new MessageSerializer()); + NetworkManager networkmanager = new NetworkManager(false); + NetworkSystem.this.networkManagers.add(networkmanager); + p_initChannel_1_.pipeline().addLast("packet_handler", networkmanager); + networkmanager.setNetHandler(new NetHandlerHandshakeTCP(NetworkSystem.this.mcServer, networkmanager)); + } + }).group(eventLoops).localAddress(p_151265_1_, p_151265_2_)).bind().syncUninterruptibly()); + } + } + + @SideOnly(Side.CLIENT) + public SocketAddress addLocalEndpoint() + { + List list = this.endpoints; + ChannelFuture channelfuture; + + synchronized (this.endpoints) + { + channelfuture = ((ServerBootstrap)((ServerBootstrap)(new ServerBootstrap()).channel(LocalServerChannel.class)).childHandler(new ChannelInitializer() + { + private static final String __OBFID = "CL_00001449"; + protected void initChannel(Channel p_initChannel_1_) + { + NetworkManager networkmanager = new NetworkManager(false); + networkmanager.setNetHandler(new NetHandlerHandshakeMemory(NetworkSystem.this.mcServer, networkmanager)); + NetworkSystem.this.networkManagers.add(networkmanager); + p_initChannel_1_.pipeline().addLast("packet_handler", networkmanager); + } + }).group(eventLoops).localAddress(LocalAddress.ANY)).bind().syncUninterruptibly(); + this.endpoints.add(channelfuture); + } + + return channelfuture.channel().localAddress(); + } + + public void terminateEndpoints() + { + this.isAlive = false; + Iterator iterator = this.endpoints.iterator(); + + while (iterator.hasNext()) + { + ChannelFuture channelfuture = (ChannelFuture)iterator.next(); + channelfuture.channel().close().syncUninterruptibly(); + } + } + + public void networkTick() + { + List list = this.networkManagers; + + synchronized (this.networkManagers) + { + Iterator iterator = this.networkManagers.iterator(); + + while (iterator.hasNext()) + { + final NetworkManager networkmanager = (NetworkManager)iterator.next(); + + if (!networkmanager.isChannelOpen()) + { + iterator.remove(); + + if (networkmanager.getExitMessage() != null) + { + networkmanager.getNetHandler().onDisconnect(networkmanager.getExitMessage()); + } + else if (networkmanager.getNetHandler() != null) + { + networkmanager.getNetHandler().onDisconnect(new ChatComponentText("Disconnected")); + } + } + else + { + try + { + networkmanager.processReceivedPackets(); + } + catch (Exception exception) + { + if (networkmanager.isLocalChannel()) + { + CrashReport crashreport = CrashReport.makeCrashReport(exception, "Ticking memory connection"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("Ticking connection"); + crashreportcategory.addCrashSectionCallable("Connection", new Callable() + { + private static final String __OBFID = "CL_00001450"; + public String call() + { + return networkmanager.toString(); + } + }); + throw new ReportedException(crashreport); + } + + logger.warn("Failed to handle packet for " + networkmanager.getSocketAddress(), exception); + final ChatComponentText chatcomponenttext = new ChatComponentText("Internal server error"); + networkmanager.scheduleOutboundPacket(new S40PacketDisconnect(chatcomponenttext), new GenericFutureListener[] {new GenericFutureListener() + { + private static final String __OBFID = "CL_00001451"; + public void operationComplete(Future p_operationComplete_1_) + { + networkmanager.closeChannel(chatcomponenttext); + } + } + }); + networkmanager.disableAutoRead(); + } + } + } + } + } + + public MinecraftServer func_151267_d() + { + return this.mcServer; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/Packet.java b/src/main/java/net/minecraft/network/Packet.java new file mode 100644 index 0000000..c6fd84a --- /dev/null +++ b/src/main/java/net/minecraft/network/Packet.java @@ -0,0 +1,70 @@ +package net.minecraft.network; + +import com.google.common.collect.BiMap; +import io.netty.buffer.ByteBuf; +import java.io.IOException; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public abstract class Packet +{ + private static final Logger logger = LogManager.getLogger(); + private static final String __OBFID = "CL_00001272"; + + public static Packet generatePacket(BiMap p_148839_0_, int p_148839_1_) + { + try + { + Class oclass = (Class)p_148839_0_.get(Integer.valueOf(p_148839_1_)); + return oclass == null ? null : (Packet)oclass.newInstance(); + } + catch (Exception exception) + { + logger.error("Couldn\'t create packet " + p_148839_1_, exception); + return null; + } + } + + public static void writeBlob(ByteBuf p_148838_0_, byte[] p_148838_1_) + { + p_148838_0_.writeShort(p_148838_1_.length); + p_148838_0_.writeBytes(p_148838_1_); + } + + public static byte[] readBlob(ByteBuf p_148834_0_) throws IOException + { + short short1 = p_148834_0_.readShort(); + + if (short1 < 0) + { + throw new IOException("Key was smaller than nothing! Weird key!"); + } + else + { + byte[] abyte = new byte[short1]; + p_148834_0_.readBytes(abyte); + return abyte; + } + } + + public abstract void readPacketData(PacketBuffer var1) throws IOException; + + public abstract void writePacketData(PacketBuffer var1) throws IOException; + + public abstract void processPacket(INetHandler var1); + + public boolean hasPriority() + { + return false; + } + + public String toString() + { + return this.getClass().getSimpleName(); + } + + public String serialize() + { + return ""; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/PacketBuffer.java b/src/main/java/net/minecraft/network/PacketBuffer.java new file mode 100644 index 0000000..f246347 --- /dev/null +++ b/src/main/java/net/minecraft/network/PacketBuffer.java @@ -0,0 +1,902 @@ +package net.minecraft.network; + +import com.google.common.base.Charsets; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.ByteBufAllocator; +import io.netty.buffer.ByteBufProcessor; +import io.netty.util.ReferenceCounted; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.channels.GatheringByteChannel; +import java.nio.channels.ScatteringByteChannel; +import java.nio.charset.Charset; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.CompressedStreamTools; +import net.minecraft.nbt.NBTTagCompound; + +public class PacketBuffer extends ByteBuf +{ + private final ByteBuf field_150794_a; + private static final String __OBFID = "CL_00001251"; + + public PacketBuffer(ByteBuf p_i45154_1_) + { + this.field_150794_a = p_i45154_1_; + } + + public static int getVarIntSize(int p_150790_0_) + { + return (p_150790_0_ & -128) == 0 ? 1 : ((p_150790_0_ & -16384) == 0 ? 2 : ((p_150790_0_ & -2097152) == 0 ? 3 : ((p_150790_0_ & -268435456) == 0 ? 4 : 5))); + } + + public int readVarIntFromBuffer() + { + int i = 0; + int j = 0; + byte b0; + + do + { + b0 = this.readByte(); + i |= (b0 & 127) << j++ * 7; + + if (j > 5) + { + throw new RuntimeException("VarInt too big"); + } + } + while ((b0 & 128) == 128); + + return i; + } + + public void writeVarIntToBuffer(int p_150787_1_) + { + while ((p_150787_1_ & -128) != 0) + { + this.writeByte(p_150787_1_ & 127 | 128); + p_150787_1_ >>>= 7; + } + + this.writeByte(p_150787_1_); + } + + public void writeNBTTagCompoundToBuffer(NBTTagCompound p_150786_1_) throws IOException + { + if (p_150786_1_ == null) + { + this.writeShort(-1); + } + else + { + byte[] abyte = CompressedStreamTools.compress(p_150786_1_); + this.writeShort((short)abyte.length); + this.writeBytes(abyte); + } + } + + public NBTTagCompound readNBTTagCompoundFromBuffer() throws IOException + { + short short1 = this.readShort(); + + if (short1 < 0) + { + return null; + } + else + { + byte[] abyte = new byte[short1]; + this.readBytes(abyte); + return CompressedStreamTools.decompress(abyte); + } + } + + public void writeItemStackToBuffer(ItemStack p_150788_1_) throws IOException + { + if (p_150788_1_ == null) + { + this.writeShort(-1); + } + else + { + this.writeShort(Item.getIdFromItem(p_150788_1_.getItem())); + this.writeByte(p_150788_1_.stackSize); + this.writeShort(p_150788_1_.getItemDamage()); + NBTTagCompound nbttagcompound = null; + + if (p_150788_1_.getItem().isDamageable() || p_150788_1_.getItem().getShareTag()) + { + nbttagcompound = p_150788_1_.stackTagCompound; + } + + this.writeNBTTagCompoundToBuffer(nbttagcompound); + } + } + + public ItemStack readItemStackFromBuffer() throws IOException + { + ItemStack itemstack = null; + short short1 = this.readShort(); + + if (short1 >= 0) + { + byte b0 = this.readByte(); + short short2 = this.readShort(); + itemstack = new ItemStack(Item.getItemById(short1), b0, short2); + itemstack.stackTagCompound = this.readNBTTagCompoundFromBuffer(); + } + + return itemstack; + } + + public String readStringFromBuffer(int p_150789_1_) throws IOException + { + int j = this.readVarIntFromBuffer(); + + if (j > p_150789_1_ * 4) + { + throw new IOException("The received encoded string buffer length is longer than maximum allowed (" + j + " > " + p_150789_1_ * 4 + ")"); + } + else if (j < 0) + { + throw new IOException("The received encoded string buffer length is less than zero! Weird string!"); + } + else + { + String s = new String(this.readBytes(j).array(), Charsets.UTF_8); + + if (s.length() > p_150789_1_) + { + throw new IOException("The received string length is longer than maximum allowed (" + j + " > " + p_150789_1_ + ")"); + } + else + { + return s; + } + } + } + + public void writeStringToBuffer(String p_150785_1_) throws IOException + { + byte[] abyte = p_150785_1_.getBytes(Charsets.UTF_8); + + if (abyte.length > 32767) + { + throw new IOException("String too big (was " + p_150785_1_.length() + " bytes encoded, max " + 32767 + ")"); + } + else + { + this.writeVarIntToBuffer(abyte.length); + this.writeBytes(abyte); + } + } + + public int capacity() + { + return this.field_150794_a.capacity(); + } + + public ByteBuf capacity(int p_capacity_1_) + { + return this.field_150794_a.capacity(p_capacity_1_); + } + + public int maxCapacity() + { + return this.field_150794_a.maxCapacity(); + } + + public ByteBufAllocator alloc() + { + return this.field_150794_a.alloc(); + } + + public ByteOrder order() + { + return this.field_150794_a.order(); + } + + public ByteBuf order(ByteOrder p_order_1_) + { + return this.field_150794_a.order(p_order_1_); + } + + public ByteBuf unwrap() + { + return this.field_150794_a.unwrap(); + } + + public boolean isDirect() + { + return this.field_150794_a.isDirect(); + } + + public int readerIndex() + { + return this.field_150794_a.readerIndex(); + } + + public ByteBuf readerIndex(int p_readerIndex_1_) + { + return this.field_150794_a.readerIndex(p_readerIndex_1_); + } + + public int writerIndex() + { + return this.field_150794_a.writerIndex(); + } + + public ByteBuf writerIndex(int p_writerIndex_1_) + { + return this.field_150794_a.writerIndex(p_writerIndex_1_); + } + + public ByteBuf setIndex(int p_setIndex_1_, int p_setIndex_2_) + { + return this.field_150794_a.setIndex(p_setIndex_1_, p_setIndex_2_); + } + + public int readableBytes() + { + return this.field_150794_a.readableBytes(); + } + + public int writableBytes() + { + return this.field_150794_a.writableBytes(); + } + + public int maxWritableBytes() + { + return this.field_150794_a.maxWritableBytes(); + } + + public boolean isReadable() + { + return this.field_150794_a.isReadable(); + } + + public boolean isReadable(int p_isReadable_1_) + { + return this.field_150794_a.isReadable(p_isReadable_1_); + } + + public boolean isWritable() + { + return this.field_150794_a.isWritable(); + } + + public boolean isWritable(int p_isWritable_1_) + { + return this.field_150794_a.isWritable(p_isWritable_1_); + } + + public ByteBuf clear() + { + return this.field_150794_a.clear(); + } + + public ByteBuf markReaderIndex() + { + return this.field_150794_a.markReaderIndex(); + } + + public ByteBuf resetReaderIndex() + { + return this.field_150794_a.resetReaderIndex(); + } + + public ByteBuf markWriterIndex() + { + return this.field_150794_a.markWriterIndex(); + } + + public ByteBuf resetWriterIndex() + { + return this.field_150794_a.resetWriterIndex(); + } + + public ByteBuf discardReadBytes() + { + return this.field_150794_a.discardReadBytes(); + } + + public ByteBuf discardSomeReadBytes() + { + return this.field_150794_a.discardSomeReadBytes(); + } + + public ByteBuf ensureWritable(int p_ensureWritable_1_) + { + return this.field_150794_a.ensureWritable(p_ensureWritable_1_); + } + + public int ensureWritable(int p_ensureWritable_1_, boolean p_ensureWritable_2_) + { + return this.field_150794_a.ensureWritable(p_ensureWritable_1_, p_ensureWritable_2_); + } + + public boolean getBoolean(int p_getBoolean_1_) + { + return this.field_150794_a.getBoolean(p_getBoolean_1_); + } + + public byte getByte(int p_getByte_1_) + { + return this.field_150794_a.getByte(p_getByte_1_); + } + + public short getUnsignedByte(int p_getUnsignedByte_1_) + { + return this.field_150794_a.getUnsignedByte(p_getUnsignedByte_1_); + } + + public short getShort(int p_getShort_1_) + { + return this.field_150794_a.getShort(p_getShort_1_); + } + + public int getUnsignedShort(int p_getUnsignedShort_1_) + { + return this.field_150794_a.getUnsignedShort(p_getUnsignedShort_1_); + } + + public int getMedium(int p_getMedium_1_) + { + return this.field_150794_a.getMedium(p_getMedium_1_); + } + + public int getUnsignedMedium(int p_getUnsignedMedium_1_) + { + return this.field_150794_a.getUnsignedMedium(p_getUnsignedMedium_1_); + } + + public int getInt(int p_getInt_1_) + { + return this.field_150794_a.getInt(p_getInt_1_); + } + + public long getUnsignedInt(int p_getUnsignedInt_1_) + { + return this.field_150794_a.getUnsignedInt(p_getUnsignedInt_1_); + } + + public long getLong(int p_getLong_1_) + { + return this.field_150794_a.getLong(p_getLong_1_); + } + + public char getChar(int p_getChar_1_) + { + return this.field_150794_a.getChar(p_getChar_1_); + } + + public float getFloat(int p_getFloat_1_) + { + return this.field_150794_a.getFloat(p_getFloat_1_); + } + + public double getDouble(int p_getDouble_1_) + { + return this.field_150794_a.getDouble(p_getDouble_1_); + } + + public ByteBuf getBytes(int p_getBytes_1_, ByteBuf p_getBytes_2_) + { + return this.field_150794_a.getBytes(p_getBytes_1_, p_getBytes_2_); + } + + public ByteBuf getBytes(int p_getBytes_1_, ByteBuf p_getBytes_2_, int p_getBytes_3_) + { + return this.field_150794_a.getBytes(p_getBytes_1_, p_getBytes_2_, p_getBytes_3_); + } + + public ByteBuf getBytes(int p_getBytes_1_, ByteBuf p_getBytes_2_, int p_getBytes_3_, int p_getBytes_4_) + { + return this.field_150794_a.getBytes(p_getBytes_1_, p_getBytes_2_, p_getBytes_3_, p_getBytes_4_); + } + + public ByteBuf getBytes(int p_getBytes_1_, byte[] p_getBytes_2_) + { + return this.field_150794_a.getBytes(p_getBytes_1_, p_getBytes_2_); + } + + public ByteBuf getBytes(int p_getBytes_1_, byte[] p_getBytes_2_, int p_getBytes_3_, int p_getBytes_4_) + { + return this.field_150794_a.getBytes(p_getBytes_1_, p_getBytes_2_, p_getBytes_3_, p_getBytes_4_); + } + + public ByteBuf getBytes(int p_getBytes_1_, ByteBuffer p_getBytes_2_) + { + return this.field_150794_a.getBytes(p_getBytes_1_, p_getBytes_2_); + } + + public ByteBuf getBytes(int p_getBytes_1_, OutputStream p_getBytes_2_, int p_getBytes_3_) throws IOException + { + return this.field_150794_a.getBytes(p_getBytes_1_, p_getBytes_2_, p_getBytes_3_); + } + + public int getBytes(int p_getBytes_1_, GatheringByteChannel p_getBytes_2_, int p_getBytes_3_) throws IOException + { + return this.field_150794_a.getBytes(p_getBytes_1_, p_getBytes_2_, p_getBytes_3_); + } + + public ByteBuf setBoolean(int p_setBoolean_1_, boolean p_setBoolean_2_) + { + return this.field_150794_a.setBoolean(p_setBoolean_1_, p_setBoolean_2_); + } + + public ByteBuf setByte(int p_setByte_1_, int p_setByte_2_) + { + return this.field_150794_a.setByte(p_setByte_1_, p_setByte_2_); + } + + public ByteBuf setShort(int p_setShort_1_, int p_setShort_2_) + { + return this.field_150794_a.setShort(p_setShort_1_, p_setShort_2_); + } + + public ByteBuf setMedium(int p_setMedium_1_, int p_setMedium_2_) + { + return this.field_150794_a.setMedium(p_setMedium_1_, p_setMedium_2_); + } + + public ByteBuf setInt(int p_setInt_1_, int p_setInt_2_) + { + return this.field_150794_a.setInt(p_setInt_1_, p_setInt_2_); + } + + public ByteBuf setLong(int p_setLong_1_, long p_setLong_2_) + { + return this.field_150794_a.setLong(p_setLong_1_, p_setLong_2_); + } + + public ByteBuf setChar(int p_setChar_1_, int p_setChar_2_) + { + return this.field_150794_a.setChar(p_setChar_1_, p_setChar_2_); + } + + public ByteBuf setFloat(int p_setFloat_1_, float p_setFloat_2_) + { + return this.field_150794_a.setFloat(p_setFloat_1_, p_setFloat_2_); + } + + public ByteBuf setDouble(int p_setDouble_1_, double p_setDouble_2_) + { + return this.field_150794_a.setDouble(p_setDouble_1_, p_setDouble_2_); + } + + public ByteBuf setBytes(int p_setBytes_1_, ByteBuf p_setBytes_2_) + { + return this.field_150794_a.setBytes(p_setBytes_1_, p_setBytes_2_); + } + + public ByteBuf setBytes(int p_setBytes_1_, ByteBuf p_setBytes_2_, int p_setBytes_3_) + { + return this.field_150794_a.setBytes(p_setBytes_1_, p_setBytes_2_, p_setBytes_3_); + } + + public ByteBuf setBytes(int p_setBytes_1_, ByteBuf p_setBytes_2_, int p_setBytes_3_, int p_setBytes_4_) + { + return this.field_150794_a.setBytes(p_setBytes_1_, p_setBytes_2_, p_setBytes_3_, p_setBytes_4_); + } + + public ByteBuf setBytes(int p_setBytes_1_, byte[] p_setBytes_2_) + { + return this.field_150794_a.setBytes(p_setBytes_1_, p_setBytes_2_); + } + + public ByteBuf setBytes(int p_setBytes_1_, byte[] p_setBytes_2_, int p_setBytes_3_, int p_setBytes_4_) + { + return this.field_150794_a.setBytes(p_setBytes_1_, p_setBytes_2_, p_setBytes_3_, p_setBytes_4_); + } + + public ByteBuf setBytes(int p_setBytes_1_, ByteBuffer p_setBytes_2_) + { + return this.field_150794_a.setBytes(p_setBytes_1_, p_setBytes_2_); + } + + public int setBytes(int p_setBytes_1_, InputStream p_setBytes_2_, int p_setBytes_3_) throws IOException + { + return this.field_150794_a.setBytes(p_setBytes_1_, p_setBytes_2_, p_setBytes_3_); + } + + public int setBytes(int p_setBytes_1_, ScatteringByteChannel p_setBytes_2_, int p_setBytes_3_) throws IOException + { + return this.field_150794_a.setBytes(p_setBytes_1_, p_setBytes_2_, p_setBytes_3_); + } + + public ByteBuf setZero(int p_setZero_1_, int p_setZero_2_) + { + return this.field_150794_a.setZero(p_setZero_1_, p_setZero_2_); + } + + public boolean readBoolean() + { + return this.field_150794_a.readBoolean(); + } + + public byte readByte() + { + return this.field_150794_a.readByte(); + } + + public short readUnsignedByte() + { + return this.field_150794_a.readUnsignedByte(); + } + + public short readShort() + { + return this.field_150794_a.readShort(); + } + + public int readUnsignedShort() + { + return this.field_150794_a.readUnsignedShort(); + } + + public int readMedium() + { + return this.field_150794_a.readMedium(); + } + + public int readUnsignedMedium() + { + return this.field_150794_a.readUnsignedMedium(); + } + + public int readInt() + { + return this.field_150794_a.readInt(); + } + + public long readUnsignedInt() + { + return this.field_150794_a.readUnsignedInt(); + } + + public long readLong() + { + return this.field_150794_a.readLong(); + } + + public char readChar() + { + return this.field_150794_a.readChar(); + } + + public float readFloat() + { + return this.field_150794_a.readFloat(); + } + + public double readDouble() + { + return this.field_150794_a.readDouble(); + } + + public ByteBuf readBytes(int p_readBytes_1_) + { + return this.field_150794_a.readBytes(p_readBytes_1_); + } + + public ByteBuf readSlice(int p_readSlice_1_) + { + return this.field_150794_a.readSlice(p_readSlice_1_); + } + + public ByteBuf readBytes(ByteBuf p_readBytes_1_) + { + return this.field_150794_a.readBytes(p_readBytes_1_); + } + + public ByteBuf readBytes(ByteBuf p_readBytes_1_, int p_readBytes_2_) + { + return this.field_150794_a.readBytes(p_readBytes_1_, p_readBytes_2_); + } + + public ByteBuf readBytes(ByteBuf p_readBytes_1_, int p_readBytes_2_, int p_readBytes_3_) + { + return this.field_150794_a.readBytes(p_readBytes_1_, p_readBytes_2_, p_readBytes_3_); + } + + public ByteBuf readBytes(byte[] p_readBytes_1_) + { + return this.field_150794_a.readBytes(p_readBytes_1_); + } + + public ByteBuf readBytes(byte[] p_readBytes_1_, int p_readBytes_2_, int p_readBytes_3_) + { + return this.field_150794_a.readBytes(p_readBytes_1_, p_readBytes_2_, p_readBytes_3_); + } + + public ByteBuf readBytes(ByteBuffer p_readBytes_1_) + { + return this.field_150794_a.readBytes(p_readBytes_1_); + } + + public ByteBuf readBytes(OutputStream p_readBytes_1_, int p_readBytes_2_) throws IOException + { + return this.field_150794_a.readBytes(p_readBytes_1_, p_readBytes_2_); + } + + public int readBytes(GatheringByteChannel p_readBytes_1_, int p_readBytes_2_) throws IOException + { + return this.field_150794_a.readBytes(p_readBytes_1_, p_readBytes_2_); + } + + public ByteBuf skipBytes(int p_skipBytes_1_) + { + return this.field_150794_a.skipBytes(p_skipBytes_1_); + } + + public ByteBuf writeBoolean(boolean p_writeBoolean_1_) + { + return this.field_150794_a.writeBoolean(p_writeBoolean_1_); + } + + public ByteBuf writeByte(int p_writeByte_1_) + { + return this.field_150794_a.writeByte(p_writeByte_1_); + } + + public ByteBuf writeShort(int p_writeShort_1_) + { + return this.field_150794_a.writeShort(p_writeShort_1_); + } + + public ByteBuf writeMedium(int p_writeMedium_1_) + { + return this.field_150794_a.writeMedium(p_writeMedium_1_); + } + + public ByteBuf writeInt(int p_writeInt_1_) + { + return this.field_150794_a.writeInt(p_writeInt_1_); + } + + public ByteBuf writeLong(long p_writeLong_1_) + { + return this.field_150794_a.writeLong(p_writeLong_1_); + } + + public ByteBuf writeChar(int p_writeChar_1_) + { + return this.field_150794_a.writeChar(p_writeChar_1_); + } + + public ByteBuf writeFloat(float p_writeFloat_1_) + { + return this.field_150794_a.writeFloat(p_writeFloat_1_); + } + + public ByteBuf writeDouble(double p_writeDouble_1_) + { + return this.field_150794_a.writeDouble(p_writeDouble_1_); + } + + public ByteBuf writeBytes(ByteBuf p_writeBytes_1_) + { + return this.field_150794_a.writeBytes(p_writeBytes_1_); + } + + public ByteBuf writeBytes(ByteBuf p_writeBytes_1_, int p_writeBytes_2_) + { + return this.field_150794_a.writeBytes(p_writeBytes_1_, p_writeBytes_2_); + } + + public ByteBuf writeBytes(ByteBuf p_writeBytes_1_, int p_writeBytes_2_, int p_writeBytes_3_) + { + return this.field_150794_a.writeBytes(p_writeBytes_1_, p_writeBytes_2_, p_writeBytes_3_); + } + + public ByteBuf writeBytes(byte[] p_writeBytes_1_) + { + return this.field_150794_a.writeBytes(p_writeBytes_1_); + } + + public ByteBuf writeBytes(byte[] p_writeBytes_1_, int p_writeBytes_2_, int p_writeBytes_3_) + { + return this.field_150794_a.writeBytes(p_writeBytes_1_, p_writeBytes_2_, p_writeBytes_3_); + } + + public ByteBuf writeBytes(ByteBuffer p_writeBytes_1_) + { + return this.field_150794_a.writeBytes(p_writeBytes_1_); + } + + public int writeBytes(InputStream p_writeBytes_1_, int p_writeBytes_2_) throws IOException + { + return this.field_150794_a.writeBytes(p_writeBytes_1_, p_writeBytes_2_); + } + + public int writeBytes(ScatteringByteChannel p_writeBytes_1_, int p_writeBytes_2_) throws IOException + { + return this.field_150794_a.writeBytes(p_writeBytes_1_, p_writeBytes_2_); + } + + public ByteBuf writeZero(int p_writeZero_1_) + { + return this.field_150794_a.writeZero(p_writeZero_1_); + } + + public int indexOf(int p_indexOf_1_, int p_indexOf_2_, byte p_indexOf_3_) + { + return this.field_150794_a.indexOf(p_indexOf_1_, p_indexOf_2_, p_indexOf_3_); + } + + public int bytesBefore(byte p_bytesBefore_1_) + { + return this.field_150794_a.bytesBefore(p_bytesBefore_1_); + } + + public int bytesBefore(int p_bytesBefore_1_, byte p_bytesBefore_2_) + { + return this.field_150794_a.bytesBefore(p_bytesBefore_1_, p_bytesBefore_2_); + } + + public int bytesBefore(int p_bytesBefore_1_, int p_bytesBefore_2_, byte p_bytesBefore_3_) + { + return this.field_150794_a.bytesBefore(p_bytesBefore_1_, p_bytesBefore_2_, p_bytesBefore_3_); + } + + public int forEachByte(ByteBufProcessor p_forEachByte_1_) + { + return this.field_150794_a.forEachByte(p_forEachByte_1_); + } + + public int forEachByte(int p_forEachByte_1_, int p_forEachByte_2_, ByteBufProcessor p_forEachByte_3_) + { + return this.field_150794_a.forEachByte(p_forEachByte_1_, p_forEachByte_2_, p_forEachByte_3_); + } + + public int forEachByteDesc(ByteBufProcessor p_forEachByteDesc_1_) + { + return this.field_150794_a.forEachByteDesc(p_forEachByteDesc_1_); + } + + public int forEachByteDesc(int p_forEachByteDesc_1_, int p_forEachByteDesc_2_, ByteBufProcessor p_forEachByteDesc_3_) + { + return this.field_150794_a.forEachByteDesc(p_forEachByteDesc_1_, p_forEachByteDesc_2_, p_forEachByteDesc_3_); + } + + public ByteBuf copy() + { + return this.field_150794_a.copy(); + } + + public ByteBuf copy(int p_copy_1_, int p_copy_2_) + { + return this.field_150794_a.copy(p_copy_1_, p_copy_2_); + } + + public ByteBuf slice() + { + return this.field_150794_a.slice(); + } + + public ByteBuf slice(int p_slice_1_, int p_slice_2_) + { + return this.field_150794_a.slice(p_slice_1_, p_slice_2_); + } + + public ByteBuf duplicate() + { + return this.field_150794_a.duplicate(); + } + + public int nioBufferCount() + { + return this.field_150794_a.nioBufferCount(); + } + + public ByteBuffer nioBuffer() + { + return this.field_150794_a.nioBuffer(); + } + + public ByteBuffer nioBuffer(int p_nioBuffer_1_, int p_nioBuffer_2_) + { + return this.field_150794_a.nioBuffer(p_nioBuffer_1_, p_nioBuffer_2_); + } + + public ByteBuffer internalNioBuffer(int p_internalNioBuffer_1_, int p_internalNioBuffer_2_) + { + return this.field_150794_a.internalNioBuffer(p_internalNioBuffer_1_, p_internalNioBuffer_2_); + } + + public ByteBuffer[] nioBuffers() + { + return this.field_150794_a.nioBuffers(); + } + + public ByteBuffer[] nioBuffers(int p_nioBuffers_1_, int p_nioBuffers_2_) + { + return this.field_150794_a.nioBuffers(p_nioBuffers_1_, p_nioBuffers_2_); + } + + public boolean hasArray() + { + return this.field_150794_a.hasArray(); + } + + public byte[] array() + { + return this.field_150794_a.array(); + } + + public int arrayOffset() + { + return this.field_150794_a.arrayOffset(); + } + + public boolean hasMemoryAddress() + { + return this.field_150794_a.hasMemoryAddress(); + } + + public long memoryAddress() + { + return this.field_150794_a.memoryAddress(); + } + + public String toString(Charset p_toString_1_) + { + return this.field_150794_a.toString(p_toString_1_); + } + + public String toString(int p_toString_1_, int p_toString_2_, Charset p_toString_3_) + { + return this.field_150794_a.toString(p_toString_1_, p_toString_2_, p_toString_3_); + } + + public int hashCode() + { + return this.field_150794_a.hashCode(); + } + + public boolean equals(Object par1Obj) + { + return this.field_150794_a.equals(par1Obj); + } + + public int compareTo(ByteBuf par1Obj) + { + return this.field_150794_a.compareTo(par1Obj); + } + + public String toString() + { + return this.field_150794_a.toString(); + } + + public ByteBuf retain(int p_retain_1_) + { + return this.field_150794_a.retain(p_retain_1_); + } + + public ByteBuf retain() + { + return this.field_150794_a.retain(); + } + + public int refCnt() + { + return this.field_150794_a.refCnt(); + } + + public boolean release() + { + return this.field_150794_a.release(); + } + + public boolean release(int p_release_1_) + { + return this.field_150794_a.release(p_release_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/PingResponseHandler.java b/src/main/java/net/minecraft/network/PingResponseHandler.java new file mode 100644 index 0000000..de5220a --- /dev/null +++ b/src/main/java/net/minecraft/network/PingResponseHandler.java @@ -0,0 +1,123 @@ +package net.minecraft.network; + +import com.google.common.base.Charsets; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; +import io.netty.channel.ChannelFutureListener; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelInboundHandlerAdapter; +import java.net.InetSocketAddress; +import net.minecraft.server.MinecraftServer; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class PingResponseHandler extends ChannelInboundHandlerAdapter +{ + private static final Logger logger = LogManager.getLogger(); + private NetworkSystem field_151257_b; + private static final String __OBFID = "CL_00001444"; + + public PingResponseHandler(NetworkSystem p_i45286_1_) + { + this.field_151257_b = p_i45286_1_; + } + + public void channelRead(ChannelHandlerContext p_channelRead_1_, Object p_channelRead_2_) + { + ByteBuf bytebuf = (ByteBuf)p_channelRead_2_; + bytebuf.markReaderIndex(); + boolean flag = true; + + try + { + try + { + if (bytebuf.readUnsignedByte() != 254) + { + return; + } + + InetSocketAddress inetsocketaddress = (InetSocketAddress)p_channelRead_1_.channel().remoteAddress(); + MinecraftServer minecraftserver = this.field_151257_b.func_151267_d(); + int i = bytebuf.readableBytes(); + String s; + + switch (i) + { + case 0: + logger.debug("Ping: (<1.3.x) from {}:{}", new Object[] {inetsocketaddress.getAddress(), Integer.valueOf(inetsocketaddress.getPort())}); + s = String.format("%s\u00a7%d\u00a7%d", new Object[] {minecraftserver.getMOTD(), Integer.valueOf(minecraftserver.getCurrentPlayerCount()), Integer.valueOf(minecraftserver.getMaxPlayers())}); + this.func_151256_a(p_channelRead_1_, this.func_151255_a(s)); + break; + case 1: + if (bytebuf.readUnsignedByte() != 1) + { + return; + } + + logger.debug("Ping: (1.4-1.5.x) from {}:{}", new Object[] {inetsocketaddress.getAddress(), Integer.valueOf(inetsocketaddress.getPort())}); + s = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", new Object[] {Integer.valueOf(127), minecraftserver.getMinecraftVersion(), minecraftserver.getMOTD(), Integer.valueOf(minecraftserver.getCurrentPlayerCount()), Integer.valueOf(minecraftserver.getMaxPlayers())}); + this.func_151256_a(p_channelRead_1_, this.func_151255_a(s)); + break; + default: + boolean flag1 = bytebuf.readUnsignedByte() == 1; + flag1 &= bytebuf.readUnsignedByte() == 250; + flag1 &= "MC|PingHost".equals(new String(bytebuf.readBytes(bytebuf.readShort() * 2).array(), Charsets.UTF_16BE)); + int j = bytebuf.readUnsignedShort(); + flag1 &= bytebuf.readUnsignedByte() >= 73; + flag1 &= 3 + bytebuf.readBytes(bytebuf.readShort() * 2).array().length + 4 == j; + flag1 &= bytebuf.readInt() <= 65535; + flag1 &= bytebuf.readableBytes() == 0; + + if (!flag1) + { + return; + } + + logger.debug("Ping: (1.6) from {}:{}", new Object[] {inetsocketaddress.getAddress(), Integer.valueOf(inetsocketaddress.getPort())}); + String s1 = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", new Object[] {Integer.valueOf(127), minecraftserver.getMinecraftVersion(), minecraftserver.getMOTD(), Integer.valueOf(minecraftserver.getCurrentPlayerCount()), Integer.valueOf(minecraftserver.getMaxPlayers())}); + this.func_151256_a(p_channelRead_1_, this.func_151255_a(s1)); + } + + bytebuf.release(); + flag = false; + } + catch (RuntimeException runtimeexception) + { + ; + } + } + finally + { + if (flag) + { + bytebuf.resetReaderIndex(); + p_channelRead_1_.channel().pipeline().remove("legacy_query"); + p_channelRead_1_.fireChannelRead(p_channelRead_2_); + } + } + } + + private void func_151256_a(ChannelHandlerContext p_151256_1_, ByteBuf p_151256_2_) + { + p_151256_1_.pipeline().firstContext().writeAndFlush(p_151256_2_).addListener(ChannelFutureListener.CLOSE); + } + + private ByteBuf func_151255_a(String p_151255_1_) + { + ByteBuf bytebuf = Unpooled.buffer(); + bytebuf.writeByte(255); + char[] achar = p_151255_1_.toCharArray(); + bytebuf.writeShort(achar.length); + char[] achar1 = achar; + int i = achar.length; + + for (int j = 0; j < i; ++j) + { + char c0 = achar1[j]; + bytebuf.writeChar(c0); + } + + return bytebuf; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/ServerStatusResponse.java b/src/main/java/net/minecraft/network/ServerStatusResponse.java new file mode 100644 index 0000000..efd70ff --- /dev/null +++ b/src/main/java/net/minecraft/network/ServerStatusResponse.java @@ -0,0 +1,272 @@ +package net.minecraft.network; + +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import com.mojang.authlib.GameProfile; +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.common.network.internal.FMLNetworkHandler; +import java.lang.reflect.Type; +import net.minecraft.util.IChatComponent; +import net.minecraft.util.JsonUtils; + +public class ServerStatusResponse +{ + private IChatComponent field_151326_a; + private ServerStatusResponse.PlayerCountData field_151324_b; + private ServerStatusResponse.MinecraftProtocolVersionIdentifier field_151325_c; + private String field_151323_d; + private static final String __OBFID = "CL_00001385"; + + public IChatComponent func_151317_a() + { + return this.field_151326_a; + } + + public void func_151315_a(IChatComponent p_151315_1_) + { + this.field_151326_a = p_151315_1_; + } + + public ServerStatusResponse.PlayerCountData func_151318_b() + { + return this.field_151324_b; + } + + public void func_151319_a(ServerStatusResponse.PlayerCountData p_151319_1_) + { + this.field_151324_b = p_151319_1_; + } + + public ServerStatusResponse.MinecraftProtocolVersionIdentifier func_151322_c() + { + return this.field_151325_c; + } + + public void func_151321_a(ServerStatusResponse.MinecraftProtocolVersionIdentifier p_151321_1_) + { + this.field_151325_c = p_151321_1_; + } + + public void func_151320_a(String p_151320_1_) + { + this.field_151323_d = p_151320_1_; + } + + public String func_151316_d() + { + return this.field_151323_d; + } + + public static class MinecraftProtocolVersionIdentifier + { + private final String field_151306_a; + private final int field_151305_b; + private static final String __OBFID = "CL_00001389"; + + public MinecraftProtocolVersionIdentifier(String p_i45275_1_, int p_i45275_2_) + { + this.field_151306_a = p_i45275_1_; + this.field_151305_b = p_i45275_2_; + } + + public String func_151303_a() + { + return this.field_151306_a; + } + + public int func_151304_b() + { + return this.field_151305_b; + } + + public static class Serializer implements JsonDeserializer, JsonSerializer + { + private static final String __OBFID = "CL_00001390"; + + public ServerStatusResponse.MinecraftProtocolVersionIdentifier deserialize(JsonElement p_151309_1_, Type p_151309_2_, JsonDeserializationContext p_151309_3_) + { + JsonObject jsonobject = JsonUtils.getJsonElementAsJsonObject(p_151309_1_, "version"); + return new ServerStatusResponse.MinecraftProtocolVersionIdentifier(JsonUtils.getJsonObjectStringFieldValue(jsonobject, "name"), JsonUtils.getJsonObjectIntegerFieldValue(jsonobject, "protocol")); + } + + public JsonElement serialize(ServerStatusResponse.MinecraftProtocolVersionIdentifier p_151310_1_, Type p_151310_2_, JsonSerializationContext p_151310_3_) + { + JsonObject jsonobject = new JsonObject(); + jsonobject.addProperty("name", p_151310_1_.func_151303_a()); + jsonobject.addProperty("protocol", Integer.valueOf(p_151310_1_.func_151304_b())); + return jsonobject; + } + + public JsonElement serialize(Object par1Obj, Type par2Type, JsonSerializationContext par3JsonSerializationContext) + { + return this.serialize((ServerStatusResponse.MinecraftProtocolVersionIdentifier)par1Obj, par2Type, par3JsonSerializationContext); + } + } + } + + public static class PlayerCountData + { + private final int field_151336_a; + private final int field_151334_b; + private GameProfile[] field_151335_c; + private static final String __OBFID = "CL_00001386"; + + public PlayerCountData(int p_i45274_1_, int p_i45274_2_) + { + this.field_151336_a = p_i45274_1_; + this.field_151334_b = p_i45274_2_; + } + + public int func_151332_a() + { + return this.field_151336_a; + } + + public int func_151333_b() + { + return this.field_151334_b; + } + + public GameProfile[] func_151331_c() + { + return this.field_151335_c; + } + + public void func_151330_a(GameProfile[] p_151330_1_) + { + this.field_151335_c = p_151330_1_; + } + + public static class Serializer implements JsonDeserializer, JsonSerializer + { + private static final String __OBFID = "CL_00001387"; + + public ServerStatusResponse.PlayerCountData deserialize(JsonElement p_151311_1_, Type p_151311_2_, JsonDeserializationContext p_151311_3_) + { + JsonObject jsonobject = JsonUtils.getJsonElementAsJsonObject(p_151311_1_, "players"); + ServerStatusResponse.PlayerCountData playercountdata = new ServerStatusResponse.PlayerCountData(JsonUtils.getJsonObjectIntegerFieldValue(jsonobject, "max"), JsonUtils.getJsonObjectIntegerFieldValue(jsonobject, "online")); + + if (JsonUtils.jsonObjectFieldTypeIsArray(jsonobject, "sample")) + { + JsonArray jsonarray = JsonUtils.getJsonObjectJsonArrayField(jsonobject, "sample"); + + if (jsonarray.size() > 0) + { + GameProfile[] agameprofile = new GameProfile[jsonarray.size()]; + + for (int i = 0; i < agameprofile.length; ++i) + { + JsonObject jsonobject1 = JsonUtils.getJsonElementAsJsonObject(jsonarray.get(i), "player[" + i + "]"); + agameprofile[i] = new GameProfile(JsonUtils.getJsonObjectStringFieldValue(jsonobject1, "id"), JsonUtils.getJsonObjectStringFieldValue(jsonobject1, "name")); + } + + playercountdata.func_151330_a(agameprofile); + } + } + + return playercountdata; + } + + public JsonElement serialize(ServerStatusResponse.PlayerCountData p_151312_1_, Type p_151312_2_, JsonSerializationContext p_151312_3_) + { + JsonObject jsonobject = new JsonObject(); + jsonobject.addProperty("max", Integer.valueOf(p_151312_1_.func_151332_a())); + jsonobject.addProperty("online", Integer.valueOf(p_151312_1_.func_151333_b())); + + if (p_151312_1_.func_151331_c() != null && p_151312_1_.func_151331_c().length > 0) + { + JsonArray jsonarray = new JsonArray(); + + for (int i = 0; i < p_151312_1_.func_151331_c().length; ++i) + { + JsonObject jsonobject1 = new JsonObject(); + jsonobject1.addProperty("id", p_151312_1_.func_151331_c()[i].getId()); + jsonobject1.addProperty("name", p_151312_1_.func_151331_c()[i].getName()); + jsonarray.add(jsonobject1); + } + + jsonobject.add("sample", jsonarray); + } + + return jsonobject; + } + + public JsonElement serialize(Object par1Obj, Type par2Type, JsonSerializationContext par3JsonSerializationContext) + { + return this.serialize((ServerStatusResponse.PlayerCountData)par1Obj, par2Type, par3JsonSerializationContext); + } + } + } + + public static class Serializer implements JsonDeserializer, JsonSerializer + { + private static final String __OBFID = "CL_00001388"; + + public ServerStatusResponse deserialize(JsonElement p_151314_1_, Type p_151314_2_, JsonDeserializationContext p_151314_3_) + { + JsonObject jsonobject = JsonUtils.getJsonElementAsJsonObject(p_151314_1_, "status"); + ServerStatusResponse serverstatusresponse = new ServerStatusResponse(); + + if (jsonobject.has("description")) + { + serverstatusresponse.func_151315_a((IChatComponent)p_151314_3_.deserialize(jsonobject.get("description"), IChatComponent.class)); + } + + if (jsonobject.has("players")) + { + serverstatusresponse.func_151319_a((ServerStatusResponse.PlayerCountData)p_151314_3_.deserialize(jsonobject.get("players"), ServerStatusResponse.PlayerCountData.class)); + } + + if (jsonobject.has("version")) + { + serverstatusresponse.func_151321_a((ServerStatusResponse.MinecraftProtocolVersionIdentifier)p_151314_3_.deserialize(jsonobject.get("version"), ServerStatusResponse.MinecraftProtocolVersionIdentifier.class)); + } + + if (jsonobject.has("favicon")) + { + serverstatusresponse.func_151320_a(JsonUtils.getJsonObjectStringFieldValue(jsonobject, "favicon")); + } + + FMLClientHandler.instance().captureAdditionalData(serverstatusresponse, jsonobject); + return serverstatusresponse; + } + + public JsonElement serialize(ServerStatusResponse p_151313_1_, Type p_151313_2_, JsonSerializationContext p_151313_3_) + { + JsonObject jsonobject = new JsonObject(); + + if (p_151313_1_.func_151317_a() != null) + { + jsonobject.add("description", p_151313_3_.serialize(p_151313_1_.func_151317_a())); + } + + if (p_151313_1_.func_151318_b() != null) + { + jsonobject.add("players", p_151313_3_.serialize(p_151313_1_.func_151318_b())); + } + + if (p_151313_1_.func_151322_c() != null) + { + jsonobject.add("version", p_151313_3_.serialize(p_151313_1_.func_151322_c())); + } + + if (p_151313_1_.func_151316_d() != null) + { + jsonobject.addProperty("favicon", p_151313_1_.func_151316_d()); + } + + FMLNetworkHandler.enhanceStatusQuery(jsonobject); + return jsonobject; + } + + public JsonElement serialize(Object par1Obj, Type par2Type, JsonSerializationContext par3JsonSerializationContext) + { + return this.serialize((ServerStatusResponse)par1Obj, par2Type, par3JsonSerializationContext); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/handshake/INetHandlerHandshakeServer.java b/src/main/java/net/minecraft/network/handshake/INetHandlerHandshakeServer.java new file mode 100644 index 0000000..21a6e51 --- /dev/null +++ b/src/main/java/net/minecraft/network/handshake/INetHandlerHandshakeServer.java @@ -0,0 +1,9 @@ +package net.minecraft.network.handshake; + +import net.minecraft.network.INetHandler; +import net.minecraft.network.handshake.client.C00Handshake; + +public interface INetHandlerHandshakeServer extends INetHandler +{ + void processHandshake(C00Handshake var1); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/handshake/client/C00Handshake.java b/src/main/java/net/minecraft/network/handshake/client/C00Handshake.java new file mode 100644 index 0000000..1162f6b --- /dev/null +++ b/src/main/java/net/minecraft/network/handshake/client/C00Handshake.java @@ -0,0 +1,71 @@ +package net.minecraft.network.handshake.client; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.EnumConnectionState; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.handshake.INetHandlerHandshakeServer; + +public class C00Handshake extends Packet +{ + private int field_149600_a; + private String field_149598_b; + private int field_149599_c; + private EnumConnectionState field_149597_d; + private static final String __OBFID = "CL_00001372"; + + public C00Handshake() {} + + @SideOnly(Side.CLIENT) + public C00Handshake(int p_i45266_1_, String p_i45266_2_, int p_i45266_3_, EnumConnectionState p_i45266_4_) + { + this.field_149600_a = p_i45266_1_; + this.field_149598_b = p_i45266_2_; + this.field_149599_c = p_i45266_3_; + this.field_149597_d = p_i45266_4_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149600_a = p_148837_1_.readVarIntFromBuffer(); + this.field_149598_b = p_148837_1_.readStringFromBuffer(255); + this.field_149599_c = p_148837_1_.readUnsignedShort(); + this.field_149597_d = EnumConnectionState.func_150760_a(p_148837_1_.readVarIntFromBuffer()); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeVarIntToBuffer(this.field_149600_a); + p_148840_1_.writeStringToBuffer(this.field_149598_b); + p_148840_1_.writeShort(this.field_149599_c); + p_148840_1_.writeVarIntToBuffer(this.field_149597_d.func_150759_c()); + } + + public void processPacket(INetHandlerHandshakeServer p_149596_1_) + { + p_149596_1_.processHandshake(this); + } + + public boolean hasPriority() + { + return true; + } + + public EnumConnectionState func_149594_c() + { + return this.field_149597_d; + } + + public int func_149595_d() + { + return this.field_149600_a; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerHandshakeServer)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/login/INetHandlerLoginClient.java b/src/main/java/net/minecraft/network/login/INetHandlerLoginClient.java new file mode 100644 index 0000000..af75e90 --- /dev/null +++ b/src/main/java/net/minecraft/network/login/INetHandlerLoginClient.java @@ -0,0 +1,15 @@ +package net.minecraft.network.login; + +import net.minecraft.network.INetHandler; +import net.minecraft.network.login.server.S00PacketDisconnect; +import net.minecraft.network.login.server.S01PacketEncryptionRequest; +import net.minecraft.network.login.server.S02PacketLoginSuccess; + +public interface INetHandlerLoginClient extends INetHandler +{ + void handleEncryptionRequest(S01PacketEncryptionRequest var1); + + void handleLoginSuccess(S02PacketLoginSuccess var1); + + void handleDisconnect(S00PacketDisconnect var1); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/login/INetHandlerLoginServer.java b/src/main/java/net/minecraft/network/login/INetHandlerLoginServer.java new file mode 100644 index 0000000..ff58632 --- /dev/null +++ b/src/main/java/net/minecraft/network/login/INetHandlerLoginServer.java @@ -0,0 +1,12 @@ +package net.minecraft.network.login; + +import net.minecraft.network.INetHandler; +import net.minecraft.network.login.client.C00PacketLoginStart; +import net.minecraft.network.login.client.C01PacketEncryptionResponse; + +public interface INetHandlerLoginServer extends INetHandler +{ + void processLoginStart(C00PacketLoginStart var1); + + void processEncryptionResponse(C01PacketEncryptionResponse var1); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/login/client/C00PacketLoginStart.java b/src/main/java/net/minecraft/network/login/client/C00PacketLoginStart.java new file mode 100644 index 0000000..607f9fa --- /dev/null +++ b/src/main/java/net/minecraft/network/login/client/C00PacketLoginStart.java @@ -0,0 +1,46 @@ +package net.minecraft.network.login.client; + +import com.mojang.authlib.GameProfile; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.login.INetHandlerLoginServer; + +public class C00PacketLoginStart extends Packet +{ + private GameProfile field_149305_a; + private static final String __OBFID = "CL_00001379"; + + public C00PacketLoginStart() {} + + public C00PacketLoginStart(GameProfile p_i45270_1_) + { + this.field_149305_a = p_i45270_1_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149305_a = new GameProfile((String)null, p_148837_1_.readStringFromBuffer(16)); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeStringToBuffer(this.field_149305_a.getName()); + } + + public void processPacket(INetHandlerLoginServer p_149303_1_) + { + p_149303_1_.processLoginStart(this); + } + + public GameProfile func_149304_c() + { + return this.field_149305_a; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerLoginServer)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/login/client/C01PacketEncryptionResponse.java b/src/main/java/net/minecraft/network/login/client/C01PacketEncryptionResponse.java new file mode 100644 index 0000000..e00512d --- /dev/null +++ b/src/main/java/net/minecraft/network/login/client/C01PacketEncryptionResponse.java @@ -0,0 +1,61 @@ +package net.minecraft.network.login.client; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import java.security.PrivateKey; +import java.security.PublicKey; +import javax.crypto.SecretKey; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.login.INetHandlerLoginServer; +import net.minecraft.util.CryptManager; + +public class C01PacketEncryptionResponse extends Packet +{ + private byte[] field_149302_a = new byte[0]; + private byte[] field_149301_b = new byte[0]; + private static final String __OBFID = "CL_00001380"; + + public C01PacketEncryptionResponse() {} + + @SideOnly(Side.CLIENT) + public C01PacketEncryptionResponse(SecretKey p_i45271_1_, PublicKey p_i45271_2_, byte[] p_i45271_3_) + { + this.field_149302_a = CryptManager.encryptData(p_i45271_2_, p_i45271_1_.getEncoded()); + this.field_149301_b = CryptManager.encryptData(p_i45271_2_, p_i45271_3_); + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149302_a = readBlob(p_148837_1_); + this.field_149301_b = readBlob(p_148837_1_); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + writeBlob(p_148840_1_, this.field_149302_a); + writeBlob(p_148840_1_, this.field_149301_b); + } + + public void processPacket(INetHandlerLoginServer p_149298_1_) + { + p_149298_1_.processEncryptionResponse(this); + } + + public SecretKey func_149300_a(PrivateKey p_149300_1_) + { + return CryptManager.decryptSharedKey(p_149300_1_, this.field_149302_a); + } + + public byte[] func_149299_b(PrivateKey p_149299_1_) + { + return p_149299_1_ == null ? this.field_149301_b : CryptManager.decryptData(p_149299_1_, this.field_149301_b); + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerLoginServer)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/login/server/S00PacketDisconnect.java b/src/main/java/net/minecraft/network/login/server/S00PacketDisconnect.java new file mode 100644 index 0000000..138fedf --- /dev/null +++ b/src/main/java/net/minecraft/network/login/server/S00PacketDisconnect.java @@ -0,0 +1,54 @@ +package net.minecraft.network.login.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.login.INetHandlerLoginClient; +import net.minecraft.util.IChatComponent; + +public class S00PacketDisconnect extends Packet +{ + private IChatComponent field_149605_a; + private static final String __OBFID = "CL_00001377"; + + public S00PacketDisconnect() {} + + public S00PacketDisconnect(IChatComponent p_i45269_1_) + { + this.field_149605_a = p_i45269_1_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149605_a = IChatComponent.Serializer.func_150699_a(p_148837_1_.readStringFromBuffer(32767)); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeStringToBuffer(IChatComponent.Serializer.func_150696_a(this.field_149605_a)); + } + + public void processPacket(INetHandlerLoginClient p_149604_1_) + { + p_149604_1_.handleDisconnect(this); + } + + public boolean hasPriority() + { + return true; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerLoginClient)p_148833_1_); + } + + @SideOnly(Side.CLIENT) + public IChatComponent func_149603_c() + { + return this.field_149605_a; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/login/server/S01PacketEncryptionRequest.java b/src/main/java/net/minecraft/network/login/server/S01PacketEncryptionRequest.java new file mode 100644 index 0000000..e46b551 --- /dev/null +++ b/src/main/java/net/minecraft/network/login/server/S01PacketEncryptionRequest.java @@ -0,0 +1,70 @@ +package net.minecraft.network.login.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import java.security.PublicKey; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.login.INetHandlerLoginClient; +import net.minecraft.util.CryptManager; + +public class S01PacketEncryptionRequest extends Packet +{ + private String field_149612_a; + private PublicKey field_149610_b; + private byte[] field_149611_c; + private static final String __OBFID = "CL_00001376"; + + public S01PacketEncryptionRequest() {} + + public S01PacketEncryptionRequest(String p_i45268_1_, PublicKey p_i45268_2_, byte[] p_i45268_3_) + { + this.field_149612_a = p_i45268_1_; + this.field_149610_b = p_i45268_2_; + this.field_149611_c = p_i45268_3_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149612_a = p_148837_1_.readStringFromBuffer(20); + this.field_149610_b = CryptManager.decodePublicKey(readBlob(p_148837_1_)); + this.field_149611_c = readBlob(p_148837_1_); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeStringToBuffer(this.field_149612_a); + writeBlob(p_148840_1_, this.field_149610_b.getEncoded()); + writeBlob(p_148840_1_, this.field_149611_c); + } + + public void processPacket(INetHandlerLoginClient p_149606_1_) + { + p_149606_1_.handleEncryptionRequest(this); + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerLoginClient)p_148833_1_); + } + + @SideOnly(Side.CLIENT) + public String func_149609_c() + { + return this.field_149612_a; + } + + @SideOnly(Side.CLIENT) + public PublicKey func_149608_d() + { + return this.field_149610_b; + } + + @SideOnly(Side.CLIENT) + public byte[] func_149607_e() + { + return this.field_149611_c; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/login/server/S02PacketLoginSuccess.java b/src/main/java/net/minecraft/network/login/server/S02PacketLoginSuccess.java new file mode 100644 index 0000000..487cfa4 --- /dev/null +++ b/src/main/java/net/minecraft/network/login/server/S02PacketLoginSuccess.java @@ -0,0 +1,49 @@ +package net.minecraft.network.login.server; + +import com.mojang.authlib.GameProfile; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.login.INetHandlerLoginClient; + +public class S02PacketLoginSuccess extends Packet +{ + private GameProfile field_149602_a; + private static final String __OBFID = "CL_00001375"; + + public S02PacketLoginSuccess() {} + + public S02PacketLoginSuccess(GameProfile p_i45267_1_) + { + this.field_149602_a = p_i45267_1_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + String s = p_148837_1_.readStringFromBuffer(36); + String s1 = p_148837_1_.readStringFromBuffer(16); + this.field_149602_a = new GameProfile(s, s1); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeStringToBuffer(this.field_149602_a.getId()); + p_148840_1_.writeStringToBuffer(this.field_149602_a.getName()); + } + + public void processPacket(INetHandlerLoginClient p_149601_1_) + { + p_149601_1_.handleLoginSuccess(this); + } + + public boolean hasPriority() + { + return true; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerLoginClient)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/INetHandlerPlayClient.java b/src/main/java/net/minecraft/network/play/INetHandlerPlayClient.java new file mode 100644 index 0000000..3e08272 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/INetHandlerPlayClient.java @@ -0,0 +1,192 @@ +package net.minecraft.network.play; + +import net.minecraft.network.INetHandler; +import net.minecraft.network.play.server.S00PacketKeepAlive; +import net.minecraft.network.play.server.S01PacketJoinGame; +import net.minecraft.network.play.server.S02PacketChat; +import net.minecraft.network.play.server.S03PacketTimeUpdate; +import net.minecraft.network.play.server.S04PacketEntityEquipment; +import net.minecraft.network.play.server.S05PacketSpawnPosition; +import net.minecraft.network.play.server.S06PacketUpdateHealth; +import net.minecraft.network.play.server.S07PacketRespawn; +import net.minecraft.network.play.server.S08PacketPlayerPosLook; +import net.minecraft.network.play.server.S09PacketHeldItemChange; +import net.minecraft.network.play.server.S0APacketUseBed; +import net.minecraft.network.play.server.S0BPacketAnimation; +import net.minecraft.network.play.server.S0CPacketSpawnPlayer; +import net.minecraft.network.play.server.S0DPacketCollectItem; +import net.minecraft.network.play.server.S0EPacketSpawnObject; +import net.minecraft.network.play.server.S0FPacketSpawnMob; +import net.minecraft.network.play.server.S10PacketSpawnPainting; +import net.minecraft.network.play.server.S11PacketSpawnExperienceOrb; +import net.minecraft.network.play.server.S12PacketEntityVelocity; +import net.minecraft.network.play.server.S13PacketDestroyEntities; +import net.minecraft.network.play.server.S14PacketEntity; +import net.minecraft.network.play.server.S18PacketEntityTeleport; +import net.minecraft.network.play.server.S19PacketEntityHeadLook; +import net.minecraft.network.play.server.S19PacketEntityStatus; +import net.minecraft.network.play.server.S1BPacketEntityAttach; +import net.minecraft.network.play.server.S1CPacketEntityMetadata; +import net.minecraft.network.play.server.S1DPacketEntityEffect; +import net.minecraft.network.play.server.S1EPacketRemoveEntityEffect; +import net.minecraft.network.play.server.S1FPacketSetExperience; +import net.minecraft.network.play.server.S20PacketEntityProperties; +import net.minecraft.network.play.server.S21PacketChunkData; +import net.minecraft.network.play.server.S22PacketMultiBlockChange; +import net.minecraft.network.play.server.S23PacketBlockChange; +import net.minecraft.network.play.server.S24PacketBlockAction; +import net.minecraft.network.play.server.S25PacketBlockBreakAnim; +import net.minecraft.network.play.server.S26PacketMapChunkBulk; +import net.minecraft.network.play.server.S27PacketExplosion; +import net.minecraft.network.play.server.S28PacketEffect; +import net.minecraft.network.play.server.S29PacketSoundEffect; +import net.minecraft.network.play.server.S2APacketParticles; +import net.minecraft.network.play.server.S2BPacketChangeGameState; +import net.minecraft.network.play.server.S2CPacketSpawnGlobalEntity; +import net.minecraft.network.play.server.S2DPacketOpenWindow; +import net.minecraft.network.play.server.S2EPacketCloseWindow; +import net.minecraft.network.play.server.S2FPacketSetSlot; +import net.minecraft.network.play.server.S30PacketWindowItems; +import net.minecraft.network.play.server.S31PacketWindowProperty; +import net.minecraft.network.play.server.S32PacketConfirmTransaction; +import net.minecraft.network.play.server.S33PacketUpdateSign; +import net.minecraft.network.play.server.S34PacketMaps; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.network.play.server.S36PacketSignEditorOpen; +import net.minecraft.network.play.server.S37PacketStatistics; +import net.minecraft.network.play.server.S38PacketPlayerListItem; +import net.minecraft.network.play.server.S39PacketPlayerAbilities; +import net.minecraft.network.play.server.S3APacketTabComplete; +import net.minecraft.network.play.server.S3BPacketScoreboardObjective; +import net.minecraft.network.play.server.S3CPacketUpdateScore; +import net.minecraft.network.play.server.S3DPacketDisplayScoreboard; +import net.minecraft.network.play.server.S3EPacketTeams; +import net.minecraft.network.play.server.S3FPacketCustomPayload; +import net.minecraft.network.play.server.S40PacketDisconnect; + +public interface INetHandlerPlayClient extends INetHandler +{ + void handleSpawnObject(S0EPacketSpawnObject var1); + + void handleSpawnExperienceOrb(S11PacketSpawnExperienceOrb var1); + + void handleSpawnGlobalEntity(S2CPacketSpawnGlobalEntity var1); + + void handleSpawnMob(S0FPacketSpawnMob var1); + + void handleScoreboardObjective(S3BPacketScoreboardObjective var1); + + void handleSpawnPainting(S10PacketSpawnPainting var1); + + void handleSpawnPlayer(S0CPacketSpawnPlayer var1); + + void handleAnimation(S0BPacketAnimation var1); + + void handleStatistics(S37PacketStatistics var1); + + void handleBlockBreakAnim(S25PacketBlockBreakAnim var1); + + void handleSignEditorOpen(S36PacketSignEditorOpen var1); + + void handleUpdateTileEntity(S35PacketUpdateTileEntity var1); + + void handleBlockAction(S24PacketBlockAction var1); + + void handleBlockChange(S23PacketBlockChange var1); + + void handleChat(S02PacketChat var1); + + void handleTabComplete(S3APacketTabComplete var1); + + void handleMultiBlockChange(S22PacketMultiBlockChange var1); + + void handleMaps(S34PacketMaps var1); + + void handleConfirmTransaction(S32PacketConfirmTransaction var1); + + void handleCloseWindow(S2EPacketCloseWindow var1); + + void handleWindowItems(S30PacketWindowItems var1); + + void handleOpenWindow(S2DPacketOpenWindow var1); + + void handleWindowProperty(S31PacketWindowProperty var1); + + void handleSetSlot(S2FPacketSetSlot var1); + + void handleCustomPayload(S3FPacketCustomPayload var1); + + void handleDisconnect(S40PacketDisconnect var1); + + void handleUseBed(S0APacketUseBed var1); + + void handleEntityStatus(S19PacketEntityStatus var1); + + void handleEntityAttach(S1BPacketEntityAttach var1); + + void handleExplosion(S27PacketExplosion var1); + + void handleChangeGameState(S2BPacketChangeGameState var1); + + void handleKeepAlive(S00PacketKeepAlive var1); + + void handleChunkData(S21PacketChunkData var1); + + void handleMapChunkBulk(S26PacketMapChunkBulk var1); + + void handleEffect(S28PacketEffect var1); + + void handleJoinGame(S01PacketJoinGame var1); + + void handleEntityMovement(S14PacketEntity var1); + + void handlePlayerPosLook(S08PacketPlayerPosLook var1); + + void handleParticles(S2APacketParticles var1); + + void handlePlayerAbilities(S39PacketPlayerAbilities var1); + + void handlePlayerListItem(S38PacketPlayerListItem var1); + + void handleDestroyEntities(S13PacketDestroyEntities var1); + + void handleRemoveEntityEffect(S1EPacketRemoveEntityEffect var1); + + void handleRespawn(S07PacketRespawn var1); + + void handleEntityHeadLook(S19PacketEntityHeadLook var1); + + void handleHeldItemChange(S09PacketHeldItemChange var1); + + void handleDisplayScoreboard(S3DPacketDisplayScoreboard var1); + + void handleEntityMetadata(S1CPacketEntityMetadata var1); + + void handleEntityVelocity(S12PacketEntityVelocity var1); + + void handleEntityEquipment(S04PacketEntityEquipment var1); + + void handleSetExperience(S1FPacketSetExperience var1); + + void handleUpdateHealth(S06PacketUpdateHealth var1); + + void handleTeams(S3EPacketTeams var1); + + void handleUpdateScore(S3CPacketUpdateScore var1); + + void handleSpawnPosition(S05PacketSpawnPosition var1); + + void handleTimeUpdate(S03PacketTimeUpdate var1); + + void handleUpdateSign(S33PacketUpdateSign var1); + + void handleSoundEffect(S29PacketSoundEffect var1); + + void handleCollectItem(S0DPacketCollectItem var1); + + void handleEntityTeleport(S18PacketEntityTeleport var1); + + void handleEntityProperties(S20PacketEntityProperties var1); + + void handleEntityEffect(S1DPacketEntityEffect var1); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/INetHandlerPlayServer.java b/src/main/java/net/minecraft/network/play/INetHandlerPlayServer.java new file mode 100644 index 0000000..4c09b21 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/INetHandlerPlayServer.java @@ -0,0 +1,69 @@ +package net.minecraft.network.play; + +import net.minecraft.network.INetHandler; +import net.minecraft.network.play.client.C00PacketKeepAlive; +import net.minecraft.network.play.client.C01PacketChatMessage; +import net.minecraft.network.play.client.C02PacketUseEntity; +import net.minecraft.network.play.client.C03PacketPlayer; +import net.minecraft.network.play.client.C07PacketPlayerDigging; +import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement; +import net.minecraft.network.play.client.C09PacketHeldItemChange; +import net.minecraft.network.play.client.C0APacketAnimation; +import net.minecraft.network.play.client.C0BPacketEntityAction; +import net.minecraft.network.play.client.C0CPacketInput; +import net.minecraft.network.play.client.C0DPacketCloseWindow; +import net.minecraft.network.play.client.C0EPacketClickWindow; +import net.minecraft.network.play.client.C0FPacketConfirmTransaction; +import net.minecraft.network.play.client.C10PacketCreativeInventoryAction; +import net.minecraft.network.play.client.C11PacketEnchantItem; +import net.minecraft.network.play.client.C12PacketUpdateSign; +import net.minecraft.network.play.client.C13PacketPlayerAbilities; +import net.minecraft.network.play.client.C14PacketTabComplete; +import net.minecraft.network.play.client.C15PacketClientSettings; +import net.minecraft.network.play.client.C16PacketClientStatus; +import net.minecraft.network.play.client.C17PacketCustomPayload; + +public interface INetHandlerPlayServer extends INetHandler +{ + void processAnimation(C0APacketAnimation var1); + + void processChatMessage(C01PacketChatMessage var1); + + void processTabComplete(C14PacketTabComplete var1); + + void processClientStatus(C16PacketClientStatus var1); + + void processClientSettings(C15PacketClientSettings var1); + + void processConfirmTransaction(C0FPacketConfirmTransaction var1); + + void processEnchantItem(C11PacketEnchantItem var1); + + void processClickWindow(C0EPacketClickWindow var1); + + void processCloseWindow(C0DPacketCloseWindow var1); + + void processVanilla250Packet(C17PacketCustomPayload var1); + + void processUseEntity(C02PacketUseEntity var1); + + void processKeepAlive(C00PacketKeepAlive var1); + + void processPlayer(C03PacketPlayer var1); + + void processPlayerAbilities(C13PacketPlayerAbilities var1); + + void processPlayerDigging(C07PacketPlayerDigging var1); + + void processEntityAction(C0BPacketEntityAction var1); + + void processInput(C0CPacketInput var1); + + void processHeldItemChange(C09PacketHeldItemChange var1); + + void processCreativeInventoryAction(C10PacketCreativeInventoryAction var1); + + void processUpdateSign(C12PacketUpdateSign var1); + + void processPlayerBlockPlacement(C08PacketPlayerBlockPlacement var1); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/client/C00PacketKeepAlive.java b/src/main/java/net/minecraft/network/play/client/C00PacketKeepAlive.java new file mode 100644 index 0000000..82b56bb --- /dev/null +++ b/src/main/java/net/minecraft/network/play/client/C00PacketKeepAlive.java @@ -0,0 +1,53 @@ +package net.minecraft.network.play.client; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayServer; + +public class C00PacketKeepAlive extends Packet +{ + private int field_149461_a; + private static final String __OBFID = "CL_00001359"; + + public C00PacketKeepAlive() {} + + @SideOnly(Side.CLIENT) + public C00PacketKeepAlive(int p_i45252_1_) + { + this.field_149461_a = p_i45252_1_; + } + + public void processPacket(INetHandlerPlayServer p_149459_1_) + { + p_149459_1_.processKeepAlive(this); + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149461_a = p_148837_1_.readInt(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeInt(this.field_149461_a); + } + + public boolean hasPriority() + { + return true; + } + + public int func_149460_c() + { + return this.field_149461_a; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayServer)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/client/C01PacketChatMessage.java b/src/main/java/net/minecraft/network/play/client/C01PacketChatMessage.java new file mode 100644 index 0000000..072696e --- /dev/null +++ b/src/main/java/net/minecraft/network/play/client/C01PacketChatMessage.java @@ -0,0 +1,55 @@ +package net.minecraft.network.play.client; + +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayServer; + +public class C01PacketChatMessage extends Packet +{ + private String field_149440_a; + private static final String __OBFID = "CL_00001347"; + + public C01PacketChatMessage() {} + + public C01PacketChatMessage(String p_i45240_1_) + { + if (p_i45240_1_.length() > 100) + { + p_i45240_1_ = p_i45240_1_.substring(0, 100); + } + + this.field_149440_a = p_i45240_1_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149440_a = p_148837_1_.readStringFromBuffer(100); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeStringToBuffer(this.field_149440_a); + } + + public void processPacket(INetHandlerPlayServer p_149438_1_) + { + p_149438_1_.processChatMessage(this); + } + + public String serialize() + { + return String.format("message=\'%s\'", new Object[] {this.field_149440_a}); + } + + public String func_149439_c() + { + return this.field_149440_a; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayServer)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/client/C02PacketUseEntity.java b/src/main/java/net/minecraft/network/play/client/C02PacketUseEntity.java new file mode 100644 index 0000000..2189ad8 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/client/C02PacketUseEntity.java @@ -0,0 +1,86 @@ +package net.minecraft.network.play.client; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.entity.Entity; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayServer; +import net.minecraft.world.World; + +public class C02PacketUseEntity extends Packet +{ + private int field_149567_a; + private C02PacketUseEntity.Action field_149566_b; + private static final String __OBFID = "CL_00001357"; + + public C02PacketUseEntity() {} + + @SideOnly(Side.CLIENT) + public C02PacketUseEntity(Entity p_i45251_1_, C02PacketUseEntity.Action p_i45251_2_) + { + this.field_149567_a = p_i45251_1_.getEntityId(); + this.field_149566_b = p_i45251_2_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149567_a = p_148837_1_.readInt(); + this.field_149566_b = C02PacketUseEntity.Action.field_151421_c[p_148837_1_.readByte() % C02PacketUseEntity.Action.field_151421_c.length]; + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeInt(this.field_149567_a); + p_148840_1_.writeByte(this.field_149566_b.field_151418_d); + } + + public void processPacket(INetHandlerPlayServer p_149563_1_) + { + p_149563_1_.processUseEntity(this); + } + + public Entity func_149564_a(World p_149564_1_) + { + return p_149564_1_.getEntityByID(this.field_149567_a); + } + + public C02PacketUseEntity.Action func_149565_c() + { + return this.field_149566_b; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayServer)p_148833_1_); + } + + public static enum Action + { + INTERACT(0), + ATTACK(1); + private static final C02PacketUseEntity.Action[] field_151421_c = new C02PacketUseEntity.Action[values().length]; + private final int field_151418_d; + + private static final String __OBFID = "CL_00001358"; + + private Action(int p_i45250_3_) + { + this.field_151418_d = p_i45250_3_; + } + + static + { + C02PacketUseEntity.Action[] var0 = values(); + int var1 = var0.length; + + for (int var2 = 0; var2 < var1; ++var2) + { + C02PacketUseEntity.Action var3 = var0[var2]; + field_151421_c[var3.field_151418_d] = var3; + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/client/C03PacketPlayer.java b/src/main/java/net/minecraft/network/play/client/C03PacketPlayer.java new file mode 100644 index 0000000..f767f0e --- /dev/null +++ b/src/main/java/net/minecraft/network/play/client/C03PacketPlayer.java @@ -0,0 +1,235 @@ +package net.minecraft.network.play.client; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayServer; + +public class C03PacketPlayer extends Packet +{ + protected double field_149479_a; + protected double field_149477_b; + protected double field_149478_c; + protected double field_149475_d; + protected float field_149476_e; + protected float field_149473_f; + protected boolean field_149474_g; + protected boolean field_149480_h; + protected boolean field_149481_i; + private static final String __OBFID = "CL_00001360"; + + public C03PacketPlayer() {} + + @SideOnly(Side.CLIENT) + public C03PacketPlayer(boolean p_i45256_1_) + { + this.field_149474_g = p_i45256_1_; + } + + public void processPacket(INetHandlerPlayServer p_149468_1_) + { + p_149468_1_.processPlayer(this); + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149474_g = p_148837_1_.readUnsignedByte() != 0; + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeByte(this.field_149474_g ? 1 : 0); + } + + public double func_149464_c() + { + return this.field_149479_a; + } + + public double func_149467_d() + { + return this.field_149477_b; + } + + public double func_149472_e() + { + return this.field_149478_c; + } + + public double func_149471_f() + { + return this.field_149475_d; + } + + public float func_149462_g() + { + return this.field_149476_e; + } + + public float func_149470_h() + { + return this.field_149473_f; + } + + public boolean func_149465_i() + { + return this.field_149474_g; + } + + public boolean func_149466_j() + { + return this.field_149480_h; + } + + public boolean func_149463_k() + { + return this.field_149481_i; + } + + public void func_149469_a(boolean p_149469_1_) + { + this.field_149480_h = p_149469_1_; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayServer)p_148833_1_); + } + + public static class C04PacketPlayerPosition extends C03PacketPlayer + { + private static final String __OBFID = "CL_00001361"; + + public C04PacketPlayerPosition() + { + this.field_149480_h = true; + } + + @SideOnly(Side.CLIENT) + public C04PacketPlayerPosition(double p_i45253_1_, double p_i45253_3_, double p_i45253_5_, double p_i45253_7_, boolean p_i45253_9_) + { + this.field_149479_a = p_i45253_1_; + this.field_149477_b = p_i45253_3_; + this.field_149475_d = p_i45253_5_; + this.field_149478_c = p_i45253_7_; + this.field_149474_g = p_i45253_9_; + this.field_149480_h = true; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149479_a = p_148837_1_.readDouble(); + this.field_149477_b = p_148837_1_.readDouble(); + this.field_149475_d = p_148837_1_.readDouble(); + this.field_149478_c = p_148837_1_.readDouble(); + super.readPacketData(p_148837_1_); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeDouble(this.field_149479_a); + p_148840_1_.writeDouble(this.field_149477_b); + p_148840_1_.writeDouble(this.field_149475_d); + p_148840_1_.writeDouble(this.field_149478_c); + super.writePacketData(p_148840_1_); + } + + public void processPacket(INetHandler p_148833_1_) + { + super.processPacket((INetHandlerPlayServer)p_148833_1_); + } + } + + public static class C05PacketPlayerLook extends C03PacketPlayer + { + private static final String __OBFID = "CL_00001363"; + + public C05PacketPlayerLook() + { + this.field_149481_i = true; + } + + @SideOnly(Side.CLIENT) + public C05PacketPlayerLook(float p_i45255_1_, float p_i45255_2_, boolean p_i45255_3_) + { + this.field_149476_e = p_i45255_1_; + this.field_149473_f = p_i45255_2_; + this.field_149474_g = p_i45255_3_; + this.field_149481_i = true; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149476_e = p_148837_1_.readFloat(); + this.field_149473_f = p_148837_1_.readFloat(); + super.readPacketData(p_148837_1_); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeFloat(this.field_149476_e); + p_148840_1_.writeFloat(this.field_149473_f); + super.writePacketData(p_148840_1_); + } + + public void processPacket(INetHandler p_148833_1_) + { + super.processPacket((INetHandlerPlayServer)p_148833_1_); + } + } + + public static class C06PacketPlayerPosLook extends C03PacketPlayer + { + private static final String __OBFID = "CL_00001362"; + + public C06PacketPlayerPosLook() + { + this.field_149480_h = true; + this.field_149481_i = true; + } + + @SideOnly(Side.CLIENT) + public C06PacketPlayerPosLook(double p_i45254_1_, double p_i45254_3_, double p_i45254_5_, double p_i45254_7_, float p_i45254_9_, float p_i45254_10_, boolean p_i45254_11_) + { + this.field_149479_a = p_i45254_1_; + this.field_149477_b = p_i45254_3_; + this.field_149475_d = p_i45254_5_; + this.field_149478_c = p_i45254_7_; + this.field_149476_e = p_i45254_9_; + this.field_149473_f = p_i45254_10_; + this.field_149474_g = p_i45254_11_; + this.field_149481_i = true; + this.field_149480_h = true; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149479_a = p_148837_1_.readDouble(); + this.field_149477_b = p_148837_1_.readDouble(); + this.field_149475_d = p_148837_1_.readDouble(); + this.field_149478_c = p_148837_1_.readDouble(); + this.field_149476_e = p_148837_1_.readFloat(); + this.field_149473_f = p_148837_1_.readFloat(); + super.readPacketData(p_148837_1_); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeDouble(this.field_149479_a); + p_148840_1_.writeDouble(this.field_149477_b); + p_148840_1_.writeDouble(this.field_149475_d); + p_148840_1_.writeDouble(this.field_149478_c); + p_148840_1_.writeFloat(this.field_149476_e); + p_148840_1_.writeFloat(this.field_149473_f); + super.writePacketData(p_148840_1_); + } + + public void processPacket(INetHandler p_148833_1_) + { + super.processPacket((INetHandlerPlayServer)p_148833_1_); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/client/C07PacketPlayerDigging.java b/src/main/java/net/minecraft/network/play/client/C07PacketPlayerDigging.java new file mode 100644 index 0000000..8cc643e --- /dev/null +++ b/src/main/java/net/minecraft/network/play/client/C07PacketPlayerDigging.java @@ -0,0 +1,84 @@ +package net.minecraft.network.play.client; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayServer; + +public class C07PacketPlayerDigging extends Packet +{ + private int field_149511_a; + private int field_149509_b; + private int field_149510_c; + private int field_149507_d; + private int field_149508_e; + private static final String __OBFID = "CL_00001365"; + + public C07PacketPlayerDigging() {} + + @SideOnly(Side.CLIENT) + public C07PacketPlayerDigging(int p_i45258_1_, int p_i45258_2_, int p_i45258_3_, int p_i45258_4_, int p_i45258_5_) + { + this.field_149508_e = p_i45258_1_; + this.field_149511_a = p_i45258_2_; + this.field_149509_b = p_i45258_3_; + this.field_149510_c = p_i45258_4_; + this.field_149507_d = p_i45258_5_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149508_e = p_148837_1_.readUnsignedByte(); + this.field_149511_a = p_148837_1_.readInt(); + this.field_149509_b = p_148837_1_.readUnsignedByte(); + this.field_149510_c = p_148837_1_.readInt(); + this.field_149507_d = p_148837_1_.readUnsignedByte(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeByte(this.field_149508_e); + p_148840_1_.writeInt(this.field_149511_a); + p_148840_1_.writeByte(this.field_149509_b); + p_148840_1_.writeInt(this.field_149510_c); + p_148840_1_.writeByte(this.field_149507_d); + } + + public void processPacket(INetHandlerPlayServer p_149504_1_) + { + p_149504_1_.processPlayerDigging(this); + } + + public int func_149505_c() + { + return this.field_149511_a; + } + + public int func_149503_d() + { + return this.field_149509_b; + } + + public int func_149502_e() + { + return this.field_149510_c; + } + + public int func_149501_f() + { + return this.field_149507_d; + } + + public int func_149506_g() + { + return this.field_149508_e; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayServer)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/client/C08PacketPlayerBlockPlacement.java b/src/main/java/net/minecraft/network/play/client/C08PacketPlayerBlockPlacement.java new file mode 100644 index 0000000..26bd91f --- /dev/null +++ b/src/main/java/net/minecraft/network/play/client/C08PacketPlayerBlockPlacement.java @@ -0,0 +1,112 @@ +package net.minecraft.network.play.client; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.item.ItemStack; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayServer; + +public class C08PacketPlayerBlockPlacement extends Packet +{ + private int field_149583_a; + private int field_149581_b; + private int field_149582_c; + private int field_149579_d; + private ItemStack field_149580_e; + private float field_149577_f; + private float field_149578_g; + private float field_149584_h; + private static final String __OBFID = "CL_00001371"; + + public C08PacketPlayerBlockPlacement() {} + + @SideOnly(Side.CLIENT) + public C08PacketPlayerBlockPlacement(int p_i45265_1_, int p_i45265_2_, int p_i45265_3_, int p_i45265_4_, ItemStack p_i45265_5_, float p_i45265_6_, float p_i45265_7_, float p_i45265_8_) + { + this.field_149583_a = p_i45265_1_; + this.field_149581_b = p_i45265_2_; + this.field_149582_c = p_i45265_3_; + this.field_149579_d = p_i45265_4_; + this.field_149580_e = p_i45265_5_ != null ? p_i45265_5_.copy() : null; + this.field_149577_f = p_i45265_6_; + this.field_149578_g = p_i45265_7_; + this.field_149584_h = p_i45265_8_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149583_a = p_148837_1_.readInt(); + this.field_149581_b = p_148837_1_.readUnsignedByte(); + this.field_149582_c = p_148837_1_.readInt(); + this.field_149579_d = p_148837_1_.readUnsignedByte(); + this.field_149580_e = p_148837_1_.readItemStackFromBuffer(); + this.field_149577_f = (float)p_148837_1_.readUnsignedByte() / 16.0F; + this.field_149578_g = (float)p_148837_1_.readUnsignedByte() / 16.0F; + this.field_149584_h = (float)p_148837_1_.readUnsignedByte() / 16.0F; + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeInt(this.field_149583_a); + p_148840_1_.writeByte(this.field_149581_b); + p_148840_1_.writeInt(this.field_149582_c); + p_148840_1_.writeByte(this.field_149579_d); + p_148840_1_.writeItemStackToBuffer(this.field_149580_e); + p_148840_1_.writeByte((int)(this.field_149577_f * 16.0F)); + p_148840_1_.writeByte((int)(this.field_149578_g * 16.0F)); + p_148840_1_.writeByte((int)(this.field_149584_h * 16.0F)); + } + + public void processPacket(INetHandlerPlayServer p_149572_1_) + { + p_149572_1_.processPlayerBlockPlacement(this); + } + + public int func_149576_c() + { + return this.field_149583_a; + } + + public int func_149571_d() + { + return this.field_149581_b; + } + + public int func_149570_e() + { + return this.field_149582_c; + } + + public int func_149568_f() + { + return this.field_149579_d; + } + + public ItemStack func_149574_g() + { + return this.field_149580_e; + } + + public float func_149573_h() + { + return this.field_149577_f; + } + + public float func_149569_i() + { + return this.field_149578_g; + } + + public float func_149575_j() + { + return this.field_149584_h; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayServer)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/client/C09PacketHeldItemChange.java b/src/main/java/net/minecraft/network/play/client/C09PacketHeldItemChange.java new file mode 100644 index 0000000..ea09e7c --- /dev/null +++ b/src/main/java/net/minecraft/network/play/client/C09PacketHeldItemChange.java @@ -0,0 +1,48 @@ +package net.minecraft.network.play.client; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayServer; + +public class C09PacketHeldItemChange extends Packet +{ + private int field_149615_a; + private static final String __OBFID = "CL_00001368"; + + public C09PacketHeldItemChange() {} + + @SideOnly(Side.CLIENT) + public C09PacketHeldItemChange(int p_i45262_1_) + { + this.field_149615_a = p_i45262_1_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149615_a = p_148837_1_.readShort(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeShort(this.field_149615_a); + } + + public void processPacket(INetHandlerPlayServer p_149613_1_) + { + p_149613_1_.processHeldItemChange(this); + } + + public int func_149614_c() + { + return this.field_149615_a; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayServer)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/client/C0APacketAnimation.java b/src/main/java/net/minecraft/network/play/client/C0APacketAnimation.java new file mode 100644 index 0000000..f48b5d1 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/client/C0APacketAnimation.java @@ -0,0 +1,58 @@ +package net.minecraft.network.play.client; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.entity.Entity; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayServer; + +public class C0APacketAnimation extends Packet +{ + private int field_149424_a; + private int field_149423_b; + private static final String __OBFID = "CL_00001345"; + + public C0APacketAnimation() {} + + @SideOnly(Side.CLIENT) + public C0APacketAnimation(Entity p_i45238_1_, int p_i45238_2_) + { + this.field_149424_a = p_i45238_1_.getEntityId(); + this.field_149423_b = p_i45238_2_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149424_a = p_148837_1_.readInt(); + this.field_149423_b = p_148837_1_.readByte(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeInt(this.field_149424_a); + p_148840_1_.writeByte(this.field_149423_b); + } + + public void processPacket(INetHandlerPlayServer p_149422_1_) + { + p_149422_1_.processAnimation(this); + } + + public String serialize() + { + return String.format("id=%d, type=%d", new Object[] {Integer.valueOf(this.field_149424_a), Integer.valueOf(this.field_149423_b)}); + } + + public int func_149421_d() + { + return this.field_149423_b; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayServer)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/client/C0BPacketEntityAction.java b/src/main/java/net/minecraft/network/play/client/C0BPacketEntityAction.java new file mode 100644 index 0000000..d631aca --- /dev/null +++ b/src/main/java/net/minecraft/network/play/client/C0BPacketEntityAction.java @@ -0,0 +1,68 @@ +package net.minecraft.network.play.client; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.entity.Entity; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayServer; + +public class C0BPacketEntityAction extends Packet +{ + private int field_149517_a; + private int field_149515_b; + private int field_149516_c; + private static final String __OBFID = "CL_00001366"; + + public C0BPacketEntityAction() {} + + @SideOnly(Side.CLIENT) + public C0BPacketEntityAction(Entity p_i45259_1_, int p_i45259_2_) + { + this(p_i45259_1_, p_i45259_2_, 0); + } + + @SideOnly(Side.CLIENT) + public C0BPacketEntityAction(Entity p_i45260_1_, int p_i45260_2_, int p_i45260_3_) + { + this.field_149517_a = p_i45260_1_.getEntityId(); + this.field_149515_b = p_i45260_2_; + this.field_149516_c = p_i45260_3_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149517_a = p_148837_1_.readInt(); + this.field_149515_b = p_148837_1_.readByte(); + this.field_149516_c = p_148837_1_.readInt(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeInt(this.field_149517_a); + p_148840_1_.writeByte(this.field_149515_b); + p_148840_1_.writeInt(this.field_149516_c); + } + + public void processPacket(INetHandlerPlayServer p_149514_1_) + { + p_149514_1_.processEntityAction(this); + } + + public int func_149513_d() + { + return this.field_149515_b; + } + + public int func_149512_e() + { + return this.field_149516_c; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayServer)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/client/C0CPacketInput.java b/src/main/java/net/minecraft/network/play/client/C0CPacketInput.java new file mode 100644 index 0000000..dd78133 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/client/C0CPacketInput.java @@ -0,0 +1,75 @@ +package net.minecraft.network.play.client; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayServer; + +public class C0CPacketInput extends Packet +{ + private float field_149624_a; + private float field_149622_b; + private boolean field_149623_c; + private boolean field_149621_d; + private static final String __OBFID = "CL_00001367"; + + public C0CPacketInput() {} + + @SideOnly(Side.CLIENT) + public C0CPacketInput(float p_i45261_1_, float p_i45261_2_, boolean p_i45261_3_, boolean p_i45261_4_) + { + this.field_149624_a = p_i45261_1_; + this.field_149622_b = p_i45261_2_; + this.field_149623_c = p_i45261_3_; + this.field_149621_d = p_i45261_4_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149624_a = p_148837_1_.readFloat(); + this.field_149622_b = p_148837_1_.readFloat(); + this.field_149623_c = p_148837_1_.readBoolean(); + this.field_149621_d = p_148837_1_.readBoolean(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeFloat(this.field_149624_a); + p_148840_1_.writeFloat(this.field_149622_b); + p_148840_1_.writeBoolean(this.field_149623_c); + p_148840_1_.writeBoolean(this.field_149621_d); + } + + public void processPacket(INetHandlerPlayServer p_149619_1_) + { + p_149619_1_.processInput(this); + } + + public float func_149620_c() + { + return this.field_149624_a; + } + + public float func_149616_d() + { + return this.field_149622_b; + } + + public boolean func_149618_e() + { + return this.field_149623_c; + } + + public boolean func_149617_f() + { + return this.field_149621_d; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayServer)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/client/C0DPacketCloseWindow.java b/src/main/java/net/minecraft/network/play/client/C0DPacketCloseWindow.java new file mode 100644 index 0000000..4a3b64e --- /dev/null +++ b/src/main/java/net/minecraft/network/play/client/C0DPacketCloseWindow.java @@ -0,0 +1,43 @@ +package net.minecraft.network.play.client; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayServer; + +public class C0DPacketCloseWindow extends Packet +{ + private int field_149556_a; + private static final String __OBFID = "CL_00001354"; + + public C0DPacketCloseWindow() {} + + @SideOnly(Side.CLIENT) + public C0DPacketCloseWindow(int p_i45247_1_) + { + this.field_149556_a = p_i45247_1_; + } + + public void processPacket(INetHandlerPlayServer p_149555_1_) + { + p_149555_1_.processCloseWindow(this); + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149556_a = p_148837_1_.readByte(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeByte(this.field_149556_a); + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayServer)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/client/C0EPacketClickWindow.java b/src/main/java/net/minecraft/network/play/client/C0EPacketClickWindow.java new file mode 100644 index 0000000..78e6bcb --- /dev/null +++ b/src/main/java/net/minecraft/network/play/client/C0EPacketClickWindow.java @@ -0,0 +1,100 @@ +package net.minecraft.network.play.client; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayServer; + +public class C0EPacketClickWindow extends Packet +{ + private int field_149554_a; + private int field_149552_b; + private int field_149553_c; + private short field_149550_d; + private ItemStack field_149551_e; + private int field_149549_f; + private static final String __OBFID = "CL_00001353"; + + public C0EPacketClickWindow() {} + + @SideOnly(Side.CLIENT) + public C0EPacketClickWindow(int p_i45246_1_, int p_i45246_2_, int p_i45246_3_, int p_i45246_4_, ItemStack p_i45246_5_, short p_i45246_6_) + { + this.field_149554_a = p_i45246_1_; + this.field_149552_b = p_i45246_2_; + this.field_149553_c = p_i45246_3_; + this.field_149551_e = p_i45246_5_ != null ? p_i45246_5_.copy() : null; + this.field_149550_d = p_i45246_6_; + this.field_149549_f = p_i45246_4_; + } + + public void processPacket(INetHandlerPlayServer p_149545_1_) + { + p_149545_1_.processClickWindow(this); + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149554_a = p_148837_1_.readByte(); + this.field_149552_b = p_148837_1_.readShort(); + this.field_149553_c = p_148837_1_.readByte(); + this.field_149550_d = p_148837_1_.readShort(); + this.field_149549_f = p_148837_1_.readByte(); + this.field_149551_e = p_148837_1_.readItemStackFromBuffer(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeByte(this.field_149554_a); + p_148840_1_.writeShort(this.field_149552_b); + p_148840_1_.writeByte(this.field_149553_c); + p_148840_1_.writeShort(this.field_149550_d); + p_148840_1_.writeByte(this.field_149549_f); + p_148840_1_.writeItemStackToBuffer(this.field_149551_e); + } + + public String serialize() + { + return this.field_149551_e != null ? String.format("id=%d, slot=%d, button=%d, type=%d, itemid=%d, itemcount=%d, itemaux=%d", new Object[] {Integer.valueOf(this.field_149554_a), Integer.valueOf(this.field_149552_b), Integer.valueOf(this.field_149553_c), Integer.valueOf(this.field_149549_f), Integer.valueOf(Item.getIdFromItem(this.field_149551_e.getItem())), Integer.valueOf(this.field_149551_e.stackSize), Integer.valueOf(this.field_149551_e.getItemDamage())}): String.format("id=%d, slot=%d, button=%d, type=%d, itemid=-1", new Object[] {Integer.valueOf(this.field_149554_a), Integer.valueOf(this.field_149552_b), Integer.valueOf(this.field_149553_c), Integer.valueOf(this.field_149549_f)}); + } + + public int func_149548_c() + { + return this.field_149554_a; + } + + public int func_149544_d() + { + return this.field_149552_b; + } + + public int func_149543_e() + { + return this.field_149553_c; + } + + public short func_149547_f() + { + return this.field_149550_d; + } + + public ItemStack func_149546_g() + { + return this.field_149551_e; + } + + public int func_149542_h() + { + return this.field_149549_f; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayServer)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/client/C0FPacketConfirmTransaction.java b/src/main/java/net/minecraft/network/play/client/C0FPacketConfirmTransaction.java new file mode 100644 index 0000000..82bd5d9 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/client/C0FPacketConfirmTransaction.java @@ -0,0 +1,66 @@ +package net.minecraft.network.play.client; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayServer; + +public class C0FPacketConfirmTransaction extends Packet +{ + private int field_149536_a; + private short field_149534_b; + private boolean field_149535_c; + private static final String __OBFID = "CL_00001351"; + + public C0FPacketConfirmTransaction() {} + + @SideOnly(Side.CLIENT) + public C0FPacketConfirmTransaction(int p_i45244_1_, short p_i45244_2_, boolean p_i45244_3_) + { + this.field_149536_a = p_i45244_1_; + this.field_149534_b = p_i45244_2_; + this.field_149535_c = p_i45244_3_; + } + + public void processPacket(INetHandlerPlayServer p_149531_1_) + { + p_149531_1_.processConfirmTransaction(this); + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149536_a = p_148837_1_.readByte(); + this.field_149534_b = p_148837_1_.readShort(); + this.field_149535_c = p_148837_1_.readByte() != 0; + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeByte(this.field_149536_a); + p_148840_1_.writeShort(this.field_149534_b); + p_148840_1_.writeByte(this.field_149535_c ? 1 : 0); + } + + public String serialize() + { + return String.format("id=%d, uid=%d, accepted=%b", new Object[] {Integer.valueOf(this.field_149536_a), Short.valueOf(this.field_149534_b), Boolean.valueOf(this.field_149535_c)}); + } + + public int func_149532_c() + { + return this.field_149536_a; + } + + public short func_149533_d() + { + return this.field_149534_b; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayServer)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/client/C10PacketCreativeInventoryAction.java b/src/main/java/net/minecraft/network/play/client/C10PacketCreativeInventoryAction.java new file mode 100644 index 0000000..4c8dd7d --- /dev/null +++ b/src/main/java/net/minecraft/network/play/client/C10PacketCreativeInventoryAction.java @@ -0,0 +1,58 @@ +package net.minecraft.network.play.client; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.item.ItemStack; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayServer; + +public class C10PacketCreativeInventoryAction extends Packet +{ + private int field_149629_a; + private ItemStack field_149628_b; + private static final String __OBFID = "CL_00001369"; + + public C10PacketCreativeInventoryAction() {} + + @SideOnly(Side.CLIENT) + public C10PacketCreativeInventoryAction(int p_i45263_1_, ItemStack p_i45263_2_) + { + this.field_149629_a = p_i45263_1_; + this.field_149628_b = p_i45263_2_ != null ? p_i45263_2_.copy() : null; + } + + public void processPacket(INetHandlerPlayServer p_149626_1_) + { + p_149626_1_.processCreativeInventoryAction(this); + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149629_a = p_148837_1_.readShort(); + this.field_149628_b = p_148837_1_.readItemStackFromBuffer(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeShort(this.field_149629_a); + p_148840_1_.writeItemStackToBuffer(this.field_149628_b); + } + + public int func_149627_c() + { + return this.field_149629_a; + } + + public ItemStack func_149625_d() + { + return this.field_149628_b; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayServer)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/client/C11PacketEnchantItem.java b/src/main/java/net/minecraft/network/play/client/C11PacketEnchantItem.java new file mode 100644 index 0000000..bb4a9b3 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/client/C11PacketEnchantItem.java @@ -0,0 +1,62 @@ +package net.minecraft.network.play.client; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayServer; + +public class C11PacketEnchantItem extends Packet +{ + private int field_149541_a; + private int field_149540_b; + private static final String __OBFID = "CL_00001352"; + + public C11PacketEnchantItem() {} + + @SideOnly(Side.CLIENT) + public C11PacketEnchantItem(int p_i45245_1_, int p_i45245_2_) + { + this.field_149541_a = p_i45245_1_; + this.field_149540_b = p_i45245_2_; + } + + public void processPacket(INetHandlerPlayServer p_149538_1_) + { + p_149538_1_.processEnchantItem(this); + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149541_a = p_148837_1_.readByte(); + this.field_149540_b = p_148837_1_.readByte(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeByte(this.field_149541_a); + p_148840_1_.writeByte(this.field_149540_b); + } + + public String serialize() + { + return String.format("id=%d, button=%d", new Object[] {Integer.valueOf(this.field_149541_a), Integer.valueOf(this.field_149540_b)}); + } + + public int func_149539_c() + { + return this.field_149541_a; + } + + public int func_149537_d() + { + return this.field_149540_b; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayServer)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/client/C12PacketUpdateSign.java b/src/main/java/net/minecraft/network/play/client/C12PacketUpdateSign.java new file mode 100644 index 0000000..7c39327 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/client/C12PacketUpdateSign.java @@ -0,0 +1,84 @@ +package net.minecraft.network.play.client; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayServer; + +public class C12PacketUpdateSign extends Packet +{ + private int field_149593_a; + private int field_149591_b; + private int field_149592_c; + private String[] field_149590_d; + private static final String __OBFID = "CL_00001370"; + + public C12PacketUpdateSign() {} + + @SideOnly(Side.CLIENT) + public C12PacketUpdateSign(int p_i45264_1_, int p_i45264_2_, int p_i45264_3_, String[] p_i45264_4_) + { + this.field_149593_a = p_i45264_1_; + this.field_149591_b = p_i45264_2_; + this.field_149592_c = p_i45264_3_; + this.field_149590_d = new String[] {p_i45264_4_[0], p_i45264_4_[1], p_i45264_4_[2], p_i45264_4_[3]}; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149593_a = p_148837_1_.readInt(); + this.field_149591_b = p_148837_1_.readShort(); + this.field_149592_c = p_148837_1_.readInt(); + this.field_149590_d = new String[4]; + + for (int i = 0; i < 4; ++i) + { + this.field_149590_d[i] = p_148837_1_.readStringFromBuffer(15); + } + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeInt(this.field_149593_a); + p_148840_1_.writeShort(this.field_149591_b); + p_148840_1_.writeInt(this.field_149592_c); + + for (int i = 0; i < 4; ++i) + { + p_148840_1_.writeStringToBuffer(this.field_149590_d[i]); + } + } + + public void processPacket(INetHandlerPlayServer p_149587_1_) + { + p_149587_1_.processUpdateSign(this); + } + + public int func_149588_c() + { + return this.field_149593_a; + } + + public int func_149586_d() + { + return this.field_149591_b; + } + + public int func_149585_e() + { + return this.field_149592_c; + } + + public String[] func_149589_f() + { + return this.field_149590_d; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayServer)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/client/C13PacketPlayerAbilities.java b/src/main/java/net/minecraft/network/play/client/C13PacketPlayerAbilities.java new file mode 100644 index 0000000..bfe78b2 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/client/C13PacketPlayerAbilities.java @@ -0,0 +1,146 @@ +package net.minecraft.network.play.client; + +import java.io.IOException; +import net.minecraft.entity.player.PlayerCapabilities; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayServer; + +public class C13PacketPlayerAbilities extends Packet +{ + private boolean field_149500_a; + private boolean field_149498_b; + private boolean field_149499_c; + private boolean field_149496_d; + private float field_149497_e; + private float field_149495_f; + private static final String __OBFID = "CL_00001364"; + + public C13PacketPlayerAbilities() {} + + public C13PacketPlayerAbilities(PlayerCapabilities p_i45257_1_) + { + this.func_149490_a(p_i45257_1_.disableDamage); + this.func_149483_b(p_i45257_1_.isFlying); + this.func_149491_c(p_i45257_1_.allowFlying); + this.func_149493_d(p_i45257_1_.isCreativeMode); + this.func_149485_a(p_i45257_1_.getFlySpeed()); + this.func_149492_b(p_i45257_1_.getWalkSpeed()); + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + byte b0 = p_148837_1_.readByte(); + this.func_149490_a((b0 & 1) > 0); + this.func_149483_b((b0 & 2) > 0); + this.func_149491_c((b0 & 4) > 0); + this.func_149493_d((b0 & 8) > 0); + this.func_149485_a(p_148837_1_.readFloat()); + this.func_149492_b(p_148837_1_.readFloat()); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + byte b0 = 0; + + if (this.func_149494_c()) + { + b0 = (byte)(b0 | 1); + } + + if (this.func_149488_d()) + { + b0 = (byte)(b0 | 2); + } + + if (this.func_149486_e()) + { + b0 = (byte)(b0 | 4); + } + + if (this.func_149484_f()) + { + b0 = (byte)(b0 | 8); + } + + p_148840_1_.writeByte(b0); + p_148840_1_.writeFloat(this.field_149497_e); + p_148840_1_.writeFloat(this.field_149495_f); + } + + public void processPacket(INetHandlerPlayServer p_149487_1_) + { + p_149487_1_.processPlayerAbilities(this); + } + + public String serialize() + { + return String.format("invuln=%b, flying=%b, canfly=%b, instabuild=%b, flyspeed=%.4f, walkspped=%.4f", new Object[] {Boolean.valueOf(this.func_149494_c()), Boolean.valueOf(this.func_149488_d()), Boolean.valueOf(this.func_149486_e()), Boolean.valueOf(this.func_149484_f()), Float.valueOf(this.func_149482_g()), Float.valueOf(this.func_149489_h())}); + } + + public boolean func_149494_c() + { + return this.field_149500_a; + } + + public void func_149490_a(boolean p_149490_1_) + { + this.field_149500_a = p_149490_1_; + } + + public boolean func_149488_d() + { + return this.field_149498_b; + } + + public void func_149483_b(boolean p_149483_1_) + { + this.field_149498_b = p_149483_1_; + } + + public boolean func_149486_e() + { + return this.field_149499_c; + } + + public void func_149491_c(boolean p_149491_1_) + { + this.field_149499_c = p_149491_1_; + } + + public boolean func_149484_f() + { + return this.field_149496_d; + } + + public void func_149493_d(boolean p_149493_1_) + { + this.field_149496_d = p_149493_1_; + } + + public float func_149482_g() + { + return this.field_149497_e; + } + + public void func_149485_a(float p_149485_1_) + { + this.field_149497_e = p_149485_1_; + } + + public float func_149489_h() + { + return this.field_149495_f; + } + + public void func_149492_b(float p_149492_1_) + { + this.field_149495_f = p_149492_1_; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayServer)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/client/C14PacketTabComplete.java b/src/main/java/net/minecraft/network/play/client/C14PacketTabComplete.java new file mode 100644 index 0000000..74f12d6 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/client/C14PacketTabComplete.java @@ -0,0 +1,51 @@ +package net.minecraft.network.play.client; + +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayServer; +import org.apache.commons.lang3.StringUtils; + +public class C14PacketTabComplete extends Packet +{ + private String field_149420_a; + private static final String __OBFID = "CL_00001346"; + + public C14PacketTabComplete() {} + + public C14PacketTabComplete(String p_i45239_1_) + { + this.field_149420_a = p_i45239_1_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149420_a = p_148837_1_.readStringFromBuffer(32767); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeStringToBuffer(StringUtils.substring(this.field_149420_a, 0, 32767)); + } + + public void processPacket(INetHandlerPlayServer p_149418_1_) + { + p_149418_1_.processTabComplete(this); + } + + public String func_149419_c() + { + return this.field_149420_a; + } + + public String serialize() + { + return String.format("message=\'%s\'", new Object[] {this.field_149420_a}); + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayServer)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/client/C15PacketClientSettings.java b/src/main/java/net/minecraft/network/play/client/C15PacketClientSettings.java new file mode 100644 index 0000000..f8aa9f9 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/client/C15PacketClientSettings.java @@ -0,0 +1,100 @@ +package net.minecraft.network.play.client; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayServer; +import net.minecraft.world.EnumDifficulty; + +public class C15PacketClientSettings extends Packet +{ + private String field_149530_a; + private int field_149528_b; + private EntityPlayer.EnumChatVisibility field_149529_c; + private boolean field_149526_d; + private EnumDifficulty field_149527_e; + private boolean field_149525_f; + private static final String __OBFID = "CL_00001350"; + + public C15PacketClientSettings() {} + + @SideOnly(Side.CLIENT) + public C15PacketClientSettings(String p_i45243_1_, int p_i45243_2_, EntityPlayer.EnumChatVisibility p_i45243_3_, boolean p_i45243_4_, EnumDifficulty p_i45243_5_, boolean p_i45243_6_) + { + this.field_149530_a = p_i45243_1_; + this.field_149528_b = p_i45243_2_; + this.field_149529_c = p_i45243_3_; + this.field_149526_d = p_i45243_4_; + this.field_149527_e = p_i45243_5_; + this.field_149525_f = p_i45243_6_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149530_a = p_148837_1_.readStringFromBuffer(7); + this.field_149528_b = p_148837_1_.readByte(); + this.field_149529_c = EntityPlayer.EnumChatVisibility.getEnumChatVisibility(p_148837_1_.readByte()); + this.field_149526_d = p_148837_1_.readBoolean(); + this.field_149527_e = EnumDifficulty.getDifficultyEnum(p_148837_1_.readByte()); + this.field_149525_f = p_148837_1_.readBoolean(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeStringToBuffer(this.field_149530_a); + p_148840_1_.writeByte(this.field_149528_b); + p_148840_1_.writeByte(this.field_149529_c.getChatVisibility()); + p_148840_1_.writeBoolean(this.field_149526_d); + p_148840_1_.writeByte(this.field_149527_e.getDifficultyId()); + p_148840_1_.writeBoolean(this.field_149525_f); + } + + public void processPacket(INetHandlerPlayServer p_149522_1_) + { + p_149522_1_.processClientSettings(this); + } + + public String func_149524_c() + { + return this.field_149530_a; + } + + public int func_149521_d() + { + return this.field_149528_b; + } + + public EntityPlayer.EnumChatVisibility func_149523_e() + { + return this.field_149529_c; + } + + public boolean func_149520_f() + { + return this.field_149526_d; + } + + public EnumDifficulty func_149518_g() + { + return this.field_149527_e; + } + + public boolean func_149519_h() + { + return this.field_149525_f; + } + + public String serialize() + { + return String.format("lang=\'%s\', view=%d, chat=%s, col=%b, difficulty=%s, cape=%b", new Object[] {this.field_149530_a, Integer.valueOf(this.field_149528_b), this.field_149529_c, Boolean.valueOf(this.field_149526_d), this.field_149527_e, Boolean.valueOf(this.field_149525_f)}); + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayServer)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/client/C16PacketClientStatus.java b/src/main/java/net/minecraft/network/play/client/C16PacketClientStatus.java new file mode 100644 index 0000000..2191d2d --- /dev/null +++ b/src/main/java/net/minecraft/network/play/client/C16PacketClientStatus.java @@ -0,0 +1,73 @@ +package net.minecraft.network.play.client; + +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayServer; + +public class C16PacketClientStatus extends Packet +{ + private C16PacketClientStatus.EnumState field_149437_a; + private static final String __OBFID = "CL_00001348"; + + public C16PacketClientStatus() {} + + public C16PacketClientStatus(C16PacketClientStatus.EnumState p_i45242_1_) + { + this.field_149437_a = p_i45242_1_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149437_a = C16PacketClientStatus.EnumState.field_151404_e[p_148837_1_.readByte() % C16PacketClientStatus.EnumState.field_151404_e.length]; + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeByte(this.field_149437_a.field_151403_d); + } + + public void processPacket(INetHandlerPlayServer p_149436_1_) + { + p_149436_1_.processClientStatus(this); + } + + public C16PacketClientStatus.EnumState func_149435_c() + { + return this.field_149437_a; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayServer)p_148833_1_); + } + + public static enum EnumState + { + PERFORM_RESPAWN(0), + REQUEST_STATS(1), + OPEN_INVENTORY_ACHIEVEMENT(2); + private final int field_151403_d; + private static final C16PacketClientStatus.EnumState[] field_151404_e = new C16PacketClientStatus.EnumState[values().length]; + + private static final String __OBFID = "CL_00001349"; + + private EnumState(int p_i45241_3_) + { + this.field_151403_d = p_i45241_3_; + } + + static + { + C16PacketClientStatus.EnumState[] var0 = values(); + int var1 = var0.length; + + for (int var2 = 0; var2 < var1; ++var2) + { + C16PacketClientStatus.EnumState var3 = var0[var2]; + field_151404_e[var3.field_151403_d] = var3; + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/client/C17PacketCustomPayload.java b/src/main/java/net/minecraft/network/play/client/C17PacketCustomPayload.java new file mode 100644 index 0000000..41418dd --- /dev/null +++ b/src/main/java/net/minecraft/network/play/client/C17PacketCustomPayload.java @@ -0,0 +1,86 @@ +package net.minecraft.network.play.client; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayServer; + +public class C17PacketCustomPayload extends Packet +{ + private String field_149562_a; + private int field_149560_b; + private byte[] field_149561_c; + private static final String __OBFID = "CL_00001356"; + + public C17PacketCustomPayload() {} + + @SideOnly(Side.CLIENT) + public C17PacketCustomPayload(String p_i45248_1_, ByteBuf p_i45248_2_) + { + this(p_i45248_1_, p_i45248_2_.array()); + } + + @SideOnly(Side.CLIENT) + public C17PacketCustomPayload(String p_i45249_1_, byte[] p_i45249_2_) + { + this.field_149562_a = p_i45249_1_; + this.field_149561_c = p_i45249_2_; + + if (p_i45249_2_ != null) + { + this.field_149560_b = p_i45249_2_.length; + + if (this.field_149560_b >= 32767) + { + throw new IllegalArgumentException("Payload may not be larger than 32k"); + } + } + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149562_a = p_148837_1_.readStringFromBuffer(20); + this.field_149560_b = p_148837_1_.readShort(); + + if (this.field_149560_b > 0 && this.field_149560_b < 32767) + { + this.field_149561_c = new byte[this.field_149560_b]; + p_148837_1_.readBytes(this.field_149561_c); + } + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeStringToBuffer(this.field_149562_a); + p_148840_1_.writeShort((short)this.field_149560_b); + + if (this.field_149561_c != null) + { + p_148840_1_.writeBytes(this.field_149561_c); + } + } + + public void processPacket(INetHandlerPlayServer p_149557_1_) + { + p_149557_1_.processVanilla250Packet(this); + } + + public String func_149559_c() + { + return this.field_149562_a; + } + + public byte[] func_149558_e() + { + return this.field_149561_c; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayServer)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S00PacketKeepAlive.java b/src/main/java/net/minecraft/network/play/server/S00PacketKeepAlive.java new file mode 100644 index 0000000..cdb39b0 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S00PacketKeepAlive.java @@ -0,0 +1,53 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; + +public class S00PacketKeepAlive extends Packet +{ + private int field_149136_a; + private static final String __OBFID = "CL_00001303"; + + public S00PacketKeepAlive() {} + + public S00PacketKeepAlive(int p_i45195_1_) + { + this.field_149136_a = p_i45195_1_; + } + + public void processPacket(INetHandlerPlayClient p_149135_1_) + { + p_149135_1_.handleKeepAlive(this); + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149136_a = p_148837_1_.readInt(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeInt(this.field_149136_a); + } + + public boolean hasPriority() + { + return true; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } + + @SideOnly(Side.CLIENT) + public int func_149134_c() + { + return this.field_149136_a; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S01PacketJoinGame.java b/src/main/java/net/minecraft/network/play/server/S01PacketJoinGame.java new file mode 100644 index 0000000..deffe21 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S01PacketJoinGame.java @@ -0,0 +1,129 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; +import net.minecraft.world.EnumDifficulty; +import net.minecraft.world.WorldSettings; +import net.minecraft.world.WorldType; + +public class S01PacketJoinGame extends Packet +{ + private int field_149206_a; + private boolean field_149204_b; + private WorldSettings.GameType field_149205_c; + private int field_149202_d; + private EnumDifficulty field_149203_e; + private int field_149200_f; + private WorldType field_149201_g; + private static final String __OBFID = "CL_00001310"; + + public S01PacketJoinGame() {} + + public S01PacketJoinGame(int p_i45201_1_, WorldSettings.GameType p_i45201_2_, boolean p_i45201_3_, int p_i45201_4_, EnumDifficulty p_i45201_5_, int p_i45201_6_, WorldType p_i45201_7_) + { + this.field_149206_a = p_i45201_1_; + this.field_149202_d = p_i45201_4_; + this.field_149203_e = p_i45201_5_; + this.field_149205_c = p_i45201_2_; + this.field_149200_f = p_i45201_6_; + this.field_149204_b = p_i45201_3_; + this.field_149201_g = p_i45201_7_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149206_a = p_148837_1_.readInt(); + short short1 = p_148837_1_.readUnsignedByte(); + this.field_149204_b = (short1 & 8) == 8; + int i = short1 & -9; + this.field_149205_c = WorldSettings.GameType.getByID(i); + this.field_149202_d = p_148837_1_.readByte(); + this.field_149203_e = EnumDifficulty.getDifficultyEnum(p_148837_1_.readUnsignedByte()); + this.field_149200_f = p_148837_1_.readUnsignedByte(); + this.field_149201_g = WorldType.parseWorldType(p_148837_1_.readStringFromBuffer(16)); + + if (this.field_149201_g == null) + { + this.field_149201_g = WorldType.DEFAULT; + } + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeInt(this.field_149206_a); + int i = this.field_149205_c.getID(); + + if (this.field_149204_b) + { + i |= 8; + } + + p_148840_1_.writeByte(i); + p_148840_1_.writeByte(this.field_149202_d); + p_148840_1_.writeByte(this.field_149203_e.getDifficultyId()); + p_148840_1_.writeByte(this.field_149200_f); + p_148840_1_.writeStringToBuffer(this.field_149201_g.getWorldTypeName()); + } + + public void processPacket(INetHandlerPlayClient p_149199_1_) + { + p_149199_1_.handleJoinGame(this); + } + + public String serialize() + { + return String.format("eid=%d, gameType=%d, hardcore=%b, dimension=%d, difficulty=%s, maxplayers=%d", new Object[] {Integer.valueOf(this.field_149206_a), Integer.valueOf(this.field_149205_c.getID()), Boolean.valueOf(this.field_149204_b), Integer.valueOf(this.field_149202_d), this.field_149203_e, Integer.valueOf(this.field_149200_f)}); + } + + @SideOnly(Side.CLIENT) + public int func_149197_c() + { + return this.field_149206_a; + } + + @SideOnly(Side.CLIENT) + public boolean func_149195_d() + { + return this.field_149204_b; + } + + @SideOnly(Side.CLIENT) + public WorldSettings.GameType func_149198_e() + { + return this.field_149205_c; + } + + @SideOnly(Side.CLIENT) + public int func_149194_f() + { + return this.field_149202_d; + } + + @SideOnly(Side.CLIENT) + public EnumDifficulty func_149192_g() + { + return this.field_149203_e; + } + + @SideOnly(Side.CLIENT) + public int func_149193_h() + { + return this.field_149200_f; + } + + @SideOnly(Side.CLIENT) + public WorldType func_149196_i() + { + return this.field_149201_g; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S02PacketChat.java b/src/main/java/net/minecraft/network/play/server/S02PacketChat.java new file mode 100644 index 0000000..5106ec1 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S02PacketChat.java @@ -0,0 +1,70 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; +import net.minecraft.util.IChatComponent; + +public class S02PacketChat extends Packet +{ + private IChatComponent field_148919_a; + private boolean field_148918_b; + private static final String __OBFID = "CL_00001289"; + + public S02PacketChat() + { + this.field_148918_b = true; + } + + public S02PacketChat(IChatComponent p_i45179_1_) + { + this(p_i45179_1_, true); + } + + public S02PacketChat(IChatComponent p_i45180_1_, boolean p_i45180_2_) + { + this.field_148918_b = true; + this.field_148919_a = p_i45180_1_; + this.field_148918_b = p_i45180_2_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_148919_a = IChatComponent.Serializer.func_150699_a(p_148837_1_.readStringFromBuffer(32767)); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeStringToBuffer(IChatComponent.Serializer.func_150696_a(this.field_148919_a)); + } + + public void processPacket(INetHandlerPlayClient p_148917_1_) + { + p_148917_1_.handleChat(this); + } + + public String serialize() + { + return String.format("message=\'%s\'", new Object[] {this.field_148919_a}); + } + + @SideOnly(Side.CLIENT) + public IChatComponent func_148915_c() + { + return this.field_148919_a; + } + + public boolean func_148916_d() + { + return this.field_148918_b; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S03PacketTimeUpdate.java b/src/main/java/net/minecraft/network/play/server/S03PacketTimeUpdate.java new file mode 100644 index 0000000..9b51211 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S03PacketTimeUpdate.java @@ -0,0 +1,73 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; + +public class S03PacketTimeUpdate extends Packet +{ + private long field_149369_a; + private long field_149368_b; + private static final String __OBFID = "CL_00001337"; + + public S03PacketTimeUpdate() {} + + public S03PacketTimeUpdate(long p_i45230_1_, long p_i45230_3_, boolean p_i45230_5_) + { + this.field_149369_a = p_i45230_1_; + this.field_149368_b = p_i45230_3_; + + if (!p_i45230_5_) + { + this.field_149368_b = -this.field_149368_b; + + if (this.field_149368_b == 0L) + { + this.field_149368_b = -1L; + } + } + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149369_a = p_148837_1_.readLong(); + this.field_149368_b = p_148837_1_.readLong(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeLong(this.field_149369_a); + p_148840_1_.writeLong(this.field_149368_b); + } + + public void processPacket(INetHandlerPlayClient p_149367_1_) + { + p_149367_1_.handleTimeUpdate(this); + } + + public String serialize() + { + return String.format("time=%d,dtime=%d", new Object[] {Long.valueOf(this.field_149369_a), Long.valueOf(this.field_149368_b)}); + } + + @SideOnly(Side.CLIENT) + public long func_149366_c() + { + return this.field_149369_a; + } + + @SideOnly(Side.CLIENT) + public long func_149365_d() + { + return this.field_149368_b; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S04PacketEntityEquipment.java b/src/main/java/net/minecraft/network/play/server/S04PacketEntityEquipment.java new file mode 100644 index 0000000..62b214e --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S04PacketEntityEquipment.java @@ -0,0 +1,74 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.item.ItemStack; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; + +public class S04PacketEntityEquipment extends Packet +{ + private int field_149394_a; + private int field_149392_b; + private ItemStack field_149393_c; + private static final String __OBFID = "CL_00001330"; + + public S04PacketEntityEquipment() {} + + public S04PacketEntityEquipment(int p_i45221_1_, int p_i45221_2_, ItemStack p_i45221_3_) + { + this.field_149394_a = p_i45221_1_; + this.field_149392_b = p_i45221_2_; + this.field_149393_c = p_i45221_3_ == null ? null : p_i45221_3_.copy(); + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149394_a = p_148837_1_.readInt(); + this.field_149392_b = p_148837_1_.readShort(); + this.field_149393_c = p_148837_1_.readItemStackFromBuffer(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeInt(this.field_149394_a); + p_148840_1_.writeShort(this.field_149392_b); + p_148840_1_.writeItemStackToBuffer(this.field_149393_c); + } + + public void processPacket(INetHandlerPlayClient p_149391_1_) + { + p_149391_1_.handleEntityEquipment(this); + } + + @SideOnly(Side.CLIENT) + public ItemStack func_149390_c() + { + return this.field_149393_c; + } + + public String serialize() + { + return String.format("entity=%d, slot=%d, item=%s", new Object[] {Integer.valueOf(this.field_149394_a), Integer.valueOf(this.field_149392_b), this.field_149393_c}); + } + + @SideOnly(Side.CLIENT) + public int func_149389_d() + { + return this.field_149394_a; + } + + @SideOnly(Side.CLIENT) + public int func_149388_e() + { + return this.field_149392_b; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S05PacketSpawnPosition.java b/src/main/java/net/minecraft/network/play/server/S05PacketSpawnPosition.java new file mode 100644 index 0000000..5d884fa --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S05PacketSpawnPosition.java @@ -0,0 +1,78 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; + +public class S05PacketSpawnPosition extends Packet +{ + private int field_149364_a; + private int field_149362_b; + private int field_149363_c; + private static final String __OBFID = "CL_00001336"; + + public S05PacketSpawnPosition() {} + + public S05PacketSpawnPosition(int p_i45229_1_, int p_i45229_2_, int p_i45229_3_) + { + this.field_149364_a = p_i45229_1_; + this.field_149362_b = p_i45229_2_; + this.field_149363_c = p_i45229_3_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149364_a = p_148837_1_.readInt(); + this.field_149362_b = p_148837_1_.readInt(); + this.field_149363_c = p_148837_1_.readInt(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeInt(this.field_149364_a); + p_148840_1_.writeInt(this.field_149362_b); + p_148840_1_.writeInt(this.field_149363_c); + } + + public void processPacket(INetHandlerPlayClient p_149361_1_) + { + p_149361_1_.handleSpawnPosition(this); + } + + public boolean hasPriority() + { + return false; + } + + public String serialize() + { + return String.format("x=%d, y=%d, z=%d", new Object[] {Integer.valueOf(this.field_149364_a), Integer.valueOf(this.field_149362_b), Integer.valueOf(this.field_149363_c)}); + } + + @SideOnly(Side.CLIENT) + public int func_149360_c() + { + return this.field_149364_a; + } + + @SideOnly(Side.CLIENT) + public int func_149359_d() + { + return this.field_149362_b; + } + + @SideOnly(Side.CLIENT) + public int func_149358_e() + { + return this.field_149363_c; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S06PacketUpdateHealth.java b/src/main/java/net/minecraft/network/play/server/S06PacketUpdateHealth.java new file mode 100644 index 0000000..dc7cccc --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S06PacketUpdateHealth.java @@ -0,0 +1,68 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; + +public class S06PacketUpdateHealth extends Packet +{ + private float field_149336_a; + private int field_149334_b; + private float field_149335_c; + private static final String __OBFID = "CL_00001332"; + + public S06PacketUpdateHealth() {} + + public S06PacketUpdateHealth(float p_i45223_1_, int p_i45223_2_, float p_i45223_3_) + { + this.field_149336_a = p_i45223_1_; + this.field_149334_b = p_i45223_2_; + this.field_149335_c = p_i45223_3_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149336_a = p_148837_1_.readFloat(); + this.field_149334_b = p_148837_1_.readShort(); + this.field_149335_c = p_148837_1_.readFloat(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeFloat(this.field_149336_a); + p_148840_1_.writeShort(this.field_149334_b); + p_148840_1_.writeFloat(this.field_149335_c); + } + + public void processPacket(INetHandlerPlayClient p_149333_1_) + { + p_149333_1_.handleUpdateHealth(this); + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } + + @SideOnly(Side.CLIENT) + public float func_149332_c() + { + return this.field_149336_a; + } + + @SideOnly(Side.CLIENT) + public int func_149330_d() + { + return this.field_149334_b; + } + + @SideOnly(Side.CLIENT) + public float func_149331_e() + { + return this.field_149335_c; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S07PacketRespawn.java b/src/main/java/net/minecraft/network/play/server/S07PacketRespawn.java new file mode 100644 index 0000000..0fa416b --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S07PacketRespawn.java @@ -0,0 +1,86 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; +import net.minecraft.world.EnumDifficulty; +import net.minecraft.world.WorldSettings; +import net.minecraft.world.WorldType; + +public class S07PacketRespawn extends Packet +{ + private int field_149088_a; + private EnumDifficulty field_149086_b; + private WorldSettings.GameType field_149087_c; + private WorldType field_149085_d; + private static final String __OBFID = "CL_00001322"; + + public S07PacketRespawn() {} + + public S07PacketRespawn(int p_i45213_1_, EnumDifficulty p_i45213_2_, WorldType p_i45213_3_, WorldSettings.GameType p_i45213_4_) + { + this.field_149088_a = p_i45213_1_; + this.field_149086_b = p_i45213_2_; + this.field_149087_c = p_i45213_4_; + this.field_149085_d = p_i45213_3_; + } + + public void processPacket(INetHandlerPlayClient p_149084_1_) + { + p_149084_1_.handleRespawn(this); + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149088_a = p_148837_1_.readInt(); + this.field_149086_b = EnumDifficulty.getDifficultyEnum(p_148837_1_.readUnsignedByte()); + this.field_149087_c = WorldSettings.GameType.getByID(p_148837_1_.readUnsignedByte()); + this.field_149085_d = WorldType.parseWorldType(p_148837_1_.readStringFromBuffer(16)); + + if (this.field_149085_d == null) + { + this.field_149085_d = WorldType.DEFAULT; + } + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeInt(this.field_149088_a); + p_148840_1_.writeByte(this.field_149086_b.getDifficultyId()); + p_148840_1_.writeByte(this.field_149087_c.getID()); + p_148840_1_.writeStringToBuffer(this.field_149085_d.getWorldTypeName()); + } + + @SideOnly(Side.CLIENT) + public int func_149082_c() + { + return this.field_149088_a; + } + + @SideOnly(Side.CLIENT) + public EnumDifficulty func_149081_d() + { + return this.field_149086_b; + } + + @SideOnly(Side.CLIENT) + public WorldSettings.GameType func_149083_e() + { + return this.field_149087_c; + } + + @SideOnly(Side.CLIENT) + public WorldType func_149080_f() + { + return this.field_149085_d; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S08PacketPlayerPosLook.java b/src/main/java/net/minecraft/network/play/server/S08PacketPlayerPosLook.java new file mode 100644 index 0000000..d197996 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S08PacketPlayerPosLook.java @@ -0,0 +1,98 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; + +public class S08PacketPlayerPosLook extends Packet +{ + private double field_148940_a; + private double field_148938_b; + private double field_148939_c; + private float field_148936_d; + private float field_148937_e; + private boolean field_148935_f; + private static final String __OBFID = "CL_00001273"; + + public S08PacketPlayerPosLook() {} + + public S08PacketPlayerPosLook(double p_i45164_1_, double p_i45164_3_, double p_i45164_5_, float p_i45164_7_, float p_i45164_8_, boolean p_i45164_9_) + { + this.field_148940_a = p_i45164_1_; + this.field_148938_b = p_i45164_3_; + this.field_148939_c = p_i45164_5_; + this.field_148936_d = p_i45164_7_; + this.field_148937_e = p_i45164_8_; + this.field_148935_f = p_i45164_9_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_148940_a = p_148837_1_.readDouble(); + this.field_148938_b = p_148837_1_.readDouble(); + this.field_148939_c = p_148837_1_.readDouble(); + this.field_148936_d = p_148837_1_.readFloat(); + this.field_148937_e = p_148837_1_.readFloat(); + this.field_148935_f = p_148837_1_.readBoolean(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeDouble(this.field_148940_a); + p_148840_1_.writeDouble(this.field_148938_b); + p_148840_1_.writeDouble(this.field_148939_c); + p_148840_1_.writeFloat(this.field_148936_d); + p_148840_1_.writeFloat(this.field_148937_e); + p_148840_1_.writeBoolean(this.field_148935_f); + } + + public void processPacket(INetHandlerPlayClient p_148934_1_) + { + p_148934_1_.handlePlayerPosLook(this); + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } + + @SideOnly(Side.CLIENT) + public double func_148932_c() + { + return this.field_148940_a; + } + + @SideOnly(Side.CLIENT) + public double func_148928_d() + { + return this.field_148938_b; + } + + @SideOnly(Side.CLIENT) + public double func_148933_e() + { + return this.field_148939_c; + } + + @SideOnly(Side.CLIENT) + public float func_148931_f() + { + return this.field_148936_d; + } + + @SideOnly(Side.CLIENT) + public float func_148930_g() + { + return this.field_148937_e; + } + + @SideOnly(Side.CLIENT) + public boolean func_148929_h() + { + return this.field_148935_f; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S09PacketHeldItemChange.java b/src/main/java/net/minecraft/network/play/server/S09PacketHeldItemChange.java new file mode 100644 index 0000000..3687695 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S09PacketHeldItemChange.java @@ -0,0 +1,48 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; + +public class S09PacketHeldItemChange extends Packet +{ + private int field_149387_a; + private static final String __OBFID = "CL_00001324"; + + public S09PacketHeldItemChange() {} + + public S09PacketHeldItemChange(int p_i45215_1_) + { + this.field_149387_a = p_i45215_1_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149387_a = p_148837_1_.readByte(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeByte(this.field_149387_a); + } + + public void processPacket(INetHandlerPlayClient p_149386_1_) + { + p_149386_1_.handleHeldItemChange(this); + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } + + @SideOnly(Side.CLIENT) + public int func_149385_c() + { + return this.field_149387_a; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S0APacketUseBed.java b/src/main/java/net/minecraft/network/play/server/S0APacketUseBed.java new file mode 100644 index 0000000..033e937 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S0APacketUseBed.java @@ -0,0 +1,80 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; +import net.minecraft.world.World; + +public class S0APacketUseBed extends Packet +{ + private int field_149097_a; + private int field_149095_b; + private int field_149096_c; + private int field_149094_d; + private static final String __OBFID = "CL_00001319"; + + public S0APacketUseBed() {} + + public S0APacketUseBed(EntityPlayer p_i45210_1_, int p_i45210_2_, int p_i45210_3_, int p_i45210_4_) + { + this.field_149095_b = p_i45210_2_; + this.field_149096_c = p_i45210_3_; + this.field_149094_d = p_i45210_4_; + this.field_149097_a = p_i45210_1_.getEntityId(); + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149097_a = p_148837_1_.readInt(); + this.field_149095_b = p_148837_1_.readInt(); + this.field_149096_c = p_148837_1_.readByte(); + this.field_149094_d = p_148837_1_.readInt(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeInt(this.field_149097_a); + p_148840_1_.writeInt(this.field_149095_b); + p_148840_1_.writeByte(this.field_149096_c); + p_148840_1_.writeInt(this.field_149094_d); + } + + public void processPacket(INetHandlerPlayClient p_149093_1_) + { + p_149093_1_.handleUseBed(this); + } + + @SideOnly(Side.CLIENT) + public EntityPlayer func_149091_a(World p_149091_1_) + { + return (EntityPlayer)p_149091_1_.getEntityByID(this.field_149097_a); + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } + + @SideOnly(Side.CLIENT) + public int func_149092_c() + { + return this.field_149095_b; + } + + @SideOnly(Side.CLIENT) + public int func_149090_d() + { + return this.field_149096_c; + } + + @SideOnly(Side.CLIENT) + public int func_149089_e() + { + return this.field_149094_d; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S0BPacketAnimation.java b/src/main/java/net/minecraft/network/play/server/S0BPacketAnimation.java new file mode 100644 index 0000000..90aa91b --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S0BPacketAnimation.java @@ -0,0 +1,64 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.entity.Entity; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; + +public class S0BPacketAnimation extends Packet +{ + private int field_148981_a; + private int field_148980_b; + private static final String __OBFID = "CL_00001282"; + + public S0BPacketAnimation() {} + + public S0BPacketAnimation(Entity p_i45172_1_, int p_i45172_2_) + { + this.field_148981_a = p_i45172_1_.getEntityId(); + this.field_148980_b = p_i45172_2_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_148981_a = p_148837_1_.readVarIntFromBuffer(); + this.field_148980_b = p_148837_1_.readUnsignedByte(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeVarIntToBuffer(this.field_148981_a); + p_148840_1_.writeByte(this.field_148980_b); + } + + public void processPacket(INetHandlerPlayClient p_148979_1_) + { + p_148979_1_.handleAnimation(this); + } + + public String serialize() + { + return String.format("id=%d, type=%d", new Object[] {Integer.valueOf(this.field_148981_a), Integer.valueOf(this.field_148980_b)}); + } + + @SideOnly(Side.CLIENT) + public int func_148978_c() + { + return this.field_148981_a; + } + + @SideOnly(Side.CLIENT) + public int func_148977_d() + { + return this.field_148980_b; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S0CPacketSpawnPlayer.java b/src/main/java/net/minecraft/network/play/server/S0CPacketSpawnPlayer.java new file mode 100644 index 0000000..da5f821 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S0CPacketSpawnPlayer.java @@ -0,0 +1,148 @@ +package net.minecraft.network.play.server; + +import com.mojang.authlib.GameProfile; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import java.util.List; +import net.minecraft.entity.DataWatcher; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; +import net.minecraft.util.MathHelper; + +public class S0CPacketSpawnPlayer extends Packet +{ + private int field_148957_a; + private GameProfile field_148955_b; + private int field_148956_c; + private int field_148953_d; + private int field_148954_e; + private byte field_148951_f; + private byte field_148952_g; + private int field_148959_h; + private DataWatcher field_148960_i; + private List field_148958_j; + private static final String __OBFID = "CL_00001281"; + + public S0CPacketSpawnPlayer() {} + + public S0CPacketSpawnPlayer(EntityPlayer p_i45171_1_) + { + this.field_148957_a = p_i45171_1_.getEntityId(); + this.field_148955_b = p_i45171_1_.getGameProfile(); + this.field_148956_c = MathHelper.floor_double(p_i45171_1_.posX * 32.0D); + this.field_148953_d = MathHelper.floor_double(p_i45171_1_.posY * 32.0D); + this.field_148954_e = MathHelper.floor_double(p_i45171_1_.posZ * 32.0D); + this.field_148951_f = (byte)((int)(p_i45171_1_.rotationYaw * 256.0F / 360.0F)); + this.field_148952_g = (byte)((int)(p_i45171_1_.rotationPitch * 256.0F / 360.0F)); + ItemStack itemstack = p_i45171_1_.inventory.getCurrentItem(); + this.field_148959_h = itemstack == null ? 0 : Item.getIdFromItem(itemstack.getItem()); + this.field_148960_i = p_i45171_1_.getDataWatcher(); + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_148957_a = p_148837_1_.readVarIntFromBuffer(); + this.field_148955_b = new GameProfile(p_148837_1_.readStringFromBuffer(36), p_148837_1_.readStringFromBuffer(16)); + this.field_148956_c = p_148837_1_.readInt(); + this.field_148953_d = p_148837_1_.readInt(); + this.field_148954_e = p_148837_1_.readInt(); + this.field_148951_f = p_148837_1_.readByte(); + this.field_148952_g = p_148837_1_.readByte(); + this.field_148959_h = p_148837_1_.readShort(); + this.field_148958_j = DataWatcher.readWatchedListFromPacketBuffer(p_148837_1_); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeVarIntToBuffer(this.field_148957_a); + p_148840_1_.writeStringToBuffer(this.field_148955_b.getId()); + p_148840_1_.writeStringToBuffer(this.field_148955_b.getName()); + p_148840_1_.writeInt(this.field_148956_c); + p_148840_1_.writeInt(this.field_148953_d); + p_148840_1_.writeInt(this.field_148954_e); + p_148840_1_.writeByte(this.field_148951_f); + p_148840_1_.writeByte(this.field_148952_g); + p_148840_1_.writeShort(this.field_148959_h); + this.field_148960_i.func_151509_a(p_148840_1_); + } + + public void processPacket(INetHandlerPlayClient p_148950_1_) + { + p_148950_1_.handleSpawnPlayer(this); + } + + @SideOnly(Side.CLIENT) + public List func_148944_c() + { + if (this.field_148958_j == null) + { + this.field_148958_j = this.field_148960_i.getAllWatched(); + } + + return this.field_148958_j; + } + + public String serialize() + { + return String.format("id=%d, gameProfile=\'%s\', x=%.2f, y=%.2f, z=%.2f, carried=%d", new Object[] {Integer.valueOf(this.field_148957_a), this.field_148955_b, Float.valueOf((float)this.field_148956_c / 32.0F), Float.valueOf((float)this.field_148953_d / 32.0F), Float.valueOf((float)this.field_148954_e / 32.0F), Integer.valueOf(this.field_148959_h)}); + } + + @SideOnly(Side.CLIENT) + public int func_148943_d() + { + return this.field_148957_a; + } + + @SideOnly(Side.CLIENT) + public GameProfile func_148948_e() + { + return this.field_148955_b; + } + + @SideOnly(Side.CLIENT) + public int func_148942_f() + { + return this.field_148956_c; + } + + @SideOnly(Side.CLIENT) + public int func_148949_g() + { + return this.field_148953_d; + } + + @SideOnly(Side.CLIENT) + public int func_148946_h() + { + return this.field_148954_e; + } + + @SideOnly(Side.CLIENT) + public byte func_148941_i() + { + return this.field_148951_f; + } + + @SideOnly(Side.CLIENT) + public byte func_148945_j() + { + return this.field_148952_g; + } + + @SideOnly(Side.CLIENT) + public int func_148947_k() + { + return this.field_148959_h; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S0DPacketCollectItem.java b/src/main/java/net/minecraft/network/play/server/S0DPacketCollectItem.java new file mode 100644 index 0000000..01cc1b1 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S0DPacketCollectItem.java @@ -0,0 +1,58 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; + +public class S0DPacketCollectItem extends Packet +{ + private int field_149357_a; + private int field_149356_b; + private static final String __OBFID = "CL_00001339"; + + public S0DPacketCollectItem() {} + + public S0DPacketCollectItem(int p_i45232_1_, int p_i45232_2_) + { + this.field_149357_a = p_i45232_1_; + this.field_149356_b = p_i45232_2_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149357_a = p_148837_1_.readInt(); + this.field_149356_b = p_148837_1_.readInt(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeInt(this.field_149357_a); + p_148840_1_.writeInt(this.field_149356_b); + } + + public void processPacket(INetHandlerPlayClient p_149355_1_) + { + p_149355_1_.handleCollectItem(this); + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } + + @SideOnly(Side.CLIENT) + public int func_149354_c() + { + return this.field_149357_a; + } + + @SideOnly(Side.CLIENT) + public int func_149353_d() + { + return this.field_149356_b; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S0EPacketSpawnObject.java b/src/main/java/net/minecraft/network/play/server/S0EPacketSpawnObject.java new file mode 100644 index 0000000..f3fadee --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S0EPacketSpawnObject.java @@ -0,0 +1,243 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.entity.Entity; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; +import net.minecraft.util.MathHelper; + +public class S0EPacketSpawnObject extends Packet +{ + private int field_149018_a; + private int field_149016_b; + private int field_149017_c; + private int field_149014_d; + private int field_149015_e; + private int field_149012_f; + private int field_149013_g; + private int field_149021_h; + private int field_149022_i; + private int field_149019_j; + private int field_149020_k; + private static final String __OBFID = "CL_00001276"; + + public S0EPacketSpawnObject() {} + + public S0EPacketSpawnObject(Entity p_i45165_1_, int p_i45165_2_) + { + this(p_i45165_1_, p_i45165_2_, 0); + } + + public S0EPacketSpawnObject(Entity p_i45166_1_, int p_i45166_2_, int p_i45166_3_) + { + this.field_149018_a = p_i45166_1_.getEntityId(); + this.field_149016_b = MathHelper.floor_double(p_i45166_1_.posX * 32.0D); + this.field_149017_c = MathHelper.floor_double(p_i45166_1_.posY * 32.0D); + this.field_149014_d = MathHelper.floor_double(p_i45166_1_.posZ * 32.0D); + this.field_149021_h = MathHelper.floor_float(p_i45166_1_.rotationPitch * 256.0F / 360.0F); + this.field_149022_i = MathHelper.floor_float(p_i45166_1_.rotationYaw * 256.0F / 360.0F); + this.field_149019_j = p_i45166_2_; + this.field_149020_k = p_i45166_3_; + + if (p_i45166_3_ > 0) + { + double d0 = p_i45166_1_.motionX; + double d1 = p_i45166_1_.motionY; + double d2 = p_i45166_1_.motionZ; + double d3 = 3.9D; + + if (d0 < -d3) + { + d0 = -d3; + } + + if (d1 < -d3) + { + d1 = -d3; + } + + if (d2 < -d3) + { + d2 = -d3; + } + + if (d0 > d3) + { + d0 = d3; + } + + if (d1 > d3) + { + d1 = d3; + } + + if (d2 > d3) + { + d2 = d3; + } + + this.field_149015_e = (int)(d0 * 8000.0D); + this.field_149012_f = (int)(d1 * 8000.0D); + this.field_149013_g = (int)(d2 * 8000.0D); + } + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149018_a = p_148837_1_.readVarIntFromBuffer(); + this.field_149019_j = p_148837_1_.readByte(); + this.field_149016_b = p_148837_1_.readInt(); + this.field_149017_c = p_148837_1_.readInt(); + this.field_149014_d = p_148837_1_.readInt(); + this.field_149021_h = p_148837_1_.readByte(); + this.field_149022_i = p_148837_1_.readByte(); + this.field_149020_k = p_148837_1_.readInt(); + + if (this.field_149020_k > 0) + { + this.field_149015_e = p_148837_1_.readShort(); + this.field_149012_f = p_148837_1_.readShort(); + this.field_149013_g = p_148837_1_.readShort(); + } + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeVarIntToBuffer(this.field_149018_a); + p_148840_1_.writeByte(this.field_149019_j); + p_148840_1_.writeInt(this.field_149016_b); + p_148840_1_.writeInt(this.field_149017_c); + p_148840_1_.writeInt(this.field_149014_d); + p_148840_1_.writeByte(this.field_149021_h); + p_148840_1_.writeByte(this.field_149022_i); + p_148840_1_.writeInt(this.field_149020_k); + + if (this.field_149020_k > 0) + { + p_148840_1_.writeShort(this.field_149015_e); + p_148840_1_.writeShort(this.field_149012_f); + p_148840_1_.writeShort(this.field_149013_g); + } + } + + public void processPacket(INetHandlerPlayClient p_149011_1_) + { + p_149011_1_.handleSpawnObject(this); + } + + public String serialize() + { + return String.format("id=%d, type=%d, x=%.2f, y=%.2f, z=%.2f", new Object[] {Integer.valueOf(this.field_149018_a), Integer.valueOf(this.field_149019_j), Float.valueOf((float)this.field_149016_b / 32.0F), Float.valueOf((float)this.field_149017_c / 32.0F), Float.valueOf((float)this.field_149014_d / 32.0F)}); + } + + @SideOnly(Side.CLIENT) + public int func_149001_c() + { + return this.field_149018_a; + } + + @SideOnly(Side.CLIENT) + public int func_148997_d() + { + return this.field_149016_b; + } + + @SideOnly(Side.CLIENT) + public int func_148998_e() + { + return this.field_149017_c; + } + + @SideOnly(Side.CLIENT) + public int func_148994_f() + { + return this.field_149014_d; + } + + @SideOnly(Side.CLIENT) + public int func_149010_g() + { + return this.field_149015_e; + } + + @SideOnly(Side.CLIENT) + public int func_149004_h() + { + return this.field_149012_f; + } + + @SideOnly(Side.CLIENT) + public int func_148999_i() + { + return this.field_149013_g; + } + + @SideOnly(Side.CLIENT) + public int func_149008_j() + { + return this.field_149021_h; + } + + @SideOnly(Side.CLIENT) + public int func_149006_k() + { + return this.field_149022_i; + } + + @SideOnly(Side.CLIENT) + public int func_148993_l() + { + return this.field_149019_j; + } + + @SideOnly(Side.CLIENT) + public int func_149009_m() + { + return this.field_149020_k; + } + + public void func_148996_a(int p_148996_1_) + { + this.field_149016_b = p_148996_1_; + } + + public void func_148995_b(int p_148995_1_) + { + this.field_149017_c = p_148995_1_; + } + + public void func_149005_c(int p_149005_1_) + { + this.field_149014_d = p_149005_1_; + } + + public void func_149003_d(int p_149003_1_) + { + this.field_149015_e = p_149003_1_; + } + + public void func_149000_e(int p_149000_1_) + { + this.field_149012_f = p_149000_1_; + } + + public void func_149007_f(int p_149007_1_) + { + this.field_149013_g = p_149007_1_; + } + + @SideOnly(Side.CLIENT) + public void func_149002_g(int p_149002_1_) + { + this.field_149020_k = p_149002_1_; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S0FPacketSpawnMob.java b/src/main/java/net/minecraft/network/play/server/S0FPacketSpawnMob.java new file mode 100644 index 0000000..9170d77 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S0FPacketSpawnMob.java @@ -0,0 +1,209 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import java.util.List; +import net.minecraft.entity.DataWatcher; +import net.minecraft.entity.EntityList; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; +import net.minecraft.util.MathHelper; + +public class S0FPacketSpawnMob extends Packet +{ + private int field_149042_a; + private int field_149040_b; + private int field_149041_c; + private int field_149038_d; + private int field_149039_e; + private int field_149036_f; + private int field_149037_g; + private int field_149047_h; + private byte field_149048_i; + private byte field_149045_j; + private byte field_149046_k; + private DataWatcher field_149043_l; + private List field_149044_m; + private static final String __OBFID = "CL_00001279"; + + public S0FPacketSpawnMob() {} + + public S0FPacketSpawnMob(EntityLivingBase p_i45192_1_) + { + this.field_149042_a = p_i45192_1_.getEntityId(); + this.field_149040_b = (byte)EntityList.getEntityID(p_i45192_1_); + this.field_149041_c = p_i45192_1_.myEntitySize.multiplyBy32AndRound(p_i45192_1_.posX); + this.field_149038_d = MathHelper.floor_double(p_i45192_1_.posY * 32.0D); + this.field_149039_e = p_i45192_1_.myEntitySize.multiplyBy32AndRound(p_i45192_1_.posZ); + this.field_149048_i = (byte)((int)(p_i45192_1_.rotationYaw * 256.0F / 360.0F)); + this.field_149045_j = (byte)((int)(p_i45192_1_.rotationPitch * 256.0F / 360.0F)); + this.field_149046_k = (byte)((int)(p_i45192_1_.rotationYawHead * 256.0F / 360.0F)); + double d0 = 3.9D; + double d1 = p_i45192_1_.motionX; + double d2 = p_i45192_1_.motionY; + double d3 = p_i45192_1_.motionZ; + + if (d1 < -d0) + { + d1 = -d0; + } + + if (d2 < -d0) + { + d2 = -d0; + } + + if (d3 < -d0) + { + d3 = -d0; + } + + if (d1 > d0) + { + d1 = d0; + } + + if (d2 > d0) + { + d2 = d0; + } + + if (d3 > d0) + { + d3 = d0; + } + + this.field_149036_f = (int)(d1 * 8000.0D); + this.field_149037_g = (int)(d2 * 8000.0D); + this.field_149047_h = (int)(d3 * 8000.0D); + this.field_149043_l = p_i45192_1_.getDataWatcher(); + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149042_a = p_148837_1_.readVarIntFromBuffer(); + this.field_149040_b = p_148837_1_.readByte() & 255; + this.field_149041_c = p_148837_1_.readInt(); + this.field_149038_d = p_148837_1_.readInt(); + this.field_149039_e = p_148837_1_.readInt(); + this.field_149048_i = p_148837_1_.readByte(); + this.field_149045_j = p_148837_1_.readByte(); + this.field_149046_k = p_148837_1_.readByte(); + this.field_149036_f = p_148837_1_.readShort(); + this.field_149037_g = p_148837_1_.readShort(); + this.field_149047_h = p_148837_1_.readShort(); + this.field_149044_m = DataWatcher.readWatchedListFromPacketBuffer(p_148837_1_); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeVarIntToBuffer(this.field_149042_a); + p_148840_1_.writeByte(this.field_149040_b & 255); + p_148840_1_.writeInt(this.field_149041_c); + p_148840_1_.writeInt(this.field_149038_d); + p_148840_1_.writeInt(this.field_149039_e); + p_148840_1_.writeByte(this.field_149048_i); + p_148840_1_.writeByte(this.field_149045_j); + p_148840_1_.writeByte(this.field_149046_k); + p_148840_1_.writeShort(this.field_149036_f); + p_148840_1_.writeShort(this.field_149037_g); + p_148840_1_.writeShort(this.field_149047_h); + this.field_149043_l.func_151509_a(p_148840_1_); + } + + public void processPacket(INetHandlerPlayClient p_149035_1_) + { + p_149035_1_.handleSpawnMob(this); + } + + @SideOnly(Side.CLIENT) + public List func_149027_c() + { + if (this.field_149044_m == null) + { + this.field_149044_m = this.field_149043_l.getAllWatched(); + } + + return this.field_149044_m; + } + + public String serialize() + { + return String.format("id=%d, type=%d, x=%.2f, y=%.2f, z=%.2f, xd=%.2f, yd=%.2f, zd=%.2f", new Object[] {Integer.valueOf(this.field_149042_a), Integer.valueOf(this.field_149040_b), Float.valueOf((float)this.field_149041_c / 32.0F), Float.valueOf((float)this.field_149038_d / 32.0F), Float.valueOf((float)this.field_149039_e / 32.0F), Float.valueOf((float)this.field_149036_f / 8000.0F), Float.valueOf((float)this.field_149037_g / 8000.0F), Float.valueOf((float)this.field_149047_h / 8000.0F)}); + } + + @SideOnly(Side.CLIENT) + public int func_149024_d() + { + return this.field_149042_a; + } + + @SideOnly(Side.CLIENT) + public int func_149025_e() + { + return this.field_149040_b; + } + + @SideOnly(Side.CLIENT) + public int func_149023_f() + { + return this.field_149041_c; + } + + @SideOnly(Side.CLIENT) + public int func_149034_g() + { + return this.field_149038_d; + } + + @SideOnly(Side.CLIENT) + public int func_149029_h() + { + return this.field_149039_e; + } + + @SideOnly(Side.CLIENT) + public int func_149026_i() + { + return this.field_149036_f; + } + + @SideOnly(Side.CLIENT) + public int func_149033_j() + { + return this.field_149037_g; + } + + @SideOnly(Side.CLIENT) + public int func_149031_k() + { + return this.field_149047_h; + } + + @SideOnly(Side.CLIENT) + public byte func_149028_l() + { + return this.field_149048_i; + } + + @SideOnly(Side.CLIENT) + public byte func_149030_m() + { + return this.field_149045_j; + } + + @SideOnly(Side.CLIENT) + public byte func_149032_n() + { + return this.field_149046_k; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S10PacketSpawnPainting.java b/src/main/java/net/minecraft/network/play/server/S10PacketSpawnPainting.java new file mode 100644 index 0000000..9b3db3e --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S10PacketSpawnPainting.java @@ -0,0 +1,104 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.entity.item.EntityPainting; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; + +public class S10PacketSpawnPainting extends Packet +{ + private int field_148973_a; + private int field_148971_b; + private int field_148972_c; + private int field_148969_d; + private int field_148970_e; + private String field_148968_f; + private static final String __OBFID = "CL_00001280"; + + public S10PacketSpawnPainting() {} + + public S10PacketSpawnPainting(EntityPainting p_i45170_1_) + { + this.field_148973_a = p_i45170_1_.getEntityId(); + this.field_148971_b = p_i45170_1_.field_146063_b; + this.field_148972_c = p_i45170_1_.field_146064_c; + this.field_148969_d = p_i45170_1_.field_146062_d; + this.field_148970_e = p_i45170_1_.hangingDirection; + this.field_148968_f = p_i45170_1_.art.title; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_148973_a = p_148837_1_.readVarIntFromBuffer(); + this.field_148968_f = p_148837_1_.readStringFromBuffer(EntityPainting.EnumArt.maxArtTitleLength); + this.field_148971_b = p_148837_1_.readInt(); + this.field_148972_c = p_148837_1_.readInt(); + this.field_148969_d = p_148837_1_.readInt(); + this.field_148970_e = p_148837_1_.readInt(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeVarIntToBuffer(this.field_148973_a); + p_148840_1_.writeStringToBuffer(this.field_148968_f); + p_148840_1_.writeInt(this.field_148971_b); + p_148840_1_.writeInt(this.field_148972_c); + p_148840_1_.writeInt(this.field_148969_d); + p_148840_1_.writeInt(this.field_148970_e); + } + + public void processPacket(INetHandlerPlayClient p_148967_1_) + { + p_148967_1_.handleSpawnPainting(this); + } + + public String serialize() + { + return String.format("id=%d, type=%s, x=%d, y=%d, z=%d", new Object[] {Integer.valueOf(this.field_148973_a), this.field_148968_f, Integer.valueOf(this.field_148971_b), Integer.valueOf(this.field_148972_c), Integer.valueOf(this.field_148969_d)}); + } + + @SideOnly(Side.CLIENT) + public int func_148965_c() + { + return this.field_148973_a; + } + + @SideOnly(Side.CLIENT) + public int func_148964_d() + { + return this.field_148971_b; + } + + @SideOnly(Side.CLIENT) + public int func_148963_e() + { + return this.field_148972_c; + } + + @SideOnly(Side.CLIENT) + public int func_148962_f() + { + return this.field_148969_d; + } + + @SideOnly(Side.CLIENT) + public int func_148966_g() + { + return this.field_148970_e; + } + + @SideOnly(Side.CLIENT) + public String func_148961_h() + { + return this.field_148968_f; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S11PacketSpawnExperienceOrb.java b/src/main/java/net/minecraft/network/play/server/S11PacketSpawnExperienceOrb.java new file mode 100644 index 0000000..71893b5 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S11PacketSpawnExperienceOrb.java @@ -0,0 +1,95 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.entity.item.EntityXPOrb; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; +import net.minecraft.util.MathHelper; + +public class S11PacketSpawnExperienceOrb extends Packet +{ + private int field_148992_a; + private int field_148990_b; + private int field_148991_c; + private int field_148988_d; + private int field_148989_e; + private static final String __OBFID = "CL_00001277"; + + public S11PacketSpawnExperienceOrb() {} + + public S11PacketSpawnExperienceOrb(EntityXPOrb p_i45167_1_) + { + this.field_148992_a = p_i45167_1_.getEntityId(); + this.field_148990_b = MathHelper.floor_double(p_i45167_1_.posX * 32.0D); + this.field_148991_c = MathHelper.floor_double(p_i45167_1_.posY * 32.0D); + this.field_148988_d = MathHelper.floor_double(p_i45167_1_.posZ * 32.0D); + this.field_148989_e = p_i45167_1_.getXpValue(); + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_148992_a = p_148837_1_.readVarIntFromBuffer(); + this.field_148990_b = p_148837_1_.readInt(); + this.field_148991_c = p_148837_1_.readInt(); + this.field_148988_d = p_148837_1_.readInt(); + this.field_148989_e = p_148837_1_.readShort(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeVarIntToBuffer(this.field_148992_a); + p_148840_1_.writeInt(this.field_148990_b); + p_148840_1_.writeInt(this.field_148991_c); + p_148840_1_.writeInt(this.field_148988_d); + p_148840_1_.writeShort(this.field_148989_e); + } + + public void processPacket(INetHandlerPlayClient p_148987_1_) + { + p_148987_1_.handleSpawnExperienceOrb(this); + } + + public String serialize() + { + return String.format("id=%d, value=%d, x=%.2f, y=%.2f, z=%.2f", new Object[] {Integer.valueOf(this.field_148992_a), Integer.valueOf(this.field_148989_e), Float.valueOf((float)this.field_148990_b / 32.0F), Float.valueOf((float)this.field_148991_c / 32.0F), Float.valueOf((float)this.field_148988_d / 32.0F)}); + } + + @SideOnly(Side.CLIENT) + public int func_148985_c() + { + return this.field_148992_a; + } + + @SideOnly(Side.CLIENT) + public int func_148984_d() + { + return this.field_148990_b; + } + + @SideOnly(Side.CLIENT) + public int func_148983_e() + { + return this.field_148991_c; + } + + @SideOnly(Side.CLIENT) + public int func_148982_f() + { + return this.field_148988_d; + } + + @SideOnly(Side.CLIENT) + public int func_148986_g() + { + return this.field_148989_e; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S12PacketEntityVelocity.java b/src/main/java/net/minecraft/network/play/server/S12PacketEntityVelocity.java new file mode 100644 index 0000000..582fa1b --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S12PacketEntityVelocity.java @@ -0,0 +1,121 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.entity.Entity; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; + +public class S12PacketEntityVelocity extends Packet +{ + private int field_149417_a; + private int field_149415_b; + private int field_149416_c; + private int field_149414_d; + private static final String __OBFID = "CL_00001328"; + + public S12PacketEntityVelocity() {} + + public S12PacketEntityVelocity(Entity p_i45219_1_) + { + this(p_i45219_1_.getEntityId(), p_i45219_1_.motionX, p_i45219_1_.motionY, p_i45219_1_.motionZ); + } + + public S12PacketEntityVelocity(int p_i45220_1_, double p_i45220_2_, double p_i45220_4_, double p_i45220_6_) + { + this.field_149417_a = p_i45220_1_; + double d3 = 3.9D; + + if (p_i45220_2_ < -d3) + { + p_i45220_2_ = -d3; + } + + if (p_i45220_4_ < -d3) + { + p_i45220_4_ = -d3; + } + + if (p_i45220_6_ < -d3) + { + p_i45220_6_ = -d3; + } + + if (p_i45220_2_ > d3) + { + p_i45220_2_ = d3; + } + + if (p_i45220_4_ > d3) + { + p_i45220_4_ = d3; + } + + if (p_i45220_6_ > d3) + { + p_i45220_6_ = d3; + } + + this.field_149415_b = (int)(p_i45220_2_ * 8000.0D); + this.field_149416_c = (int)(p_i45220_4_ * 8000.0D); + this.field_149414_d = (int)(p_i45220_6_ * 8000.0D); + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149417_a = p_148837_1_.readInt(); + this.field_149415_b = p_148837_1_.readShort(); + this.field_149416_c = p_148837_1_.readShort(); + this.field_149414_d = p_148837_1_.readShort(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeInt(this.field_149417_a); + p_148840_1_.writeShort(this.field_149415_b); + p_148840_1_.writeShort(this.field_149416_c); + p_148840_1_.writeShort(this.field_149414_d); + } + + public void processPacket(INetHandlerPlayClient p_149413_1_) + { + p_149413_1_.handleEntityVelocity(this); + } + + public String serialize() + { + return String.format("id=%d, x=%.2f, y=%.2f, z=%.2f", new Object[] {Integer.valueOf(this.field_149417_a), Float.valueOf((float)this.field_149415_b / 8000.0F), Float.valueOf((float)this.field_149416_c / 8000.0F), Float.valueOf((float)this.field_149414_d / 8000.0F)}); + } + + @SideOnly(Side.CLIENT) + public int func_149412_c() + { + return this.field_149417_a; + } + + @SideOnly(Side.CLIENT) + public int func_149411_d() + { + return this.field_149415_b; + } + + @SideOnly(Side.CLIENT) + public int func_149410_e() + { + return this.field_149416_c; + } + + @SideOnly(Side.CLIENT) + public int func_149409_f() + { + return this.field_149414_d; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S13PacketDestroyEntities.java b/src/main/java/net/minecraft/network/play/server/S13PacketDestroyEntities.java new file mode 100644 index 0000000..9a2adde --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S13PacketDestroyEntities.java @@ -0,0 +1,75 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; + +public class S13PacketDestroyEntities extends Packet +{ + private int[] field_149100_a; + private static final String __OBFID = "CL_00001320"; + + public S13PacketDestroyEntities() {} + + public S13PacketDestroyEntities(int ... p_i45211_1_) + { + this.field_149100_a = p_i45211_1_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149100_a = new int[p_148837_1_.readByte()]; + + for (int i = 0; i < this.field_149100_a.length; ++i) + { + this.field_149100_a[i] = p_148837_1_.readInt(); + } + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeByte(this.field_149100_a.length); + + for (int i = 0; i < this.field_149100_a.length; ++i) + { + p_148840_1_.writeInt(this.field_149100_a[i]); + } + } + + public void processPacket(INetHandlerPlayClient p_149099_1_) + { + p_149099_1_.handleDestroyEntities(this); + } + + public String serialize() + { + StringBuilder stringbuilder = new StringBuilder(); + + for (int i = 0; i < this.field_149100_a.length; ++i) + { + if (i > 0) + { + stringbuilder.append(", "); + } + + stringbuilder.append(this.field_149100_a[i]); + } + + return String.format("entities=%d[%s]", new Object[] {Integer.valueOf(this.field_149100_a.length), stringbuilder}); + } + + @SideOnly(Side.CLIENT) + public int[] func_149098_c() + { + return this.field_149100_a; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S14PacketEntity.java b/src/main/java/net/minecraft/network/play/server/S14PacketEntity.java new file mode 100644 index 0000000..c93c429 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S14PacketEntity.java @@ -0,0 +1,236 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.entity.Entity; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; +import net.minecraft.world.World; + +public class S14PacketEntity extends Packet +{ + protected int field_149074_a; + protected byte field_149072_b; + protected byte field_149073_c; + protected byte field_149070_d; + protected byte field_149071_e; + protected byte field_149068_f; + protected boolean field_149069_g; + private static final String __OBFID = "CL_00001312"; + + public S14PacketEntity() {} + + public S14PacketEntity(int p_i45206_1_) + { + this.field_149074_a = p_i45206_1_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149074_a = p_148837_1_.readInt(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeInt(this.field_149074_a); + } + + public void processPacket(INetHandlerPlayClient p_149067_1_) + { + p_149067_1_.handleEntityMovement(this); + } + + public String serialize() + { + return String.format("id=%d", new Object[] {Integer.valueOf(this.field_149074_a)}); + } + + public String toString() + { + return "Entity_" + super.toString(); + } + + @SideOnly(Side.CLIENT) + public Entity func_149065_a(World p_149065_1_) + { + return p_149065_1_.getEntityByID(this.field_149074_a); + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } + + @SideOnly(Side.CLIENT) + public byte func_149062_c() + { + return this.field_149072_b; + } + + @SideOnly(Side.CLIENT) + public byte func_149061_d() + { + return this.field_149073_c; + } + + @SideOnly(Side.CLIENT) + public byte func_149064_e() + { + return this.field_149070_d; + } + + @SideOnly(Side.CLIENT) + public byte func_149066_f() + { + return this.field_149071_e; + } + + @SideOnly(Side.CLIENT) + public byte func_149063_g() + { + return this.field_149068_f; + } + + @SideOnly(Side.CLIENT) + public boolean func_149060_h() + { + return this.field_149069_g; + } + + public static class S15PacketEntityRelMove extends S14PacketEntity + { + private static final String __OBFID = "CL_00001313"; + + public S15PacketEntityRelMove() {} + + public S15PacketEntityRelMove(int p_i45203_1_, byte p_i45203_2_, byte p_i45203_3_, byte p_i45203_4_) + { + super(p_i45203_1_); + this.field_149072_b = p_i45203_2_; + this.field_149073_c = p_i45203_3_; + this.field_149070_d = p_i45203_4_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + super.readPacketData(p_148837_1_); + this.field_149072_b = p_148837_1_.readByte(); + this.field_149073_c = p_148837_1_.readByte(); + this.field_149070_d = p_148837_1_.readByte(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + super.writePacketData(p_148840_1_); + p_148840_1_.writeByte(this.field_149072_b); + p_148840_1_.writeByte(this.field_149073_c); + p_148840_1_.writeByte(this.field_149070_d); + } + + public String serialize() + { + return super.serialize() + String.format(", xa=%d, ya=%d, za=%d", new Object[] {Byte.valueOf(this.field_149072_b), Byte.valueOf(this.field_149073_c), Byte.valueOf(this.field_149070_d)}); + } + + public void processPacket(INetHandler p_148833_1_) + { + super.processPacket((INetHandlerPlayClient)p_148833_1_); + } + } + + public static class S16PacketEntityLook extends S14PacketEntity + { + private static final String __OBFID = "CL_00001315"; + + public S16PacketEntityLook() + { + this.field_149069_g = true; + } + + public S16PacketEntityLook(int p_i45205_1_, byte p_i45205_2_, byte p_i45205_3_) + { + super(p_i45205_1_); + this.field_149071_e = p_i45205_2_; + this.field_149068_f = p_i45205_3_; + this.field_149069_g = true; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + super.readPacketData(p_148837_1_); + this.field_149071_e = p_148837_1_.readByte(); + this.field_149068_f = p_148837_1_.readByte(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + super.writePacketData(p_148840_1_); + p_148840_1_.writeByte(this.field_149071_e); + p_148840_1_.writeByte(this.field_149068_f); + } + + public String serialize() + { + return super.serialize() + String.format(", yRot=%d, xRot=%d", new Object[] {Byte.valueOf(this.field_149071_e), Byte.valueOf(this.field_149068_f)}); + } + + public void processPacket(INetHandler p_148833_1_) + { + super.processPacket((INetHandlerPlayClient)p_148833_1_); + } + } + + public static class S17PacketEntityLookMove extends S14PacketEntity + { + private static final String __OBFID = "CL_00001314"; + + public S17PacketEntityLookMove() + { + this.field_149069_g = true; + } + + public S17PacketEntityLookMove(int p_i45204_1_, byte p_i45204_2_, byte p_i45204_3_, byte p_i45204_4_, byte p_i45204_5_, byte p_i45204_6_) + { + super(p_i45204_1_); + this.field_149072_b = p_i45204_2_; + this.field_149073_c = p_i45204_3_; + this.field_149070_d = p_i45204_4_; + this.field_149071_e = p_i45204_5_; + this.field_149068_f = p_i45204_6_; + this.field_149069_g = true; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + super.readPacketData(p_148837_1_); + this.field_149072_b = p_148837_1_.readByte(); + this.field_149073_c = p_148837_1_.readByte(); + this.field_149070_d = p_148837_1_.readByte(); + this.field_149071_e = p_148837_1_.readByte(); + this.field_149068_f = p_148837_1_.readByte(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + super.writePacketData(p_148840_1_); + p_148840_1_.writeByte(this.field_149072_b); + p_148840_1_.writeByte(this.field_149073_c); + p_148840_1_.writeByte(this.field_149070_d); + p_148840_1_.writeByte(this.field_149071_e); + p_148840_1_.writeByte(this.field_149068_f); + } + + public String serialize() + { + return super.serialize() + String.format(", xa=%d, ya=%d, za=%d, yRot=%d, xRot=%d", new Object[] {Byte.valueOf(this.field_149072_b), Byte.valueOf(this.field_149073_c), Byte.valueOf(this.field_149070_d), Byte.valueOf(this.field_149071_e), Byte.valueOf(this.field_149068_f)}); + } + + public void processPacket(INetHandler p_148833_1_) + { + super.processPacket((INetHandlerPlayClient)p_148833_1_); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S18PacketEntityTeleport.java b/src/main/java/net/minecraft/network/play/server/S18PacketEntityTeleport.java new file mode 100644 index 0000000..db11f60 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S18PacketEntityTeleport.java @@ -0,0 +1,110 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.entity.Entity; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; +import net.minecraft.util.MathHelper; + +public class S18PacketEntityTeleport extends Packet +{ + private int field_149458_a; + private int field_149456_b; + private int field_149457_c; + private int field_149454_d; + private byte field_149455_e; + private byte field_149453_f; + private static final String __OBFID = "CL_00001340"; + + public S18PacketEntityTeleport() {} + + public S18PacketEntityTeleport(Entity p_i45233_1_) + { + this.field_149458_a = p_i45233_1_.getEntityId(); + this.field_149456_b = MathHelper.floor_double(p_i45233_1_.posX * 32.0D); + this.field_149457_c = MathHelper.floor_double(p_i45233_1_.posY * 32.0D); + this.field_149454_d = MathHelper.floor_double(p_i45233_1_.posZ * 32.0D); + this.field_149455_e = (byte)((int)(p_i45233_1_.rotationYaw * 256.0F / 360.0F)); + this.field_149453_f = (byte)((int)(p_i45233_1_.rotationPitch * 256.0F / 360.0F)); + } + + public S18PacketEntityTeleport(int p_i45234_1_, int p_i45234_2_, int p_i45234_3_, int p_i45234_4_, byte p_i45234_5_, byte p_i45234_6_) + { + this.field_149458_a = p_i45234_1_; + this.field_149456_b = p_i45234_2_; + this.field_149457_c = p_i45234_3_; + this.field_149454_d = p_i45234_4_; + this.field_149455_e = p_i45234_5_; + this.field_149453_f = p_i45234_6_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149458_a = p_148837_1_.readInt(); + this.field_149456_b = p_148837_1_.readInt(); + this.field_149457_c = p_148837_1_.readInt(); + this.field_149454_d = p_148837_1_.readInt(); + this.field_149455_e = p_148837_1_.readByte(); + this.field_149453_f = p_148837_1_.readByte(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeInt(this.field_149458_a); + p_148840_1_.writeInt(this.field_149456_b); + p_148840_1_.writeInt(this.field_149457_c); + p_148840_1_.writeInt(this.field_149454_d); + p_148840_1_.writeByte(this.field_149455_e); + p_148840_1_.writeByte(this.field_149453_f); + } + + public void processPacket(INetHandlerPlayClient p_149452_1_) + { + p_149452_1_.handleEntityTeleport(this); + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } + + @SideOnly(Side.CLIENT) + public int func_149451_c() + { + return this.field_149458_a; + } + + @SideOnly(Side.CLIENT) + public int func_149449_d() + { + return this.field_149456_b; + } + + @SideOnly(Side.CLIENT) + public int func_149448_e() + { + return this.field_149457_c; + } + + @SideOnly(Side.CLIENT) + public int func_149446_f() + { + return this.field_149454_d; + } + + @SideOnly(Side.CLIENT) + public byte func_149450_g() + { + return this.field_149455_e; + } + + @SideOnly(Side.CLIENT) + public byte func_149447_h() + { + return this.field_149453_f; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S19PacketEntityHeadLook.java b/src/main/java/net/minecraft/network/play/server/S19PacketEntityHeadLook.java new file mode 100644 index 0000000..37c2549 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S19PacketEntityHeadLook.java @@ -0,0 +1,65 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.entity.Entity; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; +import net.minecraft.world.World; + +public class S19PacketEntityHeadLook extends Packet +{ + private int field_149384_a; + private byte field_149383_b; + private static final String __OBFID = "CL_00001323"; + + public S19PacketEntityHeadLook() {} + + public S19PacketEntityHeadLook(Entity p_i45214_1_, byte p_i45214_2_) + { + this.field_149384_a = p_i45214_1_.getEntityId(); + this.field_149383_b = p_i45214_2_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149384_a = p_148837_1_.readInt(); + this.field_149383_b = p_148837_1_.readByte(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeInt(this.field_149384_a); + p_148840_1_.writeByte(this.field_149383_b); + } + + public void processPacket(INetHandlerPlayClient p_149382_1_) + { + p_149382_1_.handleEntityHeadLook(this); + } + + public String serialize() + { + return String.format("id=%d, rot=%d", new Object[] {Integer.valueOf(this.field_149384_a), Byte.valueOf(this.field_149383_b)}); + } + + @SideOnly(Side.CLIENT) + public Entity func_149381_a(World p_149381_1_) + { + return p_149381_1_.getEntityByID(this.field_149384_a); + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } + + @SideOnly(Side.CLIENT) + public byte func_149380_c() + { + return this.field_149383_b; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S19PacketEntityStatus.java b/src/main/java/net/minecraft/network/play/server/S19PacketEntityStatus.java new file mode 100644 index 0000000..3dfb5b4 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S19PacketEntityStatus.java @@ -0,0 +1,60 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.entity.Entity; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; +import net.minecraft.world.World; + +public class S19PacketEntityStatus extends Packet +{ + private int field_149164_a; + private byte field_149163_b; + private static final String __OBFID = "CL_00001299"; + + public S19PacketEntityStatus() {} + + public S19PacketEntityStatus(Entity p_i45192_1_, byte p_i45192_2_) + { + this.field_149164_a = p_i45192_1_.getEntityId(); + this.field_149163_b = p_i45192_2_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149164_a = p_148837_1_.readInt(); + this.field_149163_b = p_148837_1_.readByte(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeInt(this.field_149164_a); + p_148840_1_.writeByte(this.field_149163_b); + } + + public void processPacket(INetHandlerPlayClient p_149162_1_) + { + p_149162_1_.handleEntityStatus(this); + } + + @SideOnly(Side.CLIENT) + public Entity func_149161_a(World p_149161_1_) + { + return p_149161_1_.getEntityByID(this.field_149164_a); + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } + + @SideOnly(Side.CLIENT) + public byte func_149160_c() + { + return this.field_149163_b; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S1BPacketEntityAttach.java b/src/main/java/net/minecraft/network/play/server/S1BPacketEntityAttach.java new file mode 100644 index 0000000..0b9ca8b --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S1BPacketEntityAttach.java @@ -0,0 +1,69 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.entity.Entity; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; + +public class S1BPacketEntityAttach extends Packet +{ + private int field_149408_a; + private int field_149406_b; + private int field_149407_c; + private static final String __OBFID = "CL_00001327"; + + public S1BPacketEntityAttach() {} + + public S1BPacketEntityAttach(int p_i45218_1_, Entity p_i45218_2_, Entity p_i45218_3_) + { + this.field_149408_a = p_i45218_1_; + this.field_149406_b = p_i45218_2_.getEntityId(); + this.field_149407_c = p_i45218_3_ != null ? p_i45218_3_.getEntityId() : -1; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149406_b = p_148837_1_.readInt(); + this.field_149407_c = p_148837_1_.readInt(); + this.field_149408_a = p_148837_1_.readUnsignedByte(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeInt(this.field_149406_b); + p_148840_1_.writeInt(this.field_149407_c); + p_148840_1_.writeByte(this.field_149408_a); + } + + public void processPacket(INetHandlerPlayClient p_149405_1_) + { + p_149405_1_.handleEntityAttach(this); + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } + + @SideOnly(Side.CLIENT) + public int func_149404_c() + { + return this.field_149408_a; + } + + @SideOnly(Side.CLIENT) + public int func_149403_d() + { + return this.field_149406_b; + } + + @SideOnly(Side.CLIENT) + public int func_149402_e() + { + return this.field_149407_c; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S1CPacketEntityMetadata.java b/src/main/java/net/minecraft/network/play/server/S1CPacketEntityMetadata.java new file mode 100644 index 0000000..5f6922f --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S1CPacketEntityMetadata.java @@ -0,0 +1,68 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import java.util.List; +import net.minecraft.entity.DataWatcher; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; + +public class S1CPacketEntityMetadata extends Packet +{ + private int field_149379_a; + private List field_149378_b; + private static final String __OBFID = "CL_00001326"; + + public S1CPacketEntityMetadata() {} + + public S1CPacketEntityMetadata(int p_i45217_1_, DataWatcher p_i45217_2_, boolean p_i45217_3_) + { + this.field_149379_a = p_i45217_1_; + + if (p_i45217_3_) + { + this.field_149378_b = p_i45217_2_.getAllWatched(); + } + else + { + this.field_149378_b = p_i45217_2_.getChanged(); + } + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149379_a = p_148837_1_.readInt(); + this.field_149378_b = DataWatcher.readWatchedListFromPacketBuffer(p_148837_1_); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeInt(this.field_149379_a); + DataWatcher.writeWatchedListToPacketBuffer(this.field_149378_b, p_148840_1_); + } + + public void processPacket(INetHandlerPlayClient p_149377_1_) + { + p_149377_1_.handleEntityMetadata(this); + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } + + @SideOnly(Side.CLIENT) + public List func_149376_c() + { + return this.field_149378_b; + } + + @SideOnly(Side.CLIENT) + public int func_149375_d() + { + return this.field_149379_a; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S1DPacketEntityEffect.java b/src/main/java/net/minecraft/network/play/server/S1DPacketEntityEffect.java new file mode 100644 index 0000000..9005368 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S1DPacketEntityEffect.java @@ -0,0 +1,93 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; +import net.minecraft.potion.PotionEffect; + +public class S1DPacketEntityEffect extends Packet +{ + private int field_149434_a; + private byte field_149432_b; + private byte field_149433_c; + private short field_149431_d; + private static final String __OBFID = "CL_00001343"; + + public S1DPacketEntityEffect() {} + + public S1DPacketEntityEffect(int p_i45237_1_, PotionEffect p_i45237_2_) + { + this.field_149434_a = p_i45237_1_; + this.field_149432_b = (byte)(p_i45237_2_.getPotionID() & 255); + this.field_149433_c = (byte)(p_i45237_2_.getAmplifier() & 255); + + if (p_i45237_2_.getDuration() > 32767) + { + this.field_149431_d = 32767; + } + else + { + this.field_149431_d = (short)p_i45237_2_.getDuration(); + } + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149434_a = p_148837_1_.readInt(); + this.field_149432_b = p_148837_1_.readByte(); + this.field_149433_c = p_148837_1_.readByte(); + this.field_149431_d = p_148837_1_.readShort(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeInt(this.field_149434_a); + p_148840_1_.writeByte(this.field_149432_b); + p_148840_1_.writeByte(this.field_149433_c); + p_148840_1_.writeShort(this.field_149431_d); + } + + @SideOnly(Side.CLIENT) + public boolean func_149429_c() + { + return this.field_149431_d == 32767; + } + + public void processPacket(INetHandlerPlayClient p_149430_1_) + { + p_149430_1_.handleEntityEffect(this); + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } + + @SideOnly(Side.CLIENT) + public int func_149426_d() + { + return this.field_149434_a; + } + + @SideOnly(Side.CLIENT) + public byte func_149427_e() + { + return this.field_149432_b; + } + + @SideOnly(Side.CLIENT) + public byte func_149428_f() + { + return this.field_149433_c; + } + + @SideOnly(Side.CLIENT) + public short func_149425_g() + { + return this.field_149431_d; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S1EPacketRemoveEntityEffect.java b/src/main/java/net/minecraft/network/play/server/S1EPacketRemoveEntityEffect.java new file mode 100644 index 0000000..9f2bc45 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S1EPacketRemoveEntityEffect.java @@ -0,0 +1,59 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; +import net.minecraft.potion.PotionEffect; + +public class S1EPacketRemoveEntityEffect extends Packet +{ + private int field_149079_a; + private int field_149078_b; + private static final String __OBFID = "CL_00001321"; + + public S1EPacketRemoveEntityEffect() {} + + public S1EPacketRemoveEntityEffect(int p_i45212_1_, PotionEffect p_i45212_2_) + { + this.field_149079_a = p_i45212_1_; + this.field_149078_b = p_i45212_2_.getPotionID(); + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149079_a = p_148837_1_.readInt(); + this.field_149078_b = p_148837_1_.readUnsignedByte(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeInt(this.field_149079_a); + p_148840_1_.writeByte(this.field_149078_b); + } + + public void processPacket(INetHandlerPlayClient p_149077_1_) + { + p_149077_1_.handleRemoveEntityEffect(this); + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } + + @SideOnly(Side.CLIENT) + public int func_149076_c() + { + return this.field_149079_a; + } + + @SideOnly(Side.CLIENT) + public int func_149075_d() + { + return this.field_149078_b; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S1FPacketSetExperience.java b/src/main/java/net/minecraft/network/play/server/S1FPacketSetExperience.java new file mode 100644 index 0000000..22fe794 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S1FPacketSetExperience.java @@ -0,0 +1,68 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; + +public class S1FPacketSetExperience extends Packet +{ + private float field_149401_a; + private int field_149399_b; + private int field_149400_c; + private static final String __OBFID = "CL_00001331"; + + public S1FPacketSetExperience() {} + + public S1FPacketSetExperience(float p_i45222_1_, int p_i45222_2_, int p_i45222_3_) + { + this.field_149401_a = p_i45222_1_; + this.field_149399_b = p_i45222_2_; + this.field_149400_c = p_i45222_3_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149401_a = p_148837_1_.readFloat(); + this.field_149400_c = p_148837_1_.readShort(); + this.field_149399_b = p_148837_1_.readShort(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeFloat(this.field_149401_a); + p_148840_1_.writeShort(this.field_149400_c); + p_148840_1_.writeShort(this.field_149399_b); + } + + public void processPacket(INetHandlerPlayClient p_149398_1_) + { + p_149398_1_.handleSetExperience(this); + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } + + @SideOnly(Side.CLIENT) + public float func_149397_c() + { + return this.field_149401_a; + } + + @SideOnly(Side.CLIENT) + public int func_149396_d() + { + return this.field_149399_b; + } + + @SideOnly(Side.CLIENT) + public int func_149395_e() + { + return this.field_149400_c; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S20PacketEntityProperties.java b/src/main/java/net/minecraft/network/play/server/S20PacketEntityProperties.java new file mode 100644 index 0000000..e94bc64 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S20PacketEntityProperties.java @@ -0,0 +1,136 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.UUID; +import net.minecraft.entity.ai.attributes.AttributeModifier; +import net.minecraft.entity.ai.attributes.IAttributeInstance; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; + +public class S20PacketEntityProperties extends Packet +{ + private int field_149445_a; + private final List field_149444_b = new ArrayList(); + private static final String __OBFID = "CL_00001341"; + + public S20PacketEntityProperties() {} + + public S20PacketEntityProperties(int p_i45236_1_, Collection p_i45236_2_) + { + this.field_149445_a = p_i45236_1_; + Iterator iterator = p_i45236_2_.iterator(); + + while (iterator.hasNext()) + { + IAttributeInstance iattributeinstance = (IAttributeInstance)iterator.next(); + this.field_149444_b.add(new S20PacketEntityProperties.Snapshot(iattributeinstance.getAttribute().getAttributeUnlocalizedName(), iattributeinstance.getBaseValue(), iattributeinstance.func_111122_c())); + } + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149445_a = p_148837_1_.readInt(); + int i = p_148837_1_.readInt(); + + for (int j = 0; j < i; ++j) + { + String s = p_148837_1_.readStringFromBuffer(64); + double d0 = p_148837_1_.readDouble(); + ArrayList arraylist = new ArrayList(); + short short1 = p_148837_1_.readShort(); + + for (int k = 0; k < short1; ++k) + { + UUID uuid = new UUID(p_148837_1_.readLong(), p_148837_1_.readLong()); + arraylist.add(new AttributeModifier(uuid, "Unknown synced attribute modifier", p_148837_1_.readDouble(), p_148837_1_.readByte())); + } + + this.field_149444_b.add(new S20PacketEntityProperties.Snapshot(s, d0, arraylist)); + } + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeInt(this.field_149445_a); + p_148840_1_.writeInt(this.field_149444_b.size()); + Iterator iterator = this.field_149444_b.iterator(); + + while (iterator.hasNext()) + { + S20PacketEntityProperties.Snapshot snapshot = (S20PacketEntityProperties.Snapshot)iterator.next(); + p_148840_1_.writeStringToBuffer(snapshot.func_151409_a()); + p_148840_1_.writeDouble(snapshot.func_151410_b()); + p_148840_1_.writeShort(snapshot.func_151408_c().size()); + Iterator iterator1 = snapshot.func_151408_c().iterator(); + + while (iterator1.hasNext()) + { + AttributeModifier attributemodifier = (AttributeModifier)iterator1.next(); + p_148840_1_.writeLong(attributemodifier.getID().getMostSignificantBits()); + p_148840_1_.writeLong(attributemodifier.getID().getLeastSignificantBits()); + p_148840_1_.writeDouble(attributemodifier.getAmount()); + p_148840_1_.writeByte(attributemodifier.getOperation()); + } + } + } + + public void processPacket(INetHandlerPlayClient p_149443_1_) + { + p_149443_1_.handleEntityProperties(this); + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } + + @SideOnly(Side.CLIENT) + public int func_149442_c() + { + return this.field_149445_a; + } + + @SideOnly(Side.CLIENT) + public List func_149441_d() + { + return this.field_149444_b; + } + + public class Snapshot + { + private final String field_151412_b; + private final double field_151413_c; + private final Collection field_151411_d; + private static final String __OBFID = "CL_00001342"; + + public Snapshot(String p_i45235_2_, double p_i45235_3_, Collection p_i45235_5_) + { + this.field_151412_b = p_i45235_2_; + this.field_151413_c = p_i45235_3_; + this.field_151411_d = p_i45235_5_; + } + + public String func_151409_a() + { + return this.field_151412_b; + } + + public double func_151410_b() + { + return this.field_151413_c; + } + + public Collection func_151408_c() + { + return this.field_151411_d; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S21PacketChunkData.java b/src/main/java/net/minecraft/network/play/server/S21PacketChunkData.java new file mode 100644 index 0000000..3f2fb51 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S21PacketChunkData.java @@ -0,0 +1,296 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import java.util.concurrent.Semaphore; +import java.util.zip.DataFormatException; +import java.util.zip.Deflater; +import java.util.zip.Inflater; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.NibbleArray; +import net.minecraft.world.chunk.storage.ExtendedBlockStorage; + +public class S21PacketChunkData extends Packet +{ + private int field_149284_a; + private int field_149282_b; + private int field_149283_c; + private int field_149280_d; + private byte[] field_149281_e; + private byte[] field_149278_f; + private boolean field_149279_g; + private int field_149285_h; + private static byte[] field_149286_i = new byte[196864]; + private static final String __OBFID = "CL_00001304"; + private Semaphore deflateGate; + + public S21PacketChunkData() {} + + public S21PacketChunkData(Chunk p_i45196_1_, boolean p_i45196_2_, int p_i45196_3_) + { + this.field_149284_a = p_i45196_1_.xPosition; + this.field_149282_b = p_i45196_1_.zPosition; + this.field_149279_g = p_i45196_2_; + S21PacketChunkData.Extracted extracted = func_149269_a(p_i45196_1_, p_i45196_2_, p_i45196_3_); + this.field_149280_d = extracted.field_150281_c; + this.field_149283_c = extracted.field_150280_b; + this.field_149278_f = extracted.field_150282_a; + this.deflateGate = new Semaphore(1); + } + + private void deflate() + { + Deflater deflater = new Deflater(-1); + try + { + deflater.setInput(this.field_149278_f, 0, this.field_149278_f.length); + deflater.finish(); + byte[] deflated = new byte[this.field_149278_f.length]; + this.field_149285_h = deflater.deflate(deflated); + this.field_149281_e = deflated; + } + finally + { + deflater.end(); + } + } + + public static int func_149275_c() + { + return 196864; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149284_a = p_148837_1_.readInt(); + this.field_149282_b = p_148837_1_.readInt(); + this.field_149279_g = p_148837_1_.readBoolean(); + this.field_149283_c = p_148837_1_.readShort(); + this.field_149280_d = p_148837_1_.readShort(); + this.field_149285_h = p_148837_1_.readInt(); + + if (field_149286_i.length < this.field_149285_h) + { + field_149286_i = new byte[this.field_149285_h]; + } + + p_148837_1_.readBytes(field_149286_i, 0, this.field_149285_h); + int i = 0; + int j; + int msb = 0; //BugFix: MC does not read the MSB array from the packet properly, causing issues for servers that use blocks > 256 + + for (j = 0; j < 16; ++j) + { + i += this.field_149283_c >> j & 1; + msb += this.field_149283_c >> j & 1; + } + + j = 12288 * i; + j += 2048 * msb; + + if (this.field_149279_g) + { + j += 256; + } + + this.field_149278_f = new byte[j]; + Inflater inflater = new Inflater(); + inflater.setInput(field_149286_i, 0, this.field_149285_h); + + try + { + inflater.inflate(this.field_149278_f); + } + catch (DataFormatException dataformatexception) + { + throw new IOException("Bad compressed data format"); + } + finally + { + inflater.end(); + } + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + if (this.field_149281_e == null) + { + deflateGate.acquireUninterruptibly(); + if (this.field_149281_e == null) + { + deflate(); + } + deflateGate.release(); + } + p_148840_1_.writeInt(this.field_149284_a); + p_148840_1_.writeInt(this.field_149282_b); + p_148840_1_.writeBoolean(this.field_149279_g); + p_148840_1_.writeShort((short)(this.field_149283_c & 65535)); + p_148840_1_.writeShort((short)(this.field_149280_d & 65535)); + p_148840_1_.writeInt(this.field_149285_h); + p_148840_1_.writeBytes(this.field_149281_e, 0, this.field_149285_h); + } + + public void processPacket(INetHandlerPlayClient p_149277_1_) + { + p_149277_1_.handleChunkData(this); + } + + public String serialize() + { + return String.format("x=%d, z=%d, full=%b, sects=%d, add=%d, size=%d", new Object[] {Integer.valueOf(this.field_149284_a), Integer.valueOf(this.field_149282_b), Boolean.valueOf(this.field_149279_g), Integer.valueOf(this.field_149283_c), Integer.valueOf(this.field_149280_d), Integer.valueOf(this.field_149285_h)}); + } + + @SideOnly(Side.CLIENT) + public byte[] func_149272_d() + { + return this.field_149278_f; + } + + public static S21PacketChunkData.Extracted func_149269_a(Chunk p_149269_0_, boolean p_149269_1_, int p_149269_2_) + { + int j = 0; + ExtendedBlockStorage[] aextendedblockstorage = p_149269_0_.getBlockStorageArray(); + int k = 0; + S21PacketChunkData.Extracted extracted = new S21PacketChunkData.Extracted(); + byte[] abyte = field_149286_i; + + if (p_149269_1_) + { + p_149269_0_.sendUpdates = true; + } + + int l; + + for (l = 0; l < aextendedblockstorage.length; ++l) + { + if (aextendedblockstorage[l] != null && (!p_149269_1_ || !aextendedblockstorage[l].isEmpty()) && (p_149269_2_ & 1 << l) != 0) + { + extracted.field_150280_b |= 1 << l; + + if (aextendedblockstorage[l].getBlockMSBArray() != null) + { + extracted.field_150281_c |= 1 << l; + ++k; + } + } + } + + for (l = 0; l < aextendedblockstorage.length; ++l) + { + if (aextendedblockstorage[l] != null && (!p_149269_1_ || !aextendedblockstorage[l].isEmpty()) && (p_149269_2_ & 1 << l) != 0) + { + byte[] abyte1 = aextendedblockstorage[l].getBlockLSBArray(); + System.arraycopy(abyte1, 0, abyte, j, abyte1.length); + j += abyte1.length; + } + } + + NibbleArray nibblearray; + + for (l = 0; l < aextendedblockstorage.length; ++l) + { + if (aextendedblockstorage[l] != null && (!p_149269_1_ || !aextendedblockstorage[l].isEmpty()) && (p_149269_2_ & 1 << l) != 0) + { + nibblearray = aextendedblockstorage[l].getMetadataArray(); + System.arraycopy(nibblearray.data, 0, abyte, j, nibblearray.data.length); + j += nibblearray.data.length; + } + } + + for (l = 0; l < aextendedblockstorage.length; ++l) + { + if (aextendedblockstorage[l] != null && (!p_149269_1_ || !aextendedblockstorage[l].isEmpty()) && (p_149269_2_ & 1 << l) != 0) + { + nibblearray = aextendedblockstorage[l].getBlocklightArray(); + System.arraycopy(nibblearray.data, 0, abyte, j, nibblearray.data.length); + j += nibblearray.data.length; + } + } + + if (!p_149269_0_.worldObj.provider.hasNoSky) + { + for (l = 0; l < aextendedblockstorage.length; ++l) + { + if (aextendedblockstorage[l] != null && (!p_149269_1_ || !aextendedblockstorage[l].isEmpty()) && (p_149269_2_ & 1 << l) != 0) + { + nibblearray = aextendedblockstorage[l].getSkylightArray(); + System.arraycopy(nibblearray.data, 0, abyte, j, nibblearray.data.length); + j += nibblearray.data.length; + } + } + } + + if (k > 0) + { + for (l = 0; l < aextendedblockstorage.length; ++l) + { + if (aextendedblockstorage[l] != null && (!p_149269_1_ || !aextendedblockstorage[l].isEmpty()) && aextendedblockstorage[l].getBlockMSBArray() != null && (p_149269_2_ & 1 << l) != 0) + { + nibblearray = aextendedblockstorage[l].getBlockMSBArray(); + System.arraycopy(nibblearray.data, 0, abyte, j, nibblearray.data.length); + j += nibblearray.data.length; + } + } + } + + if (p_149269_1_) + { + byte[] abyte2 = p_149269_0_.getBiomeArray(); + System.arraycopy(abyte2, 0, abyte, j, abyte2.length); + j += abyte2.length; + } + + extracted.field_150282_a = new byte[j]; + System.arraycopy(abyte, 0, extracted.field_150282_a, 0, j); + return extracted; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } + + @SideOnly(Side.CLIENT) + public int func_149273_e() + { + return this.field_149284_a; + } + + @SideOnly(Side.CLIENT) + public int func_149271_f() + { + return this.field_149282_b; + } + + @SideOnly(Side.CLIENT) + public int func_149276_g() + { + return this.field_149283_c; + } + + @SideOnly(Side.CLIENT) + public int func_149270_h() + { + return this.field_149280_d; + } + + @SideOnly(Side.CLIENT) + public boolean func_149274_i() + { + return this.field_149279_g; + } + + public static class Extracted + { + public byte[] field_150282_a; + public int field_150280_b; + public int field_150281_c; + private static final String __OBFID = "CL_00001305"; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S22PacketMultiBlockChange.java b/src/main/java/net/minecraft/network/play/server/S22PacketMultiBlockChange.java new file mode 100644 index 0000000..a769063 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S22PacketMultiBlockChange.java @@ -0,0 +1,124 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import net.minecraft.block.Block; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; +import net.minecraft.world.ChunkCoordIntPair; +import net.minecraft.world.chunk.Chunk; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class S22PacketMultiBlockChange extends Packet +{ + private static final Logger logger = LogManager.getLogger(); + private ChunkCoordIntPair field_148925_b; + private byte[] field_148926_c; + private int field_148924_d; + private static final String __OBFID = "CL_00001290"; + + public S22PacketMultiBlockChange() {} + + public S22PacketMultiBlockChange(int p_i45181_1_, short[] p_i45181_2_, Chunk p_i45181_3_) + { + this.field_148925_b = new ChunkCoordIntPair(p_i45181_3_.xPosition, p_i45181_3_.zPosition); + this.field_148924_d = p_i45181_1_; + int j = 4 * p_i45181_1_; + + try + { + ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream(j); + DataOutputStream dataoutputstream = new DataOutputStream(bytearrayoutputstream); + + for (int k = 0; k < p_i45181_1_; ++k) + { + int l = p_i45181_2_[k] >> 12 & 15; + int i1 = p_i45181_2_[k] >> 8 & 15; + int j1 = p_i45181_2_[k] & 255; + dataoutputstream.writeShort(p_i45181_2_[k]); + dataoutputstream.writeShort((short)((Block.getIdFromBlock(p_i45181_3_.getBlock(l, j1, i1)) & 4095) << 4 | p_i45181_3_.getBlockMetadata(l, j1, i1) & 15)); + } + + this.field_148926_c = bytearrayoutputstream.toByteArray(); + + if (this.field_148926_c.length != j) + { + throw new RuntimeException("Expected length " + j + " doesn\'t match received length " + this.field_148926_c.length); + } + } + catch (IOException ioexception) + { + logger.error("Couldn\'t create bulk block update packet", ioexception); + this.field_148926_c = null; + } + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_148925_b = new ChunkCoordIntPair(p_148837_1_.readInt(), p_148837_1_.readInt()); + this.field_148924_d = p_148837_1_.readShort() & 65535; + int i = p_148837_1_.readInt(); + + if (i > 0) + { + this.field_148926_c = new byte[i]; + p_148837_1_.readBytes(this.field_148926_c); + } + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeInt(this.field_148925_b.chunkXPos); + p_148840_1_.writeInt(this.field_148925_b.chunkZPos); + p_148840_1_.writeShort((short)this.field_148924_d); + + if (this.field_148926_c != null) + { + p_148840_1_.writeInt(this.field_148926_c.length); + p_148840_1_.writeBytes(this.field_148926_c); + } + else + { + p_148840_1_.writeInt(0); + } + } + + public void processPacket(INetHandlerPlayClient p_148923_1_) + { + p_148923_1_.handleMultiBlockChange(this); + } + + public String serialize() + { + return String.format("xc=%d, zc=%d, count=%d", new Object[] {Integer.valueOf(this.field_148925_b.chunkXPos), Integer.valueOf(this.field_148925_b.chunkZPos), Integer.valueOf(this.field_148924_d)}); + } + + @SideOnly(Side.CLIENT) + public ChunkCoordIntPair func_148920_c() + { + return this.field_148925_b; + } + + @SideOnly(Side.CLIENT) + public byte[] func_148921_d() + { + return this.field_148926_c; + } + + @SideOnly(Side.CLIENT) + public int func_148922_e() + { + return this.field_148924_d; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S23PacketBlockChange.java b/src/main/java/net/minecraft/network/play/server/S23PacketBlockChange.java new file mode 100644 index 0000000..2c61e60 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S23PacketBlockChange.java @@ -0,0 +1,95 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.block.Block; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; +import net.minecraft.world.World; + +public class S23PacketBlockChange extends Packet +{ + private int field_148887_a; + private int field_148885_b; + private int field_148886_c; + public Block field_148883_d; + public int field_148884_e; + private static final String __OBFID = "CL_00001287"; + + public S23PacketBlockChange() {} + + public S23PacketBlockChange(int p_i45177_1_, int p_i45177_2_, int p_i45177_3_, World p_i45177_4_) + { + this.field_148887_a = p_i45177_1_; + this.field_148885_b = p_i45177_2_; + this.field_148886_c = p_i45177_3_; + this.field_148883_d = p_i45177_4_.getBlock(p_i45177_1_, p_i45177_2_, p_i45177_3_); + this.field_148884_e = p_i45177_4_.getBlockMetadata(p_i45177_1_, p_i45177_2_, p_i45177_3_); + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_148887_a = p_148837_1_.readInt(); + this.field_148885_b = p_148837_1_.readUnsignedByte(); + this.field_148886_c = p_148837_1_.readInt(); + this.field_148883_d = Block.getBlockById(p_148837_1_.readVarIntFromBuffer()); + this.field_148884_e = p_148837_1_.readUnsignedByte(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeInt(this.field_148887_a); + p_148840_1_.writeByte(this.field_148885_b); + p_148840_1_.writeInt(this.field_148886_c); + p_148840_1_.writeVarIntToBuffer(Block.getIdFromBlock(this.field_148883_d)); + p_148840_1_.writeByte(this.field_148884_e); + } + + public void processPacket(INetHandlerPlayClient p_148882_1_) + { + p_148882_1_.handleBlockChange(this); + } + + public String serialize() + { + return String.format("type=%d, data=%d, x=%d, y=%d, z=%d", new Object[] {Integer.valueOf(Block.getIdFromBlock(this.field_148883_d)), Integer.valueOf(this.field_148884_e), Integer.valueOf(this.field_148887_a), Integer.valueOf(this.field_148885_b), Integer.valueOf(this.field_148886_c)}); + } + + @SideOnly(Side.CLIENT) + public Block func_148880_c() + { + return this.field_148883_d; + } + + @SideOnly(Side.CLIENT) + public int func_148879_d() + { + return this.field_148887_a; + } + + @SideOnly(Side.CLIENT) + public int func_148878_e() + { + return this.field_148885_b; + } + + @SideOnly(Side.CLIENT) + public int func_148877_f() + { + return this.field_148886_c; + } + + @SideOnly(Side.CLIENT) + public int func_148881_g() + { + return this.field_148884_e; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S24PacketBlockAction.java b/src/main/java/net/minecraft/network/play/server/S24PacketBlockAction.java new file mode 100644 index 0000000..d95bee3 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S24PacketBlockAction.java @@ -0,0 +1,99 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.block.Block; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; + +public class S24PacketBlockAction extends Packet +{ + private int field_148876_a; + private int field_148874_b; + private int field_148875_c; + private int field_148872_d; + private int field_148873_e; + private Block field_148871_f; + private static final String __OBFID = "CL_00001286"; + + public S24PacketBlockAction() {} + + public S24PacketBlockAction(int p_i45176_1_, int p_i45176_2_, int p_i45176_3_, Block p_i45176_4_, int p_i45176_5_, int p_i45176_6_) + { + this.field_148876_a = p_i45176_1_; + this.field_148874_b = p_i45176_2_; + this.field_148875_c = p_i45176_3_; + this.field_148872_d = p_i45176_5_; + this.field_148873_e = p_i45176_6_; + this.field_148871_f = p_i45176_4_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_148876_a = p_148837_1_.readInt(); + this.field_148874_b = p_148837_1_.readShort(); + this.field_148875_c = p_148837_1_.readInt(); + this.field_148872_d = p_148837_1_.readUnsignedByte(); + this.field_148873_e = p_148837_1_.readUnsignedByte(); + this.field_148871_f = Block.getBlockById(p_148837_1_.readVarIntFromBuffer() & 4095); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeInt(this.field_148876_a); + p_148840_1_.writeShort(this.field_148874_b); + p_148840_1_.writeInt(this.field_148875_c); + p_148840_1_.writeByte(this.field_148872_d); + p_148840_1_.writeByte(this.field_148873_e); + p_148840_1_.writeVarIntToBuffer(Block.getIdFromBlock(this.field_148871_f) & 4095); + } + + public void processPacket(INetHandlerPlayClient p_148870_1_) + { + p_148870_1_.handleBlockAction(this); + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } + + @SideOnly(Side.CLIENT) + public Block func_148868_c() + { + return this.field_148871_f; + } + + @SideOnly(Side.CLIENT) + public int func_148867_d() + { + return this.field_148876_a; + } + + @SideOnly(Side.CLIENT) + public int func_148866_e() + { + return this.field_148874_b; + } + + @SideOnly(Side.CLIENT) + public int func_148865_f() + { + return this.field_148875_c; + } + + @SideOnly(Side.CLIENT) + public int func_148869_g() + { + return this.field_148872_d; + } + + @SideOnly(Side.CLIENT) + public int func_148864_h() + { + return this.field_148873_e; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S25PacketBlockBreakAnim.java b/src/main/java/net/minecraft/network/play/server/S25PacketBlockBreakAnim.java new file mode 100644 index 0000000..dba7141 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S25PacketBlockBreakAnim.java @@ -0,0 +1,88 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; + +public class S25PacketBlockBreakAnim extends Packet +{ + private int field_148852_a; + private int field_148850_b; + private int field_148851_c; + private int field_148848_d; + private int field_148849_e; + private static final String __OBFID = "CL_00001284"; + + public S25PacketBlockBreakAnim() {} + + public S25PacketBlockBreakAnim(int p_i45174_1_, int p_i45174_2_, int p_i45174_3_, int p_i45174_4_, int p_i45174_5_) + { + this.field_148852_a = p_i45174_1_; + this.field_148850_b = p_i45174_2_; + this.field_148851_c = p_i45174_3_; + this.field_148848_d = p_i45174_4_; + this.field_148849_e = p_i45174_5_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_148852_a = p_148837_1_.readVarIntFromBuffer(); + this.field_148850_b = p_148837_1_.readInt(); + this.field_148851_c = p_148837_1_.readInt(); + this.field_148848_d = p_148837_1_.readInt(); + this.field_148849_e = p_148837_1_.readUnsignedByte(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeVarIntToBuffer(this.field_148852_a); + p_148840_1_.writeInt(this.field_148850_b); + p_148840_1_.writeInt(this.field_148851_c); + p_148840_1_.writeInt(this.field_148848_d); + p_148840_1_.writeByte(this.field_148849_e); + } + + public void processPacket(INetHandlerPlayClient p_148847_1_) + { + p_148847_1_.handleBlockBreakAnim(this); + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } + + @SideOnly(Side.CLIENT) + public int func_148845_c() + { + return this.field_148852_a; + } + + @SideOnly(Side.CLIENT) + public int func_148844_d() + { + return this.field_148850_b; + } + + @SideOnly(Side.CLIENT) + public int func_148843_e() + { + return this.field_148851_c; + } + + @SideOnly(Side.CLIENT) + public int func_148842_f() + { + return this.field_148848_d; + } + + @SideOnly(Side.CLIENT) + public int func_148846_g() + { + return this.field_148849_e; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S26PacketMapChunkBulk.java b/src/main/java/net/minecraft/network/play/server/S26PacketMapChunkBulk.java new file mode 100644 index 0000000..90e5a6d --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S26PacketMapChunkBulk.java @@ -0,0 +1,244 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.Semaphore; +import java.util.zip.DataFormatException; +import java.util.zip.Deflater; +import java.util.zip.Inflater; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; +import net.minecraft.world.chunk.Chunk; + +public class S26PacketMapChunkBulk extends Packet +{ + private int[] field_149266_a; + private int[] field_149264_b; + private int[] field_149265_c; + private int[] field_149262_d; + private byte[] field_149263_e; + private byte[][] field_149260_f; + private int field_149261_g; + private boolean field_149267_h; + private static byte[] field_149268_i = new byte[0]; + private static final String __OBFID = "CL_00001306"; + private int maxLen = 0; + private Semaphore deflateGate; + + public S26PacketMapChunkBulk() {} + + public S26PacketMapChunkBulk(List p_i45197_1_) + { + int i = p_i45197_1_.size(); + this.field_149266_a = new int[i]; + this.field_149264_b = new int[i]; + this.field_149265_c = new int[i]; + this.field_149262_d = new int[i]; + this.field_149260_f = new byte[i][]; + this.field_149267_h = !p_i45197_1_.isEmpty() && !((Chunk)p_i45197_1_.get(0)).worldObj.provider.hasNoSky; + int j = 0; + + for (int k = 0; k < i; ++k) + { + Chunk chunk = (Chunk)p_i45197_1_.get(k); + S21PacketChunkData.Extracted extracted = S21PacketChunkData.func_149269_a(chunk, true, 65535); + j += extracted.field_150282_a.length; + this.field_149266_a[k] = chunk.xPosition; + this.field_149264_b[k] = chunk.zPosition; + this.field_149265_c[k] = extracted.field_150280_b; + this.field_149262_d[k] = extracted.field_150281_c; + this.field_149260_f[k] = extracted.field_150282_a; + } + this.deflateGate = new Semaphore(1); + maxLen = j; + } + + private void deflate() + { + byte[] data = new byte[maxLen]; + int offset = 0; + for (int x = 0; x < field_149260_f.length; x++) + { + System.arraycopy(field_149260_f[x], 0, data, offset, field_149260_f[x].length); + offset += field_149260_f[x].length; + } + Deflater deflater = new Deflater(-1); + + try + { + deflater.setInput(data, 0, data.length); + deflater.finish(); + byte[] deflated = new byte[data.length]; + this.field_149261_g = deflater.deflate(deflated); + this.field_149263_e = deflated; + } + finally + { + deflater.end(); + } + } + + public static int func_149258_c() + { + return 5; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + short short1 = p_148837_1_.readShort(); + this.field_149261_g = p_148837_1_.readInt(); + this.field_149267_h = p_148837_1_.readBoolean(); + this.field_149266_a = new int[short1]; + this.field_149264_b = new int[short1]; + this.field_149265_c = new int[short1]; + this.field_149262_d = new int[short1]; + this.field_149260_f = new byte[short1][]; + + if (field_149268_i.length < this.field_149261_g) + { + field_149268_i = new byte[this.field_149261_g]; + } + + p_148837_1_.readBytes(field_149268_i, 0, this.field_149261_g); + byte[] abyte = new byte[S21PacketChunkData.func_149275_c() * short1]; + Inflater inflater = new Inflater(); + inflater.setInput(field_149268_i, 0, this.field_149261_g); + + try + { + inflater.inflate(abyte); + } + catch (DataFormatException dataformatexception) + { + throw new IOException("Bad compressed data format"); + } + finally + { + inflater.end(); + } + + int i = 0; + + for (int j = 0; j < short1; ++j) + { + this.field_149266_a[j] = p_148837_1_.readInt(); + this.field_149264_b[j] = p_148837_1_.readInt(); + this.field_149265_c[j] = p_148837_1_.readShort(); + this.field_149262_d[j] = p_148837_1_.readShort(); + int k = 0; + int l = 0; + int i1; + + for (i1 = 0; i1 < 16; ++i1) + { + k += this.field_149265_c[j] >> i1 & 1; + l += this.field_149262_d[j] >> i1 & 1; + } + + i1 = 2048 * 4 * k + 256; + i1 += 2048 * l; + + if (this.field_149267_h) + { + i1 += 2048 * k; + } + + this.field_149260_f[j] = new byte[i1]; + System.arraycopy(abyte, i, this.field_149260_f[j], 0, i1); + i += i1; + } + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + if (this.field_149263_e == null) + { + deflateGate.acquireUninterruptibly(); + if (this.field_149263_e == null) + { + deflate(); + } + deflateGate.release(); + } + + p_148840_1_.writeShort(this.field_149266_a.length); + p_148840_1_.writeInt(this.field_149261_g); + p_148840_1_.writeBoolean(this.field_149267_h); + p_148840_1_.writeBytes(this.field_149263_e, 0, this.field_149261_g); + + for (int i = 0; i < this.field_149266_a.length; ++i) + { + p_148840_1_.writeInt(this.field_149266_a[i]); + p_148840_1_.writeInt(this.field_149264_b[i]); + p_148840_1_.writeShort((short)(this.field_149265_c[i] & 65535)); + p_148840_1_.writeShort((short)(this.field_149262_d[i] & 65535)); + } + } + + public void processPacket(INetHandlerPlayClient p_149259_1_) + { + p_149259_1_.handleMapChunkBulk(this); + } + + @SideOnly(Side.CLIENT) + public int func_149255_a(int p_149255_1_) + { + return this.field_149266_a[p_149255_1_]; + } + + @SideOnly(Side.CLIENT) + public int func_149253_b(int p_149253_1_) + { + return this.field_149264_b[p_149253_1_]; + } + + public String serialize() + { + StringBuilder stringbuilder = new StringBuilder(); + + for (int i = 0; i < this.field_149266_a.length; ++i) + { + if (i > 0) + { + stringbuilder.append(", "); + } + + stringbuilder.append(String.format("{x=%d, z=%d, sections=%d, adds=%d, data=%d}", new Object[] {Integer.valueOf(this.field_149266_a[i]), Integer.valueOf(this.field_149264_b[i]), Integer.valueOf(this.field_149265_c[i]), Integer.valueOf(this.field_149262_d[i]), Integer.valueOf(this.field_149260_f[i].length)})); + } + + return String.format("size=%d, chunks=%d[%s]", new Object[] {Integer.valueOf(this.field_149261_g), Integer.valueOf(this.field_149266_a.length), stringbuilder}); + } + + @SideOnly(Side.CLIENT) + public int func_149254_d() + { + return this.field_149266_a.length; + } + + @SideOnly(Side.CLIENT) + public byte[] func_149256_c(int p_149256_1_) + { + return this.field_149260_f[p_149256_1_]; + } + + @SideOnly(Side.CLIENT) + public int[] func_149252_e() + { + return this.field_149265_c; + } + + @SideOnly(Side.CLIENT) + public int[] func_149257_f() + { + return this.field_149262_d; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S27PacketExplosion.java b/src/main/java/net/minecraft/network/play/server/S27PacketExplosion.java new file mode 100644 index 0000000..d4ae0b9 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S27PacketExplosion.java @@ -0,0 +1,156 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; +import net.minecraft.util.Vec3; +import net.minecraft.world.ChunkPosition; + +public class S27PacketExplosion extends Packet +{ + private double field_149158_a; + private double field_149156_b; + private double field_149157_c; + private float field_149154_d; + private List field_149155_e; + private float field_149152_f; + private float field_149153_g; + private float field_149159_h; + private static final String __OBFID = "CL_00001300"; + + public S27PacketExplosion() {} + + public S27PacketExplosion(double p_i45193_1_, double p_i45193_3_, double p_i45193_5_, float p_i45193_7_, List p_i45193_8_, Vec3 p_i45193_9_) + { + this.field_149158_a = p_i45193_1_; + this.field_149156_b = p_i45193_3_; + this.field_149157_c = p_i45193_5_; + this.field_149154_d = p_i45193_7_; + this.field_149155_e = new ArrayList(p_i45193_8_); + + if (p_i45193_9_ != null) + { + this.field_149152_f = (float)p_i45193_9_.xCoord; + this.field_149153_g = (float)p_i45193_9_.yCoord; + this.field_149159_h = (float)p_i45193_9_.zCoord; + } + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149158_a = (double)p_148837_1_.readFloat(); + this.field_149156_b = (double)p_148837_1_.readFloat(); + this.field_149157_c = (double)p_148837_1_.readFloat(); + this.field_149154_d = p_148837_1_.readFloat(); + int i = p_148837_1_.readInt(); + this.field_149155_e = new ArrayList(i); + int j = (int)this.field_149158_a; + int k = (int)this.field_149156_b; + int l = (int)this.field_149157_c; + + for (int i1 = 0; i1 < i; ++i1) + { + int j1 = p_148837_1_.readByte() + j; + int k1 = p_148837_1_.readByte() + k; + int l1 = p_148837_1_.readByte() + l; + this.field_149155_e.add(new ChunkPosition(j1, k1, l1)); + } + + this.field_149152_f = p_148837_1_.readFloat(); + this.field_149153_g = p_148837_1_.readFloat(); + this.field_149159_h = p_148837_1_.readFloat(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeFloat((float)this.field_149158_a); + p_148840_1_.writeFloat((float)this.field_149156_b); + p_148840_1_.writeFloat((float)this.field_149157_c); + p_148840_1_.writeFloat(this.field_149154_d); + p_148840_1_.writeInt(this.field_149155_e.size()); + int i = (int)this.field_149158_a; + int j = (int)this.field_149156_b; + int k = (int)this.field_149157_c; + Iterator iterator = this.field_149155_e.iterator(); + + while (iterator.hasNext()) + { + ChunkPosition chunkposition = (ChunkPosition)iterator.next(); + int l = chunkposition.chunkPosX - i; + int i1 = chunkposition.chunkPosY - j; + int j1 = chunkposition.chunkPosZ - k; + p_148840_1_.writeByte(l); + p_148840_1_.writeByte(i1); + p_148840_1_.writeByte(j1); + } + + p_148840_1_.writeFloat(this.field_149152_f); + p_148840_1_.writeFloat(this.field_149153_g); + p_148840_1_.writeFloat(this.field_149159_h); + } + + public void processPacket(INetHandlerPlayClient p_149151_1_) + { + p_149151_1_.handleExplosion(this); + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } + + @SideOnly(Side.CLIENT) + public float func_149149_c() + { + return this.field_149152_f; + } + + @SideOnly(Side.CLIENT) + public float func_149144_d() + { + return this.field_149153_g; + } + + @SideOnly(Side.CLIENT) + public float func_149147_e() + { + return this.field_149159_h; + } + + @SideOnly(Side.CLIENT) + public double func_149148_f() + { + return this.field_149158_a; + } + + @SideOnly(Side.CLIENT) + public double func_149143_g() + { + return this.field_149156_b; + } + + @SideOnly(Side.CLIENT) + public double func_149145_h() + { + return this.field_149157_c; + } + + @SideOnly(Side.CLIENT) + public float func_149146_i() + { + return this.field_149154_d; + } + + @SideOnly(Side.CLIENT) + public List func_149150_j() + { + return this.field_149155_e; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S28PacketEffect.java b/src/main/java/net/minecraft/network/play/server/S28PacketEffect.java new file mode 100644 index 0000000..65c9909 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S28PacketEffect.java @@ -0,0 +1,98 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; + +public class S28PacketEffect extends Packet +{ + private int field_149251_a; + private int field_149249_b; + private int field_149250_c; + private int field_149247_d; + private int field_149248_e; + private boolean field_149246_f; + private static final String __OBFID = "CL_00001307"; + + public S28PacketEffect() {} + + public S28PacketEffect(int p_i45198_1_, int p_i45198_2_, int p_i45198_3_, int p_i45198_4_, int p_i45198_5_, boolean p_i45198_6_) + { + this.field_149251_a = p_i45198_1_; + this.field_149250_c = p_i45198_2_; + this.field_149247_d = p_i45198_3_; + this.field_149248_e = p_i45198_4_; + this.field_149249_b = p_i45198_5_; + this.field_149246_f = p_i45198_6_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149251_a = p_148837_1_.readInt(); + this.field_149250_c = p_148837_1_.readInt(); + this.field_149247_d = p_148837_1_.readByte() & 255; + this.field_149248_e = p_148837_1_.readInt(); + this.field_149249_b = p_148837_1_.readInt(); + this.field_149246_f = p_148837_1_.readBoolean(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeInt(this.field_149251_a); + p_148840_1_.writeInt(this.field_149250_c); + p_148840_1_.writeByte(this.field_149247_d & 255); + p_148840_1_.writeInt(this.field_149248_e); + p_148840_1_.writeInt(this.field_149249_b); + p_148840_1_.writeBoolean(this.field_149246_f); + } + + public void processPacket(INetHandlerPlayClient p_149245_1_) + { + p_149245_1_.handleEffect(this); + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } + + @SideOnly(Side.CLIENT) + public boolean func_149244_c() + { + return this.field_149246_f; + } + + @SideOnly(Side.CLIENT) + public int func_149242_d() + { + return this.field_149251_a; + } + + @SideOnly(Side.CLIENT) + public int func_149241_e() + { + return this.field_149249_b; + } + + @SideOnly(Side.CLIENT) + public int func_149240_f() + { + return this.field_149250_c; + } + + @SideOnly(Side.CLIENT) + public int func_149243_g() + { + return this.field_149247_d; + } + + @SideOnly(Side.CLIENT) + public int func_149239_h() + { + return this.field_149248_e; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S29PacketSoundEffect.java b/src/main/java/net/minecraft/network/play/server/S29PacketSoundEffect.java new file mode 100644 index 0000000..ffe67bb --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S29PacketSoundEffect.java @@ -0,0 +1,110 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; +import org.apache.commons.lang3.Validate; + +public class S29PacketSoundEffect extends Packet +{ + private String field_149219_a; + private int field_149217_b; + private int field_149218_c = Integer.MAX_VALUE; + private int field_149215_d; + private float field_149216_e; + private int field_149214_f; + private static final String __OBFID = "CL_00001309"; + + public S29PacketSoundEffect() {} + + public S29PacketSoundEffect(String p_i45200_1_, double p_i45200_2_, double p_i45200_4_, double p_i45200_6_, float p_i45200_8_, float p_i45200_9_) + { + Validate.notNull(p_i45200_1_, "name", new Object[0]); + this.field_149219_a = p_i45200_1_; + this.field_149217_b = (int)(p_i45200_2_ * 8.0D); + this.field_149218_c = (int)(p_i45200_4_ * 8.0D); + this.field_149215_d = (int)(p_i45200_6_ * 8.0D); + this.field_149216_e = p_i45200_8_; + this.field_149214_f = (int)(p_i45200_9_ * 63.0F); + + if (this.field_149214_f < 0) + { + this.field_149214_f = 0; + } + + if (this.field_149214_f > 255) + { + this.field_149214_f = 255; + } + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149219_a = p_148837_1_.readStringFromBuffer(256); + this.field_149217_b = p_148837_1_.readInt(); + this.field_149218_c = p_148837_1_.readInt(); + this.field_149215_d = p_148837_1_.readInt(); + this.field_149216_e = p_148837_1_.readFloat(); + this.field_149214_f = p_148837_1_.readUnsignedByte(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeStringToBuffer(this.field_149219_a); + p_148840_1_.writeInt(this.field_149217_b); + p_148840_1_.writeInt(this.field_149218_c); + p_148840_1_.writeInt(this.field_149215_d); + p_148840_1_.writeFloat(this.field_149216_e); + p_148840_1_.writeByte(this.field_149214_f); + } + + @SideOnly(Side.CLIENT) + public String func_149212_c() + { + return this.field_149219_a; + } + + @SideOnly(Side.CLIENT) + public double func_149207_d() + { + return (double)((float)this.field_149217_b / 8.0F); + } + + @SideOnly(Side.CLIENT) + public double func_149211_e() + { + return (double)((float)this.field_149218_c / 8.0F); + } + + @SideOnly(Side.CLIENT) + public double func_149210_f() + { + return (double)((float)this.field_149215_d / 8.0F); + } + + @SideOnly(Side.CLIENT) + public float func_149208_g() + { + return this.field_149216_e; + } + + @SideOnly(Side.CLIENT) + public float func_149209_h() + { + return (float)this.field_149214_f / 63.0F; + } + + public void processPacket(INetHandlerPlayClient p_149213_1_) + { + p_149213_1_.handleSoundEffect(this); + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S2APacketParticles.java b/src/main/java/net/minecraft/network/play/server/S2APacketParticles.java new file mode 100644 index 0000000..39f6dae --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S2APacketParticles.java @@ -0,0 +1,128 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; + +public class S2APacketParticles extends Packet +{ + private String field_149236_a; + private float field_149234_b; + private float field_149235_c; + private float field_149232_d; + private float field_149233_e; + private float field_149230_f; + private float field_149231_g; + private float field_149237_h; + private int field_149238_i; + private static final String __OBFID = "CL_00001308"; + + public S2APacketParticles() {} + + public S2APacketParticles(String p_i45199_1_, float p_i45199_2_, float p_i45199_3_, float p_i45199_4_, float p_i45199_5_, float p_i45199_6_, float p_i45199_7_, float p_i45199_8_, int p_i45199_9_) + { + this.field_149236_a = p_i45199_1_; + this.field_149234_b = p_i45199_2_; + this.field_149235_c = p_i45199_3_; + this.field_149232_d = p_i45199_4_; + this.field_149233_e = p_i45199_5_; + this.field_149230_f = p_i45199_6_; + this.field_149231_g = p_i45199_7_; + this.field_149237_h = p_i45199_8_; + this.field_149238_i = p_i45199_9_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149236_a = p_148837_1_.readStringFromBuffer(64); + this.field_149234_b = p_148837_1_.readFloat(); + this.field_149235_c = p_148837_1_.readFloat(); + this.field_149232_d = p_148837_1_.readFloat(); + this.field_149233_e = p_148837_1_.readFloat(); + this.field_149230_f = p_148837_1_.readFloat(); + this.field_149231_g = p_148837_1_.readFloat(); + this.field_149237_h = p_148837_1_.readFloat(); + this.field_149238_i = p_148837_1_.readInt(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeStringToBuffer(this.field_149236_a); + p_148840_1_.writeFloat(this.field_149234_b); + p_148840_1_.writeFloat(this.field_149235_c); + p_148840_1_.writeFloat(this.field_149232_d); + p_148840_1_.writeFloat(this.field_149233_e); + p_148840_1_.writeFloat(this.field_149230_f); + p_148840_1_.writeFloat(this.field_149231_g); + p_148840_1_.writeFloat(this.field_149237_h); + p_148840_1_.writeInt(this.field_149238_i); + } + + @SideOnly(Side.CLIENT) + public String func_149228_c() + { + return this.field_149236_a; + } + + @SideOnly(Side.CLIENT) + public double func_149220_d() + { + return (double)this.field_149234_b; + } + + @SideOnly(Side.CLIENT) + public double func_149226_e() + { + return (double)this.field_149235_c; + } + + @SideOnly(Side.CLIENT) + public double func_149225_f() + { + return (double)this.field_149232_d; + } + + @SideOnly(Side.CLIENT) + public float func_149221_g() + { + return this.field_149233_e; + } + + @SideOnly(Side.CLIENT) + public float func_149224_h() + { + return this.field_149230_f; + } + + @SideOnly(Side.CLIENT) + public float func_149223_i() + { + return this.field_149231_g; + } + + @SideOnly(Side.CLIENT) + public float func_149227_j() + { + return this.field_149237_h; + } + + @SideOnly(Side.CLIENT) + public int func_149222_k() + { + return this.field_149238_i; + } + + public void processPacket(INetHandlerPlayClient p_149229_1_) + { + p_149229_1_.handleParticles(this); + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S2BPacketChangeGameState.java b/src/main/java/net/minecraft/network/play/server/S2BPacketChangeGameState.java new file mode 100644 index 0000000..b56879f --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S2BPacketChangeGameState.java @@ -0,0 +1,59 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; + +public class S2BPacketChangeGameState extends Packet +{ + public static final String[] field_149142_a = new String[] {"tile.bed.notValid", null, null, "gameMode.changed"}; + private int field_149140_b; + private float field_149141_c; + private static final String __OBFID = "CL_00001301"; + + public S2BPacketChangeGameState() {} + + public S2BPacketChangeGameState(int p_i45194_1_, float p_i45194_2_) + { + this.field_149140_b = p_i45194_1_; + this.field_149141_c = p_i45194_2_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149140_b = p_148837_1_.readUnsignedByte(); + this.field_149141_c = p_148837_1_.readFloat(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeByte(this.field_149140_b); + p_148840_1_.writeFloat(this.field_149141_c); + } + + public void processPacket(INetHandlerPlayClient p_149139_1_) + { + p_149139_1_.handleChangeGameState(this); + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } + + @SideOnly(Side.CLIENT) + public int func_149138_c() + { + return this.field_149140_b; + } + + @SideOnly(Side.CLIENT) + public float func_149137_d() + { + return this.field_149141_c; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S2CPacketSpawnGlobalEntity.java b/src/main/java/net/minecraft/network/play/server/S2CPacketSpawnGlobalEntity.java new file mode 100644 index 0000000..8d251b6 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S2CPacketSpawnGlobalEntity.java @@ -0,0 +1,100 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.entity.Entity; +import net.minecraft.entity.effect.EntityLightningBolt; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; +import net.minecraft.util.MathHelper; + +public class S2CPacketSpawnGlobalEntity extends Packet +{ + private int field_149059_a; + private int field_149057_b; + private int field_149058_c; + private int field_149055_d; + private int field_149056_e; + private static final String __OBFID = "CL_00001278"; + + public S2CPacketSpawnGlobalEntity() {} + + public S2CPacketSpawnGlobalEntity(Entity p_i45191_1_) + { + this.field_149059_a = p_i45191_1_.getEntityId(); + this.field_149057_b = MathHelper.floor_double(p_i45191_1_.posX * 32.0D); + this.field_149058_c = MathHelper.floor_double(p_i45191_1_.posY * 32.0D); + this.field_149055_d = MathHelper.floor_double(p_i45191_1_.posZ * 32.0D); + + if (p_i45191_1_ instanceof EntityLightningBolt) + { + this.field_149056_e = 1; + } + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149059_a = p_148837_1_.readVarIntFromBuffer(); + this.field_149056_e = p_148837_1_.readByte(); + this.field_149057_b = p_148837_1_.readInt(); + this.field_149058_c = p_148837_1_.readInt(); + this.field_149055_d = p_148837_1_.readInt(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeVarIntToBuffer(this.field_149059_a); + p_148840_1_.writeByte(this.field_149056_e); + p_148840_1_.writeInt(this.field_149057_b); + p_148840_1_.writeInt(this.field_149058_c); + p_148840_1_.writeInt(this.field_149055_d); + } + + public void processPacket(INetHandlerPlayClient p_149054_1_) + { + p_149054_1_.handleSpawnGlobalEntity(this); + } + + public String serialize() + { + return String.format("id=%d, type=%d, x=%.2f, y=%.2f, z=%.2f", new Object[] {Integer.valueOf(this.field_149059_a), Integer.valueOf(this.field_149056_e), Float.valueOf((float)this.field_149057_b / 32.0F), Float.valueOf((float)this.field_149058_c / 32.0F), Float.valueOf((float)this.field_149055_d / 32.0F)}); + } + + @SideOnly(Side.CLIENT) + public int func_149052_c() + { + return this.field_149059_a; + } + + @SideOnly(Side.CLIENT) + public int func_149051_d() + { + return this.field_149057_b; + } + + @SideOnly(Side.CLIENT) + public int func_149050_e() + { + return this.field_149058_c; + } + + @SideOnly(Side.CLIENT) + public int func_149049_f() + { + return this.field_149055_d; + } + + @SideOnly(Side.CLIENT) + public int func_149053_g() + { + return this.field_149056_e; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S2DPacketOpenWindow.java b/src/main/java/net/minecraft/network/play/server/S2DPacketOpenWindow.java new file mode 100644 index 0000000..25815d1 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S2DPacketOpenWindow.java @@ -0,0 +1,111 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; + +public class S2DPacketOpenWindow extends Packet +{ + private int field_148909_a; + private int field_148907_b; + private String field_148908_c; + private int field_148905_d; + private boolean field_148906_e; + private int field_148904_f; + private static final String __OBFID = "CL_00001293"; + + public S2DPacketOpenWindow() {} + + public S2DPacketOpenWindow(int p_i45184_1_, int p_i45184_2_, String p_i45184_3_, int p_i45184_4_, boolean p_i45184_5_) + { + this.field_148909_a = p_i45184_1_; + this.field_148907_b = p_i45184_2_; + this.field_148908_c = p_i45184_3_; + this.field_148905_d = p_i45184_4_; + this.field_148906_e = p_i45184_5_; + } + + public S2DPacketOpenWindow(int p_i45185_1_, int p_i45185_2_, String p_i45185_3_, int p_i45185_4_, boolean p_i45185_5_, int p_i45185_6_) + { + this(p_i45185_1_, p_i45185_2_, p_i45185_3_, p_i45185_4_, p_i45185_5_); + this.field_148904_f = p_i45185_6_; + } + + public void processPacket(INetHandlerPlayClient p_148903_1_) + { + p_148903_1_.handleOpenWindow(this); + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_148909_a = p_148837_1_.readUnsignedByte(); + this.field_148907_b = p_148837_1_.readUnsignedByte(); + this.field_148908_c = p_148837_1_.readStringFromBuffer(32); + this.field_148905_d = p_148837_1_.readUnsignedByte(); + this.field_148906_e = p_148837_1_.readBoolean(); + + if (this.field_148907_b == 11) + { + this.field_148904_f = p_148837_1_.readInt(); + } + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeByte(this.field_148909_a); + p_148840_1_.writeByte(this.field_148907_b); + p_148840_1_.writeStringToBuffer(this.field_148908_c); + p_148840_1_.writeByte(this.field_148905_d); + p_148840_1_.writeBoolean(this.field_148906_e); + + if (this.field_148907_b == 11) + { + p_148840_1_.writeInt(this.field_148904_f); + } + } + + @SideOnly(Side.CLIENT) + public int func_148901_c() + { + return this.field_148909_a; + } + + @SideOnly(Side.CLIENT) + public int func_148899_d() + { + return this.field_148907_b; + } + + @SideOnly(Side.CLIENT) + public String func_148902_e() + { + return this.field_148908_c; + } + + @SideOnly(Side.CLIENT) + public int func_148898_f() + { + return this.field_148905_d; + } + + @SideOnly(Side.CLIENT) + public boolean func_148900_g() + { + return this.field_148906_e; + } + + @SideOnly(Side.CLIENT) + public int func_148897_h() + { + return this.field_148904_f; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S2EPacketCloseWindow.java b/src/main/java/net/minecraft/network/play/server/S2EPacketCloseWindow.java new file mode 100644 index 0000000..84241b7 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S2EPacketCloseWindow.java @@ -0,0 +1,40 @@ +package net.minecraft.network.play.server; + +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; + +public class S2EPacketCloseWindow extends Packet +{ + private int field_148896_a; + private static final String __OBFID = "CL_00001292"; + + public S2EPacketCloseWindow() {} + + public S2EPacketCloseWindow(int p_i45183_1_) + { + this.field_148896_a = p_i45183_1_; + } + + public void processPacket(INetHandlerPlayClient p_148895_1_) + { + p_148895_1_.handleCloseWindow(this); + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_148896_a = p_148837_1_.readUnsignedByte(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeByte(this.field_148896_a); + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S2FPacketSetSlot.java b/src/main/java/net/minecraft/network/play/server/S2FPacketSetSlot.java new file mode 100644 index 0000000..8b98577 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S2FPacketSetSlot.java @@ -0,0 +1,69 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.item.ItemStack; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; + +public class S2FPacketSetSlot extends Packet +{ + private int field_149179_a; + private int field_149177_b; + private ItemStack field_149178_c; + private static final String __OBFID = "CL_00001296"; + + public S2FPacketSetSlot() {} + + public S2FPacketSetSlot(int p_i45188_1_, int p_i45188_2_, ItemStack p_i45188_3_) + { + this.field_149179_a = p_i45188_1_; + this.field_149177_b = p_i45188_2_; + this.field_149178_c = p_i45188_3_ == null ? null : p_i45188_3_.copy(); + } + + public void processPacket(INetHandlerPlayClient p_149176_1_) + { + p_149176_1_.handleSetSlot(this); + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149179_a = p_148837_1_.readUnsignedByte(); + this.field_149177_b = p_148837_1_.readShort(); + this.field_149178_c = p_148837_1_.readItemStackFromBuffer(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeByte(this.field_149179_a); + p_148840_1_.writeShort(this.field_149177_b); + p_148840_1_.writeItemStackToBuffer(this.field_149178_c); + } + + @SideOnly(Side.CLIENT) + public int func_149175_c() + { + return this.field_149179_a; + } + + @SideOnly(Side.CLIENT) + public int func_149173_d() + { + return this.field_149177_b; + } + + @SideOnly(Side.CLIENT) + public ItemStack func_149174_e() + { + return this.field_149178_c; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S30PacketWindowItems.java b/src/main/java/net/minecraft/network/play/server/S30PacketWindowItems.java new file mode 100644 index 0000000..3d7b4cc --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S30PacketWindowItems.java @@ -0,0 +1,80 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import java.util.List; +import net.minecraft.item.ItemStack; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; + +public class S30PacketWindowItems extends Packet +{ + private int field_148914_a; + private ItemStack[] field_148913_b; + private static final String __OBFID = "CL_00001294"; + + public S30PacketWindowItems() {} + + public S30PacketWindowItems(int p_i45186_1_, List p_i45186_2_) + { + this.field_148914_a = p_i45186_1_; + this.field_148913_b = new ItemStack[p_i45186_2_.size()]; + + for (int j = 0; j < this.field_148913_b.length; ++j) + { + ItemStack itemstack = (ItemStack)p_i45186_2_.get(j); + this.field_148913_b[j] = itemstack == null ? null : itemstack.copy(); + } + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_148914_a = p_148837_1_.readUnsignedByte(); + short short1 = p_148837_1_.readShort(); + this.field_148913_b = new ItemStack[short1]; + + for (int i = 0; i < short1; ++i) + { + this.field_148913_b[i] = p_148837_1_.readItemStackFromBuffer(); + } + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeByte(this.field_148914_a); + p_148840_1_.writeShort(this.field_148913_b.length); + ItemStack[] aitemstack = this.field_148913_b; + int i = aitemstack.length; + + for (int j = 0; j < i; ++j) + { + ItemStack itemstack = aitemstack[j]; + p_148840_1_.writeItemStackToBuffer(itemstack); + } + } + + public void processPacket(INetHandlerPlayClient p_148912_1_) + { + p_148912_1_.handleWindowItems(this); + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } + + @SideOnly(Side.CLIENT) + public int func_148911_c() + { + return this.field_148914_a; + } + + @SideOnly(Side.CLIENT) + public ItemStack[] func_148910_d() + { + return this.field_148913_b; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S31PacketWindowProperty.java b/src/main/java/net/minecraft/network/play/server/S31PacketWindowProperty.java new file mode 100644 index 0000000..3be2faa --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S31PacketWindowProperty.java @@ -0,0 +1,68 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; + +public class S31PacketWindowProperty extends Packet +{ + private int field_149186_a; + private int field_149184_b; + private int field_149185_c; + private static final String __OBFID = "CL_00001295"; + + public S31PacketWindowProperty() {} + + public S31PacketWindowProperty(int p_i45187_1_, int p_i45187_2_, int p_i45187_3_) + { + this.field_149186_a = p_i45187_1_; + this.field_149184_b = p_i45187_2_; + this.field_149185_c = p_i45187_3_; + } + + public void processPacket(INetHandlerPlayClient p_149183_1_) + { + p_149183_1_.handleWindowProperty(this); + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149186_a = p_148837_1_.readUnsignedByte(); + this.field_149184_b = p_148837_1_.readShort(); + this.field_149185_c = p_148837_1_.readShort(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeByte(this.field_149186_a); + p_148840_1_.writeShort(this.field_149184_b); + p_148840_1_.writeShort(this.field_149185_c); + } + + @SideOnly(Side.CLIENT) + public int func_149182_c() + { + return this.field_149186_a; + } + + @SideOnly(Side.CLIENT) + public int func_149181_d() + { + return this.field_149184_b; + } + + @SideOnly(Side.CLIENT) + public int func_149180_e() + { + return this.field_149185_c; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S32PacketConfirmTransaction.java b/src/main/java/net/minecraft/network/play/server/S32PacketConfirmTransaction.java new file mode 100644 index 0000000..1732a34 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S32PacketConfirmTransaction.java @@ -0,0 +1,73 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; + +public class S32PacketConfirmTransaction extends Packet +{ + private int field_148894_a; + private short field_148892_b; + private boolean field_148893_c; + private static final String __OBFID = "CL_00001291"; + + public S32PacketConfirmTransaction() {} + + public S32PacketConfirmTransaction(int p_i45182_1_, short p_i45182_2_, boolean p_i45182_3_) + { + this.field_148894_a = p_i45182_1_; + this.field_148892_b = p_i45182_2_; + this.field_148893_c = p_i45182_3_; + } + + public void processPacket(INetHandlerPlayClient p_148891_1_) + { + p_148891_1_.handleConfirmTransaction(this); + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_148894_a = p_148837_1_.readUnsignedByte(); + this.field_148892_b = p_148837_1_.readShort(); + this.field_148893_c = p_148837_1_.readBoolean(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeByte(this.field_148894_a); + p_148840_1_.writeShort(this.field_148892_b); + p_148840_1_.writeBoolean(this.field_148893_c); + } + + public String serialize() + { + return String.format("id=%d, uid=%d, accepted=%b", new Object[] {Integer.valueOf(this.field_148894_a), Short.valueOf(this.field_148892_b), Boolean.valueOf(this.field_148893_c)}); + } + + @SideOnly(Side.CLIENT) + public int func_148889_c() + { + return this.field_148894_a; + } + + @SideOnly(Side.CLIENT) + public short func_148890_d() + { + return this.field_148892_b; + } + + @SideOnly(Side.CLIENT) + public boolean func_148888_e() + { + return this.field_148893_c; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S33PacketUpdateSign.java b/src/main/java/net/minecraft/network/play/server/S33PacketUpdateSign.java new file mode 100644 index 0000000..eac4fde --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S33PacketUpdateSign.java @@ -0,0 +1,87 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; + +public class S33PacketUpdateSign extends Packet +{ + private int field_149352_a; + private int field_149350_b; + private int field_149351_c; + private String[] field_149349_d; + private static final String __OBFID = "CL_00001338"; + + public S33PacketUpdateSign() {} + + public S33PacketUpdateSign(int p_i45231_1_, int p_i45231_2_, int p_i45231_3_, String[] p_i45231_4_) + { + this.field_149352_a = p_i45231_1_; + this.field_149350_b = p_i45231_2_; + this.field_149351_c = p_i45231_3_; + this.field_149349_d = new String[] {p_i45231_4_[0], p_i45231_4_[1], p_i45231_4_[2], p_i45231_4_[3]}; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149352_a = p_148837_1_.readInt(); + this.field_149350_b = p_148837_1_.readShort(); + this.field_149351_c = p_148837_1_.readInt(); + this.field_149349_d = new String[4]; + + for (int i = 0; i < 4; ++i) + { + this.field_149349_d[i] = p_148837_1_.readStringFromBuffer(15); + } + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeInt(this.field_149352_a); + p_148840_1_.writeShort(this.field_149350_b); + p_148840_1_.writeInt(this.field_149351_c); + + for (int i = 0; i < 4; ++i) + { + p_148840_1_.writeStringToBuffer(this.field_149349_d[i]); + } + } + + public void processPacket(INetHandlerPlayClient p_149348_1_) + { + p_149348_1_.handleUpdateSign(this); + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } + + @SideOnly(Side.CLIENT) + public int func_149346_c() + { + return this.field_149352_a; + } + + @SideOnly(Side.CLIENT) + public int func_149345_d() + { + return this.field_149350_b; + } + + @SideOnly(Side.CLIENT) + public int func_149344_e() + { + return this.field_149351_c; + } + + @SideOnly(Side.CLIENT) + public String[] func_149347_f() + { + return this.field_149349_d; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S34PacketMaps.java b/src/main/java/net/minecraft/network/play/server/S34PacketMaps.java new file mode 100644 index 0000000..f771b0a --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S34PacketMaps.java @@ -0,0 +1,65 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; + +public class S34PacketMaps extends Packet +{ + private int field_149191_a; + private byte[] field_149190_b; + private static final String __OBFID = "CL_00001311"; + + public S34PacketMaps() {} + + public S34PacketMaps(int p_i45202_1_, byte[] p_i45202_2_) + { + this.field_149191_a = p_i45202_1_; + this.field_149190_b = p_i45202_2_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149191_a = p_148837_1_.readVarIntFromBuffer(); + this.field_149190_b = new byte[p_148837_1_.readUnsignedShort()]; + p_148837_1_.readBytes(this.field_149190_b); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeVarIntToBuffer(this.field_149191_a); + p_148840_1_.writeShort(this.field_149190_b.length); + p_148840_1_.writeBytes(this.field_149190_b); + } + + public void processPacket(INetHandlerPlayClient p_149189_1_) + { + p_149189_1_.handleMaps(this); + } + + public String serialize() + { + return String.format("id=%d, length=%d", new Object[] {Integer.valueOf(this.field_149191_a), Integer.valueOf(this.field_149190_b.length)}); + } + + @SideOnly(Side.CLIENT) + public int func_149188_c() + { + return this.field_149191_a; + } + + @SideOnly(Side.CLIENT) + public byte[] func_149187_d() + { + return this.field_149190_b; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S35PacketUpdateTileEntity.java b/src/main/java/net/minecraft/network/play/server/S35PacketUpdateTileEntity.java new file mode 100644 index 0000000..3e28178 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S35PacketUpdateTileEntity.java @@ -0,0 +1,89 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; + +public class S35PacketUpdateTileEntity extends Packet +{ + private int field_148863_a; + private int field_148861_b; + private int field_148862_c; + private int field_148859_d; + private NBTTagCompound field_148860_e; + private static final String __OBFID = "CL_00001285"; + + public S35PacketUpdateTileEntity() {} + + public S35PacketUpdateTileEntity(int p_i45175_1_, int p_i45175_2_, int p_i45175_3_, int p_i45175_4_, NBTTagCompound p_i45175_5_) + { + this.field_148863_a = p_i45175_1_; + this.field_148861_b = p_i45175_2_; + this.field_148862_c = p_i45175_3_; + this.field_148859_d = p_i45175_4_; + this.field_148860_e = p_i45175_5_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_148863_a = p_148837_1_.readInt(); + this.field_148861_b = p_148837_1_.readShort(); + this.field_148862_c = p_148837_1_.readInt(); + this.field_148859_d = p_148837_1_.readUnsignedByte(); + this.field_148860_e = p_148837_1_.readNBTTagCompoundFromBuffer(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeInt(this.field_148863_a); + p_148840_1_.writeShort(this.field_148861_b); + p_148840_1_.writeInt(this.field_148862_c); + p_148840_1_.writeByte((byte)this.field_148859_d); + p_148840_1_.writeNBTTagCompoundToBuffer(this.field_148860_e); + } + + public void processPacket(INetHandlerPlayClient p_148858_1_) + { + p_148858_1_.handleUpdateTileEntity(this); + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } + + @SideOnly(Side.CLIENT) + public int func_148856_c() + { + return this.field_148863_a; + } + + @SideOnly(Side.CLIENT) + public int func_148855_d() + { + return this.field_148861_b; + } + + @SideOnly(Side.CLIENT) + public int func_148854_e() + { + return this.field_148862_c; + } + + @SideOnly(Side.CLIENT) + public int func_148853_f() + { + return this.field_148859_d; + } + + @SideOnly(Side.CLIENT) + public NBTTagCompound func_148857_g() + { + return this.field_148860_e; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S36PacketSignEditorOpen.java b/src/main/java/net/minecraft/network/play/server/S36PacketSignEditorOpen.java new file mode 100644 index 0000000..438dedb --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S36PacketSignEditorOpen.java @@ -0,0 +1,68 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; + +public class S36PacketSignEditorOpen extends Packet +{ + private int field_149133_a; + private int field_149131_b; + private int field_149132_c; + private static final String __OBFID = "CL_00001316"; + + public S36PacketSignEditorOpen() {} + + public S36PacketSignEditorOpen(int p_i45207_1_, int p_i45207_2_, int p_i45207_3_) + { + this.field_149133_a = p_i45207_1_; + this.field_149131_b = p_i45207_2_; + this.field_149132_c = p_i45207_3_; + } + + public void processPacket(INetHandlerPlayClient p_149130_1_) + { + p_149130_1_.handleSignEditorOpen(this); + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149133_a = p_148837_1_.readInt(); + this.field_149131_b = p_148837_1_.readInt(); + this.field_149132_c = p_148837_1_.readInt(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeInt(this.field_149133_a); + p_148840_1_.writeInt(this.field_149131_b); + p_148840_1_.writeInt(this.field_149132_c); + } + + @SideOnly(Side.CLIENT) + public int func_149129_c() + { + return this.field_149133_a; + } + + @SideOnly(Side.CLIENT) + public int func_149128_d() + { + return this.field_149131_b; + } + + @SideOnly(Side.CLIENT) + public int func_149127_e() + { + return this.field_149132_c; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S37PacketStatistics.java b/src/main/java/net/minecraft/network/play/server/S37PacketStatistics.java new file mode 100644 index 0000000..7a0e774 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S37PacketStatistics.java @@ -0,0 +1,79 @@ +package net.minecraft.network.play.server; + +import com.google.common.collect.Maps; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; +import net.minecraft.stats.StatBase; +import net.minecraft.stats.StatList; + +public class S37PacketStatistics extends Packet +{ + private Map field_148976_a; + private static final String __OBFID = "CL_00001283"; + + public S37PacketStatistics() {} + + public S37PacketStatistics(Map p_i45173_1_) + { + this.field_148976_a = p_i45173_1_; + } + + public void processPacket(INetHandlerPlayClient p_148975_1_) + { + p_148975_1_.handleStatistics(this); + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + int i = p_148837_1_.readVarIntFromBuffer(); + this.field_148976_a = Maps.newHashMap(); + + for (int j = 0; j < i; ++j) + { + StatBase statbase = StatList.func_151177_a(p_148837_1_.readStringFromBuffer(32767)); + int k = p_148837_1_.readVarIntFromBuffer(); + + if (statbase != null) + { + this.field_148976_a.put(statbase, Integer.valueOf(k)); + } + } + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeVarIntToBuffer(this.field_148976_a.size()); + Iterator iterator = this.field_148976_a.entrySet().iterator(); + + while (iterator.hasNext()) + { + Entry entry = (Entry)iterator.next(); + p_148840_1_.writeStringToBuffer(((StatBase)entry.getKey()).statId); + p_148840_1_.writeVarIntToBuffer(((Integer)entry.getValue()).intValue()); + } + } + + public String serialize() + { + return String.format("count=%d", new Object[] {Integer.valueOf(this.field_148976_a.size())}); + } + + @SideOnly(Side.CLIENT) + public Map func_148974_c() + { + return this.field_148976_a; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S38PacketPlayerListItem.java b/src/main/java/net/minecraft/network/play/server/S38PacketPlayerListItem.java new file mode 100644 index 0000000..605976e --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S38PacketPlayerListItem.java @@ -0,0 +1,68 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; + +public class S38PacketPlayerListItem extends Packet +{ + private String field_149126_a; + private boolean field_149124_b; + private int field_149125_c; + private static final String __OBFID = "CL_00001318"; + + public S38PacketPlayerListItem() {} + + public S38PacketPlayerListItem(String p_i45209_1_, boolean p_i45209_2_, int p_i45209_3_) + { + this.field_149126_a = p_i45209_1_; + this.field_149124_b = p_i45209_2_; + this.field_149125_c = p_i45209_3_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149126_a = p_148837_1_.readStringFromBuffer(16); + this.field_149124_b = p_148837_1_.readBoolean(); + this.field_149125_c = p_148837_1_.readShort(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeStringToBuffer(this.field_149126_a); + p_148840_1_.writeBoolean(this.field_149124_b); + p_148840_1_.writeShort(this.field_149125_c); + } + + public void processPacket(INetHandlerPlayClient p_149123_1_) + { + p_149123_1_.handlePlayerListItem(this); + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } + + @SideOnly(Side.CLIENT) + public String func_149122_c() + { + return this.field_149126_a; + } + + @SideOnly(Side.CLIENT) + public boolean func_149121_d() + { + return this.field_149124_b; + } + + @SideOnly(Side.CLIENT) + public int func_149120_e() + { + return this.field_149125_c; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S39PacketPlayerAbilities.java b/src/main/java/net/minecraft/network/play/server/S39PacketPlayerAbilities.java new file mode 100644 index 0000000..45ff5d2 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S39PacketPlayerAbilities.java @@ -0,0 +1,146 @@ +package net.minecraft.network.play.server; + +import java.io.IOException; +import net.minecraft.entity.player.PlayerCapabilities; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; + +public class S39PacketPlayerAbilities extends Packet +{ + private boolean field_149119_a; + private boolean field_149117_b; + private boolean field_149118_c; + private boolean field_149115_d; + private float field_149116_e; + private float field_149114_f; + private static final String __OBFID = "CL_00001317"; + + public S39PacketPlayerAbilities() {} + + public S39PacketPlayerAbilities(PlayerCapabilities p_i45208_1_) + { + this.func_149108_a(p_i45208_1_.disableDamage); + this.func_149102_b(p_i45208_1_.isFlying); + this.func_149109_c(p_i45208_1_.allowFlying); + this.func_149111_d(p_i45208_1_.isCreativeMode); + this.func_149104_a(p_i45208_1_.getFlySpeed()); + this.func_149110_b(p_i45208_1_.getWalkSpeed()); + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + byte b0 = p_148837_1_.readByte(); + this.func_149108_a((b0 & 1) > 0); + this.func_149102_b((b0 & 2) > 0); + this.func_149109_c((b0 & 4) > 0); + this.func_149111_d((b0 & 8) > 0); + this.func_149104_a(p_148837_1_.readFloat()); + this.func_149110_b(p_148837_1_.readFloat()); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + byte b0 = 0; + + if (this.func_149112_c()) + { + b0 = (byte)(b0 | 1); + } + + if (this.func_149106_d()) + { + b0 = (byte)(b0 | 2); + } + + if (this.func_149105_e()) + { + b0 = (byte)(b0 | 4); + } + + if (this.func_149103_f()) + { + b0 = (byte)(b0 | 8); + } + + p_148840_1_.writeByte(b0); + p_148840_1_.writeFloat(this.field_149116_e); + p_148840_1_.writeFloat(this.field_149114_f); + } + + public void processPacket(INetHandlerPlayClient p_149113_1_) + { + p_149113_1_.handlePlayerAbilities(this); + } + + public String serialize() + { + return String.format("invuln=%b, flying=%b, canfly=%b, instabuild=%b, flyspeed=%.4f, walkspped=%.4f", new Object[] {Boolean.valueOf(this.func_149112_c()), Boolean.valueOf(this.func_149106_d()), Boolean.valueOf(this.func_149105_e()), Boolean.valueOf(this.func_149103_f()), Float.valueOf(this.func_149101_g()), Float.valueOf(this.func_149107_h())}); + } + + public boolean func_149112_c() + { + return this.field_149119_a; + } + + public void func_149108_a(boolean p_149108_1_) + { + this.field_149119_a = p_149108_1_; + } + + public boolean func_149106_d() + { + return this.field_149117_b; + } + + public void func_149102_b(boolean p_149102_1_) + { + this.field_149117_b = p_149102_1_; + } + + public boolean func_149105_e() + { + return this.field_149118_c; + } + + public void func_149109_c(boolean p_149109_1_) + { + this.field_149118_c = p_149109_1_; + } + + public boolean func_149103_f() + { + return this.field_149115_d; + } + + public void func_149111_d(boolean p_149111_1_) + { + this.field_149115_d = p_149111_1_; + } + + public float func_149101_g() + { + return this.field_149116_e; + } + + public void func_149104_a(float p_149104_1_) + { + this.field_149116_e = p_149104_1_; + } + + public float func_149107_h() + { + return this.field_149114_f; + } + + public void func_149110_b(float p_149110_1_) + { + this.field_149114_f = p_149110_1_; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S3APacketTabComplete.java b/src/main/java/net/minecraft/network/play/server/S3APacketTabComplete.java new file mode 100644 index 0000000..63d1249 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S3APacketTabComplete.java @@ -0,0 +1,67 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; +import org.apache.commons.lang3.ArrayUtils; + +public class S3APacketTabComplete extends Packet +{ + private String[] field_149632_a; + private static final String __OBFID = "CL_00001288"; + + public S3APacketTabComplete() {} + + public S3APacketTabComplete(String[] p_i45178_1_) + { + this.field_149632_a = p_i45178_1_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149632_a = new String[p_148837_1_.readVarIntFromBuffer()]; + + for (int i = 0; i < this.field_149632_a.length; ++i) + { + this.field_149632_a[i] = p_148837_1_.readStringFromBuffer(32767); + } + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeVarIntToBuffer(this.field_149632_a.length); + String[] astring = this.field_149632_a; + int i = astring.length; + + for (int j = 0; j < i; ++j) + { + String s = astring[j]; + p_148840_1_.writeStringToBuffer(s); + } + } + + public void processPacket(INetHandlerPlayClient p_149631_1_) + { + p_149631_1_.handleTabComplete(this); + } + + @SideOnly(Side.CLIENT) + public String[] func_149630_c() + { + return this.field_149632_a; + } + + public String serialize() + { + return String.format("candidates=\'%s\'", new Object[] {ArrayUtils.toString(this.field_149632_a)}); + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S3BPacketScoreboardObjective.java b/src/main/java/net/minecraft/network/play/server/S3BPacketScoreboardObjective.java new file mode 100644 index 0000000..6a08d26 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S3BPacketScoreboardObjective.java @@ -0,0 +1,69 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; +import net.minecraft.scoreboard.ScoreObjective; + +public class S3BPacketScoreboardObjective extends Packet +{ + private String field_149343_a; + private String field_149341_b; + private int field_149342_c; + private static final String __OBFID = "CL_00001333"; + + public S3BPacketScoreboardObjective() {} + + public S3BPacketScoreboardObjective(ScoreObjective p_i45224_1_, int p_i45224_2_) + { + this.field_149343_a = p_i45224_1_.getName(); + this.field_149341_b = p_i45224_1_.getDisplayName(); + this.field_149342_c = p_i45224_2_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149343_a = p_148837_1_.readStringFromBuffer(16); + this.field_149341_b = p_148837_1_.readStringFromBuffer(32); + this.field_149342_c = p_148837_1_.readByte(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeStringToBuffer(this.field_149343_a); + p_148840_1_.writeStringToBuffer(this.field_149341_b); + p_148840_1_.writeByte(this.field_149342_c); + } + + public void processPacket(INetHandlerPlayClient p_149340_1_) + { + p_149340_1_.handleScoreboardObjective(this); + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } + + @SideOnly(Side.CLIENT) + public String func_149339_c() + { + return this.field_149343_a; + } + + @SideOnly(Side.CLIENT) + public String func_149337_d() + { + return this.field_149341_b; + } + + @SideOnly(Side.CLIENT) + public int func_149338_e() + { + return this.field_149342_c; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S3CPacketUpdateScore.java b/src/main/java/net/minecraft/network/play/server/S3CPacketUpdateScore.java new file mode 100644 index 0000000..8802506 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S3CPacketUpdateScore.java @@ -0,0 +1,95 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; +import net.minecraft.scoreboard.Score; + +public class S3CPacketUpdateScore extends Packet +{ + private String field_149329_a = ""; + private String field_149327_b = ""; + private int field_149328_c; + private int field_149326_d; + private static final String __OBFID = "CL_00001335"; + + public S3CPacketUpdateScore() {} + + public S3CPacketUpdateScore(Score p_i45227_1_, int p_i45227_2_) + { + this.field_149329_a = p_i45227_1_.getPlayerName(); + this.field_149327_b = p_i45227_1_.func_96645_d().getName(); + this.field_149328_c = p_i45227_1_.getScorePoints(); + this.field_149326_d = p_i45227_2_; + } + + public S3CPacketUpdateScore(String p_i45228_1_) + { + this.field_149329_a = p_i45228_1_; + this.field_149327_b = ""; + this.field_149328_c = 0; + this.field_149326_d = 1; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149329_a = p_148837_1_.readStringFromBuffer(16); + this.field_149326_d = p_148837_1_.readByte(); + + if (this.field_149326_d != 1) + { + this.field_149327_b = p_148837_1_.readStringFromBuffer(16); + this.field_149328_c = p_148837_1_.readInt(); + } + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeStringToBuffer(this.field_149329_a); + p_148840_1_.writeByte(this.field_149326_d); + + if (this.field_149326_d != 1) + { + p_148840_1_.writeStringToBuffer(this.field_149327_b); + p_148840_1_.writeInt(this.field_149328_c); + } + } + + public void processPacket(INetHandlerPlayClient p_149325_1_) + { + p_149325_1_.handleUpdateScore(this); + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } + + @SideOnly(Side.CLIENT) + public String func_149324_c() + { + return this.field_149329_a; + } + + @SideOnly(Side.CLIENT) + public String func_149321_d() + { + return this.field_149327_b; + } + + @SideOnly(Side.CLIENT) + public int func_149323_e() + { + return this.field_149328_c; + } + + @SideOnly(Side.CLIENT) + public int func_149322_f() + { + return this.field_149326_d; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S3DPacketDisplayScoreboard.java b/src/main/java/net/minecraft/network/play/server/S3DPacketDisplayScoreboard.java new file mode 100644 index 0000000..6d8d47c --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S3DPacketDisplayScoreboard.java @@ -0,0 +1,67 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; +import net.minecraft.scoreboard.ScoreObjective; + +public class S3DPacketDisplayScoreboard extends Packet +{ + private int field_149374_a; + private String field_149373_b; + private static final String __OBFID = "CL_00001325"; + + public S3DPacketDisplayScoreboard() {} + + public S3DPacketDisplayScoreboard(int p_i45216_1_, ScoreObjective p_i45216_2_) + { + this.field_149374_a = p_i45216_1_; + + if (p_i45216_2_ == null) + { + this.field_149373_b = ""; + } + else + { + this.field_149373_b = p_i45216_2_.getName(); + } + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149374_a = p_148837_1_.readByte(); + this.field_149373_b = p_148837_1_.readStringFromBuffer(16); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeByte(this.field_149374_a); + p_148840_1_.writeStringToBuffer(this.field_149373_b); + } + + public void processPacket(INetHandlerPlayClient p_149372_1_) + { + p_149372_1_.handleDisplayScoreboard(this); + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } + + @SideOnly(Side.CLIENT) + public int func_149371_c() + { + return this.field_149374_a; + } + + @SideOnly(Side.CLIENT) + public String func_149370_d() + { + return this.field_149373_b; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S3EPacketTeams.java b/src/main/java/net/minecraft/network/play/server/S3EPacketTeams.java new file mode 100644 index 0000000..68e76df --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S3EPacketTeams.java @@ -0,0 +1,166 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; +import net.minecraft.scoreboard.ScorePlayerTeam; + +public class S3EPacketTeams extends Packet +{ + private String field_149320_a = ""; + private String field_149318_b = ""; + private String field_149319_c = ""; + private String field_149316_d = ""; + private Collection field_149317_e = new ArrayList(); + private int field_149314_f; + private int field_149315_g; + private static final String __OBFID = "CL_00001334"; + + public S3EPacketTeams() {} + + public S3EPacketTeams(ScorePlayerTeam p_i45225_1_, int p_i45225_2_) + { + this.field_149320_a = p_i45225_1_.getRegisteredName(); + this.field_149314_f = p_i45225_2_; + + if (p_i45225_2_ == 0 || p_i45225_2_ == 2) + { + this.field_149318_b = p_i45225_1_.func_96669_c(); + this.field_149319_c = p_i45225_1_.getColorPrefix(); + this.field_149316_d = p_i45225_1_.getColorSuffix(); + this.field_149315_g = p_i45225_1_.func_98299_i(); + } + + if (p_i45225_2_ == 0) + { + this.field_149317_e.addAll(p_i45225_1_.getMembershipCollection()); + } + } + + public S3EPacketTeams(ScorePlayerTeam p_i45226_1_, Collection p_i45226_2_, int p_i45226_3_) + { + if (p_i45226_3_ != 3 && p_i45226_3_ != 4) + { + throw new IllegalArgumentException("Method must be join or leave for player constructor"); + } + else if (p_i45226_2_ != null && !p_i45226_2_.isEmpty()) + { + this.field_149314_f = p_i45226_3_; + this.field_149320_a = p_i45226_1_.getRegisteredName(); + this.field_149317_e.addAll(p_i45226_2_); + } + else + { + throw new IllegalArgumentException("Players cannot be null/empty"); + } + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149320_a = p_148837_1_.readStringFromBuffer(16); + this.field_149314_f = p_148837_1_.readByte(); + + if (this.field_149314_f == 0 || this.field_149314_f == 2) + { + this.field_149318_b = p_148837_1_.readStringFromBuffer(32); + this.field_149319_c = p_148837_1_.readStringFromBuffer(16); + this.field_149316_d = p_148837_1_.readStringFromBuffer(16); + this.field_149315_g = p_148837_1_.readByte(); + } + + if (this.field_149314_f == 0 || this.field_149314_f == 3 || this.field_149314_f == 4) + { + short short1 = p_148837_1_.readShort(); + + for (int i = 0; i < short1; ++i) + { + this.field_149317_e.add(p_148837_1_.readStringFromBuffer(16)); + } + } + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeStringToBuffer(this.field_149320_a); + p_148840_1_.writeByte(this.field_149314_f); + + if (this.field_149314_f == 0 || this.field_149314_f == 2) + { + p_148840_1_.writeStringToBuffer(this.field_149318_b); + p_148840_1_.writeStringToBuffer(this.field_149319_c); + p_148840_1_.writeStringToBuffer(this.field_149316_d); + p_148840_1_.writeByte(this.field_149315_g); + } + + if (this.field_149314_f == 0 || this.field_149314_f == 3 || this.field_149314_f == 4) + { + p_148840_1_.writeShort(this.field_149317_e.size()); + Iterator iterator = this.field_149317_e.iterator(); + + while (iterator.hasNext()) + { + String s = (String)iterator.next(); + p_148840_1_.writeStringToBuffer(s); + } + } + } + + public void processPacket(INetHandlerPlayClient p_149313_1_) + { + p_149313_1_.handleTeams(this); + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } + + @SideOnly(Side.CLIENT) + public String func_149312_c() + { + return this.field_149320_a; + } + + @SideOnly(Side.CLIENT) + public String func_149306_d() + { + return this.field_149318_b; + } + + @SideOnly(Side.CLIENT) + public String func_149311_e() + { + return this.field_149319_c; + } + + @SideOnly(Side.CLIENT) + public String func_149309_f() + { + return this.field_149316_d; + } + + @SideOnly(Side.CLIENT) + public Collection func_149310_g() + { + return this.field_149317_e; + } + + @SideOnly(Side.CLIENT) + public int func_149307_h() + { + return this.field_149314_f; + } + + @SideOnly(Side.CLIENT) + public int func_149308_i() + { + return this.field_149315_g; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S3FPacketCustomPayload.java b/src/main/java/net/minecraft/network/play/server/S3FPacketCustomPayload.java new file mode 100644 index 0000000..1f9a2a5 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S3FPacketCustomPayload.java @@ -0,0 +1,72 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.common.network.ByteBufUtils; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; + +public class S3FPacketCustomPayload extends Packet +{ + private String field_149172_a; + private byte[] field_149171_b; + private static final String __OBFID = "CL_00001297"; + + public S3FPacketCustomPayload() {} + + public S3FPacketCustomPayload(String p_i45189_1_, ByteBuf p_i45189_2_) + { + this(p_i45189_1_, p_i45189_2_.array()); + } + + public S3FPacketCustomPayload(String p_i45190_1_, byte[] p_i45190_2_) + { + this.field_149172_a = p_i45190_1_; + this.field_149171_b = p_i45190_2_; + + if (p_i45190_2_.length > 0x1ffff0) + { + throw new IllegalArgumentException("Payload may not be larger than 2097136 (0x1ffff0) bytes"); + } + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149172_a = p_148837_1_.readStringFromBuffer(20); + this.field_149171_b = new byte[ByteBufUtils.readVarShort(p_148837_1_)]; + p_148837_1_.readBytes(this.field_149171_b); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeStringToBuffer(this.field_149172_a); + ByteBufUtils.writeVarShort(p_148840_1_, this.field_149171_b.length); + p_148840_1_.writeBytes(this.field_149171_b); + } + + public void processPacket(INetHandlerPlayClient p_149170_1_) + { + p_149170_1_.handleCustomPayload(this); + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } + + @SideOnly(Side.CLIENT) + public String func_149169_c() + { + return this.field_149172_a; + } + + @SideOnly(Side.CLIENT) + public byte[] func_149168_d() + { + return this.field_149171_b; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/play/server/S40PacketDisconnect.java b/src/main/java/net/minecraft/network/play/server/S40PacketDisconnect.java new file mode 100644 index 0000000..3ad6341 --- /dev/null +++ b/src/main/java/net/minecraft/network/play/server/S40PacketDisconnect.java @@ -0,0 +1,54 @@ +package net.minecraft.network.play.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.INetHandlerPlayClient; +import net.minecraft.util.IChatComponent; + +public class S40PacketDisconnect extends Packet +{ + private IChatComponent field_149167_a; + private static final String __OBFID = "CL_00001298"; + + public S40PacketDisconnect() {} + + public S40PacketDisconnect(IChatComponent p_i45191_1_) + { + this.field_149167_a = p_i45191_1_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149167_a = IChatComponent.Serializer.func_150699_a(p_148837_1_.readStringFromBuffer(32767)); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeStringToBuffer(IChatComponent.Serializer.func_150696_a(this.field_149167_a)); + } + + public void processPacket(INetHandlerPlayClient p_149166_1_) + { + p_149166_1_.handleDisconnect(this); + } + + public boolean hasPriority() + { + return true; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerPlayClient)p_148833_1_); + } + + @SideOnly(Side.CLIENT) + public IChatComponent func_149165_c() + { + return this.field_149167_a; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/rcon/IServer.java b/src/main/java/net/minecraft/network/rcon/IServer.java new file mode 100644 index 0000000..a4d7d6d --- /dev/null +++ b/src/main/java/net/minecraft/network/rcon/IServer.java @@ -0,0 +1,48 @@ +package net.minecraft.network.rcon; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.SERVER) +public interface IServer +{ + int getIntProperty(String var1, int var2); + + String getStringProperty(String var1, String var2); + + void setProperty(String var1, Object var2); + + void saveProperties(); + + String getSettingsFilename(); + + String getHostname(); + + int getPort(); + + String getMotd(); + + String getMinecraftVersion(); + + int getCurrentPlayerCount(); + + int getMaxPlayers(); + + String[] getAllUsernames(); + + String getFolderName(); + + String getPlugins(); + + String handleRConCommand(String var1); + + boolean isDebuggingEnabled(); + + void logInfo(String var1); + + void logWarning(String var1); + + void logSevere(String var1); + + void logDebug(String var1); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/rcon/RConConsoleSource.java b/src/main/java/net/minecraft/network/rcon/RConConsoleSource.java new file mode 100644 index 0000000..9aec90a --- /dev/null +++ b/src/main/java/net/minecraft/network/rcon/RConConsoleSource.java @@ -0,0 +1,58 @@ +package net.minecraft.network.rcon; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.command.ICommandSender; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.IChatComponent; +import net.minecraft.world.World; + +@SideOnly(Side.SERVER) +public class RConConsoleSource implements ICommandSender +{ + public static final RConConsoleSource instance = new RConConsoleSource(); + private StringBuffer buffer = new StringBuffer(); + private static final String __OBFID = "CL_00001800"; + + public void resetLog() + { + this.buffer.setLength(0); + } + + public String getLogContents() + { + return this.buffer.toString(); + } + + public String getCommandSenderName() + { + return "Rcon"; + } + + public IChatComponent func_145748_c_() + { + return new ChatComponentText(this.getCommandSenderName()); + } + + public void addChatMessage(IChatComponent ichatcomponent) + { + this.buffer.append(ichatcomponent.getUnformattedText()); + } + + public boolean canCommandSenderUseCommand(int par1, String par2Str) + { + return true; + } + + public ChunkCoordinates getPlayerCoordinates() + { + return new ChunkCoordinates(0, 0, 0); + } + + public World getEntityWorld() + { + return MinecraftServer.getServer().getEntityWorld(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/rcon/RConOutputStream.java b/src/main/java/net/minecraft/network/rcon/RConOutputStream.java new file mode 100644 index 0000000..86a5679 --- /dev/null +++ b/src/main/java/net/minecraft/network/rcon/RConOutputStream.java @@ -0,0 +1,52 @@ +package net.minecraft.network.rcon; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +@SideOnly(Side.SERVER) +public class RConOutputStream +{ + private ByteArrayOutputStream byteArrayOutput; + private DataOutputStream output; + private static final String __OBFID = "CL_00001798"; + + public RConOutputStream(int par1) + { + this.byteArrayOutput = new ByteArrayOutputStream(par1); + this.output = new DataOutputStream(this.byteArrayOutput); + } + + public void writeByteArray(byte[] par1ArrayOfByte) throws IOException + { + this.output.write(par1ArrayOfByte, 0, par1ArrayOfByte.length); + } + + public void writeString(String par1Str) throws IOException + { + this.output.writeBytes(par1Str); + this.output.write(0); + } + + public void writeInt(int par1) throws IOException + { + this.output.write(par1); + } + + public void writeShort(short par1) throws IOException + { + this.output.writeShort(Short.reverseBytes(par1)); + } + + public byte[] toByteArray() + { + return this.byteArrayOutput.toByteArray(); + } + + public void reset() + { + this.byteArrayOutput.reset(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/rcon/RConThreadBase.java b/src/main/java/net/minecraft/network/rcon/RConThreadBase.java new file mode 100644 index 0000000..6a94033 --- /dev/null +++ b/src/main/java/net/minecraft/network/rcon/RConThreadBase.java @@ -0,0 +1,186 @@ +package net.minecraft.network.rcon; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import java.net.DatagramSocket; +import java.net.ServerSocket; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; + +@SideOnly(Side.SERVER) +public abstract class RConThreadBase implements Runnable +{ + private static final AtomicInteger field_164004_h = new AtomicInteger(0); + protected boolean running; + protected IServer server; + protected final String field_164003_c; + protected Thread rconThread; + protected int field_72615_d = 5; + protected List socketList = new ArrayList(); + protected List serverSocketList = new ArrayList(); + private static final String __OBFID = "CL_00001801"; + + protected RConThreadBase(IServer p_i45300_1_, String p_i45300_2_) + { + this.server = p_i45300_1_; + this.field_164003_c = p_i45300_2_; + + if (this.server.isDebuggingEnabled()) + { + this.logWarning("Debugging is enabled, performance maybe reduced!"); + } + } + + public synchronized void startThread() + { + this.rconThread = new Thread(this, this.field_164003_c + " #" + field_164004_h.incrementAndGet()); + this.rconThread.start(); + this.running = true; + } + + public boolean isRunning() + { + return this.running; + } + + protected void logDebug(String par1Str) + { + this.server.logDebug(par1Str); + } + + protected void logInfo(String par1Str) + { + this.server.logInfo(par1Str); + } + + protected void logWarning(String par1Str) + { + this.server.logWarning(par1Str); + } + + protected void logSevere(String par1Str) + { + this.server.logSevere(par1Str); + } + + protected int getNumberOfPlayers() + { + return this.server.getCurrentPlayerCount(); + } + + protected void registerSocket(DatagramSocket par1DatagramSocket) + { + this.logDebug("registerSocket: " + par1DatagramSocket); + this.socketList.add(par1DatagramSocket); + } + + protected boolean closeSocket(DatagramSocket par1DatagramSocket, boolean par2) + { + this.logDebug("closeSocket: " + par1DatagramSocket); + + if (null == par1DatagramSocket) + { + return false; + } + else + { + boolean flag1 = false; + + if (!par1DatagramSocket.isClosed()) + { + par1DatagramSocket.close(); + flag1 = true; + } + + if (par2) + { + this.socketList.remove(par1DatagramSocket); + } + + return flag1; + } + } + + protected boolean closeServerSocket(ServerSocket par1ServerSocket) + { + return this.closeServerSocket_do(par1ServerSocket, true); + } + + protected boolean closeServerSocket_do(ServerSocket par1ServerSocket, boolean par2) + { + this.logDebug("closeSocket: " + par1ServerSocket); + + if (null == par1ServerSocket) + { + return false; + } + else + { + boolean flag1 = false; + + try + { + if (!par1ServerSocket.isClosed()) + { + par1ServerSocket.close(); + flag1 = true; + } + } + catch (IOException ioexception) + { + this.logWarning("IO: " + ioexception.getMessage()); + } + + if (par2) + { + this.serverSocketList.remove(par1ServerSocket); + } + + return flag1; + } + } + + protected void closeAllSockets() + { + this.closeAllSockets_do(false); + } + + protected void closeAllSockets_do(boolean par1) + { + int i = 0; + Iterator iterator = this.socketList.iterator(); + + while (iterator.hasNext()) + { + DatagramSocket datagramsocket = (DatagramSocket)iterator.next(); + + if (this.closeSocket(datagramsocket, false)) + { + ++i; + } + } + + this.socketList.clear(); + iterator = this.serverSocketList.iterator(); + + while (iterator.hasNext()) + { + ServerSocket serversocket = (ServerSocket)iterator.next(); + + if (this.closeServerSocket_do(serversocket, false)) + { + ++i; + } + } + + this.serverSocketList.clear(); + + if (par1 && 0 < i) + { + this.logWarning("Force closed " + i + " sockets"); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/rcon/RConThreadClient.java b/src/main/java/net/minecraft/network/rcon/RConThreadClient.java new file mode 100644 index 0000000..74cc342 --- /dev/null +++ b/src/main/java/net/minecraft/network/rcon/RConThreadClient.java @@ -0,0 +1,184 @@ +package net.minecraft.network.rcon; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.BufferedInputStream; +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.net.Socket; +import java.net.SocketTimeoutException; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +@SideOnly(Side.SERVER) +public class RConThreadClient extends RConThreadBase +{ + private static final Logger field_164005_h = LogManager.getLogger(); + private boolean loggedIn; + private Socket clientSocket; + private byte[] buffer = new byte[1460]; + private String rconPassword; + private static final String __OBFID = "CL_00001804"; + + RConThreadClient(IServer par1IServer, Socket par2Socket) + { + super(par1IServer, "RCON Client"); + this.clientSocket = par2Socket; + + try + { + this.clientSocket.setSoTimeout(0); + } + catch (Exception exception) + { + this.running = false; + } + + this.rconPassword = par1IServer.getStringProperty("rcon.password", ""); + this.logInfo("Rcon connection from: " + par2Socket.getInetAddress()); + } + + public void run() + { + while (true) + { + try + { + if (!this.running) + { + break; + } + + BufferedInputStream bufferedinputstream = new BufferedInputStream(this.clientSocket.getInputStream()); + int i = bufferedinputstream.read(this.buffer, 0, 1460); + + if (10 > i) + { + return; + } + + byte b0 = 0; + int j = RConUtils.getBytesAsLEInt(this.buffer, 0, i); + + if (j == i - 4) + { + int i1 = b0 + 4; + int k = RConUtils.getBytesAsLEInt(this.buffer, i1, i); + i1 += 4; + int l = RConUtils.getRemainingBytesAsLEInt(this.buffer, i1); + i1 += 4; + + switch (l) + { + case 2: + if (this.loggedIn) + { + String s1 = RConUtils.getBytesAsString(this.buffer, i1, i); + + try + { + this.sendMultipacketResponse(k, this.server.handleRConCommand(s1)); + } + catch (Exception exception) + { + this.sendMultipacketResponse(k, "Error executing: " + s1 + " (" + exception.getMessage() + ")"); + } + + continue; + } + + this.sendLoginFailedResponse(); + continue; + case 3: + String s = RConUtils.getBytesAsString(this.buffer, i1, i); + int j1 = i1 + s.length(); + + if (0 != s.length() && s.equals(this.rconPassword)) + { + this.loggedIn = true; + this.sendResponse(k, 2, ""); + continue; + } + + this.loggedIn = false; + this.sendLoginFailedResponse(); + continue; + default: + this.sendMultipacketResponse(k, String.format("Unknown request %s", new Object[] {Integer.toHexString(l)})); + continue; + } + } + } + catch (SocketTimeoutException sockettimeoutexception) + { + break; + } + catch (IOException ioexception) + { + break; + } + catch (Exception exception1) + { + field_164005_h.error("Exception whilst parsing RCON input", exception1); + break; + } + finally + { + this.closeSocket(); + } + + return; + } + } + + private void sendResponse(int par1, int par2, String par3Str) throws IOException + { + ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream(1248); + DataOutputStream dataoutputstream = new DataOutputStream(bytearrayoutputstream); + byte[] abyte = par3Str.getBytes("UTF-8"); + dataoutputstream.writeInt(Integer.reverseBytes(abyte.length + 10)); + dataoutputstream.writeInt(Integer.reverseBytes(par1)); + dataoutputstream.writeInt(Integer.reverseBytes(par2)); + dataoutputstream.write(abyte); + dataoutputstream.write(0); + dataoutputstream.write(0); + this.clientSocket.getOutputStream().write(bytearrayoutputstream.toByteArray()); + } + + private void sendLoginFailedResponse() throws IOException + { + this.sendResponse(-1, 2, ""); + } + + private void sendMultipacketResponse(int par1, String par2Str) throws IOException + { + int j = par2Str.length(); + + do + { + int k = 4096 <= j ? 4096 : j; + this.sendResponse(par1, 0, par2Str.substring(0, k)); + par2Str = par2Str.substring(k); + j = par2Str.length(); + } + while (0 != j); + } + + private void closeSocket() + { + if (null != this.clientSocket) + { + try + { + this.clientSocket.close(); + } + catch (IOException ioexception) + { + this.logWarning("IO: " + ioexception.getMessage()); + } + + this.clientSocket = null; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/rcon/RConThreadMain.java b/src/main/java/net/minecraft/network/rcon/RConThreadMain.java new file mode 100644 index 0000000..da9827b --- /dev/null +++ b/src/main/java/net/minecraft/network/rcon/RConThreadMain.java @@ -0,0 +1,140 @@ +package net.minecraft.network.rcon; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import java.net.InetAddress; +import java.net.ServerSocket; +import java.net.Socket; +import java.net.SocketTimeoutException; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; + +@SideOnly(Side.SERVER) +public class RConThreadMain extends RConThreadBase +{ + private int rconPort; + private int serverPort; + private String hostname; + private ServerSocket serverSocket; + private String rconPassword; + private Map clientThreads; + private static final String __OBFID = "CL_00001805"; + + public RConThreadMain(IServer par1IServer) + { + super(par1IServer, "RCON Listener"); + this.rconPort = par1IServer.getIntProperty("rcon.port", 0); + this.rconPassword = par1IServer.getStringProperty("rcon.password", ""); + this.hostname = par1IServer.getHostname(); + this.serverPort = par1IServer.getPort(); + + if (0 == this.rconPort) + { + this.rconPort = this.serverPort + 10; + this.logInfo("Setting default rcon port to " + this.rconPort); + par1IServer.setProperty("rcon.port", Integer.valueOf(this.rconPort)); + + if (0 == this.rconPassword.length()) + { + par1IServer.setProperty("rcon.password", ""); + } + + par1IServer.saveProperties(); + } + + if (0 == this.hostname.length()) + { + this.hostname = "0.0.0.0"; + } + + this.initClientThreadList(); + this.serverSocket = null; + } + + private void initClientThreadList() + { + this.clientThreads = new HashMap(); + } + + private void cleanClientThreadsMap() + { + Iterator iterator = this.clientThreads.entrySet().iterator(); + + while (iterator.hasNext()) + { + Entry entry = (Entry)iterator.next(); + + if (!((RConThreadClient)entry.getValue()).isRunning()) + { + iterator.remove(); + } + } + } + + public void run() + { + this.logInfo("RCON running on " + this.hostname + ":" + this.rconPort); + + try + { + while (this.running) + { + try + { + Socket socket = this.serverSocket.accept(); + socket.setSoTimeout(500); + RConThreadClient rconthreadclient = new RConThreadClient(this.server, socket); + rconthreadclient.startThread(); + this.clientThreads.put(socket.getRemoteSocketAddress(), rconthreadclient); + this.cleanClientThreadsMap(); + } + catch (SocketTimeoutException sockettimeoutexception) + { + this.cleanClientThreadsMap(); + } + catch (IOException ioexception) + { + if (this.running) + { + this.logInfo("IO: " + ioexception.getMessage()); + } + } + } + } + finally + { + this.closeServerSocket(this.serverSocket); + } + } + + public void startThread() + { + if (0 == this.rconPassword.length()) + { + this.logWarning("No rcon password set in \'" + this.server.getSettingsFilename() + "\', rcon disabled!"); + } + else if (0 < this.rconPort && 65535 >= this.rconPort) + { + if (!this.running) + { + try + { + this.serverSocket = new ServerSocket(this.rconPort, 0, InetAddress.getByName(this.hostname)); + this.serverSocket.setSoTimeout(500); + super.startThread(); + } + catch (IOException ioexception) + { + this.logWarning("Unable to initialise rcon on " + this.hostname + ":" + this.rconPort + " : " + ioexception.getMessage()); + } + } + } + else + { + this.logWarning("Invalid rcon port " + this.rconPort + " found in \'" + this.server.getSettingsFilename() + "\', rcon disabled!"); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/rcon/RConThreadQuery.java b/src/main/java/net/minecraft/network/rcon/RConThreadQuery.java new file mode 100644 index 0000000..6491ad3 --- /dev/null +++ b/src/main/java/net/minecraft/network/rcon/RConThreadQuery.java @@ -0,0 +1,397 @@ +package net.minecraft.network.rcon; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; +import java.net.PortUnreachableException; +import java.net.SocketAddress; +import java.net.SocketException; +import java.net.SocketTimeoutException; +import java.net.UnknownHostException; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Random; +import java.util.Map.Entry; +import net.minecraft.server.MinecraftServer; + +@SideOnly(Side.SERVER) +public class RConThreadQuery extends RConThreadBase +{ + private long lastAuthCheckTime; + private int queryPort; + private int serverPort; + private int maxPlayers; + private String serverMotd; + private String worldName; + private DatagramSocket querySocket; + private byte[] buffer = new byte[1460]; + private DatagramPacket incomingPacket; + private Map field_72644_p; + private String queryHostname; + private String serverHostname; + private Map queryClients; + private long time; + private RConOutputStream output; + private long lastQueryResponseTime; + private static final String __OBFID = "CL_00001802"; + + public RConThreadQuery(IServer par1IServer) + { + super(par1IServer, "Query Listener"); + this.queryPort = par1IServer.getIntProperty("query.port", 0); + this.serverHostname = par1IServer.getHostname(); + this.serverPort = par1IServer.getPort(); + this.serverMotd = par1IServer.getMotd(); + this.maxPlayers = par1IServer.getMaxPlayers(); + this.worldName = par1IServer.getFolderName(); + this.lastQueryResponseTime = 0L; + this.queryHostname = "0.0.0.0"; + + if (0 != this.serverHostname.length() && !this.queryHostname.equals(this.serverHostname)) + { + this.queryHostname = this.serverHostname; + } + else + { + this.serverHostname = "0.0.0.0"; + + try + { + InetAddress inetaddress = InetAddress.getLocalHost(); + this.queryHostname = inetaddress.getHostAddress(); + } + catch (UnknownHostException unknownhostexception) + { + this.logWarning("Unable to determine local host IP, please set server-ip in \'" + par1IServer.getSettingsFilename() + "\' : " + unknownhostexception.getMessage()); + } + } + + if (0 == this.queryPort) + { + this.queryPort = this.serverPort; + this.logInfo("Setting default query port to " + this.queryPort); + par1IServer.setProperty("query.port", Integer.valueOf(this.queryPort)); + par1IServer.setProperty("debug", Boolean.valueOf(false)); + par1IServer.saveProperties(); + } + + this.field_72644_p = new HashMap(); + this.output = new RConOutputStream(1460); + this.queryClients = new HashMap(); + this.time = (new Date()).getTime(); + } + + private void sendResponsePacket(byte[] par1ArrayOfByte, DatagramPacket par2DatagramPacket) throws IOException + { + this.querySocket.send(new DatagramPacket(par1ArrayOfByte, par1ArrayOfByte.length, par2DatagramPacket.getSocketAddress())); + } + + private boolean parseIncomingPacket(DatagramPacket par1DatagramPacket) throws IOException + { + byte[] abyte = par1DatagramPacket.getData(); + int i = par1DatagramPacket.getLength(); + SocketAddress socketaddress = par1DatagramPacket.getSocketAddress(); + this.logDebug("Packet len " + i + " [" + socketaddress + "]"); + + if (3 <= i && -2 == abyte[0] && -3 == abyte[1]) + { + this.logDebug("Packet \'" + RConUtils.getByteAsHexString(abyte[2]) + "\' [" + socketaddress + "]"); + + switch (abyte[2]) + { + case 0: + if (!this.verifyClientAuth(par1DatagramPacket).booleanValue()) + { + this.logDebug("Invalid challenge [" + socketaddress + "]"); + return false; + } + else if (15 == i) + { + this.sendResponsePacket(this.createQueryResponse(par1DatagramPacket), par1DatagramPacket); + this.logDebug("Rules [" + socketaddress + "]"); + } + else + { + RConOutputStream rconoutputstream = new RConOutputStream(1460); + rconoutputstream.writeInt(0); + rconoutputstream.writeByteArray(this.getRequestID(par1DatagramPacket.getSocketAddress())); + rconoutputstream.writeString(this.serverMotd); + rconoutputstream.writeString("SMP"); + rconoutputstream.writeString(this.worldName); + rconoutputstream.writeString(Integer.toString(this.getNumberOfPlayers())); + rconoutputstream.writeString(Integer.toString(this.maxPlayers)); + rconoutputstream.writeShort((short)this.serverPort); + rconoutputstream.writeString(this.queryHostname); + this.sendResponsePacket(rconoutputstream.toByteArray(), par1DatagramPacket); + this.logDebug("Status [" + socketaddress + "]"); + } + case 9: + this.sendAuthChallenge(par1DatagramPacket); + this.logDebug("Challenge [" + socketaddress + "]"); + return true; + default: + return true; + } + } + else + { + this.logDebug("Invalid packet [" + socketaddress + "]"); + return false; + } + } + + private byte[] createQueryResponse(DatagramPacket par1DatagramPacket) throws IOException + { + long i = MinecraftServer.getSystemTimeMillis(); + + if (i < this.lastQueryResponseTime + 5000L) + { + byte[] abyte = this.output.toByteArray(); + byte[] abyte1 = this.getRequestID(par1DatagramPacket.getSocketAddress()); + abyte[1] = abyte1[0]; + abyte[2] = abyte1[1]; + abyte[3] = abyte1[2]; + abyte[4] = abyte1[3]; + return abyte; + } + else + { + this.lastQueryResponseTime = i; + this.output.reset(); + this.output.writeInt(0); + this.output.writeByteArray(this.getRequestID(par1DatagramPacket.getSocketAddress())); + this.output.writeString("splitnum"); + this.output.writeInt(128); + this.output.writeInt(0); + this.output.writeString("hostname"); + this.output.writeString(this.serverMotd); + this.output.writeString("gametype"); + this.output.writeString("SMP"); + this.output.writeString("game_id"); + this.output.writeString("MINECRAFT"); + this.output.writeString("version"); + this.output.writeString(this.server.getMinecraftVersion()); + this.output.writeString("plugins"); + this.output.writeString(this.server.getPlugins()); + this.output.writeString("map"); + this.output.writeString(this.worldName); + this.output.writeString("numplayers"); + this.output.writeString("" + this.getNumberOfPlayers()); + this.output.writeString("maxplayers"); + this.output.writeString("" + this.maxPlayers); + this.output.writeString("hostport"); + this.output.writeString("" + this.serverPort); + this.output.writeString("hostip"); + this.output.writeString(this.queryHostname); + this.output.writeInt(0); + this.output.writeInt(1); + this.output.writeString("player_"); + this.output.writeInt(0); + String[] astring = this.server.getAllUsernames(); + String[] astring1 = astring; + int j = astring.length; + + for (int k = 0; k < j; ++k) + { + String s = astring1[k]; + this.output.writeString(s); + } + + this.output.writeInt(0); + return this.output.toByteArray(); + } + } + + private byte[] getRequestID(SocketAddress par1SocketAddress) + { + return ((RConThreadQuery.Auth)this.queryClients.get(par1SocketAddress)).getRequestId(); + } + + private Boolean verifyClientAuth(DatagramPacket par1DatagramPacket) + { + SocketAddress socketaddress = par1DatagramPacket.getSocketAddress(); + + if (!this.queryClients.containsKey(socketaddress)) + { + return Boolean.valueOf(false); + } + else + { + byte[] abyte = par1DatagramPacket.getData(); + return ((RConThreadQuery.Auth)this.queryClients.get(socketaddress)).getRandomChallenge() != RConUtils.getBytesAsBEint(abyte, 7, par1DatagramPacket.getLength()) ? Boolean.valueOf(false) : Boolean.valueOf(true); + } + } + + private void sendAuthChallenge(DatagramPacket par1DatagramPacket) throws IOException + { + RConThreadQuery.Auth auth = new RConThreadQuery.Auth(par1DatagramPacket); + this.queryClients.put(par1DatagramPacket.getSocketAddress(), auth); + this.sendResponsePacket(auth.getChallengeValue(), par1DatagramPacket); + } + + private void cleanQueryClientsMap() + { + if (this.running) + { + long i = MinecraftServer.getSystemTimeMillis(); + + if (i >= this.lastAuthCheckTime + 30000L) + { + this.lastAuthCheckTime = i; + Iterator iterator = this.queryClients.entrySet().iterator(); + + while (iterator.hasNext()) + { + Entry entry = (Entry)iterator.next(); + + if (((RConThreadQuery.Auth)entry.getValue()).hasExpired(i).booleanValue()) + { + iterator.remove(); + } + } + } + } + } + + public void run() + { + this.logInfo("Query running on " + this.serverHostname + ":" + this.queryPort); + this.lastAuthCheckTime = MinecraftServer.getSystemTimeMillis(); + this.incomingPacket = new DatagramPacket(this.buffer, this.buffer.length); + + try + { + while (this.running) + { + try + { + this.querySocket.receive(this.incomingPacket); + this.cleanQueryClientsMap(); + this.parseIncomingPacket(this.incomingPacket); + } + catch (SocketTimeoutException sockettimeoutexception) + { + this.cleanQueryClientsMap(); + } + catch (PortUnreachableException portunreachableexception) + { + ; + } + catch (IOException ioexception) + { + this.stopWithException(ioexception); + } + } + } + finally + { + this.closeAllSockets(); + } + } + + public void startThread() + { + if (!this.running) + { + if (0 < this.queryPort && 65535 >= this.queryPort) + { + if (this.initQuerySystem()) + { + super.startThread(); + } + } + else + { + this.logWarning("Invalid query port " + this.queryPort + " found in \'" + this.server.getSettingsFilename() + "\' (queries disabled)"); + } + } + } + + private void stopWithException(Exception par1Exception) + { + if (this.running) + { + this.logWarning("Unexpected exception, buggy JRE? (" + par1Exception.toString() + ")"); + + if (!this.initQuerySystem()) + { + this.logSevere("Failed to recover from buggy JRE, shutting down!"); + this.running = false; + } + } + } + + private boolean initQuerySystem() + { + try + { + this.querySocket = new DatagramSocket(this.queryPort, InetAddress.getByName(this.serverHostname)); + this.registerSocket(this.querySocket); + this.querySocket.setSoTimeout(500); + return true; + } + catch (SocketException socketexception) + { + this.logWarning("Unable to initialise query system on " + this.serverHostname + ":" + this.queryPort + " (Socket): " + socketexception.getMessage()); + } + catch (UnknownHostException unknownhostexception) + { + this.logWarning("Unable to initialise query system on " + this.serverHostname + ":" + this.queryPort + " (Unknown Host): " + unknownhostexception.getMessage()); + } + catch (Exception exception) + { + this.logWarning("Unable to initialise query system on " + this.serverHostname + ":" + this.queryPort + " (E): " + exception.getMessage()); + } + + return false; + } + + @SideOnly(Side.SERVER) + class Auth + { + private long timestamp = (new Date()).getTime(); + private int randomChallenge; + private byte[] requestId; + private byte[] challengeValue; + private String requestIdAsString; + private static final String __OBFID = "CL_00001803"; + + public Auth(DatagramPacket par2DatagramPacket) + { + byte[] abyte = par2DatagramPacket.getData(); + this.requestId = new byte[4]; + this.requestId[0] = abyte[3]; + this.requestId[1] = abyte[4]; + this.requestId[2] = abyte[5]; + this.requestId[3] = abyte[6]; + this.requestIdAsString = new String(this.requestId); + this.randomChallenge = (new Random()).nextInt(16777216); + this.challengeValue = String.format("\t%s%d\u0000", new Object[] {this.requestIdAsString, Integer.valueOf(this.randomChallenge)}).getBytes(); + } + + public Boolean hasExpired(long par1) + { + return Boolean.valueOf(this.timestamp < par1); + } + + public int getRandomChallenge() + { + return this.randomChallenge; + } + + public byte[] getChallengeValue() + { + return this.challengeValue; + } + + public byte[] getRequestId() + { + return this.requestId; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/rcon/RConUtils.java b/src/main/java/net/minecraft/network/rcon/RConUtils.java new file mode 100644 index 0000000..9031fa5 --- /dev/null +++ b/src/main/java/net/minecraft/network/rcon/RConUtils.java @@ -0,0 +1,45 @@ +package net.minecraft.network.rcon; + +import com.google.common.base.Charsets; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.SERVER) +public class RConUtils +{ + public static char[] hexDigits = new char[] {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; + private static final String __OBFID = "CL_00001799"; + + public static String getBytesAsString(byte[] par0ArrayOfByte, int par1, int par2) + { + int k = par2 - 1; + int l; + + for (l = par1 > k ? k : par1; 0 != par0ArrayOfByte[l] && l < k; ++l) + { + ; + } + + return new String(par0ArrayOfByte, par1, l - par1, Charsets.UTF_8); + } + + public static int getRemainingBytesAsLEInt(byte[] par0ArrayOfByte, int par1) + { + return getBytesAsLEInt(par0ArrayOfByte, par1, par0ArrayOfByte.length); + } + + public static int getBytesAsLEInt(byte[] par0ArrayOfByte, int par1, int par2) + { + return 0 > par2 - par1 - 4 ? 0 : par0ArrayOfByte[par1 + 3] << 24 | (par0ArrayOfByte[par1 + 2] & 255) << 16 | (par0ArrayOfByte[par1 + 1] & 255) << 8 | par0ArrayOfByte[par1] & 255; + } + + public static int getBytesAsBEint(byte[] par0ArrayOfByte, int par1, int par2) + { + return 0 > par2 - par1 - 4 ? 0 : par0ArrayOfByte[par1] << 24 | (par0ArrayOfByte[par1 + 1] & 255) << 16 | (par0ArrayOfByte[par1 + 2] & 255) << 8 | par0ArrayOfByte[par1 + 3] & 255; + } + + public static String getByteAsHexString(byte par0) + { + return "" + hexDigits[(par0 & 240) >>> 4] + hexDigits[par0 & 15]; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/status/INetHandlerStatusClient.java b/src/main/java/net/minecraft/network/status/INetHandlerStatusClient.java new file mode 100644 index 0000000..aa84241 --- /dev/null +++ b/src/main/java/net/minecraft/network/status/INetHandlerStatusClient.java @@ -0,0 +1,12 @@ +package net.minecraft.network.status; + +import net.minecraft.network.INetHandler; +import net.minecraft.network.status.server.S00PacketServerInfo; +import net.minecraft.network.status.server.S01PacketPong; + +public interface INetHandlerStatusClient extends INetHandler +{ + void handleServerInfo(S00PacketServerInfo var1); + + void handlePong(S01PacketPong var1); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/status/INetHandlerStatusServer.java b/src/main/java/net/minecraft/network/status/INetHandlerStatusServer.java new file mode 100644 index 0000000..dd6e1d5 --- /dev/null +++ b/src/main/java/net/minecraft/network/status/INetHandlerStatusServer.java @@ -0,0 +1,12 @@ +package net.minecraft.network.status; + +import net.minecraft.network.INetHandler; +import net.minecraft.network.status.client.C00PacketServerQuery; +import net.minecraft.network.status.client.C01PacketPing; + +public interface INetHandlerStatusServer extends INetHandler +{ + void processPing(C01PacketPing var1); + + void processServerQuery(C00PacketServerQuery var1); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/status/client/C00PacketServerQuery.java b/src/main/java/net/minecraft/network/status/client/C00PacketServerQuery.java new file mode 100644 index 0000000..2aaee67 --- /dev/null +++ b/src/main/java/net/minecraft/network/status/client/C00PacketServerQuery.java @@ -0,0 +1,31 @@ +package net.minecraft.network.status.client; + +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.status.INetHandlerStatusServer; + +public class C00PacketServerQuery extends Packet +{ + private static final String __OBFID = "CL_00001393"; + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException {} + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException {} + + public void processPacket(INetHandlerStatusServer p_149287_1_) + { + p_149287_1_.processServerQuery(this); + } + + public boolean hasPriority() + { + return true; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerStatusServer)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/status/client/C01PacketPing.java b/src/main/java/net/minecraft/network/status/client/C01PacketPing.java new file mode 100644 index 0000000..30c11c6 --- /dev/null +++ b/src/main/java/net/minecraft/network/status/client/C01PacketPing.java @@ -0,0 +1,53 @@ +package net.minecraft.network.status.client; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.status.INetHandlerStatusServer; + +public class C01PacketPing extends Packet +{ + private long field_149290_a; + private static final String __OBFID = "CL_00001392"; + + public C01PacketPing() {} + + @SideOnly(Side.CLIENT) + public C01PacketPing(long p_i45276_1_) + { + this.field_149290_a = p_i45276_1_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149290_a = p_148837_1_.readLong(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeLong(this.field_149290_a); + } + + public void processPacket(INetHandlerStatusServer p_149288_1_) + { + p_149288_1_.processPing(this); + } + + public boolean hasPriority() + { + return true; + } + + public long func_149289_c() + { + return this.field_149290_a; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerStatusServer)p_148833_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/status/server/S00PacketServerInfo.java b/src/main/java/net/minecraft/network/status/server/S00PacketServerInfo.java new file mode 100644 index 0000000..158fa7e --- /dev/null +++ b/src/main/java/net/minecraft/network/status/server/S00PacketServerInfo.java @@ -0,0 +1,60 @@ +package net.minecraft.network.status.server; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.ServerStatusResponse; +import net.minecraft.network.status.INetHandlerStatusClient; +import net.minecraft.util.ChatStyle; +import net.minecraft.util.EnumTypeAdapterFactory; +import net.minecraft.util.IChatComponent; + +public class S00PacketServerInfo extends Packet +{ + private static final Gson field_149297_a = (new GsonBuilder()).registerTypeAdapter(ServerStatusResponse.MinecraftProtocolVersionIdentifier.class, new ServerStatusResponse.MinecraftProtocolVersionIdentifier.Serializer()).registerTypeAdapter(ServerStatusResponse.PlayerCountData.class, new ServerStatusResponse.PlayerCountData.Serializer()).registerTypeAdapter(ServerStatusResponse.class, new ServerStatusResponse.Serializer()).registerTypeHierarchyAdapter(IChatComponent.class, new IChatComponent.Serializer()).registerTypeHierarchyAdapter(ChatStyle.class, new ChatStyle.Serializer()).registerTypeAdapterFactory(new EnumTypeAdapterFactory()).create(); + private ServerStatusResponse field_149296_b; + private static final String __OBFID = "CL_00001384"; + + public S00PacketServerInfo() {} + + public S00PacketServerInfo(ServerStatusResponse p_i45273_1_) + { + this.field_149296_b = p_i45273_1_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149296_b = (ServerStatusResponse)field_149297_a.fromJson(p_148837_1_.readStringFromBuffer(32767), ServerStatusResponse.class); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeStringToBuffer(field_149297_a.toJson(this.field_149296_b)); + } + + public void processPacket(INetHandlerStatusClient p_149295_1_) + { + p_149295_1_.handleServerInfo(this); + } + + public boolean hasPriority() + { + return true; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerStatusClient)p_148833_1_); + } + + @SideOnly(Side.CLIENT) + public ServerStatusResponse func_149294_c() + { + return this.field_149296_b; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/network/status/server/S01PacketPong.java b/src/main/java/net/minecraft/network/status/server/S01PacketPong.java new file mode 100644 index 0000000..4cfe719 --- /dev/null +++ b/src/main/java/net/minecraft/network/status/server/S01PacketPong.java @@ -0,0 +1,53 @@ +package net.minecraft.network.status.server; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import net.minecraft.network.INetHandler; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.status.INetHandlerStatusClient; + +public class S01PacketPong extends Packet +{ + private long field_149293_a; + private static final String __OBFID = "CL_00001383"; + + public S01PacketPong() {} + + public S01PacketPong(long p_i45272_1_) + { + this.field_149293_a = p_i45272_1_; + } + + public void readPacketData(PacketBuffer p_148837_1_) throws IOException + { + this.field_149293_a = p_148837_1_.readLong(); + } + + public void writePacketData(PacketBuffer p_148840_1_) throws IOException + { + p_148840_1_.writeLong(this.field_149293_a); + } + + public void processPacket(INetHandlerStatusClient p_149291_1_) + { + p_149291_1_.handlePong(this); + } + + public boolean hasPriority() + { + return true; + } + + public void processPacket(INetHandler p_148833_1_) + { + this.processPacket((INetHandlerStatusClient)p_148833_1_); + } + + @SideOnly(Side.CLIENT) + public long func_149292_c() + { + return this.field_149293_a; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/pathfinding/Path.java b/src/main/java/net/minecraft/pathfinding/Path.java new file mode 100644 index 0000000..66f2c32 --- /dev/null +++ b/src/main/java/net/minecraft/pathfinding/Path.java @@ -0,0 +1,152 @@ +package net.minecraft.pathfinding; + +public class Path +{ + private PathPoint[] pathPoints = new PathPoint[1024]; + private int count; + private static final String __OBFID = "CL_00000573"; + + public PathPoint addPoint(PathPoint par1PathPoint) + { + if (par1PathPoint.index >= 0) + { + throw new IllegalStateException("OW KNOWS!"); + } + else + { + if (this.count == this.pathPoints.length) + { + PathPoint[] apathpoint = new PathPoint[this.count << 1]; + System.arraycopy(this.pathPoints, 0, apathpoint, 0, this.count); + this.pathPoints = apathpoint; + } + + this.pathPoints[this.count] = par1PathPoint; + par1PathPoint.index = this.count; + this.sortBack(this.count++); + return par1PathPoint; + } + } + + public void clearPath() + { + this.count = 0; + } + + public PathPoint dequeue() + { + PathPoint pathpoint = this.pathPoints[0]; + this.pathPoints[0] = this.pathPoints[--this.count]; + this.pathPoints[this.count] = null; + + if (this.count > 0) + { + this.sortForward(0); + } + + pathpoint.index = -1; + return pathpoint; + } + + public void changeDistance(PathPoint par1PathPoint, float par2) + { + float f1 = par1PathPoint.distanceToTarget; + par1PathPoint.distanceToTarget = par2; + + if (par2 < f1) + { + this.sortBack(par1PathPoint.index); + } + else + { + this.sortForward(par1PathPoint.index); + } + } + + private void sortBack(int par1) + { + PathPoint pathpoint = this.pathPoints[par1]; + int j; + + for (float f = pathpoint.distanceToTarget; par1 > 0; par1 = j) + { + j = par1 - 1 >> 1; + PathPoint pathpoint1 = this.pathPoints[j]; + + if (f >= pathpoint1.distanceToTarget) + { + break; + } + + this.pathPoints[par1] = pathpoint1; + pathpoint1.index = par1; + } + + this.pathPoints[par1] = pathpoint; + pathpoint.index = par1; + } + + private void sortForward(int par1) + { + PathPoint pathpoint = this.pathPoints[par1]; + float f = pathpoint.distanceToTarget; + + while (true) + { + int j = 1 + (par1 << 1); + int k = j + 1; + + if (j >= this.count) + { + break; + } + + PathPoint pathpoint1 = this.pathPoints[j]; + float f1 = pathpoint1.distanceToTarget; + PathPoint pathpoint2; + float f2; + + if (k >= this.count) + { + pathpoint2 = null; + f2 = Float.POSITIVE_INFINITY; + } + else + { + pathpoint2 = this.pathPoints[k]; + f2 = pathpoint2.distanceToTarget; + } + + if (f1 < f2) + { + if (f1 >= f) + { + break; + } + + this.pathPoints[par1] = pathpoint1; + pathpoint1.index = par1; + par1 = j; + } + else + { + if (f2 >= f) + { + break; + } + + this.pathPoints[par1] = pathpoint2; + pathpoint2.index = par1; + par1 = k; + } + } + + this.pathPoints[par1] = pathpoint; + pathpoint.index = par1; + } + + public boolean isPathEmpty() + { + return this.count == 0; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/pathfinding/PathEntity.java b/src/main/java/net/minecraft/pathfinding/PathEntity.java new file mode 100644 index 0000000..ff8a952 --- /dev/null +++ b/src/main/java/net/minecraft/pathfinding/PathEntity.java @@ -0,0 +1,101 @@ +package net.minecraft.pathfinding; + +import net.minecraft.entity.Entity; +import net.minecraft.util.Vec3; + +public class PathEntity +{ + private final PathPoint[] points; + private int currentPathIndex; + private int pathLength; + private static final String __OBFID = "CL_00000575"; + + public PathEntity(PathPoint[] par1ArrayOfPathPoint) + { + this.points = par1ArrayOfPathPoint; + this.pathLength = par1ArrayOfPathPoint.length; + } + + public void incrementPathIndex() + { + ++this.currentPathIndex; + } + + public boolean isFinished() + { + return this.currentPathIndex >= this.pathLength; + } + + public PathPoint getFinalPathPoint() + { + return this.pathLength > 0 ? this.points[this.pathLength - 1] : null; + } + + public PathPoint getPathPointFromIndex(int par1) + { + return this.points[par1]; + } + + public int getCurrentPathLength() + { + return this.pathLength; + } + + public void setCurrentPathLength(int par1) + { + this.pathLength = par1; + } + + public int getCurrentPathIndex() + { + return this.currentPathIndex; + } + + public void setCurrentPathIndex(int par1) + { + this.currentPathIndex = par1; + } + + public Vec3 getVectorFromIndex(Entity par1Entity, int par2) + { + double d0 = (double)this.points[par2].xCoord + (double)((int)(par1Entity.width + 1.0F)) * 0.5D; + double d1 = (double)this.points[par2].yCoord; + double d2 = (double)this.points[par2].zCoord + (double)((int)(par1Entity.width + 1.0F)) * 0.5D; + return par1Entity.worldObj.getWorldVec3Pool().getVecFromPool(d0, d1, d2); + } + + public Vec3 getPosition(Entity par1Entity) + { + return this.getVectorFromIndex(par1Entity, this.currentPathIndex); + } + + public boolean isSamePath(PathEntity par1PathEntity) + { + if (par1PathEntity == null) + { + return false; + } + else if (par1PathEntity.points.length != this.points.length) + { + return false; + } + else + { + for (int i = 0; i < this.points.length; ++i) + { + if (this.points[i].xCoord != par1PathEntity.points[i].xCoord || this.points[i].yCoord != par1PathEntity.points[i].yCoord || this.points[i].zCoord != par1PathEntity.points[i].zCoord) + { + return false; + } + } + + return true; + } + } + + public boolean isDestinationSame(Vec3 par1Vec3) + { + PathPoint pathpoint = this.getFinalPathPoint(); + return pathpoint == null ? false : pathpoint.xCoord == (int)par1Vec3.xCoord && pathpoint.zCoord == (int)par1Vec3.zCoord; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/pathfinding/PathFinder.java b/src/main/java/net/minecraft/pathfinding/PathFinder.java new file mode 100644 index 0000000..9371cd2 --- /dev/null +++ b/src/main/java/net/minecraft/pathfinding/PathFinder.java @@ -0,0 +1,357 @@ +package net.minecraft.pathfinding; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; +import net.minecraft.init.Blocks; +import net.minecraft.util.IntHashMap; +import net.minecraft.util.MathHelper; +import net.minecraft.world.IBlockAccess; + +public class PathFinder +{ + private IBlockAccess worldMap; + private Path path = new Path(); + private IntHashMap pointMap = new IntHashMap(); + private PathPoint[] pathOptions = new PathPoint[32]; + private boolean isWoddenDoorAllowed; + private boolean isMovementBlockAllowed; + private boolean isPathingInWater; + private boolean canEntityDrown; + private static final String __OBFID = "CL_00000576"; + + public PathFinder(IBlockAccess par1IBlockAccess, boolean par2, boolean par3, boolean par4, boolean par5) + { + this.worldMap = par1IBlockAccess; + this.isWoddenDoorAllowed = par2; + this.isMovementBlockAllowed = par3; + this.isPathingInWater = par4; + this.canEntityDrown = par5; + } + + public PathEntity createEntityPathTo(Entity par1Entity, Entity par2Entity, float par3) + { + return this.createEntityPathTo(par1Entity, par2Entity.posX, par2Entity.boundingBox.minY, par2Entity.posZ, par3); + } + + public PathEntity createEntityPathTo(Entity par1Entity, int par2, int par3, int par4, float par5) + { + return this.createEntityPathTo(par1Entity, (double)((float)par2 + 0.5F), (double)((float)par3 + 0.5F), (double)((float)par4 + 0.5F), par5); + } + + private PathEntity createEntityPathTo(Entity par1Entity, double par2, double par4, double par6, float par8) + { + this.path.clearPath(); + this.pointMap.clearMap(); + boolean flag = this.isPathingInWater; + int i = MathHelper.floor_double(par1Entity.boundingBox.minY + 0.5D); + + if (this.canEntityDrown && par1Entity.isInWater()) + { + i = (int)par1Entity.boundingBox.minY; + + for (Block block = this.worldMap.getBlock(MathHelper.floor_double(par1Entity.posX), i, MathHelper.floor_double(par1Entity.posZ)); block == Blocks.flowing_water || block == Blocks.water; block = this.worldMap.getBlock(MathHelper.floor_double(par1Entity.posX), i, MathHelper.floor_double(par1Entity.posZ))) + { + ++i; + } + + flag = this.isPathingInWater; + this.isPathingInWater = false; + } + else + { + i = MathHelper.floor_double(par1Entity.boundingBox.minY + 0.5D); + } + + PathPoint pathpoint2 = this.openPoint(MathHelper.floor_double(par1Entity.boundingBox.minX), i, MathHelper.floor_double(par1Entity.boundingBox.minZ)); + PathPoint pathpoint = this.openPoint(MathHelper.floor_double(par2 - (double)(par1Entity.width / 2.0F)), MathHelper.floor_double(par4), MathHelper.floor_double(par6 - (double)(par1Entity.width / 2.0F))); + PathPoint pathpoint1 = new PathPoint(MathHelper.floor_float(par1Entity.width + 1.0F), MathHelper.floor_float(par1Entity.height + 1.0F), MathHelper.floor_float(par1Entity.width + 1.0F)); + PathEntity pathentity = this.addToPath(par1Entity, pathpoint2, pathpoint, pathpoint1, par8); + this.isPathingInWater = flag; + return pathentity; + } + + private PathEntity addToPath(Entity par1Entity, PathPoint par2PathPoint, PathPoint par3PathPoint, PathPoint par4PathPoint, float par5) + { + par2PathPoint.totalPathDistance = 0.0F; + par2PathPoint.distanceToNext = par2PathPoint.distanceToSquared(par3PathPoint); + par2PathPoint.distanceToTarget = par2PathPoint.distanceToNext; + this.path.clearPath(); + this.path.addPoint(par2PathPoint); + PathPoint pathpoint3 = par2PathPoint; + + while (!this.path.isPathEmpty()) + { + PathPoint pathpoint4 = this.path.dequeue(); + + if (pathpoint4.equals(par3PathPoint)) + { + return this.createEntityPath(par2PathPoint, par3PathPoint); + } + + if (pathpoint4.distanceToSquared(par3PathPoint) < pathpoint3.distanceToSquared(par3PathPoint)) + { + pathpoint3 = pathpoint4; + } + + pathpoint4.isFirst = true; + int i = this.findPathOptions(par1Entity, pathpoint4, par4PathPoint, par3PathPoint, par5); + + for (int j = 0; j < i; ++j) + { + PathPoint pathpoint5 = this.pathOptions[j]; + float f1 = pathpoint4.totalPathDistance + pathpoint4.distanceToSquared(pathpoint5); + + if (!pathpoint5.isAssigned() || f1 < pathpoint5.totalPathDistance) + { + pathpoint5.previous = pathpoint4; + pathpoint5.totalPathDistance = f1; + pathpoint5.distanceToNext = pathpoint5.distanceToSquared(par3PathPoint); + + if (pathpoint5.isAssigned()) + { + this.path.changeDistance(pathpoint5, pathpoint5.totalPathDistance + pathpoint5.distanceToNext); + } + else + { + pathpoint5.distanceToTarget = pathpoint5.totalPathDistance + pathpoint5.distanceToNext; + this.path.addPoint(pathpoint5); + } + } + } + } + + if (pathpoint3 == par2PathPoint) + { + return null; + } + else + { + return this.createEntityPath(par2PathPoint, pathpoint3); + } + } + + private int findPathOptions(Entity par1Entity, PathPoint par2PathPoint, PathPoint par3PathPoint, PathPoint par4PathPoint, float par5) + { + int i = 0; + byte b0 = 0; + + if (this.getVerticalOffset(par1Entity, par2PathPoint.xCoord, par2PathPoint.yCoord + 1, par2PathPoint.zCoord, par3PathPoint) == 1) + { + b0 = 1; + } + + PathPoint pathpoint3 = this.getSafePoint(par1Entity, par2PathPoint.xCoord, par2PathPoint.yCoord, par2PathPoint.zCoord + 1, par3PathPoint, b0); + PathPoint pathpoint4 = this.getSafePoint(par1Entity, par2PathPoint.xCoord - 1, par2PathPoint.yCoord, par2PathPoint.zCoord, par3PathPoint, b0); + PathPoint pathpoint5 = this.getSafePoint(par1Entity, par2PathPoint.xCoord + 1, par2PathPoint.yCoord, par2PathPoint.zCoord, par3PathPoint, b0); + PathPoint pathpoint6 = this.getSafePoint(par1Entity, par2PathPoint.xCoord, par2PathPoint.yCoord, par2PathPoint.zCoord - 1, par3PathPoint, b0); + + if (pathpoint3 != null && !pathpoint3.isFirst && pathpoint3.distanceTo(par4PathPoint) < par5) + { + this.pathOptions[i++] = pathpoint3; + } + + if (pathpoint4 != null && !pathpoint4.isFirst && pathpoint4.distanceTo(par4PathPoint) < par5) + { + this.pathOptions[i++] = pathpoint4; + } + + if (pathpoint5 != null && !pathpoint5.isFirst && pathpoint5.distanceTo(par4PathPoint) < par5) + { + this.pathOptions[i++] = pathpoint5; + } + + if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(par4PathPoint) < par5) + { + this.pathOptions[i++] = pathpoint6; + } + + return i; + } + + private PathPoint getSafePoint(Entity par1Entity, int par2, int par3, int par4, PathPoint par5PathPoint, int par6) + { + PathPoint pathpoint1 = null; + int i1 = this.getVerticalOffset(par1Entity, par2, par3, par4, par5PathPoint); + + if (i1 == 2) + { + return this.openPoint(par2, par3, par4); + } + else + { + if (i1 == 1) + { + pathpoint1 = this.openPoint(par2, par3, par4); + } + + if (pathpoint1 == null && par6 > 0 && i1 != -3 && i1 != -4 && this.getVerticalOffset(par1Entity, par2, par3 + par6, par4, par5PathPoint) == 1) + { + pathpoint1 = this.openPoint(par2, par3 + par6, par4); + par3 += par6; + } + + if (pathpoint1 != null) + { + int j1 = 0; + int k1 = 0; + + while (par3 > 0) + { + k1 = this.getVerticalOffset(par1Entity, par2, par3 - 1, par4, par5PathPoint); + + if (this.isPathingInWater && k1 == -1) + { + return null; + } + + if (k1 != 1) + { + break; + } + + if (j1++ >= par1Entity.getMaxSafePointTries()) + { + return null; + } + + --par3; + + if (par3 > 0) + { + pathpoint1 = this.openPoint(par2, par3, par4); + } + } + + if (k1 == -2) + { + return null; + } + } + + return pathpoint1; + } + } + + private final PathPoint openPoint(int par1, int par2, int par3) + { + int l = PathPoint.makeHash(par1, par2, par3); + PathPoint pathpoint = (PathPoint)this.pointMap.lookup(l); + + if (pathpoint == null) + { + pathpoint = new PathPoint(par1, par2, par3); + this.pointMap.addKey(l, pathpoint); + } + + return pathpoint; + } + + public int getVerticalOffset(Entity par1Entity, int par2, int par3, int par4, PathPoint par5PathPoint) + { + return func_82565_a(par1Entity, par2, par3, par4, par5PathPoint, this.isPathingInWater, this.isMovementBlockAllowed, this.isWoddenDoorAllowed); + } + + public static int func_82565_a(Entity par0Entity, int par1, int par2, int par3, PathPoint par4PathPoint, boolean par5, boolean par6, boolean par7) + { + boolean flag3 = false; + + for (int l = par1; l < par1 + par4PathPoint.xCoord; ++l) + { + for (int i1 = par2; i1 < par2 + par4PathPoint.yCoord; ++i1) + { + for (int j1 = par3; j1 < par3 + par4PathPoint.zCoord; ++j1) + { + Block block = par0Entity.worldObj.getBlock(l, i1, j1); + + if (block.getMaterial() != Material.air) + { + if (block == Blocks.trapdoor) + { + flag3 = true; + } + else if (block != Blocks.flowing_water && block != Blocks.water) + { + if (!par7 && block == Blocks.wooden_door) + { + return 0; + } + } + else + { + if (par5) + { + return -1; + } + + flag3 = true; + } + + int k1 = block.getRenderType(); + + if (par0Entity.worldObj.getBlock(l, i1, j1).getRenderType() == 9) + { + int j2 = MathHelper.floor_double(par0Entity.posX); + int l1 = MathHelper.floor_double(par0Entity.posY); + int i2 = MathHelper.floor_double(par0Entity.posZ); + + if (par0Entity.worldObj.getBlock(j2, l1, i2).getRenderType() != 9 && par0Entity.worldObj.getBlock(j2, l1 - 1, i2).getRenderType() != 9) + { + return -3; + } + } + else if (!block.getBlocksMovement(par0Entity.worldObj, l, i1, j1) && (!par6 || block != Blocks.wooden_door)) + { + if (k1 == 11 || block == Blocks.fence_gate || k1 == 32) + { + return -3; + } + + if (block == Blocks.trapdoor) + { + return -4; + } + + Material material = block.getMaterial(); + + if (material != Material.lava) + { + return 0; + } + + if (!par0Entity.handleLavaMovement()) + { + return -2; + } + } + } + } + } + } + + return flag3 ? 2 : 1; + } + + private PathEntity createEntityPath(PathPoint par1PathPoint, PathPoint par2PathPoint) + { + int i = 1; + PathPoint pathpoint2; + + for (pathpoint2 = par2PathPoint; pathpoint2.previous != null; pathpoint2 = pathpoint2.previous) + { + ++i; + } + + PathPoint[] apathpoint = new PathPoint[i]; + pathpoint2 = par2PathPoint; + --i; + + for (apathpoint[i] = par2PathPoint; pathpoint2.previous != null; apathpoint[i] = pathpoint2) + { + pathpoint2 = pathpoint2.previous; + --i; + } + + return new PathEntity(apathpoint); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/pathfinding/PathNavigate.java b/src/main/java/net/minecraft/pathfinding/PathNavigate.java new file mode 100644 index 0000000..2c766cc --- /dev/null +++ b/src/main/java/net/minecraft/pathfinding/PathNavigate.java @@ -0,0 +1,442 @@ +package net.minecraft.pathfinding; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.attributes.IAttributeInstance; +import net.minecraft.init.Blocks; +import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; + +public class PathNavigate +{ + private EntityLiving theEntity; + private World worldObj; + private PathEntity currentPath; + private double speed; + private IAttributeInstance pathSearchRange; + private boolean noSunPathfind; + private int totalTicks; + private int ticksAtLastPos; + private Vec3 lastPosCheck = Vec3.createVectorHelper(0.0D, 0.0D, 0.0D); + private boolean canPassOpenWoodenDoors = true; + private boolean canPassClosedWoodenDoors; + private boolean avoidsWater; + private boolean canSwim; + private static final String __OBFID = "CL_00001627"; + + public PathNavigate(EntityLiving par1EntityLiving, World par2World) + { + this.theEntity = par1EntityLiving; + this.worldObj = par2World; + this.pathSearchRange = par1EntityLiving.getEntityAttribute(SharedMonsterAttributes.followRange); + } + + public void setAvoidsWater(boolean par1) + { + this.avoidsWater = par1; + } + + public boolean getAvoidsWater() + { + return this.avoidsWater; + } + + public void setBreakDoors(boolean par1) + { + this.canPassClosedWoodenDoors = par1; + } + + public void setEnterDoors(boolean par1) + { + this.canPassOpenWoodenDoors = par1; + } + + public boolean getCanBreakDoors() + { + return this.canPassClosedWoodenDoors; + } + + public void setAvoidSun(boolean par1) + { + this.noSunPathfind = par1; + } + + public void setSpeed(double par1) + { + this.speed = par1; + } + + public void setCanSwim(boolean par1) + { + this.canSwim = par1; + } + + public float getPathSearchRange() + { + return (float)this.pathSearchRange.getAttributeValue(); + } + + public PathEntity getPathToXYZ(double par1, double par3, double par5) + { + return !this.canNavigate() ? null : this.worldObj.getEntityPathToXYZ(this.theEntity, MathHelper.floor_double(par1), (int)par3, MathHelper.floor_double(par5), this.getPathSearchRange(), this.canPassOpenWoodenDoors, this.canPassClosedWoodenDoors, this.avoidsWater, this.canSwim); + } + + public boolean tryMoveToXYZ(double par1, double par3, double par5, double par7) + { + PathEntity pathentity = this.getPathToXYZ((double)MathHelper.floor_double(par1), (double)((int)par3), (double)MathHelper.floor_double(par5)); + return this.setPath(pathentity, par7); + } + + public PathEntity getPathToEntityLiving(Entity par1Entity) + { + return !this.canNavigate() ? null : this.worldObj.getPathEntityToEntity(this.theEntity, par1Entity, this.getPathSearchRange(), this.canPassOpenWoodenDoors, this.canPassClosedWoodenDoors, this.avoidsWater, this.canSwim); + } + + public boolean tryMoveToEntityLiving(Entity par1Entity, double par2) + { + PathEntity pathentity = this.getPathToEntityLiving(par1Entity); + return pathentity != null ? this.setPath(pathentity, par2) : false; + } + + public boolean setPath(PathEntity par1PathEntity, double par2) + { + if (par1PathEntity == null) + { + this.currentPath = null; + return false; + } + else + { + if (!par1PathEntity.isSamePath(this.currentPath)) + { + this.currentPath = par1PathEntity; + } + + if (this.noSunPathfind) + { + this.removeSunnyPath(); + } + + if (this.currentPath.getCurrentPathLength() == 0) + { + return false; + } + else + { + this.speed = par2; + Vec3 vec3 = this.getEntityPosition(); + this.ticksAtLastPos = this.totalTicks; + this.lastPosCheck.xCoord = vec3.xCoord; + this.lastPosCheck.yCoord = vec3.yCoord; + this.lastPosCheck.zCoord = vec3.zCoord; + return true; + } + } + } + + public PathEntity getPath() + { + return this.currentPath; + } + + public void onUpdateNavigation() + { + ++this.totalTicks; + + if (!this.noPath()) + { + if (this.canNavigate()) + { + this.pathFollow(); + } + + if (!this.noPath()) + { + Vec3 vec3 = this.currentPath.getPosition(this.theEntity); + + if (vec3 != null) + { + this.theEntity.getMoveHelper().setMoveTo(vec3.xCoord, vec3.yCoord, vec3.zCoord, this.speed); + } + } + } + } + + private void pathFollow() + { + Vec3 vec3 = this.getEntityPosition(); + int i = this.currentPath.getCurrentPathLength(); + + for (int j = this.currentPath.getCurrentPathIndex(); j < this.currentPath.getCurrentPathLength(); ++j) + { + if (this.currentPath.getPathPointFromIndex(j).yCoord != (int)vec3.yCoord) + { + i = j; + break; + } + } + + float f = this.theEntity.width * this.theEntity.width; + int k; + + for (k = this.currentPath.getCurrentPathIndex(); k < i; ++k) + { + if (vec3.squareDistanceTo(this.currentPath.getVectorFromIndex(this.theEntity, k)) < (double)f) + { + this.currentPath.setCurrentPathIndex(k + 1); + } + } + + k = MathHelper.ceiling_float_int(this.theEntity.width); + int l = (int)this.theEntity.height + 1; + int i1 = k; + + for (int j1 = i - 1; j1 >= this.currentPath.getCurrentPathIndex(); --j1) + { + if (this.isDirectPathBetweenPoints(vec3, this.currentPath.getVectorFromIndex(this.theEntity, j1), k, l, i1)) + { + this.currentPath.setCurrentPathIndex(j1); + break; + } + } + + if (this.totalTicks - this.ticksAtLastPos > 100) + { + if (vec3.squareDistanceTo(this.lastPosCheck) < 2.25D) + { + this.clearPathEntity(); + } + + this.ticksAtLastPos = this.totalTicks; + this.lastPosCheck.xCoord = vec3.xCoord; + this.lastPosCheck.yCoord = vec3.yCoord; + this.lastPosCheck.zCoord = vec3.zCoord; + } + } + + public boolean noPath() + { + return this.currentPath == null || this.currentPath.isFinished(); + } + + public void clearPathEntity() + { + this.currentPath = null; + } + + private Vec3 getEntityPosition() + { + return this.worldObj.getWorldVec3Pool().getVecFromPool(this.theEntity.posX, (double)this.getPathableYPos(), this.theEntity.posZ); + } + + private int getPathableYPos() + { + if (this.theEntity.isInWater() && this.canSwim) + { + int i = (int)this.theEntity.boundingBox.minY; + Block block = this.worldObj.getBlock(MathHelper.floor_double(this.theEntity.posX), i, MathHelper.floor_double(this.theEntity.posZ)); + int j = 0; + + do + { + if (block != Blocks.flowing_water && block != Blocks.water) + { + return i; + } + + ++i; + block = this.worldObj.getBlock(MathHelper.floor_double(this.theEntity.posX), i, MathHelper.floor_double(this.theEntity.posZ)); + ++j; + } + while (j <= 16); + + return (int)this.theEntity.boundingBox.minY; + } + else + { + return (int)(this.theEntity.boundingBox.minY + 0.5D); + } + } + + private boolean canNavigate() + { + return this.theEntity.onGround || this.canSwim && this.isInLiquid(); + } + + private boolean isInLiquid() + { + return this.theEntity.isInWater() || this.theEntity.handleLavaMovement(); + } + + private void removeSunnyPath() + { + if (!this.worldObj.canBlockSeeTheSky(MathHelper.floor_double(this.theEntity.posX), (int)(this.theEntity.boundingBox.minY + 0.5D), MathHelper.floor_double(this.theEntity.posZ))) + { + for (int i = 0; i < this.currentPath.getCurrentPathLength(); ++i) + { + PathPoint pathpoint = this.currentPath.getPathPointFromIndex(i); + + if (this.worldObj.canBlockSeeTheSky(pathpoint.xCoord, pathpoint.yCoord, pathpoint.zCoord)) + { + this.currentPath.setCurrentPathLength(i - 1); + return; + } + } + } + } + + private boolean isDirectPathBetweenPoints(Vec3 par1Vec3, Vec3 par2Vec3, int par3, int par4, int par5) + { + int l = MathHelper.floor_double(par1Vec3.xCoord); + int i1 = MathHelper.floor_double(par1Vec3.zCoord); + double d0 = par2Vec3.xCoord - par1Vec3.xCoord; + double d1 = par2Vec3.zCoord - par1Vec3.zCoord; + double d2 = d0 * d0 + d1 * d1; + + if (d2 < 1.0E-8D) + { + return false; + } + else + { + double d3 = 1.0D / Math.sqrt(d2); + d0 *= d3; + d1 *= d3; + par3 += 2; + par5 += 2; + + if (!this.isSafeToStandAt(l, (int)par1Vec3.yCoord, i1, par3, par4, par5, par1Vec3, d0, d1)) + { + return false; + } + else + { + par3 -= 2; + par5 -= 2; + double d4 = 1.0D / Math.abs(d0); + double d5 = 1.0D / Math.abs(d1); + double d6 = (double)(l * 1) - par1Vec3.xCoord; + double d7 = (double)(i1 * 1) - par1Vec3.zCoord; + + if (d0 >= 0.0D) + { + ++d6; + } + + if (d1 >= 0.0D) + { + ++d7; + } + + d6 /= d0; + d7 /= d1; + int j1 = d0 < 0.0D ? -1 : 1; + int k1 = d1 < 0.0D ? -1 : 1; + int l1 = MathHelper.floor_double(par2Vec3.xCoord); + int i2 = MathHelper.floor_double(par2Vec3.zCoord); + int j2 = l1 - l; + int k2 = i2 - i1; + + do + { + if (j2 * j1 <= 0 && k2 * k1 <= 0) + { + return true; + } + + if (d6 < d7) + { + d6 += d4; + l += j1; + j2 = l1 - l; + } + else + { + d7 += d5; + i1 += k1; + k2 = i2 - i1; + } + } + while (this.isSafeToStandAt(l, (int)par1Vec3.yCoord, i1, par3, par4, par5, par1Vec3, d0, d1)); + + return false; + } + } + } + + private boolean isSafeToStandAt(int par1, int par2, int par3, int par4, int par5, int par6, Vec3 par7Vec3, double par8, double par10) + { + int k1 = par1 - par4 / 2; + int l1 = par3 - par6 / 2; + + if (!this.isPositionClear(k1, par2, l1, par4, par5, par6, par7Vec3, par8, par10)) + { + return false; + } + else + { + for (int i2 = k1; i2 < k1 + par4; ++i2) + { + for (int j2 = l1; j2 < l1 + par6; ++j2) + { + double d2 = (double)i2 + 0.5D - par7Vec3.xCoord; + double d3 = (double)j2 + 0.5D - par7Vec3.zCoord; + + if (d2 * par8 + d3 * par10 >= 0.0D) + { + Block block = this.worldObj.getBlock(i2, par2 - 1, j2); + Material material = block.getMaterial(); + + if (material == Material.air) + { + return false; + } + + if (material == Material.water && !this.theEntity.isInWater()) + { + return false; + } + + if (material == Material.lava) + { + return false; + } + } + } + } + + return true; + } + } + + private boolean isPositionClear(int par1, int par2, int par3, int par4, int par5, int par6, Vec3 par7Vec3, double par8, double par10) + { + for (int k1 = par1; k1 < par1 + par4; ++k1) + { + for (int l1 = par2; l1 < par2 + par5; ++l1) + { + for (int i2 = par3; i2 < par3 + par6; ++i2) + { + double d2 = (double)k1 + 0.5D - par7Vec3.xCoord; + double d3 = (double)i2 + 0.5D - par7Vec3.zCoord; + + if (d2 * par8 + d3 * par10 >= 0.0D) + { + Block block = this.worldObj.getBlock(k1, l1, i2); + + if (!block.getBlocksMovement(this.worldObj, k1, l1, i2)) + { + return false; + } + } + } + } + } + + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/pathfinding/PathPoint.java b/src/main/java/net/minecraft/pathfinding/PathPoint.java new file mode 100644 index 0000000..70b44b9 --- /dev/null +++ b/src/main/java/net/minecraft/pathfinding/PathPoint.java @@ -0,0 +1,75 @@ +package net.minecraft.pathfinding; + +import net.minecraft.util.MathHelper; + +public class PathPoint +{ + public final int xCoord; + public final int yCoord; + public final int zCoord; + private final int hash; + int index = -1; + float totalPathDistance; + float distanceToNext; + float distanceToTarget; + PathPoint previous; + public boolean isFirst; + private static final String __OBFID = "CL_00000574"; + + public PathPoint(int par1, int par2, int par3) + { + this.xCoord = par1; + this.yCoord = par2; + this.zCoord = par3; + this.hash = makeHash(par1, par2, par3); + } + + public static int makeHash(int par0, int par1, int par2) + { + return par1 & 255 | (par0 & 32767) << 8 | (par2 & 32767) << 24 | (par0 < 0 ? Integer.MIN_VALUE : 0) | (par2 < 0 ? 32768 : 0); + } + + public float distanceTo(PathPoint par1PathPoint) + { + float f = (float)(par1PathPoint.xCoord - this.xCoord); + float f1 = (float)(par1PathPoint.yCoord - this.yCoord); + float f2 = (float)(par1PathPoint.zCoord - this.zCoord); + return MathHelper.sqrt_float(f * f + f1 * f1 + f2 * f2); + } + + public float distanceToSquared(PathPoint par1PathPoint) + { + float f = (float)(par1PathPoint.xCoord - this.xCoord); + float f1 = (float)(par1PathPoint.yCoord - this.yCoord); + float f2 = (float)(par1PathPoint.zCoord - this.zCoord); + return f * f + f1 * f1 + f2 * f2; + } + + public boolean equals(Object par1Obj) + { + if (!(par1Obj instanceof PathPoint)) + { + return false; + } + else + { + PathPoint pathpoint = (PathPoint)par1Obj; + return this.hash == pathpoint.hash && this.xCoord == pathpoint.xCoord && this.yCoord == pathpoint.yCoord && this.zCoord == pathpoint.zCoord; + } + } + + public int hashCode() + { + return this.hash; + } + + public boolean isAssigned() + { + return this.index >= 0; + } + + public String toString() + { + return this.xCoord + ", " + this.yCoord + ", " + this.zCoord; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/potion/Potion.java b/src/main/java/net/minecraft/potion/Potion.java new file mode 100644 index 0000000..ff18717 --- /dev/null +++ b/src/main/java/net/minecraft/potion/Potion.java @@ -0,0 +1,310 @@ +package net.minecraft.potion; + +import com.google.common.collect.Maps; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Iterator; +import java.util.Map; +import java.util.UUID; +import java.util.Map.Entry; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.attributes.AttributeModifier; +import net.minecraft.entity.ai.attributes.BaseAttributeMap; +import net.minecraft.entity.ai.attributes.IAttribute; +import net.minecraft.entity.ai.attributes.IAttributeInstance; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.DamageSource; +import net.minecraft.util.StringUtils; + +public class Potion +{ + public static final Potion[] potionTypes = new Potion[32]; + public static final Potion field_76423_b = null; + public static final Potion moveSpeed = (new Potion(1, false, 8171462)).setPotionName("potion.moveSpeed").setIconIndex(0, 0).func_111184_a(SharedMonsterAttributes.movementSpeed, "91AEAA56-376B-4498-935B-2F7F68070635", 0.20000000298023224D, 2); + public static final Potion moveSlowdown = (new Potion(2, true, 5926017)).setPotionName("potion.moveSlowdown").setIconIndex(1, 0).func_111184_a(SharedMonsterAttributes.movementSpeed, "7107DE5E-7CE8-4030-940E-514C1F160890", -0.15000000596046448D, 2); + public static final Potion digSpeed = (new Potion(3, false, 14270531)).setPotionName("potion.digSpeed").setIconIndex(2, 0).setEffectiveness(1.5D); + public static final Potion digSlowdown = (new Potion(4, true, 4866583)).setPotionName("potion.digSlowDown").setIconIndex(3, 0); + public static final Potion damageBoost = (new PotionAttackDamage(5, false, 9643043)).setPotionName("potion.damageBoost").setIconIndex(4, 0).func_111184_a(SharedMonsterAttributes.attackDamage, "648D7064-6A60-4F59-8ABE-C2C23A6DD7A9", 3.0D, 2); + public static final Potion heal = (new PotionHealth(6, false, 16262179)).setPotionName("potion.heal"); + public static final Potion harm = (new PotionHealth(7, true, 4393481)).setPotionName("potion.harm"); + public static final Potion jump = (new Potion(8, false, 7889559)).setPotionName("potion.jump").setIconIndex(2, 1); + public static final Potion confusion = (new Potion(9, true, 5578058)).setPotionName("potion.confusion").setIconIndex(3, 1).setEffectiveness(0.25D); + public static final Potion regeneration = (new Potion(10, false, 13458603)).setPotionName("potion.regeneration").setIconIndex(7, 0).setEffectiveness(0.25D); + public static final Potion resistance = (new Potion(11, false, 10044730)).setPotionName("potion.resistance").setIconIndex(6, 1); + public static final Potion fireResistance = (new Potion(12, false, 14981690)).setPotionName("potion.fireResistance").setIconIndex(7, 1); + public static final Potion waterBreathing = (new Potion(13, false, 3035801)).setPotionName("potion.waterBreathing").setIconIndex(0, 2); + public static final Potion invisibility = (new Potion(14, false, 8356754)).setPotionName("potion.invisibility").setIconIndex(0, 1); + public static final Potion blindness = (new Potion(15, true, 2039587)).setPotionName("potion.blindness").setIconIndex(5, 1).setEffectiveness(0.25D); + public static final Potion nightVision = (new Potion(16, false, 2039713)).setPotionName("potion.nightVision").setIconIndex(4, 1); + public static final Potion hunger = (new Potion(17, true, 5797459)).setPotionName("potion.hunger").setIconIndex(1, 1); + public static final Potion weakness = (new PotionAttackDamage(18, true, 4738376)).setPotionName("potion.weakness").setIconIndex(5, 0).func_111184_a(SharedMonsterAttributes.attackDamage, "22653B89-116E-49DC-9B6B-9971489B5BE5", 2.0D, 0); + public static final Potion poison = (new Potion(19, true, 5149489)).setPotionName("potion.poison").setIconIndex(6, 0).setEffectiveness(0.25D); + public static final Potion wither = (new Potion(20, true, 3484199)).setPotionName("potion.wither").setIconIndex(1, 2).setEffectiveness(0.25D); + public static final Potion field_76434_w = (new PotionHealthBoost(21, false, 16284963)).setPotionName("potion.healthBoost").setIconIndex(2, 2).func_111184_a(SharedMonsterAttributes.maxHealth, "5D6F0BA2-1186-46AC-B896-C61C5CEE99CC", 4.0D, 0); + public static final Potion field_76444_x = (new PotionAbsoption(22, false, 2445989)).setPotionName("potion.absorption").setIconIndex(2, 2); + public static final Potion field_76443_y = (new PotionHealth(23, false, 16262179)).setPotionName("potion.saturation"); + public static final Potion field_76442_z = null; + public static final Potion field_76409_A = null; + public static final Potion field_76410_B = null; + public static final Potion field_76411_C = null; + public static final Potion field_76405_D = null; + public static final Potion field_76406_E = null; + public static final Potion field_76407_F = null; + public static final Potion field_76408_G = null; + public final int id; + private final Map field_111188_I = Maps.newHashMap(); + private final boolean isBadEffect; + private final int liquidColor; + private String name = ""; + private int statusIconIndex = -1; + private double effectiveness; + private boolean usable; + private static final String __OBFID = "CL_00001528"; + + protected Potion(int par1, boolean par2, int par3) + { + this.id = par1; + potionTypes[par1] = this; + this.isBadEffect = par2; + + if (par2) + { + this.effectiveness = 0.5D; + } + else + { + this.effectiveness = 1.0D; + } + + this.liquidColor = par3; + } + + protected Potion setIconIndex(int par1, int par2) + { + this.statusIconIndex = par1 + par2 * 8; + return this; + } + + public int getId() + { + return this.id; + } + + public void performEffect(EntityLivingBase par1EntityLivingBase, int par2) + { + if (this.id == regeneration.id) + { + if (par1EntityLivingBase.getHealth() < par1EntityLivingBase.getMaxHealth()) + { + par1EntityLivingBase.heal(1.0F); + } + } + else if (this.id == poison.id) + { + if (par1EntityLivingBase.getHealth() > 1.0F) + { + par1EntityLivingBase.attackEntityFrom(DamageSource.magic, 1.0F); + } + } + else if (this.id == wither.id) + { + par1EntityLivingBase.attackEntityFrom(DamageSource.wither, 1.0F); + } + else if (this.id == hunger.id && par1EntityLivingBase instanceof EntityPlayer) + { + ((EntityPlayer)par1EntityLivingBase).addExhaustion(0.025F * (float)(par2 + 1)); + } + else if (this.id == field_76443_y.id && par1EntityLivingBase instanceof EntityPlayer) + { + if (!par1EntityLivingBase.worldObj.isRemote) + { + ((EntityPlayer)par1EntityLivingBase).getFoodStats().addStats(par2 + 1, 1.0F); + } + } + else if ((this.id != heal.id || par1EntityLivingBase.isEntityUndead()) && (this.id != harm.id || !par1EntityLivingBase.isEntityUndead())) + { + if (this.id == harm.id && !par1EntityLivingBase.isEntityUndead() || this.id == heal.id && par1EntityLivingBase.isEntityUndead()) + { + par1EntityLivingBase.attackEntityFrom(DamageSource.magic, (float)(6 << par2)); + } + } + else + { + par1EntityLivingBase.heal((float)Math.max(4 << par2, 0)); + } + } + + public void affectEntity(EntityLivingBase par1EntityLivingBase, EntityLivingBase par2EntityLivingBase, int par3, double par4) + { + int j; + + if ((this.id != heal.id || par2EntityLivingBase.isEntityUndead()) && (this.id != harm.id || !par2EntityLivingBase.isEntityUndead())) + { + if (this.id == harm.id && !par2EntityLivingBase.isEntityUndead() || this.id == heal.id && par2EntityLivingBase.isEntityUndead()) + { + j = (int)(par4 * (double)(6 << par3) + 0.5D); + + if (par1EntityLivingBase == null) + { + par2EntityLivingBase.attackEntityFrom(DamageSource.magic, (float)j); + } + else + { + par2EntityLivingBase.attackEntityFrom(DamageSource.causeIndirectMagicDamage(par2EntityLivingBase, par1EntityLivingBase), (float)j); + } + } + } + else + { + j = (int)(par4 * (double)(4 << par3) + 0.5D); + par2EntityLivingBase.heal((float)j); + } + } + + public boolean isInstant() + { + return false; + } + + public boolean isReady(int par1, int par2) + { + int k; + + if (this.id == regeneration.id) + { + k = 50 >> par2; + return k > 0 ? par1 % k == 0 : true; + } + else if (this.id == poison.id) + { + k = 25 >> par2; + return k > 0 ? par1 % k == 0 : true; + } + else if (this.id == wither.id) + { + k = 40 >> par2; + return k > 0 ? par1 % k == 0 : true; + } + else + { + return this.id == hunger.id; + } + } + + public Potion setPotionName(String par1Str) + { + this.name = par1Str; + return this; + } + + public String getName() + { + return this.name; + } + + protected Potion setEffectiveness(double par1) + { + this.effectiveness = par1; + return this; + } + + @SideOnly(Side.CLIENT) + public boolean hasStatusIcon() + { + return this.statusIconIndex >= 0; + } + + @SideOnly(Side.CLIENT) + public int getStatusIconIndex() + { + return this.statusIconIndex; + } + + @SideOnly(Side.CLIENT) + public boolean isBadEffect() + { + return this.isBadEffect; + } + + @SideOnly(Side.CLIENT) + public static String getDurationString(PotionEffect par0PotionEffect) + { + if (par0PotionEffect.getIsPotionDurationMax()) + { + return "**:**"; + } + else + { + int i = par0PotionEffect.getDuration(); + return StringUtils.ticksToElapsedTime(i); + } + } + + public double getEffectiveness() + { + return this.effectiveness; + } + + public boolean isUsable() + { + return this.usable; + } + + public int getLiquidColor() + { + return this.liquidColor; + } + + public Potion func_111184_a(IAttribute par1Attribute, String par2Str, double par3, int par5) + { + AttributeModifier attributemodifier = new AttributeModifier(UUID.fromString(par2Str), this.getName(), par3, par5); + this.field_111188_I.put(par1Attribute, attributemodifier); + return this; + } + + public void removeAttributesModifiersFromEntity(EntityLivingBase par1EntityLivingBase, BaseAttributeMap par2BaseAttributeMap, int par3) + { + Iterator iterator = this.field_111188_I.entrySet().iterator(); + + while (iterator.hasNext()) + { + Entry entry = (Entry)iterator.next(); + IAttributeInstance iattributeinstance = par2BaseAttributeMap.getAttributeInstance((IAttribute)entry.getKey()); + + if (iattributeinstance != null) + { + iattributeinstance.removeModifier((AttributeModifier)entry.getValue()); + } + } + } + + @SideOnly(Side.CLIENT) + public Map func_111186_k() + { + return this.field_111188_I; + } + + public void applyAttributesModifiersToEntity(EntityLivingBase par1EntityLivingBase, BaseAttributeMap par2BaseAttributeMap, int par3) + { + Iterator iterator = this.field_111188_I.entrySet().iterator(); + + while (iterator.hasNext()) + { + Entry entry = (Entry)iterator.next(); + IAttributeInstance iattributeinstance = par2BaseAttributeMap.getAttributeInstance((IAttribute)entry.getKey()); + + if (iattributeinstance != null) + { + AttributeModifier attributemodifier = (AttributeModifier)entry.getValue(); + iattributeinstance.removeModifier(attributemodifier); + iattributeinstance.applyModifier(new AttributeModifier(attributemodifier.getID(), this.getName() + " " + par3, this.func_111183_a(par3, attributemodifier), attributemodifier.getOperation())); + } + } + } + + public double func_111183_a(int par1, AttributeModifier par2AttributeModifier) + { + return par2AttributeModifier.getAmount() * (double)(par1 + 1); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/potion/PotionAbsoption.java b/src/main/java/net/minecraft/potion/PotionAbsoption.java new file mode 100644 index 0000000..7eac3ab --- /dev/null +++ b/src/main/java/net/minecraft/potion/PotionAbsoption.java @@ -0,0 +1,26 @@ +package net.minecraft.potion; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.ai.attributes.BaseAttributeMap; + +public class PotionAbsoption extends Potion +{ + private static final String __OBFID = "CL_00001524"; + + protected PotionAbsoption(int par1, boolean par2, int par3) + { + super(par1, par2, par3); + } + + public void removeAttributesModifiersFromEntity(EntityLivingBase par1EntityLivingBase, BaseAttributeMap par2BaseAttributeMap, int par3) + { + par1EntityLivingBase.setAbsorptionAmount(par1EntityLivingBase.getAbsorptionAmount() - (float)(4 * (par3 + 1))); + super.removeAttributesModifiersFromEntity(par1EntityLivingBase, par2BaseAttributeMap, par3); + } + + public void applyAttributesModifiersToEntity(EntityLivingBase par1EntityLivingBase, BaseAttributeMap par2BaseAttributeMap, int par3) + { + par1EntityLivingBase.setAbsorptionAmount(par1EntityLivingBase.getAbsorptionAmount() + (float)(4 * (par3 + 1))); + super.applyAttributesModifiersToEntity(par1EntityLivingBase, par2BaseAttributeMap, par3); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/potion/PotionAttackDamage.java b/src/main/java/net/minecraft/potion/PotionAttackDamage.java new file mode 100644 index 0000000..728de34 --- /dev/null +++ b/src/main/java/net/minecraft/potion/PotionAttackDamage.java @@ -0,0 +1,18 @@ +package net.minecraft.potion; + +import net.minecraft.entity.ai.attributes.AttributeModifier; + +public class PotionAttackDamage extends Potion +{ + private static final String __OBFID = "CL_00001525"; + + protected PotionAttackDamage(int par1, boolean par2, int par3) + { + super(par1, par2, par3); + } + + public double func_111183_a(int par1, AttributeModifier par2AttributeModifier) + { + return this.id == Potion.weakness.id ? (double)(-0.5F * (float)(par1 + 1)) : 1.3D * (double)(par1 + 1); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/potion/PotionEffect.java b/src/main/java/net/minecraft/potion/PotionEffect.java new file mode 100644 index 0000000..2f5f75d --- /dev/null +++ b/src/main/java/net/minecraft/potion/PotionEffect.java @@ -0,0 +1,268 @@ +package net.minecraft.potion; + +import java.util.ArrayList; +import java.util.List; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class PotionEffect +{ + private int potionID; + private int duration; + private int amplifier; + private boolean isSplashPotion; + private boolean isAmbient; + @SideOnly(Side.CLIENT) + private boolean isPotionDurationMax; + private static final String __OBFID = "CL_00001529"; + /** List of ItemStack that can cure the potion effect **/ + private List curativeItems; + + public PotionEffect(int par1, int par2) + { + this(par1, par2, 0); + } + + public PotionEffect(int par1, int par2, int par3) + { + this(par1, par2, par3, false); + } + + public PotionEffect(int par1, int par2, int par3, boolean par4) + { + this.potionID = par1; + this.duration = par2; + this.amplifier = par3; + this.isAmbient = par4; + this.curativeItems = new ArrayList(); + this.curativeItems.add(new ItemStack(Items.milk_bucket)); + } + + public PotionEffect(PotionEffect par1PotionEffect) + { + this.potionID = par1PotionEffect.potionID; + this.duration = par1PotionEffect.duration; + this.amplifier = par1PotionEffect.amplifier; + this.curativeItems = par1PotionEffect.curativeItems; + } + + public void combine(PotionEffect par1PotionEffect) + { + if (this.potionID != par1PotionEffect.potionID) + { + System.err.println("This method should only be called for matching effects!"); + } + + if (par1PotionEffect.amplifier > this.amplifier) + { + this.amplifier = par1PotionEffect.amplifier; + this.duration = par1PotionEffect.duration; + } + else if (par1PotionEffect.amplifier == this.amplifier && this.duration < par1PotionEffect.duration) + { + this.duration = par1PotionEffect.duration; + } + else if (!par1PotionEffect.isAmbient && this.isAmbient) + { + this.isAmbient = par1PotionEffect.isAmbient; + } + } + + public int getPotionID() + { + return this.potionID; + } + + public int getDuration() + { + return this.duration; + } + + public int getAmplifier() + { + return this.amplifier; + } + + public void setSplashPotion(boolean par1) + { + this.isSplashPotion = par1; + } + + public boolean getIsAmbient() + { + return this.isAmbient; + } + + public boolean onUpdate(EntityLivingBase par1EntityLivingBase) + { + if (this.duration > 0) + { + if (Potion.potionTypes[this.potionID].isReady(this.duration, this.amplifier)) + { + this.performEffect(par1EntityLivingBase); + } + + this.deincrementDuration(); + } + + return this.duration > 0; + } + + private int deincrementDuration() + { + return --this.duration; + } + + public void performEffect(EntityLivingBase par1EntityLivingBase) + { + if (this.duration > 0) + { + Potion.potionTypes[this.potionID].performEffect(par1EntityLivingBase, this.amplifier); + } + } + + public String getEffectName() + { + return Potion.potionTypes[this.potionID].getName(); + } + + public int hashCode() + { + return this.potionID; + } + + public String toString() + { + String s = ""; + + if (this.getAmplifier() > 0) + { + s = this.getEffectName() + " x " + (this.getAmplifier() + 1) + ", Duration: " + this.getDuration(); + } + else + { + s = this.getEffectName() + ", Duration: " + this.getDuration(); + } + + if (this.isSplashPotion) + { + s = s + ", Splash: true"; + } + + return Potion.potionTypes[this.potionID].isUsable() ? "(" + s + ")" : s; + } + + public boolean equals(Object par1Obj) + { + if (!(par1Obj instanceof PotionEffect)) + { + return false; + } + else + { + PotionEffect potioneffect = (PotionEffect)par1Obj; + return this.potionID == potioneffect.potionID && this.amplifier == potioneffect.amplifier && this.duration == potioneffect.duration && this.isSplashPotion == potioneffect.isSplashPotion && this.isAmbient == potioneffect.isAmbient; + } + } + + public NBTTagCompound writeCustomPotionEffectToNBT(NBTTagCompound par1NBTTagCompound) + { + par1NBTTagCompound.setByte("Id", (byte)this.getPotionID()); + par1NBTTagCompound.setByte("Amplifier", (byte)this.getAmplifier()); + par1NBTTagCompound.setInteger("Duration", this.getDuration()); + par1NBTTagCompound.setBoolean("Ambient", this.getIsAmbient()); + return par1NBTTagCompound; + } + + public static PotionEffect readCustomPotionEffectFromNBT(NBTTagCompound par0NBTTagCompound) + { + byte b0 = par0NBTTagCompound.getByte("Id"); + + if (b0 >= 0 && b0 < Potion.potionTypes.length && Potion.potionTypes[b0] != null) + { + byte b1 = par0NBTTagCompound.getByte("Amplifier"); + int i = par0NBTTagCompound.getInteger("Duration"); + boolean flag = par0NBTTagCompound.getBoolean("Ambient"); + return new PotionEffect(b0, i, b1, flag); + } + else + { + return null; + } + } + + @SideOnly(Side.CLIENT) + public void setPotionDurationMax(boolean par1) + { + this.isPotionDurationMax = par1; + } + + @SideOnly(Side.CLIENT) + public boolean getIsPotionDurationMax() + { + return this.isPotionDurationMax; + } + + /* ======================================== FORGE START =====================================*/ + /*** + * Returns a list of curative items for the potion effect + * @return The list (ItemStack) of curative items for the potion effect + */ + public List getCurativeItems() + { + return this.curativeItems; + } + + /*** + * Checks the given ItemStack to see if it is in the list of curative items for the potion effect + * @param stack The ItemStack being checked against the list of curative items for the potion effect + * @return true if the given ItemStack is in the list of curative items for the potion effect, false otherwise + */ + public boolean isCurativeItem(ItemStack stack) + { + boolean found = false; + for (ItemStack curativeItem : this.curativeItems) + { + if (curativeItem.isItemEqual(stack)) + { + found = true; + } + } + + return found; + } + + /*** + * Sets the array of curative items for the potion effect + * @param curativeItems The list of ItemStacks being set to the potion effect + */ + public void setCurativeItems(List curativeItems) + { + this.curativeItems = curativeItems; + } + + /*** + * Adds the given stack to list of curative items for the potion effect + * @param stack The ItemStack being added to the curative item list + */ + public void addCurativeItem(ItemStack stack) + { + boolean found = false; + for (ItemStack curativeItem : this.curativeItems) + { + if (curativeItem.isItemEqual(stack)) + { + found = true; + } + } + if (!found) + { + this.curativeItems.add(stack); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/potion/PotionHealth.java b/src/main/java/net/minecraft/potion/PotionHealth.java new file mode 100644 index 0000000..179ed30 --- /dev/null +++ b/src/main/java/net/minecraft/potion/PotionHealth.java @@ -0,0 +1,21 @@ +package net.minecraft.potion; + +public class PotionHealth extends Potion +{ + private static final String __OBFID = "CL_00001527"; + + public PotionHealth(int par1, boolean par2, int par3) + { + super(par1, par2, par3); + } + + public boolean isInstant() + { + return true; + } + + public boolean isReady(int par1, int par2) + { + return par1 >= 1; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/potion/PotionHealthBoost.java b/src/main/java/net/minecraft/potion/PotionHealthBoost.java new file mode 100644 index 0000000..0188f5b --- /dev/null +++ b/src/main/java/net/minecraft/potion/PotionHealthBoost.java @@ -0,0 +1,24 @@ +package net.minecraft.potion; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.ai.attributes.BaseAttributeMap; + +public class PotionHealthBoost extends Potion +{ + private static final String __OBFID = "CL_00001526"; + + public PotionHealthBoost(int par1, boolean par2, int par3) + { + super(par1, par2, par3); + } + + public void removeAttributesModifiersFromEntity(EntityLivingBase par1EntityLivingBase, BaseAttributeMap par2BaseAttributeMap, int par3) + { + super.removeAttributesModifiersFromEntity(par1EntityLivingBase, par2BaseAttributeMap, par3); + + if (par1EntityLivingBase.getHealth() > par1EntityLivingBase.getMaxHealth()) + { + par1EntityLivingBase.setHealth(par1EntityLivingBase.getMaxHealth()); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/potion/PotionHelper.java b/src/main/java/net/minecraft/potion/PotionHelper.java new file mode 100644 index 0000000..205536d --- /dev/null +++ b/src/main/java/net/minecraft/potion/PotionHelper.java @@ -0,0 +1,584 @@ +package net.minecraft.potion; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; + +public class PotionHelper +{ + public static final String field_77924_a = null; + public static final String sugarEffect; + public static final String ghastTearEffect = "+0-1-2-3&4-4+13"; + public static final String spiderEyeEffect; + public static final String fermentedSpiderEyeEffect; + public static final String speckledMelonEffect; + public static final String blazePowderEffect; + public static final String magmaCreamEffect; + public static final String redstoneEffect; + public static final String glowstoneEffect; + public static final String gunpowderEffect; + public static final String goldenCarrotEffect; + public static final String field_151423_m; + private static final HashMap potionRequirements = new HashMap(); + private static final HashMap potionAmplifiers = new HashMap(); + private static final HashMap field_77925_n; + private static final String[] potionPrefixes; + private static final String __OBFID = "CL_00000078"; + + public static boolean checkFlag(int par0, int par1) + { + return (par0 & 1 << par1) != 0; + } + + private static int isFlagSet(int par0, int par1) + { + return checkFlag(par0, par1) ? 1 : 0; + } + + private static int isFlagUnset(int par0, int par1) + { + return checkFlag(par0, par1) ? 0 : 1; + } + + public static int func_77909_a(int par0) + { + return func_77908_a(par0, 5, 4, 3, 2, 1); + } + + public static int calcPotionLiquidColor(Collection par0Collection) + { + int i = 3694022; + + if (par0Collection != null && !par0Collection.isEmpty()) + { + float f = 0.0F; + float f1 = 0.0F; + float f2 = 0.0F; + float f3 = 0.0F; + Iterator iterator = par0Collection.iterator(); + + while (iterator.hasNext()) + { + PotionEffect potioneffect = (PotionEffect)iterator.next(); + int j = Potion.potionTypes[potioneffect.getPotionID()].getLiquidColor(); + + for (int k = 0; k <= potioneffect.getAmplifier(); ++k) + { + f += (float)(j >> 16 & 255) / 255.0F; + f1 += (float)(j >> 8 & 255) / 255.0F; + f2 += (float)(j >> 0 & 255) / 255.0F; + ++f3; + } + } + + f = f / f3 * 255.0F; + f1 = f1 / f3 * 255.0F; + f2 = f2 / f3 * 255.0F; + return (int)f << 16 | (int)f1 << 8 | (int)f2; + } + else + { + return i; + } + } + + public static boolean func_82817_b(Collection par0Collection) + { + Iterator iterator = par0Collection.iterator(); + PotionEffect potioneffect; + + do + { + if (!iterator.hasNext()) + { + return true; + } + + potioneffect = (PotionEffect)iterator.next(); + } + while (potioneffect.getIsAmbient()); + + return false; + } + + @SideOnly(Side.CLIENT) + public static int func_77915_a(int par0, boolean par1) + { + if (!par1) + { + if (field_77925_n.containsKey(Integer.valueOf(par0))) + { + return ((Integer)field_77925_n.get(Integer.valueOf(par0))).intValue(); + } + else + { + int j = calcPotionLiquidColor(getPotionEffects(par0, false)); + field_77925_n.put(Integer.valueOf(par0), Integer.valueOf(j)); + return j; + } + } + else + { + return calcPotionLiquidColor(getPotionEffects(par0, par1)); + } + } + + public static String func_77905_c(int par0) + { + int j = func_77909_a(par0); + return potionPrefixes[j]; + } + + private static int func_77904_a(boolean par0, boolean par1, boolean par2, int par3, int par4, int par5, int par6) + { + int i1 = 0; + + if (par0) + { + i1 = isFlagUnset(par6, par4); + } + else if (par3 != -1) + { + if (par3 == 0 && countSetFlags(par6) == par4) + { + i1 = 1; + } + else if (par3 == 1 && countSetFlags(par6) > par4) + { + i1 = 1; + } + else if (par3 == 2 && countSetFlags(par6) < par4) + { + i1 = 1; + } + } + else + { + i1 = isFlagSet(par6, par4); + } + + if (par1) + { + i1 *= par5; + } + + if (par2) + { + i1 *= -1; + } + + return i1; + } + + private static int countSetFlags(int par0) + { + int j; + + for (j = 0; par0 > 0; ++j) + { + par0 &= par0 - 1; + } + + return j; + } + + private static int parsePotionEffects(String par0Str, int par1, int par2, int par3) + { + if (par1 < par0Str.length() && par2 >= 0 && par1 < par2) + { + int l = par0Str.indexOf(124, par1); + int i1; + int j2; + + if (l >= 0 && l < par2) + { + i1 = parsePotionEffects(par0Str, par1, l - 1, par3); + + if (i1 > 0) + { + return i1; + } + else + { + j2 = parsePotionEffects(par0Str, l + 1, par2, par3); + return j2 > 0 ? j2 : 0; + } + } + else + { + i1 = par0Str.indexOf(38, par1); + + if (i1 >= 0 && i1 < par2) + { + j2 = parsePotionEffects(par0Str, par1, i1 - 1, par3); + + if (j2 <= 0) + { + return 0; + } + else + { + int k2 = parsePotionEffects(par0Str, i1 + 1, par2, par3); + return k2 <= 0 ? 0 : (j2 > k2 ? j2 : k2); + } + } + else + { + boolean flag = false; + boolean flag1 = false; + boolean flag2 = false; + boolean flag3 = false; + boolean flag4 = false; + byte b0 = -1; + int j1 = 0; + int k1 = 0; + int l1 = 0; + + for (int i2 = par1; i2 < par2; ++i2) + { + char c0 = par0Str.charAt(i2); + + if (c0 >= 48 && c0 <= 57) + { + if (flag) + { + k1 = c0 - 48; + flag1 = true; + } + else + { + j1 *= 10; + j1 += c0 - 48; + flag2 = true; + } + } + else if (c0 == 42) + { + flag = true; + } + else if (c0 == 33) + { + if (flag2) + { + l1 += func_77904_a(flag3, flag1, flag4, b0, j1, k1, par3); + flag3 = false; + flag4 = false; + flag = false; + flag1 = false; + flag2 = false; + k1 = 0; + j1 = 0; + b0 = -1; + } + + flag3 = true; + } + else if (c0 == 45) + { + if (flag2) + { + l1 += func_77904_a(flag3, flag1, flag4, b0, j1, k1, par3); + flag3 = false; + flag4 = false; + flag = false; + flag1 = false; + flag2 = false; + k1 = 0; + j1 = 0; + b0 = -1; + } + + flag4 = true; + } + else if (c0 != 61 && c0 != 60 && c0 != 62) + { + if (c0 == 43 && flag2) + { + l1 += func_77904_a(flag3, flag1, flag4, b0, j1, k1, par3); + flag3 = false; + flag4 = false; + flag = false; + flag1 = false; + flag2 = false; + k1 = 0; + j1 = 0; + b0 = -1; + } + } + else + { + if (flag2) + { + l1 += func_77904_a(flag3, flag1, flag4, b0, j1, k1, par3); + flag3 = false; + flag4 = false; + flag = false; + flag1 = false; + flag2 = false; + k1 = 0; + j1 = 0; + b0 = -1; + } + + if (c0 == 61) + { + b0 = 0; + } + else if (c0 == 60) + { + b0 = 2; + } + else if (c0 == 62) + { + b0 = 1; + } + } + } + + if (flag2) + { + l1 += func_77904_a(flag3, flag1, flag4, b0, j1, k1, par3); + } + + return l1; + } + } + } + else + { + return 0; + } + } + + public static List getPotionEffects(int par0, boolean par1) + { + ArrayList arraylist = null; + Potion[] apotion = Potion.potionTypes; + int j = apotion.length; + + for (int k = 0; k < j; ++k) + { + Potion potion = apotion[k]; + + if (potion != null && (!potion.isUsable() || par1)) + { + String s = (String)potionRequirements.get(Integer.valueOf(potion.getId())); + + if (s != null) + { + int l = parsePotionEffects(s, 0, s.length(), par0); + + if (l > 0) + { + int i1 = 0; + String s1 = (String)potionAmplifiers.get(Integer.valueOf(potion.getId())); + + if (s1 != null) + { + i1 = parsePotionEffects(s1, 0, s1.length(), par0); + + if (i1 < 0) + { + i1 = 0; + } + } + + if (potion.isInstant()) + { + l = 1; + } + else + { + l = 1200 * (l * 3 + (l - 1) * 2); + l >>= i1; + l = (int)Math.round((double)l * potion.getEffectiveness()); + + if ((par0 & 16384) != 0) + { + l = (int)Math.round((double)l * 0.75D + 0.5D); + } + } + + if (arraylist == null) + { + arraylist = new ArrayList(); + } + + PotionEffect potioneffect = new PotionEffect(potion.getId(), l, i1); + + if ((par0 & 16384) != 0) + { + potioneffect.setSplashPotion(true); + } + + arraylist.add(potioneffect); + } + } + } + } + + return arraylist; + } + + private static int brewBitOperations(int par0, int par1, boolean par2, boolean par3, boolean par4) + { + if (par4) + { + if (!checkFlag(par0, par1)) + { + return 0; + } + } + else if (par2) + { + par0 &= ~(1 << par1); + } + else if (par3) + { + if ((par0 & 1 << par1) == 0) + { + par0 |= 1 << par1; + } + else + { + par0 &= ~(1 << par1); + } + } + else + { + par0 |= 1 << par1; + } + + return par0; + } + + public static int applyIngredient(int par0, String par1Str) + { + byte b0 = 0; + int j = par1Str.length(); + boolean flag = false; + boolean flag1 = false; + boolean flag2 = false; + boolean flag3 = false; + int k = 0; + + for (int l = b0; l < j; ++l) + { + char c0 = par1Str.charAt(l); + + if (c0 >= 48 && c0 <= 57) + { + k *= 10; + k += c0 - 48; + flag = true; + } + else if (c0 == 33) + { + if (flag) + { + par0 = brewBitOperations(par0, k, flag2, flag1, flag3); + flag3 = false; + flag1 = false; + flag2 = false; + flag = false; + k = 0; + } + + flag1 = true; + } + else if (c0 == 45) + { + if (flag) + { + par0 = brewBitOperations(par0, k, flag2, flag1, flag3); + flag3 = false; + flag1 = false; + flag2 = false; + flag = false; + k = 0; + } + + flag2 = true; + } + else if (c0 == 43) + { + if (flag) + { + par0 = brewBitOperations(par0, k, flag2, flag1, flag3); + flag3 = false; + flag1 = false; + flag2 = false; + flag = false; + k = 0; + } + } + else if (c0 == 38) + { + if (flag) + { + par0 = brewBitOperations(par0, k, flag2, flag1, flag3); + flag3 = false; + flag1 = false; + flag2 = false; + flag = false; + k = 0; + } + + flag3 = true; + } + } + + if (flag) + { + par0 = brewBitOperations(par0, k, flag2, flag1, flag3); + } + + return par0 & 32767; + } + + public static int func_77908_a(int par0, int par1, int par2, int par3, int par4, int par5) + { + return (checkFlag(par0, par1) ? 16 : 0) | (checkFlag(par0, par2) ? 8 : 0) | (checkFlag(par0, par3) ? 4 : 0) | (checkFlag(par0, par4) ? 2 : 0) | (checkFlag(par0, par5) ? 1 : 0); + } + + static + { + potionRequirements.put(Integer.valueOf(Potion.regeneration.getId()), "0 & !1 & !2 & !3 & 0+6"); + sugarEffect = "-0+1-2-3&4-4+13"; + potionRequirements.put(Integer.valueOf(Potion.moveSpeed.getId()), "!0 & 1 & !2 & !3 & 1+6"); + magmaCreamEffect = "+0+1-2-3&4-4+13"; + potionRequirements.put(Integer.valueOf(Potion.fireResistance.getId()), "0 & 1 & !2 & !3 & 0+6"); + speckledMelonEffect = "+0-1+2-3&4-4+13"; + potionRequirements.put(Integer.valueOf(Potion.heal.getId()), "0 & !1 & 2 & !3"); + spiderEyeEffect = "-0-1+2-3&4-4+13"; + potionRequirements.put(Integer.valueOf(Potion.poison.getId()), "!0 & !1 & 2 & !3 & 2+6"); + fermentedSpiderEyeEffect = "-0+3-4+13"; + potionRequirements.put(Integer.valueOf(Potion.weakness.getId()), "!0 & !1 & !2 & 3 & 3+6"); + potionRequirements.put(Integer.valueOf(Potion.harm.getId()), "!0 & !1 & 2 & 3"); + potionRequirements.put(Integer.valueOf(Potion.moveSlowdown.getId()), "!0 & 1 & !2 & 3 & 3+6"); + blazePowderEffect = "+0-1-2+3&4-4+13"; + potionRequirements.put(Integer.valueOf(Potion.damageBoost.getId()), "0 & !1 & !2 & 3 & 3+6"); + goldenCarrotEffect = "-0+1+2-3+13&4-4"; + potionRequirements.put(Integer.valueOf(Potion.nightVision.getId()), "!0 & 1 & 2 & !3 & 2+6"); + potionRequirements.put(Integer.valueOf(Potion.invisibility.getId()), "!0 & 1 & 2 & 3 & 2+6"); + field_151423_m = "+0-1+2+3+13&4-4"; + potionRequirements.put(Integer.valueOf(Potion.waterBreathing.getId()), "0 & !1 & 2 & 3 & 2+6"); + glowstoneEffect = "+5-6-7"; + potionAmplifiers.put(Integer.valueOf(Potion.moveSpeed.getId()), "5"); + potionAmplifiers.put(Integer.valueOf(Potion.digSpeed.getId()), "5"); + potionAmplifiers.put(Integer.valueOf(Potion.damageBoost.getId()), "5"); + potionAmplifiers.put(Integer.valueOf(Potion.regeneration.getId()), "5"); + potionAmplifiers.put(Integer.valueOf(Potion.harm.getId()), "5"); + potionAmplifiers.put(Integer.valueOf(Potion.heal.getId()), "5"); + potionAmplifiers.put(Integer.valueOf(Potion.resistance.getId()), "5"); + potionAmplifiers.put(Integer.valueOf(Potion.poison.getId()), "5"); + redstoneEffect = "-5+6-7"; + gunpowderEffect = "+14&13-13"; + field_77925_n = new HashMap(); + potionPrefixes = new String[] {"potion.prefix.mundane", "potion.prefix.uninteresting", "potion.prefix.bland", "potion.prefix.clear", "potion.prefix.milky", "potion.prefix.diffuse", "potion.prefix.artless", "potion.prefix.thin", "potion.prefix.awkward", "potion.prefix.flat", "potion.prefix.bulky", "potion.prefix.bungling", "potion.prefix.buttered", "potion.prefix.smooth", "potion.prefix.suave", "potion.prefix.debonair", "potion.prefix.thick", "potion.prefix.elegant", "potion.prefix.fancy", "potion.prefix.charming", "potion.prefix.dashing", "potion.prefix.refined", "potion.prefix.cordial", "potion.prefix.sparkling", "potion.prefix.potent", "potion.prefix.foul", "potion.prefix.odorless", "potion.prefix.rank", "potion.prefix.harsh", "potion.prefix.acrid", "potion.prefix.gross", "potion.prefix.stinky"}; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/profiler/IPlayerUsage.java b/src/main/java/net/minecraft/profiler/IPlayerUsage.java new file mode 100644 index 0000000..d0c8e12 --- /dev/null +++ b/src/main/java/net/minecraft/profiler/IPlayerUsage.java @@ -0,0 +1,10 @@ +package net.minecraft.profiler; + +public interface IPlayerUsage +{ + void addServerStatsToSnooper(PlayerUsageSnooper var1); + + void addServerTypeToSnooper(PlayerUsageSnooper var1); + + boolean isSnooperEnabled(); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/profiler/PlayerUsageSnooper.java b/src/main/java/net/minecraft/profiler/PlayerUsageSnooper.java new file mode 100644 index 0000000..1fb3580 --- /dev/null +++ b/src/main/java/net/minecraft/profiler/PlayerUsageSnooper.java @@ -0,0 +1,173 @@ +package net.minecraft.profiler; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.lang.management.ManagementFactory; +import java.lang.management.RuntimeMXBean; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Timer; +import java.util.TimerTask; +import java.util.UUID; +import java.util.Map.Entry; +import net.minecraft.util.HttpUtil; + +public class PlayerUsageSnooper +{ + private Map dataMap = new HashMap(); + private final String uniqueID = UUID.randomUUID().toString(); + private final URL serverUrl; + private final IPlayerUsage playerStatsCollector; + private final Timer threadTrigger = new Timer("Snooper Timer", true); + private final Object syncLock = new Object(); + private final long minecraftStartTimeMilis; + private boolean isRunning; + private int selfCounter; + private static final String __OBFID = "CL_00001515"; + + public PlayerUsageSnooper(String par1Str, IPlayerUsage par2IPlayerUsage, long par3) + { + try + { + this.serverUrl = new URL("http://snoop.minecraft.net/" + par1Str + "?version=" + 1); + } + catch (MalformedURLException malformedurlexception) + { + throw new IllegalArgumentException(); + } + + this.playerStatsCollector = par2IPlayerUsage; + this.minecraftStartTimeMilis = par3; + } + + public void startSnooper() + { + if (!this.isRunning) + { + this.isRunning = true; + this.addBaseDataToSnooper(); + this.threadTrigger.schedule(new TimerTask() + { + private static final String __OBFID = "CL_00001516"; + public void run() + { + if (PlayerUsageSnooper.this.playerStatsCollector.isSnooperEnabled()) + { + HashMap hashmap; + + synchronized (PlayerUsageSnooper.this.syncLock) + { + hashmap = new HashMap(PlayerUsageSnooper.this.dataMap); + hashmap.put("snooper_count", Integer.valueOf(PlayerUsageSnooper.getSelfCounterFor(PlayerUsageSnooper.this))); + } + + HttpUtil.func_151226_a(PlayerUsageSnooper.this.serverUrl, hashmap, true); + } + } + }, 0L, 900000L); + } + } + + private void addBaseDataToSnooper() + { + this.addJvmArgsToSnooper(); + this.addData("snooper_token", this.uniqueID); + this.addData("os_name", System.getProperty("os.name")); + this.addData("os_version", System.getProperty("os.version")); + this.addData("os_architecture", System.getProperty("os.arch")); + this.addData("java_version", System.getProperty("java.version")); + this.addData("version", "1.7.2"); + this.playerStatsCollector.addServerTypeToSnooper(this); + } + + private void addJvmArgsToSnooper() + { + RuntimeMXBean runtimemxbean = ManagementFactory.getRuntimeMXBean(); + List list = runtimemxbean.getInputArguments(); + int i = 0; + Iterator iterator = list.iterator(); + + while (iterator.hasNext()) + { + String s = (String)iterator.next(); + + if (s.startsWith("-X")) + { + this.addData("jvm_arg[" + i++ + "]", s); + } + } + + this.addData("jvm_args", Integer.valueOf(i)); + } + + public void addMemoryStatsToSnooper() + { + this.addData("memory_total", Long.valueOf(Runtime.getRuntime().totalMemory())); + this.addData("memory_max", Long.valueOf(Runtime.getRuntime().maxMemory())); + this.addData("memory_free", Long.valueOf(Runtime.getRuntime().freeMemory())); + this.addData("cpu_cores", Integer.valueOf(Runtime.getRuntime().availableProcessors())); + this.playerStatsCollector.addServerStatsToSnooper(this); + } + + public void addData(String par1Str, Object par2Obj) + { + Object object1 = this.syncLock; + + synchronized (this.syncLock) + { + this.dataMap.put(par1Str, par2Obj); + } + } + + @SideOnly(Side.CLIENT) + public Map getCurrentStats() + { + LinkedHashMap linkedhashmap = new LinkedHashMap(); + Object object = this.syncLock; + + synchronized (this.syncLock) + { + this.addMemoryStatsToSnooper(); + Iterator iterator = this.dataMap.entrySet().iterator(); + + while (iterator.hasNext()) + { + Entry entry = (Entry)iterator.next(); + linkedhashmap.put(entry.getKey(), entry.getValue().toString()); + } + + return linkedhashmap; + } + } + + public boolean isSnooperRunning() + { + return this.isRunning; + } + + public void stopSnooper() + { + this.threadTrigger.cancel(); + } + + @SideOnly(Side.CLIENT) + public String getUniqueID() + { + return this.uniqueID; + } + + public long getMinecraftStartTimeMillis() + { + return this.minecraftStartTimeMilis; + } + + static int getSelfCounterFor(PlayerUsageSnooper par0PlayerUsageSnooper) + { + return par0PlayerUsageSnooper.selfCounter++; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/profiler/Profiler.java b/src/main/java/net/minecraft/profiler/Profiler.java new file mode 100644 index 0000000..f038217 --- /dev/null +++ b/src/main/java/net/minecraft/profiler/Profiler.java @@ -0,0 +1,192 @@ +package net.minecraft.profiler; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class Profiler +{ + private static final Logger logger = LogManager.getLogger(); + private final List sectionList = new ArrayList(); + private final List timestampList = new ArrayList(); + public boolean profilingEnabled; + private String profilingSection = ""; + private final Map profilingMap = new HashMap(); + private static final String __OBFID = "CL_00001497"; + + public void clearProfiling() + { + this.profilingMap.clear(); + this.profilingSection = ""; + this.sectionList.clear(); + } + + public void startSection(String par1Str) + { + if (this.profilingEnabled) + { + if (this.profilingSection.length() > 0) + { + this.profilingSection = this.profilingSection + "."; + } + + this.profilingSection = this.profilingSection + par1Str; + this.sectionList.add(this.profilingSection); + this.timestampList.add(Long.valueOf(System.nanoTime())); + } + } + + public void endSection() + { + if (this.profilingEnabled) + { + long i = System.nanoTime(); + long j = ((Long)this.timestampList.remove(this.timestampList.size() - 1)).longValue(); + this.sectionList.remove(this.sectionList.size() - 1); + long k = i - j; + + if (this.profilingMap.containsKey(this.profilingSection)) + { + this.profilingMap.put(this.profilingSection, Long.valueOf(((Long)this.profilingMap.get(this.profilingSection)).longValue() + k)); + } + else + { + this.profilingMap.put(this.profilingSection, Long.valueOf(k)); + } + + if (k > 100000000L) + { + logger.warn("Something\'s taking too long! \'" + this.profilingSection + "\' took aprox " + (double)k / 1000000.0D + " ms"); + } + + this.profilingSection = !this.sectionList.isEmpty() ? (String)this.sectionList.get(this.sectionList.size() - 1) : ""; + } + } + + public List getProfilingData(String par1Str) + { + if (!this.profilingEnabled) + { + return null; + } + else + { + long i = this.profilingMap.containsKey("root") ? ((Long)this.profilingMap.get("root")).longValue() : 0L; + long j = this.profilingMap.containsKey(par1Str) ? ((Long)this.profilingMap.get(par1Str)).longValue() : -1L; + ArrayList arraylist = new ArrayList(); + + if (par1Str.length() > 0) + { + par1Str = par1Str + "."; + } + + long k = 0L; + Iterator iterator = this.profilingMap.keySet().iterator(); + + while (iterator.hasNext()) + { + String s1 = (String)iterator.next(); + + if (s1.length() > par1Str.length() && s1.startsWith(par1Str) && s1.indexOf(".", par1Str.length() + 1) < 0) + { + k += ((Long)this.profilingMap.get(s1)).longValue(); + } + } + + float f = (float)k; + + if (k < j) + { + k = j; + } + + if (i < k) + { + i = k; + } + + Iterator iterator1 = this.profilingMap.keySet().iterator(); + String s2; + + while (iterator1.hasNext()) + { + s2 = (String)iterator1.next(); + + if (s2.length() > par1Str.length() && s2.startsWith(par1Str) && s2.indexOf(".", par1Str.length() + 1) < 0) + { + long l = ((Long)this.profilingMap.get(s2)).longValue(); + double d0 = (double)l * 100.0D / (double)k; + double d1 = (double)l * 100.0D / (double)i; + String s3 = s2.substring(par1Str.length()); + arraylist.add(new Profiler.Result(s3, d0, d1)); + } + } + + iterator1 = this.profilingMap.keySet().iterator(); + + while (iterator1.hasNext()) + { + s2 = (String)iterator1.next(); + this.profilingMap.put(s2, Long.valueOf(((Long)this.profilingMap.get(s2)).longValue() * 999L / 1000L)); + } + + if ((float)k > f) + { + arraylist.add(new Profiler.Result("unspecified", (double)((float)k - f) * 100.0D / (double)k, (double)((float)k - f) * 100.0D / (double)i)); + } + + Collections.sort(arraylist); + arraylist.add(0, new Profiler.Result(par1Str, 100.0D, (double)k * 100.0D / (double)i)); + return arraylist; + } + } + + public void endStartSection(String par1Str) + { + this.endSection(); + this.startSection(par1Str); + } + + public String getNameOfLastSection() + { + return this.sectionList.size() == 0 ? "[UNKNOWN]" : (String)this.sectionList.get(this.sectionList.size() - 1); + } + + public static final class Result implements Comparable + { + public double field_76332_a; + public double field_76330_b; + public String field_76331_c; + private static final String __OBFID = "CL_00001498"; + + public Result(String par1Str, double par2, double par4) + { + this.field_76331_c = par1Str; + this.field_76332_a = par2; + this.field_76330_b = par4; + } + + public int compareTo(Profiler.Result par1ProfilerResult) + { + return par1ProfilerResult.field_76332_a < this.field_76332_a ? -1 : (par1ProfilerResult.field_76332_a > this.field_76332_a ? 1 : par1ProfilerResult.field_76331_c.compareTo(this.field_76331_c)); + } + + @SideOnly(Side.CLIENT) + public int func_76329_a() + { + return (this.field_76331_c.hashCode() & 11184810) + 4473924; + } + + public int compareTo(Object par1Obj) + { + return this.compareTo((Profiler.Result)par1Obj); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/scoreboard/IScoreObjectiveCriteria.java b/src/main/java/net/minecraft/scoreboard/IScoreObjectiveCriteria.java new file mode 100644 index 0000000..cf9d4b7 --- /dev/null +++ b/src/main/java/net/minecraft/scoreboard/IScoreObjectiveCriteria.java @@ -0,0 +1,21 @@ +package net.minecraft.scoreboard; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public interface IScoreObjectiveCriteria +{ + Map field_96643_a = new HashMap(); + IScoreObjectiveCriteria field_96641_b = new ScoreDummyCriteria("dummy"); + IScoreObjectiveCriteria deathCount = new ScoreDummyCriteria("deathCount"); + IScoreObjectiveCriteria playerKillCount = new ScoreDummyCriteria("playerKillCount"); + IScoreObjectiveCriteria totalKillCount = new ScoreDummyCriteria("totalKillCount"); + IScoreObjectiveCriteria health = new ScoreHealthCriteria("health"); + + String func_96636_a(); + + int func_96635_a(List var1); + + boolean isReadOnly(); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/scoreboard/Score.java b/src/main/java/net/minecraft/scoreboard/Score.java new file mode 100644 index 0000000..e84ebd2 --- /dev/null +++ b/src/main/java/net/minecraft/scoreboard/Score.java @@ -0,0 +1,104 @@ +package net.minecraft.scoreboard; + +import java.util.Comparator; +import java.util.List; + +public class Score +{ + public static final Comparator field_96658_a = new Comparator() + { + private static final String __OBFID = "CL_00000618"; + public int compare(Score par1Score, Score par2Score) + { + return par1Score.getScorePoints() > par2Score.getScorePoints() ? 1 : (par1Score.getScorePoints() < par2Score.getScorePoints() ? -1 : 0); + } + public int compare(Object par1Obj, Object par2Obj) + { + return this.compare((Score)par1Obj, (Score)par2Obj); + } + }; + private final Scoreboard theScoreboard; + private final ScoreObjective theScoreObjective; + private final String scorePlayerName; + private int field_96655_e; + private static final String __OBFID = "CL_00000617"; + + public Score(Scoreboard par1Scoreboard, ScoreObjective par2ScoreObjective, String par3Str) + { + this.theScoreboard = par1Scoreboard; + this.theScoreObjective = par2ScoreObjective; + this.scorePlayerName = par3Str; + } + + public void increseScore(int par1) + { + if (this.theScoreObjective.getCriteria().isReadOnly()) + { + throw new IllegalStateException("Cannot modify read-only score"); + } + else + { + this.setScorePoints(this.getScorePoints() + par1); + } + } + + public void decreaseScore(int par1) + { + if (this.theScoreObjective.getCriteria().isReadOnly()) + { + throw new IllegalStateException("Cannot modify read-only score"); + } + else + { + this.setScorePoints(this.getScorePoints() - par1); + } + } + + public void func_96648_a() + { + if (this.theScoreObjective.getCriteria().isReadOnly()) + { + throw new IllegalStateException("Cannot modify read-only score"); + } + else + { + this.increseScore(1); + } + } + + public int getScorePoints() + { + return this.field_96655_e; + } + + public void setScorePoints(int par1) + { + int j = this.field_96655_e; + this.field_96655_e = par1; + + if (j != par1) + { + this.getScoreScoreboard().func_96536_a(this); + } + } + + public ScoreObjective func_96645_d() + { + return this.theScoreObjective; + } + + public String getPlayerName() + { + return this.scorePlayerName; + } + + public Scoreboard getScoreScoreboard() + { + return this.theScoreboard; + } + + public void func_96651_a(List par1List) + { + this.setScorePoints(this.theScoreObjective.getCriteria().func_96635_a(par1List)); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/scoreboard/ScoreDummyCriteria.java b/src/main/java/net/minecraft/scoreboard/ScoreDummyCriteria.java new file mode 100644 index 0000000..b17bfe6 --- /dev/null +++ b/src/main/java/net/minecraft/scoreboard/ScoreDummyCriteria.java @@ -0,0 +1,30 @@ +package net.minecraft.scoreboard; + +import java.util.List; + +public class ScoreDummyCriteria implements IScoreObjectiveCriteria +{ + private final String field_96644_g; + private static final String __OBFID = "CL_00000622"; + + public ScoreDummyCriteria(String par1Str) + { + this.field_96644_g = par1Str; + IScoreObjectiveCriteria.field_96643_a.put(par1Str, this); + } + + public String func_96636_a() + { + return this.field_96644_g; + } + + public int func_96635_a(List par1List) + { + return 0; + } + + public boolean isReadOnly() + { + return false; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/scoreboard/ScoreHealthCriteria.java b/src/main/java/net/minecraft/scoreboard/ScoreHealthCriteria.java new file mode 100644 index 0000000..f1f214f --- /dev/null +++ b/src/main/java/net/minecraft/scoreboard/ScoreHealthCriteria.java @@ -0,0 +1,39 @@ +package net.minecraft.scoreboard; + +import java.util.Iterator; +import java.util.List; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.MathHelper; + +public class ScoreHealthCriteria extends ScoreDummyCriteria +{ + private static final String __OBFID = "CL_00000623"; + + public ScoreHealthCriteria(String par1Str) + { + super(par1Str); + } + + public int func_96635_a(List par1List) + { + float f = 0.0F; + EntityPlayer entityplayer; + + for (Iterator iterator = par1List.iterator(); iterator.hasNext(); f += entityplayer.getHealth() + entityplayer.getAbsorptionAmount()) + { + entityplayer = (EntityPlayer)iterator.next(); + } + + if (par1List.size() > 0) + { + f /= (float)par1List.size(); + } + + return MathHelper.ceiling_float_int(f); + } + + public boolean isReadOnly() + { + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/scoreboard/ScoreObjective.java b/src/main/java/net/minecraft/scoreboard/ScoreObjective.java new file mode 100644 index 0000000..eb306a9 --- /dev/null +++ b/src/main/java/net/minecraft/scoreboard/ScoreObjective.java @@ -0,0 +1,48 @@ +package net.minecraft.scoreboard; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class ScoreObjective +{ + private final Scoreboard theScoreboard; + private final String name; + private final IScoreObjectiveCriteria objectiveCriteria; + private String displayName; + private static final String __OBFID = "CL_00000614"; + + public ScoreObjective(Scoreboard par1Scoreboard, String par2Str, IScoreObjectiveCriteria par3ScoreObjectiveCriteria) + { + this.theScoreboard = par1Scoreboard; + this.name = par2Str; + this.objectiveCriteria = par3ScoreObjectiveCriteria; + this.displayName = par2Str; + } + + @SideOnly(Side.CLIENT) + public Scoreboard getScoreboard() + { + return this.theScoreboard; + } + + public String getName() + { + return this.name; + } + + public IScoreObjectiveCriteria getCriteria() + { + return this.objectiveCriteria; + } + + public String getDisplayName() + { + return this.displayName; + } + + public void setDisplayName(String par1Str) + { + this.displayName = par1Str; + this.theScoreboard.func_96532_b(this); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/scoreboard/ScorePlayerTeam.java b/src/main/java/net/minecraft/scoreboard/ScorePlayerTeam.java new file mode 100644 index 0000000..8a2d1c3 --- /dev/null +++ b/src/main/java/net/minecraft/scoreboard/ScorePlayerTeam.java @@ -0,0 +1,147 @@ +package net.minecraft.scoreboard; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +public class ScorePlayerTeam extends Team +{ + private final Scoreboard theScoreboard; + private final String field_96675_b; + private final Set membershipSet = new HashSet(); + private String teamNameSPT; + private String namePrefixSPT = ""; + private String colorSuffix = ""; + private boolean allowFriendlyFire = true; + private boolean canSeeFriendlyInvisibles = true; + private static final String __OBFID = "CL_00000616"; + + public ScorePlayerTeam(Scoreboard par1Scoreboard, String par2Str) + { + this.theScoreboard = par1Scoreboard; + this.field_96675_b = par2Str; + this.teamNameSPT = par2Str; + } + + public String getRegisteredName() + { + return this.field_96675_b; + } + + public String func_96669_c() + { + return this.teamNameSPT; + } + + public void setTeamName(String par1Str) + { + if (par1Str == null) + { + throw new IllegalArgumentException("Name cannot be null"); + } + else + { + this.teamNameSPT = par1Str; + this.theScoreboard.broadcastTeamRemoved(this); + } + } + + public Collection getMembershipCollection() + { + return this.membershipSet; + } + + public String getColorPrefix() + { + return this.namePrefixSPT; + } + + public void setNamePrefix(String par1Str) + { + if (par1Str == null) + { + throw new IllegalArgumentException("Prefix cannot be null"); + } + else + { + this.namePrefixSPT = par1Str; + this.theScoreboard.broadcastTeamRemoved(this); + } + } + + public String getColorSuffix() + { + return this.colorSuffix; + } + + public void setNameSuffix(String par1Str) + { + if (par1Str == null) + { + throw new IllegalArgumentException("Suffix cannot be null"); + } + else + { + this.colorSuffix = par1Str; + this.theScoreboard.broadcastTeamRemoved(this); + } + } + + public String formatString(String par1Str) + { + return this.getColorPrefix() + par1Str + this.getColorSuffix(); + } + + public static String formatPlayerName(Team par0Team, String par1Str) + { + return par0Team == null ? par1Str : par0Team.formatString(par1Str); + } + + public boolean getAllowFriendlyFire() + { + return this.allowFriendlyFire; + } + + public void setAllowFriendlyFire(boolean par1) + { + this.allowFriendlyFire = par1; + this.theScoreboard.broadcastTeamRemoved(this); + } + + public boolean func_98297_h() + { + return this.canSeeFriendlyInvisibles; + } + + public void setSeeFriendlyInvisiblesEnabled(boolean par1) + { + this.canSeeFriendlyInvisibles = par1; + this.theScoreboard.broadcastTeamRemoved(this); + } + + public int func_98299_i() + { + int i = 0; + + if (this.getAllowFriendlyFire()) + { + i |= 1; + } + + if (this.func_98297_h()) + { + i |= 2; + } + + return i; + } + + @SideOnly(Side.CLIENT) + public void func_98298_a(int par1) + { + this.setAllowFriendlyFire((par1 & 1) > 0); + this.setSeeFriendlyInvisiblesEnabled((par1 & 2) > 0); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/scoreboard/Scoreboard.java b/src/main/java/net/minecraft/scoreboard/Scoreboard.java new file mode 100644 index 0000000..9d0d6a6 --- /dev/null +++ b/src/main/java/net/minecraft/scoreboard/Scoreboard.java @@ -0,0 +1,321 @@ +package net.minecraft.scoreboard; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +public class Scoreboard +{ + private final Map scoreObjectives = new HashMap(); + private final Map scoreObjectiveCriterias = new HashMap(); + private final Map field_96544_c = new HashMap(); + private final ScoreObjective[] field_96541_d = new ScoreObjective[3]; + private final Map teams = new HashMap(); + private final Map teamMemberships = new HashMap(); + private static final String __OBFID = "CL_00000619"; + + public ScoreObjective getObjective(String par1Str) + { + return (ScoreObjective)this.scoreObjectives.get(par1Str); + } + + public ScoreObjective addScoreObjective(String par1Str, IScoreObjectiveCriteria par2ScoreObjectiveCriteria) + { + ScoreObjective scoreobjective = this.getObjective(par1Str); + + if (scoreobjective != null) + { + throw new IllegalArgumentException("An objective with the name \'" + par1Str + "\' already exists!"); + } + else + { + scoreobjective = new ScoreObjective(this, par1Str, par2ScoreObjectiveCriteria); + Object object = (List)this.scoreObjectiveCriterias.get(par2ScoreObjectiveCriteria); + + if (object == null) + { + object = new ArrayList(); + this.scoreObjectiveCriterias.put(par2ScoreObjectiveCriteria, object); + } + + ((List)object).add(scoreobjective); + this.scoreObjectives.put(par1Str, scoreobjective); + this.func_96522_a(scoreobjective); + return scoreobjective; + } + } + + public Collection func_96520_a(IScoreObjectiveCriteria par1ScoreObjectiveCriteria) + { + Collection collection = (Collection)this.scoreObjectiveCriterias.get(par1ScoreObjectiveCriteria); + return collection == null ? new ArrayList() : new ArrayList(collection); + } + + public Score func_96529_a(String par1Str, ScoreObjective par2ScoreObjective) + { + Object object = (Map)this.field_96544_c.get(par1Str); + + if (object == null) + { + object = new HashMap(); + this.field_96544_c.put(par1Str, object); + } + + Score score = (Score)((Map)object).get(par2ScoreObjective); + + if (score == null) + { + score = new Score(this, par2ScoreObjective, par1Str); + ((Map)object).put(par2ScoreObjective, score); + } + + return score; + } + + public Collection func_96534_i(ScoreObjective par1ScoreObjective) + { + ArrayList arraylist = new ArrayList(); + Iterator iterator = this.field_96544_c.values().iterator(); + + while (iterator.hasNext()) + { + Map map = (Map)iterator.next(); + Score score = (Score)map.get(par1ScoreObjective); + + if (score != null) + { + arraylist.add(score); + } + } + + Collections.sort(arraylist, Score.field_96658_a); + return arraylist; + } + + public Collection getScoreObjectives() + { + return this.scoreObjectives.values(); + } + + public Collection getObjectiveNames() + { + return this.field_96544_c.keySet(); + } + + public void func_96515_c(String par1Str) + { + Map map = (Map)this.field_96544_c.remove(par1Str); + + if (map != null) + { + this.func_96516_a(par1Str); + } + } + + public Collection func_96528_e() + { + Collection collection = this.field_96544_c.values(); + ArrayList arraylist = new ArrayList(); + Iterator iterator = collection.iterator(); + + while (iterator.hasNext()) + { + Map map = (Map)iterator.next(); + arraylist.addAll(map.values()); + } + + return arraylist; + } + + public Map func_96510_d(String par1Str) + { + Object object = (Map)this.field_96544_c.get(par1Str); + + if (object == null) + { + object = new HashMap(); + } + + return (Map)object; + } + + public void func_96519_k(ScoreObjective par1ScoreObjective) + { + this.scoreObjectives.remove(par1ScoreObjective.getName()); + + for (int i = 0; i < 3; ++i) + { + if (this.func_96539_a(i) == par1ScoreObjective) + { + this.func_96530_a(i, (ScoreObjective)null); + } + } + + List list = (List)this.scoreObjectiveCriterias.get(par1ScoreObjective.getCriteria()); + + if (list != null) + { + list.remove(par1ScoreObjective); + } + + Iterator iterator = this.field_96544_c.values().iterator(); + + while (iterator.hasNext()) + { + Map map = (Map)iterator.next(); + map.remove(par1ScoreObjective); + } + + this.func_96533_c(par1ScoreObjective); + } + + public void func_96530_a(int par1, ScoreObjective par2ScoreObjective) + { + this.field_96541_d[par1] = par2ScoreObjective; + } + + public ScoreObjective func_96539_a(int par1) + { + return this.field_96541_d[par1]; + } + + public ScorePlayerTeam getTeam(String par1Str) + { + return (ScorePlayerTeam)this.teams.get(par1Str); + } + + public ScorePlayerTeam createTeam(String par1Str) + { + ScorePlayerTeam scoreplayerteam = this.getTeam(par1Str); + + if (scoreplayerteam != null) + { + throw new IllegalArgumentException("A team with the name \'" + par1Str + "\' already exists!"); + } + else + { + scoreplayerteam = new ScorePlayerTeam(this, par1Str); + this.teams.put(par1Str, scoreplayerteam); + this.broadcastTeamCreated(scoreplayerteam); + return scoreplayerteam; + } + } + + public void removeTeam(ScorePlayerTeam par1ScorePlayerTeam) + { + this.teams.remove(par1ScorePlayerTeam.getRegisteredName()); + Iterator iterator = par1ScorePlayerTeam.getMembershipCollection().iterator(); + + while (iterator.hasNext()) + { + String s = (String)iterator.next(); + this.teamMemberships.remove(s); + } + + this.func_96513_c(par1ScorePlayerTeam); + } + + public boolean func_151392_a(String p_151392_1_, String p_151392_2_) + { + if (!this.teams.containsKey(p_151392_2_)) + { + return false; + } + else + { + ScorePlayerTeam scoreplayerteam = this.getTeam(p_151392_2_); + + if (this.getPlayersTeam(p_151392_1_) != null) + { + this.removePlayerFromTeams(p_151392_1_); + } + + this.teamMemberships.put(p_151392_1_, scoreplayerteam); + scoreplayerteam.getMembershipCollection().add(p_151392_1_); + return true; + } + } + + public boolean removePlayerFromTeams(String par1Str) + { + ScorePlayerTeam scoreplayerteam = this.getPlayersTeam(par1Str); + + if (scoreplayerteam != null) + { + this.removePlayerFromTeam(par1Str, scoreplayerteam); + return true; + } + else + { + return false; + } + } + + public void removePlayerFromTeam(String par1Str, ScorePlayerTeam par2ScorePlayerTeam) + { + if (this.getPlayersTeam(par1Str) != par2ScorePlayerTeam) + { + throw new IllegalStateException("Player is either on another team or not on any team. Cannot remove from team \'" + par2ScorePlayerTeam.getRegisteredName() + "\'."); + } + else + { + this.teamMemberships.remove(par1Str); + par2ScorePlayerTeam.getMembershipCollection().remove(par1Str); + } + } + + public Collection getTeamNames() + { + return this.teams.keySet(); + } + + public Collection getTeams() + { + return this.teams.values(); + } + + public ScorePlayerTeam getPlayersTeam(String par1Str) + { + return (ScorePlayerTeam)this.teamMemberships.get(par1Str); + } + + public void func_96522_a(ScoreObjective par1ScoreObjective) {} + + public void func_96532_b(ScoreObjective par1ScoreObjective) {} + + public void func_96533_c(ScoreObjective par1ScoreObjective) {} + + public void func_96536_a(Score par1Score) {} + + public void func_96516_a(String par1Str) {} + + public void broadcastTeamCreated(ScorePlayerTeam par1ScorePlayerTeam) {} + + public void broadcastTeamRemoved(ScorePlayerTeam par1ScorePlayerTeam) {} + + public void func_96513_c(ScorePlayerTeam par1ScorePlayerTeam) {} + + public static String getObjectiveDisplaySlot(int par0) + { + switch (par0) + { + case 0: + return "list"; + case 1: + return "sidebar"; + case 2: + return "belowName"; + default: + return null; + } + } + + public static int getObjectiveDisplaySlotNumber(String par0Str) + { + return par0Str.equalsIgnoreCase("list") ? 0 : (par0Str.equalsIgnoreCase("sidebar") ? 1 : (par0Str.equalsIgnoreCase("belowName") ? 2 : -1)); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/scoreboard/ScoreboardSaveData.java b/src/main/java/net/minecraft/scoreboard/ScoreboardSaveData.java new file mode 100644 index 0000000..c7ad7fa --- /dev/null +++ b/src/main/java/net/minecraft/scoreboard/ScoreboardSaveData.java @@ -0,0 +1,235 @@ +package net.minecraft.scoreboard; + +import java.util.Collection; +import java.util.Iterator; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.nbt.NBTTagString; +import net.minecraft.world.WorldSavedData; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class ScoreboardSaveData extends WorldSavedData +{ + private static final Logger logger = LogManager.getLogger(); + private Scoreboard theScoreboard; + private NBTTagCompound field_96506_b; + private static final String __OBFID = "CL_00000620"; + + public ScoreboardSaveData() + { + this("scoreboard"); + } + + public ScoreboardSaveData(String par1Str) + { + super(par1Str); + } + + public void func_96499_a(Scoreboard par1Scoreboard) + { + this.theScoreboard = par1Scoreboard; + + if (this.field_96506_b != null) + { + this.readFromNBT(this.field_96506_b); + } + } + + public void readFromNBT(NBTTagCompound par1NBTTagCompound) + { + if (this.theScoreboard == null) + { + this.field_96506_b = par1NBTTagCompound; + } + else + { + this.func_96501_b(par1NBTTagCompound.getTagList("Objectives", 10)); + this.func_96500_c(par1NBTTagCompound.getTagList("PlayerScores", 10)); + + if (par1NBTTagCompound.hasKey("DisplaySlots", 10)) + { + this.func_96504_c(par1NBTTagCompound.getCompoundTag("DisplaySlots")); + } + + if (par1NBTTagCompound.hasKey("Teams", 9)) + { + this.func_96498_a(par1NBTTagCompound.getTagList("Teams", 10)); + } + } + } + + protected void func_96498_a(NBTTagList par1NBTTagList) + { + for (int i = 0; i < par1NBTTagList.tagCount(); ++i) + { + NBTTagCompound nbttagcompound = par1NBTTagList.getCompoundTagAt(i); + ScorePlayerTeam scoreplayerteam = this.theScoreboard.createTeam(nbttagcompound.getString("Name")); + scoreplayerteam.setTeamName(nbttagcompound.getString("DisplayName")); + scoreplayerteam.setNamePrefix(nbttagcompound.getString("Prefix")); + scoreplayerteam.setNameSuffix(nbttagcompound.getString("Suffix")); + + if (nbttagcompound.hasKey("AllowFriendlyFire", 99)) + { + scoreplayerteam.setAllowFriendlyFire(nbttagcompound.getBoolean("AllowFriendlyFire")); + } + + if (nbttagcompound.hasKey("SeeFriendlyInvisibles", 99)) + { + scoreplayerteam.setSeeFriendlyInvisiblesEnabled(nbttagcompound.getBoolean("SeeFriendlyInvisibles")); + } + + this.func_96502_a(scoreplayerteam, nbttagcompound.getTagList("Players", 8)); + } + } + + protected void func_96502_a(ScorePlayerTeam par1ScorePlayerTeam, NBTTagList par2NBTTagList) + { + for (int i = 0; i < par2NBTTagList.tagCount(); ++i) + { + this.theScoreboard.func_151392_a(par2NBTTagList.getStringTagAt(i), par1ScorePlayerTeam.getRegisteredName()); + } + } + + protected void func_96504_c(NBTTagCompound par1NBTTagCompound) + { + for (int i = 0; i < 3; ++i) + { + if (par1NBTTagCompound.hasKey("slot_" + i, 8)) + { + String s = par1NBTTagCompound.getString("slot_" + i); + ScoreObjective scoreobjective = this.theScoreboard.getObjective(s); + this.theScoreboard.func_96530_a(i, scoreobjective); + } + } + } + + protected void func_96501_b(NBTTagList par1NBTTagList) + { + for (int i = 0; i < par1NBTTagList.tagCount(); ++i) + { + NBTTagCompound nbttagcompound = par1NBTTagList.getCompoundTagAt(i); + IScoreObjectiveCriteria iscoreobjectivecriteria = (IScoreObjectiveCriteria)IScoreObjectiveCriteria.field_96643_a.get(nbttagcompound.getString("CriteriaName")); + ScoreObjective scoreobjective = this.theScoreboard.addScoreObjective(nbttagcompound.getString("Name"), iscoreobjectivecriteria); + scoreobjective.setDisplayName(nbttagcompound.getString("DisplayName")); + } + } + + protected void func_96500_c(NBTTagList par1NBTTagList) + { + for (int i = 0; i < par1NBTTagList.tagCount(); ++i) + { + NBTTagCompound nbttagcompound = par1NBTTagList.getCompoundTagAt(i); + ScoreObjective scoreobjective = this.theScoreboard.getObjective(nbttagcompound.getString("Objective")); + Score score = this.theScoreboard.func_96529_a(nbttagcompound.getString("Name"), scoreobjective); + score.setScorePoints(nbttagcompound.getInteger("Score")); + } + } + + public void writeToNBT(NBTTagCompound par1NBTTagCompound) + { + if (this.theScoreboard == null) + { + logger.warn("Tried to save scoreboard without having a scoreboard..."); + } + else + { + par1NBTTagCompound.setTag("Objectives", this.func_96505_b()); + par1NBTTagCompound.setTag("PlayerScores", this.func_96503_e()); + par1NBTTagCompound.setTag("Teams", this.func_96496_a()); + this.func_96497_d(par1NBTTagCompound); + } + } + + protected NBTTagList func_96496_a() + { + NBTTagList nbttaglist = new NBTTagList(); + Collection collection = this.theScoreboard.getTeams(); + Iterator iterator = collection.iterator(); + + while (iterator.hasNext()) + { + ScorePlayerTeam scoreplayerteam = (ScorePlayerTeam)iterator.next(); + NBTTagCompound nbttagcompound = new NBTTagCompound(); + nbttagcompound.setString("Name", scoreplayerteam.getRegisteredName()); + nbttagcompound.setString("DisplayName", scoreplayerteam.func_96669_c()); + nbttagcompound.setString("Prefix", scoreplayerteam.getColorPrefix()); + nbttagcompound.setString("Suffix", scoreplayerteam.getColorSuffix()); + nbttagcompound.setBoolean("AllowFriendlyFire", scoreplayerteam.getAllowFriendlyFire()); + nbttagcompound.setBoolean("SeeFriendlyInvisibles", scoreplayerteam.func_98297_h()); + NBTTagList nbttaglist1 = new NBTTagList(); + Iterator iterator1 = scoreplayerteam.getMembershipCollection().iterator(); + + while (iterator1.hasNext()) + { + String s = (String)iterator1.next(); + nbttaglist1.appendTag(new NBTTagString(s)); + } + + nbttagcompound.setTag("Players", nbttaglist1); + nbttaglist.appendTag(nbttagcompound); + } + + return nbttaglist; + } + + protected void func_96497_d(NBTTagCompound par1NBTTagCompound) + { + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + boolean flag = false; + + for (int i = 0; i < 3; ++i) + { + ScoreObjective scoreobjective = this.theScoreboard.func_96539_a(i); + + if (scoreobjective != null) + { + nbttagcompound1.setString("slot_" + i, scoreobjective.getName()); + flag = true; + } + } + + if (flag) + { + par1NBTTagCompound.setTag("DisplaySlots", nbttagcompound1); + } + } + + protected NBTTagList func_96505_b() + { + NBTTagList nbttaglist = new NBTTagList(); + Collection collection = this.theScoreboard.getScoreObjectives(); + Iterator iterator = collection.iterator(); + + while (iterator.hasNext()) + { + ScoreObjective scoreobjective = (ScoreObjective)iterator.next(); + NBTTagCompound nbttagcompound = new NBTTagCompound(); + nbttagcompound.setString("Name", scoreobjective.getName()); + nbttagcompound.setString("CriteriaName", scoreobjective.getCriteria().func_96636_a()); + nbttagcompound.setString("DisplayName", scoreobjective.getDisplayName()); + nbttaglist.appendTag(nbttagcompound); + } + + return nbttaglist; + } + + protected NBTTagList func_96503_e() + { + NBTTagList nbttaglist = new NBTTagList(); + Collection collection = this.theScoreboard.func_96528_e(); + Iterator iterator = collection.iterator(); + + while (iterator.hasNext()) + { + Score score = (Score)iterator.next(); + NBTTagCompound nbttagcompound = new NBTTagCompound(); + nbttagcompound.setString("Name", score.getPlayerName()); + nbttagcompound.setString("Objective", score.func_96645_d().getName()); + nbttagcompound.setInteger("Score", score.getScorePoints()); + nbttaglist.appendTag(nbttagcompound); + } + + return nbttaglist; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/scoreboard/ServerScoreboard.java b/src/main/java/net/minecraft/scoreboard/ServerScoreboard.java new file mode 100644 index 0000000..0ccd352 --- /dev/null +++ b/src/main/java/net/minecraft/scoreboard/ServerScoreboard.java @@ -0,0 +1,260 @@ +package net.minecraft.scoreboard; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S3BPacketScoreboardObjective; +import net.minecraft.network.play.server.S3CPacketUpdateScore; +import net.minecraft.network.play.server.S3DPacketDisplayScoreboard; +import net.minecraft.network.play.server.S3EPacketTeams; +import net.minecraft.server.MinecraftServer; + +public class ServerScoreboard extends Scoreboard +{ + private final MinecraftServer scoreboardMCServer; + private final Set field_96553_b = new HashSet(); + private ScoreboardSaveData field_96554_c; + private static final String __OBFID = "CL_00001424"; + + public ServerScoreboard(MinecraftServer par1MinecraftServer) + { + this.scoreboardMCServer = par1MinecraftServer; + } + + public void func_96536_a(Score par1Score) + { + super.func_96536_a(par1Score); + + if (this.field_96553_b.contains(par1Score.func_96645_d())) + { + this.scoreboardMCServer.getConfigurationManager().sendPacketToAllPlayers(new S3CPacketUpdateScore(par1Score, 0)); + } + + this.func_96551_b(); + } + + public void func_96516_a(String par1Str) + { + super.func_96516_a(par1Str); + this.scoreboardMCServer.getConfigurationManager().sendPacketToAllPlayers(new S3CPacketUpdateScore(par1Str)); + this.func_96551_b(); + } + + public void func_96530_a(int par1, ScoreObjective par2ScoreObjective) + { + ScoreObjective scoreobjective1 = this.func_96539_a(par1); + super.func_96530_a(par1, par2ScoreObjective); + + if (scoreobjective1 != par2ScoreObjective && scoreobjective1 != null) + { + if (this.func_96552_h(scoreobjective1) > 0) + { + this.scoreboardMCServer.getConfigurationManager().sendPacketToAllPlayers(new S3DPacketDisplayScoreboard(par1, par2ScoreObjective)); + } + else + { + this.func_96546_g(scoreobjective1); + } + } + + if (par2ScoreObjective != null) + { + if (this.field_96553_b.contains(par2ScoreObjective)) + { + this.scoreboardMCServer.getConfigurationManager().sendPacketToAllPlayers(new S3DPacketDisplayScoreboard(par1, par2ScoreObjective)); + } + else + { + this.func_96549_e(par2ScoreObjective); + } + } + + this.func_96551_b(); + } + + public boolean func_151392_a(String p_151392_1_, String p_151392_2_) + { + if (super.func_151392_a(p_151392_1_, p_151392_2_)) + { + ScorePlayerTeam scoreplayerteam = this.getTeam(p_151392_2_); + this.scoreboardMCServer.getConfigurationManager().sendPacketToAllPlayers(new S3EPacketTeams(scoreplayerteam, Arrays.asList(new String[] {p_151392_1_}), 3)); + this.func_96551_b(); + return true; + } + else + { + return false; + } + } + + public void removePlayerFromTeam(String par1Str, ScorePlayerTeam par2ScorePlayerTeam) + { + super.removePlayerFromTeam(par1Str, par2ScorePlayerTeam); + this.scoreboardMCServer.getConfigurationManager().sendPacketToAllPlayers(new S3EPacketTeams(par2ScorePlayerTeam, Arrays.asList(new String[] {par1Str}), 4)); + this.func_96551_b(); + } + + public void func_96522_a(ScoreObjective par1ScoreObjective) + { + super.func_96522_a(par1ScoreObjective); + this.func_96551_b(); + } + + public void func_96532_b(ScoreObjective par1ScoreObjective) + { + super.func_96532_b(par1ScoreObjective); + + if (this.field_96553_b.contains(par1ScoreObjective)) + { + this.scoreboardMCServer.getConfigurationManager().sendPacketToAllPlayers(new S3BPacketScoreboardObjective(par1ScoreObjective, 2)); + } + + this.func_96551_b(); + } + + public void func_96533_c(ScoreObjective par1ScoreObjective) + { + super.func_96533_c(par1ScoreObjective); + + if (this.field_96553_b.contains(par1ScoreObjective)) + { + this.func_96546_g(par1ScoreObjective); + } + + this.func_96551_b(); + } + + public void broadcastTeamCreated(ScorePlayerTeam par1ScorePlayerTeam) + { + super.broadcastTeamCreated(par1ScorePlayerTeam); + this.scoreboardMCServer.getConfigurationManager().sendPacketToAllPlayers(new S3EPacketTeams(par1ScorePlayerTeam, 0)); + this.func_96551_b(); + } + + public void broadcastTeamRemoved(ScorePlayerTeam par1ScorePlayerTeam) + { + super.broadcastTeamRemoved(par1ScorePlayerTeam); + this.scoreboardMCServer.getConfigurationManager().sendPacketToAllPlayers(new S3EPacketTeams(par1ScorePlayerTeam, 2)); + this.func_96551_b(); + } + + public void func_96513_c(ScorePlayerTeam par1ScorePlayerTeam) + { + super.func_96513_c(par1ScorePlayerTeam); + this.scoreboardMCServer.getConfigurationManager().sendPacketToAllPlayers(new S3EPacketTeams(par1ScorePlayerTeam, 1)); + this.func_96551_b(); + } + + public void func_96547_a(ScoreboardSaveData par1ScoreboardSaveData) + { + this.field_96554_c = par1ScoreboardSaveData; + } + + protected void func_96551_b() + { + if (this.field_96554_c != null) + { + this.field_96554_c.markDirty(); + } + } + + public List func_96550_d(ScoreObjective par1ScoreObjective) + { + ArrayList arraylist = new ArrayList(); + arraylist.add(new S3BPacketScoreboardObjective(par1ScoreObjective, 0)); + + for (int i = 0; i < 3; ++i) + { + if (this.func_96539_a(i) == par1ScoreObjective) + { + arraylist.add(new S3DPacketDisplayScoreboard(i, par1ScoreObjective)); + } + } + + Iterator iterator = this.func_96534_i(par1ScoreObjective).iterator(); + + while (iterator.hasNext()) + { + Score score = (Score)iterator.next(); + arraylist.add(new S3CPacketUpdateScore(score, 0)); + } + + return arraylist; + } + + public void func_96549_e(ScoreObjective par1ScoreObjective) + { + List list = this.func_96550_d(par1ScoreObjective); + Iterator iterator = this.scoreboardMCServer.getConfigurationManager().playerEntityList.iterator(); + + while (iterator.hasNext()) + { + EntityPlayerMP entityplayermp = (EntityPlayerMP)iterator.next(); + Iterator iterator1 = list.iterator(); + + while (iterator1.hasNext()) + { + Packet packet = (Packet)iterator1.next(); + entityplayermp.playerNetServerHandler.sendPacket(packet); + } + } + + this.field_96553_b.add(par1ScoreObjective); + } + + public List func_96548_f(ScoreObjective par1ScoreObjective) + { + ArrayList arraylist = new ArrayList(); + arraylist.add(new S3BPacketScoreboardObjective(par1ScoreObjective, 1)); + + for (int i = 0; i < 3; ++i) + { + if (this.func_96539_a(i) == par1ScoreObjective) + { + arraylist.add(new S3DPacketDisplayScoreboard(i, par1ScoreObjective)); + } + } + + return arraylist; + } + + public void func_96546_g(ScoreObjective par1ScoreObjective) + { + List list = this.func_96548_f(par1ScoreObjective); + Iterator iterator = this.scoreboardMCServer.getConfigurationManager().playerEntityList.iterator(); + + while (iterator.hasNext()) + { + EntityPlayerMP entityplayermp = (EntityPlayerMP)iterator.next(); + Iterator iterator1 = list.iterator(); + + while (iterator1.hasNext()) + { + Packet packet = (Packet)iterator1.next(); + entityplayermp.playerNetServerHandler.sendPacket(packet); + } + } + + this.field_96553_b.remove(par1ScoreObjective); + } + + public int func_96552_h(ScoreObjective par1ScoreObjective) + { + int i = 0; + + for (int j = 0; j < 3; ++j) + { + if (this.func_96539_a(j) == par1ScoreObjective) + { + ++i; + } + } + + return i; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/scoreboard/Team.java b/src/main/java/net/minecraft/scoreboard/Team.java new file mode 100644 index 0000000..8587265 --- /dev/null +++ b/src/main/java/net/minecraft/scoreboard/Team.java @@ -0,0 +1,23 @@ +package net.minecraft.scoreboard; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public abstract class Team +{ + private static final String __OBFID = "CL_00000621"; + + public boolean isSameTeam(Team par1Team) + { + return par1Team == null ? false : this == par1Team; + } + + public abstract String getRegisteredName(); + + public abstract String formatString(String var1); + + @SideOnly(Side.CLIENT) + public abstract boolean func_98297_h(); + + public abstract boolean getAllowFriendlyFire(); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java new file mode 100644 index 0000000..6558617 --- /dev/null +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -0,0 +1,1428 @@ +package net.minecraft.server; + +import com.google.common.base.Charsets; +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.minecraft.MinecraftSessionService; +import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.LoaderState; +import cpw.mods.fml.common.StartupQuery; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.ByteBufOutputStream; +import io.netty.buffer.Unpooled; +import io.netty.handler.codec.base64.Base64; +import java.awt.GraphicsEnvironment; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.net.Proxy; +import java.security.KeyPair; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Date; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import java.util.UUID; +import java.util.concurrent.Callable; +import javax.imageio.ImageIO; +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandManager; +import net.minecraft.command.ICommandSender; +import net.minecraft.command.ServerCommandManager; +import net.minecraft.crash.CrashReport; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.init.Bootstrap; +import net.minecraft.network.NetworkSystem; +import net.minecraft.network.ServerStatusResponse; +import net.minecraft.network.play.server.S03PacketTimeUpdate; +import net.minecraft.network.rcon.RConConsoleSource; +import net.minecraft.profiler.IPlayerUsage; +import net.minecraft.profiler.PlayerUsageSnooper; +import net.minecraft.profiler.Profiler; +import net.minecraft.server.dedicated.DedicatedServer; +import net.minecraft.server.gui.IUpdatePlayerListBox; +import net.minecraft.server.management.ServerConfigurationManager; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.IChatComponent; +import net.minecraft.util.IProgressUpdate; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ReportedException; +import net.minecraft.world.EnumDifficulty; +import net.minecraft.world.MinecraftException; +import net.minecraft.world.World; +import net.minecraft.world.WorldManager; +import net.minecraft.world.WorldServer; +import net.minecraft.world.WorldServerMulti; +import net.minecraft.world.WorldSettings; +import net.minecraft.world.WorldType; +import net.minecraft.world.chunk.storage.AnvilSaveConverter; +import net.minecraft.world.demo.DemoWorldServer; +import net.minecraft.world.storage.ISaveFormat; +import net.minecraft.world.storage.ISaveHandler; +import net.minecraft.world.storage.WorldInfo; +import org.apache.commons.lang3.Validate; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import net.minecraftforge.common.DimensionManager; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.world.WorldEvent; + +public abstract class MinecraftServer implements ICommandSender, Runnable, IPlayerUsage +{ + private static final Logger logger = LogManager.getLogger(); + private static MinecraftServer mcServer; + private final ISaveFormat anvilConverterForAnvilFile; + private final PlayerUsageSnooper usageSnooper = new PlayerUsageSnooper("server", this, getSystemTimeMillis()); + private final File anvilFile; + private final List tickables = new ArrayList(); + private final ICommandManager commandManager; + public final Profiler theProfiler = new Profiler(); + private final NetworkSystem field_147144_o; + private final ServerStatusResponse field_147147_p = new ServerStatusResponse(); + private final Random field_147146_q = new Random(); + @SideOnly(Side.SERVER) + private String hostname; + private int serverPort = -1; + public WorldServer[] worldServers = new WorldServer[0]; + private ServerConfigurationManager serverConfigManager; + private boolean serverRunning = true; + private boolean serverStopped; + private int tickCounter; + protected final Proxy serverProxy; + public String currentTask; + public int percentDone; + private boolean onlineMode; + private boolean canSpawnAnimals; + private boolean canSpawnNPCs; + private boolean pvpEnabled; + private boolean allowFlight; + private String motd; + private int buildLimit; + private int field_143008_E = 0; + public final long[] tickTimeArray = new long[100]; + //public long[][] timeOfLastDimensionTick; + public Hashtable worldTickTimes = new Hashtable(); + private KeyPair serverKeyPair; + private String serverOwner; + private String folderName; + @SideOnly(Side.CLIENT) + private String worldName; + private boolean isDemo; + private boolean enableBonusChest; + private boolean worldIsBeingDeleted; + private String field_147141_M = ""; + private boolean serverIsRunning; + private long timeOfLastWarning; + private String userMessage; + private boolean startProfiling; + private boolean isGamemodeForced; + private final MinecraftSessionService field_147143_S; + private long field_147142_T = 0L; + private static final String __OBFID = "CL_00001462"; + + public MinecraftServer(File p_i45281_1_, Proxy p_i45281_2_) + { + mcServer = this; + this.serverProxy = p_i45281_2_; + this.anvilFile = p_i45281_1_; + this.field_147144_o = new NetworkSystem(this); + this.commandManager = new ServerCommandManager(); + this.anvilConverterForAnvilFile = new AnvilSaveConverter(p_i45281_1_); + this.field_147143_S = (new YggdrasilAuthenticationService(p_i45281_2_, UUID.randomUUID().toString())).createMinecraftSessionService(); + } + + protected abstract boolean startServer() throws IOException; + + protected void convertMapIfNeeded(String par1Str) + { + if (this.getActiveAnvilConverter().isOldMapFormat(par1Str)) + { + logger.info("Converting map!"); + this.setUserMessage("menu.convertingLevel"); + this.getActiveAnvilConverter().convertMapFormat(par1Str, new IProgressUpdate() + { + private long field_96245_b = System.currentTimeMillis(); + private static final String __OBFID = "CL_00001417"; + public void displayProgressMessage(String par1Str) {} + public void setLoadingProgress(int par1) + { + if (System.currentTimeMillis() - this.field_96245_b >= 1000L) + { + this.field_96245_b = System.currentTimeMillis(); + MinecraftServer.logger.info("Converting... " + par1 + "%"); + } + } + @SideOnly(Side.CLIENT) + public void resetProgressAndMessage(String par1Str) {} + @SideOnly(Side.CLIENT) + public void func_146586_a() {} + public void resetProgresAndWorkingMessage(String par1Str) {} + }); + } + } + + protected synchronized void setUserMessage(String par1Str) + { + this.userMessage = par1Str; + } + + @SideOnly(Side.CLIENT) + + public synchronized String getUserMessage() + { + return this.userMessage; + } + + protected void loadAllWorlds(String par1Str, String par2Str, long par3, WorldType par5WorldType, String par6Str) + { + this.convertMapIfNeeded(par1Str); + this.setUserMessage("menu.loadingLevel"); + ISaveHandler isavehandler = this.anvilConverterForAnvilFile.getSaveLoader(par1Str, true); + WorldInfo worldinfo = isavehandler.loadWorldInfo(); + WorldSettings worldsettings; + + if (worldinfo == null) + { + worldsettings = new WorldSettings(par3, this.getGameType(), this.canStructuresSpawn(), this.isHardcore(), par5WorldType); + worldsettings.func_82750_a(par6Str); + } + else + { + worldsettings = new WorldSettings(worldinfo); + } + + if (this.enableBonusChest) + { + worldsettings.enableBonusChest(); + } + + WorldServer overWorld = (isDemo() ? new DemoWorldServer(this, isavehandler, par2Str, 0, theProfiler) : new WorldServer(this, isavehandler, par2Str, 0, worldsettings, theProfiler)); + for (int dim : DimensionManager.getStaticDimensionIDs()) + { + WorldServer world = (dim == 0 ? overWorld : new WorldServerMulti(this, isavehandler, par2Str, dim, worldsettings, overWorld, theProfiler)); + world.addWorldAccess(new WorldManager(this, world)); + + if (!this.isSinglePlayer()) + { + world.getWorldInfo().setGameType(this.getGameType()); + } + + MinecraftForge.EVENT_BUS.post(new WorldEvent.Load(world)); + } + + this.serverConfigManager.setPlayerManager(new WorldServer[]{ overWorld }); + this.func_147139_a(this.func_147135_j()); + this.initialWorldChunkLoad(); + } + + protected void initialWorldChunkLoad() + { + boolean flag = true; + boolean flag1 = true; + boolean flag2 = true; + boolean flag3 = true; + int i = 0; + this.setUserMessage("menu.generatingTerrain"); + byte b0 = 0; + logger.info("Preparing start region for level " + b0); + WorldServer worldserver = this.worldServers[b0]; + ChunkCoordinates chunkcoordinates = worldserver.getSpawnPoint(); + long j = getSystemTimeMillis(); + + for (int k = -192; k <= 192 && this.isServerRunning(); k += 16) + { + for (int l = -192; l <= 192 && this.isServerRunning(); l += 16) + { + long i1 = getSystemTimeMillis(); + + if (i1 - j > 1000L) + { + this.outputPercentRemaining("Preparing spawn area", i * 100 / 625); + j = i1; + } + + ++i; + worldserver.theChunkProviderServer.loadChunk(chunkcoordinates.posX + k >> 4, chunkcoordinates.posZ + l >> 4); + } + } + + this.clearCurrentTask(); + } + + public abstract boolean canStructuresSpawn(); + + public abstract WorldSettings.GameType getGameType(); + + public abstract EnumDifficulty func_147135_j(); + + public abstract boolean isHardcore(); + + public abstract int getOpPermissionLevel(); + + protected void outputPercentRemaining(String par1Str, int par2) + { + this.currentTask = par1Str; + this.percentDone = par2; + logger.info(par1Str + ": " + par2 + "%"); + } + + protected void clearCurrentTask() + { + this.currentTask = null; + this.percentDone = 0; + } + + protected void saveAllWorlds(boolean par1) + { + if (!this.worldIsBeingDeleted) + { + WorldServer[] aworldserver = this.worldServers; + if (aworldserver == null) return; //Forge: Just in case, NPE protection as it has been encountered. + int i = aworldserver.length; + + for (int j = 0; j < i; ++j) + { + WorldServer worldserver = aworldserver[j]; + + if (worldserver != null) + { + if (!par1) + { + logger.info("Saving chunks for level \'" + worldserver.getWorldInfo().getWorldName() + "\'/" + worldserver.provider.getDimensionName()); + } + + try + { + worldserver.saveAllChunks(true, (IProgressUpdate)null); + } + catch (MinecraftException minecraftexception) + { + logger.warn(minecraftexception.getMessage()); + } + } + } + } + } + + public void stopServer() + { + if (!this.worldIsBeingDeleted && Loader.instance().hasReachedState(LoaderState.SERVER_STARTED)) + { + logger.info("Stopping server"); + + if (this.func_147137_ag() != null) + { + this.func_147137_ag().terminateEndpoints(); + } + + if (this.serverConfigManager != null) + { + logger.info("Saving players"); + this.serverConfigManager.saveAllPlayerData(); + this.serverConfigManager.removeAllPlayers(); + } + + logger.info("Saving worlds"); + this.saveAllWorlds(false); + + for (int i = 0; i < this.worldServers.length; ++i) + { + WorldServer worldserver = this.worldServers[i]; + MinecraftForge.EVENT_BUS.post(new WorldEvent.Unload(worldserver)); + worldserver.flush(); + } + + WorldServer[] tmp = worldServers; + for (WorldServer world : tmp) + { + DimensionManager.setWorld(world.provider.dimensionId, null); + } + + if (this.usageSnooper.isSnooperRunning()) + { + this.usageSnooper.stopSnooper(); + } + } + } + + public boolean isServerRunning() + { + return this.serverRunning; + } + + public void initiateShutdown() + { + this.serverRunning = false; + } + + public void run() + { + try + { + if (this.startServer()) + { + FMLCommonHandler.instance().handleServerStarted(); + long i = getSystemTimeMillis(); + long l = 0L; + this.field_147147_p.func_151315_a(new ChatComponentText(this.motd)); + this.field_147147_p.func_151321_a(new ServerStatusResponse.MinecraftProtocolVersionIdentifier("1.7.2", 4)); + this.func_147138_a(this.field_147147_p); + + while (this.serverRunning) + { + long j = getSystemTimeMillis(); + long k = j - i; + + if (k > 2000L && i - this.timeOfLastWarning >= 15000L) + { + logger.warn("Can\'t keep up! Did the system time change, or is the server overloaded? Running {}ms behind, skipping {} tick(s)", new Object[] {Long.valueOf(k), Long.valueOf(k / 50L)}); + k = 2000L; + this.timeOfLastWarning = i; + } + + if (k < 0L) + { + logger.warn("Time ran backwards! Did the system time change?"); + k = 0L; + } + + l += k; + i = j; + + if (this.worldServers[0].areAllPlayersAsleep()) + { + this.tick(); + l = 0L; + } + else + { + while (l > 50L) + { + l -= 50L; + this.tick(); + } + } + + Thread.sleep(1L); + this.serverIsRunning = true; + } + FMLCommonHandler.instance().handleServerStopping(); + } + else + { + this.finalTick((CrashReport)null); + } + } + catch (StartupQuery.AbortedException e) + { + // ignore silently + } + catch (Throwable throwable1) + { + logger.error("Encountered an unexpected exception", throwable1); + CrashReport crashreport = null; + + if (throwable1 instanceof ReportedException) + { + crashreport = this.addServerInfoToCrashReport(((ReportedException)throwable1).getCrashReport()); + } + else + { + crashreport = this.addServerInfoToCrashReport(new CrashReport("Exception in server tick loop", throwable1)); + } + + File file1 = new File(new File(this.getDataDirectory(), "crash-reports"), "crash-" + (new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss")).format(new Date()) + "-server.txt"); + + if (crashreport.saveToFile(file1)) + { + logger.error("This crash report has been saved to: " + file1.getAbsolutePath()); + } + else + { + logger.error("We were unable to save this crash report to disk."); + } + + this.finalTick(crashreport); + } + finally + { + try + { + this.stopServer(); + this.serverStopped = true; + } + catch (Throwable throwable) + { + logger.error("Exception stopping the server", throwable); + } + finally + { + FMLCommonHandler.instance().handleServerStopped(); + this.serverStopped = true; + this.systemExitNow(); + } + } + } + + private void func_147138_a(ServerStatusResponse p_147138_1_) + { + File file1 = this.getFile("server-icon.png"); + + if (file1.isFile()) + { + ByteBuf bytebuf = Unpooled.buffer(); + + try + { + BufferedImage bufferedimage = ImageIO.read(file1); + Validate.validState(bufferedimage.getWidth() == 64, "Must be 64 pixels wide", new Object[0]); + Validate.validState(bufferedimage.getHeight() == 64, "Must be 64 pixels high", new Object[0]); + ImageIO.write(bufferedimage, "PNG", new ByteBufOutputStream(bytebuf)); + ByteBuf bytebuf1 = Base64.encode(bytebuf); + p_147138_1_.func_151320_a("data:image/png;base64," + bytebuf1.toString(Charsets.UTF_8)); + } + catch (Exception exception) + { + logger.error("Couldn\'t load server icon", exception); + } + } + } + + protected File getDataDirectory() + { + return new File("."); + } + + protected void finalTick(CrashReport par1CrashReport) {} + + protected void systemExitNow() {} + + public void tick() + { + long i = System.nanoTime(); + AxisAlignedBB.getAABBPool().cleanPool(); + FMLCommonHandler.instance().onPreServerTick(); + ++this.tickCounter; + + if (this.startProfiling) + { + this.startProfiling = false; + this.theProfiler.profilingEnabled = true; + this.theProfiler.clearProfiling(); + } + + this.theProfiler.startSection("root"); + this.updateTimeLightAndEntities(); + + if (i - this.field_147142_T >= 5000000000L) + { + this.field_147142_T = i; + this.field_147147_p.func_151319_a(new ServerStatusResponse.PlayerCountData(this.getMaxPlayers(), this.getCurrentPlayerCount())); + GameProfile[] agameprofile = new GameProfile[Math.min(this.getCurrentPlayerCount(), 12)]; + int j = MathHelper.getRandomIntegerInRange(this.field_147146_q, 0, this.getCurrentPlayerCount() - agameprofile.length); + + for (int k = 0; k < agameprofile.length; ++k) + { + agameprofile[k] = ((EntityPlayerMP)this.serverConfigManager.playerEntityList.get(j + k)).getGameProfile(); + } + + Collections.shuffle(Arrays.asList(agameprofile)); + this.field_147147_p.func_151318_b().func_151330_a(agameprofile); + } + + if (this.tickCounter % 900 == 0) + { + this.theProfiler.startSection("save"); + this.serverConfigManager.saveAllPlayerData(); + this.saveAllWorlds(true); + this.theProfiler.endSection(); + } + + this.theProfiler.startSection("tallying"); + this.tickTimeArray[this.tickCounter % 100] = System.nanoTime() - i; + this.theProfiler.endSection(); + this.theProfiler.startSection("snooper"); + + if (!this.usageSnooper.isSnooperRunning() && this.tickCounter > 100) + { + this.usageSnooper.startSnooper(); + } + + if (this.tickCounter % 6000 == 0) + { + this.usageSnooper.addMemoryStatsToSnooper(); + } + + this.theProfiler.endSection(); + this.theProfiler.endSection(); + FMLCommonHandler.instance().onPostServerTick(); + } + + public void updateTimeLightAndEntities() + { + this.theProfiler.startSection("levels"); + int i; + + Integer[] ids = DimensionManager.getIDs(this.tickCounter % 200 == 0); + for (int x = 0; x < ids.length; x++) + { + int id = ids[x]; + long j = System.nanoTime(); + + if (id == 0 || this.getAllowNether()) + { + WorldServer worldserver = DimensionManager.getWorld(id); + this.theProfiler.startSection(worldserver.getWorldInfo().getWorldName()); + this.theProfiler.startSection("pools"); + worldserver.getWorldVec3Pool().clear(); + this.theProfiler.endSection(); + + if (this.tickCounter % 20 == 0) + { + this.theProfiler.startSection("timeSync"); + this.serverConfigManager.sendPacketToAllPlayersInDimension(new S03PacketTimeUpdate(worldserver.getTotalWorldTime(), worldserver.getWorldTime(), worldserver.getGameRules().getGameRuleBooleanValue("doDaylightCycle")), worldserver.provider.dimensionId); + this.theProfiler.endSection(); + } + + this.theProfiler.startSection("tick"); + FMLCommonHandler.instance().onPreWorldTick(worldserver); + CrashReport crashreport; + + try + { + worldserver.tick(); + } + catch (Throwable throwable1) + { + crashreport = CrashReport.makeCrashReport(throwable1, "Exception ticking world"); + worldserver.addWorldInfoToCrashReport(crashreport); + throw new ReportedException(crashreport); + } + + try + { + worldserver.updateEntities(); + } + catch (Throwable throwable) + { + crashreport = CrashReport.makeCrashReport(throwable, "Exception ticking world entities"); + worldserver.addWorldInfoToCrashReport(crashreport); + throw new ReportedException(crashreport); + } + + FMLCommonHandler.instance().onPostWorldTick(worldserver); + this.theProfiler.endSection(); + this.theProfiler.startSection("tracker"); + worldserver.getEntityTracker().updateTrackedEntities(); + this.theProfiler.endSection(); + this.theProfiler.endSection(); + } + + worldTickTimes.get(id)[this.tickCounter % 100] = System.nanoTime() - j; + } + + this.theProfiler.endStartSection("dim_unloading"); + DimensionManager.unloadWorlds(worldTickTimes); + this.theProfiler.endStartSection("connection"); + this.func_147137_ag().networkTick(); + this.theProfiler.endStartSection("players"); + this.serverConfigManager.sendPlayerInfoToAllPlayers(); + this.theProfiler.endStartSection("tickables"); + + for (i = 0; i < this.tickables.size(); ++i) + { + ((IUpdatePlayerListBox)this.tickables.get(i)).update(); + } + + this.theProfiler.endSection(); + } + + public boolean getAllowNether() + { + return true; + } + + public void startServerThread() + { + StartupQuery.reset(); + (new Thread("Server thread") + { + private static final String __OBFID = "CL_00001418"; + public void run() + { + MinecraftServer.this.run(); + } + }).start(); + } + + public File getFile(String par1Str) + { + return new File(this.getDataDirectory(), par1Str); + } + + public void logWarning(String par1Str) + { + logger.warn(par1Str); + } + + public WorldServer worldServerForDimension(int par1) + { + WorldServer ret = DimensionManager.getWorld(par1); + if (ret == null) + { + DimensionManager.initDimension(par1); + ret = DimensionManager.getWorld(par1); + } + return ret; + } + + public String getMinecraftVersion() + { + return "1.7.2"; + } + + public int getCurrentPlayerCount() + { + return this.serverConfigManager.getCurrentPlayerCount(); + } + + public int getMaxPlayers() + { + return this.serverConfigManager.getMaxPlayers(); + } + + public String[] getAllUsernames() + { + return this.serverConfigManager.getAllUsernames(); + } + + public String getServerModName() + { + return FMLCommonHandler.instance().getModName(); + } + + public CrashReport addServerInfoToCrashReport(CrashReport par1CrashReport) + { + par1CrashReport.getCategory().addCrashSectionCallable("Profiler Position", new Callable() + { + private static final String __OBFID = "CL_00001419"; + public String call() + { + return MinecraftServer.this.theProfiler.profilingEnabled ? MinecraftServer.this.theProfiler.getNameOfLastSection() : "N/A (disabled)"; + } + }); + + if (this.worldServers != null && this.worldServers.length > 0 && this.worldServers[0] != null) + { + par1CrashReport.getCategory().addCrashSectionCallable("Vec3 Pool Size", new Callable() + { + private static final String __OBFID = "CL_00001420"; + public String call() + { + int i = MinecraftServer.this.worldServers[0].getWorldVec3Pool().getPoolSize(); + int j = 56 * i; + int k = j / 1024 / 1024; + int l = MinecraftServer.this.worldServers[0].getWorldVec3Pool().getNextFreeSpace(); + int i1 = 56 * l; + int j1 = i1 / 1024 / 1024; + return i + " (" + j + " bytes; " + k + " MB) allocated, " + l + " (" + i1 + " bytes; " + j1 + " MB) used"; + } + }); + } + + if (this.serverConfigManager != null) + { + par1CrashReport.getCategory().addCrashSectionCallable("Player Count", new Callable() + { + private static final String __OBFID = "CL_00001780"; + public String call() + { + return MinecraftServer.this.serverConfigManager.getCurrentPlayerCount() + " / " + MinecraftServer.this.serverConfigManager.getMaxPlayers() + "; " + MinecraftServer.this.serverConfigManager.playerEntityList; + } + }); + } + + return par1CrashReport; + } + + public List getPossibleCompletions(ICommandSender par1ICommandSender, String par2Str) + { + ArrayList arraylist = new ArrayList(); + + if (par2Str.startsWith("/")) + { + par2Str = par2Str.substring(1); + boolean flag = !par2Str.contains(" "); + List list = this.commandManager.getPossibleCommands(par1ICommandSender, par2Str); + + if (list != null) + { + Iterator iterator = list.iterator(); + + while (iterator.hasNext()) + { + String s3 = (String)iterator.next(); + + if (flag) + { + arraylist.add("/" + s3); + } + else + { + arraylist.add(s3); + } + } + } + + return arraylist; + } + else + { + String[] astring = par2Str.split(" ", -1); + String s1 = astring[astring.length - 1]; + String[] astring1 = this.serverConfigManager.getAllUsernames(); + int i = astring1.length; + + for (int j = 0; j < i; ++j) + { + String s2 = astring1[j]; + + if (CommandBase.doesStringStartWith(s1, s2)) + { + arraylist.add(s2); + } + } + + return arraylist; + } + } + + public static MinecraftServer getServer() + { + return mcServer; + } + + public String getCommandSenderName() + { + return "Server"; + } + + public void addChatMessage(IChatComponent p_145747_1_) + { + logger.info(p_145747_1_.getUnformattedText()); + } + + public boolean canCommandSenderUseCommand(int par1, String par2Str) + { + return true; + } + + public ICommandManager getCommandManager() + { + return this.commandManager; + } + + public KeyPair getKeyPair() + { + return this.serverKeyPair; + } + + public String getServerOwner() + { + return this.serverOwner; + } + + public void setServerOwner(String par1Str) + { + this.serverOwner = par1Str; + } + + public boolean isSinglePlayer() + { + return this.serverOwner != null; + } + + public String getFolderName() + { + return this.folderName; + } + + public void setFolderName(String par1Str) + { + this.folderName = par1Str; + } + + @SideOnly(Side.CLIENT) + public void setWorldName(String par1Str) + { + this.worldName = par1Str; + } + + @SideOnly(Side.CLIENT) + public String getWorldName() + { + return this.worldName; + } + + public void setKeyPair(KeyPair par1KeyPair) + { + this.serverKeyPair = par1KeyPair; + } + + public void func_147139_a(EnumDifficulty p_147139_1_) + { + for (int i = 0; i < this.worldServers.length; ++i) + { + WorldServer worldserver = this.worldServers[i]; + + if (worldserver != null) + { + if (worldserver.getWorldInfo().isHardcoreModeEnabled()) + { + worldserver.difficultySetting = EnumDifficulty.HARD; + worldserver.setAllowedSpawnTypes(true, true); + } + else if (this.isSinglePlayer()) + { + worldserver.difficultySetting = p_147139_1_; + worldserver.setAllowedSpawnTypes(worldserver.difficultySetting != EnumDifficulty.PEACEFUL, true); + } + else + { + worldserver.difficultySetting = p_147139_1_; + worldserver.setAllowedSpawnTypes(this.allowSpawnMonsters(), this.canSpawnAnimals); + } + } + } + } + + protected boolean allowSpawnMonsters() + { + return true; + } + + public boolean isDemo() + { + return this.isDemo; + } + + public void setDemo(boolean par1) + { + this.isDemo = par1; + } + + public void canCreateBonusChest(boolean par1) + { + this.enableBonusChest = par1; + } + + public ISaveFormat getActiveAnvilConverter() + { + return this.anvilConverterForAnvilFile; + } + + public void deleteWorldAndStopServer() + { + this.worldIsBeingDeleted = true; + this.getActiveAnvilConverter().flushCache(); + + for (int i = 0; i < this.worldServers.length; ++i) + { + WorldServer worldserver = this.worldServers[i]; + + if (worldserver != null) + { + MinecraftForge.EVENT_BUS.post(new WorldEvent.Unload(worldserver)); + worldserver.flush(); + } + } + + this.getActiveAnvilConverter().deleteWorldDirectory(this.worldServers[0].getSaveHandler().getWorldDirectoryName()); + this.initiateShutdown(); + } + + public String getTexturePack() + { + return this.field_147141_M; + } + + public void addServerStatsToSnooper(PlayerUsageSnooper par1PlayerUsageSnooper) + { + par1PlayerUsageSnooper.addData("whitelist_enabled", Boolean.valueOf(false)); + par1PlayerUsageSnooper.addData("whitelist_count", Integer.valueOf(0)); + par1PlayerUsageSnooper.addData("players_current", Integer.valueOf(this.getCurrentPlayerCount())); + par1PlayerUsageSnooper.addData("players_max", Integer.valueOf(this.getMaxPlayers())); + par1PlayerUsageSnooper.addData("players_seen", Integer.valueOf(this.serverConfigManager.getAvailablePlayerDat().length)); + par1PlayerUsageSnooper.addData("uses_auth", Boolean.valueOf(this.onlineMode)); + par1PlayerUsageSnooper.addData("gui_state", this.getGuiEnabled() ? "enabled" : "disabled"); + par1PlayerUsageSnooper.addData("run_time", Long.valueOf((getSystemTimeMillis() - par1PlayerUsageSnooper.getMinecraftStartTimeMillis()) / 60L * 1000L)); + par1PlayerUsageSnooper.addData("avg_tick_ms", Integer.valueOf((int)(MathHelper.average(this.tickTimeArray) * 1.0E-6D))); + int i = 0; + + for (int j = 0; j < this.worldServers.length; ++j) + { + if (this.worldServers[j] != null) + { + WorldServer worldserver = this.worldServers[j]; + WorldInfo worldinfo = worldserver.getWorldInfo(); + par1PlayerUsageSnooper.addData("world[" + i + "][dimension]", Integer.valueOf(worldserver.provider.dimensionId)); + par1PlayerUsageSnooper.addData("world[" + i + "][mode]", worldinfo.getGameType()); + par1PlayerUsageSnooper.addData("world[" + i + "][difficulty]", worldserver.difficultySetting); + par1PlayerUsageSnooper.addData("world[" + i + "][hardcore]", Boolean.valueOf(worldinfo.isHardcoreModeEnabled())); + par1PlayerUsageSnooper.addData("world[" + i + "][generator_name]", worldinfo.getTerrainType().getWorldTypeName()); + par1PlayerUsageSnooper.addData("world[" + i + "][generator_version]", Integer.valueOf(worldinfo.getTerrainType().getGeneratorVersion())); + par1PlayerUsageSnooper.addData("world[" + i + "][height]", Integer.valueOf(this.buildLimit)); + par1PlayerUsageSnooper.addData("world[" + i + "][chunks_loaded]", Integer.valueOf(worldserver.getChunkProvider().getLoadedChunkCount())); + ++i; + } + } + + par1PlayerUsageSnooper.addData("worlds", Integer.valueOf(i)); + } + + public void addServerTypeToSnooper(PlayerUsageSnooper par1PlayerUsageSnooper) + { + par1PlayerUsageSnooper.addData("singleplayer", Boolean.valueOf(this.isSinglePlayer())); + par1PlayerUsageSnooper.addData("server_brand", this.getServerModName()); + par1PlayerUsageSnooper.addData("gui_supported", GraphicsEnvironment.isHeadless() ? "headless" : "supported"); + par1PlayerUsageSnooper.addData("dedicated", Boolean.valueOf(this.isDedicatedServer())); + } + + public boolean isSnooperEnabled() + { + return true; + } + + public abstract boolean isDedicatedServer(); + + public boolean isServerInOnlineMode() + { + return this.onlineMode; + } + + public void setOnlineMode(boolean par1) + { + this.onlineMode = par1; + } + + public boolean getCanSpawnAnimals() + { + return this.canSpawnAnimals; + } + + public void setCanSpawnAnimals(boolean par1) + { + this.canSpawnAnimals = par1; + } + + public boolean getCanSpawnNPCs() + { + return this.canSpawnNPCs; + } + + public void setCanSpawnNPCs(boolean par1) + { + this.canSpawnNPCs = par1; + } + + public boolean isPVPEnabled() + { + return this.pvpEnabled; + } + + public void setAllowPvp(boolean par1) + { + this.pvpEnabled = par1; + } + + public boolean isFlightAllowed() + { + return this.allowFlight; + } + + public void setAllowFlight(boolean par1) + { + this.allowFlight = par1; + } + + public abstract boolean isCommandBlockEnabled(); + + public String getMOTD() + { + return this.motd; + } + + public void setMOTD(String par1Str) + { + this.motd = par1Str; + } + + public int getBuildLimit() + { + return this.buildLimit; + } + + public void setBuildLimit(int par1) + { + this.buildLimit = par1; + } + + public ServerConfigurationManager getConfigurationManager() + { + return this.serverConfigManager; + } + + public void setConfigurationManager(ServerConfigurationManager par1ServerConfigurationManager) + { + this.serverConfigManager = par1ServerConfigurationManager; + } + + public void setGameType(WorldSettings.GameType par1EnumGameType) + { + for (int i = 0; i < this.worldServers.length; ++i) + { + getServer().worldServers[i].getWorldInfo().setGameType(par1EnumGameType); + } + } + + public NetworkSystem func_147137_ag() + { + return this.field_147144_o; + } + + @SideOnly(Side.CLIENT) + public boolean serverIsInRunLoop() + { + return this.serverIsRunning; + } + + public boolean getGuiEnabled() + { + return false; + } + + public abstract String shareToLAN(WorldSettings.GameType var1, boolean var2); + + public int getTickCounter() + { + return this.tickCounter; + } + + public void enableProfiling() + { + this.startProfiling = true; + } + + @SideOnly(Side.CLIENT) + public PlayerUsageSnooper getPlayerUsageSnooper() + { + return this.usageSnooper; + } + + public ChunkCoordinates getPlayerCoordinates() + { + return new ChunkCoordinates(0, 0, 0); + } + + public World getEntityWorld() + { + return this.worldServers[0]; + } + + public int getSpawnProtectionSize() + { + return 16; + } + + public boolean isBlockProtected(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer) + { + return false; + } + + public boolean getForceGamemode() + { + return this.isGamemodeForced; + } + + public Proxy getServerProxy() + { + return this.serverProxy; + } + + public static long getSystemTimeMillis() + { + return System.currentTimeMillis(); + } + + public int func_143007_ar() + { + return this.field_143008_E; + } + + public void func_143006_e(int par1) + { + this.field_143008_E = par1; + } + + public IChatComponent func_145748_c_() + { + return new ChatComponentText(this.getCommandSenderName()); + } + + public boolean func_147136_ar() + { + return true; + } + + public MinecraftSessionService func_147130_as() + { + return this.field_147143_S; + } + + public ServerStatusResponse func_147134_at() + { + return this.field_147147_p; + } + + public void func_147132_au() + { + this.field_147142_T = 0L; + } + + @SideOnly(Side.SERVER) + public String getServerHostname() + { + return this.hostname; + } + + @SideOnly(Side.SERVER) + public void setHostname(String par1Str) + { + this.hostname = par1Str; + } + + @SideOnly(Side.SERVER) + public void func_82010_a(IUpdatePlayerListBox par1IUpdatePlayerListBox) + { + this.tickables.add(par1IUpdatePlayerListBox); + } + + @SideOnly(Side.SERVER) + public static void main(String[] par0ArrayOfStr) + { + Bootstrap.func_151354_b(); + + try + { + boolean flag = !GraphicsEnvironment.isHeadless(); + String s = null; + String s1 = "."; + String s2 = null; + boolean flag1 = false; + boolean flag2 = false; + int i = -1; + + for (int j = 0; j < par0ArrayOfStr.length; ++j) + { + String s3 = par0ArrayOfStr[j]; + String s4 = j == par0ArrayOfStr.length - 1 ? null : par0ArrayOfStr[j + 1]; + boolean flag3 = false; + + if (!s3.equals("nogui") && !s3.equals("--nogui")) + { + if (s3.equals("--port") && s4 != null) + { + flag3 = true; + + try + { + i = Integer.parseInt(s4); + } + catch (NumberFormatException numberformatexception) + { + ; + } + } + else if (s3.equals("--singleplayer") && s4 != null) + { + flag3 = true; + s = s4; + } + else if (s3.equals("--universe") && s4 != null) + { + flag3 = true; + s1 = s4; + } + else if (s3.equals("--world") && s4 != null) + { + flag3 = true; + s2 = s4; + } + else if (s3.equals("--demo")) + { + flag1 = true; + } + else if (s3.equals("--bonusChest")) + { + flag2 = true; + } + } + else + { + flag = false; + } + + if (flag3) + { + ++j; + } + } + + final DedicatedServer dedicatedserver = new DedicatedServer(new File(s1)); + + if (s != null) + { + dedicatedserver.setServerOwner(s); + } + + if (s2 != null) + { + dedicatedserver.setFolderName(s2); + } + + if (i >= 0) + { + dedicatedserver.setServerPort(i); + } + + if (flag1) + { + dedicatedserver.setDemo(true); + } + + if (flag2) + { + dedicatedserver.canCreateBonusChest(true); + } + + if (flag) + { + dedicatedserver.setGuiEnabled(); + } + + dedicatedserver.startServerThread(); + Runtime.getRuntime().addShutdownHook(new Thread("Server Shutdown Thread") + { + private static final String __OBFID = "CL_00001806"; + public void run() + { + dedicatedserver.stopServer(); + } + }); + } + catch (Exception exception) + { + logger.fatal("Failed to start the minecraft server", exception); + } + } + + @SideOnly(Side.SERVER) + public void logInfo(String par1Str) + { + logger.info(par1Str); + } + + @SideOnly(Side.SERVER) + public String getHostname() + { + return this.hostname; + } + + @SideOnly(Side.SERVER) + public int getPort() + { + return this.serverPort; + } + + @SideOnly(Side.SERVER) + public String getMotd() + { + return this.motd; + } + + @SideOnly(Side.SERVER) + public String getPlugins() + { + return ""; + } + + @SideOnly(Side.SERVER) + public String handleRConCommand(String par1Str) + { + RConConsoleSource.instance.resetLog(); + this.commandManager.executeCommand(RConConsoleSource.instance, par1Str); + return RConConsoleSource.instance.getLogContents(); + } + + @SideOnly(Side.SERVER) + public boolean isDebuggingEnabled() + { + return false; + } + + @SideOnly(Side.SERVER) + public void logSevere(String par1Str) + { + logger.error(par1Str); + } + + @SideOnly(Side.SERVER) + public void logDebug(String par1Str) + { + if (this.isDebuggingEnabled()) + { + logger.info(par1Str); + } + } + + @SideOnly(Side.SERVER) + public int getServerPort() + { + return this.serverPort; + } + + @SideOnly(Side.SERVER) + public void setServerPort(int par1) + { + this.serverPort = par1; + } + + @SideOnly(Side.SERVER) + public void func_155759_m(String p_155759_1_) + { + this.field_147141_M = p_155759_1_; + } + + public boolean isServerStopped() + { + return this.serverStopped; + } + + @SideOnly(Side.SERVER) + public void setForceGamemode(boolean par1) + { + this.isGamemodeForced = par1; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedPlayerList.java b/src/main/java/net/minecraft/server/dedicated/DedicatedPlayerList.java new file mode 100644 index 0000000..9511f5a --- /dev/null +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedPlayerList.java @@ -0,0 +1,183 @@ +package net.minecraft.server.dedicated; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.PrintWriter; +import java.util.Iterator; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.management.ServerConfigurationManager; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +@SideOnly(Side.SERVER) +public class DedicatedPlayerList extends ServerConfigurationManager +{ + private static final Logger field_164439_d = LogManager.getLogger(); + private File opsList; + private File whiteList; + private static final String __OBFID = "CL_00001783"; + + public DedicatedPlayerList(DedicatedServer par1DedicatedServer) + { + super(par1DedicatedServer); + this.opsList = par1DedicatedServer.getFile("ops.txt"); + this.whiteList = par1DedicatedServer.getFile("white-list.txt"); + this.viewDistance = par1DedicatedServer.getIntProperty("view-distance", 10); + this.maxPlayers = par1DedicatedServer.getIntProperty("max-players", 20); + this.setWhiteListEnabled(par1DedicatedServer.getBooleanProperty("white-list", false)); + + if (!par1DedicatedServer.isSinglePlayer()) + { + this.getBannedPlayers().setListActive(true); + this.getBannedIPs().setListActive(true); + } + + this.getBannedPlayers().loadBanList(); + this.getBannedPlayers().saveToFileWithHeader(); + this.getBannedIPs().loadBanList(); + this.getBannedIPs().saveToFileWithHeader(); + this.loadOpsList(); + this.readWhiteList(); + this.saveOpsList(); + + if (!this.whiteList.exists()) + { + this.saveWhiteList(); + } + } + + public void setWhiteListEnabled(boolean par1) + { + super.setWhiteListEnabled(par1); + this.getServerInstance().setProperty("white-list", Boolean.valueOf(par1)); + this.getServerInstance().saveProperties(); + } + + public void addOp(String par1Str) + { + super.addOp(par1Str); + this.saveOpsList(); + } + + public void removeOp(String par1Str) + { + super.removeOp(par1Str); + this.saveOpsList(); + } + + public void removeFromWhitelist(String par1Str) + { + super.removeFromWhitelist(par1Str); + this.saveWhiteList(); + } + + public void addToWhiteList(String par1Str) + { + super.addToWhiteList(par1Str); + this.saveWhiteList(); + } + + public void loadWhiteList() + { + this.readWhiteList(); + } + + private void loadOpsList() + { + try + { + this.getOps().clear(); + BufferedReader bufferedreader = new BufferedReader(new FileReader(this.opsList)); + String s = ""; + + while ((s = bufferedreader.readLine()) != null) + { + this.getOps().add(s.trim().toLowerCase()); + } + + bufferedreader.close(); + } + catch (Exception exception) + { + field_164439_d.warn("Failed to load operators list: " + exception); + } + } + + private void saveOpsList() + { + try + { + PrintWriter printwriter = new PrintWriter(new FileWriter(this.opsList, false)); + Iterator iterator = this.getOps().iterator(); + + while (iterator.hasNext()) + { + String s = (String)iterator.next(); + printwriter.println(s); + } + + printwriter.close(); + } + catch (Exception exception) + { + field_164439_d.warn("Failed to save operators list: " + exception); + } + } + + private void readWhiteList() + { + try + { + this.getWhiteListedPlayers().clear(); + BufferedReader bufferedreader = new BufferedReader(new FileReader(this.whiteList)); + String s = ""; + + while ((s = bufferedreader.readLine()) != null) + { + this.getWhiteListedPlayers().add(s.trim().toLowerCase()); + } + + bufferedreader.close(); + } + catch (Exception exception) + { + field_164439_d.warn("Failed to load white-list: " + exception); + } + } + + private void saveWhiteList() + { + try + { + PrintWriter printwriter = new PrintWriter(new FileWriter(this.whiteList, false)); + Iterator iterator = this.getWhiteListedPlayers().iterator(); + + while (iterator.hasNext()) + { + String s = (String)iterator.next(); + printwriter.println(s); + } + + printwriter.close(); + } + catch (Exception exception) + { + field_164439_d.warn("Failed to save white-list: " + exception); + } + } + + public boolean isAllowedToLogin(String par1Str) + { + par1Str = par1Str.trim().toLowerCase(); + return !this.isWhiteListEnabled() || this.isPlayerOpped(par1Str) || this.getWhiteListedPlayers().contains(par1Str); + } + + public DedicatedServer getServerInstance() + { + return (DedicatedServer)super.getServerInstance(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java new file mode 100644 index 0000000..10b1036 --- /dev/null +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java @@ -0,0 +1,477 @@ +package net.minecraft.server.dedicated; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.InetAddress; +import java.net.Proxy; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Random; +import java.util.concurrent.Callable; +import net.minecraft.command.ICommandSender; +import net.minecraft.command.ServerCommand; +import net.minecraft.crash.CrashReport; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.network.rcon.IServer; +import net.minecraft.network.rcon.RConThreadMain; +import net.minecraft.network.rcon.RConThreadQuery; +import net.minecraft.profiler.PlayerUsageSnooper; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.gui.MinecraftServerGui; +import net.minecraft.server.management.ServerConfigurationManager; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.CryptManager; +import net.minecraft.util.MathHelper; +import net.minecraft.world.EnumDifficulty; +import net.minecraft.world.World; +import net.minecraft.world.WorldSettings; +import net.minecraft.world.WorldType; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +@SideOnly(Side.SERVER) +public class DedicatedServer extends MinecraftServer implements IServer +{ + private static final Logger field_155771_h = LogManager.getLogger(); + public final List pendingCommandList = Collections.synchronizedList(new ArrayList()); + private RConThreadQuery theRConThreadQuery; + private RConThreadMain theRConThreadMain; + private PropertyManager settings; + private boolean canSpawnStructures; + private WorldSettings.GameType gameType; + private boolean guiIsEnabled; + public static boolean allowPlayerLogins = false; + private static final String __OBFID = "CL_00001784"; + + public DedicatedServer(File par1File) + { + super(par1File, Proxy.NO_PROXY); + Thread thread = new Thread("Server Infinisleeper") + { + private static final String __OBFID = "CL_00001787"; + { + this.setDaemon(true); + this.start(); + } + public void run() + { + while (true) + { + try + { + while (true) + { + Thread.sleep(2147483647L); + } + } + catch (InterruptedException interruptedexception) + { + ; + } + } + } + }; + } + + protected boolean startServer() throws IOException + { + Thread thread = new Thread("Server console handler") + { + private static final String __OBFID = "CL_00001786"; + public void run() + { + BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(System.in)); + String s4; + + try + { + while (!DedicatedServer.this.isServerStopped() && DedicatedServer.this.isServerRunning() && (s4 = bufferedreader.readLine()) != null) + { + DedicatedServer.this.addPendingCommand(s4, DedicatedServer.this); + } + } + catch (IOException ioexception1) + { + DedicatedServer.field_155771_h.error("Exception handling console input", ioexception1); + } + } + }; + thread.setDaemon(true); + thread.start(); + field_155771_h.info("Starting minecraft server version 1.7.2"); + + if (Runtime.getRuntime().maxMemory() / 1024L / 1024L < 512L) + { + field_155771_h.warn("To start the server with more ram, launch it as \"java -Xmx1024M -Xms1024M -jar minecraft_server.jar\""); + } + + FMLCommonHandler.instance().onServerStart(this); + + field_155771_h.info("Loading properties"); + this.settings = new PropertyManager(new File("server.properties")); + + if (this.isSinglePlayer()) + { + this.setHostname("127.0.0.1"); + } + else + { + this.setOnlineMode(this.settings.getBooleanProperty("online-mode", true)); + this.setHostname(this.settings.getStringProperty("server-ip", "")); + } + + this.setCanSpawnAnimals(this.settings.getBooleanProperty("spawn-animals", true)); + this.setCanSpawnNPCs(this.settings.getBooleanProperty("spawn-npcs", true)); + this.setAllowPvp(this.settings.getBooleanProperty("pvp", true)); + this.setAllowFlight(this.settings.getBooleanProperty("allow-flight", false)); + this.func_155759_m(this.settings.getStringProperty("resource-pack", "")); + this.setMOTD(this.settings.getStringProperty("motd", "A Minecraft Server")); + this.setForceGamemode(this.settings.getBooleanProperty("force-gamemode", false)); + this.func_143006_e(this.settings.getIntProperty("player-idle-timeout", 0)); + + if (this.settings.getIntProperty("difficulty", 1) < 0) + { + this.settings.setProperty("difficulty", Integer.valueOf(0)); + } + else if (this.settings.getIntProperty("difficulty", 1) > 3) + { + this.settings.setProperty("difficulty", Integer.valueOf(3)); + } + + this.canSpawnStructures = this.settings.getBooleanProperty("generate-structures", true); + int i = this.settings.getIntProperty("gamemode", WorldSettings.GameType.SURVIVAL.getID()); + this.gameType = WorldSettings.getGameTypeById(i); + field_155771_h.info("Default game type: " + this.gameType); + InetAddress inetaddress = null; + + if (this.getServerHostname().length() > 0) + { + inetaddress = InetAddress.getByName(this.getServerHostname()); + } + + if (this.getServerPort() < 0) + { + this.setServerPort(this.settings.getIntProperty("server-port", 25565)); + } + + field_155771_h.info("Generating keypair"); + this.setKeyPair(CryptManager.createNewKeyPair()); + field_155771_h.info("Starting Minecraft server on " + (this.getServerHostname().length() == 0 ? "*" : this.getServerHostname()) + ":" + this.getServerPort()); + + try + { + this.func_147137_ag().addLanEndpoint(inetaddress, this.getServerPort()); + } + catch (IOException ioexception) + { + field_155771_h.warn("**** FAILED TO BIND TO PORT!"); + field_155771_h.warn("The exception was: {}", new Object[] {ioexception.toString()}); + field_155771_h.warn("Perhaps a server is already running on that port?"); + return false; + } + + if (!this.isServerInOnlineMode()) + { + field_155771_h.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!"); + field_155771_h.warn("The server will make no attempt to authenticate usernames. Beware."); + field_155771_h.warn("While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose."); + field_155771_h.warn("To change this, set \"online-mode\" to \"true\" in the server.properties file."); + } + + FMLCommonHandler.instance().onServerStarted(); + + this.setConfigurationManager(new DedicatedPlayerList(this)); + long j = System.nanoTime(); + + if (this.getFolderName() == null) + { + this.setFolderName(this.settings.getStringProperty("level-name", "world")); + } + + String s = this.settings.getStringProperty("level-seed", ""); + String s1 = this.settings.getStringProperty("level-type", "DEFAULT"); + String s2 = this.settings.getStringProperty("generator-settings", ""); + long k = (new Random()).nextLong(); + + if (s.length() > 0) + { + try + { + long l = Long.parseLong(s); + + if (l != 0L) + { + k = l; + } + } + catch (NumberFormatException numberformatexception) + { + k = (long)s.hashCode(); + } + } + + WorldType worldtype = WorldType.parseWorldType(s1); + + if (worldtype == null) + { + worldtype = WorldType.DEFAULT; + } + + this.func_147136_ar(); + this.isCommandBlockEnabled(); + this.getOpPermissionLevel(); + this.isSnooperEnabled(); + this.setBuildLimit(this.settings.getIntProperty("max-build-height", 256)); + this.setBuildLimit((this.getBuildLimit() + 8) / 16 * 16); + this.setBuildLimit(MathHelper.clamp_int(this.getBuildLimit(), 64, 256)); + this.settings.setProperty("max-build-height", Integer.valueOf(this.getBuildLimit())); + if (!FMLCommonHandler.instance().handleServerAboutToStart(this)) { return false; } + field_155771_h.info("Preparing level \"" + this.getFolderName() + "\""); + this.loadAllWorlds(this.getFolderName(), this.getFolderName(), k, worldtype, s2); + long i1 = System.nanoTime() - j; + String s3 = String.format("%.3fs", new Object[] {Double.valueOf((double)i1 / 1.0E9D)}); + field_155771_h.info("Done (" + s3 + ")! For help, type \"help\" or \"?\""); + + if (this.settings.getBooleanProperty("enable-query", false)) + { + field_155771_h.info("Starting GS4 status listener"); + this.theRConThreadQuery = new RConThreadQuery(this); + this.theRConThreadQuery.startThread(); + } + + if (this.settings.getBooleanProperty("enable-rcon", false)) + { + field_155771_h.info("Starting remote control listener"); + this.theRConThreadMain = new RConThreadMain(this); + this.theRConThreadMain.startThread(); + } + + allowPlayerLogins = true; + return FMLCommonHandler.instance().handleServerStarting(this); + } + + public boolean canStructuresSpawn() + { + return this.canSpawnStructures; + } + + public WorldSettings.GameType getGameType() + { + return this.gameType; + } + + public EnumDifficulty func_147135_j() + { + return EnumDifficulty.getDifficultyEnum(this.settings.getIntProperty("difficulty", 1)); + } + + public boolean isHardcore() + { + return this.settings.getBooleanProperty("hardcore", false); + } + + protected void finalTick(CrashReport par1CrashReport) + { + while (this.isServerRunning()) + { + this.executePendingCommands(); + + try + { + Thread.sleep(10L); + } + catch (InterruptedException interruptedexception) + { + ; + } + } + } + + public CrashReport addServerInfoToCrashReport(CrashReport par1CrashReport) + { + par1CrashReport = super.addServerInfoToCrashReport(par1CrashReport); + par1CrashReport.getCategory().addCrashSectionCallable("Is Modded", new Callable() + { + private static final String __OBFID = "CL_00001785"; + public String call() + { + String s = DedicatedServer.this.getServerModName(); + return !s.equals("vanilla") ? "Definitely; Server brand changed to \'" + s + "\'" : "Unknown (can\'t tell)"; + } + }); + par1CrashReport.getCategory().addCrashSectionCallable("Type", new Callable() + { + private static final String __OBFID = "CL_00001788"; + public String call() + { + return "Dedicated Server (map_server.txt)"; + } + }); + return par1CrashReport; + } + + protected void systemExitNow() + { + System.exit(0); + } + + public void updateTimeLightAndEntities() + { + super.updateTimeLightAndEntities(); + this.executePendingCommands(); + } + + public boolean getAllowNether() + { + return this.settings.getBooleanProperty("allow-nether", true); + } + + public boolean allowSpawnMonsters() + { + return this.settings.getBooleanProperty("spawn-monsters", true); + } + + public void addServerStatsToSnooper(PlayerUsageSnooper par1PlayerUsageSnooper) + { + par1PlayerUsageSnooper.addData("whitelist_enabled", Boolean.valueOf(this.getConfigurationManager().isWhiteListEnabled())); + par1PlayerUsageSnooper.addData("whitelist_count", Integer.valueOf(this.getConfigurationManager().getWhiteListedPlayers().size())); + super.addServerStatsToSnooper(par1PlayerUsageSnooper); + } + + public boolean isSnooperEnabled() + { + return this.settings.getBooleanProperty("snooper-enabled", true); + } + + public void addPendingCommand(String par1Str, ICommandSender par2ICommandSender) + { + this.pendingCommandList.add(new ServerCommand(par1Str, par2ICommandSender)); + } + + public void executePendingCommands() + { + while (!this.pendingCommandList.isEmpty()) + { + ServerCommand servercommand = (ServerCommand)this.pendingCommandList.remove(0); + this.getCommandManager().executeCommand(servercommand.sender, servercommand.command); + } + } + + public boolean isDedicatedServer() + { + return true; + } + + public DedicatedPlayerList getConfigurationManager() + { + return (DedicatedPlayerList)super.getConfigurationManager(); + } + + public int getIntProperty(String par1Str, int par2) + { + return this.settings.getIntProperty(par1Str, par2); + } + + public String getStringProperty(String par1Str, String par2Str) + { + return this.settings.getStringProperty(par1Str, par2Str); + } + + public boolean getBooleanProperty(String par1Str, boolean par2) + { + return this.settings.getBooleanProperty(par1Str, par2); + } + + public void setProperty(String par1Str, Object par2Obj) + { + this.settings.setProperty(par1Str, par2Obj); + } + + public void saveProperties() + { + this.settings.saveProperties(); + } + + public String getSettingsFilename() + { + File file1 = this.settings.getPropertiesFile(); + return file1 != null ? file1.getAbsolutePath() : "No settings file"; + } + + public void setGuiEnabled() + { + MinecraftServerGui.createServerGui(this); + this.guiIsEnabled = true; + } + + public boolean getGuiEnabled() + { + return this.guiIsEnabled; + } + + public String shareToLAN(WorldSettings.GameType par1EnumGameType, boolean par2) + { + return ""; + } + + public boolean isCommandBlockEnabled() + { + return this.settings.getBooleanProperty("enable-command-block", false); + } + + public int getSpawnProtectionSize() + { + return this.settings.getIntProperty("spawn-protection", super.getSpawnProtectionSize()); + } + + public boolean isBlockProtected(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer) + { + if (par1World.provider.dimensionId != 0) + { + return false; + } + else if (this.getConfigurationManager().getOps().isEmpty()) + { + return false; + } + else if (this.getConfigurationManager().isPlayerOpped(par5EntityPlayer.getCommandSenderName())) + { + return false; + } + else if (this.getSpawnProtectionSize() <= 0) + { + return false; + } + else + { + ChunkCoordinates chunkcoordinates = par1World.getSpawnPoint(); + int l = MathHelper.abs_int(par2 - chunkcoordinates.posX); + int i1 = MathHelper.abs_int(par4 - chunkcoordinates.posZ); + int j1 = Math.max(l, i1); + return j1 <= this.getSpawnProtectionSize(); + } + } + + public int getOpPermissionLevel() + { + return this.settings.getIntProperty("op-permission-level", 4); + } + + public void func_143006_e(int par1) + { + super.func_143006_e(par1); + this.settings.setProperty("player-idle-timeout", Integer.valueOf(par1)); + this.saveProperties(); + } + + public boolean func_147136_ar() + { + return this.settings.getBooleanProperty("announce-player-achievements", true); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/server/dedicated/PropertyManager.java b/src/main/java/net/minecraft/server/dedicated/PropertyManager.java new file mode 100644 index 0000000..2aa05ee --- /dev/null +++ b/src/main/java/net/minecraft/server/dedicated/PropertyManager.java @@ -0,0 +1,146 @@ +package net.minecraft.server.dedicated; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.Properties; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +@SideOnly(Side.SERVER) +public class PropertyManager +{ + private static final Logger field_164440_a = LogManager.getLogger(); + private final Properties serverProperties = new Properties(); + private final File serverPropertiesFile; + private static final String __OBFID = "CL_00001782"; + + public PropertyManager(File p_i45278_1_) + { + this.serverPropertiesFile = p_i45278_1_; + + if (p_i45278_1_.exists()) + { + FileInputStream fileinputstream = null; + + try + { + fileinputstream = new FileInputStream(p_i45278_1_); + this.serverProperties.load(fileinputstream); + } + catch (Exception exception) + { + field_164440_a.warn("Failed to load " + p_i45278_1_, exception); + this.generateNewProperties(); + } + finally + { + if (fileinputstream != null) + { + try + { + fileinputstream.close(); + } + catch (IOException ioexception) + { + ; + } + } + } + } + else + { + field_164440_a.warn(p_i45278_1_ + " does not exist"); + this.generateNewProperties(); + } + } + + public void generateNewProperties() + { + field_164440_a.info("Generating new properties file"); + this.saveProperties(); + } + + public void saveProperties() + { + FileOutputStream fileoutputstream = null; + + try + { + fileoutputstream = new FileOutputStream(this.serverPropertiesFile); + this.serverProperties.store(fileoutputstream, "Minecraft server properties"); + } + catch (Exception exception) + { + field_164440_a.warn("Failed to save " + this.serverPropertiesFile, exception); + this.generateNewProperties(); + } + finally + { + if (fileoutputstream != null) + { + try + { + fileoutputstream.close(); + } + catch (IOException ioexception) + { + ; + } + } + } + } + + public File getPropertiesFile() + { + return this.serverPropertiesFile; + } + + public String getStringProperty(String par1Str, String par2Str) + { + if (!this.serverProperties.containsKey(par1Str)) + { + this.serverProperties.setProperty(par1Str, par2Str); + this.saveProperties(); + this.saveProperties(); + } + + return this.serverProperties.getProperty(par1Str, par2Str); + } + + public int getIntProperty(String par1Str, int par2) + { + try + { + return Integer.parseInt(this.getStringProperty(par1Str, "" + par2)); + } + catch (Exception exception) + { + this.serverProperties.setProperty(par1Str, "" + par2); + this.saveProperties(); + return par2; + } + } + + public boolean getBooleanProperty(String par1Str, boolean par2) + { + try + { + return Boolean.parseBoolean(this.getStringProperty(par1Str, "" + par2)); + } + catch (Exception exception) + { + this.serverProperties.setProperty(par1Str, "" + par2); + this.saveProperties(); + return par2; + } + } + + public void setProperty(String par1Str, Object par2Obj) + { + this.serverProperties.setProperty(par1Str, "" + par2Obj); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/server/gui/IUpdatePlayerListBox.java b/src/main/java/net/minecraft/server/gui/IUpdatePlayerListBox.java new file mode 100644 index 0000000..9aff1b2 --- /dev/null +++ b/src/main/java/net/minecraft/server/gui/IUpdatePlayerListBox.java @@ -0,0 +1,6 @@ +package net.minecraft.server.gui; + +public interface IUpdatePlayerListBox +{ + void update(); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/server/gui/MinecraftServerGui.java b/src/main/java/net/minecraft/server/gui/MinecraftServerGui.java new file mode 100644 index 0000000..6dc36a7 --- /dev/null +++ b/src/main/java/net/minecraft/server/gui/MinecraftServerGui.java @@ -0,0 +1,215 @@ +package net.minecraft.server.gui; + +import com.mojang.util.QueueLogAppender; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.util.concurrent.CountDownLatch; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JScrollBar; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.border.EtchedBorder; +import javax.swing.border.TitledBorder; +import javax.swing.text.AttributeSet; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.dedicated.DedicatedServer; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +@SideOnly(Side.SERVER) +public class MinecraftServerGui extends JComponent +{ + private static final Font field_164249_a = new Font("Monospaced", 0, 12); + private static final Logger field_164248_b = LogManager.getLogger(); + private DedicatedServer field_120021_b; + private static final String __OBFID = "CL_00001789"; + + public static void createServerGui(final DedicatedServer par0DedicatedServer) + { + try + { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } + catch (Exception exception) + { + ; + } + + MinecraftServerGui minecraftservergui = new MinecraftServerGui(par0DedicatedServer); + JFrame jframe = new JFrame("Minecraft server"); + jframe.add(minecraftservergui); + jframe.pack(); + jframe.setLocationRelativeTo((Component)null); + jframe.setVisible(true); + jframe.addWindowListener(new WindowAdapter() + { + private static final String __OBFID = "CL_00001791"; + public void windowClosing(WindowEvent windowevent) + { + par0DedicatedServer.initiateShutdown(); + + while (!par0DedicatedServer.isServerStopped()) + { + try + { + Thread.sleep(100L); + } + catch (InterruptedException interruptedexception) + { + interruptedexception.printStackTrace(); + } + } + + System.exit(0); + } + }); + minecraftservergui.latch.countDown(); + } + + public MinecraftServerGui(DedicatedServer par1DedicatedServer) + { + this.field_120021_b = par1DedicatedServer; + this.setPreferredSize(new Dimension(854, 480)); + this.setLayout(new BorderLayout()); + + try + { + this.add(this.getLogComponent(), "Center"); + this.add(this.getStatsComponent(), "West"); + } + catch (Exception exception) + { + field_164248_b.error("Couldn\'t build server GUI", exception); + } + } + + private JComponent getStatsComponent() + { + JPanel jpanel = new JPanel(new BorderLayout()); + jpanel.add(new StatsComponent(this.field_120021_b), "North"); + jpanel.add(this.getPlayerListComponent(), "Center"); + jpanel.setBorder(new TitledBorder(new EtchedBorder(), "Stats")); + return jpanel; + } + + private JComponent getPlayerListComponent() + { + PlayerListComponent playerlistcomponent = new PlayerListComponent(this.field_120021_b); + JScrollPane jscrollpane = new JScrollPane(playerlistcomponent, 22, 30); + jscrollpane.setBorder(new TitledBorder(new EtchedBorder(), "Players")); + return jscrollpane; + } + + private JComponent getLogComponent() + { + JPanel jpanel = new JPanel(new BorderLayout()); + final JTextArea jtextarea = new JTextArea(); + final JScrollPane jscrollpane = new JScrollPane(jtextarea, 22, 30); + jtextarea.setEditable(false); + jtextarea.setFont(field_164249_a); + final JTextField jtextfield = new JTextField(); + jtextfield.addActionListener(new ActionListener() + { + private static final String __OBFID = "CL_00001790"; + public void actionPerformed(ActionEvent actionevent) + { + String s = jtextfield.getText().trim(); + + if (s.length() > 0) + { + MinecraftServerGui.this.field_120021_b.addPendingCommand(s, MinecraftServer.getServer()); + } + + jtextfield.setText(""); + } + }); + jtextarea.addFocusListener(new FocusAdapter() + { + private static final String __OBFID = "CL_00001794"; + public void focusGained(FocusEvent focusevent) {} + }); + jpanel.add(jscrollpane, "Center"); + jpanel.add(jtextfield, "South"); + jpanel.setBorder(new TitledBorder(new EtchedBorder(), "Log and chat")); + Thread thread = new Thread(new Runnable() + { + private static final String __OBFID = "CL_00001793"; + public void run() + { + String s; + + while ((s = QueueLogAppender.getNextLogEvent("ServerGuiConsole")) != null) + { + MinecraftServerGui.this.func_164247_a(jtextarea, jscrollpane, s); + } + } + }); + thread.setDaemon(true); + thread.start(); + return jpanel; + } + + private CountDownLatch latch = new CountDownLatch(1); + public void func_164247_a(final JTextArea p_164247_1_, final JScrollPane p_164247_2_, final String p_164247_3_) + { + try + { + latch.await(); + } catch (InterruptedException e) + { + } + if (!SwingUtilities.isEventDispatchThread()) + { + SwingUtilities.invokeLater(new Runnable() + { + private static final String __OBFID = "CL_00001792"; + public void run() + { + MinecraftServerGui.this.func_164247_a(p_164247_1_, p_164247_2_, p_164247_3_); + } + }); + } + else + { + Document document = p_164247_1_.getDocument(); + JScrollBar jscrollbar = p_164247_2_.getVerticalScrollBar(); + boolean flag = false; + + if (p_164247_2_.getViewport().getView() == p_164247_1_) + { + flag = (double)jscrollbar.getValue() + jscrollbar.getSize().getHeight() + (double)(field_164249_a.getSize() * 4) > (double)jscrollbar.getMaximum(); + } + + try + { + document.insertString(document.getLength(), p_164247_3_, (AttributeSet)null); + } + catch (BadLocationException badlocationexception) + { + ; + } + + if (flag) + { + jscrollbar.setValue(Integer.MAX_VALUE); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/server/gui/PlayerListComponent.java b/src/main/java/net/minecraft/server/gui/PlayerListComponent.java new file mode 100644 index 0000000..7ca981f --- /dev/null +++ b/src/main/java/net/minecraft/server/gui/PlayerListComponent.java @@ -0,0 +1,37 @@ +package net.minecraft.server.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Vector; +import javax.swing.JList; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.server.MinecraftServer; + +@SideOnly(Side.SERVER) +public class PlayerListComponent extends JList implements IUpdatePlayerListBox +{ + private MinecraftServer field_120015_a; + private int field_120014_b; + private static final String __OBFID = "CL_00001795"; + + public PlayerListComponent(MinecraftServer par1MinecraftServer) + { + this.field_120015_a = par1MinecraftServer; + par1MinecraftServer.func_82010_a(this); + } + + public void update() + { + if (this.field_120014_b++ % 20 == 0) + { + Vector vector = new Vector(); + + for (int i = 0; i < this.field_120015_a.getConfigurationManager().playerEntityList.size(); ++i) + { + vector.add(((EntityPlayerMP)this.field_120015_a.getConfigurationManager().playerEntityList.get(i)).getCommandSenderName()); + } + + this.setListData(vector); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/server/gui/StatsComponent.java b/src/main/java/net/minecraft/server/gui/StatsComponent.java new file mode 100644 index 0000000..79321ae --- /dev/null +++ b/src/main/java/net/minecraft/server/gui/StatsComponent.java @@ -0,0 +1,88 @@ +package net.minecraft.server.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.text.DecimalFormat; +import javax.swing.JComponent; +import javax.swing.Timer; +import net.minecraft.server.MinecraftServer; + +@SideOnly(Side.SERVER) +public class StatsComponent extends JComponent +{ + private static final DecimalFormat field_120040_a = new DecimalFormat("########0.000"); + private int[] field_120038_b = new int[256]; + private int field_120039_c; + private String[] field_120036_d = new String[11]; + private final MinecraftServer field_120037_e; + private static final String __OBFID = "CL_00001796"; + + public StatsComponent(MinecraftServer par1MinecraftServer) + { + this.field_120037_e = par1MinecraftServer; + this.setPreferredSize(new Dimension(456, 246)); + this.setMinimumSize(new Dimension(456, 246)); + this.setMaximumSize(new Dimension(456, 246)); + (new Timer(500, new ActionListener() + { + private static final String __OBFID = "CL_00001797"; + public void actionPerformed(ActionEvent par1ActionEvent) + { + StatsComponent.this.func_120034_a(); + } + })).start(); + this.setBackground(Color.BLACK); + } + + private void func_120034_a() + { + long i = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); + System.gc(); + this.field_120036_d[0] = "Memory use: " + i / 1024L / 1024L + " mb (" + Runtime.getRuntime().freeMemory() * 100L / Runtime.getRuntime().maxMemory() + "% free)"; + this.field_120036_d[1] = "Avg tick: " + field_120040_a.format(this.func_120035_a(this.field_120037_e.tickTimeArray) * 1.0E-6D) + " ms"; + this.repaint(); + } + + private double func_120035_a(long[] par1ArrayOfLong) + { + long i = 0L; + + for (int j = 0; j < par1ArrayOfLong.length; ++j) + { + i += par1ArrayOfLong[j]; + } + + return (double)i / (double)par1ArrayOfLong.length; + } + + public void paint(Graphics par1Graphics) + { + par1Graphics.setColor(new Color(16777215)); + par1Graphics.fillRect(0, 0, 456, 246); + int i; + + for (i = 0; i < 256; ++i) + { + int j = this.field_120038_b[i + this.field_120039_c & 255]; + par1Graphics.setColor(new Color(j + 28 << 16)); + par1Graphics.fillRect(i, 100 - j, 1, j); + } + + par1Graphics.setColor(Color.BLACK); + + for (i = 0; i < this.field_120036_d.length; ++i) + { + String s = this.field_120036_d[i]; + + if (s != null) + { + par1Graphics.drawString(s, 32, 116 + i * 16); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/server/integrated/IntegratedPlayerList.java b/src/main/java/net/minecraft/server/integrated/IntegratedPlayerList.java new file mode 100644 index 0000000..d1a7f1b --- /dev/null +++ b/src/main/java/net/minecraft/server/integrated/IntegratedPlayerList.java @@ -0,0 +1,49 @@ +package net.minecraft.server.integrated; + +import com.mojang.authlib.GameProfile; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.net.SocketAddress; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.management.ServerConfigurationManager; + +@SideOnly(Side.CLIENT) +public class IntegratedPlayerList extends ServerConfigurationManager +{ + private NBTTagCompound hostPlayerData; + private static final String __OBFID = "CL_00001128"; + + public IntegratedPlayerList(IntegratedServer par1IntegratedServer) + { + super(par1IntegratedServer); + this.viewDistance = 10; + } + + protected void writePlayerData(EntityPlayerMP par1EntityPlayerMP) + { + if (par1EntityPlayerMP.getCommandSenderName().equals(this.getServerInstance().getServerOwner())) + { + this.hostPlayerData = new NBTTagCompound(); + par1EntityPlayerMP.writeToNBT(this.hostPlayerData); + } + + super.writePlayerData(par1EntityPlayerMP); + } + + public String allowUserToConnect(SocketAddress p_148542_1_, GameProfile p_148542_2_) + { + return p_148542_2_.getName().equalsIgnoreCase(this.getServerInstance().getServerOwner()) && this.getPlayerForUsername(p_148542_2_.getName()) != null ? "That name is already taken." : super.allowUserToConnect(p_148542_1_, p_148542_2_); + } + + public IntegratedServer getServerInstance() + { + return (IntegratedServer)super.getServerInstance(); + } + + public NBTTagCompound getHostPlayerData() + { + return this.hostPlayerData; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/server/integrated/IntegratedServer.java b/src/main/java/net/minecraft/server/integrated/IntegratedServer.java new file mode 100644 index 0000000..000207c --- /dev/null +++ b/src/main/java/net/minecraft/server/integrated/IntegratedServer.java @@ -0,0 +1,269 @@ +package net.minecraft.server.integrated; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.File; +import java.io.IOException; +import java.net.InetAddress; +import java.util.concurrent.Callable; +import net.minecraft.client.ClientBrandRetriever; +import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.ThreadLanServerPing; +import net.minecraft.crash.CrashReport; +import net.minecraft.profiler.PlayerUsageSnooper; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.CryptManager; +import net.minecraft.util.HttpUtil; +import net.minecraft.world.EnumDifficulty; +import net.minecraft.world.WorldManager; +import net.minecraft.world.WorldServer; +import net.minecraft.world.WorldServerMulti; +import net.minecraft.world.WorldSettings; +import net.minecraft.world.WorldType; +import net.minecraft.world.demo.DemoWorldServer; +import net.minecraft.world.storage.ISaveHandler; +import net.minecraftforge.common.DimensionManager; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.world.WorldEvent; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +@SideOnly(Side.CLIENT) +public class IntegratedServer extends MinecraftServer +{ + private static final Logger logger = LogManager.getLogger(); + private final Minecraft mc; + private final WorldSettings theWorldSettings; + private boolean isGamePaused; + private boolean isPublic; + private ThreadLanServerPing lanServerPing; + private static final String __OBFID = "CL_00001129"; + + public IntegratedServer(Minecraft par1Minecraft, String par2Str, String par3Str, WorldSettings par4WorldSettings) + { + super(new File(par1Minecraft.mcDataDir, "saves"), par1Minecraft.getProxy()); + this.setServerOwner(par1Minecraft.getSession().getUsername()); + this.setFolderName(par2Str); + this.setWorldName(par3Str); + this.setDemo(par1Minecraft.isDemo()); + this.canCreateBonusChest(par4WorldSettings.isBonusChestEnabled()); + this.setBuildLimit(256); + this.setConfigurationManager(new IntegratedPlayerList(this)); + this.mc = par1Minecraft; + this.theWorldSettings = par4WorldSettings; + } + + protected void loadAllWorlds(String par1Str, String par2Str, long par3, WorldType par5WorldType, String par6Str) + { + this.convertMapIfNeeded(par1Str); + ISaveHandler isavehandler = this.getActiveAnvilConverter().getSaveLoader(par1Str, true); + + WorldServer overWorld = (isDemo() ? new DemoWorldServer(this, isavehandler, par2Str, 0, theProfiler) : new WorldServer(this, isavehandler, par2Str, 0, theWorldSettings, theProfiler)); + for (int dim : DimensionManager.getStaticDimensionIDs()) + { + WorldServer world = (dim == 0 ? overWorld : new WorldServerMulti(this, isavehandler, par2Str, dim, theWorldSettings, overWorld, theProfiler)); + world.addWorldAccess(new WorldManager(this, world)); + + if (!this.isSinglePlayer()) + { + world.getWorldInfo().setGameType(getGameType()); + } + + MinecraftForge.EVENT_BUS.post(new WorldEvent.Load(world)); + } + + this.getConfigurationManager().setPlayerManager(new WorldServer[]{ overWorld }); + this.func_147139_a(this.func_147135_j()); + this.initialWorldChunkLoad(); + } + + protected boolean startServer() throws IOException + { + logger.info("Starting integrated minecraft server version 1.7.2"); + this.setOnlineMode(false); + this.setCanSpawnAnimals(true); + this.setCanSpawnNPCs(true); + this.setAllowPvp(true); + this.setAllowFlight(true); + logger.info("Generating keypair"); + this.setKeyPair(CryptManager.createNewKeyPair()); + if (!FMLCommonHandler.instance().handleServerAboutToStart(this)) { return false; } + this.loadAllWorlds(this.getFolderName(), this.getWorldName(), this.theWorldSettings.getSeed(), this.theWorldSettings.getTerrainType(), this.theWorldSettings.func_82749_j()); + this.setMOTD(this.getServerOwner() + " - " + this.worldServers[0].getWorldInfo().getWorldName()); + return FMLCommonHandler.instance().handleServerStarting(this); + } + + public void tick() + { + boolean flag = this.isGamePaused; + this.isGamePaused = Minecraft.getMinecraft().getNetHandler() != null && Minecraft.getMinecraft().isGamePaused(); + + if (!flag && this.isGamePaused) + { + logger.info("Saving and pausing game..."); + this.getConfigurationManager().saveAllPlayerData(); + this.saveAllWorlds(false); + } + + if (!this.isGamePaused) + { + super.tick(); + } + } + + public boolean canStructuresSpawn() + { + return false; + } + + public WorldSettings.GameType getGameType() + { + return this.theWorldSettings.getGameType(); + } + + public EnumDifficulty func_147135_j() + { + return this.mc.gameSettings.difficulty; + } + + public boolean isHardcore() + { + return this.theWorldSettings.getHardcoreEnabled(); + } + + protected File getDataDirectory() + { + return this.mc.mcDataDir; + } + + public boolean isDedicatedServer() + { + return false; + } + + protected void finalTick(CrashReport par1CrashReport) + { + this.mc.crashed(par1CrashReport); + } + + public CrashReport addServerInfoToCrashReport(CrashReport par1CrashReport) + { + par1CrashReport = super.addServerInfoToCrashReport(par1CrashReport); + par1CrashReport.getCategory().addCrashSectionCallable("Type", new Callable() + { + private static final String __OBFID = "CL_00001130"; + public String call() + { + return "Integrated Server (map_client.txt)"; + } + }); + par1CrashReport.getCategory().addCrashSectionCallable("Is Modded", new Callable() + { + private static final String __OBFID = "CL_00001131"; + public String call() + { + String s = ClientBrandRetriever.getClientModName(); + + if (!s.equals("vanilla")) + { + return "Definitely; Client brand changed to \'" + s + "\'"; + } + else + { + s = IntegratedServer.this.getServerModName(); + return !s.equals("vanilla") ? "Definitely; Server brand changed to \'" + s + "\'" : (Minecraft.class.getSigners() == null ? "Very likely; Jar signature invalidated" : "Probably not. Jar signature remains and both client + server brands are untouched."); + } + } + }); + return par1CrashReport; + } + + public void addServerStatsToSnooper(PlayerUsageSnooper par1PlayerUsageSnooper) + { + super.addServerStatsToSnooper(par1PlayerUsageSnooper); + par1PlayerUsageSnooper.addData("snooper_partner", this.mc.getPlayerUsageSnooper().getUniqueID()); + } + + public boolean isSnooperEnabled() + { + return Minecraft.getMinecraft().isSnooperEnabled(); + } + + public String shareToLAN(WorldSettings.GameType par1EnumGameType, boolean par2) + { + try + { + int i = -1; + + try + { + i = HttpUtil.func_76181_a(); + } + catch (IOException ioexception) + { + ; + } + + if (i <= 0) + { + i = 25564; + } + + this.func_147137_ag().addLanEndpoint((InetAddress)null, i); + logger.info("Started on " + i); + this.isPublic = true; + this.lanServerPing = new ThreadLanServerPing(this.getMOTD(), i + ""); + this.lanServerPing.start(); + this.getConfigurationManager().setGameType(par1EnumGameType); + this.getConfigurationManager().setCommandsAllowedForAll(par2); + return i + ""; + } + catch (IOException ioexception1) + { + return null; + } + } + + public void stopServer() + { + super.stopServer(); + + if (this.lanServerPing != null) + { + this.lanServerPing.interrupt(); + this.lanServerPing = null; + } + } + + public void initiateShutdown() + { + super.initiateShutdown(); + + if (this.lanServerPing != null) + { + this.lanServerPing.interrupt(); + this.lanServerPing = null; + } + } + + public boolean getPublic() + { + return this.isPublic; + } + + public void setGameType(WorldSettings.GameType par1EnumGameType) + { + this.getConfigurationManager().setGameType(par1EnumGameType); + } + + public boolean isCommandBlockEnabled() + { + return true; + } + + public int getOpPermissionLevel() + { + return 4; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/server/management/BanEntry.java b/src/main/java/net/minecraft/server/management/BanEntry.java new file mode 100644 index 0000000..0a00547 --- /dev/null +++ b/src/main/java/net/minecraft/server/management/BanEntry.java @@ -0,0 +1,175 @@ +package net.minecraft.server.management; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.regex.Pattern; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class BanEntry +{ + private static final Logger logger = LogManager.getLogger(); + public static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z"); + private final String username; + private Date banStartDate = new Date(); + private String bannedBy = "(Unknown)"; + private Date banEndDate; + private String reason = "Banned by an operator."; + private static final String __OBFID = "CL_00001395"; + + public BanEntry(String par1Str) + { + this.username = par1Str; + } + + public String getBannedUsername() + { + return this.username; + } + + public Date getBanStartDate() + { + return this.banStartDate; + } + + public String getBannedBy() + { + return this.bannedBy; + } + + public void setBannedBy(String par1Str) + { + this.bannedBy = par1Str; + } + + @SideOnly(Side.SERVER) + public void setBanStartDate(Date par1Date) + { + this.banStartDate = par1Date != null ? par1Date : new Date(); + } + + public Date getBanEndDate() + { + return this.banEndDate; + } + + public boolean hasBanExpired() + { + return this.banEndDate == null ? false : this.banEndDate.before(new Date()); + } + + public String getBanReason() + { + return this.reason; + } + + public void setBanReason(String par1Str) + { + this.reason = par1Str; + } + + public String buildBanString() + { + StringBuilder stringbuilder = new StringBuilder(); + stringbuilder.append(this.getBannedUsername()); + stringbuilder.append("|"); + stringbuilder.append(dateFormat.format(this.getBanStartDate())); + stringbuilder.append("|"); + stringbuilder.append(this.getBannedBy()); + stringbuilder.append("|"); + stringbuilder.append(this.getBanEndDate() == null ? "Forever" : dateFormat.format(this.getBanEndDate())); + stringbuilder.append("|"); + stringbuilder.append(this.getBanReason()); + return stringbuilder.toString(); + } + + @SideOnly(Side.SERVER) + public void setBanEndDate(Date par1Date) + { + this.banEndDate = par1Date; + } + + @SideOnly(Side.SERVER) + public static BanEntry parse(String par0Str) + { + if (par0Str.trim().length() < 2) + { + return null; + } + else + { + String[] astring = par0Str.trim().split(Pattern.quote("|"), 5); + BanEntry banentry = new BanEntry(astring[0].trim()); + byte b0 = 0; + int j = astring.length; + int i = b0 + 1; + + if (j <= i) + { + return banentry; + } + else + { + try + { + banentry.setBanStartDate(dateFormat.parse(astring[i].trim())); + } + catch (ParseException parseexception1) + { + logger.warn("Could not read creation date format for ban entry \'" + banentry.getBannedUsername() + "\' (was: \'" + astring[i] + "\')", parseexception1); + } + + j = astring.length; + ++i; + + if (j <= i) + { + return banentry; + } + else + { + banentry.setBannedBy(astring[i].trim()); + j = astring.length; + ++i; + + if (j <= i) + { + return banentry; + } + else + { + try + { + String s1 = astring[i].trim(); + + if (!s1.equalsIgnoreCase("Forever") && s1.length() > 0) + { + banentry.setBanEndDate(dateFormat.parse(s1)); + } + } + catch (ParseException parseexception) + { + logger.warn("Could not read expiry date format for ban entry \'" + banentry.getBannedUsername() + "\' (was: \'" + astring[i] + "\')", parseexception); + } + + j = astring.length; + ++i; + + if (j <= i) + { + return banentry; + } + else + { + banentry.setBanReason(astring[i].trim()); + return banentry; + } + } + } + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/server/management/BanList.java b/src/main/java/net/minecraft/server/management/BanList.java new file mode 100644 index 0000000..07d9f20 --- /dev/null +++ b/src/main/java/net/minecraft/server/management/BanList.java @@ -0,0 +1,163 @@ +package net.minecraft.server.management; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Iterator; +import java.util.Map; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class BanList +{ + private static final Logger logger = LogManager.getLogger(); + private final LowerStringMap theBanList = new LowerStringMap(); + private final File fileName; + private boolean listActive = true; + private static final String __OBFID = "CL_00001396"; + + public BanList(File par1File) + { + this.fileName = par1File; + } + + public boolean isListActive() + { + return this.listActive; + } + + public void setListActive(boolean par1) + { + this.listActive = par1; + } + + public Map getBannedList() + { + this.removeExpiredBans(); + return this.theBanList; + } + + public boolean isBanned(String par1Str) + { + if (!this.isListActive()) + { + return false; + } + else + { + this.removeExpiredBans(); + return this.theBanList.containsKey(par1Str); + } + } + + public void put(BanEntry par1BanEntry) + { + this.theBanList.put(par1BanEntry.getBannedUsername(), par1BanEntry); + this.saveToFileWithHeader(); + } + + public void remove(String par1Str) + { + this.theBanList.remove(par1Str); + this.saveToFileWithHeader(); + } + + public void removeExpiredBans() + { + Iterator iterator = this.theBanList.values().iterator(); + + while (iterator.hasNext()) + { + BanEntry banentry = (BanEntry)iterator.next(); + + if (banentry.hasBanExpired()) + { + iterator.remove(); + } + } + } + + public void saveToFileWithHeader() + { + this.saveToFile(true); + } + + public void saveToFile(boolean par1) + { + this.removeExpiredBans(); + + try + { + PrintWriter printwriter = new PrintWriter(new FileWriter(this.fileName, false)); + + if (par1) + { + printwriter.println("# Updated " + (new SimpleDateFormat()).format(new Date()) + " by Minecraft " + "1.7.2"); + printwriter.println("# victim name | ban date | banned by | banned until | reason"); + printwriter.println(); + } + + Iterator iterator = this.theBanList.values().iterator(); + + while (iterator.hasNext()) + { + BanEntry banentry = (BanEntry)iterator.next(); + printwriter.println(banentry.buildBanString()); + } + + printwriter.close(); + } + catch (IOException ioexception) + { + logger.error("Could not save ban list", ioexception); + } + } + + @SideOnly(Side.SERVER) + public void loadBanList() + { + if (this.fileName.isFile()) + { + BufferedReader bufferedreader; + + try + { + bufferedreader = new BufferedReader(new FileReader(this.fileName)); + } + catch (FileNotFoundException filenotfoundexception) + { + throw new Error(); + } + + String s; + + try + { + while ((s = bufferedreader.readLine()) != null) + { + if (!s.startsWith("#")) + { + BanEntry banentry = BanEntry.parse(s); + + if (banentry != null) + { + this.theBanList.put(banentry.getBannedUsername(), banentry); + } + } + } + } + catch (IOException ioexception) + { + logger.error("Could not load ban list", ioexception); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/server/management/ItemInWorldManager.java b/src/main/java/net/minecraft/server/management/ItemInWorldManager.java new file mode 100644 index 0000000..9aba6bb --- /dev/null +++ b/src/main/java/net/minecraft/server/management/ItemInWorldManager.java @@ -0,0 +1,415 @@ +package net.minecraft.server.management; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemSword; +import net.minecraft.network.play.server.S23PacketBlockChange; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraft.world.WorldServer; +import net.minecraft.world.WorldSettings; +import net.minecraftforge.common.ForgeHooks; +import net.minecraftforge.common.MinecraftForge; +import cpw.mods.fml.common.eventhandler.Event; +import net.minecraftforge.event.ForgeEventFactory; +import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; +import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action; +import net.minecraftforge.event.world.BlockEvent; + +public class ItemInWorldManager +{ + /** Forge reach distance */ + private double blockReachDistance = 5.0d; + public World theWorld; + public EntityPlayerMP thisPlayerMP; + private WorldSettings.GameType gameType; + private boolean isDestroyingBlock; + private int initialDamage; + private int partiallyDestroyedBlockX; + private int partiallyDestroyedBlockY; + private int partiallyDestroyedBlockZ; + private int curblockDamage; + private boolean receivedFinishDiggingPacket; + private int posX; + private int posY; + private int posZ; + private int initialBlockDamage; + private int durabilityRemainingOnBlock; + private static final String __OBFID = "CL_00001442"; + + public ItemInWorldManager(World par1World) + { + this.gameType = WorldSettings.GameType.NOT_SET; + this.durabilityRemainingOnBlock = -1; + this.theWorld = par1World; + } + + public void setGameType(WorldSettings.GameType par1EnumGameType) + { + this.gameType = par1EnumGameType; + par1EnumGameType.configurePlayerCapabilities(this.thisPlayerMP.capabilities); + this.thisPlayerMP.sendPlayerAbilities(); + } + + public WorldSettings.GameType getGameType() + { + return this.gameType; + } + + public boolean isCreative() + { + return this.gameType.isCreative(); + } + + public void initializeGameType(WorldSettings.GameType par1EnumGameType) + { + if (this.gameType == WorldSettings.GameType.NOT_SET) + { + this.gameType = par1EnumGameType; + } + + this.setGameType(this.gameType); + } + + public void updateBlockRemoving() + { + ++this.curblockDamage; + float f; + int j; + + if (this.receivedFinishDiggingPacket) + { + int i = this.curblockDamage - this.initialBlockDamage; + Block block = this.theWorld.getBlock(this.posX, this.posY, this.posZ); + + if (block.getMaterial() == Material.air) + { + this.receivedFinishDiggingPacket = false; + } + else + { + f = block.getPlayerRelativeBlockHardness(this.thisPlayerMP, this.thisPlayerMP.worldObj, this.posX, this.posY, this.posZ) * (float)(i + 1); + j = (int)(f * 10.0F); + + if (j != this.durabilityRemainingOnBlock) + { + this.theWorld.destroyBlockInWorldPartially(this.thisPlayerMP.getEntityId(), this.posX, this.posY, this.posZ, j); + this.durabilityRemainingOnBlock = j; + } + + if (f >= 1.0F) + { + this.receivedFinishDiggingPacket = false; + this.tryHarvestBlock(this.posX, this.posY, this.posZ); + } + } + } + else if (this.isDestroyingBlock) + { + Block block1 = this.theWorld.getBlock(this.partiallyDestroyedBlockX, this.partiallyDestroyedBlockY, this.partiallyDestroyedBlockZ); + + if (block1.getMaterial() == Material.air) + { + this.theWorld.destroyBlockInWorldPartially(this.thisPlayerMP.getEntityId(), this.partiallyDestroyedBlockX, this.partiallyDestroyedBlockY, this.partiallyDestroyedBlockZ, -1); + this.durabilityRemainingOnBlock = -1; + this.isDestroyingBlock = false; + } + else + { + int k = this.curblockDamage - this.initialDamage; + f = block1.getPlayerRelativeBlockHardness(this.thisPlayerMP, this.thisPlayerMP.worldObj, this.partiallyDestroyedBlockX, this.partiallyDestroyedBlockY, this.partiallyDestroyedBlockZ) * (float)(k + 1); + j = (int)(f * 10.0F); + + if (j != this.durabilityRemainingOnBlock) + { + this.theWorld.destroyBlockInWorldPartially(this.thisPlayerMP.getEntityId(), this.partiallyDestroyedBlockX, this.partiallyDestroyedBlockY, this.partiallyDestroyedBlockZ, j); + this.durabilityRemainingOnBlock = j; + } + } + } + } + + public void onBlockClicked(int par1, int par2, int par3, int par4) + { + if (!this.gameType.isAdventure() || this.thisPlayerMP.isCurrentToolAdventureModeExempt(par1, par2, par3)) + { + PlayerInteractEvent event = ForgeEventFactory.onPlayerInteract(thisPlayerMP, Action.LEFT_CLICK_BLOCK, par1, par2, par3, par4); + if (event.isCanceled()) + { + thisPlayerMP.playerNetServerHandler.sendPacket(new S23PacketBlockChange(par1, par2, par3, theWorld)); + return; + } + + if (this.isCreative()) + { + if (!this.theWorld.extinguishFire((EntityPlayer)null, par1, par2, par3, par4)) + { + this.tryHarvestBlock(par1, par2, par3); + } + } + else + { + this.initialDamage = this.curblockDamage; + float f = 1.0F; + Block block = this.theWorld.getBlock(par1, par2, par3); + + + if (!block.isAir(theWorld, par1, par2, par3)) + { + if (event.useBlock != Event.Result.DENY) + { + block.onBlockClicked(theWorld, par1, par2, par3, thisPlayerMP); + theWorld.extinguishFire(thisPlayerMP, par1, par2, par3, par4); + } + else + { + thisPlayerMP.playerNetServerHandler.sendPacket(new S23PacketBlockChange(par1, par2, par3, theWorld)); + } + f = block.getPlayerRelativeBlockHardness(thisPlayerMP, thisPlayerMP.worldObj, par1, par2, par3); + } + + if (event.useItem == Event.Result.DENY) + { + if (f >= 1.0f) + { + thisPlayerMP.playerNetServerHandler.sendPacket(new S23PacketBlockChange(par1, par2, par3, theWorld)); + } + return; + } + + if (!block.isAir(theWorld, par1, par2, par3) && f >= 1.0F) + { + this.tryHarvestBlock(par1, par2, par3); + } + else + { + this.isDestroyingBlock = true; + this.partiallyDestroyedBlockX = par1; + this.partiallyDestroyedBlockY = par2; + this.partiallyDestroyedBlockZ = par3; + int i1 = (int)(f * 10.0F); + this.theWorld.destroyBlockInWorldPartially(this.thisPlayerMP.getEntityId(), par1, par2, par3, i1); + this.durabilityRemainingOnBlock = i1; + } + } + } + } + + public void uncheckedTryHarvestBlock(int par1, int par2, int par3) + { + if (par1 == this.partiallyDestroyedBlockX && par2 == this.partiallyDestroyedBlockY && par3 == this.partiallyDestroyedBlockZ) + { + int l = this.curblockDamage - this.initialDamage; + Block block = this.theWorld.getBlock(par1, par2, par3); + + if (!block.isAir(theWorld, par1, par2, par3)) + { + float f = block.getPlayerRelativeBlockHardness(this.thisPlayerMP, this.thisPlayerMP.worldObj, par1, par2, par3) * (float)(l + 1); + + if (f >= 0.7F) + { + this.isDestroyingBlock = false; + this.theWorld.destroyBlockInWorldPartially(this.thisPlayerMP.getEntityId(), par1, par2, par3, -1); + this.tryHarvestBlock(par1, par2, par3); + } + else if (!this.receivedFinishDiggingPacket) + { + this.isDestroyingBlock = false; + this.receivedFinishDiggingPacket = true; + this.posX = par1; + this.posY = par2; + this.posZ = par3; + this.initialBlockDamage = this.initialDamage; + } + } + } + } + + public void cancelDestroyingBlock(int par1, int par2, int par3) + { + this.isDestroyingBlock = false; + this.theWorld.destroyBlockInWorldPartially(this.thisPlayerMP.getEntityId(), this.partiallyDestroyedBlockX, this.partiallyDestroyedBlockY, this.partiallyDestroyedBlockZ, -1); + } + + private boolean removeBlock(int par1, int par2, int par3) + { + Block block = this.theWorld.getBlock(par1, par2, par3); + int l = this.theWorld.getBlockMetadata(par1, par2, par3); + block.onBlockHarvested(this.theWorld, par1, par2, par3, l, this.thisPlayerMP); + boolean flag = block.removedByPlayer(theWorld, thisPlayerMP, par1, par2, par3); + + if (flag) + { + block.onBlockDestroyedByPlayer(this.theWorld, par1, par2, par3, l); + } + + return flag; + } + + public boolean tryHarvestBlock(int par1, int par2, int par3) + { + BlockEvent.BreakEvent event = ForgeHooks.onBlockBreakEvent(theWorld, gameType, thisPlayerMP, par1, par2, par3); + if (event.isCanceled()) + { + return false; + } + else + { + ItemStack stack = thisPlayerMP.getCurrentEquippedItem(); + if (stack != null && stack.getItem().onBlockStartBreak(stack, par1, par2, par3, thisPlayerMP)) + { + return false; + } + Block block = this.theWorld.getBlock(par1, par2, par3); + int l = this.theWorld.getBlockMetadata(par1, par2, par3); + this.theWorld.playAuxSFXAtEntity(this.thisPlayerMP, 2001, par1, par2, par3, Block.getIdFromBlock(block) + (this.theWorld.getBlockMetadata(par1, par2, par3) << 12)); + boolean flag = false; + + if (this.isCreative()) + { + flag = this.removeBlock(par1, par2, par3); + this.thisPlayerMP.playerNetServerHandler.sendPacket(new S23PacketBlockChange(par1, par2, par3, this.theWorld)); + } + else + { + ItemStack itemstack = this.thisPlayerMP.getCurrentEquippedItem(); + boolean flag1 = block.canHarvestBlock(thisPlayerMP, l); + + if (itemstack != null) + { + itemstack.func_150999_a(this.theWorld, block, par1, par2, par3, this.thisPlayerMP); + + if (itemstack.stackSize == 0) + { + this.thisPlayerMP.destroyCurrentEquippedItem(); + } + } + + flag = this.removeBlock(par1, par2, par3); + if (flag && flag1) + { + block.harvestBlock(this.theWorld, this.thisPlayerMP, par1, par2, par3, l); + } + } + + // Drop experience + if (!this.isCreative() && flag && event != null) + { + block.dropXpOnBlockBreak(this.theWorld, par1, par2, par3, event.getExpToDrop()); + } + return flag; + } + } + + public boolean tryUseItem(EntityPlayer par1EntityPlayer, World par2World, ItemStack par3ItemStack) + { + int i = par3ItemStack.stackSize; + int j = par3ItemStack.getItemDamage(); + ItemStack itemstack1 = par3ItemStack.useItemRightClick(par2World, par1EntityPlayer); + + if (itemstack1 == par3ItemStack && (itemstack1 == null || itemstack1.stackSize == i && itemstack1.getMaxItemUseDuration() <= 0 && itemstack1.getItemDamage() == j)) + { + return false; + } + else + { + par1EntityPlayer.inventory.mainInventory[par1EntityPlayer.inventory.currentItem] = itemstack1; + + if (this.isCreative()) + { + itemstack1.stackSize = i; + + if (itemstack1.isItemStackDamageable()) + { + itemstack1.setItemDamage(j); + } + } + + if (itemstack1.stackSize == 0) + { + par1EntityPlayer.inventory.mainInventory[par1EntityPlayer.inventory.currentItem] = null; + MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(thisPlayerMP, itemstack1)); + } + + if (!par1EntityPlayer.isUsingItem()) + { + ((EntityPlayerMP)par1EntityPlayer).sendContainerToPlayer(par1EntityPlayer.inventoryContainer); + } + + return true; + } + } + + public boolean activateBlockOrUseItem(EntityPlayer par1EntityPlayer, World par2World, ItemStack par3ItemStack, int par4, int par5, int par6, int par7, float par8, float par9, float par10) + { + PlayerInteractEvent event = ForgeEventFactory.onPlayerInteract(par1EntityPlayer, Action.RIGHT_CLICK_BLOCK, par4, par5, par6, par7); + if (event.isCanceled()) + { + thisPlayerMP.playerNetServerHandler.sendPacket(new S23PacketBlockChange(par4, par5, par6, theWorld)); + return false; + } + + if (par3ItemStack != null && par3ItemStack.getItem().onItemUseFirst(par3ItemStack, par1EntityPlayer, par2World, par4, par5, par6, par7, par8, par9, par10)) + { + if (par3ItemStack.stackSize <= 0) ForgeEventFactory.onPlayerDestroyItem(thisPlayerMP, par3ItemStack); + return true; + } + + Block block = par2World.getBlock(par4, par5, par6); + boolean isAir = block.isAir(par2World, par4, par5, par6); + boolean useBlock = !par1EntityPlayer.isSneaking() || par1EntityPlayer.getHeldItem() == null; + if (!useBlock) useBlock = par1EntityPlayer.getHeldItem().getItem().doesSneakBypassUse(par2World, par4, par5, par6, par1EntityPlayer); + boolean result = false; + + if (useBlock) + { + if (event.useBlock != Event.Result.DENY) + { + result = block.onBlockActivated(par2World, par4, par5, par6, par1EntityPlayer, par7, par8, par9, par10); + } + else + { + thisPlayerMP.playerNetServerHandler.sendPacket(new S23PacketBlockChange(par4, par5, par6, theWorld)); + result = event.useItem != Event.Result.ALLOW; + } + } + + if (par3ItemStack != null && !result && event.useItem != Event.Result.DENY) + { + int meta = par3ItemStack.getItemDamage(); + int size = par3ItemStack.stackSize; + result = par3ItemStack.tryPlaceItemIntoWorld(par1EntityPlayer, par2World, par4, par5, par6, par7, par8, par9, par10); + if (isCreative()) + { + par3ItemStack.setItemDamage(meta); + par3ItemStack.stackSize = size; + } + if (par3ItemStack.stackSize <= 0) ForgeEventFactory.onPlayerDestroyItem(thisPlayerMP, par3ItemStack); + } + + /* Re-enable if this causes bukkit incompatibility, or re-write client side to only send a single packet per right click. + if (par3ItemStack != null && ((!result && event.useItem != Event.Result.DENY) || event.useItem == Event.Result.ALLOW)) + { + this.tryUseItem(thisPlayerMP, par2World, par3ItemStack); + }*/ + return result; + } + + public void setWorld(WorldServer par1WorldServer) + { + this.theWorld = par1WorldServer; + } + + public double getBlockReachDistance() + { + return blockReachDistance; + } + public void setBlockReachDistance(double distance) + { + blockReachDistance = distance; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/server/management/LowerStringMap.java b/src/main/java/net/minecraft/server/management/LowerStringMap.java new file mode 100644 index 0000000..cfb0f1a --- /dev/null +++ b/src/main/java/net/minecraft/server/management/LowerStringMap.java @@ -0,0 +1,85 @@ +package net.minecraft.server.management; + +import java.util.Collection; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Set; +import java.util.Map.Entry; + +public class LowerStringMap implements Map +{ + private final Map internalMap = new LinkedHashMap(); + private static final String __OBFID = "CL_00001488"; + + public int size() + { + return this.internalMap.size(); + } + + public boolean isEmpty() + { + return this.internalMap.isEmpty(); + } + + public boolean containsKey(Object par1Obj) + { + return this.internalMap.containsKey(par1Obj.toString().toLowerCase()); + } + + public boolean containsValue(Object par1Obj) + { + return this.internalMap.containsKey(par1Obj); + } + + public Object get(Object par1Obj) + { + return this.internalMap.get(par1Obj.toString().toLowerCase()); + } + + public Object put(String par1Str, Object par2Obj) + { + return this.internalMap.put(par1Str.toLowerCase(), par2Obj); + } + + public Object remove(Object par1Obj) + { + return this.internalMap.remove(par1Obj.toString().toLowerCase()); + } + + public void putAll(Map par1Map) + { + Iterator iterator = par1Map.entrySet().iterator(); + + while (iterator.hasNext()) + { + Entry entry = (Entry)iterator.next(); + this.put((String)entry.getKey(), entry.getValue()); + } + } + + public void clear() + { + this.internalMap.clear(); + } + + public Set keySet() + { + return this.internalMap.keySet(); + } + + public Collection values() + { + return this.internalMap.values(); + } + + public Set entrySet() + { + return this.internalMap.entrySet(); + } + + public Object put(Object par1Obj, Object par2Obj) + { + return this.put((String)par1Obj, par2Obj); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/server/management/PlayerManager.java b/src/main/java/net/minecraft/server/management/PlayerManager.java new file mode 100644 index 0000000..7dbc76b --- /dev/null +++ b/src/main/java/net/minecraft/server/management/PlayerManager.java @@ -0,0 +1,483 @@ +package net.minecraft.server.management; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S21PacketChunkData; +import net.minecraft.network.play.server.S22PacketMultiBlockChange; +import net.minecraft.network.play.server.S23PacketBlockChange; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.LongHashMap; +import net.minecraft.world.ChunkCoordIntPair; +import net.minecraft.world.WorldProvider; +import net.minecraft.world.WorldServer; +import net.minecraft.world.chunk.Chunk; +import net.minecraftforge.common.ForgeModContainer; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.world.ChunkWatchEvent; + +public class PlayerManager +{ + private final WorldServer theWorldServer; + private final List players = new ArrayList(); + private final LongHashMap playerInstances = new LongHashMap(); + private final List chunkWatcherWithPlayers = new ArrayList(); + private final List playerInstanceList = new ArrayList(); + private final int playerViewRadius; + private long previousTotalWorldTime; + private final int[][] xzDirectionsConst = new int[][] {{1, 0}, {0, 1}, { -1, 0}, {0, -1}}; + private static final String __OBFID = "CL_00001434"; + + public PlayerManager(WorldServer par1WorldServer, int par2) + { + if (par2 > 15) + { + throw new IllegalArgumentException("Too big view radius!"); + } + else if (par2 < 3) + { + throw new IllegalArgumentException("Too small view radius!"); + } + else + { + this.playerViewRadius = par2; + this.theWorldServer = par1WorldServer; + } + } + + public WorldServer getWorldServer() + { + return this.theWorldServer; + } + + public void updatePlayerInstances() + { + long i = this.theWorldServer.getTotalWorldTime(); + int j; + PlayerManager.PlayerInstance playerinstance; + + if (i - this.previousTotalWorldTime > 8000L) + { + this.previousTotalWorldTime = i; + + for (j = 0; j < this.playerInstanceList.size(); ++j) + { + playerinstance = (PlayerManager.PlayerInstance)this.playerInstanceList.get(j); + playerinstance.sendChunkUpdate(); + playerinstance.processChunk(); + } + } + else + { + for (j = 0; j < this.chunkWatcherWithPlayers.size(); ++j) + { + playerinstance = (PlayerManager.PlayerInstance)this.chunkWatcherWithPlayers.get(j); + playerinstance.sendChunkUpdate(); + } + } + + this.chunkWatcherWithPlayers.clear(); + + if (this.players.isEmpty()) + { + WorldProvider worldprovider = this.theWorldServer.provider; + + if (!worldprovider.canRespawnHere()) + { + this.theWorldServer.theChunkProviderServer.unloadAllChunks(); + } + } + } + + private PlayerManager.PlayerInstance getOrCreateChunkWatcher(int par1, int par2, boolean par3) + { + long k = (long)par1 + 2147483647L | (long)par2 + 2147483647L << 32; + PlayerManager.PlayerInstance playerinstance = (PlayerManager.PlayerInstance)this.playerInstances.getValueByKey(k); + + if (playerinstance == null && par3) + { + playerinstance = new PlayerManager.PlayerInstance(par1, par2); + this.playerInstances.add(k, playerinstance); + this.playerInstanceList.add(playerinstance); + } + + return playerinstance; + } + + public void markBlockForUpdate(int p_151250_1_, int p_151250_2_, int p_151250_3_) + { + int l = p_151250_1_ >> 4; + int i1 = p_151250_3_ >> 4; + PlayerManager.PlayerInstance playerinstance = this.getOrCreateChunkWatcher(l, i1, false); + + if (playerinstance != null) + { + playerinstance.flagChunkForUpdate(p_151250_1_ & 15, p_151250_2_, p_151250_3_ & 15); + } + } + + public void addPlayer(EntityPlayerMP par1EntityPlayerMP) + { + int i = (int)par1EntityPlayerMP.posX >> 4; + int j = (int)par1EntityPlayerMP.posZ >> 4; + par1EntityPlayerMP.managedPosX = par1EntityPlayerMP.posX; + par1EntityPlayerMP.managedPosZ = par1EntityPlayerMP.posZ; + + for (int k = i - this.playerViewRadius; k <= i + this.playerViewRadius; ++k) + { + for (int l = j - this.playerViewRadius; l <= j + this.playerViewRadius; ++l) + { + this.getOrCreateChunkWatcher(k, l, true).addPlayer(par1EntityPlayerMP); + } + } + + this.players.add(par1EntityPlayerMP); + this.filterChunkLoadQueue(par1EntityPlayerMP); + } + + public void filterChunkLoadQueue(EntityPlayerMP par1EntityPlayerMP) + { + ArrayList arraylist = new ArrayList(par1EntityPlayerMP.loadedChunks); + int i = 0; + int j = this.playerViewRadius; + int k = (int)par1EntityPlayerMP.posX >> 4; + int l = (int)par1EntityPlayerMP.posZ >> 4; + int i1 = 0; + int j1 = 0; + ChunkCoordIntPair chunkcoordintpair = this.getOrCreateChunkWatcher(k, l, true).chunkLocation; + par1EntityPlayerMP.loadedChunks.clear(); + + if (arraylist.contains(chunkcoordintpair)) + { + par1EntityPlayerMP.loadedChunks.add(chunkcoordintpair); + } + + int k1; + + for (k1 = 1; k1 <= j * 2; ++k1) + { + for (int l1 = 0; l1 < 2; ++l1) + { + int[] aint = this.xzDirectionsConst[i++ % 4]; + + for (int i2 = 0; i2 < k1; ++i2) + { + i1 += aint[0]; + j1 += aint[1]; + chunkcoordintpair = this.getOrCreateChunkWatcher(k + i1, l + j1, true).chunkLocation; + + if (arraylist.contains(chunkcoordintpair)) + { + par1EntityPlayerMP.loadedChunks.add(chunkcoordintpair); + } + } + } + } + + i %= 4; + + for (k1 = 0; k1 < j * 2; ++k1) + { + i1 += this.xzDirectionsConst[i][0]; + j1 += this.xzDirectionsConst[i][1]; + chunkcoordintpair = this.getOrCreateChunkWatcher(k + i1, l + j1, true).chunkLocation; + + if (arraylist.contains(chunkcoordintpair)) + { + par1EntityPlayerMP.loadedChunks.add(chunkcoordintpair); + } + } + } + + public void removePlayer(EntityPlayerMP par1EntityPlayerMP) + { + int i = (int)par1EntityPlayerMP.managedPosX >> 4; + int j = (int)par1EntityPlayerMP.managedPosZ >> 4; + + for (int k = i - this.playerViewRadius; k <= i + this.playerViewRadius; ++k) + { + for (int l = j - this.playerViewRadius; l <= j + this.playerViewRadius; ++l) + { + PlayerManager.PlayerInstance playerinstance = this.getOrCreateChunkWatcher(k, l, false); + + if (playerinstance != null) + { + playerinstance.removePlayer(par1EntityPlayerMP); + } + } + } + + this.players.remove(par1EntityPlayerMP); + } + + private boolean overlaps(int par1, int par2, int par3, int par4, int par5) + { + int j1 = par1 - par3; + int k1 = par2 - par4; + return j1 >= -par5 && j1 <= par5 ? k1 >= -par5 && k1 <= par5 : false; + } + + public void updatePlayerPertinentChunks(EntityPlayerMP par1EntityPlayerMP) + { + int i = (int)par1EntityPlayerMP.posX >> 4; + int j = (int)par1EntityPlayerMP.posZ >> 4; + double d0 = par1EntityPlayerMP.managedPosX - par1EntityPlayerMP.posX; + double d1 = par1EntityPlayerMP.managedPosZ - par1EntityPlayerMP.posZ; + double d2 = d0 * d0 + d1 * d1; + + if (d2 >= 64.0D) + { + int k = (int)par1EntityPlayerMP.managedPosX >> 4; + int l = (int)par1EntityPlayerMP.managedPosZ >> 4; + int i1 = this.playerViewRadius; + int j1 = i - k; + int k1 = j - l; + + if (j1 != 0 || k1 != 0) + { + for (int l1 = i - i1; l1 <= i + i1; ++l1) + { + for (int i2 = j - i1; i2 <= j + i1; ++i2) + { + if (!this.overlaps(l1, i2, k, l, i1)) + { + this.getOrCreateChunkWatcher(l1, i2, true).addPlayer(par1EntityPlayerMP); + } + + if (!this.overlaps(l1 - j1, i2 - k1, i, j, i1)) + { + PlayerManager.PlayerInstance playerinstance = this.getOrCreateChunkWatcher(l1 - j1, i2 - k1, false); + + if (playerinstance != null) + { + playerinstance.removePlayer(par1EntityPlayerMP); + } + } + } + } + + this.filterChunkLoadQueue(par1EntityPlayerMP); + par1EntityPlayerMP.managedPosX = par1EntityPlayerMP.posX; + par1EntityPlayerMP.managedPosZ = par1EntityPlayerMP.posZ; + } + } + } + + public boolean isPlayerWatchingChunk(EntityPlayerMP par1EntityPlayerMP, int par2, int par3) + { + PlayerManager.PlayerInstance playerinstance = this.getOrCreateChunkWatcher(par2, par3, false); + return playerinstance == null ? false : playerinstance.playersWatchingChunk.contains(par1EntityPlayerMP) && !par1EntityPlayerMP.loadedChunks.contains(playerinstance.chunkLocation); + } + + public static int getFurthestViewableBlock(int par0) + { + return par0 * 16 - 16; + } + + class PlayerInstance + { + private final List playersWatchingChunk = new ArrayList(); + private final ChunkCoordIntPair chunkLocation; + private short[] locationOfBlockChange = new short[64]; + private int numberOfTilesToUpdate; + private int flagsYAreasToUpdate; + private long previousWorldTime; + private static final String __OBFID = "CL_00001435"; + + public PlayerInstance(int par2, int par3) + { + this.chunkLocation = new ChunkCoordIntPair(par2, par3); + PlayerManager.this.getWorldServer().theChunkProviderServer.loadChunk(par2, par3); + } + + public void addPlayer(EntityPlayerMP par1EntityPlayerMP) + { + if (this.playersWatchingChunk.contains(par1EntityPlayerMP)) + { + throw new IllegalStateException("Failed to add player. " + par1EntityPlayerMP + " already is in chunk " + this.chunkLocation.chunkXPos + ", " + this.chunkLocation.chunkZPos); + } + else + { + if (this.playersWatchingChunk.isEmpty()) + { + this.previousWorldTime = PlayerManager.this.theWorldServer.getTotalWorldTime(); + } + + this.playersWatchingChunk.add(par1EntityPlayerMP); + par1EntityPlayerMP.loadedChunks.add(this.chunkLocation); + } + } + + public void removePlayer(EntityPlayerMP par1EntityPlayerMP) + { + if (this.playersWatchingChunk.contains(par1EntityPlayerMP)) + { + Chunk chunk = PlayerManager.this.theWorldServer.getChunkFromChunkCoords(this.chunkLocation.chunkXPos, this.chunkLocation.chunkZPos); + + if (chunk.func_150802_k()) + { + par1EntityPlayerMP.playerNetServerHandler.sendPacket(new S21PacketChunkData(chunk, true, 0)); + } + + this.playersWatchingChunk.remove(par1EntityPlayerMP); + par1EntityPlayerMP.loadedChunks.remove(this.chunkLocation); + + MinecraftForge.EVENT_BUS.post(new ChunkWatchEvent.UnWatch(chunkLocation, par1EntityPlayerMP)); + + if (this.playersWatchingChunk.isEmpty()) + { + long i = (long)this.chunkLocation.chunkXPos + 2147483647L | (long)this.chunkLocation.chunkZPos + 2147483647L << 32; + this.increaseInhabitedTime(chunk); + PlayerManager.this.playerInstances.remove(i); + PlayerManager.this.playerInstanceList.remove(this); + + if (this.numberOfTilesToUpdate > 0) + { + PlayerManager.this.chunkWatcherWithPlayers.remove(this); + } + + PlayerManager.this.getWorldServer().theChunkProviderServer.unloadChunksIfNotNearSpawn(this.chunkLocation.chunkXPos, this.chunkLocation.chunkZPos); + } + } + } + + public void processChunk() + { + this.increaseInhabitedTime(PlayerManager.this.theWorldServer.getChunkFromChunkCoords(this.chunkLocation.chunkXPos, this.chunkLocation.chunkZPos)); + } + + private void increaseInhabitedTime(Chunk par1Chunk) + { + par1Chunk.inhabitedTime += PlayerManager.this.theWorldServer.getTotalWorldTime() - this.previousWorldTime; + this.previousWorldTime = PlayerManager.this.theWorldServer.getTotalWorldTime(); + } + + public void flagChunkForUpdate(int p_151253_1_, int p_151253_2_, int p_151253_3_) + { + if (this.numberOfTilesToUpdate == 0) + { + PlayerManager.this.chunkWatcherWithPlayers.add(this); + } + + this.flagsYAreasToUpdate |= 1 << (p_151253_2_ >> 4); + + //if (this.numberOfTilesToUpdate < 64) //Forge; Cache everything, so always run + { + short short1 = (short)(p_151253_1_ << 12 | p_151253_3_ << 8 | p_151253_2_); + + for (int l = 0; l < this.numberOfTilesToUpdate; ++l) + { + if (this.locationOfBlockChange[l] == short1) + { + return; + } + } + + if (numberOfTilesToUpdate == locationOfBlockChange.length) + { + locationOfBlockChange = Arrays.copyOf(locationOfBlockChange, locationOfBlockChange.length << 1); + } + this.locationOfBlockChange[this.numberOfTilesToUpdate++] = short1; + } + } + + public void sendToAllPlayersWatchingChunk(Packet p_151251_1_) + { + for (int i = 0; i < this.playersWatchingChunk.size(); ++i) + { + EntityPlayerMP entityplayermp = (EntityPlayerMP)this.playersWatchingChunk.get(i); + + if (!entityplayermp.loadedChunks.contains(this.chunkLocation)) + { + entityplayermp.playerNetServerHandler.sendPacket(p_151251_1_); + } + } + } + + public void sendChunkUpdate() + { + if (this.numberOfTilesToUpdate != 0) + { + int i; + int j; + int k; + + if (this.numberOfTilesToUpdate == 1) + { + i = this.chunkLocation.chunkXPos * 16 + (this.locationOfBlockChange[0] >> 12 & 15); + j = this.locationOfBlockChange[0] & 255; + k = this.chunkLocation.chunkZPos * 16 + (this.locationOfBlockChange[0] >> 8 & 15); + this.sendToAllPlayersWatchingChunk(new S23PacketBlockChange(i, j, k, PlayerManager.this.theWorldServer)); + + if (PlayerManager.this.theWorldServer.getBlock(i, j, k).hasTileEntity(PlayerManager.this.theWorldServer.getBlockMetadata(i, j, k))) + { + this.sendTileToAllPlayersWatchingChunk(PlayerManager.this.theWorldServer.getTileEntity(i, j, k)); + } + } + else + { + int l; + + if (this.numberOfTilesToUpdate == ForgeModContainer.clumpingThreshold) + { + i = this.chunkLocation.chunkXPos * 16; + j = this.chunkLocation.chunkZPos * 16; + this.sendToAllPlayersWatchingChunk(new S21PacketChunkData(PlayerManager.this.theWorldServer.getChunkFromChunkCoords(this.chunkLocation.chunkXPos, this.chunkLocation.chunkZPos), false, this.flagsYAreasToUpdate)); + + // Forge: Grabs ALL tile entities is costly on a modded server, only send needed ones + for (k = 0; false && k < 16; ++k) + { + if ((this.flagsYAreasToUpdate & 1 << k) != 0) + { + l = k << 4; + List list = PlayerManager.this.theWorldServer.func_147486_a(i, l, j, i + 16, l + 16, j + 16); + + for (int i1 = 0; i1 < list.size(); ++i1) + { + this.sendTileToAllPlayersWatchingChunk((TileEntity)list.get(i1)); + } + } + } + } + else + { + this.sendToAllPlayersWatchingChunk(new S22PacketMultiBlockChange(this.numberOfTilesToUpdate, this.locationOfBlockChange, PlayerManager.this.theWorldServer.getChunkFromChunkCoords(this.chunkLocation.chunkXPos, this.chunkLocation.chunkZPos))); + } + + { //Forge: Send only the tile entities that are updated, Adding this brace lets us keep the indent and the patch small + WorldServer world = PlayerManager.this.theWorldServer; + for (i = 0; i < this.numberOfTilesToUpdate; ++i) + { + j = this.chunkLocation.chunkXPos * 16 + (this.locationOfBlockChange[i] >> 12 & 15); + k = this.locationOfBlockChange[i] & 255; + l = this.chunkLocation.chunkZPos * 16 + (this.locationOfBlockChange[i] >> 8 & 15); + + if (world.getBlock(j, k, l).hasTileEntity(world.getBlockMetadata(j, k, l))) + { + this.sendTileToAllPlayersWatchingChunk(PlayerManager.this.theWorldServer.getTileEntity(j, k, l)); + } + } + } + } + + this.numberOfTilesToUpdate = 0; + this.flagsYAreasToUpdate = 0; + } + } + + private void sendTileToAllPlayersWatchingChunk(TileEntity p_151252_1_) + { + if (p_151252_1_ != null) + { + Packet packet = p_151252_1_.getDescriptionPacket(); + + if (packet != null) + { + this.sendToAllPlayersWatchingChunk(packet); + } + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/server/management/PlayerPositionComparator.java b/src/main/java/net/minecraft/server/management/PlayerPositionComparator.java new file mode 100644 index 0000000..f88e54f --- /dev/null +++ b/src/main/java/net/minecraft/server/management/PlayerPositionComparator.java @@ -0,0 +1,28 @@ +package net.minecraft.server.management; + +import java.util.Comparator; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.util.ChunkCoordinates; + +public class PlayerPositionComparator implements Comparator +{ + private final ChunkCoordinates theChunkCoordinates; + private static final String __OBFID = "CL_00001422"; + + public PlayerPositionComparator(ChunkCoordinates par1ChunkCoordinates) + { + this.theChunkCoordinates = par1ChunkCoordinates; + } + + public int compare(EntityPlayerMP par1EntityPlayerMP, EntityPlayerMP par2EntityPlayerMP) + { + double d0 = par1EntityPlayerMP.getDistanceSq((double)this.theChunkCoordinates.posX, (double)this.theChunkCoordinates.posY, (double)this.theChunkCoordinates.posZ); + double d1 = par2EntityPlayerMP.getDistanceSq((double)this.theChunkCoordinates.posX, (double)this.theChunkCoordinates.posY, (double)this.theChunkCoordinates.posZ); + return d0 < d1 ? -1 : (d0 > d1 ? 1 : 0); + } + + public int compare(Object par1Obj, Object par2Obj) + { + return this.compare((EntityPlayerMP)par1Obj, (EntityPlayerMP)par2Obj); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/server/management/ServerConfigurationManager.java b/src/main/java/net/minecraft/server/management/ServerConfigurationManager.java new file mode 100644 index 0000000..7921923 --- /dev/null +++ b/src/main/java/net/minecraft/server/management/ServerConfigurationManager.java @@ -0,0 +1,995 @@ +package net.minecraft.server.management; + +import com.google.common.base.Charsets; +import com.google.common.collect.Maps; +import com.mojang.authlib.GameProfile; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.File; +import java.net.SocketAddress; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Map.Entry; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityList; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetHandlerPlayServer; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S01PacketJoinGame; +import net.minecraft.network.play.server.S02PacketChat; +import net.minecraft.network.play.server.S03PacketTimeUpdate; +import net.minecraft.network.play.server.S05PacketSpawnPosition; +import net.minecraft.network.play.server.S07PacketRespawn; +import net.minecraft.network.play.server.S09PacketHeldItemChange; +import net.minecraft.network.play.server.S1DPacketEntityEffect; +import net.minecraft.network.play.server.S1FPacketSetExperience; +import net.minecraft.network.play.server.S2BPacketChangeGameState; +import net.minecraft.network.play.server.S38PacketPlayerListItem; +import net.minecraft.network.play.server.S39PacketPlayerAbilities; +import net.minecraft.network.play.server.S3EPacketTeams; +import net.minecraft.network.play.server.S3FPacketCustomPayload; +import net.minecraft.potion.PotionEffect; +import net.minecraft.scoreboard.Score; +import net.minecraft.scoreboard.ScoreObjective; +import net.minecraft.scoreboard.ScorePlayerTeam; +import net.minecraft.scoreboard.Scoreboard; +import net.minecraft.scoreboard.ServerScoreboard; +import net.minecraft.scoreboard.Team; +import net.minecraft.server.MinecraftServer; +import net.minecraft.stats.StatList; +import net.minecraft.stats.StatisticsFile; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IChatComponent; +import net.minecraft.util.MathHelper; +import net.minecraft.world.Teleporter; +import net.minecraft.world.World; +import net.minecraft.world.WorldProvider; +import net.minecraft.world.WorldServer; +import net.minecraft.world.WorldSettings; +import net.minecraft.world.demo.DemoWorldManager; +import net.minecraft.world.storage.IPlayerFileData; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public abstract class ServerConfigurationManager +{ + private static final Logger logger = LogManager.getLogger(); + private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd \'at\' HH:mm:ss z"); + private final MinecraftServer mcServer; + public final List playerEntityList = new ArrayList(); + private final BanList bannedPlayers = new BanList(new File("banned-players.txt")); + private final BanList bannedIPs = new BanList(new File("banned-ips.txt")); + private final Set ops = new HashSet(); + private final Set whiteListedPlayers = new HashSet(); + private final Map field_148547_k = Maps.newHashMap(); + private IPlayerFileData playerNBTManagerObj; + private boolean whiteListEnforced; + protected int maxPlayers; + protected int viewDistance; + private WorldSettings.GameType gameType; + private boolean commandsAllowedForAll; + private int playerPingIndex; + private static final String __OBFID = "CL_00001423"; + + public ServerConfigurationManager(MinecraftServer par1MinecraftServer) + { + this.mcServer = par1MinecraftServer; + this.bannedPlayers.setListActive(false); + this.bannedIPs.setListActive(false); + this.maxPlayers = 8; + } + + public void initializeConnectionToPlayer(NetworkManager par1INetworkManager, EntityPlayerMP par2EntityPlayerMP, NetHandlerPlayServer nethandlerplayserver) + { + NBTTagCompound nbttagcompound = this.readPlayerDataFromFile(par2EntityPlayerMP); + par2EntityPlayerMP.setWorld(this.mcServer.worldServerForDimension(par2EntityPlayerMP.dimension)); + par2EntityPlayerMP.theItemInWorldManager.setWorld((WorldServer)par2EntityPlayerMP.worldObj); + String s = "local"; + + if (par1INetworkManager.getSocketAddress() != null) + { + s = par1INetworkManager.getSocketAddress().toString(); + } + + logger.info(par2EntityPlayerMP.getCommandSenderName() + "[" + s + "] logged in with entity id " + par2EntityPlayerMP.getEntityId() + " at (" + par2EntityPlayerMP.posX + ", " + par2EntityPlayerMP.posY + ", " + par2EntityPlayerMP.posZ + ")"); + WorldServer worldserver = this.mcServer.worldServerForDimension(par2EntityPlayerMP.dimension); + ChunkCoordinates chunkcoordinates = worldserver.getSpawnPoint(); + this.func_72381_a(par2EntityPlayerMP, (EntityPlayerMP)null, worldserver); + par2EntityPlayerMP.playerNetServerHandler = nethandlerplayserver; + nethandlerplayserver.sendPacket(new S01PacketJoinGame(par2EntityPlayerMP.getEntityId(), par2EntityPlayerMP.theItemInWorldManager.getGameType(), worldserver.getWorldInfo().isHardcoreModeEnabled(), worldserver.provider.dimensionId, worldserver.difficultySetting, this.getMaxPlayers(), worldserver.getWorldInfo().getTerrainType())); + nethandlerplayserver.sendPacket(new S3FPacketCustomPayload("MC|Brand", this.getServerInstance().getServerModName().getBytes(Charsets.UTF_8))); + nethandlerplayserver.sendPacket(new S05PacketSpawnPosition(chunkcoordinates.posX, chunkcoordinates.posY, chunkcoordinates.posZ)); + nethandlerplayserver.sendPacket(new S39PacketPlayerAbilities(par2EntityPlayerMP.capabilities)); + nethandlerplayserver.sendPacket(new S09PacketHeldItemChange(par2EntityPlayerMP.inventory.currentItem)); + par2EntityPlayerMP.func_147099_x().func_150877_d(); + par2EntityPlayerMP.func_147099_x().func_150884_b(par2EntityPlayerMP); + this.func_96456_a((ServerScoreboard)worldserver.getScoreboard(), par2EntityPlayerMP); + this.mcServer.func_147132_au(); + ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("multiplayer.player.joined", new Object[] {par2EntityPlayerMP.func_145748_c_()}); + chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.YELLOW); + this.sendChatMsg(chatcomponenttranslation); + this.playerLoggedIn(par2EntityPlayerMP); + nethandlerplayserver.setPlayerLocation(par2EntityPlayerMP.posX, par2EntityPlayerMP.posY, par2EntityPlayerMP.posZ, par2EntityPlayerMP.rotationYaw, par2EntityPlayerMP.rotationPitch); + this.updateTimeAndWeatherForPlayer(par2EntityPlayerMP, worldserver); + + if (this.mcServer.getTexturePack().length() > 0) + { + par2EntityPlayerMP.requestTexturePackLoad(this.mcServer.getTexturePack()); + } + + Iterator iterator = par2EntityPlayerMP.getActivePotionEffects().iterator(); + + while (iterator.hasNext()) + { + PotionEffect potioneffect = (PotionEffect)iterator.next(); + nethandlerplayserver.sendPacket(new S1DPacketEntityEffect(par2EntityPlayerMP.getEntityId(), potioneffect)); + } + + par2EntityPlayerMP.addSelfToInternalCraftingInventory(); + + FMLCommonHandler.instance().firePlayerLoggedIn(par2EntityPlayerMP); + if (nbttagcompound != null && nbttagcompound.hasKey("Riding", 10)) + { + Entity entity = EntityList.createEntityFromNBT(nbttagcompound.getCompoundTag("Riding"), worldserver); + + if (entity != null) + { + entity.forceSpawn = true; + worldserver.spawnEntityInWorld(entity); + par2EntityPlayerMP.mountEntity(entity); + entity.forceSpawn = false; + } + } + } + + protected void func_96456_a(ServerScoreboard par1ServerScoreboard, EntityPlayerMP par2EntityPlayerMP) + { + HashSet hashset = new HashSet(); + Iterator iterator = par1ServerScoreboard.getTeams().iterator(); + + while (iterator.hasNext()) + { + ScorePlayerTeam scoreplayerteam = (ScorePlayerTeam)iterator.next(); + par2EntityPlayerMP.playerNetServerHandler.sendPacket(new S3EPacketTeams(scoreplayerteam, 0)); + } + + for (int i = 0; i < 3; ++i) + { + ScoreObjective scoreobjective = par1ServerScoreboard.func_96539_a(i); + + if (scoreobjective != null && !hashset.contains(scoreobjective)) + { + List list = par1ServerScoreboard.func_96550_d(scoreobjective); + Iterator iterator1 = list.iterator(); + + while (iterator1.hasNext()) + { + Packet packet = (Packet)iterator1.next(); + par2EntityPlayerMP.playerNetServerHandler.sendPacket(packet); + } + + hashset.add(scoreobjective); + } + } + } + + public void setPlayerManager(WorldServer[] par1ArrayOfWorldServer) + { + this.playerNBTManagerObj = par1ArrayOfWorldServer[0].getSaveHandler().getSaveHandler(); + } + + public void func_72375_a(EntityPlayerMP par1EntityPlayerMP, WorldServer par2WorldServer) + { + WorldServer worldserver1 = par1EntityPlayerMP.getServerForPlayer(); + + if (par2WorldServer != null) + { + par2WorldServer.getPlayerManager().removePlayer(par1EntityPlayerMP); + } + + worldserver1.getPlayerManager().addPlayer(par1EntityPlayerMP); + worldserver1.theChunkProviderServer.loadChunk((int)par1EntityPlayerMP.posX >> 4, (int)par1EntityPlayerMP.posZ >> 4); + } + + public int getEntityViewDistance() + { + return PlayerManager.getFurthestViewableBlock(this.getViewDistance()); + } + + public NBTTagCompound readPlayerDataFromFile(EntityPlayerMP par1EntityPlayerMP) + { + NBTTagCompound nbttagcompound = this.mcServer.worldServers[0].getWorldInfo().getPlayerNBTTagCompound(); + NBTTagCompound nbttagcompound1; + + if (par1EntityPlayerMP.getCommandSenderName().equals(this.mcServer.getServerOwner()) && nbttagcompound != null) + { + par1EntityPlayerMP.readFromNBT(nbttagcompound); + nbttagcompound1 = nbttagcompound; + logger.debug("loading single player"); + } + else + { + nbttagcompound1 = this.playerNBTManagerObj.readPlayerData(par1EntityPlayerMP); + } + + return nbttagcompound1; + } + + protected void writePlayerData(EntityPlayerMP par1EntityPlayerMP) + { + if (par1EntityPlayerMP.playerNetServerHandler == null) return; + + this.playerNBTManagerObj.writePlayerData(par1EntityPlayerMP); + StatisticsFile statisticsfile = (StatisticsFile)this.field_148547_k.get(par1EntityPlayerMP.getCommandSenderName()); + + if (statisticsfile != null) + { + statisticsfile.func_150883_b(); + } + } + + public void playerLoggedIn(EntityPlayerMP par1EntityPlayerMP) + { + this.sendPacketToAllPlayers(new S38PacketPlayerListItem(par1EntityPlayerMP.getCommandSenderName(), true, 1000)); + this.playerEntityList.add(par1EntityPlayerMP); + WorldServer worldserver = this.mcServer.worldServerForDimension(par1EntityPlayerMP.dimension); + worldserver.spawnEntityInWorld(par1EntityPlayerMP); + this.func_72375_a(par1EntityPlayerMP, (WorldServer)null); + + for (int i = 0; i < this.playerEntityList.size(); ++i) + { + EntityPlayerMP entityplayermp1 = (EntityPlayerMP)this.playerEntityList.get(i); + par1EntityPlayerMP.playerNetServerHandler.sendPacket(new S38PacketPlayerListItem(entityplayermp1.getCommandSenderName(), true, entityplayermp1.ping)); + } + } + + public void updatePlayerPertinentChunks(EntityPlayerMP par1EntityPlayerMP) + { + par1EntityPlayerMP.getServerForPlayer().getPlayerManager().updatePlayerPertinentChunks(par1EntityPlayerMP); + } + + public void playerLoggedOut(EntityPlayerMP par1EntityPlayerMP) + { + FMLCommonHandler.instance().firePlayerLoggedOut(par1EntityPlayerMP); + par1EntityPlayerMP.triggerAchievement(StatList.leaveGameStat); + this.writePlayerData(par1EntityPlayerMP); + WorldServer worldserver = par1EntityPlayerMP.getServerForPlayer(); + + if (par1EntityPlayerMP.ridingEntity != null) + { + worldserver.removePlayerEntityDangerously(par1EntityPlayerMP.ridingEntity); + logger.debug("removing player mount"); + } + + worldserver.removeEntity(par1EntityPlayerMP); + worldserver.getPlayerManager().removePlayer(par1EntityPlayerMP); + this.playerEntityList.remove(par1EntityPlayerMP); + this.field_148547_k.remove(par1EntityPlayerMP.getCommandSenderName()); + this.sendPacketToAllPlayers(new S38PacketPlayerListItem(par1EntityPlayerMP.getCommandSenderName(), false, 9999)); + } + + public String allowUserToConnect(SocketAddress p_148542_1_, GameProfile p_148542_2_) + { + if (this.bannedPlayers.isBanned(p_148542_2_.getName())) + { + BanEntry banentry1 = (BanEntry)this.bannedPlayers.getBannedList().get(p_148542_2_.getName()); + String s2 = "You are banned from this server!\nReason: " + banentry1.getBanReason(); + + if (banentry1.getBanEndDate() != null) + { + s2 = s2 + "\nYour ban will be removed on " + dateFormat.format(banentry1.getBanEndDate()); + } + + return s2; + } + else if (!this.isAllowedToLogin(p_148542_2_.getName())) + { + return "You are not white-listed on this server!"; + } + else + { + String s = p_148542_1_.toString(); + s = s.substring(s.indexOf("/") + 1); + s = s.substring(0, s.indexOf(":")); + + if (this.bannedIPs.isBanned(s)) + { + BanEntry banentry = (BanEntry)this.bannedIPs.getBannedList().get(s); + String s1 = "Your IP address is banned from this server!\nReason: " + banentry.getBanReason(); + + if (banentry.getBanEndDate() != null) + { + s1 = s1 + "\nYour ban will be removed on " + dateFormat.format(banentry.getBanEndDate()); + } + + return s1; + } + else + { + return this.playerEntityList.size() >= this.maxPlayers ? "The server is full!" : null; + } + } + } + + public EntityPlayerMP createPlayerForUser(GameProfile p_148545_1_) + { + ArrayList arraylist = new ArrayList(); + EntityPlayerMP entityplayermp; + + for (int i = 0; i < this.playerEntityList.size(); ++i) + { + entityplayermp = (EntityPlayerMP)this.playerEntityList.get(i); + + if (entityplayermp.getCommandSenderName().equalsIgnoreCase(p_148545_1_.getName())) + { + arraylist.add(entityplayermp); + } + } + + Iterator iterator = arraylist.iterator(); + + while (iterator.hasNext()) + { + entityplayermp = (EntityPlayerMP)iterator.next(); + entityplayermp.playerNetServerHandler.kickPlayerFromServer("You logged in from another location"); + } + + Object object; + + if (this.mcServer.isDemo()) + { + object = new DemoWorldManager(this.mcServer.worldServerForDimension(0)); + } + else + { + object = new ItemInWorldManager(this.mcServer.worldServerForDimension(0)); + } + + return new EntityPlayerMP(this.mcServer, this.mcServer.worldServerForDimension(0), p_148545_1_, (ItemInWorldManager)object); + } + + public EntityPlayerMP respawnPlayer(EntityPlayerMP par1EntityPlayerMP, int par2, boolean par3) + { + World world = mcServer.worldServerForDimension(par2); + if (world == null) + { + par2 = 0; + } + else if (!world.provider.canRespawnHere()) + { + par2 = world.provider.getRespawnDimension(par1EntityPlayerMP); + } + + par1EntityPlayerMP.getServerForPlayer().getEntityTracker().removePlayerFromTrackers(par1EntityPlayerMP); + par1EntityPlayerMP.getServerForPlayer().getEntityTracker().removeEntityFromAllTrackingPlayers(par1EntityPlayerMP); + par1EntityPlayerMP.getServerForPlayer().getPlayerManager().removePlayer(par1EntityPlayerMP); + this.playerEntityList.remove(par1EntityPlayerMP); + this.mcServer.worldServerForDimension(par1EntityPlayerMP.dimension).removePlayerEntityDangerously(par1EntityPlayerMP); + ChunkCoordinates chunkcoordinates = par1EntityPlayerMP.getBedLocation(par2); + boolean flag1 = par1EntityPlayerMP.isSpawnForced(par2); + par1EntityPlayerMP.dimension = par2; + Object object; + + if (this.mcServer.isDemo()) + { + object = new DemoWorldManager(this.mcServer.worldServerForDimension(par1EntityPlayerMP.dimension)); + } + else + { + object = new ItemInWorldManager(this.mcServer.worldServerForDimension(par1EntityPlayerMP.dimension)); + } + + EntityPlayerMP entityplayermp1 = new EntityPlayerMP(this.mcServer, this.mcServer.worldServerForDimension(par1EntityPlayerMP.dimension), par1EntityPlayerMP.getGameProfile(), (ItemInWorldManager)object); + entityplayermp1.playerNetServerHandler = par1EntityPlayerMP.playerNetServerHandler; + entityplayermp1.clonePlayer(par1EntityPlayerMP, par3); + entityplayermp1.dimension = par2; + entityplayermp1.setEntityId(par1EntityPlayerMP.getEntityId()); + WorldServer worldserver = this.mcServer.worldServerForDimension(par1EntityPlayerMP.dimension); + this.func_72381_a(entityplayermp1, par1EntityPlayerMP, worldserver); + ChunkCoordinates chunkcoordinates1; + + if (chunkcoordinates != null) + { + chunkcoordinates1 = EntityPlayer.verifyRespawnCoordinates(this.mcServer.worldServerForDimension(par1EntityPlayerMP.dimension), chunkcoordinates, flag1); + + if (chunkcoordinates1 != null) + { + entityplayermp1.setLocationAndAngles((double)((float)chunkcoordinates1.posX + 0.5F), (double)((float)chunkcoordinates1.posY + 0.1F), (double)((float)chunkcoordinates1.posZ + 0.5F), 0.0F, 0.0F); + entityplayermp1.setSpawnChunk(chunkcoordinates, flag1); + } + else + { + entityplayermp1.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(0, 0.0F)); + } + } + + worldserver.theChunkProviderServer.loadChunk((int)entityplayermp1.posX >> 4, (int)entityplayermp1.posZ >> 4); + + while (!worldserver.getCollidingBoundingBoxes(entityplayermp1, entityplayermp1.boundingBox).isEmpty()) + { + entityplayermp1.setPosition(entityplayermp1.posX, entityplayermp1.posY + 1.0D, entityplayermp1.posZ); + } + + entityplayermp1.playerNetServerHandler.sendPacket(new S07PacketRespawn(entityplayermp1.dimension, entityplayermp1.worldObj.difficultySetting, entityplayermp1.worldObj.getWorldInfo().getTerrainType(), entityplayermp1.theItemInWorldManager.getGameType())); + chunkcoordinates1 = worldserver.getSpawnPoint(); + entityplayermp1.playerNetServerHandler.setPlayerLocation(entityplayermp1.posX, entityplayermp1.posY, entityplayermp1.posZ, entityplayermp1.rotationYaw, entityplayermp1.rotationPitch); + entityplayermp1.playerNetServerHandler.sendPacket(new S05PacketSpawnPosition(chunkcoordinates1.posX, chunkcoordinates1.posY, chunkcoordinates1.posZ)); + entityplayermp1.playerNetServerHandler.sendPacket(new S1FPacketSetExperience(entityplayermp1.experience, entityplayermp1.experienceTotal, entityplayermp1.experienceLevel)); + this.updateTimeAndWeatherForPlayer(entityplayermp1, worldserver); + worldserver.getPlayerManager().addPlayer(entityplayermp1); + worldserver.spawnEntityInWorld(entityplayermp1); + this.playerEntityList.add(entityplayermp1); + entityplayermp1.addSelfToInternalCraftingInventory(); + entityplayermp1.setHealth(entityplayermp1.getHealth()); + FMLCommonHandler.instance().firePlayerRespawnEvent(entityplayermp1); + return entityplayermp1; + } + + public void transferPlayerToDimension(EntityPlayerMP par1EntityPlayerMP, int par2) + { + transferPlayerToDimension(par1EntityPlayerMP, par2, mcServer.worldServerForDimension(par2).getDefaultTeleporter()); + } + + public void transferPlayerToDimension(EntityPlayerMP par1EntityPlayerMP, int par2, Teleporter teleporter) + { + int j = par1EntityPlayerMP.dimension; + WorldServer worldserver = this.mcServer.worldServerForDimension(par1EntityPlayerMP.dimension); + par1EntityPlayerMP.dimension = par2; + WorldServer worldserver1 = this.mcServer.worldServerForDimension(par1EntityPlayerMP.dimension); + par1EntityPlayerMP.playerNetServerHandler.sendPacket(new S07PacketRespawn(par1EntityPlayerMP.dimension, par1EntityPlayerMP.worldObj.difficultySetting, par1EntityPlayerMP.worldObj.getWorldInfo().getTerrainType(), par1EntityPlayerMP.theItemInWorldManager.getGameType())); + worldserver.removePlayerEntityDangerously(par1EntityPlayerMP); + par1EntityPlayerMP.isDead = false; + this.transferEntityToWorld(par1EntityPlayerMP, j, worldserver, worldserver1, teleporter); + this.func_72375_a(par1EntityPlayerMP, worldserver); + par1EntityPlayerMP.playerNetServerHandler.setPlayerLocation(par1EntityPlayerMP.posX, par1EntityPlayerMP.posY, par1EntityPlayerMP.posZ, par1EntityPlayerMP.rotationYaw, par1EntityPlayerMP.rotationPitch); + par1EntityPlayerMP.theItemInWorldManager.setWorld(worldserver1); + this.updateTimeAndWeatherForPlayer(par1EntityPlayerMP, worldserver1); + this.syncPlayerInventory(par1EntityPlayerMP); + Iterator iterator = par1EntityPlayerMP.getActivePotionEffects().iterator(); + + while (iterator.hasNext()) + { + PotionEffect potioneffect = (PotionEffect)iterator.next(); + par1EntityPlayerMP.playerNetServerHandler.sendPacket(new S1DPacketEntityEffect(par1EntityPlayerMP.getEntityId(), potioneffect)); + } + FMLCommonHandler.instance().firePlayerChangedDimensionEvent(par1EntityPlayerMP, j, par2); + } + + public void transferEntityToWorld(Entity par1Entity, int par2, WorldServer par3WorldServer, WorldServer par4WorldServer) + { + transferEntityToWorld(par1Entity, par2, par3WorldServer, par4WorldServer, par4WorldServer.getDefaultTeleporter()); + } + + public void transferEntityToWorld(Entity par1Entity, int par2, WorldServer par3WorldServer, WorldServer par4WorldServer, Teleporter teleporter) + { + WorldProvider pOld = par3WorldServer.provider; + WorldProvider pNew = par4WorldServer.provider; + double moveFactor = pOld.getMovementFactor() / pNew.getMovementFactor(); + double d0 = par1Entity.posX * moveFactor; + double d1 = par1Entity.posZ * moveFactor; + double d3 = par1Entity.posX; + double d4 = par1Entity.posY; + double d5 = par1Entity.posZ; + float f = par1Entity.rotationYaw; + par3WorldServer.theProfiler.startSection("moving"); + + /* + if (par1Entity.dimension == -1) + { + d0 /= d2; + d1 /= d2; + par1Entity.setLocationAndAngles(d0, par1Entity.posY, d1, par1Entity.rotationYaw, par1Entity.rotationPitch); + + if (par1Entity.isEntityAlive()) + { + par3WorldServer.updateEntityWithOptionalForce(par1Entity, false); + } + } + else if (par1Entity.dimension == 0) + { + d0 *= d2; + d1 *= d2; + par1Entity.setLocationAndAngles(d0, par1Entity.posY, d1, par1Entity.rotationYaw, par1Entity.rotationPitch); + + if (par1Entity.isEntityAlive()) + { + par3WorldServer.updateEntityWithOptionalForce(par1Entity, false); + } + } + */ + if (par1Entity.dimension == 1) + { + ChunkCoordinates chunkcoordinates; + + if (par2 == 1) + { + chunkcoordinates = par4WorldServer.getSpawnPoint(); + } + else + { + chunkcoordinates = par4WorldServer.getEntrancePortalLocation(); + } + + d0 = (double)chunkcoordinates.posX; + par1Entity.posY = (double)chunkcoordinates.posY; + d1 = (double)chunkcoordinates.posZ; + par1Entity.setLocationAndAngles(d0, par1Entity.posY, d1, 90.0F, 0.0F); + + if (par1Entity.isEntityAlive()) + { + par3WorldServer.updateEntityWithOptionalForce(par1Entity, false); + } + } + + par3WorldServer.theProfiler.endSection(); + + if (par2 != 1) + { + par3WorldServer.theProfiler.startSection("placing"); + d0 = (double)MathHelper.clamp_int((int)d0, -29999872, 29999872); + d1 = (double)MathHelper.clamp_int((int)d1, -29999872, 29999872); + + if (par1Entity.isEntityAlive()) + { + par1Entity.setLocationAndAngles(d0, par1Entity.posY, d1, par1Entity.rotationYaw, par1Entity.rotationPitch); + teleporter.placeInPortal(par1Entity, d3, d4, d5, f); + par4WorldServer.spawnEntityInWorld(par1Entity); + par4WorldServer.updateEntityWithOptionalForce(par1Entity, false); + } + + par3WorldServer.theProfiler.endSection(); + } + + par1Entity.setWorld(par4WorldServer); + } + + public void sendPlayerInfoToAllPlayers() + { + if (++this.playerPingIndex > 600) + { + this.playerPingIndex = 0; + } + + if (this.playerPingIndex < this.playerEntityList.size()) + { + EntityPlayerMP entityplayermp = (EntityPlayerMP)this.playerEntityList.get(this.playerPingIndex); + this.sendPacketToAllPlayers(new S38PacketPlayerListItem(entityplayermp.getCommandSenderName(), true, entityplayermp.ping)); + } + } + + public void sendPacketToAllPlayers(Packet p_148540_1_) + { + for (int i = 0; i < this.playerEntityList.size(); ++i) + { + ((EntityPlayerMP)this.playerEntityList.get(i)).playerNetServerHandler.sendPacket(p_148540_1_); + } + } + + public void sendPacketToAllPlayersInDimension(Packet p_148537_1_, int p_148537_2_) + { + for (int j = 0; j < this.playerEntityList.size(); ++j) + { + EntityPlayerMP entityplayermp = (EntityPlayerMP)this.playerEntityList.get(j); + + if (entityplayermp.dimension == p_148537_2_) + { + entityplayermp.playerNetServerHandler.sendPacket(p_148537_1_); + } + } + } + + public String getPlayerListAsString() + { + String s = ""; + + for (int i = 0; i < this.playerEntityList.size(); ++i) + { + if (i > 0) + { + s = s + ", "; + } + + s = s + ((EntityPlayerMP)this.playerEntityList.get(i)).getCommandSenderName(); + } + + return s; + } + + public String[] getAllUsernames() + { + String[] astring = new String[this.playerEntityList.size()]; + + for (int i = 0; i < this.playerEntityList.size(); ++i) + { + astring[i] = ((EntityPlayerMP)this.playerEntityList.get(i)).getCommandSenderName(); + } + + return astring; + } + + public BanList getBannedPlayers() + { + return this.bannedPlayers; + } + + public BanList getBannedIPs() + { + return this.bannedIPs; + } + + public void addOp(String par1Str) + { + this.ops.add(par1Str.toLowerCase()); + } + + public void removeOp(String par1Str) + { + this.ops.remove(par1Str.toLowerCase()); + } + + public boolean isAllowedToLogin(String par1Str) + { + par1Str = par1Str.trim().toLowerCase(); + return !this.whiteListEnforced || this.ops.contains(par1Str) || this.whiteListedPlayers.contains(par1Str); + } + + public boolean isPlayerOpped(String par1Str) + { + return this.ops.contains(par1Str.trim().toLowerCase()) || this.mcServer.isSinglePlayer() && this.mcServer.worldServers[0].getWorldInfo().areCommandsAllowed() && this.mcServer.getServerOwner().equalsIgnoreCase(par1Str) || this.commandsAllowedForAll; + } + + public EntityPlayerMP getPlayerForUsername(String par1Str) + { + Iterator iterator = this.playerEntityList.iterator(); + EntityPlayerMP entityplayermp; + + do + { + if (!iterator.hasNext()) + { + return null; + } + + entityplayermp = (EntityPlayerMP)iterator.next(); + } + while (!entityplayermp.getCommandSenderName().equalsIgnoreCase(par1Str)); + + return entityplayermp; + } + + public List findPlayers(ChunkCoordinates par1ChunkCoordinates, int par2, int par3, int par4, int par5, int par6, int par7, Map par8Map, String par9Str, String par10Str, World par11World) + { + if (this.playerEntityList.isEmpty()) + { + return null; + } + else + { + Object object = new ArrayList(); + boolean flag = par4 < 0; + boolean flag1 = par9Str != null && par9Str.startsWith("!"); + boolean flag2 = par10Str != null && par10Str.startsWith("!"); + int k1 = par2 * par2; + int l1 = par3 * par3; + par4 = MathHelper.abs_int(par4); + + if (flag1) + { + par9Str = par9Str.substring(1); + } + + if (flag2) + { + par10Str = par10Str.substring(1); + } + + for (int i2 = 0; i2 < this.playerEntityList.size(); ++i2) + { + EntityPlayerMP entityplayermp = (EntityPlayerMP)this.playerEntityList.get(i2); + + if ((par11World == null || entityplayermp.worldObj == par11World) && (par9Str == null || flag1 != par9Str.equalsIgnoreCase(entityplayermp.getCommandSenderName()))) + { + if (par10Str != null) + { + Team team = entityplayermp.getTeam(); + String s2 = team == null ? "" : team.getRegisteredName(); + + if (flag2 == par10Str.equalsIgnoreCase(s2)) + { + continue; + } + } + + if (par1ChunkCoordinates != null && (par2 > 0 || par3 > 0)) + { + float f = par1ChunkCoordinates.getDistanceSquaredToChunkCoordinates(entityplayermp.getPlayerCoordinates()); + + if (par2 > 0 && f < (float)k1 || par3 > 0 && f > (float)l1) + { + continue; + } + } + + if (this.func_96457_a(entityplayermp, par8Map) && (par5 == WorldSettings.GameType.NOT_SET.getID() || par5 == entityplayermp.theItemInWorldManager.getGameType().getID()) && (par6 <= 0 || entityplayermp.experienceLevel >= par6) && entityplayermp.experienceLevel <= par7) + { + ((List)object).add(entityplayermp); + } + } + } + + if (par1ChunkCoordinates != null) + { + Collections.sort((List)object, new PlayerPositionComparator(par1ChunkCoordinates)); + } + + if (flag) + { + Collections.reverse((List)object); + } + + if (par4 > 0) + { + object = ((List)object).subList(0, Math.min(par4, ((List)object).size())); + } + + return (List)object; + } + } + + private boolean func_96457_a(EntityPlayer par1EntityPlayer, Map par2Map) + { + if (par2Map != null && par2Map.size() != 0) + { + Iterator iterator = par2Map.entrySet().iterator(); + Entry entry; + boolean flag; + int i; + + do + { + if (!iterator.hasNext()) + { + return true; + } + + entry = (Entry)iterator.next(); + String s = (String)entry.getKey(); + flag = false; + + if (s.endsWith("_min") && s.length() > 4) + { + flag = true; + s = s.substring(0, s.length() - 4); + } + + Scoreboard scoreboard = par1EntityPlayer.getWorldScoreboard(); + ScoreObjective scoreobjective = scoreboard.getObjective(s); + + if (scoreobjective == null) + { + return false; + } + + Score score = par1EntityPlayer.getWorldScoreboard().func_96529_a(par1EntityPlayer.getCommandSenderName(), scoreobjective); + i = score.getScorePoints(); + + if (i < ((Integer)entry.getValue()).intValue() && flag) + { + return false; + } + } + while (i <= ((Integer)entry.getValue()).intValue() || flag); + + return false; + } + else + { + return true; + } + } + + public void sendToAllNear(double p_148541_1_, double p_148541_3_, double p_148541_5_, double p_148541_7_, int p_148541_9_, Packet p_148541_10_) + { + this.sendToAllNearExcept((EntityPlayer)null, p_148541_1_, p_148541_3_, p_148541_5_, p_148541_7_, p_148541_9_, p_148541_10_); + } + + public void sendToAllNearExcept(EntityPlayer p_148543_1_, double p_148543_2_, double p_148543_4_, double p_148543_6_, double p_148543_8_, int p_148543_10_, Packet p_148543_11_) + { + for (int j = 0; j < this.playerEntityList.size(); ++j) + { + EntityPlayerMP entityplayermp = (EntityPlayerMP)this.playerEntityList.get(j); + + if (entityplayermp != p_148543_1_ && entityplayermp.dimension == p_148543_10_) + { + double d4 = p_148543_2_ - entityplayermp.posX; + double d5 = p_148543_4_ - entityplayermp.posY; + double d6 = p_148543_6_ - entityplayermp.posZ; + + if (d4 * d4 + d5 * d5 + d6 * d6 < p_148543_8_ * p_148543_8_) + { + entityplayermp.playerNetServerHandler.sendPacket(p_148543_11_); + } + } + } + } + + public void saveAllPlayerData() + { + for (int i = 0; i < this.playerEntityList.size(); ++i) + { + this.writePlayerData((EntityPlayerMP)this.playerEntityList.get(i)); + } + } + + public void addToWhiteList(String par1Str) + { + this.whiteListedPlayers.add(par1Str); + } + + public void removeFromWhitelist(String par1Str) + { + this.whiteListedPlayers.remove(par1Str); + } + + public Set getWhiteListedPlayers() + { + return this.whiteListedPlayers; + } + + public Set getOps() + { + return this.ops; + } + + public void loadWhiteList() {} + + public void updateTimeAndWeatherForPlayer(EntityPlayerMP par1EntityPlayerMP, WorldServer par2WorldServer) + { + par1EntityPlayerMP.playerNetServerHandler.sendPacket(new S03PacketTimeUpdate(par2WorldServer.getTotalWorldTime(), par2WorldServer.getWorldTime(), par2WorldServer.getGameRules().getGameRuleBooleanValue("doDaylightCycle"))); + + if (par2WorldServer.isRaining()) + { + par1EntityPlayerMP.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(1, 0.0F)); + par1EntityPlayerMP.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(7, par2WorldServer.getRainStrength(1.0F))); + par1EntityPlayerMP.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(8, par2WorldServer.getWeightedThunderStrength(1.0F))); + } + } + + public void syncPlayerInventory(EntityPlayerMP par1EntityPlayerMP) + { + par1EntityPlayerMP.sendContainerToPlayer(par1EntityPlayerMP.inventoryContainer); + par1EntityPlayerMP.setPlayerHealthUpdated(); + par1EntityPlayerMP.playerNetServerHandler.sendPacket(new S09PacketHeldItemChange(par1EntityPlayerMP.inventory.currentItem)); + } + + public int getCurrentPlayerCount() + { + return this.playerEntityList.size(); + } + + public int getMaxPlayers() + { + return this.maxPlayers; + } + + public String[] getAvailablePlayerDat() + { + return this.mcServer.worldServers[0].getSaveHandler().getSaveHandler().getAvailablePlayerDat(); + } + + public void setWhiteListEnabled(boolean par1) + { + this.whiteListEnforced = par1; + } + + public List getPlayerList(String par1Str) + { + ArrayList arraylist = new ArrayList(); + Iterator iterator = this.playerEntityList.iterator(); + + while (iterator.hasNext()) + { + EntityPlayerMP entityplayermp = (EntityPlayerMP)iterator.next(); + + if (entityplayermp.getPlayerIP().equals(par1Str)) + { + arraylist.add(entityplayermp); + } + } + + return arraylist; + } + + public int getViewDistance() + { + return this.viewDistance; + } + + public MinecraftServer getServerInstance() + { + return this.mcServer; + } + + public NBTTagCompound getHostPlayerData() + { + return null; + } + + @SideOnly(Side.CLIENT) + public void setGameType(WorldSettings.GameType par1EnumGameType) + { + this.gameType = par1EnumGameType; + } + + private void func_72381_a(EntityPlayerMP par1EntityPlayerMP, EntityPlayerMP par2EntityPlayerMP, World par3World) + { + if (par2EntityPlayerMP != null) + { + par1EntityPlayerMP.theItemInWorldManager.setGameType(par2EntityPlayerMP.theItemInWorldManager.getGameType()); + } + else if (this.gameType != null) + { + par1EntityPlayerMP.theItemInWorldManager.setGameType(this.gameType); + } + + par1EntityPlayerMP.theItemInWorldManager.initializeGameType(par3World.getWorldInfo().getGameType()); + } + + @SideOnly(Side.CLIENT) + public void setCommandsAllowedForAll(boolean par1) + { + this.commandsAllowedForAll = par1; + } + + public void removeAllPlayers() + { + for (int i = 0; i < this.playerEntityList.size(); ++i) + { + ((EntityPlayerMP)this.playerEntityList.get(i)).playerNetServerHandler.kickPlayerFromServer("Server closed"); + } + } + + public void sendChatMsgImpl(IChatComponent p_148544_1_, boolean p_148544_2_) + { + this.mcServer.addChatMessage(p_148544_1_); + this.sendPacketToAllPlayers(new S02PacketChat(p_148544_1_, p_148544_2_)); + } + + public void sendChatMsg(IChatComponent p_148539_1_) + { + this.sendChatMsgImpl(p_148539_1_, true); + } + + public StatisticsFile func_148538_i(String p_148538_1_) + { + StatisticsFile statisticsfile = (StatisticsFile)this.field_148547_k.get(p_148538_1_); + + if (statisticsfile == null) + { + statisticsfile = new StatisticsFile(this.mcServer, new File(this.mcServer.worldServerForDimension(0).getSaveHandler().getWorldDirectory(), "stats/" + p_148538_1_ + ".json")); + statisticsfile.func_150882_a(); + this.field_148547_k.put(p_148538_1_, statisticsfile); + } + + return statisticsfile; + } + + @SideOnly(Side.SERVER) + public boolean isWhiteListEnabled() + { + return this.whiteListEnforced; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/server/network/NetHandlerHandshakeTCP.java b/src/main/java/net/minecraft/server/network/NetHandlerHandshakeTCP.java new file mode 100644 index 0000000..82cc15c --- /dev/null +++ b/src/main/java/net/minecraft/server/network/NetHandlerHandshakeTCP.java @@ -0,0 +1,107 @@ +package net.minecraft.server.network; + +import cpw.mods.fml.common.FMLCommonHandler; +import io.netty.util.concurrent.GenericFutureListener; +import net.minecraft.network.EnumConnectionState; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.handshake.INetHandlerHandshakeServer; +import net.minecraft.network.handshake.client.C00Handshake; +import net.minecraft.network.login.server.S00PacketDisconnect; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.IChatComponent; + +public class NetHandlerHandshakeTCP implements INetHandlerHandshakeServer +{ + private final MinecraftServer field_147387_a; + private final NetworkManager field_147386_b; + private static final String __OBFID = "CL_00001456"; + + public NetHandlerHandshakeTCP(MinecraftServer p_i45295_1_, NetworkManager p_i45295_2_) + { + this.field_147387_a = p_i45295_1_; + this.field_147386_b = p_i45295_2_; + } + + public void processHandshake(C00Handshake p_147383_1_) + { + if (!FMLCommonHandler.instance().shouldAllowPlayerLogins()) + { + ChatComponentText chatcomponenttext = new ChatComponentText("Server is still starting! Please wait before reconnecting."); + this.field_147386_b.scheduleOutboundPacket(new S00PacketDisconnect(chatcomponenttext), new GenericFutureListener[0]); + this.field_147386_b.closeChannel(chatcomponenttext); + return; + } + + switch (NetHandlerHandshakeTCP.SwitchEnumConnectionState.field_151291_a[p_147383_1_.func_149594_c().ordinal()]) + { + case 1: + this.field_147386_b.setConnectionState(EnumConnectionState.LOGIN); + ChatComponentText chatcomponenttext; + + if (p_147383_1_.func_149595_d() > 4) + { + chatcomponenttext = new ChatComponentText("Outdated server! I\'m still on 1.7.2"); + this.field_147386_b.scheduleOutboundPacket(new S00PacketDisconnect(chatcomponenttext), new GenericFutureListener[0]); + this.field_147386_b.closeChannel(chatcomponenttext); + } + else if (p_147383_1_.func_149595_d() < 4) + { + chatcomponenttext = new ChatComponentText("Outdated client! Please use 1.7.2"); + this.field_147386_b.scheduleOutboundPacket(new S00PacketDisconnect(chatcomponenttext), new GenericFutureListener[0]); + this.field_147386_b.closeChannel(chatcomponenttext); + } + else + { + this.field_147386_b.setNetHandler(new NetHandlerLoginServer(this.field_147387_a, this.field_147386_b)); + } + + break; + case 2: + this.field_147386_b.setConnectionState(EnumConnectionState.STATUS); + this.field_147386_b.setNetHandler(new NetHandlerStatusServer(this.field_147387_a, this.field_147386_b)); + break; + default: + throw new UnsupportedOperationException("Invalid intention " + p_147383_1_.func_149594_c()); + } + } + + public void onDisconnect(IChatComponent p_147231_1_) {} + + public void onConnectionStateTransition(EnumConnectionState p_147232_1_, EnumConnectionState p_147232_2_) + { + if (p_147232_2_ != EnumConnectionState.LOGIN && p_147232_2_ != EnumConnectionState.STATUS) + { + throw new UnsupportedOperationException("Invalid state " + p_147232_2_); + } + } + + public void onNetworkTick() {} + + static final class SwitchEnumConnectionState + { + static final int[] field_151291_a = new int[EnumConnectionState.values().length]; + private static final String __OBFID = "CL_00001457"; + + static + { + try + { + field_151291_a[EnumConnectionState.LOGIN.ordinal()] = 1; + } + catch (NoSuchFieldError var2) + { + ; + } + + try + { + field_151291_a[EnumConnectionState.STATUS.ordinal()] = 2; + } + catch (NoSuchFieldError var1) + { + ; + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/server/network/NetHandlerLoginServer.java b/src/main/java/net/minecraft/server/network/NetHandlerLoginServer.java new file mode 100644 index 0000000..2620a8a --- /dev/null +++ b/src/main/java/net/minecraft/server/network/NetHandlerLoginServer.java @@ -0,0 +1,193 @@ +package net.minecraft.server.network; + +import com.google.common.base.Charsets; +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.exceptions.AuthenticationUnavailableException; + +import cpw.mods.fml.common.network.internal.FMLNetworkHandler; +import io.netty.util.concurrent.GenericFutureListener; +import java.math.BigInteger; +import java.security.PrivateKey; +import java.util.Arrays; +import java.util.Random; +import java.util.UUID; +import java.util.concurrent.atomic.AtomicInteger; +import javax.crypto.SecretKey; +import net.minecraft.network.EnumConnectionState; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.login.INetHandlerLoginServer; +import net.minecraft.network.login.client.C00PacketLoginStart; +import net.minecraft.network.login.client.C01PacketEncryptionResponse; +import net.minecraft.network.login.server.S00PacketDisconnect; +import net.minecraft.network.login.server.S01PacketEncryptionRequest; +import net.minecraft.network.login.server.S02PacketLoginSuccess; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.CryptManager; +import net.minecraft.util.IChatComponent; +import org.apache.commons.lang3.Validate; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class NetHandlerLoginServer implements INetHandlerLoginServer +{ + private static final AtomicInteger field_147331_b = new AtomicInteger(0); + private static final Logger logger = LogManager.getLogger(); + private static final Random field_147329_d = new Random(); + private final byte[] field_147330_e = new byte[4]; + private final MinecraftServer field_147327_f; + public final NetworkManager field_147333_a; + private NetHandlerLoginServer.LoginState field_147328_g; + private int field_147336_h; + private GameProfile field_147337_i; + private String field_147334_j; + private SecretKey field_147335_k; + private static final String __OBFID = "CL_00001458"; + + public NetHandlerLoginServer(MinecraftServer p_i45298_1_, NetworkManager p_i45298_2_) + { + this.field_147328_g = NetHandlerLoginServer.LoginState.HELLO; + this.field_147334_j = ""; + this.field_147327_f = p_i45298_1_; + this.field_147333_a = p_i45298_2_; + field_147329_d.nextBytes(this.field_147330_e); + } + + public void onNetworkTick() + { + if (this.field_147328_g == NetHandlerLoginServer.LoginState.READY_TO_ACCEPT) + { + this.func_147326_c(); + } + + if (this.field_147336_h++ == FMLNetworkHandler.LOGIN_TIMEOUT) + { + this.func_147322_a("Took too long to log in"); + } + } + + public void func_147322_a(String p_147322_1_) + { + try + { + logger.info("Disconnecting " + this.func_147317_d() + ": " + p_147322_1_); + ChatComponentText chatcomponenttext = new ChatComponentText(p_147322_1_); + this.field_147333_a.scheduleOutboundPacket(new S00PacketDisconnect(chatcomponenttext), new GenericFutureListener[0]); + this.field_147333_a.closeChannel(chatcomponenttext); + } + catch (Exception exception) + { + logger.error("Error whilst disconnecting player", exception); + } + } + + public void func_147326_c() + { + if (!this.field_147337_i.isComplete()) + { + UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + this.field_147337_i.getName()).getBytes(Charsets.UTF_8)); + this.field_147337_i = new GameProfile(uuid.toString().replaceAll("-", ""), this.field_147337_i.getName()); + } + + String s = this.field_147327_f.getConfigurationManager().allowUserToConnect(this.field_147333_a.getSocketAddress(), this.field_147337_i); + + if (s != null) + { + this.func_147322_a(s); + } + else + { + this.field_147328_g = NetHandlerLoginServer.LoginState.ACCEPTED; + this.field_147333_a.scheduleOutboundPacket(new S02PacketLoginSuccess(this.field_147337_i), new GenericFutureListener[0]); + FMLNetworkHandler.fmlServerHandshake(this.field_147327_f.getConfigurationManager(), this.field_147333_a, this.field_147327_f.getConfigurationManager().createPlayerForUser(this.field_147337_i)); + } + } + + public void onDisconnect(IChatComponent p_147231_1_) + { + logger.info(this.func_147317_d() + " lost connection: " + p_147231_1_.getUnformattedText()); + } + + public String func_147317_d() + { + return this.field_147337_i != null ? this.field_147337_i.toString() + " (" + this.field_147333_a.getSocketAddress().toString() + ")" : String.valueOf(this.field_147333_a.getSocketAddress()); + } + + public void onConnectionStateTransition(EnumConnectionState p_147232_1_, EnumConnectionState p_147232_2_) + { + Validate.validState(this.field_147328_g == NetHandlerLoginServer.LoginState.ACCEPTED || this.field_147328_g == NetHandlerLoginServer.LoginState.HELLO, "Unexpected change in protocol", new Object[0]); + Validate.validState(p_147232_2_ == EnumConnectionState.PLAY || p_147232_2_ == EnumConnectionState.LOGIN, "Unexpected protocol " + p_147232_2_, new Object[0]); + } + + public void processLoginStart(C00PacketLoginStart p_147316_1_) + { + Validate.validState(this.field_147328_g == NetHandlerLoginServer.LoginState.HELLO, "Unexpected hello packet", new Object[0]); + this.field_147337_i = p_147316_1_.func_149304_c(); + + if (this.field_147327_f.isServerInOnlineMode() && !this.field_147333_a.isLocalChannel()) + { + this.field_147328_g = NetHandlerLoginServer.LoginState.KEY; + this.field_147333_a.scheduleOutboundPacket(new S01PacketEncryptionRequest(this.field_147334_j, this.field_147327_f.getKeyPair().getPublic(), this.field_147330_e), new GenericFutureListener[0]); + } + else + { + this.field_147328_g = NetHandlerLoginServer.LoginState.READY_TO_ACCEPT; + } + } + + public void processEncryptionResponse(C01PacketEncryptionResponse p_147315_1_) + { + Validate.validState(this.field_147328_g == NetHandlerLoginServer.LoginState.KEY, "Unexpected key packet", new Object[0]); + PrivateKey privatekey = this.field_147327_f.getKeyPair().getPrivate(); + + if (!Arrays.equals(this.field_147330_e, p_147315_1_.func_149299_b(privatekey))) + { + throw new IllegalStateException("Invalid nonce!"); + } + else + { + this.field_147335_k = p_147315_1_.func_149300_a(privatekey); + this.field_147328_g = NetHandlerLoginServer.LoginState.AUTHENTICATING; + this.field_147333_a.enableEncryption(this.field_147335_k); + (new Thread("User Authenticator #" + field_147331_b.incrementAndGet()) + { + private static final String __OBFID = "CL_00001459"; + public void run() + { + try + { + String s = (new BigInteger(CryptManager.getServerIdHash(NetHandlerLoginServer.this.field_147334_j, NetHandlerLoginServer.this.field_147327_f.getKeyPair().getPublic(), NetHandlerLoginServer.this.field_147335_k))).toString(16); + NetHandlerLoginServer.this.field_147337_i = NetHandlerLoginServer.this.field_147327_f.func_147130_as().hasJoinedServer(new GameProfile((String)null, NetHandlerLoginServer.this.field_147337_i.getName()), s); + + if (NetHandlerLoginServer.this.field_147337_i != null) + { + NetHandlerLoginServer.logger.info("UUID of player " + NetHandlerLoginServer.this.field_147337_i.getName() + " is " + NetHandlerLoginServer.this.field_147337_i.getId()); + NetHandlerLoginServer.this.field_147328_g = NetHandlerLoginServer.LoginState.READY_TO_ACCEPT; + } + else + { + NetHandlerLoginServer.this.func_147322_a("Failed to verify username!"); + NetHandlerLoginServer.logger.error("Username \'" + NetHandlerLoginServer.this.field_147337_i.getName() + "\' tried to join with an invalid session"); + } + } + catch (AuthenticationUnavailableException authenticationunavailableexception) + { + NetHandlerLoginServer.this.func_147322_a("Authentication servers are down. Please try again later, sorry!"); + NetHandlerLoginServer.logger.error("Couldn\'t verify username because servers are unavailable"); + } + } + }).start(); + } + } + + static enum LoginState + { + HELLO, + KEY, + AUTHENTICATING, + READY_TO_ACCEPT, + ACCEPTED; + + private static final String __OBFID = "CL_00001463"; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/server/network/NetHandlerStatusServer.java b/src/main/java/net/minecraft/server/network/NetHandlerStatusServer.java new file mode 100644 index 0000000..e3195f4 --- /dev/null +++ b/src/main/java/net/minecraft/server/network/NetHandlerStatusServer.java @@ -0,0 +1,47 @@ +package net.minecraft.server.network; + +import io.netty.util.concurrent.GenericFutureListener; +import net.minecraft.network.EnumConnectionState; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.status.INetHandlerStatusServer; +import net.minecraft.network.status.client.C00PacketServerQuery; +import net.minecraft.network.status.client.C01PacketPing; +import net.minecraft.network.status.server.S00PacketServerInfo; +import net.minecraft.network.status.server.S01PacketPong; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.IChatComponent; + +public class NetHandlerStatusServer implements INetHandlerStatusServer +{ + private final MinecraftServer field_147314_a; + private final NetworkManager field_147313_b; + private static final String __OBFID = "CL_00001464"; + + public NetHandlerStatusServer(MinecraftServer p_i45299_1_, NetworkManager p_i45299_2_) + { + this.field_147314_a = p_i45299_1_; + this.field_147313_b = p_i45299_2_; + } + + public void onDisconnect(IChatComponent p_147231_1_) {} + + public void onConnectionStateTransition(EnumConnectionState p_147232_1_, EnumConnectionState p_147232_2_) + { + if (p_147232_2_ != EnumConnectionState.STATUS) + { + throw new UnsupportedOperationException("Unexpected change in protocol to " + p_147232_2_); + } + } + + public void onNetworkTick() {} + + public void processServerQuery(C00PacketServerQuery p_147312_1_) + { + this.field_147313_b.scheduleOutboundPacket(new S00PacketServerInfo(this.field_147314_a.func_147134_at()), new GenericFutureListener[0]); + } + + public void processPing(C01PacketPing p_147311_1_) + { + this.field_147313_b.scheduleOutboundPacket(new S01PacketPong(p_147311_1_.func_149289_c()), new GenericFutureListener[0]); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/src/FMLRenderAccessLibrary.java b/src/main/java/net/minecraft/src/FMLRenderAccessLibrary.java new file mode 100644 index 0000000..6e6c96c --- /dev/null +++ b/src/main/java/net/minecraft/src/FMLRenderAccessLibrary.java @@ -0,0 +1,72 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package net.minecraft.src; + +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.world.IBlockAccess; +import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.common.FMLLog; + +/** + * + * A static hook library for optifine and other basemod editing code to access FML functions + * + * @author cpw + * + */ +public class FMLRenderAccessLibrary +{ + public static Logger getLogger() + { + Logger l = LogManager.getLogger("FMLRenderAccessLibrary"); + return l; + } + + public static void log(Level level, String message) + { + FMLLog.log("FMLRenderAccessLibrary", level, message); + } + + public static void log(Level level, String message, Throwable throwable) + { + FMLLog.log(level, throwable, message); + } + + @SuppressWarnings("deprecation") + public static boolean renderWorldBlock(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, Block block, int modelId) + { + return RenderingRegistry.instance().renderWorldBlock(renderer, world, x, y, z, block, modelId); + } + + @SuppressWarnings("deprecation") + public static void renderInventoryBlock(RenderBlocks renderer, Block block, int metadata, int modelID) + { + RenderingRegistry.instance().renderInventoryBlock(renderer, block, metadata, modelID); + } + + @SuppressWarnings("deprecation") + public static boolean renderItemAsFull3DBlock(int modelId) + { + return RenderingRegistry.instance().renderItemAsFull3DBlock(modelId); + } + +// public static void doTextureCopy(Texture atlas, Texture source, int targetX, int targetY) +// { +// TextureFXManager.instance().getHelper().doTextureCopy(atlas, source, targetX, targetY); +// } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/stats/Achievement.java b/src/main/java/net/minecraft/stats/Achievement.java new file mode 100644 index 0000000..ae4d9ee --- /dev/null +++ b/src/main/java/net/minecraft/stats/Achievement.java @@ -0,0 +1,119 @@ +package net.minecraft.stats; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IChatComponent; +import net.minecraft.util.StatCollector; + +public class Achievement extends StatBase +{ + public final int displayColumn; + public final int displayRow; + public final Achievement parentAchievement; + private final String achievementDescription; + @SideOnly(Side.CLIENT) + private IStatStringFormat statStringFormatter; + public final ItemStack theItemStack; + private boolean isSpecial; + private static final String __OBFID = "CL_00001466"; + + public Achievement(String p_i45300_1_, String p_i45300_2_, int p_i45300_3_, int p_i45300_4_, Item p_i45300_5_, Achievement p_i45300_6_) + { + this(p_i45300_1_, p_i45300_2_, p_i45300_3_, p_i45300_4_, new ItemStack(p_i45300_5_), p_i45300_6_); + } + + public Achievement(String p_i45301_1_, String p_i45301_2_, int p_i45301_3_, int p_i45301_4_, Block p_i45301_5_, Achievement p_i45301_6_) + { + this(p_i45301_1_, p_i45301_2_, p_i45301_3_, p_i45301_4_, new ItemStack(p_i45301_5_), p_i45301_6_); + } + + public Achievement(String p_i45302_1_, String p_i45302_2_, int p_i45302_3_, int p_i45302_4_, ItemStack p_i45302_5_, Achievement p_i45302_6_) + { + super(p_i45302_1_, new ChatComponentTranslation("achievement." + p_i45302_2_, new Object[0])); + this.theItemStack = p_i45302_5_; + this.achievementDescription = "achievement." + p_i45302_2_ + ".desc"; + this.displayColumn = p_i45302_3_; + this.displayRow = p_i45302_4_; + + if (p_i45302_3_ < AchievementList.minDisplayColumn) + { + AchievementList.minDisplayColumn = p_i45302_3_; + } + + if (p_i45302_4_ < AchievementList.minDisplayRow) + { + AchievementList.minDisplayRow = p_i45302_4_; + } + + if (p_i45302_3_ > AchievementList.maxDisplayColumn) + { + AchievementList.maxDisplayColumn = p_i45302_3_; + } + + if (p_i45302_4_ > AchievementList.maxDisplayRow) + { + AchievementList.maxDisplayRow = p_i45302_4_; + } + + this.parentAchievement = p_i45302_6_; + } + + public Achievement initIndependentStat() + { + this.isIndependent = true; + return this; + } + + public Achievement setSpecial() + { + this.isSpecial = true; + return this; + } + + public Achievement registerStat() + { + super.registerStat(); + AchievementList.achievementList.add(this); + return this; + } + + public boolean isAchievement() + { + return true; + } + + public IChatComponent func_150951_e() + { + IChatComponent ichatcomponent = super.func_150951_e(); + ichatcomponent.getChatStyle().setColor(this.getSpecial() ? EnumChatFormatting.DARK_PURPLE : EnumChatFormatting.GREEN); + return ichatcomponent; + } + + public Achievement func_150953_b(Class p_150958_1_) + { + return (Achievement)super.func_150953_b(p_150958_1_); + } + + @SideOnly(Side.CLIENT) + public String getDescription() + { + return this.statStringFormatter != null ? this.statStringFormatter.formatString(StatCollector.translateToLocal(this.achievementDescription)) : StatCollector.translateToLocal(this.achievementDescription); + } + + @SideOnly(Side.CLIENT) + public Achievement setStatStringFormatter(IStatStringFormat par1IStatStringFormat) + { + this.statStringFormatter = par1IStatStringFormat; + return this; + } + + public boolean getSpecial() + { + return this.isSpecial; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/stats/AchievementList.java b/src/main/java/net/minecraft/stats/AchievementList.java new file mode 100644 index 0000000..03074ee --- /dev/null +++ b/src/main/java/net/minecraft/stats/AchievementList.java @@ -0,0 +1,53 @@ +package net.minecraft.stats; + +import java.util.ArrayList; +import java.util.List; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.util.JsonSerializableSet; + +public class AchievementList +{ + public static int minDisplayColumn; + public static int minDisplayRow; + public static int maxDisplayColumn; + public static int maxDisplayRow; + public static List achievementList = new ArrayList(); + public static Achievement openInventory = (new Achievement("achievement.openInventory", "openInventory", 0, 0, Items.book, (Achievement)null)).initIndependentStat().registerStat(); + public static Achievement mineWood = (new Achievement("achievement.mineWood", "mineWood", 2, 1, Blocks.log, openInventory)).registerStat(); + public static Achievement buildWorkBench = (new Achievement("achievement.buildWorkBench", "buildWorkBench", 4, -1, Blocks.crafting_table, mineWood)).registerStat(); + public static Achievement buildPickaxe = (new Achievement("achievement.buildPickaxe", "buildPickaxe", 4, 2, Items.wooden_pickaxe, buildWorkBench)).registerStat(); + public static Achievement buildFurnace = (new Achievement("achievement.buildFurnace", "buildFurnace", 3, 4, Blocks.furnace, buildPickaxe)).registerStat(); + public static Achievement acquireIron = (new Achievement("achievement.acquireIron", "acquireIron", 1, 4, Items.iron_ingot, buildFurnace)).registerStat(); + public static Achievement buildHoe = (new Achievement("achievement.buildHoe", "buildHoe", 2, -3, Items.wooden_hoe, buildWorkBench)).registerStat(); + public static Achievement makeBread = (new Achievement("achievement.makeBread", "makeBread", -1, -3, Items.bread, buildHoe)).registerStat(); + public static Achievement bakeCake = (new Achievement("achievement.bakeCake", "bakeCake", 0, -5, Items.cake, buildHoe)).registerStat(); + public static Achievement buildBetterPickaxe = (new Achievement("achievement.buildBetterPickaxe", "buildBetterPickaxe", 6, 2, Items.stone_pickaxe, buildPickaxe)).registerStat(); + public static Achievement cookFish = (new Achievement("achievement.cookFish", "cookFish", 2, 6, Items.cooked_fished, buildFurnace)).registerStat(); + public static Achievement onARail = (new Achievement("achievement.onARail", "onARail", 2, 3, Blocks.rail, acquireIron)).setSpecial().registerStat(); + public static Achievement buildSword = (new Achievement("achievement.buildSword", "buildSword", 6, -1, Items.wooden_sword, buildWorkBench)).registerStat(); + public static Achievement killEnemy = (new Achievement("achievement.killEnemy", "killEnemy", 8, -1, Items.bone, buildSword)).registerStat(); + public static Achievement killCow = (new Achievement("achievement.killCow", "killCow", 7, -3, Items.leather, buildSword)).registerStat(); + public static Achievement flyPig = (new Achievement("achievement.flyPig", "flyPig", 9, -3, Items.saddle, killCow)).setSpecial().registerStat(); + public static Achievement snipeSkeleton = (new Achievement("achievement.snipeSkeleton", "snipeSkeleton", 7, 0, Items.bow, killEnemy)).setSpecial().registerStat(); + public static Achievement diamonds = (new Achievement("achievement.diamonds", "diamonds", -1, 5, Blocks.diamond_ore, acquireIron)).registerStat(); + public static Achievement field_150966_x = (new Achievement("achievement.diamondsToYou", "diamondsToYou", -1, 2, Items.diamond, diamonds)).registerStat(); + public static Achievement portal = (new Achievement("achievement.portal", "portal", -1, 7, Blocks.obsidian, diamonds)).registerStat(); + public static Achievement ghast = (new Achievement("achievement.ghast", "ghast", -4, 8, Items.ghast_tear, portal)).setSpecial().registerStat(); + public static Achievement blazeRod = (new Achievement("achievement.blazeRod", "blazeRod", 0, 9, Items.blaze_rod, portal)).registerStat(); + public static Achievement potion = (new Achievement("achievement.potion", "potion", 2, 8, Items.potionitem, blazeRod)).registerStat(); + public static Achievement theEnd = (new Achievement("achievement.theEnd", "theEnd", 3, 10, Items.ender_eye, blazeRod)).setSpecial().registerStat(); + public static Achievement theEnd2 = (new Achievement("achievement.theEnd2", "theEnd2", 4, 13, Blocks.dragon_egg, theEnd)).setSpecial().registerStat(); + public static Achievement enchantments = (new Achievement("achievement.enchantments", "enchantments", -4, 4, Blocks.enchanting_table, diamonds)).registerStat(); + public static Achievement overkill = (new Achievement("achievement.overkill", "overkill", -4, 1, Items.diamond_sword, enchantments)).setSpecial().registerStat(); + public static Achievement bookcase = (new Achievement("achievement.bookcase", "bookcase", -3, 6, Blocks.bookshelf, enchantments)).registerStat(); + public static Achievement field_150962_H = (new Achievement("achievement.breedCow", "breedCow", 7, -5, Items.wheat, killCow)).registerStat(); + public static Achievement field_150963_I = (new Achievement("achievement.spawnWither", "spawnWither", 7, 12, new ItemStack(Items.skull, 1, 1), theEnd2)).registerStat(); + public static Achievement field_150964_J = (new Achievement("achievement.killWither", "killWither", 7, 10, Items.nether_star, field_150963_I)).registerStat(); + public static Achievement field_150965_K = (new Achievement("achievement.fullBeacon", "fullBeacon", 7, 8, Blocks.beacon, field_150964_J)).setSpecial().registerStat(); + public static Achievement field_150961_L = (new Achievement("achievement.exploreAllBiomes", "exploreAllBiomes", 4, 8, Items.diamond_boots, theEnd)).func_150953_b(JsonSerializableSet.class).setSpecial().registerStat(); + private static final String __OBFID = "CL_00001467"; + + public static void init() {} +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/stats/IStatStringFormat.java b/src/main/java/net/minecraft/stats/IStatStringFormat.java new file mode 100644 index 0000000..f11b5a0 --- /dev/null +++ b/src/main/java/net/minecraft/stats/IStatStringFormat.java @@ -0,0 +1,10 @@ +package net.minecraft.stats; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public interface IStatStringFormat +{ + String formatString(String var1); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/stats/IStatType.java b/src/main/java/net/minecraft/stats/IStatType.java new file mode 100644 index 0000000..eb52a84 --- /dev/null +++ b/src/main/java/net/minecraft/stats/IStatType.java @@ -0,0 +1,10 @@ +package net.minecraft.stats; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public interface IStatType +{ + @SideOnly(Side.CLIENT) + String format(int var1); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/stats/ObjectiveStat.java b/src/main/java/net/minecraft/stats/ObjectiveStat.java new file mode 100644 index 0000000..c1942b9 --- /dev/null +++ b/src/main/java/net/minecraft/stats/ObjectiveStat.java @@ -0,0 +1,15 @@ +package net.minecraft.stats; + +import net.minecraft.scoreboard.ScoreDummyCriteria; + +public class ObjectiveStat extends ScoreDummyCriteria +{ + private final StatBase field_151459_g; + private static final String __OBFID = "CL_00000625"; + + public ObjectiveStat(StatBase p_i45483_1_) + { + super(p_i45483_1_.statId); + this.field_151459_g = p_i45483_1_; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/stats/StatBase.java b/src/main/java/net/minecraft/stats/StatBase.java new file mode 100644 index 0000000..62a082c --- /dev/null +++ b/src/main/java/net/minecraft/stats/StatBase.java @@ -0,0 +1,172 @@ +package net.minecraft.stats; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.text.DecimalFormat; +import java.text.NumberFormat; +import java.util.Locale; +import net.minecraft.event.HoverEvent; +import net.minecraft.scoreboard.IScoreObjectiveCriteria; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IChatComponent; + +public class StatBase +{ + public final String statId; + private final IChatComponent statName; + public boolean isIndependent; + private final IStatType type; + private final IScoreObjectiveCriteria field_150957_c; + private Class field_150956_d; + private static NumberFormat numberFormat = NumberFormat.getIntegerInstance(Locale.US); + public static IStatType simpleStatType = new IStatType() + { + private static final String __OBFID = "CL_00001473"; + @SideOnly(Side.CLIENT) + public String format(int par1) + { + return StatBase.numberFormat.format((long)par1); + } + }; + private static DecimalFormat decimalFormat = new DecimalFormat("########0.00"); + public static IStatType timeStatType = new IStatType() + { + private static final String __OBFID = "CL_00001474"; + @SideOnly(Side.CLIENT) + public String format(int par1) + { + double d0 = (double)par1 / 20.0D; + double d1 = d0 / 60.0D; + double d2 = d1 / 60.0D; + double d3 = d2 / 24.0D; + double d4 = d3 / 365.0D; + return d4 > 0.5D ? StatBase.decimalFormat.format(d4) + " y" : (d3 > 0.5D ? StatBase.decimalFormat.format(d3) + " d" : (d2 > 0.5D ? StatBase.decimalFormat.format(d2) + " h" : (d1 > 0.5D ? StatBase.decimalFormat.format(d1) + " m" : d0 + " s"))); + } + }; + public static IStatType distanceStatType = new IStatType() + { + private static final String __OBFID = "CL_00001475"; + @SideOnly(Side.CLIENT) + public String format(int par1) + { + double d0 = (double)par1 / 100.0D; + double d1 = d0 / 1000.0D; + return d1 > 0.5D ? StatBase.decimalFormat.format(d1) + " km" : (d0 > 0.5D ? StatBase.decimalFormat.format(d0) + " m" : par1 + " cm"); + } + }; + public static IStatType field_111202_k = new IStatType() + { + private static final String __OBFID = "CL_00001476"; + @SideOnly(Side.CLIENT) + public String format(int par1) + { + return StatBase.decimalFormat.format((double)par1 * 0.1D); + } + }; + private static final String __OBFID = "CL_00001472"; + + public StatBase(String p_i45307_1_, IChatComponent p_i45307_2_, IStatType p_i45307_3_) + { + this.statId = p_i45307_1_; + this.statName = p_i45307_2_; + this.type = p_i45307_3_; + this.field_150957_c = new ObjectiveStat(this); + IScoreObjectiveCriteria.field_96643_a.put(this.field_150957_c.func_96636_a(), this.field_150957_c); + } + + public StatBase(String p_i45308_1_, IChatComponent p_i45308_2_) + { + this(p_i45308_1_, p_i45308_2_, simpleStatType); + } + + public StatBase initIndependentStat() + { + this.isIndependent = true; + return this; + } + + public StatBase registerStat() + { + if (StatList.oneShotStats.containsKey(this.statId)) + { + throw new RuntimeException("Duplicate stat id: \"" + ((StatBase)StatList.oneShotStats.get(this.statId)).statName + "\" and \"" + this.statName + "\" at id " + this.statId); + } + else + { + StatList.allStats.add(this); + StatList.oneShotStats.put(this.statId, this); + return this; + } + } + + public boolean isAchievement() + { + return false; + } + + @SideOnly(Side.CLIENT) + public String func_75968_a(int par1) + { + return this.type.format(par1); + } + + public IChatComponent func_150951_e() + { + IChatComponent ichatcomponent = this.statName.createCopy(); + ichatcomponent.getChatStyle().setColor(EnumChatFormatting.GRAY); + ichatcomponent.getChatStyle().setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_ACHIEVEMENT, new ChatComponentText(this.statId))); + return ichatcomponent; + } + + public IChatComponent func_150955_j() + { + IChatComponent ichatcomponent = this.func_150951_e(); + IChatComponent ichatcomponent1 = (new ChatComponentText("[")).appendSibling(ichatcomponent).appendText("]"); + ichatcomponent1.setChatStyle(ichatcomponent.getChatStyle()); + return ichatcomponent1; + } + + public boolean equals(Object par1Obj) + { + if (this == par1Obj) + { + return true; + } + else if (par1Obj != null && this.getClass() == par1Obj.getClass()) + { + StatBase statbase = (StatBase)par1Obj; + return this.statId.equals(statbase.statId); + } + else + { + return false; + } + } + + public int hashCode() + { + return this.statId.hashCode(); + } + + public String toString() + { + return "Stat{id=" + this.statId + ", nameId=" + this.statName + ", awardLocallyOnly=" + this.isIndependent + ", formatter=" + this.type + ", objectiveCriteria=" + this.field_150957_c + '}'; + } + + public IScoreObjectiveCriteria func_150952_k() + { + return this.field_150957_c; + } + + public Class func_150954_l() + { + return this.field_150956_d; + } + + public StatBase func_150953_b(Class p_150953_1_) + { + this.field_150956_d = p_150953_1_; + return this; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/stats/StatBasic.java b/src/main/java/net/minecraft/stats/StatBasic.java new file mode 100644 index 0000000..aa71a74 --- /dev/null +++ b/src/main/java/net/minecraft/stats/StatBasic.java @@ -0,0 +1,25 @@ +package net.minecraft.stats; + +import net.minecraft.util.IChatComponent; + +public class StatBasic extends StatBase +{ + private static final String __OBFID = "CL_00001469"; + + public StatBasic(String p_i45303_1_, IChatComponent p_i45303_2_, IStatType p_i45303_3_) + { + super(p_i45303_1_, p_i45303_2_, p_i45303_3_); + } + + public StatBasic(String p_i45304_1_, IChatComponent p_i45304_2_) + { + super(p_i45304_1_, p_i45304_2_); + } + + public StatBase registerStat() + { + super.registerStat(); + StatList.generalStats.add(this); + return this; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/stats/StatCrafting.java b/src/main/java/net/minecraft/stats/StatCrafting.java new file mode 100644 index 0000000..a0f03ee --- /dev/null +++ b/src/main/java/net/minecraft/stats/StatCrafting.java @@ -0,0 +1,24 @@ +package net.minecraft.stats; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.item.Item; +import net.minecraft.util.IChatComponent; + +public class StatCrafting extends StatBase +{ + private final Item field_150960_a; + private static final String __OBFID = "CL_00001470"; + + public StatCrafting(String p_i45305_1_, IChatComponent p_i45305_2_, Item p_i45305_3_) + { + super(p_i45305_1_, p_i45305_2_); + this.field_150960_a = p_i45305_3_; + } + + @SideOnly(Side.CLIENT) + public Item func_150959_a() + { + return this.field_150960_a; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/stats/StatFileWriter.java b/src/main/java/net/minecraft/stats/StatFileWriter.java new file mode 100644 index 0000000..a498651 --- /dev/null +++ b/src/main/java/net/minecraft/stats/StatFileWriter.java @@ -0,0 +1,92 @@ +package net.minecraft.stats; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.HashMap; +import java.util.Map; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.IJsonSerializable; +import net.minecraft.util.TupleIntJsonSerializable; + +public class StatFileWriter +{ + protected final Map field_150875_a = new HashMap(); + private static final String __OBFID = "CL_00001481"; + + public boolean hasAchievementUnlocked(Achievement par1Achievement) + { + return this.writeStat(par1Achievement) > 0; + } + + public boolean canUnlockAchievement(Achievement par1Achievement) + { + return par1Achievement.parentAchievement == null || this.hasAchievementUnlocked(par1Achievement.parentAchievement); + } + + public void func_150871_b(EntityPlayer p_150871_1_, StatBase p_150871_2_, int p_150871_3_) + { + if (!p_150871_2_.isAchievement() || this.canUnlockAchievement((Achievement)p_150871_2_)) + { + this.func_150873_a(p_150871_1_, p_150871_2_, this.writeStat(p_150871_2_) + p_150871_3_); + } + } + + @SideOnly(Side.CLIENT) + public int func_150874_c(Achievement p_150874_1_) + { + if (this.hasAchievementUnlocked(p_150874_1_)) + { + return 0; + } + else + { + int i = 0; + + for (Achievement achievement1 = p_150874_1_.parentAchievement; achievement1 != null && !this.hasAchievementUnlocked(achievement1); ++i) + { + achievement1 = achievement1.parentAchievement; + } + + return i; + } + } + + public void func_150873_a(EntityPlayer p_150873_1_, StatBase p_150873_2_, int p_150873_3_) + { + TupleIntJsonSerializable tupleintjsonserializable = (TupleIntJsonSerializable)this.field_150875_a.get(p_150873_2_); + + if (tupleintjsonserializable == null) + { + tupleintjsonserializable = new TupleIntJsonSerializable(); + this.field_150875_a.put(p_150873_2_, tupleintjsonserializable); + } + + tupleintjsonserializable.setIntegerValue(p_150873_3_); + } + + public int writeStat(StatBase par1StatBase) + { + TupleIntJsonSerializable tupleintjsonserializable = (TupleIntJsonSerializable)this.field_150875_a.get(par1StatBase); + return tupleintjsonserializable == null ? 0 : tupleintjsonserializable.getIntegerValue(); + } + + public IJsonSerializable func_150870_b(StatBase p_150870_1_) + { + TupleIntJsonSerializable tupleintjsonserializable = (TupleIntJsonSerializable)this.field_150875_a.get(p_150870_1_); + return tupleintjsonserializable != null ? tupleintjsonserializable.getJsonSerializableValue() : null; + } + + public IJsonSerializable func_150872_a(StatBase p_150872_1_, IJsonSerializable p_150872_2_) + { + TupleIntJsonSerializable tupleintjsonserializable = (TupleIntJsonSerializable)this.field_150875_a.get(p_150872_1_); + + if (tupleintjsonserializable == null) + { + tupleintjsonserializable = new TupleIntJsonSerializable(); + this.field_150875_a.put(p_150872_1_, tupleintjsonserializable); + } + + tupleintjsonserializable.setJsonSerializableValue(p_150872_2_); + return p_150872_2_; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/stats/StatList.java b/src/main/java/net/minecraft/stats/StatList.java new file mode 100644 index 0000000..d030e3f --- /dev/null +++ b/src/main/java/net/minecraft/stats/StatList.java @@ -0,0 +1,225 @@ +package net.minecraft.stats; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import net.minecraft.block.Block; +import net.minecraft.entity.EntityList; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.item.crafting.FurnaceRecipes; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.util.ChatComponentTranslation; + +public class StatList +{ + protected static Map oneShotStats = new HashMap(); + public static List allStats = new ArrayList(); + public static List generalStats = new ArrayList(); + public static List itemStats = new ArrayList(); + public static List objectMineStats = new ArrayList(); + public static StatBase leaveGameStat = (new StatBasic("stat.leaveGame", new ChatComponentTranslation("stat.leaveGame", new Object[0]))).initIndependentStat().registerStat(); + public static StatBase minutesPlayedStat = (new StatBasic("stat.playOneMinute", new ChatComponentTranslation("stat.playOneMinute", new Object[0]), StatBase.timeStatType)).initIndependentStat().registerStat(); + public static StatBase distanceWalkedStat = (new StatBasic("stat.walkOneCm", new ChatComponentTranslation("stat.walkOneCm", new Object[0]), StatBase.distanceStatType)).initIndependentStat().registerStat(); + public static StatBase distanceSwumStat = (new StatBasic("stat.swimOneCm", new ChatComponentTranslation("stat.swimOneCm", new Object[0]), StatBase.distanceStatType)).initIndependentStat().registerStat(); + public static StatBase distanceFallenStat = (new StatBasic("stat.fallOneCm", new ChatComponentTranslation("stat.fallOneCm", new Object[0]), StatBase.distanceStatType)).initIndependentStat().registerStat(); + public static StatBase distanceClimbedStat = (new StatBasic("stat.climbOneCm", new ChatComponentTranslation("stat.climbOneCm", new Object[0]), StatBase.distanceStatType)).initIndependentStat().registerStat(); + public static StatBase distanceFlownStat = (new StatBasic("stat.flyOneCm", new ChatComponentTranslation("stat.flyOneCm", new Object[0]), StatBase.distanceStatType)).initIndependentStat().registerStat(); + public static StatBase distanceDoveStat = (new StatBasic("stat.diveOneCm", new ChatComponentTranslation("stat.diveOneCm", new Object[0]), StatBase.distanceStatType)).initIndependentStat().registerStat(); + public static StatBase distanceByMinecartStat = (new StatBasic("stat.minecartOneCm", new ChatComponentTranslation("stat.minecartOneCm", new Object[0]), StatBase.distanceStatType)).initIndependentStat().registerStat(); + public static StatBase distanceByBoatStat = (new StatBasic("stat.boatOneCm", new ChatComponentTranslation("stat.boatOneCm", new Object[0]), StatBase.distanceStatType)).initIndependentStat().registerStat(); + public static StatBase distanceByPigStat = (new StatBasic("stat.pigOneCm", new ChatComponentTranslation("stat.pigOneCm", new Object[0]), StatBase.distanceStatType)).initIndependentStat().registerStat(); + public static StatBase field_151185_q = (new StatBasic("stat.horseOneCm", new ChatComponentTranslation("stat.horseOneCm", new Object[0]), StatBase.distanceStatType)).initIndependentStat().registerStat(); + public static StatBase jumpStat = (new StatBasic("stat.jump", new ChatComponentTranslation("stat.jump", new Object[0]))).initIndependentStat().registerStat(); + public static StatBase dropStat = (new StatBasic("stat.drop", new ChatComponentTranslation("stat.drop", new Object[0]))).initIndependentStat().registerStat(); + public static StatBase damageDealtStat = (new StatBasic("stat.damageDealt", new ChatComponentTranslation("stat.damageDealt", new Object[0]), StatBase.field_111202_k)).registerStat(); + public static StatBase damageTakenStat = (new StatBasic("stat.damageTaken", new ChatComponentTranslation("stat.damageTaken", new Object[0]), StatBase.field_111202_k)).registerStat(); + public static StatBase deathsStat = (new StatBasic("stat.deaths", new ChatComponentTranslation("stat.deaths", new Object[0]))).registerStat(); + public static StatBase mobKillsStat = (new StatBasic("stat.mobKills", new ChatComponentTranslation("stat.mobKills", new Object[0]))).registerStat(); + public static StatBase field_151186_x = (new StatBasic("stat.animalsBred", new ChatComponentTranslation("stat.animalsBred", new Object[0]))).registerStat(); + public static StatBase playerKillsStat = (new StatBasic("stat.playerKills", new ChatComponentTranslation("stat.playerKills", new Object[0]))).registerStat(); + public static StatBase fishCaughtStat = (new StatBasic("stat.fishCaught", new ChatComponentTranslation("stat.fishCaught", new Object[0]))).registerStat(); + public static StatBase field_151183_A = (new StatBasic("stat.junkFished", new ChatComponentTranslation("stat.junkFished", new Object[0]))).registerStat(); + public static StatBase field_151184_B = (new StatBasic("stat.treasureFished", new ChatComponentTranslation("stat.treasureFished", new Object[0]))).registerStat(); + public static final StatBase[] mineBlockStatArray = new StatBase[4096]; + public static final StatBase[] objectCraftStats = new StatBase[32000]; + public static final StatBase[] objectUseStats = new StatBase[32000]; + public static final StatBase[] objectBreakStats = new StatBase[32000]; + private static final String __OBFID = "CL_00001480"; + + public static void func_151178_a() + { + func_151181_c(); + initStats(); + func_151179_e(); + initCraftableStats(); + AchievementList.init(); + EntityList.func_151514_a(); + } + + private static void initCraftableStats() + { + HashSet hashset = new HashSet(); + Iterator iterator = CraftingManager.getInstance().getRecipeList().iterator(); + + while (iterator.hasNext()) + { + IRecipe irecipe = (IRecipe)iterator.next(); + + if (irecipe.getRecipeOutput() != null) + { + hashset.add(irecipe.getRecipeOutput().getItem()); + } + } + + iterator = FurnaceRecipes.smelting().getSmeltingList().values().iterator(); + + while (iterator.hasNext()) + { + ItemStack itemstack = (ItemStack)iterator.next(); + hashset.add(itemstack.getItem()); + } + + iterator = hashset.iterator(); + + while (iterator.hasNext()) + { + Item item = (Item)iterator.next(); + + if (item != null) + { + int i = Item.getIdFromItem(item); //TODO: Hook FML's stat change event and re-assign these + objectCraftStats[i] = (new StatCrafting("stat.craftItem." + i, new ChatComponentTranslation("stat.craftItem", new Object[] {(new ItemStack(item)).func_151000_E()}), item)).registerStat(); + } + } + + replaceAllSimilarBlocks(objectCraftStats); + } + + private static void func_151181_c() + { + Iterator iterator = Block.blockRegistry.iterator(); + + while (iterator.hasNext()) + { + Block block = (Block)iterator.next(); + + if (Item.getItemFromBlock(block) != null) + { + int i = Block.getIdFromBlock(block); //TODO: Hook FML's stat change event and re-assign these + + if (block.getEnableStats()) + { + mineBlockStatArray[i] = (new StatCrafting("stat.mineBlock." + i, new ChatComponentTranslation("stat.mineBlock", new Object[] {(new ItemStack(block)).func_151000_E()}), Item.getItemFromBlock(block))).registerStat(); + objectMineStats.add((StatCrafting)mineBlockStatArray[i]); + } + } + } + + replaceAllSimilarBlocks(mineBlockStatArray); + } + + private static void initStats() + { + Iterator iterator = Item.itemRegistry.iterator(); + + while (iterator.hasNext()) + { + Item item = (Item)iterator.next(); + + if (item != null) + { + int i = Item.getIdFromItem(item); //TODO: Hook FML's stat change event and re-assign these + objectUseStats[i] = (new StatCrafting("stat.useItem." + i, new ChatComponentTranslation("stat.useItem", new Object[] {(new ItemStack(item)).func_151000_E()}), item)).registerStat(); + + if (!(item instanceof ItemBlock)) + { + itemStats.add((StatCrafting)objectUseStats[i]); + } + } + } + + replaceAllSimilarBlocks(objectUseStats); + } + + private static void func_151179_e() + { + Iterator iterator = Item.itemRegistry.iterator(); + + while (iterator.hasNext()) + { + Item item = (Item)iterator.next(); + + if (item != null) + { + int i = Item.getIdFromItem(item); //TODO: Hook FML's stat change event and re-assign these + + if (item.isDamageable()) + { + objectBreakStats[i] = (new StatCrafting("stat.breakItem." + i, new ChatComponentTranslation("stat.breakItem", new Object[] {(new ItemStack(item)).func_151000_E()}), item)).registerStat(); + } + } + } + + replaceAllSimilarBlocks(objectBreakStats); + } + + private static void replaceAllSimilarBlocks(StatBase[] par0ArrayOfStatBase) + { + func_151180_a(par0ArrayOfStatBase, Blocks.water, Blocks.flowing_water); + func_151180_a(par0ArrayOfStatBase, Blocks.lava, Blocks.flowing_lava); + func_151180_a(par0ArrayOfStatBase, Blocks.lit_pumpkin, Blocks.pumpkin); + func_151180_a(par0ArrayOfStatBase, Blocks.lit_furnace, Blocks.furnace); + func_151180_a(par0ArrayOfStatBase, Blocks.lit_redstone_ore, Blocks.redstone_ore); + func_151180_a(par0ArrayOfStatBase, Blocks.powered_repeater, Blocks.unpowered_repeater); + func_151180_a(par0ArrayOfStatBase, Blocks.powered_comparator, Blocks.unpowered_comparator); + func_151180_a(par0ArrayOfStatBase, Blocks.redstone_torch, Blocks.unlit_redstone_torch); + func_151180_a(par0ArrayOfStatBase, Blocks.lit_redstone_lamp, Blocks.redstone_lamp); + func_151180_a(par0ArrayOfStatBase, Blocks.red_mushroom, Blocks.brown_mushroom); + func_151180_a(par0ArrayOfStatBase, Blocks.double_stone_slab, Blocks.stone_slab); + func_151180_a(par0ArrayOfStatBase, Blocks.double_wooden_slab, Blocks.wooden_slab); + func_151180_a(par0ArrayOfStatBase, Blocks.grass, Blocks.dirt); + func_151180_a(par0ArrayOfStatBase, Blocks.farmland, Blocks.dirt); + } + + private static void func_151180_a(StatBase[] p_151180_0_, Block p_151180_1_, Block p_151180_2_) + { + int i = Block.getIdFromBlock(p_151180_1_); + int j = Block.getIdFromBlock(p_151180_2_); + + if (p_151180_0_[i] != null && p_151180_0_[j] == null) + { + p_151180_0_[j] = p_151180_0_[i]; + } + else + { + allStats.remove(p_151180_0_[i]); + objectMineStats.remove(p_151180_0_[i]); + generalStats.remove(p_151180_0_[i]); + p_151180_0_[i] = p_151180_0_[j]; + } + } + + public static StatBase func_151182_a(EntityList.EntityEggInfo p_151182_0_) + { + String s = EntityList.getStringFromID(p_151182_0_.spawnedID); + return s == null ? null : (new StatBase("stat.killEntity." + s, new ChatComponentTranslation("stat.entityKill", new Object[] {new ChatComponentTranslation("entity." + s + ".name", new Object[0])}))).registerStat(); + } + + public static StatBase func_151176_b(EntityList.EntityEggInfo p_151176_0_) + { + String s = EntityList.getStringFromID(p_151176_0_.spawnedID); + return s == null ? null : (new StatBase("stat.entityKilledBy." + s, new ChatComponentTranslation("stat.entityKilledBy", new Object[] {new ChatComponentTranslation("entity." + s + ".name", new Object[0])}))).registerStat(); + } + + public static StatBase func_151177_a(String p_151177_0_) + { + return (StatBase)oneShotStats.get(p_151177_0_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/stats/StatisticsFile.java b/src/main/java/net/minecraft/stats/StatisticsFile.java new file mode 100644 index 0000000..e76e5ca --- /dev/null +++ b/src/main/java/net/minecraft/stats/StatisticsFile.java @@ -0,0 +1,253 @@ +package net.minecraft.stats; + +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.JsonParser; +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Constructor; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; +import java.util.Map.Entry; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.network.play.server.S37PacketStatistics; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.IJsonSerializable; +import net.minecraft.util.TupleIntJsonSerializable; +import org.apache.commons.io.FileUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class StatisticsFile extends StatFileWriter +{ + private static final Logger logger = LogManager.getLogger(); + private final MinecraftServer field_150890_c; + private final File field_150887_d; + private final Set field_150888_e = Sets.newHashSet(); + private int field_150885_f = -300; + private boolean field_150886_g = false; + private static final String __OBFID = "CL_00001471"; + + public StatisticsFile(MinecraftServer p_i45306_1_, File p_i45306_2_) + { + this.field_150890_c = p_i45306_1_; + this.field_150887_d = p_i45306_2_; + } + + public void func_150882_a() + { + if (this.field_150887_d.isFile()) + { + try + { + this.field_150875_a.clear(); + this.field_150875_a.putAll(this.func_150881_a(FileUtils.readFileToString(this.field_150887_d))); + } + catch (IOException ioexception) + { + logger.error("Couldn\'t read statistics file " + this.field_150887_d, ioexception); + } + catch (JsonParseException jsonparseexception) + { + logger.error("Couldn\'t parse statistics file " + this.field_150887_d, jsonparseexception); + } + } + } + + public void func_150883_b() + { + try + { + FileUtils.writeStringToFile(this.field_150887_d, func_150880_a(this.field_150875_a)); + } + catch (IOException ioexception) + { + logger.error("Couldn\'t save stats", ioexception); + } + } + + public void func_150873_a(EntityPlayer p_150873_1_, StatBase p_150873_2_, int p_150873_3_) + { + int j = p_150873_2_.isAchievement() ? this.writeStat(p_150873_2_) : 0; + super.func_150873_a(p_150873_1_, p_150873_2_, p_150873_3_); + this.field_150888_e.add(p_150873_2_); + + if (p_150873_2_.isAchievement() && j == 0 && p_150873_3_ > 0) + { + this.field_150886_g = true; + + if (this.field_150890_c.func_147136_ar()) + { + this.field_150890_c.getConfigurationManager().sendChatMsg(new ChatComponentTranslation("chat.type.achievement", new Object[] {p_150873_1_.func_145748_c_(), p_150873_2_.func_150955_j()})); + } + } + } + + public Set func_150878_c() + { + HashSet hashset = Sets.newHashSet(this.field_150888_e); + this.field_150888_e.clear(); + this.field_150886_g = false; + return hashset; + } + + public Map func_150881_a(String p_150881_1_) + { + JsonElement jsonelement = (new JsonParser()).parse(p_150881_1_); + + if (!jsonelement.isJsonObject()) + { + return Maps.newHashMap(); + } + else + { + JsonObject jsonobject = jsonelement.getAsJsonObject(); + HashMap hashmap = Maps.newHashMap(); + Iterator iterator = jsonobject.entrySet().iterator(); + + while (iterator.hasNext()) + { + Entry entry = (Entry)iterator.next(); + StatBase statbase = StatList.func_151177_a((String)entry.getKey()); + + if (statbase != null) + { + TupleIntJsonSerializable tupleintjsonserializable = new TupleIntJsonSerializable(); + + if (((JsonElement)entry.getValue()).isJsonPrimitive() && ((JsonElement)entry.getValue()).getAsJsonPrimitive().isNumber()) + { + tupleintjsonserializable.setIntegerValue(((JsonElement)entry.getValue()).getAsInt()); + } + else if (((JsonElement)entry.getValue()).isJsonObject()) + { + JsonObject jsonobject1 = ((JsonElement)entry.getValue()).getAsJsonObject(); + + if (jsonobject1.has("value") && jsonobject1.get("value").isJsonPrimitive() && jsonobject1.get("value").getAsJsonPrimitive().isNumber()) + { + tupleintjsonserializable.setIntegerValue(jsonobject1.getAsJsonPrimitive("value").getAsInt()); + } + + if (jsonobject1.has("progress") && statbase.func_150954_l() != null) + { + try + { + Constructor constructor = statbase.func_150954_l().getConstructor(new Class[0]); + IJsonSerializable ijsonserializable = (IJsonSerializable)constructor.newInstance(new Object[0]); + tupleintjsonserializable.setJsonSerializableValue(ijsonserializable); + } + catch (Throwable throwable) + { + logger.warn("Invalid statistic progress in " + this.field_150887_d, throwable); + } + } + } + + hashmap.put(statbase, tupleintjsonserializable); + } + else + { + logger.warn("Invalid statistic in " + this.field_150887_d + ": Don\'t know what " + (String)entry.getKey() + " is"); + } + } + + return hashmap; + } + } + + public static String func_150880_a(Map p_150880_0_) + { + JsonObject jsonobject = new JsonObject(); + Iterator iterator = p_150880_0_.entrySet().iterator(); + + while (iterator.hasNext()) + { + Entry entry = (Entry)iterator.next(); + + if (((TupleIntJsonSerializable)entry.getValue()).getJsonSerializableValue() != null) + { + JsonObject jsonobject1 = new JsonObject(); + jsonobject1.addProperty("value", Integer.valueOf(((TupleIntJsonSerializable)entry.getValue()).getIntegerValue())); + + try + { + jsonobject1.add("progress", ((TupleIntJsonSerializable)entry.getValue()).getJsonSerializableValue().getSerializableElement()); + } + catch (Throwable throwable) + { + logger.warn("Couldn\'t save statistic " + ((StatBase)entry.getKey()).func_150951_e() + ": error serializing progress", throwable); + } + + jsonobject.add(((StatBase)entry.getKey()).statId, jsonobject1); + } + else + { + jsonobject.addProperty(((StatBase)entry.getKey()).statId, Integer.valueOf(((TupleIntJsonSerializable)entry.getValue()).getIntegerValue())); + } + } + + return jsonobject.toString(); + } + + public void func_150877_d() + { + Iterator iterator = this.field_150875_a.keySet().iterator(); + + while (iterator.hasNext()) + { + StatBase statbase = (StatBase)iterator.next(); + this.field_150888_e.add(statbase); + } + } + + public void func_150876_a(EntityPlayerMP p_150876_1_) + { + int i = this.field_150890_c.getTickCounter(); + HashMap hashmap = Maps.newHashMap(); + + if (this.field_150886_g || i - this.field_150885_f > 300) + { + this.field_150885_f = i; + Iterator iterator = this.func_150878_c().iterator(); + + while (iterator.hasNext()) + { + StatBase statbase = (StatBase)iterator.next(); + hashmap.put(statbase, Integer.valueOf(this.writeStat(statbase))); + } + } + + p_150876_1_.playerNetServerHandler.sendPacket(new S37PacketStatistics(hashmap)); + } + + public void func_150884_b(EntityPlayerMP p_150884_1_) + { + HashMap hashmap = Maps.newHashMap(); + Iterator iterator = AchievementList.achievementList.iterator(); + + while (iterator.hasNext()) + { + Achievement achievement = (Achievement)iterator.next(); + + if (this.hasAchievementUnlocked(achievement)) + { + hashmap.put(achievement, Integer.valueOf(this.writeStat(achievement))); + this.field_150888_e.remove(achievement); + } + } + + p_150884_1_.playerNetServerHandler.sendPacket(new S37PacketStatistics(hashmap)); + } + + public boolean func_150879_e() + { + return this.field_150886_g; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/tileentity/IHopper.java b/src/main/java/net/minecraft/tileentity/IHopper.java new file mode 100644 index 0000000..4af238c --- /dev/null +++ b/src/main/java/net/minecraft/tileentity/IHopper.java @@ -0,0 +1,15 @@ +package net.minecraft.tileentity; + +import net.minecraft.inventory.IInventory; +import net.minecraft.world.World; + +public interface IHopper extends IInventory +{ + World getWorldObj(); + + double getXPos(); + + double getYPos(); + + double getZPos(); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/tileentity/MobSpawnerBaseLogic.java b/src/main/java/net/minecraft/tileentity/MobSpawnerBaseLogic.java new file mode 100644 index 0000000..b0e9329 --- /dev/null +++ b/src/main/java/net/minecraft/tileentity/MobSpawnerBaseLogic.java @@ -0,0 +1,446 @@ +package net.minecraft.tileentity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityList; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.WeightedRandom; +import net.minecraft.world.World; + +public abstract class MobSpawnerBaseLogic +{ + public int spawnDelay = 20; + private String entityTypeName = "Pig"; + private List potentialEntitySpawns; + private MobSpawnerBaseLogic.WeightedRandomMinecart randomEntity; + public double field_98287_c; + public double field_98284_d; + private int minSpawnDelay = 200; + private int maxSpawnDelay = 800; + private int spawnCount = 4; + private Entity field_98291_j; + private int maxNearbyEntities = 6; + private int activatingRangeFromPlayer = 16; + private int spawnRange = 4; + private static final String __OBFID = "CL_00000129"; + + public String getEntityNameToSpawn() + { + if (this.getRandomEntity() == null) + { + if (this.entityTypeName.equals("Minecart")) + { + this.entityTypeName = "MinecartRideable"; + } + + return this.entityTypeName; + } + else + { + return this.getRandomEntity().entityTypeName; + } + } + + public void setEntityName(String par1Str) + { + this.entityTypeName = par1Str; + } + + public boolean isActivated() + { + return this.getSpawnerWorld().getClosestPlayer((double)this.getSpawnerX() + 0.5D, (double)this.getSpawnerY() + 0.5D, (double)this.getSpawnerZ() + 0.5D, (double)this.activatingRangeFromPlayer) != null; + } + + public void updateSpawner() + { + if (this.isActivated()) + { + double d2; + + if (this.getSpawnerWorld().isRemote) + { + double d0 = (double)((float)this.getSpawnerX() + this.getSpawnerWorld().rand.nextFloat()); + double d1 = (double)((float)this.getSpawnerY() + this.getSpawnerWorld().rand.nextFloat()); + d2 = (double)((float)this.getSpawnerZ() + this.getSpawnerWorld().rand.nextFloat()); + this.getSpawnerWorld().spawnParticle("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D); + this.getSpawnerWorld().spawnParticle("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D); + + if (this.spawnDelay > 0) + { + --this.spawnDelay; + } + + this.field_98284_d = this.field_98287_c; + this.field_98287_c = (this.field_98287_c + (double)(1000.0F / ((float)this.spawnDelay + 200.0F))) % 360.0D; + } + else + { + if (this.spawnDelay == -1) + { + this.resetTimer(); + } + + if (this.spawnDelay > 0) + { + --this.spawnDelay; + return; + } + + boolean flag = false; + + for (int i = 0; i < this.spawnCount; ++i) + { + Entity entity = EntityList.createEntityByName(this.getEntityNameToSpawn(), this.getSpawnerWorld()); + + if (entity == null) + { + return; + } + + int j = this.getSpawnerWorld().getEntitiesWithinAABB(entity.getClass(), AxisAlignedBB.getAABBPool().getAABB((double)this.getSpawnerX(), (double)this.getSpawnerY(), (double)this.getSpawnerZ(), (double)(this.getSpawnerX() + 1), (double)(this.getSpawnerY() + 1), (double)(this.getSpawnerZ() + 1)).expand((double)(this.spawnRange * 2), 4.0D, (double)(this.spawnRange * 2))).size(); + + if (j >= this.maxNearbyEntities) + { + this.resetTimer(); + return; + } + + d2 = (double)this.getSpawnerX() + (this.getSpawnerWorld().rand.nextDouble() - this.getSpawnerWorld().rand.nextDouble()) * (double)this.spawnRange; + double d3 = (double)(this.getSpawnerY() + this.getSpawnerWorld().rand.nextInt(3) - 1); + double d4 = (double)this.getSpawnerZ() + (this.getSpawnerWorld().rand.nextDouble() - this.getSpawnerWorld().rand.nextDouble()) * (double)this.spawnRange; + EntityLiving entityliving = entity instanceof EntityLiving ? (EntityLiving)entity : null; + entity.setLocationAndAngles(d2, d3, d4, this.getSpawnerWorld().rand.nextFloat() * 360.0F, 0.0F); + + if (entityliving == null || entityliving.getCanSpawnHere()) + { + this.func_98265_a(entity); + this.getSpawnerWorld().playAuxSFX(2004, this.getSpawnerX(), this.getSpawnerY(), this.getSpawnerZ(), 0); + + if (entityliving != null) + { + entityliving.spawnExplosionParticle(); + } + + flag = true; + } + } + + if (flag) + { + this.resetTimer(); + } + } + } + } + + public Entity func_98265_a(Entity par1Entity) + { + if (this.getRandomEntity() != null) + { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + par1Entity.writeToNBTOptional(nbttagcompound); + Iterator iterator = this.getRandomEntity().field_98222_b.func_150296_c().iterator(); + + while (iterator.hasNext()) + { + String s = (String)iterator.next(); + NBTBase nbtbase = this.getRandomEntity().field_98222_b.getTag(s); + nbttagcompound.setTag(s, nbtbase.copy()); + } + + par1Entity.readFromNBT(nbttagcompound); + + if (par1Entity.worldObj != null) + { + par1Entity.worldObj.spawnEntityInWorld(par1Entity); + } + + NBTTagCompound nbttagcompound2; + + for (Entity entity1 = par1Entity; nbttagcompound.hasKey("Riding", 10); nbttagcompound = nbttagcompound2) + { + nbttagcompound2 = nbttagcompound.getCompoundTag("Riding"); + Entity entity2 = EntityList.createEntityByName(nbttagcompound2.getString("id"), par1Entity.worldObj); + + if (entity2 != null) + { + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + entity2.writeToNBTOptional(nbttagcompound1); + Iterator iterator1 = nbttagcompound2.func_150296_c().iterator(); + + while (iterator1.hasNext()) + { + String s1 = (String)iterator1.next(); + NBTBase nbtbase1 = nbttagcompound2.getTag(s1); + nbttagcompound1.setTag(s1, nbtbase1.copy()); + } + + entity2.readFromNBT(nbttagcompound1); + entity2.setLocationAndAngles(entity1.posX, entity1.posY, entity1.posZ, entity1.rotationYaw, entity1.rotationPitch); + + if (par1Entity.worldObj != null) + { + par1Entity.worldObj.spawnEntityInWorld(entity2); + } + + entity1.mountEntity(entity2); + } + + entity1 = entity2; + } + } + else if (par1Entity instanceof EntityLivingBase && par1Entity.worldObj != null) + { + ((EntityLiving)par1Entity).onSpawnWithEgg((IEntityLivingData)null); + this.getSpawnerWorld().spawnEntityInWorld(par1Entity); + } + + return par1Entity; + } + + private void resetTimer() + { + if (this.maxSpawnDelay <= this.minSpawnDelay) + { + this.spawnDelay = this.minSpawnDelay; + } + else + { + int i = this.maxSpawnDelay - this.minSpawnDelay; + this.spawnDelay = this.minSpawnDelay + this.getSpawnerWorld().rand.nextInt(i); + } + + if (this.potentialEntitySpawns != null && this.potentialEntitySpawns.size() > 0) + { + this.setRandomEntity((MobSpawnerBaseLogic.WeightedRandomMinecart)WeightedRandom.getRandomItem(this.getSpawnerWorld().rand, this.potentialEntitySpawns)); + } + + this.func_98267_a(1); + } + + public void readFromNBT(NBTTagCompound par1NBTTagCompound) + { + this.entityTypeName = par1NBTTagCompound.getString("EntityId"); + this.spawnDelay = par1NBTTagCompound.getShort("Delay"); + + if (par1NBTTagCompound.hasKey("SpawnPotentials", 9)) + { + this.potentialEntitySpawns = new ArrayList(); + NBTTagList nbttaglist = par1NBTTagCompound.getTagList("SpawnPotentials", 10); + + for (int i = 0; i < nbttaglist.tagCount(); ++i) + { + this.potentialEntitySpawns.add(new MobSpawnerBaseLogic.WeightedRandomMinecart(nbttaglist.getCompoundTagAt(i))); + } + } + else + { + this.potentialEntitySpawns = null; + } + + if (par1NBTTagCompound.hasKey("SpawnData", 10)) + { + this.setRandomEntity(new MobSpawnerBaseLogic.WeightedRandomMinecart(par1NBTTagCompound.getCompoundTag("SpawnData"), this.entityTypeName)); + } + else + { + this.setRandomEntity((MobSpawnerBaseLogic.WeightedRandomMinecart)null); + } + + if (par1NBTTagCompound.hasKey("MinSpawnDelay", 99)) + { + this.minSpawnDelay = par1NBTTagCompound.getShort("MinSpawnDelay"); + this.maxSpawnDelay = par1NBTTagCompound.getShort("MaxSpawnDelay"); + this.spawnCount = par1NBTTagCompound.getShort("SpawnCount"); + } + + if (par1NBTTagCompound.hasKey("MaxNearbyEntities", 99)) + { + this.maxNearbyEntities = par1NBTTagCompound.getShort("MaxNearbyEntities"); + this.activatingRangeFromPlayer = par1NBTTagCompound.getShort("RequiredPlayerRange"); + } + + if (par1NBTTagCompound.hasKey("SpawnRange", 99)) + { + this.spawnRange = par1NBTTagCompound.getShort("SpawnRange"); + } + + if (this.getSpawnerWorld() != null && this.getSpawnerWorld().isRemote) + { + this.field_98291_j = null; + } + } + + public void writeToNBT(NBTTagCompound par1NBTTagCompound) + { + par1NBTTagCompound.setString("EntityId", this.getEntityNameToSpawn()); + par1NBTTagCompound.setShort("Delay", (short)this.spawnDelay); + par1NBTTagCompound.setShort("MinSpawnDelay", (short)this.minSpawnDelay); + par1NBTTagCompound.setShort("MaxSpawnDelay", (short)this.maxSpawnDelay); + par1NBTTagCompound.setShort("SpawnCount", (short)this.spawnCount); + par1NBTTagCompound.setShort("MaxNearbyEntities", (short)this.maxNearbyEntities); + par1NBTTagCompound.setShort("RequiredPlayerRange", (short)this.activatingRangeFromPlayer); + par1NBTTagCompound.setShort("SpawnRange", (short)this.spawnRange); + + if (this.getRandomEntity() != null) + { + par1NBTTagCompound.setTag("SpawnData", this.getRandomEntity().field_98222_b.copy()); + } + + if (this.getRandomEntity() != null || this.potentialEntitySpawns != null && this.potentialEntitySpawns.size() > 0) + { + NBTTagList nbttaglist = new NBTTagList(); + + if (this.potentialEntitySpawns != null && this.potentialEntitySpawns.size() > 0) + { + Iterator iterator = this.potentialEntitySpawns.iterator(); + + while (iterator.hasNext()) + { + MobSpawnerBaseLogic.WeightedRandomMinecart weightedrandomminecart = (MobSpawnerBaseLogic.WeightedRandomMinecart)iterator.next(); + nbttaglist.appendTag(weightedrandomminecart.func_98220_a()); + } + } + else + { + nbttaglist.appendTag(this.getRandomEntity().func_98220_a()); + } + + par1NBTTagCompound.setTag("SpawnPotentials", nbttaglist); + } + } + + public boolean setDelayToMin(int par1) + { + if (par1 == 1 && this.getSpawnerWorld().isRemote) + { + this.spawnDelay = this.minSpawnDelay; + return true; + } + else + { + return false; + } + } + + @SideOnly(Side.CLIENT) + public Entity func_98281_h() + { + if (this.field_98291_j == null) + { + Entity entity = EntityList.createEntityByName(this.getEntityNameToSpawn(), (World)null); + entity = this.func_98265_a(entity); + this.field_98291_j = entity; + } + + return this.field_98291_j; + } + + public MobSpawnerBaseLogic.WeightedRandomMinecart getRandomEntity() + { + return this.randomEntity; + } + + public void setRandomEntity(MobSpawnerBaseLogic.WeightedRandomMinecart par1WeightedRandomMinecart) + { + this.randomEntity = par1WeightedRandomMinecart; + } + + public abstract void func_98267_a(int var1); + + public abstract World getSpawnerWorld(); + + public abstract int getSpawnerX(); + + public abstract int getSpawnerY(); + + public abstract int getSpawnerZ(); + + public class WeightedRandomMinecart extends WeightedRandom.Item + { + public final NBTTagCompound field_98222_b; + public final String entityTypeName; + private static final String __OBFID = "CL_00000130"; + + public WeightedRandomMinecart(NBTTagCompound par2NBTTagCompound) + { + super(par2NBTTagCompound.getInteger("Weight")); + NBTTagCompound nbttagcompound1 = par2NBTTagCompound.getCompoundTag("Properties"); + String s = par2NBTTagCompound.getString("Type"); + + if (s.equals("Minecart")) + { + if (nbttagcompound1 != null) + { + switch (nbttagcompound1.getInteger("Type")) + { + case 0: + s = "MinecartRideable"; + break; + case 1: + s = "MinecartChest"; + break; + case 2: + s = "MinecartFurnace"; + } + } + else + { + s = "MinecartRideable"; + } + } + + this.field_98222_b = nbttagcompound1; + this.entityTypeName = s; + } + + public WeightedRandomMinecart(NBTTagCompound par2NBTTagCompound, String par3Str) + { + super(1); + + if (par3Str.equals("Minecart")) + { + if (par2NBTTagCompound != null) + { + switch (par2NBTTagCompound.getInteger("Type")) + { + case 0: + par3Str = "MinecartRideable"; + break; + case 1: + par3Str = "MinecartChest"; + break; + case 2: + par3Str = "MinecartFurnace"; + } + } + else + { + par3Str = "MinecartRideable"; + } + } + + this.field_98222_b = par2NBTTagCompound; + this.entityTypeName = par3Str; + } + + public NBTTagCompound func_98220_a() + { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + nbttagcompound.setTag("Properties", this.field_98222_b); + nbttagcompound.setString("Type", this.entityTypeName); + nbttagcompound.setInteger("Weight", this.itemWeight); + return nbttagcompound; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/tileentity/TileEntity.java b/src/main/java/net/minecraft/tileentity/TileEntity.java new file mode 100644 index 0000000..cbef503 --- /dev/null +++ b/src/main/java/net/minecraft/tileentity/TileEntity.java @@ -0,0 +1,373 @@ +package net.minecraft.tileentity; + +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.Callable; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockJukebox; +import net.minecraft.crash.CrashReportCategory; +import net.minecraft.init.Blocks; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; + +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class TileEntity +{ + private static final Logger logger = LogManager.getLogger(); + private static Map nameToClassMap = new HashMap(); + private static Map classToNameMap = new HashMap(); + protected World worldObj; + public int xCoord; + public int yCoord; + public int zCoord; + protected boolean tileEntityInvalid; + public int blockMetadata = -1; + public Block blockType; + private static final String __OBFID = "CL_00000340"; + + public static void addMapping(Class p_145826_0_, String p_145826_1_) + { + if (nameToClassMap.containsKey(p_145826_1_)) + { + throw new IllegalArgumentException("Duplicate id: " + p_145826_1_); + } + else + { + nameToClassMap.put(p_145826_1_, p_145826_0_); + classToNameMap.put(p_145826_0_, p_145826_1_); + } + } + + public World getWorldObj() + { + return this.worldObj; + } + + public void setWorldObj(World p_145834_1_) + { + this.worldObj = p_145834_1_; + } + + public boolean hasWorldObj() + { + return this.worldObj != null; + } + + public void readFromNBT(NBTTagCompound p_145839_1_) + { + this.xCoord = p_145839_1_.getInteger("x"); + this.yCoord = p_145839_1_.getInteger("y"); + this.zCoord = p_145839_1_.getInteger("z"); + } + + public void writeToNBT(NBTTagCompound p_145841_1_) + { + String s = (String)classToNameMap.get(this.getClass()); + + if (s == null) + { + throw new RuntimeException(this.getClass() + " is missing a mapping! This is a bug!"); + } + else + { + p_145841_1_.setString("id", s); + p_145841_1_.setInteger("x", this.xCoord); + p_145841_1_.setInteger("y", this.yCoord); + p_145841_1_.setInteger("z", this.zCoord); + } + } + + public void updateEntity() {} + + public static TileEntity createAndLoadEntity(NBTTagCompound p_145827_0_) + { + TileEntity tileentity = null; + + Class oclass = null; + try + { + oclass = (Class)nameToClassMap.get(p_145827_0_.getString("id")); + + if (oclass != null) + { + tileentity = (TileEntity)oclass.newInstance(); + } + } + catch (Exception exception) + { + exception.printStackTrace(); + } + + if (tileentity != null) + { + try + { + tileentity.readFromNBT(p_145827_0_); + } + catch (Exception ex) + { + FMLLog.log(Level.ERROR, ex, + "A TileEntity %s(%s) has thrown an exception during loading, its state cannot be restored. Report this to the mod author", + p_145827_0_.getString("id"), oclass.getName()); + tileentity = null; + } + } + else + { + logger.warn("Skipping BlockEntity with id " + p_145827_0_.getString("id")); + } + + return tileentity; + } + + public int getBlockMetadata() + { + if (this.blockMetadata == -1) + { + this.blockMetadata = this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord); + } + + return this.blockMetadata; + } + + public void markDirty() + { + if (this.worldObj != null) + { + this.blockMetadata = this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord); + this.worldObj.markTileEntityChunkModified(this.xCoord, this.yCoord, this.zCoord, this); + + if (this.getBlockType() != Blocks.air) + { + this.worldObj.func_147453_f(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); + } + } + } + + public double getDistanceFrom(double p_145835_1_, double p_145835_3_, double p_145835_5_) + { + double d3 = (double)this.xCoord + 0.5D - p_145835_1_; + double d4 = (double)this.yCoord + 0.5D - p_145835_3_; + double d5 = (double)this.zCoord + 0.5D - p_145835_5_; + return d3 * d3 + d4 * d4 + d5 * d5; + } + + @SideOnly(Side.CLIENT) + public double getMaxRenderDistanceSquared() + { + return 4096.0D; + } + + public Block getBlockType() + { + if (this.blockType == null) + { + this.blockType = this.worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord); + } + + return this.blockType; + } + + public Packet getDescriptionPacket() + { + return null; + } + + public boolean isInvalid() + { + return this.tileEntityInvalid; + } + + public void invalidate() + { + this.tileEntityInvalid = true; + } + + public void validate() + { + this.tileEntityInvalid = false; + } + + public boolean receiveClientEvent(int p_145842_1_, int p_145842_2_) + { + return false; + } + + public void updateContainingBlockInfo() + { + this.blockType = null; + this.blockMetadata = -1; + } + + public void func_145828_a(CrashReportCategory p_145828_1_) + { + p_145828_1_.addCrashSectionCallable("Name", new Callable() + { + private static final String __OBFID = "CL_00000341"; + public String call() + { + return (String)TileEntity.classToNameMap.get(TileEntity.this.getClass()) + " // " + TileEntity.this.getClass().getCanonicalName(); + } + }); + CrashReportCategory.func_147153_a(p_145828_1_, this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), this.getBlockMetadata()); + p_145828_1_.addCrashSectionCallable("Actual block type", new Callable() + { + private static final String __OBFID = "CL_00000343"; + public String call() + { + int i = Block.getIdFromBlock(TileEntity.this.worldObj.getBlock(TileEntity.this.xCoord, TileEntity.this.yCoord, TileEntity.this.zCoord)); + + try + { + return String.format("ID #%d (%s // %s)", new Object[] {Integer.valueOf(i), Block.getBlockById(i).getUnlocalizedName(), Block.getBlockById(i).getClass().getCanonicalName()}); + } + catch (Throwable throwable) + { + return "ID #" + i; + } + } + }); + p_145828_1_.addCrashSectionCallable("Actual block data value", new Callable() + { + private static final String __OBFID = "CL_00000344"; + public String call() + { + int i = TileEntity.this.worldObj.getBlockMetadata(TileEntity.this.xCoord, TileEntity.this.yCoord, TileEntity.this.zCoord); + + if (i < 0) + { + return "Unknown? (Got " + i + ")"; + } + else + { + String s = String.format("%4s", new Object[] {Integer.toBinaryString(i)}).replace(" ", "0"); + return String.format("%1$d / 0x%1$X / 0b%2$s", new Object[] {Integer.valueOf(i), s}); + } + } + }); + } + + static + { + addMapping(TileEntityFurnace.class, "Furnace"); + addMapping(TileEntityChest.class, "Chest"); + addMapping(TileEntityEnderChest.class, "EnderChest"); + addMapping(BlockJukebox.TileEntityJukebox.class, "RecordPlayer"); + addMapping(TileEntityDispenser.class, "Trap"); + addMapping(TileEntityDropper.class, "Dropper"); + addMapping(TileEntitySign.class, "Sign"); + addMapping(TileEntityMobSpawner.class, "MobSpawner"); + addMapping(TileEntityNote.class, "Music"); + addMapping(TileEntityPiston.class, "Piston"); + addMapping(TileEntityBrewingStand.class, "Cauldron"); + addMapping(TileEntityEnchantmentTable.class, "EnchantTable"); + addMapping(TileEntityEndPortal.class, "Airportal"); + addMapping(TileEntityCommandBlock.class, "Control"); + addMapping(TileEntityBeacon.class, "Beacon"); + addMapping(TileEntitySkull.class, "Skull"); + addMapping(TileEntityDaylightDetector.class, "DLDetector"); + addMapping(TileEntityHopper.class, "Hopper"); + addMapping(TileEntityComparator.class, "Comparator"); + addMapping(TileEntityFlowerPot.class, "FlowerPot"); + } + + // -- BEGIN FORGE PATCHES -- + /** + * Determines if this TileEntity requires update calls. + * @return True if you want updateEntity() to be called, false if not + */ + public boolean canUpdate() + { + return true; + } + + /** + * Called when you receive a TileEntityData packet for the location this + * TileEntity is currently in. On the client, the NetworkManager will always + * be the remote server. On the server, it will be whomever is responsible for + * sending the packet. + * + * @param net The NetworkManager the packet originated from + * @param pkt The data packet + */ + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) + { + } + + /** + * Called when the chunk this TileEntity is on is Unloaded. + */ + public void onChunkUnload() + { + } + + private boolean isVanilla = getClass().getName().startsWith("net.minecraft.tileentity"); + /** + * Called from Chunk.setBlockIDWithMetadata, determines if this tile entity should be re-created when the ID, or Metadata changes. + * Use with caution as this will leave straggler TileEntities, or create conflicts with other TileEntities if not used properly. + * + * @param oldID The old ID of the block + * @param newID The new ID of the block (May be the same) + * @param oldMeta The old metadata of the block + * @param newMeta The new metadata of the block (May be the same) + * @param world Current world + * @param x X Position + * @param y Y Position + * @param z Z Position + * @return True to remove the old tile entity, false to keep it in tact {and create a new one if the new values specify to} + */ + public boolean shouldRefresh(Block oldBlock, Block newBlock, int oldMeta, int newMeta, World world, int x, int y, int z) + { + return !isVanilla || (oldBlock != newBlock); + } + + public boolean shouldRenderInPass(int pass) + { + return pass == 0; + } + /** + * Sometimes default render bounding box: infinite in scope. Used to control rendering on {@link TileEntitySpecialRenderer}. + */ + public static final AxisAlignedBB INFINITE_EXTENT_AABB = AxisAlignedBB.getBoundingBox(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY); + /** + * Return an {@link AxisAlignedBB} that controls the visible scope of a {@link TileEntitySpecialRenderer} associated with this {@link TileEntity} + * Defaults to the collision bounding box {@link Block#getCollisionBoundingBoxFromPool(World, int, int, int)} associated with the block + * at this location. + * + * @return an appropriately size {@link AxisAlignedBB} for the {@link TileEntity} + */ + @SideOnly(Side.CLIENT) + public AxisAlignedBB getRenderBoundingBox() + { + AxisAlignedBB bb = INFINITE_EXTENT_AABB; + Block type = getBlockType(); + if (type == Blocks.enchanting_table) + { + bb = AxisAlignedBB.getAABBPool().getAABB(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1); + } + else if (type == Blocks.chest || type == Blocks.trapped_chest) + { + bb = AxisAlignedBB.getAABBPool().getAABB(xCoord - 1, yCoord, zCoord - 1, xCoord + 2, yCoord + 2, zCoord + 2); + } + else if (type != null && type != Blocks.beacon) + { + AxisAlignedBB cbb = type.getCollisionBoundingBoxFromPool(worldObj, xCoord, yCoord, zCoord); + if (cbb != null) + { + bb = cbb; + } + } + return bb; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/tileentity/TileEntityBeacon.java b/src/main/java/net/minecraft/tileentity/TileEntityBeacon.java new file mode 100644 index 0000000..14c692f --- /dev/null +++ b/src/main/java/net/minecraft/tileentity/TileEntityBeacon.java @@ -0,0 +1,362 @@ +package net.minecraft.tileentity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Iterator; +import java.util.List; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.stats.AchievementList; +import net.minecraft.util.AxisAlignedBB; + +public class TileEntityBeacon extends TileEntity implements IInventory +{ + public static final Potion[][] effectsList = new Potion[][] {{Potion.moveSpeed, Potion.digSpeed}, {Potion.resistance, Potion.jump}, {Potion.damageBoost}, {Potion.regeneration}}; + @SideOnly(Side.CLIENT) + private long field_146016_i; + @SideOnly(Side.CLIENT) + private float field_146014_j; + private boolean field_146015_k; + private int levels = -1; + private int primaryEffect; + private int secondaryEffect; + private ItemStack payment; + private String field_146008_p; + private static final String __OBFID = "CL_00000339"; + + public void updateEntity() + { + if (this.worldObj.getTotalWorldTime() % 80L == 0L) + { + this.func_146003_y(); + this.func_146000_x(); + } + } + + private void func_146000_x() + { + if (this.field_146015_k && this.levels > 0 && !this.worldObj.isRemote && this.primaryEffect > 0) + { + double d0 = (double)(this.levels * 10 + 10); + byte b0 = 0; + + if (this.levels >= 4 && this.primaryEffect == this.secondaryEffect) + { + b0 = 1; + } + + AxisAlignedBB axisalignedbb = AxisAlignedBB.getAABBPool().getAABB((double)this.xCoord, (double)this.yCoord, (double)this.zCoord, (double)(this.xCoord + 1), (double)(this.yCoord + 1), (double)(this.zCoord + 1)).expand(d0, d0, d0); + axisalignedbb.maxY = (double)this.worldObj.getHeight(); + List list = this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, axisalignedbb); + Iterator iterator = list.iterator(); + EntityPlayer entityplayer; + + while (iterator.hasNext()) + { + entityplayer = (EntityPlayer)iterator.next(); + entityplayer.addPotionEffect(new PotionEffect(this.primaryEffect, 180, b0, true)); + } + + if (this.levels >= 4 && this.primaryEffect != this.secondaryEffect && this.secondaryEffect > 0) + { + iterator = list.iterator(); + + while (iterator.hasNext()) + { + entityplayer = (EntityPlayer)iterator.next(); + entityplayer.addPotionEffect(new PotionEffect(this.secondaryEffect, 180, 0, true)); + } + } + } + } + + private void func_146003_y() + { + int i = this.levels; + + if (!this.worldObj.canBlockSeeTheSky(this.xCoord, this.yCoord + 1, this.zCoord)) + { + this.field_146015_k = false; + this.levels = 0; + } + else + { + this.field_146015_k = true; + this.levels = 0; + + for (int j = 1; j <= 4; this.levels = j++) + { + int k = this.yCoord - j; + + if (k < 0) + { + break; + } + + boolean flag = true; + + for (int l = this.xCoord - j; l <= this.xCoord + j && flag; ++l) + { + for (int i1 = this.zCoord - j; i1 <= this.zCoord + j; ++i1) + { + Block block = this.worldObj.getBlock(l, k, i1); + + if (!block.isBeaconBase(this.worldObj, l, k, i1, xCoord, yCoord, zCoord)) + { + flag = false; + break; + } + } + } + + if (!flag) + { + break; + } + } + + if (this.levels == 0) + { + this.field_146015_k = false; + } + } + + if (!this.worldObj.isRemote && this.levels == 4 && i < this.levels) + { + Iterator iterator = this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getAABBPool().getAABB((double)this.xCoord, (double)this.yCoord, (double)this.zCoord, (double)this.xCoord, (double)(this.yCoord - 4), (double)this.zCoord).expand(10.0D, 5.0D, 10.0D)).iterator(); + + while (iterator.hasNext()) + { + EntityPlayer entityplayer = (EntityPlayer)iterator.next(); + entityplayer.triggerAchievement(AchievementList.field_150965_K); + } + } + } + + @SideOnly(Side.CLIENT) + public float func_146002_i() + { + if (!this.field_146015_k) + { + return 0.0F; + } + else + { + int i = (int)(this.worldObj.getTotalWorldTime() - this.field_146016_i); + this.field_146016_i = this.worldObj.getTotalWorldTime(); + + if (i > 1) + { + this.field_146014_j -= (float)i / 40.0F; + + if (this.field_146014_j < 0.0F) + { + this.field_146014_j = 0.0F; + } + } + + this.field_146014_j += 0.025F; + + if (this.field_146014_j > 1.0F) + { + this.field_146014_j = 1.0F; + } + + return this.field_146014_j; + } + } + + public int getPrimaryEffect() + { + return this.primaryEffect; + } + + public int getSecondaryEffect() + { + return this.secondaryEffect; + } + + public int getLevels() + { + return this.levels; + } + + @SideOnly(Side.CLIENT) + public void func_146005_c(int p_146005_1_) + { + this.levels = p_146005_1_; + } + + public void setPrimaryEffect(int p_146001_1_) + { + this.primaryEffect = 0; + + for (int j = 0; j < this.levels && j < 3; ++j) + { + Potion[] apotion = effectsList[j]; + int k = apotion.length; + + for (int l = 0; l < k; ++l) + { + Potion potion = apotion[l]; + + if (potion.id == p_146001_1_) + { + this.primaryEffect = p_146001_1_; + return; + } + } + } + } + + public void setSecondaryEffect(int p_146004_1_) + { + this.secondaryEffect = 0; + + if (this.levels >= 4) + { + for (int j = 0; j < 4; ++j) + { + Potion[] apotion = effectsList[j]; + int k = apotion.length; + + for (int l = 0; l < k; ++l) + { + Potion potion = apotion[l]; + + if (potion.id == p_146004_1_) + { + this.secondaryEffect = p_146004_1_; + return; + } + } + } + } + } + + public Packet getDescriptionPacket() + { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + this.writeToNBT(nbttagcompound); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 3, nbttagcompound); + } + + @SideOnly(Side.CLIENT) + public double getMaxRenderDistanceSquared() + { + return 65536.0D; + } + + public void readFromNBT(NBTTagCompound p_145839_1_) + { + super.readFromNBT(p_145839_1_); + this.primaryEffect = p_145839_1_.getInteger("Primary"); + this.secondaryEffect = p_145839_1_.getInteger("Secondary"); + this.levels = p_145839_1_.getInteger("Levels"); + } + + public void writeToNBT(NBTTagCompound p_145841_1_) + { + super.writeToNBT(p_145841_1_); + p_145841_1_.setInteger("Primary", this.primaryEffect); + p_145841_1_.setInteger("Secondary", this.secondaryEffect); + p_145841_1_.setInteger("Levels", this.levels); + } + + public int getSizeInventory() + { + return 1; + } + + public ItemStack getStackInSlot(int par1) + { + return par1 == 0 ? this.payment : null; + } + + public ItemStack decrStackSize(int par1, int par2) + { + if (par1 == 0 && this.payment != null) + { + if (par2 >= this.payment.stackSize) + { + ItemStack itemstack = this.payment; + this.payment = null; + return itemstack; + } + else + { + this.payment.stackSize -= par2; + return new ItemStack(this.payment.getItem(), par2, this.payment.getItemDamage()); + } + } + else + { + return null; + } + } + + public ItemStack getStackInSlotOnClosing(int par1) + { + if (par1 == 0 && this.payment != null) + { + ItemStack itemstack = this.payment; + this.payment = null; + return itemstack; + } + else + { + return null; + } + } + + public void setInventorySlotContents(int par1, ItemStack par2ItemStack) + { + if (par1 == 0) + { + this.payment = par2ItemStack; + } + } + + public String getInventoryName() + { + return this.hasCustomInventoryName() ? this.field_146008_p : "container.beacon"; + } + + public boolean hasCustomInventoryName() + { + return this.field_146008_p != null && this.field_146008_p.length() > 0; + } + + public void func_145999_a(String p_145999_1_) + { + this.field_146008_p = p_145999_1_; + } + + public int getInventoryStackLimit() + { + return 1; + } + + public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) + { + return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D; + } + + public void openInventory() {} + + public void closeInventory() {} + + public boolean isItemValidForSlot(int par1, ItemStack par2ItemStack) + { + return par2ItemStack.getItem() == Items.emerald || par2ItemStack.getItem() == Items.diamond || par2ItemStack.getItem() == Items.gold_ingot || par2ItemStack.getItem() == Items.iron_ingot; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/tileentity/TileEntityBrewingStand.java b/src/main/java/net/minecraft/tileentity/TileEntityBrewingStand.java new file mode 100644 index 0000000..546d36f --- /dev/null +++ b/src/main/java/net/minecraft/tileentity/TileEntityBrewingStand.java @@ -0,0 +1,336 @@ +package net.minecraft.tileentity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.Item; +import net.minecraft.item.ItemPotion; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.potion.PotionHelper; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.brewing.PotionBrewedEvent; + +public class TileEntityBrewingStand extends TileEntity implements ISidedInventory +{ + private static final int[] field_145941_a = new int[] {3}; + private static final int[] field_145947_i = new int[] {0, 1, 2}; + private ItemStack[] brewingItemStacks = new ItemStack[4]; + private int brewTime; + private int filledSlots; + private Item ingredientID; + private String field_145942_n; + private static final String __OBFID = "CL_00000345"; + + public String getInventoryName() + { + return this.hasCustomInventoryName() ? this.field_145942_n : "container.brewing"; + } + + public boolean hasCustomInventoryName() + { + return this.field_145942_n != null && this.field_145942_n.length() > 0; + } + + public void func_145937_a(String p_145937_1_) + { + this.field_145942_n = p_145937_1_; + } + + public int getSizeInventory() + { + return this.brewingItemStacks.length; + } + + public void updateEntity() + { + if (this.brewTime > 0) + { + --this.brewTime; + + if (this.brewTime == 0) + { + this.brewPotions(); + this.markDirty(); + } + else if (!this.canBrew()) + { + this.brewTime = 0; + this.markDirty(); + } + else if (this.ingredientID != this.brewingItemStacks[3].getItem()) + { + this.brewTime = 0; + this.markDirty(); + } + } + else if (this.canBrew()) + { + this.brewTime = 400; + this.ingredientID = this.brewingItemStacks[3].getItem(); + } + + int i = this.getFilledSlots(); + + if (i != this.filledSlots) + { + this.filledSlots = i; + this.worldObj.setBlockMetadataWithNotify(this.xCoord, this.yCoord, this.zCoord, i, 2); + } + + super.updateEntity(); + } + + public int getBrewTime() + { + return this.brewTime; + } + + private boolean canBrew() + { + if (this.brewingItemStacks[3] != null && this.brewingItemStacks[3].stackSize > 0) + { + ItemStack itemstack = this.brewingItemStacks[3]; + + if (!itemstack.getItem().isPotionIngredient(itemstack)) + { + return false; + } + else + { + boolean flag = false; + + for (int i = 0; i < 3; ++i) + { + if (this.brewingItemStacks[i] != null && this.brewingItemStacks[i].getItem() instanceof ItemPotion) + { + int j = this.brewingItemStacks[i].getItemDamage(); + int k = this.func_145936_c(j, itemstack); + + if (!ItemPotion.isSplash(j) && ItemPotion.isSplash(k)) + { + flag = true; + break; + } + + List list = Items.potionitem.getEffects(j); + List list1 = Items.potionitem.getEffects(k); + + if ((j <= 0 || list != list1) && (list == null || !list.equals(list1) && list1 != null) && j != k) + { + flag = true; + break; + } + } + } + + return flag; + } + } + else + { + return false; + } + } + + private void brewPotions() + { + if (this.canBrew()) + { + ItemStack itemstack = this.brewingItemStacks[3]; + + for (int i = 0; i < 3; ++i) + { + if (this.brewingItemStacks[i] != null && this.brewingItemStacks[i].getItem() instanceof ItemPotion) + { + int j = this.brewingItemStacks[i].getItemDamage(); + int k = this.func_145936_c(j, itemstack); + List list = Items.potionitem.getEffects(j); + List list1 = Items.potionitem.getEffects(k); + + if ((j <= 0 || list != list1) && (list == null || !list.equals(list1) && list1 != null)) + { + if (j != k) + { + this.brewingItemStacks[i].setItemDamage(k); + } + } + else if (!ItemPotion.isSplash(j) && ItemPotion.isSplash(k)) + { + this.brewingItemStacks[i].setItemDamage(k); + } + } + } + + if (itemstack.getItem().hasContainerItem(itemstack)) + { + this.brewingItemStacks[3] = itemstack.getItem().getContainerItem(itemstack); + } + else + { + --this.brewingItemStacks[3].stackSize; + + if (this.brewingItemStacks[3].stackSize <= 0) + { + this.brewingItemStacks[3] = null; + } + } + MinecraftForge.EVENT_BUS.post(new PotionBrewedEvent(brewingItemStacks)); + } + } + + private int func_145936_c(int p_145936_1_, ItemStack p_145936_2_) + { + return p_145936_2_ == null ? p_145936_1_ : (p_145936_2_.getItem().isPotionIngredient(p_145936_2_) ? PotionHelper.applyIngredient(p_145936_1_, p_145936_2_.getItem().getPotionEffect(p_145936_2_)) : p_145936_1_); + } + + public void readFromNBT(NBTTagCompound p_145839_1_) + { + super.readFromNBT(p_145839_1_); + NBTTagList nbttaglist = p_145839_1_.getTagList("Items", 10); + this.brewingItemStacks = new ItemStack[this.getSizeInventory()]; + + for (int i = 0; i < nbttaglist.tagCount(); ++i) + { + NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); + byte b0 = nbttagcompound1.getByte("Slot"); + + if (b0 >= 0 && b0 < this.brewingItemStacks.length) + { + this.brewingItemStacks[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1); + } + } + + this.brewTime = p_145839_1_.getShort("BrewTime"); + + if (p_145839_1_.hasKey("CustomName", 8)) + { + this.field_145942_n = p_145839_1_.getString("CustomName"); + } + } + + public void writeToNBT(NBTTagCompound p_145841_1_) + { + super.writeToNBT(p_145841_1_); + p_145841_1_.setShort("BrewTime", (short)this.brewTime); + NBTTagList nbttaglist = new NBTTagList(); + + for (int i = 0; i < this.brewingItemStacks.length; ++i) + { + if (this.brewingItemStacks[i] != null) + { + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + nbttagcompound1.setByte("Slot", (byte)i); + this.brewingItemStacks[i].writeToNBT(nbttagcompound1); + nbttaglist.appendTag(nbttagcompound1); + } + } + + p_145841_1_.setTag("Items", nbttaglist); + + if (this.hasCustomInventoryName()) + { + p_145841_1_.setString("CustomName", this.field_145942_n); + } + } + + public ItemStack getStackInSlot(int par1) + { + return par1 >= 0 && par1 < this.brewingItemStacks.length ? this.brewingItemStacks[par1] : null; + } + + public ItemStack decrStackSize(int par1, int par2) + { + if (par1 >= 0 && par1 < this.brewingItemStacks.length) + { + ItemStack itemstack = this.brewingItemStacks[par1]; + this.brewingItemStacks[par1] = null; + return itemstack; + } + else + { + return null; + } + } + + public ItemStack getStackInSlotOnClosing(int par1) + { + if (par1 >= 0 && par1 < this.brewingItemStacks.length) + { + ItemStack itemstack = this.brewingItemStacks[par1]; + this.brewingItemStacks[par1] = null; + return itemstack; + } + else + { + return null; + } + } + + public void setInventorySlotContents(int par1, ItemStack par2ItemStack) + { + if (par1 >= 0 && par1 < this.brewingItemStacks.length) + { + this.brewingItemStacks[par1] = par2ItemStack; + } + } + + public int getInventoryStackLimit() + { + return 64; + } + + public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) + { + return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D; + } + + public void openInventory() {} + + public void closeInventory() {} + + public boolean isItemValidForSlot(int par1, ItemStack par2ItemStack) + { + return par1 == 3 ? par2ItemStack.getItem().isPotionIngredient(par2ItemStack) : par2ItemStack.getItem() instanceof ItemPotion || par2ItemStack.getItem() == Items.glass_bottle; + } + + @SideOnly(Side.CLIENT) + public void func_145938_d(int p_145938_1_) + { + this.brewTime = p_145938_1_; + } + + public int getFilledSlots() + { + int i = 0; + + for (int j = 0; j < 3; ++j) + { + if (this.brewingItemStacks[j] != null) + { + i |= 1 << j; + } + } + + return i; + } + + public int[] getAccessibleSlotsFromSide(int par1) + { + return par1 == 1 ? field_145941_a : field_145947_i; + } + + public boolean canInsertItem(int par1, ItemStack par2ItemStack, int par3) + { + return this.isItemValidForSlot(par1, par2ItemStack); + } + + public boolean canExtractItem(int par1, ItemStack par2ItemStack, int par3) + { + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/tileentity/TileEntityChest.java b/src/main/java/net/minecraft/tileentity/TileEntityChest.java new file mode 100644 index 0000000..4b7828d --- /dev/null +++ b/src/main/java/net/minecraft/tileentity/TileEntityChest.java @@ -0,0 +1,449 @@ +package net.minecraft.tileentity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Iterator; +import java.util.List; +import net.minecraft.block.Block; +import net.minecraft.block.BlockChest; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ContainerChest; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.InventoryLargeChest; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.AxisAlignedBB; + +public class TileEntityChest extends TileEntity implements IInventory +{ + private ItemStack[] chestContents = new ItemStack[36]; + public boolean adjacentChestChecked; + public TileEntityChest adjacentChestZNeg; + public TileEntityChest adjacentChestXPos; + public TileEntityChest adjacentChestXNeg; + public TileEntityChest adjacentChestZPos; + public float lidAngle; + public float prevLidAngle; + public int numPlayersUsing; + private int ticksSinceSync; + private int cachedChestType; + private String customName; + private static final String __OBFID = "CL_00000346"; + + public TileEntityChest() + { + this.cachedChestType = -1; + } + + @SideOnly(Side.CLIENT) + public TileEntityChest(int par1) + { + this.cachedChestType = par1; + } + + public int getSizeInventory() + { + return 27; + } + + public ItemStack getStackInSlot(int par1) + { + return this.chestContents[par1]; + } + + public ItemStack decrStackSize(int par1, int par2) + { + if (this.chestContents[par1] != null) + { + ItemStack itemstack; + + if (this.chestContents[par1].stackSize <= par2) + { + itemstack = this.chestContents[par1]; + this.chestContents[par1] = null; + this.markDirty(); + return itemstack; + } + else + { + itemstack = this.chestContents[par1].splitStack(par2); + + if (this.chestContents[par1].stackSize == 0) + { + this.chestContents[par1] = null; + } + + this.markDirty(); + return itemstack; + } + } + else + { + return null; + } + } + + public ItemStack getStackInSlotOnClosing(int par1) + { + if (this.chestContents[par1] != null) + { + ItemStack itemstack = this.chestContents[par1]; + this.chestContents[par1] = null; + return itemstack; + } + else + { + return null; + } + } + + public void setInventorySlotContents(int par1, ItemStack par2ItemStack) + { + this.chestContents[par1] = par2ItemStack; + + if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit()) + { + par2ItemStack.stackSize = this.getInventoryStackLimit(); + } + + this.markDirty(); + } + + public String getInventoryName() + { + return this.hasCustomInventoryName() ? this.customName : "container.chest"; + } + + public boolean hasCustomInventoryName() + { + return this.customName != null && this.customName.length() > 0; + } + + public void func_145976_a(String p_145976_1_) + { + this.customName = p_145976_1_; + } + + public void readFromNBT(NBTTagCompound p_145839_1_) + { + super.readFromNBT(p_145839_1_); + NBTTagList nbttaglist = p_145839_1_.getTagList("Items", 10); + this.chestContents = new ItemStack[this.getSizeInventory()]; + + if (p_145839_1_.hasKey("CustomName", 8)) + { + this.customName = p_145839_1_.getString("CustomName"); + } + + for (int i = 0; i < nbttaglist.tagCount(); ++i) + { + NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); + int j = nbttagcompound1.getByte("Slot") & 255; + + if (j >= 0 && j < this.chestContents.length) + { + this.chestContents[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); + } + } + } + + public void writeToNBT(NBTTagCompound p_145841_1_) + { + super.writeToNBT(p_145841_1_); + NBTTagList nbttaglist = new NBTTagList(); + + for (int i = 0; i < this.chestContents.length; ++i) + { + if (this.chestContents[i] != null) + { + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + nbttagcompound1.setByte("Slot", (byte)i); + this.chestContents[i].writeToNBT(nbttagcompound1); + nbttaglist.appendTag(nbttagcompound1); + } + } + + p_145841_1_.setTag("Items", nbttaglist); + + if (this.hasCustomInventoryName()) + { + p_145841_1_.setString("CustomName", this.customName); + } + } + + public int getInventoryStackLimit() + { + return 64; + } + + public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) + { + return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D; + } + + public void updateContainingBlockInfo() + { + super.updateContainingBlockInfo(); + this.adjacentChestChecked = false; + } + + private void func_145978_a(TileEntityChest p_145978_1_, int p_145978_2_) + { + if (p_145978_1_.isInvalid()) + { + this.adjacentChestChecked = false; + } + else if (this.adjacentChestChecked) + { + switch (p_145978_2_) + { + case 0: + if (this.adjacentChestZPos != p_145978_1_) + { + this.adjacentChestChecked = false; + } + + break; + case 1: + if (this.adjacentChestXNeg != p_145978_1_) + { + this.adjacentChestChecked = false; + } + + break; + case 2: + if (this.adjacentChestZNeg != p_145978_1_) + { + this.adjacentChestChecked = false; + } + + break; + case 3: + if (this.adjacentChestXPos != p_145978_1_) + { + this.adjacentChestChecked = false; + } + } + } + } + + public void checkForAdjacentChests() + { + if (!this.adjacentChestChecked) + { + this.adjacentChestChecked = true; + this.adjacentChestZNeg = null; + this.adjacentChestXPos = null; + this.adjacentChestXNeg = null; + this.adjacentChestZPos = null; + + if (this.func_145977_a(this.xCoord - 1, this.yCoord, this.zCoord)) + { + this.adjacentChestXNeg = (TileEntityChest)this.worldObj.getTileEntity(this.xCoord - 1, this.yCoord, this.zCoord); + } + + if (this.func_145977_a(this.xCoord + 1, this.yCoord, this.zCoord)) + { + this.adjacentChestXPos = (TileEntityChest)this.worldObj.getTileEntity(this.xCoord + 1, this.yCoord, this.zCoord); + } + + if (this.func_145977_a(this.xCoord, this.yCoord, this.zCoord - 1)) + { + this.adjacentChestZNeg = (TileEntityChest)this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord - 1); + } + + if (this.func_145977_a(this.xCoord, this.yCoord, this.zCoord + 1)) + { + this.adjacentChestZPos = (TileEntityChest)this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord + 1); + } + + if (this.adjacentChestZNeg != null) + { + this.adjacentChestZNeg.func_145978_a(this, 0); + } + + if (this.adjacentChestZPos != null) + { + this.adjacentChestZPos.func_145978_a(this, 2); + } + + if (this.adjacentChestXPos != null) + { + this.adjacentChestXPos.func_145978_a(this, 1); + } + + if (this.adjacentChestXNeg != null) + { + this.adjacentChestXNeg.func_145978_a(this, 3); + } + } + } + + private boolean func_145977_a(int p_145977_1_, int p_145977_2_, int p_145977_3_) + { + Block block = this.worldObj.getBlock(p_145977_1_, p_145977_2_, p_145977_3_); + return block instanceof BlockChest && ((BlockChest)block).field_149956_a == this.func_145980_j(); + } + + public void updateEntity() + { + super.updateEntity(); + this.checkForAdjacentChests(); + ++this.ticksSinceSync; + float f; + + if (!this.worldObj.isRemote && this.numPlayersUsing != 0 && (this.ticksSinceSync + this.xCoord + this.yCoord + this.zCoord) % 200 == 0) + { + this.numPlayersUsing = 0; + f = 5.0F; + List list = this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getAABBPool().getAABB((double)((float)this.xCoord - f), (double)((float)this.yCoord - f), (double)((float)this.zCoord - f), (double)((float)(this.xCoord + 1) + f), (double)((float)(this.yCoord + 1) + f), (double)((float)(this.zCoord + 1) + f))); + Iterator iterator = list.iterator(); + + while (iterator.hasNext()) + { + EntityPlayer entityplayer = (EntityPlayer)iterator.next(); + + if (entityplayer.openContainer instanceof ContainerChest) + { + IInventory iinventory = ((ContainerChest)entityplayer.openContainer).getLowerChestInventory(); + + if (iinventory == this || iinventory instanceof InventoryLargeChest && ((InventoryLargeChest)iinventory).isPartOfLargeChest(this)) + { + ++this.numPlayersUsing; + } + } + } + } + + this.prevLidAngle = this.lidAngle; + f = 0.1F; + double d2; + + if (this.numPlayersUsing > 0 && this.lidAngle == 0.0F && this.adjacentChestZNeg == null && this.adjacentChestXNeg == null) + { + double d1 = (double)this.xCoord + 0.5D; + d2 = (double)this.zCoord + 0.5D; + + if (this.adjacentChestZPos != null) + { + d2 += 0.5D; + } + + if (this.adjacentChestXPos != null) + { + d1 += 0.5D; + } + + this.worldObj.playSoundEffect(d1, (double)this.yCoord + 0.5D, d2, "random.chestopen", 0.5F, this.worldObj.rand.nextFloat() * 0.1F + 0.9F); + } + + if (this.numPlayersUsing == 0 && this.lidAngle > 0.0F || this.numPlayersUsing > 0 && this.lidAngle < 1.0F) + { + float f1 = this.lidAngle; + + if (this.numPlayersUsing > 0) + { + this.lidAngle += f; + } + else + { + this.lidAngle -= f; + } + + if (this.lidAngle > 1.0F) + { + this.lidAngle = 1.0F; + } + + float f2 = 0.5F; + + if (this.lidAngle < f2 && f1 >= f2 && this.adjacentChestZNeg == null && this.adjacentChestXNeg == null) + { + d2 = (double)this.xCoord + 0.5D; + double d0 = (double)this.zCoord + 0.5D; + + if (this.adjacentChestZPos != null) + { + d0 += 0.5D; + } + + if (this.adjacentChestXPos != null) + { + d2 += 0.5D; + } + + this.worldObj.playSoundEffect(d2, (double)this.yCoord + 0.5D, d0, "random.chestclosed", 0.5F, this.worldObj.rand.nextFloat() * 0.1F + 0.9F); + } + + if (this.lidAngle < 0.0F) + { + this.lidAngle = 0.0F; + } + } + } + + public boolean receiveClientEvent(int p_145842_1_, int p_145842_2_) + { + if (p_145842_1_ == 1) + { + this.numPlayersUsing = p_145842_2_; + return true; + } + else + { + return super.receiveClientEvent(p_145842_1_, p_145842_2_); + } + } + + public void openInventory() + { + if (this.numPlayersUsing < 0) + { + this.numPlayersUsing = 0; + } + + ++this.numPlayersUsing; + this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, this.numPlayersUsing); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); + } + + public void closeInventory() + { + if (this.getBlockType() instanceof BlockChest) + { + --this.numPlayersUsing; + this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, this.numPlayersUsing); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); + } + } + + public boolean isItemValidForSlot(int par1, ItemStack par2ItemStack) + { + return true; + } + + public void invalidate() + { + super.invalidate(); + this.updateContainingBlockInfo(); + this.checkForAdjacentChests(); + } + + public int func_145980_j() + { + if (this.cachedChestType == -1) + { + if (this.worldObj == null || !(this.getBlockType() instanceof BlockChest)) + { + return 0; + } + + this.cachedChestType = ((BlockChest)this.getBlockType()).field_149956_a; + } + + return this.cachedChestType; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/tileentity/TileEntityCommandBlock.java b/src/main/java/net/minecraft/tileentity/TileEntityCommandBlock.java new file mode 100644 index 0000000..ffc1af1 --- /dev/null +++ b/src/main/java/net/minecraft/tileentity/TileEntityCommandBlock.java @@ -0,0 +1,73 @@ +package net.minecraft.tileentity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; +import net.minecraft.command.server.CommandBlockLogic; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.world.World; + +public class TileEntityCommandBlock extends TileEntity +{ + private final CommandBlockLogic field_145994_a = new CommandBlockLogic() + { + private static final String __OBFID = "CL_00000348"; + public ChunkCoordinates getPlayerCoordinates() + { + return new ChunkCoordinates(TileEntityCommandBlock.this.xCoord, TileEntityCommandBlock.this.yCoord, TileEntityCommandBlock.this.zCoord); + } + public World getEntityWorld() + { + return TileEntityCommandBlock.this.getWorldObj(); + } + public void func_145752_a(String p_145752_1_) + { + super.func_145752_a(p_145752_1_); + TileEntityCommandBlock.this.markDirty(); + } + public void func_145756_e() + { + TileEntityCommandBlock.this.getWorldObj().markBlockForUpdate(TileEntityCommandBlock.this.xCoord, TileEntityCommandBlock.this.yCoord, TileEntityCommandBlock.this.zCoord); + } + @SideOnly(Side.CLIENT) + public int func_145751_f() + { + return 0; + } + @SideOnly(Side.CLIENT) + public void func_145757_a(ByteBuf p_145757_1_) + { + p_145757_1_.writeInt(TileEntityCommandBlock.this.xCoord); + p_145757_1_.writeInt(TileEntityCommandBlock.this.yCoord); + p_145757_1_.writeInt(TileEntityCommandBlock.this.zCoord); + } + }; + private static final String __OBFID = "CL_00000347"; + + public void writeToNBT(NBTTagCompound p_145841_1_) + { + super.writeToNBT(p_145841_1_); + this.field_145994_a.func_145758_a(p_145841_1_); + } + + public void readFromNBT(NBTTagCompound p_145839_1_) + { + super.readFromNBT(p_145839_1_); + this.field_145994_a.func_145759_b(p_145839_1_); + } + + public Packet getDescriptionPacket() + { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + this.writeToNBT(nbttagcompound); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 2, nbttagcompound); + } + + public CommandBlockLogic func_145993_a() + { + return this.field_145994_a; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/tileentity/TileEntityComparator.java b/src/main/java/net/minecraft/tileentity/TileEntityComparator.java new file mode 100644 index 0000000..d8b733e --- /dev/null +++ b/src/main/java/net/minecraft/tileentity/TileEntityComparator.java @@ -0,0 +1,31 @@ +package net.minecraft.tileentity; + +import net.minecraft.nbt.NBTTagCompound; + +public class TileEntityComparator extends TileEntity +{ + private int field_145997_a; + private static final String __OBFID = "CL_00000349"; + + public void writeToNBT(NBTTagCompound p_145841_1_) + { + super.writeToNBT(p_145841_1_); + p_145841_1_.setInteger("OutputSignal", this.field_145997_a); + } + + public void readFromNBT(NBTTagCompound p_145839_1_) + { + super.readFromNBT(p_145839_1_); + this.field_145997_a = p_145839_1_.getInteger("OutputSignal"); + } + + public int getOutputSignal() + { + return this.field_145997_a; + } + + public void setOutputSignal(int p_145995_1_) + { + this.field_145997_a = p_145995_1_; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/tileentity/TileEntityDaylightDetector.java b/src/main/java/net/minecraft/tileentity/TileEntityDaylightDetector.java new file mode 100644 index 0000000..e3f88bd --- /dev/null +++ b/src/main/java/net/minecraft/tileentity/TileEntityDaylightDetector.java @@ -0,0 +1,21 @@ +package net.minecraft.tileentity; + +import net.minecraft.block.BlockDaylightDetector; + +public class TileEntityDaylightDetector extends TileEntity +{ + private static final String __OBFID = "CL_00000350"; + + public void updateEntity() + { + if (this.worldObj != null && !this.worldObj.isRemote && this.worldObj.getTotalWorldTime() % 20L == 0L) + { + this.blockType = this.getBlockType(); + + if (this.blockType instanceof BlockDaylightDetector) + { + ((BlockDaylightDetector)this.blockType).func_149957_e(this.worldObj, this.xCoord, this.yCoord, this.zCoord); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/tileentity/TileEntityDispenser.java b/src/main/java/net/minecraft/tileentity/TileEntityDispenser.java new file mode 100644 index 0000000..f1d5d6d --- /dev/null +++ b/src/main/java/net/minecraft/tileentity/TileEntityDispenser.java @@ -0,0 +1,195 @@ +package net.minecraft.tileentity; + +import java.util.Random; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; + +public class TileEntityDispenser extends TileEntity implements IInventory +{ + private ItemStack[] field_146022_i = new ItemStack[9]; + private Random field_146021_j = new Random(); + protected String field_146020_a; + private static final String __OBFID = "CL_00000352"; + + public int getSizeInventory() + { + return 9; + } + + public ItemStack getStackInSlot(int par1) + { + return this.field_146022_i[par1]; + } + + public ItemStack decrStackSize(int par1, int par2) + { + if (this.field_146022_i[par1] != null) + { + ItemStack itemstack; + + if (this.field_146022_i[par1].stackSize <= par2) + { + itemstack = this.field_146022_i[par1]; + this.field_146022_i[par1] = null; + this.markDirty(); + return itemstack; + } + else + { + itemstack = this.field_146022_i[par1].splitStack(par2); + + if (this.field_146022_i[par1].stackSize == 0) + { + this.field_146022_i[par1] = null; + } + + this.markDirty(); + return itemstack; + } + } + else + { + return null; + } + } + + public ItemStack getStackInSlotOnClosing(int par1) + { + if (this.field_146022_i[par1] != null) + { + ItemStack itemstack = this.field_146022_i[par1]; + this.field_146022_i[par1] = null; + return itemstack; + } + else + { + return null; + } + } + + public int func_146017_i() + { + int i = -1; + int j = 1; + + for (int k = 0; k < this.field_146022_i.length; ++k) + { + if (this.field_146022_i[k] != null && this.field_146021_j.nextInt(j++) == 0) + { + i = k; + } + } + + return i; + } + + public void setInventorySlotContents(int par1, ItemStack par2ItemStack) + { + this.field_146022_i[par1] = par2ItemStack; + + if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit()) + { + par2ItemStack.stackSize = this.getInventoryStackLimit(); + } + + this.markDirty(); + } + + public int func_146019_a(ItemStack p_146019_1_) + { + for (int i = 0; i < this.field_146022_i.length; ++i) + { + if (this.field_146022_i[i] == null || this.field_146022_i[i].getItem() == null) + { + this.setInventorySlotContents(i, p_146019_1_); + return i; + } + } + + return -1; + } + + public String getInventoryName() + { + return this.hasCustomInventoryName() ? this.field_146020_a : "container.dispenser"; + } + + public void func_146018_a(String p_146018_1_) + { + this.field_146020_a = p_146018_1_; + } + + public boolean hasCustomInventoryName() + { + return this.field_146020_a != null; + } + + public void readFromNBT(NBTTagCompound p_145839_1_) + { + super.readFromNBT(p_145839_1_); + NBTTagList nbttaglist = p_145839_1_.getTagList("Items", 10); + this.field_146022_i = new ItemStack[this.getSizeInventory()]; + + for (int i = 0; i < nbttaglist.tagCount(); ++i) + { + NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); + int j = nbttagcompound1.getByte("Slot") & 255; + + if (j >= 0 && j < this.field_146022_i.length) + { + this.field_146022_i[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); + } + } + + if (p_145839_1_.hasKey("CustomName", 8)) + { + this.field_146020_a = p_145839_1_.getString("CustomName"); + } + } + + public void writeToNBT(NBTTagCompound p_145841_1_) + { + super.writeToNBT(p_145841_1_); + NBTTagList nbttaglist = new NBTTagList(); + + for (int i = 0; i < this.field_146022_i.length; ++i) + { + if (this.field_146022_i[i] != null) + { + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + nbttagcompound1.setByte("Slot", (byte)i); + this.field_146022_i[i].writeToNBT(nbttagcompound1); + nbttaglist.appendTag(nbttagcompound1); + } + } + + p_145841_1_.setTag("Items", nbttaglist); + + if (this.hasCustomInventoryName()) + { + p_145841_1_.setString("CustomName", this.field_146020_a); + } + } + + public int getInventoryStackLimit() + { + return 64; + } + + public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) + { + return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D; + } + + public void openInventory() {} + + public void closeInventory() {} + + public boolean isItemValidForSlot(int par1, ItemStack par2ItemStack) + { + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/tileentity/TileEntityDropper.java b/src/main/java/net/minecraft/tileentity/TileEntityDropper.java new file mode 100644 index 0000000..3b0ae76 --- /dev/null +++ b/src/main/java/net/minecraft/tileentity/TileEntityDropper.java @@ -0,0 +1,11 @@ +package net.minecraft.tileentity; + +public class TileEntityDropper extends TileEntityDispenser +{ + private static final String __OBFID = "CL_00000353"; + + public String getInventoryName() + { + return this.hasCustomInventoryName() ? this.field_146020_a : "container.dropper"; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/tileentity/TileEntityEnchantmentTable.java b/src/main/java/net/minecraft/tileentity/TileEntityEnchantmentTable.java new file mode 100644 index 0000000..daa64bd --- /dev/null +++ b/src/main/java/net/minecraft/tileentity/TileEntityEnchantmentTable.java @@ -0,0 +1,151 @@ +package net.minecraft.tileentity; + +import java.util.Random; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; + +public class TileEntityEnchantmentTable extends TileEntity +{ + public int field_145926_a; + public float field_145933_i; + public float field_145931_j; + public float field_145932_k; + public float field_145929_l; + public float field_145930_m; + public float field_145927_n; + public float field_145928_o; + public float field_145925_p; + public float field_145924_q; + private static Random field_145923_r = new Random(); + private String field_145922_s; + private static final String __OBFID = "CL_00000354"; + + public void writeToNBT(NBTTagCompound p_145841_1_) + { + super.writeToNBT(p_145841_1_); + + if (this.func_145921_b()) + { + p_145841_1_.setString("CustomName", this.field_145922_s); + } + } + + public void readFromNBT(NBTTagCompound p_145839_1_) + { + super.readFromNBT(p_145839_1_); + + if (p_145839_1_.hasKey("CustomName", 8)) + { + this.field_145922_s = p_145839_1_.getString("CustomName"); + } + } + + public void updateEntity() + { + super.updateEntity(); + this.field_145927_n = this.field_145930_m; + this.field_145925_p = this.field_145928_o; + EntityPlayer entityplayer = this.worldObj.getClosestPlayer((double)((float)this.xCoord + 0.5F), (double)((float)this.yCoord + 0.5F), (double)((float)this.zCoord + 0.5F), 3.0D); + + if (entityplayer != null) + { + double d0 = entityplayer.posX - (double)((float)this.xCoord + 0.5F); + double d1 = entityplayer.posZ - (double)((float)this.zCoord + 0.5F); + this.field_145924_q = (float)Math.atan2(d1, d0); + this.field_145930_m += 0.1F; + + if (this.field_145930_m < 0.5F || field_145923_r.nextInt(40) == 0) + { + float f1 = this.field_145932_k; + + do + { + this.field_145932_k += (float)(field_145923_r.nextInt(4) - field_145923_r.nextInt(4)); + } + while (f1 == this.field_145932_k); + } + } + else + { + this.field_145924_q += 0.02F; + this.field_145930_m -= 0.1F; + } + + while (this.field_145928_o >= (float)Math.PI) + { + this.field_145928_o -= ((float)Math.PI * 2F); + } + + while (this.field_145928_o < -(float)Math.PI) + { + this.field_145928_o += ((float)Math.PI * 2F); + } + + while (this.field_145924_q >= (float)Math.PI) + { + this.field_145924_q -= ((float)Math.PI * 2F); + } + + while (this.field_145924_q < -(float)Math.PI) + { + this.field_145924_q += ((float)Math.PI * 2F); + } + + float f2; + + for (f2 = this.field_145924_q - this.field_145928_o; f2 >= (float)Math.PI; f2 -= ((float)Math.PI * 2F)) + { + ; + } + + while (f2 < -(float)Math.PI) + { + f2 += ((float)Math.PI * 2F); + } + + this.field_145928_o += f2 * 0.4F; + + if (this.field_145930_m < 0.0F) + { + this.field_145930_m = 0.0F; + } + + if (this.field_145930_m > 1.0F) + { + this.field_145930_m = 1.0F; + } + + ++this.field_145926_a; + this.field_145931_j = this.field_145933_i; + float f = (this.field_145932_k - this.field_145933_i) * 0.4F; + float f3 = 0.2F; + + if (f < -f3) + { + f = -f3; + } + + if (f > f3) + { + f = f3; + } + + this.field_145929_l += (f - this.field_145929_l) * 0.9F; + this.field_145933_i += this.field_145929_l; + } + + public String func_145919_a() + { + return this.func_145921_b() ? this.field_145922_s : "container.enchant"; + } + + public boolean func_145921_b() + { + return this.field_145922_s != null && this.field_145922_s.length() > 0; + } + + public void func_145920_a(String p_145920_1_) + { + this.field_145922_s = p_145920_1_; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/tileentity/TileEntityEndPortal.java b/src/main/java/net/minecraft/tileentity/TileEntityEndPortal.java new file mode 100644 index 0000000..95b833e --- /dev/null +++ b/src/main/java/net/minecraft/tileentity/TileEntityEndPortal.java @@ -0,0 +1,6 @@ +package net.minecraft.tileentity; + +public class TileEntityEndPortal extends TileEntity +{ + private static final String __OBFID = "CL_00000365"; +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/tileentity/TileEntityEnderChest.java b/src/main/java/net/minecraft/tileentity/TileEntityEnderChest.java new file mode 100644 index 0000000..69cefb1 --- /dev/null +++ b/src/main/java/net/minecraft/tileentity/TileEntityEnderChest.java @@ -0,0 +1,103 @@ +package net.minecraft.tileentity; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; + +public class TileEntityEnderChest extends TileEntity +{ + public float field_145972_a; + public float field_145975_i; + public int field_145973_j; + private int field_145974_k; + private static final String __OBFID = "CL_00000355"; + + public void updateEntity() + { + super.updateEntity(); + + if (++this.field_145974_k % 20 * 4 == 0) + { + this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, Blocks.ender_chest, 1, this.field_145973_j); + } + + this.field_145975_i = this.field_145972_a; + float f = 0.1F; + double d1; + + if (this.field_145973_j > 0 && this.field_145972_a == 0.0F) + { + double d0 = (double)this.xCoord + 0.5D; + d1 = (double)this.zCoord + 0.5D; + this.worldObj.playSoundEffect(d0, (double)this.yCoord + 0.5D, d1, "random.chestopen", 0.5F, this.worldObj.rand.nextFloat() * 0.1F + 0.9F); + } + + if (this.field_145973_j == 0 && this.field_145972_a > 0.0F || this.field_145973_j > 0 && this.field_145972_a < 1.0F) + { + float f2 = this.field_145972_a; + + if (this.field_145973_j > 0) + { + this.field_145972_a += f; + } + else + { + this.field_145972_a -= f; + } + + if (this.field_145972_a > 1.0F) + { + this.field_145972_a = 1.0F; + } + + float f1 = 0.5F; + + if (this.field_145972_a < f1 && f2 >= f1) + { + d1 = (double)this.xCoord + 0.5D; + double d2 = (double)this.zCoord + 0.5D; + this.worldObj.playSoundEffect(d1, (double)this.yCoord + 0.5D, d2, "random.chestclosed", 0.5F, this.worldObj.rand.nextFloat() * 0.1F + 0.9F); + } + + if (this.field_145972_a < 0.0F) + { + this.field_145972_a = 0.0F; + } + } + } + + public boolean receiveClientEvent(int p_145842_1_, int p_145842_2_) + { + if (p_145842_1_ == 1) + { + this.field_145973_j = p_145842_2_; + return true; + } + else + { + return super.receiveClientEvent(p_145842_1_, p_145842_2_); + } + } + + public void invalidate() + { + this.updateContainingBlockInfo(); + super.invalidate(); + } + + public void func_145969_a() + { + ++this.field_145973_j; + this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, Blocks.ender_chest, 1, this.field_145973_j); + } + + public void func_145970_b() + { + --this.field_145973_j; + this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, Blocks.ender_chest, 1, this.field_145973_j); + } + + public boolean func_145971_a(EntityPlayer p_145971_1_) + { + return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : p_145971_1_.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/tileentity/TileEntityFlowerPot.java b/src/main/java/net/minecraft/tileentity/TileEntityFlowerPot.java new file mode 100644 index 0000000..c28a021 --- /dev/null +++ b/src/main/java/net/minecraft/tileentity/TileEntityFlowerPot.java @@ -0,0 +1,58 @@ +package net.minecraft.tileentity; + +import net.minecraft.item.Item; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; + +public class TileEntityFlowerPot extends TileEntity +{ + private Item flowerPotItem; + private int flowerPotData; + private static final String __OBFID = "CL_00000356"; + + public TileEntityFlowerPot() {} + + public TileEntityFlowerPot(Item p_i45442_1_, int p_i45442_2_) + { + this.flowerPotItem = p_i45442_1_; + this.flowerPotData = p_i45442_2_; + } + + public void writeToNBT(NBTTagCompound p_145841_1_) + { + super.writeToNBT(p_145841_1_); + p_145841_1_.setInteger("Item", Item.getIdFromItem(this.flowerPotItem)); + p_145841_1_.setInteger("Data", this.flowerPotData); + } + + public void readFromNBT(NBTTagCompound p_145839_1_) + { + super.readFromNBT(p_145839_1_); + this.flowerPotItem = Item.getItemById(p_145839_1_.getInteger("Item")); + this.flowerPotData = p_145839_1_.getInteger("Data"); + } + + public Packet getDescriptionPacket() + { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + this.writeToNBT(nbttagcompound); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 5, nbttagcompound); + } + + public void func_145964_a(Item p_145964_1_, int p_145964_2_) + { + this.flowerPotItem = p_145964_1_; + this.flowerPotData = p_145964_2_; + } + + public Item getFlowerPotItem() + { + return this.flowerPotItem; + } + + public int getFlowerPotData() + { + return this.flowerPotData; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/tileentity/TileEntityFurnace.java b/src/main/java/net/minecraft/tileentity/TileEntityFurnace.java new file mode 100644 index 0000000..825c6e8 --- /dev/null +++ b/src/main/java/net/minecraft/tileentity/TileEntityFurnace.java @@ -0,0 +1,371 @@ +package net.minecraft.tileentity; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.block.BlockFurnace; +import net.minecraft.block.material.Material; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemHoe; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemSword; +import net.minecraft.item.ItemTool; +import net.minecraft.item.crafting.FurnaceRecipes; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; + +public class TileEntityFurnace extends TileEntity implements ISidedInventory +{ + private static final int[] slotsTop = new int[] {0}; + private static final int[] slotsBottom = new int[] {2, 1}; + private static final int[] slotsSides = new int[] {1}; + private ItemStack[] furnaceItemStacks = new ItemStack[3]; + public int furnaceBurnTime; + public int currentItemBurnTime; + public int furnaceCookTime; + private String field_145958_o; + private static final String __OBFID = "CL_00000357"; + + public int getSizeInventory() + { + return this.furnaceItemStacks.length; + } + + public ItemStack getStackInSlot(int par1) + { + return this.furnaceItemStacks[par1]; + } + + public ItemStack decrStackSize(int par1, int par2) + { + if (this.furnaceItemStacks[par1] != null) + { + ItemStack itemstack; + + if (this.furnaceItemStacks[par1].stackSize <= par2) + { + itemstack = this.furnaceItemStacks[par1]; + this.furnaceItemStacks[par1] = null; + return itemstack; + } + else + { + itemstack = this.furnaceItemStacks[par1].splitStack(par2); + + if (this.furnaceItemStacks[par1].stackSize == 0) + { + this.furnaceItemStacks[par1] = null; + } + + return itemstack; + } + } + else + { + return null; + } + } + + public ItemStack getStackInSlotOnClosing(int par1) + { + if (this.furnaceItemStacks[par1] != null) + { + ItemStack itemstack = this.furnaceItemStacks[par1]; + this.furnaceItemStacks[par1] = null; + return itemstack; + } + else + { + return null; + } + } + + public void setInventorySlotContents(int par1, ItemStack par2ItemStack) + { + this.furnaceItemStacks[par1] = par2ItemStack; + + if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit()) + { + par2ItemStack.stackSize = this.getInventoryStackLimit(); + } + } + + public String getInventoryName() + { + return this.hasCustomInventoryName() ? this.field_145958_o : "container.furnace"; + } + + public boolean hasCustomInventoryName() + { + return this.field_145958_o != null && this.field_145958_o.length() > 0; + } + + public void func_145951_a(String p_145951_1_) + { + this.field_145958_o = p_145951_1_; + } + + public void readFromNBT(NBTTagCompound p_145839_1_) + { + super.readFromNBT(p_145839_1_); + NBTTagList nbttaglist = p_145839_1_.getTagList("Items", 10); + this.furnaceItemStacks = new ItemStack[this.getSizeInventory()]; + + for (int i = 0; i < nbttaglist.tagCount(); ++i) + { + NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); + byte b0 = nbttagcompound1.getByte("Slot"); + + if (b0 >= 0 && b0 < this.furnaceItemStacks.length) + { + this.furnaceItemStacks[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1); + } + } + + this.furnaceBurnTime = p_145839_1_.getShort("BurnTime"); + this.furnaceCookTime = p_145839_1_.getShort("CookTime"); + this.currentItemBurnTime = getItemBurnTime(this.furnaceItemStacks[1]); + + if (p_145839_1_.hasKey("CustomName", 8)) + { + this.field_145958_o = p_145839_1_.getString("CustomName"); + } + } + + public void writeToNBT(NBTTagCompound p_145841_1_) + { + super.writeToNBT(p_145841_1_); + p_145841_1_.setShort("BurnTime", (short)this.furnaceBurnTime); + p_145841_1_.setShort("CookTime", (short)this.furnaceCookTime); + NBTTagList nbttaglist = new NBTTagList(); + + for (int i = 0; i < this.furnaceItemStacks.length; ++i) + { + if (this.furnaceItemStacks[i] != null) + { + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + nbttagcompound1.setByte("Slot", (byte)i); + this.furnaceItemStacks[i].writeToNBT(nbttagcompound1); + nbttaglist.appendTag(nbttagcompound1); + } + } + + p_145841_1_.setTag("Items", nbttaglist); + + if (this.hasCustomInventoryName()) + { + p_145841_1_.setString("CustomName", this.field_145958_o); + } + } + + public int getInventoryStackLimit() + { + return 64; + } + + @SideOnly(Side.CLIENT) + public int getCookProgressScaled(int p_145953_1_) + { + return this.furnaceCookTime * p_145953_1_ / 200; + } + + @SideOnly(Side.CLIENT) + public int getBurnTimeRemainingScaled(int p_145955_1_) + { + if (this.currentItemBurnTime == 0) + { + this.currentItemBurnTime = 200; + } + + return this.furnaceBurnTime * p_145955_1_ / this.currentItemBurnTime; + } + + public boolean isBurning() + { + return this.furnaceBurnTime > 0; + } + + public void updateEntity() + { + boolean flag = this.furnaceBurnTime > 0; + boolean flag1 = false; + + if (this.furnaceBurnTime > 0) + { + --this.furnaceBurnTime; + } + + if (!this.worldObj.isRemote) + { + if (this.furnaceBurnTime == 0 && this.canSmelt()) + { + this.currentItemBurnTime = this.furnaceBurnTime = getItemBurnTime(this.furnaceItemStacks[1]); + + if (this.furnaceBurnTime > 0) + { + flag1 = true; + + if (this.furnaceItemStacks[1] != null) + { + --this.furnaceItemStacks[1].stackSize; + + if (this.furnaceItemStacks[1].stackSize == 0) + { + this.furnaceItemStacks[1] = furnaceItemStacks[1].getItem().getContainerItem(furnaceItemStacks[1]); + } + } + } + } + + if (this.isBurning() && this.canSmelt()) + { + ++this.furnaceCookTime; + + if (this.furnaceCookTime == 200) + { + this.furnaceCookTime = 0; + this.smeltItem(); + flag1 = true; + } + } + else + { + this.furnaceCookTime = 0; + } + + if (flag != this.furnaceBurnTime > 0) + { + flag1 = true; + BlockFurnace.updateFurnaceBlockState(this.furnaceBurnTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord); + } + } + + if (flag1) + { + this.markDirty(); + } + } + + private boolean canSmelt() + { + if (this.furnaceItemStacks[0] == null) + { + return false; + } + else + { + ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(this.furnaceItemStacks[0]); + if (itemstack == null) return false; + if (this.furnaceItemStacks[2] == null) return true; + if (!this.furnaceItemStacks[2].isItemEqual(itemstack)) return false; + int result = furnaceItemStacks[2].stackSize + itemstack.stackSize; + return result <= getInventoryStackLimit() && result <= this.furnaceItemStacks[2].getMaxStackSize(); //Forge BugFix: Make it respect stack sizes properly. + } + } + + public void smeltItem() + { + if (this.canSmelt()) + { + ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(this.furnaceItemStacks[0]); + + if (this.furnaceItemStacks[2] == null) + { + this.furnaceItemStacks[2] = itemstack.copy(); + } + else if (this.furnaceItemStacks[2].getItem() == itemstack.getItem()) + { + this.furnaceItemStacks[2].stackSize += itemstack.stackSize; // Forge BugFix: Results may have multiple items + } + + --this.furnaceItemStacks[0].stackSize; + + if (this.furnaceItemStacks[0].stackSize <= 0) + { + this.furnaceItemStacks[0] = null; + } + } + } + + public static int getItemBurnTime(ItemStack p_145952_0_) + { + if (p_145952_0_ == null) + { + return 0; + } + else + { + Item item = p_145952_0_.getItem(); + + if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.air) + { + Block block = Block.getBlockFromItem(item); + + if (block == Blocks.wooden_slab) + { + return 150; + } + + if (block.getMaterial() == Material.wood) + { + return 300; + } + + if (block == Blocks.coal_block) + { + return 16000; + } + } + + if (item instanceof ItemTool && ((ItemTool)item).getToolMaterialName().equals("WOOD")) return 200; + if (item instanceof ItemSword && ((ItemSword)item).getToolMaterialName().equals("WOOD")) return 200; + if (item instanceof ItemHoe && ((ItemHoe)item).getToolMaterialName().equals("WOOD")) return 200; + if (item == Items.stick) return 100; + if (item == Items.coal) return 1600; + if (item == Items.lava_bucket) return 20000; + if (item == Item.getItemFromBlock(Blocks.sapling)) return 100; + if (item == Items.blaze_rod) return 2400; + return GameRegistry.getFuelValue(p_145952_0_); + } + } + + public static boolean isItemFuel(ItemStack p_145954_0_) + { + return getItemBurnTime(p_145954_0_) > 0; + } + + public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) + { + return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D; + } + + public void openInventory() {} + + public void closeInventory() {} + + public boolean isItemValidForSlot(int par1, ItemStack par2ItemStack) + { + return par1 == 2 ? false : (par1 == 1 ? isItemFuel(par2ItemStack) : true); + } + + public int[] getAccessibleSlotsFromSide(int par1) + { + return par1 == 0 ? slotsBottom : (par1 == 1 ? slotsTop : slotsSides); + } + + public boolean canInsertItem(int par1, ItemStack par2ItemStack, int par3) + { + return this.isItemValidForSlot(par1, par2ItemStack); + } + + public boolean canExtractItem(int par1, ItemStack par2ItemStack, int par3) + { + return par3 != 0 || par1 != 1 || par2ItemStack.getItem() == Items.bucket; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/tileentity/TileEntityHopper.java b/src/main/java/net/minecraft/tileentity/TileEntityHopper.java new file mode 100644 index 0000000..26e5627 --- /dev/null +++ b/src/main/java/net/minecraft/tileentity/TileEntityHopper.java @@ -0,0 +1,519 @@ +package net.minecraft.tileentity; + +import java.util.List; +import net.minecraft.block.Block; +import net.minecraft.block.BlockChest; +import net.minecraft.block.BlockHopper; +import net.minecraft.command.IEntitySelector; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.Facing; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class TileEntityHopper extends TileEntity implements IHopper +{ + private ItemStack[] field_145900_a = new ItemStack[5]; + private String field_145902_i; + private int field_145901_j = -1; + private static final String __OBFID = "CL_00000359"; + + public void readFromNBT(NBTTagCompound p_145839_1_) + { + super.readFromNBT(p_145839_1_); + NBTTagList nbttaglist = p_145839_1_.getTagList("Items", 10); + this.field_145900_a = new ItemStack[this.getSizeInventory()]; + + if (p_145839_1_.hasKey("CustomName", 8)) + { + this.field_145902_i = p_145839_1_.getString("CustomName"); + } + + this.field_145901_j = p_145839_1_.getInteger("TransferCooldown"); + + for (int i = 0; i < nbttaglist.tagCount(); ++i) + { + NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); + byte b0 = nbttagcompound1.getByte("Slot"); + + if (b0 >= 0 && b0 < this.field_145900_a.length) + { + this.field_145900_a[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1); + } + } + } + + public void writeToNBT(NBTTagCompound p_145841_1_) + { + super.writeToNBT(p_145841_1_); + NBTTagList nbttaglist = new NBTTagList(); + + for (int i = 0; i < this.field_145900_a.length; ++i) + { + if (this.field_145900_a[i] != null) + { + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + nbttagcompound1.setByte("Slot", (byte)i); + this.field_145900_a[i].writeToNBT(nbttagcompound1); + nbttaglist.appendTag(nbttagcompound1); + } + } + + p_145841_1_.setTag("Items", nbttaglist); + p_145841_1_.setInteger("TransferCooldown", this.field_145901_j); + + if (this.hasCustomInventoryName()) + { + p_145841_1_.setString("CustomName", this.field_145902_i); + } + } + + public void markDirty() + { + super.markDirty(); + } + + public int getSizeInventory() + { + return this.field_145900_a.length; + } + + public ItemStack getStackInSlot(int par1) + { + return this.field_145900_a[par1]; + } + + public ItemStack decrStackSize(int par1, int par2) + { + if (this.field_145900_a[par1] != null) + { + ItemStack itemstack; + + if (this.field_145900_a[par1].stackSize <= par2) + { + itemstack = this.field_145900_a[par1]; + this.field_145900_a[par1] = null; + return itemstack; + } + else + { + itemstack = this.field_145900_a[par1].splitStack(par2); + + if (this.field_145900_a[par1].stackSize == 0) + { + this.field_145900_a[par1] = null; + } + + return itemstack; + } + } + else + { + return null; + } + } + + public ItemStack getStackInSlotOnClosing(int par1) + { + if (this.field_145900_a[par1] != null) + { + ItemStack itemstack = this.field_145900_a[par1]; + this.field_145900_a[par1] = null; + return itemstack; + } + else + { + return null; + } + } + + public void setInventorySlotContents(int par1, ItemStack par2ItemStack) + { + this.field_145900_a[par1] = par2ItemStack; + + if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit()) + { + par2ItemStack.stackSize = this.getInventoryStackLimit(); + } + } + + public String getInventoryName() + { + return this.hasCustomInventoryName() ? this.field_145902_i : "container.hopper"; + } + + public boolean hasCustomInventoryName() + { + return this.field_145902_i != null && this.field_145902_i.length() > 0; + } + + public void func_145886_a(String p_145886_1_) + { + this.field_145902_i = p_145886_1_; + } + + public int getInventoryStackLimit() + { + return 64; + } + + public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) + { + return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D; + } + + public void openInventory() {} + + public void closeInventory() {} + + public boolean isItemValidForSlot(int par1, ItemStack par2ItemStack) + { + return true; + } + + public void updateEntity() + { + if (this.worldObj != null && !this.worldObj.isRemote) + { + --this.field_145901_j; + + if (!this.func_145888_j()) + { + this.func_145896_c(0); + this.func_145887_i(); + } + } + } + + public boolean func_145887_i() + { + if (this.worldObj != null && !this.worldObj.isRemote) + { + if (!this.func_145888_j() && BlockHopper.func_149917_c(this.getBlockMetadata())) + { + boolean flag = this.func_145883_k(); + flag = func_145891_a(this) || flag; + + if (flag) + { + this.func_145896_c(8); + this.markDirty(); + return true; + } + } + + return false; + } + else + { + return false; + } + } + + private boolean func_145883_k() + { + IInventory iinventory = this.func_145895_l(); + + if (iinventory == null) + { + return false; + } + else + { + for (int i = 0; i < this.getSizeInventory(); ++i) + { + if (this.getStackInSlot(i) != null) + { + ItemStack itemstack = this.getStackInSlot(i).copy(); + ItemStack itemstack1 = func_145889_a(iinventory, this.decrStackSize(i, 1), Facing.oppositeSide[BlockHopper.getDirectionFromMetadata(this.getBlockMetadata())]); + + if (itemstack1 == null || itemstack1.stackSize == 0) + { + iinventory.markDirty(); + return true; + } + + this.setInventorySlotContents(i, itemstack); + } + } + + return false; + } + } + + public static boolean func_145891_a(IHopper p_145891_0_) + { + IInventory iinventory = func_145884_b(p_145891_0_); + + if (iinventory != null) + { + byte b0 = 0; + + if (iinventory instanceof ISidedInventory && b0 > -1) + { + ISidedInventory isidedinventory = (ISidedInventory)iinventory; + int[] aint = isidedinventory.getAccessibleSlotsFromSide(b0); + + for (int k = 0; k < aint.length; ++k) + { + if (func_145892_a(p_145891_0_, iinventory, aint[k], b0)) + { + return true; + } + } + } + else + { + int i = iinventory.getSizeInventory(); + + for (int j = 0; j < i; ++j) + { + if (func_145892_a(p_145891_0_, iinventory, j, b0)) + { + return true; + } + } + } + } + else + { + EntityItem entityitem = func_145897_a(p_145891_0_.getWorldObj(), p_145891_0_.getXPos(), p_145891_0_.getYPos() + 1.0D, p_145891_0_.getZPos()); + + if (entityitem != null) + { + return func_145898_a(p_145891_0_, entityitem); + } + } + + return false; + } + + private static boolean func_145892_a(IHopper p_145892_0_, IInventory p_145892_1_, int p_145892_2_, int p_145892_3_) + { + ItemStack itemstack = p_145892_1_.getStackInSlot(p_145892_2_); + + if (itemstack != null && func_145890_b(p_145892_1_, itemstack, p_145892_2_, p_145892_3_)) + { + ItemStack itemstack1 = itemstack.copy(); + ItemStack itemstack2 = func_145889_a(p_145892_0_, p_145892_1_.decrStackSize(p_145892_2_, 1), -1); + + if (itemstack2 == null || itemstack2.stackSize == 0) + { + p_145892_1_.markDirty(); + return true; + } + + p_145892_1_.setInventorySlotContents(p_145892_2_, itemstack1); + } + + return false; + } + + public static boolean func_145898_a(IInventory p_145898_0_, EntityItem p_145898_1_) + { + boolean flag = false; + + if (p_145898_1_ == null) + { + return false; + } + else + { + ItemStack itemstack = p_145898_1_.getEntityItem().copy(); + ItemStack itemstack1 = func_145889_a(p_145898_0_, itemstack, -1); + + if (itemstack1 != null && itemstack1.stackSize != 0) + { + p_145898_1_.setEntityItemStack(itemstack1); + } + else + { + flag = true; + p_145898_1_.setDead(); + } + + return flag; + } + } + + public static ItemStack func_145889_a(IInventory p_145889_0_, ItemStack p_145889_1_, int p_145889_2_) + { + if (p_145889_0_ instanceof ISidedInventory && p_145889_2_ > -1) + { + ISidedInventory isidedinventory = (ISidedInventory)p_145889_0_; + int[] aint = isidedinventory.getAccessibleSlotsFromSide(p_145889_2_); + + for (int l = 0; l < aint.length && p_145889_1_ != null && p_145889_1_.stackSize > 0; ++l) + { + p_145889_1_ = func_145899_c(p_145889_0_, p_145889_1_, aint[l], p_145889_2_); + } + } + else + { + int j = p_145889_0_.getSizeInventory(); + + for (int k = 0; k < j && p_145889_1_ != null && p_145889_1_.stackSize > 0; ++k) + { + p_145889_1_ = func_145899_c(p_145889_0_, p_145889_1_, k, p_145889_2_); + } + } + + if (p_145889_1_ != null && p_145889_1_.stackSize == 0) + { + p_145889_1_ = null; + } + + return p_145889_1_; + } + + private static boolean func_145885_a(IInventory p_145885_0_, ItemStack p_145885_1_, int p_145885_2_, int p_145885_3_) + { + return !p_145885_0_.isItemValidForSlot(p_145885_2_, p_145885_1_) ? false : !(p_145885_0_ instanceof ISidedInventory) || ((ISidedInventory)p_145885_0_).canInsertItem(p_145885_2_, p_145885_1_, p_145885_3_); + } + + private static boolean func_145890_b(IInventory p_145890_0_, ItemStack p_145890_1_, int p_145890_2_, int p_145890_3_) + { + return !(p_145890_0_ instanceof ISidedInventory) || ((ISidedInventory)p_145890_0_).canExtractItem(p_145890_2_, p_145890_1_, p_145890_3_); + } + + private static ItemStack func_145899_c(IInventory p_145899_0_, ItemStack p_145899_1_, int p_145899_2_, int p_145899_3_) + { + ItemStack itemstack1 = p_145899_0_.getStackInSlot(p_145899_2_); + + if (func_145885_a(p_145899_0_, p_145899_1_, p_145899_2_, p_145899_3_)) + { + boolean flag = false; + + if (itemstack1 == null) + { + //Forge: BUGFIX: Again, make things respect max stack sizes. + int max = Math.min(p_145899_1_.getMaxStackSize(), p_145899_0_.getInventoryStackLimit()); + if (max >= p_145899_1_.stackSize) + { + p_145899_0_.setInventorySlotContents(p_145899_2_, p_145899_1_); + p_145899_1_ = null; + } + else + { + p_145899_0_.setInventorySlotContents(p_145899_2_, p_145899_1_.splitStack(max)); + } + flag = true; + } + else if (func_145894_a(itemstack1, p_145899_1_)) + { + //Forge: BUGFIX: Again, make things respect max stack sizes. + int max = Math.min(p_145899_1_.getMaxStackSize(), p_145899_0_.getInventoryStackLimit()); + if (max > itemstack1.stackSize) + { + int l = Math.min(p_145899_1_.stackSize, max - itemstack1.stackSize); + p_145899_1_.stackSize -= l; + itemstack1.stackSize += l; + flag = l > 0; + } + } + + if (flag) + { + if (p_145899_0_ instanceof TileEntityHopper) + { + ((TileEntityHopper)p_145899_0_).func_145896_c(8); + p_145899_0_.markDirty(); + } + + p_145899_0_.markDirty(); + } + } + + return p_145899_1_; + } + + private IInventory func_145895_l() + { + int i = BlockHopper.getDirectionFromMetadata(this.getBlockMetadata()); + return func_145893_b(this.getWorldObj(), (double)(this.xCoord + Facing.offsetsXForSide[i]), (double)(this.yCoord + Facing.offsetsYForSide[i]), (double)(this.zCoord + Facing.offsetsZForSide[i])); + } + + public static IInventory func_145884_b(IHopper p_145884_0_) + { + return func_145893_b(p_145884_0_.getWorldObj(), p_145884_0_.getXPos(), p_145884_0_.getYPos() + 1.0D, p_145884_0_.getZPos()); + } + + public static EntityItem func_145897_a(World p_145897_0_, double p_145897_1_, double p_145897_3_, double p_145897_5_) + { + List list = p_145897_0_.selectEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getAABBPool().getAABB(p_145897_1_, p_145897_3_, p_145897_5_, p_145897_1_ + 1.0D, p_145897_3_ + 1.0D, p_145897_5_ + 1.0D), IEntitySelector.selectAnything); + return list.size() > 0 ? (EntityItem)list.get(0) : null; + } + + public static IInventory func_145893_b(World p_145893_0_, double p_145893_1_, double p_145893_3_, double p_145893_5_) + { + IInventory iinventory = null; + int i = MathHelper.floor_double(p_145893_1_); + int j = MathHelper.floor_double(p_145893_3_); + int k = MathHelper.floor_double(p_145893_5_); + TileEntity tileentity = p_145893_0_.getTileEntity(i, j, k); + + if (tileentity != null && tileentity instanceof IInventory) + { + iinventory = (IInventory)tileentity; + + if (iinventory instanceof TileEntityChest) + { + Block block = p_145893_0_.getBlock(i, j, k); + + if (block instanceof BlockChest) + { + iinventory = ((BlockChest)block).func_149951_m(p_145893_0_, i, j, k); + } + } + } + + if (iinventory == null) + { + List list = p_145893_0_.getEntitiesWithinAABBExcludingEntity((Entity)null, AxisAlignedBB.getAABBPool().getAABB(p_145893_1_, p_145893_3_, p_145893_5_, p_145893_1_ + 1.0D, p_145893_3_ + 1.0D, p_145893_5_ + 1.0D), IEntitySelector.selectInventories); + + if (list != null && list.size() > 0) + { + iinventory = (IInventory)list.get(p_145893_0_.rand.nextInt(list.size())); + } + } + + return iinventory; + } + + private static boolean func_145894_a(ItemStack p_145894_0_, ItemStack p_145894_1_) + { + return p_145894_0_.getItem() != p_145894_1_.getItem() ? false : (p_145894_0_.getItemDamage() != p_145894_1_.getItemDamage() ? false : (p_145894_0_.stackSize > p_145894_0_.getMaxStackSize() ? false : ItemStack.areItemStackTagsEqual(p_145894_0_, p_145894_1_))); + } + + public double getXPos() + { + return (double)this.xCoord; + } + + public double getYPos() + { + return (double)this.yCoord; + } + + public double getZPos() + { + return (double)this.zCoord; + } + + public void func_145896_c(int p_145896_1_) + { + this.field_145901_j = p_145896_1_; + } + + public boolean func_145888_j() + { + return this.field_145901_j > 0; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/tileentity/TileEntityMobSpawner.java b/src/main/java/net/minecraft/tileentity/TileEntityMobSpawner.java new file mode 100644 index 0000000..7b931a9 --- /dev/null +++ b/src/main/java/net/minecraft/tileentity/TileEntityMobSpawner.java @@ -0,0 +1,81 @@ +package net.minecraft.tileentity; + +import net.minecraft.init.Blocks; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.world.World; + +public class TileEntityMobSpawner extends TileEntity +{ + private final MobSpawnerBaseLogic field_145882_a = new MobSpawnerBaseLogic() + { + private static final String __OBFID = "CL_00000361"; + public void func_98267_a(int par1) + { + TileEntityMobSpawner.this.worldObj.addBlockEvent(TileEntityMobSpawner.this.xCoord, TileEntityMobSpawner.this.yCoord, TileEntityMobSpawner.this.zCoord, Blocks.mob_spawner, par1, 0); + } + public World getSpawnerWorld() + { + return TileEntityMobSpawner.this.worldObj; + } + public int getSpawnerX() + { + return TileEntityMobSpawner.this.xCoord; + } + public int getSpawnerY() + { + return TileEntityMobSpawner.this.yCoord; + } + public int getSpawnerZ() + { + return TileEntityMobSpawner.this.zCoord; + } + public void setRandomEntity(MobSpawnerBaseLogic.WeightedRandomMinecart par1WeightedRandomMinecart) + { + super.setRandomEntity(par1WeightedRandomMinecart); + + if (this.getSpawnerWorld() != null) + { + this.getSpawnerWorld().markBlockForUpdate(TileEntityMobSpawner.this.xCoord, TileEntityMobSpawner.this.yCoord, TileEntityMobSpawner.this.zCoord); + } + } + }; + private static final String __OBFID = "CL_00000360"; + + public void readFromNBT(NBTTagCompound p_145839_1_) + { + super.readFromNBT(p_145839_1_); + this.field_145882_a.readFromNBT(p_145839_1_); + } + + public void writeToNBT(NBTTagCompound p_145841_1_) + { + super.writeToNBT(p_145841_1_); + this.field_145882_a.writeToNBT(p_145841_1_); + } + + public void updateEntity() + { + this.field_145882_a.updateSpawner(); + super.updateEntity(); + } + + public Packet getDescriptionPacket() + { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + this.writeToNBT(nbttagcompound); + nbttagcompound.removeTag("SpawnPotentials"); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, nbttagcompound); + } + + public boolean receiveClientEvent(int p_145842_1_, int p_145842_2_) + { + return this.field_145882_a.setDelayToMin(p_145842_1_) ? true : super.receiveClientEvent(p_145842_1_, p_145842_2_); + } + + public MobSpawnerBaseLogic func_145881_a() + { + return this.field_145882_a; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/tileentity/TileEntityNote.java b/src/main/java/net/minecraft/tileentity/TileEntityNote.java new file mode 100644 index 0000000..2ac498d --- /dev/null +++ b/src/main/java/net/minecraft/tileentity/TileEntityNote.java @@ -0,0 +1,72 @@ +package net.minecraft.tileentity; + +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +public class TileEntityNote extends TileEntity +{ + public byte note; + public boolean previousRedstoneState; + private static final String __OBFID = "CL_00000362"; + + public void writeToNBT(NBTTagCompound p_145841_1_) + { + super.writeToNBT(p_145841_1_); + p_145841_1_.setByte("note", this.note); + } + + public void readFromNBT(NBTTagCompound p_145839_1_) + { + super.readFromNBT(p_145839_1_); + this.note = p_145839_1_.getByte("note"); + + if (this.note < 0) + { + this.note = 0; + } + + if (this.note > 24) + { + this.note = 24; + } + } + + public void changePitch() + { + this.note = (byte)((this.note + 1) % 25); + this.markDirty(); + } + + public void triggerNote(World p_145878_1_, int p_145878_2_, int p_145878_3_, int p_145878_4_) + { + if (p_145878_1_.getBlock(p_145878_2_, p_145878_3_ + 1, p_145878_4_).getMaterial() == Material.air) + { + Material material = p_145878_1_.getBlock(p_145878_2_, p_145878_3_ - 1, p_145878_4_).getMaterial(); + byte b0 = 0; + + if (material == Material.rock) + { + b0 = 1; + } + + if (material == Material.sand) + { + b0 = 2; + } + + if (material == Material.glass) + { + b0 = 3; + } + + if (material == Material.wood) + { + b0 = 4; + } + + p_145878_1_.addBlockEvent(p_145878_2_, p_145878_3_, p_145878_4_, Blocks.noteblock, b0, this.note); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/tileentity/TileEntityPiston.java b/src/main/java/net/minecraft/tileentity/TileEntityPiston.java new file mode 100644 index 0000000..3a266c0 --- /dev/null +++ b/src/main/java/net/minecraft/tileentity/TileEntityPiston.java @@ -0,0 +1,192 @@ +package net.minecraft.tileentity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.init.Blocks; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.Facing; + +public class TileEntityPiston extends TileEntity +{ + private Block storedBlock; + private int storedMetadata; + private int storedOrientation; + private boolean extending; + private boolean shouldHeadBeRendered; + private float progress; + private float lastProgress; + private List pushedObjects = new ArrayList(); + private static final String __OBFID = "CL_00000369"; + + public TileEntityPiston() {} + + public TileEntityPiston(Block p_i45444_1_, int p_i45444_2_, int p_i45444_3_, boolean p_i45444_4_, boolean p_i45444_5_) + { + this.storedBlock = p_i45444_1_; + this.storedMetadata = p_i45444_2_; + this.storedOrientation = p_i45444_3_; + this.extending = p_i45444_4_; + this.shouldHeadBeRendered = p_i45444_5_; + } + + public Block getStoredBlockID() + { + return this.storedBlock; + } + + public int getBlockMetadata() + { + return this.storedMetadata; + } + + public boolean isExtending() + { + return this.extending; + } + + public int getPistonOrientation() + { + return this.storedOrientation; + } + + @SideOnly(Side.CLIENT) + public boolean func_145867_d() + { + return this.shouldHeadBeRendered; + } + + public float func_145860_a(float p_145860_1_) + { + if (p_145860_1_ > 1.0F) + { + p_145860_1_ = 1.0F; + } + + return this.lastProgress + (this.progress - this.lastProgress) * p_145860_1_; + } + + private void func_145863_a(float p_145863_1_, float p_145863_2_) + { + if (this.extending) + { + p_145863_1_ = 1.0F - p_145863_1_; + } + else + { + --p_145863_1_; + } + + AxisAlignedBB axisalignedbb = Blocks.piston_extension.func_149964_a(this.worldObj, this.xCoord, this.yCoord, this.zCoord, this.storedBlock, p_145863_1_, this.storedOrientation); + + if (axisalignedbb != null) + { + List list = this.worldObj.getEntitiesWithinAABBExcludingEntity((Entity)null, axisalignedbb); + + if (!list.isEmpty()) + { + this.pushedObjects.addAll(list); + Iterator iterator = this.pushedObjects.iterator(); + + while (iterator.hasNext()) + { + Entity entity = (Entity)iterator.next(); + entity.moveEntity((double)(p_145863_2_ * (float)Facing.offsetsXForSide[this.storedOrientation]), (double)(p_145863_2_ * (float)Facing.offsetsYForSide[this.storedOrientation]), (double)(p_145863_2_ * (float)Facing.offsetsZForSide[this.storedOrientation])); + } + + this.pushedObjects.clear(); + } + } + } + + @SideOnly(Side.CLIENT) + public float func_145865_b(float p_145865_1_) + { + return this.extending ? (this.func_145860_a(p_145865_1_) - 1.0F) * (float)Facing.offsetsXForSide[this.storedOrientation] : (1.0F - this.func_145860_a(p_145865_1_)) * (float)Facing.offsetsXForSide[this.storedOrientation]; + } + + @SideOnly(Side.CLIENT) + public float func_145862_c(float p_145862_1_) + { + return this.extending ? (this.func_145860_a(p_145862_1_) - 1.0F) * (float)Facing.offsetsYForSide[this.storedOrientation] : (1.0F - this.func_145860_a(p_145862_1_)) * (float)Facing.offsetsYForSide[this.storedOrientation]; + } + + @SideOnly(Side.CLIENT) + public float func_145859_d(float p_145859_1_) + { + return this.extending ? (this.func_145860_a(p_145859_1_) - 1.0F) * (float)Facing.offsetsZForSide[this.storedOrientation] : (1.0F - this.func_145860_a(p_145859_1_)) * (float)Facing.offsetsZForSide[this.storedOrientation]; + } + + public void clearPistonTileEntity() + { + if (this.lastProgress < 1.0F && this.worldObj != null) + { + this.lastProgress = this.progress = 1.0F; + this.worldObj.removeTileEntity(this.xCoord, this.yCoord, this.zCoord); + this.invalidate(); + + if (this.worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord) == Blocks.piston_extension) + { + this.worldObj.setBlock(this.xCoord, this.yCoord, this.zCoord, this.storedBlock, this.storedMetadata, 3); + this.worldObj.notifyBlockOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.storedBlock); + } + } + } + + public void updateEntity() + { + this.lastProgress = this.progress; + + if (this.lastProgress >= 1.0F) + { + this.func_145863_a(1.0F, 0.25F); + this.worldObj.removeTileEntity(this.xCoord, this.yCoord, this.zCoord); + this.invalidate(); + + if (this.worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord) == Blocks.piston_extension) + { + this.worldObj.setBlock(this.xCoord, this.yCoord, this.zCoord, this.storedBlock, this.storedMetadata, 3); + this.worldObj.notifyBlockOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.storedBlock); + } + } + else + { + this.progress += 0.5F; + + if (this.progress >= 1.0F) + { + this.progress = 1.0F; + } + + if (this.extending) + { + this.func_145863_a(this.progress, this.progress - this.lastProgress + 0.0625F); + } + } + } + + public void readFromNBT(NBTTagCompound p_145839_1_) + { + super.readFromNBT(p_145839_1_); + this.storedBlock = Block.getBlockById(p_145839_1_.getInteger("blockId")); + this.storedMetadata = p_145839_1_.getInteger("blockData"); + this.storedOrientation = p_145839_1_.getInteger("facing"); + this.lastProgress = this.progress = p_145839_1_.getFloat("progress"); + this.extending = p_145839_1_.getBoolean("extending"); + } + + public void writeToNBT(NBTTagCompound p_145841_1_) + { + super.writeToNBT(p_145841_1_); + p_145841_1_.setInteger("blockId", Block.getIdFromBlock(this.storedBlock)); + p_145841_1_.setInteger("blockData", this.storedMetadata); + p_145841_1_.setInteger("facing", this.storedOrientation); + p_145841_1_.setFloat("progress", this.lastProgress); + p_145841_1_.setBoolean("extending", this.extending); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/tileentity/TileEntitySign.java b/src/main/java/net/minecraft/tileentity/TileEntitySign.java new file mode 100644 index 0000000..0fd9367 --- /dev/null +++ b/src/main/java/net/minecraft/tileentity/TileEntitySign.java @@ -0,0 +1,75 @@ +package net.minecraft.tileentity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S33PacketUpdateSign; + +public class TileEntitySign extends TileEntity +{ + public String[] signText = new String[] {"", "", "", ""}; + public int lineBeingEdited = -1; + private boolean field_145916_j = true; + private EntityPlayer field_145917_k; + private static final String __OBFID = "CL_00000363"; + + public void writeToNBT(NBTTagCompound p_145841_1_) + { + super.writeToNBT(p_145841_1_); + p_145841_1_.setString("Text1", this.signText[0]); + p_145841_1_.setString("Text2", this.signText[1]); + p_145841_1_.setString("Text3", this.signText[2]); + p_145841_1_.setString("Text4", this.signText[3]); + } + + public void readFromNBT(NBTTagCompound p_145839_1_) + { + this.field_145916_j = false; + super.readFromNBT(p_145839_1_); + + for (int i = 0; i < 4; ++i) + { + this.signText[i] = p_145839_1_.getString("Text" + (i + 1)); + + if (this.signText[i].length() > 15) + { + this.signText[i] = this.signText[i].substring(0, 15); + } + } + } + + public Packet getDescriptionPacket() + { + String[] astring = new String[4]; + System.arraycopy(this.signText, 0, astring, 0, 4); + return new S33PacketUpdateSign(this.xCoord, this.yCoord, this.zCoord, astring); + } + + public boolean func_145914_a() + { + return this.field_145916_j; + } + + @SideOnly(Side.CLIENT) + public void setEditable(boolean p_145913_1_) + { + this.field_145916_j = p_145913_1_; + + if (!p_145913_1_) + { + this.field_145917_k = null; + } + } + + public void func_145912_a(EntityPlayer p_145912_1_) + { + this.field_145917_k = p_145912_1_; + } + + public EntityPlayer func_145911_b() + { + return this.field_145917_k; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/tileentity/TileEntitySkull.java b/src/main/java/net/minecraft/tileentity/TileEntitySkull.java new file mode 100644 index 0000000..a7ba0aa --- /dev/null +++ b/src/main/java/net/minecraft/tileentity/TileEntitySkull.java @@ -0,0 +1,69 @@ +package net.minecraft.tileentity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; + +public class TileEntitySkull extends TileEntity +{ + private int field_145908_a; + private int field_145910_i; + private String field_145909_j = ""; + private static final String __OBFID = "CL_00000364"; + + public void writeToNBT(NBTTagCompound p_145841_1_) + { + super.writeToNBT(p_145841_1_); + p_145841_1_.setByte("SkullType", (byte)(this.field_145908_a & 255)); + p_145841_1_.setByte("Rot", (byte)(this.field_145910_i & 255)); + p_145841_1_.setString("ExtraType", this.field_145909_j); + } + + public void readFromNBT(NBTTagCompound p_145839_1_) + { + super.readFromNBT(p_145839_1_); + this.field_145908_a = p_145839_1_.getByte("SkullType"); + this.field_145910_i = p_145839_1_.getByte("Rot"); + + if (p_145839_1_.hasKey("ExtraType", 8)) + { + this.field_145909_j = p_145839_1_.getString("ExtraType"); + } + } + + public Packet getDescriptionPacket() + { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + this.writeToNBT(nbttagcompound); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 4, nbttagcompound); + } + + public void func_145905_a(int p_145905_1_, String p_145905_2_) + { + this.field_145908_a = p_145905_1_; + this.field_145909_j = p_145905_2_; + } + + public int func_145904_a() + { + return this.field_145908_a; + } + + public void func_145903_a(int p_145903_1_) + { + this.field_145910_i = p_145903_1_; + } + + @SideOnly(Side.CLIENT) + public int func_145906_b() + { + return this.field_145910_i; + } + + public String func_145907_c() + { + return this.field_145909_j; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/AABBPool.java b/src/main/java/net/minecraft/util/AABBPool.java new file mode 100644 index 0000000..8550c3a --- /dev/null +++ b/src/main/java/net/minecraft/util/AABBPool.java @@ -0,0 +1,82 @@ +package net.minecraft.util; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.List; + +public class AABBPool +{ + private final int maxNumCleans; + private final int numEntriesToRemove; + private final List listAABB = new ArrayList(); + private int nextPoolIndex; + private int maxPoolIndex; + private int numCleans; + private static final String __OBFID = "CL_00000609"; + + public AABBPool(int par1, int par2) + { + this.maxNumCleans = par1; + this.numEntriesToRemove = par2; + } + + public AxisAlignedBB getAABB(double par1, double par3, double par5, double par7, double par9, double par11) + { + AxisAlignedBB axisalignedbb; + + if (this.nextPoolIndex >= this.listAABB.size()) + { + axisalignedbb = new AxisAlignedBB(par1, par3, par5, par7, par9, par11); + this.listAABB.add(axisalignedbb); + } + else + { + axisalignedbb = (AxisAlignedBB)this.listAABB.get(this.nextPoolIndex); + axisalignedbb.setBounds(par1, par3, par5, par7, par9, par11); + } + + ++this.nextPoolIndex; + return axisalignedbb; + } + + public void cleanPool() + { + if (this.nextPoolIndex > this.maxPoolIndex) + { + this.maxPoolIndex = this.nextPoolIndex; + } + + if (this.numCleans++ == this.maxNumCleans) + { + int i = Math.max(this.maxPoolIndex, this.listAABB.size() - this.numEntriesToRemove); + + while (this.listAABB.size() > i) + { + this.listAABB.remove(i); + } + + this.maxPoolIndex = 0; + this.numCleans = 0; + } + + this.nextPoolIndex = 0; + } + + @SideOnly(Side.CLIENT) + public void clearPool() + { + this.nextPoolIndex = 0; + this.listAABB.clear(); + } + + public int getlistAABBsize() + { + return this.listAABB.size(); + } + + public int getnextPoolIndex() + { + return this.nextPoolIndex; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/AxisAlignedBB.java b/src/main/java/net/minecraft/util/AxisAlignedBB.java new file mode 100644 index 0000000..740650b --- /dev/null +++ b/src/main/java/net/minecraft/util/AxisAlignedBB.java @@ -0,0 +1,431 @@ +package net.minecraft.util; + +public class AxisAlignedBB +{ + private static final ThreadLocal theAABBLocalPool = new ThreadLocal() + { + private static final String __OBFID = "CL_00000608"; + protected AABBPool initialValue() + { + return new AABBPool(300, 2000); + } + }; + public double minX; + public double minY; + public double minZ; + public double maxX; + public double maxY; + public double maxZ; + private static final String __OBFID = "CL_00000607"; + + public static AxisAlignedBB getBoundingBox(double par0, double par2, double par4, double par6, double par8, double par10) + { + return new AxisAlignedBB(par0, par2, par4, par6, par8, par10); + } + + public static AABBPool getAABBPool() + { + return (AABBPool)theAABBLocalPool.get(); + } + + protected AxisAlignedBB(double par1, double par3, double par5, double par7, double par9, double par11) + { + this.minX = par1; + this.minY = par3; + this.minZ = par5; + this.maxX = par7; + this.maxY = par9; + this.maxZ = par11; + } + + public AxisAlignedBB setBounds(double par1, double par3, double par5, double par7, double par9, double par11) + { + this.minX = par1; + this.minY = par3; + this.minZ = par5; + this.maxX = par7; + this.maxY = par9; + this.maxZ = par11; + return this; + } + + public AxisAlignedBB addCoord(double par1, double par3, double par5) + { + double d3 = this.minX; + double d4 = this.minY; + double d5 = this.minZ; + double d6 = this.maxX; + double d7 = this.maxY; + double d8 = this.maxZ; + + if (par1 < 0.0D) + { + d3 += par1; + } + + if (par1 > 0.0D) + { + d6 += par1; + } + + if (par3 < 0.0D) + { + d4 += par3; + } + + if (par3 > 0.0D) + { + d7 += par3; + } + + if (par5 < 0.0D) + { + d5 += par5; + } + + if (par5 > 0.0D) + { + d8 += par5; + } + + return getAABBPool().getAABB(d3, d4, d5, d6, d7, d8); + } + + public AxisAlignedBB expand(double par1, double par3, double par5) + { + double d3 = this.minX - par1; + double d4 = this.minY - par3; + double d5 = this.minZ - par5; + double d6 = this.maxX + par1; + double d7 = this.maxY + par3; + double d8 = this.maxZ + par5; + return getAABBPool().getAABB(d3, d4, d5, d6, d7, d8); + } + + public AxisAlignedBB func_111270_a(AxisAlignedBB par1AxisAlignedBB) + { + double d0 = Math.min(this.minX, par1AxisAlignedBB.minX); + double d1 = Math.min(this.minY, par1AxisAlignedBB.minY); + double d2 = Math.min(this.minZ, par1AxisAlignedBB.minZ); + double d3 = Math.max(this.maxX, par1AxisAlignedBB.maxX); + double d4 = Math.max(this.maxY, par1AxisAlignedBB.maxY); + double d5 = Math.max(this.maxZ, par1AxisAlignedBB.maxZ); + return getAABBPool().getAABB(d0, d1, d2, d3, d4, d5); + } + + public AxisAlignedBB getOffsetBoundingBox(double par1, double par3, double par5) + { + return getAABBPool().getAABB(this.minX + par1, this.minY + par3, this.minZ + par5, this.maxX + par1, this.maxY + par3, this.maxZ + par5); + } + + public double calculateXOffset(AxisAlignedBB par1AxisAlignedBB, double par2) + { + if (par1AxisAlignedBB.maxY > this.minY && par1AxisAlignedBB.minY < this.maxY) + { + if (par1AxisAlignedBB.maxZ > this.minZ && par1AxisAlignedBB.minZ < this.maxZ) + { + double d1; + + if (par2 > 0.0D && par1AxisAlignedBB.maxX <= this.minX) + { + d1 = this.minX - par1AxisAlignedBB.maxX; + + if (d1 < par2) + { + par2 = d1; + } + } + + if (par2 < 0.0D && par1AxisAlignedBB.minX >= this.maxX) + { + d1 = this.maxX - par1AxisAlignedBB.minX; + + if (d1 > par2) + { + par2 = d1; + } + } + + return par2; + } + else + { + return par2; + } + } + else + { + return par2; + } + } + + public double calculateYOffset(AxisAlignedBB par1AxisAlignedBB, double par2) + { + if (par1AxisAlignedBB.maxX > this.minX && par1AxisAlignedBB.minX < this.maxX) + { + if (par1AxisAlignedBB.maxZ > this.minZ && par1AxisAlignedBB.minZ < this.maxZ) + { + double d1; + + if (par2 > 0.0D && par1AxisAlignedBB.maxY <= this.minY) + { + d1 = this.minY - par1AxisAlignedBB.maxY; + + if (d1 < par2) + { + par2 = d1; + } + } + + if (par2 < 0.0D && par1AxisAlignedBB.minY >= this.maxY) + { + d1 = this.maxY - par1AxisAlignedBB.minY; + + if (d1 > par2) + { + par2 = d1; + } + } + + return par2; + } + else + { + return par2; + } + } + else + { + return par2; + } + } + + public double calculateZOffset(AxisAlignedBB par1AxisAlignedBB, double par2) + { + if (par1AxisAlignedBB.maxX > this.minX && par1AxisAlignedBB.minX < this.maxX) + { + if (par1AxisAlignedBB.maxY > this.minY && par1AxisAlignedBB.minY < this.maxY) + { + double d1; + + if (par2 > 0.0D && par1AxisAlignedBB.maxZ <= this.minZ) + { + d1 = this.minZ - par1AxisAlignedBB.maxZ; + + if (d1 < par2) + { + par2 = d1; + } + } + + if (par2 < 0.0D && par1AxisAlignedBB.minZ >= this.maxZ) + { + d1 = this.maxZ - par1AxisAlignedBB.minZ; + + if (d1 > par2) + { + par2 = d1; + } + } + + return par2; + } + else + { + return par2; + } + } + else + { + return par2; + } + } + + public boolean intersectsWith(AxisAlignedBB par1AxisAlignedBB) + { + return par1AxisAlignedBB.maxX > this.minX && par1AxisAlignedBB.minX < this.maxX ? (par1AxisAlignedBB.maxY > this.minY && par1AxisAlignedBB.minY < this.maxY ? par1AxisAlignedBB.maxZ > this.minZ && par1AxisAlignedBB.minZ < this.maxZ : false) : false; + } + + public AxisAlignedBB offset(double par1, double par3, double par5) + { + this.minX += par1; + this.minY += par3; + this.minZ += par5; + this.maxX += par1; + this.maxY += par3; + this.maxZ += par5; + return this; + } + + public boolean isVecInside(Vec3 par1Vec3) + { + return par1Vec3.xCoord > this.minX && par1Vec3.xCoord < this.maxX ? (par1Vec3.yCoord > this.minY && par1Vec3.yCoord < this.maxY ? par1Vec3.zCoord > this.minZ && par1Vec3.zCoord < this.maxZ : false) : false; + } + + public double getAverageEdgeLength() + { + double d0 = this.maxX - this.minX; + double d1 = this.maxY - this.minY; + double d2 = this.maxZ - this.minZ; + return (d0 + d1 + d2) / 3.0D; + } + + public AxisAlignedBB contract(double par1, double par3, double par5) + { + double d3 = this.minX + par1; + double d4 = this.minY + par3; + double d5 = this.minZ + par5; + double d6 = this.maxX - par1; + double d7 = this.maxY - par3; + double d8 = this.maxZ - par5; + return getAABBPool().getAABB(d3, d4, d5, d6, d7, d8); + } + + public AxisAlignedBB copy() + { + return getAABBPool().getAABB(this.minX, this.minY, this.minZ, this.maxX, this.maxY, this.maxZ); + } + + public MovingObjectPosition calculateIntercept(Vec3 par1Vec3, Vec3 par2Vec3) + { + Vec3 vec32 = par1Vec3.getIntermediateWithXValue(par2Vec3, this.minX); + Vec3 vec33 = par1Vec3.getIntermediateWithXValue(par2Vec3, this.maxX); + Vec3 vec34 = par1Vec3.getIntermediateWithYValue(par2Vec3, this.minY); + Vec3 vec35 = par1Vec3.getIntermediateWithYValue(par2Vec3, this.maxY); + Vec3 vec36 = par1Vec3.getIntermediateWithZValue(par2Vec3, this.minZ); + Vec3 vec37 = par1Vec3.getIntermediateWithZValue(par2Vec3, this.maxZ); + + if (!this.isVecInYZ(vec32)) + { + vec32 = null; + } + + if (!this.isVecInYZ(vec33)) + { + vec33 = null; + } + + if (!this.isVecInXZ(vec34)) + { + vec34 = null; + } + + if (!this.isVecInXZ(vec35)) + { + vec35 = null; + } + + if (!this.isVecInXY(vec36)) + { + vec36 = null; + } + + if (!this.isVecInXY(vec37)) + { + vec37 = null; + } + + Vec3 vec38 = null; + + if (vec32 != null && (vec38 == null || par1Vec3.squareDistanceTo(vec32) < par1Vec3.squareDistanceTo(vec38))) + { + vec38 = vec32; + } + + if (vec33 != null && (vec38 == null || par1Vec3.squareDistanceTo(vec33) < par1Vec3.squareDistanceTo(vec38))) + { + vec38 = vec33; + } + + if (vec34 != null && (vec38 == null || par1Vec3.squareDistanceTo(vec34) < par1Vec3.squareDistanceTo(vec38))) + { + vec38 = vec34; + } + + if (vec35 != null && (vec38 == null || par1Vec3.squareDistanceTo(vec35) < par1Vec3.squareDistanceTo(vec38))) + { + vec38 = vec35; + } + + if (vec36 != null && (vec38 == null || par1Vec3.squareDistanceTo(vec36) < par1Vec3.squareDistanceTo(vec38))) + { + vec38 = vec36; + } + + if (vec37 != null && (vec38 == null || par1Vec3.squareDistanceTo(vec37) < par1Vec3.squareDistanceTo(vec38))) + { + vec38 = vec37; + } + + if (vec38 == null) + { + return null; + } + else + { + byte b0 = -1; + + if (vec38 == vec32) + { + b0 = 4; + } + + if (vec38 == vec33) + { + b0 = 5; + } + + if (vec38 == vec34) + { + b0 = 0; + } + + if (vec38 == vec35) + { + b0 = 1; + } + + if (vec38 == vec36) + { + b0 = 2; + } + + if (vec38 == vec37) + { + b0 = 3; + } + + return new MovingObjectPosition(0, 0, 0, b0, vec38); + } + } + + private boolean isVecInYZ(Vec3 par1Vec3) + { + return par1Vec3 == null ? false : par1Vec3.yCoord >= this.minY && par1Vec3.yCoord <= this.maxY && par1Vec3.zCoord >= this.minZ && par1Vec3.zCoord <= this.maxZ; + } + + private boolean isVecInXZ(Vec3 par1Vec3) + { + return par1Vec3 == null ? false : par1Vec3.xCoord >= this.minX && par1Vec3.xCoord <= this.maxX && par1Vec3.zCoord >= this.minZ && par1Vec3.zCoord <= this.maxZ; + } + + private boolean isVecInXY(Vec3 par1Vec3) + { + return par1Vec3 == null ? false : par1Vec3.xCoord >= this.minX && par1Vec3.xCoord <= this.maxX && par1Vec3.yCoord >= this.minY && par1Vec3.yCoord <= this.maxY; + } + + public void setBB(AxisAlignedBB par1AxisAlignedBB) + { + this.minX = par1AxisAlignedBB.minX; + this.minY = par1AxisAlignedBB.minY; + this.minZ = par1AxisAlignedBB.minZ; + this.maxX = par1AxisAlignedBB.maxX; + this.maxY = par1AxisAlignedBB.maxY; + this.maxZ = par1AxisAlignedBB.maxZ; + } + + public String toString() + { + return "box[" + this.minX + ", " + this.minY + ", " + this.minZ + " -> " + this.maxX + ", " + this.maxY + ", " + this.maxZ + "]"; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/ChatAllowedCharacters.java b/src/main/java/net/minecraft/util/ChatAllowedCharacters.java new file mode 100644 index 0000000..ee81685 --- /dev/null +++ b/src/main/java/net/minecraft/util/ChatAllowedCharacters.java @@ -0,0 +1,31 @@ +package net.minecraft.util; + +public class ChatAllowedCharacters +{ + public static final char[] allowedCharacters = new char[] {'/', '\n', '\r', '\t', '\u0000', '\f', '`', '?', '*', '\\', '<', '>', '|', '\"', ':'}; + private static final String __OBFID = "CL_00001606"; + + public static boolean isAllowedCharacter(char par0) + { + return par0 != 167 && par0 >= 32 && par0 != 127; + } + + public static String filerAllowedCharacters(String par0Str) + { + StringBuilder stringbuilder = new StringBuilder(); + char[] achar = par0Str.toCharArray(); + int i = achar.length; + + for (int j = 0; j < i; ++j) + { + char c0 = achar[j]; + + if (isAllowedCharacter(c0)) + { + stringbuilder.append(c0); + } + } + + return stringbuilder.toString(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/ChatComponentStyle.java b/src/main/java/net/minecraft/util/ChatComponentStyle.java new file mode 100644 index 0000000..af22b68 --- /dev/null +++ b/src/main/java/net/minecraft/util/ChatComponentStyle.java @@ -0,0 +1,158 @@ +package net.minecraft.util; + +import com.google.common.base.Function; +import com.google.common.collect.Iterators; +import com.google.common.collect.Lists; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Iterator; +import java.util.List; + +public abstract class ChatComponentStyle implements IChatComponent +{ + protected List siblings = Lists.newArrayList(); + private ChatStyle style; + private static final String __OBFID = "CL_00001257"; + + public IChatComponent appendSibling(IChatComponent p_150257_1_) + { + p_150257_1_.getChatStyle().setParentStyle(this.getChatStyle()); + this.siblings.add(p_150257_1_); + return this; + } + + public List getSiblings() + { + return this.siblings; + } + + public IChatComponent appendText(String p_150258_1_) + { + return this.appendSibling(new ChatComponentText(p_150258_1_)); + } + + public IChatComponent setChatStyle(ChatStyle p_150255_1_) + { + this.style = p_150255_1_; + Iterator iterator = this.siblings.iterator(); + + while (iterator.hasNext()) + { + IChatComponent ichatcomponent = (IChatComponent)iterator.next(); + ichatcomponent.getChatStyle().setParentStyle(this.getChatStyle()); + } + + return this; + } + + public ChatStyle getChatStyle() + { + if (this.style == null) + { + this.style = new ChatStyle(); + Iterator iterator = this.siblings.iterator(); + + while (iterator.hasNext()) + { + IChatComponent ichatcomponent = (IChatComponent)iterator.next(); + ichatcomponent.getChatStyle().setParentStyle(this.style); + } + } + + return this.style; + } + + public Iterator iterator() + { + return Iterators.concat(Iterators.forArray(new ChatComponentStyle[] {this}), createDeepCopyIterator(this.siblings)); + } + + public final String getUnformattedText() + { + StringBuilder stringbuilder = new StringBuilder(); + Iterator iterator = this.iterator(); + + while (iterator.hasNext()) + { + IChatComponent ichatcomponent = (IChatComponent)iterator.next(); + stringbuilder.append(ichatcomponent.getUnformattedTextForChat()); + } + + return stringbuilder.toString(); + } + + @SideOnly(Side.CLIENT) + public final String getFormattedText() + { + StringBuilder stringbuilder = new StringBuilder(); + Iterator iterator = this.iterator(); + + while (iterator.hasNext()) + { + IChatComponent ichatcomponent = (IChatComponent)iterator.next(); + stringbuilder.append(ichatcomponent.getChatStyle().getFormattingCode()); + stringbuilder.append(ichatcomponent.getUnformattedTextForChat()); + stringbuilder.append(EnumChatFormatting.RESET); + } + + return stringbuilder.toString(); + } + + public static Iterator createDeepCopyIterator(Iterable p_150262_0_) + { + Iterator iterator = Iterators.concat(Iterators.transform(p_150262_0_.iterator(), new Function() + { + private static final String __OBFID = "CL_00001258"; + public Iterator apply(IChatComponent p_150665_1_) + { + return p_150665_1_.iterator(); + } + public Object apply(Object par1Obj) + { + return this.apply((IChatComponent)par1Obj); + } + })); + iterator = Iterators.transform(iterator, new Function() + { + private static final String __OBFID = "CL_00001259"; + public IChatComponent apply(IChatComponent p_150666_1_) + { + IChatComponent ichatcomponent1 = p_150666_1_.createCopy(); + ichatcomponent1.setChatStyle(ichatcomponent1.getChatStyle().createDeepCopy()); + return ichatcomponent1; + } + public Object apply(Object par1Obj) + { + return this.apply((IChatComponent)par1Obj); + } + }); + return iterator; + } + + public boolean equals(Object par1Obj) + { + if (this == par1Obj) + { + return true; + } + else if (!(par1Obj instanceof ChatComponentStyle)) + { + return false; + } + else + { + ChatComponentStyle chatcomponentstyle = (ChatComponentStyle)par1Obj; + return this.siblings.equals(chatcomponentstyle.siblings) && this.getChatStyle().equals(chatcomponentstyle.getChatStyle()); + } + } + + public int hashCode() + { + return 31 * this.style.hashCode() + this.siblings.hashCode(); + } + + public String toString() + { + return "BaseComponent{style=" + this.style + ", siblings=" + this.siblings + '}'; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/ChatComponentText.java b/src/main/java/net/minecraft/util/ChatComponentText.java new file mode 100644 index 0000000..b53cf72 --- /dev/null +++ b/src/main/java/net/minecraft/util/ChatComponentText.java @@ -0,0 +1,61 @@ +package net.minecraft.util; + +import java.util.Iterator; + +public class ChatComponentText extends ChatComponentStyle +{ + private final String text; + private static final String __OBFID = "CL_00001269"; + + public ChatComponentText(String p_i45159_1_) + { + this.text = p_i45159_1_; + } + + public String getChatComponentText_TextValue() + { + return this.text; + } + + public String getUnformattedTextForChat() + { + return this.text; + } + + public ChatComponentText createCopy() + { + ChatComponentText chatcomponenttext = new ChatComponentText(this.text); + chatcomponenttext.setChatStyle(this.getChatStyle().createShallowCopy()); + Iterator iterator = this.getSiblings().iterator(); + + while (iterator.hasNext()) + { + IChatComponent ichatcomponent = (IChatComponent)iterator.next(); + chatcomponenttext.appendSibling(ichatcomponent.createCopy()); + } + + return chatcomponenttext; + } + + public boolean equals(Object par1Obj) + { + if (this == par1Obj) + { + return true; + } + else if (!(par1Obj instanceof ChatComponentText)) + { + return false; + } + else + { + ChatComponentText chatcomponenttext = (ChatComponentText)par1Obj; + return this.text.equals(chatcomponenttext.getChatComponentText_TextValue()) && super.equals(par1Obj); + } + } + + public String toString() + { + return "TextComponent{text=\'" + this.text + '\'' + ", siblings=" + this.siblings + ", style=" + this.getChatStyle() + '}'; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/ChatComponentTranslation.java b/src/main/java/net/minecraft/util/ChatComponentTranslation.java new file mode 100644 index 0000000..e27ddb0 --- /dev/null +++ b/src/main/java/net/minecraft/util/ChatComponentTranslation.java @@ -0,0 +1,278 @@ +package net.minecraft.util; + +import com.google.common.collect.Iterators; +import com.google.common.collect.Lists; +import java.util.Arrays; +import java.util.IllegalFormatException; +import java.util.Iterator; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class ChatComponentTranslation extends ChatComponentStyle +{ + private final String key; + private final Object[] formatArgs; + private final Object syncLock = new Object(); + private long lastTranslationUpdateTimeInMilliseconds = -1L; + List children = Lists.newArrayList(); + public static final Pattern stringVariablePattern = Pattern.compile("%(?:(\\d+)\\$)?([A-Za-z%]|$)"); + private static final String __OBFID = "CL_00001270"; + + public ChatComponentTranslation(String p_i45160_1_, Object ... p_i45160_2_) + { + this.key = p_i45160_1_; + this.formatArgs = p_i45160_2_; + Object[] aobject = p_i45160_2_; + int i = p_i45160_2_.length; + + for (int j = 0; j < i; ++j) + { + Object object1 = aobject[j]; + + if (object1 instanceof IChatComponent) + { + ((IChatComponent)object1).getChatStyle().setParentStyle(this.getChatStyle()); + } + } + } + + synchronized void ensureInitialized() + { + Object object = this.syncLock; + + synchronized (this.syncLock) + { + long i = StatCollector.getLastTranslationUpdateTimeInMilliseconds(); + + if (i == this.lastTranslationUpdateTimeInMilliseconds) + { + return; + } + + this.lastTranslationUpdateTimeInMilliseconds = i; + this.children.clear(); + } + + try + { + this.initializeFromFormat(StatCollector.translateToLocal(this.key)); + } + catch (ChatComponentTranslationFormatException chatcomponenttranslationformatexception1) + { + this.children.clear(); + + try + { + this.initializeFromFormat(StatCollector.translateToFallback(this.key)); + } + catch (ChatComponentTranslationFormatException chatcomponenttranslationformatexception) + { + throw chatcomponenttranslationformatexception1; + } + } + } + + protected void initializeFromFormat(String p_150269_1_) + { + boolean flag = false; + Matcher matcher = stringVariablePattern.matcher(p_150269_1_); + int i = 0; + int j = 0; + + try + { + int l; + + for (; matcher.find(j); j = l) + { + int k = matcher.start(); + l = matcher.end(); + + if (k > j) + { + ChatComponentText chatcomponenttext = new ChatComponentText(String.format(p_150269_1_.substring(j, k), new Object[0])); + chatcomponenttext.getChatStyle().setParentStyle(this.getChatStyle()); + this.children.add(chatcomponenttext); + } + + String s3 = matcher.group(2); + String s1 = p_150269_1_.substring(k, l); + + if ("%".equals(s3) && "%%".equals(s1)) + { + ChatComponentText chatcomponenttext2 = new ChatComponentText("%"); + chatcomponenttext2.getChatStyle().setParentStyle(this.getChatStyle()); + this.children.add(chatcomponenttext2); + } + else + { + if (!"s".equals(s3)) + { + throw new ChatComponentTranslationFormatException(this, "Unsupported format: \'" + s1 + "\'"); + } + + String s2 = matcher.group(1); + int i1 = s2 != null ? Integer.parseInt(s2) - 1 : i++; + this.children.add(this.getFormatArgumentAsComponent(i1)); + } + } + + if (j < p_150269_1_.length()) + { + ChatComponentText chatcomponenttext1 = new ChatComponentText(String.format(p_150269_1_.substring(j), new Object[0])); + chatcomponenttext1.getChatStyle().setParentStyle(this.getChatStyle()); + this.children.add(chatcomponenttext1); + } + } + catch (IllegalFormatException illegalformatexception) + { + throw new ChatComponentTranslationFormatException(this, illegalformatexception); + } + } + + private IChatComponent getFormatArgumentAsComponent(int p_150272_1_) + { + if (p_150272_1_ >= this.formatArgs.length) + { + throw new ChatComponentTranslationFormatException(this, p_150272_1_); + } + else + { + Object object = this.formatArgs[p_150272_1_]; + Object object1; + + if (object instanceof IChatComponent) + { + object1 = (IChatComponent)object; + } + else + { + object1 = new ChatComponentText(object.toString()); + ((IChatComponent)object1).getChatStyle().setParentStyle(this.getChatStyle()); + } + + return (IChatComponent)object1; + } + } + + public IChatComponent setChatStyle(ChatStyle p_150255_1_) + { + super.setChatStyle(p_150255_1_); + Object[] aobject = this.formatArgs; + int i = aobject.length; + + for (int j = 0; j < i; ++j) + { + Object object = aobject[j]; + + if (object instanceof IChatComponent) + { + ((IChatComponent)object).getChatStyle().setParentStyle(this.getChatStyle()); + } + } + + if (this.lastTranslationUpdateTimeInMilliseconds > -1L) + { + Iterator iterator = this.children.iterator(); + + while (iterator.hasNext()) + { + IChatComponent ichatcomponent = (IChatComponent)iterator.next(); + ichatcomponent.getChatStyle().setParentStyle(p_150255_1_); + } + } + + return this; + } + + public Iterator iterator() + { + this.ensureInitialized(); + return Iterators.concat(createDeepCopyIterator(this.children), createDeepCopyIterator(this.siblings)); + } + + public String getUnformattedTextForChat() + { + this.ensureInitialized(); + StringBuilder stringbuilder = new StringBuilder(); + Iterator iterator = this.children.iterator(); + + while (iterator.hasNext()) + { + IChatComponent ichatcomponent = (IChatComponent)iterator.next(); + stringbuilder.append(ichatcomponent.getUnformattedTextForChat()); + } + + return stringbuilder.toString(); + } + + public ChatComponentTranslation createCopy() + { + Object[] aobject = new Object[this.formatArgs.length]; + + for (int i = 0; i < this.formatArgs.length; ++i) + { + if (this.formatArgs[i] instanceof IChatComponent) + { + aobject[i] = ((IChatComponent)this.formatArgs[i]).createCopy(); + } + else + { + aobject[i] = this.formatArgs[i]; + } + } + + ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation(this.key, aobject); + chatcomponenttranslation.setChatStyle(this.getChatStyle().createShallowCopy()); + Iterator iterator = this.getSiblings().iterator(); + + while (iterator.hasNext()) + { + IChatComponent ichatcomponent = (IChatComponent)iterator.next(); + chatcomponenttranslation.appendSibling(ichatcomponent.createCopy()); + } + + return chatcomponenttranslation; + } + + public boolean equals(Object par1Obj) + { + if (this == par1Obj) + { + return true; + } + else if (!(par1Obj instanceof ChatComponentTranslation)) + { + return false; + } + else + { + ChatComponentTranslation chatcomponenttranslation = (ChatComponentTranslation)par1Obj; + return Arrays.equals(this.formatArgs, chatcomponenttranslation.formatArgs) && this.key.equals(chatcomponenttranslation.key) && super.equals(par1Obj); + } + } + + public int hashCode() + { + int i = super.hashCode(); + i = 31 * i + this.key.hashCode(); + i = 31 * i + Arrays.hashCode(this.formatArgs); + return i; + } + + public String toString() + { + return "TranslatableComponent{key=\'" + this.key + '\'' + ", args=" + Arrays.toString(this.formatArgs) + ", siblings=" + this.siblings + ", style=" + this.getChatStyle() + '}'; + } + + public String getKey() + { + return this.key; + } + + public Object[] getFormatArgs() + { + return this.formatArgs; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/ChatComponentTranslationFormatException.java b/src/main/java/net/minecraft/util/ChatComponentTranslationFormatException.java new file mode 100644 index 0000000..2b68d9d --- /dev/null +++ b/src/main/java/net/minecraft/util/ChatComponentTranslationFormatException.java @@ -0,0 +1,21 @@ +package net.minecraft.util; + +public class ChatComponentTranslationFormatException extends IllegalArgumentException +{ + private static final String __OBFID = "CL_00001271"; + + public ChatComponentTranslationFormatException(ChatComponentTranslation p_i45161_1_, String p_i45161_2_) + { + super(String.format("Error parsing: %s: %s", new Object[] {p_i45161_1_, p_i45161_2_})); + } + + public ChatComponentTranslationFormatException(ChatComponentTranslation p_i45162_1_, int p_i45162_2_) + { + super(String.format("Invalid index %d requested for %s", new Object[] {Integer.valueOf(p_i45162_2_), p_i45162_1_})); + } + + public ChatComponentTranslationFormatException(ChatComponentTranslation p_i45163_1_, Throwable p_i45163_2_) + { + super(String.format("Error while parsing: %s", new Object[] {p_i45163_1_}), p_i45163_2_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/ChatStyle.java b/src/main/java/net/minecraft/util/ChatStyle.java new file mode 100644 index 0000000..b81b1e9 --- /dev/null +++ b/src/main/java/net/minecraft/util/ChatStyle.java @@ -0,0 +1,508 @@ +package net.minecraft.util; + +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.lang.reflect.Type; +import net.minecraft.event.ClickEvent; +import net.minecraft.event.HoverEvent; + +public class ChatStyle +{ + private ChatStyle parentStyle; + private EnumChatFormatting color; + private Boolean bold; + private Boolean italic; + private Boolean underlined; + private Boolean strikethrough; + private Boolean obfuscated; + private ClickEvent chatClickEvent; + private HoverEvent chatHoverEvent; + private static final ChatStyle rootStyle = new ChatStyle() + { + private static final String __OBFID = "CL_00001267"; + public EnumChatFormatting getColor() + { + return null; + } + public boolean getBold() + { + return false; + } + public boolean getItalic() + { + return false; + } + public boolean getStrikethrough() + { + return false; + } + public boolean getUnderlined() + { + return false; + } + public boolean getObfuscated() + { + return false; + } + public ClickEvent getChatClickEvent() + { + return null; + } + public HoverEvent getChatHoverEvent() + { + return null; + } + public ChatStyle setColor(EnumChatFormatting p_150238_1_) + { + throw new UnsupportedOperationException(); + } + public ChatStyle setBold(Boolean p_150227_1_) + { + throw new UnsupportedOperationException(); + } + public ChatStyle setItalic(Boolean p_150217_1_) + { + throw new UnsupportedOperationException(); + } + public ChatStyle setStrikethrough(Boolean p_150225_1_) + { + throw new UnsupportedOperationException(); + } + public ChatStyle setUnderlined(Boolean p_150228_1_) + { + throw new UnsupportedOperationException(); + } + public ChatStyle setObfuscated(Boolean p_150237_1_) + { + throw new UnsupportedOperationException(); + } + public ChatStyle setChatClickEvent(ClickEvent p_150241_1_) + { + throw new UnsupportedOperationException(); + } + public ChatStyle setChatHoverEvent(HoverEvent p_150209_1_) + { + throw new UnsupportedOperationException(); + } + public ChatStyle setParentStyle(ChatStyle p_150221_1_) + { + throw new UnsupportedOperationException(); + } + public String toString() + { + return "Style.ROOT"; + } + public ChatStyle createShallowCopy() + { + return this; + } + public ChatStyle createDeepCopy() + { + return this; + } + @SideOnly(Side.CLIENT) + public String getFormattingCode() + { + return ""; + } + }; + private static final String __OBFID = "CL_00001266"; + + public EnumChatFormatting getColor() + { + return this.color == null ? this.getParent().getColor() : this.color; + } + + public boolean getBold() + { + return this.bold == null ? this.getParent().getBold() : this.bold.booleanValue(); + } + + public boolean getItalic() + { + return this.italic == null ? this.getParent().getItalic() : this.italic.booleanValue(); + } + + public boolean getStrikethrough() + { + return this.strikethrough == null ? this.getParent().getStrikethrough() : this.strikethrough.booleanValue(); + } + + public boolean getUnderlined() + { + return this.underlined == null ? this.getParent().getUnderlined() : this.underlined.booleanValue(); + } + + public boolean getObfuscated() + { + return this.obfuscated == null ? this.getParent().getObfuscated() : this.obfuscated.booleanValue(); + } + + public boolean isEmpty() + { + return this.bold == null && this.italic == null && this.strikethrough == null && this.underlined == null && this.obfuscated == null && this.color == null && this.chatClickEvent == null && this.chatHoverEvent == null; + } + + public ClickEvent getChatClickEvent() + { + return this.chatClickEvent == null ? this.getParent().getChatClickEvent() : this.chatClickEvent; + } + + public HoverEvent getChatHoverEvent() + { + return this.chatHoverEvent == null ? this.getParent().getChatHoverEvent() : this.chatHoverEvent; + } + + public ChatStyle setColor(EnumChatFormatting p_150238_1_) + { + this.color = p_150238_1_; + return this; + } + + public ChatStyle setBold(Boolean p_150227_1_) + { + this.bold = p_150227_1_; + return this; + } + + public ChatStyle setItalic(Boolean p_150217_1_) + { + this.italic = p_150217_1_; + return this; + } + + public ChatStyle setStrikethrough(Boolean p_150225_1_) + { + this.strikethrough = p_150225_1_; + return this; + } + + public ChatStyle setUnderlined(Boolean p_150228_1_) + { + this.underlined = p_150228_1_; + return this; + } + + public ChatStyle setObfuscated(Boolean p_150237_1_) + { + this.obfuscated = p_150237_1_; + return this; + } + + public ChatStyle setChatClickEvent(ClickEvent p_150241_1_) + { + this.chatClickEvent = p_150241_1_; + return this; + } + + public ChatStyle setChatHoverEvent(HoverEvent p_150209_1_) + { + this.chatHoverEvent = p_150209_1_; + return this; + } + + public ChatStyle setParentStyle(ChatStyle p_150221_1_) + { + this.parentStyle = p_150221_1_; + return this; + } + + @SideOnly(Side.CLIENT) + public String getFormattingCode() + { + if (this.isEmpty()) + { + return this.parentStyle != null ? this.parentStyle.getFormattingCode() : ""; + } + else + { + StringBuilder stringbuilder = new StringBuilder(); + + if (this.getColor() != null) + { + stringbuilder.append(this.getColor()); + } + + if (this.getBold()) + { + stringbuilder.append(EnumChatFormatting.BOLD); + } + + if (this.getItalic()) + { + stringbuilder.append(EnumChatFormatting.ITALIC); + } + + if (this.getUnderlined()) + { + stringbuilder.append(EnumChatFormatting.UNDERLINE); + } + + if (this.getObfuscated()) + { + stringbuilder.append(EnumChatFormatting.OBFUSCATED); + } + + if (this.getStrikethrough()) + { + stringbuilder.append(EnumChatFormatting.STRIKETHROUGH); + } + + return stringbuilder.toString(); + } + } + + private ChatStyle getParent() + { + return this.parentStyle == null ? rootStyle : this.parentStyle; + } + + public String toString() + { + return "Style{hasParent=" + (this.parentStyle != null) + ", color=" + this.color + ", bold=" + this.bold + ", italic=" + this.italic + ", underlined=" + this.underlined + ", obfuscated=" + this.obfuscated + ", clickEvent=" + this.getChatClickEvent() + ", hoverEvent=" + this.getChatHoverEvent() + '}'; + } + + public boolean equals(Object par1Obj) + { + if (this == par1Obj) + { + return true; + } + else if (!(par1Obj instanceof ChatStyle)) + { + return false; + } + else + { + ChatStyle chatstyle = (ChatStyle)par1Obj; + boolean flag; + + if (this.getBold() == chatstyle.getBold() && this.getColor() == chatstyle.getColor() && this.getItalic() == chatstyle.getItalic() && this.getObfuscated() == chatstyle.getObfuscated() && this.getStrikethrough() == chatstyle.getStrikethrough() && this.getUnderlined() == chatstyle.getUnderlined()) + { + label56: + { + if (this.getChatClickEvent() != null) + { + if (!this.getChatClickEvent().equals(chatstyle.getChatClickEvent())) + { + break label56; + } + } + else if (chatstyle.getChatClickEvent() != null) + { + break label56; + } + + if (this.getChatHoverEvent() != null) + { + if (!this.getChatHoverEvent().equals(chatstyle.getChatHoverEvent())) + { + break label56; + } + } + else if (chatstyle.getChatHoverEvent() != null) + { + break label56; + } + + flag = true; + return flag; + } + } + + flag = false; + return flag; + } + } + + public int hashCode() + { + int i = this.color.hashCode(); + i = 31 * i + this.bold.hashCode(); + i = 31 * i + this.italic.hashCode(); + i = 31 * i + this.underlined.hashCode(); + i = 31 * i + this.strikethrough.hashCode(); + i = 31 * i + this.obfuscated.hashCode(); + i = 31 * i + this.chatClickEvent.hashCode(); + i = 31 * i + this.chatHoverEvent.hashCode(); + return i; + } + + public ChatStyle createShallowCopy() + { + ChatStyle chatstyle = new ChatStyle(); + chatstyle.bold = this.bold; + chatstyle.italic = this.italic; + chatstyle.strikethrough = this.strikethrough; + chatstyle.underlined = this.underlined; + chatstyle.obfuscated = this.obfuscated; + chatstyle.color = this.color; + chatstyle.chatClickEvent = this.chatClickEvent; + chatstyle.chatHoverEvent = this.chatHoverEvent; + chatstyle.parentStyle = this.parentStyle; + return chatstyle; + } + + public ChatStyle createDeepCopy() + { + ChatStyle chatstyle = new ChatStyle(); + chatstyle.setBold(Boolean.valueOf(this.getBold())); + chatstyle.setItalic(Boolean.valueOf(this.getItalic())); + chatstyle.setStrikethrough(Boolean.valueOf(this.getStrikethrough())); + chatstyle.setUnderlined(Boolean.valueOf(this.getUnderlined())); + chatstyle.setObfuscated(Boolean.valueOf(this.getObfuscated())); + chatstyle.setColor(this.getColor()); + chatstyle.setChatClickEvent(this.getChatClickEvent()); + chatstyle.setChatHoverEvent(this.getChatHoverEvent()); + return chatstyle; + } + + public static class Serializer implements JsonDeserializer, JsonSerializer + { + private static final String __OBFID = "CL_00001268"; + + public ChatStyle deserialize(JsonElement p_150204_1_, Type p_150204_2_, JsonDeserializationContext p_150204_3_) + { + if (p_150204_1_.isJsonObject()) + { + ChatStyle chatstyle = new ChatStyle(); + JsonObject jsonobject = p_150204_1_.getAsJsonObject(); + + if (jsonobject.has("bold")) + { + chatstyle.bold = Boolean.valueOf(jsonobject.get("bold").getAsBoolean()); + } + + if (jsonobject.has("italic")) + { + chatstyle.italic = Boolean.valueOf(jsonobject.get("italic").getAsBoolean()); + } + + if (jsonobject.has("underlined")) + { + chatstyle.underlined = Boolean.valueOf(jsonobject.get("underlined").getAsBoolean()); + } + + if (jsonobject.has("strikethrough")) + { + chatstyle.strikethrough = Boolean.valueOf(jsonobject.get("strikethrough").getAsBoolean()); + } + + if (jsonobject.has("obfuscated")) + { + chatstyle.obfuscated = Boolean.valueOf(jsonobject.get("obfuscated").getAsBoolean()); + } + + if (jsonobject.has("color")) + { + chatstyle.color = (EnumChatFormatting)p_150204_3_.deserialize(jsonobject.get("color"), EnumChatFormatting.class); + } + + JsonObject jsonobject1; + + if (jsonobject.has("clickEvent")) + { + jsonobject1 = jsonobject.getAsJsonObject("clickEvent"); + ClickEvent.Action action = ClickEvent.Action.getValueByCanonicalName(jsonobject1.getAsJsonPrimitive("action").getAsString()); + String s = jsonobject1.getAsJsonPrimitive("value").getAsString(); + + if (action != null && s != null && action.shouldAllowInChat()) + { + chatstyle.chatClickEvent = new ClickEvent(action, s); + } + } + + if (jsonobject.has("hoverEvent")) + { + jsonobject1 = jsonobject.getAsJsonObject("hoverEvent"); + HoverEvent.Action action1 = HoverEvent.Action.getValueByCanonicalName(jsonobject1.getAsJsonPrimitive("action").getAsString()); + IChatComponent ichatcomponent = (IChatComponent)p_150204_3_.deserialize(jsonobject1.get("value"), IChatComponent.class); + + if (action1 != null && ichatcomponent != null && action1.shouldAllowInChat()) + { + chatstyle.chatHoverEvent = new HoverEvent(action1, ichatcomponent); + } + } + + return chatstyle; + } + else + { + return null; + } + } + + public JsonElement serialize(ChatStyle p_150203_1_, Type p_150203_2_, JsonSerializationContext p_150203_3_) + { + if (p_150203_1_.isEmpty()) + { + return null; + } + else + { + JsonObject jsonobject = new JsonObject(); + + if (p_150203_1_.bold != null) + { + jsonobject.addProperty("bold", p_150203_1_.bold); + } + + if (p_150203_1_.italic != null) + { + jsonobject.addProperty("italic", p_150203_1_.italic); + } + + if (p_150203_1_.underlined != null) + { + jsonobject.addProperty("underlined", p_150203_1_.underlined); + } + + if (p_150203_1_.strikethrough != null) + { + jsonobject.addProperty("strikethrough", p_150203_1_.strikethrough); + } + + if (p_150203_1_.obfuscated != null) + { + jsonobject.addProperty("obfuscated", p_150203_1_.obfuscated); + } + + if (p_150203_1_.color != null) + { + jsonobject.add("color", p_150203_3_.serialize(p_150203_1_.color)); + } + + JsonObject jsonobject1; + + if (p_150203_1_.chatClickEvent != null) + { + jsonobject1 = new JsonObject(); + jsonobject1.addProperty("action", p_150203_1_.chatClickEvent.getAction().getCanonicalName()); + jsonobject1.addProperty("value", p_150203_1_.chatClickEvent.getValue()); + jsonobject.add("clickEvent", jsonobject1); + } + + if (p_150203_1_.chatHoverEvent != null) + { + jsonobject1 = new JsonObject(); + jsonobject1.addProperty("action", p_150203_1_.chatHoverEvent.getAction().getCanonicalName()); + jsonobject1.add("value", p_150203_3_.serialize(p_150203_1_.chatHoverEvent.getValue())); + jsonobject.add("hoverEvent", jsonobject1); + } + + return jsonobject; + } + } + + public JsonElement serialize(Object par1Obj, Type par2Type, JsonSerializationContext par3JsonSerializationContext) + { + return this.serialize((ChatStyle)par1Obj, par2Type, par3JsonSerializationContext); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/ChunkCoordinates.java b/src/main/java/net/minecraft/util/ChunkCoordinates.java new file mode 100644 index 0000000..48d6b70 --- /dev/null +++ b/src/main/java/net/minecraft/util/ChunkCoordinates.java @@ -0,0 +1,78 @@ +package net.minecraft.util; + +public class ChunkCoordinates implements Comparable +{ + public int posX; + public int posY; + public int posZ; + private static final String __OBFID = "CL_00001555"; + + public ChunkCoordinates() {} + + public ChunkCoordinates(int par1, int par2, int par3) + { + this.posX = par1; + this.posY = par2; + this.posZ = par3; + } + + public ChunkCoordinates(ChunkCoordinates par1ChunkCoordinates) + { + this.posX = par1ChunkCoordinates.posX; + this.posY = par1ChunkCoordinates.posY; + this.posZ = par1ChunkCoordinates.posZ; + } + + public boolean equals(Object par1Obj) + { + if (!(par1Obj instanceof ChunkCoordinates)) + { + return false; + } + else + { + ChunkCoordinates chunkcoordinates = (ChunkCoordinates)par1Obj; + return this.posX == chunkcoordinates.posX && this.posY == chunkcoordinates.posY && this.posZ == chunkcoordinates.posZ; + } + } + + public int hashCode() + { + return this.posX + this.posZ << 8 + this.posY << 16; + } + + public int compareTo(ChunkCoordinates par1ChunkCoordinates) + { + return this.posY == par1ChunkCoordinates.posY ? (this.posZ == par1ChunkCoordinates.posZ ? this.posX - par1ChunkCoordinates.posX : this.posZ - par1ChunkCoordinates.posZ) : this.posY - par1ChunkCoordinates.posY; + } + + public void set(int par1, int par2, int par3) + { + this.posX = par1; + this.posY = par2; + this.posZ = par3; + } + + public float getDistanceSquared(int par1, int par2, int par3) + { + float f = (float)(this.posX - par1); + float f1 = (float)(this.posY - par2); + float f2 = (float)(this.posZ - par3); + return f * f + f1 * f1 + f2 * f2; + } + + public float getDistanceSquaredToChunkCoordinates(ChunkCoordinates par1ChunkCoordinates) + { + return this.getDistanceSquared(par1ChunkCoordinates.posX, par1ChunkCoordinates.posY, par1ChunkCoordinates.posZ); + } + + public String toString() + { + return "Pos{x=" + this.posX + ", y=" + this.posY + ", z=" + this.posZ + '}'; + } + + public int compareTo(Object par1Obj) + { + return this.compareTo((ChunkCoordinates)par1Obj); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/CombatEntry.java b/src/main/java/net/minecraft/util/CombatEntry.java new file mode 100644 index 0000000..ba4cb43 --- /dev/null +++ b/src/main/java/net/minecraft/util/CombatEntry.java @@ -0,0 +1,54 @@ +package net.minecraft.util; + +import net.minecraft.entity.EntityLivingBase; + +public class CombatEntry +{ + private final DamageSource damageSrc; + private final int field_94567_b; + private final float field_94568_c; + private final float field_94565_d; + private final String field_94566_e; + private final float field_94564_f; + private static final String __OBFID = "CL_00001519"; + + public CombatEntry(DamageSource par1DamageSource, int par2, float par3, float par4, String par5Str, float par6) + { + this.damageSrc = par1DamageSource; + this.field_94567_b = par2; + this.field_94568_c = par4; + this.field_94565_d = par3; + this.field_94566_e = par5Str; + this.field_94564_f = par6; + } + + public DamageSource getDamageSrc() + { + return this.damageSrc; + } + + public float func_94563_c() + { + return this.field_94568_c; + } + + public boolean func_94559_f() + { + return this.damageSrc.getEntity() instanceof EntityLivingBase; + } + + public String func_94562_g() + { + return this.field_94566_e; + } + + public IChatComponent func_151522_h() + { + return this.getDamageSrc().getEntity() == null ? null : this.getDamageSrc().getEntity().func_145748_c_(); + } + + public float func_94561_i() + { + return this.damageSrc == DamageSource.outOfWorld ? Float.MAX_VALUE : this.field_94564_f; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/CombatTracker.java b/src/main/java/net/minecraft/util/CombatTracker.java new file mode 100644 index 0000000..02304eb --- /dev/null +++ b/src/main/java/net/minecraft/util/CombatTracker.java @@ -0,0 +1,230 @@ +package net.minecraft.util; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; + +public class CombatTracker +{ + private final List combatEntries = new ArrayList(); + private final EntityLivingBase fighter; + private int field_94555_c; + private boolean field_94552_d; + private boolean field_94553_e; + private String field_94551_f; + private static final String __OBFID = "CL_00001520"; + + public CombatTracker(EntityLivingBase par1EntityLivingBase) + { + this.fighter = par1EntityLivingBase; + } + + public void func_94545_a() + { + this.func_94542_g(); + + if (this.fighter.isOnLadder()) + { + Block block = this.fighter.worldObj.getBlock(MathHelper.floor_double(this.fighter.posX), MathHelper.floor_double(this.fighter.boundingBox.minY), MathHelper.floor_double(this.fighter.posZ)); + + if (block == Blocks.ladder) + { + this.field_94551_f = "ladder"; + } + else if (block == Blocks.vine) + { + this.field_94551_f = "vines"; + } + } + else if (this.fighter.isInWater()) + { + this.field_94551_f = "water"; + } + } + + public void func_94547_a(DamageSource par1DamageSource, float par2, float par3) + { + this.func_94549_h(); + this.func_94545_a(); + CombatEntry combatentry = new CombatEntry(par1DamageSource, this.fighter.ticksExisted, par2, par3, this.field_94551_f, this.fighter.fallDistance); + this.combatEntries.add(combatentry); + this.field_94555_c = this.fighter.ticksExisted; + this.field_94553_e = true; + this.field_94552_d |= combatentry.func_94559_f(); + } + + public IChatComponent func_151521_b() + { + if (this.combatEntries.size() == 0) + { + return new ChatComponentTranslation("death.attack.generic", new Object[] {this.fighter.func_145748_c_()}); + } + else + { + CombatEntry combatentry = this.func_94544_f(); + CombatEntry combatentry1 = (CombatEntry)this.combatEntries.get(this.combatEntries.size() - 1); + IChatComponent ichatcomponent = combatentry1.func_151522_h(); + Entity entity = combatentry1.getDamageSrc().getEntity(); + Object object; + + if (combatentry != null && combatentry1.getDamageSrc() == DamageSource.fall) + { + IChatComponent ichatcomponent1 = combatentry.func_151522_h(); + + if (combatentry.getDamageSrc() != DamageSource.fall && combatentry.getDamageSrc() != DamageSource.outOfWorld) + { + if (ichatcomponent1 != null && (ichatcomponent == null || !ichatcomponent1.equals(ichatcomponent))) + { + Entity entity1 = combatentry.getDamageSrc().getEntity(); + ItemStack itemstack1 = entity1 instanceof EntityLivingBase ? ((EntityLivingBase)entity1).getHeldItem() : null; + + if (itemstack1 != null && itemstack1.hasDisplayName()) + { + object = new ChatComponentTranslation("death.fell.assist.item", new Object[] {this.fighter.func_145748_c_(), ichatcomponent1, itemstack1.func_151000_E()}); + } + else + { + object = new ChatComponentTranslation("death.fell.assist", new Object[] {this.fighter.func_145748_c_(), ichatcomponent1}); + } + } + else if (ichatcomponent != null) + { + ItemStack itemstack = entity instanceof EntityLivingBase ? ((EntityLivingBase)entity).getHeldItem() : null; + + if (itemstack != null && itemstack.hasDisplayName()) + { + object = new ChatComponentTranslation("death.fell.finish.item", new Object[] {this.fighter.func_145748_c_(), ichatcomponent, itemstack.func_151000_E()}); + } + else + { + object = new ChatComponentTranslation("death.fell.finish", new Object[] {this.fighter.func_145748_c_(), ichatcomponent}); + } + } + else + { + object = new ChatComponentTranslation("death.fell.killer", new Object[] {this.fighter.func_145748_c_()}); + } + } + else + { + object = new ChatComponentTranslation("death.fell.accident." + this.func_94548_b(combatentry), new Object[] {this.fighter.func_145748_c_()}); + } + } + else + { + object = combatentry1.getDamageSrc().func_151519_b(this.fighter); + } + + return (IChatComponent)object; + } + } + + public EntityLivingBase func_94550_c() + { + EntityLivingBase entitylivingbase = null; + EntityPlayer entityplayer = null; + float f = 0.0F; + float f1 = 0.0F; + Iterator iterator = this.combatEntries.iterator(); + + while (iterator.hasNext()) + { + CombatEntry combatentry = (CombatEntry)iterator.next(); + + if (combatentry.getDamageSrc().getEntity() instanceof EntityPlayer && (entityplayer == null || combatentry.func_94563_c() > f1)) + { + f1 = combatentry.func_94563_c(); + entityplayer = (EntityPlayer)combatentry.getDamageSrc().getEntity(); + } + + if (combatentry.getDamageSrc().getEntity() instanceof EntityLivingBase && (entitylivingbase == null || combatentry.func_94563_c() > f)) + { + f = combatentry.func_94563_c(); + entitylivingbase = (EntityLivingBase)combatentry.getDamageSrc().getEntity(); + } + } + + if (entityplayer != null && f1 >= f / 3.0F) + { + return entityplayer; + } + else + { + return entitylivingbase; + } + } + + private CombatEntry func_94544_f() + { + CombatEntry combatentry = null; + CombatEntry combatentry1 = null; + byte b0 = 0; + float f = 0.0F; + + for (int i = 0; i < this.combatEntries.size(); ++i) + { + CombatEntry combatentry2 = (CombatEntry)this.combatEntries.get(i); + CombatEntry combatentry3 = i > 0 ? (CombatEntry)this.combatEntries.get(i - 1) : null; + + if ((combatentry2.getDamageSrc() == DamageSource.fall || combatentry2.getDamageSrc() == DamageSource.outOfWorld) && combatentry2.func_94561_i() > 0.0F && (combatentry == null || combatentry2.func_94561_i() > f)) + { + if (i > 0) + { + combatentry = combatentry3; + } + else + { + combatentry = combatentry2; + } + + f = combatentry2.func_94561_i(); + } + + if (combatentry2.func_94562_g() != null && (combatentry1 == null || combatentry2.func_94563_c() > (float)b0)) + { + combatentry1 = combatentry2; + } + } + + if (f > 5.0F && combatentry != null) + { + return combatentry; + } + else if (b0 > 5 && combatentry1 != null) + { + return combatentry1; + } + else + { + return null; + } + } + + private String func_94548_b(CombatEntry par1CombatEntry) + { + return par1CombatEntry.func_94562_g() == null ? "generic" : par1CombatEntry.func_94562_g(); + } + + private void func_94542_g() + { + this.field_94551_f = null; + } + + private void func_94549_h() + { + int i = this.field_94552_d ? 300 : 100; + + if (this.field_94553_e && this.fighter.ticksExisted - this.field_94555_c > i) + { + this.combatEntries.clear(); + this.field_94553_e = false; + this.field_94552_d = false; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/CryptManager.java b/src/main/java/net/minecraft/util/CryptManager.java new file mode 100644 index 0000000..aa34e8e --- /dev/null +++ b/src/main/java/net/minecraft/util/CryptManager.java @@ -0,0 +1,192 @@ +package net.minecraft.util; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.UnsupportedEncodingException; +import java.security.GeneralSecurityException; +import java.security.InvalidKeyException; +import java.security.Key; +import java.security.KeyFactory; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.security.PrivateKey; +import java.security.PublicKey; +import java.security.spec.InvalidKeySpecException; +import java.security.spec.X509EncodedKeySpec; +import javax.crypto.BadPaddingException; +import javax.crypto.Cipher; +import javax.crypto.IllegalBlockSizeException; +import javax.crypto.KeyGenerator; +import javax.crypto.NoSuchPaddingException; +import javax.crypto.SecretKey; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; + +public class CryptManager +{ + private static final String __OBFID = "CL_00001483"; + + @SideOnly(Side.CLIENT) + public static SecretKey createNewSharedKey() + { + try + { + KeyGenerator keygenerator = KeyGenerator.getInstance("AES"); + keygenerator.init(128); + return keygenerator.generateKey(); + } + catch (NoSuchAlgorithmException nosuchalgorithmexception) + { + throw new Error(nosuchalgorithmexception); + } + } + + public static KeyPair createNewKeyPair() + { + try + { + KeyPairGenerator keypairgenerator = KeyPairGenerator.getInstance("RSA"); + keypairgenerator.initialize(1024); + return keypairgenerator.generateKeyPair(); + } + catch (NoSuchAlgorithmException nosuchalgorithmexception) + { + nosuchalgorithmexception.printStackTrace(); + System.err.println("Key pair generation failed!"); + return null; + } + } + + public static byte[] getServerIdHash(String par0Str, PublicKey par1PublicKey, SecretKey par2SecretKey) + { + try + { + return digestOperation("SHA-1", new byte[][] {par0Str.getBytes("ISO_8859_1"), par2SecretKey.getEncoded(), par1PublicKey.getEncoded()}); + } + catch (UnsupportedEncodingException unsupportedencodingexception) + { + unsupportedencodingexception.printStackTrace(); + return null; + } + } + + private static byte[] digestOperation(String par0Str, byte[] ... par1ArrayOfByte) + { + try + { + MessageDigest messagedigest = MessageDigest.getInstance(par0Str); + byte[][] abyte1 = par1ArrayOfByte; + int i = par1ArrayOfByte.length; + + for (int j = 0; j < i; ++j) + { + byte[] abyte2 = abyte1[j]; + messagedigest.update(abyte2); + } + + return messagedigest.digest(); + } + catch (NoSuchAlgorithmException nosuchalgorithmexception) + { + nosuchalgorithmexception.printStackTrace(); + return null; + } + } + + public static PublicKey decodePublicKey(byte[] par0ArrayOfByte) + { + try + { + X509EncodedKeySpec x509encodedkeyspec = new X509EncodedKeySpec(par0ArrayOfByte); + KeyFactory keyfactory = KeyFactory.getInstance("RSA"); + return keyfactory.generatePublic(x509encodedkeyspec); + } + catch (NoSuchAlgorithmException nosuchalgorithmexception) + { + ; + } + catch (InvalidKeySpecException invalidkeyspecexception) + { + ; + } + + System.err.println("Public key reconstitute failed!"); + return null; + } + + public static SecretKey decryptSharedKey(PrivateKey par0PrivateKey, byte[] par1ArrayOfByte) + { + return new SecretKeySpec(decryptData(par0PrivateKey, par1ArrayOfByte), "AES"); + } + + @SideOnly(Side.CLIENT) + public static byte[] encryptData(Key par0Key, byte[] par1ArrayOfByte) + { + return cipherOperation(1, par0Key, par1ArrayOfByte); + } + + public static byte[] decryptData(Key par0Key, byte[] par1ArrayOfByte) + { + return cipherOperation(2, par0Key, par1ArrayOfByte); + } + + private static byte[] cipherOperation(int par0, Key par1Key, byte[] par2ArrayOfByte) + { + try + { + return createTheCipherInstance(par0, par1Key.getAlgorithm(), par1Key).doFinal(par2ArrayOfByte); + } + catch (IllegalBlockSizeException illegalblocksizeexception) + { + illegalblocksizeexception.printStackTrace(); + } + catch (BadPaddingException badpaddingexception) + { + badpaddingexception.printStackTrace(); + } + + System.err.println("Cipher data failed!"); + return null; + } + + private static Cipher createTheCipherInstance(int par0, String par1Str, Key par2Key) + { + try + { + Cipher cipher = Cipher.getInstance(par1Str); + cipher.init(par0, par2Key); + return cipher; + } + catch (InvalidKeyException invalidkeyexception) + { + invalidkeyexception.printStackTrace(); + } + catch (NoSuchAlgorithmException nosuchalgorithmexception) + { + nosuchalgorithmexception.printStackTrace(); + } + catch (NoSuchPaddingException nosuchpaddingexception) + { + nosuchpaddingexception.printStackTrace(); + } + + System.err.println("Cipher creation failed!"); + return null; + } + + public static Cipher func_151229_a(int p_151229_0_, Key p_151229_1_) + { + try + { + Cipher cipher = Cipher.getInstance("AES/CFB8/NoPadding"); + cipher.init(p_151229_0_, p_151229_1_, new IvParameterSpec(p_151229_1_.getEncoded())); + return cipher; + } + catch (GeneralSecurityException generalsecurityexception) + { + throw new RuntimeException(generalsecurityexception); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/DamageSource.java b/src/main/java/net/minecraft/util/DamageSource.java new file mode 100644 index 0000000..3952881 --- /dev/null +++ b/src/main/java/net/minecraft/util/DamageSource.java @@ -0,0 +1,200 @@ +package net.minecraft.util; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.entity.projectile.EntityFireball; +import net.minecraft.world.Explosion; + +public class DamageSource +{ + public static DamageSource inFire = (new DamageSource("inFire")).setFireDamage(); + public static DamageSource onFire = (new DamageSource("onFire")).setDamageBypassesArmor().setFireDamage(); + public static DamageSource lava = (new DamageSource("lava")).setFireDamage(); + public static DamageSource inWall = (new DamageSource("inWall")).setDamageBypassesArmor(); + public static DamageSource drown = (new DamageSource("drown")).setDamageBypassesArmor(); + public static DamageSource starve = (new DamageSource("starve")).setDamageBypassesArmor().setDamageIsAbsolute(); + public static DamageSource cactus = new DamageSource("cactus"); + public static DamageSource fall = (new DamageSource("fall")).setDamageBypassesArmor(); + public static DamageSource outOfWorld = (new DamageSource("outOfWorld")).setDamageBypassesArmor().setDamageAllowedInCreativeMode(); + public static DamageSource generic = (new DamageSource("generic")).setDamageBypassesArmor(); + public static DamageSource magic = (new DamageSource("magic")).setDamageBypassesArmor().setMagicDamage(); + public static DamageSource wither = (new DamageSource("wither")).setDamageBypassesArmor(); + public static DamageSource anvil = new DamageSource("anvil"); + public static DamageSource fallingBlock = new DamageSource("fallingBlock"); + private boolean isUnblockable; + private boolean isDamageAllowedInCreativeMode; + private boolean damageIsAbsolute; + private float hungerDamage = 0.3F; + private boolean fireDamage; + private boolean projectile; + private boolean difficultyScaled; + private boolean magicDamage; + private boolean explosion; + public String damageType; + private static final String __OBFID = "CL_00001521"; + + public static DamageSource causeMobDamage(EntityLivingBase par0EntityLivingBase) + { + return new EntityDamageSource("mob", par0EntityLivingBase); + } + + public static DamageSource causePlayerDamage(EntityPlayer par0EntityPlayer) + { + return new EntityDamageSource("player", par0EntityPlayer); + } + + public static DamageSource causeArrowDamage(EntityArrow par0EntityArrow, Entity par1Entity) + { + return (new EntityDamageSourceIndirect("arrow", par0EntityArrow, par1Entity)).setProjectile(); + } + + public static DamageSource causeFireballDamage(EntityFireball par0EntityFireball, Entity par1Entity) + { + return par1Entity == null ? (new EntityDamageSourceIndirect("onFire", par0EntityFireball, par0EntityFireball)).setFireDamage().setProjectile() : (new EntityDamageSourceIndirect("fireball", par0EntityFireball, par1Entity)).setFireDamage().setProjectile(); + } + + public static DamageSource causeThrownDamage(Entity par0Entity, Entity par1Entity) + { + return (new EntityDamageSourceIndirect("thrown", par0Entity, par1Entity)).setProjectile(); + } + + public static DamageSource causeIndirectMagicDamage(Entity par0Entity, Entity par1Entity) + { + return (new EntityDamageSourceIndirect("indirectMagic", par0Entity, par1Entity)).setDamageBypassesArmor().setMagicDamage(); + } + + public static DamageSource causeThornsDamage(Entity par0Entity) + { + return (new EntityDamageSource("thorns", par0Entity)).setMagicDamage(); + } + + public static DamageSource setExplosionSource(Explosion par0Explosion) + { + return par0Explosion != null && par0Explosion.getExplosivePlacedBy() != null ? (new EntityDamageSource("explosion.player", par0Explosion.getExplosivePlacedBy())).setDifficultyScaled().setExplosion() : (new DamageSource("explosion")).setDifficultyScaled().setExplosion(); + } + + public boolean isProjectile() + { + return this.projectile; + } + + public DamageSource setProjectile() + { + this.projectile = true; + return this; + } + + public boolean isExplosion() + { + return this.explosion; + } + + public DamageSource setExplosion() + { + this.explosion = true; + return this; + } + + public boolean isUnblockable() + { + return this.isUnblockable; + } + + public float getHungerDamage() + { + return this.hungerDamage; + } + + public boolean canHarmInCreative() + { + return this.isDamageAllowedInCreativeMode; + } + + public boolean isDamageAbsolute() + { + return this.damageIsAbsolute; + } + + public DamageSource(String par1Str) + { + this.damageType = par1Str; + } + + public Entity getSourceOfDamage() + { + return this.getEntity(); + } + + public Entity getEntity() + { + return null; + } + + public DamageSource setDamageBypassesArmor() + { + this.isUnblockable = true; + this.hungerDamage = 0.0F; + return this; + } + + public DamageSource setDamageAllowedInCreativeMode() + { + this.isDamageAllowedInCreativeMode = true; + return this; + } + + public DamageSource setDamageIsAbsolute() + { + this.damageIsAbsolute = true; + this.hungerDamage = 0.0F; + return this; + } + + public DamageSource setFireDamage() + { + this.fireDamage = true; + return this; + } + + public IChatComponent func_151519_b(EntityLivingBase p_151519_1_) + { + EntityLivingBase entitylivingbase1 = p_151519_1_.func_94060_bK(); + String s = "death.attack." + this.damageType; + String s1 = s + ".player"; + return entitylivingbase1 != null && StatCollector.canTranslate(s1) ? new ChatComponentTranslation(s1, new Object[] {p_151519_1_.func_145748_c_(), entitylivingbase1.func_145748_c_()}): new ChatComponentTranslation(s, new Object[] {p_151519_1_.func_145748_c_()}); + } + + public boolean isFireDamage() + { + return this.fireDamage; + } + + public String getDamageType() + { + return this.damageType; + } + + public DamageSource setDifficultyScaled() + { + this.difficultyScaled = true; + return this; + } + + public boolean isDifficultyScaled() + { + return this.difficultyScaled; + } + + public boolean isMagicDamage() + { + return this.magicDamage; + } + + public DamageSource setMagicDamage() + { + this.magicDamage = true; + return this; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/Direction.java b/src/main/java/net/minecraft/util/Direction.java new file mode 100644 index 0000000..e38505d --- /dev/null +++ b/src/main/java/net/minecraft/util/Direction.java @@ -0,0 +1,20 @@ +package net.minecraft.util; + +public class Direction +{ + public static final int[] offsetX = new int[] {0, -1, 0, 1}; + public static final int[] offsetZ = new int[] {1, 0, -1, 0}; + public static final String[] directions = new String[] {"SOUTH", "WEST", "NORTH", "EAST"}; + public static final int[] directionToFacing = new int[] {3, 4, 2, 5}; + public static final int[] facingToDirection = new int[] { -1, -1, 2, 0, 1, 3}; + public static final int[] rotateOpposite = new int[] {2, 3, 0, 1}; + public static final int[] rotateRight = new int[] {1, 2, 3, 0}; + public static final int[] rotateLeft = new int[] {3, 0, 1, 2}; + public static final int[][] bedDirection = new int[][] {{1, 0, 3, 2, 5, 4}, {1, 0, 5, 4, 2, 3}, {1, 0, 2, 3, 4, 5}, {1, 0, 4, 5, 3, 2}}; + private static final String __OBFID = "CL_00001506"; + + public static int getMovementDirection(double par0, double par2) + { + return MathHelper.abs((float)par0) > MathHelper.abs((float)par2) ? (par0 > 0.0D ? 1 : 3) : (par2 > 0.0D ? 2 : 0); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/EnchantmentNameParts.java b/src/main/java/net/minecraft/util/EnchantmentNameParts.java new file mode 100644 index 0000000..2410b53 --- /dev/null +++ b/src/main/java/net/minecraft/util/EnchantmentNameParts.java @@ -0,0 +1,37 @@ +package net.minecraft.util; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; + +@SideOnly(Side.CLIENT) +public class EnchantmentNameParts +{ + public static final EnchantmentNameParts instance = new EnchantmentNameParts(); + private Random rand = new Random(); + private String[] namePartsArray = "the elder scrolls klaatu berata niktu xyzzy bless curse light darkness fire air earth water hot dry cold wet ignite snuff embiggen twist shorten stretch fiddle destroy imbue galvanize enchant free limited range of towards inside sphere cube self other ball mental physical grow shrink demon elemental spirit animal creature beast humanoid undead fresh stale ".split(" "); + private static final String __OBFID = "CL_00000756"; + + public String generateNewRandomName() + { + int i = this.rand.nextInt(2) + 3; + String s = ""; + + for (int j = 0; j < i; ++j) + { + if (j > 0) + { + s = s + " "; + } + + s = s + this.namePartsArray[this.rand.nextInt(this.namePartsArray.length)]; + } + + return s; + } + + public void reseedRandomGenerator(long p_148335_1_) + { + this.rand.setSeed(p_148335_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/EntityDamageSource.java b/src/main/java/net/minecraft/util/EntityDamageSource.java new file mode 100644 index 0000000..84cfb90 --- /dev/null +++ b/src/main/java/net/minecraft/util/EntityDamageSource.java @@ -0,0 +1,36 @@ +package net.minecraft.util; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +public class EntityDamageSource extends DamageSource +{ + protected Entity damageSourceEntity; + private static final String __OBFID = "CL_00001522"; + + public EntityDamageSource(String par1Str, Entity par2Entity) + { + super(par1Str); + this.damageSourceEntity = par2Entity; + } + + public Entity getEntity() + { + return this.damageSourceEntity; + } + + public IChatComponent func_151519_b(EntityLivingBase p_151519_1_) + { + ItemStack itemstack = this.damageSourceEntity instanceof EntityLivingBase ? ((EntityLivingBase)this.damageSourceEntity).getHeldItem() : null; + String s = "death.attack." + this.damageType; + String s1 = s + ".item"; + return itemstack != null && itemstack.hasDisplayName() && StatCollector.canTranslate(s1) ? new ChatComponentTranslation(s1, new Object[] {p_151519_1_.func_145748_c_(), this.damageSourceEntity.func_145748_c_(), itemstack.func_151000_E()}): new ChatComponentTranslation(s, new Object[] {p_151519_1_.func_145748_c_(), this.damageSourceEntity.func_145748_c_()}); + } + + public boolean isDifficultyScaled() + { + return this.damageSourceEntity != null && this.damageSourceEntity instanceof EntityLivingBase && !(this.damageSourceEntity instanceof EntityPlayer); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/EntityDamageSourceIndirect.java b/src/main/java/net/minecraft/util/EntityDamageSourceIndirect.java new file mode 100644 index 0000000..d8c3020 --- /dev/null +++ b/src/main/java/net/minecraft/util/EntityDamageSourceIndirect.java @@ -0,0 +1,36 @@ +package net.minecraft.util; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; + +public class EntityDamageSourceIndirect extends EntityDamageSource +{ + private Entity indirectEntity; + private static final String __OBFID = "CL_00001523"; + + public EntityDamageSourceIndirect(String par1Str, Entity par2Entity, Entity par3Entity) + { + super(par1Str, par2Entity); + this.indirectEntity = par3Entity; + } + + public Entity getSourceOfDamage() + { + return this.damageSourceEntity; + } + + public Entity getEntity() + { + return this.indirectEntity; + } + + public IChatComponent func_151519_b(EntityLivingBase p_151519_1_) + { + IChatComponent ichatcomponent = this.indirectEntity == null ? this.damageSourceEntity.func_145748_c_() : this.indirectEntity.func_145748_c_(); + ItemStack itemstack = this.indirectEntity instanceof EntityLivingBase ? ((EntityLivingBase)this.indirectEntity).getHeldItem() : null; + String s = "death.attack." + this.damageType; + String s1 = s + ".item"; + return itemstack != null && itemstack.hasDisplayName() && StatCollector.canTranslate(s1) ? new ChatComponentTranslation(s1, new Object[] {p_151519_1_.func_145748_c_(), ichatcomponent, itemstack.func_151000_E()}): new ChatComponentTranslation(s, new Object[] {p_151519_1_.func_145748_c_(), ichatcomponent}); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/EnumChatFormatting.java b/src/main/java/net/minecraft/util/EnumChatFormatting.java new file mode 100644 index 0000000..b43c26a --- /dev/null +++ b/src/main/java/net/minecraft/util/EnumChatFormatting.java @@ -0,0 +1,123 @@ +package net.minecraft.util; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.regex.Pattern; + +public enum EnumChatFormatting +{ + BLACK('0'), + DARK_BLUE('1'), + DARK_GREEN('2'), + DARK_AQUA('3'), + DARK_RED('4'), + DARK_PURPLE('5'), + GOLD('6'), + GRAY('7'), + DARK_GRAY('8'), + BLUE('9'), + GREEN('a'), + AQUA('b'), + RED('c'), + LIGHT_PURPLE('d'), + YELLOW('e'), + WHITE('f'), + OBFUSCATED('k', true), + BOLD('l', true), + STRIKETHROUGH('m', true), + UNDERLINE('n', true), + ITALIC('o', true), + RESET('r'); + private static final Map formattingCodeMapping = new HashMap(); + private static final Map nameMapping = new HashMap(); + private static final Pattern formattingCodePattern = Pattern.compile("(?i)" + String.valueOf('\u00a7') + "[0-9A-FK-OR]"); + private final char formattingCode; + private final boolean fancyStyling; + private final String controlString; + + private static final String __OBFID = "CL_00000342"; + + private EnumChatFormatting(char par3) + { + this(par3, false); + } + + private EnumChatFormatting(char par3, boolean par4) + { + this.formattingCode = par3; + this.fancyStyling = par4; + this.controlString = "\u00a7" + par3; + } + + public char getFormattingCode() + { + return this.formattingCode; + } + + public boolean isFancyStyling() + { + return this.fancyStyling; + } + + public boolean isColor() + { + return !this.fancyStyling && this != RESET; + } + + public String getFriendlyName() + { + return this.name().toLowerCase(); + } + + public String toString() + { + return this.controlString; + } + + @SideOnly(Side.CLIENT) + public static String getTextWithoutFormattingCodes(String par0Str) + { + return par0Str == null ? null : formattingCodePattern.matcher(par0Str).replaceAll(""); + } + + public static EnumChatFormatting getValueByName(String par0Str) + { + return par0Str == null ? null : (EnumChatFormatting)nameMapping.get(par0Str.toLowerCase()); + } + + public static Collection getValidValues(boolean par0, boolean par1) + { + ArrayList arraylist = new ArrayList(); + EnumChatFormatting[] aenumchatformatting = values(); + int i = aenumchatformatting.length; + + for (int j = 0; j < i; ++j) + { + EnumChatFormatting enumchatformatting = aenumchatformatting[j]; + + if ((!enumchatformatting.isColor() || par0) && (!enumchatformatting.isFancyStyling() || par1)) + { + arraylist.add(enumchatformatting.getFriendlyName()); + } + } + + return arraylist; + } + + static + { + EnumChatFormatting[] var0 = values(); + int var1 = var0.length; + + for (int var2 = 0; var2 < var1; ++var2) + { + EnumChatFormatting var3 = var0[var2]; + formattingCodeMapping.put(Character.valueOf(var3.getFormattingCode()), var3); + nameMapping.put(var3.getFriendlyName(), var3); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/EnumFacing.java b/src/main/java/net/minecraft/util/EnumFacing.java new file mode 100644 index 0000000..8e626dd --- /dev/null +++ b/src/main/java/net/minecraft/util/EnumFacing.java @@ -0,0 +1,60 @@ +package net.minecraft.util; + +public enum EnumFacing +{ + DOWN(0, 1, 0, -1, 0), + UP(1, 0, 0, 1, 0), + NORTH(2, 3, 0, 0, -1), + SOUTH(3, 2, 0, 0, 1), + EAST(4, 5, -1, 0, 0), + WEST(5, 4, 1, 0, 0); + private final int order_a; + private final int order_b; + private final int frontOffsetX; + private final int frontOffsetY; + private final int frontOffsetZ; + private static final EnumFacing[] faceList = new EnumFacing[6]; + + private static final String __OBFID = "CL_00001201"; + + private EnumFacing(int par3, int par4, int par5, int par6, int par7) + { + this.order_a = par3; + this.order_b = par4; + this.frontOffsetX = par5; + this.frontOffsetY = par6; + this.frontOffsetZ = par7; + } + + public int getFrontOffsetX() + { + return this.frontOffsetX; + } + + public int getFrontOffsetY() + { + return this.frontOffsetY; + } + + public int getFrontOffsetZ() + { + return this.frontOffsetZ; + } + + public static EnumFacing getFront(int par0) + { + return faceList[par0 % faceList.length]; + } + + static + { + EnumFacing[] var0 = values(); + int var1 = var0.length; + + for (int var2 = 0; var2 < var1; ++var2) + { + EnumFacing var3 = var0[var2]; + faceList[var3.order_a] = var3; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/EnumTypeAdapterFactory.java b/src/main/java/net/minecraft/util/EnumTypeAdapterFactory.java new file mode 100644 index 0000000..5bb73fd --- /dev/null +++ b/src/main/java/net/minecraft/util/EnumTypeAdapterFactory.java @@ -0,0 +1,72 @@ +package net.minecraft.util; + +import com.google.gson.Gson; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonToken; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.HashMap; +import java.util.Locale; + +public class EnumTypeAdapterFactory implements TypeAdapterFactory +{ + private static final String __OBFID = "CL_00001494"; + + public TypeAdapter create(Gson p_create_1_, TypeToken p_create_2_) + { + Class oclass = p_create_2_.getRawType(); + + if (!oclass.isEnum()) + { + return null; + } + else + { + final HashMap hashmap = new HashMap(); + Object[] aobject = oclass.getEnumConstants(); + int i = aobject.length; + + for (int j = 0; j < i; ++j) + { + Object object = aobject[j]; + hashmap.put(this.func_151232_a(object), object); + } + + return new TypeAdapter() + { + private static final String __OBFID = "CL_00001495"; + public void write(JsonWriter p_write_1_, Object p_write_2_) throws IOException + { + if (p_write_2_ == null) + { + p_write_1_.nullValue(); + } + else + { + p_write_1_.value(EnumTypeAdapterFactory.this.func_151232_a(p_write_2_)); + } + } + public Object read(JsonReader p_read_1_) throws IOException + { + if (p_read_1_.peek() == JsonToken.NULL) + { + p_read_1_.nextNull(); + return null; + } + else + { + return hashmap.get(p_read_1_.nextString()); + } + } + }; + } + } + + private String func_151232_a(Object p_151232_1_) + { + return p_151232_1_ instanceof Enum ? ((Enum)p_151232_1_).name().toLowerCase(Locale.US) : p_151232_1_.toString().toLowerCase(Locale.US); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/Facing.java b/src/main/java/net/minecraft/util/Facing.java new file mode 100644 index 0000000..df573e6 --- /dev/null +++ b/src/main/java/net/minecraft/util/Facing.java @@ -0,0 +1,11 @@ +package net.minecraft.util; + +public class Facing +{ + public static final int[] oppositeSide = new int[] {1, 0, 3, 2, 5, 4}; + public static final int[] offsetsXForSide = new int[] {0, 0, 0, 0, -1, 1}; + public static final int[] offsetsYForSide = new int[] { -1, 1, 0, 0, 0, 0}; + public static final int[] offsetsZForSide = new int[] {0, 0, -1, 1, 0, 0}; + public static final String[] facings = new String[] {"DOWN", "UP", "NORTH", "SOUTH", "WEST", "EAST"}; + private static final String __OBFID = "CL_00001532"; +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/FoodStats.java b/src/main/java/net/minecraft/util/FoodStats.java new file mode 100644 index 0000000..f8c56ec --- /dev/null +++ b/src/main/java/net/minecraft/util/FoodStats.java @@ -0,0 +1,137 @@ +package net.minecraft.util; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemFood; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.EnumDifficulty; + +public class FoodStats +{ + private int foodLevel = 20; + private float foodSaturationLevel = 5.0F; + private float foodExhaustionLevel; + private int foodTimer; + private int prevFoodLevel = 20; + private static final String __OBFID = "CL_00001729"; + + public void addStats(int par1, float par2) + { + this.foodLevel = Math.min(par1 + this.foodLevel, 20); + this.foodSaturationLevel = Math.min(this.foodSaturationLevel + (float)par1 * par2 * 2.0F, (float)this.foodLevel); + } + + public void func_151686_a(ItemFood p_151686_1_, ItemStack p_151686_2_) + { + this.addStats(p_151686_1_.func_150905_g(p_151686_2_), p_151686_1_.func_150906_h(p_151686_2_)); + } + + public void onUpdate(EntityPlayer par1EntityPlayer) + { + EnumDifficulty enumdifficulty = par1EntityPlayer.worldObj.difficultySetting; + this.prevFoodLevel = this.foodLevel; + + if (this.foodExhaustionLevel > 4.0F) + { + this.foodExhaustionLevel -= 4.0F; + + if (this.foodSaturationLevel > 0.0F) + { + this.foodSaturationLevel = Math.max(this.foodSaturationLevel - 1.0F, 0.0F); + } + else if (enumdifficulty != EnumDifficulty.PEACEFUL) + { + this.foodLevel = Math.max(this.foodLevel - 1, 0); + } + } + + if (par1EntityPlayer.worldObj.getGameRules().getGameRuleBooleanValue("naturalRegeneration") && this.foodLevel >= 18 && par1EntityPlayer.shouldHeal()) + { + ++this.foodTimer; + + if (this.foodTimer >= 80) + { + par1EntityPlayer.heal(1.0F); + this.addExhaustion(3.0F); + this.foodTimer = 0; + } + } + else if (this.foodLevel <= 0) + { + ++this.foodTimer; + + if (this.foodTimer >= 80) + { + if (par1EntityPlayer.getHealth() > 10.0F || enumdifficulty == EnumDifficulty.HARD || par1EntityPlayer.getHealth() > 1.0F && enumdifficulty == EnumDifficulty.NORMAL) + { + par1EntityPlayer.attackEntityFrom(DamageSource.starve, 1.0F); + } + + this.foodTimer = 0; + } + } + else + { + this.foodTimer = 0; + } + } + + public void readNBT(NBTTagCompound par1NBTTagCompound) + { + if (par1NBTTagCompound.hasKey("foodLevel", 99)) + { + this.foodLevel = par1NBTTagCompound.getInteger("foodLevel"); + this.foodTimer = par1NBTTagCompound.getInteger("foodTickTimer"); + this.foodSaturationLevel = par1NBTTagCompound.getFloat("foodSaturationLevel"); + this.foodExhaustionLevel = par1NBTTagCompound.getFloat("foodExhaustionLevel"); + } + } + + public void writeNBT(NBTTagCompound par1NBTTagCompound) + { + par1NBTTagCompound.setInteger("foodLevel", this.foodLevel); + par1NBTTagCompound.setInteger("foodTickTimer", this.foodTimer); + par1NBTTagCompound.setFloat("foodSaturationLevel", this.foodSaturationLevel); + par1NBTTagCompound.setFloat("foodExhaustionLevel", this.foodExhaustionLevel); + } + + public int getFoodLevel() + { + return this.foodLevel; + } + + @SideOnly(Side.CLIENT) + public int getPrevFoodLevel() + { + return this.prevFoodLevel; + } + + public boolean needFood() + { + return this.foodLevel < 20; + } + + public void addExhaustion(float par1) + { + this.foodExhaustionLevel = Math.min(this.foodExhaustionLevel + par1, 40.0F); + } + + public float getSaturationLevel() + { + return this.foodSaturationLevel; + } + + @SideOnly(Side.CLIENT) + public void setFoodLevel(int par1) + { + this.foodLevel = par1; + } + + @SideOnly(Side.CLIENT) + public void setFoodSaturationLevel(float par1) + { + this.foodSaturationLevel = par1; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/HttpUtil.java b/src/main/java/net/minecraft/util/HttpUtil.java new file mode 100644 index 0000000..dfd1aa5 --- /dev/null +++ b/src/main/java/net/minecraft/util/HttpUtil.java @@ -0,0 +1,316 @@ +package net.minecraft.util; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.BufferedReader; +import java.io.DataOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.UnsupportedEncodingException; +import java.net.HttpURLConnection; +import java.net.Proxy; +import java.net.ServerSocket; +import java.net.URL; +import java.net.URLConnection; +import java.net.URLEncoder; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; +import java.util.concurrent.atomic.AtomicInteger; +import net.minecraft.server.MinecraftServer; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class HttpUtil +{ + private static final AtomicInteger downloadThreadsStarted = new AtomicInteger(0); + private static final Logger logger = LogManager.getLogger(); + private static final String __OBFID = "CL_00001485"; + + public static String buildPostString(Map par0Map) + { + StringBuilder stringbuilder = new StringBuilder(); + Iterator iterator = par0Map.entrySet().iterator(); + + while (iterator.hasNext()) + { + Entry entry = (Entry)iterator.next(); + + if (stringbuilder.length() > 0) + { + stringbuilder.append('&'); + } + + try + { + stringbuilder.append(URLEncoder.encode((String)entry.getKey(), "UTF-8")); + } + catch (UnsupportedEncodingException unsupportedencodingexception1) + { + unsupportedencodingexception1.printStackTrace(); + } + + if (entry.getValue() != null) + { + stringbuilder.append('='); + + try + { + stringbuilder.append(URLEncoder.encode(entry.getValue().toString(), "UTF-8")); + } + catch (UnsupportedEncodingException unsupportedencodingexception) + { + unsupportedencodingexception.printStackTrace(); + } + } + } + + return stringbuilder.toString(); + } + + public static String func_151226_a(URL p_151226_0_, Map p_151226_1_, boolean p_151226_2_) + { + return func_151225_a(p_151226_0_, buildPostString(p_151226_1_), p_151226_2_); + } + + private static String func_151225_a(URL p_151225_0_, String p_151225_1_, boolean p_151225_2_) + { + try + { + Proxy proxy = MinecraftServer.getServer() == null ? null : MinecraftServer.getServer().getServerProxy(); + + if (proxy == null) + { + proxy = Proxy.NO_PROXY; + } + + HttpURLConnection httpurlconnection = (HttpURLConnection)p_151225_0_.openConnection(proxy); + httpurlconnection.setRequestMethod("POST"); + httpurlconnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); + httpurlconnection.setRequestProperty("Content-Length", "" + p_151225_1_.getBytes().length); + httpurlconnection.setRequestProperty("Content-Language", "en-US"); + httpurlconnection.setUseCaches(false); + httpurlconnection.setDoInput(true); + httpurlconnection.setDoOutput(true); + DataOutputStream dataoutputstream = new DataOutputStream(httpurlconnection.getOutputStream()); + dataoutputstream.writeBytes(p_151225_1_); + dataoutputstream.flush(); + dataoutputstream.close(); + BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(httpurlconnection.getInputStream())); + StringBuffer stringbuffer = new StringBuffer(); + String s1; + + while ((s1 = bufferedreader.readLine()) != null) + { + stringbuffer.append(s1); + stringbuffer.append('\r'); + } + + bufferedreader.close(); + return stringbuffer.toString(); + } + catch (Exception exception) + { + if (!p_151225_2_) + { + logger.error("Could not post to " + p_151225_0_, exception); + } + + return ""; + } + } + + @SideOnly(Side.CLIENT) + public static void func_151223_a(final File p_151223_0_, final String p_151223_1_, final HttpUtil.DownloadListener p_151223_2_, final Map p_151223_3_, final int p_151223_4_, final IProgressUpdate p_151223_5_, final Proxy p_151223_6_) + { + Thread thread = new Thread(new Runnable() + { + private static final String __OBFID = "CL_00001486"; + public void run() + { + URLConnection urlconnection = null; + InputStream inputstream = null; + DataOutputStream dataoutputstream = null; + + if (p_151223_5_ != null) + { + p_151223_5_.resetProgressAndMessage("Downloading Texture Pack"); + p_151223_5_.resetProgresAndWorkingMessage("Making Request..."); + } + + try + { + try + { + byte[] abyte = new byte[4096]; + URL url = new URL(p_151223_1_); + urlconnection = url.openConnection(p_151223_6_); + float f = 0.0F; + float f1 = (float)p_151223_3_.entrySet().size(); + Iterator iterator = p_151223_3_.entrySet().iterator(); + + while (iterator.hasNext()) + { + Entry entry = (Entry)iterator.next(); + urlconnection.setRequestProperty((String)entry.getKey(), (String)entry.getValue()); + + if (p_151223_5_ != null) + { + p_151223_5_.setLoadingProgress((int)(++f / f1 * 100.0F)); + } + } + + inputstream = urlconnection.getInputStream(); + f1 = (float)urlconnection.getContentLength(); + int i = urlconnection.getContentLength(); + + if (p_151223_5_ != null) + { + p_151223_5_.resetProgresAndWorkingMessage(String.format("Downloading file (%.2f MB)...", new Object[] {Float.valueOf(f1 / 1000.0F / 1000.0F)})); + } + + if (p_151223_0_.exists()) + { + long j = p_151223_0_.length(); + + if (j == (long)i) + { + p_151223_2_.func_148522_a(p_151223_0_); + + if (p_151223_5_ != null) + { + p_151223_5_.func_146586_a(); + } + + return; + } + + HttpUtil.logger.warn("Deleting " + p_151223_0_ + " as it does not match what we currently have (" + i + " vs our " + j + ")."); + p_151223_0_.delete(); + } + else if (p_151223_0_.getParentFile() != null) + { + p_151223_0_.getParentFile().mkdirs(); + } + + dataoutputstream = new DataOutputStream(new FileOutputStream(p_151223_0_)); + + if (p_151223_4_ > 0 && f1 > (float)p_151223_4_) + { + if (p_151223_5_ != null) + { + p_151223_5_.func_146586_a(); + } + + throw new IOException("Filesize is bigger than maximum allowed (file is " + f + ", limit is " + p_151223_4_ + ")"); + } + + boolean flag = false; + int k; + + while ((k = inputstream.read(abyte)) >= 0) + { + f += (float)k; + + if (p_151223_5_ != null) + { + p_151223_5_.setLoadingProgress((int)(f / f1 * 100.0F)); + } + + if (p_151223_4_ > 0 && f > (float)p_151223_4_) + { + if (p_151223_5_ != null) + { + p_151223_5_.func_146586_a(); + } + + throw new IOException("Filesize was bigger than maximum allowed (got >= " + f + ", limit was " + p_151223_4_ + ")"); + } + + dataoutputstream.write(abyte, 0, k); + } + + p_151223_2_.func_148522_a(p_151223_0_); + + if (p_151223_5_ != null) + { + p_151223_5_.func_146586_a(); + return; + } + } + catch (Throwable throwable) + { + throwable.printStackTrace(); + } + } + finally + { + try + { + if (inputstream != null) + { + inputstream.close(); + } + } + catch (IOException ioexception1) + { + ; + } + + try + { + if (dataoutputstream != null) + { + dataoutputstream.close(); + } + } + catch (IOException ioexception) + { + ; + } + } + } + }, "File Downloader #" + downloadThreadsStarted.incrementAndGet()); + thread.setDaemon(true); + thread.start(); + } + + @SideOnly(Side.CLIENT) + public static int func_76181_a() throws IOException + { + ServerSocket serversocket = null; + boolean flag = true; + int i; + + try + { + serversocket = new ServerSocket(0); + i = serversocket.getLocalPort(); + } + finally + { + try + { + if (serversocket != null) + { + serversocket.close(); + } + } + catch (IOException ioexception) + { + ; + } + } + + return i; + } + + @SideOnly(Side.CLIENT) + public interface DownloadListener + { + void func_148522_a(File var1); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/IChatComponent.java b/src/main/java/net/minecraft/util/IChatComponent.java new file mode 100644 index 0000000..85b15e2 --- /dev/null +++ b/src/main/java/net/minecraft/util/IChatComponent.java @@ -0,0 +1,261 @@ +package net.minecraft.util; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.JsonPrimitive; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.lang.reflect.Type; +import java.util.Iterator; +import java.util.List; +import java.util.Map.Entry; + +public interface IChatComponent extends Iterable +{ + IChatComponent setChatStyle(ChatStyle var1); + + ChatStyle getChatStyle(); + + IChatComponent appendText(String var1); + + IChatComponent appendSibling(IChatComponent var1); + + String getUnformattedTextForChat(); + + String getUnformattedText(); + + @SideOnly(Side.CLIENT) + String getFormattedText(); + + List getSiblings(); + + IChatComponent createCopy(); + + public static class Serializer implements JsonDeserializer, JsonSerializer + { + private static final Gson field_150700_a; + private static final String __OBFID = "CL_00001263"; + + public IChatComponent deserialize(JsonElement p_150698_1_, Type p_150698_2_, JsonDeserializationContext p_150698_3_) + { + if (p_150698_1_.isJsonPrimitive()) + { + return new ChatComponentText(p_150698_1_.getAsString()); + } + else if (!p_150698_1_.isJsonObject()) + { + if (p_150698_1_.isJsonArray()) + { + JsonArray jsonarray1 = p_150698_1_.getAsJsonArray(); + IChatComponent ichatcomponent = null; + Iterator iterator = jsonarray1.iterator(); + + while (iterator.hasNext()) + { + JsonElement jsonelement1 = (JsonElement)iterator.next(); + IChatComponent ichatcomponent1 = this.deserialize(jsonelement1, jsonelement1.getClass(), p_150698_3_); + + if (ichatcomponent == null) + { + ichatcomponent = ichatcomponent1; + } + else + { + ichatcomponent.appendSibling(ichatcomponent1); + } + } + + return ichatcomponent; + } + else + { + throw new JsonParseException("Don\'t know how to turn " + p_150698_1_.toString() + " into a Component"); + } + } + else + { + JsonObject jsonobject = p_150698_1_.getAsJsonObject(); + Object object; + + if (jsonobject.has("text")) + { + object = new ChatComponentText(jsonobject.get("text").getAsString()); + } + else + { + if (!jsonobject.has("translate")) + { + throw new JsonParseException("Don\'t know how to turn " + p_150698_1_.toString() + " into a Component"); + } + + String s = jsonobject.get("translate").getAsString(); + + if (jsonobject.has("with")) + { + JsonArray jsonarray = jsonobject.getAsJsonArray("with"); + Object[] aobject = new Object[jsonarray.size()]; + + for (int i = 0; i < aobject.length; ++i) + { + aobject[i] = this.deserialize(jsonarray.get(i), p_150698_2_, p_150698_3_); + + if (aobject[i] instanceof ChatComponentText) + { + ChatComponentText chatcomponenttext = (ChatComponentText)aobject[i]; + + if (chatcomponenttext.getChatStyle().isEmpty() && chatcomponenttext.getSiblings().isEmpty()) + { + aobject[i] = chatcomponenttext.getChatComponentText_TextValue(); + } + } + } + + object = new ChatComponentTranslation(s, aobject); + } + else + { + object = new ChatComponentTranslation(s, new Object[0]); + } + } + + if (jsonobject.has("extra")) + { + JsonArray jsonarray2 = jsonobject.getAsJsonArray("extra"); + + if (jsonarray2.size() <= 0) + { + throw new JsonParseException("Unexpected empty array of components"); + } + + for (int j = 0; j < jsonarray2.size(); ++j) + { + ((IChatComponent)object).appendSibling(this.deserialize(jsonarray2.get(j), p_150698_2_, p_150698_3_)); + } + } + + ((IChatComponent)object).setChatStyle((ChatStyle)p_150698_3_.deserialize(p_150698_1_, ChatStyle.class)); + return (IChatComponent)object; + } + } + + private void func_150695_a(ChatStyle p_150695_1_, JsonObject p_150695_2_, JsonSerializationContext p_150695_3_) + { + JsonElement jsonelement = p_150695_3_.serialize(p_150695_1_); + + if (jsonelement.isJsonObject()) + { + JsonObject jsonobject1 = (JsonObject)jsonelement; + Iterator iterator = jsonobject1.entrySet().iterator(); + + while (iterator.hasNext()) + { + Entry entry = (Entry)iterator.next(); + p_150695_2_.add((String)entry.getKey(), (JsonElement)entry.getValue()); + } + } + } + + public JsonElement serialize(IChatComponent p_150697_1_, Type p_150697_2_, JsonSerializationContext p_150697_3_) + { + if (p_150697_1_ instanceof ChatComponentText && p_150697_1_.getChatStyle().isEmpty() && p_150697_1_.getSiblings().isEmpty()) + { + return new JsonPrimitive(((ChatComponentText)p_150697_1_).getChatComponentText_TextValue()); + } + else + { + JsonObject jsonobject = new JsonObject(); + + if (!p_150697_1_.getChatStyle().isEmpty()) + { + this.func_150695_a(p_150697_1_.getChatStyle(), jsonobject, p_150697_3_); + } + + if (!p_150697_1_.getSiblings().isEmpty()) + { + JsonArray jsonarray = new JsonArray(); + Iterator iterator = p_150697_1_.getSiblings().iterator(); + + while (iterator.hasNext()) + { + IChatComponent ichatcomponent1 = (IChatComponent)iterator.next(); + jsonarray.add(this.serialize(ichatcomponent1, ichatcomponent1.getClass(), p_150697_3_)); + } + + jsonobject.add("extra", jsonarray); + } + + if (p_150697_1_ instanceof ChatComponentText) + { + jsonobject.addProperty("text", ((ChatComponentText)p_150697_1_).getChatComponentText_TextValue()); + } + else + { + if (!(p_150697_1_ instanceof ChatComponentTranslation)) + { + throw new IllegalArgumentException("Don\'t know how to serialize " + p_150697_1_ + " as a Component"); + } + + ChatComponentTranslation chatcomponenttranslation = (ChatComponentTranslation)p_150697_1_; + jsonobject.addProperty("translate", chatcomponenttranslation.getKey()); + + if (chatcomponenttranslation.getFormatArgs() != null && chatcomponenttranslation.getFormatArgs().length > 0) + { + JsonArray jsonarray1 = new JsonArray(); + Object[] aobject = chatcomponenttranslation.getFormatArgs(); + int i = aobject.length; + + for (int j = 0; j < i; ++j) + { + Object object = aobject[j]; + + if (object instanceof IChatComponent) + { + jsonarray1.add(this.serialize((IChatComponent)object, object.getClass(), p_150697_3_)); + } + else + { + jsonarray1.add(new JsonPrimitive(String.valueOf(object))); + } + } + + jsonobject.add("with", jsonarray1); + } + } + + return jsonobject; + } + } + + public static String func_150696_a(IChatComponent p_150696_0_) + { + return field_150700_a.toJson(p_150696_0_); + } + + public static IChatComponent func_150699_a(String p_150699_0_) + { + return (IChatComponent)field_150700_a.fromJson(p_150699_0_, IChatComponent.class); + } + + public JsonElement serialize(Object par1Obj, Type par2Type, JsonSerializationContext par3JsonSerializationContext) + { + return this.serialize((IChatComponent)par1Obj, par2Type, par3JsonSerializationContext); + } + + static + { + GsonBuilder var0 = new GsonBuilder(); + var0.registerTypeHierarchyAdapter(IChatComponent.class, new IChatComponent.Serializer()); + var0.registerTypeHierarchyAdapter(ChatStyle.class, new ChatStyle.Serializer()); + var0.registerTypeAdapterFactory(new EnumTypeAdapterFactory()); + field_150700_a = var0.create(); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/IIcon.java b/src/main/java/net/minecraft/util/IIcon.java new file mode 100644 index 0000000..a111896 --- /dev/null +++ b/src/main/java/net/minecraft/util/IIcon.java @@ -0,0 +1,34 @@ +package net.minecraft.util; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public interface IIcon +{ + @SideOnly(Side.CLIENT) + int getIconWidth(); + + @SideOnly(Side.CLIENT) + int getIconHeight(); + + @SideOnly(Side.CLIENT) + float getMinU(); + + @SideOnly(Side.CLIENT) + float getMaxU(); + + @SideOnly(Side.CLIENT) + float getInterpolatedU(double var1); + + @SideOnly(Side.CLIENT) + float getMinV(); + + @SideOnly(Side.CLIENT) + float getMaxV(); + + @SideOnly(Side.CLIENT) + float getInterpolatedV(double var1); + + @SideOnly(Side.CLIENT) + String getIconName(); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/IJsonSerializable.java b/src/main/java/net/minecraft/util/IJsonSerializable.java new file mode 100644 index 0000000..2702a2a --- /dev/null +++ b/src/main/java/net/minecraft/util/IJsonSerializable.java @@ -0,0 +1,8 @@ +package net.minecraft.util; + +import com.google.gson.JsonElement; + +public interface IJsonSerializable +{ + JsonElement getSerializableElement(); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/IObjectIntIterable.java b/src/main/java/net/minecraft/util/IObjectIntIterable.java new file mode 100644 index 0000000..bd2f746 --- /dev/null +++ b/src/main/java/net/minecraft/util/IObjectIntIterable.java @@ -0,0 +1,5 @@ +package net.minecraft.util; + +public interface IObjectIntIterable extends Iterable +{ +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/IProgressUpdate.java b/src/main/java/net/minecraft/util/IProgressUpdate.java new file mode 100644 index 0000000..ff79fe4 --- /dev/null +++ b/src/main/java/net/minecraft/util/IProgressUpdate.java @@ -0,0 +1,19 @@ +package net.minecraft.util; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public interface IProgressUpdate +{ + void displayProgressMessage(String var1); + + @SideOnly(Side.CLIENT) + void resetProgressAndMessage(String var1); + + void resetProgresAndWorkingMessage(String var1); + + void setLoadingProgress(int var1); + + @SideOnly(Side.CLIENT) + void func_146586_a(); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/IRegistry.java b/src/main/java/net/minecraft/util/IRegistry.java new file mode 100644 index 0000000..d7114d5 --- /dev/null +++ b/src/main/java/net/minecraft/util/IRegistry.java @@ -0,0 +1,8 @@ +package net.minecraft.util; + +public interface IRegistry +{ + Object getObject(Object var1); + + void putObject(Object var1, Object var2); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/IntHashMap.java b/src/main/java/net/minecraft/util/IntHashMap.java new file mode 100644 index 0000000..25f41a6 --- /dev/null +++ b/src/main/java/net/minecraft/util/IntHashMap.java @@ -0,0 +1,255 @@ +package net.minecraft.util; + +import java.util.HashSet; +import java.util.Set; + +public class IntHashMap +{ + private transient IntHashMap.Entry[] slots = new IntHashMap.Entry[16]; + private transient int count; + private int threshold = 12; + private final float growFactor = 0.75F; + private transient volatile int versionStamp; + private Set keySet = new HashSet(); + private static final String __OBFID = "CL_00001490"; + + private static int computeHash(int par0) + { + par0 ^= par0 >>> 20 ^ par0 >>> 12; + return par0 ^ par0 >>> 7 ^ par0 >>> 4; + } + + private static int getSlotIndex(int par0, int par1) + { + return par0 & par1 - 1; + } + + public Object lookup(int par1) + { + int j = computeHash(par1); + + for (IntHashMap.Entry entry = this.slots[getSlotIndex(j, this.slots.length)]; entry != null; entry = entry.nextEntry) + { + if (entry.hashEntry == par1) + { + return entry.valueEntry; + } + } + + return null; + } + + public boolean containsItem(int par1) + { + return this.lookupEntry(par1) != null; + } + + final IntHashMap.Entry lookupEntry(int par1) + { + int j = computeHash(par1); + + for (IntHashMap.Entry entry = this.slots[getSlotIndex(j, this.slots.length)]; entry != null; entry = entry.nextEntry) + { + if (entry.hashEntry == par1) + { + return entry; + } + } + + return null; + } + + public void addKey(int par1, Object par2Obj) + { + this.keySet.add(Integer.valueOf(par1)); + int j = computeHash(par1); + int k = getSlotIndex(j, this.slots.length); + + for (IntHashMap.Entry entry = this.slots[k]; entry != null; entry = entry.nextEntry) + { + if (entry.hashEntry == par1) + { + entry.valueEntry = par2Obj; + return; + } + } + + ++this.versionStamp; + this.insert(j, par1, par2Obj, k); + } + + private void grow(int par1) + { + IntHashMap.Entry[] aentry = this.slots; + int j = aentry.length; + + if (j == 1073741824) + { + this.threshold = Integer.MAX_VALUE; + } + else + { + IntHashMap.Entry[] aentry1 = new IntHashMap.Entry[par1]; + this.copyTo(aentry1); + this.slots = aentry1; + this.threshold = (int)((float)par1 * this.growFactor); + } + } + + private void copyTo(IntHashMap.Entry[] par1ArrayOfIntHashMapEntry) + { + IntHashMap.Entry[] aentry = this.slots; + int i = par1ArrayOfIntHashMapEntry.length; + + for (int j = 0; j < aentry.length; ++j) + { + IntHashMap.Entry entry = aentry[j]; + + if (entry != null) + { + aentry[j] = null; + IntHashMap.Entry entry1; + + do + { + entry1 = entry.nextEntry; + int k = getSlotIndex(entry.slotHash, i); + entry.nextEntry = par1ArrayOfIntHashMapEntry[k]; + par1ArrayOfIntHashMapEntry[k] = entry; + entry = entry1; + } + while (entry1 != null); + } + } + } + + public Object removeObject(int par1) + { + this.keySet.remove(Integer.valueOf(par1)); + IntHashMap.Entry entry = this.removeEntry(par1); + return entry == null ? null : entry.valueEntry; + } + + final IntHashMap.Entry removeEntry(int par1) + { + int j = computeHash(par1); + int k = getSlotIndex(j, this.slots.length); + IntHashMap.Entry entry = this.slots[k]; + IntHashMap.Entry entry1; + IntHashMap.Entry entry2; + + for (entry1 = entry; entry1 != null; entry1 = entry2) + { + entry2 = entry1.nextEntry; + + if (entry1.hashEntry == par1) + { + ++this.versionStamp; + --this.count; + + if (entry == entry1) + { + this.slots[k] = entry2; + } + else + { + entry.nextEntry = entry2; + } + + return entry1; + } + + entry = entry1; + } + + return entry1; + } + + public void clearMap() + { + ++this.versionStamp; + IntHashMap.Entry[] aentry = this.slots; + + for (int i = 0; i < aentry.length; ++i) + { + aentry[i] = null; + } + + this.count = 0; + } + + private void insert(int par1, int par2, Object par3Obj, int par4) + { + IntHashMap.Entry entry = this.slots[par4]; + this.slots[par4] = new IntHashMap.Entry(par1, par2, par3Obj, entry); + + if (this.count++ >= this.threshold) + { + this.grow(2 * this.slots.length); + } + } + + static class Entry + { + final int hashEntry; + Object valueEntry; + IntHashMap.Entry nextEntry; + final int slotHash; + private static final String __OBFID = "CL_00001491"; + + Entry(int par1, int par2, Object par3Obj, IntHashMap.Entry par4IntHashMapEntry) + { + this.valueEntry = par3Obj; + this.nextEntry = par4IntHashMapEntry; + this.hashEntry = par2; + this.slotHash = par1; + } + + public final int getHash() + { + return this.hashEntry; + } + + public final Object getValue() + { + return this.valueEntry; + } + + public final boolean equals(Object par1Obj) + { + if (!(par1Obj instanceof IntHashMap.Entry)) + { + return false; + } + else + { + IntHashMap.Entry entry = (IntHashMap.Entry)par1Obj; + Integer integer = Integer.valueOf(this.getHash()); + Integer integer1 = Integer.valueOf(entry.getHash()); + + if (integer == integer1 || integer != null && integer.equals(integer1)) + { + Object object1 = this.getValue(); + Object object2 = entry.getValue(); + + if (object1 == object2 || object1 != null && object1.equals(object2)) + { + return true; + } + } + + return false; + } + } + + public final int hashCode() + { + return IntHashMap.computeHash(this.hashEntry); + } + + public final String toString() + { + return this.getHash() + "=" + this.getValue(); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/JsonSerializableSet.java b/src/main/java/net/minecraft/util/JsonSerializableSet.java new file mode 100644 index 0000000..5e74fc8 --- /dev/null +++ b/src/main/java/net/minecraft/util/JsonSerializableSet.java @@ -0,0 +1,35 @@ +package net.minecraft.util; + +import com.google.common.collect.ForwardingSet; +import com.google.common.collect.Sets; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonPrimitive; +import java.util.Collection; +import java.util.Iterator; +import java.util.Set; + +public class JsonSerializableSet extends ForwardingSet implements IJsonSerializable +{ + private final Set underlyingSet = Sets.newHashSet(); + private static final String __OBFID = "CL_00001482"; + + public JsonElement getSerializableElement() + { + JsonArray jsonarray = new JsonArray(); + Iterator iterator = this.iterator(); + + while (iterator.hasNext()) + { + String s = (String)iterator.next(); + jsonarray.add(new JsonPrimitive(s)); + } + + return jsonarray; + } + + protected Set delegate() + { + return this.underlyingSet; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/JsonUtils.java b/src/main/java/net/minecraft/util/JsonUtils.java new file mode 100644 index 0000000..4ee99e5 --- /dev/null +++ b/src/main/java/net/minecraft/util/JsonUtils.java @@ -0,0 +1,255 @@ +package net.minecraft.util; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonPrimitive; +import com.google.gson.JsonSyntaxException; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class JsonUtils +{ + private static final String __OBFID = "CL_00001484"; + + @SideOnly(Side.CLIENT) + public static boolean jsonObjectFieldTypeIsString(JsonObject p_151205_0_, String p_151205_1_) + { + return !jsonObjectFieldTypeIsPrimitive(p_151205_0_, p_151205_1_) ? false : p_151205_0_.getAsJsonPrimitive(p_151205_1_).isString(); + } + + @SideOnly(Side.CLIENT) + public static boolean jsonElementTypeIsString(JsonElement p_151211_0_) + { + return !p_151211_0_.isJsonPrimitive() ? false : p_151211_0_.getAsJsonPrimitive().isString(); + } + + public static boolean jsonObjectFieldTypeIsArray(JsonObject p_151202_0_, String p_151202_1_) + { + return !jsonObjectHasNamedField(p_151202_0_, p_151202_1_) ? false : p_151202_0_.get(p_151202_1_).isJsonArray(); + } + + @SideOnly(Side.CLIENT) + public static boolean jsonObjectFieldTypeIsPrimitive(JsonObject p_151201_0_, String p_151201_1_) + { + return !jsonObjectHasNamedField(p_151201_0_, p_151201_1_) ? false : p_151201_0_.get(p_151201_1_).isJsonPrimitive(); + } + + public static boolean jsonObjectHasNamedField(JsonObject p_151204_0_, String p_151204_1_) + { + return p_151204_0_ == null ? false : p_151204_0_.get(p_151204_1_) != null; + } + + public static String getJsonElementStringValue(JsonElement p_151206_0_, String p_151206_1_) + { + if (p_151206_0_.isJsonPrimitive()) + { + return p_151206_0_.getAsString(); + } + else + { + throw new JsonSyntaxException("Expected " + p_151206_1_ + " to be a string, was " + getJsonElementTypeDescription(p_151206_0_)); + } + } + + public static String getJsonObjectStringFieldValue(JsonObject p_151200_0_, String p_151200_1_) + { + if (p_151200_0_.has(p_151200_1_)) + { + return getJsonElementStringValue(p_151200_0_.get(p_151200_1_), p_151200_1_); + } + else + { + throw new JsonSyntaxException("Missing " + p_151200_1_ + ", expected to find a string"); + } + } + + @SideOnly(Side.CLIENT) + public static String getJsonObjectStringFieldValueOrDefault(JsonObject p_151219_0_, String p_151219_1_, String p_151219_2_) + { + return p_151219_0_.has(p_151219_1_) ? getJsonElementStringValue(p_151219_0_.get(p_151219_1_), p_151219_1_) : p_151219_2_; + } + + @SideOnly(Side.CLIENT) + public static boolean getJsonElementBooleanValue(JsonElement p_151216_0_, String p_151216_1_) + { + if (p_151216_0_.isJsonPrimitive()) + { + return p_151216_0_.getAsBoolean(); + } + else + { + throw new JsonSyntaxException("Expected " + p_151216_1_ + " to be a Boolean, was " + getJsonElementTypeDescription(p_151216_0_)); + } + } + + @SideOnly(Side.CLIENT) + public static boolean getJsonObjectBooleanFieldValue(JsonObject p_151212_0_, String p_151212_1_) + { + if (p_151212_0_.has(p_151212_1_)) + { + return getJsonElementBooleanValue(p_151212_0_.get(p_151212_1_), p_151212_1_); + } + else + { + throw new JsonSyntaxException("Missing " + p_151212_1_ + ", expected to find a Boolean"); + } + } + + @SideOnly(Side.CLIENT) + public static boolean getJsonObjectBooleanFieldValueOrDefault(JsonObject p_151209_0_, String p_151209_1_, boolean p_151209_2_) + { + return p_151209_0_.has(p_151209_1_) ? getJsonElementBooleanValue(p_151209_0_.get(p_151209_1_), p_151209_1_) : p_151209_2_; + } + + @SideOnly(Side.CLIENT) + public static float getJsonElementFloatValue(JsonElement p_151220_0_, String p_151220_1_) + { + if (p_151220_0_.isJsonPrimitive() && p_151220_0_.getAsJsonPrimitive().isNumber()) + { + return p_151220_0_.getAsFloat(); + } + else + { + throw new JsonSyntaxException("Expected " + p_151220_1_ + " to be a Float, was " + getJsonElementTypeDescription(p_151220_0_)); + } + } + + @SideOnly(Side.CLIENT) + public static float getJsonObjectFloatFieldValue(JsonObject p_151217_0_, String p_151217_1_) + { + if (p_151217_0_.has(p_151217_1_)) + { + return getJsonElementFloatValue(p_151217_0_.get(p_151217_1_), p_151217_1_); + } + else + { + throw new JsonSyntaxException("Missing " + p_151217_1_ + ", expected to find a Float"); + } + } + + @SideOnly(Side.CLIENT) + public static float getJsonObjectFloatFieldValueOrDefault(JsonObject p_151221_0_, String p_151221_1_, float p_151221_2_) + { + return p_151221_0_.has(p_151221_1_) ? getJsonElementFloatValue(p_151221_0_.get(p_151221_1_), p_151221_1_) : p_151221_2_; + } + + public static int getJsonElementIntegerValue(JsonElement p_151215_0_, String p_151215_1_) + { + if (p_151215_0_.isJsonPrimitive() && p_151215_0_.getAsJsonPrimitive().isNumber()) + { + return p_151215_0_.getAsInt(); + } + else + { + throw new JsonSyntaxException("Expected " + p_151215_1_ + " to be a Int, was " + getJsonElementTypeDescription(p_151215_0_)); + } + } + + public static int getJsonObjectIntegerFieldValue(JsonObject p_151203_0_, String p_151203_1_) + { + if (p_151203_0_.has(p_151203_1_)) + { + return getJsonElementIntegerValue(p_151203_0_.get(p_151203_1_), p_151203_1_); + } + else + { + throw new JsonSyntaxException("Missing " + p_151203_1_ + ", expected to find a Int"); + } + } + + @SideOnly(Side.CLIENT) + public static int getJsonObjectIntegerFieldValueOrDefault(JsonObject p_151208_0_, String p_151208_1_, int p_151208_2_) + { + return p_151208_0_.has(p_151208_1_) ? getJsonElementIntegerValue(p_151208_0_.get(p_151208_1_), p_151208_1_) : p_151208_2_; + } + + public static JsonObject getJsonElementAsJsonObject(JsonElement p_151210_0_, String p_151210_1_) + { + if (p_151210_0_.isJsonObject()) + { + return p_151210_0_.getAsJsonObject(); + } + else + { + throw new JsonSyntaxException("Expected " + p_151210_1_ + " to be a JsonObject, was " + getJsonElementTypeDescription(p_151210_0_)); + } + } + + @SideOnly(Side.CLIENT) + public static JsonObject getJsonObjectFieldOrDefault(JsonObject p_151218_0_, String p_151218_1_, JsonObject p_151218_2_) + { + return p_151218_0_.has(p_151218_1_) ? getJsonElementAsJsonObject(p_151218_0_.get(p_151218_1_), p_151218_1_) : p_151218_2_; + } + + public static JsonArray getJsonElementAsJsonArray(JsonElement p_151207_0_, String p_151207_1_) + { + if (p_151207_0_.isJsonArray()) + { + return p_151207_0_.getAsJsonArray(); + } + else + { + throw new JsonSyntaxException("Expected " + p_151207_1_ + " to be a JsonArray, was " + getJsonElementTypeDescription(p_151207_0_)); + } + } + + public static JsonArray getJsonObjectJsonArrayField(JsonObject p_151214_0_, String p_151214_1_) + { + if (p_151214_0_.has(p_151214_1_)) + { + return getJsonElementAsJsonArray(p_151214_0_.get(p_151214_1_), p_151214_1_); + } + else + { + throw new JsonSyntaxException("Missing " + p_151214_1_ + ", expected to find a JsonArray"); + } + } + + @SideOnly(Side.CLIENT) + public static JsonArray getJsonObjectJsonArrayFieldOrDefault(JsonObject p_151213_0_, String p_151213_1_, JsonArray p_151213_2_) + { + return p_151213_0_.has(p_151213_1_) ? getJsonElementAsJsonArray(p_151213_0_.get(p_151213_1_), p_151213_1_) : p_151213_2_; + } + + public static String getJsonElementTypeDescription(JsonElement p_151222_0_) + { + String s = org.apache.commons.lang3.StringUtils.abbreviateMiddle(String.valueOf(p_151222_0_), "...", 10); + + if (p_151222_0_ == null) + { + return "null (missing)"; + } + else if (p_151222_0_.isJsonNull()) + { + return "null (json)"; + } + else if (p_151222_0_.isJsonArray()) + { + return "an array (" + s + ")"; + } + else if (p_151222_0_.isJsonObject()) + { + return "an object (" + s + ")"; + } + else + { + if (p_151222_0_.isJsonPrimitive()) + { + JsonPrimitive jsonprimitive = p_151222_0_.getAsJsonPrimitive(); + + if (jsonprimitive.isNumber()) + { + return "a number (" + s + ")"; + } + + if (jsonprimitive.isBoolean()) + { + return "a boolean (" + s + ")"; + } + } + + return s; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/LongHashMap.java b/src/main/java/net/minecraft/util/LongHashMap.java new file mode 100644 index 0000000..e3e8d3d --- /dev/null +++ b/src/main/java/net/minecraft/util/LongHashMap.java @@ -0,0 +1,246 @@ +package net.minecraft.util; + +public class LongHashMap +{ + private transient LongHashMap.Entry[] hashArray = new LongHashMap.Entry[16]; + private transient int numHashElements; + private int capacity = 12; + private final float percentUseable = 0.75F; + private transient volatile int modCount; + private static final String __OBFID = "CL_00001492"; + + private static int getHashedKey(long par0) + { + return hash((int)(par0 ^ par0 >>> 32)); + } + + private static int hash(int par0) + { + par0 ^= par0 >>> 20 ^ par0 >>> 12; + return par0 ^ par0 >>> 7 ^ par0 >>> 4; + } + + private static int getHashIndex(int par0, int par1) + { + return par0 & par1 - 1; + } + + public int getNumHashElements() + { + return this.numHashElements; + } + + public Object getValueByKey(long par1) + { + int j = getHashedKey(par1); + + for (LongHashMap.Entry entry = this.hashArray[getHashIndex(j, this.hashArray.length)]; entry != null; entry = entry.nextEntry) + { + if (entry.key == par1) + { + return entry.value; + } + } + + return null; + } + + public boolean containsItem(long par1) + { + return this.getEntry(par1) != null; + } + + final LongHashMap.Entry getEntry(long par1) + { + int j = getHashedKey(par1); + + for (LongHashMap.Entry entry = this.hashArray[getHashIndex(j, this.hashArray.length)]; entry != null; entry = entry.nextEntry) + { + if (entry.key == par1) + { + return entry; + } + } + + return null; + } + + public void add(long par1, Object par3Obj) + { + int j = getHashedKey(par1); + int k = getHashIndex(j, this.hashArray.length); + + for (LongHashMap.Entry entry = this.hashArray[k]; entry != null; entry = entry.nextEntry) + { + if (entry.key == par1) + { + entry.value = par3Obj; + return; + } + } + + ++this.modCount; + this.createKey(j, par1, par3Obj, k); + } + + private void resizeTable(int par1) + { + LongHashMap.Entry[] aentry = this.hashArray; + int j = aentry.length; + + if (j == 1073741824) + { + this.capacity = Integer.MAX_VALUE; + } + else + { + LongHashMap.Entry[] aentry1 = new LongHashMap.Entry[par1]; + this.copyHashTableTo(aentry1); + this.hashArray = aentry1; + this.capacity = (int)((float)par1 * this.percentUseable); + } + } + + private void copyHashTableTo(LongHashMap.Entry[] par1ArrayOfLongHashMapEntry) + { + LongHashMap.Entry[] aentry = this.hashArray; + int i = par1ArrayOfLongHashMapEntry.length; + + for (int j = 0; j < aentry.length; ++j) + { + LongHashMap.Entry entry = aentry[j]; + + if (entry != null) + { + aentry[j] = null; + LongHashMap.Entry entry1; + + do + { + entry1 = entry.nextEntry; + int k = getHashIndex(entry.hash, i); + entry.nextEntry = par1ArrayOfLongHashMapEntry[k]; + par1ArrayOfLongHashMapEntry[k] = entry; + entry = entry1; + } + while (entry1 != null); + } + } + } + + public Object remove(long par1) + { + LongHashMap.Entry entry = this.removeKey(par1); + return entry == null ? null : entry.value; + } + + final LongHashMap.Entry removeKey(long par1) + { + int j = getHashedKey(par1); + int k = getHashIndex(j, this.hashArray.length); + LongHashMap.Entry entry = this.hashArray[k]; + LongHashMap.Entry entry1; + LongHashMap.Entry entry2; + + for (entry1 = entry; entry1 != null; entry1 = entry2) + { + entry2 = entry1.nextEntry; + + if (entry1.key == par1) + { + ++this.modCount; + --this.numHashElements; + + if (entry == entry1) + { + this.hashArray[k] = entry2; + } + else + { + entry.nextEntry = entry2; + } + + return entry1; + } + + entry = entry1; + } + + return entry1; + } + + private void createKey(int par1, long par2, Object par4Obj, int par5) + { + LongHashMap.Entry entry = this.hashArray[par5]; + this.hashArray[par5] = new LongHashMap.Entry(par1, par2, par4Obj, entry); + + if (this.numHashElements++ >= this.capacity) + { + this.resizeTable(2 * this.hashArray.length); + } + } + + static class Entry + { + final long key; + Object value; + LongHashMap.Entry nextEntry; + final int hash; + private static final String __OBFID = "CL_00001493"; + + Entry(int par1, long par2, Object par4Obj, LongHashMap.Entry par5LongHashMapEntry) + { + this.value = par4Obj; + this.nextEntry = par5LongHashMapEntry; + this.key = par2; + this.hash = par1; + } + + public final long getKey() + { + return this.key; + } + + public final Object getValue() + { + return this.value; + } + + public final boolean equals(Object par1Obj) + { + if (!(par1Obj instanceof LongHashMap.Entry)) + { + return false; + } + else + { + LongHashMap.Entry entry = (LongHashMap.Entry)par1Obj; + Long olong = Long.valueOf(this.getKey()); + Long olong1 = Long.valueOf(entry.getKey()); + + if (olong == olong1 || olong != null && olong.equals(olong1)) + { + Object object1 = this.getValue(); + Object object2 = entry.getValue(); + + if (object1 == object2 || object1 != null && object1.equals(object2)) + { + return true; + } + } + + return false; + } + } + + public final int hashCode() + { + return LongHashMap.getHashedKey(this.key); + } + + public final String toString() + { + return this.getKey() + "=" + this.getValue(); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/MathHelper.java b/src/main/java/net/minecraft/util/MathHelper.java new file mode 100644 index 0000000..2a26b32 --- /dev/null +++ b/src/main/java/net/minecraft/util/MathHelper.java @@ -0,0 +1,304 @@ +package net.minecraft.util; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; + +public class MathHelper +{ + private static float[] SIN_TABLE = new float[65536]; + private static final int[] multiplyDeBruijnBitPosition; + private static final String __OBFID = "CL_00001496"; + + public static final float sin(float par0) + { + return SIN_TABLE[(int)(par0 * 10430.378F) & 65535]; + } + + public static final float cos(float par0) + { + return SIN_TABLE[(int)(par0 * 10430.378F + 16384.0F) & 65535]; + } + + public static final float sqrt_float(float par0) + { + return (float)Math.sqrt((double)par0); + } + + public static final float sqrt_double(double par0) + { + return (float)Math.sqrt(par0); + } + + public static int floor_float(float par0) + { + int i = (int)par0; + return par0 < (float)i ? i - 1 : i; + } + + @SideOnly(Side.CLIENT) + public static int truncateDoubleToInt(double par0) + { + return (int)(par0 + 1024.0D) - 1024; + } + + public static int floor_double(double par0) + { + int i = (int)par0; + return par0 < (double)i ? i - 1 : i; + } + + public static long floor_double_long(double par0) + { + long i = (long)par0; + return par0 < (double)i ? i - 1L : i; + } + + public static float abs(float par0) + { + return par0 >= 0.0F ? par0 : -par0; + } + + public static int abs_int(int par0) + { + return par0 >= 0 ? par0 : -par0; + } + + public static int ceiling_float_int(float par0) + { + int i = (int)par0; + return par0 > (float)i ? i + 1 : i; + } + + public static int ceiling_double_int(double par0) + { + int i = (int)par0; + return par0 > (double)i ? i + 1 : i; + } + + public static int clamp_int(int par0, int par1, int par2) + { + return par0 < par1 ? par1 : (par0 > par2 ? par2 : par0); + } + + public static float clamp_float(float par0, float par1, float par2) + { + return par0 < par1 ? par1 : (par0 > par2 ? par2 : par0); + } + + public static double clamp_double(double p_151237_0_, double p_151237_2_, double p_151237_4_) + { + return p_151237_0_ < p_151237_2_ ? p_151237_2_ : (p_151237_0_ > p_151237_4_ ? p_151237_4_ : p_151237_0_); + } + + public static double denormalizeClamp(double p_151238_0_, double p_151238_2_, double p_151238_4_) + { + return p_151238_4_ < 0.0D ? p_151238_0_ : (p_151238_4_ > 1.0D ? p_151238_2_ : p_151238_0_ + (p_151238_2_ - p_151238_0_) * p_151238_4_); + } + + public static double abs_max(double par0, double par2) + { + if (par0 < 0.0D) + { + par0 = -par0; + } + + if (par2 < 0.0D) + { + par2 = -par2; + } + + return par0 > par2 ? par0 : par2; + } + + @SideOnly(Side.CLIENT) + public static int bucketInt(int par0, int par1) + { + return par0 < 0 ? -((-par0 - 1) / par1) - 1 : par0 / par1; + } + + @SideOnly(Side.CLIENT) + public static boolean stringNullOrLengthZero(String par0Str) + { + return par0Str == null || par0Str.length() == 0; + } + + public static int getRandomIntegerInRange(Random par0Random, int par1, int par2) + { + return par1 >= par2 ? par1 : par0Random.nextInt(par2 - par1 + 1) + par1; + } + + public static float randomFloatClamp(Random p_151240_0_, float p_151240_1_, float p_151240_2_) + { + return p_151240_1_ >= p_151240_2_ ? p_151240_1_ : p_151240_0_.nextFloat() * (p_151240_2_ - p_151240_1_) + p_151240_1_; + } + + public static double getRandomDoubleInRange(Random par0Random, double par1, double par3) + { + return par1 >= par3 ? par1 : par0Random.nextDouble() * (par3 - par1) + par1; + } + + public static double average(long[] par0ArrayOfLong) + { + long i = 0L; + long[] along1 = par0ArrayOfLong; + int j = par0ArrayOfLong.length; + + for (int k = 0; k < j; ++k) + { + long l = along1[k]; + i += l; + } + + return (double)i / (double)par0ArrayOfLong.length; + } + + public static float wrapAngleTo180_float(float par0) + { + par0 %= 360.0F; + + if (par0 >= 180.0F) + { + par0 -= 360.0F; + } + + if (par0 < -180.0F) + { + par0 += 360.0F; + } + + return par0; + } + + public static double wrapAngleTo180_double(double par0) + { + par0 %= 360.0D; + + if (par0 >= 180.0D) + { + par0 -= 360.0D; + } + + if (par0 < -180.0D) + { + par0 += 360.0D; + } + + return par0; + } + + public static int parseIntWithDefault(String par0Str, int par1) + { + int j = par1; + + try + { + j = Integer.parseInt(par0Str); + } + catch (Throwable throwable) + { + ; + } + + return j; + } + + public static int parseIntWithDefaultAndMax(String par0Str, int par1, int par2) + { + int k = par1; + + try + { + k = Integer.parseInt(par0Str); + } + catch (Throwable throwable) + { + ; + } + + if (k < par2) + { + k = par2; + } + + return k; + } + + public static double parseDoubleWithDefault(String par0Str, double par1) + { + double d1 = par1; + + try + { + d1 = Double.parseDouble(par0Str); + } + catch (Throwable throwable) + { + ; + } + + return d1; + } + + public static double parseDoubleWithDefaultAndMax(String par0Str, double par1, double par3) + { + double d2 = par1; + + try + { + d2 = Double.parseDouble(par0Str); + } + catch (Throwable throwable) + { + ; + } + + if (d2 < par3) + { + d2 = par3; + } + + return d2; + } + + @SideOnly(Side.CLIENT) + public static int roundUpToPowerOfTwo(int p_151236_0_) + { + int j = p_151236_0_ - 1; + j |= j >> 1; + j |= j >> 2; + j |= j >> 4; + j |= j >> 8; + j |= j >> 16; + return j + 1; + } + + @SideOnly(Side.CLIENT) + private static boolean isPowerOfTwo(int p_151235_0_) + { + return p_151235_0_ != 0 && (p_151235_0_ & p_151235_0_ - 1) == 0; + } + + @SideOnly(Side.CLIENT) + private static int calculateLogBaseTwoDeBruijn(int p_151241_0_) + { + p_151241_0_ = isPowerOfTwo(p_151241_0_) ? p_151241_0_ : roundUpToPowerOfTwo(p_151241_0_); + return multiplyDeBruijnBitPosition[(int)((long)p_151241_0_ * 125613361L >> 27) & 31]; + } + + @SideOnly(Side.CLIENT) + public static int calculateLogBaseTwo(int p_151239_0_) + { + return calculateLogBaseTwoDeBruijn(p_151239_0_) - (isPowerOfTwo(p_151239_0_) ? 0 : 1); + } + + static + { + for (int var0 = 0; var0 < 65536; ++var0) + { + SIN_TABLE[var0] = (float)Math.sin((double)var0 * Math.PI * 2.0D / 65536.0D); + } + + multiplyDeBruijnBitPosition = new int[] {0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9}; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/MessageDeserializer.java b/src/main/java/net/minecraft/util/MessageDeserializer.java new file mode 100644 index 0000000..f442c12 --- /dev/null +++ b/src/main/java/net/minecraft/util/MessageDeserializer.java @@ -0,0 +1,55 @@ +package net.minecraft.util; + +import com.google.common.collect.BiMap; +import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelHandlerContext; +import io.netty.handler.codec.ByteToMessageDecoder; +import java.io.IOException; +import java.util.List; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.Marker; +import org.apache.logging.log4j.MarkerManager; + +public class MessageDeserializer extends ByteToMessageDecoder +{ + private static final Logger logger = LogManager.getLogger(); + private static final Marker field_150799_b = MarkerManager.getMarker("PACKET_RECEIVED", NetworkManager.logMarkerPackets); + private static final String __OBFID = "CL_00001252"; + + protected void decode(ChannelHandlerContext p_decode_1_, ByteBuf p_decode_2_, List p_decode_3_) throws IOException + { + if (p_decode_2_.readableBytes() != 0) + { + PacketBuffer packetbuffer = new PacketBuffer(p_decode_2_); + int i = packetbuffer.readVarIntFromBuffer(); + Packet packet = Packet.generatePacket((BiMap)p_decode_1_.channel().attr(NetworkManager.attrKeyReceivable).get(), i); + + if (packet == null) + { + throw new IOException("Bad packet id " + i); + } + else + { + packet.readPacketData(packetbuffer); + + if (packetbuffer.readableBytes() > 0) + { + throw new IOException("Packet was larger than I expected, found " + packetbuffer.readableBytes() + " bytes extra whilst reading packet " + i); + } + else + { + p_decode_3_.add(packet); + + if (logger.isDebugEnabled()) + { + logger.debug(field_150799_b, " IN: [{}:{}] {}[{}]", new Object[] {p_decode_1_.channel().attr(NetworkManager.attrKeyConnectionState).get(), Integer.valueOf(i), packet.getClass().getName(), packet.serialize()}); + } + } + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/MessageDeserializer2.java b/src/main/java/net/minecraft/util/MessageDeserializer2.java new file mode 100644 index 0000000..1a01672 --- /dev/null +++ b/src/main/java/net/minecraft/util/MessageDeserializer2.java @@ -0,0 +1,47 @@ +package net.minecraft.util; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; +import io.netty.channel.ChannelHandlerContext; +import io.netty.handler.codec.ByteToMessageDecoder; +import io.netty.handler.codec.CorruptedFrameException; +import java.util.List; +import net.minecraft.network.PacketBuffer; + +public class MessageDeserializer2 extends ByteToMessageDecoder +{ + private static final String __OBFID = "CL_00001255"; + + protected void decode(ChannelHandlerContext p_decode_1_, ByteBuf p_decode_2_, List p_decode_3_) + { + p_decode_2_.markReaderIndex(); + byte[] abyte = new byte[3]; + + for (int i = 0; i < abyte.length; ++i) + { + if (!p_decode_2_.isReadable()) + { + p_decode_2_.resetReaderIndex(); + return; + } + + abyte[i] = p_decode_2_.readByte(); + + if (abyte[i] >= 0) + { + int j = (new PacketBuffer(Unpooled.wrappedBuffer(abyte))).readVarIntFromBuffer(); + + if (p_decode_2_.readableBytes() < j) + { + p_decode_2_.resetReaderIndex(); + return; + } + + p_decode_3_.add(p_decode_2_.readBytes(j)); + return; + } + } + + throw new CorruptedFrameException("length wider than 21-bit"); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/MessageSerializer.java b/src/main/java/net/minecraft/util/MessageSerializer.java new file mode 100644 index 0000000..099d862 --- /dev/null +++ b/src/main/java/net/minecraft/util/MessageSerializer.java @@ -0,0 +1,47 @@ +package net.minecraft.util; + +import com.google.common.collect.BiMap; +import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelHandlerContext; +import io.netty.handler.codec.MessageToByteEncoder; +import java.io.IOException; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.Marker; +import org.apache.logging.log4j.MarkerManager; + +public class MessageSerializer extends MessageToByteEncoder +{ + private static final Logger logger = LogManager.getLogger(); + private static final Marker field_150797_b = MarkerManager.getMarker("PACKET_SENT", NetworkManager.logMarkerPackets); + private static final String __OBFID = "CL_00001253"; + + protected void encode(ChannelHandlerContext p_150796_1_, Packet p_150796_2_, ByteBuf p_150796_3_) throws IOException + { + Integer integer = (Integer)((BiMap)p_150796_1_.channel().attr(NetworkManager.attrKeySendable).get()).inverse().get(p_150796_2_.getClass()); + + if (logger.isDebugEnabled()) + { + logger.debug(field_150797_b, "OUT: [{}:{}] {}[{}]", new Object[] {p_150796_1_.channel().attr(NetworkManager.attrKeyConnectionState).get(), integer, p_150796_2_.getClass().getName(), p_150796_2_.serialize()}); + } + + if (integer == null) + { + throw new IOException("Can\'t serialize unregistered packet"); + } + else + { + PacketBuffer packetbuffer = new PacketBuffer(p_150796_3_); + packetbuffer.writeVarIntToBuffer(integer.intValue()); + p_150796_2_.writePacketData(packetbuffer); + } + } + + protected void encode(ChannelHandlerContext p_encode_1_, Object p_encode_2_, ByteBuf p_encode_3_) throws IOException + { + this.encode(p_encode_1_, (Packet)p_encode_2_, p_encode_3_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/MessageSerializer2.java b/src/main/java/net/minecraft/util/MessageSerializer2.java new file mode 100644 index 0000000..50a89f4 --- /dev/null +++ b/src/main/java/net/minecraft/util/MessageSerializer2.java @@ -0,0 +1,34 @@ +package net.minecraft.util; + +import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelHandlerContext; +import io.netty.handler.codec.MessageToByteEncoder; +import net.minecraft.network.PacketBuffer; + +public class MessageSerializer2 extends MessageToByteEncoder +{ + private static final String __OBFID = "CL_00001256"; + + protected void encode(ChannelHandlerContext p_150667_1_, ByteBuf p_150667_2_, ByteBuf p_150667_3_) + { + int i = p_150667_2_.readableBytes(); + int j = PacketBuffer.getVarIntSize(i); + + if (j > 3) + { + throw new IllegalArgumentException("unable to fit " + i + " into " + 3); + } + else + { + PacketBuffer packetbuffer = new PacketBuffer(p_150667_3_); + packetbuffer.ensureWritable(j + i); + packetbuffer.writeVarIntToBuffer(i); + packetbuffer.writeBytes(p_150667_2_, p_150667_2_.readerIndex(), i); + } + } + + protected void encode(ChannelHandlerContext p_encode_1_, Object p_encode_2_, ByteBuf p_encode_3_) + { + this.encode(p_encode_1_, (ByteBuf)p_encode_2_, p_encode_3_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/MinecraftError.java b/src/main/java/net/minecraft/util/MinecraftError.java new file mode 100644 index 0000000..7f59625 --- /dev/null +++ b/src/main/java/net/minecraft/util/MinecraftError.java @@ -0,0 +1,10 @@ +package net.minecraft.util; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class MinecraftError extends Error +{ + private static final String __OBFID = "CL_00000657"; +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/MouseFilter.java b/src/main/java/net/minecraft/util/MouseFilter.java new file mode 100644 index 0000000..ce68aa6 --- /dev/null +++ b/src/main/java/net/minecraft/util/MouseFilter.java @@ -0,0 +1,28 @@ +package net.minecraft.util; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class MouseFilter +{ + private float field_76336_a; + private float field_76334_b; + private float field_76335_c; + private static final String __OBFID = "CL_00001500"; + + public float smooth(float par1, float par2) + { + this.field_76336_a += par1; + par1 = (this.field_76336_a - this.field_76334_b) * par2; + this.field_76335_c += (par1 - this.field_76335_c) * 0.5F; + + if (par1 > 0.0F && par1 > this.field_76335_c || par1 < 0.0F && par1 < this.field_76335_c) + { + par1 = this.field_76335_c; + } + + this.field_76334_b += par1; + return par1; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/MouseHelper.java b/src/main/java/net/minecraft/util/MouseHelper.java new file mode 100644 index 0000000..4101c4e --- /dev/null +++ b/src/main/java/net/minecraft/util/MouseHelper.java @@ -0,0 +1,34 @@ +package net.minecraft.util; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.Display; + +@SideOnly(Side.CLIENT) +public class MouseHelper +{ + public int deltaX; + public int deltaY; + private static final String __OBFID = "CL_00000648"; + + public void grabMouseCursor() + { + if (Boolean.parseBoolean(System.getProperty("fml.noGrab","false"))) return; + Mouse.setGrabbed(true); + this.deltaX = 0; + this.deltaY = 0; + } + + public void ungrabMouseCursor() + { + Mouse.setCursorPosition(Display.getWidth() / 2, Display.getHeight() / 2); + Mouse.setGrabbed(false); + } + + public void mouseXYChange() + { + this.deltaX = Mouse.getDX(); + this.deltaY = Mouse.getDY(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/MovementInput.java b/src/main/java/net/minecraft/util/MovementInput.java new file mode 100644 index 0000000..6bd3cdc --- /dev/null +++ b/src/main/java/net/minecraft/util/MovementInput.java @@ -0,0 +1,16 @@ +package net.minecraft.util; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class MovementInput +{ + public float moveStrafe; + public float moveForward; + public boolean jump; + public boolean sneak; + private static final String __OBFID = "CL_00000936"; + + public void updatePlayerMoveState() {} +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/MovementInputFromOptions.java b/src/main/java/net/minecraft/util/MovementInputFromOptions.java new file mode 100644 index 0000000..4d18e7d --- /dev/null +++ b/src/main/java/net/minecraft/util/MovementInputFromOptions.java @@ -0,0 +1,52 @@ +package net.minecraft.util; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.settings.GameSettings; + +@SideOnly(Side.CLIENT) +public class MovementInputFromOptions extends MovementInput +{ + private GameSettings gameSettings; + private static final String __OBFID = "CL_00000937"; + + public MovementInputFromOptions(GameSettings par1GameSettings) + { + this.gameSettings = par1GameSettings; + } + + public void updatePlayerMoveState() + { + this.moveStrafe = 0.0F; + this.moveForward = 0.0F; + + if (this.gameSettings.keyBindForward.getIsKeyPressed()) + { + ++this.moveForward; + } + + if (this.gameSettings.keyBindBack.getIsKeyPressed()) + { + --this.moveForward; + } + + if (this.gameSettings.keyBindLeft.getIsKeyPressed()) + { + ++this.moveStrafe; + } + + if (this.gameSettings.keyBindRight.getIsKeyPressed()) + { + --this.moveStrafe; + } + + this.jump = this.gameSettings.keyBindJump.getIsKeyPressed(); + this.sneak = this.gameSettings.keyBindSneak.getIsKeyPressed(); + + if (this.sneak) + { + this.moveStrafe = (float)((double)this.moveStrafe * 0.3D); + this.moveForward = (float)((double)this.moveForward * 0.3D); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/MovingObjectPosition.java b/src/main/java/net/minecraft/util/MovingObjectPosition.java new file mode 100644 index 0000000..310657a --- /dev/null +++ b/src/main/java/net/minecraft/util/MovingObjectPosition.java @@ -0,0 +1,62 @@ +package net.minecraft.util; + +import net.minecraft.entity.Entity; + +public class MovingObjectPosition +{ + public MovingObjectPosition.MovingObjectType typeOfHit; + public int blockX; + public int blockY; + public int blockZ; + public int sideHit; + public Vec3 hitVec; + public Entity entityHit; + private static final String __OBFID = "CL_00000610"; + + /** Used to determine what sub-segment is hit */ + public int subHit = -1; + + /** Used to add extra hit info */ + public Object hitInfo = null; + + public MovingObjectPosition(int par1, int par2, int par3, int par4, Vec3 par5Vec3) + { + this(par1, par2, par3, par4, par5Vec3, true); + } + + public MovingObjectPosition(int p_i45481_1_, int p_i45481_2_, int p_i45481_3_, int p_i45481_4_, Vec3 p_i45481_5_, boolean p_i45481_6_) + { + this.typeOfHit = p_i45481_6_ ? MovingObjectPosition.MovingObjectType.BLOCK : MovingObjectPosition.MovingObjectType.MISS; + this.blockX = p_i45481_1_; + this.blockY = p_i45481_2_; + this.blockZ = p_i45481_3_; + this.sideHit = p_i45481_4_; + this.hitVec = p_i45481_5_.myVec3LocalPool.getVecFromPool(p_i45481_5_.xCoord, p_i45481_5_.yCoord, p_i45481_5_.zCoord); + } + + public MovingObjectPosition(Entity par1Entity) + { + this(par1Entity, par1Entity.worldObj.getWorldVec3Pool().getVecFromPool(par1Entity.posX, par1Entity.posY, par1Entity.posZ)); + } + + public MovingObjectPosition(Entity p_i45482_1_, Vec3 p_i45482_2_) + { + this.typeOfHit = MovingObjectPosition.MovingObjectType.ENTITY; + this.entityHit = p_i45482_1_; + this.hitVec = p_i45482_2_; + } + + public String toString() + { + return "HitResult{type=" + this.typeOfHit + ", x=" + this.blockX + ", y=" + this.blockY + ", z=" + this.blockZ + ", f=" + this.sideHit + ", pos=" + this.hitVec + ", entity=" + this.entityHit + '}'; + } + + public static enum MovingObjectType + { + MISS, + BLOCK, + ENTITY; + + private static final String __OBFID = "CL_00000611"; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/ObjectIntIdentityMap.java b/src/main/java/net/minecraft/util/ObjectIntIdentityMap.java new file mode 100644 index 0000000..83c6aab --- /dev/null +++ b/src/main/java/net/minecraft/util/ObjectIntIdentityMap.java @@ -0,0 +1,47 @@ +package net.minecraft.util; + +import com.google.common.base.Predicates; +import com.google.common.collect.Iterators; +import gnu.trove.map.hash.TIntIntHashMap; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +public class ObjectIntIdentityMap implements IObjectIntIterable +{ + protected TIntIntHashMap field_148749_a = new TIntIntHashMap(256, 0.5F, -1, -1); + protected List field_148748_b = new ArrayList(); + private static final String __OBFID = "CL_00001203"; + + public void func_148746_a(Object p_148746_1_, int p_148746_2_) + { + this.field_148749_a.put(System.identityHashCode(p_148746_1_), p_148746_2_); + + while (this.field_148748_b.size() <= p_148746_2_) + { + this.field_148748_b.add((Object)null); + } + + this.field_148748_b.set(p_148746_2_, p_148746_1_); + } + + public int func_148747_b(Object p_148747_1_) + { + return this.field_148749_a.get(System.identityHashCode(p_148747_1_)); + } + + public Object func_148745_a(int p_148745_1_) + { + return p_148745_1_ >= 0 && p_148745_1_ < this.field_148748_b.size() ? this.field_148748_b.get(p_148745_1_) : null; + } + + public Iterator iterator() + { + return Iterators.filter(this.field_148748_b.iterator(), Predicates.notNull()); + } + + public boolean func_148744_b(int p_148744_1_) + { + return this.func_148745_a(p_148744_1_) != null; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/RegistryDefaulted.java b/src/main/java/net/minecraft/util/RegistryDefaulted.java new file mode 100644 index 0000000..47630c0 --- /dev/null +++ b/src/main/java/net/minecraft/util/RegistryDefaulted.java @@ -0,0 +1,18 @@ +package net.minecraft.util; + +public class RegistryDefaulted extends RegistrySimple +{ + private final Object defaultObject; + private static final String __OBFID = "CL_00001198"; + + public RegistryDefaulted(Object par1Obj) + { + this.defaultObject = par1Obj; + } + + public Object getObject(Object par1Obj) + { + Object object1 = super.getObject(par1Obj); + return object1 == null ? this.defaultObject : object1; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/RegistryNamespaced.java b/src/main/java/net/minecraft/util/RegistryNamespaced.java new file mode 100644 index 0000000..c0b45aa --- /dev/null +++ b/src/main/java/net/minecraft/util/RegistryNamespaced.java @@ -0,0 +1,79 @@ +package net.minecraft.util; + +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; +import java.util.Iterator; +import java.util.Map; + +public class RegistryNamespaced extends RegistrySimple implements IObjectIntIterable +{ + protected ObjectIntIdentityMap underlyingIntegerMap = new ObjectIntIdentityMap(); + protected final Map field_148758_b; + private static final String __OBFID = "CL_00001206"; + + public RegistryNamespaced() + { + this.field_148758_b = ((BiMap)this.registryObjects).inverse(); + } + + public void addObject(int p_148756_1_, String p_148756_2_, Object p_148756_3_) + { + this.underlyingIntegerMap.func_148746_a(p_148756_3_, p_148756_1_); + this.putObject(ensureNamespaced(p_148756_2_), p_148756_3_); + } + + protected Map createUnderlyingMap() + { + return HashBiMap.create(); + } + + public Object getObject(String p_148751_1_) + { + return super.getObject(ensureNamespaced(p_148751_1_)); + } + + public String getNameForObject(Object p_148750_1_) + { + return (String)this.field_148758_b.get(p_148750_1_); + } + + public boolean containsKey(String p_148752_1_) + { + return super.containsKey(ensureNamespaced(p_148752_1_)); + } + + public int getIDForObject(Object p_148757_1_) + { + return this.underlyingIntegerMap.func_148747_b(p_148757_1_); + } + + public Object getObjectById(int p_148754_1_) + { + return this.underlyingIntegerMap.func_148745_a(p_148754_1_); + } + + public Iterator iterator() + { + return this.underlyingIntegerMap.iterator(); + } + + public boolean containsId(int p_148753_1_) + { + return this.underlyingIntegerMap.func_148744_b(p_148753_1_); + } + + protected static String ensureNamespaced(String p_148755_0_) + { + return p_148755_0_.indexOf(58) == -1 ? "minecraft:" + p_148755_0_ : p_148755_0_; + } + + public boolean containsKey(Object p_148741_1_) + { + return this.containsKey((String)p_148741_1_); + } + + public Object getObject(Object par1Obj) + { + return this.getObject((String)par1Obj); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/RegistryNamespacedDefaultedByKey.java b/src/main/java/net/minecraft/util/RegistryNamespacedDefaultedByKey.java new file mode 100644 index 0000000..1129719 --- /dev/null +++ b/src/main/java/net/minecraft/util/RegistryNamespacedDefaultedByKey.java @@ -0,0 +1,40 @@ +package net.minecraft.util; + +public class RegistryNamespacedDefaultedByKey extends RegistryNamespaced +{ + private final String field_148760_d; + private Object field_148761_e; + private static final String __OBFID = "CL_00001196"; + + public RegistryNamespacedDefaultedByKey(String p_i45127_1_) + { + this.field_148760_d = p_i45127_1_; + } + + public void addObject(int p_148756_1_, String p_148756_2_, Object p_148756_3_) + { + if (this.field_148760_d.equals(p_148756_2_)) + { + this.field_148761_e = p_148756_3_; + } + + super.addObject(p_148756_1_, p_148756_2_, p_148756_3_); + } + + public Object getObject(String p_148751_1_) + { + Object object = super.getObject(p_148751_1_); + return object == null ? this.field_148761_e : object; + } + + public Object getObjectById(int p_148754_1_) + { + Object object = super.getObjectById(p_148754_1_); + return object == null ? this.field_148761_e : object; + } + + public Object getObject(Object par1Obj) + { + return this.getObject((String)par1Obj); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/RegistrySimple.java b/src/main/java/net/minecraft/util/RegistrySimple.java new file mode 100644 index 0000000..7b84926 --- /dev/null +++ b/src/main/java/net/minecraft/util/RegistrySimple.java @@ -0,0 +1,45 @@ +package net.minecraft.util; + +import com.google.common.collect.Maps; +import java.util.Collections; +import java.util.Map; +import java.util.Set; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class RegistrySimple implements IRegistry +{ + private static final Logger logger = LogManager.getLogger(); + protected final Map registryObjects = this.createUnderlyingMap(); + private static final String __OBFID = "CL_00001210"; + + protected Map createUnderlyingMap() + { + return Maps.newHashMap(); + } + + public Object getObject(Object par1Obj) + { + return this.registryObjects.get(par1Obj); + } + + public void putObject(Object par1Obj, Object par2Obj) + { + if (this.registryObjects.containsKey(par1Obj)) + { + logger.warn("Adding duplicate key \'" + par1Obj + "\' to registry"); + } + + this.registryObjects.put(par1Obj, par2Obj); + } + + public Set getKeys() + { + return Collections.unmodifiableSet(this.registryObjects.keySet()); + } + + public boolean containsKey(Object p_148741_1_) + { + return this.registryObjects.containsKey(p_148741_1_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/ReportedException.java b/src/main/java/net/minecraft/util/ReportedException.java new file mode 100644 index 0000000..f6e566e --- /dev/null +++ b/src/main/java/net/minecraft/util/ReportedException.java @@ -0,0 +1,29 @@ +package net.minecraft.util; + +import net.minecraft.crash.CrashReport; + +public class ReportedException extends RuntimeException +{ + private final CrashReport theReportedExceptionCrashReport; + private static final String __OBFID = "CL_00001579"; + + public ReportedException(CrashReport par1CrashReport) + { + this.theReportedExceptionCrashReport = par1CrashReport; + } + + public CrashReport getCrashReport() + { + return this.theReportedExceptionCrashReport; + } + + public Throwable getCause() + { + return this.theReportedExceptionCrashReport.getCrashCause(); + } + + public String getMessage() + { + return this.theReportedExceptionCrashReport.getDescription(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/ResourceLocation.java b/src/main/java/net/minecraft/util/ResourceLocation.java new file mode 100644 index 0000000..9c3e2cd --- /dev/null +++ b/src/main/java/net/minecraft/util/ResourceLocation.java @@ -0,0 +1,83 @@ +package net.minecraft.util; + +import org.apache.commons.lang3.Validate; + +public class ResourceLocation +{ + private final String resourceDomain; + private final String resourcePath; + private static final String __OBFID = "CL_00001082"; + + public ResourceLocation(String par1Str, String par2Str) + { + Validate.notNull(par2Str); + + if (par1Str != null && par1Str.length() != 0) + { + this.resourceDomain = par1Str; + } + else + { + this.resourceDomain = "minecraft"; + } + + this.resourcePath = par2Str; + } + + public ResourceLocation(String par1Str) + { + String s1 = "minecraft"; + String s2 = par1Str; + int i = par1Str.indexOf(58); + + if (i >= 0) + { + s2 = par1Str.substring(i + 1, par1Str.length()); + + if (i > 1) + { + s1 = par1Str.substring(0, i); + } + } + + this.resourceDomain = s1.toLowerCase(); + this.resourcePath = s2; + } + + public String getResourcePath() + { + return this.resourcePath; + } + + public String getResourceDomain() + { + return this.resourceDomain; + } + + public String toString() + { + return this.resourceDomain + ":" + this.resourcePath; + } + + public boolean equals(Object par1Obj) + { + if (this == par1Obj) + { + return true; + } + else if (!(par1Obj instanceof ResourceLocation)) + { + return false; + } + else + { + ResourceLocation resourcelocation = (ResourceLocation)par1Obj; + return this.resourceDomain.equals(resourcelocation.resourceDomain) && this.resourcePath.equals(resourcelocation.resourcePath); + } + } + + public int hashCode() + { + return 31 * this.resourceDomain.hashCode() + this.resourcePath.hashCode(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/ScreenShotHelper.java b/src/main/java/net/minecraft/util/ScreenShotHelper.java new file mode 100644 index 0000000..51b0394 --- /dev/null +++ b/src/main/java/net/minecraft/util/ScreenShotHelper.java @@ -0,0 +1,135 @@ +package net.minecraft.util; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.awt.image.BufferedImage; +import java.io.File; +import java.nio.IntBuffer; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import javax.imageio.ImageIO; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.texture.TextureUtil; +import net.minecraft.client.shader.Framebuffer; +import net.minecraft.event.ClickEvent; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.lwjgl.BufferUtils; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +@SideOnly(Side.CLIENT) +public class ScreenShotHelper +{ + private static final Logger logger = LogManager.getLogger(); + private static final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss"); + private static IntBuffer pixelBuffer; + private static int[] pixelValues; + private static final String __OBFID = "CL_00000656"; + + public static IChatComponent saveScreenshot(File p_148260_0_, int p_148260_1_, int p_148260_2_, Framebuffer p_148260_3_) + { + return saveScreenshot(p_148260_0_, (String)null, p_148260_1_, p_148260_2_, p_148260_3_); + } + + public static IChatComponent saveScreenshot(File p_148259_0_, String p_148259_1_, int p_148259_2_, int p_148259_3_, Framebuffer p_148259_4_) + { + try + { + File file2 = new File(p_148259_0_, "screenshots"); + file2.mkdir(); + + if (OpenGlHelper.isFramebufferEnabled()) + { + p_148259_2_ = p_148259_4_.framebufferTextureWidth; + p_148259_3_ = p_148259_4_.framebufferTextureHeight; + } + + int k = p_148259_2_ * p_148259_3_; + + if (pixelBuffer == null || pixelBuffer.capacity() < k) + { + pixelBuffer = BufferUtils.createIntBuffer(k); + pixelValues = new int[k]; + } + + GL11.glPixelStorei(GL11.GL_PACK_ALIGNMENT, 1); + GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1); + pixelBuffer.clear(); + + if (OpenGlHelper.isFramebufferEnabled()) + { + GL11.glBindTexture(GL11.GL_TEXTURE_2D, p_148259_4_.framebufferTexture); + GL11.glGetTexImage(GL11.GL_TEXTURE_2D, 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, pixelBuffer); + } + else + { + GL11.glReadPixels(0, 0, p_148259_2_, p_148259_3_, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, pixelBuffer); + } + + pixelBuffer.get(pixelValues); + TextureUtil.func_147953_a(pixelValues, p_148259_2_, p_148259_3_); + BufferedImage bufferedimage = null; + + if (OpenGlHelper.isFramebufferEnabled()) + { + bufferedimage = new BufferedImage(p_148259_4_.framebufferWidth, p_148259_4_.framebufferHeight, 1); + int l = p_148259_4_.framebufferTextureHeight - p_148259_4_.framebufferHeight; + + for (int i1 = l; i1 < p_148259_4_.framebufferTextureHeight; ++i1) + { + for (int j1 = 0; j1 < p_148259_4_.framebufferWidth; ++j1) + { + bufferedimage.setRGB(j1, i1 - l, pixelValues[i1 * p_148259_4_.framebufferTextureWidth + j1]); + } + } + } + else + { + bufferedimage = new BufferedImage(p_148259_2_, p_148259_3_, 1); + bufferedimage.setRGB(0, 0, p_148259_2_, p_148259_3_, pixelValues, 0, p_148259_2_); + } + + File file3; + + if (p_148259_1_ == null) + { + file3 = getTimestampedPNGFileForDirectory(file2); + } + else + { + file3 = new File(file2, p_148259_1_); + } + + ImageIO.write(bufferedimage, "png", file3); + ChatComponentText chatcomponenttext = new ChatComponentText(file3.getName()); + chatcomponenttext.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, file3.getAbsolutePath())); + chatcomponenttext.getChatStyle().setUnderlined(Boolean.valueOf(true)); + return new ChatComponentTranslation("screenshot.success", new Object[] {chatcomponenttext}); + } + catch (Exception exception) + { + logger.warn("Couldn\'t save screenshot", exception); + return new ChatComponentTranslation("screenshot.failure", new Object[] {exception.getMessage()}); + } + } + + private static File getTimestampedPNGFileForDirectory(File par0File) + { + String s = dateFormat.format(new Date()).toString(); + int i = 1; + + while (true) + { + File file2 = new File(par0File, s + (i == 1 ? "" : "_" + i) + ".png"); + + if (!file2.exists()) + { + return file2; + } + + ++i; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/Session.java b/src/main/java/net/minecraft/util/Session.java new file mode 100644 index 0000000..c67e005 --- /dev/null +++ b/src/main/java/net/minecraft/util/Session.java @@ -0,0 +1,59 @@ +package net.minecraft.util; + +import com.mojang.authlib.GameProfile; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class Session +{ + private final String username; + private final String playerID; + private final String token; + private static final String __OBFID = "CL_00000659"; + + public Session(String p_i45006_1_, String p_i45006_2_, String p_i45006_3_) + { + if (p_i45006_1_ == null || p_i45006_1_.isEmpty()) + { + p_i45006_1_ = "MissingName"; + p_i45006_2_ = p_i45006_3_ = "NotValid"; + System.out.println("========================================================="); + System.out.println("Warning the username was not set for this session, typically"); + System.out.println("this means you installed Forge incorrectly. We have set your"); + System.out.println("name to \"MissingName\" and your session to nothing. Please"); + System.out.println("check your instation and post a console log from the launcher"); + System.out.println("when asking for help!"); + System.out.println("========================================================="); + + } + this.username = p_i45006_1_; + this.playerID = p_i45006_2_; + this.token = p_i45006_3_; + } + + public String getSessionID() + { + return "token:" + this.token + ":" + this.playerID; + } + + public String getPlayerID() + { + return this.playerID; + } + + public String getUsername() + { + return this.username; + } + + public String getToken() + { + return this.token; + } + + public GameProfile func_148256_e() + { + return new GameProfile(this.getPlayerID(), this.getUsername()); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/StatCollector.java b/src/main/java/net/minecraft/util/StatCollector.java new file mode 100644 index 0000000..4d62486 --- /dev/null +++ b/src/main/java/net/minecraft/util/StatCollector.java @@ -0,0 +1,33 @@ +package net.minecraft.util; + +public class StatCollector +{ + private static StringTranslate localizedName = StringTranslate.getInstance(); + private static StringTranslate fallbackTranslator = new StringTranslate(); + private static final String __OBFID = "CL_00001211"; + + public static String translateToLocal(String par0Str) + { + return localizedName.translateKey(par0Str); + } + + public static String translateToLocalFormatted(String par0Str, Object ... par1ArrayOfObj) + { + return localizedName.translateKeyFormat(par0Str, par1ArrayOfObj); + } + + public static String translateToFallback(String p_150826_0_) + { + return fallbackTranslator.translateKey(p_150826_0_); + } + + public static boolean canTranslate(String par0Str) + { + return localizedName.containsTranslateKey(par0Str); + } + + public static long getLastTranslationUpdateTimeInMilliseconds() + { + return localizedName.getLastUpdateTimeInMilliseconds(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/StringTranslate.java b/src/main/java/net/minecraft/util/StringTranslate.java new file mode 100644 index 0000000..271a45c --- /dev/null +++ b/src/main/java/net/minecraft/util/StringTranslate.java @@ -0,0 +1,128 @@ +package net.minecraft.util; + +import com.google.common.base.Splitter; +import com.google.common.collect.Iterables; +import com.google.common.collect.Maps; + +import cpw.mods.fml.common.registry.LanguageRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.IllegalFormatException; +import java.util.Iterator; +import java.util.Map; +import java.util.regex.Pattern; +import org.apache.commons.io.Charsets; +import org.apache.commons.io.IOUtils; + +public class StringTranslate +{ + private static final Pattern numericVariablePattern = Pattern.compile("%(\\d+\\$)?[\\d\\.]*[df]"); + private static final Splitter equalSignSplitter = Splitter.on('=').limit(2); + private final Map languageList; + private static StringTranslate instance = new StringTranslate(); + private long lastUpdateTimeInMilliseconds; + private static final String __OBFID = "CL_00001212"; + + public StringTranslate() + { + InputStream inputstream = StringTranslate.class.getResourceAsStream("/assets/minecraft/lang/en_US.lang"); + languageList = Maps.newHashMap(); + inject(this, inputstream); + } + + public static void inject(InputStream inputstream) + { + inject(instance, inputstream); + } + + private static void inject(StringTranslate inst, InputStream inputstream) + { + HashMap map = parseLangFile(inputstream); + inst.languageList.putAll(map); + inst.lastUpdateTimeInMilliseconds = System.currentTimeMillis(); + } + + public static HashMap parseLangFile(InputStream inputstream) + { + HashMap table = Maps.newHashMap(); + try + { + Iterator iterator = IOUtils.readLines(inputstream, Charsets.UTF_8).iterator(); + + while (iterator.hasNext()) + { + String s = (String)iterator.next(); + + if (!s.isEmpty() && s.charAt(0) != 35) + { + String[] astring = (String[])Iterables.toArray(equalSignSplitter.split(s), String.class); + + if (astring != null && astring.length == 2) + { + String s1 = astring[0]; + String s2 = numericVariablePattern.matcher(astring[1]).replaceAll("%$1s"); + table.put(s1, s2); + } + } + } + + } + catch (Exception ioexception) + { + ; + } + return table; + } + + static StringTranslate getInstance() + { + return instance; + } + + @SideOnly(Side.CLIENT) + + public static synchronized void replaceWith(Map par0Map) + { + instance.languageList.clear(); + instance.languageList.putAll(par0Map); + instance.lastUpdateTimeInMilliseconds = System.currentTimeMillis(); + } + + public synchronized String translateKey(String par1Str) + { + return this.tryTranslateKey(par1Str); + } + + public synchronized String translateKeyFormat(String par1Str, Object ... par2ArrayOfObj) + { + String s1 = this.tryTranslateKey(par1Str); + + try + { + return String.format(s1, par2ArrayOfObj); + } + catch (IllegalFormatException illegalformatexception) + { + return "Format error: " + s1; + } + } + + private String tryTranslateKey(String par1Str) + { + String s1 = (String)this.languageList.get(par1Str); + return s1 == null ? par1Str : s1; + } + + public synchronized boolean containsTranslateKey(String par1Str) + { + return this.languageList.containsKey(par1Str); + } + + public long getLastUpdateTimeInMilliseconds() + { + return this.lastUpdateTimeInMilliseconds; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/StringUtils.java b/src/main/java/net/minecraft/util/StringUtils.java new file mode 100644 index 0000000..2be879d --- /dev/null +++ b/src/main/java/net/minecraft/util/StringUtils.java @@ -0,0 +1,31 @@ +package net.minecraft.util; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.regex.Pattern; + +public class StringUtils +{ + private static final Pattern patternControlCode = Pattern.compile("(?i)\\u00A7[0-9A-FK-OR]"); + private static final String __OBFID = "CL_00001501"; + + @SideOnly(Side.CLIENT) + public static String ticksToElapsedTime(int par0) + { + int j = par0 / 20; + int k = j / 60; + j %= 60; + return j < 10 ? k + ":0" + j : k + ":" + j; + } + + @SideOnly(Side.CLIENT) + public static String stripControlCodes(String par0Str) + { + return patternControlCode.matcher(par0Str).replaceAll(""); + } + + public static boolean isNullOrEmpty(String p_151246_0_) + { + return p_151246_0_ == null || "".equals(p_151246_0_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/Timer.java b/src/main/java/net/minecraft/util/Timer.java new file mode 100644 index 0000000..e96bc00 --- /dev/null +++ b/src/main/java/net/minecraft/util/Timer.java @@ -0,0 +1,84 @@ +package net.minecraft.util; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.Minecraft; + +@SideOnly(Side.CLIENT) +public class Timer +{ + float ticksPerSecond; + private double lastHRTime; + public int elapsedTicks; + public float renderPartialTicks; + public float timerSpeed = 1.0F; + public float elapsedPartialTicks; + private long lastSyncSysClock; + private long lastSyncHRClock; + private long field_74285_i; + private double timeSyncAdjustment = 1.0D; + private static final String __OBFID = "CL_00000658"; + + public Timer(float par1) + { + this.ticksPerSecond = par1; + this.lastSyncSysClock = Minecraft.getSystemTime(); + this.lastSyncHRClock = System.nanoTime() / 1000000L; + } + + public void updateTimer() + { + long i = Minecraft.getSystemTime(); + long j = i - this.lastSyncSysClock; + long k = System.nanoTime() / 1000000L; + double d0 = (double)k / 1000.0D; + + if (j <= 1000L && j >= 0L) + { + this.field_74285_i += j; + + if (this.field_74285_i > 1000L) + { + long l = k - this.lastSyncHRClock; + double d1 = (double)this.field_74285_i / (double)l; + this.timeSyncAdjustment += (d1 - this.timeSyncAdjustment) * 0.20000000298023224D; + this.lastSyncHRClock = k; + this.field_74285_i = 0L; + } + + if (this.field_74285_i < 0L) + { + this.lastSyncHRClock = k; + } + } + else + { + this.lastHRTime = d0; + } + + this.lastSyncSysClock = i; + double d2 = (d0 - this.lastHRTime) * this.timeSyncAdjustment; + this.lastHRTime = d0; + + if (d2 < 0.0D) + { + d2 = 0.0D; + } + + if (d2 > 1.0D) + { + d2 = 1.0D; + } + + this.elapsedPartialTicks = (float)((double)this.elapsedPartialTicks + d2 * (double)this.timerSpeed * (double)this.ticksPerSecond); + this.elapsedTicks = (int)this.elapsedPartialTicks; + this.elapsedPartialTicks -= (float)this.elapsedTicks; + + if (this.elapsedTicks > 10) + { + this.elapsedTicks = 10; + } + + this.renderPartialTicks = this.elapsedPartialTicks; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/Tuple.java b/src/main/java/net/minecraft/util/Tuple.java new file mode 100644 index 0000000..b2f6b51 --- /dev/null +++ b/src/main/java/net/minecraft/util/Tuple.java @@ -0,0 +1,24 @@ +package net.minecraft.util; + +public class Tuple +{ + private Object first; + private Object second; + private static final String __OBFID = "CL_00001502"; + + public Tuple(Object par1Obj, Object par2Obj) + { + this.first = par1Obj; + this.second = par2Obj; + } + + public Object getFirst() + { + return this.first; + } + + public Object getSecond() + { + return this.second; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/TupleIntJsonSerializable.java b/src/main/java/net/minecraft/util/TupleIntJsonSerializable.java new file mode 100644 index 0000000..c49279f --- /dev/null +++ b/src/main/java/net/minecraft/util/TupleIntJsonSerializable.java @@ -0,0 +1,28 @@ +package net.minecraft.util; + +public class TupleIntJsonSerializable +{ + private int integerValue; + private IJsonSerializable jsonSerializableValue; + private static final String __OBFID = "CL_00001478"; + + public int getIntegerValue() + { + return this.integerValue; + } + + public void setIntegerValue(int p_151188_1_) + { + this.integerValue = p_151188_1_; + } + + public IJsonSerializable getJsonSerializableValue() + { + return this.jsonSerializableValue; + } + + public void setJsonSerializableValue(IJsonSerializable p_151190_1_) + { + this.jsonSerializableValue = p_151190_1_; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/Util.java b/src/main/java/net/minecraft/util/Util.java new file mode 100644 index 0000000..10659d1 --- /dev/null +++ b/src/main/java/net/minecraft/util/Util.java @@ -0,0 +1,62 @@ +package net.minecraft.util; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.UUID; +import java.util.regex.Pattern; + +public class Util +{ + private static final Pattern uuidPattern = Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}"); + private static final String __OBFID = "CL_00001633"; + + @SideOnly(Side.CLIENT) + public static Util.EnumOS getOSType() + { + String s = System.getProperty("os.name").toLowerCase(); + return s.contains("win") ? Util.EnumOS.WINDOWS : (s.contains("mac") ? Util.EnumOS.MACOS : (s.contains("solaris") ? Util.EnumOS.SOLARIS : (s.contains("sunos") ? Util.EnumOS.SOLARIS : (s.contains("linux") ? Util.EnumOS.LINUX : (s.contains("unix") ? Util.EnumOS.LINUX : Util.EnumOS.UNKNOWN))))); + } + + public static boolean isUUIDString(String p_147172_0_) + { + return uuidPattern.matcher(p_147172_0_).matches(); + } + + public static UUID tryGetUUIDFromString(String p_147173_0_) + { + if (p_147173_0_ == null) + { + return null; + } + else if (isUUIDString(p_147173_0_)) + { + return UUID.fromString(p_147173_0_); + } + else + { + if (p_147173_0_.length() == 32) + { + String s1 = p_147173_0_.substring(0, 8) + "-" + p_147173_0_.substring(8, 12) + "-" + p_147173_0_.substring(12, 16) + "-" + p_147173_0_.substring(16, 20) + "-" + p_147173_0_.substring(20, 32); + + if (isUUIDString(s1)) + { + return UUID.fromString(s1); + } + } + + return null; + } + } + + @SideOnly(Side.CLIENT) + public static enum EnumOS + { + LINUX, + SOLARIS, + WINDOWS, + MACOS, + UNKNOWN; + + private static final String __OBFID = "CL_00001660"; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/ValueObject.java b/src/main/java/net/minecraft/util/ValueObject.java new file mode 100644 index 0000000..398b4c0 --- /dev/null +++ b/src/main/java/net/minecraft/util/ValueObject.java @@ -0,0 +1,45 @@ +package net.minecraft.util; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; + +@SideOnly(Side.CLIENT) +public abstract class ValueObject +{ + private static final String __OBFID = "CL_00001173"; + + public String toString() + { + StringBuilder stringbuilder = new StringBuilder("{"); + Field[] afield = this.getClass().getFields(); + int i = afield.length; + + for (int j = 0; j < i; ++j) + { + Field field = afield[j]; + + if (!func_148766_a(field)) + { + try + { + stringbuilder.append(field.getName()).append("=").append(field.get(this)).append(" "); + } + catch (IllegalAccessException illegalaccessexception) + { + ; + } + } + } + + stringbuilder.deleteCharAt(stringbuilder.length() - 1); + stringbuilder.append('}'); + return stringbuilder.toString(); + } + + private static boolean func_148766_a(Field p_148766_0_) + { + return Modifier.isStatic(p_148766_0_.getModifiers()); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/Vec3.java b/src/main/java/net/minecraft/util/Vec3.java new file mode 100644 index 0000000..91e5e87 --- /dev/null +++ b/src/main/java/net/minecraft/util/Vec3.java @@ -0,0 +1,194 @@ +package net.minecraft.util; + +public class Vec3 +{ + public static final Vec3Pool fakePool = new Vec3Pool(-1, -1); + public final Vec3Pool myVec3LocalPool; + public double xCoord; + public double yCoord; + public double zCoord; + private static final String __OBFID = "CL_00000612"; + + public static Vec3 createVectorHelper(double par0, double par2, double par4) + { + return new Vec3(fakePool, par0, par2, par4); + } + + protected Vec3(Vec3Pool par1Vec3Pool, double par2, double par4, double par6) + { + if (par2 == -0.0D) + { + par2 = 0.0D; + } + + if (par4 == -0.0D) + { + par4 = 0.0D; + } + + if (par6 == -0.0D) + { + par6 = 0.0D; + } + + this.xCoord = par2; + this.yCoord = par4; + this.zCoord = par6; + this.myVec3LocalPool = par1Vec3Pool; + } + + protected Vec3 setComponents(double par1, double par3, double par5) + { + this.xCoord = par1; + this.yCoord = par3; + this.zCoord = par5; + return this; + } + + public Vec3 subtract(Vec3 par1Vec3) + { + return this.myVec3LocalPool.getVecFromPool(par1Vec3.xCoord - this.xCoord, par1Vec3.yCoord - this.yCoord, par1Vec3.zCoord - this.zCoord); + } + + public Vec3 normalize() + { + double d0 = (double)MathHelper.sqrt_double(this.xCoord * this.xCoord + this.yCoord * this.yCoord + this.zCoord * this.zCoord); + return d0 < 1.0E-4D ? this.myVec3LocalPool.getVecFromPool(0.0D, 0.0D, 0.0D) : this.myVec3LocalPool.getVecFromPool(this.xCoord / d0, this.yCoord / d0, this.zCoord / d0); + } + + public double dotProduct(Vec3 par1Vec3) + { + return this.xCoord * par1Vec3.xCoord + this.yCoord * par1Vec3.yCoord + this.zCoord * par1Vec3.zCoord; + } + + public Vec3 crossProduct(Vec3 par1Vec3) + { + return this.myVec3LocalPool.getVecFromPool(this.yCoord * par1Vec3.zCoord - this.zCoord * par1Vec3.yCoord, this.zCoord * par1Vec3.xCoord - this.xCoord * par1Vec3.zCoord, this.xCoord * par1Vec3.yCoord - this.yCoord * par1Vec3.xCoord); + } + + public Vec3 addVector(double par1, double par3, double par5) + { + return this.myVec3LocalPool.getVecFromPool(this.xCoord + par1, this.yCoord + par3, this.zCoord + par5); + } + + public double distanceTo(Vec3 par1Vec3) + { + double d0 = par1Vec3.xCoord - this.xCoord; + double d1 = par1Vec3.yCoord - this.yCoord; + double d2 = par1Vec3.zCoord - this.zCoord; + return (double)MathHelper.sqrt_double(d0 * d0 + d1 * d1 + d2 * d2); + } + + public double squareDistanceTo(Vec3 par1Vec3) + { + double d0 = par1Vec3.xCoord - this.xCoord; + double d1 = par1Vec3.yCoord - this.yCoord; + double d2 = par1Vec3.zCoord - this.zCoord; + return d0 * d0 + d1 * d1 + d2 * d2; + } + + public double squareDistanceTo(double par1, double par3, double par5) + { + double d3 = par1 - this.xCoord; + double d4 = par3 - this.yCoord; + double d5 = par5 - this.zCoord; + return d3 * d3 + d4 * d4 + d5 * d5; + } + + public double lengthVector() + { + return (double)MathHelper.sqrt_double(this.xCoord * this.xCoord + this.yCoord * this.yCoord + this.zCoord * this.zCoord); + } + + public Vec3 getIntermediateWithXValue(Vec3 par1Vec3, double par2) + { + double d1 = par1Vec3.xCoord - this.xCoord; + double d2 = par1Vec3.yCoord - this.yCoord; + double d3 = par1Vec3.zCoord - this.zCoord; + + if (d1 * d1 < 1.0000000116860974E-7D) + { + return null; + } + else + { + double d4 = (par2 - this.xCoord) / d1; + return d4 >= 0.0D && d4 <= 1.0D ? this.myVec3LocalPool.getVecFromPool(this.xCoord + d1 * d4, this.yCoord + d2 * d4, this.zCoord + d3 * d4) : null; + } + } + + public Vec3 getIntermediateWithYValue(Vec3 par1Vec3, double par2) + { + double d1 = par1Vec3.xCoord - this.xCoord; + double d2 = par1Vec3.yCoord - this.yCoord; + double d3 = par1Vec3.zCoord - this.zCoord; + + if (d2 * d2 < 1.0000000116860974E-7D) + { + return null; + } + else + { + double d4 = (par2 - this.yCoord) / d2; + return d4 >= 0.0D && d4 <= 1.0D ? this.myVec3LocalPool.getVecFromPool(this.xCoord + d1 * d4, this.yCoord + d2 * d4, this.zCoord + d3 * d4) : null; + } + } + + public Vec3 getIntermediateWithZValue(Vec3 par1Vec3, double par2) + { + double d1 = par1Vec3.xCoord - this.xCoord; + double d2 = par1Vec3.yCoord - this.yCoord; + double d3 = par1Vec3.zCoord - this.zCoord; + + if (d3 * d3 < 1.0000000116860974E-7D) + { + return null; + } + else + { + double d4 = (par2 - this.zCoord) / d3; + return d4 >= 0.0D && d4 <= 1.0D ? this.myVec3LocalPool.getVecFromPool(this.xCoord + d1 * d4, this.yCoord + d2 * d4, this.zCoord + d3 * d4) : null; + } + } + + public String toString() + { + return "(" + this.xCoord + ", " + this.yCoord + ", " + this.zCoord + ")"; + } + + public void rotateAroundX(float par1) + { + float f1 = MathHelper.cos(par1); + float f2 = MathHelper.sin(par1); + double d0 = this.xCoord; + double d1 = this.yCoord * (double)f1 + this.zCoord * (double)f2; + double d2 = this.zCoord * (double)f1 - this.yCoord * (double)f2; + this.xCoord = d0; + this.yCoord = d1; + this.zCoord = d2; + } + + public void rotateAroundY(float par1) + { + float f1 = MathHelper.cos(par1); + float f2 = MathHelper.sin(par1); + double d0 = this.xCoord * (double)f1 + this.zCoord * (double)f2; + double d1 = this.yCoord; + double d2 = this.zCoord * (double)f1 - this.xCoord * (double)f2; + this.xCoord = d0; + this.yCoord = d1; + this.zCoord = d2; + } + + public void rotateAroundZ(float par1) + { + float f1 = MathHelper.cos(par1); + float f2 = MathHelper.sin(par1); + double d0 = this.xCoord * (double)f1 + this.yCoord * (double)f2; + double d1 = this.yCoord * (double)f1 - this.xCoord * (double)f2; + double d2 = this.zCoord; + this.xCoord = d0; + this.yCoord = d1; + this.zCoord = d2; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/Vec3Pool.java b/src/main/java/net/minecraft/util/Vec3Pool.java new file mode 100644 index 0000000..f411ca4 --- /dev/null +++ b/src/main/java/net/minecraft/util/Vec3Pool.java @@ -0,0 +1,100 @@ +package net.minecraft.util; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.List; + +public class Vec3Pool +{ + private final int truncateArrayResetThreshold; + private final int minimumSize; + private final List vec3Cache = new ArrayList(); + private int nextFreeSpace; + private int maximumSizeSinceLastTruncation; + private int resetCount; + private static final String __OBFID = "CL_00000613"; + + public Vec3Pool(int par1, int par2) + { + this.truncateArrayResetThreshold = par1; + this.minimumSize = par2; + } + + public Vec3 getVecFromPool(double par1, double par3, double par5) + { + if (this.skipCache()) + { + return new Vec3(this, par1, par3, par5); + } + else + { + Vec3 vec3; + + if (this.nextFreeSpace >= this.vec3Cache.size()) + { + vec3 = new Vec3(this, par1, par3, par5); + this.vec3Cache.add(vec3); + } + else + { + vec3 = (Vec3)this.vec3Cache.get(this.nextFreeSpace); + vec3.setComponents(par1, par3, par5); + } + + ++this.nextFreeSpace; + return vec3; + } + } + + public void clear() + { + if (!this.skipCache()) + { + if (this.nextFreeSpace > this.maximumSizeSinceLastTruncation) + { + this.maximumSizeSinceLastTruncation = this.nextFreeSpace; + } + + if (this.resetCount++ == this.truncateArrayResetThreshold) + { + int i = Math.max(this.maximumSizeSinceLastTruncation, this.vec3Cache.size() - this.minimumSize); + + while (this.vec3Cache.size() > i) + { + this.vec3Cache.remove(i); + } + + this.maximumSizeSinceLastTruncation = 0; + this.resetCount = 0; + } + + this.nextFreeSpace = 0; + } + } + + @SideOnly(Side.CLIENT) + public void clearAndFreeCache() + { + if (!this.skipCache()) + { + this.nextFreeSpace = 0; + this.vec3Cache.clear(); + } + } + + public int getPoolSize() + { + return this.vec3Cache.size(); + } + + public int getNextFreeSpace() + { + return this.nextFreeSpace; + } + + private boolean skipCache() + { + return this.minimumSize < 0 || this.truncateArrayResetThreshold < 0; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/WeightedRandom.java b/src/main/java/net/minecraft/util/WeightedRandom.java new file mode 100644 index 0000000..e61d0c8 --- /dev/null +++ b/src/main/java/net/minecraft/util/WeightedRandom.java @@ -0,0 +1,114 @@ +package net.minecraft.util; + +import java.util.Collection; +import java.util.Iterator; +import java.util.Random; + +public class WeightedRandom +{ + private static final String __OBFID = "CL_00001503"; + + public static int getTotalWeight(Collection par0Collection) + { + int i = 0; + WeightedRandom.Item item; + + for (Iterator iterator = par0Collection.iterator(); iterator.hasNext(); i += item.itemWeight) + { + item = (WeightedRandom.Item)iterator.next(); + } + + return i; + } + + public static WeightedRandom.Item getRandomItem(Random par0Random, Collection par1Collection, int par2) + { + if (par2 <= 0) + { + throw new IllegalArgumentException(); + } + else + { + int j = par0Random.nextInt(par2); + Iterator iterator = par1Collection.iterator(); + WeightedRandom.Item item; + + do + { + if (!iterator.hasNext()) + { + return null; + } + + item = (WeightedRandom.Item)iterator.next(); + j -= item.itemWeight; + } + while (j >= 0); + + return item; + } + } + + public static WeightedRandom.Item getRandomItem(Random par0Random, Collection par1Collection) + { + return getRandomItem(par0Random, par1Collection, getTotalWeight(par1Collection)); + } + + public static int getTotalWeight(WeightedRandom.Item[] par0ArrayOfWeightedRandomItem) + { + int i = 0; + WeightedRandom.Item[] aitem = par0ArrayOfWeightedRandomItem; + int j = par0ArrayOfWeightedRandomItem.length; + + for (int k = 0; k < j; ++k) + { + WeightedRandom.Item item = aitem[k]; + i += item.itemWeight; + } + + return i; + } + + public static WeightedRandom.Item getRandomItem(Random par0Random, WeightedRandom.Item[] par1ArrayOfWeightedRandomItem, int par2) + { + if (par2 <= 0) + { + throw new IllegalArgumentException(); + } + else + { + int j = par0Random.nextInt(par2); + WeightedRandom.Item[] aitem = par1ArrayOfWeightedRandomItem; + int k = par1ArrayOfWeightedRandomItem.length; + + for (int l = 0; l < k; ++l) + { + WeightedRandom.Item item = aitem[l]; + j -= item.itemWeight; + + if (j < 0) + { + return item; + } + } + + return null; + } + } + + public static WeightedRandom.Item getRandomItem(Random par0Random, WeightedRandom.Item[] par1ArrayOfWeightedRandomItem) + { + return getRandomItem(par0Random, par1ArrayOfWeightedRandomItem, getTotalWeight(par1ArrayOfWeightedRandomItem)); + } + + public static class Item + { + public int itemWeight; + private static final String __OBFID = "CL_00001504"; + + public Item(int par1) + { + this.itemWeight = par1; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/WeightedRandomChestContent.java b/src/main/java/net/minecraft/util/WeightedRandomChestContent.java new file mode 100644 index 0000000..c8824dd --- /dev/null +++ b/src/main/java/net/minecraft/util/WeightedRandomChestContent.java @@ -0,0 +1,95 @@ +package net.minecraft.util; + +import java.util.Random; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntityDispenser; +import net.minecraftforge.common.ChestGenHooks; + +public class WeightedRandomChestContent extends WeightedRandom.Item +{ + public ItemStack theItemId; + public int theMinimumChanceToGenerateItem; + public int theMaximumChanceToGenerateItem; + private static final String __OBFID = "CL_00001505"; + + public WeightedRandomChestContent(Item p_i45311_1_, int p_i45311_2_, int p_i45311_3_, int p_i45311_4_, int p_i45311_5_) + { + super(p_i45311_5_); + this.theItemId = new ItemStack(p_i45311_1_, 1, p_i45311_2_); + this.theMinimumChanceToGenerateItem = p_i45311_3_; + this.theMaximumChanceToGenerateItem = p_i45311_4_; + } + + public WeightedRandomChestContent(ItemStack par1ItemStack, int par2, int par3, int par4) + { + super(par4); + this.theItemId = par1ItemStack; + this.theMinimumChanceToGenerateItem = par2; + this.theMaximumChanceToGenerateItem = par3; + } + + public static void generateChestContents(Random par0Random, WeightedRandomChestContent[] par1ArrayOfWeightedRandomChestContent, IInventory par2IInventory, int par3) + { + for (int j = 0; j < par3; ++j) + { + WeightedRandomChestContent weightedrandomchestcontent = (WeightedRandomChestContent)WeightedRandom.getRandomItem(par0Random, par1ArrayOfWeightedRandomChestContent); + ItemStack[] stacks = weightedrandomchestcontent.generateChestContent(par0Random, par2IInventory); + + for (ItemStack item : stacks) + { + par2IInventory.setInventorySlotContents(par0Random.nextInt(par2IInventory.getSizeInventory()), item); + } + } + } + + public static void generateDispenserContents(Random p_150706_0_, WeightedRandomChestContent[] p_150706_1_, TileEntityDispenser p_150706_2_, int p_150706_3_) + { + for (int j = 0; j < p_150706_3_; ++j) + { + WeightedRandomChestContent weightedrandomchestcontent = (WeightedRandomChestContent)WeightedRandom.getRandomItem(p_150706_0_, p_150706_1_); + int k = weightedrandomchestcontent.theMinimumChanceToGenerateItem + p_150706_0_.nextInt(weightedrandomchestcontent.theMaximumChanceToGenerateItem - weightedrandomchestcontent.theMinimumChanceToGenerateItem + 1); + ItemStack[] stacks = weightedrandomchestcontent.generateChestContent(p_150706_0_, p_150706_2_); + for (ItemStack item : stacks) + { + p_150706_2_.setInventorySlotContents(p_150706_0_.nextInt(p_150706_2_.getSizeInventory()), item); + } + } + } + + public static WeightedRandomChestContent[] func_92080_a(WeightedRandomChestContent[] par0ArrayOfWeightedRandomChestContent, WeightedRandomChestContent ... par1ArrayOfWeightedRandomChestContent) + { + WeightedRandomChestContent[] aweightedrandomchestcontent1 = new WeightedRandomChestContent[par0ArrayOfWeightedRandomChestContent.length + par1ArrayOfWeightedRandomChestContent.length]; + int i = 0; + + for (int j = 0; j < par0ArrayOfWeightedRandomChestContent.length; ++j) + { + aweightedrandomchestcontent1[i++] = par0ArrayOfWeightedRandomChestContent[j]; + } + + WeightedRandomChestContent[] aweightedrandomchestcontent2 = par1ArrayOfWeightedRandomChestContent; + int k = par1ArrayOfWeightedRandomChestContent.length; + + for (int l = 0; l < k; ++l) + { + WeightedRandomChestContent weightedrandomchestcontent1 = aweightedrandomchestcontent2[l]; + aweightedrandomchestcontent1[i++] = weightedrandomchestcontent1; + } + + return aweightedrandomchestcontent1; + } + + // -- Forge hooks + /** + * Allow a mod to submit a custom implementation that can delegate item stack generation beyond simple stack lookup + * + * @param random The current random for generation + * @param newInventory The inventory being generated (do not populate it, but you can refer to it) + * @return An array of {@link ItemStack} to put into the chest + */ + protected ItemStack[] generateChestContent(Random random, IInventory newInventory) + { + return ChestGenHooks.generateStacks(random, theItemId, theMinimumChanceToGenerateItem, theMaximumChanceToGenerateItem); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/WeightedRandomFishable.java b/src/main/java/net/minecraft/util/WeightedRandomFishable.java new file mode 100644 index 0000000..25c439c --- /dev/null +++ b/src/main/java/net/minecraft/util/WeightedRandomFishable.java @@ -0,0 +1,61 @@ +package net.minecraft.util; + +import java.util.Random; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.item.ItemStack; + +public class WeightedRandomFishable extends WeightedRandom.Item +{ + private final ItemStack field_150711_b; + private float field_150712_c; + private boolean field_150710_d; + private static final String __OBFID = "CL_00001664"; + + public WeightedRandomFishable(ItemStack p_i45317_1_, int p_i45317_2_) + { + super(p_i45317_2_); + this.field_150711_b = p_i45317_1_; + } + + public ItemStack func_150708_a(Random p_150708_1_) + { + ItemStack itemstack = this.field_150711_b.copy(); + + if (this.field_150712_c > 0.0F) + { + int i = (int)(this.field_150712_c * (float)this.field_150711_b.getMaxDamage()); + int j = itemstack.getMaxDamage() - p_150708_1_.nextInt(p_150708_1_.nextInt(i) + 1); + + if (j > i) + { + j = i; + } + + if (j < 1) + { + j = 1; + } + + itemstack.setItemDamage(j); + } + + if (this.field_150710_d) + { + EnchantmentHelper.addRandomEnchantment(p_150708_1_, itemstack, 30); + } + + return itemstack; + } + + public WeightedRandomFishable func_150709_a(float p_150709_1_) + { + this.field_150712_c = p_150709_1_; + return this; + } + + public WeightedRandomFishable func_150707_a() + { + this.field_150710_d = true; + return this; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/village/MerchantRecipe.java b/src/main/java/net/minecraft/village/MerchantRecipe.java new file mode 100644 index 0000000..4277fd2 --- /dev/null +++ b/src/main/java/net/minecraft/village/MerchantRecipe.java @@ -0,0 +1,134 @@ +package net.minecraft.village; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class MerchantRecipe +{ + private ItemStack itemToBuy; + private ItemStack secondItemToBuy; + private ItemStack itemToSell; + private int toolUses; + private int maxTradeUses; + private static final String __OBFID = "CL_00000126"; + + public MerchantRecipe(NBTTagCompound par1NBTTagCompound) + { + this.readFromTags(par1NBTTagCompound); + } + + public MerchantRecipe(ItemStack par1ItemStack, ItemStack par2ItemStack, ItemStack par3ItemStack) + { + this.itemToBuy = par1ItemStack; + this.secondItemToBuy = par2ItemStack; + this.itemToSell = par3ItemStack; + this.maxTradeUses = 7; + } + + public MerchantRecipe(ItemStack par1ItemStack, ItemStack par2ItemStack) + { + this(par1ItemStack, (ItemStack)null, par2ItemStack); + } + + public MerchantRecipe(ItemStack par1ItemStack, Item par2Item) + { + this(par1ItemStack, new ItemStack(par2Item)); + } + + public ItemStack getItemToBuy() + { + return this.itemToBuy; + } + + public ItemStack getSecondItemToBuy() + { + return this.secondItemToBuy; + } + + public boolean hasSecondItemToBuy() + { + return this.secondItemToBuy != null; + } + + public ItemStack getItemToSell() + { + return this.itemToSell; + } + + public boolean hasSameIDsAs(MerchantRecipe par1MerchantRecipe) + { + return this.itemToBuy.getItem() == par1MerchantRecipe.itemToBuy.getItem() && this.itemToSell.getItem() == par1MerchantRecipe.itemToSell.getItem() ? this.secondItemToBuy == null && par1MerchantRecipe.secondItemToBuy == null || this.secondItemToBuy != null && par1MerchantRecipe.secondItemToBuy != null && this.secondItemToBuy.getItem() == par1MerchantRecipe.secondItemToBuy.getItem() : false; + } + + public boolean hasSameItemsAs(MerchantRecipe par1MerchantRecipe) + { + return this.hasSameIDsAs(par1MerchantRecipe) && (this.itemToBuy.stackSize < par1MerchantRecipe.itemToBuy.stackSize || this.secondItemToBuy != null && this.secondItemToBuy.stackSize < par1MerchantRecipe.secondItemToBuy.stackSize); + } + + public void incrementToolUses() + { + ++this.toolUses; + } + + public void func_82783_a(int par1) + { + this.maxTradeUses += par1; + } + + public boolean isRecipeDisabled() + { + return this.toolUses >= this.maxTradeUses; + } + + @SideOnly(Side.CLIENT) + public void func_82785_h() + { + this.toolUses = this.maxTradeUses; + } + + public void readFromTags(NBTTagCompound par1NBTTagCompound) + { + NBTTagCompound nbttagcompound1 = par1NBTTagCompound.getCompoundTag("buy"); + this.itemToBuy = ItemStack.loadItemStackFromNBT(nbttagcompound1); + NBTTagCompound nbttagcompound2 = par1NBTTagCompound.getCompoundTag("sell"); + this.itemToSell = ItemStack.loadItemStackFromNBT(nbttagcompound2); + + if (par1NBTTagCompound.hasKey("buyB", 10)) + { + this.secondItemToBuy = ItemStack.loadItemStackFromNBT(par1NBTTagCompound.getCompoundTag("buyB")); + } + + if (par1NBTTagCompound.hasKey("uses", 99)) + { + this.toolUses = par1NBTTagCompound.getInteger("uses"); + } + + if (par1NBTTagCompound.hasKey("maxUses", 99)) + { + this.maxTradeUses = par1NBTTagCompound.getInteger("maxUses"); + } + else + { + this.maxTradeUses = 7; + } + } + + public NBTTagCompound writeToTags() + { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + nbttagcompound.setTag("buy", this.itemToBuy.writeToNBT(new NBTTagCompound())); + nbttagcompound.setTag("sell", this.itemToSell.writeToNBT(new NBTTagCompound())); + + if (this.secondItemToBuy != null) + { + nbttagcompound.setTag("buyB", this.secondItemToBuy.writeToNBT(new NBTTagCompound())); + } + + nbttagcompound.setInteger("uses", this.toolUses); + nbttagcompound.setInteger("maxUses", this.maxTradeUses); + return nbttagcompound; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/village/MerchantRecipeList.java b/src/main/java/net/minecraft/village/MerchantRecipeList.java new file mode 100644 index 0000000..57ca921 --- /dev/null +++ b/src/main/java/net/minecraft/village/MerchantRecipeList.java @@ -0,0 +1,143 @@ +package net.minecraft.village; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.IOException; +import java.util.ArrayList; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.network.PacketBuffer; + +public class MerchantRecipeList extends ArrayList +{ + private static final String __OBFID = "CL_00000127"; + + public MerchantRecipeList() {} + + public MerchantRecipeList(NBTTagCompound par1NBTTagCompound) + { + this.readRecipiesFromTags(par1NBTTagCompound); + } + + public MerchantRecipe canRecipeBeUsed(ItemStack par1ItemStack, ItemStack par2ItemStack, int par3) + { + if (par3 > 0 && par3 < this.size()) + { + MerchantRecipe merchantrecipe1 = (MerchantRecipe)this.get(par3); + return par1ItemStack.getItem() == merchantrecipe1.getItemToBuy().getItem() && (par2ItemStack == null && !merchantrecipe1.hasSecondItemToBuy() || merchantrecipe1.hasSecondItemToBuy() && par2ItemStack != null && merchantrecipe1.getSecondItemToBuy().getItem() == par2ItemStack.getItem()) && par1ItemStack.stackSize >= merchantrecipe1.getItemToBuy().stackSize && (!merchantrecipe1.hasSecondItemToBuy() || par2ItemStack.stackSize >= merchantrecipe1.getSecondItemToBuy().stackSize) ? merchantrecipe1 : null; + } + else + { + for (int j = 0; j < this.size(); ++j) + { + MerchantRecipe merchantrecipe = (MerchantRecipe)this.get(j); + + if (par1ItemStack.getItem() == merchantrecipe.getItemToBuy().getItem() && par1ItemStack.stackSize >= merchantrecipe.getItemToBuy().stackSize && (!merchantrecipe.hasSecondItemToBuy() && par2ItemStack == null || merchantrecipe.hasSecondItemToBuy() && par2ItemStack != null && merchantrecipe.getSecondItemToBuy().getItem() == par2ItemStack.getItem() && par2ItemStack.stackSize >= merchantrecipe.getSecondItemToBuy().stackSize)) + { + return merchantrecipe; + } + } + + return null; + } + } + + public void addToListWithCheck(MerchantRecipe par1MerchantRecipe) + { + for (int i = 0; i < this.size(); ++i) + { + MerchantRecipe merchantrecipe1 = (MerchantRecipe)this.get(i); + + if (par1MerchantRecipe.hasSameIDsAs(merchantrecipe1)) + { + if (par1MerchantRecipe.hasSameItemsAs(merchantrecipe1)) + { + this.set(i, par1MerchantRecipe); + } + + return; + } + } + + this.add(par1MerchantRecipe); + } + + public void func_151391_a(PacketBuffer p_151391_1_) throws IOException + { + p_151391_1_.writeByte((byte)(this.size() & 255)); + + for (int i = 0; i < this.size(); ++i) + { + MerchantRecipe merchantrecipe = (MerchantRecipe)this.get(i); + p_151391_1_.writeItemStackToBuffer(merchantrecipe.getItemToBuy()); + p_151391_1_.writeItemStackToBuffer(merchantrecipe.getItemToSell()); + ItemStack itemstack = merchantrecipe.getSecondItemToBuy(); + p_151391_1_.writeBoolean(itemstack != null); + + if (itemstack != null) + { + p_151391_1_.writeItemStackToBuffer(itemstack); + } + + p_151391_1_.writeBoolean(merchantrecipe.isRecipeDisabled()); + } + } + + public void readRecipiesFromTags(NBTTagCompound par1NBTTagCompound) + { + NBTTagList nbttaglist = par1NBTTagCompound.getTagList("Recipes", 10); + + for (int i = 0; i < nbttaglist.tagCount(); ++i) + { + NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); + this.add(new MerchantRecipe(nbttagcompound1)); + } + } + + public NBTTagCompound getRecipiesAsTags() + { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + NBTTagList nbttaglist = new NBTTagList(); + + for (int i = 0; i < this.size(); ++i) + { + MerchantRecipe merchantrecipe = (MerchantRecipe)this.get(i); + nbttaglist.appendTag(merchantrecipe.writeToTags()); + } + + nbttagcompound.setTag("Recipes", nbttaglist); + return nbttagcompound; + } + + @SideOnly(Side.CLIENT) + public static MerchantRecipeList func_151390_b(PacketBuffer p_151390_0_) throws IOException + { + MerchantRecipeList merchantrecipelist = new MerchantRecipeList(); + int i = p_151390_0_.readByte() & 255; + + for (int j = 0; j < i; ++j) + { + ItemStack itemstack = p_151390_0_.readItemStackFromBuffer(); + ItemStack itemstack1 = p_151390_0_.readItemStackFromBuffer(); + ItemStack itemstack2 = null; + + if (p_151390_0_.readBoolean()) + { + itemstack2 = p_151390_0_.readItemStackFromBuffer(); + } + + boolean flag = p_151390_0_.readBoolean(); + MerchantRecipe merchantrecipe = new MerchantRecipe(itemstack, itemstack2, itemstack1); + + if (flag) + { + merchantrecipe.func_82785_h(); + } + + merchantrecipelist.add(merchantrecipe); + } + + return merchantrecipelist; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/village/Village.java b/src/main/java/net/minecraft/village/Village.java new file mode 100644 index 0000000..e655132 --- /dev/null +++ b/src/main/java/net/minecraft/village/Village.java @@ -0,0 +1,546 @@ +package net.minecraft.village; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.TreeMap; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.monster.EntityIronGolem; +import net.minecraft.entity.passive.EntityVillager; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; + +public class Village +{ + private World worldObj; + private final List villageDoorInfoList = new ArrayList(); + private final ChunkCoordinates centerHelper = new ChunkCoordinates(0, 0, 0); + private final ChunkCoordinates center = new ChunkCoordinates(0, 0, 0); + private int villageRadius; + private int lastAddDoorTimestamp; + private int tickCounter; + private int numVillagers; + private int noBreedTicks; + private TreeMap playerReputation = new TreeMap(); + private List villageAgressors = new ArrayList(); + private int numIronGolems; + private static final String __OBFID = "CL_00001631"; + + public Village() {} + + public Village(World par1World) + { + this.worldObj = par1World; + } + + public void func_82691_a(World par1World) + { + this.worldObj = par1World; + } + + public void tick(int par1) + { + this.tickCounter = par1; + this.removeDeadAndOutOfRangeDoors(); + this.removeDeadAndOldAgressors(); + + if (par1 % 20 == 0) + { + this.updateNumVillagers(); + } + + if (par1 % 30 == 0) + { + this.updateNumIronGolems(); + } + + int j = this.numVillagers / 10; + + if (this.numIronGolems < j && this.villageDoorInfoList.size() > 20 && this.worldObj.rand.nextInt(7000) == 0) + { + Vec3 vec3 = this.tryGetIronGolemSpawningLocation(MathHelper.floor_float((float)this.center.posX), MathHelper.floor_float((float)this.center.posY), MathHelper.floor_float((float)this.center.posZ), 2, 4, 2); + + if (vec3 != null) + { + EntityIronGolem entityirongolem = new EntityIronGolem(this.worldObj); + entityirongolem.setPosition(vec3.xCoord, vec3.yCoord, vec3.zCoord); + this.worldObj.spawnEntityInWorld(entityirongolem); + ++this.numIronGolems; + } + } + } + + private Vec3 tryGetIronGolemSpawningLocation(int par1, int par2, int par3, int par4, int par5, int par6) + { + for (int k1 = 0; k1 < 10; ++k1) + { + int l1 = par1 + this.worldObj.rand.nextInt(16) - 8; + int i2 = par2 + this.worldObj.rand.nextInt(6) - 3; + int j2 = par3 + this.worldObj.rand.nextInt(16) - 8; + + if (this.isInRange(l1, i2, j2) && this.isValidIronGolemSpawningLocation(l1, i2, j2, par4, par5, par6)) + { + return this.worldObj.getWorldVec3Pool().getVecFromPool((double)l1, (double)i2, (double)j2); + } + } + + return null; + } + + private boolean isValidIronGolemSpawningLocation(int par1, int par2, int par3, int par4, int par5, int par6) + { + if (!World.doesBlockHaveSolidTopSurface(this.worldObj, par1, par2 - 1, par3)) + { + return false; + } + else + { + int k1 = par1 - par4 / 2; + int l1 = par3 - par6 / 2; + + for (int i2 = k1; i2 < k1 + par4; ++i2) + { + for (int j2 = par2; j2 < par2 + par5; ++j2) + { + for (int k2 = l1; k2 < l1 + par6; ++k2) + { + if (this.worldObj.getBlock(i2, j2, k2).isNormalCube()) + { + return false; + } + } + } + } + + return true; + } + } + + private void updateNumIronGolems() + { + List list = this.worldObj.getEntitiesWithinAABB(EntityIronGolem.class, AxisAlignedBB.getAABBPool().getAABB((double)(this.center.posX - this.villageRadius), (double)(this.center.posY - 4), (double)(this.center.posZ - this.villageRadius), (double)(this.center.posX + this.villageRadius), (double)(this.center.posY + 4), (double)(this.center.posZ + this.villageRadius))); + this.numIronGolems = list.size(); + } + + private void updateNumVillagers() + { + List list = this.worldObj.getEntitiesWithinAABB(EntityVillager.class, AxisAlignedBB.getAABBPool().getAABB((double)(this.center.posX - this.villageRadius), (double)(this.center.posY - 4), (double)(this.center.posZ - this.villageRadius), (double)(this.center.posX + this.villageRadius), (double)(this.center.posY + 4), (double)(this.center.posZ + this.villageRadius))); + this.numVillagers = list.size(); + + if (this.numVillagers == 0) + { + this.playerReputation.clear(); + } + } + + public ChunkCoordinates getCenter() + { + return this.center; + } + + public int getVillageRadius() + { + return this.villageRadius; + } + + public int getNumVillageDoors() + { + return this.villageDoorInfoList.size(); + } + + public int getTicksSinceLastDoorAdding() + { + return this.tickCounter - this.lastAddDoorTimestamp; + } + + public int getNumVillagers() + { + return this.numVillagers; + } + + public boolean isInRange(int par1, int par2, int par3) + { + return this.center.getDistanceSquared(par1, par2, par3) < (float)(this.villageRadius * this.villageRadius); + } + + public List getVillageDoorInfoList() + { + return this.villageDoorInfoList; + } + + public VillageDoorInfo findNearestDoor(int par1, int par2, int par3) + { + VillageDoorInfo villagedoorinfo = null; + int l = Integer.MAX_VALUE; + Iterator iterator = this.villageDoorInfoList.iterator(); + + while (iterator.hasNext()) + { + VillageDoorInfo villagedoorinfo1 = (VillageDoorInfo)iterator.next(); + int i1 = villagedoorinfo1.getDistanceSquared(par1, par2, par3); + + if (i1 < l) + { + villagedoorinfo = villagedoorinfo1; + l = i1; + } + } + + return villagedoorinfo; + } + + public VillageDoorInfo findNearestDoorUnrestricted(int par1, int par2, int par3) + { + VillageDoorInfo villagedoorinfo = null; + int l = Integer.MAX_VALUE; + Iterator iterator = this.villageDoorInfoList.iterator(); + + while (iterator.hasNext()) + { + VillageDoorInfo villagedoorinfo1 = (VillageDoorInfo)iterator.next(); + int i1 = villagedoorinfo1.getDistanceSquared(par1, par2, par3); + + if (i1 > 256) + { + i1 *= 1000; + } + else + { + i1 = villagedoorinfo1.getDoorOpeningRestrictionCounter(); + } + + if (i1 < l) + { + villagedoorinfo = villagedoorinfo1; + l = i1; + } + } + + return villagedoorinfo; + } + + public VillageDoorInfo getVillageDoorAt(int par1, int par2, int par3) + { + if (this.center.getDistanceSquared(par1, par2, par3) > (float)(this.villageRadius * this.villageRadius)) + { + return null; + } + else + { + Iterator iterator = this.villageDoorInfoList.iterator(); + VillageDoorInfo villagedoorinfo; + + do + { + if (!iterator.hasNext()) + { + return null; + } + + villagedoorinfo = (VillageDoorInfo)iterator.next(); + } + while (villagedoorinfo.posX != par1 || villagedoorinfo.posZ != par3 || Math.abs(villagedoorinfo.posY - par2) > 1); + + return villagedoorinfo; + } + } + + public void addVillageDoorInfo(VillageDoorInfo par1VillageDoorInfo) + { + this.villageDoorInfoList.add(par1VillageDoorInfo); + this.centerHelper.posX += par1VillageDoorInfo.posX; + this.centerHelper.posY += par1VillageDoorInfo.posY; + this.centerHelper.posZ += par1VillageDoorInfo.posZ; + this.updateVillageRadiusAndCenter(); + this.lastAddDoorTimestamp = par1VillageDoorInfo.lastActivityTimestamp; + } + + public boolean isAnnihilated() + { + return this.villageDoorInfoList.isEmpty(); + } + + public void addOrRenewAgressor(EntityLivingBase par1EntityLivingBase) + { + Iterator iterator = this.villageAgressors.iterator(); + Village.VillageAgressor villageagressor; + + do + { + if (!iterator.hasNext()) + { + this.villageAgressors.add(new Village.VillageAgressor(par1EntityLivingBase, this.tickCounter)); + return; + } + + villageagressor = (Village.VillageAgressor)iterator.next(); + } + while (villageagressor.agressor != par1EntityLivingBase); + + villageagressor.agressionTime = this.tickCounter; + } + + public EntityLivingBase findNearestVillageAggressor(EntityLivingBase par1EntityLivingBase) + { + double d0 = Double.MAX_VALUE; + Village.VillageAgressor villageagressor = null; + + for (int i = 0; i < this.villageAgressors.size(); ++i) + { + Village.VillageAgressor villageagressor1 = (Village.VillageAgressor)this.villageAgressors.get(i); + double d1 = villageagressor1.agressor.getDistanceSqToEntity(par1EntityLivingBase); + + if (d1 <= d0) + { + villageagressor = villageagressor1; + d0 = d1; + } + } + + return villageagressor != null ? villageagressor.agressor : null; + } + + public EntityPlayer func_82685_c(EntityLivingBase par1EntityLivingBase) + { + double d0 = Double.MAX_VALUE; + EntityPlayer entityplayer = null; + Iterator iterator = this.playerReputation.keySet().iterator(); + + while (iterator.hasNext()) + { + String s = (String)iterator.next(); + + if (this.isPlayerReputationTooLow(s)) + { + EntityPlayer entityplayer1 = this.worldObj.getPlayerEntityByName(s); + + if (entityplayer1 != null) + { + double d1 = entityplayer1.getDistanceSqToEntity(par1EntityLivingBase); + + if (d1 <= d0) + { + entityplayer = entityplayer1; + d0 = d1; + } + } + } + } + + return entityplayer; + } + + private void removeDeadAndOldAgressors() + { + Iterator iterator = this.villageAgressors.iterator(); + + while (iterator.hasNext()) + { + Village.VillageAgressor villageagressor = (Village.VillageAgressor)iterator.next(); + + if (!villageagressor.agressor.isEntityAlive() || Math.abs(this.tickCounter - villageagressor.agressionTime) > 300) + { + iterator.remove(); + } + } + } + + private void removeDeadAndOutOfRangeDoors() + { + boolean flag = false; + boolean flag1 = this.worldObj.rand.nextInt(50) == 0; + Iterator iterator = this.villageDoorInfoList.iterator(); + + while (iterator.hasNext()) + { + VillageDoorInfo villagedoorinfo = (VillageDoorInfo)iterator.next(); + + if (flag1) + { + villagedoorinfo.resetDoorOpeningRestrictionCounter(); + } + + if (!this.isBlockDoor(villagedoorinfo.posX, villagedoorinfo.posY, villagedoorinfo.posZ) || Math.abs(this.tickCounter - villagedoorinfo.lastActivityTimestamp) > 1200) + { + this.centerHelper.posX -= villagedoorinfo.posX; + this.centerHelper.posY -= villagedoorinfo.posY; + this.centerHelper.posZ -= villagedoorinfo.posZ; + flag = true; + villagedoorinfo.isDetachedFromVillageFlag = true; + iterator.remove(); + } + } + + if (flag) + { + this.updateVillageRadiusAndCenter(); + } + } + + private boolean isBlockDoor(int par1, int par2, int par3) + { + return this.worldObj.getBlock(par1, par2, par3) == Blocks.wooden_door; + } + + private void updateVillageRadiusAndCenter() + { + int i = this.villageDoorInfoList.size(); + + if (i == 0) + { + this.center.set(0, 0, 0); + this.villageRadius = 0; + } + else + { + this.center.set(this.centerHelper.posX / i, this.centerHelper.posY / i, this.centerHelper.posZ / i); + int j = 0; + VillageDoorInfo villagedoorinfo; + + for (Iterator iterator = this.villageDoorInfoList.iterator(); iterator.hasNext(); j = Math.max(villagedoorinfo.getDistanceSquared(this.center.posX, this.center.posY, this.center.posZ), j)) + { + villagedoorinfo = (VillageDoorInfo)iterator.next(); + } + + this.villageRadius = Math.max(32, (int)Math.sqrt((double)j) + 1); + } + } + + public int getReputationForPlayer(String par1Str) + { + Integer integer = (Integer)this.playerReputation.get(par1Str); + return integer != null ? integer.intValue() : 0; + } + + public int setReputationForPlayer(String par1Str, int par2) + { + int j = this.getReputationForPlayer(par1Str); + int k = MathHelper.clamp_int(j + par2, -30, 10); + this.playerReputation.put(par1Str, Integer.valueOf(k)); + return k; + } + + public boolean isPlayerReputationTooLow(String par1Str) + { + return this.getReputationForPlayer(par1Str) <= -15; + } + + public void readVillageDataFromNBT(NBTTagCompound par1NBTTagCompound) + { + this.numVillagers = par1NBTTagCompound.getInteger("PopSize"); + this.villageRadius = par1NBTTagCompound.getInteger("Radius"); + this.numIronGolems = par1NBTTagCompound.getInteger("Golems"); + this.lastAddDoorTimestamp = par1NBTTagCompound.getInteger("Stable"); + this.tickCounter = par1NBTTagCompound.getInteger("Tick"); + this.noBreedTicks = par1NBTTagCompound.getInteger("MTick"); + this.center.posX = par1NBTTagCompound.getInteger("CX"); + this.center.posY = par1NBTTagCompound.getInteger("CY"); + this.center.posZ = par1NBTTagCompound.getInteger("CZ"); + this.centerHelper.posX = par1NBTTagCompound.getInteger("ACX"); + this.centerHelper.posY = par1NBTTagCompound.getInteger("ACY"); + this.centerHelper.posZ = par1NBTTagCompound.getInteger("ACZ"); + NBTTagList nbttaglist = par1NBTTagCompound.getTagList("Doors", 10); + + for (int i = 0; i < nbttaglist.tagCount(); ++i) + { + NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); + VillageDoorInfo villagedoorinfo = new VillageDoorInfo(nbttagcompound1.getInteger("X"), nbttagcompound1.getInteger("Y"), nbttagcompound1.getInteger("Z"), nbttagcompound1.getInteger("IDX"), nbttagcompound1.getInteger("IDZ"), nbttagcompound1.getInteger("TS")); + this.villageDoorInfoList.add(villagedoorinfo); + } + + NBTTagList nbttaglist1 = par1NBTTagCompound.getTagList("Players", 10); + + for (int j = 0; j < nbttaglist1.tagCount(); ++j) + { + NBTTagCompound nbttagcompound2 = nbttaglist1.getCompoundTagAt(j); + this.playerReputation.put(nbttagcompound2.getString("Name"), Integer.valueOf(nbttagcompound2.getInteger("S"))); + } + } + + public void writeVillageDataToNBT(NBTTagCompound par1NBTTagCompound) + { + par1NBTTagCompound.setInteger("PopSize", this.numVillagers); + par1NBTTagCompound.setInteger("Radius", this.villageRadius); + par1NBTTagCompound.setInteger("Golems", this.numIronGolems); + par1NBTTagCompound.setInteger("Stable", this.lastAddDoorTimestamp); + par1NBTTagCompound.setInteger("Tick", this.tickCounter); + par1NBTTagCompound.setInteger("MTick", this.noBreedTicks); + par1NBTTagCompound.setInteger("CX", this.center.posX); + par1NBTTagCompound.setInteger("CY", this.center.posY); + par1NBTTagCompound.setInteger("CZ", this.center.posZ); + par1NBTTagCompound.setInteger("ACX", this.centerHelper.posX); + par1NBTTagCompound.setInteger("ACY", this.centerHelper.posY); + par1NBTTagCompound.setInteger("ACZ", this.centerHelper.posZ); + NBTTagList nbttaglist = new NBTTagList(); + Iterator iterator = this.villageDoorInfoList.iterator(); + + while (iterator.hasNext()) + { + VillageDoorInfo villagedoorinfo = (VillageDoorInfo)iterator.next(); + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + nbttagcompound1.setInteger("X", villagedoorinfo.posX); + nbttagcompound1.setInteger("Y", villagedoorinfo.posY); + nbttagcompound1.setInteger("Z", villagedoorinfo.posZ); + nbttagcompound1.setInteger("IDX", villagedoorinfo.insideDirectionX); + nbttagcompound1.setInteger("IDZ", villagedoorinfo.insideDirectionZ); + nbttagcompound1.setInteger("TS", villagedoorinfo.lastActivityTimestamp); + nbttaglist.appendTag(nbttagcompound1); + } + + par1NBTTagCompound.setTag("Doors", nbttaglist); + NBTTagList nbttaglist1 = new NBTTagList(); + Iterator iterator1 = this.playerReputation.keySet().iterator(); + + while (iterator1.hasNext()) + { + String s = (String)iterator1.next(); + NBTTagCompound nbttagcompound2 = new NBTTagCompound(); + nbttagcompound2.setString("Name", s); + nbttagcompound2.setInteger("S", ((Integer)this.playerReputation.get(s)).intValue()); + nbttaglist1.appendTag(nbttagcompound2); + } + + par1NBTTagCompound.setTag("Players", nbttaglist1); + } + + public void endMatingSeason() + { + this.noBreedTicks = this.tickCounter; + } + + public boolean isMatingSeason() + { + return this.noBreedTicks == 0 || this.tickCounter - this.noBreedTicks >= 3600; + } + + public void setDefaultPlayerReputation(int par1) + { + Iterator iterator = this.playerReputation.keySet().iterator(); + + while (iterator.hasNext()) + { + String s = (String)iterator.next(); + this.setReputationForPlayer(s, par1); + } + } + + class VillageAgressor + { + public EntityLivingBase agressor; + public int agressionTime; + private static final String __OBFID = "CL_00001632"; + + VillageAgressor(EntityLivingBase par2EntityLivingBase, int par3) + { + this.agressor = par2EntityLivingBase; + this.agressionTime = par3; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/village/VillageCollection.java b/src/main/java/net/minecraft/village/VillageCollection.java new file mode 100644 index 0000000..a476dd4 --- /dev/null +++ b/src/main/java/net/minecraft/village/VillageCollection.java @@ -0,0 +1,353 @@ +package net.minecraft.village; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import net.minecraft.block.BlockDoor; +import net.minecraft.init.Blocks; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.world.World; +import net.minecraft.world.WorldSavedData; + +public class VillageCollection extends WorldSavedData +{ + private World worldObj; + private final List villagerPositionsList = new ArrayList(); + private final List newDoors = new ArrayList(); + private final List villageList = new ArrayList(); + private int tickCounter; + private static final String __OBFID = "CL_00001635"; + + public VillageCollection(String par1Str) + { + super(par1Str); + } + + public VillageCollection(World par1World) + { + super("villages"); + this.worldObj = par1World; + this.markDirty(); + } + + public void func_82566_a(World par1World) + { + this.worldObj = par1World; + Iterator iterator = this.villageList.iterator(); + + while (iterator.hasNext()) + { + Village village = (Village)iterator.next(); + village.func_82691_a(par1World); + } + } + + public void addVillagerPosition(int par1, int par2, int par3) + { + if (this.villagerPositionsList.size() <= 64) + { + if (!this.isVillagerPositionPresent(par1, par2, par3)) + { + this.villagerPositionsList.add(new ChunkCoordinates(par1, par2, par3)); + } + } + } + + public void tick() + { + ++this.tickCounter; + Iterator iterator = this.villageList.iterator(); + + while (iterator.hasNext()) + { + Village village = (Village)iterator.next(); + village.tick(this.tickCounter); + } + + this.removeAnnihilatedVillages(); + this.dropOldestVillagerPosition(); + this.addNewDoorsToVillageOrCreateVillage(); + + if (this.tickCounter % 400 == 0) + { + this.markDirty(); + } + } + + private void removeAnnihilatedVillages() + { + Iterator iterator = this.villageList.iterator(); + + while (iterator.hasNext()) + { + Village village = (Village)iterator.next(); + + if (village.isAnnihilated()) + { + iterator.remove(); + this.markDirty(); + } + } + } + + public List getVillageList() + { + return this.villageList; + } + + public Village findNearestVillage(int par1, int par2, int par3, int par4) + { + Village village = null; + float f = Float.MAX_VALUE; + Iterator iterator = this.villageList.iterator(); + + while (iterator.hasNext()) + { + Village village1 = (Village)iterator.next(); + float f1 = village1.getCenter().getDistanceSquared(par1, par2, par3); + + if (f1 < f) + { + float f2 = (float)(par4 + village1.getVillageRadius()); + + if (f1 <= f2 * f2) + { + village = village1; + f = f1; + } + } + } + + return village; + } + + private void dropOldestVillagerPosition() + { + if (!this.villagerPositionsList.isEmpty()) + { + this.addUnassignedWoodenDoorsAroundToNewDoorsList((ChunkCoordinates)this.villagerPositionsList.remove(0)); + } + } + + private void addNewDoorsToVillageOrCreateVillage() + { + int i = 0; + + while (i < this.newDoors.size()) + { + VillageDoorInfo villagedoorinfo = (VillageDoorInfo)this.newDoors.get(i); + boolean flag = false; + Iterator iterator = this.villageList.iterator(); + + while (true) + { + if (iterator.hasNext()) + { + Village village = (Village)iterator.next(); + int j = (int)village.getCenter().getDistanceSquared(villagedoorinfo.posX, villagedoorinfo.posY, villagedoorinfo.posZ); + float k = 32f + village.getVillageRadius(); //BugFix: Avoid int wrapping + + if (j > k * k) + { + continue; + } + + village.addVillageDoorInfo(villagedoorinfo); + flag = true; + } + + if (!flag) + { + Village village1 = new Village(this.worldObj); + village1.addVillageDoorInfo(villagedoorinfo); + this.villageList.add(village1); + this.markDirty(); + } + + ++i; + break; + } + } + + this.newDoors.clear(); + } + + private void addUnassignedWoodenDoorsAroundToNewDoorsList(ChunkCoordinates par1ChunkCoordinates) + { + byte b0 = 16; + byte b1 = 4; + byte b2 = 16; + + for (int i = par1ChunkCoordinates.posX - b0; i < par1ChunkCoordinates.posX + b0; ++i) + { + for (int j = par1ChunkCoordinates.posY - b1; j < par1ChunkCoordinates.posY + b1; ++j) + { + for (int k = par1ChunkCoordinates.posZ - b2; k < par1ChunkCoordinates.posZ + b2; ++k) + { + if (this.isWoodenDoorAt(i, j, k)) + { + VillageDoorInfo villagedoorinfo = this.getVillageDoorAt(i, j, k); + + if (villagedoorinfo == null) + { + this.addDoorToNewListIfAppropriate(i, j, k); + } + else + { + villagedoorinfo.lastActivityTimestamp = this.tickCounter; + } + } + } + } + } + } + + private VillageDoorInfo getVillageDoorAt(int par1, int par2, int par3) + { + Iterator iterator = this.newDoors.iterator(); + VillageDoorInfo villagedoorinfo; + + do + { + if (!iterator.hasNext()) + { + iterator = this.villageList.iterator(); + VillageDoorInfo villagedoorinfo1; + + do + { + if (!iterator.hasNext()) + { + return null; + } + + Village village = (Village)iterator.next(); + villagedoorinfo1 = village.getVillageDoorAt(par1, par2, par3); + } + while (villagedoorinfo1 == null); + + return villagedoorinfo1; + } + + villagedoorinfo = (VillageDoorInfo)iterator.next(); + } + while (villagedoorinfo.posX != par1 || villagedoorinfo.posZ != par3 || Math.abs(villagedoorinfo.posY - par2) > 1); + + return villagedoorinfo; + } + + private void addDoorToNewListIfAppropriate(int par1, int par2, int par3) + { + int l = ((BlockDoor)Blocks.wooden_door).func_150013_e(this.worldObj, par1, par2, par3); + int i1; + int j1; + + if (l != 0 && l != 2) + { + i1 = 0; + + for (j1 = -5; j1 < 0; ++j1) + { + if (this.worldObj.canBlockSeeTheSky(par1, par2, par3 + j1)) + { + --i1; + } + } + + for (j1 = 1; j1 <= 5; ++j1) + { + if (this.worldObj.canBlockSeeTheSky(par1, par2, par3 + j1)) + { + ++i1; + } + } + + if (i1 != 0) + { + this.newDoors.add(new VillageDoorInfo(par1, par2, par3, 0, i1 > 0 ? -2 : 2, this.tickCounter)); + } + } + else + { + i1 = 0; + + for (j1 = -5; j1 < 0; ++j1) + { + if (this.worldObj.canBlockSeeTheSky(par1 + j1, par2, par3)) + { + --i1; + } + } + + for (j1 = 1; j1 <= 5; ++j1) + { + if (this.worldObj.canBlockSeeTheSky(par1 + j1, par2, par3)) + { + ++i1; + } + } + + if (i1 != 0) + { + this.newDoors.add(new VillageDoorInfo(par1, par2, par3, i1 > 0 ? -2 : 2, 0, this.tickCounter)); + } + } + } + + private boolean isVillagerPositionPresent(int par1, int par2, int par3) + { + Iterator iterator = this.villagerPositionsList.iterator(); + ChunkCoordinates chunkcoordinates; + + do + { + if (!iterator.hasNext()) + { + return false; + } + + chunkcoordinates = (ChunkCoordinates)iterator.next(); + } + while (chunkcoordinates.posX != par1 || chunkcoordinates.posY != par2 || chunkcoordinates.posZ != par3); + + return true; + } + + private boolean isWoodenDoorAt(int par1, int par2, int par3) + { + return this.worldObj.getBlock(par1, par2, par3) == Blocks.wooden_door; + } + + public void readFromNBT(NBTTagCompound par1NBTTagCompound) + { + this.tickCounter = par1NBTTagCompound.getInteger("Tick"); + NBTTagList nbttaglist = par1NBTTagCompound.getTagList("Villages", 10); + + for (int i = 0; i < nbttaglist.tagCount(); ++i) + { + NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); + Village village = new Village(); + village.readVillageDataFromNBT(nbttagcompound1); + this.villageList.add(village); + } + } + + public void writeToNBT(NBTTagCompound par1NBTTagCompound) + { + par1NBTTagCompound.setInteger("Tick", this.tickCounter); + NBTTagList nbttaglist = new NBTTagList(); + Iterator iterator = this.villageList.iterator(); + + while (iterator.hasNext()) + { + Village village = (Village)iterator.next(); + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + village.writeVillageDataToNBT(nbttagcompound1); + nbttaglist.appendTag(nbttagcompound1); + } + + par1NBTTagCompound.setTag("Villages", nbttaglist); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/village/VillageDoorInfo.java b/src/main/java/net/minecraft/village/VillageDoorInfo.java new file mode 100644 index 0000000..a7e16bf --- /dev/null +++ b/src/main/java/net/minecraft/village/VillageDoorInfo.java @@ -0,0 +1,77 @@ +package net.minecraft.village; + +public class VillageDoorInfo +{ + public final int posX; + public final int posY; + public final int posZ; + public final int insideDirectionX; + public final int insideDirectionZ; + public int lastActivityTimestamp; + public boolean isDetachedFromVillageFlag; + private int doorOpeningRestrictionCounter; + private static final String __OBFID = "CL_00001630"; + + public VillageDoorInfo(int par1, int par2, int par3, int par4, int par5, int par6) + { + this.posX = par1; + this.posY = par2; + this.posZ = par3; + this.insideDirectionX = par4; + this.insideDirectionZ = par5; + this.lastActivityTimestamp = par6; + } + + public int getDistanceSquared(int par1, int par2, int par3) + { + int l = par1 - this.posX; + int i1 = par2 - this.posY; + int j1 = par3 - this.posZ; + return l * l + i1 * i1 + j1 * j1; + } + + public int getInsideDistanceSquare(int par1, int par2, int par3) + { + int l = par1 - this.posX - this.insideDirectionX; + int i1 = par2 - this.posY; + int j1 = par3 - this.posZ - this.insideDirectionZ; + return l * l + i1 * i1 + j1 * j1; + } + + public int getInsidePosX() + { + return this.posX + this.insideDirectionX; + } + + public int getInsidePosY() + { + return this.posY; + } + + public int getInsidePosZ() + { + return this.posZ + this.insideDirectionZ; + } + + public boolean isInside(int par1, int par2) + { + int k = par1 - this.posX; + int l = par2 - this.posZ; + return k * this.insideDirectionX + l * this.insideDirectionZ >= 0; + } + + public void resetDoorOpeningRestrictionCounter() + { + this.doorOpeningRestrictionCounter = 0; + } + + public void incrementDoorOpeningRestrictionCounter() + { + ++this.doorOpeningRestrictionCounter; + } + + public int getDoorOpeningRestrictionCounter() + { + return this.doorOpeningRestrictionCounter; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/village/VillageSiege.java b/src/main/java/net/minecraft/village/VillageSiege.java new file mode 100644 index 0000000..3dcdab4 --- /dev/null +++ b/src/main/java/net/minecraft/village/VillageSiege.java @@ -0,0 +1,222 @@ +package net.minecraft.village; + +import java.util.Iterator; +import java.util.List; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.entity.monster.EntityZombie; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; +import net.minecraft.world.SpawnerAnimals; +import net.minecraft.world.World; + +public class VillageSiege +{ + private World worldObj; + private boolean field_75535_b; + private int field_75536_c = -1; + private int field_75533_d; + private int field_75534_e; + private Village theVillage; + private int field_75532_g; + private int field_75538_h; + private int field_75539_i; + private static final String __OBFID = "CL_00001634"; + + public VillageSiege(World par1World) + { + this.worldObj = par1World; + } + + public void tick() + { + boolean flag = false; + + if (flag) + { + if (this.field_75536_c == 2) + { + this.field_75533_d = 100; + return; + } + } + else + { + if (this.worldObj.isDaytime()) + { + this.field_75536_c = 0; + return; + } + + if (this.field_75536_c == 2) + { + return; + } + + if (this.field_75536_c == 0) + { + float f = this.worldObj.getCelestialAngle(0.0F); + + if ((double)f < 0.5D || (double)f > 0.501D) + { + return; + } + + this.field_75536_c = this.worldObj.rand.nextInt(10) == 0 ? 1 : 2; + this.field_75535_b = false; + + if (this.field_75536_c == 2) + { + return; + } + } + } + + if (!this.field_75535_b) + { + if (!this.func_75529_b()) + { + return; + } + + this.field_75535_b = true; + } + + if (this.field_75534_e > 0) + { + --this.field_75534_e; + } + else + { + this.field_75534_e = 2; + + if (this.field_75533_d > 0) + { + this.spawnZombie(); + --this.field_75533_d; + } + else + { + this.field_75536_c = 2; + } + } + } + + private boolean func_75529_b() + { + List list = this.worldObj.playerEntities; + Iterator iterator = list.iterator(); + + while (iterator.hasNext()) + { + EntityPlayer entityplayer = (EntityPlayer)iterator.next(); + this.theVillage = this.worldObj.villageCollectionObj.findNearestVillage((int)entityplayer.posX, (int)entityplayer.posY, (int)entityplayer.posZ, 1); + + if (this.theVillage != null && this.theVillage.getNumVillageDoors() >= 10 && this.theVillage.getTicksSinceLastDoorAdding() >= 20 && this.theVillage.getNumVillagers() >= 20) + { + ChunkCoordinates chunkcoordinates = this.theVillage.getCenter(); + float f = (float)this.theVillage.getVillageRadius(); + boolean flag = false; + int i = 0; + + while (true) + { + if (i < 10) + { + this.field_75532_g = chunkcoordinates.posX + (int)((double)(MathHelper.cos(this.worldObj.rand.nextFloat() * (float)Math.PI * 2.0F) * f) * 0.9D); + this.field_75538_h = chunkcoordinates.posY; + this.field_75539_i = chunkcoordinates.posZ + (int)((double)(MathHelper.sin(this.worldObj.rand.nextFloat() * (float)Math.PI * 2.0F) * f) * 0.9D); + flag = false; + Iterator iterator1 = this.worldObj.villageCollectionObj.getVillageList().iterator(); + + while (iterator1.hasNext()) + { + Village village = (Village)iterator1.next(); + + if (village != this.theVillage && village.isInRange(this.field_75532_g, this.field_75538_h, this.field_75539_i)) + { + flag = true; + break; + } + } + + if (flag) + { + ++i; + continue; + } + } + + if (flag) + { + return false; + } + + Vec3 vec3 = this.func_75527_a(this.field_75532_g, this.field_75538_h, this.field_75539_i); + + if (vec3 != null) + { + this.field_75534_e = 0; + this.field_75533_d = 20; + return true; + } + + break; + } + } + } + + return false; + } + + private boolean spawnZombie() + { + Vec3 vec3 = this.func_75527_a(this.field_75532_g, this.field_75538_h, this.field_75539_i); + + if (vec3 == null) + { + return false; + } + else + { + EntityZombie entityzombie; + + try + { + entityzombie = new EntityZombie(this.worldObj); + entityzombie.onSpawnWithEgg((IEntityLivingData)null); + entityzombie.setVillager(false); + } + catch (Exception exception) + { + exception.printStackTrace(); + return false; + } + + entityzombie.setLocationAndAngles(vec3.xCoord, vec3.yCoord, vec3.zCoord, this.worldObj.rand.nextFloat() * 360.0F, 0.0F); + this.worldObj.spawnEntityInWorld(entityzombie); + ChunkCoordinates chunkcoordinates = this.theVillage.getCenter(); + entityzombie.setHomeArea(chunkcoordinates.posX, chunkcoordinates.posY, chunkcoordinates.posZ, this.theVillage.getVillageRadius()); + return true; + } + } + + private Vec3 func_75527_a(int par1, int par2, int par3) + { + for (int l = 0; l < 10; ++l) + { + int i1 = par1 + this.worldObj.rand.nextInt(16) - 8; + int j1 = par2 + this.worldObj.rand.nextInt(6) - 3; + int k1 = par3 + this.worldObj.rand.nextInt(16) - 8; + + if (this.theVillage.isInRange(i1, j1, k1) && SpawnerAnimals.canCreatureTypeSpawnAtLocation(EnumCreatureType.monster, this.worldObj, i1, j1, k1)) + { + this.worldObj.getWorldVec3Pool().getVecFromPool((double)i1, (double)j1, (double)k1); + } + } + + return null; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/ChunkCache.java b/src/main/java/net/minecraft/world/ChunkCache.java new file mode 100644 index 0000000..213858b --- /dev/null +++ b/src/main/java/net/minecraft/world/ChunkCache.java @@ -0,0 +1,265 @@ +package net.minecraft.world; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.Vec3Pool; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.chunk.Chunk; +import net.minecraftforge.common.util.ForgeDirection; + +public class ChunkCache implements IBlockAccess +{ + private int chunkX; + private int chunkZ; + private Chunk[][] chunkArray; + private boolean isEmpty; + private World worldObj; + private static final String __OBFID = "CL_00000155"; + + public ChunkCache(World par1World, int par2, int par3, int par4, int par5, int par6, int par7, int par8) + { + this.worldObj = par1World; + this.chunkX = par2 - par8 >> 4; + this.chunkZ = par4 - par8 >> 4; + int l1 = par5 + par8 >> 4; + int i2 = par7 + par8 >> 4; + this.chunkArray = new Chunk[l1 - this.chunkX + 1][i2 - this.chunkZ + 1]; + this.isEmpty = true; + int j2; + int k2; + Chunk chunk; + + for (j2 = this.chunkX; j2 <= l1; ++j2) + { + for (k2 = this.chunkZ; k2 <= i2; ++k2) + { + chunk = par1World.getChunkFromChunkCoords(j2, k2); + + if (chunk != null) + { + this.chunkArray[j2 - this.chunkX][k2 - this.chunkZ] = chunk; + } + } + } + + for (j2 = par2 >> 4; j2 <= par5 >> 4; ++j2) + { + for (k2 = par4 >> 4; k2 <= par7 >> 4; ++k2) + { + chunk = this.chunkArray[j2 - this.chunkX][k2 - this.chunkZ]; + + if (chunk != null && !chunk.getAreLevelsEmpty(par3, par6)) + { + this.isEmpty = false; + } + } + } + } + + @SideOnly(Side.CLIENT) + public boolean extendedLevelsInChunkCache() + { + return this.isEmpty; + } + + public Block getBlock(int p_147439_1_, int p_147439_2_, int p_147439_3_) + { + Block block = Blocks.air; + + if (p_147439_2_ >= 0 && p_147439_2_ < 256) + { + int l = (p_147439_1_ >> 4) - this.chunkX; + int i1 = (p_147439_3_ >> 4) - this.chunkZ; + + if (l >= 0 && l < this.chunkArray.length && i1 >= 0 && i1 < this.chunkArray[l].length) + { + Chunk chunk = this.chunkArray[l][i1]; + + if (chunk != null) + { + block = chunk.getBlock(p_147439_1_ & 15, p_147439_2_, p_147439_3_ & 15); + } + } + } + + return block; + } + + public TileEntity getTileEntity(int p_147438_1_, int p_147438_2_, int p_147438_3_) + { + int l = (p_147438_1_ >> 4) - this.chunkX; + int i1 = (p_147438_3_ >> 4) - this.chunkZ; + if (l < 0 || l >= chunkArray.length || i1 < 0 || i1 >= chunkArray[l].length) return null; + if (chunkArray[l][i1] == null) return null; + return this.chunkArray[l][i1].func_150806_e(p_147438_1_ & 15, p_147438_2_, p_147438_3_ & 15); + } + + @SideOnly(Side.CLIENT) + public int getLightBrightnessForSkyBlocks(int par1, int par2, int par3, int par4) + { + int i1 = this.getSkyBlockTypeBrightness(EnumSkyBlock.Sky, par1, par2, par3); + int j1 = this.getSkyBlockTypeBrightness(EnumSkyBlock.Block, par1, par2, par3); + + if (j1 < par4) + { + j1 = par4; + } + + return i1 << 20 | j1 << 4; + } + + public int getBlockMetadata(int par1, int par2, int par3) + { + if (par2 < 0) + { + return 0; + } + else if (par2 >= 256) + { + return 0; + } + else + { + int l = (par1 >> 4) - this.chunkX; + int i1 = (par3 >> 4) - this.chunkZ; + if (l < 0 || l >= chunkArray.length || i1 < 0 || i1 >= chunkArray[l].length) return 0; + if (chunkArray[l][i1] == null) return 0; + return this.chunkArray[l][i1].getBlockMetadata(par1 & 15, par2, par3 & 15); + } + } + + @SideOnly(Side.CLIENT) + public BiomeGenBase getBiomeGenForCoords(int par1, int par2) + { + return this.worldObj.getBiomeGenForCoords(par1, par2); + } + + public Vec3Pool getWorldVec3Pool() + { + return this.worldObj.getWorldVec3Pool(); + } + + public boolean isAirBlock(int p_147437_1_, int p_147437_2_, int p_147437_3_) + { + return this.getBlock(p_147437_1_, p_147437_2_, p_147437_3_).isAir(this, p_147437_1_, p_147437_2_, p_147437_3_); + } + + @SideOnly(Side.CLIENT) + public int getSkyBlockTypeBrightness(EnumSkyBlock par1EnumSkyBlock, int par2, int par3, int par4) + { + if (par3 < 0) + { + par3 = 0; + } + + if (par3 >= 256) + { + par3 = 255; + } + + if (par3 >= 0 && par3 < 256 && par2 >= -30000000 && par4 >= -30000000 && par2 < 30000000 && par4 <= 30000000) + { + if (par1EnumSkyBlock == EnumSkyBlock.Sky && this.worldObj.provider.hasNoSky) + { + return 0; + } + else + { + int l; + int i1; + + if (this.getBlock(par2, par3, par4).getUseNeighborBrightness()) + { + l = this.getSpecialBlockBrightness(par1EnumSkyBlock, par2, par3 + 1, par4); + i1 = this.getSpecialBlockBrightness(par1EnumSkyBlock, par2 + 1, par3, par4); + int j1 = this.getSpecialBlockBrightness(par1EnumSkyBlock, par2 - 1, par3, par4); + int k1 = this.getSpecialBlockBrightness(par1EnumSkyBlock, par2, par3, par4 + 1); + int l1 = this.getSpecialBlockBrightness(par1EnumSkyBlock, par2, par3, par4 - 1); + + if (i1 > l) + { + l = i1; + } + + if (j1 > l) + { + l = j1; + } + + if (k1 > l) + { + l = k1; + } + + if (l1 > l) + { + l = l1; + } + + return l; + } + else + { + l = (par2 >> 4) - this.chunkX; + i1 = (par4 >> 4) - this.chunkZ; + return this.chunkArray[l][i1].getSavedLightValue(par1EnumSkyBlock, par2 & 15, par3, par4 & 15); + } + } + } + else + { + return par1EnumSkyBlock.defaultLightValue; + } + } + + @SideOnly(Side.CLIENT) + public int getSpecialBlockBrightness(EnumSkyBlock par1EnumSkyBlock, int par2, int par3, int par4) + { + if (par3 < 0) + { + par3 = 0; + } + + if (par3 >= 256) + { + par3 = 255; + } + + if (par3 >= 0 && par3 < 256 && par2 >= -30000000 && par4 >= -30000000 && par2 < 30000000 && par4 <= 30000000) + { + int l = (par2 >> 4) - this.chunkX; + int i1 = (par4 >> 4) - this.chunkZ; + return this.chunkArray[l][i1].getSavedLightValue(par1EnumSkyBlock, par2 & 15, par3, par4 & 15); + } + else + { + return par1EnumSkyBlock.defaultLightValue; + } + } + + @SideOnly(Side.CLIENT) + public int getHeight() + { + return 256; + } + + public int isBlockProvidingPowerTo(int par1, int par2, int par3, int par4) + { + return this.getBlock(par1, par2, par3).isProvidingStrongPower(this, par1, par2, par3, par4); + } + + @Override + public boolean isSideSolid(int x, int y, int z, ForgeDirection side, boolean _default) + { + if (x < -30000000 || z < -30000000 || x >= 30000000 || z >= 30000000) + { + return _default; + } + + return getBlock(x, y, z).isSideSolid(this, x, y, z, side); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/ChunkCoordIntPair.java b/src/main/java/net/minecraft/world/ChunkCoordIntPair.java new file mode 100644 index 0000000..8e457ff --- /dev/null +++ b/src/main/java/net/minecraft/world/ChunkCoordIntPair.java @@ -0,0 +1,53 @@ +package net.minecraft.world; + +public class ChunkCoordIntPair +{ + public final int chunkXPos; + public final int chunkZPos; + private static final String __OBFID = "CL_00000133"; + + public ChunkCoordIntPair(int par1, int par2) + { + this.chunkXPos = par1; + this.chunkZPos = par2; + } + + public static long chunkXZ2Int(int par0, int par1) + { + return (long)par0 & 4294967295L | ((long)par1 & 4294967295L) << 32; + } + + public int hashCode() + { + long i = chunkXZ2Int(this.chunkXPos, this.chunkZPos); + int j = (int)i; + int k = (int)(i >> 32); + return j ^ k; + } + + public boolean equals(Object par1Obj) + { + ChunkCoordIntPair chunkcoordintpair = (ChunkCoordIntPair)par1Obj; + return chunkcoordintpair.chunkXPos == this.chunkXPos && chunkcoordintpair.chunkZPos == this.chunkZPos; + } + + public int getCenterXPos() + { + return (this.chunkXPos << 4) + 8; + } + + public int getCenterZPosition() + { + return (this.chunkZPos << 4) + 8; + } + + public ChunkPosition func_151349_a(int p_151349_1_) + { + return new ChunkPosition(this.getCenterXPos(), p_151349_1_, this.getCenterZPosition()); + } + + public String toString() + { + return "[" + this.chunkXPos + ", " + this.chunkZPos + "]"; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/ChunkPosition.java b/src/main/java/net/minecraft/world/ChunkPosition.java new file mode 100644 index 0000000..8f26aa9 --- /dev/null +++ b/src/main/java/net/minecraft/world/ChunkPosition.java @@ -0,0 +1,42 @@ +package net.minecraft.world; + +import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; + +public class ChunkPosition +{ + public final int chunkPosX; + public final int chunkPosY; + public final int chunkPosZ; + private static final String __OBFID = "CL_00000132"; + + public ChunkPosition(int p_i45363_1_, int p_i45363_2_, int p_i45363_3_) + { + this.chunkPosX = p_i45363_1_; + this.chunkPosY = p_i45363_2_; + this.chunkPosZ = p_i45363_3_; + } + + public ChunkPosition(Vec3 p_i45364_1_) + { + this(MathHelper.floor_double(p_i45364_1_.xCoord), MathHelper.floor_double(p_i45364_1_.yCoord), MathHelper.floor_double(p_i45364_1_.zCoord)); + } + + public boolean equals(Object par1Obj) + { + if (!(par1Obj instanceof ChunkPosition)) + { + return false; + } + else + { + ChunkPosition chunkposition = (ChunkPosition)par1Obj; + return chunkposition.chunkPosX == this.chunkPosX && chunkposition.chunkPosY == this.chunkPosY && chunkposition.chunkPosZ == this.chunkPosZ; + } + } + + public int hashCode() + { + return this.chunkPosX * 8976890 + this.chunkPosY * 981131 + this.chunkPosZ; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/ColorizerFoliage.java b/src/main/java/net/minecraft/world/ColorizerFoliage.java new file mode 100644 index 0000000..ce3d5a8 --- /dev/null +++ b/src/main/java/net/minecraft/world/ColorizerFoliage.java @@ -0,0 +1,39 @@ +package net.minecraft.world; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class ColorizerFoliage +{ + private static int[] foliageBuffer = new int[65536]; + private static final String __OBFID = "CL_00000135"; + + public static void setFoliageBiomeColorizer(int[] par0ArrayOfInteger) + { + foliageBuffer = par0ArrayOfInteger; + } + + public static int getFoliageColor(double par0, double par2) + { + par2 *= par0; + int i = (int)((1.0D - par0) * 255.0D); + int j = (int)((1.0D - par2) * 255.0D); + return foliageBuffer[j << 8 | i]; + } + + public static int getFoliageColorPine() + { + return 6396257; + } + + public static int getFoliageColorBirch() + { + return 8431445; + } + + public static int getFoliageColorBasic() + { + return 4764952; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/ColorizerGrass.java b/src/main/java/net/minecraft/world/ColorizerGrass.java new file mode 100644 index 0000000..9565f64 --- /dev/null +++ b/src/main/java/net/minecraft/world/ColorizerGrass.java @@ -0,0 +1,24 @@ +package net.minecraft.world; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class ColorizerGrass +{ + private static int[] grassBuffer = new int[65536]; + private static final String __OBFID = "CL_00000138"; + + public static void setGrassBiomeColorizer(int[] par0ArrayOfInteger) + { + grassBuffer = par0ArrayOfInteger; + } + + public static int getGrassColor(double par0, double par2) + { + par2 *= par0; + int i = (int)((1.0D - par0) * 255.0D); + int j = (int)((1.0D - par2) * 255.0D); + return grassBuffer[j << 8 | i]; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/EnumDifficulty.java b/src/main/java/net/minecraft/world/EnumDifficulty.java new file mode 100644 index 0000000..5248c00 --- /dev/null +++ b/src/main/java/net/minecraft/world/EnumDifficulty.java @@ -0,0 +1,47 @@ +package net.minecraft.world; + +public enum EnumDifficulty +{ + PEACEFUL(0, "options.difficulty.peaceful"), + EASY(1, "options.difficulty.easy"), + NORMAL(2, "options.difficulty.normal"), + HARD(3, "options.difficulty.hard"); + private static final EnumDifficulty[] difficultyEnums = new EnumDifficulty[values().length]; + private final int difficultyId; + private final String difficultyResourceKey; + + private static final String __OBFID = "CL_00001510"; + + private EnumDifficulty(int p_i45312_3_, String p_i45312_4_) + { + this.difficultyId = p_i45312_3_; + this.difficultyResourceKey = p_i45312_4_; + } + + public int getDifficultyId() + { + return this.difficultyId; + } + + public static EnumDifficulty getDifficultyEnum(int p_151523_0_) + { + return difficultyEnums[p_151523_0_ % difficultyEnums.length]; + } + + public String getDifficultyResourceKey() + { + return this.difficultyResourceKey; + } + + static + { + EnumDifficulty[] var0 = values(); + int var1 = var0.length; + + for (int var2 = 0; var2 < var1; ++var2) + { + EnumDifficulty var3 = var0[var2]; + difficultyEnums[var3.difficultyId] = var3; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/EnumSkyBlock.java b/src/main/java/net/minecraft/world/EnumSkyBlock.java new file mode 100644 index 0000000..c5584cc --- /dev/null +++ b/src/main/java/net/minecraft/world/EnumSkyBlock.java @@ -0,0 +1,15 @@ +package net.minecraft.world; + +public enum EnumSkyBlock +{ + Sky(15), + Block(0); + public final int defaultLightValue; + + private static final String __OBFID = "CL_00000151"; + + private EnumSkyBlock(int par3) + { + this.defaultLightValue = par3; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/Explosion.java b/src/main/java/net/minecraft/world/Explosion.java new file mode 100644 index 0000000..fee2639 --- /dev/null +++ b/src/main/java/net/minecraft/world/Explosion.java @@ -0,0 +1,249 @@ +package net.minecraft.world; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.enchantment.EnchantmentProtection; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityTNTPrimed; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; + +public class Explosion +{ + public boolean isFlaming; + public boolean isSmoking = true; + private int field_77289_h = 16; + private Random explosionRNG = new Random(); + private World worldObj; + public double explosionX; + public double explosionY; + public double explosionZ; + public Entity exploder; + public float explosionSize; + public List affectedBlockPositions = new ArrayList(); + private Map field_77288_k = new HashMap(); + private static final String __OBFID = "CL_00000134"; + + public Explosion(World par1World, Entity par2Entity, double par3, double par5, double par7, float par9) + { + this.worldObj = par1World; + this.exploder = par2Entity; + this.explosionSize = par9; + this.explosionX = par3; + this.explosionY = par5; + this.explosionZ = par7; + } + + public void doExplosionA() + { + float f = this.explosionSize; + HashSet hashset = new HashSet(); + int i; + int j; + int k; + double d5; + double d6; + double d7; + + for (i = 0; i < this.field_77289_h; ++i) + { + for (j = 0; j < this.field_77289_h; ++j) + { + for (k = 0; k < this.field_77289_h; ++k) + { + if (i == 0 || i == this.field_77289_h - 1 || j == 0 || j == this.field_77289_h - 1 || k == 0 || k == this.field_77289_h - 1) + { + double d0 = (double)((float)i / ((float)this.field_77289_h - 1.0F) * 2.0F - 1.0F); + double d1 = (double)((float)j / ((float)this.field_77289_h - 1.0F) * 2.0F - 1.0F); + double d2 = (double)((float)k / ((float)this.field_77289_h - 1.0F) * 2.0F - 1.0F); + double d3 = Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2); + d0 /= d3; + d1 /= d3; + d2 /= d3; + float f1 = this.explosionSize * (0.7F + this.worldObj.rand.nextFloat() * 0.6F); + d5 = this.explosionX; + d6 = this.explosionY; + d7 = this.explosionZ; + + for (float f2 = 0.3F; f1 > 0.0F; f1 -= f2 * 0.75F) + { + int j1 = MathHelper.floor_double(d5); + int k1 = MathHelper.floor_double(d6); + int l1 = MathHelper.floor_double(d7); + Block block = this.worldObj.getBlock(j1, k1, l1); + + if (block.getMaterial() != Material.air) + { + float f3 = this.exploder != null ? this.exploder.func_145772_a(this, this.worldObj, j1, k1, l1, block) : block.getExplosionResistance(this.exploder, worldObj, j1, k1, l1, explosionX, explosionY, explosionZ); + f1 -= (f3 + 0.3F) * f2; + } + + if (f1 > 0.0F && (this.exploder == null || this.exploder.func_145774_a(this, this.worldObj, j1, k1, l1, block, f1))) + { + hashset.add(new ChunkPosition(j1, k1, l1)); + } + + d5 += d0 * (double)f2; + d6 += d1 * (double)f2; + d7 += d2 * (double)f2; + } + } + } + } + } + + this.affectedBlockPositions.addAll(hashset); + this.explosionSize *= 2.0F; + i = MathHelper.floor_double(this.explosionX - (double)this.explosionSize - 1.0D); + j = MathHelper.floor_double(this.explosionX + (double)this.explosionSize + 1.0D); + k = MathHelper.floor_double(this.explosionY - (double)this.explosionSize - 1.0D); + int i2 = MathHelper.floor_double(this.explosionY + (double)this.explosionSize + 1.0D); + int l = MathHelper.floor_double(this.explosionZ - (double)this.explosionSize - 1.0D); + int j2 = MathHelper.floor_double(this.explosionZ + (double)this.explosionSize + 1.0D); + List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this.exploder, AxisAlignedBB.getAABBPool().getAABB((double)i, (double)k, (double)l, (double)j, (double)i2, (double)j2)); + Vec3 vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.explosionX, this.explosionY, this.explosionZ); + + for (int i1 = 0; i1 < list.size(); ++i1) + { + Entity entity = (Entity)list.get(i1); + double d4 = entity.getDistance(this.explosionX, this.explosionY, this.explosionZ) / (double)this.explosionSize; + + if (d4 <= 1.0D) + { + d5 = entity.posX - this.explosionX; + d6 = entity.posY + (double)entity.getEyeHeight() - this.explosionY; + d7 = entity.posZ - this.explosionZ; + double d9 = (double)MathHelper.sqrt_double(d5 * d5 + d6 * d6 + d7 * d7); + + if (d9 != 0.0D) + { + d5 /= d9; + d6 /= d9; + d7 /= d9; + double d10 = (double)this.worldObj.getBlockDensity(vec3, entity.boundingBox); + double d11 = (1.0D - d4) * d10; + entity.attackEntityFrom(DamageSource.setExplosionSource(this), (float)((int)((d11 * d11 + d11) / 2.0D * 8.0D * (double)this.explosionSize + 1.0D))); + double d8 = EnchantmentProtection.func_92092_a(entity, d11); + entity.motionX += d5 * d8; + entity.motionY += d6 * d8; + entity.motionZ += d7 * d8; + + if (entity instanceof EntityPlayer) + { + this.field_77288_k.put((EntityPlayer)entity, this.worldObj.getWorldVec3Pool().getVecFromPool(d5 * d11, d6 * d11, d7 * d11)); + } + } + } + } + + this.explosionSize = f; + } + + public void doExplosionB(boolean par1) + { + this.worldObj.playSoundEffect(this.explosionX, this.explosionY, this.explosionZ, "random.explode", 4.0F, (1.0F + (this.worldObj.rand.nextFloat() - this.worldObj.rand.nextFloat()) * 0.2F) * 0.7F); + + if (this.explosionSize >= 2.0F && this.isSmoking) + { + this.worldObj.spawnParticle("hugeexplosion", this.explosionX, this.explosionY, this.explosionZ, 1.0D, 0.0D, 0.0D); + } + else + { + this.worldObj.spawnParticle("largeexplode", this.explosionX, this.explosionY, this.explosionZ, 1.0D, 0.0D, 0.0D); + } + + Iterator iterator; + ChunkPosition chunkposition; + int i; + int j; + int k; + Block block; + + if (this.isSmoking) + { + iterator = this.affectedBlockPositions.iterator(); + + while (iterator.hasNext()) + { + chunkposition = (ChunkPosition)iterator.next(); + i = chunkposition.chunkPosX; + j = chunkposition.chunkPosY; + k = chunkposition.chunkPosZ; + block = this.worldObj.getBlock(i, j, k); + + if (par1) + { + double d0 = (double)((float)i + this.worldObj.rand.nextFloat()); + double d1 = (double)((float)j + this.worldObj.rand.nextFloat()); + double d2 = (double)((float)k + this.worldObj.rand.nextFloat()); + double d3 = d0 - this.explosionX; + double d4 = d1 - this.explosionY; + double d5 = d2 - this.explosionZ; + double d6 = (double)MathHelper.sqrt_double(d3 * d3 + d4 * d4 + d5 * d5); + d3 /= d6; + d4 /= d6; + d5 /= d6; + double d7 = 0.5D / (d6 / (double)this.explosionSize + 0.1D); + d7 *= (double)(this.worldObj.rand.nextFloat() * this.worldObj.rand.nextFloat() + 0.3F); + d3 *= d7; + d4 *= d7; + d5 *= d7; + this.worldObj.spawnParticle("explode", (d0 + this.explosionX * 1.0D) / 2.0D, (d1 + this.explosionY * 1.0D) / 2.0D, (d2 + this.explosionZ * 1.0D) / 2.0D, d3, d4, d5); + this.worldObj.spawnParticle("smoke", d0, d1, d2, d3, d4, d5); + } + + if (block.getMaterial() != Material.air) + { + if (block.canDropFromExplosion(this)) + { + block.dropBlockAsItemWithChance(this.worldObj, i, j, k, this.worldObj.getBlockMetadata(i, j, k), 1.0F / this.explosionSize, 0); + } + + block.onBlockExploded(this.worldObj, i, j, k, this); + } + } + } + + if (this.isFlaming) + { + iterator = this.affectedBlockPositions.iterator(); + + while (iterator.hasNext()) + { + chunkposition = (ChunkPosition)iterator.next(); + i = chunkposition.chunkPosX; + j = chunkposition.chunkPosY; + k = chunkposition.chunkPosZ; + block = this.worldObj.getBlock(i, j, k); + Block block1 = this.worldObj.getBlock(i, j - 1, k); + + if (block.getMaterial() == Material.air && block1.func_149730_j() && this.explosionRNG.nextInt(3) == 0) + { + this.worldObj.setBlock(i, j, k, Blocks.fire); + } + } + } + } + + public Map func_77277_b() + { + return this.field_77288_k; + } + + public EntityLivingBase getExplosivePlacedBy() + { + return this.exploder == null ? null : (this.exploder instanceof EntityTNTPrimed ? ((EntityTNTPrimed)this.exploder).getTntPlacedBy() : (this.exploder instanceof EntityLivingBase ? (EntityLivingBase)this.exploder : null)); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/GameRules.java b/src/main/java/net/minecraft/world/GameRules.java new file mode 100644 index 0000000..cddbb93 --- /dev/null +++ b/src/main/java/net/minecraft/world/GameRules.java @@ -0,0 +1,142 @@ +package net.minecraft.world; + +import java.util.Iterator; +import java.util.Set; +import java.util.TreeMap; +import net.minecraft.nbt.NBTTagCompound; + +public class GameRules +{ + private TreeMap theGameRules = new TreeMap(); + private static final String __OBFID = "CL_00000136"; + + public GameRules() + { + this.addGameRule("doFireTick", "true"); + this.addGameRule("mobGriefing", "true"); + this.addGameRule("keepInventory", "false"); + this.addGameRule("doMobSpawning", "true"); + this.addGameRule("doMobLoot", "true"); + this.addGameRule("doTileDrops", "true"); + this.addGameRule("commandBlockOutput", "true"); + this.addGameRule("naturalRegeneration", "true"); + this.addGameRule("doDaylightCycle", "true"); + } + + public void addGameRule(String par1Str, String par2Str) + { + this.theGameRules.put(par1Str, new GameRules.Value(par2Str)); + } + + public void setOrCreateGameRule(String par1Str, String par2Str) + { + GameRules.Value value = (GameRules.Value)this.theGameRules.get(par1Str); + + if (value != null) + { + value.setValue(par2Str); + } + else + { + this.addGameRule(par1Str, par2Str); + } + } + + public String getGameRuleStringValue(String par1Str) + { + GameRules.Value value = (GameRules.Value)this.theGameRules.get(par1Str); + return value != null ? value.getGameRuleStringValue() : ""; + } + + public boolean getGameRuleBooleanValue(String par1Str) + { + GameRules.Value value = (GameRules.Value)this.theGameRules.get(par1Str); + return value != null ? value.getGameRuleBooleanValue() : false; + } + + public NBTTagCompound writeGameRulesToNBT() + { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + Iterator iterator = this.theGameRules.keySet().iterator(); + + while (iterator.hasNext()) + { + String s = (String)iterator.next(); + GameRules.Value value = (GameRules.Value)this.theGameRules.get(s); + nbttagcompound.setString(s, value.getGameRuleStringValue()); + } + + return nbttagcompound; + } + + public void readGameRulesFromNBT(NBTTagCompound par1NBTTagCompound) + { + Set set = par1NBTTagCompound.func_150296_c(); + Iterator iterator = set.iterator(); + + while (iterator.hasNext()) + { + String s = (String)iterator.next(); + String s1 = par1NBTTagCompound.getString(s); + this.setOrCreateGameRule(s, s1); + } + } + + public String[] getRules() + { + return (String[])this.theGameRules.keySet().toArray(new String[0]); + } + + public boolean hasRule(String par1Str) + { + return this.theGameRules.containsKey(par1Str); + } + + static class Value + { + private String valueString; + private boolean valueBoolean; + private int valueInteger; + private double valueDouble; + private static final String __OBFID = "CL_00000137"; + + public Value(String par1Str) + { + this.setValue(par1Str); + } + + public void setValue(String par1Str) + { + this.valueString = par1Str; + this.valueBoolean = Boolean.parseBoolean(par1Str); + + try + { + this.valueInteger = Integer.parseInt(par1Str); + } + catch (NumberFormatException numberformatexception1) + { + ; + } + + try + { + this.valueDouble = Double.parseDouble(par1Str); + } + catch (NumberFormatException numberformatexception) + { + ; + } + } + + public String getGameRuleStringValue() + { + return this.valueString; + } + + public boolean getGameRuleBooleanValue() + { + return this.valueBoolean; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/IBlockAccess.java b/src/main/java/net/minecraft/world/IBlockAccess.java new file mode 100644 index 0000000..e867168 --- /dev/null +++ b/src/main/java/net/minecraft/world/IBlockAccess.java @@ -0,0 +1,48 @@ +package net.minecraft.world; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.Vec3Pool; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraftforge.common.util.ForgeDirection; + +public interface IBlockAccess +{ + Block getBlock(int var1, int var2, int var3); + + TileEntity getTileEntity(int var1, int var2, int var3); + + @SideOnly(Side.CLIENT) + int getLightBrightnessForSkyBlocks(int var1, int var2, int var3, int var4); + + int getBlockMetadata(int var1, int var2, int var3); + + boolean isAirBlock(int var1, int var2, int var3); + + @SideOnly(Side.CLIENT) + BiomeGenBase getBiomeGenForCoords(int var1, int var2); + + @SideOnly(Side.CLIENT) + int getHeight(); + + @SideOnly(Side.CLIENT) + boolean extendedLevelsInChunkCache(); + + Vec3Pool getWorldVec3Pool(); + + int isBlockProvidingPowerTo(int var1, int var2, int var3, int var4); + + /** + * FORGE: isSideSolid, pulled up from {@link World} + * + * @param x X coord + * @param y Y coord + * @param z Z coord + * @param side Side + * @param _default default return value + * @return if the block is solid on the side + */ + boolean isSideSolid(int x, int y, int z, ForgeDirection side, boolean _default); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/IWorldAccess.java b/src/main/java/net/minecraft/world/IWorldAccess.java new file mode 100644 index 0000000..be861d0 --- /dev/null +++ b/src/main/java/net/minecraft/world/IWorldAccess.java @@ -0,0 +1,33 @@ +package net.minecraft.world; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; + +public interface IWorldAccess +{ + void markBlockForUpdate(int var1, int var2, int var3); + + void markBlockForRenderUpdate(int var1, int var2, int var3); + + void markBlockRangeForRenderUpdate(int var1, int var2, int var3, int var4, int var5, int var6); + + void playSound(String var1, double var2, double var4, double var6, float var8, float var9); + + void playSoundToNearExcept(EntityPlayer var1, String var2, double var3, double var5, double var7, float var9, float var10); + + void spawnParticle(String var1, double var2, double var4, double var6, double var8, double var10, double var12); + + void onEntityCreate(Entity var1); + + void onEntityDestroy(Entity var1); + + void playRecord(String var1, int var2, int var3, int var4); + + void broadcastSound(int var1, int var2, int var3, int var4, int var5); + + void playAuxSFX(EntityPlayer var1, int var2, int var3, int var4, int var5, int var6); + + void destroyBlockPartially(int var1, int var2, int var3, int var4, int var5); + + void onStaticEntitiesChanged(); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/MinecraftException.java b/src/main/java/net/minecraft/world/MinecraftException.java new file mode 100644 index 0000000..8f64dbe --- /dev/null +++ b/src/main/java/net/minecraft/world/MinecraftException.java @@ -0,0 +1,11 @@ +package net.minecraft.world; + +public class MinecraftException extends Exception +{ + private static final String __OBFID = "CL_00000145"; + + public MinecraftException(String par1Str) + { + super(par1Str); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/NextTickListEntry.java b/src/main/java/net/minecraft/world/NextTickListEntry.java new file mode 100644 index 0000000..952d2a6 --- /dev/null +++ b/src/main/java/net/minecraft/world/NextTickListEntry.java @@ -0,0 +1,74 @@ +package net.minecraft.world; + +import net.minecraft.block.Block; + +public class NextTickListEntry implements Comparable +{ + private static long nextTickEntryID; + private final Block field_151352_g; + public int xCoord; + public int yCoord; + public int zCoord; + public long scheduledTime; + public int priority; + private long tickEntryID; + private static final String __OBFID = "CL_00000156"; + + public NextTickListEntry(int p_i45370_1_, int p_i45370_2_, int p_i45370_3_, Block p_i45370_4_) + { + this.tickEntryID = (long)(nextTickEntryID++); + this.xCoord = p_i45370_1_; + this.yCoord = p_i45370_2_; + this.zCoord = p_i45370_3_; + this.field_151352_g = p_i45370_4_; + } + + public boolean equals(Object par1Obj) + { + if (!(par1Obj instanceof NextTickListEntry)) + { + return false; + } + else + { + NextTickListEntry nextticklistentry = (NextTickListEntry)par1Obj; + return this.xCoord == nextticklistentry.xCoord && this.yCoord == nextticklistentry.yCoord && this.zCoord == nextticklistentry.zCoord && Block.isEqualTo(this.field_151352_g, nextticklistentry.field_151352_g); + } + } + + public int hashCode() + { + return (this.xCoord * 1024 * 1024 + this.zCoord * 1024 + this.yCoord) * 256; + } + + public NextTickListEntry setScheduledTime(long par1) + { + this.scheduledTime = par1; + return this; + } + + public void setPriority(int par1) + { + this.priority = par1; + } + + public int compareTo(NextTickListEntry par1NextTickListEntry) + { + return this.scheduledTime < par1NextTickListEntry.scheduledTime ? -1 : (this.scheduledTime > par1NextTickListEntry.scheduledTime ? 1 : (this.priority != par1NextTickListEntry.priority ? this.priority - par1NextTickListEntry.priority : (this.tickEntryID < par1NextTickListEntry.tickEntryID ? -1 : (this.tickEntryID > par1NextTickListEntry.tickEntryID ? 1 : 0)))); + } + + public String toString() + { + return Block.getIdFromBlock(this.field_151352_g) + ": (" + this.xCoord + ", " + this.yCoord + ", " + this.zCoord + "), " + this.scheduledTime + ", " + this.priority + ", " + this.tickEntryID; + } + + public Block func_151351_a() + { + return this.field_151352_g; + } + + public int compareTo(Object par1Obj) + { + return this.compareTo((NextTickListEntry)par1Obj); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/SpawnerAnimals.java b/src/main/java/net/minecraft/world/SpawnerAnimals.java new file mode 100644 index 0000000..0742e5a --- /dev/null +++ b/src/main/java/net/minecraft/world/SpawnerAnimals.java @@ -0,0 +1,285 @@ +package net.minecraft.world; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.MathHelper; +import net.minecraft.util.WeightedRandom; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.chunk.Chunk; + +import cpw.mods.fml.common.eventhandler.Event.Result; +import net.minecraftforge.event.ForgeEventFactory; + +public final class SpawnerAnimals +{ + private HashMap eligibleChunksForSpawning = new HashMap(); + private static final String __OBFID = "CL_00000152"; + + protected static ChunkPosition func_151350_a(World p_151350_0_, int p_151350_1_, int p_151350_2_) + { + Chunk chunk = p_151350_0_.getChunkFromChunkCoords(p_151350_1_, p_151350_2_); + int k = p_151350_1_ * 16 + p_151350_0_.rand.nextInt(16); + int l = p_151350_2_ * 16 + p_151350_0_.rand.nextInt(16); + int i1 = p_151350_0_.rand.nextInt(chunk == null ? p_151350_0_.getActualHeight() : chunk.getTopFilledSegment() + 16 - 1); + return new ChunkPosition(k, i1, l); + } + + public int findChunksForSpawning(WorldServer par1WorldServer, boolean par2, boolean par3, boolean par4) + { + if (!par2 && !par3) + { + return 0; + } + else + { + this.eligibleChunksForSpawning.clear(); + int i; + int k; + + for (i = 0; i < par1WorldServer.playerEntities.size(); ++i) + { + EntityPlayer entityplayer = (EntityPlayer)par1WorldServer.playerEntities.get(i); + int j = MathHelper.floor_double(entityplayer.posX / 16.0D); + k = MathHelper.floor_double(entityplayer.posZ / 16.0D); + byte b0 = 8; + + for (int l = -b0; l <= b0; ++l) + { + for (int i1 = -b0; i1 <= b0; ++i1) + { + boolean flag3 = l == -b0 || l == b0 || i1 == -b0 || i1 == b0; + ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(l + j, i1 + k); + + if (!flag3) + { + this.eligibleChunksForSpawning.put(chunkcoordintpair, Boolean.valueOf(false)); + } + else if (!this.eligibleChunksForSpawning.containsKey(chunkcoordintpair)) + { + this.eligibleChunksForSpawning.put(chunkcoordintpair, Boolean.valueOf(true)); + } + } + } + } + + i = 0; + ChunkCoordinates chunkcoordinates = par1WorldServer.getSpawnPoint(); + EnumCreatureType[] aenumcreaturetype = EnumCreatureType.values(); + k = aenumcreaturetype.length; + + for (int k3 = 0; k3 < k; ++k3) + { + EnumCreatureType enumcreaturetype = aenumcreaturetype[k3]; + + if ((!enumcreaturetype.getPeacefulCreature() || par3) && (enumcreaturetype.getPeacefulCreature() || par2) && (!enumcreaturetype.getAnimal() || par4) && par1WorldServer.countEntities(enumcreaturetype, true) <= enumcreaturetype.getMaxNumberOfCreature() * this.eligibleChunksForSpawning.size() / 256) + { + Iterator iterator = this.eligibleChunksForSpawning.keySet().iterator(); + ArrayList tmp = new ArrayList(eligibleChunksForSpawning.keySet()); + Collections.shuffle(tmp); + iterator = tmp.iterator(); + label110: + + while (iterator.hasNext()) + { + ChunkCoordIntPair chunkcoordintpair1 = (ChunkCoordIntPair)iterator.next(); + + if (!((Boolean)this.eligibleChunksForSpawning.get(chunkcoordintpair1)).booleanValue()) + { + ChunkPosition chunkposition = func_151350_a(par1WorldServer, chunkcoordintpair1.chunkXPos, chunkcoordintpair1.chunkZPos); + int j1 = chunkposition.chunkPosX; + int k1 = chunkposition.chunkPosY; + int l1 = chunkposition.chunkPosZ; + + if (!par1WorldServer.getBlock(j1, k1, l1).isNormalCube() && par1WorldServer.getBlock(j1, k1, l1).getMaterial() == enumcreaturetype.getCreatureMaterial()) + { + int i2 = 0; + int j2 = 0; + + while (j2 < 3) + { + int k2 = j1; + int l2 = k1; + int i3 = l1; + byte b1 = 6; + BiomeGenBase.SpawnListEntry spawnlistentry = null; + IEntityLivingData ientitylivingdata = null; + int j3 = 0; + + while (true) + { + if (j3 < 4) + { + label103: + { + k2 += par1WorldServer.rand.nextInt(b1) - par1WorldServer.rand.nextInt(b1); + l2 += par1WorldServer.rand.nextInt(1) - par1WorldServer.rand.nextInt(1); + i3 += par1WorldServer.rand.nextInt(b1) - par1WorldServer.rand.nextInt(b1); + + if (canCreatureTypeSpawnAtLocation(enumcreaturetype, par1WorldServer, k2, l2, i3)) + { + float f = (float)k2 + 0.5F; + float f1 = (float)l2; + float f2 = (float)i3 + 0.5F; + + if (par1WorldServer.getClosestPlayer((double)f, (double)f1, (double)f2, 24.0D) == null) + { + float f3 = f - (float)chunkcoordinates.posX; + float f4 = f1 - (float)chunkcoordinates.posY; + float f5 = f2 - (float)chunkcoordinates.posZ; + float f6 = f3 * f3 + f4 * f4 + f5 * f5; + + if (f6 >= 576.0F) + { + if (spawnlistentry == null) + { + spawnlistentry = par1WorldServer.spawnRandomCreature(enumcreaturetype, k2, l2, i3); + + if (spawnlistentry == null) + { + break label103; + } + } + + EntityLiving entityliving; + + try + { + entityliving = (EntityLiving)spawnlistentry.entityClass.getConstructor(new Class[] {World.class}).newInstance(new Object[] {par1WorldServer}); + } + catch (Exception exception) + { + exception.printStackTrace(); + return i; + } + + entityliving.setLocationAndAngles((double)f, (double)f1, (double)f2, par1WorldServer.rand.nextFloat() * 360.0F, 0.0F); + + Result canSpawn = ForgeEventFactory.canEntitySpawn(entityliving, par1WorldServer, f, f1, f2); + if (canSpawn == Result.ALLOW || (canSpawn == Result.DEFAULT && entityliving.getCanSpawnHere())) + { + ++i2; + par1WorldServer.spawnEntityInWorld(entityliving); + if (!ForgeEventFactory.doSpecialSpawn(entityliving, par1WorldServer, f, f1, f2)) + { + ientitylivingdata = entityliving.onSpawnWithEgg(ientitylivingdata); + } + + if (j2 >= ForgeEventFactory.getMaxSpawnPackSize(entityliving)) + { + continue label110; + } + } + + i += i2; + } + } + } + + ++j3; + continue; + } + } + + ++j2; + break; + } + } + } + } + } + } + } + + return i; + } + } + + public static boolean canCreatureTypeSpawnAtLocation(EnumCreatureType par0EnumCreatureType, World par1World, int par2, int par3, int par4) + { + if (par0EnumCreatureType.getCreatureMaterial() == Material.water) + { + return par1World.getBlock(par2, par3, par4).getMaterial().isLiquid() && par1World.getBlock(par2, par3 - 1, par4).getMaterial().isLiquid() && !par1World.getBlock(par2, par3 + 1, par4).isNormalCube(); + } + else if (!World.doesBlockHaveSolidTopSurface(par1World, par2, par3 - 1, par4)) + { + return false; + } + else + { + Block block = par1World.getBlock(par2, par3 - 1, par4); + boolean spawnBlock = block.canCreatureSpawn(par0EnumCreatureType, par1World, par2, par3 - 1, par4); + return spawnBlock && block != Blocks.bedrock && !par1World.getBlock(par2, par3, par4).isNormalCube() && !par1World.getBlock(par2, par3, par4).getMaterial().isLiquid() && !par1World.getBlock(par2, par3 + 1, par4).isNormalCube(); + } + } + + public static void performWorldGenSpawning(World par0World, BiomeGenBase par1BiomeGenBase, int par2, int par3, int par4, int par5, Random par6Random) + { + List list = par1BiomeGenBase.getSpawnableList(EnumCreatureType.creature); + + if (!list.isEmpty()) + { + while (par6Random.nextFloat() < par1BiomeGenBase.getSpawningChance()) + { + BiomeGenBase.SpawnListEntry spawnlistentry = (BiomeGenBase.SpawnListEntry)WeightedRandom.getRandomItem(par0World.rand, list); + IEntityLivingData ientitylivingdata = null; + int i1 = spawnlistentry.minGroupCount + par6Random.nextInt(1 + spawnlistentry.maxGroupCount - spawnlistentry.minGroupCount); + int j1 = par2 + par6Random.nextInt(par4); + int k1 = par3 + par6Random.nextInt(par5); + int l1 = j1; + int i2 = k1; + + for (int j2 = 0; j2 < i1; ++j2) + { + boolean flag = false; + + for (int k2 = 0; !flag && k2 < 4; ++k2) + { + int l2 = par0World.getTopSolidOrLiquidBlock(j1, k1); + + if (canCreatureTypeSpawnAtLocation(EnumCreatureType.creature, par0World, j1, l2, k1)) + { + float f = (float)j1 + 0.5F; + float f1 = (float)l2; + float f2 = (float)k1 + 0.5F; + EntityLiving entityliving; + + try + { + entityliving = (EntityLiving)spawnlistentry.entityClass.getConstructor(new Class[] {World.class}).newInstance(new Object[] {par0World}); + } + catch (Exception exception) + { + exception.printStackTrace(); + continue; + } + + entityliving.setLocationAndAngles((double)f, (double)f1, (double)f2, par6Random.nextFloat() * 360.0F, 0.0F); + par0World.spawnEntityInWorld(entityliving); + ientitylivingdata = entityliving.onSpawnWithEgg(ientitylivingdata); + flag = true; + } + + j1 += par6Random.nextInt(5) - par6Random.nextInt(5); + + for (k1 += par6Random.nextInt(5) - par6Random.nextInt(5); j1 < par2 || j1 >= par2 + par4 || k1 < par3 || k1 >= par3 + par4; k1 = i2 + par6Random.nextInt(5) - par6Random.nextInt(5)) + { + j1 = l1 + par6Random.nextInt(5) - par6Random.nextInt(5); + } + } + } + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/Teleporter.java b/src/main/java/net/minecraft/world/Teleporter.java new file mode 100644 index 0000000..c23539f --- /dev/null +++ b/src/main/java/net/minecraft/world/Teleporter.java @@ -0,0 +1,506 @@ +package net.minecraft.world; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.init.Blocks; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.Direction; +import net.minecraft.util.LongHashMap; +import net.minecraft.util.MathHelper; + +public class Teleporter +{ + private final WorldServer worldServerInstance; + private final Random random; + private final LongHashMap destinationCoordinateCache = new LongHashMap(); + private final List destinationCoordinateKeys = new ArrayList(); + private static final String __OBFID = "CL_00000153"; + + public Teleporter(WorldServer par1WorldServer) + { + this.worldServerInstance = par1WorldServer; + this.random = new Random(par1WorldServer.getSeed()); + } + + public void placeInPortal(Entity par1Entity, double par2, double par4, double par6, float par8) + { + if (this.worldServerInstance.provider.dimensionId != 1) + { + if (!this.placeInExistingPortal(par1Entity, par2, par4, par6, par8)) + { + this.makePortal(par1Entity); + this.placeInExistingPortal(par1Entity, par2, par4, par6, par8); + } + } + else + { + int i = MathHelper.floor_double(par1Entity.posX); + int j = MathHelper.floor_double(par1Entity.posY) - 1; + int k = MathHelper.floor_double(par1Entity.posZ); + byte b0 = 1; + byte b1 = 0; + + for (int l = -2; l <= 2; ++l) + { + for (int i1 = -2; i1 <= 2; ++i1) + { + for (int j1 = -1; j1 < 3; ++j1) + { + int k1 = i + i1 * b0 + l * b1; + int l1 = j + j1; + int i2 = k + i1 * b1 - l * b0; + boolean flag = j1 < 0; + this.worldServerInstance.setBlock(k1, l1, i2, flag ? Blocks.obsidian : Blocks.air); + } + } + } + + par1Entity.setLocationAndAngles((double)i, (double)j, (double)k, par1Entity.rotationYaw, 0.0F); + par1Entity.motionX = par1Entity.motionY = par1Entity.motionZ = 0.0D; + } + } + + public boolean placeInExistingPortal(Entity par1Entity, double par2, double par4, double par6, float par8) + { + short short1 = 128; + double d3 = -1.0D; + int i = 0; + int j = 0; + int k = 0; + int l = MathHelper.floor_double(par1Entity.posX); + int i1 = MathHelper.floor_double(par1Entity.posZ); + long j1 = ChunkCoordIntPair.chunkXZ2Int(l, i1); + boolean flag = true; + double d7; + int l3; + + if (this.destinationCoordinateCache.containsItem(j1)) + { + Teleporter.PortalPosition portalposition = (Teleporter.PortalPosition)this.destinationCoordinateCache.getValueByKey(j1); + d3 = 0.0D; + i = portalposition.posX; + j = portalposition.posY; + k = portalposition.posZ; + portalposition.lastUpdateTime = this.worldServerInstance.getTotalWorldTime(); + flag = false; + } + else + { + for (l3 = l - short1; l3 <= l + short1; ++l3) + { + double d4 = (double)l3 + 0.5D - par1Entity.posX; + + for (int l1 = i1 - short1; l1 <= i1 + short1; ++l1) + { + double d5 = (double)l1 + 0.5D - par1Entity.posZ; + + for (int i2 = this.worldServerInstance.getActualHeight() - 1; i2 >= 0; --i2) + { + if (this.worldServerInstance.getBlock(l3, i2, l1) == Blocks.portal) + { + while (this.worldServerInstance.getBlock(l3, i2 - 1, l1) == Blocks.portal) + { + --i2; + } + + d7 = (double)i2 + 0.5D - par1Entity.posY; + double d8 = d4 * d4 + d7 * d7 + d5 * d5; + + if (d3 < 0.0D || d8 < d3) + { + d3 = d8; + i = l3; + j = i2; + k = l1; + } + } + } + } + } + } + + if (d3 >= 0.0D) + { + if (flag) + { + this.destinationCoordinateCache.add(j1, new Teleporter.PortalPosition(i, j, k, this.worldServerInstance.getTotalWorldTime())); + this.destinationCoordinateKeys.add(Long.valueOf(j1)); + } + + double d11 = (double)i + 0.5D; + double d6 = (double)j + 0.5D; + d7 = (double)k + 0.5D; + int i4 = -1; + + if (this.worldServerInstance.getBlock(i - 1, j, k) == Blocks.portal) + { + i4 = 2; + } + + if (this.worldServerInstance.getBlock(i + 1, j, k) == Blocks.portal) + { + i4 = 0; + } + + if (this.worldServerInstance.getBlock(i, j, k - 1) == Blocks.portal) + { + i4 = 3; + } + + if (this.worldServerInstance.getBlock(i, j, k + 1) == Blocks.portal) + { + i4 = 1; + } + + int j2 = par1Entity.getTeleportDirection(); + + if (i4 > -1) + { + int k2 = Direction.rotateLeft[i4]; + int l2 = Direction.offsetX[i4]; + int i3 = Direction.offsetZ[i4]; + int j3 = Direction.offsetX[k2]; + int k3 = Direction.offsetZ[k2]; + boolean flag1 = !this.worldServerInstance.isAirBlock(i + l2 + j3, j, k + i3 + k3) || !this.worldServerInstance.isAirBlock(i + l2 + j3, j + 1, k + i3 + k3); + boolean flag2 = !this.worldServerInstance.isAirBlock(i + l2, j, k + i3) || !this.worldServerInstance.isAirBlock(i + l2, j + 1, k + i3); + + if (flag1 && flag2) + { + i4 = Direction.rotateOpposite[i4]; + k2 = Direction.rotateOpposite[k2]; + l2 = Direction.offsetX[i4]; + i3 = Direction.offsetZ[i4]; + j3 = Direction.offsetX[k2]; + k3 = Direction.offsetZ[k2]; + l3 = i - j3; + d11 -= (double)j3; + int k1 = k - k3; + d7 -= (double)k3; + flag1 = !this.worldServerInstance.isAirBlock(l3 + l2 + j3, j, k1 + i3 + k3) || !this.worldServerInstance.isAirBlock(l3 + l2 + j3, j + 1, k1 + i3 + k3); + flag2 = !this.worldServerInstance.isAirBlock(l3 + l2, j, k1 + i3) || !this.worldServerInstance.isAirBlock(l3 + l2, j + 1, k1 + i3); + } + + float f1 = 0.5F; + float f2 = 0.5F; + + if (!flag1 && flag2) + { + f1 = 1.0F; + } + else if (flag1 && !flag2) + { + f1 = 0.0F; + } + else if (flag1 && flag2) + { + f2 = 0.0F; + } + + d11 += (double)((float)j3 * f1 + f2 * (float)l2); + d7 += (double)((float)k3 * f1 + f2 * (float)i3); + float f3 = 0.0F; + float f4 = 0.0F; + float f5 = 0.0F; + float f6 = 0.0F; + + if (i4 == j2) + { + f3 = 1.0F; + f4 = 1.0F; + } + else if (i4 == Direction.rotateOpposite[j2]) + { + f3 = -1.0F; + f4 = -1.0F; + } + else if (i4 == Direction.rotateRight[j2]) + { + f5 = 1.0F; + f6 = -1.0F; + } + else + { + f5 = -1.0F; + f6 = 1.0F; + } + + double d9 = par1Entity.motionX; + double d10 = par1Entity.motionZ; + par1Entity.motionX = d9 * (double)f3 + d10 * (double)f6; + par1Entity.motionZ = d9 * (double)f5 + d10 * (double)f4; + par1Entity.rotationYaw = par8 - (float)(j2 * 90) + (float)(i4 * 90); + } + else + { + par1Entity.motionX = par1Entity.motionY = par1Entity.motionZ = 0.0D; + } + + par1Entity.setLocationAndAngles(d11, d6, d7, par1Entity.rotationYaw, par1Entity.rotationPitch); + return true; + } + else + { + return false; + } + } + + public boolean makePortal(Entity par1Entity) + { + byte b0 = 16; + double d0 = -1.0D; + int i = MathHelper.floor_double(par1Entity.posX); + int j = MathHelper.floor_double(par1Entity.posY); + int k = MathHelper.floor_double(par1Entity.posZ); + int l = i; + int i1 = j; + int j1 = k; + int k1 = 0; + int l1 = this.random.nextInt(4); + int i2; + double d1; + int k2; + double d2; + int i3; + int j3; + int k3; + int l3; + int i4; + int j4; + int k4; + int l4; + int i5; + double d3; + double d4; + + for (i2 = i - b0; i2 <= i + b0; ++i2) + { + d1 = (double)i2 + 0.5D - par1Entity.posX; + + for (k2 = k - b0; k2 <= k + b0; ++k2) + { + d2 = (double)k2 + 0.5D - par1Entity.posZ; + label274: + + for (i3 = this.worldServerInstance.getActualHeight() - 1; i3 >= 0; --i3) + { + if (this.worldServerInstance.isAirBlock(i2, i3, k2)) + { + while (i3 > 0 && this.worldServerInstance.isAirBlock(i2, i3 - 1, k2)) + { + --i3; + } + + for (j3 = l1; j3 < l1 + 4; ++j3) + { + k3 = j3 % 2; + l3 = 1 - k3; + + if (j3 % 4 >= 2) + { + k3 = -k3; + l3 = -l3; + } + + for (i4 = 0; i4 < 3; ++i4) + { + for (j4 = 0; j4 < 4; ++j4) + { + for (k4 = -1; k4 < 4; ++k4) + { + l4 = i2 + (j4 - 1) * k3 + i4 * l3; + i5 = i3 + k4; + int j5 = k2 + (j4 - 1) * l3 - i4 * k3; + + if (k4 < 0 && !this.worldServerInstance.getBlock(l4, i5, j5).getMaterial().isSolid() || k4 >= 0 && !this.worldServerInstance.isAirBlock(l4, i5, j5)) + { + continue label274; + } + } + } + } + + d3 = (double)i3 + 0.5D - par1Entity.posY; + d4 = d1 * d1 + d3 * d3 + d2 * d2; + + if (d0 < 0.0D || d4 < d0) + { + d0 = d4; + l = i2; + i1 = i3; + j1 = k2; + k1 = j3 % 4; + } + } + } + } + } + } + + if (d0 < 0.0D) + { + for (i2 = i - b0; i2 <= i + b0; ++i2) + { + d1 = (double)i2 + 0.5D - par1Entity.posX; + + for (k2 = k - b0; k2 <= k + b0; ++k2) + { + d2 = (double)k2 + 0.5D - par1Entity.posZ; + label222: + + for (i3 = this.worldServerInstance.getActualHeight() - 1; i3 >= 0; --i3) + { + if (this.worldServerInstance.isAirBlock(i2, i3, k2)) + { + while (i3 > 0 && this.worldServerInstance.isAirBlock(i2, i3 - 1, k2)) + { + --i3; + } + + for (j3 = l1; j3 < l1 + 2; ++j3) + { + k3 = j3 % 2; + l3 = 1 - k3; + + for (i4 = 0; i4 < 4; ++i4) + { + for (j4 = -1; j4 < 4; ++j4) + { + k4 = i2 + (i4 - 1) * k3; + l4 = i3 + j4; + i5 = k2 + (i4 - 1) * l3; + + if (j4 < 0 && !this.worldServerInstance.getBlock(k4, l4, i5).getMaterial().isSolid() || j4 >= 0 && !this.worldServerInstance.isAirBlock(k4, l4, i5)) + { + continue label222; + } + } + } + + d3 = (double)i3 + 0.5D - par1Entity.posY; + d4 = d1 * d1 + d3 * d3 + d2 * d2; + + if (d0 < 0.0D || d4 < d0) + { + d0 = d4; + l = i2; + i1 = i3; + j1 = k2; + k1 = j3 % 2; + } + } + } + } + } + } + } + + int k5 = l; + int j2 = i1; + k2 = j1; + int l5 = k1 % 2; + int l2 = 1 - l5; + + if (k1 % 4 >= 2) + { + l5 = -l5; + l2 = -l2; + } + + boolean flag; + + if (d0 < 0.0D) + { + if (i1 < 70) + { + i1 = 70; + } + + if (i1 > this.worldServerInstance.getActualHeight() - 10) + { + i1 = this.worldServerInstance.getActualHeight() - 10; + } + + j2 = i1; + + for (i3 = -1; i3 <= 1; ++i3) + { + for (j3 = 1; j3 < 3; ++j3) + { + for (k3 = -1; k3 < 3; ++k3) + { + l3 = k5 + (j3 - 1) * l5 + i3 * l2; + i4 = j2 + k3; + j4 = k2 + (j3 - 1) * l2 - i3 * l5; + flag = k3 < 0; + this.worldServerInstance.setBlock(l3, i4, j4, flag ? Blocks.obsidian : Blocks.air); + } + } + } + } + + for (i3 = 0; i3 < 4; ++i3) + { + for (j3 = 0; j3 < 4; ++j3) + { + for (k3 = -1; k3 < 4; ++k3) + { + l3 = k5 + (j3 - 1) * l5; + i4 = j2 + k3; + j4 = k2 + (j3 - 1) * l2; + flag = j3 == 0 || j3 == 3 || k3 == -1 || k3 == 3; + this.worldServerInstance.setBlock(l3, i4, j4, (Block)(flag ? Blocks.obsidian : Blocks.portal), 0, 2); + } + } + + for (j3 = 0; j3 < 4; ++j3) + { + for (k3 = -1; k3 < 4; ++k3) + { + l3 = k5 + (j3 - 1) * l5; + i4 = j2 + k3; + j4 = k2 + (j3 - 1) * l2; + this.worldServerInstance.notifyBlocksOfNeighborChange(l3, i4, j4, this.worldServerInstance.getBlock(l3, i4, j4)); + } + } + } + + return true; + } + + public void removeStalePortalLocations(long par1) + { + if (par1 % 100L == 0L) + { + Iterator iterator = this.destinationCoordinateKeys.iterator(); + long j = par1 - 600L; + + while (iterator.hasNext()) + { + Long olong = (Long)iterator.next(); + Teleporter.PortalPosition portalposition = (Teleporter.PortalPosition)this.destinationCoordinateCache.getValueByKey(olong.longValue()); + + if (portalposition == null || portalposition.lastUpdateTime < j) + { + iterator.remove(); + this.destinationCoordinateCache.remove(olong.longValue()); + } + } + } + } + + public class PortalPosition extends ChunkCoordinates + { + public long lastUpdateTime; + private static final String __OBFID = "CL_00000154"; + + public PortalPosition(int par2, int par3, int par4, long par5) + { + super(par2, par3, par4); + this.lastUpdateTime = par5; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/World.java b/src/main/java/net/minecraft/world/World.java new file mode 100644 index 0000000..13400e8 --- /dev/null +++ b/src/main/java/net/minecraft/world/World.java @@ -0,0 +1,3957 @@ +package net.minecraft.world; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import java.util.Set; +import java.util.concurrent.Callable; +import net.minecraft.block.Block; +import net.minecraft.block.BlockHopper; +import net.minecraft.block.BlockLiquid; +import net.minecraft.block.BlockSlab; +import net.minecraft.block.BlockSnow; +import net.minecraft.block.BlockStairs; +import net.minecraft.block.material.Material; +import net.minecraft.command.IEntitySelector; +import net.minecraft.crash.CrashReport; +import net.minecraft.crash.CrashReportCategory; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.pathfinding.PathEntity; +import net.minecraft.pathfinding.PathFinder; +import net.minecraft.profiler.Profiler; +import net.minecraft.scoreboard.Scoreboard; +import net.minecraft.server.MinecraftServer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.Direction; +import net.minecraft.util.Facing; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.ReportedException; +import net.minecraft.util.Vec3; +import net.minecraft.util.Vec3Pool; +import net.minecraft.village.VillageCollection; +import net.minecraft.village.VillageSiege; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.biome.WorldChunkManager; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.IChunkProvider; +import net.minecraft.world.storage.ISaveHandler; +import net.minecraft.world.storage.MapStorage; +import net.minecraft.world.storage.WorldInfo; + +import cpw.mods.fml.common.FMLLog; + +import com.google.common.collect.ImmutableSetMultimap; + +import net.minecraftforge.client.ForgeHooksClient; +import net.minecraftforge.common.ForgeChunkManager; +import net.minecraftforge.common.ForgeChunkManager.Ticket; +import net.minecraftforge.common.ForgeModContainer; +import net.minecraftforge.common.ForgeHooks; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.common.WorldSpecificSaveHandler; +import net.minecraftforge.event.entity.EntityEvent; +import net.minecraftforge.event.entity.EntityJoinWorldEvent; +import net.minecraftforge.event.world.WorldEvent; +import net.minecraftforge.event.entity.PlaySoundAtEntityEvent; +import net.minecraft.entity.EnumCreatureType; + +public abstract class World implements IBlockAccess +{ + /** + * Used in the getEntitiesWithinAABB functions to expand the search area for entities. + * Modders should change this variable to a higher value if it is less then the radius + * of one of there entities. + */ + public static double MAX_ENTITY_RADIUS = 2.0D; + + public final MapStorage perWorldStorage; + + public boolean scheduledUpdatesAreImmediate; + public List loadedEntityList = new ArrayList(); + protected List unloadedEntityList = new ArrayList(); + public List loadedTileEntityList = new ArrayList(); + private List addedTileEntityList = new ArrayList(); + private List field_147483_b = new ArrayList(); + public List playerEntities = new ArrayList(); + public List weatherEffects = new ArrayList(); + private long cloudColour = 16777215L; + public int skylightSubtracted; + protected int updateLCG = (new Random()).nextInt(); + protected final int DIST_HASH_MAGIC = 1013904223; + public float prevRainingStrength; + public float rainingStrength; + public float prevThunderingStrength; + public float thunderingStrength; + public int lastLightningBolt; + public EnumDifficulty difficultySetting; + public Random rand = new Random(); + public final WorldProvider provider; + protected List worldAccesses = new ArrayList(); + protected IChunkProvider chunkProvider; + protected final ISaveHandler saveHandler; + protected WorldInfo worldInfo; + public boolean findingSpawnPoint; + public MapStorage mapStorage; + public VillageCollection villageCollectionObj; + protected final VillageSiege villageSiegeObj = new VillageSiege(this); + public final Profiler theProfiler; + private final Vec3Pool vecPool = new Vec3Pool(300, 2000); + private final Calendar theCalendar = Calendar.getInstance(); + protected Scoreboard worldScoreboard = new Scoreboard(); + public boolean isRemote; + protected Set activeChunkSet = new HashSet(); + private int ambientTickCountdown; + protected boolean spawnHostileMobs; + protected boolean spawnPeacefulMobs; + private ArrayList collidingBoundingBoxes; + private boolean field_147481_N; + int[] lightUpdateBlockList; + private static final String __OBFID = "CL_00000140"; + + public BiomeGenBase getBiomeGenForCoords(final int par1, final int par2) + { + return provider.getBiomeGenForCoords(par1, par2); + } + + public BiomeGenBase getBiomeGenForCoordsBody(final int par1, final int par2) + { + if (this.blockExists(par1, 0, par2)) + { + Chunk chunk = this.getChunkFromBlockCoords(par1, par2); + + try + { + return chunk.getBiomeGenForWorldCoords(par1 & 15, par2 & 15, this.provider.worldChunkMgr); + } + catch (Throwable throwable) + { + CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Getting biome"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("Coordinates of biome request"); + crashreportcategory.addCrashSectionCallable("Location", new Callable() + { + private static final String __OBFID = "CL_00000141"; + public String call() + { + return CrashReportCategory.getLocationInfo(par1, 0, par2); + } + }); + throw new ReportedException(crashreport); + } + } + else + { + return this.provider.worldChunkMgr.getBiomeGenAt(par1, par2); + } + } + + public WorldChunkManager getWorldChunkManager() + { + return this.provider.worldChunkMgr; + } + + @SideOnly(Side.CLIENT) + public World(ISaveHandler p_i45368_1_, String p_i45368_2_, WorldProvider p_i45368_3_, WorldSettings p_i45368_4_, Profiler p_i45368_5_) + { + this.ambientTickCountdown = this.rand.nextInt(12000); + this.spawnHostileMobs = true; + this.spawnPeacefulMobs = true; + this.collidingBoundingBoxes = new ArrayList(); + this.lightUpdateBlockList = new int[32768]; + this.saveHandler = p_i45368_1_; + this.theProfiler = p_i45368_5_; + this.worldInfo = new WorldInfo(p_i45368_4_, p_i45368_2_); + this.provider = p_i45368_3_; + perWorldStorage = new MapStorage((ISaveHandler)null); + } + + // Broken up so that the WorldClient gets the chance to set the mapstorage object before the dimension initializes + @SideOnly(Side.CLIENT) + protected void finishSetup() + { + VillageCollection villagecollection = (VillageCollection)this.mapStorage.loadData(VillageCollection.class, "villages"); + + if (villagecollection == null) + { + this.villageCollectionObj = new VillageCollection(this); + this.mapStorage.setData("villages", this.villageCollectionObj); + } + else + { + this.villageCollectionObj = villagecollection; + this.villageCollectionObj.func_82566_a(this); + } + + // Guarantee the dimension ID was not reset by the provider + int providerDim = this.provider.dimensionId; + this.provider.registerWorld(this); + this.provider.dimensionId = providerDim; + this.chunkProvider = this.createChunkProvider(); + this.calculateInitialSkylight(); + this.calculateInitialWeather(); + } + + public World(ISaveHandler p_i45369_1_, String p_i45369_2_, WorldSettings p_i45369_3_, WorldProvider p_i45369_4_, Profiler p_i45369_5_) + { + this.ambientTickCountdown = this.rand.nextInt(12000); + this.spawnHostileMobs = true; + this.spawnPeacefulMobs = true; + this.collidingBoundingBoxes = new ArrayList(); + this.lightUpdateBlockList = new int[32768]; + this.saveHandler = p_i45369_1_; + this.theProfiler = p_i45369_5_; + this.mapStorage = getMapStorage(p_i45369_1_); + this.worldInfo = p_i45369_1_.loadWorldInfo(); + + if (p_i45369_4_ != null) + { + this.provider = p_i45369_4_; + } + else if (this.worldInfo != null && this.worldInfo.getVanillaDimension() != 0) + { + this.provider = WorldProvider.getProviderForDimension(this.worldInfo.getVanillaDimension()); + } + else + { + this.provider = WorldProvider.getProviderForDimension(0); + } + + if (this.worldInfo == null) + { + this.worldInfo = new WorldInfo(p_i45369_3_, p_i45369_2_); + } + else + { + this.worldInfo.setWorldName(p_i45369_2_); + } + + this.provider.registerWorld(this); + this.chunkProvider = this.createChunkProvider(); + + if (this instanceof WorldServer) + { + this.perWorldStorage = new MapStorage(new WorldSpecificSaveHandler((WorldServer)this, p_i45369_1_)); + } + else + { + this.perWorldStorage = new MapStorage((ISaveHandler)null); + } + + if (!this.worldInfo.isInitialized()) + { + try + { + this.initialize(p_i45369_3_); + } + catch (Throwable throwable1) + { + CrashReport crashreport = CrashReport.makeCrashReport(throwable1, "Exception initializing level"); + + try + { + this.addWorldInfoToCrashReport(crashreport); + } + catch (Throwable throwable) + { + ; + } + + throw new ReportedException(crashreport); + } + + this.worldInfo.setServerInitialized(true); + } + + VillageCollection villagecollection = (VillageCollection)this.perWorldStorage.loadData(VillageCollection.class, "villages"); + + if (villagecollection == null) + { + this.villageCollectionObj = new VillageCollection(this); + this.perWorldStorage.setData("villages", this.villageCollectionObj); + } + else + { + this.villageCollectionObj = villagecollection; + this.villageCollectionObj.func_82566_a(this); + } + + this.calculateInitialSkylight(); + this.calculateInitialWeather(); + } + + private static MapStorage s_mapStorage; + private static ISaveHandler s_savehandler; + //Provides a solution for different worlds getting different copies of the same data, potentially rewriting the data or causing race conditions/stale data + //Buildcraft has suffered from the issue this fixes. If you load the same data from two different worlds they can get two different copies of the same object, thus the last saved gets final say. + private MapStorage getMapStorage(ISaveHandler savehandler) + { + if (s_savehandler != savehandler || s_mapStorage == null) + { + s_mapStorage = new MapStorage(savehandler); + s_savehandler = savehandler; + } + return s_mapStorage; + } + + protected abstract IChunkProvider createChunkProvider(); + + protected void initialize(WorldSettings par1WorldSettings) + { + this.worldInfo.setServerInitialized(true); + } + + @SideOnly(Side.CLIENT) + public void setSpawnLocation() + { + this.setSpawnLocation(8, 64, 8); + } + + public Block getTopBlock(int p_147474_1_, int p_147474_2_) + { + int k; + + for (k = 63; !this.isAirBlock(p_147474_1_, k + 1, p_147474_2_); ++k) + { + ; + } + + return this.getBlock(p_147474_1_, k, p_147474_2_); + } + + public Block getBlock(int p_147439_1_, int p_147439_2_, int p_147439_3_) + { + if (p_147439_1_ >= -30000000 && p_147439_3_ >= -30000000 && p_147439_1_ < 30000000 && p_147439_3_ < 30000000 && p_147439_2_ >= 0 && p_147439_2_ < 256) + { + Chunk chunk = null; + + try + { + chunk = this.getChunkFromChunkCoords(p_147439_1_ >> 4, p_147439_3_ >> 4); + return chunk.getBlock(p_147439_1_ & 15, p_147439_2_, p_147439_3_ & 15); + } + catch (Throwable throwable) + { + CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Exception getting block type in world"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("Requested block coordinates"); + crashreportcategory.addCrashSection("Found chunk", Boolean.valueOf(chunk == null)); + crashreportcategory.addCrashSection("Location", CrashReportCategory.getLocationInfo(p_147439_1_, p_147439_2_, p_147439_3_)); + throw new ReportedException(crashreport); + } + } + else + { + return Blocks.air; + } + } + + public boolean isAirBlock(int p_147437_1_, int p_147437_2_, int p_147437_3_) + { + Block block = this.getBlock(p_147437_1_, p_147437_2_, p_147437_3_); + return block.isAir(this, p_147437_1_, p_147437_2_, p_147437_3_); + } + + public boolean blockExists(int par1, int par2, int par3) + { + return par2 >= 0 && par2 < 256 ? this.chunkExists(par1 >> 4, par3 >> 4) : false; + } + + public boolean doChunksNearChunkExist(int par1, int par2, int par3, int par4) + { + return this.checkChunksExist(par1 - par4, par2 - par4, par3 - par4, par1 + par4, par2 + par4, par3 + par4); + } + + public boolean checkChunksExist(int par1, int par2, int par3, int par4, int par5, int par6) + { + if (par5 >= 0 && par2 < 256) + { + par1 >>= 4; + par3 >>= 4; + par4 >>= 4; + par6 >>= 4; + + for (int k1 = par1; k1 <= par4; ++k1) + { + for (int l1 = par3; l1 <= par6; ++l1) + { + if (!this.chunkExists(k1, l1)) + { + return false; + } + } + } + + return true; + } + else + { + return false; + } + } + + protected boolean chunkExists(int par1, int par2) + { + return this.chunkProvider.chunkExists(par1, par2); + } + + public Chunk getChunkFromBlockCoords(int par1, int par2) + { + return this.getChunkFromChunkCoords(par1 >> 4, par2 >> 4); + } + + public Chunk getChunkFromChunkCoords(int par1, int par2) + { + return this.chunkProvider.provideChunk(par1, par2); + } + + public boolean setBlock(int p_147465_1_, int p_147465_2_, int p_147465_3_, Block p_147465_4_, int p_147465_5_, int p_147465_6_) + { + if (p_147465_1_ >= -30000000 && p_147465_3_ >= -30000000 && p_147465_1_ < 30000000 && p_147465_3_ < 30000000) + { + if (p_147465_2_ < 0) + { + return false; + } + else if (p_147465_2_ >= 256) + { + return false; + } + else + { + Chunk chunk = this.getChunkFromChunkCoords(p_147465_1_ >> 4, p_147465_3_ >> 4); + Block block1 = null; + + if ((p_147465_6_ & 1) != 0) + { + block1 = chunk.getBlock(p_147465_1_ & 15, p_147465_2_, p_147465_3_ & 15); + } + + boolean flag = chunk.func_150807_a(p_147465_1_ & 15, p_147465_2_, p_147465_3_ & 15, p_147465_4_, p_147465_5_); + this.theProfiler.startSection("checkLight"); + this.func_147451_t(p_147465_1_, p_147465_2_, p_147465_3_); + this.theProfiler.endSection(); + + if (flag) + { + if ((p_147465_6_ & 2) != 0 && (!this.isRemote || (p_147465_6_ & 4) == 0) && chunk.func_150802_k()) + { + this.markBlockForUpdate(p_147465_1_, p_147465_2_, p_147465_3_); + } + + if (!this.isRemote && (p_147465_6_ & 1) != 0) + { + this.notifyBlockChange(p_147465_1_, p_147465_2_, p_147465_3_, block1); + + if (p_147465_4_.hasComparatorInputOverride()) + { + this.func_147453_f(p_147465_1_, p_147465_2_, p_147465_3_, p_147465_4_); + } + } + } + + return flag; + } + } + else + { + return false; + } + } + + public int getBlockMetadata(int par1, int par2, int par3) + { + if (par1 >= -30000000 && par3 >= -30000000 && par1 < 30000000 && par3 < 30000000) + { + if (par2 < 0) + { + return 0; + } + else if (par2 >= 256) + { + return 0; + } + else + { + Chunk chunk = this.getChunkFromChunkCoords(par1 >> 4, par3 >> 4); + par1 &= 15; + par3 &= 15; + return chunk.getBlockMetadata(par1, par2, par3); + } + } + else + { + return 0; + } + } + + public boolean setBlockMetadataWithNotify(int par1, int par2, int par3, int par4, int par5) + { + if (par1 >= -30000000 && par3 >= -30000000 && par1 < 30000000 && par3 < 30000000) + { + if (par2 < 0) + { + return false; + } + else if (par2 >= 256) + { + return false; + } + else + { + Chunk chunk = this.getChunkFromChunkCoords(par1 >> 4, par3 >> 4); + int j1 = par1 & 15; + int k1 = par3 & 15; + boolean flag = chunk.setBlockMetadata(j1, par2, k1, par4); + + if (flag) + { + Block block = chunk.getBlock(j1, par2, k1); + + if ((par5 & 2) != 0 && (!this.isRemote || (par5 & 4) == 0) && chunk.func_150802_k()) + { + this.markBlockForUpdate(par1, par2, par3); + } + + if (!this.isRemote && (par5 & 1) != 0) + { + this.notifyBlockChange(par1, par2, par3, block); + + if (block.hasComparatorInputOverride()) + { + this.func_147453_f(par1, par2, par3, block); + } + } + } + + return flag; + } + } + else + { + return false; + } + } + + public boolean setBlockToAir(int p_147468_1_, int p_147468_2_, int p_147468_3_) + { + return this.setBlock(p_147468_1_, p_147468_2_, p_147468_3_, Blocks.air, 0, 3); + } + + public boolean func_147480_a(int p_147480_1_, int p_147480_2_, int p_147480_3_, boolean p_147480_4_) + { + Block block = this.getBlock(p_147480_1_, p_147480_2_, p_147480_3_); + + if (block.getMaterial() == Material.air) + { + return false; + } + else + { + int l = this.getBlockMetadata(p_147480_1_, p_147480_2_, p_147480_3_); + this.playAuxSFX(2001, p_147480_1_, p_147480_2_, p_147480_3_, Block.getIdFromBlock(block) + (l << 12)); + + if (p_147480_4_) + { + block.dropBlockAsItem(this, p_147480_1_, p_147480_2_, p_147480_3_, l, 0); + } + + return this.setBlock(p_147480_1_, p_147480_2_, p_147480_3_, Blocks.air, 0, 3); + } + } + + public boolean setBlock(int p_147449_1_, int p_147449_2_, int p_147449_3_, Block p_147449_4_) + { + return this.setBlock(p_147449_1_, p_147449_2_, p_147449_3_, p_147449_4_, 0, 3); + } + + public void markBlockForUpdate(int p_147471_1_, int p_147471_2_, int p_147471_3_) + { + for (int l = 0; l < this.worldAccesses.size(); ++l) + { + ((IWorldAccess)this.worldAccesses.get(l)).markBlockForUpdate(p_147471_1_, p_147471_2_, p_147471_3_); + } + } + + public void notifyBlockChange(int p_147444_1_, int p_147444_2_, int p_147444_3_, Block p_147444_4_) + { + this.notifyBlocksOfNeighborChange(p_147444_1_, p_147444_2_, p_147444_3_, p_147444_4_); + } + + public void markBlocksDirtyVertical(int par1, int par2, int par3, int par4) + { + int i1; + + if (par3 > par4) + { + i1 = par4; + par4 = par3; + par3 = i1; + } + + if (!this.provider.hasNoSky) + { + for (i1 = par3; i1 <= par4; ++i1) + { + this.updateLightByType(EnumSkyBlock.Sky, par1, i1, par2); + } + } + + this.markBlockRangeForRenderUpdate(par1, par3, par2, par1, par4, par2); + } + + public void markBlockRangeForRenderUpdate(int p_147458_1_, int p_147458_2_, int p_147458_3_, int p_147458_4_, int p_147458_5_, int p_147458_6_) + { + for (int k1 = 0; k1 < this.worldAccesses.size(); ++k1) + { + ((IWorldAccess)this.worldAccesses.get(k1)).markBlockRangeForRenderUpdate(p_147458_1_, p_147458_2_, p_147458_3_, p_147458_4_, p_147458_5_, p_147458_6_); + } + } + + public void notifyBlocksOfNeighborChange(int p_147459_1_, int p_147459_2_, int p_147459_3_, Block p_147459_4_) + { + this.notifyBlockOfNeighborChange(p_147459_1_ - 1, p_147459_2_, p_147459_3_, p_147459_4_); + this.notifyBlockOfNeighborChange(p_147459_1_ + 1, p_147459_2_, p_147459_3_, p_147459_4_); + this.notifyBlockOfNeighborChange(p_147459_1_, p_147459_2_ - 1, p_147459_3_, p_147459_4_); + this.notifyBlockOfNeighborChange(p_147459_1_, p_147459_2_ + 1, p_147459_3_, p_147459_4_); + this.notifyBlockOfNeighborChange(p_147459_1_, p_147459_2_, p_147459_3_ - 1, p_147459_4_); + this.notifyBlockOfNeighborChange(p_147459_1_, p_147459_2_, p_147459_3_ + 1, p_147459_4_); + } + + public void notifyBlocksOfNeighborChange(int p_147441_1_, int p_147441_2_, int p_147441_3_, Block p_147441_4_, int p_147441_5_) + { + if (p_147441_5_ != 4) + { + this.notifyBlockOfNeighborChange(p_147441_1_ - 1, p_147441_2_, p_147441_3_, p_147441_4_); + } + + if (p_147441_5_ != 5) + { + this.notifyBlockOfNeighborChange(p_147441_1_ + 1, p_147441_2_, p_147441_3_, p_147441_4_); + } + + if (p_147441_5_ != 0) + { + this.notifyBlockOfNeighborChange(p_147441_1_, p_147441_2_ - 1, p_147441_3_, p_147441_4_); + } + + if (p_147441_5_ != 1) + { + this.notifyBlockOfNeighborChange(p_147441_1_, p_147441_2_ + 1, p_147441_3_, p_147441_4_); + } + + if (p_147441_5_ != 2) + { + this.notifyBlockOfNeighborChange(p_147441_1_, p_147441_2_, p_147441_3_ - 1, p_147441_4_); + } + + if (p_147441_5_ != 3) + { + this.notifyBlockOfNeighborChange(p_147441_1_, p_147441_2_, p_147441_3_ + 1, p_147441_4_); + } + } + + public void notifyBlockOfNeighborChange(int p_147460_1_, int p_147460_2_, int p_147460_3_, final Block p_147460_4_) + { + if (!this.isRemote) + { + Block block = this.getBlock(p_147460_1_, p_147460_2_, p_147460_3_); + + try + { + block.onNeighborBlockChange(this, p_147460_1_, p_147460_2_, p_147460_3_, p_147460_4_); + } + catch (Throwable throwable1) + { + CrashReport crashreport = CrashReport.makeCrashReport(throwable1, "Exception while updating neighbours"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("Block being updated"); + int l; + + try + { + l = this.getBlockMetadata(p_147460_1_, p_147460_2_, p_147460_3_); + } + catch (Throwable throwable) + { + l = -1; + } + + crashreportcategory.addCrashSectionCallable("Source block type", new Callable() + { + private static final String __OBFID = "CL_00000142"; + public String call() + { + try + { + return String.format("ID #%d (%s // %s)", new Object[] {Integer.valueOf(Block.getIdFromBlock(p_147460_4_)), p_147460_4_.getUnlocalizedName(), p_147460_4_.getClass().getCanonicalName()}); + } + catch (Throwable throwable2) + { + return "ID #" + Block.getIdFromBlock(p_147460_4_); + } + } + }); + CrashReportCategory.func_147153_a(crashreportcategory, p_147460_1_, p_147460_2_, p_147460_3_, block, l); + throw new ReportedException(crashreport); + } + } + } + + public boolean isBlockTickScheduledThisTick(int p_147477_1_, int p_147477_2_, int p_147477_3_, Block p_147477_4_) + { + return false; + } + + public boolean canBlockSeeTheSky(int par1, int par2, int par3) + { + return this.getChunkFromChunkCoords(par1 >> 4, par3 >> 4).canBlockSeeTheSky(par1 & 15, par2, par3 & 15); + } + + public int getFullBlockLightValue(int par1, int par2, int par3) + { + if (par2 < 0) + { + return 0; + } + else + { + if (par2 >= 256) + { + par2 = 255; + } + + return this.getChunkFromChunkCoords(par1 >> 4, par3 >> 4).getBlockLightValue(par1 & 15, par2, par3 & 15, 0); + } + } + + public int getBlockLightValue(int par1, int par2, int par3) + { + return this.getBlockLightValue_do(par1, par2, par3, true); + } + + public int getBlockLightValue_do(int par1, int par2, int par3, boolean par4) + { + if (par1 >= -30000000 && par3 >= -30000000 && par1 < 30000000 && par3 < 30000000) + { + if (par4 && this.getBlock(par1, par2, par3).getUseNeighborBrightness()) + { + int l1 = this.getBlockLightValue_do(par1, par2 + 1, par3, false); + int l = this.getBlockLightValue_do(par1 + 1, par2, par3, false); + int i1 = this.getBlockLightValue_do(par1 - 1, par2, par3, false); + int j1 = this.getBlockLightValue_do(par1, par2, par3 + 1, false); + int k1 = this.getBlockLightValue_do(par1, par2, par3 - 1, false); + + if (l > l1) + { + l1 = l; + } + + if (i1 > l1) + { + l1 = i1; + } + + if (j1 > l1) + { + l1 = j1; + } + + if (k1 > l1) + { + l1 = k1; + } + + return l1; + } + else if (par2 < 0) + { + return 0; + } + else + { + if (par2 >= 256) + { + par2 = 255; + } + + Chunk chunk = this.getChunkFromChunkCoords(par1 >> 4, par3 >> 4); + par1 &= 15; + par3 &= 15; + return chunk.getBlockLightValue(par1, par2, par3, this.skylightSubtracted); + } + } + else + { + return 15; + } + } + + public int getHeightValue(int par1, int par2) + { + if (par1 >= -30000000 && par2 >= -30000000 && par1 < 30000000 && par2 < 30000000) + { + if (!this.chunkExists(par1 >> 4, par2 >> 4)) + { + return 0; + } + else + { + Chunk chunk = this.getChunkFromChunkCoords(par1 >> 4, par2 >> 4); + return chunk.getHeightValue(par1 & 15, par2 & 15); + } + } + else + { + return 64; + } + } + + public int getChunkHeightMapMinimum(int par1, int par2) + { + if (par1 >= -30000000 && par2 >= -30000000 && par1 < 30000000 && par2 < 30000000) + { + if (!this.chunkExists(par1 >> 4, par2 >> 4)) + { + return 0; + } + else + { + Chunk chunk = this.getChunkFromChunkCoords(par1 >> 4, par2 >> 4); + return chunk.heightMapMinimum; + } + } + else + { + return 64; + } + } + + @SideOnly(Side.CLIENT) + public int getSkyBlockTypeBrightness(EnumSkyBlock par1EnumSkyBlock, int par2, int par3, int par4) + { + if (this.provider.hasNoSky && par1EnumSkyBlock == EnumSkyBlock.Sky) + { + return 0; + } + else + { + if (par3 < 0) + { + par3 = 0; + } + + if (par3 >= 256) + { + return par1EnumSkyBlock.defaultLightValue; + } + else if (par2 >= -30000000 && par4 >= -30000000 && par2 < 30000000 && par4 < 30000000) + { + int l = par2 >> 4; + int i1 = par4 >> 4; + + if (!this.chunkExists(l, i1)) + { + return par1EnumSkyBlock.defaultLightValue; + } + else if (this.getBlock(par2, par3, par4).getUseNeighborBrightness()) + { + int j2 = this.getSavedLightValue(par1EnumSkyBlock, par2, par3 + 1, par4); + int j1 = this.getSavedLightValue(par1EnumSkyBlock, par2 + 1, par3, par4); + int k1 = this.getSavedLightValue(par1EnumSkyBlock, par2 - 1, par3, par4); + int l1 = this.getSavedLightValue(par1EnumSkyBlock, par2, par3, par4 + 1); + int i2 = this.getSavedLightValue(par1EnumSkyBlock, par2, par3, par4 - 1); + + if (j1 > j2) + { + j2 = j1; + } + + if (k1 > j2) + { + j2 = k1; + } + + if (l1 > j2) + { + j2 = l1; + } + + if (i2 > j2) + { + j2 = i2; + } + + return j2; + } + else + { + Chunk chunk = this.getChunkFromChunkCoords(l, i1); + return chunk.getSavedLightValue(par1EnumSkyBlock, par2 & 15, par3, par4 & 15); + } + } + else + { + return par1EnumSkyBlock.defaultLightValue; + } + } + } + + public int getSavedLightValue(EnumSkyBlock par1EnumSkyBlock, int par2, int par3, int par4) + { + if (par3 < 0) + { + par3 = 0; + } + + if (par3 >= 256) + { + par3 = 255; + } + + if (par2 >= -30000000 && par4 >= -30000000 && par2 < 30000000 && par4 < 30000000) + { + int l = par2 >> 4; + int i1 = par4 >> 4; + + if (!this.chunkExists(l, i1)) + { + return par1EnumSkyBlock.defaultLightValue; + } + else + { + Chunk chunk = this.getChunkFromChunkCoords(l, i1); + return chunk.getSavedLightValue(par1EnumSkyBlock, par2 & 15, par3, par4 & 15); + } + } + else + { + return par1EnumSkyBlock.defaultLightValue; + } + } + + public void setLightValue(EnumSkyBlock par1EnumSkyBlock, int par2, int par3, int par4, int par5) + { + if (par2 >= -30000000 && par4 >= -30000000 && par2 < 30000000 && par4 < 30000000) + { + if (par3 >= 0) + { + if (par3 < 256) + { + if (this.chunkExists(par2 >> 4, par4 >> 4)) + { + Chunk chunk = this.getChunkFromChunkCoords(par2 >> 4, par4 >> 4); + chunk.setLightValue(par1EnumSkyBlock, par2 & 15, par3, par4 & 15, par5); + + for (int i1 = 0; i1 < this.worldAccesses.size(); ++i1) + { + ((IWorldAccess)this.worldAccesses.get(i1)).markBlockForRenderUpdate(par2, par3, par4); + } + } + } + } + } + } + + public void func_147479_m(int p_147479_1_, int p_147479_2_, int p_147479_3_) + { + for (int l = 0; l < this.worldAccesses.size(); ++l) + { + ((IWorldAccess)this.worldAccesses.get(l)).markBlockForRenderUpdate(p_147479_1_, p_147479_2_, p_147479_3_); + } + } + + @SideOnly(Side.CLIENT) + public int getLightBrightnessForSkyBlocks(int par1, int par2, int par3, int par4) + { + int i1 = this.getSkyBlockTypeBrightness(EnumSkyBlock.Sky, par1, par2, par3); + int j1 = this.getSkyBlockTypeBrightness(EnumSkyBlock.Block, par1, par2, par3); + + if (j1 < par4) + { + j1 = par4; + } + + return i1 << 20 | j1 << 4; + } + + public float getLightBrightness(int par1, int par2, int par3) + { + return this.provider.lightBrightnessTable[this.getBlockLightValue(par1, par2, par3)]; + } + + public boolean isDaytime() + { + return provider.isDaytime(); + } + + public MovingObjectPosition rayTraceBlocks(Vec3 par1Vec3, Vec3 par2Vec3) + { + return this.func_147447_a(par1Vec3, par2Vec3, false, false, false); + } + + public MovingObjectPosition rayTraceBlocks(Vec3 par1Vec3, Vec3 par2Vec3, boolean par3) + { + return this.func_147447_a(par1Vec3, par2Vec3, par3, false, false); + } + + public MovingObjectPosition func_147447_a(Vec3 p_147447_1_, Vec3 p_147447_2_, boolean p_147447_3_, boolean p_147447_4_, boolean p_147447_5_) + { + if (!Double.isNaN(p_147447_1_.xCoord) && !Double.isNaN(p_147447_1_.yCoord) && !Double.isNaN(p_147447_1_.zCoord)) + { + if (!Double.isNaN(p_147447_2_.xCoord) && !Double.isNaN(p_147447_2_.yCoord) && !Double.isNaN(p_147447_2_.zCoord)) + { + int i = MathHelper.floor_double(p_147447_2_.xCoord); + int j = MathHelper.floor_double(p_147447_2_.yCoord); + int k = MathHelper.floor_double(p_147447_2_.zCoord); + int l = MathHelper.floor_double(p_147447_1_.xCoord); + int i1 = MathHelper.floor_double(p_147447_1_.yCoord); + int j1 = MathHelper.floor_double(p_147447_1_.zCoord); + Block block = this.getBlock(l, i1, j1); + int k1 = this.getBlockMetadata(l, i1, j1); + + if ((!p_147447_4_ || block.getCollisionBoundingBoxFromPool(this, l, i1, j1) != null) && block.canCollideCheck(k1, p_147447_3_)) + { + MovingObjectPosition movingobjectposition = block.collisionRayTrace(this, l, i1, j1, p_147447_1_, p_147447_2_); + + if (movingobjectposition != null) + { + return movingobjectposition; + } + } + + MovingObjectPosition movingobjectposition2 = null; + k1 = 200; + + while (k1-- >= 0) + { + if (Double.isNaN(p_147447_1_.xCoord) || Double.isNaN(p_147447_1_.yCoord) || Double.isNaN(p_147447_1_.zCoord)) + { + return null; + } + + if (l == i && i1 == j && j1 == k) + { + return p_147447_5_ ? movingobjectposition2 : null; + } + + boolean flag6 = true; + boolean flag3 = true; + boolean flag4 = true; + double d0 = 999.0D; + double d1 = 999.0D; + double d2 = 999.0D; + + if (i > l) + { + d0 = (double)l + 1.0D; + } + else if (i < l) + { + d0 = (double)l + 0.0D; + } + else + { + flag6 = false; + } + + if (j > i1) + { + d1 = (double)i1 + 1.0D; + } + else if (j < i1) + { + d1 = (double)i1 + 0.0D; + } + else + { + flag3 = false; + } + + if (k > j1) + { + d2 = (double)j1 + 1.0D; + } + else if (k < j1) + { + d2 = (double)j1 + 0.0D; + } + else + { + flag4 = false; + } + + double d3 = 999.0D; + double d4 = 999.0D; + double d5 = 999.0D; + double d6 = p_147447_2_.xCoord - p_147447_1_.xCoord; + double d7 = p_147447_2_.yCoord - p_147447_1_.yCoord; + double d8 = p_147447_2_.zCoord - p_147447_1_.zCoord; + + if (flag6) + { + d3 = (d0 - p_147447_1_.xCoord) / d6; + } + + if (flag3) + { + d4 = (d1 - p_147447_1_.yCoord) / d7; + } + + if (flag4) + { + d5 = (d2 - p_147447_1_.zCoord) / d8; + } + + boolean flag5 = false; + byte b0; + + if (d3 < d4 && d3 < d5) + { + if (i > l) + { + b0 = 4; + } + else + { + b0 = 5; + } + + p_147447_1_.xCoord = d0; + p_147447_1_.yCoord += d7 * d3; + p_147447_1_.zCoord += d8 * d3; + } + else if (d4 < d5) + { + if (j > i1) + { + b0 = 0; + } + else + { + b0 = 1; + } + + p_147447_1_.xCoord += d6 * d4; + p_147447_1_.yCoord = d1; + p_147447_1_.zCoord += d8 * d4; + } + else + { + if (k > j1) + { + b0 = 2; + } + else + { + b0 = 3; + } + + p_147447_1_.xCoord += d6 * d5; + p_147447_1_.yCoord += d7 * d5; + p_147447_1_.zCoord = d2; + } + + Vec3 vec32 = this.getWorldVec3Pool().getVecFromPool(p_147447_1_.xCoord, p_147447_1_.yCoord, p_147447_1_.zCoord); + l = (int)(vec32.xCoord = (double)MathHelper.floor_double(p_147447_1_.xCoord)); + + if (b0 == 5) + { + --l; + ++vec32.xCoord; + } + + i1 = (int)(vec32.yCoord = (double)MathHelper.floor_double(p_147447_1_.yCoord)); + + if (b0 == 1) + { + --i1; + ++vec32.yCoord; + } + + j1 = (int)(vec32.zCoord = (double)MathHelper.floor_double(p_147447_1_.zCoord)); + + if (b0 == 3) + { + --j1; + ++vec32.zCoord; + } + + Block block1 = this.getBlock(l, i1, j1); + int l1 = this.getBlockMetadata(l, i1, j1); + + if (!p_147447_4_ || block1.getCollisionBoundingBoxFromPool(this, l, i1, j1) != null) + { + if (block1.canCollideCheck(l1, p_147447_3_)) + { + MovingObjectPosition movingobjectposition1 = block1.collisionRayTrace(this, l, i1, j1, p_147447_1_, p_147447_2_); + + if (movingobjectposition1 != null) + { + return movingobjectposition1; + } + } + else + { + movingobjectposition2 = new MovingObjectPosition(l, i1, j1, b0, p_147447_1_, false); + } + } + } + + return p_147447_5_ ? movingobjectposition2 : null; + } + else + { + return null; + } + } + else + { + return null; + } + } + + public void playSoundAtEntity(Entity par1Entity, String par2Str, float par3, float par4) + { + PlaySoundAtEntityEvent event = new PlaySoundAtEntityEvent(par1Entity, par2Str, par3, par4); + if (MinecraftForge.EVENT_BUS.post(event)) + { + return; + } + par2Str = event.name; + for (int i = 0; i < this.worldAccesses.size(); ++i) + { + ((IWorldAccess)this.worldAccesses.get(i)).playSound(par2Str, par1Entity.posX, par1Entity.posY - (double)par1Entity.yOffset, par1Entity.posZ, par3, par4); + } + } + + public void playSoundToNearExcept(EntityPlayer par1EntityPlayer, String par2Str, float par3, float par4) + { + PlaySoundAtEntityEvent event = new PlaySoundAtEntityEvent(par1EntityPlayer, par2Str, par3, par4); + if (MinecraftForge.EVENT_BUS.post(event)) + { + return; + } + par2Str = event.name; + for (int i = 0; i < this.worldAccesses.size(); ++i) + { + ((IWorldAccess)this.worldAccesses.get(i)).playSoundToNearExcept(par1EntityPlayer, par2Str, par1EntityPlayer.posX, par1EntityPlayer.posY - (double)par1EntityPlayer.yOffset, par1EntityPlayer.posZ, par3, par4); + } + } + + public void playSoundEffect(double par1, double par3, double par5, String par7Str, float par8, float par9) + { + for (int i = 0; i < this.worldAccesses.size(); ++i) + { + ((IWorldAccess)this.worldAccesses.get(i)).playSound(par7Str, par1, par3, par5, par8, par9); + } + } + + public void playSound(double par1, double par3, double par5, String par7Str, float par8, float par9, boolean par10) {} + + public void playRecord(String par1Str, int par2, int par3, int par4) + { + for (int l = 0; l < this.worldAccesses.size(); ++l) + { + ((IWorldAccess)this.worldAccesses.get(l)).playRecord(par1Str, par2, par3, par4); + } + } + + public void spawnParticle(String par1Str, double par2, double par4, double par6, double par8, double par10, double par12) + { + for (int i = 0; i < this.worldAccesses.size(); ++i) + { + ((IWorldAccess)this.worldAccesses.get(i)).spawnParticle(par1Str, par2, par4, par6, par8, par10, par12); + } + } + + public boolean addWeatherEffect(Entity par1Entity) + { + this.weatherEffects.add(par1Entity); + return true; + } + + public boolean spawnEntityInWorld(Entity par1Entity) + { + int i = MathHelper.floor_double(par1Entity.posX / 16.0D); + int j = MathHelper.floor_double(par1Entity.posZ / 16.0D); + boolean flag = par1Entity.forceSpawn; + + if (par1Entity instanceof EntityPlayer) + { + flag = true; + } + + if (!flag && !this.chunkExists(i, j)) + { + return false; + } + else + { + if (par1Entity instanceof EntityPlayer) + { + EntityPlayer entityplayer = (EntityPlayer)par1Entity; + this.playerEntities.add(entityplayer); + this.updateAllPlayersSleepingFlag(); + } + if (MinecraftForge.EVENT_BUS.post(new EntityJoinWorldEvent(par1Entity, this)) && !flag) return false; + + this.getChunkFromChunkCoords(i, j).addEntity(par1Entity); + this.loadedEntityList.add(par1Entity); + this.onEntityAdded(par1Entity); + return true; + } + } + + public void onEntityAdded(Entity par1Entity) + { + for (int i = 0; i < this.worldAccesses.size(); ++i) + { + ((IWorldAccess)this.worldAccesses.get(i)).onEntityCreate(par1Entity); + } + } + + public void onEntityRemoved(Entity par1Entity) + { + for (int i = 0; i < this.worldAccesses.size(); ++i) + { + ((IWorldAccess)this.worldAccesses.get(i)).onEntityDestroy(par1Entity); + } + } + + public void removeEntity(Entity par1Entity) + { + if (par1Entity.riddenByEntity != null) + { + par1Entity.riddenByEntity.mountEntity((Entity)null); + } + + if (par1Entity.ridingEntity != null) + { + par1Entity.mountEntity((Entity)null); + } + + par1Entity.setDead(); + + if (par1Entity instanceof EntityPlayer) + { + this.playerEntities.remove(par1Entity); + this.updateAllPlayersSleepingFlag(); + } + } + + public void removePlayerEntityDangerously(Entity par1Entity) + { + par1Entity.setDead(); + + if (par1Entity instanceof EntityPlayer) + { + this.playerEntities.remove(par1Entity); + this.updateAllPlayersSleepingFlag(); + } + + int i = par1Entity.chunkCoordX; + int j = par1Entity.chunkCoordZ; + + if (par1Entity.addedToChunk && this.chunkExists(i, j)) + { + this.getChunkFromChunkCoords(i, j).removeEntity(par1Entity); + } + + this.loadedEntityList.remove(par1Entity); + this.onEntityRemoved(par1Entity); + } + + public void addWorldAccess(IWorldAccess par1IWorldAccess) + { + this.worldAccesses.add(par1IWorldAccess); + } + + public List getCollidingBoundingBoxes(Entity par1Entity, AxisAlignedBB par2AxisAlignedBB) + { + this.collidingBoundingBoxes.clear(); + int i = MathHelper.floor_double(par2AxisAlignedBB.minX); + int j = MathHelper.floor_double(par2AxisAlignedBB.maxX + 1.0D); + int k = MathHelper.floor_double(par2AxisAlignedBB.minY); + int l = MathHelper.floor_double(par2AxisAlignedBB.maxY + 1.0D); + int i1 = MathHelper.floor_double(par2AxisAlignedBB.minZ); + int j1 = MathHelper.floor_double(par2AxisAlignedBB.maxZ + 1.0D); + + for (int k1 = i; k1 < j; ++k1) + { + for (int l1 = i1; l1 < j1; ++l1) + { + if (this.blockExists(k1, 64, l1)) + { + for (int i2 = k - 1; i2 < l; ++i2) + { + Block block; + + if (k1 >= -30000000 && k1 < 30000000 && l1 >= -30000000 && l1 < 30000000) + { + block = this.getBlock(k1, i2, l1); + } + else + { + block = Blocks.stone; + } + + block.addCollisionBoxesToList(this, k1, i2, l1, par2AxisAlignedBB, this.collidingBoundingBoxes, par1Entity); + } + } + } + } + + double d0 = 0.25D; + List list = this.getEntitiesWithinAABBExcludingEntity(par1Entity, par2AxisAlignedBB.expand(d0, d0, d0)); + + for (int j2 = 0; j2 < list.size(); ++j2) + { + AxisAlignedBB axisalignedbb1 = ((Entity)list.get(j2)).getBoundingBox(); + + if (axisalignedbb1 != null && axisalignedbb1.intersectsWith(par2AxisAlignedBB)) + { + this.collidingBoundingBoxes.add(axisalignedbb1); + } + + axisalignedbb1 = par1Entity.getCollisionBox((Entity)list.get(j2)); + + if (axisalignedbb1 != null && axisalignedbb1.intersectsWith(par2AxisAlignedBB)) + { + this.collidingBoundingBoxes.add(axisalignedbb1); + } + } + + return this.collidingBoundingBoxes; + } + + public List func_147461_a(AxisAlignedBB p_147461_1_) + { + this.collidingBoundingBoxes.clear(); + int i = MathHelper.floor_double(p_147461_1_.minX); + int j = MathHelper.floor_double(p_147461_1_.maxX + 1.0D); + int k = MathHelper.floor_double(p_147461_1_.minY); + int l = MathHelper.floor_double(p_147461_1_.maxY + 1.0D); + int i1 = MathHelper.floor_double(p_147461_1_.minZ); + int j1 = MathHelper.floor_double(p_147461_1_.maxZ + 1.0D); + + for (int k1 = i; k1 < j; ++k1) + { + for (int l1 = i1; l1 < j1; ++l1) + { + if (this.blockExists(k1, 64, l1)) + { + for (int i2 = k - 1; i2 < l; ++i2) + { + Block block; + + if (k1 >= -30000000 && k1 < 30000000 && l1 >= -30000000 && l1 < 30000000) + { + block = this.getBlock(k1, i2, l1); + } + else + { + block = Blocks.bedrock; + } + + block.addCollisionBoxesToList(this, k1, i2, l1, p_147461_1_, this.collidingBoundingBoxes, (Entity)null); + } + } + } + } + + return this.collidingBoundingBoxes; + } + + public int calculateSkylightSubtracted(float par1) + { + float f1 = this.getCelestialAngle(par1); + float f2 = 1.0F - (MathHelper.cos(f1 * (float)Math.PI * 2.0F) * 2.0F + 0.5F); + + if (f2 < 0.0F) + { + f2 = 0.0F; + } + + if (f2 > 1.0F) + { + f2 = 1.0F; + } + + f2 = 1.0F - f2; + f2 = (float)((double)f2 * (1.0D - (double)(this.getRainStrength(par1) * 5.0F) / 16.0D)); + f2 = (float)((double)f2 * (1.0D - (double)(this.getWeightedThunderStrength(par1) * 5.0F) / 16.0D)); + f2 = 1.0F - f2; + return (int)(f2 * 11.0F); + } + + public void removeWorldAccess(IWorldAccess par1IWorldAccess) + { + this.worldAccesses.remove(par1IWorldAccess); + } + + @SideOnly(Side.CLIENT) + public float getSunBrightness(float par1) + { + float f1 = this.getCelestialAngle(par1); + float f2 = 1.0F - (MathHelper.cos(f1 * (float)Math.PI * 2.0F) * 2.0F + 0.2F); + + if (f2 < 0.0F) + { + f2 = 0.0F; + } + + if (f2 > 1.0F) + { + f2 = 1.0F; + } + + f2 = 1.0F - f2; + f2 = (float)((double)f2 * (1.0D - (double)(this.getRainStrength(par1) * 5.0F) / 16.0D)); + f2 = (float)((double)f2 * (1.0D - (double)(this.getWeightedThunderStrength(par1) * 5.0F) / 16.0D)); + return f2 * 0.8F + 0.2F; + } + + @SideOnly(Side.CLIENT) + public Vec3 getSkyColor(Entity par1Entity, float par2) + { + return provider.getSkyColor(par1Entity, par2); + } + + @SideOnly(Side.CLIENT) + public Vec3 getSkyColorBody(Entity par1Entity, float par2) + { + float f1 = this.getCelestialAngle(par2); + float f2 = MathHelper.cos(f1 * (float)Math.PI * 2.0F) * 2.0F + 0.5F; + + if (f2 < 0.0F) + { + f2 = 0.0F; + } + + if (f2 > 1.0F) + { + f2 = 1.0F; + } + + int i = MathHelper.floor_double(par1Entity.posX); + int j = MathHelper.floor_double(par1Entity.posY); + int k = MathHelper.floor_double(par1Entity.posZ); + int l = ForgeHooksClient.getSkyBlendColour(this, i, j, k); + float f4 = (float)(l >> 16 & 255) / 255.0F; + float f5 = (float)(l >> 8 & 255) / 255.0F; + float f6 = (float)(l & 255) / 255.0F; + f4 *= f2; + f5 *= f2; + f6 *= f2; + float f7 = this.getRainStrength(par2); + float f8; + float f9; + + if (f7 > 0.0F) + { + f8 = (f4 * 0.3F + f5 * 0.59F + f6 * 0.11F) * 0.6F; + f9 = 1.0F - f7 * 0.75F; + f4 = f4 * f9 + f8 * (1.0F - f9); + f5 = f5 * f9 + f8 * (1.0F - f9); + f6 = f6 * f9 + f8 * (1.0F - f9); + } + + f8 = this.getWeightedThunderStrength(par2); + + if (f8 > 0.0F) + { + f9 = (f4 * 0.3F + f5 * 0.59F + f6 * 0.11F) * 0.2F; + float f10 = 1.0F - f8 * 0.75F; + f4 = f4 * f10 + f9 * (1.0F - f10); + f5 = f5 * f10 + f9 * (1.0F - f10); + f6 = f6 * f10 + f9 * (1.0F - f10); + } + + if (this.lastLightningBolt > 0) + { + f9 = (float)this.lastLightningBolt - par2; + + if (f9 > 1.0F) + { + f9 = 1.0F; + } + + f9 *= 0.45F; + f4 = f4 * (1.0F - f9) + 0.8F * f9; + f5 = f5 * (1.0F - f9) + 0.8F * f9; + f6 = f6 * (1.0F - f9) + 1.0F * f9; + } + + return this.getWorldVec3Pool().getVecFromPool((double)f4, (double)f5, (double)f6); + } + + public float getCelestialAngle(float par1) + { + return this.provider.calculateCelestialAngle(this.worldInfo.getWorldTime(), par1); + } + + @SideOnly(Side.CLIENT) + public int getMoonPhase() + { + return this.provider.getMoonPhase(this.worldInfo.getWorldTime()); + } + + public float getCurrentMoonPhaseFactor() + { + return WorldProvider.moonPhaseFactors[this.provider.getMoonPhase(this.worldInfo.getWorldTime())]; + } + + public float getCelestialAngleRadians(float par1) + { + float f1 = this.getCelestialAngle(par1); + return f1 * (float)Math.PI * 2.0F; + } + + @SideOnly(Side.CLIENT) + public Vec3 getCloudColour(float par1) + { + return provider.drawClouds(par1); + } + + @SideOnly(Side.CLIENT) + public Vec3 drawCloudsBody(float par1) + { + float f1 = this.getCelestialAngle(par1); + float f2 = MathHelper.cos(f1 * (float)Math.PI * 2.0F) * 2.0F + 0.5F; + + if (f2 < 0.0F) + { + f2 = 0.0F; + } + + if (f2 > 1.0F) + { + f2 = 1.0F; + } + + float f3 = (float)(this.cloudColour >> 16 & 255L) / 255.0F; + float f4 = (float)(this.cloudColour >> 8 & 255L) / 255.0F; + float f5 = (float)(this.cloudColour & 255L) / 255.0F; + float f6 = this.getRainStrength(par1); + float f7; + float f8; + + if (f6 > 0.0F) + { + f7 = (f3 * 0.3F + f4 * 0.59F + f5 * 0.11F) * 0.6F; + f8 = 1.0F - f6 * 0.95F; + f3 = f3 * f8 + f7 * (1.0F - f8); + f4 = f4 * f8 + f7 * (1.0F - f8); + f5 = f5 * f8 + f7 * (1.0F - f8); + } + + f3 *= f2 * 0.9F + 0.1F; + f4 *= f2 * 0.9F + 0.1F; + f5 *= f2 * 0.85F + 0.15F; + f7 = this.getWeightedThunderStrength(par1); + + if (f7 > 0.0F) + { + f8 = (f3 * 0.3F + f4 * 0.59F + f5 * 0.11F) * 0.2F; + float f9 = 1.0F - f7 * 0.95F; + f3 = f3 * f9 + f8 * (1.0F - f9); + f4 = f4 * f9 + f8 * (1.0F - f9); + f5 = f5 * f9 + f8 * (1.0F - f9); + } + + return this.getWorldVec3Pool().getVecFromPool((double)f3, (double)f4, (double)f5); + } + + @SideOnly(Side.CLIENT) + public Vec3 getFogColor(float par1) + { + float f1 = this.getCelestialAngle(par1); + return this.provider.getFogColor(f1, par1); + } + + public int getPrecipitationHeight(int par1, int par2) + { + return this.getChunkFromBlockCoords(par1, par2).getPrecipitationHeight(par1 & 15, par2 & 15); + } + + public int getTopSolidOrLiquidBlock(int par1, int par2) + { + Chunk chunk = this.getChunkFromBlockCoords(par1, par2); + int x = par1; + int z = par2; + int k = chunk.getTopFilledSegment() + 15; + par1 &= 15; + + for (par2 &= 15; k > 0; --k) + { + Block block = chunk.getBlock(par1, k, par2); + + if (block.getMaterial().blocksMovement() && block.getMaterial() != Material.leaves && !block.isFoliage(this, x, k, z)) + { + return k + 1; + } + } + + return -1; + } + + @SideOnly(Side.CLIENT) + public float getStarBrightness(float par1) + { + return provider.getStarBrightness(par1); + } + + @SideOnly(Side.CLIENT) + public float getStarBrightnessBody(float par1) + { + float f1 = this.getCelestialAngle(par1); + float f2 = 1.0F - (MathHelper.cos(f1 * (float)Math.PI * 2.0F) * 2.0F + 0.25F); + + if (f2 < 0.0F) + { + f2 = 0.0F; + } + + if (f2 > 1.0F) + { + f2 = 1.0F; + } + + return f2 * f2 * 0.5F; + } + + public void scheduleBlockUpdate(int p_147464_1_, int p_147464_2_, int p_147464_3_, Block p_147464_4_, int p_147464_5_) {} + + public void scheduleBlockUpdateWithPriority(int p_147454_1_, int p_147454_2_, int p_147454_3_, Block p_147454_4_, int p_147454_5_, int p_147454_6_) {} + + public void func_147446_b(int p_147446_1_, int p_147446_2_, int p_147446_3_, Block p_147446_4_, int p_147446_5_, int p_147446_6_) {} + + public void updateEntities() + { + this.theProfiler.startSection("entities"); + this.theProfiler.startSection("global"); + int i; + Entity entity; + CrashReport crashreport; + CrashReportCategory crashreportcategory; + + for (i = 0; i < this.weatherEffects.size(); ++i) + { + entity = (Entity)this.weatherEffects.get(i); + + try + { + ++entity.ticksExisted; + entity.onUpdate(); + } + catch (Throwable throwable2) + { + crashreport = CrashReport.makeCrashReport(throwable2, "Ticking entity"); + crashreportcategory = crashreport.makeCategory("Entity being ticked"); + + if (entity == null) + { + crashreportcategory.addCrashSection("Entity", "~~NULL~~"); + } + else + { + entity.addEntityCrashInfo(crashreportcategory); + } + + if (ForgeModContainer.removeErroringEntities) + { + FMLLog.severe(crashreport.getCompleteReport()); + removeEntity(entity); + } + else + { + throw new ReportedException(crashreport); + } + } + + if (entity.isDead) + { + this.weatherEffects.remove(i--); + } + } + + this.theProfiler.endStartSection("remove"); + this.loadedEntityList.removeAll(this.unloadedEntityList); + int j; + int l; + + for (i = 0; i < this.unloadedEntityList.size(); ++i) + { + entity = (Entity)this.unloadedEntityList.get(i); + j = entity.chunkCoordX; + l = entity.chunkCoordZ; + + if (entity.addedToChunk && this.chunkExists(j, l)) + { + this.getChunkFromChunkCoords(j, l).removeEntity(entity); + } + } + + for (i = 0; i < this.unloadedEntityList.size(); ++i) + { + this.onEntityRemoved((Entity)this.unloadedEntityList.get(i)); + } + + this.unloadedEntityList.clear(); + this.theProfiler.endStartSection("regular"); + + for (i = 0; i < this.loadedEntityList.size(); ++i) + { + entity = (Entity)this.loadedEntityList.get(i); + + if (entity.ridingEntity != null) + { + if (!entity.ridingEntity.isDead && entity.ridingEntity.riddenByEntity == entity) + { + continue; + } + + entity.ridingEntity.riddenByEntity = null; + entity.ridingEntity = null; + } + + this.theProfiler.startSection("tick"); + + if (!entity.isDead) + { + try + { + this.updateEntity(entity); + } + catch (Throwable throwable1) + { + crashreport = CrashReport.makeCrashReport(throwable1, "Ticking entity"); + crashreportcategory = crashreport.makeCategory("Entity being ticked"); + entity.addEntityCrashInfo(crashreportcategory); + + if (ForgeModContainer.removeErroringEntities) + { + FMLLog.severe(crashreport.getCompleteReport()); + removeEntity(entity); + } + else + { + throw new ReportedException(crashreport); + } + } + } + + this.theProfiler.endSection(); + this.theProfiler.startSection("remove"); + + if (entity.isDead) + { + j = entity.chunkCoordX; + l = entity.chunkCoordZ; + + if (entity.addedToChunk && this.chunkExists(j, l)) + { + this.getChunkFromChunkCoords(j, l).removeEntity(entity); + } + + this.loadedEntityList.remove(i--); + this.onEntityRemoved(entity); + } + + this.theProfiler.endSection(); + } + + this.theProfiler.endStartSection("blockEntities"); + this.field_147481_N = true; + Iterator iterator = this.loadedTileEntityList.iterator(); + + while (iterator.hasNext()) + { + TileEntity tileentity = (TileEntity)iterator.next(); + + if (!tileentity.isInvalid() && tileentity.hasWorldObj() && this.blockExists(tileentity.xCoord, tileentity.yCoord, tileentity.zCoord)) + { + try + { + tileentity.updateEntity(); + } + catch (Throwable throwable) + { + crashreport = CrashReport.makeCrashReport(throwable, "Ticking block entity"); + crashreportcategory = crashreport.makeCategory("Block entity being ticked"); + tileentity.func_145828_a(crashreportcategory); + if (ForgeModContainer.removeErroringTileEntities) + { + FMLLog.severe(crashreport.getCompleteReport()); + tileentity.invalidate(); + setBlockToAir(tileentity.xCoord, tileentity.yCoord, tileentity.zCoord); + } + else + { + throw new ReportedException(crashreport); + } + } + } + + if (tileentity.isInvalid()) + { + iterator.remove(); + + if (this.chunkExists(tileentity.xCoord >> 4, tileentity.zCoord >> 4)) + { + Chunk chunk = this.getChunkFromChunkCoords(tileentity.xCoord >> 4, tileentity.zCoord >> 4); + + if (chunk != null) + { + chunk.removeInvalidTileEntity(tileentity.xCoord & 15, tileentity.yCoord, tileentity.zCoord & 15); + } + } + } + } + + if (!this.field_147483_b.isEmpty()) + { + for (Object tile : field_147483_b) + { + ((TileEntity)tile).onChunkUnload(); + } + this.loadedTileEntityList.removeAll(this.field_147483_b); + this.field_147483_b.clear(); + } + + this.field_147481_N = false; + + this.theProfiler.endStartSection("pendingBlockEntities"); + + if (!this.addedTileEntityList.isEmpty()) + { + for (int k = 0; k < this.addedTileEntityList.size(); ++k) + { + TileEntity tileentity1 = (TileEntity)this.addedTileEntityList.get(k); + + if (!tileentity1.isInvalid()) + { + if (!this.loadedTileEntityList.contains(tileentity1)) + { + this.loadedTileEntityList.add(tileentity1); + } + } + else + { + if (this.chunkExists(tileentity1.xCoord >> 4, tileentity1.zCoord >> 4)) + { + Chunk chunk1 = this.getChunkFromChunkCoords(tileentity1.xCoord >> 4, tileentity1.zCoord >> 4); + + if (chunk1 != null) + { + chunk1.removeInvalidTileEntity(tileentity1.xCoord & 15, tileentity1.yCoord, tileentity1.zCoord & 15); + } + } + } + } + + this.addedTileEntityList.clear(); + } + + this.theProfiler.endSection(); + this.theProfiler.endSection(); + } + + public void func_147448_a(Collection p_147448_1_) + { + List dest = field_147481_N ? addedTileEntityList : loadedTileEntityList; + for(TileEntity entity : (Collection)p_147448_1_) + { + if(entity.canUpdate()) dest.add(entity); + } + } + + public void updateEntity(Entity par1Entity) + { + this.updateEntityWithOptionalForce(par1Entity, true); + } + + public void updateEntityWithOptionalForce(Entity par1Entity, boolean par2) + { + int i = MathHelper.floor_double(par1Entity.posX); + int j = MathHelper.floor_double(par1Entity.posZ); + boolean isForced = getPersistentChunks().containsKey(new ChunkCoordIntPair(i >> 4, j >> 4)); + byte b0 = isForced ? (byte)0 : 32; + boolean canUpdate = !par2 || this.checkChunksExist(i - b0, 0, j - b0, i + b0, 0, j + b0); + + if (!canUpdate) + { + EntityEvent.CanUpdate event = new EntityEvent.CanUpdate(par1Entity); + MinecraftForge.EVENT_BUS.post(event); + canUpdate = event.canUpdate; + } + + if (canUpdate) + { + par1Entity.lastTickPosX = par1Entity.posX; + par1Entity.lastTickPosY = par1Entity.posY; + par1Entity.lastTickPosZ = par1Entity.posZ; + par1Entity.prevRotationYaw = par1Entity.rotationYaw; + par1Entity.prevRotationPitch = par1Entity.rotationPitch; + + if (par2 && par1Entity.addedToChunk) + { + ++par1Entity.ticksExisted; + + if (par1Entity.ridingEntity != null) + { + par1Entity.updateRidden(); + } + else + { + par1Entity.onUpdate(); + } + } + + this.theProfiler.startSection("chunkCheck"); + + if (Double.isNaN(par1Entity.posX) || Double.isInfinite(par1Entity.posX)) + { + par1Entity.posX = par1Entity.lastTickPosX; + } + + if (Double.isNaN(par1Entity.posY) || Double.isInfinite(par1Entity.posY)) + { + par1Entity.posY = par1Entity.lastTickPosY; + } + + if (Double.isNaN(par1Entity.posZ) || Double.isInfinite(par1Entity.posZ)) + { + par1Entity.posZ = par1Entity.lastTickPosZ; + } + + if (Double.isNaN((double)par1Entity.rotationPitch) || Double.isInfinite((double)par1Entity.rotationPitch)) + { + par1Entity.rotationPitch = par1Entity.prevRotationPitch; + } + + if (Double.isNaN((double)par1Entity.rotationYaw) || Double.isInfinite((double)par1Entity.rotationYaw)) + { + par1Entity.rotationYaw = par1Entity.prevRotationYaw; + } + + int k = MathHelper.floor_double(par1Entity.posX / 16.0D); + int l = MathHelper.floor_double(par1Entity.posY / 16.0D); + int i1 = MathHelper.floor_double(par1Entity.posZ / 16.0D); + + if (!par1Entity.addedToChunk || par1Entity.chunkCoordX != k || par1Entity.chunkCoordY != l || par1Entity.chunkCoordZ != i1) + { + if (par1Entity.addedToChunk && this.chunkExists(par1Entity.chunkCoordX, par1Entity.chunkCoordZ)) + { + this.getChunkFromChunkCoords(par1Entity.chunkCoordX, par1Entity.chunkCoordZ).removeEntityAtIndex(par1Entity, par1Entity.chunkCoordY); + } + + if (this.chunkExists(k, i1)) + { + par1Entity.addedToChunk = true; + this.getChunkFromChunkCoords(k, i1).addEntity(par1Entity); + } + else + { + par1Entity.addedToChunk = false; + } + } + + this.theProfiler.endSection(); + + if (par2 && par1Entity.addedToChunk && par1Entity.riddenByEntity != null) + { + if (!par1Entity.riddenByEntity.isDead && par1Entity.riddenByEntity.ridingEntity == par1Entity) + { + this.updateEntity(par1Entity.riddenByEntity); + } + else + { + par1Entity.riddenByEntity.ridingEntity = null; + par1Entity.riddenByEntity = null; + } + } + } + } + + public boolean checkNoEntityCollision(AxisAlignedBB par1AxisAlignedBB) + { + return this.checkNoEntityCollision(par1AxisAlignedBB, (Entity)null); + } + + public boolean checkNoEntityCollision(AxisAlignedBB par1AxisAlignedBB, Entity par2Entity) + { + List list = this.getEntitiesWithinAABBExcludingEntity((Entity)null, par1AxisAlignedBB); + + for (int i = 0; i < list.size(); ++i) + { + Entity entity1 = (Entity)list.get(i); + + if (!entity1.isDead && entity1.preventEntitySpawning && entity1 != par2Entity) + { + return false; + } + } + + return true; + } + + public boolean checkBlockCollision(AxisAlignedBB par1AxisAlignedBB) + { + int i = MathHelper.floor_double(par1AxisAlignedBB.minX); + int j = MathHelper.floor_double(par1AxisAlignedBB.maxX + 1.0D); + int k = MathHelper.floor_double(par1AxisAlignedBB.minY); + int l = MathHelper.floor_double(par1AxisAlignedBB.maxY + 1.0D); + int i1 = MathHelper.floor_double(par1AxisAlignedBB.minZ); + int j1 = MathHelper.floor_double(par1AxisAlignedBB.maxZ + 1.0D); + + if (par1AxisAlignedBB.minX < 0.0D) + { + --i; + } + + if (par1AxisAlignedBB.minY < 0.0D) + { + --k; + } + + if (par1AxisAlignedBB.minZ < 0.0D) + { + --i1; + } + + for (int k1 = i; k1 < j; ++k1) + { + for (int l1 = k; l1 < l; ++l1) + { + for (int i2 = i1; i2 < j1; ++i2) + { + Block block = this.getBlock(k1, l1, i2); + + if (block.getMaterial() != Material.air) + { + return true; + } + } + } + } + + return false; + } + + public boolean isAnyLiquid(AxisAlignedBB par1AxisAlignedBB) + { + int i = MathHelper.floor_double(par1AxisAlignedBB.minX); + int j = MathHelper.floor_double(par1AxisAlignedBB.maxX + 1.0D); + int k = MathHelper.floor_double(par1AxisAlignedBB.minY); + int l = MathHelper.floor_double(par1AxisAlignedBB.maxY + 1.0D); + int i1 = MathHelper.floor_double(par1AxisAlignedBB.minZ); + int j1 = MathHelper.floor_double(par1AxisAlignedBB.maxZ + 1.0D); + + if (par1AxisAlignedBB.minX < 0.0D) + { + --i; + } + + if (par1AxisAlignedBB.minY < 0.0D) + { + --k; + } + + if (par1AxisAlignedBB.minZ < 0.0D) + { + --i1; + } + + for (int k1 = i; k1 < j; ++k1) + { + for (int l1 = k; l1 < l; ++l1) + { + for (int i2 = i1; i2 < j1; ++i2) + { + Block block = this.getBlock(k1, l1, i2); + + if (block.getMaterial().isLiquid()) + { + return true; + } + } + } + } + + return false; + } + + public boolean func_147470_e(AxisAlignedBB p_147470_1_) + { + int i = MathHelper.floor_double(p_147470_1_.minX); + int j = MathHelper.floor_double(p_147470_1_.maxX + 1.0D); + int k = MathHelper.floor_double(p_147470_1_.minY); + int l = MathHelper.floor_double(p_147470_1_.maxY + 1.0D); + int i1 = MathHelper.floor_double(p_147470_1_.minZ); + int j1 = MathHelper.floor_double(p_147470_1_.maxZ + 1.0D); + + if (this.checkChunksExist(i, k, i1, j, l, j1)) + { + for (int k1 = i; k1 < j; ++k1) + { + for (int l1 = k; l1 < l; ++l1) + { + for (int i2 = i1; i2 < j1; ++i2) + { + Block block = this.getBlock(k1, l1, i2); + + if (block == Blocks.fire || block == Blocks.flowing_lava || block == Blocks.lava) + { + return true; + } + else + { + if (block.isBurning(this, k1, l1, i2)) return true; + } + } + } + } + } + + return false; + } + + public boolean handleMaterialAcceleration(AxisAlignedBB par1AxisAlignedBB, Material par2Material, Entity par3Entity) + { + int i = MathHelper.floor_double(par1AxisAlignedBB.minX); + int j = MathHelper.floor_double(par1AxisAlignedBB.maxX + 1.0D); + int k = MathHelper.floor_double(par1AxisAlignedBB.minY); + int l = MathHelper.floor_double(par1AxisAlignedBB.maxY + 1.0D); + int i1 = MathHelper.floor_double(par1AxisAlignedBB.minZ); + int j1 = MathHelper.floor_double(par1AxisAlignedBB.maxZ + 1.0D); + + if (!this.checkChunksExist(i, k, i1, j, l, j1)) + { + return false; + } + else + { + boolean flag = false; + Vec3 vec3 = this.getWorldVec3Pool().getVecFromPool(0.0D, 0.0D, 0.0D); + + for (int k1 = i; k1 < j; ++k1) + { + for (int l1 = k; l1 < l; ++l1) + { + for (int i2 = i1; i2 < j1; ++i2) + { + Block block = this.getBlock(k1, l1, i2); + + if (block.getMaterial() == par2Material) + { + double d0 = (double)((float)(l1 + 1) - BlockLiquid.getLiquidHeightPercent(this.getBlockMetadata(k1, l1, i2))); + + if ((double)l >= d0) + { + flag = true; + block.velocityToAddToEntity(this, k1, l1, i2, par3Entity, vec3); + } + } + } + } + } + + if (vec3.lengthVector() > 0.0D && par3Entity.isPushedByWater()) + { + vec3 = vec3.normalize(); + double d1 = 0.014D; + par3Entity.motionX += vec3.xCoord * d1; + par3Entity.motionY += vec3.yCoord * d1; + par3Entity.motionZ += vec3.zCoord * d1; + } + + return flag; + } + } + + public boolean isMaterialInBB(AxisAlignedBB par1AxisAlignedBB, Material par2Material) + { + int i = MathHelper.floor_double(par1AxisAlignedBB.minX); + int j = MathHelper.floor_double(par1AxisAlignedBB.maxX + 1.0D); + int k = MathHelper.floor_double(par1AxisAlignedBB.minY); + int l = MathHelper.floor_double(par1AxisAlignedBB.maxY + 1.0D); + int i1 = MathHelper.floor_double(par1AxisAlignedBB.minZ); + int j1 = MathHelper.floor_double(par1AxisAlignedBB.maxZ + 1.0D); + + for (int k1 = i; k1 < j; ++k1) + { + for (int l1 = k; l1 < l; ++l1) + { + for (int i2 = i1; i2 < j1; ++i2) + { + if (this.getBlock(k1, l1, i2).getMaterial() == par2Material) + { + return true; + } + } + } + } + + return false; + } + + public boolean isAABBInMaterial(AxisAlignedBB par1AxisAlignedBB, Material par2Material) + { + int i = MathHelper.floor_double(par1AxisAlignedBB.minX); + int j = MathHelper.floor_double(par1AxisAlignedBB.maxX + 1.0D); + int k = MathHelper.floor_double(par1AxisAlignedBB.minY); + int l = MathHelper.floor_double(par1AxisAlignedBB.maxY + 1.0D); + int i1 = MathHelper.floor_double(par1AxisAlignedBB.minZ); + int j1 = MathHelper.floor_double(par1AxisAlignedBB.maxZ + 1.0D); + + for (int k1 = i; k1 < j; ++k1) + { + for (int l1 = k; l1 < l; ++l1) + { + for (int i2 = i1; i2 < j1; ++i2) + { + Block block = this.getBlock(k1, l1, i2); + + if (block.getMaterial() == par2Material) + { + int j2 = this.getBlockMetadata(k1, l1, i2); + double d0 = (double)(l1 + 1); + + if (j2 < 8) + { + d0 = (double)(l1 + 1) - (double)j2 / 8.0D; + } + + if (d0 >= par1AxisAlignedBB.minY) + { + return true; + } + } + } + } + } + + return false; + } + + public Explosion createExplosion(Entity par1Entity, double par2, double par4, double par6, float par8, boolean par9) + { + return this.newExplosion(par1Entity, par2, par4, par6, par8, false, par9); + } + + public Explosion newExplosion(Entity par1Entity, double par2, double par4, double par6, float par8, boolean par9, boolean par10) + { + Explosion explosion = new Explosion(this, par1Entity, par2, par4, par6, par8); + explosion.isFlaming = par9; + explosion.isSmoking = par10; + explosion.doExplosionA(); + explosion.doExplosionB(true); + return explosion; + } + + public float getBlockDensity(Vec3 par1Vec3, AxisAlignedBB par2AxisAlignedBB) + { + double d0 = 1.0D / ((par2AxisAlignedBB.maxX - par2AxisAlignedBB.minX) * 2.0D + 1.0D); + double d1 = 1.0D / ((par2AxisAlignedBB.maxY - par2AxisAlignedBB.minY) * 2.0D + 1.0D); + double d2 = 1.0D / ((par2AxisAlignedBB.maxZ - par2AxisAlignedBB.minZ) * 2.0D + 1.0D); + int i = 0; + int j = 0; + + for (float f = 0.0F; f <= 1.0F; f = (float)((double)f + d0)) + { + for (float f1 = 0.0F; f1 <= 1.0F; f1 = (float)((double)f1 + d1)) + { + for (float f2 = 0.0F; f2 <= 1.0F; f2 = (float)((double)f2 + d2)) + { + double d3 = par2AxisAlignedBB.minX + (par2AxisAlignedBB.maxX - par2AxisAlignedBB.minX) * (double)f; + double d4 = par2AxisAlignedBB.minY + (par2AxisAlignedBB.maxY - par2AxisAlignedBB.minY) * (double)f1; + double d5 = par2AxisAlignedBB.minZ + (par2AxisAlignedBB.maxZ - par2AxisAlignedBB.minZ) * (double)f2; + + if (this.rayTraceBlocks(this.getWorldVec3Pool().getVecFromPool(d3, d4, d5), par1Vec3) == null) + { + ++i; + } + + ++j; + } + } + } + + return (float)i / (float)j; + } + + public boolean extinguishFire(EntityPlayer par1EntityPlayer, int par2, int par3, int par4, int par5) + { + if (par5 == 0) + { + --par3; + } + + if (par5 == 1) + { + ++par3; + } + + if (par5 == 2) + { + --par4; + } + + if (par5 == 3) + { + ++par4; + } + + if (par5 == 4) + { + --par2; + } + + if (par5 == 5) + { + ++par2; + } + + if (this.getBlock(par2, par3, par4) == Blocks.fire) + { + this.playAuxSFXAtEntity(par1EntityPlayer, 1004, par2, par3, par4, 0); + this.setBlockToAir(par2, par3, par4); + return true; + } + else + { + return false; + } + } + + @SideOnly(Side.CLIENT) + public String getDebugLoadedEntities() + { + return "All: " + this.loadedEntityList.size(); + } + + @SideOnly(Side.CLIENT) + public String getProviderName() + { + return this.chunkProvider.makeString(); + } + + public TileEntity getTileEntity(int p_147438_1_, int p_147438_2_, int p_147438_3_) + { + if (p_147438_2_ >= 0 && p_147438_2_ < 256) + { + TileEntity tileentity = null; + int l; + TileEntity tileentity1; + + if (this.field_147481_N) + { + for (l = 0; l < this.addedTileEntityList.size(); ++l) + { + tileentity1 = (TileEntity)this.addedTileEntityList.get(l); + + if (!tileentity1.isInvalid() && tileentity1.xCoord == p_147438_1_ && tileentity1.yCoord == p_147438_2_ && tileentity1.zCoord == p_147438_3_) + { + tileentity = tileentity1; + break; + } + } + } + + if (tileentity == null) + { + Chunk chunk = this.getChunkFromChunkCoords(p_147438_1_ >> 4, p_147438_3_ >> 4); + + if (chunk != null) + { + tileentity = chunk.func_150806_e(p_147438_1_ & 15, p_147438_2_, p_147438_3_ & 15); + } + } + + if (tileentity == null) + { + for (l = 0; l < this.addedTileEntityList.size(); ++l) + { + tileentity1 = (TileEntity)this.addedTileEntityList.get(l); + + if (!tileentity1.isInvalid() && tileentity1.xCoord == p_147438_1_ && tileentity1.yCoord == p_147438_2_ && tileentity1.zCoord == p_147438_3_) + { + tileentity = tileentity1; + break; + } + } + } + + return tileentity; + } + else + { + return null; + } + } + + public void setTileEntity(int p_147455_1_, int p_147455_2_, int p_147455_3_, TileEntity p_147455_4_) + { + if (p_147455_4_ == null || p_147455_4_.isInvalid()) + { + return; + } + + if (p_147455_4_.canUpdate()) + { + if (this.field_147481_N) + { + Iterator iterator = this.addedTileEntityList.iterator(); + + while (iterator.hasNext()) + { + TileEntity tileentity1 = (TileEntity)iterator.next(); + + if (tileentity1.xCoord == p_147455_1_ && tileentity1.yCoord == p_147455_2_ && tileentity1.zCoord == p_147455_3_) + { + tileentity1.invalidate(); + iterator.remove(); + } + } + + this.addedTileEntityList.add(p_147455_4_); + } + else + { + this.loadedTileEntityList.add(p_147455_4_); + } + } + Chunk chunk = this.getChunkFromChunkCoords(p_147455_1_ >> 4, p_147455_3_ >> 4); + if (chunk != null) + { + chunk.func_150812_a(p_147455_1_ & 15, p_147455_2_, p_147455_3_ & 15, p_147455_4_); + } + //notify tile changes + func_147453_f(p_147455_1_, p_147455_2_, p_147455_3_, getBlock(p_147455_1_, p_147455_2_, p_147455_3_)); + } + + public void removeTileEntity(int p_147475_1_, int p_147475_2_, int p_147475_3_) + { + Chunk chunk = getChunkFromChunkCoords(p_147475_1_ >> 4, p_147475_3_ >> 4); + if (chunk != null) chunk.removeTileEntity(p_147475_1_ & 15, p_147475_2_, p_147475_3_ & 15); + func_147453_f(p_147475_1_, p_147475_2_, p_147475_3_, getBlock(p_147475_1_, p_147475_2_, p_147475_3_)); + } + + public void func_147457_a(TileEntity p_147457_1_) + { + this.field_147483_b.add(p_147457_1_); + } + + public boolean func_147469_q(int p_147469_1_, int p_147469_2_, int p_147469_3_) + { + AxisAlignedBB axisalignedbb = this.getBlock(p_147469_1_, p_147469_2_, p_147469_3_).getCollisionBoundingBoxFromPool(this, p_147469_1_, p_147469_2_, p_147469_3_); + return axisalignedbb != null && axisalignedbb.getAverageEdgeLength() >= 1.0D; + } + + public static boolean doesBlockHaveSolidTopSurface(IBlockAccess p_147466_0_, int p_147466_1_, int p_147466_2_, int p_147466_3_) + { + Block block = p_147466_0_.getBlock(p_147466_1_, p_147466_2_, p_147466_3_); + return block.isSideSolid(p_147466_0_, p_147466_1_, p_147466_2_, p_147466_3_, ForgeDirection.UP); + } + + public boolean isBlockNormalCubeDefault(int p_147445_1_, int p_147445_2_, int p_147445_3_, boolean p_147445_4_) + { + if (p_147445_1_ >= -30000000 && p_147445_3_ >= -30000000 && p_147445_1_ < 30000000 && p_147445_3_ < 30000000) + { + Chunk chunk = this.chunkProvider.provideChunk(p_147445_1_ >> 4, p_147445_3_ >> 4); + + if (chunk != null && !chunk.isEmpty()) + { + Block block = this.getBlock(p_147445_1_, p_147445_2_, p_147445_3_); + return block.isNormalCube(this, p_147445_1_, p_147445_2_, p_147445_3_); + } + else + { + return p_147445_4_; + } + } + else + { + return p_147445_4_; + } + } + + public void calculateInitialSkylight() + { + int i = this.calculateSkylightSubtracted(1.0F); + + if (i != this.skylightSubtracted) + { + this.skylightSubtracted = i; + } + } + + public void setAllowedSpawnTypes(boolean par1, boolean par2) + { + provider.setAllowedSpawnTypes(par1, par2); + } + + public void tick() + { + this.updateWeather(); + } + + private void calculateInitialWeather() + { + provider.calculateInitialWeather(); + } + + public void calculateInitialWeatherBody() + { + if (this.worldInfo.isRaining()) + { + this.rainingStrength = 1.0F; + + if (this.worldInfo.isThundering()) + { + this.thunderingStrength = 1.0F; + } + } + } + + protected void updateWeather() + { + provider.updateWeather(); + } + + public void updateWeatherBody() + { + if (!this.provider.hasNoSky) + { + if (!this.isRemote) + { + int i = this.worldInfo.getThunderTime(); + + if (i <= 0) + { + if (this.worldInfo.isThundering()) + { + this.worldInfo.setThunderTime(this.rand.nextInt(12000) + 3600); + } + else + { + this.worldInfo.setThunderTime(this.rand.nextInt(168000) + 12000); + } + } + else + { + --i; + this.worldInfo.setThunderTime(i); + + if (i <= 0) + { + this.worldInfo.setThundering(!this.worldInfo.isThundering()); + } + } + + this.prevThunderingStrength = this.thunderingStrength; + + if (this.worldInfo.isThundering()) + { + this.thunderingStrength = (float)((double)this.thunderingStrength + 0.01D); + } + else + { + this.thunderingStrength = (float)((double)this.thunderingStrength - 0.01D); + } + + this.thunderingStrength = MathHelper.clamp_float(this.thunderingStrength, 0.0F, 1.0F); + int j = this.worldInfo.getRainTime(); + + if (j <= 0) + { + if (this.worldInfo.isRaining()) + { + this.worldInfo.setRainTime(this.rand.nextInt(12000) + 12000); + } + else + { + this.worldInfo.setRainTime(this.rand.nextInt(168000) + 12000); + } + } + else + { + --j; + this.worldInfo.setRainTime(j); + + if (j <= 0) + { + this.worldInfo.setRaining(!this.worldInfo.isRaining()); + } + } + + this.prevRainingStrength = this.rainingStrength; + + if (this.worldInfo.isRaining()) + { + this.rainingStrength = (float)((double)this.rainingStrength + 0.01D); + } + else + { + this.rainingStrength = (float)((double)this.rainingStrength - 0.01D); + } + + this.rainingStrength = MathHelper.clamp_float(this.rainingStrength, 0.0F, 1.0F); + } + } + } + + protected void setActivePlayerChunksAndCheckLight() + { + this.activeChunkSet.clear(); + this.theProfiler.startSection("buildList"); + this.activeChunkSet.addAll(getPersistentChunks().keySet()); + int i; + EntityPlayer entityplayer; + int j; + int k; + + for (i = 0; i < this.playerEntities.size(); ++i) + { + entityplayer = (EntityPlayer)this.playerEntities.get(i); + j = MathHelper.floor_double(entityplayer.posX / 16.0D); + k = MathHelper.floor_double(entityplayer.posZ / 16.0D); + byte b0 = 7; + + for (int l = -b0; l <= b0; ++l) + { + for (int i1 = -b0; i1 <= b0; ++i1) + { + this.activeChunkSet.add(new ChunkCoordIntPair(l + j, i1 + k)); + } + } + } + + this.theProfiler.endSection(); + + if (this.ambientTickCountdown > 0) + { + --this.ambientTickCountdown; + } + + this.theProfiler.startSection("playerCheckLight"); + + if (!this.playerEntities.isEmpty()) + { + i = this.rand.nextInt(this.playerEntities.size()); + entityplayer = (EntityPlayer)this.playerEntities.get(i); + j = MathHelper.floor_double(entityplayer.posX) + this.rand.nextInt(11) - 5; + k = MathHelper.floor_double(entityplayer.posY) + this.rand.nextInt(11) - 5; + int j1 = MathHelper.floor_double(entityplayer.posZ) + this.rand.nextInt(11) - 5; + this.func_147451_t(j, k, j1); + } + + this.theProfiler.endSection(); + } + + protected void func_147467_a(int p_147467_1_, int p_147467_2_, Chunk p_147467_3_) + { + this.theProfiler.endStartSection("moodSound"); + + if (this.ambientTickCountdown == 0 && !this.isRemote) + { + this.updateLCG = this.updateLCG * 3 + 1013904223; + int k = this.updateLCG >> 2; + int l = k & 15; + int i1 = k >> 8 & 15; + int j1 = k >> 16 & 255; + Block block = p_147467_3_.getBlock(l, j1, i1); + l += p_147467_1_; + i1 += p_147467_2_; + + if (block.getMaterial() == Material.air && this.getFullBlockLightValue(l, j1, i1) <= this.rand.nextInt(8) && this.getSavedLightValue(EnumSkyBlock.Sky, l, j1, i1) <= 0) + { + EntityPlayer entityplayer = this.getClosestPlayer((double)l + 0.5D, (double)j1 + 0.5D, (double)i1 + 0.5D, 8.0D); + + if (entityplayer != null && entityplayer.getDistanceSq((double)l + 0.5D, (double)j1 + 0.5D, (double)i1 + 0.5D) > 4.0D) + { + this.playSoundEffect((double)l + 0.5D, (double)j1 + 0.5D, (double)i1 + 0.5D, "ambient.cave.cave", 0.7F, 0.8F + this.rand.nextFloat() * 0.2F); + this.ambientTickCountdown = this.rand.nextInt(12000) + 6000; + } + } + } + + this.theProfiler.endStartSection("checkLight"); + p_147467_3_.enqueueRelightChecks(); + } + + protected void func_147456_g() + { + this.setActivePlayerChunksAndCheckLight(); + } + + public boolean isBlockFreezable(int par1, int par2, int par3) + { + return this.canBlockFreeze(par1, par2, par3, false); + } + + public boolean isBlockFreezableNaturally(int par1, int par2, int par3) + { + return this.canBlockFreeze(par1, par2, par3, true); + } + + public boolean canBlockFreeze(int par1, int par2, int par3, boolean par4) + { + return provider.canBlockFreeze(par1, par2, par3, par4); + } + + public boolean canBlockFreezeBody(int par1, int par2, int par3, boolean par4) + { + BiomeGenBase biomegenbase = this.getBiomeGenForCoords(par1, par3); + float f = biomegenbase.getFloatTemperature(par1, par2, par3); + + if (f > 0.15F) + { + return false; + } + else + { + if (par2 >= 0 && par2 < 256 && this.getSavedLightValue(EnumSkyBlock.Block, par1, par2, par3) < 10) + { + Block block = this.getBlock(par1, par2, par3); + + if ((block == Blocks.water || block == Blocks.flowing_water) && this.getBlockMetadata(par1, par2, par3) == 0) + { + if (!par4) + { + return true; + } + + boolean flag1 = true; + + if (flag1 && this.getBlock(par1 - 1, par2, par3).getMaterial() != Material.water) + { + flag1 = false; + } + + if (flag1 && this.getBlock(par1 + 1, par2, par3).getMaterial() != Material.water) + { + flag1 = false; + } + + if (flag1 && this.getBlock(par1, par2, par3 - 1).getMaterial() != Material.water) + { + flag1 = false; + } + + if (flag1 && this.getBlock(par1, par2, par3 + 1).getMaterial() != Material.water) + { + flag1 = false; + } + + if (!flag1) + { + return true; + } + } + } + + return false; + } + } + + public boolean func_147478_e(int p_147478_1_, int p_147478_2_, int p_147478_3_, boolean p_147478_4_) + { + return provider.canSnowAt(p_147478_1_, p_147478_2_, p_147478_3_, p_147478_4_); + } + + public boolean canSnowAtBody(int p_147478_1_, int p_147478_2_, int p_147478_3_, boolean p_147478_4_) + { + BiomeGenBase biomegenbase = this.getBiomeGenForCoords(p_147478_1_, p_147478_3_); + float f = biomegenbase.getFloatTemperature(p_147478_1_, p_147478_2_, p_147478_3_); + + if (f > 0.15F) + { + return false; + } + else if (!p_147478_4_) + { + return true; + } + else + { + if (p_147478_2_ >= 0 && p_147478_2_ < 256 && this.getSavedLightValue(EnumSkyBlock.Block, p_147478_1_, p_147478_2_, p_147478_3_) < 10) + { + Block block = this.getBlock(p_147478_1_, p_147478_2_, p_147478_3_); + + if (block.getMaterial() == Material.air && Blocks.snow_layer.canPlaceBlockAt(this, p_147478_1_, p_147478_2_, p_147478_3_)) + { + return true; + } + } + + return false; + } + } + + public boolean func_147451_t(int p_147451_1_, int p_147451_2_, int p_147451_3_) + { + boolean flag = false; + + if (!this.provider.hasNoSky) + { + flag |= this.updateLightByType(EnumSkyBlock.Sky, p_147451_1_, p_147451_2_, p_147451_3_); + } + + flag |= this.updateLightByType(EnumSkyBlock.Block, p_147451_1_, p_147451_2_, p_147451_3_); + return flag; + } + + private int computeLightValue(int par1, int par2, int par3, EnumSkyBlock par4EnumSkyBlock) + { + if (par4EnumSkyBlock == EnumSkyBlock.Sky && this.canBlockSeeTheSky(par1, par2, par3)) + { + return 15; + } + else + { + Block block = this.getBlock(par1, par2, par3); + int blockLight = block.getLightValue(this, par1, par2, par3); + int l = par4EnumSkyBlock == EnumSkyBlock.Sky ? 0 : blockLight; + int i1 = block.getLightOpacity(this, par1, par2, par3); + + if (i1 >= 15 && blockLight > 0) + { + i1 = 1; + } + + if (i1 < 1) + { + i1 = 1; + } + + if (i1 >= 15) + { + return 0; + } + else if (l >= 14) + { + return l; + } + else + { + for (int j1 = 0; j1 < 6; ++j1) + { + int k1 = par1 + Facing.offsetsXForSide[j1]; + int l1 = par2 + Facing.offsetsYForSide[j1]; + int i2 = par3 + Facing.offsetsZForSide[j1]; + int j2 = this.getSavedLightValue(par4EnumSkyBlock, k1, l1, i2) - i1; + + if (j2 > l) + { + l = j2; + } + + if (l >= 14) + { + return l; + } + } + + return l; + } + } + } + + public boolean updateLightByType(EnumSkyBlock p_147463_1_, int p_147463_2_, int p_147463_3_, int p_147463_4_) + { + if (!this.doChunksNearChunkExist(p_147463_2_, p_147463_3_, p_147463_4_, 17)) + { + return false; + } + else + { + int l = 0; + int i1 = 0; + this.theProfiler.startSection("getBrightness"); + int j1 = this.getSavedLightValue(p_147463_1_, p_147463_2_, p_147463_3_, p_147463_4_); + int k1 = this.computeLightValue(p_147463_2_, p_147463_3_, p_147463_4_, p_147463_1_); + int l1; + int i2; + int j2; + int k2; + int l2; + int i3; + int j3; + int k3; + int l3; + + if (k1 > j1) + { + this.lightUpdateBlockList[i1++] = 133152; + } + else if (k1 < j1) + { + this.lightUpdateBlockList[i1++] = 133152 | j1 << 18; + + while (l < i1) + { + l1 = this.lightUpdateBlockList[l++]; + i2 = (l1 & 63) - 32 + p_147463_2_; + j2 = (l1 >> 6 & 63) - 32 + p_147463_3_; + k2 = (l1 >> 12 & 63) - 32 + p_147463_4_; + l2 = l1 >> 18 & 15; + i3 = this.getSavedLightValue(p_147463_1_, i2, j2, k2); + + if (i3 == l2) + { + this.setLightValue(p_147463_1_, i2, j2, k2, 0); + + if (l2 > 0) + { + j3 = MathHelper.abs_int(i2 - p_147463_2_); + k3 = MathHelper.abs_int(j2 - p_147463_3_); + l3 = MathHelper.abs_int(k2 - p_147463_4_); + + if (j3 + k3 + l3 < 17) + { + for (int i4 = 0; i4 < 6; ++i4) + { + int j4 = i2 + Facing.offsetsXForSide[i4]; + int k4 = j2 + Facing.offsetsYForSide[i4]; + int l4 = k2 + Facing.offsetsZForSide[i4]; + int i5 = Math.max(1, this.getBlock(j4, k4, l4).getLightOpacity(this, j4, k4, l4)); + i3 = this.getSavedLightValue(p_147463_1_, j4, k4, l4); + + if (i3 == l2 - i5 && i1 < this.lightUpdateBlockList.length) + { + this.lightUpdateBlockList[i1++] = j4 - p_147463_2_ + 32 | k4 - p_147463_3_ + 32 << 6 | l4 - p_147463_4_ + 32 << 12 | l2 - i5 << 18; + } + } + } + } + } + } + + l = 0; + } + + this.theProfiler.endSection(); + this.theProfiler.startSection("checkedPosition < toCheckCount"); + + while (l < i1) + { + l1 = this.lightUpdateBlockList[l++]; + i2 = (l1 & 63) - 32 + p_147463_2_; + j2 = (l1 >> 6 & 63) - 32 + p_147463_3_; + k2 = (l1 >> 12 & 63) - 32 + p_147463_4_; + l2 = this.getSavedLightValue(p_147463_1_, i2, j2, k2); + i3 = this.computeLightValue(i2, j2, k2, p_147463_1_); + + if (i3 != l2) + { + this.setLightValue(p_147463_1_, i2, j2, k2, i3); + + if (i3 > l2) + { + j3 = Math.abs(i2 - p_147463_2_); + k3 = Math.abs(j2 - p_147463_3_); + l3 = Math.abs(k2 - p_147463_4_); + boolean flag = i1 < this.lightUpdateBlockList.length - 6; + + if (j3 + k3 + l3 < 17 && flag) + { + if (this.getSavedLightValue(p_147463_1_, i2 - 1, j2, k2) < i3) + { + this.lightUpdateBlockList[i1++] = i2 - 1 - p_147463_2_ + 32 + (j2 - p_147463_3_ + 32 << 6) + (k2 - p_147463_4_ + 32 << 12); + } + + if (this.getSavedLightValue(p_147463_1_, i2 + 1, j2, k2) < i3) + { + this.lightUpdateBlockList[i1++] = i2 + 1 - p_147463_2_ + 32 + (j2 - p_147463_3_ + 32 << 6) + (k2 - p_147463_4_ + 32 << 12); + } + + if (this.getSavedLightValue(p_147463_1_, i2, j2 - 1, k2) < i3) + { + this.lightUpdateBlockList[i1++] = i2 - p_147463_2_ + 32 + (j2 - 1 - p_147463_3_ + 32 << 6) + (k2 - p_147463_4_ + 32 << 12); + } + + if (this.getSavedLightValue(p_147463_1_, i2, j2 + 1, k2) < i3) + { + this.lightUpdateBlockList[i1++] = i2 - p_147463_2_ + 32 + (j2 + 1 - p_147463_3_ + 32 << 6) + (k2 - p_147463_4_ + 32 << 12); + } + + if (this.getSavedLightValue(p_147463_1_, i2, j2, k2 - 1) < i3) + { + this.lightUpdateBlockList[i1++] = i2 - p_147463_2_ + 32 + (j2 - p_147463_3_ + 32 << 6) + (k2 - 1 - p_147463_4_ + 32 << 12); + } + + if (this.getSavedLightValue(p_147463_1_, i2, j2, k2 + 1) < i3) + { + this.lightUpdateBlockList[i1++] = i2 - p_147463_2_ + 32 + (j2 - p_147463_3_ + 32 << 6) + (k2 + 1 - p_147463_4_ + 32 << 12); + } + } + } + } + } + + this.theProfiler.endSection(); + return true; + } + } + + public boolean tickUpdates(boolean par1) + { + return false; + } + + public List getPendingBlockUpdates(Chunk par1Chunk, boolean par2) + { + return null; + } + + public List getEntitiesWithinAABBExcludingEntity(Entity par1Entity, AxisAlignedBB par2AxisAlignedBB) + { + return this.getEntitiesWithinAABBExcludingEntity(par1Entity, par2AxisAlignedBB, (IEntitySelector)null); + } + + public List getEntitiesWithinAABBExcludingEntity(Entity par1Entity, AxisAlignedBB par2AxisAlignedBB, IEntitySelector par3IEntitySelector) + { + ArrayList arraylist = new ArrayList(); + int i = MathHelper.floor_double((par2AxisAlignedBB.minX - MAX_ENTITY_RADIUS) / 16.0D); + int j = MathHelper.floor_double((par2AxisAlignedBB.maxX + MAX_ENTITY_RADIUS) / 16.0D); + int k = MathHelper.floor_double((par2AxisAlignedBB.minZ - MAX_ENTITY_RADIUS) / 16.0D); + int l = MathHelper.floor_double((par2AxisAlignedBB.maxZ + MAX_ENTITY_RADIUS) / 16.0D); + + for (int i1 = i; i1 <= j; ++i1) + { + for (int j1 = k; j1 <= l; ++j1) + { + if (this.chunkExists(i1, j1)) + { + this.getChunkFromChunkCoords(i1, j1).getEntitiesWithinAABBForEntity(par1Entity, par2AxisAlignedBB, arraylist, par3IEntitySelector); + } + } + } + + return arraylist; + } + + public List getEntitiesWithinAABB(Class par1Class, AxisAlignedBB par2AxisAlignedBB) + { + return this.selectEntitiesWithinAABB(par1Class, par2AxisAlignedBB, (IEntitySelector)null); + } + + public List selectEntitiesWithinAABB(Class par1Class, AxisAlignedBB par2AxisAlignedBB, IEntitySelector par3IEntitySelector) + { + int i = MathHelper.floor_double((par2AxisAlignedBB.minX - MAX_ENTITY_RADIUS) / 16.0D); + int j = MathHelper.floor_double((par2AxisAlignedBB.maxX + MAX_ENTITY_RADIUS) / 16.0D); + int k = MathHelper.floor_double((par2AxisAlignedBB.minZ - MAX_ENTITY_RADIUS) / 16.0D); + int l = MathHelper.floor_double((par2AxisAlignedBB.maxZ + MAX_ENTITY_RADIUS) / 16.0D); + ArrayList arraylist = new ArrayList(); + + for (int i1 = i; i1 <= j; ++i1) + { + for (int j1 = k; j1 <= l; ++j1) + { + if (this.chunkExists(i1, j1)) + { + this.getChunkFromChunkCoords(i1, j1).getEntitiesOfTypeWithinAAAB(par1Class, par2AxisAlignedBB, arraylist, par3IEntitySelector); + } + } + } + + return arraylist; + } + + public Entity findNearestEntityWithinAABB(Class par1Class, AxisAlignedBB par2AxisAlignedBB, Entity par3Entity) + { + List list = this.getEntitiesWithinAABB(par1Class, par2AxisAlignedBB); + Entity entity1 = null; + double d0 = Double.MAX_VALUE; + + for (int i = 0; i < list.size(); ++i) + { + Entity entity2 = (Entity)list.get(i); + + if (entity2 != par3Entity) + { + double d1 = par3Entity.getDistanceSqToEntity(entity2); + + if (d1 <= d0) + { + entity1 = entity2; + d0 = d1; + } + } + } + + return entity1; + } + + public abstract Entity getEntityByID(int var1); + + @SideOnly(Side.CLIENT) + public List getLoadedEntityList() + { + return this.loadedEntityList; + } + + public void markTileEntityChunkModified(int p_147476_1_, int p_147476_2_, int p_147476_3_, TileEntity p_147476_4_) + { + if (this.blockExists(p_147476_1_, p_147476_2_, p_147476_3_)) + { + this.getChunkFromBlockCoords(p_147476_1_, p_147476_3_).setChunkModified(); + } + } + + public int countEntities(Class par1Class) + { + int i = 0; + + for (int j = 0; j < this.loadedEntityList.size(); ++j) + { + Entity entity = (Entity)this.loadedEntityList.get(j); + + if ((!(entity instanceof EntityLiving) || !((EntityLiving)entity).isNoDespawnRequired()) && par1Class.isAssignableFrom(entity.getClass())) + { + ++i; + } + } + + return i; + } + + public void addLoadedEntities(List par1List) + { + for (int i = 0; i < par1List.size(); ++i) + { + Entity entity = (Entity)par1List.get(i); + if (!MinecraftForge.EVENT_BUS.post(new EntityJoinWorldEvent(entity, this))) + { + loadedEntityList.add(entity); + this.onEntityAdded(entity); + } + } + } + + public void unloadEntities(List par1List) + { + this.unloadedEntityList.addAll(par1List); + } + + public boolean canPlaceEntityOnSide(Block p_147472_1_, int p_147472_2_, int p_147472_3_, int p_147472_4_, boolean p_147472_5_, int p_147472_6_, Entity p_147472_7_, ItemStack p_147472_8_) + { + Block block1 = this.getBlock(p_147472_2_, p_147472_3_, p_147472_4_); + AxisAlignedBB axisalignedbb = p_147472_5_ ? null : p_147472_1_.getCollisionBoundingBoxFromPool(this, p_147472_2_, p_147472_3_, p_147472_4_); + return axisalignedbb != null && !this.checkNoEntityCollision(axisalignedbb, p_147472_7_) ? false : (block1.getMaterial() == Material.circuits && p_147472_1_ == Blocks.anvil ? true : block1.isReplaceable(this, p_147472_2_, p_147472_3_, p_147472_4_) && p_147472_1_.canReplace(this, p_147472_2_, p_147472_3_, p_147472_4_, p_147472_6_, p_147472_8_)); + } + + public PathEntity getPathEntityToEntity(Entity par1Entity, Entity par2Entity, float par3, boolean par4, boolean par5, boolean par6, boolean par7) + { + this.theProfiler.startSection("pathfind"); + int i = MathHelper.floor_double(par1Entity.posX); + int j = MathHelper.floor_double(par1Entity.posY + 1.0D); + int k = MathHelper.floor_double(par1Entity.posZ); + int l = (int)(par3 + 16.0F); + int i1 = i - l; + int j1 = j - l; + int k1 = k - l; + int l1 = i + l; + int i2 = j + l; + int j2 = k + l; + ChunkCache chunkcache = new ChunkCache(this, i1, j1, k1, l1, i2, j2, 0); + PathEntity pathentity = (new PathFinder(chunkcache, par4, par5, par6, par7)).createEntityPathTo(par1Entity, par2Entity, par3); + this.theProfiler.endSection(); + return pathentity; + } + + public PathEntity getEntityPathToXYZ(Entity par1Entity, int par2, int par3, int par4, float par5, boolean par6, boolean par7, boolean par8, boolean par9) + { + this.theProfiler.startSection("pathfind"); + int l = MathHelper.floor_double(par1Entity.posX); + int i1 = MathHelper.floor_double(par1Entity.posY); + int j1 = MathHelper.floor_double(par1Entity.posZ); + int k1 = (int)(par5 + 8.0F); + int l1 = l - k1; + int i2 = i1 - k1; + int j2 = j1 - k1; + int k2 = l + k1; + int l2 = i1 + k1; + int i3 = j1 + k1; + ChunkCache chunkcache = new ChunkCache(this, l1, i2, j2, k2, l2, i3, 0); + PathEntity pathentity = (new PathFinder(chunkcache, par6, par7, par8, par9)).createEntityPathTo(par1Entity, par2, par3, par4, par5); + this.theProfiler.endSection(); + return pathentity; + } + + public int isBlockProvidingPowerTo(int par1, int par2, int par3, int par4) + { + return this.getBlock(par1, par2, par3).isProvidingStrongPower(this, par1, par2, par3, par4); + } + + public int getBlockPowerInput(int par1, int par2, int par3) + { + byte b0 = 0; + int l = Math.max(b0, this.isBlockProvidingPowerTo(par1, par2 - 1, par3, 0)); + + if (l >= 15) + { + return l; + } + else + { + l = Math.max(l, this.isBlockProvidingPowerTo(par1, par2 + 1, par3, 1)); + + if (l >= 15) + { + return l; + } + else + { + l = Math.max(l, this.isBlockProvidingPowerTo(par1, par2, par3 - 1, 2)); + + if (l >= 15) + { + return l; + } + else + { + l = Math.max(l, this.isBlockProvidingPowerTo(par1, par2, par3 + 1, 3)); + + if (l >= 15) + { + return l; + } + else + { + l = Math.max(l, this.isBlockProvidingPowerTo(par1 - 1, par2, par3, 4)); + + if (l >= 15) + { + return l; + } + else + { + l = Math.max(l, this.isBlockProvidingPowerTo(par1 + 1, par2, par3, 5)); + return l >= 15 ? l : l; + } + } + } + } + } + } + + public boolean getIndirectPowerOutput(int par1, int par2, int par3, int par4) + { + return this.getIndirectPowerLevelTo(par1, par2, par3, par4) > 0; + } + + public int getIndirectPowerLevelTo(int par1, int par2, int par3, int par4) + { + Block block = this.getBlock(par1, par2, par3); + return block.shouldCheckWeakPower(this, par1, par2, par3, par4) ? this.getBlockPowerInput(par1, par2, par3) : block.isProvidingWeakPower(this, par1, par2, par3, par4); + } + + public boolean isBlockIndirectlyGettingPowered(int par1, int par2, int par3) + { + return this.getIndirectPowerLevelTo(par1, par2 - 1, par3, 0) > 0 ? true : (this.getIndirectPowerLevelTo(par1, par2 + 1, par3, 1) > 0 ? true : (this.getIndirectPowerLevelTo(par1, par2, par3 - 1, 2) > 0 ? true : (this.getIndirectPowerLevelTo(par1, par2, par3 + 1, 3) > 0 ? true : (this.getIndirectPowerLevelTo(par1 - 1, par2, par3, 4) > 0 ? true : this.getIndirectPowerLevelTo(par1 + 1, par2, par3, 5) > 0)))); + } + + public int getStrongestIndirectPower(int par1, int par2, int par3) + { + int l = 0; + + for (int i1 = 0; i1 < 6; ++i1) + { + int j1 = this.getIndirectPowerLevelTo(par1 + Facing.offsetsXForSide[i1], par2 + Facing.offsetsYForSide[i1], par3 + Facing.offsetsZForSide[i1], i1); + + if (j1 >= 15) + { + return 15; + } + + if (j1 > l) + { + l = j1; + } + } + + return l; + } + + public EntityPlayer getClosestPlayerToEntity(Entity par1Entity, double par2) + { + return this.getClosestPlayer(par1Entity.posX, par1Entity.posY, par1Entity.posZ, par2); + } + + public EntityPlayer getClosestPlayer(double par1, double par3, double par5, double par7) + { + double d4 = -1.0D; + EntityPlayer entityplayer = null; + + for (int i = 0; i < this.playerEntities.size(); ++i) + { + EntityPlayer entityplayer1 = (EntityPlayer)this.playerEntities.get(i); + double d5 = entityplayer1.getDistanceSq(par1, par3, par5); + + if ((par7 < 0.0D || d5 < par7 * par7) && (d4 == -1.0D || d5 < d4)) + { + d4 = d5; + entityplayer = entityplayer1; + } + } + + return entityplayer; + } + + public EntityPlayer getClosestVulnerablePlayerToEntity(Entity par1Entity, double par2) + { + return this.getClosestVulnerablePlayer(par1Entity.posX, par1Entity.posY, par1Entity.posZ, par2); + } + + public EntityPlayer getClosestVulnerablePlayer(double par1, double par3, double par5, double par7) + { + double d4 = -1.0D; + EntityPlayer entityplayer = null; + + for (int i = 0; i < this.playerEntities.size(); ++i) + { + EntityPlayer entityplayer1 = (EntityPlayer)this.playerEntities.get(i); + + if (!entityplayer1.capabilities.disableDamage && entityplayer1.isEntityAlive()) + { + double d5 = entityplayer1.getDistanceSq(par1, par3, par5); + double d6 = par7; + + if (entityplayer1.isSneaking()) + { + d6 = par7 * 0.800000011920929D; + } + + if (entityplayer1.isInvisible()) + { + float f = entityplayer1.getArmorVisibility(); + + if (f < 0.1F) + { + f = 0.1F; + } + + d6 *= (double)(0.7F * f); + } + + if ((par7 < 0.0D || d5 < d6 * d6) && (d4 == -1.0D || d5 < d4)) + { + d4 = d5; + entityplayer = entityplayer1; + } + } + } + + return entityplayer; + } + + public EntityPlayer getPlayerEntityByName(String par1Str) + { + for (int i = 0; i < this.playerEntities.size(); ++i) + { + if (par1Str.equals(((EntityPlayer)this.playerEntities.get(i)).getCommandSenderName())) + { + return (EntityPlayer)this.playerEntities.get(i); + } + } + + return null; + } + + @SideOnly(Side.CLIENT) + public void sendQuittingDisconnectingPacket() {} + + public void checkSessionLock() throws MinecraftException + { + this.saveHandler.checkSessionLock(); + } + + @SideOnly(Side.CLIENT) + public void func_82738_a(long par1) + { + this.worldInfo.incrementTotalWorldTime(par1); + } + + public long getSeed() + { + return provider.getSeed(); + } + + public long getTotalWorldTime() + { + return this.worldInfo.getWorldTotalTime(); + } + + public long getWorldTime() + { + return provider.getWorldTime(); + } + + public void setWorldTime(long par1) + { + provider.setWorldTime(par1); + } + + public ChunkCoordinates getSpawnPoint() + { + return provider.getSpawnPoint(); + } + + public void setSpawnLocation(int par1, int par2, int par3) + { + provider.setSpawnPoint(par1, par2, par3); + } + + @SideOnly(Side.CLIENT) + public void joinEntityInSurroundings(Entity par1Entity) + { + int i = MathHelper.floor_double(par1Entity.posX / 16.0D); + int j = MathHelper.floor_double(par1Entity.posZ / 16.0D); + byte b0 = 2; + + for (int k = i - b0; k <= i + b0; ++k) + { + for (int l = j - b0; l <= j + b0; ++l) + { + this.getChunkFromChunkCoords(k, l); + } + } + + if (!this.loadedEntityList.contains(par1Entity)) + { + if (!MinecraftForge.EVENT_BUS.post(new EntityJoinWorldEvent(par1Entity, this))) + { + this.loadedEntityList.add(par1Entity); + } + } + } + + public boolean canMineBlock(EntityPlayer par1EntityPlayer, int par2, int par3, int par4) + { + return provider.canMineBlock(par1EntityPlayer, par2, par3, par4); + } + + public boolean canMineBlockBody(EntityPlayer par1EntityPlayer, int par2, int par3, int par4) + { + return true; + } + + public void setEntityState(Entity par1Entity, byte par2) {} + + public IChunkProvider getChunkProvider() + { + return this.chunkProvider; + } + + public void addBlockEvent(int p_147452_1_, int p_147452_2_, int p_147452_3_, Block p_147452_4_, int p_147452_5_, int p_147452_6_) + { + p_147452_4_.onBlockEventReceived(this, p_147452_1_, p_147452_2_, p_147452_3_, p_147452_5_, p_147452_6_); + } + + public ISaveHandler getSaveHandler() + { + return this.saveHandler; + } + + public WorldInfo getWorldInfo() + { + return this.worldInfo; + } + + public GameRules getGameRules() + { + return this.worldInfo.getGameRulesInstance(); + } + + public void updateAllPlayersSleepingFlag() {} + + public float getWeightedThunderStrength(float par1) + { + return (this.prevThunderingStrength + (this.thunderingStrength - this.prevThunderingStrength) * par1) * this.getRainStrength(par1); + } + + @SideOnly(Side.CLIENT) + public void setThunderStrength(float p_147442_1_) + { + this.prevThunderingStrength = p_147442_1_; + this.thunderingStrength = p_147442_1_; + } + + public float getRainStrength(float par1) + { + return this.prevRainingStrength + (this.rainingStrength - this.prevRainingStrength) * par1; + } + + @SideOnly(Side.CLIENT) + public void setRainStrength(float par1) + { + this.prevRainingStrength = par1; + this.rainingStrength = par1; + } + + public boolean isThundering() + { + return (double)this.getWeightedThunderStrength(1.0F) > 0.9D; + } + + public boolean isRaining() + { + return (double)this.getRainStrength(1.0F) > 0.2D; + } + + public boolean canLightningStrikeAt(int par1, int par2, int par3) + { + if (!this.isRaining()) + { + return false; + } + else if (!this.canBlockSeeTheSky(par1, par2, par3)) + { + return false; + } + else if (this.getPrecipitationHeight(par1, par3) > par2) + { + return false; + } + else + { + BiomeGenBase biomegenbase = this.getBiomeGenForCoords(par1, par3); + return biomegenbase.getEnableSnow() ? false : (this.func_147478_e(par1, par2, par3, false) ? false : biomegenbase.canSpawnLightningBolt()); + } + } + + public boolean isBlockHighHumidity(int par1, int par2, int par3) + { + return provider.isBlockHighHumidity(par1, par2, par3); + } + + public void setItemData(String par1Str, WorldSavedData par2WorldSavedData) + { + this.mapStorage.setData(par1Str, par2WorldSavedData); + } + + public WorldSavedData loadItemData(Class par1Class, String par2Str) + { + return this.mapStorage.loadData(par1Class, par2Str); + } + + public int getUniqueDataId(String par1Str) + { + return this.mapStorage.getUniqueDataId(par1Str); + } + + public void playBroadcastSound(int par1, int par2, int par3, int par4, int par5) + { + for (int j1 = 0; j1 < this.worldAccesses.size(); ++j1) + { + ((IWorldAccess)this.worldAccesses.get(j1)).broadcastSound(par1, par2, par3, par4, par5); + } + } + + public void playAuxSFX(int par1, int par2, int par3, int par4, int par5) + { + this.playAuxSFXAtEntity((EntityPlayer)null, par1, par2, par3, par4, par5); + } + + public void playAuxSFXAtEntity(EntityPlayer par1EntityPlayer, int par2, int par3, int par4, int par5, int par6) + { + try + { + for (int j1 = 0; j1 < this.worldAccesses.size(); ++j1) + { + ((IWorldAccess)this.worldAccesses.get(j1)).playAuxSFX(par1EntityPlayer, par2, par3, par4, par5, par6); + } + } + catch (Throwable throwable) + { + CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Playing level event"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("Level event being played"); + crashreportcategory.addCrashSection("Block coordinates", CrashReportCategory.getLocationInfo(par3, par4, par5)); + crashreportcategory.addCrashSection("Event source", par1EntityPlayer); + crashreportcategory.addCrashSection("Event type", Integer.valueOf(par2)); + crashreportcategory.addCrashSection("Event data", Integer.valueOf(par6)); + throw new ReportedException(crashreport); + } + } + + public int getHeight() + { + return provider.getHeight(); + } + + public int getActualHeight() + { + return provider.getActualHeight(); + } + + public Random setRandomSeed(int par1, int par2, int par3) + { + long l = (long)par1 * 341873128712L + (long)par2 * 132897987541L + this.getWorldInfo().getSeed() + (long)par3; + this.rand.setSeed(l); + return this.rand; + } + + public ChunkPosition findClosestStructure(String p_147440_1_, int p_147440_2_, int p_147440_3_, int p_147440_4_) + { + return this.getChunkProvider().func_147416_a(this, p_147440_1_, p_147440_2_, p_147440_3_, p_147440_4_); + } + + @SideOnly(Side.CLIENT) + public boolean extendedLevelsInChunkCache() + { + return false; + } + + @SideOnly(Side.CLIENT) + public double getHorizon() + { + return provider.getHorizon(); + } + + public CrashReportCategory addWorldInfoToCrashReport(CrashReport par1CrashReport) + { + CrashReportCategory crashreportcategory = par1CrashReport.makeCategoryDepth("Affected level", 1); + crashreportcategory.addCrashSection("Level name", this.worldInfo == null ? "????" : this.worldInfo.getWorldName()); + crashreportcategory.addCrashSectionCallable("All players", new Callable() + { + private static final String __OBFID = "CL_00000143"; + public String call() + { + return World.this.playerEntities.size() + " total; " + World.this.playerEntities.toString(); + } + }); + crashreportcategory.addCrashSectionCallable("Chunk stats", new Callable() + { + private static final String __OBFID = "CL_00000144"; + public String call() + { + return World.this.chunkProvider.makeString(); + } + }); + + try + { + this.worldInfo.addToCrashReport(crashreportcategory); + } + catch (Throwable throwable) + { + crashreportcategory.addCrashSectionThrowable("Level Data Unobtainable", throwable); + } + + return crashreportcategory; + } + + public void destroyBlockInWorldPartially(int p_147443_1_, int p_147443_2_, int p_147443_3_, int p_147443_4_, int p_147443_5_) + { + for (int j1 = 0; j1 < this.worldAccesses.size(); ++j1) + { + IWorldAccess iworldaccess = (IWorldAccess)this.worldAccesses.get(j1); + iworldaccess.destroyBlockPartially(p_147443_1_, p_147443_2_, p_147443_3_, p_147443_4_, p_147443_5_); + } + } + + public Vec3Pool getWorldVec3Pool() + { + return this.vecPool; + } + + public Calendar getCurrentDate() + { + if (this.getTotalWorldTime() % 600L == 0L) + { + this.theCalendar.setTimeInMillis(MinecraftServer.getSystemTimeMillis()); + } + + return this.theCalendar; + } + + @SideOnly(Side.CLIENT) + public void makeFireworks(double par1, double par3, double par5, double par7, double par9, double par11, NBTTagCompound par13NBTTagCompound) {} + + public Scoreboard getScoreboard() + { + return this.worldScoreboard; + } + + public void func_147453_f(int p_147453_1_, int p_147453_2_, int p_147453_3_, Block p_147453_4_) + { + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) + { + int i1 = p_147453_1_ + dir.offsetX; + int y = p_147453_2_ + dir.offsetY; + int j1 = p_147453_3_ + dir.offsetZ; + Block block1 = this.getBlock(i1, y, j1); + + block1.onNeighborChange(this, i1, y, j1, p_147453_1_, p_147453_2_, p_147453_3_); + if (block1.isNormalCube(this, i1, p_147453_2_, j1)) + { + i1 += dir.offsetX; + y += dir.offsetY; + j1 += dir.offsetZ; + Block block2 = this.getBlock(i1, y, j1); + + if (block2.getWeakChanges(this, i1, y, j1)) + { + block2.onNeighborChange(this, i1, y, j1, p_147453_1_, p_147453_2_, p_147453_3_); + } + } + } + } + + public float func_147462_b(double p_147462_1_, double p_147462_3_, double p_147462_5_) + { + return this.func_147473_B(MathHelper.floor_double(p_147462_1_), MathHelper.floor_double(p_147462_3_), MathHelper.floor_double(p_147462_5_)); + } + + public float func_147473_B(int p_147473_1_, int p_147473_2_, int p_147473_3_) + { + float f = 0.0F; + boolean flag = this.difficultySetting == EnumDifficulty.HARD; + + if (this.blockExists(p_147473_1_, p_147473_2_, p_147473_3_)) + { + float f1 = this.getCurrentMoonPhaseFactor(); + f += MathHelper.clamp_float((float)this.getChunkFromBlockCoords(p_147473_1_, p_147473_3_).inhabitedTime / 3600000.0F, 0.0F, 1.0F) * (flag ? 1.0F : 0.75F); + f += f1 * 0.25F; + } + + if (this.difficultySetting == EnumDifficulty.EASY || this.difficultySetting == EnumDifficulty.PEACEFUL) + { + f *= (float)this.difficultySetting.getDifficultyId() / 2.0F; + } + + return MathHelper.clamp_float(f, 0.0F, flag ? 1.5F : 1.0F); + } + + public void func_147450_X() + { + Iterator iterator = this.worldAccesses.iterator(); + + while (iterator.hasNext()) + { + IWorldAccess iworldaccess = (IWorldAccess)iterator.next(); + iworldaccess.onStaticEntitiesChanged(); + } + } + + + /* ======================================== FORGE START =====================================*/ + /** + * Adds a single TileEntity to the world. + * @param entity The TileEntity to be added. + */ + public void addTileEntity(TileEntity entity) + { + List dest = field_147481_N ? addedTileEntityList : loadedTileEntityList; + if(entity.canUpdate()) + { + dest.add(entity); + } + } + + /** + * Determine if the given block is considered solid on the + * specified side. Used by placement logic. + * + * @param x Block X Position + * @param y Block Y Position + * @param z Block Z Position + * @param side The Side in question + * @return True if the side is solid + */ + public boolean isSideSolid(int x, int y, int z, ForgeDirection side) + { + return isSideSolid(x, y, z, side, false); + } + + /** + * Determine if the given block is considered solid on the + * specified side. Used by placement logic. + * + * @param x Block X Position + * @param y Block Y Position + * @param z Block Z Position + * @param side The Side in question + * @param _default The default to return if the block doesn't exist. + * @return True if the side is solid + */ + @Override + public boolean isSideSolid(int x, int y, int z, ForgeDirection side, boolean _default) + { + if (x < -30000000 || z < -30000000 || x >= 30000000 || z >= 30000000) + { + return _default; + } + + Chunk chunk = this.chunkProvider.provideChunk(x >> 4, z >> 4); + if (chunk == null || chunk.isEmpty()) + { + return _default; + } + return getBlock(x, y, z).isSideSolid(this, x, y, z, side); + } + + /** + * Get the persistent chunks for this world + * + * @return + */ + public ImmutableSetMultimap getPersistentChunks() + { + return ForgeChunkManager.getPersistentChunksFor(this); + } + + /** + * Readded as it was removed, very useful helper function + * + * @param x X position + * @param y Y Position + * @param z Z Position + * @return The blocks light opacity + */ + public int getBlockLightOpacity(int x, int y, int z) + { + if (x < -30000000 || z < -30000000 || x >= 30000000 || z >= 30000000) + { + return 0; + } + + if (y < 0 || y >= 256) + { + return 0; + } + + return getChunkFromChunkCoords(x >> 4, z >> 4).func_150808_b(x & 15, y, z & 15); + } + + /** + * Returns a count of entities that classify themselves as the specified creature type. + */ + public int countEntities(EnumCreatureType type, boolean forSpawnCount) + { + int count = 0; + for (int x = 0; x < loadedEntityList.size(); x++) + { + if (((Entity)loadedEntityList.get(x)).isCreatureType(type, forSpawnCount)) + { + count++; + } + } + return count; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/WorldManager.java b/src/main/java/net/minecraft/world/WorldManager.java new file mode 100644 index 0000000..653e7c0 --- /dev/null +++ b/src/main/java/net/minecraft/world/WorldManager.java @@ -0,0 +1,90 @@ +package net.minecraft.world; + +import java.util.Iterator; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.network.play.server.S25PacketBlockBreakAnim; +import net.minecraft.network.play.server.S28PacketEffect; +import net.minecraft.network.play.server.S29PacketSoundEffect; +import net.minecraft.server.MinecraftServer; + +public class WorldManager implements IWorldAccess +{ + private MinecraftServer mcServer; + private WorldServer theWorldServer; + private static final String __OBFID = "CL_00001433"; + + public WorldManager(MinecraftServer par1MinecraftServer, WorldServer par2WorldServer) + { + this.mcServer = par1MinecraftServer; + this.theWorldServer = par2WorldServer; + } + + public void spawnParticle(String par1Str, double par2, double par4, double par6, double par8, double par10, double par12) {} + + public void onEntityCreate(Entity par1Entity) + { + this.theWorldServer.getEntityTracker().addEntityToTracker(par1Entity); + } + + public void onEntityDestroy(Entity par1Entity) + { + this.theWorldServer.getEntityTracker().removeEntityFromAllTrackingPlayers(par1Entity); + } + + public void playSound(String par1Str, double par2, double par4, double par6, float par8, float par9) + { + this.mcServer.getConfigurationManager().sendToAllNear(par2, par4, par6, par8 > 1.0F ? (double)(16.0F * par8) : 16.0D, this.theWorldServer.provider.dimensionId, new S29PacketSoundEffect(par1Str, par2, par4, par6, par8, par9)); + } + + public void playSoundToNearExcept(EntityPlayer par1EntityPlayer, String par2Str, double par3, double par5, double par7, float par9, float par10) + { + this.mcServer.getConfigurationManager().sendToAllNearExcept(par1EntityPlayer, par3, par5, par7, par9 > 1.0F ? (double)(16.0F * par9) : 16.0D, this.theWorldServer.provider.dimensionId, new S29PacketSoundEffect(par2Str, par3, par5, par7, par9, par10)); + } + + public void markBlockRangeForRenderUpdate(int p_147585_1_, int p_147585_2_, int p_147585_3_, int p_147585_4_, int p_147585_5_, int p_147585_6_) {} + + public void markBlockForUpdate(int p_147586_1_, int p_147586_2_, int p_147586_3_) + { + this.theWorldServer.getPlayerManager().markBlockForUpdate(p_147586_1_, p_147586_2_, p_147586_3_); + } + + public void markBlockForRenderUpdate(int p_147588_1_, int p_147588_2_, int p_147588_3_) {} + + public void playRecord(String par1Str, int par2, int par3, int par4) {} + + public void playAuxSFX(EntityPlayer par1EntityPlayer, int par2, int par3, int par4, int par5, int par6) + { + this.mcServer.getConfigurationManager().sendToAllNearExcept(par1EntityPlayer, (double)par3, (double)par4, (double)par5, 64.0D, this.theWorldServer.provider.dimensionId, new S28PacketEffect(par2, par3, par4, par5, par6, false)); + } + + public void broadcastSound(int par1, int par2, int par3, int par4, int par5) + { + this.mcServer.getConfigurationManager().sendPacketToAllPlayers(new S28PacketEffect(par1, par2, par3, par4, par5, true)); + } + + public void destroyBlockPartially(int p_147587_1_, int p_147587_2_, int p_147587_3_, int p_147587_4_, int p_147587_5_) + { + Iterator iterator = this.mcServer.getConfigurationManager().playerEntityList.iterator(); + + while (iterator.hasNext()) + { + EntityPlayerMP entityplayermp = (EntityPlayerMP)iterator.next(); + + if (entityplayermp != null && entityplayermp.worldObj == this.theWorldServer && entityplayermp.getEntityId() != p_147587_1_) + { + double d0 = (double)p_147587_2_ - entityplayermp.posX; + double d1 = (double)p_147587_3_ - entityplayermp.posY; + double d2 = (double)p_147587_4_ - entityplayermp.posZ; + + if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) + { + entityplayermp.playerNetServerHandler.sendPacket(new S25PacketBlockBreakAnim(p_147587_1_, p_147587_2_, p_147587_3_, p_147587_4_, p_147587_5_)); + } + } + } + } + + public void onStaticEntitiesChanged() {} +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/WorldProvider.java b/src/main/java/net/minecraft/world/WorldProvider.java new file mode 100644 index 0000000..b4da1f7 --- /dev/null +++ b/src/main/java/net/minecraft/world/WorldProvider.java @@ -0,0 +1,485 @@ +package net.minecraft.world; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.init.Blocks; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; +import net.minecraft.world.WorldSettings.GameType; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.biome.WorldChunkManager; +import net.minecraft.world.biome.WorldChunkManagerHell; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.IChunkProvider; +import net.minecraft.world.gen.ChunkProviderFlat; +import net.minecraft.world.gen.ChunkProviderGenerate; +import net.minecraft.world.gen.FlatGeneratorInfo; +import net.minecraft.world.storage.WorldInfo; +import net.minecraftforge.client.IRenderHandler; +import net.minecraftforge.common.DimensionManager; + +public abstract class WorldProvider +{ + public static final float[] moonPhaseFactors = new float[] {1.0F, 0.75F, 0.5F, 0.25F, 0.0F, 0.25F, 0.5F, 0.75F}; + public World worldObj; + public WorldType terrainType; + public String field_82913_c; + public WorldChunkManager worldChunkMgr; + public boolean isHellWorld; + public boolean hasNoSky; + public float[] lightBrightnessTable = new float[16]; + public int dimensionId; + private float[] colorsSunriseSunset = new float[4]; + private static final String __OBFID = "CL_00000386"; + + public final void registerWorld(World par1World) + { + this.worldObj = par1World; + this.terrainType = par1World.getWorldInfo().getTerrainType(); + this.field_82913_c = par1World.getWorldInfo().getGeneratorOptions(); + this.registerWorldChunkManager(); + this.generateLightBrightnessTable(); + } + + protected void generateLightBrightnessTable() + { + float f = 0.0F; + + for (int i = 0; i <= 15; ++i) + { + float f1 = 1.0F - (float)i / 15.0F; + this.lightBrightnessTable[i] = (1.0F - f1) / (f1 * 3.0F + 1.0F) * (1.0F - f) + f; + } + } + + protected void registerWorldChunkManager() + { + this.worldChunkMgr = terrainType.getChunkManager(worldObj); + } + + public IChunkProvider createChunkGenerator() + { + return terrainType.getChunkGenerator(worldObj, field_82913_c); + } + + public boolean canCoordinateBeSpawn(int par1, int par2) + { + return this.worldObj.getTopBlock(par1, par2) == Blocks.grass; + } + + public float calculateCelestialAngle(long par1, float par3) + { + int j = (int)(par1 % 24000L); + float f1 = ((float)j + par3) / 24000.0F - 0.25F; + + if (f1 < 0.0F) + { + ++f1; + } + + if (f1 > 1.0F) + { + --f1; + } + + float f2 = f1; + f1 = 1.0F - (float)((Math.cos((double)f1 * Math.PI) + 1.0D) / 2.0D); + f1 = f2 + (f1 - f2) / 3.0F; + return f1; + } + + public int getMoonPhase(long par1) + { + return (int)(par1 / 24000L % 8L + 8L) % 8; + } + + public boolean isSurfaceWorld() + { + return true; + } + + @SideOnly(Side.CLIENT) + public float[] calcSunriseSunsetColors(float par1, float par2) + { + float f2 = 0.4F; + float f3 = MathHelper.cos(par1 * (float)Math.PI * 2.0F) - 0.0F; + float f4 = -0.0F; + + if (f3 >= f4 - f2 && f3 <= f4 + f2) + { + float f5 = (f3 - f4) / f2 * 0.5F + 0.5F; + float f6 = 1.0F - (1.0F - MathHelper.sin(f5 * (float)Math.PI)) * 0.99F; + f6 *= f6; + this.colorsSunriseSunset[0] = f5 * 0.3F + 0.7F; + this.colorsSunriseSunset[1] = f5 * f5 * 0.7F + 0.2F; + this.colorsSunriseSunset[2] = f5 * f5 * 0.0F + 0.2F; + this.colorsSunriseSunset[3] = f6; + return this.colorsSunriseSunset; + } + else + { + return null; + } + } + + @SideOnly(Side.CLIENT) + public Vec3 getFogColor(float par1, float par2) + { + float f2 = MathHelper.cos(par1 * (float)Math.PI * 2.0F) * 2.0F + 0.5F; + + if (f2 < 0.0F) + { + f2 = 0.0F; + } + + if (f2 > 1.0F) + { + f2 = 1.0F; + } + + float f3 = 0.7529412F; + float f4 = 0.84705883F; + float f5 = 1.0F; + f3 *= f2 * 0.94F + 0.06F; + f4 *= f2 * 0.94F + 0.06F; + f5 *= f2 * 0.91F + 0.09F; + return this.worldObj.getWorldVec3Pool().getVecFromPool((double)f3, (double)f4, (double)f5); + } + + public boolean canRespawnHere() + { + return true; + } + + public static WorldProvider getProviderForDimension(int par0) + { + return DimensionManager.createProviderFor(par0); + } + + @SideOnly(Side.CLIENT) + public float getCloudHeight() + { + return this.terrainType.getCloudHeight(); + } + + @SideOnly(Side.CLIENT) + public boolean isSkyColored() + { + return true; + } + + public ChunkCoordinates getEntrancePortalLocation() + { + return null; + } + + public int getAverageGroundLevel() + { + return this.terrainType.getMinimumSpawnHeight(this.worldObj); + } + + @SideOnly(Side.CLIENT) + public boolean getWorldHasVoidParticles() + { + return this.terrainType.hasVoidParticles(this.hasNoSky); + } + + @SideOnly(Side.CLIENT) + public double getVoidFogYFactor() + { + return this.terrainType.voidFadeMagnitude(); + } + + @SideOnly(Side.CLIENT) + public boolean doesXZShowFog(int par1, int par2) + { + return false; + } + + public abstract String getDimensionName(); + + /*======================================= Forge Start =========================================*/ + private IRenderHandler skyRenderer = null; + private IRenderHandler cloudRenderer = null; + private IRenderHandler weatherRenderer = null; + + /** + * Sets the providers current dimension ID, used in default getSaveFolder() + * Added to allow default providers to be registered for multiple dimensions. + * + * @param dim Dimension ID + */ + public void setDimension(int dim) + { + this.dimensionId = dim; + } + + /** + * Returns the sub-folder of the world folder that this WorldProvider saves to. + * EXA: DIM1, DIM-1 + * @return The sub-folder name to save this world's chunks to. + */ + public String getSaveFolder() + { + return (dimensionId == 0 ? null : "DIM" + dimensionId); + } + + /** + * A message to display to the user when they transfer to this dimension. + * + * @return The message to be displayed + */ + public String getWelcomeMessage() + { + if (this instanceof WorldProviderEnd) + { + return "Entering the End"; + } + else if (this instanceof WorldProviderHell) + { + return "Entering the Nether"; + } + return null; + } + + /** + * A Message to display to the user when they transfer out of this dismension. + * + * @return The message to be displayed + */ + public String getDepartMessage() + { + if (this instanceof WorldProviderEnd) + { + return "Leaving the End"; + } + else if (this instanceof WorldProviderHell) + { + return "Leaving the Nether"; + } + return null; + } + + /** + * The dimensions movement factor. Relative to normal overworld. + * It is applied to the players position when they transfer dimensions. + * Exa: Nether movement is 8.0 + * @return The movement factor + */ + public double getMovementFactor() + { + if (this instanceof WorldProviderHell) + { + return 8.0; + } + return 1.0; + } + + @SideOnly(Side.CLIENT) + public IRenderHandler getSkyRenderer() + { + return this.skyRenderer; + } + + @SideOnly(Side.CLIENT) + public void setSkyRenderer(IRenderHandler skyRenderer) + { + this.skyRenderer = skyRenderer; + } + + @SideOnly(Side.CLIENT) + public IRenderHandler getCloudRenderer() + { + return cloudRenderer; + } + + @SideOnly(Side.CLIENT) + public void setCloudRenderer(IRenderHandler renderer) + { + cloudRenderer = renderer; + } + + @SideOnly(Side.CLIENT) + public IRenderHandler getWeatherRenderer() + { + return weatherRenderer; + } + + @SideOnly(Side.CLIENT) + public void setWeatherRenderer(IRenderHandler renderer) + { + weatherRenderer = renderer; + } + + public ChunkCoordinates getRandomizedSpawnPoint() + { + ChunkCoordinates chunkcoordinates = new ChunkCoordinates(this.worldObj.getSpawnPoint()); + + boolean isAdventure = worldObj.getWorldInfo().getGameType() == GameType.ADVENTURE; + int spawnFuzz = terrainType.getSpawnFuzz(); + int spawnFuzzHalf = spawnFuzz / 2; + + if (!hasNoSky && !isAdventure) + { + chunkcoordinates.posX += this.worldObj.rand.nextInt(spawnFuzz) - spawnFuzzHalf; + chunkcoordinates.posZ += this.worldObj.rand.nextInt(spawnFuzz) - spawnFuzzHalf; + chunkcoordinates.posY = this.worldObj.getTopSolidOrLiquidBlock(chunkcoordinates.posX, chunkcoordinates.posZ); + } + + return chunkcoordinates; + } + + /** + * Determine if the cusor on the map should 'spin' when rendered, like it does for the player in the nether. + * + * @param entity The entity holding the map, playername, or frame-ENTITYID + * @param x X Position + * @param y Y Position + * @param z Z Postion + * @return True to 'spin' the cursor + */ + public boolean shouldMapSpin(String entity, double x, double y, double z) + { + return dimensionId < 0; + } + + /** + * Determines the dimension the player will be respawned in, typically this brings them back to the overworld. + * + * @param player The player that is respawning + * @return The dimension to respawn the player in + */ + public int getRespawnDimension(EntityPlayerMP player) + { + return 0; + } + + /*======================================= Start Moved From World =========================================*/ + + public BiomeGenBase getBiomeGenForCoords(int x, int z) + { + return worldObj.getBiomeGenForCoordsBody(x, z); + } + + public boolean isDaytime() + { + return worldObj.skylightSubtracted < 4; + } + + @SideOnly(Side.CLIENT) + public Vec3 getSkyColor(Entity cameraEntity, float partialTicks) + { + return worldObj.getSkyColorBody(cameraEntity, partialTicks); + } + + @SideOnly(Side.CLIENT) + public Vec3 drawClouds(float partialTicks) + { + return worldObj.drawCloudsBody(partialTicks); + } + + @SideOnly(Side.CLIENT) + public float getStarBrightness(float par1) + { + return worldObj.getStarBrightnessBody(par1); + } + + public void setAllowedSpawnTypes(boolean allowHostile, boolean allowPeaceful) + { + worldObj.spawnHostileMobs = allowHostile; + worldObj.spawnPeacefulMobs = allowPeaceful; + } + + public void calculateInitialWeather() + { + worldObj.calculateInitialWeatherBody(); + } + + public void updateWeather() + { + worldObj.updateWeatherBody(); + } + + public boolean canBlockFreeze(int x, int y, int z, boolean byWater) + { + return worldObj.canBlockFreezeBody(x, y, z, byWater); + } + + public boolean canSnowAt(int x, int y, int z, boolean checkLight) + { + return worldObj.canSnowAtBody(x, y, z, checkLight); + } + + public void setWorldTime(long time) + { + worldObj.worldInfo.setWorldTime(time); + } + + public long getSeed() + { + return worldObj.worldInfo.getSeed(); + } + + public long getWorldTime() + { + return worldObj.worldInfo.getWorldTime(); + } + + public ChunkCoordinates getSpawnPoint() + { + WorldInfo info = worldObj.worldInfo; + return new ChunkCoordinates(info.getSpawnX(), info.getSpawnY(), info.getSpawnZ()); + } + + public void setSpawnPoint(int x, int y, int z) + { + worldObj.worldInfo.setSpawnPosition(x, y, z); + } + + public boolean canMineBlock(EntityPlayer player, int x, int y, int z) + { + return worldObj.canMineBlockBody(player, x, y, z); + } + + public boolean isBlockHighHumidity(int x, int y, int z) + { + return worldObj.getBiomeGenForCoords(x, z).isHighHumidity(); + } + + public int getHeight() + { + return 256; + } + + public int getActualHeight() + { + return hasNoSky ? 128 : 256; + } + + public double getHorizon() + { + return worldObj.worldInfo.getTerrainType().getHorizon(worldObj); + } + + public void resetRainAndThunder() + { + worldObj.worldInfo.setRainTime(0); + worldObj.worldInfo.setRaining(false); + worldObj.worldInfo.setThunderTime(0); + worldObj.worldInfo.setThundering(false); + } + + public boolean canDoLightning(Chunk chunk) + { + return true; + } + + public boolean canDoRainSnowIce(Chunk chunk) + { + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/WorldProviderEnd.java b/src/main/java/net/minecraft/world/WorldProviderEnd.java new file mode 100644 index 0000000..f43a0dd --- /dev/null +++ b/src/main/java/net/minecraft/world/WorldProviderEnd.java @@ -0,0 +1,112 @@ +package net.minecraft.world; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.biome.WorldChunkManagerHell; +import net.minecraft.world.chunk.IChunkProvider; +import net.minecraft.world.gen.ChunkProviderEnd; + +public class WorldProviderEnd extends WorldProvider +{ + private static final String __OBFID = "CL_00000389"; + + public void registerWorldChunkManager() + { + this.worldChunkMgr = new WorldChunkManagerHell(BiomeGenBase.sky, 0.0F); + this.dimensionId = 1; + this.hasNoSky = true; + } + + public IChunkProvider createChunkGenerator() + { + return new ChunkProviderEnd(this.worldObj, this.worldObj.getSeed()); + } + + public float calculateCelestialAngle(long par1, float par3) + { + return 0.0F; + } + + @SideOnly(Side.CLIENT) + public float[] calcSunriseSunsetColors(float par1, float par2) + { + return null; + } + + @SideOnly(Side.CLIENT) + public Vec3 getFogColor(float par1, float par2) + { + int i = 10518688; + float f2 = MathHelper.cos(par1 * (float)Math.PI * 2.0F) * 2.0F + 0.5F; + + if (f2 < 0.0F) + { + f2 = 0.0F; + } + + if (f2 > 1.0F) + { + f2 = 1.0F; + } + + float f3 = (float)(i >> 16 & 255) / 255.0F; + float f4 = (float)(i >> 8 & 255) / 255.0F; + float f5 = (float)(i & 255) / 255.0F; + f3 *= f2 * 0.0F + 0.15F; + f4 *= f2 * 0.0F + 0.15F; + f5 *= f2 * 0.0F + 0.15F; + return this.worldObj.getWorldVec3Pool().getVecFromPool((double)f3, (double)f4, (double)f5); + } + + @SideOnly(Side.CLIENT) + public boolean isSkyColored() + { + return false; + } + + public boolean canRespawnHere() + { + return false; + } + + public boolean isSurfaceWorld() + { + return false; + } + + @SideOnly(Side.CLIENT) + public float getCloudHeight() + { + return 8.0F; + } + + public boolean canCoordinateBeSpawn(int par1, int par2) + { + return this.worldObj.getTopBlock(par1, par2).getMaterial().blocksMovement(); + } + + public ChunkCoordinates getEntrancePortalLocation() + { + return new ChunkCoordinates(100, 50, 0); + } + + public int getAverageGroundLevel() + { + return 50; + } + + @SideOnly(Side.CLIENT) + public boolean doesXZShowFog(int par1, int par2) + { + return true; + } + + public String getDimensionName() + { + return "The End"; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/WorldProviderHell.java b/src/main/java/net/minecraft/world/WorldProviderHell.java new file mode 100644 index 0000000..15a6aa3 --- /dev/null +++ b/src/main/java/net/minecraft/world/WorldProviderHell.java @@ -0,0 +1,75 @@ +package net.minecraft.world; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.util.Vec3; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.biome.WorldChunkManagerHell; +import net.minecraft.world.chunk.IChunkProvider; +import net.minecraft.world.gen.ChunkProviderHell; + +public class WorldProviderHell extends WorldProvider +{ + private static final String __OBFID = "CL_00000387"; + + public void registerWorldChunkManager() + { + this.worldChunkMgr = new WorldChunkManagerHell(BiomeGenBase.hell, 0.0F); + this.isHellWorld = true; + this.hasNoSky = true; + this.dimensionId = -1; + } + + @SideOnly(Side.CLIENT) + public Vec3 getFogColor(float par1, float par2) + { + return this.worldObj.getWorldVec3Pool().getVecFromPool(0.20000000298023224D, 0.029999999329447746D, 0.029999999329447746D); + } + + protected void generateLightBrightnessTable() + { + float f = 0.1F; + + for (int i = 0; i <= 15; ++i) + { + float f1 = 1.0F - (float)i / 15.0F; + this.lightBrightnessTable[i] = (1.0F - f1) / (f1 * 3.0F + 1.0F) * (1.0F - f) + f; + } + } + + public IChunkProvider createChunkGenerator() + { + return new ChunkProviderHell(this.worldObj, this.worldObj.getSeed()); + } + + public boolean isSurfaceWorld() + { + return false; + } + + public boolean canCoordinateBeSpawn(int par1, int par2) + { + return false; + } + + public float calculateCelestialAngle(long par1, float par3) + { + return 0.5F; + } + + public boolean canRespawnHere() + { + return false; + } + + @SideOnly(Side.CLIENT) + public boolean doesXZShowFog(int par1, int par2) + { + return true; + } + + public String getDimensionName() + { + return "Nether"; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/WorldProviderSurface.java b/src/main/java/net/minecraft/world/WorldProviderSurface.java new file mode 100644 index 0000000..38c699f --- /dev/null +++ b/src/main/java/net/minecraft/world/WorldProviderSurface.java @@ -0,0 +1,11 @@ +package net.minecraft.world; + +public class WorldProviderSurface extends WorldProvider +{ + private static final String __OBFID = "CL_00000388"; + + public String getDimensionName() + { + return "Overworld"; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/WorldSavedData.java b/src/main/java/net/minecraft/world/WorldSavedData.java new file mode 100644 index 0000000..5ec46a0 --- /dev/null +++ b/src/main/java/net/minecraft/world/WorldSavedData.java @@ -0,0 +1,34 @@ +package net.minecraft.world; + +import net.minecraft.nbt.NBTTagCompound; + +public abstract class WorldSavedData +{ + public final String mapName; + private boolean dirty; + private static final String __OBFID = "CL_00000580"; + + public WorldSavedData(String par1Str) + { + this.mapName = par1Str; + } + + public abstract void readFromNBT(NBTTagCompound var1); + + public abstract void writeToNBT(NBTTagCompound var1); + + public void markDirty() + { + this.setDirty(true); + } + + public void setDirty(boolean par1) + { + this.dirty = par1; + } + + public boolean isDirty() + { + return this.dirty; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/WorldServer.java b/src/main/java/net/minecraft/world/WorldServer.java new file mode 100644 index 0000000..2cc38e0 --- /dev/null +++ b/src/main/java/net/minecraft/world/WorldServer.java @@ -0,0 +1,1060 @@ +package net.minecraft.world; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.File; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import java.util.Set; +import java.util.TreeSet; +import net.minecraft.block.Block; +import net.minecraft.block.BlockEventData; +import net.minecraft.block.material.Material; +import net.minecraft.crash.CrashReport; +import net.minecraft.crash.CrashReportCategory; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityTracker; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.INpc; +import net.minecraft.entity.effect.EntityLightningBolt; +import net.minecraft.entity.passive.EntityAnimal; +import net.minecraft.entity.passive.EntityWaterMob; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.network.play.server.S19PacketEntityStatus; +import net.minecraft.network.play.server.S24PacketBlockAction; +import net.minecraft.network.play.server.S27PacketExplosion; +import net.minecraft.network.play.server.S2APacketParticles; +import net.minecraft.network.play.server.S2BPacketChangeGameState; +import net.minecraft.network.play.server.S2CPacketSpawnGlobalEntity; +import net.minecraft.profiler.Profiler; +import net.minecraft.scoreboard.ScoreboardSaveData; +import net.minecraft.scoreboard.ServerScoreboard; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.management.PlayerManager; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.IProgressUpdate; +import net.minecraft.util.IntHashMap; +import net.minecraft.util.ReportedException; +import net.minecraft.util.Vec3; +import net.minecraft.util.WeightedRandom; +import net.minecraft.util.WeightedRandomChestContent; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.biome.WorldChunkManager; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.IChunkProvider; +import net.minecraft.world.chunk.storage.AnvilChunkLoader; +import net.minecraft.world.chunk.storage.ExtendedBlockStorage; +import net.minecraft.world.chunk.storage.IChunkLoader; +import net.minecraft.world.gen.ChunkProviderServer; +import net.minecraft.world.gen.feature.WorldGeneratorBonusChest; +import net.minecraft.world.storage.ISaveHandler; +import net.minecraftforge.common.ChestGenHooks; +import static net.minecraftforge.common.ChestGenHooks.BONUS_CHEST; +import net.minecraftforge.common.DimensionManager; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.ForgeEventFactory; +import net.minecraftforge.event.world.WorldEvent; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class WorldServer extends World +{ + private static final Logger logger = LogManager.getLogger(); + private final MinecraftServer mcServer; + private final EntityTracker theEntityTracker; + private final PlayerManager thePlayerManager; + private Set pendingTickListEntriesHashSet; + private TreeSet pendingTickListEntriesTreeSet; + public ChunkProviderServer theChunkProviderServer; + public boolean levelSaving; + private boolean allPlayersSleeping; + private int updateEntityTick; + private final Teleporter worldTeleporter; + private final SpawnerAnimals animalSpawner = new SpawnerAnimals(); + private WorldServer.ServerBlockEventList[] field_147490_S = new WorldServer.ServerBlockEventList[] {new WorldServer.ServerBlockEventList(null), new WorldServer.ServerBlockEventList(null)}; + private int blockEventCacheIndex; + public static final WeightedRandomChestContent[] bonusChestContent = new WeightedRandomChestContent[] {new WeightedRandomChestContent(Items.stick, 0, 1, 3, 10), new WeightedRandomChestContent(Item.getItemFromBlock(Blocks.planks), 0, 1, 3, 10), new WeightedRandomChestContent(Item.getItemFromBlock(Blocks.log), 0, 1, 3, 10), new WeightedRandomChestContent(Items.stone_axe, 0, 1, 1, 3), new WeightedRandomChestContent(Items.wooden_axe, 0, 1, 1, 5), new WeightedRandomChestContent(Items.stone_pickaxe, 0, 1, 1, 3), new WeightedRandomChestContent(Items.wooden_pickaxe, 0, 1, 1, 5), new WeightedRandomChestContent(Items.apple, 0, 2, 3, 5), new WeightedRandomChestContent(Items.bread, 0, 2, 3, 3), new WeightedRandomChestContent(Item.getItemFromBlock(Blocks.log2), 0, 1, 3, 10)}; + private List pendingTickListEntriesThisTick = new ArrayList(); + private IntHashMap entityIdMap; + private static final String __OBFID = "CL_00001437"; + + /** Stores the recently processed (lighting) chunks */ + protected Set doneChunks = new HashSet(); + public List customTeleporters = new ArrayList(); + + public WorldServer(MinecraftServer p_i45284_1_, ISaveHandler p_i45284_2_, String p_i45284_3_, int p_i45284_4_, WorldSettings p_i45284_5_, Profiler p_i45284_6_) + { + super(p_i45284_2_, p_i45284_3_, p_i45284_5_, WorldProvider.getProviderForDimension(p_i45284_4_), p_i45284_6_); + this.mcServer = p_i45284_1_; + this.theEntityTracker = new EntityTracker(this); + this.thePlayerManager = new PlayerManager(this, p_i45284_1_.getConfigurationManager().getViewDistance()); + + if (this.entityIdMap == null) + { + this.entityIdMap = new IntHashMap(); + } + + if (this.pendingTickListEntriesHashSet == null) + { + this.pendingTickListEntriesHashSet = new HashSet(); + } + + if (this.pendingTickListEntriesTreeSet == null) + { + this.pendingTickListEntriesTreeSet = new TreeSet(); + } + + this.worldTeleporter = new Teleporter(this); + this.worldScoreboard = new ServerScoreboard(p_i45284_1_); + ScoreboardSaveData scoreboardsavedata = (ScoreboardSaveData)this.mapStorage.loadData(ScoreboardSaveData.class, "scoreboard"); + + if (scoreboardsavedata == null) + { + scoreboardsavedata = new ScoreboardSaveData(); + this.mapStorage.setData("scoreboard", scoreboardsavedata); + } + + if (!(this instanceof WorldServerMulti)) //Forge: We fix the global mapStorage, which causes us to share scoreboards early. So don't associate the save data with the temporary scoreboard + { + scoreboardsavedata.func_96499_a(this.worldScoreboard); + } + ((ServerScoreboard)this.worldScoreboard).func_96547_a(scoreboardsavedata); + DimensionManager.setWorld(p_i45284_4_, this); + } + + public void tick() + { + super.tick(); + + if (this.getWorldInfo().isHardcoreModeEnabled() && this.difficultySetting != EnumDifficulty.HARD) + { + this.difficultySetting = EnumDifficulty.HARD; + } + + this.provider.worldChunkMgr.cleanupCache(); + + if (this.areAllPlayersAsleep()) + { + if (this.getGameRules().getGameRuleBooleanValue("doDaylightCycle")) + { + long i = this.worldInfo.getWorldTime() + 24000L; + this.worldInfo.setWorldTime(i - i % 24000L); + } + + this.wakeAllPlayers(); + } + + this.theProfiler.startSection("mobSpawner"); + + if (this.getGameRules().getGameRuleBooleanValue("doMobSpawning")) + { + this.animalSpawner.findChunksForSpawning(this, this.spawnHostileMobs, this.spawnPeacefulMobs, this.worldInfo.getWorldTotalTime() % 400L == 0L); + } + + this.theProfiler.endStartSection("chunkSource"); + this.chunkProvider.unloadQueuedChunks(); + int j = this.calculateSkylightSubtracted(1.0F); + + if (j != this.skylightSubtracted) + { + this.skylightSubtracted = j; + } + + this.worldInfo.incrementTotalWorldTime(this.worldInfo.getWorldTotalTime() + 1L); + + if (this.getGameRules().getGameRuleBooleanValue("doDaylightCycle")) + { + this.worldInfo.setWorldTime(this.worldInfo.getWorldTime() + 1L); + } + + this.theProfiler.endStartSection("tickPending"); + this.tickUpdates(false); + this.theProfiler.endStartSection("tickBlocks"); + this.func_147456_g(); + this.theProfiler.endStartSection("chunkMap"); + this.thePlayerManager.updatePlayerInstances(); + this.theProfiler.endStartSection("village"); + this.villageCollectionObj.tick(); + this.villageSiegeObj.tick(); + this.theProfiler.endStartSection("portalForcer"); + this.worldTeleporter.removeStalePortalLocations(this.getTotalWorldTime()); + for (Teleporter tele : customTeleporters) + { + tele.removeStalePortalLocations(getTotalWorldTime()); + } + this.theProfiler.endSection(); + this.func_147488_Z(); + } + + public BiomeGenBase.SpawnListEntry spawnRandomCreature(EnumCreatureType par1EnumCreatureType, int par2, int par3, int par4) + { + List list = this.getChunkProvider().getPossibleCreatures(par1EnumCreatureType, par2, par3, par4); + list = ForgeEventFactory.getPotentialSpawns(this, par1EnumCreatureType, par2, par3, par4, list); + return list != null && !list.isEmpty() ? (BiomeGenBase.SpawnListEntry)WeightedRandom.getRandomItem(this.rand, list) : null; + } + + public void updateAllPlayersSleepingFlag() + { + this.allPlayersSleeping = !this.playerEntities.isEmpty(); + Iterator iterator = this.playerEntities.iterator(); + + while (iterator.hasNext()) + { + EntityPlayer entityplayer = (EntityPlayer)iterator.next(); + + if (!entityplayer.isPlayerSleeping()) + { + this.allPlayersSleeping = false; + break; + } + } + } + + protected void wakeAllPlayers() + { + this.allPlayersSleeping = false; + Iterator iterator = this.playerEntities.iterator(); + + while (iterator.hasNext()) + { + EntityPlayer entityplayer = (EntityPlayer)iterator.next(); + + if (entityplayer.isPlayerSleeping()) + { + entityplayer.wakeUpPlayer(false, false, true); + } + } + + this.resetRainAndThunder(); + } + + private void resetRainAndThunder() + { + provider.resetRainAndThunder(); + } + + public boolean areAllPlayersAsleep() + { + if (this.allPlayersSleeping && !this.isRemote) + { + Iterator iterator = this.playerEntities.iterator(); + EntityPlayer entityplayer; + + do + { + if (!iterator.hasNext()) + { + return true; + } + + entityplayer = (EntityPlayer)iterator.next(); + } + while (entityplayer.isPlayerFullyAsleep()); + + return false; + } + else + { + return false; + } + } + + @SideOnly(Side.CLIENT) + public void setSpawnLocation() + { + if (this.worldInfo.getSpawnY() <= 0) + { + this.worldInfo.setSpawnY(64); + } + + int i = this.worldInfo.getSpawnX(); + int j = this.worldInfo.getSpawnZ(); + int k = 0; + + while (this.getTopBlock(i, j).getMaterial() == Material.air) + { + i += this.rand.nextInt(8) - this.rand.nextInt(8); + j += this.rand.nextInt(8) - this.rand.nextInt(8); + ++k; + + if (k == 10000) + { + break; + } + } + + this.worldInfo.setSpawnX(i); + this.worldInfo.setSpawnZ(j); + } + + protected void func_147456_g() + { + super.func_147456_g(); + int i = 0; + int j = 0; + Iterator iterator = this.activeChunkSet.iterator(); + + doneChunks.retainAll(activeChunkSet); + if (doneChunks.size() == activeChunkSet.size()) + { + doneChunks.clear(); + } + + final long startTime = System.nanoTime(); + + while (iterator.hasNext()) + { + ChunkCoordIntPair chunkcoordintpair = (ChunkCoordIntPair)iterator.next(); + int k = chunkcoordintpair.chunkXPos * 16; + int l = chunkcoordintpair.chunkZPos * 16; + this.theProfiler.startSection("getChunk"); + Chunk chunk = this.getChunkFromChunkCoords(chunkcoordintpair.chunkXPos, chunkcoordintpair.chunkZPos); + this.func_147467_a(k, l, chunk); + this.theProfiler.endStartSection("tickChunk"); + //Limits and evenly distributes the lighting update time + if (System.nanoTime() - startTime <= 4000000 && doneChunks.add(chunkcoordintpair)) + { + chunk.func_150804_b(false); + } + this.theProfiler.endStartSection("thunder"); + int i1; + int j1; + int k1; + int l1; + + if (provider.canDoLightning(chunk) && this.rand.nextInt(100000) == 0 && this.isRaining() && this.isThundering()) + { + this.updateLCG = this.updateLCG * 3 + 1013904223; + i1 = this.updateLCG >> 2; + j1 = k + (i1 & 15); + k1 = l + (i1 >> 8 & 15); + l1 = this.getPrecipitationHeight(j1, k1); + + if (this.canLightningStrikeAt(j1, l1, k1)) + { + this.addWeatherEffect(new EntityLightningBolt(this, (double)j1, (double)l1, (double)k1)); + } + } + + this.theProfiler.endStartSection("iceandsnow"); + + if (provider.canDoRainSnowIce(chunk) && this.rand.nextInt(16) == 0) + { + this.updateLCG = this.updateLCG * 3 + 1013904223; + i1 = this.updateLCG >> 2; + j1 = i1 & 15; + k1 = i1 >> 8 & 15; + l1 = this.getPrecipitationHeight(j1 + k, k1 + l); + + if (this.isBlockFreezableNaturally(j1 + k, l1 - 1, k1 + l)) + { + this.setBlock(j1 + k, l1 - 1, k1 + l, Blocks.ice); + } + + if (this.isRaining() && this.func_147478_e(j1 + k, l1, k1 + l, true)) + { + this.setBlock(j1 + k, l1, k1 + l, Blocks.snow_layer); + } + + if (this.isRaining()) + { + BiomeGenBase biomegenbase = this.getBiomeGenForCoords(j1 + k, k1 + l); + + if (biomegenbase.canSpawnLightningBolt()) + { + this.getBlock(j1 + k, l1 - 1, k1 + l).fillWithRain(this, j1 + k, l1 - 1, k1 + l); + } + } + } + + this.theProfiler.endStartSection("tickBlocks"); + ExtendedBlockStorage[] aextendedblockstorage = chunk.getBlockStorageArray(); + j1 = aextendedblockstorage.length; + + for (k1 = 0; k1 < j1; ++k1) + { + ExtendedBlockStorage extendedblockstorage = aextendedblockstorage[k1]; + + if (extendedblockstorage != null && extendedblockstorage.getNeedsRandomTick()) + { + for (int i3 = 0; i3 < 3; ++i3) + { + this.updateLCG = this.updateLCG * 3 + 1013904223; + int i2 = this.updateLCG >> 2; + int j2 = i2 & 15; + int k2 = i2 >> 8 & 15; + int l2 = i2 >> 16 & 15; + ++j; + Block block = extendedblockstorage.getBlockByExtId(j2, l2, k2); + + if (block.getTickRandomly()) + { + ++i; + block.updateTick(this, j2 + k, l2 + extendedblockstorage.getYLocation(), k2 + l, this.rand); + } + } + } + } + + this.theProfiler.endSection(); + } + } + + public boolean isBlockTickScheduledThisTick(int p_147477_1_, int p_147477_2_, int p_147477_3_, Block p_147477_4_) + { + NextTickListEntry nextticklistentry = new NextTickListEntry(p_147477_1_, p_147477_2_, p_147477_3_, p_147477_4_); + return this.pendingTickListEntriesThisTick.contains(nextticklistentry); + } + + public void scheduleBlockUpdate(int p_147464_1_, int p_147464_2_, int p_147464_3_, Block p_147464_4_, int p_147464_5_) + { + this.scheduleBlockUpdateWithPriority(p_147464_1_, p_147464_2_, p_147464_3_, p_147464_4_, p_147464_5_, 0); + } + + public void scheduleBlockUpdateWithPriority(int p_147454_1_, int p_147454_2_, int p_147454_3_, Block p_147454_4_, int p_147454_5_, int p_147454_6_) + { + NextTickListEntry nextticklistentry = new NextTickListEntry(p_147454_1_, p_147454_2_, p_147454_3_, p_147454_4_); + //Keeping here as a note for future when it may be restored. + //boolean isForced = getPersistentChunks().containsKey(new ChunkCoordIntPair(nextticklistentry.xCoord >> 4, nextticklistentry.zCoord >> 4)); + //byte b0 = isForced ? 0 : 8; + byte b0 = 0; + + if (this.scheduledUpdatesAreImmediate && p_147454_4_.getMaterial() != Material.air) + { + if (p_147454_4_.func_149698_L()) + { + b0 = 8; + + if (this.checkChunksExist(nextticklistentry.xCoord - b0, nextticklistentry.yCoord - b0, nextticklistentry.zCoord - b0, nextticklistentry.xCoord + b0, nextticklistentry.yCoord + b0, nextticklistentry.zCoord + b0)) + { + Block block1 = this.getBlock(nextticklistentry.xCoord, nextticklistentry.yCoord, nextticklistentry.zCoord); + + if (block1.getMaterial() != Material.air && block1 == nextticklistentry.func_151351_a()) + { + block1.updateTick(this, nextticklistentry.xCoord, nextticklistentry.yCoord, nextticklistentry.zCoord, this.rand); + } + } + + return; + } + + p_147454_5_ = 1; + } + + if (this.checkChunksExist(p_147454_1_ - b0, p_147454_2_ - b0, p_147454_3_ - b0, p_147454_1_ + b0, p_147454_2_ + b0, p_147454_3_ + b0)) + { + if (p_147454_4_.getMaterial() != Material.air) + { + nextticklistentry.setScheduledTime((long)p_147454_5_ + this.worldInfo.getWorldTotalTime()); + nextticklistentry.setPriority(p_147454_6_); + } + + if (!this.pendingTickListEntriesHashSet.contains(nextticklistentry)) + { + this.pendingTickListEntriesHashSet.add(nextticklistentry); + this.pendingTickListEntriesTreeSet.add(nextticklistentry); + } + } + } + + public void func_147446_b(int p_147446_1_, int p_147446_2_, int p_147446_3_, Block p_147446_4_, int p_147446_5_, int p_147446_6_) + { + NextTickListEntry nextticklistentry = new NextTickListEntry(p_147446_1_, p_147446_2_, p_147446_3_, p_147446_4_); + nextticklistentry.setPriority(p_147446_6_); + + if (p_147446_4_.getMaterial() != Material.air) + { + nextticklistentry.setScheduledTime((long)p_147446_5_ + this.worldInfo.getWorldTotalTime()); + } + + if (!this.pendingTickListEntriesHashSet.contains(nextticklistentry)) + { + this.pendingTickListEntriesHashSet.add(nextticklistentry); + this.pendingTickListEntriesTreeSet.add(nextticklistentry); + } + } + + public void updateEntities() + { + if (this.playerEntities.isEmpty() && getPersistentChunks().isEmpty()) + { + if (this.updateEntityTick++ >= 1200) + { + return; + } + } + else + { + this.resetUpdateEntityTick(); + } + + super.updateEntities(); + } + + public void resetUpdateEntityTick() + { + this.updateEntityTick = 0; + } + + public boolean tickUpdates(boolean par1) + { + int i = this.pendingTickListEntriesTreeSet.size(); + + if (i != this.pendingTickListEntriesHashSet.size()) + { + throw new IllegalStateException("TickNextTick list out of synch"); + } + else + { + if (i > 1000) + { + i = 1000; + } + + this.theProfiler.startSection("cleaning"); + NextTickListEntry nextticklistentry; + + for (int j = 0; j < i; ++j) + { + nextticklistentry = (NextTickListEntry)this.pendingTickListEntriesTreeSet.first(); + + if (!par1 && nextticklistentry.scheduledTime > this.worldInfo.getWorldTotalTime()) + { + break; + } + + this.pendingTickListEntriesTreeSet.remove(nextticklistentry); + this.pendingTickListEntriesHashSet.remove(nextticklistentry); + this.pendingTickListEntriesThisTick.add(nextticklistentry); + } + + this.theProfiler.endSection(); + this.theProfiler.startSection("ticking"); + Iterator iterator = this.pendingTickListEntriesThisTick.iterator(); + + while (iterator.hasNext()) + { + nextticklistentry = (NextTickListEntry)iterator.next(); + iterator.remove(); + //Keeping here as a note for future when it may be restored. + //boolean isForced = getPersistentChunks().containsKey(new ChunkCoordIntPair(nextticklistentry.xCoord >> 4, nextticklistentry.zCoord >> 4)); + //byte b0 = isForced ? 0 : 8; + byte b0 = 0; + + if (this.checkChunksExist(nextticklistentry.xCoord - b0, nextticklistentry.yCoord - b0, nextticklistentry.zCoord - b0, nextticklistentry.xCoord + b0, nextticklistentry.yCoord + b0, nextticklistentry.zCoord + b0)) + { + Block block = this.getBlock(nextticklistentry.xCoord, nextticklistentry.yCoord, nextticklistentry.zCoord); + + if (block.getMaterial() != Material.air && Block.isEqualTo(block, nextticklistentry.func_151351_a())) + { + try + { + block.updateTick(this, nextticklistentry.xCoord, nextticklistentry.yCoord, nextticklistentry.zCoord, this.rand); + } + catch (Throwable throwable1) + { + CrashReport crashreport = CrashReport.makeCrashReport(throwable1, "Exception while ticking a block"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("Block being ticked"); + int k; + + try + { + k = this.getBlockMetadata(nextticklistentry.xCoord, nextticklistentry.yCoord, nextticklistentry.zCoord); + } + catch (Throwable throwable) + { + k = -1; + } + + CrashReportCategory.func_147153_a(crashreportcategory, nextticklistentry.xCoord, nextticklistentry.yCoord, nextticklistentry.zCoord, block, k); + throw new ReportedException(crashreport); + } + } + } + else + { + this.scheduleBlockUpdate(nextticklistentry.xCoord, nextticklistentry.yCoord, nextticklistentry.zCoord, nextticklistentry.func_151351_a(), 0); + } + } + + this.theProfiler.endSection(); + this.pendingTickListEntriesThisTick.clear(); + return !this.pendingTickListEntriesTreeSet.isEmpty(); + } + } + + public List getPendingBlockUpdates(Chunk par1Chunk, boolean par2) + { + ArrayList arraylist = null; + ChunkCoordIntPair chunkcoordintpair = par1Chunk.getChunkCoordIntPair(); + int i = (chunkcoordintpair.chunkXPos << 4) - 2; + int j = i + 16 + 2; + int k = (chunkcoordintpair.chunkZPos << 4) - 2; + int l = k + 16 + 2; + + for (int i1 = 0; i1 < 2; ++i1) + { + Iterator iterator; + + if (i1 == 0) + { + iterator = this.pendingTickListEntriesTreeSet.iterator(); + } + else + { + iterator = this.pendingTickListEntriesThisTick.iterator(); + + if (!this.pendingTickListEntriesThisTick.isEmpty()) + { + logger.debug("toBeTicked = " + this.pendingTickListEntriesThisTick.size()); + } + } + + while (iterator.hasNext()) + { + NextTickListEntry nextticklistentry = (NextTickListEntry)iterator.next(); + + if (nextticklistentry.xCoord >= i && nextticklistentry.xCoord < j && nextticklistentry.zCoord >= k && nextticklistentry.zCoord < l) + { + if (par2) + { + this.pendingTickListEntriesHashSet.remove(nextticklistentry); + iterator.remove(); + } + + if (arraylist == null) + { + arraylist = new ArrayList(); + } + + arraylist.add(nextticklistentry); + } + } + } + + return arraylist; + } + + public void updateEntityWithOptionalForce(Entity par1Entity, boolean par2) + { + if (!this.mcServer.getCanSpawnAnimals() && (par1Entity instanceof EntityAnimal || par1Entity instanceof EntityWaterMob)) + { + par1Entity.setDead(); + } + + if (!this.mcServer.getCanSpawnNPCs() && par1Entity instanceof INpc) + { + par1Entity.setDead(); + } + + super.updateEntityWithOptionalForce(par1Entity, par2); + } + + protected IChunkProvider createChunkProvider() + { + IChunkLoader ichunkloader = this.saveHandler.getChunkLoader(this.provider); + this.theChunkProviderServer = new ChunkProviderServer(this, ichunkloader, this.provider.createChunkGenerator()); + return this.theChunkProviderServer; + } + + public List func_147486_a(int p_147486_1_, int p_147486_2_, int p_147486_3_, int p_147486_4_, int p_147486_5_, int p_147486_6_) + { + ArrayList arraylist = new ArrayList(); + + for(int x = (p_147486_1_ >> 4); x <= (p_147486_4_ >> 4); x++) + { + for(int z = (p_147486_3_ >> 4); z <= (p_147486_6_ >> 4); z++) + { + Chunk chunk = getChunkFromChunkCoords(x, z); + if (chunk != null) + { + for(Object obj : chunk.chunkTileEntityMap.values()) + { + TileEntity entity = (TileEntity)obj; + if (!entity.isInvalid()) + { + if (entity.xCoord >= p_147486_1_ && entity.yCoord >= p_147486_2_ && entity.zCoord >= p_147486_3_ && + entity.xCoord <= p_147486_4_ && entity.yCoord <= p_147486_5_ && entity.zCoord <= p_147486_6_) + { + arraylist.add(entity); + } + } + } + } + } + } + + return arraylist; + } + + public boolean canMineBlock(EntityPlayer par1EntityPlayer, int par2, int par3, int par4) + { + return super.canMineBlock(par1EntityPlayer, par2, par3, par4); + } + + public boolean canMineBlockBody(EntityPlayer par1EntityPlayer, int par2, int par3, int par4) + { + return !this.mcServer.isBlockProtected(this, par2, par3, par4, par1EntityPlayer); + } + + protected void initialize(WorldSettings par1WorldSettings) + { + if (this.entityIdMap == null) + { + this.entityIdMap = new IntHashMap(); + } + + if (this.pendingTickListEntriesHashSet == null) + { + this.pendingTickListEntriesHashSet = new HashSet(); + } + + if (this.pendingTickListEntriesTreeSet == null) + { + this.pendingTickListEntriesTreeSet = new TreeSet(); + } + + this.createSpawnPosition(par1WorldSettings); + super.initialize(par1WorldSettings); + } + + protected void createSpawnPosition(WorldSettings par1WorldSettings) + { + if (!this.provider.canRespawnHere()) + { + this.worldInfo.setSpawnPosition(0, this.provider.getAverageGroundLevel(), 0); + } + else + { + this.findingSpawnPoint = true; + WorldChunkManager worldchunkmanager = this.provider.worldChunkMgr; + List list = worldchunkmanager.getBiomesToSpawnIn(); + Random random = new Random(this.getSeed()); + ChunkPosition chunkposition = worldchunkmanager.findBiomePosition(0, 0, 256, list, random); + int i = 0; + int j = this.provider.getAverageGroundLevel(); + int k = 0; + + if (chunkposition != null) + { + i = chunkposition.chunkPosX; + k = chunkposition.chunkPosZ; + } + else + { + logger.warn("Unable to find spawn biome"); + } + + int l = 0; + + while (!this.provider.canCoordinateBeSpawn(i, k)) + { + i += random.nextInt(64) - random.nextInt(64); + k += random.nextInt(64) - random.nextInt(64); + ++l; + + if (l == 1000) + { + break; + } + } + + this.worldInfo.setSpawnPosition(i, j, k); + this.findingSpawnPoint = false; + + if (par1WorldSettings.isBonusChestEnabled()) + { + this.createBonusChest(); + } + } + } + + protected void createBonusChest() + { + WorldGeneratorBonusChest worldgeneratorbonuschest = new WorldGeneratorBonusChest(ChestGenHooks.getItems(BONUS_CHEST, rand), ChestGenHooks.getCount(BONUS_CHEST, rand)); + + for (int i = 0; i < 10; ++i) + { + int j = this.worldInfo.getSpawnX() + this.rand.nextInt(6) - this.rand.nextInt(6); + int k = this.worldInfo.getSpawnZ() + this.rand.nextInt(6) - this.rand.nextInt(6); + int l = this.getTopSolidOrLiquidBlock(j, k) + 1; + + if (worldgeneratorbonuschest.generate(this, this.rand, j, l, k)) + { + break; + } + } + } + + public ChunkCoordinates getEntrancePortalLocation() + { + return this.provider.getEntrancePortalLocation(); + } + + public void saveAllChunks(boolean par1, IProgressUpdate par2IProgressUpdate) throws MinecraftException + { + if (this.chunkProvider.canSave()) + { + if (par2IProgressUpdate != null) + { + par2IProgressUpdate.displayProgressMessage("Saving level"); + } + + this.saveLevel(); + + if (par2IProgressUpdate != null) + { + par2IProgressUpdate.resetProgresAndWorkingMessage("Saving chunks"); + } + + this.chunkProvider.saveChunks(par1, par2IProgressUpdate); + MinecraftForge.EVENT_BUS.post(new WorldEvent.Save(this)); + } + } + + public void saveChunkData() + { + if (this.chunkProvider.canSave()) + { + this.chunkProvider.saveExtraData(); + } + } + + protected void saveLevel() throws MinecraftException + { + this.checkSessionLock(); + this.saveHandler.saveWorldInfoWithPlayer(this.worldInfo, this.mcServer.getConfigurationManager().getHostPlayerData()); + this.mapStorage.saveAllData(); + this.perWorldStorage.saveAllData(); + } + + public void onEntityAdded(Entity par1Entity) + { + super.onEntityAdded(par1Entity); + this.entityIdMap.addKey(par1Entity.getEntityId(), par1Entity); + Entity[] aentity = par1Entity.getParts(); + + if (aentity != null) + { + for (int i = 0; i < aentity.length; ++i) + { + this.entityIdMap.addKey(aentity[i].getEntityId(), aentity[i]); + } + } + } + + public void onEntityRemoved(Entity par1Entity) + { + super.onEntityRemoved(par1Entity); + this.entityIdMap.removeObject(par1Entity.getEntityId()); + Entity[] aentity = par1Entity.getParts(); + + if (aentity != null) + { + for (int i = 0; i < aentity.length; ++i) + { + this.entityIdMap.removeObject(aentity[i].getEntityId()); + } + } + } + + public Entity getEntityByID(int par1) + { + return (Entity)this.entityIdMap.lookup(par1); + } + + public boolean addWeatherEffect(Entity par1Entity) + { + if (super.addWeatherEffect(par1Entity)) + { + this.mcServer.getConfigurationManager().sendToAllNear(par1Entity.posX, par1Entity.posY, par1Entity.posZ, 512.0D, this.provider.dimensionId, new S2CPacketSpawnGlobalEntity(par1Entity)); + return true; + } + else + { + return false; + } + } + + public void setEntityState(Entity par1Entity, byte par2) + { + this.getEntityTracker().func_151248_b(par1Entity, new S19PacketEntityStatus(par1Entity, par2)); + } + + public Explosion newExplosion(Entity par1Entity, double par2, double par4, double par6, float par8, boolean par9, boolean par10) + { + Explosion explosion = new Explosion(this, par1Entity, par2, par4, par6, par8); + explosion.isFlaming = par9; + explosion.isSmoking = par10; + explosion.doExplosionA(); + explosion.doExplosionB(false); + + if (!par10) + { + explosion.affectedBlockPositions.clear(); + } + + Iterator iterator = this.playerEntities.iterator(); + + while (iterator.hasNext()) + { + EntityPlayer entityplayer = (EntityPlayer)iterator.next(); + + if (entityplayer.getDistanceSq(par2, par4, par6) < 4096.0D) + { + ((EntityPlayerMP)entityplayer).playerNetServerHandler.sendPacket(new S27PacketExplosion(par2, par4, par6, par8, explosion.affectedBlockPositions, (Vec3)explosion.func_77277_b().get(entityplayer))); + } + } + + return explosion; + } + + public void addBlockEvent(int p_147452_1_, int p_147452_2_, int p_147452_3_, Block p_147452_4_, int p_147452_5_, int p_147452_6_) + { + BlockEventData blockeventdata = new BlockEventData(p_147452_1_, p_147452_2_, p_147452_3_, p_147452_4_, p_147452_5_, p_147452_6_); + Iterator iterator = this.field_147490_S[this.blockEventCacheIndex].iterator(); + BlockEventData blockeventdata1; + + do + { + if (!iterator.hasNext()) + { + this.field_147490_S[this.blockEventCacheIndex].add(blockeventdata); + return; + } + + blockeventdata1 = (BlockEventData)iterator.next(); + } + while (!blockeventdata1.equals(blockeventdata)); + } + + private void func_147488_Z() + { + while (!this.field_147490_S[this.blockEventCacheIndex].isEmpty()) + { + int i = this.blockEventCacheIndex; + this.blockEventCacheIndex ^= 1; + Iterator iterator = this.field_147490_S[i].iterator(); + + while (iterator.hasNext()) + { + BlockEventData blockeventdata = (BlockEventData)iterator.next(); + + if (this.func_147485_a(blockeventdata)) + { + this.mcServer.getConfigurationManager().sendToAllNear((double)blockeventdata.func_151340_a(), (double)blockeventdata.func_151342_b(), (double)blockeventdata.func_151341_c(), 64.0D, this.provider.dimensionId, new S24PacketBlockAction(blockeventdata.func_151340_a(), blockeventdata.func_151342_b(), blockeventdata.func_151341_c(), blockeventdata.getBlock(), blockeventdata.getEventID(), blockeventdata.getEventParameter())); + } + } + + this.field_147490_S[i].clear(); + } + } + + private boolean func_147485_a(BlockEventData p_147485_1_) + { + Block block = this.getBlock(p_147485_1_.func_151340_a(), p_147485_1_.func_151342_b(), p_147485_1_.func_151341_c()); + return block == p_147485_1_.getBlock() ? block.onBlockEventReceived(this, p_147485_1_.func_151340_a(), p_147485_1_.func_151342_b(), p_147485_1_.func_151341_c(), p_147485_1_.getEventID(), p_147485_1_.getEventParameter()) : false; + } + + public void flush() + { + this.saveHandler.flush(); + } + + protected void updateWeather() + { + boolean flag = this.isRaining(); + super.updateWeather(); + + if (this.prevRainingStrength != this.rainingStrength) + { + this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(7, this.rainingStrength), this.provider.dimensionId); + } + + if (this.prevThunderingStrength != this.thunderingStrength) + { + this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(8, this.thunderingStrength), this.provider.dimensionId); + } + + if (flag != this.isRaining()) + { + if (flag) + { + this.mcServer.getConfigurationManager().sendPacketToAllPlayers(new S2BPacketChangeGameState(2, 0.0F)); + } + else + { + this.mcServer.getConfigurationManager().sendPacketToAllPlayers(new S2BPacketChangeGameState(1, 0.0F)); + } + + this.mcServer.getConfigurationManager().sendPacketToAllPlayers(new S2BPacketChangeGameState(7, this.rainingStrength)); + this.mcServer.getConfigurationManager().sendPacketToAllPlayers(new S2BPacketChangeGameState(8, this.thunderingStrength)); + } + } + + public MinecraftServer func_73046_m() + { + return this.mcServer; + } + + public EntityTracker getEntityTracker() + { + return this.theEntityTracker; + } + + public PlayerManager getPlayerManager() + { + return this.thePlayerManager; + } + + public Teleporter getDefaultTeleporter() + { + return this.worldTeleporter; + } + + public void func_147487_a(String p_147487_1_, double p_147487_2_, double p_147487_4_, double p_147487_6_, int p_147487_8_, double p_147487_9_, double p_147487_11_, double p_147487_13_, double p_147487_15_) + { + S2APacketParticles s2apacketparticles = new S2APacketParticles(p_147487_1_, (float)p_147487_2_, (float)p_147487_4_, (float)p_147487_6_, (float)p_147487_9_, (float)p_147487_11_, (float)p_147487_13_, (float)p_147487_15_, p_147487_8_); + + for (int j = 0; j < this.playerEntities.size(); ++j) + { + EntityPlayerMP entityplayermp = (EntityPlayerMP)this.playerEntities.get(j); + ChunkCoordinates chunkcoordinates = entityplayermp.getPlayerCoordinates(); + double d7 = p_147487_2_ - (double)chunkcoordinates.posX; + double d8 = p_147487_4_ - (double)chunkcoordinates.posY; + double d9 = p_147487_6_ - (double)chunkcoordinates.posZ; + double d10 = d7 * d7 + d8 * d8 + d9 * d9; + + if (d10 <= 256.0D) + { + entityplayermp.playerNetServerHandler.sendPacket(s2apacketparticles); + } + } + } + + public File getChunkSaveLocation() + { + return ((AnvilChunkLoader)theChunkProviderServer.currentChunkLoader).chunkSaveLocation; + } + + static class ServerBlockEventList extends ArrayList + { + private static final String __OBFID = "CL_00001439"; + + private ServerBlockEventList() {} + + ServerBlockEventList(Object par1ServerBlockEvent) + { + this(); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/WorldServerMulti.java b/src/main/java/net/minecraft/world/WorldServerMulti.java new file mode 100644 index 0000000..e8e5c3f --- /dev/null +++ b/src/main/java/net/minecraft/world/WorldServerMulti.java @@ -0,0 +1,24 @@ +package net.minecraft.world; + +import net.minecraft.profiler.Profiler; +import net.minecraft.server.MinecraftServer; +import net.minecraft.world.storage.DerivedWorldInfo; +import net.minecraft.world.storage.ISaveHandler; + +public class WorldServerMulti extends WorldServer +{ + private static final String __OBFID = "CL_00001430"; + + public WorldServerMulti(MinecraftServer p_i45283_1_, ISaveHandler p_i45283_2_, String p_i45283_3_, int p_i45283_4_, WorldSettings p_i45283_5_, WorldServer p_i45283_6_, Profiler p_i45283_7_) + { + super(p_i45283_1_, p_i45283_2_, p_i45283_3_, p_i45283_4_, p_i45283_5_, p_i45283_7_); + this.mapStorage = p_i45283_6_.mapStorage; + this.worldScoreboard = p_i45283_6_.getScoreboard(); + this.worldInfo = new DerivedWorldInfo(p_i45283_6_.getWorldInfo()); + } + + protected void saveLevel() throws MinecraftException + { + this.perWorldStorage.saveAllData(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/WorldSettings.java b/src/main/java/net/minecraft/world/WorldSettings.java new file mode 100644 index 0000000..fb2b18c --- /dev/null +++ b/src/main/java/net/minecraft/world/WorldSettings.java @@ -0,0 +1,198 @@ +package net.minecraft.world; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.player.PlayerCapabilities; +import net.minecraft.world.storage.WorldInfo; + +public final class WorldSettings +{ + private final long seed; + private final WorldSettings.GameType theGameType; + private final boolean mapFeaturesEnabled; + private final boolean hardcoreEnabled; + private final WorldType terrainType; + private boolean commandsAllowed; + private boolean bonusChestEnabled; + private String field_82751_h; + private static final String __OBFID = "CL_00000147"; + + public WorldSettings(long par1, WorldSettings.GameType par3EnumGameType, boolean par4, boolean par5, WorldType par6WorldType) + { + this.field_82751_h = ""; + this.seed = par1; + this.theGameType = par3EnumGameType; + this.mapFeaturesEnabled = par4; + this.hardcoreEnabled = par5; + this.terrainType = par6WorldType; + } + + public WorldSettings(WorldInfo par1WorldInfo) + { + this(par1WorldInfo.getSeed(), par1WorldInfo.getGameType(), par1WorldInfo.isMapFeaturesEnabled(), par1WorldInfo.isHardcoreModeEnabled(), par1WorldInfo.getTerrainType()); + } + + public WorldSettings enableBonusChest() + { + this.bonusChestEnabled = true; + return this; + } + + public WorldSettings func_82750_a(String par1Str) + { + this.field_82751_h = par1Str; + return this; + } + + @SideOnly(Side.CLIENT) + public WorldSettings enableCommands() + { + this.commandsAllowed = true; + return this; + } + + public boolean isBonusChestEnabled() + { + return this.bonusChestEnabled; + } + + public long getSeed() + { + return this.seed; + } + + public WorldSettings.GameType getGameType() + { + return this.theGameType; + } + + public boolean getHardcoreEnabled() + { + return this.hardcoreEnabled; + } + + public boolean isMapFeaturesEnabled() + { + return this.mapFeaturesEnabled; + } + + public WorldType getTerrainType() + { + return this.terrainType; + } + + public boolean areCommandsAllowed() + { + return this.commandsAllowed; + } + + public static WorldSettings.GameType getGameTypeById(int par0) + { + return WorldSettings.GameType.getByID(par0); + } + + public String func_82749_j() + { + return this.field_82751_h; + } + + public static enum GameType + { + NOT_SET(-1, ""), + SURVIVAL(0, "survival"), + CREATIVE(1, "creative"), + ADVENTURE(2, "adventure"); + int id; + String name; + + private static final String __OBFID = "CL_00000148"; + + private GameType(int par3, String par4Str) + { + this.id = par3; + this.name = par4Str; + } + + public int getID() + { + return this.id; + } + + public String getName() + { + return this.name; + } + + public void configurePlayerCapabilities(PlayerCapabilities par1PlayerCapabilities) + { + if (this == CREATIVE) + { + par1PlayerCapabilities.allowFlying = true; + par1PlayerCapabilities.isCreativeMode = true; + par1PlayerCapabilities.disableDamage = true; + } + else + { + par1PlayerCapabilities.allowFlying = false; + par1PlayerCapabilities.isCreativeMode = false; + par1PlayerCapabilities.disableDamage = false; + par1PlayerCapabilities.isFlying = false; + } + + par1PlayerCapabilities.allowEdit = !this.isAdventure(); + } + + public boolean isAdventure() + { + return this == ADVENTURE; + } + + public boolean isCreative() + { + return this == CREATIVE; + } + + @SideOnly(Side.CLIENT) + public boolean isSurvivalOrAdventure() + { + return this == SURVIVAL || this == ADVENTURE; + } + + public static WorldSettings.GameType getByID(int par0) + { + WorldSettings.GameType[] agametype = values(); + int j = agametype.length; + + for (int k = 0; k < j; ++k) + { + WorldSettings.GameType gametype = agametype[k]; + + if (gametype.id == par0) + { + return gametype; + } + } + + return SURVIVAL; + } + + @SideOnly(Side.CLIENT) + public static WorldSettings.GameType getByName(String par0Str) + { + WorldSettings.GameType[] agametype = values(); + int i = agametype.length; + + for (int j = 0; j < i; ++j) + { + WorldSettings.GameType gametype = agametype[j]; + + if (gametype.name.equals(par0Str)) + { + return gametype; + } + } + + return SURVIVAL; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/WorldType.java b/src/main/java/net/minecraft/world/WorldType.java new file mode 100644 index 0000000..f4794d5 --- /dev/null +++ b/src/main/java/net/minecraft/world/WorldType.java @@ -0,0 +1,283 @@ +package net.minecraft.world; + +import java.util.Arrays; +import java.util.Random; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiCreateFlatWorld; +import net.minecraft.client.gui.GuiCreateWorld; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.biome.WorldChunkManager; +import net.minecraft.world.biome.WorldChunkManagerHell; +import net.minecraft.world.chunk.IChunkProvider; +import net.minecraft.world.gen.ChunkProviderFlat; +import net.minecraft.world.gen.ChunkProviderGenerate; +import net.minecraft.world.gen.FlatGeneratorInfo; +import net.minecraft.world.gen.layer.GenLayer; +import net.minecraft.world.gen.layer.GenLayerBiome; +import net.minecraft.world.gen.layer.GenLayerBiomeEdge; +import net.minecraft.world.gen.layer.GenLayerZoom; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class WorldType +{ + public static WorldType[] worldTypes = new WorldType[16]; + public static final WorldType DEFAULT = (new WorldType(0, "default", 1)).setVersioned(); + public static final WorldType FLAT = new WorldType(1, "flat"); + public static final WorldType LARGE_BIOMES = new WorldType(2, "largeBiomes"); + public static final WorldType AMPLIFIED = (new WorldType(3, "amplified")).setNotificationData(); + public static final WorldType DEFAULT_1_1 = (new WorldType(8, "default_1_1", 0)).setCanBeCreated(false); + private final int worldTypeId; + private final String worldType; + private final int generatorVersion; + private boolean canBeCreated; + private boolean isWorldTypeVersioned; + private boolean hasNotificationData; + private static final String __OBFID = "CL_00000150"; + + private WorldType(int par1, String par2Str) + { + this(par1, par2Str, 0); + } + + private WorldType(int par1, String par2Str, int par3) + { + if (par2Str.length() > 16) throw new IllegalArgumentException("World type names must not be longer then 16: " + par2Str.length()); + this.worldType = par2Str; + this.generatorVersion = par3; + this.canBeCreated = true; + this.worldTypeId = par1; + worldTypes[par1] = this; + } + + public String getWorldTypeName() + { + return this.worldType; + } + + @SideOnly(Side.CLIENT) + public String getTranslateName() + { + return "generator." + this.worldType; + } + + @SideOnly(Side.CLIENT) + public String func_151359_c() + { + return this.getTranslateName() + ".info"; + } + + public int getGeneratorVersion() + { + return this.generatorVersion; + } + + public WorldType getWorldTypeForGeneratorVersion(int par1) + { + return this == DEFAULT && par1 == 0 ? DEFAULT_1_1 : this; + } + + private WorldType setCanBeCreated(boolean par1) + { + this.canBeCreated = par1; + return this; + } + + @SideOnly(Side.CLIENT) + public boolean getCanBeCreated() + { + return this.canBeCreated; + } + + private WorldType setVersioned() + { + this.isWorldTypeVersioned = true; + return this; + } + + public boolean isVersioned() + { + return this.isWorldTypeVersioned; + } + + public static WorldType parseWorldType(String par0Str) + { + for (int i = 0; i < worldTypes.length; ++i) + { + if (worldTypes[i] != null && worldTypes[i].worldType.equalsIgnoreCase(par0Str)) + { + return worldTypes[i]; + } + } + + return null; + } + + public int getWorldTypeID() + { + return this.worldTypeId; + } + + @SideOnly(Side.CLIENT) + public boolean showWorldInfoNotice() + { + return this.hasNotificationData; + } + + private WorldType setNotificationData() + { + this.hasNotificationData = true; + return this; + } + + public WorldChunkManager getChunkManager(World world) + { + if (this == FLAT) + { + FlatGeneratorInfo flatgeneratorinfo = FlatGeneratorInfo.createFlatGeneratorFromString(world.getWorldInfo().getGeneratorOptions()); + return new WorldChunkManagerHell(BiomeGenBase.getBiome(flatgeneratorinfo.getBiome()), 0.5F); + } + else + { + return new WorldChunkManager(world); + } + } + + public IChunkProvider getChunkGenerator(World world, String generatorOptions) + { + return (this == FLAT ? new ChunkProviderFlat(world, world.getSeed(), world.getWorldInfo().isMapFeaturesEnabled(), generatorOptions) : new ChunkProviderGenerate(world, world.getSeed(), world.getWorldInfo().isMapFeaturesEnabled())); + } + + public int getMinimumSpawnHeight(World world) + { + return this == FLAT ? 4 : 64; + } + + public double getHorizon(World world) + { + return this == FLAT ? 0.0D : 63.0D; + } + + public boolean hasVoidParticles(boolean flag) + { + return this != FLAT && !flag; + } + + public double voidFadeMagnitude() + { + return this == FLAT ? 1.0D : 0.03125D; + } + +/* public BiomeGenBase[] getBiomesForWorldType() { + return biomesForWorldType; + } + + public void addNewBiome(BiomeGenBase biome) + { + Set newBiomesForWorld = Sets.newLinkedHashSet(Arrays.asList(biomesForWorldType)); + newBiomesForWorld.add(biome); + biomesForWorldType = newBiomesForWorld.toArray(new BiomeGenBase[0]); + } + + public void removeBiome(BiomeGenBase biome) + { + Set newBiomesForWorld = Sets.newLinkedHashSet(Arrays.asList(biomesForWorldType)); + newBiomesForWorld.remove(biome); + biomesForWorldType = newBiomesForWorld.toArray(new BiomeGenBase[0]); + } +*/ + public boolean handleSlimeSpawnReduction(Random random, World world) + { + return this == FLAT ? random.nextInt(4) != 1 : false; + } + + /*=================================================== FORGE START ======================================*/ + private static int getNextID() + { + for (int x = 0; x < worldTypes.length; x++) + { + if (worldTypes[x] == null) + { + return x; + } + } + + int oldLen = worldTypes.length; + worldTypes = Arrays.copyOf(worldTypes, oldLen + 16); + return oldLen; + } + + /** + * Creates a new world type, the ID is hidden and should not be referenced by modders. + * It will automatically expand the underlying workdType array if there are no IDs left. + * @param name + */ + public WorldType(String name) + { + this(getNextID(), name); + } + + /** + * Called when 'Create New World' button is pressed before starting game + */ + public void onGUICreateWorldPress() { } + + /** + * Gets the spawn fuzz for players who join the world. + * Useful for void world types. + * @return Fuzz for entity initial spawn in blocks. + */ + public int getSpawnFuzz() + { + return 20; + } + + /** + * Called when the 'Customize' button is pressed on world creation GUI + * @param instance The minecraft instance + * @param guiCreateWorld the createworld GUI + */ + @SideOnly(Side.CLIENT) + public void onCustomizeButton(Minecraft instance, GuiCreateWorld guiCreateWorld) + { + if (this == FLAT) + { + instance.displayGuiScreen(new GuiCreateFlatWorld(guiCreateWorld, guiCreateWorld.field_146334_a)); + } + } + + /** + * Should world creation GUI show 'Customize' button for this world type? + * @return if this world type has customization parameters + */ + public boolean isCustomizable() + { + return this == FLAT; + } + + + /** + * Get the height to render the clouds for this world type + * @return The height to render clouds at + */ + public float getCloudHeight() + { + return 128.0F; + } + + /** + * Creates the GenLayerBiome used for generating the world + * + * @param worldSeed The world seed + * @param parentLayer The parent layer to feed into any layer you return + * @return A GenLayer that will return ints representing the Biomes to be generated, see GenLayerBiome + */ + public GenLayer getBiomeLayer(long worldSeed, GenLayer parentLayer) + { + GenLayer ret = new GenLayerBiome(200L, parentLayer, this); + ret = GenLayerZoom.magnify(1000L, ret, 2); + ret = new GenLayerBiomeEdge(1000L, ret); + return ret; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/biome/BiomeCache.java b/src/main/java/net/minecraft/world/biome/BiomeCache.java new file mode 100644 index 0000000..b264fd6 --- /dev/null +++ b/src/main/java/net/minecraft/world/biome/BiomeCache.java @@ -0,0 +1,95 @@ +package net.minecraft.world.biome; + +import java.util.ArrayList; +import java.util.List; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.LongHashMap; + +public class BiomeCache +{ + private final WorldChunkManager chunkManager; + private long lastCleanupTime; + private LongHashMap cacheMap = new LongHashMap(); + private List cache = new ArrayList(); + private static final String __OBFID = "CL_00000162"; + + public BiomeCache(WorldChunkManager par1WorldChunkManager) + { + this.chunkManager = par1WorldChunkManager; + } + + public BiomeCache.Block getBiomeCacheBlock(int par1, int par2) + { + par1 >>= 4; + par2 >>= 4; + long k = (long)par1 & 4294967295L | ((long)par2 & 4294967295L) << 32; + BiomeCache.Block block = (BiomeCache.Block)this.cacheMap.getValueByKey(k); + + if (block == null) + { + block = new BiomeCache.Block(par1, par2); + this.cacheMap.add(k, block); + this.cache.add(block); + } + + block.lastAccessTime = MinecraftServer.getSystemTimeMillis(); + return block; + } + + public BiomeGenBase getBiomeGenAt(int par1, int par2) + { + return this.getBiomeCacheBlock(par1, par2).getBiomeGenAt(par1, par2); + } + + public void cleanupCache() + { + long i = MinecraftServer.getSystemTimeMillis(); + long j = i - this.lastCleanupTime; + + if (j > 7500L || j < 0L) + { + this.lastCleanupTime = i; + + for (int k = 0; k < this.cache.size(); ++k) + { + BiomeCache.Block block = (BiomeCache.Block)this.cache.get(k); + long l = i - block.lastAccessTime; + + if (l > 30000L || l < 0L) + { + this.cache.remove(k--); + long i1 = (long)block.xPosition & 4294967295L | ((long)block.zPosition & 4294967295L) << 32; + this.cacheMap.remove(i1); + } + } + } + } + + public BiomeGenBase[] getCachedBiomes(int par1, int par2) + { + return this.getBiomeCacheBlock(par1, par2).biomes; + } + + public class Block + { + public float[] rainfallValues = new float[256]; + public BiomeGenBase[] biomes = new BiomeGenBase[256]; + public int xPosition; + public int zPosition; + public long lastAccessTime; + private static final String __OBFID = "CL_00000163"; + + public Block(int par2, int par3) + { + this.xPosition = par2; + this.zPosition = par3; + BiomeCache.this.chunkManager.getRainfall(this.rainfallValues, par2 << 4, par3 << 4, 16, 16); + BiomeCache.this.chunkManager.getBiomeGenAt(this.biomes, par2 << 4, par3 << 4, 16, 16, false); + } + + public BiomeGenBase getBiomeGenAt(int par1, int par2) + { + return this.biomes[par1 & 15 | (par2 & 15) << 4]; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/biome/BiomeDecorator.java b/src/main/java/net/minecraft/world/biome/BiomeDecorator.java new file mode 100644 index 0000000..43c3fef --- /dev/null +++ b/src/main/java/net/minecraft/world/biome/BiomeDecorator.java @@ -0,0 +1,362 @@ +package net.minecraft.world.biome; + +import java.util.Random; +import net.minecraft.block.BlockFlower; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenAbstractTree; +import net.minecraft.world.gen.feature.WorldGenBigMushroom; +import net.minecraft.world.gen.feature.WorldGenCactus; +import net.minecraft.world.gen.feature.WorldGenClay; +import net.minecraft.world.gen.feature.WorldGenDeadBush; +import net.minecraft.world.gen.feature.WorldGenFlowers; +import net.minecraft.world.gen.feature.WorldGenLiquids; +import net.minecraft.world.gen.feature.WorldGenMinable; +import net.minecraft.world.gen.feature.WorldGenPumpkin; +import net.minecraft.world.gen.feature.WorldGenReed; +import net.minecraft.world.gen.feature.WorldGenSand; +import net.minecraft.world.gen.feature.WorldGenWaterlily; +import net.minecraft.world.gen.feature.WorldGenerator; + +import static net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.*; +import static net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType.*; +import net.minecraftforge.common.*; +import net.minecraftforge.event.terraingen.*; + +public class BiomeDecorator +{ + public World currentWorld; + public Random randomGenerator; + public int chunk_X; + public int chunk_Z; + public WorldGenerator clayGen = new WorldGenClay(4); + public WorldGenerator sandGen; + public WorldGenerator gravelAsSandGen; + public WorldGenerator dirtGen; + public WorldGenerator gravelGen; + public WorldGenerator coalGen; + public WorldGenerator ironGen; + public WorldGenerator goldGen; + public WorldGenerator redstoneGen; + public WorldGenerator diamondGen; + public WorldGenerator lapisGen; + public WorldGenFlowers yellowFlowerGen; + public WorldGenerator mushroomBrownGen; + public WorldGenerator mushroomRedGen; + public WorldGenerator bigMushroomGen; + public WorldGenerator reedGen; + public WorldGenerator cactusGen; + public WorldGenerator waterlilyGen; + public int waterlilyPerChunk; + public int treesPerChunk; + public int flowersPerChunk; + public int grassPerChunk; + public int deadBushPerChunk; + public int mushroomsPerChunk; + public int reedsPerChunk; + public int cactiPerChunk; + public int sandPerChunk; + public int sandPerChunk2; + public int clayPerChunk; + public int bigMushroomsPerChunk; + public boolean generateLakes; + private static final String __OBFID = "CL_00000164"; + + public BiomeDecorator() + { + this.sandGen = new WorldGenSand(Blocks.sand, 7); + this.gravelAsSandGen = new WorldGenSand(Blocks.gravel, 6); + this.dirtGen = new WorldGenMinable(Blocks.dirt, 32); + this.gravelGen = new WorldGenMinable(Blocks.gravel, 32); + this.coalGen = new WorldGenMinable(Blocks.coal_ore, 16); + this.ironGen = new WorldGenMinable(Blocks.iron_ore, 8); + this.goldGen = new WorldGenMinable(Blocks.gold_ore, 8); + this.redstoneGen = new WorldGenMinable(Blocks.redstone_ore, 7); + this.diamondGen = new WorldGenMinable(Blocks.diamond_ore, 7); + this.lapisGen = new WorldGenMinable(Blocks.lapis_ore, 6); + this.yellowFlowerGen = new WorldGenFlowers(Blocks.yellow_flower); + this.mushroomBrownGen = new WorldGenFlowers(Blocks.brown_mushroom); + this.mushroomRedGen = new WorldGenFlowers(Blocks.red_mushroom); + this.bigMushroomGen = new WorldGenBigMushroom(); + this.reedGen = new WorldGenReed(); + this.cactusGen = new WorldGenCactus(); + this.waterlilyGen = new WorldGenWaterlily(); + this.flowersPerChunk = 2; + this.grassPerChunk = 1; + this.sandPerChunk = 1; + this.sandPerChunk2 = 3; + this.clayPerChunk = 1; + this.generateLakes = true; + } + + public void decorateChunk(World p_150512_1_, Random p_150512_2_, BiomeGenBase p_150512_3_, int p_150512_4_, int p_150512_5_) + { + if (this.currentWorld != null) + { + throw new RuntimeException("Already decorating!!"); + } + else + { + this.currentWorld = p_150512_1_; + this.randomGenerator = p_150512_2_; + this.chunk_X = p_150512_4_; + this.chunk_Z = p_150512_5_; + this.genDecorations(p_150512_3_); + this.currentWorld = null; + this.randomGenerator = null; + } + } + + protected void genDecorations(BiomeGenBase p_150513_1_) + { + MinecraftForge.EVENT_BUS.post(new DecorateBiomeEvent.Pre(currentWorld, randomGenerator, chunk_X, chunk_Z)); + this.generateOres(); + int i; + int j; + int k; + + boolean doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, SAND); + for (i = 0; doGen && i < this.sandPerChunk2; ++i) + { + j = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + this.sandGen.generate(this.currentWorld, this.randomGenerator, j, this.currentWorld.getTopSolidOrLiquidBlock(j, k), k); + } + + doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, CLAY); + for (i = 0; doGen && i < this.clayPerChunk; ++i) + { + j = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + this.clayGen.generate(this.currentWorld, this.randomGenerator, j, this.currentWorld.getTopSolidOrLiquidBlock(j, k), k); + } + + doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, SAND_PASS2); + for (i = 0; doGen && i < this.sandPerChunk; ++i) + { + j = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + this.gravelAsSandGen.generate(this.currentWorld, this.randomGenerator, j, this.currentWorld.getTopSolidOrLiquidBlock(j, k), k); + } + + i = this.treesPerChunk; + + if (this.randomGenerator.nextInt(10) == 0) + { + ++i; + } + + int l; + int i1; + + doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, TREE); + for (j = 0; doGen && j < i; ++j) + { + k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + i1 = this.currentWorld.getHeightValue(k, l); + WorldGenAbstractTree worldgenabstracttree = p_150513_1_.func_150567_a(this.randomGenerator); + worldgenabstracttree.setScale(1.0D, 1.0D, 1.0D); + + if (worldgenabstracttree.generate(this.currentWorld, this.randomGenerator, k, i1, l)) + { + worldgenabstracttree.func_150524_b(this.currentWorld, this.randomGenerator, k, i1, l); + } + } + + doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, BIG_SHROOM); + for (j = 0; doGen && j < this.bigMushroomsPerChunk; ++j) + { + k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + this.bigMushroomGen.generate(this.currentWorld, this.randomGenerator, k, this.currentWorld.getHeightValue(k, l), l); + } + + doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, FLOWERS); + for (j = 0; doGen && j < this.flowersPerChunk; ++j) + { + k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + i1 = this.randomGenerator.nextInt(this.currentWorld.getHeightValue(k, l) + 32); + String s = p_150513_1_.func_150572_a(this.randomGenerator, k, i1, l); + BlockFlower blockflower = BlockFlower.func_149857_e(s); + + if (blockflower.getMaterial() != Material.air) + { + this.yellowFlowerGen.func_150550_a(blockflower, BlockFlower.func_149856_f(s)); + this.yellowFlowerGen.generate(this.currentWorld, this.randomGenerator, k, i1, l); + } + } + + doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, GRASS); + for (j = 0; doGen && j < this.grassPerChunk; ++j) + { + k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + i1 = this.randomGenerator.nextInt(this.currentWorld.getHeightValue(k, l) * 2); + WorldGenerator worldgenerator = p_150513_1_.getRandomWorldGenForGrass(this.randomGenerator); + worldgenerator.generate(this.currentWorld, this.randomGenerator, k, i1, l); + } + + doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, DEAD_BUSH); + for (j = 0; doGen && j < this.deadBushPerChunk; ++j) + { + k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + i1 = this.randomGenerator.nextInt(this.currentWorld.getHeightValue(k, l) * 2); + (new WorldGenDeadBush(Blocks.deadbush)).generate(this.currentWorld, this.randomGenerator, k, i1, l); + } + + doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, LILYPAD); + for (j = 0; doGen && j < this.waterlilyPerChunk; ++j) + { + k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + + for (i1 = this.randomGenerator.nextInt(this.currentWorld.getHeightValue(k, l) * 2); i1 > 0 && this.currentWorld.isAirBlock(k, i1 - 1, l); --i1) + { + ; + } + + this.waterlilyGen.generate(this.currentWorld, this.randomGenerator, k, i1, l); + } + + doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, SHROOM); + for (j = 0; doGen && j < this.mushroomsPerChunk; ++j) + { + if (this.randomGenerator.nextInt(4) == 0) + { + k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + i1 = this.currentWorld.getHeightValue(k, l); + this.mushroomBrownGen.generate(this.currentWorld, this.randomGenerator, k, i1, l); + } + + if (this.randomGenerator.nextInt(8) == 0) + { + k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + i1 = this.randomGenerator.nextInt(this.currentWorld.getHeightValue(k, l) * 2); + this.mushroomRedGen.generate(this.currentWorld, this.randomGenerator, k, i1, l); + } + } + + if (doGen && this.randomGenerator.nextInt(4) == 0) + { + j = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + l = this.randomGenerator.nextInt(this.currentWorld.getHeightValue(j, k) * 2); + this.mushroomBrownGen.generate(this.currentWorld, this.randomGenerator, j, l, k); + } + + if (doGen && this.randomGenerator.nextInt(8) == 0) + { + j = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + l = this.randomGenerator.nextInt(this.currentWorld.getHeightValue(j, k) * 2); + this.mushroomRedGen.generate(this.currentWorld, this.randomGenerator, j, l, k); + } + + doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, REED); + for (j = 0; doGen && j < this.reedsPerChunk; ++j) + { + k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + i1 = this.randomGenerator.nextInt(this.currentWorld.getHeightValue(k, l) * 2); + this.reedGen.generate(this.currentWorld, this.randomGenerator, k, i1, l); + } + + for (j = 0; doGen && j < 10; ++j) + { + k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + i1 = this.randomGenerator.nextInt(this.currentWorld.getHeightValue(k, l) * 2); + this.reedGen.generate(this.currentWorld, this.randomGenerator, k, i1, l); + } + + doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, PUMPKIN); + if (doGen && this.randomGenerator.nextInt(32) == 0) + { + j = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + k = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + l = this.randomGenerator.nextInt(this.currentWorld.getHeightValue(j, k) * 2); + (new WorldGenPumpkin()).generate(this.currentWorld, this.randomGenerator, j, l, k); + } + + doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, CACTUS); + for (j = 0; doGen && j < this.cactiPerChunk; ++j) + { + k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + l = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + i1 = this.randomGenerator.nextInt(this.currentWorld.getHeightValue(k, l) * 2); + this.cactusGen.generate(this.currentWorld, this.randomGenerator, k, i1, l); + } + + doGen = TerrainGen.decorate(currentWorld, randomGenerator, chunk_X, chunk_Z, LAKE); + if (doGen && this.generateLakes) + { + for (j = 0; j < 50; ++j) + { + k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + l = this.randomGenerator.nextInt(this.randomGenerator.nextInt(248) + 8); + i1 = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + (new WorldGenLiquids(Blocks.flowing_water)).generate(this.currentWorld, this.randomGenerator, k, l, i1); + } + + for (j = 0; j < 20; ++j) + { + k = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + l = this.randomGenerator.nextInt(this.randomGenerator.nextInt(this.randomGenerator.nextInt(240) + 8) + 8); + i1 = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + (new WorldGenLiquids(Blocks.flowing_lava)).generate(this.currentWorld, this.randomGenerator, k, l, i1); + } + } + + MinecraftForge.EVENT_BUS.post(new DecorateBiomeEvent.Post(currentWorld, randomGenerator, chunk_X, chunk_Z)); + } + + protected void genStandardOre1(int par1, WorldGenerator par2WorldGenerator, int par3, int par4) + { + for (int l = 0; l < par1; ++l) + { + int i1 = this.chunk_X + this.randomGenerator.nextInt(16); + int j1 = this.randomGenerator.nextInt(par4 - par3) + par3; + int k1 = this.chunk_Z + this.randomGenerator.nextInt(16); + par2WorldGenerator.generate(this.currentWorld, this.randomGenerator, i1, j1, k1); + } + } + + protected void genStandardOre2(int par1, WorldGenerator par2WorldGenerator, int par3, int par4) + { + for (int l = 0; l < par1; ++l) + { + int i1 = this.chunk_X + this.randomGenerator.nextInt(16); + int j1 = this.randomGenerator.nextInt(par4) + this.randomGenerator.nextInt(par4) + (par3 - par4); + int k1 = this.chunk_Z + this.randomGenerator.nextInt(16); + par2WorldGenerator.generate(this.currentWorld, this.randomGenerator, i1, j1, k1); + } + } + + protected void generateOres() + { + MinecraftForge.ORE_GEN_BUS.post(new OreGenEvent.Pre(currentWorld, randomGenerator, chunk_X, chunk_Z)); + if (TerrainGen.generateOre(currentWorld, randomGenerator, dirtGen, chunk_X, chunk_Z, DIRT)) + this.genStandardOre1(20, this.dirtGen, 0, 256); + if (TerrainGen.generateOre(currentWorld, randomGenerator, gravelGen, chunk_X, chunk_Z, GRAVEL)) + this.genStandardOre1(10, this.gravelGen, 0, 256); + if (TerrainGen.generateOre(currentWorld, randomGenerator, coalGen, chunk_X, chunk_Z, COAL)) + this.genStandardOre1(20, this.coalGen, 0, 128); + if (TerrainGen.generateOre(currentWorld, randomGenerator, ironGen, chunk_X, chunk_Z, IRON)) + this.genStandardOre1(20, this.ironGen, 0, 64); + if (TerrainGen.generateOre(currentWorld, randomGenerator, goldGen, chunk_X, chunk_Z, GOLD)) + this.genStandardOre1(2, this.goldGen, 0, 32); + if (TerrainGen.generateOre(currentWorld, randomGenerator, redstoneGen, chunk_X, chunk_Z, REDSTONE)) + this.genStandardOre1(8, this.redstoneGen, 0, 16); + if (TerrainGen.generateOre(currentWorld, randomGenerator, diamondGen, chunk_X, chunk_Z, DIAMOND)) + this.genStandardOre1(1, this.diamondGen, 0, 16); + if (TerrainGen.generateOre(currentWorld, randomGenerator, lapisGen, chunk_X, chunk_Z, LAPIS)) + this.genStandardOre2(1, this.lapisGen, 16, 16); + MinecraftForge.ORE_GEN_BUS.post(new OreGenEvent.Post(currentWorld, randomGenerator, chunk_X, chunk_Z)); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/biome/BiomeEndDecorator.java b/src/main/java/net/minecraft/world/biome/BiomeEndDecorator.java new file mode 100644 index 0000000..94f4618 --- /dev/null +++ b/src/main/java/net/minecraft/world/biome/BiomeEndDecorator.java @@ -0,0 +1,37 @@ +package net.minecraft.world.biome; + +import net.minecraft.entity.boss.EntityDragon; +import net.minecraft.init.Blocks; +import net.minecraft.world.gen.feature.WorldGenSpikes; +import net.minecraft.world.gen.feature.WorldGenerator; + +public class BiomeEndDecorator extends BiomeDecorator +{ + protected WorldGenerator spikeGen; + private static final String __OBFID = "CL_00000188"; + + public BiomeEndDecorator() + { + this.spikeGen = new WorldGenSpikes(Blocks.end_stone); + } + + protected void genDecorations(BiomeGenBase p_150513_1_) + { + this.generateOres(); + + if (this.randomGenerator.nextInt(5) == 0) + { + int i = this.chunk_X + this.randomGenerator.nextInt(16) + 8; + int j = this.chunk_Z + this.randomGenerator.nextInt(16) + 8; + int k = this.currentWorld.getTopSolidOrLiquidBlock(i, j); + this.spikeGen.generate(this.currentWorld, this.randomGenerator, i, k, j); + } + + if (this.chunk_X == 0 && this.chunk_Z == 0) + { + EntityDragon entitydragon = new EntityDragon(this.currentWorld); + entitydragon.setLocationAndAngles(0.0D, 128.0D, 0.0D, this.randomGenerator.nextFloat() * 360.0F, 0.0F); + this.currentWorld.spawnEntityInWorld(entitydragon); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/biome/BiomeGenBase.java b/src/main/java/net/minecraft/world/biome/BiomeGenBase.java new file mode 100644 index 0000000..f5a7d57 --- /dev/null +++ b/src/main/java/net/minecraft/world/biome/BiomeGenBase.java @@ -0,0 +1,675 @@ +package net.minecraft.world.biome; + +import com.google.common.collect.Sets; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.awt.Color; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import java.util.Set; +import net.minecraft.block.Block; +import net.minecraft.block.BlockFlower; +import net.minecraft.block.material.Material; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.monster.EntityCreeper; +import net.minecraft.entity.monster.EntityEnderman; +import net.minecraft.entity.monster.EntitySkeleton; +import net.minecraft.entity.monster.EntitySlime; +import net.minecraft.entity.monster.EntitySpider; +import net.minecraft.entity.monster.EntityWitch; +import net.minecraft.entity.monster.EntityZombie; +import net.minecraft.entity.passive.EntityBat; +import net.minecraft.entity.passive.EntityChicken; +import net.minecraft.entity.passive.EntityCow; +import net.minecraft.entity.passive.EntityPig; +import net.minecraft.entity.passive.EntitySheep; +import net.minecraft.entity.passive.EntitySquid; +import net.minecraft.init.Blocks; +import net.minecraft.util.MathHelper; +import net.minecraft.util.WeightedRandom; +import net.minecraft.world.ColorizerFoliage; +import net.minecraft.world.ColorizerGrass; +import net.minecraft.world.World; +import net.minecraft.world.gen.NoiseGeneratorPerlin; +import net.minecraft.world.gen.feature.WorldGenAbstractTree; +import net.minecraft.world.gen.feature.WorldGenBigTree; +import net.minecraft.world.gen.feature.WorldGenDoublePlant; +import net.minecraft.world.gen.feature.WorldGenSwamp; +import net.minecraft.world.gen.feature.WorldGenTallGrass; +import net.minecraft.world.gen.feature.WorldGenTrees; +import net.minecraft.world.gen.feature.WorldGenerator; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import net.minecraftforge.common.*; +import net.minecraftforge.event.terraingen.*; + +public abstract class BiomeGenBase +{ + private static final Logger logger = LogManager.getLogger(); + protected static final BiomeGenBase.Height height_Default = new BiomeGenBase.Height(0.1F, 0.2F); + protected static final BiomeGenBase.Height height_ShallowWaters = new BiomeGenBase.Height(-0.5F, 0.0F); + protected static final BiomeGenBase.Height height_Oceans = new BiomeGenBase.Height(-1.0F, 0.1F); + protected static final BiomeGenBase.Height height_DeepOceans = new BiomeGenBase.Height(-1.8F, 0.1F); + protected static final BiomeGenBase.Height height_LowPlains = new BiomeGenBase.Height(0.125F, 0.05F); + protected static final BiomeGenBase.Height height_MidPlains = new BiomeGenBase.Height(0.2F, 0.2F); + protected static final BiomeGenBase.Height height_LowHills = new BiomeGenBase.Height(0.45F, 0.3F); + protected static final BiomeGenBase.Height height_HighPlateaus = new BiomeGenBase.Height(1.5F, 0.025F); + protected static final BiomeGenBase.Height height_MidHills = new BiomeGenBase.Height(1.0F, 0.5F); + protected static final BiomeGenBase.Height height_Shores = new BiomeGenBase.Height(0.0F, 0.025F); + protected static final BiomeGenBase.Height height_RockyWaters = new BiomeGenBase.Height(0.1F, 0.8F); + protected static final BiomeGenBase.Height height_LowIslands = new BiomeGenBase.Height(0.2F, 0.3F); + protected static final BiomeGenBase.Height height_PartiallySubmerged = new BiomeGenBase.Height(-0.2F, 0.1F); + private static final BiomeGenBase[] biomeList = new BiomeGenBase[256]; + public static final Set explorationBiomesList = Sets.newHashSet(); + public static final BiomeGenBase ocean = (new BiomeGenOcean(0)).setColor(112).setBiomeName("Ocean").setHeight(height_Oceans); + public static final BiomeGenBase plains = (new BiomeGenPlains(1)).setColor(9286496).setBiomeName("Plains"); + public static final BiomeGenBase desert = (new BiomeGenDesert(2)).setColor(16421912).setBiomeName("Desert").setDisableRain().setTemperatureRainfall(2.0F, 0.0F).setHeight(height_LowPlains); + public static final BiomeGenBase extremeHills = (new BiomeGenHills(3, false)).setColor(6316128).setBiomeName("Extreme Hills").setHeight(height_MidHills).setTemperatureRainfall(0.2F, 0.3F); + public static final BiomeGenBase forest = (new BiomeGenForest(4, 0)).setColor(353825).setBiomeName("Forest"); + public static final BiomeGenBase taiga = (new BiomeGenTaiga(5, 0)).setColor(747097).setBiomeName("Taiga").func_76733_a(5159473).setTemperatureRainfall(0.25F, 0.8F).setHeight(height_MidPlains); + public static final BiomeGenBase swampland = (new BiomeGenSwamp(6)).setColor(522674).setBiomeName("Swampland").func_76733_a(9154376).setHeight(height_PartiallySubmerged).setTemperatureRainfall(0.8F, 0.9F); + public static final BiomeGenBase river = (new BiomeGenRiver(7)).setColor(255).setBiomeName("River").setHeight(height_ShallowWaters); + public static final BiomeGenBase hell = (new BiomeGenHell(8)).setColor(16711680).setBiomeName("Hell").setDisableRain().setTemperatureRainfall(2.0F, 0.0F); + public static final BiomeGenBase sky = (new BiomeGenEnd(9)).setColor(8421631).setBiomeName("Sky").setDisableRain(); + public static final BiomeGenBase frozenOcean = (new BiomeGenOcean(10)).setColor(9474208).setBiomeName("FrozenOcean").setEnableSnow().setHeight(height_Oceans).setTemperatureRainfall(0.0F, 0.5F); + public static final BiomeGenBase frozenRiver = (new BiomeGenRiver(11)).setColor(10526975).setBiomeName("FrozenRiver").setEnableSnow().setHeight(height_ShallowWaters).setTemperatureRainfall(0.0F, 0.5F); + public static final BiomeGenBase icePlains = (new BiomeGenSnow(12, false)).setColor(16777215).setBiomeName("Ice Plains").setEnableSnow().setTemperatureRainfall(0.0F, 0.5F).setHeight(height_LowPlains); + public static final BiomeGenBase iceMountains = (new BiomeGenSnow(13, false)).setColor(10526880).setBiomeName("Ice Mountains").setEnableSnow().setHeight(height_LowHills).setTemperatureRainfall(0.0F, 0.5F); + public static final BiomeGenBase mushroomIsland = (new BiomeGenMushroomIsland(14)).setColor(16711935).setBiomeName("MushroomIsland").setTemperatureRainfall(0.9F, 1.0F).setHeight(height_LowIslands); + public static final BiomeGenBase mushroomIslandShore = (new BiomeGenMushroomIsland(15)).setColor(10486015).setBiomeName("MushroomIslandShore").setTemperatureRainfall(0.9F, 1.0F).setHeight(height_Shores); + public static final BiomeGenBase beach = (new BiomeGenBeach(16)).setColor(16440917).setBiomeName("Beach").setTemperatureRainfall(0.8F, 0.4F).setHeight(height_Shores); + public static final BiomeGenBase desertHills = (new BiomeGenDesert(17)).setColor(13786898).setBiomeName("DesertHills").setDisableRain().setTemperatureRainfall(2.0F, 0.0F).setHeight(height_LowHills); + public static final BiomeGenBase forestHills = (new BiomeGenForest(18, 0)).setColor(2250012).setBiomeName("ForestHills").setHeight(height_LowHills); + public static final BiomeGenBase taigaHills = (new BiomeGenTaiga(19, 0)).setColor(1456435).setBiomeName("TaigaHills").func_76733_a(5159473).setTemperatureRainfall(0.25F, 0.8F).setHeight(height_LowHills); + public static final BiomeGenBase extremeHillsEdge = (new BiomeGenHills(20, true)).setColor(7501978).setBiomeName("Extreme Hills Edge").setHeight(height_MidHills.attenuate()).setTemperatureRainfall(0.2F, 0.3F); + public static final BiomeGenBase jungle = (new BiomeGenJungle(21, false)).setColor(5470985).setBiomeName("Jungle").func_76733_a(5470985).setTemperatureRainfall(0.95F, 0.9F); + public static final BiomeGenBase jungleHills = (new BiomeGenJungle(22, false)).setColor(2900485).setBiomeName("JungleHills").func_76733_a(5470985).setTemperatureRainfall(0.95F, 0.9F).setHeight(height_LowHills); + public static final BiomeGenBase jungleEdge = (new BiomeGenJungle(23, true)).setColor(6458135).setBiomeName("JungleEdge").func_76733_a(5470985).setTemperatureRainfall(0.95F, 0.8F); + public static final BiomeGenBase deepOcean = (new BiomeGenOcean(24)).setColor(48).setBiomeName("Deep Ocean").setHeight(height_DeepOceans); + public static final BiomeGenBase stoneBeach = (new BiomeGenStoneBeach(25)).setColor(10658436).setBiomeName("Stone Beach").setTemperatureRainfall(0.2F, 0.3F).setHeight(height_RockyWaters); + public static final BiomeGenBase coldBeach = (new BiomeGenBeach(26)).setColor(16445632).setBiomeName("Cold Beach").setTemperatureRainfall(0.05F, 0.3F).setHeight(height_Shores).setEnableSnow(); + public static final BiomeGenBase birchForest = (new BiomeGenForest(27, 2)).setBiomeName("Birch Forest").setColor(3175492); + public static final BiomeGenBase birchForestHills = (new BiomeGenForest(28, 2)).setBiomeName("Birch Forest Hills").setColor(2055986).setHeight(height_LowHills); + public static final BiomeGenBase roofedForest = (new BiomeGenForest(29, 3)).setColor(4215066).setBiomeName("Roofed Forest"); + public static final BiomeGenBase coldTaiga = (new BiomeGenTaiga(30, 0)).setColor(3233098).setBiomeName("Cold Taiga").func_76733_a(5159473).setEnableSnow().setTemperatureRainfall(-0.5F, 0.4F).setHeight(height_MidPlains).func_150563_c(16777215); + public static final BiomeGenBase coldTaigaHills = (new BiomeGenTaiga(31, 0)).setColor(2375478).setBiomeName("Cold Taiga Hills").func_76733_a(5159473).setEnableSnow().setTemperatureRainfall(-0.5F, 0.4F).setHeight(height_LowHills).func_150563_c(16777215); + public static final BiomeGenBase megaTaiga = (new BiomeGenTaiga(32, 1)).setColor(5858897).setBiomeName("Mega Taiga").func_76733_a(5159473).setTemperatureRainfall(0.3F, 0.8F).setHeight(height_MidPlains); + public static final BiomeGenBase megaTaigaHills = (new BiomeGenTaiga(33, 1)).setColor(4542270).setBiomeName("Mega Taiga Hills").func_76733_a(5159473).setTemperatureRainfall(0.3F, 0.8F).setHeight(height_LowHills); + public static final BiomeGenBase extremeHillsPlus = (new BiomeGenHills(34, true)).setColor(5271632).setBiomeName("Extreme Hills+").setHeight(height_MidHills).setTemperatureRainfall(0.2F, 0.3F); + public static final BiomeGenBase savanna = (new BiomeGenSavanna(35)).setColor(12431967).setBiomeName("Savanna").setTemperatureRainfall(1.2F, 0.0F).setDisableRain().setHeight(height_LowPlains); + public static final BiomeGenBase savannaPlateau = (new BiomeGenSavanna(36)).setColor(10984804).setBiomeName("Savanna Plateau").setTemperatureRainfall(1.0F, 0.0F).setDisableRain().setHeight(height_HighPlateaus); + public static final BiomeGenBase mesa = (new BiomeGenMesa(37, false, false)).setColor(14238997).setBiomeName("Mesa"); + public static final BiomeGenBase mesaPlateau_F = (new BiomeGenMesa(38, false, true)).setColor(11573093).setBiomeName("Mesa Plateau F").setHeight(height_HighPlateaus); + public static final BiomeGenBase mesaPlateau = (new BiomeGenMesa(39, false, false)).setColor(13274213).setBiomeName("Mesa Plateau").setHeight(height_HighPlateaus); + protected static final NoiseGeneratorPerlin temperatureNoise; + protected static final NoiseGeneratorPerlin plantNoise; + protected static final WorldGenDoublePlant genTallFlowers; + public String biomeName; + public int color; + public int field_150609_ah; + public Block topBlock; + public int field_150604_aj; + public Block fillerBlock; + public int field_76754_C; + public float rootHeight; + public float heightVariation; + public float temperature; + public float rainfall; + public int waterColorMultiplier; + public BiomeDecorator theBiomeDecorator; + protected List spawnableMonsterList; + protected List spawnableCreatureList; + protected List spawnableWaterCreatureList; + protected List spawnableCaveCreatureList; + protected boolean enableSnow; + protected boolean enableRain; + public final int biomeID; + protected WorldGenTrees worldGeneratorTrees; + protected WorldGenBigTree worldGeneratorBigTree; + protected WorldGenSwamp worldGeneratorSwamp; + private static final String __OBFID = "CL_00000158"; + + public BiomeGenBase(int par1) + { + this(par1, true); + } + public BiomeGenBase(int par1, boolean register) + { + this.topBlock = Blocks.grass; + this.field_150604_aj = 0; + this.fillerBlock = Blocks.dirt; + this.field_76754_C = 5169201; + this.rootHeight = height_Default.rootHeight; + this.heightVariation = height_Default.variation; + this.temperature = 0.5F; + this.rainfall = 0.5F; + this.waterColorMultiplier = 16777215; + this.spawnableMonsterList = new ArrayList(); + this.spawnableCreatureList = new ArrayList(); + this.spawnableWaterCreatureList = new ArrayList(); + this.spawnableCaveCreatureList = new ArrayList(); + this.enableRain = true; + this.worldGeneratorTrees = new WorldGenTrees(false); + this.worldGeneratorBigTree = new WorldGenBigTree(false); + this.worldGeneratorSwamp = new WorldGenSwamp(); + this.biomeID = par1; + if (register) + biomeList[par1] = this; + this.theBiomeDecorator = this.createBiomeDecorator(); + this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(EntitySheep.class, 12, 4, 4)); + this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityPig.class, 10, 4, 4)); + this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityChicken.class, 10, 4, 4)); + this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityCow.class, 8, 4, 4)); + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySpider.class, 100, 4, 4)); + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityZombie.class, 100, 4, 4)); + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySkeleton.class, 100, 4, 4)); + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityCreeper.class, 100, 4, 4)); + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySlime.class, 100, 4, 4)); + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityEnderman.class, 10, 1, 4)); + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityWitch.class, 5, 1, 1)); + this.spawnableWaterCreatureList.add(new BiomeGenBase.SpawnListEntry(EntitySquid.class, 10, 4, 4)); + this.spawnableCaveCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityBat.class, 10, 8, 8)); + this.addDefaultFlowers(); + } + + public BiomeDecorator createBiomeDecorator() + { + return getModdedBiomeDecorator(new BiomeDecorator()); + } + + public BiomeGenBase setTemperatureRainfall(float par1, float par2) + { + if (par1 > 0.1F && par1 < 0.2F) + { + throw new IllegalArgumentException("Please avoid temperatures in the range 0.1 - 0.2 because of snow"); + } + else + { + this.temperature = par1; + this.rainfall = par2; + return this; + } + } + + public final BiomeGenBase setHeight(BiomeGenBase.Height p_150570_1_) + { + this.rootHeight = p_150570_1_.rootHeight; + this.heightVariation = p_150570_1_.variation; + return this; + } + + public BiomeGenBase setDisableRain() + { + this.enableRain = false; + return this; + } + + public WorldGenAbstractTree func_150567_a(Random p_150567_1_) + { + return (WorldGenAbstractTree)(p_150567_1_.nextInt(10) == 0 ? this.worldGeneratorBigTree : this.worldGeneratorTrees); + } + + public WorldGenerator getRandomWorldGenForGrass(Random par1Random) + { + return new WorldGenTallGrass(Blocks.tallgrass, 1); + } + + public String func_150572_a(Random p_150572_1_, int p_150572_2_, int p_150572_3_, int p_150572_4_) + { + return p_150572_1_.nextInt(3) > 0 ? BlockFlower.field_149858_b[0] : BlockFlower.field_149859_a[0]; + } + + public BiomeGenBase setEnableSnow() + { + this.enableSnow = true; + return this; + } + + public BiomeGenBase setBiomeName(String par1Str) + { + this.biomeName = par1Str; + return this; + } + + public BiomeGenBase func_76733_a(int par1) + { + this.field_76754_C = par1; + return this; + } + + public BiomeGenBase setColor(int par1) + { + this.func_150557_a(par1, false); + return this; + } + + public BiomeGenBase func_150563_c(int p_150563_1_) + { + this.field_150609_ah = p_150563_1_; + return this; + } + + public BiomeGenBase func_150557_a(int p_150557_1_, boolean p_150557_2_) + { + this.color = p_150557_1_; + + if (p_150557_2_) + { + this.field_150609_ah = (p_150557_1_ & 16711422) >> 1; + } + else + { + this.field_150609_ah = p_150557_1_; + } + + return this; + } + + @SideOnly(Side.CLIENT) + public int getSkyColorByTemp(float par1) + { + par1 /= 3.0F; + + if (par1 < -1.0F) + { + par1 = -1.0F; + } + + if (par1 > 1.0F) + { + par1 = 1.0F; + } + + return Color.getHSBColor(0.62222224F - par1 * 0.05F, 0.5F + par1 * 0.1F, 1.0F).getRGB(); + } + + public List getSpawnableList(EnumCreatureType par1EnumCreatureType) + { + return par1EnumCreatureType == EnumCreatureType.monster ? this.spawnableMonsterList : (par1EnumCreatureType == EnumCreatureType.creature ? this.spawnableCreatureList : (par1EnumCreatureType == EnumCreatureType.waterCreature ? this.spawnableWaterCreatureList : (par1EnumCreatureType == EnumCreatureType.ambient ? this.spawnableCaveCreatureList : null))); + } + + public boolean getEnableSnow() + { + return this.func_150559_j(); + } + + public boolean canSpawnLightningBolt() + { + return this.func_150559_j() ? false : this.enableRain; + } + + public boolean isHighHumidity() + { + return this.rainfall > 0.85F; + } + + public float getSpawningChance() + { + return 0.1F; + } + + public final int getIntRainfall() + { + return (int)(this.rainfall * 65536.0F); + } + + @SideOnly(Side.CLIENT) + public final float getFloatRainfall() + { + return this.rainfall; + } + + public final float getFloatTemperature(int p_150564_1_, int p_150564_2_, int p_150564_3_) + { + if (p_150564_2_ > 64) + { + float f = (float)temperatureNoise.func_151601_a((double)p_150564_1_ * 1.0D / 8.0D, (double)p_150564_3_ * 1.0D / 8.0D) * 4.0F; + return this.temperature - (f + (float)p_150564_2_ - 64.0F) * 0.05F / 30.0F; + } + else + { + return this.temperature; + } + } + + public void decorate(World par1World, Random par2Random, int par3, int par4) + { + this.theBiomeDecorator.decorateChunk(par1World, par2Random, this, par3, par4); + } + + @SideOnly(Side.CLIENT) + public int getBiomeGrassColor(int p_150558_1_, int p_150558_2_, int p_150558_3_) + { + double d0 = (double)MathHelper.clamp_float(this.getFloatTemperature(p_150558_1_, p_150558_2_, p_150558_3_), 0.0F, 1.0F); + double d1 = (double)MathHelper.clamp_float(this.getFloatRainfall(), 0.0F, 1.0F); + return getModdedBiomeGrassColor(ColorizerGrass.getGrassColor(d0, d1)); + } + + @SideOnly(Side.CLIENT) + public int getBiomeFoliageColor(int p_150571_1_, int p_150571_2_, int p_150571_3_) + { + double d0 = (double)MathHelper.clamp_float(this.getFloatTemperature(p_150571_1_, p_150571_2_, p_150571_3_), 0.0F, 1.0F); + double d1 = (double)MathHelper.clamp_float(this.getFloatRainfall(), 0.0F, 1.0F); + return getModdedBiomeFoliageColor(ColorizerFoliage.getFoliageColor(d0, d1)); + } + + public boolean func_150559_j() + { + return this.enableSnow; + } + + public void genTerrainBlocks(World p_150573_1_, Random p_150573_2_, Block[] p_150573_3_, byte[] p_150573_4_, int p_150573_5_, int p_150573_6_, double p_150573_7_) + { + this.genBiomeTerrain(p_150573_1_, p_150573_2_, p_150573_3_, p_150573_4_, p_150573_5_, p_150573_6_, p_150573_7_); + } + + public final void genBiomeTerrain(World p_150560_1_, Random p_150560_2_, Block[] p_150560_3_, byte[] p_150560_4_, int p_150560_5_, int p_150560_6_, double p_150560_7_) + { + boolean flag = true; + Block block = this.topBlock; + byte b0 = (byte)(this.field_150604_aj & 255); + Block block1 = this.fillerBlock; + int k = -1; + int l = (int)(p_150560_7_ / 3.0D + 3.0D + p_150560_2_.nextDouble() * 0.25D); + int i1 = p_150560_5_ & 15; + int j1 = p_150560_6_ & 15; + int k1 = p_150560_3_.length / 256; + + for (int l1 = 255; l1 >= 0; --l1) + { + int i2 = (j1 * 16 + i1) * k1 + l1; + + if (l1 <= 0 + p_150560_2_.nextInt(5)) + { + p_150560_3_[i2] = Blocks.bedrock; + } + else + { + Block block2 = p_150560_3_[i2]; + + if (block2 != null && block2.getMaterial() != Material.air) + { + if (block2 == Blocks.stone) + { + if (k == -1) + { + if (l <= 0) + { + block = null; + b0 = 0; + block1 = Blocks.stone; + } + else if (l1 >= 59 && l1 <= 64) + { + block = this.topBlock; + b0 = (byte)(this.field_150604_aj & 255); + block1 = this.fillerBlock; + } + + if (l1 < 63 && (block == null || block.getMaterial() == Material.air)) + { + if (this.getFloatTemperature(p_150560_5_, l1, p_150560_6_) < 0.15F) + { + block = Blocks.ice; + b0 = 0; + } + else + { + block = Blocks.water; + b0 = 0; + } + } + + k = l; + + if (l1 >= 62) + { + p_150560_3_[i2] = block; + p_150560_4_[i2] = b0; + } + else if (l1 < 56 - l) + { + block = null; + block1 = Blocks.stone; + p_150560_3_[i2] = Blocks.gravel; + } + else + { + p_150560_3_[i2] = block1; + } + } + else if (k > 0) + { + --k; + p_150560_3_[i2] = block1; + + if (k == 0 && block1 == Blocks.sand) + { + k = p_150560_2_.nextInt(4) + Math.max(0, l1 - 63); + block1 = Blocks.sandstone; + } + } + } + } + else + { + k = -1; + } + } + } + } + + public BiomeGenBase createMutation() + { + return new BiomeGenMutated(this.biomeID + 128, this); + } + + public Class getBiomeClass() + { + return this.getClass(); + } + + public boolean isEqualTo(BiomeGenBase p_150569_1_) + { + return p_150569_1_ == this ? true : (p_150569_1_ == null ? false : this.getBiomeClass() == p_150569_1_.getBiomeClass()); + } + + public BiomeGenBase.TempCategory getTempCategory() + { + return (double)this.temperature < 0.2D ? BiomeGenBase.TempCategory.COLD : ((double)this.temperature < 1.0D ? BiomeGenBase.TempCategory.MEDIUM : BiomeGenBase.TempCategory.WARM); + } + + public static BiomeGenBase[] getBiomeGenArray() + { + return biomeList; + } + + public static BiomeGenBase getBiome(int p_150568_0_) + { + if (p_150568_0_ >= 0 && p_150568_0_ <= biomeList.length) + { + return biomeList[p_150568_0_]; + } + else + { + logger.warn("Biome ID is out of bounds: " + p_150568_0_ + ", defaulting to 0 (Ocean)"); + return ocean; + } + } + + /* ========================================= FORGE START ======================================*/ + protected List flowers = new ArrayList(); + + public BiomeDecorator getModdedBiomeDecorator(BiomeDecorator original) + { + return new DeferredBiomeDecorator(original); + } + + public int getWaterColorMultiplier() + { + BiomeEvent.GetWaterColor event = new BiomeEvent.GetWaterColor(this, waterColorMultiplier); + MinecraftForge.EVENT_BUS.post(event); + return event.newColor; + } + + public int getModdedBiomeGrassColor(int original) + { + BiomeEvent.GetGrassColor event = new BiomeEvent.GetGrassColor(this, original); + MinecraftForge.EVENT_BUS.post(event); + return event.newColor; + } + + public int getModdedBiomeFoliageColor(int original) + { + BiomeEvent.GetFoliageColor event = new BiomeEvent.GetFoliageColor(this, original); + MinecraftForge.EVENT_BUS.post(event); + return event.newColor; + } + + /** + * Weighted random holder class used to hold possible flowers + * that can spawn in this biome when bonemeal is used on grass. + */ + public static class FlowerEntry extends WeightedRandom.Item + { + public final Block block; + public final int metadata; + public FlowerEntry(Block block, int meta, int weight) + { + super(weight); + this.block = block; + this.metadata = meta; + } + } + + /** + * Adds the default flowers, as of 1.7, it is 2 yellow, and 1 red. I chose 10 to allow some wiggle room in the numbers. + */ + public void addDefaultFlowers() + { + this.flowers.add(new FlowerEntry(Blocks.yellow_flower, 0, 20)); + this.flowers.add(new FlowerEntry(Blocks.red_flower, 0, 10)); + } + + /** Register a new plant to be planted when bonemeal is used on grass. + * @param block The block to place. + * @param metadata The metadata to set for the block when being placed. + * @param weight The weight of the plant, where red flowers are + * 10 and yellow flowers are 20. + */ + public void addFlower(Block block, int metadata, int weight) + { + this.flowers.add(new FlowerEntry(block, metadata, weight)); + } + + public void plantFlower(World world, Random rand, int x, int y, int z) + { + BiomeGenBase biome = world.getBiomeGenForCoords(x, z); + String flowername = biome.func_150572_a(rand, x, y, z); + + FlowerEntry flower = (FlowerEntry)WeightedRandom.getRandomItem(rand, flowers); + if (flower == null || flower.block == null || !flower.block.canBlockStay(world, x, y, z)) + { + return; + } + + world.setBlock(x, y, z, flower.block, flower.metadata, 3); + } + + + /* ========================================= FORGE END ======================================*/ + + static + { + plains.createMutation(); + desert.createMutation(); + forest.createMutation(); + taiga.createMutation(); + swampland.createMutation(); + icePlains.createMutation(); + jungle.createMutation(); + jungleEdge.createMutation(); + coldTaiga.createMutation(); + savanna.createMutation(); + savannaPlateau.createMutation(); + mesa.createMutation(); + mesaPlateau_F.createMutation(); + mesaPlateau.createMutation(); + birchForest.createMutation(); + birchForestHills.createMutation(); + roofedForest.createMutation(); + megaTaiga.createMutation(); + extremeHills.createMutation(); + extremeHillsPlus.createMutation(); + biomeList[megaTaigaHills.biomeID + 128] = biomeList[megaTaiga.biomeID + 128]; + BiomeGenBase[] var0 = biomeList; + int var1 = var0.length; + + for (int var2 = 0; var2 < var1; ++var2) + { + BiomeGenBase var3 = var0[var2]; + + if (var3 != null && var3.biomeID < 128) + { + explorationBiomesList.add(var3); + } + } + + explorationBiomesList.remove(hell); + explorationBiomesList.remove(sky); + temperatureNoise = new NoiseGeneratorPerlin(new Random(1234L), 1); + plantNoise = new NoiseGeneratorPerlin(new Random(2345L), 1); + genTallFlowers = new WorldGenDoublePlant(); + } + + public static class Height + { + public float rootHeight; + public float variation; + private static final String __OBFID = "CL_00000159"; + + public Height(float p_i45371_1_, float p_i45371_2_) + { + this.rootHeight = p_i45371_1_; + this.variation = p_i45371_2_; + } + + public BiomeGenBase.Height attenuate() + { + return new BiomeGenBase.Height(this.rootHeight * 0.8F, this.variation * 0.6F); + } + } + + public static class SpawnListEntry extends WeightedRandom.Item + { + public Class entityClass; + public int minGroupCount; + public int maxGroupCount; + private static final String __OBFID = "CL_00000161"; + + public SpawnListEntry(Class par1Class, int par2, int par3, int par4) + { + super(par2); + this.entityClass = par1Class; + this.minGroupCount = par3; + this.maxGroupCount = par4; + } + + public String toString() + { + return this.entityClass.getSimpleName() + "*(" + this.minGroupCount + "-" + this.maxGroupCount + "):" + this.itemWeight; + } + } + + public static enum TempCategory + { + OCEAN, + COLD, + MEDIUM, + WARM; + + private static final String __OBFID = "CL_00000160"; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/biome/BiomeGenBeach.java b/src/main/java/net/minecraft/world/biome/BiomeGenBeach.java new file mode 100644 index 0000000..d996242 --- /dev/null +++ b/src/main/java/net/minecraft/world/biome/BiomeGenBeach.java @@ -0,0 +1,20 @@ +package net.minecraft.world.biome; + +import net.minecraft.init.Blocks; + +public class BiomeGenBeach extends BiomeGenBase +{ + private static final String __OBFID = "CL_00000157"; + + public BiomeGenBeach(int par1) + { + super(par1); + this.spawnableCreatureList.clear(); + this.topBlock = Blocks.sand; + this.fillerBlock = Blocks.sand; + this.theBiomeDecorator.treesPerChunk = -999; + this.theBiomeDecorator.deadBushPerChunk = 0; + this.theBiomeDecorator.reedsPerChunk = 0; + this.theBiomeDecorator.cactiPerChunk = 0; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/biome/BiomeGenDesert.java b/src/main/java/net/minecraft/world/biome/BiomeGenDesert.java new file mode 100644 index 0000000..a929beb --- /dev/null +++ b/src/main/java/net/minecraft/world/biome/BiomeGenDesert.java @@ -0,0 +1,37 @@ +package net.minecraft.world.biome; + +import java.util.Random; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenDesertWells; + +public class BiomeGenDesert extends BiomeGenBase +{ + private static final String __OBFID = "CL_00000167"; + + public BiomeGenDesert(int par1) + { + super(par1); + this.spawnableCreatureList.clear(); + this.topBlock = Blocks.sand; + this.fillerBlock = Blocks.sand; + this.theBiomeDecorator.treesPerChunk = -999; + this.theBiomeDecorator.deadBushPerChunk = 2; + this.theBiomeDecorator.reedsPerChunk = 50; + this.theBiomeDecorator.cactiPerChunk = 10; + this.spawnableCreatureList.clear(); + } + + public void decorate(World par1World, Random par2Random, int par3, int par4) + { + super.decorate(par1World, par2Random, par3, par4); + + if (par2Random.nextInt(1000) == 0) + { + int k = par3 + par2Random.nextInt(16) + 8; + int l = par4 + par2Random.nextInt(16) + 8; + WorldGenDesertWells worldgendesertwells = new WorldGenDesertWells(); + worldgendesertwells.generate(par1World, par2Random, k, par1World.getHeightValue(k, l) + 1, l); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/biome/BiomeGenEnd.java b/src/main/java/net/minecraft/world/biome/BiomeGenEnd.java new file mode 100644 index 0000000..c3bcdad --- /dev/null +++ b/src/main/java/net/minecraft/world/biome/BiomeGenEnd.java @@ -0,0 +1,30 @@ +package net.minecraft.world.biome; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.monster.EntityEnderman; +import net.minecraft.init.Blocks; + +public class BiomeGenEnd extends BiomeGenBase +{ + private static final String __OBFID = "CL_00000187"; + + public BiomeGenEnd(int par1) + { + super(par1); + this.spawnableMonsterList.clear(); + this.spawnableCreatureList.clear(); + this.spawnableWaterCreatureList.clear(); + this.spawnableCaveCreatureList.clear(); + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityEnderman.class, 10, 4, 4)); + this.topBlock = Blocks.dirt; + this.fillerBlock = Blocks.dirt; + this.theBiomeDecorator = new BiomeEndDecorator(); + } + + @SideOnly(Side.CLIENT) + public int getSkyColorByTemp(float par1) + { + return 0; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/biome/BiomeGenForest.java b/src/main/java/net/minecraft/world/biome/BiomeGenForest.java new file mode 100644 index 0000000..13b72aa --- /dev/null +++ b/src/main/java/net/minecraft/world/biome/BiomeGenForest.java @@ -0,0 +1,238 @@ +package net.minecraft.world.biome; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.block.BlockFlower; +import net.minecraft.entity.passive.EntityWolf; +import net.minecraft.init.Blocks; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenAbstractTree; +import net.minecraft.world.gen.feature.WorldGenBigMushroom; +import net.minecraft.world.gen.feature.WorldGenCanopyTree; +import net.minecraft.world.gen.feature.WorldGenForest; + +public class BiomeGenForest extends BiomeGenBase +{ + private int field_150632_aF; + protected static final WorldGenForest field_150629_aC = new WorldGenForest(false, true); + protected static final WorldGenForest field_150630_aD = new WorldGenForest(false, false); + protected static final WorldGenCanopyTree field_150631_aE = new WorldGenCanopyTree(false); + private static final String __OBFID = "CL_00000170"; + + public BiomeGenForest(int p_i45377_1_, int p_i45377_2_) + { + super(p_i45377_1_); + this.field_150632_aF = p_i45377_2_; + this.theBiomeDecorator.treesPerChunk = 10; + this.theBiomeDecorator.grassPerChunk = 2; + + if (this.field_150632_aF == 1) + { + this.theBiomeDecorator.treesPerChunk = 6; + this.theBiomeDecorator.flowersPerChunk = 100; + this.theBiomeDecorator.grassPerChunk = 1; + } + + this.func_76733_a(5159473); + this.setTemperatureRainfall(0.7F, 0.8F); + + if (this.field_150632_aF == 2) + { + this.field_150609_ah = 353825; + this.color = 3175492; + this.setTemperatureRainfall(0.6F, 0.6F); + } + + if (this.field_150632_aF == 0) + { + this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityWolf.class, 5, 4, 4)); + } + + if (this.field_150632_aF == 3) + { + this.theBiomeDecorator.treesPerChunk = -999; + } + + if (this.field_150632_aF == 1) + { + this.flowers.clear(); + for (int x = 0; x < BlockFlower.field_149859_a.length; x++) + { + this.addFlower(Blocks.red_flower, x, 10); + } + } + } + + public BiomeGenBase func_150557_a(int p_150557_1_, boolean p_150557_2_) + { + if (this.field_150632_aF == 2) + { + this.field_150609_ah = 353825; + this.color = p_150557_1_; + + if (p_150557_2_) + { + this.field_150609_ah = (this.field_150609_ah & 16711422) >> 1; + } + + return this; + } + else + { + return super.func_150557_a(p_150557_1_, p_150557_2_); + } + } + + public WorldGenAbstractTree func_150567_a(Random p_150567_1_) + { + return (WorldGenAbstractTree)(this.field_150632_aF == 3 && p_150567_1_.nextInt(3) > 0 ? field_150631_aE : (this.field_150632_aF != 2 && p_150567_1_.nextInt(5) != 0 ? this.worldGeneratorTrees : field_150630_aD)); + } + + public String func_150572_a(Random p_150572_1_, int p_150572_2_, int p_150572_3_, int p_150572_4_) + { + if (this.field_150632_aF == 1) + { + double d0 = MathHelper.clamp_double((1.0D + plantNoise.func_151601_a((double)p_150572_2_ / 48.0D, (double)p_150572_4_ / 48.0D)) / 2.0D, 0.0D, 0.9999D); + int l = (int)(d0 * (double)BlockFlower.field_149859_a.length); + + if (l == 1) + { + l = 0; + } + + return BlockFlower.field_149859_a[l]; + } + else + { + return super.func_150572_a(p_150572_1_, p_150572_2_, p_150572_3_, p_150572_4_); + } + } + + public void decorate(World par1World, Random par2Random, int par3, int par4) + { + int k; + int l; + int i1; + int j1; + int k1; + + if (this.field_150632_aF == 3) + { + for (k = 0; k < 4; ++k) + { + for (l = 0; l < 4; ++l) + { + i1 = par3 + k * 4 + 1 + 8 + par2Random.nextInt(3); + j1 = par4 + l * 4 + 1 + 8 + par2Random.nextInt(3); + k1 = par1World.getHeightValue(i1, j1); + + if (par2Random.nextInt(20) == 0) + { + WorldGenBigMushroom worldgenbigmushroom = new WorldGenBigMushroom(); + worldgenbigmushroom.generate(par1World, par2Random, i1, k1, j1); + } + else + { + WorldGenAbstractTree worldgenabstracttree = this.func_150567_a(par2Random); + worldgenabstracttree.setScale(1.0D, 1.0D, 1.0D); + + if (worldgenabstracttree.generate(par1World, par2Random, i1, k1, j1)) + { + worldgenabstracttree.func_150524_b(par1World, par2Random, i1, k1, j1); + } + } + } + } + } + + k = par2Random.nextInt(5) - 3; + + if (this.field_150632_aF == 1) + { + k += 2; + } + + l = 0; + + while (l < k) + { + i1 = par2Random.nextInt(3); + + if (i1 == 0) + { + genTallFlowers.func_150548_a(1); + } + else if (i1 == 1) + { + genTallFlowers.func_150548_a(4); + } + else if (i1 == 2) + { + genTallFlowers.func_150548_a(5); + } + + j1 = 0; + + while (true) + { + if (j1 < 5) + { + k1 = par3 + par2Random.nextInt(16) + 8; + int i2 = par4 + par2Random.nextInt(16) + 8; + int l1 = par2Random.nextInt(par1World.getHeightValue(k1, i2) + 32); + + if (!genTallFlowers.generate(par1World, par2Random, k1, l1, i2)) + { + ++j1; + continue; + } + } + + ++l; + break; + } + } + + super.decorate(par1World, par2Random, par3, par4); + } + + @SideOnly(Side.CLIENT) + public int getBiomeGrassColor(int p_150558_1_, int p_150558_2_, int p_150558_3_) + { + int l = super.getBiomeGrassColor(p_150558_1_, p_150558_2_, p_150558_3_); + return this.field_150632_aF == 3 ? (l & 16711422) + 2634762 >> 1 : l; + } + + public BiomeGenBase createMutation() + { + if (this.biomeID == BiomeGenBase.forest.biomeID) + { + BiomeGenForest biomegenforest = new BiomeGenForest(this.biomeID + 128, 1); + biomegenforest.setHeight(new BiomeGenBase.Height(this.rootHeight, this.heightVariation + 0.2F)); + biomegenforest.setBiomeName("Flower Forest"); + biomegenforest.func_150557_a(6976549, true); + biomegenforest.func_76733_a(8233509); + return biomegenforest; + } + else + { + return this.biomeID != BiomeGenBase.birchForest.biomeID && this.biomeID != BiomeGenBase.birchForestHills.biomeID ? new BiomeGenMutated(this.biomeID + 128, this) + { + private static final String __OBFID = "CL_00000171"; + public void decorate(World world, Random random, int i, int j) + { + this.baseBiome.decorate(world, random, i, j); + } + }: new BiomeGenMutated(this.biomeID + 128, this) + { + private static final String __OBFID = "CL_00000172"; + public WorldGenAbstractTree func_150567_a(Random random) + { + return random.nextBoolean() ? BiomeGenForest.field_150629_aC : BiomeGenForest.field_150630_aD; + } + }; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/biome/BiomeGenHell.java b/src/main/java/net/minecraft/world/biome/BiomeGenHell.java new file mode 100644 index 0000000..1f6f679 --- /dev/null +++ b/src/main/java/net/minecraft/world/biome/BiomeGenHell.java @@ -0,0 +1,22 @@ +package net.minecraft.world.biome; + +import net.minecraft.entity.monster.EntityGhast; +import net.minecraft.entity.monster.EntityMagmaCube; +import net.minecraft.entity.monster.EntityPigZombie; + +public class BiomeGenHell extends BiomeGenBase +{ + private static final String __OBFID = "CL_00000173"; + + public BiomeGenHell(int par1) + { + super(par1); + this.spawnableMonsterList.clear(); + this.spawnableCreatureList.clear(); + this.spawnableWaterCreatureList.clear(); + this.spawnableCaveCreatureList.clear(); + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityGhast.class, 50, 4, 4)); + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityPigZombie.class, 100, 4, 4)); + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityMagmaCube.class, 1, 4, 4)); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/biome/BiomeGenHills.java b/src/main/java/net/minecraft/world/biome/BiomeGenHills.java new file mode 100644 index 0000000..8e62df6 --- /dev/null +++ b/src/main/java/net/minecraft/world/biome/BiomeGenHills.java @@ -0,0 +1,107 @@ +package net.minecraft.world.biome; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenAbstractTree; +import net.minecraft.world.gen.feature.WorldGenMinable; +import net.minecraft.world.gen.feature.WorldGenTaiga2; +import net.minecraft.world.gen.feature.WorldGenerator; + +public class BiomeGenHills extends BiomeGenBase +{ + private WorldGenerator theWorldGenerator; + private WorldGenTaiga2 field_150634_aD; + private int field_150635_aE; + private int field_150636_aF; + private int field_150637_aG; + private int field_150638_aH; + private static final String __OBFID = "CL_00000168"; + + public BiomeGenHills(int p_i45373_1_, boolean p_i45373_2_) + { + super(p_i45373_1_); + this.theWorldGenerator = new WorldGenMinable(Blocks.monster_egg, 8); + this.field_150634_aD = new WorldGenTaiga2(false); + this.field_150635_aE = 0; + this.field_150636_aF = 1; + this.field_150637_aG = 2; + this.field_150638_aH = this.field_150635_aE; + + if (p_i45373_2_) + { + this.theBiomeDecorator.treesPerChunk = 3; + this.field_150638_aH = this.field_150636_aF; + } + } + + public WorldGenAbstractTree func_150567_a(Random p_150567_1_) + { + return (WorldGenAbstractTree)(p_150567_1_.nextInt(3) > 0 ? this.field_150634_aD : super.func_150567_a(p_150567_1_)); + } + + public void decorate(World par1World, Random par2Random, int par3, int par4) + { + super.decorate(par1World, par2Random, par3, par4); + int k = 3 + par2Random.nextInt(6); + int l; + int i1; + int j1; + + for (l = 0; l < k; ++l) + { + i1 = par3 + par2Random.nextInt(16); + j1 = par2Random.nextInt(28) + 4; + int k1 = par4 + par2Random.nextInt(16); + + if (par1World.getBlock(i1, j1, k1) == Blocks.stone) + { + par1World.setBlock(i1, j1, k1, Blocks.emerald_ore, 0, 2); + } + } + + for (k = 0; k < 7; ++k) + { + l = par3 + par2Random.nextInt(16); + i1 = par2Random.nextInt(64); + j1 = par4 + par2Random.nextInt(16); + this.theWorldGenerator.generate(par1World, par2Random, l, i1, j1); + } + } + + public void genTerrainBlocks(World p_150573_1_, Random p_150573_2_, Block[] p_150573_3_, byte[] p_150573_4_, int p_150573_5_, int p_150573_6_, double p_150573_7_) + { + this.topBlock = Blocks.grass; + this.field_150604_aj = 0; + this.fillerBlock = Blocks.dirt; + + if ((p_150573_7_ < -1.0D || p_150573_7_ > 2.0D) && this.field_150638_aH == this.field_150637_aG) + { + this.topBlock = Blocks.gravel; + this.fillerBlock = Blocks.gravel; + } + else if (p_150573_7_ > 1.0D && this.field_150638_aH != this.field_150636_aF) + { + this.topBlock = Blocks.stone; + this.fillerBlock = Blocks.stone; + } + + this.genBiomeTerrain(p_150573_1_, p_150573_2_, p_150573_3_, p_150573_4_, p_150573_5_, p_150573_6_, p_150573_7_); + } + + public BiomeGenHills mutateHills(BiomeGenBase p_150633_1_) + { + this.field_150638_aH = this.field_150637_aG; + this.func_150557_a(p_150633_1_.color, true); + this.setBiomeName(p_150633_1_.biomeName + " M"); + this.setHeight(new BiomeGenBase.Height(p_150633_1_.rootHeight, p_150633_1_.heightVariation)); + this.setTemperatureRainfall(p_150633_1_.temperature, p_150633_1_.rainfall); + return this; + } + + public BiomeGenBase createMutation() + { + return (new BiomeGenHills(this.biomeID + 128, false)).mutateHills(this); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/biome/BiomeGenJungle.java b/src/main/java/net/minecraft/world/biome/BiomeGenJungle.java new file mode 100644 index 0000000..6f045a3 --- /dev/null +++ b/src/main/java/net/minecraft/world/biome/BiomeGenJungle.java @@ -0,0 +1,74 @@ +package net.minecraft.world.biome; + +import java.util.Random; +import net.minecraft.entity.passive.EntityChicken; +import net.minecraft.entity.passive.EntityOcelot; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenAbstractTree; +import net.minecraft.world.gen.feature.WorldGenMegaJungle; +import net.minecraft.world.gen.feature.WorldGenMelon; +import net.minecraft.world.gen.feature.WorldGenShrub; +import net.minecraft.world.gen.feature.WorldGenTallGrass; +import net.minecraft.world.gen.feature.WorldGenTrees; +import net.minecraft.world.gen.feature.WorldGenVines; +import net.minecraft.world.gen.feature.WorldGenerator; + +public class BiomeGenJungle extends BiomeGenBase +{ + private boolean field_150614_aC; + private static final String __OBFID = "CL_00000175"; + + public BiomeGenJungle(int p_i45379_1_, boolean p_i45379_2_) + { + super(p_i45379_1_); + this.field_150614_aC = p_i45379_2_; + + if (p_i45379_2_) + { + this.theBiomeDecorator.treesPerChunk = 2; + } + else + { + this.theBiomeDecorator.treesPerChunk = 50; + } + + this.theBiomeDecorator.grassPerChunk = 25; + this.theBiomeDecorator.flowersPerChunk = 4; + + if (!p_i45379_2_) + { + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntityOcelot.class, 2, 1, 1)); + } + + this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityChicken.class, 10, 4, 4)); + } + + public WorldGenAbstractTree func_150567_a(Random p_150567_1_) + { + return (WorldGenAbstractTree)(p_150567_1_.nextInt(10) == 0 ? this.worldGeneratorBigTree : (p_150567_1_.nextInt(2) == 0 ? new WorldGenShrub(3, 0) : (!this.field_150614_aC && p_150567_1_.nextInt(3) == 0 ? new WorldGenMegaJungle(false, 10, 20, 3, 3) : new WorldGenTrees(false, 4 + p_150567_1_.nextInt(7), 3, 3, true)))); + } + + public WorldGenerator getRandomWorldGenForGrass(Random par1Random) + { + return par1Random.nextInt(4) == 0 ? new WorldGenTallGrass(Blocks.tallgrass, 2) : new WorldGenTallGrass(Blocks.tallgrass, 1); + } + + public void decorate(World par1World, Random par2Random, int par3, int par4) + { + super.decorate(par1World, par2Random, par3, par4); + int k = par3 + par2Random.nextInt(16) + 8; + int l = par4 + par2Random.nextInt(16) + 8; + int i1 = par2Random.nextInt(par1World.getHeightValue(k, l) * 2); + (new WorldGenMelon()).generate(par1World, par2Random, k, i1, l); + WorldGenVines worldgenvines = new WorldGenVines(); + + for (l = 0; l < 50; ++l) + { + i1 = par3 + par2Random.nextInt(16) + 8; + short short1 = 128; + int j1 = par4 + par2Random.nextInt(16) + 8; + worldgenvines.generate(par1World, par2Random, i1, short1, j1); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/biome/BiomeGenMesa.java b/src/main/java/net/minecraft/world/biome/BiomeGenMesa.java new file mode 100644 index 0000000..8a9ba0e --- /dev/null +++ b/src/main/java/net/minecraft/world/biome/BiomeGenMesa.java @@ -0,0 +1,370 @@ +package net.minecraft.world.biome; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Arrays; +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraft.world.gen.NoiseGeneratorPerlin; +import net.minecraft.world.gen.feature.WorldGenAbstractTree; + +public class BiomeGenMesa extends BiomeGenBase +{ + private byte[] field_150621_aC; + private long field_150622_aD; + private NoiseGeneratorPerlin field_150623_aE; + private NoiseGeneratorPerlin field_150624_aF; + private NoiseGeneratorPerlin field_150625_aG; + private boolean field_150626_aH; + private boolean field_150620_aI; + private static final String __OBFID = "CL_00000176"; + + public BiomeGenMesa(int p_i45380_1_, boolean p_i45380_2_, boolean p_i45380_3_) + { + super(p_i45380_1_); + this.field_150626_aH = p_i45380_2_; + this.field_150620_aI = p_i45380_3_; + this.setDisableRain(); + this.setTemperatureRainfall(2.0F, 0.0F); + this.spawnableCreatureList.clear(); + this.topBlock = Blocks.sand; + this.field_150604_aj = 1; + this.fillerBlock = Blocks.stained_hardened_clay; + this.theBiomeDecorator.treesPerChunk = -999; + this.theBiomeDecorator.deadBushPerChunk = 20; + this.theBiomeDecorator.reedsPerChunk = 3; + this.theBiomeDecorator.cactiPerChunk = 5; + this.theBiomeDecorator.flowersPerChunk = 0; + this.spawnableCreatureList.clear(); + + if (p_i45380_3_) + { + this.theBiomeDecorator.treesPerChunk = 5; + } + } + + public WorldGenAbstractTree func_150567_a(Random p_150567_1_) + { + return this.worldGeneratorTrees; + } + + public void decorate(World par1World, Random par2Random, int par3, int par4) + { + super.decorate(par1World, par2Random, par3, par4); + } + + public void genTerrainBlocks(World p_150573_1_, Random p_150573_2_, Block[] p_150573_3_, byte[] p_150573_4_, int p_150573_5_, int p_150573_6_, double p_150573_7_) + { + if (this.field_150621_aC == null || this.field_150622_aD != p_150573_1_.getSeed()) + { + this.func_150619_a(p_150573_1_.getSeed()); + } + + if (this.field_150623_aE == null || this.field_150624_aF == null || this.field_150622_aD != p_150573_1_.getSeed()) + { + Random random1 = new Random(this.field_150622_aD); + this.field_150623_aE = new NoiseGeneratorPerlin(random1, 4); + this.field_150624_aF = new NoiseGeneratorPerlin(random1, 1); + } + + this.field_150622_aD = p_150573_1_.getSeed(); + double d5 = 0.0D; + int k; + int l; + + if (this.field_150626_aH) + { + k = (p_150573_5_ & -16) + (p_150573_6_ & 15); + l = (p_150573_6_ & -16) + (p_150573_5_ & 15); + double d1 = Math.min(Math.abs(p_150573_7_), this.field_150623_aE.func_151601_a((double)k * 0.25D, (double)l * 0.25D)); + + if (d1 > 0.0D) + { + double d2 = 0.001953125D; + double d3 = Math.abs(this.field_150624_aF.func_151601_a((double)k * d2, (double)l * d2)); + d5 = d1 * d1 * 2.5D; + double d4 = Math.ceil(d3 * 50.0D) + 14.0D; + + if (d5 > d4) + { + d5 = d4; + } + + d5 += 64.0D; + } + } + + k = p_150573_5_ & 15; + l = p_150573_6_ & 15; + boolean flag = true; + Block block = Blocks.stained_hardened_clay; + Block block2 = this.fillerBlock; + int i1 = (int)(p_150573_7_ / 3.0D + 3.0D + p_150573_2_.nextDouble() * 0.25D); + boolean flag1 = Math.cos(p_150573_7_ / 3.0D * Math.PI) > 0.0D; + int j1 = -1; + boolean flag2 = false; + int k1 = p_150573_3_.length / 256; + + for (int l1 = 255; l1 >= 0; --l1) + { + int i2 = (l * 16 + k) * k1 + l1; + + if ((p_150573_3_[i2] == null || p_150573_3_[i2].getMaterial() == Material.air) && l1 < (int)d5) + { + p_150573_3_[i2] = Blocks.stone; + } + + if (l1 <= 0 + p_150573_2_.nextInt(5)) + { + p_150573_3_[i2] = Blocks.bedrock; + } + else + { + Block block1 = p_150573_3_[i2]; + + if (block1 != null && block1.getMaterial() != Material.air) + { + if (block1 == Blocks.stone) + { + byte b0; + + if (j1 == -1) + { + flag2 = false; + + if (i1 <= 0) + { + block = null; + block2 = Blocks.stone; + } + else if (l1 >= 59 && l1 <= 64) + { + block = Blocks.stained_hardened_clay; + block2 = this.fillerBlock; + } + + if (l1 < 63 && (block == null || block.getMaterial() == Material.air)) + { + block = Blocks.water; + } + + j1 = i1 + Math.max(0, l1 - 63); + + if (l1 >= 62) + { + if (this.field_150620_aI && l1 > 86 + i1 * 2) + { + if (flag1) + { + p_150573_3_[i2] = Blocks.dirt; + p_150573_4_[i2] = 1; + } + else + { + p_150573_3_[i2] = Blocks.grass; + } + } + else if (l1 > 66 + i1) + { + b0 = 16; + + if (l1 >= 64 && l1 <= 127) + { + if (!flag1) + { + b0 = this.func_150618_d(p_150573_5_, l1, p_150573_6_); + } + } + else + { + b0 = 1; + } + + if (b0 < 16) + { + p_150573_3_[i2] = Blocks.stained_hardened_clay; + p_150573_4_[i2] = (byte)b0; + } + else + { + p_150573_3_[i2] = Blocks.hardened_clay; + } + } + else + { + p_150573_3_[i2] = this.topBlock; + p_150573_4_[i2] = (byte)this.field_150604_aj; + flag2 = true; + } + } + else + { + p_150573_3_[i2] = block2; + + if (block2 == Blocks.stained_hardened_clay) + { + p_150573_4_[i2] = 1; + } + } + } + else if (j1 > 0) + { + --j1; + + if (flag2) + { + p_150573_3_[i2] = Blocks.stained_hardened_clay; + p_150573_4_[i2] = 1; + } + else + { + b0 = this.func_150618_d(p_150573_5_, l1, p_150573_6_); + + if (b0 < 16) + { + p_150573_3_[i2] = Blocks.stained_hardened_clay; + p_150573_4_[i2] = b0; + } + else + { + p_150573_3_[i2] = Blocks.hardened_clay; + } + } + } + } + } + else + { + j1 = -1; + } + } + } + } + + public void func_150619_a(long p_150619_1_) + { + this.field_150621_aC = new byte[64]; + Arrays.fill(this.field_150621_aC, (byte)16); + Random random = new Random(p_150619_1_); + this.field_150625_aG = new NoiseGeneratorPerlin(random, 1); + int j; + + for (j = 0; j < 64; ++j) + { + j += random.nextInt(5) + 1; + + if (j < 64) + { + this.field_150621_aC[j] = 1; + } + } + + j = random.nextInt(4) + 2; + int k; + int l; + int i1; + int j1; + + for (k = 0; k < j; ++k) + { + l = random.nextInt(3) + 1; + i1 = random.nextInt(64); + + for (j1 = 0; i1 + j1 < 64 && j1 < l; ++j1) + { + this.field_150621_aC[i1 + j1] = 4; + } + } + + k = random.nextInt(4) + 2; + int k1; + + for (l = 0; l < k; ++l) + { + i1 = random.nextInt(3) + 2; + j1 = random.nextInt(64); + + for (k1 = 0; j1 + k1 < 64 && k1 < i1; ++k1) + { + this.field_150621_aC[j1 + k1] = 12; + } + } + + l = random.nextInt(4) + 2; + + for (i1 = 0; i1 < l; ++i1) + { + j1 = random.nextInt(3) + 1; + k1 = random.nextInt(64); + + for (int l1 = 0; k1 + l1 < 64 && l1 < j1; ++l1) + { + this.field_150621_aC[k1 + l1] = 14; + } + } + + i1 = random.nextInt(3) + 3; + j1 = 0; + + for (k1 = 0; k1 < i1; ++k1) + { + byte b0 = 1; + j1 += random.nextInt(16) + 4; + + for (int i2 = 0; j1 + i2 < 64 && i2 < b0; ++i2) + { + this.field_150621_aC[j1 + i2] = 0; + + if (j1 + i2 > 1 && random.nextBoolean()) + { + this.field_150621_aC[j1 + i2 - 1] = 8; + } + + if (j1 + i2 < 63 && random.nextBoolean()) + { + this.field_150621_aC[j1 + i2 + 1] = 8; + } + } + } + } + + @SideOnly(Side.CLIENT) + public int getBiomeFoliageColor(int p_150571_1_, int p_150571_2_, int p_150571_3_) + { + return 10387789; + } + + @SideOnly(Side.CLIENT) + public int getBiomeGrassColor(int p_150558_1_, int p_150558_2_, int p_150558_3_) + { + return 9470285; + } + + public byte func_150618_d(int p_150618_1_, int p_150618_2_, int p_150618_3_) + { + int l = (int)Math.round(this.field_150625_aG.func_151601_a((double)p_150618_1_ * 1.0D / 512.0D, (double)p_150618_1_ * 1.0D / 512.0D) * 2.0D); + return this.field_150621_aC[(p_150618_2_ + l + 64) % 64]; + } + + public BiomeGenBase createMutation() + { + boolean flag = this.biomeID == BiomeGenBase.mesa.biomeID; + BiomeGenMesa biomegenmesa = new BiomeGenMesa(this.biomeID + 128, flag, this.field_150620_aI); + + if (!flag) + { + biomegenmesa.setHeight(height_LowHills); + biomegenmesa.setBiomeName(this.biomeName + " M"); + } + else + { + biomegenmesa.setBiomeName(this.biomeName + " (Bryce)"); + } + + biomegenmesa.func_150557_a(this.color, true); + return biomegenmesa; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/biome/BiomeGenMushroomIsland.java b/src/main/java/net/minecraft/world/biome/BiomeGenMushroomIsland.java new file mode 100644 index 0000000..92743cc --- /dev/null +++ b/src/main/java/net/minecraft/world/biome/BiomeGenMushroomIsland.java @@ -0,0 +1,24 @@ +package net.minecraft.world.biome; + +import net.minecraft.entity.passive.EntityMooshroom; +import net.minecraft.init.Blocks; + +public class BiomeGenMushroomIsland extends BiomeGenBase +{ + private static final String __OBFID = "CL_00000177"; + + public BiomeGenMushroomIsland(int par1) + { + super(par1); + this.theBiomeDecorator.treesPerChunk = -100; + this.theBiomeDecorator.flowersPerChunk = -100; + this.theBiomeDecorator.grassPerChunk = -100; + this.theBiomeDecorator.mushroomsPerChunk = 1; + this.theBiomeDecorator.bigMushroomsPerChunk = 1; + this.topBlock = Blocks.mycelium; + this.spawnableMonsterList.clear(); + this.spawnableCreatureList.clear(); + this.spawnableWaterCreatureList.clear(); + this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityMooshroom.class, 8, 4, 8)); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/biome/BiomeGenMutated.java b/src/main/java/net/minecraft/world/biome/BiomeGenMutated.java new file mode 100644 index 0000000..72e50dc --- /dev/null +++ b/src/main/java/net/minecraft/world/biome/BiomeGenMutated.java @@ -0,0 +1,88 @@ +package net.minecraft.world.biome; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenAbstractTree; + +public class BiomeGenMutated extends BiomeGenBase +{ + protected BiomeGenBase baseBiome; + private static final String __OBFID = "CL_00000178"; + + public BiomeGenMutated(int p_i45381_1_, BiomeGenBase p_i45381_2_) + { + super(p_i45381_1_); + this.baseBiome = p_i45381_2_; + this.func_150557_a(p_i45381_2_.color, true); + this.biomeName = p_i45381_2_.biomeName + " M"; + this.topBlock = p_i45381_2_.topBlock; + this.fillerBlock = p_i45381_2_.fillerBlock; + this.field_76754_C = p_i45381_2_.field_76754_C; + this.rootHeight = p_i45381_2_.rootHeight; + this.heightVariation = p_i45381_2_.heightVariation; + this.temperature = p_i45381_2_.temperature; + this.rainfall = p_i45381_2_.rainfall; + this.waterColorMultiplier = p_i45381_2_.waterColorMultiplier; + this.enableSnow = p_i45381_2_.enableSnow; + this.enableRain = p_i45381_2_.enableRain; + this.spawnableCreatureList = new ArrayList(p_i45381_2_.spawnableCreatureList); + this.spawnableMonsterList = new ArrayList(p_i45381_2_.spawnableMonsterList); + this.spawnableCaveCreatureList = new ArrayList(p_i45381_2_.spawnableCaveCreatureList); + this.spawnableWaterCreatureList = new ArrayList(p_i45381_2_.spawnableWaterCreatureList); + this.temperature = p_i45381_2_.temperature; + this.rainfall = p_i45381_2_.rainfall; + this.rootHeight = p_i45381_2_.rootHeight + 0.1F; + this.heightVariation = p_i45381_2_.heightVariation + 0.2F; + } + + public void decorate(World par1World, Random par2Random, int par3, int par4) + { + this.baseBiome.theBiomeDecorator.decorateChunk(par1World, par2Random, this, par3, par4); + } + + public void genTerrainBlocks(World p_150573_1_, Random p_150573_2_, Block[] p_150573_3_, byte[] p_150573_4_, int p_150573_5_, int p_150573_6_, double p_150573_7_) + { + this.baseBiome.genTerrainBlocks(p_150573_1_, p_150573_2_, p_150573_3_, p_150573_4_, p_150573_5_, p_150573_6_, p_150573_7_); + } + + public float getSpawningChance() + { + return this.baseBiome.getSpawningChance(); + } + + public WorldGenAbstractTree func_150567_a(Random p_150567_1_) + { + return this.baseBiome.func_150567_a(p_150567_1_); + } + + @SideOnly(Side.CLIENT) + public int getBiomeFoliageColor(int p_150571_1_, int p_150571_2_, int p_150571_3_) + { + return this.baseBiome.getBiomeFoliageColor(p_150571_1_, p_150571_2_, p_150571_2_); + } + + @SideOnly(Side.CLIENT) + public int getBiomeGrassColor(int p_150558_1_, int p_150558_2_, int p_150558_3_) + { + return this.baseBiome.getBiomeGrassColor(p_150558_1_, p_150558_2_, p_150558_2_); + } + + public Class getBiomeClass() + { + return this.baseBiome.getBiomeClass(); + } + + public boolean isEqualTo(BiomeGenBase p_150569_1_) + { + return this.baseBiome.isEqualTo(p_150569_1_); + } + + public BiomeGenBase.TempCategory getTempCategory() + { + return this.baseBiome.getTempCategory(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/biome/BiomeGenOcean.java b/src/main/java/net/minecraft/world/biome/BiomeGenOcean.java new file mode 100644 index 0000000..7bf2a6b --- /dev/null +++ b/src/main/java/net/minecraft/world/biome/BiomeGenOcean.java @@ -0,0 +1,26 @@ +package net.minecraft.world.biome; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.world.World; + +public class BiomeGenOcean extends BiomeGenBase +{ + private static final String __OBFID = "CL_00000179"; + + public BiomeGenOcean(int par1) + { + super(par1); + this.spawnableCreatureList.clear(); + } + + public BiomeGenBase.TempCategory getTempCategory() + { + return BiomeGenBase.TempCategory.OCEAN; + } + + public void genTerrainBlocks(World p_150573_1_, Random p_150573_2_, Block[] p_150573_3_, byte[] p_150573_4_, int p_150573_5_, int p_150573_6_, double p_150573_7_) + { + super.genTerrainBlocks(p_150573_1_, p_150573_2_, p_150573_3_, p_150573_4_, p_150573_5_, p_150573_6_, p_150573_7_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/biome/BiomeGenPlains.java b/src/main/java/net/minecraft/world/biome/BiomeGenPlains.java new file mode 100644 index 0000000..81769f2 --- /dev/null +++ b/src/main/java/net/minecraft/world/biome/BiomeGenPlains.java @@ -0,0 +1,108 @@ +package net.minecraft.world.biome; + +import java.util.Random; +import net.minecraft.block.BlockFlower; +import net.minecraft.entity.passive.EntityHorse; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; + +public class BiomeGenPlains extends BiomeGenBase +{ + protected boolean field_150628_aC; + private static final String __OBFID = "CL_00000180"; + + public BiomeGenPlains(int par1) + { + super(par1); + this.setTemperatureRainfall(0.8F, 0.4F); + this.setHeight(height_LowPlains); + this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityHorse.class, 5, 2, 6)); + this.theBiomeDecorator.treesPerChunk = -999; + this.theBiomeDecorator.flowersPerChunk = 4; + this.theBiomeDecorator.grassPerChunk = 10; + this.flowers.clear(); + this.addFlower(Blocks.red_flower, 4, 3); + this.addFlower(Blocks.red_flower, 5, 3); + this.addFlower(Blocks.red_flower, 6, 3); + this.addFlower(Blocks.red_flower, 7, 3); + this.addFlower(Blocks.red_flower, 0, 20); + this.addFlower(Blocks.red_flower, 3, 20); + this.addFlower(Blocks.red_flower, 8, 20); + this.addFlower(Blocks.yellow_flower, 0, 30); + } + + public String func_150572_a(Random p_150572_1_, int p_150572_2_, int p_150572_3_, int p_150572_4_) + { + double d0 = plantNoise.func_151601_a((double)p_150572_2_ / 200.0D, (double)p_150572_4_ / 200.0D); + int l; + + if (d0 < -0.8D) + { + l = p_150572_1_.nextInt(4); + return BlockFlower.field_149859_a[4 + l]; + } + else if (p_150572_1_.nextInt(3) > 0) + { + l = p_150572_1_.nextInt(3); + return l == 0 ? BlockFlower.field_149859_a[0] : (l == 1 ? BlockFlower.field_149859_a[3] : BlockFlower.field_149859_a[8]); + } + else + { + return BlockFlower.field_149858_b[0]; + } + } + + public void decorate(World par1World, Random par2Random, int par3, int par4) + { + double d0 = plantNoise.func_151601_a((double)(par3 + 8) / 200.0D, (double)(par4 + 8) / 200.0D); + int k; + int l; + int i1; + int j1; + + if (d0 < -0.8D) + { + this.theBiomeDecorator.flowersPerChunk = 15; + this.theBiomeDecorator.grassPerChunk = 5; + } + else + { + this.theBiomeDecorator.flowersPerChunk = 4; + this.theBiomeDecorator.grassPerChunk = 10; + genTallFlowers.func_150548_a(2); + + for (k = 0; k < 7; ++k) + { + l = par3 + par2Random.nextInt(16) + 8; + i1 = par4 + par2Random.nextInt(16) + 8; + j1 = par2Random.nextInt(par1World.getHeightValue(l, i1) + 32); + genTallFlowers.generate(par1World, par2Random, l, j1, i1); + } + } + + if (this.field_150628_aC) + { + genTallFlowers.func_150548_a(0); + + for (k = 0; k < 10; ++k) + { + l = par3 + par2Random.nextInt(16) + 8; + i1 = par4 + par2Random.nextInt(16) + 8; + j1 = par2Random.nextInt(par1World.getHeightValue(l, i1) + 32); + genTallFlowers.generate(par1World, par2Random, l, j1, i1); + } + } + + super.decorate(par1World, par2Random, par3, par4); + } + + public BiomeGenBase createMutation() + { + BiomeGenPlains biomegenplains = new BiomeGenPlains(this.biomeID + 128); + biomegenplains.setBiomeName("Sunflower Plains"); + biomegenplains.field_150628_aC = true; + biomegenplains.setColor(9286496); + biomegenplains.field_150609_ah = 14273354; + return biomegenplains; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/biome/BiomeGenRiver.java b/src/main/java/net/minecraft/world/biome/BiomeGenRiver.java new file mode 100644 index 0000000..cb95726 --- /dev/null +++ b/src/main/java/net/minecraft/world/biome/BiomeGenRiver.java @@ -0,0 +1,12 @@ +package net.minecraft.world.biome; + +public class BiomeGenRiver extends BiomeGenBase +{ + private static final String __OBFID = "CL_00000181"; + + public BiomeGenRiver(int par1) + { + super(par1); + this.spawnableCreatureList.clear(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/biome/BiomeGenSavanna.java b/src/main/java/net/minecraft/world/biome/BiomeGenSavanna.java new file mode 100644 index 0000000..65eeb99 --- /dev/null +++ b/src/main/java/net/minecraft/world/biome/BiomeGenSavanna.java @@ -0,0 +1,91 @@ +package net.minecraft.world.biome; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.entity.passive.EntityHorse; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenAbstractTree; +import net.minecraft.world.gen.feature.WorldGenSavannaTree; + +public class BiomeGenSavanna extends BiomeGenBase +{ + private static final WorldGenSavannaTree field_150627_aC = new WorldGenSavannaTree(false); + private static final String __OBFID = "CL_00000182"; + + public BiomeGenSavanna(int p_i45383_1_) + { + super(p_i45383_1_); + this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityHorse.class, 1, 2, 6)); + this.theBiomeDecorator.treesPerChunk = 1; + this.theBiomeDecorator.flowersPerChunk = 4; + this.theBiomeDecorator.grassPerChunk = 20; + } + + public WorldGenAbstractTree func_150567_a(Random p_150567_1_) + { + return (WorldGenAbstractTree)(p_150567_1_.nextInt(5) > 0 ? field_150627_aC : this.worldGeneratorTrees); + } + + public BiomeGenBase createMutation() + { + BiomeGenSavanna.Mutated mutated = new BiomeGenSavanna.Mutated(this.biomeID + 128, this); + mutated.temperature = (this.temperature + 1.0F) * 0.5F; + mutated.rootHeight = this.rootHeight * 0.5F + 0.3F; + mutated.heightVariation = this.heightVariation * 0.5F + 1.2F; + return mutated; + } + + public void decorate(World par1World, Random par2Random, int par3, int par4) + { + genTallFlowers.func_150548_a(2); + + for (int k = 0; k < 7; ++k) + { + int l = par3 + par2Random.nextInt(16) + 8; + int i1 = par4 + par2Random.nextInt(16) + 8; + int j1 = par2Random.nextInt(par1World.getHeightValue(l, i1) + 32); + genTallFlowers.generate(par1World, par2Random, l, j1, i1); + } + + super.decorate(par1World, par2Random, par3, par4); + } + + public static class Mutated extends BiomeGenMutated + { + private static final String __OBFID = "CL_00000183"; + + public Mutated(int p_i45382_1_, BiomeGenBase p_i45382_2_) + { + super(p_i45382_1_, p_i45382_2_); + this.theBiomeDecorator.treesPerChunk = 2; + this.theBiomeDecorator.flowersPerChunk = 2; + this.theBiomeDecorator.grassPerChunk = 5; + } + + public void genTerrainBlocks(World p_150573_1_, Random p_150573_2_, Block[] p_150573_3_, byte[] p_150573_4_, int p_150573_5_, int p_150573_6_, double p_150573_7_) + { + this.topBlock = Blocks.grass; + this.field_150604_aj = 0; + this.fillerBlock = Blocks.dirt; + + if (p_150573_7_ > 1.75D) + { + this.topBlock = Blocks.stone; + this.fillerBlock = Blocks.stone; + } + else if (p_150573_7_ > -0.5D) + { + this.topBlock = Blocks.dirt; + this.field_150604_aj = 1; + } + + this.genBiomeTerrain(p_150573_1_, p_150573_2_, p_150573_3_, p_150573_4_, p_150573_5_, p_150573_6_, p_150573_7_); + } + + public void decorate(World par1World, Random par2Random, int par3, int par4) + { + this.theBiomeDecorator.decorateChunk(par1World, par2Random, this, par3, par4); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/biome/BiomeGenSnow.java b/src/main/java/net/minecraft/world/biome/BiomeGenSnow.java new file mode 100644 index 0000000..403c930 --- /dev/null +++ b/src/main/java/net/minecraft/world/biome/BiomeGenSnow.java @@ -0,0 +1,69 @@ +package net.minecraft.world.biome; + +import java.util.Random; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenAbstractTree; +import net.minecraft.world.gen.feature.WorldGenIcePath; +import net.minecraft.world.gen.feature.WorldGenIceSpike; +import net.minecraft.world.gen.feature.WorldGenTaiga2; + +public class BiomeGenSnow extends BiomeGenBase +{ + private boolean field_150615_aC; + private WorldGenIceSpike field_150616_aD = new WorldGenIceSpike(); + private WorldGenIcePath field_150617_aE = new WorldGenIcePath(4); + private static final String __OBFID = "CL_00000174"; + + public BiomeGenSnow(int p_i45378_1_, boolean p_i45378_2_) + { + super(p_i45378_1_); + this.field_150615_aC = p_i45378_2_; + + if (p_i45378_2_) + { + this.topBlock = Blocks.snow; + } + + this.spawnableCreatureList.clear(); + } + + public void decorate(World par1World, Random par2Random, int par3, int par4) + { + if (this.field_150615_aC) + { + int k; + int l; + int i1; + + for (k = 0; k < 3; ++k) + { + l = par3 + par2Random.nextInt(16) + 8; + i1 = par4 + par2Random.nextInt(16) + 8; + this.field_150616_aD.generate(par1World, par2Random, l, par1World.getHeightValue(l, i1), i1); + } + + for (k = 0; k < 2; ++k) + { + l = par3 + par2Random.nextInt(16) + 8; + i1 = par4 + par2Random.nextInt(16) + 8; + this.field_150617_aE.generate(par1World, par2Random, l, par1World.getHeightValue(l, i1), i1); + } + } + + super.decorate(par1World, par2Random, par3, par4); + } + + public WorldGenAbstractTree func_150567_a(Random p_150567_1_) + { + return new WorldGenTaiga2(false); + } + + public BiomeGenBase createMutation() + { + BiomeGenBase biomegenbase = (new BiomeGenSnow(this.biomeID + 128, true)).func_150557_a(13828095, true).setBiomeName(this.biomeName + " Spikes").setEnableSnow().setTemperatureRainfall(0.0F, 0.5F).setHeight(new BiomeGenBase.Height(this.rootHeight + 0.1F, this.heightVariation + 0.1F)); + biomegenbase.rootHeight = this.rootHeight + 0.3F; + biomegenbase.heightVariation = this.heightVariation + 0.4F; + return biomegenbase; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/biome/BiomeGenStoneBeach.java b/src/main/java/net/minecraft/world/biome/BiomeGenStoneBeach.java new file mode 100644 index 0000000..1a201af --- /dev/null +++ b/src/main/java/net/minecraft/world/biome/BiomeGenStoneBeach.java @@ -0,0 +1,20 @@ +package net.minecraft.world.biome; + +import net.minecraft.init.Blocks; + +public class BiomeGenStoneBeach extends BiomeGenBase +{ + private static final String __OBFID = "CL_00000184"; + + public BiomeGenStoneBeach(int p_i45384_1_) + { + super(p_i45384_1_); + this.spawnableCreatureList.clear(); + this.topBlock = Blocks.stone; + this.fillerBlock = Blocks.stone; + this.theBiomeDecorator.treesPerChunk = -999; + this.theBiomeDecorator.deadBushPerChunk = 0; + this.theBiomeDecorator.reedsPerChunk = 0; + this.theBiomeDecorator.cactiPerChunk = 0; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/biome/BiomeGenSwamp.java b/src/main/java/net/minecraft/world/biome/BiomeGenSwamp.java new file mode 100644 index 0000000..f6ee3c9 --- /dev/null +++ b/src/main/java/net/minecraft/world/biome/BiomeGenSwamp.java @@ -0,0 +1,93 @@ +package net.minecraft.world.biome; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.block.BlockFlower; +import net.minecraft.block.material.Material; +import net.minecraft.entity.monster.EntitySlime; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenAbstractTree; + +public class BiomeGenSwamp extends BiomeGenBase +{ + private static final String __OBFID = "CL_00000185"; + + protected BiomeGenSwamp(int par1) + { + super(par1); + this.theBiomeDecorator.treesPerChunk = 2; + this.theBiomeDecorator.flowersPerChunk = 1; + this.theBiomeDecorator.deadBushPerChunk = 1; + this.theBiomeDecorator.mushroomsPerChunk = 8; + this.theBiomeDecorator.reedsPerChunk = 10; + this.theBiomeDecorator.clayPerChunk = 1; + this.theBiomeDecorator.waterlilyPerChunk = 4; + this.theBiomeDecorator.sandPerChunk2 = 0; + this.theBiomeDecorator.sandPerChunk = 0; + this.theBiomeDecorator.grassPerChunk = 5; + this.waterColorMultiplier = 14745518; + this.spawnableMonsterList.add(new BiomeGenBase.SpawnListEntry(EntitySlime.class, 1, 1, 1)); + this.flowers.clear(); + this.addFlower(Blocks.red_mushroom_block, 0, 10); + } + + public WorldGenAbstractTree func_150567_a(Random p_150567_1_) + { + return this.worldGeneratorSwamp; + } + + public String func_150572_a(Random p_150572_1_, int p_150572_2_, int p_150572_3_, int p_150572_4_) + { + return BlockFlower.field_149859_a[1]; + } + + public void genTerrainBlocks(World p_150573_1_, Random p_150573_2_, Block[] p_150573_3_, byte[] p_150573_4_, int p_150573_5_, int p_150573_6_, double p_150573_7_) + { + double d1 = plantNoise.func_151601_a((double)p_150573_5_ * 0.25D, (double)p_150573_6_ * 0.25D); + + if (d1 > 0.0D) + { + int k = p_150573_5_ & 15; + int l = p_150573_6_ & 15; + int i1 = p_150573_3_.length / 256; + + for (int j1 = 255; j1 >= 0; --j1) + { + int k1 = (l * 16 + k) * i1 + j1; + + if (p_150573_3_[k1] == null || p_150573_3_[k1].getMaterial() != Material.air) + { + if (j1 == 62 && p_150573_3_[k1] != Blocks.water) + { + p_150573_3_[k1] = Blocks.water; + + if (d1 < 0.12D) + { + p_150573_3_[k1 + 1] = Blocks.waterlily; + } + } + + break; + } + } + } + + this.genBiomeTerrain(p_150573_1_, p_150573_2_, p_150573_3_, p_150573_4_, p_150573_5_, p_150573_6_, p_150573_7_); + } + + @SideOnly(Side.CLIENT) + public int getBiomeGrassColor(int p_150558_1_, int p_150558_2_, int p_150558_3_) + { + double d0 = plantNoise.func_151601_a((double)p_150558_1_ * 0.0225D, (double)p_150558_3_ * 0.0225D); + return d0 < -0.1D ? 5011004 : 6975545; + } + + @SideOnly(Side.CLIENT) + public int getBiomeFoliageColor(int p_150571_1_, int p_150571_2_, int p_150571_3_) + { + return 6975545; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/biome/BiomeGenTaiga.java b/src/main/java/net/minecraft/world/biome/BiomeGenTaiga.java new file mode 100644 index 0000000..6b06e4d --- /dev/null +++ b/src/main/java/net/minecraft/world/biome/BiomeGenTaiga.java @@ -0,0 +1,116 @@ +package net.minecraft.world.biome; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.entity.passive.EntityWolf; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenAbstractTree; +import net.minecraft.world.gen.feature.WorldGenBlockBlob; +import net.minecraft.world.gen.feature.WorldGenMegaPineTree; +import net.minecraft.world.gen.feature.WorldGenTaiga1; +import net.minecraft.world.gen.feature.WorldGenTaiga2; +import net.minecraft.world.gen.feature.WorldGenTallGrass; +import net.minecraft.world.gen.feature.WorldGenerator; + +public class BiomeGenTaiga extends BiomeGenBase +{ + private static final WorldGenTaiga1 field_150639_aC = new WorldGenTaiga1(); + private static final WorldGenTaiga2 field_150640_aD = new WorldGenTaiga2(false); + private static final WorldGenMegaPineTree field_150641_aE = new WorldGenMegaPineTree(false, false); + private static final WorldGenMegaPineTree field_150642_aF = new WorldGenMegaPineTree(false, true); + private static final WorldGenBlockBlob field_150643_aG = new WorldGenBlockBlob(Blocks.mossy_cobblestone, 0); + private int field_150644_aH; + private static final String __OBFID = "CL_00000186"; + + public BiomeGenTaiga(int p_i45385_1_, int p_i45385_2_) + { + super(p_i45385_1_); + this.field_150644_aH = p_i45385_2_; + this.spawnableCreatureList.add(new BiomeGenBase.SpawnListEntry(EntityWolf.class, 8, 4, 4)); + this.theBiomeDecorator.treesPerChunk = 10; + + if (p_i45385_2_ != 1 && p_i45385_2_ != 2) + { + this.theBiomeDecorator.grassPerChunk = 1; + this.theBiomeDecorator.mushroomsPerChunk = 1; + } + else + { + this.theBiomeDecorator.grassPerChunk = 7; + this.theBiomeDecorator.deadBushPerChunk = 1; + this.theBiomeDecorator.mushroomsPerChunk = 3; + } + } + + public WorldGenAbstractTree func_150567_a(Random p_150567_1_) + { + return (WorldGenAbstractTree)((this.field_150644_aH == 1 || this.field_150644_aH == 2) && p_150567_1_.nextInt(3) == 0 ? (this.field_150644_aH != 2 && p_150567_1_.nextInt(13) != 0 ? field_150641_aE : field_150642_aF) : (p_150567_1_.nextInt(3) == 0 ? field_150639_aC : field_150640_aD)); + } + + public WorldGenerator getRandomWorldGenForGrass(Random par1Random) + { + return par1Random.nextInt(5) > 0 ? new WorldGenTallGrass(Blocks.tallgrass, 2) : new WorldGenTallGrass(Blocks.tallgrass, 1); + } + + public void decorate(World par1World, Random par2Random, int par3, int par4) + { + int k; + int l; + int i1; + int j1; + + if (this.field_150644_aH == 1 || this.field_150644_aH == 2) + { + k = par2Random.nextInt(3); + + for (l = 0; l < k; ++l) + { + i1 = par3 + par2Random.nextInt(16) + 8; + j1 = par4 + par2Random.nextInt(16) + 8; + int k1 = par1World.getHeightValue(i1, j1); + field_150643_aG.generate(par1World, par2Random, i1, k1, j1); + } + } + + genTallFlowers.func_150548_a(3); + + for (k = 0; k < 7; ++k) + { + l = par3 + par2Random.nextInt(16) + 8; + i1 = par4 + par2Random.nextInt(16) + 8; + j1 = par2Random.nextInt(par1World.getHeightValue(l, i1) + 32); + genTallFlowers.generate(par1World, par2Random, l, j1, i1); + } + + super.decorate(par1World, par2Random, par3, par4); + } + + public void genTerrainBlocks(World p_150573_1_, Random p_150573_2_, Block[] p_150573_3_, byte[] p_150573_4_, int p_150573_5_, int p_150573_6_, double p_150573_7_) + { + if (this.field_150644_aH == 1 || this.field_150644_aH == 2) + { + this.topBlock = Blocks.grass; + this.field_150604_aj = 0; + this.fillerBlock = Blocks.dirt; + + if (p_150573_7_ > 1.75D) + { + this.topBlock = Blocks.dirt; + this.field_150604_aj = 1; + } + else if (p_150573_7_ > -0.95D) + { + this.topBlock = Blocks.dirt; + this.field_150604_aj = 2; + } + } + + this.genBiomeTerrain(p_150573_1_, p_150573_2_, p_150573_3_, p_150573_4_, p_150573_5_, p_150573_6_, p_150573_7_); + } + + public BiomeGenBase createMutation() + { + return this.biomeID == BiomeGenBase.megaTaiga.biomeID ? (new BiomeGenTaiga(this.biomeID + 128, 2)).func_150557_a(5858897, true).setBiomeName("Mega Spruce Taiga").func_76733_a(5159473).setTemperatureRainfall(0.25F, 0.8F).setHeight(new BiomeGenBase.Height(this.rootHeight, this.heightVariation)) : super.createMutation(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/biome/WorldChunkManager.java b/src/main/java/net/minecraft/world/biome/WorldChunkManager.java new file mode 100644 index 0000000..368c266 --- /dev/null +++ b/src/main/java/net/minecraft/world/biome/WorldChunkManager.java @@ -0,0 +1,252 @@ +package net.minecraft.world.biome; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Random; +import net.minecraft.crash.CrashReport; +import net.minecraft.crash.CrashReportCategory; +import net.minecraft.util.ReportedException; +import net.minecraft.world.ChunkPosition; +import net.minecraft.world.World; +import net.minecraft.world.WorldType; +import net.minecraft.world.gen.layer.GenLayer; +import net.minecraft.world.gen.layer.IntCache; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.terraingen.WorldTypeEvent; +import static net.minecraft.world.biome.BiomeGenBase.*; + +public class WorldChunkManager +{ + public static ArrayList allowedBiomes = new ArrayList(Arrays.asList(forest, plains, taiga, taigaHills, forestHills, jungle, jungleHills)); + private GenLayer genBiomes; + private GenLayer biomeIndexLayer; + private BiomeCache biomeCache; + private List biomesToSpawnIn; + private static final String __OBFID = "CL_00000166"; + + protected WorldChunkManager() + { + this.biomeCache = new BiomeCache(this); + this.biomesToSpawnIn = new ArrayList(); + this.biomesToSpawnIn.addAll(allowedBiomes); + } + + public WorldChunkManager(long par1, WorldType par3WorldType) + { + this(); + GenLayer[] agenlayer = GenLayer.initializeAllBiomeGenerators(par1, par3WorldType); + agenlayer = getModdedBiomeGenerators(par3WorldType, par1, agenlayer); + this.genBiomes = agenlayer[0]; + this.biomeIndexLayer = agenlayer[1]; + } + + public WorldChunkManager(World par1World) + { + this(par1World.getSeed(), par1World.getWorldInfo().getTerrainType()); + } + + public List getBiomesToSpawnIn() + { + return this.biomesToSpawnIn; + } + + public BiomeGenBase getBiomeGenAt(int par1, int par2) + { + return this.biomeCache.getBiomeGenAt(par1, par2); + } + + public float[] getRainfall(float[] par1ArrayOfFloat, int par2, int par3, int par4, int par5) + { + IntCache.resetIntCache(); + + if (par1ArrayOfFloat == null || par1ArrayOfFloat.length < par4 * par5) + { + par1ArrayOfFloat = new float[par4 * par5]; + } + + int[] aint = this.biomeIndexLayer.getInts(par2, par3, par4, par5); + + for (int i1 = 0; i1 < par4 * par5; ++i1) + { + try + { + float f = (float)BiomeGenBase.getBiome(aint[i1]).getIntRainfall() / 65536.0F; + + if (f > 1.0F) + { + f = 1.0F; + } + + par1ArrayOfFloat[i1] = f; + } + catch (Throwable throwable) + { + CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Invalid Biome id"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("DownfallBlock"); + crashreportcategory.addCrashSection("biome id", Integer.valueOf(i1)); + crashreportcategory.addCrashSection("downfalls[] size", Integer.valueOf(par1ArrayOfFloat.length)); + crashreportcategory.addCrashSection("x", Integer.valueOf(par2)); + crashreportcategory.addCrashSection("z", Integer.valueOf(par3)); + crashreportcategory.addCrashSection("w", Integer.valueOf(par4)); + crashreportcategory.addCrashSection("h", Integer.valueOf(par5)); + throw new ReportedException(crashreport); + } + } + + return par1ArrayOfFloat; + } + + @SideOnly(Side.CLIENT) + public float getTemperatureAtHeight(float par1, int par2) + { + return par1; + } + + public BiomeGenBase[] getBiomesForGeneration(BiomeGenBase[] par1ArrayOfBiomeGenBase, int par2, int par3, int par4, int par5) + { + IntCache.resetIntCache(); + + if (par1ArrayOfBiomeGenBase == null || par1ArrayOfBiomeGenBase.length < par4 * par5) + { + par1ArrayOfBiomeGenBase = new BiomeGenBase[par4 * par5]; + } + + int[] aint = this.genBiomes.getInts(par2, par3, par4, par5); + + try + { + for (int i1 = 0; i1 < par4 * par5; ++i1) + { + par1ArrayOfBiomeGenBase[i1] = BiomeGenBase.getBiome(aint[i1]); + } + + return par1ArrayOfBiomeGenBase; + } + catch (Throwable throwable) + { + CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Invalid Biome id"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("RawBiomeBlock"); + crashreportcategory.addCrashSection("biomes[] size", Integer.valueOf(par1ArrayOfBiomeGenBase.length)); + crashreportcategory.addCrashSection("x", Integer.valueOf(par2)); + crashreportcategory.addCrashSection("z", Integer.valueOf(par3)); + crashreportcategory.addCrashSection("w", Integer.valueOf(par4)); + crashreportcategory.addCrashSection("h", Integer.valueOf(par5)); + throw new ReportedException(crashreport); + } + } + + public BiomeGenBase[] loadBlockGeneratorData(BiomeGenBase[] par1ArrayOfBiomeGenBase, int par2, int par3, int par4, int par5) + { + return this.getBiomeGenAt(par1ArrayOfBiomeGenBase, par2, par3, par4, par5, true); + } + + public BiomeGenBase[] getBiomeGenAt(BiomeGenBase[] par1ArrayOfBiomeGenBase, int par2, int par3, int par4, int par5, boolean par6) + { + IntCache.resetIntCache(); + + if (par1ArrayOfBiomeGenBase == null || par1ArrayOfBiomeGenBase.length < par4 * par5) + { + par1ArrayOfBiomeGenBase = new BiomeGenBase[par4 * par5]; + } + + if (par6 && par4 == 16 && par5 == 16 && (par2 & 15) == 0 && (par3 & 15) == 0) + { + BiomeGenBase[] abiomegenbase1 = this.biomeCache.getCachedBiomes(par2, par3); + System.arraycopy(abiomegenbase1, 0, par1ArrayOfBiomeGenBase, 0, par4 * par5); + return par1ArrayOfBiomeGenBase; + } + else + { + int[] aint = this.biomeIndexLayer.getInts(par2, par3, par4, par5); + + for (int i1 = 0; i1 < par4 * par5; ++i1) + { + par1ArrayOfBiomeGenBase[i1] = BiomeGenBase.getBiome(aint[i1]); + } + + return par1ArrayOfBiomeGenBase; + } + } + + public boolean areBiomesViable(int par1, int par2, int par3, List par4List) + { + IntCache.resetIntCache(); + int l = par1 - par3 >> 2; + int i1 = par2 - par3 >> 2; + int j1 = par1 + par3 >> 2; + int k1 = par2 + par3 >> 2; + int l1 = j1 - l + 1; + int i2 = k1 - i1 + 1; + int[] aint = this.genBiomes.getInts(l, i1, l1, i2); + + try + { + for (int j2 = 0; j2 < l1 * i2; ++j2) + { + BiomeGenBase biomegenbase = BiomeGenBase.getBiome(aint[j2]); + + if (!par4List.contains(biomegenbase)) + { + return false; + } + } + + return true; + } + catch (Throwable throwable) + { + CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Invalid Biome id"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("Layer"); + crashreportcategory.addCrashSection("Layer", this.genBiomes.toString()); + crashreportcategory.addCrashSection("x", Integer.valueOf(par1)); + crashreportcategory.addCrashSection("z", Integer.valueOf(par2)); + crashreportcategory.addCrashSection("radius", Integer.valueOf(par3)); + crashreportcategory.addCrashSection("allowed", par4List); + throw new ReportedException(crashreport); + } + } + + public ChunkPosition findBiomePosition(int p_150795_1_, int p_150795_2_, int p_150795_3_, List p_150795_4_, Random p_150795_5_) + { + IntCache.resetIntCache(); + int l = p_150795_1_ - p_150795_3_ >> 2; + int i1 = p_150795_2_ - p_150795_3_ >> 2; + int j1 = p_150795_1_ + p_150795_3_ >> 2; + int k1 = p_150795_2_ + p_150795_3_ >> 2; + int l1 = j1 - l + 1; + int i2 = k1 - i1 + 1; + int[] aint = this.genBiomes.getInts(l, i1, l1, i2); + ChunkPosition chunkposition = null; + int j2 = 0; + + for (int k2 = 0; k2 < l1 * i2; ++k2) + { + int l2 = l + k2 % l1 << 2; + int i3 = i1 + k2 / l1 << 2; + BiomeGenBase biomegenbase = BiomeGenBase.getBiome(aint[k2]); + + if (p_150795_4_.contains(biomegenbase) && (chunkposition == null || p_150795_5_.nextInt(j2 + 1) == 0)) + { + chunkposition = new ChunkPosition(l2, 0, i3); + ++j2; + } + } + + return chunkposition; + } + + public void cleanupCache() + { + this.biomeCache.cleanupCache(); + } + + public GenLayer[] getModdedBiomeGenerators(WorldType worldType, long seed, GenLayer[] original) + { + WorldTypeEvent.InitBiomeGens event = new WorldTypeEvent.InitBiomeGens(worldType, seed, original); + MinecraftForge.TERRAIN_GEN_BUS.post(event); + return event.newBiomeGens; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/biome/WorldChunkManagerHell.java b/src/main/java/net/minecraft/world/biome/WorldChunkManagerHell.java new file mode 100644 index 0000000..8a170d8 --- /dev/null +++ b/src/main/java/net/minecraft/world/biome/WorldChunkManagerHell.java @@ -0,0 +1,72 @@ +package net.minecraft.world.biome; + +import java.util.Arrays; +import java.util.List; +import java.util.Random; +import net.minecraft.world.ChunkPosition; + +public class WorldChunkManagerHell extends WorldChunkManager +{ + private BiomeGenBase biomeGenerator; + private float rainfall; + private static final String __OBFID = "CL_00000169"; + + public WorldChunkManagerHell(BiomeGenBase p_i45374_1_, float p_i45374_2_) + { + this.biomeGenerator = p_i45374_1_; + this.rainfall = p_i45374_2_; + } + + public BiomeGenBase getBiomeGenAt(int par1, int par2) + { + return this.biomeGenerator; + } + + public BiomeGenBase[] getBiomesForGeneration(BiomeGenBase[] par1ArrayOfBiomeGenBase, int par2, int par3, int par4, int par5) + { + if (par1ArrayOfBiomeGenBase == null || par1ArrayOfBiomeGenBase.length < par4 * par5) + { + par1ArrayOfBiomeGenBase = new BiomeGenBase[par4 * par5]; + } + + Arrays.fill(par1ArrayOfBiomeGenBase, 0, par4 * par5, this.biomeGenerator); + return par1ArrayOfBiomeGenBase; + } + + public float[] getRainfall(float[] par1ArrayOfFloat, int par2, int par3, int par4, int par5) + { + if (par1ArrayOfFloat == null || par1ArrayOfFloat.length < par4 * par5) + { + par1ArrayOfFloat = new float[par4 * par5]; + } + + Arrays.fill(par1ArrayOfFloat, 0, par4 * par5, this.rainfall); + return par1ArrayOfFloat; + } + + public BiomeGenBase[] loadBlockGeneratorData(BiomeGenBase[] par1ArrayOfBiomeGenBase, int par2, int par3, int par4, int par5) + { + if (par1ArrayOfBiomeGenBase == null || par1ArrayOfBiomeGenBase.length < par4 * par5) + { + par1ArrayOfBiomeGenBase = new BiomeGenBase[par4 * par5]; + } + + Arrays.fill(par1ArrayOfBiomeGenBase, 0, par4 * par5, this.biomeGenerator); + return par1ArrayOfBiomeGenBase; + } + + public BiomeGenBase[] getBiomeGenAt(BiomeGenBase[] par1ArrayOfBiomeGenBase, int par2, int par3, int par4, int par5, boolean par6) + { + return this.loadBlockGeneratorData(par1ArrayOfBiomeGenBase, par2, par3, par4, par5); + } + + public ChunkPosition findBiomePosition(int p_150795_1_, int p_150795_2_, int p_150795_3_, List p_150795_4_, Random p_150795_5_) + { + return p_150795_4_.contains(this.biomeGenerator) ? new ChunkPosition(p_150795_1_ - p_150795_3_ + p_150795_5_.nextInt(p_150795_3_ * 2 + 1), 0, p_150795_2_ - p_150795_3_ + p_150795_5_.nextInt(p_150795_3_ * 2 + 1)) : null; + } + + public boolean areBiomesViable(int par1, int par2, int par3, List par4List) + { + return par4List.contains(this.biomeGenerator); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/chunk/Chunk.java b/src/main/java/net/minecraft/world/chunk/Chunk.java new file mode 100644 index 0000000..6c31be4 --- /dev/null +++ b/src/main/java/net/minecraft/world/chunk/Chunk.java @@ -0,0 +1,1517 @@ +package net.minecraft.world.chunk; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.concurrent.Callable; +import net.minecraft.block.Block; +import net.minecraft.block.ITileEntityProvider; +import net.minecraft.block.material.Material; +import net.minecraft.command.IEntitySelector; +import net.minecraft.crash.CrashReport; +import net.minecraft.crash.CrashReportCategory; +import net.minecraft.entity.Entity; +import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ReportedException; +import net.minecraft.world.ChunkCoordIntPair; +import net.minecraft.world.ChunkPosition; +import net.minecraft.world.EnumSkyBlock; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.biome.WorldChunkManager; +import net.minecraft.world.chunk.storage.ExtendedBlockStorage; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.EntityEvent; +import net.minecraftforge.event.world.ChunkEvent; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class Chunk +{ + private static final Logger logger = LogManager.getLogger(); + public static boolean isLit; + private ExtendedBlockStorage[] storageArrays; + private byte[] blockBiomeArray; + public int[] precipitationHeightMap; + public boolean[] updateSkylightColumns; + public boolean isChunkLoaded; + public World worldObj; + public int[] heightMap; + public final int xPosition; + public final int zPosition; + private boolean isGapLightingUpdated; + public Map chunkTileEntityMap; + public List[] entityLists; + public boolean isTerrainPopulated; + public boolean isLightPopulated; + public boolean field_150815_m; + public boolean isModified; + public boolean hasEntities; + public long lastSaveTime; + public boolean sendUpdates; + public int heightMapMinimum; + public long inhabitedTime; + private int queuedLightChecks; + private static final String __OBFID = "CL_00000373"; + + public Chunk(World par1World, int par2, int par3) + { + this.storageArrays = new ExtendedBlockStorage[16]; + this.blockBiomeArray = new byte[256]; + this.precipitationHeightMap = new int[256]; + this.updateSkylightColumns = new boolean[256]; + this.chunkTileEntityMap = new HashMap(); + this.queuedLightChecks = 4096; + this.entityLists = new List[16]; + this.worldObj = par1World; + this.xPosition = par2; + this.zPosition = par3; + this.heightMap = new int[256]; + + for (int k = 0; k < this.entityLists.length; ++k) + { + this.entityLists[k] = new ArrayList(); + } + + Arrays.fill(this.precipitationHeightMap, -999); + Arrays.fill(this.blockBiomeArray, (byte) - 1); + } + + public Chunk(World p_i45446_1_, Block[] p_i45446_2_, int p_i45446_3_, int p_i45446_4_) + { + this(p_i45446_1_, p_i45446_3_, p_i45446_4_); + int k = p_i45446_2_.length / 256; + boolean flag = !p_i45446_1_.provider.hasNoSky; + + for (int l = 0; l < 16; ++l) + { + for (int i1 = 0; i1 < 16; ++i1) + { + for (int j1 = 0; j1 < k; ++j1) + { + Block block = p_i45446_2_[l << 11 | i1 << 7 | j1]; + + if (block != null && block.getMaterial() != Material.air) + { + int k1 = j1 >> 4; + + if (this.storageArrays[k1] == null) + { + this.storageArrays[k1] = new ExtendedBlockStorage(k1 << 4, flag); + } + + this.storageArrays[k1].func_150818_a(l, j1 & 15, i1, block); + } + } + } + } + } + + public Chunk(World p_i45447_1_, Block[] p_i45447_2_, byte[] p_i45447_3_, int p_i45447_4_, int p_i45447_5_) + { + this(p_i45447_1_, p_i45447_4_, p_i45447_5_); + int k = p_i45447_2_.length / 256; + boolean flag = !p_i45447_1_.provider.hasNoSky; + + for (int l = 0; l < 16; ++l) + { + for (int i1 = 0; i1 < 16; ++i1) + { + for (int j1 = 0; j1 < k; ++j1) + { + int k1 = l * k * 16 | i1 * k | j1; + Block block = p_i45447_2_[k1]; + + if (block != null && block != Blocks.air) + { + int l1 = j1 >> 4; + + if (this.storageArrays[l1] == null) + { + this.storageArrays[l1] = new ExtendedBlockStorage(l1 << 4, flag); + } + + this.storageArrays[l1].func_150818_a(l, j1 & 15, i1, block); + this.storageArrays[l1].setExtBlockMetadata(l, j1 & 15, i1, p_i45447_3_[k1]); + } + } + } + } + } + + public boolean isAtLocation(int par1, int par2) + { + return par1 == this.xPosition && par2 == this.zPosition; + } + + public int getHeightValue(int par1, int par2) + { + return this.heightMap[par2 << 4 | par1]; + } + + public int getTopFilledSegment() + { + for (int i = this.storageArrays.length - 1; i >= 0; --i) + { + if (this.storageArrays[i] != null) + { + return this.storageArrays[i].getYLocation(); + } + } + + return 0; + } + + public ExtendedBlockStorage[] getBlockStorageArray() + { + return this.storageArrays; + } + + @SideOnly(Side.CLIENT) + public void generateHeightMap() + { + int i = this.getTopFilledSegment(); + this.heightMapMinimum = Integer.MAX_VALUE; + + for (int j = 0; j < 16; ++j) + { + int k = 0; + + while (k < 16) + { + this.precipitationHeightMap[j + (k << 4)] = -999; + int l = i + 16 - 1; + + while (true) + { + if (l > 0) + { + Block block = this.getBlock(j, l - 1, k); + + if (func_150808_b(j, l - 1, k) == 0) + { + --l; + continue; + } + + this.heightMap[k << 4 | j] = l; + + if (l < this.heightMapMinimum) + { + this.heightMapMinimum = l; + } + } + + ++k; + break; + } + } + } + + this.isModified = true; + } + + public void generateSkylightMap() + { + int i = this.getTopFilledSegment(); + this.heightMapMinimum = Integer.MAX_VALUE; + + for (int j = 0; j < 16; ++j) + { + int k = 0; + + while (k < 16) + { + this.precipitationHeightMap[j + (k << 4)] = -999; + int l = i + 16 - 1; + + while (true) + { + if (l > 0) + { + if (this.func_150808_b(j, l - 1, k) == 0) + { + --l; + continue; + } + + this.heightMap[k << 4 | j] = l; + + if (l < this.heightMapMinimum) + { + this.heightMapMinimum = l; + } + } + + if (!this.worldObj.provider.hasNoSky) + { + l = 15; + int i1 = i + 16 - 1; + + do + { + int j1 = this.func_150808_b(j, i1, k); + + if (j1 == 0 && l != 15) + { + j1 = 1; + } + + l -= j1; + + if (l > 0) + { + ExtendedBlockStorage extendedblockstorage = this.storageArrays[i1 >> 4]; + + if (extendedblockstorage != null) + { + extendedblockstorage.setExtSkylightValue(j, i1 & 15, k, l); + this.worldObj.func_147479_m((this.xPosition << 4) + j, i1, (this.zPosition << 4) + k); + } + } + + --i1; + } + while (i1 > 0 && l > 0); + } + + ++k; + break; + } + } + } + + this.isModified = true; + } + + private void propagateSkylightOcclusion(int par1, int par2) + { + this.updateSkylightColumns[par1 + par2 * 16] = true; + this.isGapLightingUpdated = true; + } + + private void recheckGaps(boolean p_150803_1_) + { + this.worldObj.theProfiler.startSection("recheckGaps"); + + if (this.worldObj.doChunksNearChunkExist(this.xPosition * 16 + 8, 0, this.zPosition * 16 + 8, 16)) + { + for (int i = 0; i < 16; ++i) + { + for (int j = 0; j < 16; ++j) + { + if (this.updateSkylightColumns[i + j * 16]) + { + this.updateSkylightColumns[i + j * 16] = false; + int k = this.getHeightValue(i, j); + int l = this.xPosition * 16 + i; + int i1 = this.zPosition * 16 + j; + int j1 = this.worldObj.getChunkHeightMapMinimum(l - 1, i1); + int k1 = this.worldObj.getChunkHeightMapMinimum(l + 1, i1); + int l1 = this.worldObj.getChunkHeightMapMinimum(l, i1 - 1); + int i2 = this.worldObj.getChunkHeightMapMinimum(l, i1 + 1); + + if (k1 < j1) + { + j1 = k1; + } + + if (l1 < j1) + { + j1 = l1; + } + + if (i2 < j1) + { + j1 = i2; + } + + this.checkSkylightNeighborHeight(l, i1, j1); + this.checkSkylightNeighborHeight(l - 1, i1, k); + this.checkSkylightNeighborHeight(l + 1, i1, k); + this.checkSkylightNeighborHeight(l, i1 - 1, k); + this.checkSkylightNeighborHeight(l, i1 + 1, k); + + if (p_150803_1_) + { + this.worldObj.theProfiler.endSection(); + return; + } + } + } + } + + this.isGapLightingUpdated = false; + } + + this.worldObj.theProfiler.endSection(); + } + + private void checkSkylightNeighborHeight(int par1, int par2, int par3) + { + int l = this.worldObj.getHeightValue(par1, par2); + + if (l > par3) + { + this.updateSkylightNeighborHeight(par1, par2, par3, l + 1); + } + else if (l < par3) + { + this.updateSkylightNeighborHeight(par1, par2, l, par3 + 1); + } + } + + private void updateSkylightNeighborHeight(int par1, int par2, int par3, int par4) + { + if (par4 > par3 && this.worldObj.doChunksNearChunkExist(par1, 0, par2, 16)) + { + for (int i1 = par3; i1 < par4; ++i1) + { + this.worldObj.updateLightByType(EnumSkyBlock.Sky, par1, i1, par2); + } + + this.isModified = true; + } + } + + private void relightBlock(int par1, int par2, int par3) + { + int l = this.heightMap[par3 << 4 | par1] & 255; + int i1 = l; + + if (par2 > l) + { + i1 = par2; + } + + while (i1 > 0 && this.func_150808_b(par1, i1 - 1, par3) == 0) + { + --i1; + } + + if (i1 != l) + { + this.worldObj.markBlocksDirtyVertical(par1 + this.xPosition * 16, par3 + this.zPosition * 16, i1, l); + this.heightMap[par3 << 4 | par1] = i1; + int j1 = this.xPosition * 16 + par1; + int k1 = this.zPosition * 16 + par3; + int l1; + int i2; + + if (!this.worldObj.provider.hasNoSky) + { + ExtendedBlockStorage extendedblockstorage; + + if (i1 < l) + { + for (l1 = i1; l1 < l; ++l1) + { + extendedblockstorage = this.storageArrays[l1 >> 4]; + + if (extendedblockstorage != null) + { + extendedblockstorage.setExtSkylightValue(par1, l1 & 15, par3, 15); + this.worldObj.func_147479_m((this.xPosition << 4) + par1, l1, (this.zPosition << 4) + par3); + } + } + } + else + { + for (l1 = l; l1 < i1; ++l1) + { + extendedblockstorage = this.storageArrays[l1 >> 4]; + + if (extendedblockstorage != null) + { + extendedblockstorage.setExtSkylightValue(par1, l1 & 15, par3, 0); + this.worldObj.func_147479_m((this.xPosition << 4) + par1, l1, (this.zPosition << 4) + par3); + } + } + } + + l1 = 15; + + while (i1 > 0 && l1 > 0) + { + --i1; + i2 = this.func_150808_b(par1, i1, par3); + + if (i2 == 0) + { + i2 = 1; + } + + l1 -= i2; + + if (l1 < 0) + { + l1 = 0; + } + + ExtendedBlockStorage extendedblockstorage1 = this.storageArrays[i1 >> 4]; + + if (extendedblockstorage1 != null) + { + extendedblockstorage1.setExtSkylightValue(par1, i1 & 15, par3, l1); + } + } + } + + l1 = this.heightMap[par3 << 4 | par1]; + i2 = l; + int j2 = l1; + + if (l1 < l) + { + i2 = l1; + j2 = l; + } + + if (l1 < this.heightMapMinimum) + { + this.heightMapMinimum = l1; + } + + if (!this.worldObj.provider.hasNoSky) + { + this.updateSkylightNeighborHeight(j1 - 1, k1, i2, j2); + this.updateSkylightNeighborHeight(j1 + 1, k1, i2, j2); + this.updateSkylightNeighborHeight(j1, k1 - 1, i2, j2); + this.updateSkylightNeighborHeight(j1, k1 + 1, i2, j2); + this.updateSkylightNeighborHeight(j1, k1, i2, j2); + } + + this.isModified = true; + } + } + + public int func_150808_b(int p_150808_1_, int p_150808_2_, int p_150808_3_) + { + int x = (xPosition << 4) + p_150808_1_; + int z = (zPosition << 4) + p_150808_3_; + return this.getBlock(p_150808_1_, p_150808_2_, p_150808_3_).getLightOpacity(worldObj, x, p_150808_2_, p_150808_3_); + } + + public Block getBlock(final int p_150810_1_, final int p_150810_2_, final int p_150810_3_) + { + Block block = Blocks.air; + + if (p_150810_2_ >> 4 < this.storageArrays.length) + { + ExtendedBlockStorage extendedblockstorage = this.storageArrays[p_150810_2_ >> 4]; + + if (extendedblockstorage != null) + { + try + { + block = extendedblockstorage.getBlockByExtId(p_150810_1_, p_150810_2_ & 15, p_150810_3_); + } + catch (Throwable throwable) + { + CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Getting block"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("Block being got"); + crashreportcategory.addCrashSectionCallable("Location", new Callable() + { + private static final String __OBFID = "CL_00000374"; + public String call() + { + return CrashReportCategory.getLocationInfo(p_150810_1_, p_150810_2_, p_150810_3_); + } + }); + throw new ReportedException(crashreport); + } + } + } + + return block; + } + + public int getBlockMetadata(int par1, int par2, int par3) + { + if (par2 >> 4 >= this.storageArrays.length) + { + return 0; + } + else + { + ExtendedBlockStorage extendedblockstorage = this.storageArrays[par2 >> 4]; + return extendedblockstorage != null ? extendedblockstorage.getExtBlockMetadata(par1, par2 & 15, par3) : 0; + } + } + + public boolean func_150807_a(int p_150807_1_, int p_150807_2_, int p_150807_3_, Block p_150807_4_, int p_150807_5_) + { + int i1 = p_150807_3_ << 4 | p_150807_1_; + + if (p_150807_2_ >= this.precipitationHeightMap[i1] - 1) + { + this.precipitationHeightMap[i1] = -999; + } + + int j1 = this.heightMap[i1]; + Block block1 = this.getBlock(p_150807_1_, p_150807_2_, p_150807_3_); + int k1 = this.getBlockMetadata(p_150807_1_, p_150807_2_, p_150807_3_); + + if (block1 == p_150807_4_ && k1 == p_150807_5_) + { + return false; + } + else + { + ExtendedBlockStorage extendedblockstorage = this.storageArrays[p_150807_2_ >> 4]; + boolean flag = false; + + if (extendedblockstorage == null) + { + if (p_150807_4_ == Blocks.air) + { + return false; + } + + extendedblockstorage = this.storageArrays[p_150807_2_ >> 4] = new ExtendedBlockStorage(p_150807_2_ >> 4 << 4, !this.worldObj.provider.hasNoSky); + flag = p_150807_2_ >= j1; + } + + int l1 = this.xPosition * 16 + p_150807_1_; + int i2 = this.zPosition * 16 + p_150807_3_; + + if (!this.worldObj.isRemote) + { + block1.onBlockPreDestroy(this.worldObj, l1, p_150807_2_, i2, k1); + } + + extendedblockstorage.func_150818_a(p_150807_1_, p_150807_2_ & 15, p_150807_3_, p_150807_4_); + extendedblockstorage.setExtBlockMetadata(p_150807_1_, p_150807_2_ & 15, p_150807_3_, p_150807_5_); // Move this above to prevent other mods/tile entites from creating invalid ones for the wrong metadata + + if (!this.worldObj.isRemote) + { + block1.breakBlock(this.worldObj, l1, p_150807_2_, i2, block1, k1); + } + else if (block1.hasTileEntity(k1)) + { + TileEntity te = this.getTileEntityUnsafe(p_150807_1_ & 0x0F, p_150807_2_, p_150807_3_ & 0x0F); + if (te != null && te.shouldRefresh(block1, p_150807_4_, k1, p_150807_5_, worldObj, l1, p_150807_2_, i2)) + { + this.worldObj.removeTileEntity(l1, p_150807_2_, i2); + } + } + + if (extendedblockstorage.getBlockByExtId(p_150807_1_, p_150807_2_ & 15, p_150807_3_) != p_150807_4_) + { + return false; + } + else + { + if (flag) + { + this.generateSkylightMap(); + } + else + { + int j2 = p_150807_4_.getLightOpacity(); + int k2 = block1.getLightOpacity(); + + if (j2 > 0) + { + if (p_150807_2_ >= j1) + { + this.relightBlock(p_150807_1_, p_150807_2_ + 1, p_150807_3_); + } + } + else if (p_150807_2_ == j1 - 1) + { + this.relightBlock(p_150807_1_, p_150807_2_, p_150807_3_); + } + + if (j2 != k2 && (j2 < k2 || this.getSavedLightValue(EnumSkyBlock.Sky, p_150807_1_, p_150807_2_, p_150807_3_) > 0 || this.getSavedLightValue(EnumSkyBlock.Block, p_150807_1_, p_150807_2_, p_150807_3_) > 0)) + { + this.propagateSkylightOcclusion(p_150807_1_, p_150807_3_); + } + } + + TileEntity tileentity; + + if (!this.worldObj.isRemote) + { + p_150807_4_.onBlockAdded(this.worldObj, l1, p_150807_2_, i2); + } + + if (p_150807_4_.hasTileEntity(p_150807_5_)) + { + tileentity = this.func_150806_e(p_150807_1_, p_150807_2_, p_150807_3_); + + if (tileentity != null) + { + tileentity.updateContainingBlockInfo(); + tileentity.blockMetadata = p_150807_5_; + } + } + + this.isModified = true; + return true; + } + } + } + + public boolean setBlockMetadata(int par1, int par2, int par3, int par4) + { + ExtendedBlockStorage extendedblockstorage = this.storageArrays[par2 >> 4]; + + if (extendedblockstorage == null) + { + return false; + } + else + { + int i1 = extendedblockstorage.getExtBlockMetadata(par1, par2 & 15, par3); + + if (i1 == par4) + { + return false; + } + else + { + this.isModified = true; + extendedblockstorage.setExtBlockMetadata(par1, par2 & 15, par3, par4); + + if (extendedblockstorage.getBlockByExtId(par1, par2 & 15, par3).hasTileEntity(par4)) + { + TileEntity tileentity = this.func_150806_e(par1, par2, par3); + + if (tileentity != null) + { + tileentity.updateContainingBlockInfo(); + tileentity.blockMetadata = par4; + } + } + + return true; + } + } + } + + public int getSavedLightValue(EnumSkyBlock par1EnumSkyBlock, int par2, int par3, int par4) + { + ExtendedBlockStorage extendedblockstorage = this.storageArrays[par3 >> 4]; + return extendedblockstorage == null ? (this.canBlockSeeTheSky(par2, par3, par4) ? par1EnumSkyBlock.defaultLightValue : 0) : (par1EnumSkyBlock == EnumSkyBlock.Sky ? (this.worldObj.provider.hasNoSky ? 0 : extendedblockstorage.getExtSkylightValue(par2, par3 & 15, par4)) : (par1EnumSkyBlock == EnumSkyBlock.Block ? extendedblockstorage.getExtBlocklightValue(par2, par3 & 15, par4) : par1EnumSkyBlock.defaultLightValue)); + } + + public void setLightValue(EnumSkyBlock par1EnumSkyBlock, int par2, int par3, int par4, int par5) + { + ExtendedBlockStorage extendedblockstorage = this.storageArrays[par3 >> 4]; + + if (extendedblockstorage == null) + { + extendedblockstorage = this.storageArrays[par3 >> 4] = new ExtendedBlockStorage(par3 >> 4 << 4, !this.worldObj.provider.hasNoSky); + this.generateSkylightMap(); + } + + this.isModified = true; + + if (par1EnumSkyBlock == EnumSkyBlock.Sky) + { + if (!this.worldObj.provider.hasNoSky) + { + extendedblockstorage.setExtSkylightValue(par2, par3 & 15, par4, par5); + } + } + else if (par1EnumSkyBlock == EnumSkyBlock.Block) + { + extendedblockstorage.setExtBlocklightValue(par2, par3 & 15, par4, par5); + } + } + + public int getBlockLightValue(int par1, int par2, int par3, int par4) + { + ExtendedBlockStorage extendedblockstorage = this.storageArrays[par2 >> 4]; + + if (extendedblockstorage == null) + { + return !this.worldObj.provider.hasNoSky && par4 < EnumSkyBlock.Sky.defaultLightValue ? EnumSkyBlock.Sky.defaultLightValue - par4 : 0; + } + else + { + int i1 = this.worldObj.provider.hasNoSky ? 0 : extendedblockstorage.getExtSkylightValue(par1, par2 & 15, par3); + + if (i1 > 0) + { + isLit = true; + } + + i1 -= par4; + int j1 = extendedblockstorage.getExtBlocklightValue(par1, par2 & 15, par3); + + if (j1 > i1) + { + i1 = j1; + } + + return i1; + } + } + + public void addEntity(Entity par1Entity) + { + this.hasEntities = true; + int i = MathHelper.floor_double(par1Entity.posX / 16.0D); + int j = MathHelper.floor_double(par1Entity.posZ / 16.0D); + + if (i != this.xPosition || j != this.zPosition) + { + logger.error("Wrong location! " + par1Entity); + Thread.dumpStack(); + } + + int k = MathHelper.floor_double(par1Entity.posY / 16.0D); + + if (k < 0) + { + k = 0; + } + + if (k >= this.entityLists.length) + { + k = this.entityLists.length - 1; + } + + MinecraftForge.EVENT_BUS.post(new EntityEvent.EnteringChunk(par1Entity, this.xPosition, this.zPosition, par1Entity.chunkCoordX, par1Entity.chunkCoordZ)); + par1Entity.addedToChunk = true; + par1Entity.chunkCoordX = this.xPosition; + par1Entity.chunkCoordY = k; + par1Entity.chunkCoordZ = this.zPosition; + this.entityLists[k].add(par1Entity); + } + + public void removeEntity(Entity par1Entity) + { + this.removeEntityAtIndex(par1Entity, par1Entity.chunkCoordY); + } + + public void removeEntityAtIndex(Entity par1Entity, int par2) + { + if (par2 < 0) + { + par2 = 0; + } + + if (par2 >= this.entityLists.length) + { + par2 = this.entityLists.length - 1; + } + + this.entityLists[par2].remove(par1Entity); + } + + public boolean canBlockSeeTheSky(int par1, int par2, int par3) + { + return par2 >= this.heightMap[par3 << 4 | par1]; + } + + public TileEntity func_150806_e(int p_150806_1_, int p_150806_2_, int p_150806_3_) + { + ChunkPosition chunkposition = new ChunkPosition(p_150806_1_, p_150806_2_, p_150806_3_); + TileEntity tileentity = (TileEntity)this.chunkTileEntityMap.get(chunkposition); + + if (tileentity != null && tileentity.isInvalid()) + { + chunkTileEntityMap.remove(chunkposition); + tileentity = null; + } + + if (tileentity == null) + { + Block block = this.getBlock(p_150806_1_, p_150806_2_, p_150806_3_); + int meta = this.getBlockMetadata(p_150806_1_, p_150806_2_, p_150806_3_); + + if (!block.hasTileEntity(meta)) + { + return null; + } + + tileentity = block.createTileEntity(worldObj, meta); + this.worldObj.setTileEntity(this.xPosition * 16 + p_150806_1_, p_150806_2_, this.zPosition * 16 + p_150806_3_, tileentity); + } + + return tileentity; + } + + public void addTileEntity(TileEntity p_150813_1_) + { + int i = p_150813_1_.xCoord - this.xPosition * 16; + int j = p_150813_1_.yCoord; + int k = p_150813_1_.zCoord - this.zPosition * 16; + this.func_150812_a(i, j, k, p_150813_1_); + + if (this.isChunkLoaded) + { + this.worldObj.addTileEntity(p_150813_1_); + } + } + + public void func_150812_a(int p_150812_1_, int p_150812_2_, int p_150812_3_, TileEntity p_150812_4_) + { + ChunkPosition chunkposition = new ChunkPosition(p_150812_1_, p_150812_2_, p_150812_3_); + p_150812_4_.setWorldObj(this.worldObj); + p_150812_4_.xCoord = this.xPosition * 16 + p_150812_1_; + p_150812_4_.yCoord = p_150812_2_; + p_150812_4_.zCoord = this.zPosition * 16 + p_150812_3_; + + int metadata = getBlockMetadata(p_150812_1_, p_150812_2_, p_150812_3_); + if (this.getBlock(p_150812_1_, p_150812_2_, p_150812_3_).hasTileEntity(metadata)) + { + if (this.chunkTileEntityMap.containsKey(chunkposition)) + { + ((TileEntity)this.chunkTileEntityMap.get(chunkposition)).invalidate(); + } + + p_150812_4_.validate(); + this.chunkTileEntityMap.put(chunkposition, p_150812_4_); + } + } + + public void removeTileEntity(int p_150805_1_, int p_150805_2_, int p_150805_3_) + { + ChunkPosition chunkposition = new ChunkPosition(p_150805_1_, p_150805_2_, p_150805_3_); + + if (this.isChunkLoaded) + { + TileEntity tileentity = (TileEntity)this.chunkTileEntityMap.remove(chunkposition); + + if (tileentity != null) + { + tileentity.invalidate(); + } + } + } + + public void onChunkLoad() + { + this.isChunkLoaded = true; + this.worldObj.func_147448_a(this.chunkTileEntityMap.values()); + + for (int i = 0; i < this.entityLists.length; ++i) + { + Iterator iterator = this.entityLists[i].iterator(); + + while (iterator.hasNext()) + { + Entity entity = (Entity)iterator.next(); + entity.onChunkLoad(); + } + + this.worldObj.addLoadedEntities(this.entityLists[i]); + } + MinecraftForge.EVENT_BUS.post(new ChunkEvent.Load(this)); + } + + public void onChunkUnload() + { + this.isChunkLoaded = false; + Iterator iterator = this.chunkTileEntityMap.values().iterator(); + + while (iterator.hasNext()) + { + TileEntity tileentity = (TileEntity)iterator.next(); + this.worldObj.func_147457_a(tileentity); + } + + for (int i = 0; i < this.entityLists.length; ++i) + { + this.worldObj.unloadEntities(this.entityLists[i]); + } + MinecraftForge.EVENT_BUS.post(new ChunkEvent.Unload(this)); + } + + public void setChunkModified() + { + this.isModified = true; + } + + public void getEntitiesWithinAABBForEntity(Entity par1Entity, AxisAlignedBB par2AxisAlignedBB, List par3List, IEntitySelector par4IEntitySelector) + { + int i = MathHelper.floor_double((par2AxisAlignedBB.minY - World.MAX_ENTITY_RADIUS) / 16.0D); + int j = MathHelper.floor_double((par2AxisAlignedBB.maxY + World.MAX_ENTITY_RADIUS) / 16.0D); + i = MathHelper.clamp_int(i, 0, this.entityLists.length - 1); + j = MathHelper.clamp_int(j, 0, this.entityLists.length - 1); + + for (int k = i; k <= j; ++k) + { + List list1 = this.entityLists[k]; + + for (int l = 0; l < list1.size(); ++l) + { + Entity entity1 = (Entity)list1.get(l); + + if (entity1 != par1Entity && entity1.boundingBox.intersectsWith(par2AxisAlignedBB) && (par4IEntitySelector == null || par4IEntitySelector.isEntityApplicable(entity1))) + { + par3List.add(entity1); + Entity[] aentity = entity1.getParts(); + + if (aentity != null) + { + for (int i1 = 0; i1 < aentity.length; ++i1) + { + entity1 = aentity[i1]; + + if (entity1 != par1Entity && entity1.boundingBox.intersectsWith(par2AxisAlignedBB) && (par4IEntitySelector == null || par4IEntitySelector.isEntityApplicable(entity1))) + { + par3List.add(entity1); + } + } + } + } + } + } + } + + public void getEntitiesOfTypeWithinAAAB(Class par1Class, AxisAlignedBB par2AxisAlignedBB, List par3List, IEntitySelector par4IEntitySelector) + { + int i = MathHelper.floor_double((par2AxisAlignedBB.minY - World.MAX_ENTITY_RADIUS) / 16.0D); + int j = MathHelper.floor_double((par2AxisAlignedBB.maxY + World.MAX_ENTITY_RADIUS) / 16.0D); + i = MathHelper.clamp_int(i, 0, this.entityLists.length - 1); + j = MathHelper.clamp_int(j, 0, this.entityLists.length - 1); + + for (int k = i; k <= j; ++k) + { + List list1 = this.entityLists[k]; + + for (int l = 0; l < list1.size(); ++l) + { + Entity entity = (Entity)list1.get(l); + + if (par1Class.isAssignableFrom(entity.getClass()) && entity.boundingBox.intersectsWith(par2AxisAlignedBB) && (par4IEntitySelector == null || par4IEntitySelector.isEntityApplicable(entity))) + { + par3List.add(entity); + } + } + } + } + + public boolean needsSaving(boolean par1) + { + if (par1) + { + if (this.hasEntities && this.worldObj.getTotalWorldTime() != this.lastSaveTime || this.isModified) + { + return true; + } + } + else if (this.hasEntities && this.worldObj.getTotalWorldTime() >= this.lastSaveTime + 600L) + { + return true; + } + + return this.isModified; + } + + public Random getRandomWithSeed(long par1) + { + return new Random(this.worldObj.getSeed() + (long)(this.xPosition * this.xPosition * 4987142) + (long)(this.xPosition * 5947611) + (long)(this.zPosition * this.zPosition) * 4392871L + (long)(this.zPosition * 389711) ^ par1); + } + + public boolean isEmpty() + { + return false; + } + + public void populateChunk(IChunkProvider par1IChunkProvider, IChunkProvider par2IChunkProvider, int par3, int par4) + { + if (!this.isTerrainPopulated && par1IChunkProvider.chunkExists(par3 + 1, par4 + 1) && par1IChunkProvider.chunkExists(par3, par4 + 1) && par1IChunkProvider.chunkExists(par3 + 1, par4)) + { + par1IChunkProvider.populate(par2IChunkProvider, par3, par4); + } + + if (par1IChunkProvider.chunkExists(par3 - 1, par4) && !par1IChunkProvider.provideChunk(par3 - 1, par4).isTerrainPopulated && par1IChunkProvider.chunkExists(par3 - 1, par4 + 1) && par1IChunkProvider.chunkExists(par3, par4 + 1) && par1IChunkProvider.chunkExists(par3 - 1, par4 + 1)) + { + par1IChunkProvider.populate(par2IChunkProvider, par3 - 1, par4); + } + + if (par1IChunkProvider.chunkExists(par3, par4 - 1) && !par1IChunkProvider.provideChunk(par3, par4 - 1).isTerrainPopulated && par1IChunkProvider.chunkExists(par3 + 1, par4 - 1) && par1IChunkProvider.chunkExists(par3 + 1, par4 - 1) && par1IChunkProvider.chunkExists(par3 + 1, par4)) + { + par1IChunkProvider.populate(par2IChunkProvider, par3, par4 - 1); + } + + if (par1IChunkProvider.chunkExists(par3 - 1, par4 - 1) && !par1IChunkProvider.provideChunk(par3 - 1, par4 - 1).isTerrainPopulated && par1IChunkProvider.chunkExists(par3, par4 - 1) && par1IChunkProvider.chunkExists(par3 - 1, par4)) + { + par1IChunkProvider.populate(par2IChunkProvider, par3 - 1, par4 - 1); + } + } + + public int getPrecipitationHeight(int par1, int par2) + { + int k = par1 | par2 << 4; + int l = this.precipitationHeightMap[k]; + + if (l == -999) + { + int i1 = this.getTopFilledSegment() + 15; + l = -1; + + while (i1 > 0 && l == -1) + { + Block block = this.getBlock(par1, i1, par2); + Material material = block.getMaterial(); + + if (!material.blocksMovement() && !material.isLiquid()) + { + --i1; + } + else + { + l = i1 + 1; + } + } + + this.precipitationHeightMap[k] = l; + } + + return l; + } + + public void func_150804_b(boolean p_150804_1_) + { + if (this.isGapLightingUpdated && !this.worldObj.provider.hasNoSky && !p_150804_1_) + { + this.recheckGaps(this.worldObj.isRemote); + } + + this.field_150815_m = true; + + if (!this.isLightPopulated && this.isTerrainPopulated) + { + this.func_150809_p(); + } + } + + public boolean func_150802_k() + { + return this.field_150815_m && this.isTerrainPopulated && this.isLightPopulated; + } + + public ChunkCoordIntPair getChunkCoordIntPair() + { + return new ChunkCoordIntPair(this.xPosition, this.zPosition); + } + + public boolean getAreLevelsEmpty(int par1, int par2) + { + if (par1 < 0) + { + par1 = 0; + } + + if (par2 >= 256) + { + par2 = 255; + } + + for (int k = par1; k <= par2; k += 16) + { + ExtendedBlockStorage extendedblockstorage = this.storageArrays[k >> 4]; + + if (extendedblockstorage != null && !extendedblockstorage.isEmpty()) + { + return false; + } + } + + return true; + } + + public void setStorageArrays(ExtendedBlockStorage[] par1ArrayOfExtendedBlockStorage) + { + this.storageArrays = par1ArrayOfExtendedBlockStorage; + } + + @SideOnly(Side.CLIENT) + public void fillChunk(byte[] par1ArrayOfByte, int par2, int par3, boolean par4) + { + Iterator iterator = chunkTileEntityMap.values().iterator(); + while(iterator.hasNext()) + { + TileEntity tileEntity = (TileEntity)iterator.next(); + tileEntity.updateContainingBlockInfo(); + tileEntity.getBlockMetadata(); + tileEntity.getBlockType(); + } + + int k = 0; + boolean flag1 = !this.worldObj.provider.hasNoSky; + int l; + + for (l = 0; l < this.storageArrays.length; ++l) + { + if ((par2 & 1 << l) != 0) + { + if (this.storageArrays[l] == null) + { + this.storageArrays[l] = new ExtendedBlockStorage(l << 4, flag1); + } + + byte[] abyte1 = this.storageArrays[l].getBlockLSBArray(); + System.arraycopy(par1ArrayOfByte, k, abyte1, 0, abyte1.length); + k += abyte1.length; + } + else if (par4 && this.storageArrays[l] != null) + { + this.storageArrays[l] = null; + } + } + + NibbleArray nibblearray; + + for (l = 0; l < this.storageArrays.length; ++l) + { + if ((par2 & 1 << l) != 0 && this.storageArrays[l] != null) + { + nibblearray = this.storageArrays[l].getMetadataArray(); + System.arraycopy(par1ArrayOfByte, k, nibblearray.data, 0, nibblearray.data.length); + k += nibblearray.data.length; + } + } + + for (l = 0; l < this.storageArrays.length; ++l) + { + if ((par2 & 1 << l) != 0 && this.storageArrays[l] != null) + { + nibblearray = this.storageArrays[l].getBlocklightArray(); + System.arraycopy(par1ArrayOfByte, k, nibblearray.data, 0, nibblearray.data.length); + k += nibblearray.data.length; + } + } + + if (flag1) + { + for (l = 0; l < this.storageArrays.length; ++l) + { + if ((par2 & 1 << l) != 0 && this.storageArrays[l] != null) + { + nibblearray = this.storageArrays[l].getSkylightArray(); + System.arraycopy(par1ArrayOfByte, k, nibblearray.data, 0, nibblearray.data.length); + k += nibblearray.data.length; + } + } + } + + for (l = 0; l < this.storageArrays.length; ++l) + { + if ((par3 & 1 << l) != 0) + { + if (this.storageArrays[l] == null) + { + k += 2048; + } + else + { + nibblearray = this.storageArrays[l].getBlockMSBArray(); + + if (nibblearray == null) + { + nibblearray = this.storageArrays[l].createBlockMSBArray(); + } + + System.arraycopy(par1ArrayOfByte, k, nibblearray.data, 0, nibblearray.data.length); + k += nibblearray.data.length; + } + } + else if (par4 && this.storageArrays[l] != null && this.storageArrays[l].getBlockMSBArray() != null) + { + this.storageArrays[l].clearMSBArray(); + } + } + + if (par4) + { + System.arraycopy(par1ArrayOfByte, k, this.blockBiomeArray, 0, this.blockBiomeArray.length); + int i1 = k + this.blockBiomeArray.length; + } + + for (l = 0; l < this.storageArrays.length; ++l) + { + if (this.storageArrays[l] != null && (par2 & 1 << l) != 0) + { + this.storageArrays[l].removeInvalidBlocks(); + } + } + + this.isLightPopulated = true; + this.isTerrainPopulated = true; + this.generateHeightMap(); + List invalidList = new ArrayList(); + iterator = this.chunkTileEntityMap.values().iterator(); + + while (iterator.hasNext()) + { + TileEntity tileentity = (TileEntity)iterator.next(); + int x = tileentity.xCoord & 15; + int y = tileentity.yCoord; + int z = tileentity.zCoord & 15; + Block block = tileentity.getBlockType(); + if (block != getBlock(x, y, z) || tileentity.blockMetadata != this.getBlockMetadata(x, y, z)) + { + invalidList.add(tileentity); + } + tileentity.updateContainingBlockInfo(); + } + + for (TileEntity te : invalidList) + { + te.invalidate(); + } + } + + public BiomeGenBase getBiomeGenForWorldCoords(int par1, int par2, WorldChunkManager par3WorldChunkManager) + { + int k = this.blockBiomeArray[par2 << 4 | par1] & 255; + + if (k == 255) + { + BiomeGenBase biomegenbase = par3WorldChunkManager.getBiomeGenAt((this.xPosition << 4) + par1, (this.zPosition << 4) + par2); + k = biomegenbase.biomeID; + this.blockBiomeArray[par2 << 4 | par1] = (byte)(k & 255); + } + + return BiomeGenBase.getBiome(k) == null ? BiomeGenBase.plains : BiomeGenBase.getBiome(k); + } + + public byte[] getBiomeArray() + { + return this.blockBiomeArray; + } + + public void setBiomeArray(byte[] par1ArrayOfByte) + { + this.blockBiomeArray = par1ArrayOfByte; + } + + public void resetRelightChecks() + { + this.queuedLightChecks = 0; + } + + public void enqueueRelightChecks() + { + for (int i = 0; i < 8; ++i) + { + if (this.queuedLightChecks >= 4096) + { + return; + } + + int j = this.queuedLightChecks % 16; + int k = this.queuedLightChecks / 16 % 16; + int l = this.queuedLightChecks / 256; + ++this.queuedLightChecks; + int i1 = (this.xPosition << 4) + k; + int j1 = (this.zPosition << 4) + l; + + for (int k1 = 0; k1 < 16; ++k1) + { + int l1 = (j << 4) + k1; + + if (this.storageArrays[j] == null && (k1 == 0 || k1 == 15 || k == 0 || k == 15 || l == 0 || l == 15) || this.storageArrays[j] != null && this.storageArrays[j].getBlockByExtId(k, k1, l).getMaterial() == Material.air) + { + if (this.worldObj.getBlock(i1, l1 - 1, j1).getLightValue() > 0) + { + this.worldObj.func_147451_t(i1, l1 - 1, j1); + } + + if (this.worldObj.getBlock(i1, l1 + 1, j1).getLightValue() > 0) + { + this.worldObj.func_147451_t(i1, l1 + 1, j1); + } + + if (this.worldObj.getBlock(i1 - 1, l1, j1).getLightValue() > 0) + { + this.worldObj.func_147451_t(i1 - 1, l1, j1); + } + + if (this.worldObj.getBlock(i1 + 1, l1, j1).getLightValue() > 0) + { + this.worldObj.func_147451_t(i1 + 1, l1, j1); + } + + if (this.worldObj.getBlock(i1, l1, j1 - 1).getLightValue() > 0) + { + this.worldObj.func_147451_t(i1, l1, j1 - 1); + } + + if (this.worldObj.getBlock(i1, l1, j1 + 1).getLightValue() > 0) + { + this.worldObj.func_147451_t(i1, l1, j1 + 1); + } + + this.worldObj.func_147451_t(i1, l1, j1); + } + } + } + } + + public void func_150809_p() + { + this.isTerrainPopulated = true; + this.isLightPopulated = true; + + if (!this.worldObj.provider.hasNoSky) + { + if (this.worldObj.checkChunksExist(this.xPosition * 16 - 1, 0, this.zPosition * 16 - 1, this.xPosition * 16 + 1, 63, this.zPosition * 16 + 1)) + { + for (int i = 0; i < 16; ++i) + { + for (int j = 0; j < 16; ++j) + { + if (!this.func_150811_f(i, j)) + { + this.isLightPopulated = false; + break; + } + } + } + + if (this.isLightPopulated) + { + Chunk chunk = this.worldObj.getChunkFromBlockCoords(this.xPosition * 16 - 1, this.zPosition * 16); + chunk.func_150801_a(3); + chunk = this.worldObj.getChunkFromBlockCoords(this.xPosition * 16 + 16, this.zPosition * 16); + chunk.func_150801_a(1); + chunk = this.worldObj.getChunkFromBlockCoords(this.xPosition * 16, this.zPosition * 16 - 1); + chunk.func_150801_a(0); + chunk = this.worldObj.getChunkFromBlockCoords(this.xPosition * 16, this.zPosition * 16 + 16); + chunk.func_150801_a(2); + } + } + else + { + this.isLightPopulated = false; + } + } + } + + private void func_150801_a(int p_150801_1_) + { + if (this.isTerrainPopulated) + { + int j; + + if (p_150801_1_ == 3) + { + for (j = 0; j < 16; ++j) + { + this.func_150811_f(15, j); + } + } + else if (p_150801_1_ == 1) + { + for (j = 0; j < 16; ++j) + { + this.func_150811_f(0, j); + } + } + else if (p_150801_1_ == 0) + { + for (j = 0; j < 16; ++j) + { + this.func_150811_f(j, 15); + } + } + else if (p_150801_1_ == 2) + { + for (j = 0; j < 16; ++j) + { + this.func_150811_f(j, 0); + } + } + } + } + + private boolean func_150811_f(int p_150811_1_, int p_150811_2_) + { + int k = this.getTopFilledSegment(); + boolean flag = false; + boolean flag1 = false; + int l; + + for (l = k + 16 - 1; l > 63 || l > 0 && !flag1; --l) + { + int i1 = this.func_150808_b(p_150811_1_, l, p_150811_2_); + + if (i1 == 255 && l < 63) + { + flag1 = true; + } + + if (!flag && i1 > 0) + { + flag = true; + } + else if (flag && i1 == 0 && !this.worldObj.func_147451_t(this.xPosition * 16 + p_150811_1_, l, this.zPosition * 16 + p_150811_2_)) + { + return false; + } + } + + for (; l > 0; --l) + { + if (this.getBlock(p_150811_1_, l, p_150811_2_).getLightValue() > 0) + { + this.worldObj.func_147451_t(this.xPosition * 16 + p_150811_1_, l, this.zPosition * 16 + p_150811_2_); + } + } + + return true; + } + + /** + * Retrieves the tile entity, WITHOUT creating it. + * Good for checking if it exists. + * + * @param x + * @param y + * @param z + * @return The tile entity at the specified location, if it exists and is valid. + */ + public TileEntity getTileEntityUnsafe(int x, int y, int z) + { + ChunkPosition chunkposition = new ChunkPosition(x, y, z); + TileEntity tileentity = (TileEntity)this.chunkTileEntityMap.get(chunkposition); + + if (tileentity != null && tileentity.isInvalid()) + { + chunkTileEntityMap.remove(chunkposition); + tileentity = null; + } + + return tileentity; + } + + /** + * Removes the tile entity at the specified position, only if it's + * marked as invalid. + * + * @param x + * @param y + * @param z + */ + public void removeInvalidTileEntity(int x, int y, int z) + { + ChunkPosition position = new ChunkPosition(x, y, z); + if (isChunkLoaded) + { + TileEntity entity = (TileEntity)chunkTileEntityMap.get(position); + if (entity != null && entity.isInvalid()) + { + chunkTileEntityMap.remove(position); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/chunk/EmptyChunk.java b/src/main/java/net/minecraft/world/chunk/EmptyChunk.java new file mode 100644 index 0000000..f391753 --- /dev/null +++ b/src/main/java/net/minecraft/world/chunk/EmptyChunk.java @@ -0,0 +1,128 @@ +package net.minecraft.world.chunk; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.command.IEntitySelector; +import net.minecraft.entity.Entity; +import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.EnumSkyBlock; +import net.minecraft.world.World; + +public class EmptyChunk extends Chunk +{ + private static final String __OBFID = "CL_00000372"; + + public EmptyChunk(World par1World, int par2, int par3) + { + super(par1World, par2, par3); + } + + public boolean isAtLocation(int par1, int par2) + { + return par1 == this.xPosition && par2 == this.zPosition; + } + + public int getHeightValue(int par1, int par2) + { + return 0; + } + + public void generateSkylightMap() {} + + @SideOnly(Side.CLIENT) + public void generateHeightMap() {} + + public Block getBlock(int p_150810_1_, int p_150810_2_, int p_150810_3_) + { + return Blocks.air; + } + + public int func_150808_b(int p_150808_1_, int p_150808_2_, int p_150808_3_) + { + return 255; + } + + public boolean func_150807_a(int p_150807_1_, int p_150807_2_, int p_150807_3_, Block p_150807_4_, int p_150807_5_) + { + return true; + } + + public int getBlockMetadata(int par1, int par2, int par3) + { + return 0; + } + + public boolean setBlockMetadata(int par1, int par2, int par3, int par4) + { + return false; + } + + public int getSavedLightValue(EnumSkyBlock par1EnumSkyBlock, int par2, int par3, int par4) + { + return 0; + } + + public void setLightValue(EnumSkyBlock par1EnumSkyBlock, int par2, int par3, int par4, int par5) {} + + public int getBlockLightValue(int par1, int par2, int par3, int par4) + { + return 0; + } + + public void addEntity(Entity par1Entity) {} + + public void removeEntity(Entity par1Entity) {} + + public void removeEntityAtIndex(Entity par1Entity, int par2) {} + + public boolean canBlockSeeTheSky(int par1, int par2, int par3) + { + return false; + } + + public TileEntity func_150806_e(int p_150806_1_, int p_150806_2_, int p_150806_3_) + { + return null; + } + + public void addTileEntity(TileEntity p_150813_1_) {} + + public void func_150812_a(int p_150812_1_, int p_150812_2_, int p_150812_3_, TileEntity p_150812_4_) {} + + public void removeTileEntity(int p_150805_1_, int p_150805_2_, int p_150805_3_) {} + + public void onChunkLoad() {} + + public void onChunkUnload() {} + + public void setChunkModified() {} + + public void getEntitiesWithinAABBForEntity(Entity par1Entity, AxisAlignedBB par2AxisAlignedBB, List par3List, IEntitySelector par4IEntitySelector) {} + + public void getEntitiesOfTypeWithinAAAB(Class par1Class, AxisAlignedBB par2AxisAlignedBB, List par3List, IEntitySelector par4IEntitySelector) {} + + public boolean needsSaving(boolean par1) + { + return false; + } + + public Random getRandomWithSeed(long par1) + { + return new Random(this.worldObj.getSeed() + (long)(this.xPosition * this.xPosition * 4987142) + (long)(this.xPosition * 5947611) + (long)(this.zPosition * this.zPosition) * 4392871L + (long)(this.zPosition * 389711) ^ par1); + } + + public boolean isEmpty() + { + return true; + } + + public boolean getAreLevelsEmpty(int par1, int par2) + { + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/chunk/IChunkProvider.java b/src/main/java/net/minecraft/world/chunk/IChunkProvider.java new file mode 100644 index 0000000..16ed19e --- /dev/null +++ b/src/main/java/net/minecraft/world/chunk/IChunkProvider.java @@ -0,0 +1,36 @@ +package net.minecraft.world.chunk; + +import java.util.List; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.util.IProgressUpdate; +import net.minecraft.world.ChunkPosition; +import net.minecraft.world.World; + +public interface IChunkProvider +{ + boolean chunkExists(int var1, int var2); + + Chunk provideChunk(int var1, int var2); + + Chunk loadChunk(int var1, int var2); + + void populate(IChunkProvider var1, int var2, int var3); + + boolean saveChunks(boolean var1, IProgressUpdate var2); + + boolean unloadQueuedChunks(); + + boolean canSave(); + + String makeString(); + + List getPossibleCreatures(EnumCreatureType var1, int var2, int var3, int var4); + + ChunkPosition func_147416_a(World var1, String var2, int var3, int var4, int var5); + + int getLoadedChunkCount(); + + void recreateStructures(int var1, int var2); + + void saveExtraData(); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/chunk/NibbleArray.java b/src/main/java/net/minecraft/world/chunk/NibbleArray.java new file mode 100644 index 0000000..0a193e6 --- /dev/null +++ b/src/main/java/net/minecraft/world/chunk/NibbleArray.java @@ -0,0 +1,47 @@ +package net.minecraft.world.chunk; + +public class NibbleArray +{ + public final byte[] data; + private final int depthBits; + private final int depthBitsPlusFour; + private static final String __OBFID = "CL_00000371"; + + public NibbleArray(int par1, int par2) + { + this.data = new byte[par1 >> 1]; + this.depthBits = par2; + this.depthBitsPlusFour = par2 + 4; + } + + public NibbleArray(byte[] par1ArrayOfByte, int par2) + { + this.data = par1ArrayOfByte; + this.depthBits = par2; + this.depthBitsPlusFour = par2 + 4; + } + + public int get(int par1, int par2, int par3) + { + int l = par2 << this.depthBitsPlusFour | par3 << this.depthBits | par1; + int i1 = l >> 1; + int j1 = l & 1; + return j1 == 0 ? this.data[i1] & 15 : this.data[i1] >> 4 & 15; + } + + public void set(int par1, int par2, int par3, int par4) + { + int i1 = par2 << this.depthBitsPlusFour | par3 << this.depthBits | par1; + int j1 = i1 >> 1; + int k1 = i1 & 1; + + if (k1 == 0) + { + this.data[j1] = (byte)(this.data[j1] & 240 | par4 & 15); + } + else + { + this.data[j1] = (byte)(this.data[j1] & 15 | (par4 & 15) << 4); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/chunk/storage/AnvilChunkLoader.java b/src/main/java/net/minecraft/world/chunk/storage/AnvilChunkLoader.java new file mode 100644 index 0000000..313988e --- /dev/null +++ b/src/main/java/net/minecraft/world/chunk/storage/AnvilChunkLoader.java @@ -0,0 +1,456 @@ +package net.minecraft.world.chunk.storage; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityList; +import net.minecraft.nbt.CompressedStreamTools; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.ChunkCoordIntPair; +import net.minecraft.world.MinecraftException; +import net.minecraft.world.NextTickListEntry; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.NibbleArray; +import net.minecraft.world.storage.IThreadedFileIO; +import net.minecraft.world.storage.ThreadedFileIOBase; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.world.ChunkDataEvent; + +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import cpw.mods.fml.common.FMLLog; + +public class AnvilChunkLoader implements IChunkLoader, IThreadedFileIO +{ + private static final Logger logger = LogManager.getLogger(); + private List chunksToRemove = new ArrayList(); + private Set pendingAnvilChunksCoordinates = new HashSet(); + private Object syncLockObject = new Object(); + public final File chunkSaveLocation; + private static final String __OBFID = "CL_00000384"; + + public AnvilChunkLoader(File par1File) + { + this.chunkSaveLocation = par1File; + } + + public Chunk loadChunk(World par1World, int par2, int par3) throws IOException + { + NBTTagCompound nbttagcompound = null; + ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(par2, par3); + Object object = this.syncLockObject; + + synchronized (this.syncLockObject) + { + if (this.pendingAnvilChunksCoordinates.contains(chunkcoordintpair)) + { + for (int k = 0; k < this.chunksToRemove.size(); ++k) + { + if (((AnvilChunkLoader.PendingChunk)this.chunksToRemove.get(k)).chunkCoordinate.equals(chunkcoordintpair)) + { + nbttagcompound = ((AnvilChunkLoader.PendingChunk)this.chunksToRemove.get(k)).nbtTags; + break; + } + } + } + } + + if (nbttagcompound == null) + { + DataInputStream datainputstream = RegionFileCache.getChunkInputStream(this.chunkSaveLocation, par2, par3); + + if (datainputstream == null) + { + return null; + } + + nbttagcompound = CompressedStreamTools.read(datainputstream); + } + + return this.checkedReadChunkFromNBT(par1World, par2, par3, nbttagcompound); + } + + protected Chunk checkedReadChunkFromNBT(World par1World, int par2, int par3, NBTTagCompound par4NBTTagCompound) + { + if (!par4NBTTagCompound.hasKey("Level", 10)) + { + logger.error("Chunk file at " + par2 + "," + par3 + " is missing level data, skipping"); + return null; + } + else if (!par4NBTTagCompound.getCompoundTag("Level").hasKey("Sections", 9)) + { + logger.error("Chunk file at " + par2 + "," + par3 + " is missing block data, skipping"); + return null; + } + else + { + Chunk chunk = this.readChunkFromNBT(par1World, par4NBTTagCompound.getCompoundTag("Level")); + + if (!chunk.isAtLocation(par2, par3)) + { + logger.error("Chunk file at " + par2 + "," + par3 + " is in the wrong location; relocating. (Expected " + par2 + ", " + par3 + ", got " + chunk.xPosition + ", " + chunk.zPosition + ")"); + par4NBTTagCompound.setInteger("xPos", par2); + par4NBTTagCompound.setInteger("zPos", par3); + chunk = this.readChunkFromNBT(par1World, par4NBTTagCompound.getCompoundTag("Level")); + } + + MinecraftForge.EVENT_BUS.post(new ChunkDataEvent.Load(chunk, par4NBTTagCompound)); + return chunk; + } + } + + public void saveChunk(World par1World, Chunk par2Chunk) throws MinecraftException, IOException + { + par1World.checkSessionLock(); + + try + { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + nbttagcompound.setTag("Level", nbttagcompound1); + this.writeChunkToNBT(par2Chunk, par1World, nbttagcompound1); + MinecraftForge.EVENT_BUS.post(new ChunkDataEvent.Save(par2Chunk, nbttagcompound)); + this.addChunkToPending(par2Chunk.getChunkCoordIntPair(), nbttagcompound); + } + catch (Exception exception) + { + exception.printStackTrace(); + } + } + + protected void addChunkToPending(ChunkCoordIntPair par1ChunkCoordIntPair, NBTTagCompound par2NBTTagCompound) + { + Object object = this.syncLockObject; + + synchronized (this.syncLockObject) + { + if (this.pendingAnvilChunksCoordinates.contains(par1ChunkCoordIntPair)) + { + for (int i = 0; i < this.chunksToRemove.size(); ++i) + { + if (((AnvilChunkLoader.PendingChunk)this.chunksToRemove.get(i)).chunkCoordinate.equals(par1ChunkCoordIntPair)) + { + this.chunksToRemove.set(i, new AnvilChunkLoader.PendingChunk(par1ChunkCoordIntPair, par2NBTTagCompound)); + return; + } + } + } + + this.chunksToRemove.add(new AnvilChunkLoader.PendingChunk(par1ChunkCoordIntPair, par2NBTTagCompound)); + this.pendingAnvilChunksCoordinates.add(par1ChunkCoordIntPair); + ThreadedFileIOBase.threadedIOInstance.queueIO(this); + } + } + + public boolean writeNextIO() + { + AnvilChunkLoader.PendingChunk pendingchunk = null; + Object object = this.syncLockObject; + + synchronized (this.syncLockObject) + { + if (this.chunksToRemove.isEmpty()) + { + return false; + } + + pendingchunk = (AnvilChunkLoader.PendingChunk)this.chunksToRemove.remove(0); + this.pendingAnvilChunksCoordinates.remove(pendingchunk.chunkCoordinate); + } + + if (pendingchunk != null) + { + try + { + this.writeChunkNBTTags(pendingchunk); + } + catch (Exception exception) + { + exception.printStackTrace(); + } + } + + return true; + } + + private void writeChunkNBTTags(AnvilChunkLoader.PendingChunk par1AnvilChunkLoaderPending) throws IOException + { + DataOutputStream dataoutputstream = RegionFileCache.getChunkOutputStream(this.chunkSaveLocation, par1AnvilChunkLoaderPending.chunkCoordinate.chunkXPos, par1AnvilChunkLoaderPending.chunkCoordinate.chunkZPos); + CompressedStreamTools.write(par1AnvilChunkLoaderPending.nbtTags, dataoutputstream); + dataoutputstream.close(); + } + + public void saveExtraChunkData(World par1World, Chunk par2Chunk) {} + + public void chunkTick() {} + + public void saveExtraData() + { + while (this.writeNextIO()) + { + ; + } + } + + private void writeChunkToNBT(Chunk par1Chunk, World par2World, NBTTagCompound par3NBTTagCompound) + { + par3NBTTagCompound.setByte("V", (byte)1); + par3NBTTagCompound.setInteger("xPos", par1Chunk.xPosition); + par3NBTTagCompound.setInteger("zPos", par1Chunk.zPosition); + par3NBTTagCompound.setLong("LastUpdate", par2World.getTotalWorldTime()); + par3NBTTagCompound.setIntArray("HeightMap", par1Chunk.heightMap); + par3NBTTagCompound.setBoolean("TerrainPopulated", par1Chunk.isTerrainPopulated); + par3NBTTagCompound.setBoolean("LightPopulated", par1Chunk.isLightPopulated); + par3NBTTagCompound.setLong("InhabitedTime", par1Chunk.inhabitedTime); + ExtendedBlockStorage[] aextendedblockstorage = par1Chunk.getBlockStorageArray(); + NBTTagList nbttaglist = new NBTTagList(); + boolean flag = !par2World.provider.hasNoSky; + ExtendedBlockStorage[] aextendedblockstorage1 = aextendedblockstorage; + int i = aextendedblockstorage.length; + NBTTagCompound nbttagcompound1; + + for (int j = 0; j < i; ++j) + { + ExtendedBlockStorage extendedblockstorage = aextendedblockstorage1[j]; + + if (extendedblockstorage != null) + { + nbttagcompound1 = new NBTTagCompound(); + nbttagcompound1.setByte("Y", (byte)(extendedblockstorage.getYLocation() >> 4 & 255)); + nbttagcompound1.setByteArray("Blocks", extendedblockstorage.getBlockLSBArray()); + + if (extendedblockstorage.getBlockMSBArray() != null) + { + nbttagcompound1.setByteArray("Add", extendedblockstorage.getBlockMSBArray().data); + } + + nbttagcompound1.setByteArray("Data", extendedblockstorage.getMetadataArray().data); + nbttagcompound1.setByteArray("BlockLight", extendedblockstorage.getBlocklightArray().data); + + if (flag) + { + nbttagcompound1.setByteArray("SkyLight", extendedblockstorage.getSkylightArray().data); + } + else + { + nbttagcompound1.setByteArray("SkyLight", new byte[extendedblockstorage.getBlocklightArray().data.length]); + } + + nbttaglist.appendTag(nbttagcompound1); + } + } + + par3NBTTagCompound.setTag("Sections", nbttaglist); + par3NBTTagCompound.setByteArray("Biomes", par1Chunk.getBiomeArray()); + par1Chunk.hasEntities = false; + NBTTagList nbttaglist2 = new NBTTagList(); + Iterator iterator1; + + for (i = 0; i < par1Chunk.entityLists.length; ++i) + { + iterator1 = par1Chunk.entityLists[i].iterator(); + + while (iterator1.hasNext()) + { + Entity entity = (Entity)iterator1.next(); + nbttagcompound1 = new NBTTagCompound(); + + try + { + if (entity.writeToNBTOptional(nbttagcompound1)) + { + par1Chunk.hasEntities = true; + nbttaglist2.appendTag(nbttagcompound1); + } + } + catch (Exception e) + { + FMLLog.log(Level.ERROR, e, + "An Entity type %s has thrown an exception trying to write state. It will not persist. Report this to the mod author", + entity.getClass().getName()); + } + } + } + + par3NBTTagCompound.setTag("Entities", nbttaglist2); + NBTTagList nbttaglist3 = new NBTTagList(); + iterator1 = par1Chunk.chunkTileEntityMap.values().iterator(); + + while (iterator1.hasNext()) + { + TileEntity tileentity = (TileEntity)iterator1.next(); + nbttagcompound1 = new NBTTagCompound(); + try { + tileentity.writeToNBT(nbttagcompound1); + nbttaglist3.appendTag(nbttagcompound1); + } + catch (Exception e) + { + FMLLog.log(Level.ERROR, e, + "A TileEntity type %s has throw an exception trying to write state. It will not persist. Report this to the mod author", + tileentity.getClass().getName()); + } + } + + par3NBTTagCompound.setTag("TileEntities", nbttaglist3); + List list = par2World.getPendingBlockUpdates(par1Chunk, false); + + if (list != null) + { + long k = par2World.getTotalWorldTime(); + NBTTagList nbttaglist1 = new NBTTagList(); + Iterator iterator = list.iterator(); + + while (iterator.hasNext()) + { + NextTickListEntry nextticklistentry = (NextTickListEntry)iterator.next(); + NBTTagCompound nbttagcompound2 = new NBTTagCompound(); + nbttagcompound2.setInteger("i", Block.getIdFromBlock(nextticklistentry.func_151351_a())); + nbttagcompound2.setInteger("x", nextticklistentry.xCoord); + nbttagcompound2.setInteger("y", nextticklistentry.yCoord); + nbttagcompound2.setInteger("z", nextticklistentry.zCoord); + nbttagcompound2.setInteger("t", (int)(nextticklistentry.scheduledTime - k)); + nbttagcompound2.setInteger("p", nextticklistentry.priority); + nbttaglist1.appendTag(nbttagcompound2); + } + + par3NBTTagCompound.setTag("TileTicks", nbttaglist1); + } + } + + private Chunk readChunkFromNBT(World par1World, NBTTagCompound par2NBTTagCompound) + { + int i = par2NBTTagCompound.getInteger("xPos"); + int j = par2NBTTagCompound.getInteger("zPos"); + Chunk chunk = new Chunk(par1World, i, j); + chunk.heightMap = par2NBTTagCompound.getIntArray("HeightMap"); + chunk.isTerrainPopulated = par2NBTTagCompound.getBoolean("TerrainPopulated"); + chunk.isLightPopulated = par2NBTTagCompound.getBoolean("LightPopulated"); + chunk.inhabitedTime = par2NBTTagCompound.getLong("InhabitedTime"); + NBTTagList nbttaglist = par2NBTTagCompound.getTagList("Sections", 10); + byte b0 = 16; + ExtendedBlockStorage[] aextendedblockstorage = new ExtendedBlockStorage[b0]; + boolean flag = !par1World.provider.hasNoSky; + + for (int k = 0; k < nbttaglist.tagCount(); ++k) + { + NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(k); + byte b1 = nbttagcompound1.getByte("Y"); + ExtendedBlockStorage extendedblockstorage = new ExtendedBlockStorage(b1 << 4, flag); + extendedblockstorage.setBlockLSBArray(nbttagcompound1.getByteArray("Blocks")); + + if (nbttagcompound1.hasKey("Add", 7)) + { + extendedblockstorage.setBlockMSBArray(new NibbleArray(nbttagcompound1.getByteArray("Add"), 4)); + } + + extendedblockstorage.setBlockMetadataArray(new NibbleArray(nbttagcompound1.getByteArray("Data"), 4)); + extendedblockstorage.setBlocklightArray(new NibbleArray(nbttagcompound1.getByteArray("BlockLight"), 4)); + + if (flag) + { + extendedblockstorage.setSkylightArray(new NibbleArray(nbttagcompound1.getByteArray("SkyLight"), 4)); + } + + extendedblockstorage.removeInvalidBlocks(); + aextendedblockstorage[b1] = extendedblockstorage; + } + + chunk.setStorageArrays(aextendedblockstorage); + + if (par2NBTTagCompound.hasKey("Biomes", 7)) + { + chunk.setBiomeArray(par2NBTTagCompound.getByteArray("Biomes")); + } + + NBTTagList nbttaglist1 = par2NBTTagCompound.getTagList("Entities", 10); + + if (nbttaglist1 != null) + { + for (int l = 0; l < nbttaglist1.tagCount(); ++l) + { + NBTTagCompound nbttagcompound3 = nbttaglist1.getCompoundTagAt(l); + Entity entity2 = EntityList.createEntityFromNBT(nbttagcompound3, par1World); + chunk.hasEntities = true; + + if (entity2 != null) + { + chunk.addEntity(entity2); + Entity entity = entity2; + + for (NBTTagCompound nbttagcompound2 = nbttagcompound3; nbttagcompound2.hasKey("Riding", 10); nbttagcompound2 = nbttagcompound2.getCompoundTag("Riding")) + { + Entity entity1 = EntityList.createEntityFromNBT(nbttagcompound2.getCompoundTag("Riding"), par1World); + + if (entity1 != null) + { + chunk.addEntity(entity1); + entity.mountEntity(entity1); + } + + entity = entity1; + } + } + } + } + + NBTTagList nbttaglist2 = par2NBTTagCompound.getTagList("TileEntities", 10); + + if (nbttaglist2 != null) + { + for (int i1 = 0; i1 < nbttaglist2.tagCount(); ++i1) + { + NBTTagCompound nbttagcompound4 = nbttaglist2.getCompoundTagAt(i1); + TileEntity tileentity = TileEntity.createAndLoadEntity(nbttagcompound4); + + if (tileentity != null) + { + chunk.addTileEntity(tileentity); + } + } + } + + if (par2NBTTagCompound.hasKey("TileTicks", 9)) + { + NBTTagList nbttaglist3 = par2NBTTagCompound.getTagList("TileTicks", 10); + + if (nbttaglist3 != null) + { + for (int j1 = 0; j1 < nbttaglist3.tagCount(); ++j1) + { + NBTTagCompound nbttagcompound5 = nbttaglist3.getCompoundTagAt(j1); + par1World.func_147446_b(nbttagcompound5.getInteger("x"), nbttagcompound5.getInteger("y"), nbttagcompound5.getInteger("z"), Block.getBlockById(nbttagcompound5.getInteger("i")), nbttagcompound5.getInteger("t"), nbttagcompound5.getInteger("p")); + } + } + } + + return chunk; + } + + static class PendingChunk + { + public final ChunkCoordIntPair chunkCoordinate; + public final NBTTagCompound nbtTags; + private static final String __OBFID = "CL_00000385"; + + public PendingChunk(ChunkCoordIntPair par1ChunkCoordIntPair, NBTTagCompound par2NBTTagCompound) + { + this.chunkCoordinate = par1ChunkCoordIntPair; + this.nbtTags = par2NBTTagCompound; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/chunk/storage/AnvilSaveConverter.java b/src/main/java/net/minecraft/world/chunk/storage/AnvilSaveConverter.java new file mode 100644 index 0000000..c828641 --- /dev/null +++ b/src/main/java/net/minecraft/world/chunk/storage/AnvilSaveConverter.java @@ -0,0 +1,273 @@ +package net.minecraft.world.chunk.storage; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.File; +import java.io.FilenameFilter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import net.minecraft.client.AnvilConverterException; +import net.minecraft.nbt.CompressedStreamTools; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.IProgressUpdate; +import net.minecraft.util.MathHelper; +import net.minecraft.world.WorldType; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.biome.WorldChunkManager; +import net.minecraft.world.biome.WorldChunkManagerHell; +import net.minecraft.world.storage.ISaveHandler; +import net.minecraft.world.storage.SaveFormatComparator; +import net.minecraft.world.storage.SaveFormatOld; +import net.minecraft.world.storage.WorldInfo; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class AnvilSaveConverter extends SaveFormatOld +{ + private static final Logger logger = LogManager.getLogger(); + private static final String __OBFID = "CL_00000582"; + + public AnvilSaveConverter(File par1File) + { + super(par1File); + } + + @SideOnly(Side.CLIENT) + public List getSaveList() throws AnvilConverterException + { + if (this.savesDirectory != null && this.savesDirectory.exists() && this.savesDirectory.isDirectory()) + { + ArrayList arraylist = new ArrayList(); + File[] afile = this.savesDirectory.listFiles(); + File[] afile1 = afile; + int i = afile.length; + + for (int j = 0; j < i; ++j) + { + File file1 = afile1[j]; + + if (file1.isDirectory()) + { + String s = file1.getName(); + WorldInfo worldinfo = this.getWorldInfo(s); + + if (worldinfo != null && (worldinfo.getSaveVersion() == 19132 || worldinfo.getSaveVersion() == 19133)) + { + boolean flag = worldinfo.getSaveVersion() != this.getSaveVersion(); + String s1 = worldinfo.getWorldName(); + + if (s1 == null || MathHelper.stringNullOrLengthZero(s1)) + { + s1 = s; + } + + long k = 0L; + arraylist.add(new SaveFormatComparator(s, s1, worldinfo.getLastTimePlayed(), k, worldinfo.getGameType(), flag, worldinfo.isHardcoreModeEnabled(), worldinfo.areCommandsAllowed())); + } + } + } + + return arraylist; + } + else + { + throw new AnvilConverterException("Unable to read or access folder where game worlds are saved!"); + } + } + + protected int getSaveVersion() + { + return 19133; + } + + public void flushCache() + { + RegionFileCache.clearRegionFileReferences(); + } + + public ISaveHandler getSaveLoader(String par1Str, boolean par2) + { + return new AnvilSaveHandler(this.savesDirectory, par1Str, par2); + } + + public boolean isOldMapFormat(String par1Str) + { + WorldInfo worldinfo = this.getWorldInfo(par1Str); + return worldinfo != null && worldinfo.getSaveVersion() != this.getSaveVersion(); + } + + public boolean convertMapFormat(String par1Str, IProgressUpdate par2IProgressUpdate) + { + par2IProgressUpdate.setLoadingProgress(0); + ArrayList arraylist = new ArrayList(); + ArrayList arraylist1 = new ArrayList(); + ArrayList arraylist2 = new ArrayList(); + File file1 = new File(this.savesDirectory, par1Str); + File file2 = new File(file1, "DIM-1"); + File file3 = new File(file1, "DIM1"); + logger.info("Scanning folders..."); + this.addRegionFilesToCollection(file1, arraylist); + + if (file2.exists()) + { + this.addRegionFilesToCollection(file2, arraylist1); + } + + if (file3.exists()) + { + this.addRegionFilesToCollection(file3, arraylist2); + } + + int i = arraylist.size() + arraylist1.size() + arraylist2.size(); + logger.info("Total conversion count is " + i); + WorldInfo worldinfo = this.getWorldInfo(par1Str); + Object object = null; + + if (worldinfo.getTerrainType() == WorldType.FLAT) + { + object = new WorldChunkManagerHell(BiomeGenBase.plains, 0.5F); + } + else + { + object = new WorldChunkManager(worldinfo.getSeed(), worldinfo.getTerrainType()); + } + + this.convertFile(new File(file1, "region"), arraylist, (WorldChunkManager)object, 0, i, par2IProgressUpdate); + this.convertFile(new File(file2, "region"), arraylist1, new WorldChunkManagerHell(BiomeGenBase.hell, 0.0F), arraylist.size(), i, par2IProgressUpdate); + this.convertFile(new File(file3, "region"), arraylist2, new WorldChunkManagerHell(BiomeGenBase.sky, 0.0F), arraylist.size() + arraylist1.size(), i, par2IProgressUpdate); + worldinfo.setSaveVersion(19133); + + if (worldinfo.getTerrainType() == WorldType.DEFAULT_1_1) + { + worldinfo.setTerrainType(WorldType.DEFAULT); + } + + this.createFile(par1Str); + ISaveHandler isavehandler = this.getSaveLoader(par1Str, false); + isavehandler.saveWorldInfo(worldinfo); + return true; + } + + private void createFile(String par1Str) + { + File file1 = new File(this.savesDirectory, par1Str); + + if (!file1.exists()) + { + logger.warn("Unable to create level.dat_mcr backup"); + } + else + { + File file2 = new File(file1, "level.dat"); + + if (!file2.exists()) + { + logger.warn("Unable to create level.dat_mcr backup"); + } + else + { + File file3 = new File(file1, "level.dat_mcr"); + + if (!file2.renameTo(file3)) + { + logger.warn("Unable to create level.dat_mcr backup"); + } + } + } + } + + private void convertFile(File par1File, Iterable par2Iterable, WorldChunkManager par3WorldChunkManager, int par4, int par5, IProgressUpdate par6IProgressUpdate) + { + Iterator iterator = par2Iterable.iterator(); + + while (iterator.hasNext()) + { + File file2 = (File)iterator.next(); + this.convertChunks(par1File, file2, par3WorldChunkManager, par4, par5, par6IProgressUpdate); + ++par4; + int k = (int)Math.round(100.0D * (double)par4 / (double)par5); + par6IProgressUpdate.setLoadingProgress(k); + } + } + + private void convertChunks(File par1File, File par2File, WorldChunkManager par3WorldChunkManager, int par4, int par5, IProgressUpdate par6IProgressUpdate) + { + try + { + String s = par2File.getName(); + RegionFile regionfile = new RegionFile(par2File); + RegionFile regionfile1 = new RegionFile(new File(par1File, s.substring(0, s.length() - ".mcr".length()) + ".mca")); + + for (int k = 0; k < 32; ++k) + { + int l; + + for (l = 0; l < 32; ++l) + { + if (regionfile.isChunkSaved(k, l) && !regionfile1.isChunkSaved(k, l)) + { + DataInputStream datainputstream = regionfile.getChunkDataInputStream(k, l); + + if (datainputstream == null) + { + logger.warn("Failed to fetch input stream"); + } + else + { + NBTTagCompound nbttagcompound = CompressedStreamTools.read(datainputstream); + datainputstream.close(); + NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("Level"); + ChunkLoader.AnvilConverterData anvilconverterdata = ChunkLoader.load(nbttagcompound1); + NBTTagCompound nbttagcompound2 = new NBTTagCompound(); + NBTTagCompound nbttagcompound3 = new NBTTagCompound(); + nbttagcompound2.setTag("Level", nbttagcompound3); + ChunkLoader.convertToAnvilFormat(anvilconverterdata, nbttagcompound3, par3WorldChunkManager); + DataOutputStream dataoutputstream = regionfile1.getChunkDataOutputStream(k, l); + CompressedStreamTools.write(nbttagcompound2, dataoutputstream); + dataoutputstream.close(); + } + } + } + + l = (int)Math.round(100.0D * (double)(par4 * 1024) / (double)(par5 * 1024)); + int i1 = (int)Math.round(100.0D * (double)((k + 1) * 32 + par4 * 1024) / (double)(par5 * 1024)); + + if (i1 > l) + { + par6IProgressUpdate.setLoadingProgress(i1); + } + } + + regionfile.close(); + regionfile1.close(); + } + catch (IOException ioexception) + { + ioexception.printStackTrace(); + } + } + + private void addRegionFilesToCollection(File par1File, Collection par2Collection) + { + File file2 = new File(par1File, "region"); + File[] afile = file2.listFiles(new FilenameFilter() + { + private static final String __OBFID = "CL_00000583"; + public boolean accept(File par1File, String par2Str) + { + return par2Str.endsWith(".mcr"); + } + }); + + if (afile != null) + { + Collections.addAll(par2Collection, afile); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/chunk/storage/AnvilSaveHandler.java b/src/main/java/net/minecraft/world/chunk/storage/AnvilSaveHandler.java new file mode 100644 index 0000000..651f633 --- /dev/null +++ b/src/main/java/net/minecraft/world/chunk/storage/AnvilSaveHandler.java @@ -0,0 +1,57 @@ +package net.minecraft.world.chunk.storage; + +import java.io.File; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.WorldProvider; +import net.minecraft.world.WorldProviderEnd; +import net.minecraft.world.WorldProviderHell; +import net.minecraft.world.storage.SaveHandler; +import net.minecraft.world.storage.ThreadedFileIOBase; +import net.minecraft.world.storage.WorldInfo; + +public class AnvilSaveHandler extends SaveHandler +{ + private static final String __OBFID = "CL_00000581"; + + public AnvilSaveHandler(File par1File, String par2Str, boolean par3) + { + super(par1File, par2Str, par3); + } + + public IChunkLoader getChunkLoader(WorldProvider par1WorldProvider) + { + File file1 = this.getWorldDirectory(); + File file2; + + if (par1WorldProvider.getSaveFolder() != null) + { + file2 = new File(file1, par1WorldProvider.getSaveFolder()); + file2.mkdirs(); + return new AnvilChunkLoader(file2); + } + else + { + return new AnvilChunkLoader(file1); + } + } + + public void saveWorldInfoWithPlayer(WorldInfo par1WorldInfo, NBTTagCompound par2NBTTagCompound) + { + par1WorldInfo.setSaveVersion(19133); + super.saveWorldInfoWithPlayer(par1WorldInfo, par2NBTTagCompound); + } + + public void flush() + { + try + { + ThreadedFileIOBase.threadedIOInstance.waitForFinish(); + } + catch (InterruptedException interruptedexception) + { + interruptedexception.printStackTrace(); + } + + RegionFileCache.clearRegionFileReferences(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/chunk/storage/ChunkLoader.java b/src/main/java/net/minecraft/world/chunk/storage/ChunkLoader.java new file mode 100644 index 0000000..40b95b6 --- /dev/null +++ b/src/main/java/net/minecraft/world/chunk/storage/ChunkLoader.java @@ -0,0 +1,166 @@ +package net.minecraft.world.chunk.storage; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.world.biome.WorldChunkManager; +import net.minecraft.world.chunk.NibbleArray; + +public class ChunkLoader +{ + private static final String __OBFID = "CL_00000379"; + + public static ChunkLoader.AnvilConverterData load(NBTTagCompound par0NBTTagCompound) + { + int i = par0NBTTagCompound.getInteger("xPos"); + int j = par0NBTTagCompound.getInteger("zPos"); + ChunkLoader.AnvilConverterData anvilconverterdata = new ChunkLoader.AnvilConverterData(i, j); + anvilconverterdata.blocks = par0NBTTagCompound.getByteArray("Blocks"); + anvilconverterdata.data = new NibbleArrayReader(par0NBTTagCompound.getByteArray("Data"), 7); + anvilconverterdata.skyLight = new NibbleArrayReader(par0NBTTagCompound.getByteArray("SkyLight"), 7); + anvilconverterdata.blockLight = new NibbleArrayReader(par0NBTTagCompound.getByteArray("BlockLight"), 7); + anvilconverterdata.heightmap = par0NBTTagCompound.getByteArray("HeightMap"); + anvilconverterdata.terrainPopulated = par0NBTTagCompound.getBoolean("TerrainPopulated"); + anvilconverterdata.entities = par0NBTTagCompound.getTagList("Entities", 10); + anvilconverterdata.field_151564_i = par0NBTTagCompound.getTagList("TileEntities", 10); + anvilconverterdata.field_151563_j = par0NBTTagCompound.getTagList("TileTicks", 10); + + try + { + anvilconverterdata.lastUpdated = par0NBTTagCompound.getLong("LastUpdate"); + } + catch (ClassCastException classcastexception) + { + anvilconverterdata.lastUpdated = (long)par0NBTTagCompound.getInteger("LastUpdate"); + } + + return anvilconverterdata; + } + + public static void convertToAnvilFormat(ChunkLoader.AnvilConverterData par0AnvilConverterData, NBTTagCompound par1NBTTagCompound, WorldChunkManager par2WorldChunkManager) + { + par1NBTTagCompound.setInteger("xPos", par0AnvilConverterData.x); + par1NBTTagCompound.setInteger("zPos", par0AnvilConverterData.z); + par1NBTTagCompound.setLong("LastUpdate", par0AnvilConverterData.lastUpdated); + int[] aint = new int[par0AnvilConverterData.heightmap.length]; + + for (int i = 0; i < par0AnvilConverterData.heightmap.length; ++i) + { + aint[i] = par0AnvilConverterData.heightmap[i]; + } + + par1NBTTagCompound.setIntArray("HeightMap", aint); + par1NBTTagCompound.setBoolean("TerrainPopulated", par0AnvilConverterData.terrainPopulated); + NBTTagList nbttaglist = new NBTTagList(); + int k; + + for (int j = 0; j < 8; ++j) + { + boolean flag = true; + + for (k = 0; k < 16 && flag; ++k) + { + int l = 0; + + while (l < 16 && flag) + { + int i1 = 0; + + while (true) + { + if (i1 < 16) + { + int j1 = k << 11 | i1 << 7 | l + (j << 4); + byte b0 = par0AnvilConverterData.blocks[j1]; + + if (b0 == 0) + { + ++i1; + continue; + } + + flag = false; + } + + ++l; + break; + } + } + } + + if (!flag) + { + byte[] abyte1 = new byte[4096]; + NibbleArray nibblearray = new NibbleArray(abyte1.length, 4); + NibbleArray nibblearray1 = new NibbleArray(abyte1.length, 4); + NibbleArray nibblearray2 = new NibbleArray(abyte1.length, 4); + + for (int k2 = 0; k2 < 16; ++k2) + { + for (int k1 = 0; k1 < 16; ++k1) + { + for (int l1 = 0; l1 < 16; ++l1) + { + int i2 = k2 << 11 | l1 << 7 | k1 + (j << 4); + byte b1 = par0AnvilConverterData.blocks[i2]; + abyte1[k1 << 8 | l1 << 4 | k2] = (byte)(b1 & 255); + nibblearray.set(k2, k1, l1, par0AnvilConverterData.data.get(k2, k1 + (j << 4), l1)); + nibblearray1.set(k2, k1, l1, par0AnvilConverterData.skyLight.get(k2, k1 + (j << 4), l1)); + nibblearray2.set(k2, k1, l1, par0AnvilConverterData.blockLight.get(k2, k1 + (j << 4), l1)); + } + } + } + + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + nbttagcompound1.setByte("Y", (byte)(j & 255)); + nbttagcompound1.setByteArray("Blocks", abyte1); + nbttagcompound1.setByteArray("Data", nibblearray.data); + nbttagcompound1.setByteArray("SkyLight", nibblearray1.data); + nbttagcompound1.setByteArray("BlockLight", nibblearray2.data); + nbttaglist.appendTag(nbttagcompound1); + } + } + + par1NBTTagCompound.setTag("Sections", nbttaglist); + byte[] abyte = new byte[256]; + + for (int j2 = 0; j2 < 16; ++j2) + { + for (k = 0; k < 16; ++k) + { + abyte[k << 4 | j2] = (byte)(par2WorldChunkManager.getBiomeGenAt(par0AnvilConverterData.x << 4 | j2, par0AnvilConverterData.z << 4 | k).biomeID & 255); + } + } + + par1NBTTagCompound.setByteArray("Biomes", abyte); + par1NBTTagCompound.setTag("Entities", par0AnvilConverterData.entities); + par1NBTTagCompound.setTag("TileEntities", par0AnvilConverterData.field_151564_i); + + if (par0AnvilConverterData.field_151563_j != null) + { + par1NBTTagCompound.setTag("TileTicks", par0AnvilConverterData.field_151563_j); + } + } + + public static class AnvilConverterData + { + public long lastUpdated; + public boolean terrainPopulated; + public byte[] heightmap; + public NibbleArrayReader blockLight; + public NibbleArrayReader skyLight; + public NibbleArrayReader data; + public byte[] blocks; + public NBTTagList entities; + public NBTTagList field_151564_i; + public NBTTagList field_151563_j; + public final int x; + public final int z; + private static final String __OBFID = "CL_00000380"; + + public AnvilConverterData(int par1, int par2) + { + this.x = par1; + this.z = par2; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/chunk/storage/ExtendedBlockStorage.java b/src/main/java/net/minecraft/world/chunk/storage/ExtendedBlockStorage.java new file mode 100644 index 0000000..1a39f5b --- /dev/null +++ b/src/main/java/net/minecraft/world/chunk/storage/ExtendedBlockStorage.java @@ -0,0 +1,229 @@ +package net.minecraft.world.chunk.storage; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.world.chunk.NibbleArray; + +public class ExtendedBlockStorage +{ + private int yBase; + private int blockRefCount; + private int tickRefCount; + private byte[] blockLSBArray; + private NibbleArray blockMSBArray; + private NibbleArray blockMetadataArray; + private NibbleArray blocklightArray; + private NibbleArray skylightArray; + private static final String __OBFID = "CL_00000375"; + + public ExtendedBlockStorage(int par1, boolean par2) + { + this.yBase = par1; + this.blockLSBArray = new byte[4096]; + this.blockMetadataArray = new NibbleArray(this.blockLSBArray.length, 4); + this.blocklightArray = new NibbleArray(this.blockLSBArray.length, 4); + + if (par2) + { + this.skylightArray = new NibbleArray(this.blockLSBArray.length, 4); + } + } + + public Block getBlockByExtId(int p_150819_1_, int p_150819_2_, int p_150819_3_) + { + int l = this.blockLSBArray[p_150819_2_ << 8 | p_150819_3_ << 4 | p_150819_1_] & 255; + + if (this.blockMSBArray != null) + { + l |= this.blockMSBArray.get(p_150819_1_, p_150819_2_, p_150819_3_) << 8; + } + + return Block.getBlockById(l); + } + + public void func_150818_a(int p_150818_1_, int p_150818_2_, int p_150818_3_, Block p_150818_4_) + { + int l = this.blockLSBArray[p_150818_2_ << 8 | p_150818_3_ << 4 | p_150818_1_] & 255; + + if (this.blockMSBArray != null) + { + l |= this.blockMSBArray.get(p_150818_1_, p_150818_2_, p_150818_3_) << 8; + } + + Block block1 = Block.getBlockById(l); + + if (block1 != Blocks.air) + { + --this.blockRefCount; + + if (block1.getTickRandomly()) + { + --this.tickRefCount; + } + } + + if (p_150818_4_ != Blocks.air) + { + ++this.blockRefCount; + + if (p_150818_4_.getTickRandomly()) + { + ++this.tickRefCount; + } + } + + int i1 = Block.getIdFromBlock(p_150818_4_); + this.blockLSBArray[p_150818_2_ << 8 | p_150818_3_ << 4 | p_150818_1_] = (byte)(i1 & 255); + + if (i1 > 255) + { + if (this.blockMSBArray == null) + { + this.blockMSBArray = new NibbleArray(this.blockLSBArray.length, 4); + } + + this.blockMSBArray.set(p_150818_1_, p_150818_2_, p_150818_3_, (i1 & 3840) >> 8); + } + else if (this.blockMSBArray != null) + { + this.blockMSBArray.set(p_150818_1_, p_150818_2_, p_150818_3_, 0); + } + } + + public int getExtBlockMetadata(int par1, int par2, int par3) + { + return this.blockMetadataArray.get(par1, par2, par3); + } + + public void setExtBlockMetadata(int par1, int par2, int par3, int par4) + { + this.blockMetadataArray.set(par1, par2, par3, par4); + } + + public boolean isEmpty() + { + return this.blockRefCount == 0; + } + + public boolean getNeedsRandomTick() + { + return this.tickRefCount > 0; + } + + public int getYLocation() + { + return this.yBase; + } + + public void setExtSkylightValue(int par1, int par2, int par3, int par4) + { + this.skylightArray.set(par1, par2, par3, par4); + } + + public int getExtSkylightValue(int par1, int par2, int par3) + { + return this.skylightArray.get(par1, par2, par3); + } + + public void setExtBlocklightValue(int par1, int par2, int par3, int par4) + { + this.blocklightArray.set(par1, par2, par3, par4); + } + + public int getExtBlocklightValue(int par1, int par2, int par3) + { + return this.blocklightArray.get(par1, par2, par3); + } + + public void removeInvalidBlocks() + { + this.blockRefCount = 0; + this.tickRefCount = 0; + + for (int i = 0; i < 16; ++i) + { + for (int j = 0; j < 16; ++j) + { + for (int k = 0; k < 16; ++k) + { + Block block = this.getBlockByExtId(i, j, k); + + if (block != Blocks.air) + { + ++this.blockRefCount; + + if (block.getTickRandomly()) + { + ++this.tickRefCount; + } + } + } + } + } + } + + public byte[] getBlockLSBArray() + { + return this.blockLSBArray; + } + + @SideOnly(Side.CLIENT) + public void clearMSBArray() + { + this.blockMSBArray = null; + } + + public NibbleArray getBlockMSBArray() + { + return this.blockMSBArray; + } + + public NibbleArray getMetadataArray() + { + return this.blockMetadataArray; + } + + public NibbleArray getBlocklightArray() + { + return this.blocklightArray; + } + + public NibbleArray getSkylightArray() + { + return this.skylightArray; + } + + public void setBlockLSBArray(byte[] par1ArrayOfByte) + { + this.blockLSBArray = par1ArrayOfByte; + } + + public void setBlockMSBArray(NibbleArray par1NibbleArray) + { + this.blockMSBArray = par1NibbleArray; + } + + public void setBlockMetadataArray(NibbleArray par1NibbleArray) + { + this.blockMetadataArray = par1NibbleArray; + } + + public void setBlocklightArray(NibbleArray par1NibbleArray) + { + this.blocklightArray = par1NibbleArray; + } + + public void setSkylightArray(NibbleArray par1NibbleArray) + { + this.skylightArray = par1NibbleArray; + } + + @SideOnly(Side.CLIENT) + public NibbleArray createBlockMSBArray() + { + this.blockMSBArray = new NibbleArray(this.blockLSBArray.length, 4); + return this.blockMSBArray; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/chunk/storage/IChunkLoader.java b/src/main/java/net/minecraft/world/chunk/storage/IChunkLoader.java new file mode 100644 index 0000000..cadf449 --- /dev/null +++ b/src/main/java/net/minecraft/world/chunk/storage/IChunkLoader.java @@ -0,0 +1,19 @@ +package net.minecraft.world.chunk.storage; + +import java.io.IOException; +import net.minecraft.world.MinecraftException; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; + +public interface IChunkLoader +{ + Chunk loadChunk(World var1, int var2, int var3) throws IOException; + + void saveChunk(World var1, Chunk var2) throws MinecraftException, IOException; + + void saveExtraChunkData(World var1, Chunk var2); + + void chunkTick(); + + void saveExtraData(); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/chunk/storage/NibbleArrayReader.java b/src/main/java/net/minecraft/world/chunk/storage/NibbleArrayReader.java new file mode 100644 index 0000000..59eefcc --- /dev/null +++ b/src/main/java/net/minecraft/world/chunk/storage/NibbleArrayReader.java @@ -0,0 +1,24 @@ +package net.minecraft.world.chunk.storage; + +public class NibbleArrayReader +{ + public final byte[] data; + private final int depthBits; + private final int depthBitsPlusFour; + private static final String __OBFID = "CL_00000376"; + + public NibbleArrayReader(byte[] par1ArrayOfByte, int par2) + { + this.data = par1ArrayOfByte; + this.depthBits = par2; + this.depthBitsPlusFour = par2 + 4; + } + + public int get(int par1, int par2, int par3) + { + int l = par1 << this.depthBitsPlusFour | par3 << this.depthBits | par2; + int i1 = l >> 1; + int j1 = l & 1; + return j1 == 0 ? this.data[i1] & 15 : this.data[i1] >> 4 & 15; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/chunk/storage/RegionFile.java b/src/main/java/net/minecraft/world/chunk/storage/RegionFile.java new file mode 100644 index 0000000..bac9c3e --- /dev/null +++ b/src/main/java/net/minecraft/world/chunk/storage/RegionFile.java @@ -0,0 +1,341 @@ +package net.minecraft.world.chunk.storage; + +import java.io.BufferedInputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.RandomAccessFile; +import java.util.ArrayList; +import java.util.zip.DeflaterOutputStream; +import java.util.zip.GZIPInputStream; +import java.util.zip.InflaterInputStream; +import net.minecraft.server.MinecraftServer; + +public class RegionFile +{ + private static final byte[] emptySector = new byte[4096]; + private final File fileName; + private RandomAccessFile dataFile; + private final int[] offsets = new int[1024]; + private final int[] chunkTimestamps = new int[1024]; + private ArrayList sectorFree; + private int sizeDelta; + private long lastModified; + private static final String __OBFID = "CL_00000381"; + + public RegionFile(File par1File) + { + this.fileName = par1File; + this.sizeDelta = 0; + + try + { + if (par1File.exists()) + { + this.lastModified = par1File.lastModified(); + } + + this.dataFile = new RandomAccessFile(par1File, "rw"); + int i; + + if (this.dataFile.length() < 4096L) + { + for (i = 0; i < 1024; ++i) + { + this.dataFile.writeInt(0); + } + + for (i = 0; i < 1024; ++i) + { + this.dataFile.writeInt(0); + } + + this.sizeDelta += 8192; + } + + if ((this.dataFile.length() & 4095L) != 0L) + { + for (i = 0; (long)i < (this.dataFile.length() & 4095L); ++i) + { + this.dataFile.write(0); + } + } + + i = (int)this.dataFile.length() / 4096; + this.sectorFree = new ArrayList(i); + int j; + + for (j = 0; j < i; ++j) + { + this.sectorFree.add(Boolean.valueOf(true)); + } + + this.sectorFree.set(0, Boolean.valueOf(false)); + this.sectorFree.set(1, Boolean.valueOf(false)); + this.dataFile.seek(0L); + int k; + + for (j = 0; j < 1024; ++j) + { + k = this.dataFile.readInt(); + this.offsets[j] = k; + + if (k != 0 && (k >> 8) + (k & 255) <= this.sectorFree.size()) + { + for (int l = 0; l < (k & 255); ++l) + { + this.sectorFree.set((k >> 8) + l, Boolean.valueOf(false)); + } + } + } + + for (j = 0; j < 1024; ++j) + { + k = this.dataFile.readInt(); + this.chunkTimestamps[j] = k; + } + } + catch (IOException ioexception) + { + ioexception.printStackTrace(); + } + } + + public synchronized DataInputStream getChunkDataInputStream(int par1, int par2) + { + if (this.outOfBounds(par1, par2)) + { + return null; + } + else + { + try + { + int k = this.getOffset(par1, par2); + + if (k == 0) + { + return null; + } + else + { + int l = k >> 8; + int i1 = k & 255; + + if (l + i1 > this.sectorFree.size()) + { + return null; + } + else + { + this.dataFile.seek((long)(l * 4096)); + int j1 = this.dataFile.readInt(); + + if (j1 > 4096 * i1) + { + return null; + } + else if (j1 <= 0) + { + return null; + } + else + { + byte b0 = this.dataFile.readByte(); + byte[] abyte; + + if (b0 == 1) + { + abyte = new byte[j1 - 1]; + this.dataFile.read(abyte); + return new DataInputStream(new BufferedInputStream(new GZIPInputStream(new ByteArrayInputStream(abyte)))); + } + else if (b0 == 2) + { + abyte = new byte[j1 - 1]; + this.dataFile.read(abyte); + return new DataInputStream(new BufferedInputStream(new InflaterInputStream(new ByteArrayInputStream(abyte)))); + } + else + { + return null; + } + } + } + } + } + catch (IOException ioexception) + { + return null; + } + } + } + + public DataOutputStream getChunkDataOutputStream(int par1, int par2) + { + return this.outOfBounds(par1, par2) ? null : new DataOutputStream(new DeflaterOutputStream(new RegionFile.ChunkBuffer(par1, par2))); + } + + protected synchronized void write(int par1, int par2, byte[] par3ArrayOfByte, int par4) + { + try + { + int l = this.getOffset(par1, par2); + int i1 = l >> 8; + int j1 = l & 255; + int k1 = (par4 + 5) / 4096 + 1; + + if (k1 >= 256) + { + return; + } + + if (i1 != 0 && j1 == k1) + { + this.write(i1, par3ArrayOfByte, par4); + } + else + { + int l1; + + for (l1 = 0; l1 < j1; ++l1) + { + this.sectorFree.set(i1 + l1, Boolean.valueOf(true)); + } + + l1 = this.sectorFree.indexOf(Boolean.valueOf(true)); + int i2 = 0; + int j2; + + if (l1 != -1) + { + for (j2 = l1; j2 < this.sectorFree.size(); ++j2) + { + if (i2 != 0) + { + if (((Boolean)this.sectorFree.get(j2)).booleanValue()) + { + ++i2; + } + else + { + i2 = 0; + } + } + else if (((Boolean)this.sectorFree.get(j2)).booleanValue()) + { + l1 = j2; + i2 = 1; + } + + if (i2 >= k1) + { + break; + } + } + } + + if (i2 >= k1) + { + i1 = l1; + this.setOffset(par1, par2, l1 << 8 | k1); + + for (j2 = 0; j2 < k1; ++j2) + { + this.sectorFree.set(i1 + j2, Boolean.valueOf(false)); + } + + this.write(i1, par3ArrayOfByte, par4); + } + else + { + this.dataFile.seek(this.dataFile.length()); + i1 = this.sectorFree.size(); + + for (j2 = 0; j2 < k1; ++j2) + { + this.dataFile.write(emptySector); + this.sectorFree.add(Boolean.valueOf(false)); + } + + this.sizeDelta += 4096 * k1; + this.write(i1, par3ArrayOfByte, par4); + this.setOffset(par1, par2, i1 << 8 | k1); + } + } + + this.setChunkTimestamp(par1, par2, (int)(MinecraftServer.getSystemTimeMillis() / 1000L)); + } + catch (IOException ioexception) + { + ioexception.printStackTrace(); + } + } + + private void write(int par1, byte[] par2ArrayOfByte, int par3) throws IOException + { + this.dataFile.seek((long)(par1 * 4096)); + this.dataFile.writeInt(par3 + 1); + this.dataFile.writeByte(2); + this.dataFile.write(par2ArrayOfByte, 0, par3); + } + + private boolean outOfBounds(int par1, int par2) + { + return par1 < 0 || par1 >= 32 || par2 < 0 || par2 >= 32; + } + + private int getOffset(int par1, int par2) + { + return this.offsets[par1 + par2 * 32]; + } + + public boolean isChunkSaved(int par1, int par2) + { + return this.getOffset(par1, par2) != 0; + } + + private void setOffset(int par1, int par2, int par3) throws IOException + { + this.offsets[par1 + par2 * 32] = par3; + this.dataFile.seek((long)((par1 + par2 * 32) * 4)); + this.dataFile.writeInt(par3); + } + + private void setChunkTimestamp(int par1, int par2, int par3) throws IOException + { + this.chunkTimestamps[par1 + par2 * 32] = par3; + this.dataFile.seek((long)(4096 + (par1 + par2 * 32) * 4)); + this.dataFile.writeInt(par3); + } + + public void close() throws IOException + { + if (this.dataFile != null) + { + this.dataFile.close(); + } + } + + class ChunkBuffer extends ByteArrayOutputStream + { + private int chunkX; + private int chunkZ; + private static final String __OBFID = "CL_00000382"; + + public ChunkBuffer(int par2, int par3) + { + super(8096); + this.chunkX = par2; + this.chunkZ = par3; + } + + public void close() throws IOException + { + RegionFile.this.write(this.chunkX, this.chunkZ, this.buf, this.count); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/chunk/storage/RegionFileCache.java b/src/main/java/net/minecraft/world/chunk/storage/RegionFileCache.java new file mode 100644 index 0000000..0832de0 --- /dev/null +++ b/src/main/java/net/minecraft/world/chunk/storage/RegionFileCache.java @@ -0,0 +1,79 @@ +package net.minecraft.world.chunk.storage; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.File; +import java.io.IOException; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +public class RegionFileCache +{ + private static final Map regionsByFilename = new HashMap(); + private static final String __OBFID = "CL_00000383"; + + public static synchronized RegionFile createOrLoadRegionFile(File par0File, int par1, int par2) + { + File file2 = new File(par0File, "region"); + File file3 = new File(file2, "r." + (par1 >> 5) + "." + (par2 >> 5) + ".mca"); + RegionFile regionfile = (RegionFile)regionsByFilename.get(file3); + + if (regionfile != null) + { + return regionfile; + } + else + { + if (!file2.exists()) + { + file2.mkdirs(); + } + + if (regionsByFilename.size() >= 256) + { + clearRegionFileReferences(); + } + + RegionFile regionfile1 = new RegionFile(file3); + regionsByFilename.put(file3, regionfile1); + return regionfile1; + } + } + + public static synchronized void clearRegionFileReferences() + { + Iterator iterator = regionsByFilename.values().iterator(); + + while (iterator.hasNext()) + { + RegionFile regionfile = (RegionFile)iterator.next(); + + try + { + if (regionfile != null) + { + regionfile.close(); + } + } + catch (IOException ioexception) + { + ioexception.printStackTrace(); + } + } + + regionsByFilename.clear(); + } + + public static DataInputStream getChunkInputStream(File par0File, int par1, int par2) + { + RegionFile regionfile = createOrLoadRegionFile(par0File, par1, par2); + return regionfile.getChunkDataInputStream(par1 & 31, par2 & 31); + } + + public static DataOutputStream getChunkOutputStream(File par0File, int par1, int par2) + { + RegionFile regionfile = createOrLoadRegionFile(par0File, par1, par2); + return regionfile.getChunkDataOutputStream(par1 & 31, par2 & 31); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/demo/DemoWorldManager.java b/src/main/java/net/minecraft/world/demo/DemoWorldManager.java new file mode 100644 index 0000000..a120c86 --- /dev/null +++ b/src/main/java/net/minecraft/world/demo/DemoWorldManager.java @@ -0,0 +1,130 @@ +package net.minecraft.world.demo; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.network.play.server.S2BPacketChangeGameState; +import net.minecraft.server.management.ItemInWorldManager; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.world.World; + +public class DemoWorldManager extends ItemInWorldManager +{ + private boolean field_73105_c; + private boolean demoTimeExpired; + private int field_73104_e; + private int field_73102_f; + private static final String __OBFID = "CL_00001429"; + + public DemoWorldManager(World par1World) + { + super(par1World); + } + + public void updateBlockRemoving() + { + super.updateBlockRemoving(); + ++this.field_73102_f; + long i = this.theWorld.getTotalWorldTime(); + long j = i / 24000L + 1L; + + if (!this.field_73105_c && this.field_73102_f > 20) + { + this.field_73105_c = true; + this.thisPlayerMP.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(5, 0.0F)); + } + + this.demoTimeExpired = i > 120500L; + + if (this.demoTimeExpired) + { + ++this.field_73104_e; + } + + if (i % 24000L == 500L) + { + if (j <= 6L) + { + this.thisPlayerMP.addChatMessage(new ChatComponentTranslation("demo.day." + j, new Object[0])); + } + } + else if (j == 1L) + { + if (i == 100L) + { + this.thisPlayerMP.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(5, 101.0F)); + } + else if (i == 175L) + { + this.thisPlayerMP.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(5, 102.0F)); + } + else if (i == 250L) + { + this.thisPlayerMP.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(5, 103.0F)); + } + } + else if (j == 5L && i % 24000L == 22000L) + { + this.thisPlayerMP.addChatMessage(new ChatComponentTranslation("demo.day.warning", new Object[0])); + } + } + + private void sendDemoReminder() + { + if (this.field_73104_e > 100) + { + this.thisPlayerMP.addChatMessage(new ChatComponentTranslation("demo.reminder", new Object[0])); + this.field_73104_e = 0; + } + } + + public void onBlockClicked(int par1, int par2, int par3, int par4) + { + if (this.demoTimeExpired) + { + this.sendDemoReminder(); + } + else + { + super.onBlockClicked(par1, par2, par3, par4); + } + } + + public void uncheckedTryHarvestBlock(int par1, int par2, int par3) + { + if (!this.demoTimeExpired) + { + super.uncheckedTryHarvestBlock(par1, par2, par3); + } + } + + public boolean tryHarvestBlock(int par1, int par2, int par3) + { + return this.demoTimeExpired ? false : super.tryHarvestBlock(par1, par2, par3); + } + + public boolean tryUseItem(EntityPlayer par1EntityPlayer, World par2World, ItemStack par3ItemStack) + { + if (this.demoTimeExpired) + { + this.sendDemoReminder(); + return false; + } + else + { + return super.tryUseItem(par1EntityPlayer, par2World, par3ItemStack); + } + } + + public boolean activateBlockOrUseItem(EntityPlayer par1EntityPlayer, World par2World, ItemStack par3ItemStack, int par4, int par5, int par6, int par7, float par8, float par9, float par10) + { + if (this.demoTimeExpired) + { + this.sendDemoReminder(); + return false; + } + else + { + return super.activateBlockOrUseItem(par1EntityPlayer, par2World, par3ItemStack, par4, par5, par6, par7, par8, par9, par10); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/demo/DemoWorldServer.java b/src/main/java/net/minecraft/world/demo/DemoWorldServer.java new file mode 100644 index 0000000..c191c72 --- /dev/null +++ b/src/main/java/net/minecraft/world/demo/DemoWorldServer.java @@ -0,0 +1,20 @@ +package net.minecraft.world.demo; + +import net.minecraft.profiler.Profiler; +import net.minecraft.server.MinecraftServer; +import net.minecraft.world.WorldServer; +import net.minecraft.world.WorldSettings; +import net.minecraft.world.WorldType; +import net.minecraft.world.storage.ISaveHandler; + +public class DemoWorldServer extends WorldServer +{ + private static final long demoWorldSeed = (long)"North Carolina".hashCode(); + public static final WorldSettings demoWorldSettings = (new WorldSettings(demoWorldSeed, WorldSettings.GameType.SURVIVAL, true, false, WorldType.DEFAULT)).enableBonusChest(); + private static final String __OBFID = "CL_00001428"; + + public DemoWorldServer(MinecraftServer p_i45282_1_, ISaveHandler p_i45282_2_, String p_i45282_3_, int p_i45282_4_, Profiler p_i45282_5_) + { + super(p_i45282_1_, p_i45282_2_, p_i45282_3_, p_i45282_4_, demoWorldSettings, p_i45282_5_); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/ChunkProviderEnd.java b/src/main/java/net/minecraft/world/gen/ChunkProviderEnd.java new file mode 100644 index 0000000..80dd51f --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/ChunkProviderEnd.java @@ -0,0 +1,410 @@ +package net.minecraft.world.gen; + +import java.util.List; +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.block.BlockFalling; +import net.minecraft.block.material.Material; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.init.Blocks; +import net.minecraft.util.IProgressUpdate; +import net.minecraft.util.MathHelper; +import net.minecraft.world.ChunkPosition; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.IChunkProvider; + +import net.minecraftforge.common.*; +import cpw.mods.fml.common.eventhandler.Event.*; +import net.minecraftforge.event.terraingen.*; + +public class ChunkProviderEnd implements IChunkProvider +{ + private Random endRNG; + private NoiseGeneratorOctaves noiseGen1; + private NoiseGeneratorOctaves noiseGen2; + private NoiseGeneratorOctaves noiseGen3; + public NoiseGeneratorOctaves noiseGen4; + public NoiseGeneratorOctaves noiseGen5; + private World endWorld; + private double[] densities; + private BiomeGenBase[] biomesForGeneration; + double[] noiseData1; + double[] noiseData2; + double[] noiseData3; + double[] noiseData4; + double[] noiseData5; + int[][] field_73203_h = new int[32][32]; + private static final String __OBFID = "CL_00000397"; + + public ChunkProviderEnd(World par1World, long par2) + { + this.endWorld = par1World; + this.endRNG = new Random(par2); + this.noiseGen1 = new NoiseGeneratorOctaves(this.endRNG, 16); + this.noiseGen2 = new NoiseGeneratorOctaves(this.endRNG, 16); + this.noiseGen3 = new NoiseGeneratorOctaves(this.endRNG, 8); + this.noiseGen4 = new NoiseGeneratorOctaves(this.endRNG, 10); + this.noiseGen5 = new NoiseGeneratorOctaves(this.endRNG, 16); + + NoiseGenerator[] noiseGens = {noiseGen1, noiseGen2, noiseGen3, noiseGen4, noiseGen5}; + noiseGens = TerrainGen.getModdedNoiseGenerators(par1World, this.endRNG, noiseGens); + this.noiseGen1 = (NoiseGeneratorOctaves)noiseGens[0]; + this.noiseGen2 = (NoiseGeneratorOctaves)noiseGens[1]; + this.noiseGen3 = (NoiseGeneratorOctaves)noiseGens[2]; + this.noiseGen4 = (NoiseGeneratorOctaves)noiseGens[3]; + this.noiseGen5 = (NoiseGeneratorOctaves)noiseGens[4]; + } + + public void func_147420_a(int p_147420_1_, int p_147420_2_, Block[] p_147420_3_, BiomeGenBase[] p_147420_4_) + { + byte b0 = 2; + int k = b0 + 1; + byte b1 = 33; + int l = b0 + 1; + this.densities = this.initializeNoiseField(this.densities, p_147420_1_ * b0, 0, p_147420_2_ * b0, k, b1, l); + + for (int i1 = 0; i1 < b0; ++i1) + { + for (int j1 = 0; j1 < b0; ++j1) + { + for (int k1 = 0; k1 < 32; ++k1) + { + double d0 = 0.25D; + double d1 = this.densities[((i1 + 0) * l + j1 + 0) * b1 + k1 + 0]; + double d2 = this.densities[((i1 + 0) * l + j1 + 1) * b1 + k1 + 0]; + double d3 = this.densities[((i1 + 1) * l + j1 + 0) * b1 + k1 + 0]; + double d4 = this.densities[((i1 + 1) * l + j1 + 1) * b1 + k1 + 0]; + double d5 = (this.densities[((i1 + 0) * l + j1 + 0) * b1 + k1 + 1] - d1) * d0; + double d6 = (this.densities[((i1 + 0) * l + j1 + 1) * b1 + k1 + 1] - d2) * d0; + double d7 = (this.densities[((i1 + 1) * l + j1 + 0) * b1 + k1 + 1] - d3) * d0; + double d8 = (this.densities[((i1 + 1) * l + j1 + 1) * b1 + k1 + 1] - d4) * d0; + + for (int l1 = 0; l1 < 4; ++l1) + { + double d9 = 0.125D; + double d10 = d1; + double d11 = d2; + double d12 = (d3 - d1) * d9; + double d13 = (d4 - d2) * d9; + + for (int i2 = 0; i2 < 8; ++i2) + { + int j2 = i2 + i1 * 8 << 11 | 0 + j1 * 8 << 7 | k1 * 4 + l1; + short short1 = 128; + double d14 = 0.125D; + double d15 = d10; + double d16 = (d11 - d10) * d14; + + for (int k2 = 0; k2 < 8; ++k2) + { + Block block = null; + + if (d15 > 0.0D) + { + block = Blocks.end_stone; + } + + p_147420_3_[j2] = block; + j2 += short1; + d15 += d16; + } + + d10 += d12; + d11 += d13; + } + + d1 += d5; + d2 += d6; + d3 += d7; + d4 += d8; + } + } + } + } + } + + public void func_147421_b(int p_147421_1_, int p_147421_2_, Block[] p_147421_3_, BiomeGenBase[] p_147421_4_) + { + ChunkProviderEvent.ReplaceBiomeBlocks event = new ChunkProviderEvent.ReplaceBiomeBlocks(this, p_147421_1_, p_147421_2_, p_147421_3_, p_147421_4_); + MinecraftForge.EVENT_BUS.post(event); + if (event.getResult() == Result.DENY) return; + + for (int k = 0; k < 16; ++k) + { + for (int l = 0; l < 16; ++l) + { + byte b0 = 1; + int i1 = -1; + Block block = Blocks.end_stone; + Block block1 = Blocks.end_stone; + + for (int j1 = 127; j1 >= 0; --j1) + { + int k1 = (l * 16 + k) * 128 + j1; + Block block2 = p_147421_3_[k1]; + + if (block2 != null && block2.getMaterial() != Material.air) + { + if (block2 == Blocks.stone) + { + if (i1 == -1) + { + if (b0 <= 0) + { + block = null; + block1 = Blocks.end_stone; + } + + i1 = b0; + + if (j1 >= 0) + { + p_147421_3_[k1] = block; + } + else + { + p_147421_3_[k1] = block1; + } + } + else if (i1 > 0) + { + --i1; + p_147421_3_[k1] = block1; + } + } + } + else + { + i1 = -1; + } + } + } + } + } + + public Chunk loadChunk(int par1, int par2) + { + return this.provideChunk(par1, par2); + } + + public Chunk provideChunk(int par1, int par2) + { + this.endRNG.setSeed((long)par1 * 341873128712L + (long)par2 * 132897987541L); + Block[] ablock = new Block[32768]; + this.biomesForGeneration = this.endWorld.getWorldChunkManager().loadBlockGeneratorData(this.biomesForGeneration, par1 * 16, par2 * 16, 16, 16); + this.func_147420_a(par1, par2, ablock, this.biomesForGeneration); + this.func_147421_b(par1, par2, ablock, this.biomesForGeneration); + Chunk chunk = new Chunk(this.endWorld, ablock, par1, par2); + byte[] abyte = chunk.getBiomeArray(); + + for (int k = 0; k < abyte.length; ++k) + { + abyte[k] = (byte)this.biomesForGeneration[k].biomeID; + } + + chunk.generateSkylightMap(); + return chunk; + } + + private double[] initializeNoiseField(double[] par1ArrayOfDouble, int par2, int par3, int par4, int par5, int par6, int par7) + { + ChunkProviderEvent.InitNoiseField event = new ChunkProviderEvent.InitNoiseField(this, par1ArrayOfDouble, par2, par3, par4, par5, par6, par7); + MinecraftForge.EVENT_BUS.post(event); + if (event.getResult() == Result.DENY) return event.noisefield; + + if (par1ArrayOfDouble == null) + { + par1ArrayOfDouble = new double[par5 * par6 * par7]; + } + + double d0 = 684.412D; + double d1 = 684.412D; + this.noiseData4 = this.noiseGen4.generateNoiseOctaves(this.noiseData4, par2, par4, par5, par7, 1.121D, 1.121D, 0.5D); + this.noiseData5 = this.noiseGen5.generateNoiseOctaves(this.noiseData5, par2, par4, par5, par7, 200.0D, 200.0D, 0.5D); + d0 *= 2.0D; + this.noiseData1 = this.noiseGen3.generateNoiseOctaves(this.noiseData1, par2, par3, par4, par5, par6, par7, d0 / 80.0D, d1 / 160.0D, d0 / 80.0D); + this.noiseData2 = this.noiseGen1.generateNoiseOctaves(this.noiseData2, par2, par3, par4, par5, par6, par7, d0, d1, d0); + this.noiseData3 = this.noiseGen2.generateNoiseOctaves(this.noiseData3, par2, par3, par4, par5, par6, par7, d0, d1, d0); + int k1 = 0; + int l1 = 0; + + for (int i2 = 0; i2 < par5; ++i2) + { + for (int j2 = 0; j2 < par7; ++j2) + { + double d2 = (this.noiseData4[l1] + 256.0D) / 512.0D; + + if (d2 > 1.0D) + { + d2 = 1.0D; + } + + double d3 = this.noiseData5[l1] / 8000.0D; + + if (d3 < 0.0D) + { + d3 = -d3 * 0.3D; + } + + d3 = d3 * 3.0D - 2.0D; + float f = (float)(i2 + par2 - 0) / 1.0F; + float f1 = (float)(j2 + par4 - 0) / 1.0F; + float f2 = 100.0F - MathHelper.sqrt_float(f * f + f1 * f1) * 8.0F; + + if (f2 > 80.0F) + { + f2 = 80.0F; + } + + if (f2 < -100.0F) + { + f2 = -100.0F; + } + + if (d3 > 1.0D) + { + d3 = 1.0D; + } + + d3 /= 8.0D; + d3 = 0.0D; + + if (d2 < 0.0D) + { + d2 = 0.0D; + } + + d2 += 0.5D; + d3 = d3 * (double)par6 / 16.0D; + ++l1; + double d4 = (double)par6 / 2.0D; + + for (int k2 = 0; k2 < par6; ++k2) + { + double d5 = 0.0D; + double d6 = ((double)k2 - d4) * 8.0D / d2; + + if (d6 < 0.0D) + { + d6 *= -1.0D; + } + + double d7 = this.noiseData2[k1] / 512.0D; + double d8 = this.noiseData3[k1] / 512.0D; + double d9 = (this.noiseData1[k1] / 10.0D + 1.0D) / 2.0D; + + if (d9 < 0.0D) + { + d5 = d7; + } + else if (d9 > 1.0D) + { + d5 = d8; + } + else + { + d5 = d7 + (d8 - d7) * d9; + } + + d5 -= 8.0D; + d5 += (double)f2; + byte b0 = 2; + double d10; + + if (k2 > par6 / 2 - b0) + { + d10 = (double)((float)(k2 - (par6 / 2 - b0)) / 64.0F); + + if (d10 < 0.0D) + { + d10 = 0.0D; + } + + if (d10 > 1.0D) + { + d10 = 1.0D; + } + + d5 = d5 * (1.0D - d10) + -3000.0D * d10; + } + + b0 = 8; + + if (k2 < b0) + { + d10 = (double)((float)(b0 - k2) / ((float)b0 - 1.0F)); + d5 = d5 * (1.0D - d10) + -30.0D * d10; + } + + par1ArrayOfDouble[k1] = d5; + ++k1; + } + } + } + + return par1ArrayOfDouble; + } + + public boolean chunkExists(int par1, int par2) + { + return true; + } + + public void populate(IChunkProvider par1IChunkProvider, int par2, int par3) + { + BlockFalling.fallInstantly = true; + + MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Pre(par1IChunkProvider, endWorld, endWorld.rand, par2, par3, false)); + + int k = par2 * 16; + int l = par3 * 16; + BiomeGenBase biomegenbase = this.endWorld.getBiomeGenForCoords(k + 16, l + 16); + biomegenbase.decorate(this.endWorld, this.endWorld.rand, k, l); + + MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Post(par1IChunkProvider, endWorld, endWorld.rand, par2, par3, false)); + + BlockFalling.fallInstantly = false; + } + + public boolean saveChunks(boolean par1, IProgressUpdate par2IProgressUpdate) + { + return true; + } + + public void saveExtraData() {} + + public boolean unloadQueuedChunks() + { + return false; + } + + public boolean canSave() + { + return true; + } + + public String makeString() + { + return "RandomLevelSource"; + } + + public List getPossibleCreatures(EnumCreatureType par1EnumCreatureType, int par2, int par3, int par4) + { + BiomeGenBase biomegenbase = this.endWorld.getBiomeGenForCoords(par2, par4); + return biomegenbase.getSpawnableList(par1EnumCreatureType); + } + + public ChunkPosition func_147416_a(World p_147416_1_, String p_147416_2_, int p_147416_3_, int p_147416_4_, int p_147416_5_) + { + return null; + } + + public int getLoadedChunkCount() + { + return 0; + } + + public void recreateStructures(int par1, int par2) {} +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/ChunkProviderFlat.java b/src/main/java/net/minecraft/world/gen/ChunkProviderFlat.java new file mode 100644 index 0000000..5560d99 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/ChunkProviderFlat.java @@ -0,0 +1,294 @@ +package net.minecraft.world.gen; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.init.Blocks; +import net.minecraft.util.IProgressUpdate; +import net.minecraft.world.ChunkPosition; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.IChunkProvider; +import net.minecraft.world.chunk.storage.ExtendedBlockStorage; +import net.minecraft.world.gen.feature.WorldGenDungeons; +import net.minecraft.world.gen.feature.WorldGenLakes; +import net.minecraft.world.gen.structure.MapGenMineshaft; +import net.minecraft.world.gen.structure.MapGenScatteredFeature; +import net.minecraft.world.gen.structure.MapGenStronghold; +import net.minecraft.world.gen.structure.MapGenStructure; +import net.minecraft.world.gen.structure.MapGenVillage; + +public class ChunkProviderFlat implements IChunkProvider +{ + private World worldObj; + private Random random; + private final Block[] cachedBlockIDs = new Block[256]; + private final byte[] cachedBlockMetadata = new byte[256]; + private final FlatGeneratorInfo flatWorldGenInfo; + private final List structureGenerators = new ArrayList(); + private final boolean hasDecoration; + private final boolean hasDungeons; + private WorldGenLakes waterLakeGenerator; + private WorldGenLakes lavaLakeGenerator; + private static final String __OBFID = "CL_00000391"; + + public ChunkProviderFlat(World par1World, long par2, boolean par4, String par5Str) + { + this.worldObj = par1World; + this.random = new Random(par2); + this.flatWorldGenInfo = FlatGeneratorInfo.createFlatGeneratorFromString(par5Str); + + if (par4) + { + Map map = this.flatWorldGenInfo.getWorldFeatures(); + + if (map.containsKey("village")) + { + Map map1 = (Map)map.get("village"); + + if (!map1.containsKey("size")) + { + map1.put("size", "1"); + } + + this.structureGenerators.add(new MapGenVillage(map1)); + } + + if (map.containsKey("biome_1")) + { + this.structureGenerators.add(new MapGenScatteredFeature((Map)map.get("biome_1"))); + } + + if (map.containsKey("mineshaft")) + { + this.structureGenerators.add(new MapGenMineshaft((Map)map.get("mineshaft"))); + } + + if (map.containsKey("stronghold")) + { + this.structureGenerators.add(new MapGenStronghold((Map)map.get("stronghold"))); + } + } + + this.hasDecoration = this.flatWorldGenInfo.getWorldFeatures().containsKey("decoration"); + + if (this.flatWorldGenInfo.getWorldFeatures().containsKey("lake")) + { + this.waterLakeGenerator = new WorldGenLakes(Blocks.water); + } + + if (this.flatWorldGenInfo.getWorldFeatures().containsKey("lava_lake")) + { + this.lavaLakeGenerator = new WorldGenLakes(Blocks.lava); + } + + this.hasDungeons = this.flatWorldGenInfo.getWorldFeatures().containsKey("dungeon"); + Iterator iterator = this.flatWorldGenInfo.getFlatLayers().iterator(); + + while (iterator.hasNext()) + { + FlatLayerInfo flatlayerinfo = (FlatLayerInfo)iterator.next(); + + for (int j = flatlayerinfo.getMinY(); j < flatlayerinfo.getMinY() + flatlayerinfo.getLayerCount(); ++j) + { + this.cachedBlockIDs[j] = flatlayerinfo.func_151536_b(); + this.cachedBlockMetadata[j] = (byte)flatlayerinfo.getFillBlockMeta(); + } + } + } + + public Chunk loadChunk(int par1, int par2) + { + return this.provideChunk(par1, par2); + } + + public Chunk provideChunk(int par1, int par2) + { + Chunk chunk = new Chunk(this.worldObj, par1, par2); + int l; + + for (int k = 0; k < this.cachedBlockIDs.length; ++k) + { + Block block = this.cachedBlockIDs[k]; + + if (block != null) + { + l = k >> 4; + ExtendedBlockStorage extendedblockstorage = chunk.getBlockStorageArray()[l]; + + if (extendedblockstorage == null) + { + extendedblockstorage = new ExtendedBlockStorage(k, !this.worldObj.provider.hasNoSky); + chunk.getBlockStorageArray()[l] = extendedblockstorage; + } + + for (int i1 = 0; i1 < 16; ++i1) + { + for (int j1 = 0; j1 < 16; ++j1) + { + extendedblockstorage.func_150818_a(i1, k & 15, j1, block); + extendedblockstorage.setExtBlockMetadata(i1, k & 15, j1, this.cachedBlockMetadata[k]); + } + } + } + } + + chunk.generateSkylightMap(); + BiomeGenBase[] abiomegenbase = this.worldObj.getWorldChunkManager().loadBlockGeneratorData((BiomeGenBase[])null, par1 * 16, par2 * 16, 16, 16); + byte[] abyte = chunk.getBiomeArray(); + + for (l = 0; l < abyte.length; ++l) + { + abyte[l] = (byte)abiomegenbase[l].biomeID; + } + + Iterator iterator = this.structureGenerators.iterator(); + + while (iterator.hasNext()) + { + MapGenStructure mapgenstructure = (MapGenStructure)iterator.next(); + mapgenstructure.func_151539_a(this, this.worldObj, par1, par2, (Block[])null); + } + + chunk.generateSkylightMap(); + return chunk; + } + + public boolean chunkExists(int par1, int par2) + { + return true; + } + + public void populate(IChunkProvider par1IChunkProvider, int par2, int par3) + { + int k = par2 * 16; + int l = par3 * 16; + BiomeGenBase biomegenbase = this.worldObj.getBiomeGenForCoords(k + 16, l + 16); + boolean flag = false; + this.random.setSeed(this.worldObj.getSeed()); + long i1 = this.random.nextLong() / 2L * 2L + 1L; + long j1 = this.random.nextLong() / 2L * 2L + 1L; + this.random.setSeed((long)par2 * i1 + (long)par3 * j1 ^ this.worldObj.getSeed()); + Iterator iterator = this.structureGenerators.iterator(); + + while (iterator.hasNext()) + { + MapGenStructure mapgenstructure = (MapGenStructure)iterator.next(); + boolean flag1 = mapgenstructure.generateStructuresInChunk(this.worldObj, this.random, par2, par3); + + if (mapgenstructure instanceof MapGenVillage) + { + flag |= flag1; + } + } + + int l1; + int i2; + int j2; + + if (this.waterLakeGenerator != null && !flag && this.random.nextInt(4) == 0) + { + l1 = k + this.random.nextInt(16) + 8; + i2 = this.random.nextInt(256); + j2 = l + this.random.nextInt(16) + 8; + this.waterLakeGenerator.generate(this.worldObj, this.random, l1, i2, j2); + } + + if (this.lavaLakeGenerator != null && !flag && this.random.nextInt(8) == 0) + { + l1 = k + this.random.nextInt(16) + 8; + i2 = this.random.nextInt(this.random.nextInt(248) + 8); + j2 = l + this.random.nextInt(16) + 8; + + if (i2 < 63 || this.random.nextInt(10) == 0) + { + this.lavaLakeGenerator.generate(this.worldObj, this.random, l1, i2, j2); + } + } + + if (this.hasDungeons) + { + for (l1 = 0; l1 < 8; ++l1) + { + i2 = k + this.random.nextInt(16) + 8; + j2 = this.random.nextInt(256); + int k1 = l + this.random.nextInt(16) + 8; + (new WorldGenDungeons()).generate(this.worldObj, this.random, i2, j2, k1); + } + } + + if (this.hasDecoration) + { + biomegenbase.decorate(this.worldObj, this.random, k, l); + } + } + + public boolean saveChunks(boolean par1, IProgressUpdate par2IProgressUpdate) + { + return true; + } + + public void saveExtraData() {} + + public boolean unloadQueuedChunks() + { + return false; + } + + public boolean canSave() + { + return true; + } + + public String makeString() + { + return "FlatLevelSource"; + } + + public List getPossibleCreatures(EnumCreatureType par1EnumCreatureType, int par2, int par3, int par4) + { + BiomeGenBase biomegenbase = this.worldObj.getBiomeGenForCoords(par2, par4); + return biomegenbase.getSpawnableList(par1EnumCreatureType); + } + + public ChunkPosition func_147416_a(World p_147416_1_, String p_147416_2_, int p_147416_3_, int p_147416_4_, int p_147416_5_) + { + if ("Stronghold".equals(p_147416_2_)) + { + Iterator iterator = this.structureGenerators.iterator(); + + while (iterator.hasNext()) + { + MapGenStructure mapgenstructure = (MapGenStructure)iterator.next(); + + if (mapgenstructure instanceof MapGenStronghold) + { + return mapgenstructure.func_151545_a(p_147416_1_, p_147416_3_, p_147416_4_, p_147416_5_); + } + } + } + + return null; + } + + public int getLoadedChunkCount() + { + return 0; + } + + public void recreateStructures(int par1, int par2) + { + Iterator iterator = this.structureGenerators.iterator(); + + while (iterator.hasNext()) + { + MapGenStructure mapgenstructure = (MapGenStructure)iterator.next(); + mapgenstructure.func_151539_a(this, this.worldObj, par1, par2, (Block[])null); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/ChunkProviderGenerate.java b/src/main/java/net/minecraft/world/gen/ChunkProviderGenerate.java new file mode 100644 index 0000000..56b67e4 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/ChunkProviderGenerate.java @@ -0,0 +1,501 @@ +package net.minecraft.world.gen; + +import java.util.List; +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.block.BlockFalling; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.init.Blocks; +import net.minecraft.util.IProgressUpdate; +import net.minecraft.util.MathHelper; +import net.minecraft.world.ChunkPosition; +import net.minecraft.world.SpawnerAnimals; +import net.minecraft.world.World; +import net.minecraft.world.WorldType; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.IChunkProvider; +import net.minecraft.world.gen.feature.WorldGenDungeons; +import net.minecraft.world.gen.feature.WorldGenLakes; +import net.minecraft.world.gen.structure.MapGenMineshaft; +import net.minecraft.world.gen.structure.MapGenScatteredFeature; +import net.minecraft.world.gen.structure.MapGenStronghold; +import net.minecraft.world.gen.structure.MapGenVillage; + +import static net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.*; +import static net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.*; +import net.minecraftforge.common.*; +import cpw.mods.fml.common.eventhandler.Event.*; +import net.minecraftforge.event.terraingen.*; + +public class ChunkProviderGenerate implements IChunkProvider +{ + private Random rand; + private NoiseGeneratorOctaves field_147431_j; + private NoiseGeneratorOctaves field_147432_k; + private NoiseGeneratorOctaves field_147429_l; + private NoiseGeneratorPerlin field_147430_m; + public NoiseGeneratorOctaves noiseGen5; + public NoiseGeneratorOctaves noiseGen6; + public NoiseGeneratorOctaves mobSpawnerNoise; + private World worldObj; + private final boolean mapFeaturesEnabled; + private WorldType field_147435_p; + private final double[] field_147434_q; + private final float[] parabolicField; + private double[] stoneNoise = new double[256]; + private MapGenBase caveGenerator = new MapGenCaves(); + private MapGenStronghold strongholdGenerator = new MapGenStronghold(); + private MapGenVillage villageGenerator = new MapGenVillage(); + private MapGenMineshaft mineshaftGenerator = new MapGenMineshaft(); + private MapGenScatteredFeature scatteredFeatureGenerator = new MapGenScatteredFeature(); + private MapGenBase ravineGenerator = new MapGenRavine(); + private BiomeGenBase[] biomesForGeneration; + double[] field_147427_d; + double[] field_147428_e; + double[] field_147425_f; + double[] field_147426_g; + int[][] field_73219_j = new int[32][32]; + private static final String __OBFID = "CL_00000396"; + + { + caveGenerator = TerrainGen.getModdedMapGen(caveGenerator, CAVE); + strongholdGenerator = (MapGenStronghold) TerrainGen.getModdedMapGen(strongholdGenerator, STRONGHOLD); + villageGenerator = (MapGenVillage) TerrainGen.getModdedMapGen(villageGenerator, VILLAGE); + mineshaftGenerator = (MapGenMineshaft) TerrainGen.getModdedMapGen(mineshaftGenerator, MINESHAFT); + scatteredFeatureGenerator = (MapGenScatteredFeature) TerrainGen.getModdedMapGen(scatteredFeatureGenerator, SCATTERED_FEATURE); + ravineGenerator = TerrainGen.getModdedMapGen(ravineGenerator, RAVINE); + } + + public ChunkProviderGenerate(World par1World, long par2, boolean par4) + { + this.worldObj = par1World; + this.mapFeaturesEnabled = par4; + this.field_147435_p = par1World.getWorldInfo().getTerrainType(); + this.rand = new Random(par2); + this.field_147431_j = new NoiseGeneratorOctaves(this.rand, 16); + this.field_147432_k = new NoiseGeneratorOctaves(this.rand, 16); + this.field_147429_l = new NoiseGeneratorOctaves(this.rand, 8); + this.field_147430_m = new NoiseGeneratorPerlin(this.rand, 4); + this.noiseGen5 = new NoiseGeneratorOctaves(this.rand, 10); + this.noiseGen6 = new NoiseGeneratorOctaves(this.rand, 16); + this.mobSpawnerNoise = new NoiseGeneratorOctaves(this.rand, 8); + this.field_147434_q = new double[825]; + this.parabolicField = new float[25]; + + for (int j = -2; j <= 2; ++j) + { + for (int k = -2; k <= 2; ++k) + { + float f = 10.0F / MathHelper.sqrt_float((float)(j * j + k * k) + 0.2F); + this.parabolicField[j + 2 + (k + 2) * 5] = f; + } + } + + NoiseGenerator[] noiseGens = {field_147431_j, field_147432_k, field_147429_l, field_147430_m, noiseGen5, noiseGen6, mobSpawnerNoise}; + noiseGens = TerrainGen.getModdedNoiseGenerators(par1World, this.rand, noiseGens); + this.field_147431_j = (NoiseGeneratorOctaves)noiseGens[0]; + this.field_147432_k = (NoiseGeneratorOctaves)noiseGens[1]; + this.field_147429_l = (NoiseGeneratorOctaves)noiseGens[2]; + this.field_147430_m = (NoiseGeneratorPerlin)noiseGens[3]; + this.noiseGen5 = (NoiseGeneratorOctaves)noiseGens[4]; + this.noiseGen6 = (NoiseGeneratorOctaves)noiseGens[5]; + this.mobSpawnerNoise = (NoiseGeneratorOctaves)noiseGens[6]; + } + + public void func_147424_a(int p_147424_1_, int p_147424_2_, Block[] p_147424_3_) + { + byte b0 = 63; + this.biomesForGeneration = this.worldObj.getWorldChunkManager().getBiomesForGeneration(this.biomesForGeneration, p_147424_1_ * 4 - 2, p_147424_2_ * 4 - 2, 10, 10); + this.func_147423_a(p_147424_1_ * 4, 0, p_147424_2_ * 4); + + for (int k = 0; k < 4; ++k) + { + int l = k * 5; + int i1 = (k + 1) * 5; + + for (int j1 = 0; j1 < 4; ++j1) + { + int k1 = (l + j1) * 33; + int l1 = (l + j1 + 1) * 33; + int i2 = (i1 + j1) * 33; + int j2 = (i1 + j1 + 1) * 33; + + for (int k2 = 0; k2 < 32; ++k2) + { + double d0 = 0.125D; + double d1 = this.field_147434_q[k1 + k2]; + double d2 = this.field_147434_q[l1 + k2]; + double d3 = this.field_147434_q[i2 + k2]; + double d4 = this.field_147434_q[j2 + k2]; + double d5 = (this.field_147434_q[k1 + k2 + 1] - d1) * d0; + double d6 = (this.field_147434_q[l1 + k2 + 1] - d2) * d0; + double d7 = (this.field_147434_q[i2 + k2 + 1] - d3) * d0; + double d8 = (this.field_147434_q[j2 + k2 + 1] - d4) * d0; + + for (int l2 = 0; l2 < 8; ++l2) + { + double d9 = 0.25D; + double d10 = d1; + double d11 = d2; + double d12 = (d3 - d1) * d9; + double d13 = (d4 - d2) * d9; + + for (int i3 = 0; i3 < 4; ++i3) + { + int j3 = i3 + k * 4 << 12 | 0 + j1 * 4 << 8 | k2 * 8 + l2; + short short1 = 256; + j3 -= short1; + double d14 = 0.25D; + double d16 = (d11 - d10) * d14; + double d15 = d10 - d16; + + for (int k3 = 0; k3 < 4; ++k3) + { + if ((d15 += d16) > 0.0D) + { + p_147424_3_[j3 += short1] = Blocks.stone; + } + else if (k2 * 8 + l2 < b0) + { + p_147424_3_[j3 += short1] = Blocks.water; + } + else + { + p_147424_3_[j3 += short1] = null; + } + } + + d10 += d12; + d11 += d13; + } + + d1 += d5; + d2 += d6; + d3 += d7; + d4 += d8; + } + } + } + } + } + + public void replaceBlocksForBiome(int p_147422_1_, int p_147422_2_, Block[] p_147422_3_, byte[] p_147422_4_, BiomeGenBase[] p_147422_5_) + { + ChunkProviderEvent.ReplaceBiomeBlocks event = new ChunkProviderEvent.ReplaceBiomeBlocks(this, p_147422_1_, p_147422_2_, p_147422_3_, p_147422_5_); + MinecraftForge.EVENT_BUS.post(event); + if (event.getResult() == Result.DENY) return; + + double d0 = 0.03125D; + this.stoneNoise = this.field_147430_m.func_151599_a(this.stoneNoise, (double)(p_147422_1_ * 16), (double)(p_147422_2_ * 16), 16, 16, d0 * 2.0D, d0 * 2.0D, 1.0D); + + for (int k = 0; k < 16; ++k) + { + for (int l = 0; l < 16; ++l) + { + BiomeGenBase biomegenbase = p_147422_5_[l + k * 16]; + biomegenbase.genTerrainBlocks(this.worldObj, this.rand, p_147422_3_, p_147422_4_, p_147422_1_ * 16 + k, p_147422_2_ * 16 + l, this.stoneNoise[l + k * 16]); + } + } + } + + public Chunk loadChunk(int par1, int par2) + { + return this.provideChunk(par1, par2); + } + + public Chunk provideChunk(int par1, int par2) + { + this.rand.setSeed((long)par1 * 341873128712L + (long)par2 * 132897987541L); + Block[] ablock = new Block[65536]; + byte[] abyte = new byte[65536]; + this.func_147424_a(par1, par2, ablock); + this.biomesForGeneration = this.worldObj.getWorldChunkManager().loadBlockGeneratorData(this.biomesForGeneration, par1 * 16, par2 * 16, 16, 16); + this.replaceBlocksForBiome(par1, par2, ablock, abyte, this.biomesForGeneration); + this.caveGenerator.func_151539_a(this, this.worldObj, par1, par2, ablock); + this.ravineGenerator.func_151539_a(this, this.worldObj, par1, par2, ablock); + + if (this.mapFeaturesEnabled) + { + this.mineshaftGenerator.func_151539_a(this, this.worldObj, par1, par2, ablock); + this.villageGenerator.func_151539_a(this, this.worldObj, par1, par2, ablock); + this.strongholdGenerator.func_151539_a(this, this.worldObj, par1, par2, ablock); + this.scatteredFeatureGenerator.func_151539_a(this, this.worldObj, par1, par2, ablock); + } + + Chunk chunk = new Chunk(this.worldObj, ablock, abyte, par1, par2); + byte[] abyte1 = chunk.getBiomeArray(); + + for (int k = 0; k < abyte1.length; ++k) + { + abyte1[k] = (byte)this.biomesForGeneration[k].biomeID; + } + + chunk.generateSkylightMap(); + return chunk; + } + + private void func_147423_a(int p_147423_1_, int p_147423_2_, int p_147423_3_) + { + double d0 = 684.412D; + double d1 = 684.412D; + double d2 = 512.0D; + double d3 = 512.0D; + this.field_147426_g = this.noiseGen6.generateNoiseOctaves(this.field_147426_g, p_147423_1_, p_147423_3_, 5, 5, 200.0D, 200.0D, 0.5D); + this.field_147427_d = this.field_147429_l.generateNoiseOctaves(this.field_147427_d, p_147423_1_, p_147423_2_, p_147423_3_, 5, 33, 5, 8.555150000000001D, 4.277575000000001D, 8.555150000000001D); + this.field_147428_e = this.field_147431_j.generateNoiseOctaves(this.field_147428_e, p_147423_1_, p_147423_2_, p_147423_3_, 5, 33, 5, 684.412D, 684.412D, 684.412D); + this.field_147425_f = this.field_147432_k.generateNoiseOctaves(this.field_147425_f, p_147423_1_, p_147423_2_, p_147423_3_, 5, 33, 5, 684.412D, 684.412D, 684.412D); + boolean flag1 = false; + boolean flag = false; + int l = 0; + int i1 = 0; + double d4 = 8.5D; + + for (int j1 = 0; j1 < 5; ++j1) + { + for (int k1 = 0; k1 < 5; ++k1) + { + float f = 0.0F; + float f1 = 0.0F; + float f2 = 0.0F; + byte b0 = 2; + BiomeGenBase biomegenbase = this.biomesForGeneration[j1 + 2 + (k1 + 2) * 10]; + + for (int l1 = -b0; l1 <= b0; ++l1) + { + for (int i2 = -b0; i2 <= b0; ++i2) + { + BiomeGenBase biomegenbase1 = this.biomesForGeneration[j1 + l1 + 2 + (k1 + i2 + 2) * 10]; + float f3 = biomegenbase1.rootHeight; + float f4 = biomegenbase1.heightVariation; + + if (this.field_147435_p == WorldType.AMPLIFIED && f3 > 0.0F) + { + f3 = 1.0F + f3 * 2.0F; + f4 = 1.0F + f4 * 4.0F; + } + + float f5 = this.parabolicField[l1 + 2 + (i2 + 2) * 5] / (f3 + 2.0F); + + if (biomegenbase1.rootHeight > biomegenbase.rootHeight) + { + f5 /= 2.0F; + } + + f += f4 * f5; + f1 += f3 * f5; + f2 += f5; + } + } + + f /= f2; + f1 /= f2; + f = f * 0.9F + 0.1F; + f1 = (f1 * 4.0F - 1.0F) / 8.0F; + double d12 = this.field_147426_g[i1] / 8000.0D; + + if (d12 < 0.0D) + { + d12 = -d12 * 0.3D; + } + + d12 = d12 * 3.0D - 2.0D; + + if (d12 < 0.0D) + { + d12 /= 2.0D; + + if (d12 < -1.0D) + { + d12 = -1.0D; + } + + d12 /= 1.4D; + d12 /= 2.0D; + } + else + { + if (d12 > 1.0D) + { + d12 = 1.0D; + } + + d12 /= 8.0D; + } + + ++i1; + double d13 = (double)f1; + double d14 = (double)f; + d13 += d12 * 0.2D; + d13 = d13 * 8.5D / 8.0D; + double d5 = 8.5D + d13 * 4.0D; + + for (int j2 = 0; j2 < 33; ++j2) + { + double d6 = ((double)j2 - d5) * 12.0D * 128.0D / 256.0D / d14; + + if (d6 < 0.0D) + { + d6 *= 4.0D; + } + + double d7 = this.field_147428_e[l] / 512.0D; + double d8 = this.field_147425_f[l] / 512.0D; + double d9 = (this.field_147427_d[l] / 10.0D + 1.0D) / 2.0D; + double d10 = MathHelper.denormalizeClamp(d7, d8, d9) - d6; + + if (j2 > 29) + { + double d11 = (double)((float)(j2 - 29) / 3.0F); + d10 = d10 * (1.0D - d11) + -10.0D * d11; + } + + this.field_147434_q[l] = d10; + ++l; + } + } + } + } + + public boolean chunkExists(int par1, int par2) + { + return true; + } + + public void populate(IChunkProvider par1IChunkProvider, int par2, int par3) + { + BlockFalling.fallInstantly = true; + int k = par2 * 16; + int l = par3 * 16; + BiomeGenBase biomegenbase = this.worldObj.getBiomeGenForCoords(k + 16, l + 16); + this.rand.setSeed(this.worldObj.getSeed()); + long i1 = this.rand.nextLong() / 2L * 2L + 1L; + long j1 = this.rand.nextLong() / 2L * 2L + 1L; + this.rand.setSeed((long)par2 * i1 + (long)par3 * j1 ^ this.worldObj.getSeed()); + boolean flag = false; + + MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Pre(par1IChunkProvider, worldObj, rand, par2, par3, flag)); + + if (this.mapFeaturesEnabled) + { + this.mineshaftGenerator.generateStructuresInChunk(this.worldObj, this.rand, par2, par3); + flag = this.villageGenerator.generateStructuresInChunk(this.worldObj, this.rand, par2, par3); + this.strongholdGenerator.generateStructuresInChunk(this.worldObj, this.rand, par2, par3); + this.scatteredFeatureGenerator.generateStructuresInChunk(this.worldObj, this.rand, par2, par3); + } + + int k1; + int l1; + int i2; + + if (biomegenbase != BiomeGenBase.desert && biomegenbase != BiomeGenBase.desertHills && !flag && this.rand.nextInt(4) == 0 + && TerrainGen.populate(par1IChunkProvider, worldObj, rand, par2, par3, flag, LAKE)) + { + k1 = k + this.rand.nextInt(16) + 8; + l1 = this.rand.nextInt(256); + i2 = l + this.rand.nextInt(16) + 8; + (new WorldGenLakes(Blocks.water)).generate(this.worldObj, this.rand, k1, l1, i2); + } + + if (TerrainGen.populate(par1IChunkProvider, worldObj, rand, par2, par3, flag, LAVA) && !flag && this.rand.nextInt(8) == 0) + { + k1 = k + this.rand.nextInt(16) + 8; + l1 = this.rand.nextInt(this.rand.nextInt(248) + 8); + i2 = l + this.rand.nextInt(16) + 8; + + if (l1 < 63 || this.rand.nextInt(10) == 0) + { + (new WorldGenLakes(Blocks.lava)).generate(this.worldObj, this.rand, k1, l1, i2); + } + } + + boolean doGen = TerrainGen.populate(par1IChunkProvider, worldObj, rand, par2, par3, flag, DUNGEON); + for (k1 = 0; doGen && k1 < 8; ++k1) + { + l1 = k + this.rand.nextInt(16) + 8; + i2 = this.rand.nextInt(256); + int j2 = l + this.rand.nextInt(16) + 8; + (new WorldGenDungeons()).generate(this.worldObj, this.rand, l1, i2, j2); + } + + biomegenbase.decorate(this.worldObj, this.rand, k, l); + if (TerrainGen.populate(par1IChunkProvider, worldObj, rand, par2, par3, flag, ANIMALS)) + { + SpawnerAnimals.performWorldGenSpawning(this.worldObj, biomegenbase, k + 8, l + 8, 16, 16, this.rand); + } + k += 8; + l += 8; + + doGen = TerrainGen.populate(par1IChunkProvider, worldObj, rand, par2, par3, flag, ICE); + for (k1 = 0; doGen && k1 < 16; ++k1) + { + for (l1 = 0; l1 < 16; ++l1) + { + i2 = this.worldObj.getPrecipitationHeight(k + k1, l + l1); + + if (this.worldObj.isBlockFreezable(k1 + k, i2 - 1, l1 + l)) + { + this.worldObj.setBlock(k1 + k, i2 - 1, l1 + l, Blocks.ice, 0, 2); + } + + if (this.worldObj.func_147478_e(k1 + k, i2, l1 + l, true)) + { + this.worldObj.setBlock(k1 + k, i2, l1 + l, Blocks.snow_layer, 0, 2); + } + } + } + + MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Post(par1IChunkProvider, worldObj, rand, par2, par3, flag)); + + BlockFalling.fallInstantly = false; + } + + public boolean saveChunks(boolean par1, IProgressUpdate par2IProgressUpdate) + { + return true; + } + + public void saveExtraData() {} + + public boolean unloadQueuedChunks() + { + return false; + } + + public boolean canSave() + { + return true; + } + + public String makeString() + { + return "RandomLevelSource"; + } + + public List getPossibleCreatures(EnumCreatureType par1EnumCreatureType, int par2, int par3, int par4) + { + BiomeGenBase biomegenbase = this.worldObj.getBiomeGenForCoords(par2, par4); + return par1EnumCreatureType == EnumCreatureType.monster && this.scatteredFeatureGenerator.func_143030_a(par2, par3, par4) ? this.scatteredFeatureGenerator.getScatteredFeatureSpawnList() : biomegenbase.getSpawnableList(par1EnumCreatureType); + } + + public ChunkPosition func_147416_a(World p_147416_1_, String p_147416_2_, int p_147416_3_, int p_147416_4_, int p_147416_5_) + { + return "Stronghold".equals(p_147416_2_) && this.strongholdGenerator != null ? this.strongholdGenerator.func_151545_a(p_147416_1_, p_147416_3_, p_147416_4_, p_147416_5_) : null; + } + + public int getLoadedChunkCount() + { + return 0; + } + + public void recreateStructures(int par1, int par2) + { + if (this.mapFeaturesEnabled) + { + this.mineshaftGenerator.func_151539_a(this, this.worldObj, par1, par2, (Block[])null); + this.villageGenerator.func_151539_a(this, this.worldObj, par1, par2, (Block[])null); + this.strongholdGenerator.func_151539_a(this, this.worldObj, par1, par2, (Block[])null); + this.scatteredFeatureGenerator.func_151539_a(this, this.worldObj, par1, par2, (Block[])null); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/ChunkProviderHell.java b/src/main/java/net/minecraft/world/gen/ChunkProviderHell.java new file mode 100644 index 0000000..186e03c --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/ChunkProviderHell.java @@ -0,0 +1,584 @@ +package net.minecraft.world.gen; + +import java.util.List; +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.block.BlockFalling; +import net.minecraft.block.material.Material; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.init.Blocks; +import net.minecraft.util.IProgressUpdate; +import net.minecraft.world.ChunkPosition; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.IChunkProvider; +import net.minecraft.world.gen.feature.WorldGenFire; +import net.minecraft.world.gen.feature.WorldGenFlowers; +import net.minecraft.world.gen.feature.WorldGenGlowStone1; +import net.minecraft.world.gen.feature.WorldGenGlowStone2; +import net.minecraft.world.gen.feature.WorldGenHellLava; +import net.minecraft.world.gen.feature.WorldGenMinable; +import net.minecraft.world.gen.structure.MapGenNetherBridge; + +import static net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.*; +import static net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.*; +import static net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.*; +import static net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType.*; +import net.minecraftforge.common.*; +import cpw.mods.fml.common.eventhandler.Event.*; +import net.minecraftforge.event.terraingen.*; + +public class ChunkProviderHell implements IChunkProvider +{ + private Random hellRNG; + private NoiseGeneratorOctaves netherNoiseGen1; + private NoiseGeneratorOctaves netherNoiseGen2; + private NoiseGeneratorOctaves netherNoiseGen3; + private NoiseGeneratorOctaves slowsandGravelNoiseGen; + private NoiseGeneratorOctaves netherrackExculsivityNoiseGen; + public NoiseGeneratorOctaves netherNoiseGen6; + public NoiseGeneratorOctaves netherNoiseGen7; + private World worldObj; + private double[] noiseField; + public MapGenNetherBridge genNetherBridge = new MapGenNetherBridge(); + private double[] slowsandNoise = new double[256]; + private double[] gravelNoise = new double[256]; + private double[] netherrackExclusivityNoise = new double[256]; + private MapGenBase netherCaveGenerator = new MapGenCavesHell(); + double[] noiseData1; + double[] noiseData2; + double[] noiseData3; + double[] noiseData4; + double[] noiseData5; + private static final String __OBFID = "CL_00000392"; + + { + genNetherBridge = (MapGenNetherBridge) TerrainGen.getModdedMapGen(genNetherBridge, NETHER_BRIDGE); + netherCaveGenerator = TerrainGen.getModdedMapGen(netherCaveGenerator, NETHER_CAVE); + } + + public ChunkProviderHell(World par1World, long par2) + { + this.worldObj = par1World; + this.hellRNG = new Random(par2); + this.netherNoiseGen1 = new NoiseGeneratorOctaves(this.hellRNG, 16); + this.netherNoiseGen2 = new NoiseGeneratorOctaves(this.hellRNG, 16); + this.netherNoiseGen3 = new NoiseGeneratorOctaves(this.hellRNG, 8); + this.slowsandGravelNoiseGen = new NoiseGeneratorOctaves(this.hellRNG, 4); + this.netherrackExculsivityNoiseGen = new NoiseGeneratorOctaves(this.hellRNG, 4); + this.netherNoiseGen6 = new NoiseGeneratorOctaves(this.hellRNG, 10); + this.netherNoiseGen7 = new NoiseGeneratorOctaves(this.hellRNG, 16); + + NoiseGenerator[] noiseGens = {netherNoiseGen1, netherNoiseGen2, netherNoiseGen3, slowsandGravelNoiseGen, netherrackExculsivityNoiseGen, netherNoiseGen6, netherNoiseGen7}; + noiseGens = TerrainGen.getModdedNoiseGenerators(par1World, this.hellRNG, noiseGens); + this.netherNoiseGen1 = (NoiseGeneratorOctaves)noiseGens[0]; + this.netherNoiseGen2 = (NoiseGeneratorOctaves)noiseGens[1]; + this.netherNoiseGen3 = (NoiseGeneratorOctaves)noiseGens[2]; + this.slowsandGravelNoiseGen = (NoiseGeneratorOctaves)noiseGens[3]; + this.netherrackExculsivityNoiseGen = (NoiseGeneratorOctaves)noiseGens[4]; + this.netherNoiseGen6 = (NoiseGeneratorOctaves)noiseGens[5]; + this.netherNoiseGen7 = (NoiseGeneratorOctaves)noiseGens[6]; + } + + public void func_147419_a(int p_147419_1_, int p_147419_2_, Block[] p_147419_3_) + { + byte b0 = 4; + byte b1 = 32; + int k = b0 + 1; + byte b2 = 17; + int l = b0 + 1; + this.noiseField = this.initializeNoiseField(this.noiseField, p_147419_1_ * b0, 0, p_147419_2_ * b0, k, b2, l); + + for (int i1 = 0; i1 < b0; ++i1) + { + for (int j1 = 0; j1 < b0; ++j1) + { + for (int k1 = 0; k1 < 16; ++k1) + { + double d0 = 0.125D; + double d1 = this.noiseField[((i1 + 0) * l + j1 + 0) * b2 + k1 + 0]; + double d2 = this.noiseField[((i1 + 0) * l + j1 + 1) * b2 + k1 + 0]; + double d3 = this.noiseField[((i1 + 1) * l + j1 + 0) * b2 + k1 + 0]; + double d4 = this.noiseField[((i1 + 1) * l + j1 + 1) * b2 + k1 + 0]; + double d5 = (this.noiseField[((i1 + 0) * l + j1 + 0) * b2 + k1 + 1] - d1) * d0; + double d6 = (this.noiseField[((i1 + 0) * l + j1 + 1) * b2 + k1 + 1] - d2) * d0; + double d7 = (this.noiseField[((i1 + 1) * l + j1 + 0) * b2 + k1 + 1] - d3) * d0; + double d8 = (this.noiseField[((i1 + 1) * l + j1 + 1) * b2 + k1 + 1] - d4) * d0; + + for (int l1 = 0; l1 < 8; ++l1) + { + double d9 = 0.25D; + double d10 = d1; + double d11 = d2; + double d12 = (d3 - d1) * d9; + double d13 = (d4 - d2) * d9; + + for (int i2 = 0; i2 < 4; ++i2) + { + int j2 = i2 + i1 * 4 << 11 | 0 + j1 * 4 << 7 | k1 * 8 + l1; + short short1 = 128; + double d14 = 0.25D; + double d15 = d10; + double d16 = (d11 - d10) * d14; + + for (int k2 = 0; k2 < 4; ++k2) + { + Block block = null; + + if (k1 * 8 + l1 < b1) + { + block = Blocks.lava; + } + + if (d15 > 0.0D) + { + block = Blocks.netherrack; + } + + p_147419_3_[j2] = block; + j2 += short1; + d15 += d16; + } + + d10 += d12; + d11 += d13; + } + + d1 += d5; + d2 += d6; + d3 += d7; + d4 += d8; + } + } + } + } + } + + public void func_147418_b(int p_147418_1_, int p_147418_2_, Block[] p_147418_3_) + { + ChunkProviderEvent.ReplaceBiomeBlocks event = new ChunkProviderEvent.ReplaceBiomeBlocks(this, p_147418_1_, p_147418_2_, p_147418_3_, null); + MinecraftForge.EVENT_BUS.post(event); + if (event.getResult() == Result.DENY) return; + + byte b0 = 64; + double d0 = 0.03125D; + this.slowsandNoise = this.slowsandGravelNoiseGen.generateNoiseOctaves(this.slowsandNoise, p_147418_1_ * 16, p_147418_2_ * 16, 0, 16, 16, 1, d0, d0, 1.0D); + this.gravelNoise = this.slowsandGravelNoiseGen.generateNoiseOctaves(this.gravelNoise, p_147418_1_ * 16, 109, p_147418_2_ * 16, 16, 1, 16, d0, 1.0D, d0); + this.netherrackExclusivityNoise = this.netherrackExculsivityNoiseGen.generateNoiseOctaves(this.netherrackExclusivityNoise, p_147418_1_ * 16, p_147418_2_ * 16, 0, 16, 16, 1, d0 * 2.0D, d0 * 2.0D, d0 * 2.0D); + + for (int k = 0; k < 16; ++k) + { + for (int l = 0; l < 16; ++l) + { + boolean flag = this.slowsandNoise[k + l * 16] + this.hellRNG.nextDouble() * 0.2D > 0.0D; + boolean flag1 = this.gravelNoise[k + l * 16] + this.hellRNG.nextDouble() * 0.2D > 0.0D; + int i1 = (int)(this.netherrackExclusivityNoise[k + l * 16] / 3.0D + 3.0D + this.hellRNG.nextDouble() * 0.25D); + int j1 = -1; + Block block = Blocks.netherrack; + Block block1 = Blocks.netherrack; + + for (int k1 = 127; k1 >= 0; --k1) + { + int l1 = (l * 16 + k) * 128 + k1; + + if (k1 < 127 - this.hellRNG.nextInt(5) && k1 > 0 + this.hellRNG.nextInt(5)) + { + Block block2 = p_147418_3_[l1]; + + if (block2 != null && block2.getMaterial() != Material.air) + { + if (block2 == Blocks.netherrack) + { + if (j1 == -1) + { + if (i1 <= 0) + { + block = null; + block1 = Blocks.netherrack; + } + else if (k1 >= b0 - 4 && k1 <= b0 + 1) + { + block = Blocks.netherrack; + block1 = Blocks.netherrack; + + if (flag1) + { + block = Blocks.gravel; + block1 = Blocks.netherrack; + } + + if (flag) + { + block = Blocks.soul_sand; + block1 = Blocks.soul_sand; + } + } + + if (k1 < b0 && (block == null || block.getMaterial() == Material.air)) + { + block = Blocks.lava; + } + + j1 = i1; + + if (k1 >= b0 - 1) + { + p_147418_3_[l1] = block; + } + else + { + p_147418_3_[l1] = block1; + } + } + else if (j1 > 0) + { + --j1; + p_147418_3_[l1] = block1; + } + } + } + else + { + j1 = -1; + } + } + else + { + p_147418_3_[l1] = Blocks.bedrock; + } + } + } + } + } + + public Chunk loadChunk(int par1, int par2) + { + return this.provideChunk(par1, par2); + } + + public Chunk provideChunk(int par1, int par2) + { + this.hellRNG.setSeed((long)par1 * 341873128712L + (long)par2 * 132897987541L); + Block[] ablock = new Block[32768]; + this.func_147419_a(par1, par2, ablock); + this.func_147418_b(par1, par2, ablock); + this.netherCaveGenerator.func_151539_a(this, this.worldObj, par1, par2, ablock); + this.genNetherBridge.func_151539_a(this, this.worldObj, par1, par2, ablock); + Chunk chunk = new Chunk(this.worldObj, ablock, par1, par2); + BiomeGenBase[] abiomegenbase = this.worldObj.getWorldChunkManager().loadBlockGeneratorData((BiomeGenBase[])null, par1 * 16, par2 * 16, 16, 16); + byte[] abyte = chunk.getBiomeArray(); + + for (int k = 0; k < abyte.length; ++k) + { + abyte[k] = (byte)abiomegenbase[k].biomeID; + } + + chunk.resetRelightChecks(); + return chunk; + } + + private double[] initializeNoiseField(double[] par1ArrayOfDouble, int par2, int par3, int par4, int par5, int par6, int par7) + { + ChunkProviderEvent.InitNoiseField event = new ChunkProviderEvent.InitNoiseField(this, par1ArrayOfDouble, par2, par3, par4, par5, par6, par7); + MinecraftForge.EVENT_BUS.post(event); + if (event.getResult() == Result.DENY) return event.noisefield; + + if (par1ArrayOfDouble == null) + { + par1ArrayOfDouble = new double[par5 * par6 * par7]; + } + + double d0 = 684.412D; + double d1 = 2053.236D; + this.noiseData4 = this.netherNoiseGen6.generateNoiseOctaves(this.noiseData4, par2, par3, par4, par5, 1, par7, 1.0D, 0.0D, 1.0D); + this.noiseData5 = this.netherNoiseGen7.generateNoiseOctaves(this.noiseData5, par2, par3, par4, par5, 1, par7, 100.0D, 0.0D, 100.0D); + this.noiseData1 = this.netherNoiseGen3.generateNoiseOctaves(this.noiseData1, par2, par3, par4, par5, par6, par7, d0 / 80.0D, d1 / 60.0D, d0 / 80.0D); + this.noiseData2 = this.netherNoiseGen1.generateNoiseOctaves(this.noiseData2, par2, par3, par4, par5, par6, par7, d0, d1, d0); + this.noiseData3 = this.netherNoiseGen2.generateNoiseOctaves(this.noiseData3, par2, par3, par4, par5, par6, par7, d0, d1, d0); + int k1 = 0; + int l1 = 0; + double[] adouble1 = new double[par6]; + int i2; + + for (i2 = 0; i2 < par6; ++i2) + { + adouble1[i2] = Math.cos((double)i2 * Math.PI * 6.0D / (double)par6) * 2.0D; + double d2 = (double)i2; + + if (i2 > par6 / 2) + { + d2 = (double)(par6 - 1 - i2); + } + + if (d2 < 4.0D) + { + d2 = 4.0D - d2; + adouble1[i2] -= d2 * d2 * d2 * 10.0D; + } + } + + for (i2 = 0; i2 < par5; ++i2) + { + for (int k2 = 0; k2 < par7; ++k2) + { + double d3 = (this.noiseData4[l1] + 256.0D) / 512.0D; + + if (d3 > 1.0D) + { + d3 = 1.0D; + } + + double d4 = 0.0D; + double d5 = this.noiseData5[l1] / 8000.0D; + + if (d5 < 0.0D) + { + d5 = -d5; + } + + d5 = d5 * 3.0D - 3.0D; + + if (d5 < 0.0D) + { + d5 /= 2.0D; + + if (d5 < -1.0D) + { + d5 = -1.0D; + } + + d5 /= 1.4D; + d5 /= 2.0D; + d3 = 0.0D; + } + else + { + if (d5 > 1.0D) + { + d5 = 1.0D; + } + + d5 /= 6.0D; + } + + d3 += 0.5D; + d5 = d5 * (double)par6 / 16.0D; + ++l1; + + for (int j2 = 0; j2 < par6; ++j2) + { + double d6 = 0.0D; + double d7 = adouble1[j2]; + double d8 = this.noiseData2[k1] / 512.0D; + double d9 = this.noiseData3[k1] / 512.0D; + double d10 = (this.noiseData1[k1] / 10.0D + 1.0D) / 2.0D; + + if (d10 < 0.0D) + { + d6 = d8; + } + else if (d10 > 1.0D) + { + d6 = d9; + } + else + { + d6 = d8 + (d9 - d8) * d10; + } + + d6 -= d7; + double d11; + + if (j2 > par6 - 4) + { + d11 = (double)((float)(j2 - (par6 - 4)) / 3.0F); + d6 = d6 * (1.0D - d11) + -10.0D * d11; + } + + if ((double)j2 < d4) + { + d11 = (d4 - (double)j2) / 4.0D; + + if (d11 < 0.0D) + { + d11 = 0.0D; + } + + if (d11 > 1.0D) + { + d11 = 1.0D; + } + + d6 = d6 * (1.0D - d11) + -10.0D * d11; + } + + par1ArrayOfDouble[k1] = d6; + ++k1; + } + } + } + + return par1ArrayOfDouble; + } + + public boolean chunkExists(int par1, int par2) + { + return true; + } + + public void populate(IChunkProvider par1IChunkProvider, int par2, int par3) + { + BlockFalling.fallInstantly = true; + + MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Pre(par1IChunkProvider, worldObj, hellRNG, par2, par3, false)); + + int k = par2 * 16; + int l = par3 * 16; + this.genNetherBridge.generateStructuresInChunk(this.worldObj, this.hellRNG, par2, par3); + int i1; + int j1; + int k1; + int l1; + + boolean doGen = TerrainGen.populate(par1IChunkProvider, worldObj, hellRNG, par2, par3, false, NETHER_LAVA); + for (i1 = 0; doGen && i1 < 8; ++i1) + { + j1 = k + this.hellRNG.nextInt(16) + 8; + k1 = this.hellRNG.nextInt(120) + 4; + l1 = l + this.hellRNG.nextInt(16) + 8; + (new WorldGenHellLava(Blocks.flowing_lava, false)).generate(this.worldObj, this.hellRNG, j1, k1, l1); + } + + i1 = this.hellRNG.nextInt(this.hellRNG.nextInt(10) + 1) + 1; + int i2; + + doGen = TerrainGen.populate(par1IChunkProvider, worldObj, hellRNG, par2, par3, false, FIRE); + for (j1 = 0; doGen && j1 < i1; ++j1) + { + k1 = k + this.hellRNG.nextInt(16) + 8; + l1 = this.hellRNG.nextInt(120) + 4; + i2 = l + this.hellRNG.nextInt(16) + 8; + (new WorldGenFire()).generate(this.worldObj, this.hellRNG, k1, l1, i2); + } + + i1 = this.hellRNG.nextInt(this.hellRNG.nextInt(10) + 1); + + doGen = TerrainGen.populate(par1IChunkProvider, worldObj, hellRNG, par2, par3, false, GLOWSTONE); + for (j1 = 0; doGen && j1 < i1; ++j1) + { + k1 = k + this.hellRNG.nextInt(16) + 8; + l1 = this.hellRNG.nextInt(120) + 4; + i2 = l + this.hellRNG.nextInt(16) + 8; + (new WorldGenGlowStone1()).generate(this.worldObj, this.hellRNG, k1, l1, i2); + } + + for (j1 = 0; doGen && j1 < 10; ++j1) + { + k1 = k + this.hellRNG.nextInt(16) + 8; + l1 = this.hellRNG.nextInt(128); + i2 = l + this.hellRNG.nextInt(16) + 8; + (new WorldGenGlowStone2()).generate(this.worldObj, this.hellRNG, k1, l1, i2); + } + + MinecraftForge.EVENT_BUS.post(new DecorateBiomeEvent.Pre(worldObj, hellRNG, k, l)); + + doGen = TerrainGen.decorate(worldObj, hellRNG, k, l, SHROOM); + if (doGen && this.hellRNG.nextInt(1) == 0) + { + j1 = k + this.hellRNG.nextInt(16) + 8; + k1 = this.hellRNG.nextInt(128); + l1 = l + this.hellRNG.nextInt(16) + 8; + (new WorldGenFlowers(Blocks.brown_mushroom)).generate(this.worldObj, this.hellRNG, j1, k1, l1); + } + + if (doGen && this.hellRNG.nextInt(1) == 0) + { + j1 = k + this.hellRNG.nextInt(16) + 8; + k1 = this.hellRNG.nextInt(128); + l1 = l + this.hellRNG.nextInt(16) + 8; + (new WorldGenFlowers(Blocks.red_mushroom)).generate(this.worldObj, this.hellRNG, j1, k1, l1); + } + + WorldGenMinable worldgenminable = new WorldGenMinable(Blocks.quartz_ore, 13, Blocks.netherrack); + int j2; + + doGen = TerrainGen.generateOre(worldObj, hellRNG, worldgenminable, k, l, QUARTZ); + for (k1 = 0; doGen && k1 < 16; ++k1) + { + l1 = k + this.hellRNG.nextInt(16); + i2 = this.hellRNG.nextInt(108) + 10; + j2 = l + this.hellRNG.nextInt(16); + worldgenminable.generate(this.worldObj, this.hellRNG, l1, i2, j2); + } + + for (k1 = 0; k1 < 16; ++k1) + { + l1 = k + this.hellRNG.nextInt(16); + i2 = this.hellRNG.nextInt(108) + 10; + j2 = l + this.hellRNG.nextInt(16); + (new WorldGenHellLava(Blocks.flowing_lava, true)).generate(this.worldObj, this.hellRNG, l1, i2, j2); + } + + MinecraftForge.EVENT_BUS.post(new DecorateBiomeEvent.Post(worldObj, hellRNG, k, l)); + MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Post(par1IChunkProvider, worldObj, hellRNG, par2, par3, false)); + + BlockFalling.fallInstantly = false; + } + + public boolean saveChunks(boolean par1, IProgressUpdate par2IProgressUpdate) + { + return true; + } + + public void saveExtraData() {} + + public boolean unloadQueuedChunks() + { + return false; + } + + public boolean canSave() + { + return true; + } + + public String makeString() + { + return "HellRandomLevelSource"; + } + + public List getPossibleCreatures(EnumCreatureType par1EnumCreatureType, int par2, int par3, int par4) + { + if (par1EnumCreatureType == EnumCreatureType.monster) + { + if (this.genNetherBridge.hasStructureAt(par2, par3, par4)) + { + return this.genNetherBridge.getSpawnList(); + } + + if (this.genNetherBridge.func_142038_b(par2, par3, par4) && this.worldObj.getBlock(par2, par3 - 1, par4) == Blocks.nether_brick) + { + return this.genNetherBridge.getSpawnList(); + } + } + + BiomeGenBase biomegenbase = this.worldObj.getBiomeGenForCoords(par2, par4); + return biomegenbase.getSpawnableList(par1EnumCreatureType); + } + + public ChunkPosition func_147416_a(World p_147416_1_, String p_147416_2_, int p_147416_3_, int p_147416_4_, int p_147416_5_) + { + return null; + } + + public int getLoadedChunkCount() + { + return 0; + } + + public void recreateStructures(int par1, int par2) + { + this.genNetherBridge.func_151539_a(this, this.worldObj, par1, par2, (Block[])null); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/ChunkProviderServer.java b/src/main/java/net/minecraft/world/gen/ChunkProviderServer.java new file mode 100644 index 0000000..1027427 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/ChunkProviderServer.java @@ -0,0 +1,327 @@ +package net.minecraft.world.gen; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import cpw.mods.fml.common.registry.GameRegistry; +import net.minecraft.crash.CrashReport; +import net.minecraft.crash.CrashReportCategory; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.IProgressUpdate; +import net.minecraft.util.LongHashMap; +import net.minecraft.util.ReportedException; +import net.minecraft.world.ChunkCoordIntPair; +import net.minecraft.world.ChunkPosition; +import net.minecraft.world.MinecraftException; +import net.minecraft.world.World; +import net.minecraft.world.WorldServer; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.EmptyChunk; +import net.minecraft.world.chunk.IChunkProvider; +import net.minecraft.world.chunk.storage.IChunkLoader; +import net.minecraftforge.common.DimensionManager; +import net.minecraftforge.common.ForgeChunkManager; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class ChunkProviderServer implements IChunkProvider +{ + private static final Logger logger = LogManager.getLogger(); + private Set chunksToUnload = new HashSet(); + private Chunk defaultEmptyChunk; + private IChunkProvider currentChunkProvider; + public IChunkLoader currentChunkLoader; + public boolean loadChunkOnProvideRequest = true; + private LongHashMap loadedChunkHashMap = new LongHashMap(); + private List loadedChunks = new ArrayList(); + private WorldServer worldObj; + private static final String __OBFID = "CL_00001436"; + + public ChunkProviderServer(WorldServer par1WorldServer, IChunkLoader par2IChunkLoader, IChunkProvider par3IChunkProvider) + { + this.defaultEmptyChunk = new EmptyChunk(par1WorldServer, 0, 0); + this.worldObj = par1WorldServer; + this.currentChunkLoader = par2IChunkLoader; + this.currentChunkProvider = par3IChunkProvider; + } + + public boolean chunkExists(int par1, int par2) + { + return this.loadedChunkHashMap.containsItem(ChunkCoordIntPair.chunkXZ2Int(par1, par2)); + } + + public void unloadChunksIfNotNearSpawn(int par1, int par2) + { + if (this.worldObj.provider.canRespawnHere() && DimensionManager.shouldLoadSpawn(this.worldObj.provider.dimensionId)) + { + ChunkCoordinates chunkcoordinates = this.worldObj.getSpawnPoint(); + int k = par1 * 16 + 8 - chunkcoordinates.posX; + int l = par2 * 16 + 8 - chunkcoordinates.posZ; + short short1 = 128; + + if (k < -short1 || k > short1 || l < -short1 || l > short1) + { + this.chunksToUnload.add(Long.valueOf(ChunkCoordIntPair.chunkXZ2Int(par1, par2))); + } + } + else + { + this.chunksToUnload.add(Long.valueOf(ChunkCoordIntPair.chunkXZ2Int(par1, par2))); + } + } + + public void unloadAllChunks() + { + Iterator iterator = this.loadedChunks.iterator(); + + while (iterator.hasNext()) + { + Chunk chunk = (Chunk)iterator.next(); + this.unloadChunksIfNotNearSpawn(chunk.xPosition, chunk.zPosition); + } + } + + public Chunk loadChunk(int par1, int par2) + { + long k = ChunkCoordIntPair.chunkXZ2Int(par1, par2); + this.chunksToUnload.remove(Long.valueOf(k)); + Chunk chunk = (Chunk)this.loadedChunkHashMap.getValueByKey(k); + + if (chunk == null) + { + chunk = ForgeChunkManager.fetchDormantChunk(k, this.worldObj); + if (chunk == null) + { + chunk = this.safeLoadChunk(par1, par2); + } + + if (chunk == null) + { + if (this.currentChunkProvider == null) + { + chunk = this.defaultEmptyChunk; + } + else + { + try + { + chunk = this.currentChunkProvider.provideChunk(par1, par2); + } + catch (Throwable throwable) + { + CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Exception generating new chunk"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("Chunk to be generated"); + crashreportcategory.addCrashSection("Location", String.format("%d,%d", new Object[] {Integer.valueOf(par1), Integer.valueOf(par2)})); + crashreportcategory.addCrashSection("Position hash", Long.valueOf(k)); + crashreportcategory.addCrashSection("Generator", this.currentChunkProvider.makeString()); + throw new ReportedException(crashreport); + } + } + } + + this.loadedChunkHashMap.add(k, chunk); + this.loadedChunks.add(chunk); + chunk.onChunkLoad(); + chunk.populateChunk(this, this, par1, par2); + } + + return chunk; + } + + public Chunk provideChunk(int par1, int par2) + { + Chunk chunk = (Chunk)this.loadedChunkHashMap.getValueByKey(ChunkCoordIntPair.chunkXZ2Int(par1, par2)); + return chunk == null ? (!this.worldObj.findingSpawnPoint && !this.loadChunkOnProvideRequest ? this.defaultEmptyChunk : this.loadChunk(par1, par2)) : chunk; + } + + private Chunk safeLoadChunk(int par1, int par2) + { + if (this.currentChunkLoader == null) + { + return null; + } + else + { + try + { + Chunk chunk = this.currentChunkLoader.loadChunk(this.worldObj, par1, par2); + + if (chunk != null) + { + chunk.lastSaveTime = this.worldObj.getTotalWorldTime(); + + if (this.currentChunkProvider != null) + { + this.currentChunkProvider.recreateStructures(par1, par2); + } + } + + return chunk; + } + catch (Exception exception) + { + logger.error("Couldn\'t load chunk", exception); + return null; + } + } + } + + private void safeSaveExtraChunkData(Chunk par1Chunk) + { + if (this.currentChunkLoader != null) + { + try + { + this.currentChunkLoader.saveExtraChunkData(this.worldObj, par1Chunk); + } + catch (Exception exception) + { + logger.error("Couldn\'t save entities", exception); + } + } + } + + private void safeSaveChunk(Chunk par1Chunk) + { + if (this.currentChunkLoader != null) + { + try + { + par1Chunk.lastSaveTime = this.worldObj.getTotalWorldTime(); + this.currentChunkLoader.saveChunk(this.worldObj, par1Chunk); + } + catch (IOException ioexception) + { + logger.error("Couldn\'t save chunk", ioexception); + } + catch (MinecraftException minecraftexception) + { + logger.error("Couldn\'t save chunk; already in use by another instance of Minecraft?", minecraftexception); + } + } + } + + public void populate(IChunkProvider par1IChunkProvider, int par2, int par3) + { + Chunk chunk = this.provideChunk(par2, par3); + + if (!chunk.isTerrainPopulated) + { + chunk.func_150809_p(); + + if (this.currentChunkProvider != null) + { + this.currentChunkProvider.populate(par1IChunkProvider, par2, par3); + GameRegistry.generateWorld(par2, par3, worldObj, currentChunkProvider, par1IChunkProvider); + chunk.setChunkModified(); + } + } + } + + public boolean saveChunks(boolean par1, IProgressUpdate par2IProgressUpdate) + { + int i = 0; + + for (int j = 0; j < this.loadedChunks.size(); ++j) + { + Chunk chunk = (Chunk)this.loadedChunks.get(j); + + if (par1) + { + this.safeSaveExtraChunkData(chunk); + } + + if (chunk.needsSaving(par1)) + { + this.safeSaveChunk(chunk); + chunk.isModified = false; + ++i; + + if (i == 24 && !par1) + { + return false; + } + } + } + + return true; + } + + public void saveExtraData() + { + if (this.currentChunkLoader != null) + { + this.currentChunkLoader.saveExtraData(); + } + } + + public boolean unloadQueuedChunks() + { + if (!this.worldObj.levelSaving) + { + for (ChunkCoordIntPair forced : this.worldObj.getPersistentChunks().keySet()) + { + this.chunksToUnload.remove(ChunkCoordIntPair.chunkXZ2Int(forced.chunkXPos, forced.chunkZPos)); + } + + for (int i = 0; i < 100; ++i) + { + if (!this.chunksToUnload.isEmpty()) + { + Long olong = (Long)this.chunksToUnload.iterator().next(); + Chunk chunk = (Chunk)this.loadedChunkHashMap.getValueByKey(olong.longValue()); + chunk.onChunkUnload(); + this.safeSaveChunk(chunk); + this.safeSaveExtraChunkData(chunk); + this.chunksToUnload.remove(olong); + this.loadedChunkHashMap.remove(olong.longValue()); + this.loadedChunks.remove(chunk); + ForgeChunkManager.putDormantChunk(ChunkCoordIntPair.chunkXZ2Int(chunk.xPosition, chunk.zPosition), chunk); + if(loadedChunks.size() == 0 && ForgeChunkManager.getPersistentChunksFor(this.worldObj).size() == 0 && !DimensionManager.shouldLoadSpawn(this.worldObj.provider.dimensionId)){ + DimensionManager.unloadWorld(this.worldObj.provider.dimensionId); + return currentChunkProvider.unloadQueuedChunks(); + } + } + } + + if (this.currentChunkLoader != null) + { + this.currentChunkLoader.chunkTick(); + } + } + + return this.currentChunkProvider.unloadQueuedChunks(); + } + + public boolean canSave() + { + return !this.worldObj.levelSaving; + } + + public String makeString() + { + return "ServerChunkCache: " + this.loadedChunkHashMap.getNumHashElements() + " Drop: " + this.chunksToUnload.size(); + } + + public List getPossibleCreatures(EnumCreatureType par1EnumCreatureType, int par2, int par3, int par4) + { + return this.currentChunkProvider.getPossibleCreatures(par1EnumCreatureType, par2, par3, par4); + } + + public ChunkPosition func_147416_a(World p_147416_1_, String p_147416_2_, int p_147416_3_, int p_147416_4_, int p_147416_5_) + { + return this.currentChunkProvider.func_147416_a(p_147416_1_, p_147416_2_, p_147416_3_, p_147416_4_, p_147416_5_); + } + + public int getLoadedChunkCount() + { + return this.loadedChunkHashMap.getNumHashElements(); + } + + public void recreateStructures(int par1, int par2) {} +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/FlatGeneratorInfo.java b/src/main/java/net/minecraft/world/gen/FlatGeneratorInfo.java new file mode 100644 index 0000000..e1e734d --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/FlatGeneratorInfo.java @@ -0,0 +1,310 @@ +package net.minecraft.world.gen; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.util.MathHelper; +import net.minecraft.world.biome.BiomeGenBase; + +public class FlatGeneratorInfo +{ + private final List flatLayers = new ArrayList(); + private final Map worldFeatures = new HashMap(); + private int biomeToUse; + private static final String __OBFID = "CL_00000440"; + + public int getBiome() + { + return this.biomeToUse; + } + + public void setBiome(int par1) + { + this.biomeToUse = par1; + } + + public Map getWorldFeatures() + { + return this.worldFeatures; + } + + public List getFlatLayers() + { + return this.flatLayers; + } + + public void func_82645_d() + { + int i = 0; + FlatLayerInfo flatlayerinfo; + + for (Iterator iterator = this.flatLayers.iterator(); iterator.hasNext(); i += flatlayerinfo.getLayerCount()) + { + flatlayerinfo = (FlatLayerInfo)iterator.next(); + flatlayerinfo.setMinY(i); + } + } + + public String toString() + { + StringBuilder stringbuilder = new StringBuilder(); + stringbuilder.append(2); + stringbuilder.append(";"); + int i; + + for (i = 0; i < this.flatLayers.size(); ++i) + { + if (i > 0) + { + stringbuilder.append(","); + } + + stringbuilder.append(((FlatLayerInfo)this.flatLayers.get(i)).toString()); + } + + stringbuilder.append(";"); + stringbuilder.append(this.biomeToUse); + + if (!this.worldFeatures.isEmpty()) + { + stringbuilder.append(";"); + i = 0; + Iterator iterator = this.worldFeatures.entrySet().iterator(); + + while (iterator.hasNext()) + { + Entry entry = (Entry)iterator.next(); + + if (i++ > 0) + { + stringbuilder.append(","); + } + + stringbuilder.append(((String)entry.getKey()).toLowerCase()); + Map map = (Map)entry.getValue(); + + if (!map.isEmpty()) + { + stringbuilder.append("("); + int j = 0; + Iterator iterator1 = map.entrySet().iterator(); + + while (iterator1.hasNext()) + { + Entry entry1 = (Entry)iterator1.next(); + + if (j++ > 0) + { + stringbuilder.append(" "); + } + + stringbuilder.append((String)entry1.getKey()); + stringbuilder.append("="); + stringbuilder.append((String)entry1.getValue()); + } + + stringbuilder.append(")"); + } + } + } + else + { + stringbuilder.append(";"); + } + + return stringbuilder.toString(); + } + + private static FlatLayerInfo func_82646_a(String par0Str, int par1) + { + String[] astring = par0Str.split("x", 2); + int j = 1; + int l = 0; + + if (astring.length == 2) + { + try + { + j = Integer.parseInt(astring[0]); + + if (par1 + j >= 256) + { + j = 256 - par1; + } + + if (j < 0) + { + j = 0; + } + } + catch (Throwable throwable) + { + return null; + } + } + + int k; + + try + { + String s1 = astring[astring.length - 1]; + astring = s1.split(":", 2); + k = Integer.parseInt(astring[0]); + + if (astring.length > 1) + { + l = Integer.parseInt(astring[1]); + } + + if (Block.getBlockById(k) == Blocks.air) + { + k = 0; + l = 0; + } + + if (l < 0 || l > 15) + { + l = 0; + } + } + catch (Throwable throwable1) + { + return null; + } + + FlatLayerInfo flatlayerinfo = new FlatLayerInfo(j, Block.getBlockById(k), l); + flatlayerinfo.setMinY(par1); + return flatlayerinfo; + } + + private static List func_82652_b(String par0Str) + { + if (par0Str != null && par0Str.length() >= 1) + { + ArrayList arraylist = new ArrayList(); + String[] astring = par0Str.split(","); + int i = 0; + String[] astring1 = astring; + int j = astring.length; + + for (int k = 0; k < j; ++k) + { + String s1 = astring1[k]; + FlatLayerInfo flatlayerinfo = func_82646_a(s1, i); + + if (flatlayerinfo == null) + { + return null; + } + + arraylist.add(flatlayerinfo); + i += flatlayerinfo.getLayerCount(); + } + + return arraylist; + } + else + { + return null; + } + } + + public static FlatGeneratorInfo createFlatGeneratorFromString(String par0Str) + { + if (par0Str == null) + { + return getDefaultFlatGenerator(); + } + else + { + String[] astring = par0Str.split(";", -1); + int i = astring.length == 1 ? 0 : MathHelper.parseIntWithDefault(astring[0], 0); + + if (i >= 0 && i <= 2) + { + FlatGeneratorInfo flatgeneratorinfo = new FlatGeneratorInfo(); + int j = astring.length == 1 ? 0 : 1; + List list = func_82652_b(astring[j++]); + + if (list != null && !list.isEmpty()) + { + flatgeneratorinfo.getFlatLayers().addAll(list); + flatgeneratorinfo.func_82645_d(); + int k = BiomeGenBase.plains.biomeID; + + if (i > 0 && astring.length > j) + { + k = MathHelper.parseIntWithDefault(astring[j++], k); + } + + flatgeneratorinfo.setBiome(k); + + if (i > 0 && astring.length > j) + { + String[] astring1 = astring[j++].toLowerCase().split(","); + String[] astring2 = astring1; + int l = astring1.length; + + for (int i1 = 0; i1 < l; ++i1) + { + String s1 = astring2[i1]; + String[] astring3 = s1.split("\\(", 2); + HashMap hashmap = new HashMap(); + + if (astring3[0].length() > 0) + { + flatgeneratorinfo.getWorldFeatures().put(astring3[0], hashmap); + + if (astring3.length > 1 && astring3[1].endsWith(")") && astring3[1].length() > 1) + { + String[] astring4 = astring3[1].substring(0, astring3[1].length() - 1).split(" "); + + for (int j1 = 0; j1 < astring4.length; ++j1) + { + String[] astring5 = astring4[j1].split("=", 2); + + if (astring5.length == 2) + { + hashmap.put(astring5[0], astring5[1]); + } + } + } + } + } + } + else + { + flatgeneratorinfo.getWorldFeatures().put("village", new HashMap()); + } + + return flatgeneratorinfo; + } + else + { + return getDefaultFlatGenerator(); + } + } + else + { + return getDefaultFlatGenerator(); + } + } + } + + public static FlatGeneratorInfo getDefaultFlatGenerator() + { + FlatGeneratorInfo flatgeneratorinfo = new FlatGeneratorInfo(); + flatgeneratorinfo.setBiome(BiomeGenBase.plains.biomeID); + flatgeneratorinfo.getFlatLayers().add(new FlatLayerInfo(1, Blocks.bedrock)); + flatgeneratorinfo.getFlatLayers().add(new FlatLayerInfo(2, Blocks.dirt)); + flatgeneratorinfo.getFlatLayers().add(new FlatLayerInfo(1, Blocks.grass)); + flatgeneratorinfo.func_82645_d(); + flatgeneratorinfo.getWorldFeatures().put("village", new HashMap()); + return flatgeneratorinfo; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/FlatLayerInfo.java b/src/main/java/net/minecraft/world/gen/FlatLayerInfo.java new file mode 100644 index 0000000..3247ed8 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/FlatLayerInfo.java @@ -0,0 +1,67 @@ +package net.minecraft.world.gen; + +import net.minecraft.block.Block; + +public class FlatLayerInfo +{ + private Block field_151537_a; + private int layerCount; + private int layerFillBlockMeta; + private int layerMinimumY; + private static final String __OBFID = "CL_00000441"; + + public FlatLayerInfo(int p_i45467_1_, Block p_i45467_2_) + { + this.layerCount = 1; + this.layerCount = p_i45467_1_; + this.field_151537_a = p_i45467_2_; + } + + public FlatLayerInfo(int p_i45468_1_, Block p_i45468_2_, int p_i45468_3_) + { + this(p_i45468_1_, p_i45468_2_); + this.layerFillBlockMeta = p_i45468_3_; + } + + public int getLayerCount() + { + return this.layerCount; + } + + public Block func_151536_b() + { + return this.field_151537_a; + } + + public int getFillBlockMeta() + { + return this.layerFillBlockMeta; + } + + public int getMinY() + { + return this.layerMinimumY; + } + + public void setMinY(int par1) + { + this.layerMinimumY = par1; + } + + public String toString() + { + String s = Integer.toString(Block.getIdFromBlock(this.field_151537_a)); + + if (this.layerCount > 1) + { + s = this.layerCount + "x" + s; + } + + if (this.layerFillBlockMeta > 0) + { + s = s + ":" + this.layerFillBlockMeta; + } + + return s; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/MapGenBase.java b/src/main/java/net/minecraft/world/gen/MapGenBase.java new file mode 100644 index 0000000..12bee6d --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/MapGenBase.java @@ -0,0 +1,36 @@ +package net.minecraft.world.gen; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.world.World; +import net.minecraft.world.chunk.IChunkProvider; + +public class MapGenBase +{ + protected int range = 8; + protected Random rand = new Random(); + protected World worldObj; + private static final String __OBFID = "CL_00000394"; + + public void func_151539_a(IChunkProvider p_151539_1_, World p_151539_2_, int p_151539_3_, int p_151539_4_, Block[] p_151539_5_) + { + int k = this.range; + this.worldObj = p_151539_2_; + this.rand.setSeed(p_151539_2_.getSeed()); + long l = this.rand.nextLong(); + long i1 = this.rand.nextLong(); + + for (int j1 = p_151539_3_ - k; j1 <= p_151539_3_ + k; ++j1) + { + for (int k1 = p_151539_4_ - k; k1 <= p_151539_4_ + k; ++k1) + { + long l1 = (long)j1 * l; + long i2 = (long)k1 * i1; + this.rand.setSeed(l1 ^ i2 ^ p_151539_2_.getSeed()); + this.func_151538_a(p_151539_2_, j1, k1, p_151539_3_, p_151539_4_, p_151539_5_); + } + } + } + + protected void func_151538_a(World p_151538_1_, int p_151538_2_, int p_151538_3_, int p_151538_4_, int p_151538_5_, Block[] p_151538_6_) {} +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/MapGenCaves.java b/src/main/java/net/minecraft/world/gen/MapGenCaves.java new file mode 100644 index 0000000..c8a7bd1 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/MapGenCaves.java @@ -0,0 +1,301 @@ +package net.minecraft.world.gen; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; + +public class MapGenCaves extends MapGenBase +{ + private static final String __OBFID = "CL_00000393"; + + protected void func_151542_a(long p_151542_1_, int p_151542_3_, int p_151542_4_, Block[] p_151542_5_, double p_151542_6_, double p_151542_8_, double p_151542_10_) + { + this.func_151541_a(p_151542_1_, p_151542_3_, p_151542_4_, p_151542_5_, p_151542_6_, p_151542_8_, p_151542_10_, 1.0F + this.rand.nextFloat() * 6.0F, 0.0F, 0.0F, -1, -1, 0.5D); + } + + protected void func_151541_a(long p_151541_1_, int p_151541_3_, int p_151541_4_, Block[] p_151541_5_, double p_151541_6_, double p_151541_8_, double p_151541_10_, float p_151541_12_, float p_151541_13_, float p_151541_14_, int p_151541_15_, int p_151541_16_, double p_151541_17_) + { + double d4 = (double)(p_151541_3_ * 16 + 8); + double d5 = (double)(p_151541_4_ * 16 + 8); + float f3 = 0.0F; + float f4 = 0.0F; + Random random = new Random(p_151541_1_); + + if (p_151541_16_ <= 0) + { + int j1 = this.range * 16 - 16; + p_151541_16_ = j1 - random.nextInt(j1 / 4); + } + + boolean flag2 = false; + + if (p_151541_15_ == -1) + { + p_151541_15_ = p_151541_16_ / 2; + flag2 = true; + } + + int k1 = random.nextInt(p_151541_16_ / 2) + p_151541_16_ / 4; + + for (boolean flag = random.nextInt(6) == 0; p_151541_15_ < p_151541_16_; ++p_151541_15_) + { + double d6 = 1.5D + (double)(MathHelper.sin((float)p_151541_15_ * (float)Math.PI / (float)p_151541_16_) * p_151541_12_ * 1.0F); + double d7 = d6 * p_151541_17_; + float f5 = MathHelper.cos(p_151541_14_); + float f6 = MathHelper.sin(p_151541_14_); + p_151541_6_ += (double)(MathHelper.cos(p_151541_13_) * f5); + p_151541_8_ += (double)f6; + p_151541_10_ += (double)(MathHelper.sin(p_151541_13_) * f5); + + if (flag) + { + p_151541_14_ *= 0.92F; + } + else + { + p_151541_14_ *= 0.7F; + } + + p_151541_14_ += f4 * 0.1F; + p_151541_13_ += f3 * 0.1F; + f4 *= 0.9F; + f3 *= 0.75F; + f4 += (random.nextFloat() - random.nextFloat()) * random.nextFloat() * 2.0F; + f3 += (random.nextFloat() - random.nextFloat()) * random.nextFloat() * 4.0F; + + if (!flag2 && p_151541_15_ == k1 && p_151541_12_ > 1.0F && p_151541_16_ > 0) + { + this.func_151541_a(random.nextLong(), p_151541_3_, p_151541_4_, p_151541_5_, p_151541_6_, p_151541_8_, p_151541_10_, random.nextFloat() * 0.5F + 0.5F, p_151541_13_ - ((float)Math.PI / 2F), p_151541_14_ / 3.0F, p_151541_15_, p_151541_16_, 1.0D); + this.func_151541_a(random.nextLong(), p_151541_3_, p_151541_4_, p_151541_5_, p_151541_6_, p_151541_8_, p_151541_10_, random.nextFloat() * 0.5F + 0.5F, p_151541_13_ + ((float)Math.PI / 2F), p_151541_14_ / 3.0F, p_151541_15_, p_151541_16_, 1.0D); + return; + } + + if (flag2 || random.nextInt(4) != 0) + { + double d8 = p_151541_6_ - d4; + double d9 = p_151541_10_ - d5; + double d10 = (double)(p_151541_16_ - p_151541_15_); + double d11 = (double)(p_151541_12_ + 2.0F + 16.0F); + + if (d8 * d8 + d9 * d9 - d10 * d10 > d11 * d11) + { + return; + } + + if (p_151541_6_ >= d4 - 16.0D - d6 * 2.0D && p_151541_10_ >= d5 - 16.0D - d6 * 2.0D && p_151541_6_ <= d4 + 16.0D + d6 * 2.0D && p_151541_10_ <= d5 + 16.0D + d6 * 2.0D) + { + int i4 = MathHelper.floor_double(p_151541_6_ - d6) - p_151541_3_ * 16 - 1; + int l1 = MathHelper.floor_double(p_151541_6_ + d6) - p_151541_3_ * 16 + 1; + int j4 = MathHelper.floor_double(p_151541_8_ - d7) - 1; + int i2 = MathHelper.floor_double(p_151541_8_ + d7) + 1; + int k4 = MathHelper.floor_double(p_151541_10_ - d6) - p_151541_4_ * 16 - 1; + int j2 = MathHelper.floor_double(p_151541_10_ + d6) - p_151541_4_ * 16 + 1; + + if (i4 < 0) + { + i4 = 0; + } + + if (l1 > 16) + { + l1 = 16; + } + + if (j4 < 1) + { + j4 = 1; + } + + if (i2 > 248) + { + i2 = 248; + } + + if (k4 < 0) + { + k4 = 0; + } + + if (j2 > 16) + { + j2 = 16; + } + + boolean flag3 = false; + int k2; + int j3; + + for (k2 = i4; !flag3 && k2 < l1; ++k2) + { + for (int l2 = k4; !flag3 && l2 < j2; ++l2) + { + for (int i3 = i2 + 1; !flag3 && i3 >= j4 - 1; --i3) + { + j3 = (k2 * 16 + l2) * 256 + i3; + + if (i3 >= 0 && i3 < 256) + { + Block block = p_151541_5_[j3]; + + if (isOceanBlock(p_151541_5_, j3, k2, i3, l2, p_151541_3_, p_151541_4_)) + { + flag3 = true; + } + + if (i3 != j4 - 1 && k2 != i4 && k2 != l1 - 1 && l2 != k4 && l2 != j2 - 1) + { + i3 = j4; + } + } + } + } + } + + if (!flag3) + { + for (k2 = i4; k2 < l1; ++k2) + { + double d13 = ((double)(k2 + p_151541_3_ * 16) + 0.5D - p_151541_6_) / d6; + + for (j3 = k4; j3 < j2; ++j3) + { + double d14 = ((double)(j3 + p_151541_4_ * 16) + 0.5D - p_151541_10_) / d6; + int k3 = (k2 * 16 + j3) * 256 + i2; + boolean flag1 = false; + + if (d13 * d13 + d14 * d14 < 1.0D) + { + for (int l3 = i2 - 1; l3 >= j4; --l3) + { + double d12 = ((double)l3 + 0.5D - p_151541_8_) / d7; + + if (d12 > -0.7D && d13 * d13 + d12 * d12 + d14 * d14 < 1.0D) + { + Block block1 = p_151541_5_[k3]; + + if (isTopBlock(p_151541_5_, k3, k2, l3, j3, p_151541_3_, p_151541_4_)) + { + flag1 = true; + } + digBlock(p_151541_5_, k3, k2, l3, j3, p_151541_3_, p_151541_4_, flag1); + } + + --k3; + } + } + } + } + + if (flag2) + { + break; + } + } + } + } + } + } + + protected void func_151538_a(World p_151538_1_, int p_151538_2_, int p_151538_3_, int p_151538_4_, int p_151538_5_, Block[] p_151538_6_) + { + int i1 = this.rand.nextInt(this.rand.nextInt(this.rand.nextInt(15) + 1) + 1); + + if (this.rand.nextInt(7) != 0) + { + i1 = 0; + } + + for (int j1 = 0; j1 < i1; ++j1) + { + double d0 = (double)(p_151538_2_ * 16 + this.rand.nextInt(16)); + double d1 = (double)this.rand.nextInt(this.rand.nextInt(120) + 8); + double d2 = (double)(p_151538_3_ * 16 + this.rand.nextInt(16)); + int k1 = 1; + + if (this.rand.nextInt(4) == 0) + { + this.func_151542_a(this.rand.nextLong(), p_151538_4_, p_151538_5_, p_151538_6_, d0, d1, d2); + k1 += this.rand.nextInt(4); + } + + for (int l1 = 0; l1 < k1; ++l1) + { + float f = this.rand.nextFloat() * (float)Math.PI * 2.0F; + float f1 = (this.rand.nextFloat() - 0.5F) * 2.0F / 8.0F; + float f2 = this.rand.nextFloat() * 2.0F + this.rand.nextFloat(); + + if (this.rand.nextInt(10) == 0) + { + f2 *= this.rand.nextFloat() * this.rand.nextFloat() * 3.0F + 1.0F; + } + + this.func_151541_a(this.rand.nextLong(), p_151538_4_, p_151538_5_, p_151538_6_, d0, d1, d2, f2, f, f1, 0, 0, 1.0D); + } + } + } + + protected boolean isOceanBlock(Block[] data, int index, int x, int y, int z, int chunkX, int chunkZ) + { + return data[index] == Blocks.flowing_water || data[index] == Blocks.water; + } + + //Exception biomes to make sure we generate like vanilla + private boolean isExceptionBiome(BiomeGenBase biome) + { + if (biome == BiomeGenBase.mushroomIsland) return true; + if (biome == BiomeGenBase.beach) return true; + if (biome == BiomeGenBase.desert) return true; + return false; + } + + //Determine if the block at the specified location is the top block for the biome, we take into account + //Vanilla bugs to make sure that we generate the map the same way vanilla does. + private boolean isTopBlock(Block[] data, int index, int x, int y, int z, int chunkX, int chunkZ) + { + BiomeGenBase biome = worldObj.getBiomeGenForCoords(x + chunkX * 16, z + chunkZ * 16); + return (isExceptionBiome(biome) ? data[index] == Blocks.grass : data[index] == biome.topBlock); + } + + /** + * Digs out the current block, default implementation removes stone, filler, and top block + * Sets the block to lava if y is less then 10, and air other wise. + * If setting to air, it also checks to see if we've broken the surface and if so + * tries to make the floor the biome's top block + * + * @param data Block data array + * @param index Pre-calculated index into block data + * @param x local X position + * @param y local Y position + * @param z local Z position + * @param chunkX Chunk X position + * @param chunkZ Chunk Y position + * @param foundTop True if we've encountered the biome's top block. Ideally if we've broken the surface. + */ + protected void digBlock(Block[] data, int index, int x, int y, int z, int chunkX, int chunkZ, boolean foundTop) + { + BiomeGenBase biome = worldObj.getBiomeGenForCoords(x + chunkX * 16, z + chunkZ * 16); + Block top = (isExceptionBiome(biome) ? Blocks.grass : biome.topBlock); + Block filler = (isExceptionBiome(biome) ? Blocks.dirt : biome.fillerBlock); + Block block = data[index]; + + if (block == Blocks.stone || block == filler || block == top) + { + if (y < 10) + { + data[index] = Blocks.lava; + } + else + { + data[index] = null; + + if (foundTop && data[index - 1] == filler) + { + data[index - 1] = top; + } + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/MapGenCavesHell.java b/src/main/java/net/minecraft/world/gen/MapGenCavesHell.java new file mode 100644 index 0000000..85907d0 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/MapGenCavesHell.java @@ -0,0 +1,227 @@ +package net.minecraft.world.gen; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class MapGenCavesHell extends MapGenBase +{ + private static final String __OBFID = "CL_00000395"; + + protected void func_151544_a(long p_151544_1_, int p_151544_3_, int p_151544_4_, Block[] p_151544_5_, double p_151544_6_, double p_151544_8_, double p_151544_10_) + { + this.func_151543_a(p_151544_1_, p_151544_3_, p_151544_4_, p_151544_5_, p_151544_6_, p_151544_8_, p_151544_10_, 1.0F + this.rand.nextFloat() * 6.0F, 0.0F, 0.0F, -1, -1, 0.5D); + } + + protected void func_151543_a(long p_151543_1_, int p_151543_3_, int p_151543_4_, Block[] p_151543_5_, double p_151543_6_, double p_151543_8_, double p_151543_10_, float p_151543_12_, float p_151543_13_, float p_151543_14_, int p_151543_15_, int p_151543_16_, double p_151543_17_) + { + double d4 = (double)(p_151543_3_ * 16 + 8); + double d5 = (double)(p_151543_4_ * 16 + 8); + float f3 = 0.0F; + float f4 = 0.0F; + Random random = new Random(p_151543_1_); + + if (p_151543_16_ <= 0) + { + int j1 = this.range * 16 - 16; + p_151543_16_ = j1 - random.nextInt(j1 / 4); + } + + boolean flag1 = false; + + if (p_151543_15_ == -1) + { + p_151543_15_ = p_151543_16_ / 2; + flag1 = true; + } + + int k1 = random.nextInt(p_151543_16_ / 2) + p_151543_16_ / 4; + + for (boolean flag = random.nextInt(6) == 0; p_151543_15_ < p_151543_16_; ++p_151543_15_) + { + double d6 = 1.5D + (double)(MathHelper.sin((float)p_151543_15_ * (float)Math.PI / (float)p_151543_16_) * p_151543_12_ * 1.0F); + double d7 = d6 * p_151543_17_; + float f5 = MathHelper.cos(p_151543_14_); + float f6 = MathHelper.sin(p_151543_14_); + p_151543_6_ += (double)(MathHelper.cos(p_151543_13_) * f5); + p_151543_8_ += (double)f6; + p_151543_10_ += (double)(MathHelper.sin(p_151543_13_) * f5); + + if (flag) + { + p_151543_14_ *= 0.92F; + } + else + { + p_151543_14_ *= 0.7F; + } + + p_151543_14_ += f4 * 0.1F; + p_151543_13_ += f3 * 0.1F; + f4 *= 0.9F; + f3 *= 0.75F; + f4 += (random.nextFloat() - random.nextFloat()) * random.nextFloat() * 2.0F; + f3 += (random.nextFloat() - random.nextFloat()) * random.nextFloat() * 4.0F; + + if (!flag1 && p_151543_15_ == k1 && p_151543_12_ > 1.0F) + { + this.func_151543_a(random.nextLong(), p_151543_3_, p_151543_4_, p_151543_5_, p_151543_6_, p_151543_8_, p_151543_10_, random.nextFloat() * 0.5F + 0.5F, p_151543_13_ - ((float)Math.PI / 2F), p_151543_14_ / 3.0F, p_151543_15_, p_151543_16_, 1.0D); + this.func_151543_a(random.nextLong(), p_151543_3_, p_151543_4_, p_151543_5_, p_151543_6_, p_151543_8_, p_151543_10_, random.nextFloat() * 0.5F + 0.5F, p_151543_13_ + ((float)Math.PI / 2F), p_151543_14_ / 3.0F, p_151543_15_, p_151543_16_, 1.0D); + return; + } + + if (flag1 || random.nextInt(4) != 0) + { + double d8 = p_151543_6_ - d4; + double d9 = p_151543_10_ - d5; + double d10 = (double)(p_151543_16_ - p_151543_15_); + double d11 = (double)(p_151543_12_ + 2.0F + 16.0F); + + if (d8 * d8 + d9 * d9 - d10 * d10 > d11 * d11) + { + return; + } + + if (p_151543_6_ >= d4 - 16.0D - d6 * 2.0D && p_151543_10_ >= d5 - 16.0D - d6 * 2.0D && p_151543_6_ <= d4 + 16.0D + d6 * 2.0D && p_151543_10_ <= d5 + 16.0D + d6 * 2.0D) + { + int i4 = MathHelper.floor_double(p_151543_6_ - d6) - p_151543_3_ * 16 - 1; + int l1 = MathHelper.floor_double(p_151543_6_ + d6) - p_151543_3_ * 16 + 1; + int j4 = MathHelper.floor_double(p_151543_8_ - d7) - 1; + int i2 = MathHelper.floor_double(p_151543_8_ + d7) + 1; + int k4 = MathHelper.floor_double(p_151543_10_ - d6) - p_151543_4_ * 16 - 1; + int j2 = MathHelper.floor_double(p_151543_10_ + d6) - p_151543_4_ * 16 + 1; + + if (i4 < 0) + { + i4 = 0; + } + + if (l1 > 16) + { + l1 = 16; + } + + if (j4 < 1) + { + j4 = 1; + } + + if (i2 > 120) + { + i2 = 120; + } + + if (k4 < 0) + { + k4 = 0; + } + + if (j2 > 16) + { + j2 = 16; + } + + boolean flag2 = false; + int k2; + int j3; + + for (k2 = i4; !flag2 && k2 < l1; ++k2) + { + for (int l2 = k4; !flag2 && l2 < j2; ++l2) + { + for (int i3 = i2 + 1; !flag2 && i3 >= j4 - 1; --i3) + { + j3 = (k2 * 16 + l2) * 128 + i3; + + if (i3 >= 0 && i3 < 128) + { + Block block = p_151543_5_[j3]; + + if (block == Blocks.flowing_lava || block == Blocks.lava) + { + flag2 = true; + } + + if (i3 != j4 - 1 && k2 != i4 && k2 != l1 - 1 && l2 != k4 && l2 != j2 - 1) + { + i3 = j4; + } + } + } + } + } + + if (!flag2) + { + for (k2 = i4; k2 < l1; ++k2) + { + double d13 = ((double)(k2 + p_151543_3_ * 16) + 0.5D - p_151543_6_) / d6; + + for (j3 = k4; j3 < j2; ++j3) + { + double d14 = ((double)(j3 + p_151543_4_ * 16) + 0.5D - p_151543_10_) / d6; + int k3 = (k2 * 16 + j3) * 128 + i2; + + for (int l3 = i2 - 1; l3 >= j4; --l3) + { + double d12 = ((double)l3 + 0.5D - p_151543_8_) / d7; + + if (d12 > -0.7D && d13 * d13 + d12 * d12 + d14 * d14 < 1.0D) + { + Block block1 = p_151543_5_[k3]; + + if (block1 == Blocks.netherrack || block1 == Blocks.dirt || block1 == Blocks.grass) + { + p_151543_5_[k3] = null; + } + } + + --k3; + } + } + } + + if (flag1) + { + break; + } + } + } + } + } + } + + protected void func_151538_a(World p_151538_1_, int p_151538_2_, int p_151538_3_, int p_151538_4_, int p_151538_5_, Block[] p_151538_6_) + { + int i1 = this.rand.nextInt(this.rand.nextInt(this.rand.nextInt(10) + 1) + 1); + + if (this.rand.nextInt(5) != 0) + { + i1 = 0; + } + + for (int j1 = 0; j1 < i1; ++j1) + { + double d0 = (double)(p_151538_2_ * 16 + this.rand.nextInt(16)); + double d1 = (double)this.rand.nextInt(128); + double d2 = (double)(p_151538_3_ * 16 + this.rand.nextInt(16)); + int k1 = 1; + + if (this.rand.nextInt(4) == 0) + { + this.func_151544_a(this.rand.nextLong(), p_151538_4_, p_151538_5_, p_151538_6_, d0, d1, d2); + k1 += this.rand.nextInt(4); + } + + for (int l1 = 0; l1 < k1; ++l1) + { + float f = this.rand.nextFloat() * (float)Math.PI * 2.0F; + float f1 = (this.rand.nextFloat() - 0.5F) * 2.0F / 8.0F; + float f2 = this.rand.nextFloat() * 2.0F + this.rand.nextFloat(); + this.func_151543_a(this.rand.nextLong(), p_151538_4_, p_151538_5_, p_151538_6_, d0, d1, d2, f2 * 2.0F, f, f1, 0, 0, 0.5D); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/MapGenRavine.java b/src/main/java/net/minecraft/world/gen/MapGenRavine.java new file mode 100644 index 0000000..c95956d --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/MapGenRavine.java @@ -0,0 +1,275 @@ +package net.minecraft.world.gen; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; + +public class MapGenRavine extends MapGenBase +{ + private float[] field_75046_d = new float[1024]; + private static final String __OBFID = "CL_00000390"; + + protected void func_151540_a(long p_151540_1_, int p_151540_3_, int p_151540_4_, Block[] p_151540_5_, double p_151540_6_, double p_151540_8_, double p_151540_10_, float p_151540_12_, float p_151540_13_, float p_151540_14_, int p_151540_15_, int p_151540_16_, double p_151540_17_) + { + Random random = new Random(p_151540_1_); + double d4 = (double)(p_151540_3_ * 16 + 8); + double d5 = (double)(p_151540_4_ * 16 + 8); + float f3 = 0.0F; + float f4 = 0.0F; + + if (p_151540_16_ <= 0) + { + int j1 = this.range * 16 - 16; + p_151540_16_ = j1 - random.nextInt(j1 / 4); + } + + boolean flag1 = false; + + if (p_151540_15_ == -1) + { + p_151540_15_ = p_151540_16_ / 2; + flag1 = true; + } + + float f5 = 1.0F; + + for (int k1 = 0; k1 < 256; ++k1) + { + if (k1 == 0 || random.nextInt(3) == 0) + { + f5 = 1.0F + random.nextFloat() * random.nextFloat() * 1.0F; + } + + this.field_75046_d[k1] = f5 * f5; + } + + for (; p_151540_15_ < p_151540_16_; ++p_151540_15_) + { + double d12 = 1.5D + (double)(MathHelper.sin((float)p_151540_15_ * (float)Math.PI / (float)p_151540_16_) * p_151540_12_ * 1.0F); + double d6 = d12 * p_151540_17_; + d12 *= (double)random.nextFloat() * 0.25D + 0.75D; + d6 *= (double)random.nextFloat() * 0.25D + 0.75D; + float f6 = MathHelper.cos(p_151540_14_); + float f7 = MathHelper.sin(p_151540_14_); + p_151540_6_ += (double)(MathHelper.cos(p_151540_13_) * f6); + p_151540_8_ += (double)f7; + p_151540_10_ += (double)(MathHelper.sin(p_151540_13_) * f6); + p_151540_14_ *= 0.7F; + p_151540_14_ += f4 * 0.05F; + p_151540_13_ += f3 * 0.05F; + f4 *= 0.8F; + f3 *= 0.5F; + f4 += (random.nextFloat() - random.nextFloat()) * random.nextFloat() * 2.0F; + f3 += (random.nextFloat() - random.nextFloat()) * random.nextFloat() * 4.0F; + + if (flag1 || random.nextInt(4) != 0) + { + double d7 = p_151540_6_ - d4; + double d8 = p_151540_10_ - d5; + double d9 = (double)(p_151540_16_ - p_151540_15_); + double d10 = (double)(p_151540_12_ + 2.0F + 16.0F); + + if (d7 * d7 + d8 * d8 - d9 * d9 > d10 * d10) + { + return; + } + + if (p_151540_6_ >= d4 - 16.0D - d12 * 2.0D && p_151540_10_ >= d5 - 16.0D - d12 * 2.0D && p_151540_6_ <= d4 + 16.0D + d12 * 2.0D && p_151540_10_ <= d5 + 16.0D + d12 * 2.0D) + { + int i4 = MathHelper.floor_double(p_151540_6_ - d12) - p_151540_3_ * 16 - 1; + int l1 = MathHelper.floor_double(p_151540_6_ + d12) - p_151540_3_ * 16 + 1; + int j4 = MathHelper.floor_double(p_151540_8_ - d6) - 1; + int i2 = MathHelper.floor_double(p_151540_8_ + d6) + 1; + int k4 = MathHelper.floor_double(p_151540_10_ - d12) - p_151540_4_ * 16 - 1; + int j2 = MathHelper.floor_double(p_151540_10_ + d12) - p_151540_4_ * 16 + 1; + + if (i4 < 0) + { + i4 = 0; + } + + if (l1 > 16) + { + l1 = 16; + } + + if (j4 < 1) + { + j4 = 1; + } + + if (i2 > 248) + { + i2 = 248; + } + + if (k4 < 0) + { + k4 = 0; + } + + if (j2 > 16) + { + j2 = 16; + } + + boolean flag2 = false; + int k2; + int j3; + + for (k2 = i4; !flag2 && k2 < l1; ++k2) + { + for (int l2 = k4; !flag2 && l2 < j2; ++l2) + { + for (int i3 = i2 + 1; !flag2 && i3 >= j4 - 1; --i3) + { + j3 = (k2 * 16 + l2) * 256 + i3; + + if (i3 >= 0 && i3 < 256) + { + Block block = p_151540_5_[j3]; + + if (isOceanBlock(p_151540_5_, j3, k2, i3, l2, p_151540_3_, p_151540_4_)) + { + flag2 = true; + } + + if (i3 != j4 - 1 && k2 != i4 && k2 != l1 - 1 && l2 != k4 && l2 != j2 - 1) + { + i3 = j4; + } + } + } + } + } + + if (!flag2) + { + for (k2 = i4; k2 < l1; ++k2) + { + double d13 = ((double)(k2 + p_151540_3_ * 16) + 0.5D - p_151540_6_) / d12; + + for (j3 = k4; j3 < j2; ++j3) + { + double d14 = ((double)(j3 + p_151540_4_ * 16) + 0.5D - p_151540_10_) / d12; + int k3 = (k2 * 16 + j3) * 256 + i2; + boolean flag = false; + + if (d13 * d13 + d14 * d14 < 1.0D) + { + for (int l3 = i2 - 1; l3 >= j4; --l3) + { + double d11 = ((double)l3 + 0.5D - p_151540_8_) / d6; + + if ((d13 * d13 + d14 * d14) * (double)this.field_75046_d[l3] + d11 * d11 / 6.0D < 1.0D) + { + Block block1 = p_151540_5_[k3]; + + if (isTopBlock(p_151540_5_, k3, k2, l3, j3, p_151540_3_, p_151540_4_)) + { + flag = true; + } + + digBlock(p_151540_5_, k3, k2, l3, j3, p_151540_3_, p_151540_4_, flag); + } + + --k3; + } + } + } + } + + if (flag1) + { + break; + } + } + } + } + } + } + + protected void func_151538_a(World p_151538_1_, int p_151538_2_, int p_151538_3_, int p_151538_4_, int p_151538_5_, Block[] p_151538_6_) + { + if (this.rand.nextInt(50) == 0) + { + double d0 = (double)(p_151538_2_ * 16 + this.rand.nextInt(16)); + double d1 = (double)(this.rand.nextInt(this.rand.nextInt(40) + 8) + 20); + double d2 = (double)(p_151538_3_ * 16 + this.rand.nextInt(16)); + byte b0 = 1; + + for (int i1 = 0; i1 < b0; ++i1) + { + float f = this.rand.nextFloat() * (float)Math.PI * 2.0F; + float f1 = (this.rand.nextFloat() - 0.5F) * 2.0F / 8.0F; + float f2 = (this.rand.nextFloat() * 2.0F + this.rand.nextFloat()) * 2.0F; + this.func_151540_a(this.rand.nextLong(), p_151538_4_, p_151538_5_, p_151538_6_, d0, d1, d2, f2, f, f1, 0, 0, 3.0D); + } + } + } + + protected boolean isOceanBlock(Block[] data, int index, int x, int y, int z, int chunkX, int chunkZ) + { + return data[index] == Blocks.water || data[index] == Blocks.flowing_water; + } + + //Exception biomes to make sure we generate like vanilla + private boolean isExceptionBiome(BiomeGenBase biome) + { + if (biome == BiomeGenBase.mushroomIsland) return true; + if (biome == BiomeGenBase.beach) return true; + if (biome == BiomeGenBase.desert) return true; + return false; + } + + //Determine if the block at the specified location is the top block for the biome, we take into account + //Vanilla bugs to make sure that we generate the map the same way vanilla does. + private boolean isTopBlock(Block[] data, int index, int x, int y, int z, int chunkX, int chunkZ) + { + BiomeGenBase biome = worldObj.getBiomeGenForCoords(x + chunkX * 16, z + chunkZ * 16); + return (isExceptionBiome(biome) ? data[index] == Blocks.grass : data[index] == biome.topBlock); + } + + /** + * Digs out the current block, default implementation removes stone, filler, and top block + * Sets the block to lava if y is less then 10, and air other wise. + * If setting to air, it also checks to see if we've broken the surface and if so + * tries to make the floor the biome's top block + * + * @param data Block data array + * @param index Pre-calculated index into block data + * @param x local X position + * @param y local Y position + * @param z local Z position + * @param chunkX Chunk X position + * @param chunkZ Chunk Y position + * @param foundTop True if we've encountered the biome's top block. Ideally if we've broken the surface. + */ + protected void digBlock(Block[] data, int index, int x, int y, int z, int chunkX, int chunkZ, boolean foundTop) + { + BiomeGenBase biome = worldObj.getBiomeGenForCoords(x + chunkX * 16, z + chunkZ * 16); + Block top = (isExceptionBiome(biome) ? Blocks.grass : biome.topBlock); + Block filler = (isExceptionBiome(biome) ? Blocks.dirt : biome.fillerBlock); + Block block = data[index]; + + if (block == Blocks.stone || block == filler || block == top) + { + if (y < 10) + { + data[index] = Blocks.flowing_lava; + } + else + { + data[index] = null; + + if (foundTop && data[index - 1] == filler) + { + data[index - 1] = top; + } + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/NoiseGenerator.java b/src/main/java/net/minecraft/world/gen/NoiseGenerator.java new file mode 100644 index 0000000..2425c5e --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/NoiseGenerator.java @@ -0,0 +1,6 @@ +package net.minecraft.world.gen; + +public abstract class NoiseGenerator +{ + private static final String __OBFID = "CL_00000538"; +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/NoiseGeneratorImproved.java b/src/main/java/net/minecraft/world/gen/NoiseGeneratorImproved.java new file mode 100644 index 0000000..008f2a6 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/NoiseGeneratorImproved.java @@ -0,0 +1,209 @@ +package net.minecraft.world.gen; + +import java.util.Random; + +public class NoiseGeneratorImproved extends NoiseGenerator +{ + private int[] permutations; + public double xCoord; + public double yCoord; + public double zCoord; + private static final String __OBFID = "CL_00000534"; + + public NoiseGeneratorImproved() + { + this(new Random()); + } + + public NoiseGeneratorImproved(Random p_i45469_1_) + { + this.permutations = new int[512]; + this.xCoord = p_i45469_1_.nextDouble() * 256.0D; + this.yCoord = p_i45469_1_.nextDouble() * 256.0D; + this.zCoord = p_i45469_1_.nextDouble() * 256.0D; + int i; + + for (i = 0; i < 256; this.permutations[i] = i++) + { + ; + } + + for (i = 0; i < 256; ++i) + { + int j = p_i45469_1_.nextInt(256 - i) + i; + int k = this.permutations[i]; + this.permutations[i] = this.permutations[j]; + this.permutations[j] = k; + this.permutations[i + 256] = this.permutations[i]; + } + } + + public final double lerp(double par1, double par3, double par5) + { + return par3 + par1 * (par5 - par3); + } + + public final double func_76309_a(int par1, double par2, double par4) + { + int j = par1 & 15; + double d2 = (double)(1 - ((j & 8) >> 3)) * par2; + double d3 = j < 4 ? 0.0D : (j != 12 && j != 14 ? par4 : par2); + return ((j & 1) == 0 ? d2 : -d2) + ((j & 2) == 0 ? d3 : -d3); + } + + public final double grad(int par1, double par2, double par4, double par6) + { + int j = par1 & 15; + double d3 = j < 8 ? par2 : par4; + double d4 = j < 4 ? par4 : (j != 12 && j != 14 ? par6 : par2); + return ((j & 1) == 0 ? d3 : -d3) + ((j & 2) == 0 ? d4 : -d4); + } + + public void populateNoiseArray(double[] par1ArrayOfDouble, double par2, double par4, double par6, int par8, int par9, int par10, double par11, double par13, double par15, double par17) + { + int l; + int i1; + double d9; + double d11; + int l1; + double d12; + int i2; + int j2; + double d13; + int k5; + int j6; + + if (par9 == 1) + { + boolean flag7 = false; + boolean flag8 = false; + boolean flag = false; + boolean flag9 = false; + double d21 = 0.0D; + double d22 = 0.0D; + k5 = 0; + double d23 = 1.0D / par17; + + for (int j1 = 0; j1 < par8; ++j1) + { + d9 = par2 + (double)j1 * par11 + this.xCoord; + int i6 = (int)d9; + + if (d9 < (double)i6) + { + --i6; + } + + int k1 = i6 & 255; + d9 -= (double)i6; + d11 = d9 * d9 * d9 * (d9 * (d9 * 6.0D - 15.0D) + 10.0D); + + for (l1 = 0; l1 < par10; ++l1) + { + d12 = par6 + (double)l1 * par15 + this.zCoord; + i2 = (int)d12; + + if (d12 < (double)i2) + { + --i2; + } + + j2 = i2 & 255; + d12 -= (double)i2; + d13 = d12 * d12 * d12 * (d12 * (d12 * 6.0D - 15.0D) + 10.0D); + l = this.permutations[k1] + 0; + int i4 = this.permutations[l] + j2; + int j4 = this.permutations[k1 + 1] + 0; + i1 = this.permutations[j4] + j2; + d21 = this.lerp(d11, this.func_76309_a(this.permutations[i4], d9, d12), this.grad(this.permutations[i1], d9 - 1.0D, 0.0D, d12)); + d22 = this.lerp(d11, this.grad(this.permutations[i4 + 1], d9, 0.0D, d12 - 1.0D), this.grad(this.permutations[i1 + 1], d9 - 1.0D, 0.0D, d12 - 1.0D)); + double d24 = this.lerp(d13, d21, d22); + j6 = k5++; + par1ArrayOfDouble[j6] += d24 * d23; + } + } + } + else + { + l = 0; + double d7 = 1.0D / par17; + i1 = -1; + boolean flag1 = false; + boolean flag2 = false; + boolean flag3 = false; + boolean flag4 = false; + boolean flag5 = false; + boolean flag6 = false; + double d8 = 0.0D; + d9 = 0.0D; + double d10 = 0.0D; + d11 = 0.0D; + + for (l1 = 0; l1 < par8; ++l1) + { + d12 = par2 + (double)l1 * par11 + this.xCoord; + i2 = (int)d12; + + if (d12 < (double)i2) + { + --i2; + } + + j2 = i2 & 255; + d12 -= (double)i2; + d13 = d12 * d12 * d12 * (d12 * (d12 * 6.0D - 15.0D) + 10.0D); + + for (int k2 = 0; k2 < par10; ++k2) + { + double d14 = par6 + (double)k2 * par15 + this.zCoord; + int l2 = (int)d14; + + if (d14 < (double)l2) + { + --l2; + } + + int i3 = l2 & 255; + d14 -= (double)l2; + double d15 = d14 * d14 * d14 * (d14 * (d14 * 6.0D - 15.0D) + 10.0D); + + for (int j3 = 0; j3 < par9; ++j3) + { + double d16 = par4 + (double)j3 * par13 + this.yCoord; + int k3 = (int)d16; + + if (d16 < (double)k3) + { + --k3; + } + + int l3 = k3 & 255; + d16 -= (double)k3; + double d17 = d16 * d16 * d16 * (d16 * (d16 * 6.0D - 15.0D) + 10.0D); + + if (j3 == 0 || l3 != i1) + { + i1 = l3; + int k4 = this.permutations[j2] + l3; + int l4 = this.permutations[k4] + i3; + int i5 = this.permutations[k4 + 1] + i3; + int j5 = this.permutations[j2 + 1] + l3; + k5 = this.permutations[j5] + i3; + int l5 = this.permutations[j5 + 1] + i3; + d8 = this.lerp(d13, this.grad(this.permutations[l4], d12, d16, d14), this.grad(this.permutations[k5], d12 - 1.0D, d16, d14)); + d9 = this.lerp(d13, this.grad(this.permutations[i5], d12, d16 - 1.0D, d14), this.grad(this.permutations[l5], d12 - 1.0D, d16 - 1.0D, d14)); + d10 = this.lerp(d13, this.grad(this.permutations[l4 + 1], d12, d16, d14 - 1.0D), this.grad(this.permutations[k5 + 1], d12 - 1.0D, d16, d14 - 1.0D)); + d11 = this.lerp(d13, this.grad(this.permutations[i5 + 1], d12, d16 - 1.0D, d14 - 1.0D), this.grad(this.permutations[l5 + 1], d12 - 1.0D, d16 - 1.0D, d14 - 1.0D)); + } + + double d18 = this.lerp(d17, d8, d9); + double d19 = this.lerp(d17, d10, d11); + double d20 = this.lerp(d15, d18, d19); + j6 = l++; + par1ArrayOfDouble[j6] += d20 * d7; + } + } + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/NoiseGeneratorOctaves.java b/src/main/java/net/minecraft/world/gen/NoiseGeneratorOctaves.java new file mode 100644 index 0000000..f734867 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/NoiseGeneratorOctaves.java @@ -0,0 +1,63 @@ +package net.minecraft.world.gen; + +import java.util.Random; +import net.minecraft.util.MathHelper; + +public class NoiseGeneratorOctaves extends NoiseGenerator +{ + private NoiseGeneratorImproved[] generatorCollection; + private int octaves; + private static final String __OBFID = "CL_00000535"; + + public NoiseGeneratorOctaves(Random par1Random, int par2) + { + this.octaves = par2; + this.generatorCollection = new NoiseGeneratorImproved[par2]; + + for (int j = 0; j < par2; ++j) + { + this.generatorCollection[j] = new NoiseGeneratorImproved(par1Random); + } + } + + public double[] generateNoiseOctaves(double[] par1ArrayOfDouble, int par2, int par3, int par4, int par5, int par6, int par7, double par8, double par10, double par12) + { + if (par1ArrayOfDouble == null) + { + par1ArrayOfDouble = new double[par5 * par6 * par7]; + } + else + { + for (int k1 = 0; k1 < par1ArrayOfDouble.length; ++k1) + { + par1ArrayOfDouble[k1] = 0.0D; + } + } + + double d6 = 1.0D; + + for (int l1 = 0; l1 < this.octaves; ++l1) + { + double d3 = (double)par2 * d6 * par8; + double d4 = (double)par3 * d6 * par10; + double d5 = (double)par4 * d6 * par12; + long i2 = MathHelper.floor_double_long(d3); + long j2 = MathHelper.floor_double_long(d5); + d3 -= (double)i2; + d5 -= (double)j2; + i2 %= 16777216L; + j2 %= 16777216L; + d3 += (double)i2; + d5 += (double)j2; + this.generatorCollection[l1].populateNoiseArray(par1ArrayOfDouble, d3, d4, d5, par5, par6, par7, par8 * d6, par10 * d6, par12 * d6, d6); + d6 /= 2.0D; + } + + return par1ArrayOfDouble; + } + + public double[] generateNoiseOctaves(double[] par1ArrayOfDouble, int par2, int par3, int par4, int par5, double par6, double par8, double par10) + { + return this.generateNoiseOctaves(par1ArrayOfDouble, par2, 10, par3, par4, 1, par5, par6, 1.0D, par8); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/NoiseGeneratorPerlin.java b/src/main/java/net/minecraft/world/gen/NoiseGeneratorPerlin.java new file mode 100644 index 0000000..f8360d1 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/NoiseGeneratorPerlin.java @@ -0,0 +1,67 @@ +package net.minecraft.world.gen; + +import java.util.Random; + +public class NoiseGeneratorPerlin extends NoiseGenerator +{ + private NoiseGeneratorSimplex[] field_151603_a; + private int field_151602_b; + private static final String __OBFID = "CL_00000536"; + + public NoiseGeneratorPerlin(Random p_i45470_1_, int p_i45470_2_) + { + this.field_151602_b = p_i45470_2_; + this.field_151603_a = new NoiseGeneratorSimplex[p_i45470_2_]; + + for (int j = 0; j < p_i45470_2_; ++j) + { + this.field_151603_a[j] = new NoiseGeneratorSimplex(p_i45470_1_); + } + } + + public double func_151601_a(double p_151601_1_, double p_151601_3_) + { + double d2 = 0.0D; + double d3 = 1.0D; + + for (int i = 0; i < this.field_151602_b; ++i) + { + d2 += this.field_151603_a[i].func_151605_a(p_151601_1_ * d3, p_151601_3_ * d3) / d3; + d3 /= 2.0D; + } + + return d2; + } + + public double[] func_151599_a(double[] p_151599_1_, double p_151599_2_, double p_151599_4_, int p_151599_6_, int p_151599_7_, double p_151599_8_, double p_151599_10_, double p_151599_12_) + { + return this.func_151600_a(p_151599_1_, p_151599_2_, p_151599_4_, p_151599_6_, p_151599_7_, p_151599_8_, p_151599_10_, p_151599_12_, 0.5D); + } + + public double[] func_151600_a(double[] p_151600_1_, double p_151600_2_, double p_151600_4_, int p_151600_6_, int p_151600_7_, double p_151600_8_, double p_151600_10_, double p_151600_12_, double p_151600_14_) + { + if (p_151600_1_ != null && p_151600_1_.length >= p_151600_6_ * p_151600_7_) + { + for (int k = 0; k < p_151600_1_.length; ++k) + { + p_151600_1_[k] = 0.0D; + } + } + else + { + p_151600_1_ = new double[p_151600_6_ * p_151600_7_]; + } + + double d7 = 1.0D; + double d6 = 1.0D; + + for (int l = 0; l < this.field_151602_b; ++l) + { + this.field_151603_a[l].func_151606_a(p_151600_1_, p_151600_2_, p_151600_4_, p_151600_6_, p_151600_7_, p_151600_8_ * d6 * d7, p_151600_10_ * d6 * d7, 0.55D / d7); + d6 *= p_151600_12_; + d7 *= p_151600_14_; + } + + return p_151600_1_; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/NoiseGeneratorSimplex.java b/src/main/java/net/minecraft/world/gen/NoiseGeneratorSimplex.java new file mode 100644 index 0000000..db0efe7 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/NoiseGeneratorSimplex.java @@ -0,0 +1,218 @@ +package net.minecraft.world.gen; + +import java.util.Random; + +public class NoiseGeneratorSimplex +{ + private static int[][] field_151611_e = new int[][] {{1, 1, 0}, { -1, 1, 0}, {1, -1, 0}, { -1, -1, 0}, {1, 0, 1}, { -1, 0, 1}, {1, 0, -1}, { -1, 0, -1}, {0, 1, 1}, {0, -1, 1}, {0, 1, -1}, {0, -1, -1}}; + public static final double field_151614_a = Math.sqrt(3.0D); + private int[] field_151608_f; + public double field_151612_b; + public double field_151613_c; + public double field_151610_d; + private static final double field_151609_g = 0.5D * (field_151614_a - 1.0D); + private static final double field_151615_h = (3.0D - field_151614_a) / 6.0D; + private static final String __OBFID = "CL_00000537"; + + public NoiseGeneratorSimplex() + { + this(new Random()); + } + + public NoiseGeneratorSimplex(Random p_i45471_1_) + { + this.field_151608_f = new int[512]; + this.field_151612_b = p_i45471_1_.nextDouble() * 256.0D; + this.field_151613_c = p_i45471_1_.nextDouble() * 256.0D; + this.field_151610_d = p_i45471_1_.nextDouble() * 256.0D; + int i; + + for (i = 0; i < 256; this.field_151608_f[i] = i++) + { + ; + } + + for (i = 0; i < 256; ++i) + { + int j = p_i45471_1_.nextInt(256 - i) + i; + int k = this.field_151608_f[i]; + this.field_151608_f[i] = this.field_151608_f[j]; + this.field_151608_f[j] = k; + this.field_151608_f[i + 256] = this.field_151608_f[i]; + } + } + + private static int func_151607_a(double p_151607_0_) + { + return p_151607_0_ > 0.0D ? (int)p_151607_0_ : (int)p_151607_0_ - 1; + } + + private static double func_151604_a(int[] p_151604_0_, double p_151604_1_, double p_151604_3_) + { + return (double)p_151604_0_[0] * p_151604_1_ + (double)p_151604_0_[1] * p_151604_3_; + } + + public double func_151605_a(double p_151605_1_, double p_151605_3_) + { + double d5 = 0.5D * (field_151614_a - 1.0D); + double d6 = (p_151605_1_ + p_151605_3_) * d5; + int i = func_151607_a(p_151605_1_ + d6); + int j = func_151607_a(p_151605_3_ + d6); + double d7 = (3.0D - field_151614_a) / 6.0D; + double d8 = (double)(i + j) * d7; + double d9 = (double)i - d8; + double d10 = (double)j - d8; + double d11 = p_151605_1_ - d9; + double d12 = p_151605_3_ - d10; + byte b0; + byte b1; + + if (d11 > d12) + { + b0 = 1; + b1 = 0; + } + else + { + b0 = 0; + b1 = 1; + } + + double d13 = d11 - (double)b0 + d7; + double d14 = d12 - (double)b1 + d7; + double d15 = d11 - 1.0D + 2.0D * d7; + double d16 = d12 - 1.0D + 2.0D * d7; + int k = i & 255; + int l = j & 255; + int i1 = this.field_151608_f[k + this.field_151608_f[l]] % 12; + int j1 = this.field_151608_f[k + b0 + this.field_151608_f[l + b1]] % 12; + int k1 = this.field_151608_f[k + 1 + this.field_151608_f[l + 1]] % 12; + double d17 = 0.5D - d11 * d11 - d12 * d12; + double d2; + + if (d17 < 0.0D) + { + d2 = 0.0D; + } + else + { + d17 *= d17; + d2 = d17 * d17 * func_151604_a(field_151611_e[i1], d11, d12); + } + + double d18 = 0.5D - d13 * d13 - d14 * d14; + double d3; + + if (d18 < 0.0D) + { + d3 = 0.0D; + } + else + { + d18 *= d18; + d3 = d18 * d18 * func_151604_a(field_151611_e[j1], d13, d14); + } + + double d19 = 0.5D - d15 * d15 - d16 * d16; + double d4; + + if (d19 < 0.0D) + { + d4 = 0.0D; + } + else + { + d19 *= d19; + d4 = d19 * d19 * func_151604_a(field_151611_e[k1], d15, d16); + } + + return 70.0D * (d2 + d3 + d4); + } + + public void func_151606_a(double[] p_151606_1_, double p_151606_2_, double p_151606_4_, int p_151606_6_, int p_151606_7_, double p_151606_8_, double p_151606_10_, double p_151606_12_) + { + int k = 0; + + for (int l = 0; l < p_151606_7_; ++l) + { + double d5 = (p_151606_4_ + (double)l) * p_151606_10_ + this.field_151613_c; + + for (int i1 = 0; i1 < p_151606_6_; ++i1) + { + double d6 = (p_151606_2_ + (double)i1) * p_151606_8_ + this.field_151612_b; + double d10 = (d6 + d5) * field_151609_g; + int j1 = func_151607_a(d6 + d10); + int k1 = func_151607_a(d5 + d10); + double d11 = (double)(j1 + k1) * field_151615_h; + double d12 = (double)j1 - d11; + double d13 = (double)k1 - d11; + double d14 = d6 - d12; + double d15 = d5 - d13; + byte b0; + byte b1; + + if (d14 > d15) + { + b0 = 1; + b1 = 0; + } + else + { + b0 = 0; + b1 = 1; + } + + double d16 = d14 - (double)b0 + field_151615_h; + double d17 = d15 - (double)b1 + field_151615_h; + double d18 = d14 - 1.0D + 2.0D * field_151615_h; + double d19 = d15 - 1.0D + 2.0D * field_151615_h; + int l1 = j1 & 255; + int i2 = k1 & 255; + int j2 = this.field_151608_f[l1 + this.field_151608_f[i2]] % 12; + int k2 = this.field_151608_f[l1 + b0 + this.field_151608_f[i2 + b1]] % 12; + int l2 = this.field_151608_f[l1 + 1 + this.field_151608_f[i2 + 1]] % 12; + double d20 = 0.5D - d14 * d14 - d15 * d15; + double d7; + + if (d20 < 0.0D) + { + d7 = 0.0D; + } + else + { + d20 *= d20; + d7 = d20 * d20 * func_151604_a(field_151611_e[j2], d14, d15); + } + + double d21 = 0.5D - d16 * d16 - d17 * d17; + double d8; + + if (d21 < 0.0D) + { + d8 = 0.0D; + } + else + { + d21 *= d21; + d8 = d21 * d21 * func_151604_a(field_151611_e[k2], d16, d17); + } + + double d22 = 0.5D - d18 * d18 - d19 * d19; + double d9; + + if (d22 < 0.0D) + { + d9 = 0.0D; + } + else + { + d22 *= d22; + d9 = d22 * d22 * func_151604_a(field_151611_e[l2], d18, d19); + } + + int i3 = k++; + p_151606_1_[i3] += 70.0D * (d7 + d8 + d9) * p_151606_12_; + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/feature/WorldGenAbstractTree.java b/src/main/java/net/minecraft/world/gen/feature/WorldGenAbstractTree.java new file mode 100644 index 0000000..bf2ff98 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/feature/WorldGenAbstractTree.java @@ -0,0 +1,30 @@ +package net.minecraft.world.gen.feature; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; + +public abstract class WorldGenAbstractTree extends WorldGenerator +{ + private static final String __OBFID = "CL_00000399"; + + public WorldGenAbstractTree(boolean p_i45448_1_) + { + super(p_i45448_1_); + } + + protected boolean func_150523_a(Block p_150523_1_) + { + return p_150523_1_.getMaterial() == Material.air || p_150523_1_.getMaterial() == Material.leaves || p_150523_1_ == Blocks.grass || p_150523_1_ == Blocks.dirt || p_150523_1_ == Blocks.log || p_150523_1_ == Blocks.log2 || p_150523_1_ == Blocks.sapling || p_150523_1_ == Blocks.vine; + } + + public void func_150524_b(World p_150524_1_, Random p_150524_2_, int p_150524_3_, int p_150524_4_, int p_150524_5_) {} + + protected boolean isReplaceable(World world, int x, int y, int z) + { + Block block = world.getBlock(x, y, z); + return block.isAir(world, x, y, z) || block.isLeaves(world, x, y, z) || block.isWood(world, x, y, z) || func_150523_a(block); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/feature/WorldGenBigMushroom.java b/src/main/java/net/minecraft/world/gen/feature/WorldGenBigMushroom.java new file mode 100644 index 0000000..47a4206 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/feature/WorldGenBigMushroom.java @@ -0,0 +1,213 @@ +package net.minecraft.world.gen.feature; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; + +public class WorldGenBigMushroom extends WorldGenerator +{ + private int mushroomType = -1; + private static final String __OBFID = "CL_00000415"; + + public WorldGenBigMushroom(int par1) + { + super(true); + this.mushroomType = par1; + } + + public WorldGenBigMushroom() + { + super(false); + } + + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + int l = par2Random.nextInt(2); + + if (this.mushroomType >= 0) + { + l = this.mushroomType; + } + + int i1 = par2Random.nextInt(3) + 4; + boolean flag = true; + + if (par4 >= 1 && par4 + i1 + 1 < 256) + { + int k1; + int l1; + + for (int j1 = par4; j1 <= par4 + 1 + i1; ++j1) + { + byte b0 = 3; + + if (j1 <= par4 + 3) + { + b0 = 0; + } + + for (k1 = par3 - b0; k1 <= par3 + b0 && flag; ++k1) + { + for (l1 = par5 - b0; l1 <= par5 + b0 && flag; ++l1) + { + if (j1 >= 0 && j1 < 256) + { + Block block = par1World.getBlock(k1, j1, l1); + + if (!block.isAir(par1World, k1, j1, l1) && !block.isLeaves(par1World, k1, j1, l1)) + { + flag = false; + } + } + else + { + flag = false; + } + } + } + } + + if (!flag) + { + return false; + } + else + { + Block block1 = par1World.getBlock(par3, par4 - 1, par5); + + if (block1 != Blocks.dirt && block1 != Blocks.grass && block1 != Blocks.mycelium) + { + return false; + } + else + { + int k2 = par4 + i1; + + if (l == 1) + { + k2 = par4 + i1 - 3; + } + + for (k1 = k2; k1 <= par4 + i1; ++k1) + { + l1 = 1; + + if (k1 < par4 + i1) + { + ++l1; + } + + if (l == 0) + { + l1 = 3; + } + + for (int l2 = par3 - l1; l2 <= par3 + l1; ++l2) + { + for (int i2 = par5 - l1; i2 <= par5 + l1; ++i2) + { + int j2 = 5; + + if (l2 == par3 - l1) + { + --j2; + } + + if (l2 == par3 + l1) + { + ++j2; + } + + if (i2 == par5 - l1) + { + j2 -= 3; + } + + if (i2 == par5 + l1) + { + j2 += 3; + } + + if (l == 0 || k1 < par4 + i1) + { + if ((l2 == par3 - l1 || l2 == par3 + l1) && (i2 == par5 - l1 || i2 == par5 + l1)) + { + continue; + } + + if (l2 == par3 - (l1 - 1) && i2 == par5 - l1) + { + j2 = 1; + } + + if (l2 == par3 - l1 && i2 == par5 - (l1 - 1)) + { + j2 = 1; + } + + if (l2 == par3 + (l1 - 1) && i2 == par5 - l1) + { + j2 = 3; + } + + if (l2 == par3 + l1 && i2 == par5 - (l1 - 1)) + { + j2 = 3; + } + + if (l2 == par3 - (l1 - 1) && i2 == par5 + l1) + { + j2 = 7; + } + + if (l2 == par3 - l1 && i2 == par5 + (l1 - 1)) + { + j2 = 7; + } + + if (l2 == par3 + (l1 - 1) && i2 == par5 + l1) + { + j2 = 9; + } + + if (l2 == par3 + l1 && i2 == par5 + (l1 - 1)) + { + j2 = 9; + } + } + + if (j2 == 5 && k1 < par4 + i1) + { + j2 = 0; + } + + if ((j2 != 0 || par4 >= par4 + i1 - 1) && par1World.getBlock(l2, k1, i2).canBeReplacedByLeaves(par1World, l2, k1, i2)) + { + this.setBlockAndNotifyAdequately(par1World, l2, k1, i2, Block.getBlockById(Block.getIdFromBlock(Blocks.brown_mushroom_block) + l), j2); + } + } + } + } + + for (k1 = 0; k1 < i1; ++k1) + { + Block block2 = par1World.getBlock(par3, par4 + k1, par5); + + if (block2.canBeReplacedByLeaves(par1World, par3, par4 + k1, par5)) + { + this.setBlockAndNotifyAdequately(par1World, par3, par4 + k1, par5, Block.getBlockById(Block.getIdFromBlock(Blocks.brown_mushroom_block) + l), 10); + } + } + + return true; + } + } + } + else + { + return false; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/feature/WorldGenBigTree.java b/src/main/java/net/minecraft/world/gen/feature/WorldGenBigTree.java new file mode 100644 index 0000000..6929ab7 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/feature/WorldGenBigTree.java @@ -0,0 +1,460 @@ +package net.minecraft.world.gen.feature; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.block.BlockSapling; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public class WorldGenBigTree extends WorldGenAbstractTree +{ + static final byte[] otherCoordPairs = new byte[] {(byte)2, (byte)0, (byte)0, (byte)1, (byte)2, (byte)1}; + Random rand = new Random(); + World worldObj; + int[] basePos = new int[] {0, 0, 0}; + int heightLimit; + int height; + double heightAttenuation = 0.618D; + double branchDensity = 1.0D; + double branchSlope = 0.381D; + double scaleWidth = 1.0D; + double leafDensity = 1.0D; + int trunkSize = 1; + int heightLimitLimit = 12; + int leafDistanceLimit = 4; + int[][] leafNodes; + private static final String __OBFID = "CL_00000400"; + + public WorldGenBigTree(boolean par1) + { + super(par1); + } + + void generateLeafNodeList() + { + this.height = (int)((double)this.heightLimit * this.heightAttenuation); + + if (this.height >= this.heightLimit) + { + this.height = this.heightLimit - 1; + } + + int i = (int)(1.382D + Math.pow(this.leafDensity * (double)this.heightLimit / 13.0D, 2.0D)); + + if (i < 1) + { + i = 1; + } + + int[][] aint = new int[i * this.heightLimit][4]; + int j = this.basePos[1] + this.heightLimit - this.leafDistanceLimit; + int k = 1; + int l = this.basePos[1] + this.height; + int i1 = j - this.basePos[1]; + aint[0][0] = this.basePos[0]; + aint[0][1] = j; + aint[0][2] = this.basePos[2]; + aint[0][3] = l; + --j; + + while (i1 >= 0) + { + int j1 = 0; + float f = this.layerSize(i1); + + if (f < 0.0F) + { + --j; + --i1; + } + else + { + for (double d0 = 0.5D; j1 < i; ++j1) + { + double d1 = this.scaleWidth * (double)f * ((double)this.rand.nextFloat() + 0.328D); + double d2 = (double)this.rand.nextFloat() * 2.0D * Math.PI; + int k1 = MathHelper.floor_double(d1 * Math.sin(d2) + (double)this.basePos[0] + d0); + int l1 = MathHelper.floor_double(d1 * Math.cos(d2) + (double)this.basePos[2] + d0); + int[] aint1 = new int[] {k1, j, l1}; + int[] aint2 = new int[] {k1, j + this.leafDistanceLimit, l1}; + + if (this.checkBlockLine(aint1, aint2) == -1) + { + int[] aint3 = new int[] {this.basePos[0], this.basePos[1], this.basePos[2]}; + double d3 = Math.sqrt(Math.pow((double)Math.abs(this.basePos[0] - aint1[0]), 2.0D) + Math.pow((double)Math.abs(this.basePos[2] - aint1[2]), 2.0D)); + double d4 = d3 * this.branchSlope; + + if ((double)aint1[1] - d4 > (double)l) + { + aint3[1] = l; + } + else + { + aint3[1] = (int)((double)aint1[1] - d4); + } + + if (this.checkBlockLine(aint3, aint1) == -1) + { + aint[k][0] = k1; + aint[k][1] = j; + aint[k][2] = l1; + aint[k][3] = aint3[1]; + ++k; + } + } + } + + --j; + --i1; + } + } + + this.leafNodes = new int[k][4]; + System.arraycopy(aint, 0, this.leafNodes, 0, k); + } + + void func_150529_a(int p_150529_1_, int p_150529_2_, int p_150529_3_, float p_150529_4_, byte p_150529_5_, Block p_150529_6_) + { + int l = (int)((double)p_150529_4_ + 0.618D); + byte b1 = otherCoordPairs[p_150529_5_]; + byte b2 = otherCoordPairs[p_150529_5_ + 3]; + int[] aint = new int[] {p_150529_1_, p_150529_2_, p_150529_3_}; + int[] aint1 = new int[] {0, 0, 0}; + int i1 = -l; + int j1 = -l; + + for (aint1[p_150529_5_] = aint[p_150529_5_]; i1 <= l; ++i1) + { + aint1[b1] = aint[b1] + i1; + j1 = -l; + + while (j1 <= l) + { + double d0 = Math.pow((double)Math.abs(i1) + 0.5D, 2.0D) + Math.pow((double)Math.abs(j1) + 0.5D, 2.0D); + + if (d0 > (double)(p_150529_4_ * p_150529_4_)) + { + ++j1; + } + else + { + aint1[b2] = aint[b2] + j1; + Block block1 = this.worldObj.getBlock(aint1[0], aint1[1], aint1[2]); + + if (!block1.isAir(worldObj, aint1[0], aint1[1], aint1[2]) && !block1.isLeaves(worldObj, aint1[0], aint1[1], aint1[2])) + { + ++j1; + } + else + { + this.setBlockAndNotifyAdequately(this.worldObj, aint1[0], aint1[1], aint1[2], p_150529_6_, 0); + ++j1; + } + } + } + } + } + + float layerSize(int par1) + { + if ((double)par1 < (double)((float)this.heightLimit) * 0.3D) + { + return -1.618F; + } + else + { + float f = (float)this.heightLimit / 2.0F; + float f1 = (float)this.heightLimit / 2.0F - (float)par1; + float f2; + + if (f1 == 0.0F) + { + f2 = f; + } + else if (Math.abs(f1) >= f) + { + f2 = 0.0F; + } + else + { + f2 = (float)Math.sqrt(Math.pow((double)Math.abs(f), 2.0D) - Math.pow((double)Math.abs(f1), 2.0D)); + } + + f2 *= 0.5F; + return f2; + } + } + + float leafSize(int par1) + { + return par1 >= 0 && par1 < this.leafDistanceLimit ? (par1 != 0 && par1 != this.leafDistanceLimit - 1 ? 3.0F : 2.0F) : -1.0F; + } + + void generateLeafNode(int par1, int par2, int par3) + { + int l = par2; + + for (int i1 = par2 + this.leafDistanceLimit; l < i1; ++l) + { + float f = this.leafSize(l - par2); + this.func_150529_a(par1, l, par3, f, (byte)1, Blocks.leaves); + } + } + + void func_150530_a(int[] p_150530_1_, int[] p_150530_2_, Block p_150530_3_) + { + int[] aint2 = new int[] {0, 0, 0}; + byte b0 = 0; + byte b1; + + for (b1 = 0; b0 < 3; ++b0) + { + aint2[b0] = p_150530_2_[b0] - p_150530_1_[b0]; + + if (Math.abs(aint2[b0]) > Math.abs(aint2[b1])) + { + b1 = b0; + } + } + + if (aint2[b1] != 0) + { + byte b2 = otherCoordPairs[b1]; + byte b3 = otherCoordPairs[b1 + 3]; + byte b4; + + if (aint2[b1] > 0) + { + b4 = 1; + } + else + { + b4 = -1; + } + + double d0 = (double)aint2[b2] / (double)aint2[b1]; + double d1 = (double)aint2[b3] / (double)aint2[b1]; + int[] aint3 = new int[] {0, 0, 0}; + int i = 0; + + for (int j = aint2[b1] + b4; i != j; i += b4) + { + aint3[b1] = MathHelper.floor_double((double)(p_150530_1_[b1] + i) + 0.5D); + aint3[b2] = MathHelper.floor_double((double)p_150530_1_[b2] + (double)i * d0 + 0.5D); + aint3[b3] = MathHelper.floor_double((double)p_150530_1_[b3] + (double)i * d1 + 0.5D); + byte b5 = 0; + int k = Math.abs(aint3[0] - p_150530_1_[0]); + int l = Math.abs(aint3[2] - p_150530_1_[2]); + int i1 = Math.max(k, l); + + if (i1 > 0) + { + if (k == i1) + { + b5 = 4; + } + else if (l == i1) + { + b5 = 8; + } + } + + this.setBlockAndNotifyAdequately(this.worldObj, aint3[0], aint3[1], aint3[2], p_150530_3_, b5); + } + } + } + + void generateLeaves() + { + int i = 0; + + for (int j = this.leafNodes.length; i < j; ++i) + { + int k = this.leafNodes[i][0]; + int l = this.leafNodes[i][1]; + int i1 = this.leafNodes[i][2]; + this.generateLeafNode(k, l, i1); + } + } + + boolean leafNodeNeedsBase(int par1) + { + return (double)par1 >= (double)this.heightLimit * 0.2D; + } + + void generateTrunk() + { + int i = this.basePos[0]; + int j = this.basePos[1]; + int k = this.basePos[1] + this.height; + int l = this.basePos[2]; + int[] aint = new int[] {i, j, l}; + int[] aint1 = new int[] {i, k, l}; + this.func_150530_a(aint, aint1, Blocks.log); + + if (this.trunkSize == 2) + { + ++aint[0]; + ++aint1[0]; + this.func_150530_a(aint, aint1, Blocks.log); + ++aint[2]; + ++aint1[2]; + this.func_150530_a(aint, aint1, Blocks.log); + aint[0] += -1; + aint1[0] += -1; + this.func_150530_a(aint, aint1, Blocks.log); + } + } + + void generateLeafNodeBases() + { + int i = 0; + int j = this.leafNodes.length; + + for (int[] aint = new int[] {this.basePos[0], this.basePos[1], this.basePos[2]}; i < j; ++i) + { + int[] aint1 = this.leafNodes[i]; + int[] aint2 = new int[] {aint1[0], aint1[1], aint1[2]}; + aint[1] = aint1[3]; + int k = aint[1] - this.basePos[1]; + + if (this.leafNodeNeedsBase(k)) + { + this.func_150530_a(aint, aint2, Blocks.log); + } + } + } + + int checkBlockLine(int[] par1ArrayOfInteger, int[] par2ArrayOfInteger) + { + int[] aint2 = new int[] {0, 0, 0}; + byte b0 = 0; + byte b1; + + for (b1 = 0; b0 < 3; ++b0) + { + aint2[b0] = par2ArrayOfInteger[b0] - par1ArrayOfInteger[b0]; + + if (Math.abs(aint2[b0]) > Math.abs(aint2[b1])) + { + b1 = b0; + } + } + + if (aint2[b1] == 0) + { + return -1; + } + else + { + byte b2 = otherCoordPairs[b1]; + byte b3 = otherCoordPairs[b1 + 3]; + byte b4; + + if (aint2[b1] > 0) + { + b4 = 1; + } + else + { + b4 = -1; + } + + double d0 = (double)aint2[b2] / (double)aint2[b1]; + double d1 = (double)aint2[b3] / (double)aint2[b1]; + int[] aint3 = new int[] {0, 0, 0}; + int i = 0; + int j; + + for (j = aint2[b1] + b4; i != j; i += b4) + { + aint3[b1] = par1ArrayOfInteger[b1] + i; + aint3[b2] = MathHelper.floor_double((double)par1ArrayOfInteger[b2] + (double)i * d0); + aint3[b3] = MathHelper.floor_double((double)par1ArrayOfInteger[b3] + (double)i * d1); + Block block = this.worldObj.getBlock(aint3[0], aint3[1], aint3[2]); + + if (!this.isReplaceable(worldObj, aint3[0], aint3[1], aint3[2])) + { + break; + } + } + + return i == j ? -1 : Math.abs(i); + } + } + + boolean validTreeLocation() + { + int[] aint = new int[] {this.basePos[0], this.basePos[1], this.basePos[2]}; + int[] aint1 = new int[] {this.basePos[0], this.basePos[1] + this.heightLimit - 1, this.basePos[2]}; + Block block = this.worldObj.getBlock(this.basePos[0], this.basePos[1] - 1, this.basePos[2]); + + boolean isSoil = block.canSustainPlant(worldObj, basePos[0], basePos[1] - 1, basePos[2], ForgeDirection.UP, (BlockSapling)Blocks.sapling); + if (!isSoil) + { + return false; + } + else + { + int i = this.checkBlockLine(aint, aint1); + + if (i == -1) + { + return true; + } + else if (i < 6) + { + return false; + } + else + { + this.heightLimit = i; + return true; + } + } + } + + public void setScale(double par1, double par3, double par5) + { + this.heightLimitLimit = (int)(par1 * 12.0D); + + if (par1 > 0.5D) + { + this.leafDistanceLimit = 5; + } + + this.scaleWidth = par3; + this.leafDensity = par5; + } + + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + this.worldObj = par1World; + long l = par2Random.nextLong(); + this.rand.setSeed(l); + this.basePos[0] = par3; + this.basePos[1] = par4; + this.basePos[2] = par5; + + if (this.heightLimit == 0) + { + this.heightLimit = 5 + this.rand.nextInt(this.heightLimitLimit); + } + + if (!this.validTreeLocation()) + { + return false; + } + else + { + this.generateLeafNodeList(); + this.generateLeaves(); + this.generateTrunk(); + this.generateLeafNodeBases(); + return true; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/feature/WorldGenBlockBlob.java b/src/main/java/net/minecraft/world/gen/feature/WorldGenBlockBlob.java new file mode 100644 index 0000000..0bb7055 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/feature/WorldGenBlockBlob.java @@ -0,0 +1,84 @@ +package net.minecraft.world.gen.feature; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; + +public class WorldGenBlockBlob extends WorldGenerator +{ + private Block field_150545_a; + private int field_150544_b; + private static final String __OBFID = "CL_00000402"; + + public WorldGenBlockBlob(Block p_i45450_1_, int p_i45450_2_) + { + super(false); + this.field_150545_a = p_i45450_1_; + this.field_150544_b = p_i45450_2_; + } + + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + while (true) + { + if (par4 > 3) + { + label63: + { + if (!par1World.isAirBlock(par3, par4 - 1, par5)) + { + Block block = par1World.getBlock(par3, par4 - 1, par5); + + if (block == Blocks.grass || block == Blocks.dirt || block == Blocks.stone) + { + break label63; + } + } + + --par4; + continue; + } + } + + if (par4 <= 3) + { + return false; + } + + int k2 = this.field_150544_b; + + for (int l = 0; k2 >= 0 && l < 3; ++l) + { + int i1 = k2 + par2Random.nextInt(2); + int j1 = k2 + par2Random.nextInt(2); + int k1 = k2 + par2Random.nextInt(2); + float f = (float)(i1 + j1 + k1) * 0.333F + 0.5F; + + for (int l1 = par3 - i1; l1 <= par3 + i1; ++l1) + { + for (int i2 = par5 - k1; i2 <= par5 + k1; ++i2) + { + for (int j2 = par4 - j1; j2 <= par4 + j1; ++j2) + { + float f1 = (float)(l1 - par3); + float f2 = (float)(i2 - par5); + float f3 = (float)(j2 - par4); + + if (f1 * f1 + f2 * f2 + f3 * f3 <= f * f) + { + par1World.setBlock(l1, j2, i2, this.field_150545_a, 0, 4); + } + } + } + } + + par3 += -(k2 + 1) + par2Random.nextInt(2 + k2 * 2); + par5 += -(k2 + 1) + par2Random.nextInt(2 + k2 * 2); + par4 += 0 - par2Random.nextInt(2); + } + + return true; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/feature/WorldGenCactus.java b/src/main/java/net/minecraft/world/gen/feature/WorldGenCactus.java new file mode 100644 index 0000000..8a07ffa --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/feature/WorldGenCactus.java @@ -0,0 +1,35 @@ +package net.minecraft.world.gen.feature; + +import java.util.Random; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; + +public class WorldGenCactus extends WorldGenerator +{ + private static final String __OBFID = "CL_00000404"; + + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + for (int l = 0; l < 10; ++l) + { + int i1 = par3 + par2Random.nextInt(8) - par2Random.nextInt(8); + int j1 = par4 + par2Random.nextInt(4) - par2Random.nextInt(4); + int k1 = par5 + par2Random.nextInt(8) - par2Random.nextInt(8); + + if (par1World.isAirBlock(i1, j1, k1)) + { + int l1 = 1 + par2Random.nextInt(par2Random.nextInt(3) + 1); + + for (int i2 = 0; i2 < l1; ++i2) + { + if (Blocks.cactus.canBlockStay(par1World, i1, j1 + i2, k1)) + { + par1World.setBlock(i1, j1 + i2, k1, Blocks.cactus, 0, 2); + } + } + } + } + + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/feature/WorldGenCanopyTree.java b/src/main/java/net/minecraft/world/gen/feature/WorldGenCanopyTree.java new file mode 100644 index 0000000..801a94c --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/feature/WorldGenCanopyTree.java @@ -0,0 +1,220 @@ +package net.minecraft.world.gen.feature; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.block.BlockSapling; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.util.Direction; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public class WorldGenCanopyTree extends WorldGenAbstractTree +{ + private static final String __OBFID = "CL_00000430"; + + public WorldGenCanopyTree(boolean p_i45461_1_) + { + super(p_i45461_1_); + } + + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + int l = par2Random.nextInt(3) + par2Random.nextInt(2) + 6; + boolean flag = true; + + if (par4 >= 1 && par4 + l + 1 <= 256) + { + int j1; + int k1; + + for (int i1 = par4; i1 <= par4 + 1 + l; ++i1) + { + byte b0 = 1; + + if (i1 == par4) + { + b0 = 0; + } + + if (i1 >= par4 + 1 + l - 2) + { + b0 = 2; + } + + for (j1 = par3 - b0; j1 <= par3 + b0 && flag; ++j1) + { + for (k1 = par5 - b0; k1 <= par5 + b0 && flag; ++k1) + { + if (i1 >= 0 && i1 < 256) + { + Block block = par1World.getBlock(j1, i1, k1); + + if (!this.isReplaceable(par1World, j1, i1, k1)) + { + flag = false; + } + } + else + { + flag = false; + } + } + } + } + + if (!flag) + { + return false; + } + else + { + Block block2 = par1World.getBlock(par3, par4 - 1, par5); + + boolean isSoil = block2.canSustainPlant(par1World, par3, par4 - 1, par5, ForgeDirection.UP, (BlockSapling)Blocks.sapling); + if (isSoil && par4 < 256 - l - 1) + { + onPlantGrow(par1World, par3, par4 - 1, par5, par3, par4, par5); + onPlantGrow(par1World, par3 + 1, par4 - 1, par5, par3, par4, par5); + onPlantGrow(par1World, par3 + 1, par4 - 1, par5 + 1, par3, par4, par5); + onPlantGrow(par1World, par3, par4 - 1, par5 + 1, par3, par4, par5); + int j3 = par2Random.nextInt(4); + j1 = l - par2Random.nextInt(4); + k1 = 2 - par2Random.nextInt(3); + int k3 = par3; + int l1 = par5; + int i2 = 0; + int j2; + int k2; + + for (j2 = 0; j2 < l; ++j2) + { + k2 = par4 + j2; + + if (j2 >= j1 && k1 > 0) + { + k3 += Direction.offsetX[j3]; + l1 += Direction.offsetZ[j3]; + --k1; + } + + Block block1 = par1World.getBlock(k3, k2, l1); + + if (block1.isAir(par1World, k3, k2, l1) || block1.isLeaves(par1World, k3, k2, l1)) + { + this.setBlockAndNotifyAdequately(par1World, k3, k2, l1, Blocks.log2, 1); + this.setBlockAndNotifyAdequately(par1World, k3 + 1, k2, l1, Blocks.log2, 1); + this.setBlockAndNotifyAdequately(par1World, k3, k2, l1 + 1, Blocks.log2, 1); + this.setBlockAndNotifyAdequately(par1World, k3 + 1, k2, l1 + 1, Blocks.log2, 1); + i2 = k2; + } + } + + for (j2 = -2; j2 <= 0; ++j2) + { + for (k2 = -2; k2 <= 0; ++k2) + { + byte b1 = -1; + this.func_150526_a(par1World, k3 + j2, i2 + b1, l1 + k2); + this.func_150526_a(par1World, 1 + k3 - j2, i2 + b1, l1 + k2); + this.func_150526_a(par1World, k3 + j2, i2 + b1, 1 + l1 - k2); + this.func_150526_a(par1World, 1 + k3 - j2, i2 + b1, 1 + l1 - k2); + + if ((j2 > -2 || k2 > -1) && (j2 != -1 || k2 != -2)) + { + byte b2 = 1; + this.func_150526_a(par1World, k3 + j2, i2 + b2, l1 + k2); + this.func_150526_a(par1World, 1 + k3 - j2, i2 + b2, l1 + k2); + this.func_150526_a(par1World, k3 + j2, i2 + b2, 1 + l1 - k2); + this.func_150526_a(par1World, 1 + k3 - j2, i2 + b2, 1 + l1 - k2); + } + } + } + + if (par2Random.nextBoolean()) + { + this.func_150526_a(par1World, k3, i2 + 2, l1); + this.func_150526_a(par1World, k3 + 1, i2 + 2, l1); + this.func_150526_a(par1World, k3 + 1, i2 + 2, l1 + 1); + this.func_150526_a(par1World, k3, i2 + 2, l1 + 1); + } + + for (j2 = -3; j2 <= 4; ++j2) + { + for (k2 = -3; k2 <= 4; ++k2) + { + if ((j2 != -3 || k2 != -3) && (j2 != -3 || k2 != 4) && (j2 != 4 || k2 != -3) && (j2 != 4 || k2 != 4) && (Math.abs(j2) < 3 || Math.abs(k2) < 3)) + { + this.func_150526_a(par1World, k3 + j2, i2, l1 + k2); + } + } + } + + for (j2 = -1; j2 <= 2; ++j2) + { + for (k2 = -1; k2 <= 2; ++k2) + { + if ((j2 < 0 || j2 > 1 || k2 < 0 || k2 > 1) && par2Random.nextInt(3) <= 0) + { + int l3 = par2Random.nextInt(3) + 2; + int l2; + + for (l2 = 0; l2 < l3; ++l2) + { + this.setBlockAndNotifyAdequately(par1World, par3 + j2, i2 - l2 - 1, par5 + k2, Blocks.log2, 1); + } + + int i3; + + for (l2 = -1; l2 <= 1; ++l2) + { + for (i3 = -1; i3 <= 1; ++i3) + { + this.func_150526_a(par1World, k3 + j2 + l2, i2 - 0, l1 + k2 + i3); + } + } + + for (l2 = -2; l2 <= 2; ++l2) + { + for (i3 = -2; i3 <= 2; ++i3) + { + if (Math.abs(l2) != 2 || Math.abs(i3) != 2) + { + this.func_150526_a(par1World, k3 + j2 + l2, i2 - 1, l1 + k2 + i3); + } + } + } + } + } + } + + return true; + } + else + { + return false; + } + } + } + else + { + return false; + } + } + + private void func_150526_a(World p_150526_1_, int p_150526_2_, int p_150526_3_, int p_150526_4_) + { + Block block = p_150526_1_.getBlock(p_150526_2_, p_150526_3_, p_150526_4_); + + if (block.isAir(p_150526_1_, p_150526_2_, p_150526_3_, p_150526_4_)) + { + this.setBlockAndNotifyAdequately(p_150526_1_, p_150526_2_, p_150526_3_, p_150526_4_, Blocks.leaves2, 1); + } + } + + //Just a helper macro + private void onPlantGrow(World world, int x, int y, int z, int sourceX, int sourceY, int sourceZ) + { + world.getBlock(x, y, z).onPlantGrow(world, x, y, z, sourceX, sourceY, sourceZ); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/feature/WorldGenClay.java b/src/main/java/net/minecraft/world/gen/feature/WorldGenClay.java new file mode 100644 index 0000000..c6adcd5 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/feature/WorldGenClay.java @@ -0,0 +1,57 @@ +package net.minecraft.world.gen.feature; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; + +public class WorldGenClay extends WorldGenerator +{ + private Block field_150546_a; + private int numberOfBlocks; + private static final String __OBFID = "CL_00000405"; + + public WorldGenClay(int par1) + { + this.field_150546_a = Blocks.clay; + this.numberOfBlocks = par1; + } + + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + if (par1World.getBlock(par3, par4, par5).getMaterial() != Material.water) + { + return false; + } + else + { + int l = par2Random.nextInt(this.numberOfBlocks - 2) + 2; + byte b0 = 1; + + for (int i1 = par3 - l; i1 <= par3 + l; ++i1) + { + for (int j1 = par5 - l; j1 <= par5 + l; ++j1) + { + int k1 = i1 - par3; + int l1 = j1 - par5; + + if (k1 * k1 + l1 * l1 <= l * l) + { + for (int i2 = par4 - b0; i2 <= par4 + b0; ++i2) + { + Block block = par1World.getBlock(i1, i2, j1); + + if (block == Blocks.dirt || block == Blocks.clay) + { + par1World.setBlock(i1, i2, j1, this.field_150546_a, 0, 2); + } + } + } + } + } + + return true; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/feature/WorldGenDeadBush.java b/src/main/java/net/minecraft/world/gen/feature/WorldGenDeadBush.java new file mode 100644 index 0000000..ad8305b --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/feature/WorldGenDeadBush.java @@ -0,0 +1,46 @@ +package net.minecraft.world.gen.feature; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.world.World; + +public class WorldGenDeadBush extends WorldGenerator +{ + private Block field_150547_a; + private static final String __OBFID = "CL_00000406"; + + public WorldGenDeadBush(Block p_i45451_1_) + { + this.field_150547_a = p_i45451_1_; + } + + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + Block block; + + do + { + block = par1World.getBlock(par3, par4, par5); + if (!(block.isLeaves(par1World, par3, par4, par5) || block.isAir(par1World, par3, par4, par5))) + { + break; + } + --par4; + } while (par4 > 0); + + for (int l = 0; l < 4; ++l) + { + int i1 = par3 + par2Random.nextInt(8) - par2Random.nextInt(8); + int j1 = par4 + par2Random.nextInt(4) - par2Random.nextInt(4); + int k1 = par5 + par2Random.nextInt(8) - par2Random.nextInt(8); + + if (par1World.isAirBlock(i1, j1, k1) && this.field_150547_a.canBlockStay(par1World, i1, j1, k1)) + { + par1World.setBlock(i1, j1, k1, this.field_150547_a, 0, 2); + } + } + + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/feature/WorldGenDesertWells.java b/src/main/java/net/minecraft/world/gen/feature/WorldGenDesertWells.java new file mode 100644 index 0000000..2fab1d6 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/feature/WorldGenDesertWells.java @@ -0,0 +1,97 @@ +package net.minecraft.world.gen.feature; + +import java.util.Random; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; + +public class WorldGenDesertWells extends WorldGenerator +{ + private static final String __OBFID = "CL_00000407"; + + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + while (par1World.isAirBlock(par3, par4, par5) && par4 > 2) + { + --par4; + } + + if (par1World.getBlock(par3, par4, par5) != Blocks.sand) + { + return false; + } + else + { + int l; + int i1; + + for (l = -2; l <= 2; ++l) + { + for (i1 = -2; i1 <= 2; ++i1) + { + if (par1World.isAirBlock(par3 + l, par4 - 1, par5 + i1) && par1World.isAirBlock(par3 + l, par4 - 2, par5 + i1)) + { + return false; + } + } + } + + for (l = -1; l <= 0; ++l) + { + for (i1 = -2; i1 <= 2; ++i1) + { + for (int j1 = -2; j1 <= 2; ++j1) + { + par1World.setBlock(par3 + i1, par4 + l, par5 + j1, Blocks.sandstone, 0, 2); + } + } + } + + par1World.setBlock(par3, par4, par5, Blocks.flowing_water, 0, 2); + par1World.setBlock(par3 - 1, par4, par5, Blocks.flowing_water, 0, 2); + par1World.setBlock(par3 + 1, par4, par5, Blocks.flowing_water, 0, 2); + par1World.setBlock(par3, par4, par5 - 1, Blocks.flowing_water, 0, 2); + par1World.setBlock(par3, par4, par5 + 1, Blocks.flowing_water, 0, 2); + + for (l = -2; l <= 2; ++l) + { + for (i1 = -2; i1 <= 2; ++i1) + { + if (l == -2 || l == 2 || i1 == -2 || i1 == 2) + { + par1World.setBlock(par3 + l, par4 + 1, par5 + i1, Blocks.sandstone, 0, 2); + } + } + } + + par1World.setBlock(par3 + 2, par4 + 1, par5, Blocks.stone_slab, 1, 2); + par1World.setBlock(par3 - 2, par4 + 1, par5, Blocks.stone_slab, 1, 2); + par1World.setBlock(par3, par4 + 1, par5 + 2, Blocks.stone_slab, 1, 2); + par1World.setBlock(par3, par4 + 1, par5 - 2, Blocks.stone_slab, 1, 2); + + for (l = -1; l <= 1; ++l) + { + for (i1 = -1; i1 <= 1; ++i1) + { + if (l == 0 && i1 == 0) + { + par1World.setBlock(par3 + l, par4 + 4, par5 + i1, Blocks.sandstone, 0, 2); + } + else + { + par1World.setBlock(par3 + l, par4 + 4, par5 + i1, Blocks.stone_slab, 1, 2); + } + } + } + + for (l = 1; l <= 3; ++l) + { + par1World.setBlock(par3 - 1, par4 + l, par5 - 1, Blocks.sandstone, 0, 2); + par1World.setBlock(par3 - 1, par4 + l, par5 + 1, Blocks.sandstone, 0, 2); + par1World.setBlock(par3 + 1, par4 + l, par5 - 1, Blocks.sandstone, 0, 2); + par1World.setBlock(par3 + 1, par4 + l, par5 + 1, Blocks.sandstone, 0, 2); + } + + return true; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/feature/WorldGenDoublePlant.java b/src/main/java/net/minecraft/world/gen/feature/WorldGenDoublePlant.java new file mode 100644 index 0000000..fef33d7 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/feature/WorldGenDoublePlant.java @@ -0,0 +1,36 @@ +package net.minecraft.world.gen.feature; + +import java.util.Random; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; + +public class WorldGenDoublePlant extends WorldGenerator +{ + private int field_150549_a; + private static final String __OBFID = "CL_00000408"; + + public void func_150548_a(int p_150548_1_) + { + this.field_150549_a = p_150548_1_; + } + + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + boolean flag = false; + + for (int l = 0; l < 64; ++l) + { + int i1 = par3 + par2Random.nextInt(8) - par2Random.nextInt(8); + int j1 = par4 + par2Random.nextInt(4) - par2Random.nextInt(4); + int k1 = par5 + par2Random.nextInt(8) - par2Random.nextInt(8); + + if (par1World.isAirBlock(i1, j1, k1) && (!par1World.provider.hasNoSky || j1 < 254) && Blocks.double_plant.canPlaceBlockAt(par1World, i1, j1, k1)) + { + Blocks.double_plant.func_149889_c(par1World, i1, j1, k1, this.field_150549_a, 2); + flag = true; + } + } + + return flag; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/feature/WorldGenDungeons.java b/src/main/java/net/minecraft/world/gen/feature/WorldGenDungeons.java new file mode 100644 index 0000000..3a3ceb2 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/feature/WorldGenDungeons.java @@ -0,0 +1,174 @@ +package net.minecraft.world.gen.feature; + +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.tileentity.TileEntityChest; +import net.minecraft.tileentity.TileEntityMobSpawner; +import net.minecraft.util.WeightedRandomChestContent; +import net.minecraft.world.World; +import net.minecraftforge.common.ChestGenHooks; +import net.minecraftforge.common.DungeonHooks; +import static net.minecraftforge.common.ChestGenHooks.DUNGEON_CHEST;; + +public class WorldGenDungeons extends WorldGenerator +{ + public static final WeightedRandomChestContent[] field_111189_a = new WeightedRandomChestContent[] {new WeightedRandomChestContent(Items.saddle, 0, 1, 1, 10), new WeightedRandomChestContent(Items.iron_ingot, 0, 1, 4, 10), new WeightedRandomChestContent(Items.bread, 0, 1, 1, 10), new WeightedRandomChestContent(Items.wheat, 0, 1, 4, 10), new WeightedRandomChestContent(Items.gunpowder, 0, 1, 4, 10), new WeightedRandomChestContent(Items.string, 0, 1, 4, 10), new WeightedRandomChestContent(Items.bucket, 0, 1, 1, 10), new WeightedRandomChestContent(Items.golden_apple, 0, 1, 1, 1), new WeightedRandomChestContent(Items.redstone, 0, 1, 4, 10), new WeightedRandomChestContent(Items.record_13, 0, 1, 1, 10), new WeightedRandomChestContent(Items.record_cat, 0, 1, 1, 10), new WeightedRandomChestContent(Items.name_tag, 0, 1, 1, 10), new WeightedRandomChestContent(Items.golden_horse_armor, 0, 1, 1, 2), new WeightedRandomChestContent(Items.iron_horse_armor, 0, 1, 1, 5), new WeightedRandomChestContent(Items.diamond_horse_armor, 0, 1, 1, 1)}; + private static final String __OBFID = "CL_00000425"; + + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + byte b0 = 3; + int l = par2Random.nextInt(2) + 2; + int i1 = par2Random.nextInt(2) + 2; + int j1 = 0; + int k1; + int l1; + int i2; + + for (k1 = par3 - l - 1; k1 <= par3 + l + 1; ++k1) + { + for (l1 = par4 - 1; l1 <= par4 + b0 + 1; ++l1) + { + for (i2 = par5 - i1 - 1; i2 <= par5 + i1 + 1; ++i2) + { + Material material = par1World.getBlock(k1, l1, i2).getMaterial(); + + if (l1 == par4 - 1 && !material.isSolid()) + { + return false; + } + + if (l1 == par4 + b0 + 1 && !material.isSolid()) + { + return false; + } + + if ((k1 == par3 - l - 1 || k1 == par3 + l + 1 || i2 == par5 - i1 - 1 || i2 == par5 + i1 + 1) && l1 == par4 && par1World.isAirBlock(k1, l1, i2) && par1World.isAirBlock(k1, l1 + 1, i2)) + { + ++j1; + } + } + } + } + + if (j1 >= 1 && j1 <= 5) + { + for (k1 = par3 - l - 1; k1 <= par3 + l + 1; ++k1) + { + for (l1 = par4 + b0; l1 >= par4 - 1; --l1) + { + for (i2 = par5 - i1 - 1; i2 <= par5 + i1 + 1; ++i2) + { + if (k1 != par3 - l - 1 && l1 != par4 - 1 && i2 != par5 - i1 - 1 && k1 != par3 + l + 1 && l1 != par4 + b0 + 1 && i2 != par5 + i1 + 1) + { + par1World.setBlockToAir(k1, l1, i2); + } + else if (l1 >= 0 && !par1World.getBlock(k1, l1 - 1, i2).getMaterial().isSolid()) + { + par1World.setBlockToAir(k1, l1, i2); + } + else if (par1World.getBlock(k1, l1, i2).getMaterial().isSolid()) + { + if (l1 == par4 - 1 && par2Random.nextInt(4) != 0) + { + par1World.setBlock(k1, l1, i2, Blocks.mossy_cobblestone, 0, 2); + } + else + { + par1World.setBlock(k1, l1, i2, Blocks.cobblestone, 0, 2); + } + } + } + } + } + + k1 = 0; + + while (k1 < 2) + { + l1 = 0; + + while (true) + { + if (l1 < 3) + { + label101: + { + i2 = par3 + par2Random.nextInt(l * 2 + 1) - l; + int j2 = par5 + par2Random.nextInt(i1 * 2 + 1) - i1; + + if (par1World.isAirBlock(i2, par4, j2)) + { + int k2 = 0; + + if (par1World.getBlock(i2 - 1, par4, j2).getMaterial().isSolid()) + { + ++k2; + } + + if (par1World.getBlock(i2 + 1, par4, j2).getMaterial().isSolid()) + { + ++k2; + } + + if (par1World.getBlock(i2, par4, j2 - 1).getMaterial().isSolid()) + { + ++k2; + } + + if (par1World.getBlock(i2, par4, j2 + 1).getMaterial().isSolid()) + { + ++k2; + } + + if (k2 == 1) + { + par1World.setBlock(i2, par4, j2, Blocks.chest, 0, 2); + TileEntityChest tileentitychest = (TileEntityChest)par1World.getTileEntity(i2, par4, j2); + + if (tileentitychest != null) + { + WeightedRandomChestContent.generateChestContents(par2Random, ChestGenHooks.getItems(DUNGEON_CHEST, par2Random), tileentitychest, ChestGenHooks.getCount(DUNGEON_CHEST, par2Random)); + } + + break label101; + } + } + + ++l1; + continue; + } + } + + ++k1; + break; + } + } + + par1World.setBlock(par3, par4, par5, Blocks.mob_spawner, 0, 2); + TileEntityMobSpawner tileentitymobspawner = (TileEntityMobSpawner)par1World.getTileEntity(par3, par4, par5); + + if (tileentitymobspawner != null) + { + tileentitymobspawner.func_145881_a().setEntityName(this.pickMobSpawner(par2Random)); + } + else + { + System.err.println("Failed to fetch mob spawner entity at (" + par3 + ", " + par4 + ", " + par5 + ")"); + } + + return true; + } + else + { + return false; + } + } + + private String pickMobSpawner(Random par1Random) + { + return DungeonHooks.getRandomDungeonMob(par1Random); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/feature/WorldGenFire.java b/src/main/java/net/minecraft/world/gen/feature/WorldGenFire.java new file mode 100644 index 0000000..e6f1664 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/feature/WorldGenFire.java @@ -0,0 +1,27 @@ +package net.minecraft.world.gen.feature; + +import java.util.Random; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; + +public class WorldGenFire extends WorldGenerator +{ + private static final String __OBFID = "CL_00000412"; + + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + for (int l = 0; l < 64; ++l) + { + int i1 = par3 + par2Random.nextInt(8) - par2Random.nextInt(8); + int j1 = par4 + par2Random.nextInt(4) - par2Random.nextInt(4); + int k1 = par5 + par2Random.nextInt(8) - par2Random.nextInt(8); + + if (par1World.isAirBlock(i1, j1, k1) && par1World.getBlock(i1, j1 - 1, k1) == Blocks.netherrack) + { + par1World.setBlock(i1, j1, k1, Blocks.fire, 0, 2); + } + } + + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/feature/WorldGenFlowers.java b/src/main/java/net/minecraft/world/gen/feature/WorldGenFlowers.java new file mode 100644 index 0000000..a436253 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/feature/WorldGenFlowers.java @@ -0,0 +1,40 @@ +package net.minecraft.world.gen.feature; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.world.World; + +public class WorldGenFlowers extends WorldGenerator +{ + private Block field_150552_a; + private int field_150551_b; + private static final String __OBFID = "CL_00000410"; + + public WorldGenFlowers(Block p_i45452_1_) + { + this.field_150552_a = p_i45452_1_; + } + + public void func_150550_a(Block p_150550_1_, int p_150550_2_) + { + this.field_150552_a = p_150550_1_; + this.field_150551_b = p_150550_2_; + } + + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + for (int l = 0; l < 64; ++l) + { + int i1 = par3 + par2Random.nextInt(8) - par2Random.nextInt(8); + int j1 = par4 + par2Random.nextInt(4) - par2Random.nextInt(4); + int k1 = par5 + par2Random.nextInt(8) - par2Random.nextInt(8); + + if (par1World.isAirBlock(i1, j1, k1) && (!par1World.provider.hasNoSky || j1 < 255) && this.field_150552_a.canBlockStay(par1World, i1, j1, k1)) + { + par1World.setBlock(i1, j1, k1, this.field_150552_a, this.field_150551_b, 2); + } + } + + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/feature/WorldGenForest.java b/src/main/java/net/minecraft/world/gen/feature/WorldGenForest.java new file mode 100644 index 0000000..5689936 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/feature/WorldGenForest.java @@ -0,0 +1,136 @@ +package net.minecraft.world.gen.feature; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.block.BlockSapling; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public class WorldGenForest extends WorldGenAbstractTree +{ + private boolean field_150531_a; + private static final String __OBFID = "CL_00000401"; + + public WorldGenForest(boolean p_i45449_1_, boolean p_i45449_2_) + { + super(p_i45449_1_); + this.field_150531_a = p_i45449_2_; + } + + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + int l = par2Random.nextInt(3) + 5; + + if (this.field_150531_a) + { + l += par2Random.nextInt(7); + } + + boolean flag = true; + + if (par4 >= 1 && par4 + l + 1 <= 256) + { + int j1; + int k1; + + for (int i1 = par4; i1 <= par4 + 1 + l; ++i1) + { + byte b0 = 1; + + if (i1 == par4) + { + b0 = 0; + } + + if (i1 >= par4 + 1 + l - 2) + { + b0 = 2; + } + + for (j1 = par3 - b0; j1 <= par3 + b0 && flag; ++j1) + { + for (k1 = par5 - b0; k1 <= par5 + b0 && flag; ++k1) + { + if (i1 >= 0 && i1 < 256) + { + Block block = par1World.getBlock(j1, i1, k1); + + if (!this.isReplaceable(par1World, j1, i1, k1)) + { + flag = false; + } + } + else + { + flag = false; + } + } + } + } + + if (!flag) + { + return false; + } + else + { + Block block2 = par1World.getBlock(par3, par4 - 1, par5); + + boolean isSoil = block2.canSustainPlant(par1World, par3, par4 - 1, par5, ForgeDirection.UP, (BlockSapling)Blocks.sapling); + if (isSoil && par4 < 256 - l - 1) + { + block2.onPlantGrow(par1World, par3, par4 - 1, par5, par3, par4, par5); + int k2; + + for (k2 = par4 - 3 + l; k2 <= par4 + l; ++k2) + { + j1 = k2 - (par4 + l); + k1 = 1 - j1 / 2; + + for (int l2 = par3 - k1; l2 <= par3 + k1; ++l2) + { + int l1 = l2 - par3; + + for (int i2 = par5 - k1; i2 <= par5 + k1; ++i2) + { + int j2 = i2 - par5; + + if (Math.abs(l1) != k1 || Math.abs(j2) != k1 || par2Random.nextInt(2) != 0 && j1 != 0) + { + Block block1 = par1World.getBlock(l2, k2, i2); + + if (block1.isAir(par1World, l2, k2, i2) || block1.isLeaves(par1World, l2, k2, i2)) + { + this.setBlockAndNotifyAdequately(par1World, l2, k2, i2, Blocks.leaves, 2); + } + } + } + } + } + + for (k2 = 0; k2 < l; ++k2) + { + Block block3 = par1World.getBlock(par3, par4 + k2, par5); + + if (block3.isAir(par1World, par3, par4 + k2, par5) || block3.isLeaves(par1World, par3, par4 + k2, par5)) + { + this.setBlockAndNotifyAdequately(par1World, par3, par4 + k2, par5, Blocks.log, 2); + } + } + + return true; + } + else + { + return false; + } + } + } + else + { + return false; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/feature/WorldGenGlowStone1.java b/src/main/java/net/minecraft/world/gen/feature/WorldGenGlowStone1.java new file mode 100644 index 0000000..978d0c4 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/feature/WorldGenGlowStone1.java @@ -0,0 +1,87 @@ +package net.minecraft.world.gen.feature; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; + +public class WorldGenGlowStone1 extends WorldGenerator +{ + private static final String __OBFID = "CL_00000419"; + + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + if (!par1World.isAirBlock(par3, par4, par5)) + { + return false; + } + else if (par1World.getBlock(par3, par4 + 1, par5) != Blocks.netherrack) + { + return false; + } + else + { + par1World.setBlock(par3, par4, par5, Blocks.glowstone, 0, 2); + + for (int l = 0; l < 1500; ++l) + { + int i1 = par3 + par2Random.nextInt(8) - par2Random.nextInt(8); + int j1 = par4 - par2Random.nextInt(12); + int k1 = par5 + par2Random.nextInt(8) - par2Random.nextInt(8); + + if (par1World.getBlock(i1, j1, k1).getMaterial() == Material.air) + { + int l1 = 0; + + for (int i2 = 0; i2 < 6; ++i2) + { + Block block = null; + + if (i2 == 0) + { + block = par1World.getBlock(i1 - 1, j1, k1); + } + + if (i2 == 1) + { + block = par1World.getBlock(i1 + 1, j1, k1); + } + + if (i2 == 2) + { + block = par1World.getBlock(i1, j1 - 1, k1); + } + + if (i2 == 3) + { + block = par1World.getBlock(i1, j1 + 1, k1); + } + + if (i2 == 4) + { + block = par1World.getBlock(i1, j1, k1 - 1); + } + + if (i2 == 5) + { + block = par1World.getBlock(i1, j1, k1 + 1); + } + + if (block == Blocks.glowstone) + { + ++l1; + } + } + + if (l1 == 1) + { + par1World.setBlock(i1, j1, k1, Blocks.glowstone, 0, 2); + } + } + } + + return true; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/feature/WorldGenGlowStone2.java b/src/main/java/net/minecraft/world/gen/feature/WorldGenGlowStone2.java new file mode 100644 index 0000000..963a8ac --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/feature/WorldGenGlowStone2.java @@ -0,0 +1,87 @@ +package net.minecraft.world.gen.feature; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; + +public class WorldGenGlowStone2 extends WorldGenerator +{ + private static final String __OBFID = "CL_00000413"; + + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + if (!par1World.isAirBlock(par3, par4, par5)) + { + return false; + } + else if (par1World.getBlock(par3, par4 + 1, par5) != Blocks.netherrack) + { + return false; + } + else + { + par1World.setBlock(par3, par4, par5, Blocks.glowstone, 0, 2); + + for (int l = 0; l < 1500; ++l) + { + int i1 = par3 + par2Random.nextInt(8) - par2Random.nextInt(8); + int j1 = par4 - par2Random.nextInt(12); + int k1 = par5 + par2Random.nextInt(8) - par2Random.nextInt(8); + + if (par1World.getBlock(i1, j1, k1).getMaterial() == Material.air) + { + int l1 = 0; + + for (int i2 = 0; i2 < 6; ++i2) + { + Block block = null; + + if (i2 == 0) + { + block = par1World.getBlock(i1 - 1, j1, k1); + } + + if (i2 == 1) + { + block = par1World.getBlock(i1 + 1, j1, k1); + } + + if (i2 == 2) + { + block = par1World.getBlock(i1, j1 - 1, k1); + } + + if (i2 == 3) + { + block = par1World.getBlock(i1, j1 + 1, k1); + } + + if (i2 == 4) + { + block = par1World.getBlock(i1, j1, k1 - 1); + } + + if (i2 == 5) + { + block = par1World.getBlock(i1, j1, k1 + 1); + } + + if (block == Blocks.glowstone) + { + ++l1; + } + } + + if (l1 == 1) + { + par1World.setBlock(i1, j1, k1, Blocks.glowstone, 0, 2); + } + } + } + + return true; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/feature/WorldGenHellLava.java b/src/main/java/net/minecraft/world/gen/feature/WorldGenHellLava.java new file mode 100644 index 0000000..1430c4a --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/feature/WorldGenHellLava.java @@ -0,0 +1,98 @@ +package net.minecraft.world.gen.feature; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; + +public class WorldGenHellLava extends WorldGenerator +{ + private Block field_150553_a; + private boolean field_94524_b; + private static final String __OBFID = "CL_00000414"; + + public WorldGenHellLava(Block p_i45453_1_, boolean p_i45453_2_) + { + this.field_150553_a = p_i45453_1_; + this.field_94524_b = p_i45453_2_; + } + + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + if (par1World.getBlock(par3, par4 + 1, par5) != Blocks.netherrack) + { + return false; + } + else if (par1World.getBlock(par3, par4, par5).getMaterial() != Material.air && par1World.getBlock(par3, par4, par5) != Blocks.netherrack) + { + return false; + } + else + { + int l = 0; + + if (par1World.getBlock(par3 - 1, par4, par5) == Blocks.netherrack) + { + ++l; + } + + if (par1World.getBlock(par3 + 1, par4, par5) == Blocks.netherrack) + { + ++l; + } + + if (par1World.getBlock(par3, par4, par5 - 1) == Blocks.netherrack) + { + ++l; + } + + if (par1World.getBlock(par3, par4, par5 + 1) == Blocks.netherrack) + { + ++l; + } + + if (par1World.getBlock(par3, par4 - 1, par5) == Blocks.netherrack) + { + ++l; + } + + int i1 = 0; + + if (par1World.isAirBlock(par3 - 1, par4, par5)) + { + ++i1; + } + + if (par1World.isAirBlock(par3 + 1, par4, par5)) + { + ++i1; + } + + if (par1World.isAirBlock(par3, par4, par5 - 1)) + { + ++i1; + } + + if (par1World.isAirBlock(par3, par4, par5 + 1)) + { + ++i1; + } + + if (par1World.isAirBlock(par3, par4 - 1, par5)) + { + ++i1; + } + + if (!this.field_94524_b && l == 4 && i1 == 1 || l == 5) + { + par1World.setBlock(par3, par4, par5, this.field_150553_a, 0, 2); + par1World.scheduledUpdatesAreImmediate = true; + this.field_150553_a.updateTick(par1World, par3, par4, par5, par2Random); + par1World.scheduledUpdatesAreImmediate = false; + } + + return true; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/feature/WorldGenHugeTrees.java b/src/main/java/net/minecraft/world/gen/feature/WorldGenHugeTrees.java new file mode 100644 index 0000000..25ee8f9 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/feature/WorldGenHugeTrees.java @@ -0,0 +1,170 @@ +package net.minecraft.world.gen.feature; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.block.BlockSapling; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public abstract class WorldGenHugeTrees extends WorldGenAbstractTree +{ + protected final int baseHeight; + protected final int woodMetadata; + protected final int leavesMetadata; + protected int field_150538_d; + private static final String __OBFID = "CL_00000423"; + + public WorldGenHugeTrees(boolean p_i45458_1_, int p_i45458_2_, int p_i45458_3_, int p_i45458_4_, int p_i45458_5_) + { + super(p_i45458_1_); + this.baseHeight = p_i45458_2_; + this.field_150538_d = p_i45458_3_; + this.woodMetadata = p_i45458_4_; + this.leavesMetadata = p_i45458_5_; + } + + protected int func_150533_a(Random p_150533_1_) + { + int i = p_150533_1_.nextInt(3) + this.baseHeight; + + if (this.field_150538_d > 1) + { + i += p_150533_1_.nextInt(this.field_150538_d); + } + + return i; + } + + private boolean func_150536_b(World p_150536_1_, Random p_150536_2_, int p_150536_3_, int p_150536_4_, int p_150536_5_, int p_150536_6_) + { + boolean flag = true; + + if (p_150536_4_ >= 1 && p_150536_4_ + p_150536_6_ + 1 <= 256) + { + for (int i1 = p_150536_4_; i1 <= p_150536_4_ + 1 + p_150536_6_; ++i1) + { + byte b0 = 2; + + if (i1 == p_150536_4_) + { + b0 = 1; + } + + if (i1 >= p_150536_4_ + 1 + p_150536_6_ - 2) + { + b0 = 2; + } + + for (int j1 = p_150536_3_ - b0; j1 <= p_150536_3_ + b0 && flag; ++j1) + { + for (int k1 = p_150536_5_ - b0; k1 <= p_150536_5_ + b0 && flag; ++k1) + { + if (i1 >= 0 && i1 < 256) + { + Block block = p_150536_1_.getBlock(j1, i1, k1); + + if (!this.isReplaceable(p_150536_1_, j1, i1, k1)) + { + flag = false; + } + } + else + { + flag = false; + } + } + } + } + + return flag; + } + else + { + return false; + } + } + + private boolean func_150532_c(World p_150532_1_, Random p_150532_2_, int p_150532_3_, int p_150532_4_, int p_150532_5_) + { + Block block = p_150532_1_.getBlock(p_150532_3_, p_150532_4_ - 1, p_150532_5_); + + boolean isSoil = block.canSustainPlant(p_150532_1_, p_150532_3_, p_150532_4_ - 1, p_150532_5_, ForgeDirection.UP, (BlockSapling)Blocks.sapling); + if (isSoil && p_150532_4_ >= 2) + { + onPlantGrow(p_150532_1_, p_150532_3_, p_150532_4_ - 1, p_150532_5_, p_150532_3_, p_150532_4_, p_150532_5_); + onPlantGrow(p_150532_1_, p_150532_3_ + 1, p_150532_4_ - 1, p_150532_5_, p_150532_3_, p_150532_4_, p_150532_5_); + onPlantGrow(p_150532_1_, p_150532_3_, p_150532_4_ - 1, p_150532_5_ + 1, p_150532_3_, p_150532_4_, p_150532_5_); + onPlantGrow(p_150532_1_, p_150532_3_ + 1, p_150532_4_ - 1, p_150532_5_ + 1, p_150532_3_, p_150532_4_, p_150532_5_); + return true; + } + else + { + return false; + } + } + + protected boolean func_150537_a(World p_150537_1_, Random p_150537_2_, int p_150537_3_, int p_150537_4_, int p_150537_5_, int p_150537_6_) + { + return this.func_150536_b(p_150537_1_, p_150537_2_, p_150537_3_, p_150537_4_, p_150537_5_, p_150537_6_) && this.func_150532_c(p_150537_1_, p_150537_2_, p_150537_3_, p_150537_4_, p_150537_5_); + } + + protected void func_150535_a(World p_150535_1_, int p_150535_2_, int p_150535_3_, int p_150535_4_, int p_150535_5_, Random p_150535_6_) + { + int i1 = p_150535_5_ * p_150535_5_; + + for (int j1 = p_150535_2_ - p_150535_5_; j1 <= p_150535_2_ + p_150535_5_ + 1; ++j1) + { + int k1 = j1 - p_150535_2_; + + for (int l1 = p_150535_4_ - p_150535_5_; l1 <= p_150535_4_ + p_150535_5_ + 1; ++l1) + { + int i2 = l1 - p_150535_4_; + int j2 = k1 - 1; + int k2 = i2 - 1; + + if (k1 * k1 + i2 * i2 <= i1 || j2 * j2 + k2 * k2 <= i1 || k1 * k1 + k2 * k2 <= i1 || j2 * j2 + i2 * i2 <= i1) + { + Block block = p_150535_1_.getBlock(j1, p_150535_3_, l1); + + if (block.isAir(p_150535_1_, j1, p_150535_3_, l1) || block.isLeaves(p_150535_1_, j1, p_150535_3_, l1)) + { + this.setBlockAndNotifyAdequately(p_150535_1_, j1, p_150535_3_, l1, Blocks.leaves, this.leavesMetadata); + } + } + } + } + } + + protected void func_150534_b(World p_150534_1_, int p_150534_2_, int p_150534_3_, int p_150534_4_, int p_150534_5_, Random p_150534_6_) + { + int i1 = p_150534_5_ * p_150534_5_; + + for (int j1 = p_150534_2_ - p_150534_5_; j1 <= p_150534_2_ + p_150534_5_; ++j1) + { + int k1 = j1 - p_150534_2_; + + for (int l1 = p_150534_4_ - p_150534_5_; l1 <= p_150534_4_ + p_150534_5_; ++l1) + { + int i2 = l1 - p_150534_4_; + + if (k1 * k1 + i2 * i2 <= i1) + { + Block block = p_150534_1_.getBlock(j1, p_150534_3_, l1); + + if (block.isAir(p_150534_1_, j1, p_150534_3_, l1) || block.isLeaves(p_150534_1_, j1, p_150534_3_, l1)) + { + this.setBlockAndNotifyAdequately(p_150534_1_, j1, p_150534_3_, l1, Blocks.leaves, this.leavesMetadata); + } + } + } + } + } + + //Just a helper macro + private void onPlantGrow(World world, int x, int y, int z, int sourceX, int sourceY, int sourceZ) + { + world.getBlock(x, y, z).onPlantGrow(world, x, y, z, sourceX, sourceY, sourceZ); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/feature/WorldGenIcePath.java b/src/main/java/net/minecraft/world/gen/feature/WorldGenIcePath.java new file mode 100644 index 0000000..6f44946 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/feature/WorldGenIcePath.java @@ -0,0 +1,61 @@ +package net.minecraft.world.gen.feature; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; + +public class WorldGenIcePath extends WorldGenerator +{ + private Block field_150555_a; + private int field_150554_b; + private static final String __OBFID = "CL_00000416"; + + public WorldGenIcePath(int p_i45454_1_) + { + this.field_150555_a = Blocks.packed_ice; + this.field_150554_b = p_i45454_1_; + } + + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + while (par1World.isAirBlock(par3, par4, par5) && par4 > 2) + { + --par4; + } + + if (par1World.getBlock(par3, par4, par5) != Blocks.snow) + { + return false; + } + else + { + int l = par2Random.nextInt(this.field_150554_b - 2) + 2; + byte b0 = 1; + + for (int i1 = par3 - l; i1 <= par3 + l; ++i1) + { + for (int j1 = par5 - l; j1 <= par5 + l; ++j1) + { + int k1 = i1 - par3; + int l1 = j1 - par5; + + if (k1 * k1 + l1 * l1 <= l * l) + { + for (int i2 = par4 - b0; i2 <= par4 + b0; ++i2) + { + Block block = par1World.getBlock(i1, i2, j1); + + if (block == Blocks.dirt || block == Blocks.snow || block == Blocks.ice) + { + par1World.setBlock(i1, i2, j1, this.field_150555_a, 0, 2); + } + } + } + } + } + + return true; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/feature/WorldGenIceSpike.java b/src/main/java/net/minecraft/world/gen/feature/WorldGenIceSpike.java new file mode 100644 index 0000000..fee648c --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/feature/WorldGenIceSpike.java @@ -0,0 +1,132 @@ +package net.minecraft.world.gen.feature; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class WorldGenIceSpike extends WorldGenerator +{ + private static final String __OBFID = "CL_00000417"; + + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + while (par1World.isAirBlock(par3, par4, par5) && par4 > 2) + { + --par4; + } + + if (par1World.getBlock(par3, par4, par5) != Blocks.snow) + { + return false; + } + else + { + par4 += par2Random.nextInt(4); + int l = par2Random.nextInt(4) + 7; + int i1 = l / 4 + par2Random.nextInt(2); + + if (i1 > 1 && par2Random.nextInt(60) == 0) + { + par4 += 10 + par2Random.nextInt(30); + } + + int j1; + int k1; + int l1; + + for (j1 = 0; j1 < l; ++j1) + { + float f = (1.0F - (float)j1 / (float)l) * (float)i1; + k1 = MathHelper.ceiling_float_int(f); + + for (l1 = -k1; l1 <= k1; ++l1) + { + float f1 = (float)MathHelper.abs_int(l1) - 0.25F; + + for (int i2 = -k1; i2 <= k1; ++i2) + { + float f2 = (float)MathHelper.abs_int(i2) - 0.25F; + + if ((l1 == 0 && i2 == 0 || f1 * f1 + f2 * f2 <= f * f) && (l1 != -k1 && l1 != k1 && i2 != -k1 && i2 != k1 || par2Random.nextFloat() <= 0.75F)) + { + Block block = par1World.getBlock(par3 + l1, par4 + j1, par5 + i2); + + if (block.getMaterial() == Material.air || block == Blocks.dirt || block == Blocks.snow || block == Blocks.ice) + { + this.func_150515_a(par1World, par3 + l1, par4 + j1, par5 + i2, Blocks.packed_ice); + } + + if (j1 != 0 && k1 > 1) + { + block = par1World.getBlock(par3 + l1, par4 - j1, par5 + i2); + + if (block.getMaterial() == Material.air || block == Blocks.dirt || block == Blocks.snow || block == Blocks.ice) + { + this.func_150515_a(par1World, par3 + l1, par4 - j1, par5 + i2, Blocks.packed_ice); + } + } + } + } + } + } + + j1 = i1 - 1; + + if (j1 < 0) + { + j1 = 0; + } + else if (j1 > 1) + { + j1 = 1; + } + + for (int j2 = -j1; j2 <= j1; ++j2) + { + k1 = -j1; + + while (k1 <= j1) + { + l1 = par4 - 1; + int k2 = 50; + + if (Math.abs(j2) == 1 && Math.abs(k1) == 1) + { + k2 = par2Random.nextInt(5); + } + + while (true) + { + if (l1 > 50) + { + Block block1 = par1World.getBlock(par3 + j2, l1, par5 + k1); + + if (block1.getMaterial() == Material.air || block1 == Blocks.dirt || block1 == Blocks.snow || block1 == Blocks.ice || block1 == Blocks.packed_ice) + { + this.func_150515_a(par1World, par3 + j2, l1, par5 + k1, Blocks.packed_ice); + --l1; + --k2; + + if (k2 <= 0) + { + l1 -= par2Random.nextInt(5) + 1; + k2 = par2Random.nextInt(5); + } + + continue; + } + } + + ++k1; + break; + } + } + } + + return true; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/feature/WorldGenLakes.java b/src/main/java/net/minecraft/world/gen/feature/WorldGenLakes.java new file mode 100644 index 0000000..190544a --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/feature/WorldGenLakes.java @@ -0,0 +1,175 @@ +package net.minecraft.world.gen.feature; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.world.EnumSkyBlock; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; + +public class WorldGenLakes extends WorldGenerator +{ + private Block field_150556_a; + private static final String __OBFID = "CL_00000418"; + + public WorldGenLakes(Block p_i45455_1_) + { + this.field_150556_a = p_i45455_1_; + } + + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + par3 -= 8; + + for (par5 -= 8; par4 > 5 && par1World.isAirBlock(par3, par4, par5); --par4) + { + ; + } + + if (par4 <= 4) + { + return false; + } + else + { + par4 -= 4; + boolean[] aboolean = new boolean[2048]; + int l = par2Random.nextInt(4) + 4; + int i1; + + for (i1 = 0; i1 < l; ++i1) + { + double d0 = par2Random.nextDouble() * 6.0D + 3.0D; + double d1 = par2Random.nextDouble() * 4.0D + 2.0D; + double d2 = par2Random.nextDouble() * 6.0D + 3.0D; + double d3 = par2Random.nextDouble() * (16.0D - d0 - 2.0D) + 1.0D + d0 / 2.0D; + double d4 = par2Random.nextDouble() * (8.0D - d1 - 4.0D) + 2.0D + d1 / 2.0D; + double d5 = par2Random.nextDouble() * (16.0D - d2 - 2.0D) + 1.0D + d2 / 2.0D; + + for (int k1 = 1; k1 < 15; ++k1) + { + for (int l1 = 1; l1 < 15; ++l1) + { + for (int i2 = 1; i2 < 7; ++i2) + { + double d6 = ((double)k1 - d3) / (d0 / 2.0D); + double d7 = ((double)i2 - d4) / (d1 / 2.0D); + double d8 = ((double)l1 - d5) / (d2 / 2.0D); + double d9 = d6 * d6 + d7 * d7 + d8 * d8; + + if (d9 < 1.0D) + { + aboolean[(k1 * 16 + l1) * 8 + i2] = true; + } + } + } + } + } + + int j1; + int j2; + boolean flag; + + for (i1 = 0; i1 < 16; ++i1) + { + for (j2 = 0; j2 < 16; ++j2) + { + for (j1 = 0; j1 < 8; ++j1) + { + flag = !aboolean[(i1 * 16 + j2) * 8 + j1] && (i1 < 15 && aboolean[((i1 + 1) * 16 + j2) * 8 + j1] || i1 > 0 && aboolean[((i1 - 1) * 16 + j2) * 8 + j1] || j2 < 15 && aboolean[(i1 * 16 + j2 + 1) * 8 + j1] || j2 > 0 && aboolean[(i1 * 16 + (j2 - 1)) * 8 + j1] || j1 < 7 && aboolean[(i1 * 16 + j2) * 8 + j1 + 1] || j1 > 0 && aboolean[(i1 * 16 + j2) * 8 + (j1 - 1)]); + + if (flag) + { + Material material = par1World.getBlock(par3 + i1, par4 + j1, par5 + j2).getMaterial(); + + if (j1 >= 4 && material.isLiquid()) + { + return false; + } + + if (j1 < 4 && !material.isSolid() && par1World.getBlock(par3 + i1, par4 + j1, par5 + j2) != this.field_150556_a) + { + return false; + } + } + } + } + } + + for (i1 = 0; i1 < 16; ++i1) + { + for (j2 = 0; j2 < 16; ++j2) + { + for (j1 = 0; j1 < 8; ++j1) + { + if (aboolean[(i1 * 16 + j2) * 8 + j1]) + { + par1World.setBlock(par3 + i1, par4 + j1, par5 + j2, j1 >= 4 ? Blocks.air : this.field_150556_a, 0, 2); + } + } + } + } + + for (i1 = 0; i1 < 16; ++i1) + { + for (j2 = 0; j2 < 16; ++j2) + { + for (j1 = 4; j1 < 8; ++j1) + { + if (aboolean[(i1 * 16 + j2) * 8 + j1] && par1World.getBlock(par3 + i1, par4 + j1 - 1, par5 + j2) == Blocks.dirt && par1World.getSavedLightValue(EnumSkyBlock.Sky, par3 + i1, par4 + j1, par5 + j2) > 0) + { + BiomeGenBase biomegenbase = par1World.getBiomeGenForCoords(par3 + i1, par5 + j2); + + if (biomegenbase.topBlock == Blocks.mycelium) + { + par1World.setBlock(par3 + i1, par4 + j1 - 1, par5 + j2, Blocks.mycelium, 0, 2); + } + else + { + par1World.setBlock(par3 + i1, par4 + j1 - 1, par5 + j2, Blocks.grass, 0, 2); + } + } + } + } + } + + if (this.field_150556_a.getMaterial() == Material.lava) + { + for (i1 = 0; i1 < 16; ++i1) + { + for (j2 = 0; j2 < 16; ++j2) + { + for (j1 = 0; j1 < 8; ++j1) + { + flag = !aboolean[(i1 * 16 + j2) * 8 + j1] && (i1 < 15 && aboolean[((i1 + 1) * 16 + j2) * 8 + j1] || i1 > 0 && aboolean[((i1 - 1) * 16 + j2) * 8 + j1] || j2 < 15 && aboolean[(i1 * 16 + j2 + 1) * 8 + j1] || j2 > 0 && aboolean[(i1 * 16 + (j2 - 1)) * 8 + j1] || j1 < 7 && aboolean[(i1 * 16 + j2) * 8 + j1 + 1] || j1 > 0 && aboolean[(i1 * 16 + j2) * 8 + (j1 - 1)]); + + if (flag && (j1 < 4 || par2Random.nextInt(2) != 0) && par1World.getBlock(par3 + i1, par4 + j1, par5 + j2).getMaterial().isSolid()) + { + par1World.setBlock(par3 + i1, par4 + j1, par5 + j2, Blocks.stone, 0, 2); + } + } + } + } + } + + if (this.field_150556_a.getMaterial() == Material.water) + { + for (i1 = 0; i1 < 16; ++i1) + { + for (j2 = 0; j2 < 16; ++j2) + { + byte b0 = 4; + + if (par1World.isBlockFreezable(par3 + i1, par4 + b0, par5 + j2)) + { + par1World.setBlock(par3 + i1, par4 + b0, par5 + j2, Blocks.ice, 0, 2); + } + } + } + } + + return true; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/feature/WorldGenLiquids.java b/src/main/java/net/minecraft/world/gen/feature/WorldGenLiquids.java new file mode 100644 index 0000000..711bf28 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/feature/WorldGenLiquids.java @@ -0,0 +1,90 @@ +package net.minecraft.world.gen.feature; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; + +public class WorldGenLiquids extends WorldGenerator +{ + private Block field_150521_a; + private static final String __OBFID = "CL_00000434"; + + public WorldGenLiquids(Block p_i45465_1_) + { + this.field_150521_a = p_i45465_1_; + } + + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + if (par1World.getBlock(par3, par4 + 1, par5) != Blocks.stone) + { + return false; + } + else if (par1World.getBlock(par3, par4 - 1, par5) != Blocks.stone) + { + return false; + } + else if (par1World.getBlock(par3, par4, par5).getMaterial() != Material.air && par1World.getBlock(par3, par4, par5) != Blocks.stone) + { + return false; + } + else + { + int l = 0; + + if (par1World.getBlock(par3 - 1, par4, par5) == Blocks.stone) + { + ++l; + } + + if (par1World.getBlock(par3 + 1, par4, par5) == Blocks.stone) + { + ++l; + } + + if (par1World.getBlock(par3, par4, par5 - 1) == Blocks.stone) + { + ++l; + } + + if (par1World.getBlock(par3, par4, par5 + 1) == Blocks.stone) + { + ++l; + } + + int i1 = 0; + + if (par1World.isAirBlock(par3 - 1, par4, par5)) + { + ++i1; + } + + if (par1World.isAirBlock(par3 + 1, par4, par5)) + { + ++i1; + } + + if (par1World.isAirBlock(par3, par4, par5 - 1)) + { + ++i1; + } + + if (par1World.isAirBlock(par3, par4, par5 + 1)) + { + ++i1; + } + + if (l == 3 && i1 == 1) + { + par1World.setBlock(par3, par4, par5, this.field_150521_a, 0, 2); + par1World.scheduledUpdatesAreImmediate = true; + this.field_150521_a.updateTick(par1World, par3, par4, par5, par2Random); + par1World.scheduledUpdatesAreImmediate = false; + } + + return true; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/feature/WorldGenMegaJungle.java b/src/main/java/net/minecraft/world/gen/feature/WorldGenMegaJungle.java new file mode 100644 index 0000000..34a69fe --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/feature/WorldGenMegaJungle.java @@ -0,0 +1,155 @@ +package net.minecraft.world.gen.feature; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class WorldGenMegaJungle extends WorldGenHugeTrees +{ + private static final String __OBFID = "CL_00000420"; + + public WorldGenMegaJungle(boolean p_i45456_1_, int p_i45456_2_, int p_i45456_3_, int p_i45456_4_, int p_i45456_5_) + { + super(p_i45456_1_, p_i45456_2_, p_i45456_3_, p_i45456_4_, p_i45456_5_); + } + + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + int l = this.func_150533_a(par2Random); + + if (!this.func_150537_a(par1World, par2Random, par3, par4, par5, l)) + { + return false; + } + else + { + this.func_150543_c(par1World, par3, par5, par4 + l, 2, par2Random); + + for (int i1 = par4 + l - 2 - par2Random.nextInt(4); i1 > par4 + l / 2; i1 -= 2 + par2Random.nextInt(4)) + { + float f = par2Random.nextFloat() * (float)Math.PI * 2.0F; + int j1 = par3 + (int)(0.5F + MathHelper.cos(f) * 4.0F); + int k1 = par5 + (int)(0.5F + MathHelper.sin(f) * 4.0F); + int l1; + + for (l1 = 0; l1 < 5; ++l1) + { + j1 = par3 + (int)(1.5F + MathHelper.cos(f) * (float)l1); + k1 = par5 + (int)(1.5F + MathHelper.sin(f) * (float)l1); + this.setBlockAndNotifyAdequately(par1World, j1, i1 - 3 + l1 / 2, k1, Blocks.log, this.woodMetadata); + } + + l1 = 1 + par2Random.nextInt(2); + int i2 = i1; + + for (int j2 = i1 - l1; j2 <= i2; ++j2) + { + int k2 = j2 - i2; + this.func_150534_b(par1World, j1, j2, k1, 1 - k2, par2Random); + } + } + + for (int l2 = 0; l2 < l; ++l2) + { + Block block = par1World.getBlock(par3, par4 + l2, par5); + + if (block.isAir(par1World, par3, par4 + l2, par5) || block.isLeaves(par1World, par3, par4 + l2, par5)) + { + this.setBlockAndNotifyAdequately(par1World, par3, par4 + l2, par5, Blocks.log, this.woodMetadata); + + if (l2 > 0) + { + if (par2Random.nextInt(3) > 0 && par1World.isAirBlock(par3 - 1, par4 + l2, par5)) + { + this.setBlockAndNotifyAdequately(par1World, par3 - 1, par4 + l2, par5, Blocks.vine, 8); + } + + if (par2Random.nextInt(3) > 0 && par1World.isAirBlock(par3, par4 + l2, par5 - 1)) + { + this.setBlockAndNotifyAdequately(par1World, par3, par4 + l2, par5 - 1, Blocks.vine, 1); + } + } + } + + if (l2 < l - 1) + { + block = par1World.getBlock(par3 + 1, par4 + l2, par5); + + if (block.isAir(par1World, par3 + 1, par4 + l2, par5) || block.isLeaves(par1World, par3 + 1, par4 + l2, par5)) + { + this.setBlockAndNotifyAdequately(par1World, par3 + 1, par4 + l2, par5, Blocks.log, this.woodMetadata); + + if (l2 > 0) + { + if (par2Random.nextInt(3) > 0 && par1World.isAirBlock(par3 + 2, par4 + l2, par5)) + { + this.setBlockAndNotifyAdequately(par1World, par3 + 2, par4 + l2, par5, Blocks.vine, 2); + } + + if (par2Random.nextInt(3) > 0 && par1World.isAirBlock(par3 + 1, par4 + l2, par5 - 1)) + { + this.setBlockAndNotifyAdequately(par1World, par3 + 1, par4 + l2, par5 - 1, Blocks.vine, 1); + } + } + } + + block = par1World.getBlock(par3 + 1, par4 + l2, par5 + 1); + + if (block.isAir(par1World, par3 + 1, par4 + l2, par5 + 1) || block.isLeaves(par1World, par3 + 1, par4 + l2, par5 + 1)) + { + this.setBlockAndNotifyAdequately(par1World, par3 + 1, par4 + l2, par5 + 1, Blocks.log, this.woodMetadata); + + if (l2 > 0) + { + if (par2Random.nextInt(3) > 0 && par1World.isAirBlock(par3 + 2, par4 + l2, par5 + 1)) + { + this.setBlockAndNotifyAdequately(par1World, par3 + 2, par4 + l2, par5 + 1, Blocks.vine, 2); + } + + if (par2Random.nextInt(3) > 0 && par1World.isAirBlock(par3 + 1, par4 + l2, par5 + 2)) + { + this.setBlockAndNotifyAdequately(par1World, par3 + 1, par4 + l2, par5 + 2, Blocks.vine, 4); + } + } + } + + block = par1World.getBlock(par3, par4 + l2, par5 + 1); + + if (block.isAir(par1World, par3, par4 + l2, par5 + 1) || block.isLeaves(par1World, par3, par4 + l2, par5 + 1)) + { + this.setBlockAndNotifyAdequately(par1World, par3, par4 + l2, par5 + 1, Blocks.log, this.woodMetadata); + + if (l2 > 0) + { + if (par2Random.nextInt(3) > 0 && par1World.isAirBlock(par3 - 1, par4 + l2, par5 + 1)) + { + this.setBlockAndNotifyAdequately(par1World, par3 - 1, par4 + l2, par5 + 1, Blocks.vine, 8); + } + + if (par2Random.nextInt(3) > 0 && par1World.isAirBlock(par3, par4 + l2, par5 + 2)) + { + this.setBlockAndNotifyAdequately(par1World, par3, par4 + l2, par5 + 2, Blocks.vine, 4); + } + } + } + } + } + + return true; + } + } + + private void func_150543_c(World p_150543_1_, int p_150543_2_, int p_150543_3_, int p_150543_4_, int p_150543_5_, Random p_150543_6_) + { + byte b0 = 2; + + for (int i1 = p_150543_4_ - b0; i1 <= p_150543_4_; ++i1) + { + int j1 = i1 - p_150543_4_; + this.func_150535_a(p_150543_1_, p_150543_2_, i1, p_150543_3_, p_150543_5_ + 1 - j1, p_150543_6_); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/feature/WorldGenMegaPineTree.java b/src/main/java/net/minecraft/world/gen/feature/WorldGenMegaPineTree.java new file mode 100644 index 0000000..cf7aa8b --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/feature/WorldGenMegaPineTree.java @@ -0,0 +1,149 @@ +package net.minecraft.world.gen.feature; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.block.BlockSapling; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public class WorldGenMegaPineTree extends WorldGenHugeTrees +{ + private boolean field_150542_e; + private static final String __OBFID = "CL_00000421"; + + public WorldGenMegaPineTree(boolean p_i45457_1_, boolean p_i45457_2_) + { + super(p_i45457_1_, 13, 15, 1, 1); + this.field_150542_e = p_i45457_2_; + } + + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + int l = this.func_150533_a(par2Random); + + if (!this.func_150537_a(par1World, par2Random, par3, par4, par5, l)) + { + return false; + } + else + { + this.func_150541_c(par1World, par3, par5, par4 + l, 0, par2Random); + + for (int i1 = 0; i1 < l; ++i1) + { + Block block = par1World.getBlock(par3, par4 + i1, par5); + + if (block.isAir(par1World, par3, par4 + i1, par5) || block.isLeaves(par1World, par3, par4 + i1, par5)) + { + this.setBlockAndNotifyAdequately(par1World, par3, par4 + i1, par5, Blocks.log, this.woodMetadata); + } + + if (i1 < l - 1) + { + block = par1World.getBlock(par3 + 1, par4 + i1, par5); + + if (block.isAir(par1World, par3 + 1, par4 + i1, par5) || block.isLeaves(par1World, par3 + 1, par4 + i1, par5)) + { + this.setBlockAndNotifyAdequately(par1World, par3 + 1, par4 + i1, par5, Blocks.log, this.woodMetadata); + } + + block = par1World.getBlock(par3 + 1, par4 + i1, par5 + 1); + + if (block.isAir(par1World, par3 + 1, par4 + i1, par5 + 1) || block.isLeaves(par1World, par3 + 1, par4 + i1, par5 + 1)) + { + this.setBlockAndNotifyAdequately(par1World, par3 + 1, par4 + i1, par5 + 1, Blocks.log, this.woodMetadata); + } + + block = par1World.getBlock(par3, par4 + i1, par5 + 1); + + if (block.isAir(par1World, par3, par4 + i1, par5 + 1) || block.isLeaves(par1World, par3, par4 + i1, par5 + 1)) + { + this.setBlockAndNotifyAdequately(par1World, par3, par4 + i1, par5 + 1, Blocks.log, this.woodMetadata); + } + } + } + + return true; + } + } + + private void func_150541_c(World p_150541_1_, int p_150541_2_, int p_150541_3_, int p_150541_4_, int p_150541_5_, Random p_150541_6_) + { + int i1 = p_150541_6_.nextInt(5); + + if (this.field_150542_e) + { + i1 += this.baseHeight; + } + else + { + i1 += 3; + } + + int j1 = 0; + + for (int k1 = p_150541_4_ - i1; k1 <= p_150541_4_; ++k1) + { + int l1 = p_150541_4_ - k1; + int i2 = p_150541_5_ + MathHelper.floor_float((float)l1 / (float)i1 * 3.5F); + this.func_150535_a(p_150541_1_, p_150541_2_, k1, p_150541_3_, i2 + (l1 > 0 && i2 == j1 && (k1 & 1) == 0 ? 1 : 0), p_150541_6_); + j1 = i2; + } + } + + public void func_150524_b(World p_150524_1_, Random p_150524_2_, int p_150524_3_, int p_150524_4_, int p_150524_5_) + { + this.func_150539_c(p_150524_1_, p_150524_2_, p_150524_3_ - 1, p_150524_4_, p_150524_5_ - 1); + this.func_150539_c(p_150524_1_, p_150524_2_, p_150524_3_ + 2, p_150524_4_, p_150524_5_ - 1); + this.func_150539_c(p_150524_1_, p_150524_2_, p_150524_3_ - 1, p_150524_4_, p_150524_5_ + 2); + this.func_150539_c(p_150524_1_, p_150524_2_, p_150524_3_ + 2, p_150524_4_, p_150524_5_ + 2); + + for (int l = 0; l < 5; ++l) + { + int i1 = p_150524_2_.nextInt(64); + int j1 = i1 % 8; + int k1 = i1 / 8; + + if (j1 == 0 || j1 == 7 || k1 == 0 || k1 == 7) + { + this.func_150539_c(p_150524_1_, p_150524_2_, p_150524_3_ - 3 + j1, p_150524_4_, p_150524_5_ - 3 + k1); + } + } + } + + private void func_150539_c(World p_150539_1_, Random p_150539_2_, int p_150539_3_, int p_150539_4_, int p_150539_5_) + { + for (int l = -2; l <= 2; ++l) + { + for (int i1 = -2; i1 <= 2; ++i1) + { + if (Math.abs(l) != 2 || Math.abs(i1) != 2) + { + this.func_150540_a(p_150539_1_, p_150539_3_ + l, p_150539_4_, p_150539_5_ + i1); + } + } + } + } + + private void func_150540_a(World p_150540_1_, int p_150540_2_, int p_150540_3_, int p_150540_4_) + { + for (int l = p_150540_3_ + 2; l >= p_150540_3_ - 3; --l) + { + Block block = p_150540_1_.getBlock(p_150540_2_, l, p_150540_4_); + + if (block.canSustainPlant(p_150540_1_, p_150540_2_, l, p_150540_4_, ForgeDirection.UP, (BlockSapling)Blocks.sapling)) + { + this.setBlockAndNotifyAdequately(p_150540_1_, p_150540_2_, l, p_150540_4_, Blocks.dirt, 2); + break; + } + + if (block.isAir(p_150540_1_, p_150540_2_, l, p_150540_4_) && l < p_150540_3_) + { + break; + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/feature/WorldGenMelon.java b/src/main/java/net/minecraft/world/gen/feature/WorldGenMelon.java new file mode 100644 index 0000000..218d6e9 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/feature/WorldGenMelon.java @@ -0,0 +1,27 @@ +package net.minecraft.world.gen.feature; + +import java.util.Random; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; + +public class WorldGenMelon extends WorldGenerator +{ + private static final String __OBFID = "CL_00000424"; + + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + for (int l = 0; l < 64; ++l) + { + int i1 = par3 + par2Random.nextInt(8) - par2Random.nextInt(8); + int j1 = par4 + par2Random.nextInt(4) - par2Random.nextInt(4); + int k1 = par5 + par2Random.nextInt(8) - par2Random.nextInt(8); + + if (Blocks.melon_block.canPlaceBlockAt(par1World, i1, j1, k1) && par1World.getBlock(i1, j1 - 1, k1) == Blocks.grass) + { + par1World.setBlock(i1, j1, k1, Blocks.melon_block, 0, 2); + } + } + + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/feature/WorldGenMinable.java b/src/main/java/net/minecraft/world/gen/feature/WorldGenMinable.java new file mode 100644 index 0000000..24451b5 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/feature/WorldGenMinable.java @@ -0,0 +1,89 @@ +package net.minecraft.world.gen.feature; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +public class WorldGenMinable extends WorldGenerator +{ + private Block field_150519_a; + private int numberOfBlocks; + private Block field_150518_c; + private static final String __OBFID = "CL_00000426"; + private int mineableBlockMeta; + + public WorldGenMinable(Block p_i45459_1_, int p_i45459_2_) + { + this(p_i45459_1_, p_i45459_2_, Blocks.stone); + } + + public WorldGenMinable(Block p_i45460_1_, int p_i45460_2_, Block p_i45460_3_) + { + this.field_150519_a = p_i45460_1_; + this.numberOfBlocks = p_i45460_2_; + this.field_150518_c = p_i45460_3_; + } + + public WorldGenMinable(Block block, int meta, int number, Block target) + { + this(block, number, target); + this.mineableBlockMeta = meta; + } + + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + float f = par2Random.nextFloat() * (float)Math.PI; + double d0 = (double)((float)(par3 + 8) + MathHelper.sin(f) * (float)this.numberOfBlocks / 8.0F); + double d1 = (double)((float)(par3 + 8) - MathHelper.sin(f) * (float)this.numberOfBlocks / 8.0F); + double d2 = (double)((float)(par5 + 8) + MathHelper.cos(f) * (float)this.numberOfBlocks / 8.0F); + double d3 = (double)((float)(par5 + 8) - MathHelper.cos(f) * (float)this.numberOfBlocks / 8.0F); + double d4 = (double)(par4 + par2Random.nextInt(3) - 2); + double d5 = (double)(par4 + par2Random.nextInt(3) - 2); + + for (int l = 0; l <= this.numberOfBlocks; ++l) + { + double d6 = d0 + (d1 - d0) * (double)l / (double)this.numberOfBlocks; + double d7 = d4 + (d5 - d4) * (double)l / (double)this.numberOfBlocks; + double d8 = d2 + (d3 - d2) * (double)l / (double)this.numberOfBlocks; + double d9 = par2Random.nextDouble() * (double)this.numberOfBlocks / 16.0D; + double d10 = (double)(MathHelper.sin((float)l * (float)Math.PI / (float)this.numberOfBlocks) + 1.0F) * d9 + 1.0D; + double d11 = (double)(MathHelper.sin((float)l * (float)Math.PI / (float)this.numberOfBlocks) + 1.0F) * d9 + 1.0D; + int i1 = MathHelper.floor_double(d6 - d10 / 2.0D); + int j1 = MathHelper.floor_double(d7 - d11 / 2.0D); + int k1 = MathHelper.floor_double(d8 - d10 / 2.0D); + int l1 = MathHelper.floor_double(d6 + d10 / 2.0D); + int i2 = MathHelper.floor_double(d7 + d11 / 2.0D); + int j2 = MathHelper.floor_double(d8 + d10 / 2.0D); + + for (int k2 = i1; k2 <= l1; ++k2) + { + double d12 = ((double)k2 + 0.5D - d6) / (d10 / 2.0D); + + if (d12 * d12 < 1.0D) + { + for (int l2 = j1; l2 <= i2; ++l2) + { + double d13 = ((double)l2 + 0.5D - d7) / (d11 / 2.0D); + + if (d12 * d12 + d13 * d13 < 1.0D) + { + for (int i3 = k1; i3 <= j2; ++i3) + { + double d14 = ((double)i3 + 0.5D - d8) / (d10 / 2.0D); + + if (d12 * d12 + d13 * d13 + d14 * d14 < 1.0D && par1World.getBlock(k2, l2, i3).isReplaceableOreGen(par1World, k2, l2, i3, field_150518_c)) + { + par1World.setBlock(k2, l2, i3, this.field_150519_a, mineableBlockMeta, 2); + } + } + } + } + } + } + } + + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/feature/WorldGenPumpkin.java b/src/main/java/net/minecraft/world/gen/feature/WorldGenPumpkin.java new file mode 100644 index 0000000..b4e8c18 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/feature/WorldGenPumpkin.java @@ -0,0 +1,27 @@ +package net.minecraft.world.gen.feature; + +import java.util.Random; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; + +public class WorldGenPumpkin extends WorldGenerator +{ + private static final String __OBFID = "CL_00000428"; + + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + for (int l = 0; l < 64; ++l) + { + int i1 = par3 + par2Random.nextInt(8) - par2Random.nextInt(8); + int j1 = par4 + par2Random.nextInt(4) - par2Random.nextInt(4); + int k1 = par5 + par2Random.nextInt(8) - par2Random.nextInt(8); + + if (par1World.isAirBlock(i1, j1, k1) && par1World.getBlock(i1, j1 - 1, k1) == Blocks.grass && Blocks.pumpkin.canPlaceBlockAt(par1World, i1, j1, k1)) + { + par1World.setBlock(i1, j1, k1, Blocks.pumpkin, par2Random.nextInt(4), 2); + } + } + + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/feature/WorldGenReed.java b/src/main/java/net/minecraft/world/gen/feature/WorldGenReed.java new file mode 100644 index 0000000..d6c70f6 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/feature/WorldGenReed.java @@ -0,0 +1,36 @@ +package net.minecraft.world.gen.feature; + +import java.util.Random; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; + +public class WorldGenReed extends WorldGenerator +{ + private static final String __OBFID = "CL_00000429"; + + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + for (int l = 0; l < 20; ++l) + { + int i1 = par3 + par2Random.nextInt(4) - par2Random.nextInt(4); + int j1 = par4; + int k1 = par5 + par2Random.nextInt(4) - par2Random.nextInt(4); + + if (par1World.isAirBlock(i1, par4, k1) && (par1World.getBlock(i1 - 1, par4 - 1, k1).getMaterial() == Material.water || par1World.getBlock(i1 + 1, par4 - 1, k1).getMaterial() == Material.water || par1World.getBlock(i1, par4 - 1, k1 - 1).getMaterial() == Material.water || par1World.getBlock(i1, par4 - 1, k1 + 1).getMaterial() == Material.water)) + { + int l1 = 2 + par2Random.nextInt(par2Random.nextInt(3) + 1); + + for (int i2 = 0; i2 < l1; ++i2) + { + if (Blocks.reeds.canBlockStay(par1World, i1, j1 + i2, k1)) + { + par1World.setBlock(i1, j1 + i2, k1, Blocks.reeds, 0, 2); + } + } + } + } + + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/feature/WorldGenSand.java b/src/main/java/net/minecraft/world/gen/feature/WorldGenSand.java new file mode 100644 index 0000000..54b451f --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/feature/WorldGenSand.java @@ -0,0 +1,57 @@ +package net.minecraft.world.gen.feature; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; + +public class WorldGenSand extends WorldGenerator +{ + private Block field_150517_a; + private int radius; + private static final String __OBFID = "CL_00000431"; + + public WorldGenSand(Block p_i45462_1_, int p_i45462_2_) + { + this.field_150517_a = p_i45462_1_; + this.radius = p_i45462_2_; + } + + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + if (par1World.getBlock(par3, par4, par5).getMaterial() != Material.water) + { + return false; + } + else + { + int l = par2Random.nextInt(this.radius - 2) + 2; + byte b0 = 2; + + for (int i1 = par3 - l; i1 <= par3 + l; ++i1) + { + for (int j1 = par5 - l; j1 <= par5 + l; ++j1) + { + int k1 = i1 - par3; + int l1 = j1 - par5; + + if (k1 * k1 + l1 * l1 <= l * l) + { + for (int i2 = par4 - b0; i2 <= par4 + b0; ++i2) + { + Block block = par1World.getBlock(i1, i2, j1); + + if (block == Blocks.dirt || block == Blocks.grass) + { + par1World.setBlock(i1, i2, j1, this.field_150517_a, 0, 2); + } + } + } + } + } + + return true; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/feature/WorldGenSavannaTree.java b/src/main/java/net/minecraft/world/gen/feature/WorldGenSavannaTree.java new file mode 100644 index 0000000..5c39407 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/feature/WorldGenSavannaTree.java @@ -0,0 +1,208 @@ +package net.minecraft.world.gen.feature; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.block.BlockSapling; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.util.Direction; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public class WorldGenSavannaTree extends WorldGenAbstractTree +{ + private static final String __OBFID = "CL_00000432"; + + public WorldGenSavannaTree(boolean p_i45463_1_) + { + super(p_i45463_1_); + } + + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + int l = par2Random.nextInt(3) + par2Random.nextInt(3) + 5; + boolean flag = true; + + if (par4 >= 1 && par4 + l + 1 <= 256) + { + int j1; + int k1; + + for (int i1 = par4; i1 <= par4 + 1 + l; ++i1) + { + byte b0 = 1; + + if (i1 == par4) + { + b0 = 0; + } + + if (i1 >= par4 + 1 + l - 2) + { + b0 = 2; + } + + for (j1 = par3 - b0; j1 <= par3 + b0 && flag; ++j1) + { + for (k1 = par5 - b0; k1 <= par5 + b0 && flag; ++k1) + { + if (i1 >= 0 && i1 < 256) + { + Block block = par1World.getBlock(j1, i1, k1); + + if (!this.isReplaceable(par1World, j1, i1, k1)) + { + flag = false; + } + } + else + { + flag = false; + } + } + } + } + + if (!flag) + { + return false; + } + else + { + Block block3 = par1World.getBlock(par3, par4 - 1, par5); + + boolean isSoil = block3.canSustainPlant(par1World, par3, par4 - 1, par5, ForgeDirection.UP, (BlockSapling)Blocks.sapling); + if (isSoil && par4 < 256 - l - 1) + { + block3.onPlantGrow(par1World, par3, par4 - 1, par5, par3, par4, par5); + int j3 = par2Random.nextInt(4); + j1 = l - par2Random.nextInt(4) - 1; + k1 = 3 - par2Random.nextInt(3); + int k3 = par3; + int l1 = par5; + int i2 = 0; + int j2; + int k2; + + for (j2 = 0; j2 < l; ++j2) + { + k2 = par4 + j2; + + if (j2 >= j1 && k1 > 0) + { + k3 += Direction.offsetX[j3]; + l1 += Direction.offsetZ[j3]; + --k1; + } + + Block block1 = par1World.getBlock(k3, k2, l1); + + if (block1.isAir(par1World, k3, k2, l1) || block1.isLeaves(par1World, k3, k2, l1)) + { + this.setBlockAndNotifyAdequately(par1World, k3, k2, l1, Blocks.log2, 0); + i2 = k2; + } + } + + for (j2 = -1; j2 <= 1; ++j2) + { + for (k2 = -1; k2 <= 1; ++k2) + { + this.func_150525_a(par1World, k3 + j2, i2 + 1, l1 + k2); + } + } + + this.func_150525_a(par1World, k3 + 2, i2 + 1, l1); + this.func_150525_a(par1World, k3 - 2, i2 + 1, l1); + this.func_150525_a(par1World, k3, i2 + 1, l1 + 2); + this.func_150525_a(par1World, k3, i2 + 1, l1 - 2); + + for (j2 = -3; j2 <= 3; ++j2) + { + for (k2 = -3; k2 <= 3; ++k2) + { + if (Math.abs(j2) != 3 || Math.abs(k2) != 3) + { + this.func_150525_a(par1World, k3 + j2, i2, l1 + k2); + } + } + } + + k3 = par3; + l1 = par5; + j2 = par2Random.nextInt(4); + + if (j2 != j3) + { + k2 = j1 - par2Random.nextInt(2) - 1; + int l3 = 1 + par2Random.nextInt(3); + i2 = 0; + int l2; + int i3; + + for (l2 = k2; l2 < l && l3 > 0; --l3) + { + if (l2 >= 1) + { + i3 = par4 + l2; + k3 += Direction.offsetX[j2]; + l1 += Direction.offsetZ[j2]; + Block block2 = par1World.getBlock(k3, i3, l1); + + if (block2.isAir(par1World, k3, i3, l1) || block2.isLeaves(par1World, k3, i3, l1)) + { + this.setBlockAndNotifyAdequately(par1World, k3, i3, l1, Blocks.log2, 0); + i2 = i3; + } + } + + ++l2; + } + + if (i2 > 0) + { + for (l2 = -1; l2 <= 1; ++l2) + { + for (i3 = -1; i3 <= 1; ++i3) + { + this.func_150525_a(par1World, k3 + l2, i2 + 1, l1 + i3); + } + } + + for (l2 = -2; l2 <= 2; ++l2) + { + for (i3 = -2; i3 <= 2; ++i3) + { + if (Math.abs(l2) != 2 || Math.abs(i3) != 2) + { + this.func_150525_a(par1World, k3 + l2, i2, l1 + i3); + } + } + } + } + } + + return true; + } + else + { + return false; + } + } + } + else + { + return false; + } + } + + private void func_150525_a(World p_150525_1_, int p_150525_2_, int p_150525_3_, int p_150525_4_) + { + Block block = p_150525_1_.getBlock(p_150525_2_, p_150525_3_, p_150525_4_); + + if (block.isAir(p_150525_1_, p_150525_2_, p_150525_3_, p_150525_4_) || block.isLeaves(p_150525_1_, p_150525_2_, p_150525_3_, p_150525_4_)) + { + this.setBlockAndNotifyAdequately(p_150525_1_, p_150525_2_, p_150525_3_, p_150525_4_, Blocks.leaves2, 0); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/feature/WorldGenShrub.java b/src/main/java/net/minecraft/world/gen/feature/WorldGenShrub.java new file mode 100644 index 0000000..1235e0c --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/feature/WorldGenShrub.java @@ -0,0 +1,67 @@ +package net.minecraft.world.gen.feature; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; + +public class WorldGenShrub extends WorldGenTrees +{ + private int field_150528_a; + private int field_150527_b; + private static final String __OBFID = "CL_00000411"; + + public WorldGenShrub(int par1, int par2) + { + super(false); + this.field_150527_b = par1; + this.field_150528_a = par2; + } + + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + Block block; + + do + { + block = par1World.getBlock(par3, par4, par5); + if (!(block.isLeaves(par1World, par3, par4, par5) || block.isAir(par1World, par3, par4, par5))) + { + break; + } + --par4; + } while (par4 > 0); + + Block block1 = par1World.getBlock(par3, par4, par5); + + if (block1 == Blocks.dirt || block1 == Blocks.grass) + { + ++par4; + this.setBlockAndNotifyAdequately(par1World, par3, par4, par5, Blocks.log, this.field_150527_b); + + for (int l = par4; l <= par4 + 2; ++l) + { + int i1 = l - par4; + int j1 = 2 - i1; + + for (int k1 = par3 - j1; k1 <= par3 + j1; ++k1) + { + int l1 = k1 - par3; + + for (int i2 = par5 - j1; i2 <= par5 + j1; ++i2) + { + int j2 = i2 - par5; + + if ((Math.abs(l1) != j1 || Math.abs(j2) != j1 || par2Random.nextInt(2) != 0) && par1World.getBlock(k1, l, i2).canBeReplacedByLeaves(par1World, k1, l, i2)) + { + this.setBlockAndNotifyAdequately(par1World, k1, l, i2, Blocks.leaves, this.field_150528_a); + } + } + } + } + } + + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/feature/WorldGenSpikes.java b/src/main/java/net/minecraft/world/gen/feature/WorldGenSpikes.java new file mode 100644 index 0000000..42f4615 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/feature/WorldGenSpikes.java @@ -0,0 +1,72 @@ +package net.minecraft.world.gen.feature; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.entity.item.EntityEnderCrystal; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; + +public class WorldGenSpikes extends WorldGenerator +{ + private Block field_150520_a; + private static final String __OBFID = "CL_00000433"; + + public WorldGenSpikes(Block p_i45464_1_) + { + this.field_150520_a = p_i45464_1_; + } + + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + if (par1World.isAirBlock(par3, par4, par5) && par1World.getBlock(par3, par4 - 1, par5) == this.field_150520_a) + { + int l = par2Random.nextInt(32) + 6; + int i1 = par2Random.nextInt(4) + 1; + int j1; + int k1; + int l1; + int i2; + + for (j1 = par3 - i1; j1 <= par3 + i1; ++j1) + { + for (k1 = par5 - i1; k1 <= par5 + i1; ++k1) + { + l1 = j1 - par3; + i2 = k1 - par5; + + if (l1 * l1 + i2 * i2 <= i1 * i1 + 1 && par1World.getBlock(j1, par4 - 1, k1) != this.field_150520_a) + { + return false; + } + } + } + + for (j1 = par4; j1 < par4 + l && j1 < 256; ++j1) + { + for (k1 = par3 - i1; k1 <= par3 + i1; ++k1) + { + for (l1 = par5 - i1; l1 <= par5 + i1; ++l1) + { + i2 = k1 - par3; + int j2 = l1 - par5; + + if (i2 * i2 + j2 * j2 <= i1 * i1 + 1) + { + par1World.setBlock(k1, j1, l1, Blocks.obsidian, 0, 2); + } + } + } + } + + EntityEnderCrystal entityendercrystal = new EntityEnderCrystal(par1World); + entityendercrystal.setLocationAndAngles((double)((float)par3 + 0.5F), (double)(par4 + l), (double)((float)par5 + 0.5F), par2Random.nextFloat() * 360.0F, 0.0F); + par1World.spawnEntityInWorld(entityendercrystal); + par1World.setBlock(par3, par4 + l, par5, Blocks.bedrock, 0, 2); + return true; + } + else + { + return false; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/feature/WorldGenSwamp.java b/src/main/java/net/minecraft/world/gen/feature/WorldGenSwamp.java new file mode 100644 index 0000000..ca8c9ab --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/feature/WorldGenSwamp.java @@ -0,0 +1,192 @@ +package net.minecraft.world.gen.feature; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.block.BlockSapling; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public class WorldGenSwamp extends WorldGenAbstractTree +{ + private static final String __OBFID = "CL_00000436"; + + public WorldGenSwamp() + { + super(false); + } + + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + int l; + + for (l = par2Random.nextInt(4) + 5; par1World.getBlock(par3, par4 - 1, par5).getMaterial() == Material.water; --par4) + { + ; + } + + boolean flag = true; + + if (par4 >= 1 && par4 + l + 1 <= 256) + { + int j1; + int k1; + + for (int i1 = par4; i1 <= par4 + 1 + l; ++i1) + { + byte b0 = 1; + + if (i1 == par4) + { + b0 = 0; + } + + if (i1 >= par4 + 1 + l - 2) + { + b0 = 3; + } + + for (j1 = par3 - b0; j1 <= par3 + b0 && flag; ++j1) + { + for (k1 = par5 - b0; k1 <= par5 + b0 && flag; ++k1) + { + if (i1 >= 0 && i1 < 256) + { + Block block = par1World.getBlock(j1, i1, k1); + + if (!(block.isAir(par1World, j1, i1, k1) || block.isLeaves(par1World, j1, i1, k1))) + { + if (block != Blocks.water && block != Blocks.flowing_water) + { + flag = false; + } + else if (i1 > par4) + { + flag = false; + } + } + } + else + { + flag = false; + } + } + } + } + + if (!flag) + { + return false; + } + else + { + Block block1 = par1World.getBlock(par3, par4 - 1, par5); + + boolean isSoil = block1.canSustainPlant(par1World, par3, par4 - 1, par5, ForgeDirection.UP, (BlockSapling)Blocks.sapling); + if (isSoil && par4 < 256 - l - 1) + { + block1.onPlantGrow(par1World, par3, par4 - 1, par5, par3, par4, par5); + int l1; + int k2; + int l2; + + for (k2 = par4 - 3 + l; k2 <= par4 + l; ++k2) + { + j1 = k2 - (par4 + l); + k1 = 2 - j1 / 2; + + for (l2 = par3 - k1; l2 <= par3 + k1; ++l2) + { + l1 = l2 - par3; + + for (int i2 = par5 - k1; i2 <= par5 + k1; ++i2) + { + int j2 = i2 - par5; + + if ((Math.abs(l1) != k1 || Math.abs(j2) != k1 || par2Random.nextInt(2) != 0 && j1 != 0) && par1World.getBlock(l2, k2, i2).canBeReplacedByLeaves(par1World, l2, k2, i2)) + { + this.func_150515_a(par1World, l2, k2, i2, Blocks.leaves); + } + } + } + } + + for (k2 = 0; k2 < l; ++k2) + { + Block block2 = par1World.getBlock(par3, par4 + k2, par5); + + if (block2.isAir(par1World, par3, par4 + k2, par5) || block2.isLeaves(par1World, par3, par4 + k2, par5) || block2 == Blocks.flowing_water || block2 == Blocks.water) + { + this.func_150515_a(par1World, par3, par4 + k2, par5, Blocks.log); + } + } + + for (k2 = par4 - 3 + l; k2 <= par4 + l; ++k2) + { + j1 = k2 - (par4 + l); + k1 = 2 - j1 / 2; + + for (l2 = par3 - k1; l2 <= par3 + k1; ++l2) + { + for (l1 = par5 - k1; l1 <= par5 + k1; ++l1) + { + if (par1World.getBlock(l2, k2, l1).isLeaves(par1World, l2, k2, l1)) + { + if (par2Random.nextInt(4) == 0 && par1World.getBlock(l2 - 1, k2, l1).isAir(par1World, l2 - 1, k2, l1)) + { + this.generateVines(par1World, l2 - 1, k2, l1, 8); + } + + if (par2Random.nextInt(4) == 0 && par1World.getBlock(l2 + 1, k2, l1).isAir(par1World, l2 + 1, k2, l1)) + { + this.generateVines(par1World, l2 + 1, k2, l1, 2); + } + + if (par2Random.nextInt(4) == 0 && par1World.getBlock(l2, k2, l1 - 1).isAir(par1World, l2, k2, l1 - 1)) + { + this.generateVines(par1World, l2, k2, l1 - 1, 1); + } + + if (par2Random.nextInt(4) == 0 && par1World.getBlock(l2, k2, l1 + 1).isAir(par1World, l2, k2, l1 + 1)) + { + this.generateVines(par1World, l2, k2, l1 + 1, 4); + } + } + } + } + } + + return true; + } + else + { + return false; + } + } + } + else + { + return false; + } + } + + private void generateVines(World par1World, int par2, int par3, int par4, int par5) + { + this.setBlockAndNotifyAdequately(par1World, par2, par3, par4, Blocks.vine, par5); + int i1 = 4; + + while (true) + { + --par3; + + if (!(par1World.getBlock(par2, par3, par4).isAir(par1World, par2, par3, par4)) || i1 <= 0) + { + return; + } + + this.setBlockAndNotifyAdequately(par1World, par2, par3, par4, Blocks.vine, par5); + --i1; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/feature/WorldGenTaiga1.java b/src/main/java/net/minecraft/world/gen/feature/WorldGenTaiga1.java new file mode 100644 index 0000000..d68d57d --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/feature/WorldGenTaiga1.java @@ -0,0 +1,132 @@ +package net.minecraft.world.gen.feature; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.block.BlockSapling; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public class WorldGenTaiga1 extends WorldGenAbstractTree +{ + private static final String __OBFID = "CL_00000427"; + + public WorldGenTaiga1() + { + super(false); + } + + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + int l = par2Random.nextInt(5) + 7; + int i1 = l - par2Random.nextInt(2) - 3; + int j1 = l - i1; + int k1 = 1 + par2Random.nextInt(j1 + 1); + boolean flag = true; + + if (par4 >= 1 && par4 + l + 1 <= 256) + { + int i2; + int j2; + int i3; + + for (int l1 = par4; l1 <= par4 + 1 + l && flag; ++l1) + { + boolean flag1 = true; + + if (l1 - par4 < i1) + { + i3 = 0; + } + else + { + i3 = k1; + } + + for (i2 = par3 - i3; i2 <= par3 + i3 && flag; ++i2) + { + for (j2 = par5 - i3; j2 <= par5 + i3 && flag; ++j2) + { + if (l1 >= 0 && l1 < 256) + { + Block block = par1World.getBlock(i2, l1, j2); + + if (!this.isReplaceable(par1World, i2, l1, j2)) + { + flag = false; + } + } + else + { + flag = false; + } + } + } + } + + if (!flag) + { + return false; + } + else + { + Block block1 = par1World.getBlock(par3, par4 - 1, par5); + + boolean isSoil = block1.canSustainPlant(par1World, par3, par4 - 1, par5, ForgeDirection.UP, (BlockSapling)Blocks.sapling); + if (isSoil && par4 < 256 - l - 1) + { + block1.onPlantGrow(par1World, par3, par4 - 1, par5, par3, par4, par5); + i3 = 0; + + for (i2 = par4 + l; i2 >= par4 + i1; --i2) + { + for (j2 = par3 - i3; j2 <= par3 + i3; ++j2) + { + int j3 = j2 - par3; + + for (int k2 = par5 - i3; k2 <= par5 + i3; ++k2) + { + int l2 = k2 - par5; + + if ((Math.abs(j3) != i3 || Math.abs(l2) != i3 || i3 <= 0) && par1World.getBlock(j2, i2, k2).canBeReplacedByLeaves(par1World, j2, i2, k2)) + { + this.setBlockAndNotifyAdequately(par1World, j2, i2, k2, Blocks.leaves, 1); + } + } + } + + if (i3 >= 1 && i2 == par4 + i1 + 1) + { + --i3; + } + else if (i3 < k1) + { + ++i3; + } + } + + for (i2 = 0; i2 < l - 1; ++i2) + { + Block block2 = par1World.getBlock(par3, par4 + i2, par5); + + if (block2.isAir(par1World, par3, par4 + i2, par5) || block2.isLeaves(par1World, par3, par4 + i2, par5)) + { + this.setBlockAndNotifyAdequately(par1World, par3, par4 + i2, par5, Blocks.log, 1); + } + } + + return true; + } + else + { + return false; + } + } + } + else + { + return false; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/feature/WorldGenTaiga2.java b/src/main/java/net/minecraft/world/gen/feature/WorldGenTaiga2.java new file mode 100644 index 0000000..aa005a8 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/feature/WorldGenTaiga2.java @@ -0,0 +1,146 @@ +package net.minecraft.world.gen.feature; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.block.BlockSapling; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public class WorldGenTaiga2 extends WorldGenAbstractTree +{ + private static final String __OBFID = "CL_00000435"; + + public WorldGenTaiga2(boolean par1) + { + super(par1); + } + + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + int l = par2Random.nextInt(4) + 6; + int i1 = 1 + par2Random.nextInt(2); + int j1 = l - i1; + int k1 = 2 + par2Random.nextInt(2); + boolean flag = true; + + if (par4 >= 1 && par4 + l + 1 <= 256) + { + int i2; + int l3; + + for (int l1 = par4; l1 <= par4 + 1 + l && flag; ++l1) + { + boolean flag1 = true; + + if (l1 - par4 < i1) + { + l3 = 0; + } + else + { + l3 = k1; + } + + for (i2 = par3 - l3; i2 <= par3 + l3 && flag; ++i2) + { + for (int j2 = par5 - l3; j2 <= par5 + l3 && flag; ++j2) + { + if (l1 >= 0 && l1 < 256) + { + Block block = par1World.getBlock(i2, l1, j2); + + if (!block.isAir(par1World, i2, l1, j2) && !block.isLeaves(par1World, i2, l1, j2)) + { + flag = false; + } + } + else + { + flag = false; + } + } + } + } + + if (!flag) + { + return false; + } + else + { + Block block1 = par1World.getBlock(par3, par4 - 1, par5); + + boolean isSoil = block1.canSustainPlant(par1World, par3, par4 - 1, par5, ForgeDirection.UP, (BlockSapling)Blocks.sapling); + if (isSoil && par4 < 256 - l - 1) + { + block1.onPlantGrow(par1World, par3, par4 - 1, par5, par3, par4, par5); + l3 = par2Random.nextInt(2); + i2 = 1; + byte b0 = 0; + int k2; + int i4; + + for (i4 = 0; i4 <= j1; ++i4) + { + k2 = par4 + l - i4; + + for (int l2 = par3 - l3; l2 <= par3 + l3; ++l2) + { + int i3 = l2 - par3; + + for (int j3 = par5 - l3; j3 <= par5 + l3; ++j3) + { + int k3 = j3 - par5; + + if ((Math.abs(i3) != l3 || Math.abs(k3) != l3 || l3 <= 0) && par1World.getBlock(l2, k2, j3).canBeReplacedByLeaves(par1World, l2, k2, j3)) + { + this.setBlockAndNotifyAdequately(par1World, l2, k2, j3, Blocks.leaves, 1); + } + } + } + + if (l3 >= i2) + { + l3 = b0; + b0 = 1; + ++i2; + + if (i2 > k1) + { + i2 = k1; + } + } + else + { + ++l3; + } + } + + i4 = par2Random.nextInt(3); + + for (k2 = 0; k2 < l - i4; ++k2) + { + Block block2 = par1World.getBlock(par3, par4 + k2, par5); + + if (block2.isAir(par1World, par3, par4 + k2, par5) || block2.isLeaves(par1World, par3, par4 + k2, par5)) + { + this.setBlockAndNotifyAdequately(par1World, par3, par4 + k2, par5, Blocks.log, 1); + } + } + + return true; + } + else + { + return false; + } + } + } + else + { + return false; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/feature/WorldGenTallGrass.java b/src/main/java/net/minecraft/world/gen/feature/WorldGenTallGrass.java new file mode 100644 index 0000000..cb30fbb --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/feature/WorldGenTallGrass.java @@ -0,0 +1,48 @@ +package net.minecraft.world.gen.feature; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.world.World; + +public class WorldGenTallGrass extends WorldGenerator +{ + private Block field_150522_a; + private int tallGrassMetadata; + private static final String __OBFID = "CL_00000437"; + + public WorldGenTallGrass(Block p_i45466_1_, int p_i45466_2_) + { + this.field_150522_a = p_i45466_1_; + this.tallGrassMetadata = p_i45466_2_; + } + + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + Block block; + + do + { + block = par1World.getBlock(par3, par4, par5); + if (!(block.isLeaves(par1World, par3, par4, par5) || block.isAir(par1World, par3, par4, par5))) + { + break; + } + --par4; + } while (par4 > 0); + + for (int l = 0; l < 128; ++l) + { + int i1 = par3 + par2Random.nextInt(8) - par2Random.nextInt(8); + int j1 = par4 + par2Random.nextInt(4) - par2Random.nextInt(4); + int k1 = par5 + par2Random.nextInt(8) - par2Random.nextInt(8); + + if (par1World.isAirBlock(i1, j1, k1) && this.field_150522_a.canBlockStay(par1World, i1, j1, k1)) + { + par1World.setBlock(i1, j1, k1, this.field_150522_a, this.tallGrassMetadata, 2); + } + } + + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/feature/WorldGenTrees.java b/src/main/java/net/minecraft/world/gen/feature/WorldGenTrees.java new file mode 100644 index 0000000..748231b --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/feature/WorldGenTrees.java @@ -0,0 +1,243 @@ +package net.minecraft.world.gen.feature; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.block.BlockSapling; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.util.Direction; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public class WorldGenTrees extends WorldGenAbstractTree +{ + private final int minTreeHeight; + private final boolean vinesGrow; + private final int metaWood; + private final int metaLeaves; + private static final String __OBFID = "CL_00000438"; + + public WorldGenTrees(boolean par1) + { + this(par1, 4, 0, 0, false); + } + + public WorldGenTrees(boolean par1, int par2, int par3, int par4, boolean par5) + { + super(par1); + this.minTreeHeight = par2; + this.metaWood = par3; + this.metaLeaves = par4; + this.vinesGrow = par5; + } + + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + int l = par2Random.nextInt(3) + this.minTreeHeight; + boolean flag = true; + + if (par4 >= 1 && par4 + l + 1 <= 256) + { + byte b0; + int k1; + Block block; + + for (int i1 = par4; i1 <= par4 + 1 + l; ++i1) + { + b0 = 1; + + if (i1 == par4) + { + b0 = 0; + } + + if (i1 >= par4 + 1 + l - 2) + { + b0 = 2; + } + + for (int j1 = par3 - b0; j1 <= par3 + b0 && flag; ++j1) + { + for (k1 = par5 - b0; k1 <= par5 + b0 && flag; ++k1) + { + if (i1 >= 0 && i1 < 256) + { + block = par1World.getBlock(j1, i1, k1); + + if (!this.isReplaceable(par1World, j1, i1, k1)) + { + flag = false; + } + } + else + { + flag = false; + } + } + } + } + + if (!flag) + { + return false; + } + else + { + Block block2 = par1World.getBlock(par3, par4 - 1, par5); + + boolean isSoil = block2.canSustainPlant(par1World, par3, par4 - 1, par5, ForgeDirection.UP, (BlockSapling)Blocks.sapling); + if (isSoil && par4 < 256 - l - 1) + { + block2.onPlantGrow(par1World, par3, par4 - 1, par5, par3, par4, par5); + b0 = 3; + byte b1 = 0; + int l1; + int i2; + int j2; + int i3; + + for (k1 = par4 - b0 + l; k1 <= par4 + l; ++k1) + { + i3 = k1 - (par4 + l); + l1 = b1 + 1 - i3 / 2; + + for (i2 = par3 - l1; i2 <= par3 + l1; ++i2) + { + j2 = i2 - par3; + + for (int k2 = par5 - l1; k2 <= par5 + l1; ++k2) + { + int l2 = k2 - par5; + + if (Math.abs(j2) != l1 || Math.abs(l2) != l1 || par2Random.nextInt(2) != 0 && i3 != 0) + { + Block block1 = par1World.getBlock(i2, k1, k2); + + if (block1.isAir(par1World, i2, k1, k2) || block1.isLeaves(par1World, i2, k1, k2)) + { + this.setBlockAndNotifyAdequately(par1World, i2, k1, k2, Blocks.leaves, this.metaLeaves); + } + } + } + } + } + + for (k1 = 0; k1 < l; ++k1) + { + block = par1World.getBlock(par3, par4 + k1, par5); + + if (block.isAir(par1World, par3, par4 + k1, par5) || block.isLeaves(par1World, par3, par4 + k1, par5)) + { + this.setBlockAndNotifyAdequately(par1World, par3, par4 + k1, par5, Blocks.log, this.metaWood); + + if (this.vinesGrow && k1 > 0) + { + if (par2Random.nextInt(3) > 0 && par1World.isAirBlock(par3 - 1, par4 + k1, par5)) + { + this.setBlockAndNotifyAdequately(par1World, par3 - 1, par4 + k1, par5, Blocks.vine, 8); + } + + if (par2Random.nextInt(3) > 0 && par1World.isAirBlock(par3 + 1, par4 + k1, par5)) + { + this.setBlockAndNotifyAdequately(par1World, par3 + 1, par4 + k1, par5, Blocks.vine, 2); + } + + if (par2Random.nextInt(3) > 0 && par1World.isAirBlock(par3, par4 + k1, par5 - 1)) + { + this.setBlockAndNotifyAdequately(par1World, par3, par4 + k1, par5 - 1, Blocks.vine, 1); + } + + if (par2Random.nextInt(3) > 0 && par1World.isAirBlock(par3, par4 + k1, par5 + 1)) + { + this.setBlockAndNotifyAdequately(par1World, par3, par4 + k1, par5 + 1, Blocks.vine, 4); + } + } + } + } + + if (this.vinesGrow) + { + for (k1 = par4 - 3 + l; k1 <= par4 + l; ++k1) + { + i3 = k1 - (par4 + l); + l1 = 2 - i3 / 2; + + for (i2 = par3 - l1; i2 <= par3 + l1; ++i2) + { + for (j2 = par5 - l1; j2 <= par5 + l1; ++j2) + { + if (par1World.getBlock(i2, k1, j2).isLeaves(par1World, i2, k1, j2)) + { + if (par2Random.nextInt(4) == 0 && par1World.getBlock(i2 - 1, k1, j2).isAir(par1World, i2 - 1, k1, j2)) + { + this.growVines(par1World, i2 - 1, k1, j2, 8); + } + + if (par2Random.nextInt(4) == 0 && par1World.getBlock(i2 + 1, k1, j2).isAir(par1World, i2 + 1, k1, j2)) + { + this.growVines(par1World, i2 + 1, k1, j2, 2); + } + + if (par2Random.nextInt(4) == 0 && par1World.getBlock(i2, k1, j2 - 1).isAir(par1World, i2, k1, j2 - 1)) + { + this.growVines(par1World, i2, k1, j2 - 1, 1); + } + + if (par2Random.nextInt(4) == 0 && par1World.getBlock(i2, k1, j2 + 1).isAir(par1World, i2, k1, j2 + 1)) + { + this.growVines(par1World, i2, k1, j2 + 1, 4); + } + } + } + } + } + + if (par2Random.nextInt(5) == 0 && l > 5) + { + for (k1 = 0; k1 < 2; ++k1) + { + for (i3 = 0; i3 < 4; ++i3) + { + if (par2Random.nextInt(4 - k1) == 0) + { + l1 = par2Random.nextInt(3); + this.setBlockAndNotifyAdequately(par1World, par3 + Direction.offsetX[Direction.rotateOpposite[i3]], par4 + l - 5 + k1, par5 + Direction.offsetZ[Direction.rotateOpposite[i3]], Blocks.cocoa, l1 << 2 | i3); + } + } + } + } + } + + return true; + } + else + { + return false; + } + } + } + else + { + return false; + } + } + + private void growVines(World par1World, int par2, int par3, int par4, int par5) + { + this.setBlockAndNotifyAdequately(par1World, par2, par3, par4, Blocks.vine, par5); + int i1 = 4; + + while (true) + { + --par3; + + if (par1World.getBlock(par2, par3, par4).isAir(par1World, par2, par3, par4) || i1 <= 0) + { + return; + } + + this.setBlockAndNotifyAdequately(par1World, par2, par3, par4, Blocks.vine, par5); + --i1; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/feature/WorldGenVines.java b/src/main/java/net/minecraft/world/gen/feature/WorldGenVines.java new file mode 100644 index 0000000..2cd05ff --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/feature/WorldGenVines.java @@ -0,0 +1,39 @@ +package net.minecraft.world.gen.feature; + +import java.util.Random; +import net.minecraft.init.Blocks; +import net.minecraft.util.Direction; +import net.minecraft.util.Facing; +import net.minecraft.world.World; + +public class WorldGenVines extends WorldGenerator +{ + private static final String __OBFID = "CL_00000439"; + + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + int l = par3; + + for (int i1 = par5; par4 < 128; ++par4) + { + if (par1World.isAirBlock(par3, par4, par5)) + { + for (int j1 = 2; j1 <= 5; ++j1) + { + if (Blocks.vine.canPlaceBlockOnSide(par1World, par3, par4, par5, j1)) + { + par1World.setBlock(par3, par4, par5, Blocks.vine, 1 << Direction.facingToDirection[Facing.oppositeSide[j1]], 2); + break; + } + } + } + else + { + par3 = l + par2Random.nextInt(4) - par2Random.nextInt(4); + par5 = i1 + par2Random.nextInt(4) - par2Random.nextInt(4); + } + } + + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/feature/WorldGenWaterlily.java b/src/main/java/net/minecraft/world/gen/feature/WorldGenWaterlily.java new file mode 100644 index 0000000..8567f5c --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/feature/WorldGenWaterlily.java @@ -0,0 +1,27 @@ +package net.minecraft.world.gen.feature; + +import java.util.Random; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; + +public class WorldGenWaterlily extends WorldGenerator +{ + private static final String __OBFID = "CL_00000189"; + + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + for (int l = 0; l < 10; ++l) + { + int i1 = par3 + par2Random.nextInt(8) - par2Random.nextInt(8); + int j1 = par4 + par2Random.nextInt(4) - par2Random.nextInt(4); + int k1 = par5 + par2Random.nextInt(8) - par2Random.nextInt(8); + + if (par1World.isAirBlock(i1, j1, k1) && Blocks.waterlily.canPlaceBlockAt(par1World, i1, j1, k1)) + { + par1World.setBlock(i1, j1, k1, Blocks.waterlily, 0, 2); + } + } + + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/feature/WorldGenerator.java b/src/main/java/net/minecraft/world/gen/feature/WorldGenerator.java new file mode 100644 index 0000000..b486bf6 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/feature/WorldGenerator.java @@ -0,0 +1,42 @@ +package net.minecraft.world.gen.feature; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.world.World; + +public abstract class WorldGenerator +{ + private final boolean doBlockNotify; + private static final String __OBFID = "CL_00000409"; + + public WorldGenerator() + { + this.doBlockNotify = false; + } + + public WorldGenerator(boolean par1) + { + this.doBlockNotify = par1; + } + + public abstract boolean generate(World var1, Random var2, int var3, int var4, int var5); + + public void setScale(double par1, double par3, double par5) {} + + protected void func_150515_a(World p_150515_1_, int p_150515_2_, int p_150515_3_, int p_150515_4_, Block p_150515_5_) + { + this.setBlockAndNotifyAdequately(p_150515_1_, p_150515_2_, p_150515_3_, p_150515_4_, p_150515_5_, 0); + } + + protected void setBlockAndNotifyAdequately(World p_150516_1_, int p_150516_2_, int p_150516_3_, int p_150516_4_, Block p_150516_5_, int p_150516_6_) + { + if (this.doBlockNotify) + { + p_150516_1_.setBlock(p_150516_2_, p_150516_3_, p_150516_4_, p_150516_5_, p_150516_6_, 3); + } + else + { + p_150516_1_.setBlock(p_150516_2_, p_150516_3_, p_150516_4_, p_150516_5_, p_150516_6_, 2); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/feature/WorldGeneratorBonusChest.java b/src/main/java/net/minecraft/world/gen/feature/WorldGeneratorBonusChest.java new file mode 100644 index 0000000..41b3018 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/feature/WorldGeneratorBonusChest.java @@ -0,0 +1,85 @@ +package net.minecraft.world.gen.feature; + +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntityChest; +import net.minecraft.util.WeightedRandomChestContent; +import net.minecraft.world.World; + +public class WorldGeneratorBonusChest extends WorldGenerator +{ + private final WeightedRandomChestContent[] theBonusChestGenerator; + private final int itemsToGenerateInBonusChest; + private static final String __OBFID = "CL_00000403"; + + public WorldGeneratorBonusChest(WeightedRandomChestContent[] par1ArrayOfWeightedRandomChestContent, int par2) + { + this.theBonusChestGenerator = par1ArrayOfWeightedRandomChestContent; + this.itemsToGenerateInBonusChest = par2; + } + + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + Block block; + + do + { + block = par1World.getBlock(par3, par4, par5); + if (!block.isAir(par1World, par3, par4, par5) && !block.isLeaves(par1World, par3, par4, par5)) break; + par4--; + } while (par4 > 1); + + if (par4 < 1) + { + return false; + } + else + { + ++par4; + + for (int l = 0; l < 4; ++l) + { + int i1 = par3 + par2Random.nextInt(4) - par2Random.nextInt(4); + int j1 = par4 + par2Random.nextInt(3) - par2Random.nextInt(3); + int k1 = par5 + par2Random.nextInt(4) - par2Random.nextInt(4); + + if (par1World.isAirBlock(i1, j1, k1) && World.doesBlockHaveSolidTopSurface(par1World, i1, j1 - 1, k1)) + { + par1World.setBlock(i1, j1, k1, Blocks.chest, 0, 2); + TileEntityChest tileentitychest = (TileEntityChest)par1World.getTileEntity(i1, j1, k1); + + if (tileentitychest != null && tileentitychest != null) + { + WeightedRandomChestContent.generateChestContents(par2Random, this.theBonusChestGenerator, tileentitychest, this.itemsToGenerateInBonusChest); + } + + if (par1World.isAirBlock(i1 - 1, j1, k1) && World.doesBlockHaveSolidTopSurface(par1World, i1 - 1, j1 - 1, k1)) + { + par1World.setBlock(i1 - 1, j1, k1, Blocks.torch, 0, 2); + } + + if (par1World.isAirBlock(i1 + 1, j1, k1) && World.doesBlockHaveSolidTopSurface(par1World, i1 - 1, j1 - 1, k1)) + { + par1World.setBlock(i1 + 1, j1, k1, Blocks.torch, 0, 2); + } + + if (par1World.isAirBlock(i1, j1, k1 - 1) && World.doesBlockHaveSolidTopSurface(par1World, i1 - 1, j1 - 1, k1)) + { + par1World.setBlock(i1, j1, k1 - 1, Blocks.torch, 0, 2); + } + + if (par1World.isAirBlock(i1, j1, k1 + 1) && World.doesBlockHaveSolidTopSurface(par1World, i1 - 1, j1 - 1, k1)) + { + par1World.setBlock(i1, j1, k1 + 1, Blocks.torch, 0, 2); + } + + return true; + } + } + + return false; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/layer/GenLayer.java b/src/main/java/net/minecraft/world/gen/layer/GenLayer.java new file mode 100644 index 0000000..1f208a5 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/layer/GenLayer.java @@ -0,0 +1,212 @@ +package net.minecraft.world.gen.layer; + +import java.util.concurrent.Callable; +import net.minecraft.crash.CrashReport; +import net.minecraft.crash.CrashReportCategory; +import net.minecraft.util.ReportedException; +import net.minecraft.world.WorldType; +import net.minecraft.world.biome.BiomeGenBase; + +import net.minecraftforge.common.*; +import net.minecraftforge.event.terraingen.*; + +public abstract class GenLayer +{ + private long worldGenSeed; + protected GenLayer parent; + private long chunkSeed; + protected long baseSeed; + private static final String __OBFID = "CL_00000559"; + + public static GenLayer[] initializeAllBiomeGenerators(long par0, WorldType par2WorldType) + { + boolean flag = false; + GenLayerIsland genlayerisland = new GenLayerIsland(1L); + GenLayerFuzzyZoom genlayerfuzzyzoom = new GenLayerFuzzyZoom(2000L, genlayerisland); + GenLayerAddIsland genlayeraddisland = new GenLayerAddIsland(1L, genlayerfuzzyzoom); + GenLayerZoom genlayerzoom = new GenLayerZoom(2001L, genlayeraddisland); + genlayeraddisland = new GenLayerAddIsland(2L, genlayerzoom); + genlayeraddisland = new GenLayerAddIsland(50L, genlayeraddisland); + genlayeraddisland = new GenLayerAddIsland(70L, genlayeraddisland); + GenLayerRemoveTooMuchOcean genlayerremovetoomuchocean = new GenLayerRemoveTooMuchOcean(2L, genlayeraddisland); + GenLayerAddSnow genlayeraddsnow = new GenLayerAddSnow(2L, genlayerremovetoomuchocean); + genlayeraddisland = new GenLayerAddIsland(3L, genlayeraddsnow); + GenLayerEdge genlayeredge = new GenLayerEdge(2L, genlayeraddisland, GenLayerEdge.Mode.COOL_WARM); + genlayeredge = new GenLayerEdge(2L, genlayeredge, GenLayerEdge.Mode.HEAT_ICE); + genlayeredge = new GenLayerEdge(3L, genlayeredge, GenLayerEdge.Mode.SPECIAL); + genlayerzoom = new GenLayerZoom(2002L, genlayeredge); + genlayerzoom = new GenLayerZoom(2003L, genlayerzoom); + genlayeraddisland = new GenLayerAddIsland(4L, genlayerzoom); + GenLayerAddMushroomIsland genlayeraddmushroomisland = new GenLayerAddMushroomIsland(5L, genlayeraddisland); + GenLayerDeepOcean genlayerdeepocean = new GenLayerDeepOcean(4L, genlayeraddmushroomisland); + GenLayer genlayer2 = GenLayerZoom.magnify(1000L, genlayerdeepocean, 0); + byte b0 = 4; + + if (par2WorldType == WorldType.LARGE_BIOMES) + { + b0 = 6; + } + + if (flag) + { + b0 = 4; + } + b0 = getModdedBiomeSize(par2WorldType, b0); + + GenLayer genlayer = GenLayerZoom.magnify(1000L, genlayer2, 0); + GenLayerRiverInit genlayerriverinit = new GenLayerRiverInit(100L, genlayer); + Object object = par2WorldType.getBiomeLayer(par0, genlayer2); + + GenLayer genlayer1 = GenLayerZoom.magnify(1000L, genlayerriverinit, 2); + GenLayerHills genlayerhills = new GenLayerHills(1000L, (GenLayer)object, genlayer1); + genlayer = GenLayerZoom.magnify(1000L, genlayerriverinit, 2); + genlayer = GenLayerZoom.magnify(1000L, genlayer, b0); + GenLayerRiver genlayerriver = new GenLayerRiver(1L, genlayer); + GenLayerSmooth genlayersmooth = new GenLayerSmooth(1000L, genlayerriver); + object = new GenLayerRareBiome(1001L, genlayerhills); + + for (int j = 0; j < b0; ++j) + { + object = new GenLayerZoom((long)(1000 + j), (GenLayer)object); + + if (j == 0) + { + object = new GenLayerAddIsland(3L, (GenLayer)object); + } + + if (j == 1) + { + object = new GenLayerShore(1000L, (GenLayer)object); + } + } + + GenLayerSmooth genlayersmooth1 = new GenLayerSmooth(1000L, (GenLayer)object); + GenLayerRiverMix genlayerrivermix = new GenLayerRiverMix(100L, genlayersmooth1, genlayersmooth); + GenLayerVoronoiZoom genlayervoronoizoom = new GenLayerVoronoiZoom(10L, genlayerrivermix); + genlayerrivermix.initWorldGenSeed(par0); + genlayervoronoizoom.initWorldGenSeed(par0); + return new GenLayer[] {genlayerrivermix, genlayervoronoizoom, genlayerrivermix}; + } + + public GenLayer(long par1) + { + this.baseSeed = par1; + this.baseSeed *= this.baseSeed * 6364136223846793005L + 1442695040888963407L; + this.baseSeed += par1; + this.baseSeed *= this.baseSeed * 6364136223846793005L + 1442695040888963407L; + this.baseSeed += par1; + this.baseSeed *= this.baseSeed * 6364136223846793005L + 1442695040888963407L; + this.baseSeed += par1; + } + + public void initWorldGenSeed(long par1) + { + this.worldGenSeed = par1; + + if (this.parent != null) + { + this.parent.initWorldGenSeed(par1); + } + + this.worldGenSeed *= this.worldGenSeed * 6364136223846793005L + 1442695040888963407L; + this.worldGenSeed += this.baseSeed; + this.worldGenSeed *= this.worldGenSeed * 6364136223846793005L + 1442695040888963407L; + this.worldGenSeed += this.baseSeed; + this.worldGenSeed *= this.worldGenSeed * 6364136223846793005L + 1442695040888963407L; + this.worldGenSeed += this.baseSeed; + } + + public void initChunkSeed(long par1, long par3) + { + this.chunkSeed = this.worldGenSeed; + this.chunkSeed *= this.chunkSeed * 6364136223846793005L + 1442695040888963407L; + this.chunkSeed += par1; + this.chunkSeed *= this.chunkSeed * 6364136223846793005L + 1442695040888963407L; + this.chunkSeed += par3; + this.chunkSeed *= this.chunkSeed * 6364136223846793005L + 1442695040888963407L; + this.chunkSeed += par1; + this.chunkSeed *= this.chunkSeed * 6364136223846793005L + 1442695040888963407L; + this.chunkSeed += par3; + } + + protected int nextInt(int par1) + { + int j = (int)((this.chunkSeed >> 24) % (long)par1); + + if (j < 0) + { + j += par1; + } + + this.chunkSeed *= this.chunkSeed * 6364136223846793005L + 1442695040888963407L; + this.chunkSeed += this.worldGenSeed; + return j; + } + + public abstract int[] getInts(int var1, int var2, int var3, int var4); + + protected static boolean compareBiomesById(final int p_151616_0_, final int p_151616_1_) + { + if (p_151616_0_ == p_151616_1_) + { + return true; + } + else if (p_151616_0_ != BiomeGenBase.mesaPlateau_F.biomeID && p_151616_0_ != BiomeGenBase.mesaPlateau.biomeID) + { + try + { + return BiomeGenBase.getBiome(p_151616_0_) != null && BiomeGenBase.getBiome(p_151616_1_) != null ? BiomeGenBase.getBiome(p_151616_0_).isEqualTo(BiomeGenBase.getBiome(p_151616_1_)) : false; + } + catch (Throwable throwable) + { + CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Comparing biomes"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("Biomes being compared"); + crashreportcategory.addCrashSection("Biome A ID", Integer.valueOf(p_151616_0_)); + crashreportcategory.addCrashSection("Biome B ID", Integer.valueOf(p_151616_1_)); + crashreportcategory.addCrashSectionCallable("Biome A", new Callable() + { + private static final String __OBFID = "CL_00000560"; + public String call() + { + return String.valueOf(BiomeGenBase.getBiome(p_151616_0_)); + } + }); + crashreportcategory.addCrashSectionCallable("Biome B", new Callable() + { + private static final String __OBFID = "CL_00000561"; + public String call() + { + return String.valueOf(BiomeGenBase.getBiome(p_151616_1_)); + } + }); + throw new ReportedException(crashreport); + } + } + else + { + return p_151616_1_ == BiomeGenBase.mesaPlateau_F.biomeID || p_151616_1_ == BiomeGenBase.mesaPlateau.biomeID; + } + } + + protected static boolean isBiomeOceanic(int p_151618_0_) + { + return p_151618_0_ == BiomeGenBase.ocean.biomeID || p_151618_0_ == BiomeGenBase.deepOcean.biomeID || p_151618_0_ == BiomeGenBase.frozenOcean.biomeID; + } + + protected int selectRandom(int ... p_151619_1_) + { + return p_151619_1_[this.nextInt(p_151619_1_.length)]; + } + + protected int selectModeOrRandom(int p_151617_1_, int p_151617_2_, int p_151617_3_, int p_151617_4_) + { + return p_151617_2_ == p_151617_3_ && p_151617_3_ == p_151617_4_ ? p_151617_2_ : (p_151617_1_ == p_151617_2_ && p_151617_1_ == p_151617_3_ ? p_151617_1_ : (p_151617_1_ == p_151617_2_ && p_151617_1_ == p_151617_4_ ? p_151617_1_ : (p_151617_1_ == p_151617_3_ && p_151617_1_ == p_151617_4_ ? p_151617_1_ : (p_151617_1_ == p_151617_2_ && p_151617_3_ != p_151617_4_ ? p_151617_1_ : (p_151617_1_ == p_151617_3_ && p_151617_2_ != p_151617_4_ ? p_151617_1_ : (p_151617_1_ == p_151617_4_ && p_151617_2_ != p_151617_3_ ? p_151617_1_ : (p_151617_2_ == p_151617_3_ && p_151617_1_ != p_151617_4_ ? p_151617_2_ : (p_151617_2_ == p_151617_4_ && p_151617_1_ != p_151617_3_ ? p_151617_2_ : (p_151617_3_ == p_151617_4_ && p_151617_1_ != p_151617_2_ ? p_151617_3_ : this.selectRandom(new int[] {p_151617_1_, p_151617_2_, p_151617_3_, p_151617_4_})))))))))); + } + + public static byte getModdedBiomeSize(WorldType worldType, byte original) + { + WorldTypeEvent.BiomeSize event = new WorldTypeEvent.BiomeSize(worldType, original); + MinecraftForge.TERRAIN_GEN_BUS.post(event); + return event.newSize; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/layer/GenLayerAddIsland.java b/src/main/java/net/minecraft/world/gen/layer/GenLayerAddIsland.java new file mode 100644 index 0000000..11a254a --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/layer/GenLayerAddIsland.java @@ -0,0 +1,98 @@ +package net.minecraft.world.gen.layer; + +public class GenLayerAddIsland extends GenLayer +{ + private static final String __OBFID = "CL_00000551"; + + public GenLayerAddIsland(long par1, GenLayer par3GenLayer) + { + super(par1); + this.parent = par3GenLayer; + } + + public int[] getInts(int par1, int par2, int par3, int par4) + { + int i1 = par1 - 1; + int j1 = par2 - 1; + int k1 = par3 + 2; + int l1 = par4 + 2; + int[] aint = this.parent.getInts(i1, j1, k1, l1); + int[] aint1 = IntCache.getIntCache(par3 * par4); + + for (int i2 = 0; i2 < par4; ++i2) + { + for (int j2 = 0; j2 < par3; ++j2) + { + int k2 = aint[j2 + 0 + (i2 + 0) * k1]; + int l2 = aint[j2 + 2 + (i2 + 0) * k1]; + int i3 = aint[j2 + 0 + (i2 + 2) * k1]; + int j3 = aint[j2 + 2 + (i2 + 2) * k1]; + int k3 = aint[j2 + 1 + (i2 + 1) * k1]; + this.initChunkSeed((long)(j2 + par1), (long)(i2 + par2)); + + if (k3 == 0 && (k2 != 0 || l2 != 0 || i3 != 0 || j3 != 0)) + { + int l3 = 1; + int i4 = 1; + + if (k2 != 0 && this.nextInt(l3++) == 0) + { + i4 = k2; + } + + if (l2 != 0 && this.nextInt(l3++) == 0) + { + i4 = l2; + } + + if (i3 != 0 && this.nextInt(l3++) == 0) + { + i4 = i3; + } + + if (j3 != 0 && this.nextInt(l3++) == 0) + { + i4 = j3; + } + + if (this.nextInt(3) == 0) + { + aint1[j2 + i2 * par3] = i4; + } + else if (i4 == 4) + { + aint1[j2 + i2 * par3] = 4; + } + else + { + aint1[j2 + i2 * par3] = 0; + } + } + else if (k3 > 0 && (k2 == 0 || l2 == 0 || i3 == 0 || j3 == 0)) + { + if (this.nextInt(5) == 0) + { + if (k3 == 4) + { + aint1[j2 + i2 * par3] = 4; + } + else + { + aint1[j2 + i2 * par3] = 0; + } + } + else + { + aint1[j2 + i2 * par3] = k3; + } + } + else + { + aint1[j2 + i2 * par3] = k3; + } + } + } + + return aint1; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/layer/GenLayerAddMushroomIsland.java b/src/main/java/net/minecraft/world/gen/layer/GenLayerAddMushroomIsland.java new file mode 100644 index 0000000..306dbc3 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/layer/GenLayerAddMushroomIsland.java @@ -0,0 +1,48 @@ +package net.minecraft.world.gen.layer; + +import net.minecraft.world.biome.BiomeGenBase; + +public class GenLayerAddMushroomIsland extends GenLayer +{ + private static final String __OBFID = "CL_00000552"; + + public GenLayerAddMushroomIsland(long par1, GenLayer par3GenLayer) + { + super(par1); + this.parent = par3GenLayer; + } + + public int[] getInts(int par1, int par2, int par3, int par4) + { + int i1 = par1 - 1; + int j1 = par2 - 1; + int k1 = par3 + 2; + int l1 = par4 + 2; + int[] aint = this.parent.getInts(i1, j1, k1, l1); + int[] aint1 = IntCache.getIntCache(par3 * par4); + + for (int i2 = 0; i2 < par4; ++i2) + { + for (int j2 = 0; j2 < par3; ++j2) + { + int k2 = aint[j2 + 0 + (i2 + 0) * k1]; + int l2 = aint[j2 + 2 + (i2 + 0) * k1]; + int i3 = aint[j2 + 0 + (i2 + 2) * k1]; + int j3 = aint[j2 + 2 + (i2 + 2) * k1]; + int k3 = aint[j2 + 1 + (i2 + 1) * k1]; + this.initChunkSeed((long)(j2 + par1), (long)(i2 + par2)); + + if (k3 == 0 && k2 == 0 && l2 == 0 && i3 == 0 && j3 == 0 && this.nextInt(100) == 0) + { + aint1[j2 + i2 * par3] = BiomeGenBase.mushroomIsland.biomeID; + } + else + { + aint1[j2 + i2 * par3] = k3; + } + } + } + + return aint1; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/layer/GenLayerAddSnow.java b/src/main/java/net/minecraft/world/gen/layer/GenLayerAddSnow.java new file mode 100644 index 0000000..388d3f9 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/layer/GenLayerAddSnow.java @@ -0,0 +1,58 @@ +package net.minecraft.world.gen.layer; + +public class GenLayerAddSnow extends GenLayer +{ + private static final String __OBFID = "CL_00000553"; + + public GenLayerAddSnow(long par1, GenLayer par3GenLayer) + { + super(par1); + this.parent = par3GenLayer; + } + + public int[] getInts(int par1, int par2, int par3, int par4) + { + int i1 = par1 - 1; + int j1 = par2 - 1; + int k1 = par3 + 2; + int l1 = par4 + 2; + int[] aint = this.parent.getInts(i1, j1, k1, l1); + int[] aint1 = IntCache.getIntCache(par3 * par4); + + for (int i2 = 0; i2 < par4; ++i2) + { + for (int j2 = 0; j2 < par3; ++j2) + { + int k2 = aint[j2 + 1 + (i2 + 1) * k1]; + this.initChunkSeed((long)(j2 + par1), (long)(i2 + par2)); + + if (k2 == 0) + { + aint1[j2 + i2 * par3] = 0; + } + else + { + int l2 = this.nextInt(6); + byte b0; + + if (l2 == 0) + { + b0 = 4; + } + else if (l2 <= 1) + { + b0 = 3; + } + else + { + b0 = 1; + } + + aint1[j2 + i2 * par3] = b0; + } + } + } + + return aint1; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/layer/GenLayerBiome.java b/src/main/java/net/minecraft/world/gen/layer/GenLayerBiome.java new file mode 100644 index 0000000..95a16c0 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/layer/GenLayerBiome.java @@ -0,0 +1,104 @@ +package net.minecraft.world.gen.layer; + +import net.minecraft.world.WorldType; +import net.minecraft.world.biome.BiomeGenBase; + +public class GenLayerBiome extends GenLayer +{ + private BiomeGenBase[] field_151623_c; + private BiomeGenBase[] field_151621_d; + private BiomeGenBase[] field_151622_e; + private BiomeGenBase[] field_151620_f; + private static final String __OBFID = "CL_00000555"; + + public GenLayerBiome(long par1, GenLayer par3GenLayer, WorldType par4WorldType) + { + super(par1); + this.field_151623_c = new BiomeGenBase[] {BiomeGenBase.desert, BiomeGenBase.desert, BiomeGenBase.desert, BiomeGenBase.savanna, BiomeGenBase.savanna, BiomeGenBase.plains}; + this.field_151621_d = new BiomeGenBase[] {BiomeGenBase.forest, BiomeGenBase.roofedForest, BiomeGenBase.extremeHills, BiomeGenBase.plains, BiomeGenBase.birchForest, BiomeGenBase.swampland}; + this.field_151622_e = new BiomeGenBase[] {BiomeGenBase.forest, BiomeGenBase.extremeHills, BiomeGenBase.taiga, BiomeGenBase.plains}; + this.field_151620_f = new BiomeGenBase[] {BiomeGenBase.icePlains, BiomeGenBase.icePlains, BiomeGenBase.icePlains, BiomeGenBase.coldTaiga}; + this.parent = par3GenLayer; + + if (par4WorldType == WorldType.DEFAULT_1_1) + { + this.field_151623_c = new BiomeGenBase[] {BiomeGenBase.desert, BiomeGenBase.forest, BiomeGenBase.extremeHills, BiomeGenBase.swampland, BiomeGenBase.plains, BiomeGenBase.taiga}; + } + } + + public int[] getInts(int par1, int par2, int par3, int par4) + { + int[] aint = this.parent.getInts(par1, par2, par3, par4); + int[] aint1 = IntCache.getIntCache(par3 * par4); + + for (int i1 = 0; i1 < par4; ++i1) + { + for (int j1 = 0; j1 < par3; ++j1) + { + this.initChunkSeed((long)(j1 + par1), (long)(i1 + par2)); + int k1 = aint[j1 + i1 * par3]; + int l1 = (k1 & 3840) >> 8; + k1 &= -3841; + + if (isBiomeOceanic(k1)) + { + aint1[j1 + i1 * par3] = k1; + } + else if (k1 == BiomeGenBase.mushroomIsland.biomeID) + { + aint1[j1 + i1 * par3] = k1; + } + else if (k1 == 1) + { + if (l1 > 0) + { + if (this.nextInt(3) == 0) + { + aint1[j1 + i1 * par3] = BiomeGenBase.mesaPlateau.biomeID; + } + else + { + aint1[j1 + i1 * par3] = BiomeGenBase.mesaPlateau_F.biomeID; + } + } + else + { + aint1[j1 + i1 * par3] = this.field_151623_c[this.nextInt(this.field_151623_c.length)].biomeID; + } + } + else if (k1 == 2) + { + if (l1 > 0) + { + aint1[j1 + i1 * par3] = BiomeGenBase.jungle.biomeID; + } + else + { + aint1[j1 + i1 * par3] = this.field_151621_d[this.nextInt(this.field_151621_d.length)].biomeID; + } + } + else if (k1 == 3) + { + if (l1 > 0) + { + aint1[j1 + i1 * par3] = BiomeGenBase.megaTaiga.biomeID; + } + else + { + aint1[j1 + i1 * par3] = this.field_151622_e[this.nextInt(this.field_151622_e.length)].biomeID; + } + } + else if (k1 == 4) + { + aint1[j1 + i1 * par3] = this.field_151620_f[this.nextInt(this.field_151620_f.length)].biomeID; + } + else + { + aint1[j1 + i1 * par3] = BiomeGenBase.mushroomIsland.biomeID; + } + } + } + + return aint1; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/layer/GenLayerBiomeEdge.java b/src/main/java/net/minecraft/world/gen/layer/GenLayerBiomeEdge.java new file mode 100644 index 0000000..f8be56b --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/layer/GenLayerBiomeEdge.java @@ -0,0 +1,153 @@ +package net.minecraft.world.gen.layer; + +import net.minecraft.world.biome.BiomeGenBase; + +public class GenLayerBiomeEdge extends GenLayer +{ + private static final String __OBFID = "CL_00000554"; + + public GenLayerBiomeEdge(long p_i45475_1_, GenLayer p_i45475_3_) + { + super(p_i45475_1_); + this.parent = p_i45475_3_; + } + + public int[] getInts(int par1, int par2, int par3, int par4) + { + int[] aint = this.parent.getInts(par1 - 1, par2 - 1, par3 + 2, par4 + 2); + int[] aint1 = IntCache.getIntCache(par3 * par4); + + for (int i1 = 0; i1 < par4; ++i1) + { + for (int j1 = 0; j1 < par3; ++j1) + { + this.initChunkSeed((long)(j1 + par1), (long)(i1 + par2)); + int k1 = aint[j1 + 1 + (i1 + 1) * (par3 + 2)]; + + if (!this.func_151636_a(aint, aint1, j1, i1, par3, k1, BiomeGenBase.extremeHills.biomeID, BiomeGenBase.extremeHillsEdge.biomeID) && !this.func_151635_b(aint, aint1, j1, i1, par3, k1, BiomeGenBase.mesaPlateau_F.biomeID, BiomeGenBase.mesa.biomeID) && !this.func_151635_b(aint, aint1, j1, i1, par3, k1, BiomeGenBase.mesaPlateau.biomeID, BiomeGenBase.mesa.biomeID) && !this.func_151635_b(aint, aint1, j1, i1, par3, k1, BiomeGenBase.megaTaiga.biomeID, BiomeGenBase.taiga.biomeID)) + { + int l1; + int i2; + int j2; + int k2; + + if (k1 == BiomeGenBase.desert.biomeID) + { + l1 = aint[j1 + 1 + (i1 + 1 - 1) * (par3 + 2)]; + i2 = aint[j1 + 1 + 1 + (i1 + 1) * (par3 + 2)]; + j2 = aint[j1 + 1 - 1 + (i1 + 1) * (par3 + 2)]; + k2 = aint[j1 + 1 + (i1 + 1 + 1) * (par3 + 2)]; + + if (l1 != BiomeGenBase.icePlains.biomeID && i2 != BiomeGenBase.icePlains.biomeID && j2 != BiomeGenBase.icePlains.biomeID && k2 != BiomeGenBase.icePlains.biomeID) + { + aint1[j1 + i1 * par3] = k1; + } + else + { + aint1[j1 + i1 * par3] = BiomeGenBase.extremeHillsPlus.biomeID; + } + } + else if (k1 == BiomeGenBase.swampland.biomeID) + { + l1 = aint[j1 + 1 + (i1 + 1 - 1) * (par3 + 2)]; + i2 = aint[j1 + 1 + 1 + (i1 + 1) * (par3 + 2)]; + j2 = aint[j1 + 1 - 1 + (i1 + 1) * (par3 + 2)]; + k2 = aint[j1 + 1 + (i1 + 1 + 1) * (par3 + 2)]; + + if (l1 != BiomeGenBase.desert.biomeID && i2 != BiomeGenBase.desert.biomeID && j2 != BiomeGenBase.desert.biomeID && k2 != BiomeGenBase.desert.biomeID && l1 != BiomeGenBase.coldTaiga.biomeID && i2 != BiomeGenBase.coldTaiga.biomeID && j2 != BiomeGenBase.coldTaiga.biomeID && k2 != BiomeGenBase.coldTaiga.biomeID && l1 != BiomeGenBase.icePlains.biomeID && i2 != BiomeGenBase.icePlains.biomeID && j2 != BiomeGenBase.icePlains.biomeID && k2 != BiomeGenBase.icePlains.biomeID) + { + if (l1 != BiomeGenBase.jungle.biomeID && k2 != BiomeGenBase.jungle.biomeID && i2 != BiomeGenBase.jungle.biomeID && j2 != BiomeGenBase.jungle.biomeID) + { + aint1[j1 + i1 * par3] = k1; + } + else + { + aint1[j1 + i1 * par3] = BiomeGenBase.jungleEdge.biomeID; + } + } + else + { + aint1[j1 + i1 * par3] = BiomeGenBase.plains.biomeID; + } + } + else + { + aint1[j1 + i1 * par3] = k1; + } + } + } + } + + return aint1; + } + + private boolean func_151636_a(int[] p_151636_1_, int[] p_151636_2_, int p_151636_3_, int p_151636_4_, int p_151636_5_, int p_151636_6_, int p_151636_7_, int p_151636_8_) + { + if (!compareBiomesById(p_151636_6_, p_151636_7_)) + { + return false; + } + else + { + int k1 = p_151636_1_[p_151636_3_ + 1 + (p_151636_4_ + 1 - 1) * (p_151636_5_ + 2)]; + int l1 = p_151636_1_[p_151636_3_ + 1 + 1 + (p_151636_4_ + 1) * (p_151636_5_ + 2)]; + int i2 = p_151636_1_[p_151636_3_ + 1 - 1 + (p_151636_4_ + 1) * (p_151636_5_ + 2)]; + int j2 = p_151636_1_[p_151636_3_ + 1 + (p_151636_4_ + 1 + 1) * (p_151636_5_ + 2)]; + + if (this.func_151634_b(k1, p_151636_7_) && this.func_151634_b(l1, p_151636_7_) && this.func_151634_b(i2, p_151636_7_) && this.func_151634_b(j2, p_151636_7_)) + { + p_151636_2_[p_151636_3_ + p_151636_4_ * p_151636_5_] = p_151636_6_; + } + else + { + p_151636_2_[p_151636_3_ + p_151636_4_ * p_151636_5_] = p_151636_8_; + } + + return true; + } + } + + private boolean func_151635_b(int[] p_151635_1_, int[] p_151635_2_, int p_151635_3_, int p_151635_4_, int p_151635_5_, int p_151635_6_, int p_151635_7_, int p_151635_8_) + { + if (p_151635_6_ != p_151635_7_) + { + return false; + } + else + { + int k1 = p_151635_1_[p_151635_3_ + 1 + (p_151635_4_ + 1 - 1) * (p_151635_5_ + 2)]; + int l1 = p_151635_1_[p_151635_3_ + 1 + 1 + (p_151635_4_ + 1) * (p_151635_5_ + 2)]; + int i2 = p_151635_1_[p_151635_3_ + 1 - 1 + (p_151635_4_ + 1) * (p_151635_5_ + 2)]; + int j2 = p_151635_1_[p_151635_3_ + 1 + (p_151635_4_ + 1 + 1) * (p_151635_5_ + 2)]; + + if (compareBiomesById(k1, p_151635_7_) && compareBiomesById(l1, p_151635_7_) && compareBiomesById(i2, p_151635_7_) && compareBiomesById(j2, p_151635_7_)) + { + p_151635_2_[p_151635_3_ + p_151635_4_ * p_151635_5_] = p_151635_6_; + } + else + { + p_151635_2_[p_151635_3_ + p_151635_4_ * p_151635_5_] = p_151635_8_; + } + + return true; + } + } + + private boolean func_151634_b(int p_151634_1_, int p_151634_2_) + { + if (compareBiomesById(p_151634_1_, p_151634_2_)) + { + return true; + } + else if (BiomeGenBase.getBiome(p_151634_1_) != null && BiomeGenBase.getBiome(p_151634_2_) != null) + { + BiomeGenBase.TempCategory tempcategory = BiomeGenBase.getBiome(p_151634_1_).getTempCategory(); + BiomeGenBase.TempCategory tempcategory1 = BiomeGenBase.getBiome(p_151634_2_).getTempCategory(); + return tempcategory == tempcategory1 || tempcategory == BiomeGenBase.TempCategory.MEDIUM || tempcategory1 == BiomeGenBase.TempCategory.MEDIUM; + } + else + { + return false; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/layer/GenLayerDeepOcean.java b/src/main/java/net/minecraft/world/gen/layer/GenLayerDeepOcean.java new file mode 100644 index 0000000..5aeed7a --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/layer/GenLayerDeepOcean.java @@ -0,0 +1,68 @@ +package net.minecraft.world.gen.layer; + +import net.minecraft.world.biome.BiomeGenBase; + +public class GenLayerDeepOcean extends GenLayer +{ + private static final String __OBFID = "CL_00000546"; + + public GenLayerDeepOcean(long p_i45472_1_, GenLayer p_i45472_3_) + { + super(p_i45472_1_); + this.parent = p_i45472_3_; + } + + public int[] getInts(int par1, int par2, int par3, int par4) + { + int i1 = par1 - 1; + int j1 = par2 - 1; + int k1 = par3 + 2; + int l1 = par4 + 2; + int[] aint = this.parent.getInts(i1, j1, k1, l1); + int[] aint1 = IntCache.getIntCache(par3 * par4); + + for (int i2 = 0; i2 < par4; ++i2) + { + for (int j2 = 0; j2 < par3; ++j2) + { + int k2 = aint[j2 + 1 + (i2 + 1 - 1) * (par3 + 2)]; + int l2 = aint[j2 + 1 + 1 + (i2 + 1) * (par3 + 2)]; + int i3 = aint[j2 + 1 - 1 + (i2 + 1) * (par3 + 2)]; + int j3 = aint[j2 + 1 + (i2 + 1 + 1) * (par3 + 2)]; + int k3 = aint[j2 + 1 + (i2 + 1) * k1]; + int l3 = 0; + + if (k2 == 0) + { + ++l3; + } + + if (l2 == 0) + { + ++l3; + } + + if (i3 == 0) + { + ++l3; + } + + if (j3 == 0) + { + ++l3; + } + + if (k3 == 0 && l3 > 3) + { + aint1[j2 + i2 * par3] = BiomeGenBase.deepOcean.biomeID; + } + else + { + aint1[j2 + i2 * par3] = k3; + } + } + } + + return aint1; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/layer/GenLayerEdge.java b/src/main/java/net/minecraft/world/gen/layer/GenLayerEdge.java new file mode 100644 index 0000000..47d7507 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/layer/GenLayerEdge.java @@ -0,0 +1,172 @@ +package net.minecraft.world.gen.layer; + +public class GenLayerEdge extends GenLayer +{ + private final GenLayerEdge.Mode field_151627_c; + private static final String __OBFID = "CL_00000547"; + + public GenLayerEdge(long p_i45474_1_, GenLayer p_i45474_3_, GenLayerEdge.Mode p_i45474_4_) + { + super(p_i45474_1_); + this.parent = p_i45474_3_; + this.field_151627_c = p_i45474_4_; + } + + public int[] getInts(int par1, int par2, int par3, int par4) + { + switch (GenLayerEdge.SwitchMode.field_151642_a[this.field_151627_c.ordinal()]) + { + case 1: + default: + return this.getIntsCoolWarm(par1, par2, par3, par4); + case 2: + return this.getIntsHeatIce(par1, par2, par3, par4); + case 3: + return this.getIntsSpecial(par1, par2, par3, par4); + } + } + + private int[] getIntsCoolWarm(int p_151626_1_, int p_151626_2_, int p_151626_3_, int p_151626_4_) + { + int i1 = p_151626_1_ - 1; + int j1 = p_151626_2_ - 1; + int k1 = 1 + p_151626_3_ + 1; + int l1 = 1 + p_151626_4_ + 1; + int[] aint = this.parent.getInts(i1, j1, k1, l1); + int[] aint1 = IntCache.getIntCache(p_151626_3_ * p_151626_4_); + + for (int i2 = 0; i2 < p_151626_4_; ++i2) + { + for (int j2 = 0; j2 < p_151626_3_; ++j2) + { + this.initChunkSeed((long)(j2 + p_151626_1_), (long)(i2 + p_151626_2_)); + int k2 = aint[j2 + 1 + (i2 + 1) * k1]; + + if (k2 == 1) + { + int l2 = aint[j2 + 1 + (i2 + 1 - 1) * k1]; + int i3 = aint[j2 + 1 + 1 + (i2 + 1) * k1]; + int j3 = aint[j2 + 1 - 1 + (i2 + 1) * k1]; + int k3 = aint[j2 + 1 + (i2 + 1 + 1) * k1]; + boolean flag = l2 == 3 || i3 == 3 || j3 == 3 || k3 == 3; + boolean flag1 = l2 == 4 || i3 == 4 || j3 == 4 || k3 == 4; + + if (flag || flag1) + { + k2 = 2; + } + } + + aint1[j2 + i2 * p_151626_3_] = k2; + } + } + + return aint1; + } + + private int[] getIntsHeatIce(int p_151624_1_, int p_151624_2_, int p_151624_3_, int p_151624_4_) + { + int i1 = p_151624_1_ - 1; + int j1 = p_151624_2_ - 1; + int k1 = 1 + p_151624_3_ + 1; + int l1 = 1 + p_151624_4_ + 1; + int[] aint = this.parent.getInts(i1, j1, k1, l1); + int[] aint1 = IntCache.getIntCache(p_151624_3_ * p_151624_4_); + + for (int i2 = 0; i2 < p_151624_4_; ++i2) + { + for (int j2 = 0; j2 < p_151624_3_; ++j2) + { + int k2 = aint[j2 + 1 + (i2 + 1) * k1]; + + if (k2 == 4) + { + int l2 = aint[j2 + 1 + (i2 + 1 - 1) * k1]; + int i3 = aint[j2 + 1 + 1 + (i2 + 1) * k1]; + int j3 = aint[j2 + 1 - 1 + (i2 + 1) * k1]; + int k3 = aint[j2 + 1 + (i2 + 1 + 1) * k1]; + boolean flag = l2 == 2 || i3 == 2 || j3 == 2 || k3 == 2; + boolean flag1 = l2 == 1 || i3 == 1 || j3 == 1 || k3 == 1; + + if (flag1 || flag) + { + k2 = 3; + } + } + + aint1[j2 + i2 * p_151624_3_] = k2; + } + } + + return aint1; + } + + private int[] getIntsSpecial(int p_151625_1_, int p_151625_2_, int p_151625_3_, int p_151625_4_) + { + int[] aint = this.parent.getInts(p_151625_1_, p_151625_2_, p_151625_3_, p_151625_4_); + int[] aint1 = IntCache.getIntCache(p_151625_3_ * p_151625_4_); + + for (int i1 = 0; i1 < p_151625_4_; ++i1) + { + for (int j1 = 0; j1 < p_151625_3_; ++j1) + { + this.initChunkSeed((long)(j1 + p_151625_1_), (long)(i1 + p_151625_2_)); + int k1 = aint[j1 + i1 * p_151625_3_]; + + if (k1 != 0 && this.nextInt(13) == 0) + { + k1 |= 1 + this.nextInt(15) << 8 & 3840; + } + + aint1[j1 + i1 * p_151625_3_] = k1; + } + } + + return aint1; + } + + public static enum Mode + { + COOL_WARM, + HEAT_ICE, + SPECIAL; + + private static final String __OBFID = "CL_00000549"; + } + + static final class SwitchMode + { + static final int[] field_151642_a = new int[GenLayerEdge.Mode.values().length]; + private static final String __OBFID = "CL_00000548"; + + static + { + try + { + field_151642_a[GenLayerEdge.Mode.COOL_WARM.ordinal()] = 1; + } + catch (NoSuchFieldError var3) + { + ; + } + + try + { + field_151642_a[GenLayerEdge.Mode.HEAT_ICE.ordinal()] = 2; + } + catch (NoSuchFieldError var2) + { + ; + } + + try + { + field_151642_a[GenLayerEdge.Mode.SPECIAL.ordinal()] = 3; + } + catch (NoSuchFieldError var1) + { + ; + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/layer/GenLayerFuzzyZoom.java b/src/main/java/net/minecraft/world/gen/layer/GenLayerFuzzyZoom.java new file mode 100644 index 0000000..b817883 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/layer/GenLayerFuzzyZoom.java @@ -0,0 +1,16 @@ +package net.minecraft.world.gen.layer; + +public class GenLayerFuzzyZoom extends GenLayerZoom +{ + private static final String __OBFID = "CL_00000556"; + + public GenLayerFuzzyZoom(long par1, GenLayer par3GenLayer) + { + super(par1, par3GenLayer); + } + + protected int selectModeOrRandom(int p_151617_1_, int p_151617_2_, int p_151617_3_, int p_151617_4_) + { + return this.selectRandom(new int[] {p_151617_1_, p_151617_2_, p_151617_3_, p_151617_4_}); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/layer/GenLayerHills.java b/src/main/java/net/minecraft/world/gen/layer/GenLayerHills.java new file mode 100644 index 0000000..2c527e8 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/layer/GenLayerHills.java @@ -0,0 +1,196 @@ +package net.minecraft.world.gen.layer; + +import net.minecraft.world.biome.BiomeGenBase; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class GenLayerHills extends GenLayer +{ + private static final Logger logger = LogManager.getLogger(); + private GenLayer field_151628_d; + private static final String __OBFID = "CL_00000563"; + + public GenLayerHills(long p_i45479_1_, GenLayer p_i45479_3_, GenLayer p_i45479_4_) + { + super(p_i45479_1_); + this.parent = p_i45479_3_; + this.field_151628_d = p_i45479_4_; + } + + public int[] getInts(int par1, int par2, int par3, int par4) + { + int[] aint = this.parent.getInts(par1 - 1, par2 - 1, par3 + 2, par4 + 2); + int[] aint1 = this.field_151628_d.getInts(par1 - 1, par2 - 1, par3 + 2, par4 + 2); + int[] aint2 = IntCache.getIntCache(par3 * par4); + + for (int i1 = 0; i1 < par4; ++i1) + { + for (int j1 = 0; j1 < par3; ++j1) + { + this.initChunkSeed((long)(j1 + par1), (long)(i1 + par2)); + int k1 = aint[j1 + 1 + (i1 + 1) * (par3 + 2)]; + int l1 = aint1[j1 + 1 + (i1 + 1) * (par3 + 2)]; + boolean flag = (l1 - 2) % 29 == 0; + + if (k1 > 255) + { + logger.debug("old! " + k1); + } + + if (k1 != 0 && l1 >= 2 && (l1 - 2) % 29 == 1 && k1 < 128) + { + if (BiomeGenBase.getBiome(k1 + 128) != null) + { + aint2[j1 + i1 * par3] = k1 + 128; + } + else + { + aint2[j1 + i1 * par3] = k1; + } + } + else if (this.nextInt(3) != 0 && !flag) + { + aint2[j1 + i1 * par3] = k1; + } + else + { + int i2 = k1; + int j2; + + if (k1 == BiomeGenBase.desert.biomeID) + { + i2 = BiomeGenBase.desertHills.biomeID; + } + else if (k1 == BiomeGenBase.forest.biomeID) + { + i2 = BiomeGenBase.forestHills.biomeID; + } + else if (k1 == BiomeGenBase.birchForest.biomeID) + { + i2 = BiomeGenBase.birchForestHills.biomeID; + } + else if (k1 == BiomeGenBase.roofedForest.biomeID) + { + i2 = BiomeGenBase.plains.biomeID; + } + else if (k1 == BiomeGenBase.taiga.biomeID) + { + i2 = BiomeGenBase.taigaHills.biomeID; + } + else if (k1 == BiomeGenBase.megaTaiga.biomeID) + { + i2 = BiomeGenBase.megaTaigaHills.biomeID; + } + else if (k1 == BiomeGenBase.coldTaiga.biomeID) + { + i2 = BiomeGenBase.coldTaigaHills.biomeID; + } + else if (k1 == BiomeGenBase.plains.biomeID) + { + if (this.nextInt(3) == 0) + { + i2 = BiomeGenBase.forestHills.biomeID; + } + else + { + i2 = BiomeGenBase.forest.biomeID; + } + } + else if (k1 == BiomeGenBase.icePlains.biomeID) + { + i2 = BiomeGenBase.iceMountains.biomeID; + } + else if (k1 == BiomeGenBase.jungle.biomeID) + { + i2 = BiomeGenBase.jungleHills.biomeID; + } + else if (k1 == BiomeGenBase.ocean.biomeID) + { + i2 = BiomeGenBase.deepOcean.biomeID; + } + else if (k1 == BiomeGenBase.extremeHills.biomeID) + { + i2 = BiomeGenBase.extremeHillsPlus.biomeID; + } + else if (k1 == BiomeGenBase.savanna.biomeID) + { + i2 = BiomeGenBase.savannaPlateau.biomeID; + } + else if (compareBiomesById(k1, BiomeGenBase.mesaPlateau_F.biomeID)) + { + i2 = BiomeGenBase.mesa.biomeID; + } + else if (k1 == BiomeGenBase.deepOcean.biomeID && this.nextInt(3) == 0) + { + j2 = this.nextInt(2); + + if (j2 == 0) + { + i2 = BiomeGenBase.plains.biomeID; + } + else + { + i2 = BiomeGenBase.forest.biomeID; + } + } + + if (flag && i2 != k1) + { + if (BiomeGenBase.getBiome(i2 + 128) != null) + { + i2 += 128; + } + else + { + i2 = k1; + } + } + + if (i2 == k1) + { + aint2[j1 + i1 * par3] = k1; + } + else + { + j2 = aint[j1 + 1 + (i1 + 1 - 1) * (par3 + 2)]; + int k2 = aint[j1 + 1 + 1 + (i1 + 1) * (par3 + 2)]; + int l2 = aint[j1 + 1 - 1 + (i1 + 1) * (par3 + 2)]; + int i3 = aint[j1 + 1 + (i1 + 1 + 1) * (par3 + 2)]; + int j3 = 0; + + if (compareBiomesById(j2, k1)) + { + ++j3; + } + + if (compareBiomesById(k2, k1)) + { + ++j3; + } + + if (compareBiomesById(l2, k1)) + { + ++j3; + } + + if (compareBiomesById(i3, k1)) + { + ++j3; + } + + if (j3 >= 3) + { + aint2[j1 + i1 * par3] = i2; + } + else + { + aint2[j1 + i1 * par3] = k1; + } + } + } + } + } + + return aint2; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/layer/GenLayerIsland.java b/src/main/java/net/minecraft/world/gen/layer/GenLayerIsland.java new file mode 100644 index 0000000..c3611f2 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/layer/GenLayerIsland.java @@ -0,0 +1,32 @@ +package net.minecraft.world.gen.layer; + +public class GenLayerIsland extends GenLayer +{ + private static final String __OBFID = "CL_00000558"; + + public GenLayerIsland(long par1) + { + super(par1); + } + + public int[] getInts(int par1, int par2, int par3, int par4) + { + int[] aint = IntCache.getIntCache(par3 * par4); + + for (int i1 = 0; i1 < par4; ++i1) + { + for (int j1 = 0; j1 < par3; ++j1) + { + this.initChunkSeed((long)(par1 + j1), (long)(par2 + i1)); + aint[j1 + i1 * par3] = this.nextInt(10) == 0 ? 1 : 0; + } + } + + if (par1 > -par3 && par1 <= 0 && par2 > -par4 && par2 <= 0) + { + aint[-par1 + -par2 * par3] = 1; + } + + return aint; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/layer/GenLayerRareBiome.java b/src/main/java/net/minecraft/world/gen/layer/GenLayerRareBiome.java new file mode 100644 index 0000000..d86a8ca --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/layer/GenLayerRareBiome.java @@ -0,0 +1,47 @@ +package net.minecraft.world.gen.layer; + +import net.minecraft.world.biome.BiomeGenBase; + +public class GenLayerRareBiome extends GenLayer +{ + private static final String __OBFID = "CL_00000562"; + + public GenLayerRareBiome(long p_i45478_1_, GenLayer p_i45478_3_) + { + super(p_i45478_1_); + this.parent = p_i45478_3_; + } + + public int[] getInts(int par1, int par2, int par3, int par4) + { + int[] aint = this.parent.getInts(par1 - 1, par2 - 1, par3 + 2, par4 + 2); + int[] aint1 = IntCache.getIntCache(par3 * par4); + + for (int i1 = 0; i1 < par4; ++i1) + { + for (int j1 = 0; j1 < par3; ++j1) + { + this.initChunkSeed((long)(j1 + par1), (long)(i1 + par2)); + int k1 = aint[j1 + 1 + (i1 + 1) * (par3 + 2)]; + + if (this.nextInt(57) == 0) + { + if (k1 == BiomeGenBase.plains.biomeID) + { + aint1[j1 + i1 * par3] = BiomeGenBase.plains.biomeID + 128; + } + else + { + aint1[j1 + i1 * par3] = k1; + } + } + else + { + aint1[j1 + i1 * par3] = k1; + } + } + } + + return aint1; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/layer/GenLayerRemoveTooMuchOcean.java b/src/main/java/net/minecraft/world/gen/layer/GenLayerRemoveTooMuchOcean.java new file mode 100644 index 0000000..ef75f49 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/layer/GenLayerRemoveTooMuchOcean.java @@ -0,0 +1,43 @@ +package net.minecraft.world.gen.layer; + +public class GenLayerRemoveTooMuchOcean extends GenLayer +{ + private static final String __OBFID = "CL_00000564"; + + public GenLayerRemoveTooMuchOcean(long p_i45480_1_, GenLayer p_i45480_3_) + { + super(p_i45480_1_); + this.parent = p_i45480_3_; + } + + public int[] getInts(int par1, int par2, int par3, int par4) + { + int i1 = par1 - 1; + int j1 = par2 - 1; + int k1 = par3 + 2; + int l1 = par4 + 2; + int[] aint = this.parent.getInts(i1, j1, k1, l1); + int[] aint1 = IntCache.getIntCache(par3 * par4); + + for (int i2 = 0; i2 < par4; ++i2) + { + for (int j2 = 0; j2 < par3; ++j2) + { + int k2 = aint[j2 + 1 + (i2 + 1 - 1) * (par3 + 2)]; + int l2 = aint[j2 + 1 + 1 + (i2 + 1) * (par3 + 2)]; + int i3 = aint[j2 + 1 - 1 + (i2 + 1) * (par3 + 2)]; + int j3 = aint[j2 + 1 + (i2 + 1 + 1) * (par3 + 2)]; + int k3 = aint[j2 + 1 + (i2 + 1) * k1]; + aint1[j2 + i2 * par3] = k3; + this.initChunkSeed((long)(j2 + par1), (long)(i2 + par2)); + + if (k3 == 0 && k2 == 0 && l2 == 0 && i3 == 0 && j3 == 0 && this.nextInt(2) == 0) + { + aint1[j2 + i2 * par3] = 1; + } + } + } + + return aint1; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/layer/GenLayerRiver.java b/src/main/java/net/minecraft/world/gen/layer/GenLayerRiver.java new file mode 100644 index 0000000..01f06aa --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/layer/GenLayerRiver.java @@ -0,0 +1,52 @@ +package net.minecraft.world.gen.layer; + +import net.minecraft.world.biome.BiomeGenBase; + +public class GenLayerRiver extends GenLayer +{ + private static final String __OBFID = "CL_00000566"; + + public GenLayerRiver(long par1, GenLayer par3GenLayer) + { + super(par1); + super.parent = par3GenLayer; + } + + public int[] getInts(int par1, int par2, int par3, int par4) + { + int i1 = par1 - 1; + int j1 = par2 - 1; + int k1 = par3 + 2; + int l1 = par4 + 2; + int[] aint = this.parent.getInts(i1, j1, k1, l1); + int[] aint1 = IntCache.getIntCache(par3 * par4); + + for (int i2 = 0; i2 < par4; ++i2) + { + for (int j2 = 0; j2 < par3; ++j2) + { + int k2 = this.func_151630_c(aint[j2 + 0 + (i2 + 1) * k1]); + int l2 = this.func_151630_c(aint[j2 + 2 + (i2 + 1) * k1]); + int i3 = this.func_151630_c(aint[j2 + 1 + (i2 + 0) * k1]); + int j3 = this.func_151630_c(aint[j2 + 1 + (i2 + 2) * k1]); + int k3 = this.func_151630_c(aint[j2 + 1 + (i2 + 1) * k1]); + + if (k3 == k2 && k3 == i3 && k3 == l2 && k3 == j3) + { + aint1[j2 + i2 * par3] = -1; + } + else + { + aint1[j2 + i2 * par3] = BiomeGenBase.river.biomeID; + } + } + } + + return aint1; + } + + private int func_151630_c(int p_151630_1_) + { + return p_151630_1_ >= 2 ? 2 + (p_151630_1_ & 1) : p_151630_1_; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/layer/GenLayerRiverInit.java b/src/main/java/net/minecraft/world/gen/layer/GenLayerRiverInit.java new file mode 100644 index 0000000..85c6a48 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/layer/GenLayerRiverInit.java @@ -0,0 +1,29 @@ +package net.minecraft.world.gen.layer; + +public class GenLayerRiverInit extends GenLayer +{ + private static final String __OBFID = "CL_00000565"; + + public GenLayerRiverInit(long par1, GenLayer par3GenLayer) + { + super(par1); + this.parent = par3GenLayer; + } + + public int[] getInts(int par1, int par2, int par3, int par4) + { + int[] aint = this.parent.getInts(par1, par2, par3, par4); + int[] aint1 = IntCache.getIntCache(par3 * par4); + + for (int i1 = 0; i1 < par4; ++i1) + { + for (int j1 = 0; j1 < par3; ++j1) + { + this.initChunkSeed((long)(j1 + par1), (long)(i1 + par2)); + aint1[j1 + i1 * par3] = aint[j1 + i1 * par3] > 0 ? this.nextInt(299999) + 2 : 0; + } + } + + return aint1; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/layer/GenLayerRiverMix.java b/src/main/java/net/minecraft/world/gen/layer/GenLayerRiverMix.java new file mode 100644 index 0000000..70435f0 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/layer/GenLayerRiverMix.java @@ -0,0 +1,63 @@ +package net.minecraft.world.gen.layer; + +import net.minecraft.world.biome.BiomeGenBase; + +public class GenLayerRiverMix extends GenLayer +{ + private GenLayer biomePatternGeneratorChain; + private GenLayer riverPatternGeneratorChain; + private static final String __OBFID = "CL_00000567"; + + public GenLayerRiverMix(long par1, GenLayer par3GenLayer, GenLayer par4GenLayer) + { + super(par1); + this.biomePatternGeneratorChain = par3GenLayer; + this.riverPatternGeneratorChain = par4GenLayer; + } + + public void initWorldGenSeed(long par1) + { + this.biomePatternGeneratorChain.initWorldGenSeed(par1); + this.riverPatternGeneratorChain.initWorldGenSeed(par1); + super.initWorldGenSeed(par1); + } + + public int[] getInts(int par1, int par2, int par3, int par4) + { + int[] aint = this.biomePatternGeneratorChain.getInts(par1, par2, par3, par4); + int[] aint1 = this.riverPatternGeneratorChain.getInts(par1, par2, par3, par4); + int[] aint2 = IntCache.getIntCache(par3 * par4); + + for (int i1 = 0; i1 < par3 * par4; ++i1) + { + if (aint[i1] != BiomeGenBase.ocean.biomeID && aint[i1] != BiomeGenBase.deepOcean.biomeID) + { + if (aint1[i1] == BiomeGenBase.river.biomeID) + { + if (aint[i1] == BiomeGenBase.icePlains.biomeID) + { + aint2[i1] = BiomeGenBase.frozenRiver.biomeID; + } + else if (aint[i1] != BiomeGenBase.mushroomIsland.biomeID && aint[i1] != BiomeGenBase.mushroomIslandShore.biomeID) + { + aint2[i1] = aint1[i1] & 255; + } + else + { + aint2[i1] = BiomeGenBase.mushroomIslandShore.biomeID; + } + } + else + { + aint2[i1] = aint[i1]; + } + } + else + { + aint2[i1] = aint[i1]; + } + } + + return aint2; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/layer/GenLayerShore.java b/src/main/java/net/minecraft/world/gen/layer/GenLayerShore.java new file mode 100644 index 0000000..2d7b4e5 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/layer/GenLayerShore.java @@ -0,0 +1,169 @@ +package net.minecraft.world.gen.layer; + +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.biome.BiomeGenJungle; +import net.minecraft.world.biome.BiomeGenMesa; + +public class GenLayerShore extends GenLayer +{ + private static final String __OBFID = "CL_00000568"; + + public GenLayerShore(long par1, GenLayer par3GenLayer) + { + super(par1); + this.parent = par3GenLayer; + } + + public int[] getInts(int par1, int par2, int par3, int par4) + { + int[] aint = this.parent.getInts(par1 - 1, par2 - 1, par3 + 2, par4 + 2); + int[] aint1 = IntCache.getIntCache(par3 * par4); + + for (int i1 = 0; i1 < par4; ++i1) + { + for (int j1 = 0; j1 < par3; ++j1) + { + this.initChunkSeed((long)(j1 + par1), (long)(i1 + par2)); + int k1 = aint[j1 + 1 + (i1 + 1) * (par3 + 2)]; + BiomeGenBase biomegenbase = BiomeGenBase.getBiome(k1); + int l1; + int i2; + int j2; + int k2; + + if (k1 == BiomeGenBase.mushroomIsland.biomeID) + { + l1 = aint[j1 + 1 + (i1 + 1 - 1) * (par3 + 2)]; + i2 = aint[j1 + 1 + 1 + (i1 + 1) * (par3 + 2)]; + j2 = aint[j1 + 1 - 1 + (i1 + 1) * (par3 + 2)]; + k2 = aint[j1 + 1 + (i1 + 1 + 1) * (par3 + 2)]; + + if (l1 != BiomeGenBase.ocean.biomeID && i2 != BiomeGenBase.ocean.biomeID && j2 != BiomeGenBase.ocean.biomeID && k2 != BiomeGenBase.ocean.biomeID) + { + aint1[j1 + i1 * par3] = k1; + } + else + { + aint1[j1 + i1 * par3] = BiomeGenBase.mushroomIslandShore.biomeID; + } + } + else if (biomegenbase != null && biomegenbase.getBiomeClass() == BiomeGenJungle.class) + { + l1 = aint[j1 + 1 + (i1 + 1 - 1) * (par3 + 2)]; + i2 = aint[j1 + 1 + 1 + (i1 + 1) * (par3 + 2)]; + j2 = aint[j1 + 1 - 1 + (i1 + 1) * (par3 + 2)]; + k2 = aint[j1 + 1 + (i1 + 1 + 1) * (par3 + 2)]; + + if (this.func_151631_c(l1) && this.func_151631_c(i2) && this.func_151631_c(j2) && this.func_151631_c(k2)) + { + if (!isBiomeOceanic(l1) && !isBiomeOceanic(i2) && !isBiomeOceanic(j2) && !isBiomeOceanic(k2)) + { + aint1[j1 + i1 * par3] = k1; + } + else + { + aint1[j1 + i1 * par3] = BiomeGenBase.beach.biomeID; + } + } + else + { + aint1[j1 + i1 * par3] = BiomeGenBase.jungleEdge.biomeID; + } + } + else if (k1 != BiomeGenBase.extremeHills.biomeID && k1 != BiomeGenBase.extremeHillsPlus.biomeID && k1 != BiomeGenBase.extremeHillsEdge.biomeID) + { + if (biomegenbase != null && biomegenbase.func_150559_j()) + { + this.func_151632_a(aint, aint1, j1, i1, par3, k1, BiomeGenBase.coldBeach.biomeID); + } + else if (k1 != BiomeGenBase.mesa.biomeID && k1 != BiomeGenBase.mesaPlateau_F.biomeID) + { + if (k1 != BiomeGenBase.ocean.biomeID && k1 != BiomeGenBase.deepOcean.biomeID && k1 != BiomeGenBase.river.biomeID && k1 != BiomeGenBase.swampland.biomeID) + { + l1 = aint[j1 + 1 + (i1 + 1 - 1) * (par3 + 2)]; + i2 = aint[j1 + 1 + 1 + (i1 + 1) * (par3 + 2)]; + j2 = aint[j1 + 1 - 1 + (i1 + 1) * (par3 + 2)]; + k2 = aint[j1 + 1 + (i1 + 1 + 1) * (par3 + 2)]; + + if (!isBiomeOceanic(l1) && !isBiomeOceanic(i2) && !isBiomeOceanic(j2) && !isBiomeOceanic(k2)) + { + aint1[j1 + i1 * par3] = k1; + } + else + { + aint1[j1 + i1 * par3] = BiomeGenBase.beach.biomeID; + } + } + else + { + aint1[j1 + i1 * par3] = k1; + } + } + else + { + l1 = aint[j1 + 1 + (i1 + 1 - 1) * (par3 + 2)]; + i2 = aint[j1 + 1 + 1 + (i1 + 1) * (par3 + 2)]; + j2 = aint[j1 + 1 - 1 + (i1 + 1) * (par3 + 2)]; + k2 = aint[j1 + 1 + (i1 + 1 + 1) * (par3 + 2)]; + + if (!isBiomeOceanic(l1) && !isBiomeOceanic(i2) && !isBiomeOceanic(j2) && !isBiomeOceanic(k2)) + { + if (this.func_151633_d(l1) && this.func_151633_d(i2) && this.func_151633_d(j2) && this.func_151633_d(k2)) + { + aint1[j1 + i1 * par3] = k1; + } + else + { + aint1[j1 + i1 * par3] = BiomeGenBase.desert.biomeID; + } + } + else + { + aint1[j1 + i1 * par3] = k1; + } + } + } + else + { + this.func_151632_a(aint, aint1, j1, i1, par3, k1, BiomeGenBase.stoneBeach.biomeID); + } + } + } + + return aint1; + } + + private void func_151632_a(int[] p_151632_1_, int[] p_151632_2_, int p_151632_3_, int p_151632_4_, int p_151632_5_, int p_151632_6_, int p_151632_7_) + { + if (isBiomeOceanic(p_151632_6_)) + { + p_151632_2_[p_151632_3_ + p_151632_4_ * p_151632_5_] = p_151632_6_; + } + else + { + int j1 = p_151632_1_[p_151632_3_ + 1 + (p_151632_4_ + 1 - 1) * (p_151632_5_ + 2)]; + int k1 = p_151632_1_[p_151632_3_ + 1 + 1 + (p_151632_4_ + 1) * (p_151632_5_ + 2)]; + int l1 = p_151632_1_[p_151632_3_ + 1 - 1 + (p_151632_4_ + 1) * (p_151632_5_ + 2)]; + int i2 = p_151632_1_[p_151632_3_ + 1 + (p_151632_4_ + 1 + 1) * (p_151632_5_ + 2)]; + + if (!isBiomeOceanic(j1) && !isBiomeOceanic(k1) && !isBiomeOceanic(l1) && !isBiomeOceanic(i2)) + { + p_151632_2_[p_151632_3_ + p_151632_4_ * p_151632_5_] = p_151632_6_; + } + else + { + p_151632_2_[p_151632_3_ + p_151632_4_ * p_151632_5_] = p_151632_7_; + } + } + } + + private boolean func_151631_c(int p_151631_1_) + { + return BiomeGenBase.getBiome(p_151631_1_) != null && BiomeGenBase.getBiome(p_151631_1_).getBiomeClass() == BiomeGenJungle.class ? true : p_151631_1_ == BiomeGenBase.jungleEdge.biomeID || p_151631_1_ == BiomeGenBase.jungle.biomeID || p_151631_1_ == BiomeGenBase.jungleHills.biomeID || p_151631_1_ == BiomeGenBase.forest.biomeID || p_151631_1_ == BiomeGenBase.taiga.biomeID || isBiomeOceanic(p_151631_1_); + } + + private boolean func_151633_d(int p_151633_1_) + { + return BiomeGenBase.getBiome(p_151633_1_) != null && BiomeGenBase.getBiome(p_151633_1_) instanceof BiomeGenMesa; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/layer/GenLayerSmooth.java b/src/main/java/net/minecraft/world/gen/layer/GenLayerSmooth.java new file mode 100644 index 0000000..03b01e3 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/layer/GenLayerSmooth.java @@ -0,0 +1,64 @@ +package net.minecraft.world.gen.layer; + +public class GenLayerSmooth extends GenLayer +{ + private static final String __OBFID = "CL_00000569"; + + public GenLayerSmooth(long par1, GenLayer par3GenLayer) + { + super(par1); + super.parent = par3GenLayer; + } + + public int[] getInts(int par1, int par2, int par3, int par4) + { + int i1 = par1 - 1; + int j1 = par2 - 1; + int k1 = par3 + 2; + int l1 = par4 + 2; + int[] aint = this.parent.getInts(i1, j1, k1, l1); + int[] aint1 = IntCache.getIntCache(par3 * par4); + + for (int i2 = 0; i2 < par4; ++i2) + { + for (int j2 = 0; j2 < par3; ++j2) + { + int k2 = aint[j2 + 0 + (i2 + 1) * k1]; + int l2 = aint[j2 + 2 + (i2 + 1) * k1]; + int i3 = aint[j2 + 1 + (i2 + 0) * k1]; + int j3 = aint[j2 + 1 + (i2 + 2) * k1]; + int k3 = aint[j2 + 1 + (i2 + 1) * k1]; + + if (k2 == l2 && i3 == j3) + { + this.initChunkSeed((long)(j2 + par1), (long)(i2 + par2)); + + if (this.nextInt(2) == 0) + { + k3 = k2; + } + else + { + k3 = i3; + } + } + else + { + if (k2 == l2) + { + k3 = k2; + } + + if (i3 == j3) + { + k3 = i3; + } + } + + aint1[j2 + i2 * par3] = k3; + } + } + + return aint1; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/layer/GenLayerVoronoiZoom.java b/src/main/java/net/minecraft/world/gen/layer/GenLayerVoronoiZoom.java new file mode 100644 index 0000000..98164a6 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/layer/GenLayerVoronoiZoom.java @@ -0,0 +1,94 @@ +package net.minecraft.world.gen.layer; + +public class GenLayerVoronoiZoom extends GenLayer +{ + private static final String __OBFID = "CL_00000571"; + + public GenLayerVoronoiZoom(long par1, GenLayer par3GenLayer) + { + super(par1); + super.parent = par3GenLayer; + } + + public int[] getInts(int par1, int par2, int par3, int par4) + { + par1 -= 2; + par2 -= 2; + int i1 = par1 >> 2; + int j1 = par2 >> 2; + int k1 = (par3 >> 2) + 2; + int l1 = (par4 >> 2) + 2; + int[] aint = this.parent.getInts(i1, j1, k1, l1); + int i2 = k1 - 1 << 2; + int j2 = l1 - 1 << 2; + int[] aint1 = IntCache.getIntCache(i2 * j2); + int l2; + + for (int k2 = 0; k2 < l1 - 1; ++k2) + { + l2 = 0; + int i3 = aint[l2 + 0 + (k2 + 0) * k1]; + + for (int j3 = aint[l2 + 0 + (k2 + 1) * k1]; l2 < k1 - 1; ++l2) + { + double d0 = 3.6D; + this.initChunkSeed((long)(l2 + i1 << 2), (long)(k2 + j1 << 2)); + double d1 = ((double)this.nextInt(1024) / 1024.0D - 0.5D) * 3.6D; + double d2 = ((double)this.nextInt(1024) / 1024.0D - 0.5D) * 3.6D; + this.initChunkSeed((long)(l2 + i1 + 1 << 2), (long)(k2 + j1 << 2)); + double d3 = ((double)this.nextInt(1024) / 1024.0D - 0.5D) * 3.6D + 4.0D; + double d4 = ((double)this.nextInt(1024) / 1024.0D - 0.5D) * 3.6D; + this.initChunkSeed((long)(l2 + i1 << 2), (long)(k2 + j1 + 1 << 2)); + double d5 = ((double)this.nextInt(1024) / 1024.0D - 0.5D) * 3.6D; + double d6 = ((double)this.nextInt(1024) / 1024.0D - 0.5D) * 3.6D + 4.0D; + this.initChunkSeed((long)(l2 + i1 + 1 << 2), (long)(k2 + j1 + 1 << 2)); + double d7 = ((double)this.nextInt(1024) / 1024.0D - 0.5D) * 3.6D + 4.0D; + double d8 = ((double)this.nextInt(1024) / 1024.0D - 0.5D) * 3.6D + 4.0D; + int k3 = aint[l2 + 1 + (k2 + 0) * k1] & 255; + int l3 = aint[l2 + 1 + (k2 + 1) * k1] & 255; + + for (int i4 = 0; i4 < 4; ++i4) + { + int j4 = ((k2 << 2) + i4) * i2 + (l2 << 2); + + for (int k4 = 0; k4 < 4; ++k4) + { + double d9 = ((double)i4 - d2) * ((double)i4 - d2) + ((double)k4 - d1) * ((double)k4 - d1); + double d10 = ((double)i4 - d4) * ((double)i4 - d4) + ((double)k4 - d3) * ((double)k4 - d3); + double d11 = ((double)i4 - d6) * ((double)i4 - d6) + ((double)k4 - d5) * ((double)k4 - d5); + double d12 = ((double)i4 - d8) * ((double)i4 - d8) + ((double)k4 - d7) * ((double)k4 - d7); + + if (d9 < d10 && d9 < d11 && d9 < d12) + { + aint1[j4++] = i3; + } + else if (d10 < d9 && d10 < d11 && d10 < d12) + { + aint1[j4++] = k3; + } + else if (d11 < d9 && d11 < d10 && d11 < d12) + { + aint1[j4++] = j3; + } + else + { + aint1[j4++] = l3; + } + } + } + + i3 = k3; + j3 = l3; + } + } + + int[] aint2 = IntCache.getIntCache(par3 * par4); + + for (l2 = 0; l2 < par4; ++l2) + { + System.arraycopy(aint1, (l2 + (par2 & 3)) * i2 + (par1 & 3), aint2, l2 * par3, par3); + } + + return aint2; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/layer/GenLayerZoom.java b/src/main/java/net/minecraft/world/gen/layer/GenLayerZoom.java new file mode 100644 index 0000000..b0e555a --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/layer/GenLayerZoom.java @@ -0,0 +1,66 @@ +package net.minecraft.world.gen.layer; + +public class GenLayerZoom extends GenLayer +{ + private static final String __OBFID = "CL_00000572"; + + public GenLayerZoom(long par1, GenLayer par3GenLayer) + { + super(par1); + super.parent = par3GenLayer; + } + + public int[] getInts(int par1, int par2, int par3, int par4) + { + int i1 = par1 >> 1; + int j1 = par2 >> 1; + int k1 = (par3 >> 1) + 2; + int l1 = (par4 >> 1) + 2; + int[] aint = this.parent.getInts(i1, j1, k1, l1); + int i2 = k1 - 1 << 1; + int j2 = l1 - 1 << 1; + int[] aint1 = IntCache.getIntCache(i2 * j2); + int l2; + + for (int k2 = 0; k2 < l1 - 1; ++k2) + { + l2 = (k2 << 1) * i2; + int i3 = 0; + int j3 = aint[i3 + 0 + (k2 + 0) * k1]; + + for (int k3 = aint[i3 + 0 + (k2 + 1) * k1]; i3 < k1 - 1; ++i3) + { + this.initChunkSeed((long)(i3 + i1 << 1), (long)(k2 + j1 << 1)); + int l3 = aint[i3 + 1 + (k2 + 0) * k1]; + int i4 = aint[i3 + 1 + (k2 + 1) * k1]; + aint1[l2] = j3; + aint1[l2++ + i2] = this.selectRandom(new int[] {j3, k3}); + aint1[l2] = this.selectRandom(new int[] {j3, l3}); + aint1[l2++ + i2] = this.selectModeOrRandom(j3, l3, k3, i4); + j3 = l3; + k3 = i4; + } + } + + int[] aint2 = IntCache.getIntCache(par3 * par4); + + for (l2 = 0; l2 < par4; ++l2) + { + System.arraycopy(aint1, (l2 + (par2 & 1)) * i2 + (par1 & 1), aint2, l2 * par3, par3); + } + + return aint2; + } + + public static GenLayer magnify(long par0, GenLayer par2GenLayer, int par3) + { + Object object = par2GenLayer; + + for (int k = 0; k < par3; ++k) + { + object = new GenLayerZoom(par0 + (long)k, (GenLayer)object); + } + + return (GenLayer)object; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/layer/IntCache.java b/src/main/java/net/minecraft/world/gen/layer/IntCache.java new file mode 100644 index 0000000..f459fe7 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/layer/IntCache.java @@ -0,0 +1,79 @@ +package net.minecraft.world.gen.layer; + +import java.util.ArrayList; +import java.util.List; + +public class IntCache +{ + private static int intCacheSize = 256; + private static List freeSmallArrays = new ArrayList(); + private static List inUseSmallArrays = new ArrayList(); + private static List freeLargeArrays = new ArrayList(); + private static List inUseLargeArrays = new ArrayList(); + private static final String __OBFID = "CL_00000557"; + + public static synchronized int[] getIntCache(int par0) + { + int[] aint; + + if (par0 <= 256) + { + if (freeSmallArrays.isEmpty()) + { + aint = new int[256]; + inUseSmallArrays.add(aint); + return aint; + } + else + { + aint = (int[])freeSmallArrays.remove(freeSmallArrays.size() - 1); + inUseSmallArrays.add(aint); + return aint; + } + } + else if (par0 > intCacheSize) + { + intCacheSize = par0; + freeLargeArrays.clear(); + inUseLargeArrays.clear(); + aint = new int[intCacheSize]; + inUseLargeArrays.add(aint); + return aint; + } + else if (freeLargeArrays.isEmpty()) + { + aint = new int[intCacheSize]; + inUseLargeArrays.add(aint); + return aint; + } + else + { + aint = (int[])freeLargeArrays.remove(freeLargeArrays.size() - 1); + inUseLargeArrays.add(aint); + return aint; + } + } + + public static synchronized void resetIntCache() + { + if (!freeLargeArrays.isEmpty()) + { + freeLargeArrays.remove(freeLargeArrays.size() - 1); + } + + if (!freeSmallArrays.isEmpty()) + { + freeSmallArrays.remove(freeSmallArrays.size() - 1); + } + + freeLargeArrays.addAll(inUseLargeArrays); + freeSmallArrays.addAll(inUseSmallArrays); + inUseLargeArrays.clear(); + inUseSmallArrays.clear(); + } + + public static synchronized String getCacheSizes() + { + return "cache: " + freeLargeArrays.size() + ", tcache: " + freeSmallArrays.size() + ", allocated: " + inUseLargeArrays.size() + ", tallocated: " + inUseSmallArrays.size(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/structure/ComponentScatteredFeaturePieces.java b/src/main/java/net/minecraft/world/gen/structure/ComponentScatteredFeaturePieces.java new file mode 100644 index 0000000..9ffa81b --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/structure/ComponentScatteredFeaturePieces.java @@ -0,0 +1,701 @@ +package net.minecraft.world.gen.structure; + +import java.util.Random; +import net.minecraft.block.BlockLever; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.entity.monster.EntityWitch; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.Direction; +import net.minecraft.util.WeightedRandomChestContent; +import net.minecraft.world.World; + +import net.minecraftforge.common.ChestGenHooks; +import static net.minecraftforge.common.ChestGenHooks.*; + +public class ComponentScatteredFeaturePieces +{ + private static final String __OBFID = "CL_00000473"; + + public static void registerScatteredFeaturePieces() + { + MapGenStructureIO.func_143031_a(ComponentScatteredFeaturePieces.DesertPyramid.class, "TeDP"); + MapGenStructureIO.func_143031_a(ComponentScatteredFeaturePieces.JunglePyramid.class, "TeJP"); + MapGenStructureIO.func_143031_a(ComponentScatteredFeaturePieces.SwampHut.class, "TeSH"); + } + + public static class DesertPyramid extends ComponentScatteredFeaturePieces.Feature + { + private boolean[] field_74940_h = new boolean[4]; + public static final WeightedRandomChestContent[] itemsToGenerateInTemple = new WeightedRandomChestContent[] {new WeightedRandomChestContent(Items.diamond, 0, 1, 3, 3), new WeightedRandomChestContent(Items.iron_ingot, 0, 1, 5, 10), new WeightedRandomChestContent(Items.gold_ingot, 0, 2, 7, 15), new WeightedRandomChestContent(Items.emerald, 0, 1, 3, 2), new WeightedRandomChestContent(Items.bone, 0, 4, 6, 20), new WeightedRandomChestContent(Items.rotten_flesh, 0, 3, 7, 16), new WeightedRandomChestContent(Items.saddle, 0, 1, 1, 3), new WeightedRandomChestContent(Items.iron_horse_armor, 0, 1, 1, 1), new WeightedRandomChestContent(Items.golden_horse_armor, 0, 1, 1, 1), new WeightedRandomChestContent(Items.diamond_horse_armor, 0, 1, 1, 1)}; + private static final String __OBFID = "CL_00000476"; + + public DesertPyramid() {} + + public DesertPyramid(Random par1Random, int par2, int par3) + { + super(par1Random, par2, 64, par3, 21, 15, 21); + } + + protected void func_143012_a(NBTTagCompound par1NBTTagCompound) + { + super.func_143012_a(par1NBTTagCompound); + par1NBTTagCompound.setBoolean("hasPlacedChest0", this.field_74940_h[0]); + par1NBTTagCompound.setBoolean("hasPlacedChest1", this.field_74940_h[1]); + par1NBTTagCompound.setBoolean("hasPlacedChest2", this.field_74940_h[2]); + par1NBTTagCompound.setBoolean("hasPlacedChest3", this.field_74940_h[3]); + } + + protected void func_143011_b(NBTTagCompound par1NBTTagCompound) + { + super.func_143011_b(par1NBTTagCompound); + this.field_74940_h[0] = par1NBTTagCompound.getBoolean("hasPlacedChest0"); + this.field_74940_h[1] = par1NBTTagCompound.getBoolean("hasPlacedChest1"); + this.field_74940_h[2] = par1NBTTagCompound.getBoolean("hasPlacedChest2"); + this.field_74940_h[3] = par1NBTTagCompound.getBoolean("hasPlacedChest3"); + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, -4, 0, this.scatteredFeatureSizeX - 1, 0, this.scatteredFeatureSizeZ - 1, Blocks.sandstone, Blocks.sandstone, false); + int i; + + for (i = 1; i <= 9; ++i) + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, i, i, i, this.scatteredFeatureSizeX - 1 - i, i, this.scatteredFeatureSizeZ - 1 - i, Blocks.sandstone, Blocks.sandstone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, i + 1, i, i + 1, this.scatteredFeatureSizeX - 2 - i, i, this.scatteredFeatureSizeZ - 2 - i, Blocks.air, Blocks.air, false); + } + + int j; + + for (i = 0; i < this.scatteredFeatureSizeX; ++i) + { + for (j = 0; j < this.scatteredFeatureSizeZ; ++j) + { + byte b0 = -5; + this.func_151554_b(par1World, Blocks.sandstone, 0, i, b0, j, par3StructureBoundingBox); + } + } + + i = this.getMetadataWithOffset(Blocks.sandstone_stairs, 3); + j = this.getMetadataWithOffset(Blocks.sandstone_stairs, 2); + int k1 = this.getMetadataWithOffset(Blocks.sandstone_stairs, 0); + int k = this.getMetadataWithOffset(Blocks.sandstone_stairs, 1); + byte b1 = 1; + byte b2 = 11; + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 0, 0, 4, 9, 4, Blocks.sandstone, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 10, 1, 3, 10, 3, Blocks.sandstone, Blocks.sandstone, false); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone_stairs, i, 2, 10, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone_stairs, j, 2, 10, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone_stairs, k1, 0, 10, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone_stairs, k, 4, 10, 2, par3StructureBoundingBox); + this.fillWithBlocks(par1World, par3StructureBoundingBox, this.scatteredFeatureSizeX - 5, 0, 0, this.scatteredFeatureSizeX - 1, 9, 4, Blocks.sandstone, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, this.scatteredFeatureSizeX - 4, 10, 1, this.scatteredFeatureSizeX - 2, 10, 3, Blocks.sandstone, Blocks.sandstone, false); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone_stairs, i, this.scatteredFeatureSizeX - 3, 10, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone_stairs, j, this.scatteredFeatureSizeX - 3, 10, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone_stairs, k1, this.scatteredFeatureSizeX - 5, 10, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone_stairs, k, this.scatteredFeatureSizeX - 1, 10, 2, par3StructureBoundingBox); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 8, 0, 0, 12, 4, 4, Blocks.sandstone, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 9, 1, 0, 11, 3, 4, Blocks.air, Blocks.air, false); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone, 2, 9, 1, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone, 2, 9, 2, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone, 2, 9, 3, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone, 2, 10, 3, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone, 2, 11, 3, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone, 2, 11, 2, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone, 2, 11, 1, 1, par3StructureBoundingBox); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 1, 1, 8, 3, 3, Blocks.sandstone, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 1, 2, 8, 2, 2, Blocks.air, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 12, 1, 1, 16, 3, 3, Blocks.sandstone, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 12, 1, 2, 16, 2, 2, Blocks.air, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 5, 4, 5, this.scatteredFeatureSizeX - 6, 4, this.scatteredFeatureSizeZ - 6, Blocks.sandstone, Blocks.sandstone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 9, 4, 9, 11, 4, 11, Blocks.air, Blocks.air, false); + this.fillWithMetadataBlocks(par1World, par3StructureBoundingBox, 8, 1, 8, 8, 3, 8, Blocks.sandstone, 2, Blocks.sandstone, 2, false); + this.fillWithMetadataBlocks(par1World, par3StructureBoundingBox, 12, 1, 8, 12, 3, 8, Blocks.sandstone, 2, Blocks.sandstone, 2, false); + this.fillWithMetadataBlocks(par1World, par3StructureBoundingBox, 8, 1, 12, 8, 3, 12, Blocks.sandstone, 2, Blocks.sandstone, 2, false); + this.fillWithMetadataBlocks(par1World, par3StructureBoundingBox, 12, 1, 12, 12, 3, 12, Blocks.sandstone, 2, Blocks.sandstone, 2, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 1, 5, 4, 4, 11, Blocks.sandstone, Blocks.sandstone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, this.scatteredFeatureSizeX - 5, 1, 5, this.scatteredFeatureSizeX - 2, 4, 11, Blocks.sandstone, Blocks.sandstone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 6, 7, 9, 6, 7, 11, Blocks.sandstone, Blocks.sandstone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, this.scatteredFeatureSizeX - 7, 7, 9, this.scatteredFeatureSizeX - 7, 7, 11, Blocks.sandstone, Blocks.sandstone, false); + this.fillWithMetadataBlocks(par1World, par3StructureBoundingBox, 5, 5, 9, 5, 7, 11, Blocks.sandstone, 2, Blocks.sandstone, 2, false); + this.fillWithMetadataBlocks(par1World, par3StructureBoundingBox, this.scatteredFeatureSizeX - 6, 5, 9, this.scatteredFeatureSizeX - 6, 7, 11, Blocks.sandstone, 2, Blocks.sandstone, 2, false); + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, 5, 5, 10, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, 5, 6, 10, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, 6, 6, 10, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, this.scatteredFeatureSizeX - 6, 5, 10, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, this.scatteredFeatureSizeX - 6, 6, 10, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, this.scatteredFeatureSizeX - 7, 6, 10, par3StructureBoundingBox); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 2, 4, 4, 2, 6, 4, Blocks.air, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, this.scatteredFeatureSizeX - 3, 4, 4, this.scatteredFeatureSizeX - 3, 6, 4, Blocks.air, Blocks.air, false); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone_stairs, i, 2, 4, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone_stairs, i, 2, 3, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone_stairs, i, this.scatteredFeatureSizeX - 3, 4, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone_stairs, i, this.scatteredFeatureSizeX - 3, 3, 4, par3StructureBoundingBox); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 1, 3, 2, 2, 3, Blocks.sandstone, Blocks.sandstone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, this.scatteredFeatureSizeX - 3, 1, 3, this.scatteredFeatureSizeX - 2, 2, 3, Blocks.sandstone, Blocks.sandstone, false); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone_stairs, 0, 1, 1, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone_stairs, 0, this.scatteredFeatureSizeX - 2, 1, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_slab, 1, 1, 2, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_slab, 1, this.scatteredFeatureSizeX - 2, 2, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone_stairs, k, 2, 1, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone_stairs, k1, this.scatteredFeatureSizeX - 3, 1, 2, par3StructureBoundingBox); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 3, 5, 4, 3, 18, Blocks.sandstone, Blocks.sandstone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, this.scatteredFeatureSizeX - 5, 3, 5, this.scatteredFeatureSizeX - 5, 3, 17, Blocks.sandstone, Blocks.sandstone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 3, 1, 5, 4, 2, 16, Blocks.air, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, this.scatteredFeatureSizeX - 6, 1, 5, this.scatteredFeatureSizeX - 5, 2, 16, Blocks.air, Blocks.air, false); + int l; + + for (l = 5; l <= 17; l += 2) + { + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone, 2, 4, 1, l, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone, 1, 4, 2, l, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone, 2, this.scatteredFeatureSizeX - 5, 1, l, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone, 1, this.scatteredFeatureSizeX - 5, 2, l, par3StructureBoundingBox); + } + + this.placeBlockAtCurrentPosition(par1World, Blocks.wool, b1, 10, 0, 7, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.wool, b1, 10, 0, 8, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.wool, b1, 9, 0, 9, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.wool, b1, 11, 0, 9, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.wool, b1, 8, 0, 10, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.wool, b1, 12, 0, 10, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.wool, b1, 7, 0, 10, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.wool, b1, 13, 0, 10, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.wool, b1, 9, 0, 11, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.wool, b1, 11, 0, 11, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.wool, b1, 10, 0, 12, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.wool, b1, 10, 0, 13, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.wool, b2, 10, 0, 10, par3StructureBoundingBox); + + for (l = 0; l <= this.scatteredFeatureSizeX - 1; l += this.scatteredFeatureSizeX - 1) + { + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone, 2, l, 2, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.wool, b1, l, 2, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone, 2, l, 2, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone, 2, l, 3, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.wool, b1, l, 3, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone, 2, l, 3, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.wool, b1, l, 4, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone, 1, l, 4, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.wool, b1, l, 4, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone, 2, l, 5, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.wool, b1, l, 5, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone, 2, l, 5, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.wool, b1, l, 6, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone, 1, l, 6, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.wool, b1, l, 6, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.wool, b1, l, 7, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.wool, b1, l, 7, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.wool, b1, l, 7, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone, 2, l, 8, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone, 2, l, 8, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone, 2, l, 8, 3, par3StructureBoundingBox); + } + + for (l = 2; l <= this.scatteredFeatureSizeX - 3; l += this.scatteredFeatureSizeX - 3 - 2) + { + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone, 2, l - 1, 2, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.wool, b1, l, 2, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone, 2, l + 1, 2, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone, 2, l - 1, 3, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.wool, b1, l, 3, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone, 2, l + 1, 3, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.wool, b1, l - 1, 4, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone, 1, l, 4, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.wool, b1, l + 1, 4, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone, 2, l - 1, 5, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.wool, b1, l, 5, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone, 2, l + 1, 5, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.wool, b1, l - 1, 6, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone, 1, l, 6, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.wool, b1, l + 1, 6, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.wool, b1, l - 1, 7, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.wool, b1, l, 7, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.wool, b1, l + 1, 7, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone, 2, l - 1, 8, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone, 2, l, 8, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone, 2, l + 1, 8, 0, par3StructureBoundingBox); + } + + this.fillWithMetadataBlocks(par1World, par3StructureBoundingBox, 8, 4, 0, 12, 6, 0, Blocks.sandstone, 2, Blocks.sandstone, 2, false); + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, 8, 6, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, 12, 6, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.wool, b1, 9, 5, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone, 1, 10, 5, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.wool, b1, 11, 5, 0, par3StructureBoundingBox); + this.fillWithMetadataBlocks(par1World, par3StructureBoundingBox, 8, -14, 8, 12, -11, 12, Blocks.sandstone, 2, Blocks.sandstone, 2, false); + this.fillWithMetadataBlocks(par1World, par3StructureBoundingBox, 8, -10, 8, 12, -10, 12, Blocks.sandstone, 1, Blocks.sandstone, 1, false); + this.fillWithMetadataBlocks(par1World, par3StructureBoundingBox, 8, -9, 8, 12, -9, 12, Blocks.sandstone, 2, Blocks.sandstone, 2, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 8, -8, 8, 12, -1, 12, Blocks.sandstone, Blocks.sandstone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 9, -11, 9, 11, -1, 11, Blocks.air, Blocks.air, false); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_pressure_plate, 0, 10, -11, 10, par3StructureBoundingBox); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 9, -13, 9, 11, -13, 11, Blocks.tnt, Blocks.air, false); + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, 8, -11, 10, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, 8, -10, 10, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone, 1, 7, -10, 10, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone, 2, 7, -11, 10, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, 12, -11, 10, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, 12, -10, 10, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone, 1, 13, -10, 10, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone, 2, 13, -11, 10, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, 10, -11, 8, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, 10, -10, 8, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone, 1, 10, -10, 7, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone, 2, 10, -11, 7, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, 10, -11, 12, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, 10, -10, 12, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone, 1, 10, -10, 13, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sandstone, 2, 10, -11, 13, par3StructureBoundingBox); + + for (l = 0; l < 4; ++l) + { + if (!this.field_74940_h[l]) + { + int i1 = Direction.offsetX[l] * 2; + int j1 = Direction.offsetZ[l] * 2; + this.field_74940_h[l] = this.generateStructureChestContents(par1World, par3StructureBoundingBox, par2Random, 10 + i1, -11, 10 + j1, ChestGenHooks.getItems(PYRAMID_DESERT_CHEST, par2Random), ChestGenHooks.getCount(PYRAMID_DESERT_CHEST, par2Random)); + } + } + + return true; + } + } + + abstract static class Feature extends StructureComponent + { + protected int scatteredFeatureSizeX; + protected int scatteredFeatureSizeY; + protected int scatteredFeatureSizeZ; + protected int field_74936_d = -1; + private static final String __OBFID = "CL_00000479"; + + public Feature() {} + + protected Feature(Random par1Random, int par2, int par3, int par4, int par5, int par6, int par7) + { + super(0); + this.scatteredFeatureSizeX = par5; + this.scatteredFeatureSizeY = par6; + this.scatteredFeatureSizeZ = par7; + this.coordBaseMode = par1Random.nextInt(4); + + switch (this.coordBaseMode) + { + case 0: + case 2: + this.boundingBox = new StructureBoundingBox(par2, par3, par4, par2 + par5 - 1, par3 + par6 - 1, par4 + par7 - 1); + break; + default: + this.boundingBox = new StructureBoundingBox(par2, par3, par4, par2 + par7 - 1, par3 + par6 - 1, par4 + par5 - 1); + } + } + + protected void func_143012_a(NBTTagCompound par1NBTTagCompound) + { + par1NBTTagCompound.setInteger("Width", this.scatteredFeatureSizeX); + par1NBTTagCompound.setInteger("Height", this.scatteredFeatureSizeY); + par1NBTTagCompound.setInteger("Depth", this.scatteredFeatureSizeZ); + par1NBTTagCompound.setInteger("HPos", this.field_74936_d); + } + + protected void func_143011_b(NBTTagCompound par1NBTTagCompound) + { + this.scatteredFeatureSizeX = par1NBTTagCompound.getInteger("Width"); + this.scatteredFeatureSizeY = par1NBTTagCompound.getInteger("Height"); + this.scatteredFeatureSizeZ = par1NBTTagCompound.getInteger("Depth"); + this.field_74936_d = par1NBTTagCompound.getInteger("HPos"); + } + + protected boolean func_74935_a(World par1World, StructureBoundingBox par2StructureBoundingBox, int par3) + { + if (this.field_74936_d >= 0) + { + return true; + } + else + { + int j = 0; + int k = 0; + + for (int l = this.boundingBox.minZ; l <= this.boundingBox.maxZ; ++l) + { + for (int i1 = this.boundingBox.minX; i1 <= this.boundingBox.maxX; ++i1) + { + if (par2StructureBoundingBox.isVecInside(i1, 64, l)) + { + j += Math.max(par1World.getTopSolidOrLiquidBlock(i1, l), par1World.provider.getAverageGroundLevel()); + ++k; + } + } + } + + if (k == 0) + { + return false; + } + else + { + this.field_74936_d = j / k; + this.boundingBox.offset(0, this.field_74936_d - this.boundingBox.minY + par3, 0); + return true; + } + } + } + } + + public static class JunglePyramid extends ComponentScatteredFeaturePieces.Feature + { + private boolean field_74947_h; + private boolean field_74948_i; + private boolean field_74945_j; + private boolean field_74946_k; + public static final WeightedRandomChestContent[] junglePyramidsChestContents = new WeightedRandomChestContent[] {new WeightedRandomChestContent(Items.diamond, 0, 1, 3, 3), new WeightedRandomChestContent(Items.iron_ingot, 0, 1, 5, 10), new WeightedRandomChestContent(Items.gold_ingot, 0, 2, 7, 15), new WeightedRandomChestContent(Items.emerald, 0, 1, 3, 2), new WeightedRandomChestContent(Items.bone, 0, 4, 6, 20), new WeightedRandomChestContent(Items.rotten_flesh, 0, 3, 7, 16), new WeightedRandomChestContent(Items.saddle, 0, 1, 1, 3), new WeightedRandomChestContent(Items.iron_horse_armor, 0, 1, 1, 1), new WeightedRandomChestContent(Items.golden_horse_armor, 0, 1, 1, 1), new WeightedRandomChestContent(Items.diamond_horse_armor, 0, 1, 1, 1)}; + public static final WeightedRandomChestContent[] junglePyramidsDispenserContents = new WeightedRandomChestContent[] {new WeightedRandomChestContent(Items.arrow, 0, 2, 7, 30)}; + private static ComponentScatteredFeaturePieces.JunglePyramid.Stones junglePyramidsRandomScatteredStones = new ComponentScatteredFeaturePieces.JunglePyramid.Stones(null); + private static final String __OBFID = "CL_00000477"; + + public JunglePyramid() {} + + public JunglePyramid(Random par1Random, int par2, int par3) + { + super(par1Random, par2, 64, par3, 12, 10, 15); + } + + protected void func_143012_a(NBTTagCompound par1NBTTagCompound) + { + super.func_143012_a(par1NBTTagCompound); + par1NBTTagCompound.setBoolean("placedMainChest", this.field_74947_h); + par1NBTTagCompound.setBoolean("placedHiddenChest", this.field_74948_i); + par1NBTTagCompound.setBoolean("placedTrap1", this.field_74945_j); + par1NBTTagCompound.setBoolean("placedTrap2", this.field_74946_k); + } + + protected void func_143011_b(NBTTagCompound par1NBTTagCompound) + { + super.func_143011_b(par1NBTTagCompound); + this.field_74947_h = par1NBTTagCompound.getBoolean("placedMainChest"); + this.field_74948_i = par1NBTTagCompound.getBoolean("placedHiddenChest"); + this.field_74945_j = par1NBTTagCompound.getBoolean("placedTrap1"); + this.field_74946_k = par1NBTTagCompound.getBoolean("placedTrap2"); + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + if (!this.func_74935_a(par1World, par3StructureBoundingBox, 0)) + { + return false; + } + else + { + int i = this.getMetadataWithOffset(Blocks.stone_stairs, 3); + int j = this.getMetadataWithOffset(Blocks.stone_stairs, 2); + int k = this.getMetadataWithOffset(Blocks.stone_stairs, 0); + int l = this.getMetadataWithOffset(Blocks.stone_stairs, 1); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 0, -4, 0, this.scatteredFeatureSizeX - 1, 0, this.scatteredFeatureSizeZ - 1, false, par2Random, junglePyramidsRandomScatteredStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 2, 1, 2, 9, 2, 2, false, par2Random, junglePyramidsRandomScatteredStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 2, 1, 12, 9, 2, 12, false, par2Random, junglePyramidsRandomScatteredStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 2, 1, 3, 2, 2, 11, false, par2Random, junglePyramidsRandomScatteredStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 9, 1, 3, 9, 2, 11, false, par2Random, junglePyramidsRandomScatteredStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 1, 3, 1, 10, 6, 1, false, par2Random, junglePyramidsRandomScatteredStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 1, 3, 13, 10, 6, 13, false, par2Random, junglePyramidsRandomScatteredStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 1, 3, 2, 1, 6, 12, false, par2Random, junglePyramidsRandomScatteredStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 10, 3, 2, 10, 6, 12, false, par2Random, junglePyramidsRandomScatteredStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 2, 3, 2, 9, 3, 12, false, par2Random, junglePyramidsRandomScatteredStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 2, 6, 2, 9, 6, 12, false, par2Random, junglePyramidsRandomScatteredStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 3, 7, 3, 8, 7, 11, false, par2Random, junglePyramidsRandomScatteredStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 4, 8, 4, 7, 8, 10, false, par2Random, junglePyramidsRandomScatteredStones); + this.fillWithAir(par1World, par3StructureBoundingBox, 3, 1, 3, 8, 2, 11); + this.fillWithAir(par1World, par3StructureBoundingBox, 4, 3, 6, 7, 3, 9); + this.fillWithAir(par1World, par3StructureBoundingBox, 2, 4, 2, 9, 5, 12); + this.fillWithAir(par1World, par3StructureBoundingBox, 4, 6, 5, 7, 6, 9); + this.fillWithAir(par1World, par3StructureBoundingBox, 5, 7, 6, 6, 7, 8); + this.fillWithAir(par1World, par3StructureBoundingBox, 5, 1, 2, 6, 2, 2); + this.fillWithAir(par1World, par3StructureBoundingBox, 5, 2, 12, 6, 2, 12); + this.fillWithAir(par1World, par3StructureBoundingBox, 5, 5, 1, 6, 5, 1); + this.fillWithAir(par1World, par3StructureBoundingBox, 5, 5, 13, 6, 5, 13); + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, 1, 5, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, 10, 5, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, 1, 5, 9, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, 10, 5, 9, par3StructureBoundingBox); + int i1; + + for (i1 = 0; i1 <= 14; i1 += 14) + { + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 2, 4, i1, 2, 5, i1, false, par2Random, junglePyramidsRandomScatteredStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 4, 4, i1, 4, 5, i1, false, par2Random, junglePyramidsRandomScatteredStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 7, 4, i1, 7, 5, i1, false, par2Random, junglePyramidsRandomScatteredStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 9, 4, i1, 9, 5, i1, false, par2Random, junglePyramidsRandomScatteredStones); + } + + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 5, 6, 0, 6, 6, 0, false, par2Random, junglePyramidsRandomScatteredStones); + + for (i1 = 0; i1 <= 11; i1 += 11) + { + for (int j1 = 2; j1 <= 12; j1 += 2) + { + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, i1, 4, j1, i1, 5, j1, false, par2Random, junglePyramidsRandomScatteredStones); + } + + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, i1, 6, 5, i1, 6, 5, false, par2Random, junglePyramidsRandomScatteredStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, i1, 6, 9, i1, 6, 9, false, par2Random, junglePyramidsRandomScatteredStones); + } + + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 2, 7, 2, 2, 9, 2, false, par2Random, junglePyramidsRandomScatteredStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 9, 7, 2, 9, 9, 2, false, par2Random, junglePyramidsRandomScatteredStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 2, 7, 12, 2, 9, 12, false, par2Random, junglePyramidsRandomScatteredStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 9, 7, 12, 9, 9, 12, false, par2Random, junglePyramidsRandomScatteredStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 4, 9, 4, 4, 9, 4, false, par2Random, junglePyramidsRandomScatteredStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 7, 9, 4, 7, 9, 4, false, par2Random, junglePyramidsRandomScatteredStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 4, 9, 10, 4, 9, 10, false, par2Random, junglePyramidsRandomScatteredStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 7, 9, 10, 7, 9, 10, false, par2Random, junglePyramidsRandomScatteredStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 5, 9, 7, 6, 9, 7, false, par2Random, junglePyramidsRandomScatteredStones); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_stairs, i, 5, 9, 6, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_stairs, i, 6, 9, 6, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_stairs, j, 5, 9, 8, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_stairs, j, 6, 9, 8, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_stairs, i, 4, 0, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_stairs, i, 5, 0, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_stairs, i, 6, 0, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_stairs, i, 7, 0, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_stairs, i, 4, 1, 8, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_stairs, i, 4, 2, 9, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_stairs, i, 4, 3, 10, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_stairs, i, 7, 1, 8, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_stairs, i, 7, 2, 9, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_stairs, i, 7, 3, 10, par3StructureBoundingBox); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 4, 1, 9, 4, 1, 9, false, par2Random, junglePyramidsRandomScatteredStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 7, 1, 9, 7, 1, 9, false, par2Random, junglePyramidsRandomScatteredStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 4, 1, 10, 7, 2, 10, false, par2Random, junglePyramidsRandomScatteredStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 5, 4, 5, 6, 4, 5, false, par2Random, junglePyramidsRandomScatteredStones); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_stairs, k, 4, 4, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_stairs, l, 7, 4, 5, par3StructureBoundingBox); + + for (i1 = 0; i1 < 4; ++i1) + { + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_stairs, j, 5, 0 - i1, 6 + i1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_stairs, j, 6, 0 - i1, 6 + i1, par3StructureBoundingBox); + this.fillWithAir(par1World, par3StructureBoundingBox, 5, 0 - i1, 7 + i1, 6, 0 - i1, 9 + i1); + } + + this.fillWithAir(par1World, par3StructureBoundingBox, 1, -3, 12, 10, -1, 13); + this.fillWithAir(par1World, par3StructureBoundingBox, 1, -3, 1, 3, -1, 13); + this.fillWithAir(par1World, par3StructureBoundingBox, 1, -3, 1, 9, -1, 5); + + for (i1 = 1; i1 <= 13; i1 += 2) + { + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 1, -3, i1, 1, -2, i1, false, par2Random, junglePyramidsRandomScatteredStones); + } + + for (i1 = 2; i1 <= 12; i1 += 2) + { + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 1, -1, i1, 3, -1, i1, false, par2Random, junglePyramidsRandomScatteredStones); + } + + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 2, -2, 1, 5, -2, 1, false, par2Random, junglePyramidsRandomScatteredStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 7, -2, 1, 9, -2, 1, false, par2Random, junglePyramidsRandomScatteredStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 6, -3, 1, 6, -3, 1, false, par2Random, junglePyramidsRandomScatteredStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 6, -1, 1, 6, -1, 1, false, par2Random, junglePyramidsRandomScatteredStones); + this.placeBlockAtCurrentPosition(par1World, Blocks.tripwire_hook, this.getMetadataWithOffset(Blocks.tripwire_hook, 3) | 4, 1, -3, 8, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.tripwire_hook, this.getMetadataWithOffset(Blocks.tripwire_hook, 1) | 4, 4, -3, 8, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.tripwire, 4, 2, -3, 8, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.tripwire, 4, 3, -3, 8, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.redstone_wire, 0, 5, -3, 7, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.redstone_wire, 0, 5, -3, 6, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.redstone_wire, 0, 5, -3, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.redstone_wire, 0, 5, -3, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.redstone_wire, 0, 5, -3, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.redstone_wire, 0, 5, -3, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.redstone_wire, 0, 5, -3, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.redstone_wire, 0, 4, -3, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.mossy_cobblestone, 0, 3, -3, 1, par3StructureBoundingBox); + + ChestGenHooks dispenser = ChestGenHooks.getInfo(PYRAMID_JUNGLE_DISPENSER); + ChestGenHooks chest = ChestGenHooks.getInfo(PYRAMID_JUNGLE_CHEST); + + if (!this.field_74945_j) + { + this.field_74945_j = this.generateStructureDispenserContents(par1World, par3StructureBoundingBox, par2Random, 3, -2, 1, 2, dispenser.getItems(par2Random), dispenser.getCount(par2Random)); + } + + this.placeBlockAtCurrentPosition(par1World, Blocks.vine, 15, 3, -2, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.tripwire_hook, this.getMetadataWithOffset(Blocks.tripwire_hook, 2) | 4, 7, -3, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.tripwire_hook, this.getMetadataWithOffset(Blocks.tripwire_hook, 0) | 4, 7, -3, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.tripwire, 4, 7, -3, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.tripwire, 4, 7, -3, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.tripwire, 4, 7, -3, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.redstone_wire, 0, 8, -3, 6, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.redstone_wire, 0, 9, -3, 6, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.redstone_wire, 0, 9, -3, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.mossy_cobblestone, 0, 9, -3, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.redstone_wire, 0, 9, -2, 4, par3StructureBoundingBox); + + if (!this.field_74946_k) + { + this.field_74946_k = this.generateStructureDispenserContents(par1World, par3StructureBoundingBox, par2Random, 9, -2, 3, 4, dispenser.getItems(par2Random), dispenser.getCount(par2Random)); + } + + this.placeBlockAtCurrentPosition(par1World, Blocks.vine, 15, 8, -1, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.vine, 15, 8, -2, 3, par3StructureBoundingBox); + + if (!this.field_74947_h) + { + this.field_74947_h = this.generateStructureChestContents(par1World, par3StructureBoundingBox, par2Random, 8, -3, 3, chest.getItems(par2Random), chest.getCount(par2Random)); + } + + this.placeBlockAtCurrentPosition(par1World, Blocks.mossy_cobblestone, 0, 9, -3, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.mossy_cobblestone, 0, 8, -3, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.mossy_cobblestone, 0, 4, -3, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.mossy_cobblestone, 0, 5, -2, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.mossy_cobblestone, 0, 5, -1, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.mossy_cobblestone, 0, 6, -3, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.mossy_cobblestone, 0, 7, -2, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.mossy_cobblestone, 0, 7, -1, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.mossy_cobblestone, 0, 8, -3, 5, par3StructureBoundingBox); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 9, -1, 1, 9, -1, 5, false, par2Random, junglePyramidsRandomScatteredStones); + this.fillWithAir(par1World, par3StructureBoundingBox, 8, -3, 8, 10, -1, 10); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 3, 8, -2, 11, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 3, 9, -2, 11, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 3, 10, -2, 11, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.lever, BlockLever.invertMetadata(this.getMetadataWithOffset(Blocks.lever, 2)), 8, -2, 12, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.lever, BlockLever.invertMetadata(this.getMetadataWithOffset(Blocks.lever, 2)), 9, -2, 12, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.lever, BlockLever.invertMetadata(this.getMetadataWithOffset(Blocks.lever, 2)), 10, -2, 12, par3StructureBoundingBox); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 8, -3, 8, 8, -3, 10, false, par2Random, junglePyramidsRandomScatteredStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 10, -3, 8, 10, -3, 10, false, par2Random, junglePyramidsRandomScatteredStones); + this.placeBlockAtCurrentPosition(par1World, Blocks.mossy_cobblestone, 0, 10, -2, 9, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.redstone_wire, 0, 8, -2, 9, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.redstone_wire, 0, 8, -2, 10, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.redstone_wire, 0, 10, -1, 9, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sticky_piston, 1, 9, -2, 8, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sticky_piston, this.getMetadataWithOffset(Blocks.sticky_piston, 4), 10, -2, 8, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.sticky_piston, this.getMetadataWithOffset(Blocks.sticky_piston, 4), 10, -1, 8, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.unpowered_repeater, this.getMetadataWithOffset(Blocks.unpowered_repeater, 2), 10, -2, 10, par3StructureBoundingBox); + + if (!this.field_74948_i) + { + this.field_74948_i = this.generateStructureChestContents(par1World, par3StructureBoundingBox, par2Random, 9, -3, 10, chest.getItems(par2Random), chest.getCount(par2Random)); + } + + return true; + } + } + + static class Stones extends StructureComponent.BlockSelector + { + private static final String __OBFID = "CL_00000478"; + + private Stones() {} + + public void selectBlocks(Random par1Random, int par2, int par3, int par4, boolean par5) + { + if (par1Random.nextFloat() < 0.4F) + { + this.field_151562_a = Blocks.cobblestone; + } + else + { + this.field_151562_a = Blocks.mossy_cobblestone; + } + } + + Stones(Object par1ComponentScatteredFeaturePieces2) + { + this(); + } + } + } + + public static class SwampHut extends ComponentScatteredFeaturePieces.Feature + { + private boolean hasWitch; + private static final String __OBFID = "CL_00000480"; + + public SwampHut() {} + + public SwampHut(Random par1Random, int par2, int par3) + { + super(par1Random, par2, 64, par3, 7, 5, 9); + } + + protected void func_143012_a(NBTTagCompound par1NBTTagCompound) + { + super.func_143012_a(par1NBTTagCompound); + par1NBTTagCompound.setBoolean("Witch", this.hasWitch); + } + + protected void func_143011_b(NBTTagCompound par1NBTTagCompound) + { + super.func_143011_b(par1NBTTagCompound); + this.hasWitch = par1NBTTagCompound.getBoolean("Witch"); + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + if (!this.func_74935_a(par1World, par3StructureBoundingBox, 0)) + { + return false; + } + else + { + this.fillWithMetadataBlocks(par1World, par3StructureBoundingBox, 1, 1, 1, 5, 1, 7, Blocks.planks, 1, Blocks.planks, 1, false); + this.fillWithMetadataBlocks(par1World, par3StructureBoundingBox, 1, 4, 2, 5, 4, 7, Blocks.planks, 1, Blocks.planks, 1, false); + this.fillWithMetadataBlocks(par1World, par3StructureBoundingBox, 2, 1, 0, 4, 1, 0, Blocks.planks, 1, Blocks.planks, 1, false); + this.fillWithMetadataBlocks(par1World, par3StructureBoundingBox, 2, 2, 2, 3, 3, 2, Blocks.planks, 1, Blocks.planks, 1, false); + this.fillWithMetadataBlocks(par1World, par3StructureBoundingBox, 1, 2, 3, 1, 3, 6, Blocks.planks, 1, Blocks.planks, 1, false); + this.fillWithMetadataBlocks(par1World, par3StructureBoundingBox, 5, 2, 3, 5, 3, 6, Blocks.planks, 1, Blocks.planks, 1, false); + this.fillWithMetadataBlocks(par1World, par3StructureBoundingBox, 2, 2, 7, 4, 3, 7, Blocks.planks, 1, Blocks.planks, 1, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 0, 2, 1, 3, 2, Blocks.log, Blocks.log, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 5, 0, 2, 5, 3, 2, Blocks.log, Blocks.log, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 0, 7, 1, 3, 7, Blocks.log, Blocks.log, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 5, 0, 7, 5, 3, 7, Blocks.log, Blocks.log, false); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, 2, 3, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, 3, 3, 7, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, 1, 3, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, 5, 3, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, 5, 3, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.flower_pot, 7, 1, 3, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.crafting_table, 0, 3, 2, 6, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.cauldron, 0, 4, 2, 6, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, 1, 2, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, 5, 2, 1, par3StructureBoundingBox); + int i = this.getMetadataWithOffset(Blocks.oak_stairs, 3); + int j = this.getMetadataWithOffset(Blocks.oak_stairs, 1); + int k = this.getMetadataWithOffset(Blocks.oak_stairs, 0); + int l = this.getMetadataWithOffset(Blocks.oak_stairs, 2); + this.fillWithMetadataBlocks(par1World, par3StructureBoundingBox, 0, 4, 1, 6, 4, 1, Blocks.spruce_stairs, i, Blocks.spruce_stairs, i, false); + this.fillWithMetadataBlocks(par1World, par3StructureBoundingBox, 0, 4, 2, 0, 4, 7, Blocks.spruce_stairs, k, Blocks.spruce_stairs, k, false); + this.fillWithMetadataBlocks(par1World, par3StructureBoundingBox, 6, 4, 2, 6, 4, 7, Blocks.spruce_stairs, j, Blocks.spruce_stairs, j, false); + this.fillWithMetadataBlocks(par1World, par3StructureBoundingBox, 0, 4, 8, 6, 4, 8, Blocks.spruce_stairs, l, Blocks.spruce_stairs, l, false); + int i1; + int j1; + + for (i1 = 2; i1 <= 7; i1 += 5) + { + for (j1 = 1; j1 <= 5; j1 += 4) + { + this.func_151554_b(par1World, Blocks.log, 0, j1, -1, i1, par3StructureBoundingBox); + } + } + + if (!this.hasWitch) + { + i1 = this.getXWithOffset(2, 5); + j1 = this.getYWithOffset(2); + int k1 = this.getZWithOffset(2, 5); + + if (par3StructureBoundingBox.isVecInside(i1, j1, k1)) + { + this.hasWitch = true; + EntityWitch entitywitch = new EntityWitch(par1World); + entitywitch.setLocationAndAngles((double)i1 + 0.5D, (double)j1, (double)k1 + 0.5D, 0.0F, 0.0F); + entitywitch.onSpawnWithEgg((IEntityLivingData)null); + par1World.spawnEntityInWorld(entitywitch); + } + } + + return true; + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/structure/MapGenMineshaft.java b/src/main/java/net/minecraft/world/gen/structure/MapGenMineshaft.java new file mode 100644 index 0000000..794d5d6 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/structure/MapGenMineshaft.java @@ -0,0 +1,44 @@ +package net.minecraft.world.gen.structure; + +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; +import net.minecraft.util.MathHelper; + +public class MapGenMineshaft extends MapGenStructure +{ + private double field_82673_e = 0.004D; + private static final String __OBFID = "CL_00000443"; + + public MapGenMineshaft() {} + + public String func_143025_a() + { + return "Mineshaft"; + } + + public MapGenMineshaft(Map par1Map) + { + Iterator iterator = par1Map.entrySet().iterator(); + + while (iterator.hasNext()) + { + Entry entry = (Entry)iterator.next(); + + if (((String)entry.getKey()).equals("chance")) + { + this.field_82673_e = MathHelper.parseDoubleWithDefault((String)entry.getValue(), this.field_82673_e); + } + } + } + + protected boolean canSpawnStructureAtCoords(int par1, int par2) + { + return this.rand.nextDouble() < this.field_82673_e && this.rand.nextInt(80) < Math.max(Math.abs(par1), Math.abs(par2)); + } + + protected StructureStart getStructureStart(int par1, int par2) + { + return new StructureMineshaftStart(this.worldObj, this.rand, par1, par2); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/structure/MapGenNetherBridge.java b/src/main/java/net/minecraft/world/gen/structure/MapGenNetherBridge.java new file mode 100644 index 0000000..84307d7 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/structure/MapGenNetherBridge.java @@ -0,0 +1,75 @@ +package net.minecraft.world.gen.structure; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import net.minecraft.entity.monster.EntityBlaze; +import net.minecraft.entity.monster.EntityMagmaCube; +import net.minecraft.entity.monster.EntityPigZombie; +import net.minecraft.entity.monster.EntitySkeleton; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; + +public class MapGenNetherBridge extends MapGenStructure +{ + private List spawnList = new ArrayList(); + private static final String __OBFID = "CL_00000451"; + + public MapGenNetherBridge() + { + this.spawnList.add(new BiomeGenBase.SpawnListEntry(EntityBlaze.class, 10, 2, 3)); + this.spawnList.add(new BiomeGenBase.SpawnListEntry(EntityPigZombie.class, 5, 4, 4)); + this.spawnList.add(new BiomeGenBase.SpawnListEntry(EntitySkeleton.class, 10, 4, 4)); + this.spawnList.add(new BiomeGenBase.SpawnListEntry(EntityMagmaCube.class, 3, 4, 4)); + } + + public String func_143025_a() + { + return "Fortress"; + } + + public List getSpawnList() + { + return this.spawnList; + } + + protected boolean canSpawnStructureAtCoords(int par1, int par2) + { + int k = par1 >> 4; + int l = par2 >> 4; + this.rand.setSeed((long)(k ^ l << 4) ^ this.worldObj.getSeed()); + this.rand.nextInt(); + return this.rand.nextInt(3) != 0 ? false : (par1 != (k << 4) + 4 + this.rand.nextInt(8) ? false : par2 == (l << 4) + 4 + this.rand.nextInt(8)); + } + + protected StructureStart getStructureStart(int par1, int par2) + { + return new MapGenNetherBridge.Start(this.worldObj, this.rand, par1, par2); + } + + public static class Start extends StructureStart + { + private static final String __OBFID = "CL_00000452"; + + public Start() {} + + public Start(World par1World, Random par2Random, int par3, int par4) + { + super(par3, par4); + StructureNetherBridgePieces.Start start = new StructureNetherBridgePieces.Start(par2Random, (par3 << 4) + 2, (par4 << 4) + 2); + this.components.add(start); + start.buildComponent(start, this.components, par2Random); + ArrayList arraylist = start.field_74967_d; + + while (!arraylist.isEmpty()) + { + int k = par2Random.nextInt(arraylist.size()); + StructureComponent structurecomponent = (StructureComponent)arraylist.remove(k); + structurecomponent.buildComponent(start, this.components, par2Random); + } + + this.updateBoundingBox(); + this.setRandomHeight(par1World, par2Random, 48, 70); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/structure/MapGenScatteredFeature.java b/src/main/java/net/minecraft/world/gen/structure/MapGenScatteredFeature.java new file mode 100644 index 0000000..1a66ac7 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/structure/MapGenScatteredFeature.java @@ -0,0 +1,152 @@ +package net.minecraft.world.gen.structure; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.Map.Entry; +import net.minecraft.entity.monster.EntityWitch; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; + +public class MapGenScatteredFeature extends MapGenStructure +{ + private static List biomelist = Arrays.asList(new BiomeGenBase[] {BiomeGenBase.desert, BiomeGenBase.desertHills, BiomeGenBase.jungle, BiomeGenBase.jungleHills, BiomeGenBase.swampland}); + private List scatteredFeatureSpawnList; + private int maxDistanceBetweenScatteredFeatures; + private int minDistanceBetweenScatteredFeatures; + private static final String __OBFID = "CL_00000471"; + + public MapGenScatteredFeature() + { + this.scatteredFeatureSpawnList = new ArrayList(); + this.maxDistanceBetweenScatteredFeatures = 32; + this.minDistanceBetweenScatteredFeatures = 8; + this.scatteredFeatureSpawnList.add(new BiomeGenBase.SpawnListEntry(EntityWitch.class, 1, 1, 1)); + } + + public MapGenScatteredFeature(Map par1Map) + { + this(); + Iterator iterator = par1Map.entrySet().iterator(); + + while (iterator.hasNext()) + { + Entry entry = (Entry)iterator.next(); + + if (((String)entry.getKey()).equals("distance")) + { + this.maxDistanceBetweenScatteredFeatures = MathHelper.parseIntWithDefaultAndMax((String)entry.getValue(), this.maxDistanceBetweenScatteredFeatures, this.minDistanceBetweenScatteredFeatures + 1); + } + } + } + + public String func_143025_a() + { + return "Temple"; + } + + protected boolean canSpawnStructureAtCoords(int par1, int par2) + { + int k = par1; + int l = par2; + + if (par1 < 0) + { + par1 -= this.maxDistanceBetweenScatteredFeatures - 1; + } + + if (par2 < 0) + { + par2 -= this.maxDistanceBetweenScatteredFeatures - 1; + } + + int i1 = par1 / this.maxDistanceBetweenScatteredFeatures; + int j1 = par2 / this.maxDistanceBetweenScatteredFeatures; + Random random = this.worldObj.setRandomSeed(i1, j1, 14357617); + i1 *= this.maxDistanceBetweenScatteredFeatures; + j1 *= this.maxDistanceBetweenScatteredFeatures; + i1 += random.nextInt(this.maxDistanceBetweenScatteredFeatures - this.minDistanceBetweenScatteredFeatures); + j1 += random.nextInt(this.maxDistanceBetweenScatteredFeatures - this.minDistanceBetweenScatteredFeatures); + + if (k == i1 && l == j1) + { + BiomeGenBase biomegenbase = this.worldObj.getWorldChunkManager().getBiomeGenAt(k * 16 + 8, l * 16 + 8); + Iterator iterator = biomelist.iterator(); + + while (iterator.hasNext()) + { + BiomeGenBase biomegenbase1 = (BiomeGenBase)iterator.next(); + + if (biomegenbase == biomegenbase1) + { + return true; + } + } + } + + return false; + } + + protected StructureStart getStructureStart(int par1, int par2) + { + return new MapGenScatteredFeature.Start(this.worldObj, this.rand, par1, par2); + } + + public boolean func_143030_a(int par1, int par2, int par3) + { + StructureStart structurestart = this.func_143028_c(par1, par2, par3); + + if (structurestart != null && structurestart instanceof MapGenScatteredFeature.Start && !structurestart.components.isEmpty()) + { + StructureComponent structurecomponent = (StructureComponent)structurestart.components.getFirst(); + return structurecomponent instanceof ComponentScatteredFeaturePieces.SwampHut; + } + else + { + return false; + } + } + + public List getScatteredFeatureSpawnList() + { + return this.scatteredFeatureSpawnList; + } + + public static class Start extends StructureStart + { + private static final String __OBFID = "CL_00000472"; + + public Start() {} + + public Start(World par1World, Random par2Random, int par3, int par4) + { + super(par3, par4); + BiomeGenBase biomegenbase = par1World.getBiomeGenForCoords(par3 * 16 + 8, par4 * 16 + 8); + + if (biomegenbase != BiomeGenBase.jungle && biomegenbase != BiomeGenBase.jungleHills) + { + if (biomegenbase == BiomeGenBase.swampland) + { + ComponentScatteredFeaturePieces.SwampHut swamphut = new ComponentScatteredFeaturePieces.SwampHut(par2Random, par3 * 16, par4 * 16); + this.components.add(swamphut); + } + else + { + ComponentScatteredFeaturePieces.DesertPyramid desertpyramid = new ComponentScatteredFeaturePieces.DesertPyramid(par2Random, par3 * 16, par4 * 16); + this.components.add(desertpyramid); + } + } + else + { + ComponentScatteredFeaturePieces.JunglePyramid junglepyramid = new ComponentScatteredFeaturePieces.JunglePyramid(par2Random, par3 * 16, par4 * 16); + this.components.add(junglepyramid); + } + + this.updateBoundingBox(); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/structure/MapGenStronghold.java b/src/main/java/net/minecraft/world/gen/structure/MapGenStronghold.java new file mode 100644 index 0000000..a91b32a --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/structure/MapGenStronghold.java @@ -0,0 +1,189 @@ +package net.minecraft.world.gen.structure; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.Map.Entry; +import net.minecraft.util.MathHelper; +import net.minecraft.world.ChunkCoordIntPair; +import net.minecraft.world.ChunkPosition; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraftforge.common.BiomeManager; + +public class MapGenStronghold extends MapGenStructure +{ + public final List field_151546_e; + private boolean ranBiomeCheck; + private ChunkCoordIntPair[] structureCoords; + private double field_82671_h; + private int field_82672_i; + private static final String __OBFID = "CL_00000481"; + + public MapGenStronghold() + { + this.structureCoords = new ChunkCoordIntPair[3]; + this.field_82671_h = 32.0D; + this.field_82672_i = 3; + this.field_151546_e = new ArrayList(); + BiomeGenBase[] abiomegenbase = BiomeGenBase.getBiomeGenArray(); + int i = abiomegenbase.length; + + for (int j = 0; j < i; ++j) + { + BiomeGenBase biomegenbase = abiomegenbase[j]; + + if (biomegenbase != null && biomegenbase.rootHeight > 0.0F && !BiomeManager.strongHoldBiomesBlackList.contains(biomegenbase)) + { + this.field_151546_e.add(biomegenbase); + } + } + for (BiomeGenBase biome : BiomeManager.strongHoldBiomes) + { + if (!this.field_151546_e.contains(biome)) + { + this.field_151546_e.add(biome); + } + } + } + + public MapGenStronghold(Map par1Map) + { + this(); + Iterator iterator = par1Map.entrySet().iterator(); + + while (iterator.hasNext()) + { + Entry entry = (Entry)iterator.next(); + + if (((String)entry.getKey()).equals("distance")) + { + this.field_82671_h = MathHelper.parseDoubleWithDefaultAndMax((String)entry.getValue(), this.field_82671_h, 1.0D); + } + else if (((String)entry.getKey()).equals("count")) + { + this.structureCoords = new ChunkCoordIntPair[MathHelper.parseIntWithDefaultAndMax((String)entry.getValue(), this.structureCoords.length, 1)]; + } + else if (((String)entry.getKey()).equals("spread")) + { + this.field_82672_i = MathHelper.parseIntWithDefaultAndMax((String)entry.getValue(), this.field_82672_i, 1); + } + } + } + + public String func_143025_a() + { + return "Stronghold"; + } + + protected boolean canSpawnStructureAtCoords(int par1, int par2) + { + if (!this.ranBiomeCheck) + { + Random random = new Random(); + random.setSeed(this.worldObj.getSeed()); + double d0 = random.nextDouble() * Math.PI * 2.0D; + int l = 1; + + for (int i1 = 0; i1 < this.structureCoords.length; ++i1) + { + double d1 = (1.25D * (double)l + random.nextDouble()) * this.field_82671_h * (double)l; + int j1 = (int)Math.round(Math.cos(d0) * d1); + int k1 = (int)Math.round(Math.sin(d0) * d1); + ChunkPosition chunkposition = this.worldObj.getWorldChunkManager().findBiomePosition((j1 << 4) + 8, (k1 << 4) + 8, 112, this.field_151546_e, random); + + if (chunkposition != null) + { + j1 = chunkposition.chunkPosX >> 4; + k1 = chunkposition.chunkPosZ >> 4; + } + + this.structureCoords[i1] = new ChunkCoordIntPair(j1, k1); + d0 += (Math.PI * 2D) * (double)l / (double)this.field_82672_i; + + if (i1 == this.field_82672_i) + { + l += 2 + random.nextInt(5); + this.field_82672_i += 1 + random.nextInt(2); + } + } + + this.ranBiomeCheck = true; + } + + ChunkCoordIntPair[] achunkcoordintpair = this.structureCoords; + int l1 = achunkcoordintpair.length; + + for (int k = 0; k < l1; ++k) + { + ChunkCoordIntPair chunkcoordintpair = achunkcoordintpair[k]; + + if (par1 == chunkcoordintpair.chunkXPos && par2 == chunkcoordintpair.chunkZPos) + { + return true; + } + } + + return false; + } + + protected List getCoordList() + { + ArrayList arraylist = new ArrayList(); + ChunkCoordIntPair[] achunkcoordintpair = this.structureCoords; + int i = achunkcoordintpair.length; + + for (int j = 0; j < i; ++j) + { + ChunkCoordIntPair chunkcoordintpair = achunkcoordintpair[j]; + + if (chunkcoordintpair != null) + { + arraylist.add(chunkcoordintpair.func_151349_a(64)); + } + } + + return arraylist; + } + + protected StructureStart getStructureStart(int par1, int par2) + { + MapGenStronghold.Start start; + + for (start = new MapGenStronghold.Start(this.worldObj, this.rand, par1, par2); start.getComponents().isEmpty() || ((StructureStrongholdPieces.Stairs2)start.getComponents().get(0)).strongholdPortalRoom == null; start = new MapGenStronghold.Start(this.worldObj, this.rand, par1, par2)) + { + ; + } + + return start; + } + + public static class Start extends StructureStart + { + private static final String __OBFID = "CL_00000482"; + + public Start() {} + + public Start(World par1World, Random par2Random, int par3, int par4) + { + super(par3, par4); + StructureStrongholdPieces.prepareStructurePieces(); + StructureStrongholdPieces.Stairs2 stairs2 = new StructureStrongholdPieces.Stairs2(0, par2Random, (par3 << 4) + 2, (par4 << 4) + 2); + this.components.add(stairs2); + stairs2.buildComponent(stairs2, this.components, par2Random); + List list = stairs2.field_75026_c; + + while (!list.isEmpty()) + { + int k = par2Random.nextInt(list.size()); + StructureComponent structurecomponent = (StructureComponent)list.remove(k); + structurecomponent.buildComponent(stairs2, this.components, par2Random); + } + + this.updateBoundingBox(); + this.markAvailableHeight(par1World, par2Random, 10); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/structure/MapGenStructure.java b/src/main/java/net/minecraft/world/gen/structure/MapGenStructure.java new file mode 100644 index 0000000..5265261 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/structure/MapGenStructure.java @@ -0,0 +1,285 @@ +package net.minecraft.world.gen.structure; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.concurrent.Callable; +import net.minecraft.block.Block; +import net.minecraft.crash.CrashReport; +import net.minecraft.crash.CrashReportCategory; +import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ReportedException; +import net.minecraft.world.ChunkCoordIntPair; +import net.minecraft.world.ChunkPosition; +import net.minecraft.world.World; +import net.minecraft.world.gen.MapGenBase; + +public abstract class MapGenStructure extends MapGenBase +{ + private MapGenStructureData field_143029_e; + protected Map structureMap = new HashMap(); + private static final String __OBFID = "CL_00000505"; + + public abstract String func_143025_a(); + + protected final void func_151538_a(World p_151538_1_, final int p_151538_2_, final int p_151538_3_, int p_151538_4_, int p_151538_5_, Block[] p_151538_6_) + { + this.func_143027_a(p_151538_1_); + + if (!this.structureMap.containsKey(Long.valueOf(ChunkCoordIntPair.chunkXZ2Int(p_151538_2_, p_151538_3_)))) + { + this.rand.nextInt(); + + try + { + if (this.canSpawnStructureAtCoords(p_151538_2_, p_151538_3_)) + { + StructureStart structurestart = this.getStructureStart(p_151538_2_, p_151538_3_); + this.structureMap.put(Long.valueOf(ChunkCoordIntPair.chunkXZ2Int(p_151538_2_, p_151538_3_)), structurestart); + this.func_143026_a(p_151538_2_, p_151538_3_, structurestart); + } + } + catch (Throwable throwable) + { + CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Exception preparing structure feature"); + CrashReportCategory crashreportcategory = crashreport.makeCategory("Feature being prepared"); + crashreportcategory.addCrashSectionCallable("Is feature chunk", new Callable() + { + private static final String __OBFID = "CL_00000506"; + public String call() + { + return MapGenStructure.this.canSpawnStructureAtCoords(p_151538_2_, p_151538_3_) ? "True" : "False"; + } + }); + crashreportcategory.addCrashSection("Chunk location", String.format("%d,%d", new Object[] {Integer.valueOf(p_151538_2_), Integer.valueOf(p_151538_3_)})); + crashreportcategory.addCrashSectionCallable("Chunk pos hash", new Callable() + { + private static final String __OBFID = "CL_00000507"; + public String call() + { + return String.valueOf(ChunkCoordIntPair.chunkXZ2Int(p_151538_2_, p_151538_3_)); + } + }); + crashreportcategory.addCrashSectionCallable("Structure type", new Callable() + { + private static final String __OBFID = "CL_00000508"; + public String call() + { + return MapGenStructure.this.getClass().getCanonicalName(); + } + }); + throw new ReportedException(crashreport); + } + } + } + + public boolean generateStructuresInChunk(World par1World, Random par2Random, int par3, int par4) + { + this.func_143027_a(par1World); + int k = (par3 << 4) + 8; + int l = (par4 << 4) + 8; + boolean flag = false; + Iterator iterator = this.structureMap.values().iterator(); + + while (iterator.hasNext()) + { + StructureStart structurestart = (StructureStart)iterator.next(); + + if (structurestart.isSizeableStructure() && structurestart.getBoundingBox().intersectsWith(k, l, k + 15, l + 15)) + { + structurestart.generateStructure(par1World, par2Random, new StructureBoundingBox(k, l, k + 15, l + 15)); + flag = true; + this.func_143026_a(structurestart.func_143019_e(), structurestart.func_143018_f(), structurestart); + } + } + + return flag; + } + + public boolean hasStructureAt(int par1, int par2, int par3) + { + this.func_143027_a(this.worldObj); + return this.func_143028_c(par1, par2, par3) != null; + } + + protected StructureStart func_143028_c(int par1, int par2, int par3) + { + Iterator iterator = this.structureMap.values().iterator(); + + while (iterator.hasNext()) + { + StructureStart structurestart = (StructureStart)iterator.next(); + + if (structurestart.isSizeableStructure() && structurestart.getBoundingBox().intersectsWith(par1, par3, par1, par3)) + { + Iterator iterator1 = structurestart.getComponents().iterator(); + + while (iterator1.hasNext()) + { + StructureComponent structurecomponent = (StructureComponent)iterator1.next(); + + if (structurecomponent.getBoundingBox().isVecInside(par1, par2, par3)) + { + return structurestart; + } + } + } + } + + return null; + } + + public boolean func_142038_b(int par1, int par2, int par3) + { + this.func_143027_a(this.worldObj); + Iterator iterator = this.structureMap.values().iterator(); + StructureStart structurestart; + + do + { + if (!iterator.hasNext()) + { + return false; + } + + structurestart = (StructureStart)iterator.next(); + } + while (!structurestart.isSizeableStructure()); + + return structurestart.getBoundingBox().intersectsWith(par1, par3, par1, par3); + } + + public ChunkPosition func_151545_a(World p_151545_1_, int p_151545_2_, int p_151545_3_, int p_151545_4_) + { + this.worldObj = p_151545_1_; + this.func_143027_a(p_151545_1_); + this.rand.setSeed(p_151545_1_.getSeed()); + long l = this.rand.nextLong(); + long i1 = this.rand.nextLong(); + long j1 = (long)(p_151545_2_ >> 4) * l; + long k1 = (long)(p_151545_4_ >> 4) * i1; + this.rand.setSeed(j1 ^ k1 ^ p_151545_1_.getSeed()); + this.func_151538_a(p_151545_1_, p_151545_2_ >> 4, p_151545_4_ >> 4, 0, 0, (Block[])null); + double d0 = Double.MAX_VALUE; + ChunkPosition chunkposition = null; + Iterator iterator = this.structureMap.values().iterator(); + ChunkPosition chunkposition1; + int l1; + int i2; + int j2; + double d1; + + while (iterator.hasNext()) + { + StructureStart structurestart = (StructureStart)iterator.next(); + + if (structurestart.isSizeableStructure()) + { + StructureComponent structurecomponent = (StructureComponent)structurestart.getComponents().get(0); + chunkposition1 = structurecomponent.func_151553_a(); + l1 = chunkposition1.chunkPosX - p_151545_2_; + i2 = chunkposition1.chunkPosY - p_151545_3_; + j2 = chunkposition1.chunkPosZ - p_151545_4_; + d1 = (double)(l1 * l1 + i2 * i2 + j2 * j2); + + if (d1 < d0) + { + d0 = d1; + chunkposition = chunkposition1; + } + } + } + + if (chunkposition != null) + { + return chunkposition; + } + else + { + List list = this.getCoordList(); + + if (list != null) + { + ChunkPosition chunkposition2 = null; + Iterator iterator1 = list.iterator(); + + while (iterator1.hasNext()) + { + chunkposition1 = (ChunkPosition)iterator1.next(); + l1 = chunkposition1.chunkPosX - p_151545_2_; + i2 = chunkposition1.chunkPosY - p_151545_3_; + j2 = chunkposition1.chunkPosZ - p_151545_4_; + d1 = (double)(l1 * l1 + i2 * i2 + j2 * j2); + + if (d1 < d0) + { + d0 = d1; + chunkposition2 = chunkposition1; + } + } + + return chunkposition2; + } + else + { + return null; + } + } + } + + protected List getCoordList() + { + return null; + } + + private void func_143027_a(World par1World) + { + if (this.field_143029_e == null) + { + this.field_143029_e = (MapGenStructureData)par1World.perWorldStorage.loadData(MapGenStructureData.class, this.func_143025_a()); + + if (this.field_143029_e == null) + { + this.field_143029_e = new MapGenStructureData(this.func_143025_a()); + par1World.perWorldStorage.setData(this.func_143025_a(), this.field_143029_e); + } + else + { + NBTTagCompound nbttagcompound = this.field_143029_e.func_143041_a(); + Iterator iterator = nbttagcompound.func_150296_c().iterator(); + + while (iterator.hasNext()) + { + String s = (String)iterator.next(); + NBTBase nbtbase = nbttagcompound.getTag(s); + + if (nbtbase.getId() == 10) + { + NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbtbase; + + if (nbttagcompound1.hasKey("ChunkX") && nbttagcompound1.hasKey("ChunkZ")) + { + int i = nbttagcompound1.getInteger("ChunkX"); + int j = nbttagcompound1.getInteger("ChunkZ"); + StructureStart structurestart = MapGenStructureIO.func_143035_a(nbttagcompound1, par1World); + this.structureMap.put(Long.valueOf(ChunkCoordIntPair.chunkXZ2Int(i, j)), structurestart); + } + } + } + } + } + } + + private void func_143026_a(int par1, int par2, StructureStart par3StructureStart) + { + this.field_143029_e.func_143043_a(par3StructureStart.func_143021_a(par1, par2), par1, par2); + this.field_143029_e.markDirty(); + } + + protected abstract boolean canSpawnStructureAtCoords(int var1, int var2); + + protected abstract StructureStart getStructureStart(int var1, int var2); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/structure/MapGenStructureData.java b/src/main/java/net/minecraft/world/gen/structure/MapGenStructureData.java new file mode 100644 index 0000000..00b8c07 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/structure/MapGenStructureData.java @@ -0,0 +1,40 @@ +package net.minecraft.world.gen.structure; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.WorldSavedData; + +public class MapGenStructureData extends WorldSavedData +{ + private NBTTagCompound field_143044_a = new NBTTagCompound(); + private static final String __OBFID = "CL_00000510"; + + public MapGenStructureData(String par1Str) + { + super(par1Str); + } + + public void readFromNBT(NBTTagCompound par1NBTTagCompound) + { + this.field_143044_a = par1NBTTagCompound.getCompoundTag("Features"); + } + + public void writeToNBT(NBTTagCompound par1NBTTagCompound) + { + par1NBTTagCompound.setTag("Features", this.field_143044_a); + } + + public void func_143043_a(NBTTagCompound par1NBTTagCompound, int par2, int par3) + { + this.field_143044_a.setTag(func_143042_b(par2, par3), par1NBTTagCompound); + } + + public static String func_143042_b(int par1, int par2) + { + return "[" + par1 + "," + par2 + "]"; + } + + public NBTTagCompound func_143041_a() + { + return this.field_143044_a; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/structure/MapGenStructureIO.java b/src/main/java/net/minecraft/world/gen/structure/MapGenStructureIO.java new file mode 100644 index 0000000..cf7dfc0 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/structure/MapGenStructureIO.java @@ -0,0 +1,116 @@ +package net.minecraft.world.gen.structure; + +import java.util.HashMap; +import java.util.Map; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class MapGenStructureIO +{ + private static final Logger logger = LogManager.getLogger(); + private static Map field_143040_a = new HashMap(); + private static Map field_143038_b = new HashMap(); + private static Map field_143039_c = new HashMap(); + private static Map field_143037_d = new HashMap(); + private static final String __OBFID = "CL_00000509"; + + public static void registerStructure(Class par0Class, String par1Str) + { + field_143040_a.put(par1Str, par0Class); + field_143038_b.put(par0Class, par1Str); + } + + public static void func_143031_a(Class par0Class, String par1Str) + { + field_143039_c.put(par1Str, par0Class); + field_143037_d.put(par0Class, par1Str); + } + + public static String func_143033_a(StructureStart par0StructureStart) + { + return (String)field_143038_b.get(par0StructureStart.getClass()); + } + + public static String func_143036_a(StructureComponent par0StructureComponent) + { + return (String)field_143037_d.get(par0StructureComponent.getClass()); + } + + public static StructureStart func_143035_a(NBTTagCompound par0NBTTagCompound, World par1World) + { + StructureStart structurestart = null; + + try + { + Class oclass = (Class)field_143040_a.get(par0NBTTagCompound.getString("id")); + + if (oclass != null) + { + structurestart = (StructureStart)oclass.newInstance(); + } + } + catch (Exception exception) + { + logger.warn("Failed Start with id " + par0NBTTagCompound.getString("id")); + exception.printStackTrace(); + } + + if (structurestart != null) + { + structurestart.func_143020_a(par1World, par0NBTTagCompound); + } + else + { + logger.warn("Skipping Structure with id " + par0NBTTagCompound.getString("id")); + } + + return structurestart; + } + + public static StructureComponent func_143032_b(NBTTagCompound par0NBTTagCompound, World par1World) + { + StructureComponent structurecomponent = null; + + try + { + Class oclass = (Class)field_143039_c.get(par0NBTTagCompound.getString("id")); + + if (oclass != null) + { + structurecomponent = (StructureComponent)oclass.newInstance(); + } + } + catch (Exception exception) + { + logger.warn("Failed Piece with id " + par0NBTTagCompound.getString("id")); + exception.printStackTrace(); + } + + if (structurecomponent != null) + { + structurecomponent.func_143009_a(par1World, par0NBTTagCompound); + } + else + { + logger.warn("Skipping Piece with id " + par0NBTTagCompound.getString("id")); + } + + return structurecomponent; + } + + static + { + registerStructure(StructureMineshaftStart.class, "Mineshaft"); + registerStructure(MapGenVillage.Start.class, "Village"); + registerStructure(MapGenNetherBridge.Start.class, "Fortress"); + registerStructure(MapGenStronghold.Start.class, "Stronghold"); + registerStructure(MapGenScatteredFeature.Start.class, "Temple"); + StructureMineshaftPieces.registerStructurePieces(); + StructureVillagePieces.registerVillagePieces(); + StructureNetherBridgePieces.registerNetherFortressPieces(); + StructureStrongholdPieces.registerStrongholdPieces(); + ComponentScatteredFeaturePieces.registerScatteredFeaturePieces(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/structure/MapGenVillage.java b/src/main/java/net/minecraft/world/gen/structure/MapGenVillage.java new file mode 100644 index 0000000..e20129b --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/structure/MapGenVillage.java @@ -0,0 +1,164 @@ +package net.minecraft.world.gen.structure; + +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.Map.Entry; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; + +public class MapGenVillage extends MapGenStructure +{ + public static List villageSpawnBiomes = Arrays.asList(new BiomeGenBase[] {BiomeGenBase.plains, BiomeGenBase.desert, BiomeGenBase.savanna}); + private int terrainType; + private int field_82665_g; + private int field_82666_h; + private static final String __OBFID = "CL_00000514"; + + public MapGenVillage() + { + this.field_82665_g = 32; + this.field_82666_h = 8; + } + + public MapGenVillage(Map par1Map) + { + this(); + Iterator iterator = par1Map.entrySet().iterator(); + + while (iterator.hasNext()) + { + Entry entry = (Entry)iterator.next(); + + if (((String)entry.getKey()).equals("size")) + { + this.terrainType = MathHelper.parseIntWithDefaultAndMax((String)entry.getValue(), this.terrainType, 0); + } + else if (((String)entry.getKey()).equals("distance")) + { + this.field_82665_g = MathHelper.parseIntWithDefaultAndMax((String)entry.getValue(), this.field_82665_g, this.field_82666_h + 1); + } + } + } + + public String func_143025_a() + { + return "Village"; + } + + protected boolean canSpawnStructureAtCoords(int par1, int par2) + { + int k = par1; + int l = par2; + + if (par1 < 0) + { + par1 -= this.field_82665_g - 1; + } + + if (par2 < 0) + { + par2 -= this.field_82665_g - 1; + } + + int i1 = par1 / this.field_82665_g; + int j1 = par2 / this.field_82665_g; + Random random = this.worldObj.setRandomSeed(i1, j1, 10387312); + i1 *= this.field_82665_g; + j1 *= this.field_82665_g; + i1 += random.nextInt(this.field_82665_g - this.field_82666_h); + j1 += random.nextInt(this.field_82665_g - this.field_82666_h); + + if (k == i1 && l == j1) + { + boolean flag = this.worldObj.getWorldChunkManager().areBiomesViable(k * 16 + 8, l * 16 + 8, 0, villageSpawnBiomes); + + if (flag) + { + return true; + } + } + + return false; + } + + protected StructureStart getStructureStart(int par1, int par2) + { + return new MapGenVillage.Start(this.worldObj, this.rand, par1, par2, this.terrainType); + } + + public static class Start extends StructureStart + { + private boolean hasMoreThanTwoComponents; + private static final String __OBFID = "CL_00000515"; + + public Start() {} + + public Start(World par1World, Random par2Random, int par3, int par4, int par5) + { + super(par3, par4); + List list = StructureVillagePieces.getStructureVillageWeightedPieceList(par2Random, par5); + StructureVillagePieces.Start start = new StructureVillagePieces.Start(par1World.getWorldChunkManager(), 0, par2Random, (par3 << 4) + 2, (par4 << 4) + 2, list, par5); + this.components.add(start); + start.buildComponent(start, this.components, par2Random); + List list1 = start.field_74930_j; + List list2 = start.field_74932_i; + int l; + + while (!list1.isEmpty() || !list2.isEmpty()) + { + StructureComponent structurecomponent; + + if (list1.isEmpty()) + { + l = par2Random.nextInt(list2.size()); + structurecomponent = (StructureComponent)list2.remove(l); + structurecomponent.buildComponent(start, this.components, par2Random); + } + else + { + l = par2Random.nextInt(list1.size()); + structurecomponent = (StructureComponent)list1.remove(l); + structurecomponent.buildComponent(start, this.components, par2Random); + } + } + + this.updateBoundingBox(); + l = 0; + Iterator iterator = this.components.iterator(); + + while (iterator.hasNext()) + { + StructureComponent structurecomponent1 = (StructureComponent)iterator.next(); + + if (!(structurecomponent1 instanceof StructureVillagePieces.Road)) + { + ++l; + } + } + + this.hasMoreThanTwoComponents = l > 2; + } + + public boolean isSizeableStructure() + { + return this.hasMoreThanTwoComponents; + } + + public void func_143022_a(NBTTagCompound par1NBTTagCompound) + { + super.func_143022_a(par1NBTTagCompound); + par1NBTTagCompound.setBoolean("Valid", this.hasMoreThanTwoComponents); + } + + public void func_143017_b(NBTTagCompound par1NBTTagCompound) + { + super.func_143017_b(par1NBTTagCompound); + this.hasMoreThanTwoComponents = par1NBTTagCompound.getBoolean("Valid"); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/structure/StructureBoundingBox.java b/src/main/java/net/minecraft/world/gen/structure/StructureBoundingBox.java new file mode 100644 index 0000000..90dc6dc --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/structure/StructureBoundingBox.java @@ -0,0 +1,156 @@ +package net.minecraft.world.gen.structure; + +import net.minecraft.nbt.NBTTagIntArray; + +public class StructureBoundingBox +{ + public int minX; + public int minY; + public int minZ; + public int maxX; + public int maxY; + public int maxZ; + private static final String __OBFID = "CL_00000442"; + + public StructureBoundingBox() {} + + public StructureBoundingBox(int[] par1ArrayOfInteger) + { + if (par1ArrayOfInteger.length == 6) + { + this.minX = par1ArrayOfInteger[0]; + this.minY = par1ArrayOfInteger[1]; + this.minZ = par1ArrayOfInteger[2]; + this.maxX = par1ArrayOfInteger[3]; + this.maxY = par1ArrayOfInteger[4]; + this.maxZ = par1ArrayOfInteger[5]; + } + } + + public static StructureBoundingBox getNewBoundingBox() + { + return new StructureBoundingBox(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE); + } + + public static StructureBoundingBox getComponentToAddBoundingBox(int par0, int par1, int par2, int par3, int par4, int par5, int par6, int par7, int par8, int par9) + { + switch (par9) + { + case 0: + return new StructureBoundingBox(par0 + par3, par1 + par4, par2 + par5, par0 + par6 - 1 + par3, par1 + par7 - 1 + par4, par2 + par8 - 1 + par5); + case 1: + return new StructureBoundingBox(par0 - par8 + 1 + par5, par1 + par4, par2 + par3, par0 + par5, par1 + par7 - 1 + par4, par2 + par6 - 1 + par3); + case 2: + return new StructureBoundingBox(par0 + par3, par1 + par4, par2 - par8 + 1 + par5, par0 + par6 - 1 + par3, par1 + par7 - 1 + par4, par2 + par5); + case 3: + return new StructureBoundingBox(par0 + par5, par1 + par4, par2 + par3, par0 + par8 - 1 + par5, par1 + par7 - 1 + par4, par2 + par6 - 1 + par3); + default: + return new StructureBoundingBox(par0 + par3, par1 + par4, par2 + par5, par0 + par6 - 1 + par3, par1 + par7 - 1 + par4, par2 + par8 - 1 + par5); + } + } + + public StructureBoundingBox(StructureBoundingBox par1StructureBoundingBox) + { + this.minX = par1StructureBoundingBox.minX; + this.minY = par1StructureBoundingBox.minY; + this.minZ = par1StructureBoundingBox.minZ; + this.maxX = par1StructureBoundingBox.maxX; + this.maxY = par1StructureBoundingBox.maxY; + this.maxZ = par1StructureBoundingBox.maxZ; + } + + public StructureBoundingBox(int par1, int par2, int par3, int par4, int par5, int par6) + { + this.minX = par1; + this.minY = par2; + this.minZ = par3; + this.maxX = par4; + this.maxY = par5; + this.maxZ = par6; + } + + public StructureBoundingBox(int par1, int par2, int par3, int par4) + { + this.minX = par1; + this.minZ = par2; + this.maxX = par3; + this.maxZ = par4; + this.minY = 1; + this.maxY = 512; + } + + public boolean intersectsWith(StructureBoundingBox par1StructureBoundingBox) + { + return this.maxX >= par1StructureBoundingBox.minX && this.minX <= par1StructureBoundingBox.maxX && this.maxZ >= par1StructureBoundingBox.minZ && this.minZ <= par1StructureBoundingBox.maxZ && this.maxY >= par1StructureBoundingBox.minY && this.minY <= par1StructureBoundingBox.maxY; + } + + public boolean intersectsWith(int par1, int par2, int par3, int par4) + { + return this.maxX >= par1 && this.minX <= par3 && this.maxZ >= par2 && this.minZ <= par4; + } + + public void expandTo(StructureBoundingBox par1StructureBoundingBox) + { + this.minX = Math.min(this.minX, par1StructureBoundingBox.minX); + this.minY = Math.min(this.minY, par1StructureBoundingBox.minY); + this.minZ = Math.min(this.minZ, par1StructureBoundingBox.minZ); + this.maxX = Math.max(this.maxX, par1StructureBoundingBox.maxX); + this.maxY = Math.max(this.maxY, par1StructureBoundingBox.maxY); + this.maxZ = Math.max(this.maxZ, par1StructureBoundingBox.maxZ); + } + + public void offset(int par1, int par2, int par3) + { + this.minX += par1; + this.minY += par2; + this.minZ += par3; + this.maxX += par1; + this.maxY += par2; + this.maxZ += par3; + } + + public boolean isVecInside(int par1, int par2, int par3) + { + return par1 >= this.minX && par1 <= this.maxX && par3 >= this.minZ && par3 <= this.maxZ && par2 >= this.minY && par2 <= this.maxY; + } + + public int getXSize() + { + return this.maxX - this.minX + 1; + } + + public int getYSize() + { + return this.maxY - this.minY + 1; + } + + public int getZSize() + { + return this.maxZ - this.minZ + 1; + } + + public int getCenterX() + { + return this.minX + (this.maxX - this.minX + 1) / 2; + } + + public int getCenterY() + { + return this.minY + (this.maxY - this.minY + 1) / 2; + } + + public int getCenterZ() + { + return this.minZ + (this.maxZ - this.minZ + 1) / 2; + } + + public String toString() + { + return "(" + this.minX + ", " + this.minY + ", " + this.minZ + "; " + this.maxX + ", " + this.maxY + ", " + this.maxZ + ")"; + } + + public NBTTagIntArray func_151535_h() + { + return new NBTTagIntArray(new int[] {this.minX, this.minY, this.minZ, this.maxX, this.maxY, this.maxZ}); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/structure/StructureComponent.java b/src/main/java/net/minecraft/world/gen/structure/StructureComponent.java new file mode 100644 index 0000000..d15a8ad --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/structure/StructureComponent.java @@ -0,0 +1,814 @@ +package net.minecraft.world.gen.structure; + +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.block.BlockDirectional; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemDoor; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntityChest; +import net.minecraft.tileentity.TileEntityDispenser; +import net.minecraft.util.Direction; +import net.minecraft.util.Facing; +import net.minecraft.util.WeightedRandomChestContent; +import net.minecraft.world.ChunkPosition; +import net.minecraft.world.World; + +public abstract class StructureComponent +{ + protected StructureBoundingBox boundingBox; + protected int coordBaseMode; + protected int componentType; + private static final String __OBFID = "CL_00000511"; + + public StructureComponent() {} + + protected StructureComponent(int par1) + { + this.componentType = par1; + this.coordBaseMode = -1; + } + + public NBTTagCompound func_143010_b() + { + if (MapGenStructureIO.func_143036_a(this) == null) // Friendlier error then the Null Stirng error below. + { + throw new RuntimeException("StructureComponent \"" + this.getClass().getName() + "\" missing ID Mapping, Modder see MapGenStructureIO"); + } + NBTTagCompound nbttagcompound = new NBTTagCompound(); + nbttagcompound.setString("id", MapGenStructureIO.func_143036_a(this)); + nbttagcompound.setTag("BB", this.boundingBox.func_151535_h()); + nbttagcompound.setInteger("O", this.coordBaseMode); + nbttagcompound.setInteger("GD", this.componentType); + this.func_143012_a(nbttagcompound); + return nbttagcompound; + } + + protected abstract void func_143012_a(NBTTagCompound var1); + + public void func_143009_a(World par1World, NBTTagCompound par2NBTTagCompound) + { + if (par2NBTTagCompound.hasKey("BB")) + { + this.boundingBox = new StructureBoundingBox(par2NBTTagCompound.getIntArray("BB")); + } + + this.coordBaseMode = par2NBTTagCompound.getInteger("O"); + this.componentType = par2NBTTagCompound.getInteger("GD"); + this.func_143011_b(par2NBTTagCompound); + } + + protected abstract void func_143011_b(NBTTagCompound var1); + + public void buildComponent(StructureComponent par1StructureComponent, List par2List, Random par3Random) {} + + public abstract boolean addComponentParts(World var1, Random var2, StructureBoundingBox var3); + + public StructureBoundingBox getBoundingBox() + { + return this.boundingBox; + } + + public int getComponentType() + { + return this.componentType; + } + + public static StructureComponent findIntersecting(List par0List, StructureBoundingBox par1StructureBoundingBox) + { + Iterator iterator = par0List.iterator(); + StructureComponent structurecomponent; + + do + { + if (!iterator.hasNext()) + { + return null; + } + + structurecomponent = (StructureComponent)iterator.next(); + } + while (structurecomponent.getBoundingBox() == null || !structurecomponent.getBoundingBox().intersectsWith(par1StructureBoundingBox)); + + return structurecomponent; + } + + public ChunkPosition func_151553_a() + { + return new ChunkPosition(this.boundingBox.getCenterX(), this.boundingBox.getCenterY(), this.boundingBox.getCenterZ()); + } + + protected boolean isLiquidInStructureBoundingBox(World par1World, StructureBoundingBox par2StructureBoundingBox) + { + int i = Math.max(this.boundingBox.minX - 1, par2StructureBoundingBox.minX); + int j = Math.max(this.boundingBox.minY - 1, par2StructureBoundingBox.minY); + int k = Math.max(this.boundingBox.minZ - 1, par2StructureBoundingBox.minZ); + int l = Math.min(this.boundingBox.maxX + 1, par2StructureBoundingBox.maxX); + int i1 = Math.min(this.boundingBox.maxY + 1, par2StructureBoundingBox.maxY); + int j1 = Math.min(this.boundingBox.maxZ + 1, par2StructureBoundingBox.maxZ); + int k1; + int l1; + + for (k1 = i; k1 <= l; ++k1) + { + for (l1 = k; l1 <= j1; ++l1) + { + if (par1World.getBlock(k1, j, l1).getMaterial().isLiquid()) + { + return true; + } + + if (par1World.getBlock(k1, i1, l1).getMaterial().isLiquid()) + { + return true; + } + } + } + + for (k1 = i; k1 <= l; ++k1) + { + for (l1 = j; l1 <= i1; ++l1) + { + if (par1World.getBlock(k1, l1, k).getMaterial().isLiquid()) + { + return true; + } + + if (par1World.getBlock(k1, l1, j1).getMaterial().isLiquid()) + { + return true; + } + } + } + + for (k1 = k; k1 <= j1; ++k1) + { + for (l1 = j; l1 <= i1; ++l1) + { + if (par1World.getBlock(i, l1, k1).getMaterial().isLiquid()) + { + return true; + } + + if (par1World.getBlock(l, l1, k1).getMaterial().isLiquid()) + { + return true; + } + } + } + + return false; + } + + protected int getXWithOffset(int par1, int par2) + { + switch (this.coordBaseMode) + { + case 0: + case 2: + return this.boundingBox.minX + par1; + case 1: + return this.boundingBox.maxX - par2; + case 3: + return this.boundingBox.minX + par2; + default: + return par1; + } + } + + protected int getYWithOffset(int par1) + { + return this.coordBaseMode == -1 ? par1 : par1 + this.boundingBox.minY; + } + + protected int getZWithOffset(int par1, int par2) + { + switch (this.coordBaseMode) + { + case 0: + return this.boundingBox.minZ + par2; + case 1: + case 3: + return this.boundingBox.minZ + par1; + case 2: + return this.boundingBox.maxZ - par2; + default: + return par2; + } + } + + protected int getMetadataWithOffset(Block p_151555_1_, int p_151555_2_) + { + if (p_151555_1_ == Blocks.rail) + { + if (this.coordBaseMode == 1 || this.coordBaseMode == 3) + { + if (p_151555_2_ == 1) + { + return 0; + } + + return 1; + } + } + else if (p_151555_1_ != Blocks.wooden_door && p_151555_1_ != Blocks.iron_door) + { + if (p_151555_1_ != Blocks.stone_stairs && p_151555_1_ != Blocks.oak_stairs && p_151555_1_ != Blocks.nether_brick_stairs && p_151555_1_ != Blocks.stone_brick_stairs && p_151555_1_ != Blocks.sandstone_stairs) + { + if (p_151555_1_ == Blocks.ladder) + { + if (this.coordBaseMode == 0) + { + if (p_151555_2_ == 2) + { + return 3; + } + + if (p_151555_2_ == 3) + { + return 2; + } + } + else if (this.coordBaseMode == 1) + { + if (p_151555_2_ == 2) + { + return 4; + } + + if (p_151555_2_ == 3) + { + return 5; + } + + if (p_151555_2_ == 4) + { + return 2; + } + + if (p_151555_2_ == 5) + { + return 3; + } + } + else if (this.coordBaseMode == 3) + { + if (p_151555_2_ == 2) + { + return 5; + } + + if (p_151555_2_ == 3) + { + return 4; + } + + if (p_151555_2_ == 4) + { + return 2; + } + + if (p_151555_2_ == 5) + { + return 3; + } + } + } + else if (p_151555_1_ == Blocks.stone_button) + { + if (this.coordBaseMode == 0) + { + if (p_151555_2_ == 3) + { + return 4; + } + + if (p_151555_2_ == 4) + { + return 3; + } + } + else if (this.coordBaseMode == 1) + { + if (p_151555_2_ == 3) + { + return 1; + } + + if (p_151555_2_ == 4) + { + return 2; + } + + if (p_151555_2_ == 2) + { + return 3; + } + + if (p_151555_2_ == 1) + { + return 4; + } + } + else if (this.coordBaseMode == 3) + { + if (p_151555_2_ == 3) + { + return 2; + } + + if (p_151555_2_ == 4) + { + return 1; + } + + if (p_151555_2_ == 2) + { + return 3; + } + + if (p_151555_2_ == 1) + { + return 4; + } + } + } + else if (p_151555_1_ != Blocks.tripwire_hook && !(p_151555_1_ instanceof BlockDirectional)) + { + if (p_151555_1_ == Blocks.piston || p_151555_1_ == Blocks.sticky_piston || p_151555_1_ == Blocks.lever || p_151555_1_ == Blocks.dispenser) + { + if (this.coordBaseMode == 0) + { + if (p_151555_2_ == 2 || p_151555_2_ == 3) + { + return Facing.oppositeSide[p_151555_2_]; + } + } + else if (this.coordBaseMode == 1) + { + if (p_151555_2_ == 2) + { + return 4; + } + + if (p_151555_2_ == 3) + { + return 5; + } + + if (p_151555_2_ == 4) + { + return 2; + } + + if (p_151555_2_ == 5) + { + return 3; + } + } + else if (this.coordBaseMode == 3) + { + if (p_151555_2_ == 2) + { + return 5; + } + + if (p_151555_2_ == 3) + { + return 4; + } + + if (p_151555_2_ == 4) + { + return 2; + } + + if (p_151555_2_ == 5) + { + return 3; + } + } + } + } + else if (this.coordBaseMode == 0) + { + if (p_151555_2_ == 0 || p_151555_2_ == 2) + { + return Direction.rotateOpposite[p_151555_2_]; + } + } + else if (this.coordBaseMode == 1) + { + if (p_151555_2_ == 2) + { + return 1; + } + + if (p_151555_2_ == 0) + { + return 3; + } + + if (p_151555_2_ == 1) + { + return 2; + } + + if (p_151555_2_ == 3) + { + return 0; + } + } + else if (this.coordBaseMode == 3) + { + if (p_151555_2_ == 2) + { + return 3; + } + + if (p_151555_2_ == 0) + { + return 1; + } + + if (p_151555_2_ == 1) + { + return 2; + } + + if (p_151555_2_ == 3) + { + return 0; + } + } + } + else if (this.coordBaseMode == 0) + { + if (p_151555_2_ == 2) + { + return 3; + } + + if (p_151555_2_ == 3) + { + return 2; + } + } + else if (this.coordBaseMode == 1) + { + if (p_151555_2_ == 0) + { + return 2; + } + + if (p_151555_2_ == 1) + { + return 3; + } + + if (p_151555_2_ == 2) + { + return 0; + } + + if (p_151555_2_ == 3) + { + return 1; + } + } + else if (this.coordBaseMode == 3) + { + if (p_151555_2_ == 0) + { + return 2; + } + + if (p_151555_2_ == 1) + { + return 3; + } + + if (p_151555_2_ == 2) + { + return 1; + } + + if (p_151555_2_ == 3) + { + return 0; + } + } + } + else if (this.coordBaseMode == 0) + { + if (p_151555_2_ == 0) + { + return 2; + } + + if (p_151555_2_ == 2) + { + return 0; + } + } + else + { + if (this.coordBaseMode == 1) + { + return p_151555_2_ + 1 & 3; + } + + if (this.coordBaseMode == 3) + { + return p_151555_2_ + 3 & 3; + } + } + + return p_151555_2_; + } + + protected void placeBlockAtCurrentPosition(World p_151550_1_, Block p_151550_2_, int p_151550_3_, int p_151550_4_, int p_151550_5_, int p_151550_6_, StructureBoundingBox p_151550_7_) + { + int i1 = this.getXWithOffset(p_151550_4_, p_151550_6_); + int j1 = this.getYWithOffset(p_151550_5_); + int k1 = this.getZWithOffset(p_151550_4_, p_151550_6_); + + if (p_151550_7_.isVecInside(i1, j1, k1)) + { + p_151550_1_.setBlock(i1, j1, k1, p_151550_2_, p_151550_3_, 2); + } + } + + protected Block getBlockAtCurrentPosition(World p_151548_1_, int p_151548_2_, int p_151548_3_, int p_151548_4_, StructureBoundingBox p_151548_5_) + { + int l = this.getXWithOffset(p_151548_2_, p_151548_4_); + int i1 = this.getYWithOffset(p_151548_3_); + int j1 = this.getZWithOffset(p_151548_2_, p_151548_4_); + return !p_151548_5_.isVecInside(l, i1, j1) ? Blocks.air : p_151548_1_.getBlock(l, i1, j1); + } + + protected void fillWithAir(World par1World, StructureBoundingBox par2StructureBoundingBox, int par3, int par4, int par5, int par6, int par7, int par8) + { + for (int k1 = par4; k1 <= par7; ++k1) + { + for (int l1 = par3; l1 <= par6; ++l1) + { + for (int i2 = par5; i2 <= par8; ++i2) + { + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, l1, k1, i2, par2StructureBoundingBox); + } + } + } + } + + protected void fillWithBlocks(World p_151549_1_, StructureBoundingBox p_151549_2_, int p_151549_3_, int p_151549_4_, int p_151549_5_, int p_151549_6_, int p_151549_7_, int p_151549_8_, Block p_151549_9_, Block p_151549_10_, boolean p_151549_11_) + { + for (int k1 = p_151549_4_; k1 <= p_151549_7_; ++k1) + { + for (int l1 = p_151549_3_; l1 <= p_151549_6_; ++l1) + { + for (int i2 = p_151549_5_; i2 <= p_151549_8_; ++i2) + { + if (!p_151549_11_ || this.getBlockAtCurrentPosition(p_151549_1_, l1, k1, i2, p_151549_2_).getMaterial() != Material.air) + { + if (k1 != p_151549_4_ && k1 != p_151549_7_ && l1 != p_151549_3_ && l1 != p_151549_6_ && i2 != p_151549_5_ && i2 != p_151549_8_) + { + this.placeBlockAtCurrentPosition(p_151549_1_, p_151549_10_, 0, l1, k1, i2, p_151549_2_); + } + else + { + this.placeBlockAtCurrentPosition(p_151549_1_, p_151549_9_, 0, l1, k1, i2, p_151549_2_); + } + } + } + } + } + } + + protected void fillWithMetadataBlocks(World p_151556_1_, StructureBoundingBox p_151556_2_, int p_151556_3_, int p_151556_4_, int p_151556_5_, int p_151556_6_, int p_151556_7_, int p_151556_8_, Block p_151556_9_, int p_151556_10_, Block p_151556_11_, int p_151556_12_, boolean p_151556_13_) + { + for (int i2 = p_151556_4_; i2 <= p_151556_7_; ++i2) + { + for (int j2 = p_151556_3_; j2 <= p_151556_6_; ++j2) + { + for (int k2 = p_151556_5_; k2 <= p_151556_8_; ++k2) + { + if (!p_151556_13_ || this.getBlockAtCurrentPosition(p_151556_1_, j2, i2, k2, p_151556_2_).getMaterial() != Material.air) + { + if (i2 != p_151556_4_ && i2 != p_151556_7_ && j2 != p_151556_3_ && j2 != p_151556_6_ && k2 != p_151556_5_ && k2 != p_151556_8_) + { + this.placeBlockAtCurrentPosition(p_151556_1_, p_151556_11_, p_151556_12_, j2, i2, k2, p_151556_2_); + } + else + { + this.placeBlockAtCurrentPosition(p_151556_1_, p_151556_9_, p_151556_10_, j2, i2, k2, p_151556_2_); + } + } + } + } + } + } + + protected void fillWithRandomizedBlocks(World par1World, StructureBoundingBox par2StructureBoundingBox, int par3, int par4, int par5, int par6, int par7, int par8, boolean par9, Random par10Random, StructureComponent.BlockSelector par11StructurePieceBlockSelector) + { + for (int k1 = par4; k1 <= par7; ++k1) + { + for (int l1 = par3; l1 <= par6; ++l1) + { + for (int i2 = par5; i2 <= par8; ++i2) + { + if (!par9 || this.getBlockAtCurrentPosition(par1World, l1, k1, i2, par2StructureBoundingBox).getMaterial() != Material.air) + { + par11StructurePieceBlockSelector.selectBlocks(par10Random, l1, k1, i2, k1 == par4 || k1 == par7 || l1 == par3 || l1 == par6 || i2 == par5 || i2 == par8); + this.placeBlockAtCurrentPosition(par1World, par11StructurePieceBlockSelector.func_151561_a(), par11StructurePieceBlockSelector.getSelectedBlockMetaData(), l1, k1, i2, par2StructureBoundingBox); + } + } + } + } + } + + protected void randomlyFillWithBlocks(World p_151551_1_, StructureBoundingBox p_151551_2_, Random p_151551_3_, float p_151551_4_, int p_151551_5_, int p_151551_6_, int p_151551_7_, int p_151551_8_, int p_151551_9_, int p_151551_10_, Block p_151551_11_, Block p_151551_12_, boolean p_151551_13_) + { + for (int k1 = p_151551_6_; k1 <= p_151551_9_; ++k1) + { + for (int l1 = p_151551_5_; l1 <= p_151551_8_; ++l1) + { + for (int i2 = p_151551_7_; i2 <= p_151551_10_; ++i2) + { + if (p_151551_3_.nextFloat() <= p_151551_4_ && (!p_151551_13_ || this.getBlockAtCurrentPosition(p_151551_1_, l1, k1, i2, p_151551_2_).getMaterial() != Material.air)) + { + if (k1 != p_151551_6_ && k1 != p_151551_9_ && l1 != p_151551_5_ && l1 != p_151551_8_ && i2 != p_151551_7_ && i2 != p_151551_10_) + { + this.placeBlockAtCurrentPosition(p_151551_1_, p_151551_12_, 0, l1, k1, i2, p_151551_2_); + } + else + { + this.placeBlockAtCurrentPosition(p_151551_1_, p_151551_11_, 0, l1, k1, i2, p_151551_2_); + } + } + } + } + } + } + + protected void func_151552_a(World p_151552_1_, StructureBoundingBox p_151552_2_, Random p_151552_3_, float p_151552_4_, int p_151552_5_, int p_151552_6_, int p_151552_7_, Block p_151552_8_, int p_151552_9_) + { + if (p_151552_3_.nextFloat() < p_151552_4_) + { + this.placeBlockAtCurrentPosition(p_151552_1_, p_151552_8_, p_151552_9_, p_151552_5_, p_151552_6_, p_151552_7_, p_151552_2_); + } + } + + protected void func_151547_a(World p_151547_1_, StructureBoundingBox p_151547_2_, int p_151547_3_, int p_151547_4_, int p_151547_5_, int p_151547_6_, int p_151547_7_, int p_151547_8_, Block p_151547_9_, boolean p_151547_10_) + { + float f = (float)(p_151547_6_ - p_151547_3_ + 1); + float f1 = (float)(p_151547_7_ - p_151547_4_ + 1); + float f2 = (float)(p_151547_8_ - p_151547_5_ + 1); + float f3 = (float)p_151547_3_ + f / 2.0F; + float f4 = (float)p_151547_5_ + f2 / 2.0F; + + for (int k1 = p_151547_4_; k1 <= p_151547_7_; ++k1) + { + float f5 = (float)(k1 - p_151547_4_) / f1; + + for (int l1 = p_151547_3_; l1 <= p_151547_6_; ++l1) + { + float f6 = ((float)l1 - f3) / (f * 0.5F); + + for (int i2 = p_151547_5_; i2 <= p_151547_8_; ++i2) + { + float f7 = ((float)i2 - f4) / (f2 * 0.5F); + + if (!p_151547_10_ || this.getBlockAtCurrentPosition(p_151547_1_, l1, k1, i2, p_151547_2_).getMaterial() != Material.air) + { + float f8 = f6 * f6 + f5 * f5 + f7 * f7; + + if (f8 <= 1.05F) + { + this.placeBlockAtCurrentPosition(p_151547_1_, p_151547_9_, 0, l1, k1, i2, p_151547_2_); + } + } + } + } + } + } + + protected void clearCurrentPositionBlocksUpwards(World par1World, int par2, int par3, int par4, StructureBoundingBox par5StructureBoundingBox) + { + int l = this.getXWithOffset(par2, par4); + int i1 = this.getYWithOffset(par3); + int j1 = this.getZWithOffset(par2, par4); + + if (par5StructureBoundingBox.isVecInside(l, i1, j1)) + { + while (!par1World.isAirBlock(l, i1, j1) && i1 < 255) + { + par1World.setBlock(l, i1, j1, Blocks.air, 0, 2); + ++i1; + } + } + } + + protected void func_151554_b(World p_151554_1_, Block p_151554_2_, int p_151554_3_, int p_151554_4_, int p_151554_5_, int p_151554_6_, StructureBoundingBox p_151554_7_) + { + int i1 = this.getXWithOffset(p_151554_4_, p_151554_6_); + int j1 = this.getYWithOffset(p_151554_5_); + int k1 = this.getZWithOffset(p_151554_4_, p_151554_6_); + + if (p_151554_7_.isVecInside(i1, j1, k1)) + { + while ((p_151554_1_.isAirBlock(i1, j1, k1) || p_151554_1_.getBlock(i1, j1, k1).getMaterial().isLiquid()) && j1 > 1) + { + p_151554_1_.setBlock(i1, j1, k1, p_151554_2_, p_151554_3_, 2); + --j1; + } + } + } + + protected boolean generateStructureChestContents(World par1World, StructureBoundingBox par2StructureBoundingBox, Random par3Random, int par4, int par5, int par6, WeightedRandomChestContent[] par7ArrayOfWeightedRandomChestContent, int par8) + { + int i1 = this.getXWithOffset(par4, par6); + int j1 = this.getYWithOffset(par5); + int k1 = this.getZWithOffset(par4, par6); + + if (par2StructureBoundingBox.isVecInside(i1, j1, k1) && par1World.getBlock(i1, j1, k1) != Blocks.chest) + { + par1World.setBlock(i1, j1, k1, Blocks.chest, 0, 2); + TileEntityChest tileentitychest = (TileEntityChest)par1World.getTileEntity(i1, j1, k1); + + if (tileentitychest != null) + { + WeightedRandomChestContent.generateChestContents(par3Random, par7ArrayOfWeightedRandomChestContent, tileentitychest, par8); + } + + return true; + } + else + { + return false; + } + } + + protected boolean generateStructureDispenserContents(World par1World, StructureBoundingBox par2StructureBoundingBox, Random par3Random, int par4, int par5, int par6, int par7, WeightedRandomChestContent[] par8ArrayOfWeightedRandomChestContent, int par9) + { + int j1 = this.getXWithOffset(par4, par6); + int k1 = this.getYWithOffset(par5); + int l1 = this.getZWithOffset(par4, par6); + + if (par2StructureBoundingBox.isVecInside(j1, k1, l1) && par1World.getBlock(j1, k1, l1) != Blocks.dispenser) + { + par1World.setBlock(j1, k1, l1, Blocks.dispenser, this.getMetadataWithOffset(Blocks.dispenser, par7), 2); + TileEntityDispenser tileentitydispenser = (TileEntityDispenser)par1World.getTileEntity(j1, k1, l1); + + if (tileentitydispenser != null) + { + WeightedRandomChestContent.generateDispenserContents(par3Random, par8ArrayOfWeightedRandomChestContent, tileentitydispenser, par9); + } + + return true; + } + else + { + return false; + } + } + + protected void placeDoorAtCurrentPosition(World par1World, StructureBoundingBox par2StructureBoundingBox, Random par3Random, int par4, int par5, int par6, int par7) + { + int i1 = this.getXWithOffset(par4, par6); + int j1 = this.getYWithOffset(par5); + int k1 = this.getZWithOffset(par4, par6); + + if (par2StructureBoundingBox.isVecInside(i1, j1, k1)) + { + ItemDoor.placeDoorBlock(par1World, i1, j1, k1, par7, Blocks.wooden_door); + } + } + + public abstract static class BlockSelector + { + protected Block field_151562_a; + protected int selectedBlockMetaData; + private static final String __OBFID = "CL_00000512"; + + protected BlockSelector() + { + this.field_151562_a = Blocks.air; + } + + public abstract void selectBlocks(Random var1, int var2, int var3, int var4, boolean var5); + + public Block func_151561_a() + { + return this.field_151562_a; + } + + public int getSelectedBlockMetaData() + { + return this.selectedBlockMetaData; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/structure/StructureMineshaftPieces.java b/src/main/java/net/minecraft/world/gen/structure/StructureMineshaftPieces.java new file mode 100644 index 0000000..a04e7b2 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/structure/StructureMineshaftPieces.java @@ -0,0 +1,808 @@ +package net.minecraft.world.gen.structure; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.item.EntityMinecartChest; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.tileentity.TileEntityMobSpawner; +import net.minecraft.util.WeightedRandomChestContent; +import net.minecraft.world.World; + +import net.minecraftforge.common.ChestGenHooks; +import static net.minecraftforge.common.ChestGenHooks.*; + +public class StructureMineshaftPieces +{ + public static final WeightedRandomChestContent[] mineshaftChestContents = new WeightedRandomChestContent[] {new WeightedRandomChestContent(Items.iron_ingot, 0, 1, 5, 10), new WeightedRandomChestContent(Items.gold_ingot, 0, 1, 3, 5), new WeightedRandomChestContent(Items.redstone, 0, 4, 9, 5), new WeightedRandomChestContent(Items.dye, 4, 4, 9, 5), new WeightedRandomChestContent(Items.diamond, 0, 1, 2, 3), new WeightedRandomChestContent(Items.coal, 0, 3, 8, 10), new WeightedRandomChestContent(Items.bread, 0, 1, 3, 15), new WeightedRandomChestContent(Items.iron_pickaxe, 0, 1, 1, 1), new WeightedRandomChestContent(Item.getItemFromBlock(Blocks.rail), 0, 4, 8, 1), new WeightedRandomChestContent(Items.melon_seeds, 0, 2, 4, 10), new WeightedRandomChestContent(Items.pumpkin_seeds, 0, 2, 4, 10), new WeightedRandomChestContent(Items.saddle, 0, 1, 1, 3), new WeightedRandomChestContent(Items.iron_horse_armor, 0, 1, 1, 1)}; + private static final String __OBFID = "CL_00000444"; + + public static void registerStructurePieces() + { + MapGenStructureIO.func_143031_a(StructureMineshaftPieces.Corridor.class, "MSCorridor"); + MapGenStructureIO.func_143031_a(StructureMineshaftPieces.Cross.class, "MSCrossing"); + MapGenStructureIO.func_143031_a(StructureMineshaftPieces.Room.class, "MSRoom"); + MapGenStructureIO.func_143031_a(StructureMineshaftPieces.Stairs.class, "MSStairs"); + } + + private static StructureComponent getRandomComponent(List par0List, Random par1Random, int par2, int par3, int par4, int par5, int par6) + { + int j1 = par1Random.nextInt(100); + StructureBoundingBox structureboundingbox; + + if (j1 >= 80) + { + structureboundingbox = StructureMineshaftPieces.Cross.findValidPlacement(par0List, par1Random, par2, par3, par4, par5); + + if (structureboundingbox != null) + { + return new StructureMineshaftPieces.Cross(par6, par1Random, structureboundingbox, par5); + } + } + else if (j1 >= 70) + { + structureboundingbox = StructureMineshaftPieces.Stairs.findValidPlacement(par0List, par1Random, par2, par3, par4, par5); + + if (structureboundingbox != null) + { + return new StructureMineshaftPieces.Stairs(par6, par1Random, structureboundingbox, par5); + } + } + else + { + structureboundingbox = StructureMineshaftPieces.Corridor.findValidPlacement(par0List, par1Random, par2, par3, par4, par5); + + if (structureboundingbox != null) + { + return new StructureMineshaftPieces.Corridor(par6, par1Random, structureboundingbox, par5); + } + } + + return null; + } + + private static StructureComponent getNextMineShaftComponent(StructureComponent par0StructureComponent, List par1List, Random par2Random, int par3, int par4, int par5, int par6, int par7) + { + if (par7 > 8) + { + return null; + } + else if (Math.abs(par3 - par0StructureComponent.getBoundingBox().minX) <= 80 && Math.abs(par5 - par0StructureComponent.getBoundingBox().minZ) <= 80) + { + StructureComponent structurecomponent1 = getRandomComponent(par1List, par2Random, par3, par4, par5, par6, par7 + 1); + + if (structurecomponent1 != null) + { + par1List.add(structurecomponent1); + structurecomponent1.buildComponent(par0StructureComponent, par1List, par2Random); + } + + return structurecomponent1; + } + else + { + return null; + } + } + + public static class Corridor extends StructureComponent + { + private boolean hasRails; + private boolean hasSpiders; + private boolean spawnerPlaced; + private int sectionCount; + private static final String __OBFID = "CL_00000445"; + + public Corridor() {} + + protected void func_143012_a(NBTTagCompound par1NBTTagCompound) + { + par1NBTTagCompound.setBoolean("hr", this.hasRails); + par1NBTTagCompound.setBoolean("sc", this.hasSpiders); + par1NBTTagCompound.setBoolean("hps", this.spawnerPlaced); + par1NBTTagCompound.setInteger("Num", this.sectionCount); + } + + protected void func_143011_b(NBTTagCompound par1NBTTagCompound) + { + this.hasRails = par1NBTTagCompound.getBoolean("hr"); + this.hasSpiders = par1NBTTagCompound.getBoolean("sc"); + this.spawnerPlaced = par1NBTTagCompound.getBoolean("hps"); + this.sectionCount = par1NBTTagCompound.getInteger("Num"); + } + + public Corridor(int par1, Random par2Random, StructureBoundingBox par3StructureBoundingBox, int par4) + { + super(par1); + this.coordBaseMode = par4; + this.boundingBox = par3StructureBoundingBox; + this.hasRails = par2Random.nextInt(3) == 0; + this.hasSpiders = !this.hasRails && par2Random.nextInt(23) == 0; + + if (this.coordBaseMode != 2 && this.coordBaseMode != 0) + { + this.sectionCount = par3StructureBoundingBox.getXSize() / 5; + } + else + { + this.sectionCount = par3StructureBoundingBox.getZSize() / 5; + } + } + + public static StructureBoundingBox findValidPlacement(List par0List, Random par1Random, int par2, int par3, int par4, int par5) + { + StructureBoundingBox structureboundingbox = new StructureBoundingBox(par2, par3, par4, par2, par3 + 2, par4); + int i1; + + for (i1 = par1Random.nextInt(3) + 2; i1 > 0; --i1) + { + int j1 = i1 * 5; + + switch (par5) + { + case 0: + structureboundingbox.maxX = par2 + 2; + structureboundingbox.maxZ = par4 + (j1 - 1); + break; + case 1: + structureboundingbox.minX = par2 - (j1 - 1); + structureboundingbox.maxZ = par4 + 2; + break; + case 2: + structureboundingbox.maxX = par2 + 2; + structureboundingbox.minZ = par4 - (j1 - 1); + break; + case 3: + structureboundingbox.maxX = par2 + (j1 - 1); + structureboundingbox.maxZ = par4 + 2; + } + + if (StructureComponent.findIntersecting(par0List, structureboundingbox) == null) + { + break; + } + } + + return i1 > 0 ? structureboundingbox : null; + } + + public void buildComponent(StructureComponent par1StructureComponent, List par2List, Random par3Random) + { + int i = this.getComponentType(); + int j = par3Random.nextInt(4); + + switch (this.coordBaseMode) + { + case 0: + if (j <= 1) + { + StructureMineshaftPieces.getNextMineShaftComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.minX, this.boundingBox.minY - 1 + par3Random.nextInt(3), this.boundingBox.maxZ + 1, this.coordBaseMode, i); + } + else if (j == 2) + { + StructureMineshaftPieces.getNextMineShaftComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.minX - 1, this.boundingBox.minY - 1 + par3Random.nextInt(3), this.boundingBox.maxZ - 3, 1, i); + } + else + { + StructureMineshaftPieces.getNextMineShaftComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.maxX + 1, this.boundingBox.minY - 1 + par3Random.nextInt(3), this.boundingBox.maxZ - 3, 3, i); + } + + break; + case 1: + if (j <= 1) + { + StructureMineshaftPieces.getNextMineShaftComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.minX - 1, this.boundingBox.minY - 1 + par3Random.nextInt(3), this.boundingBox.minZ, this.coordBaseMode, i); + } + else if (j == 2) + { + StructureMineshaftPieces.getNextMineShaftComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.minX, this.boundingBox.minY - 1 + par3Random.nextInt(3), this.boundingBox.minZ - 1, 2, i); + } + else + { + StructureMineshaftPieces.getNextMineShaftComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.minX, this.boundingBox.minY - 1 + par3Random.nextInt(3), this.boundingBox.maxZ + 1, 0, i); + } + + break; + case 2: + if (j <= 1) + { + StructureMineshaftPieces.getNextMineShaftComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.minX, this.boundingBox.minY - 1 + par3Random.nextInt(3), this.boundingBox.minZ - 1, this.coordBaseMode, i); + } + else if (j == 2) + { + StructureMineshaftPieces.getNextMineShaftComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.minX - 1, this.boundingBox.minY - 1 + par3Random.nextInt(3), this.boundingBox.minZ, 1, i); + } + else + { + StructureMineshaftPieces.getNextMineShaftComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.maxX + 1, this.boundingBox.minY - 1 + par3Random.nextInt(3), this.boundingBox.minZ, 3, i); + } + + break; + case 3: + if (j <= 1) + { + StructureMineshaftPieces.getNextMineShaftComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.maxX + 1, this.boundingBox.minY - 1 + par3Random.nextInt(3), this.boundingBox.minZ, this.coordBaseMode, i); + } + else if (j == 2) + { + StructureMineshaftPieces.getNextMineShaftComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.maxX - 3, this.boundingBox.minY - 1 + par3Random.nextInt(3), this.boundingBox.minZ - 1, 2, i); + } + else + { + StructureMineshaftPieces.getNextMineShaftComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.maxX - 3, this.boundingBox.minY - 1 + par3Random.nextInt(3), this.boundingBox.maxZ + 1, 0, i); + } + } + + if (i < 8) + { + int k; + int l; + + if (this.coordBaseMode != 2 && this.coordBaseMode != 0) + { + for (k = this.boundingBox.minX + 3; k + 3 <= this.boundingBox.maxX; k += 5) + { + l = par3Random.nextInt(5); + + if (l == 0) + { + StructureMineshaftPieces.getNextMineShaftComponent(par1StructureComponent, par2List, par3Random, k, this.boundingBox.minY, this.boundingBox.minZ - 1, 2, i + 1); + } + else if (l == 1) + { + StructureMineshaftPieces.getNextMineShaftComponent(par1StructureComponent, par2List, par3Random, k, this.boundingBox.minY, this.boundingBox.maxZ + 1, 0, i + 1); + } + } + } + else + { + for (k = this.boundingBox.minZ + 3; k + 3 <= this.boundingBox.maxZ; k += 5) + { + l = par3Random.nextInt(5); + + if (l == 0) + { + StructureMineshaftPieces.getNextMineShaftComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.minX - 1, this.boundingBox.minY, k, 1, i + 1); + } + else if (l == 1) + { + StructureMineshaftPieces.getNextMineShaftComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.maxX + 1, this.boundingBox.minY, k, 3, i + 1); + } + } + } + } + } + + protected boolean generateStructureChestContents(World par1World, StructureBoundingBox par2StructureBoundingBox, Random par3Random, int par4, int par5, int par6, WeightedRandomChestContent[] par7ArrayOfWeightedRandomChestContent, int par8) + { + int i1 = this.getXWithOffset(par4, par6); + int j1 = this.getYWithOffset(par5); + int k1 = this.getZWithOffset(par4, par6); + + if (par2StructureBoundingBox.isVecInside(i1, j1, k1) && par1World.getBlock(i1, j1, k1).getMaterial() == Material.air) + { + int l1 = par3Random.nextBoolean() ? 1 : 0; + par1World.setBlock(i1, j1, k1, Blocks.rail, this.getMetadataWithOffset(Blocks.rail, l1), 2); + EntityMinecartChest entityminecartchest = new EntityMinecartChest(par1World, (double)((float)i1 + 0.5F), (double)((float)j1 + 0.5F), (double)((float)k1 + 0.5F)); + WeightedRandomChestContent.generateChestContents(par3Random, par7ArrayOfWeightedRandomChestContent, entityminecartchest, par8); + par1World.spawnEntityInWorld(entityminecartchest); + return true; + } + else + { + return false; + } + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + if (this.isLiquidInStructureBoundingBox(par1World, par3StructureBoundingBox)) + { + return false; + } + else + { + boolean flag = false; + boolean flag1 = true; + boolean flag2 = false; + boolean flag3 = true; + int i = this.sectionCount * 5 - 1; + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 0, 0, 2, 1, i, Blocks.air, Blocks.air, false); + this.randomlyFillWithBlocks(par1World, par3StructureBoundingBox, par2Random, 0.8F, 0, 2, 0, 2, 2, i, Blocks.air, Blocks.air, false); + + if (this.hasSpiders) + { + this.randomlyFillWithBlocks(par1World, par3StructureBoundingBox, par2Random, 0.6F, 0, 0, 0, 2, 1, i, Blocks.web, Blocks.air, false); + } + + int j; + int k; + + for (j = 0; j < this.sectionCount; ++j) + { + k = 2 + j * 5; + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 0, k, 0, 1, k, Blocks.fence, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 2, 0, k, 2, 1, k, Blocks.fence, Blocks.air, false); + + if (par2Random.nextInt(4) == 0) + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 2, k, 0, 2, k, Blocks.planks, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 2, 2, k, 2, 2, k, Blocks.planks, Blocks.air, false); + } + else + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 2, k, 2, 2, k, Blocks.planks, Blocks.air, false); + } + + this.func_151552_a(par1World, par3StructureBoundingBox, par2Random, 0.1F, 0, 2, k - 1, Blocks.web, 0); + this.func_151552_a(par1World, par3StructureBoundingBox, par2Random, 0.1F, 2, 2, k - 1, Blocks.web, 0); + this.func_151552_a(par1World, par3StructureBoundingBox, par2Random, 0.1F, 0, 2, k + 1, Blocks.web, 0); + this.func_151552_a(par1World, par3StructureBoundingBox, par2Random, 0.1F, 2, 2, k + 1, Blocks.web, 0); + this.func_151552_a(par1World, par3StructureBoundingBox, par2Random, 0.05F, 0, 2, k - 2, Blocks.web, 0); + this.func_151552_a(par1World, par3StructureBoundingBox, par2Random, 0.05F, 2, 2, k - 2, Blocks.web, 0); + this.func_151552_a(par1World, par3StructureBoundingBox, par2Random, 0.05F, 0, 2, k + 2, Blocks.web, 0); + this.func_151552_a(par1World, par3StructureBoundingBox, par2Random, 0.05F, 2, 2, k + 2, Blocks.web, 0); + this.func_151552_a(par1World, par3StructureBoundingBox, par2Random, 0.05F, 1, 2, k - 1, Blocks.torch, 0); + this.func_151552_a(par1World, par3StructureBoundingBox, par2Random, 0.05F, 1, 2, k + 1, Blocks.torch, 0); + + ChestGenHooks info = ChestGenHooks.getInfo(MINESHAFT_CORRIDOR); + if (par2Random.nextInt(100) == 0) + { + this.generateStructureChestContents(par1World, par3StructureBoundingBox, par2Random, 2, 0, k - 1, info.getItems(par2Random), info.getCount(par2Random)); + } + + if (par2Random.nextInt(100) == 0) + { + this.generateStructureChestContents(par1World, par3StructureBoundingBox, par2Random, 0, 0, k + 1, info.getItems(par2Random), info.getCount(par2Random)); + } + + if (this.hasSpiders && !this.spawnerPlaced) + { + int l = this.getYWithOffset(0); + int i1 = k - 1 + par2Random.nextInt(3); + int j1 = this.getXWithOffset(1, i1); + i1 = this.getZWithOffset(1, i1); + + if (par3StructureBoundingBox.isVecInside(j1, l, i1)) + { + this.spawnerPlaced = true; + par1World.setBlock(j1, l, i1, Blocks.mob_spawner, 0, 2); + TileEntityMobSpawner tileentitymobspawner = (TileEntityMobSpawner)par1World.getTileEntity(j1, l, i1); + + if (tileentitymobspawner != null) + { + tileentitymobspawner.func_145881_a().setEntityName("CaveSpider"); + } + } + } + } + + for (j = 0; j <= 2; ++j) + { + for (k = 0; k <= i; ++k) + { + byte b0 = -1; + Block block1 = this.getBlockAtCurrentPosition(par1World, j, b0, k, par3StructureBoundingBox); + + if (block1.getMaterial() == Material.air) + { + byte b1 = -1; + this.placeBlockAtCurrentPosition(par1World, Blocks.planks, 0, j, b1, k, par3StructureBoundingBox); + } + } + } + + if (this.hasRails) + { + for (j = 0; j <= i; ++j) + { + Block block = this.getBlockAtCurrentPosition(par1World, 1, -1, j, par3StructureBoundingBox); + + if (block.getMaterial() != Material.air && block.func_149730_j()) + { + this.func_151552_a(par1World, par3StructureBoundingBox, par2Random, 0.7F, 1, 0, j, Blocks.rail, this.getMetadataWithOffset(Blocks.rail, 0)); + } + } + } + + return true; + } + } + } + + public static class Cross extends StructureComponent + { + private int corridorDirection; + private boolean isMultipleFloors; + private static final String __OBFID = "CL_00000446"; + + public Cross() {} + + protected void func_143012_a(NBTTagCompound par1NBTTagCompound) + { + par1NBTTagCompound.setBoolean("tf", this.isMultipleFloors); + par1NBTTagCompound.setInteger("D", this.corridorDirection); + } + + protected void func_143011_b(NBTTagCompound par1NBTTagCompound) + { + this.isMultipleFloors = par1NBTTagCompound.getBoolean("tf"); + this.corridorDirection = par1NBTTagCompound.getInteger("D"); + } + + public Cross(int par1, Random par2Random, StructureBoundingBox par3StructureBoundingBox, int par4) + { + super(par1); + this.corridorDirection = par4; + this.boundingBox = par3StructureBoundingBox; + this.isMultipleFloors = par3StructureBoundingBox.getYSize() > 3; + } + + public static StructureBoundingBox findValidPlacement(List par0List, Random par1Random, int par2, int par3, int par4, int par5) + { + StructureBoundingBox structureboundingbox = new StructureBoundingBox(par2, par3, par4, par2, par3 + 2, par4); + + if (par1Random.nextInt(4) == 0) + { + structureboundingbox.maxY += 4; + } + + switch (par5) + { + case 0: + structureboundingbox.minX = par2 - 1; + structureboundingbox.maxX = par2 + 3; + structureboundingbox.maxZ = par4 + 4; + break; + case 1: + structureboundingbox.minX = par2 - 4; + structureboundingbox.minZ = par4 - 1; + structureboundingbox.maxZ = par4 + 3; + break; + case 2: + structureboundingbox.minX = par2 - 1; + structureboundingbox.maxX = par2 + 3; + structureboundingbox.minZ = par4 - 4; + break; + case 3: + structureboundingbox.maxX = par2 + 4; + structureboundingbox.minZ = par4 - 1; + structureboundingbox.maxZ = par4 + 3; + } + + return StructureComponent.findIntersecting(par0List, structureboundingbox) != null ? null : structureboundingbox; + } + + public void buildComponent(StructureComponent par1StructureComponent, List par2List, Random par3Random) + { + int i = this.getComponentType(); + + switch (this.corridorDirection) + { + case 0: + StructureMineshaftPieces.getNextMineShaftComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.minX + 1, this.boundingBox.minY, this.boundingBox.maxZ + 1, 0, i); + StructureMineshaftPieces.getNextMineShaftComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.minX - 1, this.boundingBox.minY, this.boundingBox.minZ + 1, 1, i); + StructureMineshaftPieces.getNextMineShaftComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.maxX + 1, this.boundingBox.minY, this.boundingBox.minZ + 1, 3, i); + break; + case 1: + StructureMineshaftPieces.getNextMineShaftComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.minX + 1, this.boundingBox.minY, this.boundingBox.minZ - 1, 2, i); + StructureMineshaftPieces.getNextMineShaftComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.minX + 1, this.boundingBox.minY, this.boundingBox.maxZ + 1, 0, i); + StructureMineshaftPieces.getNextMineShaftComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.minX - 1, this.boundingBox.minY, this.boundingBox.minZ + 1, 1, i); + break; + case 2: + StructureMineshaftPieces.getNextMineShaftComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.minX + 1, this.boundingBox.minY, this.boundingBox.minZ - 1, 2, i); + StructureMineshaftPieces.getNextMineShaftComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.minX - 1, this.boundingBox.minY, this.boundingBox.minZ + 1, 1, i); + StructureMineshaftPieces.getNextMineShaftComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.maxX + 1, this.boundingBox.minY, this.boundingBox.minZ + 1, 3, i); + break; + case 3: + StructureMineshaftPieces.getNextMineShaftComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.minX + 1, this.boundingBox.minY, this.boundingBox.minZ - 1, 2, i); + StructureMineshaftPieces.getNextMineShaftComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.minX + 1, this.boundingBox.minY, this.boundingBox.maxZ + 1, 0, i); + StructureMineshaftPieces.getNextMineShaftComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.maxX + 1, this.boundingBox.minY, this.boundingBox.minZ + 1, 3, i); + } + + if (this.isMultipleFloors) + { + if (par3Random.nextBoolean()) + { + StructureMineshaftPieces.getNextMineShaftComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.minX + 1, this.boundingBox.minY + 3 + 1, this.boundingBox.minZ - 1, 2, i); + } + + if (par3Random.nextBoolean()) + { + StructureMineshaftPieces.getNextMineShaftComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.minX - 1, this.boundingBox.minY + 3 + 1, this.boundingBox.minZ + 1, 1, i); + } + + if (par3Random.nextBoolean()) + { + StructureMineshaftPieces.getNextMineShaftComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.maxX + 1, this.boundingBox.minY + 3 + 1, this.boundingBox.minZ + 1, 3, i); + } + + if (par3Random.nextBoolean()) + { + StructureMineshaftPieces.getNextMineShaftComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.minX + 1, this.boundingBox.minY + 3 + 1, this.boundingBox.maxZ + 1, 0, i); + } + } + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + if (this.isLiquidInStructureBoundingBox(par1World, par3StructureBoundingBox)) + { + return false; + } + else + { + if (this.isMultipleFloors) + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, this.boundingBox.minX + 1, this.boundingBox.minY, this.boundingBox.minZ, this.boundingBox.maxX - 1, this.boundingBox.minY + 3 - 1, this.boundingBox.maxZ, Blocks.air, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, this.boundingBox.minX, this.boundingBox.minY, this.boundingBox.minZ + 1, this.boundingBox.maxX, this.boundingBox.minY + 3 - 1, this.boundingBox.maxZ - 1, Blocks.air, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, this.boundingBox.minX + 1, this.boundingBox.maxY - 2, this.boundingBox.minZ, this.boundingBox.maxX - 1, this.boundingBox.maxY, this.boundingBox.maxZ, Blocks.air, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, this.boundingBox.minX, this.boundingBox.maxY - 2, this.boundingBox.minZ + 1, this.boundingBox.maxX, this.boundingBox.maxY, this.boundingBox.maxZ - 1, Blocks.air, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, this.boundingBox.minX + 1, this.boundingBox.minY + 3, this.boundingBox.minZ + 1, this.boundingBox.maxX - 1, this.boundingBox.minY + 3, this.boundingBox.maxZ - 1, Blocks.air, Blocks.air, false); + } + else + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, this.boundingBox.minX + 1, this.boundingBox.minY, this.boundingBox.minZ, this.boundingBox.maxX - 1, this.boundingBox.maxY, this.boundingBox.maxZ, Blocks.air, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, this.boundingBox.minX, this.boundingBox.minY, this.boundingBox.minZ + 1, this.boundingBox.maxX, this.boundingBox.maxY, this.boundingBox.maxZ - 1, Blocks.air, Blocks.air, false); + } + + this.fillWithBlocks(par1World, par3StructureBoundingBox, this.boundingBox.minX + 1, this.boundingBox.minY, this.boundingBox.minZ + 1, this.boundingBox.minX + 1, this.boundingBox.maxY, this.boundingBox.minZ + 1, Blocks.planks, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, this.boundingBox.minX + 1, this.boundingBox.minY, this.boundingBox.maxZ - 1, this.boundingBox.minX + 1, this.boundingBox.maxY, this.boundingBox.maxZ - 1, Blocks.planks, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, this.boundingBox.maxX - 1, this.boundingBox.minY, this.boundingBox.minZ + 1, this.boundingBox.maxX - 1, this.boundingBox.maxY, this.boundingBox.minZ + 1, Blocks.planks, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, this.boundingBox.maxX - 1, this.boundingBox.minY, this.boundingBox.maxZ - 1, this.boundingBox.maxX - 1, this.boundingBox.maxY, this.boundingBox.maxZ - 1, Blocks.planks, Blocks.air, false); + + for (int i = this.boundingBox.minX; i <= this.boundingBox.maxX; ++i) + { + for (int j = this.boundingBox.minZ; j <= this.boundingBox.maxZ; ++j) + { + if (this.getBlockAtCurrentPosition(par1World, i, this.boundingBox.minY - 1, j, par3StructureBoundingBox).getMaterial() == Material.air) + { + this.placeBlockAtCurrentPosition(par1World, Blocks.planks, 0, i, this.boundingBox.minY - 1, j, par3StructureBoundingBox); + } + } + } + + return true; + } + } + } + + public static class Room extends StructureComponent + { + private List roomsLinkedToTheRoom = new LinkedList(); + private static final String __OBFID = "CL_00000447"; + + public Room() {} + + public Room(int par1, Random par2Random, int par3, int par4) + { + super(par1); + this.boundingBox = new StructureBoundingBox(par3, 50, par4, par3 + 7 + par2Random.nextInt(6), 54 + par2Random.nextInt(6), par4 + 7 + par2Random.nextInt(6)); + } + + public void buildComponent(StructureComponent par1StructureComponent, List par2List, Random par3Random) + { + int i = this.getComponentType(); + int k = this.boundingBox.getYSize() - 3 - 1; + + if (k <= 0) + { + k = 1; + } + + int j; + StructureComponent structurecomponent1; + StructureBoundingBox structureboundingbox; + + for (j = 0; j < this.boundingBox.getXSize(); j += 4) + { + j += par3Random.nextInt(this.boundingBox.getXSize()); + + if (j + 3 > this.boundingBox.getXSize()) + { + break; + } + + structurecomponent1 = StructureMineshaftPieces.getNextMineShaftComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.minX + j, this.boundingBox.minY + par3Random.nextInt(k) + 1, this.boundingBox.minZ - 1, 2, i); + + if (structurecomponent1 != null) + { + structureboundingbox = structurecomponent1.getBoundingBox(); + this.roomsLinkedToTheRoom.add(new StructureBoundingBox(structureboundingbox.minX, structureboundingbox.minY, this.boundingBox.minZ, structureboundingbox.maxX, structureboundingbox.maxY, this.boundingBox.minZ + 1)); + } + } + + for (j = 0; j < this.boundingBox.getXSize(); j += 4) + { + j += par3Random.nextInt(this.boundingBox.getXSize()); + + if (j + 3 > this.boundingBox.getXSize()) + { + break; + } + + structurecomponent1 = StructureMineshaftPieces.getNextMineShaftComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.minX + j, this.boundingBox.minY + par3Random.nextInt(k) + 1, this.boundingBox.maxZ + 1, 0, i); + + if (structurecomponent1 != null) + { + structureboundingbox = structurecomponent1.getBoundingBox(); + this.roomsLinkedToTheRoom.add(new StructureBoundingBox(structureboundingbox.minX, structureboundingbox.minY, this.boundingBox.maxZ - 1, structureboundingbox.maxX, structureboundingbox.maxY, this.boundingBox.maxZ)); + } + } + + for (j = 0; j < this.boundingBox.getZSize(); j += 4) + { + j += par3Random.nextInt(this.boundingBox.getZSize()); + + if (j + 3 > this.boundingBox.getZSize()) + { + break; + } + + structurecomponent1 = StructureMineshaftPieces.getNextMineShaftComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.minX - 1, this.boundingBox.minY + par3Random.nextInt(k) + 1, this.boundingBox.minZ + j, 1, i); + + if (structurecomponent1 != null) + { + structureboundingbox = structurecomponent1.getBoundingBox(); + this.roomsLinkedToTheRoom.add(new StructureBoundingBox(this.boundingBox.minX, structureboundingbox.minY, structureboundingbox.minZ, this.boundingBox.minX + 1, structureboundingbox.maxY, structureboundingbox.maxZ)); + } + } + + for (j = 0; j < this.boundingBox.getZSize(); j += 4) + { + j += par3Random.nextInt(this.boundingBox.getZSize()); + + if (j + 3 > this.boundingBox.getZSize()) + { + break; + } + + structurecomponent1 = StructureMineshaftPieces.getNextMineShaftComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.maxX + 1, this.boundingBox.minY + par3Random.nextInt(k) + 1, this.boundingBox.minZ + j, 3, i); + + if (structurecomponent1 != null) + { + structureboundingbox = structurecomponent1.getBoundingBox(); + this.roomsLinkedToTheRoom.add(new StructureBoundingBox(this.boundingBox.maxX - 1, structureboundingbox.minY, structureboundingbox.minZ, this.boundingBox.maxX, structureboundingbox.maxY, structureboundingbox.maxZ)); + } + } + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + if (this.isLiquidInStructureBoundingBox(par1World, par3StructureBoundingBox)) + { + return false; + } + else + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, this.boundingBox.minX, this.boundingBox.minY, this.boundingBox.minZ, this.boundingBox.maxX, this.boundingBox.minY, this.boundingBox.maxZ, Blocks.dirt, Blocks.air, true); + this.fillWithBlocks(par1World, par3StructureBoundingBox, this.boundingBox.minX, this.boundingBox.minY + 1, this.boundingBox.minZ, this.boundingBox.maxX, Math.min(this.boundingBox.minY + 3, this.boundingBox.maxY), this.boundingBox.maxZ, Blocks.air, Blocks.air, false); + Iterator iterator = this.roomsLinkedToTheRoom.iterator(); + + while (iterator.hasNext()) + { + StructureBoundingBox structureboundingbox1 = (StructureBoundingBox)iterator.next(); + this.fillWithBlocks(par1World, par3StructureBoundingBox, structureboundingbox1.minX, structureboundingbox1.maxY - 2, structureboundingbox1.minZ, structureboundingbox1.maxX, structureboundingbox1.maxY, structureboundingbox1.maxZ, Blocks.air, Blocks.air, false); + } + + this.func_151547_a(par1World, par3StructureBoundingBox, this.boundingBox.minX, this.boundingBox.minY + 4, this.boundingBox.minZ, this.boundingBox.maxX, this.boundingBox.maxY, this.boundingBox.maxZ, Blocks.air, false); + return true; + } + } + + protected void func_143012_a(NBTTagCompound par1NBTTagCompound) + { + NBTTagList nbttaglist = new NBTTagList(); + Iterator iterator = this.roomsLinkedToTheRoom.iterator(); + + while (iterator.hasNext()) + { + StructureBoundingBox structureboundingbox = (StructureBoundingBox)iterator.next(); + nbttaglist.appendTag(structureboundingbox.func_151535_h()); + } + + par1NBTTagCompound.setTag("Entrances", nbttaglist); + } + + protected void func_143011_b(NBTTagCompound par1NBTTagCompound) + { + NBTTagList nbttaglist = par1NBTTagCompound.getTagList("Entrances", 11); + + for (int i = 0; i < nbttaglist.tagCount(); ++i) + { + this.roomsLinkedToTheRoom.add(new StructureBoundingBox(nbttaglist.func_150306_c(i))); + } + } + } + + public static class Stairs extends StructureComponent + { + private static final String __OBFID = "CL_00000449"; + + public Stairs() {} + + public Stairs(int par1, Random par2Random, StructureBoundingBox par3StructureBoundingBox, int par4) + { + super(par1); + this.coordBaseMode = par4; + this.boundingBox = par3StructureBoundingBox; + } + + protected void func_143012_a(NBTTagCompound par1NBTTagCompound) {} + + protected void func_143011_b(NBTTagCompound par1NBTTagCompound) {} + + public static StructureBoundingBox findValidPlacement(List par0List, Random par1Random, int par2, int par3, int par4, int par5) + { + StructureBoundingBox structureboundingbox = new StructureBoundingBox(par2, par3 - 5, par4, par2, par3 + 2, par4); + + switch (par5) + { + case 0: + structureboundingbox.maxX = par2 + 2; + structureboundingbox.maxZ = par4 + 8; + break; + case 1: + structureboundingbox.minX = par2 - 8; + structureboundingbox.maxZ = par4 + 2; + break; + case 2: + structureboundingbox.maxX = par2 + 2; + structureboundingbox.minZ = par4 - 8; + break; + case 3: + structureboundingbox.maxX = par2 + 8; + structureboundingbox.maxZ = par4 + 2; + } + + return StructureComponent.findIntersecting(par0List, structureboundingbox) != null ? null : structureboundingbox; + } + + public void buildComponent(StructureComponent par1StructureComponent, List par2List, Random par3Random) + { + int i = this.getComponentType(); + + switch (this.coordBaseMode) + { + case 0: + StructureMineshaftPieces.getNextMineShaftComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.minX, this.boundingBox.minY, this.boundingBox.maxZ + 1, 0, i); + break; + case 1: + StructureMineshaftPieces.getNextMineShaftComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.minX - 1, this.boundingBox.minY, this.boundingBox.minZ, 1, i); + break; + case 2: + StructureMineshaftPieces.getNextMineShaftComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.minX, this.boundingBox.minY, this.boundingBox.minZ - 1, 2, i); + break; + case 3: + StructureMineshaftPieces.getNextMineShaftComponent(par1StructureComponent, par2List, par3Random, this.boundingBox.maxX + 1, this.boundingBox.minY, this.boundingBox.minZ, 3, i); + } + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + if (this.isLiquidInStructureBoundingBox(par1World, par3StructureBoundingBox)) + { + return false; + } + else + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 5, 0, 2, 7, 1, Blocks.air, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 0, 7, 2, 2, 8, Blocks.air, Blocks.air, false); + + for (int i = 0; i < 5; ++i) + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 5 - i - (i < 4 ? 1 : 0), 2 + i, 2, 7 - i, 2 + i, Blocks.air, Blocks.air, false); + } + + return true; + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/structure/StructureMineshaftStart.java b/src/main/java/net/minecraft/world/gen/structure/StructureMineshaftStart.java new file mode 100644 index 0000000..eed34eb --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/structure/StructureMineshaftStart.java @@ -0,0 +1,21 @@ +package net.minecraft.world.gen.structure; + +import java.util.Random; +import net.minecraft.world.World; + +public class StructureMineshaftStart extends StructureStart +{ + private static final String __OBFID = "CL_00000450"; + + public StructureMineshaftStart() {} + + public StructureMineshaftStart(World par1World, Random par2Random, int par3, int par4) + { + super(par3, par4); + StructureMineshaftPieces.Room room = new StructureMineshaftPieces.Room(0, par2Random, (par3 << 4) + 2, (par4 << 4) + 2); + this.components.add(room); + room.buildComponent(room, this.components, par2Random); + this.updateBoundingBox(); + this.markAvailableHeight(par1World, par2Random, 10); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/structure/StructureNetherBridgePieces.java b/src/main/java/net/minecraft/world/gen/structure/StructureNetherBridgePieces.java new file mode 100644 index 0000000..89f8461 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/structure/StructureNetherBridgePieces.java @@ -0,0 +1,1416 @@ +package net.minecraft.world.gen.structure; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntityMobSpawner; +import net.minecraft.util.WeightedRandomChestContent; +import net.minecraft.world.World; + +public class StructureNetherBridgePieces +{ + private static final StructureNetherBridgePieces.PieceWeight[] primaryComponents = new StructureNetherBridgePieces.PieceWeight[] {new StructureNetherBridgePieces.PieceWeight(StructureNetherBridgePieces.Straight.class, 30, 0, true), new StructureNetherBridgePieces.PieceWeight(StructureNetherBridgePieces.Crossing3.class, 10, 4), new StructureNetherBridgePieces.PieceWeight(StructureNetherBridgePieces.Crossing.class, 10, 4), new StructureNetherBridgePieces.PieceWeight(StructureNetherBridgePieces.Stairs.class, 10, 3), new StructureNetherBridgePieces.PieceWeight(StructureNetherBridgePieces.Throne.class, 5, 2), new StructureNetherBridgePieces.PieceWeight(StructureNetherBridgePieces.Entrance.class, 5, 1)}; + private static final StructureNetherBridgePieces.PieceWeight[] secondaryComponents = new StructureNetherBridgePieces.PieceWeight[] {new StructureNetherBridgePieces.PieceWeight(StructureNetherBridgePieces.Corridor5.class, 25, 0, true), new StructureNetherBridgePieces.PieceWeight(StructureNetherBridgePieces.Crossing2.class, 15, 5), new StructureNetherBridgePieces.PieceWeight(StructureNetherBridgePieces.Corridor2.class, 5, 10), new StructureNetherBridgePieces.PieceWeight(StructureNetherBridgePieces.Corridor.class, 5, 10), new StructureNetherBridgePieces.PieceWeight(StructureNetherBridgePieces.Corridor3.class, 10, 3, true), new StructureNetherBridgePieces.PieceWeight(StructureNetherBridgePieces.Corridor4.class, 7, 2), new StructureNetherBridgePieces.PieceWeight(StructureNetherBridgePieces.NetherStalkRoom.class, 5, 2)}; + private static final String __OBFID = "CL_00000453"; + + public static void registerNetherFortressPieces() + { + MapGenStructureIO.func_143031_a(StructureNetherBridgePieces.Crossing3.class, "NeBCr"); + MapGenStructureIO.func_143031_a(StructureNetherBridgePieces.End.class, "NeBEF"); + MapGenStructureIO.func_143031_a(StructureNetherBridgePieces.Straight.class, "NeBS"); + MapGenStructureIO.func_143031_a(StructureNetherBridgePieces.Corridor3.class, "NeCCS"); + MapGenStructureIO.func_143031_a(StructureNetherBridgePieces.Corridor4.class, "NeCTB"); + MapGenStructureIO.func_143031_a(StructureNetherBridgePieces.Entrance.class, "NeCE"); + MapGenStructureIO.func_143031_a(StructureNetherBridgePieces.Crossing2.class, "NeSCSC"); + MapGenStructureIO.func_143031_a(StructureNetherBridgePieces.Corridor.class, "NeSCLT"); + MapGenStructureIO.func_143031_a(StructureNetherBridgePieces.Corridor5.class, "NeSC"); + MapGenStructureIO.func_143031_a(StructureNetherBridgePieces.Corridor2.class, "NeSCRT"); + MapGenStructureIO.func_143031_a(StructureNetherBridgePieces.NetherStalkRoom.class, "NeCSR"); + MapGenStructureIO.func_143031_a(StructureNetherBridgePieces.Throne.class, "NeMT"); + MapGenStructureIO.func_143031_a(StructureNetherBridgePieces.Crossing.class, "NeRC"); + MapGenStructureIO.func_143031_a(StructureNetherBridgePieces.Stairs.class, "NeSR"); + MapGenStructureIO.func_143031_a(StructureNetherBridgePieces.Start.class, "NeStart"); + } + + private static StructureNetherBridgePieces.Piece createNextComponentRandom(StructureNetherBridgePieces.PieceWeight par0StructureNetherBridgePieceWeight, List par1List, Random par2Random, int par3, int par4, int par5, int par6, int par7) + { + Class oclass = par0StructureNetherBridgePieceWeight.weightClass; + Object object = null; + + if (oclass == StructureNetherBridgePieces.Straight.class) + { + object = StructureNetherBridgePieces.Straight.createValidComponent(par1List, par2Random, par3, par4, par5, par6, par7); + } + else if (oclass == StructureNetherBridgePieces.Crossing3.class) + { + object = StructureNetherBridgePieces.Crossing3.createValidComponent(par1List, par2Random, par3, par4, par5, par6, par7); + } + else if (oclass == StructureNetherBridgePieces.Crossing.class) + { + object = StructureNetherBridgePieces.Crossing.createValidComponent(par1List, par2Random, par3, par4, par5, par6, par7); + } + else if (oclass == StructureNetherBridgePieces.Stairs.class) + { + object = StructureNetherBridgePieces.Stairs.createValidComponent(par1List, par2Random, par3, par4, par5, par6, par7); + } + else if (oclass == StructureNetherBridgePieces.Throne.class) + { + object = StructureNetherBridgePieces.Throne.createValidComponent(par1List, par2Random, par3, par4, par5, par6, par7); + } + else if (oclass == StructureNetherBridgePieces.Entrance.class) + { + object = StructureNetherBridgePieces.Entrance.createValidComponent(par1List, par2Random, par3, par4, par5, par6, par7); + } + else if (oclass == StructureNetherBridgePieces.Corridor5.class) + { + object = StructureNetherBridgePieces.Corridor5.createValidComponent(par1List, par2Random, par3, par4, par5, par6, par7); + } + else if (oclass == StructureNetherBridgePieces.Corridor2.class) + { + object = StructureNetherBridgePieces.Corridor2.createValidComponent(par1List, par2Random, par3, par4, par5, par6, par7); + } + else if (oclass == StructureNetherBridgePieces.Corridor.class) + { + object = StructureNetherBridgePieces.Corridor.createValidComponent(par1List, par2Random, par3, par4, par5, par6, par7); + } + else if (oclass == StructureNetherBridgePieces.Corridor3.class) + { + object = StructureNetherBridgePieces.Corridor3.createValidComponent(par1List, par2Random, par3, par4, par5, par6, par7); + } + else if (oclass == StructureNetherBridgePieces.Corridor4.class) + { + object = StructureNetherBridgePieces.Corridor4.createValidComponent(par1List, par2Random, par3, par4, par5, par6, par7); + } + else if (oclass == StructureNetherBridgePieces.Crossing2.class) + { + object = StructureNetherBridgePieces.Crossing2.createValidComponent(par1List, par2Random, par3, par4, par5, par6, par7); + } + else if (oclass == StructureNetherBridgePieces.NetherStalkRoom.class) + { + object = StructureNetherBridgePieces.NetherStalkRoom.createValidComponent(par1List, par2Random, par3, par4, par5, par6, par7); + } + + return (StructureNetherBridgePieces.Piece)object; + } + + public static class Corridor extends StructureNetherBridgePieces.Piece + { + private boolean field_111021_b; + private static final String __OBFID = "CL_00000461"; + + public Corridor() {} + + public Corridor(int par1, Random par2Random, StructureBoundingBox par3StructureBoundingBox, int par4) + { + super(par1); + this.coordBaseMode = par4; + this.boundingBox = par3StructureBoundingBox; + this.field_111021_b = par2Random.nextInt(3) == 0; + } + + protected void func_143011_b(NBTTagCompound par1NBTTagCompound) + { + super.func_143011_b(par1NBTTagCompound); + this.field_111021_b = par1NBTTagCompound.getBoolean("Chest"); + } + + protected void func_143012_a(NBTTagCompound par1NBTTagCompound) + { + super.func_143012_a(par1NBTTagCompound); + par1NBTTagCompound.setBoolean("Chest", this.field_111021_b); + } + + public void buildComponent(StructureComponent par1StructureComponent, List par2List, Random par3Random) + { + this.getNextComponentX((StructureNetherBridgePieces.Start)par1StructureComponent, par2List, par3Random, 0, 1, true); + } + + public static StructureNetherBridgePieces.Corridor createValidComponent(List par0List, Random par1Random, int par2, int par3, int par4, int par5, int par6) + { + StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(par2, par3, par4, -1, 0, 0, 5, 7, 5, par5); + return isAboveGround(structureboundingbox) && StructureComponent.findIntersecting(par0List, structureboundingbox) == null ? new StructureNetherBridgePieces.Corridor(par6, par1Random, structureboundingbox, par5) : null; + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 0, 0, 4, 1, 4, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 2, 0, 4, 5, 4, Blocks.air, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 2, 0, 4, 5, 4, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 3, 1, 4, 4, 1, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 3, 3, 4, 4, 3, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 2, 0, 0, 5, 0, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 2, 4, 3, 5, 4, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 3, 4, 1, 4, 4, Blocks.nether_brick_fence, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 3, 3, 4, 3, 4, 4, Blocks.nether_brick_fence, Blocks.nether_brick, false); + int i; + int j; + + if (this.field_111021_b) + { + i = this.getYWithOffset(2); + j = this.getXWithOffset(3, 3); + int k = this.getZWithOffset(3, 3); + + if (par3StructureBoundingBox.isVecInside(j, i, k)) + { + this.field_111021_b = false; + this.generateStructureChestContents(par1World, par3StructureBoundingBox, par2Random, 3, 2, 3, field_111019_a, 2 + par2Random.nextInt(4)); + } + } + + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 6, 0, 4, 6, 4, Blocks.nether_brick, Blocks.nether_brick, false); + + for (i = 0; i <= 4; ++i) + { + for (j = 0; j <= 4; ++j) + { + this.func_151554_b(par1World, Blocks.nether_brick, 0, i, -1, j, par3StructureBoundingBox); + } + } + + return true; + } + } + + public static class Corridor2 extends StructureNetherBridgePieces.Piece + { + private boolean field_111020_b; + private static final String __OBFID = "CL_00000463"; + + public Corridor2() {} + + public Corridor2(int par1, Random par2Random, StructureBoundingBox par3StructureBoundingBox, int par4) + { + super(par1); + this.coordBaseMode = par4; + this.boundingBox = par3StructureBoundingBox; + this.field_111020_b = par2Random.nextInt(3) == 0; + } + + protected void func_143011_b(NBTTagCompound par1NBTTagCompound) + { + super.func_143011_b(par1NBTTagCompound); + this.field_111020_b = par1NBTTagCompound.getBoolean("Chest"); + } + + protected void func_143012_a(NBTTagCompound par1NBTTagCompound) + { + super.func_143012_a(par1NBTTagCompound); + par1NBTTagCompound.setBoolean("Chest", this.field_111020_b); + } + + public void buildComponent(StructureComponent par1StructureComponent, List par2List, Random par3Random) + { + this.getNextComponentZ((StructureNetherBridgePieces.Start)par1StructureComponent, par2List, par3Random, 0, 1, true); + } + + public static StructureNetherBridgePieces.Corridor2 createValidComponent(List par0List, Random par1Random, int par2, int par3, int par4, int par5, int par6) + { + StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(par2, par3, par4, -1, 0, 0, 5, 7, 5, par5); + return isAboveGround(structureboundingbox) && StructureComponent.findIntersecting(par0List, structureboundingbox) == null ? new StructureNetherBridgePieces.Corridor2(par6, par1Random, structureboundingbox, par5) : null; + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 0, 0, 4, 1, 4, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 2, 0, 4, 5, 4, Blocks.air, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 2, 0, 0, 5, 4, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 3, 1, 0, 4, 1, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 3, 3, 0, 4, 3, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 2, 0, 4, 5, 0, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 2, 4, 4, 5, 4, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 3, 4, 1, 4, 4, Blocks.nether_brick_fence, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 3, 3, 4, 3, 4, 4, Blocks.nether_brick_fence, Blocks.nether_brick, false); + int i; + int j; + + if (this.field_111020_b) + { + i = this.getYWithOffset(2); + j = this.getXWithOffset(1, 3); + int k = this.getZWithOffset(1, 3); + + if (par3StructureBoundingBox.isVecInside(j, i, k)) + { + this.field_111020_b = false; + this.generateStructureChestContents(par1World, par3StructureBoundingBox, par2Random, 1, 2, 3, field_111019_a, 2 + par2Random.nextInt(4)); + } + } + + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 6, 0, 4, 6, 4, Blocks.nether_brick, Blocks.nether_brick, false); + + for (i = 0; i <= 4; ++i) + { + for (j = 0; j <= 4; ++j) + { + this.func_151554_b(par1World, Blocks.nether_brick, 0, i, -1, j, par3StructureBoundingBox); + } + } + + return true; + } + } + + public static class Corridor3 extends StructureNetherBridgePieces.Piece + { + private static final String __OBFID = "CL_00000457"; + + public Corridor3() {} + + public Corridor3(int par1, Random par2Random, StructureBoundingBox par3StructureBoundingBox, int par4) + { + super(par1); + this.coordBaseMode = par4; + this.boundingBox = par3StructureBoundingBox; + } + + public void buildComponent(StructureComponent par1StructureComponent, List par2List, Random par3Random) + { + this.getNextComponentNormal((StructureNetherBridgePieces.Start)par1StructureComponent, par2List, par3Random, 1, 0, true); + } + + public static StructureNetherBridgePieces.Corridor3 createValidComponent(List par0List, Random par1Random, int par2, int par3, int par4, int par5, int par6) + { + StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(par2, par3, par4, -1, -7, 0, 5, 14, 10, par5); + return isAboveGround(structureboundingbox) && StructureComponent.findIntersecting(par0List, structureboundingbox) == null ? new StructureNetherBridgePieces.Corridor3(par6, par1Random, structureboundingbox, par5) : null; + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + int i = this.getMetadataWithOffset(Blocks.nether_brick_stairs, 2); + + for (int j = 0; j <= 9; ++j) + { + int k = Math.max(1, 7 - j); + int l = Math.min(Math.max(k + 5, 14 - j), 13); + int i1 = j; + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 0, j, 4, k, j, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, k + 1, j, 3, l - 1, j, Blocks.air, Blocks.air, false); + + if (j <= 6) + { + this.placeBlockAtCurrentPosition(par1World, Blocks.nether_brick_stairs, i, 1, k + 1, j, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.nether_brick_stairs, i, 2, k + 1, j, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.nether_brick_stairs, i, 3, k + 1, j, par3StructureBoundingBox); + } + + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, l, j, 4, l, j, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, k + 1, j, 0, l - 1, j, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, k + 1, j, 4, l - 1, j, Blocks.nether_brick, Blocks.nether_brick, false); + + if ((j & 1) == 0) + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, k + 2, j, 0, k + 3, j, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, k + 2, j, 4, k + 3, j, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + } + + for (int j1 = 0; j1 <= 4; ++j1) + { + this.func_151554_b(par1World, Blocks.nether_brick, 0, j1, -1, i1, par3StructureBoundingBox); + } + } + + return true; + } + } + + public static class Corridor4 extends StructureNetherBridgePieces.Piece + { + private static final String __OBFID = "CL_00000458"; + + public Corridor4() {} + + public Corridor4(int par1, Random par2Random, StructureBoundingBox par3StructureBoundingBox, int par4) + { + super(par1); + this.coordBaseMode = par4; + this.boundingBox = par3StructureBoundingBox; + } + + public void buildComponent(StructureComponent par1StructureComponent, List par2List, Random par3Random) + { + byte b0 = 1; + + if (this.coordBaseMode == 1 || this.coordBaseMode == 2) + { + b0 = 5; + } + + this.getNextComponentX((StructureNetherBridgePieces.Start)par1StructureComponent, par2List, par3Random, 0, b0, par3Random.nextInt(8) > 0); + this.getNextComponentZ((StructureNetherBridgePieces.Start)par1StructureComponent, par2List, par3Random, 0, b0, par3Random.nextInt(8) > 0); + } + + public static StructureNetherBridgePieces.Corridor4 createValidComponent(List par0List, Random par1Random, int par2, int par3, int par4, int par5, int par6) + { + StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(par2, par3, par4, -3, 0, 0, 9, 7, 9, par5); + return isAboveGround(structureboundingbox) && StructureComponent.findIntersecting(par0List, structureboundingbox) == null ? new StructureNetherBridgePieces.Corridor4(par6, par1Random, structureboundingbox, par5) : null; + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 0, 0, 8, 1, 8, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 2, 0, 8, 5, 8, Blocks.air, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 6, 0, 8, 6, 5, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 2, 0, 2, 5, 0, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 6, 2, 0, 8, 5, 0, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 3, 0, 1, 4, 0, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 7, 3, 0, 7, 4, 0, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 2, 4, 8, 2, 8, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 1, 4, 2, 2, 4, Blocks.air, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 6, 1, 4, 7, 2, 4, Blocks.air, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 3, 8, 8, 3, 8, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 3, 6, 0, 3, 7, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 8, 3, 6, 8, 3, 7, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 3, 4, 0, 5, 5, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 8, 3, 4, 8, 5, 5, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 3, 5, 2, 5, 5, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 6, 3, 5, 7, 5, 5, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 4, 5, 1, 5, 5, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 7, 4, 5, 7, 5, 5, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + + for (int i = 0; i <= 5; ++i) + { + for (int j = 0; j <= 8; ++j) + { + this.func_151554_b(par1World, Blocks.nether_brick, 0, j, -1, i, par3StructureBoundingBox); + } + } + + return true; + } + } + + public static class Corridor5 extends StructureNetherBridgePieces.Piece + { + private static final String __OBFID = "CL_00000462"; + + public Corridor5() {} + + public Corridor5(int par1, Random par2Random, StructureBoundingBox par3StructureBoundingBox, int par4) + { + super(par1); + this.coordBaseMode = par4; + this.boundingBox = par3StructureBoundingBox; + } + + public void buildComponent(StructureComponent par1StructureComponent, List par2List, Random par3Random) + { + this.getNextComponentNormal((StructureNetherBridgePieces.Start)par1StructureComponent, par2List, par3Random, 1, 0, true); + } + + public static StructureNetherBridgePieces.Corridor5 createValidComponent(List par0List, Random par1Random, int par2, int par3, int par4, int par5, int par6) + { + StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(par2, par3, par4, -1, 0, 0, 5, 7, 5, par5); + return isAboveGround(structureboundingbox) && StructureComponent.findIntersecting(par0List, structureboundingbox) == null ? new StructureNetherBridgePieces.Corridor5(par6, par1Random, structureboundingbox, par5) : null; + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 0, 0, 4, 1, 4, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 2, 0, 4, 5, 4, Blocks.air, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 2, 0, 0, 5, 4, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 2, 0, 4, 5, 4, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 3, 1, 0, 4, 1, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 3, 3, 0, 4, 3, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 3, 1, 4, 4, 1, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 3, 3, 4, 4, 3, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 6, 0, 4, 6, 4, Blocks.nether_brick, Blocks.nether_brick, false); + + for (int i = 0; i <= 4; ++i) + { + for (int j = 0; j <= 4; ++j) + { + this.func_151554_b(par1World, Blocks.nether_brick, 0, i, -1, j, par3StructureBoundingBox); + } + } + + return true; + } + } + + public static class Crossing extends StructureNetherBridgePieces.Piece + { + private static final String __OBFID = "CL_00000468"; + + public Crossing() {} + + public Crossing(int par1, Random par2Random, StructureBoundingBox par3StructureBoundingBox, int par4) + { + super(par1); + this.coordBaseMode = par4; + this.boundingBox = par3StructureBoundingBox; + } + + public void buildComponent(StructureComponent par1StructureComponent, List par2List, Random par3Random) + { + this.getNextComponentNormal((StructureNetherBridgePieces.Start)par1StructureComponent, par2List, par3Random, 2, 0, false); + this.getNextComponentX((StructureNetherBridgePieces.Start)par1StructureComponent, par2List, par3Random, 0, 2, false); + this.getNextComponentZ((StructureNetherBridgePieces.Start)par1StructureComponent, par2List, par3Random, 0, 2, false); + } + + public static StructureNetherBridgePieces.Crossing createValidComponent(List par0List, Random par1Random, int par2, int par3, int par4, int par5, int par6) + { + StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(par2, par3, par4, -2, 0, 0, 7, 9, 7, par5); + return isAboveGround(structureboundingbox) && StructureComponent.findIntersecting(par0List, structureboundingbox) == null ? new StructureNetherBridgePieces.Crossing(par6, par1Random, structureboundingbox, par5) : null; + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 0, 0, 6, 1, 6, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 2, 0, 6, 7, 6, Blocks.air, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 2, 0, 1, 6, 0, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 2, 6, 1, 6, 6, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 5, 2, 0, 6, 6, 0, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 5, 2, 6, 6, 6, 6, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 2, 0, 0, 6, 1, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 2, 5, 0, 6, 6, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 6, 2, 0, 6, 6, 1, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 6, 2, 5, 6, 6, 6, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 2, 6, 0, 4, 6, 0, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 2, 5, 0, 4, 5, 0, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 2, 6, 6, 4, 6, 6, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 2, 5, 6, 4, 5, 6, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 6, 2, 0, 6, 4, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 5, 2, 0, 5, 4, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 6, 6, 2, 6, 6, 4, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 6, 5, 2, 6, 5, 4, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + + for (int i = 0; i <= 6; ++i) + { + for (int j = 0; j <= 6; ++j) + { + this.func_151554_b(par1World, Blocks.nether_brick, 0, i, -1, j, par3StructureBoundingBox); + } + } + + return true; + } + } + + public static class Crossing2 extends StructureNetherBridgePieces.Piece + { + private static final String __OBFID = "CL_00000460"; + + public Crossing2() {} + + public Crossing2(int par1, Random par2Random, StructureBoundingBox par3StructureBoundingBox, int par4) + { + super(par1); + this.coordBaseMode = par4; + this.boundingBox = par3StructureBoundingBox; + } + + public void buildComponent(StructureComponent par1StructureComponent, List par2List, Random par3Random) + { + this.getNextComponentNormal((StructureNetherBridgePieces.Start)par1StructureComponent, par2List, par3Random, 1, 0, true); + this.getNextComponentX((StructureNetherBridgePieces.Start)par1StructureComponent, par2List, par3Random, 0, 1, true); + this.getNextComponentZ((StructureNetherBridgePieces.Start)par1StructureComponent, par2List, par3Random, 0, 1, true); + } + + public static StructureNetherBridgePieces.Crossing2 createValidComponent(List par0List, Random par1Random, int par2, int par3, int par4, int par5, int par6) + { + StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(par2, par3, par4, -1, 0, 0, 5, 7, 5, par5); + return isAboveGround(structureboundingbox) && StructureComponent.findIntersecting(par0List, structureboundingbox) == null ? new StructureNetherBridgePieces.Crossing2(par6, par1Random, structureboundingbox, par5) : null; + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 0, 0, 4, 1, 4, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 2, 0, 4, 5, 4, Blocks.air, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 2, 0, 0, 5, 0, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 2, 0, 4, 5, 0, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 2, 4, 0, 5, 4, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 2, 4, 4, 5, 4, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 6, 0, 4, 6, 4, Blocks.nether_brick, Blocks.nether_brick, false); + + for (int i = 0; i <= 4; ++i) + { + for (int j = 0; j <= 4; ++j) + { + this.func_151554_b(par1World, Blocks.nether_brick, 0, i, -1, j, par3StructureBoundingBox); + } + } + + return true; + } + } + + public static class Crossing3 extends StructureNetherBridgePieces.Piece + { + private static final String __OBFID = "CL_00000454"; + + public Crossing3() {} + + public Crossing3(int par1, Random par2Random, StructureBoundingBox par3StructureBoundingBox, int par4) + { + super(par1); + this.coordBaseMode = par4; + this.boundingBox = par3StructureBoundingBox; + } + + protected Crossing3(Random par1Random, int par2, int par3) + { + super(0); + this.coordBaseMode = par1Random.nextInt(4); + + switch (this.coordBaseMode) + { + case 0: + case 2: + this.boundingBox = new StructureBoundingBox(par2, 64, par3, par2 + 19 - 1, 73, par3 + 19 - 1); + break; + default: + this.boundingBox = new StructureBoundingBox(par2, 64, par3, par2 + 19 - 1, 73, par3 + 19 - 1); + } + } + + public void buildComponent(StructureComponent par1StructureComponent, List par2List, Random par3Random) + { + this.getNextComponentNormal((StructureNetherBridgePieces.Start)par1StructureComponent, par2List, par3Random, 8, 3, false); + this.getNextComponentX((StructureNetherBridgePieces.Start)par1StructureComponent, par2List, par3Random, 3, 8, false); + this.getNextComponentZ((StructureNetherBridgePieces.Start)par1StructureComponent, par2List, par3Random, 3, 8, false); + } + + public static StructureNetherBridgePieces.Crossing3 createValidComponent(List par0List, Random par1Random, int par2, int par3, int par4, int par5, int par6) + { + StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(par2, par3, par4, -8, -3, 0, 19, 10, 19, par5); + return isAboveGround(structureboundingbox) && StructureComponent.findIntersecting(par0List, structureboundingbox) == null ? new StructureNetherBridgePieces.Crossing3(par6, par1Random, structureboundingbox, par5) : null; + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, 7, 3, 0, 11, 4, 18, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 3, 7, 18, 4, 11, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 8, 5, 0, 10, 7, 18, Blocks.air, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 5, 8, 18, 7, 10, Blocks.air, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 7, 5, 0, 7, 5, 7, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 7, 5, 11, 7, 5, 18, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 11, 5, 0, 11, 5, 7, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 11, 5, 11, 11, 5, 18, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 5, 7, 7, 5, 7, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 11, 5, 7, 18, 5, 7, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 5, 11, 7, 5, 11, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 11, 5, 11, 18, 5, 11, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 7, 2, 0, 11, 2, 5, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 7, 2, 13, 11, 2, 18, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 7, 0, 0, 11, 1, 3, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 7, 0, 15, 11, 1, 18, Blocks.nether_brick, Blocks.nether_brick, false); + int i; + int j; + + for (i = 7; i <= 11; ++i) + { + for (j = 0; j <= 2; ++j) + { + this.func_151554_b(par1World, Blocks.nether_brick, 0, i, -1, j, par3StructureBoundingBox); + this.func_151554_b(par1World, Blocks.nether_brick, 0, i, -1, 18 - j, par3StructureBoundingBox); + } + } + + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 2, 7, 5, 2, 11, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 13, 2, 7, 18, 2, 11, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 0, 7, 3, 1, 11, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 15, 0, 7, 18, 1, 11, Blocks.nether_brick, Blocks.nether_brick, false); + + for (i = 0; i <= 2; ++i) + { + for (j = 7; j <= 11; ++j) + { + this.func_151554_b(par1World, Blocks.nether_brick, 0, i, -1, j, par3StructureBoundingBox); + this.func_151554_b(par1World, Blocks.nether_brick, 0, 18 - i, -1, j, par3StructureBoundingBox); + } + } + + return true; + } + } + + public static class End extends StructureNetherBridgePieces.Piece + { + private int fillSeed; + private static final String __OBFID = "CL_00000455"; + + public End() {} + + public End(int par1, Random par2Random, StructureBoundingBox par3StructureBoundingBox, int par4) + { + super(par1); + this.coordBaseMode = par4; + this.boundingBox = par3StructureBoundingBox; + this.fillSeed = par2Random.nextInt(); + } + + public static StructureNetherBridgePieces.End func_74971_a(List par0List, Random par1Random, int par2, int par3, int par4, int par5, int par6) + { + StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(par2, par3, par4, -1, -3, 0, 5, 10, 8, par5); + return isAboveGround(structureboundingbox) && StructureComponent.findIntersecting(par0List, structureboundingbox) == null ? new StructureNetherBridgePieces.End(par6, par1Random, structureboundingbox, par5) : null; + } + + protected void func_143011_b(NBTTagCompound par1NBTTagCompound) + { + super.func_143011_b(par1NBTTagCompound); + this.fillSeed = par1NBTTagCompound.getInteger("Seed"); + } + + protected void func_143012_a(NBTTagCompound par1NBTTagCompound) + { + super.func_143012_a(par1NBTTagCompound); + par1NBTTagCompound.setInteger("Seed", this.fillSeed); + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + Random random1 = new Random((long)this.fillSeed); + int i; + int j; + int k; + + for (i = 0; i <= 4; ++i) + { + for (j = 3; j <= 4; ++j) + { + k = random1.nextInt(8); + this.fillWithBlocks(par1World, par3StructureBoundingBox, i, j, 0, i, j, k, Blocks.nether_brick, Blocks.nether_brick, false); + } + } + + i = random1.nextInt(8); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 5, 0, 0, 5, i, Blocks.nether_brick, Blocks.nether_brick, false); + i = random1.nextInt(8); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 5, 0, 4, 5, i, Blocks.nether_brick, Blocks.nether_brick, false); + + for (i = 0; i <= 4; ++i) + { + j = random1.nextInt(5); + this.fillWithBlocks(par1World, par3StructureBoundingBox, i, 2, 0, i, 2, j, Blocks.nether_brick, Blocks.nether_brick, false); + } + + for (i = 0; i <= 4; ++i) + { + for (j = 0; j <= 1; ++j) + { + k = random1.nextInt(3); + this.fillWithBlocks(par1World, par3StructureBoundingBox, i, j, 0, i, j, k, Blocks.nether_brick, Blocks.nether_brick, false); + } + } + + return true; + } + } + + public static class Entrance extends StructureNetherBridgePieces.Piece + { + private static final String __OBFID = "CL_00000459"; + + public Entrance() {} + + public Entrance(int par1, Random par2Random, StructureBoundingBox par3StructureBoundingBox, int par4) + { + super(par1); + this.coordBaseMode = par4; + this.boundingBox = par3StructureBoundingBox; + } + + public void buildComponent(StructureComponent par1StructureComponent, List par2List, Random par3Random) + { + this.getNextComponentNormal((StructureNetherBridgePieces.Start)par1StructureComponent, par2List, par3Random, 5, 3, true); + } + + public static StructureNetherBridgePieces.Entrance createValidComponent(List par0List, Random par1Random, int par2, int par3, int par4, int par5, int par6) + { + StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(par2, par3, par4, -5, -3, 0, 13, 14, 13, par5); + return isAboveGround(structureboundingbox) && StructureComponent.findIntersecting(par0List, structureboundingbox) == null ? new StructureNetherBridgePieces.Entrance(par6, par1Random, structureboundingbox, par5) : null; + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 3, 0, 12, 4, 12, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 5, 0, 12, 13, 12, Blocks.air, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 5, 0, 1, 12, 12, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 11, 5, 0, 12, 12, 12, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 2, 5, 11, 4, 12, 12, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 8, 5, 11, 10, 12, 12, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 5, 9, 11, 7, 12, 12, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 2, 5, 0, 4, 12, 1, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 8, 5, 0, 10, 12, 1, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 5, 9, 0, 7, 12, 1, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 2, 11, 2, 10, 12, 10, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 5, 8, 0, 7, 8, 0, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + int i; + + for (i = 1; i <= 11; i += 2) + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, i, 10, 0, i, 11, 0, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, i, 10, 12, i, 11, 12, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 10, i, 0, 11, i, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 12, 10, i, 12, 11, i, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + this.placeBlockAtCurrentPosition(par1World, Blocks.nether_brick, 0, i, 13, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.nether_brick, 0, i, 13, 12, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.nether_brick, 0, 0, 13, i, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.nether_brick, 0, 12, 13, i, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.nether_brick_fence, 0, i + 1, 13, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.nether_brick_fence, 0, i + 1, 13, 12, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.nether_brick_fence, 0, 0, 13, i + 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.nether_brick_fence, 0, 12, 13, i + 1, par3StructureBoundingBox); + } + + this.placeBlockAtCurrentPosition(par1World, Blocks.nether_brick_fence, 0, 0, 13, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.nether_brick_fence, 0, 0, 13, 12, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.nether_brick_fence, 0, 0, 13, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.nether_brick_fence, 0, 12, 13, 0, par3StructureBoundingBox); + + for (i = 3; i <= 9; i += 2) + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 7, i, 1, 8, i, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 11, 7, i, 11, 8, i, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + } + + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 2, 0, 8, 2, 12, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 2, 4, 12, 2, 8, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 0, 0, 8, 1, 3, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 0, 9, 8, 1, 12, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 0, 4, 3, 1, 8, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 9, 0, 4, 12, 1, 8, Blocks.nether_brick, Blocks.nether_brick, false); + int j; + + for (i = 4; i <= 8; ++i) + { + for (j = 0; j <= 2; ++j) + { + this.func_151554_b(par1World, Blocks.nether_brick, 0, i, -1, j, par3StructureBoundingBox); + this.func_151554_b(par1World, Blocks.nether_brick, 0, i, -1, 12 - j, par3StructureBoundingBox); + } + } + + for (i = 0; i <= 2; ++i) + { + for (j = 4; j <= 8; ++j) + { + this.func_151554_b(par1World, Blocks.nether_brick, 0, i, -1, j, par3StructureBoundingBox); + this.func_151554_b(par1World, Blocks.nether_brick, 0, 12 - i, -1, j, par3StructureBoundingBox); + } + } + + this.fillWithBlocks(par1World, par3StructureBoundingBox, 5, 5, 5, 7, 5, 7, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 6, 1, 6, 6, 4, 6, Blocks.air, Blocks.air, false); + this.placeBlockAtCurrentPosition(par1World, Blocks.nether_brick, 0, 6, 0, 6, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.flowing_lava, 0, 6, 5, 6, par3StructureBoundingBox); + i = this.getXWithOffset(6, 6); + j = this.getYWithOffset(5); + int k = this.getZWithOffset(6, 6); + + if (par3StructureBoundingBox.isVecInside(i, j, k)) + { + par1World.scheduledUpdatesAreImmediate = true; + Blocks.flowing_lava.updateTick(par1World, i, j, k, par2Random); + par1World.scheduledUpdatesAreImmediate = false; + } + + return true; + } + } + + public static class NetherStalkRoom extends StructureNetherBridgePieces.Piece + { + private static final String __OBFID = "CL_00000464"; + + public NetherStalkRoom() {} + + public NetherStalkRoom(int par1, Random par2Random, StructureBoundingBox par3StructureBoundingBox, int par4) + { + super(par1); + this.coordBaseMode = par4; + this.boundingBox = par3StructureBoundingBox; + } + + public void buildComponent(StructureComponent par1StructureComponent, List par2List, Random par3Random) + { + this.getNextComponentNormal((StructureNetherBridgePieces.Start)par1StructureComponent, par2List, par3Random, 5, 3, true); + this.getNextComponentNormal((StructureNetherBridgePieces.Start)par1StructureComponent, par2List, par3Random, 5, 11, true); + } + + public static StructureNetherBridgePieces.NetherStalkRoom createValidComponent(List par0List, Random par1Random, int par2, int par3, int par4, int par5, int par6) + { + StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(par2, par3, par4, -5, -3, 0, 13, 14, 13, par5); + return isAboveGround(structureboundingbox) && StructureComponent.findIntersecting(par0List, structureboundingbox) == null ? new StructureNetherBridgePieces.NetherStalkRoom(par6, par1Random, structureboundingbox, par5) : null; + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 3, 0, 12, 4, 12, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 5, 0, 12, 13, 12, Blocks.air, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 5, 0, 1, 12, 12, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 11, 5, 0, 12, 12, 12, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 2, 5, 11, 4, 12, 12, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 8, 5, 11, 10, 12, 12, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 5, 9, 11, 7, 12, 12, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 2, 5, 0, 4, 12, 1, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 8, 5, 0, 10, 12, 1, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 5, 9, 0, 7, 12, 1, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 2, 11, 2, 10, 12, 10, Blocks.nether_brick, Blocks.nether_brick, false); + int i; + + for (i = 1; i <= 11; i += 2) + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, i, 10, 0, i, 11, 0, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, i, 10, 12, i, 11, 12, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 10, i, 0, 11, i, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 12, 10, i, 12, 11, i, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + this.placeBlockAtCurrentPosition(par1World, Blocks.nether_brick, 0, i, 13, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.nether_brick, 0, i, 13, 12, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.nether_brick, 0, 0, 13, i, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.nether_brick, 0, 12, 13, i, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.nether_brick_fence, 0, i + 1, 13, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.nether_brick_fence, 0, i + 1, 13, 12, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.nether_brick_fence, 0, 0, 13, i + 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.nether_brick_fence, 0, 12, 13, i + 1, par3StructureBoundingBox); + } + + this.placeBlockAtCurrentPosition(par1World, Blocks.nether_brick_fence, 0, 0, 13, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.nether_brick_fence, 0, 0, 13, 12, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.nether_brick_fence, 0, 0, 13, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.nether_brick_fence, 0, 12, 13, 0, par3StructureBoundingBox); + + for (i = 3; i <= 9; i += 2) + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 7, i, 1, 8, i, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 11, 7, i, 11, 8, i, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + } + + i = this.getMetadataWithOffset(Blocks.nether_brick_stairs, 3); + int j; + int k; + int l; + + for (j = 0; j <= 6; ++j) + { + k = j + 4; + + for (l = 5; l <= 7; ++l) + { + this.placeBlockAtCurrentPosition(par1World, Blocks.nether_brick_stairs, i, l, 5 + j, k, par3StructureBoundingBox); + } + + if (k >= 5 && k <= 8) + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, 5, 5, k, 7, j + 4, k, Blocks.nether_brick, Blocks.nether_brick, false); + } + else if (k >= 9 && k <= 10) + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, 5, 8, k, 7, j + 4, k, Blocks.nether_brick, Blocks.nether_brick, false); + } + + if (j >= 1) + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, 5, 6 + j, k, 7, 9 + j, k, Blocks.air, Blocks.air, false); + } + } + + for (j = 5; j <= 7; ++j) + { + this.placeBlockAtCurrentPosition(par1World, Blocks.nether_brick_stairs, i, j, 12, 11, par3StructureBoundingBox); + } + + this.fillWithBlocks(par1World, par3StructureBoundingBox, 5, 6, 7, 5, 7, 7, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 7, 6, 7, 7, 7, 7, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 5, 13, 12, 7, 13, 12, Blocks.air, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 2, 5, 2, 3, 5, 3, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 2, 5, 9, 3, 5, 10, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 2, 5, 4, 2, 5, 8, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 9, 5, 2, 10, 5, 3, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 9, 5, 9, 10, 5, 10, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 10, 5, 4, 10, 5, 8, Blocks.nether_brick, Blocks.nether_brick, false); + j = this.getMetadataWithOffset(Blocks.nether_brick_stairs, 0); + k = this.getMetadataWithOffset(Blocks.nether_brick_stairs, 1); + this.placeBlockAtCurrentPosition(par1World, Blocks.nether_brick_stairs, k, 4, 5, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.nether_brick_stairs, k, 4, 5, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.nether_brick_stairs, k, 4, 5, 9, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.nether_brick_stairs, k, 4, 5, 10, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.nether_brick_stairs, j, 8, 5, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.nether_brick_stairs, j, 8, 5, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.nether_brick_stairs, j, 8, 5, 9, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.nether_brick_stairs, j, 8, 5, 10, par3StructureBoundingBox); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 3, 4, 4, 4, 4, 8, Blocks.soul_sand, Blocks.soul_sand, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 8, 4, 4, 9, 4, 8, Blocks.soul_sand, Blocks.soul_sand, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 3, 5, 4, 4, 5, 8, Blocks.nether_wart, Blocks.nether_wart, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 8, 5, 4, 9, 5, 8, Blocks.nether_wart, Blocks.nether_wart, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 2, 0, 8, 2, 12, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 2, 4, 12, 2, 8, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 0, 0, 8, 1, 3, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 0, 9, 8, 1, 12, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 0, 4, 3, 1, 8, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 9, 0, 4, 12, 1, 8, Blocks.nether_brick, Blocks.nether_brick, false); + int i1; + + for (l = 4; l <= 8; ++l) + { + for (i1 = 0; i1 <= 2; ++i1) + { + this.func_151554_b(par1World, Blocks.nether_brick, 0, l, -1, i1, par3StructureBoundingBox); + this.func_151554_b(par1World, Blocks.nether_brick, 0, l, -1, 12 - i1, par3StructureBoundingBox); + } + } + + for (l = 0; l <= 2; ++l) + { + for (i1 = 4; i1 <= 8; ++i1) + { + this.func_151554_b(par1World, Blocks.nether_brick, 0, l, -1, i1, par3StructureBoundingBox); + this.func_151554_b(par1World, Blocks.nether_brick, 0, 12 - l, -1, i1, par3StructureBoundingBox); + } + } + + return true; + } + } + + abstract static class Piece extends StructureComponent + { + protected static final WeightedRandomChestContent[] field_111019_a = new WeightedRandomChestContent[] {new WeightedRandomChestContent(Items.diamond, 0, 1, 3, 5), new WeightedRandomChestContent(Items.iron_ingot, 0, 1, 5, 5), new WeightedRandomChestContent(Items.gold_ingot, 0, 1, 3, 15), new WeightedRandomChestContent(Items.golden_sword, 0, 1, 1, 5), new WeightedRandomChestContent(Items.golden_chestplate, 0, 1, 1, 5), new WeightedRandomChestContent(Items.flint_and_steel, 0, 1, 1, 5), new WeightedRandomChestContent(Items.nether_wart, 0, 3, 7, 5), new WeightedRandomChestContent(Items.saddle, 0, 1, 1, 10), new WeightedRandomChestContent(Items.golden_horse_armor, 0, 1, 1, 8), new WeightedRandomChestContent(Items.iron_horse_armor, 0, 1, 1, 5), new WeightedRandomChestContent(Items.diamond_horse_armor, 0, 1, 1, 3)}; + private static final String __OBFID = "CL_00000466"; + + public Piece() {} + + protected Piece(int par1) + { + super(par1); + } + + protected void func_143011_b(NBTTagCompound par1NBTTagCompound) {} + + protected void func_143012_a(NBTTagCompound par1NBTTagCompound) {} + + private int getTotalWeight(List par1List) + { + boolean flag = false; + int i = 0; + StructureNetherBridgePieces.PieceWeight pieceweight; + + for (Iterator iterator = par1List.iterator(); iterator.hasNext(); i += pieceweight.field_78826_b) + { + pieceweight = (StructureNetherBridgePieces.PieceWeight)iterator.next(); + + if (pieceweight.field_78824_d > 0 && pieceweight.field_78827_c < pieceweight.field_78824_d) + { + flag = true; + } + } + + return flag ? i : -1; + } + + private StructureNetherBridgePieces.Piece getNextComponent(StructureNetherBridgePieces.Start par1ComponentNetherBridgeStartPiece, List par2List, List par3List, Random par4Random, int par5, int par6, int par7, int par8, int par9) + { + int j1 = this.getTotalWeight(par2List); + boolean flag = j1 > 0 && par9 <= 30; + int k1 = 0; + + while (k1 < 5 && flag) + { + ++k1; + int l1 = par4Random.nextInt(j1); + Iterator iterator = par2List.iterator(); + + while (iterator.hasNext()) + { + StructureNetherBridgePieces.PieceWeight pieceweight = (StructureNetherBridgePieces.PieceWeight)iterator.next(); + l1 -= pieceweight.field_78826_b; + + if (l1 < 0) + { + if (!pieceweight.func_78822_a(par9) || pieceweight == par1ComponentNetherBridgeStartPiece.theNetherBridgePieceWeight && !pieceweight.field_78825_e) + { + break; + } + + StructureNetherBridgePieces.Piece piece = StructureNetherBridgePieces.createNextComponentRandom(pieceweight, par3List, par4Random, par5, par6, par7, par8, par9); + + if (piece != null) + { + ++pieceweight.field_78827_c; + par1ComponentNetherBridgeStartPiece.theNetherBridgePieceWeight = pieceweight; + + if (!pieceweight.func_78823_a()) + { + par2List.remove(pieceweight); + } + + return piece; + } + } + } + } + + return StructureNetherBridgePieces.End.func_74971_a(par3List, par4Random, par5, par6, par7, par8, par9); + } + + private StructureComponent getNextComponent(StructureNetherBridgePieces.Start par1ComponentNetherBridgeStartPiece, List par2List, Random par3Random, int par4, int par5, int par6, int par7, int par8, boolean par9) + { + if (Math.abs(par4 - par1ComponentNetherBridgeStartPiece.getBoundingBox().minX) <= 112 && Math.abs(par6 - par1ComponentNetherBridgeStartPiece.getBoundingBox().minZ) <= 112) + { + List list1 = par1ComponentNetherBridgeStartPiece.primaryWeights; + + if (par9) + { + list1 = par1ComponentNetherBridgeStartPiece.secondaryWeights; + } + + StructureNetherBridgePieces.Piece piece = this.getNextComponent(par1ComponentNetherBridgeStartPiece, list1, par2List, par3Random, par4, par5, par6, par7, par8 + 1); + + if (piece != null) + { + par2List.add(piece); + par1ComponentNetherBridgeStartPiece.field_74967_d.add(piece); + } + + return piece; + } + else + { + return StructureNetherBridgePieces.End.func_74971_a(par2List, par3Random, par4, par5, par6, par7, par8); + } + } + + protected StructureComponent getNextComponentNormal(StructureNetherBridgePieces.Start par1ComponentNetherBridgeStartPiece, List par2List, Random par3Random, int par4, int par5, boolean par6) + { + switch (this.coordBaseMode) + { + case 0: + return this.getNextComponent(par1ComponentNetherBridgeStartPiece, par2List, par3Random, this.boundingBox.minX + par4, this.boundingBox.minY + par5, this.boundingBox.maxZ + 1, this.coordBaseMode, this.getComponentType(), par6); + case 1: + return this.getNextComponent(par1ComponentNetherBridgeStartPiece, par2List, par3Random, this.boundingBox.minX - 1, this.boundingBox.minY + par5, this.boundingBox.minZ + par4, this.coordBaseMode, this.getComponentType(), par6); + case 2: + return this.getNextComponent(par1ComponentNetherBridgeStartPiece, par2List, par3Random, this.boundingBox.minX + par4, this.boundingBox.minY + par5, this.boundingBox.minZ - 1, this.coordBaseMode, this.getComponentType(), par6); + case 3: + return this.getNextComponent(par1ComponentNetherBridgeStartPiece, par2List, par3Random, this.boundingBox.maxX + 1, this.boundingBox.minY + par5, this.boundingBox.minZ + par4, this.coordBaseMode, this.getComponentType(), par6); + default: + return null; + } + } + + protected StructureComponent getNextComponentX(StructureNetherBridgePieces.Start par1ComponentNetherBridgeStartPiece, List par2List, Random par3Random, int par4, int par5, boolean par6) + { + switch (this.coordBaseMode) + { + case 0: + return this.getNextComponent(par1ComponentNetherBridgeStartPiece, par2List, par3Random, this.boundingBox.minX - 1, this.boundingBox.minY + par4, this.boundingBox.minZ + par5, 1, this.getComponentType(), par6); + case 1: + return this.getNextComponent(par1ComponentNetherBridgeStartPiece, par2List, par3Random, this.boundingBox.minX + par5, this.boundingBox.minY + par4, this.boundingBox.minZ - 1, 2, this.getComponentType(), par6); + case 2: + return this.getNextComponent(par1ComponentNetherBridgeStartPiece, par2List, par3Random, this.boundingBox.minX - 1, this.boundingBox.minY + par4, this.boundingBox.minZ + par5, 1, this.getComponentType(), par6); + case 3: + return this.getNextComponent(par1ComponentNetherBridgeStartPiece, par2List, par3Random, this.boundingBox.minX + par5, this.boundingBox.minY + par4, this.boundingBox.minZ - 1, 2, this.getComponentType(), par6); + default: + return null; + } + } + + protected StructureComponent getNextComponentZ(StructureNetherBridgePieces.Start par1ComponentNetherBridgeStartPiece, List par2List, Random par3Random, int par4, int par5, boolean par6) + { + switch (this.coordBaseMode) + { + case 0: + return this.getNextComponent(par1ComponentNetherBridgeStartPiece, par2List, par3Random, this.boundingBox.maxX + 1, this.boundingBox.minY + par4, this.boundingBox.minZ + par5, 3, this.getComponentType(), par6); + case 1: + return this.getNextComponent(par1ComponentNetherBridgeStartPiece, par2List, par3Random, this.boundingBox.minX + par5, this.boundingBox.minY + par4, this.boundingBox.maxZ + 1, 0, this.getComponentType(), par6); + case 2: + return this.getNextComponent(par1ComponentNetherBridgeStartPiece, par2List, par3Random, this.boundingBox.maxX + 1, this.boundingBox.minY + par4, this.boundingBox.minZ + par5, 3, this.getComponentType(), par6); + case 3: + return this.getNextComponent(par1ComponentNetherBridgeStartPiece, par2List, par3Random, this.boundingBox.minX + par5, this.boundingBox.minY + par4, this.boundingBox.maxZ + 1, 0, this.getComponentType(), par6); + default: + return null; + } + } + + protected static boolean isAboveGround(StructureBoundingBox par0StructureBoundingBox) + { + return par0StructureBoundingBox != null && par0StructureBoundingBox.minY > 10; + } + } + + static class PieceWeight + { + public Class weightClass; + public final int field_78826_b; + public int field_78827_c; + public int field_78824_d; + public boolean field_78825_e; + private static final String __OBFID = "CL_00000467"; + + public PieceWeight(Class par1Class, int par2, int par3, boolean par4) + { + this.weightClass = par1Class; + this.field_78826_b = par2; + this.field_78824_d = par3; + this.field_78825_e = par4; + } + + public PieceWeight(Class par1Class, int par2, int par3) + { + this(par1Class, par2, par3, false); + } + + public boolean func_78822_a(int par1) + { + return this.field_78824_d == 0 || this.field_78827_c < this.field_78824_d; + } + + public boolean func_78823_a() + { + return this.field_78824_d == 0 || this.field_78827_c < this.field_78824_d; + } + } + + public static class Stairs extends StructureNetherBridgePieces.Piece + { + private static final String __OBFID = "CL_00000469"; + + public Stairs() {} + + public Stairs(int par1, Random par2Random, StructureBoundingBox par3StructureBoundingBox, int par4) + { + super(par1); + this.coordBaseMode = par4; + this.boundingBox = par3StructureBoundingBox; + } + + public void buildComponent(StructureComponent par1StructureComponent, List par2List, Random par3Random) + { + this.getNextComponentZ((StructureNetherBridgePieces.Start)par1StructureComponent, par2List, par3Random, 6, 2, false); + } + + public static StructureNetherBridgePieces.Stairs createValidComponent(List par0List, Random par1Random, int par2, int par3, int par4, int par5, int par6) + { + StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(par2, par3, par4, -2, 0, 0, 7, 11, 7, par5); + return isAboveGround(structureboundingbox) && StructureComponent.findIntersecting(par0List, structureboundingbox) == null ? new StructureNetherBridgePieces.Stairs(par6, par1Random, structureboundingbox, par5) : null; + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 0, 0, 6, 1, 6, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 2, 0, 6, 10, 6, Blocks.air, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 2, 0, 1, 8, 0, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 5, 2, 0, 6, 8, 0, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 2, 1, 0, 8, 6, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 6, 2, 1, 6, 8, 6, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 2, 6, 5, 8, 6, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 3, 2, 0, 5, 4, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 6, 3, 2, 6, 5, 2, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 6, 3, 4, 6, 5, 4, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + this.placeBlockAtCurrentPosition(par1World, Blocks.nether_brick, 0, 5, 2, 5, par3StructureBoundingBox); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 2, 5, 4, 3, 5, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 3, 2, 5, 3, 4, 5, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 2, 2, 5, 2, 5, 5, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 2, 5, 1, 6, 5, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 7, 1, 5, 7, 4, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 6, 8, 2, 6, 8, 4, Blocks.air, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 2, 6, 0, 4, 8, 0, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 2, 5, 0, 4, 5, 0, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + + for (int i = 0; i <= 6; ++i) + { + for (int j = 0; j <= 6; ++j) + { + this.func_151554_b(par1World, Blocks.nether_brick, 0, i, -1, j, par3StructureBoundingBox); + } + } + + return true; + } + } + + public static class Start extends StructureNetherBridgePieces.Crossing3 + { + public StructureNetherBridgePieces.PieceWeight theNetherBridgePieceWeight; + public List primaryWeights; + public List secondaryWeights; + public ArrayList field_74967_d = new ArrayList(); + private static final String __OBFID = "CL_00000470"; + + public Start() {} + + public Start(Random par1Random, int par2, int par3) + { + super(par1Random, par2, par3); + this.primaryWeights = new ArrayList(); + StructureNetherBridgePieces.PieceWeight[] apieceweight = StructureNetherBridgePieces.primaryComponents; + int k = apieceweight.length; + int l; + StructureNetherBridgePieces.PieceWeight pieceweight; + + for (l = 0; l < k; ++l) + { + pieceweight = apieceweight[l]; + pieceweight.field_78827_c = 0; + this.primaryWeights.add(pieceweight); + } + + this.secondaryWeights = new ArrayList(); + apieceweight = StructureNetherBridgePieces.secondaryComponents; + k = apieceweight.length; + + for (l = 0; l < k; ++l) + { + pieceweight = apieceweight[l]; + pieceweight.field_78827_c = 0; + this.secondaryWeights.add(pieceweight); + } + } + + protected void func_143011_b(NBTTagCompound par1NBTTagCompound) + { + super.func_143011_b(par1NBTTagCompound); + } + + protected void func_143012_a(NBTTagCompound par1NBTTagCompound) + { + super.func_143012_a(par1NBTTagCompound); + } + } + + public static class Straight extends StructureNetherBridgePieces.Piece + { + private static final String __OBFID = "CL_00000456"; + + public Straight() {} + + public Straight(int par1, Random par2Random, StructureBoundingBox par3StructureBoundingBox, int par4) + { + super(par1); + this.coordBaseMode = par4; + this.boundingBox = par3StructureBoundingBox; + } + + public void buildComponent(StructureComponent par1StructureComponent, List par2List, Random par3Random) + { + this.getNextComponentNormal((StructureNetherBridgePieces.Start)par1StructureComponent, par2List, par3Random, 1, 3, false); + } + + public static StructureNetherBridgePieces.Straight createValidComponent(List par0List, Random par1Random, int par2, int par3, int par4, int par5, int par6) + { + StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(par2, par3, par4, -1, -3, 0, 5, 10, 19, par5); + return isAboveGround(structureboundingbox) && StructureComponent.findIntersecting(par0List, structureboundingbox) == null ? new StructureNetherBridgePieces.Straight(par6, par1Random, structureboundingbox, par5) : null; + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 3, 0, 4, 4, 18, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 5, 0, 3, 7, 18, Blocks.air, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 5, 0, 0, 5, 18, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 5, 0, 4, 5, 18, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 2, 0, 4, 2, 5, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 2, 13, 4, 2, 18, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 0, 0, 4, 1, 3, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 0, 15, 4, 1, 18, Blocks.nether_brick, Blocks.nether_brick, false); + + for (int i = 0; i <= 4; ++i) + { + for (int j = 0; j <= 2; ++j) + { + this.func_151554_b(par1World, Blocks.nether_brick, 0, i, -1, j, par3StructureBoundingBox); + this.func_151554_b(par1World, Blocks.nether_brick, 0, i, -1, 18 - j, par3StructureBoundingBox); + } + } + + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 1, 1, 0, 4, 1, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 3, 4, 0, 4, 4, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 3, 14, 0, 4, 14, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 1, 17, 0, 4, 17, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 1, 1, 4, 4, 1, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 3, 4, 4, 4, 4, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 3, 14, 4, 4, 14, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 1, 17, 4, 4, 17, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + return true; + } + } + + public static class Throne extends StructureNetherBridgePieces.Piece + { + private boolean hasSpawner; + private static final String __OBFID = "CL_00000465"; + + public Throne() {} + + public Throne(int par1, Random par2Random, StructureBoundingBox par3StructureBoundingBox, int par4) + { + super(par1); + this.coordBaseMode = par4; + this.boundingBox = par3StructureBoundingBox; + } + + protected void func_143011_b(NBTTagCompound par1NBTTagCompound) + { + super.func_143011_b(par1NBTTagCompound); + this.hasSpawner = par1NBTTagCompound.getBoolean("Mob"); + } + + protected void func_143012_a(NBTTagCompound par1NBTTagCompound) + { + super.func_143012_a(par1NBTTagCompound); + par1NBTTagCompound.setBoolean("Mob", this.hasSpawner); + } + + public static StructureNetherBridgePieces.Throne createValidComponent(List par0List, Random par1Random, int par2, int par3, int par4, int par5, int par6) + { + StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(par2, par3, par4, -2, 0, 0, 7, 8, 9, par5); + return isAboveGround(structureboundingbox) && StructureComponent.findIntersecting(par0List, structureboundingbox) == null ? new StructureNetherBridgePieces.Throne(par6, par1Random, structureboundingbox, par5) : null; + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 2, 0, 6, 7, 7, Blocks.air, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 0, 0, 5, 1, 7, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 2, 1, 5, 2, 7, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 3, 2, 5, 3, 7, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 4, 3, 5, 4, 7, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 2, 0, 1, 4, 2, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 5, 2, 0, 5, 4, 2, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 5, 2, 1, 5, 3, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 5, 5, 2, 5, 5, 3, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 5, 3, 0, 5, 8, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 6, 5, 3, 6, 5, 8, Blocks.nether_brick, Blocks.nether_brick, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 5, 8, 5, 5, 8, Blocks.nether_brick, Blocks.nether_brick, false); + this.placeBlockAtCurrentPosition(par1World, Blocks.nether_brick_fence, 0, 1, 6, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.nether_brick_fence, 0, 5, 6, 3, par3StructureBoundingBox); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 6, 3, 0, 6, 8, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 6, 6, 3, 6, 6, 8, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 6, 8, 5, 7, 8, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 2, 8, 8, 4, 8, 8, Blocks.nether_brick_fence, Blocks.nether_brick_fence, false); + int i; + int j; + + if (!this.hasSpawner) + { + i = this.getYWithOffset(5); + j = this.getXWithOffset(3, 5); + int k = this.getZWithOffset(3, 5); + + if (par3StructureBoundingBox.isVecInside(j, i, k)) + { + this.hasSpawner = true; + par1World.setBlock(j, i, k, Blocks.mob_spawner, 0, 2); + TileEntityMobSpawner tileentitymobspawner = (TileEntityMobSpawner)par1World.getTileEntity(j, i, k); + + if (tileentitymobspawner != null) + { + tileentitymobspawner.func_145881_a().setEntityName("Blaze"); + } + } + } + + for (i = 0; i <= 6; ++i) + { + for (j = 0; j <= 6; ++j) + { + this.func_151554_b(par1World, Blocks.nether_brick, 0, i, -1, j, par3StructureBoundingBox); + } + } + + return true; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/structure/StructureStart.java b/src/main/java/net/minecraft/world/gen/structure/StructureStart.java new file mode 100644 index 0000000..0d14646 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/structure/StructureStart.java @@ -0,0 +1,173 @@ +package net.minecraft.world.gen.structure; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.Random; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.world.World; + +public abstract class StructureStart +{ + protected LinkedList components = new LinkedList(); + protected StructureBoundingBox boundingBox; + private int field_143024_c; + private int field_143023_d; + private static final String __OBFID = "CL_00000513"; + + public StructureStart() {} + + public StructureStart(int par1, int par2) + { + this.field_143024_c = par1; + this.field_143023_d = par2; + } + + public StructureBoundingBox getBoundingBox() + { + return this.boundingBox; + } + + public LinkedList getComponents() + { + return this.components; + } + + public void generateStructure(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + Iterator iterator = this.components.iterator(); + + while (iterator.hasNext()) + { + StructureComponent structurecomponent = (StructureComponent)iterator.next(); + + if (structurecomponent.getBoundingBox().intersectsWith(par3StructureBoundingBox) && !structurecomponent.addComponentParts(par1World, par2Random, par3StructureBoundingBox)) + { + iterator.remove(); + } + } + } + + protected void updateBoundingBox() + { + this.boundingBox = StructureBoundingBox.getNewBoundingBox(); + Iterator iterator = this.components.iterator(); + + while (iterator.hasNext()) + { + StructureComponent structurecomponent = (StructureComponent)iterator.next(); + this.boundingBox.expandTo(structurecomponent.getBoundingBox()); + } + } + + public NBTTagCompound func_143021_a(int par1, int par2) + { + if (MapGenStructureIO.func_143033_a(this) == null) // This is just a more friendly error instead of the 'Null String' below + { + throw new RuntimeException("StructureStart \"" + this.getClass().getName() + "\" missing ID Mapping, Modder see MapGenStructureIO"); + } + NBTTagCompound nbttagcompound = new NBTTagCompound(); + nbttagcompound.setString("id", MapGenStructureIO.func_143033_a(this)); + nbttagcompound.setInteger("ChunkX", par1); + nbttagcompound.setInteger("ChunkZ", par2); + nbttagcompound.setTag("BB", this.boundingBox.func_151535_h()); + NBTTagList nbttaglist = new NBTTagList(); + Iterator iterator = this.components.iterator(); + + while (iterator.hasNext()) + { + StructureComponent structurecomponent = (StructureComponent)iterator.next(); + nbttaglist.appendTag(structurecomponent.func_143010_b()); + } + + nbttagcompound.setTag("Children", nbttaglist); + this.func_143022_a(nbttagcompound); + return nbttagcompound; + } + + public void func_143022_a(NBTTagCompound par1NBTTagCompound) {} + + public void func_143020_a(World par1World, NBTTagCompound par2NBTTagCompound) + { + this.field_143024_c = par2NBTTagCompound.getInteger("ChunkX"); + this.field_143023_d = par2NBTTagCompound.getInteger("ChunkZ"); + + if (par2NBTTagCompound.hasKey("BB")) + { + this.boundingBox = new StructureBoundingBox(par2NBTTagCompound.getIntArray("BB")); + } + + NBTTagList nbttaglist = par2NBTTagCompound.getTagList("Children", 10); + + for (int i = 0; i < nbttaglist.tagCount(); ++i) + { + this.components.add(MapGenStructureIO.func_143032_b(nbttaglist.getCompoundTagAt(i), par1World)); + } + + this.func_143017_b(par2NBTTagCompound); + } + + public void func_143017_b(NBTTagCompound par1NBTTagCompound) {} + + protected void markAvailableHeight(World par1World, Random par2Random, int par3) + { + int j = 63 - par3; + int k = this.boundingBox.getYSize() + 1; + + if (k < j) + { + k += par2Random.nextInt(j - k); + } + + int l = k - this.boundingBox.maxY; + this.boundingBox.offset(0, l, 0); + Iterator iterator = this.components.iterator(); + + while (iterator.hasNext()) + { + StructureComponent structurecomponent = (StructureComponent)iterator.next(); + structurecomponent.getBoundingBox().offset(0, l, 0); + } + } + + protected void setRandomHeight(World par1World, Random par2Random, int par3, int par4) + { + int k = par4 - par3 + 1 - this.boundingBox.getYSize(); + boolean flag = true; + int i1; + + if (k > 1) + { + i1 = par3 + par2Random.nextInt(k); + } + else + { + i1 = par3; + } + + int l = i1 - this.boundingBox.minY; + this.boundingBox.offset(0, l, 0); + Iterator iterator = this.components.iterator(); + + while (iterator.hasNext()) + { + StructureComponent structurecomponent = (StructureComponent)iterator.next(); + structurecomponent.getBoundingBox().offset(0, l, 0); + } + } + + public boolean isSizeableStructure() + { + return true; + } + + public int func_143019_e() + { + return this.field_143024_c; + } + + public int func_143018_f() + { + return this.field_143023_d; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/structure/StructureStrongholdPieces.java b/src/main/java/net/minecraft/world/gen/structure/StructureStrongholdPieces.java new file mode 100644 index 0000000..c77635a --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/structure/StructureStrongholdPieces.java @@ -0,0 +1,1677 @@ +package net.minecraft.world.gen.structure; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntityMobSpawner; +import net.minecraft.util.WeightedRandomChestContent; +import net.minecraft.world.ChunkPosition; +import net.minecraft.world.World; + +import net.minecraftforge.common.ChestGenHooks; +import static net.minecraftforge.common.ChestGenHooks.*; + +public class StructureStrongholdPieces +{ + private static final StructureStrongholdPieces.PieceWeight[] pieceWeightArray = new StructureStrongholdPieces.PieceWeight[] {new StructureStrongholdPieces.PieceWeight(StructureStrongholdPieces.Straight.class, 40, 0), new StructureStrongholdPieces.PieceWeight(StructureStrongholdPieces.Prison.class, 5, 5), new StructureStrongholdPieces.PieceWeight(StructureStrongholdPieces.LeftTurn.class, 20, 0), new StructureStrongholdPieces.PieceWeight(StructureStrongholdPieces.RightTurn.class, 20, 0), new StructureStrongholdPieces.PieceWeight(StructureStrongholdPieces.RoomCrossing.class, 10, 6), new StructureStrongholdPieces.PieceWeight(StructureStrongholdPieces.StairsStraight.class, 5, 5), new StructureStrongholdPieces.PieceWeight(StructureStrongholdPieces.Stairs.class, 5, 5), new StructureStrongholdPieces.PieceWeight(StructureStrongholdPieces.Crossing.class, 5, 4), new StructureStrongholdPieces.PieceWeight(StructureStrongholdPieces.ChestCorridor.class, 5, 4), new StructureStrongholdPieces.PieceWeight(StructureStrongholdPieces.Library.class, 10, 2) + { + private static final String __OBFID = "CL_00000484"; + public boolean canSpawnMoreStructuresOfType(int par1) + { + return super.canSpawnMoreStructuresOfType(par1) && par1 > 4; + } + }, new StructureStrongholdPieces.PieceWeight(StructureStrongholdPieces.PortalRoom.class, 20, 1) + { + private static final String __OBFID = "CL_00000485"; + public boolean canSpawnMoreStructuresOfType(int par1) + { + return super.canSpawnMoreStructuresOfType(par1) && par1 > 5; + } + } + }; + private static List structurePieceList; + private static Class strongComponentType; + static int totalWeight; + private static final StructureStrongholdPieces.Stones strongholdStones = new StructureStrongholdPieces.Stones(null); + private static final String __OBFID = "CL_00000483"; + + public static void registerStrongholdPieces() + { + MapGenStructureIO.func_143031_a(StructureStrongholdPieces.ChestCorridor.class, "SHCC"); + MapGenStructureIO.func_143031_a(StructureStrongholdPieces.Corridor.class, "SHFC"); + MapGenStructureIO.func_143031_a(StructureStrongholdPieces.Crossing.class, "SH5C"); + MapGenStructureIO.func_143031_a(StructureStrongholdPieces.LeftTurn.class, "SHLT"); + MapGenStructureIO.func_143031_a(StructureStrongholdPieces.Library.class, "SHLi"); + MapGenStructureIO.func_143031_a(StructureStrongholdPieces.PortalRoom.class, "SHPR"); + MapGenStructureIO.func_143031_a(StructureStrongholdPieces.Prison.class, "SHPH"); + MapGenStructureIO.func_143031_a(StructureStrongholdPieces.RightTurn.class, "SHRT"); + MapGenStructureIO.func_143031_a(StructureStrongholdPieces.RoomCrossing.class, "SHRC"); + MapGenStructureIO.func_143031_a(StructureStrongholdPieces.Stairs.class, "SHSD"); + MapGenStructureIO.func_143031_a(StructureStrongholdPieces.Stairs2.class, "SHStart"); + MapGenStructureIO.func_143031_a(StructureStrongholdPieces.Straight.class, "SHS"); + MapGenStructureIO.func_143031_a(StructureStrongholdPieces.StairsStraight.class, "SHSSD"); + } + + public static void prepareStructurePieces() + { + structurePieceList = new ArrayList(); + StructureStrongholdPieces.PieceWeight[] apieceweight = pieceWeightArray; + int i = apieceweight.length; + + for (int j = 0; j < i; ++j) + { + StructureStrongholdPieces.PieceWeight pieceweight = apieceweight[j]; + pieceweight.instancesSpawned = 0; + structurePieceList.add(pieceweight); + } + + strongComponentType = null; + } + + private static boolean canAddStructurePieces() + { + boolean flag = false; + totalWeight = 0; + StructureStrongholdPieces.PieceWeight pieceweight; + + for (Iterator iterator = structurePieceList.iterator(); iterator.hasNext(); totalWeight += pieceweight.pieceWeight) + { + pieceweight = (StructureStrongholdPieces.PieceWeight)iterator.next(); + + if (pieceweight.instancesLimit > 0 && pieceweight.instancesSpawned < pieceweight.instancesLimit) + { + flag = true; + } + } + + return flag; + } + + private static StructureStrongholdPieces.Stronghold getStrongholdComponentFromWeightedPiece(Class par0Class, List par1List, Random par2Random, int par3, int par4, int par5, int par6, int par7) + { + Object object = null; + + if (par0Class == StructureStrongholdPieces.Straight.class) + { + object = StructureStrongholdPieces.Straight.findValidPlacement(par1List, par2Random, par3, par4, par5, par6, par7); + } + else if (par0Class == StructureStrongholdPieces.Prison.class) + { + object = StructureStrongholdPieces.Prison.findValidPlacement(par1List, par2Random, par3, par4, par5, par6, par7); + } + else if (par0Class == StructureStrongholdPieces.LeftTurn.class) + { + object = StructureStrongholdPieces.LeftTurn.findValidPlacement(par1List, par2Random, par3, par4, par5, par6, par7); + } + else if (par0Class == StructureStrongholdPieces.RightTurn.class) + { + object = StructureStrongholdPieces.RightTurn.findValidPlacement(par1List, par2Random, par3, par4, par5, par6, par7); + } + else if (par0Class == StructureStrongholdPieces.RoomCrossing.class) + { + object = StructureStrongholdPieces.RoomCrossing.findValidPlacement(par1List, par2Random, par3, par4, par5, par6, par7); + } + else if (par0Class == StructureStrongholdPieces.StairsStraight.class) + { + object = StructureStrongholdPieces.StairsStraight.findValidPlacement(par1List, par2Random, par3, par4, par5, par6, par7); + } + else if (par0Class == StructureStrongholdPieces.Stairs.class) + { + object = StructureStrongholdPieces.Stairs.getStrongholdStairsComponent(par1List, par2Random, par3, par4, par5, par6, par7); + } + else if (par0Class == StructureStrongholdPieces.Crossing.class) + { + object = StructureStrongholdPieces.Crossing.findValidPlacement(par1List, par2Random, par3, par4, par5, par6, par7); + } + else if (par0Class == StructureStrongholdPieces.ChestCorridor.class) + { + object = StructureStrongholdPieces.ChestCorridor.findValidPlacement(par1List, par2Random, par3, par4, par5, par6, par7); + } + else if (par0Class == StructureStrongholdPieces.Library.class) + { + object = StructureStrongholdPieces.Library.findValidPlacement(par1List, par2Random, par3, par4, par5, par6, par7); + } + else if (par0Class == StructureStrongholdPieces.PortalRoom.class) + { + object = StructureStrongholdPieces.PortalRoom.findValidPlacement(par1List, par2Random, par3, par4, par5, par6, par7); + } + + return (StructureStrongholdPieces.Stronghold)object; + } + + private static StructureStrongholdPieces.Stronghold getNextComponent(StructureStrongholdPieces.Stairs2 par0ComponentStrongholdStairs2, List par1List, Random par2Random, int par3, int par4, int par5, int par6, int par7) + { + if (!canAddStructurePieces()) + { + return null; + } + else + { + if (strongComponentType != null) + { + StructureStrongholdPieces.Stronghold stronghold = getStrongholdComponentFromWeightedPiece(strongComponentType, par1List, par2Random, par3, par4, par5, par6, par7); + strongComponentType = null; + + if (stronghold != null) + { + return stronghold; + } + } + + int k1 = 0; + + while (k1 < 5) + { + ++k1; + int j1 = par2Random.nextInt(totalWeight); + Iterator iterator = structurePieceList.iterator(); + + while (iterator.hasNext()) + { + StructureStrongholdPieces.PieceWeight pieceweight = (StructureStrongholdPieces.PieceWeight)iterator.next(); + j1 -= pieceweight.pieceWeight; + + if (j1 < 0) + { + if (!pieceweight.canSpawnMoreStructuresOfType(par7) || pieceweight == par0ComponentStrongholdStairs2.strongholdPieceWeight) + { + break; + } + + StructureStrongholdPieces.Stronghold stronghold1 = getStrongholdComponentFromWeightedPiece(pieceweight.pieceClass, par1List, par2Random, par3, par4, par5, par6, par7); + + if (stronghold1 != null) + { + ++pieceweight.instancesSpawned; + par0ComponentStrongholdStairs2.strongholdPieceWeight = pieceweight; + + if (!pieceweight.canSpawnMoreStructures()) + { + structurePieceList.remove(pieceweight); + } + + return stronghold1; + } + } + } + } + + StructureBoundingBox structureboundingbox = StructureStrongholdPieces.Corridor.func_74992_a(par1List, par2Random, par3, par4, par5, par6); + + if (structureboundingbox != null && structureboundingbox.minY > 1) + { + return new StructureStrongholdPieces.Corridor(par7, par2Random, structureboundingbox, par6); + } + else + { + return null; + } + } + } + + private static StructureComponent getNextValidComponent(StructureStrongholdPieces.Stairs2 par0ComponentStrongholdStairs2, List par1List, Random par2Random, int par3, int par4, int par5, int par6, int par7) + { + if (par7 > 50) + { + return null; + } + else if (Math.abs(par3 - par0ComponentStrongholdStairs2.getBoundingBox().minX) <= 112 && Math.abs(par5 - par0ComponentStrongholdStairs2.getBoundingBox().minZ) <= 112) + { + StructureStrongholdPieces.Stronghold stronghold = getNextComponent(par0ComponentStrongholdStairs2, par1List, par2Random, par3, par4, par5, par6, par7 + 1); + + if (stronghold != null) + { + par1List.add(stronghold); + par0ComponentStrongholdStairs2.field_75026_c.add(stronghold); + } + + return stronghold; + } + else + { + return null; + } + } + + public static class ChestCorridor extends StructureStrongholdPieces.Stronghold + { + public static final WeightedRandomChestContent[] strongholdChestContents = new WeightedRandomChestContent[] {new WeightedRandomChestContent(Items.ender_pearl, 0, 1, 1, 10), new WeightedRandomChestContent(Items.diamond, 0, 1, 3, 3), new WeightedRandomChestContent(Items.iron_ingot, 0, 1, 5, 10), new WeightedRandomChestContent(Items.gold_ingot, 0, 1, 3, 5), new WeightedRandomChestContent(Items.redstone, 0, 4, 9, 5), new WeightedRandomChestContent(Items.bread, 0, 1, 3, 15), new WeightedRandomChestContent(Items.apple, 0, 1, 3, 15), new WeightedRandomChestContent(Items.iron_pickaxe, 0, 1, 1, 5), new WeightedRandomChestContent(Items.iron_sword, 0, 1, 1, 5), new WeightedRandomChestContent(Items.iron_chestplate, 0, 1, 1, 5), new WeightedRandomChestContent(Items.iron_helmet, 0, 1, 1, 5), new WeightedRandomChestContent(Items.iron_leggings, 0, 1, 1, 5), new WeightedRandomChestContent(Items.iron_boots, 0, 1, 1, 5), new WeightedRandomChestContent(Items.golden_apple, 0, 1, 1, 1), new WeightedRandomChestContent(Items.saddle, 0, 1, 1, 1), new WeightedRandomChestContent(Items.iron_horse_armor, 0, 1, 1, 1), new WeightedRandomChestContent(Items.golden_horse_armor, 0, 1, 1, 1), new WeightedRandomChestContent(Items.diamond_horse_armor, 0, 1, 1, 1)}; + private boolean hasMadeChest; + private static final String __OBFID = "CL_00000487"; + + public ChestCorridor() {} + + public ChestCorridor(int par1, Random par2Random, StructureBoundingBox par3StructureBoundingBox, int par4) + { + super(par1); + this.coordBaseMode = par4; + this.field_143013_d = this.getRandomDoor(par2Random); + this.boundingBox = par3StructureBoundingBox; + } + + protected void func_143012_a(NBTTagCompound par1NBTTagCompound) + { + super.func_143012_a(par1NBTTagCompound); + par1NBTTagCompound.setBoolean("Chest", this.hasMadeChest); + } + + protected void func_143011_b(NBTTagCompound par1NBTTagCompound) + { + super.func_143011_b(par1NBTTagCompound); + this.hasMadeChest = par1NBTTagCompound.getBoolean("Chest"); + } + + public void buildComponent(StructureComponent par1StructureComponent, List par2List, Random par3Random) + { + this.getNextComponentNormal((StructureStrongholdPieces.Stairs2)par1StructureComponent, par2List, par3Random, 1, 1); + } + + public static StructureStrongholdPieces.ChestCorridor findValidPlacement(List par0List, Random par1Random, int par2, int par3, int par4, int par5, int par6) + { + StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(par2, par3, par4, -1, -1, 0, 5, 5, 7, par5); + return canStrongholdGoDeeper(structureboundingbox) && StructureComponent.findIntersecting(par0List, structureboundingbox) == null ? new StructureStrongholdPieces.ChestCorridor(par6, par1Random, structureboundingbox, par5) : null; + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + if (this.isLiquidInStructureBoundingBox(par1World, par3StructureBoundingBox)) + { + return false; + } + else + { + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 0, 0, 0, 4, 4, 6, true, par2Random, StructureStrongholdPieces.strongholdStones); + this.placeDoor(par1World, par2Random, par3StructureBoundingBox, this.field_143013_d, 1, 1, 0); + this.placeDoor(par1World, par2Random, par3StructureBoundingBox, StructureStrongholdPieces.Stronghold.Door.OPENING, 1, 1, 6); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 3, 1, 2, 3, 1, 4, Blocks.stonebrick, Blocks.stonebrick, false); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_slab, 5, 3, 1, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_slab, 5, 3, 1, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_slab, 5, 3, 2, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_slab, 5, 3, 2, 4, par3StructureBoundingBox); + int i; + + for (i = 2; i <= 4; ++i) + { + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_slab, 5, 2, 1, i, par3StructureBoundingBox); + } + + if (!this.hasMadeChest) + { + i = this.getYWithOffset(2); + int j = this.getXWithOffset(3, 3); + int k = this.getZWithOffset(3, 3); + + if (par3StructureBoundingBox.isVecInside(j, i, k)) + { + this.hasMadeChest = true; + this.generateStructureChestContents(par1World, par3StructureBoundingBox, par2Random, 3, 2, 3, ChestGenHooks.getItems(STRONGHOLD_CORRIDOR, par2Random), ChestGenHooks.getCount(STRONGHOLD_CORRIDOR, par2Random)); + } + } + + return true; + } + } + } + + public static class Corridor extends StructureStrongholdPieces.Stronghold + { + private int field_74993_a; + private static final String __OBFID = "CL_00000488"; + + public Corridor() {} + + public Corridor(int par1, Random par2Random, StructureBoundingBox par3StructureBoundingBox, int par4) + { + super(par1); + this.coordBaseMode = par4; + this.boundingBox = par3StructureBoundingBox; + this.field_74993_a = par4 != 2 && par4 != 0 ? par3StructureBoundingBox.getXSize() : par3StructureBoundingBox.getZSize(); + } + + protected void func_143012_a(NBTTagCompound par1NBTTagCompound) + { + super.func_143012_a(par1NBTTagCompound); + par1NBTTagCompound.setInteger("Steps", this.field_74993_a); + } + + protected void func_143011_b(NBTTagCompound par1NBTTagCompound) + { + super.func_143011_b(par1NBTTagCompound); + this.field_74993_a = par1NBTTagCompound.getInteger("Steps"); + } + + public static StructureBoundingBox func_74992_a(List par0List, Random par1Random, int par2, int par3, int par4, int par5) + { + boolean flag = true; + StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(par2, par3, par4, -1, -1, 0, 5, 5, 4, par5); + StructureComponent structurecomponent = StructureComponent.findIntersecting(par0List, structureboundingbox); + + if (structurecomponent == null) + { + return null; + } + else + { + if (structurecomponent.getBoundingBox().minY == structureboundingbox.minY) + { + for (int i1 = 3; i1 >= 1; --i1) + { + structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(par2, par3, par4, -1, -1, 0, 5, 5, i1 - 1, par5); + + if (!structurecomponent.getBoundingBox().intersectsWith(structureboundingbox)) + { + return StructureBoundingBox.getComponentToAddBoundingBox(par2, par3, par4, -1, -1, 0, 5, 5, i1, par5); + } + } + } + + return null; + } + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + if (this.isLiquidInStructureBoundingBox(par1World, par3StructureBoundingBox)) + { + return false; + } + else + { + for (int i = 0; i < this.field_74993_a; ++i) + { + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, 0, 0, i, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, 1, 0, i, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, 2, 0, i, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, 3, 0, i, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, 4, 0, i, par3StructureBoundingBox); + + for (int j = 1; j <= 3; ++j) + { + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, 0, j, i, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, 1, j, i, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, 2, j, i, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, 3, j, i, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, 4, j, i, par3StructureBoundingBox); + } + + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, 0, 4, i, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, 1, 4, i, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, 2, 4, i, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, 3, 4, i, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, 4, 4, i, par3StructureBoundingBox); + } + + return true; + } + } + } + + public static class Crossing extends StructureStrongholdPieces.Stronghold + { + private boolean field_74996_b; + private boolean field_74997_c; + private boolean field_74995_d; + private boolean field_74999_h; + private static final String __OBFID = "CL_00000489"; + + public Crossing() {} + + public Crossing(int par1, Random par2Random, StructureBoundingBox par3StructureBoundingBox, int par4) + { + super(par1); + this.coordBaseMode = par4; + this.field_143013_d = this.getRandomDoor(par2Random); + this.boundingBox = par3StructureBoundingBox; + this.field_74996_b = par2Random.nextBoolean(); + this.field_74997_c = par2Random.nextBoolean(); + this.field_74995_d = par2Random.nextBoolean(); + this.field_74999_h = par2Random.nextInt(3) > 0; + } + + protected void func_143012_a(NBTTagCompound par1NBTTagCompound) + { + super.func_143012_a(par1NBTTagCompound); + par1NBTTagCompound.setBoolean("leftLow", this.field_74996_b); + par1NBTTagCompound.setBoolean("leftHigh", this.field_74997_c); + par1NBTTagCompound.setBoolean("rightLow", this.field_74995_d); + par1NBTTagCompound.setBoolean("rightHigh", this.field_74999_h); + } + + protected void func_143011_b(NBTTagCompound par1NBTTagCompound) + { + super.func_143011_b(par1NBTTagCompound); + this.field_74996_b = par1NBTTagCompound.getBoolean("leftLow"); + this.field_74997_c = par1NBTTagCompound.getBoolean("leftHigh"); + this.field_74995_d = par1NBTTagCompound.getBoolean("rightLow"); + this.field_74999_h = par1NBTTagCompound.getBoolean("rightHigh"); + } + + public void buildComponent(StructureComponent par1StructureComponent, List par2List, Random par3Random) + { + int i = 3; + int j = 5; + + if (this.coordBaseMode == 1 || this.coordBaseMode == 2) + { + i = 8 - i; + j = 8 - j; + } + + this.getNextComponentNormal((StructureStrongholdPieces.Stairs2)par1StructureComponent, par2List, par3Random, 5, 1); + + if (this.field_74996_b) + { + this.getNextComponentX((StructureStrongholdPieces.Stairs2)par1StructureComponent, par2List, par3Random, i, 1); + } + + if (this.field_74997_c) + { + this.getNextComponentX((StructureStrongholdPieces.Stairs2)par1StructureComponent, par2List, par3Random, j, 7); + } + + if (this.field_74995_d) + { + this.getNextComponentZ((StructureStrongholdPieces.Stairs2)par1StructureComponent, par2List, par3Random, i, 1); + } + + if (this.field_74999_h) + { + this.getNextComponentZ((StructureStrongholdPieces.Stairs2)par1StructureComponent, par2List, par3Random, j, 7); + } + } + + public static StructureStrongholdPieces.Crossing findValidPlacement(List par0List, Random par1Random, int par2, int par3, int par4, int par5, int par6) + { + StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(par2, par3, par4, -4, -3, 0, 10, 9, 11, par5); + return canStrongholdGoDeeper(structureboundingbox) && StructureComponent.findIntersecting(par0List, structureboundingbox) == null ? new StructureStrongholdPieces.Crossing(par6, par1Random, structureboundingbox, par5) : null; + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + if (this.isLiquidInStructureBoundingBox(par1World, par3StructureBoundingBox)) + { + return false; + } + else + { + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 0, 0, 0, 9, 8, 10, true, par2Random, StructureStrongholdPieces.strongholdStones); + this.placeDoor(par1World, par2Random, par3StructureBoundingBox, this.field_143013_d, 4, 3, 0); + + if (this.field_74996_b) + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 3, 1, 0, 5, 3, Blocks.air, Blocks.air, false); + } + + if (this.field_74995_d) + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, 9, 3, 1, 9, 5, 3, Blocks.air, Blocks.air, false); + } + + if (this.field_74997_c) + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 5, 7, 0, 7, 9, Blocks.air, Blocks.air, false); + } + + if (this.field_74999_h) + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, 9, 5, 7, 9, 7, 9, Blocks.air, Blocks.air, false); + } + + this.fillWithBlocks(par1World, par3StructureBoundingBox, 5, 1, 10, 7, 3, 10, Blocks.air, Blocks.air, false); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 1, 2, 1, 8, 2, 6, false, par2Random, StructureStrongholdPieces.strongholdStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 4, 1, 5, 4, 4, 9, false, par2Random, StructureStrongholdPieces.strongholdStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 8, 1, 5, 8, 4, 9, false, par2Random, StructureStrongholdPieces.strongholdStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 1, 4, 7, 3, 4, 9, false, par2Random, StructureStrongholdPieces.strongholdStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 1, 3, 5, 3, 3, 6, false, par2Random, StructureStrongholdPieces.strongholdStones); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 3, 4, 3, 3, 4, Blocks.stone_slab, Blocks.stone_slab, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 4, 6, 3, 4, 6, Blocks.stone_slab, Blocks.stone_slab, false); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 5, 1, 7, 7, 1, 8, false, par2Random, StructureStrongholdPieces.strongholdStones); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 5, 1, 9, 7, 1, 9, Blocks.stone_slab, Blocks.stone_slab, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 5, 2, 7, 7, 2, 7, Blocks.stone_slab, Blocks.stone_slab, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 5, 7, 4, 5, 9, Blocks.stone_slab, Blocks.stone_slab, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 8, 5, 7, 8, 5, 9, Blocks.stone_slab, Blocks.stone_slab, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 5, 5, 7, 7, 5, 9, Blocks.double_stone_slab, Blocks.double_stone_slab, false); + this.placeBlockAtCurrentPosition(par1World, Blocks.torch, 0, 6, 5, 6, par3StructureBoundingBox); + return true; + } + } + } + + public static class LeftTurn extends StructureStrongholdPieces.Stronghold + { + private static final String __OBFID = "CL_00000490"; + + public LeftTurn() {} + + public LeftTurn(int par1, Random par2Random, StructureBoundingBox par3StructureBoundingBox, int par4) + { + super(par1); + this.coordBaseMode = par4; + this.field_143013_d = this.getRandomDoor(par2Random); + this.boundingBox = par3StructureBoundingBox; + } + + public void buildComponent(StructureComponent par1StructureComponent, List par2List, Random par3Random) + { + if (this.coordBaseMode != 2 && this.coordBaseMode != 3) + { + this.getNextComponentZ((StructureStrongholdPieces.Stairs2)par1StructureComponent, par2List, par3Random, 1, 1); + } + else + { + this.getNextComponentX((StructureStrongholdPieces.Stairs2)par1StructureComponent, par2List, par3Random, 1, 1); + } + } + + public static StructureStrongholdPieces.LeftTurn findValidPlacement(List par0List, Random par1Random, int par2, int par3, int par4, int par5, int par6) + { + StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(par2, par3, par4, -1, -1, 0, 5, 5, 5, par5); + return canStrongholdGoDeeper(structureboundingbox) && StructureComponent.findIntersecting(par0List, structureboundingbox) == null ? new StructureStrongholdPieces.LeftTurn(par6, par1Random, structureboundingbox, par5) : null; + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + if (this.isLiquidInStructureBoundingBox(par1World, par3StructureBoundingBox)) + { + return false; + } + else + { + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 0, 0, 0, 4, 4, 4, true, par2Random, StructureStrongholdPieces.strongholdStones); + this.placeDoor(par1World, par2Random, par3StructureBoundingBox, this.field_143013_d, 1, 1, 0); + + if (this.coordBaseMode != 2 && this.coordBaseMode != 3) + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 1, 1, 4, 3, 3, Blocks.air, Blocks.air, false); + } + else + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 1, 1, 0, 3, 3, Blocks.air, Blocks.air, false); + } + + return true; + } + } + } + + public static class Library extends StructureStrongholdPieces.Stronghold + { + public static final WeightedRandomChestContent[] strongholdLibraryChestContents = new WeightedRandomChestContent[] {new WeightedRandomChestContent(Items.book, 0, 1, 3, 20), new WeightedRandomChestContent(Items.paper, 0, 2, 7, 20), new WeightedRandomChestContent(Items.map, 0, 1, 1, 1), new WeightedRandomChestContent(Items.compass, 0, 1, 1, 1)}; + private boolean isLargeRoom; + private static final String __OBFID = "CL_00000491"; + + public Library() {} + + public Library(int par1, Random par2Random, StructureBoundingBox par3StructureBoundingBox, int par4) + { + super(par1); + this.coordBaseMode = par4; + this.field_143013_d = this.getRandomDoor(par2Random); + this.boundingBox = par3StructureBoundingBox; + this.isLargeRoom = par3StructureBoundingBox.getYSize() > 6; + } + + protected void func_143012_a(NBTTagCompound par1NBTTagCompound) + { + super.func_143012_a(par1NBTTagCompound); + par1NBTTagCompound.setBoolean("Tall", this.isLargeRoom); + } + + protected void func_143011_b(NBTTagCompound par1NBTTagCompound) + { + super.func_143011_b(par1NBTTagCompound); + this.isLargeRoom = par1NBTTagCompound.getBoolean("Tall"); + } + + public static StructureStrongholdPieces.Library findValidPlacement(List par0List, Random par1Random, int par2, int par3, int par4, int par5, int par6) + { + StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(par2, par3, par4, -4, -1, 0, 14, 11, 15, par5); + + if (!canStrongholdGoDeeper(structureboundingbox) || StructureComponent.findIntersecting(par0List, structureboundingbox) != null) + { + structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(par2, par3, par4, -4, -1, 0, 14, 6, 15, par5); + + if (!canStrongholdGoDeeper(structureboundingbox) || StructureComponent.findIntersecting(par0List, structureboundingbox) != null) + { + return null; + } + } + + return new StructureStrongholdPieces.Library(par6, par1Random, structureboundingbox, par5); + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + if (this.isLiquidInStructureBoundingBox(par1World, par3StructureBoundingBox)) + { + return false; + } + else + { + byte b0 = 11; + + if (!this.isLargeRoom) + { + b0 = 6; + } + + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 0, 0, 0, 13, b0 - 1, 14, true, par2Random, StructureStrongholdPieces.strongholdStones); + this.placeDoor(par1World, par2Random, par3StructureBoundingBox, this.field_143013_d, 4, 1, 0); + this.randomlyFillWithBlocks(par1World, par3StructureBoundingBox, par2Random, 0.07F, 2, 1, 1, 11, 4, 13, Blocks.web, Blocks.web, false); + boolean flag = true; + boolean flag1 = true; + int i; + + for (i = 1; i <= 13; ++i) + { + if ((i - 1) % 4 == 0) + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 1, i, 1, 4, i, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 12, 1, i, 12, 4, i, Blocks.planks, Blocks.planks, false); + this.placeBlockAtCurrentPosition(par1World, Blocks.torch, 0, 2, 3, i, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.torch, 0, 11, 3, i, par3StructureBoundingBox); + + if (this.isLargeRoom) + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 6, i, 1, 9, i, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 12, 6, i, 12, 9, i, Blocks.planks, Blocks.planks, false); + } + } + else + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 1, i, 1, 4, i, Blocks.bookshelf, Blocks.bookshelf, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 12, 1, i, 12, 4, i, Blocks.bookshelf, Blocks.bookshelf, false); + + if (this.isLargeRoom) + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 6, i, 1, 9, i, Blocks.bookshelf, Blocks.bookshelf, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 12, 6, i, 12, 9, i, Blocks.bookshelf, Blocks.bookshelf, false); + } + } + } + + for (i = 3; i < 12; i += 2) + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, 3, 1, i, 4, 3, i, Blocks.bookshelf, Blocks.bookshelf, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 6, 1, i, 7, 3, i, Blocks.bookshelf, Blocks.bookshelf, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 9, 1, i, 10, 3, i, Blocks.bookshelf, Blocks.bookshelf, false); + } + + if (this.isLargeRoom) + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 5, 1, 3, 5, 13, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 10, 5, 1, 12, 5, 13, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 5, 1, 9, 5, 2, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 5, 12, 9, 5, 13, Blocks.planks, Blocks.planks, false); + this.placeBlockAtCurrentPosition(par1World, Blocks.planks, 0, 9, 5, 11, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.planks, 0, 8, 5, 11, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.planks, 0, 9, 5, 10, par3StructureBoundingBox); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 3, 6, 2, 3, 6, 12, Blocks.fence, Blocks.fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 10, 6, 2, 10, 6, 10, Blocks.fence, Blocks.fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 6, 2, 9, 6, 2, Blocks.fence, Blocks.fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 6, 12, 8, 6, 12, Blocks.fence, Blocks.fence, false); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, 9, 6, 11, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, 8, 6, 11, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, 9, 6, 10, par3StructureBoundingBox); + i = this.getMetadataWithOffset(Blocks.ladder, 3); + this.placeBlockAtCurrentPosition(par1World, Blocks.ladder, i, 10, 1, 13, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.ladder, i, 10, 2, 13, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.ladder, i, 10, 3, 13, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.ladder, i, 10, 4, 13, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.ladder, i, 10, 5, 13, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.ladder, i, 10, 6, 13, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.ladder, i, 10, 7, 13, par3StructureBoundingBox); + byte b1 = 7; + byte b2 = 7; + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, b1 - 1, 9, b2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, b1, 9, b2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, b1 - 1, 8, b2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, b1, 8, b2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, b1 - 1, 7, b2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, b1, 7, b2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, b1 - 2, 7, b2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, b1 + 1, 7, b2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, b1 - 1, 7, b2 - 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, b1 - 1, 7, b2 + 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, b1, 7, b2 - 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, b1, 7, b2 + 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.torch, 0, b1 - 2, 8, b2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.torch, 0, b1 + 1, 8, b2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.torch, 0, b1 - 1, 8, b2 - 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.torch, 0, b1 - 1, 8, b2 + 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.torch, 0, b1, 8, b2 - 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.torch, 0, b1, 8, b2 + 1, par3StructureBoundingBox); + } + + ChestGenHooks info = ChestGenHooks.getInfo(STRONGHOLD_LIBRARY); + + this.generateStructureChestContents(par1World, par3StructureBoundingBox, par2Random, 3, 3, 5, info.getItems(par2Random), info.getCount(par2Random)); + + if (this.isLargeRoom) + { + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, 12, 9, 1, par3StructureBoundingBox); + this.generateStructureChestContents(par1World, par3StructureBoundingBox, par2Random, 12, 8, 1, info.getItems(par2Random), info.getCount(par2Random)); + } + + return true; + } + } + } + + static class PieceWeight + { + public Class pieceClass; + public final int pieceWeight; + public int instancesSpawned; + public int instancesLimit; + private static final String __OBFID = "CL_00000492"; + + public PieceWeight(Class par1Class, int par2, int par3) + { + this.pieceClass = par1Class; + this.pieceWeight = par2; + this.instancesLimit = par3; + } + + public boolean canSpawnMoreStructuresOfType(int par1) + { + return this.instancesLimit == 0 || this.instancesSpawned < this.instancesLimit; + } + + public boolean canSpawnMoreStructures() + { + return this.instancesLimit == 0 || this.instancesSpawned < this.instancesLimit; + } + } + + public static class PortalRoom extends StructureStrongholdPieces.Stronghold + { + private boolean hasSpawner; + private static final String __OBFID = "CL_00000493"; + + public PortalRoom() {} + + public PortalRoom(int par1, Random par2Random, StructureBoundingBox par3StructureBoundingBox, int par4) + { + super(par1); + this.coordBaseMode = par4; + this.boundingBox = par3StructureBoundingBox; + } + + protected void func_143012_a(NBTTagCompound par1NBTTagCompound) + { + super.func_143012_a(par1NBTTagCompound); + par1NBTTagCompound.setBoolean("Mob", this.hasSpawner); + } + + protected void func_143011_b(NBTTagCompound par1NBTTagCompound) + { + super.func_143011_b(par1NBTTagCompound); + this.hasSpawner = par1NBTTagCompound.getBoolean("Mob"); + } + + public void buildComponent(StructureComponent par1StructureComponent, List par2List, Random par3Random) + { + if (par1StructureComponent != null) + { + ((StructureStrongholdPieces.Stairs2)par1StructureComponent).strongholdPortalRoom = this; + } + } + + public static StructureStrongholdPieces.PortalRoom findValidPlacement(List par0List, Random par1Random, int par2, int par3, int par4, int par5, int par6) + { + StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(par2, par3, par4, -4, -1, 0, 11, 8, 16, par5); + return canStrongholdGoDeeper(structureboundingbox) && StructureComponent.findIntersecting(par0List, structureboundingbox) == null ? new StructureStrongholdPieces.PortalRoom(par6, par1Random, structureboundingbox, par5) : null; + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 0, 0, 0, 10, 7, 15, false, par2Random, StructureStrongholdPieces.strongholdStones); + this.placeDoor(par1World, par2Random, par3StructureBoundingBox, StructureStrongholdPieces.Stronghold.Door.GRATES, 4, 1, 0); + byte b0 = 6; + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 1, b0, 1, 1, b0, 14, false, par2Random, StructureStrongholdPieces.strongholdStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 9, b0, 1, 9, b0, 14, false, par2Random, StructureStrongholdPieces.strongholdStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 2, b0, 1, 8, b0, 2, false, par2Random, StructureStrongholdPieces.strongholdStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 2, b0, 14, 8, b0, 14, false, par2Random, StructureStrongholdPieces.strongholdStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 1, 1, 1, 2, 1, 4, false, par2Random, StructureStrongholdPieces.strongholdStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 8, 1, 1, 9, 1, 4, false, par2Random, StructureStrongholdPieces.strongholdStones); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 1, 1, 1, 1, 3, Blocks.flowing_lava, Blocks.flowing_lava, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 9, 1, 1, 9, 1, 3, Blocks.flowing_lava, Blocks.flowing_lava, false); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 3, 1, 8, 7, 1, 12, false, par2Random, StructureStrongholdPieces.strongholdStones); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 1, 9, 6, 1, 11, Blocks.flowing_lava, Blocks.flowing_lava, false); + int i; + + for (i = 3; i < 14; i += 2) + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 3, i, 0, 4, i, Blocks.iron_bars, Blocks.iron_bars, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 10, 3, i, 10, 4, i, Blocks.iron_bars, Blocks.iron_bars, false); + } + + for (i = 2; i < 9; i += 2) + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, i, 3, 15, i, 4, 15, Blocks.iron_bars, Blocks.iron_bars, false); + } + + i = this.getMetadataWithOffset(Blocks.stone_brick_stairs, 3); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 4, 1, 5, 6, 1, 7, false, par2Random, StructureStrongholdPieces.strongholdStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 4, 2, 6, 6, 2, 7, false, par2Random, StructureStrongholdPieces.strongholdStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 4, 3, 7, 6, 3, 7, false, par2Random, StructureStrongholdPieces.strongholdStones); + + for (int j = 4; j <= 6; ++j) + { + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_brick_stairs, i, j, 1, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_brick_stairs, i, j, 2, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_brick_stairs, i, j, 3, 6, par3StructureBoundingBox); + } + + byte b4 = 2; + byte b1 = 0; + byte b2 = 3; + byte b3 = 1; + + switch (this.coordBaseMode) + { + case 0: + b4 = 0; + b1 = 2; + break; + case 1: + b4 = 1; + b1 = 3; + b2 = 0; + b3 = 2; + case 2: + default: + break; + case 3: + b4 = 3; + b1 = 1; + b2 = 0; + b3 = 2; + } + + this.placeBlockAtCurrentPosition(par1World, Blocks.end_portal_frame, b4 + (par2Random.nextFloat() > 0.9F ? 4 : 0), 4, 3, 8, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.end_portal_frame, b4 + (par2Random.nextFloat() > 0.9F ? 4 : 0), 5, 3, 8, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.end_portal_frame, b4 + (par2Random.nextFloat() > 0.9F ? 4 : 0), 6, 3, 8, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.end_portal_frame, b1 + (par2Random.nextFloat() > 0.9F ? 4 : 0), 4, 3, 12, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.end_portal_frame, b1 + (par2Random.nextFloat() > 0.9F ? 4 : 0), 5, 3, 12, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.end_portal_frame, b1 + (par2Random.nextFloat() > 0.9F ? 4 : 0), 6, 3, 12, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.end_portal_frame, b2 + (par2Random.nextFloat() > 0.9F ? 4 : 0), 3, 3, 9, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.end_portal_frame, b2 + (par2Random.nextFloat() > 0.9F ? 4 : 0), 3, 3, 10, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.end_portal_frame, b2 + (par2Random.nextFloat() > 0.9F ? 4 : 0), 3, 3, 11, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.end_portal_frame, b3 + (par2Random.nextFloat() > 0.9F ? 4 : 0), 7, 3, 9, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.end_portal_frame, b3 + (par2Random.nextFloat() > 0.9F ? 4 : 0), 7, 3, 10, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.end_portal_frame, b3 + (par2Random.nextFloat() > 0.9F ? 4 : 0), 7, 3, 11, par3StructureBoundingBox); + + if (!this.hasSpawner) + { + int i1 = this.getYWithOffset(3); + int k = this.getXWithOffset(5, 6); + int l = this.getZWithOffset(5, 6); + + if (par3StructureBoundingBox.isVecInside(k, i1, l)) + { + this.hasSpawner = true; + par1World.setBlock(k, i1, l, Blocks.mob_spawner, 0, 2); + TileEntityMobSpawner tileentitymobspawner = (TileEntityMobSpawner)par1World.getTileEntity(k, i1, l); + + if (tileentitymobspawner != null) + { + tileentitymobspawner.func_145881_a().setEntityName("Silverfish"); + } + } + } + + return true; + } + } + + public static class Prison extends StructureStrongholdPieces.Stronghold + { + private static final String __OBFID = "CL_00000494"; + + public Prison() {} + + public Prison(int par1, Random par2Random, StructureBoundingBox par3StructureBoundingBox, int par4) + { + super(par1); + this.coordBaseMode = par4; + this.field_143013_d = this.getRandomDoor(par2Random); + this.boundingBox = par3StructureBoundingBox; + } + + public void buildComponent(StructureComponent par1StructureComponent, List par2List, Random par3Random) + { + this.getNextComponentNormal((StructureStrongholdPieces.Stairs2)par1StructureComponent, par2List, par3Random, 1, 1); + } + + public static StructureStrongholdPieces.Prison findValidPlacement(List par0List, Random par1Random, int par2, int par3, int par4, int par5, int par6) + { + StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(par2, par3, par4, -1, -1, 0, 9, 5, 11, par5); + return canStrongholdGoDeeper(structureboundingbox) && StructureComponent.findIntersecting(par0List, structureboundingbox) == null ? new StructureStrongholdPieces.Prison(par6, par1Random, structureboundingbox, par5) : null; + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + if (this.isLiquidInStructureBoundingBox(par1World, par3StructureBoundingBox)) + { + return false; + } + else + { + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 0, 0, 0, 8, 4, 10, true, par2Random, StructureStrongholdPieces.strongholdStones); + this.placeDoor(par1World, par2Random, par3StructureBoundingBox, this.field_143013_d, 1, 1, 0); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 1, 10, 3, 3, 10, Blocks.air, Blocks.air, false); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 4, 1, 1, 4, 3, 1, false, par2Random, StructureStrongholdPieces.strongholdStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 4, 1, 3, 4, 3, 3, false, par2Random, StructureStrongholdPieces.strongholdStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 4, 1, 7, 4, 3, 7, false, par2Random, StructureStrongholdPieces.strongholdStones); + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 4, 1, 9, 4, 3, 9, false, par2Random, StructureStrongholdPieces.strongholdStones); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 1, 4, 4, 3, 6, Blocks.iron_bars, Blocks.iron_bars, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 5, 1, 5, 7, 3, 5, Blocks.iron_bars, Blocks.iron_bars, false); + this.placeBlockAtCurrentPosition(par1World, Blocks.iron_bars, 0, 4, 3, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.iron_bars, 0, 4, 3, 8, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.iron_door, this.getMetadataWithOffset(Blocks.iron_door, 3), 4, 1, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.iron_door, this.getMetadataWithOffset(Blocks.iron_door, 3) + 8, 4, 2, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.iron_door, this.getMetadataWithOffset(Blocks.iron_door, 3), 4, 1, 8, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.iron_door, this.getMetadataWithOffset(Blocks.iron_door, 3) + 8, 4, 2, 8, par3StructureBoundingBox); + return true; + } + } + } + + public static class RightTurn extends StructureStrongholdPieces.LeftTurn + { + private static final String __OBFID = "CL_00000495"; + + public void buildComponent(StructureComponent par1StructureComponent, List par2List, Random par3Random) + { + if (this.coordBaseMode != 2 && this.coordBaseMode != 3) + { + this.getNextComponentX((StructureStrongholdPieces.Stairs2)par1StructureComponent, par2List, par3Random, 1, 1); + } + else + { + this.getNextComponentZ((StructureStrongholdPieces.Stairs2)par1StructureComponent, par2List, par3Random, 1, 1); + } + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + if (this.isLiquidInStructureBoundingBox(par1World, par3StructureBoundingBox)) + { + return false; + } + else + { + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 0, 0, 0, 4, 4, 4, true, par2Random, StructureStrongholdPieces.strongholdStones); + this.placeDoor(par1World, par2Random, par3StructureBoundingBox, this.field_143013_d, 1, 1, 0); + + if (this.coordBaseMode != 2 && this.coordBaseMode != 3) + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 1, 1, 0, 3, 3, Blocks.air, Blocks.air, false); + } + else + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 1, 1, 4, 3, 3, Blocks.air, Blocks.air, false); + } + + return true; + } + } + } + + public static class RoomCrossing extends StructureStrongholdPieces.Stronghold + { + public static final WeightedRandomChestContent[] strongholdRoomCrossingChestContents = new WeightedRandomChestContent[] {new WeightedRandomChestContent(Items.iron_ingot, 0, 1, 5, 10), new WeightedRandomChestContent(Items.gold_ingot, 0, 1, 3, 5), new WeightedRandomChestContent(Items.redstone, 0, 4, 9, 5), new WeightedRandomChestContent(Items.coal, 0, 3, 8, 10), new WeightedRandomChestContent(Items.bread, 0, 1, 3, 15), new WeightedRandomChestContent(Items.apple, 0, 1, 3, 15), new WeightedRandomChestContent(Items.iron_pickaxe, 0, 1, 1, 1)}; + protected int roomType; + private static final String __OBFID = "CL_00000496"; + + public RoomCrossing() {} + + public RoomCrossing(int par1, Random par2Random, StructureBoundingBox par3StructureBoundingBox, int par4) + { + super(par1); + this.coordBaseMode = par4; + this.field_143013_d = this.getRandomDoor(par2Random); + this.boundingBox = par3StructureBoundingBox; + this.roomType = par2Random.nextInt(5); + } + + protected void func_143012_a(NBTTagCompound par1NBTTagCompound) + { + super.func_143012_a(par1NBTTagCompound); + par1NBTTagCompound.setInteger("Type", this.roomType); + } + + protected void func_143011_b(NBTTagCompound par1NBTTagCompound) + { + super.func_143011_b(par1NBTTagCompound); + this.roomType = par1NBTTagCompound.getInteger("Type"); + } + + public void buildComponent(StructureComponent par1StructureComponent, List par2List, Random par3Random) + { + this.getNextComponentNormal((StructureStrongholdPieces.Stairs2)par1StructureComponent, par2List, par3Random, 4, 1); + this.getNextComponentX((StructureStrongholdPieces.Stairs2)par1StructureComponent, par2List, par3Random, 1, 4); + this.getNextComponentZ((StructureStrongholdPieces.Stairs2)par1StructureComponent, par2List, par3Random, 1, 4); + } + + public static StructureStrongholdPieces.RoomCrossing findValidPlacement(List par0List, Random par1Random, int par2, int par3, int par4, int par5, int par6) + { + StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(par2, par3, par4, -4, -1, 0, 11, 7, 11, par5); + return canStrongholdGoDeeper(structureboundingbox) && StructureComponent.findIntersecting(par0List, structureboundingbox) == null ? new StructureStrongholdPieces.RoomCrossing(par6, par1Random, structureboundingbox, par5) : null; + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + if (this.isLiquidInStructureBoundingBox(par1World, par3StructureBoundingBox)) + { + return false; + } + else + { + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 0, 0, 0, 10, 6, 10, true, par2Random, StructureStrongholdPieces.strongholdStones); + this.placeDoor(par1World, par2Random, par3StructureBoundingBox, this.field_143013_d, 4, 1, 0); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 1, 10, 6, 3, 10, Blocks.air, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 1, 4, 0, 3, 6, Blocks.air, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 10, 1, 4, 10, 3, 6, Blocks.air, Blocks.air, false); + int i; + + switch (this.roomType) + { + case 0: + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, 5, 1, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, 5, 2, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, 5, 3, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.torch, 0, 4, 3, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.torch, 0, 6, 3, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.torch, 0, 5, 3, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.torch, 0, 5, 3, 6, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_slab, 0, 4, 1, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_slab, 0, 4, 1, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_slab, 0, 4, 1, 6, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_slab, 0, 6, 1, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_slab, 0, 6, 1, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_slab, 0, 6, 1, 6, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_slab, 0, 5, 1, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_slab, 0, 5, 1, 6, par3StructureBoundingBox); + break; + case 1: + for (i = 0; i < 5; ++i) + { + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, 3, 1, 3 + i, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, 7, 1, 3 + i, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, 3 + i, 1, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, 3 + i, 1, 7, par3StructureBoundingBox); + } + + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, 5, 1, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, 5, 2, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, 5, 3, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.flowing_water, 0, 5, 4, 5, par3StructureBoundingBox); + break; + case 2: + for (i = 1; i <= 9; ++i) + { + this.placeBlockAtCurrentPosition(par1World, Blocks.cobblestone, 0, 1, 3, i, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.cobblestone, 0, 9, 3, i, par3StructureBoundingBox); + } + + for (i = 1; i <= 9; ++i) + { + this.placeBlockAtCurrentPosition(par1World, Blocks.cobblestone, 0, i, 3, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.cobblestone, 0, i, 3, 9, par3StructureBoundingBox); + } + + this.placeBlockAtCurrentPosition(par1World, Blocks.cobblestone, 0, 5, 1, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.cobblestone, 0, 5, 1, 6, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.cobblestone, 0, 5, 3, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.cobblestone, 0, 5, 3, 6, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.cobblestone, 0, 4, 1, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.cobblestone, 0, 6, 1, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.cobblestone, 0, 4, 3, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.cobblestone, 0, 6, 3, 5, par3StructureBoundingBox); + + for (i = 1; i <= 3; ++i) + { + this.placeBlockAtCurrentPosition(par1World, Blocks.cobblestone, 0, 4, i, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.cobblestone, 0, 6, i, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.cobblestone, 0, 4, i, 6, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.cobblestone, 0, 6, i, 6, par3StructureBoundingBox); + } + + this.placeBlockAtCurrentPosition(par1World, Blocks.torch, 0, 5, 3, 5, par3StructureBoundingBox); + + for (i = 2; i <= 8; ++i) + { + this.placeBlockAtCurrentPosition(par1World, Blocks.planks, 0, 2, 3, i, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.planks, 0, 3, 3, i, par3StructureBoundingBox); + + if (i <= 3 || i >= 7) + { + this.placeBlockAtCurrentPosition(par1World, Blocks.planks, 0, 4, 3, i, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.planks, 0, 5, 3, i, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.planks, 0, 6, 3, i, par3StructureBoundingBox); + } + + this.placeBlockAtCurrentPosition(par1World, Blocks.planks, 0, 7, 3, i, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.planks, 0, 8, 3, i, par3StructureBoundingBox); + } + + this.placeBlockAtCurrentPosition(par1World, Blocks.ladder, this.getMetadataWithOffset(Blocks.ladder, 4), 9, 1, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.ladder, this.getMetadataWithOffset(Blocks.ladder, 4), 9, 2, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.ladder, this.getMetadataWithOffset(Blocks.ladder, 4), 9, 3, 3, par3StructureBoundingBox); + this.generateStructureChestContents(par1World, par3StructureBoundingBox, par2Random, 3, 4, 8, ChestGenHooks.getItems(STRONGHOLD_CROSSING, par2Random), ChestGenHooks.getCount(STRONGHOLD_CROSSING, par2Random)); + } + + return true; + } + } + } + + public static class Stairs extends StructureStrongholdPieces.Stronghold + { + private boolean field_75024_a; + private static final String __OBFID = "CL_00000498"; + + public Stairs() {} + + public Stairs(int par1, Random par2Random, int par3, int par4) + { + super(par1); + this.field_75024_a = true; + this.coordBaseMode = par2Random.nextInt(4); + this.field_143013_d = StructureStrongholdPieces.Stronghold.Door.OPENING; + + switch (this.coordBaseMode) + { + case 0: + case 2: + this.boundingBox = new StructureBoundingBox(par3, 64, par4, par3 + 5 - 1, 74, par4 + 5 - 1); + break; + default: + this.boundingBox = new StructureBoundingBox(par3, 64, par4, par3 + 5 - 1, 74, par4 + 5 - 1); + } + } + + public Stairs(int par1, Random par2Random, StructureBoundingBox par3StructureBoundingBox, int par4) + { + super(par1); + this.field_75024_a = false; + this.coordBaseMode = par4; + this.field_143013_d = this.getRandomDoor(par2Random); + this.boundingBox = par3StructureBoundingBox; + } + + protected void func_143012_a(NBTTagCompound par1NBTTagCompound) + { + super.func_143012_a(par1NBTTagCompound); + par1NBTTagCompound.setBoolean("Source", this.field_75024_a); + } + + protected void func_143011_b(NBTTagCompound par1NBTTagCompound) + { + super.func_143011_b(par1NBTTagCompound); + this.field_75024_a = par1NBTTagCompound.getBoolean("Source"); + } + + public void buildComponent(StructureComponent par1StructureComponent, List par2List, Random par3Random) + { + if (this.field_75024_a) + { + StructureStrongholdPieces.strongComponentType = StructureStrongholdPieces.Crossing.class; + } + + this.getNextComponentNormal((StructureStrongholdPieces.Stairs2)par1StructureComponent, par2List, par3Random, 1, 1); + } + + public static StructureStrongholdPieces.Stairs getStrongholdStairsComponent(List par0List, Random par1Random, int par2, int par3, int par4, int par5, int par6) + { + StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(par2, par3, par4, -1, -7, 0, 5, 11, 5, par5); + return canStrongholdGoDeeper(structureboundingbox) && StructureComponent.findIntersecting(par0List, structureboundingbox) == null ? new StructureStrongholdPieces.Stairs(par6, par1Random, structureboundingbox, par5) : null; + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + if (this.isLiquidInStructureBoundingBox(par1World, par3StructureBoundingBox)) + { + return false; + } + else + { + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 0, 0, 0, 4, 10, 4, true, par2Random, StructureStrongholdPieces.strongholdStones); + this.placeDoor(par1World, par2Random, par3StructureBoundingBox, this.field_143013_d, 1, 7, 0); + this.placeDoor(par1World, par2Random, par3StructureBoundingBox, StructureStrongholdPieces.Stronghold.Door.OPENING, 1, 1, 4); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, 2, 6, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, 1, 5, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_slab, 0, 1, 6, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, 1, 5, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, 1, 4, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_slab, 0, 1, 5, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, 2, 4, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, 3, 3, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_slab, 0, 3, 4, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, 3, 3, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, 3, 2, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_slab, 0, 3, 3, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, 2, 2, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, 1, 1, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_slab, 0, 1, 2, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, 1, 1, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_slab, 0, 1, 1, 3, par3StructureBoundingBox); + return true; + } + } + } + + public static class Stairs2 extends StructureStrongholdPieces.Stairs + { + public StructureStrongholdPieces.PieceWeight strongholdPieceWeight; + public StructureStrongholdPieces.PortalRoom strongholdPortalRoom; + public List field_75026_c = new ArrayList(); + private static final String __OBFID = "CL_00000499"; + + public Stairs2() {} + + public Stairs2(int par1, Random par2Random, int par3, int par4) + { + super(0, par2Random, par3, par4); + } + + public ChunkPosition func_151553_a() + { + return this.strongholdPortalRoom != null ? this.strongholdPortalRoom.func_151553_a() : super.func_151553_a(); + } + } + + public static class StairsStraight extends StructureStrongholdPieces.Stronghold + { + private static final String __OBFID = "CL_00000501"; + + public StairsStraight() {} + + public StairsStraight(int par1, Random par2Random, StructureBoundingBox par3StructureBoundingBox, int par4) + { + super(par1); + this.coordBaseMode = par4; + this.field_143013_d = this.getRandomDoor(par2Random); + this.boundingBox = par3StructureBoundingBox; + } + + public void buildComponent(StructureComponent par1StructureComponent, List par2List, Random par3Random) + { + this.getNextComponentNormal((StructureStrongholdPieces.Stairs2)par1StructureComponent, par2List, par3Random, 1, 1); + } + + public static StructureStrongholdPieces.StairsStraight findValidPlacement(List par0List, Random par1Random, int par2, int par3, int par4, int par5, int par6) + { + StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(par2, par3, par4, -1, -7, 0, 5, 11, 8, par5); + return canStrongholdGoDeeper(structureboundingbox) && StructureComponent.findIntersecting(par0List, structureboundingbox) == null ? new StructureStrongholdPieces.StairsStraight(par6, par1Random, structureboundingbox, par5) : null; + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + if (this.isLiquidInStructureBoundingBox(par1World, par3StructureBoundingBox)) + { + return false; + } + else + { + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 0, 0, 0, 4, 10, 7, true, par2Random, StructureStrongholdPieces.strongholdStones); + this.placeDoor(par1World, par2Random, par3StructureBoundingBox, this.field_143013_d, 1, 7, 0); + this.placeDoor(par1World, par2Random, par3StructureBoundingBox, StructureStrongholdPieces.Stronghold.Door.OPENING, 1, 1, 7); + int i = this.getMetadataWithOffset(Blocks.stone_stairs, 2); + + for (int j = 0; j < 6; ++j) + { + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_stairs, i, 1, 6 - j, 1 + j, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_stairs, i, 2, 6 - j, 1 + j, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_stairs, i, 3, 6 - j, 1 + j, par3StructureBoundingBox); + + if (j < 5) + { + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, 1, 5 - j, 1 + j, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, 2, 5 - j, 1 + j, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, 3, 5 - j, 1 + j, par3StructureBoundingBox); + } + } + + return true; + } + } + } + + static class Stones extends StructureComponent.BlockSelector + { + private static final String __OBFID = "CL_00000497"; + + private Stones() {} + + public void selectBlocks(Random par1Random, int par2, int par3, int par4, boolean par5) + { + if (par5) + { + this.field_151562_a = Blocks.stonebrick; + float f = par1Random.nextFloat(); + + if (f < 0.2F) + { + this.selectedBlockMetaData = 2; + } + else if (f < 0.5F) + { + this.selectedBlockMetaData = 1; + } + else if (f < 0.55F) + { + this.field_151562_a = Blocks.monster_egg; + this.selectedBlockMetaData = 2; + } + else + { + this.selectedBlockMetaData = 0; + } + } + else + { + this.field_151562_a = Blocks.air; + this.selectedBlockMetaData = 0; + } + } + + Stones(Object par1StructureStrongholdPieceWeight2) + { + this(); + } + } + + public static class Straight extends StructureStrongholdPieces.Stronghold + { + private boolean expandsX; + private boolean expandsZ; + private static final String __OBFID = "CL_00000500"; + + public Straight() {} + + public Straight(int par1, Random par2Random, StructureBoundingBox par3StructureBoundingBox, int par4) + { + super(par1); + this.coordBaseMode = par4; + this.field_143013_d = this.getRandomDoor(par2Random); + this.boundingBox = par3StructureBoundingBox; + this.expandsX = par2Random.nextInt(2) == 0; + this.expandsZ = par2Random.nextInt(2) == 0; + } + + protected void func_143012_a(NBTTagCompound par1NBTTagCompound) + { + super.func_143012_a(par1NBTTagCompound); + par1NBTTagCompound.setBoolean("Left", this.expandsX); + par1NBTTagCompound.setBoolean("Right", this.expandsZ); + } + + protected void func_143011_b(NBTTagCompound par1NBTTagCompound) + { + super.func_143011_b(par1NBTTagCompound); + this.expandsX = par1NBTTagCompound.getBoolean("Left"); + this.expandsZ = par1NBTTagCompound.getBoolean("Right"); + } + + public void buildComponent(StructureComponent par1StructureComponent, List par2List, Random par3Random) + { + this.getNextComponentNormal((StructureStrongholdPieces.Stairs2)par1StructureComponent, par2List, par3Random, 1, 1); + + if (this.expandsX) + { + this.getNextComponentX((StructureStrongholdPieces.Stairs2)par1StructureComponent, par2List, par3Random, 1, 2); + } + + if (this.expandsZ) + { + this.getNextComponentZ((StructureStrongholdPieces.Stairs2)par1StructureComponent, par2List, par3Random, 1, 2); + } + } + + public static StructureStrongholdPieces.Straight findValidPlacement(List par0List, Random par1Random, int par2, int par3, int par4, int par5, int par6) + { + StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(par2, par3, par4, -1, -1, 0, 5, 5, 7, par5); + return canStrongholdGoDeeper(structureboundingbox) && StructureComponent.findIntersecting(par0List, structureboundingbox) == null ? new StructureStrongholdPieces.Straight(par6, par1Random, structureboundingbox, par5) : null; + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + if (this.isLiquidInStructureBoundingBox(par1World, par3StructureBoundingBox)) + { + return false; + } + else + { + this.fillWithRandomizedBlocks(par1World, par3StructureBoundingBox, 0, 0, 0, 4, 4, 6, true, par2Random, StructureStrongholdPieces.strongholdStones); + this.placeDoor(par1World, par2Random, par3StructureBoundingBox, this.field_143013_d, 1, 1, 0); + this.placeDoor(par1World, par2Random, par3StructureBoundingBox, StructureStrongholdPieces.Stronghold.Door.OPENING, 1, 1, 6); + this.func_151552_a(par1World, par3StructureBoundingBox, par2Random, 0.1F, 1, 2, 1, Blocks.torch, 0); + this.func_151552_a(par1World, par3StructureBoundingBox, par2Random, 0.1F, 3, 2, 1, Blocks.torch, 0); + this.func_151552_a(par1World, par3StructureBoundingBox, par2Random, 0.1F, 1, 2, 5, Blocks.torch, 0); + this.func_151552_a(par1World, par3StructureBoundingBox, par2Random, 0.1F, 3, 2, 5, Blocks.torch, 0); + + if (this.expandsX) + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 1, 2, 0, 3, 4, Blocks.air, Blocks.air, false); + } + + if (this.expandsZ) + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 1, 2, 4, 3, 4, Blocks.air, Blocks.air, false); + } + + return true; + } + } + } + + public abstract static class Stronghold extends StructureComponent + { + protected StructureStrongholdPieces.Stronghold.Door field_143013_d; + private static final String __OBFID = "CL_00000503"; + + public Stronghold() + { + this.field_143013_d = StructureStrongholdPieces.Stronghold.Door.OPENING; + } + + protected Stronghold(int par1) + { + super(par1); + this.field_143013_d = StructureStrongholdPieces.Stronghold.Door.OPENING; + } + + protected void func_143012_a(NBTTagCompound par1NBTTagCompound) + { + par1NBTTagCompound.setString("EntryDoor", this.field_143013_d.name()); + } + + protected void func_143011_b(NBTTagCompound par1NBTTagCompound) + { + this.field_143013_d = StructureStrongholdPieces.Stronghold.Door.valueOf(par1NBTTagCompound.getString("EntryDoor")); + } + + protected void placeDoor(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox, StructureStrongholdPieces.Stronghold.Door par4EnumDoor, int par5, int par6, int par7) + { + switch (StructureStrongholdPieces.SwitchDoor.doorEnum[par4EnumDoor.ordinal()]) + { + case 1: + default: + this.fillWithBlocks(par1World, par3StructureBoundingBox, par5, par6, par7, par5 + 3 - 1, par6 + 3 - 1, par7, Blocks.air, Blocks.air, false); + break; + case 2: + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, par5, par6, par7, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, par5, par6 + 1, par7, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, par5, par6 + 2, par7, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, par5 + 1, par6 + 2, par7, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, par5 + 2, par6 + 2, par7, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, par5 + 2, par6 + 1, par7, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, par5 + 2, par6, par7, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.wooden_door, 0, par5 + 1, par6, par7, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.wooden_door, 8, par5 + 1, par6 + 1, par7, par3StructureBoundingBox); + break; + case 3: + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, par5 + 1, par6, par7, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, par5 + 1, par6 + 1, par7, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.iron_bars, 0, par5, par6, par7, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.iron_bars, 0, par5, par6 + 1, par7, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.iron_bars, 0, par5, par6 + 2, par7, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.iron_bars, 0, par5 + 1, par6 + 2, par7, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.iron_bars, 0, par5 + 2, par6 + 2, par7, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.iron_bars, 0, par5 + 2, par6 + 1, par7, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.iron_bars, 0, par5 + 2, par6, par7, par3StructureBoundingBox); + break; + case 4: + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, par5, par6, par7, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, par5, par6 + 1, par7, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, par5, par6 + 2, par7, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, par5 + 1, par6 + 2, par7, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, par5 + 2, par6 + 2, par7, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, par5 + 2, par6 + 1, par7, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stonebrick, 0, par5 + 2, par6, par7, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.iron_door, 0, par5 + 1, par6, par7, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.iron_door, 8, par5 + 1, par6 + 1, par7, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_button, this.getMetadataWithOffset(Blocks.stone_button, 4), par5 + 2, par6 + 1, par7 + 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_button, this.getMetadataWithOffset(Blocks.stone_button, 3), par5 + 2, par6 + 1, par7 - 1, par3StructureBoundingBox); + } + } + + protected StructureStrongholdPieces.Stronghold.Door getRandomDoor(Random par1Random) + { + int i = par1Random.nextInt(5); + + switch (i) + { + case 0: + case 1: + default: + return StructureStrongholdPieces.Stronghold.Door.OPENING; + case 2: + return StructureStrongholdPieces.Stronghold.Door.WOOD_DOOR; + case 3: + return StructureStrongholdPieces.Stronghold.Door.GRATES; + case 4: + return StructureStrongholdPieces.Stronghold.Door.IRON_DOOR; + } + } + + protected StructureComponent getNextComponentNormal(StructureStrongholdPieces.Stairs2 par1ComponentStrongholdStairs2, List par2List, Random par3Random, int par4, int par5) + { + switch (this.coordBaseMode) + { + case 0: + return StructureStrongholdPieces.getNextValidComponent(par1ComponentStrongholdStairs2, par2List, par3Random, this.boundingBox.minX + par4, this.boundingBox.minY + par5, this.boundingBox.maxZ + 1, this.coordBaseMode, this.getComponentType()); + case 1: + return StructureStrongholdPieces.getNextValidComponent(par1ComponentStrongholdStairs2, par2List, par3Random, this.boundingBox.minX - 1, this.boundingBox.minY + par5, this.boundingBox.minZ + par4, this.coordBaseMode, this.getComponentType()); + case 2: + return StructureStrongholdPieces.getNextValidComponent(par1ComponentStrongholdStairs2, par2List, par3Random, this.boundingBox.minX + par4, this.boundingBox.minY + par5, this.boundingBox.minZ - 1, this.coordBaseMode, this.getComponentType()); + case 3: + return StructureStrongholdPieces.getNextValidComponent(par1ComponentStrongholdStairs2, par2List, par3Random, this.boundingBox.maxX + 1, this.boundingBox.minY + par5, this.boundingBox.minZ + par4, this.coordBaseMode, this.getComponentType()); + default: + return null; + } + } + + protected StructureComponent getNextComponentX(StructureStrongholdPieces.Stairs2 par1ComponentStrongholdStairs2, List par2List, Random par3Random, int par4, int par5) + { + switch (this.coordBaseMode) + { + case 0: + return StructureStrongholdPieces.getNextValidComponent(par1ComponentStrongholdStairs2, par2List, par3Random, this.boundingBox.minX - 1, this.boundingBox.minY + par4, this.boundingBox.minZ + par5, 1, this.getComponentType()); + case 1: + return StructureStrongholdPieces.getNextValidComponent(par1ComponentStrongholdStairs2, par2List, par3Random, this.boundingBox.minX + par5, this.boundingBox.minY + par4, this.boundingBox.minZ - 1, 2, this.getComponentType()); + case 2: + return StructureStrongholdPieces.getNextValidComponent(par1ComponentStrongholdStairs2, par2List, par3Random, this.boundingBox.minX - 1, this.boundingBox.minY + par4, this.boundingBox.minZ + par5, 1, this.getComponentType()); + case 3: + return StructureStrongholdPieces.getNextValidComponent(par1ComponentStrongholdStairs2, par2List, par3Random, this.boundingBox.minX + par5, this.boundingBox.minY + par4, this.boundingBox.minZ - 1, 2, this.getComponentType()); + default: + return null; + } + } + + protected StructureComponent getNextComponentZ(StructureStrongholdPieces.Stairs2 par1ComponentStrongholdStairs2, List par2List, Random par3Random, int par4, int par5) + { + switch (this.coordBaseMode) + { + case 0: + return StructureStrongholdPieces.getNextValidComponent(par1ComponentStrongholdStairs2, par2List, par3Random, this.boundingBox.maxX + 1, this.boundingBox.minY + par4, this.boundingBox.minZ + par5, 3, this.getComponentType()); + case 1: + return StructureStrongholdPieces.getNextValidComponent(par1ComponentStrongholdStairs2, par2List, par3Random, this.boundingBox.minX + par5, this.boundingBox.minY + par4, this.boundingBox.maxZ + 1, 0, this.getComponentType()); + case 2: + return StructureStrongholdPieces.getNextValidComponent(par1ComponentStrongholdStairs2, par2List, par3Random, this.boundingBox.maxX + 1, this.boundingBox.minY + par4, this.boundingBox.minZ + par5, 3, this.getComponentType()); + case 3: + return StructureStrongholdPieces.getNextValidComponent(par1ComponentStrongholdStairs2, par2List, par3Random, this.boundingBox.minX + par5, this.boundingBox.minY + par4, this.boundingBox.maxZ + 1, 0, this.getComponentType()); + default: + return null; + } + } + + protected static boolean canStrongholdGoDeeper(StructureBoundingBox par0StructureBoundingBox) + { + return par0StructureBoundingBox != null && par0StructureBoundingBox.minY > 10; + } + + public static enum Door + { + OPENING, + WOOD_DOOR, + GRATES, + IRON_DOOR; + + private static final String __OBFID = "CL_00000504"; + } + } + + static final class SwitchDoor + { + static final int[] doorEnum = new int[StructureStrongholdPieces.Stronghold.Door.values().length]; + private static final String __OBFID = "CL_00000486"; + + static + { + try + { + doorEnum[StructureStrongholdPieces.Stronghold.Door.OPENING.ordinal()] = 1; + } + catch (NoSuchFieldError var4) + { + ; + } + + try + { + doorEnum[StructureStrongholdPieces.Stronghold.Door.WOOD_DOOR.ordinal()] = 2; + } + catch (NoSuchFieldError var3) + { + ; + } + + try + { + doorEnum[StructureStrongholdPieces.Stronghold.Door.GRATES.ordinal()] = 3; + } + catch (NoSuchFieldError var2) + { + ; + } + + try + { + doorEnum[StructureStrongholdPieces.Stronghold.Door.IRON_DOOR.ordinal()] = 4; + } + catch (NoSuchFieldError var1) + { + ; + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/gen/structure/StructureVillagePieces.java b/src/main/java/net/minecraft/world/gen/structure/StructureVillagePieces.java new file mode 100644 index 0000000..07cd5b9 --- /dev/null +++ b/src/main/java/net/minecraft/world/gen/structure/StructureVillagePieces.java @@ -0,0 +1,1906 @@ +package net.minecraft.world.gen.structure; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import cpw.mods.fml.common.eventhandler.Event.Result; +import cpw.mods.fml.common.registry.VillagerRegistry; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.passive.EntityVillager; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.MathHelper; +import net.minecraft.util.WeightedRandomChestContent; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.biome.WorldChunkManager; +import net.minecraftforge.common.ChestGenHooks; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.terraingen.BiomeEvent; +import static net.minecraftforge.common.ChestGenHooks.*; + +public class StructureVillagePieces +{ + private static final String __OBFID = "CL_00000516"; + + public static void registerVillagePieces() + { + MapGenStructureIO.func_143031_a(StructureVillagePieces.House1.class, "ViBH"); + MapGenStructureIO.func_143031_a(StructureVillagePieces.Field1.class, "ViDF"); + MapGenStructureIO.func_143031_a(StructureVillagePieces.Field2.class, "ViF"); + MapGenStructureIO.func_143031_a(StructureVillagePieces.Torch.class, "ViL"); + MapGenStructureIO.func_143031_a(StructureVillagePieces.Hall.class, "ViPH"); + MapGenStructureIO.func_143031_a(StructureVillagePieces.House4Garden.class, "ViSH"); + MapGenStructureIO.func_143031_a(StructureVillagePieces.WoodHut.class, "ViSmH"); + MapGenStructureIO.func_143031_a(StructureVillagePieces.Church.class, "ViST"); + MapGenStructureIO.func_143031_a(StructureVillagePieces.House2.class, "ViS"); + MapGenStructureIO.func_143031_a(StructureVillagePieces.Start.class, "ViStart"); + MapGenStructureIO.func_143031_a(StructureVillagePieces.Path.class, "ViSR"); + MapGenStructureIO.func_143031_a(StructureVillagePieces.House3.class, "ViTRH"); + MapGenStructureIO.func_143031_a(StructureVillagePieces.Well.class, "ViW"); + } + + public static List getStructureVillageWeightedPieceList(Random par0Random, int par1) + { + ArrayList arraylist = new ArrayList(); + arraylist.add(new StructureVillagePieces.PieceWeight(StructureVillagePieces.House4Garden.class, 4, MathHelper.getRandomIntegerInRange(par0Random, 2 + par1, 4 + par1 * 2))); + arraylist.add(new StructureVillagePieces.PieceWeight(StructureVillagePieces.Church.class, 20, MathHelper.getRandomIntegerInRange(par0Random, 0 + par1, 1 + par1))); + arraylist.add(new StructureVillagePieces.PieceWeight(StructureVillagePieces.House1.class, 20, MathHelper.getRandomIntegerInRange(par0Random, 0 + par1, 2 + par1))); + arraylist.add(new StructureVillagePieces.PieceWeight(StructureVillagePieces.WoodHut.class, 3, MathHelper.getRandomIntegerInRange(par0Random, 2 + par1, 5 + par1 * 3))); + arraylist.add(new StructureVillagePieces.PieceWeight(StructureVillagePieces.Hall.class, 15, MathHelper.getRandomIntegerInRange(par0Random, 0 + par1, 2 + par1))); + arraylist.add(new StructureVillagePieces.PieceWeight(StructureVillagePieces.Field1.class, 3, MathHelper.getRandomIntegerInRange(par0Random, 1 + par1, 4 + par1))); + arraylist.add(new StructureVillagePieces.PieceWeight(StructureVillagePieces.Field2.class, 3, MathHelper.getRandomIntegerInRange(par0Random, 2 + par1, 4 + par1 * 2))); + arraylist.add(new StructureVillagePieces.PieceWeight(StructureVillagePieces.House2.class, 15, MathHelper.getRandomIntegerInRange(par0Random, 0, 1 + par1))); + arraylist.add(new StructureVillagePieces.PieceWeight(StructureVillagePieces.House3.class, 8, MathHelper.getRandomIntegerInRange(par0Random, 0 + par1, 3 + par1 * 2))); + VillagerRegistry.addExtraVillageComponents(arraylist, par0Random, par1); + + Iterator iterator = arraylist.iterator(); + + while (iterator.hasNext()) + { + if (((StructureVillagePieces.PieceWeight)iterator.next()).villagePiecesLimit == 0) + { + iterator.remove(); + } + } + + return arraylist; + } + + private static int func_75079_a(List par0List) + { + boolean flag = false; + int i = 0; + StructureVillagePieces.PieceWeight pieceweight; + + for (Iterator iterator = par0List.iterator(); iterator.hasNext(); i += pieceweight.villagePieceWeight) + { + pieceweight = (StructureVillagePieces.PieceWeight)iterator.next(); + + if (pieceweight.villagePiecesLimit > 0 && pieceweight.villagePiecesSpawned < pieceweight.villagePiecesLimit) + { + flag = true; + } + } + + return flag ? i : -1; + } + + private static StructureVillagePieces.Village func_75083_a(StructureVillagePieces.Start par0ComponentVillageStartPiece, StructureVillagePieces.PieceWeight par1StructureVillagePieceWeight, List par2List, Random par3Random, int par4, int par5, int par6, int par7, int par8) + { + Class oclass = par1StructureVillagePieceWeight.villagePieceClass; + Object object = null; + + if (oclass == StructureVillagePieces.House4Garden.class) + { + object = StructureVillagePieces.House4Garden.func_74912_a(par0ComponentVillageStartPiece, par2List, par3Random, par4, par5, par6, par7, par8); + } + else if (oclass == StructureVillagePieces.Church.class) + { + object = StructureVillagePieces.Church.func_74919_a(par0ComponentVillageStartPiece, par2List, par3Random, par4, par5, par6, par7, par8); + } + else if (oclass == StructureVillagePieces.House1.class) + { + object = StructureVillagePieces.House1.func_74898_a(par0ComponentVillageStartPiece, par2List, par3Random, par4, par5, par6, par7, par8); + } + else if (oclass == StructureVillagePieces.WoodHut.class) + { + object = StructureVillagePieces.WoodHut.func_74908_a(par0ComponentVillageStartPiece, par2List, par3Random, par4, par5, par6, par7, par8); + } + else if (oclass == StructureVillagePieces.Hall.class) + { + object = StructureVillagePieces.Hall.func_74906_a(par0ComponentVillageStartPiece, par2List, par3Random, par4, par5, par6, par7, par8); + } + else if (oclass == StructureVillagePieces.Field1.class) + { + object = StructureVillagePieces.Field1.func_74900_a(par0ComponentVillageStartPiece, par2List, par3Random, par4, par5, par6, par7, par8); + } + else if (oclass == StructureVillagePieces.Field2.class) + { + object = StructureVillagePieces.Field2.func_74902_a(par0ComponentVillageStartPiece, par2List, par3Random, par4, par5, par6, par7, par8); + } + else if (oclass == StructureVillagePieces.House2.class) + { + object = StructureVillagePieces.House2.func_74915_a(par0ComponentVillageStartPiece, par2List, par3Random, par4, par5, par6, par7, par8); + } + else if (oclass == StructureVillagePieces.House3.class) + { + object = StructureVillagePieces.House3.func_74921_a(par0ComponentVillageStartPiece, par2List, par3Random, par4, par5, par6, par7, par8); + } + else + { + object = VillagerRegistry.getVillageComponent(par1StructureVillagePieceWeight, par0ComponentVillageStartPiece , par2List, par3Random, par4, par5, par6, par7, par8); + } + + return (StructureVillagePieces.Village)object; + } + + private static StructureVillagePieces.Village getNextVillageComponent(StructureVillagePieces.Start par0ComponentVillageStartPiece, List par1List, Random par2Random, int par3, int par4, int par5, int par6, int par7) + { + int j1 = func_75079_a(par0ComponentVillageStartPiece.structureVillageWeightedPieceList); + + if (j1 <= 0) + { + return null; + } + else + { + int k1 = 0; + + while (k1 < 5) + { + ++k1; + int l1 = par2Random.nextInt(j1); + Iterator iterator = par0ComponentVillageStartPiece.structureVillageWeightedPieceList.iterator(); + + while (iterator.hasNext()) + { + StructureVillagePieces.PieceWeight pieceweight = (StructureVillagePieces.PieceWeight)iterator.next(); + l1 -= pieceweight.villagePieceWeight; + + if (l1 < 0) + { + if (!pieceweight.canSpawnMoreVillagePiecesOfType(par7) || pieceweight == par0ComponentVillageStartPiece.structVillagePieceWeight && par0ComponentVillageStartPiece.structureVillageWeightedPieceList.size() > 1) + { + break; + } + + StructureVillagePieces.Village village = func_75083_a(par0ComponentVillageStartPiece, pieceweight, par1List, par2Random, par3, par4, par5, par6, par7); + + if (village != null) + { + ++pieceweight.villagePiecesSpawned; + par0ComponentVillageStartPiece.structVillagePieceWeight = pieceweight; + + if (!pieceweight.canSpawnMoreVillagePieces()) + { + par0ComponentVillageStartPiece.structureVillageWeightedPieceList.remove(pieceweight); + } + + return village; + } + } + } + } + + StructureBoundingBox structureboundingbox = StructureVillagePieces.Torch.func_74904_a(par0ComponentVillageStartPiece, par1List, par2Random, par3, par4, par5, par6); + + if (structureboundingbox != null) + { + return new StructureVillagePieces.Torch(par0ComponentVillageStartPiece, par7, par2Random, structureboundingbox, par6); + } + else + { + return null; + } + } + } + + private static StructureComponent getNextVillageStructureComponent(StructureVillagePieces.Start par0ComponentVillageStartPiece, List par1List, Random par2Random, int par3, int par4, int par5, int par6, int par7) + { + if (par7 > 50) + { + return null; + } + else if (Math.abs(par3 - par0ComponentVillageStartPiece.getBoundingBox().minX) <= 112 && Math.abs(par5 - par0ComponentVillageStartPiece.getBoundingBox().minZ) <= 112) + { + StructureVillagePieces.Village village = getNextVillageComponent(par0ComponentVillageStartPiece, par1List, par2Random, par3, par4, par5, par6, par7 + 1); + + if (village != null) + { + int j1 = (village.boundingBox.minX + village.boundingBox.maxX) / 2; + int k1 = (village.boundingBox.minZ + village.boundingBox.maxZ) / 2; + int l1 = village.boundingBox.maxX - village.boundingBox.minX; + int i2 = village.boundingBox.maxZ - village.boundingBox.minZ; + int j2 = l1 > i2 ? l1 : i2; + + if (par0ComponentVillageStartPiece.getWorldChunkManager().areBiomesViable(j1, k1, j2 / 2 + 4, MapGenVillage.villageSpawnBiomes)) + { + par1List.add(village); + par0ComponentVillageStartPiece.field_74932_i.add(village); + return village; + } + } + + return null; + } + else + { + return null; + } + } + + private static StructureComponent getNextComponentVillagePath(StructureVillagePieces.Start par0ComponentVillageStartPiece, List par1List, Random par2Random, int par3, int par4, int par5, int par6, int par7) + { + if (par7 > 3 + par0ComponentVillageStartPiece.terrainType) + { + return null; + } + else if (Math.abs(par3 - par0ComponentVillageStartPiece.getBoundingBox().minX) <= 112 && Math.abs(par5 - par0ComponentVillageStartPiece.getBoundingBox().minZ) <= 112) + { + StructureBoundingBox structureboundingbox = StructureVillagePieces.Path.func_74933_a(par0ComponentVillageStartPiece, par1List, par2Random, par3, par4, par5, par6); + + if (structureboundingbox != null && structureboundingbox.minY > 10) + { + StructureVillagePieces.Path path = new StructureVillagePieces.Path(par0ComponentVillageStartPiece, par7, par2Random, structureboundingbox, par6); + int j1 = (path.boundingBox.minX + path.boundingBox.maxX) / 2; + int k1 = (path.boundingBox.minZ + path.boundingBox.maxZ) / 2; + int l1 = path.boundingBox.maxX - path.boundingBox.minX; + int i2 = path.boundingBox.maxZ - path.boundingBox.minZ; + int j2 = l1 > i2 ? l1 : i2; + + if (par0ComponentVillageStartPiece.getWorldChunkManager().areBiomesViable(j1, k1, j2 / 2 + 4, MapGenVillage.villageSpawnBiomes)) + { + par1List.add(path); + par0ComponentVillageStartPiece.field_74930_j.add(path); + return path; + } + } + + return null; + } + else + { + return null; + } + } + + public static class Church extends StructureVillagePieces.Village + { + private static final String __OBFID = "CL_00000525"; + + public Church() {} + + public Church(StructureVillagePieces.Start par1ComponentVillageStartPiece, int par2, Random par3Random, StructureBoundingBox par4StructureBoundingBox, int par5) + { + super(par1ComponentVillageStartPiece, par2); + this.coordBaseMode = par5; + this.boundingBox = par4StructureBoundingBox; + } + + public static StructureVillagePieces.Church func_74919_a(StructureVillagePieces.Start par0ComponentVillageStartPiece, List par1List, Random par2Random, int par3, int par4, int par5, int par6, int par7) + { + StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(par3, par4, par5, 0, 0, 0, 5, 12, 9, par6); + return canVillageGoDeeper(structureboundingbox) && StructureComponent.findIntersecting(par1List, structureboundingbox) == null ? new StructureVillagePieces.Church(par0ComponentVillageStartPiece, par7, par2Random, structureboundingbox, par6) : null; + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + if (this.field_143015_k < 0) + { + this.field_143015_k = this.getAverageGroundLevel(par1World, par3StructureBoundingBox); + + if (this.field_143015_k < 0) + { + return true; + } + + this.boundingBox.offset(0, this.field_143015_k - this.boundingBox.maxY + 12 - 1, 0); + } + + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 1, 1, 3, 3, 7, Blocks.air, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 5, 1, 3, 9, 3, Blocks.air, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 0, 0, 3, 0, 8, Blocks.cobblestone, Blocks.cobblestone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 1, 0, 3, 10, 0, Blocks.cobblestone, Blocks.cobblestone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 1, 1, 0, 10, 3, Blocks.cobblestone, Blocks.cobblestone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 1, 1, 4, 10, 3, Blocks.cobblestone, Blocks.cobblestone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 0, 4, 0, 4, 7, Blocks.cobblestone, Blocks.cobblestone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 0, 4, 4, 4, 7, Blocks.cobblestone, Blocks.cobblestone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 1, 8, 3, 4, 8, Blocks.cobblestone, Blocks.cobblestone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 5, 4, 3, 10, 4, Blocks.cobblestone, Blocks.cobblestone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 5, 5, 3, 5, 7, Blocks.cobblestone, Blocks.cobblestone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 9, 0, 4, 9, 4, Blocks.cobblestone, Blocks.cobblestone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 4, 0, 4, 4, 4, Blocks.cobblestone, Blocks.cobblestone, false); + this.placeBlockAtCurrentPosition(par1World, Blocks.cobblestone, 0, 0, 11, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.cobblestone, 0, 4, 11, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.cobblestone, 0, 2, 11, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.cobblestone, 0, 2, 11, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.cobblestone, 0, 1, 1, 6, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.cobblestone, 0, 1, 1, 7, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.cobblestone, 0, 2, 1, 7, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.cobblestone, 0, 3, 1, 6, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.cobblestone, 0, 3, 1, 7, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_stairs, this.getMetadataWithOffset(Blocks.stone_stairs, 3), 1, 1, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_stairs, this.getMetadataWithOffset(Blocks.stone_stairs, 3), 2, 1, 6, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_stairs, this.getMetadataWithOffset(Blocks.stone_stairs, 3), 3, 1, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_stairs, this.getMetadataWithOffset(Blocks.stone_stairs, 1), 1, 2, 7, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_stairs, this.getMetadataWithOffset(Blocks.stone_stairs, 0), 3, 2, 7, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 0, 2, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 0, 3, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 4, 2, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 4, 3, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 0, 6, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 0, 7, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 4, 6, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 4, 7, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 2, 6, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 2, 7, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 2, 6, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 2, 7, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 0, 3, 6, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 4, 3, 6, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 2, 3, 8, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.torch, 0, 2, 4, 7, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.torch, 0, 1, 4, 6, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.torch, 0, 3, 4, 6, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.torch, 0, 2, 4, 5, par3StructureBoundingBox); + int i = this.getMetadataWithOffset(Blocks.ladder, 4); + int j; + + for (j = 1; j <= 9; ++j) + { + this.placeBlockAtCurrentPosition(par1World, Blocks.ladder, i, 3, j, 3, par3StructureBoundingBox); + } + + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, 2, 1, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, 2, 2, 0, par3StructureBoundingBox); + this.placeDoorAtCurrentPosition(par1World, par3StructureBoundingBox, par2Random, 2, 1, 0, this.getMetadataWithOffset(Blocks.wooden_door, 1)); + + if (this.getBlockAtCurrentPosition(par1World, 2, 0, -1, par3StructureBoundingBox).getMaterial() == Material.air && this.getBlockAtCurrentPosition(par1World, 2, -1, -1, par3StructureBoundingBox).getMaterial() != Material.air) + { + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_stairs, this.getMetadataWithOffset(Blocks.stone_stairs, 3), 2, 0, -1, par3StructureBoundingBox); + } + + for (j = 0; j < 9; ++j) + { + for (int k = 0; k < 5; ++k) + { + this.clearCurrentPositionBlocksUpwards(par1World, k, 12, j, par3StructureBoundingBox); + this.func_151554_b(par1World, Blocks.cobblestone, 0, k, -1, j, par3StructureBoundingBox); + } + } + + this.spawnVillagers(par1World, par3StructureBoundingBox, 2, 1, 2, 1); + return true; + } + + protected int getVillagerType(int par1) + { + return 2; + } + } + + public static class Field1 extends StructureVillagePieces.Village + { + private Block cropTypeA; + private Block cropTypeB; + private Block cropTypeC; + private Block cropTypeD; + private static final String __OBFID = "CL_00000518"; + + public Field1() {} + + public Field1(StructureVillagePieces.Start par1ComponentVillageStartPiece, int par2, Random par3Random, StructureBoundingBox par4StructureBoundingBox, int par5) + { + super(par1ComponentVillageStartPiece, par2); + this.coordBaseMode = par5; + this.boundingBox = par4StructureBoundingBox; + this.cropTypeA = this.func_151559_a(par3Random); + this.cropTypeB = this.func_151559_a(par3Random); + this.cropTypeC = this.func_151559_a(par3Random); + this.cropTypeD = this.func_151559_a(par3Random); + } + + protected void func_143012_a(NBTTagCompound par1NBTTagCompound) + { + super.func_143012_a(par1NBTTagCompound); + par1NBTTagCompound.setInteger("CA", Block.blockRegistry.getIDForObject(this.cropTypeA)); + par1NBTTagCompound.setInteger("CB", Block.blockRegistry.getIDForObject(this.cropTypeB)); + par1NBTTagCompound.setInteger("CC", Block.blockRegistry.getIDForObject(this.cropTypeC)); + par1NBTTagCompound.setInteger("CD", Block.blockRegistry.getIDForObject(this.cropTypeD)); + } + + protected void func_143011_b(NBTTagCompound par1NBTTagCompound) + { + super.func_143011_b(par1NBTTagCompound); + this.cropTypeA = Block.getBlockById(par1NBTTagCompound.getInteger("CA")); + this.cropTypeB = Block.getBlockById(par1NBTTagCompound.getInteger("CB")); + this.cropTypeC = Block.getBlockById(par1NBTTagCompound.getInteger("CC")); + this.cropTypeD = Block.getBlockById(par1NBTTagCompound.getInteger("CD")); + } + + private Block func_151559_a(Random p_151559_1_) + { + switch (p_151559_1_.nextInt(5)) + { + case 0: + return Blocks.carrots; + case 1: + return Blocks.potatoes; + default: + return Blocks.wheat; + } + } + + public static StructureVillagePieces.Field1 func_74900_a(StructureVillagePieces.Start par0ComponentVillageStartPiece, List par1List, Random par2Random, int par3, int par4, int par5, int par6, int par7) + { + StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(par3, par4, par5, 0, 0, 0, 13, 4, 9, par6); + return canVillageGoDeeper(structureboundingbox) && StructureComponent.findIntersecting(par1List, structureboundingbox) == null ? new StructureVillagePieces.Field1(par0ComponentVillageStartPiece, par7, par2Random, structureboundingbox, par6) : null; + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + if (this.field_143015_k < 0) + { + this.field_143015_k = this.getAverageGroundLevel(par1World, par3StructureBoundingBox); + + if (this.field_143015_k < 0) + { + return true; + } + + this.boundingBox.offset(0, this.field_143015_k - this.boundingBox.maxY + 4 - 1, 0); + } + + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 1, 0, 12, 4, 8, Blocks.air, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 0, 1, 2, 0, 7, Blocks.farmland, Blocks.farmland, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 0, 1, 5, 0, 7, Blocks.farmland, Blocks.farmland, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 7, 0, 1, 8, 0, 7, Blocks.farmland, Blocks.farmland, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 10, 0, 1, 11, 0, 7, Blocks.farmland, Blocks.farmland, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 0, 0, 0, 0, 8, Blocks.log, Blocks.log, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 6, 0, 0, 6, 0, 8, Blocks.log, Blocks.log, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 12, 0, 0, 12, 0, 8, Blocks.log, Blocks.log, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 0, 0, 11, 0, 0, Blocks.log, Blocks.log, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 0, 8, 11, 0, 8, Blocks.log, Blocks.log, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 3, 0, 1, 3, 0, 7, Blocks.water, Blocks.water, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 9, 0, 1, 9, 0, 7, Blocks.water, Blocks.water, false); + int i; + + for (i = 1; i <= 7; ++i) + { + this.placeBlockAtCurrentPosition(par1World, this.cropTypeA, MathHelper.getRandomIntegerInRange(par2Random, 2, 7), 1, 1, i, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, this.cropTypeA, MathHelper.getRandomIntegerInRange(par2Random, 2, 7), 2, 1, i, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, this.cropTypeB, MathHelper.getRandomIntegerInRange(par2Random, 2, 7), 4, 1, i, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, this.cropTypeB, MathHelper.getRandomIntegerInRange(par2Random, 2, 7), 5, 1, i, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, this.cropTypeC, MathHelper.getRandomIntegerInRange(par2Random, 2, 7), 7, 1, i, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, this.cropTypeC, MathHelper.getRandomIntegerInRange(par2Random, 2, 7), 8, 1, i, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, this.cropTypeD, MathHelper.getRandomIntegerInRange(par2Random, 2, 7), 10, 1, i, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, this.cropTypeD, MathHelper.getRandomIntegerInRange(par2Random, 2, 7), 11, 1, i, par3StructureBoundingBox); + } + + for (i = 0; i < 9; ++i) + { + for (int j = 0; j < 13; ++j) + { + this.clearCurrentPositionBlocksUpwards(par1World, j, 4, i, par3StructureBoundingBox); + this.func_151554_b(par1World, Blocks.dirt, 0, j, -1, i, par3StructureBoundingBox); + } + } + + return true; + } + } + + public static class Field2 extends StructureVillagePieces.Village + { + private Block cropTypeA; + private Block cropTypeB; + private static final String __OBFID = "CL_00000519"; + + public Field2() {} + + public Field2(StructureVillagePieces.Start par1ComponentVillageStartPiece, int par2, Random par3Random, StructureBoundingBox par4StructureBoundingBox, int par5) + { + super(par1ComponentVillageStartPiece, par2); + this.coordBaseMode = par5; + this.boundingBox = par4StructureBoundingBox; + this.cropTypeA = this.func_151560_a(par3Random); + this.cropTypeB = this.func_151560_a(par3Random); + } + + protected void func_143012_a(NBTTagCompound par1NBTTagCompound) + { + super.func_143012_a(par1NBTTagCompound); + par1NBTTagCompound.setInteger("CA", Block.blockRegistry.getIDForObject(this.cropTypeA)); + par1NBTTagCompound.setInteger("CB", Block.blockRegistry.getIDForObject(this.cropTypeB)); + } + + protected void func_143011_b(NBTTagCompound par1NBTTagCompound) + { + super.func_143011_b(par1NBTTagCompound); + this.cropTypeA = Block.getBlockById(par1NBTTagCompound.getInteger("CA")); + this.cropTypeB = Block.getBlockById(par1NBTTagCompound.getInteger("CB")); + } + + private Block func_151560_a(Random p_151560_1_) + { + switch (p_151560_1_.nextInt(5)) + { + case 0: + return Blocks.carrots; + case 1: + return Blocks.potatoes; + default: + return Blocks.wheat; + } + } + + public static StructureVillagePieces.Field2 func_74902_a(StructureVillagePieces.Start par0ComponentVillageStartPiece, List par1List, Random par2Random, int par3, int par4, int par5, int par6, int par7) + { + StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(par3, par4, par5, 0, 0, 0, 7, 4, 9, par6); + return canVillageGoDeeper(structureboundingbox) && StructureComponent.findIntersecting(par1List, structureboundingbox) == null ? new StructureVillagePieces.Field2(par0ComponentVillageStartPiece, par7, par2Random, structureboundingbox, par6) : null; + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + if (this.field_143015_k < 0) + { + this.field_143015_k = this.getAverageGroundLevel(par1World, par3StructureBoundingBox); + + if (this.field_143015_k < 0) + { + return true; + } + + this.boundingBox.offset(0, this.field_143015_k - this.boundingBox.maxY + 4 - 1, 0); + } + + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 1, 0, 6, 4, 8, Blocks.air, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 0, 1, 2, 0, 7, Blocks.farmland, Blocks.farmland, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 0, 1, 5, 0, 7, Blocks.farmland, Blocks.farmland, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 0, 0, 0, 0, 8, Blocks.log, Blocks.log, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 6, 0, 0, 6, 0, 8, Blocks.log, Blocks.log, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 0, 0, 5, 0, 0, Blocks.log, Blocks.log, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 0, 8, 5, 0, 8, Blocks.log, Blocks.log, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 3, 0, 1, 3, 0, 7, Blocks.water, Blocks.water, false); + int i; + + for (i = 1; i <= 7; ++i) + { + this.placeBlockAtCurrentPosition(par1World, this.cropTypeA, MathHelper.getRandomIntegerInRange(par2Random, 2, 7), 1, 1, i, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, this.cropTypeA, MathHelper.getRandomIntegerInRange(par2Random, 2, 7), 2, 1, i, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, this.cropTypeB, MathHelper.getRandomIntegerInRange(par2Random, 2, 7), 4, 1, i, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, this.cropTypeB, MathHelper.getRandomIntegerInRange(par2Random, 2, 7), 5, 1, i, par3StructureBoundingBox); + } + + for (i = 0; i < 9; ++i) + { + for (int j = 0; j < 7; ++j) + { + this.clearCurrentPositionBlocksUpwards(par1World, j, 4, i, par3StructureBoundingBox); + this.func_151554_b(par1World, Blocks.dirt, 0, j, -1, i, par3StructureBoundingBox); + } + } + + return true; + } + } + + public static class Hall extends StructureVillagePieces.Village + { + private static final String __OBFID = "CL_00000522"; + + public Hall() {} + + public Hall(StructureVillagePieces.Start par1ComponentVillageStartPiece, int par2, Random par3Random, StructureBoundingBox par4StructureBoundingBox, int par5) + { + super(par1ComponentVillageStartPiece, par2); + this.coordBaseMode = par5; + this.boundingBox = par4StructureBoundingBox; + } + + public static StructureVillagePieces.Hall func_74906_a(StructureVillagePieces.Start par0ComponentVillageStartPiece, List par1List, Random par2Random, int par3, int par4, int par5, int par6, int par7) + { + StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(par3, par4, par5, 0, 0, 0, 9, 7, 11, par6); + return canVillageGoDeeper(structureboundingbox) && StructureComponent.findIntersecting(par1List, structureboundingbox) == null ? new StructureVillagePieces.Hall(par0ComponentVillageStartPiece, par7, par2Random, structureboundingbox, par6) : null; + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + if (this.field_143015_k < 0) + { + this.field_143015_k = this.getAverageGroundLevel(par1World, par3StructureBoundingBox); + + if (this.field_143015_k < 0) + { + return true; + } + + this.boundingBox.offset(0, this.field_143015_k - this.boundingBox.maxY + 7 - 1, 0); + } + + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 1, 1, 7, 4, 4, Blocks.air, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 2, 1, 6, 8, 4, 10, Blocks.air, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 2, 0, 6, 8, 0, 10, Blocks.dirt, Blocks.dirt, false); + this.placeBlockAtCurrentPosition(par1World, Blocks.cobblestone, 0, 6, 0, 6, par3StructureBoundingBox); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 2, 1, 6, 2, 1, 10, Blocks.fence, Blocks.fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 8, 1, 6, 8, 1, 10, Blocks.fence, Blocks.fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 3, 1, 10, 7, 1, 10, Blocks.fence, Blocks.fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 0, 1, 7, 0, 4, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 0, 0, 0, 3, 5, Blocks.cobblestone, Blocks.cobblestone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 8, 0, 0, 8, 3, 5, Blocks.cobblestone, Blocks.cobblestone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 0, 0, 7, 1, 0, Blocks.cobblestone, Blocks.cobblestone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 0, 5, 7, 1, 5, Blocks.cobblestone, Blocks.cobblestone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 2, 0, 7, 3, 0, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 2, 5, 7, 3, 5, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 4, 1, 8, 4, 1, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 4, 4, 8, 4, 4, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 5, 2, 8, 5, 3, Blocks.planks, Blocks.planks, false); + this.placeBlockAtCurrentPosition(par1World, Blocks.planks, 0, 0, 4, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.planks, 0, 0, 4, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.planks, 0, 8, 4, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.planks, 0, 8, 4, 3, par3StructureBoundingBox); + int i = this.getMetadataWithOffset(Blocks.oak_stairs, 3); + int j = this.getMetadataWithOffset(Blocks.oak_stairs, 2); + int k; + int l; + + for (k = -1; k <= 2; ++k) + { + for (l = 0; l <= 8; ++l) + { + this.placeBlockAtCurrentPosition(par1World, Blocks.oak_stairs, i, l, 4 + k, k, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.oak_stairs, j, l, 4 + k, 5 - k, par3StructureBoundingBox); + } + } + + this.placeBlockAtCurrentPosition(par1World, Blocks.log, 0, 0, 2, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.log, 0, 0, 2, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.log, 0, 8, 2, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.log, 0, 8, 2, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 0, 2, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 0, 2, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 8, 2, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 8, 2, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 2, 2, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 3, 2, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 5, 2, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 6, 2, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, 2, 1, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.wooden_pressure_plate, 0, 2, 2, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.planks, 0, 1, 1, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.oak_stairs, this.getMetadataWithOffset(Blocks.oak_stairs, 3), 2, 1, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.oak_stairs, this.getMetadataWithOffset(Blocks.oak_stairs, 1), 1, 1, 3, par3StructureBoundingBox); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 5, 0, 1, 7, 0, 3, Blocks.double_stone_slab, Blocks.double_stone_slab, false); + this.placeBlockAtCurrentPosition(par1World, Blocks.double_stone_slab, 0, 6, 1, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.double_stone_slab, 0, 6, 1, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, 2, 1, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, 2, 2, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.torch, 0, 2, 3, 1, par3StructureBoundingBox); + this.placeDoorAtCurrentPosition(par1World, par3StructureBoundingBox, par2Random, 2, 1, 0, this.getMetadataWithOffset(Blocks.wooden_door, 1)); + + if (this.getBlockAtCurrentPosition(par1World, 2, 0, -1, par3StructureBoundingBox).getMaterial() == Material.air && this.getBlockAtCurrentPosition(par1World, 2, -1, -1, par3StructureBoundingBox).getMaterial() != Material.air) + { + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_stairs, this.getMetadataWithOffset(Blocks.stone_stairs, 3), 2, 0, -1, par3StructureBoundingBox); + } + + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, 6, 1, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, 6, 2, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.torch, 0, 6, 3, 4, par3StructureBoundingBox); + this.placeDoorAtCurrentPosition(par1World, par3StructureBoundingBox, par2Random, 6, 1, 5, this.getMetadataWithOffset(Blocks.wooden_door, 1)); + + for (k = 0; k < 5; ++k) + { + for (l = 0; l < 9; ++l) + { + this.clearCurrentPositionBlocksUpwards(par1World, l, 7, k, par3StructureBoundingBox); + this.func_151554_b(par1World, Blocks.cobblestone, 0, l, -1, k, par3StructureBoundingBox); + } + } + + this.spawnVillagers(par1World, par3StructureBoundingBox, 4, 1, 2, 2); + return true; + } + + protected int getVillagerType(int par1) + { + return par1 == 0 ? 4 : 0; + } + } + + public static class House1 extends StructureVillagePieces.Village + { + private static final String __OBFID = "CL_00000517"; + + public House1() {} + + public House1(StructureVillagePieces.Start par1ComponentVillageStartPiece, int par2, Random par3Random, StructureBoundingBox par4StructureBoundingBox, int par5) + { + super(par1ComponentVillageStartPiece, par2); + this.coordBaseMode = par5; + this.boundingBox = par4StructureBoundingBox; + } + + public static StructureVillagePieces.House1 func_74898_a(StructureVillagePieces.Start par0ComponentVillageStartPiece, List par1List, Random par2Random, int par3, int par4, int par5, int par6, int par7) + { + StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(par3, par4, par5, 0, 0, 0, 9, 9, 6, par6); + return canVillageGoDeeper(structureboundingbox) && StructureComponent.findIntersecting(par1List, structureboundingbox) == null ? new StructureVillagePieces.House1(par0ComponentVillageStartPiece, par7, par2Random, structureboundingbox, par6) : null; + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + if (this.field_143015_k < 0) + { + this.field_143015_k = this.getAverageGroundLevel(par1World, par3StructureBoundingBox); + + if (this.field_143015_k < 0) + { + return true; + } + + this.boundingBox.offset(0, this.field_143015_k - this.boundingBox.maxY + 9 - 1, 0); + } + + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 1, 1, 7, 5, 4, Blocks.air, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 0, 0, 8, 0, 5, Blocks.cobblestone, Blocks.cobblestone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 5, 0, 8, 5, 5, Blocks.cobblestone, Blocks.cobblestone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 6, 1, 8, 6, 4, Blocks.cobblestone, Blocks.cobblestone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 7, 2, 8, 7, 3, Blocks.cobblestone, Blocks.cobblestone, false); + int i = this.getMetadataWithOffset(Blocks.oak_stairs, 3); + int j = this.getMetadataWithOffset(Blocks.oak_stairs, 2); + int k; + int l; + + for (k = -1; k <= 2; ++k) + { + for (l = 0; l <= 8; ++l) + { + this.placeBlockAtCurrentPosition(par1World, Blocks.oak_stairs, i, l, 6 + k, k, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.oak_stairs, j, l, 6 + k, 5 - k, par3StructureBoundingBox); + } + } + + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 1, 0, 0, 1, 5, Blocks.cobblestone, Blocks.cobblestone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 1, 5, 8, 1, 5, Blocks.cobblestone, Blocks.cobblestone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 8, 1, 0, 8, 1, 4, Blocks.cobblestone, Blocks.cobblestone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 2, 1, 0, 7, 1, 0, Blocks.cobblestone, Blocks.cobblestone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 2, 0, 0, 4, 0, Blocks.cobblestone, Blocks.cobblestone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 2, 5, 0, 4, 5, Blocks.cobblestone, Blocks.cobblestone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 8, 2, 5, 8, 4, 5, Blocks.cobblestone, Blocks.cobblestone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 8, 2, 0, 8, 4, 0, Blocks.cobblestone, Blocks.cobblestone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 2, 1, 0, 4, 4, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 2, 5, 7, 4, 5, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 8, 2, 1, 8, 4, 4, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 2, 0, 7, 4, 0, Blocks.planks, Blocks.planks, false); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 4, 2, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 5, 2, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 6, 2, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 4, 3, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 5, 3, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 6, 3, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 0, 2, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 0, 2, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 0, 3, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 0, 3, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 8, 2, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 8, 2, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 8, 3, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 8, 3, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 2, 2, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 3, 2, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 5, 2, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 6, 2, 5, par3StructureBoundingBox); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 4, 1, 7, 4, 1, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 4, 4, 7, 4, 4, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 3, 4, 7, 3, 4, Blocks.bookshelf, Blocks.bookshelf, false); + this.placeBlockAtCurrentPosition(par1World, Blocks.planks, 0, 7, 1, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.oak_stairs, this.getMetadataWithOffset(Blocks.oak_stairs, 0), 7, 1, 3, par3StructureBoundingBox); + k = this.getMetadataWithOffset(Blocks.oak_stairs, 3); + this.placeBlockAtCurrentPosition(par1World, Blocks.oak_stairs, k, 6, 1, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.oak_stairs, k, 5, 1, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.oak_stairs, k, 4, 1, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.oak_stairs, k, 3, 1, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, 6, 1, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.wooden_pressure_plate, 0, 6, 2, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, 4, 1, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.wooden_pressure_plate, 0, 4, 2, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.crafting_table, 0, 7, 1, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, 1, 1, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, 1, 2, 0, par3StructureBoundingBox); + this.placeDoorAtCurrentPosition(par1World, par3StructureBoundingBox, par2Random, 1, 1, 0, this.getMetadataWithOffset(Blocks.wooden_door, 1)); + + if (this.getBlockAtCurrentPosition(par1World, 1, 0, -1, par3StructureBoundingBox).getMaterial() == Material.air && this.getBlockAtCurrentPosition(par1World, 1, -1, -1, par3StructureBoundingBox).getMaterial() != Material.air) + { + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_stairs, this.getMetadataWithOffset(Blocks.stone_stairs, 3), 1, 0, -1, par3StructureBoundingBox); + } + + for (l = 0; l < 6; ++l) + { + for (int i1 = 0; i1 < 9; ++i1) + { + this.clearCurrentPositionBlocksUpwards(par1World, i1, 9, l, par3StructureBoundingBox); + this.func_151554_b(par1World, Blocks.cobblestone, 0, i1, -1, l, par3StructureBoundingBox); + } + } + + this.spawnVillagers(par1World, par3StructureBoundingBox, 2, 1, 2, 1); + return true; + } + + protected int getVillagerType(int par1) + { + return 1; + } + } + + public static class House2 extends StructureVillagePieces.Village + { + public static final WeightedRandomChestContent[] villageBlacksmithChestContents = new WeightedRandomChestContent[] {new WeightedRandomChestContent(Items.diamond, 0, 1, 3, 3), new WeightedRandomChestContent(Items.iron_ingot, 0, 1, 5, 10), new WeightedRandomChestContent(Items.gold_ingot, 0, 1, 3, 5), new WeightedRandomChestContent(Items.bread, 0, 1, 3, 15), new WeightedRandomChestContent(Items.apple, 0, 1, 3, 15), new WeightedRandomChestContent(Items.iron_pickaxe, 0, 1, 1, 5), new WeightedRandomChestContent(Items.iron_sword, 0, 1, 1, 5), new WeightedRandomChestContent(Items.iron_chestplate, 0, 1, 1, 5), new WeightedRandomChestContent(Items.iron_helmet, 0, 1, 1, 5), new WeightedRandomChestContent(Items.iron_leggings, 0, 1, 1, 5), new WeightedRandomChestContent(Items.iron_boots, 0, 1, 1, 5), new WeightedRandomChestContent(Item.getItemFromBlock(Blocks.obsidian), 0, 3, 7, 5), new WeightedRandomChestContent(Item.getItemFromBlock(Blocks.sapling), 0, 3, 7, 5), new WeightedRandomChestContent(Items.saddle, 0, 1, 1, 3), new WeightedRandomChestContent(Items.iron_horse_armor, 0, 1, 1, 1), new WeightedRandomChestContent(Items.golden_horse_armor, 0, 1, 1, 1), new WeightedRandomChestContent(Items.diamond_horse_armor, 0, 1, 1, 1)}; + private boolean hasMadeChest; + private static final String __OBFID = "CL_00000526"; + + public House2() {} + + public House2(StructureVillagePieces.Start par1ComponentVillageStartPiece, int par2, Random par3Random, StructureBoundingBox par4StructureBoundingBox, int par5) + { + super(par1ComponentVillageStartPiece, par2); + this.coordBaseMode = par5; + this.boundingBox = par4StructureBoundingBox; + } + + public static StructureVillagePieces.House2 func_74915_a(StructureVillagePieces.Start par0ComponentVillageStartPiece, List par1List, Random par2Random, int par3, int par4, int par5, int par6, int par7) + { + StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(par3, par4, par5, 0, 0, 0, 10, 6, 7, par6); + return canVillageGoDeeper(structureboundingbox) && StructureComponent.findIntersecting(par1List, structureboundingbox) == null ? new StructureVillagePieces.House2(par0ComponentVillageStartPiece, par7, par2Random, structureboundingbox, par6) : null; + } + + protected void func_143012_a(NBTTagCompound par1NBTTagCompound) + { + super.func_143012_a(par1NBTTagCompound); + par1NBTTagCompound.setBoolean("Chest", this.hasMadeChest); + } + + protected void func_143011_b(NBTTagCompound par1NBTTagCompound) + { + super.func_143011_b(par1NBTTagCompound); + this.hasMadeChest = par1NBTTagCompound.getBoolean("Chest"); + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + if (this.field_143015_k < 0) + { + this.field_143015_k = this.getAverageGroundLevel(par1World, par3StructureBoundingBox); + + if (this.field_143015_k < 0) + { + return true; + } + + this.boundingBox.offset(0, this.field_143015_k - this.boundingBox.maxY + 6 - 1, 0); + } + + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 1, 0, 9, 4, 6, Blocks.air, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 0, 0, 9, 0, 6, Blocks.cobblestone, Blocks.cobblestone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 4, 0, 9, 4, 6, Blocks.cobblestone, Blocks.cobblestone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 5, 0, 9, 5, 6, Blocks.stone_slab, Blocks.stone_slab, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 5, 1, 8, 5, 5, Blocks.air, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 1, 0, 2, 3, 0, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 1, 0, 0, 4, 0, Blocks.log, Blocks.log, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 3, 1, 0, 3, 4, 0, Blocks.log, Blocks.log, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 1, 6, 0, 4, 6, Blocks.log, Blocks.log, false); + this.placeBlockAtCurrentPosition(par1World, Blocks.planks, 0, 3, 3, 1, par3StructureBoundingBox); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 3, 1, 2, 3, 3, 2, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 1, 3, 5, 3, 3, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 1, 1, 0, 3, 5, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 1, 6, 5, 3, 6, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 5, 1, 0, 5, 3, 0, Blocks.fence, Blocks.fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 9, 1, 0, 9, 3, 0, Blocks.fence, Blocks.fence, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 6, 1, 4, 9, 4, 6, Blocks.cobblestone, Blocks.cobblestone, false); + this.placeBlockAtCurrentPosition(par1World, Blocks.flowing_lava, 0, 7, 1, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.flowing_lava, 0, 8, 1, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.iron_bars, 0, 9, 2, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.iron_bars, 0, 9, 2, 4, par3StructureBoundingBox); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 7, 2, 4, 8, 2, 5, Blocks.air, Blocks.air, false); + this.placeBlockAtCurrentPosition(par1World, Blocks.cobblestone, 0, 6, 1, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.furnace, 0, 6, 2, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.furnace, 0, 6, 3, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.double_stone_slab, 0, 8, 1, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 0, 2, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 0, 2, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 2, 2, 6, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 4, 2, 6, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, 2, 1, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.wooden_pressure_plate, 0, 2, 2, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.planks, 0, 1, 1, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.oak_stairs, this.getMetadataWithOffset(Blocks.oak_stairs, 3), 2, 1, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.oak_stairs, this.getMetadataWithOffset(Blocks.oak_stairs, 1), 1, 1, 4, par3StructureBoundingBox); + int i; + int j; + + if (!this.hasMadeChest) + { + i = this.getYWithOffset(1); + j = this.getXWithOffset(5, 5); + int k = this.getZWithOffset(5, 5); + + if (par3StructureBoundingBox.isVecInside(j, i, k)) + { + this.hasMadeChest = true; + this.generateStructureChestContents(par1World, par3StructureBoundingBox, par2Random, 5, 1, 5, ChestGenHooks.getItems(VILLAGE_BLACKSMITH, par2Random), ChestGenHooks.getCount(VILLAGE_BLACKSMITH, par2Random)); + } + } + + for (i = 6; i <= 8; ++i) + { + if (this.getBlockAtCurrentPosition(par1World, i, 0, -1, par3StructureBoundingBox).getMaterial() == Material.air && this.getBlockAtCurrentPosition(par1World, i, -1, -1, par3StructureBoundingBox).getMaterial() != Material.air) + { + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_stairs, this.getMetadataWithOffset(Blocks.stone_stairs, 3), i, 0, -1, par3StructureBoundingBox); + } + } + + for (i = 0; i < 7; ++i) + { + for (j = 0; j < 10; ++j) + { + this.clearCurrentPositionBlocksUpwards(par1World, j, 6, i, par3StructureBoundingBox); + this.func_151554_b(par1World, Blocks.cobblestone, 0, j, -1, i, par3StructureBoundingBox); + } + } + + this.spawnVillagers(par1World, par3StructureBoundingBox, 7, 1, 1, 1); + return true; + } + + protected int getVillagerType(int par1) + { + return 3; + } + } + + public static class House3 extends StructureVillagePieces.Village + { + private static final String __OBFID = "CL_00000530"; + + public House3() {} + + public House3(StructureVillagePieces.Start par1ComponentVillageStartPiece, int par2, Random par3Random, StructureBoundingBox par4StructureBoundingBox, int par5) + { + super(par1ComponentVillageStartPiece, par2); + this.coordBaseMode = par5; + this.boundingBox = par4StructureBoundingBox; + } + + public static StructureVillagePieces.House3 func_74921_a(StructureVillagePieces.Start par0ComponentVillageStartPiece, List par1List, Random par2Random, int par3, int par4, int par5, int par6, int par7) + { + StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(par3, par4, par5, 0, 0, 0, 9, 7, 12, par6); + return canVillageGoDeeper(structureboundingbox) && StructureComponent.findIntersecting(par1List, structureboundingbox) == null ? new StructureVillagePieces.House3(par0ComponentVillageStartPiece, par7, par2Random, structureboundingbox, par6) : null; + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + if (this.field_143015_k < 0) + { + this.field_143015_k = this.getAverageGroundLevel(par1World, par3StructureBoundingBox); + + if (this.field_143015_k < 0) + { + return true; + } + + this.boundingBox.offset(0, this.field_143015_k - this.boundingBox.maxY + 7 - 1, 0); + } + + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 1, 1, 7, 4, 4, Blocks.air, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 2, 1, 6, 8, 4, 10, Blocks.air, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 2, 0, 5, 8, 0, 10, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 0, 1, 7, 0, 4, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 0, 0, 0, 3, 5, Blocks.cobblestone, Blocks.cobblestone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 8, 0, 0, 8, 3, 10, Blocks.cobblestone, Blocks.cobblestone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 0, 0, 7, 2, 0, Blocks.cobblestone, Blocks.cobblestone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 0, 5, 2, 1, 5, Blocks.cobblestone, Blocks.cobblestone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 2, 0, 6, 2, 3, 10, Blocks.cobblestone, Blocks.cobblestone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 3, 0, 10, 7, 3, 10, Blocks.cobblestone, Blocks.cobblestone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 2, 0, 7, 3, 0, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 2, 5, 2, 3, 5, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 4, 1, 8, 4, 1, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 4, 4, 3, 4, 4, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 5, 2, 8, 5, 3, Blocks.planks, Blocks.planks, false); + this.placeBlockAtCurrentPosition(par1World, Blocks.planks, 0, 0, 4, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.planks, 0, 0, 4, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.planks, 0, 8, 4, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.planks, 0, 8, 4, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.planks, 0, 8, 4, 4, par3StructureBoundingBox); + int i = this.getMetadataWithOffset(Blocks.oak_stairs, 3); + int j = this.getMetadataWithOffset(Blocks.oak_stairs, 2); + int k; + int l; + + for (k = -1; k <= 2; ++k) + { + for (l = 0; l <= 8; ++l) + { + this.placeBlockAtCurrentPosition(par1World, Blocks.oak_stairs, i, l, 4 + k, k, par3StructureBoundingBox); + + if ((k > -1 || l <= 1) && (k > 0 || l <= 3) && (k > 1 || l <= 4 || l >= 6)) + { + this.placeBlockAtCurrentPosition(par1World, Blocks.oak_stairs, j, l, 4 + k, 5 - k, par3StructureBoundingBox); + } + } + } + + this.fillWithBlocks(par1World, par3StructureBoundingBox, 3, 4, 5, 3, 4, 10, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 7, 4, 2, 7, 4, 10, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 5, 4, 4, 5, 10, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 6, 5, 4, 6, 5, 10, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 5, 6, 3, 5, 6, 10, Blocks.planks, Blocks.planks, false); + k = this.getMetadataWithOffset(Blocks.oak_stairs, 0); + int i1; + + for (l = 4; l >= 1; --l) + { + this.placeBlockAtCurrentPosition(par1World, Blocks.planks, 0, l, 2 + l, 7 - l, par3StructureBoundingBox); + + for (i1 = 8 - l; i1 <= 10; ++i1) + { + this.placeBlockAtCurrentPosition(par1World, Blocks.oak_stairs, k, l, 2 + l, i1, par3StructureBoundingBox); + } + } + + l = this.getMetadataWithOffset(Blocks.oak_stairs, 1); + this.placeBlockAtCurrentPosition(par1World, Blocks.planks, 0, 6, 6, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.planks, 0, 7, 5, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.oak_stairs, l, 6, 6, 4, par3StructureBoundingBox); + int j1; + + for (i1 = 6; i1 <= 8; ++i1) + { + for (j1 = 5; j1 <= 10; ++j1) + { + this.placeBlockAtCurrentPosition(par1World, Blocks.oak_stairs, l, i1, 12 - i1, j1, par3StructureBoundingBox); + } + } + + this.placeBlockAtCurrentPosition(par1World, Blocks.log, 0, 0, 2, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.log, 0, 0, 2, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 0, 2, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 0, 2, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.log, 0, 4, 2, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 5, 2, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.log, 0, 6, 2, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.log, 0, 8, 2, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 8, 2, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 8, 2, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.log, 0, 8, 2, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.planks, 0, 8, 2, 5, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.log, 0, 8, 2, 6, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 8, 2, 7, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 8, 2, 8, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.log, 0, 8, 2, 9, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.log, 0, 2, 2, 6, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 2, 2, 7, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 2, 2, 8, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.log, 0, 2, 2, 9, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.log, 0, 4, 4, 10, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 5, 4, 10, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.log, 0, 6, 4, 10, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.planks, 0, 5, 5, 10, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, 2, 1, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, 2, 2, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.torch, 0, 2, 3, 1, par3StructureBoundingBox); + this.placeDoorAtCurrentPosition(par1World, par3StructureBoundingBox, par2Random, 2, 1, 0, this.getMetadataWithOffset(Blocks.wooden_door, 1)); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 0, -1, 3, 2, -1, Blocks.air, Blocks.air, false); + + if (this.getBlockAtCurrentPosition(par1World, 2, 0, -1, par3StructureBoundingBox).getMaterial() == Material.air && this.getBlockAtCurrentPosition(par1World, 2, -1, -1, par3StructureBoundingBox).getMaterial() != Material.air) + { + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_stairs, this.getMetadataWithOffset(Blocks.stone_stairs, 3), 2, 0, -1, par3StructureBoundingBox); + } + + for (i1 = 0; i1 < 5; ++i1) + { + for (j1 = 0; j1 < 9; ++j1) + { + this.clearCurrentPositionBlocksUpwards(par1World, j1, 7, i1, par3StructureBoundingBox); + this.func_151554_b(par1World, Blocks.cobblestone, 0, j1, -1, i1, par3StructureBoundingBox); + } + } + + for (i1 = 5; i1 < 11; ++i1) + { + for (j1 = 2; j1 < 9; ++j1) + { + this.clearCurrentPositionBlocksUpwards(par1World, j1, 7, i1, par3StructureBoundingBox); + this.func_151554_b(par1World, Blocks.cobblestone, 0, j1, -1, i1, par3StructureBoundingBox); + } + } + + this.spawnVillagers(par1World, par3StructureBoundingBox, 4, 1, 2, 2); + return true; + } + } + + public static class House4Garden extends StructureVillagePieces.Village + { + private boolean isRoofAccessible; + private static final String __OBFID = "CL_00000523"; + + public House4Garden() {} + + public House4Garden(StructureVillagePieces.Start par1ComponentVillageStartPiece, int par2, Random par3Random, StructureBoundingBox par4StructureBoundingBox, int par5) + { + super(par1ComponentVillageStartPiece, par2); + this.coordBaseMode = par5; + this.boundingBox = par4StructureBoundingBox; + this.isRoofAccessible = par3Random.nextBoolean(); + } + + protected void func_143012_a(NBTTagCompound par1NBTTagCompound) + { + super.func_143012_a(par1NBTTagCompound); + par1NBTTagCompound.setBoolean("Terrace", this.isRoofAccessible); + } + + protected void func_143011_b(NBTTagCompound par1NBTTagCompound) + { + super.func_143011_b(par1NBTTagCompound); + this.isRoofAccessible = par1NBTTagCompound.getBoolean("Terrace"); + } + + public static StructureVillagePieces.House4Garden func_74912_a(StructureVillagePieces.Start par0ComponentVillageStartPiece, List par1List, Random par2Random, int par3, int par4, int par5, int par6, int par7) + { + StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(par3, par4, par5, 0, 0, 0, 5, 6, 5, par6); + return StructureComponent.findIntersecting(par1List, structureboundingbox) != null ? null : new StructureVillagePieces.House4Garden(par0ComponentVillageStartPiece, par7, par2Random, structureboundingbox, par6); + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + if (this.field_143015_k < 0) + { + this.field_143015_k = this.getAverageGroundLevel(par1World, par3StructureBoundingBox); + + if (this.field_143015_k < 0) + { + return true; + } + + this.boundingBox.offset(0, this.field_143015_k - this.boundingBox.maxY + 6 - 1, 0); + } + + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 0, 0, 4, 0, 4, Blocks.cobblestone, Blocks.cobblestone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 4, 0, 4, 4, 4, Blocks.log, Blocks.log, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 4, 1, 3, 4, 3, Blocks.planks, Blocks.planks, false); + this.placeBlockAtCurrentPosition(par1World, Blocks.cobblestone, 0, 0, 1, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.cobblestone, 0, 0, 2, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.cobblestone, 0, 0, 3, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.cobblestone, 0, 4, 1, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.cobblestone, 0, 4, 2, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.cobblestone, 0, 4, 3, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.cobblestone, 0, 0, 1, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.cobblestone, 0, 0, 2, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.cobblestone, 0, 0, 3, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.cobblestone, 0, 4, 1, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.cobblestone, 0, 4, 2, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.cobblestone, 0, 4, 3, 4, par3StructureBoundingBox); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 1, 1, 0, 3, 3, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 4, 1, 1, 4, 3, 3, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 1, 4, 3, 3, 4, Blocks.planks, Blocks.planks, false); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 0, 2, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 2, 2, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 4, 2, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.planks, 0, 1, 1, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.planks, 0, 1, 2, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.planks, 0, 1, 3, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.planks, 0, 2, 3, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.planks, 0, 3, 3, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.planks, 0, 3, 2, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.planks, 0, 3, 1, 0, par3StructureBoundingBox); + + if (this.getBlockAtCurrentPosition(par1World, 2, 0, -1, par3StructureBoundingBox).getMaterial() == Material.air && this.getBlockAtCurrentPosition(par1World, 2, -1, -1, par3StructureBoundingBox).getMaterial() != Material.air) + { + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_stairs, this.getMetadataWithOffset(Blocks.stone_stairs, 3), 2, 0, -1, par3StructureBoundingBox); + } + + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 1, 1, 3, 3, 3, Blocks.air, Blocks.air, false); + + if (this.isRoofAccessible) + { + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, 0, 5, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, 1, 5, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, 2, 5, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, 3, 5, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, 4, 5, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, 0, 5, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, 1, 5, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, 2, 5, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, 3, 5, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, 4, 5, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, 4, 5, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, 4, 5, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, 4, 5, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, 0, 5, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, 0, 5, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, 0, 5, 3, par3StructureBoundingBox); + } + + int i; + + if (this.isRoofAccessible) + { + i = this.getMetadataWithOffset(Blocks.ladder, 3); + this.placeBlockAtCurrentPosition(par1World, Blocks.ladder, i, 3, 1, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.ladder, i, 3, 2, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.ladder, i, 3, 3, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.ladder, i, 3, 4, 3, par3StructureBoundingBox); + } + + this.placeBlockAtCurrentPosition(par1World, Blocks.torch, 0, 2, 3, 1, par3StructureBoundingBox); + + for (i = 0; i < 5; ++i) + { + for (int j = 0; j < 5; ++j) + { + this.clearCurrentPositionBlocksUpwards(par1World, j, 6, i, par3StructureBoundingBox); + this.func_151554_b(par1World, Blocks.cobblestone, 0, j, -1, i, par3StructureBoundingBox); + } + } + + this.spawnVillagers(par1World, par3StructureBoundingBox, 1, 1, 2, 1); + return true; + } + } + + public static class Path extends StructureVillagePieces.Road + { + private int averageGroundLevel; + private static final String __OBFID = "CL_00000528"; + + public Path() {} + + public Path(StructureVillagePieces.Start par1ComponentVillageStartPiece, int par2, Random par3Random, StructureBoundingBox par4StructureBoundingBox, int par5) + { + super(par1ComponentVillageStartPiece, par2); + this.coordBaseMode = par5; + this.boundingBox = par4StructureBoundingBox; + this.averageGroundLevel = Math.max(par4StructureBoundingBox.getXSize(), par4StructureBoundingBox.getZSize()); + } + + protected void func_143012_a(NBTTagCompound par1NBTTagCompound) + { + super.func_143012_a(par1NBTTagCompound); + par1NBTTagCompound.setInteger("Length", this.averageGroundLevel); + } + + protected void func_143011_b(NBTTagCompound par1NBTTagCompound) + { + super.func_143011_b(par1NBTTagCompound); + this.averageGroundLevel = par1NBTTagCompound.getInteger("Length"); + } + + public void buildComponent(StructureComponent par1StructureComponent, List par2List, Random par3Random) + { + boolean flag = false; + int i; + StructureComponent structurecomponent1; + + for (i = par3Random.nextInt(5); i < this.averageGroundLevel - 8; i += 2 + par3Random.nextInt(5)) + { + structurecomponent1 = this.getNextComponentNN((StructureVillagePieces.Start)par1StructureComponent, par2List, par3Random, 0, i); + + if (structurecomponent1 != null) + { + i += Math.max(structurecomponent1.boundingBox.getXSize(), structurecomponent1.boundingBox.getZSize()); + flag = true; + } + } + + for (i = par3Random.nextInt(5); i < this.averageGroundLevel - 8; i += 2 + par3Random.nextInt(5)) + { + structurecomponent1 = this.getNextComponentPP((StructureVillagePieces.Start)par1StructureComponent, par2List, par3Random, 0, i); + + if (structurecomponent1 != null) + { + i += Math.max(structurecomponent1.boundingBox.getXSize(), structurecomponent1.boundingBox.getZSize()); + flag = true; + } + } + + if (flag && par3Random.nextInt(3) > 0) + { + switch (this.coordBaseMode) + { + case 0: + StructureVillagePieces.getNextComponentVillagePath((StructureVillagePieces.Start)par1StructureComponent, par2List, par3Random, this.boundingBox.minX - 1, this.boundingBox.minY, this.boundingBox.maxZ - 2, 1, this.getComponentType()); + break; + case 1: + StructureVillagePieces.getNextComponentVillagePath((StructureVillagePieces.Start)par1StructureComponent, par2List, par3Random, this.boundingBox.minX, this.boundingBox.minY, this.boundingBox.minZ - 1, 2, this.getComponentType()); + break; + case 2: + StructureVillagePieces.getNextComponentVillagePath((StructureVillagePieces.Start)par1StructureComponent, par2List, par3Random, this.boundingBox.minX - 1, this.boundingBox.minY, this.boundingBox.minZ, 1, this.getComponentType()); + break; + case 3: + StructureVillagePieces.getNextComponentVillagePath((StructureVillagePieces.Start)par1StructureComponent, par2List, par3Random, this.boundingBox.maxX - 2, this.boundingBox.minY, this.boundingBox.minZ - 1, 2, this.getComponentType()); + } + } + + if (flag && par3Random.nextInt(3) > 0) + { + switch (this.coordBaseMode) + { + case 0: + StructureVillagePieces.getNextComponentVillagePath((StructureVillagePieces.Start)par1StructureComponent, par2List, par3Random, this.boundingBox.maxX + 1, this.boundingBox.minY, this.boundingBox.maxZ - 2, 3, this.getComponentType()); + break; + case 1: + StructureVillagePieces.getNextComponentVillagePath((StructureVillagePieces.Start)par1StructureComponent, par2List, par3Random, this.boundingBox.minX, this.boundingBox.minY, this.boundingBox.maxZ + 1, 0, this.getComponentType()); + break; + case 2: + StructureVillagePieces.getNextComponentVillagePath((StructureVillagePieces.Start)par1StructureComponent, par2List, par3Random, this.boundingBox.maxX + 1, this.boundingBox.minY, this.boundingBox.minZ, 3, this.getComponentType()); + break; + case 3: + StructureVillagePieces.getNextComponentVillagePath((StructureVillagePieces.Start)par1StructureComponent, par2List, par3Random, this.boundingBox.maxX - 2, this.boundingBox.minY, this.boundingBox.maxZ + 1, 0, this.getComponentType()); + } + } + } + + public static StructureBoundingBox func_74933_a(StructureVillagePieces.Start par0ComponentVillageStartPiece, List par1List, Random par2Random, int par3, int par4, int par5, int par6) + { + for (int i1 = 7 * MathHelper.getRandomIntegerInRange(par2Random, 3, 5); i1 >= 7; i1 -= 7) + { + StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(par3, par4, par5, 0, 0, 0, 3, 3, i1, par6); + + if (StructureComponent.findIntersecting(par1List, structureboundingbox) == null) + { + return structureboundingbox; + } + } + + return null; + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + Block block = this.func_151558_b(Blocks.gravel, 0); + + for (int i = this.boundingBox.minX; i <= this.boundingBox.maxX; ++i) + { + for (int j = this.boundingBox.minZ; j <= this.boundingBox.maxZ; ++j) + { + if (par3StructureBoundingBox.isVecInside(i, 64, j)) + { + int k = par1World.getTopSolidOrLiquidBlock(i, j) - 1; + par1World.setBlock(i, k, j, block, 0, 2); + } + } + } + + return true; + } + } + + public static class PieceWeight + { + public Class villagePieceClass; + public final int villagePieceWeight; + public int villagePiecesSpawned; + public int villagePiecesLimit; + private static final String __OBFID = "CL_00000521"; + + public PieceWeight(Class par1Class, int par2, int par3) + { + this.villagePieceClass = par1Class; + this.villagePieceWeight = par2; + this.villagePiecesLimit = par3; + } + + public boolean canSpawnMoreVillagePiecesOfType(int par1) + { + return this.villagePiecesLimit == 0 || this.villagePiecesSpawned < this.villagePiecesLimit; + } + + public boolean canSpawnMoreVillagePieces() + { + return this.villagePiecesLimit == 0 || this.villagePiecesSpawned < this.villagePiecesLimit; + } + } + + public abstract static class Road extends StructureVillagePieces.Village + { + private static final String __OBFID = "CL_00000532"; + + public Road() {} + + protected Road(StructureVillagePieces.Start par1ComponentVillageStartPiece, int par2) + { + super(par1ComponentVillageStartPiece, par2); + } + } + + public static class Start extends StructureVillagePieces.Well + { + public WorldChunkManager worldChunkMngr; + public boolean inDesert; + public int terrainType; + public StructureVillagePieces.PieceWeight structVillagePieceWeight; + public List structureVillageWeightedPieceList; + public List field_74932_i = new ArrayList(); + public List field_74930_j = new ArrayList(); + private static final String __OBFID = "CL_00000527"; + public BiomeGenBase biome; + + public Start() {} + + public Start(WorldChunkManager par1WorldChunkManager, int par2, Random par3Random, int par4, int par5, List par6List, int par7) + { + super((StructureVillagePieces.Start)null, 0, par3Random, par4, par5); + this.worldChunkMngr = par1WorldChunkManager; + this.structureVillageWeightedPieceList = par6List; + this.terrainType = par7; + BiomeGenBase biomegenbase = par1WorldChunkManager.getBiomeGenAt(par4, par5); + this.inDesert = biomegenbase == BiomeGenBase.desert || biomegenbase == BiomeGenBase.desertHills; + this.biome = biomegenbase; + } + + public WorldChunkManager getWorldChunkManager() + { + return this.worldChunkMngr; + } + } + + public static class Torch extends StructureVillagePieces.Village + { + private static final String __OBFID = "CL_00000520"; + + public Torch() {} + + public Torch(StructureVillagePieces.Start par1ComponentVillageStartPiece, int par2, Random par3Random, StructureBoundingBox par4StructureBoundingBox, int par5) + { + super(par1ComponentVillageStartPiece, par2); + this.coordBaseMode = par5; + this.boundingBox = par4StructureBoundingBox; + } + + public static StructureBoundingBox func_74904_a(StructureVillagePieces.Start par0ComponentVillageStartPiece, List par1List, Random par2Random, int par3, int par4, int par5, int par6) + { + StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(par3, par4, par5, 0, 0, 0, 3, 4, 2, par6); + return StructureComponent.findIntersecting(par1List, structureboundingbox) != null ? null : structureboundingbox; + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + if (this.field_143015_k < 0) + { + this.field_143015_k = this.getAverageGroundLevel(par1World, par3StructureBoundingBox); + + if (this.field_143015_k < 0) + { + return true; + } + + this.boundingBox.offset(0, this.field_143015_k - this.boundingBox.maxY + 4 - 1, 0); + } + + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 0, 0, 2, 3, 1, Blocks.air, Blocks.air, false); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, 1, 0, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, 1, 1, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, 1, 2, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.wool, 15, 1, 3, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.torch, 0, 0, 3, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.torch, 0, 1, 3, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.torch, 0, 2, 3, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.torch, 0, 1, 3, -1, par3StructureBoundingBox); + return true; + } + } + + public abstract static class Village extends StructureComponent + { + protected int field_143015_k = -1; + private int villagersSpawned; + private boolean field_143014_b; + private static final String __OBFID = "CL_00000531"; + private StructureVillagePieces.Start startPiece; + + public Village() {} + + protected Village(StructureVillagePieces.Start par1ComponentVillageStartPiece, int par2) + { + super(par2); + + if (par1ComponentVillageStartPiece != null) + { + this.field_143014_b = par1ComponentVillageStartPiece.inDesert; + startPiece = par1ComponentVillageStartPiece; + } + } + + protected void func_143012_a(NBTTagCompound par1NBTTagCompound) + { + par1NBTTagCompound.setInteger("HPos", this.field_143015_k); + par1NBTTagCompound.setInteger("VCount", this.villagersSpawned); + par1NBTTagCompound.setBoolean("Desert", this.field_143014_b); + } + + protected void func_143011_b(NBTTagCompound par1NBTTagCompound) + { + this.field_143015_k = par1NBTTagCompound.getInteger("HPos"); + this.villagersSpawned = par1NBTTagCompound.getInteger("VCount"); + this.field_143014_b = par1NBTTagCompound.getBoolean("Desert"); + } + + protected StructureComponent getNextComponentNN(StructureVillagePieces.Start par1ComponentVillageStartPiece, List par2List, Random par3Random, int par4, int par5) + { + switch (this.coordBaseMode) + { + case 0: + return StructureVillagePieces.getNextVillageStructureComponent(par1ComponentVillageStartPiece, par2List, par3Random, this.boundingBox.minX - 1, this.boundingBox.minY + par4, this.boundingBox.minZ + par5, 1, this.getComponentType()); + case 1: + return StructureVillagePieces.getNextVillageStructureComponent(par1ComponentVillageStartPiece, par2List, par3Random, this.boundingBox.minX + par5, this.boundingBox.minY + par4, this.boundingBox.minZ - 1, 2, this.getComponentType()); + case 2: + return StructureVillagePieces.getNextVillageStructureComponent(par1ComponentVillageStartPiece, par2List, par3Random, this.boundingBox.minX - 1, this.boundingBox.minY + par4, this.boundingBox.minZ + par5, 1, this.getComponentType()); + case 3: + return StructureVillagePieces.getNextVillageStructureComponent(par1ComponentVillageStartPiece, par2List, par3Random, this.boundingBox.minX + par5, this.boundingBox.minY + par4, this.boundingBox.minZ - 1, 2, this.getComponentType()); + default: + return null; + } + } + + protected StructureComponent getNextComponentPP(StructureVillagePieces.Start par1ComponentVillageStartPiece, List par2List, Random par3Random, int par4, int par5) + { + switch (this.coordBaseMode) + { + case 0: + return StructureVillagePieces.getNextVillageStructureComponent(par1ComponentVillageStartPiece, par2List, par3Random, this.boundingBox.maxX + 1, this.boundingBox.minY + par4, this.boundingBox.minZ + par5, 3, this.getComponentType()); + case 1: + return StructureVillagePieces.getNextVillageStructureComponent(par1ComponentVillageStartPiece, par2List, par3Random, this.boundingBox.minX + par5, this.boundingBox.minY + par4, this.boundingBox.maxZ + 1, 0, this.getComponentType()); + case 2: + return StructureVillagePieces.getNextVillageStructureComponent(par1ComponentVillageStartPiece, par2List, par3Random, this.boundingBox.maxX + 1, this.boundingBox.minY + par4, this.boundingBox.minZ + par5, 3, this.getComponentType()); + case 3: + return StructureVillagePieces.getNextVillageStructureComponent(par1ComponentVillageStartPiece, par2List, par3Random, this.boundingBox.minX + par5, this.boundingBox.minY + par4, this.boundingBox.maxZ + 1, 0, this.getComponentType()); + default: + return null; + } + } + + protected int getAverageGroundLevel(World par1World, StructureBoundingBox par2StructureBoundingBox) + { + int i = 0; + int j = 0; + + for (int k = this.boundingBox.minZ; k <= this.boundingBox.maxZ; ++k) + { + for (int l = this.boundingBox.minX; l <= this.boundingBox.maxX; ++l) + { + if (par2StructureBoundingBox.isVecInside(l, 64, k)) + { + i += Math.max(par1World.getTopSolidOrLiquidBlock(l, k), par1World.provider.getAverageGroundLevel()); + ++j; + } + } + } + + if (j == 0) + { + return -1; + } + else + { + return i / j; + } + } + + protected static boolean canVillageGoDeeper(StructureBoundingBox par0StructureBoundingBox) + { + return par0StructureBoundingBox != null && par0StructureBoundingBox.minY > 10; + } + + protected void spawnVillagers(World par1World, StructureBoundingBox par2StructureBoundingBox, int par3, int par4, int par5, int par6) + { + if (this.villagersSpawned < par6) + { + for (int i1 = this.villagersSpawned; i1 < par6; ++i1) + { + int j1 = this.getXWithOffset(par3 + i1, par5); + int k1 = this.getYWithOffset(par4); + int l1 = this.getZWithOffset(par3 + i1, par5); + + if (!par2StructureBoundingBox.isVecInside(j1, k1, l1)) + { + break; + } + + ++this.villagersSpawned; + EntityVillager entityvillager = new EntityVillager(par1World, this.getVillagerType(i1)); + entityvillager.setLocationAndAngles((double)j1 + 0.5D, (double)k1, (double)l1 + 0.5D, 0.0F, 0.0F); + par1World.spawnEntityInWorld(entityvillager); + } + } + } + + protected int getVillagerType(int par1) + { + return 0; + } + + protected Block func_151558_b(Block p_151558_1_, int p_151558_2_) + { + BiomeEvent.GetVillageBlockID event = new BiomeEvent.GetVillageBlockID(startPiece == null ? null : startPiece.biome, p_151558_1_, p_151558_2_); + MinecraftForge.TERRAIN_GEN_BUS.post(event); + if (event.getResult() == Result.DENY) return event.replacement; + if (this.field_143014_b) + { + if (p_151558_1_ == Blocks.log || p_151558_1_ == Blocks.log2) + { + return Blocks.sandstone; + } + + if (p_151558_1_ == Blocks.cobblestone) + { + return Blocks.sandstone; + } + + if (p_151558_1_ == Blocks.planks) + { + return Blocks.sandstone; + } + + if (p_151558_1_ == Blocks.oak_stairs) + { + return Blocks.sandstone_stairs; + } + + if (p_151558_1_ == Blocks.stone_stairs) + { + return Blocks.sandstone_stairs; + } + + if (p_151558_1_ == Blocks.gravel) + { + return Blocks.sandstone; + } + } + + return p_151558_1_; + } + + protected int func_151557_c(Block p_151557_1_, int p_151557_2_) + { + BiomeEvent.GetVillageBlockMeta event = new BiomeEvent.GetVillageBlockMeta(startPiece == null ? null : startPiece.biome, p_151557_1_, p_151557_2_); + MinecraftForge.TERRAIN_GEN_BUS.post(event); + if (event.getResult() == Result.DENY) return event.replacement; + if (this.field_143014_b) + { + if (p_151557_1_ == Blocks.log || p_151557_1_ == Blocks.log2) + { + return 0; + } + + if (p_151557_1_ == Blocks.cobblestone) + { + return 0; + } + + if (p_151557_1_ == Blocks.planks) + { + return 2; + } + } + + return p_151557_2_; + } + + protected void placeBlockAtCurrentPosition(World p_151550_1_, Block p_151550_2_, int p_151550_3_, int p_151550_4_, int p_151550_5_, int p_151550_6_, StructureBoundingBox p_151550_7_) + { + Block block1 = this.func_151558_b(p_151550_2_, p_151550_3_); + int i1 = this.func_151557_c(p_151550_2_, p_151550_3_); + super.placeBlockAtCurrentPosition(p_151550_1_, block1, i1, p_151550_4_, p_151550_5_, p_151550_6_, p_151550_7_); + } + + protected void fillWithBlocks(World p_151549_1_, StructureBoundingBox p_151549_2_, int p_151549_3_, int p_151549_4_, int p_151549_5_, int p_151549_6_, int p_151549_7_, int p_151549_8_, Block p_151549_9_, Block p_151549_10_, boolean p_151549_11_) + { + Block block2 = this.func_151558_b(p_151549_9_, 0); + int k1 = this.func_151557_c(p_151549_9_, 0); + Block block3 = this.func_151558_b(p_151549_10_, 0); + int l1 = this.func_151557_c(p_151549_10_, 0); + super.fillWithMetadataBlocks(p_151549_1_, p_151549_2_, p_151549_3_, p_151549_4_, p_151549_5_, p_151549_6_, p_151549_7_, p_151549_8_, block2, k1, block3, l1, p_151549_11_); + } + + protected void func_151554_b(World p_151554_1_, Block p_151554_2_, int p_151554_3_, int p_151554_4_, int p_151554_5_, int p_151554_6_, StructureBoundingBox p_151554_7_) + { + Block block1 = this.func_151558_b(p_151554_2_, p_151554_3_); + int i1 = this.func_151557_c(p_151554_2_, p_151554_3_); + super.func_151554_b(p_151554_1_, block1, i1, p_151554_4_, p_151554_5_, p_151554_6_, p_151554_7_); + } + } + + public static class Well extends StructureVillagePieces.Village + { + private static final String __OBFID = "CL_00000533"; + + public Well() {} + + public Well(StructureVillagePieces.Start par1ComponentVillageStartPiece, int par2, Random par3Random, int par4, int par5) + { + super(par1ComponentVillageStartPiece, par2); + this.coordBaseMode = par3Random.nextInt(4); + + switch (this.coordBaseMode) + { + case 0: + case 2: + this.boundingBox = new StructureBoundingBox(par4, 64, par5, par4 + 6 - 1, 78, par5 + 6 - 1); + break; + default: + this.boundingBox = new StructureBoundingBox(par4, 64, par5, par4 + 6 - 1, 78, par5 + 6 - 1); + } + } + + public void buildComponent(StructureComponent par1StructureComponent, List par2List, Random par3Random) + { + StructureVillagePieces.getNextComponentVillagePath((StructureVillagePieces.Start)par1StructureComponent, par2List, par3Random, this.boundingBox.minX - 1, this.boundingBox.maxY - 4, this.boundingBox.minZ + 1, 1, this.getComponentType()); + StructureVillagePieces.getNextComponentVillagePath((StructureVillagePieces.Start)par1StructureComponent, par2List, par3Random, this.boundingBox.maxX + 1, this.boundingBox.maxY - 4, this.boundingBox.minZ + 1, 3, this.getComponentType()); + StructureVillagePieces.getNextComponentVillagePath((StructureVillagePieces.Start)par1StructureComponent, par2List, par3Random, this.boundingBox.minX + 1, this.boundingBox.maxY - 4, this.boundingBox.minZ - 1, 2, this.getComponentType()); + StructureVillagePieces.getNextComponentVillagePath((StructureVillagePieces.Start)par1StructureComponent, par2List, par3Random, this.boundingBox.minX + 1, this.boundingBox.maxY - 4, this.boundingBox.maxZ + 1, 0, this.getComponentType()); + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + if (this.field_143015_k < 0) + { + this.field_143015_k = this.getAverageGroundLevel(par1World, par3StructureBoundingBox); + + if (this.field_143015_k < 0) + { + return true; + } + + this.boundingBox.offset(0, this.field_143015_k - this.boundingBox.maxY + 3, 0); + } + + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 0, 1, 4, 12, 4, Blocks.cobblestone, Blocks.flowing_water, false); + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, 2, 12, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, 3, 12, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, 2, 12, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, 3, 12, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, 1, 13, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, 1, 14, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, 4, 13, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, 4, 14, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, 1, 13, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, 1, 14, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, 4, 13, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, 4, 14, 4, par3StructureBoundingBox); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 15, 1, 4, 15, 4, Blocks.cobblestone, Blocks.cobblestone, false); + + for (int i = 0; i <= 5; ++i) + { + for (int j = 0; j <= 5; ++j) + { + if (j == 0 || j == 5 || i == 0 || i == 5) + { + this.placeBlockAtCurrentPosition(par1World, Blocks.gravel, 0, j, 11, i, par3StructureBoundingBox); + this.clearCurrentPositionBlocksUpwards(par1World, j, 12, i, par3StructureBoundingBox); + } + } + } + + return true; + } + } + + public static class WoodHut extends StructureVillagePieces.Village + { + private boolean isTallHouse; + private int tablePosition; + private static final String __OBFID = "CL_00000524"; + + public WoodHut() {} + + public WoodHut(StructureVillagePieces.Start par1ComponentVillageStartPiece, int par2, Random par3Random, StructureBoundingBox par4StructureBoundingBox, int par5) + { + super(par1ComponentVillageStartPiece, par2); + this.coordBaseMode = par5; + this.boundingBox = par4StructureBoundingBox; + this.isTallHouse = par3Random.nextBoolean(); + this.tablePosition = par3Random.nextInt(3); + } + + protected void func_143012_a(NBTTagCompound par1NBTTagCompound) + { + super.func_143012_a(par1NBTTagCompound); + par1NBTTagCompound.setInteger("T", this.tablePosition); + par1NBTTagCompound.setBoolean("C", this.isTallHouse); + } + + protected void func_143011_b(NBTTagCompound par1NBTTagCompound) + { + super.func_143011_b(par1NBTTagCompound); + this.tablePosition = par1NBTTagCompound.getInteger("T"); + this.isTallHouse = par1NBTTagCompound.getBoolean("C"); + } + + public static StructureVillagePieces.WoodHut func_74908_a(StructureVillagePieces.Start par0ComponentVillageStartPiece, List par1List, Random par2Random, int par3, int par4, int par5, int par6, int par7) + { + StructureBoundingBox structureboundingbox = StructureBoundingBox.getComponentToAddBoundingBox(par3, par4, par5, 0, 0, 0, 4, 6, 5, par6); + return canVillageGoDeeper(structureboundingbox) && StructureComponent.findIntersecting(par1List, structureboundingbox) == null ? new StructureVillagePieces.WoodHut(par0ComponentVillageStartPiece, par7, par2Random, structureboundingbox, par6) : null; + } + + public boolean addComponentParts(World par1World, Random par2Random, StructureBoundingBox par3StructureBoundingBox) + { + if (this.field_143015_k < 0) + { + this.field_143015_k = this.getAverageGroundLevel(par1World, par3StructureBoundingBox); + + if (this.field_143015_k < 0) + { + return true; + } + + this.boundingBox.offset(0, this.field_143015_k - this.boundingBox.maxY + 6 - 1, 0); + } + + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 1, 1, 3, 5, 4, Blocks.air, Blocks.air, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 0, 0, 3, 0, 4, Blocks.cobblestone, Blocks.cobblestone, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 0, 1, 2, 0, 3, Blocks.dirt, Blocks.dirt, false); + + if (this.isTallHouse) + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 4, 1, 2, 4, 3, Blocks.log, Blocks.log, false); + } + else + { + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 5, 1, 2, 5, 3, Blocks.log, Blocks.log, false); + } + + this.placeBlockAtCurrentPosition(par1World, Blocks.log, 0, 1, 4, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.log, 0, 2, 4, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.log, 0, 1, 4, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.log, 0, 2, 4, 4, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.log, 0, 0, 4, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.log, 0, 0, 4, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.log, 0, 0, 4, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.log, 0, 3, 4, 1, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.log, 0, 3, 4, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.log, 0, 3, 4, 3, par3StructureBoundingBox); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 1, 0, 0, 3, 0, Blocks.log, Blocks.log, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 3, 1, 0, 3, 3, 0, Blocks.log, Blocks.log, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 1, 4, 0, 3, 4, Blocks.log, Blocks.log, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 3, 1, 4, 3, 3, 4, Blocks.log, Blocks.log, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 1, 1, 0, 3, 3, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 3, 1, 1, 3, 3, 3, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 1, 0, 2, 3, 0, Blocks.planks, Blocks.planks, false); + this.fillWithBlocks(par1World, par3StructureBoundingBox, 1, 1, 4, 2, 3, 4, Blocks.planks, Blocks.planks, false); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 0, 2, 2, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.glass_pane, 0, 3, 2, 2, par3StructureBoundingBox); + + if (this.tablePosition > 0) + { + this.placeBlockAtCurrentPosition(par1World, Blocks.fence, 0, this.tablePosition, 1, 3, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.wooden_pressure_plate, 0, this.tablePosition, 2, 3, par3StructureBoundingBox); + } + + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, 1, 1, 0, par3StructureBoundingBox); + this.placeBlockAtCurrentPosition(par1World, Blocks.air, 0, 1, 2, 0, par3StructureBoundingBox); + this.placeDoorAtCurrentPosition(par1World, par3StructureBoundingBox, par2Random, 1, 1, 0, this.getMetadataWithOffset(Blocks.wooden_door, 1)); + + if (this.getBlockAtCurrentPosition(par1World, 1, 0, -1, par3StructureBoundingBox).getMaterial() == Material.air && this.getBlockAtCurrentPosition(par1World, 1, -1, -1, par3StructureBoundingBox).getMaterial() != Material.air) + { + this.placeBlockAtCurrentPosition(par1World, Blocks.stone_stairs, this.getMetadataWithOffset(Blocks.stone_stairs, 3), 1, 0, -1, par3StructureBoundingBox); + } + + for (int i = 0; i < 5; ++i) + { + for (int j = 0; j < 4; ++j) + { + this.clearCurrentPositionBlocksUpwards(par1World, j, 6, i, par3StructureBoundingBox); + this.func_151554_b(par1World, Blocks.cobblestone, 0, j, -1, i, par3StructureBoundingBox); + } + } + + this.spawnVillagers(par1World, par3StructureBoundingBox, 1, 1, 2, 1); + return true; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/storage/DerivedWorldInfo.java b/src/main/java/net/minecraft/world/storage/DerivedWorldInfo.java new file mode 100644 index 0000000..12a73dc --- /dev/null +++ b/src/main/java/net/minecraft/world/storage/DerivedWorldInfo.java @@ -0,0 +1,177 @@ +package net.minecraft.world.storage; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.GameRules; +import net.minecraft.world.WorldSettings; +import net.minecraft.world.WorldType; + +public class DerivedWorldInfo extends WorldInfo +{ + private final WorldInfo theWorldInfo; + private static final String __OBFID = "CL_00000584"; + + public DerivedWorldInfo(WorldInfo par1WorldInfo) + { + this.theWorldInfo = par1WorldInfo; + } + + public NBTTagCompound getNBTTagCompound() + { + return this.theWorldInfo.getNBTTagCompound(); + } + + public NBTTagCompound cloneNBTCompound(NBTTagCompound par1NBTTagCompound) + { + return this.theWorldInfo.cloneNBTCompound(par1NBTTagCompound); + } + + public long getSeed() + { + return this.theWorldInfo.getSeed(); + } + + public int getSpawnX() + { + return this.theWorldInfo.getSpawnX(); + } + + public int getSpawnY() + { + return this.theWorldInfo.getSpawnY(); + } + + public int getSpawnZ() + { + return this.theWorldInfo.getSpawnZ(); + } + + public long getWorldTotalTime() + { + return this.theWorldInfo.getWorldTotalTime(); + } + + public long getWorldTime() + { + return this.theWorldInfo.getWorldTime(); + } + + @SideOnly(Side.CLIENT) + public long getSizeOnDisk() + { + return this.theWorldInfo.getSizeOnDisk(); + } + + public NBTTagCompound getPlayerNBTTagCompound() + { + return this.theWorldInfo.getPlayerNBTTagCompound(); + } + + public int getVanillaDimension() + { + return this.theWorldInfo.getVanillaDimension(); + } + + public String getWorldName() + { + return this.theWorldInfo.getWorldName(); + } + + public int getSaveVersion() + { + return this.theWorldInfo.getSaveVersion(); + } + + @SideOnly(Side.CLIENT) + public long getLastTimePlayed() + { + return this.theWorldInfo.getLastTimePlayed(); + } + + public boolean isThundering() + { + return this.theWorldInfo.isThundering(); + } + + public int getThunderTime() + { + return this.theWorldInfo.getThunderTime(); + } + + public boolean isRaining() + { + return this.theWorldInfo.isRaining(); + } + + public int getRainTime() + { + return this.theWorldInfo.getRainTime(); + } + + public WorldSettings.GameType getGameType() + { + return this.theWorldInfo.getGameType(); + } + + @SideOnly(Side.CLIENT) + public void setSpawnX(int par1) {} + + @SideOnly(Side.CLIENT) + public void setSpawnY(int par1) {} + + public void incrementTotalWorldTime(long par1) {} + + @SideOnly(Side.CLIENT) + public void setSpawnZ(int par1) {} + + public void setWorldTime(long par1) {} + + public void setSpawnPosition(int par1, int par2, int par3) {} + + public void setWorldName(String par1Str) {} + + public void setSaveVersion(int par1) {} + + public void setThundering(boolean par1) {} + + public void setThunderTime(int par1) {} + + public void setRaining(boolean par1) {} + + public void setRainTime(int par1) {} + + public boolean isMapFeaturesEnabled() + { + return this.theWorldInfo.isMapFeaturesEnabled(); + } + + public boolean isHardcoreModeEnabled() + { + return this.theWorldInfo.isHardcoreModeEnabled(); + } + + public WorldType getTerrainType() + { + return this.theWorldInfo.getTerrainType(); + } + + public void setTerrainType(WorldType par1WorldType) {} + + public boolean areCommandsAllowed() + { + return this.theWorldInfo.areCommandsAllowed(); + } + + public boolean isInitialized() + { + return this.theWorldInfo.isInitialized(); + } + + public void setServerInitialized(boolean par1) {} + + public GameRules getGameRulesInstance() + { + return this.theWorldInfo.getGameRulesInstance(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/storage/IPlayerFileData.java b/src/main/java/net/minecraft/world/storage/IPlayerFileData.java new file mode 100644 index 0000000..cb88be8 --- /dev/null +++ b/src/main/java/net/minecraft/world/storage/IPlayerFileData.java @@ -0,0 +1,13 @@ +package net.minecraft.world.storage; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; + +public interface IPlayerFileData +{ + void writePlayerData(EntityPlayer var1); + + NBTTagCompound readPlayerData(EntityPlayer var1); + + String[] getAvailablePlayerDat(); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/storage/ISaveFormat.java b/src/main/java/net/minecraft/world/storage/ISaveFormat.java new file mode 100644 index 0000000..e199928 --- /dev/null +++ b/src/main/java/net/minecraft/world/storage/ISaveFormat.java @@ -0,0 +1,32 @@ +package net.minecraft.world.storage; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; +import net.minecraft.client.AnvilConverterException; +import net.minecraft.util.IProgressUpdate; + +public interface ISaveFormat +{ + ISaveHandler getSaveLoader(String var1, boolean var2); + + @SideOnly(Side.CLIENT) + List getSaveList() throws AnvilConverterException; + + void flushCache(); + + @SideOnly(Side.CLIENT) + WorldInfo getWorldInfo(String var1); + + boolean deleteWorldDirectory(String var1); + + @SideOnly(Side.CLIENT) + void renameWorld(String var1, String var2); + + boolean isOldMapFormat(String var1); + + boolean convertMapFormat(String var1, IProgressUpdate var2); + + @SideOnly(Side.CLIENT) + boolean canLoadWorld(String var1); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/storage/ISaveHandler.java b/src/main/java/net/minecraft/world/storage/ISaveHandler.java new file mode 100644 index 0000000..3b8582b --- /dev/null +++ b/src/main/java/net/minecraft/world/storage/ISaveHandler.java @@ -0,0 +1,30 @@ +package net.minecraft.world.storage; + +import java.io.File; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.MinecraftException; +import net.minecraft.world.WorldProvider; +import net.minecraft.world.chunk.storage.IChunkLoader; + +public interface ISaveHandler +{ + WorldInfo loadWorldInfo(); + + void checkSessionLock() throws MinecraftException; + + IChunkLoader getChunkLoader(WorldProvider var1); + + void saveWorldInfoWithPlayer(WorldInfo var1, NBTTagCompound var2); + + void saveWorldInfo(WorldInfo var1); + + IPlayerFileData getSaveHandler(); + + void flush(); + + File getWorldDirectory(); + + File getMapFileFromName(String var1); + + String getWorldDirectoryName(); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/storage/IThreadedFileIO.java b/src/main/java/net/minecraft/world/storage/IThreadedFileIO.java new file mode 100644 index 0000000..c580014 --- /dev/null +++ b/src/main/java/net/minecraft/world/storage/IThreadedFileIO.java @@ -0,0 +1,6 @@ +package net.minecraft.world.storage; + +public interface IThreadedFileIO +{ + boolean writeNextIO(); +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/storage/MapData.java b/src/main/java/net/minecraft/world/storage/MapData.java new file mode 100644 index 0000000..dc0764d --- /dev/null +++ b/src/main/java/net/minecraft/world/storage/MapData.java @@ -0,0 +1,399 @@ +package net.minecraft.world.storage; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.*; +import net.minecraft.world.World; +import net.minecraft.world.WorldSavedData; + +public class MapData extends WorldSavedData +{ + public int xCenter; + public int zCenter; + public int dimension; + public byte scale; + public byte[] colors = new byte[16384]; + public List playersArrayList = new ArrayList(); + private Map playersHashMap = new HashMap(); + public Map playersVisibleOnMap = new LinkedHashMap(); + private static final String __OBFID = "CL_00000577"; + + public MapData(String par1Str) + { + super(par1Str); + } + + public void readFromNBT(NBTTagCompound par1NBTTagCompound) + { + NBTBase dimension = par1NBTTagCompound.getTag("dimension"); + + if (dimension instanceof NBTTagByte) + { + this.dimension = ((NBTTagByte)dimension).func_150290_f(); + } + else + { + this.dimension = ((NBTTagInt)dimension).func_150287_d(); + } + + this.xCenter = par1NBTTagCompound.getInteger("xCenter"); + this.zCenter = par1NBTTagCompound.getInteger("zCenter"); + this.scale = par1NBTTagCompound.getByte("scale"); + + if (this.scale < 0) + { + this.scale = 0; + } + + if (this.scale > 4) + { + this.scale = 4; + } + + short short1 = par1NBTTagCompound.getShort("width"); + short short2 = par1NBTTagCompound.getShort("height"); + + if (short1 == 128 && short2 == 128) + { + this.colors = par1NBTTagCompound.getByteArray("colors"); + } + else + { + byte[] abyte = par1NBTTagCompound.getByteArray("colors"); + this.colors = new byte[16384]; + int i = (128 - short1) / 2; + int j = (128 - short2) / 2; + + for (int k = 0; k < short2; ++k) + { + int l = k + j; + + if (l >= 0 || l < 128) + { + for (int i1 = 0; i1 < short1; ++i1) + { + int j1 = i1 + i; + + if (j1 >= 0 || j1 < 128) + { + this.colors[j1 + l * 128] = abyte[i1 + k * short1]; + } + } + } + } + } + } + + public void writeToNBT(NBTTagCompound par1NBTTagCompound) + { + par1NBTTagCompound.setInteger("dimension", this.dimension); + par1NBTTagCompound.setInteger("xCenter", this.xCenter); + par1NBTTagCompound.setInteger("zCenter", this.zCenter); + par1NBTTagCompound.setByte("scale", this.scale); + par1NBTTagCompound.setShort("width", (short)128); + par1NBTTagCompound.setShort("height", (short)128); + par1NBTTagCompound.setByteArray("colors", this.colors); + } + + public void updateVisiblePlayers(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack) + { + if (!this.playersHashMap.containsKey(par1EntityPlayer)) + { + MapData.MapInfo mapinfo = new MapData.MapInfo(par1EntityPlayer); + this.playersHashMap.put(par1EntityPlayer, mapinfo); + this.playersArrayList.add(mapinfo); + } + + if (!par1EntityPlayer.inventory.hasItemStack(par2ItemStack)) + { + this.playersVisibleOnMap.remove(par1EntityPlayer.getCommandSenderName()); + } + + for (int i = 0; i < this.playersArrayList.size(); ++i) + { + MapData.MapInfo mapinfo1 = (MapData.MapInfo)this.playersArrayList.get(i); + + if (!mapinfo1.entityplayerObj.isDead && (mapinfo1.entityplayerObj.inventory.hasItemStack(par2ItemStack) || par2ItemStack.isOnItemFrame())) + { + if (!par2ItemStack.isOnItemFrame() && mapinfo1.entityplayerObj.dimension == this.dimension) + { + this.func_82567_a(0, mapinfo1.entityplayerObj.worldObj, mapinfo1.entityplayerObj.getCommandSenderName(), mapinfo1.entityplayerObj.posX, mapinfo1.entityplayerObj.posZ, (double)mapinfo1.entityplayerObj.rotationYaw); + } + } + else + { + this.playersHashMap.remove(mapinfo1.entityplayerObj); + this.playersArrayList.remove(mapinfo1); + } + } + + if (par2ItemStack.isOnItemFrame()) + { + this.func_82567_a(1, par1EntityPlayer.worldObj, "frame-" + par2ItemStack.getItemFrame().getEntityId(), (double)par2ItemStack.getItemFrame().field_146063_b, (double)par2ItemStack.getItemFrame().field_146062_d, (double)(par2ItemStack.getItemFrame().hangingDirection * 90)); + } + } + + private void func_82567_a(int par1, World par2World, String par3Str, double par4, double par6, double par8) + { + int j = 1 << this.scale; + float f = (float)(par4 - (double)this.xCenter) / (float)j; + float f1 = (float)(par6 - (double)this.zCenter) / (float)j; + byte b0 = (byte)((int)((double)(f * 2.0F) + 0.5D)); + byte b1 = (byte)((int)((double)(f1 * 2.0F) + 0.5D)); + byte b3 = 63; + byte b2; + + if (f >= (float)(-b3) && f1 >= (float)(-b3) && f <= (float)b3 && f1 <= (float)b3) + { + par8 += par8 < 0.0D ? -8.0D : 8.0D; + b2 = (byte)((int)(par8 * 16.0D / 360.0D)); + + if (par2World.provider.shouldMapSpin(par3Str, par4, par6, par8)) + { + int k = (int)(par2World.getWorldInfo().getWorldTime() / 10L); + b2 = (byte)(k * k * 34187121 + k * 121 >> 15 & 15); + } + } + else + { + if (Math.abs(f) >= 320.0F || Math.abs(f1) >= 320.0F) + { + this.playersVisibleOnMap.remove(par3Str); + return; + } + + par1 = 6; + b2 = 0; + + if (f <= (float)(-b3)) + { + b0 = (byte)((int)((double)(b3 * 2) + 2.5D)); + } + + if (f1 <= (float)(-b3)) + { + b1 = (byte)((int)((double)(b3 * 2) + 2.5D)); + } + + if (f >= (float)b3) + { + b0 = (byte)(b3 * 2 + 1); + } + + if (f1 >= (float)b3) + { + b1 = (byte)(b3 * 2 + 1); + } + } + + this.playersVisibleOnMap.put(par3Str, new MapData.MapCoord((byte)par1, b0, b1, b2)); + } + + public byte[] getUpdatePacketData(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + { + MapData.MapInfo mapinfo = (MapData.MapInfo)this.playersHashMap.get(par3EntityPlayer); + return mapinfo == null ? null : mapinfo.getPlayersOnMap(par1ItemStack); + } + + public void setColumnDirty(int par1, int par2, int par3) + { + super.markDirty(); + + for (int l = 0; l < this.playersArrayList.size(); ++l) + { + MapData.MapInfo mapinfo = (MapData.MapInfo)this.playersArrayList.get(l); + + if (mapinfo.field_76209_b[par1] < 0 || mapinfo.field_76209_b[par1] > par2) + { + mapinfo.field_76209_b[par1] = par2; + } + + if (mapinfo.field_76210_c[par1] < 0 || mapinfo.field_76210_c[par1] < par3) + { + mapinfo.field_76210_c[par1] = par3; + } + } + } + + @SideOnly(Side.CLIENT) + public void updateMPMapData(byte[] par1ArrayOfByte) + { + int i; + + if (par1ArrayOfByte[0] == 0) + { + i = par1ArrayOfByte[1] & 255; + int j = par1ArrayOfByte[2] & 255; + + for (int k = 0; k < par1ArrayOfByte.length - 3; ++k) + { + this.colors[(k + j) * 128 + i] = par1ArrayOfByte[k + 3]; + } + + this.markDirty(); + } + else if (par1ArrayOfByte[0] == 1) + { + this.playersVisibleOnMap.clear(); + + for (i = 0; i < (par1ArrayOfByte.length - 1) / 3; ++i) + { + byte b2 = (byte)(par1ArrayOfByte[i * 3 + 1] >> 4); + byte b3 = par1ArrayOfByte[i * 3 + 2]; + byte b0 = par1ArrayOfByte[i * 3 + 3]; + byte b1 = (byte)(par1ArrayOfByte[i * 3 + 1] & 15); + this.playersVisibleOnMap.put("icon-" + i, new MapData.MapCoord(b2, b3, b0, b1)); + } + } + else if (par1ArrayOfByte[0] == 2) + { + this.scale = par1ArrayOfByte[1]; + } + } + + public MapData.MapInfo func_82568_a(EntityPlayer par1EntityPlayer) + { + MapData.MapInfo mapinfo = (MapData.MapInfo)this.playersHashMap.get(par1EntityPlayer); + + if (mapinfo == null) + { + mapinfo = new MapData.MapInfo(par1EntityPlayer); + this.playersHashMap.put(par1EntityPlayer, mapinfo); + this.playersArrayList.add(mapinfo); + } + + return mapinfo; + } + + public class MapCoord + { + public byte iconSize; + public byte centerX; + public byte centerZ; + public byte iconRotation; + private static final String __OBFID = "CL_00000579"; + + public MapCoord(byte par2, byte par3, byte par4, byte par5) + { + this.iconSize = par2; + this.centerX = par3; + this.centerZ = par4; + this.iconRotation = par5; + } + } + + public class MapInfo + { + public final EntityPlayer entityplayerObj; + public int[] field_76209_b = new int[128]; + public int[] field_76210_c = new int[128]; + private int currentRandomNumber; + private int ticksUntilPlayerLocationMapUpdate; + private byte[] lastPlayerLocationOnMap; + public int field_82569_d; + private boolean field_82570_i; + private static final String __OBFID = "CL_00000578"; + + public MapInfo(EntityPlayer par2EntityPlayer) + { + this.entityplayerObj = par2EntityPlayer; + + for (int i = 0; i < this.field_76209_b.length; ++i) + { + this.field_76209_b[i] = 0; + this.field_76210_c[i] = 127; + } + } + + public byte[] getPlayersOnMap(ItemStack par1ItemStack) + { + byte[] abyte; + + if (!this.field_82570_i) + { + abyte = new byte[] {(byte)2, MapData.this.scale}; + this.field_82570_i = true; + return abyte; + } + else + { + int i; + int i1; + + if (--this.ticksUntilPlayerLocationMapUpdate < 0) + { + this.ticksUntilPlayerLocationMapUpdate = 4; + abyte = new byte[MapData.this.playersVisibleOnMap.size() * 3 + 1]; + abyte[0] = 1; + i = 0; + + for (Iterator iterator = MapData.this.playersVisibleOnMap.values().iterator(); iterator.hasNext(); ++i) + { + MapData.MapCoord mapcoord = (MapData.MapCoord)iterator.next(); + abyte[i * 3 + 1] = (byte)(mapcoord.iconSize << 4 | mapcoord.iconRotation & 15); + abyte[i * 3 + 2] = mapcoord.centerX; + abyte[i * 3 + 3] = mapcoord.centerZ; + } + + boolean flag = !par1ItemStack.isOnItemFrame(); + + if (this.lastPlayerLocationOnMap != null && this.lastPlayerLocationOnMap.length == abyte.length) + { + for (i1 = 0; i1 < abyte.length; ++i1) + { + if (abyte[i1] != this.lastPlayerLocationOnMap[i1]) + { + flag = false; + break; + } + } + } + else + { + flag = false; + } + + if (!flag) + { + this.lastPlayerLocationOnMap = abyte; + return abyte; + } + } + + for (int k = 0; k < 1; ++k) + { + i = this.currentRandomNumber++ * 11 % 128; + + if (this.field_76209_b[i] >= 0) + { + int l = this.field_76210_c[i] - this.field_76209_b[i] + 1; + i1 = this.field_76209_b[i]; + byte[] abyte1 = new byte[l + 3]; + abyte1[0] = 0; + abyte1[1] = (byte)i; + abyte1[2] = (byte)i1; + + for (int j = 0; j < abyte1.length - 3; ++j) + { + abyte1[j + 3] = MapData.this.colors[(j + i1) * 128 + i]; + } + + this.field_76210_c[i] = -1; + this.field_76209_b[i] = -1; + return abyte1; + } + } + + return null; + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/storage/MapStorage.java b/src/main/java/net/minecraft/world/storage/MapStorage.java new file mode 100644 index 0000000..e85dd85 --- /dev/null +++ b/src/main/java/net/minecraft/world/storage/MapStorage.java @@ -0,0 +1,230 @@ +package net.minecraft.world.storage; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import net.minecraft.nbt.CompressedStreamTools; +import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagShort; +import net.minecraft.world.WorldSavedData; + +public class MapStorage +{ + private ISaveHandler saveHandler; + private Map loadedDataMap = new HashMap(); + private List loadedDataList = new ArrayList(); + private Map idCounts = new HashMap(); + private static final String __OBFID = "CL_00000604"; + + public MapStorage(ISaveHandler par1ISaveHandler) + { + this.saveHandler = par1ISaveHandler; + this.loadIdCounts(); + } + + public WorldSavedData loadData(Class par1Class, String par2Str) + { + WorldSavedData worldsaveddata = (WorldSavedData)this.loadedDataMap.get(par2Str); + + if (worldsaveddata != null) + { + return worldsaveddata; + } + else + { + if (this.saveHandler != null) + { + try + { + File file1 = this.saveHandler.getMapFileFromName(par2Str); + + if (file1 != null && file1.exists()) + { + try + { + worldsaveddata = (WorldSavedData)par1Class.getConstructor(new Class[] {String.class}).newInstance(new Object[] {par2Str}); + } + catch (Exception exception) + { + throw new RuntimeException("Failed to instantiate " + par1Class.toString(), exception); + } + + FileInputStream fileinputstream = new FileInputStream(file1); + NBTTagCompound nbttagcompound = CompressedStreamTools.readCompressed(fileinputstream); + fileinputstream.close(); + worldsaveddata.readFromNBT(nbttagcompound.getCompoundTag("data")); + } + } + catch (Exception exception1) + { + exception1.printStackTrace(); + } + } + + if (worldsaveddata != null) + { + this.loadedDataMap.put(par2Str, worldsaveddata); + this.loadedDataList.add(worldsaveddata); + } + + return worldsaveddata; + } + } + + public void setData(String par1Str, WorldSavedData par2WorldSavedData) + { + if (par2WorldSavedData == null) + { + throw new RuntimeException("Can\'t set null data"); + } + else + { + if (this.loadedDataMap.containsKey(par1Str)) + { + this.loadedDataList.remove(this.loadedDataMap.remove(par1Str)); + } + + this.loadedDataMap.put(par1Str, par2WorldSavedData); + this.loadedDataList.add(par2WorldSavedData); + } + } + + public void saveAllData() + { + for (int i = 0; i < this.loadedDataList.size(); ++i) + { + WorldSavedData worldsaveddata = (WorldSavedData)this.loadedDataList.get(i); + + if (worldsaveddata.isDirty()) + { + this.saveData(worldsaveddata); + worldsaveddata.setDirty(false); + } + } + } + + private void saveData(WorldSavedData par1WorldSavedData) + { + if (this.saveHandler != null) + { + try + { + File file1 = this.saveHandler.getMapFileFromName(par1WorldSavedData.mapName); + + if (file1 != null) + { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + par1WorldSavedData.writeToNBT(nbttagcompound); + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + nbttagcompound1.setTag("data", nbttagcompound); + FileOutputStream fileoutputstream = new FileOutputStream(file1); + CompressedStreamTools.writeCompressed(nbttagcompound1, fileoutputstream); + fileoutputstream.close(); + } + } + catch (Exception exception) + { + exception.printStackTrace(); + } + } + } + + private void loadIdCounts() + { + try + { + this.idCounts.clear(); + + if (this.saveHandler == null) + { + return; + } + + File file1 = this.saveHandler.getMapFileFromName("idcounts"); + + if (file1 != null && file1.exists()) + { + DataInputStream datainputstream = new DataInputStream(new FileInputStream(file1)); + NBTTagCompound nbttagcompound = CompressedStreamTools.read(datainputstream); + datainputstream.close(); + Iterator iterator = nbttagcompound.func_150296_c().iterator(); + + while (iterator.hasNext()) + { + String s = (String)iterator.next(); + NBTBase nbtbase = nbttagcompound.getTag(s); + + if (nbtbase instanceof NBTTagShort) + { + NBTTagShort nbttagshort = (NBTTagShort)nbtbase; + short short1 = nbttagshort.func_150289_e(); + this.idCounts.put(s, Short.valueOf(short1)); + } + } + } + } + catch (Exception exception) + { + exception.printStackTrace(); + } + } + + public int getUniqueDataId(String par1Str) + { + Short oshort = (Short)this.idCounts.get(par1Str); + + if (oshort == null) + { + oshort = Short.valueOf((short)0); + } + else + { + oshort = Short.valueOf((short)(oshort.shortValue() + 1)); + } + + this.idCounts.put(par1Str, oshort); + + if (this.saveHandler == null) + { + return oshort.shortValue(); + } + else + { + try + { + File file1 = this.saveHandler.getMapFileFromName("idcounts"); + + if (file1 != null) + { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + Iterator iterator = this.idCounts.keySet().iterator(); + + while (iterator.hasNext()) + { + String s1 = (String)iterator.next(); + short short1 = ((Short)this.idCounts.get(s1)).shortValue(); + nbttagcompound.setShort(s1, short1); + } + + DataOutputStream dataoutputstream = new DataOutputStream(new FileOutputStream(file1)); + CompressedStreamTools.write(nbttagcompound, dataoutputstream); + dataoutputstream.close(); + } + } + catch (Exception exception) + { + exception.printStackTrace(); + } + + return oshort.shortValue(); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/storage/SaveFormatComparator.java b/src/main/java/net/minecraft/world/storage/SaveFormatComparator.java new file mode 100644 index 0000000..e14d0c0 --- /dev/null +++ b/src/main/java/net/minecraft/world/storage/SaveFormatComparator.java @@ -0,0 +1,76 @@ +package net.minecraft.world.storage; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.world.WorldSettings; + +@SideOnly(Side.CLIENT) +public class SaveFormatComparator implements Comparable +{ + private final String fileName; + private final String displayName; + private final long lastTimePlayed; + private final long sizeOnDisk; + private final boolean requiresConversion; + private final WorldSettings.GameType theEnumGameType; + private final boolean hardcore; + private final boolean cheatsEnabled; + private static final String __OBFID = "CL_00000601"; + + public SaveFormatComparator(String par1Str, String par2Str, long par3, long par5, WorldSettings.GameType par7EnumGameType, boolean par8, boolean par9, boolean par10) + { + this.fileName = par1Str; + this.displayName = par2Str; + this.lastTimePlayed = par3; + this.sizeOnDisk = par5; + this.theEnumGameType = par7EnumGameType; + this.requiresConversion = par8; + this.hardcore = par9; + this.cheatsEnabled = par10; + } + + public String getFileName() + { + return this.fileName; + } + + public String getDisplayName() + { + return this.displayName; + } + + public boolean requiresConversion() + { + return this.requiresConversion; + } + + public long getLastTimePlayed() + { + return this.lastTimePlayed; + } + + public int compareTo(SaveFormatComparator par1SaveFormatComparator) + { + return this.lastTimePlayed < par1SaveFormatComparator.lastTimePlayed ? 1 : (this.lastTimePlayed > par1SaveFormatComparator.lastTimePlayed ? -1 : this.fileName.compareTo(par1SaveFormatComparator.fileName)); + } + + public WorldSettings.GameType getEnumGameType() + { + return this.theEnumGameType; + } + + public boolean isHardcoreModeEnabled() + { + return this.hardcore; + } + + public boolean getCheatsEnabled() + { + return this.cheatsEnabled; + } + + public int compareTo(Object par1Obj) + { + return this.compareTo((SaveFormatComparator)par1Obj); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/storage/SaveFormatOld.java b/src/main/java/net/minecraft/world/storage/SaveFormatOld.java new file mode 100644 index 0000000..3ebcd9e --- /dev/null +++ b/src/main/java/net/minecraft/world/storage/SaveFormatOld.java @@ -0,0 +1,212 @@ +package net.minecraft.world.storage; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.util.ArrayList; +import java.util.List; +import net.minecraft.client.AnvilConverterException; +import net.minecraft.nbt.CompressedStreamTools; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.IProgressUpdate; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class SaveFormatOld implements ISaveFormat +{ + private static final Logger logger = LogManager.getLogger(); + public final File savesDirectory; + private static final String __OBFID = "CL_00000586"; + + public SaveFormatOld(File par1File) + { + if (!par1File.exists()) + { + par1File.mkdirs(); + } + + this.savesDirectory = par1File; + } + + @SideOnly(Side.CLIENT) + public List getSaveList() throws AnvilConverterException + { + ArrayList arraylist = new ArrayList(); + + for (int i = 0; i < 5; ++i) + { + String s = "World" + (i + 1); + WorldInfo worldinfo = this.getWorldInfo(s); + + if (worldinfo != null) + { + arraylist.add(new SaveFormatComparator(s, "", worldinfo.getLastTimePlayed(), worldinfo.getSizeOnDisk(), worldinfo.getGameType(), false, worldinfo.isHardcoreModeEnabled(), worldinfo.areCommandsAllowed())); + } + } + + return arraylist; + } + + public void flushCache() {} + + public WorldInfo getWorldInfo(String par1Str) + { + File file1 = new File(this.savesDirectory, par1Str); + + if (!file1.exists()) + { + return null; + } + else + { + File file2 = new File(file1, "level.dat"); + NBTTagCompound nbttagcompound; + NBTTagCompound nbttagcompound1; + + if (file2.exists()) + { + try + { + nbttagcompound = CompressedStreamTools.readCompressed(new FileInputStream(file2)); + nbttagcompound1 = nbttagcompound.getCompoundTag("Data"); + return new WorldInfo(nbttagcompound1); + } + catch (Exception exception1) + { + logger.error("Exception reading " + file2, exception1); + } + } + + file2 = new File(file1, "level.dat_old"); + + if (file2.exists()) + { + try + { + nbttagcompound = CompressedStreamTools.readCompressed(new FileInputStream(file2)); + nbttagcompound1 = nbttagcompound.getCompoundTag("Data"); + return new WorldInfo(nbttagcompound1); + } + catch (Exception exception) + { + logger.error("Exception reading " + file2, exception); + } + } + + return null; + } + } + + @SideOnly(Side.CLIENT) + public void renameWorld(String par1Str, String par2Str) + { + File file1 = new File(this.savesDirectory, par1Str); + + if (file1.exists()) + { + File file2 = new File(file1, "level.dat"); + + if (file2.exists()) + { + try + { + NBTTagCompound nbttagcompound = CompressedStreamTools.readCompressed(new FileInputStream(file2)); + NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("Data"); + nbttagcompound1.setString("LevelName", par2Str); + CompressedStreamTools.writeCompressed(nbttagcompound, new FileOutputStream(file2)); + } + catch (Exception exception) + { + exception.printStackTrace(); + } + } + } + } + + public boolean deleteWorldDirectory(String par1Str) + { + File file1 = new File(this.savesDirectory, par1Str); + + if (!file1.exists()) + { + return true; + } + else + { + logger.info("Deleting level " + par1Str); + + for (int i = 1; i <= 5; ++i) + { + logger.info("Attempt " + i + "..."); + + if (deleteFiles(file1.listFiles())) + { + break; + } + + logger.warn("Unsuccessful in deleting contents."); + + if (i < 5) + { + try + { + Thread.sleep(500L); + } + catch (InterruptedException interruptedexception) + { + ; + } + } + } + + return file1.delete(); + } + } + + protected static boolean deleteFiles(File[] par0ArrayOfFile) + { + for (int i = 0; i < par0ArrayOfFile.length; ++i) + { + File file1 = par0ArrayOfFile[i]; + logger.debug("Deleting " + file1); + + if (file1.isDirectory() && !deleteFiles(file1.listFiles())) + { + logger.warn("Couldn\'t delete directory " + file1); + return false; + } + + if (!file1.delete()) + { + logger.warn("Couldn\'t delete file " + file1); + return false; + } + } + + return true; + } + + public ISaveHandler getSaveLoader(String par1Str, boolean par2) + { + return new SaveHandler(this.savesDirectory, par1Str, par2); + } + + public boolean isOldMapFormat(String par1Str) + { + return false; + } + + public boolean convertMapFormat(String par1Str, IProgressUpdate par2IProgressUpdate) + { + return false; + } + + @SideOnly(Side.CLIENT) + public boolean canLoadWorld(String par1Str) + { + File file1 = new File(this.savesDirectory, par1Str); + return file1.isDirectory(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/storage/SaveHandler.java b/src/main/java/net/minecraft/world/storage/SaveHandler.java new file mode 100644 index 0000000..ff9360f --- /dev/null +++ b/src/main/java/net/minecraft/world/storage/SaveHandler.java @@ -0,0 +1,326 @@ +package net.minecraft.world.storage; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.StartupQuery; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.CompressedStreamTools; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.server.MinecraftServer; +import net.minecraft.world.MinecraftException; +import net.minecraft.world.WorldProvider; +import net.minecraft.world.chunk.storage.IChunkLoader; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class SaveHandler implements ISaveHandler, IPlayerFileData +{ + private static final Logger logger = LogManager.getLogger(); + private final File worldDirectory; + private final File playersDirectory; + private final File mapDataDir; + private final long initializationTime = MinecraftServer.getSystemTimeMillis(); + private final String saveDirectoryName; + private static final String __OBFID = "CL_00000585"; + + public SaveHandler(File par1File, String par2Str, boolean par3) + { + this.worldDirectory = new File(par1File, par2Str); + this.worldDirectory.mkdirs(); + this.playersDirectory = new File(this.worldDirectory, "players"); + this.mapDataDir = new File(this.worldDirectory, "data"); + this.mapDataDir.mkdirs(); + this.saveDirectoryName = par2Str; + + if (par3) + { + this.playersDirectory.mkdirs(); + } + + this.setSessionLock(); + } + + private void setSessionLock() + { + try + { + File file1 = new File(this.worldDirectory, "session.lock"); + DataOutputStream dataoutputstream = new DataOutputStream(new FileOutputStream(file1)); + + try + { + dataoutputstream.writeLong(this.initializationTime); + } + finally + { + dataoutputstream.close(); + } + } + catch (IOException ioexception) + { + ioexception.printStackTrace(); + throw new RuntimeException("Failed to check session lock, aborting"); + } + } + + public File getWorldDirectory() + { + return this.worldDirectory; + } + + public void checkSessionLock() throws MinecraftException + { + try + { + File file1 = new File(this.worldDirectory, "session.lock"); + DataInputStream datainputstream = new DataInputStream(new FileInputStream(file1)); + + try + { + if (datainputstream.readLong() != this.initializationTime) + { + throw new MinecraftException("The save is being accessed from another location, aborting"); + } + } + finally + { + datainputstream.close(); + } + } + catch (IOException ioexception) + { + throw new MinecraftException("Failed to check session lock, aborting"); + } + } + + public IChunkLoader getChunkLoader(WorldProvider par1WorldProvider) + { + throw new RuntimeException("Old Chunk Storage is no longer supported."); + } + + public WorldInfo loadWorldInfo() + { + File file1 = new File(this.worldDirectory, "level.dat"); + NBTTagCompound nbttagcompound; + NBTTagCompound nbttagcompound1; + + WorldInfo worldInfo = null; + + if (file1.exists()) + { + try + { + nbttagcompound = CompressedStreamTools.readCompressed(new FileInputStream(file1)); + nbttagcompound1 = nbttagcompound.getCompoundTag("Data"); + worldInfo = new WorldInfo(nbttagcompound1); + FMLCommonHandler.instance().handleWorldDataLoad(this, worldInfo, nbttagcompound); + return worldInfo; + } + catch (StartupQuery.AbortedException e) + { + throw e; + } + catch (Exception exception1) + { + exception1.printStackTrace(); + } + } + + FMLCommonHandler.instance().confirmBackupLevelDatUse(this); + file1 = new File(this.worldDirectory, "level.dat_old"); + + if (file1.exists()) + { + try + { + nbttagcompound = CompressedStreamTools.readCompressed(new FileInputStream(file1)); + nbttagcompound1 = nbttagcompound.getCompoundTag("Data"); + worldInfo = new WorldInfo(nbttagcompound1); + FMLCommonHandler.instance().handleWorldDataLoad(this, worldInfo, nbttagcompound); + return worldInfo; + } + catch (StartupQuery.AbortedException e) + { + throw e; + } + catch (Exception exception) + { + exception.printStackTrace(); + } + } + + return null; + } + + public void saveWorldInfoWithPlayer(WorldInfo par1WorldInfo, NBTTagCompound par2NBTTagCompound) + { + NBTTagCompound nbttagcompound1 = par1WorldInfo.cloneNBTCompound(par2NBTTagCompound); + NBTTagCompound nbttagcompound2 = new NBTTagCompound(); + nbttagcompound2.setTag("Data", nbttagcompound1); + + FMLCommonHandler.instance().handleWorldDataSave(this, par1WorldInfo, nbttagcompound2); + + try + { + File file1 = new File(this.worldDirectory, "level.dat_new"); + File file2 = new File(this.worldDirectory, "level.dat_old"); + File file3 = new File(this.worldDirectory, "level.dat"); + CompressedStreamTools.writeCompressed(nbttagcompound2, new FileOutputStream(file1)); + + if (file2.exists()) + { + file2.delete(); + } + + file3.renameTo(file2); + + if (file3.exists()) + { + file3.delete(); + } + + file1.renameTo(file3); + + if (file1.exists()) + { + file1.delete(); + } + } + catch (Exception exception) + { + exception.printStackTrace(); + } + } + + public void saveWorldInfo(WorldInfo par1WorldInfo) + { + NBTTagCompound nbttagcompound = par1WorldInfo.getNBTTagCompound(); + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + nbttagcompound1.setTag("Data", nbttagcompound); + + FMLCommonHandler.instance().handleWorldDataSave(this, par1WorldInfo, nbttagcompound1); + + try + { + File file1 = new File(this.worldDirectory, "level.dat_new"); + File file2 = new File(this.worldDirectory, "level.dat_old"); + File file3 = new File(this.worldDirectory, "level.dat"); + CompressedStreamTools.writeCompressed(nbttagcompound1, new FileOutputStream(file1)); + + if (file2.exists()) + { + file2.delete(); + } + + file3.renameTo(file2); + + if (file3.exists()) + { + file3.delete(); + } + + file1.renameTo(file3); + + if (file1.exists()) + { + file1.delete(); + } + } + catch (Exception exception) + { + exception.printStackTrace(); + } + } + + public void writePlayerData(EntityPlayer par1EntityPlayer) + { + try + { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + par1EntityPlayer.writeToNBT(nbttagcompound); + File file1 = new File(this.playersDirectory, par1EntityPlayer.getCommandSenderName() + ".dat.tmp"); + File file2 = new File(this.playersDirectory, par1EntityPlayer.getCommandSenderName() + ".dat"); + CompressedStreamTools.writeCompressed(nbttagcompound, new FileOutputStream(file1)); + + if (file2.exists()) + { + file2.delete(); + } + + file1.renameTo(file2); + } + catch (Exception exception) + { + logger.warn("Failed to save player data for " + par1EntityPlayer.getCommandSenderName()); + } + } + + public NBTTagCompound readPlayerData(EntityPlayer par1EntityPlayer) + { + NBTTagCompound nbttagcompound = this.getPlayerData(par1EntityPlayer.getCommandSenderName()); + + if (nbttagcompound != null) + { + par1EntityPlayer.readFromNBT(nbttagcompound); + } + + return nbttagcompound; + } + + public NBTTagCompound getPlayerData(String par1Str) + { + try + { + File file1 = new File(this.playersDirectory, par1Str + ".dat"); + + if (file1.exists()) + { + return CompressedStreamTools.readCompressed(new FileInputStream(file1)); + } + } + catch (Exception exception) + { + logger.warn("Failed to load player data for " + par1Str); + } + + return null; + } + + public IPlayerFileData getSaveHandler() + { + return this; + } + + public String[] getAvailablePlayerDat() + { + String[] astring = this.playersDirectory.list(); + + for (int i = 0; i < astring.length; ++i) + { + if (astring[i].endsWith(".dat")) + { + astring[i] = astring[i].substring(0, astring[i].length() - 4); + } + } + + return astring; + } + + public void flush() {} + + public File getMapFileFromName(String par1Str) + { + return new File(this.mapDataDir, par1Str + ".dat"); + } + + public String getWorldDirectoryName() + { + return this.saveDirectoryName; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/storage/SaveHandlerMP.java b/src/main/java/net/minecraft/world/storage/SaveHandlerMP.java new file mode 100644 index 0000000..8152a19 --- /dev/null +++ b/src/main/java/net/minecraft/world/storage/SaveHandlerMP.java @@ -0,0 +1,53 @@ +package net.minecraft.world.storage; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.io.File; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.MinecraftException; +import net.minecraft.world.WorldProvider; +import net.minecraft.world.chunk.storage.IChunkLoader; + +@SideOnly(Side.CLIENT) +public class SaveHandlerMP implements ISaveHandler +{ + private static final String __OBFID = "CL_00000602"; + + public WorldInfo loadWorldInfo() + { + return null; + } + + public void checkSessionLock() throws MinecraftException {} + + public IChunkLoader getChunkLoader(WorldProvider par1WorldProvider) + { + return null; + } + + public void saveWorldInfoWithPlayer(WorldInfo par1WorldInfo, NBTTagCompound par2NBTTagCompound) {} + + public void saveWorldInfo(WorldInfo par1WorldInfo) {} + + public IPlayerFileData getSaveHandler() + { + return null; + } + + public void flush() {} + + public File getMapFileFromName(String par1Str) + { + return null; + } + + public String getWorldDirectoryName() + { + return "none"; + } + + public File getWorldDirectory() + { + return null; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/storage/ThreadedFileIOBase.java b/src/main/java/net/minecraft/world/storage/ThreadedFileIOBase.java new file mode 100644 index 0000000..36a51ab --- /dev/null +++ b/src/main/java/net/minecraft/world/storage/ThreadedFileIOBase.java @@ -0,0 +1,85 @@ +package net.minecraft.world.storage; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class ThreadedFileIOBase implements Runnable +{ + public static final ThreadedFileIOBase threadedIOInstance = new ThreadedFileIOBase(); + private List threadedIOQueue = Collections.synchronizedList(new ArrayList()); + private volatile long writeQueuedCounter; + private volatile long savedIOCounter; + private volatile boolean isThreadWaiting; + private static final String __OBFID = "CL_00000605"; + + private ThreadedFileIOBase() + { + Thread thread = new Thread(this, "File IO Thread"); + thread.setPriority(1); + thread.start(); + } + + public void run() + { + while (true) + this.processQueue(); + } + + private void processQueue() + { + for (int i = 0; i < this.threadedIOQueue.size(); ++i) + { + IThreadedFileIO ithreadedfileio = (IThreadedFileIO)this.threadedIOQueue.get(i); + boolean flag = ithreadedfileio.writeNextIO(); + + if (!flag) + { + this.threadedIOQueue.remove(i--); + ++this.savedIOCounter; + } + + try + { + Thread.sleep(this.isThreadWaiting ? 0L : 10L); + } + catch (InterruptedException interruptedexception1) + { + interruptedexception1.printStackTrace(); + } + } + + if (this.threadedIOQueue.isEmpty()) + { + try + { + Thread.sleep(25L); + } + catch (InterruptedException interruptedexception) + { + interruptedexception.printStackTrace(); + } + } + } + + public void queueIO(IThreadedFileIO par1IThreadedFileIO) + { + if (!this.threadedIOQueue.contains(par1IThreadedFileIO)) + { + ++this.writeQueuedCounter; + this.threadedIOQueue.add(par1IThreadedFileIO); + } + } + + public void waitForFinish() throws InterruptedException + { + this.isThreadWaiting = true; + + while (this.writeQueuedCounter != this.savedIOCounter) + { + Thread.sleep(10L); + } + + this.isThreadWaiting = false; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/world/storage/WorldInfo.java b/src/main/java/net/minecraft/world/storage/WorldInfo.java new file mode 100644 index 0000000..a0103ba --- /dev/null +++ b/src/main/java/net/minecraft/world/storage/WorldInfo.java @@ -0,0 +1,559 @@ +package net.minecraft.world.storage; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import java.util.Map; +import java.util.concurrent.Callable; +import net.minecraft.crash.CrashReportCategory; +import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.server.MinecraftServer; +import net.minecraft.world.GameRules; +import net.minecraft.world.WorldSettings; +import net.minecraft.world.WorldType; + +public class WorldInfo +{ + private long randomSeed; + private WorldType terrainType; + private String generatorOptions; + private int spawnX; + private int spawnY; + private int spawnZ; + private long totalTime; + private long worldTime; + private long lastTimePlayed; + private long sizeOnDisk; + private NBTTagCompound playerTag; + private int dimension; + private String levelName; + private int saveVersion; + private boolean raining; + private int rainTime; + private boolean thundering; + private int thunderTime; + private WorldSettings.GameType theGameType; + private boolean mapFeaturesEnabled; + private boolean hardcore; + private boolean allowCommands; + private boolean initialized; + private GameRules theGameRules; + private Map additionalProperties; + private static final String __OBFID = "CL_00000587"; + + protected WorldInfo() + { + this.terrainType = WorldType.DEFAULT; + this.generatorOptions = ""; + this.theGameRules = new GameRules(); + } + + public WorldInfo(NBTTagCompound par1NBTTagCompound) + { + this.terrainType = WorldType.DEFAULT; + this.generatorOptions = ""; + this.theGameRules = new GameRules(); + this.randomSeed = par1NBTTagCompound.getLong("RandomSeed"); + + if (par1NBTTagCompound.hasKey("generatorName", 8)) + { + String s = par1NBTTagCompound.getString("generatorName"); + this.terrainType = WorldType.parseWorldType(s); + + if (this.terrainType == null) + { + this.terrainType = WorldType.DEFAULT; + } + else if (this.terrainType.isVersioned()) + { + int i = 0; + + if (par1NBTTagCompound.hasKey("generatorVersion", 99)) + { + i = par1NBTTagCompound.getInteger("generatorVersion"); + } + + this.terrainType = this.terrainType.getWorldTypeForGeneratorVersion(i); + } + + if (par1NBTTagCompound.hasKey("generatorOptions", 8)) + { + this.generatorOptions = par1NBTTagCompound.getString("generatorOptions"); + } + } + + this.theGameType = WorldSettings.GameType.getByID(par1NBTTagCompound.getInteger("GameType")); + + if (par1NBTTagCompound.hasKey("MapFeatures", 99)) + { + this.mapFeaturesEnabled = par1NBTTagCompound.getBoolean("MapFeatures"); + } + else + { + this.mapFeaturesEnabled = true; + } + + this.spawnX = par1NBTTagCompound.getInteger("SpawnX"); + this.spawnY = par1NBTTagCompound.getInteger("SpawnY"); + this.spawnZ = par1NBTTagCompound.getInteger("SpawnZ"); + this.totalTime = par1NBTTagCompound.getLong("Time"); + + if (par1NBTTagCompound.hasKey("DayTime", 99)) + { + this.worldTime = par1NBTTagCompound.getLong("DayTime"); + } + else + { + this.worldTime = this.totalTime; + } + + this.lastTimePlayed = par1NBTTagCompound.getLong("LastPlayed"); + this.sizeOnDisk = par1NBTTagCompound.getLong("SizeOnDisk"); + this.levelName = par1NBTTagCompound.getString("LevelName"); + this.saveVersion = par1NBTTagCompound.getInteger("version"); + this.rainTime = par1NBTTagCompound.getInteger("rainTime"); + this.raining = par1NBTTagCompound.getBoolean("raining"); + this.thunderTime = par1NBTTagCompound.getInteger("thunderTime"); + this.thundering = par1NBTTagCompound.getBoolean("thundering"); + this.hardcore = par1NBTTagCompound.getBoolean("hardcore"); + + if (par1NBTTagCompound.hasKey("initialized", 99)) + { + this.initialized = par1NBTTagCompound.getBoolean("initialized"); + } + else + { + this.initialized = true; + } + + if (par1NBTTagCompound.hasKey("allowCommands", 99)) + { + this.allowCommands = par1NBTTagCompound.getBoolean("allowCommands"); + } + else + { + this.allowCommands = this.theGameType == WorldSettings.GameType.CREATIVE; + } + + if (par1NBTTagCompound.hasKey("Player", 10)) + { + this.playerTag = par1NBTTagCompound.getCompoundTag("Player"); + this.dimension = this.playerTag.getInteger("Dimension"); + } + + if (par1NBTTagCompound.hasKey("GameRules", 10)) + { + this.theGameRules.readGameRulesFromNBT(par1NBTTagCompound.getCompoundTag("GameRules")); + } + } + + public WorldInfo(WorldSettings par1WorldSettings, String par2Str) + { + this.terrainType = WorldType.DEFAULT; + this.generatorOptions = ""; + this.theGameRules = new GameRules(); + this.randomSeed = par1WorldSettings.getSeed(); + this.theGameType = par1WorldSettings.getGameType(); + this.mapFeaturesEnabled = par1WorldSettings.isMapFeaturesEnabled(); + this.levelName = par2Str; + this.hardcore = par1WorldSettings.getHardcoreEnabled(); + this.terrainType = par1WorldSettings.getTerrainType(); + this.generatorOptions = par1WorldSettings.func_82749_j(); + this.allowCommands = par1WorldSettings.areCommandsAllowed(); + this.initialized = false; + } + + public WorldInfo(WorldInfo par1WorldInfo) + { + this.terrainType = WorldType.DEFAULT; + this.generatorOptions = ""; + this.theGameRules = new GameRules(); + this.randomSeed = par1WorldInfo.randomSeed; + this.terrainType = par1WorldInfo.terrainType; + this.generatorOptions = par1WorldInfo.generatorOptions; + this.theGameType = par1WorldInfo.theGameType; + this.mapFeaturesEnabled = par1WorldInfo.mapFeaturesEnabled; + this.spawnX = par1WorldInfo.spawnX; + this.spawnY = par1WorldInfo.spawnY; + this.spawnZ = par1WorldInfo.spawnZ; + this.totalTime = par1WorldInfo.totalTime; + this.worldTime = par1WorldInfo.worldTime; + this.lastTimePlayed = par1WorldInfo.lastTimePlayed; + this.sizeOnDisk = par1WorldInfo.sizeOnDisk; + this.playerTag = par1WorldInfo.playerTag; + this.dimension = par1WorldInfo.dimension; + this.levelName = par1WorldInfo.levelName; + this.saveVersion = par1WorldInfo.saveVersion; + this.rainTime = par1WorldInfo.rainTime; + this.raining = par1WorldInfo.raining; + this.thunderTime = par1WorldInfo.thunderTime; + this.thundering = par1WorldInfo.thundering; + this.hardcore = par1WorldInfo.hardcore; + this.allowCommands = par1WorldInfo.allowCommands; + this.initialized = par1WorldInfo.initialized; + this.theGameRules = par1WorldInfo.theGameRules; + } + + public NBTTagCompound getNBTTagCompound() + { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + this.updateTagCompound(nbttagcompound, this.playerTag); + return nbttagcompound; + } + + public NBTTagCompound cloneNBTCompound(NBTTagCompound par1NBTTagCompound) + { + NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + this.updateTagCompound(nbttagcompound1, par1NBTTagCompound); + return nbttagcompound1; + } + + private void updateTagCompound(NBTTagCompound par1NBTTagCompound, NBTTagCompound par2NBTTagCompound) + { + par1NBTTagCompound.setLong("RandomSeed", this.randomSeed); + par1NBTTagCompound.setString("generatorName", this.terrainType.getWorldTypeName()); + par1NBTTagCompound.setInteger("generatorVersion", this.terrainType.getGeneratorVersion()); + par1NBTTagCompound.setString("generatorOptions", this.generatorOptions); + par1NBTTagCompound.setInteger("GameType", this.theGameType.getID()); + par1NBTTagCompound.setBoolean("MapFeatures", this.mapFeaturesEnabled); + par1NBTTagCompound.setInteger("SpawnX", this.spawnX); + par1NBTTagCompound.setInteger("SpawnY", this.spawnY); + par1NBTTagCompound.setInteger("SpawnZ", this.spawnZ); + par1NBTTagCompound.setLong("Time", this.totalTime); + par1NBTTagCompound.setLong("DayTime", this.worldTime); + par1NBTTagCompound.setLong("SizeOnDisk", this.sizeOnDisk); + par1NBTTagCompound.setLong("LastPlayed", MinecraftServer.getSystemTimeMillis()); + par1NBTTagCompound.setString("LevelName", this.levelName); + par1NBTTagCompound.setInteger("version", this.saveVersion); + par1NBTTagCompound.setInteger("rainTime", this.rainTime); + par1NBTTagCompound.setBoolean("raining", this.raining); + par1NBTTagCompound.setInteger("thunderTime", this.thunderTime); + par1NBTTagCompound.setBoolean("thundering", this.thundering); + par1NBTTagCompound.setBoolean("hardcore", this.hardcore); + par1NBTTagCompound.setBoolean("allowCommands", this.allowCommands); + par1NBTTagCompound.setBoolean("initialized", this.initialized); + par1NBTTagCompound.setTag("GameRules", this.theGameRules.writeGameRulesToNBT()); + + if (par2NBTTagCompound != null) + { + par1NBTTagCompound.setTag("Player", par2NBTTagCompound); + } + } + + public long getSeed() + { + return this.randomSeed; + } + + public int getSpawnX() + { + return this.spawnX; + } + + public int getSpawnY() + { + return this.spawnY; + } + + public int getSpawnZ() + { + return this.spawnZ; + } + + public long getWorldTotalTime() + { + return this.totalTime; + } + + public long getWorldTime() + { + return this.worldTime; + } + + @SideOnly(Side.CLIENT) + public long getSizeOnDisk() + { + return this.sizeOnDisk; + } + + public NBTTagCompound getPlayerNBTTagCompound() + { + return this.playerTag; + } + + public int getVanillaDimension() + { + return this.dimension; + } + + @SideOnly(Side.CLIENT) + public void setSpawnX(int par1) + { + this.spawnX = par1; + } + + @SideOnly(Side.CLIENT) + public void setSpawnY(int par1) + { + this.spawnY = par1; + } + + public void incrementTotalWorldTime(long par1) + { + this.totalTime = par1; + } + + @SideOnly(Side.CLIENT) + public void setSpawnZ(int par1) + { + this.spawnZ = par1; + } + + public void setWorldTime(long par1) + { + this.worldTime = par1; + } + + public void setSpawnPosition(int par1, int par2, int par3) + { + this.spawnX = par1; + this.spawnY = par2; + this.spawnZ = par3; + } + + public String getWorldName() + { + return this.levelName; + } + + public void setWorldName(String par1Str) + { + this.levelName = par1Str; + } + + public int getSaveVersion() + { + return this.saveVersion; + } + + public void setSaveVersion(int par1) + { + this.saveVersion = par1; + } + + @SideOnly(Side.CLIENT) + public long getLastTimePlayed() + { + return this.lastTimePlayed; + } + + public boolean isThundering() + { + return this.thundering; + } + + public void setThundering(boolean par1) + { + this.thundering = par1; + } + + public int getThunderTime() + { + return this.thunderTime; + } + + public void setThunderTime(int par1) + { + this.thunderTime = par1; + } + + public boolean isRaining() + { + return this.raining; + } + + public void setRaining(boolean par1) + { + this.raining = par1; + } + + public int getRainTime() + { + return this.rainTime; + } + + public void setRainTime(int par1) + { + this.rainTime = par1; + } + + public WorldSettings.GameType getGameType() + { + return this.theGameType; + } + + public boolean isMapFeaturesEnabled() + { + return this.mapFeaturesEnabled; + } + + public void setGameType(WorldSettings.GameType par1EnumGameType) + { + this.theGameType = par1EnumGameType; + } + + public boolean isHardcoreModeEnabled() + { + return this.hardcore; + } + + public WorldType getTerrainType() + { + return this.terrainType; + } + + public void setTerrainType(WorldType par1WorldType) + { + this.terrainType = par1WorldType; + } + + public String getGeneratorOptions() + { + return this.generatorOptions; + } + + public boolean areCommandsAllowed() + { + return this.allowCommands; + } + + public boolean isInitialized() + { + return this.initialized; + } + + public void setServerInitialized(boolean par1) + { + this.initialized = par1; + } + + public GameRules getGameRulesInstance() + { + return this.theGameRules; + } + + public void addToCrashReport(CrashReportCategory par1CrashReportCategory) + { + par1CrashReportCategory.addCrashSectionCallable("Level seed", new Callable() + { + private static final String __OBFID = "CL_00000588"; + public String call() + { + return String.valueOf(WorldInfo.this.getSeed()); + } + }); + par1CrashReportCategory.addCrashSectionCallable("Level generator", new Callable() + { + private static final String __OBFID = "CL_00000589"; + public String call() + { + return String.format("ID %02d - %s, ver %d. Features enabled: %b", new Object[] {Integer.valueOf(WorldInfo.this.terrainType.getWorldTypeID()), WorldInfo.this.terrainType.getWorldTypeName(), Integer.valueOf(WorldInfo.this.terrainType.getGeneratorVersion()), Boolean.valueOf(WorldInfo.this.mapFeaturesEnabled)}); + } + }); + par1CrashReportCategory.addCrashSectionCallable("Level generator options", new Callable() + { + private static final String __OBFID = "CL_00000590"; + public String call() + { + return WorldInfo.this.generatorOptions; + } + }); + par1CrashReportCategory.addCrashSectionCallable("Level spawn location", new Callable() + { + private static final String __OBFID = "CL_00000591"; + public String call() + { + return CrashReportCategory.getLocationInfo(WorldInfo.this.spawnX, WorldInfo.this.spawnY, WorldInfo.this.spawnZ); + } + }); + par1CrashReportCategory.addCrashSectionCallable("Level time", new Callable() + { + private static final String __OBFID = "CL_00000592"; + public String call() + { + return String.format("%d game time, %d day time", new Object[] {Long.valueOf(WorldInfo.this.totalTime), Long.valueOf(WorldInfo.this.worldTime)}); + } + }); + par1CrashReportCategory.addCrashSectionCallable("Level dimension", new Callable() + { + private static final String __OBFID = "CL_00000593"; + public String call() + { + return String.valueOf(WorldInfo.this.dimension); + } + }); + par1CrashReportCategory.addCrashSectionCallable("Level storage version", new Callable() + { + private static final String __OBFID = "CL_00000594"; + public String call() + { + String s = "Unknown?"; + + try + { + switch (WorldInfo.this.saveVersion) + { + case 19132: + s = "McRegion"; + break; + case 19133: + s = "Anvil"; + } + } + catch (Throwable throwable) + { + ; + } + + return String.format("0x%05X - %s", new Object[] {Integer.valueOf(WorldInfo.this.saveVersion), s}); + } + }); + par1CrashReportCategory.addCrashSectionCallable("Level weather", new Callable() + { + private static final String __OBFID = "CL_00000595"; + public String call() + { + return String.format("Rain time: %d (now: %b), thunder time: %d (now: %b)", new Object[] {Integer.valueOf(WorldInfo.this.rainTime), Boolean.valueOf(WorldInfo.this.raining), Integer.valueOf(WorldInfo.this.thunderTime), Boolean.valueOf(WorldInfo.this.thundering)}); + } + }); + par1CrashReportCategory.addCrashSectionCallable("Level game mode", new Callable() + { + private static final String __OBFID = "CL_00000597"; + public String call() + { + return String.format("Game mode: %s (ID %d). Hardcore: %b. Cheats: %b", new Object[] {WorldInfo.this.theGameType.getName(), Integer.valueOf(WorldInfo.this.theGameType.getID()), Boolean.valueOf(WorldInfo.this.hardcore), Boolean.valueOf(WorldInfo.this.allowCommands)}); + } + }); + } + + /** + * Allow access to additional mod specific world based properties + * Used by FML to store mod list associated with a world, and maybe an id map + * Used by Forge to store the dimensions available to a world + * @param additionalProperties + */ + public void setAdditionalProperties(Map additionalProperties) + { + // one time set for this + if (this.additionalProperties == null) + { + this.additionalProperties = additionalProperties; + } + } + + public NBTBase getAdditionalProperty(String additionalProperty) + { + return this.additionalProperties!=null? this.additionalProperties.get(additionalProperty) : null; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/classloading/FMLForgePlugin.java b/src/main/java/net/minecraftforge/classloading/FMLForgePlugin.java new file mode 100644 index 0000000..f94d1d8 --- /dev/null +++ b/src/main/java/net/minecraftforge/classloading/FMLForgePlugin.java @@ -0,0 +1,43 @@ +package net.minecraftforge.classloading; + +import java.io.File; +import java.util.Map; + +import cpw.mods.fml.relauncher.IFMLLoadingPlugin; + +public class FMLForgePlugin implements IFMLLoadingPlugin +{ + public static boolean RUNTIME_DEOBF = false; + public static File forgeLocation; + + @Override + public String[] getASMTransformerClass() + { + return new String[0]; + } + + @Override + public String getModContainerClass() + { + return "net.minecraftforge.common.ForgeModContainer"; + } + + @Override + public String getSetupClass() + { + return null; + } + + @Override + public void injectData(Map data) + { + RUNTIME_DEOBF = (Boolean)data.get("runtimeDeobfuscationEnabled"); + forgeLocation = (File)data.get("coremodLocation"); + } + + @Override + public String getAccessTransformerClass() + { + return "net.minecraftforge.transformers.ForgeAccessTransformer"; + } +} diff --git a/src/main/java/net/minecraftforge/client/ClientCommandHandler.java b/src/main/java/net/minecraftforge/client/ClientCommandHandler.java new file mode 100644 index 0000000..46b5478 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/ClientCommandHandler.java @@ -0,0 +1,140 @@ +package net.minecraftforge.client; + +import java.util.List; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiChat; +import net.minecraft.command.CommandException; +import net.minecraft.command.CommandHandler; +import net.minecraft.command.ICommand; +import net.minecraft.command.ICommandSender; +import net.minecraft.command.WrongUsageException; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.CommandEvent; +import cpw.mods.fml.client.FMLClientHandler; +import net.minecraft.util.EnumChatFormatting; +import static net.minecraft.util.EnumChatFormatting.*; + +/** + * The class that handles client-side chat commands. You should register any + * commands that you want handled on the client with this command handler. + * + * If there is a command with the same name registered both on the server and + * client, the client takes precedence! + * + */ +public class ClientCommandHandler extends CommandHandler +{ + public static final ClientCommandHandler instance = new ClientCommandHandler(); + + public String[] latestAutoComplete = null; + + /** + * @return 1 if successfully executed, 0 if wrong usage, it doesn't exist or + * it was canceled. + */ + @Override + public int executeCommand(ICommandSender sender, String message) + { + message = message.trim(); + + if (message.startsWith("/")) + { + message = message.substring(1); + } + + String[] temp = message.split(" "); + String[] args = new String[temp.length - 1]; + String commandName = temp[0]; + System.arraycopy(temp, 1, args, 0, args.length); + ICommand icommand = (ICommand) getCommands().get(commandName); + + try + { + if (icommand == null) + { + return 0; + } + + if (icommand.canCommandSenderUseCommand(sender)) + { + CommandEvent event = new CommandEvent(icommand, sender, args); + if (MinecraftForge.EVENT_BUS.post(event)) + { + if (event.exception != null) + { + throw event.exception; + } + return 0; + } + + icommand.processCommand(sender, args); + return 1; + } + else + { + sender.addChatMessage(format(RED, "commands.generic.permission")); + } + } + catch (WrongUsageException wue) + { + sender.addChatMessage(format(RED, "commands.generic.usage", format(RED, wue.getMessage(), wue.getErrorOjbects()))); + } + catch (CommandException ce) + { + sender.addChatMessage(format(RED, ce.getMessage(), ce.getErrorOjbects())); + } + catch (Throwable t) + { + sender.addChatMessage(format(RED, "commands.generic.exception")); + t.printStackTrace(); + } + + return 0; + } + + //Couple of helpers because the mcp names are stupid and long... + private ChatComponentTranslation format(EnumChatFormatting color, String str, Object... args) + { + ChatComponentTranslation ret = new ChatComponentTranslation(str, args); + ret.getChatStyle().setColor(color); + return ret; + } + + public void autoComplete(String leftOfCursor, String full) + { + latestAutoComplete = null; + + if (leftOfCursor.charAt(0) == '/') + { + leftOfCursor = leftOfCursor.substring(1); + + Minecraft mc = FMLClientHandler.instance().getClient(); + if (mc.currentScreen instanceof GuiChat) + { + @SuppressWarnings("unchecked") + List commands = getPossibleCommands(mc.thePlayer, leftOfCursor); + if (commands != null && !commands.isEmpty()) + { + if (leftOfCursor.indexOf(' ') == -1) + { + for (int i = 0; i < commands.size(); i++) + { + commands.set(i, GRAY + "/" + commands.get(i) + RESET); + } + } + else + { + for (int i = 0; i < commands.size(); i++) + { + commands.set(i, GRAY + commands.get(i) + RESET); + } + } + + latestAutoComplete = commands.toArray(new String[commands.size()]); + } + } + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/client/EnumHelperClient.java b/src/main/java/net/minecraftforge/client/EnumHelperClient.java new file mode 100644 index 0000000..f991fdd --- /dev/null +++ b/src/main/java/net/minecraftforge/client/EnumHelperClient.java @@ -0,0 +1,44 @@ +package net.minecraftforge.client; + +import net.minecraft.util.Util.EnumOS; +import net.minecraft.world.WorldSettings.GameType; +import net.minecraft.client.settings.GameSettings.Options; +import net.minecraft.item.EnumRarity; +import net.minecraftforge.common.util.EnumHelper; + +public class EnumHelperClient extends EnumHelper +{ + @SuppressWarnings("rawtypes") + private static Class[][] clentTypes = + { + {GameType.class, int.class, String.class}, + {Options.class, String.class, boolean.class, boolean.class}, + {EnumOS.class}, + {EnumRarity.class, int.class, String.class} + }; + + public static GameType addGameType(String name, int id, String displayName) + { + return addEnum(GameType.class, name, id, displayName); + } + + public static Options addOptions(String name, String langName, boolean isSlider, boolean isToggle) + { + return addEnum(Options.class, name, langName, isSlider, isToggle); + } + + public static EnumOS addOS2(String name) + { + return addEnum(EnumOS.class, name); + } + + public static EnumRarity addRarity(String name, int color, String displayName) + { + return addEnum(EnumRarity.class, name, color, displayName); + } + + public static > T addEnum(Class enumType, String enumName, Object... paramValues) + { + return addEnum(clentTypes, enumType, enumName, paramValues); + } +} diff --git a/src/main/java/net/minecraftforge/client/ForgeHooksClient.java b/src/main/java/net/minecraftforge/client/ForgeHooksClient.java new file mode 100644 index 0000000..da53fa0 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/ForgeHooksClient.java @@ -0,0 +1,456 @@ +package net.minecraftforge.client; + +import java.util.Random; + +import javax.imageio.ImageIO; + +import net.minecraftforge.client.event.MouseEvent; +import net.minecraft.client.audio.ISound; +import net.minecraft.client.audio.SoundEventAccessorComposite; +import net.minecraft.client.audio.SoundManager; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.GuiMainMenu; +import net.minecraftforge.client.event.FOVUpdateEvent; + +import org.lwjgl.LWJGLException; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; +import org.lwjgl.opengl.PixelFormat; + +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.common.FMLLog; +import net.minecraft.client.Minecraft; +import net.minecraft.block.Block; +import net.minecraft.block.BlockLiquid; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.client.model.ModelBiped; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.RenderGlobal; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.client.settings.GameSettings; +import net.minecraftforge.client.IItemRenderer.ItemRenderType; +import net.minecraftforge.client.event.DrawBlockHighlightEvent; +import net.minecraftforge.client.event.RenderHandEvent; +import net.minecraftforge.client.event.RenderWorldLastEvent; +import net.minecraftforge.client.event.TextureStitchEvent; +import net.minecraftforge.client.event.sound.PlaySoundEvent17; +import net.minecraftforge.common.ForgeModContainer; +import net.minecraftforge.common.ForgeVersion; +import net.minecraftforge.common.ForgeVersion.Status; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.RenderBlockFluid; +import static net.minecraftforge.client.IItemRenderer.ItemRenderType.*; +import static net.minecraftforge.client.IItemRenderer.ItemRendererHelper.*; +import static net.minecraftforge.common.ForgeVersion.Status.*; + +public class ForgeHooksClient +{ + //private static final ResourceLocation ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png"); + + static TextureManager engine() + { + return FMLClientHandler.instance().getClient().renderEngine; + } + + public static String getArmorTexture(Entity entity, ItemStack armor, String _default, int slot, String type) + { + String result = armor.getItem().getArmorTexture(armor, entity, slot, type); + return result != null ? result : _default; + } + + public static boolean renderEntityItem(EntityItem entity, ItemStack item, float bobing, float rotation, Random random, TextureManager engine, RenderBlocks renderBlocks, int count) + { + IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(item, ENTITY); + if (customRenderer == null) + { + return false; + } + + if (customRenderer.shouldUseRenderHelper(ENTITY, item, ENTITY_ROTATION)) + { + GL11.glRotatef(rotation, 0.0F, 1.0F, 0.0F); + } + if (!customRenderer.shouldUseRenderHelper(ENTITY, item, ENTITY_BOBBING)) + { + GL11.glTranslatef(0.0F, -bobing, 0.0F); + } + boolean is3D = customRenderer.shouldUseRenderHelper(ENTITY, item, BLOCK_3D); + + engine.bindTexture(item.getItemSpriteNumber() == 0 ? TextureMap.locationBlocksTexture : TextureMap.locationItemsTexture); + Block block = item.getItem() instanceof ItemBlock ? Block.getBlockFromItem(item.getItem()) : null; + if (is3D || (block != null && RenderBlocks.renderItemIn3d(block.getRenderType()))) + { + int renderType = (block != null ? block.getRenderType() : 1); + float scale = (renderType == 1 || renderType == 19 || renderType == 12 || renderType == 2 ? 0.5F : 0.25F); + boolean blend = block != null && block.getRenderBlockPass() > 0; + + if (RenderItem.renderInFrame) + { + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glTranslatef(0.0F, 0.05F, 0.0F); + GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); + } + + if (blend) + { + GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + } + + GL11.glScalef(scale, scale, scale); + + for(int j = 0; j < count; j++) + { + GL11.glPushMatrix(); + if (j > 0) + { + GL11.glTranslatef( + ((random.nextFloat() * 2.0F - 1.0F) * 0.2F) / scale, + ((random.nextFloat() * 2.0F - 1.0F) * 0.2F) / scale, + ((random.nextFloat() * 2.0F - 1.0F) * 0.2F) / scale); + } + customRenderer.renderItem(ENTITY, item, renderBlocks, entity); + GL11.glPopMatrix(); + } + + if (blend) + { + GL11.glDisable(GL11.GL_BLEND); + } + } + else + { + GL11.glScalef(0.5F, 0.5F, 0.5F); + customRenderer.renderItem(ENTITY, item, renderBlocks, entity); + } + return true; + } + + public static boolean renderInventoryItem(RenderBlocks renderBlocks, TextureManager engine, ItemStack item, boolean inColor, float zLevel, float x, float y) + { + IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(item, INVENTORY); + if (customRenderer == null) + { + return false; + } + + engine.bindTexture(item.getItemSpriteNumber() == 0 ? TextureMap.locationBlocksTexture : TextureMap.locationItemsTexture); + if (customRenderer.shouldUseRenderHelper(INVENTORY, item, INVENTORY_BLOCK)) + { + GL11.glPushMatrix(); + GL11.glTranslatef(x - 2, y + 3, -3.0F + zLevel); + GL11.glScalef(10F, 10F, 10F); + GL11.glTranslatef(1.0F, 0.5F, 1.0F); + GL11.glScalef(1.0F, 1.0F, -1F); + GL11.glRotatef(210F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(45F, 0.0F, 1.0F, 0.0F); + + if(inColor) + { + int color = item.getItem().getColorFromItemStack(item, 0); + float r = (float)(color >> 16 & 0xff) / 255F; + float g = (float)(color >> 8 & 0xff) / 255F; + float b = (float)(color & 0xff) / 255F; + GL11.glColor4f(r, g, b, 1.0F); + } + + GL11.glRotatef(-90F, 0.0F, 1.0F, 0.0F); + renderBlocks.useInventoryTint = inColor; + customRenderer.renderItem(INVENTORY, item, renderBlocks); + renderBlocks.useInventoryTint = true; + GL11.glPopMatrix(); + } + else + { + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPushMatrix(); + GL11.glTranslatef(x, y, -3.0F + zLevel); + + if (inColor) + { + int color = item.getItem().getColorFromItemStack(item, 0); + float r = (float)(color >> 16 & 255) / 255.0F; + float g = (float)(color >> 8 & 255) / 255.0F; + float b = (float)(color & 255) / 255.0F; + GL11.glColor4f(r, g, b, 1.0F); + } + + customRenderer.renderItem(INVENTORY, item, renderBlocks); + GL11.glPopMatrix(); + GL11.glEnable(GL11.GL_LIGHTING); + } + + return true; + } + + public static void renderEffectOverlay(TextureManager manager, RenderItem render) + { + } + + public static void renderEquippedItem(ItemRenderType type, IItemRenderer customRenderer, RenderBlocks renderBlocks, EntityLivingBase entity, ItemStack item) + { + if (customRenderer.shouldUseRenderHelper(type, item, EQUIPPED_BLOCK)) + { + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + customRenderer.renderItem(type, item, renderBlocks, entity); + GL11.glPopMatrix(); + } + else + { + GL11.glPushMatrix(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glTranslatef(0.0F, -0.3F, 0.0F); + GL11.glScalef(1.5F, 1.5F, 1.5F); + GL11.glRotatef(50.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(335.0F, 0.0F, 0.0F, 1.0F); + GL11.glTranslatef(-0.9375F, -0.0625F, 0.0F); + customRenderer.renderItem(type, item, renderBlocks, entity); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } + } + + //Optifine Helper Functions u.u, these are here specifically for Optifine + //Note: When using Optfine, these methods are invoked using reflection, which + //incurs a major performance penalty. + public static void orientBedCamera(Minecraft mc, EntityLivingBase entity) + { + int x = MathHelper.floor_double(entity.posX); + int y = MathHelper.floor_double(entity.posY); + int z = MathHelper.floor_double(entity.posZ); + Block block = mc.theWorld.getBlock(x, y, z); + + if (block != null && block.isBed(mc.theWorld, x, y, z, entity)) + { + GL11.glRotatef((float)(block.getBedDirection(mc.theWorld, x, y, z) * 90), 0.0F, 1.0F, 0.0F); + } + } + + public static boolean onDrawBlockHighlight(RenderGlobal context, EntityPlayer player, MovingObjectPosition target, int subID, ItemStack currentItem, float partialTicks) + { + return MinecraftForge.EVENT_BUS.post(new DrawBlockHighlightEvent(context, player, target, subID, currentItem, partialTicks)); + } + + public static void dispatchRenderLast(RenderGlobal context, float partialTicks) + { + MinecraftForge.EVENT_BUS.post(new RenderWorldLastEvent(context, partialTicks)); + } + + public static boolean renderFirstPersonHand(RenderGlobal context, float partialTicks, int renderPass) + { + return MinecraftForge.EVENT_BUS.post(new RenderHandEvent(context, partialTicks, renderPass)); + } + + public static void onTextureStitchedPre(TextureMap map) + { + MinecraftForge.EVENT_BUS.post(new TextureStitchEvent.Pre(map)); + } + + public static void onTextureStitchedPost(TextureMap map) + { + MinecraftForge.EVENT_BUS.post(new TextureStitchEvent.Post(map)); + + FluidRegistry.WATER.setIcons(BlockLiquid.getLiquidIcon("water_still"), BlockLiquid.getLiquidIcon("water_flow")); + FluidRegistry.LAVA.setIcons(BlockLiquid.getLiquidIcon("lava_still"), BlockLiquid.getLiquidIcon("lava_flow")); + } + + /** + * This is added for Optifine's convenience. And to explode if a ModMaker is developing. + * @param texture + */ + public static void onTextureLoadPre(String texture) + { + if (Tessellator.renderingWorldRenderer) + { + FMLLog.warning("Warning: Texture %s not preloaded, will cause render glitches!", texture); + if (Tessellator.class.getPackage() != null) + { + if (Tessellator.class.getPackage().getName().startsWith("net.minecraft.")) + { + Minecraft mc = FMLClientHandler.instance().getClient(); + if (mc.ingameGUI != null) + { + mc.ingameGUI.getChatGUI().printChatMessage(new ChatComponentTranslation("forge.texture.preload.warning", texture)); + } + } + } + } + } + + static int renderPass = -1; + public static void setRenderPass(int pass) + { + renderPass = pass; + } + + public static ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int slotID, ModelBiped _default) + { + ModelBiped modelbiped = itemStack.getItem().getArmorModel(entityLiving, itemStack, slotID); + return modelbiped == null ? _default : modelbiped; + } + + static int stencilBits = 0; + public static void createDisplay() throws LWJGLException + { + ImageIO.setUseCache(false); //Disable on-disc stream cache should speed up texture pack reloading. + PixelFormat format = new PixelFormat().withDepthBits(24); + try + { + //TODO: Figure out how to determine the max bits. + Display.create(format.withStencilBits(8)); + stencilBits = 8; + } + catch(LWJGLException e) + { + Display.create(format); + stencilBits = 0; + } + } + + //This properly moves the domain, if provided, to the front of the string before concatenating + public static String fixDomain(String base, String complex) + { + int idx = complex.indexOf(':'); + if (idx == -1) + { + return base + complex; + } + + String name = complex.substring(idx + 1, complex.length()); + if (idx > 1) + { + String domain = complex.substring(0, idx); + return domain + ':' + base + name; + } + else + { + return base + name; + } + } + + public static boolean postMouseEvent() + { + return MinecraftForge.EVENT_BUS.post(new MouseEvent()); + } + + public static float getOffsetFOV(EntityPlayerSP entity, float fov) + { + FOVUpdateEvent fovUpdateEvent = new FOVUpdateEvent(entity, fov); + MinecraftForge.EVENT_BUS.post(fovUpdateEvent); + return fovUpdateEvent.newfov; + } + + private static int skyX, skyZ; + + private static boolean skyInit; + private static int skyRGBMultiplier; + + public static int getSkyBlendColour(World world, int playerX, int playerY, int playerZ) + { + if (playerX == skyX && playerZ == skyZ && skyInit) + { + return skyRGBMultiplier; + } + skyInit = true; + + GameSettings settings = Minecraft.getMinecraft().gameSettings; + int[] ranges = ForgeModContainer.blendRanges; + int distance = 0; + if (settings.fancyGraphics && settings.renderDistanceChunks >= 0 && settings.renderDistanceChunks < ranges.length) + { + distance = ranges[settings.renderDistanceChunks]; + } + + int r = 0; + int g = 0; + int b = 0; + + int divider = 0; + for (int x = -distance; x <= distance; ++x) + { + for (int z = -distance; z <= distance; ++z) + { + BiomeGenBase biome = world.getBiomeGenForCoords(playerX + x, playerZ + z); + int colour = biome.getSkyColorByTemp(biome.getFloatTemperature(playerX + x, playerY, playerZ + z)); + r += (colour & 0xFF0000) >> 16; + g += (colour & 0x00FF00) >> 8; + b += colour & 0x0000FF; + divider++; + } + } + + int multiplier = (r / divider & 255) << 16 | (g / divider & 255) << 8 | b / divider & 255; + + skyX = playerX; + skyZ = playerZ; + skyRGBMultiplier = multiplier; + return skyRGBMultiplier; + } + /** + * Initialization of Forge Renderers. + */ + static + { + FluidRegistry.renderIdFluid = RenderingRegistry.getNextAvailableRenderId(); + RenderingRegistry.registerBlockHandler(RenderBlockFluid.instance); + } + + public static void renderMainMenu(GuiMainMenu gui, FontRenderer font, int width, int height) + { + Status status = ForgeVersion.getStatus(); + if (status == BETA || status == BETA_OUTDATED) + { + // render a warning at the top of the screen, + String line = EnumChatFormatting.RED + "WARNING:" + EnumChatFormatting.RESET + " Forge Beta,"; + gui.drawString(font, line, (width - font.getStringWidth(line)) / 2, 4 + (0 * (font.FONT_HEIGHT + 1)), -1); + line = "Major issues may arise, verify before reporting."; + gui.drawString(font, line, (width - font.getStringWidth(line)) / 2, 4 + (1 * (font.FONT_HEIGHT + 1)), -1); + } + + String line = null; + switch(status) + { + //case FAILED: line = " Version check failed"; break; + //case UP_TO_DATE: line = "Forge up to date"}; break; + //case AHEAD: line = "Using non-recommended Forge build, issues may arise."}; break; + case OUTDATED: + case BETA_OUTDATED: line = "New Forge version available: " + ForgeVersion.getTarget(); break; + default: break; + } + + if (line != null) + { + // if we have a line, render it in the bottom right, above Mojang's copyright line + gui.drawString(font, line, width - font.getStringWidth(line) - 2, height - (2 * (font.FONT_HEIGHT + 1)), -1); + } + } + + public static ISound playSound(SoundManager manager, ISound sound) + { + SoundEventAccessorComposite accessor = manager.sndHandler.getSound(sound.getPositionedSoundLocation()); + PlaySoundEvent17 e = new PlaySoundEvent17(manager, sound, (accessor == null ? null : accessor.getSoundCategory())); + MinecraftForge.EVENT_BUS.post(e); + return e.result; + } +} diff --git a/src/main/java/net/minecraftforge/client/GuiIngameForge.java b/src/main/java/net/minecraftforge/client/GuiIngameForge.java new file mode 100644 index 0000000..0f6b29b --- /dev/null +++ b/src/main/java/net/minecraftforge/client/GuiIngameForge.java @@ -0,0 +1,900 @@ +package net.minecraftforge.client; + +import static net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType.*; + +import java.awt.Color; +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.block.material.Material; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.GuiIngame; +import net.minecraft.client.gui.GuiPlayerInfo; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.network.NetHandlerPlayClient; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.attributes.IAttributeInstance; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.Potion; +import net.minecraft.scoreboard.Score; +import net.minecraft.scoreboard.ScoreObjective; +import net.minecraft.scoreboard.ScorePlayerTeam; +import net.minecraft.util.Direction; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.FoodStats; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StringUtils; +import net.minecraft.world.EnumSkyBlock; +import net.minecraft.world.chunk.Chunk; +import net.minecraftforge.client.event.RenderGameOverlayEvent; +import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; +import net.minecraftforge.common.ForgeHooks; +import net.minecraftforge.common.MinecraftForge; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import cpw.mods.fml.common.FMLCommonHandler; + +public class GuiIngameForge extends GuiIngame +{ + //private static final ResourceLocation VIGNETTE = new ResourceLocation("textures/misc/vignette.png"); + private static final ResourceLocation WIDGITS = new ResourceLocation("textures/gui/widgets.png"); + //private static final ResourceLocation PUMPKIN_BLUR = new ResourceLocation("textures/misc/pumpkinblur.png"); + + private static final int WHITE = 0xFFFFFF; + + //Flags to toggle the rendering of certain aspects of the HUD, valid conditions + //must be met for them to render normally. If those conditions are met, but this flag + //is false, they will not be rendered. + public static boolean renderHelmet = true; + public static boolean renderPortal = true; + public static boolean renderHotbar = true; + public static boolean renderCrosshairs = true; + public static boolean renderBossHealth = true; + public static boolean renderHealth = true; + public static boolean renderArmor = true; + public static boolean renderFood = true; + public static boolean renderHealthMount = true; + public static boolean renderAir = true; + public static boolean renderExperiance = true; + public static boolean renderJumpBar = true; + public static boolean renderObjective = true; + + public static int left_height = 39; + public static int right_height = 39; + + private ScaledResolution res = null; + private FontRenderer fontrenderer = null; + private RenderGameOverlayEvent eventParent; + private static final String MC_VERSION = MinecraftForge.MC_VERSION; + + public GuiIngameForge(Minecraft mc) + { + super(mc); + } + + @Override + public void renderGameOverlay(float partialTicks, boolean hasScreen, int mouseX, int mouseY) + { + res = new ScaledResolution(mc.gameSettings, mc.displayWidth, mc.displayHeight); + eventParent = new RenderGameOverlayEvent(partialTicks, res, mouseX, mouseY); + int width = res.getScaledWidth(); + int height = res.getScaledHeight(); + renderHealthMount = mc.thePlayer.ridingEntity instanceof EntityLivingBase; + renderFood = mc.thePlayer.ridingEntity == null; + renderJumpBar = mc.thePlayer.isRidingHorse(); + + right_height = 39; + left_height = 39; + + if (pre(ALL)) return; + + fontrenderer = mc.fontRenderer; + mc.entityRenderer.setupOverlayRendering(); + GL11.glEnable(GL11.GL_BLEND); + + if (Minecraft.isFancyGraphicsEnabled()) + { + renderVignette(mc.thePlayer.getBrightness(partialTicks), width, height); + } + else + { + OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); + } + + if (renderHelmet) renderHelmet(res, partialTicks, hasScreen, mouseX, mouseY); + + if (renderPortal && !mc.thePlayer.isPotionActive(Potion.confusion)) + { + renderPortal(width, height, partialTicks); + } + + if (!mc.playerController.enableEverythingIsScrewedUpMode()) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + zLevel = -90.0F; + rand.setSeed((long)(updateCounter * 312871)); + + if (renderCrosshairs) renderCrosshairs(width, height); + if (renderBossHealth) renderBossHealth(); + + if (this.mc.playerController.shouldDrawHUD()) + { + if (renderHealth) renderHealth(width, height); + if (renderArmor) renderArmor(width, height); + if (renderFood) renderFood(width, height); + if (renderHealthMount) renderHealthMount(width, height); + if (renderAir) renderAir(width, height); + } + if (renderHotbar) renderHotbar(width, height, partialTicks); + } + + if (renderJumpBar) + { + renderJumpBar(width, height); + } + else if (renderExperiance) + { + renderExperience(width, height); + } + + renderSleepFade(width, height); + renderToolHightlight(width, height); + renderHUDText(width, height); + renderRecordOverlay(width, height, partialTicks); + + ScoreObjective objective = mc.theWorld.getScoreboard().func_96539_a(1); + if (renderObjective && objective != null) + { + this.func_96136_a(objective, height, width, fontrenderer); + } + + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); + GL11.glDisable(GL11.GL_ALPHA_TEST); + + renderChat(width, height); + + renderPlayerList(width, height); + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_ALPHA_TEST); + + post(ALL); + } + + public ScaledResolution getResolution() + { + return res; + } + + protected void renderHotbar(int width, int height, float partialTicks) + { + if (pre(HOTBAR)) return; + mc.mcProfiler.startSection("actionBar"); + + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(WIDGITS); + + InventoryPlayer inv = mc.thePlayer.inventory; + drawTexturedModalRect(width / 2 - 91, height - 22, 0, 0, 182, 22); + drawTexturedModalRect(width / 2 - 91 - 1 + inv.currentItem * 20, height - 22 - 1, 0, 22, 24, 22); + + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + RenderHelper.enableGUIStandardItemLighting(); + + for (int i = 0; i < 9; ++i) + { + int x = width / 2 - 90 + i * 20 + 2; + int z = height - 16 - 3; + renderInventorySlot(i, x, z, partialTicks); + } + + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + mc.mcProfiler.endSection(); + post(HOTBAR); + } + + protected void renderCrosshairs(int width, int height) + { + if (pre(CROSSHAIRS)) return; + bind(Gui.icons); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(GL11.GL_ONE_MINUS_DST_COLOR, GL11.GL_ONE_MINUS_SRC_COLOR, 1, 0); + drawTexturedModalRect(width / 2 - 7, height / 2 - 7, 0, 0, 16, 16); + OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); + GL11.glDisable(GL11.GL_BLEND); + post(CROSSHAIRS); + } + + @Override + protected void renderBossHealth() + { + if (pre(BOSSHEALTH)) return; + mc.mcProfiler.startSection("bossHealth"); + GL11.glEnable(GL11.GL_BLEND); + super.renderBossHealth(); + GL11.glDisable(GL11.GL_BLEND); + mc.mcProfiler.endSection(); + post(BOSSHEALTH); + } + + private void renderHelmet(ScaledResolution res, float partialTicks, boolean hasScreen, int mouseX, int mouseY) + { + if (pre(HELMET)) return; + + ItemStack itemstack = this.mc.thePlayer.inventory.armorItemInSlot(3); + + if (this.mc.gameSettings.thirdPersonView == 0 && itemstack != null && itemstack.getItem() != null) + { + if (itemstack.getItem() == Item.getItemFromBlock(Blocks.pumpkin)) + { + renderPumpkinBlur(res.getScaledWidth(), res.getScaledHeight()); + } + else + { + itemstack.getItem().renderHelmetOverlay(itemstack, mc.thePlayer, res, partialTicks, hasScreen, mouseX, mouseY); + } + } + + post(HELMET); + } + + protected void renderArmor(int width, int height) + { + if (pre(ARMOR)) return; + mc.mcProfiler.startSection("armor"); + + GL11.glEnable(GL11.GL_BLEND); + int left = width / 2 - 91; + int top = height - left_height; + + int level = ForgeHooks.getTotalArmorValue(mc.thePlayer); + for (int i = 1; level > 0 && i < 20; i += 2) + { + if (i < level) + { + drawTexturedModalRect(left, top, 34, 9, 9, 9); + } + else if (i == level) + { + drawTexturedModalRect(left, top, 25, 9, 9, 9); + } + else if (i > level) + { + drawTexturedModalRect(left, top, 16, 9, 9, 9); + } + left += 8; + } + left_height += 10; + + GL11.glDisable(GL11.GL_BLEND); + mc.mcProfiler.endSection(); + post(ARMOR); + } + + protected void renderPortal(int width, int height, float partialTicks) + { + if (pre(PORTAL)) return; + + float f1 = mc.thePlayer.prevTimeInPortal + (mc.thePlayer.timeInPortal - mc.thePlayer.prevTimeInPortal) * partialTicks; + + if (f1 > 0.0F) + { + func_130015_b(f1, width, height); + } + + post(PORTAL); + } + + protected void renderAir(int width, int height) + { + if (pre(AIR)) return; + mc.mcProfiler.startSection("air"); + GL11.glEnable(GL11.GL_BLEND); + int left = width / 2 + 91; + int top = height - right_height; + + if (mc.thePlayer.isInsideOfMaterial(Material.water)) + { + int air = mc.thePlayer.getAir(); + int full = MathHelper.ceiling_double_int((double)(air - 2) * 10.0D / 300.0D); + int partial = MathHelper.ceiling_double_int((double)air * 10.0D / 300.0D) - full; + + for (int i = 0; i < full + partial; ++i) + { + drawTexturedModalRect(left - i * 8 - 9, top, (i < full ? 16 : 25), 18, 9, 9); + } + right_height += 10; + } + + GL11.glDisable(GL11.GL_BLEND); + mc.mcProfiler.endSection(); + post(AIR); + } + + public void renderHealth(int width, int height) + { + bind(icons); + if (pre(HEALTH)) return; + mc.mcProfiler.startSection("health"); + GL11.glEnable(GL11.GL_BLEND); + + boolean highlight = mc.thePlayer.hurtResistantTime / 3 % 2 == 1; + + if (mc.thePlayer.hurtResistantTime < 10) + { + highlight = false; + } + + IAttributeInstance attrMaxHealth = this.mc.thePlayer.getEntityAttribute(SharedMonsterAttributes.maxHealth); + int health = MathHelper.ceiling_float_int(mc.thePlayer.getHealth()); + int healthLast = MathHelper.ceiling_float_int(mc.thePlayer.prevHealth); + float healthMax = (float)attrMaxHealth.getAttributeValue(); + float absorb = this.mc.thePlayer.getAbsorptionAmount(); + + int healthRows = MathHelper.ceiling_float_int((healthMax + absorb) / 2.0F / 10.0F); + int rowHeight = Math.max(10 - (healthRows - 2), 3); + + this.rand.setSeed((long)(updateCounter * 312871)); + + int left = width / 2 - 91; + int top = height - left_height; + left_height += (healthRows * rowHeight); + if (rowHeight != 10) left_height += 10 - rowHeight; + + int regen = -1; + if (mc.thePlayer.isPotionActive(Potion.regeneration)) + { + regen = updateCounter % 25; + } + + final int TOP = 9 * (mc.theWorld.getWorldInfo().isHardcoreModeEnabled() ? 5 : 0); + final int BACKGROUND = (highlight ? 25 : 16); + int MARGIN = 16; + if (mc.thePlayer.isPotionActive(Potion.poison)) MARGIN += 36; + else if (mc.thePlayer.isPotionActive(Potion.wither)) MARGIN += 72; + float absorbRemaining = absorb; + + for (int i = MathHelper.ceiling_float_int((healthMax + absorb) / 2.0F) - 1; i >= 0; --i) + { + //int b0 = (highlight ? 1 : 0); + int row = MathHelper.ceiling_float_int((float)(i + 1) / 10.0F) - 1; + int x = left + i % 10 * 8; + int y = top - row * rowHeight; + + if (health <= 4) y += rand.nextInt(2); + if (i == regen) y -= 2; + + drawTexturedModalRect(x, y, BACKGROUND, TOP, 9, 9); + + if (highlight) + { + if (i * 2 + 1 < healthLast) + drawTexturedModalRect(x, y, MARGIN + 54, TOP, 9, 9); //6 + else if (i * 2 + 1 == healthLast) + drawTexturedModalRect(x, y, MARGIN + 63, TOP, 9, 9); //7 + } + + if (absorbRemaining > 0.0F) + { + if (absorbRemaining == absorb && absorb % 2.0F == 1.0F) + drawTexturedModalRect(x, y, MARGIN + 153, TOP, 9, 9); //17 + else + drawTexturedModalRect(x, y, MARGIN + 144, TOP, 9, 9); //16 + absorbRemaining -= 2.0F; + } + else + { + if (i * 2 + 1 < health) + drawTexturedModalRect(x, y, MARGIN + 36, TOP, 9, 9); //4 + else if (i * 2 + 1 == health) + drawTexturedModalRect(x, y, MARGIN + 45, TOP, 9, 9); //5 + } + } + + GL11.glDisable(GL11.GL_BLEND); + mc.mcProfiler.endSection(); + post(HEALTH); + } + + public void renderFood(int width, int height) + { + if (pre(FOOD)) return; + mc.mcProfiler.startSection("food"); + + GL11.glEnable(GL11.GL_BLEND); + int left = width / 2 + 91; + int top = height - right_height; + right_height += 10; + boolean unused = false;// Unused flag in vanilla, seems to be part of a 'fade out' mechanic + + FoodStats stats = mc.thePlayer.getFoodStats(); + int level = stats.getFoodLevel(); + int levelLast = stats.getPrevFoodLevel(); + + for (int i = 0; i < 10; ++i) + { + int idx = i * 2 + 1; + int x = left - i * 8 - 9; + int y = top; + int icon = 16; + byte backgound = 0; + + if (mc.thePlayer.isPotionActive(Potion.hunger)) + { + icon += 36; + backgound = 13; + } + if (unused) backgound = 1; //Probably should be a += 1 but vanilla never uses this + + if (mc.thePlayer.getFoodStats().getSaturationLevel() <= 0.0F && updateCounter % (level * 3 + 1) == 0) + { + y = top + (rand.nextInt(3) - 1); + } + + drawTexturedModalRect(x, y, 16 + backgound * 9, 27, 9, 9); + + if (unused) + { + if (idx < levelLast) + drawTexturedModalRect(x, y, icon + 54, 27, 9, 9); + else if (idx == levelLast) + drawTexturedModalRect(x, y, icon + 63, 27, 9, 9); + } + + if (idx < level) + drawTexturedModalRect(x, y, icon + 36, 27, 9, 9); + else if (idx == level) + drawTexturedModalRect(x, y, icon + 45, 27, 9, 9); + } + GL11.glDisable(GL11.GL_BLEND); + mc.mcProfiler.endSection(); + post(FOOD); + } + + protected void renderSleepFade(int width, int height) + { + if (mc.thePlayer.getSleepTimer() > 0) + { + mc.mcProfiler.startSection("sleep"); + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glDisable(GL11.GL_ALPHA_TEST); + int sleepTime = mc.thePlayer.getSleepTimer(); + float opacity = (float)sleepTime / 100.0F; + + if (opacity > 1.0F) + { + opacity = 1.0F - (float)(sleepTime - 100) / 10.0F; + } + + int color = (int)(220.0F * opacity) << 24 | 1052704; + drawRect(0, 0, width, height, color); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_DEPTH_TEST); + mc.mcProfiler.endSection(); + } + } + + protected void renderExperience(int width, int height) + { + bind(icons); + if (pre(EXPERIENCE)) return; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + + if (mc.playerController.gameIsSurvivalOrAdventure()) + { + mc.mcProfiler.startSection("expBar"); + int cap = this.mc.thePlayer.xpBarCap(); + int left = width / 2 - 91; + + if (cap > 0) + { + short barWidth = 182; + int filled = (int)(mc.thePlayer.experience * (float)(barWidth + 1)); + int top = height - 32 + 3; + drawTexturedModalRect(left, top, 0, 64, barWidth, 5); + + if (filled > 0) + { + drawTexturedModalRect(left, top, 0, 69, filled, 5); + } + } + + this.mc.mcProfiler.endSection(); + + + if (mc.playerController.gameIsSurvivalOrAdventure() && mc.thePlayer.experienceLevel > 0) + { + mc.mcProfiler.startSection("expLevel"); + boolean flag1 = false; + int color = flag1 ? 16777215 : 8453920; + String text = "" + mc.thePlayer.experienceLevel; + int x = (width - fontrenderer.getStringWidth(text)) / 2; + int y = height - 31 - 4; + fontrenderer.drawString(text, x + 1, y, 0); + fontrenderer.drawString(text, x - 1, y, 0); + fontrenderer.drawString(text, x, y + 1, 0); + fontrenderer.drawString(text, x, y - 1, 0); + fontrenderer.drawString(text, x, y, color); + mc.mcProfiler.endSection(); + } + } + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + + post(EXPERIENCE); + } + + protected void renderJumpBar(int width, int height) + { + bind(icons); + if (pre(JUMPBAR)) return; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + + mc.mcProfiler.startSection("jumpBar"); + float charge = mc.thePlayer.getHorseJumpPower(); + final int barWidth = 182; + int x = (width / 2) - (barWidth / 2); + int filled = (int)(charge * (float)(barWidth + 1)); + int top = height - 32 + 3; + + drawTexturedModalRect(x, top, 0, 84, barWidth, 5); + + if (filled > 0) + { + this.drawTexturedModalRect(x, top, 0, 89, filled, 5); + } + + mc.mcProfiler.endSection(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + + post(JUMPBAR); + } + + protected void renderToolHightlight(int width, int height) + { + if (this.mc.gameSettings.heldItemTooltips) + { + mc.mcProfiler.startSection("toolHighlight"); + + if (this.remainingHighlightTicks > 0 && this.highlightingItemStack != null) + { + String name = this.highlightingItemStack.getDisplayName(); + + int opacity = (int)((float)this.remainingHighlightTicks * 256.0F / 10.0F); + if (opacity > 255) opacity = 255; + + if (opacity > 0) + { + int y = height - 59; + if (!mc.playerController.shouldDrawHUD()) y += 14; + + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); + FontRenderer font = highlightingItemStack.getItem().getFontRenderer(highlightingItemStack); + if (font != null) + { + int x = (width - font.getStringWidth(name)) / 2; + font.drawStringWithShadow(name, x, y, WHITE | (opacity << 24)); + } + else + { + int x = (width - fontrenderer.getStringWidth(name)) / 2; + fontrenderer.drawStringWithShadow(name, x, y, WHITE | (opacity << 24)); + } + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); + } + } + + mc.mcProfiler.endSection(); + } + } + + protected void renderHUDText(int width, int height) + { + mc.mcProfiler.startSection("forgeHudText"); + OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); + ArrayList left = new ArrayList(); + ArrayList right = new ArrayList(); + + if (mc.isDemo()) + { + long time = mc.theWorld.getTotalWorldTime(); + if (time >= 120500L) + { + right.add(I18n.format("demo.demoExpired")); + } + else + { + right.add(I18n.format("demo.remainingTime", StringUtils.ticksToElapsedTime((int)(120500L - time)))); + } + } + + + if (this.mc.gameSettings.showDebugInfo) + { + mc.mcProfiler.startSection("debug"); + GL11.glPushMatrix(); + left.add("Minecraft " + MC_VERSION + " (" + this.mc.debug + ")"); + left.add(mc.debugInfoRenders()); + left.add(mc.getEntityDebug()); + left.add(mc.debugInfoEntities()); + left.add(mc.getWorldProviderName()); + left.add(null); //Spacer + + long max = Runtime.getRuntime().maxMemory(); + long total = Runtime.getRuntime().totalMemory(); + long free = Runtime.getRuntime().freeMemory(); + long used = total - free; + + right.add("Used memory: " + used * 100L / max + "% (" + used / 1024L / 1024L + "MB) of " + max / 1024L / 1024L + "MB"); + right.add("Allocated memory: " + total * 100L / max + "% (" + total / 1024L / 1024L + "MB)"); + + int x = MathHelper.floor_double(mc.thePlayer.posX); + int y = MathHelper.floor_double(mc.thePlayer.posY); + int z = MathHelper.floor_double(mc.thePlayer.posZ); + float yaw = mc.thePlayer.rotationYaw; + int heading = MathHelper.floor_double((double)(mc.thePlayer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + + left.add(String.format("x: %.5f (%d) // c: %d (%d)", mc.thePlayer.posX, x, x >> 4, x & 15)); + left.add(String.format("y: %.3f (feet pos, %.3f eyes pos)", mc.thePlayer.boundingBox.minY, mc.thePlayer.posY)); + left.add(String.format("z: %.5f (%d) // c: %d (%d)", mc.thePlayer.posZ, z, z >> 4, z & 15)); + left.add(String.format("f: %d (%s) / %f", heading, Direction.directions[heading], MathHelper.wrapAngleTo180_float(yaw))); + + if (mc.theWorld != null && mc.theWorld.blockExists(x, y, z)) + { + Chunk chunk = this.mc.theWorld.getChunkFromBlockCoords(x, z); + left.add(String.format("lc: %d b: %s bl: %d sl: %d rl: %d", + chunk.getTopFilledSegment() + 15, + chunk.getBiomeGenForWorldCoords(x & 15, z & 15, mc.theWorld.getWorldChunkManager()).biomeName, + chunk.getSavedLightValue(EnumSkyBlock.Block, x & 15, y, z & 15), + chunk.getSavedLightValue(EnumSkyBlock.Sky, x & 15, y, z & 15), + chunk.getBlockLightValue(x & 15, y, z & 15, 0))); + } + else + { + left.add(null); + } + + left.add(String.format("ws: %.3f, fs: %.3f, g: %b, fl: %d", mc.thePlayer.capabilities.getWalkSpeed(), mc.thePlayer.capabilities.getFlySpeed(), mc.thePlayer.onGround, mc.theWorld.getHeightValue(x, z))); + if (mc.entityRenderer != null && mc.entityRenderer.isShaderActive()) + { + left.add(String.format("shader: %s", mc.entityRenderer.getShaderGroup().getShaderGroupName())); + } + + right.add(null); + for (String brand : FMLCommonHandler.instance().getBrandings(false)) + { + right.add(brand); + } + GL11.glPopMatrix(); + mc.mcProfiler.endSection(); + } + + RenderGameOverlayEvent.Text event = new RenderGameOverlayEvent.Text(eventParent, left, right); + if (!MinecraftForge.EVENT_BUS.post(event)) + { + for (int x = 0; x < left.size(); x++) + { + String msg = left.get(x); + if (msg == null) continue; + fontrenderer.drawStringWithShadow(msg, 2, 2 + x * 10, WHITE); + } + + for (int x = 0; x < right.size(); x++) + { + String msg = right.get(x); + if (msg == null) continue; + int w = fontrenderer.getStringWidth(msg); + fontrenderer.drawStringWithShadow(msg, width - w - 10, 2 + x * 10, WHITE); + } + } + + mc.mcProfiler.endSection(); + post(TEXT); + } + + protected void renderRecordOverlay(int width, int height, float partialTicks) + { + if (recordPlayingUpFor > 0) + { + mc.mcProfiler.startSection("overlayMessage"); + float hue = (float)recordPlayingUpFor - partialTicks; + int opacity = (int)(hue * 256.0F / 20.0F); + if (opacity > 255) opacity = 255; + + if (opacity > 0) + { + GL11.glPushMatrix(); + GL11.glTranslatef((float)(width / 2), (float)(height - 48), 0.0F); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); + int color = (recordIsPlaying ? Color.HSBtoRGB(hue / 50.0F, 0.7F, 0.6F) & WHITE : WHITE); + fontrenderer.drawString(recordPlaying, -fontrenderer.getStringWidth(recordPlaying) / 2, -4, color | (opacity << 24)); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); + } + + mc.mcProfiler.endSection(); + } + } + + protected void renderChat(int width, int height) + { + mc.mcProfiler.startSection("chat"); + + RenderGameOverlayEvent.Chat event = new RenderGameOverlayEvent.Chat(eventParent, 0, height - 48); + if (MinecraftForge.EVENT_BUS.post(event)) return; + + GL11.glPushMatrix(); + GL11.glTranslatef((float)event.posX, (float)event.posY, 0.0F); + persistantChatGUI.drawChat(updateCounter); + GL11.glPopMatrix(); + + post(CHAT); + + mc.mcProfiler.endSection(); + } + + @SuppressWarnings("unchecked") + protected void renderPlayerList(int width, int height) + { + ScoreObjective scoreobjective = this.mc.theWorld.getScoreboard().func_96539_a(0); + NetHandlerPlayClient handler = mc.thePlayer.sendQueue; + + if (mc.gameSettings.keyBindPlayerList.getIsKeyPressed() && (!mc.isIntegratedServerRunning() || handler.playerInfoList.size() > 1 || scoreobjective != null)) + { + if (pre(PLAYER_LIST)) return; + this.mc.mcProfiler.startSection("playerList"); + List players = (List)handler.playerInfoList; + int maxPlayers = handler.currentServerMaxPlayers; + int rows = maxPlayers; + int columns = 1; + + for (columns = 1; rows > 20; rows = (maxPlayers + columns - 1) / columns) + { + columns++; + } + + int columnWidth = 300 / columns; + + if (columnWidth > 150) + { + columnWidth = 150; + } + + int left = (width - columns * columnWidth) / 2; + byte border = 10; + drawRect(left - 1, border - 1, left + columnWidth * columns, border + 9 * rows, Integer.MIN_VALUE); + + for (int i = 0; i < maxPlayers; i++) + { + int xPos = left + i % columns * columnWidth; + int yPos = border + i / columns * 9; + drawRect(xPos, yPos, xPos + columnWidth - 1, yPos + 8, 553648127); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glEnable(GL11.GL_ALPHA_TEST); + + if (i < players.size()) + { + GuiPlayerInfo player = (GuiPlayerInfo)players.get(i); + ScorePlayerTeam team = mc.theWorld.getScoreboard().getPlayersTeam(player.name); + String displayName = ScorePlayerTeam.formatPlayerName(team, player.name); + fontrenderer.drawStringWithShadow(displayName, xPos, yPos, 16777215); + + if (scoreobjective != null) + { + int endX = xPos + fontrenderer.getStringWidth(displayName) + 5; + int maxX = xPos + columnWidth - 12 - 5; + + if (maxX - endX > 5) + { + Score score = scoreobjective.getScoreboard().func_96529_a(player.name, scoreobjective); + String scoreDisplay = EnumChatFormatting.YELLOW + "" + score.getScorePoints(); + fontrenderer.drawStringWithShadow(scoreDisplay, maxX - fontrenderer.getStringWidth(scoreDisplay), yPos, 16777215); + } + } + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + + mc.getTextureManager().bindTexture(Gui.icons); + int pingIndex = 4; + int ping = player.responseTime; + if (ping < 0) pingIndex = 5; + else if (ping < 150) pingIndex = 0; + else if (ping < 300) pingIndex = 1; + else if (ping < 600) pingIndex = 2; + else if (ping < 1000) pingIndex = 3; + + zLevel += 100.0F; + drawTexturedModalRect(xPos + columnWidth - 12, yPos, 0, 176 + pingIndex * 8, 10, 8); + zLevel -= 100.0F; + } + } + post(PLAYER_LIST); + } + } + + protected void renderHealthMount(int width, int height) + { + Entity tmp = mc.thePlayer.ridingEntity; + if (!(tmp instanceof EntityLivingBase)) return; + + bind(icons); + + if (pre(HEALTHMOUNT)) return; + + boolean unused = false; + int left_align = width / 2 + 91; + + mc.mcProfiler.endStartSection("mountHealth"); + GL11.glEnable(GL11.GL_BLEND); + EntityLivingBase mount = (EntityLivingBase)tmp; + int health = (int)Math.ceil((double)mount.getHealth()); + float healthMax = mount.getMaxHealth(); + int hearts = (int)(healthMax + 0.5F) / 2; + + if (hearts > 30) hearts = 30; + + final int MARGIN = 52; + final int BACKGROUND = MARGIN + (unused ? 1 : 0); + final int HALF = MARGIN + 45; + final int FULL = MARGIN + 36; + + for (int heart = 0; hearts > 0; heart += 20) + { + int top = height - right_height; + + int rowCount = Math.min(hearts, 10); + hearts -= rowCount; + + for (int i = 0; i < rowCount; ++i) + { + int x = left_align - i * 8 - 9; + drawTexturedModalRect(x, top, BACKGROUND, 9, 9, 9); + + if (i * 2 + 1 + heart < health) + drawTexturedModalRect(x, top, FULL, 9, 9, 9); + else if (i * 2 + 1 + heart == health) + drawTexturedModalRect(x, top, HALF, 9, 9, 9); + } + + right_height += 10; + } + GL11.glDisable(GL11.GL_BLEND); + post(HEALTHMOUNT); + } + + //Helper macros + private boolean pre(ElementType type) + { + return MinecraftForge.EVENT_BUS.post(new RenderGameOverlayEvent.Pre(eventParent, type)); + } + private void post(ElementType type) + { + MinecraftForge.EVENT_BUS.post(new RenderGameOverlayEvent.Post(eventParent, type)); + } + private void bind(ResourceLocation res) + { + mc.getTextureManager().bindTexture(res); + } +} diff --git a/src/main/java/net/minecraftforge/client/IItemRenderer.java b/src/main/java/net/minecraftforge/client/IItemRenderer.java new file mode 100644 index 0000000..5b5b844 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/IItemRenderer.java @@ -0,0 +1,134 @@ +package net.minecraftforge.client; + +import net.minecraft.item.ItemStack; + +public interface IItemRenderer +{ + public enum ItemRenderType + { + /** + * Called to render an in-world item, e.g. one that has been thrown or + * dropped. The appropriate OpenGL transformations and scaling have already + * been applied, so Tessellator location (0,0,0) is the center of the + * EntityItem. + * + * Data parameters: + * RenderBlocks render - The RenderBlocks instance + * EntityItem entity - The in-world item to be rendered + */ + ENTITY, + + /** + * Called to render an item currently held in-hand by a living entity. If + * rendering as a 3D block, the item will be rotated to a 45-degree angle. + * To render a 2D texture with some thickness (like default items), see + * net.minecraft.src.ItemRenderer. In either case, rendering should be done + * in local coordinates from (0,0,0)-(1,1,1). + * + * Data parameters: + * RenderBlocks render - The RenderBlocks instance + * EntityLiving entity - The entity holding this item + */ + EQUIPPED, + + /** + * Called to render an item currently held in-hand by a living entity in + * first person. If rendering as a 3D block, the item will be rotated to a + * 45-degree angle. To render a 2D texture with some thickness, see + * net.minecraft.src.ItemRenderer. In either case, rendering should be done + * in local coordinates from (0,0,0)-(1,1,1). + * + * Data parameters: + * RenderBlocks render - The RenderBlocks instance + * EntityLiving entity - The entity holding this item + */ + EQUIPPED_FIRST_PERSON, + + /** + * Called to render an item in a GUI inventory slot. If rendering as a 3D + * block, the appropriate OpenGL translations and scaling have already been + * applied, and the rendering should be done in local coordinates from + * (0,0,0)-(1,1,1). If rendering as a 2D texture, the rendering should be in + * GUI pixel coordinates from (0, 0, 0)-(16, 16, 0). + * + * Data parameters: + * RenderBlocks render - The RenderBlocks instance + */ + INVENTORY, + + /** + * The render type used for when a ItemMap is rendered in first person, + * All appropriate rotations have been applied, and the player's hands, + * and the map BG are already rendered. + * + * Data Parameters: + * EntityPlayer player - The player holding the map + * RenderEngine engine - The RenderEngine instance + * MapData mapData - The map data + */ + FIRST_PERSON_MAP + } + + public enum ItemRendererHelper + { + /** + * Determines if a rotation effect should be used when rendering an + * EntityItem, like most default blocks do. + */ + ENTITY_ROTATION, + + /** + * Determines if an up-and-down bobbing effect should be used when + * rendering an EntityItem, like most default items do. + */ + ENTITY_BOBBING, + + /** + * Determines if the currently equipped item should be rendered as a 3D + * block or as a 2D texture. + */ + EQUIPPED_BLOCK, + + /** + * Determines if the item should equate to a block that has + * RenderBlocks.renderItemIn3d return true + */ + BLOCK_3D, + + /** + * Determines if the item should be rendered in GUI inventory slots as a 3D + * block or as a 2D texture. + */ + INVENTORY_BLOCK + } + + /** + * Checks if this renderer should handle a specific item's render type + * @param item The item we are trying to render + * @param type A render type to check if this renderer handles + * @return true if this renderer should handle the given render type, + * otherwise false + */ + public boolean handleRenderType(ItemStack item, ItemRenderType type); + + /** + * Checks if certain helper functionality should be executed for this renderer. + * See ItemRendererHelper for more info + * + * @param type The render type + * @param item The ItemStack being rendered + * @param helper The type of helper functionality to be ran + * @return True to run the helper functionality, false to not. + */ + public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper); + + /** + * Called to do the actual rendering, see ItemRenderType for details on when specific + * types are run, and what extra data is passed into the data parameter. + * + * @param type The render type + * @param item The ItemStack being rendered + * @param data Extra Type specific data + */ + public void renderItem(ItemRenderType type, ItemStack item, Object... data); +} diff --git a/src/main/java/net/minecraftforge/client/IRenderContextHandler.java b/src/main/java/net/minecraftforge/client/IRenderContextHandler.java new file mode 100644 index 0000000..9843220 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/IRenderContextHandler.java @@ -0,0 +1,17 @@ +/* + * This software is provided under the terms of the Minecraft Forge Public + * License v1.0. + */ +package net.minecraftforge.client; + +public interface IRenderContextHandler +{ + /** Run before the specified rendering context. + */ + public void beforeRenderContext(); + + /** Run after the specified rendering context. + */ + public void afterRenderContext(); +} + diff --git a/src/main/java/net/minecraftforge/client/IRenderHandler.java b/src/main/java/net/minecraftforge/client/IRenderHandler.java new file mode 100644 index 0000000..0429520 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/IRenderHandler.java @@ -0,0 +1,12 @@ +package net.minecraftforge.client; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.WorldClient; + +public abstract class IRenderHandler +{ + @SideOnly(Side.CLIENT) + public abstract void render(float partialTicks, WorldClient world, Minecraft mc); +} diff --git a/src/main/java/net/minecraftforge/client/MinecraftForgeClient.java b/src/main/java/net/minecraftforge/client/MinecraftForgeClient.java new file mode 100644 index 0000000..27e0adc --- /dev/null +++ b/src/main/java/net/minecraftforge/client/MinecraftForgeClient.java @@ -0,0 +1,88 @@ +/** + * This software is provided under the terms of the Minecraft Forge Public + * License v1.0. + */ + +package net.minecraftforge.client; + +import java.util.BitSet; +import java.util.IdentityHashMap; + +import com.google.common.collect.Maps; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.client.IItemRenderer.ItemRenderType; + +public class MinecraftForgeClient +{ + private static IdentityHashMap customItemRenderers = Maps.newIdentityHashMap(); + + /** + * Register a custom renderer for a specific item. This can be used to + * render the item in-world as an EntityItem, when the item is equipped, or + * when the item is in an inventory slot. + * @param itemID The item ID (shifted index) to handle rendering. + * @param renderer The IItemRenderer interface that handles rendering for + * this item. + */ + public static void registerItemRenderer(Item item, IItemRenderer renderer) + { + customItemRenderers.put(item, renderer); + } + + public static IItemRenderer getItemRenderer(ItemStack item, ItemRenderType type) + { + IItemRenderer renderer = customItemRenderers.get(item.getItem()); + if (renderer != null && renderer.handleRenderType(item, type)) + { + return renderer; + } + return null; + } + + public static int getRenderPass() + { + return ForgeHooksClient.renderPass; + } + + public static int getStencilBits() + { + return ForgeHooksClient.stencilBits; + } + + + private static BitSet stencilBits = new BitSet(getStencilBits()); + static + { + stencilBits.set(0,getStencilBits()); + } + + /** + * Reserve a stencil bit for use in rendering + * + * @return A bit or -1 if no further stencil bits are available + */ + public static int reserveStencilBit() + { + int bit = stencilBits.nextSetBit(0); + if (bit >= 0) + { + stencilBits.clear(bit); + } + return bit; + } + + /** + * Release the stencil bit for other use + * + * @param bit The bit from {@link #reserveStencilBit()} + */ + public static void releaseStencilBit(int bit) + { + if (bit >= 0 && bit < getStencilBits()) + { + stencilBits.set(bit); + } + } +} diff --git a/src/main/java/net/minecraftforge/client/event/ClientChatReceivedEvent.java b/src/main/java/net/minecraftforge/client/event/ClientChatReceivedEvent.java new file mode 100644 index 0000000..888b687 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/event/ClientChatReceivedEvent.java @@ -0,0 +1,15 @@ +package net.minecraftforge.client.event; + +import net.minecraft.util.IChatComponent; +import cpw.mods.fml.common.eventhandler.Cancelable; +import cpw.mods.fml.common.eventhandler.Event; + +@Cancelable +public class ClientChatReceivedEvent extends Event +{ + public IChatComponent message; + public ClientChatReceivedEvent(IChatComponent message) + { + this.message = message; + } +} diff --git a/src/main/java/net/minecraftforge/client/event/DrawBlockHighlightEvent.java b/src/main/java/net/minecraftforge/client/event/DrawBlockHighlightEvent.java new file mode 100644 index 0000000..b556910 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/event/DrawBlockHighlightEvent.java @@ -0,0 +1,30 @@ +package net.minecraftforge.client.event; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import cpw.mods.fml.common.eventhandler.Event; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.client.renderer.RenderGlobal; + +@Cancelable +public class DrawBlockHighlightEvent extends Event +{ + public final RenderGlobal context; + public final EntityPlayer player; + public final MovingObjectPosition target; + public final int subID; + public final ItemStack currentItem; + public final float partialTicks; + + public DrawBlockHighlightEvent(RenderGlobal context, EntityPlayer player, MovingObjectPosition target, int subID, ItemStack currentItem, float partialTicks) + { + this.context = context; + this.player = player; + this.target = target; + this.subID = subID; + this.currentItem = currentItem; + this.partialTicks= partialTicks; + } + +} diff --git a/src/main/java/net/minecraftforge/client/event/FOVUpdateEvent.java b/src/main/java/net/minecraftforge/client/event/FOVUpdateEvent.java new file mode 100644 index 0000000..b72a570 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/event/FOVUpdateEvent.java @@ -0,0 +1,22 @@ +package net.minecraftforge.client.event; + +import cpw.mods.fml.common.eventhandler.Event; +import net.minecraft.client.entity.EntityPlayerSP; + +/** + * Author: MachineMuse (Claire Semple) + * Created: 6:07 PM, 9/5/13 + */ +public class FOVUpdateEvent extends Event +{ + public final EntityPlayerSP entity; + public final float fov; + public float newfov; + + public FOVUpdateEvent(EntityPlayerSP entity, float fov) + { + this.entity = entity; + this.fov = fov; + this.newfov = fov; + } +} diff --git a/src/main/java/net/minecraftforge/client/event/GuiOpenEvent.java b/src/main/java/net/minecraftforge/client/event/GuiOpenEvent.java new file mode 100644 index 0000000..ee7da5f --- /dev/null +++ b/src/main/java/net/minecraftforge/client/event/GuiOpenEvent.java @@ -0,0 +1,22 @@ +package net.minecraftforge.client.event; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import cpw.mods.fml.common.eventhandler.Event; +import net.minecraft.client.gui.GuiScreen; + +/** + * This event is called before any Gui will open. + * If you don't want this to happen, cancel the event. + * If you want to override this Gui, simply set the gui variable to your own Gui. + * + * @author jk-5 + */ +@Cancelable +public class GuiOpenEvent extends Event +{ + public GuiScreen gui; + public GuiOpenEvent(GuiScreen gui) + { + this.gui = gui; + } +} diff --git a/src/main/java/net/minecraftforge/client/event/MouseEvent.java b/src/main/java/net/minecraftforge/client/event/MouseEvent.java new file mode 100644 index 0000000..945a240 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/event/MouseEvent.java @@ -0,0 +1,35 @@ +package net.minecraftforge.client.event; + +import org.lwjgl.input.Mouse; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import cpw.mods.fml.common.eventhandler.Event; + +/** + * Author: MachineMuse (Claire Semple) + * Created: 2:46 PM, 9/4/13 + */ +@Cancelable +public class MouseEvent extends Event +{ + public final int x; + public final int y; + public final int dx; + public final int dy; + public final int dwheel; + public final int button; + public final boolean buttonstate; + public final long nanoseconds; + + public MouseEvent() + { + this.x = Mouse.getEventX(); + this.y = Mouse.getEventY(); + this.dx = Mouse.getEventDX(); + this.dy = Mouse.getEventDY(); + this.dwheel = Mouse.getEventDWheel(); + this.button = Mouse.getEventButton(); + this.buttonstate = Mouse.getEventButtonState(); + this.nanoseconds = Mouse.getEventNanoseconds(); + } +} diff --git a/src/main/java/net/minecraftforge/client/event/RenderGameOverlayEvent.java b/src/main/java/net/minecraftforge/client/event/RenderGameOverlayEvent.java new file mode 100644 index 0000000..e083d32 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/event/RenderGameOverlayEvent.java @@ -0,0 +1,98 @@ +package net.minecraftforge.client.event; + +import java.util.ArrayList; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import cpw.mods.fml.common.eventhandler.Event; + +import net.minecraft.client.gui.ScaledResolution; + +@Cancelable +public class RenderGameOverlayEvent extends Event +{ + public static enum ElementType + { + ALL, + HELMET, + PORTAL, + CROSSHAIRS, + BOSSHEALTH, + ARMOR, + HEALTH, + FOOD, + AIR, + HOTBAR, + EXPERIENCE, + TEXT, + HEALTHMOUNT, + JUMPBAR, + CHAT, + PLAYER_LIST + } + + public final float partialTicks; + public final ScaledResolution resolution; + public final int mouseX; + public final int mouseY; + public final ElementType type; + + public RenderGameOverlayEvent(float partialTicks, ScaledResolution resolution, int mouseX, int mouseY) + { + this.partialTicks = partialTicks; + this.resolution = resolution; + this.mouseX = mouseX; + this.mouseY = mouseY; + this.type = null; + } + + private RenderGameOverlayEvent(RenderGameOverlayEvent parent, ElementType type) + { + this.partialTicks = parent.partialTicks; + this.resolution = parent.resolution; + this.mouseX = parent.mouseX; + this.mouseY = parent.mouseY; + this.type = type; + } + + public static class Pre extends RenderGameOverlayEvent + { + public Pre(RenderGameOverlayEvent parent, ElementType type) + { + super(parent, type); + } + } + + public static class Post extends RenderGameOverlayEvent + { + public Post(RenderGameOverlayEvent parent, ElementType type) + { + super(parent, type); + } + @Override public boolean isCancelable(){ return false; } + } + + public static class Text extends Pre + { + public final ArrayList left; + public final ArrayList right; + public Text(RenderGameOverlayEvent parent, ArrayList left, ArrayList right) + { + super(parent, ElementType.TEXT); + this.left = left; + this.right = right; + } + } + + public static class Chat extends Pre + { + public int posX; + public int posY; + + public Chat(RenderGameOverlayEvent parent, int posX, int posY) + { + super(parent, ElementType.CHAT); + this.posX = posX; + this.posY = posY; + } + } +} diff --git a/src/main/java/net/minecraftforge/client/event/RenderHandEvent.java b/src/main/java/net/minecraftforge/client/event/RenderHandEvent.java new file mode 100644 index 0000000..44c6807 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/event/RenderHandEvent.java @@ -0,0 +1,19 @@ +package net.minecraftforge.client.event; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import cpw.mods.fml.common.eventhandler.Event; +import net.minecraft.client.renderer.RenderGlobal; + +@Cancelable +public class RenderHandEvent extends Event +{ + public final RenderGlobal context; + public final float partialTicks; + public final int renderPass; + public RenderHandEvent(RenderGlobal context, float partialTicks, int renderPass) + { + this.context = context; + this.partialTicks = partialTicks; + this.renderPass = renderPass; + } +} diff --git a/src/main/java/net/minecraftforge/client/event/RenderLivingEvent.java b/src/main/java/net/minecraftforge/client/event/RenderLivingEvent.java new file mode 100644 index 0000000..1bbee17 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/event/RenderLivingEvent.java @@ -0,0 +1,49 @@ +package net.minecraftforge.client.event; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import cpw.mods.fml.common.eventhandler.Event; +import net.minecraft.client.renderer.entity.RendererLivingEntity; +import net.minecraft.entity.EntityLivingBase; + +public abstract class RenderLivingEvent extends Event +{ + public final EntityLivingBase entity; + public final RendererLivingEntity renderer; + public final double x; + public final double y; + public final double z; + + public RenderLivingEvent(EntityLivingBase entity, RendererLivingEntity renderer, double x, double y, double z) + { + this.entity = entity; + this.renderer = renderer; + this.x = x; + this.y = y; + this.z = z; + } + + @Cancelable + public static class Pre extends RenderLivingEvent + { + public Pre(EntityLivingBase entity, RendererLivingEntity renderer, double x, double y, double z){ super(entity, renderer, x, y, z); } + } + public static class Post extends RenderLivingEvent + { + public Post(EntityLivingBase entity, RendererLivingEntity renderer, double x, double y, double z){ super(entity, renderer, x, y, z); } + } + + public abstract static class Specials extends RenderLivingEvent + { + public Specials(EntityLivingBase entity, RendererLivingEntity renderer, double x, double y, double z){ super(entity, renderer, x, y, z); } + + @Cancelable + public static class Pre extends Specials + { + public Pre(EntityLivingBase entity, RendererLivingEntity renderer, double x, double y, double z){ super(entity, renderer, x, y, z); } + } + public static class Post extends Specials + { + public Post(EntityLivingBase entity, RendererLivingEntity renderer, double x, double y, double z){ super(entity, renderer, x, y, z); } + } + } +} diff --git a/src/main/java/net/minecraftforge/client/event/RenderPlayerEvent.java b/src/main/java/net/minecraftforge/client/event/RenderPlayerEvent.java new file mode 100644 index 0000000..fa373eb --- /dev/null +++ b/src/main/java/net/minecraftforge/client/event/RenderPlayerEvent.java @@ -0,0 +1,70 @@ +package net.minecraftforge.client.event; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import net.minecraft.client.renderer.entity.RenderPlayer; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.event.entity.player.PlayerEvent; + +public abstract class RenderPlayerEvent extends PlayerEvent +{ + public final RenderPlayer renderer; + public final float partialRenderTick; + + public RenderPlayerEvent(EntityPlayer player, RenderPlayer renderer, float partialRenderTick) + { + super(player); + this.renderer = renderer; + this.partialRenderTick = partialRenderTick; + } + + @Cancelable + public static class Pre extends RenderPlayerEvent + { + public Pre(EntityPlayer player, RenderPlayer renderer, float tick){ super(player, renderer, tick); } + } + + public static class Post extends RenderPlayerEvent + { + public Post(EntityPlayer player, RenderPlayer renderer, float tick){ super(player, renderer, tick); } + } + + public abstract static class Specials extends RenderPlayerEvent + { + public Specials(EntityPlayer player, RenderPlayer renderer, float partialTicks) + { + super(player, renderer, partialTicks); + } + + @Cancelable + public static class Pre extends Specials + { + public boolean renderHelmet = true; + public boolean renderCape = true; + public boolean renderItem = true; + public Pre(EntityPlayer player, RenderPlayer renderer, float partialTicks){ super(player, renderer, partialTicks); } + } + + public static class Post extends Specials + { + public Post(EntityPlayer player, RenderPlayer renderer, float partialTicks){ super(player, renderer, partialTicks); } + } + } + + public static class SetArmorModel extends RenderPlayerEvent + { + /** + * Setting this to any value besides -1 will result in the function being + * Immediately exited with the return value specified. + */ + public int result = -1; + public final int slot; + public final ItemStack stack; + public SetArmorModel(EntityPlayer player, RenderPlayer renderer, int slot, float partialTick, ItemStack stack) + { + super(player, renderer, partialTick); + this.slot = slot; + this.stack = stack; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/client/event/RenderWorldLastEvent.java b/src/main/java/net/minecraftforge/client/event/RenderWorldLastEvent.java new file mode 100644 index 0000000..5c47eab --- /dev/null +++ b/src/main/java/net/minecraftforge/client/event/RenderWorldLastEvent.java @@ -0,0 +1,15 @@ +package net.minecraftforge.client.event; + +import cpw.mods.fml.common.eventhandler.Event; +import net.minecraft.client.renderer.RenderGlobal; + +public class RenderWorldLastEvent extends Event +{ + public final RenderGlobal context; + public final float partialTicks; + public RenderWorldLastEvent(RenderGlobal context, float partialTicks) + { + this.context = context; + this.partialTicks = partialTicks; + } +} diff --git a/src/main/java/net/minecraftforge/client/event/TextureStitchEvent.java b/src/main/java/net/minecraftforge/client/event/TextureStitchEvent.java new file mode 100644 index 0000000..acf30c3 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/event/TextureStitchEvent.java @@ -0,0 +1,35 @@ +package net.minecraftforge.client.event; + +import cpw.mods.fml.common.eventhandler.Event; +import net.minecraft.client.renderer.texture.TextureMap; + + +public class TextureStitchEvent extends Event +{ + public final TextureMap map; + + public TextureStitchEvent(TextureMap map) + { + this.map = map; + } + + /** + * Fired when the TextureMap is told to refresh it's stitched texture. + * Called after the Stitched list is cleared, but before any blocks or items + * add themselves to the list. + */ + public static class Pre extends TextureStitchEvent + { + public Pre(TextureMap map){ super(map); } + } + + /** + * This event is fired once the texture map has loaded all textures and + * stitched them together. All Icons should have there locations defined + * by the time this is fired. + */ + public static class Post extends TextureStitchEvent + { + public Post(TextureMap map){ super(map); } + } +} diff --git a/src/main/java/net/minecraftforge/client/event/sound/PlayBackgroundMusicEvent.java b/src/main/java/net/minecraftforge/client/event/sound/PlayBackgroundMusicEvent.java new file mode 100644 index 0000000..3148e3a --- /dev/null +++ b/src/main/java/net/minecraftforge/client/event/sound/PlayBackgroundMusicEvent.java @@ -0,0 +1,16 @@ +package net.minecraftforge.client.event.sound; + +import net.minecraft.client.audio.SoundManager; +import net.minecraft.client.audio.SoundPoolEntry; + +/** + * Raised when the SoundManager tries to play a Background Music file, + * If you return null from this function it will prevent the sound from being played, + * you can return a different entry if you want to change the sound being played. + */ +@Deprecated // Remove in 1.8 +public class PlayBackgroundMusicEvent extends SoundResultEvent +{ + public PlayBackgroundMusicEvent(SoundManager manager, SoundPoolEntry entry) + { super(manager, entry, null, 0.0f, 0.0f); } +} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/client/event/sound/PlaySoundEffectEvent.java b/src/main/java/net/minecraftforge/client/event/sound/PlaySoundEffectEvent.java new file mode 100644 index 0000000..5124616 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/event/sound/PlaySoundEffectEvent.java @@ -0,0 +1,11 @@ +package net.minecraftforge.client.event.sound; + +import net.minecraft.client.audio.SoundManager; +import net.minecraft.client.audio.SoundPoolEntry; + +@Deprecated //Remove in 1.8 +public class PlaySoundEffectEvent extends SoundResultEvent +{ + public PlaySoundEffectEvent(SoundManager manager, SoundPoolEntry source, String name, float volume, float pitch) + { super(manager, source, name, volume, pitch); } +} diff --git a/src/main/java/net/minecraftforge/client/event/sound/PlaySoundEffectSourceEvent.java b/src/main/java/net/minecraftforge/client/event/sound/PlaySoundEffectSourceEvent.java new file mode 100644 index 0000000..f13132e --- /dev/null +++ b/src/main/java/net/minecraftforge/client/event/sound/PlaySoundEffectSourceEvent.java @@ -0,0 +1,16 @@ +package net.minecraftforge.client.event.sound; + +import net.minecraft.client.audio.SoundManager; + +@Deprecated //Remove in 1.8 +public class PlaySoundEffectSourceEvent extends SoundEvent +{ + public final SoundManager manager; + public final String name; + public PlaySoundEffectSourceEvent(SoundManager manager, String name) + { + super(manager); + this.manager = manager; + this.name = name; + } +} diff --git a/src/main/java/net/minecraftforge/client/event/sound/PlaySoundEvent.java b/src/main/java/net/minecraftforge/client/event/sound/PlaySoundEvent.java new file mode 100644 index 0000000..c4b2a36 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/event/sound/PlaySoundEvent.java @@ -0,0 +1,25 @@ +package net.minecraftforge.client.event.sound; + +import net.minecraft.client.audio.SoundManager; +import net.minecraft.client.audio.SoundPoolEntry; + +/*** + * Raised when the SoundManager tries to play a normal sound. + * + * If you return null from this function it will prevent the sound from being played, + * you can return a different entry if you want to change the sound being played. + */ +@Deprecated // Switch with PlaySoundEvent17 in 1.8 +public class PlaySoundEvent extends SoundResultEvent +{ + public final float x; + public final float y; + public final float z; + public PlaySoundEvent(SoundManager manager, SoundPoolEntry source, String name, float x, float y, float z, float volume, float pitch) + { + super(manager, source, name, volume, pitch); + this.x = x; + this.y = y; + this.z = z; + } +} diff --git a/src/main/java/net/minecraftforge/client/event/sound/PlaySoundEvent17.java b/src/main/java/net/minecraftforge/client/event/sound/PlaySoundEvent17.java new file mode 100644 index 0000000..abacdaa --- /dev/null +++ b/src/main/java/net/minecraftforge/client/event/sound/PlaySoundEvent17.java @@ -0,0 +1,30 @@ +package net.minecraftforge.client.event.sound; + +import net.minecraft.client.audio.ISound; +import net.minecraft.client.audio.SoundCategory; +import net.minecraft.client.audio.SoundManager; +import net.minecraft.client.audio.SoundPoolEntry; + +/*** + * Raised when the SoundManager tries to play a normal sound. + * + * If you return null from this function it will prevent the sound from being played, + * you can return a different entry if you want to change the sound being played. + */ +//TODO: Replace PlaySoundEvent in 1.8 +public class PlaySoundEvent17 extends SoundEvent +{ + public final String name; + public final ISound sound; + public final SoundCategory category; + public ISound result; + + public PlaySoundEvent17(SoundManager manager, ISound sound, SoundCategory category) + { + super(manager); + this.sound = sound; + this.category = category; + this.name = sound.getPositionedSoundLocation().getResourcePath(); + this.result = sound; + } +} diff --git a/src/main/java/net/minecraftforge/client/event/sound/PlaySoundSourceEvent.java b/src/main/java/net/minecraftforge/client/event/sound/PlaySoundSourceEvent.java new file mode 100644 index 0000000..a056e99 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/event/sound/PlaySoundSourceEvent.java @@ -0,0 +1,38 @@ +package net.minecraftforge.client.event.sound; + +import net.minecraft.client.audio.ISound; +import net.minecraft.client.audio.SoundManager; +import net.minecraftforge.client.event.sound.SoundEvent.SoundSourceEvent; + +public class PlaySoundSourceEvent extends SoundSourceEvent +{ + @Deprecated + public final SoundManager manager; + @Deprecated + public final String name; + @Deprecated + public final float x; + @Deprecated + public final float y; + @Deprecated + public final float z; + + @Deprecated + public PlaySoundSourceEvent(SoundManager manager, String name, float x, float y, float z) + { + super(manager, null, null); + this.manager = manager; + this.name = name; + this.x = x; + this.y = y; + this.z = z; + } + + public PlaySoundSourceEvent(SoundManager manager, ISound sound, String uuid) + { + super(manager, sound, uuid); + this.name = sound.getPositionedSoundLocation().getResourcePath(); + this.manager = manager; + this.x = this.y = this.z = 0; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/client/event/sound/PlayStreamingEvent.java b/src/main/java/net/minecraftforge/client/event/sound/PlayStreamingEvent.java new file mode 100644 index 0000000..1a89b26 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/event/sound/PlayStreamingEvent.java @@ -0,0 +1,27 @@ +package net.minecraftforge.client.event.sound; + +import net.minecraft.client.audio.SoundManager; +import net.minecraft.client.audio.SoundPoolEntry; + +/** + * Raised when the SoundManager tries to play a 'Streaming' file, + * in vanilla it is only the Jukebox that uses this function. + * + * If you return null from this function it will prevent the sound from being played, + * you can return a different entry if you want to change the sound being played. + * + */ +@Deprecated +public class PlayStreamingEvent extends SoundResultEvent +{ + public final float x; + public final float y; + public final float z; + public PlayStreamingEvent(SoundManager manager, SoundPoolEntry source, String name, float x, float y, float z) + { + super(manager, source, name, 0.0f, 0.0f); + this.x = x; + this.y = y; + this.z = z; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/client/event/sound/PlayStreamingSourceEvent.java b/src/main/java/net/minecraftforge/client/event/sound/PlayStreamingSourceEvent.java new file mode 100644 index 0000000..cde2aa5 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/event/sound/PlayStreamingSourceEvent.java @@ -0,0 +1,38 @@ +package net.minecraftforge.client.event.sound; + +import net.minecraft.client.audio.ISound; +import net.minecraft.client.audio.SoundManager; +import net.minecraftforge.client.event.sound.SoundEvent.SoundSourceEvent; + +public class PlayStreamingSourceEvent extends SoundSourceEvent +{ + @Deprecated + public final SoundManager manager; + @Deprecated + public final String name; + @Deprecated + public final float x; + @Deprecated + public final float y; + @Deprecated + public final float z; + + @Deprecated + public PlayStreamingSourceEvent(SoundManager manager, String name, float x, float y, float z) + { + super(manager, null, null); + this.manager = manager; + this.name = name; + this.x = x; + this.y = y; + this.z = z; + } + + public PlayStreamingSourceEvent(SoundManager manager, ISound sound, String uuid) + { + super(manager, sound, uuid); + this.x = this.y = this.z = 0; + this.manager = null; + this.name = sound.getPositionedSoundLocation().getResourcePath(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/client/event/sound/SoundEvent.java b/src/main/java/net/minecraftforge/client/event/sound/SoundEvent.java new file mode 100644 index 0000000..b1c0eb1 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/event/sound/SoundEvent.java @@ -0,0 +1,38 @@ +package net.minecraftforge.client.event.sound; + +import cpw.mods.fml.common.eventhandler.Event; +import net.minecraft.client.audio.ISound; +import net.minecraft.client.audio.SoundManager; +import net.minecraft.client.audio.SoundPoolEntry; +import net.minecraftforge.common.MinecraftForge; + +public class SoundEvent extends Event +{ + public final SoundManager manager; + public SoundEvent(SoundManager manager) + { + this.manager = manager; + } + + @Deprecated + public static SoundPoolEntry getResult(SoundResultEvent event) + { + MinecraftForge.EVENT_BUS.post(event); + return event.result; + } + + public static class SoundSourceEvent extends SoundEvent + { + public final ISound sound; + public final String uuid; + public final String name; + + public SoundSourceEvent(SoundManager manager, ISound sound, String uuid) + { + super(manager); + this.name = sound.getPositionedSoundLocation().getResourcePath(); + this.sound = sound; + this.uuid = uuid; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/client/event/sound/SoundLoadEvent.java b/src/main/java/net/minecraftforge/client/event/sound/SoundLoadEvent.java new file mode 100644 index 0000000..21ace17 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/event/sound/SoundLoadEvent.java @@ -0,0 +1,18 @@ +package net.minecraftforge.client.event.sound; + +import net.minecraft.client.audio.SoundManager; + +/** + * Raised by the SoundManager.loadSoundSettings, this would be a good place for + * adding your custom sounds to the SoundPool. + */ +public class SoundLoadEvent extends SoundEvent +{ + @Deprecated + public final SoundManager manager; + public SoundLoadEvent(SoundManager manager) + { + super(manager); + this.manager = manager; + } +} diff --git a/src/main/java/net/minecraftforge/client/event/sound/SoundResultEvent.java b/src/main/java/net/minecraftforge/client/event/sound/SoundResultEvent.java new file mode 100644 index 0000000..8eac5e4 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/event/sound/SoundResultEvent.java @@ -0,0 +1,26 @@ +package net.minecraftforge.client.event.sound; + +import net.minecraft.client.audio.SoundManager; +import net.minecraft.client.audio.SoundPoolEntry; + +@Deprecated //Remove in 1.8 +public abstract class SoundResultEvent extends SoundEvent +{ + public final SoundManager manager; + public final SoundPoolEntry source; + public final String name; + public final float volume; + public final float pitch; + public SoundPoolEntry result; + + public SoundResultEvent(SoundManager manager, SoundPoolEntry source, String name, float volume, float pitch) + { + super(manager); + this.manager = manager; + this.source = source; + this.name = name; + this.volume = volume; + this.pitch = pitch; + this.result = source; + } +} diff --git a/src/main/java/net/minecraftforge/client/event/sound/SoundSetupEvent.java b/src/main/java/net/minecraftforge/client/event/sound/SoundSetupEvent.java new file mode 100644 index 0000000..1daf788 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/event/sound/SoundSetupEvent.java @@ -0,0 +1,18 @@ +package net.minecraftforge.client.event.sound; + +import net.minecraft.client.audio.SoundManager; + +/** + * This event is raised by the SoundManager when it does its first setup of the + * SoundSystemConfig's codecs, use this function to add your own codecs. + */ +public class SoundSetupEvent extends SoundEvent +{ + @Deprecated + public final SoundManager manager; + public SoundSetupEvent(SoundManager manager) + { + super(manager); + this.manager = manager; + } +} diff --git a/src/main/java/net/minecraftforge/client/model/AdvancedModelLoader.java b/src/main/java/net/minecraftforge/client/model/AdvancedModelLoader.java new file mode 100644 index 0000000..16f5e53 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/model/AdvancedModelLoader.java @@ -0,0 +1,79 @@ +package net.minecraftforge.client.model; +// TODO: Move this package to net.minecraftforge.model in 1.8 + +import java.util.Collection; +import java.util.Map; + +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.model.obj.ObjModelLoader; +import net.minecraftforge.client.model.techne.TechneModelLoader; + +import com.google.common.collect.Maps; + +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/** + * Common interface for advanced model loading from files, based on file suffix + * Model support can be queried through the {@link #getSupportedSuffixes()} method. + * Instances can be created by calling {@link #loadModel(String)} with a class-loadable-path + * + * @author cpw + * + */ +@SideOnly(Side.CLIENT) +public class AdvancedModelLoader { + private static Map instances = Maps.newHashMap(); + + /** + * Register a new model handler + * @param modelHandler The model handler to register + */ + public static void registerModelHandler(IModelCustomLoader modelHandler) + { + for (String suffix : modelHandler.getSuffixes()) + { + instances.put(suffix, modelHandler); + } + } + + /** + * Load the model from the supplied classpath resolvable resource name + * @param resource The resource name + * @return A model + * @throws IllegalArgumentException if the resource name cannot be understood + * @throws ModelFormatException if the underlying model handler cannot parse the model format + */ + public static IModelCustom loadModel(ResourceLocation resource) throws IllegalArgumentException, ModelFormatException + { + String name = resource.getResourcePath(); + int i = name.lastIndexOf('.'); + if (i == -1) + { + FMLLog.severe("The resource name %s is not valid", resource); + throw new IllegalArgumentException("The resource name is not valid"); + } + String suffix = name.substring(i+1); + IModelCustomLoader loader = instances.get(suffix); + if (loader == null) + { + FMLLog.severe("The resource name %s is not supported", resource); + throw new IllegalArgumentException("The resource name is not supported"); + } + + return loader.loadInstance(resource); + } + + public static Collection getSupportedSuffixes() + { + return instances.keySet(); + } + + + static + { + registerModelHandler(new ObjModelLoader()); + registerModelHandler(new TechneModelLoader()); + } +} diff --git a/src/main/java/net/minecraftforge/client/model/IModelCustom.java b/src/main/java/net/minecraftforge/client/model/IModelCustom.java new file mode 100644 index 0000000..c325632 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/model/IModelCustom.java @@ -0,0 +1,17 @@ +package net.minecraftforge.client.model; + +import static cpw.mods.fml.relauncher.Side.CLIENT; +import cpw.mods.fml.relauncher.SideOnly; + +public interface IModelCustom +{ + String getType(); + @SideOnly(CLIENT) + void renderAll(); + @SideOnly(CLIENT) + void renderOnly(String... groupNames); + @SideOnly(CLIENT) + void renderPart(String partName); + @SideOnly(CLIENT) + void renderAllExcept(String... excludedGroupNames); +} diff --git a/src/main/java/net/minecraftforge/client/model/IModelCustomLoader.java b/src/main/java/net/minecraftforge/client/model/IModelCustomLoader.java new file mode 100644 index 0000000..b045228 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/model/IModelCustomLoader.java @@ -0,0 +1,29 @@ +package net.minecraftforge.client.model; + +import net.minecraft.util.ResourceLocation; + +/** + * Instances of this class act as factories for their model type + * + * @author cpw + * + */ +public interface IModelCustomLoader { + /** + * Get the main type name for this loader + * @return the type name + */ + String getType(); + /** + * Get resource suffixes this model loader recognizes + * @return a list of suffixes + */ + String[] getSuffixes(); + /** + * Load a model instance from the supplied path + * @param resource The ResourceLocation of the model + * @return A model instance + * @throws ModelFormatException if the model format is not correct + */ + IModelCustom loadInstance(ResourceLocation resource) throws ModelFormatException; +} diff --git a/src/main/java/net/minecraftforge/client/model/ModelFormatException.java b/src/main/java/net/minecraftforge/client/model/ModelFormatException.java new file mode 100644 index 0000000..abed554 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/model/ModelFormatException.java @@ -0,0 +1,33 @@ +package net.minecraftforge.client.model; + +/** + * Thrown if there is a problem parsing the model + * + * @author cpw + * + */ +public class ModelFormatException extends RuntimeException { + + private static final long serialVersionUID = 2023547503969671835L; + + public ModelFormatException() + { + super(); + } + + public ModelFormatException(String message, Throwable cause) + { + super(message, cause); + } + + public ModelFormatException(String message) + { + super(message); + } + + public ModelFormatException(Throwable cause) + { + super(cause); + } + +} diff --git a/src/main/java/net/minecraftforge/client/model/obj/Face.java b/src/main/java/net/minecraftforge/client/model/obj/Face.java new file mode 100644 index 0000000..6849b58 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/model/obj/Face.java @@ -0,0 +1,84 @@ +package net.minecraftforge.client.model.obj; + +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.Vec3; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class Face +{ + public Vertex[] vertices; + public Vertex[] vertexNormals; + public Vertex faceNormal; + public TextureCoordinate[] textureCoordinates; + + @SideOnly(Side.CLIENT) + public void addFaceForRender(Tessellator tessellator) + { + addFaceForRender(tessellator, 0.0005F); + } + + @SideOnly(Side.CLIENT) + public void addFaceForRender(Tessellator tessellator, float textureOffset) + { + if (faceNormal == null) + { + faceNormal = this.calculateFaceNormal(); + } + + tessellator.setNormal(faceNormal.x, faceNormal.y, faceNormal.z); + + float averageU = 0F; + float averageV = 0F; + + if ((textureCoordinates != null) && (textureCoordinates.length > 0)) + { + for (int i = 0; i < textureCoordinates.length; ++i) + { + averageU += textureCoordinates[i].u; + averageV += textureCoordinates[i].v; + } + + averageU = averageU / textureCoordinates.length; + averageV = averageV / textureCoordinates.length; + } + + float offsetU, offsetV; + + for (int i = 0; i < vertices.length; ++i) + { + + if ((textureCoordinates != null) && (textureCoordinates.length > 0)) + { + offsetU = textureOffset; + offsetV = textureOffset; + + if (textureCoordinates[i].u > averageU) + { + offsetU = -offsetU; + } + if (textureCoordinates[i].v > averageV) + { + offsetV = -offsetV; + } + + tessellator.addVertexWithUV(vertices[i].x, vertices[i].y, vertices[i].z, textureCoordinates[i].u + offsetU, textureCoordinates[i].v + offsetV); + } + else + { + tessellator.addVertex(vertices[i].x, vertices[i].y, vertices[i].z); + } + } + } + + public Vertex calculateFaceNormal() + { + Vec3 v1 = Vec3.createVectorHelper(vertices[1].x - vertices[0].x, vertices[1].y - vertices[0].y, vertices[1].z - vertices[0].z); + Vec3 v2 = Vec3.createVectorHelper(vertices[2].x - vertices[0].x, vertices[2].y - vertices[0].y, vertices[2].z - vertices[0].z); + Vec3 normalVector = null; + + normalVector = v1.crossProduct(v2).normalize(); + + return new Vertex((float) normalVector.xCoord, (float) normalVector.yCoord, (float) normalVector.zCoord); + } +} diff --git a/src/main/java/net/minecraftforge/client/model/obj/GroupObject.java b/src/main/java/net/minecraftforge/client/model/obj/GroupObject.java new file mode 100644 index 0000000..7cc5035 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/model/obj/GroupObject.java @@ -0,0 +1,54 @@ +package net.minecraftforge.client.model.obj; + +import java.util.ArrayList; + +import net.minecraft.client.renderer.Tessellator; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class GroupObject +{ + public String name; + public ArrayList faces = new ArrayList(); + public int glDrawingMode; + + public GroupObject() + { + this(""); + } + + public GroupObject(String name) + { + this(name, -1); + } + + public GroupObject(String name, int glDrawingMode) + { + this.name = name; + this.glDrawingMode = glDrawingMode; + } + + @SideOnly(Side.CLIENT) + public void render() + { + if (faces.size() > 0) + { + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawing(glDrawingMode); + render(tessellator); + tessellator.draw(); + } + } + + @SideOnly(Side.CLIENT) + public void render(Tessellator tessellator) + { + if (faces.size() > 0) + { + for (Face face : faces) + { + face.addFaceForRender(tessellator); + } + } + } +} diff --git a/src/main/java/net/minecraftforge/client/model/obj/ObjModelLoader.java b/src/main/java/net/minecraftforge/client/model/obj/ObjModelLoader.java new file mode 100644 index 0000000..824ed93 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/model/obj/ObjModelLoader.java @@ -0,0 +1,29 @@ +package net.minecraftforge.client.model.obj; + +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.model.IModelCustom; +import net.minecraftforge.client.model.IModelCustomLoader; +import net.minecraftforge.client.model.ModelFormatException; + +public class ObjModelLoader implements IModelCustomLoader +{ + + @Override + public String getType() + { + return "OBJ model"; + } + + private static final String[] types = { "obj" }; + @Override + public String[] getSuffixes() + { + return types; + } + + @Override + public IModelCustom loadInstance(ResourceLocation resource) throws ModelFormatException + { + return new WavefrontObject(resource); + } +} diff --git a/src/main/java/net/minecraftforge/client/model/obj/TextureCoordinate.java b/src/main/java/net/minecraftforge/client/model/obj/TextureCoordinate.java new file mode 100644 index 0000000..e8c4541 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/model/obj/TextureCoordinate.java @@ -0,0 +1,21 @@ +package net.minecraftforge.client.model.obj; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class TextureCoordinate +{ + public float u, v, w; + + public TextureCoordinate(float u, float v) + { + this(u, v, 0F); + } + + public TextureCoordinate(float u, float v, float w) + { + this.u = u; + this.v = v; + this.w = w; + } +} diff --git a/src/main/java/net/minecraftforge/client/model/obj/Vertex.java b/src/main/java/net/minecraftforge/client/model/obj/Vertex.java new file mode 100644 index 0000000..ac73c1b --- /dev/null +++ b/src/main/java/net/minecraftforge/client/model/obj/Vertex.java @@ -0,0 +1,21 @@ +package net.minecraftforge.client.model.obj; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class Vertex +{ + public float x, y, z; + + public Vertex(float x, float y) + { + this(x, y, 0F); + } + + public Vertex(float x, float y, float z) + { + this.x = x; + this.y = y; + this.z = z; + } +} diff --git a/src/main/java/net/minecraftforge/client/model/obj/WavefrontObject.java b/src/main/java/net/minecraftforge/client/model/obj/WavefrontObject.java new file mode 100644 index 0000000..d25ea21 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/model/obj/WavefrontObject.java @@ -0,0 +1,660 @@ +package net.minecraftforge.client.model.obj; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.resources.IResource; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.model.IModelCustom; +import net.minecraftforge.client.model.ModelFormatException; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/** + * Wavefront Object importer + * Based heavily off of the specifications found at http://en.wikipedia.org/wiki/Wavefront_.obj_file + */ +public class WavefrontObject implements IModelCustom +{ + private static Pattern vertexPattern = Pattern.compile("(v( (\\-){0,1}\\d+\\.\\d+){3,4} *\\n)|(v( (\\-){0,1}\\d+\\.\\d+){3,4} *$)"); + private static Pattern vertexNormalPattern = Pattern.compile("(vn( (\\-){0,1}\\d+\\.\\d+){3,4} *\\n)|(vn( (\\-){0,1}\\d+\\.\\d+){3,4} *$)"); + private static Pattern textureCoordinatePattern = Pattern.compile("(vt( (\\-){0,1}\\d+\\.\\d+){2,3} *\\n)|(vt( (\\-){0,1}\\d+\\.\\d+){2,3} *$)"); + private static Pattern face_V_VT_VN_Pattern = Pattern.compile("(f( \\d+/\\d+/\\d+){3,4} *\\n)|(f( \\d+/\\d+/\\d+){3,4} *$)"); + private static Pattern face_V_VT_Pattern = Pattern.compile("(f( \\d+/\\d+){3,4} *\\n)|(f( \\d+/\\d+){3,4} *$)"); + private static Pattern face_V_VN_Pattern = Pattern.compile("(f( \\d+//\\d+){3,4} *\\n)|(f( \\d+//\\d+){3,4} *$)"); + private static Pattern face_V_Pattern = Pattern.compile("(f( \\d+){3,4} *\\n)|(f( \\d+){3,4} *$)"); + private static Pattern groupObjectPattern = Pattern.compile("([go]( [\\w\\d]+) *\\n)|([go]( [\\w\\d]+) *$)"); + + private static Matcher vertexMatcher, vertexNormalMatcher, textureCoordinateMatcher; + private static Matcher face_V_VT_VN_Matcher, face_V_VT_Matcher, face_V_VN_Matcher, face_V_Matcher; + private static Matcher groupObjectMatcher; + + public ArrayList vertices = new ArrayList(); + public ArrayList vertexNormals = new ArrayList(); + public ArrayList textureCoordinates = new ArrayList(); + public ArrayList groupObjects = new ArrayList(); + private GroupObject currentGroupObject; + private String fileName; + + public WavefrontObject(ResourceLocation resource) throws ModelFormatException + { + this.fileName = resource.toString(); + + try + { + IResource res = Minecraft.getMinecraft().getResourceManager().getResource(resource); + loadObjModel(res.getInputStream()); + } + catch (IOException e) + { + throw new ModelFormatException("IO Exception reading model format", e); + } + } + + public WavefrontObject(String filename, InputStream inputStream) throws ModelFormatException + { + this.fileName = filename; + loadObjModel(inputStream); + } + + private void loadObjModel(InputStream inputStream) throws ModelFormatException + { + BufferedReader reader = null; + + String currentLine = null; + int lineCount = 0; + + try + { + reader = new BufferedReader(new InputStreamReader(inputStream)); + + while ((currentLine = reader.readLine()) != null) + { + lineCount++; + currentLine = currentLine.replaceAll("\\s+", " ").trim(); + + if (currentLine.startsWith("#") || currentLine.length() == 0) + { + continue; + } + else if (currentLine.startsWith("v ")) + { + Vertex vertex = parseVertex(currentLine, lineCount); + if (vertex != null) + { + vertices.add(vertex); + } + } + else if (currentLine.startsWith("vn ")) + { + Vertex vertex = parseVertexNormal(currentLine, lineCount); + if (vertex != null) + { + vertexNormals.add(vertex); + } + } + else if (currentLine.startsWith("vt ")) + { + TextureCoordinate textureCoordinate = parseTextureCoordinate(currentLine, lineCount); + if (textureCoordinate != null) + { + textureCoordinates.add(textureCoordinate); + } + } + else if (currentLine.startsWith("f ")) + { + + if (currentGroupObject == null) + { + currentGroupObject = new GroupObject("Default"); + } + + Face face = parseFace(currentLine, lineCount); + + if (face != null) + { + currentGroupObject.faces.add(face); + } + } + else if (currentLine.startsWith("g ") | currentLine.startsWith("o ")) + { + GroupObject group = parseGroupObject(currentLine, lineCount); + + if (group != null) + { + if (currentGroupObject != null) + { + groupObjects.add(currentGroupObject); + } + } + + currentGroupObject = group; + } + } + + groupObjects.add(currentGroupObject); + } + catch (IOException e) + { + throw new ModelFormatException("IO Exception reading model format", e); + } + finally + { + try + { + reader.close(); + } + catch (IOException e) + { + // hush + } + + try + { + inputStream.close(); + } + catch (IOException e) + { + // hush + } + } + } + + @Override + @SideOnly(Side.CLIENT) + public void renderAll() + { + Tessellator tessellator = Tessellator.instance; + + if (currentGroupObject != null) + { + tessellator.startDrawing(currentGroupObject.glDrawingMode); + } + else + { + tessellator.startDrawing(GL11.GL_TRIANGLES); + } + tessellateAll(tessellator); + + tessellator.draw(); + } + + @SideOnly(Side.CLIENT) + public void tessellateAll(Tessellator tessellator) + { + for (GroupObject groupObject : groupObjects) + { + groupObject.render(tessellator); + } + } + + @Override + @SideOnly(Side.CLIENT) + public void renderOnly(String... groupNames) + { + for (GroupObject groupObject : groupObjects) + { + for (String groupName : groupNames) + { + if (groupName.equalsIgnoreCase(groupObject.name)) + { + groupObject.render(); + } + } + } + } + + @SideOnly(Side.CLIENT) + public void tessellateOnly(Tessellator tessellator, String... groupNames) { + for (GroupObject groupObject : groupObjects) + { + for (String groupName : groupNames) + { + if (groupName.equalsIgnoreCase(groupObject.name)) + { + groupObject.render(tessellator); + } + } + } + } + + @Override + @SideOnly(Side.CLIENT) + public void renderPart(String partName) + { + for (GroupObject groupObject : groupObjects) + { + if (partName.equalsIgnoreCase(groupObject.name)) + { + groupObject.render(); + } + } + } + + @SideOnly(Side.CLIENT) + public void tessellatePart(Tessellator tessellator, String partName) { + for (GroupObject groupObject : groupObjects) + { + if (partName.equalsIgnoreCase(groupObject.name)) + { + groupObject.render(tessellator); + } + } + } + + @Override + @SideOnly(Side.CLIENT) + public void renderAllExcept(String... excludedGroupNames) + { + for (GroupObject groupObject : groupObjects) + { + boolean skipPart=false; + for (String excludedGroupName : excludedGroupNames) + { + if (excludedGroupName.equalsIgnoreCase(groupObject.name)) + { + skipPart=true; + } + } + if(!skipPart) + { + groupObject.render(); + } + } + } + + @SideOnly(Side.CLIENT) + public void tessellateAllExcept(Tessellator tessellator, String... excludedGroupNames) + { + boolean exclude; + for (GroupObject groupObject : groupObjects) + { + exclude=false; + for (String excludedGroupName : excludedGroupNames) + { + if (excludedGroupName.equalsIgnoreCase(groupObject.name)) + { + exclude=true; + } + } + if(!exclude) + { + groupObject.render(tessellator); + } + } + } + + private Vertex parseVertex(String line, int lineCount) throws ModelFormatException + { + Vertex vertex = null; + + if (isValidVertexLine(line)) + { + line = line.substring(line.indexOf(" ") + 1); + String[] tokens = line.split(" "); + + try + { + if (tokens.length == 2) + { + return new Vertex(Float.parseFloat(tokens[0]), Float.parseFloat(tokens[1])); + } + else if (tokens.length == 3) + { + return new Vertex(Float.parseFloat(tokens[0]), Float.parseFloat(tokens[1]), Float.parseFloat(tokens[2])); + } + } + catch (NumberFormatException e) + { + throw new ModelFormatException(String.format("Number formatting error at line %d",lineCount), e); + } + } + else + { + throw new ModelFormatException("Error parsing entry ('" + line + "'" + ", line " + lineCount + ") in file '" + fileName + "' - Incorrect format"); + } + + return vertex; + } + + private Vertex parseVertexNormal(String line, int lineCount) throws ModelFormatException + { + Vertex vertexNormal = null; + + if (isValidVertexNormalLine(line)) + { + line = line.substring(line.indexOf(" ") + 1); + String[] tokens = line.split(" "); + + try + { + if (tokens.length == 3) + return new Vertex(Float.parseFloat(tokens[0]), Float.parseFloat(tokens[1]), Float.parseFloat(tokens[2])); + } + catch (NumberFormatException e) + { + throw new ModelFormatException(String.format("Number formatting error at line %d",lineCount), e); + } + } + else + { + throw new ModelFormatException("Error parsing entry ('" + line + "'" + ", line " + lineCount + ") in file '" + fileName + "' - Incorrect format"); + } + + return vertexNormal; + } + + private TextureCoordinate parseTextureCoordinate(String line, int lineCount) throws ModelFormatException + { + TextureCoordinate textureCoordinate = null; + + if (isValidTextureCoordinateLine(line)) + { + line = line.substring(line.indexOf(" ") + 1); + String[] tokens = line.split(" "); + + try + { + if (tokens.length == 2) + return new TextureCoordinate(Float.parseFloat(tokens[0]), 1 - Float.parseFloat(tokens[1])); + else if (tokens.length == 3) + return new TextureCoordinate(Float.parseFloat(tokens[0]), 1 - Float.parseFloat(tokens[1]), Float.parseFloat(tokens[2])); + } + catch (NumberFormatException e) + { + throw new ModelFormatException(String.format("Number formatting error at line %d",lineCount), e); + } + } + else + { + throw new ModelFormatException("Error parsing entry ('" + line + "'" + ", line " + lineCount + ") in file '" + fileName + "' - Incorrect format"); + } + + return textureCoordinate; + } + + private Face parseFace(String line, int lineCount) throws ModelFormatException + { + Face face = null; + + if (isValidFaceLine(line)) + { + face = new Face(); + + String trimmedLine = line.substring(line.indexOf(" ") + 1); + String[] tokens = trimmedLine.split(" "); + String[] subTokens = null; + + if (tokens.length == 3) + { + if (currentGroupObject.glDrawingMode == -1) + { + currentGroupObject.glDrawingMode = GL11.GL_TRIANGLES; + } + else if (currentGroupObject.glDrawingMode != GL11.GL_TRIANGLES) + { + throw new ModelFormatException("Error parsing entry ('" + line + "'" + ", line " + lineCount + ") in file '" + fileName + "' - Invalid number of points for face (expected 4, found " + tokens.length + ")"); + } + } + else if (tokens.length == 4) + { + if (currentGroupObject.glDrawingMode == -1) + { + currentGroupObject.glDrawingMode = GL11.GL_QUADS; + } + else if (currentGroupObject.glDrawingMode != GL11.GL_QUADS) + { + throw new ModelFormatException("Error parsing entry ('" + line + "'" + ", line " + lineCount + ") in file '" + fileName + "' - Invalid number of points for face (expected 3, found " + tokens.length + ")"); + } + } + + // f v1/vt1/vn1 v2/vt2/vn2 v3/vt3/vn3 ... + if (isValidFace_V_VT_VN_Line(line)) + { + face.vertices = new Vertex[tokens.length]; + face.textureCoordinates = new TextureCoordinate[tokens.length]; + face.vertexNormals = new Vertex[tokens.length]; + + for (int i = 0; i < tokens.length; ++i) + { + subTokens = tokens[i].split("/"); + + face.vertices[i] = vertices.get(Integer.parseInt(subTokens[0]) - 1); + face.textureCoordinates[i] = textureCoordinates.get(Integer.parseInt(subTokens[1]) - 1); + face.vertexNormals[i] = vertexNormals.get(Integer.parseInt(subTokens[2]) - 1); + } + + face.faceNormal = face.calculateFaceNormal(); + } + // f v1/vt1 v2/vt2 v3/vt3 ... + else if (isValidFace_V_VT_Line(line)) + { + face.vertices = new Vertex[tokens.length]; + face.textureCoordinates = new TextureCoordinate[tokens.length]; + + for (int i = 0; i < tokens.length; ++i) + { + subTokens = tokens[i].split("/"); + + face.vertices[i] = vertices.get(Integer.parseInt(subTokens[0]) - 1); + face.textureCoordinates[i] = textureCoordinates.get(Integer.parseInt(subTokens[1]) - 1); + } + + face.faceNormal = face.calculateFaceNormal(); + } + // f v1//vn1 v2//vn2 v3//vn3 ... + else if (isValidFace_V_VN_Line(line)) + { + face.vertices = new Vertex[tokens.length]; + face.vertexNormals = new Vertex[tokens.length]; + + for (int i = 0; i < tokens.length; ++i) + { + subTokens = tokens[i].split("//"); + + face.vertices[i] = vertices.get(Integer.parseInt(subTokens[0]) - 1); + face.vertexNormals[i] = vertexNormals.get(Integer.parseInt(subTokens[1]) - 1); + } + + face.faceNormal = face.calculateFaceNormal(); + } + // f v1 v2 v3 ... + else if (isValidFace_V_Line(line)) + { + face.vertices = new Vertex[tokens.length]; + + for (int i = 0; i < tokens.length; ++i) + { + face.vertices[i] = vertices.get(Integer.parseInt(tokens[i]) - 1); + } + + face.faceNormal = face.calculateFaceNormal(); + } + else + { + throw new ModelFormatException("Error parsing entry ('" + line + "'" + ", line " + lineCount + ") in file '" + fileName + "' - Incorrect format"); + } + } + else + { + throw new ModelFormatException("Error parsing entry ('" + line + "'" + ", line " + lineCount + ") in file '" + fileName + "' - Incorrect format"); + } + + return face; + } + + private GroupObject parseGroupObject(String line, int lineCount) throws ModelFormatException + { + GroupObject group = null; + + if (isValidGroupObjectLine(line)) + { + String trimmedLine = line.substring(line.indexOf(" ") + 1); + + if (trimmedLine.length() > 0) + { + group = new GroupObject(trimmedLine); + } + } + else + { + throw new ModelFormatException("Error parsing entry ('" + line + "'" + ", line " + lineCount + ") in file '" + fileName + "' - Incorrect format"); + } + + return group; + } + + /*** + * Verifies that the given line from the model file is a valid vertex + * @param line the line being validated + * @return true if the line is a valid vertex, false otherwise + */ + private static boolean isValidVertexLine(String line) + { + if (vertexMatcher != null) + { + vertexMatcher.reset(); + } + + vertexMatcher = vertexPattern.matcher(line); + return vertexMatcher.matches(); + } + + /*** + * Verifies that the given line from the model file is a valid vertex normal + * @param line the line being validated + * @return true if the line is a valid vertex normal, false otherwise + */ + private static boolean isValidVertexNormalLine(String line) + { + if (vertexNormalMatcher != null) + { + vertexNormalMatcher.reset(); + } + + vertexNormalMatcher = vertexNormalPattern.matcher(line); + return vertexNormalMatcher.matches(); + } + + /*** + * Verifies that the given line from the model file is a valid texture coordinate + * @param line the line being validated + * @return true if the line is a valid texture coordinate, false otherwise + */ + private static boolean isValidTextureCoordinateLine(String line) + { + if (textureCoordinateMatcher != null) + { + textureCoordinateMatcher.reset(); + } + + textureCoordinateMatcher = textureCoordinatePattern.matcher(line); + return textureCoordinateMatcher.matches(); + } + + /*** + * Verifies that the given line from the model file is a valid face that is described by vertices, texture coordinates, and vertex normals + * @param line the line being validated + * @return true if the line is a valid face that matches the format "f v1/vt1/vn1 ..." (with a minimum of 3 points in the face, and a maximum of 4), false otherwise + */ + private static boolean isValidFace_V_VT_VN_Line(String line) + { + if (face_V_VT_VN_Matcher != null) + { + face_V_VT_VN_Matcher.reset(); + } + + face_V_VT_VN_Matcher = face_V_VT_VN_Pattern.matcher(line); + return face_V_VT_VN_Matcher.matches(); + } + + /*** + * Verifies that the given line from the model file is a valid face that is described by vertices and texture coordinates + * @param line the line being validated + * @return true if the line is a valid face that matches the format "f v1/vt1 ..." (with a minimum of 3 points in the face, and a maximum of 4), false otherwise + */ + private static boolean isValidFace_V_VT_Line(String line) + { + if (face_V_VT_Matcher != null) + { + face_V_VT_Matcher.reset(); + } + + face_V_VT_Matcher = face_V_VT_Pattern.matcher(line); + return face_V_VT_Matcher.matches(); + } + + /*** + * Verifies that the given line from the model file is a valid face that is described by vertices and vertex normals + * @param line the line being validated + * @return true if the line is a valid face that matches the format "f v1//vn1 ..." (with a minimum of 3 points in the face, and a maximum of 4), false otherwise + */ + private static boolean isValidFace_V_VN_Line(String line) + { + if (face_V_VN_Matcher != null) + { + face_V_VN_Matcher.reset(); + } + + face_V_VN_Matcher = face_V_VN_Pattern.matcher(line); + return face_V_VN_Matcher.matches(); + } + + /*** + * Verifies that the given line from the model file is a valid face that is described by only vertices + * @param line the line being validated + * @return true if the line is a valid face that matches the format "f v1 ..." (with a minimum of 3 points in the face, and a maximum of 4), false otherwise + */ + private static boolean isValidFace_V_Line(String line) + { + if (face_V_Matcher != null) + { + face_V_Matcher.reset(); + } + + face_V_Matcher = face_V_Pattern.matcher(line); + return face_V_Matcher.matches(); + } + + /*** + * Verifies that the given line from the model file is a valid face of any of the possible face formats + * @param line the line being validated + * @return true if the line is a valid face that matches any of the valid face formats, false otherwise + */ + private static boolean isValidFaceLine(String line) + { + return isValidFace_V_VT_VN_Line(line) || isValidFace_V_VT_Line(line) || isValidFace_V_VN_Line(line) || isValidFace_V_Line(line); + } + + /*** + * Verifies that the given line from the model file is a valid group (or object) + * @param line the line being validated + * @return true if the line is a valid group (or object), false otherwise + */ + private static boolean isValidGroupObjectLine(String line) + { + if (groupObjectMatcher != null) + { + groupObjectMatcher.reset(); + } + + groupObjectMatcher = groupObjectPattern.matcher(line); + return groupObjectMatcher.matches(); + } + + @Override + public String getType() + { + return "obj"; + } +} diff --git a/src/main/java/net/minecraftforge/client/model/techne/TechneModel.java b/src/main/java/net/minecraftforge/client/model/techne/TechneModel.java new file mode 100644 index 0000000..ec3a010 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/model/techne/TechneModel.java @@ -0,0 +1,365 @@ +package net.minecraftforge.client.model.techne; + +import java.awt.Dimension; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Arrays; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.zip.ZipEntry; +import java.util.zip.ZipException; +import java.util.zip.ZipInputStream; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + +import org.w3c.dom.Document; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; + +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.Minecraft; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.client.resources.IResource; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.model.IModelCustom; +import net.minecraftforge.client.model.ModelFormatException; + +/** + * Techne model importer, based on iChun's Hats importer + */ +@SideOnly(Side.CLIENT) +public class TechneModel extends ModelBase implements IModelCustom { + public static final List cubeTypes = Arrays.asList( + "d9e621f7-957f-4b77-b1ae-20dcd0da7751", + "de81aa14-bd60-4228-8d8d-5238bcd3caaa" + ); + + private String fileName; + private Map zipContents = new HashMap(); + + private Map parts = new LinkedHashMap(); + private String texture = null; + private Dimension textureDims = null; + private int textureName; + private boolean textureNameSet = false; + + public TechneModel(ResourceLocation resource) throws ModelFormatException + { + this.fileName = resource.toString(); + + try + { + IResource res = Minecraft.getMinecraft().getResourceManager().getResource(resource); + loadTechneModel(res.getInputStream()); + } + catch (IOException e) + { + throw new ModelFormatException("IO Exception reading model format", e); + } + } + + private void loadTechneModel(InputStream stream) throws ModelFormatException + { + try + { + ZipInputStream zipInput = new ZipInputStream(stream); + + ZipEntry entry; + while ((entry = zipInput.getNextEntry()) != null) + { + byte[] data = new byte[(int) entry.getSize()]; + // For some reason, using read(byte[]) makes reading stall upon reaching a 0x1E byte + int i = 0; + while (zipInput.available() > 0 && i < data.length) + { + data[i++] = (byte)zipInput.read(); + } + zipContents.put(entry.getName(), data); + } + + byte[] modelXml = zipContents.get("model.xml"); + if (modelXml == null) + { + throw new ModelFormatException("Model " + fileName + " contains no model.xml file"); + } + + DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); + Document document = documentBuilder.parse(new ByteArrayInputStream(modelXml)); + + NodeList nodeListTechne = document.getElementsByTagName("Techne"); + if (nodeListTechne.getLength() < 1) + { + throw new ModelFormatException("Model " + fileName + " contains no Techne tag"); + } + + NodeList nodeListModel = document.getElementsByTagName("Model"); + if (nodeListModel.getLength() < 1) + { + throw new ModelFormatException("Model " + fileName + " contains no Model tag"); + } + + NamedNodeMap modelAttributes = nodeListModel.item(0).getAttributes(); + if (modelAttributes == null) + { + throw new ModelFormatException("Model " + fileName + " contains a Model tag with no attributes"); + } + + Node modelTexture = modelAttributes.getNamedItem("texture"); + if (modelTexture != null) + { + texture = modelTexture.getTextContent(); + } + + NodeList textureDim = document.getElementsByTagName("TextureSize"); + if (textureDim.getLength() > 0) + { + try + { + String[] tmp = textureDim.item(0).getTextContent().split(","); + if (tmp.length == 2) + { + this.textureDims = new Dimension(Integer.parseInt(tmp[0]), Integer.parseInt(tmp[1])); + } + } + catch (NumberFormatException e) + { + throw new ModelFormatException("Model " + fileName + " contains a TextureSize tag with invalid data"); + } + } + + NodeList shapes = document.getElementsByTagName("Shape"); + for (int i = 0; i < shapes.getLength(); i++) + { + Node shape = shapes.item(i); + NamedNodeMap shapeAttributes = shape.getAttributes(); + if (shapeAttributes == null) + { + throw new ModelFormatException("Shape #" + (i + 1) + " in " + fileName + " has no attributes"); + } + + Node name = shapeAttributes.getNamedItem("name"); + String shapeName = null; + if (name != null) + { + shapeName = name.getNodeValue(); + } + if (shapeName == null) + { + shapeName = "Shape #" + (i + 1); + } + + String shapeType = null; + Node type = shapeAttributes.getNamedItem("type"); + if (type != null) + { + shapeType = type.getNodeValue(); + } + if (shapeType != null && !cubeTypes.contains(shapeType)) + { + FMLLog.warning("Model shape [" + shapeName + "] in " + fileName + " is not a cube, ignoring"); + continue; + } + + try + { + boolean mirrored = false; + String[] offset = new String[3]; + String[] position = new String[3]; + String[] rotation = new String[3]; + String[] size = new String[3]; + String[] textureOffset = new String[2]; + + NodeList shapeChildren = shape.getChildNodes(); + for (int j = 0; j < shapeChildren.getLength(); j++) + { + Node shapeChild = shapeChildren.item(j); + + String shapeChildName = shapeChild.getNodeName(); + String shapeChildValue = shapeChild.getTextContent(); + if (shapeChildValue != null) + { + shapeChildValue = shapeChildValue.trim(); + + if (shapeChildName.equals("IsMirrored")) + { + mirrored = !shapeChildValue.equals("False"); + } + else if (shapeChildName.equals("Offset")) + { + offset = shapeChildValue.split(","); + } + else if (shapeChildName.equals("Position")) + { + position = shapeChildValue.split(","); + } + else if (shapeChildName.equals("Rotation")) + { + rotation = shapeChildValue.split(","); + } + else if (shapeChildName.equals("Size")) + { + size = shapeChildValue.split(","); + } + else if (shapeChildName.equals("TextureOffset")) + { + textureOffset = shapeChildValue.split(","); + } + } + } + + // That's what the ModelBase subclassing is needed for + ModelRenderer cube = new ModelRenderer(this, Integer.parseInt(textureOffset[0]), Integer.parseInt(textureOffset[1])); + cube.mirror = mirrored; + cube.addBox(Float.parseFloat(offset[0]), Float.parseFloat(offset[1]), Float.parseFloat(offset[2]), Integer.parseInt(size[0]), Integer.parseInt(size[1]), Integer.parseInt(size[2])); + cube.setRotationPoint(Float.parseFloat(position[0]), Float.parseFloat(position[1]) - 23.4F, Float.parseFloat(position[2])); + + cube.rotateAngleX = (float)Math.toRadians(Float.parseFloat(rotation[0])); + cube.rotateAngleY = (float)Math.toRadians(Float.parseFloat(rotation[1])); + cube.rotateAngleZ = (float)Math.toRadians(Float.parseFloat(rotation[2])); + + if (this.textureDims != null) + { + cube.setTextureSize((int)textureDims.getWidth(), (int)textureDims.getHeight()); + } + + parts.put(shapeName, cube); + } + catch (NumberFormatException e) + { + FMLLog.warning("Model shape [" + shapeName + "] in " + fileName + " contains malformed integers within its data, ignoring"); + e.printStackTrace(); + } + } + } + catch (ZipException e) + { + throw new ModelFormatException("Model " + fileName + " is not a valid zip file"); + } + catch (IOException e) + { + throw new ModelFormatException("Model " + fileName + " could not be read", e); + } + catch (ParserConfigurationException e) + { + // hush + } + catch (SAXException e) + { + throw new ModelFormatException("Model " + fileName + " contains invalid XML", e); + } + } + + private void bindTexture() + { + /* TODO: Update to 1.6 + if (texture != null) + { + if (!textureNameSet) + { + try + { + byte[] textureEntry = zipContents.get(texture); + if (textureEntry == null) + { + throw new ModelFormatException("Model " + fileName + " has no such texture " + texture); + } + + BufferedImage image = ImageIO.read(new ByteArrayInputStream(textureEntry)); + textureName = Minecraft.getMinecraft().renderEngine.allocateAndSetupTexture(image); + textureNameSet = true; + } + catch (ZipException e) + { + throw new ModelFormatException("Model " + fileName + " is not a valid zip file"); + } + catch (IOException e) + { + throw new ModelFormatException("Texture for model " + fileName + " could not be read", e); + } + } + + if (textureNameSet) + { + GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureName); + Minecraft.getMinecraft().renderEngine.resetBoundTexture(); + } + } + */ + } + + @Override + public String getType() + { + return "tcn"; + } + + @Override + public void renderAll() + { + bindTexture(); + + for (ModelRenderer part : parts.values()) + { + part.renderWithRotation(1.0F); + } + } + + @Override + public void renderPart(String partName) + { + ModelRenderer part = parts.get(partName); + if (part != null) + { + bindTexture(); + + part.renderWithRotation(1.0F); + } + } + + @Override + public void renderOnly(String... groupNames) + { + bindTexture(); + for (ModelRenderer part : parts.values()) + { + for (String groupName : groupNames) + { + if (groupName.equalsIgnoreCase(part.boxName)) + { + part.render(1.0f); + } + } + } + } + + @Override + public void renderAllExcept(String... excludedGroupNames) + { + for (ModelRenderer part : parts.values()) + { + boolean skipPart=false; + for (String excludedGroupName : excludedGroupNames) + { + if (excludedGroupName.equalsIgnoreCase(part.boxName)) + { + skipPart=true; + } + } + if(!skipPart) + { + part.render(1.0f); + } + } + } +} diff --git a/src/main/java/net/minecraftforge/client/model/techne/TechneModelLoader.java b/src/main/java/net/minecraftforge/client/model/techne/TechneModelLoader.java new file mode 100644 index 0000000..d5c830c --- /dev/null +++ b/src/main/java/net/minecraftforge/client/model/techne/TechneModelLoader.java @@ -0,0 +1,29 @@ +package net.minecraftforge.client.model.techne; + +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.model.IModelCustom; +import net.minecraftforge.client.model.IModelCustomLoader; +import net.minecraftforge.client.model.ModelFormatException; + +public class TechneModelLoader implements IModelCustomLoader { + + @Override + public String getType() + { + return "Techne model"; + } + + private static final String[] types = { "tcn" }; + @Override + public String[] getSuffixes() + { + return types; + } + + @Override + public IModelCustom loadInstance(ResourceLocation resource) throws ModelFormatException + { + return new TechneModel(resource); + } + +} diff --git a/src/main/java/net/minecraftforge/common/AchievementPage.java b/src/main/java/net/minecraftforge/common/AchievementPage.java new file mode 100644 index 0000000..dccb74a --- /dev/null +++ b/src/main/java/net/minecraftforge/common/AchievementPage.java @@ -0,0 +1,108 @@ +/** + * This software is provided under the terms of the Minecraft Forge Public + * License v1.0. + */ + +package net.minecraftforge.common; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; + +import net.minecraft.stats.Achievement; + +public class AchievementPage +{ + private String name; + private LinkedList achievements; + + public AchievementPage(String name, Achievement... achievements) + { + this.name = name; + this.achievements = new LinkedList(Arrays.asList(achievements)); + } + + public String getName() + { + return name; + } + + public List getAchievements() + { + return achievements; + } + + private static LinkedList achievementPages = new LinkedList(); + + /** + * Registers an achievement page. + * @param page The page. + */ + public static void registerAchievementPage(AchievementPage page) + { + if (getAchievementPage(page.getName()) != null) + { + throw new RuntimeException("Duplicate achievement page name \"" + page.getName() + "\"!"); + } + achievementPages.add(page); + } + + /** + * Will return an achievement page by its index on the list. + * @param index The page's index. + * @return the achievement page corresponding to the index or null if invalid index + */ + public static AchievementPage getAchievementPage(int index) + { + return achievementPages.get(index); + } + + /** + * Will return an achievement page by its name. + * @param name The page's name. + * @return the achievement page with the given name or null if no such page + */ + public static AchievementPage getAchievementPage(String name) + { + for (AchievementPage page : achievementPages) + { + if (page.getName().equals(name)) + { + return page; + } + } + return null; + } + + /** + * Will return the list of achievement pages. + * @return the list's size + */ + public static Set getAchievementPages() + { + return new HashSet(achievementPages); + } + + /** + * Will return whether an achievement is in any page or not. + * @param achievement The achievement. + */ + public static boolean isAchievementInPages(Achievement achievement) + { + for (AchievementPage page : achievementPages) + { + if (page.getAchievements().contains(achievement)) + { + return true; + } + } + return false; + } + + public static String getTitle(int index) + { + return index == -1 ? "Minecraft" : getAchievementPage(index).getName(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/common/BiomeDictionary.java b/src/main/java/net/minecraftforge/common/BiomeDictionary.java new file mode 100644 index 0000000..ade9eb4 --- /dev/null +++ b/src/main/java/net/minecraftforge/common/BiomeDictionary.java @@ -0,0 +1,320 @@ +package net.minecraftforge.common; + +import java.util.*; + +import cpw.mods.fml.common.FMLLog; +import net.minecraft.world.biome.*; +import net.minecraftforge.event.terraingen.DeferredBiomeDecorator; +import static net.minecraft.world.biome.BiomeGenBase.*; +import static net.minecraftforge.common.BiomeDictionary.Type.*; + +public class BiomeDictionary +{ + public enum Type + { + FOREST, + PLAINS, + MOUNTAIN, + HILLS, + SWAMP, + WATER, + DESERT, + FROZEN, + JUNGLE, + WASTELAND, + BEACH, + NETHER, + END, + MUSHROOM, + MAGICAL; + } + + private static final int BIOME_LIST_SIZE = BiomeGenBase.getBiomeGenArray().length; + private static BiomeInfo[] biomeList = new BiomeInfo[BIOME_LIST_SIZE]; + @SuppressWarnings("unchecked") + private static ArrayList[] typeInfoList = new ArrayList[Type.values().length]; + + private static class BiomeInfo + { + public EnumSet typeList; + + public BiomeInfo(Type[] types) + { + typeList = EnumSet.noneOf(Type.class); + for(Type t : types) + { + typeList.add(t); + } + } + } + + static + { + registerVanillaBiomes(); + } + + /** + * Registers a biome with a specific biome type + * + * @param biome the biome to be registered + * @param type the type to register the biome as + * @return returns true if the biome was registered successfully + */ + public static boolean registerBiomeType(BiomeGenBase biome, Type ... types) + { + if(BiomeGenBase.getBiomeGenArray()[biome.biomeID] != null) + { + for(Type type : types) + { + if(typeInfoList[type.ordinal()] == null) + { + typeInfoList[type.ordinal()] = new ArrayList(); + } + + typeInfoList[type.ordinal()].add(biome); + } + + if(biomeList[biome.biomeID] == null) + { + biomeList[biome.biomeID] = new BiomeInfo(types); + } + else + { + for(Type type : types) + { + biomeList[biome.biomeID].typeList.add(type); + } + } + + return true; + } + + return false; + } + + /** + * Returns a list of biomes registered with a specific type + * + * @param type the Type to look for + * @return a list of biomes of the specified type, null if there are none + */ + public static BiomeGenBase[] getBiomesForType(Type type) + { + if(typeInfoList[type.ordinal()] != null) + { + return (BiomeGenBase[])typeInfoList[type.ordinal()].toArray(new BiomeGenBase[0]); + } + + return new BiomeGenBase[0]; + } + + /** + * Gets a list of Types that a specific biome is registered with + * + * @param biome the biome to check + * @return the list of types, null if there are none + */ + public static Type[] getTypesForBiome(BiomeGenBase biome) + { + checkRegistration(biome); + + if(biomeList[biome.biomeID] != null) + { + return (Type[])biomeList[biome.biomeID].typeList.toArray(new Type[0]); + } + + return new Type[0]; + } + + /** + * Checks to see if two biomes are registered as having the same type + * + * @param biomeA + * @param biomeB + * @return returns true if a common type is found, false otherwise + */ + public static boolean areBiomesEquivalent(BiomeGenBase biomeA, BiomeGenBase biomeB) + { + int a = biomeA.biomeID; + int b = biomeB.biomeID; + + checkRegistration(biomeA); + checkRegistration(biomeB); + + if(biomeList[a] != null && biomeList[b] != null) + { + for(Type type : biomeList[a].typeList) + { + if(containsType(biomeList[b], type)) + { + return true; + } + } + } + + return false; + } + + /** + * Checks to see if the given biome is registered as being a specific type + * + * @param biome the biome to be considered + * @param type the type to check for + * @return returns true if the biome is registered as being of type type, false otherwise + */ + public static boolean isBiomeOfType(BiomeGenBase biome, Type type) + { + checkRegistration(biome); + + if(biomeList[biome.biomeID] != null) + { + return containsType(biomeList[biome.biomeID], type); + } + + return false; + } + + /** + * Checks to see if the given biome has been registered as being of any type + * @param biome the biome to consider + * @return returns true if the biome has been registered, false otherwise + */ + public static boolean isBiomeRegistered(BiomeGenBase biome) + { + return biomeList[biome.biomeID] != null; + } + + public static boolean isBiomeRegistered(int biomeID) + { + return biomeList[biomeID] != null; + } + + public static void registerAllBiomes() + { + FMLLog.warning("Redundant call to BiomeDictionary.registerAllBiomes ignored"); + } + /** + * Loops through the biome list and automatically adds tags to any biome that does not have any + * This is called by Forge at postinit time. It will additionally dispatch any deferred decorator + * creation events. + * + * DO NOT call this during world generation + */ + public static void registerAllBiomesAndGenerateEvents() + { + for(int i = 0; i < BiomeGenBase.getBiomeGenArray().length; i++) + { + BiomeGenBase biome = BiomeGenBase.getBiomeGenArray()[i]; + + if(biome == null) + { + continue; + } + + if (biome.theBiomeDecorator instanceof DeferredBiomeDecorator) + { + DeferredBiomeDecorator decorator = (DeferredBiomeDecorator) biome.theBiomeDecorator; + decorator.fireCreateEventAndReplace(biome); + } + + checkRegistration(biome); + } + } + + /** + * Automatically looks for and registers a given biome with appropriate tags + * This method is called automatically if a biome has not been registered with any tags, + * And another method requests information about it + * + * NOTE: You can opt out of having your biome registered by registering it as type NULL + * + * @param biome the biome to be considered + */ + public static void makeBestGuess(BiomeGenBase biome) + { + if(biome.theBiomeDecorator.treesPerChunk >= 3) + { + if(biome.isHighHumidity() && biome.temperature >= 1.0F) + { + BiomeDictionary.registerBiomeType(biome, JUNGLE); + } + else if(!biome.isHighHumidity()) + { + BiomeDictionary.registerBiomeType(biome, FOREST); + } + } + else if(biome.heightVariation <= 0.3F && biome.heightVariation >= 0.0F) + { + if(!biome.isHighHumidity() || biome.rootHeight >= 0.0F) + { + BiomeDictionary.registerBiomeType(biome, PLAINS); + } + } + + if(biome.isHighHumidity() && biome.rootHeight < 0.0F && (biome.heightVariation <= 0.3F && biome.heightVariation >= 0.0F)) + { + BiomeDictionary.registerBiomeType(biome, SWAMP); + } + + if(biome.rootHeight <= -0.5F) + { + BiomeDictionary.registerBiomeType(biome, WATER); + } + + if(biome.heightVariation >= 1.5F) + { + BiomeDictionary.registerBiomeType(biome, MOUNTAIN); + } + + if(biome.getEnableSnow() || biome.temperature < 0.2F) + { + BiomeDictionary.registerBiomeType(biome, FROZEN); + } + + if(!biome.isHighHumidity() && biome.temperature >= 1.0F) + { + BiomeDictionary.registerBiomeType(biome, DESERT); + } + } + + //Internal implementation + private static void checkRegistration(BiomeGenBase biome) + { + if(!isBiomeRegistered(biome)) + { + makeBestGuess(biome); + } + } + + private static boolean containsType(BiomeInfo info, Type type) + { + return info.typeList.contains(type); + } + + private static void registerVanillaBiomes() + { + registerBiomeType(ocean, WATER ); + registerBiomeType(plains, PLAINS ); + registerBiomeType(desert, DESERT ); + registerBiomeType(extremeHills, MOUNTAIN ); + registerBiomeType(forest, FOREST ); + registerBiomeType(taiga, FOREST, FROZEN); + registerBiomeType(taigaHills, FOREST, FROZEN); + registerBiomeType(swampland, SWAMP ); + registerBiomeType(river, WATER ); + registerBiomeType(frozenOcean, WATER, FROZEN); + registerBiomeType(frozenRiver, WATER, FROZEN); + registerBiomeType(icePlains, FROZEN ); + registerBiomeType(iceMountains, FROZEN ); + registerBiomeType(beach, BEACH ); + registerBiomeType(desertHills, DESERT ); + registerBiomeType(jungle, JUNGLE ); + registerBiomeType(jungleHills, JUNGLE ); + registerBiomeType(forestHills, FOREST ); + registerBiomeType(sky, END ); + registerBiomeType(hell, NETHER ); + registerBiomeType(mushroomIsland, MUSHROOM ); + registerBiomeType(extremeHillsEdge, MOUNTAIN ); + registerBiomeType(mushroomIslandShore, MUSHROOM, BEACH); + } +} diff --git a/src/main/java/net/minecraftforge/common/BiomeManager.java b/src/main/java/net/minecraftforge/common/BiomeManager.java new file mode 100644 index 0000000..b88c20c --- /dev/null +++ b/src/main/java/net/minecraftforge/common/BiomeManager.java @@ -0,0 +1,67 @@ +package net.minecraftforge.common; + +import java.util.ArrayList; + +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.gen.structure.MapGenVillage; +import net.minecraft.world.biome.WorldChunkManager; + +public class BiomeManager +{ + public static ArrayList strongHoldBiomes = new ArrayList(); + public static ArrayList strongHoldBiomesBlackList = new ArrayList(); + + @SuppressWarnings("unchecked") + public static void addVillageBiome(BiomeGenBase biome, boolean canSpawn) + { + if (!MapGenVillage.villageSpawnBiomes.contains(biome)) + { + ArrayList biomes = new ArrayList(MapGenVillage.villageSpawnBiomes); + biomes.add(biome); + MapGenVillage.villageSpawnBiomes = biomes; + } + } + + @SuppressWarnings("unchecked") + public static void removeVillageBiome(BiomeGenBase biome) + { + if (MapGenVillage.villageSpawnBiomes.contains(biome)) + { + ArrayList biomes = new ArrayList(MapGenVillage.villageSpawnBiomes); + biomes.remove(biome); + MapGenVillage.villageSpawnBiomes = biomes; + } + } + + public static void addStrongholdBiome(BiomeGenBase biome) + { + if (!strongHoldBiomes.contains(biome)) + { + strongHoldBiomes.add(biome); + } + } + + public static void removeStrongholdBiome(BiomeGenBase biome) + { + if (!strongHoldBiomesBlackList.contains(biome)) + { + strongHoldBiomesBlackList.add(biome); + } + } + + public static void addSpawnBiome(BiomeGenBase biome) + { + if (!WorldChunkManager.allowedBiomes.contains(biome)) + { + WorldChunkManager.allowedBiomes.add(biome); + } + } + + public static void removeSpawnBiome(BiomeGenBase biome) + { + if (WorldChunkManager.allowedBiomes.contains(biome)) + { + WorldChunkManager.allowedBiomes.remove(biome); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/common/ChestGenHooks.java b/src/main/java/net/minecraftforge/common/ChestGenHooks.java new file mode 100644 index 0000000..d32fe3b --- /dev/null +++ b/src/main/java/net/minecraftforge/common/ChestGenHooks.java @@ -0,0 +1,250 @@ +package net.minecraftforge.common; + +import java.util.*; + +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.WeightedRandom; +import net.minecraft.util.WeightedRandomChestContent; +import net.minecraft.world.WorldServer; +import net.minecraft.world.gen.feature.WorldGenDungeons; +import net.minecraft.world.gen.structure.*; +import net.minecraft.world.gen.structure.ComponentScatteredFeaturePieces.DesertPyramid; +import net.minecraft.world.gen.structure.ComponentScatteredFeaturePieces.JunglePyramid; +import net.minecraft.world.gen.structure.StructureStrongholdPieces.ChestCorridor; +import net.minecraft.world.gen.structure.StructureStrongholdPieces.Library; +import net.minecraft.world.gen.structure.StructureStrongholdPieces.RoomCrossing; +import net.minecraft.world.gen.structure.StructureVillagePieces.House2; +import net.minecraftforge.oredict.OreDictionary; + +public class ChestGenHooks +{ + //Currently implemented categories for chests/dispensers, Dungeon loot is still in DungeonHooks + public static final String MINESHAFT_CORRIDOR = "mineshaftCorridor"; + public static final String PYRAMID_DESERT_CHEST = "pyramidDesertyChest"; + public static final String PYRAMID_JUNGLE_CHEST = "pyramidJungleChest"; + public static final String PYRAMID_JUNGLE_DISPENSER = "pyramidJungleDispenser"; + public static final String STRONGHOLD_CORRIDOR = "strongholdCorridor"; + public static final String STRONGHOLD_LIBRARY = "strongholdLibrary"; + public static final String STRONGHOLD_CROSSING = "strongholdCrossing"; + public static final String VILLAGE_BLACKSMITH = "villageBlacksmith"; + public static final String BONUS_CHEST = "bonusChest"; + public static final String DUNGEON_CHEST = "dungeonChest"; + + private static final HashMap chestInfo = new HashMap(); + private static boolean hasInit = false; + static + { + init(); + } + + private static void init() + { + if (hasInit) + { + return; + } + + hasInit = true; + + addInfo(MINESHAFT_CORRIDOR, StructureMineshaftPieces.mineshaftChestContents, 3, 7); + addInfo(PYRAMID_DESERT_CHEST, DesertPyramid.itemsToGenerateInTemple, 2, 7); + addInfo(PYRAMID_JUNGLE_CHEST, JunglePyramid.junglePyramidsChestContents, 2, 7); + addInfo(PYRAMID_JUNGLE_DISPENSER, JunglePyramid.junglePyramidsDispenserContents, 2, 2); + addInfo(STRONGHOLD_CORRIDOR, ChestCorridor.strongholdChestContents, 2, 4); + addInfo(STRONGHOLD_LIBRARY, Library.strongholdLibraryChestContents, 1, 5); + addInfo(STRONGHOLD_CROSSING, RoomCrossing.strongholdRoomCrossingChestContents, 1, 5); + addInfo(VILLAGE_BLACKSMITH, House2.villageBlacksmithChestContents, 3, 9); + addInfo(BONUS_CHEST, WorldServer.bonusChestContent, 10, 10); + addInfo(DUNGEON_CHEST, WorldGenDungeons.field_111189_a, 8, 8); + + ItemStack book = new ItemStack(Items.enchanted_book, 1, 0); + WeightedRandomChestContent tmp = new WeightedRandomChestContent(book, 1, 1, 1); + getInfo(MINESHAFT_CORRIDOR ).addItem(tmp); + getInfo(PYRAMID_DESERT_CHEST).addItem(tmp); + getInfo(PYRAMID_JUNGLE_CHEST).addItem(tmp); + getInfo(STRONGHOLD_CORRIDOR ).addItem(tmp); + getInfo(STRONGHOLD_LIBRARY ).addItem(new WeightedRandomChestContent(book, 1, 5, 2)); + getInfo(STRONGHOLD_CROSSING ).addItem(tmp); + getInfo(DUNGEON_CHEST ).addItem(tmp); + } + + static void addDungeonLoot(ChestGenHooks dungeon, ItemStack item, int weight, int min, int max) + { + dungeon.addItem(new WeightedRandomChestContent(item, min, max, weight)); + } + + private static void addInfo(String category, WeightedRandomChestContent[] items, int min, int max) + { + chestInfo.put(category, new ChestGenHooks(category, items, min, max)); + } + + /** + * Retrieves, or creates the info class for the specified category. + * + * @param category The category name + * @return A instance of ChestGenHooks for the specified category. + */ + public static ChestGenHooks getInfo(String category) + { + if (!chestInfo.containsKey(category)) + { + chestInfo.put(category, new ChestGenHooks(category)); + } + return chestInfo.get(category); + } + + /** + * Generates an array of items based on the input min/max count. + * If the stack can not hold the total amount, it will be split into + * stacks of size 1. + * + * @param rand A random number generator + * @param source Source item stack + * @param min Minimum number of items + * @param max Maximum number of items + * @return An array containing the generated item stacks + */ + public static ItemStack[] generateStacks(Random rand, ItemStack source, int min, int max) + { + int count = min + (rand.nextInt(max - min + 1)); + + ItemStack[] ret; + if (source.getItem() == null) + { + ret = new ItemStack[0]; + } + else if (count > source.getMaxStackSize()) + { + ret = new ItemStack[count]; + for (int x = 0; x < count; x++) + { + ret[x] = source.copy(); + ret[x].stackSize = 1; + } + } + else + { + ret = new ItemStack[1]; + ret[0] = source.copy(); + ret[0].stackSize = count; + } + return ret; + } + + //shortcut functions, See the non-static versions below + public static WeightedRandomChestContent[] getItems(String category, Random rnd){ return getInfo(category).getItems(rnd); } + public static int getCount(String category, Random rand){ return getInfo(category).getCount(rand); } + public static void addItem(String category, WeightedRandomChestContent item){ getInfo(category).addItem(item); } + public static void removeItem(String category, ItemStack item){ getInfo(category).removeItem(item); } + public static ItemStack getOneItem(String category, Random rand){ return getInfo(category).getOneItem(rand); } + + private String category; + private int countMin = 0; + private int countMax = 0; + private ArrayList contents = new ArrayList(); + + public ChestGenHooks(String category) + { + this.category = category; + } + + public ChestGenHooks(String category, WeightedRandomChestContent[] items, int min, int max) + { + this(category); + for (WeightedRandomChestContent item : items) + { + contents.add(item); + } + countMin = min; + countMax = max; + } + + /** + * Adds a new entry into the possible items to generate. + * + * @param item The item to add. + */ + public void addItem(WeightedRandomChestContent item) + { + contents.add(item); + } + + /** + * Removes all items that match the input item stack, Only metadata and item ID are checked. + * If the input item has a metadata of -1, all metadatas will match. + * + * @param item The item to check + */ + public void removeItem(ItemStack item) + { + Iterator itr = contents.iterator(); + while(itr.hasNext()) + { + WeightedRandomChestContent cont = itr.next(); + if (item.isItemEqual(cont.theItemId) || (item.getItemDamage() == OreDictionary.WILDCARD_VALUE && item.getItem() == cont.theItemId.getItem())) + { + itr.remove(); + } + } + } + + /** + * Gets an array of all random objects that are associated with this category. + * + * @return The random objects + */ + public WeightedRandomChestContent[] getItems(Random rnd) + { + ArrayList ret = new ArrayList(); + + for (WeightedRandomChestContent orig : contents) + { + Item item = orig.theItemId.getItem(); + + if (item != null) + { + WeightedRandomChestContent n = item.getChestGenBase(this, rnd, orig); + if (n != null) + { + ret.add(n); + } + } + } + + return ret.toArray(new WeightedRandomChestContent[ret.size()]); + } + + /** + * Gets a random number between countMin and countMax. + * + * @param rand A RNG + * @return A random number where countMin <= num <= countMax + */ + public int getCount(Random rand) + { + return countMin < countMax ? countMin + rand.nextInt(countMax - countMin) : countMin; + } + + /** + * Returns a single ItemStack from the possible items in this registry, + * Useful if you just want a quick and dirty random Item. + * + * @param rand A Random Number gen + * @return A single ItemStack, or null if it could not get one. + */ + public ItemStack getOneItem(Random rand) + { + WeightedRandomChestContent[] items = getItems(rand); + WeightedRandomChestContent item = (WeightedRandomChestContent)WeightedRandom.getRandomItem(rand, items); + ItemStack[] stacks = ChestGenHooks.generateStacks(rand, item.theItemId, item.theMinimumChanceToGenerateItem, item.theMaximumChanceToGenerateItem); + return (stacks.length > 0 ? stacks[0] : null); + } + + //Accessors + public int getMin(){ return countMin; } + public int getMax(){ return countMax; } + public void setMin(int value){ countMin = value; } + public void setMax(int value){ countMax = value; } +} diff --git a/src/main/java/net/minecraftforge/common/DimensionManager.java b/src/main/java/net/minecraftforge/common/DimensionManager.java new file mode 100644 index 0000000..e5c4c7a --- /dev/null +++ b/src/main/java/net/minecraftforge/common/DimensionManager.java @@ -0,0 +1,428 @@ +package net.minecraftforge.common; + +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.BitSet; +import java.util.Hashtable; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; +import java.util.Map.Entry; +import java.util.concurrent.ConcurrentMap; + +import org.apache.logging.log4j.Level; + +import com.google.common.collect.HashMultiset; +import com.google.common.collect.Lists; +import com.google.common.collect.MapMaker; +import com.google.common.collect.Multiset; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.FMLLog; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.server.MinecraftServer; +import net.minecraft.world.MinecraftException; +import net.minecraft.world.World; +import net.minecraft.world.WorldManager; +import net.minecraft.world.WorldProvider; +import net.minecraft.world.WorldProviderEnd; +import net.minecraft.world.WorldProviderHell; +import net.minecraft.world.WorldProviderSurface; +import net.minecraft.world.WorldServer; +import net.minecraft.world.WorldServerMulti; +import net.minecraft.world.WorldSettings; +import net.minecraft.world.storage.ISaveHandler; +import net.minecraft.world.storage.SaveHandler; +import net.minecraftforge.event.world.WorldEvent; + +public class DimensionManager +{ + private static Hashtable> providers = new Hashtable>(); + private static Hashtable spawnSettings = new Hashtable(); + private static Hashtable worlds = new Hashtable(); + private static boolean hasInit = false; + private static Hashtable dimensions = new Hashtable(); + private static ArrayList unloadQueue = new ArrayList(); + private static BitSet dimensionMap = new BitSet(Long.SIZE << 4); + private static ConcurrentMap weakWorldMap = new MapMaker().weakKeys().weakValues().makeMap(); + private static Multiset leakedWorlds = HashMultiset.create(); + + public static boolean registerProviderType(int id, Class provider, boolean keepLoaded) + { + if (providers.containsKey(id)) + { + return false; + } + providers.put(id, provider); + spawnSettings.put(id, keepLoaded); + return true; + } + + /** + * Unregisters a Provider type, and returns a array of all dimensions that are + * registered to this provider type. + * If the return size is greater then 0, it is required that the caller either + * change those dimensions's registered type, or replace this type before the + * world is attempted to load, else the loader will throw an exception. + * + * @param id The provider type ID to unreigster + * @return An array containing all dimension IDs still registered to this provider type. + */ + public static int[] unregisterProviderType(int id) + { + if (!providers.containsKey(id)) + { + return new int[0]; + } + providers.remove(id); + spawnSettings.remove(id); + + int[] ret = new int[dimensions.size()]; + int x = 0; + for (Map.Entry ent : dimensions.entrySet()) + { + if (ent.getValue() == id) + { + ret[x++] = ent.getKey(); + } + } + + return Arrays.copyOf(ret, x); + } + + public static void init() + { + if (hasInit) + { + return; + } + + hasInit = true; + + registerProviderType( 0, WorldProviderSurface.class, true); + registerProviderType(-1, WorldProviderHell.class, true); + registerProviderType( 1, WorldProviderEnd.class, false); + registerDimension( 0, 0); + registerDimension(-1, -1); + registerDimension( 1, 1); + } + + public static void registerDimension(int id, int providerType) + { + if (!providers.containsKey(providerType)) + { + throw new IllegalArgumentException(String.format("Failed to register dimension for id %d, provider type %d does not exist", id, providerType)); + } + if (dimensions.containsKey(id)) + { + throw new IllegalArgumentException(String.format("Failed to register dimension for id %d, One is already registered", id)); + } + dimensions.put(id, providerType); + if (id >= 0) + { + dimensionMap.set(id); + } + } + + /** + * For unregistering a dimension when the save is changed (disconnected from a server or loaded a new save + */ + public static void unregisterDimension(int id) + { + if (!dimensions.containsKey(id)) + { + throw new IllegalArgumentException(String.format("Failed to unregister dimension for id %d; No provider registered", id)); + } + dimensions.remove(id); + } + + public static boolean isDimensionRegistered(int dim) + { + return dimensions.containsKey(dim); + } + + public static int getProviderType(int dim) + { + if (!dimensions.containsKey(dim)) + { + throw new IllegalArgumentException(String.format("Could not get provider type for dimension %d, does not exist", dim)); + } + return dimensions.get(dim); + } + + public static WorldProvider getProvider(int dim) + { + return getWorld(dim).provider; + } + + public static Integer[] getIDs(boolean check) + { + if (check) + { + List allWorlds = Lists.newArrayList(weakWorldMap.keySet()); + allWorlds.removeAll(worlds.values()); + for (ListIterator li = allWorlds.listIterator(); li.hasNext(); ) + { + World w = li.next(); + leakedWorlds.add(System.identityHashCode(w)); + } + for (World w : allWorlds) + { + int leakCount = leakedWorlds.count(System.identityHashCode(w)); + if (leakCount == 5) + { + FMLLog.fine("The world %x (%s) may have leaked: first encounter (5 occurences).\n", System.identityHashCode(w), w.getWorldInfo().getWorldName()); + } + else if (leakCount % 5 == 0) + { + FMLLog.fine("The world %x (%s) may have leaked: seen %d times.\n", System.identityHashCode(w), w.getWorldInfo().getWorldName(), leakCount); + } + } + } + return getIDs(); + } + public static Integer[] getIDs() + { + return worlds.keySet().toArray(new Integer[worlds.size()]); //Only loaded dims, since usually used to cycle through loaded worlds + } + + public static void setWorld(int id, WorldServer world) + { + if (world != null) + { + worlds.put(id, world); + weakWorldMap.put(world, world); + MinecraftServer.getServer().worldTickTimes.put(id, new long[100]); + FMLLog.info("Loading dimension %d (%s) (%s)", id, world.getWorldInfo().getWorldName(), world.func_73046_m()); + } + else + { + worlds.remove(id); + MinecraftServer.getServer().worldTickTimes.remove(id); + FMLLog.info("Unloading dimension %d", id); + } + + ArrayList tmp = new ArrayList(); + if (worlds.get( 0) != null) + tmp.add(worlds.get( 0)); + if (worlds.get(-1) != null) + tmp.add(worlds.get(-1)); + if (worlds.get( 1) != null) + tmp.add(worlds.get( 1)); + + for (Entry entry : worlds.entrySet()) + { + int dim = entry.getKey(); + if (dim >= -1 && dim <= 1) + { + continue; + } + tmp.add(entry.getValue()); + } + + MinecraftServer.getServer().worldServers = tmp.toArray(new WorldServer[tmp.size()]); + } + + public static void initDimension(int dim) { + WorldServer overworld = getWorld(0); + if (overworld == null) + { + throw new RuntimeException("Cannot Hotload Dim: Overworld is not Loaded!"); + } + try + { + DimensionManager.getProviderType(dim); + } + catch (Exception e) + { + System.err.println("Cannot Hotload Dim: " + e.getMessage()); + return; // If a provider hasn't been registered then we can't hotload the dim + } + MinecraftServer mcServer = overworld.func_73046_m(); + ISaveHandler savehandler = overworld.getSaveHandler(); + WorldSettings worldSettings = new WorldSettings(overworld.getWorldInfo()); + + WorldServer world = (dim == 0 ? overworld : new WorldServerMulti(mcServer, savehandler, overworld.getWorldInfo().getWorldName(), dim, worldSettings, overworld, mcServer.theProfiler)); + world.addWorldAccess(new WorldManager(mcServer, world)); + MinecraftForge.EVENT_BUS.post(new WorldEvent.Load(world)); + if (!mcServer.isSinglePlayer()) + { + world.getWorldInfo().setGameType(mcServer.getGameType()); + } + + mcServer.func_147139_a(mcServer.func_147135_j()); + } + + public static WorldServer getWorld(int id) + { + return worlds.get(id); + } + + public static WorldServer[] getWorlds() + { + return worlds.values().toArray(new WorldServer[worlds.size()]); + } + + public static boolean shouldLoadSpawn(int dim) + { + int id = getProviderType(dim); + return spawnSettings.containsKey(id) && spawnSettings.get(id); + } + + static + { + init(); + } + + /** + * Not public API: used internally to get dimensions that should load at + * server startup + */ + public static Integer[] getStaticDimensionIDs() + { + return dimensions.keySet().toArray(new Integer[dimensions.keySet().size()]); + } + public static WorldProvider createProviderFor(int dim) + { + try + { + if (dimensions.containsKey(dim)) + { + WorldProvider provider = providers.get(getProviderType(dim)).newInstance(); + provider.setDimension(dim); + return provider; + } + else + { + throw new RuntimeException(String.format("No WorldProvider bound for dimension %d", dim)); //It's going to crash anyway at this point. Might as well be informative + } + } + catch (Exception e) + { + FMLCommonHandler.instance().getFMLLogger().log(Level.ERROR, String.format("An error occured trying to create an instance of WorldProvider %d (%s)", + dim, providers.get(getProviderType(dim)).getSimpleName()),e); + throw new RuntimeException(e); + } + } + + public static void unloadWorld(int id) { + unloadQueue.add(id); + } + + /* + * To be called by the server at the appropriate time, do not call from mod code. + */ + public static void unloadWorlds(Hashtable worldTickTimes) { + for (int id : unloadQueue) { + WorldServer w = worlds.get(id); + try { + if (w != null) + { + w.saveAllChunks(true, null); + } + else + { + FMLLog.warning("Unexpected world unload - world %d is already unloaded", id); + } + } catch (MinecraftException e) { + e.printStackTrace(); + } + finally + { + if (w != null) + { + MinecraftForge.EVENT_BUS.post(new WorldEvent.Unload(w)); + w.flush(); + setWorld(id, null); + } + } + } + unloadQueue.clear(); + } + + /** + * Return the next free dimension ID. Note: you are not guaranteed a contiguous + * block of free ids. Always call for each individual ID you wish to get. + * @return the next free dimension ID + */ + public static int getNextFreeDimId() { + int next = 0; + while (true) + { + next = dimensionMap.nextClearBit(next); + if (dimensions.containsKey(next)) + { + dimensionMap.set(next); + } + else + { + return next; + } + } + } + + public static NBTTagCompound saveDimensionDataMap() + { + int[] data = new int[(dimensionMap.length() + Integer.SIZE - 1 )/ Integer.SIZE]; + NBTTagCompound dimMap = new NBTTagCompound(); + for (int i = 0; i < data.length; i++) + { + int val = 0; + for (int j = 0; j < Integer.SIZE; j++) + { + val |= dimensionMap.get(i * Integer.SIZE + j) ? (1 << j) : 0; + } + data[i] = val; + } + dimMap.setIntArray("DimensionArray", data); + return dimMap; + } + + public static void loadDimensionDataMap(NBTTagCompound compoundTag) + { + if (compoundTag == null) + { + dimensionMap.clear(); + for (Integer id : dimensions.keySet()) + { + if (id >= 0) + { + dimensionMap.set(id); + } + } + } + else + { + int[] intArray = compoundTag.getIntArray("DimensionArray"); + for (int i = 0; i < intArray.length; i++) + { + for (int j = 0; j < Integer.SIZE; j++) + { + dimensionMap.set(i * Integer.SIZE + j, (intArray[i] & (1 << j)) != 0); + } + } + } + } + + /** + * Return the current root directory for the world save. Accesses getSaveHandler from the overworld + * @return the root directory of the save + */ + public static File getCurrentSaveRootDirectory() + { + if (DimensionManager.getWorld(0) != null) + { + return ((SaveHandler)DimensionManager.getWorld(0).getSaveHandler()).getWorldDirectory(); + } + else if (MinecraftServer.getServer() != null) + { + MinecraftServer srv = MinecraftServer.getServer(); + SaveHandler saveHandler = (SaveHandler) srv.getActiveAnvilConverter().getSaveLoader(srv.getFolderName(), false); + return saveHandler.getWorldDirectory(); + } + else + { + return null; + } + } +} diff --git a/src/main/java/net/minecraftforge/common/DungeonHooks.java b/src/main/java/net/minecraftforge/common/DungeonHooks.java new file mode 100644 index 0000000..1a922d2 --- /dev/null +++ b/src/main/java/net/minecraftforge/common/DungeonHooks.java @@ -0,0 +1,102 @@ +package net.minecraftforge.common; + +import java.util.ArrayList; +import java.util.Random; + +import net.minecraft.util.WeightedRandom; + +public class DungeonHooks +{ + private static ArrayList dungeonMobs = new ArrayList(); + + /** + * Adds a mob to the possible list of creatures the spawner will create. + * If the mob is already in the spawn list, the rarity will be added to the existing one, + * causing the mob to be more common. + * + * @param name The name of the monster, use the same name used when registering the entity. + * @param rarity The rarity of selecting this mob over others. Must be greater then 0. + * Vanilla Minecraft has the following mobs: + * Spider 100 + * Skeleton 100 + * Zombie 200 + * Meaning, Zombies are twice as common as spiders or skeletons. + * @return The new rarity of the monster, + */ + public static float addDungeonMob(String name, int rarity) + { + if (rarity <= 0) + { + throw new IllegalArgumentException("Rarity must be greater then zero"); + } + + for (DungeonMob mob : dungeonMobs) + { + if (name.equals(mob.type)) + { + return mob.itemWeight += rarity; + } + } + + dungeonMobs.add(new DungeonMob(rarity, name)); + return rarity; + } + + /** + * Will completely remove a Mob from the dungeon spawn list. + * + * @param name The name of the mob to remove + * @return The rarity of the removed mob, prior to being removed. + */ + public static int removeDungeonMob(String name) + { + for (DungeonMob mob : dungeonMobs) + { + if (name.equals(mob.type)) + { + dungeonMobs.remove(mob); + return mob.itemWeight; + } + } + return 0; + } + + /** + * Gets a random mob name from the list. + * @param rand World generation random number generator + * @return The mob name + */ + public static String getRandomDungeonMob(Random rand) + { + DungeonMob mob = (DungeonMob)WeightedRandom.getRandomItem(rand, dungeonMobs); + if (mob == null) + { + return ""; + } + return mob.type; + } + + + public static class DungeonMob extends WeightedRandom.Item + { + public String type; + public DungeonMob(int weight, String type) + { + super(weight); + this.type = type; + } + + @Override + public boolean equals(Object target) + { + return target instanceof DungeonMob && type.equals(((DungeonMob)target).type); + } + } + + static + { + addDungeonMob("Skeleton", 100); + addDungeonMob("Zombie", 200); + addDungeonMob("Spider", 100); + } +} diff --git a/src/main/java/net/minecraftforge/common/EnumPlantType.java b/src/main/java/net/minecraftforge/common/EnumPlantType.java new file mode 100644 index 0000000..658cfdd --- /dev/null +++ b/src/main/java/net/minecraftforge/common/EnumPlantType.java @@ -0,0 +1,12 @@ +package net.minecraftforge.common; + +public enum EnumPlantType +{ + Plains, + Desert, + Beach, + Cave, + Water, + Nether, + Crop +} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/common/ForgeChunkManager.java b/src/main/java/net/minecraftforge/common/ForgeChunkManager.java new file mode 100644 index 0000000..8757cf6 --- /dev/null +++ b/src/main/java/net/minecraftforge/common/ForgeChunkManager.java @@ -0,0 +1,993 @@ +package net.minecraftforge.common; + +import java.io.File; +import java.io.IOException; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; + +import org.apache.logging.log4j.Level; + +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableListMultimap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableSetMultimap; +import com.google.common.collect.LinkedHashMultimap; +import com.google.common.collect.ListMultimap; +import com.google.common.collect.MapMaker; +import com.google.common.collect.Maps; +import com.google.common.collect.Multimap; +import com.google.common.collect.SetMultimap; +import com.google.common.collect.Sets; + +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.ModContainer; +import cpw.mods.fml.common.eventhandler.Event; +import net.minecraft.server.MinecraftServer; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.ChunkCoordIntPair; +import net.minecraft.nbt.CompressedStreamTools; +import net.minecraft.entity.Entity; +import net.minecraft.util.MathHelper; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.world.World; +import net.minecraft.world.WorldServer; +import net.minecraftforge.common.config.ConfigCategory; +import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.common.config.Property; +import net.minecraftforge.common.util.Constants; + +/** + * Manages chunkloading for mods. + * + * The basic principle is a ticket based system. + * 1. Mods register a callback {@link #setForcedChunkLoadingCallback(Object, LoadingCallback)} + * 2. Mods ask for a ticket {@link #requestTicket(Object, World, Type)} and then hold on to that ticket. + * 3. Mods request chunks to stay loaded {@link #forceChunk(Ticket, ChunkCoordIntPair)} or remove chunks from force loading {@link #unforceChunk(Ticket, ChunkCoordIntPair)}. + * 4. When a world unloads, the tickets associated with that world are saved by the chunk manager. + * 5. When a world loads, saved tickets are offered to the mods associated with the tickets. The {@link Ticket#getModData()} that is set by the mod should be used to re-register + * chunks to stay loaded (and maybe take other actions). + * + * The chunkloading is configurable at runtime. The file "config/forgeChunkLoading.cfg" contains both default configuration for chunkloading, and a sample individual mod + * specific override section. + * + * @author cpw + * + */ +public class ForgeChunkManager +{ + private static int defaultMaxCount; + private static int defaultMaxChunks; + private static boolean overridesEnabled; + + private static Map> tickets = new MapMaker().weakKeys().makeMap(); + private static Map ticketConstraints = Maps.newHashMap(); + private static Map chunkConstraints = Maps.newHashMap(); + + private static SetMultimap playerTickets = HashMultimap.create(); + + private static Map callbacks = Maps.newHashMap(); + + private static Map> forcedChunks = new MapMaker().weakKeys().makeMap(); + private static BiMap pendingEntities = HashBiMap.create(); + + private static Map> dormantChunkCache = new MapMaker().weakKeys().makeMap(); + + private static File cfgFile; + private static Configuration config; + private static int playerTicketLength; + private static int dormantChunkCacheSize; + + private static Set warnedMods = Sets.newHashSet(); + /** + * All mods requiring chunkloading need to implement this to handle the + * re-registration of chunk tickets at world loading time + * + * @author cpw + * + */ + public interface LoadingCallback + { + /** + * Called back when tickets are loaded from the world to allow the + * mod to re-register the chunks associated with those tickets. The list supplied + * here is truncated to length prior to use. Tickets unwanted by the + * mod must be disposed of manually unless the mod is an OrderedLoadingCallback instance + * in which case, they will have been disposed of by the earlier callback. + * + * @param tickets The tickets to re-register. The list is immutable and cannot be manipulated directly. Copy it first. + * @param world the world + */ + public void ticketsLoaded(List tickets, World world); + } + + /** + * This is a special LoadingCallback that can be implemented as well as the + * LoadingCallback to provide access to additional behaviour. + * Specifically, this callback will fire prior to Forge dropping excess + * tickets. Tickets in the returned list are presumed ordered and excess will + * be truncated from the returned list. + * This allows the mod to control not only if they actually want a ticket but + * also their preferred ticket ordering. + * + * @author cpw + * + */ + public interface OrderedLoadingCallback extends LoadingCallback + { + /** + * Called back when tickets are loaded from the world to allow the + * mod to decide if it wants the ticket still, and prioritise overflow + * based on the ticket count. + * WARNING: You cannot force chunks in this callback, it is strictly for allowing the mod + * to be more selective in which tickets it wishes to preserve in an overflow situation + * + * @param tickets The tickets that you will want to select from. The list is immutable and cannot be manipulated directly. Copy it first. + * @param world The world + * @param maxTicketCount The maximum number of tickets that will be allowed. + * @return A list of the tickets this mod wishes to continue using. This list will be truncated + * to "maxTicketCount" size after the call returns and then offered to the other callback + * method + */ + public List ticketsLoaded(List tickets, World world, int maxTicketCount); + } + + public interface PlayerOrderedLoadingCallback extends LoadingCallback + { + /** + * Called back when tickets are loaded from the world to allow the + * mod to decide if it wants the ticket still. + * This is for player bound tickets rather than mod bound tickets. It is here so mods can + * decide they want to dump all player tickets + * + * WARNING: You cannot force chunks in this callback, it is strictly for allowing the mod + * to be more selective in which tickets it wishes to preserve + * + * @param tickets The tickets that you will want to select from. The list is immutable and cannot be manipulated directly. Copy it first. + * @param world The world + * @return A list of the tickets this mod wishes to use. This list will subsequently be offered + * to the main callback for action + */ + public ListMultimap playerTicketsLoaded(ListMultimap tickets, World world); + } + public enum Type + { + + /** + * For non-entity registrations + */ + NORMAL, + /** + * For entity registrations + */ + ENTITY + } + public static class Ticket + { + private String modId; + private Type ticketType; + private LinkedHashSet requestedChunks; + private NBTTagCompound modData; + public final World world; + private int maxDepth; + //private String entityClazz; + private int entityChunkX; + private int entityChunkZ; + private Entity entity; + private String player; + + Ticket(String modId, Type type, World world) + { + this.modId = modId; + this.ticketType = type; + this.world = world; + this.maxDepth = getMaxChunkDepthFor(modId); + this.requestedChunks = Sets.newLinkedHashSet(); + } + + Ticket(String modId, Type type, World world, String player) + { + this(modId, type, world); + if (player != null) + { + this.player = player; + } + else + { + FMLLog.log(Level.ERROR, "Attempt to create a player ticket without a valid player"); + throw new RuntimeException(); + } + } + /** + * The chunk list depth can be manipulated up to the maximal grant allowed for the mod. This value is configurable. Once the maximum is reached, + * the least recently forced chunk, by original registration time, is removed from the forced chunk list. + * + * @param depth The new depth to set + */ + public void setChunkListDepth(int depth) + { + if (depth > getMaxChunkDepthFor(modId) || (depth <= 0 && getMaxChunkDepthFor(modId) > 0)) + { + FMLLog.warning("The mod %s tried to modify the chunk ticket depth to: %d, its allowed maximum is: %d", modId, depth, getMaxChunkDepthFor(modId)); + } + else + { + this.maxDepth = depth; + } + } + + /** + * Gets the current max depth for this ticket. + * Should be the same as getMaxChunkListDepth() + * unless setChunkListDepth has been called. + * + * @return Current max depth + */ + public int getChunkListDepth() + { + return maxDepth; + } + + /** + * Get the maximum chunk depth size + * + * @return The maximum chunk depth size + */ + public int getMaxChunkListDepth() + { + return getMaxChunkDepthFor(modId); + } + + /** + * Bind the entity to the ticket for {@link Type#ENTITY} type tickets. Other types will throw a runtime exception. + * + * @param entity The entity to bind + */ + public void bindEntity(Entity entity) + { + if (ticketType!=Type.ENTITY) + { + throw new RuntimeException("Cannot bind an entity to a non-entity ticket"); + } + this.entity = entity; + } + + /** + * Retrieve the {@link NBTTagCompound} that stores mod specific data for the chunk ticket. + * Example data to store would be a TileEntity or Block location. This is persisted with the ticket and + * provided to the {@link LoadingCallback} for the mod. It is recommended to use this to recover + * useful state information for the forced chunks. + * + * @return The custom compound tag for mods to store additional chunkloading data + */ + public NBTTagCompound getModData() + { + if (this.modData == null) + { + this.modData = new NBTTagCompound(); + } + return modData; + } + + /** + * Get the entity associated with this {@link Type#ENTITY} type ticket + * @return the entity + */ + public Entity getEntity() + { + return entity; + } + + /** + * Is this a player associated ticket rather than a mod associated ticket? + */ + public boolean isPlayerTicket() + { + return player != null; + } + + /** + * Get the player associated with this ticket + */ + public String getPlayerName() + { + return player; + } + + /** + * Get the associated mod id + */ + public String getModId() + { + return modId; + } + + /** + * Gets the ticket type + */ + public Type getType() + { + return ticketType; + } + + /** + * Gets a list of requested chunks for this ticket. + */ + public ImmutableSet getChunkList() + { + return ImmutableSet.copyOf(requestedChunks); + } + } + + public static class ForceChunkEvent extends Event { + public final Ticket ticket; + public final ChunkCoordIntPair location; + + public ForceChunkEvent(Ticket ticket, ChunkCoordIntPair location) + { + this.ticket = ticket; + this.location = location; + } + } + + public static class UnforceChunkEvent extends Event { + public final Ticket ticket; + public final ChunkCoordIntPair location; + + public UnforceChunkEvent(Ticket ticket, ChunkCoordIntPair location) + { + this.ticket = ticket; + this.location = location; + } + } + + + /** + * Allows dynamically loading world mods to test if there are chunk tickets in the world + * Mods that add dynamically generated worlds (like Mystcraft) should call this method + * to determine if the world should be loaded during server starting. + * + * @param chunkDir The chunk directory to test: should be equivalent to {@link WorldServer#getChunkSaveLocation()} + * @return if there are tickets outstanding for this world or not + */ + public static boolean savedWorldHasForcedChunkTickets(File chunkDir) + { + File chunkLoaderData = new File(chunkDir, "forcedchunks.dat"); + + if (chunkLoaderData.exists() && chunkLoaderData.isFile()) + { + ; + try + { + NBTTagCompound forcedChunkData = CompressedStreamTools.read(chunkLoaderData); + return forcedChunkData.getTagList("TicketList", Constants.NBT.TAG_COMPOUND).tagCount() > 0; + } + catch (IOException e) + { + } + } + return false; + } + + static void loadWorld(World world) + { + ArrayListMultimap newTickets = ArrayListMultimap.create(); + tickets.put(world, newTickets); + + forcedChunks.put(world, ImmutableSetMultimap.of()); + + if (!(world instanceof WorldServer)) + { + return; + } + + dormantChunkCache.put(world, CacheBuilder.newBuilder().maximumSize(dormantChunkCacheSize).build()); + WorldServer worldServer = (WorldServer) world; + File chunkDir = worldServer.getChunkSaveLocation(); + File chunkLoaderData = new File(chunkDir, "forcedchunks.dat"); + + if (chunkLoaderData.exists() && chunkLoaderData.isFile()) + { + ArrayListMultimap loadedTickets = ArrayListMultimap.create(); + Map> playerLoadedTickets = Maps.newHashMap(); + NBTTagCompound forcedChunkData; + try + { + forcedChunkData = CompressedStreamTools.read(chunkLoaderData); + } + catch (IOException e) + { + FMLLog.log(Level.WARN, e, "Unable to read forced chunk data at %s - it will be ignored", chunkLoaderData.getAbsolutePath()); + return; + } + NBTTagList ticketList = forcedChunkData.getTagList("TicketList", Constants.NBT.TAG_COMPOUND); + for (int i = 0; i < ticketList.tagCount(); i++) + { + NBTTagCompound ticketHolder = (NBTTagCompound)ticketList.getCompoundTagAt(i); + String modId = ticketHolder.getString("Owner"); + boolean isPlayer = "Forge".equals(modId); + + if (!isPlayer && !Loader.isModLoaded(modId)) + { + FMLLog.warning("Found chunkloading data for mod %s which is currently not available or active - it will be removed from the world save", modId); + continue; + } + + if (!isPlayer && !callbacks.containsKey(modId)) + { + FMLLog.warning("The mod %s has registered persistent chunkloading data but doesn't seem to want to be called back with it - it will be removed from the world save", modId); + continue; + } + + NBTTagList tickets = ticketHolder.getTagList("Tickets", Constants.NBT.TAG_COMPOUND); + for (int j = 0; j < tickets.tagCount(); j++) + { + NBTTagCompound ticket = (NBTTagCompound) tickets.getCompoundTagAt(j); + modId = ticket.hasKey("ModId") ? ticket.getString("ModId") : modId; + Type type = Type.values()[ticket.getByte("Type")]; + //byte ticketChunkDepth = ticket.getByte("ChunkListDepth"); + Ticket tick = new Ticket(modId, type, world); + if (ticket.hasKey("ModData")) + { + tick.modData = ticket.getCompoundTag("ModData"); + } + if (ticket.hasKey("Player")) + { + tick.player = ticket.getString("Player"); + if (!playerLoadedTickets.containsKey(tick.modId)) + { + playerLoadedTickets.put(modId, ArrayListMultimap.create()); + } + playerLoadedTickets.get(tick.modId).put(tick.player, tick); + } + else + { + loadedTickets.put(modId, tick); + } + if (type == Type.ENTITY) + { + tick.entityChunkX = ticket.getInteger("chunkX"); + tick.entityChunkZ = ticket.getInteger("chunkZ"); + UUID uuid = new UUID(ticket.getLong("PersistentIDMSB"), ticket.getLong("PersistentIDLSB")); + // add the ticket to the "pending entity" list + pendingEntities.put(uuid, tick); + } + } + } + + for (Ticket tick : ImmutableSet.copyOf(pendingEntities.values())) + { + if (tick.ticketType == Type.ENTITY && tick.entity == null) + { + // force the world to load the entity's chunk + // the load will come back through the loadEntity method and attach the entity + // to the ticket + world.getChunkFromChunkCoords(tick.entityChunkX, tick.entityChunkZ); + } + } + for (Ticket tick : ImmutableSet.copyOf(pendingEntities.values())) + { + if (tick.ticketType == Type.ENTITY && tick.entity == null) + { + FMLLog.warning("Failed to load persistent chunkloading entity %s from store.", pendingEntities.inverse().get(tick)); + loadedTickets.remove(tick.modId, tick); + } + } + pendingEntities.clear(); + // send callbacks + for (String modId : loadedTickets.keySet()) + { + LoadingCallback loadingCallback = callbacks.get(modId); + if (loadingCallback == null) + { + continue; + } + int maxTicketLength = getMaxTicketLengthFor(modId); + List tickets = loadedTickets.get(modId); + if (loadingCallback instanceof OrderedLoadingCallback) + { + OrderedLoadingCallback orderedLoadingCallback = (OrderedLoadingCallback) loadingCallback; + tickets = orderedLoadingCallback.ticketsLoaded(ImmutableList.copyOf(tickets), world, maxTicketLength); + } + if (tickets.size() > maxTicketLength) + { + FMLLog.warning("The mod %s has too many open chunkloading tickets %d. Excess will be dropped", modId, tickets.size()); + tickets.subList(maxTicketLength, tickets.size()).clear(); + } + ForgeChunkManager.tickets.get(world).putAll(modId, tickets); + loadingCallback.ticketsLoaded(ImmutableList.copyOf(tickets), world); + } + for (String modId : playerLoadedTickets.keySet()) + { + LoadingCallback loadingCallback = callbacks.get(modId); + if (loadingCallback == null) + { + continue; + } + ListMultimap tickets = playerLoadedTickets.get(modId); + if (loadingCallback instanceof PlayerOrderedLoadingCallback) + { + PlayerOrderedLoadingCallback orderedLoadingCallback = (PlayerOrderedLoadingCallback) loadingCallback; + tickets = orderedLoadingCallback.playerTicketsLoaded(ImmutableListMultimap.copyOf(tickets), world); + playerTickets.putAll(tickets); + } + ForgeChunkManager.tickets.get(world).putAll("Forge", tickets.values()); + loadingCallback.ticketsLoaded(ImmutableList.copyOf(tickets.values()), world); + } + } + } + + static void unloadWorld(World world) + { + // World save fires before this event so the chunk loading info will be done + if (!(world instanceof WorldServer)) + { + return; + } + + forcedChunks.remove(world); + dormantChunkCache.remove(world); + // integrated server is shutting down + if (!MinecraftServer.getServer().isServerRunning()) + { + playerTickets.clear(); + tickets.clear(); + } + } + + /** + * Set a chunkloading callback for the supplied mod object + * + * @param mod The mod instance registering the callback + * @param callback The code to call back when forced chunks are loaded + */ + public static void setForcedChunkLoadingCallback(Object mod, LoadingCallback callback) + { + ModContainer container = getContainer(mod); + if (container == null) + { + FMLLog.warning("Unable to register a callback for an unknown mod %s (%s : %x)", mod, mod.getClass().getName(), System.identityHashCode(mod)); + return; + } + + callbacks.put(container.getModId(), callback); + } + + /** + * Discover the available tickets for the mod in the world + * + * @param mod The mod that will own the tickets + * @param world The world + * @return The count of tickets left for the mod in the supplied world + */ + public static int ticketCountAvailableFor(Object mod, World world) + { + ModContainer container = getContainer(mod); + if (container!=null) + { + String modId = container.getModId(); + int allowedCount = getMaxTicketLengthFor(modId); + return allowedCount - tickets.get(world).get(modId).size(); + } + else + { + return 0; + } + } + + private static ModContainer getContainer(Object mod) + { + ModContainer container = Loader.instance().getModObjectList().inverse().get(mod); + return container; + } + + public static int getMaxTicketLengthFor(String modId) + { + int allowedCount = ticketConstraints.containsKey(modId) && overridesEnabled ? ticketConstraints.get(modId) : defaultMaxCount; + return allowedCount; + } + + public static int getMaxChunkDepthFor(String modId) + { + int allowedCount = chunkConstraints.containsKey(modId) && overridesEnabled ? chunkConstraints.get(modId) : defaultMaxChunks; + return allowedCount; + } + + public static int ticketCountAvailableFor(String username) + { + return playerTicketLength - playerTickets.get(username).size(); + } + + public static Ticket requestPlayerTicket(Object mod, String player, World world, Type type) + { + ModContainer mc = getContainer(mod); + if (mc == null) + { + FMLLog.log(Level.ERROR, "Failed to locate the container for mod instance %s (%s : %x)", mod, mod.getClass().getName(), System.identityHashCode(mod)); + return null; + } + if (playerTickets.get(player).size()>playerTicketLength) + { + FMLLog.warning("Unable to assign further chunkloading tickets to player %s (on behalf of mod %s)", player, mc.getModId()); + return null; + } + Ticket ticket = new Ticket(mc.getModId(),type,world,player); + playerTickets.put(player, ticket); + tickets.get(world).put("Forge", ticket); + return ticket; + } + /** + * Request a chunkloading ticket of the appropriate type for the supplied mod + * + * @param mod The mod requesting a ticket + * @param world The world in which it is requesting the ticket + * @param type The type of ticket + * @return A ticket with which to register chunks for loading, or null if no further tickets are available + */ + public static Ticket requestTicket(Object mod, World world, Type type) + { + ModContainer container = getContainer(mod); + if (container == null) + { + FMLLog.log(Level.ERROR, "Failed to locate the container for mod instance %s (%s : %x)", mod, mod.getClass().getName(), System.identityHashCode(mod)); + return null; + } + String modId = container.getModId(); + if (!callbacks.containsKey(modId)) + { + FMLLog.severe("The mod %s has attempted to request a ticket without a listener in place", modId); + throw new RuntimeException("Invalid ticket request"); + } + + int allowedCount = ticketConstraints.containsKey(modId) ? ticketConstraints.get(modId) : defaultMaxCount; + + if (tickets.get(world).get(modId).size() >= allowedCount) + { + if (!warnedMods.contains(modId)) + { + FMLLog.info("The mod %s has attempted to allocate a chunkloading ticket beyond it's currently allocated maximum : %d", modId, allowedCount); + warnedMods.add(modId); + } + return null; + } + Ticket ticket = new Ticket(modId, type, world); + tickets.get(world).put(modId, ticket); + + return ticket; + } + + /** + * Release the ticket back to the system. This will also unforce any chunks held by the ticket so that they can be unloaded and/or stop ticking. + * + * @param ticket The ticket to release + */ + public static void releaseTicket(Ticket ticket) + { + if (ticket == null) + { + return; + } + if (ticket.isPlayerTicket() ? !playerTickets.containsValue(ticket) : !tickets.get(ticket.world).containsEntry(ticket.modId, ticket)) + { + return; + } + if (ticket.requestedChunks!=null) + { + for (ChunkCoordIntPair chunk : ImmutableSet.copyOf(ticket.requestedChunks)) + { + unforceChunk(ticket, chunk); + } + } + if (ticket.isPlayerTicket()) + { + playerTickets.remove(ticket.player, ticket); + tickets.get(ticket.world).remove("Forge",ticket); + } + else + { + tickets.get(ticket.world).remove(ticket.modId, ticket); + } + } + + /** + * Force the supplied chunk coordinate to be loaded by the supplied ticket. If the ticket's {@link Ticket#maxDepth} is exceeded, the least + * recently registered chunk is unforced and may be unloaded. + * It is safe to force the chunk several times for a ticket, it will not generate duplication or change the ordering. + * + * @param ticket The ticket registering the chunk + * @param chunk The chunk to force + */ + public static void forceChunk(Ticket ticket, ChunkCoordIntPair chunk) + { + if (ticket == null || chunk == null) + { + return; + } + if (ticket.ticketType == Type.ENTITY && ticket.entity == null) + { + throw new RuntimeException("Attempted to use an entity ticket to force a chunk, without an entity"); + } + if (ticket.isPlayerTicket() ? !playerTickets.containsValue(ticket) : !tickets.get(ticket.world).containsEntry(ticket.modId, ticket)) + { + FMLLog.severe("The mod %s attempted to force load a chunk with an invalid ticket. This is not permitted.", ticket.modId); + return; + } + ticket.requestedChunks.add(chunk); + MinecraftForge.EVENT_BUS.post(new ForceChunkEvent(ticket, chunk)); + + ImmutableSetMultimap newMap = ImmutableSetMultimap.builder().putAll(forcedChunks.get(ticket.world)).put(chunk, ticket).build(); + forcedChunks.put(ticket.world, newMap); + if (ticket.maxDepth > 0 && ticket.requestedChunks.size() > ticket.maxDepth) + { + ChunkCoordIntPair removed = ticket.requestedChunks.iterator().next(); + unforceChunk(ticket,removed); + } + } + + /** + * Reorganize the internal chunk list so that the chunk supplied is at the *end* of the list + * This helps if you wish to guarantee a certain "automatic unload ordering" for the chunks + * in the ticket list + * + * @param ticket The ticket holding the chunk list + * @param chunk The chunk you wish to push to the end (so that it would be unloaded last) + */ + public static void reorderChunk(Ticket ticket, ChunkCoordIntPair chunk) + { + if (ticket == null || chunk == null || !ticket.requestedChunks.contains(chunk)) + { + return; + } + ticket.requestedChunks.remove(chunk); + ticket.requestedChunks.add(chunk); + } + /** + * Unforce the supplied chunk, allowing it to be unloaded and stop ticking. + * + * @param ticket The ticket holding the chunk + * @param chunk The chunk to unforce + */ + public static void unforceChunk(Ticket ticket, ChunkCoordIntPair chunk) + { + if (ticket == null || chunk == null) + { + return; + } + ticket.requestedChunks.remove(chunk); + MinecraftForge.EVENT_BUS.post(new UnforceChunkEvent(ticket, chunk)); + LinkedHashMultimap copy = LinkedHashMultimap.create(forcedChunks.get(ticket.world)); + copy.remove(chunk, ticket); + ImmutableSetMultimap newMap = ImmutableSetMultimap.copyOf(copy); + forcedChunks.put(ticket.world,newMap); + } + + static void loadConfiguration() + { + for (String mod : config.getCategoryNames()) + { + if (mod.equals("Forge") || mod.equals("defaults")) + { + continue; + } + Property modTC = config.get(mod, "maximumTicketCount", 200); + Property modCPT = config.get(mod, "maximumChunksPerTicket", 25); + ticketConstraints.put(mod, modTC.getInt(200)); + chunkConstraints.put(mod, modCPT.getInt(25)); + } + if (config.hasChanged()) + { + config.save(); + } + } + + /** + * The list of persistent chunks in the world. This set is immutable. + * @param world + * @return the list of persistent chunks in the world + */ + public static ImmutableSetMultimap getPersistentChunksFor(World world) + { + return forcedChunks.containsKey(world) ? forcedChunks.get(world) : ImmutableSetMultimap.of(); + } + + static void saveWorld(World world) + { + // only persist persistent worlds + if (!(world instanceof WorldServer)) + { + return; + } + WorldServer worldServer = (WorldServer) world; + File chunkDir = worldServer.getChunkSaveLocation(); + File chunkLoaderData = new File(chunkDir, "forcedchunks.dat"); + + NBTTagCompound forcedChunkData = new NBTTagCompound(); + NBTTagList ticketList = new NBTTagList(); + forcedChunkData.setTag("TicketList", ticketList); + + Multimap ticketSet = tickets.get(worldServer); + for (String modId : ticketSet.keySet()) + { + NBTTagCompound ticketHolder = new NBTTagCompound(); + ticketList.appendTag(ticketHolder); + + ticketHolder.setString("Owner", modId); + NBTTagList tickets = new NBTTagList(); + ticketHolder.setTag("Tickets", tickets); + + for (Ticket tick : ticketSet.get(modId)) + { + NBTTagCompound ticket = new NBTTagCompound(); + ticket.setByte("Type", (byte) tick.ticketType.ordinal()); + ticket.setByte("ChunkListDepth", (byte) tick.maxDepth); + if (tick.isPlayerTicket()) + { + ticket.setString("ModId", tick.modId); + ticket.setString("Player", tick.player); + } + if (tick.modData != null) + { + ticket.setTag("ModData", tick.modData); + } + if (tick.ticketType == Type.ENTITY && tick.entity != null && tick.entity.writeToNBTOptional(new NBTTagCompound())) + { + ticket.setInteger("chunkX", MathHelper.floor_double(tick.entity.chunkCoordX)); + ticket.setInteger("chunkZ", MathHelper.floor_double(tick.entity.chunkCoordZ)); + ticket.setLong("PersistentIDMSB", tick.entity.getPersistentID().getMostSignificantBits()); + ticket.setLong("PersistentIDLSB", tick.entity.getPersistentID().getLeastSignificantBits()); + tickets.appendTag(ticket); + } + else if (tick.ticketType != Type.ENTITY) + { + tickets.appendTag(ticket); + } + } + } + try + { + CompressedStreamTools.write(forcedChunkData, chunkLoaderData); + } + catch (IOException e) + { + FMLLog.log(Level.WARN, e, "Unable to write forced chunk data to %s - chunkloading won't work", chunkLoaderData.getAbsolutePath()); + return; + } + } + + static void loadEntity(Entity entity) + { + UUID id = entity.getPersistentID(); + Ticket tick = pendingEntities.get(id); + if (tick != null) + { + tick.bindEntity(entity); + pendingEntities.remove(id); + } + } + + public static void putDormantChunk(long coords, Chunk chunk) + { + Cache cache = dormantChunkCache.get(chunk.worldObj); + if (cache != null) + { + cache.put(coords, chunk); + } + } + + @SuppressWarnings("unchecked") + public static Chunk fetchDormantChunk(long coords, World world) + { + Cache cache = dormantChunkCache.get(world); + if (cache == null) + { + return null; + } + Chunk chunk = cache.getIfPresent(coords); + if (chunk != null) + { + for (List eList : (List[])chunk.entityLists) + { + for (Entity e: eList) + { + e.resetEntityId(); + } + } + } + return chunk; + } + + static void captureConfig(File configDir) + { + cfgFile = new File(configDir,"forgeChunkLoading.cfg"); + config = new Configuration(cfgFile, true); + try + { + config.load(); + } + catch (Exception e) + { + File dest = new File(cfgFile.getParentFile(),"forgeChunkLoading.cfg.bak"); + if (dest.exists()) + { + dest.delete(); + } + cfgFile.renameTo(dest); + FMLLog.log(Level.ERROR, e, "A critical error occured reading the forgeChunkLoading.cfg file, defaults will be used - the invalid file is backed up at forgeChunkLoading.cfg.bak"); + } + config.addCustomCategoryComment("defaults", "Default configuration for forge chunk loading control"); + Property maxTicketCount = config.get("defaults", "maximumTicketCount", 200); + maxTicketCount.comment = "The default maximum ticket count for a mod which does not have an override\n" + + "in this file. This is the number of chunk loading requests a mod is allowed to make."; + defaultMaxCount = maxTicketCount.getInt(200); + + Property maxChunks = config.get("defaults", "maximumChunksPerTicket", 25); + maxChunks.comment = "The default maximum number of chunks a mod can force, per ticket, \n" + + "for a mod without an override. This is the maximum number of chunks a single ticket can force."; + defaultMaxChunks = maxChunks.getInt(25); + + Property playerTicketCount = config.get("defaults", "playerTicketCount", 500); + playerTicketCount.comment = "The number of tickets a player can be assigned instead of a mod. This is shared across all mods and it is up to the mods to use it."; + playerTicketLength = playerTicketCount.getInt(500); + + Property dormantChunkCacheSizeProperty = config.get("defaults", "dormantChunkCacheSize", 0); + dormantChunkCacheSizeProperty.comment = "Unloaded chunks can first be kept in a dormant cache for quicker\n" + + "loading times. Specify the size (in chunks) of that cache here"; + dormantChunkCacheSize = dormantChunkCacheSizeProperty.getInt(0); + FMLLog.info("Configured a dormant chunk cache size of %d", dormantChunkCacheSizeProperty.getInt(0)); + + Property modOverridesEnabled = config.get("defaults", "enabled", true); + modOverridesEnabled.comment = "Are mod overrides enabled?"; + overridesEnabled = modOverridesEnabled.getBoolean(true); + + config.addCustomCategoryComment("Forge", "Sample mod specific control section.\n" + + "Copy this section and rename the with the modid for the mod you wish to override.\n" + + "A value of zero in either entry effectively disables any chunkloading capabilities\n" + + "for that mod"); + + Property sampleTC = config.get("Forge", "maximumTicketCount", 200); + sampleTC.comment = "Maximum ticket count for the mod. Zero disables chunkloading capabilities."; + sampleTC = config.get("Forge", "maximumChunksPerTicket", 25); + sampleTC.comment = "Maximum chunks per ticket for the mod."; + for (String mod : config.getCategoryNames()) + { + if (mod.equals("Forge") || mod.equals("defaults")) + { + continue; + } + config.get(mod, "maximumTicketCount", 200); + config.get(mod, "maximumChunksPerTicket", 25); + } + } + + + public static ConfigCategory getConfigFor(Object mod) + { + ModContainer container = getContainer(mod); + if (container != null) + { + return config.getCategory(container.getModId()); + } + + return null; + } + + public static void addConfigProperty(Object mod, String propertyName, String value, Property.Type type) + { + ModContainer container = getContainer(mod); + if (container != null) + { + ConfigCategory cat = config.getCategory(container.getModId()); + cat.put(propertyName, new Property(propertyName, value, type)); + } + } +} diff --git a/src/main/java/net/minecraftforge/common/ForgeHooks.java b/src/main/java/net/minecraftforge/common/ForgeHooks.java new file mode 100644 index 0000000..188145d --- /dev/null +++ b/src/main/java/net/minecraftforge/common/ForgeHooks.java @@ -0,0 +1,439 @@ +package net.minecraftforge.common; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; +import cpw.mods.fml.common.eventhandler.Event; +import cpw.mods.fml.relauncher.ReflectionHelper; +import net.minecraft.block.Block; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ContainerRepair; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemArmor; +import net.minecraft.item.ItemAxe; +import net.minecraft.item.ItemPickaxe; +import net.minecraft.item.ItemSpade; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemSword; +import net.minecraft.network.NetHandlerPlayServer; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S23PacketBlockChange; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.MovingObjectPosition.MovingObjectType; +import net.minecraft.util.WeightedRandom; +import net.minecraft.world.World; +import net.minecraft.world.WorldSettings.GameType; +import net.minecraftforge.event.AnvilUpdateEvent; +import net.minecraftforge.event.ServerChatEvent; +import net.minecraftforge.event.entity.item.ItemTossEvent; +import net.minecraftforge.event.entity.living.LivingAttackEvent; +import net.minecraftforge.event.entity.living.LivingDeathEvent; +import net.minecraftforge.event.entity.living.LivingDropsEvent; +import net.minecraftforge.event.entity.living.LivingEvent.LivingJumpEvent; +import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; +import net.minecraftforge.event.entity.living.LivingFallEvent; +import net.minecraftforge.event.entity.living.LivingHurtEvent; +import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent; +import net.minecraftforge.event.entity.player.PlayerOpenContainerEvent; +import net.minecraftforge.event.world.BlockEvent; +import static net.minecraft.init.Blocks.*; + +public class ForgeHooks +{ + static class SeedEntry extends WeightedRandom.Item + { + public final ItemStack seed; + public SeedEntry(ItemStack seed, int weight) + { + super(weight); + this.seed = seed; + } + } + static final List seedList = new ArrayList(); + + public static ItemStack getGrassSeed(World world) + { + SeedEntry entry = (SeedEntry)WeightedRandom.getRandomItem(world.rand, seedList); + if (entry == null || entry.seed == null) + { + return null; + } + return entry.seed.copy(); + } + + private static boolean toolInit = false; + //static HashSet toolEffectiveness = new HashSet(); + + public static boolean canHarvestBlock(Block block, EntityPlayer player, int metadata) + { + if (block.getMaterial().isToolNotRequired()) + { + return true; + } + + ItemStack stack = player.inventory.getCurrentItem(); + String tool = block.getHarvestTool(metadata); + if (stack == null || tool == null) + { + return player.canHarvestBlock(block); + } + + int toolLevel = stack.getItem().getHarvestLevel(stack, tool); + if (toolLevel < 0) + { + return player.canHarvestBlock(block); + } + + return toolLevel >= block.getHarvestLevel(metadata); + } + + public static boolean canToolHarvestBlock(Block block, int metadata, ItemStack stack) + { + String tool = block.getHarvestTool(metadata); + if (stack == null || tool == null) return false; + return stack.getItem().getHarvestLevel(stack, tool) >= block.getHarvestLevel(metadata); + } + + public static float blockStrength(Block block, EntityPlayer player, World world, int x, int y, int z) + { + int metadata = world.getBlockMetadata(x, y, z); + float hardness = block.getBlockHardness(world, x, y, z); + if (hardness < 0.0F) + { + return 0.0F; + } + + if (!canHarvestBlock(block, player, metadata)) + { + return player.getBreakSpeed(block, true, metadata, x, y, z) / hardness / 100F; + } + else + { + return player.getBreakSpeed(block, false, metadata, x, y, z) / hardness / 30F; + } + } + + public static boolean isToolEffective(ItemStack stack, Block block, int metadata) + { + for (String type : stack.getItem().getToolClasses(stack)) + { + if (block.isToolEffective(type, metadata)) + return true; + } + return false; + } + + static void initTools() + { + if (toolInit) + { + return; + } + toolInit = true; + + Set blocks = ReflectionHelper.getPrivateValue(ItemPickaxe.class, null, 0); + for (Block block : blocks) + { + block.setHarvestLevel("pickaxe", 0); + } + + blocks = ReflectionHelper.getPrivateValue(ItemSpade.class, null, 0); + for (Block block : blocks) + { + block.setHarvestLevel("shovel", 0); + } + + blocks = ReflectionHelper.getPrivateValue(ItemAxe.class, null, 0); + for (Block block : blocks) + { + block.setHarvestLevel("axe", 0); + } + + Blocks.obsidian.setHarvestLevel("pickaxe", 3); + for (Block block : new Block[]{emerald_ore, emerald_block, diamond_ore, diamond_block, gold_ore, gold_block, redstone_ore, lit_redstone_ore}) + { + block.setHarvestLevel("pickaxe", 2); + } + Blocks.iron_ore.setHarvestLevel("pickaxe", 1); + Blocks.iron_block.setHarvestLevel("pickaxe", 1); + Blocks.lapis_ore.setHarvestLevel("pickaxe", 1); + Blocks.lapis_block.setHarvestLevel("pickaxe", 1); + } + + public static int getTotalArmorValue(EntityPlayer player) + { + int ret = 0; + for (int x = 0; x < player.inventory.armorInventory.length; x++) + { + ItemStack stack = player.inventory.armorInventory[x]; + if (stack != null && stack.getItem() instanceof ISpecialArmor) + { + ret += ((ISpecialArmor)stack.getItem()).getArmorDisplay(player, stack, x); + } + else if (stack != null && stack.getItem() instanceof ItemArmor) + { + ret += ((ItemArmor)stack.getItem()).damageReduceAmount; + } + } + return ret; + } + + static + { + seedList.add(new SeedEntry(new ItemStack(Items.wheat_seeds), 10)); + initTools(); + } + + /** + * Called when a player uses 'pick block', calls new Entity and Block hooks. + */ + public static boolean onPickBlock(MovingObjectPosition target, EntityPlayer player, World world) + { + ItemStack result = null; + boolean isCreative = player.capabilities.isCreativeMode; + + if (target.typeOfHit == MovingObjectType.BLOCK) + { + int x = target.blockX; + int y = target.blockY; + int z = target.blockZ; + Block block = world.getBlock(x, y, z); + + if (block.isAir(world, x, y, z)) + { + return false; + } + + result = block.getPickBlock(target, world, x, y, z); + } + else + { + if (target.typeOfHit != MovingObjectType.ENTITY || target.entityHit == null || !isCreative) + { + return false; + } + + result = target.entityHit.getPickedResult(target); + } + + if (result == null) + { + return false; + } + + for (int x = 0; x < 9; x++) + { + ItemStack stack = player.inventory.getStackInSlot(x); + if (stack != null && stack.isItemEqual(result) && ItemStack.areItemStackTagsEqual(stack, result)) + { + player.inventory.currentItem = x; + return true; + } + } + + if (!isCreative) + { + return false; + } + + int slot = player.inventory.getFirstEmptyStack(); + if (slot < 0 || slot >= 9) + { + slot = player.inventory.currentItem; + } + + player.inventory.setInventorySlotContents(slot, result); + player.inventory.currentItem = slot; + return true; + } + + //Optifine Helper Functions u.u, these are here specifically for Optifine + //Note: When using Optfine, these methods are invoked using reflection, which + //incurs a major performance penalty. + public static void onLivingSetAttackTarget(EntityLivingBase entity, EntityLivingBase target) + { + MinecraftForge.EVENT_BUS.post(new LivingSetAttackTargetEvent(entity, target)); + } + + public static boolean onLivingUpdate(EntityLivingBase entity) + { + return MinecraftForge.EVENT_BUS.post(new LivingUpdateEvent(entity)); + } + + public static boolean onLivingAttack(EntityLivingBase entity, DamageSource src, float amount) + { + return MinecraftForge.EVENT_BUS.post(new LivingAttackEvent(entity, src, amount)); + } + + public static float onLivingHurt(EntityLivingBase entity, DamageSource src, float amount) + { + LivingHurtEvent event = new LivingHurtEvent(entity, src, amount); + return (MinecraftForge.EVENT_BUS.post(event) ? 0 : event.ammount); + } + + public static boolean onLivingDeath(EntityLivingBase entity, DamageSource src) + { + return MinecraftForge.EVENT_BUS.post(new LivingDeathEvent(entity, src)); + } + + public static boolean onLivingDrops(EntityLivingBase entity, DamageSource source, ArrayList drops, int lootingLevel, boolean recentlyHit, int specialDropValue) + { + return MinecraftForge.EVENT_BUS.post(new LivingDropsEvent(entity, source, drops, lootingLevel, recentlyHit, specialDropValue)); + } + + public static float onLivingFall(EntityLivingBase entity, float distance) + { + LivingFallEvent event = new LivingFallEvent(entity, distance); + return (MinecraftForge.EVENT_BUS.post(event) ? 0.0f : event.distance); + } + + public static boolean isLivingOnLadder(Block block, World world, int x, int y, int z, EntityLivingBase entity) + { + if (!ForgeModContainer.fullBoundingBoxLadders) + { + return block != null && block.isLadder(world, x, y, z, entity); + } + else + { + AxisAlignedBB bb = entity.boundingBox; + int mX = MathHelper.floor_double(bb.minX); + int mY = MathHelper.floor_double(bb.minY); + int mZ = MathHelper.floor_double(bb.minZ); + for (int y2 = mY; y2 < bb.maxY; y2++) + { + for (int x2 = mX; x2 < bb.maxX; x2++) + { + for (int z2 = mZ; z2 < bb.maxZ; z2++) + { + block = world.getBlock(x2, y2, z2); + if (block != null && block.isLadder(world, x2, y2, z2, entity)) + { + return true; + } + } + } + } + return false; + } + } + + public static void onLivingJump(EntityLivingBase entity) + { + MinecraftForge.EVENT_BUS.post(new LivingJumpEvent(entity)); + } + + public static EntityItem onPlayerTossEvent(EntityPlayer player, ItemStack item, boolean includeName) + { + player.captureDrops = true; + EntityItem ret = player.func_146097_a(item, false, includeName); + player.capturedDrops.clear(); + player.captureDrops = false; + + if (ret == null) + { + return null; + } + + ItemTossEvent event = new ItemTossEvent(ret, player); + if (MinecraftForge.EVENT_BUS.post(event)) + { + return null; + } + + player.joinEntityItemWithWorld(event.entityItem); + return event.entityItem; + } + + public static float getEnchantPower(World world, int x, int y, int z) + { + return world.getBlock(x, y, z).getEnchantPowerBonus(world, x, y, z); + } + + public static ChatComponentTranslation onServerChatEvent(NetHandlerPlayServer net, String raw, ChatComponentTranslation comp) + { + ServerChatEvent event = new ServerChatEvent(net.playerEntity, raw, comp); + if (MinecraftForge.EVENT_BUS.post(event)) + { + return null; + } + return event.component; + } + + public static boolean canInteractWith(EntityPlayer player, Container openContainer) + { + PlayerOpenContainerEvent event = new PlayerOpenContainerEvent(player, openContainer); + MinecraftForge.EVENT_BUS.post(event); + return event.getResult() == Event.Result.DEFAULT ? event.canInteractWith : event.getResult() == Event.Result.ALLOW ? true : false; + } + + public static BlockEvent.BreakEvent onBlockBreakEvent(World world, GameType gameType, EntityPlayerMP entityPlayer, int x, int y, int z) + { + // Logic from tryHarvestBlock for pre-canceling the event + boolean preCancelEvent = false; + if (gameType.isAdventure() && !entityPlayer.isCurrentToolAdventureModeExempt(x, y, z)) + { + preCancelEvent = true; + } + else if (gameType.isCreative() && entityPlayer.getHeldItem() != null && entityPlayer.getHeldItem().getItem() instanceof ItemSword) + { + preCancelEvent = true; + } + + // Tell client the block is gone immediately then process events + if (world.getTileEntity(x, y, z) == null) + { + S23PacketBlockChange packet = new S23PacketBlockChange(x, y, z, world); + packet.field_148883_d = Blocks.air; + packet.field_148884_e = 0; + entityPlayer.playerNetServerHandler.sendPacket(packet); + } + + // Post the block break event + Block block = world.getBlock(x, y, z); + int blockMetadata = world.getBlockMetadata(x, y, z); + BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(x, y, z, world, block, blockMetadata, entityPlayer); + event.setCanceled(preCancelEvent); + MinecraftForge.EVENT_BUS.post(event); + + // Handle if the event is canceled + if (event.isCanceled()) + { + // Let the client know the block still exists + entityPlayer.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world)); + + // Update any tile entity data for this block + TileEntity tileentity = world.getTileEntity(x, y, z); + if (tileentity != null) + { + Packet pkt = tileentity.getDescriptionPacket(); + if (pkt != null) + { + entityPlayer.playerNetServerHandler.sendPacket(pkt); + } + } + } + return event; + } + + public static boolean onAnvilChange(ContainerRepair container, ItemStack left, ItemStack right, IInventory outputSlot, String name, int baseCost) + { + AnvilUpdateEvent e = new AnvilUpdateEvent(left, right, name, baseCost); + if (MinecraftForge.EVENT_BUS.post(e)) return false; + if (e.output == null) return true; + + outputSlot.setInventorySlotContents(0, e.output); + container.maximumCost = e.cost; + return false; + } +} diff --git a/src/main/java/net/minecraftforge/common/ForgeInternalHandler.java b/src/main/java/net/minecraftforge/common/ForgeInternalHandler.java new file mode 100644 index 0000000..06e7671 --- /dev/null +++ b/src/main/java/net/minecraftforge/common/ForgeInternalHandler.java @@ -0,0 +1,80 @@ +package net.minecraftforge.common; + +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.eventhandler.EventPriority; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.WorldServer; +import net.minecraftforge.common.util.FakePlayerFactory; +import net.minecraftforge.event.entity.*; +import net.minecraftforge.event.world.WorldEvent; + +public class ForgeInternalHandler +{ + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onEntityJoinWorld(EntityJoinWorldEvent event) + { + if (!event.world.isRemote) + { + ForgeChunkManager.loadEntity(event.entity); + } + + Entity entity = event.entity; + if (entity.getClass().equals(EntityItem.class)) + { + ItemStack stack = entity.getDataWatcher().getWatchableObjectItemStack(10); + + if (stack == null) + { + //entity.setDead(); + //event.setCanceled(true); + return; + } + + Item item = stack.getItem(); + if (item == null) + { + FMLLog.warning("Attempted to add a EntityItem to the world with a invalid item at " + + "(%2.2f, %2.2f, %2.2f), this is most likely a config issue between you and the server. Please double check your configs", + entity.posX, entity.posY, entity.posZ); + entity.setDead(); + event.setCanceled(true); + return; + } + + if (item.hasCustomEntity(stack)) + { + Entity newEntity = item.createEntity(event.world, entity, stack); + if (newEntity != null) + { + entity.setDead(); + event.setCanceled(true); + event.world.spawnEntityInWorld(newEntity); + } + } + } + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onDimensionLoad(WorldEvent.Load event) + { + ForgeChunkManager.loadWorld(event.world); + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onDimensionSave(WorldEvent.Save event) + { + ForgeChunkManager.saveWorld(event.world); + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onDimensionUnload(WorldEvent.Unload event) + { + ForgeChunkManager.unloadWorld(event.world); + if (event.world instanceof WorldServer) + FakePlayerFactory.unloadWorld((WorldServer)event.world); + } +} diff --git a/src/main/java/net/minecraftforge/common/ForgeModContainer.java b/src/main/java/net/minecraftforge/common/ForgeModContainer.java new file mode 100644 index 0000000..43fcb17 --- /dev/null +++ b/src/main/java/net/minecraftforge/common/ForgeModContainer.java @@ -0,0 +1,290 @@ +package net.minecraftforge.common; + +import static net.minecraftforge.common.ForgeVersion.buildVersion; +import static net.minecraftforge.common.ForgeVersion.majorVersion; +import static net.minecraftforge.common.ForgeVersion.minorVersion; +import static net.minecraftforge.common.ForgeVersion.revisionVersion; +import static net.minecraftforge.common.config.Configuration.CATEGORY_GENERAL; + +import java.io.File; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import net.minecraft.init.Blocks; +import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.storage.SaveHandler; +import net.minecraft.world.storage.WorldInfo; +import net.minecraftforge.classloading.FMLForgePlugin; +import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.common.config.Property; +import net.minecraftforge.common.network.ForgeNetworkHandler; +import net.minecraftforge.oredict.RecipeSorter; +import net.minecraftforge.server.command.ForgeCommand; + +import com.google.common.collect.ImmutableList; +import com.google.common.eventbus.EventBus; +import com.google.common.eventbus.Subscribe; + +import cpw.mods.fml.client.FMLFileResourcePack; +import cpw.mods.fml.client.FMLFolderResourcePack; +import cpw.mods.fml.common.DummyModContainer; +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.LoadController; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.ModMetadata; +import cpw.mods.fml.common.WorldAccessContainer; +import cpw.mods.fml.common.event.FMLConstructionEvent; +import cpw.mods.fml.common.event.FMLLoadCompleteEvent; +import cpw.mods.fml.common.event.FMLModIdMappingEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.event.FMLServerStartingEvent; +import cpw.mods.fml.common.network.NetworkRegistry; + +public class ForgeModContainer extends DummyModContainer implements WorldAccessContainer +{ + public static int clumpingThreshold = 64; + public static boolean removeErroringEntities = false; + public static boolean removeErroringTileEntities = false; + public static boolean disableStitchedFileSaving = false; + public static boolean forceDuplicateFluidBlockCrash = true; + public static boolean fullBoundingBoxLadders = false; + public static double zombieSummonBaseChance = 0.1; + public static int[] blendRanges = { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34 }; + public static float zombieBabyChance = 0.05f; + public static boolean shouldSortRecipies = true; + public static boolean disableVersionCheck = false; + + public ForgeModContainer() + { + super(new ModMetadata()); + ModMetadata meta = getMetadata(); + meta.modId = "Forge"; + meta.name = "Minecraft Forge"; + meta.version = String.format("%d.%d.%d.%d", majorVersion, minorVersion, revisionVersion, buildVersion); + meta.credits = "Made possible with help from many people"; + meta.authorList = Arrays.asList("LexManos", "Eloraam", "Spacetoad"); + meta.description = "Minecraft Forge is a common open source API allowing a broad range of mods " + + "to work cooperatively together. It allows many mods to be created without " + + "them editing the main Minecraft code."; + meta.url = "http://MinecraftForge.net"; + meta.updateUrl = "http://MinecraftForge.net/forum/index.php/topic,5.0.html"; + meta.screenshots = new String[0]; + meta.logoFile = "/forge_logo.png"; + + Configuration config = null; + File cfgFile = new File(Loader.instance().getConfigDir(), "forge.cfg"); + try + { + config = new Configuration(cfgFile); + } + catch (Exception e) + { + System.out.println("Error loading forge.cfg, deleting file and resetting: "); + e.printStackTrace(); + + if (cfgFile.exists()) + cfgFile.delete(); + + config = new Configuration(cfgFile); + } + if (!config.isChild) + { + config.load(); + Property enableGlobalCfg = config.get(Configuration.CATEGORY_GENERAL, "enableGlobalConfig", false); + if (enableGlobalCfg.getBoolean(false)) + { + Configuration.enableGlobalConfig(); + } + } + Property prop; + prop = config.get(Configuration.CATEGORY_GENERAL, "clumpingThreshold", 64); + prop.comment = "Controls the number threshold at which Packet51 is preferred over Packet52, default and minimum 64, maximum 1024"; + clumpingThreshold = prop.getInt(64); + if (clumpingThreshold > 1024 || clumpingThreshold < 64) + { + clumpingThreshold = 64; + prop.set(64); + } + + prop = config.get(Configuration.CATEGORY_GENERAL, "removeErroringEntities", false); + prop.comment = "Set this to just remove any TileEntity that throws a error in there update method instead of closing the server and reporting a crash log. BE WARNED THIS COULD SCREW UP EVERYTHING USE SPARINGLY WE ARE NOT RESPONSIBLE FOR DAMAGES."; + removeErroringEntities = prop.getBoolean(false); + + if (removeErroringEntities) + { + FMLLog.warning("Enabling removal of erroring Entities - USE AT YOUR OWN RISK"); + } + + prop = config.get(Configuration.CATEGORY_GENERAL, "removeErroringTileEntities", false); + prop.comment = "Set this to just remove any TileEntity that throws a error in there update method instead of closing the server and reporting a crash log. BE WARNED THIS COULD SCREW UP EVERYTHING USE SPARINGLY WE ARE NOT RESPONSIBLE FOR DAMAGES."; + removeErroringTileEntities = prop.getBoolean(false); + + if (removeErroringTileEntities) + { + FMLLog.warning("Enabling removal of erroring Tile Entities - USE AT YOUR OWN RISK"); + } + + //prop = config.get(Configuration.CATEGORY_GENERAL, "disableStitchedFileSaving", true); + //prop.comment = "Set this to just disable the texture stitcher from writing the 'debug.stitched_{name}.png file to disc. Just a small performance tweak. Default: true"; + //disableStitchedFileSaving = prop.getBoolean(true); + + prop = config.get(Configuration.CATEGORY_GENERAL, "fullBoundingBoxLadders", false); + prop.comment = "Set this to check the entire entity's collision bounding box for ladders instead of just the block they are in. Causes noticable differences in mechanics so default is vanilla behavior. Default: false"; + fullBoundingBoxLadders = prop.getBoolean(false); + + prop = config.get(Configuration.CATEGORY_GENERAL, "forceDuplicateFluidBlockCrash", true); + prop.comment = "Set this to force a crash if more than one block attempts to link back to the same Fluid. Enabled by default."; + forceDuplicateFluidBlockCrash = prop.getBoolean(true); + + if (!forceDuplicateFluidBlockCrash) + { + FMLLog.warning("Disabling forced crashes on duplicate Fluid Blocks - USE AT YOUR OWN RISK"); + } + + prop = config.get(Configuration.CATEGORY_GENERAL, "biomeSkyBlendRange", new int[] { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34 }); + prop.comment = "Control the range of sky blending for colored skies in biomes."; + blendRanges = prop.getIntList(); + + prop = config.get(Configuration.CATEGORY_GENERAL, "zombieBaseSummonChance", 0.1); + prop.comment = "Base zombie summoning spawn chance. Allows changing the bonus zombie summoning mechanic."; + zombieSummonBaseChance = prop.getDouble(0.1); + + prop = config.get(Configuration.CATEGORY_GENERAL, "zombieBabyChance", 0.05); + prop.comment = "Chance that a zombie (or subclass) is a baby. Allows changing the zombie spawning mechanic."; + zombieBabyChance = (float) prop.getDouble(0.05); + + prop = config.get(CATEGORY_GENERAL, "sortRecipies", shouldSortRecipies); + prop.comment = "Set to true to enable the post initlization sorting of crafting recipes using Froge's sorter. May cause desyncing on conflicting recipies. ToDo: Set to true by default in 1.7"; + shouldSortRecipies = prop.getBoolean(shouldSortRecipies); + + prop = config.get(CATEGORY_GENERAL, "disableVersionCheck", disableVersionCheck); + prop.comment = "Set to true to disable Forge's version check mechanics, Forge queries a small json file on our server for version information. For more details see the ForgeVersion class in our github."; + disableVersionCheck = prop.getBoolean(disableVersionCheck); + + if (config.hasChanged()) + { + config.save(); + } + } + + @Override + public boolean registerBus(EventBus bus, LoadController controller) + { + bus.register(this); + return true; + } + + @Subscribe + public void modConstruction(FMLConstructionEvent evt) + { + NetworkRegistry.INSTANCE.register(this, this.getClass(), null, evt.getASMHarvestedData()); + ForgeNetworkHandler.registerChannel(this, evt.getSide()); + } + + @Subscribe + public void preInit(FMLPreInitializationEvent evt) + { + MinecraftForge.EVENT_BUS.register(MinecraftForge.INTERNAL_HANDLER); + ForgeChunkManager.captureConfig(evt.getModConfigurationDirectory()); + } + + @Subscribe + public void postInit(FMLPostInitializationEvent evt) + { + BiomeDictionary.registerAllBiomesAndGenerateEvents(); + ForgeChunkManager.loadConfiguration(); + } + + @Subscribe + public void onAvalible(FMLLoadCompleteEvent evt) + { + if (shouldSortRecipies) + { + RecipeSorter.sortCraftManager(); + } + } + + @Subscribe + public void serverStarting(FMLServerStartingEvent evt) + { + evt.registerServerCommand(new ForgeCommand(evt.getServer())); + } + @Override + public NBTTagCompound getDataForWriting(SaveHandler handler, WorldInfo info) + { + NBTTagCompound forgeData = new NBTTagCompound(); + NBTTagCompound dimData = DimensionManager.saveDimensionDataMap(); + forgeData.setTag("DimensionData", dimData); + return forgeData; + } + + @Override + public void readData(SaveHandler handler, WorldInfo info, Map propertyMap, NBTTagCompound tag) + { + if (tag.hasKey("DimensionData")) + { + DimensionManager.loadDimensionDataMap(tag.hasKey("DimensionData") ? tag.getCompoundTag("DimensionData") : null); + } + } + + @Subscribe + public void mappingChanged(FMLModIdMappingEvent evt) + { + Blocks.fire.rebuildFireInfo(); + } + + + @Override + public File getSource() + { + return FMLForgePlugin.forgeLocation; + } + @Override + public Class getCustomResourcePackClass() + { + if (getSource().isDirectory()) + { + return FMLFolderResourcePack.class; + } + else + { + return FMLFileResourcePack.class; + } + } + + @Override + public List getOwnedPackages() + { + // All the packages which are part of forge. Only needs updating if new logic is added + // that requires event handlers + return ImmutableList.of( + "net.minecraftforge.classloading", + "net.minecraftforge.client", + "net.minecraftforge.client.event", + "net.minecraftforge.client.event.sound", + "net.minecraftforge.client.model", + "net.minecraftforge.client.model.obj", + "net.minecraftforge.client.model.techne", + "net.minecraftforge.common", + "net.minecraftforge.common.config", + "net.minecraftforge.common.network", + "net.minecraftforge.common.util", + "net.minecraftforge.event", + "net.minecraftforge.event.brewing", + "net.minecraftforge.event.entity", + "net.minecraftforge.event.entity.item", + "net.minecraftforge.event.entity.living", + "net.minecraftforge.event.entity.minecart", + "net.minecraftforge.event.entity.player", + "net.minecraftforge.event.terraingen", + "net.minecraftforge.event.world", + "net.minecraftforge.fluids", + "net.minecraftforge.oredict", + "net.minecraftforge.server", + "net.minecraftforge.server.command", + "net.minecraftforge.transformers" + ); + } +} diff --git a/src/main/java/net/minecraftforge/common/ForgeVersion.java b/src/main/java/net/minecraftforge/common/ForgeVersion.java new file mode 100644 index 0000000..698ccc0 --- /dev/null +++ b/src/main/java/net/minecraftforge/common/ForgeVersion.java @@ -0,0 +1,149 @@ +/** + * This software is provided under the terms of the Minecraft Forge Public + * License v1.0. + */ + +package net.minecraftforge.common; +import static net.minecraftforge.common.ForgeVersion.Status.*; + +import java.io.InputStream; +import java.net.URL; +import java.util.Map; + +import com.google.common.io.ByteStreams; +import com.google.gson.Gson; + +import cpw.mods.fml.common.versioning.ArtifactVersion; +import cpw.mods.fml.common.versioning.DefaultArtifactVersion; + +public class ForgeVersion +{ + //This number is incremented every time we remove deprecated code/major API changes, never reset + public static final int majorVersion = 10; + //This number is incremented every minecraft release, never reset + public static final int minorVersion = 12; + //This number is incremented every time a interface changes or new major feature is added, and reset every Minecraft version + public static final int revisionVersion = 1; + //This number is incremented every time Jenkins builds Forge, and never reset. Should always be 0 in the repo code. + public static final int buildVersion = 0; + + private static Status status = PENDING; + private static String target = null; + + public static int getMajorVersion() + { + return majorVersion; + } + + public static int getMinorVersion() + { + return minorVersion; + } + + public static int getRevisionVersion() + { + return revisionVersion; + } + + public static int getBuildVersion() + { + return buildVersion; + } + + public static Status getStatus() + { + return status; + } + + public static String getTarget() + { + return target; + } + + public static String getVersion() + { + return String.format("%d.%d.%d.%d", majorVersion, minorVersion, revisionVersion, buildVersion); + } + + public static enum Status + { + PENDING, + FAILED, + UP_TO_DATE, + OUTDATED, + AHEAD, + BETA, + BETA_OUTDATED + } + + public static void startVersionCheck() + { + new Thread("Forge Version Check") + { + @SuppressWarnings("unchecked") + @Override + public void run() + { + try + { + URL url = new URL("http://files.minecraftforge.net/maven/net/minecraftforge/forge/promotions_slim.json"); + InputStream con = url.openStream(); + String data = new String(ByteStreams.toByteArray(con)); + con.close(); + + Map json = new Gson().fromJson(data, Map.class); + //String homepage = (String)json.get("homepage"); + Map promos = (Map)json.get("promos"); + + String rec = promos.get(MinecraftForge.MC_VERSION + "-recommended"); + String lat = promos.get(MinecraftForge.MC_VERSION + "-latest"); + ArtifactVersion current = new DefaultArtifactVersion(getVersion()); + + if (rec != null) + { + ArtifactVersion recommended = new DefaultArtifactVersion(rec); + int diff = recommended.compareTo(current); + + if (diff == 0) + status = UP_TO_DATE; + else if (diff < 0) + { + status = AHEAD; + if (lat != null) + { + if (current.compareTo(new DefaultArtifactVersion(lat)) < 0) + { + status = OUTDATED; + target = lat; + } + } + } + else + { + status = OUTDATED; + target = rec; + } + } + else if (lat != null) + { + if (current.compareTo(new DefaultArtifactVersion(lat)) < 0) + { + status = BETA_OUTDATED; + target = lat; + } + else + status = BETA; + } + else + status = BETA; + } + catch (Exception e) + { + e.printStackTrace(); + status = FAILED; + } + } + }.start(); + } +} + diff --git a/src/main/java/net/minecraftforge/common/IExtendedEntityProperties.java b/src/main/java/net/minecraftforge/common/IExtendedEntityProperties.java new file mode 100644 index 0000000..2270cb2 --- /dev/null +++ b/src/main/java/net/minecraftforge/common/IExtendedEntityProperties.java @@ -0,0 +1,37 @@ +package net.minecraftforge.common; + +import net.minecraft.entity.Entity; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +/** + * Allows for custom entity data and logic to be hooked to existing entity classes. + * + * @author cpw, mithion + * + */ +public interface IExtendedEntityProperties { + /** + * Called when the entity that this class is attached to is saved. + * Any custom entity data that needs saving should be saved here. + * @param compound The compound to save to. + */ + public void saveNBTData(NBTTagCompound compound); + + /** + * Called when the entity that this class is attached to is loaded. + * In order to hook into this, you will need to subscribe to the EntityConstructing event. + * Otherwise, you will need to initialize manually. + * @param compound The compound to load from. + */ + public void loadNBTData(NBTTagCompound compound); + + /** + * Used to initialize the extended properties with the entity that this is attached to, as well + * as the world object. + * Called automatically if you register with the EntityConstructing event. + * @param entity The entity that this extended properties is attached to + * @param world The world in which the entity exists + */ + public void init(Entity entity, World world); +} diff --git a/src/main/java/net/minecraftforge/common/IMinecartCollisionHandler.java b/src/main/java/net/minecraftforge/common/IMinecartCollisionHandler.java new file mode 100644 index 0000000..a7003f1 --- /dev/null +++ b/src/main/java/net/minecraftforge/common/IMinecartCollisionHandler.java @@ -0,0 +1,50 @@ +package net.minecraftforge.common; + +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityMinecart; + +/** + * This class defines a replacement for the default minecart collision code. + * Only one handler can be registered at a time. It it registered with EntityMinecart.registerCollisionHandler(). + * If you use this, make it a configuration option. + * @author CovertJaguar + */ +public interface IMinecartCollisionHandler +{ + + /** + * This basically replaces the function of the same name in EnityMinecart. + * Code in IMinecartHooks.applyEntityCollisionHook is still run. + * @param cart The cart that called the collision. + * @param other The object it collided with. + */ + public void onEntityCollision(EntityMinecart cart, Entity other); + + /** + * This function replaced the function of the same name in EntityMinecart. + * It is used to define whether minecarts collide with specific entities, + * for example items. + * @param cart The cart for which the collision box was requested. + * @param other The entity requesting the collision box. + * @return The collision box or null. + */ + public AxisAlignedBB getCollisionBox(EntityMinecart cart, Entity other); + + /** + * This function is used to define the box used for detecting minecart collisions. + * It is generally bigger that the normal collision box. + * @param cart The cart for which the collision box was requested. + * @return The collision box, cannot be null. + */ + public AxisAlignedBB getMinecartCollisionBox(EntityMinecart cart); + + /** + * This function replaces the function of the same name in EntityMinecart. + * It defines whether minecarts are solid to the player. + * @param cart The cart for which the bounding box was requested. + * @return The bounding box or null. + */ + public AxisAlignedBB getBoundingBox(EntityMinecart cart); +} + diff --git a/src/main/java/net/minecraftforge/common/IPlantable.java b/src/main/java/net/minecraftforge/common/IPlantable.java new file mode 100644 index 0000000..1b61222 --- /dev/null +++ b/src/main/java/net/minecraftforge/common/IPlantable.java @@ -0,0 +1,11 @@ +package net.minecraftforge.common; + +import net.minecraft.block.Block; +import net.minecraft.world.IBlockAccess; + +public interface IPlantable +{ + public EnumPlantType getPlantType(IBlockAccess world, int x, int y, int z); + public Block getPlant(IBlockAccess world, int x, int y, int z); + public int getPlantMetadata(IBlockAccess world, int x, int y, int z); +} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/common/IShearable.java b/src/main/java/net/minecraftforge/common/IShearable.java new file mode 100644 index 0000000..7e40580 --- /dev/null +++ b/src/main/java/net/minecraftforge/common/IShearable.java @@ -0,0 +1,51 @@ +package net.minecraftforge.common; + +import java.util.ArrayList; + +import net.minecraft.item.ItemStack; +import net.minecraft.world.IBlockAccess; + +/** + * + * This allows for mods to create there own Shear-like items + * and have them interact with Blocks/Entities without extra work. + * Also, if your block/entity supports the Shears, this allows you + * to support mod-shears as well. + * + */ +public interface IShearable +{ + /** + * Checks if the object is currently shearable + * Example: Sheep return false when they have no wool + * + * @param item The itemstack that is being used, Possible to be null + * @param world The current world + * @param x The X Position + * @param y The Y Position + * @param z The Z Position + * @return If this is shearable, and onSheared should be called. + */ + public boolean isShearable(ItemStack item, IBlockAccess world, int x, int y, int z); + + /** + * Performs the shear function on this object. + * This is called for both client, and server. + * The object should perform all actions related to being sheared, + * except for dropping of the items. + * + * Returns a list of items that resulted from the shearing process. + * + * For entities, they should trust there internal location information + * over the values passed into this function. + * + * @param item The itemstack that is being used, Possible to be null + * @param world The current world + * @param x The X Position + * @param y The Y Position + * @param z The Z Position + * @param fortune The fortune level of the shears being used + * @return A ArrayList containing all items from this shearing. Possible to be null. + */ + public ArrayList onSheared(ItemStack item, IBlockAccess world, int x, int y, int z, int fortune); +} diff --git a/src/main/java/net/minecraftforge/common/ISpecialArmor.java b/src/main/java/net/minecraftforge/common/ISpecialArmor.java new file mode 100644 index 0000000..d9fc44e --- /dev/null +++ b/src/main/java/net/minecraftforge/common/ISpecialArmor.java @@ -0,0 +1,319 @@ +/** + * This software is provided under the terms of the Minecraft Forge Public + * License v1.0. + */ + +package net.minecraftforge.common; + +import java.util.ArrayList; +import java.util.Arrays; + +import net.minecraft.util.DamageSource; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemArmor; +import net.minecraft.item.ItemStack; + +/** + * This interface is to be implemented by ItemArmor classes. It will allow to + * modify computation of damage and health loss. Computation will be called + * before the actual armor computation, which can then be cancelled. + * + * @see ItemArmor + */ +public interface ISpecialArmor +{ + /** + * Retrieves the modifiers to be used when calculating armor damage. + * + * Armor will higher priority will have damage applied to them before + * lower priority ones. If there are multiple pieces of armor with the + * same priority, damage will be distributed between them based on there + * absorption ratio. + * + * @param player The entity wearing the armor. + * @param armor The ItemStack of the armor item itself. + * @param source The source of the damage, which can be used to alter armor + * properties based on the type or source of damage. + * @param damage The total damage being applied to the entity + * @param slot The armor slot the item is in. + * @return A ArmorProperties instance holding information about how the armor effects damage. + */ + public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot); + + /** + * Get the displayed effective armor. + * + * @param player The player wearing the armor. + * @param armor The ItemStack of the armor item itself. + * @param slot The armor slot the item is in. + * @return The number of armor points for display, 2 per shield. + */ + public abstract int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot); + + /** + * Applies damage to the ItemStack. The mod is responsible for reducing the + * item durability and stack size. If the stack is depleted it will be cleaned + * up automatically. + * + * @param entity The entity wearing the armor + * @param stack The ItemStack of the armor item itself. + * @param source The source of the damage, which can be used to alter armor + * properties based on the type or source of damage. + * @param damage The amount of damage being applied to the armor + * @param slot The armor slot the item is in. + */ + public abstract void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot); + + public static class ArmorProperties implements Comparable + { + public int Priority = 0; + public int AbsorbMax = Integer.MAX_VALUE; + public double AbsorbRatio = 0; + public int Slot = 0; + private static final boolean DEBUG = false; //Only enable this if you wish to be spamed with debugging information. + //Left it in because I figured it'd be useful for modders developing custom armor. + + public ArmorProperties(int priority, double ratio, int max) + { + Priority = priority; + AbsorbRatio = ratio; + AbsorbMax = max; + } + + /** + * Gathers and applies armor reduction to damage being dealt to a entity. + * + * @param entity The Entity being damage + * @param inventory An array of armor items + * @param source The damage source type + * @param damage The total damage being done + * @return The left over damage that has not been absorbed by the armor + */ + public static float ApplyArmor(EntityLivingBase entity, ItemStack[] inventory, DamageSource source, double damage) + { + if (DEBUG) + { + System.out.println("Start: " + damage + " " + (damage * 25)); + } + damage *= 25; + ArrayList dmgVals = new ArrayList(); + for (int x = 0; x < inventory.length; x++) + { + ItemStack stack = inventory[x]; + if (stack == null) + { + continue; + } + ArmorProperties prop = null; + if (stack.getItem() instanceof ISpecialArmor) + { + ISpecialArmor armor = (ISpecialArmor)stack.getItem(); + prop = armor.getProperties(entity, stack, source, damage / 25D, x).copy(); + } + else if (stack.getItem() instanceof ItemArmor && !source.isUnblockable()) + { + ItemArmor armor = (ItemArmor)stack.getItem(); + prop = new ArmorProperties(0, armor.damageReduceAmount / 25D, armor.getMaxDamage() + 1 - stack.getItemDamage()); + } + if (prop != null) + { + prop.Slot = x; + dmgVals.add(prop); + } + } + if (dmgVals.size() > 0) + { + ArmorProperties[] props = dmgVals.toArray(new ArmorProperties[dmgVals.size()]); + StandardizeList(props, damage); + int level = props[0].Priority; + double ratio = 0; + for (ArmorProperties prop : props) + { + if (level != prop.Priority) + { + damage -= (damage * ratio); + ratio = 0; + level = prop.Priority; + } + ratio += prop.AbsorbRatio; + + double absorb = damage * prop.AbsorbRatio; + if (absorb > 0) + { + ItemStack stack = inventory[prop.Slot]; + int itemDamage = (int)(absorb / 25D < 1 ? 1 : absorb / 25D); + if (stack.getItem() instanceof ISpecialArmor) + { + ((ISpecialArmor)stack.getItem()).damageArmor(entity, stack, source, itemDamage, prop.Slot); + } + else + { + if (DEBUG) + { + System.out.println("Item: " + stack.toString() + " Absorbed: " + (absorb / 25D) + " Damaged: " + itemDamage); + } + stack.damageItem(itemDamage, entity); + } + if (stack.stackSize <= 0) + { + /*if (entity instanceof EntityPlayer) + { + stack.onItemDestroyedByUse((EntityPlayer)entity); + }*/ + inventory[prop.Slot] = null; + } + } + } + damage -= (damage * ratio); + } + if (DEBUG) + { + System.out.println("Return: " + (int)(damage / 25.0F) + " " + damage); + } + return (float)(damage / 25.0F); + } + + /** + * Sorts and standardizes the distribution of damage over armor. + * + * @param armor The armor information + * @param damage The total damage being received + */ + private static void StandardizeList(ArmorProperties[] armor, double damage) + { + Arrays.sort(armor); + + int start = 0; + double total = 0; + int priority = armor[0].Priority; + int pStart = 0; + boolean pChange = false; + boolean pFinished = false; + + if (DEBUG) + { + for (ArmorProperties prop : armor) + { + System.out.println(prop); + } + System.out.println("========================"); + } + + for (int x = 0; x < armor.length; x++) + { + total += armor[x].AbsorbRatio; + if (x == armor.length - 1 || armor[x].Priority != priority) + { + if (armor[x].Priority != priority) + { + total -= armor[x].AbsorbRatio; + x--; + pChange = true; + } + if (total > 1) + { + for (int y = start; y <= x; y++) + { + double newRatio = armor[y].AbsorbRatio / total; + if (newRatio * damage > armor[y].AbsorbMax) + { + armor[y].AbsorbRatio = (double)armor[y].AbsorbMax / damage; + total = 0; + for (int z = pStart; z <= y; z++) + { + total += armor[z].AbsorbRatio; + } + start = y + 1; + x = y; + break; + } + else + { + armor[y].AbsorbRatio = newRatio; + pFinished = true; + } + } + if (pChange && pFinished) + { + damage -= (damage * total); + total = 0; + start = x + 1; + priority = armor[start].Priority; + pStart = start; + pChange = false; + pFinished = false; + if (damage <= 0) + { + for (int y = x + 1; y < armor.length; y++) + { + armor[y].AbsorbRatio = 0; + } + break; + } + } + } + else + { + for (int y = start; y <= x; y++) + { + total -= armor[y].AbsorbRatio; + if (damage * armor[y].AbsorbRatio > armor[y].AbsorbMax) + { + armor[y].AbsorbRatio = (double)armor[y].AbsorbMax / damage; + } + total += armor[y].AbsorbRatio; + } + damage -= (damage * total); + total = 0; + if (x != armor.length - 1) + { + start = x + 1; + priority = armor[start].Priority; + pStart = start; + pChange = false; + if (damage <= 0) + { + for (int y = x + 1; y < armor.length; y++) + { + armor[y].AbsorbRatio = 0; + } + break; + } + } + } + } + } + if (DEBUG) + { + for (ArmorProperties prop : armor) + { + System.out.println(prop); + } + } + } + + @Override + public int compareTo(ArmorProperties o) + { + if (o.Priority != Priority) + { + return o.Priority - Priority; + } + double left = ( AbsorbRatio == 0 ? 0 : AbsorbMax * 100.0D / AbsorbRatio); + double right = (o.AbsorbRatio == 0 ? 0 : o.AbsorbMax * 100.0D / o.AbsorbRatio); + return (int)(left - right); + } + + @Override + public String toString() + { + return String.format("%d, %d, %f, %d", Priority, AbsorbMax, AbsorbRatio, (AbsorbRatio == 0 ? 0 : (int)(AbsorbMax * 100.0D / AbsorbRatio))); + } + + public ArmorProperties copy() + { + return new ArmorProperties(Priority, AbsorbRatio, AbsorbMax); + } + } +} diff --git a/src/main/java/net/minecraftforge/common/MinecraftForge.java b/src/main/java/net/minecraftforge/common/MinecraftForge.java new file mode 100644 index 0000000..37dd044 --- /dev/null +++ b/src/main/java/net/minecraftforge/common/MinecraftForge.java @@ -0,0 +1,61 @@ +package net.minecraftforge.common; + +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.eventhandler.EventBus; +import net.minecraft.crash.CrashReport; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.ForgeHooks.SeedEntry; +import net.minecraftforge.oredict.OreDictionary; + +public class MinecraftForge +{ + /** + * The core Forge EventBusses, all events for Forge will be fired on these, + * you should use this to register all your listeners. + * This replaces every register*Handler() function in the old version of Forge. + * TERRAIN_GEN_BUS for terrain gen events + * ORE_GEN_BUS for ore gen events + * EVENT_BUS for everything else + */ + public static final EventBus EVENT_BUS = new EventBus(); + public static final EventBus TERRAIN_GEN_BUS = new EventBus(); + public static final EventBus ORE_GEN_BUS = new EventBus(); + public static final String MC_VERSION = "1.7.2"; + + static final ForgeInternalHandler INTERNAL_HANDLER = new ForgeInternalHandler(); + + /** + * Register a new seed to be dropped when breaking tall grass. + * + * @param seed The item to drop as a seed. + * @param weight The relative probability of the seeds, + * where wheat seeds are 10. + */ + public static void addGrassSeed(ItemStack seed, int weight) + { + ForgeHooks.seedList.add(new SeedEntry(seed, weight)); + } + + /** + * Method invoked by FML before any other mods are loaded. + */ + public static void initialize() + { + FMLLog.info("MinecraftForge v%s Initialized", ForgeVersion.getVersion()); + + OreDictionary.getOreName(0); + + if (!ForgeModContainer.disableVersionCheck) + { + ForgeVersion.startVersionCheck(); + } + + //Force these classes to be defined, Should prevent derp error hiding. + new CrashReport("ThisIsFake", new Exception("Not real")); + } + + public static String getBrandingVersion() + { + return "Minecraft Forge "+ ForgeVersion.getVersion(); + } +} diff --git a/src/main/java/net/minecraftforge/common/WorldSpecificSaveHandler.java b/src/main/java/net/minecraftforge/common/WorldSpecificSaveHandler.java new file mode 100644 index 0000000..1032f1a --- /dev/null +++ b/src/main/java/net/minecraftforge/common/WorldSpecificSaveHandler.java @@ -0,0 +1,46 @@ +package net.minecraftforge.common; + +import java.io.File; + +import net.minecraft.world.chunk.storage.IChunkLoader; +import net.minecraft.world.storage.IPlayerFileData; +import net.minecraft.world.storage.ISaveHandler; +import net.minecraft.world.MinecraftException; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.storage.WorldInfo; +import net.minecraft.world.WorldProvider; +import net.minecraft.world.WorldServer; + +//Class used internally to provide the world specific data directories. + +public class WorldSpecificSaveHandler implements ISaveHandler +{ + private WorldServer world; + private ISaveHandler parent; + private File dataDir; + + public WorldSpecificSaveHandler(WorldServer world, ISaveHandler parent) + { + this.world = world; + this.parent = parent; + dataDir = new File(world.getChunkSaveLocation(), "data"); + dataDir.mkdirs(); + } + + @Override public WorldInfo loadWorldInfo() { return parent.loadWorldInfo(); } + @Override public void checkSessionLock() throws MinecraftException { parent.checkSessionLock(); } + @Override public IChunkLoader getChunkLoader(WorldProvider var1) { return parent.getChunkLoader(var1); } + @Override public void saveWorldInfoWithPlayer(WorldInfo var1, NBTTagCompound var2) { parent.saveWorldInfoWithPlayer(var1, var2); } + @Override public void saveWorldInfo(WorldInfo var1){ parent.saveWorldInfo(var1); } + @Override public IPlayerFileData getSaveHandler() { return parent.getSaveHandler(); } + @Override public void flush() { parent.flush(); } + @Override public String getWorldDirectoryName() { return parent.getWorldDirectoryName(); } + @Override public File getWorldDirectory() { return parent.getWorldDirectory(); } + + @Override + public File getMapFileFromName(String name) + { + return new File(dataDir, name + ".dat"); + } + +} diff --git a/src/main/java/net/minecraftforge/common/config/ConfigCategory.java b/src/main/java/net/minecraftforge/common/config/ConfigCategory.java new file mode 100644 index 0000000..249365d --- /dev/null +++ b/src/main/java/net/minecraftforge/common/config/ConfigCategory.java @@ -0,0 +1,271 @@ +package net.minecraftforge.common.config; + +import static net.minecraftforge.common.config.Configuration.NEW_LINE; +import static net.minecraftforge.common.config.Configuration.allowedProperties; + +import java.io.BufferedWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.base.Splitter; + +public class ConfigCategory implements Map +{ + private String name; + private String comment; + private ArrayList children = new ArrayList(); + private Map properties = new TreeMap(); + public final ConfigCategory parent; + private boolean changed = false; + + public ConfigCategory(String name) + { + this(name, null); + } + + public ConfigCategory(String name, ConfigCategory parent) + { + this.name = name; + this.parent = parent; + if (parent != null) + { + parent.children.add(this); + } + } + + @Override + public boolean equals(Object obj) + { + if (obj instanceof ConfigCategory) + { + ConfigCategory cat = (ConfigCategory)obj; + return name.equals(cat.name) && children.equals(cat.children); + } + + return false; + } + + public String getQualifiedName() + { + return getQualifiedName(name, parent); + } + + public static String getQualifiedName(String name, ConfigCategory parent) + { + return (parent == null ? name : parent.getQualifiedName() + Configuration.CATEGORY_SPLITTER + name); + } + + public ConfigCategory getFirstParent() + { + return (parent == null ? this : parent.getFirstParent()); + } + + public boolean isChild() + { + return parent != null; + } + + public Map getValues() + { + return ImmutableMap.copyOf(properties); + } + + public void setComment(String comment) + { + this.comment = comment; + } + + public boolean containsKey(String key) + { + return properties.containsKey(key); + } + + public Property get(String key) + { + return properties.get(key); + } + + private void write(BufferedWriter out, String... data) throws IOException + { + write(out, true, data); + } + + private void write(BufferedWriter out, boolean new_line, String... data) throws IOException + { + for (int x = 0; x < data.length; x++) + { + out.write(data[x]); + } + if (new_line) out.write(NEW_LINE); + } + + public void write(BufferedWriter out, int indent) throws IOException + { + String pad0 = getIndent(indent); + String pad1 = getIndent(indent + 1); + String pad2 = getIndent(indent + 2); + + write(out, pad0, "####################"); + write(out, pad0, "# ", name); + + if (comment != null) + { + write(out, pad0, "#==================="); + Splitter splitter = Splitter.onPattern("\r?\n"); + + for (String line : splitter.split(comment)) + { + write(out, pad0, "# ", line); + } + } + + write(out, pad0, "####################", NEW_LINE); + + if (!allowedProperties.matchesAllOf(name)) + { + name = '"' + name + '"'; + } + + write(out, pad0, name, " {"); + + Property[] props = properties.values().toArray(new Property[properties.size()]); + + for (int x = 0; x < props.length; x++) + { + Property prop = props[x]; + + if (prop.comment != null) + { + if (x != 0) + { + out.newLine(); + } + + Splitter splitter = Splitter.onPattern("\r?\n"); + for (String commentLine : splitter.split(prop.comment)) + { + write(out, pad1, "# ", commentLine); + } + } + + String propName = prop.getName(); + + if (!allowedProperties.matchesAllOf(propName)) + { + propName = '"' + propName + '"'; + } + + if (prop.isList()) + { + char type = prop.getType().getID(); + + write(out, pad1, String.valueOf(type), ":", propName, " <"); + + for (String line : prop.getStringList()) + { + write(out, pad2, line); + } + + write(out, pad1, " >"); + } + else if (prop.getType() == null) + { + write(out, pad1, propName, "=", prop.getString()); + } + else + { + char type = prop.getType().getID(); + write(out, pad1, String.valueOf(type), ":", propName, "=", prop.getString()); + } + } + + for (ConfigCategory child : children) + { + child.write(out, indent + 1); + } + + write(out, pad0, "}", NEW_LINE); + } + + private String getIndent(int indent) + { + StringBuilder buf = new StringBuilder(""); + for (int x = 0; x < indent; x++) + { + buf.append(" "); + } + return buf.toString(); + } + + public boolean hasChanged() + { + if (changed) return true; + for (Property prop : properties.values()) + { + if (prop.hasChanged()) return true; + } + return false; + } + + void resetChangedState() + { + changed = false; + for (Property prop : properties.values()) + { + prop.resetChangedState(); + } + } + + + //Map bouncer functions for compatibility with older mods, to be removed once all mods stop using it. + @Override public int size(){ return properties.size(); } + @Override public boolean isEmpty() { return properties.isEmpty(); } + @Override public boolean containsKey(Object key) { return properties.containsKey(key); } + @Override public boolean containsValue(Object value){ return properties.containsValue(value); } + @Override public Property get(Object key) { return properties.get(key); } + @Override public Property put(String key, Property value) + { + changed = true; + return properties.put(key, value); + } + @Override public Property remove(Object key) + { + changed = true; + return properties.remove(key); + } + @Override public void putAll(Map m) + { + changed = true; + properties.putAll(m); + } + @Override public void clear() + { + changed = true; + properties.clear(); + } + @Override public Set keySet() { return properties.keySet(); } + @Override public Collection values() { return properties.values(); } + + @Override //Immutable copy, changes will NOT be reflected in this category + public Set> entrySet() + { + return ImmutableSet.copyOf(properties.entrySet()); + } + + public Set getChildren(){ return ImmutableSet.copyOf(children); } + + public void removeChild(ConfigCategory child) + { + if (children.contains(child)) + { + children.remove(child); + changed = true; + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/common/config/Configuration.java b/src/main/java/net/minecraftforge/common/config/Configuration.java new file mode 100644 index 0000000..e8c86e5 --- /dev/null +++ b/src/main/java/net/minecraftforge/common/config/Configuration.java @@ -0,0 +1,794 @@ +/** + * This software is provided under the terms of the Minecraft Forge Public + * License v1.0. + */ + +package net.minecraftforge.common.config; + +import static net.minecraftforge.common.config.Property.Type.BOOLEAN; +import static net.minecraftforge.common.config.Property.Type.DOUBLE; +import static net.minecraftforge.common.config.Property.Type.INTEGER; +import static net.minecraftforge.common.config.Property.Type.STRING; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.io.PushbackInputStream; +import java.io.Reader; +import java.util.ArrayList; +import java.util.Locale; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import com.google.common.base.CharMatcher; +import com.google.common.collect.ImmutableSet; + +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.relauncher.FMLInjectionData; + +/** + * This class offers advanced configurations capabilities, allowing to provide + * various categories for configuration variables. + */ +public class Configuration +{ + public static final String CATEGORY_GENERAL = "general"; + public static final String ALLOWED_CHARS = "._-"; + public static final String DEFAULT_ENCODING = "UTF-8"; + public static final String CATEGORY_SPLITTER = "."; + public static final String NEW_LINE; + private static final Pattern CONFIG_START = Pattern.compile("START: \"([^\\\"]+)\""); + private static final Pattern CONFIG_END = Pattern.compile("END: \"([^\\\"]+)\""); + public static final CharMatcher allowedProperties = CharMatcher.JAVA_LETTER_OR_DIGIT.or(CharMatcher.anyOf(ALLOWED_CHARS)); + private static Configuration PARENT = null; + + File file; + + private Map categories = new TreeMap(); + private Map children = new TreeMap(); + + private boolean caseSensitiveCustomCategories; + public String defaultEncoding = DEFAULT_ENCODING; + private String fileName = null; + public boolean isChild = false; + private boolean changed = false; + + static + { + NEW_LINE = System.getProperty("line.separator"); + } + + public Configuration(){} + + /** + * Create a configuration file for the file given in parameter. + */ + public Configuration(File file) + { + this.file = file; + String basePath = ((File)(FMLInjectionData.data()[6])).getAbsolutePath().replace(File.separatorChar, '/').replace("/.", ""); + String path = file.getAbsolutePath().replace(File.separatorChar, '/').replace("/./", "/").replace(basePath, ""); + if (PARENT != null) + { + PARENT.setChild(path, this); + isChild = true; + } + else + { + fileName = path; + load(); + } + } + + public Configuration(File file, boolean caseSensitiveCustomCategories) + { + this(file); + this.caseSensitiveCustomCategories = caseSensitiveCustomCategories; + } + + public Property get(String category, String key, int defaultValue) + { + return get(category, key, defaultValue, null); + } + + public Property get(String category, String key, int defaultValue, String comment) + { + Property prop = get(category, key, Integer.toString(defaultValue), comment, INTEGER); + if (!prop.isIntValue()) + { + prop.set(defaultValue); + } + return prop; + } + + public Property get(String category, String key, boolean defaultValue) + { + return get(category, key, defaultValue, null); + } + + public Property get(String category, String key, boolean defaultValue, String comment) + { + Property prop = get(category, key, Boolean.toString(defaultValue), comment, BOOLEAN); + if (!prop.isBooleanValue()) + { + prop.set(defaultValue); + } + return prop; + } + + public Property get(String category, String key, double defaultValue) + { + return get(category, key, defaultValue, null); + } + + public Property get(String category, String key, double defaultValue, String comment) + { + Property prop = get(category, key, Double.toString(defaultValue), comment, DOUBLE); + if (!prop.isDoubleValue()) + { + prop.set(defaultValue); + } + return prop; + } + + public Property get(String category, String key, String defaultValue) + { + return get(category, key, defaultValue, null); + } + + public Property get(String category, String key, String defaultValue, String comment) + { + return get(category, key, defaultValue, comment, STRING); + } + + public Property get(String category, String key, String[] defaultValue) + { + return get(category, key, defaultValue, null); + } + + public Property get(String category, String key, String[] defaultValue, String comment) + { + return get(category, key, defaultValue, comment, STRING); + } + + public Property get(String category, String key, int[] defaultValue) + { + return get(category, key, defaultValue, null); + } + + public Property get(String category, String key, int[] defaultValue, String comment) + { + String[] values = new String[defaultValue.length]; + for (int i = 0; i < defaultValue.length; i++) + { + values[i] = Integer.toString(defaultValue[i]); + } + + Property prop = get(category, key, values, comment, INTEGER); + if (!prop.isIntList()) + { + prop.set(values); + } + + return prop; + } + + public Property get(String category, String key, double[] defaultValue) + { + return get(category, key, defaultValue, null); + } + + public Property get(String category, String key, double[] defaultValue, String comment) + { + String[] values = new String[defaultValue.length]; + for (int i = 0; i < defaultValue.length; i++) + { + values[i] = Double.toString(defaultValue[i]); + } + + Property prop = get(category, key, values, comment, DOUBLE); + + if (!prop.isDoubleList()) + { + prop.set(values); + } + + return prop; + } + + public Property get(String category, String key, boolean[] defaultValue) + { + return get(category, key, defaultValue, null); + } + + public Property get(String category, String key, boolean[] defaultValue, String comment) + { + String[] values = new String[defaultValue.length]; + for (int i = 0; i < defaultValue.length; i++) + { + values[i] = Boolean.toString(defaultValue[i]); + } + + Property prop = get(category, key, values, comment, BOOLEAN); + + if (!prop.isBooleanList()) + { + prop.set(values); + } + + return prop; + } + + public Property get(String category, String key, String defaultValue, String comment, Property.Type type) + { + if (!caseSensitiveCustomCategories) + { + category = category.toLowerCase(Locale.ENGLISH); + } + + ConfigCategory cat = getCategory(category); + + if (cat.containsKey(key)) + { + Property prop = cat.get(key); + + if (prop.getType() == null) + { + prop = new Property(prop.getName(), prop.getString(), type); + cat.put(key, prop); + } + + prop.comment = comment; + return prop; + } + else if (defaultValue != null) + { + Property prop = new Property(key, defaultValue, type); + prop.set(defaultValue); //Set and mark as dirty to signify it should save + cat.put(key, prop); + prop.comment = comment; + return prop; + } + else + { + return null; + } + } + + public Property get(String category, String key, String[] defaultValue, String comment, Property.Type type) + { + if (!caseSensitiveCustomCategories) + { + category = category.toLowerCase(Locale.ENGLISH); + } + + ConfigCategory cat = getCategory(category); + + if (cat.containsKey(key)) + { + Property prop = cat.get(key); + + if (prop.getType() == null) + { + prop = new Property(prop.getName(), prop.getString(), type); + cat.put(key, prop); + } + + prop.comment = comment; + + return prop; + } + else if (defaultValue != null) + { + Property prop = new Property(key, defaultValue, type); + prop.comment = comment; + cat.put(key, prop); + return prop; + } + else + { + return null; + } + } + + public boolean hasCategory(String category) + { + return categories.get(category) != null; + } + + public boolean hasKey(String category, String key) + { + ConfigCategory cat = categories.get(category); + return cat != null && cat.containsKey(key); + } + + public void load() + { + if (PARENT != null && PARENT != this) + { + return; + } + + BufferedReader buffer = null; + UnicodeInputStreamReader input = null; + try + { + if (file.getParentFile() != null) + { + file.getParentFile().mkdirs(); + } + + if (!file.exists() && !file.createNewFile()) + { + return; + } + + if (file.canRead()) + { + input = new UnicodeInputStreamReader(new FileInputStream(file), defaultEncoding); + defaultEncoding = input.getEncoding(); + buffer = new BufferedReader(input); + + String line; + ConfigCategory currentCat = null; + Property.Type type = null; + ArrayList tmpList = null; + int lineNum = 0; + String name = null; + + while (true) + { + lineNum++; + line = buffer.readLine(); + + if (line == null) + { + break; + } + + Matcher start = CONFIG_START.matcher(line); + Matcher end = CONFIG_END.matcher(line); + + if (start.matches()) + { + fileName = start.group(1); + categories = new TreeMap(); + continue; + } + else if (end.matches()) + { + fileName = end.group(1); + Configuration child = new Configuration(); + child.categories = categories; + this.children.put(fileName, child); + continue; + } + + int nameStart = -1, nameEnd = -1; + boolean skip = false; + boolean quoted = false; + + for (int i = 0; i < line.length() && !skip; ++i) + { + if (Character.isLetterOrDigit(line.charAt(i)) || ALLOWED_CHARS.indexOf(line.charAt(i)) != -1 || (quoted && line.charAt(i) != '"')) + { + if (nameStart == -1) + { + nameStart = i; + } + + nameEnd = i; + } + else if (Character.isWhitespace(line.charAt(i))) + { + // ignore space charaters + } + else + { + switch (line.charAt(i)) + { + case '#': + skip = true; + continue; + + case '"': + if (quoted) + { + quoted = false; + } + if (!quoted && nameStart == -1) + { + quoted = true; + } + break; + + case '{': + name = line.substring(nameStart, nameEnd + 1); + String qualifiedName = ConfigCategory.getQualifiedName(name, currentCat); + + ConfigCategory cat = categories.get(qualifiedName); + if (cat == null) + { + currentCat = new ConfigCategory(name, currentCat); + categories.put(qualifiedName, currentCat); + } + else + { + currentCat = cat; + } + name = null; + + break; + + case '}': + if (currentCat == null) + { + throw new RuntimeException(String.format("Config file corrupt, attepted to close to many categories '%s:%d'", fileName, lineNum)); + } + currentCat = currentCat.parent; + break; + + case '=': + name = line.substring(nameStart, nameEnd + 1); + + if (currentCat == null) + { + throw new RuntimeException(String.format("'%s' has no scope in '%s:%d'", name, fileName, lineNum)); + } + + Property prop = new Property(name, line.substring(i + 1), type, true); + i = line.length(); + + currentCat.put(name, prop); + + break; + + case ':': + type = Property.Type.tryParse(line.substring(nameStart, nameEnd + 1).charAt(0)); + nameStart = nameEnd = -1; + break; + + case '<': + if (tmpList != null) + { + throw new RuntimeException(String.format("Malformed list property \"%s:%d\"", fileName, lineNum)); + } + + name = line.substring(nameStart, nameEnd + 1); + + if (currentCat == null) + { + throw new RuntimeException(String.format("'%s' has no scope in '%s:%d'", name, fileName, lineNum)); + } + + tmpList = new ArrayList(); + + skip = true; + + break; + + case '>': + if (tmpList == null) + { + throw new RuntimeException(String.format("Malformed list property \"%s:%d\"", fileName, lineNum)); + } + + currentCat.put(name, new Property(name, tmpList.toArray(new String[tmpList.size()]), type)); + name = null; + tmpList = null; + type = null; + break; + + default: + throw new RuntimeException(String.format("Unknown character '%s' in '%s:%d'", line.charAt(i), fileName, lineNum)); + } + } + } + + if (quoted) + { + throw new RuntimeException(String.format("Unmatched quote in '%s:%d'", fileName, lineNum)); + } + else if (tmpList != null && !skip) + { + tmpList.add(line.trim()); + } + } + } + } + catch (IOException e) + { + e.printStackTrace(); + } + finally + { + if (buffer != null) + { + try + { + buffer.close(); + } catch (IOException e){} + } + if (input != null) + { + try + { + input.close(); + } catch (IOException e){} + } + } + + resetChangedState(); + } + + public void save() + { + if (PARENT != null && PARENT != this) + { + PARENT.save(); + return; + } + + try + { + if (file.getParentFile() != null) + { + file.getParentFile().mkdirs(); + } + + if (!file.exists() && !file.createNewFile()) + { + return; + } + + if (file.canWrite()) + { + FileOutputStream fos = new FileOutputStream(file); + BufferedWriter buffer = new BufferedWriter(new OutputStreamWriter(fos, defaultEncoding)); + + buffer.write("# Configuration file" + NEW_LINE + NEW_LINE); + + if (children.isEmpty()) + { + save(buffer); + } + else + { + for (Map.Entry entry : children.entrySet()) + { + buffer.write("START: \"" + entry.getKey() + "\"" + NEW_LINE); + entry.getValue().save(buffer); + buffer.write("END: \"" + entry.getKey() + "\"" + NEW_LINE + NEW_LINE); + } + } + + buffer.close(); + fos.close(); + } + } + catch (IOException e) + { + e.printStackTrace(); + } + } + + private void save(BufferedWriter out) throws IOException + { + for (ConfigCategory cat : categories.values()) + { + if (!cat.isChild()) + { + cat.write(out, 0); + out.newLine(); + } + } + } + + public ConfigCategory getCategory(String category) + { + ConfigCategory ret = categories.get(category); + + if (ret == null) + { + if (category.contains(CATEGORY_SPLITTER)) + { + String[] hierarchy = category.split("\\"+CATEGORY_SPLITTER); + ConfigCategory parent = categories.get(hierarchy[0]); + + if (parent == null) + { + parent = new ConfigCategory(hierarchy[0]); + categories.put(parent.getQualifiedName(), parent); + changed = true; + } + + for (int i = 1; i < hierarchy.length; i++) + { + String name = ConfigCategory.getQualifiedName(hierarchy[i], parent); + ConfigCategory child = categories.get(name); + + if (child == null) + { + child = new ConfigCategory(hierarchy[i], parent); + categories.put(name, child); + changed = true; + } + + ret = child; + parent = child; + } + } + else + { + ret = new ConfigCategory(category); + categories.put(category, ret); + changed = true; + } + } + + return ret; + } + + public void removeCategory(ConfigCategory category) + { + for (ConfigCategory child : category.getChildren()) + { + removeCategory(child); + } + + if (categories.containsKey(category.getQualifiedName())) + { + categories.remove(category.getQualifiedName()); + if (category.parent != null) + { + category.parent.removeChild(category); + } + changed = true; + } + } + + public void addCustomCategoryComment(String category, String comment) + { + if (!caseSensitiveCustomCategories) + category = category.toLowerCase(Locale.ENGLISH); + getCategory(category).setComment(comment); + } + + private void setChild(String name, Configuration child) + { + if (!children.containsKey(name)) + { + children.put(name, child); + changed = true; + } + else + { + Configuration old = children.get(name); + child.categories = old.categories; + child.fileName = old.fileName; + old.changed = true; + } + } + + public static void enableGlobalConfig() + { + PARENT = new Configuration(new File(Loader.instance().getConfigDir(), "global.cfg")); + PARENT.load(); + } + + public static class UnicodeInputStreamReader extends Reader + { + private final InputStreamReader input; + private final String defaultEnc; + + public UnicodeInputStreamReader(InputStream source, String encoding) throws IOException + { + defaultEnc = encoding; + String enc = encoding; + byte[] data = new byte[4]; + + PushbackInputStream pbStream = new PushbackInputStream(source, data.length); + int read = pbStream.read(data, 0, data.length); + int size = 0; + + int bom16 = (data[0] & 0xFF) << 8 | (data[1] & 0xFF); + int bom24 = bom16 << 8 | (data[2] & 0xFF); + int bom32 = bom24 << 8 | (data[3] & 0xFF); + + if (bom24 == 0xEFBBBF) + { + enc = "UTF-8"; + size = 3; + } + else if (bom16 == 0xFEFF) + { + enc = "UTF-16BE"; + size = 2; + } + else if (bom16 == 0xFFFE) + { + enc = "UTF-16LE"; + size = 2; + } + else if (bom32 == 0x0000FEFF) + { + enc = "UTF-32BE"; + size = 4; + } + else if (bom32 == 0xFFFE0000) //This will never happen as it'll be caught by UTF-16LE, + { //but if anyone ever runs across a 32LE file, i'd like to disect it. + enc = "UTF-32LE"; + size = 4; + } + + if (size < read) + { + pbStream.unread(data, size, read - size); + } + + this.input = new InputStreamReader(pbStream, enc); + } + + public String getEncoding() + { + return input.getEncoding(); + } + + @Override + public int read(char[] cbuf, int off, int len) throws IOException + { + return input.read(cbuf, off, len); + } + + @Override + public void close() throws IOException + { + input.close(); + } + } + + public boolean hasChanged() + { + if (changed) return true; + + for (ConfigCategory cat : categories.values()) + { + if (cat.hasChanged()) return true; + } + + for (Configuration child : children.values()) + { + if (child.hasChanged()) return true; + } + + return false; + } + + private void resetChangedState() + { + changed = false; + for (ConfigCategory cat : categories.values()) + { + cat.resetChangedState(); + } + + for (Configuration child : children.values()) + { + child.resetChangedState(); + } + } + + public Set getCategoryNames() + { + return ImmutableSet.copyOf(categories.keySet()); + } +} diff --git a/src/main/java/net/minecraftforge/common/config/Property.java b/src/main/java/net/minecraftforge/common/config/Property.java new file mode 100644 index 0000000..46de7c1 --- /dev/null +++ b/src/main/java/net/minecraftforge/common/config/Property.java @@ -0,0 +1,407 @@ +/** + * This software is provided under the terms of the Minecraft Forge Public + * License v1.0. + */ + +package net.minecraftforge.common.config; + +import java.util.ArrayList; + +public class Property +{ + public enum Type + { + STRING, + INTEGER, + BOOLEAN, + DOUBLE; + + private static Type[] values = {STRING, INTEGER, BOOLEAN, DOUBLE}; + + public static Type tryParse(char id) + { + for (int x = 0; x < values.length; x++) + { + if (values[x].getID() == id) + { + return values[x]; + } + } + + return STRING; + } + + public char getID() + { + return name().charAt(0); + } + } + + private String name; + private String value; + public String comment; + private String[] values; + + private final boolean wasRead; + private final boolean isList; + private final Type type; + private boolean changed = false; + + public Property() + { + wasRead = false; + type = null; + isList = false; + } + + public Property(String name, String value, Type type) + { + this(name, value, type, false); + } + + Property(String name, String value, Type type, boolean read) + { + setName(name); + this.value = value; + this.type = type; + wasRead = read; + isList = false; + } + + public Property(String name, String[] values, Type type) + { + this(name, values, type, false); + } + + Property(String name, String[] values, Type type, boolean read) + { + setName(name); + this.type = type; + this.values = values; + wasRead = read; + isList = true; + } + + /** + * Returns the value in this property as it's raw string. + * + * @return current value + */ + public String getString() + { + return value; + } + + /** + * Returns the value in this property as an integer, + * if the value is not a valid integer, it will return -1. + * + * @return The value + */ + public int getInt() + { + return getInt(-1); + } + + /** + * Returns the value in this property as an integer, + * if the value is not a valid integer, it will return the + * provided default. + * + * @param _default The default to provide if the current value is not a valid integer + * @return The value + */ + public int getInt(int _default) + { + try + { + return Integer.parseInt(value); + } + catch (NumberFormatException e) + { + return _default; + } + } + + /** + * Checks if the current value stored in this property can be converted to an integer. + * @return True if the type of the Property is an Integer + */ + public boolean isIntValue() + { + try + { + Integer.parseInt(value); + return true; + } + catch (NumberFormatException e) + { + return false; + } + } + + /** + * Returns the value in this property as a boolean, + * if the value is not a valid boolean, it will return the + * provided default. + * + * @param _default The default to provide + * @return The value as a boolean, or the default + */ + public boolean getBoolean(boolean _default) + { + if (isBooleanValue()) + { + return Boolean.parseBoolean(value); + } + else + { + return _default; + } + } + + /** + * Checks if the current value held by this property is a valid boolean value. + * @return True if it is a boolean value + */ + public boolean isBooleanValue() + { + return ("true".equals(value.toLowerCase()) || "false".equals(value.toLowerCase())); + } + + /** + * Checks if the current value held by this property is a valid double value. + * @return True if the value can be converted to an double + */ + public boolean isDoubleValue() + { + try + { + Double.parseDouble(value); + return true; + } + catch (NumberFormatException e) + { + return false; + } + } + + /** + * Returns the value in this property as a double, + * if the value is not a valid double, it will return the + * provided default. + * + * @param _default The default to provide if the current value is not a valid double + * @return The value + */ + public double getDouble(double _default) + { + try + { + return Double.parseDouble(value); + } + catch (NumberFormatException e) + { + return _default; + } + } + + public String[] getStringList() + { + return values; + } + + /** + * Returns the integer value of all values that can + * be parsed in the list. + * + * @return Array of length 0 if none of the values could be parsed. + */ + public int[] getIntList() + { + ArrayList nums = new ArrayList(); + + for (String value : values) + { + try + { + nums.add(Integer.parseInt(value)); + } + catch (NumberFormatException e){} + } + + int[] primitives = new int[nums.size()]; + + for (int i = 0; i < nums.size(); i++) + { + primitives[i] = nums.get(i); + } + + return primitives; + } + + /** + * Checks if all of the current values stored in this property can be converted to an integer. + * @return True if the type of the Property is an Integer List + */ + public boolean isIntList() + { + for (String value : values) + { + try + { + Integer.parseInt(value); + } + catch (NumberFormatException e) + { + return false; + } + } + return true; + } + + /** + * Returns the boolean value of all values that can + * be parsed in the list. + * + * @return Array of length 0 if none of the values could be parsed. + */ + public boolean[] getBooleanList() + { + ArrayList tmp = new ArrayList(); + for (String value : values) + { + try + { + tmp.add(Boolean.parseBoolean(value)); + } + catch (NumberFormatException e){} + } + + boolean[] primitives = new boolean[tmp.size()]; + + for (int i = 0; i < tmp.size(); i++) + { + primitives[i] = tmp.get(i); + } + + return primitives; + } + + /** + * Checks if all of current values stored in this property can be converted to a boolean. + * @return True if it is a boolean value + */ + public boolean isBooleanList() + { + for (String value : values) + { + if (!"true".equalsIgnoreCase(value) && !"false".equalsIgnoreCase(value)) + { + return false; + } + } + + return true; + } + + /** + * Returns the double value of all values that can + * be parsed in the list. + * + * @return Array of length 0 if none of the values could be parsed. + */ + public double[] getDoubleList() + { + ArrayList tmp = new ArrayList(); + for (String value : values) + { + try + { + tmp.add(Double.parseDouble(value)); + } + catch (NumberFormatException e) {} + } + + double[] primitives = new double[tmp.size()]; + + for (int i = 0; i < tmp.size(); i++) + { + primitives[i] = tmp.get(i); + } + + return primitives; + } + + /** + * Checks if all of the current values stored in this property can be converted to a double. + * @return True if the type of the Property is a double List + */ + public boolean isDoubleList() + { + for (String value : values) + { + try + { + Double.parseDouble(value); + } + catch (NumberFormatException e) + { + return false; + } + } + + return true; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + /** + * Determines if this config value was just created, or if it was read from the config file. + * This is useful for mods who auto-assign there blocks to determine if the ID returned is + * a configured one, or a automatically generated one. + * + * @return True if this property was loaded from the config file with a value + */ + public boolean wasRead() + { + return wasRead; + } + + public Type getType() + { + return type; + } + + public boolean isList() + { + return isList; + } + + public boolean hasChanged(){ return changed; } + void resetChangedState(){ changed = false; } + + public void set(String value) + { + this.value = value; + changed = true; + } + + public void set(String[] values) + { + this.values = values; + changed = true; + } + + public void set(int value){ set(Integer.toString(value)); } + public void set(boolean value){ set(Boolean.toString(value)); } + public void set(double value){ set(Double.toString(value)); } +} diff --git a/src/main/java/net/minecraftforge/common/network/DimensionMessageHandler.java b/src/main/java/net/minecraftforge/common/network/DimensionMessageHandler.java new file mode 100644 index 0000000..a3c0d8c --- /dev/null +++ b/src/main/java/net/minecraftforge/common/network/DimensionMessageHandler.java @@ -0,0 +1,26 @@ +package net.minecraftforge.common.network; + +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.SimpleChannelInboundHandler; +import net.minecraftforge.common.DimensionManager; +import net.minecraftforge.common.network.ForgeMessage.DimensionRegisterMessage; +import org.apache.logging.log4j.Level; +import cpw.mods.fml.common.FMLLog; + +public class DimensionMessageHandler extends SimpleChannelInboundHandler{ + @Override + protected void channelRead0(ChannelHandlerContext ctx, DimensionRegisterMessage msg) throws Exception + { + if (!DimensionManager.isDimensionRegistered(msg.dimensionId)) + { + DimensionManager.registerDimension(msg.dimensionId, msg.providerId); + } + } + @Override + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception + { + FMLLog.log(Level.ERROR, cause, "DimensionMessageHandler exception"); + super.exceptionCaught(ctx, cause); + } + +} diff --git a/src/main/java/net/minecraftforge/common/network/FluidIdRegistryMessageHandler.java b/src/main/java/net/minecraftforge/common/network/FluidIdRegistryMessageHandler.java new file mode 100644 index 0000000..e445fed --- /dev/null +++ b/src/main/java/net/minecraftforge/common/network/FluidIdRegistryMessageHandler.java @@ -0,0 +1,24 @@ +package net.minecraftforge.common.network; + +import net.minecraftforge.fluids.FluidRegistry; + +import org.apache.logging.log4j.Level; + +import cpw.mods.fml.common.FMLLog; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.SimpleChannelInboundHandler; + +public class FluidIdRegistryMessageHandler extends SimpleChannelInboundHandler { + @Override + protected void channelRead0(ChannelHandlerContext ctx, ForgeMessage.FluidIdMapMessage msg) throws Exception + { + FluidRegistry.initFluidIDs(msg.fluidIds); + } + @Override + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception + { + FMLLog.log(Level.ERROR, cause, "FluidIdRegistryMessageHandler exception"); + super.exceptionCaught(ctx, cause); + } + +} diff --git a/src/main/java/net/minecraftforge/common/network/ForgeMessage.java b/src/main/java/net/minecraftforge/common/network/ForgeMessage.java new file mode 100644 index 0000000..577c558 --- /dev/null +++ b/src/main/java/net/minecraftforge/common/network/ForgeMessage.java @@ -0,0 +1,70 @@ +package net.minecraftforge.common.network; + +import java.util.Map; + +import net.minecraftforge.fluids.FluidRegistry; + +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; + +import cpw.mods.fml.common.network.ByteBufUtils; +import io.netty.buffer.ByteBuf; + +public abstract class ForgeMessage { + public static class DimensionRegisterMessage extends ForgeMessage { + /** The dimension ID to register on client */ + int dimensionId; + /** The provider ID to register with dimension on client */ + int providerId; + + public DimensionRegisterMessage(){} + public DimensionRegisterMessage(int dimensionId, int providerId) + { + this.dimensionId = dimensionId; + this.providerId = providerId; + } + + @Override + void toBytes(ByteBuf bytes) + { + bytes.writeInt(this.dimensionId); + bytes.writeInt(this.providerId); + } + + @Override + void fromBytes(ByteBuf bytes) + { + dimensionId = bytes.readInt(); + providerId = bytes.readInt(); + } + } + + public static class FluidIdMapMessage extends ForgeMessage { + BiMap fluidIds = HashBiMap.create(); + @Override + void toBytes(ByteBuf bytes) + { + Map ids = FluidRegistry.getRegisteredFluidIDs(); + bytes.writeInt(ids.size()); + for (Map.Entry entry : ids.entrySet()) + { + ByteBufUtils.writeUTF8String(bytes,entry.getKey()); + bytes.writeInt(entry.getValue()); + } + } + + @Override + void fromBytes(ByteBuf bytes) + { + int listSize = bytes.readInt(); + for (int i = 0; i < listSize; i++) { + String fluidName = ByteBufUtils.readUTF8String(bytes); + int fluidId = bytes.readInt(); + fluidIds.put(fluidName, fluidId); + } + } + } + + abstract void toBytes(ByteBuf bytes); + abstract void fromBytes(ByteBuf bytes); +} diff --git a/src/main/java/net/minecraftforge/common/network/ForgeNetworkHandler.java b/src/main/java/net/minecraftforge/common/network/ForgeNetworkHandler.java new file mode 100644 index 0000000..6c15d8e --- /dev/null +++ b/src/main/java/net/minecraftforge/common/network/ForgeNetworkHandler.java @@ -0,0 +1,38 @@ +package net.minecraftforge.common.network; + +import java.util.EnumMap; +import net.minecraftforge.common.ForgeModContainer; +import cpw.mods.fml.common.network.FMLEmbeddedChannel; +import cpw.mods.fml.common.network.FMLOutboundHandler; +import cpw.mods.fml.common.network.FMLOutboundHandler.OutboundTarget; +import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class ForgeNetworkHandler +{ + private static EnumMap channelPair; + + public static void registerChannel(ForgeModContainer forgeModContainer, Side side) + { + channelPair = NetworkRegistry.INSTANCE.newChannel(forgeModContainer, "FORGE", new ForgeRuntimeCodec()); + if (side == Side.CLIENT) + { + addClientHandlers(); + } + + FMLEmbeddedChannel serverChannel = channelPair.get(Side.SERVER); + serverChannel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.NOWHERE); + String handlerName = serverChannel.findChannelHandlerNameForType(ForgeRuntimeCodec.class); + serverChannel.pipeline().addAfter(handlerName, "ServerToClientConnection", new ServerToClientConnectionEstablishedHandler()); + } + + @SideOnly(Side.CLIENT) + private static void addClientHandlers() + { + FMLEmbeddedChannel clientChannel = channelPair.get(Side.CLIENT); + String handlerName = clientChannel.findChannelHandlerNameForType(ForgeRuntimeCodec.class); + clientChannel.pipeline().addAfter(handlerName, "DimensionHandler", new DimensionMessageHandler()); + clientChannel.pipeline().addAfter(handlerName, "FluidIdRegistryHandler", new FluidIdRegistryMessageHandler()); + } +} diff --git a/src/main/java/net/minecraftforge/common/network/ForgeRuntimeCodec.java b/src/main/java/net/minecraftforge/common/network/ForgeRuntimeCodec.java new file mode 100644 index 0000000..6f6798c --- /dev/null +++ b/src/main/java/net/minecraftforge/common/network/ForgeRuntimeCodec.java @@ -0,0 +1,24 @@ +package net.minecraftforge.common.network; + +import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelHandlerContext; +import cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec; + +public class ForgeRuntimeCodec extends FMLIndexedMessageToMessageCodec { + public ForgeRuntimeCodec() + { + addDiscriminator(1, ForgeMessage.DimensionRegisterMessage.class); + addDiscriminator(2, ForgeMessage.FluidIdMapMessage.class); + } + @Override + public void encodeInto(ChannelHandlerContext ctx, ForgeMessage msg, ByteBuf target) throws Exception + { + msg.toBytes(target); + } + + @Override + public void decodeInto(ChannelHandlerContext ctx, ByteBuf source, ForgeMessage msg) + { + msg.fromBytes(source); + } +} diff --git a/src/main/java/net/minecraftforge/common/network/ServerToClientConnectionEstablishedHandler.java b/src/main/java/net/minecraftforge/common/network/ServerToClientConnectionEstablishedHandler.java new file mode 100644 index 0000000..b72f3d7 --- /dev/null +++ b/src/main/java/net/minecraftforge/common/network/ServerToClientConnectionEstablishedHandler.java @@ -0,0 +1,19 @@ +package net.minecraftforge.common.network; + +import cpw.mods.fml.common.network.NetworkHandshakeEstablished; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelInboundHandlerAdapter; + +public class ServerToClientConnectionEstablishedHandler extends ChannelInboundHandlerAdapter { + @Override + public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception + { + if (evt instanceof NetworkHandshakeEstablished) + { + ctx.writeAndFlush(new ForgeMessage.FluidIdMapMessage()); + return; + } + // pass it forward + ctx.fireUserEventTriggered(evt); + } +} diff --git a/src/main/java/net/minecraftforge/common/util/Constants.java b/src/main/java/net/minecraftforge/common/util/Constants.java new file mode 100644 index 0000000..58eb606 --- /dev/null +++ b/src/main/java/net/minecraftforge/common/util/Constants.java @@ -0,0 +1,32 @@ +package net.minecraftforge.common.util; + +/** + * A class containing constants for magic numbers used in the minecraft codebase. + * Everything here should be checked each update, and have a comment relating to where to check it. + */ +public class Constants +{ + /** + * NBT Tag type IDS, used when storing the nbt to disc, Should align with NBTBase.getId, + * table used in NBTBase.func_150283_g + * + * Main use is checking tag type in NBTTagCompound.func_150297_b(String, int) + * + */ + public static class NBT + { + public static final int TAG_END = 0; + public static final int TAG_BYTE = 1; + public static final int TAG_SHORT = 2; + public static final int TAG_INT = 3; + public static final int TAG_LONG = 4; + public static final int TAG_FLOAT = 5; + public static final int TAG_DOUBLE = 6; + public static final int TAG_BYTE_ARRAY = 7; + public static final int TAG_STRING = 8; + public static final int TAG_LIST = 9; + public static final int TAG_COMPOUND = 10; + public static final int TAG_INT_ARRAY = 11; + public static final int TAG_ANY_NUMERIC = 99; + } +} diff --git a/src/main/java/net/minecraftforge/common/util/EnumHelper.java b/src/main/java/net/minecraftforge/common/util/EnumHelper.java new file mode 100644 index 0000000..4ae531f --- /dev/null +++ b/src/main/java/net/minecraftforge/common/util/EnumHelper.java @@ -0,0 +1,283 @@ +package net.minecraftforge.common.util; + +import java.lang.reflect.*; +import java.util.*; + +import cpw.mods.fml.common.FMLLog; +import net.minecraft.block.BlockPressurePlate.Sensitivity; +import net.minecraft.block.material.Material; +import net.minecraft.enchantment.EnumEnchantmentType; +import net.minecraft.entity.Entity.EnumEntitySize; +import net.minecraft.entity.EnumCreatureAttribute; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.item.EntityPainting.EnumArt; +import net.minecraft.entity.player.EntityPlayer.EnumStatus; +import net.minecraft.item.EnumAction; +import net.minecraft.item.Item.ToolMaterial; +import net.minecraft.item.ItemArmor.ArmorMaterial; +import net.minecraft.util.MovingObjectPosition.MovingObjectType; +import net.minecraft.world.EnumSkyBlock; +import net.minecraft.world.gen.structure.StructureStrongholdPieces.Stronghold.Door; +import net.minecraftforge.classloading.FMLForgePlugin; + +public class EnumHelper +{ + private static Object reflectionFactory = null; + private static Method newConstructorAccessor = null; + private static Method newInstance = null; + private static Method newFieldAccessor = null; + private static Method fieldAccessorSet = null; + private static boolean isSetup = false; + + //Some enums are decompiled with extra arguments, so lets check for that + @SuppressWarnings("rawtypes") + private static Class[][] commonTypes = + { + {EnumAction.class}, + {ArmorMaterial.class, int.class, int[].class, int.class}, + {EnumArt.class, String.class, int.class, int.class, int.class, int.class}, + {EnumCreatureAttribute.class}, + {EnumCreatureType.class, Class.class, int.class, Material.class, boolean.class}, + {Door.class}, + {EnumEnchantmentType.class}, + {EnumEntitySize.class}, + {Sensitivity.class}, + {MovingObjectType.class}, + {EnumSkyBlock.class, int.class}, + {EnumStatus.class}, + {ToolMaterial.class, int.class, int.class, float.class, float.class, int.class} + }; + + public static EnumAction addAction(String name) + { + return addEnum(EnumAction.class, name); + } + public static ArmorMaterial addArmorMaterial(String name, int durability, int[] reductionAmounts, int enchantability) + { + return addEnum(ArmorMaterial.class, name, durability, reductionAmounts, enchantability); + } + public static EnumArt addArt(String name, String tile, int sizeX, int sizeY, int offsetX, int offsetY) + { + return addEnum(EnumArt.class, name, tile, sizeX, sizeY, offsetX, offsetY); + } + public static EnumCreatureAttribute addCreatureAttribute(String name) + { + return addEnum(EnumCreatureAttribute.class, name); + } + @SuppressWarnings("rawtypes") + public static EnumCreatureType addCreatureType(String name, Class typeClass, int maxNumber, Material material, boolean peaceful) + { + return addEnum(EnumCreatureType.class, name, typeClass, maxNumber, material, peaceful); + } + public static Door addDoor(String name) + { + return addEnum(Door.class, name); + } + public static EnumEnchantmentType addEnchantmentType(String name) + { + return addEnum(EnumEnchantmentType.class, name); + } + public static EnumEntitySize addEntitySize(String name) + { + return addEnum(EnumEntitySize.class, name); + } + public static Sensitivity addSensitivity(String name) + { + return addEnum(Sensitivity.class, name); + } + public static MovingObjectType addMovingObjectType(String name) + { + return addEnum(MovingObjectType.class, name); + } + public static EnumSkyBlock addSkyBlock(String name, int lightValue) + { + return addEnum(EnumSkyBlock.class, name, lightValue); + } + public static EnumStatus addStatus(String name) + { + return addEnum(EnumStatus.class, name); + } + public static ToolMaterial addToolMaterial(String name, int harvestLevel, int maxUses, float efficiency, float damage, int enchantability) + { + return addEnum(ToolMaterial.class, name, harvestLevel, maxUses, efficiency, damage, enchantability); + } + + private static void setup() + { + if (isSetup) + { + return; + } + + try + { + Method getReflectionFactory = Class.forName("sun.reflect.ReflectionFactory").getDeclaredMethod("getReflectionFactory"); + reflectionFactory = getReflectionFactory.invoke(null); + newConstructorAccessor = Class.forName("sun.reflect.ReflectionFactory").getDeclaredMethod("newConstructorAccessor", Constructor.class); + newInstance = Class.forName("sun.reflect.ConstructorAccessor").getDeclaredMethod("newInstance", Object[].class); + newFieldAccessor = Class.forName("sun.reflect.ReflectionFactory").getDeclaredMethod("newFieldAccessor", Field.class, boolean.class); + fieldAccessorSet = Class.forName("sun.reflect.FieldAccessor").getDeclaredMethod("set", Object.class, Object.class); + } + catch (Exception e) + { + e.printStackTrace(); + } + + isSetup = true; + } + + /* + * Everything below this is found at the site below, and updated to be able to compile in Eclipse/Java 1.6+ + * Also modified for use in decompiled code. + * Found at: http://niceideas.ch/roller2/badtrash/entry/java_create_enum_instances_dynamically + */ + private static Object getConstructorAccessor(Class enumClass, Class[] additionalParameterTypes) throws Exception + { + Class[] parameterTypes = new Class[additionalParameterTypes.length + 2]; + parameterTypes[0] = String.class; + parameterTypes[1] = int.class; + System.arraycopy(additionalParameterTypes, 0, parameterTypes, 2, additionalParameterTypes.length); + return newConstructorAccessor.invoke(reflectionFactory, enumClass.getDeclaredConstructor(parameterTypes)); + } + + private static < T extends Enum> T makeEnum(Class enumClass, String value, int ordinal, Class[] additionalTypes, Object[] additionalValues) throws Exception + { + Object[] parms = new Object[additionalValues.length + 2]; + parms[0] = value; + parms[1] = Integer.valueOf(ordinal); + System.arraycopy(additionalValues, 0, parms, 2, additionalValues.length); + return enumClass.cast(newInstance.invoke(getConstructorAccessor(enumClass, additionalTypes), new Object[] {parms})); + } + + public static void setFailsafeFieldValue(Field field, Object target, Object value) throws Exception + { + field.setAccessible(true); + Field modifiersField = Field.class.getDeclaredField("modifiers"); + modifiersField.setAccessible(true); + modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL); + Object fieldAccessor = newFieldAccessor.invoke(reflectionFactory, field, false); + fieldAccessorSet.invoke(fieldAccessor, target, value); + } + + private static void blankField(Class enumClass, String fieldName) throws Exception + { + for (Field field : Class.class.getDeclaredFields()) + { + if (field.getName().contains(fieldName)) + { + field.setAccessible(true); + setFailsafeFieldValue(field, enumClass, null); + break; + } + } + } + + private static void cleanEnumCache(Class enumClass) throws Exception + { + blankField(enumClass, "enumConstantDirectory"); + blankField(enumClass, "enumConstants"); + } + + public static > T addEnum(Class enumType, String enumName, Object... paramValues) + { + setup(); + return addEnum(commonTypes, enumType, enumName, paramValues); + } + + @SuppressWarnings("rawtypes") + public static > T addEnum(Class[][] map, Class enumType, String enumName, Object... paramValues) + { + for (Class[] lookup : map) + { + if (lookup[0] == enumType) + { + Class[] paramTypes = new Class[lookup.length - 1]; + if (paramTypes.length > 0) + { + System.arraycopy(lookup, 1, paramTypes, 0, paramTypes.length); + } + return addEnum(enumType, enumName, paramTypes, paramValues); + } + } + return null; + } + + @SuppressWarnings("unchecked") + public static > T addEnum(Class enumType, String enumName, Class[] paramTypes, Object[] paramValues) + { + if (!isSetup) + { + setup(); + } + + Field valuesField = null; + Field[] fields = enumType.getDeclaredFields(); + + for (Field field : fields) + { + String name = field.getName(); + if (name.equals("$VALUES") || name.equals("ENUM$VALUES")) //Added 'ENUM$VALUES' because Eclipse's internal compiler doesn't follow standards + { + valuesField = field; + break; + } + } + + int flags = (FMLForgePlugin.RUNTIME_DEOBF ? Modifier.PUBLIC : Modifier.PRIVATE) | Modifier.STATIC | Modifier.FINAL | 0x1000 /*SYNTHETIC*/; + if (valuesField == null) + { + String valueType = String.format("[L%s;", enumType.getName().replace('.', '/')); + + for (Field field : fields) + { + if ((field.getModifiers() & flags) == flags && + field.getType().getName().replace('.', '/').equals(valueType)) //Apparently some JVMs return .'s and some don't.. + { + valuesField = field; + break; + } + } + } + + if (valuesField == null) + { + FMLLog.severe("Could not find $VALUES field for enum: %s", enumType.getName()); + FMLLog.severe("Runtime Deobf: %s", FMLForgePlugin.RUNTIME_DEOBF); + FMLLog.severe("Flags: %s", String.format("%16s", Integer.toBinaryString(flags)).replace(' ', '0')); + FMLLog.severe("Fields:"); + for (Field field : fields) + { + String mods = String.format("%16s", Integer.toBinaryString(field.getModifiers())).replace(' ', '0'); + FMLLog.severe(" %s %s: %s", mods, field.getName(), field.getType().getName()); + } + return null; + } + + valuesField.setAccessible(true); + + try + { + T[] previousValues = (T[])valuesField.get(enumType); + List values = new ArrayList(Arrays.asList(previousValues)); + T newValue = (T)makeEnum(enumType, enumName, values.size(), paramTypes, paramValues); + values.add(newValue); + setFailsafeFieldValue(valuesField, null, values.toArray((T[]) Array.newInstance(enumType, 0))); + cleanEnumCache(enumType); + + return newValue; + } + catch (Exception e) + { + e.printStackTrace(); + throw new RuntimeException(e.getMessage(), e); + } + } + + static + { + if (!isSetup) + { + setup(); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/common/util/FakePlayer.java b/src/main/java/net/minecraftforge/common/util/FakePlayer.java new file mode 100644 index 0000000..f4af43b --- /dev/null +++ b/src/main/java/net/minecraftforge/common/util/FakePlayer.java @@ -0,0 +1,40 @@ +package net.minecraftforge.common.util; + +import com.mojang.authlib.GameProfile; + +import cpw.mods.fml.common.FMLCommonHandler; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.network.play.client.C15PacketClientSettings; +import net.minecraft.server.management.ItemInWorldManager; +import net.minecraft.stats.StatBase; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.DamageSource; +import net.minecraft.util.IChatComponent; +import net.minecraft.world.World; +import net.minecraft.world.WorldServer; + +//Preliminary, simple Fake Player class +public class FakePlayer extends EntityPlayerMP +{ + public FakePlayer(WorldServer world, GameProfile name) + { + super(FMLCommonHandler.instance().getMinecraftServerInstance(), world, name, new ItemInWorldManager(world)); + } + + @Override public boolean canCommandSenderUseCommand(int i, String s){ return false; } + @Override public ChunkCoordinates getPlayerCoordinates() + { + return new ChunkCoordinates(0,0,0); + } + + @Override public void addChatComponentMessage(IChatComponent chatmessagecomponent){} + @Override public void addStat(StatBase par1StatBase, int par2){} + @Override public void openGui(Object mod, int modGuiId, World world, int x, int y, int z){} + @Override public boolean isEntityInvulnerable(){ return true; } + @Override public boolean canAttackPlayer(EntityPlayer player){ return false; } + @Override public void onDeath(DamageSource source){ return; } + @Override public void onUpdate(){ return; } + @Override public void travelToDimension(int dim){ return; } + @Override public void func_147100_a(C15PacketClientSettings pkt){ return; } +} diff --git a/src/main/java/net/minecraftforge/common/util/FakePlayerFactory.java b/src/main/java/net/minecraftforge/common/util/FakePlayerFactory.java new file mode 100644 index 0000000..d39af8a --- /dev/null +++ b/src/main/java/net/minecraftforge/common/util/FakePlayerFactory.java @@ -0,0 +1,58 @@ +package net.minecraftforge.common.util; + +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; + +import com.google.common.collect.Maps; +import com.mojang.authlib.GameProfile; + +import net.minecraft.world.WorldServer; +import net.minecraftforge.common.DimensionManager; + +//To be expanded for generic Mod fake players? +public class FakePlayerFactory +{ + private static GameProfile MINECRAFT = new GameProfile("41C82C87-7AfB-4024-BA57-13D2C99CAE77", "[Minecraft]"); + // Map of all active fake player usernames to their entities + private static Map fakePlayers = Maps.newHashMap(); + private static FakePlayer MINECRAFT_PLAYER = null; + + public static FakePlayer getMinecraft(WorldServer world) + { + if (MINECRAFT_PLAYER == null) + { + MINECRAFT_PLAYER = FakePlayerFactory.get(world, MINECRAFT); + } + return MINECRAFT_PLAYER; + } + + /** + * Get a fake player with a given username, + * Mods should either hold weak references to the return value, or listen for a + * WorldEvent.Unload and kill all references to prevent worlds staying in memory. + */ + public static FakePlayer get(WorldServer world, GameProfile username) + { + if (!fakePlayers.containsKey(username)) + { + FakePlayer fakePlayer = new FakePlayer(world, username); + fakePlayers.put(username, fakePlayer); + } + + return fakePlayers.get(username); + } + + public static void unloadWorld(WorldServer world) + { + Iterator> itr = fakePlayers.entrySet().iterator(); + while (itr.hasNext()) + { + Entry entry = itr.next(); + if (entry.getValue().worldObj == world) + { + itr.remove(); + } + } + } +} diff --git a/src/main/java/net/minecraftforge/common/util/ForgeDirection.java b/src/main/java/net/minecraftforge/common/util/ForgeDirection.java new file mode 100644 index 0000000..4ae8182 --- /dev/null +++ b/src/main/java/net/minecraftforge/common/util/ForgeDirection.java @@ -0,0 +1,71 @@ +package net.minecraftforge.common.util; + +public enum ForgeDirection +{ + /** -Y */ + DOWN(0, -1, 0), + + /** +Y */ + UP(0, 1, 0), + + /** -Z */ + NORTH(0, 0, -1), + + /** +Z */ + SOUTH(0, 0, 1), + + /** -X */ + WEST(-1, 0, 0), + + /** +X */ + EAST(1, 0, 0), + + /** + * Used only by getOrientation, for invalid inputs + */ + UNKNOWN(0, 0, 0); + + public final int offsetX; + public final int offsetY; + public final int offsetZ; + public final int flag; + public static final ForgeDirection[] VALID_DIRECTIONS = {DOWN, UP, NORTH, SOUTH, WEST, EAST}; + public static final int[] OPPOSITES = {1, 0, 3, 2, 5, 4, 6}; + // Left hand rule rotation matrix for all possible axes of rotation + public static final int[][] ROTATION_MATRIX = { + {0, 1, 4, 5, 3, 2, 6}, + {0, 1, 5, 4, 2, 3, 6}, + {5, 4, 2, 3, 0, 1, 6}, + {4, 5, 2, 3, 1, 0, 6}, + {2, 3, 1, 0, 4, 5, 6}, + {3, 2, 0, 1, 4, 5, 6}, + {0, 1, 2, 3, 4, 5, 6}, + }; + + private ForgeDirection(int x, int y, int z) + { + offsetX = x; + offsetY = y; + offsetZ = z; + flag = 1 << ordinal(); + } + + public static ForgeDirection getOrientation(int id) + { + if (id >= 0 && id < VALID_DIRECTIONS.length) + { + return VALID_DIRECTIONS[id]; + } + return UNKNOWN; + } + + public ForgeDirection getOpposite() + { + return getOrientation(OPPOSITES[ordinal()]); + } + + public ForgeDirection getRotation(ForgeDirection axis) + { + return getOrientation(ROTATION_MATRIX[axis.ordinal()][ordinal()]); + } +} diff --git a/src/main/java/net/minecraftforge/common/util/RotationHelper.java b/src/main/java/net/minecraftforge/common/util/RotationHelper.java new file mode 100644 index 0000000..5fa8d89 --- /dev/null +++ b/src/main/java/net/minecraftforge/common/util/RotationHelper.java @@ -0,0 +1,434 @@ +package net.minecraftforge.common.util; + +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockAnvil; +import net.minecraft.block.BlockBed; +import net.minecraft.block.BlockButton; +import net.minecraft.block.BlockChest; +import net.minecraft.block.BlockCocoa; +import net.minecraft.block.BlockDispenser; +import net.minecraft.block.BlockDoor; +import net.minecraft.block.BlockEndPortalFrame; +import net.minecraft.block.BlockEnderChest; +import net.minecraft.block.BlockFenceGate; +import net.minecraft.block.BlockFurnace; +import net.minecraft.block.BlockHopper; +import net.minecraft.block.BlockHugeMushroom; +import net.minecraft.block.BlockLadder; +import net.minecraft.block.BlockLever; +import net.minecraft.block.BlockLog; +import net.minecraft.block.BlockPistonBase; +import net.minecraft.block.BlockPistonExtension; +import net.minecraft.block.BlockPumpkin; +import net.minecraft.block.BlockRail; +import net.minecraft.block.BlockRailDetector; +import net.minecraft.block.BlockRailPowered; +import net.minecraft.block.BlockRedstoneComparator; +import net.minecraft.block.BlockRedstoneRepeater; +import net.minecraft.block.BlockSkull; +import net.minecraft.block.BlockStairs; +import net.minecraft.block.BlockTorch; +import net.minecraft.block.BlockTrapDoor; +import net.minecraft.block.BlockTripWireHook; +import net.minecraft.block.BlockVine; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; + +import java.util.HashMap; +import java.util.Map; + +import static net.minecraftforge.common.util.ForgeDirection.*; + +public class RotationHelper { + /** + * Some blocks have the same rotation. + * The first of these blocks (sorted by itemID) should be listed as a type. + * Some of the types aren't actual blocks (helper types). + */ + private static enum BlockType { + LOG, + DISPENSER, + BED, + RAIL, + RAIL_POWERED, + RAIL_ASCENDING, + RAIL_CORNER, + TORCH, + STAIR, + CHEST, + SIGNPOST, + DOOR, + LEVER, + BUTTON, + REDSTONE_REPEATER, + TRAPDOOR, + MUSHROOM_CAP, + MUSHROOM_CAP_CORNER, + MUSHROOM_CAP_SIDE, + VINE, + SKULL, + ANVIL + } + + private static final ForgeDirection[] UP_DOWN_AXES = new ForgeDirection[] { UP, DOWN }; + private static final Map> MAPPINGS = new HashMap>(); + + public static ForgeDirection[] getValidVanillaBlockRotations(Block block) + { + return (block instanceof BlockBed || + block instanceof BlockPumpkin || + block instanceof BlockFenceGate || + block instanceof BlockEndPortalFrame || + block instanceof BlockTripWireHook || + block instanceof BlockCocoa || + block instanceof BlockRailPowered || + block instanceof BlockRailDetector || + block instanceof BlockStairs || + block instanceof BlockChest || + block instanceof BlockEnderChest || + block instanceof BlockFurnace || + block instanceof BlockLadder || + block == Blocks.wall_sign || + block == Blocks.standing_sign || + block instanceof BlockDoor || + block instanceof BlockRail || + block instanceof BlockButton || + block instanceof BlockRedstoneRepeater || + block instanceof BlockRedstoneComparator || + block instanceof BlockTrapDoor || + block instanceof BlockHugeMushroom || + block instanceof BlockVine || + block instanceof BlockSkull || + block instanceof BlockAnvil) ? UP_DOWN_AXES : VALID_DIRECTIONS; + } + + public static boolean rotateVanillaBlock(Block block, World worldObj, int x, int y, int z, ForgeDirection axis) + { + if (worldObj.isRemote) + { + return false; + } + + if (axis == UP || axis == DOWN) + { + if (block instanceof BlockBed || block instanceof BlockPumpkin || block instanceof BlockFenceGate || block instanceof BlockEndPortalFrame || block instanceof BlockTripWireHook || block instanceof BlockCocoa) + { + return rotateBlock(worldObj, x, y, z, axis, 0x3, BlockType.BED); + } + if (block instanceof BlockRail) + { + return rotateBlock(worldObj, x, y, z, axis, 0xF, BlockType.RAIL); + } + if (block instanceof BlockRailPowered || block instanceof BlockRailDetector) + { + return rotateBlock(worldObj, x, y, z, axis, 0x7, BlockType.RAIL_POWERED); + } + if (block instanceof BlockStairs) + { + return rotateBlock(worldObj, x, y, z, axis, 0x3, BlockType.STAIR); + } + if (block instanceof BlockChest || block instanceof BlockEnderChest || block instanceof BlockFurnace || block instanceof BlockLadder || block == Blocks.wall_sign) + { + return rotateBlock(worldObj, x, y, z, axis, 0x7, BlockType.CHEST); + } + if (block == Blocks.standing_sign) + { + return rotateBlock(worldObj, x, y, z, axis, 0xF, BlockType.SIGNPOST); + } + if (block instanceof BlockDoor) + { + return rotateBlock(worldObj, x, y, z, axis, 0x3, BlockType.DOOR); + } + if (block instanceof BlockButton) + { + return rotateBlock(worldObj, x, y, z, axis, 0x7, BlockType.BUTTON); + } + if (block instanceof BlockRedstoneRepeater || block instanceof BlockRedstoneComparator) + { + return rotateBlock(worldObj, x, y, z, axis, 0x3, BlockType.REDSTONE_REPEATER); + } + if (block instanceof BlockTrapDoor) + { + return rotateBlock(worldObj, x, y, z, axis, 0x3, BlockType.TRAPDOOR); + } + if (block instanceof BlockHugeMushroom) + { + return rotateBlock(worldObj, x, y, z, axis, 0xF, BlockType.MUSHROOM_CAP); + } + if (block instanceof BlockVine) + { + return rotateBlock(worldObj, x, y, z, axis, 0xF, BlockType.VINE); + } + if (block instanceof BlockSkull) + { + return rotateBlock(worldObj, x, y, z, axis, 0x7, BlockType.SKULL); + } + if (block instanceof BlockAnvil) + { + return rotateBlock(worldObj, x, y, z, axis, 0x1, BlockType.ANVIL); + } + } + + if (block instanceof BlockLog) + { + return rotateBlock(worldObj, x, y, z, axis, 0xC, BlockType.LOG); + } + if (block instanceof BlockDispenser || block instanceof BlockPistonBase || block instanceof BlockPistonExtension || block instanceof BlockHopper) + { + return rotateBlock(worldObj, x, y, z, axis, 0x7, BlockType.DISPENSER); + } + if (block instanceof BlockTorch) + { + return rotateBlock(worldObj, x, y, z, axis, 0xF, BlockType.TORCH); + } + if (block instanceof BlockLever) + { + return rotateBlock(worldObj, x, y, z, axis, 0x7, BlockType.LEVER); + } + + return false; + } + + private static boolean rotateBlock(World worldObj, int x, int y, int z, ForgeDirection axis, int mask, BlockType blockType) + { + int rotMeta = worldObj.getBlockMetadata(x, y, z); + if (blockType == BlockType.DOOR && (rotMeta & 0x8) == 0x8) + { + return false; + } + int masked = rotMeta & ~mask; + int meta = rotateMetadata(axis, blockType, rotMeta & mask); + if (meta == -1) + { + return false; + } + worldObj.setBlockMetadataWithNotify(x, y, z, meta & mask | masked, 3); + return true; + } + + private static int rotateMetadata(ForgeDirection axis, BlockType blockType, int meta) + { + if (blockType == BlockType.RAIL || blockType == BlockType.RAIL_POWERED) + { + if (meta == 0x0 || meta == 0x1) + { + return ~meta & 0x1; + } + if (meta >= 0x2 && meta <= 0x5) + { + blockType = BlockType.RAIL_ASCENDING; + } + if (meta >= 0x6 && meta <= 0x9 && blockType == BlockType.RAIL) + { + blockType = BlockType.RAIL_CORNER; + } + } + if (blockType == BlockType.SIGNPOST) + { + return (axis == UP) ? (meta + 0x4) % 0x10 : (meta + 0xC) % 0x10; + } + if (blockType == BlockType.LEVER && (axis == UP || axis == DOWN)) + { + switch (meta) + { + case 0x5: + return 0x6; + case 0x6: + return 0x5; + case 0x7: + return 0x0; + case 0x0: + return 0x7; + } + } + if (blockType == BlockType.MUSHROOM_CAP) + { + if (meta % 0x2 == 0) + { + blockType = BlockType.MUSHROOM_CAP_SIDE; + } + else + { + blockType = BlockType.MUSHROOM_CAP_CORNER; + } + } + if (blockType == BlockType.VINE) + { + return ((meta << 1) | ((meta & 0x8) >> 3)); + } + + ForgeDirection orientation = metadataToDirection(blockType, meta); + ForgeDirection rotated = orientation.getRotation(axis); + return directionToMetadata(blockType, rotated); + } + + private static ForgeDirection metadataToDirection(BlockType blockType, int meta) + { + if (blockType == BlockType.LEVER) + { + if (meta == 0x6) + { + meta = 0x5; + } + else if (meta == 0x0) + { + meta = 0x7; + } + } + + if (MAPPINGS.containsKey(blockType)) + { + BiMap biMap = MAPPINGS.get(blockType); + if (biMap.containsKey(meta)) + { + return biMap.get(meta); + } + } + + if (blockType == BlockType.TORCH) + { + return ForgeDirection.getOrientation(6 - meta); + } + if (blockType == BlockType.STAIR) + { + return ForgeDirection.getOrientation(5 - meta); + } + if (blockType == BlockType.CHEST || blockType == BlockType.DISPENSER || blockType == BlockType.SKULL) + { + return ForgeDirection.getOrientation(meta); + } + if (blockType == BlockType.BUTTON) + { + return ForgeDirection.getOrientation(6 - meta); + } + if (blockType == BlockType.TRAPDOOR) + { + return ForgeDirection.getOrientation(meta + 2).getOpposite(); + } + + return ForgeDirection.UNKNOWN; + } + + private static int directionToMetadata(BlockType blockType, ForgeDirection direction) + { + if ((blockType == BlockType.LOG || blockType == BlockType.ANVIL) && (direction.offsetX + direction.offsetY + direction.offsetZ) < 0) + { + direction = direction.getOpposite(); + } + + if (MAPPINGS.containsKey(blockType)) + { + BiMap biMap = MAPPINGS.get(blockType).inverse(); + if (biMap.containsKey(direction)) + { + return biMap.get(direction); + } + } + + if (blockType == BlockType.TORCH) + { + if (direction.ordinal() >= 1) + { + return 6 - direction.ordinal(); + } + } + if (blockType == BlockType.STAIR) + { + return 5 - direction.ordinal(); + } + if (blockType == BlockType.CHEST || blockType == BlockType.DISPENSER || blockType == BlockType.SKULL) + { + return direction.ordinal(); + } + if (blockType == BlockType.BUTTON) + { + if (direction.ordinal() >= 2) + { + return 6 - direction.ordinal(); + } + } + if (blockType == BlockType.TRAPDOOR) + { + return direction.getOpposite().ordinal() - 2; + } + + return -1; + } + + static + { + BiMap biMap; + + biMap = HashBiMap.create(3); + biMap.put(0x0, UP); + biMap.put(0x4, EAST); + biMap.put(0x8, SOUTH); + MAPPINGS.put(BlockType.LOG, biMap); + + biMap = HashBiMap.create(4); + biMap.put(0x0, SOUTH); + biMap.put(0x1, WEST); + biMap.put(0x2, NORTH); + biMap.put(0x3, EAST); + MAPPINGS.put(BlockType.BED, biMap); + + biMap = HashBiMap.create(4); + biMap.put(0x2, EAST); + biMap.put(0x3, WEST); + biMap.put(0x4, NORTH); + biMap.put(0x5, SOUTH); + MAPPINGS.put(BlockType.RAIL_ASCENDING, biMap); + + biMap = HashBiMap.create(4); + biMap.put(0x6, WEST); + biMap.put(0x7, NORTH); + biMap.put(0x8, EAST); + biMap.put(0x9, SOUTH); + MAPPINGS.put(BlockType.RAIL_CORNER, biMap); + + biMap = HashBiMap.create(6); + biMap.put(0x1, EAST); + biMap.put(0x2, WEST); + biMap.put(0x3, SOUTH); + biMap.put(0x4, NORTH); + biMap.put(0x5, UP); + biMap.put(0x7, DOWN); + MAPPINGS.put(BlockType.LEVER, biMap); + + biMap = HashBiMap.create(4); + biMap.put(0x0, WEST); + biMap.put(0x1, NORTH); + biMap.put(0x2, EAST); + biMap.put(0x3, SOUTH); + MAPPINGS.put(BlockType.DOOR, biMap); + + biMap = HashBiMap.create(4); + biMap.put(0x0, NORTH); + biMap.put(0x1, EAST); + biMap.put(0x2, SOUTH); + biMap.put(0x3, WEST); + MAPPINGS.put(BlockType.REDSTONE_REPEATER, biMap); + + biMap = HashBiMap.create(4); + biMap.put(0x1, EAST); + biMap.put(0x3, SOUTH); + biMap.put(0x7, NORTH); + biMap.put(0x9, WEST); + MAPPINGS.put(BlockType.MUSHROOM_CAP_CORNER, biMap); + + biMap = HashBiMap.create(4); + biMap.put(0x2, NORTH); + biMap.put(0x4, WEST); + biMap.put(0x6, EAST); + biMap.put(0x8, SOUTH); + MAPPINGS.put(BlockType.MUSHROOM_CAP_SIDE, biMap); + + biMap = HashBiMap.create(2); + biMap.put(0x0, SOUTH); + biMap.put(0x1, EAST); + MAPPINGS.put(BlockType.ANVIL, biMap); + } +} diff --git a/src/main/java/net/minecraftforge/event/AnvilUpdateEvent.java b/src/main/java/net/minecraftforge/event/AnvilUpdateEvent.java new file mode 100644 index 0000000..cd6a2d9 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/AnvilUpdateEvent.java @@ -0,0 +1,30 @@ +package net.minecraftforge.event; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import cpw.mods.fml.common.eventhandler.Event; +import net.minecraft.item.ItemStack; + +/** + * + * AnvilUpdateEvent is fired when a player places items in both the left and right slots of a anvil. + * If the event is canceled, vanilla behavior will not run, and the output will be set to null. + * If the event is not canceled, but the output is not null, it will set the output and not run vanilla behavior. + * if the output is null, and the event is not canceled, vanilla behavior will execute. + */ +@Cancelable +public class AnvilUpdateEvent extends Event +{ + public final ItemStack left; // The left side of the input + public final ItemStack right; // The right side of the input + public final String name; // The name to set the item, if the user specified one. + public ItemStack output; // Set this to set the output stack + public int cost; // The base cost, set this to change it if output != null + + public AnvilUpdateEvent(ItemStack left, ItemStack right, String name, int cost) + { + this.left = left; + this.right = right; + this.name = name; + this.cost = cost; + } +} diff --git a/src/main/java/net/minecraftforge/event/CommandEvent.java b/src/main/java/net/minecraftforge/event/CommandEvent.java new file mode 100644 index 0000000..2d68bc7 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/CommandEvent.java @@ -0,0 +1,23 @@ +package net.minecraftforge.event; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import cpw.mods.fml.common.eventhandler.Event; +import net.minecraft.command.ICommand; +import net.minecraft.command.ICommandSender; + +@Cancelable +public class CommandEvent extends Event +{ + + public final ICommand command; + public final ICommandSender sender; + public String[] parameters; + public Throwable exception; + + public CommandEvent(ICommand command, ICommandSender sender, String[] parameters) + { + this.command = command; + this.sender = sender; + this.parameters = parameters; + } +} diff --git a/src/main/java/net/minecraftforge/event/ForgeEventFactory.java b/src/main/java/net/minecraftforge/event/ForgeEventFactory.java new file mode 100644 index 0000000..c17165e --- /dev/null +++ b/src/main/java/net/minecraftforge/event/ForgeEventFactory.java @@ -0,0 +1,158 @@ +package net.minecraftforge.event; + +import java.util.ArrayList; +import java.util.List; +import cpw.mods.fml.common.eventhandler.Event.Result; +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.effect.EntityLightningBolt; +import net.minecraft.entity.monster.EntityZombie; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraft.world.WorldServer; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.EntityStruckByLightningEvent; +import net.minecraftforge.event.entity.living.LivingPackSizeEvent; +import net.minecraftforge.event.entity.living.LivingSpawnEvent; +import net.minecraftforge.event.entity.living.LivingSpawnEvent.AllowDespawn; +import net.minecraftforge.event.entity.living.ZombieEvent.SummonAidEvent; +import net.minecraftforge.event.entity.player.ItemTooltipEvent; +import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent; +import net.minecraftforge.event.entity.player.PlayerEvent; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; +import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action; +import net.minecraftforge.event.entity.player.PlayerUseItemEvent; +import net.minecraftforge.event.world.BlockEvent; +import net.minecraftforge.event.world.WorldEvent; + +public class ForgeEventFactory +{ + public static boolean doPlayerHarvestCheck(EntityPlayer player, Block block, boolean success) + { + PlayerEvent.HarvestCheck event = new PlayerEvent.HarvestCheck(player, block, success); + MinecraftForge.EVENT_BUS.post(event); + return event.success; + } + + @Deprecated // Location version below + public static float getBreakSpeed(EntityPlayer player, Block block, int metadata, float original) + { + return getBreakSpeed(player, block, metadata, original, 0, -1, 0); + } + + public static float getBreakSpeed(EntityPlayer player, Block block, int metadata, float original, int x, int y, int z) + { + PlayerEvent.BreakSpeed event = new PlayerEvent.BreakSpeed(player, block, metadata, original, x, y, z); + return (MinecraftForge.EVENT_BUS.post(event) ? -1 : event.newSpeed); + } + + public static PlayerInteractEvent onPlayerInteract(EntityPlayer player, Action action, int x, int y, int z, int face) + { + PlayerInteractEvent event = new PlayerInteractEvent(player, action, x, y, z, face); + MinecraftForge.EVENT_BUS.post(event); + return event; + } + + public static void onPlayerDestroyItem(EntityPlayer player, ItemStack stack) + { + MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(player, stack)); + } + + public static Result canEntitySpawn(EntityLiving entity, World world, float x, float y, float z) + { + LivingSpawnEvent.CheckSpawn event = new LivingSpawnEvent.CheckSpawn(entity, world, x, y, z); + MinecraftForge.EVENT_BUS.post(event); + return event.getResult(); + } + + public static boolean doSpecialSpawn(EntityLiving entity, World world, float x, float y, float z) + { + return MinecraftForge.EVENT_BUS.post(new LivingSpawnEvent.SpecialSpawn(entity, world, x, y, z)); + } + + public static Result canEntityDespawn(EntityLiving entity) + { + AllowDespawn event = new AllowDespawn(entity); + MinecraftForge.EVENT_BUS.post(event); + return event.getResult(); + } + + public static List getPotentialSpawns(WorldServer world, EnumCreatureType type, int x, int y, int z, List oldList) + { + WorldEvent.PotentialSpawns event = new WorldEvent.PotentialSpawns(world, type, x, y, z, oldList); + if (MinecraftForge.EVENT_BUS.post(event)) + { + return null; + } + return event.list; + } + + public static int getMaxSpawnPackSize(EntityLiving entity) + { + LivingPackSizeEvent maxCanSpawnEvent = new LivingPackSizeEvent(entity); + MinecraftForge.EVENT_BUS.post(maxCanSpawnEvent); + return maxCanSpawnEvent.getResult() == Result.ALLOW ? maxCanSpawnEvent.maxPackSize : entity.getMaxSpawnedInChunk(); + } + + public static String getPlayerDisplayName(EntityPlayer player, String username) + { + PlayerEvent.NameFormat event = new PlayerEvent.NameFormat(player, username); + MinecraftForge.EVENT_BUS.post(event); + return event.displayname; + } + + public static float fireBlockHarvesting(ArrayList drops, World world, Block block, int x, int y, int z, int meta, int fortune, float dropChance, boolean silkTouch, EntityPlayer player) + { + BlockEvent.HarvestDropsEvent event = new BlockEvent.HarvestDropsEvent(x, y, z, world, block, meta, fortune, dropChance, drops, player, silkTouch); + MinecraftForge.EVENT_BUS.post(event); + return event.dropChance; + } + + public static ItemTooltipEvent onItemTooltip(ItemStack itemStack, EntityPlayer entityPlayer, List toolTip, boolean showAdvancedItemTooltips) + { + ItemTooltipEvent event = new ItemTooltipEvent(itemStack, entityPlayer, toolTip, showAdvancedItemTooltips); + MinecraftForge.EVENT_BUS.post(event); + return event; + } + + public static SummonAidEvent fireZombieSummonAid(EntityZombie zombie, World world, int x, int y, int z, EntityLivingBase attacker, double summonChance) + { + SummonAidEvent summonEvent = new SummonAidEvent(zombie, world, x, y, z, attacker, summonChance); + MinecraftForge.EVENT_BUS.post(summonEvent); + return summonEvent; + } + + public static boolean onEntityStruckByLightning(Entity entity, EntityLightningBolt bolt) + { + return MinecraftForge.EVENT_BUS.post(new EntityStruckByLightningEvent(entity, bolt)); + } + + public static int onItemUseStart(EntityPlayer player, ItemStack item, int duration) + { + PlayerUseItemEvent event = new PlayerUseItemEvent.Start(player, item, duration); + return MinecraftForge.EVENT_BUS.post(event) ? -1 : event.duration; + } + + public static int onItemUseTick(EntityPlayer player, ItemStack item, int duration) + { + PlayerUseItemEvent event = new PlayerUseItemEvent.Tick(player, item, duration); + return MinecraftForge.EVENT_BUS.post(event) ? -1 : event.duration; + } + + public static boolean onUseItemStop(EntityPlayer player, ItemStack item, int duration) + { + return MinecraftForge.EVENT_BUS.post(new PlayerUseItemEvent.Stop(player, item, duration)); + } + + public static ItemStack onItemUseFinish(EntityPlayer player, ItemStack item, int duration, ItemStack result) + { + PlayerUseItemEvent.Finish event = new PlayerUseItemEvent.Finish(player, item, duration, result); + MinecraftForge.EVENT_BUS.post(event); + return event.result; + } +} diff --git a/src/main/java/net/minecraftforge/event/ServerChatEvent.java b/src/main/java/net/minecraftforge/event/ServerChatEvent.java new file mode 100644 index 0000000..f820e53 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/ServerChatEvent.java @@ -0,0 +1,22 @@ +package net.minecraftforge.event; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import cpw.mods.fml.common.eventhandler.Event; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.util.ChatComponentTranslation; + +@Cancelable +public class ServerChatEvent extends Event +{ + public final String message, username; + public final EntityPlayerMP player; + public ChatComponentTranslation component; + public ServerChatEvent(EntityPlayerMP player, String message, ChatComponentTranslation component) + { + super(); + this.message = message; + this.player = player; + this.username = player.getGameProfile().getName(); + this.component = component; + } +} diff --git a/src/main/java/net/minecraftforge/event/brewing/PotionBrewedEvent.java b/src/main/java/net/minecraftforge/event/brewing/PotionBrewedEvent.java new file mode 100644 index 0000000..6143ea2 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/brewing/PotionBrewedEvent.java @@ -0,0 +1,16 @@ +package net.minecraftforge.event.brewing; + +import cpw.mods.fml.common.eventhandler.Event; +import net.minecraft.item.ItemStack; + +public class PotionBrewedEvent extends Event +{ + /** + * The brewing stacks in the brewing stand. Each index has the possibility to be null, so make sure you check. + */ + public ItemStack[] brewingStacks; + public PotionBrewedEvent(ItemStack[] brewingStacks) + { + this.brewingStacks = brewingStacks; + } +} diff --git a/src/main/java/net/minecraftforge/event/entity/EntityEvent.java b/src/main/java/net/minecraftforge/event/entity/EntityEvent.java new file mode 100644 index 0000000..b34765d --- /dev/null +++ b/src/main/java/net/minecraftforge/event/entity/EntityEvent.java @@ -0,0 +1,48 @@ +package net.minecraftforge.event.entity; + +import cpw.mods.fml.common.eventhandler.Event; +import net.minecraft.entity.Entity; + +public class EntityEvent extends Event +{ + public final Entity entity; + + public EntityEvent(Entity entity) + { + this.entity = entity; + } + + public static class EntityConstructing extends EntityEvent + { + public EntityConstructing(Entity entity) + { + super(entity); + } + } + + public static class CanUpdate extends EntityEvent + { + public boolean canUpdate = false; + public CanUpdate(Entity entity) + { + super(entity); + } + } + + public static class EnteringChunk extends EntityEvent + { + public int newChunkX; + public int newChunkZ; + public int oldChunkX; + public int oldChunkZ; + + public EnteringChunk(Entity entity, int newChunkX, int newChunkZ, int oldChunkX, int oldChunkZ) + { + super(entity); + this.newChunkX = newChunkX; + this.newChunkZ = newChunkZ; + this.oldChunkX = oldChunkX; + this.oldChunkZ = oldChunkZ; + } + } +} diff --git a/src/main/java/net/minecraftforge/event/entity/EntityJoinWorldEvent.java b/src/main/java/net/minecraftforge/event/entity/EntityJoinWorldEvent.java new file mode 100644 index 0000000..6e5850d --- /dev/null +++ b/src/main/java/net/minecraftforge/event/entity/EntityJoinWorldEvent.java @@ -0,0 +1,18 @@ +package net.minecraftforge.event.entity; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import net.minecraft.entity.Entity; +import net.minecraft.world.World; + +@Cancelable +public class EntityJoinWorldEvent extends EntityEvent +{ + + public final World world; + + public EntityJoinWorldEvent(Entity entity, World world) + { + super(entity); + this.world = world; + } +} diff --git a/src/main/java/net/minecraftforge/event/entity/EntityStruckByLightningEvent.java b/src/main/java/net/minecraftforge/event/entity/EntityStruckByLightningEvent.java new file mode 100644 index 0000000..ddf88b5 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/entity/EntityStruckByLightningEvent.java @@ -0,0 +1,17 @@ +package net.minecraftforge.event.entity; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import net.minecraft.entity.Entity; +import net.minecraft.entity.effect.EntityLightningBolt; + +@Cancelable +public class EntityStruckByLightningEvent extends EntityEvent +{ + public final EntityLightningBolt lightning; + + public EntityStruckByLightningEvent(Entity entity, EntityLightningBolt lightning) + { + super(entity); + this.lightning = lightning; + } +} diff --git a/src/main/java/net/minecraftforge/event/entity/PlaySoundAtEntityEvent.java b/src/main/java/net/minecraftforge/event/entity/PlaySoundAtEntityEvent.java new file mode 100644 index 0000000..b40aed6 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/entity/PlaySoundAtEntityEvent.java @@ -0,0 +1,20 @@ +package net.minecraftforge.event.entity; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import net.minecraft.entity.Entity; + +@Cancelable +public class PlaySoundAtEntityEvent extends EntityEvent +{ + public String name; + public final float volume; + public final float pitch; + + public PlaySoundAtEntityEvent(Entity entity, String name, float volume, float pitch) + { + super(entity); + this.name = name; + this.volume = volume; + this.pitch = pitch; + } +} diff --git a/src/main/java/net/minecraftforge/event/entity/item/ItemEvent.java b/src/main/java/net/minecraftforge/event/entity/item/ItemEvent.java new file mode 100644 index 0000000..8bb6f31 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/entity/item/ItemEvent.java @@ -0,0 +1,29 @@ +package net.minecraftforge.event.entity.item; + +import net.minecraft.entity.item.EntityItem; +import net.minecraftforge.event.entity.EntityEvent; + +/** + * Base class for all EntityItem events. Contains a reference to the + * EntityItem of interest. For most EntityItem events, there's little to no + * additional useful data from the firing method that isn't already contained + * within the EntityItem instance. + */ +public class ItemEvent extends EntityEvent +{ + /** + * The relevant EntityItem for this event, already cast for you. + */ + public final EntityItem entityItem; + + /** + * Creates a new event for an EntityItem. + * + * @param itemEntity The EntityItem for this event + */ + public ItemEvent(EntityItem itemEntity) + { + super(itemEntity); + this.entityItem = itemEntity; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/event/entity/item/ItemExpireEvent.java b/src/main/java/net/minecraftforge/event/entity/item/ItemExpireEvent.java new file mode 100644 index 0000000..472dd51 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/entity/item/ItemExpireEvent.java @@ -0,0 +1,29 @@ +package net.minecraftforge.event.entity.item; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import net.minecraft.entity.item.EntityItem; + +/** + * Event that is fired when an EntityItem's age has reached its maximum + * lifespan. Canceling this event will prevent the EntityItem from being + * flagged as dead, thus staying it's removal from the world. If canceled + * it will add more time to the entitie's life equal to extraLife. + */ +@Cancelable +public class ItemExpireEvent extends ItemEvent +{ + + public int extraLife; + + /** + * Creates a new event for an expiring EntityItem. + * + * @param entityItem The EntityItem being deleted. + * @param extraLife The amount of time to be added to this entities lifespan if the event is canceled. + */ + public ItemExpireEvent(EntityItem entityItem, int extraLife) + { + super(entityItem); + this.extraLife = extraLife; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/event/entity/item/ItemTossEvent.java b/src/main/java/net/minecraftforge/event/entity/item/ItemTossEvent.java new file mode 100644 index 0000000..2342710 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/entity/item/ItemTossEvent.java @@ -0,0 +1,33 @@ +package net.minecraftforge.event.entity.item; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; + +/** + * Event that is fired whenever a player tosses (Q) an item or drag-n-drops a + * stack of items outside the inventory GUI screens. Canceling the event will + * stop the items from entering the world, but will not prevent them being + * removed from the inventory - and thus removed from the system. + */ +@Cancelable +public class ItemTossEvent extends ItemEvent +{ + + /** + * The player tossing the item. + */ + public final EntityPlayer player; + + /** + * Creates a new event for EntityItems tossed by a player. + * + * @param entityItem The EntityItem being tossed. + * @param player The player tossing the item. + */ + public ItemTossEvent(EntityItem entityItem, EntityPlayer player) + { + super(entityItem); + this.player = player; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/event/entity/living/EnderTeleportEvent.java b/src/main/java/net/minecraftforge/event/entity/living/EnderTeleportEvent.java new file mode 100644 index 0000000..7b01e81 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/entity/living/EnderTeleportEvent.java @@ -0,0 +1,28 @@ +package net.minecraftforge.event.entity.living; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import net.minecraft.entity.EntityLivingBase; + +/** + * Event for when an Enderman teleports or an ender pearl is used. Can be used to either modify the target position, or cancel the teleport outright. + * @author Mithion + * + */ +@Cancelable +public class EnderTeleportEvent extends LivingEvent +{ + + public double targetX; + public double targetY; + public double targetZ; + public float attackDamage; + + public EnderTeleportEvent(EntityLivingBase entity, double targetX, double targetY, double targetZ, float attackDamage) + { + super(entity); + this.targetX = targetX; + this.targetY = targetY; + this.targetZ = targetZ; + this.attackDamage = attackDamage; + } +} diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingAttackEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingAttackEvent.java new file mode 100644 index 0000000..445f0b0 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingAttackEvent.java @@ -0,0 +1,18 @@ +package net.minecraftforge.event.entity.living; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import net.minecraft.util.DamageSource; +import net.minecraft.entity.EntityLivingBase; + +@Cancelable +public class LivingAttackEvent extends LivingEvent +{ + public final DamageSource source; + public final float ammount; + public LivingAttackEvent(EntityLivingBase entity, DamageSource source, float ammount) + { + super(entity); + this.source = source; + this.ammount = ammount; + } +} diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingDeathEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingDeathEvent.java new file mode 100644 index 0000000..b0b5c7e --- /dev/null +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingDeathEvent.java @@ -0,0 +1,17 @@ +package net.minecraftforge.event.entity.living; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import net.minecraft.util.DamageSource; +import net.minecraft.entity.EntityLivingBase; + +@Cancelable +public class LivingDeathEvent extends LivingEvent +{ + public final DamageSource source; + public LivingDeathEvent(EntityLivingBase entity, DamageSource source) + { + super(entity); + this.source = source; + } + +} diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingDropsEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingDropsEvent.java new file mode 100644 index 0000000..bd445a1 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingDropsEvent.java @@ -0,0 +1,29 @@ +package net.minecraftforge.event.entity.living; + +import java.util.ArrayList; + +import cpw.mods.fml.common.eventhandler.Cancelable; + +import net.minecraft.util.DamageSource; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.EntityLivingBase; + +@Cancelable +public class LivingDropsEvent extends LivingEvent +{ + public final DamageSource source; + public final ArrayList drops; + public final int lootingLevel; + public final boolean recentlyHit; + public final int specialDropValue; + + public LivingDropsEvent(EntityLivingBase entity, DamageSource source, ArrayList drops, int lootingLevel, boolean recentlyHit, int specialDropValue) + { + super(entity); + this.source = source; + this.drops = drops; + this.lootingLevel = lootingLevel; + this.recentlyHit = recentlyHit; + this.specialDropValue = specialDropValue; + } +} diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingEvent.java new file mode 100644 index 0000000..508187a --- /dev/null +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingEvent.java @@ -0,0 +1,26 @@ +package net.minecraftforge.event.entity.living; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import net.minecraft.entity.EntityLivingBase; +import net.minecraftforge.event.entity.EntityEvent; + +public class LivingEvent extends EntityEvent +{ + public final EntityLivingBase entityLiving; + public LivingEvent(EntityLivingBase entity) + { + super(entity); + entityLiving = entity; + } + + @Cancelable + public static class LivingUpdateEvent extends LivingEvent + { + public LivingUpdateEvent(EntityLivingBase e){ super(e); } + } + + public static class LivingJumpEvent extends LivingEvent + { + public LivingJumpEvent(EntityLivingBase e){ super(e); } + } +} diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingFallEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingFallEvent.java new file mode 100644 index 0000000..e0d9960 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingFallEvent.java @@ -0,0 +1,15 @@ +package net.minecraftforge.event.entity.living; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import net.minecraft.entity.EntityLivingBase; + +@Cancelable +public class LivingFallEvent extends LivingEvent +{ + public float distance; + public LivingFallEvent(EntityLivingBase entity, float distance) + { + super(entity); + this.distance = distance; + } +} diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingHurtEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingHurtEvent.java new file mode 100644 index 0000000..3df63aa --- /dev/null +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingHurtEvent.java @@ -0,0 +1,19 @@ +package net.minecraftforge.event.entity.living; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import net.minecraft.util.DamageSource; +import net.minecraft.entity.EntityLivingBase; + +@Cancelable +public class LivingHurtEvent extends LivingEvent +{ + public final DamageSource source; + public float ammount; + public LivingHurtEvent(EntityLivingBase entity, DamageSource source, float ammount) + { + super(entity); + this.source = source; + this.ammount = ammount; + } + +} diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingPackSizeEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingPackSizeEvent.java new file mode 100644 index 0000000..e55aa01 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingPackSizeEvent.java @@ -0,0 +1,23 @@ +package net.minecraftforge.event.entity.living; + +import cpw.mods.fml.common.eventhandler.Event.HasResult; +import net.minecraft.entity.EntityLiving; + +@HasResult +public class LivingPackSizeEvent extends LivingEvent +{ + /** + * This event is fired when the spawning system determines the + * maximum amount of the selected entity that can spawn at the same + * time. + * + * If you set the result to 'ALLOW', it means that you want to return + * the value of maxPackSize as the maximum pack size for current entity. + */ + public int maxPackSize; + + public LivingPackSizeEvent(EntityLiving entity) + { + super(entity); + } +} diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingSetAttackTargetEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingSetAttackTargetEvent.java new file mode 100644 index 0000000..6877550 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingSetAttackTargetEvent.java @@ -0,0 +1,15 @@ +package net.minecraftforge.event.entity.living; + +import net.minecraft.entity.EntityLivingBase; + +public class LivingSetAttackTargetEvent extends LivingEvent +{ + + public final EntityLivingBase target; + public LivingSetAttackTargetEvent(EntityLivingBase entity, EntityLivingBase target) + { + super(entity); + this.target = target; + } + +} diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingSpawnEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingSpawnEvent.java new file mode 100644 index 0000000..8701ba3 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingSpawnEvent.java @@ -0,0 +1,72 @@ +package net.minecraftforge.event.entity.living; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import net.minecraft.entity.EntityLiving; +import net.minecraft.world.World; + +public class LivingSpawnEvent extends LivingEvent +{ + public final World world; + public final float x; + public final float y; + public final float z; + + public LivingSpawnEvent(EntityLiving entity, World world, float x, float y, float z) + { + super(entity); + this.world = world; + this.x = x; + this.y = y; + this.z = z; + } + + /** + * Fires before mob spawn events. + * + * Result is significant: + * DEFAULT: use vanilla spawn rules + * ALLOW: allow the spawn + * DENY: deny the spawn + * + */ + @HasResult + public static class CheckSpawn extends LivingSpawnEvent + { + public CheckSpawn(EntityLiving entity, World world, float x, float y, float z) + { + super(entity, world, x, y, z); + } + } + + @Cancelable + public static class SpecialSpawn extends LivingSpawnEvent + { + public SpecialSpawn(EntityLiving entity, World world, float x, float y, float z) + { + super(entity, world, x, y, z); + } + } + + /** + * Fired each tick for despawnable mobs to allow control over despawning. + * {@link Result#DEFAULT} will pass the mob on to vanilla despawn mechanics. + * {@link Result#ALLOW} will force the mob to despawn. + * {@link Result#DENY} will force the mob to remain. + * This is fired every tick for every despawnable entity. Be efficient in your handlers. + * + * Note: this is not fired if the mob is definitely going to otherwise despawn. It is fired to check if + * the mob can be allowed to despawn. See {@link EntityLiving#despawnEntity} + * + * @author cpw + * + */ + @HasResult + public static class AllowDespawn extends LivingSpawnEvent + { + public AllowDespawn(EntityLiving entity) + { + super(entity, entity.worldObj, (float)entity.posX, (float)entity.posY, (float)entity.posZ); + } + + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/event/entity/living/ZombieEvent.java b/src/main/java/net/minecraftforge/event/entity/living/ZombieEvent.java new file mode 100644 index 0000000..8330196 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/entity/living/ZombieEvent.java @@ -0,0 +1,46 @@ +package net.minecraftforge.event.entity.living; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.monster.EntityZombie; +import net.minecraft.world.World; +import net.minecraftforge.event.entity.EntityEvent; + +public class ZombieEvent extends EntityEvent { + + public ZombieEvent(EntityZombie entity) + { + super(entity); + } + + public EntityZombie getSummoner() + { + return (EntityZombie) entity; + } + + @HasResult + public static class SummonAidEvent extends ZombieEvent { + /** + * Populate this field to have a custom zombie instead of a normal zombie summoned + */ + public EntityZombie customSummonedAid; + + public final World world; + public final int x; + public final int y; + public final int z; + public final EntityLivingBase attacker; + public final double summonChance; + + public SummonAidEvent(EntityZombie entity, World world, int x, int y, int z, EntityLivingBase attacker, double summonChance) + { + super(entity); + this.world = world; + this.x = x; + this.y = y; + this.z = z; + this.attacker = attacker; + this.summonChance = summonChance; + } + + } +} diff --git a/src/main/java/net/minecraftforge/event/entity/minecart/MinecartCollisionEvent.java b/src/main/java/net/minecraftforge/event/entity/minecart/MinecartCollisionEvent.java new file mode 100644 index 0000000..3f13aa5 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/entity/minecart/MinecartCollisionEvent.java @@ -0,0 +1,15 @@ +package net.minecraftforge.event.entity.minecart; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityMinecart; + +public class MinecartCollisionEvent extends MinecartEvent +{ + public final Entity collider; + + public MinecartCollisionEvent(EntityMinecart minecart, Entity collider) + { + super(minecart); + this.collider = collider; + } +} diff --git a/src/main/java/net/minecraftforge/event/entity/minecart/MinecartEvent.java b/src/main/java/net/minecraftforge/event/entity/minecart/MinecartEvent.java new file mode 100644 index 0000000..a58ef50 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/entity/minecart/MinecartEvent.java @@ -0,0 +1,15 @@ +package net.minecraftforge.event.entity.minecart; + +import net.minecraft.entity.item.EntityMinecart; +import net.minecraftforge.event.entity.EntityEvent; + +public class MinecartEvent extends EntityEvent +{ + public final EntityMinecart minecart; + + public MinecartEvent(EntityMinecart minecart) + { + super(minecart); + this.minecart = minecart; + } +} diff --git a/src/main/java/net/minecraftforge/event/entity/minecart/MinecartInteractEvent.java b/src/main/java/net/minecraftforge/event/entity/minecart/MinecartInteractEvent.java new file mode 100644 index 0000000..98a93fa --- /dev/null +++ b/src/main/java/net/minecraftforge/event/entity/minecart/MinecartInteractEvent.java @@ -0,0 +1,17 @@ +package net.minecraftforge.event.entity.minecart; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import net.minecraft.entity.item.EntityMinecart; +import net.minecraft.entity.player.EntityPlayer; + +@Cancelable +public class MinecartInteractEvent extends MinecartEvent +{ + public final EntityPlayer player; + + public MinecartInteractEvent(EntityMinecart minecart, EntityPlayer player) + { + super(minecart); + this.player = player; + } +} diff --git a/src/main/java/net/minecraftforge/event/entity/minecart/MinecartUpdateEvent.java b/src/main/java/net/minecraftforge/event/entity/minecart/MinecartUpdateEvent.java new file mode 100644 index 0000000..e809796 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/entity/minecart/MinecartUpdateEvent.java @@ -0,0 +1,18 @@ +package net.minecraftforge.event.entity.minecart; + +import net.minecraft.entity.item.EntityMinecart; + +public class MinecartUpdateEvent extends MinecartEvent +{ + public final float x; + public final float y; + public final float z; + + public MinecartUpdateEvent(EntityMinecart minecart, float x, float y, float z) + { + super(minecart); + this.x = x; + this.y = y; + this.z = z; + } +} diff --git a/src/main/java/net/minecraftforge/event/entity/player/ArrowLooseEvent.java b/src/main/java/net/minecraftforge/event/entity/player/ArrowLooseEvent.java new file mode 100644 index 0000000..2792a42 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/entity/player/ArrowLooseEvent.java @@ -0,0 +1,19 @@ +package net.minecraftforge.event.entity.player; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +@Cancelable +public class ArrowLooseEvent extends PlayerEvent +{ + public final ItemStack bow; + public int charge; + + public ArrowLooseEvent(EntityPlayer player, ItemStack bow, int charge) + { + super(player); + this.bow = bow; + this.charge = charge; + } +} diff --git a/src/main/java/net/minecraftforge/event/entity/player/ArrowNockEvent.java b/src/main/java/net/minecraftforge/event/entity/player/ArrowNockEvent.java new file mode 100644 index 0000000..cf3500f --- /dev/null +++ b/src/main/java/net/minecraftforge/event/entity/player/ArrowNockEvent.java @@ -0,0 +1,17 @@ +package net.minecraftforge.event.entity.player; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +@Cancelable +public class ArrowNockEvent extends PlayerEvent +{ + public ItemStack result; + + public ArrowNockEvent(EntityPlayer player, ItemStack result) + { + super(player); + this.result = result; + } +} diff --git a/src/main/java/net/minecraftforge/event/entity/player/AttackEntityEvent.java b/src/main/java/net/minecraftforge/event/entity/player/AttackEntityEvent.java new file mode 100644 index 0000000..de27733 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/entity/player/AttackEntityEvent.java @@ -0,0 +1,16 @@ +package net.minecraftforge.event.entity.player; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; + +@Cancelable +public class AttackEntityEvent extends PlayerEvent +{ + public final Entity target; + public AttackEntityEvent(EntityPlayer player, Entity target) + { + super(player); + this.target = target; + } +} diff --git a/src/main/java/net/minecraftforge/event/entity/player/BonemealEvent.java b/src/main/java/net/minecraftforge/event/entity/player/BonemealEvent.java new file mode 100644 index 0000000..acbfd45 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/entity/player/BonemealEvent.java @@ -0,0 +1,38 @@ +package net.minecraftforge.event.entity.player; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import cpw.mods.fml.common.eventhandler.Event; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; + +@Cancelable +@Event.HasResult +public class BonemealEvent extends PlayerEvent +{ + /** + * This event is called when a player attempts to use Bonemeal on a block. + * It can be canceled to completely prevent any further processing. + * + * You can also set the result to ALLOW to mark the event as processed + * and use up a bonemeal from the stack but do no further processing. + * + * setResult(ALLOW) is the same as the old setHandeled() + */ + + public final World world; + public final Block block; + public final int x; + public final int y; + public final int z; + + public BonemealEvent(EntityPlayer player, World world, Block block, int x, int y, int z) + { + super(player); + this.world = world; + this.block = block; + this.x = x; + this.y = y; + this.z = z; + } +} diff --git a/src/main/java/net/minecraftforge/event/entity/player/EntityInteractEvent.java b/src/main/java/net/minecraftforge/event/entity/player/EntityInteractEvent.java new file mode 100644 index 0000000..40883e5 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/entity/player/EntityInteractEvent.java @@ -0,0 +1,16 @@ +package net.minecraftforge.event.entity.player; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; + +@Cancelable +public class EntityInteractEvent extends PlayerEvent +{ + public final Entity target; + public EntityInteractEvent(EntityPlayer player, Entity target) + { + super(player); + this.target = target; + } +} diff --git a/src/main/java/net/minecraftforge/event/entity/player/EntityItemPickupEvent.java b/src/main/java/net/minecraftforge/event/entity/player/EntityItemPickupEvent.java new file mode 100644 index 0000000..6065315 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/entity/player/EntityItemPickupEvent.java @@ -0,0 +1,29 @@ +package net.minecraftforge.event.entity.player; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import cpw.mods.fml.common.eventhandler.Event; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; + +@Cancelable +@Event.HasResult +public class EntityItemPickupEvent extends PlayerEvent +{ + /** + * This event is called when a player collides with a EntityItem on the ground. + * The event can be canceled, and no further processing will be done. + * + * You can set the result of this event to ALLOW which will trigger the + * processing of achievements, FML's event, play the sound, and kill the + * entity if all the items are picked up. + * + * setResult(ALLOW) is the same as the old setHandled() + */ + public final EntityItem item; + + public EntityItemPickupEvent(EntityPlayer player, EntityItem item) + { + super(player); + this.item = item; + } +} diff --git a/src/main/java/net/minecraftforge/event/entity/player/FillBucketEvent.java b/src/main/java/net/minecraftforge/event/entity/player/FillBucketEvent.java new file mode 100644 index 0000000..d615c16 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/entity/player/FillBucketEvent.java @@ -0,0 +1,37 @@ +package net.minecraftforge.event.entity.player; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import cpw.mods.fml.common.eventhandler.Event; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; + +@Cancelable +@Event.HasResult +public class FillBucketEvent extends PlayerEvent +{ + /** + * This event is fired when a player attempts to use a Empty bucket, it + * can be canceled to completely prevent any further processing. + * + * If you set the result to 'ALLOW', it means that you have processed + * the event and wants the basic functionality of adding the new + * ItemStack to your inventory and reducing the stack size to process. + * setResult(ALLOW) is the same as the old setHandeled(); + */ + + public final ItemStack current; + public final World world; + public final MovingObjectPosition target; + + public ItemStack result; + + public FillBucketEvent(EntityPlayer player, ItemStack current, World world, MovingObjectPosition target) + { + super(player); + this.current = current; + this.world = world; + this.target = target; + } +} diff --git a/src/main/java/net/minecraftforge/event/entity/player/ItemTooltipEvent.java b/src/main/java/net/minecraftforge/event/entity/player/ItemTooltipEvent.java new file mode 100644 index 0000000..ba4d393 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/entity/player/ItemTooltipEvent.java @@ -0,0 +1,32 @@ +package net.minecraftforge.event.entity.player; + +import java.util.List; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +public class ItemTooltipEvent extends PlayerEvent +{ + /** + * Whether the advanced information on item tooltips is being shown, toggled by F3+H. + */ + public final boolean showAdvancedItemTooltips; + /** + * The {@link ItemStack} with the tooltip. + */ + public final ItemStack itemStack; + /** + * The {@link ItemStack} tooltip. + */ + public final List toolTip; + + /** + * This event is fired in {@link ItemStack#getTooltip(EntityPlayer, boolean)}, which in turn is called from it's respective GUIContainer. + */ + public ItemTooltipEvent(ItemStack itemStack, EntityPlayer entityPlayer, List toolTip, boolean showAdvancedItemTooltips) + { + super(entityPlayer); + this.itemStack = itemStack; + this.toolTip = toolTip; + this.showAdvancedItemTooltips = showAdvancedItemTooltips; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerDestroyItemEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerDestroyItemEvent.java new file mode 100644 index 0000000..7c3cbd1 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerDestroyItemEvent.java @@ -0,0 +1,15 @@ +package net.minecraftforge.event.entity.player; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +public class PlayerDestroyItemEvent extends PlayerEvent +{ + public final ItemStack original; + public PlayerDestroyItemEvent(EntityPlayer player, ItemStack original) + { + super(player); + this.original = original; + } + +} diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerDropsEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerDropsEvent.java new file mode 100644 index 0000000..b6827b4 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerDropsEvent.java @@ -0,0 +1,39 @@ +package net.minecraftforge.event.entity.player; + +import java.util.ArrayList; + +import cpw.mods.fml.common.eventhandler.Cancelable; + +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.DamageSource; +import net.minecraftforge.event.entity.living.LivingDropsEvent; + +/** + * Child class of LivingDropEvent that is fired specifically when a + * player dies. Canceling the event will prevent ALL drops from entering the + * world. + */ +@Cancelable +public class PlayerDropsEvent extends LivingDropsEvent +{ + public final EntityPlayer entityPlayer; + + /** + * Creates a new event containing all the items that will drop into the + * world when a player dies. + * @param entity The dying player. + * @param source The source of the damage which is killing the player. + * @param drops List of all drops entering the world. + */ + public PlayerDropsEvent(EntityPlayer entity, DamageSource source, ArrayList drops, boolean recentlyHit) + { + super(entity, source, drops, + (source.getEntity() instanceof EntityPlayer) ? + EnchantmentHelper.getLootingModifier(((EntityPlayer)source.getEntity())) : 0, + recentlyHit, 0); + + this.entityPlayer = entity; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerEvent.java new file mode 100644 index 0000000..fbcf587 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerEvent.java @@ -0,0 +1,71 @@ +package net.minecraftforge.event.entity.player; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraftforge.event.entity.living.LivingEvent; + +public class PlayerEvent extends LivingEvent +{ + public final EntityPlayer entityPlayer; + public PlayerEvent(EntityPlayer player) + { + super(player); + entityPlayer = player; + } + + public static class HarvestCheck extends PlayerEvent + { + public final Block block; + public boolean success; + + public HarvestCheck(EntityPlayer player, Block block, boolean success) + { + super(player); + this.block = block; + this.success = success; + } + } + + @Cancelable + public static class BreakSpeed extends PlayerEvent + { + public final Block block; + public final int metadata; + public final float originalSpeed; + public float newSpeed = 0.0f; + public final int x; + public final int y; // -1 notes unknown location + public final int z; + + @Deprecated + public BreakSpeed(EntityPlayer player, Block block, int metadata, float original) + { + this(player, block, metadata, original, 0, -1, 0); + } + + public BreakSpeed(EntityPlayer player, Block block, int metadata, float original, int x, int y, int z) + { + super(player); + this.block = block; + this.metadata = metadata; + this.originalSpeed = original; + this.newSpeed = original; + this.x = x; + this.y = y; + this.z = z; + } + } + + public static class NameFormat extends PlayerEvent + { + public final String username; + public String displayname; + + public NameFormat(EntityPlayer player, String username) { + super(player); + this.username = username; + this.displayname = username; + } + } +} diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerFlyableFallEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerFlyableFallEvent.java new file mode 100644 index 0000000..a52ddc7 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerFlyableFallEvent.java @@ -0,0 +1,21 @@ +package net.minecraftforge.event.entity.player; + +import net.minecraft.entity.player.EntityPlayer; + +/** + * Occurs when a player falls, but is able to fly. Doesn't need to be cancelable, this is mainly for notification purposes. + * @author Mithion + * + */ +public class PlayerFlyableFallEvent extends PlayerEvent +{ + + public float distance; + + public PlayerFlyableFallEvent(EntityPlayer player, float f) + { + super(player); + this.distance = f; + } + +} diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerInteractEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerInteractEvent.java new file mode 100644 index 0000000..b797bdb --- /dev/null +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerInteractEvent.java @@ -0,0 +1,44 @@ +package net.minecraftforge.event.entity.player; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import net.minecraft.entity.player.EntityPlayer; +import static cpw.mods.fml.common.eventhandler.Event.Result.*; + +@Cancelable +public class PlayerInteractEvent extends PlayerEvent +{ + public static enum Action + { + RIGHT_CLICK_AIR, + RIGHT_CLICK_BLOCK, + LEFT_CLICK_BLOCK + } + + public final Action action; + public final int x; + public final int y; + public final int z; + public final int face; + + public Result useBlock = DEFAULT; + public Result useItem = DEFAULT; + + public PlayerInteractEvent(EntityPlayer player, Action action, int x, int y, int z, int face) + { + super(player); + this.action = action; + this.x = x; + this.y = y; + this.z = z; + this.face = face; + if (face == -1) useBlock = DENY; + } + + @Override + public void setCanceled(boolean cancel) + { + super.setCanceled(cancel); + useBlock = (cancel ? DENY : useBlock == DENY ? DEFAULT : useBlock); + useItem = (cancel ? DENY : useItem == DENY ? DEFAULT : useItem); + } +} diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerOpenContainerEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerOpenContainerEvent.java new file mode 100644 index 0000000..5fced11 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerOpenContainerEvent.java @@ -0,0 +1,29 @@ +package net.minecraftforge.event.entity.player; + +import cpw.mods.fml.common.eventhandler.Event.HasResult; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; + +@HasResult +public class PlayerOpenContainerEvent extends PlayerEvent +{ + + public final boolean canInteractWith; + + /** + * This event is fired when a player attempts to view a container during + * player tick. + * + * setResult ALLOW to allow the container to stay open + * setResult DENY to force close the container (denying access) + * + * DEFAULT is vanilla behaviour + * + */ + + public PlayerOpenContainerEvent(EntityPlayer player, Container openContainer) + { + super(player); + this.canInteractWith = openContainer.canInteractWith(player); + } +} diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerPickupXpEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerPickupXpEvent.java new file mode 100644 index 0000000..6929b0e --- /dev/null +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerPickupXpEvent.java @@ -0,0 +1,21 @@ +package net.minecraftforge.event.entity.player; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import net.minecraft.entity.item.EntityXPOrb; +import net.minecraft.entity.player.EntityPlayer; + +/** + * This event is called when a player collides with a EntityXPOrb on the ground. + * The event can be canceled, and no further processing will be done. + */ +@Cancelable +public class PlayerPickupXpEvent extends PlayerEvent +{ + public final EntityXPOrb orb; + + public PlayerPickupXpEvent(EntityPlayer player, EntityXPOrb orb) + { + super(player); + this.orb = orb; + } +} diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerSleepInBedEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerSleepInBedEvent.java new file mode 100644 index 0000000..df76794 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerSleepInBedEvent.java @@ -0,0 +1,21 @@ +package net.minecraftforge.event.entity.player; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayer.EnumStatus; + +public class PlayerSleepInBedEvent extends PlayerEvent +{ + public EnumStatus result = null; + public final int x; + public final int y; + public final int z; + + public PlayerSleepInBedEvent(EntityPlayer player, int x, int y, int z) + { + super(player); + this.x = x; + this.y = y; + this.z = z; + } + +} diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerUseItemEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerUseItemEvent.java new file mode 100644 index 0000000..dacf356 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerUseItemEvent.java @@ -0,0 +1,94 @@ +package net.minecraftforge.event.entity.player; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +public abstract class PlayerUseItemEvent extends PlayerEvent +{ + public final ItemStack item; + public int duration; + + private PlayerUseItemEvent(EntityPlayer player, ItemStack item, int duration) + { + super(player); + this.item = item; + this.duration = duration; + } + + /** + * Fired when a player starts 'using' an item, typically when they hold right mouse. + * Examples: + * Drawing a bow + * Eating Food + * Drinking Potions/Milk + * Guarding with a sword + * + * Cancel the event, or set the duration or <= 0 to prevent it from processing. + * + */ + @Cancelable + public static class Start extends PlayerUseItemEvent + { + public Start(EntityPlayer player, ItemStack item, int duration) + { + super(player, item, duration); + } + } + + /** + * Fired every tick that a player is 'using' an item, see {@link Start} for info. + * + * Cancel the event, or set the duration or <= 0 to cause the player to stop using the item. + * + */ + @Cancelable + public static class Tick extends PlayerUseItemEvent + { + public Tick(EntityPlayer player, ItemStack item, int duration) + { + super(player, item, duration); + } + } + + /** + * Fired when a player stops using an item without the use duration timing out. + * Example: + * Stop eating 1/2 way through + * Stop defending with sword + * Stop drawing bow. This case would fire the arrow + * + * Duration on this event is how long the item had left in it's count down before 'finishing' + * + * Canceling this event will prevent the Item from being notified that it has stopped being used, + * The only vanilla item this would effect are bows, and it would cause them NOT to fire there arrow. + */ + @Cancelable + public static class Stop extends PlayerUseItemEvent + { + public Stop(EntityPlayer player, ItemStack item, int duration) + { + super(player, item, duration); + } + } + + /** + * Fired after an item has fully finished being used. + * The item has been notified that it was used, and the item/result stacks reflect after that state. + * This means that when this is fired for a Potion, the potion effect has already been applied. + * + * If you wish to cancel those effects, you should cancel one of the above events. + * + * The result item stack is the stack that is placed in the player's inventory in replacement of the stack that is currently being used. + * + */ + public static class Finish extends PlayerUseItemEvent + { + public ItemStack result; + public Finish(EntityPlayer player, ItemStack item, int duration, ItemStack result) + { + super(player, item, duration); + this.result = result; + } + } +} diff --git a/src/main/java/net/minecraftforge/event/entity/player/UseHoeEvent.java b/src/main/java/net/minecraftforge/event/entity/player/UseHoeEvent.java new file mode 100644 index 0000000..f3373d5 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/entity/player/UseHoeEvent.java @@ -0,0 +1,38 @@ +package net.minecraftforge.event.entity.player; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import cpw.mods.fml.common.eventhandler.Event; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +@Cancelable +@Event.HasResult +public class UseHoeEvent extends PlayerEvent +{ + /** + * This event is fired when a player attempts to use a Hoe on a block, it + * can be canceled to completely prevent any further processing. + * + * You can also set the result to ALLOW to mark the event as processed + * and damage the hoe. + * + * setResult(ALLOW) is the same as the old setHandeled(); + */ + + public final ItemStack current; + public final World world; + public final int x; + public final int y; + public final int z; + + public UseHoeEvent(EntityPlayer player, ItemStack current, World world, int x, int y, int z) + { + super(player); + this.current = current; + this.world = world; + this.x = x; + this.y = y; + this.z = z; + } +} diff --git a/src/main/java/net/minecraftforge/event/terraingen/BiomeEvent.java b/src/main/java/net/minecraftforge/event/terraingen/BiomeEvent.java new file mode 100644 index 0000000..82fe7f5 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/terraingen/BiomeEvent.java @@ -0,0 +1,117 @@ +package net.minecraftforge.event.terraingen; + +import cpw.mods.fml.common.eventhandler.Event; +import net.minecraft.block.Block; +import net.minecraft.world.biome.BiomeDecorator; +import net.minecraft.world.biome.BiomeGenBase; + +public class BiomeEvent extends Event +{ + public final BiomeGenBase biome; + + public BiomeEvent(BiomeGenBase biome) + { + this.biome = biome; + } + + public static class CreateDecorator extends BiomeEvent + { + public final BiomeDecorator originalBiomeDecorator; + public BiomeDecorator newBiomeDecorator; + + public CreateDecorator(BiomeGenBase biome, BiomeDecorator original) + { + super(biome); + originalBiomeDecorator = original; + newBiomeDecorator = original; + } + } + + public static class BiomeColor extends BiomeEvent + { + public final int originalColor; + public int newColor; + + public BiomeColor(BiomeGenBase biome, int original) + { + super(biome); + originalColor = original; + newColor = original; + } + } + + /** + * This event is fired when the village generator attempts to choose a block ID + * based on the village's biome. + * + * You can cancel the event to override default values + */ + @HasResult + public static class GetVillageBlockID extends BiomeEvent + { + public final Block original; + public final int type; + public Block replacement; + + public GetVillageBlockID(BiomeGenBase biome, Block original, int type) + { + super(biome); + this.original = original; + this.type = type; + } + } + + /** + * This event is fired when the village generator attempts to choose a block + * metadata based on the village's biome. + * + * You can set the result to DENY to prevent the default block metadata selection. + */ + @HasResult + public static class GetVillageBlockMeta extends BiomeEvent + { + public final Block original; + public final int type; + public int replacement; + + public GetVillageBlockMeta(BiomeGenBase biome, Block original, int type) + { + super(biome); + this.original = original; + this.type = type; + } + } + + /** + * This event is fired when a biome is queried for its grass color. + */ + public static class GetGrassColor extends BiomeColor + { + public GetGrassColor(BiomeGenBase biome, int original) + { + super(biome, original); + } + } + + /** + * This event is fired when a biome is queried for its grass color. + */ + public static class GetFoliageColor extends BiomeColor + { + public GetFoliageColor(BiomeGenBase biome, int original) + { + super(biome, original); + } + } + + /** + * This event is fired when a biome is queried for its water color. + */ + public static class GetWaterColor extends BiomeColor + { + public GetWaterColor(BiomeGenBase biome, int original) + { + super(biome, original); + } + } +} diff --git a/src/main/java/net/minecraftforge/event/terraingen/ChunkProviderEvent.java b/src/main/java/net/minecraftforge/event/terraingen/ChunkProviderEvent.java new file mode 100644 index 0000000..baebb57 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/terraingen/ChunkProviderEvent.java @@ -0,0 +1,72 @@ +package net.minecraftforge.event.terraingen; + +import cpw.mods.fml.common.eventhandler.Event; +import net.minecraft.block.Block; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.chunk.IChunkProvider; + +public class ChunkProviderEvent extends Event +{ + + public final IChunkProvider chunkProvider; + + public ChunkProviderEvent(IChunkProvider chunkProvider) + { + this.chunkProvider = chunkProvider; + } + + /** + * This event is fired when a chunks blocks are replaced by a biomes top and + * filler blocks. + * + * You can set the result to DENY to prevent the default replacement. + */ + @HasResult + public static class ReplaceBiomeBlocks extends ChunkProviderEvent + { + public final int chunkX; + public final int chunkZ; + public final Block[] blockArray; + public final BiomeGenBase[] biomeArray; + + public ReplaceBiomeBlocks(IChunkProvider chunkProvider, int chunkX, int chunkZ, Block[] blockArray, BiomeGenBase[] biomeArray) + { + super(chunkProvider); + this.chunkX = chunkX; + this.chunkZ = chunkZ; + this.blockArray = blockArray; + this.biomeArray = biomeArray; + } + + } + + /** + * This event is fired before a chunks terrain noise field is initialized. + * + * You can set the result to DENY to substitute your own noise field. + */ + @HasResult + public static class InitNoiseField extends ChunkProviderEvent + { + public double[] noisefield; + public final int posX; + public final int posY; + public final int posZ; + public final int sizeX; + public final int sizeY; + public final int sizeZ; + + public InitNoiseField(IChunkProvider chunkProvider, double[] noisefield, int posX, int posY, int posZ, int sizeX, int sizeY, int sizeZ) + { + super(chunkProvider); + this.noisefield = noisefield; + this.posX = posX; + this.posY = posY; + this.posZ = posZ; + this.sizeX = sizeX; + this.sizeY = sizeY; + this.sizeZ = sizeZ; + } + + } +} diff --git a/src/main/java/net/minecraftforge/event/terraingen/DecorateBiomeEvent.java b/src/main/java/net/minecraftforge/event/terraingen/DecorateBiomeEvent.java new file mode 100644 index 0000000..4c36fb0 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/terraingen/DecorateBiomeEvent.java @@ -0,0 +1,60 @@ +package net.minecraftforge.event.terraingen; + +import java.util.Random; + +import cpw.mods.fml.common.eventhandler.Event; + +import net.minecraft.world.World; + +public class DecorateBiomeEvent extends Event +{ + public final World world; + public final Random rand; + public final int chunkX; + public final int chunkZ; + + public DecorateBiomeEvent(World world, Random rand, int worldX, int worldZ) + { + this.world = world; + this.rand = rand; + this.chunkX = worldX; + this.chunkZ = worldZ; + } + + public static class Pre extends DecorateBiomeEvent + { + public Pre(World world, Random rand, int worldX, int worldZ) + { + super(world, rand, worldX, worldZ); + } + } + + public static class Post extends DecorateBiomeEvent + { + public Post(World world, Random rand, int worldX, int worldZ) + { + super(world, rand, worldX, worldZ); + } + } + + /** + * This event is fired when a chunk is decorated with a biome feature. + * + * You can set the result to DENY to prevent the default biome decoration. + */ + @HasResult + public static class Decorate extends DecorateBiomeEvent + { + /** Use CUSTOM to filter custom event types + */ + public static enum EventType { BIG_SHROOM, CACTUS, CLAY, DEAD_BUSH, LILYPAD, FLOWERS, GRASS, LAKE, PUMPKIN, REED, SAND, SAND_PASS2, SHROOM, TREE, CUSTOM } + + public final EventType type; + + public Decorate(World world, Random rand, int worldX, int worldZ, EventType type) + { + super(world, rand, worldX, worldZ); + this.type = type; + } + } +} diff --git a/src/main/java/net/minecraftforge/event/terraingen/DeferredBiomeDecorator.java b/src/main/java/net/minecraftforge/event/terraingen/DeferredBiomeDecorator.java new file mode 100644 index 0000000..4c5ab05 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/terraingen/DeferredBiomeDecorator.java @@ -0,0 +1,46 @@ +package net.minecraftforge.event.terraingen; + +import java.util.Random; + +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeDecorator; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraftforge.common.MinecraftForge; + +public class DeferredBiomeDecorator extends BiomeDecorator { + private BiomeDecorator wrapped; + + public DeferredBiomeDecorator(BiomeDecorator wrappedOriginal) + { + this.wrapped = wrappedOriginal; + } + + @Override + public void decorateChunk(World par1World, Random par2Random, BiomeGenBase biome, int par3, int par4) + { + fireCreateEventAndReplace(biome); + // On first call to decorate, we fire and substitute ourselves, if we haven't already done so + biome.theBiomeDecorator.decorateChunk(par1World, par2Random, biome, par3, par4); + } + public void fireCreateEventAndReplace(BiomeGenBase biome) + { + // Copy any configuration from us to the real instance. + wrapped.bigMushroomsPerChunk = bigMushroomsPerChunk; + wrapped.cactiPerChunk = cactiPerChunk; + wrapped.clayPerChunk = clayPerChunk; + wrapped.deadBushPerChunk = deadBushPerChunk; + wrapped.flowersPerChunk = flowersPerChunk; + wrapped.generateLakes = generateLakes; + wrapped.grassPerChunk = grassPerChunk; + wrapped.mushroomsPerChunk = mushroomsPerChunk; + wrapped.reedsPerChunk = reedsPerChunk; + wrapped.sandPerChunk = sandPerChunk; + wrapped.sandPerChunk2 = sandPerChunk2; + wrapped.treesPerChunk = treesPerChunk; + wrapped.waterlilyPerChunk = waterlilyPerChunk; + + BiomeEvent.CreateDecorator event = new BiomeEvent.CreateDecorator(biome, wrapped); + MinecraftForge.TERRAIN_GEN_BUS.post(event); + biome.theBiomeDecorator = event.newBiomeDecorator; + } +} diff --git a/src/main/java/net/minecraftforge/event/terraingen/InitMapGenEvent.java b/src/main/java/net/minecraftforge/event/terraingen/InitMapGenEvent.java new file mode 100644 index 0000000..eba1e2d --- /dev/null +++ b/src/main/java/net/minecraftforge/event/terraingen/InitMapGenEvent.java @@ -0,0 +1,22 @@ +package net.minecraftforge.event.terraingen; + +import cpw.mods.fml.common.eventhandler.Event; +import net.minecraft.world.gen.MapGenBase; + +public class InitMapGenEvent extends Event +{ + /** Use CUSTOM to filter custom event types + */ + public static enum EventType { CAVE, MINESHAFT, NETHER_BRIDGE, NETHER_CAVE, RAVINE, SCATTERED_FEATURE, STRONGHOLD, VILLAGE, CUSTOM } + + public final EventType type; + public final MapGenBase originalGen; + public MapGenBase newGen; + + InitMapGenEvent(EventType type, MapGenBase original) + { + this.type = type; + this.originalGen = original; + this.newGen = original; + } +} diff --git a/src/main/java/net/minecraftforge/event/terraingen/InitNoiseGensEvent.java b/src/main/java/net/minecraftforge/event/terraingen/InitNoiseGensEvent.java new file mode 100644 index 0000000..e0da762 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/terraingen/InitNoiseGensEvent.java @@ -0,0 +1,22 @@ +package net.minecraftforge.event.terraingen; + +import java.util.Random; + +import net.minecraft.world.World; +import net.minecraft.world.gen.NoiseGenerator; +import net.minecraftforge.event.world.*; + +public class InitNoiseGensEvent extends WorldEvent +{ + public final Random rand; + public final NoiseGenerator[] originalNoiseGens; + public NoiseGenerator[] newNoiseGens; + + public InitNoiseGensEvent(World world, Random rand, NoiseGenerator[] original) + { + super(world); + this.rand = rand; + originalNoiseGens = original; + newNoiseGens = original.clone(); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/event/terraingen/OreGenEvent.java b/src/main/java/net/minecraftforge/event/terraingen/OreGenEvent.java new file mode 100644 index 0000000..43036df --- /dev/null +++ b/src/main/java/net/minecraftforge/event/terraingen/OreGenEvent.java @@ -0,0 +1,61 @@ +package net.minecraftforge.event.terraingen; + +import java.util.Random; + +import cpw.mods.fml.common.eventhandler.Event; + +import net.minecraft.world.World; +import net.minecraft.world.gen.feature.WorldGenerator; + +public class OreGenEvent extends Event +{ + public final World world; + public final Random rand; + public final int worldX; + public final int worldZ; + + public OreGenEvent(World world, Random rand, int worldX, int worldZ) + { + this.world = world; + this.rand = rand; + this.worldX = worldX; + this.worldZ = worldZ; + } + + public static class Pre extends OreGenEvent + { + public Pre(World world, Random rand, int worldX, int worldZ) + { + super(world, rand, worldX, worldZ); + } + } + + public static class Post extends OreGenEvent + { + public Post(World world, Random rand, int worldX, int worldZ) + { + super(world, rand, worldX, worldZ); + } + } + + /** + * This event is fired when an ore is generated in a chunk. + * + * You can set the result to DENY to prevent the default ore generation. + */ + @HasResult + public static class GenerateMinable extends OreGenEvent + { + public static enum EventType { COAL, DIAMOND, DIRT, GOLD, GRAVEL, IRON, LAPIS, REDSTONE, QUARTZ, CUSTOM } + + public final EventType type; + public final WorldGenerator generator; + + public GenerateMinable(World world, Random rand, WorldGenerator generator, int worldX, int worldZ, EventType type) + { + super(world, rand, worldX, worldZ); + this.generator = generator; + this.type = type; + } + } +} diff --git a/src/main/java/net/minecraftforge/event/terraingen/PopulateChunkEvent.java b/src/main/java/net/minecraftforge/event/terraingen/PopulateChunkEvent.java new file mode 100644 index 0000000..6e33036 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/terraingen/PopulateChunkEvent.java @@ -0,0 +1,63 @@ +package net.minecraftforge.event.terraingen; + +import java.util.Random; + +import net.minecraft.world.World; +import net.minecraft.world.chunk.IChunkProvider; + +public class PopulateChunkEvent extends ChunkProviderEvent +{ + public final World world; + public final Random rand; + public final int chunkX; + public final int chunkZ; + public final boolean hasVillageGenerated; + + public PopulateChunkEvent(IChunkProvider chunkProvider, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated) + { + super(chunkProvider); + this.world = world; + this.rand = rand; + this.chunkX = chunkX; + this.chunkZ = chunkZ; + this.hasVillageGenerated = hasVillageGenerated; + } + + public static class Pre extends PopulateChunkEvent + { + public Pre(IChunkProvider chunkProvider, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated) + { + super(chunkProvider, world, rand, chunkX, chunkZ, hasVillageGenerated); + } + } + + public static class Post extends PopulateChunkEvent + { + public Post(IChunkProvider chunkProvider, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated) + { + super(chunkProvider, world, rand, chunkX, chunkZ, hasVillageGenerated); + } + } + + /** + * This event is fired when a chunk is populated with a terrain feature. + * + * You can set the result to DENY to prevent the default generation + * of a terrain feature. + */ + @HasResult + public static class Populate extends PopulateChunkEvent + { + /** Use CUSTOM to filter custom event types + */ + public static enum EventType { DUNGEON, FIRE, GLOWSTONE, ICE, LAKE, LAVA, NETHER_LAVA, ANIMALS, CUSTOM } + + public final EventType type; + + public Populate(IChunkProvider chunkProvider, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated, EventType type) + { + super(chunkProvider, world, rand, chunkX, chunkZ, hasVillageGenerated); + this.type = type; + } + } +} diff --git a/src/main/java/net/minecraftforge/event/terraingen/SaplingGrowTreeEvent.java b/src/main/java/net/minecraftforge/event/terraingen/SaplingGrowTreeEvent.java new file mode 100644 index 0000000..8c5604f --- /dev/null +++ b/src/main/java/net/minecraftforge/event/terraingen/SaplingGrowTreeEvent.java @@ -0,0 +1,31 @@ +package net.minecraftforge.event.terraingen; + +import java.util.Random; + +import cpw.mods.fml.common.eventhandler.Event.HasResult; + +import net.minecraft.world.World; +import net.minecraftforge.event.world.WorldEvent; + +/** + * This event is fired when a sapling grows a tree. + * + * You can set the result to DENY to prevent the default tree growth. + */ +@HasResult +public class SaplingGrowTreeEvent extends WorldEvent +{ + public final int x; + public final int y; + public final int z; + public final Random rand; + + public SaplingGrowTreeEvent(World world, Random rand, int x, int y, int z) + { + super(world); + this.rand = rand; + this.x = x; + this.y = y; + this.z = z; + } +} diff --git a/src/main/java/net/minecraftforge/event/terraingen/TerrainGen.java b/src/main/java/net/minecraftforge/event/terraingen/TerrainGen.java new file mode 100644 index 0000000..cef2162 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/terraingen/TerrainGen.java @@ -0,0 +1,60 @@ +package net.minecraftforge.event.terraingen; + +import java.util.Random; + +import cpw.mods.fml.common.eventhandler.Event.*; + +import net.minecraft.world.World; +import net.minecraft.world.chunk.IChunkProvider; +import net.minecraft.world.gen.MapGenBase; +import net.minecraft.world.gen.NoiseGenerator; +import net.minecraft.world.gen.feature.WorldGenerator; +import net.minecraftforge.common.*; +import net.minecraftforge.event.terraingen.DecorateBiomeEvent.*; +import net.minecraftforge.event.terraingen.OreGenEvent.*; +import net.minecraftforge.event.terraingen.PopulateChunkEvent.*; + +public abstract class TerrainGen +{ + public static NoiseGenerator[] getModdedNoiseGenerators(World world, Random rand, NoiseGenerator[] original) + { + InitNoiseGensEvent event = new InitNoiseGensEvent(world, rand, original); + MinecraftForge.TERRAIN_GEN_BUS.post(event); + return event.newNoiseGens; + } + + public static MapGenBase getModdedMapGen(MapGenBase original, InitMapGenEvent.EventType type) + { + InitMapGenEvent event = new InitMapGenEvent(type, original); + MinecraftForge.TERRAIN_GEN_BUS.post(event); + return event.newGen; + } + + public static boolean populate(IChunkProvider chunkProvider, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated, Populate.EventType type) + { + PopulateChunkEvent.Populate event = new PopulateChunkEvent.Populate(chunkProvider, world, rand, chunkX, chunkZ, hasVillageGenerated, type); + MinecraftForge.TERRAIN_GEN_BUS.post(event); + return event.getResult() != Result.DENY; + } + + public static boolean decorate(World world, Random rand, int chunkX, int chunkZ, Decorate.EventType type) + { + Decorate event = new Decorate(world, rand, chunkX, chunkZ, type); + MinecraftForge.TERRAIN_GEN_BUS.post(event); + return event.getResult() != Result.DENY; + } + + public static boolean generateOre(World world, Random rand, WorldGenerator generator, int worldX, int worldZ, GenerateMinable.EventType type) + { + GenerateMinable event = new GenerateMinable(world, rand, generator, worldX, worldZ, type); + MinecraftForge.ORE_GEN_BUS.post(event); + return event.getResult() != Result.DENY; + } + + public static boolean saplingGrowTree(World world, Random rand, int x, int y, int z) + { + SaplingGrowTreeEvent event = new SaplingGrowTreeEvent(world, rand, x, y, z); + MinecraftForge.TERRAIN_GEN_BUS.post(event); + return event.getResult() != Result.DENY; + } +} diff --git a/src/main/java/net/minecraftforge/event/terraingen/WorldTypeEvent.java b/src/main/java/net/minecraftforge/event/terraingen/WorldTypeEvent.java new file mode 100644 index 0000000..ab35cc1 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/terraingen/WorldTypeEvent.java @@ -0,0 +1,43 @@ +package net.minecraftforge.event.terraingen; + +import cpw.mods.fml.common.eventhandler.Event; +import net.minecraft.world.gen.layer.GenLayer; +import net.minecraft.world.WorldType; + +public class WorldTypeEvent extends Event +{ + public final WorldType worldType; + + public WorldTypeEvent(WorldType worldType) + { + this.worldType = worldType; + } + + public static class BiomeSize extends WorldTypeEvent + { + public final byte originalSize; + public byte newSize; + + public BiomeSize(WorldType worldType, byte original) + { + super(worldType); + originalSize = original; + newSize = original; + } + } + + public static class InitBiomeGens extends WorldTypeEvent + { + public final long seed; + public final GenLayer[] originalBiomeGens; + public GenLayer[] newBiomeGens; + + public InitBiomeGens(WorldType worldType, long seed, GenLayer[] original) + { + super(worldType); + this.seed = seed; + originalBiomeGens = original; + newBiomeGens = original.clone(); + } + } +} diff --git a/src/main/java/net/minecraftforge/event/world/BlockEvent.java b/src/main/java/net/minecraftforge/event/world/BlockEvent.java new file mode 100644 index 0000000..b19644b --- /dev/null +++ b/src/main/java/net/minecraftforge/event/world/BlockEvent.java @@ -0,0 +1,114 @@ +package net.minecraftforge.event.world; + +import java.util.ArrayList; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import cpw.mods.fml.common.eventhandler.Event; +import net.minecraft.block.Block; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraftforge.common.ForgeHooks; + +public class BlockEvent extends Event { + public final int x; + public final int y; + public final int z; + public final World world; + public final Block block; + public final int blockMetadata; + public BlockEvent(int x, int y, int z, World world, Block block, int blockMetadata) + { + this.x = x; + this.y = y; + this.z = z; + this.world = world; + this.block = block; + this.blockMetadata = blockMetadata; + } + + /** + * Fired when a block is about to drop it's harvested items. The {@link #drops} array can be amended, as can the {@link #dropChance}. + * Note well: the {@link #harvester} player field is null in a variety of scenarios. Code expecting null. + * + * The {@link #dropChance} is used to determine which items in this array will actually drop, compared to a random number. If you wish, you + * can pre-filter yourself, and set {@link #dropChance} to 1.0f to always drop the contents of the {@link #drops} array. + * + * {@link #isSilkTouching} is set if this is considered a silk touch harvesting operation, vs a normal harvesting operation. Act accordingly. + * + * @author cpw + */ + public static class HarvestDropsEvent extends BlockEvent { + public final int fortuneLevel; + public final ArrayList drops; + public final boolean isSilkTouching; + public float dropChance; // Change to e.g. 1.0f, if you manipulate the list and want to guarantee it always drops + public final EntityPlayer harvester; // May be null for non-player harvesting such as explosions or machines + + public HarvestDropsEvent(int x, int y, int z, World world, Block block, int blockMetadata, int fortuneLevel, float dropChance, ArrayList drops, EntityPlayer harvester, boolean isSilkTouching) + { + super(x, y, z, world, block, blockMetadata); + this.fortuneLevel = fortuneLevel; + this.dropChance = dropChance; + this.drops = drops; + this.isSilkTouching = isSilkTouching; + this.harvester = harvester; + } + } + + /** + * Event that is fired when an Block is about to be broken by a player + * Canceling this event will prevent the Block from being broken. + */ + @Cancelable + public static class BreakEvent extends BlockEvent + { + /** Reference to the Player who broke the block. If no player is available, use a EntityFakePlayer */ + private final EntityPlayer player; + private int exp; + + public BreakEvent(int x, int y, int z, World world, Block block, int blockMetadata, EntityPlayer player) + { + super(x, y, z, world, block, blockMetadata); + this.player = player; + + if (block == null || !ForgeHooks.canHarvestBlock(block, player, blockMetadata) || // Handle empty block or player unable to break block scenario + block.canSilkHarvest(world, player, x, y, z, blockMetadata) && EnchantmentHelper.getSilkTouchModifier(player)) // If the block is being silk harvested, the exp dropped is 0 + { + this.exp = 0; + } + else + { + int meta = block.getDamageValue(world, x, y, z); + int bonusLevel = EnchantmentHelper.getFortuneModifier(player); + this.exp = block.getExpDrop(world, meta, bonusLevel); + } + } + + public EntityPlayer getPlayer() + { + return player; + } + + /** + * Get the experience dropped by the block after the event has processed + * + * @return The experience to drop or 0 if the event was canceled + */ + public int getExpToDrop() + { + return this.isCanceled() ? 0 : exp; + } + + /** + * Set the amount of experience dropped by the block after the event has processed + * + * @param exp 1 or higher to drop experience, else nothing will drop + */ + public void setExpToDrop(int exp) + { + this.exp = exp; + } + } +} diff --git a/src/main/java/net/minecraftforge/event/world/ChunkDataEvent.java b/src/main/java/net/minecraftforge/event/world/ChunkDataEvent.java new file mode 100644 index 0000000..c339c53 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/world/ChunkDataEvent.java @@ -0,0 +1,36 @@ +package net.minecraftforge.event.world; + +import net.minecraft.world.chunk.Chunk; +import net.minecraft.nbt.NBTTagCompound; + +public class ChunkDataEvent extends ChunkEvent +{ + private final NBTTagCompound data; + + public ChunkDataEvent(Chunk chunk, NBTTagCompound data) + { + super(chunk); + this.data = data; + } + + public NBTTagCompound getData() + { + return data; + } + + public static class Load extends ChunkDataEvent + { + public Load(Chunk chunk, NBTTagCompound data) + { + super(chunk, data); + } + } + + public static class Save extends ChunkDataEvent + { + public Save(Chunk chunk, NBTTagCompound data) + { + super(chunk, data); + } + } +} diff --git a/src/main/java/net/minecraftforge/event/world/ChunkEvent.java b/src/main/java/net/minecraftforge/event/world/ChunkEvent.java new file mode 100644 index 0000000..c59f2ea --- /dev/null +++ b/src/main/java/net/minecraftforge/event/world/ChunkEvent.java @@ -0,0 +1,35 @@ +package net.minecraftforge.event.world; + +import net.minecraft.world.chunk.Chunk; + +public class ChunkEvent extends WorldEvent +{ + private final Chunk chunk; + + public ChunkEvent(Chunk chunk) + { + super(chunk.worldObj); + this.chunk = chunk; + } + + public Chunk getChunk() + { + return chunk; + } + + public static class Load extends ChunkEvent + { + public Load(Chunk chunk) + { + super(chunk); + } + } + + public static class Unload extends ChunkEvent + { + public Unload(Chunk chunk) + { + super(chunk); + } + } +} diff --git a/src/main/java/net/minecraftforge/event/world/ChunkWatchEvent.java b/src/main/java/net/minecraftforge/event/world/ChunkWatchEvent.java new file mode 100644 index 0000000..c183f6c --- /dev/null +++ b/src/main/java/net/minecraftforge/event/world/ChunkWatchEvent.java @@ -0,0 +1,27 @@ +package net.minecraftforge.event.world; + +import cpw.mods.fml.common.eventhandler.Event; +import net.minecraft.world.ChunkCoordIntPair; +import net.minecraft.entity.player.EntityPlayerMP; + +public class ChunkWatchEvent extends Event +{ + public final ChunkCoordIntPair chunk; + public final EntityPlayerMP player; + + public ChunkWatchEvent(ChunkCoordIntPair chunk, EntityPlayerMP player) + { + this.chunk = chunk; + this.player = player; + } + + public static class Watch extends ChunkWatchEvent + { + public Watch(ChunkCoordIntPair chunk, EntityPlayerMP player) { super(chunk, player); } + } + + public static class UnWatch extends ChunkWatchEvent + { + public UnWatch(ChunkCoordIntPair chunkLocation, EntityPlayerMP player) { super(chunkLocation, player); } + } +} diff --git a/src/main/java/net/minecraftforge/event/world/WorldEvent.java b/src/main/java/net/minecraftforge/event/world/WorldEvent.java new file mode 100644 index 0000000..860a45e --- /dev/null +++ b/src/main/java/net/minecraftforge/event/world/WorldEvent.java @@ -0,0 +1,66 @@ +package net.minecraftforge.event.world; + +import java.util.ArrayList; +import java.util.List; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import cpw.mods.fml.common.eventhandler.Event; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase.SpawnListEntry; + +public class WorldEvent extends Event +{ + public final World world; + + public WorldEvent(World world) + { + this.world = world; + } + + public static class Load extends WorldEvent + { + public Load(World world) { super(world); } + } + + public static class Unload extends WorldEvent + { + public Unload(World world) { super(world); } + } + + public static class Save extends WorldEvent + { + public Save(World world) { super(world); } + } + + /** + * Called by WorldServer to gather a list of all possible entities that can spawn at the specified location. + * Canceling the event will result in a empty list, meaning no entity will be spawned. + */ + @Cancelable + public static class PotentialSpawns extends WorldEvent + { + public final EnumCreatureType type; + public final int x; + public final int y; + public final int z; + public final List list; + + public PotentialSpawns(World world, EnumCreatureType type, int x, int y, int z, List oldList) + { + super(world); + this.x = x; + this.y = y; + this.z = z; + this.type = type; + if (oldList != null) + { + this.list = oldList; + } + else + { + this.list = new ArrayList(); + } + } + } +} diff --git a/src/main/java/net/minecraftforge/fluids/BlockFluidBase.java b/src/main/java/net/minecraftforge/fluids/BlockFluidBase.java new file mode 100644 index 0000000..f44c103 --- /dev/null +++ b/src/main/java/net/minecraftforge/fluids/BlockFluidBase.java @@ -0,0 +1,470 @@ +package net.minecraftforge.fluids; + +import java.util.HashMap; +import java.util.Map; +import java.util.Random; + +import com.google.common.collect.Maps; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.Vec3; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +/** + * This is a base implementation for Fluid blocks. + * + * It is highly recommended that you extend this class or one of the Forge-provided child classes. + * + * @author King Lemming, OvermindDL1 + * + */ +public abstract class BlockFluidBase extends Block implements IFluidBlock +{ + protected final static Map defaultDisplacements = Maps.newHashMap(); + + static + { + defaultDisplacements.put(Blocks.wooden_door, false); + defaultDisplacements.put(Blocks.iron_door, false); + defaultDisplacements.put(Blocks.standing_sign, false); + defaultDisplacements.put(Blocks.wall_sign, false); + defaultDisplacements.put(Blocks.reeds, false); + } + protected Map displacements = Maps.newHashMap(); + + protected int quantaPerBlock = 8; + protected float quantaPerBlockFloat = 8F; + protected int density = 1; + protected int densityDir = -1; + protected int temperature = 295; + + protected int tickRate = 20; + protected int renderPass = 1; + protected int maxScaledLight = 0; + + protected final String fluidName; + + public BlockFluidBase(Fluid fluid, Material material) + { + super(material); + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + this.setTickRandomly(true); + this.disableStats(); + + this.fluidName = fluid.getName(); + this.density = fluid.density; + this.temperature = fluid.temperature; + this.maxScaledLight = fluid.luminosity; + this.tickRate = fluid.viscosity / 200; + this.densityDir = fluid.density > 0 ? -1 : 1; + fluid.setBlock(this); + + displacements.putAll(defaultDisplacements); + } + + public BlockFluidBase setQuantaPerBlock(int quantaPerBlock) + { + if (quantaPerBlock > 16 || quantaPerBlock < 1) quantaPerBlock = 8; + this.quantaPerBlock = quantaPerBlock; + this.quantaPerBlockFloat = quantaPerBlock; + return this; + } + + public BlockFluidBase setDensity(int density) + { + if (density == 0) density = 1; + this.density = density; + this.densityDir = density > 0 ? -1 : 1; + return this; + } + + public BlockFluidBase setTemperature(int temperature) + { + this.temperature = temperature; + return this; + } + + public BlockFluidBase setTickRate(int tickRate) + { + if (tickRate <= 0) tickRate = 20; + this.tickRate = tickRate; + return this; + } + + public BlockFluidBase setRenderPass(int renderPass) + { + this.renderPass = renderPass; + return this; + } + + public BlockFluidBase setMaxScaledLight(int maxScaledLight) + { + this.maxScaledLight = maxScaledLight; + return this; + } + + /** + * Returns true if the block at (x, y, z) is displaceable. Does not displace the block. + */ + public boolean canDisplace(IBlockAccess world, int x, int y, int z) + { + if (world.getBlock(x, y, z).isAir(world, x, y, z)) return true; + + Block block = world.getBlock(x, y, z); + + if (block == this) + { + return false; + } + + if (displacements.containsKey(block)) + { + return displacements.get(block); + } + + Material material = block.getMaterial(); + if (material.blocksMovement() || material == Material.portal) + { + return false; + } + + int density = getDensity(world, x, y, z); + if (density == Integer.MAX_VALUE) + { + return true; + } + + if (this.density > density) + { + return true; + } + else + { + return false; + } + } + + /** + * Attempt to displace the block at (x, y, z), return true if it was displaced. + */ + public boolean displaceIfPossible(World world, int x, int y, int z) + { + if (world.getBlock(x, y, z).isAir(world, x, y, z)) + { + return true; + } + + Block block = world.getBlock(x, y, z); + if (block == this) + { + return false; + } + + if (displacements.containsKey(block)) + { + if (displacements.get(block)) + { + block.dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0); + return true; + } + return false; + } + + Material material = block.getMaterial(); + if (material.blocksMovement() || material == Material.portal) + { + return false; + } + + int density = getDensity(world, x, y, z); + if (density == Integer.MAX_VALUE) + { + block.dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0); + return true; + } + + if (this.density > density) + { + return true; + } + else + { + return false; + } + } + + public abstract int getQuantaValue(IBlockAccess world, int x, int y, int z); + + @Override + public abstract boolean canCollideCheck(int meta, boolean fullHit); + + public abstract int getMaxRenderHeightMeta(); + + /* BLOCK FUNCTIONS */ + @Override + public void onBlockAdded(World world, int x, int y, int z) + { + world.scheduleBlockUpdate(x, y, z, this, tickRate); + } + + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) + { + world.scheduleBlockUpdate(x, y, z, this, tickRate); + } + + // Used to prevent updates on chunk generation + @Override + public boolean func_149698_L() + { + return false; + } + + @Override + public boolean getBlocksMovement(IBlockAccess world, int x, int y, int z) + { + return true; + } + + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) + { + return null; + } + + @Override + public Item getItemDropped(int par1, Random par2Random, int par3) + { + return null; + } + + @Override + public int quantityDropped(Random par1Random) + { + return 0; + } + + @Override + public int tickRate(World world) + { + return tickRate; + } + + @Override + public void velocityToAddToEntity(World world, int x, int y, int z, Entity entity, Vec3 vec) + { + if (densityDir > 0) return; + Vec3 vec_flow = this.getFlowVector(world, x, y, z); + vec.xCoord += vec_flow.xCoord * (quantaPerBlock * 4); + vec.yCoord += vec_flow.yCoord * (quantaPerBlock * 4); + vec.zCoord += vec_flow.zCoord * (quantaPerBlock * 4); + } + + @Override + public int getLightValue(IBlockAccess world, int x, int y, int z) + { + if (maxScaledLight == 0) + { + return super.getLightValue(world, x, y, z); + } + int data = world.getBlockMetadata(x, y, z); + return (int) (data / quantaPerBlockFloat * maxScaledLight); + } + + @Override + public int getRenderType() + { + return FluidRegistry.renderIdFluid; + } + + @Override + public boolean isOpaqueCube() + { + return false; + } + + @Override + public boolean renderAsNormalBlock() + { + return false; + } + + /* Never used...? + @Override + public float getBlockBrightness(World world, int x, int y, int z) + { + float lightThis = world.getLightBrightness(x, y, z); + float lightUp = world.getLightBrightness(x, y + 1, z); + return lightThis > lightUp ? lightThis : lightUp; + } + */ + + @Override + public int getMixedBrightnessForBlock(IBlockAccess world, int x, int y, int z) + { + int lightThis = world.getLightBrightnessForSkyBlocks(x, y, z, 0); + int lightUp = world.getLightBrightnessForSkyBlocks(x, y + 1, z, 0); + int lightThisBase = lightThis & 255; + int lightUpBase = lightUp & 255; + int lightThisExt = lightThis >> 16 & 255; + int lightUpExt = lightUp >> 16 & 255; + return (lightThisBase > lightUpBase ? lightThisBase : lightUpBase) | + ((lightThisExt > lightUpExt ? lightThisExt : lightUpExt) << 16); + } + + @Override + public int getRenderBlockPass() + { + return renderPass; + } + + @Override + public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) + { + Block block = world.getBlock(x, y, z); + if (block != this) + { + return !block.isOpaqueCube(); + } + return block.getMaterial() == this.getMaterial() ? false : super.shouldSideBeRendered(world, x, y, z, side); + } + + /* FLUID FUNCTIONS */ + public static final int getDensity(IBlockAccess world, int x, int y, int z) + { + Block block = world.getBlock(x, y, z); + if (!(block instanceof BlockFluidBase)) + { + return Integer.MAX_VALUE; + } + return ((BlockFluidBase)block).density; + } + + public static final int getTemperature(IBlockAccess world, int x, int y, int z) + { + Block block = world.getBlock(x, y, z); + if (!(block instanceof BlockFluidBase)) + { + return Integer.MAX_VALUE; + } + return ((BlockFluidBase)block).temperature; + } + + public static double getFlowDirection(IBlockAccess world, int x, int y, int z) + { + Block block = world.getBlock(x, y, z); + if (!block.getMaterial().isLiquid()) + { + return -1000.0; + } + Vec3 vec = ((BlockFluidBase) block).getFlowVector(world, x, y, z); + return vec.xCoord == 0.0D && vec.zCoord == 0.0D ? -1000.0D : Math.atan2(vec.zCoord, vec.xCoord) - Math.PI / 2D; + } + + public final int getQuantaValueBelow(IBlockAccess world, int x, int y, int z, int belowThis) + { + int quantaRemaining = getQuantaValue(world, x, y, z); + if (quantaRemaining >= belowThis) + { + return -1; + } + return quantaRemaining; + } + + public final int getQuantaValueAbove(IBlockAccess world, int x, int y, int z, int aboveThis) + { + int quantaRemaining = getQuantaValue(world, x, y, z); + if (quantaRemaining <= aboveThis) + { + return -1; + } + return quantaRemaining; + } + + public final float getQuantaPercentage(IBlockAccess world, int x, int y, int z) + { + int quantaRemaining = getQuantaValue(world, x, y, z); + return quantaRemaining / quantaPerBlockFloat; + } + + public Vec3 getFlowVector(IBlockAccess world, int x, int y, int z) + { + Vec3 vec = world.getWorldVec3Pool().getVecFromPool(0.0D, 0.0D, 0.0D); + int decay = quantaPerBlock - getQuantaValue(world, x, y, z); + + for (int side = 0; side < 4; ++side) + { + int x2 = x; + int z2 = z; + + switch (side) + { + case 0: --x2; break; + case 1: --z2; break; + case 2: ++x2; break; + case 3: ++z2; break; + } + + int otherDecay = quantaPerBlock - getQuantaValue(world, x2, y, z2); + if (otherDecay >= quantaPerBlock) + { + if (!world.getBlock(x2, y, z2).getMaterial().blocksMovement()) + { + otherDecay = quantaPerBlock - getQuantaValue(world, x2, y - 1, z2); + if (otherDecay >= 0) + { + int power = otherDecay - (decay - quantaPerBlock); + vec = vec.addVector((x2 - x) * power, (y - y) * power, (z2 - z) * power); + } + } + } + else if (otherDecay >= 0) + { + int power = otherDecay - decay; + vec = vec.addVector((x2 - x) * power, (y - y) * power, (z2 - z) * power); + } + } + + if (world.getBlock(x, y + 1, z) == this) + { + boolean flag = + isBlockSolid(world, x, y, z - 1, 2) || + isBlockSolid(world, x, y, z + 1, 3) || + isBlockSolid(world, x - 1, y, z, 4) || + isBlockSolid(world, x + 1, y, z, 5) || + isBlockSolid(world, x, y + 1, z - 1, 2) || + isBlockSolid(world, x, y + 1, z + 1, 3) || + isBlockSolid(world, x - 1, y + 1, z, 4) || + isBlockSolid(world, x + 1, y + 1, z, 5); + + if (flag) + { + vec = vec.normalize().addVector(0.0D, -6.0D, 0.0D); + } + } + vec = vec.normalize(); + return vec; + } + + /* IFluidBlock */ + @Override + public Fluid getFluid() + { + return FluidRegistry.getFluid(fluidName); + } + + @Override + public float getFilledPercentage(World world, int x, int y, int z) + { + int quantaRemaining = getQuantaValue(world, x, y, z) + 1; + float remaining = quantaRemaining / quantaPerBlockFloat; + if (remaining > 1) remaining = 1.0f; + return remaining * (density > 0 ? 1 : -1); + } +} diff --git a/src/main/java/net/minecraftforge/fluids/BlockFluidClassic.java b/src/main/java/net/minecraftforge/fluids/BlockFluidClassic.java new file mode 100644 index 0000000..e6042fe --- /dev/null +++ b/src/main/java/net/minecraftforge/fluids/BlockFluidClassic.java @@ -0,0 +1,356 @@ +package net.minecraftforge.fluids; + +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +/** + * This is a fluid block implementation which emulates vanilla Minecraft fluid behavior. + * + * It is highly recommended that you use/extend this class for "classic" fluid blocks. + * + * @author King Lemming + * + */ +public class BlockFluidClassic extends BlockFluidBase +{ + protected boolean[] isOptimalFlowDirection = new boolean[4]; + protected int[] flowCost = new int[4]; + + protected FluidStack stack; + public BlockFluidClassic(Fluid fluid, Material material) + { + super(fluid, material); + stack = new FluidStack(fluid, FluidContainerRegistry.BUCKET_VOLUME); + } + + public BlockFluidClassic setFluidStack(FluidStack stack) + { + this.stack = stack; + return this; + } + + public BlockFluidClassic setFluidStackAmount(int amount) + { + this.stack.amount = amount; + return this; + } + + @Override + public int getQuantaValue(IBlockAccess world, int x, int y, int z) + { + if (world.getBlock(x, y, z) == Blocks.air) + { + return 0; + } + + if (world.getBlock(x, y, z) != this) + { + return -1; + } + + int quantaRemaining = quantaPerBlock - world.getBlockMetadata(x, y, z); + return quantaRemaining; + } + + @Override + public boolean canCollideCheck(int meta, boolean fullHit) + { + return fullHit && meta == 0; + } + + @Override + public int getMaxRenderHeightMeta() + { + return 0; + } + + @Override + public int getLightValue(IBlockAccess world, int x, int y, int z) + { + if (maxScaledLight == 0) + { + return super.getLightValue(world, x, y, z); + } + int data = quantaPerBlock - world.getBlockMetadata(x, y, z) - 1; + return (int) (data / quantaPerBlockFloat * maxScaledLight); + } + + @Override + public void updateTick(World world, int x, int y, int z, Random rand) + { + int quantaRemaining = quantaPerBlock - world.getBlockMetadata(x, y, z); + int expQuanta = -101; + + // check adjacent block levels if non-source + if (quantaRemaining < quantaPerBlock) + { + int y2 = y - densityDir; + + if (world.getBlock(x, y2, z ) == this || + world.getBlock(x - 1, y2, z ) == this || + world.getBlock(x + 1, y2, z ) == this || + world.getBlock(x, y2, z - 1) == this || + world.getBlock(x, y2, z + 1) == this) + { + expQuanta = quantaPerBlock - 1; + } + else + { + int maxQuanta = -100; + maxQuanta = getLargerQuanta(world, x - 1, y, z, maxQuanta); + maxQuanta = getLargerQuanta(world, x + 1, y, z, maxQuanta); + maxQuanta = getLargerQuanta(world, x, y, z - 1, maxQuanta); + maxQuanta = getLargerQuanta(world, x, y, z + 1, maxQuanta); + + expQuanta = maxQuanta - 1; + } + + // decay calculation + if (expQuanta != quantaRemaining) + { + quantaRemaining = expQuanta; + + if (expQuanta <= 0) + { + world.setBlock(x, y, z, Blocks.air); + } + else + { + world.setBlockMetadataWithNotify(x, y, z, quantaPerBlock - expQuanta, 3); + world.scheduleBlockUpdate(x, y, z, this, tickRate); + world.notifyBlocksOfNeighborChange(x, y, z, this); + } + } + } + // This is a "source" block, set meta to zero, and send a server only update + else if (quantaRemaining >= quantaPerBlock) + { + world.setBlockMetadataWithNotify(x, y, z, 0, 2); + } + + // Flow vertically if possible + if (canDisplace(world, x, y + densityDir, z)) + { + flowIntoBlock(world, x, y + densityDir, z, 1); + return; + } + + // Flow outward if possible + int flowMeta = quantaPerBlock - quantaRemaining + 1; + if (flowMeta >= quantaPerBlock) + { + return; + } + + if (isSourceBlock(world, x, y, z) || !isFlowingVertically(world, x, y, z)) + { + if (world.getBlock(x, y - densityDir, z) == this) + { + flowMeta = 1; + } + boolean flowTo[] = getOptimalFlowDirections(world, x, y, z); + + if (flowTo[0]) flowIntoBlock(world, x - 1, y, z, flowMeta); + if (flowTo[1]) flowIntoBlock(world, x + 1, y, z, flowMeta); + if (flowTo[2]) flowIntoBlock(world, x, y, z - 1, flowMeta); + if (flowTo[3]) flowIntoBlock(world, x, y, z + 1, flowMeta); + } + } + + public boolean isFlowingVertically(IBlockAccess world, int x, int y, int z) + { + return world.getBlock(x, y + densityDir, z) == this || + (world.getBlock(x, y, z) == this && canFlowInto(world, x, y + densityDir, z)); + } + + public boolean isSourceBlock(IBlockAccess world, int x, int y, int z) + { + return world.getBlock(x, y, z) == this && world.getBlockMetadata(x, y, z) == 0; + } + + protected boolean[] getOptimalFlowDirections(World world, int x, int y, int z) + { + for (int side = 0; side < 4; side++) + { + flowCost[side] = 1000; + + int x2 = x; + int y2 = y; + int z2 = z; + + switch (side) + { + case 0: --x2; break; + case 1: ++x2; break; + case 2: --z2; break; + case 3: ++z2; break; + } + + if (!canFlowInto(world, x2, y2, z2) || isSourceBlock(world, x2, y2, z2)) + { + continue; + } + + if (canFlowInto(world, x2, y2 + densityDir, z2)) + { + flowCost[side] = 0; + } + else + { + flowCost[side] = calculateFlowCost(world, x2, y2, z2, 1, side); + } + } + + int min = flowCost[0]; + for (int side = 1; side < 4; side++) + { + if (flowCost[side] < min) + { + min = flowCost[side]; + } + } + for (int side = 0; side < 4; side++) + { + isOptimalFlowDirection[side] = flowCost[side] == min; + } + return isOptimalFlowDirection; + } + + protected int calculateFlowCost(World world, int x, int y, int z, int recurseDepth, int side) + { + int cost = 1000; + for (int adjSide = 0; adjSide < 4; adjSide++) + { + if ((adjSide == 0 && side == 1) || + (adjSide == 1 && side == 0) || + (adjSide == 2 && side == 3) || + (adjSide == 3 && side == 2)) + { + continue; + } + + int x2 = x; + int y2 = y; + int z2 = z; + + switch (adjSide) + { + case 0: --x2; break; + case 1: ++x2; break; + case 2: --z2; break; + case 3: ++z2; break; + } + + if (!canFlowInto(world, x2, y2, z2) || isSourceBlock(world, x2, y2, z2)) + { + continue; + } + + if (canFlowInto(world, x2, y2 + densityDir, z2)) + { + return recurseDepth; + } + + if (recurseDepth >= 4) + { + continue; + } + + int min = calculateFlowCost(world, x2, y2, z2, recurseDepth + 1, adjSide); + if (min < cost) + { + cost = min; + } + } + return cost; + } + + protected void flowIntoBlock(World world, int x, int y, int z, int meta) + { + if (meta < 0) return; + if (displaceIfPossible(world, x, y, z)) + { + world.setBlock(x, y, z, this, meta, 3); + } + } + + protected boolean canFlowInto(IBlockAccess world, int x, int y, int z) + { + if (world.getBlock(x, y, z).isAir(world, x, y, z)) return true; + + Block block = world.getBlock(x, y, z); + if (block == this) + { + return true; + } + + if (displacements.containsKey(block)) + { + return displacements.get(block); + } + + Material material = block.getMaterial(); + if (material.blocksMovement() || + material == Material.water || + material == Material.lava || + material == Material.portal) + { + return false; + } + + int density = getDensity(world, x, y, z); + if (density == Integer.MAX_VALUE) + { + return true; + } + + if (this.density > density) + { + return true; + } + else + { + return false; + } + } + + protected int getLargerQuanta(IBlockAccess world, int x, int y, int z, int compare) + { + int quantaRemaining = getQuantaValue(world, x, y, z); + if (quantaRemaining <= 0) + { + return compare; + } + return quantaRemaining >= compare ? quantaRemaining : compare; + } + + /* IFluidBlock */ + @Override + public FluidStack drain(World world, int x, int y, int z, boolean doDrain) + { + if (!isSourceBlock(world, x, y, z)) + { + return null; + } + + if (doDrain) + { + world.setBlock(x, y, z, Blocks.air); + } + + return stack.copy(); + } + + @Override + public boolean canDrain(World world, int x, int y, int z) + { + return false; //isSourceBlock(world, x, y, z); + } + @Override public Fluid getFluid(){ return null; } + @Override public float getFilledPercentage(World world, int x, int y, int z) { return 0; } +} diff --git a/src/main/java/net/minecraftforge/fluids/BlockFluidFinite.java b/src/main/java/net/minecraftforge/fluids/BlockFluidFinite.java new file mode 100644 index 0000000..3373fab --- /dev/null +++ b/src/main/java/net/minecraftforge/fluids/BlockFluidFinite.java @@ -0,0 +1,323 @@ + +package net.minecraftforge.fluids; + +import java.util.Random; + +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +/** + * This is a cellular-automata based finite fluid block implementation. + * + * It is highly recommended that you use/extend this class for finite fluid blocks. + * + * @author OvermindDL1, KingLemming + * + */ +public class BlockFluidFinite extends BlockFluidBase +{ + public BlockFluidFinite(Fluid fluid, Material material) + { + super(fluid, material); + } + + @Override + public int getQuantaValue(IBlockAccess world, int x, int y, int z) + { + if (world.getBlock(x, y, z).isAir(world, x, y, z)) + { + return 0; + } + + if (world.getBlock(x, y, z) != this) + { + return -1; + } + + int quantaRemaining = world.getBlockMetadata(x, y, z) + 1; + return quantaRemaining; + } + + @Override + public boolean canCollideCheck(int meta, boolean fullHit) + { + return fullHit && meta == quantaPerBlock - 1; + } + + @Override + public int getMaxRenderHeightMeta() + { + return quantaPerBlock - 1; + } + + @Override + public void updateTick(World world, int x, int y, int z, Random rand) + { + boolean changed = false; + int quantaRemaining = world.getBlockMetadata(x, y, z) + 1; + + // Flow vertically if possible + int prevRemaining = quantaRemaining; + quantaRemaining = tryToFlowVerticallyInto(world, x, y, z, quantaRemaining); + + if (quantaRemaining < 1) + { + return; + } + else if (quantaRemaining != prevRemaining) + { + changed = true; + if (quantaRemaining == 1) + { + world.setBlockMetadataWithNotify(x, y, z, quantaRemaining - 1, 2); + return; + } + } + else if (quantaRemaining == 1) + { + return; + } + + // Flow out if possible + int lowerthan = quantaRemaining - 1; + if (displaceIfPossible(world, x, y, z - 1)) world.setBlock(x, y, z - 1, Blocks.air); + if (displaceIfPossible(world, x, y, z + 1)) world.setBlock(x, y, z + 1, Blocks.air); + if (displaceIfPossible(world, x - 1, y, z )) world.setBlock(x - 1, y, z, Blocks.air); + if (displaceIfPossible(world, x + 1, y, z )) world.setBlock(x + 1, y, z, Blocks.air); + int north = getQuantaValueBelow(world, x, y, z - 1, lowerthan); + int south = getQuantaValueBelow(world, x, y, z + 1, lowerthan); + int west = getQuantaValueBelow(world, x - 1, y, z, lowerthan); + int east = getQuantaValueBelow(world, x + 1, y, z, lowerthan); + int total = quantaRemaining; + int count = 1; + + if (north >= 0) + { + count++; + total += north; + } + + if (south >= 0) + { + count++; + total += south; + } + + if (west >= 0) + { + count++; + total += west; + } + + if (east >= 0) + { + ++count; + total += east; + } + + if (count == 1) + { + if (changed) + { + world.setBlockMetadataWithNotify(x, y, z, quantaRemaining - 1, 2); + } + return; + } + + int each = total / count; + int rem = total % count; + if (north >= 0) + { + int newnorth = each; + if (rem == count || rem > 1 && rand.nextInt(count - rem) != 0) + { + ++newnorth; + --rem; + } + + if (newnorth != north) + { + if (newnorth == 0) + { + world.setBlock(x, y, z - 1, Blocks.air); + } + else + { + world.setBlock(x, y, z - 1, this, newnorth - 1, 2); + } + world.scheduleBlockUpdate(x, y, z - 1, this, tickRate); + } + --count; + } + + if (south >= 0) + { + int newsouth = each; + if (rem == count || rem > 1 && rand.nextInt(count - rem) != 0) + { + ++newsouth; + --rem; + } + + if (newsouth != south) + { + if (newsouth == 0) + { + world.setBlock(x, y, z + 1, Blocks.air); + } + else + { + world.setBlock(x, y, z + 1, this, newsouth - 1, 2); + } + world.scheduleBlockUpdate(x, y, z + 1, this, tickRate); + } + --count; + } + + if (west >= 0) + { + int newwest = each; + if (rem == count || rem > 1 && rand.nextInt(count - rem) != 0) + { + ++newwest; + --rem; + } + if (newwest != west) + { + if (newwest == 0) + { + world.setBlock(x - 1, y, z, Blocks.air); + } + else + { + world.setBlock(x - 1, y, z, this, newwest - 1, 2); + } + world.scheduleBlockUpdate(x - 1, y, z, this, tickRate); + } + --count; + } + + if (east >= 0) + { + int neweast = each; + if (rem == count || rem > 1 && rand.nextInt(count - rem) != 0) + { + ++neweast; + --rem; + } + + if (neweast != east) + { + if (neweast == 0) + { + world.setBlock(x + 1, y, z, Blocks.air); + } + else + { + world.setBlock(x + 1, y, z, this, neweast - 1, 2); + } + world.scheduleBlockUpdate(x + 1, y, z, this, tickRate); + } + --count; + } + + if (rem > 0) + { + ++each; + } + world.setBlockMetadataWithNotify(x, y, z, each - 1, 2); + } + + public int tryToFlowVerticallyInto(World world, int x, int y, int z, int amtToInput) + { + int otherY = y + densityDir; + if (otherY < 0 || otherY >= world.getHeight()) + { + world.setBlock(x, y, z, Blocks.air); + return 0; + } + + int amt = getQuantaValueBelow(world, x, otherY, z, quantaPerBlock); + if (amt >= 0) + { + amt += amtToInput; + if (amt > quantaPerBlock) + { + world.setBlock(x, otherY, z, this, quantaPerBlock - 1, 3); + world.scheduleBlockUpdate(x, otherY, z, this, tickRate); + return amt - quantaPerBlock; + } + else if (amt > 0) + { + world.setBlock(x, otherY, z, this, amt - 1, 3); + world.scheduleBlockUpdate(x, otherY, z, this, tickRate); + world.setBlock(x, y, z, Blocks.air); + return 0; + } + return amtToInput; + } + else + { + int density_other = getDensity(world, x, otherY, z); + if (density_other == Integer.MAX_VALUE) + { + if (displaceIfPossible(world, x, otherY, z)) + { + world.setBlock(x, otherY, z, this, amtToInput - 1, 3); + world.scheduleBlockUpdate(x, otherY, z, this, tickRate); + world.setBlock(x, y, z, Blocks.air); + return 0; + } + else + { + return amtToInput; + } + } + + if (densityDir < 0) + { + if (density_other < density) // then swap + { + BlockFluidBase block = (BlockFluidBase)world.getBlock(x, otherY, z); + int otherData = world.getBlockMetadata(x, otherY, z); + world.setBlock(x, otherY, z, this, amtToInput - 1, 3); + world.setBlock(x, y, z, block, otherData, 3); + world.scheduleBlockUpdate(x, otherY, z, this, tickRate); + world.scheduleBlockUpdate(x, y, z, block, block.tickRate(world)); + return 0; + } + } + else + { + if (density_other > density) + { + BlockFluidBase block = (BlockFluidBase)world.getBlock(x, otherY, z); + int otherData = world.getBlockMetadata(x, otherY, z); + world.setBlock(x, otherY, z, this, amtToInput - 1, 3); + world.setBlock(x, y, z, block, otherData, 3); + world.scheduleBlockUpdate(x, otherY, z, this, tickRate); + world.scheduleBlockUpdate(x, y, z, block, block.tickRate(world)); + return 0; + } + } + return amtToInput; + } + } + + /* IFluidBlock */ + @Override + public FluidStack drain(World world, int x, int y, int z, boolean doDrain) + { + return null; + } + + @Override + public boolean canDrain(World world, int x, int y, int z) + { + return false; + } + @Override public Fluid getFluid() { return null; } + @Override public float getFilledPercentage(World world, int x, int y, int z) { return 0; } +} diff --git a/src/main/java/net/minecraftforge/fluids/Fluid.java b/src/main/java/net/minecraftforge/fluids/Fluid.java new file mode 100644 index 0000000..0c299a7 --- /dev/null +++ b/src/main/java/net/minecraftforge/fluids/Fluid.java @@ -0,0 +1,319 @@ +package net.minecraftforge.fluids; + +import java.util.Locale; +import java.util.Map; + +import com.google.common.collect.Maps; + +import net.minecraft.block.Block; +import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import net.minecraftforge.common.ForgeModContainer; +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.LoaderException; +import net.minecraft.item.EnumRarity; + +/** + * Minecraft Forge Fluid Implementation + * + * This class is a fluid (liquid or gas) equivalent to "Item." It describes the nature of a fluid + * and contains its general properties. + * + * These properties do not have inherent gameplay mechanics - they are provided so that mods may + * choose to take advantage of them. + * + * Fluid implementations are not required to actively use these properties, nor are objects + * interfacing with fluids required to make use of them, but it is encouraged. + * + * The default values can be used as a reference point for mods adding fluids such as oil or heavy + * water. + * + * @author King Lemming + * + */ +public class Fluid +{ + /** The unique identification name for this fluid. */ + protected final String fluidName; + + /** The unlocalized name of this fluid. */ + protected String unlocalizedName; + + /** The Icons for this fluid. */ + protected IIcon stillIcon; + protected IIcon flowingIcon; + + /** + * The light level emitted by this fluid. + * + * Default value is 0, as most fluids do not actively emit light. + */ + protected int luminosity = 0; + + /** + * Density of the fluid - completely arbitrary; negative density indicates that the fluid is + * lighter than air. + * + * Default value is approximately the real-life density of water in kg/m^3. + */ + protected int density = 1000; + + /** + * Temperature of the fluid - completely arbitrary; higher temperature indicates that the fluid is + * hotter than air. + * + * Default value is approximately the real-life room temperature of water in degrees Kelvin. + */ + protected int temperature = 295; + + /** + * Viscosity ("thickness") of the fluid - completely arbitrary; negative values are not + * permissible. + * + * Default value is approximately the real-life density of water in m/s^2 (x10^-3). + */ + protected int viscosity = 1000; + + /** + * This indicates if the fluid is gaseous. + * + * Useful for rendering the fluid in containers and the world. + * + * Generally this is associated with negative density fluids. + */ + protected boolean isGaseous; + + /** + * The rarity of the fluid. + * + * Used primarily in tool tips. + */ + protected EnumRarity rarity = EnumRarity.common; + + /** + * If there is a Block implementation of the Fluid, the Block is linked here. + * + * The default value of null should remain for any Fluid without a Block implementation. + */ + protected Block block = null; + + public Fluid(String fluidName) + { + this.fluidName = fluidName.toLowerCase(Locale.ENGLISH); + this.unlocalizedName = fluidName; + } + + public Fluid setUnlocalizedName(String unlocalizedName) + { + this.unlocalizedName = unlocalizedName; + return this; + } + + public Fluid setBlock(Block block) + { + if (this.block == null || this.block == block) + { + this.block = block; + } + else if (!ForgeModContainer.forceDuplicateFluidBlockCrash) + { + FMLLog.warning("A mod has attempted to assign Block " + block + " to the Fluid '" + fluidName + "' but this Fluid has already been linked to BlockID " + + this.block + ". Configure your mods to prevent this from happening."); + } + else + { + FMLLog.severe("A mod has attempted to assign BlockID " + block + " to the Fluid '" + fluidName + "' but this Fluid has already been linked to BlockID " + + this.block + ". Configure your mods to prevent this from happening."); + throw new LoaderException(new RuntimeException("A mod has attempted to assign BlockID " + block + " to the Fluid '" + fluidName + + "' but this Fluid has already been linked to BlockID " + this.block + ". Configure your mods to prevent this from happening.")); + } + return this; + } + + public Fluid setLuminosity(int luminosity) + { + this.luminosity = luminosity; + return this; + } + + public Fluid setDensity(int density) + { + this.density = density; + return this; + } + + public Fluid setTemperature(int temperature) + { + this.temperature = temperature; + return this; + } + + public Fluid setViscosity(int viscosity) + { + this.viscosity = viscosity; + return this; + } + + public Fluid setGaseous(boolean isGaseous) + { + this.isGaseous = isGaseous; + return this; + } + + public Fluid setRarity(EnumRarity rarity) + { + this.rarity = rarity; + return this; + } + + public final String getName() + { + return this.fluidName; + } + + public final int getID() + { + return FluidRegistry.getFluidID(this.fluidName); + } + + public final Block getBlock() + { + return block; + } + + public final boolean canBePlacedInWorld() + { + return block != null; + } + + /** + * Returns the localized name of this fluid. + */ + public String getLocalizedName() + { + String s = this.getUnlocalizedName(); + return s == null ? "" : StatCollector.translateToLocal(s); + } + + /** + * Returns the unlocalized name of this fluid. + */ + public String getUnlocalizedName() + { + return "fluid." + this.unlocalizedName; + } + + /** + * Returns 0 for "/terrain.png". ALL FLUID TEXTURES MUST BE ON THIS SHEET. + */ + public final int getSpriteNumber() + { + return 0; + } + + /* Default Accessors */ + public final int getLuminosity() + { + return this.luminosity; + } + + public final int getDensity() + { + return this.density; + } + + public final int getTemperature() + { + return this.temperature; + } + + public final int getViscosity() + { + return this.viscosity; + } + + public final boolean isGaseous() + { + return this.isGaseous; + } + + public EnumRarity getRarity() + { + return rarity; + } + + public int getColor() + { + return 0xFFFFFF; + } + + public final Fluid setStillIcon(IIcon stillIcon) + { + this.stillIcon = stillIcon; + return this; + } + + public final Fluid setFlowingIcon(IIcon flowingIcon) + { + this.flowingIcon = flowingIcon; + return this; + } + + public final Fluid setIcons(IIcon stillIcon, IIcon flowingIcon) + { + return this.setStillIcon(stillIcon).setFlowingIcon(flowingIcon); + } + + public final Fluid setIcons(IIcon commonIcon) + { + return this.setStillIcon(commonIcon).setFlowingIcon(commonIcon); + } + + public IIcon getIcon(){ return getStillIcon(); } + + public IIcon getStillIcon() + { + return this.stillIcon; + } + + public IIcon getFlowingIcon() + { + return this.flowingIcon; + } + + /* Stack-based Accessors */ + public int getLuminosity(FluidStack stack){ return getLuminosity(); } + public int getDensity(FluidStack stack){ return getDensity(); } + public int getTemperature(FluidStack stack){ return getTemperature(); } + public int getViscosity(FluidStack stack){ return getViscosity(); } + public boolean isGaseous(FluidStack stack){ return isGaseous(); } + public EnumRarity getRarity(FluidStack stack){ return getRarity(); } + public int getColor(FluidStack stack){ return getColor(); } + public IIcon getIcon(FluidStack stack){ return getIcon(); } + /* World-based Accessors */ + public int getLuminosity(World world, int x, int y, int z){ return getLuminosity(); } + public int getDensity(World world, int x, int y, int z){ return getDensity(); } + public int getTemperature(World world, int x, int y, int z){ return getTemperature(); } + public int getViscosity(World world, int x, int y, int z){ return getViscosity(); } + public boolean isGaseous(World world, int x, int y, int z){ return isGaseous(); } + public EnumRarity getRarity(World world, int x, int y, int z){ return getRarity(); } + public int getColor(World world, int x, int y, int z){ return getColor(); } + public IIcon getIcon(World world, int x, int y, int z){ return getIcon(); } + + private static Map legacyNames = Maps.newHashMap(); + static String convertLegacyName(String fluidName) + { + return fluidName != null && legacyNames.containsKey(fluidName) ? legacyNames.get(fluidName) : fluidName; + } + + /** + * Register a legacy liquid name with the Fluids system + * @param legacyName The legacy name to recognize + * @param canonicalName The canonical fluid name it will become + */ + public static void registerLegacyName(String legacyName, String canonicalName) + { + legacyNames.put(legacyName.toLowerCase(Locale.ENGLISH), canonicalName); + } +} diff --git a/src/main/java/net/minecraftforge/fluids/FluidContainerRegistry.java b/src/main/java/net/minecraftforge/fluids/FluidContainerRegistry.java new file mode 100644 index 0000000..8cddbd1 --- /dev/null +++ b/src/main/java/net/minecraftforge/fluids/FluidContainerRegistry.java @@ -0,0 +1,322 @@ + +package net.minecraftforge.fluids; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; + +import cpw.mods.fml.common.eventhandler.Event; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.MinecraftForge; + +/** + * Register simple items that contain fluids here. Useful for buckets, bottles, and things that have + * ID/metadata mappings. + * + * For more complex items, use {@link IFluidContainerItem} instead. + * + * @author King Lemming + * + */ +public abstract class FluidContainerRegistry +{ + // Holder object that implements HashCode for an ItemStack, + // the local maps are not guaranteed to have the same internal generic structure, + // but the external interface for checking ItemStacks will still exist. + private static class ContainerKey + { + ItemStack container; + FluidStack fluid; + private ContainerKey(ItemStack container) + { + this.container = container; + } + private ContainerKey(ItemStack container, FluidStack fluid) + { + this(container); + this.fluid = fluid; + } + @Override + public int hashCode() + { + int code = 1; + code = 31*code + container.getItem().hashCode(); + code = 31*code + container.getItemDamage(); + if (fluid != null) + code = 31*code + fluid.fluidID; + return code; + } + @Override + public boolean equals(Object o) + { + if (!(o instanceof ContainerKey)) return false; + ContainerKey ck = (ContainerKey)o; + if (container.getItem() != ck.container.getItem()) return false; + if (container.getItemDamage() != ck.container.getItemDamage()) return false; + if (fluid == null && ck.fluid != null) return false; + if (fluid != null && ck.fluid == null) return false; + if (fluid == null && ck.fluid == null) return true; + if (fluid.fluidID != ck.fluid.fluidID) return false; + return true; + } + } + + private static Map containerFluidMap = Maps.newHashMap(); + private static Map filledContainerMap = Maps.newHashMap(); + private static Set emptyContainers = Sets.newHashSet(); + + public static final int BUCKET_VOLUME = 1000; + public static final ItemStack EMPTY_BUCKET = new ItemStack(Items.bucket); + public static final ItemStack EMPTY_BOTTLE = new ItemStack(Items.glass_bottle); + private static final ItemStack NULL_EMPTYCONTAINER = new ItemStack(Items.bucket); + + static + { + registerFluidContainer(FluidRegistry.WATER, new ItemStack(Items.water_bucket), EMPTY_BUCKET); + registerFluidContainer(FluidRegistry.LAVA, new ItemStack(Items.lava_bucket), EMPTY_BUCKET); + registerFluidContainer(FluidRegistry.WATER, new ItemStack(Items.potionitem), EMPTY_BOTTLE); + } + + private FluidContainerRegistry(){} + + /** + * Register a new fluid containing item. + * + * @param stack + * FluidStack containing the type and amount of the fluid stored in the item. + * @param filledContainer + * ItemStack representing the container when it is full. + * @param emptyContainer + * ItemStack representing the container when it is empty. + * @return True if container was successfully registered; false if it already is. + */ + public static boolean registerFluidContainer(FluidStack stack, ItemStack filledContainer, ItemStack emptyContainer) + { + return registerFluidContainer(new FluidContainerData(stack, filledContainer, emptyContainer)); + } + + /** + * Register a new fluid containing item. The item is assumed to hold 1000 mB of fluid. Also + * registers the Fluid if possible. + * + * @param fluid + * Fluid type that is stored in the item. + * @param filledContainer + * ItemStack representing the container when it is full. + * @param emptyContainer + * ItemStack representing the container when it is empty. + * @return True if container was successfully registered; false if it already is. + */ + public static boolean registerFluidContainer(Fluid fluid, ItemStack filledContainer, ItemStack emptyContainer) + { + if (!FluidRegistry.isFluidRegistered(fluid)) + { + FluidRegistry.registerFluid(fluid); + } + return registerFluidContainer(new FluidStack(fluid, BUCKET_VOLUME), filledContainer, emptyContainer); + } + + /** + * Register a new fluid containing item that does not have an empty container. + * + * @param stack + * FluidStack containing the type and amount of the fluid stored in the item. + * @param filledContainer + * ItemStack representing the container when it is full. + * @return True if container was successfully registered; false if it already is. + */ + public static boolean registerFluidContainer(FluidStack stack, ItemStack filledContainer) + { + return registerFluidContainer(new FluidContainerData(stack, filledContainer, null, true)); + } + + /** + * Register a new fluid containing item that does not have an empty container. The item is + * assumed to hold 1000 mB of fluid. Also registers the Fluid if possible. + * + * @param fluid + * Fluid type that is stored in the item. + * @param filledContainer + * ItemStack representing the container when it is full. + * @return True if container was successfully registered; false if it already is. + */ + public static boolean registerFluidContainer(Fluid fluid, ItemStack filledContainer) + { + if (!FluidRegistry.isFluidRegistered(fluid)) + { + FluidRegistry.registerFluid(fluid); + } + return registerFluidContainer(new FluidStack(fluid, BUCKET_VOLUME), filledContainer); + } + + /** + * Register a new fluid containing item. + * + * @param data + * See {@link FluidContainerData}. + * @return True if container was successfully registered; false if it already is. + */ + public static boolean registerFluidContainer(FluidContainerData data) + { + if (isFilledContainer(data.filledContainer)) + { + return false; + } + containerFluidMap.put(new ContainerKey(data.filledContainer), data); + + if (data.emptyContainer != null && data.emptyContainer != NULL_EMPTYCONTAINER) + { + filledContainerMap.put(new ContainerKey(data.emptyContainer, data.fluid), data); + emptyContainers.add(new ContainerKey(data.emptyContainer)); + } + + MinecraftForge.EVENT_BUS.post(new FluidContainerRegisterEvent(data)); + return true; + } + + /** + * Determines the fluid type and amount inside a container. + * + * @param container + * The fluid container. + * @return FluidStack representing stored fluid. + */ + public static FluidStack getFluidForFilledItem(ItemStack container) + { + if (container == null) + { + return null; + } + + FluidContainerData data = containerFluidMap.get(new ContainerKey(container)); + return data == null ? null : data.fluid.copy(); + } + + /** + * Attempts to fill an empty container with a fluid. + * + * NOTE: Returns null on fail, NOT the empty container. + * + * @param fluid + * FluidStack containing the type and amount of fluid to fill. + * @param container + * ItemStack representing the empty container. + * @return Filled container if successful, otherwise null. + */ + public static ItemStack fillFluidContainer(FluidStack fluid, ItemStack container) + { + if (container == null || fluid == null) + { + return null; + } + + FluidContainerData data = filledContainerMap.get(new ContainerKey(container, fluid)); + if (data != null && fluid.amount >= data.fluid.amount) + { + return data.filledContainer.copy(); + } + return null; + } + + /** + * Determines if a container holds a specific fluid. + */ + public static boolean containsFluid(ItemStack container, FluidStack fluid) + { + if (container == null || fluid == null) + { + return false; + } + + FluidContainerData data = containerFluidMap.get(new ContainerKey(container)); + return data == null ? false : data.fluid.containsFluid(fluid); + } + + public static boolean isBucket(ItemStack container) + { + if (container == null) + { + return false; + } + + if (container.isItemEqual(EMPTY_BUCKET)) + { + return true; + } + + FluidContainerData data = containerFluidMap.get(new ContainerKey(container)); + return data != null && data.emptyContainer.isItemEqual(EMPTY_BUCKET); + } + + public static boolean isContainer(ItemStack container) + { + return isEmptyContainer(container) || isFilledContainer(container); + } + + public static boolean isEmptyContainer(ItemStack container) + { + return container != null && emptyContainers.contains(new ContainerKey(container)); + } + + public static boolean isFilledContainer(ItemStack container) + { + return container != null && getFluidForFilledItem(container) != null; + } + + public static FluidContainerData[] getRegisteredFluidContainerData() + { + return containerFluidMap.values().toArray(new FluidContainerData[containerFluidMap.size()]); + } + + /** + * Wrapper class for the registry entries. Ensures that none of the attempted registrations + * contain null references unless permitted. + */ + public static class FluidContainerData + { + public final FluidStack fluid; + public final ItemStack filledContainer; + public final ItemStack emptyContainer; + + + public FluidContainerData(FluidStack stack, ItemStack filledContainer, ItemStack emptyContainer) + { + this(stack, filledContainer, emptyContainer, false); + } + + public FluidContainerData(FluidStack stack, ItemStack filledContainer, ItemStack emptyContainer, boolean nullEmpty) + { + this.fluid = stack; + this.filledContainer = filledContainer; + this.emptyContainer = emptyContainer == null ? NULL_EMPTYCONTAINER : emptyContainer; + + if (stack == null || filledContainer == null || emptyContainer == null && !nullEmpty) + { + throw new RuntimeException("Invalid FluidContainerData - a parameter was null."); + } + } + + public FluidContainerData copy() + { + return new FluidContainerData(fluid, filledContainer, emptyContainer, true); + } + } + + public static class FluidContainerRegisterEvent extends Event + { + public final FluidContainerData data; + + public FluidContainerRegisterEvent(FluidContainerData data) + { + this.data = data.copy(); + } + } +} diff --git a/src/main/java/net/minecraftforge/fluids/FluidEvent.java b/src/main/java/net/minecraftforge/fluids/FluidEvent.java new file mode 100644 index 0000000..9164c68 --- /dev/null +++ b/src/main/java/net/minecraftforge/fluids/FluidEvent.java @@ -0,0 +1,97 @@ + +package net.minecraftforge.fluids; + +import cpw.mods.fml.common.eventhandler.Event; +import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; + +public class FluidEvent extends Event +{ + public final FluidStack fluid; + public final int x; + public final int y; + public final int z; + public final World world; + + public FluidEvent(FluidStack fluid, World world, int x, int y, int z) + { + this.fluid = fluid; + this.world = world; + this.x = x; + this.y = y; + this.z = z; + } + + /** + * Mods should fire this event when they move fluids around. + * + * @author cpw + * + */ + public static class FluidMotionEvent extends FluidEvent + { + public FluidMotionEvent(FluidStack fluid, World world, int x, int y, int z) + { + super(fluid, world, x, y, z); + } + } + + /** + * Mods should fire this event when a fluid is {@link IFluidTank#fill(FluidStack, boolean)} + * their tank implementation. {@link FluidTank} does. + * + * @author cpw + * + */ + public static class FluidFillingEvent extends FluidEvent + { + public final IFluidTank tank; + public FluidFillingEvent(FluidStack fluid, World world, int x, int y, int z, IFluidTank tank) + { + super(fluid, world, x, y, z); + this.tank = tank; + } + } + + /** + * Mods should fire this event when a fluid is {@link IFluidTank#drain(int, boolean)} from their + * tank. + * + * @author cpw + * + */ + public static class FluidDrainingEvent extends FluidEvent + { + public final IFluidTank tank; + public FluidDrainingEvent(FluidStack fluid, World world, int x, int y, int z, IFluidTank tank) + { + super(fluid, world, x, y, z); + this.tank = tank; + } + } + + /** + * Mods should fire this event when a fluid "spills", for example, if a block containing fluid + * is broken. + * + * @author cpw + * + */ + public static class FluidSpilledEvent extends FluidEvent + { + public FluidSpilledEvent(FluidStack fluid, World world, int x, int y, int z) + { + super(fluid, world, x, y, z); + } + } + + /** + * A handy shortcut for firing the various fluid events. + * + * @param event + */ + public static final void fireEvent(FluidEvent event) + { + MinecraftForge.EVENT_BUS.post(event); + } +} diff --git a/src/main/java/net/minecraftforge/fluids/FluidRegistry.java b/src/main/java/net/minecraftforge/fluids/FluidRegistry.java new file mode 100644 index 0000000..d399d79 --- /dev/null +++ b/src/main/java/net/minecraftforge/fluids/FluidRegistry.java @@ -0,0 +1,180 @@ +package net.minecraftforge.fluids; + +import java.util.HashMap; +import java.util.Map; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.util.StatCollector; +import net.minecraftforge.common.MinecraftForge; + +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Maps; + +import cpw.mods.fml.common.eventhandler.Event; + +/** + * Handles Fluid registrations. Fluids MUST be registered in order to function. + * + * @author King Lemming, CovertJaguar (LiquidDictionary) + * + */ +public abstract class FluidRegistry +{ + static int maxID = 0; + + static HashMap fluids = Maps.newHashMap(); + static BiMap fluidIDs = HashBiMap.create(); + static BiMap fluidBlocks; + + public static final Fluid WATER = new Fluid("water") { + @Override + public String getLocalizedName() { + return StatCollector.translateToLocal("tile.water.name"); + } + }.setBlock(Blocks.water).setUnlocalizedName(Blocks.water.getUnlocalizedName()); + + public static final Fluid LAVA = new Fluid("lava") { + @Override + public String getLocalizedName() { + return StatCollector.translateToLocal("tile.lava.name"); + } + }.setBlock(Blocks.lava).setLuminosity(15).setDensity(3000).setViscosity(6000).setTemperature(1300).setUnlocalizedName(Blocks.lava.getUnlocalizedName()); + + public static int renderIdFluid = -1; + + static + { + registerFluid(WATER); + registerFluid(LAVA); + } + + private FluidRegistry(){} + + /** + * Called by Forge to prepare the ID map for server -> client sync. + * Modders, DO NOT call this. + */ + public static void initFluidIDs(BiMap newfluidIDs) + { + maxID = newfluidIDs.size(); + fluidIDs.clear(); + fluidIDs.putAll(newfluidIDs); + } + + /** + * Register a new Fluid. If a fluid with the same name already exists, registration is denied. + * + * @param fluid + * The fluid to register. + * @return True if the fluid was successfully registered; false if there is a name clash. + */ + public static boolean registerFluid(Fluid fluid) + { + if (fluidIDs.containsKey(fluid.getName())) + { + return false; + } + fluids.put(fluid.getName(), fluid); + fluidIDs.put(fluid.getName(), ++maxID); + + MinecraftForge.EVENT_BUS.post(new FluidRegisterEvent(fluid.getName(), maxID)); + return true; + } + + public static boolean isFluidRegistered(Fluid fluid) + { + return fluidIDs.containsKey(fluid.getName()); + } + + public static boolean isFluidRegistered(String fluidName) + { + return fluidIDs.containsKey(fluidName); + } + + public static Fluid getFluid(String fluidName) + { + return fluids.get(fluidName); + } + + public static Fluid getFluid(int fluidID) + { + return fluids.get(getFluidName(fluidID)); + } + + public static String getFluidName(int fluidID) + { + return fluidIDs.inverse().get(fluidID); + } + + public static String getFluidName(FluidStack stack) + { + return getFluidName(stack.fluidID); + } + + public static int getFluidID(String fluidName) + { + return fluidIDs.get(fluidName); + } + + public static FluidStack getFluidStack(String fluidName, int amount) + { + if (!fluidIDs.containsKey(fluidName)) + { + return null; + } + return new FluidStack(getFluidID(fluidName), amount); + } + + /** + * Returns a read-only map containing Fluid Names and their associated Fluids. + */ + public static Map getRegisteredFluids() + { + return ImmutableMap.copyOf(fluids); + } + + /** + * Returns a read-only map containing Fluid Names and their associated IDs. + */ + public static Map getRegisteredFluidIDs() + { + return ImmutableMap.copyOf(fluidIDs); + } + + public static Fluid lookupFluidForBlock(Block block) + { + if (fluidBlocks == null) + { + BiMap tmp = HashBiMap.create(); + for (Fluid fluid : fluids.values()) + { + if (fluid.canBePlacedInWorld() && fluid.getBlock() != null) + { + tmp.put(fluid.getBlock(), fluid); + } + } + fluidBlocks = tmp; + } + return fluidBlocks.get(block); + } + + public static class FluidRegisterEvent extends Event + { + public final String fluidName; + public final int fluidID; + + public FluidRegisterEvent(String fluidName, int fluidID) + { + this.fluidName = fluidName; + this.fluidID = fluidID; + } + } + + public static int getMaxID() + { + return maxID; + } +} diff --git a/src/main/java/net/minecraftforge/fluids/FluidStack.java b/src/main/java/net/minecraftforge/fluids/FluidStack.java new file mode 100644 index 0000000..1f4a29f --- /dev/null +++ b/src/main/java/net/minecraftforge/fluids/FluidStack.java @@ -0,0 +1,203 @@ + +package net.minecraftforge.fluids; + +import java.util.Locale; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +/** + * ItemStack substitute for Fluids. + * + * NOTE: Equality is based on the Fluid, not the amount. Use + * {@link #isFluidStackIdentical(FluidStack)} to determine if FluidID, Amount and NBT Tag are all + * equal. + * + * @author King Lemming, SirSengir (LiquidStack) + * + */ +public class FluidStack +{ + public int fluidID; + public int amount; + public NBTTagCompound tag; + + public FluidStack(Fluid fluid, int amount) + { + this.fluidID = fluid.getID(); + this.amount = amount; + } + + public FluidStack(int fluidID, int amount) + { + this.fluidID = fluidID; + this.amount = amount; + } + + public FluidStack(int fluidID, int amount, NBTTagCompound nbt) + { + this(fluidID, amount); + + if (nbt != null) + { + tag = (NBTTagCompound) nbt.copy(); + } + } + + public FluidStack(FluidStack stack, int amount) + { + this(stack.fluidID, amount, stack.tag); + } + + /** + * This provides a safe method for retrieving a FluidStack - if the Fluid is invalid, the stack + * will return as null. + */ + public static FluidStack loadFluidStackFromNBT(NBTTagCompound nbt) + { + if (nbt == null) + { + return null; + } + String fluidName = nbt.getString("FluidName"); + if (fluidName == null) + { + fluidName = nbt.hasKey("LiquidName") ? nbt.getString("LiquidName").toLowerCase(Locale.ENGLISH) : null; + fluidName = Fluid.convertLegacyName(fluidName); + } + + if (fluidName ==null || FluidRegistry.getFluid(fluidName) == null) + { + return null; + } + FluidStack stack = new FluidStack(FluidRegistry.getFluidID(fluidName), nbt.getInteger("Amount")); + + if (nbt.hasKey("Tag")) + { + stack.tag = nbt.getCompoundTag("Tag"); + } + else if (nbt.hasKey("extra")) + { + stack.tag = nbt.getCompoundTag("extra"); + } + return stack; + } + + public NBTTagCompound writeToNBT(NBTTagCompound nbt) + { + nbt.setString("FluidName", FluidRegistry.getFluidName(fluidID)); + nbt.setInteger("Amount", amount); + + if (tag != null) + { + nbt.setTag("Tag", tag); + } + return nbt; + } + + public final Fluid getFluid() + { + return FluidRegistry.getFluid(fluidID); + } + + /** + * @return A copy of this FluidStack + */ + public FluidStack copy() + { + return new FluidStack(fluidID, amount, tag); + } + + /** + * Determines if the FluidIDs and NBT Tags are equal. This does not check amounts. + * + * @param other + * The FluidStack for comparison + * @return true if the Fluids (IDs and NBT Tags) are the same + */ + public boolean isFluidEqual(FluidStack other) + { + return other != null && fluidID == other.fluidID && isFluidStackTagEqual(other); + } + + private boolean isFluidStackTagEqual(FluidStack other) + { + return tag == null ? other.tag == null : other.tag == null ? false : tag.equals(other.tag); + } + + /** + * Determines if the NBT Tags are equal. Useful if the FluidIDs are known to be equal. + */ + public static boolean areFluidStackTagsEqual(FluidStack stack1, FluidStack stack2) + { + return stack1 == null && stack2 == null ? true : stack1 == null || stack2 == null ? false : stack1.isFluidStackTagEqual(stack2); + } + + /** + * Determines if the Fluids are equal and this stack is larger. + * + * @param other + * @return true if this FluidStack contains the other FluidStack (same fluid and >= amount) + */ + public boolean containsFluid(FluidStack other) + { + return isFluidEqual(other) && amount >= other.amount; + } + + /** + * Determines if the FluidIDs, Amounts, and NBT Tags are all equal. + * + * @param other + * - the FluidStack for comparison + * @return true if the two FluidStacks are exactly the same + */ + public boolean isFluidStackIdentical(FluidStack other) + { + return isFluidEqual(other) && amount == other.amount; + } + + /** + * Determines if the FluidIDs and NBT Tags are equal compared to a registered container + * ItemStack. This does not check amounts. + * + * @param other + * The ItemStack for comparison + * @return true if the Fluids (IDs and NBT Tags) are the same + */ + public boolean isFluidEqual(ItemStack other) + { + if (other == null) + { + return false; + } + + if (other.getItem() instanceof IFluidContainerItem) + { + return isFluidEqual(((IFluidContainerItem) other.getItem()).getFluid(other)); + } + + return isFluidEqual(FluidContainerRegistry.getFluidForFilledItem(other)); + } + + @Override + public final int hashCode() + { + return fluidID; + } + + /** + * Default equality comparison for a FluidStack. Same functionality as isFluidEqual(). + * + * This is included for use in data structures. + */ + @Override + public final boolean equals(Object o) + { + if (!(o instanceof FluidStack)) + { + return false; + } + + return isFluidEqual((FluidStack) o); + } +} diff --git a/src/main/java/net/minecraftforge/fluids/FluidTank.java b/src/main/java/net/minecraftforge/fluids/FluidTank.java new file mode 100644 index 0000000..a992eb5 --- /dev/null +++ b/src/main/java/net/minecraftforge/fluids/FluidTank.java @@ -0,0 +1,188 @@ + +package net.minecraftforge.fluids; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; + +/** + * Reference implementation of {@link IFluidTank}. Use/extend this or implement your own. + * + * @author King Lemming, cpw (LiquidTank) + * + */ +public class FluidTank implements IFluidTank +{ + protected FluidStack fluid; + protected int capacity; + protected TileEntity tile; + + public FluidTank(int capacity) + { + this(null, capacity); + } + + public FluidTank(FluidStack stack, int capacity) + { + this.fluid = stack; + this.capacity = capacity; + } + + public FluidTank(Fluid fluid, int amount, int capacity) + { + this(new FluidStack(fluid, amount), capacity); + } + + public FluidTank readFromNBT(NBTTagCompound nbt) + { + if (!nbt.hasKey("Empty")) + { + FluidStack fluid = FluidStack.loadFluidStackFromNBT(nbt); + + if (fluid != null) + { + setFluid(fluid); + } + } + return this; + } + + public NBTTagCompound writeToNBT(NBTTagCompound nbt) + { + if (fluid != null) + { + fluid.writeToNBT(nbt); + } + else + { + nbt.setString("Empty", ""); + } + return nbt; + } + + public void setFluid(FluidStack fluid) + { + this.fluid = fluid; + } + + public void setCapacity(int capacity) + { + this.capacity = capacity; + } + + /* IFluidTank */ + @Override + public FluidStack getFluid() + { + return fluid; + } + + @Override + public int getFluidAmount() + { + if (fluid == null) + { + return 0; + } + return fluid.amount; + } + + @Override + public int getCapacity() + { + return capacity; + } + + @Override + public FluidTankInfo getInfo() + { + return new FluidTankInfo(this); + } + + @Override + public int fill(FluidStack resource, boolean doFill) + { + if (resource == null) + { + return 0; + } + + if (!doFill) + { + if (fluid == null) + { + return Math.min(capacity, resource.amount); + } + + if (!fluid.isFluidEqual(resource)) + { + return 0; + } + + return Math.min(capacity - fluid.amount, resource.amount); + } + + if (fluid == null) + { + fluid = new FluidStack(resource, Math.min(capacity, resource.amount)); + + if (tile != null) + { + FluidEvent.fireEvent(new FluidEvent.FluidFillingEvent(fluid, tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord, this)); + } + return fluid.amount; + } + + if (!fluid.isFluidEqual(resource)) + { + return 0; + } + int filled = capacity - fluid.amount; + + if (resource.amount < filled) + { + fluid.amount += resource.amount; + filled = resource.amount; + } + else + { + fluid.amount = capacity; + } + + if (tile != null) + { + FluidEvent.fireEvent(new FluidEvent.FluidFillingEvent(fluid, tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord, this)); + } + return filled; + } + + @Override + public FluidStack drain(int maxDrain, boolean doDrain) + { + if (fluid == null) + { + return null; + } + + int drained = maxDrain; + if (fluid.amount < drained) + { + drained = fluid.amount; + } + + FluidStack stack = new FluidStack(fluid, drained); + if (doDrain) + { + fluid.amount -= drained; + if (fluid.amount <= 0) + { + fluid = null; + } + + if (tile != null) + { + FluidEvent.fireEvent(new FluidEvent.FluidDrainingEvent(fluid, tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord, this)); + } + } + return stack; + } +} diff --git a/src/main/java/net/minecraftforge/fluids/FluidTankInfo.java b/src/main/java/net/minecraftforge/fluids/FluidTankInfo.java new file mode 100644 index 0000000..08a0033 --- /dev/null +++ b/src/main/java/net/minecraftforge/fluids/FluidTankInfo.java @@ -0,0 +1,25 @@ +package net.minecraftforge.fluids; + +/** + * Wrapper class used to encapsulate information about an IFluidTank. + * + * @author King Lemming + * + */ +public final class FluidTankInfo +{ + public final FluidStack fluid; + public final int capacity; + + public FluidTankInfo(FluidStack fluid, int capacity) + { + this.fluid = fluid; + this.capacity = capacity; + } + + public FluidTankInfo(IFluidTank tank) + { + this.fluid = tank.getFluid(); + this.capacity = tank.getCapacity(); + } +} diff --git a/src/main/java/net/minecraftforge/fluids/IFluidBlock.java b/src/main/java/net/minecraftforge/fluids/IFluidBlock.java new file mode 100644 index 0000000..52c0595 --- /dev/null +++ b/src/main/java/net/minecraftforge/fluids/IFluidBlock.java @@ -0,0 +1,51 @@ +package net.minecraftforge.fluids; + +import net.minecraft.world.World; + +/** + * Implement this interface on Block classes which represent world-placeable Fluids. + * + * NOTE: Using/extending the reference implementations {@link BlockFluidBase} is encouraged. + * + * @author King Lemming + * + */ +public interface IFluidBlock +{ + /** + * Returns the Fluid associated with this Block. + */ + Fluid getFluid(); + + /** + * Attempt to drain the block. This method should be called by devices such as pumps. + * + * NOTE: The block is intended to handle its own state changes. + * + * @param doDrain + * If false, the drain will only be simulated. + * @return + */ + FluidStack drain(World world, int x, int y, int z, boolean doDrain); + + /** + * Check to see if a block can be drained. This method should be called by devices such as + * pumps. + * + * @param doDrain + * If false, the drain will only be simulated. + * @return + */ + boolean canDrain(World world, int x, int y, int z); + + /** + * Returns the amount of a single block is filled. Value between 0 and 1. + * 1 meaning the entire 1x1x1 cube is full, 0 meaning completely empty. + * + * If the return value is negative. It will be treated as filling the block + * from the top down instead of bottom up. + * + * @return + */ + float getFilledPercentage(World world, int x, int y, int z); +} diff --git a/src/main/java/net/minecraftforge/fluids/IFluidContainerItem.java b/src/main/java/net/minecraftforge/fluids/IFluidContainerItem.java new file mode 100644 index 0000000..ba566e0 --- /dev/null +++ b/src/main/java/net/minecraftforge/fluids/IFluidContainerItem.java @@ -0,0 +1,59 @@ +package net.minecraftforge.fluids; + +import net.minecraft.item.ItemStack; + +/** + * Implement this interface on Item classes that support external manipulation of their internal + * fluid storage. + * + * A reference implementation is provided {@link ItemFluidContainer}. + * + * NOTE: Use of NBT data on the containing ItemStack is encouraged. + * + * @author King Lemming + * + */ +public interface IFluidContainerItem +{ + /** + * + * @param container + * ItemStack which is the fluid container. + * @return FluidStack representing the fluid in the container, null if the container is empty. + */ + FluidStack getFluid(ItemStack container); + + /** + * + * @param container + * ItemStack which is the fluid container. + * @return Capacity of this fluid container. + */ + int getCapacity(ItemStack container); + + /** + * + * @param container + * ItemStack which is the fluid container. + * @param resource + * FluidStack attempting to fill the container. + * @param doFill + * If false, the fill will only be simulated. + * @return Amount of fluid that was (or would have been, if simulated) filled into the + * container. + */ + int fill(ItemStack container, FluidStack resource, boolean doFill); + + /** + * + * @param container + * ItemStack which is the fluid container. + * @param maxDrain + * Maximum amount of fluid to be removed from the container. + * @param doFill + * If false, the drain will only be simulated. + * @return Amount of fluid that was (or would have been, if simulated) drained from the + * container. + */ + FluidStack drain(ItemStack container, int maxDrain, boolean doDrain); +} diff --git a/src/main/java/net/minecraftforge/fluids/IFluidHandler.java b/src/main/java/net/minecraftforge/fluids/IFluidHandler.java new file mode 100644 index 0000000..6d0d194 --- /dev/null +++ b/src/main/java/net/minecraftforge/fluids/IFluidHandler.java @@ -0,0 +1,82 @@ +package net.minecraftforge.fluids; + +import net.minecraftforge.common.util.ForgeDirection; + +/** + * Implement this interface on TileEntities which should handle fluids, generally storing them in + * one or more internal {@link IFluidTank} objects. + * + * A reference implementation is provided {@link TileFluidHandler}. + * + * @author King Lemming + * + */ +public interface IFluidHandler +{ + /** + * Fills fluid into internal tanks, distribution is left entirely to the IFluidHandler. + * + * @param from + * Orientation the Fluid is pumped in from. + * @param resource + * FluidStack representing the Fluid and maximum amount of fluid to be filled. + * @param doFill + * If false, fill will only be simulated. + * @return Amount of resource that was (or would have been, if simulated) filled. + */ + int fill(ForgeDirection from, FluidStack resource, boolean doFill); + + /** + * Drains fluid out of internal tanks, distribution is left entirely to the IFluidHandler. + * + * @param from + * Orientation the Fluid is drained to. + * @param resource + * FluidStack representing the Fluid and maximum amount of fluid to be drained. + * @param doDrain + * If false, drain will only be simulated. + * @return FluidStack representing the Fluid and amount that was (or would have been, if + * simulated) drained. + */ + FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain); + + /** + * Drains fluid out of internal tanks, distribution is left entirely to the IFluidHandler. + * + * This method is not Fluid-sensitive. + * + * @param from + * Orientation the fluid is drained to. + * @param maxDrain + * Maximum amount of fluid to drain. + * @param doDrain + * If false, drain will only be simulated. + * @return FluidStack representing the Fluid and amount that was (or would have been, if + * simulated) drained. + */ + FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain); + + /** + * Returns true if the given fluid can be inserted into the given direction. + * + * More formally, this should return true if fluid is able to enter from the given direction. + */ + boolean canFill(ForgeDirection from, Fluid fluid); + + /** + * Returns true if the given fluid can be extracted from the given direction. + * + * More formally, this should return true if fluid is able to leave from the given direction. + */ + boolean canDrain(ForgeDirection from, Fluid fluid); + + /** + * Returns an array of objects which represent the internal tanks. These objects cannot be used + * to manipulate the internal tanks. See {@link FluidTankInfo}. + * + * @param from + * Orientation determining which tanks should be queried. + * @return Info for the relevant internal tanks. + */ + FluidTankInfo[] getTankInfo(ForgeDirection from); +} diff --git a/src/main/java/net/minecraftforge/fluids/IFluidTank.java b/src/main/java/net/minecraftforge/fluids/IFluidTank.java new file mode 100644 index 0000000..ce1da16 --- /dev/null +++ b/src/main/java/net/minecraftforge/fluids/IFluidTank.java @@ -0,0 +1,57 @@ +package net.minecraftforge.fluids; + +/** + * A tank is the unit of interaction with Fluid inventories. + * + * A reference implementation can be found at {@link FluidTank}. + * + * @author King Lemming, cpw (ILiquidTank) + * + */ +public interface IFluidTank +{ + /** + * @return FluidStack representing the fluid in the tank, null if the tank is empty. + */ + FluidStack getFluid(); + + /** + * @return Current amount of fluid in the tank. + */ + int getFluidAmount(); + + /** + * @return Capacity of this fluid tank. + */ + int getCapacity(); + + /** + * Returns a wrapper object {@link FluidTankInfo } containing the capacity of the tank and the + * FluidStack it holds. + * + * Should prevent manipulation of the IFluidTank. See {@link FluidTank}. + * + * @return State information for the IFluidTank. + */ + FluidTankInfo getInfo(); + + /** + * + * @param resource + * FluidStack attempting to fill the tank. + * @param doFill + * If false, the fill will only be simulated. + * @return Amount of fluid that was accepted by the tank. + */ + int fill(FluidStack resource, boolean doFill); + + /** + * + * @param maxDrain + * Maximum amount of fluid to be removed from the container. + * @param doFill + * If false, the fill will only be simulated. + * @return Amount of fluid that was removed from the tank. + */ + FluidStack drain(int maxDrain, boolean doDrain); +} diff --git a/src/main/java/net/minecraftforge/fluids/ItemFluidContainer.java b/src/main/java/net/minecraftforge/fluids/ItemFluidContainer.java new file mode 100644 index 0000000..2aecc1c --- /dev/null +++ b/src/main/java/net/minecraftforge/fluids/ItemFluidContainer.java @@ -0,0 +1,158 @@ +package net.minecraftforge.fluids; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +/** + * Reference implementation of {@link IFluidContainerItem}. Use/extend this or implement your own. + * + * @author King Lemming + * + */ +public class ItemFluidContainer extends Item implements IFluidContainerItem +{ + protected int capacity; + + public ItemFluidContainer(int itemID) + { + super(); + } + + public ItemFluidContainer(int itemID, int capacity) + { + super(); + this.capacity = capacity; + } + + public ItemFluidContainer setCapacity(int capacity) + { + this.capacity = capacity; + return this; + } + + /* IFluidContainerItem */ + @Override + public FluidStack getFluid(ItemStack container) + { + if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Fluid")) + { + return null; + } + return FluidStack.loadFluidStackFromNBT(container.stackTagCompound.getCompoundTag("Fluid")); + } + + @Override + public int getCapacity(ItemStack container) + { + return capacity; + } + + @Override + public int fill(ItemStack container, FluidStack resource, boolean doFill) + { + if (resource == null) + { + return 0; + } + + if (!doFill) + { + if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Fluid")) + { + return Math.min(capacity, resource.amount); + } + + FluidStack stack = FluidStack.loadFluidStackFromNBT(container.stackTagCompound.getCompoundTag("Fluid")); + + if (stack == null) + { + return Math.min(capacity, resource.amount); + } + + if (!stack.isFluidEqual(resource)) + { + return 0; + } + + return Math.min(capacity - stack.amount, resource.amount); + } + + if (container.stackTagCompound == null) + { + container.stackTagCompound = new NBTTagCompound(); + } + + if (!container.stackTagCompound.hasKey("Fluid")) + { + NBTTagCompound fluidTag = resource.writeToNBT(new NBTTagCompound()); + + if (capacity < resource.amount) + { + fluidTag.setInteger("Amount", capacity); + container.stackTagCompound.setTag("Fluid", fluidTag); + return capacity; + } + + container.stackTagCompound.setTag("Fluid", fluidTag); + return resource.amount; + } + + NBTTagCompound fluidTag = container.stackTagCompound.getCompoundTag("Fluid"); + FluidStack stack = FluidStack.loadFluidStackFromNBT(fluidTag); + + if (!stack.isFluidEqual(resource)) + { + return 0; + } + + int filled = capacity - stack.amount; + if (resource.amount < filled) + { + stack.amount += resource.amount; + filled = resource.amount; + } + else + { + stack.amount = capacity; + } + + container.stackTagCompound.setTag("Fluid", stack.writeToNBT(fluidTag)); + return filled; + } + + @Override + public FluidStack drain(ItemStack container, int maxDrain, boolean doDrain) + { + if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Fluid")) + { + return null; + } + + FluidStack stack = FluidStack.loadFluidStackFromNBT(container.stackTagCompound.getCompoundTag("Fluid")); + if (stack == null) + { + return null; + } + + stack.amount = Math.min(stack.amount, maxDrain); + if (doDrain) + { + if (maxDrain >= capacity) + { + container.stackTagCompound.removeTag("Fluid"); + + if (container.stackTagCompound.hasNoTags()) + { + container.stackTagCompound = null; + } + return stack; + } + + NBTTagCompound fluidTag = container.stackTagCompound.getCompoundTag("Fluid"); + fluidTag.setInteger("Amount", fluidTag.getInteger("Amount") - maxDrain); + container.stackTagCompound.setTag("Fluid", fluidTag); + } + return stack; + } +} diff --git a/src/main/java/net/minecraftforge/fluids/RenderBlockFluid.java b/src/main/java/net/minecraftforge/fluids/RenderBlockFluid.java new file mode 100644 index 0000000..4d82e16 --- /dev/null +++ b/src/main/java/net/minecraftforge/fluids/RenderBlockFluid.java @@ -0,0 +1,336 @@ +package net.minecraftforge.fluids; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.IBlockAccess; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; + +/** + * Default renderer for Forge fluid blocks. + * + * @author King Lemming + * + */ +public class RenderBlockFluid implements ISimpleBlockRenderingHandler +{ + public static RenderBlockFluid instance = new RenderBlockFluid(); + + static final float LIGHT_Y_NEG = 0.5F; + static final float LIGHT_Y_POS = 1.0F; + static final float LIGHT_XZ_NEG = 0.8F; + static final float LIGHT_XZ_POS = 0.6F; + static final double RENDER_OFFSET = 0.0010000000474974513D; + + public float getFluidHeightAverage(float[] flow) + { + float total = 0; + int count = 0; + + float end = 0; + + for (int i = 0; i < flow.length; i++) + { + if (flow[i] >= 0.875F && end != 1F) + { + end = flow[i]; + } + + if (flow[i] >= 0) + { + total += flow[i]; + count++; + } + } + + if (end == 0) + end = total / count; + + return end; + } + + public float getFluidHeightForRender(IBlockAccess world, int x, int y, int z, BlockFluidBase block) + { + if (world.getBlock(x, y, z) == block) + { + if (world.getBlock(x, y - block.densityDir, z).getMaterial().isLiquid()) + { + return 1; + } + + if (world.getBlockMetadata(x, y, z) == block.getMaxRenderHeightMeta()) + { + return 0.875F; + } + } + return !world.getBlock(x, y, z).getMaterial().isSolid() && world.getBlock(x, y - block.densityDir, z) == block ? 1 : block.getQuantaPercentage(world, x, y, z) * 0.875F; + } + + /* ISimpleBlockRenderingHandler */ + @Override + public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer){} + + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) + { + if (!(block instanceof BlockFluidBase)) + { + return false; + } + + Tessellator tessellator = Tessellator.instance; + int color = block.colorMultiplier(world, x, y, z); + float red = (color >> 16 & 255) / 255.0F; + float green = (color >> 8 & 255) / 255.0F; + float blue = (color & 255) / 255.0F; + + BlockFluidBase theFluid = (BlockFluidBase) block; + int bMeta = world.getBlockMetadata(x, y, z); + + boolean renderTop = world.getBlock(x, y - theFluid.densityDir, z) != theFluid; + + boolean renderBottom = block.shouldSideBeRendered(world, x, y + theFluid.densityDir, z, 0) && world.getBlock(x, y + theFluid.densityDir, z) != theFluid; + + boolean[] renderSides = new boolean[] + { + block.shouldSideBeRendered(world, x, y, z - 1, 2), + block.shouldSideBeRendered(world, x, y, z + 1, 3), + block.shouldSideBeRendered(world, x - 1, y, z, 4), + block.shouldSideBeRendered(world, x + 1, y, z, 5) + }; + + if (!renderTop && !renderBottom && !renderSides[0] && !renderSides[1] && !renderSides[2] && !renderSides[3]) + { + return false; + } + else + { + boolean rendered = false; + double heightNW, heightSW, heightSE, heightNE; + float flow11 = getFluidHeightForRender(world, x, y, z, theFluid); + + if (flow11 != 1) + { + float flow00 = getFluidHeightForRender(world, x - 1, y, z - 1, theFluid); + float flow01 = getFluidHeightForRender(world, x - 1, y, z, theFluid); + float flow02 = getFluidHeightForRender(world, x - 1, y, z + 1, theFluid); + float flow10 = getFluidHeightForRender(world, x, y, z - 1, theFluid); + float flow12 = getFluidHeightForRender(world, x, y, z + 1, theFluid); + float flow20 = getFluidHeightForRender(world, x + 1, y, z - 1, theFluid); + float flow21 = getFluidHeightForRender(world, x + 1, y, z, theFluid); + float flow22 = getFluidHeightForRender(world, x + 1, y, z + 1, theFluid); + + heightNW = getFluidHeightAverage(new float[]{ flow00, flow01, flow10, flow11 }); + heightSW = getFluidHeightAverage(new float[]{ flow01, flow02, flow12, flow11 }); + heightSE = getFluidHeightAverage(new float[]{ flow12, flow21, flow22, flow11 }); + heightNE = getFluidHeightAverage(new float[]{ flow10, flow20, flow21, flow11 }); + } + else + { + heightNW = flow11; + heightSW = flow11; + heightSE = flow11; + heightNE = flow11; + } + + boolean rises = theFluid.densityDir == 1; + if (renderer.renderAllFaces || renderTop) + { + rendered = true; + IIcon iconStill = getIcon(block.getIcon(1, bMeta)); + float flowDir = (float) BlockFluidBase.getFlowDirection(world, x, y, z); + + if (flowDir > -999.0F) + { + iconStill = getIcon(block.getIcon(2, bMeta)); + } + + heightNW -= RENDER_OFFSET; + heightSW -= RENDER_OFFSET; + heightSE -= RENDER_OFFSET; + heightNE -= RENDER_OFFSET; + + double u1, u2, u3, u4, v1, v2, v3, v4; + + if (flowDir < -999.0F) + { + u2 = iconStill.getInterpolatedU(0.0D); + v2 = iconStill.getInterpolatedV(0.0D); + u1 = u2; + v1 = iconStill.getInterpolatedV(16.0D); + u4 = iconStill.getInterpolatedU(16.0D); + v4 = v1; + u3 = u4; + v3 = v2; + } + else + { + float xFlow = MathHelper.sin(flowDir) * 0.25F; + float zFlow = MathHelper.cos(flowDir) * 0.25F; + u2 = iconStill.getInterpolatedU(8.0F + (-zFlow - xFlow) * 16.0F); + v2 = iconStill.getInterpolatedV(8.0F + (-zFlow + xFlow) * 16.0F); + u1 = iconStill.getInterpolatedU(8.0F + (-zFlow + xFlow) * 16.0F); + v1 = iconStill.getInterpolatedV(8.0F + (zFlow + xFlow) * 16.0F); + u4 = iconStill.getInterpolatedU(8.0F + (zFlow + xFlow) * 16.0F); + v4 = iconStill.getInterpolatedV(8.0F + (zFlow - xFlow) * 16.0F); + u3 = iconStill.getInterpolatedU(8.0F + (zFlow - xFlow) * 16.0F); + v3 = iconStill.getInterpolatedV(8.0F + (-zFlow - xFlow) * 16.0F); + } + + tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z)); + tessellator.setColorOpaque_F(LIGHT_Y_POS * red, LIGHT_Y_POS * green, LIGHT_Y_POS * blue); + + if (!rises) + { + tessellator.addVertexWithUV(x + 0, y + heightNW, z + 0, u2, v2); + tessellator.addVertexWithUV(x + 0, y + heightSW, z + 1, u1, v1); + tessellator.addVertexWithUV(x + 1, y + heightSE, z + 1, u4, v4); + tessellator.addVertexWithUV(x + 1, y + heightNE, z + 0, u3, v3); + } + else + { + tessellator.addVertexWithUV(x + 1, y + 1 - heightNE, z + 0, u3, v3); + tessellator.addVertexWithUV(x + 1, y + 1 - heightSE, z + 1, u4, v4); + tessellator.addVertexWithUV(x + 0, y + 1 - heightSW, z + 1, u1, v1); + tessellator.addVertexWithUV(x + 0, y + 1 - heightNW, z + 0, u2, v2); + } + } + + if (renderer.renderAllFaces || renderBottom) + { + rendered = true; + tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y - 1, z)); + if (!rises) + { + tessellator.setColorOpaque_F(LIGHT_Y_NEG * red, LIGHT_Y_NEG * green, LIGHT_Y_NEG * blue); + renderer.renderFaceYNeg(block, x, y + RENDER_OFFSET, z, getIcon(block.getIcon(0, bMeta))); + } + else + { + tessellator.setColorOpaque_F(LIGHT_Y_POS * red, LIGHT_Y_POS * green, LIGHT_Y_POS * blue); + renderer.renderFaceYPos(block, x, y + RENDER_OFFSET, z, getIcon(block.getIcon(1, bMeta))); + } + } + + for (int side = 0; side < 4; ++side) + { + int x2 = x; + int z2 = z; + + switch (side) + { + case 0: --z2; break; + case 1: ++z2; break; + case 2: --x2; break; + case 3: ++x2; break; + } + + IIcon iconFlow = getIcon(block.getIcon(side + 2, bMeta)); + if (renderer.renderAllFaces || renderSides[side]) + { + rendered = true; + + double ty1; + double tx1; + double ty2; + double tx2; + double tz1; + double tz2; + + if (side == 0) + { + ty1 = heightNW; + ty2 = heightNE; + tx1 = x; + tx2 = x + 1; + tz1 = z + RENDER_OFFSET; + tz2 = z + RENDER_OFFSET; + } + else if (side == 1) + { + ty1 = heightSE; + ty2 = heightSW; + tx1 = x + 1; + tx2 = x; + tz1 = z + 1 - RENDER_OFFSET; + tz2 = z + 1 - RENDER_OFFSET; + } + else if (side == 2) + { + ty1 = heightSW; + ty2 = heightNW; + tx1 = x + RENDER_OFFSET; + tx2 = x + RENDER_OFFSET; + tz1 = z + 1; + tz2 = z; + } + else + { + ty1 = heightNE; + ty2 = heightSE; + tx1 = x + 1 - RENDER_OFFSET; + tx2 = x + 1 - RENDER_OFFSET; + tz1 = z; + tz2 = z + 1; + } + + float u1Flow = iconFlow.getInterpolatedU(0.0D); + float u2Flow = iconFlow.getInterpolatedU(8.0D); + float v1Flow = iconFlow.getInterpolatedV((1.0D - ty1) * 16.0D * 0.5D); + float v2Flow = iconFlow.getInterpolatedV((1.0D - ty2) * 16.0D * 0.5D); + float v3Flow = iconFlow.getInterpolatedV(8.0D); + tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x2, y, z2)); + float sideLighting = 1.0F; + + if (side < 2) + { + sideLighting = LIGHT_XZ_NEG; + } + else + { + sideLighting = LIGHT_XZ_POS; + } + + tessellator.setColorOpaque_F(LIGHT_Y_POS * sideLighting * red, LIGHT_Y_POS * sideLighting * green, LIGHT_Y_POS * sideLighting * blue); + + if (!rises) + { + tessellator.addVertexWithUV(tx1, y + ty1, tz1, u1Flow, v1Flow); + tessellator.addVertexWithUV(tx2, y + ty2, tz2, u2Flow, v2Flow); + tessellator.addVertexWithUV(tx2, y + 0, tz2, u2Flow, v3Flow); + tessellator.addVertexWithUV(tx1, y + 0, tz1, u1Flow, v3Flow); + } + else + { + tessellator.addVertexWithUV(tx1, y + 1 - 0, tz1, u1Flow, v3Flow); + tessellator.addVertexWithUV(tx2, y + 1 - 0, tz2, u2Flow, v3Flow); + tessellator.addVertexWithUV(tx2, y + 1 - ty2, tz2, u2Flow, v2Flow); + tessellator.addVertexWithUV(tx1, y + 1 - ty1, tz1, u1Flow, v1Flow); + } + } + } + renderer.renderMinY = 0; + renderer.renderMaxY = 1; + return rendered; + } + } + + @Override + public boolean shouldRender3DInInventory(int modelId){ return false; } + @Override + public int getRenderId() + { + return FluidRegistry.renderIdFluid; + } + + + private IIcon getIcon(IIcon icon) + { + if (icon != null) return icon; + return ((TextureMap)Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno"); + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/fluids/TileFluidHandler.java b/src/main/java/net/minecraftforge/fluids/TileFluidHandler.java new file mode 100644 index 0000000..decb290 --- /dev/null +++ b/src/main/java/net/minecraftforge/fluids/TileFluidHandler.java @@ -0,0 +1,72 @@ + +package net.minecraftforge.fluids; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; + +/** + * Reference Tile Entity implementation of {@link IFluidHandler}. Use/extend this or write your own. + * + * @author King Lemming + * + */ +public class TileFluidHandler extends TileEntity implements IFluidHandler +{ + protected FluidTank tank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME); + + @Override + public void readFromNBT(NBTTagCompound tag) + { + super.readFromNBT(tag); + tank.readFromNBT(tag); + } + + @Override + public void writeToNBT(NBTTagCompound tag) + { + super.writeToNBT(tag); + tank.writeToNBT(tag); + } + + /* IFluidHandler */ + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) + { + return tank.fill(resource, doFill); + } + + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) + { + if (resource == null || !resource.isFluidEqual(tank.getFluid())) + { + return null; + } + return tank.drain(resource.amount, doDrain); + } + + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) + { + return tank.drain(maxDrain, doDrain); + } + + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) + { + return true; + } + + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) + { + return true; + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection from) + { + return new FluidTankInfo[] { tank.getInfo() }; + } +} diff --git a/src/main/java/net/minecraftforge/oredict/OreDictionary.java b/src/main/java/net/minecraftforge/oredict/OreDictionary.java new file mode 100644 index 0000000..e0eb1aa --- /dev/null +++ b/src/main/java/net/minecraftforge/oredict/OreDictionary.java @@ -0,0 +1,367 @@ +package net.minecraftforge.oredict; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.eventhandler.Event; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.item.crafting.ShapedRecipes; +import net.minecraft.item.crafting.ShapelessRecipes; +import net.minecraftforge.common.MinecraftForge; + +public class OreDictionary +{ + private static boolean hasInit = false; + private static int maxID = 0; + private static HashMap oreIDs = new HashMap(); + private static HashMap> oreStacks = new HashMap>(); + + /** + * Minecraft changed from -1 to Short.MAX_VALUE in 1.5 release for the "block wildcard". Use this in case it + * changes again. + */ + public static final int WILDCARD_VALUE = Short.MAX_VALUE; + + static { + initVanillaEntries(); + } + + @SuppressWarnings("unchecked") + public static void initVanillaEntries() + { + if (!hasInit) + { + registerOre("logWood", new ItemStack(Blocks.log, 1, WILDCARD_VALUE)); + registerOre("logWood", new ItemStack(Blocks.log2, 1, WILDCARD_VALUE)); + registerOre("plankWood", new ItemStack(Blocks.planks, 1, WILDCARD_VALUE)); + registerOre("slabWood", new ItemStack(Blocks.wooden_slab, 1, WILDCARD_VALUE)); + registerOre("stairWood", Blocks.oak_stairs); + registerOre("stairWood", Blocks.spruce_stairs); + registerOre("stairWood", Blocks.birch_stairs); + registerOre("stairWood", Blocks.jungle_stairs); + registerOre("stairWood", Blocks.acacia_stairs); + registerOre("stairWood", Blocks.dark_oak_stairs); + registerOre("stickWood", Items.stick); + registerOre("treeSapling", new ItemStack(Blocks.sapling, 1, WILDCARD_VALUE)); + registerOre("treeLeaves", new ItemStack(Blocks.leaves, 1, WILDCARD_VALUE)); + registerOre("treeLeaves", new ItemStack(Blocks.leaves2, 1, WILDCARD_VALUE)); + registerOre("oreGold", Blocks.gold_ore); + registerOre("oreIron", Blocks.iron_ore); + registerOre("oreLapis", Blocks.lapis_ore); + registerOre("oreDiamond", Blocks.diamond_ore); + registerOre("oreRedstone", Blocks.redstone_ore); + registerOre("oreEmerald", Blocks.emerald_ore); + registerOre("oreQuartz", Blocks.quartz_ore); + registerOre("oreCoal", Blocks.coal_ore); + registerOre("gemDiamond", Items.diamond); + registerOre("gemEmerald", Items.emerald); + registerOre("dustRedstone", Items.redstone); + registerOre("dustGlowstone", Items.glowstone_dust); + registerOre("glowstone", Blocks.glowstone); + registerOre("cropWheat", Items.wheat); + registerOre("cropPotato", Items.potato); + registerOre("cropCarrot", Items.carrot); + registerOre("stone", Blocks.stone); + registerOre("cobblestone", Blocks.cobblestone); + registerOre("record", Items.record_13); + registerOre("record", Items.record_cat); + registerOre("record", Items.record_blocks); + registerOre("record", Items.record_chirp); + registerOre("record", Items.record_far); + registerOre("record", Items.record_mall); + registerOre("record", Items.record_mellohi); + registerOre("record", Items.record_stal); + registerOre("record", Items.record_strad); + registerOre("record", Items.record_ward); + registerOre("record", Items.record_11); + registerOre("record", Items.record_wait); + } + + // Build our list of items to replace with ore tags + Map replacements = new HashMap(); + replacements.put(new ItemStack(Items.stick), "stickWood"); + replacements.put(new ItemStack(Blocks.planks), "plankWood"); + replacements.put(new ItemStack(Blocks.planks, 1, WILDCARD_VALUE), "plankWood"); + replacements.put(new ItemStack(Blocks.stone), "stone"); + replacements.put(new ItemStack(Blocks.stone, 1, WILDCARD_VALUE), "stone"); + replacements.put(new ItemStack(Blocks.cobblestone), "cobblestone"); + replacements.put(new ItemStack(Blocks.cobblestone, 1, WILDCARD_VALUE), "cobblestone"); + replacements.put(new ItemStack(Items.diamond), "gemDiamond"); + replacements.put(new ItemStack(Items.emerald), "gemEmerald"); + replacements.put(new ItemStack(Items.redstone), "dustRedstone"); + replacements.put(new ItemStack(Items.glowstone_dust), "dustGlowstone"); + replacements.put(new ItemStack(Blocks.glowstone), "glowstone"); + + // Register dyes + String[] dyes = + { + "dyeBlack", + "dyeRed", + "dyeGreen", + "dyeBrown", + "dyeBlue", + "dyePurple", + "dyeCyan", + "dyeLightGray", + "dyeGray", + "dyePink", + "dyeLime", + "dyeYellow", + "dyeLightBlue", + "dyeMagenta", + "dyeOrange", + "dyeWhite" + }; + + for(int i = 0; i < 16; i++) + { + ItemStack dye = new ItemStack(Items.dye, 1, i); + if (!hasInit) + { + registerOre(dyes[i], dye); + } + replacements.put(dye, dyes[i]); + } + hasInit = true; + + ItemStack[] replaceStacks = replacements.keySet().toArray(new ItemStack[replacements.keySet().size()]); + + // Ignore recipes for the following items + ItemStack[] exclusions = new ItemStack[] + { + new ItemStack(Blocks.lapis_block), + new ItemStack(Items.cookie), + new ItemStack(Blocks.stonebrick), + new ItemStack(Blocks.stone_slab, 1, WILDCARD_VALUE), + new ItemStack(Blocks.stone_stairs), + new ItemStack(Blocks.cobblestone_wall), + new ItemStack(Blocks.oak_stairs), + new ItemStack(Blocks.spruce_stairs), + new ItemStack(Blocks.birch_stairs), + new ItemStack(Blocks.jungle_stairs), + new ItemStack(Blocks.acacia_stairs), + new ItemStack(Blocks.dark_oak_stairs) + }; + + List recipes = CraftingManager.getInstance().getRecipeList(); + List recipesToRemove = new ArrayList(); + List recipesToAdd = new ArrayList(); + + // Search vanilla recipes for recipes to replace + for(Object obj : recipes) + { + if(obj instanceof ShapedRecipes) + { + ShapedRecipes recipe = (ShapedRecipes)obj; + ItemStack output = recipe.getRecipeOutput(); + if (output != null && containsMatch(false, exclusions, output)) + { + continue; + } + + if(containsMatch(true, recipe.recipeItems, replaceStacks)) + { + recipesToRemove.add(recipe); + recipesToAdd.add(new ShapedOreRecipe(recipe, replacements)); + } + } + else if(obj instanceof ShapelessRecipes) + { + ShapelessRecipes recipe = (ShapelessRecipes)obj; + ItemStack output = recipe.getRecipeOutput(); + if (output != null && containsMatch(false, exclusions, output)) + { + continue; + } + + if(containsMatch(true, (ItemStack[])recipe.recipeItems.toArray(new ItemStack[recipe.recipeItems.size()]), replaceStacks)) + { + recipesToRemove.add((IRecipe)obj); + IRecipe newRecipe = new ShapelessOreRecipe(recipe, replacements); + recipesToAdd.add(newRecipe); + } + } + } + + recipes.removeAll(recipesToRemove); + recipes.addAll(recipesToAdd); + if (recipesToRemove.size() > 0) + { + FMLLog.info("Replaced %d ore recipies", recipesToRemove.size()); + } + } + + /** + * Gets the integer ID for the specified ore name. + * If the name does not have a ID it assigns it a new one. + * + * @param name The unique name for this ore 'oreIron', 'ingotIron', etc.. + * @return A number representing the ID for this ore type + */ + public static int getOreID(String name) + { + Integer val = oreIDs.get(name); + if (val == null) + { + val = maxID++; + oreIDs.put(name, val); + oreStacks.put(val, new ArrayList()); + } + return val; + } + + /** + * Reverse of getOreID, will not create new entries. + * + * @param id The ID to translate to a string + * @return The String name, or "Unknown" if not found. + */ + public static String getOreName(int id) + { + for (Map.Entry entry : oreIDs.entrySet()) + { + if (id == entry.getValue()) + { + return entry.getKey(); + } + } + return "Unknown"; + } + + /** + * Gets the integer ID for the specified item stack. + * If the item stack is not linked to any ore, this will return -1 and no new entry will be created. + * + * @param itemStack The item stack of the ore. + * @return A number representing the ID for this ore type, or -1 if couldn't find it. + */ + public static int getOreID(ItemStack itemStack) + { + if (itemStack == null) + { + return -1; + } + + for(Entry> ore : oreStacks.entrySet()) + { + for(ItemStack target : ore.getValue()) + { + if(itemStack.getItem() == target.getItem() && (target.getItemDamage() == WILDCARD_VALUE || itemStack.getItemDamage() == target.getItemDamage())) + { + return ore.getKey(); + } + } + } + return -1; // didn't find it. + } + + /** + * Retrieves the ArrayList of items that are registered to this ore type. + * Creates the list as empty if it did not exist. + * + * @param name The ore name, directly calls getOreID + * @return An arrayList containing ItemStacks registered for this ore + */ + public static ArrayList getOres(String name) + { + return getOres(getOreID(name)); + } + + /** + * Retrieves a list of all unique ore names that are already registered. + * + * @return All unique ore names that are currently registered. + */ + public static String[] getOreNames() + { + return oreIDs.keySet().toArray(new String[oreIDs.keySet().size()]); + } + + /** + * Retrieves the ArrayList of items that are registered to this ore type. + * Creates the list as empty if it did not exist. + * + * @param id The ore ID, see getOreID + * @return An arrayList containing ItemStacks registered for this ore + */ + public static ArrayList getOres(Integer id) + { + ArrayList val = oreStacks.get(id); + if (val == null) + { + val = new ArrayList(); + oreStacks.put(id, val); + } + return val; + } + + private static boolean containsMatch(boolean strict, ItemStack[] inputs, ItemStack... targets) + { + for (ItemStack input : inputs) + { + for (ItemStack target : targets) + { + if (itemMatches(target, input, strict)) + { + return true; + } + } + } + return false; + } + + public static boolean itemMatches(ItemStack target, ItemStack input, boolean strict) + { + if (input == null && target != null || input != null && target == null) + { + return false; + } + return (target.getItem() == input.getItem() && ((target.getItemDamage() == WILDCARD_VALUE && !strict) || target.getItemDamage() == input.getItemDamage())); + } + + //Convenience functions that make for cleaner code mod side. They all drill down to registerOre(String, int, ItemStack) + public static void registerOre(String name, Item ore){ registerOre(name, new ItemStack(ore)); } + public static void registerOre(String name, Block ore){ registerOre(name, new ItemStack(ore)); } + public static void registerOre(String name, ItemStack ore){ registerOre(name, getOreID(name), ore); } + public static void registerOre(int id, Item ore){ registerOre(id, new ItemStack(ore)); } + public static void registerOre(int id, Block ore){ registerOre(id, new ItemStack(ore)); } + public static void registerOre(int id, ItemStack ore){ registerOre(getOreName(id), id, ore); } + + /** + * Registers a ore item into the dictionary. + * Raises the registerOre function in all registered handlers. + * + * @param name The name of the ore + * @param id The ID of the ore + * @param ore The ore's ItemStack + */ + private static void registerOre(String name, int id, ItemStack ore) + { + ArrayList ores = getOres(id); + ore = ore.copy(); + ores.add(ore); + MinecraftForge.EVENT_BUS.post(new OreRegisterEvent(name, ore)); + } + + public static class OreRegisterEvent extends Event + { + public final String Name; + public final ItemStack Ore; + + public OreRegisterEvent(String name, ItemStack ore) + { + this.Name = name; + this.Ore = ore; + } + } +} diff --git a/src/main/java/net/minecraftforge/oredict/RecipeSorter.java b/src/main/java/net/minecraftforge/oredict/RecipeSorter.java new file mode 100644 index 0000000..18088f9 --- /dev/null +++ b/src/main/java/net/minecraftforge/oredict/RecipeSorter.java @@ -0,0 +1,273 @@ +package net.minecraftforge.oredict; + +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.google.common.base.Joiner; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; + +import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.toposort.TopologicalSort; +import cpw.mods.fml.common.toposort.TopologicalSort.DirectedGraph; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.item.crafting.RecipeBookCloning; +import net.minecraft.item.crafting.RecipeFireworks; +import net.minecraft.item.crafting.RecipesArmorDyes; +import net.minecraft.item.crafting.RecipesMapCloning; +import net.minecraft.item.crafting.RecipesMapExtending; +import net.minecraft.item.crafting.ShapedRecipes; +import net.minecraft.item.crafting.ShapelessRecipes; +import static net.minecraftforge.oredict.RecipeSorter.Category.*; + +@SuppressWarnings("rawtypes") +public class RecipeSorter implements Comparator +{ + public enum Category + { + UNKNOWN, + SHAPELESS, + SHAPED + }; + + private static class SortEntry + { + private String name; + private Class cls; + private Category cat; + List before = Lists.newArrayList(); + List after = Lists.newArrayList(); + + private SortEntry(String name, Class cls, Category cat, String deps) + { + this.name = name; + this.cls = cls; + this.cat = cat; + parseDepends(deps); + } + + private void parseDepends(String deps) + { + if (deps.isEmpty()) return; + for (String dep : deps.split(" ")) + { + if (dep.startsWith("before:")) + { + before.add(dep.substring(7)); + } + else if (dep.startsWith("after:")) + { + after.add(dep.substring(6)); + } + else + { + throw new IllegalArgumentException("Invalid dependancy: " + dep); + } + } + } + + @Override + public String toString() + { + StringBuilder buf = new StringBuilder(); + buf.append("RecipeEntry(\"").append(name).append("\", "); + buf.append(cat.name()).append(", "); + buf.append(cls == null ? "" : cls.getName()).append(")"); + + if (before.size() > 0) + { + buf.append(" Before: ").append(Joiner.on(", ").join(before)); + } + + if (after.size() > 0) + { + buf.append(" After: ").append(Joiner.on(", ").join(after)); + } + + return buf.toString(); + } + + @Override + public int hashCode() + { + return name.hashCode(); + } + }; + + private static Map categories = Maps.newHashMap(); + //private static Map types = Maps.newHashMap(); + private static Map entries = Maps.newHashMap(); + private static Map priorities = Maps.newHashMap(); + + public static RecipeSorter INSTANCE = new RecipeSorter(); + private static boolean isDirty = true; + + private static SortEntry before = new SortEntry("Before", null, UNKNOWN, ""); + private static SortEntry after = new SortEntry("After", null, UNKNOWN, ""); + + private RecipeSorter() + { + register("minecraft:shaped", ShapedRecipes.class, SHAPED, "before:minecraft:shapeless"); + register("minecraft:mapextending", RecipesMapExtending.class, SHAPED, "after:minecraft:shaped before:minecraft:shapeless"); + register("minecraft:shapeless", ShapelessRecipes.class, SHAPELESS, "after:minecraft:shaped"); + register("minecraft:bookcloning", RecipeBookCloning.class, SHAPELESS, "after:minecraft:shapeless"); //Size 9 + register("minecraft:fireworks", RecipeFireworks.class, SHAPELESS, "after:minecraft:shapeless"); //Size 10 + register("minecraft:armordyes", RecipesArmorDyes.class, SHAPELESS, "after:minecraft:shapeless"); //Size 10 + register("minecraft:mapcloning", RecipesMapCloning.class, SHAPELESS, "after:minecraft:shapeless"); //Size 10 + + register("forge:shapedore", ShapedOreRecipe.class, SHAPED, "after:minecraft:shaped before:minecraft:shapeless"); + register("forge:shapelessore", ShapelessOreRecipe.class, SHAPELESS, "after:minecraft:shapeless"); + } + + @Override + public int compare(IRecipe r1, IRecipe r2) + { + Category c1 = getCategory(r1); + Category c2 = getCategory(r2); + if (c1 == SHAPELESS && c2 == SHAPED) return 1; + if (c1 == SHAPED && c2 == SHAPELESS) return -1; + if (r2.getRecipeSize() < r1.getRecipeSize()) return -1; + if (r2.getRecipeSize() > r1.getRecipeSize()) return 1; + return getPriority(r2) - getPriority(r1); // high priority value first! + } + + private static Set warned = Sets.newHashSet(); + @SuppressWarnings("unchecked") + public static void sortCraftManager() + { + bake(); + FMLLog.fine("Sorting recipies"); + warned.clear(); + Collections.sort(CraftingManager.getInstance().getRecipeList(), INSTANCE); + } + + public static void register(String name, Class recipe, Category category, String dependancies) + { + assert(category != UNKNOWN) : "Category must not be unknown!"; + isDirty = true; + + SortEntry entry = new SortEntry(name, recipe, category, dependancies); + entries.put(name, entry); + setCategory(recipe, category); + } + + public static void setCategory(Class recipe, Category category) + { + assert(category != UNKNOWN) : "Category must not be unknown!"; + categories.put(recipe, category); + } + + public static Category getCategory(IRecipe recipe) + { + return getCategory(recipe.getClass()); + } + + public static Category getCategory(Class recipe) + { + Class cls = recipe; + Category ret = categories.get(cls); + + if (ret == null) + { + while (cls != Object.class) + { + cls = cls.getSuperclass(); + ret = categories.get(cls); + if (ret != null) + { + categories.put(recipe, ret); + return ret; + } + } + } + + return ret == null ? UNKNOWN : ret; + } + + private static int getPriority(IRecipe recipe) + { + Class cls = recipe.getClass(); + Integer ret = priorities.get(cls); + + if (ret == null) + { + if (!warned.contains(cls)) + { + FMLLog.info(" Unknown recipe class! %s Modder please refer to %s", cls.getName(), RecipeSorter.class.getName()); + warned.add(cls); + } + cls = cls.getSuperclass(); + while (cls != Object.class) + { + ret = priorities.get(cls); + if (ret != null) + { + priorities.put(recipe.getClass(), ret); + FMLLog.fine(" Parent Found: %d - %s", ret.intValue(), cls.getName()); + return ret.intValue(); + } + } + } + + return ret == null ? 0 : ret.intValue(); + } + + private static void bake() + { + if (!isDirty) return; + FMLLog.fine("Forge RecipeSorter Baking:"); + DirectedGraph sorter = new DirectedGraph(); + sorter.addNode(before); + sorter.addNode(after); + sorter.addEdge(before, after); + + for (Map.Entry entry : entries.entrySet()) + { + sorter.addNode(entry.getValue()); + } + + for (Map.Entry e : entries.entrySet()) + { + SortEntry entry = e.getValue(); + boolean postAdded = false; + + sorter.addEdge(before, entry); + for (String dep : entry.after) + { + if (entries.containsKey(dep)) + { + sorter.addEdge(entries.get(dep), entry); + } + } + + for (String dep : entry.before) + { + postAdded = true; + sorter.addEdge(entry, after); + if (entries.containsKey(dep)) + { + sorter.addEdge(entry, entries.get(dep)); + } + } + + if (!postAdded) + { + sorter.addEdge(entry, after); + } + } + + + List sorted = TopologicalSort.topologicalSort(sorter); + int x = sorted.size(); + for (SortEntry entry : sorted) + { + FMLLog.fine(" %d: %s", x, entry); + priorities.put(entry.cls, x--); + } + } +} diff --git a/src/main/java/net/minecraftforge/oredict/ShapedOreRecipe.java b/src/main/java/net/minecraftforge/oredict/ShapedOreRecipe.java new file mode 100644 index 0000000..0f10ad3 --- /dev/null +++ b/src/main/java/net/minecraftforge/oredict/ShapedOreRecipe.java @@ -0,0 +1,265 @@ +package net.minecraftforge.oredict; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; + +import net.minecraft.block.Block; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.ShapedRecipes; +import net.minecraft.world.World; + +public class ShapedOreRecipe implements IRecipe +{ + //Added in for future ease of change, but hard coded for now. + private static final int MAX_CRAFT_GRID_WIDTH = 3; + private static final int MAX_CRAFT_GRID_HEIGHT = 3; + + private ItemStack output = null; + private Object[] input = null; + private int width = 0; + private int height = 0; + private boolean mirrored = true; + + public ShapedOreRecipe(Block result, Object... recipe){ this(new ItemStack(result), recipe); } + public ShapedOreRecipe(Item result, Object... recipe){ this(new ItemStack(result), recipe); } + public ShapedOreRecipe(ItemStack result, Object... recipe) + { + output = result.copy(); + + String shape = ""; + int idx = 0; + + if (recipe[idx] instanceof Boolean) + { + mirrored = (Boolean)recipe[idx]; + if (recipe[idx+1] instanceof Object[]) + { + recipe = (Object[])recipe[idx+1]; + } + else + { + idx = 1; + } + } + + if (recipe[idx] instanceof String[]) + { + String[] parts = ((String[])recipe[idx++]); + + for (String s : parts) + { + width = s.length(); + shape += s; + } + + height = parts.length; + } + else + { + while (recipe[idx] instanceof String) + { + String s = (String)recipe[idx++]; + shape += s; + width = s.length(); + height++; + } + } + + if (width * height != shape.length()) + { + String ret = "Invalid shaped ore recipe: "; + for (Object tmp : recipe) + { + ret += tmp + ", "; + } + ret += output; + throw new RuntimeException(ret); + } + + HashMap itemMap = new HashMap(); + + for (; idx < recipe.length; idx += 2) + { + Character chr = (Character)recipe[idx]; + Object in = recipe[idx + 1]; + + if (in instanceof ItemStack) + { + itemMap.put(chr, ((ItemStack)in).copy()); + } + else if (in instanceof Item) + { + itemMap.put(chr, new ItemStack((Item)in)); + } + else if (in instanceof Block) + { + itemMap.put(chr, new ItemStack((Block)in, 1, OreDictionary.WILDCARD_VALUE)); + } + else if (in instanceof String) + { + itemMap.put(chr, OreDictionary.getOres((String)in)); + } + else + { + String ret = "Invalid shaped ore recipe: "; + for (Object tmp : recipe) + { + ret += tmp + ", "; + } + ret += output; + throw new RuntimeException(ret); + } + } + + input = new Object[width * height]; + int x = 0; + for (char chr : shape.toCharArray()) + { + input[x++] = itemMap.get(chr); + } + } + + ShapedOreRecipe(ShapedRecipes recipe, Map replacements) + { + output = recipe.getRecipeOutput(); + width = recipe.recipeWidth; + height = recipe.recipeHeight; + + input = new Object[recipe.recipeItems.length]; + + for(int i = 0; i < input.length; i++) + { + ItemStack ingred = recipe.recipeItems[i]; + + if(ingred == null) continue; + + input[i] = recipe.recipeItems[i]; + + for(Entry replace : replacements.entrySet()) + { + if(OreDictionary.itemMatches(replace.getKey(), ingred, true)) + { + input[i] = OreDictionary.getOres(replace.getValue()); + break; + } + } + } + } + + @Override + public ItemStack getCraftingResult(InventoryCrafting var1){ return output.copy(); } + + @Override + public int getRecipeSize(){ return input.length; } + + @Override + public ItemStack getRecipeOutput(){ return output; } + + @Override + public boolean matches(InventoryCrafting inv, World world) + { + for (int x = 0; x <= MAX_CRAFT_GRID_WIDTH - width; x++) + { + for (int y = 0; y <= MAX_CRAFT_GRID_HEIGHT - height; ++y) + { + if (checkMatch(inv, x, y, false)) + { + return true; + } + + if (mirrored && checkMatch(inv, x, y, true)) + { + return true; + } + } + } + + return false; + } + + @SuppressWarnings("unchecked") + private boolean checkMatch(InventoryCrafting inv, int startX, int startY, boolean mirror) + { + for (int x = 0; x < MAX_CRAFT_GRID_WIDTH; x++) + { + for (int y = 0; y < MAX_CRAFT_GRID_HEIGHT; y++) + { + int subX = x - startX; + int subY = y - startY; + Object target = null; + + if (subX >= 0 && subY >= 0 && subX < width && subY < height) + { + if (mirror) + { + target = input[width - subX - 1 + subY * width]; + } + else + { + target = input[subX + subY * width]; + } + } + + ItemStack slot = inv.getStackInRowAndColumn(x, y); + + if (target instanceof ItemStack) + { + if (!checkItemEquals((ItemStack)target, slot)) + { + return false; + } + } + else if (target instanceof ArrayList) + { + boolean matched = false; + + for (ItemStack item : (ArrayList)target) + { + matched = matched || checkItemEquals(item, slot); + } + + if (!matched) + { + return false; + } + } + else if (target == null && slot != null) + { + return false; + } + } + } + + return true; + } + + private boolean checkItemEquals(ItemStack target, ItemStack input) + { + if (input == null && target != null || input != null && target == null) + { + return false; + } + return (target.getItem() == input.getItem() && (target.getItemDamage() == OreDictionary.WILDCARD_VALUE|| target.getItemDamage() == input.getItemDamage())); + } + + public ShapedOreRecipe setMirrored(boolean mirror) + { + mirrored = mirror; + return this; + } + + /** + * Returns the input for this recipe, any mod accessing this value should never + * manipulate the values in this array as it will effect the recipe itself. + * @return The recipes input vales. + */ + public Object[] getInput() + { + return this.input; + } +} diff --git a/src/main/java/net/minecraftforge/oredict/ShapelessOreRecipe.java b/src/main/java/net/minecraftforge/oredict/ShapelessOreRecipe.java new file mode 100644 index 0000000..cf9b301 --- /dev/null +++ b/src/main/java/net/minecraftforge/oredict/ShapelessOreRecipe.java @@ -0,0 +1,153 @@ +package net.minecraftforge.oredict; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.ShapelessRecipes; +import net.minecraft.world.World; + +public class ShapelessOreRecipe implements IRecipe +{ + private ItemStack output = null; + private ArrayList input = new ArrayList(); + + public ShapelessOreRecipe(Block result, Object... recipe){ this(new ItemStack(result), recipe); } + public ShapelessOreRecipe(Item result, Object... recipe){ this(new ItemStack(result), recipe); } + + public ShapelessOreRecipe(ItemStack result, Object... recipe) + { + output = result.copy(); + for (Object in : recipe) + { + if (in instanceof ItemStack) + { + input.add(((ItemStack)in).copy()); + } + else if (in instanceof Item) + { + input.add(new ItemStack((Item)in)); + } + else if (in instanceof Block) + { + input.add(new ItemStack((Block)in)); + } + else if (in instanceof String) + { + input.add(OreDictionary.getOres((String)in)); + } + else + { + String ret = "Invalid shapeless ore recipe: "; + for (Object tmp : recipe) + { + ret += tmp + ", "; + } + ret += output; + throw new RuntimeException(ret); + } + } + } + + @SuppressWarnings("unchecked") + ShapelessOreRecipe(ShapelessRecipes recipe, Map replacements) + { + output = recipe.getRecipeOutput(); + + for(ItemStack ingred : ((List)recipe.recipeItems)) + { + Object finalObj = ingred; + for(Entry replace : replacements.entrySet()) + { + if(OreDictionary.itemMatches(replace.getKey(), ingred, false)) + { + finalObj = OreDictionary.getOres(replace.getValue()); + break; + } + } + input.add(finalObj); + } + } + + @Override + public int getRecipeSize(){ return input.size(); } + + @Override + public ItemStack getRecipeOutput(){ return output; } + + @Override + public ItemStack getCraftingResult(InventoryCrafting var1){ return output.copy(); } + + @SuppressWarnings("unchecked") + @Override + public boolean matches(InventoryCrafting var1, World world) + { + ArrayList required = new ArrayList(input); + + for (int x = 0; x < var1.getSizeInventory(); x++) + { + ItemStack slot = var1.getStackInSlot(x); + + if (slot != null) + { + boolean inRecipe = false; + Iterator req = required.iterator(); + + while (req.hasNext()) + { + boolean match = false; + + Object next = req.next(); + + if (next instanceof ItemStack) + { + match = checkItemEquals((ItemStack)next, slot); + } + else if (next instanceof ArrayList) + { + for (ItemStack item : (ArrayList)next) + { + match = match || checkItemEquals(item, slot); + } + } + + if (match) + { + inRecipe = true; + required.remove(next); + break; + } + } + + if (!inRecipe) + { + return false; + } + } + } + + return required.isEmpty(); + } + + private boolean checkItemEquals(ItemStack target, ItemStack input) + { + return (target.getItem() == input.getItem() && (target.getItemDamage() == OreDictionary.WILDCARD_VALUE || target.getItemDamage() == input.getItemDamage())); + } + + /** + * Returns the input for this recipe, any mod accessing this value should never + * manipulate the values in this array as it will effect the recipe itself. + * @return The recipes input vales. + */ + public ArrayList getInput() + { + return this.input; + } +} diff --git a/src/main/java/net/minecraftforge/server/ForgeTimeTracker.java b/src/main/java/net/minecraftforge/server/ForgeTimeTracker.java new file mode 100644 index 0000000..7436896 --- /dev/null +++ b/src/main/java/net/minecraftforge/server/ForgeTimeTracker.java @@ -0,0 +1,113 @@ +package net.minecraftforge.server; + +import java.lang.ref.WeakReference; +import java.util.Arrays; +import java.util.Map; +import java.util.Map.Entry; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMap.Builder; +import com.google.common.collect.MapMaker; + +import net.minecraft.entity.Entity; +import net.minecraft.tileentity.TileEntity; + +public class ForgeTimeTracker { + public static boolean tileEntityTracking; + public static int tileEntityTrackingDuration; + public static long tileEntityTrackingTime; + + private Map tileEntityTimings; + private Map entityTimings; + + private static final ForgeTimeTracker INSTANCE = new ForgeTimeTracker(); + + private WeakReference tile; + private WeakReference entity; + + private long timing; + + private ForgeTimeTracker() + { + MapMaker mm = new MapMaker(); + mm.weakKeys(); + tileEntityTimings = mm.makeMap(); + entityTimings = mm.makeMap(); + } + + + private void trackTileStart(TileEntity tileEntity, long nanoTime) + { + if (tileEntityTrackingTime == 0) + { + tileEntityTrackingTime = nanoTime; + } + else if (tileEntityTrackingTime + tileEntityTrackingDuration < nanoTime) + { + tileEntityTracking = false; + tileEntityTrackingTime = 0; + + return; + } + tile = new WeakReference(tileEntity); + timing = nanoTime; + } + + + private void trackTileEnd(TileEntity tileEntity, long nanoTime) + { + if (tile == null || tile.get() != tileEntity) + { + tile = null; + // race, exit + return; + } + int[] timings = tileEntityTimings.get(tileEntity); + if (timings == null) + { + timings = new int[101]; + tileEntityTimings.put(tileEntity, timings); + } + int idx = timings[100] = (timings[100] + 1) % 100; + timings[idx] = (int) (nanoTime - timing); + } + + public static ImmutableMap getTileTimings() + { + return INSTANCE.buildImmutableTileEntityTimingMap(); + } + + private ImmutableMap buildImmutableTileEntityTimingMap() + { + Builder builder = ImmutableMap.builder(); + for (Entry entry : tileEntityTimings.entrySet()) + { + builder.put(entry.getKey(), Arrays.copyOfRange(entry.getValue(), 0, 100)); + } + return builder.build(); + } + + + public static void trackStart(TileEntity tileEntity) + { + if (!tileEntityTracking) return; + INSTANCE.trackTileStart(tileEntity, System.nanoTime()); + } + + public static void trackEnd(TileEntity tileEntity) + { + if (!tileEntityTracking) return; + INSTANCE.trackTileEnd(tileEntity, System.nanoTime()); + } + + public static void trackStart(Entity par1Entity) + { + + } + + public static void trackEnd(Entity par1Entity) + { + + } + +} diff --git a/src/main/java/net/minecraftforge/server/command/ForgeCommand.java b/src/main/java/net/minecraftforge/server/command/ForgeCommand.java new file mode 100644 index 0000000..a9e4257 --- /dev/null +++ b/src/main/java/net/minecraftforge/server/command/ForgeCommand.java @@ -0,0 +1,138 @@ +package net.minecraftforge.server.command; + +import java.text.DecimalFormat; +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandSender; +import net.minecraft.command.WrongUsageException; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraftforge.common.DimensionManager; +import net.minecraftforge.server.ForgeTimeTracker; + +public class ForgeCommand extends CommandBase { + + private MinecraftServer server; + + public ForgeCommand(MinecraftServer server) + { + this.server = server; + } + private static final DecimalFormat timeFormatter = new DecimalFormat("########0.000"); + + @Override + public String getCommandName() + { + return "forge"; + } + + @Override + public String getCommandUsage(ICommandSender icommandsender) + { + return "commands.forge.usage"; + } + + @Override + public int getRequiredPermissionLevel() + { + return 2; + } + @Override + public void processCommand(ICommandSender sender, String[] args) + { + if (args.length == 0) + { + throw new WrongUsageException("commands.forge.usage"); + } + else if ("help".equals(args[0])) + { + throw new WrongUsageException("commands.forge.usage"); + } + else if ("tps".equals(args[0])) + { + displayTPS(sender,args); + } + else if ("tpslog".equals(args[0])) + { + doTPSLog(sender,args); + } + else if ("track".equals(args[0])) + { + handleTracking(sender, args); + } + else + { + throw new WrongUsageException("commands.forge.usage"); + } + } + + private void handleTracking(ICommandSender sender, String[] args) + { + if (args.length != 3) + { + throw new WrongUsageException("commands.forge.usage.tracking"); + } + String type = args[1]; + int duration = parseIntBounded(sender, args[2], 1, 60); + + if ("te".equals(type)) + { + doTurnOnTileEntityTracking(sender, duration); + } + else + { + throw new WrongUsageException("commands.forge.usage.tracking"); + } + } + + private void doTurnOnTileEntityTracking(ICommandSender sender, int duration) + { + ForgeTimeTracker.tileEntityTrackingDuration = duration; + ForgeTimeTracker.tileEntityTracking = true; + sender.addChatMessage(new ChatComponentTranslation("commands.forge.tracking.te.enabled", duration)); + } + + private void doTPSLog(ICommandSender sender, String[] args) + { + + } + + private void displayTPS(ICommandSender sender, String[] args) + { + int dim = 0; + boolean summary = true; + if (args.length > 1) + { + dim = parseInt(sender, args[1]); + summary = false; + } + if (summary) + { + for (Integer dimId : DimensionManager.getIDs()) + { + double worldTickTime = ForgeCommand.mean(this.server.worldTickTimes.get(dimId)) * 1.0E-6D; + double worldTPS = Math.min(1000.0/worldTickTime, 20); + sender.addChatMessage(new ChatComponentTranslation("commands.forge.tps.summary",String.format("Dim %d", dimId), timeFormatter.format(worldTickTime), timeFormatter.format(worldTPS))); + } + double meanTickTime = ForgeCommand.mean(this.server.tickTimeArray) * 1.0E-6D; + double meanTPS = Math.min(1000.0/meanTickTime, 20); + sender.addChatMessage(new ChatComponentTranslation("commands.forge.tps.summary","Overall", timeFormatter.format(meanTickTime), timeFormatter.format(meanTPS))); + } + else + { + double worldTickTime = ForgeCommand.mean(this.server.worldTickTimes.get(dim)) * 1.0E-6D; + double worldTPS = Math.min(1000.0/worldTickTime, 20); + sender.addChatMessage(new ChatComponentTranslation("commands.forge.tps.summary",String.format("Dim %d", dim), timeFormatter.format(worldTickTime), timeFormatter.format(worldTPS))); + } + } + + private static long mean(long[] values) + { + long sum = 0l; + for (long v : values) + { + sum+=v; + } + + return sum / values.length; + } +} diff --git a/src/main/java/net/minecraftforge/transformers/ForgeAccessTransformer.java b/src/main/java/net/minecraftforge/transformers/ForgeAccessTransformer.java new file mode 100644 index 0000000..27e0ebf --- /dev/null +++ b/src/main/java/net/minecraftforge/transformers/ForgeAccessTransformer.java @@ -0,0 +1,13 @@ +package net.minecraftforge.transformers; + +import java.io.IOException; + +import cpw.mods.fml.common.asm.transformers.AccessTransformer; + +public class ForgeAccessTransformer extends AccessTransformer +{ + public ForgeAccessTransformer() throws IOException + { + super("forge_at.cfg"); + } +} diff --git a/src/main/resources/Log4j-config.xsd b/src/main/resources/Log4j-config.xsd new file mode 100644 index 0000000..a19e125 --- /dev/null +++ b/src/main/resources/Log4j-config.xsd @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/Log4j-events.dtd b/src/main/resources/Log4j-events.dtd new file mode 100644 index 0000000..91af8c7 --- /dev/null +++ b/src/main/resources/Log4j-events.dtd @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/Log4j-events.xsd b/src/main/resources/Log4j-events.xsd new file mode 100644 index 0000000..2310227 --- /dev/null +++ b/src/main/resources/Log4j-events.xsd @@ -0,0 +1,74 @@ + + + + + + + Log4J 2.0 XML Schema for XML log event files. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/assets/fml/textures/gui/icons.png b/src/main/resources/assets/fml/textures/gui/icons.png new file mode 100644 index 0000000..20bb91e --- /dev/null +++ b/src/main/resources/assets/fml/textures/gui/icons.png Binary files differ diff --git a/src/main/resources/assets/forge/lang/de_DE.lang b/src/main/resources/assets/forge/lang/de_DE.lang new file mode 100644 index 0000000..6f7aa57 --- /dev/null +++ b/src/main/resources/assets/forge/lang/de_DE.lang @@ -0,0 +1,6 @@ +commands.forge.usage=Nutzte /forge . Subbefehle sind tps, track +commands.forge.usage.tracking=Nutze /forge track . Gültige Typen sind te (Tile Entities). Dauer ist < 60. +commands.forge.tps.summary=%s : Mittlere tick-Zeit: %d ms. Mittlere TPS: %d + +commands.forge.tracking.te.enabled=Tile-Entity-Tracking aktiviert für %d Sekunden. +forge.texture.preload.warning=Warnung: Textur %s nicht vorgeladen, wird Render-Probleme verursachen! diff --git a/src/main/resources/assets/forge/lang/en_US.lang b/src/main/resources/assets/forge/lang/en_US.lang new file mode 100644 index 0000000..0110b4d --- /dev/null +++ b/src/main/resources/assets/forge/lang/en_US.lang @@ -0,0 +1,6 @@ +commands.forge.usage=Use /forge . Subcommands are tps, track +commands.forge.usage.tracking=Use /forge track . Valid types are te (Tile Entities). Duration is < 60. +commands.forge.tps.summary=%s : Mean tick time: %d ms. Mean TPS: %d + +commands.forge.tracking.te.enabled=Tile Entity tracking enabled for %d seconds. +forge.texture.preload.warning=Warning: Texture %s not preloaded, will cause render glitches! \ No newline at end of file diff --git a/src/main/resources/assets/forge/lang/es_ES.lang b/src/main/resources/assets/forge/lang/es_ES.lang new file mode 100644 index 0000000..b7c198e --- /dev/null +++ b/src/main/resources/assets/forge/lang/es_ES.lang @@ -0,0 +1,5 @@ +commands.forge.usage=Usa /forge . Los subcomandos son tps, track +commands.forge.usage.tracking=Usa /forge track . Los tipos válidos te (Tile Entities). La duración es < 60. +commands.forge.tps.summary=%s : Tiempo de tick medio: %d ms. TPS medio: %d + +commands.forge.tracking.te.enabled=Rastreo de Tile Entity activado durante %d segundos. diff --git a/src/main/resources/assets/forge/lang/fr_FR.lang b/src/main/resources/assets/forge/lang/fr_FR.lang new file mode 100644 index 0000000..bd01daa --- /dev/null +++ b/src/main/resources/assets/forge/lang/fr_FR.lang @@ -0,0 +1,5 @@ +commands.forge.usage=Utilisez /forge . Les sous-commandes sont tps, track +commands.forge.usage.tracking=Utilisez /forge track . Les types valides sont te (Tile Entities). La durée doit être inférieur à 60. +commands.forge.tps.summary=%s : Duré de tick : %d ms. TPS moyen : %d + +commands.forge.tracking.te.enabled=Trackage des Tile Entity activé pour %d secondes. \ No newline at end of file diff --git a/src/main/resources/assets/forge/lang/ru_RU.lang b/src/main/resources/assets/forge/lang/ru_RU.lang new file mode 100644 index 0000000..0e18c09 --- /dev/null +++ b/src/main/resources/assets/forge/lang/ru_RU.lang @@ -0,0 +1,6 @@ +commands.forge.usage=Используйте /forge <подкоманда>. Подкоманды: tps, track +commands.forge.usage.tracking=Используйте /forge track <тип> <длительность>. Возможные типы te (Tile Entities). Длительность < 60. +commands.forge.tps.summary=%s : Среднее время (такт): %d ms. Средняя TPS: %d + +commands.forge.tracking.te.enabled=Tile Entity отслеживание включено на %d секунд. +forge.texture.preload.warning=Предупреждение: Текстура %s не загрузилась, вызовет графические глюки! diff --git a/src/main/resources/assets/minecraft/font/glyph_sizes.bin b/src/main/resources/assets/minecraft/font/glyph_sizes.bin new file mode 100644 index 0000000..69c857e --- /dev/null +++ b/src/main/resources/assets/minecraft/font/glyph_sizes.bin Binary files differ diff --git a/src/main/resources/assets/minecraft/lang/en_US.lang b/src/main/resources/assets/minecraft/lang/en_US.lang new file mode 100644 index 0000000..4feb71f --- /dev/null +++ b/src/main/resources/assets/minecraft/lang/en_US.lang @@ -0,0 +1,1685 @@ + +language.name=English +language.region=US +language.code=en_US + +gui.done=Done +gui.cancel=Cancel +gui.back=Back +gui.toMenu=Back to title screen +gui.up=Up +gui.down=Down +gui.yes=Yes +gui.no=No + +translation.test.none=Hello, world! +translation.test.complex=Prefix, %s%2$s again %s and %1$s lastly %s and also %1$s again! +translation.test.escape=%%s %%%s %%%%s %%%%%s +translation.test.invalid=hi % +translation.test.invalid2=hi % s +translation.test.args=%s %s +translation.test.world=world + +menu.singleplayer=Singleplayer +menu.multiplayer=Multiplayer +menu.online=Minecraft Realms +menu.options=Options... +menu.quit=Quit Game +menu.returnToMenu=Save and Quit to Title +menu.disconnect=Disconnect +menu.returnToGame=Back to Game +menu.switchingLevel=Switching worlds +menu.generatingLevel=Generating world +menu.loadingLevel=Loading world +menu.generatingTerrain=Building terrain +menu.convertingLevel=Converting world +menu.simulating=Simulating the world for a bit +menu.respawning=Respawning +menu.shareToLan=Open to LAN + +selectWorld.title=Select World +selectWorld.empty=empty +selectWorld.world=World +selectWorld.select=Play Selected World +selectWorld.create=Create New World +selectWorld.recreate=Re-Create +selectWorld.createDemo=Play New Demo World +selectWorld.delete=Delete +selectWorld.rename=Rename +selectWorld.deleteQuestion=Are you sure you want to delete this world? +selectWorld.deleteWarning=will be lost forever! (A long time!) +selectWorld.deleteButton=Delete +selectWorld.renameButton=Rename +selectWorld.renameTitle=Rename World +selectWorld.conversion=Must be converted! +selectWorld.newWorld=New World +selectWorld.newWorld.copyOf=Copy of %s +selectWorld.enterName=World Name +selectWorld.resultFolder=Will be saved in: +selectWorld.enterSeed=Seed for the World Generator +selectWorld.seedInfo=Leave blank for a random seed +selectWorld.cheats=Cheats +selectWorld.customizeType=Customize + +createWorld.customize.presets=Presets +createWorld.customize.presets.title=Select a Preset +createWorld.customize.presets.select=Use Preset +createWorld.customize.presets.share=Want to share your preset with someone? Use the below box! +createWorld.customize.presets.list=Alternatively, here's some we made earlier! +createWorld.customize.flat.title=Superflat Customization +createWorld.customize.flat.tile=Layer Material +createWorld.customize.flat.height=Height +createWorld.customize.flat.addLayer=Add Layer +createWorld.customize.flat.editLayer=Edit Layer +createWorld.customize.flat.removeLayer=Remove Layer +createWorld.customize.flat.layer.top=Top - %d +createWorld.customize.flat.layer=%d +createWorld.customize.flat.layer.bottom=Bottom - %d + +gameMode.survival=Survival Mode +gameMode.creative=Creative Mode +gameMode.adventure=Adventure Mode +gameMode.hardcore=Hardcore Mode! +gameMode.changed=Your game mode has been updated + +selectWorld.gameMode=Game Mode +selectWorld.gameMode.survival=Survival +selectWorld.gameMode.survival.line1=Search for resources, crafting, gain +selectWorld.gameMode.survival.line2=levels, health and hunger +selectWorld.gameMode.creative=Creative +selectWorld.gameMode.creative.line1=Unlimited resources, free flying and +selectWorld.gameMode.creative.line2=destroy blocks instantly +selectWorld.gameMode.hardcore=Hardcore +selectWorld.gameMode.hardcore.line1=Same as survival mode, locked at hardest +selectWorld.gameMode.hardcore.line2=difficulty, and one life only +selectWorld.gameMode.adventure=Adventure +selectWorld.gameMode.adventure.line1=Same as survival mode, but blocks can't +selectWorld.gameMode.adventure.line2=be added or removed +selectWorld.moreWorldOptions=More World Options... +selectWorld.mapFeatures=Generate Structures: +selectWorld.mapFeatures.info=Villages, dungeons etc +selectWorld.mapType=World Type: +selectWorld.mapType.normal=Normal +selectWorld.allowCommands=Allow Cheats: +selectWorld.allowCommands.info=Commands like /gamemode, /xp +selectWorld.hardcoreMode=Hardcore: +selectWorld.hardcoreMode.info=World is deleted upon death +selectWorld.bonusItems=Bonus Chest: + +generator.default=Default +generator.flat=Superflat +generator.largeBiomes=Large Biomes +generator.amplified=AMPLIFIED + +generator.amplified.info=Notice: Just for fun, requires beefy computer + +selectServer.title=Select Server +selectServer.empty=empty +selectServer.select=Join Server +selectServer.direct=Direct Connect +selectServer.edit=Edit +selectServer.delete=Delete +selectServer.add=Add server +selectServer.defaultName=Minecraft Server +selectServer.deleteQuestion=Are you sure you want to remove this server? +selectServer.deleteWarning=will be lost forever! (A long time!) +selectServer.deleteButton=Delete +selectServer.refresh=Refresh +selectServer.hiddenAddress=(Hidden) +addServer.title=Edit Server Info +addServer.enterName=Server Name +addServer.enterIp=Server Address +addServer.add=Done +addServer.hideAddress=Hide Address +lanServer.title=LAN World +lanServer.scanning=Scanning for games on your local network +lanServer.start=Start LAN World +lanServer.otherPlayers=Settings for Other Players +mcoServer.title=Minecraft Online World + +multiplayer.title=Play Multiplayer +multiplayer.connect=Connect +multiplayer.info1=Minecraft Multiplayer is currently not finished, but there +multiplayer.info2=is some buggy early testing going on. +multiplayer.ipinfo=Enter the IP of a server to connect to it: +multiplayer.texturePrompt.line1=This server recommends the use of a custom resource pack. +multiplayer.texturePrompt.line2=Would you like to download and install it automagically? +multiplayer.downloadingTerrain=Downloading terrain +multiplayer.downloadingStats=Downloading statistics & achievements... +multiplayer.stopSleeping=Leave Bed +multiplayer.player.joined=%s joined the game +multiplayer.player.left=%s left the game + +chat.cannotSend=Cannot send chat message +chat.type.text=<%s> %s +chat.type.emote=* %s %s +chat.type.announcement=[%s] %s +chat.type.admin=[%s: %s] +chat.type.achievement=%s has just earned the achievement %s +chat.link.confirm=Are you sure you want to open the following website? +chat.link.warning=Never open links from people that you don't trust! +chat.copy=Copy to Clipboard +chat.link.confirmTrusted=Do you want to open this link or copy it to your clipboard? +chat.link.open=Open in browser + +$o=Play Demo World +menu.resetdemo=Reset Demo World + +demo.day.1=This demo will last five game days, do your best! +demo.day.2=Day Two +demo.day.3=Day Three +demo.day.4=Day Four +demo.day.5=This is your last day! +demo.day.warning=Your time is almost up! +demo.day.6=You have passed your fifth day, use F2 to save a screenshot of your creation +demo.reminder=The demo time has expired, buy the game to continue or start a new world! +demo.remainingTime=Remaining time: %s +demo.demoExpired=Demo time's up! +demo.help.movement=Use %1$s, %2$s, %3$s, %4$s and the mouse to move around +demo.help.movementShort=Move by pressing %1$s, %2$s, %3$s, %4$s +demo.help.movementMouse=Look around using the mouse +demo.help.jump=Jump by pressing %1$s +demo.help.inventory=Use %1$s to open your inventory +demo.help.title=Minecraft Demo Mode +demo.help.fullWrapped=This demo will last 5 ingame days (about 1 hour and 40 minutes of real time). Check the achievements for hints! Have fun! +demo.help.buy=Purchase Now! +demo.help.later=Continue Playing! + +connect.connecting=Connecting to the server... +connect.authorizing=Logging in... +connect.failed=Failed to connect to the server + +disconnect.genericReason=%s +disconnect.disconnected=Disconnected by Server +disconnect.lost=Connection Lost +disconnect.kicked=Was kicked from the game +disconnect.timeout=Timed out +disconnect.closed=Connection closed +disconnect.loginFailed=Failed to login +disconnect.loginFailedInfo=Failed to login: %s +disconnect.loginFailedInfo.serversUnavailable=The authentication are currently down for maintenance. +disconnect.loginFailedInfo.invalidSession=Invalid session (Try restarting your game) +disconnect.quitting=Quitting +disconnect.endOfStream=End of stream +disconnect.overflow=Buffer overflow +disconnect.spam=Kicked for spamming + +soundCategory.master=Master Volume +soundCategory.music=Music +soundCategory.record=Jukebox/Noteblocks +soundCategory.weather=Weather +soundCategory.hostile=Hostile Creatures +soundCategory.neutral=Friendly Creatures +soundCategory.player=Players +soundCategory.block=Blocks +soundCategory.ambient=Ambient/Environment + +options.off=OFF +options.on=ON +options.visible=Shown +options.hidden=Hidden +options.title=Options +options.controls=Controls... +options.video=Video Settings... +options.language=Language... +options.sounds=Music & Sounds... +options.sounds.title=Music & Sound Options +options.languageWarning=Language translations may not be 100%% accurate +options.videoTitle=Video Settings +options.music=Music +options.sound=Sound +options.invertMouse=Invert Mouse +options.fov=FOV +options.fov.min=Normal +options.fov.max=Quake Pro +options.saturation=Saturation +options.gamma=Brightness +options.gamma.min=Moody +options.gamma.max=Bright +options.sensitivity=Sensitivity +options.sensitivity.min=*yawn* +options.sensitivity.max=HYPERSPEED!!! +options.renderDistance=Render Distance +options.renderDistance.tiny=Tiny +options.renderDistance.short=Short +options.renderDistance.normal=Normal +options.renderDistance.far=Far +options.viewBobbing=View Bobbing +options.ao=Smooth Lighting +options.ao.off=OFF +options.ao.min=Minimum +options.ao.max=Maximum +options.anaglyph=3D Anaglyph +options.framerateLimit=Max Framerate +options.framerateLimit.max=Unlimited +options.difficulty=Difficulty +options.difficulty.peaceful=Peaceful +options.difficulty.easy=Easy +options.difficulty.normal=Normal +options.difficulty.hard=Hard +options.difficulty.hardcore=Hardcore +options.graphics=Graphics +options.graphics.fancy=Fancy +options.graphics.fast=Fast +options.guiScale=GUI Scale +options.guiScale.auto=Auto +options.guiScale.small=Small +options.guiScale.normal=Normal +options.guiScale.large=Large +options.advancedOpengl=Advanced OpenGL +options.fboEnable=Enable FBOs +options.postProcessEnable=Enable Post-Processing +options.aoDesc0=Enable faux ambient occlusion on blocks. +options.aoDesc1= +options.framerateLimitDesc0=Selects the maximum frame rate: +options.framerateLimitDesc1=35fps, 120fps, or 200+fps. +options.viewBobbingDesc0=Enables view-bob when moving. +options.viewBobbingDesc1= +options.renderCloudsDesc0=Enables the rendering of clouds. +options.renderCloudsDesc1= +options.graphicsDesc0='Fancy': Enables extra transparency. +options.graphicsDesc1='Fast': Suggested for lower-end hardware. +options.renderDistanceDesc0=Maximum render distance. Smaller values +options.renderDistanceDesc1=run better on lower-end hardware. +options.particlesDesc0=Selects the overall amount of particles. +options.particlesDesc1=On lower-end hardware, less is better. +options.advancedOpenglDesc0=Enables occlusion queries. On AMD and Intel +options.advancedOpenglDesc1=hardware, this may decrease performance. +options.fboEnableDesc0=Enables the use of Framebuffer Objects. +options.fboEnableDesc1=Necessary for certain Minecraft features. +options.postProcessEnableDesc0=Enables post-processing. Disabling will +options.postProcessEnableDesc1=result in reduction in Awesome Levels. +options.renderClouds=Clouds +options.qualityButton=Video Quality Settings... +options.qualityVideoTitle=Video Quality Settings +options.performanceButton=Video Performance Settings... +options.performanceVideoTitle=Video Performance Settings +options.advancedButton=Advanced Video Settings... +options.advancedVideoTitle=Advanced Video Settings +options.postButton=Post-Processing Settings... +options.postVideoTitle=Post-Processing Settings +options.farWarning1=A 64 bit Java installation is recommended +options.farWarning2=for 'Far' render distance (you have 32 bit) +options.particles=Particles +options.particles.all=All +options.particles.decreased=Decreased +options.particles.minimal=Minimal +options.multiplayer.title=Multiplayer Settings... +options.chat.title=Chat Settings... +options.chat.visibility=Chat +options.chat.visibility.full=Shown +options.chat.visibility.system=Commands Only +options.chat.visibility.hidden=Hidden +options.chat.color=Colors +options.chat.opacity=Opacity +options.chat.links=Web Links +options.chat.links.prompt=Prompt on Links +options.chat.scale=Scale +options.chat.width=Width +options.chat.height.focused=Focused Height +options.chat.height.unfocused=Unfocused Height +options.showCape=Show Cape +options.serverTextures=Server Textures +options.snooper=Allow Snooper +options.snooper.view=Snooper Settings... +options.snooper.title=Machine Specs Collection +options.snooper.desc=We want to collect information about your machine to help improve Minecraft by knowing what we can support and where the biggest problems are. All of this information is completely anonymous and viewable below. We promise we won't do anything bad with this data, but if you want to opt out then feel free to toggle it off! +options.resourcepack=Resource Packs... +options.fullscreen=Fullscreen +options.vsync=Use VSync +options.touchscreen=Touchscreen Mode +options.mipmapLevels=Mipmap Levels +options.anisotropicFiltering=Anisotropic Filtering +options.forceUnicodeFont=Force Unicode Font + +controls.title=Controls +controls.reset=Reset +controls.resetAll=Reset Keys + +key.sprint=Sprint +key.forward=Walk Forwards +key.left=Strafe Left +key.back=Walk Backwards +key.right=Strafe Right +key.jump=Jump +key.inventory=Inventory +key.drop=Drop Item +key.chat=Open Chat +key.sneak=Sneak +key.playerlist=List Players +key.attack=Attack/Destroy +key.use=Use Item/Place Block +key.pickItem=Pick Block +key.mouseButton=Button %1$s +key.command=Open Command +key.screenshot=Take Screenshot +key.togglePerspective=Toggle Perspective +key.smoothCamera=Toggle Cinematic Camera +key.hotbar.1=Hotbar Slot 1 +key.hotbar.2=Hotbar Slot 2 +key.hotbar.3=Hotbar Slot 3 +key.hotbar.4=Hotbar Slot 4 +key.hotbar.5=Hotbar Slot 5 +key.hotbar.6=Hotbar Slot 6 +key.hotbar.7=Hotbar Slot 7 +key.hotbar.8=Hotbar Slot 8 +key.hotbar.9=Hotbar Slot 9 + +key.categories.movement=Movement +key.categories.misc=Miscellaneous +key.categories.multiplayer=Multiplayer +key.categories.gameplay=Gameplay +key.categories.ui=Game Interface +key.categories.inventory=Inventory + +resourcePack.openFolder=Open resource pack folder +resourcePack.title=Select Resource Packs +resourcePack.available.title=Available Resource Packs +resourcePack.selected.title=Selected Resource Packs +resourcePack.folderInfo=(Place resource pack files here) + +book.pageIndicator=Page %1$s of %2$s +book.byAuthor=by %1$s +book.signButton=Sign +book.editTitle=Enter Book Title: +book.finalizeButton=Sign and Close +book.finalizeWarning=Note! When you sign the book, it will no longer be editable. + +tile.stone.name=Stone +tile.hayBlock.name=Hay Bale +tile.grass.name=Grass Block +tile.dirt.default.name=Dirt +tile.dirt.podzol.name=Podzol +tile.stonebrick.name=Cobblestone +tile.wood.name=Wooden Planks +tile.wood.oak.name=Oak Wood Planks +tile.wood.spruce.name=Spruce Wood Planks +tile.wood.birch.name=Birch Wood Planks +tile.wood.jungle.name=Jungle Wood Planks +tile.wood.acacia.name=Acacia Wood Planks +tile.wood.big_oak.name=Dark Oak Wood Planks +tile.sapling.oak.name=Oak Sapling +tile.sapling.spruce.name=Spruce Sapling +tile.sapling.birch.name=Birch Sapling +tile.sapling.jungle.name=Jungle Sapling +tile.sapling.acacia.name=Acacia Sapling +tile.sapling.roofed_oak.name=Dark Oak Sapling +tile.deadbush.name=Dead Bush +tile.bedrock.name=Bedrock +tile.water.name=Water +tile.lava.name=Lava +tile.sand.default.name=Sand +tile.sand.red.name=Red Sand +tile.sandStone.name=Sandstone +tile.sandStone.default.name=Sandstone +tile.sandStone.chiseled.name=Chiseled Sandstone +tile.sandStone.smooth.name=Smooth Sandstone +tile.gravel.name=Gravel +tile.oreGold.name=Gold Ore +tile.oreIron.name=Iron Ore +tile.oreCoal.name=Coal Ore +tile.log.name=Wood +tile.log.oak.name=Oak Wood +tile.log.spruce.name=Spruce Wood +tile.log.birch.name=Birch Wood +tile.log.jungle.name=Jungle Wood +tile.log.acacia.name=Acacia Wood +tile.log.big_oak.name=Dark Oak Wood +tile.leaves.name=Leaves +tile.leaves.oak.name=Oak Leaves +tile.leaves.spruce.name=Spruce Leaves +tile.leaves.birch.name=Birch Leaves +tile.leaves.jungle.name=Jungle Leaves +tile.leaves.acacia.name=Acacia Leaves +tile.leaves.big_oak.name=Dark Oak Leaves +tile.tallgrass.name=Grass +tile.tallgrass.shrub.name=Shrub +tile.tallgrass.grass.name=Grass +tile.tallgrass.fern.name=Fern +tile.sponge.name=Sponge +tile.glass.name=Glass +tile.stainedGlass.name=Stained Glass +tile.stainedGlass.black.name=Black Stained Glass +tile.stainedGlass.red.name=Red Stained Glass +tile.stainedGlass.green.name=Green Stained Glass +tile.stainedGlass.brown.name=Brown Stained Glass +tile.stainedGlass.blue.name=Blue Stained Glass +tile.stainedGlass.purple.name=Purple Stained Glass +tile.stainedGlass.cyan.name=Cyan Stained Glass +tile.stainedGlass.silver.name=Light Gray Stained Glass +tile.stainedGlass.gray.name=Gray Stained Glass +tile.stainedGlass.pink.name=Pink Stained Glass +tile.stainedGlass.lime.name=Lime Stained Glass +tile.stainedGlass.yellow.name=Yellow Stained Glass +tile.stainedGlass.lightBlue.name=Light Blue Stained Glass +tile.stainedGlass.magenta.name=Magenta Stained Glass +tile.stainedGlass.orange.name=Orange Stained Glass +tile.stainedGlass.white.name=White Stained Glass +tile.thinStainedGlass.name=Stained Glass Pane +tile.thinStainedGlass.black.name=Black Stained Glass Pane +tile.thinStainedGlass.red.name=Red Stained Glass Pane +tile.thinStainedGlass.green.name=Green Stained Glass Pane +tile.thinStainedGlass.brown.name=Brown Stained Glass Pane +tile.thinStainedGlass.blue.name=Blue Stained Glass Pane +tile.thinStainedGlass.purple.name=Purple Stained Glass Pane +tile.thinStainedGlass.cyan.name=Cyan Stained Glass Pane +tile.thinStainedGlass.silver.name=Light Gray Stained Glass Pane +tile.thinStainedGlass.gray.name=Gray Stained Glass Pane +tile.thinStainedGlass.pink.name=Pink Stained Glass Pane +tile.thinStainedGlass.lime.name=Lime Stained Glass Pane +tile.thinStainedGlass.yellow.name=Yellow Stained Glass Pane +tile.thinStainedGlass.lightBlue.name=Light Blue Stained Glass Pane +tile.thinStainedGlass.magenta.name=Magenta Stained Glass Pane +tile.thinStainedGlass.orange.name=Orange Stained Glass Pane +tile.thinStainedGlass.white.name=White Stained Glass Pane +tile.thinGlass.name=Glass Pane +tile.cloth.name=Wool +tile.flower1.dandelion.name=Dandelion +tile.flower2.poppy.name=Poppy +tile.flower2.blueOrchid.name=Blue Orchid +tile.flower2.allium.name=Allium +tile.flower2.houstonia.name=Azure Bluet +tile.flower2.tulipRed.name=Red Tulip +tile.flower2.tulipOrange.name=Orange Tulip +tile.flower2.tulipWhite.name=White Tulip +tile.flower2.tulipPink.name=Pink Tulip +tile.flower2.oxeyeDaisy.name=Oxeye Daisy +tile.doublePlant.sunflower.name=Sunflower +tile.doublePlant.syringa.name=Lilac +tile.doublePlant.grass.name=Double Tallgrass +tile.doublePlant.fern.name=Large Fern +tile.doublePlant.rose.name=Rose Bush +tile.doublePlant.paeonia.name=Peony +tile.mushroom.name=Mushroom +tile.blockGold.name=Block of Gold +tile.blockIron.name=Block of Iron +tile.stoneSlab.stone.name=Stone Slab +tile.stoneSlab.sand.name=Sandstone Slab +tile.stoneSlab.wood.name=Wooden Slab +tile.stoneSlab.cobble.name=Cobblestone Slab +tile.stoneSlab.brick.name=Bricks Slab +tile.stoneSlab.smoothStoneBrick.name=Stone Bricks Slab +tile.stoneSlab.netherBrick.name=Nether Brick Slab +tile.stoneSlab.quartz.name=Quartz Slab +tile.woodSlab.oak.name=Oak Wood Slab +tile.woodSlab.spruce.name=Spruce Wood Slab +tile.woodSlab.birch.name=Birch Wood Slab +tile.woodSlab.jungle.name=Jungle Wood Slab +tile.woodSlab.acacia.name=Acacia Wood Slab +tile.woodSlab.big_oak.name=Dark Oak Wood Slab +tile.brick.name=Bricks +tile.tnt.name=TNT +tile.bookshelf.name=Bookshelf +tile.stoneMoss.name=Moss Stone +tile.obsidian.name=Obsidian +tile.torch.name=Torch +tile.fire.name=Fire +tile.mobSpawner.name=Monster Spawner +tile.stairsWood.name=Oak Wood Stairs +tile.stairsWoodSpruce.name=Spruce Wood Stairs +tile.stairsWoodBirch.name=Birch Wood Stairs +tile.stairsWoodJungle.name=Jungle Wood Stairs +tile.stairsWoodAcacia.name=Acacia Wood Stairs +tile.stairsWoodDarkOak.name=Dark Oak Wood Stairs +tile.chest.name=Chest +tile.chestTrap.name=Trapped Chest +tile.redstoneDust.name=Redstone Dust +tile.oreDiamond.name=Diamond Ore +tile.blockCoal.name=Block of Coal +tile.blockDiamond.name=Block of Diamond +tile.workbench.name=Crafting Table +tile.crops.name=Crops +tile.farmland.name=Farmland +tile.furnace.name=Furnace +tile.sign.name=Sign +tile.doorWood.name=Wooden Door +tile.ladder.name=Ladder +tile.rail.name=Rail +tile.goldenRail.name=Powered Rail +tile.activatorRail.name=Activator Rail +tile.detectorRail.name=Detector Rail +tile.stairsStone.name=Stone Stairs +tile.stairsSandStone.name=Sandstone Stairs +tile.lever.name=Lever +tile.pressurePlate.name=Pressure Plate +tile.weightedPlate_light.name=Weighted Pressure Plate (Light) +tile.weightedPlate_heavy.name=Weighted Pressure Plate (Heavy) +tile.doorIron.name=Iron Door +tile.oreRedstone.name=Redstone Ore +tile.notGate.name=Redstone Torch +tile.button.name=Button +tile.snow.name=Snow +tile.woolCarpet.black.name=Black Carpet +tile.woolCarpet.red.name=Red Carpet +tile.woolCarpet.green.name=Green Carpet +tile.woolCarpet.brown.name=Brown Carpet +tile.woolCarpet.blue.name=Blue Carpet +tile.woolCarpet.purple.name=Purple Carpet +tile.woolCarpet.cyan.name=Cyan Carpet +tile.woolCarpet.silver.name=Light Gray Carpet +tile.woolCarpet.gray.name=Gray Carpet +tile.woolCarpet.pink.name=Pink Carpet +tile.woolCarpet.lime.name=Lime Carpet +tile.woolCarpet.yellow.name=Yellow Carpet +tile.woolCarpet.lightBlue.name=Light Blue Carpet +tile.woolCarpet.magenta.name=Magenta Carpet +tile.woolCarpet.orange.name=Orange Carpet +tile.woolCarpet.white.name=Carpet +tile.ice.name=Ice +tile.icePacked.name=Packed Ice +tile.cactus.name=Cactus +tile.clay.name=Clay +tile.clayHardenedStained.black.name=Black Stained Clay +tile.clayHardenedStained.red.name=Red Stained Clay +tile.clayHardenedStained.green.name=Green Stained Clay +tile.clayHardenedStained.brown.name=Brown Stained Clay +tile.clayHardenedStained.blue.name=Blue Stained Clay +tile.clayHardenedStained.purple.name=Purple Stained Clay +tile.clayHardenedStained.cyan.name=Cyan Stained Clay +tile.clayHardenedStained.silver.name=Light Gray Stained Clay +tile.clayHardenedStained.gray.name=Gray Stained Clay +tile.clayHardenedStained.pink.name=Pink Stained Clay +tile.clayHardenedStained.lime.name=Lime Stained Clay +tile.clayHardenedStained.yellow.name=Yellow Stained Clay +tile.clayHardenedStained.lightBlue.name=Light Blue Stained Clay +tile.clayHardenedStained.magenta.name=Magenta Stained Clay +tile.clayHardenedStained.orange.name=Orange Stained Clay +tile.clayHardenedStained.white.name=White Stained Clay +tile.clayHardened.name=Hardened Clay +tile.reeds.name=Sugar cane +tile.jukebox.name=Jukebox +tile.fence.name=Fence +tile.fenceGate.name=Fence Gate +tile.pumpkin.name=Pumpkin +tile.litpumpkin.name=Jack o'Lantern +tile.hellrock.name=Netherrack +tile.hellsand.name=Soul Sand +tile.lightgem.name=Glowstone +tile.portal.name=Portal +tile.cloth.black.name=Black Wool +tile.cloth.red.name=Red Wool +tile.cloth.green.name=Green Wool +tile.cloth.brown.name=Brown Wool +tile.cloth.blue.name=Blue Wool +tile.cloth.purple.name=Purple Wool +tile.cloth.cyan.name=Cyan Wool +tile.cloth.silver.name=Light Gray Wool +tile.cloth.gray.name=Gray Wool +tile.cloth.pink.name=Pink Wool +tile.cloth.lime.name=Lime Wool +tile.cloth.yellow.name=Yellow Wool +tile.cloth.lightBlue.name=Light Blue Wool +tile.cloth.magenta.name=Magenta Wool +tile.cloth.orange.name=Orange Wool +tile.cloth.white.name=Wool +tile.oreLapis.name=Lapis Lazuli Ore +tile.blockLapis.name=Lapis Lazuli Block +tile.dispenser.name=Dispenser +tile.dropper.name=Dropper +tile.musicBlock.name=Note Block +tile.cake.name=Cake +tile.bed.name=Bed +tile.bed.occupied=This bed is occupied +tile.bed.noSleep=You can only sleep at night +tile.bed.notSafe=You may not rest now, there are monsters nearby +tile.bed.notValid=Your home bed was missing or obstructed +tile.lockedchest.name=Locked chest +tile.trapdoor.name=Trapdoor +tile.web.name=Cobweb +tile.stonebricksmooth.name=Stone Bricks +tile.stonebricksmooth.default.name=Stone Bricks +tile.stonebricksmooth.mossy.name=Mossy Stone Bricks +tile.stonebricksmooth.cracked.name=Cracked Stone Bricks +tile.stonebricksmooth.chiseled.name=Chiseled Stone Bricks +tile.monsterStoneEgg.stone.name=Stone Monster Egg +tile.monsterStoneEgg.cobble.name=Cobblestone Monster Egg +tile.monsterStoneEgg.brick.name=Stone Brick Monster Egg +tile.monsterStoneEgg.mossybrick.name=Mossy Stone Brick Monster Egg +tile.monsterStoneEgg.crackedbrick.name=Cracked Stone Brick Monster Egg +tile.monsterStoneEgg.chiseledbrick.name=Chiseled Stone Brick Monster Egg +tile.pistonBase.name=Piston +tile.pistonStickyBase.name=Sticky Piston +tile.fenceIron.name=Iron Bars +tile.melon.name=Melon +tile.stairsBrick.name=Brick Stairs +tile.stairsStoneBrickSmooth.name=Stone Brick Stairs +tile.vine.name=Vines +tile.netherBrick.name=Nether Brick +tile.netherFence.name=Nether Brick Fence +tile.stairsNetherBrick.name=Nether Brick Stairs +tile.netherStalk.name=Nether Wart +tile.cauldron.name=Cauldron +tile.enchantmentTable.name=Enchantment Table +tile.anvil.name=Anvil +tile.anvil.intact.name=Anvil +tile.anvil.slightlyDamaged.name=Slightly Damaged Anvil +tile.anvil.veryDamaged.name=Very Damaged Anvil +tile.whiteStone.name=End Stone +tile.endPortalFrame.name=End Portal +tile.mycel.name=Mycelium +tile.waterlily.name=Lily Pad +tile.dragonEgg.name=Dragon Egg +tile.redstoneLight.name=Redstone Lamp +tile.cocoa.name=Cocoa +tile.enderChest.name=Ender Chest +tile.oreRuby.name=Ruby Ore +tile.oreEmerald.name=Emerald Ore +tile.blockEmerald.name=Block of Emerald +tile.blockRedstone.name=Block of Redstone +tile.tripWire.name=Tripwire +tile.tripWireSource.name=Tripwire Hook +tile.commandBlock.name=Command Block +tile.beacon.name=Beacon +tile.beacon.primary=Primary Power +tile.beacon.secondary=Secondary Power +tile.cobbleWall.normal.name=Cobblestone Wall +tile.cobbleWall.mossy.name=Mossy Cobblestone Wall +tile.carrots.name=Carrots +tile.potatoes.name=Potatoes +tile.daylightDetector.name=Daylight Sensor +tile.netherquartz.name=Nether Quartz Ore +tile.hopper.name=Hopper +tile.quartzBlock.default.name=Block of Quartz +tile.quartzBlock.chiseled.name=Chiseled Quartz Block +tile.quartzBlock.lines.name=Pillar Quartz Block +tile.stairsQuartz.name=Quartz Stairs + +item.nameTag.name=Name Tag +item.leash.name=Lead +item.shovelIron.name=Iron Shovel +item.pickaxeIron.name=Iron Pickaxe +item.hatchetIron.name=Iron Axe +item.flintAndSteel.name=Flint and Steel +item.apple.name=Apple +item.cookie.name=Cookie +item.bow.name=Bow +item.arrow.name=Arrow +item.coal.name=Coal +item.charcoal.name=Charcoal +item.diamond.name=Diamond +item.emerald.name=Emerald +item.ingotIron.name=Iron Ingot +item.ingotGold.name=Gold Ingot +item.swordIron.name=Iron Sword +item.swordWood.name=Wooden Sword +item.shovelWood.name=Wooden Shovel +item.pickaxeWood.name=Wooden Pickaxe +item.hatchetWood.name=Wooden Axe +item.swordStone.name=Stone Sword +item.shovelStone.name=Stone Shovel +item.pickaxeStone.name=Stone Pickaxe +item.hatchetStone.name=Stone Axe +item.swordDiamond.name=Diamond Sword +item.shovelDiamond.name=Diamond Shovel +item.pickaxeDiamond.name=Diamond Pickaxe +item.hatchetDiamond.name=Diamond Axe +item.stick.name=Stick +item.bowl.name=Bowl +item.mushroomStew.name=Mushroom Stew +item.swordGold.name=Golden Sword +item.shovelGold.name=Golden Shovel +item.pickaxeGold.name=Golden Pickaxe +item.hatchetGold.name=Golden Axe +item.string.name=String +item.feather.name=Feather +item.sulphur.name=Gunpowder +item.hoeWood.name=Wooden Hoe +item.hoeStone.name=Stone Hoe +item.hoeIron.name=Iron Hoe +item.hoeDiamond.name=Diamond Hoe +item.hoeGold.name=Golden Hoe +item.seeds.name=Seeds +item.seeds_pumpkin.name=Pumpkin Seeds +item.seeds_melon.name=Melon Seeds +item.melon.name=Melon +item.wheat.name=Wheat +item.bread.name=Bread +item.helmetCloth.name=Leather Cap +item.chestplateCloth.name=Leather Tunic +item.leggingsCloth.name=Leather Pants +item.bootsCloth.name=Leather Boots +item.helmetChain.name=Chain Helmet +item.chestplateChain.name=Chain Chestplate +item.leggingsChain.name=Chain Leggings +item.bootsChain.name=Chain Boots +item.helmetIron.name=Iron Helmet +item.chestplateIron.name=Iron Chestplate +item.leggingsIron.name=Iron Leggings +item.bootsIron.name=Iron Boots +item.helmetDiamond.name=Diamond Helmet +item.chestplateDiamond.name=Diamond Chestplate +item.leggingsDiamond.name=Diamond Leggings +item.bootsDiamond.name=Diamond Boots +item.helmetGold.name=Golden Helmet +item.chestplateGold.name=Golden Chestplate +item.leggingsGold.name=Golden Leggings +item.bootsGold.name=Golden Boots +item.flint.name=Flint +item.porkchopRaw.name=Raw Porkchop +item.porkchopCooked.name=Cooked Porkchop +item.chickenRaw.name=Raw Chicken +item.chickenCooked.name=Cooked Chicken +item.beefRaw.name=Raw Beef +item.beefCooked.name=Steak +item.painting.name=Painting +item.frame.name=Item Frame +item.appleGold.name=Golden Apple +item.sign.name=Sign +item.doorWood.name=Wooden Door +item.bucket.name=Bucket +item.bucketWater.name=Water Bucket +item.bucketLava.name=Lava Bucket +item.minecart.name=Minecart +item.saddle.name=Saddle +item.doorIron.name=Iron Door +item.redstone.name=Redstone +item.snowball.name=Snowball +item.boat.name=Boat +item.leather.name=Leather +item.milk.name=Milk +item.brick.name=Brick +item.clay.name=Clay +item.reeds.name=Sugar Canes +item.paper.name=Paper +item.book.name=Book +item.slimeball.name=Slimeball +item.minecartChest.name=Minecart with Chest +item.minecartFurnace.name=Minecart with Furnace +item.minecartTnt.name=Minecart with TNT +item.minecartHopper.name=Minecart with Hopper +item.minecartCommandBlock.name=Minecart with Command Block +item.egg.name=Egg +item.compass.name=Compass +item.fishingRod.name=Fishing Rod +item.clock.name=Clock +item.yellowDust.name=Glowstone Dust +item.fish.cod.raw.name=Raw Fish +item.fish.salmon.raw.name=Raw Salmon +item.fish.pufferfish.raw.name=Pufferfish +item.fish.clownfish.raw.name=Clownfish +item.fish.cod.cooked.name=Cooked Fish +item.fish.salmon.cooked.name=Cooked Salmon +item.record.name=Music Disc +item.record.13.desc=C418 - 13 +item.record.cat.desc=C418 - cat +item.record.blocks.desc=C418 - blocks +item.record.chirp.desc=C418 - chirp +item.record.far.desc=C418 - far +item.record.mall.desc=C418 - mall +item.record.mellohi.desc=C418 - mellohi +item.record.stal.desc=C418 - stal +item.record.strad.desc=C418 - strad +item.record.ward.desc=C418 - ward +item.record.11.desc=C418 - 11 +item.record.wait.desc=C418 - wait +item.bone.name=Bone +item.dyePowder.black.name=Ink Sac +item.dyePowder.red.name=Rose Red +item.dyePowder.green.name=Cactus Green +item.dyePowder.brown.name=Cocoa Beans +item.dyePowder.blue.name=Lapis Lazuli +item.dyePowder.purple.name=Purple Dye +item.dyePowder.cyan.name=Cyan Dye +item.dyePowder.silver.name=Light Gray Dye +item.dyePowder.gray.name=Gray Dye +item.dyePowder.pink.name=Pink Dye +item.dyePowder.lime.name=Lime Dye +item.dyePowder.yellow.name=Dandelion Yellow +item.dyePowder.lightBlue.name=Light Blue Dye +item.dyePowder.magenta.name=Magenta Dye +item.dyePowder.orange.name=Orange Dye +item.dyePowder.white.name=Bone Meal +item.sugar.name=Sugar +item.cake.name=Cake +item.bed.name=Bed +item.diode.name=Redstone Repeater +item.comparator.name=Redstone Comparator +item.map.name=Map +item.leaves.name=Leaves +item.shears.name=Shears +item.rottenFlesh.name=Rotten Flesh +item.enderPearl.name=Ender Pearl +item.blazeRod.name=Blaze Rod +item.ghastTear.name=Ghast Tear +item.netherStalkSeeds.name=Nether Wart +item.potion.name=Potion +item.emptyPotion.name=Water Bottle +item.goldNugget.name=Gold Nugget +item.glassBottle.name=Glass Bottle +item.spiderEye.name=Spider Eye +item.fermentedSpiderEye.name=Fermented Spider Eye +item.blazePowder.name=Blaze Powder +item.magmaCream.name=Magma Cream +item.cauldron.name=Cauldron +item.brewingStand.name=Brewing Stand +item.eyeOfEnder.name=Eye of Ender +item.speckledMelon.name=Glistering Melon +item.monsterPlacer.name=Spawn +item.expBottle.name=Bottle o' Enchanting +item.fireball.name=Fire Charge +item.writingBook.name=Book and Quill +item.writtenBook.name=Written Book +item.ruby.name=Ruby +item.flowerPot.name=Flower Pot +item.emptyMap.name=Empty Map +item.carrots.name=Carrot +item.carrotGolden.name=Golden Carrot +item.potato.name=Potato +item.potatoBaked.name=Baked Potato +item.potatoPoisonous.name=Poisonous Potato +item.skull.skeleton.name=Skeleton Skull +item.skull.wither.name=Wither Skeleton Skull +item.skull.zombie.name=Zombie Head +item.skull.char.name=Head +item.skull.player.name=%s's Head +item.skull.creeper.name=Creeper Head +item.carrotOnAStick.name=Carrot on a Stick +item.netherStar.name=Nether Star +item.pumpkinPie.name=Pumpkin Pie +item.enchantedBook.name=Enchanted Book +item.fireworks.name=Firework Rocket +item.fireworks.flight=Flight Duration: +item.fireworksCharge.name=Firework Star +item.fireworksCharge.black=Black +item.fireworksCharge.red=Red +item.fireworksCharge.green=Green +item.fireworksCharge.brown=Brown +item.fireworksCharge.blue=Blue +item.fireworksCharge.purple=Purple +item.fireworksCharge.cyan=Cyan +item.fireworksCharge.silver=Light Gray +item.fireworksCharge.gray=Gray +item.fireworksCharge.pink=Pink +item.fireworksCharge.lime=Lime +item.fireworksCharge.yellow=Yellow +item.fireworksCharge.lightBlue=Light Blue +item.fireworksCharge.magenta=Magenta +item.fireworksCharge.orange=Orange +item.fireworksCharge.white=White +item.fireworksCharge.customColor=Custom +item.fireworksCharge.fadeTo=Fade to +item.fireworksCharge.flicker=Twinkle +item.fireworksCharge.trail=Trail +item.fireworksCharge.type.0=Small Ball +item.fireworksCharge.type.1=Large Ball +item.fireworksCharge.type.2=Star-shaped +item.fireworksCharge.type.3=Creeper-shaped +item.fireworksCharge.type.4=Burst +item.fireworksCharge.type=Unknown Shape +item.netherbrick.name=Nether Brick +item.netherquartz.name=Nether Quartz +item.horsearmormetal.name=Iron Horse Armor +item.horsearmorgold.name=Gold Horse Armor +item.horsearmordiamond.name=Diamond Horse Armor + +container.inventory=Inventory +container.hopper=Item Hopper +container.crafting=Crafting +container.dispenser=Dispenser +container.dropper=Dropper +container.furnace=Furnace +container.enchant=Enchant +container.repair=Repair & Name +container.repair.cost=Enchantment Cost: %1$d +container.repair.expensive=Too Expensive! +container.creative=Item Selection +container.brewing=Brewing Stand +container.chest=Chest +container.chestDouble=Large Chest +container.minecart=Minecart +container.enderchest=Ender Chest + +item.dyed=Dyed +item.unbreakable=Unbreakable + +entity.Item.name=Item +entity.XPOrb.name=Experience Orb +entity.SmallFireball.name=Small Fireball +entity.Fireball.name=Fireball + +entity.Arrow.name=Arrow +entity.Snowball.name=Snowball +entity.Painting.name=Painting + +entity.Mob.name=Mob +entity.Monster.name=Monster + +entity.Creeper.name=Creeper +entity.Skeleton.name=Skeleton +entity.Spider.name=Spider +entity.Giant.name=Giant +entity.Zombie.name=Zombie +entity.Slime.name=Slime +entity.Ghast.name=Ghast +entity.PigZombie.name=Zombie Pigman +entity.Enderman.name=Enderman +entity.Silverfish.name=Silverfish +entity.CaveSpider.name=Cave Spider +entity.Blaze.name=Blaze +entity.LavaSlime.name=Magma Cube +entity.MushroomCow.name=Mooshroom +entity.Villager.name=Villager +entity.VillagerGolem.name=Iron Golem +entity.SnowMan.name=Snow Golem +entity.EnderDragon.name=Ender Dragon +entity.WitherBoss.name=Wither +entity.Witch.name=Witch + +entity.Pig.name=Pig +entity.Sheep.name=Sheep +entity.Cow.name=Cow +entity.Chicken.name=Chicken +entity.Squid.name=Squid +entity.Wolf.name=Wolf +entity.Ozelot.name=Ocelot +entity.Cat.name=Cat +entity.Bat.name=Bat +entity.EntityHorse.name=Horse +entity.horse.name=Horse +entity.donkey.name=Donkey +entity.mule.name=Mule +entity.skeletonhorse.name=Skeleton Horse +entity.zombiehorse.name=Zombie Horse + +entity.PrimedTnt.name=Block of TNT +entity.FallingSand.name=Falling Block + +entity.Minecart.name=Minecart +entity.Boat.name=Boat + +entity.Arrow.name=arrow +entity.generic.name=unknown + +death.fell.accident.ladder=%1$s fell off a ladder +death.fell.accident.vines=%1$s fell off some vines +death.fell.accident.water=%1$s fell out of the water +death.fell.accident.generic=%1$s fell from a high place +death.fell.killer=%1$s was doomed to fall +death.fell.assist=%1$s was doomed to fall by %2$s +death.fell.assist.item=%1$s was doomed to fall by %2$s using %3$s +death.fell.finish=%1$s fell too far and was finished by %2$s +death.fell.finish.item=%1$s fell too far and was finished by %2$s using %3$s + +death.attack.inFire=%1$s went up in flames +death.attack.inFire.player=%1$s walked into fire whilst fighting %2$s +death.attack.onFire=%1$s burned to death +death.attack.onFire.player=%1$s was burnt to a crisp whilst fighting %2$s +death.attack.lava=%1$s tried to swim in lava +death.attack.lava.player=%1$s tried to swim in lava to escape %2$s +death.attack.inWall=%1$s suffocated in a wall +death.attack.drown=%1$s drowned +death.attack.drown.player=%1$s drowned whilst trying to escape %2$s +death.attack.starve=%1$s starved to death +death.attack.cactus=%1$s was pricked to death +death.attack.cactus.player=%1$s walked into a cactus whilst trying to escape %2$s +death.attack.generic=%1$s died +death.attack.explosion=%1$s blew up +death.attack.explosion.player=%1$s was blown up by %2$s +death.attack.magic=%1$s was killed by magic +death.attack.wither=%1$s withered away +death.attack.anvil=%1$s was squashed by a falling anvil +death.attack.fallingBlock=%1$s was squashed by a falling block +death.attack.mob=%1$s was slain by %2$s +death.attack.player=%1$s was slain by %2$s +death.attack.player.item=%1$s was slain by %2$s using %3$s +death.attack.arrow=%1$s was shot by %2$s +death.attack.arrow.item=%1$s was shot by %2$s using %3$s +death.attack.fireball=%1$s was fireballed by %2$s +death.attack.fireball.item=%1$s was fireballed by %2$s using %3$s +death.attack.thrown=%1$s was pummeled by %2$s +death.attack.thrown.item=%1$s was pummeled by %2$s using %3$s +death.attack.indirectMagic=%1$s was killed by %2$s using magic +death.attack.indirectMagic.item=%1$s was killed by %2$s using %3$s +death.attack.thorns=%1$s was killed trying to hurt %2$s +death.attack.fall=%1$s hit the ground too hard +death.attack.outOfWorld=%1$s fell out of the world + +deathScreen.respawn=Respawn +deathScreen.deleteWorld=Delete world +deathScreen.titleScreen=Title screen +deathScreen.score=Score +deathScreen.title.hardcore=Game over! +deathScreen.hardcoreInfo=You cannot respawn in hardcore mode! +deathScreen.title=You died! +deathScreen.leaveServer=Leave server +deathScreen.quit.confirm=Are you sure you want to quit? + +potion.effects.whenDrank=When Applied: +potion.empty=No Effects +potion.moveSpeed=Speed +potion.moveSlowdown=Slowness +potion.digSpeed=Haste +potion.digSlowDown=Mining Fatigue +potion.damageBoost=Strength +potion.weakness=Weakness +potion.heal=Instant Health +potion.harm=Instant Damage +potion.jump=Jump Boost +potion.confusion=Nausea +potion.regeneration=Regeneration +potion.resistance=Resistance +potion.fireResistance=Fire Resistance +potion.waterBreathing=Water Breathing +potion.invisibility=Invisibility +potion.blindness=Blindness +potion.nightVision=Night Vision +potion.hunger=Hunger +potion.poison=Poison +potion.wither=Wither +potion.healthBoost=Health Boost +potion.absorption=Absorption +potion.saturation=Saturation + +potion.moveSpeed.postfix=Potion of Swiftness +potion.moveSlowdown.postfix=Potion of Slowness +potion.digSpeed.postfix=Potion of Haste +potion.digSlowDown.postfix=Potion of Dullness +potion.damageBoost.postfix=Potion of Strength +potion.weakness.postfix=Potion of Weakness +potion.heal.postfix=Potion of Healing +potion.harm.postfix=Potion of Harming +potion.jump.postfix=Potion of Leaping +potion.confusion.postfix=Potion of Nausea +potion.regeneration.postfix=Potion of Regeneration +potion.resistance.postfix=Potion of Resistance +potion.fireResistance.postfix=Potion of Fire Resistance +potion.waterBreathing.postfix=Potion of Water Breathing +potion.invisibility.postfix=Potion of Invisibility +potion.blindness.postfix=Potion of Blindness +potion.nightVision.postfix=Potion of Night Vision +potion.hunger.postfix=Potion of Hunger +potion.poison.postfix=Potion of Poison +potion.wither.postfix=Potion of Decay +potion.healthBoost.postfix=Potion of Health Boost +potion.absorption.postfix=Potion of Absorption +potion.saturation.postfix=Potion of Saturation + +potion.potency.0= +potion.potency.1=II +potion.potency.2=III +potion.potency.3=IV + +potion.prefix.grenade=Splash +potion.prefix.mundane=Mundane +potion.prefix.uninteresting=Uninteresting +potion.prefix.bland=Bland +potion.prefix.clear=Clear +potion.prefix.milky=Milky +potion.prefix.diffuse=Diffuse +potion.prefix.artless=Artless +potion.prefix.thin=Thin +potion.prefix.awkward=Awkward +potion.prefix.flat=Flat +potion.prefix.bulky=Bulky +potion.prefix.bungling=Bungling +potion.prefix.buttered=Buttered +potion.prefix.smooth=Smooth +potion.prefix.suave=Suave +potion.prefix.debonair=Debonair +potion.prefix.thick=Thick +potion.prefix.elegant=Elegant +potion.prefix.fancy=Fancy +potion.prefix.charming=Charming +potion.prefix.dashing=Dashing +potion.prefix.refined=Refined +potion.prefix.cordial=Cordial +potion.prefix.sparkling=Sparkling +potion.prefix.potent=Potent +potion.prefix.foul=Foul +potion.prefix.odorless=Odorless +potion.prefix.rank=Rank +potion.prefix.harsh=Harsh +potion.prefix.acrid=Acrid +potion.prefix.gross=Gross +potion.prefix.stinky=Stinky + +enchantment.damage.all=Sharpness +enchantment.damage.undead=Smite +enchantment.damage.arthropods=Bane of Arthropods +enchantment.knockback=Knockback +enchantment.fire=Fire Aspect +enchantment.protect.all=Protection +enchantment.protect.fire=Fire Protection +enchantment.protect.fall=Feather Falling +enchantment.protect.explosion=Blast Protection +enchantment.protect.projectile=Projectile Protection +enchantment.oxygen=Respiration +enchantment.waterWorker=Aqua Affinity +enchantment.digging=Efficiency +enchantment.untouching=Silk Touch +enchantment.durability=Unbreaking +enchantment.lootBonus=Looting +enchantment.lootBonusDigger=Fortune +enchantment.lootBonusFishing=Luck of the Sea +enchantment.fishingSpeed=Lure +enchantment.arrowDamage=Power +enchantment.arrowFire=Flame +enchantment.arrowKnockback=Punch +enchantment.arrowInfinite=Infinity +enchantment.thorns=Thorns + +enchantment.level.1=I +enchantment.level.2=II +enchantment.level.3=III +enchantment.level.4=IV +enchantment.level.5=V +enchantment.level.6=VI +enchantment.level.7=VII +enchantment.level.8=VIII +enchantment.level.9=IX +enchantment.level.10=X + +gui.achievements=Achievements +gui.stats=Statistics + +stats.tooltip.type.achievement=Achievement +stats.tooltip.type.statistic=Statistic +stat.generalButton=General +stat.blocksButton=Blocks +stat.itemsButton=Items +stat.mobsButton=Mobs + +stat.used=Times Used +stat.mined=Times Mined +stat.depleted=Times Depleted +stat.crafted=Times Crafted +stat.entityKills=You killed %d %s +stat.entityKilledBy=%s killed you %d time(s) +stat.entityKills.none=You have never killed %s +stat.entityKilledBy.none=You have never been killed by %s + +stat.startGame=Times played +stat.createWorld=Worlds created +stat.loadWorld=Saves loaded +stat.joinMultiplayer=Multiplayer joins +stat.leaveGame=Games quit + +stat.playOneMinute=Minutes Played + +stat.walkOneCm=Distance Walked +stat.fallOneCm=Distance Fallen +stat.swimOneCm=Distance Swum +stat.flyOneCm=Distance Flown +stat.climbOneCm=Distance Climbed +stat.diveOneCm=Distance Dove +stat.minecartOneCm=Distance by Minecart +stat.boatOneCm=Distance by Boat +stat.pigOneCm=Distance by Pig +stat.horseOneCm=Distance by Horse +stat.jump=Jumps +stat.drop=Items Dropped + +stat.damageDealt=Damage Dealt +stat.damageTaken=Damage Taken +stat.deaths=Number of Deaths +stat.mobKills=Mob Kills +stat.animalsBred=Animals Bred +stat.playerKills=Player Kills +stat.fishCaught=Fish Caught +stat.treasureFished=Treasure Fished +stat.junkFished=Junk Fished + +stat.mineBlock=%1$s Mined +stat.craftItem=%1$s Crafted +stat.useItem=%1$s Used +stat.breakItem=%1$s Depleted + +achievement.get=Achievement get! + +achievement.taken=Taken! +achievement.unknown=??? + +achievement.requires=Requires '%1$s' +achievement.openInventory=Taking Inventory +achievement.openInventory.desc=Press '%1$s' to open your inventory. +achievement.mineWood=Getting Wood +achievement.mineWood.desc=Attack a tree until a block of wood pops out +achievement.buildWorkBench=Benchmarking +achievement.buildWorkBench.desc=Craft a workbench with four blocks of planks +achievement.buildPickaxe=Time to Mine! +achievement.buildPickaxe.desc=Use planks and sticks to make a pickaxe +achievement.buildFurnace=Hot Topic +achievement.buildFurnace.desc=Construct a furnace out of eight stone blocks +achievement.acquireIron=Acquire Hardware +achievement.acquireIron.desc=Smelt an iron ingot +achievement.buildHoe=Time to Farm! +achievement.buildHoe.desc=Use planks and sticks to make a hoe +achievement.makeBread=Bake Bread +achievement.makeBread.desc=Turn wheat into bread +achievement.bakeCake=The Lie +achievement.bakeCake.desc=Wheat, sugar, milk and eggs! +achievement.buildBetterPickaxe=Getting an Upgrade +achievement.buildBetterPickaxe.desc=Construct a better pickaxe +achievement.cookFish=Delicious Fish +achievement.cookFish.desc=Catch and cook fish! +achievement.onARail=On A Rail +achievement.onARail.desc=Travel by minecart at least 1 km from where you started +achievement.buildSword=Time to Strike! +achievement.buildSword.desc=Use planks and sticks to make a sword +achievement.killEnemy=Monster Hunter +achievement.killEnemy.desc=Attack and destroy a monster +achievement.killCow=Cow Tipper +achievement.killCow.desc=Harvest some leather +achievement.breedCow=Repopulation +achievement.breedCow.desc=Breed two cows with wheat +achievement.flyPig=When Pigs Fly +achievement.flyPig.desc=Fly a pig off a cliff +achievement.snipeSkeleton=Sniper Duel +achievement.snipeSkeleton.desc=Kill a skeleton with an arrow from more than 50 meters +achievement.diamonds=DIAMONDS! +achievement.diamonds.desc=Acquire diamonds with your iron tools +achievement.diamondsToYou=Diamonds to you! +achievement.diamondsToYou.desc=Throw diamonds at another player. +achievement.portal=We Need to Go Deeper +achievement.portal.desc=Build a portal to the Nether +achievement.ghast=Return to Sender +achievement.ghast.desc=Destroy a Ghast with a fireball +achievement.blazeRod=Into Fire +achievement.blazeRod.desc=Relieve a Blaze of its rod +achievement.potion=Local Brewery +achievement.potion.desc=Brew a potion +achievement.theEnd=The End? +achievement.theEnd.desc=Locate the End +achievement.theEnd2=The End. +achievement.theEnd2.desc=Defeat the Ender Dragon +achievement.spawnWither=The Beginning? +achievement.spawnWither.desc=Spawn the Wither +achievement.killWither=The Beginning. +achievement.killWither.desc=Kill the Wither +achievement.fullBeacon=Beaconator +achievement.fullBeacon.desc=Create a full beacon +achievement.exploreAllBiomes=Adventuring Time +achievement.exploreAllBiomes.desc=Discover all biomes +achievement.enchantments=Enchanter +achievement.enchantments.desc=Use a book, obsidian and diamonds to construct an enchantment table +achievement.overkill=Overkill +achievement.overkill.desc=Deal eight hearts of damage in a single hit +achievement.bookcase=Librarian +achievement.bookcase.desc=Build some bookshelves to improve your enchantment table + +commands.generic.exception=An unknown error occurred while attempting to perform this command +commands.generic.permission=You do not have permission to use this command +commands.generic.syntax=Invalid command syntax +commands.generic.player.notFound=That player cannot be found +commands.generic.notFound=Unknown command. Try /help for a list of commands +commands.generic.num.invalid='%s' is not a valid number +commands.generic.boolean.invalid='%s' is not true or false +commands.generic.num.tooSmall=The number you have entered (%d) is too small, it must be at least %d +commands.generic.num.tooBig=The number you have entered (%d) is too big, it must be at most %d +commands.generic.double.tooSmall=The number you have entered (%.2f) is too small, it must be at least %.2f +commands.generic.double.tooBig=The number you have entered (%.2f) is too big, it must be at most %.2f +commands.generic.usage=Usage: %s +commands.generic.deprecatedId=Warning: Using numeric IDs will not be supported in the future. Please use names, such as '%s' + +commands.setidletimeout.usage=/setidletimeout +commands.setidletimeout.success=Successfully set the idle timeout to %d minutes. +commands.xp.failure.widthdrawXp=Cannot give player negative experience points +commands.xp.success=Given %d experience to %s +commands.xp.success.levels=Given %d levels to %s +commands.xp.success.negative.levels=Taken %d levels from %s +commands.xp.usage=/xp [player] OR /xp L [player] +commands.playsound.usage=/playsound [x] [y] [z] [volume] [pitch] [minimumVolume] +commands.playsound.success=Played sound '%s' to %s +commands.playsound.playerTooFar=Player %s is too far away to hear the sound +commands.give.usage=/give [amount] [data] [dataTag] +commands.give.notFound=There is no such item with ID %d +commands.give.success=Given %s * %d to %s +commands.give.tagError=Data tag parsing failed: %s +commands.summon.usage=/summon [x] [y] [z] [dataTag] +commands.summon.success=Object successfully summoned +commands.summon.failed=Unable to summon object +commands.summon.tagError=Data tag parsing failed: %s +commands.summon.outOfWorld=Cannot summon the object out of the world +commands.testforblock.usage=/testforblock [dataValue] [dataTag] +commands.testforblock.failed.tile=The block at %d,%d,%d is %s (expected: %s). +commands.testforblock.failed.data=The block at %d,%d,%d had the data value of %s (expected: %s). +commands.testforblock.failed.nbt=The block at %d,%d,%d did not have the required NBT keys. +commands.testforblock.failed.tileEntity=The block at %d,%d,%d is not a tile entity and cannot support tag matching. +commands.testforblock.success=Successfully found the block at %d,%d,%d. +commands.testforblock.outOfWorld=Cannot test for block outside of the world +commands.setblock.usage=/setblock [dataValue] [oldBlockHandling] [dataTag] +commands.setblock.success=Block placed +commands.setblock.failed=Unable to place block +commands.setblock.tagError=Data tag parsing failed: %s +commands.setblock.outOfWorld=Cannot place block outside of the world +commands.setblock.notFound=There is no such block with ID/name %s +commands.setblock.noChange=The block couldn't be placed +commands.effect.usage=/effect [seconds] [amplifier] +commands.effect.notFound=There is no such mob effect with ID %d +commands.effect.success=Given %1$s (ID %2$d) * %3$d to %4$s for %5$d seconds +commands.effect.success.removed=Took %1$s from %2$s +commands.effect.success.removed.all=Took all effects from %s +commands.effect.failure.notActive=Couldn't take %1$s from %2$s as they do not have the effect +commands.effect.failure.notActive.all=Couldn't take any effects from %s as they do not have any +commands.enchant.usage=/enchant [level] +commands.enchant.notFound=There is no such enchantment with ID %d +commands.enchant.noItem=The target doesn't hold an item +commands.enchant.cantEnchant=The selected enchantment can't be added to the target item +commands.enchant.cantCombine=%1$s can't be combined with %2$s +commands.enchant.success=Enchanting succeeded +commands.clear.usage=/clear [item] [data] +commands.clear.success=Cleared the inventory of %s, removing %d items +commands.clear.failure=Could not clear the inventory of %s, no items to remove +commands.downfall.usage=/toggledownfall +commands.downfall.success=Toggled downfall +commands.time.usage=/time +commands.time.added=Added %d to the time +commands.time.set=Set the time to %d +commands.players.usage=/list +commands.players.list=There are %d/%d players online: +commands.banlist.ips=There are %d total banned IP addresses: +commands.banlist.players=There are %d total banned players: +commands.banlist.usage=/banlist [ips|players] +commands.kill.usage=/kill +commands.kill.success=Ouch! That looked like it hurt +commands.kick.success=Kicked %s from the game +commands.kick.success.reason=Kicked %s from the game: '%s' +commands.kick.usage=/kick [reason ...] +commands.op.success=Opped %s +commands.op.usage=/op +commands.deop.success=De-opped %s +commands.deop.usage=/deop +commands.say.usage=/say +commands.ban.success=Banned player %s +commands.ban.usage=/ban [reason ...] +commands.unban.success=Unbanned player %s +commands.unban.usage=/pardon +commands.banip.invalid=You have entered an invalid IP address or a player that is not online +commands.banip.success=Banned IP address %s +commands.banip.success.players=Banned IP address %s belonging to %s +commands.banip.usage=/ban-ip [reason ...] +commands.unbanip.invalid=You have entered an invalid IP address +commands.unbanip.success=Unbanned IP address %s +commands.unbanip.usage=/pardon-ip
+commands.save.usage=/save-all +commands.save-on.alreadyOn=Saving is already turned on. +commands.save-on.usage=/save-on +commands.save-off.alreadyOff=Saving is already turned off. +commands.save-off.usage=/save-off +commands.save.enabled=Turned on world auto-saving +commands.save.disabled=Turned off world auto-saving +commands.save.start=Saving... +commands.save.success=Saved the world +commands.save.failed=Saving failed: %s +commands.stop.usage=/stop +commands.stop.start=Stopping the server +commands.tp.success=Teleported %s to %s +commands.tp.success.coordinates=Teleported %s to %.2f,%.2f,%.2f +commands.tp.usage=/tp [target player] OR /tp [target player] +commands.tp.notSameDimension=Unable to teleport because players are not in the same dimension +commands.whitelist.list=There are %d (out of %d seen) whitelisted players: +commands.whitelist.enabled=Turned on the whitelist +commands.whitelist.disabled=Turned off the whitelist +commands.whitelist.reloaded=Reloaded the whitelist +commands.whitelist.add.success=Added %s to the whitelist +commands.whitelist.add.usage=/whitelist add +commands.whitelist.remove.success=Removed %s from the whitelist +commands.whitelist.remove.usage=/whitelist remove +commands.whitelist.usage=/whitelist +commands.scoreboard.usage=/scoreboard +commands.scoreboard.teamNotFound=No team was found by the name '%s' +commands.scoreboard.objectiveNotFound=No objective was found by the name '%s' +commands.scoreboard.objectiveReadOnly=The objective '%s' is read-only and cannot be set +commands.scoreboard.objectives.usage=/scoreboard objectives +commands.scoreboard.objectives.setdisplay.usage=/scoreboard objectives setdisplay [objective] +commands.scoreboard.objectives.setdisplay.invalidSlot=No such display slot '%s' +commands.scoreboard.objectives.setdisplay.successCleared=Cleared objective display slot '%s' +commands.scoreboard.objectives.setdisplay.successSet=Set the display objective in slot '%s' to '%s' +commands.scoreboard.objectives.add.usage=/scoreboard objectives add [display name ...] +commands.scoreboard.objectives.add.wrongType=Invalid objective criteria type '%s' +commands.scoreboard.objectives.add.alreadyExists=An objective with the name '%s' already exists +commands.scoreboard.objectives.add.tooLong=The name '%s' is too long for an objective, it can be at most %d characters long +commands.scoreboard.objectives.add.displayTooLong=The display name '%s' is too long for an objective, it can be at most %d characters long +commands.scoreboard.objectives.add.success=Added new objective '%s' successfully +commands.scoreboard.objectives.remove.usage=/scoreboard objectives remove +commands.scoreboard.objectives.remove.success=Removed objective '%s' successfully +commands.scoreboard.objectives.list.count=Showing %d objective(s) on scoreboard: +commands.scoreboard.objectives.list.entry=- %s: displays as '%s' and is type '%s' +commands.scoreboard.objectives.list.empty=There are no objectives on the scoreboard +commands.scoreboard.players.usage=/scoreboard players +commands.scoreboard.players.set.success=Set score of %s for player %s to %d +commands.scoreboard.players.set.usage=/scoreboard players set +commands.scoreboard.players.add.usage=/scoreboard players add +commands.scoreboard.players.remove.usage=/scoreboard players remove +commands.scoreboard.players.reset.usage=/scoreboard players reset +commands.scoreboard.players.reset.success=Reset all scores of player %s +commands.scoreboard.players.list.usage=/scoreboard players list [name] +commands.scoreboard.players.list.count=Showing %d tracked players on the scoreboard: +commands.scoreboard.players.list.empty=There are no tracked players on the scoreboard +commands.scoreboard.players.list.player.count=Showing %d tracked objective(s) for %s: +commands.scoreboard.players.list.player.entry=- %2$s: %1$d (%3$s) +commands.scoreboard.players.list.player.empty=Player %s has no scores recorded +commands.scoreboard.teams.usage=/scoreboard teams +commands.scoreboard.teams.add.usage=/scoreboard teams add [display name ...] +commands.scoreboard.teams.add.alreadyExists=A team with the name '%s' already exists +commands.scoreboard.teams.add.tooLong=The name '%s' is too long for a team, it can be at most %d characters long +commands.scoreboard.teams.add.displayTooLong=The display name '%s' is too long for a team, it can be at most %d characters long +commands.scoreboard.teams.add.success=Added new team '%s' successfully +commands.scoreboard.teams.list.usage=/scoreboard teams list [name] +commands.scoreboard.teams.list.count=Showing %d teams on the scoreboard: +commands.scoreboard.teams.list.entry=- %1$s: '%2$s' has %3$d players +commands.scoreboard.teams.list.empty=There are no teams registered on the scoreboard +commands.scoreboard.teams.list.player.count=Showing %d player(s) in team %s: +commands.scoreboard.teams.list.player.entry=- %2$s: %1$d (%3$s) +commands.scoreboard.teams.list.player.empty=Team %s has no players +commands.scoreboard.teams.empty.usage=/scoreboard teams empty +commands.scoreboard.teams.empty.alreadyEmpty=Team %s is already empty, cannot remove nonexistant players +commands.scoreboard.teams.empty.success=Removed all %d player(s) from team %s +commands.scoreboard.teams.remove.usage=/scoreboard teams remove +commands.scoreboard.teams.remove.success=Removed team %s +commands.scoreboard.teams.join.usage=/scoreboard teams join [player] +commands.scoreboard.teams.join.success=Added %d player(s) to team %s: %s +commands.scoreboard.teams.join.failure=Could not add %d player(s) to team %s: %s +commands.scoreboard.teams.leave.usage=/scoreboard teams leave [player] +commands.scoreboard.teams.leave.success=Removed %d player(s) from their teams: %s +commands.scoreboard.teams.leave.failure=Could not remove %d player(s) from their teams: %s +commands.scoreboard.teams.leave.noTeam=You are not in a team +commands.scoreboard.teams.option.usage=/scoreboard teams option +commands.scoreboard.teams.option.noValue=Valid values for option %s are: %s +commands.scoreboard.teams.option.success=Set option %s for team %s to %s +commands.gamemode.success.self=Set own game mode to %s +commands.gamemode.success.other=Set %s's game mode to %s +commands.gamemode.usage=/gamemode [player] +commands.defaultgamemode.usage=/defaultgamemode +commands.defaultgamemode.success=The world's default game mode is now %s +commands.me.usage=/me +commands.help.header=--- Showing help page %d of %d (/help ) --- +commands.help.footer=Tip: Use the key while typing a command to auto-complete the command or its arguments +commands.help.usage=/help [page|command name] +commands.publish.usage=/publish +commands.publish.started=Local game hosted on port %s +commands.publish.failed=Unable to host local game +commands.debug.start=Started debug profiling +commands.debug.stop=Stopped debug profiling after %.2f seconds (%d ticks) +commands.debug.notStarted=Can't stop profiling when we haven't started yet! +commands.debug.usage=/debug +commands.tellraw.usage=/tellraw +commands.tellraw.jsonException=Invalid json: %s +commands.message.usage=/tell +commands.message.sameTarget=You can't send a private message to yourself! +commands.message.display.outgoing=You whisper to %s: %s +commands.message.display.incoming=%s whispers to you: %s +commands.difficulty.usage=/difficulty +commands.difficulty.success=Set game difficulty to %s +commands.spawnpoint.usage=/spawnpoint OR /spawnpoint OR /spawnpoint +commands.spawnpoint.success=Set %s's spawn point to (%d, %d, %d) +commands.setworldspawn.usage=/setworldspawn OR /setworldspawn +commands.setworldspawn.success=Set the world spawn point to (%d, %d, %d) +commands.gamerule.usage=/gamerule OR /gamerule +commands.gamerule.success=Game rule has been updated +commands.gamerule.norule=No game rule called '%s' is available +commands.weather.usage=/weather [duration in seconds] +commands.weather.clear=Changing to clear weather +commands.weather.rain=Changing to rainy weather +commands.weather.thunder=Changing to rain and thunder +commands.testfor.usage=/testfor +commands.testfor.failed=/testfor is only usable by commandblocks with analog output +commands.seed.usage=/seed +commands.seed.success=Seed: %s +commands.spreadplayers.usage=/spreadplayers +commands.spreadplayers.spreading.teams=Spreading %s teams %s blocks around %s,%s (min %s blocks apart) +commands.spreadplayers.spreading.players=Spreading %s players %s blocks around %s,%s (min %s blocks apart) +commands.spreadplayers.success.teams=Successfully spread %s teams around %s,%s +commands.spreadplayers.success.players=Successfully spread %s players around %s,%s +commands.spreadplayers.info.teams=(Average distance between teams is %s blocks apart after %s iterations) +commands.spreadplayers.info.players=(Average distance between players is %s blocks apart after %s iterations) +commands.spreadplayers.failure.teams=Could not spread %s teams around %s,%s (too many players for space - try using spread of at most %s) +commands.spreadplayers.failure.players=Could not spread %s players around %s,%s (too many players for space - try using spread of at most %s) +commands.achievement.usage=/achievement give [player] +commands.achievement.unknownAchievement=Unknown achievement or statistic '%s' +commands.achievement.give.success.all=Successfully given all achievements to %s +commands.achievement.give.success.one=Successfully given %s the stat %s +commands.achievement.statTooLow=Player %s does not have the stat %s + +itemGroup.buildingBlocks=Building Blocks +itemGroup.decorations=Decoration Blocks +itemGroup.redstone=Redstone +itemGroup.transportation=Transportation +itemGroup.misc=Miscellaneous +itemGroup.search=Search Items +itemGroup.food=Foodstuffs +itemGroup.tools=Tools +itemGroup.combat=Combat +itemGroup.brewing=Brewing +itemGroup.materials=Materials +itemGroup.inventory=Survival Inventory + +inventory.binSlot=Destroy Item + +advMode.setCommand=Set Console Command for Block +advMode.setCommand.success=Command set: %s +advMode.command=Console Command +advMode.nearestPlayer=Use "@p" to target nearest player +advMode.randomPlayer=Use "@r" to target random player +advMode.allPlayers=Use "@a" to target all players +advMode.previousOutput=Previous Output + +advMode.notEnabled=Command blocks are not enabled on this server +advMode.notAllowed=Must be an opped player in creative mode + +mco.title=Minecraft Realms +mount.onboard=Press %1$s to dismount + +mco.terms.buttons.agree=Agree +mco.terms.buttons.disagree=Don't Agree +mco.terms.title=Realms Terms of Service +mco.terms.sentence.1=I agree to Minecraft Realms +mco.terms.sentence.2=Terms of Service + +mco.buy.realms.title=Buy a Realm +mco.buy.realms.buy=I want one! + +mco.selectServer.play=Play +mco.selectServer.configure=Configure +mco.selectServer.leave=Leave Realm +mco.selectServer.create=Create Realm +mco.selectServer.buy=Buy Realm +mco.selectServer.moreinfo=More Info + +mco.selectServer.expired=Expired Server +mco.selectServer.open=Open Server +mco.selectServer.closed=Closed Server +mco.selectServer.locked=Locked Server + +mco.selectServer.expires.days=Expires in %s days +mco.selectServer.expires.day=Expires in a day +mco.selectServer.expires.soon=Expires soon + +mco.configure.world.edit.title=Edit Realm + +mco.configure.world.title=Configure Realm +mco.configure.world.name=Name +mco.configure.world.description=Description +mco.configure.world.location=Location +mco.configure.world.invited=Invited +mco.configure.world.buttons.edit=Edit +mco.configure.world.buttons.reset=Reset Realm +mco.configure.world.buttons.done=Done +mco.configure.world.buttons.delete=Delete +mco.configure.world.buttons.open=Open Realm +mco.configure.world.buttons.close=Close Realm +mco.configure.world.buttons.invite=Invite +mco.configure.world.buttons.uninvite=Uninvite +mco.configure.world.buttons.backup=Backups +mco.configure.world.buttons.subscription=Subscription +mco.configure.world.invite.profile.name=Name +mco.configure.world.uninvite.question=Are you sure that you want to uninvite +mco.configure.world.status=Status + +mco.configure.world.subscription.title=Subscription Info +mco.configure.world.subscription.daysleft=Days Left +mco.configure.world.subscription.start=Start Date +mco.configure.world.subscription.extend=Extend Subscription + +mco.create.world.location.title=Locations +mco.create.world.location.warning=You may not get the exact location you select +mco.create.world.wait=Creating the realm... +mco.create.world.seed=Seed (Optional) + +mco.reset.world.title=Reset Realm +mco.reset.world.warning=This will permanently delete your realm! +mco.reset.world.seed=Seed (Optional) +mco.reset.world.resetting.screen.title=Resetting Realm... + +mco.configure.world.close.question.line1=Your realm will become unavailable. +mco.configure.world.close.question.line2=Are you sure you want to do that? + +mco.configure.world.leave.question.line1=If you leave this realm you won't see it unless invited again +mco.configure.world.leave.question.line2=Are you sure you want to do that? + +mco.configure.world.reset.question.line1=Your realm will be regenerated and your current realm will be lost +mco.configure.world.reset.question.line2=Are you sure you want to do that? + +mco.configure.world.restore.question.line1=Your realm will be restored to date +mco.configure.world.restore.question.line2=Are you sure you want to do that? + +mco.configure.world.restore.download.question.line1=You will be redirected to your default browser to download your world map. +mco.configure.world.restore.download.question.line2=Do you want to continue? + +mco.more.info.question.line1=You will be redirected to your default browser to see the page. +mco.more.info.question.line2=Do you want to continue? + +mco.connect.connecting=Connecting to the online server... +mco.connect.authorizing=Logging in... +mco.connect.failed=Failed to connect to the online server + +mco.create.world=Create + +mco.client.outdated.title=Client Outdated! +mco.client.outdated.msg=Your client is outdated, please consider updating it to use Realms + +mco.backup.title=Backups +mco.backup.button.restore=Restore +mco.backup.restoring=Restoring your realm +mco.backup.button.download=Download Latest + +mco.template.title=Realm Templates +mco.template.button.select=Select +mco.template.default.name=Select Template (Optional) +mco.template.name=Template + +mco.invites.button.accept=Accept +mco.invites.button.reject=Reject +mco.invites.title=Pending Invitations +mco.invites.pending=New invitations! +mco.invites.nopending=No pending invitations! + +build.tooHigh=Height limit for building is %s blocks + +attribute.modifier.plus.0=+%d %s +attribute.modifier.plus.1=+%d%% %s +attribute.modifier.plus.2=+%d%% %s +attribute.modifier.take.0=-%d %s +attribute.modifier.take.1=-%d%% %s +attribute.modifier.take.2=-%d%% %s + +attribute.name.horse.jumpStrength=Horse Jump Strength +attribute.name.zombie.spawnReinforcements=Zombie Reinforcements +attribute.name.generic.maxHealth=Max Health +attribute.name.generic.followRange=Mob Follow Range +attribute.name.generic.knockbackResistance=Knockback Resistance +attribute.name.generic.movementSpeed=Speed +attribute.name.generic.attackDamage=Attack Damage + +screenshot.success=Saved screenshot as %s +screenshot.failure=Couldn't save screenshot: %s diff --git a/src/main/resources/assets/minecraft/shaders/post/antialias.json b/src/main/resources/assets/minecraft/shaders/post/antialias.json new file mode 100644 index 0000000..bc31af3 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/post/antialias.json @@ -0,0 +1,17 @@ +{ + "targets": [ + "swap" + ], + "passes": [ + { + "name": "antialias", + "intarget": "minecraft:main", + "outtarget": "swap" + }, + { + "name": "blit", + "intarget": "swap", + "outtarget": "minecraft:main" + } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/post/art.json b/src/main/resources/assets/minecraft/shaders/post/art.json new file mode 100644 index 0000000..6d6c7ec --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/post/art.json @@ -0,0 +1,64 @@ +{ + "targets": [ + "0", + "1" + ], + "passes": [ + { + "name": "blobs2", + "intarget": "minecraft:main", + "outtarget": "0" + }, + { + "name": "outline_watercolor", + "intarget": "0", + "outtarget": "minecraft:main" + }, + { + "name": "blur", + "intarget": "minecraft:main", + "outtarget": "1", + "uniforms": [ + { + "name": "BlurDir", + "values": [ 0.8, 0.0 ] + }, + { + "name": "Radius", + "values": [ 20.0 ] + } + ] + }, + { + "name": "blur", + "intarget": "1", + "outtarget": "minecraft:main", + "uniforms": [ + { + "name": "BlurDir", + "values": [ 0.0, 0.8 ] + }, + { + "name": "Radius", + "values": [ 20.0 ] + } + ] + }, + { + "name": "outline_combine", + "intarget": "0", + "outtarget": "1", + "auxtargets": [ + { + "name": "OutlineSampler", + "id": "minecraft:main" + } + ] + }, + { + "name": "blit", + "intarget": "1", + "outtarget": "minecraft:main" + } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/post/bits.json b/src/main/resources/assets/minecraft/shaders/post/bits.json new file mode 100644 index 0000000..7236746 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/post/bits.json @@ -0,0 +1,17 @@ +{ + "targets": [ + "swap" + ], + "passes": [ + { + "name": "bits", + "intarget": "minecraft:main", + "outtarget": "swap" + }, + { + "name": "blit", + "intarget": "swap", + "outtarget": "minecraft:main" + } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/post/blobs.json b/src/main/resources/assets/minecraft/shaders/post/blobs.json new file mode 100644 index 0000000..d6260aa --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/post/blobs.json @@ -0,0 +1,17 @@ +{ + "targets": [ + "swap" + ], + "passes": [ + { + "name": "blobs", + "intarget": "minecraft:main", + "outtarget": "swap" + }, + { + "name": "blit", + "intarget": "swap", + "outtarget": "minecraft:main" + } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/post/blobs2.json b/src/main/resources/assets/minecraft/shaders/post/blobs2.json new file mode 100644 index 0000000..3464ae3 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/post/blobs2.json @@ -0,0 +1,17 @@ +{ + "targets": [ + "swap" + ], + "passes": [ + { + "name": "blobs2", + "intarget": "minecraft:main", + "outtarget": "swap" + }, + { + "name": "blit", + "intarget": "swap", + "outtarget": "minecraft:main" + } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/post/blur.json b/src/main/resources/assets/minecraft/shaders/post/blur.json new file mode 100644 index 0000000..bca04d5 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/post/blur.json @@ -0,0 +1,37 @@ +{ + "targets": [ + "swap" + ], + "passes": [ + { + "name": "blur", + "intarget": "minecraft:main", + "outtarget": "swap", + "uniforms": [ + { + "name": "BlurDir", + "values": [ 1.0, 0.0 ] + }, + { + "name": "Radius", + "values": [ 20.0 ] + } + ] + }, + { + "name": "blur", + "intarget": "swap", + "outtarget": "minecraft:main", + "uniforms": [ + { + "name": "BlurDir", + "values": [ 0.0, 1.0 ] + }, + { + "name": "Radius", + "values": [ 20.0 ] + } + ] + } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/post/bumpy.json b/src/main/resources/assets/minecraft/shaders/post/bumpy.json new file mode 100644 index 0000000..0870985 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/post/bumpy.json @@ -0,0 +1,17 @@ +{ + "targets": [ + "swap" + ], + "passes": [ + { + "name": "bumpy", + "intarget": "minecraft:main", + "outtarget": "swap" + }, + { + "name": "blit", + "intarget": "swap", + "outtarget": "minecraft:main" + } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/post/color_convolve.json b/src/main/resources/assets/minecraft/shaders/post/color_convolve.json new file mode 100644 index 0000000..9f00212 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/post/color_convolve.json @@ -0,0 +1,20 @@ +{ + "targets": [ + "swap" + ], + "passes": [ + { + "name": "color_convolve", + "intarget": "minecraft:main", + "outtarget": "swap", + "uniforms": [ + { "name": "Saturation", "values": [ 1.4 ] } + ] + }, + { + "name": "blit", + "intarget": "swap", + "outtarget": "minecraft:main" + } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/post/deconverge.json b/src/main/resources/assets/minecraft/shaders/post/deconverge.json new file mode 100644 index 0000000..4eb2b8d --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/post/deconverge.json @@ -0,0 +1,17 @@ +{ + "targets": [ + "swap" + ], + "passes": [ + { + "name": "deconverge", + "intarget": "minecraft:main", + "outtarget": "swap" + }, + { + "name": "blit", + "intarget": "swap", + "outtarget": "minecraft:main" + } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/post/desaturate.json b/src/main/resources/assets/minecraft/shaders/post/desaturate.json new file mode 100644 index 0000000..675018f --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/post/desaturate.json @@ -0,0 +1,23 @@ +{ + "targets": [ + "swap" + ], + "passes": [ + { + "name": "color_convolve", + "intarget": "minecraft:main", + "outtarget": "swap", + "uniforms": [ + { + "name": "Saturation", + "values": [ 0.2 ] + } + ] + }, + { + "name": "blit", + "intarget": "swap", + "outtarget": "minecraft:main" + } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/post/flip.json b/src/main/resources/assets/minecraft/shaders/post/flip.json new file mode 100644 index 0000000..e382435 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/post/flip.json @@ -0,0 +1,17 @@ +{ + "targets": [ + "swap" + ], + "passes": [ + { + "name": "flip", + "intarget": "minecraft:main", + "outtarget": "swap" + }, + { + "name": "blit", + "intarget": "swap", + "outtarget": "minecraft:main" + } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/post/fxaa.json b/src/main/resources/assets/minecraft/shaders/post/fxaa.json new file mode 100644 index 0000000..83292b7 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/post/fxaa.json @@ -0,0 +1,17 @@ +{ + "targets": [ + "swap" + ], + "passes": [ + { + "name": "fxaa", + "intarget": "minecraft:main", + "outtarget": "swap" + }, + { + "name": "blit", + "intarget": "swap", + "outtarget": "minecraft:main" + } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/post/green.json b/src/main/resources/assets/minecraft/shaders/post/green.json new file mode 100644 index 0000000..5d0af6c --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/post/green.json @@ -0,0 +1,41 @@ +{ + "targets": [ + "swap" + ], + "passes": [ + { + "name": "color_convolve", + "intarget": "minecraft:main", + "outtarget": "swap", + "uniforms": [ + { + "name": "RedMatrix", + "values": [ 0.0, 0.0, 0.0 ] + }, + { + "name": "GreenMatrix", + "values": [ 0.3, 0.59, 0.11 ] + }, + { + "name": "BlueMatrix", + "values": [ 0.0, 0.0, 0.0 ] + } + ] + }, + { + "name": "bits", + "intarget": "swap", + "outtarget": "minecraft:main" + }, + { + "name": "scan_pincushion", + "intarget": "minecraft:main", + "outtarget": "swap" + }, + { + "name": "blit", + "intarget": "swap", + "outtarget": "minecraft:main" + } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/post/invert.json b/src/main/resources/assets/minecraft/shaders/post/invert.json new file mode 100644 index 0000000..2ab63fb --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/post/invert.json @@ -0,0 +1,23 @@ +{ + "targets": [ + "swap" + ], + "passes": [ + { + "name": "invert", + "intarget": "minecraft:main", + "outtarget": "swap", + "uniforms": [ + { + "name": "InverseAmount", + "values": [ 0.8 ] + } + ] + }, + { + "name": "blit", + "intarget": "swap", + "outtarget": "minecraft:main" + } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/post/ntsc.json b/src/main/resources/assets/minecraft/shaders/post/ntsc.json new file mode 100644 index 0000000..abc005b --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/post/ntsc.json @@ -0,0 +1,92 @@ +{ + "targets": [ + "swap", + "swap2", + "previous" + ], + "passes": [ + { + "name": "ntsc_encode", + "intarget": "minecraft:main", + "outtarget": "swap" + }, + { + "name": "ntsc_decode", + "intarget": "swap", + "outtarget": "swap2", + "auxtargets": [ + { + "name": "BaseSampler", + "id": "minecraft:main" + } + ] + }, + { + "name": "color_convolve", + "intarget": "swap2", + "outtarget": "swap" + }, + { + "name": "deconverge", + "intarget": "swap", + "outtarget": "minecraft:main" + }, + { + "name": "blur", + "intarget": "minecraft:main", + "outtarget": "swap", + "uniforms": [ + { + "name": "BlurDir", + "values": [ 1.0, 0.0 ] + }, + { + "name": "Radius", + "values": [ 10.0 ] + } + ] + }, + { + "name": "blur", + "intarget": "swap", + "outtarget": "minecraft:main", + "uniforms": [ + { + "name": "BlurDir", + "values": [ 0.0, 1.0 ] + }, + { + "name": "Radius", + "values": [ 10.0 ] + } + ] + }, + { + "name": "scan_pincushion", + "intarget": "minecraft:main", + "outtarget": "swap" + }, + { + "name": "phosphor", + "intarget": "swap", + "outtarget": "minecraft:main", + "auxtargets": [ + { + "name": "PrevSampler", + "id": "previous" + } + ], + "uniforms": [ + { + "name": "Phosphor", + "values": [ 0.4, 0.4, 0.4 ] + } + ] + }, + { + "name": "blit", + "intarget": "minecraft:main", + "outtarget": "previous" + } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/post/outline.json b/src/main/resources/assets/minecraft/shaders/post/outline.json new file mode 100644 index 0000000..e299c0f --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/post/outline.json @@ -0,0 +1,17 @@ +{ + "targets": [ + "swap" + ], + "passes": [ + { + "name": "outline", + "intarget": "minecraft:main", + "outtarget": "swap" + }, + { + "name": "blit", + "intarget": "swap", + "outtarget": "minecraft:main" + } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/post/pencil.json b/src/main/resources/assets/minecraft/shaders/post/pencil.json new file mode 100644 index 0000000..1fc5b13 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/post/pencil.json @@ -0,0 +1,17 @@ +{ + "targets": [ + "swap" + ], + "passes": [ + { + "name": "outline_soft", + "intarget": "minecraft:main", + "outtarget": "swap" + }, + { + "name": "blit", + "intarget": "swap", + "outtarget": "minecraft:main" + } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/post/phosphor.json b/src/main/resources/assets/minecraft/shaders/post/phosphor.json new file mode 100644 index 0000000..0fa09c4 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/post/phosphor.json @@ -0,0 +1,35 @@ +{ + "targets": [ + "swap", + "previous" + ], + "passes": [ + { + "name": "phosphor", + "intarget": "minecraft:main", + "outtarget": "swap", + "auxtargets": [ + { + "name": "PrevSampler", + "id": "previous" + } + ], + "uniforms": [ + { + "name": "Phosphor", + "values": [ 0.95, 0.95, 0.95 ] + } + ] + }, + { + "name": "blit", + "intarget": "swap", + "outtarget": "previous" + }, + { + "name": "blit", + "intarget": "swap", + "outtarget": "minecraft:main" + } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/post/scan_pincushion.json b/src/main/resources/assets/minecraft/shaders/post/scan_pincushion.json new file mode 100644 index 0000000..b5d0a3e --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/post/scan_pincushion.json @@ -0,0 +1,17 @@ +{ + "targets": [ + "swap" + ], + "passes": [ + { + "name": "scan_pincushion", + "intarget": "minecraft:main", + "outtarget": "swap" + }, + { + "name": "blit", + "intarget": "swap", + "outtarget": "minecraft:main" + } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/post/sobel.json b/src/main/resources/assets/minecraft/shaders/post/sobel.json new file mode 100644 index 0000000..5c390a4 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/post/sobel.json @@ -0,0 +1,17 @@ +{ + "targets": [ + "swap" + ], + "passes": [ + { + "name": "sobel", + "intarget": "minecraft:main", + "outtarget": "swap" + }, + { + "name": "blit", + "intarget": "swap", + "outtarget": "minecraft:main" + } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/post/wobble.json b/src/main/resources/assets/minecraft/shaders/post/wobble.json new file mode 100644 index 0000000..1fc4534 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/post/wobble.json @@ -0,0 +1,17 @@ +{ + "targets": [ + "swap" + ], + "passes": [ + { + "name": "wobble", + "intarget": "minecraft:main", + "outtarget": "swap" + }, + { + "name": "blit", + "intarget": "swap", + "outtarget": "minecraft:main" + } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/program/antialias.fsh b/src/main/resources/assets/minecraft/shaders/program/antialias.fsh new file mode 100644 index 0000000..44b4141 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/antialias.fsh @@ -0,0 +1,29 @@ +#version 120 + +uniform sampler2D DiffuseSampler; + +varying vec2 texCoord; +varying vec2 oneTexel; + +void main(){ + vec4 c = texture2D (DiffuseSampler, texCoord); + vec4 u1 = texture2D (DiffuseSampler, texCoord + vec2 ( 0.0, -oneTexel.y )); + vec4 u2 = texture2D (DiffuseSampler, texCoord + vec2 ( 0.0, -oneTexel.y * 2.0)); + vec4 d1 = texture2D (DiffuseSampler, texCoord + vec2 ( 0.0, oneTexel.y )); + vec4 d2 = texture2D (DiffuseSampler, texCoord + vec2 ( 0.0, oneTexel.y * 2.0)); + vec4 l1 = texture2D (DiffuseSampler, texCoord + vec2 (-oneTexel.x, 0.0)); + vec4 l2 = texture2D (DiffuseSampler, texCoord + vec2 (-oneTexel.x * 2.0, 0.0)); + vec4 r1 = texture2D (DiffuseSampler, texCoord + vec2 ( oneTexel.x, 0.0)); + vec4 r2 = texture2D (DiffuseSampler, texCoord + vec2 ( oneTexel.x * 2.0, 0.0)); + + vec4 v1 = mix (c, mix (l1, l2, 0.667), 0.75); + vec4 v2 = mix (c, mix (r1, r2, 0.667), 0.75); + vec4 v3 = mix (c, mix (u1, u2, 0.667), 0.75); + vec4 v4 = mix (c, mix (d1, d2, 0.667), 0.75); + + vec4 v5 = mix (v1, v2, 0.5); + vec4 v6 = mix (v3, v4, 0.5); + + vec4 color = mix (v5, v6, 0.5); + gl_FragColor = vec4(color.rgb, c.a); +} diff --git a/src/main/resources/assets/minecraft/shaders/program/antialias.json b/src/main/resources/assets/minecraft/shaders/program/antialias.json new file mode 100644 index 0000000..6916fd9 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/antialias.json @@ -0,0 +1,18 @@ +{ + "blend": { + "func": "add", + "srcrgb": "one", + "dstrgb": "zero" + }, + "vertex": "blobs", + "fragment": "antialias", + "attributes": [ "Position" ], + "samplers": [ + { "name": "DiffuseSampler" } + ], + "uniforms": [ + { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, + { "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/program/bits.fsh b/src/main/resources/assets/minecraft/shaders/program/bits.fsh new file mode 100644 index 0000000..96ef3cb --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/bits.fsh @@ -0,0 +1,26 @@ +#version 120 + +uniform sampler2D DiffuseSampler; + +varying vec2 texCoord; +varying vec2 oneTexel; + +uniform vec2 InSize; + +uniform float Resolution = 4.0; +uniform float Saturation = 1.5; +uniform float MosaicSize = 8.0; + +void main() { + vec2 mosaicInSize = InSize / MosaicSize; + vec2 fractPix = fract(texCoord * mosaicInSize) / mosaicInSize; + + vec4 baseTexel = texture2D(DiffuseSampler, texCoord - fractPix); + + baseTexel = baseTexel - fract(baseTexel * Resolution) / Resolution; + float luma = dot(baseTexel.rgb, vec3(0.3, 0.59, 0.11)); + vec3 chroma = (baseTexel.rgb - luma) * Saturation; + baseTexel = vec4(luma + chroma, baseTexel.a); + + gl_FragColor = baseTexel; +} diff --git a/src/main/resources/assets/minecraft/shaders/program/bits.json b/src/main/resources/assets/minecraft/shaders/program/bits.json new file mode 100644 index 0000000..c19239b --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/bits.json @@ -0,0 +1,21 @@ +{ + "blend": { + "func": "add", + "srcrgb": "one", + "dstrgb": "zero" + }, + "vertex": "sobel", + "fragment": "bits", + "attributes": [ "Position" ], + "samplers": [ + { "name": "DiffuseSampler" } + ], + "uniforms": [ + { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, + { "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "Resolution", "type": "float", "count": 1, "values": [ 4.0 ] }, + { "name": "Saturation", "type": "float", "count": 1, "values": [ 1.5 ] }, + { "name": "MosaicSize", "type": "float", "count": 1, "values": [ 8.0 ] } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/program/blit.fsh b/src/main/resources/assets/minecraft/shaders/program/blit.fsh new file mode 100644 index 0000000..a0d5e79 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/blit.fsh @@ -0,0 +1,9 @@ +#version 120 + +uniform sampler2D DiffuseSampler; + +varying vec2 texCoord; + +void main(){ + gl_FragColor = texture2D(DiffuseSampler, texCoord); +} diff --git a/src/main/resources/assets/minecraft/shaders/program/blit.json b/src/main/resources/assets/minecraft/shaders/program/blit.json new file mode 100644 index 0000000..a61043e --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/blit.json @@ -0,0 +1,17 @@ +{ + "blend": { + "func": "add", + "srcrgb": "one", + "dstrgb": "zero" + }, + "vertex": "blit", + "fragment": "blit", + "attributes": [ "Position" ], + "samplers": [ + { "name": "DiffuseSampler" } + ], + "uniforms": [ + { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, + { "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/program/blit.vsh b/src/main/resources/assets/minecraft/shaders/program/blit.vsh new file mode 100644 index 0000000..01a16db --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/blit.vsh @@ -0,0 +1,16 @@ +#version 120 + +attribute vec4 Position; + +uniform mat4 ProjMat; +uniform vec2 OutSize; + +varying vec2 texCoord; + +void main(){ + vec4 outPos = ProjMat * vec4(Position.xy, 0.0, 1.0); + gl_Position = vec4(outPos.xy, 0.2, 1.0); + + texCoord = Position.xy / OutSize; + texCoord.y = 1.0 - texCoord.y; +} diff --git a/src/main/resources/assets/minecraft/shaders/program/blobs.fsh b/src/main/resources/assets/minecraft/shaders/program/blobs.fsh new file mode 100644 index 0000000..82a1cc7 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/blobs.fsh @@ -0,0 +1,43 @@ +#version 120 + +uniform sampler2D DiffuseSampler; + +varying vec2 texCoord; +varying vec2 oneTexel; + +void main(){ + vec4 u = texture2D(DiffuseSampler, texCoord + vec2( 0.0, -oneTexel.y)); + vec4 d = texture2D(DiffuseSampler, texCoord + vec2( 0.0, oneTexel.y)); + vec4 l = texture2D(DiffuseSampler, texCoord + vec2(-oneTexel.x, 0.0)); + vec4 r = texture2D(DiffuseSampler, texCoord + vec2( oneTexel.x, 0.0)); + + vec4 v1 = min(l, r); + vec4 v2 = min(u, d); + vec4 v3 = min(v1, v2); + + vec4 ul = texture2D(DiffuseSampler, texCoord + vec2(-oneTexel.x, -oneTexel.y)); + vec4 dr = texture2D(DiffuseSampler, texCoord + vec2( oneTexel.x, oneTexel.y)); + vec4 dl = texture2D(DiffuseSampler, texCoord + vec2(-oneTexel.x, oneTexel.y)); + vec4 ur = texture2D(DiffuseSampler, texCoord + vec2( oneTexel.x, -oneTexel.y)); + + vec4 v4 = min(ul, dr); + vec4 v5 = min(ur, dl); + vec4 v6 = min(v4, v5); + + vec4 v7 = min(v3, v6); + + vec4 uu = texture2D(DiffuseSampler, texCoord + vec2( 0.0, -oneTexel.y * 2.0)); + vec4 dd = texture2D(DiffuseSampler, texCoord + vec2( 0.0, oneTexel.y * 2.0)); + vec4 ll = texture2D(DiffuseSampler, texCoord + vec2(-oneTexel.x * 2.0, 0.0)); + vec4 rr = texture2D(DiffuseSampler, texCoord + vec2( oneTexel.x * 2.0, 0.0)); + + vec4 v8 = min(uu, dd); + vec4 v9 = min(ll, rr); + vec4 v10 = min(v8, v9); + + vec4 v11 = min(v7, v10); + + vec4 c = texture2D(DiffuseSampler, texCoord); + vec4 color = min(c, v11); + gl_FragColor = vec4(color.rgb, c.a); +} diff --git a/src/main/resources/assets/minecraft/shaders/program/blobs.json b/src/main/resources/assets/minecraft/shaders/program/blobs.json new file mode 100644 index 0000000..6a5f245 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/blobs.json @@ -0,0 +1,18 @@ +{ + "blend": { + "func": "add", + "srcrgb": "one", + "dstrgb": "zero" + }, + "vertex": "blobs", + "fragment": "blobs", + "attributes": [ "Position" ], + "samplers": [ + { "name": "DiffuseSampler" } + ], + "uniforms": [ + { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, + { "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/program/blobs.vsh b/src/main/resources/assets/minecraft/shaders/program/blobs.vsh new file mode 100644 index 0000000..3ece274 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/blobs.vsh @@ -0,0 +1,17 @@ +#version 120 + +attribute vec4 Position; + +uniform mat4 ProjMat; +uniform vec2 InSize; + +varying vec2 texCoord; +varying vec2 oneTexel; + +void main(){ + vec4 outPos = ProjMat * vec4(Position.xy, 0.0, 1.0); + gl_Position = vec4(outPos.xy, 0.2, 1.0); + + oneTexel = 1.0 / InSize; + texCoord = outPos.xy * 0.5 + 0.5; +} diff --git a/src/main/resources/assets/minecraft/shaders/program/blobs2.fsh b/src/main/resources/assets/minecraft/shaders/program/blobs2.fsh new file mode 100644 index 0000000..1fb217d --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/blobs2.fsh @@ -0,0 +1,30 @@ +#version 120 + +uniform sampler2D DiffuseSampler; + +varying vec2 texCoord; +varying vec2 oneTexel; + +uniform float Radius; + +void main(){ + vec4 c = texture2D(DiffuseSampler, texCoord); + vec4 maxVal = c; + for(float u = 0.0; u <= Radius; u += 1.0) { + for(float v = 0.0; v <= Radius; v += 1.0) { + float weight = (((sqrt(u * u + v * v) / (Radius)) > 1.0) ? 0.0 : 1.0); + + vec4 s0 = texture2D(DiffuseSampler, texCoord + vec2(-u * oneTexel.x, -v * oneTexel.y)); + vec4 s1 = texture2D(DiffuseSampler, texCoord + vec2( u * oneTexel.x, v * oneTexel.y)); + vec4 s2 = texture2D(DiffuseSampler, texCoord + vec2(-u * oneTexel.x, v * oneTexel.y)); + vec4 s3 = texture2D(DiffuseSampler, texCoord + vec2( u * oneTexel.x, -v * oneTexel.y)); + + vec4 o0 = max(s0, s1); + vec4 o1 = max(s2, s3); + vec4 tempMax = max(o0, o1); + maxVal = mix(maxVal, max(maxVal, tempMax), weight); + } + } + + gl_FragColor = vec4(maxVal.rgb, c.a); +} diff --git a/src/main/resources/assets/minecraft/shaders/program/blobs2.json b/src/main/resources/assets/minecraft/shaders/program/blobs2.json new file mode 100644 index 0000000..6df4594 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/blobs2.json @@ -0,0 +1,18 @@ +{ + "blend": { + "func": "add", + "srcrgb": "one", + "dstrgb": "zero" + }, + "vertex": "blobs", + "fragment": "blobs2", + "attributes": [ "Position" ], + "samplers": [ + { "name": "DiffuseSampler" } + ], + "uniforms": [ + { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, + { "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "Radius", "type": "float", "count": 1, "values": [ 7.0 ] } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/program/bloom.json b/src/main/resources/assets/minecraft/shaders/program/bloom.json new file mode 100644 index 0000000..4dd764f --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/bloom.json @@ -0,0 +1,19 @@ +{ + "blend": { + "func": "add", + "srcrgb": "one", + "dstrgb": "zero" + }, + "vertex": "sobel", + "fragment": "phosphor", + "attributes": [ "Position" ], + "samplers": [ + { "name": "DiffuseSampler" }, + { "name": "CycleSampler" } + ], + "uniforms": [ + { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, + { "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/program/blur.fsh b/src/main/resources/assets/minecraft/shaders/program/blur.fsh new file mode 100644 index 0000000..1178391 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/blur.fsh @@ -0,0 +1,23 @@ +#version 120 + +uniform sampler2D DiffuseSampler; + +varying vec2 texCoord; +varying vec2 oneTexel; + +uniform vec2 InSize; + +uniform vec2 BlurDir; +uniform float Radius; + +void main() { + vec4 blurred = vec4(0.0); + float totalStrength = 0.0; + for(float r = -Radius; r <= Radius; r += 1.0) { + float strength = abs(1.0 - r / Radius); + strength = strength * strength; + totalStrength = totalStrength + strength; + blurred = blurred + texture2D(DiffuseSampler, texCoord + oneTexel * r * BlurDir) * strength; + } + gl_FragColor = vec4(blurred.rgb / totalStrength, texture2D(DiffuseSampler, texCoord).a); +} diff --git a/src/main/resources/assets/minecraft/shaders/program/blur.json b/src/main/resources/assets/minecraft/shaders/program/blur.json new file mode 100644 index 0000000..51a2323 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/blur.json @@ -0,0 +1,20 @@ +{ + "blend": { + "func": "add", + "srcrgb": "one", + "dstrgb": "zero" + }, + "vertex": "sobel", + "fragment": "blur", + "attributes": [ "Position" ], + "samplers": [ + { "name": "DiffuseSampler" } + ], + "uniforms": [ + { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, + { "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "BlurDir", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "Radius", "type": "float", "count": 1, "values": [ 5.0 ] } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/program/bumpy.fsh b/src/main/resources/assets/minecraft/shaders/program/bumpy.fsh new file mode 100644 index 0000000..56fd5a9 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/bumpy.fsh @@ -0,0 +1,34 @@ +#version 120 + +uniform sampler2D DiffuseSampler; + +varying vec2 texCoord; +varying vec2 oneTexel; + +void main(){ + vec4 c = texture2D(DiffuseSampler, texCoord); + vec4 u = texture2D(DiffuseSampler, texCoord + vec2( 0.0, -oneTexel.y)); + vec4 d = texture2D(DiffuseSampler, texCoord + vec2( 0.0, oneTexel.y)); + vec4 l = texture2D(DiffuseSampler, texCoord + vec2(-oneTexel.x, 0.0)); + vec4 r = texture2D(DiffuseSampler, texCoord + vec2( oneTexel.x, 0.0)); + + vec4 nc = normalize(c); + vec4 nu = normalize(u); + vec4 nd = normalize(d); + vec4 nl = normalize(l); + vec4 nr = normalize(r); + + float du = dot(nc, nu); + float dd = dot(nc, nd); + float dl = dot(nc, nl); + float dr = dot(nc, nr); + + float i = 64.0; + + float f = 1.0; + f += (du * i) - (dd * i); + f += (dr * i) - (dl * i); + + vec4 color = c * clamp(f, 0.5, 2); + gl_FragColor = vec4(color.rgb, c.a); +} diff --git a/src/main/resources/assets/minecraft/shaders/program/bumpy.json b/src/main/resources/assets/minecraft/shaders/program/bumpy.json new file mode 100644 index 0000000..59cae19 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/bumpy.json @@ -0,0 +1,18 @@ +{ + "blend": { + "func": "add", + "srcrgb": "one", + "dstrgb": "zero" + }, + "vertex": "bumpy", + "fragment": "bumpy", + "attributes": [ "Position" ], + "samplers": [ + { "name": "DiffuseSampler" } + ], + "uniforms": [ + { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, + { "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/program/bumpy.vsh b/src/main/resources/assets/minecraft/shaders/program/bumpy.vsh new file mode 100644 index 0000000..3ece274 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/bumpy.vsh @@ -0,0 +1,17 @@ +#version 120 + +attribute vec4 Position; + +uniform mat4 ProjMat; +uniform vec2 InSize; + +varying vec2 texCoord; +varying vec2 oneTexel; + +void main(){ + vec4 outPos = ProjMat * vec4(Position.xy, 0.0, 1.0); + gl_Position = vec4(outPos.xy, 0.2, 1.0); + + oneTexel = 1.0 / InSize; + texCoord = outPos.xy * 0.5 + 0.5; +} diff --git a/src/main/resources/assets/minecraft/shaders/program/color_convolve.fsh b/src/main/resources/assets/minecraft/shaders/program/color_convolve.fsh new file mode 100644 index 0000000..bfc3de5 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/color_convolve.fsh @@ -0,0 +1,36 @@ +#version 120 + +uniform sampler2D DiffuseSampler; + +varying vec2 texCoord; +varying vec2 oneTexel; + +uniform vec2 InSize; + +uniform vec3 Gray = vec3(0.3, 0.59, 0.11); +uniform vec3 RedMatrix = vec3(1.0, 0.0, 0.0); +uniform vec3 GreenMatrix = vec3(0.0, 1.0, 0.0); +uniform vec3 BlueMatrix = vec3(0.0, 0.0, 1.0); +uniform vec3 Offset = vec3(0.0, 0.0, 0.0); +uniform vec3 ColorScale = vec3(1.0, 1.0, 1.0); +uniform float Saturation = 1.8; + +void main() { + vec4 InTexel = texture2D(DiffuseSampler, texCoord); + + // Color Matrix + float RedValue = dot(InTexel.rgb, RedMatrix); + float GreenValue = dot(InTexel.rgb, GreenMatrix); + float BlueValue = dot(InTexel.rgb, BlueMatrix); + vec3 OutColor = vec3(RedValue, GreenValue, BlueValue); + + // Offset & Scale + OutColor = (OutColor * ColorScale) + Offset; + + // Saturation + float Luma = dot(OutColor, Gray); + vec3 Chroma = OutColor - Luma; + OutColor = (Chroma * Saturation) + Luma; + + gl_FragColor = vec4(OutColor, InTexel.a); +} diff --git a/src/main/resources/assets/minecraft/shaders/program/color_convolve.json b/src/main/resources/assets/minecraft/shaders/program/color_convolve.json new file mode 100644 index 0000000..e3a32c2 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/color_convolve.json @@ -0,0 +1,25 @@ +{ + "blend": { + "func": "add", + "srcrgb": "one", + "dstrgb": "zero" + }, + "vertex": "sobel", + "fragment": "color_convolve", + "attributes": [ "Position" ], + "samplers": [ + { "name": "DiffuseSampler" } + ], + "uniforms": [ + { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, + { "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "Gray", "type": "float", "count": 3, "values": [ 0.3, 0.59, 0.11 ] }, + { "name": "RedMatrix", "type": "float", "count": 3, "values": [ 1.0, 0.0, 0.0 ] }, + { "name": "GreenMatrix", "type": "float", "count": 3, "values": [ 0.0, 1.0, 0.0 ] }, + { "name": "BlueMatrix", "type": "float", "count": 3, "values": [ 0.0, 0.0, 1.0 ] }, + { "name": "Offset", "type": "float", "count": 3, "values": [ 0.0, 0.0, 0.0 ] }, + { "name": "ColorScale", "type": "float", "count": 3, "values": [ 1.0, 1.0, 1.0 ] }, + { "name": "Saturation", "type": "float", "count": 1, "values": [ 1.8 ] } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/program/deconverge.fsh b/src/main/resources/assets/minecraft/shaders/program/deconverge.fsh new file mode 100644 index 0000000..6b5a207 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/deconverge.fsh @@ -0,0 +1,28 @@ +#version 120 + +uniform sampler2D DiffuseSampler; + +varying vec2 texCoord; +varying vec2 oneTexel; + +uniform vec2 InSize; + +uniform vec3 ConvergeX = vec3(-1.0, 0.0, 0.5); +uniform vec3 ConvergeY = vec3( 0.0, -1.0, 0.5); +uniform vec3 RadialConvergeX = vec3(1.0, 1.0, 1.0); +uniform vec3 RadialConvergeY = vec3(1.0, 1.0, 1.0); + +void main() { + vec3 CoordX = texCoord.x * RadialConvergeX; + vec3 CoordY = texCoord.y * RadialConvergeY; + + CoordX += ConvergeX * oneTexel.x - (RadialConvergeX - 1.0) * 0.5; + CoordY += ConvergeY * oneTexel.y - (RadialConvergeY - 1.0) * 0.5; + + float RedValue = texture2D(DiffuseSampler, vec2(CoordX.x, CoordY.x)).r; + float GreenValue = texture2D(DiffuseSampler, vec2(CoordX.y, CoordY.y)).g; + float BlueValue = texture2D(DiffuseSampler, vec2(CoordX.z, CoordY.z)).b; + float AlphaValue = texture2D(DiffuseSampler, texCoord).a; + + gl_FragColor = vec4(RedValue, GreenValue, BlueValue, AlphaValue); +} diff --git a/src/main/resources/assets/minecraft/shaders/program/deconverge.json b/src/main/resources/assets/minecraft/shaders/program/deconverge.json new file mode 100644 index 0000000..e23e9c5 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/deconverge.json @@ -0,0 +1,22 @@ +{ + "blend": { + "func": "add", + "srcrgb": "one", + "dstrgb": "zero" + }, + "vertex": "sobel", + "fragment": "deconverge", + "attributes": [ "Position" ], + "samplers": [ + { "name": "DiffuseSampler" } + ], + "uniforms": [ + { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, + { "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "ConvergeX", "type": "float", "count": 3, "values": [ -4.0, 0.0, 2.0 ] }, + { "name": "ConvergeY", "type": "float", "count": 3, "values": [ 0.0, -4.0, 2.0 ] }, + { "name": "RadialConvergeX", "type": "float", "count": 3, "values": [ 1.0, 1.0, 1.0 ] }, + { "name": "RadialConvergeY", "type": "float", "count": 3, "values": [ 1.0, 1.0, 1.0 ] } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/program/downscale.fsh b/src/main/resources/assets/minecraft/shaders/program/downscale.fsh new file mode 100644 index 0000000..5502444 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/downscale.fsh @@ -0,0 +1,17 @@ +#version 120 + +uniform sampler2D DiffuseSampler; + +varying vec2 texCoord; +varying vec2 oneTexel; + +uniform vec2 InSize; + +void main() { + vec3 Texel0 = texture2D(DiffuseSampler, texCoord).rgb; + vec3 Texel1 = texture2D(DiffuseSampler, texCoord + vec2(oneTexel.x, 0.0)).rgb; + vec3 Texel2 = texture2D(DiffuseSampler, texCoord + vec2(0.0, oneTexel.y)).rgb; + vec3 Texel3 = texture2D(DiffuseSampler, texCoord + oneTexel).rgb; + + gl_FragColor = vec4((Texel0 + Texel1 + Texel2 + Texel3) * 0.25, Texel0.a); +} diff --git a/src/main/resources/assets/minecraft/shaders/program/downscale.json b/src/main/resources/assets/minecraft/shaders/program/downscale.json new file mode 100644 index 0000000..9099ec1 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/downscale.json @@ -0,0 +1,18 @@ +{ + "blend": { + "func": "add", + "srcrgb": "one", + "dstrgb": "zero" + }, + "vertex": "downscale", + "fragment": "downscale", + "attributes": [ "Position" ], + "samplers": [ + { "name": "DiffuseSampler" } + ], + "uniforms": [ + { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, + { "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/program/downscale.vsh b/src/main/resources/assets/minecraft/shaders/program/downscale.vsh new file mode 100644 index 0000000..ec09759 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/downscale.vsh @@ -0,0 +1,19 @@ +#version 120 + +attribute vec4 Position; + +uniform mat4 ProjMat; +uniform vec2 InSize; +uniform vec2 OutSize; + +varying vec2 texCoord; +varying vec2 oneTexel; + +void main(){ + vec4 outPos = ProjMat * vec4(Position.xy, 0.0, 1.0); + gl_Position = vec4(outPos.xy, 0.2, 1.0); + + oneTexel = 1.0 / InSize; + texCoord = outPos.xy * 0.5 + 0.5; + texCoord.y = 1.0 - texCoord.y; +} diff --git a/src/main/resources/assets/minecraft/shaders/program/flip.json b/src/main/resources/assets/minecraft/shaders/program/flip.json new file mode 100644 index 0000000..de87ed0 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/flip.json @@ -0,0 +1,19 @@ +{ + "blend": { + "func": "add", + "srcrgb": "one", + "dstrgb": "zero" + }, + "vertex": "flip", + "fragment": "blit", + "attributes": [ "Position" ], + "samplers": [ + { "name": "DiffuseSampler" } + ], + "uniforms": [ + { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, + { "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "ScreenSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/program/flip.vsh b/src/main/resources/assets/minecraft/shaders/program/flip.vsh new file mode 100644 index 0000000..bd0a4d3 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/flip.vsh @@ -0,0 +1,22 @@ +#version 120 + +attribute vec4 Position; + +uniform mat4 ProjMat; +uniform vec2 InSize; +uniform vec2 OutSize; +uniform vec2 ScreenSize; + +varying vec2 texCoord; + +void main(){ + vec4 outPos = ProjMat * vec4(Position.xy, 0.0, 1.0); + gl_Position = vec4(outPos.xy, 0.2, 1.0); + + vec2 inOutRatio = OutSize / InSize; + vec2 inScreenRatio = ScreenSize / InSize; + texCoord = Position.xy / OutSize; + texCoord.x = texCoord.x * inOutRatio.x; + texCoord.y = texCoord.y * inOutRatio.y; + texCoord.y -= 1.0 - inScreenRatio.y; +} diff --git a/src/main/resources/assets/minecraft/shaders/program/fxaa.fsh b/src/main/resources/assets/minecraft/shaders/program/fxaa.fsh new file mode 100644 index 0000000..6fd9f80 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/fxaa.fsh @@ -0,0 +1,84 @@ +#extension GL_EXT_gpu_shader4 : enable + +uniform sampler2D DiffuseSampler; +uniform vec2 OutSize; + +uniform float VxOffset; +uniform float SpanMax; +uniform float ReduceMul; + +varying vec2 texCoord; +varying vec4 posPos; + +#define FxaaTex(t, p) texture2D(t, p) + +#if __VERSION__ >= 130 + #define OffsetVec(a, b) ivec2(a, b) + #define FxaaTexOff(t, p, o, r) textureOffset(t, p, o) +#elif defined(GL_EXT_gpu_shader4) + #define OffsetVec(a, b) ivec2(a, b) + #define FxaaTexOff(t, p, o, r) texture2DLodOffset(t, p, 0.0, o) +#else + #define OffsetVec(a, b) vec2(a, b) + #define FxaaTexOff(t, p, o, r) texture2D(t, p + o * r) +#endif + +vec3 FxaaPixelShader( + vec4 posPos, // Output of FxaaVertexShader interpolated across screen. + sampler2D tex, // Input texture. + vec2 rcpFrame) // Constant {1.0/frameWidth, 1.0/frameHeight}. +{ + + #define FXAA_REDUCE_MIN (1.0/128.0) + //#define FXAA_REDUCE_MUL (1.0/8.0) + //#define FXAA_SPAN_MAX 8.0 + + vec3 rgbNW = FxaaTex(tex, posPos.zw).xyz; + vec3 rgbNE = FxaaTexOff(tex, posPos.zw, OffsetVec(1,0), rcpFrame.xy).xyz; + vec3 rgbSW = FxaaTexOff(tex, posPos.zw, OffsetVec(0,1), rcpFrame.xy).xyz; + vec3 rgbSE = FxaaTexOff(tex, posPos.zw, OffsetVec(1,1), rcpFrame.xy).xyz; + + vec3 rgbM = FxaaTex(tex, posPos.xy).xyz; + + vec3 luma = vec3(0.299, 0.587, 0.114); + float lumaNW = dot(rgbNW, luma); + float lumaNE = dot(rgbNE, luma); + float lumaSW = dot(rgbSW, luma); + float lumaSE = dot(rgbSE, luma); + float lumaM = dot(rgbM, luma); + + float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE))); + float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE))); + + vec2 dir; + dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE)); + dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE)); + + float dirReduce = max( + (lumaNW + lumaNE + lumaSW + lumaSE) * (0.25 * ReduceMul), + FXAA_REDUCE_MIN); + float rcpDirMin = 1.0/(min(abs(dir.x), abs(dir.y)) + dirReduce); + dir = min(vec2( SpanMax, SpanMax), + max(vec2(-SpanMax, -SpanMax), + dir * rcpDirMin)) * rcpFrame.xy; + + vec3 rgbA = (1.0/2.0) * ( + FxaaTex(tex, posPos.xy + dir * vec2(1.0/3.0 - 0.5)).xyz + + FxaaTex(tex, posPos.xy + dir * vec2(2.0/3.0 - 0.5)).xyz); + vec3 rgbB = rgbA * (1.0/2.0) + (1.0/4.0) * ( + FxaaTex(tex, posPos.xy + dir * vec2(0.0/3.0 - 0.5)).xyz + + FxaaTex(tex, posPos.xy + dir * vec2(3.0/3.0 - 0.5)).xyz); + + float lumaB = dot(rgbB, luma); + + if ((lumaB < lumaMin) || (lumaB > lumaMax)) { + return rgbA; + } else { + return rgbB; + } +} + +void main() { + vec4 baseTexel = texture2D(DiffuseSampler, posPos.xy); + gl_FragColor = vec4(FxaaPixelShader(posPos, DiffuseSampler, 1.0 / OutSize), baseTexel.a); +} diff --git a/src/main/resources/assets/minecraft/shaders/program/fxaa.json b/src/main/resources/assets/minecraft/shaders/program/fxaa.json new file mode 100644 index 0000000..eb85073 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/fxaa.json @@ -0,0 +1,20 @@ +{ + "blend": { + "func": "add", + "srcrgb": "one", + "dstrgb": "zero" + }, + "vertex": "fxaa", + "fragment": "fxaa", + "attributes": [ "Position" ], + "samplers": [ + { "name": "DiffuseSampler" } + ], + "uniforms": [ + { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, + { "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "SpanMax", "type": "float", "count": 1, "values": [ 8.0 ] }, + { "name": "SubPixelShift", "type": "float", "count": 1, "values": [ 0.25 ] }, + { "name": "ReduceMul", "type": "float", "count": 1, "values": [ 0.125 ] } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/program/fxaa.vsh b/src/main/resources/assets/minecraft/shaders/program/fxaa.vsh new file mode 100644 index 0000000..9fe81ea --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/fxaa.vsh @@ -0,0 +1,21 @@ +#version 120 + +attribute vec4 Position; + +uniform mat4 ProjMat; +uniform vec2 OutSize; + +uniform float SubPixelShift; + +varying vec2 texCoord; +varying vec4 posPos; + +void main() { + vec4 outPos = ProjMat * vec4(Position.xy, 0.0, 1.0); + gl_Position = vec4(outPos.xy, 0.2, 1.0); + + texCoord = Position.xy / OutSize; + texCoord.y = 1.0 - texCoord.y; + posPos.xy = texCoord.xy; + posPos.zw = texCoord.xy - (1.0/OutSize * vec2(0.5 + SubPixelShift)); +} diff --git a/src/main/resources/assets/minecraft/shaders/program/invert.fsh b/src/main/resources/assets/minecraft/shaders/program/invert.fsh new file mode 100644 index 0000000..ab2b43b --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/invert.fsh @@ -0,0 +1,14 @@ +#version 120 + +uniform sampler2D DiffuseSampler; + +varying vec2 texCoord; + +uniform float InverseAmount; + +void main(){ + vec4 diffuseColor = texture2D(DiffuseSampler, texCoord); + vec4 invertColor = 1.0 - diffuseColor; + vec4 outColor = mix(diffuseColor, invertColor, InverseAmount); + gl_FragColor = vec4(outColor.rgb, diffuseColor.a); +} diff --git a/src/main/resources/assets/minecraft/shaders/program/invert.json b/src/main/resources/assets/minecraft/shaders/program/invert.json new file mode 100644 index 0000000..f9ab649 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/invert.json @@ -0,0 +1,19 @@ +{ + "blend": { + "func": "add", + "srcrgb": "one", + "dstrgb": "zero" + }, + "vertex": "blit", + "fragment": "invert", + "attributes": [ "Position" ], + "samplers": [ + { "name": "DiffuseSampler" } + ], + "uniforms": [ + { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, + { "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "InverseAmount", "type": "float", "count": 1, "values": [ 0.0 ] } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/program/invert.vsh b/src/main/resources/assets/minecraft/shaders/program/invert.vsh new file mode 100644 index 0000000..5110ef5 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/invert.vsh @@ -0,0 +1,20 @@ +#version 120 + +attribute vec4 Position; + +uniform mat4 ProjMat; +uniform vec2 InSize; +uniform vec2 OutSize; + +varying vec2 texCoord; + +void main(){ + vec4 outPos = ProjMat * vec4(Position.xy, 0.0, 1.0); + gl_Position = vec4(outPos.xy, 0.2, 1.0); + + vec2 sizeRatio = OutSize / InSize; + texCoord = Position.xy / OutSize; + texCoord.x = texCoord.x * sizeRatio.x; + texCoord.y = texCoord.y * sizeRatio.y; + texCoord.y = sizeRatio.y - texCoord.y; +} diff --git a/src/main/resources/assets/minecraft/shaders/program/ntsc_decode.fsh b/src/main/resources/assets/minecraft/shaders/program/ntsc_decode.fsh new file mode 100644 index 0000000..57d3dd5 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/ntsc_decode.fsh @@ -0,0 +1,132 @@ +#version 120 + +uniform sampler2D DiffuseSampler; +uniform sampler2D BaseSampler; + +varying vec2 texCoord; +varying vec2 oneTexel; + +uniform vec2 InSize; + +const vec4 Zero = vec4(0.0); +const vec4 One = vec4(1.0); + +const float Pi = 3.1415926535; +const float Pi2 = 6.283185307; + +const vec4 A2 = vec4(1.0); +const vec4 B = vec4(0.5); +const float P = 1.0; +const float CCFrequency = 3.59754545; +const float NotchWidth = 2.0; +const float NotchUpperFrequency = 3.59754545 + NotchWidth; +const float NotchLowerFrequency = 3.59754545 - NotchWidth; +const float YFrequency = 6.0; +const float IFrequency = 1.2; +const float QFrequency = 0.6; +const float ScanTime = 52.6; +const vec3 YIQ2R = vec3(1.0, 0.956, 0.621); +const vec3 YIQ2G = vec3(1.0, -0.272, -0.647); +const vec3 YIQ2B = vec3(1.0, -1.106, 1.703); +const vec4 MinC = vec4(-1.1183); +const vec4 CRange = vec4(3.2366); +const float Pi2Length = Pi2 / 83.0; +const vec4 NotchOffset = vec4(0.0, 1.0, 2.0, 3.0); +const vec4 W = vec4(Pi2 * CCFrequency * ScanTime); + +void main() { + vec4 YAccum = Zero; + vec4 IAccum = Zero; + vec4 QAccum = Zero; + float QuadXSize = InSize.x * 4.0; + float TimePerSample = ScanTime / QuadXSize; + + // Frequency cutoffs for the individual portions of the signal that we extract. + // Y1 and Y2 are the positive and negative frequency limits of the notch filter on Y. + // Y3 is the center of the frequency response of the Y filter. + // I is the center of the frequency response of the I filter. + // Q is the center of the frequency response of the Q filter. + float Fc_y1 = NotchLowerFrequency * TimePerSample; + float Fc_y2 = NotchUpperFrequency * TimePerSample; + float Fc_y3 = YFrequency * TimePerSample; + float Fc_i = IFrequency * TimePerSample; + float Fc_q = QFrequency * TimePerSample; + float Pi2Fc_y1 = Fc_y1 * Pi2; + float Pi2Fc_y2 = Fc_y2 * Pi2; + float Pi2Fc_y3 = Fc_y3 * Pi2; + float Pi2Fc_i = Fc_i * Pi2; + float Pi2Fc_q = Fc_q * Pi2; + float Fc_y1_2 = Fc_y1 * 2.0; + float Fc_y2_2 = Fc_y2 * 2.0; + float Fc_y3_2 = Fc_y3 * 2.0; + float Fc_i_2 = Fc_i * 2.0; + float Fc_q_2 = Fc_q * 2.0; + vec4 CoordY = vec4(texCoord.y); + + vec4 BaseTexel = texture2D(DiffuseSampler, texCoord); + // 83 composite samples wide, 4 composite pixels per texel + for (float n = -41.0; n < 42.0; n += 4.0) + { + vec4 n4 = n + NotchOffset; + vec4 CoordX = texCoord.x + oneTexel.x * n4 * 0.25; + vec2 TexCoord = vec2(CoordX.x, CoordY.y); + vec4 C = texture2D(DiffuseSampler, TexCoord) * CRange + MinC; + vec4 WT = W * (CoordX + A2 * CoordY * InSize.y + B); + vec4 Cosine = 0.54 + 0.46 * cos(Pi2Length * n4); + + vec4 SincYIn1 = Pi2Fc_y1 * n4; + vec4 SincYIn2 = Pi2Fc_y2 * n4; + vec4 SincYIn3 = Pi2Fc_y3 * n4; + vec4 SincY1 = sin(SincYIn1) / SincYIn1; + vec4 SincY2 = sin(SincYIn2) / SincYIn2; + vec4 SincY3 = sin(SincYIn3) / SincYIn3; + + // These zero-checks could be made more efficient, but we are trying to support + // downlevel GLSL + if(SincYIn1.x == 0.0) SincY1.x = 1.0; + if(SincYIn1.y == 0.0) SincY1.y = 1.0; + if(SincYIn1.z == 0.0) SincY1.z = 1.0; + if(SincYIn1.w == 0.0) SincY1.w = 1.0; + if(SincYIn2.x == 0.0) SincY2.x = 1.0; + if(SincYIn2.y == 0.0) SincY2.y = 1.0; + if(SincYIn2.z == 0.0) SincY2.z = 1.0; + if(SincYIn2.w == 0.0) SincY2.w = 1.0; + if(SincYIn3.x == 0.0) SincY3.x = 1.0; + if(SincYIn3.y == 0.0) SincY3.y = 1.0; + if(SincYIn3.z == 0.0) SincY3.z = 1.0; + if(SincYIn3.w == 0.0) SincY3.w = 1.0; + vec4 IdealY = (Fc_y1_2 * SincY1 - Fc_y2_2 * SincY2) + Fc_y3_2 * SincY3; + vec4 FilterY = Cosine * IdealY; + + vec4 SincIIn = Pi2Fc_i * n4; + vec4 SincI = sin(SincIIn) / SincIIn; + if(SincIIn.x == 0.0) SincI.x = 1.0; + if(SincIIn.y == 0.0) SincI.y = 1.0; + if(SincIIn.z == 0.0) SincI.z = 1.0; + if(SincIIn.w == 0.0) SincI.w = 1.0; + vec4 IdealI = Fc_i_2 * SincI; + vec4 FilterI = Cosine * IdealI; + + vec4 SincQIn = Pi2Fc_q * n4; + vec4 SincQ = sin(SincQIn) / SincQIn; + if(SincQIn.x == 0.0) SincQ.x = 1.0; + if(SincQIn.y == 0.0) SincQ.y = 1.0; + if(SincQIn.z == 0.0) SincQ.z = 1.0; + if(SincQIn.w == 0.0) SincQ.w = 1.0; + vec4 IdealQ = Fc_q_2 * SincQ; + vec4 FilterQ = Cosine * IdealQ; + + YAccum += C * FilterY; + IAccum += C * cos(WT) * FilterI; + QAccum += C * sin(WT) * FilterQ; + } + + float Y = dot(YAccum, One); + float I = dot(IAccum, One) * 2.0; + float Q = dot(QAccum, One) * 2.0; + + vec3 YIQ = vec3(Y, I, Q); + vec3 OutRGB = vec3(dot(YIQ, YIQ2R), dot(YIQ, YIQ2G), dot(YIQ, YIQ2B)); + + gl_FragColor = vec4(OutRGB, BaseTexel.a); +} diff --git a/src/main/resources/assets/minecraft/shaders/program/ntsc_decode.json b/src/main/resources/assets/minecraft/shaders/program/ntsc_decode.json new file mode 100644 index 0000000..2870923 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/ntsc_decode.json @@ -0,0 +1,19 @@ +{ + "blend": { + "func": "add", + "srcrgb": "one", + "dstrgb": "zero" + }, + "vertex": "sobel", + "fragment": "ntsc_decode", + "attributes": [ "Position" ], + "samplers": [ + { "name": "DiffuseSampler" }, + { "name": "BaseSampler" } + ], + "uniforms": [ + { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, + { "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/program/ntsc_encode.fsh b/src/main/resources/assets/minecraft/shaders/program/ntsc_encode.fsh new file mode 100644 index 0000000..450bc6d --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/ntsc_encode.fsh @@ -0,0 +1,50 @@ +#version 120 + +uniform sampler2D DiffuseSampler; + +varying vec2 texCoord; +varying vec2 oneTexel; + +uniform vec2 InSize; + +const float Pi2 = 6.283185307; + +const vec4 A2 = vec4(1.0); +const vec4 B = vec4(0.5); +const float P = 1.0; +const float CCFrequency = 3.59754545; +const float ScanTime = 52.6; +const float Pi2ScanTime = Pi2 * ScanTime; +const vec4 YTransform = vec4(0.299, 0.587, 0.114, 0.0); +const vec4 ITransform = vec4(0.595716, -0.274453, -0.321263, 0.0); +const vec4 QTransform = vec4(0.211456, -0.522591, 0.31135, 0.0); +const vec4 MinC = vec4(-1.1183); +const vec4 InvCRange = vec4(1.0 / 3.2366); + +void main() { + vec2 InverseP = vec2(P, 0.0) * oneTexel; + + // UVs for four linearly-interpolated samples spread 0.25 texels apart + vec2 C0 = texCoord; + vec2 C1 = texCoord + InverseP * 0.25; + vec2 C2 = texCoord + InverseP * 0.50; + vec2 C3 = texCoord + InverseP * 0.75; + vec4 Cx = vec4(C0.x, C1.x, C2.x, C3.x); + vec4 Cy = vec4(C0.y, C1.y, C2.y, C3.y); + + vec4 Texel0 = texture2D(DiffuseSampler, C0); + vec4 Texel1 = texture2D(DiffuseSampler, C1); + vec4 Texel2 = texture2D(DiffuseSampler, C2); + vec4 Texel3 = texture2D(DiffuseSampler, C3); + + // Calculate the expected time of the sample. + vec4 T = A2 * Cy * vec4(InSize.y) + B + Cx; + vec4 W = vec4(Pi2ScanTime * CCFrequency); + vec4 TW = T * W; + vec4 Y = vec4(dot(Texel0, YTransform), dot(Texel1, YTransform), dot(Texel2, YTransform), dot(Texel3, YTransform)); + vec4 I = vec4(dot(Texel0, ITransform), dot(Texel1, ITransform), dot(Texel2, ITransform), dot(Texel3, ITransform)); + vec4 Q = vec4(dot(Texel0, QTransform), dot(Texel1, QTransform), dot(Texel2, QTransform), dot(Texel3, QTransform)); + + vec4 Encoded = Y + I * cos(TW) + Q * sin(TW); + gl_FragColor = (Encoded - MinC) * InvCRange; +} diff --git a/src/main/resources/assets/minecraft/shaders/program/ntsc_encode.json b/src/main/resources/assets/minecraft/shaders/program/ntsc_encode.json new file mode 100644 index 0000000..2cda4df --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/ntsc_encode.json @@ -0,0 +1,18 @@ +{ + "blend": { + "func": "add", + "srcrgb": "one", + "dstrgb": "zero" + }, + "vertex": "sobel", + "fragment": "ntsc_encode", + "attributes": [ "Position" ], + "samplers": [ + { "name": "DiffuseSampler" } + ], + "uniforms": [ + { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, + { "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/program/outline.fsh b/src/main/resources/assets/minecraft/shaders/program/outline.fsh new file mode 100644 index 0000000..6285820 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/outline.fsh @@ -0,0 +1,21 @@ +#version 120 + +uniform sampler2D DiffuseSampler; + +varying vec2 texCoord; +varying vec2 oneTexel; + +void main(){ + vec4 center = texture2D(DiffuseSampler, texCoord); + vec4 up = texture2D(DiffuseSampler, texCoord + vec2( 0.0, -oneTexel.y)); + vec4 down = texture2D(DiffuseSampler, texCoord + vec2( oneTexel.x, 0.0)); + vec4 left = texture2D(DiffuseSampler, texCoord + vec2(-oneTexel.x, 0.0)); + vec4 right = texture2D(DiffuseSampler, texCoord + vec2( 0.0, oneTexel.y)); + vec4 uDiff = center - up; + vec4 dDiff = center - down; + vec4 lDiff = center - left; + vec4 rDiff = center - right; + vec4 sum = uDiff + dDiff + lDiff + rDiff; + vec3 clamped = clamp(center.rgb - sum.rgb, 0.0, 1.0); + gl_FragColor = vec4(clamped, center.a); +} diff --git a/src/main/resources/assets/minecraft/shaders/program/outline.json b/src/main/resources/assets/minecraft/shaders/program/outline.json new file mode 100644 index 0000000..7d41382 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/outline.json @@ -0,0 +1,18 @@ +{ + "blend": { + "func": "add", + "srcrgb": "one", + "dstrgb": "zero" + }, + "vertex": "sobel", + "fragment": "outline", + "attributes": [ "Position" ], + "samplers": [ + { "name": "DiffuseSampler" } + ], + "uniforms": [ + { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, + { "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/program/outline_combine.fsh b/src/main/resources/assets/minecraft/shaders/program/outline_combine.fsh new file mode 100644 index 0000000..d4b7682 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/outline_combine.fsh @@ -0,0 +1,13 @@ +#version 120 + +uniform sampler2D DiffuseSampler; +uniform sampler2D OutlineSampler; + +varying vec2 texCoord; +varying vec2 oneTexel; + +void main(){ + vec4 diffuseTexel = texture2D(DiffuseSampler, texCoord); + vec4 outlineTexel = texture2D(OutlineSampler, texCoord); + gl_FragColor = vec4(diffuseTexel.rgb + diffuseTexel.rgb * outlineTexel.rgb * vec3(0.75), diffuseTexel.a); +} diff --git a/src/main/resources/assets/minecraft/shaders/program/outline_combine.json b/src/main/resources/assets/minecraft/shaders/program/outline_combine.json new file mode 100644 index 0000000..d52f4a3 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/outline_combine.json @@ -0,0 +1,19 @@ +{ + "blend": { + "func": "add", + "srcrgb": "one", + "dstrgb": "zero" + }, + "vertex": "sobel", + "fragment": "outline_combine", + "attributes": [ "Position" ], + "samplers": [ + { "name": "DiffuseSampler" }, + { "name": "OutlineSampler" } + ], + "uniforms": [ + { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, + { "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/program/outline_soft.fsh b/src/main/resources/assets/minecraft/shaders/program/outline_soft.fsh new file mode 100644 index 0000000..92031c1 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/outline_soft.fsh @@ -0,0 +1,46 @@ +#version 120 + +uniform sampler2D DiffuseSampler; + +varying vec2 texCoord; +varying vec2 oneTexel; + +uniform float LumaRamp; +uniform float LumaLevel; + +void main(){ + vec4 center = texture2D(DiffuseSampler, texCoord); + vec4 up = texture2D(DiffuseSampler, texCoord + vec2( 0.0, -oneTexel.y)); + vec4 up2 = texture2D(DiffuseSampler, texCoord + vec2( 0.0, -oneTexel.y) * 2.0); + vec4 down = texture2D(DiffuseSampler, texCoord + vec2( oneTexel.x, 0.0)); + vec4 down2 = texture2D(DiffuseSampler, texCoord + vec2( oneTexel.x, 0.0) * 2.0); + vec4 left = texture2D(DiffuseSampler, texCoord + vec2(-oneTexel.x, 0.0)); + vec4 left2 = texture2D(DiffuseSampler, texCoord + vec2(-oneTexel.x, 0.0) * 2.0); + vec4 right = texture2D(DiffuseSampler, texCoord + vec2( 0.0, oneTexel.y)); + vec4 right2 = texture2D(DiffuseSampler, texCoord + vec2( 0.0, oneTexel.y) * 2.0); + vec4 uDiff = abs(center - up); + vec4 dDiff = abs(center - down); + vec4 lDiff = abs(center - left); + vec4 rDiff = abs(center - right); + vec4 u2Diff = abs(center - up2); + vec4 d2Diff = abs(center - down2); + vec4 l2Diff = abs(center - left2); + vec4 r2Diff = abs(center - right2); + vec4 sum = uDiff + dDiff + lDiff + rDiff + u2Diff + d2Diff + l2Diff + r2Diff; + vec4 gray = vec4(0.3, 0.59, 0.11, 0.0); + float sumLuma = 1.0 - dot(clamp(sum, 0.0, 1.0), gray); + + // Get luminance of center pixel and adjust + float centerLuma = dot(center + (center - pow(center, vec4(LumaRamp))), gray); + + // Quantize the luma value + centerLuma = centerLuma - fract(centerLuma * LumaLevel) / LumaLevel; + + // Re-scale to full range + centerLuma = centerLuma * (LumaLevel / (LumaLevel - 1.0)); + + // Blend with outline + centerLuma = centerLuma * sumLuma; + + gl_FragColor = vec4(centerLuma, centerLuma, centerLuma, center.a); +} diff --git a/src/main/resources/assets/minecraft/shaders/program/outline_soft.json b/src/main/resources/assets/minecraft/shaders/program/outline_soft.json new file mode 100644 index 0000000..c58bb5d --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/outline_soft.json @@ -0,0 +1,20 @@ +{ + "blend": { + "func": "add", + "srcrgb": "one", + "dstrgb": "zero" + }, + "vertex": "sobel", + "fragment": "outline_soft", + "attributes": [ "Position" ], + "samplers": [ + { "name": "DiffuseSampler" } + ], + "uniforms": [ + { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, + { "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "LumaRamp", "type": "float", "count": 1, "values": [ 16.0 ] }, + { "name": "LumaLevel", "type": "float", "count": 1, "values": [ 4.0 ] } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/program/outline_watercolor.fsh b/src/main/resources/assets/minecraft/shaders/program/outline_watercolor.fsh new file mode 100644 index 0000000..b7d47d2 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/outline_watercolor.fsh @@ -0,0 +1,41 @@ +#version 120 + +uniform sampler2D DiffuseSampler; + +varying vec2 texCoord; +varying vec2 oneTexel; + +uniform float LumaRamp; + +void main(){ + vec4 center = texture2D(DiffuseSampler, texCoord); + vec4 up = texture2D(DiffuseSampler, texCoord + vec2( 0.0, -oneTexel.y)); + vec4 up2 = texture2D(DiffuseSampler, texCoord + vec2( 0.0, -oneTexel.y) * 2.0); + vec4 down = texture2D(DiffuseSampler, texCoord + vec2( oneTexel.x, 0.0)); + vec4 down2 = texture2D(DiffuseSampler, texCoord + vec2( oneTexel.x, 0.0) * 2.0); + vec4 left = texture2D(DiffuseSampler, texCoord + vec2(-oneTexel.x, 0.0)); + vec4 left2 = texture2D(DiffuseSampler, texCoord + vec2(-oneTexel.x, 0.0) * 2.0); + vec4 right = texture2D(DiffuseSampler, texCoord + vec2( 0.0, oneTexel.y)); + vec4 right2 = texture2D(DiffuseSampler, texCoord + vec2( 0.0, oneTexel.y) * 2.0); + vec4 ul = texture2D(DiffuseSampler, texCoord + vec2(-oneTexel.x, -oneTexel.y)); + vec4 ur = texture2D(DiffuseSampler, texCoord + vec2( oneTexel.x, -oneTexel.y)); + vec4 bl = texture2D(DiffuseSampler, texCoord + vec2(-oneTexel.x, oneTexel.y)); + vec4 br = texture2D(DiffuseSampler, texCoord + vec2( oneTexel.x, oneTexel.y)); + vec4 gray = vec4(0.3, 0.59, 0.11, 0.0); + float uDiff = dot(abs(center - up), gray); + float dDiff = dot(abs(center - down), gray); + float lDiff = dot(abs(center - left), gray); + float rDiff = dot(abs(center - right), gray); + float u2Diff = dot(abs(center - up2), gray); + float d2Diff = dot(abs(center - down2), gray); + float l2Diff = dot(abs(center - left2), gray); + float r2Diff = dot(abs(center - right2), gray); + float ulDiff = dot(abs(center - ul), gray); + float urDiff = dot(abs(center - ur), gray); + float blDiff = dot(abs(center - bl), gray); + float brDiff = dot(abs(center - br), gray); + float sum = uDiff + dDiff + lDiff + rDiff + u2Diff + d2Diff + l2Diff + r2Diff + ulDiff + urDiff + blDiff + brDiff; + float sumLuma = clamp(sum, 0.0, 1.0); + + gl_FragColor = vec4(sumLuma, sumLuma, sumLuma, center.a); +} diff --git a/src/main/resources/assets/minecraft/shaders/program/outline_watercolor.json b/src/main/resources/assets/minecraft/shaders/program/outline_watercolor.json new file mode 100644 index 0000000..2954352 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/outline_watercolor.json @@ -0,0 +1,19 @@ +{ + "blend": { + "func": "add", + "srcrgb": "one", + "dstrgb": "zero" + }, + "vertex": "sobel", + "fragment": "outline_watercolor", + "attributes": [ "Position" ], + "samplers": [ + { "name": "DiffuseSampler" } + ], + "uniforms": [ + { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, + { "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "LumaRamp", "type": "float", "count": 1, "values": [ 16.0 ] } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/program/overlay.fsh b/src/main/resources/assets/minecraft/shaders/program/overlay.fsh new file mode 100644 index 0000000..311d26d --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/overlay.fsh @@ -0,0 +1,26 @@ +#version 120 + +uniform sampler2D DiffuseSampler; +uniform sampler2D OverlaySampler; + +uniform vec2 InSize; + +varying vec2 texCoord; + +uniform float MosaicSize = 1.0; +uniform vec3 RedMatrix = vec3(1.0, 0.0, 0.0); +uniform vec3 GreenMatrix = vec3(0.0, 1.0, 0.0); +uniform vec3 BlueMatrix = vec3(0.0, 0.0, 1.0); + +void main(){ + vec2 mosaicInSize = InSize / MosaicSize; + vec2 fractPix = fract(texCoord * mosaicInSize) / mosaicInSize; + + vec4 baseTexel = texture2D(DiffuseSampler, texCoord - fractPix); + float red = dot(baseTexel.rgb, RedMatrix); + float green = dot(baseTexel.rgb, GreenMatrix); + float blue = dot(baseTexel.rgb, BlueMatrix); + + vec4 overlayTexel = texture2D(OverlaySampler, vec2(texCoord.x, 1.0 - texCoord.y)); + gl_FragColor = mix(vec4(red, green, blue, baseTexel.a), overlayTexel, overlayTexel.a); +} diff --git a/src/main/resources/assets/minecraft/shaders/program/overlay.json b/src/main/resources/assets/minecraft/shaders/program/overlay.json new file mode 100644 index 0000000..ceb8d0f --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/overlay.json @@ -0,0 +1,23 @@ +{ + "blend": { + "func": "add", + "srcrgb": "one", + "dstrgb": "zero" + }, + "vertex": "blit", + "fragment": "overlay", + "attributes": [ "Position" ], + "samplers": [ + { "name": "OverlaySampler" }, + { "name": "DiffuseSampler" } + ], + "uniforms": [ + { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, + { "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "MosaicSize", "type": "float", "count": 1, "values": [ 1.0 ] }, + { "name": "RedMatrix", "type": "float", "count": 3, "values": [ 1.0, 0.0, 0.0 ] }, + { "name": "GreenMatrix", "type": "float", "count": 3, "values": [ 0.0, 1.0, 1.0 ] }, + { "name": "BlueMatrix", "type": "float", "count": 3, "values": [ 0.0, 0.0, 1.0 ] } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/program/phosphor.fsh b/src/main/resources/assets/minecraft/shaders/program/phosphor.fsh new file mode 100644 index 0000000..7721436 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/phosphor.fsh @@ -0,0 +1,19 @@ +#version 120 + +uniform sampler2D DiffuseSampler; +uniform sampler2D PrevSampler; + +varying vec2 texCoord; +varying vec2 oneTexel; + +uniform vec2 InSize; + +uniform vec3 Phosphor = vec3(0.7, 0.7, 0.7); +uniform float LerpFactor = 1.0; + +void main() { + vec4 CurrTexel = texture2D(DiffuseSampler, texCoord); + vec4 PrevTexel = texture2D(PrevSampler, texCoord); + + gl_FragColor = vec4(max(PrevTexel.rgb * Phosphor, CurrTexel.rgb), CurrTexel.a); +} diff --git a/src/main/resources/assets/minecraft/shaders/program/phosphor.json b/src/main/resources/assets/minecraft/shaders/program/phosphor.json new file mode 100644 index 0000000..c3a01f2 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/phosphor.json @@ -0,0 +1,20 @@ +{ + "blend": { + "func": "add", + "srcrgb": "one", + "dstrgb": "zero" + }, + "vertex": "sobel", + "fragment": "phosphor", + "attributes": [ "Position" ], + "samplers": [ + { "name": "DiffuseSampler" }, + { "name": "PrevSampler" } + ], + "uniforms": [ + { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, + { "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "Phosphor", "type": "float", "count": 3, "values": [ 0.3, 0.3, 0.3 ] } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/program/scan_pincushion.fsh b/src/main/resources/assets/minecraft/shaders/program/scan_pincushion.fsh new file mode 100644 index 0000000..0911697 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/scan_pincushion.fsh @@ -0,0 +1,64 @@ +#version 120 + +uniform sampler2D DiffuseSampler; + +varying vec2 texCoord; +varying vec2 oneTexel; + +uniform vec2 InSize; + +const vec4 Zero = vec4(0.0); +const vec4 Half = vec4(0.5); +const vec4 One = vec4(1.0); +const vec4 Two = vec4(2.0); + +const float Pi = 3.1415926535; +const float PincushionAmount = 0.02; +const float CurvatureAmount = 0.02; +const float ScanlineAmount = 0.8; +const float ScanlineScale = 1.0; +const float ScanlineHeight = 1.0; +const float ScanlineBrightScale = 1.0; +const float ScanlineBrightOffset = 0.0; +const float ScanlineOffset = 0.0; +const vec3 Floor = vec3(0.05, 0.05, 0.05); +const vec3 Power = vec3(0.8, 0.8, 0.8); + +void main() { + vec4 InTexel = texture2D(DiffuseSampler, texCoord); + + vec2 PinUnitCoord = texCoord * Two.xy - One.xy; + float PincushionR2 = pow(length(PinUnitCoord), 2.0); + vec2 PincushionCurve = PinUnitCoord * PincushionAmount * PincushionR2; + vec2 ScanCoord = texCoord; + + ScanCoord *= One.xy - PincushionAmount * 0.2; + ScanCoord += PincushionAmount * 0.1; + ScanCoord += PincushionCurve; + + vec2 CurvatureClipCurve = PinUnitCoord * CurvatureAmount * PincushionR2; + vec2 ScreenClipCoord = texCoord; + ScreenClipCoord -= Half.xy; + ScreenClipCoord *= One.xy - CurvatureAmount * 0.2; + ScreenClipCoord += Half.xy; + ScreenClipCoord += CurvatureClipCurve; + + // -- Alpha Clipping -- + if (ScanCoord.x < 0.0) discard; + if (ScanCoord.y < 0.0) discard; + if (ScanCoord.x > 1.0) discard; + if (ScanCoord.y > 1.0) discard; + + // -- Scanline Simulation -- + float InnerSine = ScanCoord.y * InSize.y * ScanlineScale * 0.25; + float ScanBrightMod = sin(InnerSine * Pi + ScanlineOffset * InSize.y * 0.25); + float ScanBrightness = mix(1.0, (pow(ScanBrightMod * ScanBrightMod, ScanlineHeight) * ScanlineBrightScale + 1.0) * 0.5, ScanlineAmount); + vec3 ScanlineTexel = InTexel.rgb * ScanBrightness; + + // -- Color Compression (increasing the floor of the signal without affecting the ceiling) -- + ScanlineTexel = Floor + (One.xyz - Floor) * ScanlineTexel; + + ScanlineTexel.rgb = pow(ScanlineTexel.rgb, Power); + + gl_FragColor = vec4(ScanlineTexel.rgb, InTexel.a); +} diff --git a/src/main/resources/assets/minecraft/shaders/program/scan_pincushion.json b/src/main/resources/assets/minecraft/shaders/program/scan_pincushion.json new file mode 100644 index 0000000..9c7f9a3 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/scan_pincushion.json @@ -0,0 +1,18 @@ +{ + "blend": { + "func": "add", + "srcrgb": "one", + "dstrgb": "zero" + }, + "vertex": "sobel", + "fragment": "scan_pincushion", + "attributes": [ "Position" ], + "samplers": [ + { "name": "DiffuseSampler" } + ], + "uniforms": [ + { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, + { "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/program/sobel.fsh b/src/main/resources/assets/minecraft/shaders/program/sobel.fsh new file mode 100644 index 0000000..b17c769 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/sobel.fsh @@ -0,0 +1,20 @@ +#version 120 + +uniform sampler2D DiffuseSampler; + +varying vec2 texCoord; +varying vec2 oneTexel; + +void main(){ + vec4 center = texture2D(DiffuseSampler, texCoord); + vec4 left = texture2D(DiffuseSampler, texCoord - vec2(oneTexel.x, 0.0)); + vec4 right = texture2D(DiffuseSampler, texCoord + vec2(oneTexel.x, 0.0)); + vec4 up = texture2D(DiffuseSampler, texCoord - vec2(0.0, oneTexel.y)); + vec4 down = texture2D(DiffuseSampler, texCoord + vec2(0.0, oneTexel.y)); + vec4 leftDiff = center - left; + vec4 rightDiff = center - right; + vec4 upDiff = center - up; + vec4 downDiff = center - down; + vec4 total = clamp(leftDiff + rightDiff + upDiff + downDiff, 0.0, 1.0); + gl_FragColor = vec4(total.rgb, center.a); +} diff --git a/src/main/resources/assets/minecraft/shaders/program/sobel.json b/src/main/resources/assets/minecraft/shaders/program/sobel.json new file mode 100644 index 0000000..dc2fc17 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/sobel.json @@ -0,0 +1,18 @@ +{ + "blend": { + "func": "add", + "srcrgb": "one", + "dstrgb": "zero" + }, + "vertex": "sobel", + "fragment": "sobel", + "attributes": [ "Position" ], + "samplers": [ + { "name": "DiffuseSampler" } + ], + "uniforms": [ + { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, + { "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/program/sobel.vsh b/src/main/resources/assets/minecraft/shaders/program/sobel.vsh new file mode 100644 index 0000000..21b1736 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/sobel.vsh @@ -0,0 +1,20 @@ +#version 120 + +attribute vec4 Position; + +uniform mat4 ProjMat; +uniform vec2 InSize; +uniform vec2 OutSize; + +varying vec2 texCoord; +varying vec2 oneTexel; + +void main(){ + vec4 outPos = ProjMat * vec4(Position.xy, 0.0, 1.0); + gl_Position = vec4(outPos.xy, 0.2, 1.0); + + oneTexel = 1.0 / InSize; + + texCoord = Position.xy / OutSize; + texCoord.y = 1.0 - texCoord.y; +} diff --git a/src/main/resources/assets/minecraft/shaders/program/wobble.fsh b/src/main/resources/assets/minecraft/shaders/program/wobble.fsh new file mode 100644 index 0000000..a124319 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/wobble.fsh @@ -0,0 +1,58 @@ +#version 120 + +uniform sampler2D DiffuseSampler; + +varying vec2 texCoord; +varying vec2 oneTexel; + +uniform vec2 InSize; + +uniform float Time; +uniform vec2 Frequency; +uniform vec2 WobbleAmount; + +vec3 hue(float h) +{ + float r = abs(h * 6.0 - 3.0) - 1.0; + float g = 2 - abs(h * 6.0 - 2.0); + float b = 2 - abs(h * 6.0 - 4.0); + return clamp(vec3(r,g,b), 0.0, 1.0); +} + +vec3 HSVtoRGB(vec3 hsv) { + return ((hue(hsv.x) - 1.0) * hsv.y + 1.0) * hsv.z; +} + +vec3 RGBtoHSV(vec3 rgb) { + vec3 hsv = vec3(0.0); + hsv.z = max(rgb.r, max(rgb.g, rgb.b)); + float min = min(rgb.r, min(rgb.g, rgb.b)); + float c = hsv.z - min; + + if (c != 0) + { + hsv.y = c / hsv.z; + vec3 delta = (hsv.z - rgb) / c; + delta.rgb -= delta.brg; + delta.rg += vec2(2.0, 4.0); + if (rgb.r >= hsv.z) { + hsv.x = delta.b; + } else if (rgb.g >= hsv.z) { + hsv.x = delta.r; + } else { + hsv.x = delta.g; + } + hsv.x = fract(hsv.x / 6.0); + } + return hsv; +} + +void main() { + float xOffset = sin(texCoord.y * Frequency.x + Time * 3.1415926535 * 2.0) * WobbleAmount.x; + float yOffset = cos(texCoord.x * Frequency.y + Time * 3.1415926535 * 2.0) * WobbleAmount.y; + vec2 offset = vec2(xOffset, yOffset); + vec4 rgb = texture2D(DiffuseSampler, texCoord + offset); + vec3 hsv = RGBtoHSV(rgb.rgb); + hsv.x = fract(hsv.x + Time); + gl_FragColor = vec4(HSVtoRGB(hsv), rgb.a); +} diff --git a/src/main/resources/assets/minecraft/shaders/program/wobble.json b/src/main/resources/assets/minecraft/shaders/program/wobble.json new file mode 100644 index 0000000..d8e9945 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/program/wobble.json @@ -0,0 +1,21 @@ +{ + "blend": { + "func": "add", + "srcrgb": "one", + "dstrgb": "zero" + }, + "vertex": "sobel", + "fragment": "wobble", + "attributes": [ "Position" ], + "samplers": [ + { "name": "DiffuseSampler" } + ], + "uniforms": [ + { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, + { "name": "InSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] }, + { "name": "Time", "type": "float", "count": 1, "values": [ 0.0 ] }, + { "name": "Frequency", "type": "float", "count": 2, "values": [ 512.0, 288.0 ] }, + { "name": "WobbleAmount", "type": "float", "count": 2, "values": [ 0.002, 0.002 ] } + ] +} diff --git a/src/main/resources/assets/minecraft/texts/credits.txt b/src/main/resources/assets/minecraft/texts/credits.txt new file mode 100644 index 0000000..7396a16 --- /dev/null +++ b/src/main/resources/assets/minecraft/texts/credits.txt @@ -0,0 +1,66 @@ +[C]§f=============== +[C]§eMinecraft Credits +[C]§f=============== + +§7Created by: +§f Markus Persson + +§7Game design, programming and graphics: +§f Markus Persson +§f Jens Bergensten +§f Nathan Adams + +§7Programming: +§f Erik Broes + +§7Music and sound: +§f Daniel Rosenfeld + +§7Ingame artwork and paintings: +§f Kristoffer Zetterstrand + +§7End game narrative: +§f Julian Gough + +§7Website development: +§f Tobias Möllstam +§f Daniel Frisk +§f Leonard Axelsson +§f Jens Bergensten +§f Markus Persson + +§7Logo and promotional artwork: +§f Markus Toivonen + +§7Business and administration: +§f Carl Manneh +§f Daniel Kaplan + +§7Director of fun: +§f Lydia Winters + +§7Number crunching and statistics: +§f Patrick Geuder + +§7Additional programming: +§f Paul Spooner +§f Ryan 'Scaevolus' Hitchman +§f Elliot 'Hippoplatimus' Segal + +§7Developers of Mo' Creatures (horses etc): +§f John Olarte (DrZhark) +§f Kent Christian Jensen +§f Dan Roque + +§7Technologies used: +§f Java by Oracle +§f LWJGL by many talented people +§f "3d Sound System" by Paul Lamb +§f JOrbis by JCraft + + + + + + +§f"Twenty years from now you will be more disappointed by the things that you didn't do than by the ones you did do. So throw off the bowlines. Sail away from the safe harbor. Catch the trade winds in your sails. Explore. Dream. Discover." §7- Unknown \ No newline at end of file diff --git a/src/main/resources/assets/minecraft/texts/end.txt b/src/main/resources/assets/minecraft/texts/end.txt new file mode 100644 index 0000000..7277524 --- /dev/null +++ b/src/main/resources/assets/minecraft/texts/end.txt @@ -0,0 +1,151 @@ +§3I see the player you mean. + +§2PLAYERNAME? + +§3Yes. Take care. It has reached a higher level now. It can read our thoughts. + +§2That doesn't matter. It thinks we are part of the game. + +§3I like this player. It played well. It did not give up. + +§2It is reading our thoughts as though they were words on a screen. + +§3That is how it chooses to imagine many things, when it is deep in the dream of a game. + +§2Words make a wonderful interface. Very flexible. And less terrifying than staring at the reality behind the screen. + +§3They used to hear voices. Before players could read. Back in the days when those who did not play called the players witches, and warlocks. And players dreamed they flew through the air, on sticks powered by demons. + +§2What did this player dream? + +§3This player dreamed of sunlight and trees. Of fire and water. It dreamed it created. And it dreamed it destroyed. It dreamed it hunted, and was hunted. It dreamed of shelter. + +§2Hah, the original interface. A million years old, and it still works. But what true structure did this player create, in the reality behind the screen? + +§3It worked, with a million others, to sculpt a true world in a fold of the §f§k§a§b§3, and created a §f§k§a§b§3 for §f§k§a§b§3, in the §f§k§a§b§3. + +§2It cannot read that thought. + +§3No. It has not yet achieved the highest level. That, it must achieve in the long dream of life, not the short dream of a game. + +§2Does it know that we love it? That the universe is kind? + +§3Sometimes, through the noise of its thoughts, it hears the universe, yes. + +§2But there are times it is sad, in the long dream. It creates worlds that have no summer, and it shivers under a black sun, and it takes its sad creation for reality. + +§3To cure it of sorrow would destroy it. The sorrow is part of its own private task. We cannot interfere. + +§2Sometimes when they are deep in dreams, I want to tell them, they are building true worlds in reality. Sometimes I want to tell them of their importance to the universe. Sometimes, when they have not made a true connection in a while, I want to help them to speak the word they fear. + +§3It reads our thoughts. + +§2Sometimes I do not care. Sometimes I wish to tell them, this world you take for truth is merely §f§k§a§b§2 and §f§k§a§b§2, I wish to tell them that they are §f§k§a§b§2 in the §f§k§a§b§2. They see so little of reality, in their long dream. + +§3And yet they play the game. + +§2But it would be so easy to tell them... + +§3Too strong for this dream. To tell them how to live is to prevent them living. + +§2I will not tell the player how to live. + +§3The player is growing restless. + +§2I will tell the player a story. + +§3But not the truth. + +§2No. A story that contains the truth safely, in a cage of words. Not the naked truth that can burn over any distance. + +§3Give it a body, again. + +§2Yes. Player... + +§3Use its name. + +§2PLAYERNAME. Player of games. + +§3Good. + +§2Take a breath, now. Take another. Feel air in your lungs. Let your limbs return. Yes, move your fingers. Have a body again, under gravity, in air. Respawn in the long dream. There you are. Your body touching the universe again at every point, as though you were separate things. As though we were separate things. + +§3Who are we? Once we were called the spirit of the mountain. Father sun, mother moon. Ancestral spirits, animal spirits. Jinn. Ghosts. The green man. Then gods, demons. Angels. Poltergeists. Aliens, extraterrestrials. Leptons, quarks. The words change. We do not change. + +§2We are the universe. We are everything you think isn't you. You are looking at us now, through your skin and your eyes. And why does the universe touch your skin, and throw light on you? To see you, player. To know you. And to be known. I shall tell you a story. + +§2Once upon a time, there was a player. + +§3The player was you, PLAYERNAME. + +§2Sometimes it thought itself human, on the thin crust of a spinning globe of molten rock. The ball of molten rock circled a ball of blazing gas that was three hundred and thirty thousand times more massive than it. They were so far apart that light took eight minutes to cross the gap. The light was information from a star, and it could burn your skin from a hundred and fifty million kilometres away. + +§2Sometimes the player dreamed it was a miner, on the surface of a world that was flat, and infinite. The sun was a square of white. The days were short; there was much to do; and death was a temporary inconvenience. + +§3Sometimes the player dreamed it was lost in a story. + +§2Sometimes the player dreamed it was other things, in other places. Sometimes these dreams were disturbing. Sometimes very beautiful indeed. Sometimes the player woke from one dream into another, then woke from that into a third. + +§3Sometimes the player dreamed it watched words on a screen. + +§2Let's go back. + +§2The atoms of the player were scattered in the grass, in the rivers, in the air, in the ground. A woman gathered the atoms; she drank and ate and inhaled; and the woman assembled the player, in her body. + +§2And the player awoke, from the warm, dark world of its mother's body, into the long dream. + +§2And the player was a new story, never told before, written in letters of DNA. And the player was a new program, never run before, generated by a sourcecode a billion years old. And the player was a new human, never alive before, made from nothing but milk and love. + +§3You are the player. The story. The program. The human. Made from nothing but milk and love. + +§2Let's go further back. + +§2The seven billion billion billion atoms of the player's body were created, long before this game, in the heart of a star. So the player, too, is information from a star. And the player moves through a story, which is a forest of information planted by a man called Julian, on a flat, infinite world created by a man called Markus, that exists inside a small, private world created by the player, who inhabits a universe created by... + +§3Shush. Sometimes the player created a small, private world that was soft and warm and simple. Sometimes hard, and cold, and complicated. Sometimes it built a model of the universe in its head; flecks of energy, moving through vast empty spaces. Sometimes it called those flecks "electrons" and "protons". + +§2Sometimes it called them "planets" and "stars". + +§2Sometimes it believed it was in a universe that was made of energy that was made of offs and ons; zeros and ones; lines of code. Sometimes it believed it was playing a game. Sometimes it believed it was reading words on a screen. + +§3You are the player, reading words... + +§2Shush... Sometimes the player read lines of code on a screen. Decoded them into words; decoded words into meaning; decoded meaning into feelings, emotions, theories, ideas, and the player started to breathe faster and deeper and realised it was alive, it was alive, those thousand deaths had not been real, the player was alive + +§3You. You. You are alive. + +§2and sometimes the player believed the universe had spoken to it through the sunlight that came through the shuffling leaves of the summer trees + +§3and sometimes the player believed the universe had spoken to it through the light that fell from the crisp night sky of winter, where a fleck of light in the corner of the player's eye might be a star a million times as massive as the sun, boiling its planets to plasma in order to be visible for a moment to the player, walking home at the far side of the universe, suddenly smelling food, almost at the familiar door, about to dream again + +§2and sometimes the player believed the universe had spoken to it through the zeros and ones, through the electricity of the world, through the scrolling words on a screen at the end of a dream + +§3and the universe said I love you + +§2and the universe said you have played the game well + +§3and the universe said everything you need is within you + +§2and the universe said you are stronger than you know + +§3and the universe said you are the daylight + +§2and the universe said you are the night + +§3and the universe said the darkness you fight is within you + +§2and the universe said the light you seek is within you + +§3and the universe said you are not alone + +§2and the universe said you are not separate from every other thing + +§3and the universe said you are the universe tasting itself, talking to itself, reading its own code + +§2and the universe said I love you because you are love. + +§3And the game was over and the player woke up from the dream. And the player began a new dream. And the player dreamed again, dreamed better. And the player was the universe. And the player was love. + +§3You are the player. + +§2Wake up. diff --git a/src/main/resources/assets/minecraft/texts/splashes.txt b/src/main/resources/assets/minecraft/texts/splashes.txt new file mode 100644 index 0000000..bdb7557 --- /dev/null +++ b/src/main/resources/assets/minecraft/texts/splashes.txt @@ -0,0 +1,321 @@ +As seen on TV! +Awesome! +100% pure! +May contain nuts! +Better than Prey! +More polygons! +Sexy! +Limited edition! +Flashing letters! +Made by Notch! +It's here! +Best in class! +It's finished! +Kind of dragon free! +Excitement! +More than 500 sold! +One of a kind! +Heaps of hits on YouTube! +Indev! +Spiders everywhere! +Check it out! +Holy cow, man! +It's a game! +Made in Sweden! +Uses LWJGL! +Reticulating splines! +Minecraft! +Yaaay! +Singleplayer! +Keyboard compatible! +Undocumented! +Ingots! +Exploding creepers! +That's no moon! +l33t! +Create! +Survive! +Dungeon! +Exclusive! +The bee's knees! +Down with O.P.P.! +Closed source! +Classy! +Wow! +Not on steam! +Oh man! +Awesome community! +Pixels! +Teetsuuuuoooo! +Kaaneeeedaaaa! +Now with difficulty! +Enhanced! +90% bug free! +Pretty! +12 herbs and spices! +Fat free! +Absolutely no memes! +Free dental! +Ask your doctor! +Minors welcome! +Cloud computing! +Legal in Finland! +Hard to label! +Technically good! +Bringing home the bacon! +Indie! +GOTY! +Ceci n'est pas une title screen! +Euclidian! +Now in 3D! +Inspirational! +Herregud! +Complex cellular automata! +Yes, sir! +Played by cowboys! +OpenGL 1.2! +Thousands of colors! +Try it! +Age of Wonders is better! +Try the mushroom stew! +Sensational! +Hot tamale, hot hot tamale! +Play him off, keyboard cat! +Guaranteed! +Macroscopic! +Bring it on! +Random splash! +Call your mother! +Monster infighting! +Loved by millions! +Ultimate edition! +Freaky! +You've got a brand new key! +Water proof! +Uninflammable! +Whoa, dude! +All inclusive! +Tell your friends! +NP is not in P! +Notch <3 ez! +Music by C418! +Livestreamed! +Haunted! +Polynomial! +Terrestrial! +All is full of love! +Full of stars! +Scientific! +Cooler than Spock! +Collaborate and listen! +Never dig down! +Take frequent breaks! +Not linear! +Han shot first! +Nice to meet you! +Buckets of lava! +Ride the pig! +Larger than Earth! +sqrt(-1) love you! +Phobos anomaly! +Punching wood! +Falling off cliffs! +0% sugar! +150% hyperbole! +Synecdoche! +Let's danec! +Seecret Friday update! +Reference implementation! +Lewd with two dudes with food! +Kiss the sky! +20 GOTO 10! +Verlet intregration! +Peter Griffin! +Do not distribute! +Cogito ergo sum! +4815162342 lines of code! +A skeleton popped out! +The Work of Notch! +The sum of its parts! +BTAF used to be good! +I miss ADOM! +umop-apisdn! +OICU812! +Bring me Ray Cokes! +Finger-licking! +Thematic! +Pneumatic! +Sublime! +Octagonal! +Une baguette! +Gargamel plays it! +Rita is the new top dog! +SWM forever! +Representing Edsbyn! +Matt Damon! +Supercalifragilisticexpialidocious! +Consummate V's! +Cow Tools! +Double buffered! +Fan fiction! +Flaxkikare! +Jason! Jason! Jason! +Hotter than the sun! +Internet enabled! +Autonomous! +Engage! +Fantasy! +DRR! DRR! DRR! +Kick it root down! +Regional resources! +Woo, facepunch! +Woo, somethingawful! +Woo, /v/! +Woo, tigsource! +Woo, minecraftforum! +Woo, worldofminecraft! +Woo, reddit! +Woo, 2pp! +Google anlyticsed! +Now supports åäö! +Give us Gordon! +Tip your waiter! +Very fun! +12345 is a bad password! +Vote for net neutrality! +Lives in a pineapple under the sea! +MAP11 has two names! +Omnipotent! +Gasp! +...! +Bees, bees, bees, bees! +Jag känner en bot! +This text is hard to read if you play the game at the default resolution, but at 1080p it's fine! +Haha, LOL! +Hampsterdance! +Switches and ores! +Menger sponge! +idspispopd! +Eple (original edit)! +So fresh, so clean! +Slow acting portals! +Try the Nether! +Don't look directly at the bugs! +Oh, ok, Pigmen! +Finally with ladders! +Scary! +Play Minecraft, Watch Topgear, Get Pig! +Twittered about! +Jump up, jump up, and get down! +Joel is neat! +A riddle, wrapped in a mystery! +Huge tracts of land! +Welcome to your Doom! +Stay a while, stay forever! +Stay a while and listen! +Treatment for your rash! +"Autological" is! +Information wants to be free! +"Almost never" is an interesting concept! +Lots of truthiness! +The creeper is a spy! +Turing complete! +It's groundbreaking! +Let our battle's begin! +The sky is the limit! +Jeb has amazing hair! +Casual gaming! +Undefeated! +Kinda like Lemmings! +Follow the train, CJ! +Leveraging synergy! +This message will never appear on the splash screen, isn't that weird? +DungeonQuest is unfair! +110813! +90210! +Check out the far lands! +Tyrion would love it! +Also try VVVVVV! +Also try Super Meat Boy! +Also try Terraria! +Also try Mount And Blade! +Also try Project Zomboid! +Also try World of Goo! +Also try Limbo! +Also try Pixeljunk Shooter! +Also try Braid! +That's super! +Bread is pain! +Read more books! +Khaaaaaaaaan! +Less addictive than TV Tropes! +More addictive than lemonade! +Bigger than a bread box! +Millions of peaches! +Fnord! +This is my true form! +Totally forgot about Dre! +Don't bother with the clones! +Pumpkinhead! +Hobo humping slobo babe! +Made by Jeb! +Has an ending! +Finally complete! +Feature packed! +Boots with the fur! +Stop, hammertime! +Testificates! +Conventional! +Homeomorphic to a 3-sphere! +Doesn't avoid double negatives! +Place ALL the blocks! +Does barrel rolls! +Meeting expectations! +PC gaming since 1873! +Ghoughpteighbteau tchoghs! +Déjà vu! +Déjà vu! +Got your nose! +Haley loves Elan! +Afraid of the big, black bat! +Doesn't use the U-word! +Child's play! +See you next Friday or so! +From the streets of Södermalm! +150 bpm for 400000 minutes! +Technologic! +Funk soul brother! +Pumpa kungen! +日本ハロー! +한국 안녕하세요! +Helo Cymru! +Cześć Polsko! +你好中国! +Привет Россия! +Γεια σου Ελλάδα! +My life for Aiur! +Lennart lennart = new Lennart(); +I see your vocabulary has improved! +Who put it there? +You can't explain that! +if not ok then return end +§1C§2o§3l§4o§5r§6m§7a§8t§9i§ac +§kFUNKY LOL +SOPA means LOSER in Swedish! +Big Pointy Teeth! +Bekarton guards the gate! +Mmmph, mmph! +Don't feed avocados to parrots! +Swords for everyone! +Plz reply to my tweet! +.party()! +Take her pillow! +Put that cookie down! +Pretty scary! +I have a suggestion. +Now with extra hugs! +Now java 6! +Woah. +HURNERJSGER? +What's up, Doc? +Now contains 32 random daily cats! \ No newline at end of file diff --git a/src/main/resources/assets/minecraft/textures/blocks/anvil_base.png b/src/main/resources/assets/minecraft/textures/blocks/anvil_base.png new file mode 100644 index 0000000..cfc1fc8 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/anvil_base.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/anvil_top_damaged_0.png b/src/main/resources/assets/minecraft/textures/blocks/anvil_top_damaged_0.png new file mode 100644 index 0000000..395dea4 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/anvil_top_damaged_0.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/anvil_top_damaged_1.png b/src/main/resources/assets/minecraft/textures/blocks/anvil_top_damaged_1.png new file mode 100644 index 0000000..eddc47f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/anvil_top_damaged_1.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/anvil_top_damaged_2.png b/src/main/resources/assets/minecraft/textures/blocks/anvil_top_damaged_2.png new file mode 100644 index 0000000..6cade1f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/anvil_top_damaged_2.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/beacon.png b/src/main/resources/assets/minecraft/textures/blocks/beacon.png new file mode 100644 index 0000000..a69e59d --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/beacon.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/bed_feet_end.png b/src/main/resources/assets/minecraft/textures/blocks/bed_feet_end.png new file mode 100644 index 0000000..6e1a4be --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/bed_feet_end.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/bed_feet_side.png b/src/main/resources/assets/minecraft/textures/blocks/bed_feet_side.png new file mode 100644 index 0000000..3ce06f3 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/bed_feet_side.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/bed_feet_top.png b/src/main/resources/assets/minecraft/textures/blocks/bed_feet_top.png new file mode 100644 index 0000000..b96d357 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/bed_feet_top.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/bed_head_end.png b/src/main/resources/assets/minecraft/textures/blocks/bed_head_end.png new file mode 100644 index 0000000..b684c9a --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/bed_head_end.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/bed_head_side.png b/src/main/resources/assets/minecraft/textures/blocks/bed_head_side.png new file mode 100644 index 0000000..3270b4a --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/bed_head_side.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/bed_head_top.png b/src/main/resources/assets/minecraft/textures/blocks/bed_head_top.png new file mode 100644 index 0000000..2ab1090 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/bed_head_top.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/bedrock.png b/src/main/resources/assets/minecraft/textures/blocks/bedrock.png new file mode 100644 index 0000000..1643c99 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/bedrock.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/bookshelf.png b/src/main/resources/assets/minecraft/textures/blocks/bookshelf.png new file mode 100644 index 0000000..4c87f0f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/bookshelf.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/brewing_stand.png b/src/main/resources/assets/minecraft/textures/blocks/brewing_stand.png new file mode 100644 index 0000000..60832aa --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/brewing_stand.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/brewing_stand_base.png b/src/main/resources/assets/minecraft/textures/blocks/brewing_stand_base.png new file mode 100644 index 0000000..0742fbf --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/brewing_stand_base.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/brick.png b/src/main/resources/assets/minecraft/textures/blocks/brick.png new file mode 100644 index 0000000..fd6959c --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/brick.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/cactus_bottom.png b/src/main/resources/assets/minecraft/textures/blocks/cactus_bottom.png new file mode 100644 index 0000000..6f10bc0 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/cactus_bottom.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/cactus_side.png b/src/main/resources/assets/minecraft/textures/blocks/cactus_side.png new file mode 100644 index 0000000..9c55503 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/cactus_side.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/cactus_top.png b/src/main/resources/assets/minecraft/textures/blocks/cactus_top.png new file mode 100644 index 0000000..f182e84 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/cactus_top.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/cake_bottom.png b/src/main/resources/assets/minecraft/textures/blocks/cake_bottom.png new file mode 100644 index 0000000..d93b15a --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/cake_bottom.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/cake_inner.png b/src/main/resources/assets/minecraft/textures/blocks/cake_inner.png new file mode 100644 index 0000000..ce7ce69 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/cake_inner.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/cake_side.png b/src/main/resources/assets/minecraft/textures/blocks/cake_side.png new file mode 100644 index 0000000..343a023 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/cake_side.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/cake_top.png b/src/main/resources/assets/minecraft/textures/blocks/cake_top.png new file mode 100644 index 0000000..2947892 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/cake_top.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/carrots_stage_0.png b/src/main/resources/assets/minecraft/textures/blocks/carrots_stage_0.png new file mode 100644 index 0000000..c1ef732 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/carrots_stage_0.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/carrots_stage_1.png b/src/main/resources/assets/minecraft/textures/blocks/carrots_stage_1.png new file mode 100644 index 0000000..1275f4f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/carrots_stage_1.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/carrots_stage_2.png b/src/main/resources/assets/minecraft/textures/blocks/carrots_stage_2.png new file mode 100644 index 0000000..b7347df --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/carrots_stage_2.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/carrots_stage_3.png b/src/main/resources/assets/minecraft/textures/blocks/carrots_stage_3.png new file mode 100644 index 0000000..2391be8 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/carrots_stage_3.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/cauldron_bottom.png b/src/main/resources/assets/minecraft/textures/blocks/cauldron_bottom.png new file mode 100644 index 0000000..fb31385 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/cauldron_bottom.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/cauldron_inner.png b/src/main/resources/assets/minecraft/textures/blocks/cauldron_inner.png new file mode 100644 index 0000000..d5a30dd --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/cauldron_inner.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/cauldron_side.png b/src/main/resources/assets/minecraft/textures/blocks/cauldron_side.png new file mode 100644 index 0000000..72b0e5a --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/cauldron_side.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/cauldron_top.png b/src/main/resources/assets/minecraft/textures/blocks/cauldron_top.png new file mode 100644 index 0000000..3ed6171 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/cauldron_top.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/clay.png b/src/main/resources/assets/minecraft/textures/blocks/clay.png new file mode 100644 index 0000000..c19e031 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/clay.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/coal_block.png b/src/main/resources/assets/minecraft/textures/blocks/coal_block.png new file mode 100644 index 0000000..024404b --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/coal_block.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/coal_ore.png b/src/main/resources/assets/minecraft/textures/blocks/coal_ore.png new file mode 100644 index 0000000..49486d2 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/coal_ore.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/cobblestone.png b/src/main/resources/assets/minecraft/textures/blocks/cobblestone.png new file mode 100644 index 0000000..da3498c --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/cobblestone.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/cobblestone_mossy.png b/src/main/resources/assets/minecraft/textures/blocks/cobblestone_mossy.png new file mode 100644 index 0000000..29449e3 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/cobblestone_mossy.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/cocoa_stage_0.png b/src/main/resources/assets/minecraft/textures/blocks/cocoa_stage_0.png new file mode 100644 index 0000000..25892eb --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/cocoa_stage_0.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/cocoa_stage_1.png b/src/main/resources/assets/minecraft/textures/blocks/cocoa_stage_1.png new file mode 100644 index 0000000..d0098ff --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/cocoa_stage_1.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/cocoa_stage_2.png b/src/main/resources/assets/minecraft/textures/blocks/cocoa_stage_2.png new file mode 100644 index 0000000..db28c7b --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/cocoa_stage_2.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/command_block.png b/src/main/resources/assets/minecraft/textures/blocks/command_block.png new file mode 100644 index 0000000..4459675 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/command_block.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/comparator_off.png b/src/main/resources/assets/minecraft/textures/blocks/comparator_off.png new file mode 100644 index 0000000..c9527bc --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/comparator_off.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/comparator_on.png b/src/main/resources/assets/minecraft/textures/blocks/comparator_on.png new file mode 100644 index 0000000..2e4fb7a --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/comparator_on.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/crafting_table_front.png b/src/main/resources/assets/minecraft/textures/blocks/crafting_table_front.png new file mode 100644 index 0000000..11986a4 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/crafting_table_front.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/crafting_table_side.png b/src/main/resources/assets/minecraft/textures/blocks/crafting_table_side.png new file mode 100644 index 0000000..1c678b4 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/crafting_table_side.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/crafting_table_top.png b/src/main/resources/assets/minecraft/textures/blocks/crafting_table_top.png new file mode 100644 index 0000000..5cd53a5 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/crafting_table_top.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/daylight_detector_side.png b/src/main/resources/assets/minecraft/textures/blocks/daylight_detector_side.png new file mode 100644 index 0000000..ac273ea --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/daylight_detector_side.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/daylight_detector_top.png b/src/main/resources/assets/minecraft/textures/blocks/daylight_detector_top.png new file mode 100644 index 0000000..3bfb2da --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/daylight_detector_top.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/deadbush.png b/src/main/resources/assets/minecraft/textures/blocks/deadbush.png new file mode 100644 index 0000000..c64e079 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/deadbush.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/destroy_stage_0.png b/src/main/resources/assets/minecraft/textures/blocks/destroy_stage_0.png new file mode 100644 index 0000000..f65b7ed --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/destroy_stage_0.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/destroy_stage_1.png b/src/main/resources/assets/minecraft/textures/blocks/destroy_stage_1.png new file mode 100644 index 0000000..7c91596 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/destroy_stage_1.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/destroy_stage_2.png b/src/main/resources/assets/minecraft/textures/blocks/destroy_stage_2.png new file mode 100644 index 0000000..dadd6b0 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/destroy_stage_2.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/destroy_stage_3.png b/src/main/resources/assets/minecraft/textures/blocks/destroy_stage_3.png new file mode 100644 index 0000000..52a40b6 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/destroy_stage_3.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/destroy_stage_4.png b/src/main/resources/assets/minecraft/textures/blocks/destroy_stage_4.png new file mode 100644 index 0000000..e37c88a --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/destroy_stage_4.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/destroy_stage_5.png b/src/main/resources/assets/minecraft/textures/blocks/destroy_stage_5.png new file mode 100644 index 0000000..9590d2f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/destroy_stage_5.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/destroy_stage_6.png b/src/main/resources/assets/minecraft/textures/blocks/destroy_stage_6.png new file mode 100644 index 0000000..8e490c0 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/destroy_stage_6.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/destroy_stage_7.png b/src/main/resources/assets/minecraft/textures/blocks/destroy_stage_7.png new file mode 100644 index 0000000..0b40c78 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/destroy_stage_7.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/destroy_stage_8.png b/src/main/resources/assets/minecraft/textures/blocks/destroy_stage_8.png new file mode 100644 index 0000000..c0bf1de --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/destroy_stage_8.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/destroy_stage_9.png b/src/main/resources/assets/minecraft/textures/blocks/destroy_stage_9.png new file mode 100644 index 0000000..e3185f8 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/destroy_stage_9.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/diamond_block.png b/src/main/resources/assets/minecraft/textures/blocks/diamond_block.png new file mode 100644 index 0000000..f2e2e77 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/diamond_block.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/diamond_ore.png b/src/main/resources/assets/minecraft/textures/blocks/diamond_ore.png new file mode 100644 index 0000000..735ecda --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/diamond_ore.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/dirt.png b/src/main/resources/assets/minecraft/textures/blocks/dirt.png new file mode 100644 index 0000000..617d353 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/dirt.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/dirt_podzol_side.png b/src/main/resources/assets/minecraft/textures/blocks/dirt_podzol_side.png new file mode 100644 index 0000000..5921d37 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/dirt_podzol_side.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/dirt_podzol_top.png b/src/main/resources/assets/minecraft/textures/blocks/dirt_podzol_top.png new file mode 100644 index 0000000..ebeda86 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/dirt_podzol_top.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/dispenser_front_horizontal.png b/src/main/resources/assets/minecraft/textures/blocks/dispenser_front_horizontal.png new file mode 100644 index 0000000..3e09fde --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/dispenser_front_horizontal.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/dispenser_front_vertical.png b/src/main/resources/assets/minecraft/textures/blocks/dispenser_front_vertical.png new file mode 100644 index 0000000..87a7837 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/dispenser_front_vertical.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/door_iron_lower.png b/src/main/resources/assets/minecraft/textures/blocks/door_iron_lower.png new file mode 100644 index 0000000..dbc33ab --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/door_iron_lower.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/door_iron_upper.png b/src/main/resources/assets/minecraft/textures/blocks/door_iron_upper.png new file mode 100644 index 0000000..56878fe --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/door_iron_upper.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/door_wood_lower.png b/src/main/resources/assets/minecraft/textures/blocks/door_wood_lower.png new file mode 100644 index 0000000..cc61731 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/door_wood_lower.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/door_wood_upper.png b/src/main/resources/assets/minecraft/textures/blocks/door_wood_upper.png new file mode 100644 index 0000000..93319d5 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/door_wood_upper.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/double_plant_fern_bottom.png b/src/main/resources/assets/minecraft/textures/blocks/double_plant_fern_bottom.png new file mode 100644 index 0000000..6a5fa6a --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/double_plant_fern_bottom.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/double_plant_fern_top.png b/src/main/resources/assets/minecraft/textures/blocks/double_plant_fern_top.png new file mode 100644 index 0000000..393144c --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/double_plant_fern_top.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/double_plant_grass_bottom.png b/src/main/resources/assets/minecraft/textures/blocks/double_plant_grass_bottom.png new file mode 100644 index 0000000..ec717f9 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/double_plant_grass_bottom.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/double_plant_grass_top.png b/src/main/resources/assets/minecraft/textures/blocks/double_plant_grass_top.png new file mode 100644 index 0000000..113d2b3 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/double_plant_grass_top.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/double_plant_paeonia_bottom.png b/src/main/resources/assets/minecraft/textures/blocks/double_plant_paeonia_bottom.png new file mode 100644 index 0000000..21285f5 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/double_plant_paeonia_bottom.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/double_plant_paeonia_top.png b/src/main/resources/assets/minecraft/textures/blocks/double_plant_paeonia_top.png new file mode 100644 index 0000000..bc68241 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/double_plant_paeonia_top.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/double_plant_rose_bottom.png b/src/main/resources/assets/minecraft/textures/blocks/double_plant_rose_bottom.png new file mode 100644 index 0000000..4d59f44 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/double_plant_rose_bottom.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/double_plant_rose_top.png b/src/main/resources/assets/minecraft/textures/blocks/double_plant_rose_top.png new file mode 100644 index 0000000..028aa80 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/double_plant_rose_top.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/double_plant_sunflower_back.png b/src/main/resources/assets/minecraft/textures/blocks/double_plant_sunflower_back.png new file mode 100644 index 0000000..d488923 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/double_plant_sunflower_back.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/double_plant_sunflower_bottom.png b/src/main/resources/assets/minecraft/textures/blocks/double_plant_sunflower_bottom.png new file mode 100644 index 0000000..8a12ebe --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/double_plant_sunflower_bottom.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/double_plant_sunflower_front.png b/src/main/resources/assets/minecraft/textures/blocks/double_plant_sunflower_front.png new file mode 100644 index 0000000..699e34f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/double_plant_sunflower_front.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/double_plant_sunflower_top.png b/src/main/resources/assets/minecraft/textures/blocks/double_plant_sunflower_top.png new file mode 100644 index 0000000..4d14203 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/double_plant_sunflower_top.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/double_plant_syringa_bottom.png b/src/main/resources/assets/minecraft/textures/blocks/double_plant_syringa_bottom.png new file mode 100644 index 0000000..5b880b5 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/double_plant_syringa_bottom.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/double_plant_syringa_top.png b/src/main/resources/assets/minecraft/textures/blocks/double_plant_syringa_top.png new file mode 100644 index 0000000..b00751f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/double_plant_syringa_top.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/dragon_egg.png b/src/main/resources/assets/minecraft/textures/blocks/dragon_egg.png new file mode 100644 index 0000000..02af123 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/dragon_egg.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/dropper_front_horizontal.png b/src/main/resources/assets/minecraft/textures/blocks/dropper_front_horizontal.png new file mode 100644 index 0000000..7d5f260 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/dropper_front_horizontal.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/dropper_front_vertical.png b/src/main/resources/assets/minecraft/textures/blocks/dropper_front_vertical.png new file mode 100644 index 0000000..68a56c8 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/dropper_front_vertical.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/emerald_block.png b/src/main/resources/assets/minecraft/textures/blocks/emerald_block.png new file mode 100644 index 0000000..dc214ee --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/emerald_block.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/emerald_ore.png b/src/main/resources/assets/minecraft/textures/blocks/emerald_ore.png new file mode 100644 index 0000000..a26c35f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/emerald_ore.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/enchanting_table_bottom.png b/src/main/resources/assets/minecraft/textures/blocks/enchanting_table_bottom.png new file mode 100644 index 0000000..0f492aa --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/enchanting_table_bottom.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/enchanting_table_side.png b/src/main/resources/assets/minecraft/textures/blocks/enchanting_table_side.png new file mode 100644 index 0000000..f2f4614 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/enchanting_table_side.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/enchanting_table_top.png b/src/main/resources/assets/minecraft/textures/blocks/enchanting_table_top.png new file mode 100644 index 0000000..0d5f68f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/enchanting_table_top.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/end_stone.png b/src/main/resources/assets/minecraft/textures/blocks/end_stone.png new file mode 100644 index 0000000..c2a91e3 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/end_stone.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/endframe_eye.png b/src/main/resources/assets/minecraft/textures/blocks/endframe_eye.png new file mode 100644 index 0000000..afa1d5d --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/endframe_eye.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/endframe_side.png b/src/main/resources/assets/minecraft/textures/blocks/endframe_side.png new file mode 100644 index 0000000..e6cb567 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/endframe_side.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/endframe_top.png b/src/main/resources/assets/minecraft/textures/blocks/endframe_top.png new file mode 100644 index 0000000..35215a5 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/endframe_top.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/farmland_dry.png b/src/main/resources/assets/minecraft/textures/blocks/farmland_dry.png new file mode 100644 index 0000000..d03a0f4 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/farmland_dry.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/farmland_wet.png b/src/main/resources/assets/minecraft/textures/blocks/farmland_wet.png new file mode 100644 index 0000000..f8d460d --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/farmland_wet.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/fern.png b/src/main/resources/assets/minecraft/textures/blocks/fern.png new file mode 100644 index 0000000..fd76950 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/fern.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/fire_layer_0.png b/src/main/resources/assets/minecraft/textures/blocks/fire_layer_0.png new file mode 100644 index 0000000..cf8910f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/fire_layer_0.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/fire_layer_0.png.mcmeta b/src/main/resources/assets/minecraft/textures/blocks/fire_layer_0.png.mcmeta new file mode 100644 index 0000000..7644671 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/fire_layer_0.png.mcmeta @@ -0,0 +1,38 @@ +{ + "animation": { + "frames": [ + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15 + ] + } +} diff --git a/src/main/resources/assets/minecraft/textures/blocks/fire_layer_1.png b/src/main/resources/assets/minecraft/textures/blocks/fire_layer_1.png new file mode 100644 index 0000000..6db92ac --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/fire_layer_1.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/fire_layer_1.png.mcmeta b/src/main/resources/assets/minecraft/textures/blocks/fire_layer_1.png.mcmeta new file mode 100644 index 0000000..4f0718a --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/fire_layer_1.png.mcmeta @@ -0,0 +1,3 @@ +{ + "animation": {} +} \ No newline at end of file diff --git a/src/main/resources/assets/minecraft/textures/blocks/flower_allium.png b/src/main/resources/assets/minecraft/textures/blocks/flower_allium.png new file mode 100644 index 0000000..b7b5a45 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/flower_allium.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/flower_blue_orchid.png b/src/main/resources/assets/minecraft/textures/blocks/flower_blue_orchid.png new file mode 100644 index 0000000..51d7fd9 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/flower_blue_orchid.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/flower_dandelion.png b/src/main/resources/assets/minecraft/textures/blocks/flower_dandelion.png new file mode 100644 index 0000000..873e3f5 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/flower_dandelion.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/flower_houstonia.png b/src/main/resources/assets/minecraft/textures/blocks/flower_houstonia.png new file mode 100644 index 0000000..2f9127d --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/flower_houstonia.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/flower_oxeye_daisy.png b/src/main/resources/assets/minecraft/textures/blocks/flower_oxeye_daisy.png new file mode 100644 index 0000000..6d48913 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/flower_oxeye_daisy.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/flower_paeonia.png b/src/main/resources/assets/minecraft/textures/blocks/flower_paeonia.png new file mode 100644 index 0000000..01a92ee --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/flower_paeonia.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/flower_pot.png b/src/main/resources/assets/minecraft/textures/blocks/flower_pot.png new file mode 100644 index 0000000..09c2523 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/flower_pot.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/flower_rose.png b/src/main/resources/assets/minecraft/textures/blocks/flower_rose.png new file mode 100644 index 0000000..895d78f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/flower_rose.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/flower_tulip_orange.png b/src/main/resources/assets/minecraft/textures/blocks/flower_tulip_orange.png new file mode 100644 index 0000000..6715a62 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/flower_tulip_orange.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/flower_tulip_pink.png b/src/main/resources/assets/minecraft/textures/blocks/flower_tulip_pink.png new file mode 100644 index 0000000..a757bf5 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/flower_tulip_pink.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/flower_tulip_red.png b/src/main/resources/assets/minecraft/textures/blocks/flower_tulip_red.png new file mode 100644 index 0000000..3048b63 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/flower_tulip_red.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/flower_tulip_white.png b/src/main/resources/assets/minecraft/textures/blocks/flower_tulip_white.png new file mode 100644 index 0000000..6aa12a9 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/flower_tulip_white.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/furnace_front_off.png b/src/main/resources/assets/minecraft/textures/blocks/furnace_front_off.png new file mode 100644 index 0000000..0570c3a --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/furnace_front_off.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/furnace_front_on.png b/src/main/resources/assets/minecraft/textures/blocks/furnace_front_on.png new file mode 100644 index 0000000..92c89f3 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/furnace_front_on.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/furnace_side.png b/src/main/resources/assets/minecraft/textures/blocks/furnace_side.png new file mode 100644 index 0000000..115f73d --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/furnace_side.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/furnace_top.png b/src/main/resources/assets/minecraft/textures/blocks/furnace_top.png new file mode 100644 index 0000000..a3a5a08 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/furnace_top.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/glass.png b/src/main/resources/assets/minecraft/textures/blocks/glass.png new file mode 100644 index 0000000..acadb01 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/glass.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/glass_black.png b/src/main/resources/assets/minecraft/textures/blocks/glass_black.png new file mode 100644 index 0000000..06f3427 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/glass_black.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/glass_blue.png b/src/main/resources/assets/minecraft/textures/blocks/glass_blue.png new file mode 100644 index 0000000..38885de --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/glass_blue.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/glass_brown.png b/src/main/resources/assets/minecraft/textures/blocks/glass_brown.png new file mode 100644 index 0000000..259b61c --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/glass_brown.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/glass_cyan.png b/src/main/resources/assets/minecraft/textures/blocks/glass_cyan.png new file mode 100644 index 0000000..d30caa4 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/glass_cyan.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/glass_gray.png b/src/main/resources/assets/minecraft/textures/blocks/glass_gray.png new file mode 100644 index 0000000..3f07a5d --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/glass_gray.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/glass_green.png b/src/main/resources/assets/minecraft/textures/blocks/glass_green.png new file mode 100644 index 0000000..7c1f4e6 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/glass_green.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/glass_light_blue.png b/src/main/resources/assets/minecraft/textures/blocks/glass_light_blue.png new file mode 100644 index 0000000..b62703d --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/glass_light_blue.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/glass_lime.png b/src/main/resources/assets/minecraft/textures/blocks/glass_lime.png new file mode 100644 index 0000000..f1d3c46 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/glass_lime.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/glass_magenta.png b/src/main/resources/assets/minecraft/textures/blocks/glass_magenta.png new file mode 100644 index 0000000..5cd9945 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/glass_magenta.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/glass_orange.png b/src/main/resources/assets/minecraft/textures/blocks/glass_orange.png new file mode 100644 index 0000000..3a29e31 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/glass_orange.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top.png b/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top.png new file mode 100644 index 0000000..02de587 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_black.png b/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_black.png new file mode 100644 index 0000000..43d60c5 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_black.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_blue.png b/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_blue.png new file mode 100644 index 0000000..55c614f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_blue.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_brown.png b/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_brown.png new file mode 100644 index 0000000..cbd791a --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_brown.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_cyan.png b/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_cyan.png new file mode 100644 index 0000000..9a34b84 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_cyan.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_gray.png b/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_gray.png new file mode 100644 index 0000000..bb06114 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_gray.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_green.png b/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_green.png new file mode 100644 index 0000000..a7d9fc7 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_green.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_light_blue.png b/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_light_blue.png new file mode 100644 index 0000000..6a0e661 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_light_blue.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_lime.png b/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_lime.png new file mode 100644 index 0000000..0607d75 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_lime.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_magenta.png b/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_magenta.png new file mode 100644 index 0000000..5419e52 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_magenta.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_orange.png b/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_orange.png new file mode 100644 index 0000000..2866571 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_orange.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_pink.png b/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_pink.png new file mode 100644 index 0000000..6b6cd76 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_pink.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_purple.png b/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_purple.png new file mode 100644 index 0000000..23e208e --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_purple.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_red.png b/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_red.png new file mode 100644 index 0000000..22b69db --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_red.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_silver.png b/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_silver.png new file mode 100644 index 0000000..f226ecc --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_silver.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_white.png b/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_white.png new file mode 100644 index 0000000..9a273c3 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_white.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_yellow.png b/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_yellow.png new file mode 100644 index 0000000..1c8580f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/glass_pane_top_yellow.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/glass_pink.png b/src/main/resources/assets/minecraft/textures/blocks/glass_pink.png new file mode 100644 index 0000000..42d8739 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/glass_pink.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/glass_purple.png b/src/main/resources/assets/minecraft/textures/blocks/glass_purple.png new file mode 100644 index 0000000..fcae3d2 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/glass_purple.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/glass_red.png b/src/main/resources/assets/minecraft/textures/blocks/glass_red.png new file mode 100644 index 0000000..db4c5eb --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/glass_red.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/glass_silver.png b/src/main/resources/assets/minecraft/textures/blocks/glass_silver.png new file mode 100644 index 0000000..8461664 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/glass_silver.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/glass_white.png b/src/main/resources/assets/minecraft/textures/blocks/glass_white.png new file mode 100644 index 0000000..696c5aa --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/glass_white.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/glass_yellow.png b/src/main/resources/assets/minecraft/textures/blocks/glass_yellow.png new file mode 100644 index 0000000..8e48e12 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/glass_yellow.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/glowstone.png b/src/main/resources/assets/minecraft/textures/blocks/glowstone.png new file mode 100644 index 0000000..c7253b3 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/glowstone.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/gold_block.png b/src/main/resources/assets/minecraft/textures/blocks/gold_block.png new file mode 100644 index 0000000..174002e --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/gold_block.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/gold_ore.png b/src/main/resources/assets/minecraft/textures/blocks/gold_ore.png new file mode 100644 index 0000000..b1a7a55 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/gold_ore.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/grass_side.png b/src/main/resources/assets/minecraft/textures/blocks/grass_side.png new file mode 100644 index 0000000..a4975e5 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/grass_side.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/grass_side_overlay.png b/src/main/resources/assets/minecraft/textures/blocks/grass_side_overlay.png new file mode 100644 index 0000000..fc3fa9d --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/grass_side_overlay.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/grass_side_snowed.png b/src/main/resources/assets/minecraft/textures/blocks/grass_side_snowed.png new file mode 100644 index 0000000..41f6197 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/grass_side_snowed.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/grass_top.png b/src/main/resources/assets/minecraft/textures/blocks/grass_top.png new file mode 100644 index 0000000..eaa7e45 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/grass_top.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/gravel.png b/src/main/resources/assets/minecraft/textures/blocks/gravel.png new file mode 100644 index 0000000..388e5c5 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/gravel.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/hardened_clay.png b/src/main/resources/assets/minecraft/textures/blocks/hardened_clay.png new file mode 100644 index 0000000..2446380 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/hardened_clay.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_black.png b/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_black.png new file mode 100644 index 0000000..59da22c --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_black.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_blue.png b/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_blue.png new file mode 100644 index 0000000..7e38e27 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_blue.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_brown.png b/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_brown.png new file mode 100644 index 0000000..f81745f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_brown.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_cyan.png b/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_cyan.png new file mode 100644 index 0000000..b05428c --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_cyan.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_gray.png b/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_gray.png new file mode 100644 index 0000000..8f86904 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_gray.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_green.png b/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_green.png new file mode 100644 index 0000000..e89162e --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_green.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_light_blue.png b/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_light_blue.png new file mode 100644 index 0000000..3d9ebea --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_light_blue.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_lime.png b/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_lime.png new file mode 100644 index 0000000..b459a0b --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_lime.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_magenta.png b/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_magenta.png new file mode 100644 index 0000000..9663106 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_magenta.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_orange.png b/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_orange.png new file mode 100644 index 0000000..40929db --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_orange.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_pink.png b/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_pink.png new file mode 100644 index 0000000..c21c0aa --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_pink.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_purple.png b/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_purple.png new file mode 100644 index 0000000..edece94 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_purple.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_red.png b/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_red.png new file mode 100644 index 0000000..6561d12 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_red.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_silver.png b/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_silver.png new file mode 100644 index 0000000..eae07f2 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_silver.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_white.png b/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_white.png new file mode 100644 index 0000000..8066af0 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_white.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_yellow.png b/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_yellow.png new file mode 100644 index 0000000..5da4687 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/hardened_clay_stained_yellow.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/hay_block_side.png b/src/main/resources/assets/minecraft/textures/blocks/hay_block_side.png new file mode 100644 index 0000000..a2b32db --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/hay_block_side.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/hay_block_top.png b/src/main/resources/assets/minecraft/textures/blocks/hay_block_top.png new file mode 100644 index 0000000..1d35593 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/hay_block_top.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/hopper_inside.png b/src/main/resources/assets/minecraft/textures/blocks/hopper_inside.png new file mode 100644 index 0000000..24e8eae --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/hopper_inside.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/hopper_outside.png b/src/main/resources/assets/minecraft/textures/blocks/hopper_outside.png new file mode 100644 index 0000000..50ed8d5 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/hopper_outside.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/hopper_top.png b/src/main/resources/assets/minecraft/textures/blocks/hopper_top.png new file mode 100644 index 0000000..3ed6171 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/hopper_top.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/ice.png b/src/main/resources/assets/minecraft/textures/blocks/ice.png new file mode 100644 index 0000000..ac946e9 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/ice.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/ice_packed.png b/src/main/resources/assets/minecraft/textures/blocks/ice_packed.png new file mode 100644 index 0000000..50f0f34 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/ice_packed.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/iron_bars.png b/src/main/resources/assets/minecraft/textures/blocks/iron_bars.png new file mode 100644 index 0000000..732807f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/iron_bars.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/iron_block.png b/src/main/resources/assets/minecraft/textures/blocks/iron_block.png new file mode 100644 index 0000000..7816799 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/iron_block.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/iron_ore.png b/src/main/resources/assets/minecraft/textures/blocks/iron_ore.png new file mode 100644 index 0000000..250d8bb --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/iron_ore.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/itemframe_background.png b/src/main/resources/assets/minecraft/textures/blocks/itemframe_background.png new file mode 100644 index 0000000..b40ad65 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/itemframe_background.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/jukebox_side.png b/src/main/resources/assets/minecraft/textures/blocks/jukebox_side.png new file mode 100644 index 0000000..a3c27c1 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/jukebox_side.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/jukebox_top.png b/src/main/resources/assets/minecraft/textures/blocks/jukebox_top.png new file mode 100644 index 0000000..92ddb15 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/jukebox_top.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/ladder.png b/src/main/resources/assets/minecraft/textures/blocks/ladder.png new file mode 100644 index 0000000..e2ec5f2 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/ladder.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/lapis_block.png b/src/main/resources/assets/minecraft/textures/blocks/lapis_block.png new file mode 100644 index 0000000..0271489 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/lapis_block.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/lapis_ore.png b/src/main/resources/assets/minecraft/textures/blocks/lapis_ore.png new file mode 100644 index 0000000..6144236 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/lapis_ore.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/lava_flow.png b/src/main/resources/assets/minecraft/textures/blocks/lava_flow.png new file mode 100644 index 0000000..af07f91 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/lava_flow.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/lava_flow.png.mcmeta b/src/main/resources/assets/minecraft/textures/blocks/lava_flow.png.mcmeta new file mode 100644 index 0000000..8e55e43 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/lava_flow.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 3 + } +} diff --git a/src/main/resources/assets/minecraft/textures/blocks/lava_still.png b/src/main/resources/assets/minecraft/textures/blocks/lava_still.png new file mode 100644 index 0000000..78bb29d --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/lava_still.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/lava_still.png.mcmeta b/src/main/resources/assets/minecraft/textures/blocks/lava_still.png.mcmeta new file mode 100644 index 0000000..7ceb363 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/lava_still.png.mcmeta @@ -0,0 +1,45 @@ +{ + "animation": { + "frametime": 2, + "frames": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 18, + 17, + 16, + 15, + 14, + 13, + 12, + 11, + 10, + 9, + 8, + 7, + 6, + 5, + 4, + 3, + 2, + 1 + ] + } +} \ No newline at end of file diff --git a/src/main/resources/assets/minecraft/textures/blocks/leaves_acacia.png b/src/main/resources/assets/minecraft/textures/blocks/leaves_acacia.png new file mode 100644 index 0000000..a6773af --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/leaves_acacia.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/leaves_acacia_opaque.png b/src/main/resources/assets/minecraft/textures/blocks/leaves_acacia_opaque.png new file mode 100644 index 0000000..e91ed32 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/leaves_acacia_opaque.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/leaves_big_oak.png b/src/main/resources/assets/minecraft/textures/blocks/leaves_big_oak.png new file mode 100644 index 0000000..a6773af --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/leaves_big_oak.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/leaves_big_oak_opaque.png b/src/main/resources/assets/minecraft/textures/blocks/leaves_big_oak_opaque.png new file mode 100644 index 0000000..e91ed32 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/leaves_big_oak_opaque.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/leaves_birch.png b/src/main/resources/assets/minecraft/textures/blocks/leaves_birch.png new file mode 100644 index 0000000..a6773af --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/leaves_birch.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/leaves_birch_opaque.png b/src/main/resources/assets/minecraft/textures/blocks/leaves_birch_opaque.png new file mode 100644 index 0000000..e91ed32 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/leaves_birch_opaque.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/leaves_jungle.png b/src/main/resources/assets/minecraft/textures/blocks/leaves_jungle.png new file mode 100644 index 0000000..e0cb935 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/leaves_jungle.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/leaves_jungle_opaque.png b/src/main/resources/assets/minecraft/textures/blocks/leaves_jungle_opaque.png new file mode 100644 index 0000000..110a618 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/leaves_jungle_opaque.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/leaves_oak.png b/src/main/resources/assets/minecraft/textures/blocks/leaves_oak.png new file mode 100644 index 0000000..a6773af --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/leaves_oak.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/leaves_oak_opaque.png b/src/main/resources/assets/minecraft/textures/blocks/leaves_oak_opaque.png new file mode 100644 index 0000000..e91ed32 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/leaves_oak_opaque.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/leaves_spruce.png b/src/main/resources/assets/minecraft/textures/blocks/leaves_spruce.png new file mode 100644 index 0000000..602eab8 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/leaves_spruce.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/leaves_spruce_opaque.png b/src/main/resources/assets/minecraft/textures/blocks/leaves_spruce_opaque.png new file mode 100644 index 0000000..2e5228e --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/leaves_spruce_opaque.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/lever.png b/src/main/resources/assets/minecraft/textures/blocks/lever.png new file mode 100644 index 0000000..051187f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/lever.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/log_acacia.png b/src/main/resources/assets/minecraft/textures/blocks/log_acacia.png new file mode 100644 index 0000000..d221210 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/log_acacia.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/log_acacia_top.png b/src/main/resources/assets/minecraft/textures/blocks/log_acacia_top.png new file mode 100644 index 0000000..3d44878 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/log_acacia_top.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/log_big_oak.png b/src/main/resources/assets/minecraft/textures/blocks/log_big_oak.png new file mode 100644 index 0000000..d4da03e --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/log_big_oak.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/log_big_oak_top.png b/src/main/resources/assets/minecraft/textures/blocks/log_big_oak_top.png new file mode 100644 index 0000000..99137b6 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/log_big_oak_top.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/log_birch.png b/src/main/resources/assets/minecraft/textures/blocks/log_birch.png new file mode 100644 index 0000000..bfb209d --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/log_birch.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/log_birch_top.png b/src/main/resources/assets/minecraft/textures/blocks/log_birch_top.png new file mode 100644 index 0000000..f9b94f4 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/log_birch_top.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/log_jungle.png b/src/main/resources/assets/minecraft/textures/blocks/log_jungle.png new file mode 100644 index 0000000..0b7120a --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/log_jungle.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/log_jungle_top.png b/src/main/resources/assets/minecraft/textures/blocks/log_jungle_top.png new file mode 100644 index 0000000..26b0361 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/log_jungle_top.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/log_oak.png b/src/main/resources/assets/minecraft/textures/blocks/log_oak.png new file mode 100644 index 0000000..914cb5f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/log_oak.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/log_oak_top.png b/src/main/resources/assets/minecraft/textures/blocks/log_oak_top.png new file mode 100644 index 0000000..7a44e77 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/log_oak_top.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/log_spruce.png b/src/main/resources/assets/minecraft/textures/blocks/log_spruce.png new file mode 100644 index 0000000..dc1aa2f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/log_spruce.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/log_spruce_top.png b/src/main/resources/assets/minecraft/textures/blocks/log_spruce_top.png new file mode 100644 index 0000000..280c64e --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/log_spruce_top.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/melon_side.png b/src/main/resources/assets/minecraft/textures/blocks/melon_side.png new file mode 100644 index 0000000..ec7b430 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/melon_side.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/melon_stem_connected.png b/src/main/resources/assets/minecraft/textures/blocks/melon_stem_connected.png new file mode 100644 index 0000000..6a5c10e --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/melon_stem_connected.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/melon_stem_disconnected.png b/src/main/resources/assets/minecraft/textures/blocks/melon_stem_disconnected.png new file mode 100644 index 0000000..38065ef --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/melon_stem_disconnected.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/melon_top.png b/src/main/resources/assets/minecraft/textures/blocks/melon_top.png new file mode 100644 index 0000000..65cf169 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/melon_top.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/mob_spawner.png b/src/main/resources/assets/minecraft/textures/blocks/mob_spawner.png new file mode 100644 index 0000000..7d55217 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/mob_spawner.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/mushroom_block_inside.png b/src/main/resources/assets/minecraft/textures/blocks/mushroom_block_inside.png new file mode 100644 index 0000000..f0e7a04 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/mushroom_block_inside.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/mushroom_block_skin_brown.png b/src/main/resources/assets/minecraft/textures/blocks/mushroom_block_skin_brown.png new file mode 100644 index 0000000..1f52ba8 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/mushroom_block_skin_brown.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/mushroom_block_skin_red.png b/src/main/resources/assets/minecraft/textures/blocks/mushroom_block_skin_red.png new file mode 100644 index 0000000..66cf12c --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/mushroom_block_skin_red.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/mushroom_block_skin_stem.png b/src/main/resources/assets/minecraft/textures/blocks/mushroom_block_skin_stem.png new file mode 100644 index 0000000..83c0840 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/mushroom_block_skin_stem.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/mushroom_brown.png b/src/main/resources/assets/minecraft/textures/blocks/mushroom_brown.png new file mode 100644 index 0000000..bf33d34 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/mushroom_brown.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/mushroom_red.png b/src/main/resources/assets/minecraft/textures/blocks/mushroom_red.png new file mode 100644 index 0000000..1b332b7 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/mushroom_red.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/mycelium_side.png b/src/main/resources/assets/minecraft/textures/blocks/mycelium_side.png new file mode 100644 index 0000000..5547425 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/mycelium_side.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/mycelium_top.png b/src/main/resources/assets/minecraft/textures/blocks/mycelium_top.png new file mode 100644 index 0000000..088a825 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/mycelium_top.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/nether_brick.png b/src/main/resources/assets/minecraft/textures/blocks/nether_brick.png new file mode 100644 index 0000000..caaf66f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/nether_brick.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/nether_wart_stage_0.png b/src/main/resources/assets/minecraft/textures/blocks/nether_wart_stage_0.png new file mode 100644 index 0000000..514a95b --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/nether_wart_stage_0.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/nether_wart_stage_1.png b/src/main/resources/assets/minecraft/textures/blocks/nether_wart_stage_1.png new file mode 100644 index 0000000..b4ad0d1 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/nether_wart_stage_1.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/nether_wart_stage_2.png b/src/main/resources/assets/minecraft/textures/blocks/nether_wart_stage_2.png new file mode 100644 index 0000000..b9b6743 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/nether_wart_stage_2.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/netherrack.png b/src/main/resources/assets/minecraft/textures/blocks/netherrack.png new file mode 100644 index 0000000..88129c4 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/netherrack.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/noteblock.png b/src/main/resources/assets/minecraft/textures/blocks/noteblock.png new file mode 100644 index 0000000..a3c27c1 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/noteblock.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/obsidian.png b/src/main/resources/assets/minecraft/textures/blocks/obsidian.png new file mode 100644 index 0000000..ff0a683 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/obsidian.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/piston_bottom.png b/src/main/resources/assets/minecraft/textures/blocks/piston_bottom.png new file mode 100644 index 0000000..a3a5a08 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/piston_bottom.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/piston_inner.png b/src/main/resources/assets/minecraft/textures/blocks/piston_inner.png new file mode 100644 index 0000000..1043929 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/piston_inner.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/piston_side.png b/src/main/resources/assets/minecraft/textures/blocks/piston_side.png new file mode 100644 index 0000000..634f54a --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/piston_side.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/piston_top_normal.png b/src/main/resources/assets/minecraft/textures/blocks/piston_top_normal.png new file mode 100644 index 0000000..eeaadab --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/piston_top_normal.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/piston_top_sticky.png b/src/main/resources/assets/minecraft/textures/blocks/piston_top_sticky.png new file mode 100644 index 0000000..6ddd4ad --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/piston_top_sticky.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/planks_acacia.png b/src/main/resources/assets/minecraft/textures/blocks/planks_acacia.png new file mode 100644 index 0000000..6858c51 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/planks_acacia.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/planks_big_oak.png b/src/main/resources/assets/minecraft/textures/blocks/planks_big_oak.png new file mode 100644 index 0000000..e3fd4ea --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/planks_big_oak.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/planks_birch.png b/src/main/resources/assets/minecraft/textures/blocks/planks_birch.png new file mode 100644 index 0000000..b113e3a --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/planks_birch.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/planks_jungle.png b/src/main/resources/assets/minecraft/textures/blocks/planks_jungle.png new file mode 100644 index 0000000..e3fe82d --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/planks_jungle.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/planks_oak.png b/src/main/resources/assets/minecraft/textures/blocks/planks_oak.png new file mode 100644 index 0000000..346f77d --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/planks_oak.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/planks_spruce.png b/src/main/resources/assets/minecraft/textures/blocks/planks_spruce.png new file mode 100644 index 0000000..f45fa94 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/planks_spruce.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/portal.png b/src/main/resources/assets/minecraft/textures/blocks/portal.png new file mode 100644 index 0000000..96859e2 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/portal.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/portal.png.mcmeta b/src/main/resources/assets/minecraft/textures/blocks/portal.png.mcmeta new file mode 100644 index 0000000..4f0718a --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/portal.png.mcmeta @@ -0,0 +1,3 @@ +{ + "animation": {} +} \ No newline at end of file diff --git a/src/main/resources/assets/minecraft/textures/blocks/potatoes_stage_0.png b/src/main/resources/assets/minecraft/textures/blocks/potatoes_stage_0.png new file mode 100644 index 0000000..c1ef732 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/potatoes_stage_0.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/potatoes_stage_1.png b/src/main/resources/assets/minecraft/textures/blocks/potatoes_stage_1.png new file mode 100644 index 0000000..1275f4f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/potatoes_stage_1.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/potatoes_stage_2.png b/src/main/resources/assets/minecraft/textures/blocks/potatoes_stage_2.png new file mode 100644 index 0000000..b7347df --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/potatoes_stage_2.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/potatoes_stage_3.png b/src/main/resources/assets/minecraft/textures/blocks/potatoes_stage_3.png new file mode 100644 index 0000000..d7e8185 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/potatoes_stage_3.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/pumpkin_face_off.png b/src/main/resources/assets/minecraft/textures/blocks/pumpkin_face_off.png new file mode 100644 index 0000000..ecef025 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/pumpkin_face_off.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/pumpkin_face_on.png b/src/main/resources/assets/minecraft/textures/blocks/pumpkin_face_on.png new file mode 100644 index 0000000..907f499 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/pumpkin_face_on.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/pumpkin_side.png b/src/main/resources/assets/minecraft/textures/blocks/pumpkin_side.png new file mode 100644 index 0000000..75dfc47 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/pumpkin_side.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/pumpkin_stem_connected.png b/src/main/resources/assets/minecraft/textures/blocks/pumpkin_stem_connected.png new file mode 100644 index 0000000..6a5c10e --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/pumpkin_stem_connected.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/pumpkin_stem_disconnected.png b/src/main/resources/assets/minecraft/textures/blocks/pumpkin_stem_disconnected.png new file mode 100644 index 0000000..38065ef --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/pumpkin_stem_disconnected.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/pumpkin_top.png b/src/main/resources/assets/minecraft/textures/blocks/pumpkin_top.png new file mode 100644 index 0000000..297ce3c --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/pumpkin_top.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/quartz_block_bottom.png b/src/main/resources/assets/minecraft/textures/blocks/quartz_block_bottom.png new file mode 100644 index 0000000..7e16c7c --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/quartz_block_bottom.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/quartz_block_chiseled.png b/src/main/resources/assets/minecraft/textures/blocks/quartz_block_chiseled.png new file mode 100644 index 0000000..80465a1 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/quartz_block_chiseled.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/quartz_block_chiseled_top.png b/src/main/resources/assets/minecraft/textures/blocks/quartz_block_chiseled_top.png new file mode 100644 index 0000000..44073e5 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/quartz_block_chiseled_top.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/quartz_block_lines.png b/src/main/resources/assets/minecraft/textures/blocks/quartz_block_lines.png new file mode 100644 index 0000000..184ecd2 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/quartz_block_lines.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/quartz_block_lines_top.png b/src/main/resources/assets/minecraft/textures/blocks/quartz_block_lines_top.png new file mode 100644 index 0000000..6d20379 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/quartz_block_lines_top.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/quartz_block_side.png b/src/main/resources/assets/minecraft/textures/blocks/quartz_block_side.png new file mode 100644 index 0000000..a2cd2ca --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/quartz_block_side.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/quartz_block_top.png b/src/main/resources/assets/minecraft/textures/blocks/quartz_block_top.png new file mode 100644 index 0000000..a2cd2ca --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/quartz_block_top.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/quartz_ore.png b/src/main/resources/assets/minecraft/textures/blocks/quartz_ore.png new file mode 100644 index 0000000..4d758c1 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/quartz_ore.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/rail_activator.png b/src/main/resources/assets/minecraft/textures/blocks/rail_activator.png new file mode 100644 index 0000000..ce115ba --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/rail_activator.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/rail_activator_powered.png b/src/main/resources/assets/minecraft/textures/blocks/rail_activator_powered.png new file mode 100644 index 0000000..a3aaca9 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/rail_activator_powered.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/rail_detector.png b/src/main/resources/assets/minecraft/textures/blocks/rail_detector.png new file mode 100644 index 0000000..92c1466 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/rail_detector.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/rail_detector_powered.png b/src/main/resources/assets/minecraft/textures/blocks/rail_detector_powered.png new file mode 100644 index 0000000..a1c6e6b --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/rail_detector_powered.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/rail_golden.png b/src/main/resources/assets/minecraft/textures/blocks/rail_golden.png new file mode 100644 index 0000000..1fc52c3 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/rail_golden.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/rail_golden_powered.png b/src/main/resources/assets/minecraft/textures/blocks/rail_golden_powered.png new file mode 100644 index 0000000..bd343be --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/rail_golden_powered.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/rail_normal.png b/src/main/resources/assets/minecraft/textures/blocks/rail_normal.png new file mode 100644 index 0000000..d609236 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/rail_normal.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/rail_normal_turned.png b/src/main/resources/assets/minecraft/textures/blocks/rail_normal_turned.png new file mode 100644 index 0000000..f394a23 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/rail_normal_turned.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/red_sand.png b/src/main/resources/assets/minecraft/textures/blocks/red_sand.png new file mode 100644 index 0000000..b216a42 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/red_sand.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/redstone_block.png b/src/main/resources/assets/minecraft/textures/blocks/redstone_block.png new file mode 100644 index 0000000..fcf6b40 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/redstone_block.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/redstone_dust_cross.png b/src/main/resources/assets/minecraft/textures/blocks/redstone_dust_cross.png new file mode 100644 index 0000000..dcec893 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/redstone_dust_cross.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/redstone_dust_cross_overlay.png b/src/main/resources/assets/minecraft/textures/blocks/redstone_dust_cross_overlay.png new file mode 100644 index 0000000..96729e1 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/redstone_dust_cross_overlay.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/redstone_dust_line.png b/src/main/resources/assets/minecraft/textures/blocks/redstone_dust_line.png new file mode 100644 index 0000000..ff0fb23 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/redstone_dust_line.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/redstone_dust_line_overlay.png b/src/main/resources/assets/minecraft/textures/blocks/redstone_dust_line_overlay.png new file mode 100644 index 0000000..96729e1 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/redstone_dust_line_overlay.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/redstone_lamp_off.png b/src/main/resources/assets/minecraft/textures/blocks/redstone_lamp_off.png new file mode 100644 index 0000000..522765b --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/redstone_lamp_off.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/redstone_lamp_on.png b/src/main/resources/assets/minecraft/textures/blocks/redstone_lamp_on.png new file mode 100644 index 0000000..9562ef3 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/redstone_lamp_on.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/redstone_ore.png b/src/main/resources/assets/minecraft/textures/blocks/redstone_ore.png new file mode 100644 index 0000000..575a488 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/redstone_ore.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/redstone_torch_off.png b/src/main/resources/assets/minecraft/textures/blocks/redstone_torch_off.png new file mode 100644 index 0000000..635eabd --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/redstone_torch_off.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/redstone_torch_on.png b/src/main/resources/assets/minecraft/textures/blocks/redstone_torch_on.png new file mode 100644 index 0000000..2983d6c --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/redstone_torch_on.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/reeds.png b/src/main/resources/assets/minecraft/textures/blocks/reeds.png new file mode 100644 index 0000000..64bbfe0 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/reeds.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/repeater_off.png b/src/main/resources/assets/minecraft/textures/blocks/repeater_off.png new file mode 100644 index 0000000..8634669 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/repeater_off.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/repeater_on.png b/src/main/resources/assets/minecraft/textures/blocks/repeater_on.png new file mode 100644 index 0000000..d71d0d9 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/repeater_on.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/sand.png b/src/main/resources/assets/minecraft/textures/blocks/sand.png new file mode 100644 index 0000000..86b9654 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/sand.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/sandstone_bottom.png b/src/main/resources/assets/minecraft/textures/blocks/sandstone_bottom.png new file mode 100644 index 0000000..e102220 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/sandstone_bottom.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/sandstone_carved.png b/src/main/resources/assets/minecraft/textures/blocks/sandstone_carved.png new file mode 100644 index 0000000..9bd7fa1 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/sandstone_carved.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/sandstone_normal.png b/src/main/resources/assets/minecraft/textures/blocks/sandstone_normal.png new file mode 100644 index 0000000..1b79145 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/sandstone_normal.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/sandstone_smooth.png b/src/main/resources/assets/minecraft/textures/blocks/sandstone_smooth.png new file mode 100644 index 0000000..ef118bd --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/sandstone_smooth.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/sandstone_top.png b/src/main/resources/assets/minecraft/textures/blocks/sandstone_top.png new file mode 100644 index 0000000..bb5b157 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/sandstone_top.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/sapling_acacia.png b/src/main/resources/assets/minecraft/textures/blocks/sapling_acacia.png new file mode 100644 index 0000000..a1215cb --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/sapling_acacia.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/sapling_birch.png b/src/main/resources/assets/minecraft/textures/blocks/sapling_birch.png new file mode 100644 index 0000000..b0dacc5 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/sapling_birch.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/sapling_jungle.png b/src/main/resources/assets/minecraft/textures/blocks/sapling_jungle.png new file mode 100644 index 0000000..4e10b35 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/sapling_jungle.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/sapling_oak.png b/src/main/resources/assets/minecraft/textures/blocks/sapling_oak.png new file mode 100644 index 0000000..1bf1bfa --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/sapling_oak.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/sapling_roofed_oak.png b/src/main/resources/assets/minecraft/textures/blocks/sapling_roofed_oak.png new file mode 100644 index 0000000..dcf5588 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/sapling_roofed_oak.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/sapling_spruce.png b/src/main/resources/assets/minecraft/textures/blocks/sapling_spruce.png new file mode 100644 index 0000000..5767d48 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/sapling_spruce.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/snow.png b/src/main/resources/assets/minecraft/textures/blocks/snow.png new file mode 100644 index 0000000..5c146cd --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/snow.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/soul_sand.png b/src/main/resources/assets/minecraft/textures/blocks/soul_sand.png new file mode 100644 index 0000000..fca7e8f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/soul_sand.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/sponge.png b/src/main/resources/assets/minecraft/textures/blocks/sponge.png new file mode 100644 index 0000000..a850804 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/sponge.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/stone.png b/src/main/resources/assets/minecraft/textures/blocks/stone.png new file mode 100644 index 0000000..87e19ff --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/stone.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/stone_slab_side.png b/src/main/resources/assets/minecraft/textures/blocks/stone_slab_side.png new file mode 100644 index 0000000..fe2a204 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/stone_slab_side.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/stone_slab_top.png b/src/main/resources/assets/minecraft/textures/blocks/stone_slab_top.png new file mode 100644 index 0000000..090657d --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/stone_slab_top.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/stonebrick.png b/src/main/resources/assets/minecraft/textures/blocks/stonebrick.png new file mode 100644 index 0000000..69138cf --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/stonebrick.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/stonebrick_carved.png b/src/main/resources/assets/minecraft/textures/blocks/stonebrick_carved.png new file mode 100644 index 0000000..b7e88db --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/stonebrick_carved.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/stonebrick_cracked.png b/src/main/resources/assets/minecraft/textures/blocks/stonebrick_cracked.png new file mode 100644 index 0000000..918a884 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/stonebrick_cracked.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/stonebrick_mossy.png b/src/main/resources/assets/minecraft/textures/blocks/stonebrick_mossy.png new file mode 100644 index 0000000..5b9fe37 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/stonebrick_mossy.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/tallgrass.png b/src/main/resources/assets/minecraft/textures/blocks/tallgrass.png new file mode 100644 index 0000000..65209fa --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/tallgrass.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/tnt_bottom.png b/src/main/resources/assets/minecraft/textures/blocks/tnt_bottom.png new file mode 100644 index 0000000..cc2e586 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/tnt_bottom.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/tnt_side.png b/src/main/resources/assets/minecraft/textures/blocks/tnt_side.png new file mode 100644 index 0000000..21109fb --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/tnt_side.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/tnt_top.png b/src/main/resources/assets/minecraft/textures/blocks/tnt_top.png new file mode 100644 index 0000000..ceb44b6 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/tnt_top.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/torch_on.png b/src/main/resources/assets/minecraft/textures/blocks/torch_on.png new file mode 100644 index 0000000..a2ce41b --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/torch_on.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/trapdoor.png b/src/main/resources/assets/minecraft/textures/blocks/trapdoor.png new file mode 100644 index 0000000..a7dcccc --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/trapdoor.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/trip_wire.png b/src/main/resources/assets/minecraft/textures/blocks/trip_wire.png new file mode 100644 index 0000000..6a9a72b --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/trip_wire.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/trip_wire_source.png b/src/main/resources/assets/minecraft/textures/blocks/trip_wire_source.png new file mode 100644 index 0000000..fbd464d --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/trip_wire_source.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/vine.png b/src/main/resources/assets/minecraft/textures/blocks/vine.png new file mode 100644 index 0000000..df5e435 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/vine.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/water_flow.png b/src/main/resources/assets/minecraft/textures/blocks/water_flow.png new file mode 100644 index 0000000..e72280c --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/water_flow.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/water_flow.png.mcmeta b/src/main/resources/assets/minecraft/textures/blocks/water_flow.png.mcmeta new file mode 100644 index 0000000..4f0718a --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/water_flow.png.mcmeta @@ -0,0 +1,3 @@ +{ + "animation": {} +} \ No newline at end of file diff --git a/src/main/resources/assets/minecraft/textures/blocks/water_still.png b/src/main/resources/assets/minecraft/textures/blocks/water_still.png new file mode 100644 index 0000000..c7e90b0 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/water_still.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/water_still.png.mcmeta b/src/main/resources/assets/minecraft/textures/blocks/water_still.png.mcmeta new file mode 100644 index 0000000..0645f48 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/water_still.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 2 + } +} diff --git a/src/main/resources/assets/minecraft/textures/blocks/waterlily.png b/src/main/resources/assets/minecraft/textures/blocks/waterlily.png new file mode 100644 index 0000000..f6c84f8 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/waterlily.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/web.png b/src/main/resources/assets/minecraft/textures/blocks/web.png new file mode 100644 index 0000000..7c097f1 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/web.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/wheat_stage_0.png b/src/main/resources/assets/minecraft/textures/blocks/wheat_stage_0.png new file mode 100644 index 0000000..185af6f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/wheat_stage_0.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/wheat_stage_1.png b/src/main/resources/assets/minecraft/textures/blocks/wheat_stage_1.png new file mode 100644 index 0000000..67588c1 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/wheat_stage_1.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/wheat_stage_2.png b/src/main/resources/assets/minecraft/textures/blocks/wheat_stage_2.png new file mode 100644 index 0000000..3d33792 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/wheat_stage_2.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/wheat_stage_3.png b/src/main/resources/assets/minecraft/textures/blocks/wheat_stage_3.png new file mode 100644 index 0000000..4649f78 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/wheat_stage_3.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/wheat_stage_4.png b/src/main/resources/assets/minecraft/textures/blocks/wheat_stage_4.png new file mode 100644 index 0000000..ac04b52 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/wheat_stage_4.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/wheat_stage_5.png b/src/main/resources/assets/minecraft/textures/blocks/wheat_stage_5.png new file mode 100644 index 0000000..1ea81ac --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/wheat_stage_5.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/wheat_stage_6.png b/src/main/resources/assets/minecraft/textures/blocks/wheat_stage_6.png new file mode 100644 index 0000000..cb5f195 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/wheat_stage_6.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/wheat_stage_7.png b/src/main/resources/assets/minecraft/textures/blocks/wheat_stage_7.png new file mode 100644 index 0000000..7acafb3 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/wheat_stage_7.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/wool_colored_black.png b/src/main/resources/assets/minecraft/textures/blocks/wool_colored_black.png new file mode 100644 index 0000000..b74d5c9 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/wool_colored_black.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/wool_colored_blue.png b/src/main/resources/assets/minecraft/textures/blocks/wool_colored_blue.png new file mode 100644 index 0000000..ce9515f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/wool_colored_blue.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/wool_colored_brown.png b/src/main/resources/assets/minecraft/textures/blocks/wool_colored_brown.png new file mode 100644 index 0000000..b4dc3c5 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/wool_colored_brown.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/wool_colored_cyan.png b/src/main/resources/assets/minecraft/textures/blocks/wool_colored_cyan.png new file mode 100644 index 0000000..ca0800a --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/wool_colored_cyan.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/wool_colored_gray.png b/src/main/resources/assets/minecraft/textures/blocks/wool_colored_gray.png new file mode 100644 index 0000000..6409ff2 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/wool_colored_gray.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/wool_colored_green.png b/src/main/resources/assets/minecraft/textures/blocks/wool_colored_green.png new file mode 100644 index 0000000..a7be6d7 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/wool_colored_green.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/wool_colored_light_blue.png b/src/main/resources/assets/minecraft/textures/blocks/wool_colored_light_blue.png new file mode 100644 index 0000000..72d9d9e --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/wool_colored_light_blue.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/wool_colored_lime.png b/src/main/resources/assets/minecraft/textures/blocks/wool_colored_lime.png new file mode 100644 index 0000000..bf56389 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/wool_colored_lime.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/wool_colored_magenta.png b/src/main/resources/assets/minecraft/textures/blocks/wool_colored_magenta.png new file mode 100644 index 0000000..3af6747 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/wool_colored_magenta.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/wool_colored_orange.png b/src/main/resources/assets/minecraft/textures/blocks/wool_colored_orange.png new file mode 100644 index 0000000..eefe6de --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/wool_colored_orange.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/wool_colored_pink.png b/src/main/resources/assets/minecraft/textures/blocks/wool_colored_pink.png new file mode 100644 index 0000000..c2785af --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/wool_colored_pink.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/wool_colored_purple.png b/src/main/resources/assets/minecraft/textures/blocks/wool_colored_purple.png new file mode 100644 index 0000000..76f68d6 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/wool_colored_purple.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/wool_colored_red.png b/src/main/resources/assets/minecraft/textures/blocks/wool_colored_red.png new file mode 100644 index 0000000..0cff7a9 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/wool_colored_red.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/wool_colored_silver.png b/src/main/resources/assets/minecraft/textures/blocks/wool_colored_silver.png new file mode 100644 index 0000000..756d9b0 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/wool_colored_silver.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/wool_colored_white.png b/src/main/resources/assets/minecraft/textures/blocks/wool_colored_white.png new file mode 100644 index 0000000..abc7999 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/wool_colored_white.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/blocks/wool_colored_yellow.png b/src/main/resources/assets/minecraft/textures/blocks/wool_colored_yellow.png new file mode 100644 index 0000000..4babaaa --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/blocks/wool_colored_yellow.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/colormap/foliage.png b/src/main/resources/assets/minecraft/textures/colormap/foliage.png new file mode 100644 index 0000000..dcc119e --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/colormap/foliage.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/colormap/grass.png b/src/main/resources/assets/minecraft/textures/colormap/grass.png new file mode 100644 index 0000000..484a9a6 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/colormap/grass.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/arrow.png b/src/main/resources/assets/minecraft/textures/entity/arrow.png new file mode 100644 index 0000000..3afa604 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/arrow.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/bat.png b/src/main/resources/assets/minecraft/textures/entity/bat.png new file mode 100644 index 0000000..803860e --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/bat.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/beacon_beam.png b/src/main/resources/assets/minecraft/textures/entity/beacon_beam.png new file mode 100644 index 0000000..67545b4 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/beacon_beam.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/blaze.png b/src/main/resources/assets/minecraft/textures/entity/blaze.png new file mode 100644 index 0000000..19cdbb5 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/blaze.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/boat.png b/src/main/resources/assets/minecraft/textures/entity/boat.png new file mode 100644 index 0000000..9b58965 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/boat.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/cat/black.png b/src/main/resources/assets/minecraft/textures/entity/cat/black.png new file mode 100644 index 0000000..422908f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/cat/black.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/cat/ocelot.png b/src/main/resources/assets/minecraft/textures/entity/cat/ocelot.png new file mode 100644 index 0000000..6b5064e --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/cat/ocelot.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/cat/red.png b/src/main/resources/assets/minecraft/textures/entity/cat/red.png new file mode 100644 index 0000000..17b6de5 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/cat/red.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/cat/siamese.png b/src/main/resources/assets/minecraft/textures/entity/cat/siamese.png new file mode 100644 index 0000000..cfed948 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/cat/siamese.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/chest/christmas.png b/src/main/resources/assets/minecraft/textures/entity/chest/christmas.png new file mode 100644 index 0000000..4459112 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/chest/christmas.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/chest/christmas_double.png b/src/main/resources/assets/minecraft/textures/entity/chest/christmas_double.png new file mode 100644 index 0000000..9e44eeb --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/chest/christmas_double.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/chest/ender.png b/src/main/resources/assets/minecraft/textures/entity/chest/ender.png new file mode 100644 index 0000000..3631d0d --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/chest/ender.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/chest/normal.png b/src/main/resources/assets/minecraft/textures/entity/chest/normal.png new file mode 100644 index 0000000..2e3d7fd --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/chest/normal.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/chest/normal_double.png b/src/main/resources/assets/minecraft/textures/entity/chest/normal_double.png new file mode 100644 index 0000000..0168338 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/chest/normal_double.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/chest/trapped.png b/src/main/resources/assets/minecraft/textures/entity/chest/trapped.png new file mode 100644 index 0000000..3aef190 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/chest/trapped.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/chest/trapped_double.png b/src/main/resources/assets/minecraft/textures/entity/chest/trapped_double.png new file mode 100644 index 0000000..00eebe5 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/chest/trapped_double.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/chicken.png b/src/main/resources/assets/minecraft/textures/entity/chicken.png new file mode 100644 index 0000000..e24d550 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/chicken.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/cow/cow.png b/src/main/resources/assets/minecraft/textures/entity/cow/cow.png new file mode 100644 index 0000000..f1320c3 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/cow/cow.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/cow/mooshroom.png b/src/main/resources/assets/minecraft/textures/entity/cow/mooshroom.png new file mode 100644 index 0000000..905f160 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/cow/mooshroom.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/creeper/creeper.png b/src/main/resources/assets/minecraft/textures/entity/creeper/creeper.png new file mode 100644 index 0000000..abdb540 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/creeper/creeper.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/creeper/creeper_armor.png b/src/main/resources/assets/minecraft/textures/entity/creeper/creeper_armor.png new file mode 100644 index 0000000..119f6ff --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/creeper/creeper_armor.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/enchanting_table_book.png b/src/main/resources/assets/minecraft/textures/entity/enchanting_table_book.png new file mode 100644 index 0000000..619e7a5 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/enchanting_table_book.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/end_portal.png b/src/main/resources/assets/minecraft/textures/entity/end_portal.png new file mode 100644 index 0000000..d5d8569 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/end_portal.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/endercrystal/endercrystal.png b/src/main/resources/assets/minecraft/textures/entity/endercrystal/endercrystal.png new file mode 100644 index 0000000..8b3668a --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/endercrystal/endercrystal.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/endercrystal/endercrystal_beam.png b/src/main/resources/assets/minecraft/textures/entity/endercrystal/endercrystal_beam.png new file mode 100644 index 0000000..1259a5d --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/endercrystal/endercrystal_beam.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/enderdragon/dragon.png b/src/main/resources/assets/minecraft/textures/entity/enderdragon/dragon.png new file mode 100644 index 0000000..b8a680c --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/enderdragon/dragon.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/enderdragon/dragon_exploding.png b/src/main/resources/assets/minecraft/textures/entity/enderdragon/dragon_exploding.png new file mode 100644 index 0000000..ca5c949 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/enderdragon/dragon_exploding.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/enderdragon/dragon_eyes.png b/src/main/resources/assets/minecraft/textures/entity/enderdragon/dragon_eyes.png new file mode 100644 index 0000000..147b303 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/enderdragon/dragon_eyes.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/enderman/enderman.png b/src/main/resources/assets/minecraft/textures/entity/enderman/enderman.png new file mode 100644 index 0000000..ab23cb9 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/enderman/enderman.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/enderman/enderman_eyes.png b/src/main/resources/assets/minecraft/textures/entity/enderman/enderman_eyes.png new file mode 100644 index 0000000..0804402 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/enderman/enderman_eyes.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/experience_orb.png b/src/main/resources/assets/minecraft/textures/entity/experience_orb.png new file mode 100644 index 0000000..92f9d0f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/experience_orb.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/explosion.png b/src/main/resources/assets/minecraft/textures/entity/explosion.png new file mode 100644 index 0000000..c309409 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/explosion.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/ghast/ghast.png b/src/main/resources/assets/minecraft/textures/entity/ghast/ghast.png new file mode 100644 index 0000000..dd63bc1 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/ghast/ghast.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/ghast/ghast_shooting.png b/src/main/resources/assets/minecraft/textures/entity/ghast/ghast_shooting.png new file mode 100644 index 0000000..5d9be29 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/ghast/ghast_shooting.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/horse/armor/horse_armor_diamond.png b/src/main/resources/assets/minecraft/textures/entity/horse/armor/horse_armor_diamond.png new file mode 100644 index 0000000..39068f2 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/horse/armor/horse_armor_diamond.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/horse/armor/horse_armor_gold.png b/src/main/resources/assets/minecraft/textures/entity/horse/armor/horse_armor_gold.png new file mode 100644 index 0000000..4a0786d --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/horse/armor/horse_armor_gold.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/horse/armor/horse_armor_iron.png b/src/main/resources/assets/minecraft/textures/entity/horse/armor/horse_armor_iron.png new file mode 100644 index 0000000..533b2dd --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/horse/armor/horse_armor_iron.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/horse/donkey.png b/src/main/resources/assets/minecraft/textures/entity/horse/donkey.png new file mode 100644 index 0000000..b94bc63 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/horse/donkey.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/horse/horse_black.png b/src/main/resources/assets/minecraft/textures/entity/horse/horse_black.png new file mode 100644 index 0000000..dde716e --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/horse/horse_black.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/horse/horse_brown.png b/src/main/resources/assets/minecraft/textures/entity/horse/horse_brown.png new file mode 100644 index 0000000..ec0158f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/horse/horse_brown.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/horse/horse_chestnut.png b/src/main/resources/assets/minecraft/textures/entity/horse/horse_chestnut.png new file mode 100644 index 0000000..40322ff --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/horse/horse_chestnut.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/horse/horse_creamy.png b/src/main/resources/assets/minecraft/textures/entity/horse/horse_creamy.png new file mode 100644 index 0000000..bc42bcc --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/horse/horse_creamy.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/horse/horse_darkbrown.png b/src/main/resources/assets/minecraft/textures/entity/horse/horse_darkbrown.png new file mode 100644 index 0000000..b38e914 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/horse/horse_darkbrown.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/horse/horse_gray.png b/src/main/resources/assets/minecraft/textures/entity/horse/horse_gray.png new file mode 100644 index 0000000..4987532 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/horse/horse_gray.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/horse/horse_markings_blackdots.png b/src/main/resources/assets/minecraft/textures/entity/horse/horse_markings_blackdots.png new file mode 100644 index 0000000..7320648 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/horse/horse_markings_blackdots.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/horse/horse_markings_white.png b/src/main/resources/assets/minecraft/textures/entity/horse/horse_markings_white.png new file mode 100644 index 0000000..b1f0a69 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/horse/horse_markings_white.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/horse/horse_markings_whitedots.png b/src/main/resources/assets/minecraft/textures/entity/horse/horse_markings_whitedots.png new file mode 100644 index 0000000..20e1954 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/horse/horse_markings_whitedots.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/horse/horse_markings_whitefield.png b/src/main/resources/assets/minecraft/textures/entity/horse/horse_markings_whitefield.png new file mode 100644 index 0000000..baa2c06 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/horse/horse_markings_whitefield.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/horse/horse_skeleton.png b/src/main/resources/assets/minecraft/textures/entity/horse/horse_skeleton.png new file mode 100644 index 0000000..29d4ed5 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/horse/horse_skeleton.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/horse/horse_white.png b/src/main/resources/assets/minecraft/textures/entity/horse/horse_white.png new file mode 100644 index 0000000..e90e6e7 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/horse/horse_white.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/horse/horse_zombie.png b/src/main/resources/assets/minecraft/textures/entity/horse/horse_zombie.png new file mode 100644 index 0000000..22d55fa --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/horse/horse_zombie.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/horse/mule.png b/src/main/resources/assets/minecraft/textures/entity/horse/mule.png new file mode 100644 index 0000000..241bdaa --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/horse/mule.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/iron_golem.png b/src/main/resources/assets/minecraft/textures/entity/iron_golem.png new file mode 100644 index 0000000..f9f6465 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/iron_golem.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/lead_knot.png b/src/main/resources/assets/minecraft/textures/entity/lead_knot.png new file mode 100644 index 0000000..ab4d3b3 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/lead_knot.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/minecart.png b/src/main/resources/assets/minecraft/textures/entity/minecart.png new file mode 100644 index 0000000..7ad7b54 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/minecart.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/pig/pig.png b/src/main/resources/assets/minecraft/textures/entity/pig/pig.png new file mode 100644 index 0000000..0a9532f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/pig/pig.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/pig/pig_saddle.png b/src/main/resources/assets/minecraft/textures/entity/pig/pig_saddle.png new file mode 100644 index 0000000..640ea76 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/pig/pig_saddle.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/sheep/sheep.png b/src/main/resources/assets/minecraft/textures/entity/sheep/sheep.png new file mode 100644 index 0000000..d9fe93f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/sheep/sheep.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/sheep/sheep_fur.png b/src/main/resources/assets/minecraft/textures/entity/sheep/sheep_fur.png new file mode 100644 index 0000000..623340b --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/sheep/sheep_fur.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/sign.png b/src/main/resources/assets/minecraft/textures/entity/sign.png new file mode 100644 index 0000000..e22e2f7 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/sign.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/silverfish.png b/src/main/resources/assets/minecraft/textures/entity/silverfish.png new file mode 100644 index 0000000..416fa16 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/silverfish.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/skeleton/skeleton.png b/src/main/resources/assets/minecraft/textures/entity/skeleton/skeleton.png new file mode 100644 index 0000000..184b585 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/skeleton/skeleton.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/skeleton/wither_skeleton.png b/src/main/resources/assets/minecraft/textures/entity/skeleton/wither_skeleton.png new file mode 100644 index 0000000..b0db19d --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/skeleton/wither_skeleton.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/slime/magmacube.png b/src/main/resources/assets/minecraft/textures/entity/slime/magmacube.png new file mode 100644 index 0000000..c1b397f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/slime/magmacube.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/slime/slime.png b/src/main/resources/assets/minecraft/textures/entity/slime/slime.png new file mode 100644 index 0000000..96edcf6 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/slime/slime.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/snowman.png b/src/main/resources/assets/minecraft/textures/entity/snowman.png new file mode 100644 index 0000000..568d5f6 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/snowman.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/spider/cave_spider.png b/src/main/resources/assets/minecraft/textures/entity/spider/cave_spider.png new file mode 100644 index 0000000..934f1ea --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/spider/cave_spider.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/spider/spider.png b/src/main/resources/assets/minecraft/textures/entity/spider/spider.png new file mode 100644 index 0000000..3a8c779 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/spider/spider.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/spider_eyes.png b/src/main/resources/assets/minecraft/textures/entity/spider_eyes.png new file mode 100644 index 0000000..6b80a06 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/spider_eyes.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/squid.png b/src/main/resources/assets/minecraft/textures/entity/squid.png new file mode 100644 index 0000000..f285388 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/squid.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/steve.png b/src/main/resources/assets/minecraft/textures/entity/steve.png new file mode 100644 index 0000000..6650185 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/steve.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/villager/butcher.png b/src/main/resources/assets/minecraft/textures/entity/villager/butcher.png new file mode 100644 index 0000000..f1c07d4 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/villager/butcher.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/villager/farmer.png b/src/main/resources/assets/minecraft/textures/entity/villager/farmer.png new file mode 100644 index 0000000..970c179 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/villager/farmer.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/villager/librarian.png b/src/main/resources/assets/minecraft/textures/entity/villager/librarian.png new file mode 100644 index 0000000..b071cd3 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/villager/librarian.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/villager/priest.png b/src/main/resources/assets/minecraft/textures/entity/villager/priest.png new file mode 100644 index 0000000..35054ce --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/villager/priest.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/villager/smith.png b/src/main/resources/assets/minecraft/textures/entity/villager/smith.png new file mode 100644 index 0000000..965da7f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/villager/smith.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/villager/villager.png b/src/main/resources/assets/minecraft/textures/entity/villager/villager.png new file mode 100644 index 0000000..52de8e7 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/villager/villager.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/witch.png b/src/main/resources/assets/minecraft/textures/entity/witch.png new file mode 100644 index 0000000..2403570 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/witch.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/wither/wither.png b/src/main/resources/assets/minecraft/textures/entity/wither/wither.png new file mode 100644 index 0000000..0882d05 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/wither/wither.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/wither/wither_armor.png b/src/main/resources/assets/minecraft/textures/entity/wither/wither_armor.png new file mode 100644 index 0000000..a6b5cf5 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/wither/wither_armor.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/wither/wither_invulnerable.png b/src/main/resources/assets/minecraft/textures/entity/wither/wither_invulnerable.png new file mode 100644 index 0000000..717750b --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/wither/wither_invulnerable.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/wolf/wolf.png b/src/main/resources/assets/minecraft/textures/entity/wolf/wolf.png new file mode 100644 index 0000000..f37ef81 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/wolf/wolf.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/wolf/wolf_angry.png b/src/main/resources/assets/minecraft/textures/entity/wolf/wolf_angry.png new file mode 100644 index 0000000..7891ce9 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/wolf/wolf_angry.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/wolf/wolf_collar.png b/src/main/resources/assets/minecraft/textures/entity/wolf/wolf_collar.png new file mode 100644 index 0000000..ae1c920 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/wolf/wolf_collar.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/wolf/wolf_tame.png b/src/main/resources/assets/minecraft/textures/entity/wolf/wolf_tame.png new file mode 100644 index 0000000..f1236d2 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/wolf/wolf_tame.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/zombie/zombie.png b/src/main/resources/assets/minecraft/textures/entity/zombie/zombie.png new file mode 100644 index 0000000..22ff8f9 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/zombie/zombie.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/zombie/zombie_villager.png b/src/main/resources/assets/minecraft/textures/entity/zombie/zombie_villager.png new file mode 100644 index 0000000..349f9c2 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/zombie/zombie_villager.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/entity/zombie_pigman.png b/src/main/resources/assets/minecraft/textures/entity/zombie_pigman.png new file mode 100644 index 0000000..e95cc4c --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/entity/zombie_pigman.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/environment/clouds.png b/src/main/resources/assets/minecraft/textures/environment/clouds.png new file mode 100644 index 0000000..a67c44d --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/environment/clouds.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/environment/end_sky.png b/src/main/resources/assets/minecraft/textures/environment/end_sky.png new file mode 100644 index 0000000..094b309 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/environment/end_sky.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/environment/moon_phases.png b/src/main/resources/assets/minecraft/textures/environment/moon_phases.png new file mode 100644 index 0000000..cdba8d1 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/environment/moon_phases.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/environment/rain.png b/src/main/resources/assets/minecraft/textures/environment/rain.png new file mode 100644 index 0000000..2dc4b1c --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/environment/rain.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/environment/snow.png b/src/main/resources/assets/minecraft/textures/environment/snow.png new file mode 100644 index 0000000..1898903 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/environment/snow.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/environment/sun.png b/src/main/resources/assets/minecraft/textures/environment/sun.png new file mode 100644 index 0000000..08de644 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/environment/sun.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/ascii.png b/src/main/resources/assets/minecraft/textures/font/ascii.png new file mode 100644 index 0000000..587966d --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/ascii.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/ascii_sga.png b/src/main/resources/assets/minecraft/textures/font/ascii_sga.png new file mode 100644 index 0000000..f443b4a --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/ascii_sga.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_00.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_00.png new file mode 100644 index 0000000..44fd12f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_00.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_01.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_01.png new file mode 100644 index 0000000..ddac030 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_01.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_02.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_02.png new file mode 100644 index 0000000..dc1335a --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_02.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_03.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_03.png new file mode 100644 index 0000000..6ff0257 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_03.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_04.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_04.png new file mode 100644 index 0000000..be3e833 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_04.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_05.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_05.png new file mode 100644 index 0000000..9b58804 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_05.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_06.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_06.png new file mode 100644 index 0000000..ed74e78 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_06.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_07.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_07.png new file mode 100644 index 0000000..b532177 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_07.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_09.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_09.png new file mode 100644 index 0000000..083b911 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_09.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_0a.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_0a.png new file mode 100644 index 0000000..0190c11 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_0a.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_0b.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_0b.png new file mode 100644 index 0000000..4d0af48 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_0b.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_0c.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_0c.png new file mode 100644 index 0000000..773297d --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_0c.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_0d.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_0d.png new file mode 100644 index 0000000..5f52231 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_0d.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_0e.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_0e.png new file mode 100644 index 0000000..531ca7d --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_0e.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_0f.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_0f.png new file mode 100644 index 0000000..7b879fc --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_0f.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_10.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_10.png new file mode 100644 index 0000000..53f056c --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_10.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_11.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_11.png new file mode 100644 index 0000000..a9d5c11 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_11.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_12.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_12.png new file mode 100644 index 0000000..d20a864 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_12.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_13.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_13.png new file mode 100644 index 0000000..bbb0641 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_13.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_14.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_14.png new file mode 100644 index 0000000..ffd8e42 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_14.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_15.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_15.png new file mode 100644 index 0000000..ccfcae6 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_15.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_16.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_16.png new file mode 100644 index 0000000..d02c557 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_16.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_17.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_17.png new file mode 100644 index 0000000..fed5b6e --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_17.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_18.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_18.png new file mode 100644 index 0000000..97394d0 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_18.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_19.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_19.png new file mode 100644 index 0000000..6929413 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_19.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_1a.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_1a.png new file mode 100644 index 0000000..d3a1b98 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_1a.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_1b.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_1b.png new file mode 100644 index 0000000..9e0adf7 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_1b.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_1c.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_1c.png new file mode 100644 index 0000000..14d4890 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_1c.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_1d.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_1d.png new file mode 100644 index 0000000..1924226 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_1d.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_1e.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_1e.png new file mode 100644 index 0000000..cce20e3 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_1e.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_1f.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_1f.png new file mode 100644 index 0000000..bdaf22f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_1f.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_20.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_20.png new file mode 100644 index 0000000..ba948e9 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_20.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_21.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_21.png new file mode 100644 index 0000000..998f2f9 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_21.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_22.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_22.png new file mode 100644 index 0000000..c3fd5dd --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_22.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_23.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_23.png new file mode 100644 index 0000000..9c2b2dc --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_23.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_24.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_24.png new file mode 100644 index 0000000..d6cc8ae --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_24.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_25.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_25.png new file mode 100644 index 0000000..ee7535d --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_25.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_26.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_26.png new file mode 100644 index 0000000..93aa960 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_26.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_27.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_27.png new file mode 100644 index 0000000..92f4501 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_27.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_28.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_28.png new file mode 100644 index 0000000..5f96e1b --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_28.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_29.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_29.png new file mode 100644 index 0000000..4558220 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_29.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_2a.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_2a.png new file mode 100644 index 0000000..87e0e0c --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_2a.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_2b.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_2b.png new file mode 100644 index 0000000..722edf0 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_2b.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_2c.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_2c.png new file mode 100644 index 0000000..51830f7 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_2c.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_2d.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_2d.png new file mode 100644 index 0000000..dfafa53 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_2d.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_2e.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_2e.png new file mode 100644 index 0000000..2aea04b --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_2e.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_2f.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_2f.png new file mode 100644 index 0000000..bff5f8e --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_2f.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_30.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_30.png new file mode 100644 index 0000000..5ccba75 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_30.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_31.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_31.png new file mode 100644 index 0000000..44fc5e5 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_31.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_32.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_32.png new file mode 100644 index 0000000..4858d08 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_32.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_33.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_33.png new file mode 100644 index 0000000..ab67072 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_33.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_34.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_34.png new file mode 100644 index 0000000..fd8fca9 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_34.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_35.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_35.png new file mode 100644 index 0000000..603dc02 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_35.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_36.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_36.png new file mode 100644 index 0000000..778c190 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_36.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_37.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_37.png new file mode 100644 index 0000000..3032a23 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_37.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_38.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_38.png new file mode 100644 index 0000000..9b637bd --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_38.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_39.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_39.png new file mode 100644 index 0000000..2f93850 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_39.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_3a.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_3a.png new file mode 100644 index 0000000..cdf4944 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_3a.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_3b.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_3b.png new file mode 100644 index 0000000..10e8502 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_3b.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_3c.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_3c.png new file mode 100644 index 0000000..022fea5 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_3c.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_3d.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_3d.png new file mode 100644 index 0000000..01ea1d1 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_3d.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_3e.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_3e.png new file mode 100644 index 0000000..3bdf7f8 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_3e.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_3f.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_3f.png new file mode 100644 index 0000000..3fd5249 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_3f.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_40.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_40.png new file mode 100644 index 0000000..544f89e --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_40.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_41.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_41.png new file mode 100644 index 0000000..729fdaf --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_41.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_42.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_42.png new file mode 100644 index 0000000..755e546 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_42.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_43.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_43.png new file mode 100644 index 0000000..6069d0d --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_43.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_44.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_44.png new file mode 100644 index 0000000..845c364 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_44.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_45.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_45.png new file mode 100644 index 0000000..294c78d --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_45.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_46.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_46.png new file mode 100644 index 0000000..ee5e629 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_46.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_47.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_47.png new file mode 100644 index 0000000..55cb0c0 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_47.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_48.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_48.png new file mode 100644 index 0000000..7652211 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_48.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_49.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_49.png new file mode 100644 index 0000000..b736232 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_49.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_4a.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_4a.png new file mode 100644 index 0000000..d3419bd --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_4a.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_4b.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_4b.png new file mode 100644 index 0000000..5e02ad3 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_4b.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_4c.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_4c.png new file mode 100644 index 0000000..11c6b31 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_4c.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_4d.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_4d.png new file mode 100644 index 0000000..3eb224a --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_4d.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_4e.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_4e.png new file mode 100644 index 0000000..11a78ba --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_4e.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_4f.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_4f.png new file mode 100644 index 0000000..b4c9fab --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_4f.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_50.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_50.png new file mode 100644 index 0000000..ff73d23 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_50.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_51.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_51.png new file mode 100644 index 0000000..6e0eae9 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_51.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_52.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_52.png new file mode 100644 index 0000000..6f10fcb --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_52.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_53.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_53.png new file mode 100644 index 0000000..60d478e --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_53.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_54.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_54.png new file mode 100644 index 0000000..ac75bdd --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_54.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_55.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_55.png new file mode 100644 index 0000000..3d122d2 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_55.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_56.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_56.png new file mode 100644 index 0000000..576d07f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_56.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_57.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_57.png new file mode 100644 index 0000000..545da73 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_57.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_58.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_58.png new file mode 100644 index 0000000..941542e --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_58.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_59.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_59.png new file mode 100644 index 0000000..56f0102 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_59.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_5a.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_5a.png new file mode 100644 index 0000000..c14f1b1 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_5a.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_5b.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_5b.png new file mode 100644 index 0000000..f418e4c --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_5b.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_5c.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_5c.png new file mode 100644 index 0000000..e7efae6 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_5c.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_5d.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_5d.png new file mode 100644 index 0000000..7355fd3 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_5d.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_5e.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_5e.png new file mode 100644 index 0000000..abfd3af --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_5e.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_5f.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_5f.png new file mode 100644 index 0000000..5a64b50 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_5f.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_60.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_60.png new file mode 100644 index 0000000..8166f15 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_60.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_61.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_61.png new file mode 100644 index 0000000..d11cd8a --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_61.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_62.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_62.png new file mode 100644 index 0000000..f7b9a5b --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_62.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_63.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_63.png new file mode 100644 index 0000000..5d4a8cc --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_63.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_64.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_64.png new file mode 100644 index 0000000..bc43210 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_64.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_65.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_65.png new file mode 100644 index 0000000..42144c1 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_65.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_66.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_66.png new file mode 100644 index 0000000..a65f25e --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_66.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_67.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_67.png new file mode 100644 index 0000000..a115bb8 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_67.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_68.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_68.png new file mode 100644 index 0000000..d47938b --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_68.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_69.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_69.png new file mode 100644 index 0000000..c36e640 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_69.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_6a.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_6a.png new file mode 100644 index 0000000..5265d07 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_6a.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_6b.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_6b.png new file mode 100644 index 0000000..6f207cc --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_6b.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_6c.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_6c.png new file mode 100644 index 0000000..6ffad7e --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_6c.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_6d.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_6d.png new file mode 100644 index 0000000..0fa88e3 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_6d.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_6e.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_6e.png new file mode 100644 index 0000000..301513e --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_6e.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_6f.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_6f.png new file mode 100644 index 0000000..a24cfff --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_6f.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_70.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_70.png new file mode 100644 index 0000000..2cec746 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_70.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_71.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_71.png new file mode 100644 index 0000000..1592ff4 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_71.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_72.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_72.png new file mode 100644 index 0000000..856eedc --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_72.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_73.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_73.png new file mode 100644 index 0000000..a7a2151 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_73.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_74.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_74.png new file mode 100644 index 0000000..a1b034a --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_74.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_75.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_75.png new file mode 100644 index 0000000..512dc16 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_75.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_76.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_76.png new file mode 100644 index 0000000..12a45ff --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_76.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_77.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_77.png new file mode 100644 index 0000000..d763fba --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_77.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_78.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_78.png new file mode 100644 index 0000000..846c060 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_78.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_79.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_79.png new file mode 100644 index 0000000..f887cae --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_79.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_7a.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_7a.png new file mode 100644 index 0000000..90d5561 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_7a.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_7b.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_7b.png new file mode 100644 index 0000000..2932cee --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_7b.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_7c.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_7c.png new file mode 100644 index 0000000..416a21b --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_7c.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_7d.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_7d.png new file mode 100644 index 0000000..2e12e13 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_7d.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_7e.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_7e.png new file mode 100644 index 0000000..952bfab --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_7e.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_7f.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_7f.png new file mode 100644 index 0000000..d3d275c --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_7f.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_80.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_80.png new file mode 100644 index 0000000..044ac3e --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_80.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_81.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_81.png new file mode 100644 index 0000000..913a4ca --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_81.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_82.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_82.png new file mode 100644 index 0000000..19b8ded --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_82.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_83.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_83.png new file mode 100644 index 0000000..ef2d794 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_83.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_84.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_84.png new file mode 100644 index 0000000..74a6a53 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_84.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_85.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_85.png new file mode 100644 index 0000000..73cb2f9 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_85.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_86.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_86.png new file mode 100644 index 0000000..135d6fc --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_86.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_87.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_87.png new file mode 100644 index 0000000..bef88db --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_87.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_88.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_88.png new file mode 100644 index 0000000..698ff80 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_88.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_89.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_89.png new file mode 100644 index 0000000..a3820ee --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_89.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_8a.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_8a.png new file mode 100644 index 0000000..beb9024 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_8a.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_8b.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_8b.png new file mode 100644 index 0000000..7f978ab --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_8b.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_8c.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_8c.png new file mode 100644 index 0000000..3ed4594 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_8c.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_8d.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_8d.png new file mode 100644 index 0000000..8d79123 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_8d.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_8e.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_8e.png new file mode 100644 index 0000000..d82000b --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_8e.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_8f.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_8f.png new file mode 100644 index 0000000..b8c8328 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_8f.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_90.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_90.png new file mode 100644 index 0000000..132974b --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_90.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_91.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_91.png new file mode 100644 index 0000000..b8e09ae --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_91.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_92.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_92.png new file mode 100644 index 0000000..9244661 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_92.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_93.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_93.png new file mode 100644 index 0000000..f71d835 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_93.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_94.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_94.png new file mode 100644 index 0000000..fa68d81 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_94.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_95.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_95.png new file mode 100644 index 0000000..346bc36 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_95.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_96.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_96.png new file mode 100644 index 0000000..bbd1772 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_96.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_97.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_97.png new file mode 100644 index 0000000..2fd136b --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_97.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_98.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_98.png new file mode 100644 index 0000000..9319c0b --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_98.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_99.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_99.png new file mode 100644 index 0000000..2bb7f3e --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_99.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_9a.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_9a.png new file mode 100644 index 0000000..cbdd91e --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_9a.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_9b.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_9b.png new file mode 100644 index 0000000..8a96209 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_9b.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_9c.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_9c.png new file mode 100644 index 0000000..8e977ff --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_9c.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_9d.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_9d.png new file mode 100644 index 0000000..5041d6a --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_9d.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_9e.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_9e.png new file mode 100644 index 0000000..1cb0a5b --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_9e.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_9f.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_9f.png new file mode 100644 index 0000000..d987326 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_9f.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_a0.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_a0.png new file mode 100644 index 0000000..8c47db0 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_a0.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_a1.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_a1.png new file mode 100644 index 0000000..5ede7e7 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_a1.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_a2.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_a2.png new file mode 100644 index 0000000..a8c6ac1 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_a2.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_a3.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_a3.png new file mode 100644 index 0000000..7cc8448 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_a3.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_a4.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_a4.png new file mode 100644 index 0000000..dc00e27 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_a4.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_a5.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_a5.png new file mode 100644 index 0000000..eccfa47 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_a5.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_a6.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_a6.png new file mode 100644 index 0000000..dcac87f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_a6.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_a7.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_a7.png new file mode 100644 index 0000000..76c1ce2 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_a7.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_a8.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_a8.png new file mode 100644 index 0000000..a022390 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_a8.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_a9.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_a9.png new file mode 100644 index 0000000..a35159a --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_a9.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_aa.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_aa.png new file mode 100644 index 0000000..da1b615 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_aa.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_ab.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_ab.png new file mode 100644 index 0000000..0e45eae --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_ab.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_ac.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_ac.png new file mode 100644 index 0000000..04d4d59 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_ac.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_ad.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_ad.png new file mode 100644 index 0000000..3834337 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_ad.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_ae.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_ae.png new file mode 100644 index 0000000..1445e68 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_ae.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_af.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_af.png new file mode 100644 index 0000000..ea945dc --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_af.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_b0.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_b0.png new file mode 100644 index 0000000..84b4885 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_b0.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_b1.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_b1.png new file mode 100644 index 0000000..5f64672 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_b1.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_b2.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_b2.png new file mode 100644 index 0000000..8551db8 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_b2.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_b3.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_b3.png new file mode 100644 index 0000000..b954159 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_b3.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_b4.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_b4.png new file mode 100644 index 0000000..65991a4 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_b4.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_b5.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_b5.png new file mode 100644 index 0000000..3e6391b --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_b5.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_b6.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_b6.png new file mode 100644 index 0000000..df7c0f7 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_b6.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_b7.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_b7.png new file mode 100644 index 0000000..9142cad --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_b7.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_b8.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_b8.png new file mode 100644 index 0000000..5b18d12 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_b8.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_b9.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_b9.png new file mode 100644 index 0000000..0d212f0 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_b9.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_ba.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_ba.png new file mode 100644 index 0000000..696cca9 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_ba.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_bb.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_bb.png new file mode 100644 index 0000000..5a2544c --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_bb.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_bc.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_bc.png new file mode 100644 index 0000000..df37526 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_bc.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_bd.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_bd.png new file mode 100644 index 0000000..aed7803 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_bd.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_be.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_be.png new file mode 100644 index 0000000..0da2254 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_be.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_bf.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_bf.png new file mode 100644 index 0000000..1f6a248 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_bf.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_c0.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_c0.png new file mode 100644 index 0000000..0610d67 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_c0.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_c1.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_c1.png new file mode 100644 index 0000000..a95ca9b --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_c1.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_c2.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_c2.png new file mode 100644 index 0000000..1d104a0 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_c2.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_c3.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_c3.png new file mode 100644 index 0000000..6470dd8 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_c3.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_c4.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_c4.png new file mode 100644 index 0000000..e8c3105 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_c4.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_c5.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_c5.png new file mode 100644 index 0000000..d89f288 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_c5.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_c6.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_c6.png new file mode 100644 index 0000000..004091d --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_c6.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_c7.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_c7.png new file mode 100644 index 0000000..f64f6b4 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_c7.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_c8.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_c8.png new file mode 100644 index 0000000..75f8a50 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_c8.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_c9.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_c9.png new file mode 100644 index 0000000..fbd9435 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_c9.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_ca.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_ca.png new file mode 100644 index 0000000..112b9c6 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_ca.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_cb.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_cb.png new file mode 100644 index 0000000..c0549b5 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_cb.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_cc.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_cc.png new file mode 100644 index 0000000..0684431 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_cc.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_cd.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_cd.png new file mode 100644 index 0000000..9fdc54d --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_cd.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_ce.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_ce.png new file mode 100644 index 0000000..958a96b --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_ce.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_cf.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_cf.png new file mode 100644 index 0000000..4106f1b --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_cf.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_d0.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_d0.png new file mode 100644 index 0000000..546b014 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_d0.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_d1.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_d1.png new file mode 100644 index 0000000..6d67bf1 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_d1.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_d2.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_d2.png new file mode 100644 index 0000000..c4ae511 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_d2.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_d3.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_d3.png new file mode 100644 index 0000000..576c9ea --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_d3.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_d4.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_d4.png new file mode 100644 index 0000000..14be6c7 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_d4.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_d5.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_d5.png new file mode 100644 index 0000000..3c41836 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_d5.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_d6.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_d6.png new file mode 100644 index 0000000..27424b1 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_d6.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_d7.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_d7.png new file mode 100644 index 0000000..d8772d8 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_d7.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_f9.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_f9.png new file mode 100644 index 0000000..e723235 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_f9.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_fa.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_fa.png new file mode 100644 index 0000000..d78dcfe --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_fa.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_fb.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_fb.png new file mode 100644 index 0000000..5423c86 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_fb.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_fc.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_fc.png new file mode 100644 index 0000000..8034140 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_fc.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_fd.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_fd.png new file mode 100644 index 0000000..c31bd6f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_fd.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_fe.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_fe.png new file mode 100644 index 0000000..42ed33e --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_fe.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/font/unicode_page_ff.png b/src/main/resources/assets/minecraft/textures/font/unicode_page_ff.png new file mode 100644 index 0000000..f0ff742 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/font/unicode_page_ff.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/gui/achievement/achievement_background.png b/src/main/resources/assets/minecraft/textures/gui/achievement/achievement_background.png new file mode 100644 index 0000000..921bce0 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/gui/achievement/achievement_background.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/gui/achievement/achievement_icons.png b/src/main/resources/assets/minecraft/textures/gui/achievement/achievement_icons.png new file mode 100644 index 0000000..8c4ae79 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/gui/achievement/achievement_icons.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/gui/book.png b/src/main/resources/assets/minecraft/textures/gui/book.png new file mode 100644 index 0000000..3e4ba4e --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/gui/book.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/gui/container/anvil.png b/src/main/resources/assets/minecraft/textures/gui/container/anvil.png new file mode 100644 index 0000000..34e8f9f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/gui/container/anvil.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/gui/container/beacon.png b/src/main/resources/assets/minecraft/textures/gui/container/beacon.png new file mode 100644 index 0000000..f51a2ef --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/gui/container/beacon.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/gui/container/brewing_stand.png b/src/main/resources/assets/minecraft/textures/gui/container/brewing_stand.png new file mode 100644 index 0000000..e7dc203 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/gui/container/brewing_stand.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/gui/container/crafting_table.png b/src/main/resources/assets/minecraft/textures/gui/container/crafting_table.png new file mode 100644 index 0000000..254dacc --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/gui/container/crafting_table.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/gui/container/creative_inventory/tab_inventory.png b/src/main/resources/assets/minecraft/textures/gui/container/creative_inventory/tab_inventory.png new file mode 100644 index 0000000..c8d53a6 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/gui/container/creative_inventory/tab_inventory.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/gui/container/creative_inventory/tab_item_search.png b/src/main/resources/assets/minecraft/textures/gui/container/creative_inventory/tab_item_search.png new file mode 100644 index 0000000..cc250e5 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/gui/container/creative_inventory/tab_item_search.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/gui/container/creative_inventory/tab_items.png b/src/main/resources/assets/minecraft/textures/gui/container/creative_inventory/tab_items.png new file mode 100644 index 0000000..38421f7 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/gui/container/creative_inventory/tab_items.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/gui/container/creative_inventory/tabs.png b/src/main/resources/assets/minecraft/textures/gui/container/creative_inventory/tabs.png new file mode 100644 index 0000000..1c44093 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/gui/container/creative_inventory/tabs.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/gui/container/dispenser.png b/src/main/resources/assets/minecraft/textures/gui/container/dispenser.png new file mode 100644 index 0000000..0a6ebe7 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/gui/container/dispenser.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/gui/container/enchanting_table.png b/src/main/resources/assets/minecraft/textures/gui/container/enchanting_table.png new file mode 100644 index 0000000..59aeb04 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/gui/container/enchanting_table.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/gui/container/furnace.png b/src/main/resources/assets/minecraft/textures/gui/container/furnace.png new file mode 100644 index 0000000..2255d0a --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/gui/container/furnace.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/gui/container/generic_54.png b/src/main/resources/assets/minecraft/textures/gui/container/generic_54.png new file mode 100644 index 0000000..0b880ef --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/gui/container/generic_54.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/gui/container/hopper.png b/src/main/resources/assets/minecraft/textures/gui/container/hopper.png new file mode 100644 index 0000000..3d00547 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/gui/container/hopper.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/gui/container/horse.png b/src/main/resources/assets/minecraft/textures/gui/container/horse.png new file mode 100644 index 0000000..194cc6b --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/gui/container/horse.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/gui/container/inventory.png b/src/main/resources/assets/minecraft/textures/gui/container/inventory.png new file mode 100644 index 0000000..d553c4f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/gui/container/inventory.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/gui/container/stats_icons.png b/src/main/resources/assets/minecraft/textures/gui/container/stats_icons.png new file mode 100644 index 0000000..f13323b --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/gui/container/stats_icons.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/gui/container/villager.png b/src/main/resources/assets/minecraft/textures/gui/container/villager.png new file mode 100644 index 0000000..3211a7a --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/gui/container/villager.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/gui/demo_background.png b/src/main/resources/assets/minecraft/textures/gui/demo_background.png new file mode 100644 index 0000000..a7fd8be --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/gui/demo_background.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/gui/icons.png b/src/main/resources/assets/minecraft/textures/gui/icons.png new file mode 100644 index 0000000..89d780f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/gui/icons.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/gui/options_background.png b/src/main/resources/assets/minecraft/textures/gui/options_background.png new file mode 100644 index 0000000..cae5528 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/gui/options_background.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/gui/resource_packs.png b/src/main/resources/assets/minecraft/textures/gui/resource_packs.png new file mode 100644 index 0000000..15a80bd --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/gui/resource_packs.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/gui/title/background/panorama_0.png b/src/main/resources/assets/minecraft/textures/gui/title/background/panorama_0.png new file mode 100644 index 0000000..27f015d --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/gui/title/background/panorama_0.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/gui/title/background/panorama_1.png b/src/main/resources/assets/minecraft/textures/gui/title/background/panorama_1.png new file mode 100644 index 0000000..c16841a --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/gui/title/background/panorama_1.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/gui/title/background/panorama_2.png b/src/main/resources/assets/minecraft/textures/gui/title/background/panorama_2.png new file mode 100644 index 0000000..0436d77 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/gui/title/background/panorama_2.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/gui/title/background/panorama_3.png b/src/main/resources/assets/minecraft/textures/gui/title/background/panorama_3.png new file mode 100644 index 0000000..2c7ad77 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/gui/title/background/panorama_3.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/gui/title/background/panorama_4.png b/src/main/resources/assets/minecraft/textures/gui/title/background/panorama_4.png new file mode 100644 index 0000000..0390096 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/gui/title/background/panorama_4.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/gui/title/background/panorama_5.png b/src/main/resources/assets/minecraft/textures/gui/title/background/panorama_5.png new file mode 100644 index 0000000..0331ad4 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/gui/title/background/panorama_5.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/gui/title/minecraft.png b/src/main/resources/assets/minecraft/textures/gui/title/minecraft.png new file mode 100644 index 0000000..c60927b --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/gui/title/minecraft.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/gui/title/mojang.png b/src/main/resources/assets/minecraft/textures/gui/title/mojang.png new file mode 100644 index 0000000..ba394db --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/gui/title/mojang.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/gui/widgets.png b/src/main/resources/assets/minecraft/textures/gui/widgets.png new file mode 100644 index 0000000..2a749c8 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/gui/widgets.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/apple.png b/src/main/resources/assets/minecraft/textures/items/apple.png new file mode 100644 index 0000000..3e2ee59 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/apple.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/apple_golden.png b/src/main/resources/assets/minecraft/textures/items/apple_golden.png new file mode 100644 index 0000000..6201989 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/apple_golden.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/arrow.png b/src/main/resources/assets/minecraft/textures/items/arrow.png new file mode 100644 index 0000000..4f748a0 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/arrow.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/bed.png b/src/main/resources/assets/minecraft/textures/items/bed.png new file mode 100644 index 0000000..22a4cf0 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/bed.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/beef_cooked.png b/src/main/resources/assets/minecraft/textures/items/beef_cooked.png new file mode 100644 index 0000000..a1c765a --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/beef_cooked.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/beef_raw.png b/src/main/resources/assets/minecraft/textures/items/beef_raw.png new file mode 100644 index 0000000..82af4e7 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/beef_raw.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/blaze_powder.png b/src/main/resources/assets/minecraft/textures/items/blaze_powder.png new file mode 100644 index 0000000..89c57d6 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/blaze_powder.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/blaze_rod.png b/src/main/resources/assets/minecraft/textures/items/blaze_rod.png new file mode 100644 index 0000000..7050e10 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/blaze_rod.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/boat.png b/src/main/resources/assets/minecraft/textures/items/boat.png new file mode 100644 index 0000000..235e0a2 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/boat.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/bone.png b/src/main/resources/assets/minecraft/textures/items/bone.png new file mode 100644 index 0000000..3faca89 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/bone.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/book_enchanted.png b/src/main/resources/assets/minecraft/textures/items/book_enchanted.png new file mode 100644 index 0000000..44215f6 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/book_enchanted.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/book_normal.png b/src/main/resources/assets/minecraft/textures/items/book_normal.png new file mode 100644 index 0000000..f791ae4 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/book_normal.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/book_writable.png b/src/main/resources/assets/minecraft/textures/items/book_writable.png new file mode 100644 index 0000000..fa95246 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/book_writable.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/book_written.png b/src/main/resources/assets/minecraft/textures/items/book_written.png new file mode 100644 index 0000000..b2a2aa8 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/book_written.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/bow_pulling_0.png b/src/main/resources/assets/minecraft/textures/items/bow_pulling_0.png new file mode 100644 index 0000000..2022aab --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/bow_pulling_0.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/bow_pulling_1.png b/src/main/resources/assets/minecraft/textures/items/bow_pulling_1.png new file mode 100644 index 0000000..a132079 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/bow_pulling_1.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/bow_pulling_2.png b/src/main/resources/assets/minecraft/textures/items/bow_pulling_2.png new file mode 100644 index 0000000..d459e68 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/bow_pulling_2.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/bow_standby.png b/src/main/resources/assets/minecraft/textures/items/bow_standby.png new file mode 100644 index 0000000..d709b9c --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/bow_standby.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/bowl.png b/src/main/resources/assets/minecraft/textures/items/bowl.png new file mode 100644 index 0000000..63d16ad --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/bowl.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/bread.png b/src/main/resources/assets/minecraft/textures/items/bread.png new file mode 100644 index 0000000..c833604 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/bread.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/brewing_stand.png b/src/main/resources/assets/minecraft/textures/items/brewing_stand.png new file mode 100644 index 0000000..97db9af --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/brewing_stand.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/brick.png b/src/main/resources/assets/minecraft/textures/items/brick.png new file mode 100644 index 0000000..11e74be --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/brick.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/bucket_empty.png b/src/main/resources/assets/minecraft/textures/items/bucket_empty.png new file mode 100644 index 0000000..f8e5369 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/bucket_empty.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/bucket_lava.png b/src/main/resources/assets/minecraft/textures/items/bucket_lava.png new file mode 100644 index 0000000..13a1957 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/bucket_lava.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/bucket_milk.png b/src/main/resources/assets/minecraft/textures/items/bucket_milk.png new file mode 100644 index 0000000..c77d92c --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/bucket_milk.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/bucket_water.png b/src/main/resources/assets/minecraft/textures/items/bucket_water.png new file mode 100644 index 0000000..2f36acc --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/bucket_water.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/cake.png b/src/main/resources/assets/minecraft/textures/items/cake.png new file mode 100644 index 0000000..46e94b8 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/cake.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/carrot.png b/src/main/resources/assets/minecraft/textures/items/carrot.png new file mode 100644 index 0000000..2d08aab --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/carrot.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/carrot_golden.png b/src/main/resources/assets/minecraft/textures/items/carrot_golden.png new file mode 100644 index 0000000..e0f1ea6 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/carrot_golden.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/carrot_on_a_stick.png b/src/main/resources/assets/minecraft/textures/items/carrot_on_a_stick.png new file mode 100644 index 0000000..9e88571 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/carrot_on_a_stick.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/cauldron.png b/src/main/resources/assets/minecraft/textures/items/cauldron.png new file mode 100644 index 0000000..e3186eb --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/cauldron.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/chainmail_boots.png b/src/main/resources/assets/minecraft/textures/items/chainmail_boots.png new file mode 100644 index 0000000..54a4a15 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/chainmail_boots.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/chainmail_chestplate.png b/src/main/resources/assets/minecraft/textures/items/chainmail_chestplate.png new file mode 100644 index 0000000..cd2115a --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/chainmail_chestplate.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/chainmail_helmet.png b/src/main/resources/assets/minecraft/textures/items/chainmail_helmet.png new file mode 100644 index 0000000..a143338 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/chainmail_helmet.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/chainmail_leggings.png b/src/main/resources/assets/minecraft/textures/items/chainmail_leggings.png new file mode 100644 index 0000000..dae4b26 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/chainmail_leggings.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/charcoal.png b/src/main/resources/assets/minecraft/textures/items/charcoal.png new file mode 100644 index 0000000..20d5b25 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/charcoal.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/chicken_cooked.png b/src/main/resources/assets/minecraft/textures/items/chicken_cooked.png new file mode 100644 index 0000000..890b5b3 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/chicken_cooked.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/chicken_raw.png b/src/main/resources/assets/minecraft/textures/items/chicken_raw.png new file mode 100644 index 0000000..6d25922 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/chicken_raw.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/clay_ball.png b/src/main/resources/assets/minecraft/textures/items/clay_ball.png new file mode 100644 index 0000000..5103d6c --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/clay_ball.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/clock.png b/src/main/resources/assets/minecraft/textures/items/clock.png new file mode 100644 index 0000000..069a0ab --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/clock.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/clock.png.mcmeta b/src/main/resources/assets/minecraft/textures/items/clock.png.mcmeta new file mode 100644 index 0000000..4f0718a --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/clock.png.mcmeta @@ -0,0 +1,3 @@ +{ + "animation": {} +} \ No newline at end of file diff --git a/src/main/resources/assets/minecraft/textures/items/coal.png b/src/main/resources/assets/minecraft/textures/items/coal.png new file mode 100644 index 0000000..5563b6f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/coal.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/comparator.png b/src/main/resources/assets/minecraft/textures/items/comparator.png new file mode 100644 index 0000000..28b8eec --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/comparator.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/compass.png b/src/main/resources/assets/minecraft/textures/items/compass.png new file mode 100644 index 0000000..9dcbdfe --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/compass.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/compass.png.mcmeta b/src/main/resources/assets/minecraft/textures/items/compass.png.mcmeta new file mode 100644 index 0000000..4f0718a --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/compass.png.mcmeta @@ -0,0 +1,3 @@ +{ + "animation": {} +} \ No newline at end of file diff --git a/src/main/resources/assets/minecraft/textures/items/cookie.png b/src/main/resources/assets/minecraft/textures/items/cookie.png new file mode 100644 index 0000000..01fe56b --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/cookie.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/diamond.png b/src/main/resources/assets/minecraft/textures/items/diamond.png new file mode 100644 index 0000000..10e70a0 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/diamond.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/diamond_axe.png b/src/main/resources/assets/minecraft/textures/items/diamond_axe.png new file mode 100644 index 0000000..7627f87 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/diamond_axe.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/diamond_boots.png b/src/main/resources/assets/minecraft/textures/items/diamond_boots.png new file mode 100644 index 0000000..70d9e5f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/diamond_boots.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/diamond_chestplate.png b/src/main/resources/assets/minecraft/textures/items/diamond_chestplate.png new file mode 100644 index 0000000..afdff93 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/diamond_chestplate.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/diamond_helmet.png b/src/main/resources/assets/minecraft/textures/items/diamond_helmet.png new file mode 100644 index 0000000..1c88592 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/diamond_helmet.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/diamond_hoe.png b/src/main/resources/assets/minecraft/textures/items/diamond_hoe.png new file mode 100644 index 0000000..c9a97e0 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/diamond_hoe.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/diamond_horse_armor.png b/src/main/resources/assets/minecraft/textures/items/diamond_horse_armor.png new file mode 100644 index 0000000..b281aad --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/diamond_horse_armor.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/diamond_leggings.png b/src/main/resources/assets/minecraft/textures/items/diamond_leggings.png new file mode 100644 index 0000000..a99c896 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/diamond_leggings.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/diamond_pickaxe.png b/src/main/resources/assets/minecraft/textures/items/diamond_pickaxe.png new file mode 100644 index 0000000..c279828 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/diamond_pickaxe.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/diamond_shovel.png b/src/main/resources/assets/minecraft/textures/items/diamond_shovel.png new file mode 100644 index 0000000..e4a8992 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/diamond_shovel.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/diamond_sword.png b/src/main/resources/assets/minecraft/textures/items/diamond_sword.png new file mode 100644 index 0000000..2a1552d --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/diamond_sword.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/door_iron.png b/src/main/resources/assets/minecraft/textures/items/door_iron.png new file mode 100644 index 0000000..67877ab --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/door_iron.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/door_wood.png b/src/main/resources/assets/minecraft/textures/items/door_wood.png new file mode 100644 index 0000000..750307f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/door_wood.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/dye_powder_black.png b/src/main/resources/assets/minecraft/textures/items/dye_powder_black.png new file mode 100644 index 0000000..909bea5 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/dye_powder_black.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/dye_powder_blue.png b/src/main/resources/assets/minecraft/textures/items/dye_powder_blue.png new file mode 100644 index 0000000..4713983 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/dye_powder_blue.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/dye_powder_brown.png b/src/main/resources/assets/minecraft/textures/items/dye_powder_brown.png new file mode 100644 index 0000000..62eae8d --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/dye_powder_brown.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/dye_powder_cyan.png b/src/main/resources/assets/minecraft/textures/items/dye_powder_cyan.png new file mode 100644 index 0000000..7b10c11 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/dye_powder_cyan.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/dye_powder_gray.png b/src/main/resources/assets/minecraft/textures/items/dye_powder_gray.png new file mode 100644 index 0000000..4fce7e7 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/dye_powder_gray.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/dye_powder_green.png b/src/main/resources/assets/minecraft/textures/items/dye_powder_green.png new file mode 100644 index 0000000..009e058 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/dye_powder_green.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/dye_powder_light_blue.png b/src/main/resources/assets/minecraft/textures/items/dye_powder_light_blue.png new file mode 100644 index 0000000..a8b45c9 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/dye_powder_light_blue.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/dye_powder_lime.png b/src/main/resources/assets/minecraft/textures/items/dye_powder_lime.png new file mode 100644 index 0000000..7a78764 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/dye_powder_lime.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/dye_powder_magenta.png b/src/main/resources/assets/minecraft/textures/items/dye_powder_magenta.png new file mode 100644 index 0000000..ea7342a --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/dye_powder_magenta.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/dye_powder_orange.png b/src/main/resources/assets/minecraft/textures/items/dye_powder_orange.png new file mode 100644 index 0000000..677a1aa --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/dye_powder_orange.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/dye_powder_pink.png b/src/main/resources/assets/minecraft/textures/items/dye_powder_pink.png new file mode 100644 index 0000000..1acc483 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/dye_powder_pink.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/dye_powder_purple.png b/src/main/resources/assets/minecraft/textures/items/dye_powder_purple.png new file mode 100644 index 0000000..7d201c2 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/dye_powder_purple.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/dye_powder_red.png b/src/main/resources/assets/minecraft/textures/items/dye_powder_red.png new file mode 100644 index 0000000..2d1a742 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/dye_powder_red.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/dye_powder_silver.png b/src/main/resources/assets/minecraft/textures/items/dye_powder_silver.png new file mode 100644 index 0000000..fa9e501 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/dye_powder_silver.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/dye_powder_white.png b/src/main/resources/assets/minecraft/textures/items/dye_powder_white.png new file mode 100644 index 0000000..5b1833b --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/dye_powder_white.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/dye_powder_yellow.png b/src/main/resources/assets/minecraft/textures/items/dye_powder_yellow.png new file mode 100644 index 0000000..95e0673 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/dye_powder_yellow.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/egg.png b/src/main/resources/assets/minecraft/textures/items/egg.png new file mode 100644 index 0000000..a6fe2bf --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/egg.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/emerald.png b/src/main/resources/assets/minecraft/textures/items/emerald.png new file mode 100644 index 0000000..98d953e --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/emerald.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/empty_armor_slot_boots.png b/src/main/resources/assets/minecraft/textures/items/empty_armor_slot_boots.png new file mode 100644 index 0000000..fd7e05f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/empty_armor_slot_boots.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/empty_armor_slot_chestplate.png b/src/main/resources/assets/minecraft/textures/items/empty_armor_slot_chestplate.png new file mode 100644 index 0000000..6e632b9 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/empty_armor_slot_chestplate.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/empty_armor_slot_helmet.png b/src/main/resources/assets/minecraft/textures/items/empty_armor_slot_helmet.png new file mode 100644 index 0000000..3a455f3 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/empty_armor_slot_helmet.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/empty_armor_slot_leggings.png b/src/main/resources/assets/minecraft/textures/items/empty_armor_slot_leggings.png new file mode 100644 index 0000000..28b2c49 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/empty_armor_slot_leggings.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/ender_eye.png b/src/main/resources/assets/minecraft/textures/items/ender_eye.png new file mode 100644 index 0000000..8c4ef4e --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/ender_eye.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/ender_pearl.png b/src/main/resources/assets/minecraft/textures/items/ender_pearl.png new file mode 100644 index 0000000..4b752a6 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/ender_pearl.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/experience_bottle.png b/src/main/resources/assets/minecraft/textures/items/experience_bottle.png new file mode 100644 index 0000000..ae4214f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/experience_bottle.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/feather.png b/src/main/resources/assets/minecraft/textures/items/feather.png new file mode 100644 index 0000000..d4c3be5 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/feather.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/fireball.png b/src/main/resources/assets/minecraft/textures/items/fireball.png new file mode 100644 index 0000000..d62a6f4 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/fireball.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/fireworks.png b/src/main/resources/assets/minecraft/textures/items/fireworks.png new file mode 100644 index 0000000..f1e07fd --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/fireworks.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/fireworks_charge.png b/src/main/resources/assets/minecraft/textures/items/fireworks_charge.png new file mode 100644 index 0000000..43a4a21 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/fireworks_charge.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/fireworks_charge_overlay.png b/src/main/resources/assets/minecraft/textures/items/fireworks_charge_overlay.png new file mode 100644 index 0000000..d8b91a9 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/fireworks_charge_overlay.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/fish_clownfish_raw.png b/src/main/resources/assets/minecraft/textures/items/fish_clownfish_raw.png new file mode 100644 index 0000000..41df72f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/fish_clownfish_raw.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/fish_cod_cooked.png b/src/main/resources/assets/minecraft/textures/items/fish_cod_cooked.png new file mode 100644 index 0000000..87564c7 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/fish_cod_cooked.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/fish_cod_raw.png b/src/main/resources/assets/minecraft/textures/items/fish_cod_raw.png new file mode 100644 index 0000000..32996bf --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/fish_cod_raw.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/fish_pufferfish_raw.png b/src/main/resources/assets/minecraft/textures/items/fish_pufferfish_raw.png new file mode 100644 index 0000000..aadbd88 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/fish_pufferfish_raw.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/fish_salmon_cooked.png b/src/main/resources/assets/minecraft/textures/items/fish_salmon_cooked.png new file mode 100644 index 0000000..fb765ed --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/fish_salmon_cooked.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/fish_salmon_raw.png b/src/main/resources/assets/minecraft/textures/items/fish_salmon_raw.png new file mode 100644 index 0000000..68bcd69 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/fish_salmon_raw.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/fishing_rod_cast.png b/src/main/resources/assets/minecraft/textures/items/fishing_rod_cast.png new file mode 100644 index 0000000..a5ab378 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/fishing_rod_cast.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/fishing_rod_uncast.png b/src/main/resources/assets/minecraft/textures/items/fishing_rod_uncast.png new file mode 100644 index 0000000..d4b53f0 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/fishing_rod_uncast.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/flint.png b/src/main/resources/assets/minecraft/textures/items/flint.png new file mode 100644 index 0000000..5f51093 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/flint.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/flint_and_steel.png b/src/main/resources/assets/minecraft/textures/items/flint_and_steel.png new file mode 100644 index 0000000..77bc340 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/flint_and_steel.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/flower_pot.png b/src/main/resources/assets/minecraft/textures/items/flower_pot.png new file mode 100644 index 0000000..c4f26d2 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/flower_pot.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/ghast_tear.png b/src/main/resources/assets/minecraft/textures/items/ghast_tear.png new file mode 100644 index 0000000..e5c741f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/ghast_tear.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/glowstone_dust.png b/src/main/resources/assets/minecraft/textures/items/glowstone_dust.png new file mode 100644 index 0000000..edd93a6 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/glowstone_dust.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/gold_axe.png b/src/main/resources/assets/minecraft/textures/items/gold_axe.png new file mode 100644 index 0000000..0f47b60 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/gold_axe.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/gold_boots.png b/src/main/resources/assets/minecraft/textures/items/gold_boots.png new file mode 100644 index 0000000..f6033d2 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/gold_boots.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/gold_chestplate.png b/src/main/resources/assets/minecraft/textures/items/gold_chestplate.png new file mode 100644 index 0000000..e36076a --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/gold_chestplate.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/gold_helmet.png b/src/main/resources/assets/minecraft/textures/items/gold_helmet.png new file mode 100644 index 0000000..9eb89a0 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/gold_helmet.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/gold_hoe.png b/src/main/resources/assets/minecraft/textures/items/gold_hoe.png new file mode 100644 index 0000000..1685d47 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/gold_hoe.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/gold_horse_armor.png b/src/main/resources/assets/minecraft/textures/items/gold_horse_armor.png new file mode 100644 index 0000000..7c5c3a5 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/gold_horse_armor.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/gold_ingot.png b/src/main/resources/assets/minecraft/textures/items/gold_ingot.png new file mode 100644 index 0000000..ea781e7 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/gold_ingot.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/gold_leggings.png b/src/main/resources/assets/minecraft/textures/items/gold_leggings.png new file mode 100644 index 0000000..da23771 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/gold_leggings.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/gold_nugget.png b/src/main/resources/assets/minecraft/textures/items/gold_nugget.png new file mode 100644 index 0000000..3a9a2fe --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/gold_nugget.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/gold_pickaxe.png b/src/main/resources/assets/minecraft/textures/items/gold_pickaxe.png new file mode 100644 index 0000000..ecccafe --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/gold_pickaxe.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/gold_shovel.png b/src/main/resources/assets/minecraft/textures/items/gold_shovel.png new file mode 100644 index 0000000..150cbb9 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/gold_shovel.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/gold_sword.png b/src/main/resources/assets/minecraft/textures/items/gold_sword.png new file mode 100644 index 0000000..0ddef04 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/gold_sword.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/gunpowder.png b/src/main/resources/assets/minecraft/textures/items/gunpowder.png new file mode 100644 index 0000000..73cadec --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/gunpowder.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/hopper.png b/src/main/resources/assets/minecraft/textures/items/hopper.png new file mode 100644 index 0000000..f8b244f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/hopper.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/iron_axe.png b/src/main/resources/assets/minecraft/textures/items/iron_axe.png new file mode 100644 index 0000000..8bf133e --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/iron_axe.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/iron_boots.png b/src/main/resources/assets/minecraft/textures/items/iron_boots.png new file mode 100644 index 0000000..b69ca05 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/iron_boots.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/iron_chestplate.png b/src/main/resources/assets/minecraft/textures/items/iron_chestplate.png new file mode 100644 index 0000000..e7993ce --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/iron_chestplate.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/iron_helmet.png b/src/main/resources/assets/minecraft/textures/items/iron_helmet.png new file mode 100644 index 0000000..65e64cc --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/iron_helmet.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/iron_hoe.png b/src/main/resources/assets/minecraft/textures/items/iron_hoe.png new file mode 100644 index 0000000..28d4c36 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/iron_hoe.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/iron_horse_armor.png b/src/main/resources/assets/minecraft/textures/items/iron_horse_armor.png new file mode 100644 index 0000000..5d697d1 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/iron_horse_armor.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/iron_ingot.png b/src/main/resources/assets/minecraft/textures/items/iron_ingot.png new file mode 100644 index 0000000..3833fa0 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/iron_ingot.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/iron_leggings.png b/src/main/resources/assets/minecraft/textures/items/iron_leggings.png new file mode 100644 index 0000000..ad53673 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/iron_leggings.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/iron_pickaxe.png b/src/main/resources/assets/minecraft/textures/items/iron_pickaxe.png new file mode 100644 index 0000000..d21440b --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/iron_pickaxe.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/iron_shovel.png b/src/main/resources/assets/minecraft/textures/items/iron_shovel.png new file mode 100644 index 0000000..079b236 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/iron_shovel.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/iron_sword.png b/src/main/resources/assets/minecraft/textures/items/iron_sword.png new file mode 100644 index 0000000..4d49c5a --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/iron_sword.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/item_frame.png b/src/main/resources/assets/minecraft/textures/items/item_frame.png new file mode 100644 index 0000000..261c98a --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/item_frame.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/lead.png b/src/main/resources/assets/minecraft/textures/items/lead.png new file mode 100644 index 0000000..0ef5312 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/lead.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/leather.png b/src/main/resources/assets/minecraft/textures/items/leather.png new file mode 100644 index 0000000..13dc199 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/leather.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/leather_boots.png b/src/main/resources/assets/minecraft/textures/items/leather_boots.png new file mode 100644 index 0000000..31c2132 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/leather_boots.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/leather_boots_overlay.png b/src/main/resources/assets/minecraft/textures/items/leather_boots_overlay.png new file mode 100644 index 0000000..b6896d8 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/leather_boots_overlay.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/leather_chestplate.png b/src/main/resources/assets/minecraft/textures/items/leather_chestplate.png new file mode 100644 index 0000000..e534aef --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/leather_chestplate.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/leather_chestplate_overlay.png b/src/main/resources/assets/minecraft/textures/items/leather_chestplate_overlay.png new file mode 100644 index 0000000..125fd34 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/leather_chestplate_overlay.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/leather_helmet.png b/src/main/resources/assets/minecraft/textures/items/leather_helmet.png new file mode 100644 index 0000000..da2cfa8 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/leather_helmet.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/leather_helmet_overlay.png b/src/main/resources/assets/minecraft/textures/items/leather_helmet_overlay.png new file mode 100644 index 0000000..8040d77 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/leather_helmet_overlay.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/leather_leggings.png b/src/main/resources/assets/minecraft/textures/items/leather_leggings.png new file mode 100644 index 0000000..3ff24ee --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/leather_leggings.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/leather_leggings_overlay.png b/src/main/resources/assets/minecraft/textures/items/leather_leggings_overlay.png new file mode 100644 index 0000000..813ba26 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/leather_leggings_overlay.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/magma_cream.png b/src/main/resources/assets/minecraft/textures/items/magma_cream.png new file mode 100644 index 0000000..b2be210 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/magma_cream.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/map_empty.png b/src/main/resources/assets/minecraft/textures/items/map_empty.png new file mode 100644 index 0000000..8dc6e58 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/map_empty.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/map_filled.png b/src/main/resources/assets/minecraft/textures/items/map_filled.png new file mode 100644 index 0000000..1381e21 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/map_filled.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/melon.png b/src/main/resources/assets/minecraft/textures/items/melon.png new file mode 100644 index 0000000..590f47a --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/melon.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/melon_speckled.png b/src/main/resources/assets/minecraft/textures/items/melon_speckled.png new file mode 100644 index 0000000..dee1bf5 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/melon_speckled.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/minecart_chest.png b/src/main/resources/assets/minecraft/textures/items/minecart_chest.png new file mode 100644 index 0000000..78a3778 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/minecart_chest.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/minecart_command_block.png b/src/main/resources/assets/minecraft/textures/items/minecart_command_block.png new file mode 100644 index 0000000..c597ee7 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/minecart_command_block.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/minecart_furnace.png b/src/main/resources/assets/minecraft/textures/items/minecart_furnace.png new file mode 100644 index 0000000..5478f25 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/minecart_furnace.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/minecart_hopper.png b/src/main/resources/assets/minecraft/textures/items/minecart_hopper.png new file mode 100644 index 0000000..8a138fb --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/minecart_hopper.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/minecart_normal.png b/src/main/resources/assets/minecraft/textures/items/minecart_normal.png new file mode 100644 index 0000000..2046f2b --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/minecart_normal.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/minecart_tnt.png b/src/main/resources/assets/minecraft/textures/items/minecart_tnt.png new file mode 100644 index 0000000..561279b --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/minecart_tnt.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/mushroom_stew.png b/src/main/resources/assets/minecraft/textures/items/mushroom_stew.png new file mode 100644 index 0000000..5598bc7 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/mushroom_stew.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/name_tag.png b/src/main/resources/assets/minecraft/textures/items/name_tag.png new file mode 100644 index 0000000..a88f559 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/name_tag.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/nether_star.png b/src/main/resources/assets/minecraft/textures/items/nether_star.png new file mode 100644 index 0000000..6b848af --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/nether_star.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/nether_wart.png b/src/main/resources/assets/minecraft/textures/items/nether_wart.png new file mode 100644 index 0000000..09da1e3 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/nether_wart.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/netherbrick.png b/src/main/resources/assets/minecraft/textures/items/netherbrick.png new file mode 100644 index 0000000..e9c14ed --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/netherbrick.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/painting.png b/src/main/resources/assets/minecraft/textures/items/painting.png new file mode 100644 index 0000000..b394f30 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/painting.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/paper.png b/src/main/resources/assets/minecraft/textures/items/paper.png new file mode 100644 index 0000000..a1d9c7e --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/paper.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/porkchop_cooked.png b/src/main/resources/assets/minecraft/textures/items/porkchop_cooked.png new file mode 100644 index 0000000..605d3f5 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/porkchop_cooked.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/porkchop_raw.png b/src/main/resources/assets/minecraft/textures/items/porkchop_raw.png new file mode 100644 index 0000000..7e83c1a --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/porkchop_raw.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/potato.png b/src/main/resources/assets/minecraft/textures/items/potato.png new file mode 100644 index 0000000..c1d8541 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/potato.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/potato_baked.png b/src/main/resources/assets/minecraft/textures/items/potato_baked.png new file mode 100644 index 0000000..e4d765b --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/potato_baked.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/potato_poisonous.png b/src/main/resources/assets/minecraft/textures/items/potato_poisonous.png new file mode 100644 index 0000000..6f154af --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/potato_poisonous.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/potion_bottle_drinkable.png b/src/main/resources/assets/minecraft/textures/items/potion_bottle_drinkable.png new file mode 100644 index 0000000..87339d7 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/potion_bottle_drinkable.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/potion_bottle_empty.png b/src/main/resources/assets/minecraft/textures/items/potion_bottle_empty.png new file mode 100644 index 0000000..87339d7 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/potion_bottle_empty.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/potion_bottle_splash.png b/src/main/resources/assets/minecraft/textures/items/potion_bottle_splash.png new file mode 100644 index 0000000..03b1f90 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/potion_bottle_splash.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/potion_overlay.png b/src/main/resources/assets/minecraft/textures/items/potion_overlay.png new file mode 100644 index 0000000..1e6165e --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/potion_overlay.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/pumpkin_pie.png b/src/main/resources/assets/minecraft/textures/items/pumpkin_pie.png new file mode 100644 index 0000000..c21a032 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/pumpkin_pie.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/quartz.png b/src/main/resources/assets/minecraft/textures/items/quartz.png new file mode 100644 index 0000000..e403446 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/quartz.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/quiver.png b/src/main/resources/assets/minecraft/textures/items/quiver.png new file mode 100644 index 0000000..818f728 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/quiver.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/record_11.png b/src/main/resources/assets/minecraft/textures/items/record_11.png new file mode 100644 index 0000000..07ac487 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/record_11.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/record_13.png b/src/main/resources/assets/minecraft/textures/items/record_13.png new file mode 100644 index 0000000..ead0c61 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/record_13.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/record_blocks.png b/src/main/resources/assets/minecraft/textures/items/record_blocks.png new file mode 100644 index 0000000..3732d6c --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/record_blocks.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/record_cat.png b/src/main/resources/assets/minecraft/textures/items/record_cat.png new file mode 100644 index 0000000..b3527ef --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/record_cat.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/record_chirp.png b/src/main/resources/assets/minecraft/textures/items/record_chirp.png new file mode 100644 index 0000000..1b24e11 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/record_chirp.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/record_far.png b/src/main/resources/assets/minecraft/textures/items/record_far.png new file mode 100644 index 0000000..2320efd --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/record_far.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/record_mall.png b/src/main/resources/assets/minecraft/textures/items/record_mall.png new file mode 100644 index 0000000..811d046 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/record_mall.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/record_mellohi.png b/src/main/resources/assets/minecraft/textures/items/record_mellohi.png new file mode 100644 index 0000000..879b6a4 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/record_mellohi.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/record_stal.png b/src/main/resources/assets/minecraft/textures/items/record_stal.png new file mode 100644 index 0000000..c650d21 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/record_stal.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/record_strad.png b/src/main/resources/assets/minecraft/textures/items/record_strad.png new file mode 100644 index 0000000..72d6e32 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/record_strad.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/record_wait.png b/src/main/resources/assets/minecraft/textures/items/record_wait.png new file mode 100644 index 0000000..5306b51 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/record_wait.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/record_ward.png b/src/main/resources/assets/minecraft/textures/items/record_ward.png new file mode 100644 index 0000000..b33b93d --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/record_ward.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/redstone_dust.png b/src/main/resources/assets/minecraft/textures/items/redstone_dust.png new file mode 100644 index 0000000..6da938b --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/redstone_dust.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/reeds.png b/src/main/resources/assets/minecraft/textures/items/reeds.png new file mode 100644 index 0000000..40872c6 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/reeds.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/repeater.png b/src/main/resources/assets/minecraft/textures/items/repeater.png new file mode 100644 index 0000000..7a07381 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/repeater.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/rotten_flesh.png b/src/main/resources/assets/minecraft/textures/items/rotten_flesh.png new file mode 100644 index 0000000..3f39998 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/rotten_flesh.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/ruby.png b/src/main/resources/assets/minecraft/textures/items/ruby.png new file mode 100644 index 0000000..4f288d9 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/ruby.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/saddle.png b/src/main/resources/assets/minecraft/textures/items/saddle.png new file mode 100644 index 0000000..b12eafa --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/saddle.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/seeds_melon.png b/src/main/resources/assets/minecraft/textures/items/seeds_melon.png new file mode 100644 index 0000000..ef84499 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/seeds_melon.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/seeds_pumpkin.png b/src/main/resources/assets/minecraft/textures/items/seeds_pumpkin.png new file mode 100644 index 0000000..8d8f076 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/seeds_pumpkin.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/seeds_wheat.png b/src/main/resources/assets/minecraft/textures/items/seeds_wheat.png new file mode 100644 index 0000000..83d23a6 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/seeds_wheat.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/shears.png b/src/main/resources/assets/minecraft/textures/items/shears.png new file mode 100644 index 0000000..f9c6de1 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/shears.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/sign.png b/src/main/resources/assets/minecraft/textures/items/sign.png new file mode 100644 index 0000000..9b6e2ee --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/sign.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/skull_creeper.png b/src/main/resources/assets/minecraft/textures/items/skull_creeper.png new file mode 100644 index 0000000..c195fd5 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/skull_creeper.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/skull_skeleton.png b/src/main/resources/assets/minecraft/textures/items/skull_skeleton.png new file mode 100644 index 0000000..bf383fc --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/skull_skeleton.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/skull_steve.png b/src/main/resources/assets/minecraft/textures/items/skull_steve.png new file mode 100644 index 0000000..e56f406 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/skull_steve.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/skull_wither.png b/src/main/resources/assets/minecraft/textures/items/skull_wither.png new file mode 100644 index 0000000..3571603 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/skull_wither.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/skull_zombie.png b/src/main/resources/assets/minecraft/textures/items/skull_zombie.png new file mode 100644 index 0000000..67d1347 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/skull_zombie.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/slimeball.png b/src/main/resources/assets/minecraft/textures/items/slimeball.png new file mode 100644 index 0000000..46478ee --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/slimeball.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/snowball.png b/src/main/resources/assets/minecraft/textures/items/snowball.png new file mode 100644 index 0000000..340c639 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/snowball.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/spawn_egg.png b/src/main/resources/assets/minecraft/textures/items/spawn_egg.png new file mode 100644 index 0000000..23259c7 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/spawn_egg.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/spawn_egg_overlay.png b/src/main/resources/assets/minecraft/textures/items/spawn_egg_overlay.png new file mode 100644 index 0000000..83ec78f --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/spawn_egg_overlay.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/spider_eye.png b/src/main/resources/assets/minecraft/textures/items/spider_eye.png new file mode 100644 index 0000000..35d8584 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/spider_eye.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/spider_eye_fermented.png b/src/main/resources/assets/minecraft/textures/items/spider_eye_fermented.png new file mode 100644 index 0000000..226ffb8 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/spider_eye_fermented.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/stick.png b/src/main/resources/assets/minecraft/textures/items/stick.png new file mode 100644 index 0000000..6f8ce13 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/stick.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/stone_axe.png b/src/main/resources/assets/minecraft/textures/items/stone_axe.png new file mode 100644 index 0000000..fb33584 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/stone_axe.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/stone_hoe.png b/src/main/resources/assets/minecraft/textures/items/stone_hoe.png new file mode 100644 index 0000000..d46b272 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/stone_hoe.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/stone_pickaxe.png b/src/main/resources/assets/minecraft/textures/items/stone_pickaxe.png new file mode 100644 index 0000000..19a8e50 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/stone_pickaxe.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/stone_shovel.png b/src/main/resources/assets/minecraft/textures/items/stone_shovel.png new file mode 100644 index 0000000..8e1c0c2 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/stone_shovel.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/stone_sword.png b/src/main/resources/assets/minecraft/textures/items/stone_sword.png new file mode 100644 index 0000000..5810dfd --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/stone_sword.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/string.png b/src/main/resources/assets/minecraft/textures/items/string.png new file mode 100644 index 0000000..0b04ddb --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/string.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/sugar.png b/src/main/resources/assets/minecraft/textures/items/sugar.png new file mode 100644 index 0000000..0864df9 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/sugar.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/wheat.png b/src/main/resources/assets/minecraft/textures/items/wheat.png new file mode 100644 index 0000000..bbd2fd9 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/wheat.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/wood_axe.png b/src/main/resources/assets/minecraft/textures/items/wood_axe.png new file mode 100644 index 0000000..3a19203 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/wood_axe.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/wood_hoe.png b/src/main/resources/assets/minecraft/textures/items/wood_hoe.png new file mode 100644 index 0000000..de1c7a6 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/wood_hoe.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/wood_pickaxe.png b/src/main/resources/assets/minecraft/textures/items/wood_pickaxe.png new file mode 100644 index 0000000..ebc6756 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/wood_pickaxe.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/wood_shovel.png b/src/main/resources/assets/minecraft/textures/items/wood_shovel.png new file mode 100644 index 0000000..b057911 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/wood_shovel.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/items/wood_sword.png b/src/main/resources/assets/minecraft/textures/items/wood_sword.png new file mode 100644 index 0000000..c04dc0a --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/items/wood_sword.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/map/map_background.png b/src/main/resources/assets/minecraft/textures/map/map_background.png new file mode 100644 index 0000000..2783b50 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/map/map_background.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/map/map_icons.png b/src/main/resources/assets/minecraft/textures/map/map_icons.png new file mode 100644 index 0000000..c2f35b8 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/map/map_icons.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/misc/enchanted_item_glint.png b/src/main/resources/assets/minecraft/textures/misc/enchanted_item_glint.png new file mode 100644 index 0000000..f9ca97c --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/misc/enchanted_item_glint.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/misc/enchanted_item_glint.png.mcmeta b/src/main/resources/assets/minecraft/textures/misc/enchanted_item_glint.png.mcmeta new file mode 100644 index 0000000..e38a5ad --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/misc/enchanted_item_glint.png.mcmeta @@ -0,0 +1,5 @@ +{ + "texture": { + "blur": true + } +} diff --git a/src/main/resources/assets/minecraft/textures/misc/pumpkinblur.png b/src/main/resources/assets/minecraft/textures/misc/pumpkinblur.png new file mode 100644 index 0000000..d9725ce --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/misc/pumpkinblur.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/misc/pumpkinblur.png.mcmeta b/src/main/resources/assets/minecraft/textures/misc/pumpkinblur.png.mcmeta new file mode 100644 index 0000000..2077f3c --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/misc/pumpkinblur.png.mcmeta @@ -0,0 +1,6 @@ +{ + "texture": { + "blur": true + } +} + diff --git a/src/main/resources/assets/minecraft/textures/misc/shadow.png b/src/main/resources/assets/minecraft/textures/misc/shadow.png new file mode 100644 index 0000000..b09fd47 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/misc/shadow.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/misc/shadow.png.mcmeta b/src/main/resources/assets/minecraft/textures/misc/shadow.png.mcmeta new file mode 100644 index 0000000..8c6c7d1 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/misc/shadow.png.mcmeta @@ -0,0 +1,6 @@ +{ + "texture": { + "clamp": true + } +} + diff --git a/src/main/resources/assets/minecraft/textures/misc/underwater.png b/src/main/resources/assets/minecraft/textures/misc/underwater.png new file mode 100644 index 0000000..2fc23b1 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/misc/underwater.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/misc/unknown_pack.png b/src/main/resources/assets/minecraft/textures/misc/unknown_pack.png new file mode 100644 index 0000000..16afade --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/misc/unknown_pack.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/misc/vignette.png b/src/main/resources/assets/minecraft/textures/misc/vignette.png new file mode 100644 index 0000000..9c14e2d --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/misc/vignette.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/misc/vignette.png.mcmeta b/src/main/resources/assets/minecraft/textures/misc/vignette.png.mcmeta new file mode 100644 index 0000000..2077f3c --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/misc/vignette.png.mcmeta @@ -0,0 +1,6 @@ +{ + "texture": { + "blur": true + } +} + diff --git a/src/main/resources/assets/minecraft/textures/models/armor/chainmail_layer_1.png b/src/main/resources/assets/minecraft/textures/models/armor/chainmail_layer_1.png new file mode 100644 index 0000000..9f84c18 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/models/armor/chainmail_layer_1.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/models/armor/chainmail_layer_2.png b/src/main/resources/assets/minecraft/textures/models/armor/chainmail_layer_2.png new file mode 100644 index 0000000..117811c --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/models/armor/chainmail_layer_2.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/models/armor/diamond_layer_1.png b/src/main/resources/assets/minecraft/textures/models/armor/diamond_layer_1.png new file mode 100644 index 0000000..14fecf2 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/models/armor/diamond_layer_1.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/models/armor/diamond_layer_2.png b/src/main/resources/assets/minecraft/textures/models/armor/diamond_layer_2.png new file mode 100644 index 0000000..2cca056 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/models/armor/diamond_layer_2.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/models/armor/gold_layer_1.png b/src/main/resources/assets/minecraft/textures/models/armor/gold_layer_1.png new file mode 100644 index 0000000..6802e06 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/models/armor/gold_layer_1.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/models/armor/gold_layer_2.png b/src/main/resources/assets/minecraft/textures/models/armor/gold_layer_2.png new file mode 100644 index 0000000..a7cf835 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/models/armor/gold_layer_2.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/models/armor/iron_layer_1.png b/src/main/resources/assets/minecraft/textures/models/armor/iron_layer_1.png new file mode 100644 index 0000000..6da6e84 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/models/armor/iron_layer_1.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/models/armor/iron_layer_2.png b/src/main/resources/assets/minecraft/textures/models/armor/iron_layer_2.png new file mode 100644 index 0000000..fab422a --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/models/armor/iron_layer_2.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/models/armor/leather_layer_1.png b/src/main/resources/assets/minecraft/textures/models/armor/leather_layer_1.png new file mode 100644 index 0000000..ebcfc41 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/models/armor/leather_layer_1.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/models/armor/leather_layer_1_overlay.png b/src/main/resources/assets/minecraft/textures/models/armor/leather_layer_1_overlay.png new file mode 100644 index 0000000..546397d --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/models/armor/leather_layer_1_overlay.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/models/armor/leather_layer_2.png b/src/main/resources/assets/minecraft/textures/models/armor/leather_layer_2.png new file mode 100644 index 0000000..8d8bba6 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/models/armor/leather_layer_2.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/models/armor/leather_layer_2_overlay.png b/src/main/resources/assets/minecraft/textures/models/armor/leather_layer_2_overlay.png new file mode 100644 index 0000000..5655659 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/models/armor/leather_layer_2_overlay.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/painting/paintings_kristoffer_zetterstrand.png b/src/main/resources/assets/minecraft/textures/painting/paintings_kristoffer_zetterstrand.png new file mode 100644 index 0000000..d7df7f6 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/painting/paintings_kristoffer_zetterstrand.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/particle/footprint.png b/src/main/resources/assets/minecraft/textures/particle/footprint.png new file mode 100644 index 0000000..8d23f64 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/particle/footprint.png Binary files differ diff --git a/src/main/resources/assets/minecraft/textures/particle/particles.png b/src/main/resources/assets/minecraft/textures/particle/particles.png new file mode 100644 index 0000000..eec1f89 --- /dev/null +++ b/src/main/resources/assets/minecraft/textures/particle/particles.png Binary files differ diff --git a/src/main/resources/deobfuscation_data-1.7.2.lzma b/src/main/resources/deobfuscation_data-1.7.2.lzma new file mode 100644 index 0000000..53a8676 --- /dev/null +++ b/src/main/resources/deobfuscation_data-1.7.2.lzma Binary files differ diff --git a/src/main/resources/fml.exc b/src/main/resources/fml.exc new file mode 100644 index 0000000..860fdd9 --- /dev/null +++ b/src/main/resources/fml.exc @@ -0,0 +1 @@ +net/minecraft/server/management/ServerConfigurationManager.initializeConnectionToPlayer(Lnet/minecraft/network/NetworkManager;Lnet/minecraft/entity/player/EntityPlayerMP;Lnet/minecraft/network/NetHandlerPlayServer;)V=|p_72355_1_,p_72355_2_,nethandlerplayserver diff --git a/src/main/resources/fml.srg b/src/main/resources/fml.srg new file mode 100644 index 0000000..e8eb7d4 --- /dev/null +++ b/src/main/resources/fml.srg @@ -0,0 +1 @@ +MD: net/minecraft/server/management/ServerConfigurationManager/initializeConnectionToPlayer (Lnet/minecraft/network/NetworkManager;Lnet/minecraft/entity/player/EntityPlayerMP;Lnet/minecraft/network/NetHandlerPlayServer;)V net/minecraft/server/management/ServerConfigurationManager/func_72355_a (Lnet/minecraft/network/NetworkManager;Lnet/minecraft/entity/player/EntityPlayerMP;Lnet/minecraft/network/NetHandlerPlayServer;)V diff --git a/src/main/resources/fml_at.cfg b/src/main/resources/fml_at.cfg new file mode 100644 index 0000000..8b54a7f --- /dev/null +++ b/src/main/resources/fml_at.cfg @@ -0,0 +1,87 @@ +#Main FML Access Transformer configuration file +# TileEntity addMapping +public net.minecraft.tileentity.TileEntity func_145826_a(Ljava/lang/Class;Ljava/lang/String;)V +# EntityList addMappings +public net.minecraft.entity.EntityList func_75618_a(Ljava/lang/Class;Ljava/lang/String;I)V +public net.minecraft.entity.EntityList func_75614_a(Ljava/lang/Class;Ljava/lang/String;III)V +public net.minecraft.entity.EntityList field_75625_b #nameToClassMap +public net.minecraft.entity.EntityList field_75626_c #classToNameMap +public net.minecraft.entity.EntityList field_75623_d #idToClassMap +## RenderManager +public net.minecraft.client.renderer.entity.RenderManager field_78729_o #renderers +## RenderBlocks - everything +public net.minecraft.client.renderer.RenderBlocks * # all fields +public net.minecraft.client.renderer.RenderBlocks *() # all methods +##RenderPlayer +##public-f bht.h #FD:RenderPlayer/field_77110_j #armorlist # -- MISSING MAPPING +##RenderBiped +public-f net.minecraft.client.renderer.entity.RenderBiped field_82424_k #armorlist +##StringTranslate +##public bp.b #FD:StringTranslate/field_74815_b # -- MISSING MAPPING +##public bp.e #FD:StringTranslate/field_74813_d # -- MISSING MAPPING +## TileEntityRendererDispatcher +public net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher field_147559_m +## CraftingManager - make the add recipe methods public +public net.minecraft.item.crafting.CraftingManager func_92103_a(Lnet.minecraft.item.ItemStack;[Ljava/lang/Object;)Lnet.minecraft.item.crafting.ShapedRecipes; +public net.minecraft.item.crafting.CraftingManager func_77596_b(Lnet.minecraft.item.ItemStack;[Ljava/lang/Object;)V +## WeightedRandomItem +public net.minecraft.util.WeightedRandom$Item field_76292_a #probability +## ItemStack +##public+f tv.c #FD:ItemStack/field_77993_c #itemId +## StatBase +#public ku.a #FD:StatBase/field_75978_a #statName +## NetLoginHandler +#public jy.a(Ljy;Z)Z #MD:NetLoginHandler/func_72531_a #'complete connection' +#public jy.g #FD:NetLoginHandler/field_72543_h #userName +## EntityPlayerMP getNextWindowId +public net.minecraft.entity.player.EntityPlayerMP func_71117_bO()V +public net.minecraft.entity.player.EntityPlayerMP field_71139_cq +## EntityAITaskEntry +public net.minecraft.entity.ai.EntityAITasks$EntityAITaskEntry +## EntityAITasks +#public pt.a #FD:EntityAITasks/field_75782_a #taskList +## BlockChest +#public ank.m(Labw;III)Z #MD:BlockChest/func_72292_n #isOcelotBlockingChest +## EntityLiving +##public ng.aU #FD:EntityLiving/field_70736_aM #carryoverDamage # -- MISSING MAPPING +public net.minecraft.entity.EntityLiving field_70714_bg #tasks +public net.minecraft.entity.EntityLiving field_70715_bh #targetTasks +##public ng.bG #FD:EntityLiving/field_70703_bu #isJumping # -- MISSING MAPPING +## EntityAIOcelotSit +#protected qg.a(Labw;III)Z #MD:EntityAIOcelotSit/func_75398_a #nearestSittableBlock +#protected qg.f()Z #MD:EntityAIOcelotSit/func_75399_f #isblocksittable +## CallableMinecraftVersion - sanity check the MC version +#public c #CL:CallableMinecraftVersion +#public c.(Lb;)V #MD:CallableMinecraftVersion/(Lnet/minecraft/src/CrashReport;) #constructor +## EntityAnimal +#public rp.bp #FD:EntityAnimal/field_70881_d #inLove +## WorldType +#public acg.(ILjava/lang/String;)V #MD:WorldType/(ILjava/lang/String;) +#public acg.(ILjava/lang/String;I)V #MD:WorldType/(ILjava/lang/String;I) +## ComponentVillage +#public ajm #CL:ComponentVillage +## StructureStart +#public aiv.a #FD:StructureStart/field_75075_a +## EntityVillager - minmax lists +public net.minecraft.entity.passive.EntityVillager func_146091_a(Lnet/minecraft/village/MerchantRecipeList;Lnet/minecraft/item/Item;Ljava/util/Random;F)V # buy +public net.minecraft.entity.passive.EntityVillager func_146089_b(Lnet/minecraft/village/MerchantRecipeList;Lnet/minecraft/item/Item;Ljava/util/Random;F)V # sell +public net.minecraft.entity.passive.EntityVillager field_70958_bB +public net.minecraft.entity.passive.EntityVillager field_70960_bC +## GuiButtonMerchant +#public axx #CL:GuiButtonMerchant +# GuiScreen +public net.minecraft.client.gui.GuiScreen field_146297_k # minecraft instance - public because gui's outside access it +# Minecraft +#public atv.D #FD:Minecraft/field_71425_J #running +public net.minecraft.client.Minecraft field_71446_o # textureManager +## ItemBlock +public net.minecraft.item.ItemBlock field_150939_a +## DedicatedServer +public net.minecraft.server.dedicated.DedicatedServer field_71341_l # pendingCommandList +## SaveFormatOld +public net.minecraft.world.storage.SaveFormatOld field_75808_a # savesDirectory + +protected net.minecraft.util.ObjectIntIdentityMap field_148749_a # internal map +protected net.minecraft.util.ObjectIntIdentityMap field_148748_b # internal index list +protected-f net.minecraft.util.RegistryNamespaced field_148759_a # identitymap +protected net.minecraft.util.RegistryNamespaced func_148755_c(Ljava/lang/String;)Ljava/lang/String; # prefix if necessary diff --git a/src/main/resources/fml_marker.cfg b/src/main/resources/fml_marker.cfg new file mode 100644 index 0000000..bfd4e92 --- /dev/null +++ b/src/main/resources/fml_marker.cfg @@ -0,0 +1,3 @@ +# Marker interfaces to add to minecraft - helps in bukkit and client/server unification +# Only runs at runtime because it's not necessary at compile time +# has deobf and obf mappings so it runs OK in mcp diff --git a/src/main/resources/fmlversion.properties b/src/main/resources/fmlversion.properties new file mode 100644 index 0000000..527bb1f --- /dev/null +++ b/src/main/resources/fmlversion.properties @@ -0,0 +1,6 @@ +fmlbuild.major.number=7 +fmlbuild.minor.number=2 +fmlbuild.revision.number=156 +fmlbuild.build.number=0 +fmlbuild.mcversion=1.7.2 +fmlbuild.mcpversion=9.01-pre diff --git a/src/main/resources/forge.exc b/src/main/resources/forge.exc new file mode 100644 index 0000000..8a3c3af --- /dev/null +++ b/src/main/resources/forge.exc @@ -0,0 +1,12 @@ +net/minecraft/client/particle/EntityDiggingFX.(Lnet/minecraft/world/World;DDDDDDLnet/minecraft/block/Block;II)V=|p_i1234_1_,p_i1234_2_,p_i1234_4_,p_i1234_6_,p_i1234_8_,p_i1234_10_,p_i1234_12_,p_i1234_14_,p_i1234_15_,side +net/minecraft/client/renderer/ItemRenderer.renderItem(Lnet/minecraft/entity/EntityLivingBase;Lnet/minecraft/item/ItemStack;ILnet/minecraftforge/client/IItemRenderer$ItemRenderType;)V=|p_78443_1_,p_78443_2_,p_78443_3_,type +net/minecraft/client/renderer/RenderGlobal.drawBlockDamageTexture(Lnet/minecraft/client/renderer/Tessellator;Lnet/minecraft/entity/EntityLivingBase;F)V=|p_72717_1_,p_72717_2_,p_72717_3_ +net/minecraft/client/renderer/entity/RenderItem.renderDroppedItem(Lnet/minecraft/entity/item/EntityItem;Lnet/minecraft/util/IIcon;IFFFFI)V=|p_77020_1_,p_77020_2_,p_77020_3_,p_77020_4_,p_77020_5_,p_77020_6_,p_77020_7_,pass +net/minecraft/client/renderer/entity/RenderItem.renderItemIntoGUI(Lnet/minecraft/client/gui/FontRenderer;Lnet/minecraft/client/renderer/texture/TextureManager;Lnet/minecraft/item/ItemStack;IIZ)V=|p_77015_1_,p_77015_2_,p_77015_3_,p_77015_4_,p_77015_5_,renderEffect +net/minecraft/server/management/ServerConfigurationManager.transferPlayerToDimension(Lnet/minecraft/entity/player/EntityPlayerMP;ILnet/minecraft/world/Teleporter;)V=|p_72356_1_,p_72356_2_,teleporter +net/minecraft/server/management/ServerConfigurationManager.transferEntityToWorld(Lnet/minecraft/entity/Entity;ILnet/minecraft/world/WorldServer;Lnet/minecraft/world/WorldServer;Lnet/minecraft/world/Teleporter;)V=|p_82448_1_,p_82448_2_,p_82448_3_,p_82448_4_,teleporter +net/minecraft/world/World.getBiomeGenForCoordsBody(II)Lnet/minecraft/world/biome/BiomeGenBase;=|p_72807_1_,p_72807_2_ +net/minecraft/world/World.getSkyColorBody(Lnet/minecraft/entity/Entity;F)Lnet/minecraft/util/Vec3;=|p_72833_1_,p_72833_2_ +net/minecraft/world/World.drawCloudsBody(F)Lnet/minecraft/util/Vec3;=|p_72824_1_ +net/minecraft/world/World.canBlockFreezeBody(IIIZ)Z=|p_72834_1_,p_72834_2_,p_72834_3_,p_72834_4_ +net/minecraft/world/biome/BiomeGenBase.(IZ)V=|p_i1971_1_,register diff --git a/src/main/resources/forge_at.cfg b/src/main/resources/forge_at.cfg new file mode 100644 index 0000000..984c702 --- /dev/null +++ b/src/main/resources/forge_at.cfg @@ -0,0 +1,181 @@ +#Main Forge Access Transformer configuration file +# Tessellator +#public-f bfq.a #FD:Tessellator/field_78398_a #instance +#public bfq.u #FD:Tessellator/field_78409_u #drawMode +#public bfq.v #FD:Tessellator/field_78408_v #xOffset +#public bfq.w #FD:Tessellator/field_78407_w #yOffset +#public bfq.x #FD:Tessellator/field_78417_x #zOffset +#public bfq.z #FD:Tessellator/field_78415_z #isDrawing +# ItemPickaxe +public net.minecraft.item.ItemPickaxe (Lnet.minecraft.item.Item$ToolMaterial;) +public net.minecraft.item.ItemAxe (Lnet.minecraft.item.Item$ToolMaterial;) +public net.minecraft.item.ItemSpade (Lnet.minecraft.item.Item$ToolMaterial;) +# ItemTool +#public xj.a #FD:ItemTool/field_77864_a #efficiencyOnProperMaterial +#public xj.d #FD:ItemTool/field_77865_bY #damageVsEntity +# EntityEnderman +#public tg.br #FD:EntityEnderman/field_70827_d #carriableBlocks +# RenderGlobal +#public bfl.k #FD:RenderGlobal/field_72769_h #theWorld +#public bfl.l #FD:RenderGlobal/field_72770_i #renderEngine +#public bfl.t #FD:RenderGlobal/field_72777_q #mc +#public bfl.u #FD:RenderGlobal/field_72776_r #globalRenderBlocks +#public bfl.H #FD:RenderGlobal/field_72738_E #damagedBlocks +# SoundManager +public net.minecraft.client.audio.SoundManager field_148622_c #sndHandler +# EntityMinecart +#protected st.* #FD:EntityMinecart/* # All private -> protected +# Block +public net.minecraft.block.Block (Lnet/minecraft/src/Material;)V +public net.minecraft.block.Block func_149658_d(Ljava/lang/String;)Lnet.minecraft.block.Block; #setIconName +public net.minecraft.block.Block func_149672_a(Lnet.minecraft.block.Block$SoundType;)Lnet.minecraft.block.Block; #setStepSound +public net.minecraft.block.Block func_149752_b(F)Lnet.minecraft.block.Block; #setResistance +public net.minecraft.block.Block func_149711_c(F)Lnet.minecraft.block.Block; #setHardness +public net.minecraft.block.Block func_149713_g(I)Lnet.minecraft.block.Block; #setLightOpacity +public net.minecraft.block.Block func_149715_a(F)Lnet.minecraft.block.Block; #setLightValue +public net.minecraft.block.Block func_149722_s()Lnet.minecraft.block.Block; #setBlockUnbreakable +public net.minecraft.block.Block func_149675_a(Z)Lnet.minecraft.block.Block; #setTickRandomly +public net.minecraft.block.Block func_149676_a(FFFFFF)V #setBlockBounds +public net.minecraft.block.Block func_149657_c(Lnet/minecraft/world/World;IIII)V # dropXpOnBlockBreak +# NetServerHandler +#public ka.f #FD:NetServerHandler/field_72572_g #playerInAirTime +# TileEntity +#public asp.k #FD:TileEntity/field_70331_k #worldObj +# BlockLeavesBase +#public arh.d #FD:BlockLeavesBase/field_72131_c #graphicsLevel +# Item +public net.minecraft.item.Item func_77656_e(I)Lnet.minecraft.item.Item; #setMaxDamage +public-f net.minecraft.item.Item func_77650_f(Lnet.minecraft.item.ItemStack;)Lnet.minecraft.util.IIcon; #getIcon is Final for unknown reason +public net.minecraft.item.Item func_77627_a(Z)Lnet.minecraft.item.Item; #setHasSubtypes +public net.minecraft.item.Item func_77631_c(Ljava.lang.String;)Lnet.minecraft.item.Item; #setPotionEffect +public net.minecraft.item.Item func_111206_d(Ljava.lang.String;)Lnet.minecraft.item.Item; #setTextureName +# RailLogic +#public amz #CL:BlockBaseRailLogic +#public amz.a()I #MD:BlockBaseRailLogic/func_94505_a #getNAdjacentTiles +# EntityPlayer +public net.minecraft.entity.player.EntityPlayer func_71012_a(Lnet/minecraft/entity/item/EntityItem;)V #joinEntityItemWithWorld +public net.minecraft.client.entity.EntityClientPlayerMP func_71012_a(Lnet/minecraft/entity/item/EntityItem;)V #joinEntityItemWithWorld +public net.minecraft.entity.player.EntityPlayer func_71053_j()V #closeScreen +#public uf.b #FD:EntityPlayer/field_71076_b #sleepTimer +# World Gen Chests Related +public net.minecraft.util.WeightedRandomChestContent * +public net.minecraft.world.WorldServer field_73069_S +public net.minecraft.world.gen.structure.StructureMineshaftPieces field_78818_a +public net.minecraft.world.gen.structure.ComponentScatteredFeaturePieces$DesertPyramid field_74941_i +public net.minecraft.world.gen.structure.ComponentScatteredFeaturePieces$JunglePyramid field_74943_l +public net.minecraft.world.gen.structure.ComponentScatteredFeaturePieces$JunglePyramid field_74944_m +public net.minecraft.world.gen.structure.StructureStrongholdPieces$ChestCorridor field_75003_a +public net.minecraft.world.gen.structure.StructureStrongholdPieces$Library field_75007_b +public net.minecraft.world.gen.structure.StructureStrongholdPieces$RoomCrossing field_75014_c +public net.minecraft.world.gen.structure.StructureVillagePieces$House2 field_74918_a +public net.minecraft.world.gen.feature.WorldGenDungeons field_111189_a +# Save Location +public net.minecraft.world.chunk.storage.AnvilChunkLoader field_75825_d # chunkSaveLocation +public net.minecraft.world.gen.ChunkProviderServer field_73247_e # currentChunkLoader +# PlayerManager +#public jp.a(IIZ)Ljq; #MD:PlayerManager/func_72690_a #getOrCreateChunkWatcher +# PlayerInstance +#public jq #CL:PlayerInstance +# World +public-f net.minecraft.world.World field_72982_D #villageCollectionObj +#public abw.G #FD:World/field_72993_I #activeChunkSet +# EntityLiving +#public og.b #FD:EntityLiving/field_70728_aV #experienceValue +#public og.d #FD:EntityLiving/field_70715_bh #targetTasks +# GuiFlatPresets +#public avz.a(Ljava/lang/String;ILacq;Ljava/util/List;[Lagd;)V #MD:GuiFlatPresets/func_82294_a +#public avz.a(Ljava/lang/String;ILacq;[Lagd;)V #MD:GuiFlatPresets/func_82297_a +# BiomeGenBase +public net.minecraft.world.biome.BiomeGenBase *() #Everything protected->public +public net.minecraft.world.biome.BiomeGenForest *() +public net.minecraft.world.biome.BiomeGenHills *() +public net.minecraft.world.biome.BiomeGenMesa *() +public net.minecraft.world.biome.BiomeGenPlains *() +public net.minecraft.world.biome.BiomeGenSavanna *() +public net.minecraft.world.biome.BiomeGenSnow *() +public net.minecraft.world.biome.BiomeGenTaiga *() +# Map Gen Biome Lists +public+f net.minecraft.world.gen.structure.MapGenStronghold field_151546_e +# MapGenVillage +public-f net.minecraft.world.gen.structure.MapGenVillage field_75055_e #villageSpawnBiomes +# ShapedRecipes +public+f net.minecraft.item.crafting.ShapedRecipes field_77574_d #recipeItems +public+f net.minecraft.item.crafting.ShapedRecipes field_77576_b #recipeWidth +public+f net.minecraft.item.crafting.ShapedRecipes field_77577_c #recipeHeight +# ShapelessRecipes +public net.minecraft.item.crafting.ShapelessRecipes field_77579_b #recipeItems +# GuiContainer +#protected awy.a(Lwe;)V #MD:GuiContainer/func_74192_a #drawSlotInventory +# ContainerPlayer +#protected vv.h #FD:ContainerPlayer/field_82862_h #player +# BlockButton +#protected anf.n(Labw;III)V #MD:BlockButton/func_82535_o #checkActivation +#protected-f anf.a #FD:BlockButton/field_82537_a #sensible +# BiomeDecorator +public net.minecraft.world.biome.BiomeDecorator * +# CreativeTabs +public-f net.minecraft.creativetab.CreativeTabs field_78032_a # creativeTabArray non-final +# Packet +#public ey.a(IZZLjava/lang/Class;)V #MD:Packet/func_73285_a #addIdClassMapping +# SaveHandler +#public alq.b()Ljava/io/File; #MD:SaveHandler/func_75765_b +# World stuff +public net.minecraft.world.World field_73003_n #prevRainingStrength +public net.minecraft.world.World field_73004_o #rainingStrength +public net.minecraft.world.World field_73017_q #thunderingStrength +public net.minecraft.world.World field_73018_p #prevThunderingStrength +public net.minecraft.world.World func_72923_a(Lnet/minecraft/entity/Entity;)V #onEntityAdded +public net.minecraft.world.World func_72847_b(Lnet/minecraft/entity/Entity;)V #onEntityRemoved +public net.minecraft.world.WorldServer func_72923_a(Lnet/minecraft/entity/Entity;)V #onEntityAdded +public net.minecraft.world.WorldServer func_72847_b(Lnet/minecraft/entity/Entity;)V #onEntityRemoved +public net.minecraft.client.multiplayer.WorldClient func_72923_a(Lnet/minecraft/entity/Entity;)V #onEntityAdded +public net.minecraft.client.multiplayer.WorldClient func_72847_b(Lnet/minecraft/entity/Entity;)V #onEntityRemoved +# WorldServer +#public js.N #FD:WorldServer/field_73068_P #allPlayersSleeping +# TextureMap +#public bik.g #FD:TextureMap/field_94255_a +#public bik.h #FD:TextureMap/field_94254_c +# Potion +#public ni.b(II)Lni; #MD:Potion/func_76399_b #setIconIndex +# PotionHelper +#public zp.m #FD:PotionHelper/field_77927_l #potionRequirements +#public zp.n #FD:PotionHelper/field_77928_m #potionAmplifiers +# PotionEffect +#public nj.b #FD:PotionEffect/field_76460_b #duration +# BlockFluid +#protected apc.a #FD:BlockFluid/field_94425_a #theIcon +# GuiIngame +protected net.minecraft.client.gui.GuiIngame * +protected net.minecraft.client.gui.GuiIngame *() +# ItemStack +default net.minecraft.item.ItemStack field_77991_e +# GuiSlot +#protected awg.b(IIII)V #MD:GuiSlot/func_77206_b #overlayBackground +# EntityPlayer +#public uf.bu #FD:EntityPlayer/field_71092_bJ #username +# MapGenStructureIO +public net.minecraft.world.gen.structure.MapGenStructureIO func_143034_b(Ljava/lang/Class;Ljava/lang/String;)V # registerStart +public net.minecraft.world.gen.structure.MapGenStructureIO func_143031_a(Ljava/lang/Class;Ljava/lang/String;)V # registerPiece +# Stronghold +public net.minecraft.world.gen.structure.StructureStrongholdPieces$Stronghold +# Packets +public net.minecraft.network.play.server.S23PacketBlockChange field_148883_d # Block +public net.minecraft.network.play.server.S23PacketBlockChange field_148884_e # Metadata +# WorldType +public-f net.minecraft.world.WorldType field_77139_a #worldTypes +# DamageSource +public net.minecraft.util.DamageSource *() #All methods public, most are already +# ItemBlock +public net.minecraft.item.ItemBlock field_150939_a # block +# EntityAITasks +public net.minecraft.entity.ai.EntityAITasks field_75782_a # taskEntries +# EntityXPOrb +public net.minecraft.entity.item.EntityXPOrb field_70530_e # xpValue +# Village +public net.minecraft.world.gen.structure.StructureVillagePieces$Village +# RenderPlayer +public net.minecraft.client.renderer.entity.RenderBiped field_77071_a #modelBipedMain +public net.minecraft.client.renderer.entity.RenderPlayer field_77109_a #modelBipedMain +public net.minecraft.client.renderer.entity.RenderPlayer field_77108_b #modelArmorChestplate +public net.minecraft.client.renderer.entity.RenderPlayer field_77111_i #modelArmor + diff --git a/src/main/resources/forge_logo.png b/src/main/resources/forge_logo.png new file mode 100644 index 0000000..19a02ca --- /dev/null +++ b/src/main/resources/forge_logo.png Binary files differ diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml new file mode 100644 index 0000000..482e65a --- /dev/null +++ b/src/main/resources/log4j2.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/mcplogo.png b/src/main/resources/mcplogo.png new file mode 100644 index 0000000..8ebae88 --- /dev/null +++ b/src/main/resources/mcplogo.png Binary files differ diff --git a/src/main/resources/mcpmod.info b/src/main/resources/mcpmod.info new file mode 100644 index 0000000..67862bc --- /dev/null +++ b/src/main/resources/mcpmod.info @@ -0,0 +1,17 @@ +[ +{ + "modid": "mcp", + "name": "Minecraft Coder Pack", + "description": "Modding toolkit to decompile and deobfuscate the Minecraft client and server files.", + "version": "8.09", + "mcversion": "1.6.3", + "logoFile": "/mcplogo.png", + "url": "http://mcp.ocean-labs.de/", + "updateUrl": "", + "authors": ["Searge", "ProfMobius", "IngisKahn", "Fesh0r", "ZeuX", "R4wk", "Others"], + "credits": "Made by the MCP team", + "parent": "", + "screenshots": [], + "dependencies": [] +} +] diff --git a/src/main/resources/pack.png b/src/main/resources/pack.png new file mode 100644 index 0000000..cfaa986 --- /dev/null +++ b/src/main/resources/pack.png Binary files differ diff --git a/src/main/resources/templates/release-notes.vm b/src/main/resources/templates/release-notes.vm new file mode 100644 index 0000000..51b0da2 --- /dev/null +++ b/src/main/resources/templates/release-notes.vm @@ -0,0 +1,136 @@ +## Licensed to the Apache Software Foundation (ASF) under one +## or more contributor license agreements. See the NOTICE file +## distributed with this work for additional information +## regarding copyright ownership. The ASF licenses this file +## to you under the Apache License, Version 2.0 (the +## "License"); you may not use this file except in compliance +## with the License. You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, +## software distributed under the License is distributed on an +## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +## KIND, either express or implied. See the License for the +## specific language governing permissions and limitations +## under the License. + + Apache ${project.name} Package + Version ${version} + Release Notes + + +INTRODUCTION: + +This document contains the release notes for the 3.0.1 version of Apache Commons Lang. +Commons Lang is a set of utility functions and reusable components that should be of use in any +Java environment. + +Lang 3.0 and onwards now targets Java 5.0, making use of features that arrived with Java 5.0 such as generics, +variable arguments, autoboxing, concurrency and formatted output. + +For the advice on upgrading from 2.x to 3.x, see the following page: + + http://commons.apache.org/lang/article3_0.html + +## Hack to improve layout: replace all pairs of spaces with a single new-line +##$release.description.replaceAll(" ", " +##") + +#if ($release.getActions().size() == 0) +No changes defined in this version. +#else +Changes in this version include: + +#if ($release.getActions('add').size() !=0) +New features: +#foreach($actionItem in $release.getActions('add')) +#set($action=$actionItem.getAction()) +#if ($actionItem.getIssue()) +#set($issue=$actionItem.getIssue()) +#else +#set($issue="") +#end +#if ($actionItem.getDueTo()) +#set($dueto=$actionItem.getDueTo()) +#else +#set($dueto="") +#end +o#if($!issue != "") $issue: #end ${action} #if($!dueto != "")Thanks to $dueto. #end + +#set($issue="") +#set($dueto="") +#end +#end + +#if ($release.getActions('fix').size() !=0) +Fixed Bugs: +#foreach($actionItem in $release.getActions('fix')) +#set($action=$actionItem.getAction()) +#if ($actionItem.getIssue()) +#set($issue=$actionItem.getIssue()) +#else +#set($issue="") +#end +#if ($actionItem.getDueTo()) +#set($dueto=$actionItem.getDueTo()) +#else +#set($dueto="") +#end +o#if($!issue != "") $issue: #end ${action} #if($!dueto != "")Thanks to $dueto. #end + +#set($issue="") +#set($dueto="") +#end +#end + +#if ($release.getActions('update').size() !=0) +Changes: +#foreach($actionItem in $release.getActions('update')) +#set($action=$actionItem.getAction()) +#if ($actionItem.getIssue()) +#set($issue=$actionItem.getIssue()) +#else +#set($issue="") +#end +#if ($actionItem.getDueTo()) +#set($dueto=$actionItem.getDueTo()) +#else +#set($dueto="") +#end +o#if($!issue != "") $issue: #end ${action} #if($!dueto != "")Thanks to $dueto. #end + +#set($issue="") +#set($dueto="") +#end +#end + +#if ($release.getActions('remove').size() !=0) +Removed: +#foreach($actionItem in $release.getActions('remove')) +#set($action=$actionItem.getAction()) +#if ($actionItem.getIssue()) +#set($issue=$actionItem.getIssue()) +#else +#set($issue="") +#end +#if ($actionItem.getDueTo()) +#set($dueto=$actionItem.getDueTo()) +#else +#set($dueto="") +#end +o#if($!issue != "") $issue: #end ${action} #if($!dueto != "")Thanks to $dueto. #end + +#set($issue="") +#set($dueto="") +#end +#end +## End of main loop +#end + +For complete information on ${project.name}, including instructions on how to submit bug reports, +patches, or suggestions for improvement, see the Apache ${project.name} website: + +${project.url} + +